Skip to content

feat: add native OpenCode V2 plugin support - #84

Open
pascalandr wants to merge 4 commits into
jenslys:mainfrom
pascalandr:feat/v2-compat
Open

feat: add native OpenCode V2 plugin support#84
pascalandr wants to merge 4 commits into
jenslys:mainfrom
pascalandr:feat/v2-compat

Conversation

@pascalandr

@pascalandr pascalandr commented Aug 23, 2026

Copy link
Copy Markdown

Summary

Adds a native OpenCode V2 server plugin entrypoint while preserving the existing V1 root entrypoint.

Implementation

  • Exposes ./server as a default Plugin.define plugin using @opencode-ai/plugin@beta.
  • Registers the Gemini CLI OAuth method with the current V2 integration.transform contract, including credential refresh and account labels.
  • Reuses the existing Gemini request and response transformations through provider-scoped V2 session HTTP hooks.
  • Reads V2 providers.google.settings.projectId through the current catalog client as well as the existing project environment variables.
  • Keeps V1 runtime loading independent from the V2 plugin package while preserving the root exports and V1 hooks.
  • Makes the package self-import smoke portable and checks both the root and ./server exports.

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 fail
  • bunx tsc --noEmit: pass
  • bun run build: pass
  • npm pack: pass, including prepack imports
  • Packed artifact root and ./server imports: pass
  • Packed V1 root hook construction: pass
  • Isolated current OpenCode V2 CLI load: plugin active and gemini-cli registered for Google

A live Google OAuth exchange and model request were not run because they require an eligible account and credentials.

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.
@pascalandr pascalandr changed the title feat: OpenCode V2 compatibility feat: add native OpenCode V2 plugin support Aug 23, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant