fix(plugin-handlers): remove ZWSP prefixes from API-facing agent paths

This commit is contained in:
YeonGyu-Kim
2026-04-10 18:47:18 +09:00
parent 68c8701d34
commit 9532440cb2
11 changed files with 101 additions and 85 deletions
+36 -36
View File
@@ -3,7 +3,7 @@
import { describe, test, expect, spyOn, beforeEach, afterEach, mock } from "bun:test"
import type { CategoryConfig } from "../config/schema"
import type { OhMyOpenCodeConfig } from "../config"
import { getAgentDisplayName, getAgentListDisplayName } from "../shared/agent-display-names"
import { getAgentDisplayName } from "../shared/agent-display-names"
import { resolveCategoryConfig } from "./category-config-resolver"
import * as agents from "../agents"
@@ -260,10 +260,10 @@ describe("Plan agent demote behavior", () => {
// #then
const keys = Object.keys(config.agent as Record<string, unknown>)
const coreAgents = [
getAgentListDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"),
getAgentListDisplayName("atlas"),
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("atlas"),
]
const ordered = keys.filter((key) => coreAgents.includes(key))
expect(ordered).toEqual(coreAgents)
@@ -308,10 +308,10 @@ describe("Plan agent demote behavior", () => {
reorderSpy.mock.calls.at(0)?.[0] as Record<string, unknown>
)
expect(assembledAgentKeys.slice(0, 4)).toEqual([
getAgentListDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"),
getAgentListDisplayName("atlas"),
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("atlas"),
])
})
@@ -350,7 +350,7 @@ describe("Plan agent demote behavior", () => {
expect(agents.plan).toBeDefined()
expect(agents.plan.mode).toBe("subagent")
expect(agents.plan.prompt).toBeUndefined()
expect(agents[getAgentListDisplayName("prometheus")]?.prompt).toBeDefined()
expect(agents[getAgentDisplayName("prometheus")]?.prompt).toBeDefined()
})
test("plan agent remains unchanged when planner is disabled", async () => {
@@ -384,7 +384,7 @@ describe("Plan agent demote behavior", () => {
// #then - plan is not touched, prometheus is not created
const agents = config.agent as Record<string, { mode?: string; name?: string; prompt?: string }>
expect(agents[getAgentListDisplayName("prometheus")]).toBeUndefined()
expect(agents[getAgentDisplayName("prometheus")]).toBeUndefined()
expect(agents.plan).toBeDefined()
expect(agents.plan.mode).toBe("primary")
expect(agents.plan.prompt).toBe("original plan prompt")
@@ -415,7 +415,7 @@ describe("Plan agent demote behavior", () => {
// then
const agents = config.agent as Record<string, { mode?: string }>
const prometheusKey = getAgentListDisplayName("prometheus")
const prometheusKey = getAgentDisplayName("prometheus")
expect(agents[prometheusKey]).toBeDefined()
expect(agents[prometheusKey].mode).toBe("all")
})
@@ -451,7 +451,7 @@ describe("Agent permission defaults", () => {
// #then
const agentConfig = config.agent as Record<string, { permission?: Record<string, string> }>
const hephaestusKey = getAgentListDisplayName("hephaestus")
const hephaestusKey = getAgentDisplayName("hephaestus")
expect(agentConfig[hephaestusKey]).toBeDefined()
expect(agentConfig[hephaestusKey].permission?.task).toBe("allow")
})
@@ -479,7 +479,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// then
expect(config.default_agent).toBe(getAgentListDisplayName("hephaestus"))
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
})
test("canonicalizes configured default_agent when key uses mixed case", async () => {
@@ -503,7 +503,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// then
expect(config.default_agent).toBe(getAgentListDisplayName("hephaestus"))
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
})
test("canonicalizes configured default_agent key to display name", async () => {
@@ -527,13 +527,13 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// #then
expect(config.default_agent).toBe(getAgentListDisplayName("hephaestus"))
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
})
test("preserves existing display-name default_agent", async () => {
// #given
const pluginConfig = createPluginConfig({})
const displayName = getAgentListDisplayName("hephaestus")
const displayName = getAgentDisplayName("hephaestus")
const config: Record<string, unknown> = {
model: "anthropic/claude-opus-4-6",
default_agent: displayName,
@@ -575,7 +575,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// #then
expect(config.default_agent).toBe(getAgentListDisplayName("sisyphus"))
expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
})
test("sets default_agent to sisyphus when configured default_agent is empty after trim", async () => {
@@ -599,7 +599,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config)
// then
expect(config.default_agent).toBe(getAgentListDisplayName("sisyphus"))
expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
})
test("preserves custom default_agent names while trimming whitespace", async () => {
@@ -793,7 +793,7 @@ describe("Prometheus direct override priority over category", () => {
// then - direct override's reasoningEffort wins
const agents = config.agent as Record<string, { reasoningEffort?: string }>
const pKey = getAgentListDisplayName("prometheus")
const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].reasoningEffort).toBe("low")
})
@@ -834,7 +834,7 @@ describe("Prometheus direct override priority over category", () => {
// then - category's reasoningEffort is applied
const agents = config.agent as Record<string, { reasoningEffort?: string }>
const pKey = getAgentListDisplayName("prometheus")
const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].reasoningEffort).toBe("high")
})
@@ -876,7 +876,7 @@ describe("Prometheus direct override priority over category", () => {
// then - direct temperature wins over category
const agents = config.agent as Record<string, { temperature?: number }>
const pKey = getAgentListDisplayName("prometheus")
const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].temperature).toBe(0.1)
})
@@ -912,7 +912,7 @@ describe("Prometheus direct override priority over category", () => {
// #then - prompt_append is appended to base prompt, not overwriting it
const agents = config.agent as Record<string, { prompt?: string }>
const pKey = getAgentListDisplayName("prometheus")
const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].prompt).toContain("Prometheus")
expect(agents[pKey].prompt).toContain(customInstructions)
@@ -1137,7 +1137,7 @@ describe("Deadlock prevention - fetchAvailableModels must not receive client", (
// then - regression guard: handler completes and still assembles planner config
const agentConfig = config.agent as Record<string, unknown>
expect(agentConfig[getAgentListDisplayName("prometheus")]).toBeDefined()
expect(agentConfig[getAgentDisplayName("prometheus")]).toBeDefined()
})
})
@@ -1303,17 +1303,17 @@ describe("command agent routing coherence", () => {
//#then
const agentConfig = config.agent as Record<string, unknown>
const commandConfig = config.command as Record<string, { agent?: string }>
expect(Object.keys(agentConfig)).toContain(getAgentListDisplayName("atlas"))
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas"))
expect(Object.keys(agentConfig)).toContain(getAgentDisplayName("atlas"))
expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"))
})
})
describe("per-agent todowrite/todoread deny when task_system enabled", () => {
const AGENTS_WITH_TODO_DENY = new Set([
getAgentListDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"),
getAgentListDisplayName("atlas"),
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("atlas"),
getAgentDisplayName("sisyphus-junior"),
])
@@ -1394,10 +1394,10 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
expect(lastCall?.[11]).toBe(false)
const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }>
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentListDisplayName("hephaestus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("hephaestus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentDisplayName("hephaestus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentDisplayName("hephaestus")]?.permission?.todoread).toBeUndefined()
})
test("does not deny todowrite/todoread when task_system is undefined", async () => {
@@ -1433,8 +1433,8 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
expect(lastCall?.[11]).toBe(false)
const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }>
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
})
})