Skip to content

docs: document OpenCode 2 (V2) usage - #17

Closed
Majidalee1 wants to merge 3 commits into
brent-weatherall:mainfrom
Majidalee1:pr3-docs/v2-usage
Closed

docs: document OpenCode 2 (V2) usage#17
Majidalee1 wants to merge 3 commits into
brent-weatherall:mainfrom
Majidalee1:pr3-docs/v2-usage

Conversation

@Majidalee1

@Majidalee1 Majidalee1 commented Aug 7, 2026

Copy link
Copy Markdown

Summary

Documents how to use the Command Code provider with OpenCode 2 and updates the repo's example config to the V2 plugin format.

Stacked PRs: this is PR 3 of 3. Please review/merge #15 then #16 first — this branch is based on them. It targets main here because the intermediate branches live on a fork and cannot be used as base refs in this repo; the diff is scoped to just the documentation.

Changes

  • README.md:
    • New "OpenCode 2 (V2)" section: install via plugins: ["commandcode-go-opencode-provider/v2"], API-key setup (/connect or COMMANDCODE_API_KEY), and model selection.
    • Note clarifying that the existing plugin/provider block remains the entrypoint for the legacy opencode CLI.
    • V2 local-development snippet using a file:// path to the ./v2 entrypoint.
  • opencode.json: switch the example to the native V2 config (plugins + providers).

Verification

Documentation and example-config only; no runtime behavior changed. bun run typecheck and bun test tests/unit/ continue to pass.

Introduce src/models.ts so the V1 plugin and the upcoming V2 entrypoint
share one source of truth for loading models.json and converting entries
into their runtime-specific shapes.

- loadModels(): reads models.json once, typed as ModelEntry[]
- toConfigKey(): stable short key derivation (preserves prior behavior)
- toV1ModelConfig(): legacy { config } hook model shape
- toV2ModelDraft()/toV2ModelMap(): OpenCode V2 catalog model drafts

plugin.ts now delegates to the shared module; behavior is unchanged
and covered by tests.
OpenCode 2 loads plugins from a module's default export as
{ id, setup }, and requires provider/model registration through the
catalog transform API. The legacy plugin.ts factory (V1 only) fails to
load in V2 with a SchemaError.

Add a new ./v2 entrypoint that exports { id, setup } and registers the
commandcode provider plus all models from models.json via
ctx.catalog.transform. Users can now opt in with:

  plugins: ["commandcode-go-opencode-provider/v2"]

No provider block or hand-written model list is needed.

- v2.ts: V2 plugin default export ({ id, setup })
- package.json: expose ./v2, include v2.ts in files, bump to 0.5.0
- tsconfig.json: include v2.ts
- tests/unit/v2.test.ts: coverage for provider/model registration
Add a V2 section to the README covering install via the ./v2 entrypoint,
API-key setup, and model selection. Add a V2 local-development snippet and
switch the repo's example opencode.json to the native V2 plugin config.
@Majidalee1

Copy link
Copy Markdown
Author

Closing this PR. PR #15 now has all the changes from #15, #16, and #17. GitHub does not allow a fork branch as a PR base in the upstream repo. This made a real 3-PR stack impossible without push access to this repo. See #15 for the combined change: #15

@Majidalee1 Majidalee1 closed this Aug 7, 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