2026-01-23 18:50:03 +09:00
|
|
|
import { describe, it, expect } from "bun:test"
|
2026-04-06 11:44:11 +09:00
|
|
|
import { AGENT_DISPLAY_NAMES, getAgentConfigKey, getAgentDisplayName, getAgentListDisplayName, normalizeAgentForPrompt, normalizeAgentForPromptKey } from "./agent-display-names"
|
2026-01-23 18:50:03 +09:00
|
|
|
|
|
|
|
|
describe("getAgentDisplayName", () => {
|
|
|
|
|
it("returns display name for lowercase config key (new format)", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "sisyphus"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "sisyphus"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then returns "Sisyphus (Ultraworker)"
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(result).toBe("Sisyphus (Ultraworker)")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns display name for uppercase config key (old format - case-insensitive)", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "Sisyphus" (old format)
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "Sisyphus"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then returns "Sisyphus (Ultraworker)" (case-insensitive lookup)
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(result).toBe("Sisyphus (Ultraworker)")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns original key for unknown agents (fallback)", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "custom-agent"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "custom-agent"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then returns "custom-agent" (original key unchanged)
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(result).toBe("custom-agent")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns display name for atlas", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "atlas"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "atlas"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-16 18:51:42 +09:00
|
|
|
// then returns "Atlas (Plan Executor)"
|
|
|
|
|
expect(result).toBe("Atlas (Plan Executor)")
|
2026-01-23 18:50:03 +09:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns display name for prometheus", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "prometheus"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "prometheus"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then returns "Prometheus (Plan Builder)"
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(result).toBe("Prometheus (Plan Builder)")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns display name for sisyphus-junior", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "sisyphus-junior"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "sisyphus-junior"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then returns "Sisyphus-Junior"
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(result).toBe("Sisyphus-Junior")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns display name for metis", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "metis"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "metis"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then returns "Metis (Plan Consultant)"
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(result).toBe("Metis (Plan Consultant)")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns display name for momus", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "momus"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "momus"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-16 18:51:42 +09:00
|
|
|
// then returns "Momus (Plan Critic)"
|
|
|
|
|
expect(result).toBe("Momus (Plan Critic)")
|
2026-01-23 18:50:03 +09:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns display name for oracle", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "oracle"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "oracle"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then returns "oracle"
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(result).toBe("oracle")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns display name for librarian", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "librarian"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "librarian"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then returns "librarian"
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(result).toBe("librarian")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns display name for explore", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "explore"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "explore"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then returns "explore"
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(result).toBe("explore")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("returns display name for multimodal-looker", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given config key "multimodal-looker"
|
2026-01-23 18:50:03 +09:00
|
|
|
const configKey = "multimodal-looker"
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when getAgentDisplayName called
|
2026-01-23 18:50:03 +09:00
|
|
|
const result = getAgentDisplayName(configKey)
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// then returns "multimodal-looker"
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(result).toBe("multimodal-looker")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
2026-02-16 20:42:45 +09:00
|
|
|
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")
|
|
|
|
|
})
|
2026-03-31 15:11:00 -07:00
|
|
|
|
|
|
|
|
it("resolves atlas even when the UI ordering prefix is present", () => {
|
|
|
|
|
expect(getAgentConfigKey(getAgentListDisplayName("atlas"))).toBe("atlas")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe("getAgentListDisplayName", () => {
|
2026-04-06 18:07:07 +09:00
|
|
|
it("applies invisible stable-sort prefixes to the core agent list", () => {
|
|
|
|
|
expect(getAgentListDisplayName("sisyphus")).toBe("\u200BSisyphus (Ultraworker)")
|
|
|
|
|
expect(getAgentListDisplayName("hephaestus")).toBe("\u200B\u200BHephaestus (Deep Agent)")
|
|
|
|
|
expect(getAgentListDisplayName("prometheus")).toBe("\u200B\u200B\u200BPrometheus (Plan Builder)")
|
|
|
|
|
expect(getAgentListDisplayName("atlas")).toBe("\u200B\u200B\u200B\u200BAtlas (Plan Executor)")
|
2026-03-31 15:11:00 -07:00
|
|
|
})
|
|
|
|
|
|
2026-04-06 18:07:07 +09:00
|
|
|
it("keeps non-core agents unprefixed for list display", () => {
|
|
|
|
|
expect(getAgentListDisplayName("oracle")).toBe("oracle")
|
2026-03-31 15:11:00 -07:00
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe("normalizeAgentForPrompt", () => {
|
2026-04-06 18:07:07 +09:00
|
|
|
it("strips core UI ordering prefixes back to canonical display names", () => {
|
|
|
|
|
expect(normalizeAgentForPrompt(getAgentListDisplayName("sisyphus"))).toBe("Sisyphus (Ultraworker)")
|
|
|
|
|
expect(normalizeAgentForPrompt(getAgentListDisplayName("hephaestus"))).toBe("Hephaestus (Deep Agent)")
|
|
|
|
|
expect(normalizeAgentForPrompt(getAgentListDisplayName("prometheus"))).toBe("Prometheus (Plan Builder)")
|
2026-03-31 15:11:00 -07:00
|
|
|
expect(normalizeAgentForPrompt(getAgentListDisplayName("atlas"))).toBe("Atlas (Plan Executor)")
|
|
|
|
|
})
|
2026-02-16 20:42:45 +09:00
|
|
|
})
|
|
|
|
|
|
2026-04-06 11:44:11 +09:00
|
|
|
describe("normalizeAgentForPromptKey", () => {
|
|
|
|
|
it("converts built-in display names to config keys", () => {
|
|
|
|
|
expect(normalizeAgentForPromptKey("Sisyphus (Ultraworker)")).toBe("sisyphus")
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it("preserves custom agents", () => {
|
|
|
|
|
expect(normalizeAgentForPromptKey("MyCustomAgent")).toBe("MyCustomAgent")
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
2026-01-23 18:50:03 +09:00
|
|
|
describe("AGENT_DISPLAY_NAMES", () => {
|
|
|
|
|
it("contains all expected agent mappings", () => {
|
2026-02-01 16:47:50 +09:00
|
|
|
// given expected mappings
|
2026-01-23 18:50:03 +09:00
|
|
|
const expectedMappings = {
|
|
|
|
|
sisyphus: "Sisyphus (Ultraworker)",
|
2026-02-16 18:51:42 +09:00
|
|
|
hephaestus: "Hephaestus (Deep Agent)",
|
2026-01-23 18:50:03 +09:00
|
|
|
prometheus: "Prometheus (Plan Builder)",
|
2026-02-16 18:51:42 +09:00
|
|
|
atlas: "Atlas (Plan Executor)",
|
2026-01-23 18:50:03 +09:00
|
|
|
"sisyphus-junior": "Sisyphus-Junior",
|
|
|
|
|
metis: "Metis (Plan Consultant)",
|
2026-02-16 18:51:42 +09:00
|
|
|
momus: "Momus (Plan Critic)",
|
2026-03-29 04:02:13 +00:00
|
|
|
athena: "Athena (Council)",
|
|
|
|
|
"athena-junior": "Athena-Junior (Council)",
|
2026-01-23 18:50:03 +09:00
|
|
|
oracle: "oracle",
|
|
|
|
|
librarian: "librarian",
|
|
|
|
|
explore: "explore",
|
|
|
|
|
"multimodal-looker": "multimodal-looker",
|
2026-03-29 04:02:13 +00:00
|
|
|
"council-member": "council-member",
|
2026-01-23 18:50:03 +09:00
|
|
|
}
|
|
|
|
|
|
2026-02-01 16:47:50 +09:00
|
|
|
// when checking the constant
|
|
|
|
|
// then contains all expected mappings
|
2026-01-23 18:50:03 +09:00
|
|
|
expect(AGENT_DISPLAY_NAMES).toEqual(expectedMappings)
|
|
|
|
|
})
|
2026-03-31 15:11:00 -07:00
|
|
|
})
|