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", () => {