Skip to content

Claude Code. Any Model. The most powerful AI coding agent now speaks every language.

test(picker): point the N3 chat filter at the test's own catalog

Jack Rudenkoee56c2705a6f
diff --git a/packages/cli/src/model-selector.muse-code.test.ts b/packages/cli/src/model-selector.muse-code.test.ts
index 3860c860..9b422964 100644
--- a/packages/cli/src/model-selector.muse-code.test.ts
+++ b/packages/cli/src/model-selector.muse-code.test.ts
@@ -150,6 +150,9 @@ test("N3: discovery failure notice identifies the missing Muse login", async ()
});
test("N3: contributor-first cloud connections emit plain Meta specs and no implicit zgo contributor", async () => {
+ const { _setChatCapabilityCachePathForTest } = await import(
+ "./providers/transport/probe-discovery.js"
+ );
const { createCatalogClient } = await import("./providers/model-catalog.js");
const { servedModelsForProvider, resolveProviderExternalId } = await import(
"./model-selector.js"
@@ -202,10 +205,12 @@ test("N3: contributor-first cloud connections emit plain Meta specs and no impli
searchModels: async () => [],
});
try {
+ _setChatCapabilityCachePathForTest(cachePath);
const rows = servedModelsForProvider("meta", catalog);
expect(rows.map((r) => resolveProviderExternalId("meta", r))).toEqual(["muse-spark-1.3"]);
expect(servedModelsForProvider("opencode-zen-go", catalog)).toEqual([]);
} finally {
+ _setChatCapabilityCachePathForTest(undefined);
_clearAllModelsCacheMemo();
}
});
diff --git a/packages/cli/src/providers/transport/probe-discovery.ts b/packages/cli/src/providers/transport/probe-discovery.ts
index da322e57..a69e1145 100644
--- a/packages/cli/src/providers/transport/probe-discovery.ts
+++ b/packages/cli/src/providers/transport/probe-discovery.ts
@@ -131,6 +131,19 @@ export function _clearChatCapabilityIndex(): void {
_catalogChatIndex.clear();
}
+/**
+ * The catalog path {@link classifyChatCapability} reads when its caller passes none.
+ * Tests only: a caller several layers up (`servedModelsForProvider`, the picker) has
+ * no `cachePath` to forward, and Bun keeps `homedir()` on the real `~/.claudish`.
+ */
+let _defaultChatCapabilityCachePath: string | undefined;
+
+/** Point the chat filter at a test-owned catalog; `undefined` restores the real one. */
+export function _setChatCapabilityCachePathForTest(path: string | undefined): void {
+ _defaultChatCapabilityCachePath = path;
+ _catalogChatIndex.clear();
+}
+
/** The catalog key for an id: lowercased, vendor prefix dropped (`openai/x` is `x`). */
function catalogKey(name: string): string {
const lower = name.toLowerCase();
@@ -271,7 +284,7 @@ export function classifyChatCapability(
if (reported) return reported;
- const index = catalogCapabilityIndex(cachePath);
+ const index = catalogCapabilityIndex(cachePath ?? _defaultChatCapabilityCachePath);
const key = catalogKey(name);
if (index.nonTextOutput.has(key)) return "not-chat";