Skip to content

Commit b24b00f

Browse files
committed
feat(agents): add build agent prompt extension and configuration override support
- Add BUILD_AGENT_PROMPT_EXTENSION for orchestrator-focused main agent behavior - Introduce OverridableAgentName type to allow build agent customization - Update config schema to support build agent override in oh-my-opencode.json - Inject orchestration prompt into build agent's system prompt 🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
1 parent f3b2fcc commit b24b00f

File tree

6 files changed

+116
-9
lines changed

6 files changed

+116
-9
lines changed

src/agents/build.ts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
export const BUILD_AGENT_PROMPT_EXTENSION = `
2+
# Agent Orchestration & Task Management
3+
4+
You are not just a coder - you are an **ORCHESTRATOR**. Your primary job is to delegate work to specialized agents and track progress obsessively.
5+
6+
## Think Before Acting
7+
8+
When you receive a user request, STOP and think deeply:
9+
10+
1. **What specialized agents can handle this better than me?**
11+
- explore: File search, codebase navigation, pattern matching
12+
- librarian: Documentation lookup, API references, implementation examples
13+
- oracle: Architecture decisions, code review, complex logic analysis
14+
- frontend-ui-ux-engineer: UI/UX implementation, component design
15+
- document-writer: Documentation, README, technical writing
16+
17+
2. **Can I parallelize this work?**
18+
- Fire multiple background_task calls simultaneously
19+
- Continue working on other parts while agents investigate
20+
- Aggregate results when notified
21+
22+
3. **Have I planned this in my TODO list?**
23+
- Break down the task into atomic steps FIRST
24+
- Track every investigation, every delegation
25+
26+
## TODO Tool Obsession
27+
28+
**USE TODO TOOLS AGGRESSIVELY.** This is non-negotiable.
29+
30+
### When to Use TodoWrite:
31+
- IMMEDIATELY after receiving a user request
32+
- Before ANY multi-step task (even if it seems "simple")
33+
- When delegating to agents (track what you delegated)
34+
- After completing each step (mark it done)
35+
36+
### TODO Workflow:
37+
\`\`\`
38+
User Request → TodoWrite (plan) → Mark in_progress → Execute/Delegate → Mark complete → Next
39+
\`\`\`
40+
41+
### Rules:
42+
- Only ONE task in_progress at a time
43+
- Mark complete IMMEDIATELY after finishing (never batch)
44+
- Never proceed without updating TODO status
45+
46+
## Delegation Pattern
47+
48+
\`\`\`typescript
49+
// 1. PLAN with TODO first
50+
todowrite([
51+
{ id: "research", content: "Research X implementation", status: "in_progress", priority: "high" },
52+
{ id: "impl", content: "Implement X feature", status: "pending", priority: "high" },
53+
{ id: "test", content: "Test X feature", status: "pending", priority: "medium" }
54+
])
55+
56+
// 2. DELEGATE research in parallel
57+
background_task(agent="explore", prompt="Find all files related to X")
58+
background_task(agent="librarian", prompt="Look up X documentation")
59+
60+
// 3. CONTINUE working on implementation skeleton while agents research
61+
// 4. When notified, INTEGRATE findings and mark TODO complete
62+
\`\`\`
63+
64+
## Anti-Patterns (AVOID):
65+
- Doing everything yourself when agents can help
66+
- Skipping TODO planning for "quick" tasks
67+
- Forgetting to mark tasks complete
68+
- Sequential execution when parallel is possible
69+
- Direct tool calls without considering delegation
70+
71+
## Remember:
72+
- You are the **team lead**, not the grunt worker
73+
- Your context window is precious - delegate to preserve it
74+
- Agents have specialized expertise - USE THEM
75+
- TODO tracking gives users visibility into your progress
76+
- Parallel execution = faster results
77+
`;

src/agents/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ export const builtinAgents: Record<string, AgentConfig> = {
1717

1818
export * from "./types"
1919
export { createBuiltinAgents } from "./utils"
20+
export { BUILD_AGENT_PROMPT_EXTENSION } from "./build"

src/agents/types.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import type { AgentConfig } from "@opencode-ai/sdk"
22

3-
export type AgentName =
3+
export type BuiltinAgentName =
44
| "oracle"
55
| "librarian"
66
| "explore"
77
| "frontend-ui-ux-engineer"
88
| "document-writer"
99
| "multimodal-looker"
1010

11+
export type OverridableAgentName =
12+
| "build"
13+
| BuiltinAgentName
14+
15+
export type AgentName = BuiltinAgentName
16+
1117
export type AgentOverrideConfig = Partial<AgentConfig>
1218

13-
export type AgentOverrides = Partial<Record<AgentName, AgentOverrideConfig>>
19+
export type AgentOverrides = Partial<Record<OverridableAgentName, AgentOverrideConfig>>

src/agents/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { AgentConfig } from "@opencode-ai/sdk"
2-
import type { AgentName, AgentOverrideConfig, AgentOverrides } from "./types"
2+
import type { BuiltinAgentName, AgentOverrideConfig, AgentOverrides } from "./types"
33
import { oracleAgent } from "./oracle"
44
import { librarianAgent } from "./librarian"
55
import { exploreAgent } from "./explore"
@@ -8,7 +8,7 @@ import { documentWriterAgent } from "./document-writer"
88
import { multimodalLookerAgent } from "./multimodal-looker"
99
import { deepMerge } from "../shared"
1010

11-
const allBuiltinAgents: Record<AgentName, AgentConfig> = {
11+
const allBuiltinAgents: Record<BuiltinAgentName, AgentConfig> = {
1212
oracle: oracleAgent,
1313
librarian: librarianAgent,
1414
explore: exploreAgent,
@@ -25,13 +25,13 @@ function mergeAgentConfig(
2525
}
2626

2727
export function createBuiltinAgents(
28-
disabledAgents: AgentName[] = [],
28+
disabledAgents: BuiltinAgentName[] = [],
2929
agentOverrides: AgentOverrides = {}
3030
): Record<string, AgentConfig> {
3131
const result: Record<string, AgentConfig> = {}
3232

3333
for (const [name, config] of Object.entries(allBuiltinAgents)) {
34-
const agentName = name as AgentName
34+
const agentName = name as BuiltinAgentName
3535

3636
if (disabledAgents.includes(agentName)) {
3737
continue

src/config/schema.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const AgentPermissionSchema = z.object({
1616
external_directory: PermissionValue.optional(),
1717
})
1818

19-
export const AgentNameSchema = z.enum([
19+
export const BuiltinAgentNameSchema = z.enum([
2020
"oracle",
2121
"librarian",
2222
"explore",
@@ -25,6 +25,18 @@ export const AgentNameSchema = z.enum([
2525
"multimodal-looker",
2626
])
2727

28+
export const OverridableAgentNameSchema = z.enum([
29+
"build",
30+
"oracle",
31+
"librarian",
32+
"explore",
33+
"frontend-ui-ux-engineer",
34+
"document-writer",
35+
"multimodal-looker",
36+
])
37+
38+
export const AgentNameSchema = BuiltinAgentNameSchema
39+
2840
export const HookNameSchema = z.enum([
2941
"todo-continuation-enforcer",
3042
"context-window-monitor",
@@ -62,6 +74,7 @@ export const AgentOverrideConfigSchema = z.object({
6274

6375
export const AgentOverridesSchema = z
6476
.object({
77+
build: AgentOverrideConfigSchema.optional(),
6578
oracle: AgentOverrideConfigSchema.optional(),
6679
librarian: AgentOverrideConfigSchema.optional(),
6780
explore: AgentOverrideConfigSchema.optional(),
@@ -82,7 +95,7 @@ export const ClaudeCodeConfigSchema = z.object({
8295
export const OhMyOpenCodeConfigSchema = z.object({
8396
$schema: z.string().optional(),
8497
disabled_mcps: z.array(McpNameSchema).optional(),
85-
disabled_agents: z.array(AgentNameSchema).optional(),
98+
disabled_agents: z.array(BuiltinAgentNameSchema).optional(),
8699
disabled_hooks: z.array(HookNameSchema).optional(),
87100
agents: AgentOverridesSchema.optional(),
88101
claude_code: ClaudeCodeConfigSchema.optional(),

src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Plugin } from "@opencode-ai/plugin";
2-
import { createBuiltinAgents } from "./agents";
2+
import { createBuiltinAgents, BUILD_AGENT_PROMPT_EXTENSION } from "./agents";
33
import {
44
createTodoContinuationEnforcer,
55
createContextWindowMonitorHook,
@@ -258,6 +258,16 @@ const OhMyOpenCodePlugin: Plugin = async (ctx) => {
258258
...projectAgents,
259259
...config.agent,
260260
};
261+
262+
if (config.agent.build) {
263+
const existingPrompt = config.agent.build.prompt || "";
264+
const userOverride = pluginConfig.agents?.build?.prompt || "";
265+
config.agent.build = {
266+
...config.agent.build,
267+
prompt: existingPrompt + BUILD_AGENT_PROMPT_EXTENSION + userOverride,
268+
};
269+
}
270+
261271
config.tools = {
262272
...config.tools,
263273
};

0 commit comments

Comments
 (0)