opencode-swarm-plugin 0.35.0 → 0.36.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 (52) hide show
  1. package/.hive/issues.jsonl +4 -4
  2. package/.hive/memories.jsonl +274 -1
  3. package/.turbo/turbo-build.log +4 -4
  4. package/.turbo/turbo-test.log +307 -307
  5. package/CHANGELOG.md +133 -0
  6. package/bin/swarm.ts +234 -179
  7. package/dist/compaction-hook.d.ts +54 -4
  8. package/dist/compaction-hook.d.ts.map +1 -1
  9. package/dist/eval-capture.d.ts +122 -17
  10. package/dist/eval-capture.d.ts.map +1 -1
  11. package/dist/index.d.ts +1 -7
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +1278 -619
  14. package/dist/planning-guardrails.d.ts +121 -0
  15. package/dist/planning-guardrails.d.ts.map +1 -1
  16. package/dist/plugin.d.ts +9 -9
  17. package/dist/plugin.d.ts.map +1 -1
  18. package/dist/plugin.js +1283 -329
  19. package/dist/schemas/task.d.ts +0 -1
  20. package/dist/schemas/task.d.ts.map +1 -1
  21. package/dist/swarm-decompose.d.ts +0 -8
  22. package/dist/swarm-decompose.d.ts.map +1 -1
  23. package/dist/swarm-orchestrate.d.ts.map +1 -1
  24. package/dist/swarm-prompts.d.ts +0 -4
  25. package/dist/swarm-prompts.d.ts.map +1 -1
  26. package/dist/swarm-review.d.ts.map +1 -1
  27. package/dist/swarm.d.ts +0 -6
  28. package/dist/swarm.d.ts.map +1 -1
  29. package/evals/README.md +38 -0
  30. package/evals/coordinator-session.eval.ts +154 -0
  31. package/evals/fixtures/coordinator-sessions.ts +328 -0
  32. package/evals/lib/data-loader.ts +69 -0
  33. package/evals/scorers/coordinator-discipline.evalite-test.ts +536 -0
  34. package/evals/scorers/coordinator-discipline.ts +315 -0
  35. package/evals/scorers/index.ts +12 -0
  36. package/examples/plugin-wrapper-template.ts +747 -34
  37. package/package.json +2 -2
  38. package/src/compaction-hook.test.ts +234 -281
  39. package/src/compaction-hook.ts +221 -63
  40. package/src/eval-capture.test.ts +390 -0
  41. package/src/eval-capture.ts +168 -10
  42. package/src/index.ts +89 -2
  43. package/src/learning.integration.test.ts +0 -2
  44. package/src/planning-guardrails.test.ts +387 -2
  45. package/src/planning-guardrails.ts +289 -0
  46. package/src/plugin.ts +10 -10
  47. package/src/schemas/task.ts +0 -1
  48. package/src/swarm-decompose.ts +21 -8
  49. package/src/swarm-orchestrate.ts +44 -0
  50. package/src/swarm-prompts.ts +20 -0
  51. package/src/swarm-review.ts +41 -0
  52. package/src/swarm.integration.test.ts +0 -40
package/CHANGELOG.md CHANGED
@@ -1,5 +1,138 @@
1
1
  # opencode-swarm-plugin
2
2
 
3
+ ## 0.36.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9c1f3f3`](https://github.com/joelhooks/swarm-tools/commit/9c1f3f3e7204f02c133c4a036fa34e83d8376a8c) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🐝 Coordinator Discipline: Prohibition-First Enforcement
8
+
9
+ Coordinators kept "just doing it themselves" after compaction. Now they can't.
10
+
11
+ **The Problem:**
12
+ After context compaction, coordinators would ignore their own instructions to "spawn workers for remaining subtasks" and edit files directly. The compaction context was narrative ("do this") rather than prescriptive ("NEVER do that").
13
+
14
+ **The Fix:**
15
+
16
+ ### 1. Prohibition-First Compaction Context
17
+
18
+ The `SWARM_COMPACTION_CONTEXT` now leads with explicit anti-patterns:
19
+
20
+ ```markdown
21
+ ### ⛔ NEVER DO THESE (Coordinator Anti-Patterns)
22
+
23
+ - ❌ **NEVER** use `edit` or `write` tools - SPAWN A WORKER
24
+ - ❌ **NEVER** run tests with `bash` - SPAWN A WORKER
25
+ - ❌ **NEVER** implement features yourself - SPAWN A WORKER
26
+ - ❌ **NEVER** "just do it myself to save time" - NO. SPAWN A WORKER.
27
+ ```
28
+
29
+ ### 2. Runtime Violation Detection
30
+
31
+ `detectCoordinatorViolation()` is now wired up in `tool.execute.before`:
32
+
33
+ - Detects when coordinators call `edit`, `write`, or test commands
34
+ - Emits warnings to help coordinators self-correct
35
+ - Captures VIOLATION events for post-hoc analysis
36
+
37
+ ### 3. Coordinator Context Tracking
38
+
39
+ New functions track when we're in coordinator mode:
40
+
41
+ - `setCoordinatorContext()` - Activated when `hive_create_epic` or `swarm_decompose` is called
42
+ - `isInCoordinatorContext()` - Checks if we're currently coordinating
43
+ - `clearCoordinatorContext()` - Cleared when epic is closed
44
+
45
+ **Why This Matters:**
46
+
47
+ Coordinators that do implementation work burn context, create conflicts, and defeat the purpose of swarm coordination. This fix makes the anti-pattern visible and provides guardrails to prevent it.
48
+
49
+ **Validation:**
50
+
51
+ - Check `~/.config/swarm-tools/sessions/` for VIOLATION events
52
+ - Run `coordinator-behavior.eval.ts` to score coordinator discipline
53
+
54
+ - [`4c23c7a`](https://github.com/joelhooks/swarm-tools/commit/4c23c7a31013bc6537d83a9294b51540056cde93) Thanks [@joelhooks](https://github.com/joelhooks)! - ## Fix Double Hook Registration
55
+
56
+ The compaction hook was firing twice per compaction event because OpenCode's plugin loader
57
+ calls ALL exports as plugin functions. We were exporting `SwarmPlugin` as both:
58
+
59
+ 1. Named export: `export const SwarmPlugin`
60
+ 2. Default export: `export default SwarmPlugin`
61
+
62
+ This caused the plugin to register twice, doubling all hook invocations.
63
+
64
+ **Fix:** Changed to default-only export pattern:
65
+
66
+ - `src/index.ts`: `const SwarmPlugin` (no export keyword)
67
+ - `src/plugin.ts`: `export default SwarmPlugin` (no named re-export)
68
+
69
+ **Impact:** Compaction hooks now fire once. LLM calls during compaction reduced by 50%.
70
+
71
+ - Updated dependencies [[`e0c422d`](https://github.com/joelhooks/swarm-tools/commit/e0c422de3f5e15c117cc0cc655c0b03242245be4), [`43c8c93`](https://github.com/joelhooks/swarm-tools/commit/43c8c93ef90b2f04ce59317192334f69d7c4204e)]:
72
+ - swarm-mail@1.5.1
73
+
74
+ ## 0.36.0
75
+
76
+ ### Minor Changes
77
+
78
+ - [`ae213aa`](https://github.com/joelhooks/swarm-tools/commit/ae213aa49be977e425e0a767b5b2db16e462f76b) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🔬 Compaction Hook: Now With X-Ray Vision
79
+
80
+ The compaction hook was logging to `console.log` like a caveman. Now it writes structured JSON logs to `~/.config/swarm-tools/logs/compaction.log` - visible via `swarm log compaction`.
81
+
82
+ **The Problem:**
83
+
84
+ - Plugin wrapper used `console.log` → stdout → invisible
85
+ - npm package had pino logging → but wrapper didn't use it
86
+ - Running `/compact` gave zero visibility into what happened
87
+
88
+ **The Fix:**
89
+ Added comprehensive file-based logging throughout the compaction flow:
90
+
91
+ ```
92
+ ┌─────────────────────────────────────────────────────────────┐
93
+ │ COMPACTION LOGGING │
94
+ ├─────────────────────────────────────────────────────────────┤
95
+ │ compaction_hook_invoked │ Full input/output objects │
96
+ │ detect_swarm_* │ CLI calls, cells, confidence │
97
+ │ query_swarm_state_* │ Epic/subtask extraction │
98
+ │ generate_compaction_prompt_*│ LLM timing, success/failure │
99
+ │ context_injected_via_* │ Which API used │
100
+ │ compaction_complete_* │ Final result + timing │
101
+ └─────────────────────────────────────────────────────────────┘
102
+ ```
103
+
104
+ **Also Enhanced:**
105
+
106
+ - SDK message scanning for precise swarm state extraction
107
+ - Merged scanned state (ground truth) with hive detection (heuristic)
108
+ - 9 new tests for `scanSessionMessages()` (32 total passing)
109
+
110
+ **To See It Work:**
111
+
112
+ ```bash
113
+ swarm setup --reinstall # Regenerate plugin wrapper
114
+ # Run /compact in OpenCode
115
+ swarm log compaction # See what happened
116
+ ```
117
+
118
+ ### Patch Changes
119
+
120
+ - [`5cfc42e`](https://github.com/joelhooks/swarm-tools/commit/5cfc42e93d3e5424e308857a40af4fd9fbda0ba3) Thanks [@joelhooks](https://github.com/joelhooks)! - ## 🐝 Swarm Workers Unchained
121
+
122
+ Removed the vestigial `max_subtasks` parameter from decomposition tools. It was dead code - the prompts already say "as many as needed" and the replacement was doing nothing.
123
+
124
+ **What changed:**
125
+
126
+ - Removed `max_subtasks` arg from `swarm_decompose`, `swarm_plan_prompt`, `swarm_delegate_planning`
127
+ - Removed from `DecomposeArgsSchema`
128
+ - Renamed `max_subtasks` → `subtask_count` in eval capture (records actual count, not a limit)
129
+ - Cleaned up tests that were passing the unused parameter
130
+
131
+ **Why it matters:**
132
+ The LLM decides how many subtasks based on task complexity, not an arbitrary cap. "Plan aggressively" means spawn as many workers as the task needs.
133
+
134
+ **No functional change** - the parameter wasn't being used anyway.
135
+
3
136
  ## 0.35.0
4
137
 
5
138
  ### Minor Changes