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).
This commit is contained in:
@@ -44,7 +44,7 @@ export function nameIndex() {
|
|||||||
index = new Map()
|
index = new Map()
|
||||||
if (rows) {
|
if (rows) {
|
||||||
const families = new Map()
|
const families = new Map()
|
||||||
const aliases = []
|
const claims = new Map() // display name -> the families that use it
|
||||||
for (const model of rows) {
|
for (const model of rows) {
|
||||||
const effort = /-(high|medium|low|minimal|xhigh|max)$/i.exec(model.id)?.[1]?.toLowerCase() || ""
|
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
|
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)
|
families.get(family).add(model.id)
|
||||||
const name = normalizeName(model.name)
|
const name = normalizeName(model.name)
|
||||||
if (!name) continue
|
if (!name) continue
|
||||||
if (index.has(name) && index.get(name).family !== family) continue // one name, two families: no match
|
for (const alias of [name, stripEffortSuffix(name)]) {
|
||||||
aliases.push([name, family], [stripEffortSuffix(name), family])
|
if (!claims.has(alias)) claims.set(alias, new Set())
|
||||||
|
claims.get(alias).add(family)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (const [family, ids] of families) {
|
for (const [family, ids] of families) {
|
||||||
// the bare id the catalog serves even when agy lists no variant of it
|
// the bare id the catalog serves even when agy lists no variant of it
|
||||||
ids.add(family)
|
ids.add(family)
|
||||||
}
|
}
|
||||||
for (const [name, family] of aliases) {
|
for (const [name, owners] of claims) {
|
||||||
if (index.has(name) && index.get(name).family !== family) continue
|
// 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) })
|
index.set(name, { family, ids: families.get(family) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@magpie-community/opencode-agy-cli-auth",
|
"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",
|
"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",
|
"type": "module",
|
||||||
"main": "./opencode.mjs",
|
"main": "./opencode.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".
|
// 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" }])
|
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"])
|
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)
|
storeCatalogRows(null)
|
||||||
})
|
})
|
||||||
|
|
||||||
const report = groups => ({ status: "SUCCESS", command: { name: "usage", data: { groups } } })
|
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 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 })
|
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", () => {
|
test("maps all groups/cadences to display-only Magpie windows, without invented identity", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user