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 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
- ## What Swarm Catches
50
+ ## Shell Write Detection
49
51
 
50
- Concrete classes of failure that Swarm gates exist to stop every item ties to an agent or pipeline gate that already runs in this repo:
52
+ Swarm includes comprehensive static analysis for shell commands to detect and intercept file write operations before execution.
51
53
 
52
- - **Hallucinated APIs and citations** — `critic_hallucination_verifier` verifies referenced APIs and citations against real sources before they reach the codebase.
53
- - **Missing tests and regressions** — `test_engineer` writes and runs tests on every task; the architect runs a regression sweep across the graph after each task (pipeline step `5l`).
54
- - **Unsafe secret and logging patterns** — `secretscan` and `sast_scan` (63+ rules across 9 languages, offline) run as part of the per-task `pre_check_batch`.
55
- - **Plan and spec drift** `critic_drift_verifier` is a blocking phase-completion gate; `curator_phase` also flags workflow drift across phases.
56
- - **Placeholders and TODO stubs** — `placeholder_scan` runs in the per-task pipeline (step `5d`) and rejects code that ships incomplete stubs.
57
- - **Untrusted plans** `critic` reviews the plan before any code is written; `completion-verify` is a deterministic phase-close gate that checks plan task identifiers actually exist in source files.
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>Working Directory Requirement: No process.cwd() Fallback</strong></summary>
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
- ### Defense-in-Depth
722
+ The `save_plan` tool requires an explicit target workspace path. It does **not** fall back to `process.cwd()`.
692
723
 
693
- This safety guarantee is implemented in two layers:
724
+ ### Explicit Workspace Requirement
694
725
 
695
- 1. **Fast-path filter** (`resolveWorkingDirectory` in `src/tools/resolve-working-directory.ts`) — validates all incoming `working_directory` values for null-byte injection, path traversal, Windows device paths, and subdirectory containment before any file system access
696
- 2. **Canonical write-time guard** (`validateProjectRoot` in `src/evidence/manager.ts`) uses `realpathSync` to canonicalize paths at evidence-write time, catching any symlink-based subdirectory bypasses that slip past the fast-path filter
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 any affected tool, always pass a valid `working_directory`:
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>