Remap config.agent keys to display names at output boundary

Use display names as config.agent keys so opencode shows proper names in UI
(Tab/@ menu). Key remapping happens after all agents are assembled but before
reordering, via remapAgentKeysToDisplayNames().

- agent-config-handler: set default_agent to display name, add key remapping
- agent-key-remapper: new module to transform lowercase keys to display names
- agent-priority-order: CORE_AGENT_ORDER uses display names
- tool-config-handler: look up agents by config key via agentByKey() helper
This commit is contained in:
YeonGyu-Kim
2026-02-16 20:42:58 +09:00
parent c71a80a86c
commit d94a739203
4 changed files with 63 additions and 28 deletions

View File

@@ -3,6 +3,7 @@ import { createSisyphusJuniorAgentWithOverrides } from "../agents/sisyphus-junio
import type { OhMyOpenCodeConfig } from "../config";
import { log, migrateAgentConfig } from "../shared";
import { AGENT_NAME_MAP } from "../shared/migration";
import { getAgentDisplayName } from "../shared/agent-display-names";
import {
discoverConfigSourceSkills,
discoverOpencodeGlobalSkills,
@@ -13,6 +14,7 @@ import {
import { loadProjectAgents, loadUserAgents } from "../features/claude-code-agent-loader";
import type { PluginComponents } from "./plugin-components-loader";
import { reorderAgentsByPriority } from "./agent-priority-order";
import { remapAgentKeysToDisplayNames } from "./agent-key-remapper";
import { buildPrometheusAgentConfig } from "./prometheus-agent-config-builder";
import { buildPlanDemoteConfig } from "./plan-model-inheritance";
@@ -104,7 +106,7 @@ export async function applyAgentConfig(params: {
const configAgent = params.config.agent as AgentConfigRecord | undefined;
if (isSisyphusEnabled && builtinAgents.sisyphus) {
(params.config as { default_agent?: string }).default_agent = "sisyphus";
(params.config as { default_agent?: string }).default_agent = getAgentDisplayName("sisyphus");
const agentConfig: Record<string, unknown> = {
sisyphus: builtinAgents.sisyphus,
@@ -193,6 +195,9 @@ export async function applyAgentConfig(params: {
}
if (params.config.agent) {
params.config.agent = remapAgentKeysToDisplayNames(
params.config.agent as Record<string, unknown>,
);
params.config.agent = reorderAgentsByPriority(
params.config.agent as Record<string, unknown>,
);

View File

@@ -0,0 +1,18 @@
import { AGENT_DISPLAY_NAMES } from "../shared/agent-display-names"
export function remapAgentKeysToDisplayNames(
agents: Record<string, unknown>,
): Record<string, unknown> {
const result: Record<string, unknown> = {}
for (const [key, value] of Object.entries(agents)) {
const displayName = AGENT_DISPLAY_NAMES[key]
if (displayName && displayName !== key) {
result[displayName] = value
} else {
result[key] = value
}
}
return result
}

View File

@@ -1,4 +1,11 @@
const CORE_AGENT_ORDER = ["sisyphus", "hephaestus", "prometheus", "atlas"] as const;
import { getAgentDisplayName } from "../shared/agent-display-names";
const CORE_AGENT_ORDER = [
getAgentDisplayName("sisyphus"),
getAgentDisplayName("hephaestus"),
getAgentDisplayName("prometheus"),
getAgentDisplayName("atlas"),
] as const;
export function reorderAgentsByPriority(
agents: Record<string, unknown>,

View File

@@ -1,7 +1,12 @@
import type { OhMyOpenCodeConfig } from "../config";
import { getAgentDisplayName } from "../shared/agent-display-names";
type AgentWithPermission = { permission?: Record<string, unknown> };
function agentByKey(agentResult: Record<string, unknown>, key: string): AgentWithPermission | undefined {
return agentResult[getAgentDisplayName(key)] as AgentWithPermission | undefined;
}
export function applyToolConfig(params: {
config: Record<string, unknown>;
pluginConfig: OhMyOpenCodeConfig;
@@ -27,18 +32,18 @@ export function applyToolConfig(params: {
const isCliRunMode = process.env.OPENCODE_CLI_RUN_MODE === "true";
const questionPermission = isCliRunMode ? "deny" : "allow";
if (params.agentResult.librarian) {
const agent = params.agentResult.librarian as AgentWithPermission;
agent.permission = { ...agent.permission, "grep_app_*": "allow" };
const librarian = agentByKey(params.agentResult, "librarian");
if (librarian) {
librarian.permission = { ...librarian.permission, "grep_app_*": "allow" };
}
if (params.agentResult["multimodal-looker"]) {
const agent = params.agentResult["multimodal-looker"] as AgentWithPermission;
agent.permission = { ...agent.permission, task: "deny", look_at: "deny" };
const looker = agentByKey(params.agentResult, "multimodal-looker");
if (looker) {
looker.permission = { ...looker.permission, task: "deny", look_at: "deny" };
}
if (params.agentResult["atlas"]) {
const agent = params.agentResult["atlas"] as AgentWithPermission;
agent.permission = {
...agent.permission,
const atlas = agentByKey(params.agentResult, "atlas");
if (atlas) {
atlas.permission = {
...atlas.permission,
task: "allow",
call_omo_agent: "deny",
"task_*": "allow",
@@ -46,10 +51,10 @@ export function applyToolConfig(params: {
...denyTodoTools,
};
}
if (params.agentResult.sisyphus) {
const agent = params.agentResult.sisyphus as AgentWithPermission;
agent.permission = {
...agent.permission,
const sisyphus = agentByKey(params.agentResult, "sisyphus");
if (sisyphus) {
sisyphus.permission = {
...sisyphus.permission,
call_omo_agent: "deny",
task: "allow",
question: questionPermission,
@@ -58,20 +63,20 @@ export function applyToolConfig(params: {
...denyTodoTools,
};
}
if (params.agentResult.hephaestus) {
const agent = params.agentResult.hephaestus as AgentWithPermission;
agent.permission = {
...agent.permission,
const hephaestus = agentByKey(params.agentResult, "hephaestus");
if (hephaestus) {
hephaestus.permission = {
...hephaestus.permission,
call_omo_agent: "deny",
task: "allow",
question: questionPermission,
...denyTodoTools,
};
}
if (params.agentResult["prometheus"]) {
const agent = params.agentResult["prometheus"] as AgentWithPermission;
agent.permission = {
...agent.permission,
const prometheus = agentByKey(params.agentResult, "prometheus");
if (prometheus) {
prometheus.permission = {
...prometheus.permission,
call_omo_agent: "deny",
task: "allow",
question: questionPermission,
@@ -80,10 +85,10 @@ export function applyToolConfig(params: {
...denyTodoTools,
};
}
if (params.agentResult["sisyphus-junior"]) {
const agent = params.agentResult["sisyphus-junior"] as AgentWithPermission;
agent.permission = {
...agent.permission,
const junior = agentByKey(params.agentResult, "sisyphus-junior");
if (junior) {
junior.permission = {
...junior.permission,
task: "allow",
"task_*": "allow",
teammate: "allow",