opencode-swarm 6.81.0 → 6.81.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +167 -1510
  2. package/dist/cli/index.js +14 -6
  3. package/package.json +1 -1
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,1512 +60,282 @@ 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
- ```
159
-
160
- ### Step 2 — Open your project in OpenCode
161
-
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
98
+ **→ For a complete first-run walkthrough, see [Getting Started](docs/getting-started.md).**
189
99
 
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
- ```
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
206
105
 
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.
106
+ ---
210
107
 
211
- ### Step 7 — Performance modes (optional)
108
+ ## Commands
212
109
 
213
- Swarm runs optional quality hooks (slop detection, incremental verification, compaction) on every tool call. For faster iteration, you can skip these:
110
+ All 41 subcommands at a glance:
214
111
 
215
- **Via slash command** (session-wide):
216
- ```
217
- /swarm turbo
218
- ```
219
-
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)
203
+ ### Model Fallback
322
204
 
323
- When a transient model error occurs (rate limit, 429, 503, timeout, overloaded, model not found), Swarm can automatically switch to a fallback model.
324
-
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.
345
-
346
- ### Bounded Coder Revisions (v6.33)
347
-
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.
349
-
350
- **Configuration:**
351
-
352
- ```json
353
- {
354
- "guardrails": {
355
- "max_coder_revisions": 5
356
- }
357
- }
358
- ```
359
-
360
- | Parameter | Type | Default | Description |
361
- |-----------|------|---------|-------------|
362
- | `max_coder_revisions` | integer | `5` | Maximum coder re-delegations per task before advisory warning (1–20) |
363
-
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
369
-
370
- ## Useful Commands
371
-
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) |
381
-
382
- ---
383
-
384
- ## The Agents
385
-
386
- Swarm has specialized internal agents, but you do **not** manually switch into them during normal use.
387
-
388
- The **architect** is the coordinator. It decides when to invoke the other agents and what they should do.
389
-
390
- That means the normal user workflow is:
391
-
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`
396
-
397
- Agent roles (see [Agent Categories](#agent-categories) for classification reference):
398
-
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:
414
-
415
- ```text
416
- /swarm status
417
- /swarm agents
418
- ```
419
-
420
- ---
421
-
422
- ## How It Compares
423
-
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) | ❌ | ❌ |
433
-
434
- ---
435
-
436
- ## Agent Categories
437
-
438
- Agents are classified into four categories for the monitor server `/metadata` endpoint:
439
-
440
- | Category | Agents |
441
- |----------|--------|
442
- | `orchestrator` | architect |
443
- | `pipeline` | explorer, coder, test_engineer |
444
- | `qa` | reviewer, critic, critic_sounding_board, critic_drift_verifier |
445
- | `support` | sme, docs, designer |
446
-
447
- Use `getAgentCategory(agentName)` from `src/config/agent-categories.ts` to resolve an agent's category at runtime.
218
+ See [docs/configuration.md](docs/configuration.md) for full configuration reference.
448
219
 
449
220
  ---
450
221
 
451
222
  <details>
452
- <summary><strong>Full Execution Pipeline (Technical Detail)</strong></summary>
453
-
454
- ### The Pipeline
455
-
456
- Every task goes through this sequence. No exceptions, no overrides.
457
-
458
- ```
459
- MODE: EXECUTE (per task)
460
-
461
- ├── 5a. @coder implements (ONE task only)
462
- ├── 5b. diff + imports (contract + dependency analysis + semantic diff context)
463
- │ └── @system-enhancer injects AST-based semantic diff summary with blast radius
464
- │ into @reviewer context (up to 10 files, conditional on declared scope)
465
- ├── 5c. syntax_check (parse validation)
466
- ├── 5d. placeholder_scan (catches TODOs, stubs, incomplete code)
467
- ├── 5e. lint fix → lint check
468
- ├── 5f. build_check (does it compile?)
469
- ├── 5g. pre_check_batch (4 parallel: lint, secretscan, SAST, quality budget)
470
- ├── 5h. @reviewer (correctness pass)
471
- ├── 5i. @reviewer (security pass, if security-sensitive files changed)
472
- ├── 5j. @test_engineer (verification tests + coverage ≥70%)
473
- ├── 5k. @test_engineer (adversarial tests)
474
- ├── 5l. architect regression sweep (scope:"graph" to find cross-task test regressions)
475
- ├── 5l-ter. test drift detection (conditional — fires when changes involve command behaviour,
476
- │ parsing/routing logic, user-visible output, public contracts, assertion-heavy areas,
477
- │ or helper lifecycle changes; validates tests still align with current behaviour)
478
- ├── 5m. ⛔ Pre-commit checklist (all 4 items required, no override)
479
- └── 5n. Task marked complete, evidence written
480
- ```
481
-
482
- If any step fails, the coder gets structured feedback and retries. After 5 failures on the same task, it escalates to you.
483
-
484
- ### Architect Workflow Modes
485
-
486
- The architect moves through these modes automatically:
487
-
488
- | Mode | What It Means |
489
- |---|---|
490
- | `RESUME` | Existing `.swarm/` state was found, so Swarm continues where it left off |
491
- | `CLARIFY` | Swarm asks for missing information it cannot infer |
492
- | `DISCOVER` | Explorer scans the codebase; co-change dark matter analysis runs automatically to detect hidden file couplings (v6.41) |
493
- | `CONSULT` | SME agents provide domain guidance |
494
- | `PLAN` | Architect writes or updates the phased plan (includes CODEBASE REALITY CHECK on brownfield projects) |
495
- | `CRITIC-GATE` | Critic reviews the plan before execution |
496
- | `EXECUTE` | Tasks are implemented one at a time through the QA pipeline |
497
- | `PHASE-WRAP` | A phase closes out, including: explorer rescan, docs update, `context.md` update, `write_retro`, evidence check, `sbom_generate`, **`@critic_drift_verifier` delegation** (drift check — blocking gate), `write_drift_evidence` call with verdict, mandatory gate evidence verification (`completion-verify.json` + `drift-verifier.json` both required), then `phase_complete` |
498
-
499
- > **CODEBASE REALITY CHECK (v6.29.2):** Before any planning, the Architect dispatches Explorer to verify the current state of every referenced item. Produces a CODEBASE REALITY REPORT with statuses: NOT STARTED, PARTIALLY DONE, ALREADY COMPLETE, or ASSUMPTION INCORRECT. This prevents planning against stale assumptions. Skipped for greenfield projects with no existing codebase references.
500
-
501
- > **Phase Completion Gates (v6.33.4):** Before a phase can be marked complete, two mandatory gates are enforced: (1) completion-verify — deterministic check that plan task identifiers exist in source files, and (2) critic_drift_verifier evidence — verification that the drift verifier approved the implementation. Both gates are automatically bypassed when turbo mode is active.
502
-
503
- ### Important
504
-
505
- A second or later run does **not** necessarily look like a first run.
506
-
507
- If `.swarm/plan.md` already exists, the architect may enter `RESUME` and then go directly into `EXECUTE`. That is expected and does **not** mean Swarm stopped using agents.
508
-
509
- Use `/swarm status` if you are unsure what Swarm is doing.
510
-
511
- Release automation uses release-please and requires conventional commit prefixes such as `fix:` or `feat:` on changes merged to `main`.
512
-
513
- </details>
514
-
515
- <details>
516
- <summary><strong>Persistent Memory (What's in .swarm/)</strong></summary>
517
-
518
- ### plan.md: Your Project Roadmap
519
-
520
- ```markdown
521
- # Project: Auth System
522
- Current Phase: 2
523
-
524
- ## Phase 1: Foundation [COMPLETE]
525
- - [x] Task 1.1: Create user model [SMALL]
526
- - [x] Task 1.2: Add password hashing [SMALL]
527
- - [x] Task 1.3: Database migrations [MEDIUM]
528
-
529
- ## Phase 2: Core Auth [IN PROGRESS]
530
- - [x] Task 2.1: Login endpoint [MEDIUM]
531
- - [ ] Task 2.2: JWT generation [MEDIUM] (depends: 2.1) ← CURRENT
532
- - Acceptance: Returns valid JWT with user claims, 15-minute expiry
533
- - Attempt 1: REJECTED — missing expiration claim
534
- - [ ] Task 2.3: Token validation middleware [MEDIUM]
535
- ```
536
-
537
- ### context.md: What's Been Decided
538
-
539
- ```markdown
540
- ## Technical Decisions
541
- - bcrypt cost factor: 12
542
- - JWT TTL: 15 minutes; refresh TTL: 7 days
543
-
544
- ## SME Guidance (cached, never re-asked)
545
- ### security (Phase 1)
546
- - Never log tokens or passwords
547
- - Rate-limit login: 5 attempts / 15 min per IP
548
-
549
- ### api (Phase 1)
550
- - Return 401 for invalid credentials (not 404)
551
- ```
552
-
553
- ### Evidence Bundles
554
-
555
- Every completed task writes structured evidence to `.swarm/evidence/`:
556
-
557
- | Type | What It Captures |
558
- |------|--------------------|
559
- | review | Verdict, risk level, specific issues |
560
- | test | Pass/fail counts, coverage %, failure messages |
561
- | diff | Files changed, additions/deletions |
562
- | retrospective | Phase metrics, lessons learned, error taxonomy classification (injected into next phase) |
563
- | secretscan | Secret scan results: findings count, files scanned, skipped files (v6.33) |
564
- | completion-verify | Deterministic gate: verifies plan task identifiers exist in source files (written automatically by `completion-verify` tool; required before `phase_complete`) |
565
- | drift-verifier | Phase-close drift gate: `critic_drift_verifier` verdict (APPROVED/NEEDS_REVISION) and summary (written by architect via `write_drift_evidence`; required before `phase_complete`) |
566
-
567
- ### telemetry.jsonl: Session Observability
568
-
569
- Swarm emits structured JSONL events to `.swarm/telemetry.jsonl` for observability tooling (dashboards, alerting, audit logs). Events are fire-and-forget — failures never affect execution.
570
-
571
- ```json
572
- {"timestamp":"2026-03-25T14:30:00.000Z","event":"session_started","sessionId":"abc123","agentName":"architect"}
573
- {"timestamp":"2026-03-25T14:30:05.000Z","event":"delegation_begin","sessionId":"abc123","agentName":"coder","taskId":"1.1"}
574
- {"timestamp":"2026-03-25T14:31:00.000Z","event":"delegation_end","sessionId":"abc123","agentName":"coder","taskId":"1.1","result":"success"}
575
- {"timestamp":"2026-03-25T14:31:10.000Z","event":"gate_passed","sessionId":"abc123","gate":"reviewer","taskId":"1.1"}
576
- {"timestamp":"2026-03-25T14:32:00.000Z","event":"phase_changed","sessionId":"abc123","oldPhase":1,"newPhase":2}
577
- ```
578
-
579
- | Event | When Emitted |
580
- |-------|-------------|
581
- | `session_started` | New agent session created |
582
- | `session_ended` | Session ends (reason: normal, timeout, error) |
583
- | `agent_activated` | Agent identity confirmed via chat.message |
584
- | `delegation_begin` | Task dispatched to a sub-agent |
585
- | `delegation_end` | Sub-agent returns (success, rejected, error) |
586
- | `task_state_changed` | Task workflow state transitions |
587
- | `gate_passed` | Evidence written to `.swarm/evidence/{taskId}.json` |
588
- | `gate_failed` | Gate check blocked task completion |
589
- | `phase_changed` | Phase completed and new phase started |
590
- | `budget_updated` | Context budget crossed warning/critical threshold |
591
- | `hard_limit_hit` | Tool call/duration/repetition limit reached |
592
- | `revision_limit_hit` | Coder revision limit exceeded |
593
- | `loop_detected` | Repetitive tool call pattern detected |
594
- | `scope_violation` | Architect wrote outside declared scope |
595
- | `qa_skip_violation` | QA gate skipped without valid reason |
596
- | `model_fallback` | Transient error triggered model fallback |
597
- | `heartbeat` | 30-second throttled keep-alive signal |
598
-
599
- File rotates automatically at 10MB to `.swarm/telemetry.jsonl.1`.
600
-
601
- </details>
602
-
603
- <details>
604
- <summary><strong>Save Plan Tool: Target Workspace Requirement</strong></summary>
605
-
606
- The `save_plan` tool requires an explicit target workspace path. It does **not** fall back to `process.cwd()`.
607
-
608
- ### Explicit Workspace Requirement
609
-
610
- - The `working_directory` parameter must be provided
611
- - Providing no value or relying on implicit directory resolution will result in deterministic failure
612
-
613
- ### Failure Conditions
614
-
615
- | Condition | Behavior |
616
- |-----------|----------|
617
- | Missing (`undefined` / `null`) | Fails with: "Target workspace is required" |
618
- | Empty or whitespace-only | Fails with: "Target workspace cannot be empty or whitespace" |
619
- | Path traversal (`..`) | Fails with: "Target workspace cannot contain path traversal" |
620
-
621
- ### Usage Contract
622
-
623
- When using `save_plan`, always pass a valid `working_directory`:
624
-
625
- ```typescript
626
- save_plan({
627
- title: "My Project",
628
- swarm_id: "mega",
629
- phases: [{ id: 1, name: "Setup", tasks: [{ id: "1.1", description: "Initialize project" }] }],
630
- working_directory: "/path/to/project" // Required - no fallback
631
- })
632
- ```
633
-
634
- </details>
635
-
636
- <details>
637
- <summary><strong>Guardrails and Circuit Breakers</strong></summary>
638
-
639
- Every agent runs inside a circuit breaker that kills runaway behavior before it burns your credits.
223
+ <summary><strong>Advanced Topics (Technical Detail)</strong></summary>
640
224
 
641
- | Signal | Default Limit | What Happens |
642
- |--------|:---:|-------------|
643
- | Tool calls | 200 | Agent is stopped |
644
- | Duration | 30 min | Agent is stopped |
645
- | Same tool repeated | 10x | Agent is warned, then stopped |
646
- | Consecutive errors | 5 | Agent is stopped |
225
+ ### Process Remediation Model (PRM)
647
226
 
648
- Limits reset per task. A coder working on Task 2.3 is not penalized for tool calls made during Task 2.2.
227
+ Swarm monitors agent trajectories and injects course-correction guidance before loops form. Detects five failure patterns:
649
228
 
650
- #### Architect Self-Coding Block
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
651
234
 
652
- If the architect writes files directly instead of delegating to the coder, a hard block fires:
235
+ When detected, escalation levels trigger:
236
+ - Level 1: Advisory guidance injected
237
+ - Level 2: Architect alert sent
238
+ - Level 3: Hard stop directive
653
239
 
654
- | Write count | Behavior |
655
- |:-----------:|----------|
656
- | 1–2 | Warning injected into next architect message |
657
- | ≥ 3 | `Error` thrown with `SELF_CODING_BLOCK` — identifies file paths written and count |
658
-
659
- The counter resets only when a coder delegation is dispatched. This is a hard enforcement — not advisory.
660
-
661
- Per-agent overrides:
240
+ Configure via:
662
241
 
663
242
  ```json
664
243
  {
665
- "guardrails": {
666
- "profiles": {
667
- "coder": { "max_tool_calls": 500, "max_duration_minutes": 60 },
668
- "explorer": { "max_tool_calls": 50 }
669
- }
670
- }
671
- }
672
- ```
673
-
674
- </details>
675
-
676
- <details>
677
- <summary><strong>File Authority (Per-Agent Write Permissions)</strong></summary>
678
-
679
- Swarm enforces per-agent file write authority — each agent can only write to specific paths. By default, these rules are hardcoded, but you can override them via config.
680
-
681
- ### Default Rules
682
-
683
- | Agent | Can Write | Blocked | Zones |
684
- |-------|-----------|---------|-------|
685
- | `architect` | Everything (except plan files) | `.swarm/plan.md`, `.swarm/plan.json` | `generated` |
686
- | `coder` | `src/`, `tests/`, `docs/`, `scripts/` | `.swarm/` (entire directory) | `generated`, `config` |
687
- | `reviewer` | `.swarm/evidence/`, `.swarm/outputs/` | `src/`, `.swarm/plan.md`, `.swarm/plan.json` | `generated` |
688
- | `test_engineer` | `tests/`, `.swarm/evidence/` | `src/`, `.swarm/plan.md`, `.swarm/plan.json` | `generated` |
689
- | `explorer` | Read-only | Everything | — |
690
- | `sme` | Read-only | Everything | — |
691
- | `docs` | `docs/`, `.swarm/outputs/` | — | `generated` |
692
- | `designer` | `docs/`, `.swarm/outputs/` | — | `generated` |
693
- | `critic` | `.swarm/evidence/` | — | `generated` |
694
-
695
- ### Prefixed Agents
696
-
697
- Prefixed agents (e.g., `paid_coder`, `mega_reviewer`, `local_architect`) inherit defaults from their canonical base agent via `stripKnownSwarmPrefix`. The lookup order is:
698
-
699
- 1. Exact match for the prefixed name (if explicitly defined in user config)
700
- 2. Fall back to the canonical agent's defaults (e.g., `paid_coder` → `coder`)
701
-
702
- ```json
703
- {
704
- "authority": {
705
- "rules": {
706
- "coder": { "allowedPrefix": ["src/", "lib/"] },
707
- "paid_coder": { "allowedPrefix": ["vendor/", "plugins/"] }
708
- }
709
- }
710
- }
711
- ```
712
-
713
- In this example, `paid_coder` gets its own explicit rule, while other prefixed coders (e.g., `mega_coder`) fall back to `coder`.
714
-
715
- ### Runtime Enforcement
716
-
717
- Architect direct writes are enforced at runtime via `toolBefore` hook. This tracks writes to source code paths outside `.swarm/` and protects `.swarm/plan.md` and `.swarm/plan.json` from direct modification.
718
-
719
- ### Configuration
720
-
721
- Override default rules in `.opencode/opencode-swarm.json`:
722
-
723
- ```json
724
- {
725
- "authority": {
726
- "enabled": true,
727
- "rules": {
728
- "coder": {
729
- "allowedPrefix": ["src/", "lib/", "scripts/"],
730
- "blockedPrefix": [".swarm/"],
731
- "blockedZones": ["generated"]
732
- },
733
- "explorer": {
734
- "readOnly": false,
735
- "allowedPrefix": ["notes/", "scratch/"]
736
- }
737
- }
738
- }
739
- }
740
- ```
741
-
742
- ### Rule Fields
743
-
744
- | Field | Type | Description |
745
- |-------|------|-------------|
746
- | `readOnly` | boolean | If `true`, agent cannot write anywhere |
747
- | `blockedExact` | string[] | Exact file paths that are blocked |
748
- | `allowedExact` | string[] | Exact file paths that are allowed (overrides prefix/glob restrictions) |
749
- | `blockedPrefix` | string[] | Path prefixes that are blocked (e.g., `.swarm/`) |
750
- | `allowedPrefix` | string[] | Only these path prefixes are allowed. Omit to remove restriction; set `[]` to deny all |
751
- | `blockedGlobs` | string[] | Glob patterns that are blocked (uses picomatch: `**`, `*`, `?`) |
752
- | `allowedGlobs` | string[] | Glob patterns that are allowed (uses picomatch: `**`, `*`, `?`) |
753
- | `blockedZones` | string[] | File zones to block: `production`, `test`, `config`, `generated`, `docs`, `build` |
754
-
755
- ### Merge Behavior
756
-
757
- - User rules **override** hardcoded defaults for the specified agent
758
- - Scalar fields (`readOnly`) — user value replaces default
759
- - Array fields (`blockedPrefix`, `allowedPrefix`, etc.) — user array **replaces** entirely (not merged)
760
- - If a field is omitted in the user rule for a **known agent** (one with hardcoded defaults), the default value for that field is preserved
761
- - If a field is omitted in the user rule for a **custom agent** (not in the defaults list), that field is `undefined` — there are no defaults to inherit
762
- - `allowedPrefix: []` explicitly denies all writes; omitting `allowedPrefix` entirely means no allowlist restriction is applied (all paths are evaluated against blocklist rules only)
763
- - Setting `enabled: false` ignores all custom rules and uses hardcoded defaults
764
-
765
- ### Custom Agents
766
-
767
- Custom agents (not in the defaults list) start with no rules. Their write authority depends entirely on what you configure:
768
-
769
- - **Not in config at all** — agent is denied with `Unknown agent` (no rule exists; this is not the same as "blocked from all writes")
770
- - **In config without `allowedPrefix`** — no allowlist restriction applies; only any `blockedPrefix`, `blockedZones`, or `readOnly` rules you explicitly set will enforce limits
771
- - **In config with `allowedPrefix: []`** — all writes are denied
772
-
773
- To safely restrict a custom agent, always set `allowedPrefix` explicitly:
774
-
775
- ```json
776
- {
777
- "authority": {
778
- "rules": {
779
- "my_custom_agent": {
780
- "allowedPrefix": ["plugins/", "extensions/"],
781
- "blockedZones": ["generated"]
782
- }
783
- }
784
- }
785
- }
786
- ```
787
-
788
- ### Advanced Examples
789
-
790
- #### Glob Pattern Support
791
-
792
- Use glob patterns for complex path matching:
793
-
794
- ```json
795
- {
796
- "authority": {
797
- "rules": {
798
- "coder": {
799
- "allowedGlobs": ["src/**/*.ts", "tests/**/*.test.ts"],
800
- "blockedGlobs": ["src/**/*.generated.ts", "**/*.d.ts"],
801
- "allowedExact": ["src/index.ts", "package.json"]
802
- },
803
- "docs_agent": {
804
- "allowedGlobs": ["docs/**/*.md", "*.md"],
805
- "blockedExact": [".swarm/plan.md"]
806
- }
807
- }
808
- }
809
- }
810
- ```
811
-
812
- **Glob Pattern Features:**
813
- - `**` — Match any number of directories: `src/**/*.ts` matches all TypeScript files in src/ and subdirectories
814
- - `*` — Match any characters except path separators: `*.md` matches all Markdown files in current directory
815
- - `?` — Match single character: `test?.js` matches `test1.js`, `testa.js`
816
- - Uses [picomatch](https://github.com/micromatch/picomatch) for cross-platform compatibility
817
-
818
- **Path Normalization and Symlinks:**
819
- Paths are resolved via `realpathSync` before matching, which resolves symlinks and prevents path-traversal escapes. However, if a symlink's target does not exist, `realpathSync` throws and the fallback returns the symlink's own path (unresolved). A dangling symlink inside an `allowedPrefix` directory will therefore pass prefix-based checks even if its intended target is outside the project. Use `blockedExact` or `blockedGlobs` to deny known dangling-symlink paths explicitly.
820
-
821
- **Evaluation Order:**
822
- 1. `readOnly` check (if true, deny all writes)
823
- 2. `blockedExact` (exact path matches, highest priority)
824
- 3. `blockedGlobs` (glob pattern matches)
825
- 4. `allowedExact` (exact path matches, overrides prefix/glob restrictions)
826
- 5. `allowedGlobs` (glob pattern matches)
827
- 6. `blockedPrefix` (prefix matches)
828
- 7. `allowedPrefix` (prefix matches)
829
- 8. `blockedZones` (zone classification)
830
-
831
- </details>
832
-
833
- <details>
834
- <summary><strong>Context Budget Guard</strong></summary>
835
-
836
- The Context Budget Guard monitors how much context Swarm is injecting into the conversation. It helps prevent context overflow before it becomes a problem.
837
-
838
- ### Default Behavior
839
-
840
- - **Enabled automatically** — No setup required. Swarm starts tracking context usage right away.
841
- - **What it measures** — Only the context that Swarm injects (plan, context, evidence, retrospectives). It does **not** count your chat history or the model's responses.
842
- - **Warning threshold (0.7 ratio)** — When swarm-injected context reaches ~2800 tokens (70% of 4000), the architect receives a one-time advisory warning. This is informational — execution continues normally.
843
- - **Critical threshold (0.9 ratio)** — When context reaches ~3600 tokens (90% of 4000), the architect receives a critical alert with a recommendation to run `/swarm handoff`. This is also one-time only.
844
- - **Non-nagging** — Alerts fire once per session, not repeatedly. You won't be pestered every turn.
845
- - **Who sees warnings** — Only the architect receives these warnings. Other agents are unaware of the budget.
846
-
847
- To disable entirely, set `context_budget.enabled: false` in your swarm config.
848
-
849
- ### Configuration Reference
850
-
851
- | Key | Type | Default | Description |
852
- |-----|------|---------|-------------|
853
- | `context_budget.enabled` | boolean | `true` | Enable or disable the context budget guard entirely |
854
- | `context_budget.max_injection_tokens` | number | `4000` | Token budget for swarm-injected context per turn. This is NOT the model's context window — it's the swarm plugin's own contribution |
855
- | `context_budget.warn_threshold` | number | `0.7` | Ratio (0.0-1.0) of `max_injection_tokens` that triggers a warning advisory |
856
- | `context_budget.critical_threshold` | number | `0.9` | Ratio (0.0-1.0) of `max_injection_tokens` that triggers a critical alert with handoff recommendation |
857
- | `context_budget.enforce` | boolean | `true` | When true, enforces budget limits and may trigger handoffs |
858
- | `context_budget.prune_target` | number | `0.7` | Ratio (0.0-1.0) of context to preserve when pruning occurs |
859
- | `context_budget.preserve_last_n_turns` | number | `4` | Number of recent turns to preserve when pruning |
860
- | `context_budget.recent_window` | number | `10` | Number of turns to consider as "recent" for scoring |
861
- | `context_budget.tracked_agents` | string[] | `['architect']` | Agents to track for context budget warnings |
862
- | `context_budget.enforce_on_agent_switch` | boolean | `true` | Enforce budget limits when switching agents |
863
- | `context_budget.model_limits` | record | `{ default: 128000 }` | Per-model token limits (model name -> max tokens) |
864
- | `context_budget.tool_output_mask_threshold` | number | `2000` | Threshold for masking tool outputs (chars) |
865
- | `context_budget.scoring.enabled` | boolean | `false` | Enable context scoring/ranking |
866
- | `context_budget.scoring.max_candidates` | number | `100` | Maximum items to score (10-500) |
867
- | `context_budget.scoring.weights` | object | `{ recency: 0.3, ... }` | Scoring weights for priority |
868
- | `context_budget.scoring.decision_decay` | object | `{ mode: 'exponential', half_life_hours: 24 }` | Decision relevance decay |
869
- | `context_budget.scoring.token_ratios` | object | `{ prose: 0.25, code: 0.4, ... }` | Token cost multipliers |
870
-
871
- ### Example Configurations
872
-
873
- **Minimal (disable):**
874
- ```json
875
- {
876
- "context_budget": {
877
- "enabled": false
878
- }
879
- }
880
- ```
881
-
882
- **Default (reference):**
883
- ```json
884
- {
885
- "context_budget": {
886
- "enabled": true,
887
- "max_injection_tokens": 4000,
888
- "warn_threshold": 0.7,
889
- "critical_threshold": 0.9,
890
- "enforce": true,
891
- "prune_target": 0.7,
892
- "preserve_last_n_turns": 4,
893
- "recent_window": 10,
894
- "tracked_agents": ["architect"],
895
- "enforce_on_agent_switch": true,
896
- "model_limits": { "default": 128000 },
897
- "tool_output_mask_threshold": 2000,
898
- "scoring": {
899
- "enabled": false,
900
- "max_candidates": 100,
901
- "weights": { "recency": 0.3, "relevance": 0.4, "importance": 0.3 },
902
- "decision_decay": { "mode": "exponential", "half_life_hours": 24 },
903
- "token_ratios": { "prose": 0.25, "code": 0.4, "json": 0.6, "logs": 0.1 }
904
- }
905
- }
906
- }
907
- ```
908
-
909
- **Aggressive (for long-running sessions):**
910
- ```json
911
- {
912
- "context_budget": {
913
- "enabled": true,
914
- "max_injection_tokens": 2000,
915
- "warn_threshold": 0.5,
916
- "critical_threshold": 0.75,
917
- "enforce": true,
918
- "prune_target": 0.6,
919
- "preserve_last_n_turns": 2,
920
- "recent_window": 5,
921
- "tracked_agents": ["architect"],
922
- "enforce_on_agent_switch": true,
923
- "model_limits": { "default": 128000 },
924
- "tool_output_mask_threshold": 1500,
925
- "scoring": {
926
- "enabled": true,
927
- "max_candidates": 50,
928
- "weights": { "recency": 0.5, "relevance": 0.3, "importance": 0.2 },
929
- "decision_decay": { "mode": "linear", "half_life_hours": 12 },
930
- "token_ratios": { "prose": 0.2, "code": 0.35, "json": 0.5, "logs": 0.05 }
931
- }
932
- }
933
- }
934
- ```
935
-
936
- ### What This Does NOT Do
937
-
938
- - **Does NOT prune chat history** — Your conversation with the model is untouched
939
- - **Does NOT modify tool outputs** — What tools return is unchanged
940
- - **Does NOT block execution** — The guard is advisory only; it warns but never stops the pipeline
941
- - **Does NOT interact with compaction.auto** — Separate feature with separate configuration
942
- - **Only measures swarm's injected context** — Not the full context window, just what Swarm adds
943
-
944
- </details>
945
-
946
- <details>
947
- <summary><strong>Quality Gates (Technical Detail)</strong></summary>
948
-
949
- ### Built-in Tools
950
-
951
- | Tool | What It Does |
952
- |------|-------------|
953
- | syntax_check | Tree-sitter validation across 12 languages |
954
- | placeholder_scan | Catches TODOs, FIXMEs, stubs, placeholder text |
955
- | sast_scan | Offline security analysis, 63+ rules, 9 languages |
956
- | sbom_generate | CycloneDX dependency tracking, 8 ecosystems |
957
- | build_check | Runs your project's native build/typecheck |
958
- | incremental_verify | Post-coder typecheck for TS/JS, Go, Rust, C# (v6.29.2) |
959
- | quality_budget | Enforces complexity, duplication, and test ratio limits |
960
- | pre_check_batch | Runs lint, secretscan, SAST, and quality budget in parallel (~15s vs ~60s sequential) |
961
- | 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 |
962
-
963
-
964
- All tools run locally. No Docker, no network calls, no external APIs.
965
-
966
- Optional enhancement: Semgrep (if on PATH).
967
-
968
- ### Gate Configuration
969
-
970
- ```json
971
- {
972
- "gates": {
973
- "syntax_check": { "enabled": true },
974
- "placeholder_scan": { "enabled": true },
975
- "sast_scan": { "enabled": true },
976
- "quality_budget": {
977
- "enabled": true,
978
- "max_complexity_delta": 5,
979
- "min_test_to_code_ratio": 0.3
980
- }
981
- }
982
- }
983
- ```
984
-
985
- </details>
986
-
987
- <details>
988
- <summary><strong>File Locking for Concurrent Write Safety</strong></summary>
989
-
990
- Swarm uses file locking to protect shared state files from concurrent write corruption. The locking strategy differs by file: `plan.json` uses hard locking (write blocked on contention), while `events.jsonl` uses advisory locking (write proceeds with a warning on contention).
991
-
992
- ### Locking Implementation
993
-
994
- - **Library**: `proper-lockfile` with `retries: 0` (fail-fast — no polling retries)
995
- - **Scope**: Each tool acquires an exclusive lock on the target file before writing
996
- - **Agents**: Lock is tagged with the current agent name and task context for diagnostics
997
-
998
- ### Protected Files
999
-
1000
- | File | Tool | Lock Key |
1001
- |------|------|----------|
1002
- | `.swarm/plan.json` | `update_task_status` | `plan.json` |
1003
- | `.swarm/events.jsonl` | `phase_complete` | `events.jsonl` |
1004
-
1005
- ### Lock Semantics
1006
-
1007
- The two protected tools use different strategies:
1008
-
1009
- **`update_task_status` — Hard lock on `plan.json`**
1010
-
1011
- When two calls contend for `plan.json`:
1012
- 1. **Exactly one call wins** — only the first to acquire the lock proceeds
1013
- 2. **Winner writes** — the lock holder writes to the file, then releases the lock
1014
- 3. **Losers receive `success: false`** — with `recovery_guidance: "retry"` and an error message identifying the lock holder
1015
-
1016
- ```json
1017
- {
1018
- "success": false,
1019
- "message": "Task status write blocked: plan.json is locked by architect (task: update-task-status-1.1-1234567890)",
1020
- "errors": ["Concurrent plan write detected — retry after the current write completes"],
1021
- "recovery_guidance": "Wait a moment and retry update_task_status. The lock will expire automatically if the holding agent fails."
1022
- }
1023
- ```
1024
-
1025
- **What the caller should do**: Retry `update_task_status` after a short delay.
1026
-
1027
- **`phase_complete` — Advisory lock on `events.jsonl`**
1028
-
1029
- When two calls contend for `events.jsonl`:
1030
- 1. **Lock is attempted** — if acquired, write is serialized
1031
- 2. **If lock unavailable** — a warning is added to the result and the write proceeds anyway
1032
- 3. **Both callers return `success: true`** — duplicate concurrent appends are possible but `events.jsonl` is an append-only log and duplicate phase entries do not corrupt state
1033
-
1034
- This asymmetry is intentional: `plan.json` stores mutable structured JSON where concurrent overwrites produce malformed files; `events.jsonl` is an append-only log where a duplicate entry is a recoverable nuisance.
1035
-
1036
- ### Lock Recovery
1037
-
1038
- If a lock-holding agent crashes or hangs, the lock file will eventually expire (handled by `proper-lockfile` stale-lock cleanup). On the next retry, the call will succeed. Swarm does not auto-retry on lock contention — the architect receives the error and decides when to retry.
1039
-
1040
- </details>
1041
-
1042
- <details>
1043
- <summary id="configuration-reference"><strong>Full Configuration Reference</strong></summary>
1044
-
1045
- Config file location: `~/.config/opencode/opencode-swarm.json` (global) or `.opencode/opencode-swarm.json` (project). Project config merges over global.
1046
-
1047
- ```json
1048
- {
1049
- "agents": {
1050
- "architect": { "model": "anthropic/claude-opus-4-6" },
1051
- "coder": { "model": "minimax-coding-plan/MiniMax-M2.5", "fallback_models": ["minimax-coding-plan/MiniMax-M2.1"] },
1052
- "explorer": { "model": "minimax-coding-plan/MiniMax-M2.1" },
1053
- "sme": { "model": "kimi-for-coding/k2p5" },
1054
- "critic": { "model": "zai-coding-plan/glm-5" },
1055
- "reviewer": { "model": "zai-coding-plan/glm-5", "fallback_models": ["opencode/big-pickle"] },
1056
- "test_engineer": { "model": "minimax-coding-plan/MiniMax-M2.5" },
1057
- "docs": { "model": "zai-coding-plan/glm-4.7-flash" },
1058
- "designer": { "model": "kimi-for-coding/k2p5" }
1059
- },
1060
- "guardrails": {
1061
- "max_tool_calls": 200,
1062
- "max_duration_minutes": 30,
1063
- "profiles": {
1064
- "coder": { "max_tool_calls": 500 }
1065
- }
1066
- },
1067
- "authority": {
244
+ "prm": {
1068
245
  "enabled": true,
1069
- "rules": {
1070
- "coder": {
1071
- "allowedPrefix": ["src/", "lib/"],
1072
- "blockedPrefix": [".swarm/"],
1073
- "blockedZones": ["generated"]
1074
- }
1075
- }
1076
- },
1077
- "review_passes": {
1078
- "always_security_review": false,
1079
- "security_globs": ["**/*auth*", "**/*crypto*", "**/*session*"]
1080
- },
1081
- "automation": {
1082
- "mode": "manual",
1083
- "capabilities": {
1084
- "plan_sync": true,
1085
- "phase_preflight": false,
1086
- "config_doctor_on_startup": false,
1087
- "config_doctor_autofix": false,
1088
- "evidence_auto_summaries": true,
1089
- "decision_drift_detection": 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
1090
252
  }
1091
- },
1092
- "knowledge": {
1093
- "enabled": true,
1094
- "swarm_max_entries": 100,
1095
- "hive_max_entries": 1000,
1096
- "auto_promote_days": 30,
1097
- "max_inject_count": 5,
1098
- "dedup_threshold": 0.6,
1099
- "scope_filter": ["global"],
1100
- "hive_enabled": true,
1101
- "rejected_max_entries": 200,
1102
- "validation_enabled": true,
1103
- "evergreen_confidence": 0.8,
1104
- "evergreen_utility": 0.5,
1105
- "low_utility_threshold": 0.2,
1106
- "min_retrievals_for_utility": 3,
1107
- "schema_version": "v6.17"
1108
253
  }
1109
254
  }
1110
255
  ```
1111
256
 
1112
- ### Automation
257
+ > **Note:** Some configuration fields (`max_trajectory_lines`, `escalation_enabled`) are defined in schema but not yet enforced at runtime.
1113
258
 
1114
- ## Mode Detection (v6.13)
259
+ ### Persistent Memory
1115
260
 
1116
- Swarm now explicitly distinguishes five architect modes:
261
+ **`.swarm/plan-ledger.jsonl`** authoritative source of truth (v6.44 durability model)
1117
262
 
1118
- - **`DISCOVER`** — After the explorer finishes scanning the codebase.
1119
- - **`PLAN`** — When the architect writes or updates the plan.
1120
- - **`EXECUTE`** — During task implementation (the normal pipeline).
1121
- - **`PHASE-WRAP`** — After all tasks in a phase are completed, before docs are updated.
1122
- - **`UNKNOWN`** — Fallback when the current state does not match any known mode.
263
+ **`.swarm/context.md`** — technical decisions and cached SME guidance
1123
264
 
1124
- Each mode determines which injection blocks are added to the LLM prompt (e.g., plan cursor is injected in `PLAN`, tool output truncation in `EXECUTE`, etc.).
265
+ **`.swarm/evidence/`** review/test results per task
1125
266
 
1126
- Default mode: `manual`. No background automation all actions require explicit slash commands.
267
+ **`.swarm/telemetry.jsonl`** session observability events (fire-and-forget, never blocks execution)
1127
268
 
1128
- Modes:
269
+ **`.swarm/curator-summary.json`** — phase-level intelligence and drift reports
1129
270
 
1130
- - `manual` No background automation. All actions via slash commands (default).
1131
- - `hybrid` — Background automation for safe operations, manual for sensitive ones.
1132
- - `auto` — Full background automation.
271
+ ### Guardrails & Circuit Breakers
1133
272
 
1134
- Capability defaults:
273
+ Every agent runs inside a circuit breaker that prevents runaway behavior:
1135
274
 
1136
- - `plan_sync`: `true` Background plan synchronization using `fs.watch` with debounced writes (300ms) and 2-second polling fallback
1137
- - `phase_preflight`: `false` — Phase preflight checks before agent execution (opt-in)
1138
- - `config_doctor_on_startup`: `false` Validate configuration on startup
1139
- - `config_doctor_autofix`: `false` Auto-fix for config doctor (opt-in, security-sensitive)
1140
- - `evidence_auto_summaries`: `true` Automatic summaries for evidence bundles
1141
- - `decision_drift_detection`: `true` Detect drift between planned and actual decisions
275
+ | Signal | Default Limit |
276
+ |--------|:---:|
277
+ | Tool calls | 200 |
278
+ | Duration | 30 min |
279
+ | Same tool repeated | 10x |
280
+ | Consecutive errors | 5 |
1142
281
 
1143
- ## Plan Cursor (v6.13)
282
+ Limits reset per task. Per-agent overrides available in config.
1144
283
 
1145
- The `plan_cursor` config compresses the plan that is injected into the LLM context.
284
+ ### File Authority (Per-Agent Write Permissions)
1146
285
 
1147
- ```json
1148
- {
1149
- "plan_cursor": {
1150
- "enabled": true,
1151
- "max_tokens": 1500,
1152
- "lookahead_tasks": 2
1153
- }
1154
- }
1155
- ```
286
+ Each agent can only write to specific paths:
1156
287
 
1157
- - **enabled** When `true` (default) Swarm injects a compact plan cursor instead of the full `plan.md`.
1158
- - **max_tokens** Upper bound on the number of tokens emitted for the cursor (default 1500). The cursor contains the current phase summary, the full current task, and up to `lookahead_tasks` upcoming tasks. Earlier phases are reduced to one‑line summaries.
1159
- - **lookahead_tasks** Number of future tasks to include in full detail (default 2). Set to `0` to show only the current task.
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
1160
293
 
1161
- Disabling (`"enabled": false`) falls back to the pre‑v6.13 behavior of injecting the entire plan text.
294
+ Override via `authority.rules` in config.
1162
295
 
1163
- ## Tool Output Truncation (v6.13)
296
+ ### Quality Gates
1164
297
 
1165
- Control the size of tool outputs that are sent back to the LLM.
298
+ Built-in tools verify every task before it ships:
1166
299
 
1167
- ```json
1168
- {
1169
- "tool_output": {
1170
- "truncation_enabled": true,
1171
- "max_lines": 150,
1172
- "per_tool": {
1173
- "diff": 200,
1174
- "symbols": 100
1175
- }
1176
- }
1177
- }
1178
- ```
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
1179
305
 
1180
- - **truncation_enabled** Global switch (default true).
1181
- - **max_lines** – Default line limit for any tool output.
1182
- - **per_tool** – Overrides `max_lines` for specific tools. The `diff` and `symbols` tools are truncated by default because their outputs can be very large.
306
+ All tools run locally. No Docker, no network calls.
1183
307
 
1184
- When truncation is active, a footer is appended:
308
+ ### Context Budget Guard
1185
309
 
1186
- ```
1187
- ---
1188
- [output truncated to {maxLines} lines – use `tool_output.per_tool.<tool>` to adjust]
1189
- ```
1190
-
1191
- ## Summarization Settings
1192
-
1193
- Control how tool outputs are summarized for LLM context.
1194
-
1195
- ```json
1196
- {
1197
- "summaries": {
1198
- "threshold_bytes": 102400,
1199
- "exempt_tools": ["retrieve_summary", "task", "read"]
1200
- }
1201
- }
1202
- ```
1203
-
1204
- - **threshold_bytes** – Output size threshold in bytes before summarization is triggered (default 102400 = 100KB).
1205
- - **exempt_tools** – Tools whose outputs are never summarized. Defaults to `["retrieve_summary", "task", "read"]` to prevent re-summarization loops.
310
+ Monitors how much context Swarm injects to prevent overflow:
1206
311
 
1207
- > **Note:** The `retrieve_summary` tool supports paginated retrieval via `offset` and `limit` parameters to fetch large summarized outputs in chunks.
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
1208
315
 
1209
- ---
316
+ Disable entirely with `context_budget.enabled: false`.
1210
317
 
1211
- ### Disabling Agents
318
+ ### File Locking for Concurrent Safety
1212
319
 
1213
- ```json
1214
- {
1215
- "sme": { "disabled": true },
1216
- "designer": { "disabled": true },
1217
- "test_engineer": { "disabled": true }
1218
- }
1219
- ```
1220
-
1221
- </details>
1222
-
1223
- <details>
1224
- <summary><strong>All Slash Commands</strong></summary>
1225
-
1226
- | Command | Description |
1227
- |---------|-------------|
1228
- | `/swarm status` | Current phase, task progress, agent count |
1229
- | `/swarm plan [N]` | Full plan or filtered by phase |
1230
- | `/swarm agents` | Registered agents with models and permissions |
1231
- | `/swarm history` | Completed phases with status |
1232
- | `/swarm config` | Current resolved configuration |
1233
- | `/swarm diagnose` | Health check for `.swarm/` files and config |
1234
- | `/swarm export` | Export plan and context as portable JSON |
1235
- | `/swarm evidence [task]` | Evidence bundles for a task or all tasks |
1236
- | `/swarm archive [--dry-run]` | Archive old evidence with retention policy |
1237
- | `/swarm benchmark` | Performance benchmarks |
1238
- | `/swarm retrieve [id]` | Retrieve auto-summarized tool outputs (supports offset/limit pagination) |
1239
- | `/swarm reset --confirm` | Clear swarm state files |
1240
- | `/swarm reset-session` | Clear session state files in `.swarm/session/` (preserves plan and context) |
1241
- | `/swarm preflight` | Run phase preflight checks |
1242
- | `/swarm config doctor [--fix]` | Config validation with optional auto-fix |
1243
- | `/swarm doctor tools` | Tool registration coherence and binary readiness check |
1244
- | `/swarm sync-plan` | Force plan.md regeneration from plan.json |
1245
- | `/swarm specify [description]` | Generate or import a feature specification |
1246
- | `/swarm clarify [topic]` | Clarify and refine an existing feature specification |
1247
- | `/swarm analyze` | Analyze spec.md vs plan.md for requirement coverage gaps |
1248
- | `/swarm close [--prune-branches]` | Idempotent session close-out: retrospectives, lesson curation, evidence archive, context.md reset, config-backup cleanup, optional branch pruning |
1249
- | `/swarm write-retro` | Write a phase retrospective manually |
1250
- | `/swarm handoff` | Generate a handoff summary for context-budget-critical sessions |
1251
- | `/swarm simulate` | Simulate plan execution without writing code |
1252
- | `/swarm promote` | Promote swarm-scoped knowledge to hive (global) knowledge |
1253
- | `/swarm evidence summary` | Generate a summary across all evidence bundles with completion ratio and blockers |
1254
- | `/swarm knowledge` | List knowledge entries |
1255
- | `/swarm knowledge migrate` | Migrate knowledge entries to the current format |
1256
- | `/swarm knowledge quarantine [id]` | Move a knowledge entry to quarantine |
1257
- | `/swarm knowledge restore [id]` | Restore a quarantined knowledge entry |
1258
- | `/swarm turbo` | Enable turbo mode for the current session (bypasses QA gates) |
1259
- | `/swarm full-auto` | Toggle Full-Auto Mode for the current session [on|off] |
1260
- | `/swarm checkpoint` | Save a git checkpoint for the current state |
320
+ Hard lock on `plan.json` (serialized writes), advisory lock on `events.jsonl` (append-only log). Stale locks auto-expire via `proper-lockfile`.
1261
321
 
1262
322
  </details>
1263
323
 
1264
324
  ---
1265
325
 
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
326
+ ## Supported Languages
1554
327
 
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.
328
+ Full Tier-1 support: TypeScript, JavaScript, Python, Go, Rust
329
+ Tier-2 support: Java, Kotlin, C#, C/C++, Swift
330
+ Tier-3 support: Dart, Ruby, PHP/Laravel
1561
331
 
1562
- </details>
332
+ All binaries optional. Missing tools produce soft warnings, never hard-fail.
1563
333
 
1564
334
  ---
1565
335
 
1566
336
  ## Testing
1567
337
 
1568
- 6,000+ tests. Unit, integration, adversarial, and smoke. Zero additional test dependencies.
338
+ 6,000+ tests. Unit, integration, adversarial, and smoke. Run with:
1569
339
 
1570
340
  ```bash
1571
341
  bun test
@@ -1575,139 +345,26 @@ bun test
1575
345
 
1576
346
  ## Design Principles
1577
347
 
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.
348
+ 1. **Plan before code.** Critic approves the plan before a single line is written.
349
+ 2. **One task at a time.** Coder gets one task and full context. Nothing else.
1580
350
  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`.
351
+ 4. **Different models catch different bugs.** Blind spots of the coder are the reviewer's strength.
352
+ 5. **Save everything to disk.** Resume any project any day from `.swarm/` state.
353
+ 6. **Document failures.** Rejections and retries recorded. After 5 failures, escalate to you.
1695
354
 
1696
355
  ---
1697
356
 
1698
357
  ## Documentation
1699
358
 
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)
359
+ - [Getting Started](docs/getting-started.md) — 15-minute first-run guide
360
+ - [Documentation Index](docs/index.md) — navigate all docs
361
+ - [Installation Guide](docs/installation.md) — comprehensive reference
362
+ - [Architecture Deep Dive](docs/architecture.md) — control model, pipeline, tools
363
+ - [Design Rationale](docs/design-rationale.md) — why every major decision
364
+ - [Commands Reference](docs/commands.md) — all 41 `/swarm` subcommands
365
+ - [Modes Guide](docs/modes.md) — session modes (Turbo, Full-Auto) and project modes (strict/balanced/fast)
366
+ - [Configuration](docs/configuration.md) — all config keys and examples
367
+ - [Planning Guide](docs/planning.md) — task format, phase structure, sizing
1711
368
 
1712
369
  ---
1713
370