From 0262214e6709ebef9fc09323480f15eb1a3e5b12 Mon Sep 17 00:00:00 2001 From: yetone Date: Sun, 15 Nov 2026 20:35:40 +0800 Subject: [PATCH] agy-cli 0.1.66: a display name two families share names neither (#1180) model-ids.mjs's nameIndex said "one name, two families: no match" but kept whichever family came first: the check in its first loop read the index before anything was in it. Names are now collected with every family that claims them, and a name claimed by more than one maps to nothing, so a usage window never names the wrong family's ids. Also drops the unused groupNoDesc helper from test/usage.mjs. Both were noted in #1180's review. Run on macOS (mote), CI-style with a temp HOME: bun test packages/agy-cli, 35 pass, 0 fail; bun scripts/check.mjs agy-cli passes. Broken by hand: with #1180's model-ids.mjs and the new test, the test fails (34 pass, 1 fail). Not tried: a real agy catalog with a shared name (none is known today). --- packages/agy-cli/model-ids.mjs | 14 +++++++++----- packages/agy-cli/package.json | 2 +- packages/agy-cli/test/usage.mjs | 4 +++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/agy-cli/model-ids.mjs b/packages/agy-cli/model-ids.mjs index 99a9d16..cd7e20c 100644 --- a/packages/agy-cli/model-ids.mjs +++ b/packages/agy-cli/model-ids.mjs @@ -44,7 +44,7 @@ export function nameIndex() { index = new Map() if (rows) { const families = new Map() - const aliases = [] + const claims = new Map() // display name -> the families that use it for (const model of rows) { const effort = /-(high|medium|low|minimal|xhigh|max)$/i.exec(model.id)?.[1]?.toLowerCase() || "" const family = effort ? model.id.slice(0, -(effort.length + 1)) : model.id @@ -52,15 +52,19 @@ export function nameIndex() { families.get(family).add(model.id) const name = normalizeName(model.name) if (!name) continue - if (index.has(name) && index.get(name).family !== family) continue // one name, two families: no match - aliases.push([name, family], [stripEffortSuffix(name), family]) + for (const alias of [name, stripEffortSuffix(name)]) { + if (!claims.has(alias)) claims.set(alias, new Set()) + claims.get(alias).add(family) + } } for (const [family, ids] of families) { // the bare id the catalog serves even when agy lists no variant of it ids.add(family) } - for (const [name, family] of aliases) { - if (index.has(name) && index.get(name).family !== family) continue + for (const [name, owners] of claims) { + // one name, two families: no match, rather than whichever came first + if (owners.size !== 1) continue + const [family] = owners index.set(name, { family, ids: families.get(family) }) } } diff --git a/packages/agy-cli/package.json b/packages/agy-cli/package.json index 07fd91b..34dc62a 100644 --- a/packages/agy-cli/package.json +++ b/packages/agy-cli/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-agy-cli-auth", - "version": "0.1.65", + "version": "0.1.66", "description": "Magpie/OpenCode model provider that connects your local agy CLI through the Agent Client Protocol (agy acp), so Antigravity subscription models run through the real CLI", "type": "module", "main": "./opencode.mjs", diff --git a/packages/agy-cli/test/usage.mjs b/packages/agy-cli/test/usage.mjs index a271c5a..d6c877c 100644 --- a/packages/agy-cli/test/usage.mjs +++ b/packages/agy-cli/test/usage.mjs @@ -102,12 +102,14 @@ test("ids on windows follow the catalog, and names agy adds match nothing until // The separator list "A, B and C" also splits with no comma before "and". storeCatalogRows([{ id: "m1", name: "Model One" }, { id: "m2", name: "Model Two" }]) assert.deepEqual(modelsInGroup({ description: "Models within this group: Model One and Model Two" }), ["m1", "m2"]) + // One display name used by two families matches neither. + storeCatalogRows([{ id: "a-high", name: "Twin (High)", effort: "high" }, { id: "b", name: "Twin" }, { id: "c", name: "Solo" }]) + assert.deepEqual(modelsInGroup({ description: "Models within this group: Twin, Solo" }), ["c"]) storeCatalogRows(null) }) const report = groups => ({ status: "SUCCESS", command: { name: "usage", data: { groups } } }) const group = (buckets, name = "Gemini Models", description = "For paid Pro plans, Argon quota is separate.") => ({ name, description, buckets }) -const groupNoDesc = (buckets, name = "Gemini Models") => ({ name, buckets }) const bucket = (overrides = {}) => ({ id: "gemini-5h", name: "Five Hour Limit Remaining", window: "5h", remaining_fraction: 0.75, ...overrides }) test("maps all groups/cadences to display-only Magpie windows, without invented identity", () => {