fix(agents): use list display names for ordered agent config
This commit is contained in:
@@ -54,7 +54,7 @@ describe("remapAgentKeysToDisplayNames", () => {
|
||||
expect(result["hephaestus"]).toBeUndefined()
|
||||
expect(result["Prometheus (Plan Builder)"]).toBeDefined()
|
||||
expect(result["prometheus"]).toBeUndefined()
|
||||
expect(result["Atlas (Plan Executor)"]).toBeDefined()
|
||||
expect(result["\u200BAtlas (Plan Executor)"]).toBeDefined()
|
||||
expect(result["atlas"]).toBeUndefined()
|
||||
expect(result["Athena (Council)"]).toBeDefined()
|
||||
expect(result["athena"]).toBeUndefined()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AGENT_DISPLAY_NAMES } from "../shared/agent-display-names"
|
||||
import { getAgentListDisplayName } from "../shared/agent-display-names"
|
||||
|
||||
export function remapAgentKeysToDisplayNames(
|
||||
agents: Record<string, unknown>,
|
||||
@@ -6,7 +6,7 @@ export function remapAgentKeysToDisplayNames(
|
||||
const result: Record<string, unknown> = {}
|
||||
|
||||
for (const [key, value] of Object.entries(agents)) {
|
||||
const displayName = AGENT_DISPLAY_NAMES[key]
|
||||
const displayName = getAgentListDisplayName(key)
|
||||
if (displayName && displayName !== key) {
|
||||
result[displayName] = value
|
||||
// Regression guard: do not also assign result[key].
|
||||
|
||||
@@ -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 }> = [
|
||||
{ displayName: getAgentDisplayName("sisyphus"), order: 1 },
|
||||
{ displayName: getAgentDisplayName("hephaestus"), order: 2 },
|
||||
{ displayName: getAgentDisplayName("prometheus"), order: 3 },
|
||||
{ displayName: getAgentDisplayName("atlas"), order: 4 },
|
||||
{ displayName: getAgentListDisplayName("sisyphus"), order: 1 },
|
||||
{ displayName: getAgentListDisplayName("hephaestus"), order: 2 },
|
||||
{ displayName: getAgentListDisplayName("prometheus"), order: 3 },
|
||||
{ displayName: getAgentListDisplayName("atlas"), order: 4 },
|
||||
];
|
||||
|
||||
function injectOrderField(
|
||||
|
||||
@@ -4,7 +4,7 @@ import { describe, test, expect, spyOn, beforeEach, afterEach } from "bun:test"
|
||||
import { resolveCategoryConfig, createConfigHandler } from "./config-handler"
|
||||
import type { CategoryConfig } from "../config/schema"
|
||||
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 sisyphusJunior from "../agents/sisyphus-junior"
|
||||
@@ -198,10 +198,10 @@ describe("Plan agent demote behavior", () => {
|
||||
// #then
|
||||
const keys = Object.keys(config.agent as Record<string, unknown>)
|
||||
const coreAgents = [
|
||||
getAgentDisplayName("sisyphus"),
|
||||
getAgentDisplayName("hephaestus"),
|
||||
getAgentDisplayName("prometheus"),
|
||||
getAgentDisplayName("atlas"),
|
||||
getAgentListDisplayName("sisyphus"),
|
||||
getAgentListDisplayName("hephaestus"),
|
||||
getAgentListDisplayName("prometheus"),
|
||||
getAgentListDisplayName("atlas"),
|
||||
]
|
||||
const ordered = keys.filter((key) => coreAgents.includes(key))
|
||||
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", () => {
|
||||
const AGENTS_WITH_TODO_DENY = new Set([
|
||||
getAgentDisplayName("sisyphus"),
|
||||
getAgentDisplayName("hephaestus"),
|
||||
getAgentDisplayName("atlas"),
|
||||
getAgentDisplayName("prometheus"),
|
||||
getAgentDisplayName("sisyphus-junior"),
|
||||
getAgentListDisplayName("sisyphus"),
|
||||
getAgentListDisplayName("hephaestus"),
|
||||
getAgentListDisplayName("atlas"),
|
||||
getAgentListDisplayName("prometheus"),
|
||||
getAgentListDisplayName("sisyphus-junior"),
|
||||
])
|
||||
|
||||
test("denies todowrite and todoread for primary agents when task_system is enabled", async () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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> };
|
||||
|
||||
@@ -15,7 +15,7 @@ function getConfigQuestionPermission(): string | null {
|
||||
}
|
||||
|
||||
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
|
||||
| undefined;
|
||||
}
|
||||
|
||||
@@ -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