Revert name fields from agent configs, add getAgentConfigKey reverse lookup
Remove crash-causing name fields from 6 agent configs (sisyphus, hephaestus, atlas, metis, momus, prometheus). The name field approach breaks opencode because Agent.get(agent.name) uses name as lookup key. Add getAgentConfigKey() to agent-display-names.ts for resolving display names back to lowercase config keys (e.g. 'Atlas (Plan Executor)' -> 'atlas').
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { describe, it, expect } from "bun:test"
|
||||
import { AGENT_DISPLAY_NAMES, getAgentDisplayName } from "./agent-display-names"
|
||||
import { AGENT_DISPLAY_NAMES, getAgentDisplayName, getAgentConfigKey } from "./agent-display-names"
|
||||
|
||||
describe("getAgentDisplayName", () => {
|
||||
it("returns display name for lowercase config key (new format)", () => {
|
||||
@@ -135,6 +135,47 @@ describe("getAgentDisplayName", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("getAgentConfigKey", () => {
|
||||
it("resolves display name to config key", () => {
|
||||
// given display name "Sisyphus (Ultraworker)"
|
||||
// when getAgentConfigKey called
|
||||
// then returns "sisyphus"
|
||||
expect(getAgentConfigKey("Sisyphus (Ultraworker)")).toBe("sisyphus")
|
||||
})
|
||||
|
||||
it("resolves display name case-insensitively", () => {
|
||||
// given display name in different case
|
||||
// when getAgentConfigKey called
|
||||
// then returns "atlas"
|
||||
expect(getAgentConfigKey("atlas (plan executor)")).toBe("atlas")
|
||||
})
|
||||
|
||||
it("passes through lowercase config keys unchanged", () => {
|
||||
// given lowercase config key "prometheus"
|
||||
// when getAgentConfigKey called
|
||||
// then returns "prometheus"
|
||||
expect(getAgentConfigKey("prometheus")).toBe("prometheus")
|
||||
})
|
||||
|
||||
it("returns lowercased unknown agents", () => {
|
||||
// given unknown agent name
|
||||
// when getAgentConfigKey called
|
||||
// then returns lowercased
|
||||
expect(getAgentConfigKey("Custom-Agent")).toBe("custom-agent")
|
||||
})
|
||||
|
||||
it("resolves all core agent display names", () => {
|
||||
// given all core display names
|
||||
// when/then each resolves to its config key
|
||||
expect(getAgentConfigKey("Hephaestus (Deep Agent)")).toBe("hephaestus")
|
||||
expect(getAgentConfigKey("Prometheus (Plan Builder)")).toBe("prometheus")
|
||||
expect(getAgentConfigKey("Atlas (Plan Executor)")).toBe("atlas")
|
||||
expect(getAgentConfigKey("Metis (Plan Consultant)")).toBe("metis")
|
||||
expect(getAgentConfigKey("Momus (Plan Critic)")).toBe("momus")
|
||||
expect(getAgentConfigKey("Sisyphus-Junior")).toBe("sisyphus-junior")
|
||||
})
|
||||
})
|
||||
|
||||
describe("AGENT_DISPLAY_NAMES", () => {
|
||||
it("contains all expected agent mappings", () => {
|
||||
// given expected mappings
|
||||
|
||||
@@ -35,4 +35,20 @@ export function getAgentDisplayName(configKey: string): string {
|
||||
|
||||
// Unknown agent: return original key
|
||||
return configKey
|
||||
}
|
||||
|
||||
const REVERSE_DISPLAY_NAMES: Record<string, string> = Object.fromEntries(
|
||||
Object.entries(AGENT_DISPLAY_NAMES).map(([key, displayName]) => [displayName.toLowerCase(), key]),
|
||||
)
|
||||
|
||||
/**
|
||||
* Resolve an agent name (display name or config key) to its lowercase config key.
|
||||
* "Atlas (Plan Executor)" → "atlas", "atlas" → "atlas", "unknown" → "unknown"
|
||||
*/
|
||||
export function getAgentConfigKey(agentName: string): string {
|
||||
const lower = agentName.toLowerCase()
|
||||
const reversed = REVERSE_DISPLAY_NAMES[lower]
|
||||
if (reversed !== undefined) return reversed
|
||||
if (AGENT_DISPLAY_NAMES[lower] !== undefined) return lower
|
||||
return lower
|
||||
}
|
||||
Reference in New Issue
Block a user