Giter Site home page Giter Site logo

gopilot's Introduction

gopilot

Enjoy Github Copilot on the CLI. Especially powerful when combined with tmux.

nvim

nvim

cli

cli

Disclaimer

This project go as-if. It will be my WIP project to learn Go. You have been warned.

Why?

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.

Why not a plugin for nvim?

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

Technical considerations

Authentication token

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:

  1. Install VSCode
  2. Install the Copilot extension
  3. The extension should ask you for your Github details and create the token file
  4. Done!

Request headers

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.

Debugging

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.

How to use gopilot

  1. Clone this repo
  2. Run go get
  3. Run make build
  4. Run make install
  5. Run gopilot
  6. Enjoy!

Chat

Keybindings

  • Ctrl + j: Sends the message
  • Ctrl + l: Clears the chat and restarts the session
  • Ctrl + c: Quit
  • enter: Allows for multi-line messages
  • Ctrl + p, PageUp: Scroll up in the chat viewport
  • Ctrl + n, PageDown: Scroll down in the chat viewport
  • Ctrl + r: Used only for debugging. Reloads the Github token

How to develop?

Well, it's all about reverse engineering APIs.

  1. Install and configure mitmproxy to support SSL
  2. Configure VSCode to use your local proxy
  3. Use VSCode with Copilot Chat
  4. Check the requests and responses in mitmproxy
  5. Profit!

gopilot's People

Contributors

ainformatico avatar

Stargazers

Juan González avatar flrnd avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.