opencode-swarm 7.25.2 → 7.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -42
- package/dist/cli/index.js +153 -551
- package/dist/evidence/manager.d.ts +0 -8
- package/dist/hooks/guardrails.d.ts +22 -0
- package/dist/hooks/shell-write-detect.d.ts +110 -0
- package/dist/index.js +2752 -1867
- package/dist/scope/scope-persistence.d.ts +4 -3
- package/dist/services/config-doctor.d.ts +0 -33
- package/dist/test-impact/analyzer.d.ts +0 -2
- package/dist/test-impact/history-store.d.ts +0 -7
- package/dist/tools/pre-check-batch.d.ts +1 -1
- package/dist/tools/resolve-working-directory.d.ts +1 -8
- package/dist/tools/test-runner.d.ts +0 -10
- package/dist/tools/update-task-status.d.ts +2 -3
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -38,6 +38,8 @@ Most AI coding tools let one model write code and ask that same model whether th
|
|
|
38
38
|
- 🔁 **Resumable sessions** — all state saved to `.swarm/`; pick up any project any day
|
|
39
39
|
- 🌐 **20 languages** — TypeScript, Python, Go, Rust, Java, Kotlin, C/C++, C#, Ruby, Swift, Dart, PHP, JavaScript, CSS, Bash, PowerShell, INI, Regex (extending: see [docs/adding-a-language.md](docs/adding-a-language.md))
|
|
40
40
|
- 🛡️ **Built-in security** — SAST, secrets scanning, dependency audit per task
|
|
41
|
+
- 📝 **Shell write detection** — Static analysis of POSIX/PowerShell/cmd commands to detect file writes (redirects, builtins, in-place editors, network downloads, archive extraction, git destructive ops) before execution
|
|
42
|
+
- 🔒 **Scope enforcement** — Validates write targets against declared scope with cross-process persistence and TTL expiry
|
|
41
43
|
- 🆓 **Free tier** — works with OpenCode Zen's free model roster
|
|
42
44
|
- ⚙️ **Fully configurable** — override any agent's model, disable agents, tune guardrails
|
|
43
45
|
|
|
@@ -45,16 +47,44 @@ Most AI coding tools let one model write code and ask that same model whether th
|
|
|
45
47
|
|
|
46
48
|
---
|
|
47
49
|
|
|
48
|
-
##
|
|
50
|
+
## Shell Write Detection
|
|
49
51
|
|
|
50
|
-
|
|
52
|
+
Swarm includes comprehensive static analysis for shell commands to detect and intercept file write operations before execution.
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
- **
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
54
|
+
### Shell Write Detection Features
|
|
55
|
+
|
|
56
|
+
- **POSIX shell detection** — Parses commands with `bash-parser` AST for accurate detection of:
|
|
57
|
+
- Redirect operators (`>`, `>>`, `>|`, `<<`, `<<-`)
|
|
58
|
+
- Here-documents and here-strings
|
|
59
|
+
- Write-effect builtins (`cp`, `mv`, `install`, `ln`, `truncate`, `dd`)
|
|
60
|
+
- In-place editors (`sed -i`, `perl -i`, `awk -i`)
|
|
61
|
+
- Interpreter eval (`python -c`, `node -e`, `bun -e`, `ruby -e`, `php -r`)
|
|
62
|
+
- Network downloaders (`curl -o`, `wget -O`, `scp`)
|
|
63
|
+
- Archive extraction (`tar -x`, `unzip`, `gunzip`)
|
|
64
|
+
- Git destructive operations (`git clean -fd`, `git reset --hard`)
|
|
65
|
+
|
|
66
|
+
- **Windows shell detection** — Uses regex heuristics for PowerShell and cmd.exe:
|
|
67
|
+
- PowerShell cmdlets: `Out-File`, `Set-Content`, `Add-Content`, `Copy-Item`, `Move-Item`
|
|
68
|
+
- cmd.exe builtins: `copy`, `move`, `ren`, `del`, `rd`, `md`
|
|
69
|
+
- Redirect operators (`>`, `>>`)
|
|
70
|
+
|
|
71
|
+
- **Interactive session denial** — Blocks commands that create persistent or open-ended sessions:
|
|
72
|
+
- POSIX: `watch`, `screen`, `tmux new-session`
|
|
73
|
+
- PowerShell: `Start-Process`
|
|
74
|
+
|
|
75
|
+
- **Cross-process scope enforcement** — Declared scope is persisted to `.swarm/scopes/scope-{taskId}.json` with:
|
|
76
|
+
- TTL expiry (default 24 hours)
|
|
77
|
+
- Symlink guards (O_NOFOLLOW + realpath containment)
|
|
78
|
+
- Schema versioning and fail-closed validation
|
|
79
|
+
|
|
80
|
+
### Security Patterns
|
|
81
|
+
|
|
82
|
+
The guardrails system blocks destructive shell commands targeting:
|
|
83
|
+
- System paths (`/root`, `/etc`, `C:\Windows`, etc.)
|
|
84
|
+
- Symlink/junction creation with external targets
|
|
85
|
+
- File operations under `.swarm/` directory
|
|
86
|
+
- Fork bombs and infinite loops
|
|
87
|
+
- Disk wiping and ransomware-grade operations
|
|
58
88
|
|
|
59
89
|
---
|
|
60
90
|
|
|
@@ -349,6 +379,9 @@ graph TB
|
|
|
349
379
|
| Plan reviewed before coding | ✅ | ❌ | ❌ |
|
|
350
380
|
| Every task reviewed + tested | ✅ | ❌ | ❌ |
|
|
351
381
|
| Different model for review vs. code | ✅ | ❌ | ❌ |
|
|
382
|
+
| Shell write detection (POSIX/PowerShell/cmd) | ✅ | ❌ | ❌ |
|
|
383
|
+
| Scope enforcement with cross-process persistence | ✅ | ❌ | ❌ |
|
|
384
|
+
| Interactive session detection and blocking | ✅ | ❌ | ❌ |
|
|
352
385
|
| Resumable sessions | ✅ | ❌ | ❌ |
|
|
353
386
|
| Built-in security scanning | ✅ | ❌ | ❌ |
|
|
354
387
|
| Learns from mistakes | ✅ | ❌ | ❌ |
|
|
@@ -684,28 +717,14 @@ File rotates automatically at 10MB to `.swarm/telemetry.jsonl.1`.
|
|
|
684
717
|
</details>
|
|
685
718
|
|
|
686
719
|
<details>
|
|
687
|
-
<summary><strong>
|
|
688
|
-
|
|
689
|
-
All Swarm tools that accept a `working_directory` parameter **require an explicit path**. They do **not** fall back to `process.cwd()`. This prevents `.swarm` state from being created in project subdirectories when the host process's working directory differs from the actual project root (issue [#922](https://github.com/zaxbysauce/opencode-swarm/issues/922)).
|
|
720
|
+
<summary><strong>Save Plan Tool: Target Workspace Requirement</strong></summary>
|
|
690
721
|
|
|
691
|
-
|
|
722
|
+
The `save_plan` tool requires an explicit target workspace path. It does **not** fall back to `process.cwd()`.
|
|
692
723
|
|
|
693
|
-
|
|
724
|
+
### Explicit Workspace Requirement
|
|
694
725
|
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
### Tools That Require Explicit working_directory
|
|
699
|
-
|
|
700
|
-
The following tools require an explicit `working_directory` and reject subdirectory paths:
|
|
701
|
-
|
|
702
|
-
- `save_plan`
|
|
703
|
-
- `update_task_status`
|
|
704
|
-
- `declare_scope`
|
|
705
|
-
- `pre_check_batch`
|
|
706
|
-
- `test_impact`
|
|
707
|
-
- `mutation_test`
|
|
708
|
-
- `diff_summary`
|
|
726
|
+
- The `working_directory` parameter must be provided
|
|
727
|
+
- Providing no value or relying on implicit directory resolution will result in deterministic failure
|
|
709
728
|
|
|
710
729
|
### Failure Conditions
|
|
711
730
|
|
|
@@ -714,34 +733,20 @@ The following tools require an explicit `working_directory` and reject subdirect
|
|
|
714
733
|
| Missing (`undefined` / `null`) | Fails with: "Target workspace is required" |
|
|
715
734
|
| Empty or whitespace-only | Fails with: "Target workspace cannot be empty or whitespace" |
|
|
716
735
|
| Path traversal (`..`) | Fails with: "Target workspace cannot contain path traversal" |
|
|
717
|
-
| Subdirectory of project root | Fails with: "...is a subdirectory of fallback..." |
|
|
718
|
-
| Windows device path | Fails with: "Windows device paths are not allowed" |
|
|
719
736
|
|
|
720
737
|
### Usage Contract
|
|
721
738
|
|
|
722
|
-
When using
|
|
739
|
+
When using `save_plan`, always pass a valid `working_directory`:
|
|
723
740
|
|
|
724
741
|
```typescript
|
|
725
|
-
// save_plan example
|
|
726
742
|
save_plan({
|
|
727
743
|
title: "My Project",
|
|
728
744
|
swarm_id: "mega",
|
|
729
745
|
phases: [{ id: 1, name: "Setup", tasks: [{ id: "1.1", description: "Initialize project" }] }],
|
|
730
|
-
working_directory: "/path/to/project" // Required - no process.cwd() fallback
|
|
731
|
-
})
|
|
732
|
-
|
|
733
|
-
// update_task_status example
|
|
734
|
-
update_task_status({
|
|
735
|
-
task_id: "1.1",
|
|
736
|
-
status: "completed",
|
|
737
746
|
working_directory: "/path/to/project" // Required - no fallback
|
|
738
747
|
})
|
|
739
748
|
```
|
|
740
749
|
|
|
741
|
-
### Stray .swarm Detection
|
|
742
|
-
|
|
743
|
-
`/swarm doctor` now detects and reports stray `.swarm` directories found in project subdirectories (created by older versions or misconfigured tools). It offers cleanup guidance to prevent state pollution.
|
|
744
|
-
|
|
745
750
|
</details>
|
|
746
751
|
|
|
747
752
|
<details>
|