opencode-swarm-plugin 0.22.0 → 0.23.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.
Files changed (128) hide show
  1. package/.turbo/turbo-build.log +9 -0
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +109 -429
  4. package/dist/agent-mail.d.ts +480 -0
  5. package/dist/agent-mail.d.ts.map +1 -0
  6. package/dist/anti-patterns.d.ts +257 -0
  7. package/dist/anti-patterns.d.ts.map +1 -0
  8. package/dist/beads.d.ts +377 -0
  9. package/dist/beads.d.ts.map +1 -0
  10. package/dist/eval-capture.d.ts +206 -0
  11. package/dist/eval-capture.d.ts.map +1 -0
  12. package/dist/index.d.ts +1299 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +498 -4246
  15. package/dist/learning.d.ts +670 -0
  16. package/dist/learning.d.ts.map +1 -0
  17. package/dist/mandate-promotion.d.ts +93 -0
  18. package/dist/mandate-promotion.d.ts.map +1 -0
  19. package/dist/mandate-storage.d.ts +209 -0
  20. package/dist/mandate-storage.d.ts.map +1 -0
  21. package/dist/mandates.d.ts +230 -0
  22. package/dist/mandates.d.ts.map +1 -0
  23. package/dist/output-guardrails.d.ts +125 -0
  24. package/dist/output-guardrails.d.ts.map +1 -0
  25. package/dist/pattern-maturity.d.ts +246 -0
  26. package/dist/pattern-maturity.d.ts.map +1 -0
  27. package/dist/plugin.d.ts +22 -0
  28. package/dist/plugin.d.ts.map +1 -0
  29. package/dist/plugin.js +493 -4241
  30. package/dist/rate-limiter.d.ts +218 -0
  31. package/dist/rate-limiter.d.ts.map +1 -0
  32. package/dist/repo-crawl.d.ts +146 -0
  33. package/dist/repo-crawl.d.ts.map +1 -0
  34. package/dist/schemas/bead.d.ts +255 -0
  35. package/dist/schemas/bead.d.ts.map +1 -0
  36. package/dist/schemas/evaluation.d.ts +161 -0
  37. package/dist/schemas/evaluation.d.ts.map +1 -0
  38. package/dist/schemas/index.d.ts +34 -0
  39. package/dist/schemas/index.d.ts.map +1 -0
  40. package/dist/schemas/mandate.d.ts +336 -0
  41. package/dist/schemas/mandate.d.ts.map +1 -0
  42. package/dist/schemas/swarm-context.d.ts +131 -0
  43. package/dist/schemas/swarm-context.d.ts.map +1 -0
  44. package/dist/schemas/task.d.ts +188 -0
  45. package/dist/schemas/task.d.ts.map +1 -0
  46. package/dist/skills.d.ts +471 -0
  47. package/dist/skills.d.ts.map +1 -0
  48. package/dist/storage.d.ts +260 -0
  49. package/dist/storage.d.ts.map +1 -0
  50. package/dist/structured.d.ts +196 -0
  51. package/dist/structured.d.ts.map +1 -0
  52. package/dist/swarm-decompose.d.ts +201 -0
  53. package/dist/swarm-decompose.d.ts.map +1 -0
  54. package/dist/swarm-mail.d.ts +240 -0
  55. package/dist/swarm-mail.d.ts.map +1 -0
  56. package/dist/swarm-orchestrate.d.ts +708 -0
  57. package/dist/swarm-orchestrate.d.ts.map +1 -0
  58. package/dist/swarm-prompts.d.ts +292 -0
  59. package/dist/swarm-prompts.d.ts.map +1 -0
  60. package/dist/swarm-strategies.d.ts +100 -0
  61. package/dist/swarm-strategies.d.ts.map +1 -0
  62. package/dist/swarm.d.ts +455 -0
  63. package/dist/swarm.d.ts.map +1 -0
  64. package/dist/tool-availability.d.ts +91 -0
  65. package/dist/tool-availability.d.ts.map +1 -0
  66. package/docs/planning/ADR-001-monorepo-structure.md +171 -0
  67. package/docs/planning/ADR-002-package-extraction.md +393 -0
  68. package/docs/planning/ADR-003-performance-improvements.md +451 -0
  69. package/docs/planning/ADR-004-message-queue-features.md +187 -0
  70. package/docs/planning/ADR-005-devtools-observability.md +202 -0
  71. package/docs/planning/ROADMAP.md +368 -0
  72. package/package.json +13 -24
  73. package/src/agent-mail.ts +1 -1
  74. package/src/beads.ts +1 -2
  75. package/src/index.ts +2 -2
  76. package/src/learning.integration.test.ts +66 -11
  77. package/src/mandate-storage.test.ts +3 -3
  78. package/src/storage.ts +78 -10
  79. package/src/swarm-mail.ts +3 -3
  80. package/src/swarm-orchestrate.ts +7 -7
  81. package/src/tool-availability.ts +1 -1
  82. package/tsconfig.json +1 -1
  83. package/.beads/.local_version +0 -1
  84. package/.beads/README.md +0 -81
  85. package/.beads/analysis/skill-architecture-meta-skills.md +0 -1562
  86. package/.beads/config.yaml +0 -62
  87. package/.beads/issues.jsonl +0 -2197
  88. package/.beads/metadata.json +0 -4
  89. package/.gitattributes +0 -3
  90. package/.github/workflows/ci.yml +0 -30
  91. package/.github/workflows/opencode.yml +0 -31
  92. package/.opencode/skills/tdd/SKILL.md +0 -182
  93. package/INTEGRATION_EXAMPLE.md +0 -66
  94. package/VERIFICATION_QUALITY_PATTERNS.md +0 -565
  95. package/bun.lock +0 -286
  96. package/dist/pglite.data +0 -0
  97. package/dist/pglite.wasm +0 -0
  98. package/src/streams/agent-mail.test.ts +0 -777
  99. package/src/streams/agent-mail.ts +0 -535
  100. package/src/streams/debug.test.ts +0 -500
  101. package/src/streams/debug.ts +0 -727
  102. package/src/streams/effect/ask.integration.test.ts +0 -314
  103. package/src/streams/effect/ask.ts +0 -202
  104. package/src/streams/effect/cursor.integration.test.ts +0 -418
  105. package/src/streams/effect/cursor.ts +0 -288
  106. package/src/streams/effect/deferred.test.ts +0 -357
  107. package/src/streams/effect/deferred.ts +0 -445
  108. package/src/streams/effect/index.ts +0 -17
  109. package/src/streams/effect/layers.ts +0 -73
  110. package/src/streams/effect/lock.test.ts +0 -385
  111. package/src/streams/effect/lock.ts +0 -399
  112. package/src/streams/effect/mailbox.test.ts +0 -260
  113. package/src/streams/effect/mailbox.ts +0 -318
  114. package/src/streams/events.test.ts +0 -924
  115. package/src/streams/events.ts +0 -329
  116. package/src/streams/index.test.ts +0 -229
  117. package/src/streams/index.ts +0 -578
  118. package/src/streams/migrations.test.ts +0 -359
  119. package/src/streams/migrations.ts +0 -362
  120. package/src/streams/projections.test.ts +0 -611
  121. package/src/streams/projections.ts +0 -504
  122. package/src/streams/store.integration.test.ts +0 -658
  123. package/src/streams/store.ts +0 -1075
  124. package/src/streams/swarm-mail.ts +0 -552
  125. package/test-bug-fixes.ts +0 -86
  126. package/vitest.integration.config.ts +0 -19
  127. package/vitest.integration.setup.ts +0 -48
  128. package/workflow-integration-analysis.md +0 -876
@@ -1,4 +0,0 @@
1
- {
2
- "database": "beads.db",
3
- "jsonl_export": "issues.jsonl"
4
- }
package/.gitattributes DELETED
@@ -1,3 +0,0 @@
1
-
2
- # Use bd merge for beads JSONL files
3
- .beads/issues.jsonl merge=beads
@@ -1,30 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches: [main]
6
- pull_request:
7
- branches: [main]
8
-
9
- jobs:
10
- test:
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v4
14
-
15
- - uses: oven-sh/setup-bun@v2
16
- with:
17
- bun-version: latest
18
-
19
- - name: Install dependencies
20
- run: bun install
21
-
22
- - name: Type check
23
- run: bun run typecheck
24
-
25
- - name: Run unit tests
26
- run: bun run test
27
-
28
- - name: Run integration tests
29
- run: bun run test:integration
30
- timeout-minutes: 10
@@ -1,31 +0,0 @@
1
- name: opencode
2
-
3
- on:
4
- issue_comment:
5
- types: [created]
6
- pull_request_review_comment:
7
- types: [created]
8
-
9
- jobs:
10
- opencode:
11
- if: |
12
- contains(github.event.comment.body, ' /oc') ||
13
- startsWith(github.event.comment.body, '/oc') ||
14
- contains(github.event.comment.body, ' /opencode') ||
15
- startsWith(github.event.comment.body, '/opencode')
16
- runs-on: ubuntu-latest
17
- permissions:
18
- id-token: write
19
- contents: read
20
- pull-requests: read
21
- issues: read
22
- steps:
23
- - name: Checkout repository
24
- uses: actions/checkout@v4
25
-
26
- - name: Run opencode
27
- uses: sst/opencode/github@latest
28
- env:
29
- ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
30
- with:
31
- model: anthropic/claude-sonnet-4-5
@@ -1,182 +0,0 @@
1
- ---
2
- name: tdd
3
- description: "Test-Driven Development workflow with RED-GREEN-REFACTOR, lore from Kent Beck, Michael Feathers, and Ousterhout's counterpoint"
4
- tags:
5
- - testing
6
- - workflow
7
- - methodology
8
- - tdd
9
- ---
10
-
11
- # Test-Driven Development (TDD)
12
-
13
- ## The Rhythm: RED-GREEN-REFACTOR
14
-
15
- ```
16
- 1. RED - Write failing test first (define expected behavior)
17
- 2. GREEN - Minimal implementation to pass (don't over-engineer)
18
- 3. REFACTOR - Clean up, remove duplication, run tests again
19
- ```
20
-
21
- ## Why TDD Works (The Lore)
22
-
23
- ### Kent Beck (Test-Driven Development by Example)
24
-
25
- > "The act of writing a unit test is more an act of design than verification."
26
-
27
- - Tests become executable documentation of intent
28
- - "Fake it til you make it" - start with hardcoded values, generalize
29
- - Small steps reduce debugging time
30
- - Confidence to refactor comes from test coverage
31
-
32
- ### Michael Feathers (Working Effectively with Legacy Code)
33
-
34
- > "The most powerful feature-addition technique I know of is test-driven development."
35
-
36
- - TDD works in both OO and procedural code
37
- - Writing tests first forces you to think about interfaces
38
- - Tests are the safety net that enables aggressive refactoring
39
- - Legacy code = code without tests
40
-
41
- ### Martin Fowler (Refactoring)
42
-
43
- > "Kent Beck baked this habit of writing the test first into a technique called Test-Driven Development."
44
-
45
- - TDD relies on short cycles
46
- - Tests enable refactoring
47
- - Refactoring becomes safe - tests catch regressions instantly
48
-
49
- ## The Counterpoint: Know When to Break the Rule
50
-
51
- ### John Ousterhout (A Philosophy of Software Design)
52
-
53
- > "The problem with test-driven development is that it focuses attention on getting specific features working, rather than finding the best design."
54
-
55
- **When TDD can hurt:**
56
-
57
- - Can lead to tactical programming (feature-focused, not design-focused)
58
- - May produce code that's easy to test but hard to understand
59
- - Risk of over-testing implementation details
60
-
61
- **The balance:**
62
-
63
- - For exploratory/architectural work, design first, then add tests
64
- - Don't let tests drive you into a corner
65
- - Step back periodically to evaluate overall design
66
-
67
- ## When to Use TDD
68
-
69
- ✅ **Use TDD for:**
70
-
71
- - New features with clear requirements
72
- - Bug fixes (write test that reproduces bug first)
73
- - Refactoring existing code (add characterization tests first)
74
- - API design (tests reveal ergonomics)
75
- - Any code that will be maintained long-term
76
-
77
- ❌ **Skip TDD for:**
78
-
79
- - Exploratory spikes (but add tests after if keeping the code)
80
- - Emergency hotfixes (but add tests immediately after)
81
- - Pure UI/styling changes
82
- - One-off scripts
83
- - Throwaway prototypes
84
-
85
- ## The TDD Workflow
86
-
87
- ```bash
88
- # 1. Write test, watch it fail
89
- bun test src/thing.test.ts # RED - test fails
90
-
91
- # 2. Implement minimal code to pass
92
- bun test src/thing.test.ts # GREEN - test passes
93
-
94
- # 3. Refactor, tests still pass
95
- bun test src/thing.test.ts # GREEN - still passing
96
-
97
- # 4. Repeat for next behavior
98
- ```
99
-
100
- ## TDD Patterns
101
-
102
- ### Start with the Assertion
103
-
104
- Write the assertion first, then work backwards:
105
-
106
- ```typescript
107
- // Start here
108
- expect(result).toBe(42);
109
-
110
- // Then figure out what 'result' is
111
- const result = calculate(input);
112
-
113
- // Then figure out what 'input' is
114
- const input = { value: 21 };
115
- ```
116
-
117
- ### Triangulation
118
-
119
- Use multiple examples to drive generalization:
120
-
121
- ```typescript
122
- it("doubles 2", () => expect(double(2)).toBe(4));
123
- it("doubles 3", () => expect(double(3)).toBe(6));
124
- // Now you MUST implement the general solution
125
- ```
126
-
127
- ### Obvious Implementation
128
-
129
- When the solution is obvious, just write it:
130
-
131
- ```typescript
132
- function add(a: number, b: number): number {
133
- return a + b; // Don't fake this
134
- }
135
- ```
136
-
137
- ### Fake It Til You Make It
138
-
139
- When unsure, start with hardcoded values:
140
-
141
- ```typescript
142
- // First pass
143
- function fibonacci(n: number): number {
144
- return 1; // Passes for n=1
145
- }
146
-
147
- // Add test for n=2, then generalize
148
- ```
149
-
150
- ## Testing Pyramid
151
-
152
- ```
153
- /\
154
- / \ E2E (few)
155
- /----\
156
- / \ Integration (some)
157
- /--------\
158
- / \ Unit (many)
159
- --------------
160
- ```
161
-
162
- - **Unit tests**: Fast, isolated, test one thing
163
- - **Integration tests**: Test component interactions
164
- - **E2E tests**: Test full user flows (expensive, use sparingly)
165
-
166
- ## Common TDD Mistakes
167
-
168
- 1. **Writing too many tests at once** - One failing test at a time
169
- 2. **Testing implementation, not behavior** - Test what, not how
170
- 3. **Skipping the refactor step** - Technical debt accumulates
171
- 4. **Over-mocking** - Don't mock what you don't own
172
- 5. **Testing private methods** - Test through public interface
173
-
174
- ## Integration with Beads
175
-
176
- When working on a bead:
177
-
178
- 1. Start bead: `beads_start(id="bd-123")`
179
- 2. Write failing test for the requirement
180
- 3. Implement to pass
181
- 4. Refactor
182
- 5. Close bead: `beads_close(id="bd-123", reason="Done: tests passing")`
@@ -1,66 +0,0 @@
1
- # Output Guardrails Integration Example
2
-
3
- ## How to Integrate into src/index.ts
4
-
5
- Add to the `tool.execute.after` hook:
6
-
7
- ```typescript
8
- import { guardrailOutput, createMetrics } from "./output-guardrails";
9
-
10
- // In the SwarmPlugin function:
11
- "tool.execute.after": async (input, output) => {
12
- const toolName = input.tool;
13
-
14
- // Apply guardrails to prevent context blowout
15
- const guardrailed = guardrailOutput(toolName, output.output || "");
16
-
17
- if (guardrailed.truncated) {
18
- // Log metrics for learning
19
- const metrics = createMetrics(guardrailed, toolName);
20
- console.log(
21
- `[swarm-plugin] Truncated ${toolName}: ${metrics.originalLength} → ${metrics.truncatedLength} chars`
22
- );
23
-
24
- // Update output
25
- output.output = guardrailed.output;
26
- }
27
-
28
- // ... existing code (Agent Mail tracking, auto-release, etc.)
29
- },
30
- ```
31
-
32
- ## What It Does
33
-
34
- 1. **Prevents Context Exhaustion**: Tools like `context7_get-library-docs` and `repo-autopsy_search` can return 100k+ chars, blowing out context
35
- 2. **Smart Truncation**: Preserves JSON structure, code blocks (```), and markdown headers
36
- 3. **Per-Tool Limits**: Higher limits for code tools (64k), lower for stats (8k)
37
- 4. **Skip Internal Tools**: Never truncates beads_*, swarmmail_*, structured_*, swarm_* tools
38
- 5. **Metrics**: Track truncation patterns for future optimization
39
-
40
- ## Default Limits
41
-
42
- - **Default**: 32,000 chars (~8k tokens)
43
- - **Code/Doc Tools**: 64,000 chars (repo-autopsy_file, context7_get-library-docs, cass_view)
44
- - **Search Tools**: 48,000 chars (cass_search, skills_read)
45
- - **Stats Tools**: 8,000-24,000 chars (cass_stats, repo-autopsy_stats, repo-autopsy_structure)
46
- - **Skip Tools**: All beads_*, agentmail_*, swarmmail_*, structured_*, swarm_*, mandate_* tools
47
-
48
- ## Testing
49
-
50
- ```bash
51
- # Run tests
52
- bun test src/output-guardrails.test.ts
53
-
54
- # Typecheck
55
- bun run typecheck
56
- ```
57
-
58
- ## Coverage
59
-
60
- - ✅ 29 tests passing
61
- - ✅ JSON structure preservation
62
- - ✅ Code block boundary detection
63
- - ✅ Markdown header preservation
64
- - ✅ Per-tool limits
65
- - ✅ Skip tool configuration
66
- - ✅ Edge cases (empty string, exact limit, unicode, CRLF)