diff --git a/src/plugin-handlers/agent-config-handler.test.ts b/src/plugin-handlers/agent-config-handler.test.ts index ac7551782..db7146f77 100644 --- a/src/plugin-handlers/agent-config-handler.test.ts +++ b/src/plugin-handlers/agent-config-handler.test.ts @@ -9,7 +9,7 @@ import type { OhMyOpenCodeConfig } from "../config" import * as agentLoader from "../features/claude-code-agent-loader" import * as skillLoader from "../features/opencode-skill-loader" import type { LoadedSkill } from "../features/opencode-skill-loader" -import { getAgentDisplayName } from "../shared/agent-display-names" +import { getAgentDisplayName, getAgentRuntimeName } from "../shared/agent-display-names" import { applyAgentConfig } from "./agent-config-handler" import type { PluginComponents } from "./plugin-components-loader" @@ -203,7 +203,7 @@ describe("applyAgentConfig builtin override protection", () => { // then expect(result[BUILTIN_SISYPHUS_DISPLAY_NAME]).toEqual({ ...builtinSisyphusConfig, - name: getAgentDisplayName("sisyphus"), + name: getAgentRuntimeName("sisyphus"), }) }) @@ -228,7 +228,7 @@ describe("applyAgentConfig builtin override protection", () => { // then expect(result[BUILTIN_SISYPHUS_DISPLAY_NAME]).toEqual({ ...builtinSisyphusConfig, - name: getAgentDisplayName("sisyphus"), + name: getAgentRuntimeName("sisyphus"), }) expect(result.SiSyPhUs).toBeUndefined() }) @@ -255,7 +255,7 @@ describe("applyAgentConfig builtin override protection", () => { // then expect(result[BUILTIN_SISYPHUS_DISPLAY_NAME]).toEqual({ ...builtinSisyphusConfig, - name: getAgentDisplayName("sisyphus"), + name: getAgentRuntimeName("sisyphus"), }) }) diff --git a/src/plugin-handlers/agent-config-handler.ts b/src/plugin-handlers/agent-config-handler.ts index 8c4a8b1fd..732576ec9 100644 --- a/src/plugin-handlers/agent-config-handler.ts +++ b/src/plugin-handlers/agent-config-handler.ts @@ -2,7 +2,7 @@ import { createBuiltinAgents } from "../agents"; import { createSisyphusJuniorAgentWithOverrides } from "../agents/sisyphus-junior"; import type { OhMyOpenCodeConfig } from "../config"; import { isTaskSystemEnabled, log, migrateAgentConfig } from "../shared"; -import { getAgentDisplayName } from "../shared/agent-display-names"; +import { getAgentDisplayName, getAgentRuntimeName } from "../shared/agent-display-names"; import { AGENT_NAME_MAP } from "../shared/migration"; import { registerAgentName } from "../features/claude-code-session-state"; import { @@ -159,10 +159,10 @@ export async function applyAgentConfig(params: { if (isSisyphusEnabled && builtinAgents.sisyphus) { if (configuredDefaultAgent) { (params.config as { default_agent?: string }).default_agent = - getAgentDisplayName(configuredDefaultAgent); + getAgentRuntimeName(configuredDefaultAgent); } else { (params.config as { default_agent?: string }).default_agent = - getAgentDisplayName("sisyphus"); + getAgentRuntimeName("sisyphus"); } // Assembly order: Sisyphus -> Hephaestus -> Prometheus -> Atlas diff --git a/src/plugin-handlers/agent-key-remapper.test.ts b/src/plugin-handlers/agent-key-remapper.test.ts index 94a81a0b6..e792d8755 100644 --- a/src/plugin-handlers/agent-key-remapper.test.ts +++ b/src/plugin-handlers/agent-key-remapper.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect } from "bun:test" import { remapAgentKeysToDisplayNames } from "./agent-key-remapper" -import { getAgentDisplayName } from "../shared/agent-display-names" +import { getAgentDisplayName, getAgentRuntimeName } from "../shared/agent-display-names" describe("remapAgentKeysToDisplayNames", () => { it("remaps known agent keys to display names", () => { @@ -106,7 +106,7 @@ describe("remapAgentKeysToDisplayNames", () => { } }) - it("preserves clean keys and rewrites core agent name fields to canonical display names", () => { + it("preserves clean keys but rewrites core agent name fields to runtime names for sort ordering", () => { // given agents with raw config-key names const agents = { sisyphus: { name: "sisyphus", prompt: "test", mode: "primary" }, @@ -119,7 +119,7 @@ describe("remapAgentKeysToDisplayNames", () => { // when remapping const result = remapAgentKeysToDisplayNames(agents) - // then keys stay HTTP-header-safe, and nested names match the lookup-safe display names + // then keys stay HTTP-header-safe, name fields carry ZWSP for OpenCode localeCompare sort expect(Object.keys(result).slice(0, 4)).toEqual([ getAgentDisplayName("sisyphus"), getAgentDisplayName("hephaestus"), @@ -127,29 +127,29 @@ describe("remapAgentKeysToDisplayNames", () => { getAgentDisplayName("atlas"), ]) expect(result[getAgentDisplayName("sisyphus")]).toEqual({ - name: getAgentDisplayName("sisyphus"), + name: getAgentRuntimeName("sisyphus"), prompt: "test", mode: "primary", }) expect(result[getAgentDisplayName("hephaestus")]).toEqual({ - name: getAgentDisplayName("hephaestus"), + name: getAgentRuntimeName("hephaestus"), prompt: "test", mode: "primary", }) expect(result[getAgentDisplayName("prometheus")]).toEqual({ - name: getAgentDisplayName("prometheus"), + name: getAgentRuntimeName("prometheus"), prompt: "test", mode: "all", }) expect(result[getAgentDisplayName("atlas")]).toEqual({ - name: getAgentDisplayName("atlas"), + name: getAgentRuntimeName("atlas"), prompt: "test", mode: "primary", }) expect(result.oracle).toEqual({ name: "oracle", prompt: "test", mode: "subagent" }) }) - it("backfills canonical display names for core agents when builtin configs omit name", () => { + it("backfills runtime names for core agents when builtin configs omit name", () => { // given builtin-style configs without name fields const agents = { sisyphus: { prompt: "test", mode: "primary" }, @@ -161,24 +161,24 @@ describe("remapAgentKeysToDisplayNames", () => { // when remapping const result = remapAgentKeysToDisplayNames(agents) - // then OpenCode receives lookup-safe display names and uses order for sorting + // then OpenCode's name sort can still preserve canonical order expect(result[getAgentDisplayName("sisyphus")]).toEqual({ - name: getAgentDisplayName("sisyphus"), + name: getAgentRuntimeName("sisyphus"), prompt: "test", mode: "primary", }) expect(result[getAgentDisplayName("hephaestus")]).toEqual({ - name: getAgentDisplayName("hephaestus"), + name: getAgentRuntimeName("hephaestus"), prompt: "test", mode: "primary", }) expect(result[getAgentDisplayName("prometheus")]).toEqual({ - name: getAgentDisplayName("prometheus"), + name: getAgentRuntimeName("prometheus"), prompt: "test", mode: "all", }) expect(result[getAgentDisplayName("atlas")]).toEqual({ - name: getAgentDisplayName("atlas"), + name: getAgentRuntimeName("atlas"), prompt: "test", mode: "primary", }) diff --git a/src/plugin-handlers/agent-key-remapper.ts b/src/plugin-handlers/agent-key-remapper.ts index c15241301..93499b014 100644 --- a/src/plugin-handlers/agent-key-remapper.ts +++ b/src/plugin-handlers/agent-key-remapper.ts @@ -1,4 +1,4 @@ -import { getAgentDisplayName } from "../shared/agent-display-names" +import { getAgentDisplayName, getAgentRuntimeName } from "../shared/agent-display-names" function rewriteAgentNameForListDisplay( key: string, @@ -11,7 +11,7 @@ function rewriteAgentNameForListDisplay( const agent = value as Record return { ...agent, - name: getAgentDisplayName(key), + name: getAgentRuntimeName(key), } } diff --git a/src/plugin-handlers/config-handler.test.ts b/src/plugin-handlers/config-handler.test.ts index 8fdc2d29c..4cde1dadb 100644 --- a/src/plugin-handlers/config-handler.test.ts +++ b/src/plugin-handlers/config-handler.test.ts @@ -355,19 +355,19 @@ describe("Plan agent demote behavior", () => { expect(emittedCoreEntries).toEqual([ [ getAgentDisplayName("sisyphus"), - expect.objectContaining({ name: getAgentDisplayName("sisyphus") }), + expect.objectContaining({ name: getAgentRuntimeName("sisyphus") }), ], [ getAgentDisplayName("hephaestus"), - expect.objectContaining({ name: getAgentDisplayName("hephaestus") }), + expect.objectContaining({ name: getAgentRuntimeName("hephaestus") }), ], [ getAgentDisplayName("prometheus"), - expect.objectContaining({ name: getAgentDisplayName("prometheus") }), + expect.objectContaining({ name: getAgentRuntimeName("prometheus") }), ], [ getAgentDisplayName("atlas"), - expect.objectContaining({ name: getAgentDisplayName("atlas") }), + expect.objectContaining({ name: getAgentRuntimeName("atlas") }), ], ]) }) @@ -536,7 +536,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => { await handler(config) // then - expect(config.default_agent).toBe(getAgentDisplayName("hephaestus")) + expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus")) }) test("canonicalizes configured default_agent when key uses mixed case", async () => { @@ -560,7 +560,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => { await handler(config) // then - expect(config.default_agent).toBe(getAgentDisplayName("hephaestus")) + expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus")) }) test("canonicalizes configured default_agent key to display name", async () => { @@ -584,7 +584,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => { await handler(config) // #then - expect(config.default_agent).toBe(getAgentDisplayName("hephaestus")) + expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus")) }) test("preserves existing display-name default_agent", async () => { @@ -632,7 +632,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => { await handler(config) // #then - expect(config.default_agent).toBe(getAgentDisplayName("sisyphus")) + expect(config.default_agent).toBe(getAgentRuntimeName("sisyphus")) }) test("uses canonical default_agent display name so OpenCode lookups match emitted agent keys", async () => { @@ -656,7 +656,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => { await handler(config) // then - expect(config.default_agent).toBe(getAgentDisplayName("hephaestus")) + expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus")) }) test("sets default_agent to sisyphus when configured default_agent is empty after trim", async () => { @@ -680,7 +680,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => { await handler(config) // then - expect(config.default_agent).toBe(getAgentDisplayName("sisyphus")) + expect(config.default_agent).toBe(getAgentRuntimeName("sisyphus")) }) test("preserves custom default_agent names while trimming whitespace", async () => {