Enjoy Github Copilot on the CLI. Especially powerful when combined with tmux
.
This project go as-if. It will be my WIP project to learn Go. You have been warned.
I am a heavy (n)vim user. I have been using it for 14 years now. When Copilot Chat was out I decided to try VSCode with the Chat integration. I have to admit that it was a great experience. Well, the Chat was, the editor wasn't. I spent many days trying to configure VSCode to behave like my nvim setup. They are completely different, so there's no point trying to make them behave the same way. Still, I wanted to use Copilot Chat from my editor! So, as any good developer would do, I decided to write my own client for it. This coincided with me wanting to learn Go, so here we are.
I am also a tmux
heavy user, and I wanted to have the chat available on any terminal, not just on nvim.
Sometimes I ask questions about certain CLI commands and not just about code.
If you are looking for a great plugin to integrate Copilot Chat in your nvim, take a look at CopilotChat.nvim
This project assumes that you have ~/.config/github-copilot/hosts.json
that contains your Github Token for Copilot.
Note that this is a UNIX path. I am not interested in adding Windows support at the moment. Feel free to open a PR or fork if you want to add it.
The fastest way to get your token is:
- Install VSCode
- Install the Copilot extension
- The extension should ask you for your Github details and create the token file
- Done!
I ported (using Copilot) the great work from CopilotChat.nvim, so I am using the same request headers as they are. Most of the values are randomized, but it is up to you to check and use the desired values.
If you are having issues or are developing this project, you can run:
gopilot -d
This will create a gopilot.log
file in the project directory with the debug information.
- Clone this repo
- Run
go get
- Run
make build
- Run
make install
- Run
gopilot
- Enjoy!
Ctrl + j
: Sends the messageCtrl + l
: Clears the chat and restarts the sessionCtrl + c
: Quitenter
: Allows for multi-line messagesCtrl + p
,PageUp
: Scroll up in the chat viewportCtrl + n
,PageDown
: Scroll down in the chat viewportCtrl + r
: Used only for debugging. Reloads the Github token
Well, it's all about reverse engineering APIs.
- Install and configure mitmproxy to support SSL
- Configure VSCode to use your local proxy
- Use VSCode with Copilot Chat
- Check the requests and responses in
mitmproxy
- Profit!