fix(agents): use list display names for ordered agent config
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
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", () => {
|
||||
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("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", () => {
|
||||
@@ -200,4 +220,4 @@ describe("AGENT_DISPLAY_NAMES", () => {
|
||||
// then contains all expected mappings
|
||||
expect(AGENT_DISPLAY_NAMES).toEqual(expectedMappings)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -20,6 +20,14 @@ export const AGENT_DISPLAY_NAMES: Record<string, string> = {
|
||||
"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.
|
||||
* Uses case-insensitive lookup for backward compatibility.
|
||||
@@ -40,6 +48,13 @@ export function getAgentDisplayName(configKey: string): string {
|
||||
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(
|
||||
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"
|
||||
*/
|
||||
export function getAgentConfigKey(agentName: string): string {
|
||||
const lower = agentName.toLowerCase()
|
||||
const lower = stripAgentListSortPrefix(agentName).toLowerCase()
|
||||
const reversed = REVERSE_DISPLAY_NAMES[lower]
|
||||
if (reversed !== undefined) return reversed
|
||||
if (AGENT_DISPLAY_NAMES[lower] !== undefined) return lower
|
||||
@@ -67,7 +82,7 @@ export function normalizeAgentForPrompt(agentName: string | undefined): string |
|
||||
return undefined
|
||||
}
|
||||
|
||||
const trimmed = agentName.trim()
|
||||
const trimmed = stripAgentListSortPrefix(agentName.trim())
|
||||
if (!trimmed) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user