-
Notifications
You must be signed in to change notification settings - Fork 508
feat: add github copilot provider #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,4 @@ Thumbs.db | |
.opencode/ | ||
|
||
opencode | ||
opencode.md |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"If using explicit github token" - suggests there is another way. Is there? If not I would change that wording to have just two options - GITHUB_TOKEN variable or opencode.json setting.
Also it would be good to add, which file to use (hosts.json or apps.json), because those contain different tokens.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary auth method, and also the recommended method by
aider.chat
andavante.nvim
, is to first login to github copilot using an IDE (VSCode, JetBrains, Neovim); then let the agent use the token created by the IDE. This ensures that the token has the required scope, as those IDEs plugins are first party and will always generate a token with the correct scopes.The
GITHUB_TOKEN
env var should only really be used, if you are manually overriding the token for testing, need to toggle between two github copilot accounts (e.g. personal vs work), or the user has sufficient knowledge on how to generate an auth token with the correct scopes. Given that API access to Copilot Chat is not formally documented, documenting manual token generation, and maintaining that documentation is a support task that no one is really interested (Github has taken additional measures to hide the source code for newer revisions, so the fact that we have a Copilot plugin at all is really just us being luck with me having enough free time to reverse engineer one).As far as which json file has the correct auth token, this is also obfuscated by Github and not documented. Both
aider
and third-partyneovim
plugins basically guess which file has the correct one based on format. The token searching logic included in this PR is replicated fromavante
, but is by no means perfect. In theory, it might be possible preflight each token against the copilot api, but that kind of edge case hand holding is well beyond the scope of this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I get that. But I wasn't sure if this plugin does the search in the github-copilot config files (and I think others might be confused also), or the user should do that and provide the token manually as with other providers inside the opencode.json file (with the env variable as another method).
BTW. Both opencode and your plugin are awesome, thank you all for the work.