Skip to content

feat(plugin): add opencode v2 dual compatibility support - #107

Draft
anthonyhaussman wants to merge 23 commits into
mainfrom
tone/feat/opencode-v2-dual-compat
Draft

anthonyhaussman wants to merge 23 commits into
mainfrom
tone/feat/opencode-v2-dual-compat

Conversation

@anthonyhaussman

@anthonyhaussman anthonyhaussman commented Sep 13, 2026 •

Copy link
Copy Markdown
Owner

Description

Reference Issue: #106.

Plugin Core Architecture

Add OpenCode v2 plugin contracts and composite entrypoint support to maintain full backward and forward compatibility.
Enable OpenCode v1 runtimes to invoke the existing server lifecycle while OpenCode v2 runtimes execute the setup hook from a single package.

V2 Adapter Implementation

Implement OpenCode v2 setup adapter integrating catalog, tool, command, and session hooks.
Route model registration, quota tools, CLI quota commands, HTTP request header injections, and backoff retry logic through native v2 extension points.

Package Entrypoint & Exports

Export the dual v1 and v2 plugin definition from index.ts.
Preserve named exports for v1 consumers while exposing the default composite object expected by both runtime generations.

Documentation

Document the dual v1 and v2 architectural design and runtime execution paths in README.md and AGENTS.md.
Detail runtime resolution mechanics, version capability mappings, and updated surface review checklists for future maintenance.

@anthonyhaussman anthonyhaussman self-assigned this Sep 13, 2026
@anthonyhaussman
anthonyhaussman force-pushed the tone/feat/opencode-v2-dual-compat branch 8 times, most recently from 2a565ef to 9dc0b7a Compare September 19, 2026 10:18
@anthonyhaussman
anthonyhaussman force-pushed the tone/feat/opencode-v2-dual-compat branch 4 times, most recently from f821504 to 6539e46 Compare September 24, 2026 16:00
Document dual runtime paths, capability mappings,
and update surface review checklist for v2 adapter.

Assisted-by: Gemini 3.8 Flash
Configure provider package prefix as 'aisdk:@ai-sdk/google' for bundled adapter mapping. Register model variants for tiered models from TIER_MAPPING in catalog transforms.

Assisted-by: Gemini 3.8 Flash
Configure integration transform for oauth login and attach providerID filter
to session hooks to route requests and strip api key.

Assisted-by: Gemini 3.8 Flash
Register aisdk sdk hook with dummy apiKey and v2
fetch interceptor. Implement full Google OAuth authorize
method and token exchange callback in integration transform.

Assisted-by: Gemini 3.8 Flash
Use standard authorizeAgy with PKCE verification in v2
integration transform. Auto inject bearer token from stored
credentials in session http request hook.

Assisted-by: Gemini 3.8 Flash
Avoid automatically launching web browser during coverage runs.

Assisted-by: Gemini 3.8 Flash
Add test launcher hook to prevent browser popup during unit tests.
Stub stored credentials in v2 tests to fix CI assertions.

Assisted-by: Gemini 3.8 Flash
Guard openBrowserUrl against launching desktop browsers in
vitest test environments. Mock browser launcher in unit
tests while preserving coverage.

Assisted-by: Gemini 3.8 Flash
Align v2 oauth callback schema to Credential.OAuth and rewrite
generativelanguage requests to Code Assist endpoint with payload
transformations. Guard auth storage against test overwrites.

Assisted-by: Gemini 3.8 Flash
anthonyhaussman and others added 8 commits September 25, 2026 08:31
Add unit tests for request header mutation and fallback handling. Ensures coverage thresholds pass on CI.

Assisted-by: Gemini 3.8 Flash
Await transformAgyResponse in http.response hook to prevent
undefined response status in OpenCode v2 executor.
Correlate requested model across rewritten request URLs.

Assisted-by: Gemini 3.8 Flash
Document v2 integration transform with PKCE flow, AI SDK hook, dual auth storage, surface checklist, and local v2 smoke testing.

Assisted-by: Gemini 3.8 Flash
Support top-level provider and model registries
introduced in OpenCode v2.0.8. Retain catalog
fallback for backward compatibility.

Assisted-by: Gemini 3.8 Flash
Split v2 plugin logic across modular submodules. Extract shared headers, tier
resolution, auth storage, fetch interceptor, and session hooks. Colocate tool
and command definitions.

Assisted-by: Gemini 3.8 Flash
Clone Request instance with updated url instead of
mutating read-only property in request hook fallback.

Assisted-by: Gemini 3.8 Flash
Delete parameters_json_schema and parametersJsonSchema fields to avoid
backend rejection when parameters is set.

Assisted-by: Gemini 3.8 Flash
@anthonyhaussman
anthonyhaussman force-pushed the tone/feat/opencode-v2-dual-compat branch from 68104cf to c7d92ef Compare September 25, 2026 06:31
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.

2 participants