test: update expectations for ZWSP-free object keys

- Add RFC 7230 compliance tests for object key validation
- Verify name field still contains ZWSP for core agents
- Update all test expectations to use getAgentDisplayName()
This commit is contained in:
YeonGyu-Kim
2026-04-13 11:16:11 +09:00
parent 35fdd22d36
commit 4681e7ce27
8 changed files with 137 additions and 89 deletions
@@ -9,13 +9,13 @@ import type { OhMyOpenCodeConfig } from "../config"
import * as agentLoader from "../features/claude-code-agent-loader" import * as agentLoader from "../features/claude-code-agent-loader"
import * as skillLoader from "../features/opencode-skill-loader" import * as skillLoader from "../features/opencode-skill-loader"
import type { LoadedSkill } from "../features/opencode-skill-loader" import type { LoadedSkill } from "../features/opencode-skill-loader"
import { getAgentListDisplayName, getAgentRuntimeName } from "../shared/agent-display-names" import { getAgentDisplayName, getAgentRuntimeName } from "../shared/agent-display-names"
import { applyAgentConfig } from "./agent-config-handler" import { applyAgentConfig } from "./agent-config-handler"
import type { PluginComponents } from "./plugin-components-loader" import type { PluginComponents } from "./plugin-components-loader"
const BUILTIN_SISYPHUS_DISPLAY_NAME = getAgentListDisplayName("sisyphus") const BUILTIN_SISYPHUS_DISPLAY_NAME = getAgentDisplayName("sisyphus")
const BUILTIN_SISYPHUS_JUNIOR_DISPLAY_NAME = getAgentListDisplayName("sisyphus-junior") const BUILTIN_SISYPHUS_JUNIOR_DISPLAY_NAME = getAgentDisplayName("sisyphus-junior")
const BUILTIN_MULTIMODAL_LOOKER_DISPLAY_NAME = getAgentListDisplayName("multimodal-looker") const BUILTIN_MULTIMODAL_LOOKER_DISPLAY_NAME = getAgentDisplayName("multimodal-looker")
function createPluginComponents(): PluginComponents { function createPluginComponents(): PluginComponents {
return { return {
+75 -24
View File
@@ -1,8 +1,59 @@
import { describe, it, expect } from "bun:test" import { describe, it, expect } from "bun:test"
import { remapAgentKeysToDisplayNames } from "./agent-key-remapper" import { remapAgentKeysToDisplayNames } from "./agent-key-remapper"
import { getAgentDisplayName, getAgentListDisplayName, getAgentRuntimeName } from "../shared/agent-display-names" import { getAgentDisplayName, getAgentRuntimeName } from "../shared/agent-display-names"
const ZWSP_REGEX = /[\u200B\u200C\u200D\uFEFF]/
describe("remapAgentKeysToDisplayNames", () => { describe("remapAgentKeysToDisplayNames", () => {
it("object keys must not contain ZWSP characters (RFC 7230)", () => {
// given all core agents with ZWSP-based ordering
const agents = {
sisyphus: { prompt: "test" },
hephaestus: { prompt: "test" },
prometheus: { prompt: "test" },
atlas: { prompt: "test" },
}
// when remapping
const result = remapAgentKeysToDisplayNames(agents)
// then NO object key should contain ZWSP (RFC 7230 compliance)
for (const key of Object.keys(result)) {
expect(key).not.toMatch(ZWSP_REGEX)
}
})
it("name field MUST contain ZWSP for core agents (OpenCode sort ordering)", () => {
// given core agents
const agents = {
sisyphus: { prompt: "test" },
hephaestus: { prompt: "test" },
prometheus: { prompt: "test" },
atlas: { prompt: "test" },
}
// when remapping
const result = remapAgentKeysToDisplayNames(agents)
// then name fields MUST have ZWSP prefixes for sort ordering
const sisyphusConfig = result[getAgentDisplayName("sisyphus")] as Record<string, unknown>
const hephaestusConfig = result[getAgentDisplayName("hephaestus")] as Record<string, unknown>
const prometheusConfig = result[getAgentDisplayName("prometheus")] as Record<string, unknown>
const atlasConfig = result[getAgentDisplayName("atlas")] as Record<string, unknown>
expect(sisyphusConfig.name).toMatch(ZWSP_REGEX)
expect(hephaestusConfig.name).toMatch(ZWSP_REGEX)
expect(prometheusConfig.name).toMatch(ZWSP_REGEX)
expect(atlasConfig.name).toMatch(ZWSP_REGEX)
// And they should be the runtime names (with ZWSP)
expect(sisyphusConfig.name).toBe(getAgentRuntimeName("sisyphus"))
expect(hephaestusConfig.name).toBe(getAgentRuntimeName("hephaestus"))
expect(prometheusConfig.name).toBe(getAgentRuntimeName("prometheus"))
expect(atlasConfig.name).toBe(getAgentRuntimeName("atlas"))
})
it("remaps known agent keys to display names", () => { it("remaps known agent keys to display names", () => {
// given agents with lowercase keys // given agents with lowercase keys
const agents = { const agents = {
@@ -14,7 +65,7 @@ describe("remapAgentKeysToDisplayNames", () => {
const result = remapAgentKeysToDisplayNames(agents) const result = remapAgentKeysToDisplayNames(agents)
// then known agents get display name keys only // then known agents get display name keys only
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined() expect(result[getAgentDisplayName("sisyphus")]).toBeDefined()
expect(result["oracle"]).toBeDefined() expect(result["oracle"]).toBeDefined()
expect(result["sisyphus"]).toBeUndefined() expect(result["sisyphus"]).toBeUndefined()
}) })
@@ -49,13 +100,13 @@ describe("remapAgentKeysToDisplayNames", () => {
const result = remapAgentKeysToDisplayNames(agents) const result = remapAgentKeysToDisplayNames(agents)
// then all get display name keys // then all get display name keys
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined() expect(result[getAgentDisplayName("sisyphus")]).toBeDefined()
expect(result["sisyphus"]).toBeUndefined() expect(result["sisyphus"]).toBeUndefined()
expect(result[getAgentListDisplayName("hephaestus")]).toBeDefined() expect(result[getAgentDisplayName("hephaestus")]).toBeDefined()
expect(result["hephaestus"]).toBeUndefined() expect(result["hephaestus"]).toBeUndefined()
expect(result[getAgentListDisplayName("prometheus")]).toBeDefined() expect(result[getAgentDisplayName("prometheus")]).toBeDefined()
expect(result["prometheus"]).toBeUndefined() expect(result["prometheus"]).toBeUndefined()
expect(result[getAgentListDisplayName("atlas")]).toBeDefined() expect(result[getAgentDisplayName("atlas")]).toBeDefined()
expect(result["atlas"]).toBeUndefined() expect(result["atlas"]).toBeUndefined()
expect(result[getAgentDisplayName("athena")]).toBeDefined() expect(result[getAgentDisplayName("athena")]).toBeDefined()
expect(result["athena"]).toBeUndefined() expect(result["athena"]).toBeUndefined()
@@ -77,8 +128,8 @@ describe("remapAgentKeysToDisplayNames", () => {
const result = remapAgentKeysToDisplayNames(agents) const result = remapAgentKeysToDisplayNames(agents)
// then only display key is emitted // then only display key is emitted
expect(Object.keys(result)).toEqual([getAgentListDisplayName("sisyphus")]) expect(Object.keys(result)).toEqual([getAgentDisplayName("sisyphus")])
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined() expect(result[getAgentDisplayName("sisyphus")]).toBeDefined()
expect(result["sisyphus"]).toBeUndefined() expect(result["sisyphus"]).toBeUndefined()
}) })
@@ -96,10 +147,10 @@ describe("remapAgentKeysToDisplayNames", () => {
// then // then
expect(remappedNames).toEqual([ expect(remappedNames).toEqual([
getAgentListDisplayName("atlas"), getAgentDisplayName("atlas"),
getAgentListDisplayName("prometheus"), getAgentDisplayName("prometheus"),
getAgentListDisplayName("hephaestus"), getAgentDisplayName("hephaestus"),
getAgentListDisplayName("sisyphus"), getAgentDisplayName("sisyphus"),
]) ])
}) })
@@ -118,27 +169,27 @@ describe("remapAgentKeysToDisplayNames", () => {
// then keys and names both use the same runtime-facing list names // then keys and names both use the same runtime-facing list names
expect(Object.keys(result).slice(0, 4)).toEqual([ expect(Object.keys(result).slice(0, 4)).toEqual([
getAgentListDisplayName("sisyphus"), getAgentDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"), getAgentDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"), getAgentDisplayName("prometheus"),
getAgentListDisplayName("atlas"), getAgentDisplayName("atlas"),
]) ])
expect(result[getAgentListDisplayName("sisyphus")]).toEqual({ expect(result[getAgentDisplayName("sisyphus")]).toEqual({
name: getAgentRuntimeName("sisyphus"), name: getAgentRuntimeName("sisyphus"),
prompt: "test", prompt: "test",
mode: "primary", mode: "primary",
}) })
expect(result[getAgentListDisplayName("hephaestus")]).toEqual({ expect(result[getAgentDisplayName("hephaestus")]).toEqual({
name: getAgentRuntimeName("hephaestus"), name: getAgentRuntimeName("hephaestus"),
prompt: "test", prompt: "test",
mode: "primary", mode: "primary",
}) })
expect(result[getAgentListDisplayName("prometheus")]).toEqual({ expect(result[getAgentDisplayName("prometheus")]).toEqual({
name: getAgentRuntimeName("prometheus"), name: getAgentRuntimeName("prometheus"),
prompt: "test", prompt: "test",
mode: "all", mode: "all",
}) })
expect(result[getAgentListDisplayName("atlas")]).toEqual({ expect(result[getAgentDisplayName("atlas")]).toEqual({
name: getAgentRuntimeName("atlas"), name: getAgentRuntimeName("atlas"),
prompt: "test", prompt: "test",
mode: "primary", mode: "primary",
@@ -159,22 +210,22 @@ describe("remapAgentKeysToDisplayNames", () => {
const result = remapAgentKeysToDisplayNames(agents) const result = remapAgentKeysToDisplayNames(agents)
// then runtime-facing names stay aligned even when builtin configs omit name // then runtime-facing names stay aligned even when builtin configs omit name
expect(result[getAgentListDisplayName("sisyphus")]).toEqual({ expect(result[getAgentDisplayName("sisyphus")]).toEqual({
name: getAgentRuntimeName("sisyphus"), name: getAgentRuntimeName("sisyphus"),
prompt: "test", prompt: "test",
mode: "primary", mode: "primary",
}) })
expect(result[getAgentListDisplayName("hephaestus")]).toEqual({ expect(result[getAgentDisplayName("hephaestus")]).toEqual({
name: getAgentRuntimeName("hephaestus"), name: getAgentRuntimeName("hephaestus"),
prompt: "test", prompt: "test",
mode: "primary", mode: "primary",
}) })
expect(result[getAgentListDisplayName("prometheus")]).toEqual({ expect(result[getAgentDisplayName("prometheus")]).toEqual({
name: getAgentRuntimeName("prometheus"), name: getAgentRuntimeName("prometheus"),
prompt: "test", prompt: "test",
mode: "all", mode: "all",
}) })
expect(result[getAgentListDisplayName("atlas")]).toEqual({ expect(result[getAgentDisplayName("atlas")]).toEqual({
name: getAgentRuntimeName("atlas"), name: getAgentRuntimeName("atlas"),
prompt: "test", prompt: "test",
mode: "primary", mode: "primary",
@@ -6,7 +6,7 @@ import {
reorderAgentsByPriority, reorderAgentsByPriority,
CANONICAL_CORE_AGENT_ORDER, CANONICAL_CORE_AGENT_ORDER,
} from "./agent-priority-order" } from "./agent-priority-order"
import { getAgentDisplayName, getAgentListDisplayName } from "../shared/agent-display-names" import { getAgentDisplayName } from "../shared/agent-display-names"
describe("agent-priority-order", () => { describe("agent-priority-order", () => {
describe("CANONICAL_CORE_AGENT_ORDER", () => { describe("CANONICAL_CORE_AGENT_ORDER", () => {
@@ -35,11 +35,11 @@ describe("agent-priority-order", () => {
}) })
describe("reorderAgentsByPriority", () => { describe("reorderAgentsByPriority", () => {
// given: display names for all core agents // given: display names for all core agents (no ZWSP in keys)
const sisyphus = getAgentListDisplayName("sisyphus") const sisyphus = getAgentDisplayName("sisyphus")
const hephaestus = getAgentListDisplayName("hephaestus") const hephaestus = getAgentDisplayName("hephaestus")
const prometheus = getAgentListDisplayName("prometheus") const prometheus = getAgentDisplayName("prometheus")
const atlas = getAgentListDisplayName("atlas") const atlas = getAgentDisplayName("atlas")
const oracle = getAgentDisplayName("oracle") const oracle = getAgentDisplayName("oracle")
const librarian = getAgentDisplayName("librarian") const librarian = getAgentDisplayName("librarian")
const explore = getAgentDisplayName("explore") const explore = getAgentDisplayName("explore")
@@ -7,10 +7,7 @@ import * as skillLoader from "../features/opencode-skill-loader";
import type { OhMyOpenCodeConfig } from "../config"; import type { OhMyOpenCodeConfig } from "../config";
import type { PluginComponents } from "./plugin-components-loader"; import type { PluginComponents } from "./plugin-components-loader";
import { applyCommandConfig } from "./command-config-handler"; import { applyCommandConfig } from "./command-config-handler";
import { import { getAgentDisplayName } from "../shared/agent-display-names";
getAgentDisplayName,
getAgentListDisplayName,
} from "../shared/agent-display-names";
function createPluginComponents(): PluginComponents { function createPluginComponents(): PluginComponents {
return { return {
@@ -108,7 +105,7 @@ describe("applyCommandConfig", () => {
expect(commandConfig["agents-global-skill"]?.description).toContain("Agents global skill"); expect(commandConfig["agents-global-skill"]?.description).toContain("Agents global skill");
}); });
test("normalizes Atlas command agents to the runtime list name used by opencode command routing", async () => { test("normalizes Atlas command agents to the display name for HTTP-safe routing", async () => {
// given // given
loadBuiltinCommandsSpy.mockReturnValue({ loadBuiltinCommandsSpy.mockReturnValue({
"start-work": { "start-work": {
@@ -130,10 +127,10 @@ describe("applyCommandConfig", () => {
// then // then
const commandConfig = config.command as Record<string, { agent?: string }>; const commandConfig = config.command as Record<string, { agent?: string }>;
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas")); expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"));
}); });
test("normalizes legacy display-name command agents to the runtime list name", async () => { test("normalizes legacy display-name command agents to the display name", async () => {
// given // given
loadBuiltinCommandsSpy.mockReturnValue({ loadBuiltinCommandsSpy.mockReturnValue({
"start-work": { "start-work": {
@@ -155,6 +152,6 @@ describe("applyCommandConfig", () => {
// then // then
const commandConfig = config.command as Record<string, { agent?: string }>; const commandConfig = config.command as Record<string, { agent?: string }>;
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas")); expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"));
}); });
}); });
+42 -42
View File
@@ -3,7 +3,7 @@
import { describe, test, expect, spyOn, beforeEach, afterEach, mock } from "bun:test" import { describe, test, expect, spyOn, beforeEach, afterEach, mock } from "bun:test"
import type { CategoryConfig } from "../config/schema" import type { CategoryConfig } from "../config/schema"
import type { OhMyOpenCodeConfig } from "../config" import type { OhMyOpenCodeConfig } from "../config"
import { getAgentDisplayName, getAgentListDisplayName, getAgentRuntimeName } from "../shared/agent-display-names" import { getAgentDisplayName, getAgentDisplayName, getAgentRuntimeName } from "../shared/agent-display-names"
import { resolveCategoryConfig } from "./category-config-resolver" import { resolveCategoryConfig } from "./category-config-resolver"
import * as agents from "../agents" import * as agents from "../agents"
@@ -260,10 +260,10 @@ describe("Plan agent demote behavior", () => {
// #then // #then
const keys = Object.keys(config.agent as Record<string, unknown>) const keys = Object.keys(config.agent as Record<string, unknown>)
const coreAgents = [ const coreAgents = [
getAgentListDisplayName("sisyphus"), getAgentDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"), getAgentDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"), getAgentDisplayName("prometheus"),
getAgentListDisplayName("atlas"), getAgentDisplayName("atlas"),
] ]
const ordered = keys.filter((key) => coreAgents.includes(key)) const ordered = keys.filter((key) => coreAgents.includes(key))
expect(ordered).toEqual(coreAgents) expect(ordered).toEqual(coreAgents)
@@ -308,10 +308,10 @@ describe("Plan agent demote behavior", () => {
reorderSpy.mock.calls.at(0)?.[0] as Record<string, unknown> reorderSpy.mock.calls.at(0)?.[0] as Record<string, unknown>
) )
expect(assembledAgentKeys.slice(0, 4)).toEqual([ expect(assembledAgentKeys.slice(0, 4)).toEqual([
getAgentListDisplayName("sisyphus"), getAgentDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"), getAgentDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"), getAgentDisplayName("prometheus"),
getAgentListDisplayName("atlas"), getAgentDisplayName("atlas"),
]) ])
}) })
@@ -354,19 +354,19 @@ describe("Plan agent demote behavior", () => {
expect(emittedCoreEntries).toEqual([ expect(emittedCoreEntries).toEqual([
[ [
getAgentListDisplayName("sisyphus"), getAgentDisplayName("sisyphus"),
expect.objectContaining({ name: getAgentRuntimeName("sisyphus") }), expect.objectContaining({ name: getAgentRuntimeName("sisyphus") }),
], ],
[ [
getAgentListDisplayName("hephaestus"), getAgentDisplayName("hephaestus"),
expect.objectContaining({ name: getAgentRuntimeName("hephaestus") }), expect.objectContaining({ name: getAgentRuntimeName("hephaestus") }),
], ],
[ [
getAgentListDisplayName("prometheus"), getAgentDisplayName("prometheus"),
expect.objectContaining({ name: getAgentRuntimeName("prometheus") }), expect.objectContaining({ name: getAgentRuntimeName("prometheus") }),
], ],
[ [
getAgentListDisplayName("atlas"), getAgentDisplayName("atlas"),
expect.objectContaining({ name: getAgentRuntimeName("atlas") }), expect.objectContaining({ name: getAgentRuntimeName("atlas") }),
], ],
]) ])
@@ -407,7 +407,7 @@ describe("Plan agent demote behavior", () => {
expect(agents.plan).toBeDefined() expect(agents.plan).toBeDefined()
expect(agents.plan.mode).toBe("subagent") expect(agents.plan.mode).toBe("subagent")
expect(agents.plan.prompt).toBeUndefined() 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 () => { test("plan agent remains unchanged when planner is disabled", async () => {
@@ -441,7 +441,7 @@ describe("Plan agent demote behavior", () => {
// #then - plan is not touched, prometheus is not created // #then - plan is not touched, prometheus is not created
const agents = config.agent as Record<string, { mode?: string; name?: string; prompt?: string }> 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).toBeDefined()
expect(agents.plan.mode).toBe("primary") expect(agents.plan.mode).toBe("primary")
expect(agents.plan.prompt).toBe("original plan prompt") expect(agents.plan.prompt).toBe("original plan prompt")
@@ -472,7 +472,7 @@ describe("Plan agent demote behavior", () => {
// then // then
const agents = config.agent as Record<string, { mode?: string }> const agents = config.agent as Record<string, { mode?: string }>
const prometheusKey = getAgentListDisplayName("prometheus") const prometheusKey = getAgentDisplayName("prometheus")
expect(agents[prometheusKey]).toBeDefined() expect(agents[prometheusKey]).toBeDefined()
expect(agents[prometheusKey].mode).toBe("all") expect(agents[prometheusKey].mode).toBe("all")
}) })
@@ -508,7 +508,7 @@ describe("Agent permission defaults", () => {
// #then // #then
const agentConfig = config.agent as Record<string, { permission?: Record<string, string> }> 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]).toBeDefined()
expect(agentConfig[hephaestusKey].permission?.task).toBe("allow") expect(agentConfig[hephaestusKey].permission?.task).toBe("allow")
}) })
@@ -536,7 +536,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// then // then
expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus")) expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
}) })
test("canonicalizes configured default_agent when key uses mixed case", async () => { test("canonicalizes configured default_agent when key uses mixed case", async () => {
@@ -560,7 +560,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// then // then
expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus")) expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
}) })
test("canonicalizes configured default_agent key to display name", async () => { test("canonicalizes configured default_agent key to display name", async () => {
@@ -584,13 +584,13 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// #then // #then
expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus")) expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
}) })
test("preserves existing display-name default_agent", async () => { test("preserves existing display-name default_agent", async () => {
// #given // #given
const pluginConfig = createPluginConfig({}) const pluginConfig = createPluginConfig({})
const displayName = getAgentListDisplayName("hephaestus") const displayName = getAgentDisplayName("hephaestus")
const config: Record<string, unknown> = { const config: Record<string, unknown> = {
model: "anthropic/claude-opus-4-6", model: "anthropic/claude-opus-4-6",
default_agent: displayName, default_agent: displayName,
@@ -609,7 +609,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// #then // #then
expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus")) expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
}) })
test("sets default_agent to sisyphus when missing", async () => { test("sets default_agent to sisyphus when missing", async () => {
@@ -632,7 +632,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// #then // #then
expect(config.default_agent).toBe(getAgentRuntimeName("sisyphus")) expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
}) })
test("uses canonical default_agent display name so OpenCode lookups match emitted agent keys", async () => { test("uses canonical default_agent display name so OpenCode lookups match emitted agent keys", async () => {
@@ -656,7 +656,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// then // then
expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus")) expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
}) })
test("sets default_agent to sisyphus when configured default_agent is empty after trim", async () => { test("sets default_agent to sisyphus when configured default_agent is empty after trim", async () => {
@@ -680,7 +680,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// then // then
expect(config.default_agent).toBe(getAgentRuntimeName("sisyphus")) expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
}) })
test("preserves custom default_agent names while trimming whitespace", async () => { test("preserves custom default_agent names while trimming whitespace", async () => {
@@ -874,7 +874,7 @@ describe("Prometheus direct override priority over category", () => {
// then - direct override's reasoningEffort wins // then - direct override's reasoningEffort wins
const agents = config.agent as Record<string, { reasoningEffort?: string }> const agents = config.agent as Record<string, { reasoningEffort?: string }>
const pKey = getAgentListDisplayName("prometheus") const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined() expect(agents[pKey]).toBeDefined()
expect(agents[pKey].reasoningEffort).toBe("low") expect(agents[pKey].reasoningEffort).toBe("low")
}) })
@@ -915,7 +915,7 @@ describe("Prometheus direct override priority over category", () => {
// then - category's reasoningEffort is applied // then - category's reasoningEffort is applied
const agents = config.agent as Record<string, { reasoningEffort?: string }> const agents = config.agent as Record<string, { reasoningEffort?: string }>
const pKey = getAgentListDisplayName("prometheus") const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined() expect(agents[pKey]).toBeDefined()
expect(agents[pKey].reasoningEffort).toBe("high") expect(agents[pKey].reasoningEffort).toBe("high")
}) })
@@ -957,7 +957,7 @@ describe("Prometheus direct override priority over category", () => {
// then - direct temperature wins over category // then - direct temperature wins over category
const agents = config.agent as Record<string, { temperature?: number }> const agents = config.agent as Record<string, { temperature?: number }>
const pKey = getAgentListDisplayName("prometheus") const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined() expect(agents[pKey]).toBeDefined()
expect(agents[pKey].temperature).toBe(0.1) expect(agents[pKey].temperature).toBe(0.1)
}) })
@@ -993,7 +993,7 @@ describe("Prometheus direct override priority over category", () => {
// #then - prompt_append is appended to base prompt, not overwriting it // #then - prompt_append is appended to base prompt, not overwriting it
const agents = config.agent as Record<string, { prompt?: string }> const agents = config.agent as Record<string, { prompt?: string }>
const pKey = getAgentListDisplayName("prometheus") const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined() expect(agents[pKey]).toBeDefined()
expect(agents[pKey].prompt).toContain("Prometheus") expect(agents[pKey].prompt).toContain("Prometheus")
expect(agents[pKey].prompt).toContain(customInstructions) expect(agents[pKey].prompt).toContain(customInstructions)
@@ -1218,7 +1218,7 @@ describe("Deadlock prevention - fetchAvailableModels must not receive client", (
// then - regression guard: handler completes and still assembles planner config // then - regression guard: handler completes and still assembles planner config
const agentConfig = config.agent as Record<string, unknown> const agentConfig = config.agent as Record<string, unknown>
expect(agentConfig[getAgentListDisplayName("prometheus")]).toBeDefined() expect(agentConfig[getAgentDisplayName("prometheus")]).toBeDefined()
}) })
}) })
@@ -1384,17 +1384,17 @@ describe("command agent routing coherence", () => {
//#then //#then
const agentConfig = config.agent as Record<string, unknown> const agentConfig = config.agent as Record<string, unknown>
const commandConfig = config.command as Record<string, { agent?: string }> const commandConfig = config.command as Record<string, { agent?: string }>
expect(Object.keys(agentConfig)).toContain(getAgentListDisplayName("atlas")) expect(Object.keys(agentConfig)).toContain(getAgentDisplayName("atlas"))
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas")) expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"))
}) })
}) })
describe("per-agent todowrite/todoread deny when task_system enabled", () => { describe("per-agent todowrite/todoread deny when task_system enabled", () => {
const AGENTS_WITH_TODO_DENY = new Set([ const AGENTS_WITH_TODO_DENY = new Set([
getAgentListDisplayName("sisyphus"), getAgentDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"), getAgentDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"), getAgentDisplayName("prometheus"),
getAgentListDisplayName("atlas"), getAgentDisplayName("atlas"),
getAgentDisplayName("sisyphus-junior"), getAgentDisplayName("sisyphus-junior"),
]) ])
@@ -1475,10 +1475,10 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
expect(lastCall?.[11]).toBe(false) expect(lastCall?.[11]).toBe(false)
const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }> const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }>
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined() expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined() expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentListDisplayName("hephaestus")]?.permission?.todowrite).toBeUndefined() expect(agentResult[getAgentDisplayName("hephaestus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("hephaestus")]?.permission?.todoread).toBeUndefined() expect(agentResult[getAgentDisplayName("hephaestus")]?.permission?.todoread).toBeUndefined()
}) })
test("does not deny todowrite/todoread when task_system is undefined", async () => { test("does not deny todowrite/todoread when task_system is undefined", async () => {
@@ -1514,8 +1514,8 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
expect(lastCall?.[11]).toBe(false) expect(lastCall?.[11]).toBe(false)
const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }> const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }>
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined() expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined() expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
}) })
}) })
+1 -1
View File
@@ -6,7 +6,7 @@ import { randomUUID } from "node:crypto"
import { createPluginInterface } from "./plugin-interface" import { createPluginInterface } from "./plugin-interface"
import { createAutoSlashCommandHook } from "./hooks/auto-slash-command" import { createAutoSlashCommandHook } from "./hooks/auto-slash-command"
import { createStartWorkHook } from "./hooks/start-work" import { createStartWorkHook } from "./hooks/start-work"
import { getAgentListDisplayName } from "./shared/agent-display-names" import { getAgentDisplayName } from "./shared/agent-display-names"
import { readBoulderState } from "./features/boulder-state" import { readBoulderState } from "./features/boulder-state"
import { import {
_resetForTesting, _resetForTesting,
+2 -2
View File
@@ -10,7 +10,7 @@ import { createKeywordDetectorHook } from "../hooks/keyword-detector"
import { createStartWorkHook } from "../hooks/start-work" import { createStartWorkHook } from "../hooks/start-work"
import { readBoulderState } from "../features/boulder-state" import { readBoulderState } from "../features/boulder-state"
import { _resetForTesting, setMainSession, subagentSessions, registerAgentName, updateSessionAgent, getSessionAgent } from "../features/claude-code-session-state" import { _resetForTesting, setMainSession, subagentSessions, registerAgentName, updateSessionAgent, getSessionAgent } from "../features/claude-code-session-state"
import { getAgentListDisplayName } from "../shared/agent-display-names" import { getAgentDisplayName } from "../shared/agent-display-names"
import { getOmoOpenCodeCacheDir, getOpenCodeCacheDir } from "../shared/data-path" import { getOmoOpenCodeCacheDir, getOpenCodeCacheDir } from "../shared/data-path"
import { clearSessionModel, getSessionModel, setSessionModel } from "../shared/session-model-state" import { clearSessionModel, getSessionModel, setSessionModel } from "../shared/session-model-state"
@@ -738,7 +738,7 @@ describe("createChatMessageHandler - TUI variant passthrough", () => {
}, },
}) })
const handler = createChatMessageHandler(args) const handler = createChatMessageHandler(args)
const input = createMockInput(getAgentListDisplayName("prometheus")) const input = createMockInput(getAgentDisplayName("prometheus"))
const output = createMockOutput() const output = createMockOutput()
//#when //#when
+2 -2
View File
@@ -1,7 +1,7 @@
declare const require: NodeJS.Require declare const require: NodeJS.Require
const { describe, test, expect, beforeEach, afterEach, spyOn, mock } = require("bun:test") const { describe, test, expect, beforeEach, afterEach, spyOn, mock } = require("bun:test")
import { DEFAULT_CATEGORIES, CATEGORY_PROMPT_APPENDS, CATEGORY_DESCRIPTIONS, isPlanAgent, PLAN_AGENT_NAMES, isPlanFamily, PLAN_FAMILY_NAMES } from "./constants" import { DEFAULT_CATEGORIES, CATEGORY_PROMPT_APPENDS, CATEGORY_DESCRIPTIONS, isPlanAgent, PLAN_AGENT_NAMES, isPlanFamily, PLAN_FAMILY_NAMES } from "./constants"
import { getAgentDisplayName, getAgentListDisplayName } from "../../shared/agent-display-names" import { getAgentDisplayName, getAgentDisplayName } from "../../shared/agent-display-names"
import type { CategoryConfig } from "../../config/schema" import type { CategoryConfig } from "../../config/schema"
import type { DelegateTaskArgs } from "./types" import type { DelegateTaskArgs } from "./types"
import { __resetModelCache } from "../../shared/model-availability" import { __resetModelCache } from "../../shared/model-availability"
@@ -277,7 +277,7 @@ describe("sisyphus-task", () => {
test("returns true for prometheus list display name with zwsp prefix", () => { test("returns true for prometheus list display name with zwsp prefix", () => {
//#given / #when //#given / #when
const result = isPlanFamily(getAgentListDisplayName("prometheus")) const result = isPlanFamily(getAgentDisplayName("prometheus"))
//#then //#then
expect(result).toBe(true) expect(result).toBe(true)
}) })