@fanfan4204/commandcode-go-opencode-providerCommand Code API provider for opencode — use Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax, and Step models via Command Code
0
524
近 7 天 114
35.5
生态多维模型
28 天前
2026-07-23
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@fanfan4204/commandcode-go-opencode-provider@0.4.1"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@fanfan4204/commandcode-go-opencode-provider@0.4.1"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @fanfan4204/commandcode-go-opencode-provideropencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Command Code API provider for opencode. Use Claude, GPT, Gemini, DeepSeek, Qwen, Kimi, GLM, MiniMax, Step, and other models through a single API key.
Forked from brent-weatherall/opencode-commandcode-provider — originally created by Brent Weatherall.
繁體中文說明請見 README.zh.md
Key improvements over upstream
- Auto-load catalog from local command-code — on startup, scrapes the model catalog (including
reasoningEfforts) from your locally installedcommand-codenpm package. Falls back to bundledmodels.jsonif the package is not found. - Reasoning effort variants — models with
reasoningEffortsautomatically getvariants(e.g.low/medium/high/xhigh/max). Upgradecommand-codeand restart to pick up new models and efforts — no manual sync needed. - Shared catalog module —
src/catalog.tsprovides unified package resolution, bundle extraction, and model-building logic used by both the plugin and the sync command. - No more dropped models — models without cost data now receive a conservative default cost instead of being silently dropped.
- Deduplicated display names — models sharing the same upstream display name (e.g.
MiniMax M3/MiniMax M3 Free) are automatically disambiguated. - Windows compatibility — sync temp directory now uses
os.tmpdir()instead of hard-coded/tmp.
Quick Start
1. Install
opencode plugin @fanfan4204/commandcode-go-opencode-provider
This installs the provider and registers all available models automatically.
Tip: For the latest model catalog (including reasoning effort variants), install the
command-codeCLI globally:npm install -g command-codeWithout it, the plugin falls back to the bundled
models.jsonwhich may be outdated.
2. Connect
Run /connect in opencode, search for Command Code, and enter your API key:
/connect
3. Select a model
Run /models to pick from available models:
/models
Manual Configuration
If you prefer to configure manually, add this to your opencode.json:
{
"plugin": ["@fanfan4204/commandcode-go-opencode-provider/server"],
"provider": {
"commandcode": {
"npm": "@fanfan4204/commandcode-go-opencode-provider",
"name": "Command Code",
"env": ["COMMANDCODE_API_KEY"]
}
},
"model": "commandcode/deepseek-v4-flash"
}
The plugin auto-registers models at startup. It prefers the model catalog (including reasoning effort variants) from a locally installed command-code package, and falls back to the bundled models.json if that package is not found. You only need the provider.commandcode block — no need to list individual models.
Optional overrides:
- Env:
COMMANDCODE_PACKAGE_PATH— path to thecommand-codepackage root (or itsdist/index.mjs) - Config file
~/.config/opencode/commandcode-go-opencode-provider.json:{ "commandCodePackagePath": "C:/Users/you/AppData/Roaming/npm/node_modules/command-code", "disableModelSync": false }
Environment Variable
Set COMMANDCODE_API_KEY instead of using /connect:
COMMANDCODE_API_KEY=your-key opencode
Available Models
The full model list is maintained in models.json as a fallback. Upgrade your local/global command-code install to pick up new models and reasoning efforts on the next OpenCode start. Run bun run sync to refresh the committed models.json from local command-code (or npm latest with --remote).
Development
git clone https://github.com/FanFan4204/opencode-commandcode-provider.git
cd opencode-commandcode-provider
bun install
For local testing, create opencode.local.json (gitignored) with file:// paths:
{
"plugin": ["file:///path/to/@fanfan4204/commandcode-go-opencode-provider/server"],
"provider": {
"commandcode": {
"npm": "file:///path/to/commandcode-go-opencode-provider",
"name": "Command Code (local)",
"env": ["COMMANDCODE_API_KEY"]
}
}
}
Run opencode --config opencode.local.json to test with your local build.
Sync Models
bun run sync # update models.json from local command-code (npm latest if missing)
bun run sync -- --remote # force download latest command-code tarball from npm
bun run sync:global # update models.json + write to ~/.config/opencode/opencode.jsonc
At runtime OpenCode does not need bun run sync if command-code is installed locally or globally — the plugin scrapes that package on startup.
License
MIT