Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions packages/cli/src/commands/doctor-opencode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,53 @@ describe("OpenCode model catalog parsing", () => {
),
).toEqual([{ agent: "historian", model: "provider/model", variant: "medium" }]);
});
it("checks variants on host catalog models whose IDs contain slashes", () => {
const catalog = [
{ providerID: "openrouter", id: "openrouter/free", variants: { high: {} } },
];
expect(
findUndeclaredConfiguredVariants(
[
{ agent: "historian", model: "openrouter/openrouter/free", variant: "medium" },
{ agent: "dreamer", model: "openrouter/openrouter/free", variant: "high" },
],
catalog,
),
).toEqual([{ agent: "historian", model: "openrouter/openrouter/free", variant: "medium" }]);
});
it("matches v2 host catalog entries whose model IDs contain slashes, as OpenRouter serves them", () => {
const warnings: string[] = [];
checkConfiguredVariantCatalog(
{
historian: { model: "openrouter/openrouter/free" },
dreamer: { model: "openrouter/dots-studio/dots-3-note-preview:free" },
},
"v2",
(message) => warnings.push(message),
() => ({
stdout: JSON.stringify({
location: { directory: "/tmp/project" },
data: [
{
id: "openrouter/free",
modelID: "openrouter/free",
providerID: "openrouter",
variants: [],
},
{
id: "dots-studio/dots-3-note-preview:free",
modelID: "dots-studio/dots-3-note-preview:free",
providerID: "openrouter",
variants: [],
},
],
}),
status: 0,
}),
"/tmp/project",
);
expect(warnings).toEqual([]);
});
it("checks real v2 model.list variant IDs for both missing and declared variants", () => {
// Captured from OpenCode 2.0.12 in an isolated root with a dummy API key.
const output = readFileSync(
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/src/commands/doctor-opencode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ export function findUndeclaredConfiguredVariants(
catalog: ReturnType<typeof parseOpenCodeModelCatalog>,
): Array<{ agent: string; model: string; variant: string }> {
return configured.filter((entry) => {
const [providerID, id] = entry.model.split("/", 2);
const [providerID, ...modelParts] = entry.model.split("/");
const id = modelParts.join("/");
const model = catalog.find((item) => item.providerID === providerID && item.id === id);
return model !== undefined && !Object.hasOwn(model.variants, entry.variant);
});
Expand All @@ -201,7 +202,8 @@ export function findUnknownConfiguredModels(
catalog: ReturnType<typeof parseOpenCodeModelCatalog>,
): Array<{ agent: string; model: string; fallback: boolean; unknown: "provider" | "model" }> {
return configured.flatMap((entry): Array<typeof entry & { unknown: "provider" | "model" }> => {
const [providerID, id] = entry.model.split("/", 2);
const [providerID, ...modelParts] = entry.model.split("/");
const id = modelParts.join("/");
if (!catalog.some((item) => item.providerID === providerID)) {
return [{ ...entry, unknown: "provider" as const }];
}
Expand Down
Loading