diff --git a/src/plugin-config.test.ts b/src/plugin-config.test.ts index 5e2cd08aa..c1bc3441b 100644 --- a/src/plugin-config.test.ts +++ b/src/plugin-config.test.ts @@ -370,4 +370,30 @@ describe("detectUnknownBuiltinAgentKeys", () => { expect(unknownKeys).toEqual([]) }) + + it("excludes typo keys when explicitly provided", () => { + const rawConfig = { + agents: { + sisyphuss: { model: "openai/gpt-5.2" }, + translator: { model: "google/gemini-3-flash-preview" }, + }, + } + + const unknownKeys = detectUnknownBuiltinAgentKeys(rawConfig, ["sisyphuss"]) + + expect(unknownKeys).toEqual(["translator"]) + }) + + it("excludes typo keys case-insensitively", () => { + const rawConfig = { + agents: { + Sisyphuss: { model: "openai/gpt-5.2" }, + translator: { model: "google/gemini-3-flash-preview" }, + }, + } + + const unknownKeys = detectUnknownBuiltinAgentKeys(rawConfig, ["sisyphuss"]) + + expect(unknownKeys).toEqual(["translator"]) + }) }) diff --git a/src/plugin-config.ts b/src/plugin-config.ts index 37b3ff49b..c480f9848 100644 --- a/src/plugin-config.ts +++ b/src/plugin-config.ts @@ -81,12 +81,21 @@ export function detectLikelyBuiltinAgentTypos( export function detectUnknownBuiltinAgentKeys( rawConfig: Record, + excludeKeys: string[] = [], ): string[] { const agents = rawConfig.agents; if (!agents || typeof agents !== "object") return []; + const excluded = new Set(excludeKeys.map((key) => key.toLowerCase())); + return Object.keys(agents).filter( - (key) => !BUILTIN_AGENT_OVERRIDE_KEYS_BY_LOWER.has(key.toLowerCase()), + (key) => { + const lower = key.toLowerCase(); + return ( + !BUILTIN_AGENT_OVERRIDE_KEYS_BY_LOWER.has(lower) + && !excluded.has(lower) + ); + }, ); } @@ -194,7 +203,10 @@ export function loadConfigFromPath( }); } - const unknownAgentKeys = detectUnknownBuiltinAgentKeys(rawConfig); + const unknownAgentKeys = detectUnknownBuiltinAgentKeys( + rawConfig, + typoWarnings.map((warning) => warning.key), + ); if (unknownAgentKeys.length > 0) { const unknownKeysMsg = unknownAgentKeys.map((key) => `agents.${key}`).join(", "); const migrationHint = "Move custom entries from agents.* to custom_agents.*";