Files
plugins/packages/commandcode
yetone ff2d815249 commandcode 0.1.11: a streamed Go reply Command Code stops before its finish line ends cut short, with a note, instead of failing the turn (#91)
This is the sibling of zen-free 0.1.4 (6a5dd01). /alpha/generate's reply
is turned into a Chat Completions stream, which magpie's gateway can't go
on with, so the error frame threw away what the client was already shown.

Now a streamed reply that said something (text, reasoning or a tool call)
and then lost its finish line ends with the note, a finish (`stop`, or
`tool_calls` after a call) and [DONE]. Tool calls arrive whole here, so
none can be half written. A reply that said nothing, or one that wasn't
streamed, is still a 502, so magpie retries it.

Run: HOME=$(mktemp -d) bun test packages/commandcode gave 37 pass. The
whole repo's bun test gave 1129 pass, 0 fail. bun scripts/check.mjs passed.
On the old index.mjs, 3 of the 4 new tests fail. With the cut branch
disabled by hand they fail again.

Not tried: a real Go account. The owner's two Command Code accounts aren't
on Go, and the real upstream can't be made to cut a stream. A streamed
request through the patched loader on those accounts still takes the
Provider API path, which this commit doesn't touch.
2026-10-12 20:31:33 +08:00
..
commandcode 0.1.8: a model of the plan takes pictures as its maker's models do, not none of them (ARNO on magpie 0.1.810, Discord: command code provider 的所有模型都没有自动勾上支持图片输入) — Command Code's /provider/v1/models gives no modalities (all 86 entries, testdata/models.json and the live list read from a moved account's plugin-providers.json alike), and runtimeModel always set capabilities.input.image to !!m.images, false for every model, which magpie's plugin host reads as the plugin's answer (host.js: imageSaid when the value is a boolean) and takes over models.dev's. So every model of a moved plan, Claude, GPT-6, Kimi K3 and Qwen 3.8 included, showed no image input, where the built-in (whose list said nothing either) answered from models.dev (catalog.SeesImages). runtimeModel now says image only when m.images is a boolean; liveModels takes the list's modalities when it gives them, else the default list's answer (which now marks Claude Sonnet 5, Opus 5.5, GPT-6 Sol, Kimi K3 and MiniMax M3, as models.dev has them; DeepSeek V4 and GLM-5.3 read text alone and say nothing), else the CLI's table's (GO_MODELS, Pixel Canary among them), else true for a Claude model, and of any other says nothing, so magpie answers from models.dev as the built-in did (DeepSeek V4, GLM-5.x, MiniMax M2.x, Hy4 and the rest models.dev calls text-only stay without). A list that gives modalities is taken at its word, an explicit text-only included (the old || undefined dropped it). Go's goModels is unchanged but no longer says false for a model the table doesn't mark. models.test.mjs gains a test (a Pro account's 86 models: known image models say true, the rest leave image unsaid, a list's own modalities win, Go keeps the table's); it fails on 0.1.7 and passes. HOME=$(mktemp -d) bun test (459 pass) and bun scripts/check.mjs commandcode pass. Not tried in a real OpenCode/magpie session with the new version; magpie needs the mover's min raised to 0.1.8 for moved users to get it.
2026-10-04 12:04:57 +08:00

@magpie-community/opencode-commandcode-auth

Signs in to a Command Code plan (Pro, GOAT, Max, Ultra, Go, Teams Pro) and makes its requests, in OpenCode and in magpie. Provider id: commandcode-plan.

Signing in

An account is a Command Code API key. There are three ways to get one:

  • Command Code (browser): the CLI's own sign-in. Studio asks you to approve a key for this machine, then posts it to a callback on 127.0.0.1. The plugin checks the key with /alpha/whoami and reads the plan.
  • Command Code CLI's sign-in: takes the account commandcode login signed in to, from ~/.commandcode/auth.json. The file is only read, never changed.
  • API key: paste a key from commandcode.ai/settings/keys.

The key is kept where OpenCode keeps sign-ins (auth.json; in magpie, plugin-auth.json) as { "type": "api", "key", "metadata": { "email": <user>, "plan" } }. Keys don't expire, so there is nothing to refresh.

Requests

  • Every plan but Go uses the Provider API at https://api.commandcode.ai/provider/v1. Every request carries the key as both Authorization: Bearer and x-api-key.
    • Claude models speak Anthropic's Messages API.
    • The other models speak chat completions.
  • Go has no Provider API access. Its key is only accepted where the CLI asks, POST /alpha/generate, in the CLI's own format (command-code 1.72.2 and its headers). The plugin's fetch handles this:
    • It turns OpenCode's chat completion into that format.
    • It turns the line-by-line reply back into a chat completion, streamed or not.
    • Failures keep their statuses: a model the plan lacks is a 403, running out of credits is a 402, and a usage-window limit is a 429.
    • A reply that stops before its finish line is a 502, unless it was streamed and had already said something. Then it ends cut short, with a note saying so, and [DONE] (#91).

The plan is read from /alpha/billing/subscriptions. It is cached for 10 minutes; after a failed read, the plugin tries again after 1 minute. When the plan isn't known yet and the Provider API refuses the key with "Your Go plan doesn't include API access", the key is taken as Go's from then on (and saved so with it), and a chat completion is sent again to /alpha/generate.

Models

The config hook declares the default list:

Model Context window
Claude Sonnet 5 1M
Claude Opus 5.5 1M
GPT-6 Sol 1.05M
DeepSeek V4 Pro 1M
DeepSeek V4 Flash 1M
Kimi K3 1M
GLM-5.3 1M
MiniMax M3 1M

Once signed in, the provider.models hook replaces the default list with the account's own:

  • Every plan but Go: the Provider API's /models list. Each model's supported_endpoints picks the API it speaks.

  • Go: the same /models list, asked without the key (it answers without one, and Go's key has no Provider API), less the models the CLI's table (command-code 1.73.0) refuses Go: the premium ones (Claude, GPT-6 Sol, GPT-5.6 Terra, …) and those it blocks for Go (GPT-5.6 Sol, Claude Sonnet 5.5, Grok 4.6 and 4.7, …). That is 56 models as of 2026-10-01. When the list can't be had, the CLI's own Go table (57 models) stands in.

    The Go models carry their reasoning levels, and a requested level is fitted to the nearest one the model has.

The /models list doesn't say which models take images. A model is marked as taking them when it is a Claude model, or when the default list or the CLI's table says so. For any other model the plugin says nothing either way, and magpie answers from models.dev, as its built-in did.

Not included

  • Usage and quota (/alpha/billing/credits, the 5-hour and weekly windows).
  • Switching between several accounts. OpenCode keeps one sign-in per provider.