1b9d9d0851
Move bundled models, model cache/manager, thinking metadata, effort helpers, provider descriptors/discovery, wire constants, and model identity utilities into the new @oh-my-pi/pi-catalog package. Update pi-ai to keep provider runtime/auth concerns, move catalog provider metadata into CATALOG_PROVIDERS, and migrate coding-agent, agent, stats, docs, and tests to import catalog values from pi-catalog. Split coding-agent model registry helpers into discovery, roles, and models config modules while preserving registry orchestration. BREAKING CHANGE: @oh-my-pi/pi-ai no longer exports catalog subpaths such as /models, /model-cache, /model-manager, /model-thinking, /effort, /provider-models*, discovery helpers, and provider wire constants; use the matching @oh-my-pi/pi-catalog subpaths instead.
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "bun:test";
|
|
import { Effort } from "@oh-my-pi/pi-ai";
|
|
import { getBundledModel } from "@oh-my-pi/pi-catalog/models";
|
|
import { resolvePrimaryModel, resolveSmolModel } from "@oh-my-pi/pi-coding-agent/commit/model-selection";
|
|
|
|
function getModelOrThrow(id: string) {
|
|
const model = getBundledModel("anthropic", id);
|
|
if (!model) throw new Error(`Expected model ${id}`);
|
|
return model;
|
|
}
|
|
|
|
function createSettings(modelRoles: Record<string, string>) {
|
|
return {
|
|
getModelRole(role: string) {
|
|
return modelRoles[role];
|
|
},
|
|
getStorage() {
|
|
return undefined;
|
|
},
|
|
setModelRole(role: string, value: string) {
|
|
modelRoles[role] = value;
|
|
},
|
|
get(path: string) {
|
|
if (path === "modelRoles") return modelRoles;
|
|
return undefined;
|
|
},
|
|
} as never;
|
|
}
|
|
|
|
describe("commit role thinking selection", () => {
|
|
it("returns explicit thinking for commit and smol roles, including alias overrides", async () => {
|
|
const defaultModel = getModelOrThrow("claude-sonnet-4-5");
|
|
const commitModel = getModelOrThrow("claude-opus-4-5");
|
|
const settings = createSettings({
|
|
default: `${defaultModel.provider}/${defaultModel.id}:high`,
|
|
commit: `${commitModel.provider}/${commitModel.id}:low`,
|
|
smol: "pi/default:minimal",
|
|
});
|
|
const registry = {
|
|
getAvailable: () => [defaultModel, commitModel],
|
|
getApiKey: async () => "test-key",
|
|
getApiKeyForProvider: async () => "test-key",
|
|
authStorage: { rotateSessionCredential: async () => false as const },
|
|
resolver: () => async () => "test-key",
|
|
};
|
|
|
|
const primary = await resolvePrimaryModel(undefined, settings, registry);
|
|
expect(primary.model.id).toBe(commitModel.id);
|
|
expect(primary.thinkingLevel).toBe(Effort.Low);
|
|
|
|
const smol = await resolveSmolModel(settings, registry, commitModel, "fallback-key");
|
|
expect(smol.model.id).toBe(defaultModel.id);
|
|
expect(smol.thinkingLevel).toBe(Effort.Minimal);
|
|
});
|
|
});
|