From ea1ab932ef6d03e5155cee0ada5e6a6a50b75ae7 Mon Sep 17 00:00:00 2001 From: yetone Date: Thu, 1 Oct 2026 17:06:07 +0800 Subject: [PATCH] =?UTF-8?q?commandcode=200.1.7:=20a=20list=20that=20can't?= =?UTF-8?q?=20be=20had=20says=20so=20=E2=80=94=20the=20Go=20table,=20or=20?= =?UTF-8?q?the=20defaults,=20handed=20back=20when=20Command=20Code's=20lis?= =?UTF-8?q?t=20fails=20is=20marked=20Symbol.for("magpie.fellBack"),=20and?= =?UTF-8?q?=20magpie=20keeps=20the=20list=20it=20was=20told=20last,=20as?= =?UTF-8?q?=20the=20built-in=20keeps=20the=20one=20it=20fetched=20last.=20?= =?UTF-8?q?models.test.mjs=20checks=20the=20mark=20on=20each=20failure=20a?= =?UTF-8?q?nd=20its=20absence=20on=20a=20list=20read.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/commandcode/index.mjs | 17 ++++++++++++++--- packages/commandcode/models.test.mjs | 2 ++ packages/commandcode/package.json | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/commandcode/index.mjs b/packages/commandcode/index.mjs index 9585ba3..3c358ef 100644 --- a/packages/commandcode/index.mjs +++ b/packages/commandcode/index.mjs @@ -53,6 +53,10 @@ const MODELS = [ // and give that list the reasoning levels and pictures it doesn't say — // magpie's cmdGoModels. const EFF5 = ["low", "medium", "high", "xhigh", "max"] +// FELL_BACK marks a list handed back for one that can't be had (magpie's +// plugin host reads it; OpenCode never sees a symbol's key) +const FELL_BACK = Symbol.for("magpie.fellBack") + const GO_MODELS = [ { id: "gpt-6-luna", name: "GPT-6 Luna", context: 1_050_000, images: true, efforts: EFF5 }, { id: "gpt-5.6-luna", name: "GPT-5.6 Luna", context: 1_050_000, images: true, efforts: EFF5 }, @@ -1121,15 +1125,22 @@ export async function CommandCodePlugin({ client } = {}) { const key = await liveKey(auth) if ((await planNow(key, auth.metadata?.plan)) === "Go") { let ms = GO_MODELS + let fell = false try { ms = await goModels() - } catch {} - return Object.fromEntries(ms.map((m) => [m.id, runtimeModel({ ...m, npm: CHAT })])) + } catch { + fell = true + } + const out = Object.fromEntries(ms.map((m) => [m.id, runtimeModel({ ...m, npm: CHAT })])) + // the CLI's table stands in: magpie keeps the list it was told + // last, as the built-in keeps the one it fetched last + if (fell) out[FELL_BACK] = true + return out } try { return Object.fromEntries((await liveModels(key)).map((m) => [m.id, runtimeModel(m)])) } catch { - return provider.models + return Object.assign(provider.models, { [FELL_BACK]: true }) } }, }, diff --git a/packages/commandcode/models.test.mjs b/packages/commandcode/models.test.mjs index 10ceb34..5f3fde4 100644 --- a/packages/commandcode/models.test.mjs +++ b/packages/commandcode/models.test.mjs @@ -54,6 +54,7 @@ test("Go lists Command Code's models less those Go is refused, asked without the expect(Object.keys(k3.variants)).toEqual(["low", "high", "max"]) expect(k3.capabilities.attachment).toBe(true) expect(k3.limit.context).toBe(1_000_000) + expect(ms[Symbol.for("magpie.fellBack")]).toBeUndefined() // every Go model on chat completions, which the fetch sends to /alpha/generate expect(new Set(Object.values(ms).map((m) => m.api.npm))).toEqual(new Set(["@ai-sdk/openai-compatible"])) }) @@ -64,6 +65,7 @@ test("the CLI's table stands in when the list can't be had, and offers nothing G for (const reply of [500, "not json", JSON.stringify({ data: [] }), JSON.stringify({ data: [{ id: "claude-opus-5-5" }, { id: "gpt-6-sol" }] })]) { const { ms } = await models(reply) expect(Object.keys(ms)).toEqual(_internal.GO_MODELS.map((m) => m.id)) + expect(ms[Symbol.for("magpie.fellBack")]).toBe(true) } }) diff --git a/packages/commandcode/package.json b/packages/commandcode/package.json index 40ff52b..a401494 100644 --- a/packages/commandcode/package.json +++ b/packages/commandcode/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-commandcode-auth", - "version": "0.1.6", + "version": "0.1.7", "description": "Command Code plans (Pro, GOAT, Max, Ultra, Go, Teams) in OpenCode and magpie", "type": "module", "main": "./index.mjs",