feat: add native OpenCode V2 plugin support - #84
Open
pascalandr wants to merge 4 commits into
Open
Conversation
Replace the metadata-only V2 compatibility claim with a real server entrypoint that registers Gemini CLI OAuth through the V2 integration API and rewrites native Google requests and responses through session HTTP hooks. Keep the legacy root entrypoint unchanged, and expose both setup and server from ./server so current V1 and V2 loaders select the contract they understand. Remove the invalid @opencode-ai/client >=1.17.0 peer range because V2 client releases are 0.0.0-beta prereleases and the plugin context is host-supplied. Document V2 configuration and the V1-only quota, retry, and notification features instead of claiming unsupported parity. Add a focused V2 registration and transport test. Validated with the full Bun test suite, TypeScript checking, tsup declaration builds, a packed-package import check, and structural assignment against @opencode-ai/plugin@0.0.0-beta-17595.
Replace the hand-written V2 contract with the current promise plugin types and Plugin.define entrypoint. Register Gemini OAuth through the current integration transform, scope transport hooks to Google, and read project settings through the current catalog client. Keep the V1 root entrypoint independent by replacing its legacy plugin helper and SDK type imports with equivalent local structures. Depend on the moving beta tag for V2 runtime compatibility and make the package self-import smoke portable across platforms. Validated with the full Bun test suite, TypeScript checking, declaration builds, npm packing, packed root and server imports, a V1 hook construction smoke, and an isolated load against the current OpenCode V2 CLI.
Remove the obsolete free-tier claim and state that Gemini CLI OAuth is limited to organization-backed Code Assist Standard and Enterprise subscriptions. Personal accounts should use the native API-key flow, which avoids the third-party OAuth policy risk.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a native OpenCode V2 server plugin entrypoint while preserving the existing V1 root entrypoint.
Implementation
./serveras a defaultPlugin.defineplugin using@opencode-ai/plugin@beta.integration.transformcontract, including credential refresh and account labels.providers.google.settings.projectIdthrough the current catalog client as well as the existing project environment variables../serverexports.Google OAuth limitation
Google no longer serves Gemini CLI OAuth requests for Gemini Code Assist Individuals, Google AI Pro, or Google AI Ultra accounts. Google also warns that third-party use of Gemini CLI OAuth may trigger abuse detection or account restrictions. This V2 port therefore only claims OAuth functionality for eligible organization-backed Code Assist Standard and Enterprise subscriptions. Personal accounts should use OpenCode's native Gemini API-key flow instead.
Current V2 scope
V2 supports OAuth login, refresh, project resolution, and Gemini model request/response rewriting.
/gquota, the quota tool, retry transport, and TUI capacity notifications remain V1-only and are documented as such.Validation
bun test: 60 pass, 0 failbunx tsc --noEmit: passbun run build: passnpm pack: pass, including prepack imports./serverimports: passgemini-cliregistered for GoogleA live Google OAuth exchange and model request were not run because they require an eligible account and credentials.