Repository navigation
OpenCode V2 support (dual V1 + V2)
One package now works on both OpenCode V2 (Plugin.define({ id, setup })) and OpenCode V1 (1.18.29+, via the server hook). The discovery core is shared; only the entrypoint differs.
Highlights
- New V2 plugin (
src/v2.ts) built withPlugin.define({ id: "9router", setup }), registering providers/models throughctx.provider.transform(...)and refreshing viactx.provider.reload() - New
src/v2-map.tsmapping the discoveredModelConfigonto V2Model.Info(capabilities, requiredlimit.context/limit.output, variants) - New
src/index.tsdual entrypoint: default export merges the V2 definition withserver: NineRouterPlugin(V1 1.18.29+); namedNineRouterPluginexport retained for older V1 - Package entry (
exports,main,types) now points atdist/index.js/dist/index.d.ts @opencode/plugin@^2.0.12added as a runtime dependency;@opencode-ai/plugin/@opencode-ai/sdkkept for V1 types
Install
{
"$schema": "https://opencode.ai/config.json",
"plugins": ["@vheins/opencode-9router@latest"]
}Config for V2 uses "plugins": [...]; custom providers use package: "@opencode/ai/providers/openai-compatible" + settings.baseURL under the providers key. See README "OpenCode V2" section for full config.
Compatibility & notes
- V1 behavior unchanged; discovery/capability/cache algorithms untouched (no V1 regression).