fix(agents): restore ZWSP runtime names in name field for OpenCode sort ordering
Reverts getAgentDisplayName back to getAgentRuntimeName in the remapper and default_agent assignment. OpenCode sorts agents by name via localeCompare, so ZWSP prefixes in the name field are required to preserve canonical core agent order (sisyphus > hephaestus > prometheus > atlas).
This commit is contained in:
@@ -9,7 +9,7 @@ import type { OhMyOpenCodeConfig } from "../config"
|
|||||||
import * as agentLoader from "../features/claude-code-agent-loader"
|
import * as agentLoader from "../features/claude-code-agent-loader"
|
||||||
import * as skillLoader from "../features/opencode-skill-loader"
|
import * as skillLoader from "../features/opencode-skill-loader"
|
||||||
import type { LoadedSkill } 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 { applyAgentConfig } from "./agent-config-handler"
|
||||||
import type { PluginComponents } from "./plugin-components-loader"
|
import type { PluginComponents } from "./plugin-components-loader"
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ describe("applyAgentConfig builtin override protection", () => {
|
|||||||
// then
|
// then
|
||||||
expect(result[BUILTIN_SISYPHUS_DISPLAY_NAME]).toEqual({
|
expect(result[BUILTIN_SISYPHUS_DISPLAY_NAME]).toEqual({
|
||||||
...builtinSisyphusConfig,
|
...builtinSisyphusConfig,
|
||||||
name: getAgentDisplayName("sisyphus"),
|
name: getAgentRuntimeName("sisyphus"),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ describe("applyAgentConfig builtin override protection", () => {
|
|||||||
// then
|
// then
|
||||||
expect(result[BUILTIN_SISYPHUS_DISPLAY_NAME]).toEqual({
|
expect(result[BUILTIN_SISYPHUS_DISPLAY_NAME]).toEqual({
|
||||||
...builtinSisyphusConfig,
|
...builtinSisyphusConfig,
|
||||||
name: getAgentDisplayName("sisyphus"),
|
name: getAgentRuntimeName("sisyphus"),
|
||||||
})
|
})
|
||||||
expect(result.SiSyPhUs).toBeUndefined()
|
expect(result.SiSyPhUs).toBeUndefined()
|
||||||
})
|
})
|
||||||
@@ -255,7 +255,7 @@ describe("applyAgentConfig builtin override protection", () => {
|
|||||||
// then
|
// then
|
||||||
expect(result[BUILTIN_SISYPHUS_DISPLAY_NAME]).toEqual({
|
expect(result[BUILTIN_SISYPHUS_DISPLAY_NAME]).toEqual({
|
||||||
...builtinSisyphusConfig,
|
...builtinSisyphusConfig,
|
||||||
name: getAgentDisplayName("sisyphus"),
|
name: getAgentRuntimeName("sisyphus"),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { createBuiltinAgents } from "../agents";
|
|||||||
import { createSisyphusJuniorAgentWithOverrides } from "../agents/sisyphus-junior";
|
import { createSisyphusJuniorAgentWithOverrides } from "../agents/sisyphus-junior";
|
||||||
import type { OhMyOpenCodeConfig } from "../config";
|
import type { OhMyOpenCodeConfig } from "../config";
|
||||||
import { isTaskSystemEnabled, log, migrateAgentConfig } from "../shared";
|
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 { AGENT_NAME_MAP } from "../shared/migration";
|
||||||
import { registerAgentName } from "../features/claude-code-session-state";
|
import { registerAgentName } from "../features/claude-code-session-state";
|
||||||
import {
|
import {
|
||||||
@@ -159,10 +159,10 @@ export async function applyAgentConfig(params: {
|
|||||||
if (isSisyphusEnabled && builtinAgents.sisyphus) {
|
if (isSisyphusEnabled && builtinAgents.sisyphus) {
|
||||||
if (configuredDefaultAgent) {
|
if (configuredDefaultAgent) {
|
||||||
(params.config as { default_agent?: string }).default_agent =
|
(params.config as { default_agent?: string }).default_agent =
|
||||||
getAgentDisplayName(configuredDefaultAgent);
|
getAgentRuntimeName(configuredDefaultAgent);
|
||||||
} else {
|
} else {
|
||||||
(params.config as { default_agent?: string }).default_agent =
|
(params.config as { default_agent?: string }).default_agent =
|
||||||
getAgentDisplayName("sisyphus");
|
getAgentRuntimeName("sisyphus");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assembly order: Sisyphus -> Hephaestus -> Prometheus -> Atlas
|
// Assembly order: Sisyphus -> Hephaestus -> Prometheus -> Atlas
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { describe, it, expect } from "bun:test"
|
import { describe, it, expect } from "bun:test"
|
||||||
import { remapAgentKeysToDisplayNames } from "./agent-key-remapper"
|
import { remapAgentKeysToDisplayNames } from "./agent-key-remapper"
|
||||||
import { getAgentDisplayName } from "../shared/agent-display-names"
|
import { getAgentDisplayName, getAgentRuntimeName } from "../shared/agent-display-names"
|
||||||
|
|
||||||
describe("remapAgentKeysToDisplayNames", () => {
|
describe("remapAgentKeysToDisplayNames", () => {
|
||||||
it("remaps known agent keys to display names", () => {
|
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
|
// given agents with raw config-key names
|
||||||
const agents = {
|
const agents = {
|
||||||
sisyphus: { name: "sisyphus", prompt: "test", mode: "primary" },
|
sisyphus: { name: "sisyphus", prompt: "test", mode: "primary" },
|
||||||
@@ -119,7 +119,7 @@ describe("remapAgentKeysToDisplayNames", () => {
|
|||||||
// when remapping
|
// when remapping
|
||||||
const result = remapAgentKeysToDisplayNames(agents)
|
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([
|
expect(Object.keys(result).slice(0, 4)).toEqual([
|
||||||
getAgentDisplayName("sisyphus"),
|
getAgentDisplayName("sisyphus"),
|
||||||
getAgentDisplayName("hephaestus"),
|
getAgentDisplayName("hephaestus"),
|
||||||
@@ -127,29 +127,29 @@ describe("remapAgentKeysToDisplayNames", () => {
|
|||||||
getAgentDisplayName("atlas"),
|
getAgentDisplayName("atlas"),
|
||||||
])
|
])
|
||||||
expect(result[getAgentDisplayName("sisyphus")]).toEqual({
|
expect(result[getAgentDisplayName("sisyphus")]).toEqual({
|
||||||
name: getAgentDisplayName("sisyphus"),
|
name: getAgentRuntimeName("sisyphus"),
|
||||||
prompt: "test",
|
prompt: "test",
|
||||||
mode: "primary",
|
mode: "primary",
|
||||||
})
|
})
|
||||||
expect(result[getAgentDisplayName("hephaestus")]).toEqual({
|
expect(result[getAgentDisplayName("hephaestus")]).toEqual({
|
||||||
name: getAgentDisplayName("hephaestus"),
|
name: getAgentRuntimeName("hephaestus"),
|
||||||
prompt: "test",
|
prompt: "test",
|
||||||
mode: "primary",
|
mode: "primary",
|
||||||
})
|
})
|
||||||
expect(result[getAgentDisplayName("prometheus")]).toEqual({
|
expect(result[getAgentDisplayName("prometheus")]).toEqual({
|
||||||
name: getAgentDisplayName("prometheus"),
|
name: getAgentRuntimeName("prometheus"),
|
||||||
prompt: "test",
|
prompt: "test",
|
||||||
mode: "all",
|
mode: "all",
|
||||||
})
|
})
|
||||||
expect(result[getAgentDisplayName("atlas")]).toEqual({
|
expect(result[getAgentDisplayName("atlas")]).toEqual({
|
||||||
name: getAgentDisplayName("atlas"),
|
name: getAgentRuntimeName("atlas"),
|
||||||
prompt: "test",
|
prompt: "test",
|
||||||
mode: "primary",
|
mode: "primary",
|
||||||
})
|
})
|
||||||
expect(result.oracle).toEqual({ name: "oracle", prompt: "test", mode: "subagent" })
|
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
|
// given builtin-style configs without name fields
|
||||||
const agents = {
|
const agents = {
|
||||||
sisyphus: { prompt: "test", mode: "primary" },
|
sisyphus: { prompt: "test", mode: "primary" },
|
||||||
@@ -161,24 +161,24 @@ describe("remapAgentKeysToDisplayNames", () => {
|
|||||||
// when remapping
|
// when remapping
|
||||||
const result = remapAgentKeysToDisplayNames(agents)
|
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({
|
expect(result[getAgentDisplayName("sisyphus")]).toEqual({
|
||||||
name: getAgentDisplayName("sisyphus"),
|
name: getAgentRuntimeName("sisyphus"),
|
||||||
prompt: "test",
|
prompt: "test",
|
||||||
mode: "primary",
|
mode: "primary",
|
||||||
})
|
})
|
||||||
expect(result[getAgentDisplayName("hephaestus")]).toEqual({
|
expect(result[getAgentDisplayName("hephaestus")]).toEqual({
|
||||||
name: getAgentDisplayName("hephaestus"),
|
name: getAgentRuntimeName("hephaestus"),
|
||||||
prompt: "test",
|
prompt: "test",
|
||||||
mode: "primary",
|
mode: "primary",
|
||||||
})
|
})
|
||||||
expect(result[getAgentDisplayName("prometheus")]).toEqual({
|
expect(result[getAgentDisplayName("prometheus")]).toEqual({
|
||||||
name: getAgentDisplayName("prometheus"),
|
name: getAgentRuntimeName("prometheus"),
|
||||||
prompt: "test",
|
prompt: "test",
|
||||||
mode: "all",
|
mode: "all",
|
||||||
})
|
})
|
||||||
expect(result[getAgentDisplayName("atlas")]).toEqual({
|
expect(result[getAgentDisplayName("atlas")]).toEqual({
|
||||||
name: getAgentDisplayName("atlas"),
|
name: getAgentRuntimeName("atlas"),
|
||||||
prompt: "test",
|
prompt: "test",
|
||||||
mode: "primary",
|
mode: "primary",
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getAgentDisplayName } from "../shared/agent-display-names"
|
import { getAgentDisplayName, getAgentRuntimeName } from "../shared/agent-display-names"
|
||||||
|
|
||||||
function rewriteAgentNameForListDisplay(
|
function rewriteAgentNameForListDisplay(
|
||||||
key: string,
|
key: string,
|
||||||
@@ -11,7 +11,7 @@ function rewriteAgentNameForListDisplay(
|
|||||||
const agent = value as Record<string, unknown>
|
const agent = value as Record<string, unknown>
|
||||||
return {
|
return {
|
||||||
...agent,
|
...agent,
|
||||||
name: getAgentDisplayName(key),
|
name: getAgentRuntimeName(key),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -355,19 +355,19 @@ describe("Plan agent demote behavior", () => {
|
|||||||
expect(emittedCoreEntries).toEqual([
|
expect(emittedCoreEntries).toEqual([
|
||||||
[
|
[
|
||||||
getAgentDisplayName("sisyphus"),
|
getAgentDisplayName("sisyphus"),
|
||||||
expect.objectContaining({ name: getAgentDisplayName("sisyphus") }),
|
expect.objectContaining({ name: getAgentRuntimeName("sisyphus") }),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
getAgentDisplayName("hephaestus"),
|
getAgentDisplayName("hephaestus"),
|
||||||
expect.objectContaining({ name: getAgentDisplayName("hephaestus") }),
|
expect.objectContaining({ name: getAgentRuntimeName("hephaestus") }),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
getAgentDisplayName("prometheus"),
|
getAgentDisplayName("prometheus"),
|
||||||
expect.objectContaining({ name: getAgentDisplayName("prometheus") }),
|
expect.objectContaining({ name: getAgentRuntimeName("prometheus") }),
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
getAgentDisplayName("atlas"),
|
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)
|
await handler(config)
|
||||||
|
|
||||||
// then
|
// 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 () => {
|
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)
|
await handler(config)
|
||||||
|
|
||||||
// then
|
// 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 () => {
|
test("canonicalizes configured default_agent key to display name", async () => {
|
||||||
@@ -584,7 +584,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
|
|||||||
await handler(config)
|
await handler(config)
|
||||||
|
|
||||||
// #then
|
// #then
|
||||||
expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
|
expect(config.default_agent).toBe(getAgentRuntimeName("hephaestus"))
|
||||||
})
|
})
|
||||||
|
|
||||||
test("preserves existing display-name default_agent", async () => {
|
test("preserves existing display-name default_agent", async () => {
|
||||||
@@ -632,7 +632,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
|
|||||||
await handler(config)
|
await handler(config)
|
||||||
|
|
||||||
// #then
|
// #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 () => {
|
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)
|
await handler(config)
|
||||||
|
|
||||||
// then
|
// 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 () => {
|
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)
|
await handler(config)
|
||||||
|
|
||||||
// then
|
// 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 () => {
|
test("preserves custom default_agent names while trimming whitespace", async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user