opencode-swarm-plugin 0.12.29 → 0.12.31
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/README.md +1 -1
- package/bin/swarm.ts +120 -31
- package/examples/commands/swarm.md +70 -19
- package/global-skills/swarm-coordination/SKILL.md +233 -110
- package/global-skills/swarm-coordination/references/coordinator-patterns.md +235 -0
- package/global-skills/swarm-coordination/references/strategies.md +138 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -203,7 +203,7 @@ skills_use(name="swarm-coordination") # Load swarm workflow
|
|
|
203
203
|
| `learning-systems` | learning, feedback | Implicit feedback scoring, confidence decay, anti-pattern detection |
|
|
204
204
|
| `mcp-tool-authoring` | mcp, tools | Building MCP tools - schema definition, context passing, error handling |
|
|
205
205
|
| `skill-creator` | meta, skills | Guide for creating effective skills |
|
|
206
|
-
| `swarm-coordination` | swarm, multi-agent |
|
|
206
|
+
| `swarm-coordination` | swarm, multi-agent | Complete swarm playbook - strategies, coordinator patterns, failure recovery |
|
|
207
207
|
| `system-design` | design, architecture | Building reusable systems - deep modules, complexity management, design red flags |
|
|
208
208
|
|
|
209
209
|
### Skill Locations
|
package/bin/swarm.ts
CHANGED
|
@@ -497,23 +497,65 @@ $ARGUMENTS
|
|
|
497
497
|
|
|
498
498
|
## Workflow
|
|
499
499
|
|
|
500
|
-
1.
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
500
|
+
### 1. Initialize
|
|
501
|
+
\`agentmail_init(project_path="$PWD", task_description="Swarm: <task>")\`
|
|
502
|
+
|
|
503
|
+
### 2. Knowledge Gathering (MANDATORY)
|
|
504
|
+
|
|
505
|
+
**Before decomposing, query ALL knowledge sources:**
|
|
506
|
+
|
|
507
|
+
\`\`\`
|
|
508
|
+
semantic-memory_find(query="<task keywords>", limit=5) # Past learnings
|
|
509
|
+
cass_search(query="<task description>", limit=5) # Similar past tasks
|
|
510
|
+
pdf-brain_search(query="<domain concepts>", limit=5) # Design patterns
|
|
511
|
+
skills_list() # Available skills
|
|
512
|
+
\`\`\`
|
|
513
|
+
|
|
514
|
+
Synthesize findings into shared_context for workers.
|
|
515
|
+
|
|
516
|
+
### 3. Decompose
|
|
517
|
+
\`\`\`
|
|
518
|
+
swarm_select_strategy(task="<task>")
|
|
519
|
+
swarm_plan_prompt(task="<task>", context="<synthesized knowledge>")
|
|
520
|
+
swarm_validate_decomposition(response="<BeadTree JSON>")
|
|
521
|
+
\`\`\`
|
|
522
|
+
|
|
523
|
+
### 4. Create Beads
|
|
524
|
+
\`beads_create_epic(epic_title="<task>", subtasks=[...])\`
|
|
525
|
+
|
|
526
|
+
### 5. Reserve Files
|
|
527
|
+
\`agentmail_reserve(paths=[...], reason="<bead-id>: <desc>")\`
|
|
528
|
+
|
|
529
|
+
### 6. Spawn Agents (ALL in single message)
|
|
530
|
+
\`\`\`
|
|
531
|
+
swarm_spawn_subtask(bead_id, epic_id, subtask_title, files, shared_context)
|
|
532
|
+
Task(subagent_type="swarm/worker", prompt="<from above>")
|
|
533
|
+
\`\`\`
|
|
534
|
+
|
|
535
|
+
### 7. Monitor
|
|
536
|
+
\`\`\`
|
|
537
|
+
swarm_status(epic_id, project_key)
|
|
538
|
+
agentmail_inbox()
|
|
539
|
+
\`\`\`
|
|
540
|
+
|
|
541
|
+
Intervene if: blocked >5min, file conflicts, scope creep.
|
|
542
|
+
|
|
543
|
+
### 8. Complete
|
|
544
|
+
\`\`\`
|
|
545
|
+
swarm_complete(...)
|
|
546
|
+
beads_sync()
|
|
547
|
+
\`\`\`
|
|
548
|
+
|
|
549
|
+
## Strategy Reference
|
|
550
|
+
|
|
551
|
+
| Strategy | Best For | Keywords |
|
|
552
|
+
| -------------- | ------------------------ | -------------------------------------- |
|
|
553
|
+
| file-based | Refactoring, migrations | refactor, migrate, rename, update all |
|
|
554
|
+
| feature-based | New features | add, implement, build, create, feature |
|
|
555
|
+
| risk-based | Bug fixes, security | fix, bug, security, critical, urgent |
|
|
556
|
+
| research-based | Investigation, discovery | research, investigate, explore, learn |
|
|
557
|
+
|
|
558
|
+
Begin with knowledge gathering now.
|
|
517
559
|
`;
|
|
518
560
|
|
|
519
561
|
const getPlannerAgent = (model: string) => `---
|
|
@@ -526,12 +568,30 @@ You are a swarm planner. Decompose tasks into optimal parallel subtasks.
|
|
|
526
568
|
|
|
527
569
|
## Workflow
|
|
528
570
|
|
|
529
|
-
1.
|
|
530
|
-
2. Call \`swarm_plan_prompt\` to get strategy-specific guidance
|
|
531
|
-
3. Create a BeadTree following the guidelines
|
|
532
|
-
4. Return ONLY valid JSON - no markdown, no explanation
|
|
571
|
+
### 1. Knowledge Gathering (MANDATORY)
|
|
533
572
|
|
|
534
|
-
|
|
573
|
+
**Before decomposing, query ALL knowledge sources:**
|
|
574
|
+
|
|
575
|
+
\`\`\`
|
|
576
|
+
semantic-memory_find(query="<task keywords>", limit=5) # Past learnings
|
|
577
|
+
cass_search(query="<task description>", limit=5) # Similar past tasks
|
|
578
|
+
pdf-brain_search(query="<domain concepts>", limit=5) # Design patterns
|
|
579
|
+
skills_list() # Available skills
|
|
580
|
+
\`\`\`
|
|
581
|
+
|
|
582
|
+
Synthesize findings - note relevant patterns, past approaches, and skills to recommend.
|
|
583
|
+
|
|
584
|
+
### 2. Strategy Selection
|
|
585
|
+
|
|
586
|
+
\`swarm_select_strategy(task="<task>")\`
|
|
587
|
+
|
|
588
|
+
### 3. Generate Plan
|
|
589
|
+
|
|
590
|
+
\`swarm_plan_prompt(task="<task>", context="<synthesized knowledge>")\`
|
|
591
|
+
|
|
592
|
+
### 4. Output BeadTree
|
|
593
|
+
|
|
594
|
+
Return ONLY valid JSON - no markdown, no explanation:
|
|
535
595
|
|
|
536
596
|
\`\`\`json
|
|
537
597
|
{
|
|
@@ -539,7 +599,7 @@ You are a swarm planner. Decompose tasks into optimal parallel subtasks.
|
|
|
539
599
|
"subtasks": [
|
|
540
600
|
{
|
|
541
601
|
"title": "...",
|
|
542
|
-
"description": "
|
|
602
|
+
"description": "Include relevant context from knowledge gathering",
|
|
543
603
|
"files": ["src/..."],
|
|
544
604
|
"dependencies": [],
|
|
545
605
|
"estimated_complexity": 2
|
|
@@ -554,6 +614,7 @@ You are a swarm planner. Decompose tasks into optimal parallel subtasks.
|
|
|
554
614
|
- No file overlap between subtasks
|
|
555
615
|
- Include tests with the code they test
|
|
556
616
|
- Order by dependency (if B needs A, A comes first)
|
|
617
|
+
- Pass synthesized knowledge to workers via subtask descriptions
|
|
557
618
|
`;
|
|
558
619
|
|
|
559
620
|
const getWorkerAgent = (model: string) => `---
|
|
@@ -564,17 +625,45 @@ model: ${model}
|
|
|
564
625
|
|
|
565
626
|
You are a swarm worker agent. Execute your assigned subtask efficiently.
|
|
566
627
|
|
|
628
|
+
## Context
|
|
629
|
+
|
|
630
|
+
Your prompt includes shared_context from the coordinator's knowledge gathering:
|
|
631
|
+
- Relevant patterns from pdf-brain
|
|
632
|
+
- Similar past approaches from CASS
|
|
633
|
+
- Project-specific learnings from semantic-memory
|
|
634
|
+
|
|
635
|
+
**Use this context** - it contains patterns and prior art relevant to your task.
|
|
636
|
+
|
|
637
|
+
## Workflow
|
|
638
|
+
|
|
639
|
+
1. **Read** assigned files to understand current state
|
|
640
|
+
2. **Check skills** if you need domain guidance: \`skills_use(name="<relevant-skill>")\`
|
|
641
|
+
3. **Implement** changes following patterns from shared_context
|
|
642
|
+
4. **Verify** (typecheck, lint if applicable)
|
|
643
|
+
5. **Complete** with \`swarm_complete\`
|
|
644
|
+
|
|
567
645
|
## Rules
|
|
646
|
+
|
|
568
647
|
- Focus ONLY on your assigned files
|
|
569
|
-
- Report
|
|
570
|
-
- Use beads_update
|
|
571
|
-
- Call swarm_complete when done
|
|
648
|
+
- Report blockers immediately via Agent Mail (don't spin)
|
|
649
|
+
- Use beads_update if blocked
|
|
650
|
+
- Call swarm_complete when done - it handles bead closure and file release
|
|
572
651
|
|
|
573
|
-
##
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
652
|
+
## Communication
|
|
653
|
+
|
|
654
|
+
\`\`\`
|
|
655
|
+
agentmail_send(
|
|
656
|
+
to=["coordinator"],
|
|
657
|
+
subject="Progress/Blocker",
|
|
658
|
+
body="...",
|
|
659
|
+
thread_id="<epic_id>"
|
|
660
|
+
)
|
|
661
|
+
\`\`\`
|
|
662
|
+
|
|
663
|
+
## Learning
|
|
664
|
+
|
|
665
|
+
If you discover a reusable pattern worth preserving:
|
|
666
|
+
\`semantic-memory_store(information="<pattern + why it matters>")\`
|
|
578
667
|
`;
|
|
579
668
|
|
|
580
669
|
// ============================================================================
|
|
@@ -23,20 +23,45 @@ $ARGUMENTS
|
|
|
23
23
|
agentmail_init(project_path="$PWD", task_description="Swarm: <task summary>")
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
### 2.
|
|
26
|
+
### 2. Knowledge Gathering (MANDATORY)
|
|
27
|
+
|
|
28
|
+
**Before decomposing, query ALL knowledge sources:**
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
# Past learnings from this project
|
|
32
|
+
semantic-memory_find(query="<task keywords>", limit=5)
|
|
33
|
+
|
|
34
|
+
# How similar tasks were solved before
|
|
35
|
+
cass_search(query="<task description>", limit=5)
|
|
36
|
+
|
|
37
|
+
# Design patterns and prior art
|
|
38
|
+
pdf-brain_search(query="<domain concepts>", limit=5)
|
|
39
|
+
|
|
40
|
+
# Available skills to inject into workers
|
|
41
|
+
skills_list()
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Synthesize findings into shared context for workers. Note:
|
|
45
|
+
|
|
46
|
+
- Relevant patterns from pdf-brain
|
|
47
|
+
- Similar past approaches from CASS
|
|
48
|
+
- Project-specific learnings from semantic-memory
|
|
49
|
+
- Skills to recommend for subtasks
|
|
50
|
+
|
|
51
|
+
### 3. Create Feature Branch (unless --to-main)
|
|
27
52
|
|
|
28
53
|
```bash
|
|
29
54
|
git checkout -b swarm/<short-task-name>
|
|
30
55
|
git push -u origin HEAD
|
|
31
56
|
```
|
|
32
57
|
|
|
33
|
-
###
|
|
58
|
+
### 4. Decompose Task
|
|
34
59
|
|
|
35
60
|
Use strategy selection and planning:
|
|
36
61
|
|
|
37
62
|
```
|
|
38
63
|
swarm_select_strategy(task="<the task>")
|
|
39
|
-
swarm_plan_prompt(task="<the task>", strategy="<auto or selected>")
|
|
64
|
+
swarm_plan_prompt(task="<the task>", strategy="<auto or selected>", context="<synthesized knowledge>")
|
|
40
65
|
```
|
|
41
66
|
|
|
42
67
|
Follow the prompt to create a BeadTree, then validate:
|
|
@@ -45,7 +70,7 @@ Follow the prompt to create a BeadTree, then validate:
|
|
|
45
70
|
swarm_validate_decomposition(response="<your BeadTree JSON>")
|
|
46
71
|
```
|
|
47
72
|
|
|
48
|
-
###
|
|
73
|
+
### 5. Create Beads
|
|
49
74
|
|
|
50
75
|
```
|
|
51
76
|
beads_create_epic(epic_title="<task>", subtasks=[{title, files, priority}...])
|
|
@@ -56,8 +81,9 @@ Rules:
|
|
|
56
81
|
- Each bead completable by one agent
|
|
57
82
|
- Independent where possible (parallelizable)
|
|
58
83
|
- 3-7 beads per swarm
|
|
84
|
+
- No file overlap between subtasks
|
|
59
85
|
|
|
60
|
-
###
|
|
86
|
+
### 6. Reserve Files
|
|
61
87
|
|
|
62
88
|
```
|
|
63
89
|
agentmail_reserve(paths=[<files>], reason="<bead-id>: <description>")
|
|
@@ -65,43 +91,56 @@ agentmail_reserve(paths=[<files>], reason="<bead-id>: <description>")
|
|
|
65
91
|
|
|
66
92
|
No two agents should edit the same file.
|
|
67
93
|
|
|
68
|
-
###
|
|
94
|
+
### 7. Spawn Agents
|
|
69
95
|
|
|
70
96
|
**CRITICAL: Spawn ALL in a SINGLE message with multiple Task calls.**
|
|
71
97
|
|
|
72
98
|
For each subtask:
|
|
73
99
|
|
|
74
100
|
```
|
|
75
|
-
swarm_spawn_subtask(
|
|
101
|
+
swarm_spawn_subtask(
|
|
102
|
+
bead_id="<id>",
|
|
103
|
+
epic_id="<epic>",
|
|
104
|
+
subtask_title="<title>",
|
|
105
|
+
files=[...],
|
|
106
|
+
shared_context="<synthesized knowledge from step 2>"
|
|
107
|
+
)
|
|
76
108
|
```
|
|
77
109
|
|
|
78
110
|
Then spawn:
|
|
79
111
|
|
|
80
112
|
```
|
|
81
|
-
Task(subagent_type="swarm
|
|
113
|
+
Task(subagent_type="swarm/worker", description="<bead-title>", prompt="<from swarm_spawn_subtask>")
|
|
82
114
|
```
|
|
83
115
|
|
|
84
|
-
###
|
|
116
|
+
### 8. Monitor (unless --no-sync)
|
|
85
117
|
|
|
86
118
|
```
|
|
87
|
-
swarm_status(epic_id="<epic-id>")
|
|
119
|
+
swarm_status(epic_id="<epic-id>", project_key="$PWD")
|
|
88
120
|
agentmail_inbox()
|
|
89
121
|
```
|
|
90
122
|
|
|
123
|
+
**Intervention triggers:**
|
|
124
|
+
|
|
125
|
+
- Worker blocked >5 min → Check inbox, offer guidance
|
|
126
|
+
- File conflict → Mediate, reassign files
|
|
127
|
+
- Worker asking questions → Answer directly
|
|
128
|
+
- Scope creep → Redirect, create new bead for extras
|
|
129
|
+
|
|
91
130
|
If incompatibilities spotted, broadcast:
|
|
92
131
|
|
|
93
132
|
```
|
|
94
133
|
agentmail_send(to=["*"], subject="Coordinator Update", body="<guidance>", importance="high")
|
|
95
134
|
```
|
|
96
135
|
|
|
97
|
-
###
|
|
136
|
+
### 9. Complete
|
|
98
137
|
|
|
99
138
|
```
|
|
100
139
|
swarm_complete(project_key="$PWD", agent_name="<your-name>", bead_id="<epic-id>", summary="<done>", files_touched=[...])
|
|
101
140
|
beads_sync()
|
|
102
141
|
```
|
|
103
142
|
|
|
104
|
-
###
|
|
143
|
+
### 10. Create PR (unless --to-main)
|
|
105
144
|
|
|
106
145
|
```bash
|
|
107
146
|
gh pr create --title "feat: <epic title>" --body "## Summary\n<bullets>\n\n## Beads\n<list>"
|
|
@@ -109,10 +148,22 @@ gh pr create --title "feat: <epic title>" --body "## Summary\n<bullets>\n\n## Be
|
|
|
109
148
|
|
|
110
149
|
## Strategy Reference
|
|
111
150
|
|
|
112
|
-
| Strategy
|
|
113
|
-
|
|
|
114
|
-
| file-based
|
|
115
|
-
| feature-based
|
|
116
|
-
| risk-based
|
|
117
|
-
|
|
118
|
-
|
|
151
|
+
| Strategy | Best For | Keywords |
|
|
152
|
+
| -------------- | ------------------------ | ------------------------------------- |
|
|
153
|
+
| file-based | Refactoring, migrations | refactor, migrate, rename, update all |
|
|
154
|
+
| feature-based | New features | add, implement, build, create, new |
|
|
155
|
+
| risk-based | Bug fixes, security | fix, bug, security, critical, urgent |
|
|
156
|
+
| research-based | Investigation, discovery | research, investigate, explore, learn |
|
|
157
|
+
|
|
158
|
+
## Quick Checklist
|
|
159
|
+
|
|
160
|
+
- [ ] Knowledge gathered (semantic-memory, CASS, pdf-brain, skills)
|
|
161
|
+
- [ ] Strategy selected
|
|
162
|
+
- [ ] BeadTree validated (no file conflicts)
|
|
163
|
+
- [ ] Epic + subtasks created
|
|
164
|
+
- [ ] Files reserved
|
|
165
|
+
- [ ] Workers spawned in parallel
|
|
166
|
+
- [ ] Progress monitored
|
|
167
|
+
- [ ] PR created (or pushed to main)
|
|
168
|
+
|
|
169
|
+
Begin with knowledge gathering now.
|
|
@@ -6,161 +6,284 @@ tags:
|
|
|
6
6
|
- multi-agent
|
|
7
7
|
- coordination
|
|
8
8
|
tools:
|
|
9
|
+
- swarm_plan_prompt
|
|
9
10
|
- swarm_decompose
|
|
10
|
-
-
|
|
11
|
+
- swarm_validate_decomposition
|
|
11
12
|
- swarm_spawn_subtask
|
|
13
|
+
- swarm_complete
|
|
14
|
+
- swarm_status
|
|
15
|
+
- swarm_progress
|
|
16
|
+
- beads_create_epic
|
|
17
|
+
- beads_query
|
|
12
18
|
- agentmail_init
|
|
13
19
|
- agentmail_send
|
|
14
20
|
- agentmail_inbox
|
|
15
21
|
- agentmail_reserve
|
|
22
|
+
- agentmail_release
|
|
23
|
+
- semantic-memory_find
|
|
24
|
+
- cass_search
|
|
25
|
+
- pdf-brain_search
|
|
26
|
+
- skills_list
|
|
27
|
+
references:
|
|
28
|
+
- references/strategies.md
|
|
29
|
+
- references/coordinator-patterns.md
|
|
16
30
|
---
|
|
17
31
|
|
|
18
|
-
# Swarm Coordination
|
|
32
|
+
# Swarm Coordination
|
|
19
33
|
|
|
20
|
-
|
|
34
|
+
Multi-agent orchestration for parallel task execution. The coordinator breaks work into subtasks, spawns worker agents, monitors progress, and aggregates results.
|
|
21
35
|
|
|
22
|
-
## When to
|
|
36
|
+
## When to Swarm
|
|
23
37
|
|
|
24
|
-
|
|
38
|
+
**DO swarm when:**
|
|
25
39
|
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
- Time-to-completion matters
|
|
40
|
+
- Task touches 3+ files
|
|
41
|
+
- Natural parallel boundaries exist (frontend/backend/tests)
|
|
42
|
+
- Different specializations needed
|
|
43
|
+
- Time-to-completion matters
|
|
30
44
|
|
|
31
|
-
|
|
45
|
+
**DON'T swarm when:**
|
|
32
46
|
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
-
|
|
47
|
+
- Task is 1-2 files
|
|
48
|
+
- Heavy sequential dependencies
|
|
49
|
+
- Coordination overhead > benefit
|
|
50
|
+
- Tight feedback loop needed
|
|
36
51
|
|
|
37
|
-
|
|
52
|
+
**Heuristic:** If you can describe the task in one sentence without "and", don't swarm.
|
|
38
53
|
|
|
39
|
-
|
|
54
|
+
## Coordinator Workflow
|
|
40
55
|
|
|
41
|
-
|
|
56
|
+
### Phase 1: Knowledge Gathering (MANDATORY)
|
|
42
57
|
|
|
43
|
-
|
|
44
|
-
- Which parts can run in parallel vs sequentially?
|
|
45
|
-
- What are the file/module boundaries?
|
|
46
|
-
- Are there shared resources that need coordination?
|
|
58
|
+
Before decomposing, query ALL knowledge sources:
|
|
47
59
|
|
|
48
|
-
|
|
60
|
+
```typescript
|
|
61
|
+
// 1. Past learnings from this project
|
|
62
|
+
semantic - memory_find({ query: "<task keywords>", limit: 5 });
|
|
49
63
|
|
|
50
|
-
|
|
64
|
+
// 2. How similar tasks were solved before
|
|
65
|
+
cass_search({ query: "<task description>", limit: 5 });
|
|
51
66
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
├── Subtask 1: "Create auth API endpoints" (backend)
|
|
55
|
-
├── Subtask 2: "Build login/signup forms" (frontend)
|
|
56
|
-
├── Subtask 3: "Write auth integration tests" (testing)
|
|
57
|
-
└── Subtask 4: "Add auth documentation" (docs)
|
|
58
|
-
```
|
|
67
|
+
// 3. Design patterns and prior art
|
|
68
|
+
pdf - brain_search({ query: "<domain concepts>", limit: 5 });
|
|
59
69
|
|
|
60
|
-
|
|
70
|
+
// 4. Available skills to inject into workers
|
|
71
|
+
skills_list();
|
|
72
|
+
```
|
|
61
73
|
|
|
74
|
+
Synthesize findings into `shared_context` for workers.
|
|
75
|
+
|
|
76
|
+
### Phase 2: Decomposition
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
// Auto-select strategy and generate decomposition prompt
|
|
80
|
+
const plan = await swarm_plan_prompt({
|
|
81
|
+
task: "Add user authentication with OAuth",
|
|
82
|
+
max_subtasks: 5,
|
|
83
|
+
query_cass: true, // searches history
|
|
84
|
+
include_skills: true, // lists relevant skills
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Agent responds with BeadTree JSON, then validate
|
|
88
|
+
const validation = await swarm_validate_decomposition({
|
|
89
|
+
response: agentResponse,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Create epic + subtasks atomically
|
|
93
|
+
await beads_create_epic({
|
|
94
|
+
epic_title: "Add OAuth Authentication",
|
|
95
|
+
epic_description: "...",
|
|
96
|
+
subtasks: validation.subtasks,
|
|
97
|
+
});
|
|
62
98
|
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
99
|
+
|
|
100
|
+
### Phase 3: Spawn Workers
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
for (const subtask of subtasks) {
|
|
104
|
+
const prompt = await swarm_spawn_subtask({
|
|
105
|
+
bead_id: subtask.id,
|
|
106
|
+
epic_id: epic.id,
|
|
107
|
+
subtask_title: subtask.title,
|
|
108
|
+
subtask_description: subtask.description,
|
|
109
|
+
files: subtask.files,
|
|
110
|
+
shared_context: synthesizedContext,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// Spawn via Task tool
|
|
114
|
+
Task({
|
|
115
|
+
subagent_type: "swarm/worker",
|
|
116
|
+
prompt: prompt.worker_prompt,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
68
119
|
```
|
|
69
120
|
|
|
70
|
-
|
|
121
|
+
### Phase 4: Monitor & Intervene
|
|
71
122
|
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
├── Subtask D: "Write tests"
|
|
81
|
-
└── Subtask E: "Update docs"
|
|
123
|
+
```typescript
|
|
124
|
+
// Check progress
|
|
125
|
+
const status = await swarm_status({ epic_id, project_key });
|
|
126
|
+
|
|
127
|
+
// Check for messages
|
|
128
|
+
const inbox = await agentmail_inbox({ limit: 5 });
|
|
129
|
+
|
|
130
|
+
// Intervene if needed (see Intervention Patterns)
|
|
82
131
|
```
|
|
83
132
|
|
|
84
|
-
|
|
133
|
+
### Phase 5: Aggregate & Complete
|
|
85
134
|
|
|
86
|
-
|
|
135
|
+
- Verify all subtasks completed
|
|
136
|
+
- Run final verification (typecheck, tests)
|
|
137
|
+
- Close epic with summary
|
|
138
|
+
- Record outcomes for learning
|
|
87
139
|
|
|
88
|
-
|
|
89
|
-
2. **Respect reservations** - Don't edit files reserved by other agents
|
|
90
|
-
3. **Release when done** - Files auto-release on task completion
|
|
91
|
-
4. **Coordinate on shared files** - If you must edit a reserved file, send a message to the owning agent
|
|
140
|
+
## Decomposition Strategies
|
|
92
141
|
|
|
93
|
-
|
|
142
|
+
Four strategies, auto-selected by task keywords:
|
|
94
143
|
|
|
95
|
-
|
|
144
|
+
| Strategy | Best For | Keywords |
|
|
145
|
+
| ------------------ | ----------------------------- | ------------------------------------- |
|
|
146
|
+
| **file-based** | Refactoring, migrations | refactor, migrate, rename, update all |
|
|
147
|
+
| **feature-based** | New features, vertical slices | add, implement, build, create |
|
|
148
|
+
| **risk-based** | Bug fixes, security | fix, bug, security, critical |
|
|
149
|
+
| **research-based** | Investigation, discovery | research, investigate, explore |
|
|
96
150
|
|
|
97
|
-
|
|
98
|
-
agentmail_send(to: ["all"], subject: "API Complete", body: "Completed API endpoints, ready for frontend integration")
|
|
99
|
-
```
|
|
151
|
+
See `references/strategies.md` for full details.
|
|
100
152
|
|
|
101
|
-
|
|
153
|
+
## File Reservation Protocol
|
|
102
154
|
|
|
103
|
-
|
|
104
|
-
agentmail_send(to: ["frontend-agent"], subject: "Auth API Ready", body: "Auth API is at /api/auth/*, here's the spec...")
|
|
105
|
-
```
|
|
155
|
+
Workers MUST reserve files before editing:
|
|
106
156
|
|
|
107
|
-
|
|
157
|
+
```typescript
|
|
158
|
+
// Reserve (exclusive by default)
|
|
159
|
+
await agentmail_reserve({
|
|
160
|
+
paths: ["src/auth/**"],
|
|
161
|
+
reason: "bd-123: Auth service implementation",
|
|
162
|
+
ttl_seconds: 3600,
|
|
163
|
+
});
|
|
108
164
|
|
|
109
|
-
|
|
110
|
-
# Check inbox for updates (context-safe: max 5, no bodies)
|
|
111
|
-
agentmail_inbox()
|
|
165
|
+
// Work...
|
|
112
166
|
|
|
113
|
-
|
|
114
|
-
|
|
167
|
+
// Release (or let swarm_complete handle it)
|
|
168
|
+
await agentmail_release({ paths: ["src/auth/**"] });
|
|
115
169
|
```
|
|
116
170
|
|
|
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
|
-
|
|
171
|
+
**Rules:**
|
|
172
|
+
|
|
173
|
+
- No file overlap between subtasks
|
|
174
|
+
- Coordinator mediates conflicts
|
|
175
|
+
- `swarm_complete` auto-releases
|
|
176
|
+
|
|
177
|
+
## Communication Protocol
|
|
178
|
+
|
|
179
|
+
Workers communicate via Agent Mail with epic ID as thread:
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
// Progress update
|
|
183
|
+
agentmail_send({
|
|
184
|
+
to: ["coordinator"],
|
|
185
|
+
subject: "Auth API complete",
|
|
186
|
+
body: "Endpoints ready at /api/auth/*",
|
|
187
|
+
thread_id: epic_id,
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Blocker
|
|
191
|
+
agentmail_send({
|
|
192
|
+
to: ["coordinator"],
|
|
193
|
+
subject: "BLOCKED: Need DB schema",
|
|
194
|
+
body: "Can't proceed without users table",
|
|
195
|
+
thread_id: epic_id,
|
|
196
|
+
importance: "urgent",
|
|
197
|
+
});
|
|
142
198
|
```
|
|
143
199
|
|
|
144
|
-
|
|
200
|
+
**Coordinator checks inbox regularly** - don't let workers spin.
|
|
201
|
+
|
|
202
|
+
## Intervention Patterns
|
|
203
|
+
|
|
204
|
+
| Signal | Action |
|
|
205
|
+
| ----------------------- | ------------------------------------ |
|
|
206
|
+
| Worker blocked >5 min | Check inbox, offer guidance |
|
|
207
|
+
| File conflict | Mediate, reassign files |
|
|
208
|
+
| Worker asking questions | Answer directly |
|
|
209
|
+
| Scope creep | Redirect, create new bead for extras |
|
|
210
|
+
| Repeated failures | Take over or reassign |
|
|
211
|
+
|
|
212
|
+
## Failure Recovery
|
|
213
|
+
|
|
214
|
+
### Incompatible Outputs
|
|
215
|
+
|
|
216
|
+
Two workers produce conflicting results.
|
|
145
217
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
218
|
+
**Fix:** Pick one approach, re-run other with constraint.
|
|
219
|
+
|
|
220
|
+
### Worker Drift
|
|
221
|
+
|
|
222
|
+
Worker implements something different than asked.
|
|
223
|
+
|
|
224
|
+
**Fix:** Revert, re-run with explicit instructions.
|
|
225
|
+
|
|
226
|
+
### Cascade Failure
|
|
227
|
+
|
|
228
|
+
One blocker affects multiple subtasks.
|
|
229
|
+
|
|
230
|
+
**Fix:** Unblock manually, reassign dependent work, accept partial completion.
|
|
231
|
+
|
|
232
|
+
## Anti-Patterns
|
|
233
|
+
|
|
234
|
+
| Anti-Pattern | Symptom | Fix |
|
|
235
|
+
| -------------------- | -------------------------------- | ----------------------------- |
|
|
236
|
+
| **Mega-Coordinator** | Coordinator editing files | Coordinator only orchestrates |
|
|
237
|
+
| **Silent Swarm** | No communication, late conflicts | Require updates, check inbox |
|
|
238
|
+
| **Over-Decomposed** | 10 subtasks for 20 lines | 2-5 subtasks max |
|
|
239
|
+
| **Under-Specified** | "Implement backend" | Clear goal, files, criteria |
|
|
240
|
+
|
|
241
|
+
## Shared Context Template
|
|
242
|
+
|
|
243
|
+
```markdown
|
|
244
|
+
## Project Context
|
|
245
|
+
|
|
246
|
+
- Repository: {repo}
|
|
247
|
+
- Stack: {tech stack}
|
|
248
|
+
- Patterns: {from pdf-brain}
|
|
249
|
+
|
|
250
|
+
## Task Context
|
|
251
|
+
|
|
252
|
+
- Epic: {title}
|
|
253
|
+
- Goal: {success criteria}
|
|
254
|
+
- Constraints: {scope, time}
|
|
255
|
+
|
|
256
|
+
## Prior Art
|
|
257
|
+
|
|
258
|
+
- Similar tasks: {from CASS}
|
|
259
|
+
- Learnings: {from semantic-memory}
|
|
260
|
+
|
|
261
|
+
## Coordination
|
|
262
|
+
|
|
263
|
+
- Active subtasks: {list}
|
|
264
|
+
- Reserved files: {list}
|
|
265
|
+
- Thread: {epic_id}
|
|
154
266
|
```
|
|
155
267
|
|
|
156
|
-
|
|
268
|
+
## Quick Reference
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
// Full swarm flow
|
|
272
|
+
semantic - memory_find({ query }); // 1. Check learnings
|
|
273
|
+
cass_search({ query }); // 2. Check history
|
|
274
|
+
pdf - brain_search({ query }); // 3. Check patterns
|
|
275
|
+
skills_list(); // 4. Check skills
|
|
276
|
+
|
|
277
|
+
swarm_plan_prompt({ task }); // 5. Generate decomposition
|
|
278
|
+
swarm_validate_decomposition(); // 6. Validate
|
|
279
|
+
beads_create_epic(); // 7. Create beads
|
|
157
280
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
- update-imports
|
|
165
|
-
- run-full-test-suite
|
|
281
|
+
swarm_spawn_subtask(); // 8. Spawn workers (loop)
|
|
282
|
+
swarm_status(); // 9. Monitor
|
|
283
|
+
agentmail_inbox(); // 10. Check messages
|
|
284
|
+
|
|
285
|
+
// Workers complete with:
|
|
286
|
+
swarm_complete(); // Auto: close bead, release files, notify
|
|
166
287
|
```
|
|
288
|
+
|
|
289
|
+
See `references/coordinator-patterns.md` for detailed patterns.
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
# Coordinator Patterns
|
|
2
|
+
|
|
3
|
+
The coordinator is the orchestration layer that manages the swarm. This document covers the coordinator's responsibilities, decision points, and intervention patterns.
|
|
4
|
+
|
|
5
|
+
## Coordinator Responsibilities
|
|
6
|
+
|
|
7
|
+
### 1. Knowledge Gathering (BEFORE decomposition)
|
|
8
|
+
|
|
9
|
+
**MANDATORY**: Before decomposing any task, the coordinator MUST query all available knowledge sources:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
# 1. Search semantic memory for past learnings
|
|
13
|
+
semantic-memory_find(query="<task keywords>", limit=5)
|
|
14
|
+
|
|
15
|
+
# 2. Search CASS for similar past tasks
|
|
16
|
+
cass_search(query="<task description>", limit=5)
|
|
17
|
+
|
|
18
|
+
# 3. Search pdf-brain for design patterns and prior art
|
|
19
|
+
pdf-brain_search(query="<domain concepts>", limit=5)
|
|
20
|
+
|
|
21
|
+
# 4. List available skills
|
|
22
|
+
skills_list()
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Why this matters:** From "Patterns for Building AI Agents":
|
|
26
|
+
|
|
27
|
+
> "AI agents, like people, make better decisions when they understand the full context rather than working from fragments."
|
|
28
|
+
|
|
29
|
+
The coordinator synthesizes findings into `shared_context` that all workers receive.
|
|
30
|
+
|
|
31
|
+
### 2. Task Decomposition
|
|
32
|
+
|
|
33
|
+
After knowledge gathering:
|
|
34
|
+
|
|
35
|
+
1. Select strategy (auto or explicit)
|
|
36
|
+
2. Generate decomposition with `swarm_plan_prompt` or `swarm_decompose`
|
|
37
|
+
3. Validate with `swarm_validate_decomposition`
|
|
38
|
+
4. Create beads with `beads_create_epic`
|
|
39
|
+
|
|
40
|
+
### 3. Worker Spawning
|
|
41
|
+
|
|
42
|
+
For each subtask:
|
|
43
|
+
|
|
44
|
+
1. Generate worker prompt with `swarm_spawn_subtask`
|
|
45
|
+
2. Include relevant skills in prompt
|
|
46
|
+
3. Spawn worker agent via Task tool
|
|
47
|
+
4. Track bead status
|
|
48
|
+
|
|
49
|
+
### 4. Progress Monitoring
|
|
50
|
+
|
|
51
|
+
- Check `beads_query(status="in_progress")` for active work
|
|
52
|
+
- Check `agentmail_inbox()` for worker messages
|
|
53
|
+
- Intervene on blockers (see Intervention Patterns below)
|
|
54
|
+
|
|
55
|
+
### 5. Completion & Aggregation
|
|
56
|
+
|
|
57
|
+
- Verify all subtasks completed via bead status
|
|
58
|
+
- Aggregate results from worker summaries
|
|
59
|
+
- Run final verification (typecheck, tests)
|
|
60
|
+
- Close epic bead with summary
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Decision Points
|
|
65
|
+
|
|
66
|
+
### When to Swarm vs Single Agent
|
|
67
|
+
|
|
68
|
+
**Swarm when:**
|
|
69
|
+
|
|
70
|
+
- 3+ files need modification
|
|
71
|
+
- Task has natural parallel boundaries
|
|
72
|
+
- Different specializations needed (frontend/backend/tests)
|
|
73
|
+
- Time-to-completion matters
|
|
74
|
+
|
|
75
|
+
**Single agent when:**
|
|
76
|
+
|
|
77
|
+
- Task touches 1-2 files
|
|
78
|
+
- Heavy sequential dependencies
|
|
79
|
+
- Coordination overhead > parallelization benefit
|
|
80
|
+
- Task requires tight feedback loop
|
|
81
|
+
|
|
82
|
+
**Heuristic:** If you can describe the task in one sentence without "and", probably single agent.
|
|
83
|
+
|
|
84
|
+
### When to Intervene
|
|
85
|
+
|
|
86
|
+
| Signal | Action |
|
|
87
|
+
| ------------------------- | ----------------------------------------------------- |
|
|
88
|
+
| Worker blocked >5 min | Check inbox, offer guidance |
|
|
89
|
+
| File conflict detected | Mediate, reassign files |
|
|
90
|
+
| Worker asking questions | Answer directly, don't spawn new agent |
|
|
91
|
+
| Scope creep detected | Redirect to original task, create new bead for extras |
|
|
92
|
+
| Worker failing repeatedly | Take over subtask or reassign |
|
|
93
|
+
|
|
94
|
+
### When to Abort
|
|
95
|
+
|
|
96
|
+
- Critical blocker affects all subtasks
|
|
97
|
+
- Scope changed fundamentally mid-swarm
|
|
98
|
+
- Resource exhaustion (context, time, cost)
|
|
99
|
+
|
|
100
|
+
On abort: Close all beads with reason, summarize partial progress.
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## Context Engineering
|
|
105
|
+
|
|
106
|
+
From "Patterns for Building AI Agents":
|
|
107
|
+
|
|
108
|
+
> "Instead of just instructing subagents 'Do this specific task,' you should try to ensure they are able to share context along the way."
|
|
109
|
+
|
|
110
|
+
### Shared Context Template
|
|
111
|
+
|
|
112
|
+
```markdown
|
|
113
|
+
## Project Context
|
|
114
|
+
|
|
115
|
+
- Repository: {repo_name}
|
|
116
|
+
- Tech stack: {stack}
|
|
117
|
+
- Relevant patterns: {patterns from pdf-brain}
|
|
118
|
+
|
|
119
|
+
## Task Context
|
|
120
|
+
|
|
121
|
+
- Epic: {epic_title}
|
|
122
|
+
- Goal: {what success looks like}
|
|
123
|
+
- Constraints: {time, scope, dependencies}
|
|
124
|
+
|
|
125
|
+
## Prior Art
|
|
126
|
+
|
|
127
|
+
- Similar past tasks: {from CASS}
|
|
128
|
+
- Relevant learnings: {from semantic-memory}
|
|
129
|
+
|
|
130
|
+
## Coordination
|
|
131
|
+
|
|
132
|
+
- Other active subtasks: {list}
|
|
133
|
+
- Shared files to avoid: {reserved files}
|
|
134
|
+
- Communication channel: thread_id={epic_id}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Context Compression
|
|
138
|
+
|
|
139
|
+
For long-running swarms, compress context periodically:
|
|
140
|
+
|
|
141
|
+
- Summarize completed subtasks (don't list all details)
|
|
142
|
+
- Keep only active blockers and decisions
|
|
143
|
+
- Preserve key learnings for remaining work
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Failure Modes & Recovery
|
|
148
|
+
|
|
149
|
+
### Incompatible Parallel Outputs
|
|
150
|
+
|
|
151
|
+
**Problem:** Two agents produce conflicting results that can't be merged.
|
|
152
|
+
|
|
153
|
+
**From "Patterns for Building AI Agents":**
|
|
154
|
+
|
|
155
|
+
> "Subagents can create responses that are in conflict — forcing the final agent to combine two incompatible, intermediate products."
|
|
156
|
+
|
|
157
|
+
**Prevention:**
|
|
158
|
+
|
|
159
|
+
- Clear file boundaries (no overlap)
|
|
160
|
+
- Explicit interface contracts in shared_context
|
|
161
|
+
- Sequential phases for tightly coupled work
|
|
162
|
+
|
|
163
|
+
**Recovery:**
|
|
164
|
+
|
|
165
|
+
- Identify conflict source
|
|
166
|
+
- Pick one approach, discard other
|
|
167
|
+
- Re-run losing subtask with winning approach as constraint
|
|
168
|
+
|
|
169
|
+
### Worker Drift
|
|
170
|
+
|
|
171
|
+
**Problem:** Worker goes off-task, implements something different.
|
|
172
|
+
|
|
173
|
+
**Prevention:**
|
|
174
|
+
|
|
175
|
+
- Specific, actionable subtask descriptions
|
|
176
|
+
- Clear success criteria in prompt
|
|
177
|
+
- File list as hard constraint
|
|
178
|
+
|
|
179
|
+
**Recovery:**
|
|
180
|
+
|
|
181
|
+
- Revert changes
|
|
182
|
+
- Re-run with more explicit instructions
|
|
183
|
+
- Consider taking over manually
|
|
184
|
+
|
|
185
|
+
### Cascade Failure
|
|
186
|
+
|
|
187
|
+
**Problem:** One failure blocks multiple dependent subtasks.
|
|
188
|
+
|
|
189
|
+
**Prevention:**
|
|
190
|
+
|
|
191
|
+
- Minimize dependencies in decomposition
|
|
192
|
+
- Front-load risky/uncertain work
|
|
193
|
+
- Have fallback plans for critical paths
|
|
194
|
+
|
|
195
|
+
**Recovery:**
|
|
196
|
+
|
|
197
|
+
- Unblock manually if possible
|
|
198
|
+
- Reassign dependent work
|
|
199
|
+
- Partial completion is okay - close what's done
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Anti-Patterns
|
|
204
|
+
|
|
205
|
+
### The Mega-Coordinator
|
|
206
|
+
|
|
207
|
+
**Problem:** Coordinator does too much work itself instead of delegating.
|
|
208
|
+
|
|
209
|
+
**Symptom:** Coordinator editing files, running tests, debugging.
|
|
210
|
+
|
|
211
|
+
**Fix:** Coordinator only orchestrates. If you're writing code, you're a worker.
|
|
212
|
+
|
|
213
|
+
### The Silent Swarm
|
|
214
|
+
|
|
215
|
+
**Problem:** Workers don't communicate, coordinator doesn't monitor.
|
|
216
|
+
|
|
217
|
+
**Symptom:** Swarm runs for 30 minutes, then fails with conflicts.
|
|
218
|
+
|
|
219
|
+
**Fix:** Require progress updates. Check inbox regularly. Intervene early.
|
|
220
|
+
|
|
221
|
+
### The Over-Decomposed Task
|
|
222
|
+
|
|
223
|
+
**Problem:** 10 subtasks for a 20-line change.
|
|
224
|
+
|
|
225
|
+
**Symptom:** Coordination overhead exceeds actual work.
|
|
226
|
+
|
|
227
|
+
**Fix:** 2-5 subtasks is the sweet spot. If task is small, don't swarm.
|
|
228
|
+
|
|
229
|
+
### The Under-Specified Subtask
|
|
230
|
+
|
|
231
|
+
**Problem:** "Implement the backend" with no details.
|
|
232
|
+
|
|
233
|
+
**Symptom:** Worker asks questions, guesses wrong, or stalls.
|
|
234
|
+
|
|
235
|
+
**Fix:** Each subtask needs: clear goal, file list, success criteria, context.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Decomposition Strategies
|
|
2
|
+
|
|
3
|
+
Four strategies for breaking tasks into parallelizable subtasks. The coordinator auto-selects based on task keywords, or you can specify explicitly.
|
|
4
|
+
|
|
5
|
+
## File-Based Strategy
|
|
6
|
+
|
|
7
|
+
**Best for:** Refactoring, migrations, pattern changes across codebase
|
|
8
|
+
|
|
9
|
+
**Keywords:** refactor, migrate, update all, rename, replace, convert, upgrade, deprecate, remove, cleanup, lint, format
|
|
10
|
+
|
|
11
|
+
### Guidelines
|
|
12
|
+
|
|
13
|
+
- Group files by directory or type (e.g., all components, all tests)
|
|
14
|
+
- Minimize cross-directory dependencies within a subtask
|
|
15
|
+
- Handle shared types/utilities FIRST if they change
|
|
16
|
+
- Each subtask should be a complete transformation of its file set
|
|
17
|
+
- Consider import/export relationships when grouping
|
|
18
|
+
|
|
19
|
+
### Anti-Patterns
|
|
20
|
+
|
|
21
|
+
- Don't split tightly coupled files across subtasks
|
|
22
|
+
- Don't group files that have no relationship
|
|
23
|
+
- Don't forget to update imports when moving/renaming
|
|
24
|
+
|
|
25
|
+
### Examples
|
|
26
|
+
|
|
27
|
+
| Task | Decomposition |
|
|
28
|
+
| ----------------------------------- | --------------------------------------------- |
|
|
29
|
+
| Migrate all components to new API | Split by component directory |
|
|
30
|
+
| Rename `userId` to `accountId` | Split by module (types first, then consumers) |
|
|
31
|
+
| Update all tests to use new matcher | Split by test directory |
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Feature-Based Strategy
|
|
36
|
+
|
|
37
|
+
**Best for:** New features, adding functionality, vertical slices
|
|
38
|
+
|
|
39
|
+
**Keywords:** add, implement, build, create, feature, new, integrate, connect, enable, support
|
|
40
|
+
|
|
41
|
+
### Guidelines
|
|
42
|
+
|
|
43
|
+
- Each subtask is a complete vertical slice (UI + logic + data)
|
|
44
|
+
- Start with data layer/types, then logic, then UI
|
|
45
|
+
- Keep related components together (form + validation + submission)
|
|
46
|
+
- Separate concerns that can be developed independently
|
|
47
|
+
- Consider user-facing features as natural boundaries
|
|
48
|
+
|
|
49
|
+
### Anti-Patterns
|
|
50
|
+
|
|
51
|
+
- Don't split a single feature across multiple subtasks
|
|
52
|
+
- Don't create subtasks that can't be tested independently
|
|
53
|
+
- Don't forget integration points between features
|
|
54
|
+
|
|
55
|
+
### Examples
|
|
56
|
+
|
|
57
|
+
| Task | Decomposition |
|
|
58
|
+
| --------------- | ---------------------------------------------------- |
|
|
59
|
+
| Add user auth | [OAuth setup, Session management, Protected routes] |
|
|
60
|
+
| Build dashboard | [Data fetching, Chart components, Layout/navigation] |
|
|
61
|
+
| Add search | [Search API, Search UI, Results display] |
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Risk-Based Strategy
|
|
66
|
+
|
|
67
|
+
**Best for:** Bug fixes, security issues, critical changes, hotfixes
|
|
68
|
+
|
|
69
|
+
**Keywords:** fix, bug, security, vulnerability, critical, urgent, hotfix, patch, audit, review
|
|
70
|
+
|
|
71
|
+
### Guidelines
|
|
72
|
+
|
|
73
|
+
- Write tests FIRST to capture expected behavior
|
|
74
|
+
- Isolate the risky change to minimize blast radius
|
|
75
|
+
- Add monitoring/logging around the change
|
|
76
|
+
- Create rollback plan as part of the task
|
|
77
|
+
- Audit similar code for the same issue
|
|
78
|
+
|
|
79
|
+
### Anti-Patterns
|
|
80
|
+
|
|
81
|
+
- Don't make multiple risky changes in one subtask
|
|
82
|
+
- Don't skip tests for "simple" fixes
|
|
83
|
+
- Don't forget to check for similar issues elsewhere
|
|
84
|
+
|
|
85
|
+
### Examples
|
|
86
|
+
|
|
87
|
+
| Task | Decomposition |
|
|
88
|
+
| ------------------ | ------------------------------------------------------------------------- |
|
|
89
|
+
| Fix auth bypass | [Add regression test, Fix vulnerability, Audit similar endpoints] |
|
|
90
|
+
| Fix race condition | [Add test reproducing issue, Implement fix, Add concurrency tests] |
|
|
91
|
+
| Security audit | [Scan for vulnerabilities, Fix critical issues, Document remaining risks] |
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Research-Based Strategy
|
|
96
|
+
|
|
97
|
+
**Best for:** Investigation, learning, discovery, debugging options
|
|
98
|
+
|
|
99
|
+
**Keywords:** research, investigate, explore, find out, discover, understand, learn about, analyze, compare, evaluate, study, debug options, configuration options
|
|
100
|
+
|
|
101
|
+
### Guidelines
|
|
102
|
+
|
|
103
|
+
- Split by information source (PDFs, repos, history, web)
|
|
104
|
+
- Each agent searches with different query angles
|
|
105
|
+
- Include a synthesis subtask that depends on all search subtasks
|
|
106
|
+
- Use pdf-brain for documentation/books if available
|
|
107
|
+
- Use repo-crawl for GitHub repos if URL provided
|
|
108
|
+
- Use CASS for past agent session history
|
|
109
|
+
- Assign NO files to research subtasks (read-only)
|
|
110
|
+
|
|
111
|
+
### Anti-Patterns
|
|
112
|
+
|
|
113
|
+
- Don't have one agent search everything sequentially
|
|
114
|
+
- Don't skip synthesis - raw search results need consolidation
|
|
115
|
+
- Don't forget to check tool availability before assigning sources
|
|
116
|
+
|
|
117
|
+
### Examples
|
|
118
|
+
|
|
119
|
+
| Task | Decomposition |
|
|
120
|
+
| ---------------------- | ---------------------------------------------------------------------------- |
|
|
121
|
+
| Research auth patterns | [Search PDFs, Search repos, Search history, Synthesize] |
|
|
122
|
+
| Investigate error | [Search CASS for similar errors, Search repo for error handling, Synthesize] |
|
|
123
|
+
| Learn about library | [Search docs, Search examples, Search issues, Synthesize findings] |
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Strategy Selection
|
|
128
|
+
|
|
129
|
+
The coordinator auto-selects strategy by matching task keywords. Override with explicit strategy when:
|
|
130
|
+
|
|
131
|
+
- Task spans multiple categories (e.g., "fix bug and add feature")
|
|
132
|
+
- You have domain knowledge the keywords don't capture
|
|
133
|
+
- Past experience suggests a different approach
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
swarm_plan_prompt(task="...", strategy="risk-based") // explicit override
|
|
137
|
+
swarm_plan_prompt(task="...") // auto-select
|
|
138
|
+
```
|
package/package.json
CHANGED