opencode-swarm-plugin 0.12.31 → 0.13.1

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.
Files changed (49) hide show
  1. package/.beads/issues.jsonl +204 -10
  2. package/.opencode/skills/tdd/SKILL.md +182 -0
  3. package/README.md +165 -17
  4. package/bun.lock +23 -0
  5. package/dist/index.js +4082 -457
  6. package/dist/pglite.data +0 -0
  7. package/dist/pglite.wasm +0 -0
  8. package/dist/plugin.js +4070 -533
  9. package/examples/commands/swarm.md +100 -28
  10. package/examples/skills/beads-workflow/SKILL.md +75 -28
  11. package/examples/skills/swarm-coordination/SKILL.md +165 -21
  12. package/global-skills/swarm-coordination/SKILL.md +116 -58
  13. package/global-skills/testing-patterns/SKILL.md +430 -0
  14. package/global-skills/testing-patterns/references/dependency-breaking-catalog.md +586 -0
  15. package/package.json +11 -5
  16. package/src/index.ts +44 -5
  17. package/src/streams/agent-mail.test.ts +777 -0
  18. package/src/streams/agent-mail.ts +535 -0
  19. package/src/streams/debug.test.ts +500 -0
  20. package/src/streams/debug.ts +629 -0
  21. package/src/streams/effect/ask.integration.test.ts +314 -0
  22. package/src/streams/effect/ask.ts +202 -0
  23. package/src/streams/effect/cursor.integration.test.ts +418 -0
  24. package/src/streams/effect/cursor.ts +288 -0
  25. package/src/streams/effect/deferred.test.ts +357 -0
  26. package/src/streams/effect/deferred.ts +445 -0
  27. package/src/streams/effect/index.ts +17 -0
  28. package/src/streams/effect/layers.ts +73 -0
  29. package/src/streams/effect/lock.test.ts +385 -0
  30. package/src/streams/effect/lock.ts +399 -0
  31. package/src/streams/effect/mailbox.test.ts +260 -0
  32. package/src/streams/effect/mailbox.ts +318 -0
  33. package/src/streams/events.test.ts +628 -0
  34. package/src/streams/events.ts +214 -0
  35. package/src/streams/index.test.ts +229 -0
  36. package/src/streams/index.ts +492 -0
  37. package/src/streams/migrations.test.ts +355 -0
  38. package/src/streams/migrations.ts +269 -0
  39. package/src/streams/projections.test.ts +611 -0
  40. package/src/streams/projections.ts +302 -0
  41. package/src/streams/store.integration.test.ts +548 -0
  42. package/src/streams/store.ts +546 -0
  43. package/src/streams/swarm-mail.ts +552 -0
  44. package/src/swarm-mail.integration.test.ts +970 -0
  45. package/src/swarm-mail.ts +739 -0
  46. package/src/swarm.integration.test.ts +16 -10
  47. package/src/swarm.ts +146 -78
  48. package/src/tool-availability.ts +35 -2
  49. package/global-skills/mcp-tool-authoring/SKILL.md +0 -695
@@ -15,19 +15,31 @@ $ARGUMENTS
15
15
 
16
16
  **Default: Feature branch + PR with context sync.**
17
17
 
18
+ ## MANDATORY: Swarm Mail
19
+
20
+ **ALL coordination MUST use `swarmmail_*` tools.** This is non-negotiable.
21
+
22
+ Swarm Mail is embedded (no external server needed) and provides:
23
+
24
+ - File reservations to prevent conflicts
25
+ - Message passing between agents
26
+ - Thread-based coordination tied to beads
27
+
18
28
  ## Workflow
19
29
 
20
- ### 1. Initialize
30
+ ### 1. Initialize Swarm Mail (FIRST)
21
31
 
22
- ```
23
- agentmail_init(project_path="$PWD", task_description="Swarm: <task summary>")
32
+ ```bash
33
+ swarmmail_init(project_path="$PWD", task_description="Swarm: <task summary>")
24
34
  ```
25
35
 
36
+ This registers you as the coordinator agent.
37
+
26
38
  ### 2. Knowledge Gathering (MANDATORY)
27
39
 
28
40
  **Before decomposing, query ALL knowledge sources:**
29
41
 
30
- ```
42
+ ```bash
31
43
  # Past learnings from this project
32
44
  semantic-memory_find(query="<task keywords>", limit=5)
33
45
 
@@ -41,12 +53,28 @@ pdf-brain_search(query="<domain concepts>", limit=5)
41
53
  skills_list()
42
54
  ```
43
55
 
56
+ **Load coordinator skills based on task type:**
57
+
58
+ ```bash
59
+ # For swarm coordination (ALWAYS load this)
60
+ skills_use(name="swarm-coordination")
61
+
62
+ # For architectural decisions
63
+ skills_use(name="system-design")
64
+
65
+ # If task involves testing
66
+ skills_use(name="testing-patterns")
67
+
68
+ # If building CLI tools
69
+ skills_use(name="cli-builder")
70
+ ```
71
+
44
72
  Synthesize findings into shared context for workers. Note:
45
73
 
46
74
  - Relevant patterns from pdf-brain
47
75
  - Similar past approaches from CASS
48
76
  - Project-specific learnings from semantic-memory
49
- - Skills to recommend for subtasks
77
+ - **Skills to recommend for each subtask** (critical for worker effectiveness)
50
78
 
51
79
  ### 3. Create Feature Branch (unless --to-main)
52
80
 
@@ -59,20 +87,20 @@ git push -u origin HEAD
59
87
 
60
88
  Use strategy selection and planning:
61
89
 
62
- ```
90
+ ```bash
63
91
  swarm_select_strategy(task="<the task>")
64
92
  swarm_plan_prompt(task="<the task>", strategy="<auto or selected>", context="<synthesized knowledge>")
65
93
  ```
66
94
 
67
95
  Follow the prompt to create a BeadTree, then validate:
68
96
 
69
- ```
97
+ ```bash
70
98
  swarm_validate_decomposition(response="<your BeadTree JSON>")
71
99
  ```
72
100
 
73
101
  ### 5. Create Beads
74
102
 
75
- ```
103
+ ```bash
76
104
  beads_create_epic(epic_title="<task>", subtasks=[{title, files, priority}...])
77
105
  ```
78
106
 
@@ -83,13 +111,13 @@ Rules:
83
111
  - 3-7 beads per swarm
84
112
  - No file overlap between subtasks
85
113
 
86
- ### 6. Reserve Files
114
+ ### 6. Reserve Files (via Swarm Mail)
87
115
 
88
- ```
89
- agentmail_reserve(paths=[<files>], reason="<bead-id>: <description>")
116
+ ```bash
117
+ swarmmail_reserve(paths=[<files>], reason="<bead-id>: <description>", ttl_seconds=3600)
90
118
  ```
91
119
 
92
- No two agents should edit the same file.
120
+ No two agents should edit the same file. Reservations prevent conflicts.
93
121
 
94
122
  ### 7. Spawn Agents
95
123
 
@@ -97,7 +125,7 @@ No two agents should edit the same file.
97
125
 
98
126
  For each subtask:
99
127
 
100
- ```
128
+ ```bash
101
129
  swarm_spawn_subtask(
102
130
  bead_id="<id>",
103
131
  epic_id="<epic>",
@@ -107,17 +135,33 @@ swarm_spawn_subtask(
107
135
  )
108
136
  ```
109
137
 
110
- Then spawn:
138
+ **Include skill recommendations in shared_context:**
139
+
140
+ ```markdown
141
+ ## Recommended Skills
142
+
143
+ Load these skills before starting work:
111
144
 
145
+ - skills_use(name="testing-patterns") - if adding tests or breaking dependencies
146
+ - skills_use(name="swarm-coordination") - if coordinating with other agents
147
+ - skills_use(name="system-design") - if making architectural decisions
148
+ - skills_use(name="cli-builder") - if working on CLI components
149
+
150
+ See full skill list with skills_list().
112
151
  ```
152
+
153
+ Then spawn:
154
+
155
+ ```bash
113
156
  Task(subagent_type="swarm/worker", description="<bead-title>", prompt="<from swarm_spawn_subtask>")
114
157
  ```
115
158
 
116
159
  ### 8. Monitor (unless --no-sync)
117
160
 
118
- ```
161
+ ```bash
119
162
  swarm_status(epic_id="<epic-id>", project_key="$PWD")
120
- agentmail_inbox()
163
+ swarmmail_inbox() # Check for worker messages
164
+ swarmmail_read_message(message_id=N) # Read specific message
121
165
  ```
122
166
 
123
167
  **Intervention triggers:**
@@ -129,14 +173,15 @@ agentmail_inbox()
129
173
 
130
174
  If incompatibilities spotted, broadcast:
131
175
 
132
- ```
133
- agentmail_send(to=["*"], subject="Coordinator Update", body="<guidance>", importance="high")
176
+ ```bash
177
+ swarmmail_send(to=["*"], subject="Coordinator Update", body="<guidance>", importance="high", thread_id="<epic-id>")
134
178
  ```
135
179
 
136
180
  ### 9. Complete
137
181
 
138
- ```
182
+ ```bash
139
183
  swarm_complete(project_key="$PWD", agent_name="<your-name>", bead_id="<epic-id>", summary="<done>", files_touched=[...])
184
+ swarmmail_release() # Release any remaining reservations
140
185
  beads_sync()
141
186
  ```
142
187
 
@@ -146,24 +191,51 @@ beads_sync()
146
191
  gh pr create --title "feat: <epic title>" --body "## Summary\n<bullets>\n\n## Beads\n<list>"
147
192
  ```
148
193
 
194
+ ## Swarm Mail Quick Reference
195
+
196
+ | Tool | Purpose |
197
+ | ------------------------ | ----------------------------------- |
198
+ | `swarmmail_init` | Initialize session (REQUIRED FIRST) |
199
+ | `swarmmail_send` | Send message to agents |
200
+ | `swarmmail_inbox` | Check inbox (max 5, no bodies) |
201
+ | `swarmmail_read_message` | Read specific message body |
202
+ | `swarmmail_reserve` | Reserve files for exclusive editing |
203
+ | `swarmmail_release` | Release file reservations |
204
+ | `swarmmail_ack` | Acknowledge message |
205
+ | `swarmmail_health` | Check database health |
206
+
149
207
  ## Strategy Reference
150
208
 
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 |
209
+ | Strategy | Best For | Keywords | Recommended Skills |
210
+ | -------------- | ------------------------ | ------------------------------------- | --------------------------------- |
211
+ | file-based | Refactoring, migrations | refactor, migrate, rename, update all | system-design, testing-patterns |
212
+ | feature-based | New features | add, implement, build, create, new | system-design, swarm-coordination |
213
+ | risk-based | Bug fixes, security | fix, bug, security, critical, urgent | testing-patterns |
214
+ | research-based | Investigation, discovery | research, investigate, explore, learn | system-design |
215
+
216
+ ## Skill Triggers (Auto-load based on task type)
217
+
218
+ **Task Analysis** → Recommend these skills in shared_context:
219
+
220
+ | Task Pattern | Skills to Load |
221
+ | ---------------------- | ------------------------------------------------------- |
222
+ | Contains "test" | `skills_use(name="testing-patterns")` |
223
+ | Contains "refactor" | `skills_use(name="testing-patterns")` + `system-design` |
224
+ | Contains "CLI" | `skills_use(name="cli-builder")` |
225
+ | Multi-agent work | `skills_use(name="swarm-coordination")` |
226
+ | Architecture decisions | `skills_use(name="system-design")` |
227
+ | Breaking dependencies | `skills_use(name="testing-patterns")` |
157
228
 
158
229
  ## Quick Checklist
159
230
 
231
+ - [ ] **swarmmail_init** called FIRST
160
232
  - [ ] Knowledge gathered (semantic-memory, CASS, pdf-brain, skills)
161
233
  - [ ] Strategy selected
162
234
  - [ ] BeadTree validated (no file conflicts)
163
235
  - [ ] Epic + subtasks created
164
- - [ ] Files reserved
236
+ - [ ] Files reserved via **swarmmail_reserve**
165
237
  - [ ] Workers spawned in parallel
166
- - [ ] Progress monitored
238
+ - [ ] Progress monitored via **swarmmail_inbox**
167
239
  - [ ] PR created (or pushed to main)
168
240
 
169
- Begin with knowledge gathering now.
241
+ Begin with swarmmail_init and knowledge gathering now.
@@ -11,60 +11,78 @@ tools:
11
11
  - beads_query
12
12
  - beads_update
13
13
  - beads_close
14
+ - beads_create_epic
15
+ - beads_sync
16
+ related_skills:
17
+ - swarm-coordination
14
18
  ---
15
19
 
16
20
  # Beads Workflow Skill
17
21
 
18
22
  Beads is a local-first issue tracking system designed for AI agents. This skill provides best practices for effective bead management.
19
23
 
24
+ **NOTE:** For swarm workflows, combine this skill with `swarm-coordination` from global-skills/.
25
+
20
26
  ## Bead Types
21
27
 
22
- | Type | When to Use |
23
- |------|-------------|
24
- | `bug` | Something is broken and needs fixing |
25
- | `feature` | New functionality to add |
26
- | `task` | General work item |
27
- | `chore` | Maintenance, refactoring, dependencies |
28
- | `epic` | Large initiative with multiple subtasks |
28
+ | Type | When to Use |
29
+ | --------- | --------------------------------------- |
30
+ | `bug` | Something is broken and needs fixing |
31
+ | `feature` | New functionality to add |
32
+ | `task` | General work item |
33
+ | `chore` | Maintenance, refactoring, dependencies |
34
+ | `epic` | Large initiative with multiple subtasks |
29
35
 
30
36
  ## Creating Effective Beads
31
37
 
32
38
  ### Good Bead Titles
39
+
40
+ ```text
33
41
  - "Fix null pointer exception in UserService.getProfile()"
34
42
  - "Add dark mode toggle to settings page"
35
43
  - "Migrate auth tokens from localStorage to httpOnly cookies"
44
+ ```
36
45
 
37
46
  ### Bad Bead Titles
47
+
48
+ ```text
38
49
  - "Fix bug" (too vague)
39
50
  - "Make it better" (not actionable)
40
51
  - "stuff" (meaningless)
52
+ ```
41
53
 
42
54
  ### Bead Body Structure
43
55
 
44
56
  ```markdown
45
57
  ## Problem
58
+
46
59
  [Clear description of the issue or need]
47
60
 
48
61
  ## Expected Behavior
62
+
49
63
  [What should happen]
50
64
 
51
65
  ## Current Behavior
66
+
52
67
  [What currently happens, for bugs]
53
68
 
54
69
  ## Proposed Solution
70
+
55
71
  [How to fix/implement, if known]
56
72
 
57
73
  ## Acceptance Criteria
74
+
58
75
  - [ ] Criterion 1
59
76
  - [ ] Criterion 2
60
77
 
61
78
  ## Notes
79
+
62
80
  [Any additional context, links, or constraints]
63
81
  ```
64
82
 
65
83
  ## Workflow States
66
84
 
67
- ```
85
+ ```text
68
86
  open → in_progress → closed
69
87
 
70
88
  blocked (optional)
@@ -72,38 +90,47 @@ open → in_progress → closed
72
90
 
73
91
  ### State Transitions
74
92
 
75
- **Open → In Progress**
76
- ```
93
+ ### Open → In Progress
94
+
95
+ ```typescript
77
96
  beads_update(id: "abc123", state: "in_progress")
78
97
  ```
98
+
79
99
  Use when you start working on a bead.
80
100
 
81
- **In Progress → Closed**
82
- ```
101
+ ### In Progress → Closed
102
+
103
+ ```typescript
83
104
  beads_close(id: "abc123", resolution: "Fixed in commit abc1234")
84
105
  ```
106
+
85
107
  Use when work is complete.
86
108
 
87
- **In Progress → Blocked**
88
- ```
109
+ ### In Progress → Blocked
110
+
111
+ ```typescript
89
112
  beads_update(id: "abc123", state: "blocked", body: "Blocked by #xyz789")
90
113
  ```
114
+
91
115
  Use when you can't proceed due to a dependency.
92
116
 
93
117
  ## Querying Beads
94
118
 
95
119
  ### Find Open Work
96
- ```
120
+
121
+ ```typescript
97
122
  beads_query(state: "open", type: "bug")
98
123
  ```
99
124
 
100
125
  ### Search by Keywords
101
- ```
126
+
127
+ ```typescript
102
128
  beads_query(search: "authentication")
103
129
  ```
104
130
 
105
131
  ### List Recent Activity
106
- ```
132
+
133
+ ```typescript
107
134
  beads_query(limit: 10, sort: "updated")
108
135
  ```
109
136
 
@@ -118,9 +145,11 @@ title: User Authentication Overhaul
118
145
  ---
119
146
 
120
147
  ## Objective
148
+
121
149
  Modernize the authentication system
122
150
 
123
151
  ## Subtasks
152
+
124
153
  - [ ] #bead-001: Implement OAuth2 provider
125
154
  - [ ] #bead-002: Add MFA support
126
155
  - [ ] #bead-003: Migrate session storage
@@ -130,36 +159,54 @@ Modernize the authentication system
130
159
  ### Creating an Epic with Subtasks
131
160
 
132
161
  1. Create the epic first:
133
- ```
162
+
163
+ ```typescript
134
164
  beads_create(type: "epic", title: "User Auth Overhaul", body: "...")
135
165
  ```
136
166
 
137
167
  2. Create subtasks linked to the epic:
138
- ```
168
+
169
+ ```typescript
139
170
  beads_create(type: "task", title: "Implement OAuth2", parent: "epic-id")
140
171
  ```
141
172
 
142
173
  ## Best Practices
143
174
 
175
+ ```text
144
176
  1. **One bead per logical unit of work** - Don't combine unrelated fixes
145
177
  2. **Update state promptly** - Keep beads reflecting reality
146
178
  3. **Add context in body** - Future you will thank present you
147
179
  4. **Link related beads** - Use `#bead-id` references
148
180
  5. **Close with resolution** - Explain how it was resolved
149
181
  6. **Use labels** - `priority:high`, `area:frontend`, etc.
182
+ ```
150
183
 
151
184
  ## Sync and Collaboration
152
185
 
153
- Beads sync automatically with the central server:
154
- - Changes push on close
155
- - Conflicts merge automatically
156
- - Use `bd sync` to force sync
186
+ Beads sync with git:
187
+
188
+ - Changes tracked locally
189
+ - Use `beads_sync()` to commit and push to remote
157
190
 
158
191
  ## Integration with Swarm
159
192
 
160
193
  When working in a swarm:
161
- 1. Create a parent bead for the overall task
162
- 2. Decompose into child beads for subtasks
163
- 3. Assign agents to specific beads
164
- 4. Close beads as subtasks complete
165
- 5. Close parent when all children done
194
+
195
+ ```text
196
+ 1. Load `swarm-coordination` skill with `skills_use(name="swarm-coordination")`
197
+ 2. Create epic with `beads_create_epic()` (atomic operation)
198
+ 3. Coordinator assigns beads to worker agents
199
+ 4. Workers load relevant skills based on subtask type
200
+ 5. Close beads as subtasks complete
201
+ 6. Close epic when all subtasks done
202
+ 7. Sync with `beads_sync()` (MANDATORY at session end)
203
+ ```
204
+
205
+ ### Skill Recommendations for Common Bead Types
206
+
207
+ ```text
208
+ - `type: "bug"` → Load `testing-patterns` for regression tests
209
+ - `type: "feature"` → Load `system-design` for architecture
210
+ - `type: "chore"` → Load `testing-patterns` if refactoring
211
+ - `type: "epic"` → Load `swarm-coordination` for decomposition
212
+ ```