Skip to content

Commit 9e71117

Browse files
committed
fix(review): address owner review feedback on PR #1728
1 parent 20fc8d9 commit 9e71117

File tree

10 files changed

+64
-37
lines changed

10 files changed

+64
-37
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,16 @@ jobs:
4444
env:
4545
BUN_INSTALL_ALLOW_SCRIPTS: "@ast-grep/napi"
4646

47-
- name: Run mock-heavy tests (isolated)
48-
run: |
49-
# These files use mock.module() which pollutes module cache
50-
# Run them in separate processes to prevent cross-file contamination
51-
bun test src/plugin-handlers
52-
bun test src/hooks/atlas
53-
bun test src/hooks/compaction-context-injector
54-
bun test src/features/tmux-subagent
47+
- name: Run mock-heavy tests (isolated)
48+
run: |
49+
# These files use mock.module() which pollutes module cache
50+
# Run them in separate processes to prevent cross-file contamination
51+
bun test src/plugin-handlers
52+
bun test src/hooks/atlas
53+
bun test src/hooks/compaction-context-injector
54+
bun test src/features/tmux-subagent
55+
bun test src/shared/session-utils.test.ts
56+
bun test src/tools/skill/tools.test.ts
5557
5658
- name: Run remaining tests
5759
run: |

src/config/schema/oh-my-opencode-config.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@ export const OhMyOpenCodeConfigSchema = z.object({
3232
disabled_hooks: z.array(HookNameSchema).optional(),
3333
disabled_commands: z.array(BuiltinCommandNameSchema).optional(),
3434
/** Disable specific tools by name (e.g., ["todowrite", "todoread"]) */
35-
disabled_tools: z.array(z.string()).optional(),
36-
agent_display_names: z.record(z.string(), z.string()).optional(),
37-
agents: AgentOverridesSchema.optional(),
35+
disabled_tools: z.array(z.string()).optional(),
36+
/** Map agent canonical names to custom display names (e.g., { "sisyphus": "Builder" }) */
37+
agent_display_names: z.record(z.string(), z.string()).optional(),
38+
agents: AgentOverridesSchema.optional(),
3839
categories: CategoriesConfigSchema.optional(),
3940
claude_code: ClaudeCodeConfigSchema.optional(),
4041
sisyphus_agent: SisyphusAgentConfigSchema.optional(),

src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import { createPluginInterface } from "./plugin-interface"
1010
import { loadPluginConfig } from "./plugin-config"
1111
import { createModelCacheState } from "./plugin-state"
1212
import { createFirstMessageVariantGate } from "./shared/first-message-variant"
13-
import { initializeAgentDisplayNames } from "./shared/agent-display-names"
1413
import { injectServerAuthIntoClient, log } from "./shared"
1514
import { startTmuxCheck } from "./tools"
1615

@@ -24,10 +23,6 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
2423

2524
const pluginConfig = loadPluginConfig(ctx.directory, ctx)
2625

27-
if (pluginConfig.agent_display_names) {
28-
initializeAgentDisplayNames(pluginConfig.agent_display_names)
29-
}
30-
3126
const disabledHooks = new Set(pluginConfig.disabled_hooks ?? [])
3227

3328
const isHookEnabled = (hookName: HookName): boolean => !disabledHooks.has(hookName)

src/plugin-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function mergeConfigs(
5454
return {
5555
...base,
5656
...override,
57-
agent_display_names: deepMerge(base.agent_display_names ?? {}, override.agent_display_names ?? {}),
57+
agent_display_names: { ...(base.agent_display_names ?? {}), ...(override.agent_display_names ?? {}) },
5858
agents: deepMerge(base.agents, override.agents),
5959
categories: deepMerge(base.categories, override.categories),
6060
disabled_agents: [

src/plugin-handlers/agent-display-name-rekeyer.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
import { describe, test, expect, spyOn, beforeEach, afterEach } from "bun:test"
44
import { rekeyAgentsByDisplayNames } from "./agent-display-name-rekeyer"
55
import * as aliasModule from "../shared/agent-name-aliases"
6+
import * as displayNamesModule from "../shared/agent-display-names"
67
import * as shared from "../shared"
78

89
beforeEach(() => {
910
aliasModule.resetAgentNameAliases()
11+
displayNamesModule.resetAgentDisplayNames()
1012
spyOn(shared, "log" as any).mockImplementation(() => {})
1113
})
1214

1315
afterEach(() => {
1416
aliasModule.resetAgentNameAliases()
17+
displayNamesModule.resetAgentDisplayNames()
1518
;(shared.log as any)?.mockRestore?.()
1619
})
1720

src/plugin-handlers/agent-display-name-rekeyer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { log } from "../shared"
2+
import { initializeAgentDisplayNames } from "../shared/agent-display-names"
23
import {
34
initializeAgentNameAliases,
45
getCanonicalToRegisteredMap,
@@ -13,6 +14,8 @@ export function rekeyAgentsByDisplayNames(params: {
1314

1415
if (!displayNames || Object.keys(displayNames).length === 0) return
1516

17+
initializeAgentDisplayNames(displayNames)
18+
1619
const { warnings } = initializeAgentNameAliases(
1720
displayNames,
1821
Object.keys(agentResult),

src/shared/agent-config-integration.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, test, expect, afterEach } from "bun:test"
1+
import { describe, test, expect, afterEach, beforeEach } from "bun:test"
22
import { migrateAgentNames } from "./migration"
33
import { getAgentDisplayName, initializeAgentDisplayNames, resetAgentDisplayNames } from "./agent-display-names"
44
import { AGENT_MODEL_REQUIREMENTS } from "./model-requirements"
@@ -84,6 +84,10 @@ describe("Agent Config Integration", () => {
8484
})
8585

8686
describe("Display name resolution", () => {
87+
beforeEach(() => {
88+
resetAgentDisplayNames()
89+
})
90+
8791
test("returns correct display names for all builtin agents", () => {
8892
// given - lowercase config keys
8993
const agents = ["sisyphus", "atlas", "prometheus", "metis", "momus", "oracle", "librarian", "explore", "multimodal-looker"]
@@ -169,6 +173,10 @@ describe("Agent Config Integration", () => {
169173
})
170174

171175
describe("End-to-end config flow", () => {
176+
beforeEach(() => {
177+
resetAgentDisplayNames()
178+
})
179+
172180
test("old config migrates and displays correctly", () => {
173181
// given - old format config
174182
const oldConfig = {

src/shared/agent-display-names.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ describe("config-aware display names", () => {
217217
expect(result).toBe("Sisyphus (Ultraworker)")
218218
})
219219

220-
it("clears overrides after reset", () => {
221-
// given override
222-
initializeAgentDisplayNames({ sisyphus: "Builder" })
220+
it("clears overrides after reset", () => {
221+
// given override
222+
initializeAgentDisplayNames({ sisyphus: "Builder" })
223223

224-
// when resetAgentDisplayNames called
225-
resetAgentDisplayNames()
224+
// when resetAgentDisplayNames called
225+
resetAgentDisplayNames()
226226

227-
// then getAgentDisplayName returns default
228-
const result = getAgentDisplayName("sisyphus")
229-
expect(result).toBe("Sisyphus (Ultraworker)")
230-
})
231-
})
227+
// then getAgentDisplayName returns default
228+
const result = getAgentDisplayName("sisyphus")
229+
expect(result).toBe("Sisyphus (Ultraworker)")
230+
})
231+
})

src/shared/agent-display-names.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/**
2+
* Agent config keys to display names mapping.
3+
* Config keys are lowercase (e.g., "sisyphus", "atlas").
4+
* Display names include suffixes for UI/logs (e.g., "Sisyphus (Ultraworker)").
5+
*/
16
export const AGENT_DISPLAY_NAMES: Record<string, string> = {
27
sisyphus: "Sisyphus (Ultraworker)",
38
atlas: "Atlas (Plan Execution Orchestrator)",
@@ -13,14 +18,28 @@ export const AGENT_DISPLAY_NAMES: Record<string, string> = {
1318

1419
let userOverrides: Record<string, string> = {}
1520

21+
/**
22+
* Initialize agent display name overrides from configuration.
23+
* @param overrides - Map of agent config keys to custom display names
24+
*/
1625
export function initializeAgentDisplayNames(overrides: Record<string, string>): void {
1726
userOverrides = overrides
1827
}
1928

29+
/**
30+
* Reset agent display name overrides to empty state.
31+
*/
2032
export function resetAgentDisplayNames(): void {
2133
userOverrides = {}
2234
}
2335

36+
/**
37+
* Get display name for an agent config key.
38+
* Uses case-insensitive lookup for backward compatibility.
39+
* Returns original key if not found.
40+
* @param configKey - Agent config key (e.g., "sisyphus", "atlas")
41+
* @returns Display name with UI/log suffix, or original key if not found
42+
*/
2443
export function getAgentDisplayName(configKey: string): string {
2544
const lowerKey = configKey.toLowerCase()
2645

src/tools/call-omo-agent/tools.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,12 @@ export function createCallOmoAgent(
3333
log(`[call_omo_agent] Starting with agent: ${args.subagent_type}, background: ${args.run_in_background}`)
3434

3535
// Case-insensitive agent validation - allows "Explore", "EXPLORE", "explore" etc.
36-
if (
37-
!ALLOWED_AGENTS.some(
38-
(name) => name.toLowerCase() === toCanonical(args.subagent_type).toLowerCase(),
39-
)
40-
) {
41-
return `Error: Invalid agent type "${args.subagent_type}". Only ${ALLOWED_AGENTS.join(", ")} are allowed.`
42-
}
36+
const canonicalAgent = toCanonical(args.subagent_type)
37+
if (!ALLOWED_AGENTS.includes(canonicalAgent as AllowedAgentType)) {
38+
return `Error: Invalid agent type "${args.subagent_type}". Only ${ALLOWED_AGENTS.join(", ")} are allowed.`
39+
}
4340

44-
const normalizedAgent = toCanonical(args.subagent_type).toLowerCase() as AllowedAgentType
45-
args = { ...args, subagent_type: normalizedAgent }
41+
args = { ...args, subagent_type: canonicalAgent as AllowedAgentType }
4642

4743
if (args.run_in_background) {
4844
if (args.session_id) {

0 commit comments

Comments
 (0)