import { describe, expect, it } from "vitest"; import { cliAgentRequest, cliModelRequest } from "./cli-model.js"; import { Orchestrator } from "./orchestrator.js"; import { getDefaultConfig, normalizeConfigDurations } from "./config.js"; describe("cliModelRequest", () => { it("reads --model, --provider and --thinking the way pi parses them", () => { expect(cliModelRequest(["--mode", "rpc", "--model", "sub/claude-opus-4-5", "--thinking", "high"])).toEqual({ model: "sub/claude-opus-4-5", provider: undefined, thinking: "high" }); expect(cliModelRequest(["--provider", "github-copilot", "--model", "claude-opus-4.5"])).toEqual({ model: "claude-opus-4.5", provider: "github-copilot", thinking: undefined }); expect(cliModelRequest(["--mode", "rpc", "--no-session"])).toBeNull(); }); }); describe("cliAgentRequest", () => { it("reads --pp-agent in either spelling, and an empty role when none follows", () => { expect(cliAgentRequest(["-p", "--pp-agent", "quick", "--no-session"])).toEqual({ role: "quick", check: false }); expect(cliAgentRequest(["-p", "--pp-agent=quick", "--pp-agent-check"])).toEqual({ role: "quick", check: true }); expect(cliAgentRequest(["-p", "--pp-agent", "--no-session"])).toEqual({ role: "", check: false }); expect(cliAgentRequest(["-p", "--no-session", "hello"])).toBeNull(); }); }); describe("Orchestrator.keepCliModel", () => { it("marks the session's model as picked by hand, so routing never moves it", () => { const orchestrator = new Orchestrator({} as any); orchestrator.config = normalizeConfigDurations(getDefaultConfig()); orchestrator.routedMainSpec = "github-copilot/claude-opus-4.5"; expect(orchestrator.keepCliModel({ model: "sub/claude-opus-4-5" })).toBe(true); expect(orchestrator.routedMainSpec).toBeNull(); expect(orchestrator.mainPickedByHand).toBe(true); }); it("does nothing without a request", () => { const orchestrator = new Orchestrator({} as any); expect(orchestrator.keepCliModel(null)).toBe(false); expect(orchestrator.mainPickedByHand).toBe(false); }); });