feat(ai): add max thinking level
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { isValidThinkingLevel } from "../src/cli/args.ts";
|
||||
import { SettingsManager } from "../src/core/settings-manager.ts";
|
||||
import { loadThemeFromPath } from "../src/modes/interactive/theme/theme.ts";
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
|
||||
afterEach(() => {
|
||||
for (const dir of tempDirs.splice(0)) {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
describe("max thinking level", () => {
|
||||
it("is accepted by CLI and settings", async () => {
|
||||
expect(isValidThinkingLevel("max")).toBe(true);
|
||||
|
||||
const settings = SettingsManager.inMemory();
|
||||
settings.setDefaultThinkingLevel("max");
|
||||
await settings.flush();
|
||||
expect(settings.getDefaultThinkingLevel()).toBe("max");
|
||||
});
|
||||
|
||||
it("falls back to thinkingXhigh for legacy themes", () => {
|
||||
const testDir = mkdtempSync(join(tmpdir(), "pi-max-theme-"));
|
||||
tempDirs.push(testDir);
|
||||
const currentDir = dirname(fileURLToPath(import.meta.url));
|
||||
const darkTheme = JSON.parse(
|
||||
readFileSync(join(currentDir, "../src/modes/interactive/theme/dark.json"), "utf8"),
|
||||
) as { name: string; colors: Record<string, unknown> };
|
||||
darkTheme.name = "legacy-theme";
|
||||
delete darkTheme.colors.thinkingMax;
|
||||
const themePath = join(testDir, "legacy-theme.json");
|
||||
writeFileSync(themePath, JSON.stringify(darkTheme));
|
||||
|
||||
const legacyTheme = loadThemeFromPath(themePath);
|
||||
expect(legacyTheme.getThinkingBorderColor("max")("border")).toBe(
|
||||
legacyTheme.getThinkingBorderColor("xhigh")("border"),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -107,7 +107,7 @@ describe("parseModelPattern", () => {
|
||||
});
|
||||
|
||||
test("all valid thinking levels work", () => {
|
||||
for (const level of ["off", "minimal", "low", "medium", "high", "xhigh"]) {
|
||||
for (const level of ["off", "minimal", "low", "medium", "high", "xhigh", "max"]) {
|
||||
const result = parseModelPattern(`sonnet:${level}`, allModels);
|
||||
expect(result.model?.id).toBe("claude-sonnet-4-5");
|
||||
expect(result.thinkingLevel).toBe(level);
|
||||
@@ -520,7 +520,7 @@ describe("resolveCliModel", () => {
|
||||
getAll: () => modelsWithNeuralwatt,
|
||||
} as unknown as Parameters<typeof resolveCliModel>[0]["modelRegistry"];
|
||||
|
||||
for (const level of ["off", "minimal", "low", "medium", "high", "xhigh"]) {
|
||||
for (const level of ["off", "minimal", "low", "medium", "high", "xhigh", "max"]) {
|
||||
const result = resolveCliModel({
|
||||
cliModel: `neuralwatt/zai-org/GLM-5.1-FP8:${level}`,
|
||||
modelRegistry: registry,
|
||||
|
||||
@@ -78,6 +78,26 @@ describe("AgentSession model and extension characterization", () => {
|
||||
expect(harness.session.cycleThinkingLevel()).toBeUndefined();
|
||||
});
|
||||
|
||||
it("cycles xhigh before max when both are supported", async () => {
|
||||
const harness = await createHarness({ models: [{ id: "faux-1", reasoning: true }] });
|
||||
harnesses.push(harness);
|
||||
harness.getModel().thinkingLevelMap = { xhigh: "xhigh", max: "max" };
|
||||
|
||||
expect(harness.session.getAvailableThinkingLevels()).toEqual([
|
||||
"off",
|
||||
"minimal",
|
||||
"low",
|
||||
"medium",
|
||||
"high",
|
||||
"xhigh",
|
||||
"max",
|
||||
]);
|
||||
harness.session.setThinkingLevel("high");
|
||||
expect(harness.session.cycleThinkingLevel()).toBe("xhigh");
|
||||
expect(harness.session.cycleThinkingLevel()).toBe("max");
|
||||
expect(harness.session.cycleThinkingLevel()).toBe("off");
|
||||
});
|
||||
|
||||
it("throws when setModel is called without configured auth", async () => {
|
||||
const harness = await createHarness({
|
||||
models: [
|
||||
|
||||
Reference in New Issue
Block a user