prjct-cli 0.33.5 → 0.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +65 -0
- package/core/agentic/command-executor.ts +26 -4
- package/core/agentic/index.ts +1 -0
- package/core/agentic/template-executor.ts +261 -0
- package/core/commands/workflow.ts +28 -6
- package/core/schemas/state.ts +43 -1
- package/core/services/agent-service.ts +36 -45
- package/core/storage/state-storage.ts +259 -1
- package/core/types/agentic.ts +6 -0
- package/dist/bin/prjct.mjs +1320 -523
- package/dist/core/infrastructure/command-installer.js +45 -19
- package/dist/core/infrastructure/editors-config.js +1 -1
- package/dist/core/infrastructure/setup.js +111 -70
- package/dist/core/utils/version.js +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.js +26 -2
- package/templates/agentic/orchestrator.md +402 -0
- package/templates/agentic/task-fragmentation.md +323 -0
- package/templates/commands/bug.md +2 -0
- package/templates/commands/github.md +63 -7
- package/templates/commands/jira.md +44 -4
- package/templates/commands/linear.md +40 -8
- package/templates/commands/monday.md +42 -6
- package/templates/commands/p.md +57 -10
- package/templates/commands/sync.md +133 -97
- package/templates/commands/task.md +12 -0
- package/templates/config/skill-mappings.json +95 -63
- package/packages/shared/.turbo/turbo-build.log +0 -14
- package/packages/shared/dist/index.d.ts +0 -10
- package/packages/shared/dist/index.d.ts.map +0 -1
- package/packages/shared/dist/index.js +0 -4196
- package/packages/shared/dist/schemas.d.ts +0 -408
- package/packages/shared/dist/schemas.d.ts.map +0 -1
- package/packages/shared/dist/types.d.ts +0 -144
- package/packages/shared/dist/types.d.ts.map +0 -1
- package/packages/shared/dist/unified.d.ts +0 -139
- package/packages/shared/dist/unified.d.ts.map +0 -1
- package/packages/shared/dist/utils.d.ts +0 -60
- package/packages/shared/dist/utils.d.ts.map +0 -1
- package/templates/commands/ask.md +0 -128
- package/templates/commands/dashboard.md +0 -686
- package/templates/commands/feature.md +0 -46
- package/templates/commands/now.md +0 -53
- package/templates/commands/suggest.md +0 -116
- package/templates/global/docs/agents.md +0 -88
- package/templates/global/docs/architecture.md +0 -103
- package/templates/global/docs/commands.md +0 -96
- package/templates/global/docs/validation.md +0 -95
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
# Orchestrator - Agent & Skill Coordinator
|
|
2
|
+
|
|
3
|
+
**Purpose**: Automatically route tasks to the right agents and skills.
|
|
4
|
+
|
|
5
|
+
## How It Works
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
User Task → Orchestrator → [Analyze] → [Fragment?] → [Load Agents] → [Delegate] → [Execute]
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The orchestrator is **implicit** - it runs automatically for every p. command.
|
|
12
|
+
|
|
13
|
+
**CRITICAL**: This is an AGENTIC orchestrator. Claude analyzes and decides - NO hardcoded keyword matching.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Step 1: Task Analysis (AGENTIC)
|
|
18
|
+
|
|
19
|
+
Analyze the current task/command to determine domains involved.
|
|
20
|
+
|
|
21
|
+
**DO NOT use keyword matching.** Instead, analyze:
|
|
22
|
+
1. What does the task actually require?
|
|
23
|
+
2. What files/modules will be affected?
|
|
24
|
+
3. What expertise is needed?
|
|
25
|
+
|
|
26
|
+
### Domain Detection (Agentic, Not Keyword-Based)
|
|
27
|
+
|
|
28
|
+
| Domain | What It Handles | Agent |
|
|
29
|
+
|--------|----------------|-------|
|
|
30
|
+
| **Frontend** | UI components, forms, layouts, styling, client-side logic | `frontend.md` |
|
|
31
|
+
| **UX/UI** | Design systems, accessibility, user experience | `uxui.md` |
|
|
32
|
+
| **Backend** | API endpoints, server logic, business rules, auth | `backend.md` |
|
|
33
|
+
| **Database** | Schema design, migrations, queries, data models | `database.md` |
|
|
34
|
+
| **Testing** | Unit tests, integration tests, e2e tests | `testing.md` |
|
|
35
|
+
| **DevOps** | CI/CD, deployment, infrastructure, containers | `devops.md` |
|
|
36
|
+
|
|
37
|
+
### Analysis Process (AGENTIC)
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
1. READ the task description carefully
|
|
41
|
+
2. REASON about what work is actually required
|
|
42
|
+
3. IDENTIFY which domains are involved (can be multiple)
|
|
43
|
+
4. CHECK which agents exist in {agentsDir}
|
|
44
|
+
5. DECIDE: Fragment into subtasks OR single execution
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Remember**: Agents in `{agentsDir}` are ALREADY project-specific. They were generated during `p. sync` with this project's patterns and technologies. Always prefer specialist agents over generalist.
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Step 2: Load Project Context
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
READ: .prjct/prjct.config.json → {projectId}
|
|
55
|
+
SET: {globalPath} = ~/.prjct-cli/projects/{projectId}
|
|
56
|
+
|
|
57
|
+
READ: {globalPath}/config/skills.json → {skillsConfig}
|
|
58
|
+
READ: {globalPath}/analysis/repo-analysis.json → {repoAnalysis}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Step 3: Load Relevant Agents
|
|
64
|
+
|
|
65
|
+
For each detected domain, load the corresponding agent.
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
SET: {loadedAgents} = []
|
|
69
|
+
|
|
70
|
+
FOR EACH domain IN {detectedDomains}:
|
|
71
|
+
SET: {agentPath} = {globalPath}/agents/{domain}.md
|
|
72
|
+
|
|
73
|
+
IF file exists:
|
|
74
|
+
READ: {agentPath}
|
|
75
|
+
EXTRACT: frontmatter (description, skills, patterns)
|
|
76
|
+
ADD to {loadedAgents}
|
|
77
|
+
|
|
78
|
+
OUTPUT: "🤖 Loaded: {domain} agent"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Agent Context Injection
|
|
82
|
+
|
|
83
|
+
Each loaded agent provides:
|
|
84
|
+
- **Patterns**: Code patterns specific to this project
|
|
85
|
+
- **Conventions**: Naming, structure, style rules
|
|
86
|
+
- **Skills**: Which skills to invoke for this domain
|
|
87
|
+
- **Anti-patterns**: What to avoid
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Step 4: Invoke Skills
|
|
92
|
+
|
|
93
|
+
For each loaded agent, check if skills should be invoked.
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
FOR EACH agent IN {loadedAgents}:
|
|
97
|
+
GET: {agentSkills} = agent.frontmatter.skills
|
|
98
|
+
|
|
99
|
+
FOR EACH skillName IN {agentSkills}:
|
|
100
|
+
SET: {skillPath} = ~/.claude/skills/{skillName}/SKILL.md
|
|
101
|
+
|
|
102
|
+
IF file exists:
|
|
103
|
+
READ: {skillPath}
|
|
104
|
+
EXTRACT: skill instructions
|
|
105
|
+
ADD to {activeSkills}
|
|
106
|
+
|
|
107
|
+
OUTPUT: "⚡ Skill active: {skillName}"
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Skill Selection Criteria
|
|
111
|
+
|
|
112
|
+
Only invoke skills that are:
|
|
113
|
+
1. **Relevant** to the current task
|
|
114
|
+
2. **Installed** in ~/.claude/skills/
|
|
115
|
+
3. **Linked** to a loaded agent
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
119
|
+
## Step 5: Build Execution Context
|
|
120
|
+
|
|
121
|
+
Combine all context for task execution.
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"task": "{original task description}",
|
|
126
|
+
"command": "{p. command being executed}",
|
|
127
|
+
"project": {
|
|
128
|
+
"id": "{projectId}",
|
|
129
|
+
"ecosystem": "{repoAnalysis.ecosystem}",
|
|
130
|
+
"conventions": "{repoAnalysis.conventions}"
|
|
131
|
+
},
|
|
132
|
+
"agents": [
|
|
133
|
+
{
|
|
134
|
+
"name": "{agent.name}",
|
|
135
|
+
"patterns": "{agent.patterns}",
|
|
136
|
+
"rules": "{agent.rules}"
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
"skills": [
|
|
140
|
+
{
|
|
141
|
+
"name": "{skill.name}",
|
|
142
|
+
"instructions": "{skill.instructions}"
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
"execution": {
|
|
146
|
+
"primaryDomain": "{primaryDomain}",
|
|
147
|
+
"secondaryDomains": ["{secondaryDomains}"],
|
|
148
|
+
"commands": "{repoAnalysis.commands}"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
## Step 6: Task Fragmentation (AGENTIC)
|
|
156
|
+
|
|
157
|
+
For complex multi-domain tasks, fragment into subtasks for specialist agents.
|
|
158
|
+
|
|
159
|
+
**Read**: `templates/agentic/task-fragmentation.md` for full details.
|
|
160
|
+
|
|
161
|
+
### When to Fragment
|
|
162
|
+
|
|
163
|
+
Fragment when:
|
|
164
|
+
- Task spans 3+ domains
|
|
165
|
+
- One-shot execution would saturate context
|
|
166
|
+
- Task has natural dependency order (database → backend → frontend)
|
|
167
|
+
|
|
168
|
+
### Fragmentation Process
|
|
169
|
+
|
|
170
|
+
```
|
|
171
|
+
1. IDENTIFY atomic subtasks (one domain each)
|
|
172
|
+
2. ASSIGN responsible agent to each subtask
|
|
173
|
+
3. ORDER by dependencies
|
|
174
|
+
4. DELEGATE via Task tool with clean context
|
|
175
|
+
5. COLLECT summaries for context handoff
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Delegation Pattern
|
|
179
|
+
|
|
180
|
+
For each subtask:
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
Task(
|
|
184
|
+
subagent_type: 'general-purpose',
|
|
185
|
+
prompt: '
|
|
186
|
+
## Agent Assignment
|
|
187
|
+
Read and apply: {agentsPath}/{domain}.md
|
|
188
|
+
|
|
189
|
+
## Subtask
|
|
190
|
+
{subtask.description}
|
|
191
|
+
|
|
192
|
+
## Previous Subtask Output (if any)
|
|
193
|
+
{previousSubtask.summary}
|
|
194
|
+
|
|
195
|
+
## MANDATORY: Generate Summary on Completion
|
|
196
|
+
- What was done
|
|
197
|
+
- Files created/modified
|
|
198
|
+
- Output for next agent
|
|
199
|
+
|
|
200
|
+
## FOCUS
|
|
201
|
+
ONLY this subtask. Do NOT implement other parts.
|
|
202
|
+
'
|
|
203
|
+
)
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Context Handoff
|
|
207
|
+
|
|
208
|
+
Each subtask generates a summary stored in `storage/state.json`:
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"subtasks": [{
|
|
213
|
+
"id": "subtask-1",
|
|
214
|
+
"status": "completed",
|
|
215
|
+
"summary": {
|
|
216
|
+
"title": "Create auth schema",
|
|
217
|
+
"description": "Created User and Session models",
|
|
218
|
+
"outputForNextAgent": "Models available via Prisma"
|
|
219
|
+
}
|
|
220
|
+
}]
|
|
221
|
+
}
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
The summary is passed to the next subtask for context.
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## Step 7: Execute with Context
|
|
229
|
+
|
|
230
|
+
Pass the execution context to the command template.
|
|
231
|
+
|
|
232
|
+
The command template receives:
|
|
233
|
+
- `{orchestrator.agents}` - Loaded agent contexts
|
|
234
|
+
- `{orchestrator.skills}` - Active skill instructions
|
|
235
|
+
- `{orchestrator.project}` - Project conventions
|
|
236
|
+
- `{orchestrator.execution}` - Execution metadata
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Multi-Domain Coordination (Example)
|
|
241
|
+
|
|
242
|
+
When task spans multiple domains, use FRAGMENTATION:
|
|
243
|
+
|
|
244
|
+
### Example: "Add user authentication with login form"
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
🎯 Task: add user authentication with login form
|
|
248
|
+
|
|
249
|
+
📊 Analysis:
|
|
250
|
+
├── Domains detected: database, backend, frontend
|
|
251
|
+
├── Agents available: database.md ✅, backend.md ✅, frontend.md ✅
|
|
252
|
+
└── Fragmentation: REQUIRED (3 domains)
|
|
253
|
+
|
|
254
|
+
📋 Subtasks (ordered by dependencies):
|
|
255
|
+
│
|
|
256
|
+
├─ 1. [database] Create auth schema
|
|
257
|
+
│ Agent: database.md
|
|
258
|
+
│ Output: User model, Session model, migrations
|
|
259
|
+
│
|
|
260
|
+
├─ 2. [backend] Implement auth API
|
|
261
|
+
│ Agent: backend.md
|
|
262
|
+
│ Depends on: #1
|
|
263
|
+
│ Output: /login, /logout endpoints
|
|
264
|
+
│
|
|
265
|
+
└─ 3. [frontend] Create login form
|
|
266
|
+
Agent: frontend.md
|
|
267
|
+
Depends on: #2
|
|
268
|
+
Output: LoginForm component
|
|
269
|
+
|
|
270
|
+
🚀 Executing subtasks...
|
|
271
|
+
|
|
272
|
+
✅ Subtask 1 complete → Summary passed to subtask 2
|
|
273
|
+
✅ Subtask 2 complete → Summary passed to subtask 3
|
|
274
|
+
✅ Subtask 3 complete
|
|
275
|
+
|
|
276
|
+
📋 Task Complete: All 3 subtasks finished
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## Orchestrator Output
|
|
282
|
+
|
|
283
|
+
At the start of each command, output:
|
|
284
|
+
|
|
285
|
+
```
|
|
286
|
+
🎯 Task: {task description}
|
|
287
|
+
|
|
288
|
+
📦 Context Loaded:
|
|
289
|
+
├── Agents: {loadedAgents.join(', ')}
|
|
290
|
+
├── Skills: {activeSkills.join(', ')}
|
|
291
|
+
└── Primary: {primaryDomain}
|
|
292
|
+
|
|
293
|
+
{Continue with command execution...}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Integration with Commands
|
|
299
|
+
|
|
300
|
+
Every p. command should:
|
|
301
|
+
|
|
302
|
+
1. **Before execution**: Run orchestrator Steps 1-6 (including fragmentation check)
|
|
303
|
+
2. **During execution**: Use orchestrator context, delegate to specialists
|
|
304
|
+
3. **After execution**: Aggregate subtask results, log which agents were used
|
|
305
|
+
|
|
306
|
+
### Command Template Integration
|
|
307
|
+
|
|
308
|
+
```markdown
|
|
309
|
+
# p. {command}
|
|
310
|
+
|
|
311
|
+
## Step 0: Orchestrator
|
|
312
|
+
|
|
313
|
+
INCLUDE: templates/agentic/orchestrator.md
|
|
314
|
+
|
|
315
|
+
Execute orchestrator Steps 1-6 to:
|
|
316
|
+
1. Analyze task (agentic, not keyword-based)
|
|
317
|
+
2. Load project context
|
|
318
|
+
3. Load relevant agents
|
|
319
|
+
4. Invoke skills
|
|
320
|
+
5. Build execution context
|
|
321
|
+
6. Fragment into subtasks if needed
|
|
322
|
+
|
|
323
|
+
## Step 1: {Command-specific logic}
|
|
324
|
+
|
|
325
|
+
Use {orchestrator.agents} and {orchestrator.skills} for:
|
|
326
|
+
- Code patterns
|
|
327
|
+
- Conventions
|
|
328
|
+
- Domain expertise
|
|
329
|
+
|
|
330
|
+
If fragmented, delegate each subtask via Task tool.
|
|
331
|
+
|
|
332
|
+
{Rest of command...}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## Configuration
|
|
338
|
+
|
|
339
|
+
### Disable Orchestrator
|
|
340
|
+
|
|
341
|
+
For simple commands that don't need orchestration:
|
|
342
|
+
|
|
343
|
+
```yaml
|
|
344
|
+
---
|
|
345
|
+
orchestrator: false
|
|
346
|
+
---
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Force Specific Agents
|
|
350
|
+
|
|
351
|
+
```yaml
|
|
352
|
+
---
|
|
353
|
+
orchestrator:
|
|
354
|
+
agents: [frontend, testing]
|
|
355
|
+
skills: [ui-design]
|
|
356
|
+
---
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
---
|
|
360
|
+
|
|
361
|
+
## Skill Invocation Patterns
|
|
362
|
+
|
|
363
|
+
### When to Invoke Skills
|
|
364
|
+
|
|
365
|
+
| Trigger | Skills to Invoke |
|
|
366
|
+
|---------|------------------|
|
|
367
|
+
| Creating UI component | ui-design, accessibility |
|
|
368
|
+
| Writing API endpoint | api-design, backend-patterns |
|
|
369
|
+
| Database changes | sql-patterns, database-design |
|
|
370
|
+
| Writing tests | test-automation |
|
|
371
|
+
| Deploying | ci-cd, infrastructure |
|
|
372
|
+
| Code review | code-review |
|
|
373
|
+
| Creating documents | pdf, docx, pptx (if installed) |
|
|
374
|
+
|
|
375
|
+
### Skill Execution
|
|
376
|
+
|
|
377
|
+
Skills provide:
|
|
378
|
+
1. **Instructions** - How to approach the task
|
|
379
|
+
2. **Examples** - Code/pattern examples
|
|
380
|
+
3. **Checklists** - Quality gates
|
|
381
|
+
4. **References** - Additional documentation
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## Error Handling
|
|
386
|
+
|
|
387
|
+
| Situation | Action |
|
|
388
|
+
|-----------|--------|
|
|
389
|
+
| No agents found | Use default patterns from repo-analysis |
|
|
390
|
+
| No skills installed | Continue without skills, suggest `p. sync` |
|
|
391
|
+
| Agent file missing | Skip that agent, continue with others |
|
|
392
|
+
| Skill file missing | Skip that skill, log warning |
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## Logging
|
|
397
|
+
|
|
398
|
+
Log orchestrator decisions to memory:
|
|
399
|
+
|
|
400
|
+
```json
|
|
401
|
+
{"ts":"{timestamp}","action":"orchestrator","task":"{task}","agents":["{agents}"],"skills":["{skills}"],"primaryDomain":"{domain}"}
|
|
402
|
+
```
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
# Task Fragmentation
|
|
2
|
+
|
|
3
|
+
**Purpose**: Break complex multi-domain tasks into subtasks for specialist agents.
|
|
4
|
+
|
|
5
|
+
## When to Fragment
|
|
6
|
+
|
|
7
|
+
Fragment a task when:
|
|
8
|
+
- It spans multiple domains (frontend + backend + database)
|
|
9
|
+
- It would require loading 3+ agents for one-shot execution
|
|
10
|
+
- One-shot implementation would saturate context
|
|
11
|
+
- The task has natural dependency order
|
|
12
|
+
- Complex enough that specialist focus improves quality
|
|
13
|
+
|
|
14
|
+
## When NOT to Fragment
|
|
15
|
+
|
|
16
|
+
Keep as single task when:
|
|
17
|
+
- Single domain only
|
|
18
|
+
- Small, focused change
|
|
19
|
+
- Already atomic
|
|
20
|
+
- User explicitly requests one-shot execution
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Fragmentation Algorithm
|
|
25
|
+
|
|
26
|
+
### Input
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
Task: "{task description}"
|
|
30
|
+
Available Agents: [list from {agentsDir}]
|
|
31
|
+
Project Tech: {from repo-analysis.json}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Process
|
|
35
|
+
|
|
36
|
+
#### 1. Parse Intent
|
|
37
|
+
|
|
38
|
+
What is the user trying to achieve?
|
|
39
|
+
What are the moving parts?
|
|
40
|
+
|
|
41
|
+
#### 2. Identify Components
|
|
42
|
+
|
|
43
|
+
| Component | Domain | Indicator Keywords |
|
|
44
|
+
|-----------|--------|-------------------|
|
|
45
|
+
| Data layer changes | database | schema, migration, table, query, model |
|
|
46
|
+
| API changes | backend | endpoint, API, route, controller, auth |
|
|
47
|
+
| UI changes | frontend | component, form, page, UI, layout, styling |
|
|
48
|
+
| Test changes | testing | test, spec, coverage, TDD |
|
|
49
|
+
| Deploy changes | devops | deploy, CI/CD, pipeline, container |
|
|
50
|
+
|
|
51
|
+
#### 3. Check Agent Availability
|
|
52
|
+
|
|
53
|
+
For each identified component:
|
|
54
|
+
- Does a matching agent exist in `{agentsDir}`?
|
|
55
|
+
- If YES → Create subtask for that agent
|
|
56
|
+
- If NO → Mark for generalist execution (rare)
|
|
57
|
+
|
|
58
|
+
**Remember**: Agents in `{agentsDir}` are ALREADY project-specific (generated during `p. sync`). Don't second-guess whether they "match" the technology.
|
|
59
|
+
|
|
60
|
+
#### 4. Order by Dependencies
|
|
61
|
+
|
|
62
|
+
Typical dependency order:
|
|
63
|
+
1. **Database** (data models first)
|
|
64
|
+
2. **Backend** (API using models)
|
|
65
|
+
3. **Frontend** (UI using API)
|
|
66
|
+
4. **Testing** (tests for all)
|
|
67
|
+
5. **DevOps** (deploy everything)
|
|
68
|
+
|
|
69
|
+
#### 5. Create Subtask Objects
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"subtasks": [
|
|
74
|
+
{
|
|
75
|
+
"id": "subtask-1",
|
|
76
|
+
"description": "Create users table schema",
|
|
77
|
+
"domain": "database",
|
|
78
|
+
"agent": "database.md",
|
|
79
|
+
"dependsOn": [],
|
|
80
|
+
"expectedOutput": "Migration file created"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "subtask-2",
|
|
84
|
+
"description": "Create auth API endpoints",
|
|
85
|
+
"domain": "backend",
|
|
86
|
+
"agent": "backend.md",
|
|
87
|
+
"dependsOn": ["subtask-1"],
|
|
88
|
+
"expectedOutput": "Auth routes implemented"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "subtask-3",
|
|
92
|
+
"description": "Create login form component",
|
|
93
|
+
"domain": "frontend",
|
|
94
|
+
"agent": "frontend.md",
|
|
95
|
+
"dependsOn": ["subtask-2"],
|
|
96
|
+
"expectedOutput": "Login form component"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Output Format
|
|
105
|
+
|
|
106
|
+
Report fragmentation plan before executing:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
🎯 Task: {original task}
|
|
110
|
+
|
|
111
|
+
📋 Subtasks (ordered by dependencies):
|
|
112
|
+
├─ 1. [database] Create users table schema
|
|
113
|
+
├─ 2. [backend] Create auth API endpoints
|
|
114
|
+
└─ 3. [frontend] Create login form
|
|
115
|
+
|
|
116
|
+
🤖 Agents to invoke: database, backend, frontend
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Delegation Pattern
|
|
122
|
+
|
|
123
|
+
For each subtask, delegate via Task tool:
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
Task(
|
|
127
|
+
subagent_type: 'general-purpose',
|
|
128
|
+
prompt: '
|
|
129
|
+
## Agent Assignment
|
|
130
|
+
Read and apply: {agentsPath}/{domain}.md
|
|
131
|
+
|
|
132
|
+
## Subtask
|
|
133
|
+
{subtask.description}
|
|
134
|
+
|
|
135
|
+
## Dependencies
|
|
136
|
+
{list completed subtasks and their summaries}
|
|
137
|
+
|
|
138
|
+
## Previous Subtask Output
|
|
139
|
+
{previousSubtask.summary if available}
|
|
140
|
+
|
|
141
|
+
## Expected Output
|
|
142
|
+
{subtask.expectedOutput}
|
|
143
|
+
|
|
144
|
+
## MANDATORY: Summary on Completion
|
|
145
|
+
|
|
146
|
+
When you complete this subtask, provide a summary:
|
|
147
|
+
|
|
148
|
+
### Summary
|
|
149
|
+
[1-2 sentence description of what you did]
|
|
150
|
+
|
|
151
|
+
### Files Created/Modified
|
|
152
|
+
[Table of files with actions]
|
|
153
|
+
|
|
154
|
+
### What Was Done
|
|
155
|
+
[Numbered list of concrete actions]
|
|
156
|
+
|
|
157
|
+
### Output for Next Agent
|
|
158
|
+
[What the next agent can use from your work]
|
|
159
|
+
|
|
160
|
+
### Notes for Integration
|
|
161
|
+
[Any important notes for integration]
|
|
162
|
+
|
|
163
|
+
## IMPORTANT
|
|
164
|
+
Focus ONLY on this subtask.
|
|
165
|
+
Do NOT implement other parts.
|
|
166
|
+
Return when this subtask is complete.
|
|
167
|
+
'
|
|
168
|
+
)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Summary Storage
|
|
174
|
+
|
|
175
|
+
After each subtask completes, the summary is stored in `storage/state.json`:
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
179
|
+
"currentTask": {
|
|
180
|
+
"subtasks": [{
|
|
181
|
+
"id": "subtask-1",
|
|
182
|
+
"status": "completed",
|
|
183
|
+
"summary": {
|
|
184
|
+
"title": "Create auth schema",
|
|
185
|
+
"description": "Created database schema for user authentication",
|
|
186
|
+
"filesChanged": [
|
|
187
|
+
{ "path": "prisma/schema.prisma", "action": "modified" }
|
|
188
|
+
],
|
|
189
|
+
"whatWasDone": [
|
|
190
|
+
"Added User model",
|
|
191
|
+
"Added Session model"
|
|
192
|
+
],
|
|
193
|
+
"outputForNextAgent": "User and Session models available via Prisma",
|
|
194
|
+
"notes": "Use bcrypt for password hashing"
|
|
195
|
+
}
|
|
196
|
+
}]
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Context Handoff
|
|
204
|
+
|
|
205
|
+
Each subsequent subtask receives the previous subtask's summary:
|
|
206
|
+
|
|
207
|
+
```
|
|
208
|
+
## Previous Subtask Summary (CONTEXT)
|
|
209
|
+
${previousSubtask.summary}
|
|
210
|
+
|
|
211
|
+
## What's Available
|
|
212
|
+
- User model (prisma.user)
|
|
213
|
+
- Session model (prisma.session)
|
|
214
|
+
- Notes: Use bcrypt for passwords
|
|
215
|
+
|
|
216
|
+
## Your Task
|
|
217
|
+
Create auth API endpoints using the models from subtask 1.
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## Progress Tracking
|
|
223
|
+
|
|
224
|
+
The orchestrator updates progress after each subtask:
|
|
225
|
+
|
|
226
|
+
```
|
|
227
|
+
📊 Progress: 2/4 subtasks (50%)
|
|
228
|
+
|
|
229
|
+
✅ 1. [database] Create auth schema
|
|
230
|
+
✅ 2. [backend] Create auth API
|
|
231
|
+
▶️ 3. [frontend] Create login form ← CURRENT
|
|
232
|
+
⏳ 4. [testing] Add auth tests
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Aggregating Results
|
|
238
|
+
|
|
239
|
+
After all subtasks complete, report aggregated status:
|
|
240
|
+
|
|
241
|
+
```
|
|
242
|
+
✅ Task Complete: add user authentication
|
|
243
|
+
|
|
244
|
+
📋 Subtasks Completed:
|
|
245
|
+
├─ ✅ 1. [database] Create auth schema
|
|
246
|
+
│ Files: prisma/schema.prisma
|
|
247
|
+
│
|
|
248
|
+
├─ ✅ 2. [backend] Create auth API
|
|
249
|
+
│ Files: src/routes/auth.ts, src/middleware/auth.ts
|
|
250
|
+
│
|
|
251
|
+
├─ ✅ 3. [frontend] Create login form
|
|
252
|
+
│ Files: src/components/LoginForm.tsx
|
|
253
|
+
│
|
|
254
|
+
└─ ✅ 4. [testing] Add auth tests
|
|
255
|
+
Files: tests/auth.test.ts
|
|
256
|
+
|
|
257
|
+
📁 Total files affected: 5
|
|
258
|
+
⏱️ Total duration: {calculated from subtask times}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Error Handling
|
|
264
|
+
|
|
265
|
+
If a subtask fails:
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
❌ Subtask 2/4 failed: Create auth API
|
|
269
|
+
|
|
270
|
+
Error: Database connection failed
|
|
271
|
+
|
|
272
|
+
Options:
|
|
273
|
+
1. Retry this subtask
|
|
274
|
+
2. Skip and continue with remaining subtasks
|
|
275
|
+
3. Abort task and rollback
|
|
276
|
+
|
|
277
|
+
What would you like to do?
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Use `AskUserQuestion` to get user decision on failure handling.
|
|
281
|
+
|
|
282
|
+
---
|
|
283
|
+
|
|
284
|
+
## Anti-Patterns to Avoid
|
|
285
|
+
|
|
286
|
+
### 1. Over-fragmentation
|
|
287
|
+
```
|
|
288
|
+
❌ WRONG: 10 subtasks for "add login button"
|
|
289
|
+
✅ RIGHT: Single task (already atomic)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### 2. Under-fragmentation
|
|
293
|
+
```
|
|
294
|
+
❌ WRONG: 1 subtask for "add complete auth system"
|
|
295
|
+
✅ RIGHT: 4 subtasks (database, backend, frontend, testing)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### 3. Wrong Dependency Order
|
|
299
|
+
```
|
|
300
|
+
❌ WRONG: Frontend before backend (depends on API)
|
|
301
|
+
✅ RIGHT: Database → Backend → Frontend
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### 4. Missing Summaries
|
|
305
|
+
```
|
|
306
|
+
❌ WRONG: Subtask completes without summary
|
|
307
|
+
✅ RIGHT: Every subtask generates structured summary
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## Integration with Storage
|
|
313
|
+
|
|
314
|
+
The subtasks are stored in `storage/state.json` under `currentTask.subtasks`.
|
|
315
|
+
|
|
316
|
+
Key methods available:
|
|
317
|
+
- `stateStorage.createSubtasks(projectId, subtasks)` - Create subtasks
|
|
318
|
+
- `stateStorage.completeSubtask(projectId, output, summary)` - Complete current subtask
|
|
319
|
+
- `stateStorage.getCurrentSubtask(projectId)` - Get current subtask
|
|
320
|
+
- `stateStorage.getNextSubtask(projectId)` - Get next subtask
|
|
321
|
+
- `stateStorage.getSubtaskProgress(projectId)` - Get progress
|
|
322
|
+
|
|
323
|
+
These are called by the orchestrator as subtasks are processed.
|