opencodekit 0.18.1 → 0.18.3
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/dist/index.js +161 -38
- package/dist/template/.opencode/.version +1 -1
- package/dist/template/.opencode/AGENTS.md +39 -9
- package/dist/template/.opencode/AGENT_ALIGNMENT.md +6 -6
- package/dist/template/.opencode/agent/build.md +7 -103
- package/dist/template/.opencode/agent/general.md +0 -52
- package/dist/template/.opencode/agent/plan.md +10 -0
- package/dist/template/.opencode/agent/runner.md +79 -0
- package/dist/template/.opencode/command/create.md +13 -1
- package/dist/template/.opencode/command/init-context.md +20 -6
- package/dist/template/.opencode/command/init-user.md +18 -16
- package/dist/template/.opencode/command/lfg.md +3 -4
- package/dist/template/.opencode/command/ship.md +6 -48
- package/dist/template/.opencode/command/start.md +20 -3
- package/dist/template/.opencode/command/verify.md +12 -17
- package/dist/template/.opencode/context/README.md +29 -0
- package/dist/template/.opencode/memory/_templates/{STATE.md → state.md} +1 -1
- package/dist/template/.opencode/memory.db +0 -0
- package/dist/template/.opencode/memory.db-shm +0 -0
- package/dist/template/.opencode/memory.db-wal +0 -0
- package/dist/template/.opencode/opencode.json +131 -7
- package/dist/template/.opencode/package.json +1 -1
- package/dist/template/.opencode/plugin/lib/memory-helpers.ts +51 -16
- package/dist/template/.opencode/plugin/lib/memory-hooks.ts +1 -1
- package/dist/template/.opencode/skill/accessibility-audit/SKILL.md +11 -5
- package/dist/template/.opencode/skill/agent-browser/SKILL.md +55 -18
- package/dist/template/.opencode/skill/agent-teams/SKILL.md +12 -1
- package/dist/template/.opencode/skill/augment-context-engine/SKILL.md +11 -1
- package/dist/template/.opencode/skill/beads/SKILL.md +57 -390
- package/dist/template/.opencode/skill/beads/references/BEST_PRACTICES.md +27 -0
- package/dist/template/.opencode/skill/beads/references/EXAMPLES.md +45 -0
- package/dist/template/.opencode/skill/beads/references/FILE_CLAIMING.md +101 -0
- package/dist/template/.opencode/skill/beads/references/GIT_SYNC.md +25 -0
- package/dist/template/.opencode/skill/beads/references/HIERARCHY.md +71 -0
- package/dist/template/.opencode/skill/beads/references/MULTI_AGENT.md +40 -0
- package/dist/template/.opencode/skill/beads/references/SESSION_PROTOCOL.md +61 -0
- package/dist/template/.opencode/skill/beads/references/TASK_CREATION.md +38 -0
- package/dist/template/.opencode/skill/beads/references/TROUBLESHOOTING.md +38 -0
- package/dist/template/.opencode/skill/beads-bridge/SKILL.md +10 -10
- package/dist/template/.opencode/skill/brainstorming/SKILL.md +13 -0
- package/dist/template/.opencode/skill/chrome-devtools/SKILL.md +11 -1
- package/dist/template/.opencode/skill/cloudflare/SKILL.md +87 -67
- package/dist/template/.opencode/skill/compaction/SKILL.md +11 -3
- package/dist/template/.opencode/skill/condition-based-waiting/SKILL.md +11 -25
- package/dist/template/.opencode/skill/context-engineering/SKILL.md +13 -2
- package/dist/template/.opencode/skill/context-initialization/SKILL.md +11 -1
- package/dist/template/.opencode/skill/context-management/SKILL.md +13 -1
- package/dist/template/.opencode/skill/core-data-expert/SKILL.md +13 -2
- package/dist/template/.opencode/skill/deep-research/SKILL.md +5 -8
- package/dist/template/.opencode/skill/defense-in-depth/SKILL.md +13 -0
- package/dist/template/.opencode/skill/design-system-audit/SKILL.md +9 -3
- package/dist/template/.opencode/skill/development-lifecycle/SKILL.md +51 -0
- package/dist/template/.opencode/skill/dispatching-parallel-agents/SKILL.md +19 -30
- package/dist/template/.opencode/skill/executing-plans/SKILL.md +36 -0
- package/dist/template/.opencode/skill/figma/SKILL.md +11 -1
- package/dist/template/.opencode/skill/finishing-a-development-branch/SKILL.md +31 -0
- package/dist/template/.opencode/skill/frontend-design/SKILL.md +13 -3
- package/dist/template/.opencode/skill/gemini-large-context/SKILL.md +11 -0
- package/dist/template/.opencode/skill/index-knowledge/SKILL.md +11 -1
- package/dist/template/.opencode/skill/jira/SKILL.md +11 -1
- package/dist/template/.opencode/skill/memory-system/SKILL.md +13 -1
- package/dist/template/.opencode/skill/mockup-to-code/SKILL.md +9 -3
- package/dist/template/.opencode/skill/mqdh/SKILL.md +11 -1
- package/dist/template/.opencode/skill/obsidian/SKILL.md +11 -1
- package/dist/template/.opencode/skill/opensrc/SKILL.md +18 -6
- package/dist/template/.opencode/skill/pdf-extract/SKILL.md +11 -1
- package/dist/template/.opencode/skill/playwright/SKILL.md +11 -1
- package/dist/template/.opencode/skill/playwriter/SKILL.md +11 -1
- package/dist/template/.opencode/skill/polar/SKILL.md +11 -1
- package/dist/template/.opencode/skill/prd/SKILL.md +13 -4
- package/dist/template/.opencode/skill/prd-task/SKILL.md +13 -3
- package/dist/template/.opencode/skill/ralph/SKILL.md +4 -8
- package/dist/template/.opencode/skill/react-best-practices/SKILL.md +24 -16
- package/dist/template/.opencode/skill/receiving-code-review/SKILL.md +22 -0
- package/dist/template/.opencode/skill/requesting-code-review/SKILL.md +30 -2
- package/dist/template/.opencode/skill/resend/SKILL.md +11 -1
- package/dist/template/.opencode/skill/root-cause-tracing/SKILL.md +12 -23
- package/dist/template/.opencode/skill/session-management/SKILL.md +11 -1
- package/dist/template/.opencode/skill/sharing-skills/SKILL.md +11 -0
- package/dist/template/.opencode/skill/skill-creator/SKILL.md +12 -11
- package/dist/template/.opencode/skill/source-code-research/SKILL.md +20 -266
- package/dist/template/.opencode/skill/source-code-research/references/analysis-tips.md +43 -0
- package/dist/template/.opencode/skill/source-code-research/references/anti-patterns.md +36 -0
- package/dist/template/.opencode/skill/source-code-research/references/common-patterns.md +57 -0
- package/dist/template/.opencode/skill/source-code-research/references/example-workflow.md +60 -0
- package/dist/template/.opencode/skill/source-code-research/references/further-reading.md +5 -0
- package/dist/template/.opencode/skill/source-code-research/references/source-structure.md +45 -0
- package/dist/template/.opencode/skill/stitch/SKILL.md +11 -1
- package/dist/template/.opencode/skill/structured-edit/SKILL.md +13 -0
- package/dist/template/.opencode/skill/subagent-driven-development/SKILL.md +13 -14
- package/dist/template/.opencode/skill/supabase/SKILL.md +11 -1
- package/dist/template/.opencode/skill/supabase-postgres-best-practices/SKILL.md +23 -15
- package/dist/template/.opencode/skill/swarm-coordination/SKILL.md +23 -923
- package/dist/template/.opencode/skill/swarm-coordination/references/architecture.md +39 -0
- package/dist/template/.opencode/skill/swarm-coordination/references/delegation-worker-protocol.md +145 -0
- package/dist/template/.opencode/skill/swarm-coordination/references/dependency-graph.md +50 -0
- package/dist/template/.opencode/skill/swarm-coordination/references/drift-check.md +90 -0
- package/dist/template/.opencode/skill/swarm-coordination/references/integration-beads.md +20 -0
- package/dist/template/.opencode/skill/swarm-coordination/references/launch-flow.md +186 -0
- package/dist/template/.opencode/skill/swarm-coordination/references/reconciler.md +172 -0
- package/dist/template/.opencode/skill/swarm-coordination/references/tier-enforcement.md +78 -0
- package/dist/template/.opencode/skill/swarm-coordination/references/tmux-integration.md +134 -0
- package/dist/template/.opencode/skill/swift-concurrency/SKILL.md +22 -2
- package/dist/template/.opencode/skill/swiftui-expert-skill/SKILL.md +58 -19
- package/dist/template/.opencode/skill/systematic-debugging/SKILL.md +25 -25
- package/dist/template/.opencode/skill/test-driven-development/SKILL.md +19 -15
- package/dist/template/.opencode/skill/testing-anti-patterns/SKILL.md +13 -0
- package/dist/template/.opencode/skill/testing-skills-with-subagents/SKILL.md +13 -15
- package/dist/template/.opencode/skill/tool-priority/SKILL.md +13 -0
- package/dist/template/.opencode/skill/ui-ux-research/SKILL.md +9 -3
- package/dist/template/.opencode/skill/using-git-worktrees/SKILL.md +37 -0
- package/dist/template/.opencode/skill/using-skills/SKILL.md +13 -0
- package/dist/template/.opencode/skill/v0/SKILL.md +11 -1
- package/dist/template/.opencode/skill/v1-run/SKILL.md +11 -1
- package/dist/template/.opencode/skill/vercel-deploy-claimable/SKILL.md +14 -2
- package/dist/template/.opencode/skill/verification-before-completion/SKILL.md +22 -0
- package/dist/template/.opencode/skill/verification-before-completion/references/VERIFICATION_PROTOCOL.md +67 -0
- package/dist/template/.opencode/skill/visual-analysis/SKILL.md +9 -3
- package/dist/template/.opencode/skill/web-design-guidelines/SKILL.md +12 -5
- package/dist/template/.opencode/skill/writing-plans/SKILL.md +13 -0
- package/dist/template/.opencode/skill/writing-skills/SKILL.md +26 -421
- package/dist/template/.opencode/skill/writing-skills/references/anti-patterns.md +25 -0
- package/dist/template/.opencode/skill/writing-skills/references/claude-search-optimization.md +140 -0
- package/dist/template/.opencode/skill/writing-skills/references/discovery-workflow.md +11 -0
- package/dist/template/.opencode/skill/writing-skills/references/file-organization.md +32 -0
- package/dist/template/.opencode/skill/writing-skills/references/flowcharts-and-examples.md +57 -0
- package/dist/template/.opencode/skill/writing-skills/references/rationalization-hardening.md +75 -0
- package/dist/template/.opencode/skill/writing-skills/references/testing-skill-types.md +52 -0
- package/package.json +15 -4
- /package/dist/template/.opencode/memory/_templates/{PROJECT.md → project.md} +0 -0
- /package/dist/template/.opencode/memory/_templates/{ROADMAP.md → roadmap.md} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Swarm Architecture
|
|
2
|
+
|
|
3
|
+
```
|
|
4
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
5
|
+
│ BUILD AGENT (Leader) │
|
|
6
|
+
│ - Parses plan into tasks │
|
|
7
|
+
│ - Creates delegation packets │
|
|
8
|
+
│ - Spawns worker agents via Task tool │
|
|
9
|
+
│ - Monitors progress via swarm tool │
|
|
10
|
+
│ - Synthesizes final results │
|
|
11
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
12
|
+
│ │ │
|
|
13
|
+
▼ ▼ ▼
|
|
14
|
+
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
|
15
|
+
│ WORKER-1 │ │ WORKER-2 │ │ WORKER-3 │
|
|
16
|
+
│ (general) │ │ (general) │ │ (general) │
|
|
17
|
+
│ │ │ │ │ │
|
|
18
|
+
│ - Read │ │ - Read │ │ - Read │
|
|
19
|
+
│ delegation│ │ delegation│ │ delegation│
|
|
20
|
+
│ - Execute │ │ - Execute │ │ - Execute │
|
|
21
|
+
│ - Report │ │ - Report │ │ - Report │
|
|
22
|
+
└─────────────┘ └─────────────┘ └─────────────┘
|
|
23
|
+
│ │ │
|
|
24
|
+
└────────────────────┼────────────────────┘
|
|
25
|
+
▼
|
|
26
|
+
┌─────────────────┐
|
|
27
|
+
│ RECONCILER │
|
|
28
|
+
│ │
|
|
29
|
+
│ - Watch CI │
|
|
30
|
+
│ - Detect broken │
|
|
31
|
+
│ - Spawn fixes │
|
|
32
|
+
└─────────────────┘
|
|
33
|
+
│
|
|
34
|
+
▼
|
|
35
|
+
┌─────────────────┐
|
|
36
|
+
│ PROGRESS + │
|
|
37
|
+
│ TODO PERSIST │
|
|
38
|
+
└─────────────────┘
|
|
39
|
+
```
|
package/dist/template/.opencode/skill/swarm-coordination/references/delegation-worker-protocol.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# Delegation Packet Structure and Worker Protocol
|
|
2
|
+
|
|
3
|
+
## Delegation Packet Structure
|
|
4
|
+
|
|
5
|
+
```markdown
|
|
6
|
+
# Delegation Packet
|
|
7
|
+
|
|
8
|
+
- TASK: task-1 - Implement auth service
|
|
9
|
+
- EXPECTED OUTCOME: Auth service with JWT tokens, tests pass
|
|
10
|
+
- REQUIRED TOOLS:
|
|
11
|
+
- read
|
|
12
|
+
- grep
|
|
13
|
+
- lsp
|
|
14
|
+
- edit
|
|
15
|
+
- bash
|
|
16
|
+
- MUST DO:
|
|
17
|
+
- LSP before edits
|
|
18
|
+
- Run npm test after changes
|
|
19
|
+
- Follow existing code patterns
|
|
20
|
+
- MUST NOT DO:
|
|
21
|
+
- No new dependencies
|
|
22
|
+
- Don't edit config files
|
|
23
|
+
- Don't modify shared utilities
|
|
24
|
+
- ACCEPTANCE CHECKS:
|
|
25
|
+
- typecheck: npm run typecheck
|
|
26
|
+
- lint: npm run lint
|
|
27
|
+
- test: npm test
|
|
28
|
+
- CONTEXT:
|
|
29
|
+
See .beads/artifacts/task-1/spec.md for requirements
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Worker Protocol (Updated with Progress Tracking)
|
|
33
|
+
|
|
34
|
+
Workers follow this execution pattern:
|
|
35
|
+
|
|
36
|
+
### 1. Read Delegation
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// First action: read the delegation packet
|
|
40
|
+
read({ filePath: ".beads/artifacts/<task-id>/delegation.md" });
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### 2. Announce Start with Progress
|
|
44
|
+
|
|
45
|
+
```typescript
|
|
46
|
+
await swarm({
|
|
47
|
+
operation: "monitor",
|
|
48
|
+
operation: "progress_update",
|
|
49
|
+
team_name: "plan-implementation",
|
|
50
|
+
worker_id: "worker-1",
|
|
51
|
+
phase: "explore", // or "generate", "reflect", etc.
|
|
52
|
+
progress: 0,
|
|
53
|
+
status: "working",
|
|
54
|
+
file: "src/api/users.ts", // current file being worked on
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 3. Execute Task with Progress Updates
|
|
59
|
+
|
|
60
|
+
Follow the MUST DO constraints. Avoid MUST NOT DO items. Use required tools only.
|
|
61
|
+
|
|
62
|
+
Report progress every 25%:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
// At 25%, 50%, 75% completion
|
|
66
|
+
await swarm({
|
|
67
|
+
operation: "monitor",
|
|
68
|
+
operation: "progress_update",
|
|
69
|
+
team_name: "plan-implementation",
|
|
70
|
+
worker_id: "worker-1",
|
|
71
|
+
phase: "explore",
|
|
72
|
+
progress: 25, // or 50, 75
|
|
73
|
+
status: "working",
|
|
74
|
+
file: "src/api/users.ts",
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 4. Run Acceptance Checks
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Run each check from the delegation packet
|
|
82
|
+
npm run typecheck
|
|
83
|
+
npm run lint
|
|
84
|
+
npm test
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 5. Report Completion
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Mark as completed
|
|
91
|
+
await swarm({
|
|
92
|
+
operation: "monitor",
|
|
93
|
+
operation: "progress_update",
|
|
94
|
+
team_name: "plan-implementation",
|
|
95
|
+
worker_id: "worker-1",
|
|
96
|
+
phase: "explore",
|
|
97
|
+
progress: 100,
|
|
98
|
+
status: "completed",
|
|
99
|
+
file: "src/api/users.ts",
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Error Handling
|
|
104
|
+
|
|
105
|
+
### Worker Fails Acceptance Checks
|
|
106
|
+
|
|
107
|
+
Workers report failures via progress updates with error status:
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
// Worker reports error via progress update
|
|
111
|
+
await swarm({
|
|
112
|
+
operation: "monitor",
|
|
113
|
+
operation: "progress_update",
|
|
114
|
+
team_name: "plan-implementation",
|
|
115
|
+
worker_id: "worker-1",
|
|
116
|
+
phase: "explore",
|
|
117
|
+
progress: 75,
|
|
118
|
+
status: "error",
|
|
119
|
+
message: "typecheck failed: missing type for AuthToken",
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Leader Response
|
|
124
|
+
|
|
125
|
+
1. Check worker status via `swarm({ operation: "monitor", operation: "status" })`
|
|
126
|
+
2. Review error details in progress entries
|
|
127
|
+
3. Decide: fix locally or reassign to new worker
|
|
128
|
+
|
|
129
|
+
### Worker Gets Blocked
|
|
130
|
+
|
|
131
|
+
Workers should report blockers via progress updates:
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
// Worker reports blocker via progress update
|
|
135
|
+
await swarm({
|
|
136
|
+
operation: "monitor",
|
|
137
|
+
operation: "progress_update",
|
|
138
|
+
team_name: "plan-implementation",
|
|
139
|
+
worker_id: "worker-2",
|
|
140
|
+
phase: "explore",
|
|
141
|
+
progress: 50,
|
|
142
|
+
status: "blocked",
|
|
143
|
+
message: "Need auth service types from worker-1",
|
|
144
|
+
});
|
|
145
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Dependency Graph Features
|
|
2
|
+
|
|
3
|
+
The `swarm` tool's plan operation includes full dependency graph analysis:
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
interface DependencyGraph {
|
|
9
|
+
nodes: TaskNode[]; // Individual tasks
|
|
10
|
+
edges: Edge[]; // Dependencies between tasks
|
|
11
|
+
critical_path: string[]; // Longest dependency chain
|
|
12
|
+
parallelizable_groups: string[][]; // Tasks that can run in parallel
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface TaskNode {
|
|
16
|
+
id: string;
|
|
17
|
+
content: string;
|
|
18
|
+
phase: string;
|
|
19
|
+
worker: string;
|
|
20
|
+
status: "pending" | "in_progress" | "completed";
|
|
21
|
+
priority: "high" | "medium" | "low";
|
|
22
|
+
blockedBy: string[]; // Tasks this depends on
|
|
23
|
+
blocks: string[]; // Tasks that depend on this
|
|
24
|
+
assignedFiles: string[]; // Files assigned to this task
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
const analysis = await swarm({
|
|
32
|
+
operation: "plan",
|
|
33
|
+
operation: "analyze",
|
|
34
|
+
task: "Refactor API layer",
|
|
35
|
+
files: "src/api/users.ts,src/api/posts.ts,src/api/auth.ts",
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const plan = JSON.parse(analysis);
|
|
39
|
+
|
|
40
|
+
// Critical path shows the longest dependency chain
|
|
41
|
+
// Focus attention here for optimal completion time
|
|
42
|
+
console.log(`Critical path: ${plan.dependency_graph.critical_path.join(" → ")}`);
|
|
43
|
+
|
|
44
|
+
// Parallelizable groups show which tasks can run simultaneously
|
|
45
|
+
// Each group must complete before starting the next
|
|
46
|
+
for (let i = 0; i < plan.dependency_graph.parallelizable_groups.length; i++) {
|
|
47
|
+
const group = plan.dependency_graph.parallelizable_groups[i];
|
|
48
|
+
console.log(`Wave ${i + 1}: ${group.join(", ")} (${group.length} parallel tasks)`);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Drift Check After Each Wave
|
|
2
|
+
|
|
3
|
+
After every wave completes and before starting the next, run a **drift check** to verify the codebase has not deviated from the intended state. Accumulated drift between waves is the primary cause of cascading failures in large swarms.
|
|
4
|
+
|
|
5
|
+
**Drift** = any difference between actual codebase state and the plan's expected state at a wave boundary.
|
|
6
|
+
|
|
7
|
+
## What to Check
|
|
8
|
+
|
|
9
|
+
| Check | Command | Passing Condition |
|
|
10
|
+
| ----------------- | -------------------------------------------------- | ------------------------------ |
|
|
11
|
+
| Build gates | `npm run typecheck && npm run lint` | Zero errors |
|
|
12
|
+
| Unexpected files | `git diff --name-only HEAD` | Only planned files modified |
|
|
13
|
+
| Missing artifacts | Verify expected files exist | All declared outputs present |
|
|
14
|
+
| Scope adherence | Compare `git status` vs wave's declared file scope | No out-of-scope files modified |
|
|
15
|
+
|
|
16
|
+
## Drift Check Protocol
|
|
17
|
+
|
|
18
|
+
Run after every wave, before spawning the next:
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
async function driftCheckAfterWave(wave: Wave, expectedFiles: string[]) {
|
|
22
|
+
console.log(`\n=== DRIFT CHECK: Wave ${wave.number} ===`);
|
|
23
|
+
|
|
24
|
+
// 1. Build gates must pass
|
|
25
|
+
const gates = await bash("npm run typecheck && npm run lint");
|
|
26
|
+
if (!gates.success) {
|
|
27
|
+
throw new Error(`Wave ${wave.number} drift: build gates failed\n${gates.output}`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 2. Detect unexpected file modifications
|
|
31
|
+
const changedFiles = await bash("git diff --name-only HEAD");
|
|
32
|
+
const actualFiles = changedFiles.output.trim().split("\n").filter(Boolean);
|
|
33
|
+
const unexpected = actualFiles.filter((f) => !expectedFiles.includes(f));
|
|
34
|
+
|
|
35
|
+
if (unexpected.length > 0) {
|
|
36
|
+
console.warn(`⚠️ Unexpected files modified in wave ${wave.number}:`);
|
|
37
|
+
unexpected.forEach((f) => console.warn(` - ${f}`));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 3. Verify declared artifacts exist
|
|
41
|
+
for (const artifact of wave.expectedArtifacts ?? []) {
|
|
42
|
+
const exists = await bash(`test -f ${artifact} && echo "ok" || echo "missing"`);
|
|
43
|
+
if (exists.output.trim() === "missing") {
|
|
44
|
+
throw new Error(`Wave ${wave.number} drift: expected artifact missing: ${artifact}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
console.log(`✓ Drift check passed: Wave ${wave.number}`);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Integration in Wave Execution
|
|
53
|
+
|
|
54
|
+
Call drift check between every wave:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
for (let i = 0; i < waves.length; i++) {
|
|
58
|
+
const wave = waves[i];
|
|
59
|
+
const reconciler = runReconciler(teamName, "npm run typecheck && npm run lint");
|
|
60
|
+
|
|
61
|
+
await Promise.all(wave.tasks.map((task) => spawnWorker(task, teamName)));
|
|
62
|
+
await reconciler;
|
|
63
|
+
|
|
64
|
+
// MANDATORY: Drift check before next wave
|
|
65
|
+
await driftCheckAfterWave(
|
|
66
|
+
wave,
|
|
67
|
+
wave.tasks.flatMap((t) => t.assignedFiles),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
console.log(`✓ Wave ${i + 1}/${waves.length} complete and verified`);
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Drift Response Protocol
|
|
75
|
+
|
|
76
|
+
| Drift Type | Severity | Action |
|
|
77
|
+
| ------------------------ | -------- | ------------------------------------------------ |
|
|
78
|
+
| Build gate failure | Critical | Stop swarm, run reconciler, fix before next wave |
|
|
79
|
+
| Unexpected file modified | Warning | Review change, revert if out of scope |
|
|
80
|
+
| Missing artifact | Critical | Re-run failed worker task, verify output |
|
|
81
|
+
| Scope creep | Warning | Escalate to user if >3 unexpected files changed |
|
|
82
|
+
|
|
83
|
+
## When Drift Is Unrecoverable
|
|
84
|
+
|
|
85
|
+
If drift check fails twice in a row on the same wave:
|
|
86
|
+
|
|
87
|
+
1. **Stop the swarm** - don't start next wave
|
|
88
|
+
2. **Report to user**: exact drift details, failing gate output, list of unexpected files
|
|
89
|
+
3. **Rollback option**: use `git reset --hard <wave-N-start-tag>` (see `executing-plans` skill)
|
|
90
|
+
4. **Never paper over drift** - proceeding with known drift compounds into cascading failure
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Integration with Beads
|
|
2
|
+
|
|
3
|
+
Swarm works on top of Beads:
|
|
4
|
+
|
|
5
|
+
1. **Session start**: `swarm sync push` to make tasks visible
|
|
6
|
+
2. **Leader claims parent** bead
|
|
7
|
+
3. **Workers claim child** beads (via delegation packets)
|
|
8
|
+
4. **Progress tracked** via `swarm monitor progress_update`
|
|
9
|
+
5. **Completion syncs** back via `swarm sync pull`
|
|
10
|
+
6. **Close parent** bead with `br close`
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
// Full integration workflow
|
|
14
|
+
await swarm({ operation: "sync", action: "push" }); // Make Beads visible
|
|
15
|
+
// ... spawn swarm ...
|
|
16
|
+
await swarm({ operation: "monitor", action: "render_block", team_name: "..." }); // Monitor progress
|
|
17
|
+
// ... monitor completion ...
|
|
18
|
+
await swarm({ operation: "sync", action: "pull" }); // Sync completed back
|
|
19
|
+
await bash("br close parent-task --reason 'Swarm completed'");
|
|
20
|
+
```
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# Swarm Launch Flow - PARL Pattern (7 Steps)
|
|
2
|
+
|
|
3
|
+
## Step 0: Task Analysis (Anti-Serial-Collapse + Dependency Graph)
|
|
4
|
+
|
|
5
|
+
Analyze the user's actual task to determine optimal swarm strategy:
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
// 1. Classify the task and build dependency graph
|
|
9
|
+
const analysis = await swarm({
|
|
10
|
+
operation: "plan",
|
|
11
|
+
operation: "analyze",
|
|
12
|
+
task: "<user's request from input>",
|
|
13
|
+
files: "<detected files from glob/grep>",
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Returns:
|
|
17
|
+
// - type: "search" | "batch" | "writing" | "sequential" | "mixed"
|
|
18
|
+
// - recommended_agents: number
|
|
19
|
+
// - phases: [{ name, role, agent_count, dependencies }]
|
|
20
|
+
// - coupling: "high" | "medium" | "low"
|
|
21
|
+
// - confidence: "high" | "medium" | "low"
|
|
22
|
+
// - dependency_graph: { nodes, edges, critical_path, parallelizable_groups }
|
|
23
|
+
|
|
24
|
+
const plan = JSON.parse(analysis);
|
|
25
|
+
|
|
26
|
+
// 2. Check for serial collapse
|
|
27
|
+
const check = await swarm({
|
|
28
|
+
operation: "plan",
|
|
29
|
+
operation: "check",
|
|
30
|
+
task: "<user's request>",
|
|
31
|
+
files: String(plan.file_count),
|
|
32
|
+
recommended_agents: plan.classification.recommended_agents,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// If serial collapse detected, force parallelization
|
|
36
|
+
if (check.serial_collapse_detected) {
|
|
37
|
+
console.log(`⚠️ Serial collapse detected: ${check.warning_signs.join(", ")}`);
|
|
38
|
+
console.log(`✓ Adjusting to ${check.suggested_agents} agents`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// 3. Use dependency graph for spawn ordering
|
|
42
|
+
const { parallelizable_groups, critical_path } = plan.dependency_graph;
|
|
43
|
+
console.log(`Critical path: ${critical_path.join(" → ")}`);
|
|
44
|
+
console.log(`Parallel groups: ${parallelizable_groups.length}`);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Step 1: Session Setup (Push Beads to Todos)
|
|
48
|
+
|
|
49
|
+
Make Beads tasks visible to subagents:
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
// Push Beads to OpenCode todos (subagents see via todoread)
|
|
53
|
+
await swarm({ operation: "sync", operation: "push", filter: "open" });
|
|
54
|
+
|
|
55
|
+
// Check for existing swarm state
|
|
56
|
+
const status = await swarm({
|
|
57
|
+
operation: "monitor",
|
|
58
|
+
operation: "status",
|
|
59
|
+
team_name: "plan-implementation",
|
|
60
|
+
});
|
|
61
|
+
const stats = JSON.parse(status).summary;
|
|
62
|
+
|
|
63
|
+
if (stats.total_workers > 0) {
|
|
64
|
+
console.log(`Found existing swarm with ${stats.total_workers} workers`);
|
|
65
|
+
// Render current progress
|
|
66
|
+
const ui = await swarm({
|
|
67
|
+
operation: "monitor",
|
|
68
|
+
operation: "render_block",
|
|
69
|
+
team_name: "plan-implementation",
|
|
70
|
+
});
|
|
71
|
+
console.log(ui);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Step 2: Create Delegation Packets
|
|
76
|
+
|
|
77
|
+
For each task, create a delegation packet:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
swarm({
|
|
81
|
+
operation: "delegate",
|
|
82
|
+
bead_id: "task-1",
|
|
83
|
+
title: "Implement auth service",
|
|
84
|
+
expected_outcome: "Auth service with JWT tokens, tests pass",
|
|
85
|
+
required_tools: "read, grep, lsp, edit, bash",
|
|
86
|
+
must_do: "LSP before edits, run npm test after changes",
|
|
87
|
+
must_not_do: "No new dependencies, don't edit config files",
|
|
88
|
+
acceptance_checks: "typecheck: npm run typecheck, lint: npm run lint, test: npm test",
|
|
89
|
+
context: "See .beads/artifacts/task-1/spec.md for requirements",
|
|
90
|
+
write: true,
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Step 3: Spawn Worker Agents (Using Dependency Groups)
|
|
95
|
+
|
|
96
|
+
Use parallelizable_groups from dependency graph for proper ordering:
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
// Spawn workers in dependency order
|
|
100
|
+
for (const group of plan.dependency_graph.parallelizable_groups) {
|
|
101
|
+
// All tasks in this group can run in parallel
|
|
102
|
+
const spawnPromises = group.map((taskId) => {
|
|
103
|
+
const node = plan.dependency_graph.nodes.find((n) => n.id === taskId);
|
|
104
|
+
return Task({
|
|
105
|
+
subagent_type: "general",
|
|
106
|
+
description: `Execute ${taskId}`,
|
|
107
|
+
prompt: `Execute bead ${taskId}: ${node.content}
|
|
108
|
+
|
|
109
|
+
Read delegation packet at: .beads/artifacts/${taskId}/delegation.md
|
|
110
|
+
|
|
111
|
+
Files: ${node.assignedFiles.join(", ")}
|
|
112
|
+
Phase: ${node.phase}
|
|
113
|
+
Worker: ${node.worker}
|
|
114
|
+
Team: plan-implementation
|
|
115
|
+
|
|
116
|
+
Requirements:
|
|
117
|
+
1. Follow all MUST DO constraints
|
|
118
|
+
2. Avoid all MUST NOT DO items
|
|
119
|
+
3. Run acceptance checks before claiming done
|
|
120
|
+
4. Report progress via swarm monitor`,
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Wait for parallel group to complete before starting next
|
|
125
|
+
await Promise.all(spawnPromises);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Step 4: Monitor Progress (Real-time TUI + Persistence)
|
|
130
|
+
|
|
131
|
+
Monitor with beautiful block UI, progress tracking, and auto-persistence:
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
let allComplete = false;
|
|
135
|
+
while (!allComplete) {
|
|
136
|
+
// Option A: Render beautiful TUI block
|
|
137
|
+
const ui = await swarm({
|
|
138
|
+
operation: "monitor",
|
|
139
|
+
operation: "render_block",
|
|
140
|
+
team_name: "plan-implementation",
|
|
141
|
+
});
|
|
142
|
+
console.log(ui); // Markdown block with tables, emojis, progress
|
|
143
|
+
|
|
144
|
+
// Option B: Get detailed status
|
|
145
|
+
const status = await swarm({
|
|
146
|
+
operation: "monitor",
|
|
147
|
+
operation: "status",
|
|
148
|
+
team_name: "plan-implementation",
|
|
149
|
+
});
|
|
150
|
+
const stats = JSON.parse(status).summary;
|
|
151
|
+
// Returns: total_workers, completed, working, errors, messages
|
|
152
|
+
|
|
153
|
+
// Check completion
|
|
154
|
+
allComplete = stats.completed === stats.total_workers;
|
|
155
|
+
|
|
156
|
+
if (!allComplete) {
|
|
157
|
+
// Wait before checking again
|
|
158
|
+
await new Promise((r) => setTimeout(r, 2000)); // Wait 2s
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Step 5: Synthesize Results
|
|
164
|
+
|
|
165
|
+
When all workers complete:
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// 1. Get final status
|
|
169
|
+
const finalStatus = await swarm({
|
|
170
|
+
operation: "monitor",
|
|
171
|
+
operation: "status",
|
|
172
|
+
team_name: "plan-implementation",
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// 2. Run full verification
|
|
176
|
+
await bash("npm run typecheck && npm run lint && npm test");
|
|
177
|
+
|
|
178
|
+
// 3. Pull completed todos back to Beads
|
|
179
|
+
await swarm({ operation: "sync", operation: "pull" });
|
|
180
|
+
|
|
181
|
+
// 4. Clear swarm data
|
|
182
|
+
await swarm({ operation: "monitor", operation: "clear", team_name: "plan-implementation" });
|
|
183
|
+
|
|
184
|
+
// 5. Close parent bead
|
|
185
|
+
await bash("br close parent-task --reason 'Swarm completed all subtasks'");
|
|
186
|
+
```
|