Skip to content

This is base for making Github Copilot Labs plugin for different IDEs

License

Notifications You must be signed in to change notification settings

haukot/copilot_labs_plugin_base

Repository files navigation

POC: Github Copilot Labs Plugin Base

What's inside

Concept is similar with agent.js in Github Copilot VIM plugin, but it works directly with extension.js file from VS Code extension. So it should provide more up to date versions.

In a similar way it uses jsonrpc protocol upon runned process.

  • index.js is the code that should be implemented by plugin(VIM, Emacs, etc). It contains jsonrpc client code. It spawns agent.js as process, and sends jsonrpc commands to it.
  • agent.js is a middleware code between client and extension. It contains jsonrpc server, and converts jsonrpc commands to extension commands.
  • vscode_extension.js is a wrapper upon extension. It imitates the extension activation and call commands.
  • vscode directory - is a stub on VS Code. It stubs VS Code functions in the way the extension uses them.

This example has many logs and uses jsonrpc upon stdin/stdout, combination of which doesn't really work great. So for real plugin we need to remove console.log statements, or use jsonrpc upon network or socket, so logs will not return by jsonrpc channel to the client.

A more step by step explanation is here.

Preparations

Firstly get github token for extension. Tokens from Github Copilot plugins are working(you could use output from this code https://github.com/haukot/copilot_auth_example). My personal Github token didn't work.

Copy token without quotes to the file SecretGithubToken

Download extension from https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-labs&ssr=false#overview

and extract it to the extension folder.

npm i
unzip -o ~/Downloads/GitHub.copilot-labs-0.14.884.vsix -d extension
npx js-beautify -r ./extension/extension/dist/extension.js

(beautify is not required, but in this way you can easier read errors)

Run

Then run

node index.js

It'll run debug brush on the code.

Notes

I found an example of similar approach in LSP wrapper for typescript extension of vscode. It goes much farther and uses vscode itself(files 1, 2, 3).

It's seems like a overkill for extension like Copilot Labs, but maybe it could be more useful for wrapping some complex extensions.

About

This is base for making Github Copilot Labs plugin for different IDEs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published