feat(agents): add ZWSP stable-sort prefixes for core agent list ordering

Populate AGENT_LIST_SORT_PREFIXES for sisyphus/hephaestus/prometheus/atlas
so the TUI agent list renders in canonical order. Update dependent tests
to use getAgentListDisplayName() instead of hardcoded display strings.

🤖 Generated with [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode) assistance
This commit is contained in:
YeonGyu-Kim
2026-04-06 18:07:07 +09:00
parent 88280d0e4d
commit 178b635d72
5 changed files with 45 additions and 33 deletions
@@ -9,11 +9,11 @@ import type { OhMyOpenCodeConfig } from "../config"
import * as agentLoader from "../features/claude-code-agent-loader"
import * as skillLoader from "../features/opencode-skill-loader"
import type { LoadedSkill } from "../features/opencode-skill-loader"
import { getAgentDisplayName } from "../shared/agent-display-names"
import { getAgentDisplayName, getAgentListDisplayName } from "../shared/agent-display-names"
import { applyAgentConfig } from "./agent-config-handler"
import type { PluginComponents } from "./plugin-components-loader"
const BUILTIN_SISYPHUS_DISPLAY_NAME = getAgentDisplayName("sisyphus")
const BUILTIN_SISYPHUS_DISPLAY_NAME = getAgentListDisplayName("sisyphus")
const BUILTIN_SISYPHUS_JUNIOR_DISPLAY_NAME = getAgentDisplayName("sisyphus-junior")
const BUILTIN_MULTIMODAL_LOOKER_DISPLAY_NAME = getAgentDisplayName("multimodal-looker")
+12 -11
View File
@@ -1,5 +1,6 @@
import { describe, it, expect } from "bun:test"
import { remapAgentKeysToDisplayNames } from "./agent-key-remapper"
import { getAgentListDisplayName } from "../shared/agent-display-names"
describe("remapAgentKeysToDisplayNames", () => {
it("remaps known agent keys to display names", () => {
@@ -13,7 +14,7 @@ describe("remapAgentKeysToDisplayNames", () => {
const result = remapAgentKeysToDisplayNames(agents)
// then known agents get display name keys only
expect(result["Sisyphus (Ultraworker)"]).toBeDefined()
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined()
expect(result["oracle"]).toBeDefined()
expect(result["sisyphus"]).toBeUndefined()
})
@@ -48,21 +49,21 @@ describe("remapAgentKeysToDisplayNames", () => {
const result = remapAgentKeysToDisplayNames(agents)
// then all get display name keys
expect(result["Sisyphus (Ultraworker)"]).toBeDefined()
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined()
expect(result["sisyphus"]).toBeUndefined()
expect(result["Hephaestus (Deep Agent)"]).toBeDefined()
expect(result[getAgentListDisplayName("hephaestus")]).toBeDefined()
expect(result["hephaestus"]).toBeUndefined()
expect(result["Prometheus (Plan Builder)"]).toBeDefined()
expect(result[getAgentListDisplayName("prometheus")]).toBeDefined()
expect(result["prometheus"]).toBeUndefined()
expect(result["Atlas (Plan Executor)"]).toBeDefined()
expect(result[getAgentListDisplayName("atlas")]).toBeDefined()
expect(result["atlas"]).toBeUndefined()
expect(result["Athena (Council)"]).toBeDefined()
expect(result[getAgentListDisplayName("athena")]).toBeDefined()
expect(result["athena"]).toBeUndefined()
expect(result["Metis (Plan Consultant)"]).toBeDefined()
expect(result[getAgentListDisplayName("metis")]).toBeDefined()
expect(result["metis"]).toBeUndefined()
expect(result["Momus (Plan Critic)"]).toBeDefined()
expect(result[getAgentListDisplayName("momus")]).toBeDefined()
expect(result["momus"]).toBeUndefined()
expect(result["Sisyphus-Junior"]).toBeDefined()
expect(result[getAgentListDisplayName("sisyphus-junior")]).toBeDefined()
expect(result["sisyphus-junior"]).toBeUndefined()
})
@@ -76,8 +77,8 @@ describe("remapAgentKeysToDisplayNames", () => {
const result = remapAgentKeysToDisplayNames(agents)
// then only display key is emitted
expect(Object.keys(result)).toEqual(["Sisyphus (Ultraworker)"])
expect(result["Sisyphus (Ultraworker)"]).toBeDefined()
expect(Object.keys(result)).toEqual([getAgentListDisplayName("sisyphus")])
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined()
expect(result["sisyphus"]).toBeUndefined()
})
})
+14 -14
View File
@@ -336,7 +336,7 @@ describe("Plan agent demote behavior", () => {
expect(agents.plan).toBeDefined()
expect(agents.plan.mode).toBe("subagent")
expect(agents.plan.prompt).toBeUndefined()
expect(agents[getAgentDisplayName("prometheus")]?.prompt).toBeDefined()
expect(agents[getAgentListDisplayName("prometheus")]?.prompt).toBeDefined()
})
test("plan agent remains unchanged when planner is disabled", async () => {
@@ -370,7 +370,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[getAgentDisplayName("prometheus")]).toBeUndefined()
expect(agents[getAgentListDisplayName("prometheus")]).toBeUndefined()
expect(agents.plan).toBeDefined()
expect(agents.plan.mode).toBe("primary")
expect(agents.plan.prompt).toBe("original plan prompt")
@@ -401,7 +401,7 @@ describe("Plan agent demote behavior", () => {
// then
const agents = config.agent as Record<string, { mode?: string }>
const prometheusKey = getAgentDisplayName("prometheus")
const prometheusKey = getAgentListDisplayName("prometheus")
expect(agents[prometheusKey]).toBeDefined()
expect(agents[prometheusKey].mode).toBe("all")
})
@@ -437,7 +437,7 @@ describe("Agent permission defaults", () => {
// #then
const agentConfig = config.agent as Record<string, { permission?: Record<string, string> }>
const hephaestusKey = getAgentDisplayName("hephaestus")
const hephaestusKey = getAgentListDisplayName("hephaestus")
expect(agentConfig[hephaestusKey]).toBeDefined()
expect(agentConfig[hephaestusKey].permission?.task).toBe("allow")
})
@@ -779,7 +779,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 = getAgentDisplayName("prometheus")
const pKey = getAgentListDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].reasoningEffort).toBe("low")
})
@@ -820,7 +820,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 = getAgentDisplayName("prometheus")
const pKey = getAgentListDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].reasoningEffort).toBe("high")
})
@@ -862,7 +862,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 = getAgentDisplayName("prometheus")
const pKey = getAgentListDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].temperature).toBe(0.1)
})
@@ -898,7 +898,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 = getAgentDisplayName("prometheus")
const pKey = getAgentListDisplayName("prometheus")
expect(agents[pKey]).toBeDefined()
expect(agents[pKey].prompt).toContain("Prometheus")
expect(agents[pKey].prompt).toContain(customInstructions)
@@ -1336,10 +1336,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[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()
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()
})
test("does not deny todowrite/todoread when task_system is undefined", async () => {
@@ -1375,8 +1375,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[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
})
})