opencode-commandcode is the OpenCode plugin for running Command Code models — including Laguna S 2.1 — with tools/MCP, attachments, compact, and usage, through the same gateway the cmd CLI uses.
Use Command Code from OpenCode and OpenChamber via Go-plan ($1) browser login and a local OpenAI-compatible proxy that POSTs to /alpha/generate. Sibling plugins: @openchamber/opencode-cursor and @openchamber/opencode-claude.
opencode auth login --provider command-code opens the same browser flow as cmd login: Authorize, then paste the key Studio shows (or confirm if the browser already finished). You can also sync an existing cmd login session.
The plugin proxies OpenCode chat to POST https://api.commandcode.ai/alpha/generate (mode=agent) — the same transport as npm i -g command-code@latest.
Default live-test target is Laguna S 2.1 free (poolside/laguna-s-2.1-free, 256k context, $0). The catalog comes from cmd --list-models, not a hardcoded list. Aliases like laguna still resolve to the upstream id.
OpenCode tool calls park and resume. MCP tools configured natively in OpenCode (mcp: in opencode.json) are mapped both ways — OpenCode's <server>_<tool> ↔ the gateway's mcp__<server>__<tool> — so the agent sees them and OpenCode executes them with its own MCP clients. Attachments (images, PDFs, text/binary) pass through. Auto-compact tips and tiered client compact run before the 256k window overflows. Per-turn and session usage come from SSE usage plus GET /v1/usage.
command-code is not a built-in OpenCode provider. Install the plugin first, or opencode auth login --provider command-code fails with Unknown provider "command-code".
npm install -g @openchamber/opencode-commandcodeOr with the OpenCode CLI:
# global (recommended)
opencode plugin @openchamber/opencode-commandcode -g
# or project-local (writes .opencode/opencode.json)
opencode plugin @openchamber/opencode-commandcodeAdd (or merge) this into ~/.config/opencode/opencode.json:
# Option A — sync from Command Code CLI (recommended)
npm i -g command-code@latest
cmd login # browser → Studio CLI auth (Go plan)
opencode auth login --provider command-code
# pick "Use existing cmd login session"
# Option B — browser login inside OpenCode (Go $1)
opencode auth login --provider command-code
# pick "Login with Command Code (Go $1)"
# open the URL, Authorize, then paste the API key (or ok if the browser already finished)opencode run "Summarise this repository in five bullets." --model command-code/laguna-s-2.1-freeIn the TUI, pick provider command-code, then a model from the live catalog. Laguna S 2.1 free is the default when available. It needs an active Go (or higher) account with credits on file; requests on that model still bill $0.
git clone https://github.com/openchamber/opencode-commandcode.git
cd opencode-commandcode
bun install && bun run build
npm install -g .
# or: opencode plugin file://$PWD| Step | What happens |
|---|---|
opencode auth login --provider command-code |
Starts Go-plan browser login (or offers to sync cmd login) |
| You Authorize in the browser | Studio may show a one-time key to paste |
| Plugin stores credentials | Mirrored between OpenCode auth.json and ~/.commandcode/auth.json |
| Session expires | Re-run login or cmd login |
Go-plan browser login is the supported path. You do not need a separate Studio product API key. The paste-key prompt is part of the same cmd login flow.
OpenCode
└─ /v1/chat/completions
└─ Bun.serve proxy (dynamic port, prefer 8797)
└─ POST https://api.commandcode.ai/alpha/generate
└─ poolside/laguna-s-2.1-free (default)
| Layer | Responsibility |
|---|---|
| Plugin hooks | Go-plan OAuth, provider config, live catalog, credential sync |
| Proxy | OpenAI ↔ Command Code gateway, tools/MCP, attachments, compact, usage |
| Transport | POST /alpha/generate to api.commandcode.ai |
Model catalog: live from cmd --list-models, with context, reasoning efforts, and the installed CLI’s text-only/vision registry. Each upstream model appears once in OpenCode; request aliases still resolve to the gateway id.
- OpenCode
- Command Code CLI (
npm i -g command-code@latest) and a Go-plan account - Bun (plugin runtime) · Node.js ≥ 18 (CLI needs ≥ 22)
bun install
bun run build
bun run test # mocked gateway — attachments, tools, compact, usage
bun run test:live # live Laguna S 2.1 (needs `cmd login` / Go plan session)Debug logging: OPENCODE_COMMANDCODE_DEBUG=1.
Optional knobs:
OPENCODE_COMMANDCODE_PROXY_PORT— pin a fixed local proxy port (otherwise dynamic: prefer8797, then scan upward / ephemeral)OPENCODE_COMMANDCODE_CWD— working directory reported to the gatewayCOMMANDCODE_API_URL/OPENCODE_COMMANDCODE_API_URL— override API base (defaulthttps://api.commandcode.ai)
Local pin refresh after a release:
./scripts/update-plugin.sh| Symptom | Fix |
|---|---|
Unknown provider command-code |
Install @openchamber/opencode-commandcode and restart OpenCode |
| Command Code missing from provider list | Confirm plugin includes @openchamber/opencode-commandcode and restart |
| Need a Studio API key? | No — use Go-plan browser login or sync from cmd login |
| Only Laguna models? | No — the plugin loads the full live catalog from cmd --list-models |
| Laguna S 2.1 free rejected | Needs an active Go (or higher) account with credits on file |
Issues and pull requests belong in this repository: openchamber/opencode-commandcode.
bun install
bun run build
bun run testThis plugin started as community work around Command Code access in OpenCode. Special thanks to:
- OpenCode for the plugin API
- OpenChamber for the workspace that runs this plugin in production
- Command Code for the gateway and Go-plan login
- Contributors who shaped OAuth, the live catalog, and the
/alpha/generateproxy
Related plugins: @openchamber/opencode-cursor, @openchamber/opencode-claude.
{ "$schema": "https://opencode.ai/config.json", "plugin": ["@openchamber/opencode-commandcode"], "provider": { "command-code": { "name": "Command Code" } } }