opencode-swarm-plugin 0.22.0 → 0.23.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.
- package/.turbo/turbo-build.log +9 -0
- package/CHANGELOG.md +20 -0
- package/README.md +109 -429
- package/dist/agent-mail.d.ts +480 -0
- package/dist/agent-mail.d.ts.map +1 -0
- package/dist/anti-patterns.d.ts +257 -0
- package/dist/anti-patterns.d.ts.map +1 -0
- package/dist/beads.d.ts +377 -0
- package/dist/beads.d.ts.map +1 -0
- package/dist/eval-capture.d.ts +206 -0
- package/dist/eval-capture.d.ts.map +1 -0
- package/dist/index.d.ts +1299 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +498 -4246
- package/dist/learning.d.ts +670 -0
- package/dist/learning.d.ts.map +1 -0
- package/dist/mandate-promotion.d.ts +93 -0
- package/dist/mandate-promotion.d.ts.map +1 -0
- package/dist/mandate-storage.d.ts +209 -0
- package/dist/mandate-storage.d.ts.map +1 -0
- package/dist/mandates.d.ts +230 -0
- package/dist/mandates.d.ts.map +1 -0
- package/dist/output-guardrails.d.ts +125 -0
- package/dist/output-guardrails.d.ts.map +1 -0
- package/dist/pattern-maturity.d.ts +246 -0
- package/dist/pattern-maturity.d.ts.map +1 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +493 -4241
- package/dist/rate-limiter.d.ts +218 -0
- package/dist/rate-limiter.d.ts.map +1 -0
- package/dist/repo-crawl.d.ts +146 -0
- package/dist/repo-crawl.d.ts.map +1 -0
- package/dist/schemas/bead.d.ts +255 -0
- package/dist/schemas/bead.d.ts.map +1 -0
- package/dist/schemas/evaluation.d.ts +161 -0
- package/dist/schemas/evaluation.d.ts.map +1 -0
- package/dist/schemas/index.d.ts +34 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/mandate.d.ts +336 -0
- package/dist/schemas/mandate.d.ts.map +1 -0
- package/dist/schemas/swarm-context.d.ts +131 -0
- package/dist/schemas/swarm-context.d.ts.map +1 -0
- package/dist/schemas/task.d.ts +188 -0
- package/dist/schemas/task.d.ts.map +1 -0
- package/dist/skills.d.ts +471 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/storage.d.ts +260 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/structured.d.ts +196 -0
- package/dist/structured.d.ts.map +1 -0
- package/dist/swarm-decompose.d.ts +201 -0
- package/dist/swarm-decompose.d.ts.map +1 -0
- package/dist/swarm-mail.d.ts +240 -0
- package/dist/swarm-mail.d.ts.map +1 -0
- package/dist/swarm-orchestrate.d.ts +708 -0
- package/dist/swarm-orchestrate.d.ts.map +1 -0
- package/dist/swarm-prompts.d.ts +292 -0
- package/dist/swarm-prompts.d.ts.map +1 -0
- package/dist/swarm-strategies.d.ts +100 -0
- package/dist/swarm-strategies.d.ts.map +1 -0
- package/dist/swarm.d.ts +455 -0
- package/dist/swarm.d.ts.map +1 -0
- package/dist/tool-availability.d.ts +91 -0
- package/dist/tool-availability.d.ts.map +1 -0
- package/docs/planning/ADR-001-monorepo-structure.md +171 -0
- package/docs/planning/ADR-002-package-extraction.md +393 -0
- package/docs/planning/ADR-003-performance-improvements.md +451 -0
- package/docs/planning/ADR-004-message-queue-features.md +187 -0
- package/docs/planning/ADR-005-devtools-observability.md +202 -0
- package/docs/planning/ROADMAP.md +368 -0
- package/package.json +13 -24
- package/src/agent-mail.ts +1 -1
- package/src/beads.ts +1 -2
- package/src/index.ts +2 -2
- package/src/learning.integration.test.ts +66 -11
- package/src/mandate-storage.test.ts +3 -3
- package/src/storage.ts +78 -10
- package/src/swarm-mail.ts +3 -3
- package/src/swarm-orchestrate.ts +7 -7
- package/src/tool-availability.ts +1 -1
- package/tsconfig.json +1 -1
- package/.beads/.local_version +0 -1
- package/.beads/README.md +0 -81
- package/.beads/analysis/skill-architecture-meta-skills.md +0 -1562
- package/.beads/config.yaml +0 -62
- package/.beads/issues.jsonl +0 -2197
- package/.beads/metadata.json +0 -4
- package/.gitattributes +0 -3
- package/.github/workflows/ci.yml +0 -30
- package/.github/workflows/opencode.yml +0 -31
- package/.opencode/skills/tdd/SKILL.md +0 -182
- package/INTEGRATION_EXAMPLE.md +0 -66
- package/VERIFICATION_QUALITY_PATTERNS.md +0 -565
- package/bun.lock +0 -286
- package/dist/pglite.data +0 -0
- package/dist/pglite.wasm +0 -0
- package/src/streams/agent-mail.test.ts +0 -777
- package/src/streams/agent-mail.ts +0 -535
- package/src/streams/debug.test.ts +0 -500
- package/src/streams/debug.ts +0 -727
- package/src/streams/effect/ask.integration.test.ts +0 -314
- package/src/streams/effect/ask.ts +0 -202
- package/src/streams/effect/cursor.integration.test.ts +0 -418
- package/src/streams/effect/cursor.ts +0 -288
- package/src/streams/effect/deferred.test.ts +0 -357
- package/src/streams/effect/deferred.ts +0 -445
- package/src/streams/effect/index.ts +0 -17
- package/src/streams/effect/layers.ts +0 -73
- package/src/streams/effect/lock.test.ts +0 -385
- package/src/streams/effect/lock.ts +0 -399
- package/src/streams/effect/mailbox.test.ts +0 -260
- package/src/streams/effect/mailbox.ts +0 -318
- package/src/streams/events.test.ts +0 -924
- package/src/streams/events.ts +0 -329
- package/src/streams/index.test.ts +0 -229
- package/src/streams/index.ts +0 -578
- package/src/streams/migrations.test.ts +0 -359
- package/src/streams/migrations.ts +0 -362
- package/src/streams/projections.test.ts +0 -611
- package/src/streams/projections.ts +0 -504
- package/src/streams/store.integration.test.ts +0 -658
- package/src/streams/store.ts +0 -1075
- package/src/streams/swarm-mail.ts +0 -552
- package/test-bug-fixes.ts +0 -86
- package/vitest.integration.config.ts +0 -19
- package/vitest.integration.setup.ts +0 -48
- package/workflow-integration-analysis.md +0 -876
package/.beads/metadata.json
DELETED
package/.gitattributes
DELETED
package/.github/workflows/ci.yml
DELETED
|
@@ -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")`
|
package/INTEGRATION_EXAMPLE.md
DELETED
|
@@ -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)
|