/copilot-clone

VSCode extension for code suggestion

Primary LanguageTypeScript

Captain Stack

Captain Stack — Code suggestion for VSCode

This feature is somewhat similar to Github Copilot's code suggestion. But instead of using AI, it sends your search query to Google, then retrieves StackOverflow answers and autocompletes them for you.

Captain Stack is launched on Product Hunt and would appricate your support

Captain Stack - An open source alternative to GitHub Copilot | Product Hunt

Demo Video

Table of contents:

  1. Installation
  2. Play with Captain Stack
  3. Notes
  4. Changelog

Note: ⚠️ This extension uses a proposed API (inline-completion) and can only be used for extension development in VSCode Insider release. It's not yet available on VSCode


1. Installation

Before installation, make sure you have VSCode Insider. You'll be using this version

To install and starting Captain Stack:

  1. Download this repository to your local machine
  2. Run npm install in the terminal to install dependencies. A postinstall script would download the latest version of vscode.proposed.d.ts
  3. Run the Run Extension target in the Debug View. Or from the top menu, choose Run > Start Debugging.

This will:

  • Start a task npm: watch to compile the code and watch for changes
  • Open a new VSCode windows (you should play the extension here)

Note: when you make changes, you should refresh that windows to apply changes. To refersh, open Command Palette (Command+Shift+P on MacOS, or Ctrl+Shift+P on Windows), then choose "Developer: Reload window"


2. Play with Captain Stack

To trigger inline completion, you'll need to type //find {your keyword}. (start with //find, end with a dot .)

For example

//find binary search in javascript.

Make sure that showInlineCompletions is enabled in your settings!

"editor.inlineSuggest.enabled": true

3. Notes

  • The extension use fetch-node to get page content, and I don't know if there is any fetching limit
  • The extension uses querySelector to extract code and other info. There is a risk when either StackOverflow or Google changing its querySelector
  • There are more code sources that should be considered besides StackOverflow

If those factor became problems, the extension could be using their official APIs instead.

4. Changelog

  • Jul 01, 2021 - Added snippet source (thanks for mechero's suggestion)
  • Jun 30, 2021 — Publish the initial version

Feel free to open a thread for feedback or discussion. And have fun!