opencode-swarm 6.81.0 → 6.82.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.
package/README.md CHANGED
@@ -27,10 +27,10 @@ Most AI coding tools let one model write code and ask that same model whether th
27
27
  ### Key Features
28
28
 
29
29
  - 🏗️ **11 specialized agents** — architect, coder, reviewer, test engineer, critic, critic_sounding_board, critic_drift_verifier, explorer, SME, docs, designer
30
- - 🔒 **Gated pipeline** — code never ships without reviewer + test engineer approval (bypassed in turbo mode)
31
- - 🔄 **Phase completion gates** — completion-verify and drift verifier gates enforced before phase completion (bypassed in turbo mode)
30
+ - 🔒 **Gated pipeline** — code never ships without reviewer + test engineer approval
31
+ - 🔄 **Phase completion gates** — completion-verify and drift verifier gates enforced before phase completion
32
32
  - 🔁 **Resumable sessions** — all state saved to `.swarm/`; pick up any project any day
33
- - 🌐 **20 languages** — TypeScript, TSX, Python, Go, Rust, Java, Kotlin, C, C++, C#, Ruby, Swift, Dart, PHP, JavaScript, CSS, Bash, PowerShell, INI, Regex
33
+ - 🌐 **20 languages** — TypeScript, Python, Go, Rust, Java, Kotlin, C/C++, C#, Ruby, Swift, Dart, PHP, JavaScript, CSS, Bash, PowerShell, INI, Regex
34
34
  - 🛡️ **Built-in security** — SAST, secrets scanning, dependency audit per task
35
35
  - 🆓 **Free tier** — works with OpenCode Zen's free model roster
36
36
  - ⚙️ **Fully configurable** — override any agent's model, disable agents, tune guardrails
@@ -60,380 +60,266 @@ Swarm then:
60
60
  * automated checks run
61
61
  * reviewer checks correctness
62
62
  * test engineer writes and runs tests
63
- * architect runs regression sweep (scope:"graph" to find cross-task test regressions)
63
+ * architect runs regression sweep
64
64
  * failures loop back with structured feedback
65
65
 
66
66
  7. After each phase, docs and retrospectives are updated.
67
67
 
68
- All project state lives in `.swarm/`:
68
+ All project state lives in `.swarm/` — plans, evidence, context, knowledge, and telemetry. Resumable by design. If `.swarm/` already exists, the architect goes straight into **RESUME** → **EXECUTE** instead of repeating discovery.
69
69
 
70
- ```text
71
- .swarm/
72
- ├── plan.md # Projected plan (generated from ledger)
73
- ├── plan.json # Projected plan data (generated from ledger)
74
- ├── plan-ledger.jsonl # Durable append-only ledger — authoritative source of truth (v6.44)
75
- ├── SWARM_PLAN.md # Export checkpoint artifact written on save_plan / phase_complete / close
76
- ├── SWARM_PLAN.json # Export checkpoint artifact (importable via importCheckpoint)
77
- ├── context.md # Technical decisions and SME guidance
78
- ├── spec.md # Feature specification (written by /swarm specify)
79
- ├── close-summary.md # Written by /swarm close with project summary
80
- ├── close-lessons.md # Optional: explicit session lessons for /swarm close to curate
81
- ├── doc-manifest.json # Documentation index built by doc_scan tool
82
- ├── events.jsonl # Event stream for diagnostics
83
- ├── evidence/ # Review/test evidence bundles per task
84
- ├── telemetry.jsonl # Session observability events (JSONL)
85
- ├── curator-summary.json # Curator system state
86
- ├── curator-briefing.md # Curator init briefing injected at session start
87
- └── drift-report-phase-N.json # Plan-vs-reality drift reports (Curator)
88
- ```
89
-
90
- > **Plan durability (v6.44):** `plan-ledger.jsonl` is the authoritative source of truth for plan state. `plan.json` and `plan.md` are projections derived from the ledger — if they are missing or stale, `loadPlan()` auto-rebuilds them from the ledger. `SWARM_PLAN.md` / `SWARM_PLAN.json` are export-only checkpoint artifacts written automatically — use `SWARM_PLAN.json` to restore if both `plan.json` and the ledger are lost.
91
-
92
- Swarm is resumable by design. If `.swarm/` already exists, the architect goes straight into **RESUME** → **EXECUTE** instead of repeating discovery.
93
-
94
- ## Process Remediation Model (PRM)
95
-
96
- Swarm includes a lightweight Process Remediation Model that monitors agent trajectories and injects course-correction guidance before loops form. Based on research from SWE-PRM (arXiv 2509.02360), taxonomy-guided PRMs improve task resolution by detecting failure patterns early.
97
-
98
- ### Detected Patterns
99
-
100
- The PRM detects five trajectory patterns:
101
-
102
- 1. **Repetition Loop** — Same agent performs the same action on the same target file repeatedly
103
- 2. **Ping-Pong** — Agent A hands off to B, B hands back to A, and A hands to B again
104
- 3. **Expansion Drift** — Successive plans grow in scope beyond the original task
105
- 4. **Stuck-on-Test** — Coder edits → tests fail → coder edits same file → tests fail, repeating
106
- 5. **Context Thrashing** — Agent requests increasingly large file sets without narrowing scope
107
-
108
- ### Escalation Protocol
109
-
110
- When a pattern is detected, the PRM tracks escalation levels:
111
-
112
- - **Level 1 (1st detection):** Course-correction guidance is added to `pendingAdvisoryMessages` and injected via the `[ADVISORIES]` block. Sets `escalationLevel = 1`.
113
- - **Level 2 (2nd detection):** Additional guidance added to `pendingAdvisoryMessages`, `architectAlertPending = true` is set, and `telemetry.prmEscalationTriggered()` is emitted. Sets `escalationLevel = 2`.
114
- - **Level 3 (3rd+ detection):** Guidance added to `pendingAdvisoryMessages`, plus a hard stop directive is injected separately via `[HARD STOP]` block. Sets `escalationLevel = 3` and `hardStopPending = true`. Emits `telemetry.prmHardStop()`.
115
-
116
- ### Configuration
70
+ ---
117
71
 
118
- PRM behavior is controlled via the `prm` section in your configuration:
72
+ ## Execution Modes
119
73
 
120
- ```json
121
- {
122
- "prm": {
123
- "enabled": true,
124
- "pattern_thresholds": {
125
- "repetition_loop": 2,
126
- "ping_pong": 4,
127
- "expansion_drift": 3,
128
- "stuck_on_test": 3,
129
- "context_thrash": 5
130
- },
131
- "max_trajectory_lines": 100,
132
- "escalation_enabled": true,
133
- "detection_timeout_ms": 5000
134
- }
135
- }
136
- ```
74
+ Swarm has two independent mode systems:
137
75
 
138
- > **Note:** `max_trajectory_lines`, `escalation_enabled`, and `detection_timeout_ms` are defined in the schema but not yet enforced at runtime. The default trajectory limit is 1000 lines.
76
+ **Session modes** toggle per session with a slash command:
139
77
 
140
- ### Replay Recording
78
+ | Mode | Safety | Speed | When to Use |
79
+ |------|--------|-------|------------|
80
+ | **Balanced** (default) | High | Medium | Everyday development |
81
+ | **Turbo** | Medium | Fast | Rapid iteration; skips Stage B gates for non-Tier-3 files |
82
+ | **Full-Auto** | Depends on critic | Fast | Unattended multi-interaction runs |
141
83
 
142
- PRM records all pattern detections, course corrections, escalations, and hard stops to `.swarm/replays/{sessionId}-{timestamp}.jsonl` for post-mortem analysis. Use the replay artifacts to understand why loops formed and how they were resolved.
84
+ **Project mode** persistent via `execution_mode` config key:
143
85
 
144
- ### Performance
86
+ | Value | Effect |
87
+ |-------|--------|
88
+ | `strict` | Maximum safety — adds slop-detector and incremental-verify hooks |
89
+ | `balanced` (default) | Standard hooks |
90
+ | `fast` | Skips compaction service — for short sessions under context pressure |
145
91
 
146
- Pattern detection runs in less than 100ms per step using rule-based analysis no LLM calls required for detection.
92
+ Switch session modes with `/swarm turbo [on|off]` or `/swarm full-auto [on|off]`. Set project mode in config. The two systems compose independently — see [docs/modes.md](docs/modes.md).
147
93
 
148
94
  ---
149
95
 
150
96
  ## Quick Start
151
97
 
152
- > **Prerequisites:** [OpenCode](https://opencode.ai) installed and working. An API key for at least one LLM provider (or use the free OpenCode Zen tier — no key required).
153
-
154
- ### Step 1 — Install
155
-
156
- ```bash
157
- npm install -g opencode-swarm
158
- ```
98
+ **→ For a complete first-run walkthrough, see [Getting Started](docs/getting-started.md).**
159
99
 
160
- ### Step 2 — Open your project in OpenCode
100
+ The 15-minute guide covers:
101
+ - Installation (`bunx opencode-swarm install`)
102
+ - Selecting the architect in OpenCode
103
+ - Running your first task
104
+ - Troubleshooting common issues
161
105
 
162
- ```bash
163
- cd /your/project
164
- opencode
165
- ```
166
-
167
- ### Step 3 — Select a Swarm architect and describe your goal
168
-
169
- 1. In the OpenCode GUI, open the **agent/mode dropdown** and select a **Swarm architect** (e.g., `architect`).
170
- 2. Type what you want to build:
171
-
172
- ```text
173
- Build a REST API with user registration, login, and JWT auth.
174
- ```
175
-
176
- That's it. The architect coordinates all other agents automatically.
177
-
178
- > **First time?** Run `/swarm diagnose` to verify Swarm is healthy, `/swarm agents` to see registered agents, and `/swarm config` to see the resolved configuration.
179
-
180
- ### Step 4 — Monitor progress
181
-
182
- ```text
183
- /swarm status # Current phase and task
184
- /swarm plan # Full project plan
185
- /swarm evidence # Review and test results per task
186
- ```
187
-
188
- ### Step 5 — Start over if needed
189
-
190
- ```text
191
- /swarm reset --confirm
192
- ```
193
-
194
- ### Step 6 — Configure models (optional)
195
-
196
- Swarm works with its defaults out of the box. To override models, create `.opencode/opencode-swarm.json`:
197
-
198
- ```json
199
- {
200
- "agents": {
201
- "coder": { "model": "opencode/minimax-m2.5-free" },
202
- "reviewer": { "model": "opencode/big-pickle" }
203
- }
204
- }
205
- ```
206
-
207
- You only need to specify the agents you want to override. The `architect` inherits the model currently selected in the OpenCode UI unless you set it explicitly.
208
-
209
- See the [full configuration reference](#configuration-reference) and the [free-tier model setup](#free-tier-opencode-zen-models) for more options.
210
-
211
- ### Step 7 — Performance modes (optional)
106
+ ---
212
107
 
213
- Swarm runs optional quality hooks (slop detection, incremental verification, compaction) on every tool call. For faster iteration, you can skip these:
108
+ ## Commands
214
109
 
215
- **Via slash command** (session-wide):
216
- ```
217
- /swarm turbo
218
- ```
110
+ All 41 subcommands at a glance:
219
111
 
220
- **Via config** (persistent):
221
- ```json
222
- {
223
- "execution_mode": "fast"
224
- }
112
+ ```bash
113
+ /swarm status # Current phase and task
114
+ /swarm plan [N] # Full plan or filtered by phase
115
+ /swarm agents # Registered agents and models
116
+ /swarm diagnose # Health check
117
+ /swarm evidence [task] # Test and review results
118
+ /swarm reset --confirm # Clear swarm state
225
119
  ```
226
120
 
227
- | Mode | Behavior |
228
- |------|----------|
229
- | `strict` | Runs all quality hooks (slop detector, incremental verify, compaction). Maximum safety, highest overhead. |
230
- | `balanced` (default) | Skips optional quality hooks. Recommended for most workflows. |
231
- | `fast` | Same as balanced. Reserved for future more aggressive optimizations. |
232
-
233
- Use `strict` mode for critical security-sensitive changes. Switch to `balanced` for routine development.
121
+ See [docs/commands.md](docs/commands.md) for the full reference (41 commands).
234
122
 
235
123
  ---
236
124
 
237
- ## Common First-Run Questions
238
-
239
- ### "Do I need to select a Swarm architect?"
240
-
241
- **Yes.** You must explicitly choose a Swarm architect agent in the OpenCode GUI before starting your session. If you use the default OpenCode `Build` / `Plan` options, the plugin is bypassed entirely.
242
-
243
- ### "Why did the second run start coding immediately?"
244
-
245
- Because Swarm persists state in `.swarm/` and resumes from where it left off. Check `/swarm status` or `/swarm plan`.
246
-
247
- ### "How do I know Swarm is really active?"
125
+ ## The Agents
248
126
 
249
- Run:
127
+ Swarm has 11 specialized agents. You don't manually switch between them — the architect coordinates automatically.
250
128
 
251
- ```text
252
- /swarm diagnose
253
- /swarm agents
254
- /swarm config
255
- ```
129
+ | Agent | Role |
130
+ |---|---|
131
+ | **architect** | Orchestrates workflow, writes plans, enforces gates |
132
+ | **coder** | Implements one task at a time |
133
+ | **reviewer** | Checks correctness and security |
134
+ | **test_engineer** | Writes and runs tests |
135
+ | **critic** | Reviews plans and challenges findings |
136
+ | **explorer** | Scans codebase and gathers context |
137
+ | **sme** | Provides domain expertise guidance |
138
+ | **docs** | Updates documentation to match implementation |
139
+ | **designer** | Generates UI scaffolds and design tokens |
140
+ | **critic_sounding_board** | Pre-escalation pushback to the architect |
141
+ | **critic_drift_verifier** | Verifies implementation matches plan |
142
+
143
+ Run `/swarm status` and `/swarm agents` to see what's active.
256
144
 
257
- ### "How do I force a clean restart?"
145
+ ---
258
146
 
259
- Run:
147
+ ## How It Compares
260
148
 
261
- ```text
262
- /swarm reset --confirm
263
- ```
149
+ | Feature | Swarm | oh-my-opencode | get-shit-done |
150
+ |---|:-:|:-:|:-:|
151
+ | Multiple specialized agents | ✅ 11 agents | ❌ | ❌ |
152
+ | Plan reviewed before coding | ✅ | ❌ | ❌ |
153
+ | Every task reviewed + tested | ✅ | ❌ | ❌ |
154
+ | Different model for review vs. code | ✅ | ❌ | ❌ |
155
+ | Resumable sessions | ✅ | ❌ | ❌ |
156
+ | Built-in security scanning | ✅ | ❌ | ❌ |
157
+ | Learns from mistakes | ✅ | ❌ | ❌ |
264
158
 
265
159
  ---
266
160
 
267
161
  ## LLM Provider Guide
268
162
 
269
- Swarm works with any LLM provider supported by OpenCode. Different agents benefit from different models — the architect needs strong reasoning, the coder needs strong code generation, and the reviewer benefits from a model different from the coder (to catch blind spots).
163
+ Swarm works with any provider supported by OpenCode.
270
164
 
271
- ### Free Tier OpenCode Zen Models {#free-tier-opencode-zen-models}
165
+ ### Free Tier (OpenCode Zen)
272
166
 
273
- OpenCode Zen provides free models via the `opencode/` provider prefix. These are excellent starting points and require no API key:
167
+ No API key required. Excellent starting point:
274
168
 
275
169
  ```json
276
170
  {
277
171
  "agents": {
278
- "coder": { "model": "opencode/minimax-m2.5-free" },
279
- "reviewer": { "model": "opencode/big-pickle" },
280
- "test_engineer":{ "model": "opencode/gpt-5-nano" },
281
- "explorer": { "model": "opencode/trinity-large-preview-free" },
282
- "sme": { "model": "opencode/trinity-large-preview-free" },
283
- "critic": { "model": "opencode/trinity-large-preview-free" },
284
- "docs": { "model": "opencode/trinity-large-preview-free" },
285
- "designer": { "model": "opencode/trinity-large-preview-free" }
172
+ "coder": { "model": "opencode/minimax-m2.5-free" },
173
+ "reviewer": { "model": "opencode/big-pickle" },
174
+ "explorer": { "model": "opencode/trinity-large-preview-free" }
286
175
  }
287
176
  }
288
177
  ```
289
178
 
290
- > Save this configuration to `.opencode/opencode-swarm.json` in your project root (or `~/.config/opencode/opencode-swarm.json` for global config).
291
-
292
- > **Note:** The `architect` key is intentionally omitted — it inherits whatever model you have selected in the OpenCode UI for maximum reasoning quality.
293
-
294
179
  ### Paid Providers
295
180
 
296
- For production use, mix providers to maximize quality across writing vs. reviewing:
181
+ For production, mix providers by role:
297
182
 
298
- | Agent | Recommended Model | Why |
183
+ | Agent | Recommended | Why |
299
184
  |---|---|---|
300
- | `architect` | OpenCode UI selection | Needs strongest reasoning |
301
- | `coder` | `minimax-coding-plan/MiniMax-M2.5` | Fast, accurate code generation |
302
- | `reviewer` | `zai-coding-plan/glm-5` | Different training data from coder |
303
- | `test_engineer` | `minimax-coding-plan/MiniMax-M2.5` | Same strengths as coder |
304
- | `explorer` | `google/gemini-2.5-flash` | Fast read-heavy analysis |
305
- | `sme` | `kimi-for-coding/k2p5` | Strong domain expertise |
306
- | `critic` | `zai-coding-plan/glm-5` | Independent plan review |
307
- | `docs` | `zai-coding-plan/glm-4.7-flash` | Fast, cost-effective documentation generation |
308
- | `designer` | `kimi-for-coding/k2p5` | Strong UI/UX generation capabilities |
185
+ | architect | OpenCode UI selection | Needs strongest reasoning |
186
+ | coder | minimax-coding-plan/MiniMax-M2.5 | Fast, accurate code generation |
187
+ | reviewer | zai-coding-plan/glm-5 | Different training from coder |
188
+ | test_engineer | minimax-coding-plan/MiniMax-M2.5 | Same strengths as coder |
189
+ | explorer | google/gemini-2.5-flash | Fast read-heavy analysis |
190
+ | sme | kimi-for-coding/k2p5 | Strong domain expertise |
309
191
 
310
192
  ### Provider Formats
311
193
 
312
194
  | Provider | Format | Example |
313
195
  |---|---|---|
314
- | OpenCode Zen (free) | `opencode/<model>` | `opencode/trinity-large-preview-free` |
315
- | Anthropic | `anthropic/<model>` | `anthropic/claude-opus-4-6` |
196
+ | OpenCode Zen | `opencode/<model>` | `opencode/trinity-large-preview-free` |
197
+ | Anthropic | `anthropic/<model>` | `anthropic/claude-sonnet-4-20250514` |
316
198
  | Google | `google/<model>` | `google/gemini-2.5-flash` |
317
199
  | Z.ai | `zai-coding-plan/<model>` | `zai-coding-plan/glm-5` |
318
200
  | MiniMax | `minimax-coding-plan/<model>` | `minimax-coding-plan/MiniMax-M2.5` |
319
201
  | Kimi | `kimi-for-coding/<model>` | `kimi-for-coding/k2p5` |
320
202
 
321
- ### Model Fallback (v6.33)
322
-
323
- When a transient model error occurs (rate limit, 429, 503, timeout, overloaded, model not found), Swarm can automatically switch to a fallback model.
203
+ ### Model Fallback
324
204
 
325
- **Configuration:**
205
+ Automatic fallback to a secondary model on transient errors:
326
206
 
327
207
  ```json
328
208
  {
329
209
  "agents": {
330
210
  "coder": {
331
- "model": "anthropic/claude-opus-4-6",
332
- "fallback_models": [
333
- "anthropic/claude-sonnet-4-5",
334
- "opencode/gpt-5-nano"
335
- ]
211
+ "model": "anthropic/claude-sonnet-4-20250514",
212
+ "fallback_models": ["opencode/gpt-5-nano"]
336
213
  }
337
214
  }
338
215
  }
339
216
  ```
340
217
 
341
- - **`fallback_models`** — Optional array of up to 3 fallback model identifiers. When the primary model fails with a transient error, Swarm injects a `MODEL FALLBACK` advisory and the next retry uses the next fallback model in the list.
342
- - **Advisory injection** — When a transient error is detected, a `MODEL FALLBACK` advisory is injected into the architect's context: *"Transient model error detected (attempt N). The agent model may be rate-limited, overloaded, or temporarily unavailable. Consider retrying with a fallback model or waiting before retrying."*
343
- - **Exhaustion guard** — After exhausting all fallbacks (`modelFallbackExhausted = true`), further transient errors do not spam additional advisories.
344
- - **Reset on success** — Both `model_fallback_index` and `modelFallbackExhausted` reset to 0/false on the next successful tool execution.
218
+ See [docs/configuration.md](docs/configuration.md) for full configuration reference.
219
+
220
+ ---
221
+
222
+ <details>
223
+ <summary><strong>Advanced Topics (Technical Detail)</strong></summary>
224
+
225
+ ### Process Remediation Model (PRM)
226
+
227
+ Swarm monitors agent trajectories and injects course-correction guidance before loops form. Detects five failure patterns:
345
228
 
346
- ### Bounded Coder Revisions (v6.33)
229
+ 1. **Repetition Loop** Same agent performs the same action repeatedly
230
+ 2. **Ping-Pong** — Agents hand off back and forth without progress
231
+ 3. **Expansion Drift** — Plan scope grows beyond original task
232
+ 4. **Stuck-on-Test** — Coder and tests fail in a loop
233
+ 5. **Context Thrashing** — Agent requests increasingly large file sets
347
234
 
348
- When a task requires multiple coder attempts (e.g., reviewer rejections), Swarm tracks how many times the coder has been re-delegated for the same task and warns when limits are approached.
235
+ When detected, escalation levels trigger:
236
+ - Level 1: Advisory guidance injected
237
+ - Level 2: Architect alert sent
238
+ - Level 3: Hard stop directive
349
239
 
350
- **Configuration:**
240
+ Configure via:
351
241
 
352
242
  ```json
353
243
  {
354
- "guardrails": {
355
- "max_coder_revisions": 5
244
+ "prm": {
245
+ "enabled": true,
246
+ "pattern_thresholds": {
247
+ "repetition_loop": 2,
248
+ "ping_pong": 4,
249
+ "expansion_drift": 3,
250
+ "stuck_on_test": 3,
251
+ "context_thrash": 5
252
+ }
356
253
  }
357
254
  }
358
255
  ```
359
256
 
360
- | Parameter | Type | Default | Description |
361
- |-----------|------|---------|-------------|
362
- | `max_coder_revisions` | integer | `5` | Maximum coder re-delegations per task before advisory warning (1–20) |
257
+ > **Note:** Some configuration fields (`max_trajectory_lines`, `escalation_enabled`) are defined in schema but not yet enforced at runtime.
363
258
 
364
- **Behavior:**
365
- - **`coderRevisions` counter** — Incremented each time the coder delegation completes for the same task (reset on new task)
366
- - **`revisionLimitHit` flag** — Set when `coderRevisions >= max_coder_revisions`
367
- - **Advisory injection** — When the limit is hit, a `CODER REVISION LIMIT` advisory is injected: *"Agent has been revised N times (max: M) for task X. Escalate to user or consider a fundamentally different approach."*
368
- - **Persistence** — Both `coderRevisions` and `revisionLimitHit` are serialized/deserialized in session snapshots
259
+ ### Persistent Memory
369
260
 
370
- ## Useful Commands
261
+ **`.swarm/plan-ledger.jsonl`** authoritative source of truth (v6.44 durability model)
371
262
 
372
- | Command | What It Does |
373
- |---------|-------------|
374
- | `/swarm status` | Where am I? Current phase, task progress |
375
- | `/swarm plan` | Show the full project plan |
376
- | `/swarm diagnose` | Health check for swarm state, including config parsing, grammar files, checkpoint manifest, events stream integrity, and steering directive staleness |
377
- | `/swarm evidence 2.1` | Show review/test results for a specific task |
378
- | `/swarm history` | What's been completed so far |
379
- | `/swarm close [--prune-branches]` | Idempotent session close-out: writes retrospectives, curates lessons (reads `.swarm/close-lessons.md` if present), archives evidence, resets `context.md`, cleans config-backup files, optionally prunes merged branches |
380
- | `/swarm reset --confirm` | Start over (clears all swarm state) |
263
+ **`.swarm/context.md`** technical decisions and cached SME guidance
381
264
 
382
- ---
265
+ **`.swarm/evidence/`** — review/test results per task
383
266
 
384
- ## The Agents
267
+ **`.swarm/telemetry.jsonl`** session observability events (fire-and-forget, never blocks execution)
385
268
 
386
- Swarm has specialized internal agents, but you do **not** manually switch into them during normal use.
269
+ **`.swarm/curator-summary.json`** phase-level intelligence and drift reports
387
270
 
388
- The **architect** is the coordinator. It decides when to invoke the other agents and what they should do.
271
+ ### Guardrails & Circuit Breakers
389
272
 
390
- That means the normal user workflow is:
273
+ Every agent runs inside a circuit breaker that prevents runaway behavior:
391
274
 
392
- 1. open the project in OpenCode
393
- 2. describe what you want built or changed
394
- 3. let Swarm coordinate the internal pipeline
395
- 4. inspect progress with `/swarm status`, `/swarm plan`, and `/swarm evidence`
275
+ | Signal | Default Limit |
276
+ |--------|:---:|
277
+ | Tool calls | 200 |
278
+ | Duration | 30 min |
279
+ | Same tool repeated | 10x |
280
+ | Consecutive errors | 5 |
396
281
 
397
- Agent roles (see [Agent Categories](#agent-categories) for classification reference):
282
+ Limits reset per task. Per-agent overrides available in config.
398
283
 
399
- | Agent | Role | When It Runs |
400
- |---|---|---|
401
- | `architect` | Coordinates the workflow, writes plans, enforces gates | Always |
402
- | `explorer` | Scans the codebase and gathers context | Before planning, after phase wrap |
403
- | `sme` | Provides domain guidance | During planning / consultation |
404
- | `critic` | Reviews the plan before execution and blocks coding until approved | Before coding starts (CRITIC-GATE mode) |
405
- | `critic_sounding_board` | Pre-escalation pushback — the architect consults this before contacting the user; returns UNNECESSARY / REPHRASE / APPROVED / RESOLVE | When architect hits an impasse |
406
- | `critic_drift_verifier` | **Phase-close drift detector**: verifies that the completed implementation still matches the original plan spec. Returns APPROVED or NEEDS_REVISION. When NEEDS_REVISION is returned, the phase is **blocked** — the architect must address deviations before calling `phase_complete`. After receiving the verdict, the architect calls `write_drift_evidence` to record the gate result. Bypassed in turbo mode. | Before `phase_complete` (PHASE-WRAP mode) |
407
- | `coder` | Implements one task at a time | During execution |
408
- | `reviewer` | Reviews correctness and security; receives AST semantic diff summary with blast radius | After each task |
409
- | `test_engineer` | Writes and runs tests | After each task |
410
- | `designer` | Generates UI scaffolds and design tokens when needed | UI-specific work |
411
- | `docs` | Updates docs to match what was actually built | After each phase |
412
-
413
- If you want to see what is active right now, run:
284
+ ### File Authority (Per-Agent Write Permissions)
414
285
 
415
- ```text
416
- /swarm status
417
- /swarm agents
418
- ```
286
+ Each agent can only write to specific paths:
419
287
 
420
- ---
288
+ - **architect** — Everything (except `.swarm/plan.md`, `.swarm/plan.json`)
289
+ - **coder** — `src/`, `tests/`, `docs/`, `scripts/`
290
+ - **reviewer** — `.swarm/evidence/`
291
+ - **test_engineer** — `tests/`, `.swarm/evidence/`
292
+ - **explorer, sme** — Read-only
421
293
 
422
- ## How It Compares
294
+ Override via `authority.rules` in config.
423
295
 
424
- | | OpenCode Swarm | oh-my-opencode | get-shit-done |
425
- |---|:-:|:-:|:-:|
426
- | Multiple specialized agents | ✅ 11 agents | ❌ Prompt config | ❌ Single-agent macros |
427
- | Plan reviewed before coding starts | ✅ | ❌ | ❌ |
428
- | Every task reviewed + tested | ✅ | ❌ | ❌ |
429
- | Different model for review vs. coding | ✅ | ❌ | ❌ |
430
- | Saves state to disk, resumable | ✅ | ❌ | ❌ |
431
- | Security scanning built in | ✅ | ❌ | ❌ |
432
- | Learns from its own mistakes | ✅ (retrospectives) | ❌ | ❌ |
296
+ ### Quality Gates
433
297
 
434
- ---
298
+ Built-in tools verify every task before it ships:
435
299
 
436
- ## Agent Categories
300
+ - **syntax_check** — Tree-sitter validation (12 languages)
301
+ - **placeholder_scan** — Catches TODOs, stubs, incomplete code
302
+ - **sast_scan** — 63+ security rules, 9 languages (offline)
303
+ - **sbom_generate** — Dependency tracking (CycloneDX)
304
+ - **quality_budget** — Complexity, duplication, test ratio limits
305
+
306
+ All tools run locally. No Docker, no network calls.
307
+
308
+ ### Context Budget Guard
309
+
310
+ Monitors how much context Swarm injects to prevent overflow:
311
+
312
+ - **Warning threshold (70%)** — Advisory when context reaches ~2800 tokens
313
+ - **Critical threshold (90%)** — Alert at ~3600 tokens with `/swarm handoff` recommendation
314
+ - **Non-nagging** — One-time alerts per session
315
+
316
+ Disable entirely with `context_budget.enabled: false`.
317
+
318
+ ### File Locking for Concurrent Safety
319
+
320
+ Hard lock on `plan.json` (serialized writes), advisory lock on `events.jsonl` (append-only log). Stale locks auto-expire via `proper-lockfile`.
321
+
322
+ ### Agent Categories
437
323
 
438
324
  Agents are classified into four categories for the monitor server `/metadata` endpoint:
439
325
 
@@ -959,6 +845,9 @@ To disable entirely, set `context_budget.enabled: false` in your swarm config.
959
845
  | quality_budget | Enforces complexity, duplication, and test ratio limits |
960
846
  | pre_check_batch | Runs lint, secretscan, SAST, and quality budget in parallel (~15s vs ~60s sequential) |
961
847
  | phase_complete | Enforces phase completion, verifies required agents, requires a valid retrospective evidence bundle, logs events, and resets state; appends to `events.jsonl` with file locking |
848
+ | mutation_test | Applies LLM-generated mutation patches to source files and runs tests to measure kill rate; verdict is pass/warn/fail based on configurable thresholds; used by the mutation_test gate (opt-in, off by default) |
849
+ | generate_mutants | Architect-only: generates LLM-based mutation patches (5–10 per function across 6 types: off-by-one, null substitution, operator swap, guard removal, branch swap, side-effect deletion) for direct consumption by the mutation_test tool; returns SKIP verdict on LLM failure rather than throwing |
850
+ | write_mutation_evidence | Architect-only: writes mutation gate results atomically to `.swarm/evidence/{phase}/mutation-gate.json`; accepts verdict (PASS/WARN/FAIL/SKIP), kill rate metrics, and optional survived mutant details; normalizes uppercase-to-lowercase before persisting |
962
851
 
963
852
 
964
853
  All tools run locally. No Docker, no network calls, no external APIs.
@@ -1263,309 +1152,19 @@ Control how tool outputs are summarized for LLM context.
1263
1152
 
1264
1153
  ---
1265
1154
 
1266
- ## Role-Scoped Tool Filtering
1267
-
1268
- Swarm limits which tools each agent can access based on their role. This prevents agents from using tools that aren't appropriate for their responsibilities, reducing errors and keeping agents focused.
1269
-
1270
- ### Default Tool Allocations
1271
-
1272
- | Agent | Tools | Count | Rationale |
1273
- |-------|-------|:---:|-----------|
1274
- | **architect** | All registered tools | — | Orchestrator needs full visibility |
1275
- | **reviewer** | diff, imports, lint, pkg_audit, pre_check_batch, secretscan, symbols, complexity_hotspots, retrieve_summary, extract_code_blocks, test_runner, suggest_patch, batch_symbols | 13 | Security-focused QA |
1276
- | **coder** | diff, imports, lint, symbols, extract_code_blocks, retrieve_summary, search | 7 | Write-focused, minimal read tools |
1277
- | **test_engineer** | test_runner, diff, symbols, extract_code_blocks, retrieve_summary, imports, complexity_hotspots, pkg_audit, search | 9 | Testing and verification |
1278
- | **explorer** | complexity_hotspots, detect_domains, extract_code_blocks, gitingest, imports, retrieve_summary, schema_drift, symbols, todo_extract, search, batch_symbols | 11 | Discovery and analysis |
1279
- | **sme** | complexity_hotspots, detect_domains, extract_code_blocks, imports, retrieve_summary, schema_drift, symbols | 7 | Domain expertise research |
1280
- | **critic** | complexity_hotspots, detect_domains, imports, retrieve_summary, symbols | 5 | Plan review, minimal toolset |
1281
- | **docs** | detect_domains, doc_extract, doc_scan, extract_code_blocks, gitingest, imports, retrieve_summary, schema_drift, symbols, todo_extract | 10 | Documentation synthesis and discovery |
1282
- | **designer** | extract_code_blocks, retrieve_summary, symbols | 3 | UI-focused, minimal toolset |
1283
-
1284
- ### Configuration
1285
-
1286
- Tool filtering is enabled by default. Customize it in your config:
1287
-
1288
- ```json
1289
- {
1290
- "tool_filter": {
1291
- "enabled": true,
1292
- "overrides": {
1293
- "coder": ["diff", "imports", "lint", "symbols", "test_runner"],
1294
- "reviewer": ["diff", "secretscan", "sast_scan", "symbols"]
1295
- }
1296
- }
1297
- }
1298
- ```
1299
-
1300
- | Option | Type | Default | Description |
1301
- |--------|------|---------|-------------|
1302
- | `enabled` | boolean | `true` | Enable tool filtering globally |
1303
- | `overrides` | Record<string, string[]> | `{}` | Per-agent tool whitelist. Empty array denies all tools. |
1304
-
1305
- ### Troubleshooting: Agent Missing a Tool
1306
-
1307
- If an agent reports it doesn't have access to a tool it needs:
1308
-
1309
- 1. Check if the tool is in the agent's default allocation (see table above)
1310
- 2. Add a custom override in your config:
1311
-
1312
- ```json
1313
- {
1314
- "tool_filter": {
1315
- "overrides": {
1316
- "coder": ["diff", "imports", "lint", "symbols", "extract_code_blocks", "retrieve_summary", "test_runner"]
1317
- }
1318
- }
1319
- }
1320
- ```
1321
-
1322
- 3. To completely disable filtering for all agents:
1323
-
1324
- ```json
1325
- {
1326
- "tool_filter": {
1327
- "enabled": false
1328
- }
1329
- }
1330
- ```
1331
-
1332
- ### Available Tools Reference
1333
-
1334
- The following tools can be assigned to agents via overrides:
1335
-
1336
- | Tool | Purpose |
1337
- |------|---------|
1338
- | `batch_symbols` | Extract exported symbols from multiple files in a single call; per-file error isolation; 75–98% call reduction vs sequential (v6.45); registered for architect, explorer, reviewer |
1339
- | `checkpoint` | Save/restore git checkpoints |
1340
- | `check_gate_status` | Read-only query of task gate status |
1341
- | `co_change_analyzer` | Scan git history for files that co-change frequently; generates dark matter architecture knowledge entries during DISCOVER mode (v6.41); architect-only |
1342
- | `complexity_hotspots` | Identify high-risk code areas |
1343
- | `declare_scope` | Pre-declare the file scope for the next coder delegation (architect-only); violations trigger warnings |
1344
- | `detect_domains` | Detect SME domains from text |
1345
- | `diff` | Analyze git diffs and changes |
1346
- | `doc_extract` | Extract actionable constraints from project documentation relevant to current task (Jaccard bigram scoring + dedup) |
1347
- | `doc_scan` | Scan project documentation and build index manifest at `.swarm/doc-manifest.json` (mtime-based caching) |
1348
- | `evidence_check` | Verify task evidence |
1349
- | `extract_code_blocks` | Extract code from markdown |
1350
- | `gitingest` | Ingest external repositories |
1351
- | `imports` | Analyze import relationships |
1352
- | `lint` | Run project linters |
1353
- | `phase_complete` | Enforces phase completion, verifies required agents, logs events, resets state; appends to `events.jsonl` with file locking |
1354
- | `pkg_audit` | Security audit of dependencies |
1355
- | `pre_check_batch` | Parallel pre-checks (lint, secrets, SAST, quality) |
1356
- | `retrieve_summary` | Retrieve summarized tool outputs |
1357
- | `save_plan` | Persist plan to `.swarm/plan.json`, `plan.md`, and ledger; also writes `SWARM_PLAN.md` / `SWARM_PLAN.json` checkpoint artifacts; requires explicit `working_directory` parameter |
1358
- | `schema_drift` | Detect OpenAPI/schema drift |
1359
- | `search` | Workspace-scoped ripgrep-style structured text search; literal and regex modes, glob filtering, result limits (v6.45); registered for architect, coder, reviewer, explorer, test_engineer |
1360
- | `secretscan` | Scan for secrets in code |
1361
- | `suggest_patch` | Generate contextual diff hunks without modifying files; read-only patch suggestions for reviewer→coder handoff (v6.45); registered for reviewer and architect |
1362
- | `symbols` | Extract exported symbols |
1363
- | `test_runner` | Run project tests |
1364
- | `update_task_status` | Mark plan tasks as pending/in_progress/completed/blocked; track phase progress; acquires lock on `plan.json` before writing |
1365
- | `todo_extract` | Extract TODO/FIXME comments |
1366
- | `write_retro` | Document phase retrospectives via the phase_complete workflow; capture lessons learned |
1367
- | `write_drift_evidence` | Write drift verification evidence after critic_drift_verifier completes; architect calls this after receiving the verifier’s verdict — the critic does not write files directly |
1368
-
1369
- ---
1370
-
1371
- <details>
1372
- <summary><strong>Recent Changes (v6.12 – v6.31+)</strong></summary>
1373
-
1374
- > For the complete version history, see [CHANGELOG.md](CHANGELOG.md) or [docs/releases/](docs/releases/).
1375
-
1376
- ### v6.47.0 — `/swarm close` Full Session Close-Out
1377
-
1378
- - **`/swarm close` expanded**: Now performs complete close-out: resets `context.md`, deletes stale `config-backup-*.json` files, supports plan-free sessions (PR reviews, investigations), and accepts `--prune-branches` to delete local branches whose remote tracking ref is `gone` (merged/deleted upstream).
1379
- - **Lesson injection**: If `.swarm/close-lessons.md` exists when `/swarm close` runs, the architect’s explicit lessons are curated into the knowledge base before the file is deleted.
1380
-
1381
- ### v6.45.0 — New Search, Patch, and Batch Tools
1382
-
1383
- - **`search` tool**: Workspace-scoped ripgrep-style structured search with literal/regex modes and glob filtering. Registered for architect, coder, reviewer, explorer, test_engineer.
1384
- - **`suggest_patch` tool**: Reviewer-safe context-anchored patch suggestion. Generates diff hunks without writing files. Registered for reviewer and architect.
1385
- - **`batch_symbols` tool**: Batched symbol extraction from multiple files in one call; per-file error isolation; 75–98% call reduction vs sequential single-file calls. Registered for architect, explorer, reviewer.
1386
- - **Step 5l-ter**: Test drift detection step added to the EXECUTE pipeline. Fires conditionally when changes involve command behaviour, parsing/routing logic, user-visible output, public contracts, assertion-heavy areas, or helper lifecycle changes.
1387
-
1388
- ### v6.44.0 — Durable Plan Ledger
1389
-
1390
- - **`plan-ledger.jsonl`**: Append-only JSONL ledger is now the authoritative source of truth for plan state. `plan.json` and `plan.md` are projections derived from the ledger. `loadPlan()` auto-rebuilds projections from the ledger on hash mismatch.
1391
- - **Checkpoint artifacts**: `writeCheckpoint()` writes `SWARM_PLAN.md` and `SWARM_PLAN.json` at the project root on every `save_plan`, `phase_complete`, and `/swarm close`. Use `SWARM_PLAN.json` to restore after data loss.
1392
- - **Auto-generated tool lists**: Architect prompt `YOUR TOOLS` and `Available Tools` sections are now generated from `AGENT_TOOL_MAP.architect` — no more hand-maintained lists that drift.
1393
- - See [docs/plan-durability.md](docs/plan-durability.md) for migration notes.
1394
-
1395
- ### v6.42.0 — Curator LLM Delegation Wired
1396
-
1397
- - **Curator now performs real LLM analysis**: Previously the LLM delegation was scaffolded but never connected — every call fell through to data-only mode. All three call sites now invoke the Explorer agent with curator-specific system prompts.
1398
- - **`curator.enabled` now defaults to `true`**: The curator falls back gracefully to data-only mode when no SDK client is available (e.g., in unit tests). If you relied on the previous `false` default, set `"curator": { "enabled": false }` explicitly.
1399
-
1400
- ### v6.41.0 — Dark Matter Detection + `/swarm close` + Drift Evidence Tool
1401
-
1402
- - **Dark matter detection pipeline**: During DISCOVER mode, automatically scans git history for files that frequently co-change. Results are stored as `architecture` knowledge entries and the architect is guided to consider co-change partners when declaring scope. Silently skips repos with fewer than 20 commits or no git history.
1403
- - **`/swarm close` command**: New idempotent close command. Writes retrospectives for in-progress phases, curates session lessons via the knowledge pipeline, archives evidence, marks phases/tasks as `closed`, writes `.swarm/close-summary.md`, and cleans state.
1404
- - **`write_drift_evidence` tool**: New architect tool for persisting drift verification evidence after critic_drift_verifier delegation
1405
- - Accepts phase number, verdict (APPROVED/NEEDS_REVISION), and summary
1406
- - Normalizes verdict automatically (APPROVED → approved, NEEDS_REVISION → rejected)
1407
- - Writes gate-contract formatted evidence to `.swarm/evidence/{phase}/drift-verifier.json`
1408
-
1409
- ### v6.31.0 — process.cwd() Cleanup + Watchdog + Knowledge Tools
1410
-
1411
- - **process.cwd() cleanup**: All 14 source files now use plugin-injected `directory` parameter. Five tools migrated to `createSwarmTool` wrapper.
1412
- - **`curator_analyze` tool**: Architect can now explicitly trigger phase analysis and apply curator recommendations.
1413
- - **Watchdog system**: `scope_guard` (blocks out-of-scope writes), `delegation_ledger` (tracks per-session tool calls), and loop-detector escalation.
1414
- - **Self-correcting workflow**: `self_review` advisory hook after task transitions; `checkStaleImports` heuristic for unused import detection.
1415
- - **Knowledge memory tools**: `knowledge_recall`, `knowledge_add`, `knowledge_remove` — any agent can now directly access the persistent knowledge base.
1416
-
1417
- ### v6.30.1 — Bug Fixes
1418
-
1419
- - **Package manager detection**: `incremental_verify` now detects bun/npm/pnpm/yarn from lockfiles instead of always using `bun`.
1420
- - **spawnAsync OOM fix**: 512KB output cap prevents infinite-output commands from OOM-crashing.
1421
- - **Windows spawn fix**: `npx.cmd`, `npm.cmd`, `pnpm.cmd`, `yarn.cmd` resolved correctly on Windows.
1422
- - **Curator config fix**: `applyCuratorKnowledgeUpdates` now receives fully-populated `KnowledgeConfig`.
1423
- - **Rehydration race guard**: Concurrent `loadSnapshot` calls no longer silently drop workflow state.
1424
-
1425
- ### v6.29.4 — Cross-Task Regression Sweep
1426
-
1427
- - **Regression sweep**: Architect dispatches `scope:"graph"` test runs after each task to catch cross-task regressions (found 15 in RAGAPPv2 retrospective).
1428
- - **Curator data pipeline**: Curator outputs now visible to the architect via advisory injection.
1429
- - **Full-suite opt-in**: Explicit flag unlocks full `bun test` execution when needed.
1430
-
1431
- ### v6.29.3 — Curator Visibility + Documentation Refresh
1432
-
1433
- - **Curator status in diagnose**: `/swarm diagnose` now reports whether Curator is enabled/disabled and validates `curator-summary.json`.
1434
- - **README and config docs refreshed**: Updated `.swarm/` directory tree, Curator configuration options, and drift report artifacts.
1435
-
1436
- ### v6.29.2 — Multi-Language Incremental Verify + Slop-Detector Hardening
1437
-
1438
- - **Multi-language incremental_verify**: Post-coder typecheck supports TypeScript/JavaScript, Go, Rust, and C#.
1439
- - **Slop-detector hardening**: Multi-language heuristics for placeholder code detection across Go/Rust/C#/Python.
1440
- - **CODEBASE REALITY CHECK**: Explorer verifies referenced items before planning (NOT STARTED / PARTIALLY DONE / ALREADY COMPLETE / ASSUMPTION INCORRECT).
1441
- - **Evidence schema fix**: Evidence bundles now correctly validate against schema.
1442
-
1443
- ### v6.29.1 — Advisory Hook Message Injection
1444
-
1445
- - **Advisory hook message injection**: Enhanced message formatting for self-coding detection, partial gate tracking, batch detection, and scope violation warnings.
1446
-
1447
- ### v6.26 through v6.28 — Session Durability + Turbo Mode
1448
-
1449
- - **Turbo Mode**: Accelerated task delegation for faster pipeline execution.
1450
- - **Session durability**: Directory-based evidence writes, task ID recovery from `plan.json` for cold/resumed sessions.
1451
- - **Gate recovery fix** (v6.26.1): `update_task_status(completed)` no longer blocks pure-verification tasks without a prior coder delegation.
1452
-
1453
- ### v6.22 — Curator Background Analysis + Session State Persistence
1454
-
1455
- This release adds the optional Curator system for phase-level intelligence and fixes session snapshot persistence for task workflow states.
1456
-
1457
- - **Curator system**: Background analysis system (`curator.enabled = false` by default in v6.22; **changed to `true` in v6.42**). After each phase, collects events, checks compliance, and writes drift reports to `.swarm/drift-report-phase-N.json`. Three integration points: init on first phase, phase analysis after each phase, and drift injection into architect context at phase start.
1458
- - **Drift reports**: `runCriticDriftCheck` compares planned vs. actual decisions and writes structured drift reports with alignment scores (`ALIGNED` / `MINOR_DRIFT` / `MAJOR_DRIFT` / `OFF_SPEC`). Latest drift summary is prepended to the architect's knowledge context each phase.
1459
- - **Issue #81 fix — taskWorkflowStates persistence**: Session snapshots now correctly serialize and restore the per-task state machine. Invalid state values are filtered to `idle` on deserialization. `reconcileTaskStatesFromPlan` seeds task states from `plan.json` on snapshot load (completed → `tests_run`, in-progress → `coder_delegated`).
1460
-
1461
- See the [Curator section](#curator) above for configuration details and the [v6.22 release notes](docs/releases/v6.22.0.md) for the full change list.
1462
-
1463
- ### v6.21 — Gate Enforcement Hardening
1464
-
1465
- This release replaces soft advisory warnings with hard runtime blocks and adds structural compliance tooling for all model tiers.
1466
-
1467
- #### Phase 1 — P0 Bug Fixes: Hard Blocks Replace Soft Warnings
1468
-
1469
- - **`qaSkipCount` reset fixed**: The skip-detection counter in `delegation-gate.ts` now resets only when **both** reviewer **and** test_engineer have been seen since the last coder entry — not when either one runs alone.
1470
- - **`update_task_status` reviewer gate check**: Accepting `status='completed'` now validates that the reviewer gate is present in the session's `gateLog` for the given task. Missing reviewer returns a structured error naming the absent gate.
1471
- - **Architect self-coding hard block**: `architectWriteCount ≥ 3` now throws an `Error` with message `SELF_CODING_BLOCK` (previously a warning only). Counts 1–2 remain advisory warnings. Counter resets on coder delegation.
1472
-
1473
- #### Phase 2 — Per-Task State Machine
1474
-
1475
- Every task now has a tracked workflow state in the session:
1476
-
1477
- | State | Meaning |
1478
- |-------|---------|
1479
- | `idle` | Task not started |
1480
- | `coder_delegated` | Coder has received the delegation |
1481
- | `pre_check_passed` | Automated gates (lint, SAST, secrets, quality) passed |
1482
- | `reviewer_run` | Reviewer agent has returned a verdict |
1483
- | `tests_run` | Test engineer has completed (verification + adversarial) |
1484
- | `complete` | `update_task_status` accepted the `completed` transition |
1485
-
1486
- Transitions are forward-only. `advanceTaskState()` throws `INVALID_TASK_STATE_TRANSITION` if an illegal jump is attempted. `getTaskState()` returns `'idle'` for unknown tasks.
1487
-
1488
- `session.lastGateOutcome` records the most recent gate result: `{ gate, taskId, passed, timestamp }`.
1489
-
1490
- #### Phase 3 — State Machine Integration
1491
-
1492
- - `update_task_status` now uses the state machine (not a raw `gateLog.has()` check): `status='completed'` is rejected unless the task is in `'tests_run'` or `'complete'` state.
1493
- - `delegation-gate.ts` protocol-violation check additionally verifies that the prior task's state has advanced past `'coder_delegated'` before allowing a new coder delegation.
1494
-
1495
- #### Phase 4 — Context Engineering
1496
-
1497
- - **Progressive task disclosure**: When >5 tasks are visible in the last user message, `delegation-gate.ts` trims to the current task ± a context window. A `[Task window: showing N of M tasks]` comment marks the trim point.
1498
- - **Deliberation preamble**: Each architect turn is prefixed with `[Last gate: {tool} {result} for task {taskId}]` sourced from `session.lastGateOutcome`, prompting the architect to identify the single next step.
1499
- - **Low-capability model detection**: `LOW_CAPABILITY_MODELS` constant (matches substrings `mini`, `nano`, `small`, `free`) and `isLowCapabilityModel(modelId)` helper added to `constants.ts`.
1500
- - **Behavioral guidance markers**: Three `<!-- BEHAVIORAL_GUIDANCE_START --> … <!-- BEHAVIORAL_GUIDANCE_END -->` pairs wrap the BATCHING DETECTION, ARCHITECT CODING BOUNDARIES, and QA gate behavioral sections in the architect prompt.
1501
- - **Tier-based prompt trimming**: When `session.activeModel` matches `isLowCapabilityModel()`, the behavioral guidance blocks are stripped from the architect prompt and replaced with `[Enforcement: programmatic gates active]`. Programmatic enforcement substitutes for verbose prompt instructions on smaller models.
1502
-
1503
- #### Phase 5 — Structural Scope Declaration (`declare_scope`)
1504
-
1505
- New architect-only tool and supporting runtime enforcement:
1506
-
1507
- - **`declare_scope` tool**: Pre-declares which files the coder is allowed to modify for a given task. Input: `{ taskId, files, whitelist?, working_directory? }`. Validates task ID format, plan membership, and non-`complete` state. On success, sets `session.declaredCoderScope`. Architect-only.
1508
- - **Automatic scope from FILE: directives**: When a coder delegation is detected, `delegation-gate.ts` extracts FILE: directive values and stores them as `session.declaredCoderScope` automatically — no explicit `declare_scope` call required.
1509
- - **Scope containment tracking**: `guardrails.ts` appends every file the architect writes to `session.modifiedFilesThisCoderTask`. On coder delegation start, the list resets to `[]`.
1510
- - **Violation detection**: After a coder task completes, `toolAfter` compares `modifiedFilesThisCoderTask` against `declaredCoderScope`. If >2 files are outside the declared scope, `session.lastScopeViolation` is set. The next architect message receives a scope violation warning.
1511
- - **`isInDeclaredScope(filePath, scopeEntries)`**: Module-level helper using `path.resolve()` + `path.relative()` for proper directory containment (not string matching).
1512
-
1513
- ### v6.13.2 — Pipeline Enforcement
1514
-
1515
- This release adds enforcement-layer tooling and self-healing guardrails:
1516
-
1517
- - **`phase_complete` tool**: Verifies all required agents were dispatched before a phase closes; emits events to `.swarm/events.jsonl`; configurable `enforce`/`warn` policy
1518
- - **Summarization loop fix**: `exempt_tools` config prevents `retrieve_summary` and `task` outputs from being re-summarized (fixes Issue #8)
1519
- - **Same-model adversarial detection**: Warns when coder and reviewer share the same model; `warn`/`gate`/`ignore` policy
1520
- - **Architect test guardrail (HF-1b)**: Prevents architect from running full `bun test` suite — must target specific files one at a time
1521
- - **Docs**: `docs/swarm-briefing.md` (LLM pipeline briefing), Task Field Reference in `docs/planning.md`
1522
-
1523
- ### v6.13.1 — Consolidation & Defaults Fix
1524
-
1525
- - **`consolidateSystemMessages`**: Merges multiple system messages into one at index 0
1526
- - **Test isolation helpers**: `createIsolatedTestEnv` and `assertSafeForWrite`
1527
- - **Coder self-verify guardrail (HF-1)**: Coder and test_engineer agents blocked from running build/test/lint
1528
- - **`/swarm` template fix**: `{{arguments}}` → `$ARGUMENTS`
1529
- - **DEFAULT_MODELS update**: `claude-sonnet-4-5` → `claude-sonnet-4-20250514`, `gemini-2.0-flash` → `gemini-2.5-flash`
1530
-
1531
- ### v6.13.0 — Context Efficiency
1532
-
1533
- This release focuses on reducing context usage and improving mode-conditional behavior:
1534
-
1535
- - **Role-Scoped Tool Filtering**: Agent tools filtered via AGENT_TOOL_MAP
1536
- - **Plan Cursor**: Compressed plan summary under 1,500 tokens
1537
- - **Mode Detection**: DISCOVER/PLAN/EXECUTE/PHASE-WRAP/UNKNOWN modes
1538
- - **Tool Output Truncation**: diff/symbols outputs truncated with footer
1539
- - **ZodError Fixes**: Optional current_phase, 'completed' status support
1540
-
1541
- ### v6.12.0 — Anti-Process-Violation Hardening
1542
-
1543
- This release adds runtime detection hooks to catch and warn about architect workflow violations:
1544
-
1545
- - **Self-coding detection**: Warns when the architect writes code directly instead of delegating
1546
- - **Partial gate tracking**: Detects when QA gates are skipped
1547
- - **Self-fix detection**: Warns when an agent fixes its own gate failure (should delegate to fresh agent)
1548
- - **Batch detection**: Catches "implement X and add Y" batching in task requests
1549
- - **Zero-delegation detection**: Warns when tasks complete without any coder delegation; supports parsing delegation envelopes from JSON or KEY: VALUE text format for validation.
1550
-
1551
- These hooks are advisory (warnings only) and help maintain workflow discipline during long sessions.
1552
-
1553
- ### v6.19 — Critic Sounding Board + Complexity-Scaled Review
1155
+ ## Supported Languages
1554
1156
 
1555
- - **Critic sounding board**: Before escalating to the user, the Architect consults the critic in SOUNDING_BOARD mode. Returns: UNNECESSARY, REPHRASE, APPROVED, or RESOLVE.
1556
- - **Escalation discipline**: Three-tier hierarchy self-resolve → critic consult → user escalation (requires critic APPROVED).
1557
- - **Retry circuit breaker**: After 3 coder rejections, the Architect simplifies the approach instead of adding more logic.
1558
- - **Intent reconstruction**: Reviewer reconstructs developer intent from task specs and diffs before evaluating changes.
1559
- - **Complexity-scaled review**: TRIVIAL → Tier 1 only; MODERATE → Tiers 1–2; COMPLEX → all three tiers.
1560
- - **`meta.summary` convention**: Agents include one-line summaries in state events for downstream agent consumption.
1157
+ Full Tier-1 support: TypeScript, JavaScript, Python, Go, Rust
1158
+ Tier-2 support: Java, Kotlin, C#, C/C++, Swift
1159
+ Tier-3 support: Dart, Ruby, PHP/Laravel
1561
1160
 
1562
- </details>
1161
+ All binaries optional. Missing tools produce soft warnings, never hard-fail.
1563
1162
 
1564
1163
  ---
1565
1164
 
1566
1165
  ## Testing
1567
1166
 
1568
- 6,000+ tests. Unit, integration, adversarial, and smoke. Zero additional test dependencies.
1167
+ 6,000+ tests. Unit, integration, adversarial, and smoke. Run with:
1569
1168
 
1570
1169
  ```bash
1571
1170
  bun test
@@ -1575,139 +1174,26 @@ bun test
1575
1174
 
1576
1175
  ## Design Principles
1577
1176
 
1578
- 1. **Plan before code.** The critic approves the plan before a single line is written.
1579
- 2. **One task at a time.** The coder gets one task and full context. Nothing else.
1177
+ 1. **Plan before code.** Critic approves the plan before a single line is written.
1178
+ 2. **One task at a time.** Coder gets one task and full context. Nothing else.
1580
1179
  3. **Review everything immediately.** Correctness, security, tests, adversarial tests. Every task.
1581
- 4. **Different models catch different bugs.** The coder's blind spot is the reviewer's strength.
1582
- 5. **Save everything to disk.** Any session, any model, any day, pick up where you left off.
1583
- 6. **Document failures.** Rejections and retries are recorded. After 5 failures, it escalates to you.
1584
-
1585
- ---
1586
-
1587
- ## Supported Languages
1588
-
1589
- OpenCode Swarm v6.46+ ships with language profiles for 12 languages across three quality tiers. All tools use graceful degradation — if a binary is not on PATH, the tool skips with a soft warning rather than a hard failure.
1590
-
1591
- | Language | Tier | Syntax | Build | Test | Lint | Audit | SAST |
1592
- |---|:---:|:---:|:---:|:---:|:---:|:---:|:---:|
1593
- | TypeScript / JavaScript | 1 | ✅ | ✅ | ✅ | ✅ Biome / ESLint | ✅ npm audit | ✅ Semgrep |
1594
- | Python | 1 | ✅ | ✅ | ✅ pytest | ✅ ruff | ✅ pip-audit | ✅ Semgrep |
1595
- | Rust | 1 | ✅ | ✅ | ✅ cargo test | ✅ clippy | ✅ cargo audit | ✅ Semgrep |
1596
- | Go | 1 | ✅ | ✅ | ✅ go test | ✅ golangci-lint | ✅ govulncheck | ✅ Semgrep |
1597
- | Java | 2 | ✅ | ✅ Gradle / Maven | ✅ JUnit | ✅ Checkstyle | — | ✅ Semgrep |
1598
- | Kotlin | 2 | ✅ | ✅ Gradle | ✅ JUnit | ✅ ktlint | — | 🔶 Semgrep beta |
1599
- | C# / .NET | 2 | ✅ | ✅ dotnet build | ✅ dotnet test | ✅ dotnet format | ✅ dotnet list | ✅ Semgrep |
1600
- | C / C++ | 2 | ✅ | ✅ cmake / make | ✅ ctest | ✅ cppcheck | — | 🔶 Semgrep exp. |
1601
- | Swift | 2 | ✅ | ✅ swift build | ✅ swift test | ✅ swiftlint | — | 🔶 Semgrep exp. |
1602
- | Dart / Flutter | 3 | ✅ | ✅ dart pub | ✅ dart test | ✅ dart analyze | ✅ dart pub outdated | — |
1603
- | Ruby | 3 | ✅ | — | ✅ RSpec / minitest | ✅ RuboCop | ✅ bundle-audit | 🔶 Semgrep exp. |
1604
- | PHP / Laravel | 3 | ✅ | ✅ Composer install | ✅ PHPUnit / Pest / artisan test | ✅ Pint / PHP-CS-Fixer | ✅ composer audit | ✅ 10+ native rules |
1605
-
1606
- > **PHP + Laravel baseline**: PHP v6.49+ ships with deterministic Laravel project detection (multi-signal: `artisan` file, `laravel/framework` dependency, `config/app.php`). When detected, commands are automatically overridden to `php artisan test`, Pint formatting, and PHPStan static analysis. Laravel-specific SAST rules cover SQL injection via raw queries, mass-assignment vulnerabilities, and destructive migrations without rollback. `.blade.php` files are included in all scanning pipelines.
1607
-
1608
- **Tier definitions:**
1609
- - **Tier 1** — Full pipeline: all tools integrated and tested end-to-end.
1610
- - **Tier 2** — Strong coverage: most tools integrated; some optional (audit, SAST).
1611
- - **Tier 3** — Basic coverage: core tools integrated; advanced tooling limited.
1612
-
1613
- > All binaries are optional. Missing tools produce a soft warning and skip — the pipeline never hard-fails on a missing linter or auditor.
1614
-
1615
- ---
1616
-
1617
- ## Curator
1618
-
1619
- The Curator is a background analysis system that runs after each phase. It is **enabled by default** as of v6.42 (`curator.enabled = true`) and never blocks execution — all Curator operations are wrapped in try/catch. It falls back gracefully to data-only mode when no SDK client is available.
1620
-
1621
- Since v6.42, the Curator performs real LLM analysis by delegating to the Explorer agent with curator-specific prompts. Before v6.42, the LLM delegation was scaffolded but never wired.
1622
-
1623
- To disable, set `"curator": { "enabled": false }` in your config. When enabled, it writes `.swarm/curator-summary.json`, `.swarm/curator-briefing.md`, and `.swarm/drift-report-phase-N.json` files.
1624
-
1625
- ### What the Curator Does
1626
-
1627
- - **Init** (`phase-monitor.ts`): On the first phase, initializes a curator summary file at `.swarm/curator-summary.json` and persists the init briefing to `.swarm/curator-briefing.md`.
1628
- - **Phase analysis** (`phase-complete.ts`): After each phase completes, collects phase events, checks compliance, and optionally invokes the curator explorer to summarize findings.
1629
- - **Compliance surfacing** (`phase-complete.ts`): Compliance observations are surfaced in the return value's warnings array (unless `suppress_warnings` is true).
1630
- - **Knowledge updates** (`phase-complete.ts`): Merges curator findings into the knowledge base up to the configured `max_summary_tokens` cap.
1631
- - **Briefing injection** (`knowledge-injector.ts`): The curator-briefing.md content is injected into the architect's context at session start.
1632
- - **Drift injection** (`knowledge-injector.ts`): Prepends the latest drift report summary to the architect's knowledge context at phase start, up to `drift_inject_max_chars` characters. Drift reports now inject even when no knowledge entries exist.
1633
-
1634
- ### Configuration
1635
-
1636
- Add a `curator` block to `.opencode/opencode-swarm.json`:
1637
-
1638
- ```json
1639
- {
1640
- "curator": {
1641
- "enabled": true,
1642
- "init_enabled": true,
1643
- "phase_enabled": true,
1644
- "max_summary_tokens": 2000,
1645
- "min_knowledge_confidence": 0.7,
1646
- "compliance_report": true,
1647
- "suppress_warnings": true,
1648
- "drift_inject_max_chars": 500
1649
- }
1650
- }
1651
- ```
1652
-
1653
- | Field | Default | Description |
1654
- |-------|---------|-------------|
1655
- | `enabled` | `true` | Master switch. Set to `false` to disable the Curator pipeline. |
1656
- | `init_enabled` | `true` | Initialize curator summary on first phase (requires `enabled: true`). |
1657
- | `phase_enabled` | `true` | Run phase analysis and knowledge updates after each phase. |
1658
- | `max_summary_tokens` | `2000` | Maximum token budget for curator knowledge summaries. |
1659
- | `min_knowledge_confidence` | `0.7` | Minimum confidence threshold for curator knowledge entries. |
1660
- | `compliance_report` | `true` | Include phase compliance check results in curator summary. |
1661
- | `suppress_warnings` | `true` | Suppress non-critical curator warnings from the architect context. |
1662
- | `drift_inject_max_chars` | `500` | Maximum characters of drift report text injected into each phase context. |
1663
-
1664
- ### Drift Reports
1665
-
1666
- Drift reports are written to `.swarm/drift-report-phase-N.json` after each phase. The `knowledge-injector.ts` hook reads the latest report and prepends a summary to the architect's knowledge context for the next phase, helping the architect stay aware of plan vs. reality divergence.
1667
-
1668
- ### Issue #81 Hotfix — taskWorkflowStates Persistence
1669
-
1670
- v6.22 includes a fix for session snapshot persistence of per-task workflow states:
1671
-
1672
- - **`SerializedAgentSession.taskWorkflowStates`**: Task workflow states are now serialized as `Record<string, string>` in session snapshots and deserialized back to a `Map` on load. Invalid state values are filtered out and default to `idle`.
1673
- - **`reconcileTaskStatesFromPlan`**: On snapshot load, task states are reconciled against the current plan — tasks marked `completed` in the plan are seeded to `tests_run` state, and `in_progress` tasks are seeded to `coder_delegated` if currently `idle`. This is best-effort and never throws.
1674
-
1675
- See [CHANGELOG.md](CHANGELOG.md) for shipped features.
1676
-
1677
- ---
1678
-
1679
- ## FAQ
1680
-
1681
- ### Do I need to select a Swarm architect?
1682
-
1683
- **Yes.** You must explicitly choose a Swarm architect agent in the OpenCode GUI before starting your session. The architect name shown in OpenCode is config-driven — you can define multiple architects with different model assignments in your configuration.
1684
-
1685
- If you use the default OpenCode `Build` / `Plan` options without selecting a Swarm architect, the plugin is bypassed entirely.
1686
-
1687
- ### Why did Swarm start coding immediately on my second run?
1688
- Because Swarm resumes from `.swarm/` state when it exists. Check `/swarm status` to see the current mode.
1689
-
1690
- ### How do I know which agents and models are active?
1691
- Run `/swarm agents` and `/swarm config`.
1692
-
1693
- ### How do I start over?
1694
- Run `/swarm reset --confirm`.
1180
+ 4. **Different models catch different bugs.** Blind spots of the coder are the reviewer's strength.
1181
+ 5. **Save everything to disk.** Resume any project any day from `.swarm/` state.
1182
+ 6. **Document failures.** Rejections and retries recorded. After 5 failures, escalate to you.
1695
1183
 
1696
1184
  ---
1697
1185
 
1698
1186
  ## Documentation
1699
1187
 
1700
- - [Documentation Index](docs/index.md)
1701
- - [Getting Started](docs/getting-started.md)
1702
- - [Architecture Deep Dive](docs/architecture.md)
1703
- - [Design Rationale](docs/design-rationale.md)
1704
- - [Plan Durability & Ledger](docs/plan-durability.md)
1705
- - [Installation Guide](docs/installation.md)
1706
- - [Linux + Docker Desktop Install Guide](docs/installation-linux-docker.md)
1707
- - [LLM Operator Installation Guide](docs/installation-llm-operator.md)
1708
- - [Pre-Swarm Planning Guide](docs/planning.md)
1709
- - [Swarm Briefing for LLMs](docs/swarm-briefing.md)
1710
- - [Configuration](docs/configuration.md)
1188
+ - [Getting Started](docs/getting-started.md) — 15-minute first-run guide
1189
+ - [Documentation Index](docs/index.md) — navigate all docs
1190
+ - [Installation Guide](docs/installation.md) — comprehensive reference
1191
+ - [Architecture Deep Dive](docs/architecture.md) — control model, pipeline, tools
1192
+ - [Design Rationale](docs/design-rationale.md) — why every major decision
1193
+ - [Commands Reference](docs/commands.md) — all 41 `/swarm` subcommands
1194
+ - [Modes Guide](docs/modes.md) — session modes (Turbo, Full-Auto) and project modes (strict/balanced/fast)
1195
+ - [Configuration](docs/configuration.md) — all config keys and examples
1196
+ - [Planning Guide](docs/planning.md) — task format, phase structure, sizing
1711
1197
 
1712
1198
  ---
1713
1199