feat(models): add refresh-model-catalog skill

Add an agent skill that walks through a full model catalog refresh: drift
detection, catalog sync, manually reviewed pricing updates, fixture
refresh, and test updates. Its helper scripts run on Windows and Linux:
one snapshots the live model-id list into the test fixture, the other
regenerates the pricing fixture from MODEL_COSTS through prettier so
format:check stays green. Typecheck now covers the skill scripts.
This commit is contained in:
Thomas Byr
2026-08-28 17:00:39 +02:00
parent 425483e0e1
commit 8b5e4d78ba
5 changed files with 161 additions and 1 deletions
@@ -0,0 +1,40 @@
#!/usr/bin/env node
// Refreshes tests/fixtures/commandcode-model-ids.json from the live Command Code
// models API. Run from the repository root:
// node .agents/skills/refresh-model-catalog/scripts/refresh-model-ids.mjs
import { writeFile } from "node:fs/promises"
import { format, resolveConfig } from "prettier"
const MODELS_URL = "https://api.commandcode.ai/provider/v1/models"
const FIXTURE_PATH = new URL(
"../../../../tests/fixtures/commandcode-model-ids.json",
import.meta.url,
)
const response = await fetch(MODELS_URL)
if (!response.ok) {
throw new Error(`Failed to fetch Command Code models: ${response.status} ${response.statusText}`)
}
const body = await response.json()
if (body?.object !== "list" || !Array.isArray(body.data)) {
throw new Error("Expected a Command Code models list response")
}
const modelIds = body.data.map((model) => {
if (typeof model?.id !== "string" || model.id.length === 0) {
throw new Error("Expected each model entry to have a non-empty id")
}
return model.id
})
if (modelIds.length === 0) throw new Error("Command Code returned an empty model catalog")
const fixture = { fetchedAt: new Date().toISOString(), source: MODELS_URL, modelIds }
const options = await resolveConfig(new URL("../../../../.prettierrc.json", import.meta.url))
const contents = await format(JSON.stringify(fixture), {
...options,
filepath: "commandcode-model-ids.json",
})
await writeFile(FIXTURE_PATH, contents, "utf-8")
console.log(`Wrote ${modelIds.length} model ids to tests/fixtures/commandcode-model-ids.json`)