fix: unify agent display names and strip invisible sort prefixes

- Replace getAgentRuntimeName with getAgentDisplayName for consistency
- Add stripAgentListSortPrefix helper to normalize agent names
- Strip sort prefixes in subagent-resolver and sync-executor
- Backfill canonical names for core agents when builtin configs omit name
- Update tests to match new behavior
This commit is contained in:
YeonGyu-Kim
2026-04-11 14:53:01 +09:00
parent c30b058b7e
commit 9f135af41c
9 changed files with 180 additions and 37 deletions
+42 -7
View File
@@ -1,6 +1,6 @@
import { describe, it, expect } from "bun:test"
import { remapAgentKeysToDisplayNames } from "./agent-key-remapper"
import { getAgentDisplayName, getAgentRuntimeName } from "../shared/agent-display-names"
import { getAgentDisplayName } from "../shared/agent-display-names"
describe("remapAgentKeysToDisplayNames", () => {
it("remaps known agent keys to display names", () => {
@@ -106,7 +106,7 @@ describe("remapAgentKeysToDisplayNames", () => {
}
})
it("preserves clean keys but rewrites core agent name fields to list-display names for tab cycling", () => {
it("preserves clean keys and rewrites core agent name fields to canonical display names", () => {
// given agents with raw config-key names
const agents = {
sisyphus: { name: "sisyphus", prompt: "test", mode: "primary" },
@@ -119,7 +119,7 @@ describe("remapAgentKeysToDisplayNames", () => {
// when remapping
const result = remapAgentKeysToDisplayNames(agents)
// then keys stay HTTP-header-safe, but nested names carry stable list ordering
// then keys stay HTTP-header-safe, and nested names match the lookup-safe display names
expect(Object.keys(result).slice(0, 4)).toEqual([
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
@@ -127,25 +127,60 @@ describe("remapAgentKeysToDisplayNames", () => {
getAgentDisplayName("atlas"),
])
expect(result[getAgentDisplayName("sisyphus")]).toEqual({
name: getAgentRuntimeName("sisyphus"),
name: getAgentDisplayName("sisyphus"),
prompt: "test",
mode: "primary",
})
expect(result[getAgentDisplayName("hephaestus")]).toEqual({
name: getAgentRuntimeName("hephaestus"),
name: getAgentDisplayName("hephaestus"),
prompt: "test",
mode: "primary",
})
expect(result[getAgentDisplayName("prometheus")]).toEqual({
name: getAgentRuntimeName("prometheus"),
name: getAgentDisplayName("prometheus"),
prompt: "test",
mode: "all",
})
expect(result[getAgentDisplayName("atlas")]).toEqual({
name: getAgentRuntimeName("atlas"),
name: getAgentDisplayName("atlas"),
prompt: "test",
mode: "primary",
})
expect(result.oracle).toEqual({ name: "oracle", prompt: "test", mode: "subagent" })
})
it("backfills canonical display names for core agents when builtin configs omit name", () => {
// given builtin-style configs without name fields
const agents = {
sisyphus: { prompt: "test", mode: "primary" },
hephaestus: { prompt: "test", mode: "primary" },
prometheus: { prompt: "test", mode: "all" },
atlas: { prompt: "test", mode: "primary" },
}
// when remapping
const result = remapAgentKeysToDisplayNames(agents)
// then OpenCode receives lookup-safe display names and uses order for sorting
expect(result[getAgentDisplayName("sisyphus")]).toEqual({
name: getAgentDisplayName("sisyphus"),
prompt: "test",
mode: "primary",
})
expect(result[getAgentDisplayName("hephaestus")]).toEqual({
name: getAgentDisplayName("hephaestus"),
prompt: "test",
mode: "primary",
})
expect(result[getAgentDisplayName("prometheus")]).toEqual({
name: getAgentDisplayName("prometheus"),
prompt: "test",
mode: "all",
})
expect(result[getAgentDisplayName("atlas")]).toEqual({
name: getAgentDisplayName("atlas"),
prompt: "test",
mode: "primary",
})
})
})