refactor(agents): use lowercase config keys in utils

This commit is contained in:
justsisyphus 2026-01-23 21:27:26 +09:00
parent 90292db4c4
commit 91060c35ab
5 changed files with 49 additions and 49 deletions

View File

@ -57,14 +57,14 @@ export function isGptModel(model: string): boolean {
} }
export type BuiltinAgentName = export type BuiltinAgentName =
| "Sisyphus" | "sisyphus"
| "oracle" | "oracle"
| "librarian" | "librarian"
| "explore" | "explore"
| "multimodal-looker" | "multimodal-looker"
| "Metis (Plan Consultant)" | "metis"
| "Momus (Plan Reviewer)" | "momus"
| "Atlas" | "atlas"
export type OverridableAgentName = export type OverridableAgentName =
| "build" | "build"

View File

@ -12,24 +12,24 @@ describe("createBuiltinAgents with model overrides", () => {
const agents = await createBuiltinAgents([], {}, undefined, TEST_DEFAULT_MODEL) const agents = await createBuiltinAgents([], {}, undefined, TEST_DEFAULT_MODEL)
// #then // #then
expect(agents.Sisyphus.model).toBe("anthropic/claude-opus-4-5") expect(agents.sisyphus.model).toBe("anthropic/claude-opus-4-5")
expect(agents.Sisyphus.thinking).toEqual({ type: "enabled", budgetTokens: 32000 }) expect(agents.sisyphus.thinking).toEqual({ type: "enabled", budgetTokens: 32000 })
expect(agents.Sisyphus.reasoningEffort).toBeUndefined() expect(agents.sisyphus.reasoningEffort).toBeUndefined()
}) })
test("Sisyphus with GPT model override has reasoningEffort, no thinking", async () => { test("Sisyphus with GPT model override has reasoningEffort, no thinking", async () => {
// #given // #given
const overrides = { const overrides = {
Sisyphus: { model: "github-copilot/gpt-5.2" }, sisyphus: { model: "github-copilot/gpt-5.2" },
} }
// #when // #when
const agents = await createBuiltinAgents([], overrides, undefined, TEST_DEFAULT_MODEL) const agents = await createBuiltinAgents([], overrides, undefined, TEST_DEFAULT_MODEL)
// #then // #then
expect(agents.Sisyphus.model).toBe("github-copilot/gpt-5.2") expect(agents.sisyphus.model).toBe("github-copilot/gpt-5.2")
expect(agents.Sisyphus.reasoningEffort).toBe("medium") expect(agents.sisyphus.reasoningEffort).toBe("medium")
expect(agents.Sisyphus.thinking).toBeUndefined() expect(agents.sisyphus.thinking).toBeUndefined()
}) })
test("Sisyphus uses system default when no availableModels provided", async () => { test("Sisyphus uses system default when no availableModels provided", async () => {
@ -40,9 +40,9 @@ describe("createBuiltinAgents with model overrides", () => {
const agents = await createBuiltinAgents([], {}, undefined, systemDefaultModel) const agents = await createBuiltinAgents([], {}, undefined, systemDefaultModel)
// #then - falls back to system default when no availability match // #then - falls back to system default when no availability match
expect(agents.Sisyphus.model).toBe("anthropic/claude-opus-4-5") expect(agents.sisyphus.model).toBe("anthropic/claude-opus-4-5")
expect(agents.Sisyphus.thinking).toEqual({ type: "enabled", budgetTokens: 32000 }) expect(agents.sisyphus.thinking).toEqual({ type: "enabled", budgetTokens: 32000 })
expect(agents.Sisyphus.reasoningEffort).toBeUndefined() expect(agents.sisyphus.reasoningEffort).toBeUndefined()
}) })
test("Oracle uses first fallback entry when no availableModels provided (no cache scenario)", async () => { test("Oracle uses first fallback entry when no availableModels provided (no cache scenario)", async () => {
@ -93,15 +93,15 @@ describe("createBuiltinAgents with model overrides", () => {
test("non-model overrides are still applied after factory rebuild", async () => { test("non-model overrides are still applied after factory rebuild", async () => {
// #given // #given
const overrides = { const overrides = {
Sisyphus: { model: "github-copilot/gpt-5.2", temperature: 0.5 }, sisyphus: { model: "github-copilot/gpt-5.2", temperature: 0.5 },
} }
// #when // #when
const agents = await createBuiltinAgents([], overrides, undefined, TEST_DEFAULT_MODEL) const agents = await createBuiltinAgents([], overrides, undefined, TEST_DEFAULT_MODEL)
// #then // #then
expect(agents.Sisyphus.model).toBe("github-copilot/gpt-5.2") expect(agents.sisyphus.model).toBe("github-copilot/gpt-5.2")
expect(agents.Sisyphus.temperature).toBe(0.5) expect(agents.sisyphus.temperature).toBe(0.5)
}) })
}) })

View File

@ -19,16 +19,16 @@ import type { LoadedSkill, SkillScope } from "../features/opencode-skill-loader/
type AgentSource = AgentFactory | AgentConfig type AgentSource = AgentFactory | AgentConfig
const agentSources: Record<BuiltinAgentName, AgentSource> = { const agentSources: Record<BuiltinAgentName, AgentSource> = {
Sisyphus: createSisyphusAgent, sisyphus: createSisyphusAgent,
oracle: createOracleAgent, oracle: createOracleAgent,
librarian: createLibrarianAgent, librarian: createLibrarianAgent,
explore: createExploreAgent, explore: createExploreAgent,
"multimodal-looker": createMultimodalLookerAgent, "multimodal-looker": createMultimodalLookerAgent,
"Metis (Plan Consultant)": createMetisAgent, metis: createMetisAgent,
"Momus (Plan Reviewer)": createMomusAgent, momus: createMomusAgent,
// Note: Atlas is handled specially in createBuiltinAgents() // Note: Atlas is handled specially in createBuiltinAgents()
// because it needs OrchestratorContext, not just a model string // because it needs OrchestratorContext, not just a model string
Atlas: createAtlasAgent as unknown as AgentFactory, atlas: createAtlasAgent as unknown as AgentFactory,
} }
/** /**
@ -189,8 +189,8 @@ export async function createBuiltinAgents(
for (const [name, source] of Object.entries(agentSources)) { for (const [name, source] of Object.entries(agentSources)) {
const agentName = name as BuiltinAgentName const agentName = name as BuiltinAgentName
if (agentName === "Sisyphus") continue if (agentName === "sisyphus") continue
if (agentName === "Atlas") continue if (agentName === "atlas") continue
if (includesCaseInsensitive(disabledAgents, agentName)) continue if (includesCaseInsensitive(disabledAgents, agentName)) continue
const override = findCaseInsensitive(agentOverrides, agentName) const override = findCaseInsensitive(agentOverrides, agentName)
@ -234,9 +234,9 @@ export async function createBuiltinAgents(
} }
} }
if (!disabledAgents.includes("Sisyphus")) { if (!disabledAgents.includes("sisyphus")) {
const sisyphusOverride = agentOverrides["Sisyphus"] const sisyphusOverride = agentOverrides["sisyphus"]
const sisyphusRequirement = AGENT_MODEL_REQUIREMENTS["Sisyphus"] const sisyphusRequirement = AGENT_MODEL_REQUIREMENTS["sisyphus"]
// Use resolver to determine model // Use resolver to determine model
const { model: sisyphusModel, variant: sisyphusResolvedVariant } = resolveModelWithFallback({ const { model: sisyphusModel, variant: sisyphusResolvedVariant } = resolveModelWithFallback({
@ -270,12 +270,12 @@ export async function createBuiltinAgents(
sisyphusConfig = mergeAgentConfig(sisyphusConfig, sisyphusOverride) sisyphusConfig = mergeAgentConfig(sisyphusConfig, sisyphusOverride)
} }
result["Sisyphus"] = sisyphusConfig result["sisyphus"] = sisyphusConfig
} }
if (!disabledAgents.includes("Atlas")) { if (!disabledAgents.includes("atlas")) {
const orchestratorOverride = agentOverrides["Atlas"] const orchestratorOverride = agentOverrides["atlas"]
const atlasRequirement = AGENT_MODEL_REQUIREMENTS["Atlas"] const atlasRequirement = AGENT_MODEL_REQUIREMENTS["atlas"]
// Use resolver to determine model // Use resolver to determine model
const { model: atlasModel, variant: atlasResolvedVariant } = resolveModelWithFallback({ const { model: atlasModel, variant: atlasResolvedVariant } = resolveModelWithFallback({
@ -303,8 +303,8 @@ export async function createBuiltinAgents(
orchestratorConfig = mergeAgentConfig(orchestratorConfig, orchestratorOverride) orchestratorConfig = mergeAgentConfig(orchestratorConfig, orchestratorOverride)
} }
result["Atlas"] = orchestratorConfig result["atlas"] = orchestratorConfig
} }
return result return result
} }

View File

@ -241,7 +241,7 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
directory: ctx.directory, directory: ctx.directory,
userCategories: pluginConfig.categories, userCategories: pluginConfig.categories,
gitMasterConfig: pluginConfig.git_master, gitMasterConfig: pluginConfig.git_master,
sisyphusJuniorModel: pluginConfig.agents?.["Sisyphus-Junior"]?.model, sisyphusJuniorModel: pluginConfig.agents?.["sisyphus-junior"]?.model,
}); });
const disabledSkills = new Set(pluginConfig.disabled_skills ?? []); const disabledSkills = new Set(pluginConfig.disabled_skills ?? []);
const systemMcpNames = getSystemMcpServerNames(); const systemMcpNames = getSystemMcpServerNames();

View File

@ -199,7 +199,7 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
}; };
agentConfig["Sisyphus-Junior"] = createSisyphusJuniorAgentWithOverrides( agentConfig["Sisyphus-Junior"] = createSisyphusJuniorAgentWithOverrides(
pluginConfig.agents?.["Sisyphus-Junior"], pluginConfig.agents?.["sisyphus-junior"],
config.model as string | undefined config.model as string | undefined
); );
@ -228,7 +228,7 @@ export function createConfigHandler(deps: ConfigHandlerDeps) {
planConfigWithoutName as Record<string, unknown> planConfigWithoutName as Record<string, unknown>
); );
const prometheusOverride = const prometheusOverride =
pluginConfig.agents?.["Prometheus (Planner)"] as pluginConfig.agents?.["prometheus"] as
| (Record<string, unknown> & { category?: string; model?: string }) | (Record<string, unknown> & { category?: string; model?: string })
| undefined; | undefined;
const defaultModel = config.model as string | undefined; const defaultModel = config.model as string | undefined;