diff --git a/docs/specs/2026-09-20-catalog-freshness.md b/docs/specs/2026-09-20-catalog-freshness.md index 74b0814..3066e10 100644 --- a/docs/specs/2026-09-20-catalog-freshness.md +++ b/docs/specs/2026-09-20-catalog-freshness.md @@ -99,12 +99,12 @@ The unavailable list is sorted by ID so repeated synchronization is deterministi `https://commandcode.ai/docs/resources/pricing-limits` embeds every model row (`id`, `name`, `category`, `contextWindow`, `caps`, `deal`, `tiers` or `contextTiers`) in its Next.js flight payload. Synchronization decodes the `self.__next_f.push` chunks and parses the `rows` array. - Rows join availability items by exact ID, then by the vendor-less ID ignoring case and punctuation (`Qwen/Qwen3.7-Max` ↔ `qwen-3.7-max`), then by display name. A key shared by two rows never matches. This join selects pricing data only; it never makes an ID available. -- `contextWindow` is the catalog context authority. The live `context_length` is a cross-check: a disagreement is reported as a warning in the run log and the GitHub step summary. +- `contextWindow` is the catalog context authority. Positive models.dev input limits are capped at the catalog context window; non-positive input limits are ignored. The live `context_length` is a cross-check: a disagreement is reported as a warning in the run log and the GitHub step summary. - Costs use the billed `rates` (deal prices), never `listRates`, including `cacheWrite` when present. The first band is the base cost; each later band becomes a context tier priced above the previous band's upper bound (`≤ 32K` then `≤ 256K` then `> 256K` gives tiers at 32,000 and 256,000 tokens). A band billed like the previous band adds no tier. - For a model with an official row, official rates and tiers replace every other cost source, and models.dev context tiers are not applied. Models without an official row keep the existing waterfall (CLI, official table, free SKU, models.dev, models.dev tiers). - Official cost rows are counted under `costSources.officialDocs`. -If the page cannot be fetched or no `rows` array with at least two priced models parses, synchronization fails soft: it writes no generated artifact, exits zero, and appends a warning to the log and to `$GITHUB_STEP_SUMMARY`. The previous committed artifacts remain the published catalog. +If the page cannot be fetched or no `rows` array with at least two priced models parses, synchronization fails soft: it leaves `models.json`, `_version.txt`, and `manifest.json` untouched, exits zero, and logs a warning. When `$GITHUB_STEP_SUMMARY` is set, it also appends the warning to the GitHub Actions step summary. The previous committed artifacts remain the published catalog. ### Mutable OpenCode plugin packages @@ -150,6 +150,7 @@ This preserves deterministic startup and offline use. Freshness is delivered by - Cost, reasoning, and manifest counts are computed from the filtered catalog. - The official pricing-page fixture parses every embedded row, and its rows join all 111 live IDs of the matching availability fixture. - Official prices replace third-party tiers: `claude-sonnet-4-6` is flat 3/15 with no 200K tier, `gpt-5.5` is flat 5/30 with a 400K context, MiniMax M3 bills 0.3/1.2, and Qwen 3.7 Max has no 32K or 128K tier. +- `gpt-5.5`'s models.dev input limit of 922,000 is capped at its 400,000-token context; positive limits below context are kept unchanged. - Live IDs without a CLI candidate are synthesized from the official row (for example `subquadratic/subq-savant-1.4` with a 4,194,304-token context and the free `recursive/flint-v1.1:free` and `reflection/beam-contributor:free` at $0) and listed in `manifest.review.apiOnly`. - An unparseable pricing page leaves generated artifacts unchanged, exits zero, and records a step-summary warning. - `bun run check` passes after generated artifacts are refreshed. diff --git a/manifest.json b/manifest.json index fd611d5..2985b85 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, - "generatedAt": "2026-12-04T19:03:51.789Z", + "generatedAt": "2026-12-04T20:10:17.894Z", "pluginVersion": "0.13.0", "commandCodeVersion": "1.94.0", "commandCodeTarball": "https://registry.npmjs.org/command-code/-/command-code-1.94.0.tgz", diff --git a/models.json b/models.json index bdd68c8..4c6123c 100644 --- a/models.json +++ b/models.json @@ -533,7 +533,7 @@ "limit": { "context": 400000, "output": 128000, - "input": 922000 + "input": 400000 }, "attachment": true, "modalities": { @@ -612,7 +612,7 @@ "limit": { "context": 400000, "output": 128000, - "input": 922000 + "input": 400000 }, "attachment": true, "modalities": { @@ -3997,7 +3997,7 @@ "limit": { "context": 256000, "output": 65536, - "input": 262144 + "input": 256000 }, "attachment": true, "modalities": { diff --git a/scripts/sync-models.ts b/scripts/sync-models.ts index c745e56..19a6cbe 100644 --- a/scripts/sync-models.ts +++ b/scripts/sync-models.ts @@ -214,6 +214,21 @@ export function appendStepSummaryWarning( appendFileSync(summaryPath, `> [!WARNING]\n> ${warning}\n\n`, "utf-8"); } +/** Run the artifact-producing part of sync only when official pricing is available. */ +export async function runOfficialPricingStep( + official: OfficialPricingResult, + sync: (rows: OfficialModelRow[]) => Promise, + summaryPath?: string, +): Promise { + if (!official.ok) { + appendStepSummaryWarning(official.warning, summaryPath); + return false; + } + console.log(` Official model rows: ${official.rows.length}`); + await sync(official.rows); + return true; +} + /** Live context windows that disagree with the official catalog context. */ export function contextMismatches( models: ModelEntry[], @@ -350,6 +365,20 @@ async function main() { console.log("Fetching callable model availability..."); const vendorModels = await fetchAvailabilityModels(); + console.log(` Callable models: ${vendorModels.length}`); + + console.log("Fetching official pricing page..."); + const official = resolveOfficialPricing(await fetchOfficialPricingHtml()); + await runOfficialPricingStep(official, (rows) => + syncCatalog(vendorModels, rows, { forceRemote, shouldUpdateGlobal }), + ); +} + +async function syncCatalog( + vendorModels: ProviderModelMetadata[], + officialRows: OfficialModelRow[], + { forceRemote, shouldUpdateGlobal }: { forceRemote: boolean; shouldUpdateGlobal: boolean }, +) { const availableIds = vendorModels.map((model) => model.id); const vendorContextLengths = new Map(); for (const model of vendorModels) { @@ -357,15 +386,6 @@ async function main() { vendorContextLengths.set(model.id.toLowerCase(), model.context_length); } } - console.log(` Callable models: ${availableIds.length}`); - - console.log("Fetching official pricing page..."); - const official = resolveOfficialPricing(await fetchOfficialPricingHtml()); - if (!official.ok) { - appendStepSummaryWarning(official.warning); - return; - } - console.log(` Official model rows: ${official.rows.length}`); let version: string; let sourceLabel: string; @@ -406,7 +426,7 @@ async function main() { `filtered model count ${prefiltered.retained.length} below floor (lastSuccessful=${last}); leaving generated artifacts unchanged`, ); } - const officialMatches = matchOfficialRows(vendorModels, official.rows); + const officialMatches = matchOfficialRows(vendorModels, officialRows); const synthesized = synthesizeApiOnlyEntries({ liveModels: vendorModels, candidateIds: new Set(prefiltered.retained.map((e) => e.id)), diff --git a/src/costs-models-dev.ts b/src/costs-models-dev.ts index 07f8564..222b6d7 100644 --- a/src/costs-models-dev.ts +++ b/src/costs-models-dev.ts @@ -233,8 +233,9 @@ export function applyModelsDevMetadata(models: ModelEntry[], rows: ModelsDevRow[ model.status = row.status; changed = true; } - if (row.limit?.input !== undefined) { - model.limit.input = row.limit.input; + const input = Math.min(row.limit?.input ?? 0, model.limit.context); + if (input > 0) { + model.limit.input = input; changed = true; } if (changed) filled++; diff --git a/tests/unit/costs-models-dev.test.ts b/tests/unit/costs-models-dev.test.ts index 2b94025..f26abe9 100644 --- a/tests/unit/costs-models-dev.test.ts +++ b/tests/unit/costs-models-dev.test.ts @@ -154,6 +154,23 @@ describe("applyModelsDevModalities", () => { }); describe("applyModelsDevMetadata", () => { + test.each([ + { input: 922000, expected: 400000, filled: 1 }, + { input: 200000, expected: 200000, filled: 1 }, + { input: 0, expected: 100000, filled: 0 }, + { input: -1, expected: 100000, filled: 0 }, + ])("enriches a 400K context with input $input as $expected", ({ input, expected, filled }) => { + const entry = model({ + id: "openai/gpt-5.5", + name: "GPT-5.5", + limit: { context: 400000, input: 100000, output: 65536 }, + }); + expect( + applyModelsDevMetadata([entry], [{ id: entry.id, name: entry.name, limit: { input } }]), + ).toBe(filled); + expect(entry.limit).toEqual({ context: 400000, input: expected, output: 65536 }); + }); + test("applies present fields and preserves known values missing from a partial response", () => { const rows = parseModelsDev( JSON.stringify({ diff --git a/tests/unit/sync-models.test.ts b/tests/unit/sync-models.test.ts index e4b5269..385adb9 100644 --- a/tests/unit/sync-models.test.ts +++ b/tests/unit/sync-models.test.ts @@ -1,13 +1,13 @@ -import { expect, test, describe } from "bun:test"; +import { expect, test, describe, mock } from "bun:test"; import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "fs"; import { tmpdir } from "os"; import { join } from "path"; import { parseAvailabilityIds } from "@/src/catalog.ts"; import { - appendStepSummaryWarning, buildSyncArtifacts, contextMismatches, resolveOfficialPricing, + runOfficialPricingStep, } from "@/scripts/sync-models.ts"; import { lastSuccessfulModelCount, meetsModelCountFloor } from "@/src/manifest.ts"; import { ManifestSchema } from "@/src/schemas.ts"; @@ -21,23 +21,32 @@ describe("official pricing fail-soft", () => { } }); - test("the fixture page parses", () => { + test("a valid pricing page allows synchronization to continue with the parsed rows", async () => { const html = readFileSync( join(import.meta.dir, "../fixtures/command-code/pricing-limits.html.txt"), "utf-8", ); const result = resolveOfficialPricing(html); expect(result.ok && result.rows.length).toBe(115); + const sync = mock(() => Promise.resolve()); + expect(await runOfficialPricingStep(result, sync)).toBe(true); + if (result.ok) expect(sync).toHaveBeenCalledWith(result.rows); }); - test("the warning is appended to the step summary", () => { + test("an empty pricing page warns in the step summary and stops before artifact writes", async () => { const dir = mkdtempSync(join(tmpdir(), "sync-summary-")); try { const path = join(dir, "summary.md"); writeFileSync(path, "# Sync\n"); - appendStepSummaryWarning("pricing page unparseable", path); + const official = resolveOfficialPricing(""); + const sync = mock(() => { + throw new Error("artifact-producing sync must not run"); + }); + expect(official.ok).toBe(false); + expect(await runOfficialPricingStep(official, sync, path)).toBe(false); + expect(sync).not.toHaveBeenCalled(); expect(readFileSync(path, "utf-8")).toBe( - "# Sync\n> [!WARNING]\n> pricing page unparseable\n\n", + "# Sync\n> [!WARNING]\n> Official pricing page https://commandcode.ai/docs/resources/pricing-limits returned no parseable model rows; kept the previous models.json and manifest.json.\n\n", ); } finally { rmSync(dir, { recursive: true, force: true });