fix(plugin-handlers): remove ZWSP prefixes from API-facing agent paths

This commit is contained in:
YeonGyu-Kim
2026-04-10 18:47:18 +09:00
parent 68c8701d34
commit 9532440cb2
11 changed files with 101 additions and 85 deletions
@@ -9,11 +9,11 @@ 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, getAgentListDisplayName } from "../shared/agent-display-names" import { getAgentDisplayName } 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"
const BUILTIN_SISYPHUS_DISPLAY_NAME = getAgentListDisplayName("sisyphus") const BUILTIN_SISYPHUS_DISPLAY_NAME = getAgentDisplayName("sisyphus")
const BUILTIN_SISYPHUS_JUNIOR_DISPLAY_NAME = getAgentDisplayName("sisyphus-junior") const BUILTIN_SISYPHUS_JUNIOR_DISPLAY_NAME = getAgentDisplayName("sisyphus-junior")
const BUILTIN_MULTIMODAL_LOOKER_DISPLAY_NAME = getAgentDisplayName("multimodal-looker") const BUILTIN_MULTIMODAL_LOOKER_DISPLAY_NAME = getAgentDisplayName("multimodal-looker")
@@ -38,6 +38,11 @@ function createBaseConfig(): Record<string, unknown> {
function createPluginConfig(): OhMyOpenCodeConfig { function createPluginConfig(): OhMyOpenCodeConfig {
return { return {
git_master: {
commit_footer: true,
include_co_authored_by: true,
git_env_prefix: "GIT_MASTER=1",
},
sisyphus_agent: { sisyphus_agent: {
planner_enabled: false, planner_enabled: false,
}, },
+3 -4
View File
@@ -2,8 +2,8 @@ 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 { AGENT_NAME_MAP } from "../shared/migration";
import { getAgentDisplayName } from "../shared/agent-display-names"; import { getAgentDisplayName } from "../shared/agent-display-names";
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 {
discoverConfigSourceSkills, discoverConfigSourceSkills,
@@ -24,7 +24,6 @@ import {
} from "./agent-override-protection"; } from "./agent-override-protection";
import { buildPrometheusAgentConfig } from "./prometheus-agent-config-builder"; import { buildPrometheusAgentConfig } from "./prometheus-agent-config-builder";
import { buildPlanDemoteConfig } from "./plan-model-inheritance"; import { buildPlanDemoteConfig } from "./plan-model-inheritance";
import { getAgentListDisplayName } from "../shared/agent-display-names";
type AgentConfigRecord = Record<string, Record<string, unknown> | undefined> & { type AgentConfigRecord = Record<string, Record<string, unknown> | undefined> & {
build?: Record<string, unknown>; build?: Record<string, unknown>;
@@ -160,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 =
getAgentListDisplayName(configuredDefaultAgent); getAgentDisplayName(configuredDefaultAgent);
} else { } else {
(params.config as { default_agent?: string }).default_agent = (params.config as { default_agent?: string }).default_agent =
getAgentListDisplayName("sisyphus"); getAgentDisplayName("sisyphus");
} }
// Assembly order: Sisyphus -> Hephaestus -> Prometheus -> Atlas // Assembly order: Sisyphus -> Hephaestus -> Prometheus -> Atlas
+18 -15
View File
@@ -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, getAgentListDisplayName } from "../shared/agent-display-names" import { getAgentDisplayName } 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", () => {
@@ -14,7 +14,7 @@ describe("remapAgentKeysToDisplayNames", () => {
const result = remapAgentKeysToDisplayNames(agents) const result = remapAgentKeysToDisplayNames(agents)
// then known agents get display name keys only // then known agents get display name keys only
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined() expect(result[getAgentDisplayName("sisyphus")]).toBeDefined()
expect(result["oracle"]).toBeDefined() expect(result["oracle"]).toBeDefined()
expect(result["sisyphus"]).toBeUndefined() expect(result["sisyphus"]).toBeUndefined()
}) })
@@ -49,13 +49,13 @@ describe("remapAgentKeysToDisplayNames", () => {
const result = remapAgentKeysToDisplayNames(agents) const result = remapAgentKeysToDisplayNames(agents)
// then all get display name keys // then all get display name keys
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined() expect(result[getAgentDisplayName("sisyphus")]).toBeDefined()
expect(result["sisyphus"]).toBeUndefined() expect(result["sisyphus"]).toBeUndefined()
expect(result[getAgentListDisplayName("hephaestus")]).toBeDefined() expect(result[getAgentDisplayName("hephaestus")]).toBeDefined()
expect(result["hephaestus"]).toBeUndefined() expect(result["hephaestus"]).toBeUndefined()
expect(result[getAgentListDisplayName("prometheus")]).toBeDefined() expect(result[getAgentDisplayName("prometheus")]).toBeDefined()
expect(result["prometheus"]).toBeUndefined() expect(result["prometheus"]).toBeUndefined()
expect(result[getAgentListDisplayName("atlas")]).toBeDefined() expect(result[getAgentDisplayName("atlas")]).toBeDefined()
expect(result["atlas"]).toBeUndefined() expect(result["atlas"]).toBeUndefined()
expect(result[getAgentDisplayName("athena")]).toBeDefined() expect(result[getAgentDisplayName("athena")]).toBeDefined()
expect(result["athena"]).toBeUndefined() expect(result["athena"]).toBeUndefined()
@@ -77,12 +77,12 @@ describe("remapAgentKeysToDisplayNames", () => {
const result = remapAgentKeysToDisplayNames(agents) const result = remapAgentKeysToDisplayNames(agents)
// then only display key is emitted // then only display key is emitted
expect(Object.keys(result)).toEqual([getAgentListDisplayName("sisyphus")]) expect(Object.keys(result)).toEqual([getAgentDisplayName("sisyphus")])
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined() expect(result[getAgentDisplayName("sisyphus")]).toBeDefined()
expect(result["sisyphus"]).toBeUndefined() expect(result["sisyphus"]).toBeUndefined()
}) })
it("keeps the four core agents in canonical order under opencode name sorting", () => { it("returns clean core agent display names without ZWSP prefixes", () => {
// given // given
const result = remapAgentKeysToDisplayNames({ const result = remapAgentKeysToDisplayNames({
atlas: {}, atlas: {},
@@ -92,14 +92,17 @@ describe("remapAgentKeysToDisplayNames", () => {
}) })
// when // when
const sortedNames = Object.keys(result).sort() const remappedNames = Object.keys(result)
// then // then
expect(sortedNames).toEqual([ expect(remappedNames).toEqual([
getAgentListDisplayName("sisyphus"), getAgentDisplayName("atlas"),
getAgentListDisplayName("hephaestus"), getAgentDisplayName("prometheus"),
getAgentListDisplayName("prometheus"), getAgentDisplayName("hephaestus"),
getAgentListDisplayName("atlas"), getAgentDisplayName("sisyphus"),
]) ])
for (const name of remappedNames) {
expect(name).not.toContain("\u200B")
}
}) })
}) })
+2 -2
View File
@@ -1,4 +1,4 @@
import { getAgentListDisplayName } from "../shared/agent-display-names" import { getAgentDisplayName } from "../shared/agent-display-names"
export function remapAgentKeysToDisplayNames( export function remapAgentKeysToDisplayNames(
agents: Record<string, unknown>, agents: Record<string, unknown>,
@@ -6,7 +6,7 @@ export function remapAgentKeysToDisplayNames(
const result: Record<string, unknown> = {} const result: Record<string, unknown> = {}
for (const [key, value] of Object.entries(agents)) { for (const [key, value] of Object.entries(agents)) {
const displayName = getAgentListDisplayName(key) const displayName = getAgentDisplayName(key)
if (displayName && displayName !== key) { if (displayName && displayName !== key) {
result[displayName] = value result[displayName] = value
// Regression guard: do not also assign result[key]. // Regression guard: do not also assign result[key].
@@ -1,15 +1,17 @@
/// <reference types="bun-types" />
import { describe, expect, test } from "bun:test" import { describe, expect, test } from "bun:test"
import { reorderAgentsByPriority } from "./agent-priority-order" import { reorderAgentsByPriority } from "./agent-priority-order"
import { getAgentDisplayName, getAgentListDisplayName } from "../shared/agent-display-names" import { getAgentDisplayName } from "../shared/agent-display-names"
describe("reorderAgentsByPriority", () => { describe("reorderAgentsByPriority", () => {
test("moves core agents to canonical order and injects runtime order fields", () => { test("moves core agents to canonical order and injects runtime order fields", () => {
// given // given
const sisyphus = getAgentListDisplayName("sisyphus") const sisyphus = getAgentDisplayName("sisyphus")
const hephaestus = getAgentListDisplayName("hephaestus") const hephaestus = getAgentDisplayName("hephaestus")
const prometheus = getAgentListDisplayName("prometheus") const prometheus = getAgentDisplayName("prometheus")
const atlas = getAgentListDisplayName("atlas") const atlas = getAgentDisplayName("atlas")
const oracle = getAgentDisplayName("oracle") const oracle = getAgentDisplayName("oracle")
const agents: Record<string, unknown> = { const agents: Record<string, unknown> = {
@@ -59,8 +61,8 @@ describe("reorderAgentsByPriority", () => {
test("leaves non-object agent configs untouched while still reordering keys", () => { test("leaves non-object agent configs untouched while still reordering keys", () => {
// given // given
const sisyphus = getAgentListDisplayName("sisyphus") const sisyphus = getAgentDisplayName("sisyphus")
const atlas = getAgentListDisplayName("atlas") const atlas = getAgentDisplayName("atlas")
const agents: Record<string, unknown> = { const agents: Record<string, unknown> = {
[atlas]: "atlas-config", [atlas]: "atlas-config",
+5 -5
View File
@@ -1,10 +1,10 @@
import { getAgentListDisplayName } from "../shared/agent-display-names"; import { getAgentDisplayName } from "../shared/agent-display-names";
const CORE_AGENT_ORDER: ReadonlyArray<{ displayName: string; order: number }> = [ const CORE_AGENT_ORDER: ReadonlyArray<{ displayName: string; order: number }> = [
{ displayName: getAgentListDisplayName("sisyphus"), order: 1 }, { displayName: getAgentDisplayName("sisyphus"), order: 1 },
{ displayName: getAgentListDisplayName("hephaestus"), order: 2 }, { displayName: getAgentDisplayName("hephaestus"), order: 2 },
{ displayName: getAgentListDisplayName("prometheus"), order: 3 }, { displayName: getAgentDisplayName("prometheus"), order: 3 },
{ displayName: getAgentListDisplayName("atlas"), order: 4 }, { displayName: getAgentDisplayName("atlas"), order: 4 },
]; ];
function injectOrderField( function injectOrderField(
@@ -1,3 +1,5 @@
/// <reference types="bun-types" />
import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test"; import { afterEach, beforeEach, describe, expect, spyOn, test } from "bun:test";
import * as builtinCommands from "../features/builtin-commands"; import * as builtinCommands from "../features/builtin-commands";
import * as commandLoader from "../features/claude-code-command-loader"; import * as commandLoader from "../features/claude-code-command-loader";
@@ -7,7 +9,6 @@ import type { PluginComponents } from "./plugin-components-loader";
import { applyCommandConfig } from "./command-config-handler"; import { applyCommandConfig } from "./command-config-handler";
import { import {
getAgentDisplayName, getAgentDisplayName,
getAgentListDisplayName,
} from "../shared/agent-display-names"; } from "../shared/agent-display-names";
function createPluginComponents(): PluginComponents { function createPluginComponents(): PluginComponents {
@@ -23,7 +24,13 @@ function createPluginComponents(): PluginComponents {
} }
function createPluginConfig(): OhMyOpenCodeConfig { function createPluginConfig(): OhMyOpenCodeConfig {
return {}; return {
git_master: {
commit_footer: true,
include_co_authored_by: true,
git_env_prefix: "GIT_MASTER=1",
},
};
} }
describe("applyCommandConfig", () => { describe("applyCommandConfig", () => {
@@ -100,7 +107,7 @@ describe("applyCommandConfig", () => {
expect(commandConfig["agents-global-skill"]?.description).toContain("Agents global skill"); expect(commandConfig["agents-global-skill"]?.description).toContain("Agents global skill");
}); });
test("normalizes Atlas command agents to the exported list key used by opencode command routing", async () => { test("normalizes Atlas command agents to the clean display name used by opencode command routing", async () => {
// given // given
loadBuiltinCommandsSpy.mockReturnValue({ loadBuiltinCommandsSpy.mockReturnValue({
"start-work": { "start-work": {
@@ -122,10 +129,10 @@ describe("applyCommandConfig", () => {
// then // then
const commandConfig = config.command as Record<string, { agent?: string }>; const commandConfig = config.command as Record<string, { agent?: string }>;
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas")); expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"));
}); });
test("normalizes legacy display-name command agents to the exported list key", async () => { test("normalizes legacy display-name command agents to the clean display name", async () => {
// given // given
loadBuiltinCommandsSpy.mockReturnValue({ loadBuiltinCommandsSpy.mockReturnValue({
"start-work": { "start-work": {
@@ -147,6 +154,6 @@ describe("applyCommandConfig", () => {
// then // then
const commandConfig = config.command as Record<string, { agent?: string }>; const commandConfig = config.command as Record<string, { agent?: string }>;
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas")); expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"));
}); });
}); });
@@ -1,7 +1,7 @@
import type { OhMyOpenCodeConfig } from "../config"; import type { OhMyOpenCodeConfig } from "../config";
import { import {
getAgentConfigKey, getAgentConfigKey,
getAgentListDisplayName, getAgentDisplayName,
} from "../shared/agent-display-names"; } from "../shared/agent-display-names";
import { import {
loadUserCommands, loadUserCommands,
@@ -99,7 +99,7 @@ export async function applyCommandConfig(params: {
function remapCommandAgentFields(commands: Record<string, Record<string, unknown>>): void { function remapCommandAgentFields(commands: Record<string, Record<string, unknown>>): void {
for (const cmd of Object.values(commands)) { for (const cmd of Object.values(commands)) {
if (cmd?.agent && typeof cmd.agent === "string") { if (cmd?.agent && typeof cmd.agent === "string") {
cmd.agent = getAgentListDisplayName(getAgentConfigKey(cmd.agent)); cmd.agent = getAgentDisplayName(getAgentConfigKey(cmd.agent));
} }
} }
} }
+36 -36
View File
@@ -3,7 +3,7 @@
import { describe, test, expect, spyOn, beforeEach, afterEach, mock } from "bun:test" import { describe, test, expect, spyOn, beforeEach, afterEach, mock } from "bun:test"
import type { CategoryConfig } from "../config/schema" import type { CategoryConfig } from "../config/schema"
import type { OhMyOpenCodeConfig } from "../config" import type { OhMyOpenCodeConfig } from "../config"
import { getAgentDisplayName, getAgentListDisplayName } from "../shared/agent-display-names" import { getAgentDisplayName } from "../shared/agent-display-names"
import { resolveCategoryConfig } from "./category-config-resolver" import { resolveCategoryConfig } from "./category-config-resolver"
import * as agents from "../agents" import * as agents from "../agents"
@@ -260,10 +260,10 @@ describe("Plan agent demote behavior", () => {
// #then // #then
const keys = Object.keys(config.agent as Record<string, unknown>) const keys = Object.keys(config.agent as Record<string, unknown>)
const coreAgents = [ const coreAgents = [
getAgentListDisplayName("sisyphus"), getAgentDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"), getAgentDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"), getAgentDisplayName("prometheus"),
getAgentListDisplayName("atlas"), getAgentDisplayName("atlas"),
] ]
const ordered = keys.filter((key) => coreAgents.includes(key)) const ordered = keys.filter((key) => coreAgents.includes(key))
expect(ordered).toEqual(coreAgents) expect(ordered).toEqual(coreAgents)
@@ -308,10 +308,10 @@ describe("Plan agent demote behavior", () => {
reorderSpy.mock.calls.at(0)?.[0] as Record<string, unknown> reorderSpy.mock.calls.at(0)?.[0] as Record<string, unknown>
) )
expect(assembledAgentKeys.slice(0, 4)).toEqual([ expect(assembledAgentKeys.slice(0, 4)).toEqual([
getAgentListDisplayName("sisyphus"), getAgentDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"), getAgentDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"), getAgentDisplayName("prometheus"),
getAgentListDisplayName("atlas"), getAgentDisplayName("atlas"),
]) ])
}) })
@@ -350,7 +350,7 @@ describe("Plan agent demote behavior", () => {
expect(agents.plan).toBeDefined() expect(agents.plan).toBeDefined()
expect(agents.plan.mode).toBe("subagent") expect(agents.plan.mode).toBe("subagent")
expect(agents.plan.prompt).toBeUndefined() expect(agents.plan.prompt).toBeUndefined()
expect(agents[getAgentListDisplayName("prometheus")]?.prompt).toBeDefined() expect(agents[getAgentDisplayName("prometheus")]?.prompt).toBeDefined()
}) })
test("plan agent remains unchanged when planner is disabled", async () => { test("plan agent remains unchanged when planner is disabled", async () => {
@@ -384,7 +384,7 @@ describe("Plan agent demote behavior", () => {
// #then - plan is not touched, prometheus is not created // #then - plan is not touched, prometheus is not created
const agents = config.agent as Record<string, { mode?: string; name?: string; prompt?: string }> const agents = config.agent as Record<string, { mode?: string; name?: string; prompt?: string }>
expect(agents[getAgentListDisplayName("prometheus")]).toBeUndefined() expect(agents[getAgentDisplayName("prometheus")]).toBeUndefined()
expect(agents.plan).toBeDefined() expect(agents.plan).toBeDefined()
expect(agents.plan.mode).toBe("primary") expect(agents.plan.mode).toBe("primary")
expect(agents.plan.prompt).toBe("original plan prompt") expect(agents.plan.prompt).toBe("original plan prompt")
@@ -415,7 +415,7 @@ describe("Plan agent demote behavior", () => {
// then // then
const agents = config.agent as Record<string, { mode?: string }> const agents = config.agent as Record<string, { mode?: string }>
const prometheusKey = getAgentListDisplayName("prometheus") const prometheusKey = getAgentDisplayName("prometheus")
expect(agents[prometheusKey]).toBeDefined() expect(agents[prometheusKey]).toBeDefined()
expect(agents[prometheusKey].mode).toBe("all") expect(agents[prometheusKey].mode).toBe("all")
}) })
@@ -451,7 +451,7 @@ describe("Agent permission defaults", () => {
// #then // #then
const agentConfig = config.agent as Record<string, { permission?: Record<string, string> }> const agentConfig = config.agent as Record<string, { permission?: Record<string, string> }>
const hephaestusKey = getAgentListDisplayName("hephaestus") const hephaestusKey = getAgentDisplayName("hephaestus")
expect(agentConfig[hephaestusKey]).toBeDefined() expect(agentConfig[hephaestusKey]).toBeDefined()
expect(agentConfig[hephaestusKey].permission?.task).toBe("allow") expect(agentConfig[hephaestusKey].permission?.task).toBe("allow")
}) })
@@ -479,7 +479,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// then // then
expect(config.default_agent).toBe(getAgentListDisplayName("hephaestus")) expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
}) })
test("canonicalizes configured default_agent when key uses mixed case", async () => { test("canonicalizes configured default_agent when key uses mixed case", async () => {
@@ -503,7 +503,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// then // then
expect(config.default_agent).toBe(getAgentListDisplayName("hephaestus")) expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
}) })
test("canonicalizes configured default_agent key to display name", async () => { test("canonicalizes configured default_agent key to display name", async () => {
@@ -527,13 +527,13 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// #then // #then
expect(config.default_agent).toBe(getAgentListDisplayName("hephaestus")) expect(config.default_agent).toBe(getAgentDisplayName("hephaestus"))
}) })
test("preserves existing display-name default_agent", async () => { test("preserves existing display-name default_agent", async () => {
// #given // #given
const pluginConfig = createPluginConfig({}) const pluginConfig = createPluginConfig({})
const displayName = getAgentListDisplayName("hephaestus") const displayName = getAgentDisplayName("hephaestus")
const config: Record<string, unknown> = { const config: Record<string, unknown> = {
model: "anthropic/claude-opus-4-6", model: "anthropic/claude-opus-4-6",
default_agent: displayName, default_agent: displayName,
@@ -575,7 +575,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// #then // #then
expect(config.default_agent).toBe(getAgentListDisplayName("sisyphus")) expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
}) })
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 () => {
@@ -599,7 +599,7 @@ describe("default_agent behavior with Sisyphus orchestration", () => {
await handler(config) await handler(config)
// then // then
expect(config.default_agent).toBe(getAgentListDisplayName("sisyphus")) expect(config.default_agent).toBe(getAgentDisplayName("sisyphus"))
}) })
test("preserves custom default_agent names while trimming whitespace", async () => { test("preserves custom default_agent names while trimming whitespace", async () => {
@@ -793,7 +793,7 @@ describe("Prometheus direct override priority over category", () => {
// then - direct override's reasoningEffort wins // then - direct override's reasoningEffort wins
const agents = config.agent as Record<string, { reasoningEffort?: string }> const agents = config.agent as Record<string, { reasoningEffort?: string }>
const pKey = getAgentListDisplayName("prometheus") const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined() expect(agents[pKey]).toBeDefined()
expect(agents[pKey].reasoningEffort).toBe("low") expect(agents[pKey].reasoningEffort).toBe("low")
}) })
@@ -834,7 +834,7 @@ describe("Prometheus direct override priority over category", () => {
// then - category's reasoningEffort is applied // then - category's reasoningEffort is applied
const agents = config.agent as Record<string, { reasoningEffort?: string }> const agents = config.agent as Record<string, { reasoningEffort?: string }>
const pKey = getAgentListDisplayName("prometheus") const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined() expect(agents[pKey]).toBeDefined()
expect(agents[pKey].reasoningEffort).toBe("high") expect(agents[pKey].reasoningEffort).toBe("high")
}) })
@@ -876,7 +876,7 @@ describe("Prometheus direct override priority over category", () => {
// then - direct temperature wins over category // then - direct temperature wins over category
const agents = config.agent as Record<string, { temperature?: number }> const agents = config.agent as Record<string, { temperature?: number }>
const pKey = getAgentListDisplayName("prometheus") const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined() expect(agents[pKey]).toBeDefined()
expect(agents[pKey].temperature).toBe(0.1) expect(agents[pKey].temperature).toBe(0.1)
}) })
@@ -912,7 +912,7 @@ describe("Prometheus direct override priority over category", () => {
// #then - prompt_append is appended to base prompt, not overwriting it // #then - prompt_append is appended to base prompt, not overwriting it
const agents = config.agent as Record<string, { prompt?: string }> const agents = config.agent as Record<string, { prompt?: string }>
const pKey = getAgentListDisplayName("prometheus") const pKey = getAgentDisplayName("prometheus")
expect(agents[pKey]).toBeDefined() expect(agents[pKey]).toBeDefined()
expect(agents[pKey].prompt).toContain("Prometheus") expect(agents[pKey].prompt).toContain("Prometheus")
expect(agents[pKey].prompt).toContain(customInstructions) expect(agents[pKey].prompt).toContain(customInstructions)
@@ -1137,7 +1137,7 @@ describe("Deadlock prevention - fetchAvailableModels must not receive client", (
// then - regression guard: handler completes and still assembles planner config // then - regression guard: handler completes and still assembles planner config
const agentConfig = config.agent as Record<string, unknown> const agentConfig = config.agent as Record<string, unknown>
expect(agentConfig[getAgentListDisplayName("prometheus")]).toBeDefined() expect(agentConfig[getAgentDisplayName("prometheus")]).toBeDefined()
}) })
}) })
@@ -1303,17 +1303,17 @@ describe("command agent routing coherence", () => {
//#then //#then
const agentConfig = config.agent as Record<string, unknown> const agentConfig = config.agent as Record<string, unknown>
const commandConfig = config.command as Record<string, { agent?: string }> const commandConfig = config.command as Record<string, { agent?: string }>
expect(Object.keys(agentConfig)).toContain(getAgentListDisplayName("atlas")) expect(Object.keys(agentConfig)).toContain(getAgentDisplayName("atlas"))
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas")) expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"))
}) })
}) })
describe("per-agent todowrite/todoread deny when task_system enabled", () => { describe("per-agent todowrite/todoread deny when task_system enabled", () => {
const AGENTS_WITH_TODO_DENY = new Set([ const AGENTS_WITH_TODO_DENY = new Set([
getAgentListDisplayName("sisyphus"), getAgentDisplayName("sisyphus"),
getAgentListDisplayName("hephaestus"), getAgentDisplayName("hephaestus"),
getAgentListDisplayName("prometheus"), getAgentDisplayName("prometheus"),
getAgentListDisplayName("atlas"), getAgentDisplayName("atlas"),
getAgentDisplayName("sisyphus-junior"), getAgentDisplayName("sisyphus-junior"),
]) ])
@@ -1394,10 +1394,10 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
expect(lastCall?.[11]).toBe(false) expect(lastCall?.[11]).toBe(false)
const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }> const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }>
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined() expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined() expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
expect(agentResult[getAgentListDisplayName("hephaestus")]?.permission?.todowrite).toBeUndefined() expect(agentResult[getAgentDisplayName("hephaestus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("hephaestus")]?.permission?.todoread).toBeUndefined() expect(agentResult[getAgentDisplayName("hephaestus")]?.permission?.todoread).toBeUndefined()
}) })
test("does not deny todowrite/todoread when task_system is undefined", async () => { test("does not deny todowrite/todoread when task_system is undefined", async () => {
@@ -1433,8 +1433,8 @@ describe("per-agent todowrite/todoread deny when task_system enabled", () => {
expect(lastCall?.[11]).toBe(false) expect(lastCall?.[11]).toBe(false)
const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }> const agentResult = config.agent as Record<string, { permission?: Record<string, unknown> }>
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined() expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined() expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
}) })
}) })
@@ -1,7 +1,7 @@
import { describe, it, expect, beforeEach, afterEach } from "bun:test" import { describe, it, expect, beforeEach, afterEach } from "bun:test"
import { applyToolConfig } from "./tool-config-handler" import { applyToolConfig } from "./tool-config-handler"
import type { OhMyOpenCodeConfig } from "../config" import type { OhMyOpenCodeConfig } from "../config"
import { getAgentListDisplayName } from "../shared/agent-display-names" import { getAgentDisplayName } from "../shared/agent-display-names"
function createParams(overrides: { function createParams(overrides: {
taskSystem?: boolean taskSystem?: boolean
@@ -251,9 +251,9 @@ describe("applyToolConfig", () => {
}) })
}) })
describe("#given agentResult uses exported list display keys", () => { describe("#given agentResult uses clean display keys", () => {
it("#then should still resolve atlas permissions through the prefixed key", () => { it("#then should still resolve atlas permissions through the display key", () => {
const atlasKey = getAgentListDisplayName("atlas") const atlasKey = getAgentDisplayName("atlas")
const params = createParams({ agents: [atlasKey] }) const params = createParams({ agents: [atlasKey] })
applyToolConfig(params) applyToolConfig(params)
+2 -2
View File
@@ -1,5 +1,5 @@
import type { OhMyOpenCodeConfig } from "../config"; import type { OhMyOpenCodeConfig } from "../config";
import { getAgentDisplayName, getAgentListDisplayName } from "../shared/agent-display-names"; import { getAgentDisplayName } from "../shared/agent-display-names";
import { isTaskSystemEnabled } from "../shared"; import { isTaskSystemEnabled } from "../shared";
type AgentWithPermission = { permission?: Record<string, unknown> }; type AgentWithPermission = { permission?: Record<string, unknown> };
@@ -16,7 +16,7 @@ function getConfigQuestionPermission(): string | null {
} }
function agentByKey(agentResult: Record<string, unknown>, key: string): AgentWithPermission | undefined { function agentByKey(agentResult: Record<string, unknown>, key: string): AgentWithPermission | undefined {
return (agentResult[getAgentListDisplayName(key)] ?? agentResult[getAgentDisplayName(key)] ?? agentResult[key]) as return (agentResult[getAgentDisplayName(key)] ?? agentResult[key]) as
| AgentWithPermission | AgentWithPermission
| undefined; | undefined;
} }