Skip to content

feat: add native OpenCode V2 plugin support - #3

Open
pascalandr wants to merge 5 commits into
openchamber:mainfrom
pascalandr:feat/v2-compat
Open

feat: add native OpenCode V2 plugin support#3
pascalandr wants to merge 5 commits into
openchamber:mainfrom
pascalandr:feat/v2-compat

Conversation

@pascalandr

@pascalandr pascalandr commented Aug 23, 2026

Copy link
Copy Markdown

Summary

Adds native OpenCode V2 compatibility while preserving the OpenCode V1 root entrypoint.

  • tracks @opencode-ai/plugin through the published beta dist-tag
  • exposes a pure Plugin.define({ id, setup }) V2 ./server export
  • starts and cleans up the existing Bun Claude proxy
  • adds the claude-code provider and six Claude models with effort variants
  • associates the provider with its Claude CLI authentication integration
  • routes V2 model requests through the proxy while preserving effort, session, and directory headers
  • keeps V1 code on a stable-major dependency alias because the beta package no longer exports V1 types

Configuration

{
  "$schema": "https://opencode.ai/config.json",
  "plugins": ["@openchamber/opencode-claude"],
  "providers": {
    "claude-code": { "name": "Claude Code" }
  }
}

The package root remains the V1 entrypoint. OpenCode V2 package installation selects ./server; that export intentionally has no legacy server property, preventing the V2 loader from classifying it as a V1 plugin.

Verification

  • bun run build
  • bunx tsc -p tsconfig.json --noEmit
  • focused V2 test covering module shape, catalog, provider/integration association, request routing, headers, and cleanup
  • npm pack --dry-run
  • packed root and ./server imports
  • real V1 catalog smoke
  • isolated V2 setup/proxy smoke

Limitations

  • The complete smoke suite still reaches the existing Windows extensionless-executable fixture failure at test/smoke.ts:236.
  • Interactive Claude login and authenticated inference require account interaction and were not automated.
  • The V2 API remains beta, so updates to the beta dist-tag require the same build and runtime validation.

V2 host uses @opencode-ai/client Promise API (0.0.0-beta-17595+)
and a single global daemon instead of per-workspace runtimes.
This plugin requires no runtime change: the Bun.serve proxy
already binds an ephemeral port and reuses a healthy sibling on
OPENCODE_CLAUDE_PROXY_PORT, so it coexists with the global
service. Registration stays plugin field in opencode.json.
Add optional peer @opencode-ai/client >=0.0.0-beta-17595, document
no packages/opencode-plugin (deleted in CodeNomad MIGRATION_V2.md),
and note CodeNomad V2 quota now surfaces Claude OAuth usage via
api.anthropic.com/api/oauth/usage (e2b784f2).
OpenCode V2 requires the new Plugin.define entrypoint and registration APIs, while this package still implements the V1 hook contract. Remove the unrelated optional client peer and the claims that daemon and proxy behavior make the existing plugin compatible.

Document the current V1-only requirement so users are not directed to install a package that V2 cannot load. The existing V1 runtime remains unchanged.

Validated with bun run build. The smoke script still fails on Windows at its Unix executable fixture in test/smoke.ts:236, which is unrelated to this documentation and manifest correction.
@pascalandr pascalandr changed the title feat: OpenCode V2 compatibility docs: clarify OpenCode V2 support status Aug 23, 2026
Add a real V2 server plugin entrypoint while preserving the existing V1 root export. The V2 plugin starts the Claude proxy, contributes the claude-code provider and model catalog through native transforms, registers the official Claude CLI sign-in relay, and rewrites native model requests with live proxy, effort, session, model, and project-directory context.

Pin @opencode-ai/plugin to the target 0.0.0-beta-17595 release and use its versioned V1 type export for the legacy entrypoint. V2 stores only a non-secret connection marker because its integration contract requires a credential record; Claude Code continues to own and refresh the actual subscription credentials.

Add a mocked V2 context test covering catalog, integration, hook registration, routing, and cleanup. Validate TypeScript build and no-emit checking plus fresh packed-package imports for both root and ./server; the legacy smoke script retains its pre-existing Windows fake executable failure at test/smoke.ts:236.
@pascalandr pascalandr changed the title docs: clarify OpenCode V2 support status feat: OpenCode V2 compatibility Aug 23, 2026
Depend on the beta dist-tag instead of a numbered prerelease and regenerate the Bun lockfile. Keep the OpenCode V1 type contract through a stable-major npm alias because the current beta no longer exports its V1 compatibility path.

Expose the V1 handler from the server entrypoint for loaders that prefer package server exports, while retaining the native V2 id/setup plugin and its catalog, integration, request-hook, and proxy behavior. Document the explicit V2 server-file configuration required while the package root remains V1-compatible.

Validated with build, no-emit typecheck, focused V2 tests, packed root/server imports, an isolated current opencode2 loader smoke covering plugin/catalog/integration/provider/proxy state, and a current V1 model-catalog smoke. The full suite still reaches the existing Windows extensionless fixture failure in test/smoke.ts.
@pascalandr pascalandr changed the title feat: OpenCode V2 compatibility feat: support the current OpenCode V2 plugin API Aug 23, 2026
Keep the V2 server export limited to the Plugin.define contract so OpenCode does not classify it as a legacy server plugin. Register the provider with its authentication integration and document normal package installation instead of requiring a dist/server.js path. The focused V2 test now prevents the legacy server property from returning.
@pascalandr pascalandr changed the title feat: support the current OpenCode V2 plugin API feat: add native OpenCode V2 plugin support Aug 23, 2026
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