opencode-swarm 6.45.1 → 6.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -0
- package/dist/cli/index.js +353 -240
- package/dist/commands/close.d.ts +1 -1
- package/dist/config/evidence-schema.d.ts +2 -2
- package/dist/config/schema.d.ts +50 -0
- package/dist/hooks/guardrails.d.ts +12 -3
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.js +765 -587
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -601,6 +601,117 @@ Per-agent overrides:
|
|
|
601
601
|
|
|
602
602
|
</details>
|
|
603
603
|
|
|
604
|
+
<details>
|
|
605
|
+
<summary><strong>File Authority (Per-Agent Write Permissions)</strong></summary>
|
|
606
|
+
|
|
607
|
+
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.
|
|
608
|
+
|
|
609
|
+
### Default Rules
|
|
610
|
+
|
|
611
|
+
| Agent | Can Write | Blocked | Zones |
|
|
612
|
+
|-------|-----------|---------|-------|
|
|
613
|
+
| `architect` | Everything (except plan files) | `.swarm/plan.md`, `.swarm/plan.json` | `generated` |
|
|
614
|
+
| `coder` | `src/`, `tests/`, `docs/`, `scripts/` | `.swarm/` (entire directory) | `generated`, `config` |
|
|
615
|
+
| `reviewer` | `.swarm/evidence/`, `.swarm/outputs/` | `src/`, `.swarm/plan.md`, `.swarm/plan.json` | `generated` |
|
|
616
|
+
| `test_engineer` | `tests/`, `.swarm/evidence/` | `src/`, `.swarm/plan.md`, `.swarm/plan.json` | `generated` |
|
|
617
|
+
| `explorer` | Read-only | Everything | — |
|
|
618
|
+
| `sme` | Read-only | Everything | — |
|
|
619
|
+
| `docs` | `docs/`, `.swarm/outputs/` | — | `generated` |
|
|
620
|
+
| `designer` | `docs/`, `.swarm/outputs/` | — | `generated` |
|
|
621
|
+
| `critic` | `.swarm/evidence/` | — | `generated` |
|
|
622
|
+
|
|
623
|
+
### Prefixed Agents
|
|
624
|
+
|
|
625
|
+
Prefixed agents (e.g., `paid_coder`, `mega_reviewer`, `local_architect`) inherit defaults from their canonical base agent via `stripKnownSwarmPrefix`. The lookup order is:
|
|
626
|
+
|
|
627
|
+
1. Exact match for the prefixed name (if explicitly defined in user config)
|
|
628
|
+
2. Fall back to the canonical agent's defaults (e.g., `paid_coder` → `coder`)
|
|
629
|
+
|
|
630
|
+
```json
|
|
631
|
+
{
|
|
632
|
+
"authority": {
|
|
633
|
+
"rules": {
|
|
634
|
+
"coder": { "allowedPrefix": ["src/", "lib/"] },
|
|
635
|
+
"paid_coder": { "allowedPrefix": ["vendor/", "plugins/"] }
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
In this example, `paid_coder` gets its own explicit rule, while other prefixed coders (e.g., `mega_coder`) fall back to `coder`.
|
|
642
|
+
|
|
643
|
+
### Runtime Enforcement
|
|
644
|
+
|
|
645
|
+
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.
|
|
646
|
+
|
|
647
|
+
### Configuration
|
|
648
|
+
|
|
649
|
+
Override default rules in `.opencode/opencode-swarm.json`:
|
|
650
|
+
|
|
651
|
+
```json
|
|
652
|
+
{
|
|
653
|
+
"authority": {
|
|
654
|
+
"enabled": true,
|
|
655
|
+
"rules": {
|
|
656
|
+
"coder": {
|
|
657
|
+
"allowedPrefix": ["src/", "lib/", "scripts/"],
|
|
658
|
+
"blockedPrefix": [".swarm/"],
|
|
659
|
+
"blockedZones": ["generated"]
|
|
660
|
+
},
|
|
661
|
+
"explorer": {
|
|
662
|
+
"readOnly": false,
|
|
663
|
+
"allowedPrefix": ["notes/", "scratch/"]
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
```
|
|
669
|
+
|
|
670
|
+
### Rule Fields
|
|
671
|
+
|
|
672
|
+
| Field | Type | Description |
|
|
673
|
+
|-------|------|-------------|
|
|
674
|
+
| `readOnly` | boolean | If `true`, agent cannot write anywhere |
|
|
675
|
+
| `blockedExact` | string[] | Exact file paths that are blocked |
|
|
676
|
+
| `blockedPrefix` | string[] | Path prefixes that are blocked (e.g., `.swarm/`) |
|
|
677
|
+
| `allowedPrefix` | string[] | Only these path prefixes are allowed. Omit to remove restriction; set `[]` to deny all |
|
|
678
|
+
| `blockedZones` | string[] | File zones to block: `production`, `test`, `config`, `generated`, `docs`, `build` |
|
|
679
|
+
|
|
680
|
+
### Merge Behavior
|
|
681
|
+
|
|
682
|
+
- User rules **override** hardcoded defaults for the specified agent
|
|
683
|
+
- Scalar fields (`readOnly`) — user value replaces default
|
|
684
|
+
- Array fields (`blockedPrefix`, `allowedPrefix`, etc.) — user array **replaces** entirely (not merged)
|
|
685
|
+
- 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
|
|
686
|
+
- 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
|
|
687
|
+
- `allowedPrefix: []` explicitly denies all writes; omitting `allowedPrefix` entirely means no allowlist restriction is applied (all paths are evaluated against blocklist rules only)
|
|
688
|
+
- Setting `enabled: false` ignores all custom rules and uses hardcoded defaults
|
|
689
|
+
|
|
690
|
+
### Custom Agents
|
|
691
|
+
|
|
692
|
+
Custom agents (not in the defaults list) start with no rules. Their write authority depends entirely on what you configure:
|
|
693
|
+
|
|
694
|
+
- **Not in config at all** — agent is denied with `Unknown agent` (no rule exists; this is not the same as "blocked from all writes")
|
|
695
|
+
- **In config without `allowedPrefix`** — no allowlist restriction applies; only any `blockedPrefix`, `blockedZones`, or `readOnly` rules you explicitly set will enforce limits
|
|
696
|
+
- **In config with `allowedPrefix: []`** — all writes are denied
|
|
697
|
+
|
|
698
|
+
To safely restrict a custom agent, always set `allowedPrefix` explicitly:
|
|
699
|
+
|
|
700
|
+
```json
|
|
701
|
+
{
|
|
702
|
+
"authority": {
|
|
703
|
+
"rules": {
|
|
704
|
+
"my_custom_agent": {
|
|
705
|
+
"allowedPrefix": ["plugins/", "extensions/"],
|
|
706
|
+
"blockedZones": ["generated"]
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
```
|
|
712
|
+
|
|
713
|
+
</details>
|
|
714
|
+
|
|
604
715
|
<details>
|
|
605
716
|
<summary><strong>Context Budget Guard</strong></summary>
|
|
606
717
|
|
|
@@ -780,6 +891,16 @@ Config file location: `~/.config/opencode/opencode-swarm.json` (global) or `.ope
|
|
|
780
891
|
"coder": { "max_tool_calls": 500 }
|
|
781
892
|
}
|
|
782
893
|
},
|
|
894
|
+
"authority": {
|
|
895
|
+
"enabled": true,
|
|
896
|
+
"rules": {
|
|
897
|
+
"coder": {
|
|
898
|
+
"allowedPrefix": ["src/", "lib/"],
|
|
899
|
+
"blockedPrefix": [".swarm/"],
|
|
900
|
+
"blockedZones": ["generated"]
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
},
|
|
783
904
|
"review_passes": {
|
|
784
905
|
"always_security_review": false,
|
|
785
906
|
"security_globs": ["**/*auth*", "**/*crypto*", "**/*session*"]
|