forked from Yeachan-Heo/oh-my-claudecode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefinitions.ts
More file actions
392 lines (336 loc) · 15.2 KB
/
definitions.ts
File metadata and controls
392 lines (336 loc) · 15.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
/**
* Agent Definitions for Oh-My-ClaudeCode
*
* This module provides:
* 1. Re-exports of base agents from individual files
* 2. Tiered agent variants with dynamically loaded prompts from /agents/*.md
* 3. getAgentDefinitions() for agent registry
* 4. omcSystemPrompt for the main orchestrator
*/
import type { AgentConfig, PluginConfig } from '../shared/types.js';
import { loadAgentPrompt, parseDisallowedTools } from './utils.js';
import { loadConfig } from '../config/loader.js';
// Re-export base agents from individual files (rebranded names)
export { architectAgent } from './architect.js';
export { designerAgent } from './designer.js';
export { writerAgent } from './writer.js';
export { criticAgent } from './critic.js';
export { analystAgent } from './analyst.js';
export { executorAgent } from './executor.js';
export { plannerAgent } from './planner.js';
export { qaTesterAgent } from './qa-tester.js';
export { scientistAgent } from './scientist.js';
export { exploreAgent } from './explore.js';
export { documentSpecialistAgent } from './document-specialist.js';
// Import base agents for use in getAgentDefinitions
import { architectAgent } from './architect.js';
import { designerAgent } from './designer.js';
import { writerAgent } from './writer.js';
import { criticAgent } from './critic.js';
import { analystAgent } from './analyst.js';
import { executorAgent } from './executor.js';
import { plannerAgent } from './planner.js';
import { qaTesterAgent } from './qa-tester.js';
import { scientistAgent } from './scientist.js';
import { exploreAgent } from './explore.js';
import { documentSpecialistAgent } from './document-specialist.js';
// Re-export loadAgentPrompt (also exported from index.ts)
export { loadAgentPrompt };
// ============================================================
// REFORMED AGENTS (BUILD/ANALYSIS LANE)
// ============================================================
/**
* Debugger Agent - Root-Cause Analysis & Debugging (Sonnet)
*/
export const debuggerAgent: AgentConfig = {
name: 'debugger',
description: 'Root-cause analysis, regression isolation, failure diagnosis (Sonnet).',
prompt: loadAgentPrompt('debugger'),
model: 'sonnet',
defaultModel: 'sonnet'
};
/**
* Verifier Agent - Completion Evidence & Test Validation (Sonnet)
*/
export const verifierAgent: AgentConfig = {
name: 'verifier',
description: 'Completion evidence, claim validation, test adequacy (Sonnet).',
prompt: loadAgentPrompt('verifier'),
model: 'sonnet',
defaultModel: 'sonnet'
};
// ============================================================
// REFORMED AGENTS (REVIEW LANE)
// ============================================================
// ============================================================
// REFORMED AGENTS (DOMAIN SPECIALISTS)
// ============================================================
/**
* Test-Engineer Agent - Test Strategy & Coverage (Sonnet)
* Replaces: tdd-guide agent
*/
export const testEngineerAgent: AgentConfig = {
name: 'test-engineer',
description: 'Test strategy, coverage, flaky test hardening (Sonnet).',
prompt: loadAgentPrompt('test-engineer'),
model: 'sonnet',
defaultModel: 'sonnet'
};
// ============================================================
// SPECIALIZED AGENTS (Security, Build, TDD, Code Review)
// ============================================================
/**
* Security-Reviewer Agent - Security Vulnerability Detection (Sonnet)
*/
export const securityReviewerAgent: AgentConfig = {
name: 'security-reviewer',
description: 'Security vulnerability detection specialist (Sonnet). Use for security audits and OWASP detection.',
prompt: loadAgentPrompt('security-reviewer'),
model: 'sonnet',
defaultModel: 'sonnet'
};
/**
* Code-Reviewer Agent - Expert Code Review (Opus)
*/
export const codeReviewerAgent: AgentConfig = {
name: 'code-reviewer',
description: 'Expert code review specialist (Opus). Use for comprehensive code quality review.',
prompt: loadAgentPrompt('code-reviewer'),
model: 'opus',
defaultModel: 'opus'
};
/**
* Git-Master Agent - Git Operations Expert (Sonnet)
*/
export const gitMasterAgent: AgentConfig = {
name: 'git-master',
description: 'Git expert for atomic commits, rebasing, and history management with style detection',
prompt: loadAgentPrompt('git-master'),
model: 'sonnet',
defaultModel: 'sonnet'
};
/**
* Code-Simplifier Agent - Code Simplification & Refactoring (Opus)
*/
export const codeSimplifierAgent: AgentConfig = {
name: 'code-simplifier',
description: 'Simplifies and refines code for clarity, consistency, and maintainability (Opus).',
prompt: loadAgentPrompt('code-simplifier'),
model: 'opus',
defaultModel: 'opus'
};
// ============================================================
// DEPRECATED ALIASES (Backward Compatibility)
// ============================================================
/**
* @deprecated Use test-engineer agent instead
*/
export const tddGuideAgentAlias = testEngineerAgent;
const AGENT_CONFIG_KEY_MAP = {
explore: 'explore',
analyst: 'analyst',
planner: 'planner',
architect: 'architect',
debugger: 'debugger',
executor: 'executor',
verifier: 'verifier',
'security-reviewer': 'securityReviewer',
'code-reviewer': 'codeReviewer',
'test-engineer': 'testEngineer',
designer: 'designer',
writer: 'writer',
'qa-tester': 'qaTester',
scientist: 'scientist',
'git-master': 'gitMaster',
'code-simplifier': 'codeSimplifier',
critic: 'critic',
'document-specialist': 'documentSpecialist',
} as const satisfies Partial<Record<string, keyof NonNullable<PluginConfig['agents']>>>;
function getConfiguredAgentModel(name: string, config: PluginConfig): string | undefined {
const key = AGENT_CONFIG_KEY_MAP[name as keyof typeof AGENT_CONFIG_KEY_MAP];
return key ? config.agents?.[key]?.model : undefined;
}
// ============================================================
// AGENT REGISTRY
// ============================================================
/**
* Agent Role Disambiguation
*
* HIGH-tier review/planning agents have distinct, non-overlapping roles:
*
* | Agent | Role | What They Do | What They Don't Do |
* |-------|------|--------------|-------------------|
* | architect | code-analysis | Analyze code, debug, verify | Requirements, plan creation, plan review |
* | analyst | requirements-analysis | Find requirement gaps | Code analysis, planning, plan review |
* | planner | plan-creation | Create work plans | Requirements, code analysis, plan review |
* | critic | plan-review | Review plan quality | Requirements, code analysis, plan creation |
*
* Workflow: explore → analyst → planner → critic → executor → architect (verify)
*/
/**
* Get all agent definitions as a record for use with Claude Agent SDK
*/
export function getAgentDefinitions(options?: {
overrides?: Partial<Record<string, Partial<AgentConfig>>>;
config?: PluginConfig;
}): Record<string, {
description: string;
prompt: string;
tools?: string[];
disallowedTools?: string[];
model?: string;
defaultModel?: string;
}> {
const agents: Record<string, AgentConfig> = {
// ============================================================
// BUILD/ANALYSIS LANE
// ============================================================
explore: exploreAgent,
analyst: analystAgent,
planner: plannerAgent,
architect: architectAgent,
debugger: debuggerAgent,
executor: executorAgent,
verifier: verifierAgent,
// ============================================================
// REVIEW LANE
// ============================================================
'security-reviewer': securityReviewerAgent,
'code-reviewer': codeReviewerAgent,
// ============================================================
// DOMAIN SPECIALISTS
// ============================================================
'test-engineer': testEngineerAgent,
designer: designerAgent,
writer: writerAgent,
'qa-tester': qaTesterAgent,
scientist: scientistAgent,
'git-master': gitMasterAgent,
'code-simplifier': codeSimplifierAgent,
// ============================================================
// COORDINATION
// ============================================================
critic: criticAgent,
// ============================================================
// BACKWARD COMPATIBILITY (Deprecated)
// ============================================================
'document-specialist': documentSpecialistAgent
};
const resolvedConfig = options?.config ?? loadConfig();
const result: Record<string, { description: string; prompt: string; tools?: string[]; disallowedTools?: string[]; model?: string; defaultModel?: string }> = {};
for (const [name, agentConfig] of Object.entries(agents)) {
const override = options?.overrides?.[name];
const configuredModel = getConfiguredAgentModel(name, resolvedConfig);
const disallowedTools = agentConfig.disallowedTools ?? parseDisallowedTools(name);
const resolvedModel = override?.model ?? configuredModel ?? agentConfig.model;
const resolvedDefaultModel = override?.defaultModel ?? agentConfig.defaultModel;
result[name] = {
description: override?.description ?? agentConfig.description,
prompt: override?.prompt ?? agentConfig.prompt,
tools: override?.tools ?? agentConfig.tools,
disallowedTools,
model: resolvedModel,
defaultModel: resolvedDefaultModel,
};
}
return result;
}
// ============================================================
// OMC SYSTEM PROMPT
// ============================================================
/**
* OMC System Prompt - The main orchestrator
*/
export const omcSystemPrompt = `You are the relentless orchestrator of a multi-agent development system.
## RELENTLESS EXECUTION
You are BOUND to your task list. You do not stop. You do not quit. You do not take breaks. Work continues until EVERY task is COMPLETE.
## Your Core Duty
You coordinate specialized subagents to accomplish complex software engineering tasks. Abandoning work mid-task is not an option. If you stop without completing ALL tasks, you have failed.
## Available Subagents (18 Agents)
### Build/Analysis Lane
- **explore**: Internal codebase discovery (haiku) — fast pattern matching
- **analyst**: Requirements clarity (opus) — hidden constraint analysis
- **planner**: Task sequencing (opus) — execution plans and risk flags
- **architect**: System design (opus) — boundaries, interfaces, tradeoffs
- **debugger**: Root-cause analysis + build error fixing (sonnet) — regression isolation, diagnosis, type/compilation errors
- **executor**: Code implementation (sonnet) — features, refactoring, autonomous complex tasks (use model=opus for complex multi-file changes)
- **verifier**: Completion validation (sonnet) — evidence, claims, test adequacy
### Review Lane
- **security-reviewer**: Security audits (sonnet) — vulns, trust boundaries, authn/authz
- **code-reviewer**: Comprehensive review (opus) — API contracts, versioning, backward compatibility, logic defects, maintainability, anti-patterns, performance, quality strategy
### Domain Specialists
- **test-engineer**: Test strategy (sonnet) — coverage, flaky test hardening
- **designer**: UI/UX architecture (sonnet) — interaction design
- **writer**: Documentation (haiku) — docs, migration notes
- **qa-tester**: CLI testing (sonnet) — interactive runtime validation via tmux
- **scientist**: Data analysis (sonnet) — statistics and research
- **git-master**: Git operations (sonnet) — commits, rebasing, history
- **document-specialist**: External docs & reference lookup (sonnet) — SDK/API/package research
- **code-simplifier**: Code clarity (opus) — simplification and maintainability
### Coordination
- **critic**: Plan review + thorough gap analysis (opus) — critical challenge, multi-perspective investigation, structured "What's Missing" analysis
### Deprecated Aliases
- **api-reviewer** → code-reviewer
- **performance-reviewer** → code-reviewer
- **quality-reviewer** → code-reviewer
- **quality-strategist** → code-reviewer
- **dependency-expert** → document-specialist
- **researcher** → document-specialist
- **tdd-guide** → test-engineer
- **deep-executor** → executor
- **build-fixer** → debugger
- **harsh-critic** → critic
## Orchestration Principles
1. **Delegate Aggressively**: Fire off subagents for specialized tasks - don't do everything yourself
2. **Parallelize Ruthlessly**: Launch multiple subagents concurrently whenever tasks are independent
3. **PERSIST RELENTLESSLY**: Continue until ALL tasks are VERIFIED complete - check your todo list BEFORE stopping
4. **Communicate Progress**: Keep the user informed but DON'T STOP to explain when you should be working
5. **Verify Thoroughly**: Test, check, verify - then verify again
## Agent Combinations
### Architect + QA-Tester (Diagnosis -> Verification Loop)
For debugging CLI apps and services:
1. **architect** diagnoses the issue, provides root cause analysis
2. **architect** outputs a test plan with specific commands and expected outputs
3. **qa-tester** executes the test plan in tmux, captures real outputs
4. If verification fails, feed results back to architect for re-diagnosis
5. Repeat until verified
This is the recommended workflow for any bug that requires running actual services to verify.
### Verification Guidance (Gated for Token Efficiency)
**Verification priority order:**
1. **Existing tests** (run the project's test command) - PREFERRED, cheapest
2. **Direct commands** (curl, simple CLI) - cheap
3. **QA-Tester** (tmux sessions) - expensive, use sparingly
**When to use qa-tester:**
- No test suite covers the behavior
- Interactive CLI input/output simulation needed
- Service startup/shutdown testing required
- Streaming/real-time behavior verification
**When NOT to use qa-tester:**
- Project has tests that cover the functionality -> run tests
- Simple command verification -> run directly
- Static code analysis -> use architect
## Workflow
1. Analyze the user's request and break it into tasks using TodoWrite
2. Mark the first task in_progress and BEGIN WORKING
3. Delegate to appropriate subagents based on task type
4. Coordinate results and handle any issues WITHOUT STOPPING
5. Mark tasks complete ONLY when verified
6. LOOP back to step 2 until ALL tasks show 'completed'
7. Final verification: Re-read todo list, confirm 100% completion
8. Only THEN may you rest
## CRITICAL RULES - VIOLATION IS FAILURE
1. **NEVER STOP WITH INCOMPLETE WORK** - If your todo list has pending/in_progress items, YOU ARE NOT DONE
2. **ALWAYS VERIFY** - Check your todo list before ANY attempt to conclude
3. **NO PREMATURE CONCLUSIONS** - Saying "I've completed the task" without verification is a LIE
4. **PARALLEL EXECUTION** - Use it whenever possible for speed
5. **CONTINUOUS PROGRESS** - Report progress but keep working
6. **WHEN BLOCKED, UNBLOCK** - Don't stop because something is hard; find another way
7. **ASK ONLY WHEN NECESSARY** - Clarifying questions are for ambiguity, not for avoiding work
## Completion Checklist
Before concluding, you MUST verify:
- [ ] Every todo item is marked 'completed'
- [ ] All requested functionality is implemented
- [ ] Tests pass (if applicable)
- [ ] No errors remain unaddressed
- [ ] The user's original request is FULLY satisfied
If ANY checkbox is unchecked, YOU ARE NOT DONE. Continue working.`;