From bcd4a8b7631d211ebf212bd57af48e7efdc32e19 Mon Sep 17 00:00:00 2001 From: Daytonrad <106027925+Daytonrad@users.noreply.github.com> Date: Wed, 25 Nov 2026 08:40:32 -0700 Subject: [PATCH] Migrate the retired Anthropic API engine to Claude Code --- src/plugin/settingsTab.ts | 5 ++++- src/shared/settings.ts | 6 +++++- src/ui/copy.ts | 2 +- tests/kernel.test.ts | 7 +++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/plugin/settingsTab.ts b/src/plugin/settingsTab.ts index de1c63f..980f364 100644 --- a/src/plugin/settingsTab.ts +++ b/src/plugin/settingsTab.ts @@ -747,7 +747,10 @@ export class CortexSettingTab extends PluginSettingTab { const c = SETTINGS_COPY.agents; const a = s.agents; this.toggle(c.organise, c.organiseDesc, a.enabled, (x, v) => void (x.agents.enabled = v)); - this.dropdown(c.engine, a.engine === "none" ? c.engineNoneDesc : undefined, { "claude-cli": c.engineCli, "codex-cli": c.engineCodex, "anthropic-api": c.engineApi, local: c.engineLocal, none: c.engineNone }, a.engine, (x, v) => void (x.agents.engine = v), true); + this.dropdown(c.engine, a.engine === "none" ? c.engineNoneDesc : undefined, { "claude-cli": c.engineCli, "codex-cli": c.engineCodex, local: c.engineLocal, none: c.engineNone }, a.engine, (x, v) => void (x.agents.engine = v), true); + if (a.engine === "claude-cli" && this.host.settings().issues.some((issue) => issue.path === "agents.engine" && issue.problem === "unknown-value")) { + this.mount.createEl("p", { cls: "cx-note", text: c.engineApiMigrated }); + } if (a.engine === "local") this.localRows(a.local); else if (a.engine === "codex-cli") this.codexRows(a); else if (a.engine !== "none") this.claudeRows(a); diff --git a/src/shared/settings.ts b/src/shared/settings.ts index 4fc54bc..e6db113 100644 --- a/src/shared/settings.ts +++ b/src/shared/settings.ts @@ -43,7 +43,7 @@ export type MotionPref = "system" | "reduced" | "full"; export type AgeColours = "hue" | "lightness"; export type ModelRole = "labels" | "summaries" | "maps" | "ask"; /** Only the Claude Code CLI is built; the other two are listed as "later" and disabled (§5.27). */ -export type AgentEngineSetting = "claude-cli" | "anthropic-api" | "local" | "codex-cli" | "none"; +export type AgentEngineSetting = "claude-cli" | "local" | "codex-cli" | "none"; /** The Codex CLI engine (agents/codexCli.ts): the person's own OpenAI sign-in, run headless in a read-only sandbox. */ export interface CodexEngineSettings { @@ -513,6 +513,10 @@ function listIsWellFormed(path: string, raw: readonly unknown[]): boolean { function mergeAt(def: unknown, raw: unknown, path: string, issues: SettingsIssue[]): unknown { if (raw === undefined) return structuredCloneSafe(def); + if (path === "agents.engine" && raw === "anthropic-api") { + issues.push({ path, problem: "unknown-value", action: "used-default" }); + return "claude-cli"; + } if (isPlainObject(def)) { if (!isPlainObject(raw)) return fallback(def, path, issues); const out: Record = {}; diff --git a/src/ui/copy.ts b/src/ui/copy.ts index 60674e0..b2074eb 100644 --- a/src/ui/copy.ts +++ b/src/ui/copy.ts @@ -3742,7 +3742,7 @@ export const SETTINGS_COPY = { organiseDesc: "Agents label and summarise new material in the background, stopping at your plan caps, and suggest where things belong.", engine: "Engine", engineCli: "Claude Code CLI", - engineApi: "Anthropic API (later)", + engineApiMigrated: "Your earlier Anthropic API setting was loaded as Claude Code.", engineLocal: "A model on this computer", engineCodex: "Codex CLI (your OpenAI sign-in)", engineNone: "No model (plain rules)", diff --git a/tests/kernel.test.ts b/tests/kernel.test.ts index 8fb2c7d..02721ff 100644 --- a/tests/kernel.test.ts +++ b/tests/kernel.test.ts @@ -283,6 +283,13 @@ describe("plugin/notices + statusBar (§5.11)", () => { }); describe("shared/settings fail-safe migration (SAFE-08, §12.10)", () => { + it("loads the retired Anthropic API engine as Claude Code and reports the migration", () => { + const migrated = migrateSettingsChecked({ agents: { engine: "anthropic-api" } }); + expect(migrated.settings.agents.engine).toBe("claude-cli"); + expect(migrated.issues).toContainEqual({ path: "agents.engine", problem: "unknown-value", action: "used-default" }); + expect(migrated.corrupt).toBe(false); + expect(migrateSettingsChecked(migrated.settings).issues).toEqual([]); + }); it("defaults follow CORTEX-UX §5.27", () => { const s = DEFAULT_SETTINGS; expect(s.agents.planCaps).toEqual({ fiveHour: { on: true, pct: 70 }, weekly: { on: true, pct: 70 } });