commandcode 0.1.7: a list that can't be had says so — the Go table, or the defaults, handed back when Command Code's list fails is marked Symbol.for("magpie.fellBack"), and magpie keeps the list it was told last, as the built-in keeps the one it fetched last. models.test.mjs checks the mark on each failure and its absence on a list read.
This commit is contained in:
@@ -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 })
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user