fix(agents): restore canonical core agent ordering
Remap the core agent keys, default agent, and command routing back to\nlist display names so OpenCode's name-based sorting keeps the\ncanonical Sisyphus -> Hephaestus -> Prometheus -> Atlas order.\n\nAlso teach tool config lookups to resolve the prefixed list keys and\nadd regression tests that exercise the real ordering and routing path.
This commit is contained in:
@@ -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, getAgentDisplayName } from "../shared/agent-display-names"
|
import { getAgentDisplayName, getAgentListDisplayName } 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 = getAgentDisplayName("sisyphus")
|
const BUILTIN_SISYPHUS_DISPLAY_NAME = getAgentListDisplayName("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")
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ 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>;
|
||||||
@@ -159,10 +160,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);
|
getAgentListDisplayName(configuredDefaultAgent);
|
||||||
} else {
|
} else {
|
||||||
(params.config as { default_agent?: string }).default_agent =
|
(params.config as { default_agent?: string }).default_agent =
|
||||||
getAgentDisplayName("sisyphus");
|
getAgentListDisplayName("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, getAgentListDisplayName } 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[getAgentDisplayName("sisyphus")]).toBeDefined()
|
expect(result[getAgentListDisplayName("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[getAgentDisplayName("sisyphus")]).toBeDefined()
|
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined()
|
||||||
expect(result["sisyphus"]).toBeUndefined()
|
expect(result["sisyphus"]).toBeUndefined()
|
||||||
expect(result[getAgentDisplayName("hephaestus")]).toBeDefined()
|
expect(result[getAgentListDisplayName("hephaestus")]).toBeDefined()
|
||||||
expect(result["hephaestus"]).toBeUndefined()
|
expect(result["hephaestus"]).toBeUndefined()
|
||||||
expect(result[getAgentDisplayName("prometheus")]).toBeDefined()
|
expect(result[getAgentListDisplayName("prometheus")]).toBeDefined()
|
||||||
expect(result["prometheus"]).toBeUndefined()
|
expect(result["prometheus"]).toBeUndefined()
|
||||||
expect(result[getAgentDisplayName("atlas")]).toBeDefined()
|
expect(result[getAgentListDisplayName("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,8 +77,29 @@ 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([getAgentDisplayName("sisyphus")])
|
expect(Object.keys(result)).toEqual([getAgentListDisplayName("sisyphus")])
|
||||||
expect(result[getAgentDisplayName("sisyphus")]).toBeDefined()
|
expect(result[getAgentListDisplayName("sisyphus")]).toBeDefined()
|
||||||
expect(result["sisyphus"]).toBeUndefined()
|
expect(result["sisyphus"]).toBeUndefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("keeps the four core agents in canonical order under opencode name sorting", () => {
|
||||||
|
// given
|
||||||
|
const result = remapAgentKeysToDisplayNames({
|
||||||
|
atlas: {},
|
||||||
|
prometheus: {},
|
||||||
|
hephaestus: {},
|
||||||
|
sisyphus: {},
|
||||||
|
})
|
||||||
|
|
||||||
|
// when
|
||||||
|
const sortedNames = Object.keys(result).sort()
|
||||||
|
|
||||||
|
// then
|
||||||
|
expect(sortedNames).toEqual([
|
||||||
|
getAgentListDisplayName("sisyphus"),
|
||||||
|
getAgentListDisplayName("hephaestus"),
|
||||||
|
getAgentListDisplayName("prometheus"),
|
||||||
|
getAgentListDisplayName("atlas"),
|
||||||
|
])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getAgentDisplayName } from "../shared/agent-display-names"
|
import { getAgentListDisplayName } 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 = getAgentDisplayName(key)
|
const displayName = getAgentListDisplayName(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,15 @@
|
|||||||
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 } from "../shared/agent-display-names"
|
import { getAgentDisplayName, getAgentListDisplayName } 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 = getAgentDisplayName("sisyphus")
|
const sisyphus = getAgentListDisplayName("sisyphus")
|
||||||
const hephaestus = getAgentDisplayName("hephaestus")
|
const hephaestus = getAgentListDisplayName("hephaestus")
|
||||||
const prometheus = getAgentDisplayName("prometheus")
|
const prometheus = getAgentListDisplayName("prometheus")
|
||||||
const atlas = getAgentDisplayName("atlas")
|
const atlas = getAgentListDisplayName("atlas")
|
||||||
const oracle = getAgentDisplayName("oracle")
|
const oracle = getAgentDisplayName("oracle")
|
||||||
|
|
||||||
const agents: Record<string, unknown> = {
|
const agents: Record<string, unknown> = {
|
||||||
@@ -59,8 +59,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 = getAgentDisplayName("sisyphus")
|
const sisyphus = getAgentListDisplayName("sisyphus")
|
||||||
const atlas = getAgentDisplayName("atlas")
|
const atlas = getAgentListDisplayName("atlas")
|
||||||
|
|
||||||
const agents: Record<string, unknown> = {
|
const agents: Record<string, unknown> = {
|
||||||
[atlas]: "atlas-config",
|
[atlas]: "atlas-config",
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { getAgentDisplayName } from "../shared/agent-display-names";
|
import { getAgentListDisplayName } from "../shared/agent-display-names";
|
||||||
|
|
||||||
const CORE_AGENT_ORDER: ReadonlyArray<{ displayName: string; order: number }> = [
|
const CORE_AGENT_ORDER: ReadonlyArray<{ displayName: string; order: number }> = [
|
||||||
{ displayName: getAgentDisplayName("sisyphus"), order: 1 },
|
{ displayName: getAgentListDisplayName("sisyphus"), order: 1 },
|
||||||
{ displayName: getAgentDisplayName("hephaestus"), order: 2 },
|
{ displayName: getAgentListDisplayName("hephaestus"), order: 2 },
|
||||||
{ displayName: getAgentDisplayName("prometheus"), order: 3 },
|
{ displayName: getAgentListDisplayName("prometheus"), order: 3 },
|
||||||
{ displayName: getAgentDisplayName("atlas"), order: 4 },
|
{ displayName: getAgentListDisplayName("atlas"), order: 4 },
|
||||||
];
|
];
|
||||||
|
|
||||||
function injectOrderField(
|
function injectOrderField(
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import type { PluginComponents } from "./plugin-components-loader";
|
|||||||
import { applyCommandConfig } from "./command-config-handler";
|
import { applyCommandConfig } from "./command-config-handler";
|
||||||
import {
|
import {
|
||||||
getAgentDisplayName,
|
getAgentDisplayName,
|
||||||
getAgentDisplayName,
|
getAgentListDisplayName,
|
||||||
} from "../shared/agent-display-names";
|
} from "../shared/agent-display-names";
|
||||||
|
|
||||||
function createPluginComponents(): PluginComponents {
|
function createPluginComponents(): PluginComponents {
|
||||||
@@ -122,7 +122,7 @@ 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(getAgentDisplayName("atlas"));
|
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas"));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("normalizes legacy display-name command agents to the exported list key", async () => {
|
test("normalizes legacy display-name command agents to the exported list key", async () => {
|
||||||
@@ -147,6 +147,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(getAgentDisplayName("atlas"));
|
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("atlas"));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { OhMyOpenCodeConfig } from "../config";
|
import type { OhMyOpenCodeConfig } from "../config";
|
||||||
import {
|
import {
|
||||||
getAgentConfigKey,
|
getAgentConfigKey,
|
||||||
getAgentDisplayName,
|
getAgentListDisplayName,
|
||||||
} 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 = getAgentDisplayName(getAgentConfigKey(cmd.agent));
|
cmd.agent = getAgentListDisplayName(getAgentConfigKey(cmd.agent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { describe, test, expect, spyOn, beforeEach, afterEach } from "bun:test"
|
|||||||
import { resolveCategoryConfig, createConfigHandler } from "./config-handler"
|
import { resolveCategoryConfig, createConfigHandler } from "./config-handler"
|
||||||
import type { CategoryConfig } from "../config/schema"
|
import type { CategoryConfig } from "../config/schema"
|
||||||
import type { OhMyOpenCodeConfig } from "../config"
|
import type { OhMyOpenCodeConfig } from "../config"
|
||||||
import { getAgentDisplayName, getAgentDisplayName } from "../shared/agent-display-names"
|
import { getAgentDisplayName, getAgentListDisplayName } from "../shared/agent-display-names"
|
||||||
|
|
||||||
import * as agents from "../agents"
|
import * as agents from "../agents"
|
||||||
import * as sisyphusJunior from "../agents/sisyphus-junior"
|
import * as sisyphusJunior from "../agents/sisyphus-junior"
|
||||||
@@ -246,10 +246,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 = [
|
||||||
getAgentDisplayName("sisyphus"),
|
getAgentListDisplayName("sisyphus"),
|
||||||
getAgentDisplayName("hephaestus"),
|
getAgentListDisplayName("hephaestus"),
|
||||||
getAgentDisplayName("prometheus"),
|
getAgentListDisplayName("prometheus"),
|
||||||
getAgentDisplayName("atlas"),
|
getAgentListDisplayName("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)
|
||||||
@@ -294,10 +294,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([
|
||||||
getAgentDisplayName("sisyphus"),
|
getAgentListDisplayName("sisyphus"),
|
||||||
getAgentDisplayName("hephaestus"),
|
getAgentListDisplayName("hephaestus"),
|
||||||
getAgentDisplayName("prometheus"),
|
getAgentListDisplayName("prometheus"),
|
||||||
getAgentDisplayName("atlas"),
|
getAgentListDisplayName("atlas"),
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -336,7 +336,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[getAgentDisplayName("prometheus")]?.prompt).toBeDefined()
|
expect(agents[getAgentListDisplayName("prometheus")]?.prompt).toBeDefined()
|
||||||
})
|
})
|
||||||
|
|
||||||
test("plan agent remains unchanged when planner is disabled", async () => {
|
test("plan agent remains unchanged when planner is disabled", async () => {
|
||||||
@@ -370,7 +370,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[getAgentDisplayName("prometheus")]).toBeUndefined()
|
expect(agents[getAgentListDisplayName("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")
|
||||||
@@ -401,7 +401,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 = getAgentDisplayName("prometheus")
|
const prometheusKey = getAgentListDisplayName("prometheus")
|
||||||
expect(agents[prometheusKey]).toBeDefined()
|
expect(agents[prometheusKey]).toBeDefined()
|
||||||
expect(agents[prometheusKey].mode).toBe("all")
|
expect(agents[prometheusKey].mode).toBe("all")
|
||||||
})
|
})
|
||||||
@@ -437,7 +437,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 = getAgentDisplayName("hephaestus")
|
const hephaestusKey = getAgentListDisplayName("hephaestus")
|
||||||
expect(agentConfig[hephaestusKey]).toBeDefined()
|
expect(agentConfig[hephaestusKey]).toBeDefined()
|
||||||
expect(agentConfig[hephaestusKey].permission?.task).toBe("allow")
|
expect(agentConfig[hephaestusKey].permission?.task).toBe("allow")
|
||||||
})
|
})
|
||||||
@@ -465,7 +465,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(getAgentListDisplayName("hephaestus"))
|
||||||
})
|
})
|
||||||
|
|
||||||
test("canonicalizes configured default_agent when key uses mixed case", async () => {
|
test("canonicalizes configured default_agent when key uses mixed case", async () => {
|
||||||
@@ -489,7 +489,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(getAgentListDisplayName("hephaestus"))
|
||||||
})
|
})
|
||||||
|
|
||||||
test("canonicalizes configured default_agent key to display name", async () => {
|
test("canonicalizes configured default_agent key to display name", async () => {
|
||||||
@@ -513,13 +513,13 @@ 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(getAgentListDisplayName("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 = getAgentDisplayName("hephaestus")
|
const displayName = getAgentListDisplayName("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,
|
||||||
@@ -561,7 +561,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(getAgentListDisplayName("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 () => {
|
||||||
@@ -585,7 +585,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(getAgentListDisplayName("sisyphus"))
|
||||||
})
|
})
|
||||||
|
|
||||||
test("preserves custom default_agent names while trimming whitespace", async () => {
|
test("preserves custom default_agent names while trimming whitespace", async () => {
|
||||||
@@ -779,7 +779,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 = getAgentDisplayName("prometheus")
|
const pKey = getAgentListDisplayName("prometheus")
|
||||||
expect(agents[pKey]).toBeDefined()
|
expect(agents[pKey]).toBeDefined()
|
||||||
expect(agents[pKey].reasoningEffort).toBe("low")
|
expect(agents[pKey].reasoningEffort).toBe("low")
|
||||||
})
|
})
|
||||||
@@ -820,7 +820,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 = getAgentDisplayName("prometheus")
|
const pKey = getAgentListDisplayName("prometheus")
|
||||||
expect(agents[pKey]).toBeDefined()
|
expect(agents[pKey]).toBeDefined()
|
||||||
expect(agents[pKey].reasoningEffort).toBe("high")
|
expect(agents[pKey].reasoningEffort).toBe("high")
|
||||||
})
|
})
|
||||||
@@ -862,7 +862,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 = getAgentDisplayName("prometheus")
|
const pKey = getAgentListDisplayName("prometheus")
|
||||||
expect(agents[pKey]).toBeDefined()
|
expect(agents[pKey]).toBeDefined()
|
||||||
expect(agents[pKey].temperature).toBe(0.1)
|
expect(agents[pKey].temperature).toBe(0.1)
|
||||||
})
|
})
|
||||||
@@ -898,7 +898,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 = getAgentDisplayName("prometheus")
|
const pKey = getAgentListDisplayName("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)
|
||||||
@@ -1290,17 +1290,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(getAgentDisplayName("atlas"))
|
expect(Object.keys(agentConfig)).toContain(getAgentListDisplayName("atlas"))
|
||||||
expect(commandConfig["start-work"]?.agent).toBe(getAgentDisplayName("atlas"))
|
expect(commandConfig["start-work"]?.agent).toBe(getAgentListDisplayName("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([
|
||||||
getAgentDisplayName("sisyphus"),
|
getAgentListDisplayName("sisyphus"),
|
||||||
getAgentDisplayName("hephaestus"),
|
getAgentListDisplayName("hephaestus"),
|
||||||
getAgentDisplayName("prometheus"),
|
getAgentListDisplayName("prometheus"),
|
||||||
getAgentDisplayName("atlas"),
|
getAgentListDisplayName("atlas"),
|
||||||
getAgentDisplayName("sisyphus-junior"),
|
getAgentDisplayName("sisyphus-junior"),
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -1381,10 +1381,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[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
|
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
|
||||||
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
|
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
|
||||||
expect(agentResult[getAgentDisplayName("hephaestus")]?.permission?.todowrite).toBeUndefined()
|
expect(agentResult[getAgentListDisplayName("hephaestus")]?.permission?.todowrite).toBeUndefined()
|
||||||
expect(agentResult[getAgentDisplayName("hephaestus")]?.permission?.todoread).toBeUndefined()
|
expect(agentResult[getAgentListDisplayName("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 () => {
|
||||||
@@ -1420,8 +1420,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[getAgentDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
|
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todowrite).toBeUndefined()
|
||||||
expect(agentResult[getAgentDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
|
expect(agentResult[getAgentListDisplayName("sisyphus")]?.permission?.todoread).toBeUndefined()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +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"
|
||||||
|
|
||||||
function createParams(overrides: {
|
function createParams(overrides: {
|
||||||
taskSystem?: boolean
|
taskSystem?: boolean
|
||||||
@@ -250,6 +251,22 @@ describe("applyToolConfig", () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("#given agentResult uses exported list display keys", () => {
|
||||||
|
it("#then should still resolve atlas permissions through the prefixed key", () => {
|
||||||
|
const atlasKey = getAgentListDisplayName("atlas")
|
||||||
|
const params = createParams({ agents: [atlasKey] })
|
||||||
|
|
||||||
|
applyToolConfig(params)
|
||||||
|
|
||||||
|
const agent = params.agentResult[atlasKey] as {
|
||||||
|
permission: Record<string, unknown>
|
||||||
|
}
|
||||||
|
expect(agent.permission.task).toBe("allow")
|
||||||
|
expect(agent.permission["task_*"]).toBe("allow")
|
||||||
|
expect(agent.permission.teammate).toBe("allow")
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe("#given disabled_tools includes 'question'", () => {
|
describe("#given disabled_tools includes 'question'", () => {
|
||||||
let originalConfigContent: string | undefined
|
let originalConfigContent: string | undefined
|
||||||
let originalCliRunMode: string | undefined
|
let originalCliRunMode: string | undefined
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { OhMyOpenCodeConfig } from "../config";
|
import type { OhMyOpenCodeConfig } from "../config";
|
||||||
import { getAgentDisplayName } from "../shared/agent-display-names";
|
import { getAgentDisplayName, getAgentListDisplayName } 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[getAgentDisplayName(key)] ?? agentResult[key]) as
|
return (agentResult[getAgentListDisplayName(key)] ?? agentResult[getAgentDisplayName(key)] ?? agentResult[key]) as
|
||||||
| AgentWithPermission
|
| AgentWithPermission
|
||||||
| undefined;
|
| undefined;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user