Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
test: cover the v3 reader-gap fixes, and guard the retired "roster"
Jack Rudenko5d87942f88ab
diff --git a/packages/cli/src/adapters/gemini-api-format-claude-budget.test.ts b/packages/cli/src/adapters/gemini-api-format-claude-budget.test.tsnew file mode 100644index 00000000..4fc0d56c--- /dev/null+++ b/packages/cli/src/adapters/gemini-api-format-claude-budget.test.ts@@ -0,0 +1,46 @@+import { describe, expect, test } from "bun:test";+import { GeminiAPIFormat } from "./gemini-api-format.js";++interface ThinkingPayload {+ generationConfig: {+ thinkingConfig?: {+ thinkingBudget?: number;+ };+ };+}++function buildThinkingPayload(modelId: string, maxTokens: number, effort: string): ThinkingPayload {+ return new GeminiAPIFormat(modelId).buildPayload(+ { max_tokens: maxTokens, output_config: { effort } },+ [],+ []+ ) as ThinkingPayload;+}++describe("Claude thinking budget below max_tokens", () => {+ // Mutation target: gemini-api-format.ts:303-307. Returning the original+ // effort budget instead of the fitted value breaks the first, second and fourth cases.+ test.each([+ [16000, "high", 8000],+ [8000, "medium", 4000],+ [32000, "high", 16384],+ ])("fits Claude max_tokens=%d effort=%s to %d", (maxTokens, effort, expected) => {+ expect(+ buildThinkingPayload("claude-sonnet-4-6", maxTokens, effort).generationConfig.thinkingConfig+ ?.thinkingBudget+ ).toBe(expected);+ });++ test("omits thinking when half the Claude output cap is below its minimum", () => {+ expect(+ buildThinkingPayload("claude-sonnet-4-6", 1500, "high").generationConfig.thinkingConfig+ ).toBeUndefined();+ });++ test("does not apply the Claude cap rule to Gemini", () => {+ expect(+ buildThinkingPayload("gemini-2.5-flash", 8000, "medium").generationConfig.thinkingConfig+ ?.thinkingBudget+ ).toBe(8192);+ });+});diff --git a/packages/cli/src/providers/all-models-cache-separation.test.ts b/packages/cli/src/providers/all-models-cache-separation.test.tsnew file mode 100644index 00000000..e18a2638--- /dev/null+++ b/packages/cli/src/providers/all-models-cache-separation.test.ts@@ -0,0 +1,54 @@+import { describe, expect, test } from "bun:test";+import { readFileSync, readdirSync } from "node:fs";+import { join, relative, resolve, sep } from "node:path";+import { ALL_MODELS_CACHE_PATH } from "./all-models-cache.js";++const sourceRoot = resolve(import.meta.dir, "..");+const mcpServerPath = resolve(sourceRoot, "mcp-server.ts");++function sourceFiles(dir: string): string[] {+ const files: string[] = [];+ for (const entry of readdirSync(dir, { withFileTypes: true })) {+ const path = join(dir, entry.name);+ if (entry.isDirectory()) {+ if (entry.name !== "node_modules" && entry.name !== "dist") files.push(...sourceFiles(path));+ } else if (entry.isFile() && !entry.name.endsWith(".test.ts")) {+ files.push(path);+ }+ }+ return files;+}++describe("catalog cache file separation", () => {+ // Mutation targets: all-models-cache.ts:102 and mcp-server.ts:93. Restoring+ // either writer to the retired filename makes these path/source guards fail.+ test("the cloud models catalog uses its v3-specific cache file", () => {+ expect(+ ALL_MODELS_CACHE_PATH.endsWith(`${sep}.claudish${sep}cloud-models-catalog-v3.json`)+ ).toBe(true);+ });++ test("production source does not assign or join the retired cache filename", () => {+ const retiredLiteral = /["']all-models\.json["']/;+ const pathConstruction = /\b(?:join|resolve)\s*\(|=/;+ const offenders: string[] = [];++ for (const file of sourceFiles(sourceRoot)) {+ const lines = readFileSync(file, "utf-8").split("\n");+ for (const [index, line] of lines.entries()) {+ if (retiredLiteral.test(line) && pathConstruction.test(line)) {+ offenders.push(`${relative(sourceRoot, file)}:${index + 1}`);+ }+ }+ }++ expect(offenders, `retired cache path writers:\n${offenders.join("\n")}`).toEqual([]);+ });++ test("the MCP OpenRouter list uses its own cache file without importing the server", () => {+ const source = readFileSync(mcpServerPath, "utf-8");+ expect(source).toMatch(+ /OPENROUTER_MODELS_CACHE_PATH\s*=\s*join\([^\n)]*["']openrouter-models\.json["']\)/+ );+ });+});diff --git a/packages/cli/src/providers/catalog-client-v3-reader-gaps.test.ts b/packages/cli/src/providers/catalog-client-v3-reader-gaps.test.tsnew file mode 100644index 00000000..e5953004--- /dev/null+++ b/packages/cli/src/providers/catalog-client-v3-reader-gaps.test.ts@@ -0,0 +1,80 @@+import { describe, expect, test } from "bun:test";+import { readFileSync } from "node:fs";+import { resolve } from "node:path";+import type { SlimModelEntry } from "./all-models-cache.js";+import { buildCatalogPageUrl, externalIdFor, isMovingPointer } from "./catalog-client.js";++interface CatalogFixture {+ entries: SlimModelEntry[];+}++const fixture = JSON.parse(+ readFileSync(+ resolve(import.meta.dir, "../test-fixtures/catalog-v3/rows-g-20260919013346169.json"),+ "utf-8"+ )+) as CatalogFixture;++function fixtureEntry(modelId: string): SlimModelEntry {+ const entry = fixture.entries.find((candidate) => candidate.modelId === modelId);+ if (!entry) throw new Error(`Fixture is missing ${modelId}`);+ return entry;+}++describe("catalog v3 exact wire ids", () => {+ // Mutation targets: catalog-client.ts:123 and :148-149. Dropping the latest+ // suffix rule breaks pointer classification; returning wireIds[0] selects the+ // Kimi pointer and makes the reduced-row assertion return it instead of null.+ test("selects an exact id instead of a moving pointer listed first", () => {+ expect(externalIdFor(fixtureEntry("kimi-k3"), "openrouter")).toBe("moonshotai/kimi-k3");+ });++ test("preserves a pointer when the canonical model id itself requests latest", () => {+ expect(externalIdFor(fixtureEntry("gemini-flash-latest"), "google")).toBe(+ "gemini-flash-latest"+ );+ });++ test.each([+ ["~moonshotai/kimi-latest", true],+ ["gemini-flash-latest", true],+ ["vendor/foo-latest", true],+ ["moonshotai/kimi-k3", false],+ ["k3", false],+ ["latest-model-x", false],+ ])("classifies %s as moving=%s", (wireId, expected) => {+ expect(isMovingPointer(wireId)).toBe(expected);+ });++ test("returns null when a pinned model has only a pointer connection", () => {+ const realKimi = fixtureEntry("kimi-k3");+ // This is the real Kimi fixture row reduced to its one OpenRouter pointer connection.+ const pointerOnly: SlimModelEntry = {+ ...realKimi,+ aggregators: realKimi.aggregators?.filter(+ (candidate) =>+ candidate.routeStatus === "mapped" &&+ candidate.route?.routeId === "openrouter" &&+ candidate.externalModelId === "~moonshotai/kimi-latest"+ ),+ };++ expect(externalIdFor(pointerOnly, "openrouter")).toBeNull();+ });+});++describe("catalog v3 page URL", () => {+ // Mutation targets: catalog-client.ts:257-258. Removing either set() drops a+ // required projection flag; URLSearchParams.set also proves existing keys are not duplicated.+ test.each([+ ["https://catalog.test/queryModels", undefined],+ ["https://catalog.test/queryModels?catalog=slim&status=active", "next-page"],+ ])("sets required parameters for %s", (baseUrl, cursor) => {+ const url = new URL(buildCatalogPageUrl(baseUrl, cursor, 1000));++ expect(url.searchParams.getAll("status")).toEqual(["all"]);+ expect(url.searchParams.getAll("includeRouteVariants")).toEqual(["true"]);+ expect(url.searchParams.get("catalog")).toBe(baseUrl.includes("catalog=") ? "slim" : null);+ expect(url.searchParams.get("cursor")).toBe(cursor ?? null);+ });+});diff --git a/packages/cli/src/providers/probe-live-provider-effort.test.ts b/packages/cli/src/providers/probe-live-provider-effort.test.tsnew file mode 100644index 00000000..c6cfc070--- /dev/null+++ b/packages/cli/src/providers/probe-live-provider-effort.test.ts@@ -0,0 +1,74 @@+import { describe, expect, test } from "bun:test";+import { probeLink } from "./probe-live.js";++interface CapturedProbeBody {+ output_config?: { effort?: string };+}++const MINIMAL_ANTHROPIC_SSE = [+ 'event: message_start\ndata: {"type":"message_start","message":{"id":"msg_test","type":"message","role":"assistant","content":[],"model":"test","stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":1,"output_tokens":0}}}',+ 'event: content_block_delta\ndata: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"ok"}}',+ 'event: message_stop\ndata: {"type":"message_stop"}',+ "",+].join("\n\n");++async function captureProbeBody(provider: string): Promise<CapturedProbeBody> {+ let captured: CapturedProbeBody | undefined;+ const handleRequest = async (request: Request): Promise<Response> => {+ const url = new URL(request.url);+ if (request.method !== "POST" || url.pathname !== "/v1/messages") {+ return new Response("not found", { status: 404 });+ }+ captured = (await request.json()) as CapturedProbeBody;+ return new Response(MINIMAL_ANTHROPIC_SSE, {+ headers: { "Content-Type": "text/event-stream" },+ });+ };++ let server: ReturnType<typeof Bun.serve> | undefined;+ let proxyUrl = "http://proxy.test";+ const realFetch = globalThis.fetch;+ try {+ server = Bun.serve({ port: 0, fetch: handleRequest });+ proxyUrl = `http://localhost:${server.port}`;+ } catch (error) {+ // The Codex filesystem sandbox used for local validation denies every bind+ // as EADDRINUSE. Normal runs use Bun.serve; this preserves the same Request+ // handler and body/SSE round-trip when local sockets are unavailable.+ if ((error as { code?: unknown }).code !== "EADDRINUSE") throw error;+ globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) =>+ handleRequest(new Request(input, init))) as typeof fetch;+ }++ try {+ const result = await probeLink(+ proxyUrl,+ { provider, modelSpec: `${provider}@test-model`, hasCredentials: true },+ 1000+ );+ expect(result.state).toBe("live");+ } finally {+ server?.stop(true);+ globalThis.fetch = realFetch;+ }++ if (!captured) throw new Error("probeLink did not POST a JSON body");+ return captured;+}++describe("probe effort per provider", () => {+ // Mutation targets: probe-live.ts:120, :136 and :140. Removing Antigravity+ // from EFFORT_OMITTED adds minimal; dropping the Anthropic set sends minimal;+ // changing the default sends low to OpenAI.+ test("Antigravity omits output_config", async () => {+ expect(await captureProbeBody("antigravity")).not.toHaveProperty("output_config");+ });++ test("native Anthropic uses low effort", async () => {+ expect((await captureProbeBody("native-anthropic")).output_config?.effort).toBe("low");+ });++ test("OpenAI uses minimal effort", async () => {+ expect((await captureProbeBody("openai")).output_config?.effort).toBe("minimal");+ });+});diff --git a/packages/cli/src/providers/transport/antigravity-probe-discovery.test.ts b/packages/cli/src/providers/transport/antigravity-probe-discovery.test.tsnew file mode 100644index 00000000..b7d53e1b--- /dev/null+++ b/packages/cli/src/providers/transport/antigravity-probe-discovery.test.ts@@ -0,0 +1,20 @@+import { describe, expect, test } from "bun:test";+import { readFileSync } from "node:fs";+import { resolve } from "node:path";+import { AntigravityProviderTransport } from "./antigravity.js";++describe("Antigravity probe discovery", () => {+ // Mutation targets: antigravity.ts:364-365. Removing the method breaks the+ // proxy's capability check; dropping its third argument loses the exclusion set.+ test("exposes discoverProbeModel to the proxy route", () => {+ const transport = new AntigravityProviderTransport("gemini-3.8-flash");+ expect(typeof transport.discoverProbeModel).toBe("function");+ });++ test("forwards exclude to shared account-scoped discovery without a live API call", () => {+ const source = readFileSync(resolve(import.meta.dir, "antigravity.ts"), "utf-8");+ expect(source).toMatch(+ /discoverProbeModel\(exclude\?[^)]*\)[\s\S]*?discoverProviderProbeModel\(this\.name,\s*this\.displayName,\s*exclude\)/+ );+ });+});diff --git a/packages/cli/src/providers/transport/probe-discovery-catalog-chat-capability.test.ts b/packages/cli/src/providers/transport/probe-discovery-catalog-chat-capability.test.tsnew file mode 100644index 00000000..1df92ba6--- /dev/null+++ b/packages/cli/src/providers/transport/probe-discovery-catalog-chat-capability.test.ts@@ -0,0 +1,69 @@+import { afterEach, beforeEach, describe, expect, test } from "bun:test";+import { mkdtempSync, readFileSync, rmSync } from "node:fs";+import { tmpdir } from "node:os";+import { join, resolve } from "node:path";+import { type DiskCacheV3, type SlimModelEntry, writeAllModelsCache } from "../all-models-cache.js";+import {+ _clearChatCapabilityIndex,+ classifyChatCapability,+ isChatCapable,+} from "./probe-discovery.js";++interface CatalogFixture {+ provenance: { catalogGenerationId: string };+ entries: SlimModelEntry[];+}++const fixture = JSON.parse(+ readFileSync(+ resolve(import.meta.dir, "../../test-fixtures/catalog-v3/rows-g-20260919013346169.json"),+ "utf-8"+ )+) as CatalogFixture;++let tempDir = "";+let cachePath = "";++beforeEach(() => {+ _clearChatCapabilityIndex();+ tempDir = mkdtempSync(join(tmpdir(), "claudish-chat-capability-"));+ cachePath = join(tempDir, "cloud-models-catalog-v3.json");+ const cache: DiskCacheV3 = {+ version: 3,+ lastUpdated: "2026-09-19T01:33:46.169Z",+ catalogGenerationId: fixture.provenance.catalogGenerationId,+ entries: fixture.entries,+ models: [],+ plans: [],+ };+ writeAllModelsCache(cache, cachePath);+});++afterEach(() => {+ _clearChatCapabilityIndex();+ rmSync(tempDir, { recursive: true, force: true });+});++describe("chat capability from the catalog", () => {+ // Mutation targets: probe-discovery.ts:150, :181 and :195. Removing the catalog+ // videoOutput denial breaks Omni; treating videoInput as output breaks 3.8 Flash;+ // requiring literal "chat" instead of anything but "not-chat" breaks unknowns.+ test("video output is not chat", () => {+ expect(classifyChatCapability("gemini-omni-1.1-flash", cachePath)).toBe("not-chat");+ });++ test("video input alone does not exclude a chat model", () => {+ expect(classifyChatCapability("gemini-3.8-flash", cachePath)).not.toBe("not-chat");+ });++ test("the video-name fallback applies to names absent from the catalog", () => {+ expect(classifyChatCapability("unpublished-model-t2v", cachePath)).toBe("not-chat");+ });++ test.each(["unpublished-model-t2v", "unpublished-chat-model"])(+ "isChatCapable is the boolean projection for %s",+ (name) => {+ expect(isChatCapable(name)).toBe(classifyChatCapability(name) !== "not-chat");+ }+ );+});diff --git a/scripts/no-retired-terms.test.ts b/scripts/no-retired-terms.test.tsnew file mode 100644index 00000000..c1d26db1--- /dev/null+++ b/scripts/no-retired-terms.test.ts@@ -0,0 +1,36 @@+import { test } from "bun:test";+import { readFileSync, readdirSync } from "node:fs";+import { join, relative, resolve } from "node:path";++const repositoryRoot = resolve(import.meta.dir, "..");+const thisFile = resolve(import.meta.path);++function filesUnder(dir: string): string[] {+ const files: string[] = [];+ for (const entry of readdirSync(dir, { withFileTypes: true })) {+ if (entry.name === "node_modules" || entry.name === "dist") continue;+ const path = join(dir, entry.name);+ if (entry.isDirectory()) files.push(...filesUnder(path));+ else if (entry.isFile() && resolve(path) !== thisFile) files.push(path);+ }+ return files;+}++test("packages and scripts contain no retired terminology", () => {+ // Mutation target: agent-availability.ts:24. Restoring its previous wording+ // is a representative one-line rename revert and must be reported as file:line.+ const findings: string[] = [];+ for (const root of [join(repositoryRoot, "packages"), join(repositoryRoot, "scripts")]) {+ for (const file of filesUnder(root)) {+ for (const [index, line] of readFileSync(file, "utf-8").split("\n").entries()) {+ if (/\broster\b/i.test(line)) {+ findings.push(`${relative(repositoryRoot, file)}:${index + 1}: ${line.trim()}`);+ }+ }+ }+ }++ if (findings.length > 0) {+ throw new Error(`Retired terminology found:\n${findings.join("\n")}`);+ }+});