fix(agents): use list display names for ordered agent config

This commit is contained in:
YeonGyu-Kim
2026-03-31 15:11:00 -07:00
parent 1d0135b230
commit e2e57bb2dd
7 changed files with 59 additions and 24 deletions
@@ -54,7 +54,7 @@ describe("remapAgentKeysToDisplayNames", () => {
expect(result["hephaestus"]).toBeUndefined() expect(result["hephaestus"]).toBeUndefined()
expect(result["Prometheus (Plan Builder)"]).toBeDefined() expect(result["Prometheus (Plan Builder)"]).toBeDefined()
expect(result["prometheus"]).toBeUndefined() expect(result["prometheus"]).toBeUndefined()
expect(result["Atlas (Plan Executor)"]).toBeDefined() expect(result["\u200BAtlas (Plan Executor)"]).toBeDefined()
expect(result["atlas"]).toBeUndefined() expect(result["atlas"]).toBeUndefined()
expect(result["Athena (Council)"]).toBeDefined() expect(result["Athena (Council)"]).toBeDefined()
expect(result["athena"]).toBeUndefined() expect(result["athena"]).toBeUndefined()
+2 -2
View File
@@ -1,4 +1,4 @@
import { AGENT_DISPLAY_NAMES } from "../shared/agent-display-names" import { getAgentListDisplayName } from "../shared/agent-display-names"
export function remapAgentKeysToDisplayNames( export function remapAgentKeysToDisplayNames(
agents: Record<string, unknown>, agents: Record<string, unknown>,
@@ -6,7 +6,7 @@ export function remapAgentKeysToDisplayNames(
const result: Record<string, unknown> = {} const result: Record<string, unknown> = {}
for (const [key, value] of Object.entries(agents)) { for (const [key, value] of Object.entries(agents)) {
const displayName = AGENT_DISPLAY_NAMES[key] const displayName = getAgentListDisplayName(key)
if (displayName && displayName !== key) { if (displayName && displayName !== key) {
result[displayName] = value result[displayName] = value
// Regression guard: do not also assign result[key]. // Regression guard: do not also assign result[key].
+5 -5
View File
@@ -1,10 +1,10 @@
import { getAgentDisplayName } from "../shared/agent-display-names"; import { getAgentListDisplayName } from "../shared/agent-display-names";
const CORE_AGENT_ORDER: ReadonlyArray<{ displayName: string; order: number }> = [ const CORE_AGENT_ORDER: ReadonlyArray<{ displayName: string; order: number }> = [
{ displayName: getAgentDisplayName("sisyphus"), order: 1 }, { displayName: getAgentListDisplayName("sisyphus"), order: 1 },
{ displayName: getAgentDisplayName("hephaestus"), order: 2 }, { displayName: getAgentListDisplayName("hephaestus"), order: 2 },
{ displayName: getAgentDisplayName("prometheus"), order: 3 }, { displayName: getAgentListDisplayName("prometheus"), order: 3 },
{ displayName: getAgentDisplayName("atlas"), order: 4 }, { displayName: getAgentListDisplayName("atlas"), order: 4 },
]; ];
function injectOrderField( function injectOrderField(
+10 -10
View File
@@ -4,7 +4,7 @@ import { describe, test, expect, spyOn, beforeEach, afterEach } from "bun:test"
import { resolveCategoryConfig, createConfigHandler } from "./config-handler" import { resolveCategoryConfig, createConfigHandler } from "./config-handler"
import type { CategoryConfig } from "../config/schema" import type { CategoryConfig } from "../config/schema"
import type { OhMyOpenCodeConfig } from "../config" import type { OhMyOpenCodeConfig } from "../config"
import { getAgentDisplayName } from "../shared/agent-display-names" import { getAgentDisplayName, getAgentListDisplayName } from "../shared/agent-display-names"
import * as agents from "../agents" import * as agents from "../agents"
import * as sisyphusJunior from "../agents/sisyphus-junior" import * as sisyphusJunior from "../agents/sisyphus-junior"
@@ -198,10 +198,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 = [
getAgentDisplayName("sisyphus"), getAgentListDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"), getAgentListDisplayName("hephaestus"),
getAgentDisplayName("prometheus"), getAgentListDisplayName("prometheus"),
getAgentDisplayName("atlas"), getAgentListDisplayName("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)
@@ -1158,11 +1158,11 @@ describe("config-handler plugin loading error boundary (#1559)", () => {
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([
getAgentDisplayName("sisyphus"), getAgentListDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"), getAgentListDisplayName("hephaestus"),
getAgentDisplayName("atlas"), getAgentListDisplayName("atlas"),
getAgentDisplayName("prometheus"), getAgentListDisplayName("prometheus"),
getAgentDisplayName("sisyphus-junior"), getAgentListDisplayName("sisyphus-junior"),
]) ])
test("denies todowrite and todoread for primary agents when task_system is enabled", async () => { test("denies todowrite and todoread for primary agents when task_system is enabled", async () => {
+2 -2
View File
@@ -1,5 +1,5 @@
import type { OhMyOpenCodeConfig } from "../config"; import type { OhMyOpenCodeConfig } from "../config";
import { getAgentDisplayName } from "../shared/agent-display-names"; import { getAgentDisplayName, getAgentListDisplayName } from "../shared/agent-display-names";
type AgentWithPermission = { permission?: Record<string, unknown> }; type AgentWithPermission = { permission?: Record<string, unknown> };
@@ -15,7 +15,7 @@ function getConfigQuestionPermission(): string | null {
} }
function agentByKey(agentResult: Record<string, unknown>, key: string): AgentWithPermission | undefined { function agentByKey(agentResult: Record<string, unknown>, key: string): AgentWithPermission | undefined {
return (agentResult[getAgentDisplayName(key)] ?? agentResult[key]) as return (agentResult[getAgentListDisplayName(key)] ?? agentResult[getAgentDisplayName(key)] ?? agentResult[key]) as
| AgentWithPermission | AgentWithPermission
| undefined; | undefined;
} }
+22 -2
View File
@@ -1,5 +1,5 @@
import { describe, it, expect } from "bun:test" import { describe, it, expect } from "bun:test"
import { AGENT_DISPLAY_NAMES, getAgentDisplayName, getAgentConfigKey } from "./agent-display-names" import { AGENT_DISPLAY_NAMES, getAgentConfigKey, getAgentDisplayName, getAgentListDisplayName, normalizeAgentForPrompt } from "./agent-display-names"
describe("getAgentDisplayName", () => { describe("getAgentDisplayName", () => {
it("returns display name for lowercase config key (new format)", () => { it("returns display name for lowercase config key (new format)", () => {
@@ -174,6 +174,26 @@ describe("getAgentConfigKey", () => {
expect(getAgentConfigKey("Momus (Plan Critic)")).toBe("momus") expect(getAgentConfigKey("Momus (Plan Critic)")).toBe("momus")
expect(getAgentConfigKey("Sisyphus-Junior")).toBe("sisyphus-junior") expect(getAgentConfigKey("Sisyphus-Junior")).toBe("sisyphus-junior")
}) })
it("resolves atlas even when the UI ordering prefix is present", () => {
expect(getAgentConfigKey(getAgentListDisplayName("atlas"))).toBe("atlas")
})
})
describe("getAgentListDisplayName", () => {
it("keeps sisyphus unchanged for list display", () => {
expect(getAgentListDisplayName("sisyphus")).toBe("Sisyphus (Ultraworker)")
})
it("applies invisible atlas sort prefix for list display", () => {
expect(getAgentListDisplayName("atlas")).toBe("\u200BAtlas (Plan Executor)")
})
})
describe("normalizeAgentForPrompt", () => {
it("strips atlas UI ordering prefix back to canonical display name", () => {
expect(normalizeAgentForPrompt(getAgentListDisplayName("atlas"))).toBe("Atlas (Plan Executor)")
})
}) })
describe("AGENT_DISPLAY_NAMES", () => { describe("AGENT_DISPLAY_NAMES", () => {
@@ -200,4 +220,4 @@ describe("AGENT_DISPLAY_NAMES", () => {
// then contains all expected mappings // then contains all expected mappings
expect(AGENT_DISPLAY_NAMES).toEqual(expectedMappings) expect(AGENT_DISPLAY_NAMES).toEqual(expectedMappings)
}) })
}) })
+17 -2
View File
@@ -20,6 +20,14 @@ export const AGENT_DISPLAY_NAMES: Record<string, string> = {
"council-member": "council-member", "council-member": "council-member",
} }
const AGENT_LIST_SORT_PREFIXES: Record<string, string> = {
atlas: "\u200B",
}
function stripAgentListSortPrefix(agentName: string): string {
return agentName.replace(/^\u200B+/, "")
}
/** /**
* Get display name for an agent config key. * Get display name for an agent config key.
* Uses case-insensitive lookup for backward compatibility. * Uses case-insensitive lookup for backward compatibility.
@@ -40,6 +48,13 @@ export function getAgentDisplayName(configKey: string): string {
return configKey return configKey
} }
export function getAgentListDisplayName(configKey: string): string {
const displayName = getAgentDisplayName(configKey)
const prefix = AGENT_LIST_SORT_PREFIXES[configKey.toLowerCase()]
return prefix ? `${prefix}${displayName}` : displayName
}
const REVERSE_DISPLAY_NAMES: Record<string, string> = Object.fromEntries( const REVERSE_DISPLAY_NAMES: Record<string, string> = Object.fromEntries(
Object.entries(AGENT_DISPLAY_NAMES).map(([key, displayName]) => [displayName.toLowerCase(), key]), Object.entries(AGENT_DISPLAY_NAMES).map(([key, displayName]) => [displayName.toLowerCase(), key]),
) )
@@ -49,7 +64,7 @@ const REVERSE_DISPLAY_NAMES: Record<string, string> = Object.fromEntries(
* "Atlas (Plan Executor)" → "atlas", "atlas" → "atlas", "unknown" → "unknown" * "Atlas (Plan Executor)" → "atlas", "atlas" → "atlas", "unknown" → "unknown"
*/ */
export function getAgentConfigKey(agentName: string): string { export function getAgentConfigKey(agentName: string): string {
const lower = agentName.toLowerCase() const lower = stripAgentListSortPrefix(agentName).toLowerCase()
const reversed = REVERSE_DISPLAY_NAMES[lower] const reversed = REVERSE_DISPLAY_NAMES[lower]
if (reversed !== undefined) return reversed if (reversed !== undefined) return reversed
if (AGENT_DISPLAY_NAMES[lower] !== undefined) return lower if (AGENT_DISPLAY_NAMES[lower] !== undefined) return lower
@@ -67,7 +82,7 @@ export function normalizeAgentForPrompt(agentName: string | undefined): string |
return undefined return undefined
} }
const trimmed = agentName.trim() const trimmed = stripAgentListSortPrefix(agentName.trim())
if (!trimmed) { if (!trimmed) {
return undefined return undefined
} }