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
5 changes: 4 additions & 1 deletion src/plugin/settingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issues on the handle only refreshes on reload(), so the note stays for the rest of the session. That includes switching to another engine and back to Claude Code. It's harmless, because the migrated value is what gets saved on the next change. I just wanted it noted in case someone wonders why the note outlives the fix.

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);
Expand Down
6 changes: 5 additions & 1 deletion src/shared/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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). */

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is out of date now. Codex CLI and the local model are both built, and nothing is listed as "later" any more. Something like "The agent engines Settings › Agents offers. A stored anthropic-api from older builds loads as claude-cli" would match the code.

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 {
Expand Down Expand Up @@ -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<string, unknown> = {};
Expand Down
2 changes: 1 addition & 1 deletion src/ui/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
7 changes: 7 additions & 0 deletions tests/kernel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 } });
Expand Down