feat(agents): support per-agent displayName for i18n (#4004)

Add optional `displayName` field to AgentOverrideConfigSchema (next to
the existing `color` field) so users can specify localized agent names
in oh-my-openagent.json:

  { "agents": { "sisyphus": { "displayName": "总指挥" } } }

When set, the override takes precedence everywhere
AGENT_DISPLAY_NAMES[agentName] is used — TUI agent selector, the
agent list key, and the internal `name` field. When not set, behavior
is identical to before (hardcoded English names from AGENT_DISPLAY_NAMES).

Implementation touches:
- AgentOverrideConfigSchema: adds displayName?: z.string().optional()
- getAgentDisplayName / getAgentListDisplayName: accept optional overrides
  map and check displayName before the hardcoded table
- remapAgentKeysToDisplayNames: forwards overrides map to name resolution
- agent-config-handler: passes pluginConfig.agents as the overrides map

Backward compatible — existing configs without displayName continue to
work unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ZeyuFu
2026-05-16 06:52:14 -04:00
parent fbc5768f9a
commit 7bc92bcd25
5 changed files with 80 additions and 6 deletions
@@ -197,4 +197,54 @@ describe("remapAgentKeysToDisplayNames", () => {
foo: "bar",
})
})
describe("displayName i18n override (#4004)", () => {
it("uses per-agent displayName override when set", () => {
// given sisyphus config with a Chinese displayName override
const agents = {
sisyphus: { prompt: "test", mode: "primary" },
}
const overrides = {
sisyphus: { displayName: "总指挥" },
}
// when remapping with overrides
const result = remapAgentKeysToDisplayNames(agents, overrides)
// then the localized name is used instead of "Sisyphus - Ultraworker"
expect(result["总指挥"]).toBeDefined()
expect((result["总指挥"] as Record<string, unknown>).name).toBe("总指挥")
expect(result["Sisyphus - Ultraworker"]).toBeUndefined()
})
it("falls back to hardcoded English name when displayName is not set", () => {
// given sisyphus config without displayName override
const agents = {
sisyphus: { prompt: "test", mode: "primary" },
}
const overrides = {
sisyphus: { model: "claude-opus-4-7" },
}
// when remapping with overrides that have no displayName
const result = remapAgentKeysToDisplayNames(agents, overrides)
// then the legacy AGENT_DISPLAY_NAMES value is used
expect(result["Sisyphus - Ultraworker"]).toBeDefined()
expect(result["总指挥"]).toBeUndefined()
})
it("falls back to hardcoded English name when no overrides are passed", () => {
// given sisyphus config with no overrides at all
const agents = {
sisyphus: { prompt: "test", mode: "primary" },
}
// when remapping without overrides
const result = remapAgentKeysToDisplayNames(agents)
// then the legacy AGENT_DISPLAY_NAMES value is used
expect(result["Sisyphus - Ultraworker"]).toBeDefined()
})
})
})