Files
plugins/packages/commandcode
yetone 49e9d89d59 commandcode 0.1.12: each plan lists only the models it may use; a Go account no longer lists GOAT's (01huadalang on Discord)
01huadalang, signed in on the Go plan, was shown models only GOAT and above
may use. Command Code's /provider/v1/models is the same 87 models for every
plan (read with a GOAT key and without one on 2026-10-13: the same but for
"created"); which of them a plan may use is the CLI's own table (command-code
1.79.2, evaluateModelAccess: each model's category, premium or open, and
each plan's allowedCategories and blockedModels), and the Provider API turns
the rest away only when asked (403 "MODEL_NOT_IN_PLAN: Claude Opus 5.5
available in Provider and above plans or extra on demand usage").

Cause: the plugin filtered Go's list by a copy of CLI 1.73.0's table, which
didn't have Claude Haiku 5.5 (1.79.2: "haiku 5.5 in goat plan", blocked for
Go), and didn't filter any other plan at all, so GOAT, Pro and Provider were
shown models their plan refuses (a real GOAT account listed all 87, Claude
Opus 5.5 and GPT-6 Sol among them).

Now:
- PLAN_MODELS is CLI 1.79.2's table by plan name: Go and GOAT the open
  models only, Go also blocked from GOAT's (Sonnet 5.5, Haiku 5.5, GPT-5.6
  Sol, Grok 4.6/4.7, Muse Spark 1.2/1.3, Gemini 3.7/3.8 Flash, MiMo V2.6 Pro
  UltraSpeed), Pro blocked from Opus, Fable, GPT-6 Astra, GPT-6.1 Sol and
  Fugu Ultra, Provider from GPT-6.1 Sol, Max/Ultra/Teams Pro everything.
  GO_REFUSED is derived from it. Blocks are by id: the CLI's own block of
  "vercel-ai-gateway:xiaomi/mimo-v2.6-pro-ultraspeed" misses its "cai"
  model, and Go stays kept off it as before.
- provider.models filters every plan's list (and the default list standing
  in when the list can't be read) by it.
- A plan not read (billing/subscriptions failing, nothing saved), "No plan",
  or a plan name the table doesn't know keeps the whole list.
- Bought or free credits (billing/credits) let every model, as the CLI does;
  credits not read are taken as last read, else none, so the plan's list
  stands and a model it leaves out is still refused by Command Code.
- The refusal itself is unchanged: the Provider API's 403 reaches the agent
  as it came, and on Go's endpoint failure() says "Model not in plan: …".

Tests: plan-models.test.mjs is new, built from real bytes in testdata
(models-2026-10-13.json, a GOAT account's subscriptions and credits replies
with its ids zeroed, the two MODEL_NOT_IN_PLAN refusals). The Go case uses
the GOAT reply with Go's planId: there is no Go account here. All 7 fail on
0.1.11. Broken by hand, each goes red: Haiku 5.5 unblocked for Go (Go test),
no plan filter (5 tests), credits ignored, an unread plan refusing premium,
the stand-in list unfiltered, credits unread taken as extra.
models.test.mjs's pictures test moves from Pro to Max, since Pro's list no
longer has Claude Opus 5.5.

Ran: TMPDIR=<scratch> HOME=<scratch>/home bun test (all packages, 1144 pass,
0 fail) and bun scripts/check.mjs commandcode. The new provider.models hook
against the owner's real GOAT account (saved plan and none) lists 66 models:
Sonnet 5.5, Haiku 5.5 and GPT-5.6 Sol in, Opus 5.5, Sonnet 5 and GPT-6 Sol
out; a 1-token request confirmed GOAT gets Haiku 5.5 (200) and is refused
Sonnet 5 (403 MODEL_NOT_IN_PLAN).
Not tried: a real Go account (none here), an account with bought credits,
and the new version inside a running OpenCode/magpie; magpie needs the
mover's min raised to 0.1.12 for moved users to get it.
2026-10-13 00:44:50 +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:

Command Code's /models list is the same for every plan. A plan's list is that list less the models the plan may not use, as the CLI's own table (command-code 1.79.2) has it:

  • Go and GOAT may not use the premium models (Claude Sonnet 5 and Opus, GPT-6 Sol, GPT-5.6 Terra, …). Go is also blocked from GOAT's own (Claude Sonnet 5.5 and Haiku 5.5, GPT-5.6 Sol, Grok 4.6 and 4.7, …).
  • Pro may not use Claude Opus and Fable, GPT-6 Astra, GPT-6.1 Sol and Fugu Ultra; Provider may not use GPT-6.1 Sol.
  • Max, Ultra and Teams Pro may use every model.

An account with bought or free credits may use every model, and so may one whose plan can't be read: then the whole list is shown. A model the plan doesn't have is still refused by Command Code (403 MODEL_NOT_IN_PLAN), and that refusal reaches the agent.

  • 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). That is 56 models as of 2026-10-13. 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.