opencode-swarm-plugin 0.12.30 → 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/bin/swarm.ts +120 -31
- package/examples/commands/swarm.md +70 -19
- package/package.json +1 -1
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.
|
package/package.json
CHANGED