opencode-fs-plugin 3.4.0 → 3.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -10,70 +10,76 @@ unit, end-to-end and coverage tests.
10
10
 
11
11
  | Native command | Tool | Main options |
12
12
  |---|---|---|
13
- | `mkdir` | `fs.mkdir` | `parents`, `mode`, `verbose` |
14
- | `rmdir` | `fs.rmdir` | `parents`, `ignoreNonEmpty`, `verbose` |
15
- | `rm` | `fs.rm` | `recursive`, `force`, `dir`, `verbose` |
16
- | `cp` | `fs.cp` | `recursive`, `archive`, `force`, `noClobber`, `update`, `preserve`, `dereference`, `verbose` |
17
- | `mv` | `fs.mv` | `force`, `noClobber`, `update`, `verbose` |
18
- | `ls` | `fs.ls` | `all`, `almostAll`, `long`, `human`, `recursive`, `directory`, `inode`, `classify`, `size`, `numericIds`, `noGroup`, `noOwner`, `slash`, `quote`, `versionSort`, `extensionSort`, `fullTime`, `timeStyle`, `hide`, `ignore`, `groupDirectoriesFirst`, `sortBy`, `reverse`, `onePerLine` |
19
- | `stat` | `fs.stat` | `follow`, `format`, `terse`, `filesystem` |
20
- | `touch` | `fs.touch` | `accessOnly`, `modifyOnly`, `noCreate`, `date`, `timestamp`, `reference`, `noDereference` |
21
- | `truncate` | `fs.truncate` | `size`, `reference`, `noCreate`, `noDereference` |
22
- | `ln` | `fs.ln` | `symbolic`, `force`, `noDereference`, `relative`, `verbose` |
23
- | `readlink` | `fs.readlink` | `mode` (`raw`, `canonical`, `existing`, `missing`), `noNewline` |
13
+ | `ar` | `fs.ar` | `create`/`list`/`extract`, `directory`, `members` |
14
+ | `base64` | `fs.base64` | `decode`, `wrap`, `ignoreGarbage` |
15
+ | `cat` | `fs.cat` | `number`, `numberNonBlank`, `squeezeBlank`, `showEnds`, `showTabs`, `showNonPrinting` |
24
16
  | `chmod` | `fs.chmod` | octal/symbolic mode, `reference`, `recursive`, `noDereference`, `verbose`, `changes`, `silent` |
25
- | `sha256sum`/`md5sum` | `fs.hash` | `algorithm`, `tag`; hashes files or stdin |
26
- | `du` | `fs.du` | `summarize`, `all`, `human`, `total`, `maxDepth`, `follow`, `oneFileSystem` |
17
+ | `chown` | `fs.chown` | `user`/`uid`, `group`/`gid`, `recursive`, `noDereference` |
18
+ | `comm` | `fs.comm` | `suppress1`/`2`/`3`, `outputDelimiter` |
19
+ | `command` | `fs.command` | `command`, `args`, `cwd`, `stdin`, `timeoutMs`; `fs_command` permission, procage sandbox, no shell |
20
+ | `cp` | `fs.cp` | `recursive`, `archive`, `force`, `noClobber`, `update`, `preserve`, `dereference`, `verbose` |
21
+ | `cpio` | `fs.cpio` | `create`/`list`/`extract` (newc), `directory`, `members`, `input`, `member`, `verbose` |
22
+ | `curl` | `fs.curl` | `url`, `method`, `headers`, `body`, `json`, `output`, `checksum`, `maxBytes`, `timeoutMs`, `failOnError`, `followRedirects`, `maxRedirects` |
23
+ | `cut` | `fs.cut` | `fields`, `characters`, `bytes`, `delimiter`, `outputDelimiter`, `complement`, `onlyDelimited` |
24
+ | `date` | `fs.date` | `value`, `utc`, `format` (`iso`, `unix`, `rfc`, `date`) |
25
+ | `dd` | `fs.dd` | `input`, `output`, `blockSize`, `count`, `skip`, `seek`, `status` |
27
26
  | `df` | `fs.df` | `human`, `inodes`, `printType`, `all` |
27
+ | `diff` | `fs.diff` | `unified`, `brief`, `recursive`, `ignoreWhitespace`, `ignoreCase`, `exclude` |
28
+ | `du` | `fs.du` | `summarize`, `all`, `human`, `total`, `maxDepth`, `follow`, `oneFileSystem` |
29
+ | `file` | `fs.file` | `paths`, `mime`; content magic detection |
28
30
  | `find` | `fs.find` | `name`, `iname`, `pathPattern`, `lname`, `ilname`, `regex`, `iregex`, `type`, `size`, `mtime`, `mmin`, `maxDepth`, `minDepth`, `empty`, `perm`, `uid`, `gid`, `user`, `group`, `links`, `inum`, `samefile`, `fstype`, `newer`, `newerXY`, `printf`, `follow`, `print0`, `sort`, `action` (`print`/`delete`/`trash`), `recursive` |
29
- | `cat` | `fs.cat` | `number`, `numberNonBlank`, `squeezeBlank`, `showEnds`, `showTabs`, `showNonPrinting` |
30
- | `head` | `fs.head` | `lines`, `skip`, `bytes`, `quiet`, `verbose` |
31
- | `tail` | `fs.tail` | `lines`, `bytes`, `fromStart`, `quiet`, `verbose`, `follow`, `timeoutMs`, `intervalMs`, `maxBytes` |
32
- | `tee` | `fs.tee` | `append`, `content` |
33
- | `wc` | `fs.wc` | `lines`, `words`, `bytes`, `chars`, `maxLineLength` |
34
- | `sort` | `fs.sort` | `numeric`, `generalNumeric`, `humanNumeric`, `version`, `reverse`, `unique`, `ignoreCase`, `dictionary`, `ignoreNonPrinting`, `ignoreLeadingBlanks`, `stable`, `check`, `checkQuiet`, `zeroTerminated`, `keys`, `field`, `separator` |
35
- | `uniq` | `fs.uniq` | `count`, `repeated`, `uniqueOnly`, `ignoreCase`, `skipFields`, `skipChars` |
36
- | `cut` | `fs.cut` | `fields`, `characters`, `bytes`, `delimiter`, `outputDelimiter`, `complement`, `onlyDelimited` |
37
- | `tr` | `fs.tr` | `set1`, `set2`, `delete`, `squeeze`, `complement`; ranges and classes |
38
- | `sed` | `fs.sed` | `script`, `expressions`, `inPlace`, `extendedRegexp`, `quiet`; `s///` subset |
31
+ | `findmnt` | `fs.findmnt` | `paths`, `fsType`, `noHeader` |
32
+ | `fold` | `fs.fold` | `width`, `spaces` |
39
33
  | `grep` | `fs.grep` | `recursive`, `include`, `exclude`, `ignoreCase`, `invert`, `lineNumbers`, `withFilename`, `noFilename`, `filesWithMatches`, `filesWithoutMatch`, `count`, `onlyMatching`, `word`, `line`, `fixed`, `context`, `before`, `after`, `maxCount`, `noMessages` |
40
- | `tar` | `fs.tar` | `create`/`extract`/`list`, `gzip`, `directory`, `stripComponents`, `exclude`, `verbose`, `input`, `member` |
41
- | `zip` | `fs.zip` | `archive`, `paths`, `level`, `input`, `member` |
42
- | `unzip` | `fs.unzip` | `extract`/`list`, `directory`, `overwrite`, `noOverwrite` |
43
- | `gzip` | `fs.gzip` | `keep`, `force`, `stdout`, `level` |
44
34
  | `gunzip` | `fs.gunzip` | `keep`, `force`, `stdout`, `suffix` |
45
- | `mktemp` | `fs.mktemp` | `template`, `directory`, `tmpdir`, `suffix` |
46
- | `trash` | `fs.trash` | XDG home trash |
47
- | `diff` | `fs.diff` | `unified`, `brief`, `recursive`, `ignoreWhitespace`, `ignoreCase`, `exclude` |
48
- | `chown` | `fs.chown` | `user`/`uid`, `group`/`gid`, `recursive`, `noDereference` |
49
- | `ps` | `fs.ps` | `pids`, `user`, `command`, `sortBy`, `limit`, `noHeader`, `format` |
50
- | `pgrep` | `fs.pgrep` | `pattern`, `full`, `ignoreCase`, `user`, `newest`, `oldest`, `count`, `delimiter` |
51
- | `kill` | `fs.kill` | `pids`, `signal`, `dryRun`; pid 0/1 and groups rejected |
52
- | `file` | `fs.file` | `paths`, `mime`; content magic detection |
53
- | `base64` | `fs.base64` | `decode`, `wrap`, `ignoreGarbage` |
54
- | `od` | `fs.od` | `offset`, `length`, `width` |
55
- | `strings` | `fs.strings` | `minLength` |
35
+ | `gzip` | `fs.gzip` | `keep`, `force`, `stdout`, `level` |
36
+ | `sha256sum`/`md5sum` | `fs.hash` | `algorithm`, `tag`; hashes files or stdin |
37
+ | `head` | `fs.head` | `lines`, `skip`, `bytes`, `quiet`, `verbose` |
56
38
  | `id` | `fs.id` | `only` (`user`, `group`, `groups`) |
57
- | `uname` | `fs.uname` | `kernel`, `nodename`, `release`, `version`, `machine` |
58
- | `uptime` | `fs.uptime` | `pretty`, `loadAverage` |
59
- | `date` | `fs.date` | `value`, `utc`, `format` (`iso`, `unix`, `rfc`, `date`) |
60
- | `findmnt` | `fs.findmnt` | `paths`, `fsType`, `noHeader` |
39
+ | `kill` | `fs.kill` | `pids`, `signal`, `dryRun`; pid 0/1 and groups rejected |
40
+ | `ln` | `fs.ln` | `symbolic`, `force`, `noDereference`, `relative`, `verbose` |
41
+ | `ls` | `fs.ls` | `all`, `almostAll`, `long`, `human`, `recursive`, `directory`, `inode`, `classify`, `size`, `numericIds`, `noGroup`, `noOwner`, `slash`, `quote`, `versionSort`, `extensionSort`, `fullTime`, `timeStyle`, `hide`, `ignore`, `groupDirectoriesFirst`, `sortBy`, `reverse`, `onePerLine` |
42
+ | `mkdir` | `fs.mkdir` | `parents`, `mode`, `verbose` |
43
+ | `mktemp` | `fs.mktemp` | `template`, `directory`, `tmpdir`, `suffix` |
61
44
  | `mountpoint` | `fs.mountpoint` | `paths`, `quiet` |
62
- | `tac` | `fs.tac` | reverse lines |
63
- | `rev` | `fs.rev` | reverse characters per line |
45
+ | `mv` | `fs.mv` | `force`, `noClobber`, `update`, `verbose` |
64
46
  | `nl` | `fs.nl` | `all`, `start`, `width`, `separator` |
47
+ | `od` | `fs.od` | `offset`, `length`, `width` |
65
48
  | `paste` | `fs.paste` | `delimiters`, `serial` |
66
- | `comm` | `fs.comm` | `suppress1`/`2`/`3`, `outputDelimiter` |
67
- | `split` | `fs.split` | `lines`/`bytes`, `prefix`, `suffixLength`, `numeric`, `additionalSuffix` |
49
+ | `pgrep` | `fs.pgrep` | `pattern`, `full`, `ignoreCase`, `user`, `newest`, `oldest`, `count`, `delimiter` |
50
+ | `ps` | `fs.ps` | `pids`, `user`, `command`, `sortBy`, `limit`, `noHeader`, `format` |
51
+ | `readlink` | `fs.readlink` | `mode` (`raw`, `canonical`, `existing`, `missing`), `noNewline` |
52
+ | `rev` | `fs.rev` | reverse characters per line |
53
+ | `rm` | `fs.rm` | `recursive`, `force`, `dir`, `verbose` |
54
+ | `rmdir` | `fs.rmdir` | `parents`, `ignoreNonEmpty`, `verbose` |
55
+ | `sed` | `fs.sed` | `script`, `expressions`, `inPlace`, `extendedRegexp`, `quiet`; `s///` subset |
68
56
  | `shuf` | `fs.shuf` | `headCount`, `zeroTerminated` |
69
- | `fold` | `fs.fold` | `width`, `spaces` |
57
+ | `sort` | `fs.sort` | `numeric`, `generalNumeric`, `humanNumeric`, `version`, `reverse`, `unique`, `ignoreCase`, `dictionary`, `ignoreNonPrinting`, `ignoreLeadingBlanks`, `stable`, `check`, `checkQuiet`, `zeroTerminated`, `keys`, `field`, `separator` |
58
+ | `split` | `fs.split` | `lines`/`bytes`, `prefix`, `suffixLength`, `numeric`, `additionalSuffix` |
59
+ | `stat` | `fs.stat` | `follow`, `format`, `terse`, `filesystem` |
60
+ | `strings` | `fs.strings` | `minLength` |
70
61
  | `sync` | `fs.sync` | `paths`; file/directory fsync |
71
- | `dd` | `fs.dd` | `input`, `output`, `blockSize`, `count`, `skip`, `seek`, `status` |
72
- | `cpio` | `fs.cpio` | `create`/`list`/`extract` (newc), `directory`, `members`, `input`, `member`, `verbose` |
73
- | `ar` | `fs.ar` | `create`/`list`/`extract`, `directory`, `members` |
74
- | HTTP(S) | `fs.http_request` | `url`, `method`, `headers`, `body`, `json`, `output`, `checksum`, `maxBytes`, `timeoutMs`, `failOnError`, `followRedirects`, `maxRedirects` |
75
- | process | `fs.exec` | `command`, `args`, `cwd`, `stdin`, `timeoutMs`; exact allowlist, procage sandbox, no shell |
76
- | shell pipe | `fs.pipe` | `stages`, `input`, `output`, `append` |
62
+ | `tac` | `fs.tac` | reverse lines |
63
+ | `tail` | `fs.tail` | `lines`, `bytes`, `fromStart`, `quiet`, `verbose`, `follow`, `timeoutMs`, `intervalMs`, `maxBytes` |
64
+ | `tar` | `fs.tar` | `create`/`extract`/`list`, `gzip`, `directory`, `stripComponents`, `exclude`, `verbose`, `input`, `member` |
65
+ | `tee` | `fs.tee` | `append`, `content` |
66
+ | `touch` | `fs.touch` | `accessOnly`, `modifyOnly`, `noCreate`, `date`, `timestamp`, `reference`, `noDereference` |
67
+ | `tr` | `fs.tr` | `set1`, `set2`, `delete`, `squeeze`, `complement`; ranges and classes |
68
+ | `trash` | `fs.trash` | XDG home trash |
69
+ | `truncate` | `fs.truncate` | `size`, `reference`, `noCreate`, `noDereference` |
70
+ | `uname` | `fs.uname` | `kernel`, `nodename`, `release`, `version`, `machine` |
71
+ | `uniq` | `fs.uniq` | `count`, `repeated`, `uniqueOnly`, `ignoreCase`, `skipFields`, `skipChars` |
72
+ | `unzip` | `fs.unzip` | `extract`/`list`, `directory`, `overwrite`, `noOverwrite` |
73
+ | `uptime` | `fs.uptime` | `pretty`, `loadAverage` |
74
+ | `wc` | `fs.wc` | `lines`, `words`, `bytes`, `chars`, `maxLineLength` |
75
+ | `zip` | `fs.zip` | `archive`, `paths`, `level`, `input`, `member` |
76
+
77
+ `fs.job` and `fs.pipe` are support tools rather than shell replacements:
78
+
79
+ | Purpose | Tool | Main options |
80
+ |---|---|---|
81
+ | Background jobs | `fs.job` | `id`, `wait`, `cancel`, `list`, `timeoutMs` |
82
+ | Sequential byte pipeline | `fs.pipe` | `stages`, `input`, `output`, `append` |
77
83
 
78
84
  `fs.head.skip` selects line ranges (`sed -n '20,40p'`). `fs.find` can
79
85
  `action: "delete"` or `"trash"` its matches; the starting directory itself is
@@ -88,13 +94,6 @@ Prefer the canonical names.
88
94
 
89
95
  ## Pipe
90
96
 
91
- Direct results larger than the spill threshold are written to
92
- `/tmp/opencode/fs-spill` and returned as a 64 KiB preview plus `outputPath`,
93
- `bytes`, and `spilled` metadata; the rendered result points at the file. The
94
- threshold defaults to a quarter of free memory, clamped between 16 MiB and
95
- 512 MiB; set `spillThresholdBytes` in the plugin options to fix it. Pipe stages
96
- keep whole buffers so bytes pass unchanged.
97
-
98
97
  `fs.pipe` joins registered tools through byte buffers. Stages run in order;
99
98
  only pipeable tools can be used. Each stage asserts its own `fs_<tool>` action
100
99
  before it runs, so a disabled stage cannot be hidden inside a pipe. `output` and
@@ -112,22 +111,25 @@ await tools.fs.pipe({
112
111
  })
113
112
  ```
114
113
 
115
- New filter stages: `exec`, `tac`, `rev`, `nl`, `paste`, `shuf`, `fold`, `base64`, `od`,
114
+ Filter stages: `base64`, `command`, `fold`, `nl`, `od`, `paste`, `rev`, `shuf`, `tac`,
116
115
  and `strings`; `dd` and `cpio` are source/sink stages like `tar`.
117
116
 
118
- `fs.http_request` is a pipe source, so network data can feed the same stages:
117
+ `fs.curl` is a pipe source, so network data can feed the same stages:
119
118
 
120
119
  ```js
121
120
  await tools.fs.pipe({
122
121
  stages: [
123
- { tool: "http_request", args: { url: "https://example.com/app.log" } },
122
+ { tool: "curl", args: { url: "https://example.com/app.log" } },
124
123
  { tool: "grep", args: { pattern: "ERROR" } },
125
124
  ],
126
125
  })
127
126
  ```
128
127
 
129
128
  Pipe stages exchange whole buffers, so use `maxBytes` for large responses. For
130
- large downloads prefer `fs.http_request({ output })`, which streams to disk.
129
+ large downloads prefer `fs.curl({ output })`, which streams to disk. A stage
130
+ that yields no stdout becomes an empty buffer, so `output` writes an empty file
131
+ instead of skipping it. The signal is checked before each stage and before the
132
+ final write, so an abort stops the chain without creating the output.
131
133
 
132
134
  There is no shell, redirection operator, nested pipe, or arbitrary `find -exec`.
133
135
 
@@ -135,23 +137,36 @@ There is no shell, redirection operator, nested pipe, or arbitrary `find -exec`.
135
137
  work, fan out with `Promise.all` over `tools.fs.*` (or one multi-path call).
136
138
  `fs` domain errors resolve as `ERROR:`/`BLOCKED:` text; permission denials throw.
137
139
 
138
- ## Exec
140
+ ## Command
139
141
 
140
- `fs.exec` runs one allowlisted executable inside a procage sandbox with
141
- `shell: false`. The default allowlist is `npm`, `npx`, `uv`, `uvx`, `pip`,
142
- `pip3`; override it in the plugin options:
142
+ `fs.command` runs one executable inside a procage sandbox with
143
+ `shell: false`. It is closest to the shell's `command <prog>`: one program with
144
+ literal argv, not `exec` (which replaces the calling shell) and not `sh -c`
145
+ (which parses shell syntax). The executable allowlist is the `fs_command`
146
+ permission: the tool asserts that action with the bare executable name as its
147
+ resource. Deny `*` to close the set, then allow the names you need:
143
148
 
144
149
  ```jsonc
145
150
  {
146
- "package": "./repos/opencode-fs-plugin",
147
- "options": { "execAllowlist": ["npm", "uv"] }
151
+ "permissions": [
152
+ { "action": "fs_command", "resource": "*", "effect": "deny" },
153
+ { "action": "fs_command", "resource": "npm", "effect": "allow" },
154
+ { "action": "fs_command", "resource": "uv", "effect": "allow" }
155
+ ]
148
156
  }
149
157
  ```
150
158
 
151
- The workspace (project) is read/write/exec. **Network is proxy-only by
152
- default**: every run gets its own egress proxy, no direct route, and every host
153
- must be approved through `fs_exec_network`. There is no separate allowlist
154
- option; the permission rules are the allowlist:
159
+ With no rule the base allow applies to every executable, so keep the `*` deny
160
+ when you want a closed set.
161
+
162
+ The workspace (project) is read/write/exec. **Network egress needs Linux tier
163
+ T1** (user namespaces and TPROXY). Every run gets procage's transparent relay:
164
+ there is no direct route, and every TCP or UDP flow is named to the plugin as a
165
+ DNS QNAME, TLS SNI, HTTP `Host`, QUIC SNI, or an IP literal. Bare IPv6 literals
166
+ and bracketed IPv6 `Host` forms with an optional port are accepted as
167
+ resources. That exact resource must be approved through `fs_exec_network`; the
168
+ port, URL, headers, and payload are never part of the permission. There is no
169
+ separate network allowlist option:
155
170
 
156
171
  ```jsonc
157
172
  {
@@ -163,50 +178,85 @@ option; the permission rules are the allowlist:
163
178
  }
164
179
  ```
165
180
 
166
- A host the proxy refuses asks `fs_exec_network` with that host, and the run
167
- retries with it added. With no rule (base allow), that happens silently; with a
168
- `*` deny the host fails closed instead. `execNetworkMode: "ip"` opts into all-IP
169
- networking after the same approval instead. External paths are separate: a
170
- blocked path asks `external_directory` for its containing directory (or the
171
- nearest existing ancestor), and the sandbox grants read/write there.
181
+ A flow asks with its own resource. With no rule (base allow) the request is
182
+ approved silently; with a `*` deny an unlisted resource fails closed. DNS
183
+ queries are flows too: an allowed QNAME is answered through the parent resolver
184
+ (procage reads `/etc/resolv.conf` and systemd-resolved paths, including a
185
+ loopback stub), a denied one gets `REFUSED`, and TCP/853 or a known
186
+ encrypted-DNS endpoint is refused without asking. That DoH filtering is
187
+ best-effort: TCP/853 and the finite list of known DoH names are blocked, but
188
+ custom or unknown DoH endpoints on other names or ports may not be recognized.
189
+ ECH detected in TLS or QUIC is visibly refused. Allowed answers feed a
190
+ bounded per-run address-to-name cache: a later flow that names no host is
191
+ authorized by a fresh allowed name bound to its address, otherwise by the
192
+ address itself. A named flow must either match an allowed DNS answer for the
193
+ exact `(name, address)` pair or have both its name and its address allowed; a
194
+ denied named identity is never rescued by an allowed address. Allow the DNS
195
+ names a program uses. Also allow an address when the program connects to IP
196
+ literals, or when a named flow's name is allowed but that exact
197
+ `(name, address)` was not returned by an allowed DNS answer: only the cached
198
+ pair avoids the separate address check, so that named flow needs both
199
+ permissions.
200
+
201
+ External proxy settings are preserved: `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`,
202
+ `NO_PROXY`, their lowercase forms, and the npm proxy variables are passed to the
203
+ child explicitly, because they are not in the preset's environment allowlist.
204
+ The relay treats the proxy as the destination, never its `CONNECT` target, so
205
+ an external proxy works only when `fs_exec_network` allows the proxy's address
206
+ (or its cached DNS name, which also needs its DNS query allowed). That approval
207
+ lets the proxy forward to whatever it reaches; it is not scoped to the target
208
+ URL behind the proxy. No other caller environment variable is forwarded
209
+ explicitly, but the preset's own environment allowlist still applies, and a
210
+ proxy variable may itself carry proxy credentials.
211
+
212
+ External paths are separate: a blocked path asks `external_directory` for its
213
+ containing directory (or the nearest existing ancestor), and the sandbox grants
214
+ read/write there. Only procage's structured **write** violations (`file-write-*`)
215
+ can trigger that auto-approval; read, exec, network, or unknown path failures
216
+ never do. When procage reports no write violation, no path grant is inferred and
217
+ access remains denied — pre-grant the path with `external_directory` or a rule.
218
+ A path printed by the child on stdout or stderr is reported, never auto-approved.
172
219
 
173
220
  The decision comes from your `opencode.jsonc` rules (`ask`, `allow`, `deny`), the
174
221
  same as every other tool. If a path stays blocked after approval, the result
175
- reports `violations` and a `hint`. `fs.exec` also kills every process it started
222
+ reports `violations` and a `hint`. `fs.command` also kills every process it started
176
223
  when the run ends, including detached descendants.
177
224
 
178
- Proxy mode needs Linux T1 (user namespaces) or macOS. On Linux T2 there is no
179
- network namespace, so `fs.exec` falls back to all-IP: a socket denial asks
180
- `fs_exec_network` and retries with `ip`. In `ip` mode the policy also opens the
181
- resolver sockets used by systemd-resolved, nscd, and SSSD
182
- (`/run/systemd/resolve`, `/run/nscd`, `/var/lib/sss/pipes`), so DNS works across
183
- common Linux distributions. Plain UDP DNS needs none of them; other Unix sockets
184
- stay blocked. On kernels where procage cannot scope Unix sockets (T2 below
185
- Landlock ABI 9), the policy drops them via `no-unix-sockets`; DNS then works only
186
- through a plain UDP resolver.
225
+ On Linux T2 and on macOS the relay is unavailable, and a relay control server
226
+ that cannot start is treated the same way. `fs.command` retries the same run once
227
+ with networking off: the policy stays `net: "none"`, no resolver sockets are
228
+ granted, and macOS gets no resolver exception. The result carries
229
+ `networkMode: "disabled"` and a `networkReason`; there is no direct-IP fallback. Every flow decision is
230
+ fail-closed: a denial, a closed control link, an oversized or malformed frame,
231
+ a missing HELLO, or a decision timeout refuses the flow. The control socket
232
+ lives in a private per-run directory and is never part of the child's known
233
+ Unix sockets.
187
234
 
188
235
  ```js
189
- await tools.fs.exec({ command: "npm", args: ["install"], timeoutMs: 300000 })
236
+ await tools.fs.command({ command: "npm", args: ["install"], timeoutMs: 300000 })
190
237
  ```
191
238
 
192
239
  `command` is a bare name, `args` are literal, and `cwd` is sandboxed. Direct
193
- calls return JSON with `exitCode`, `stdout`, `stderr`, and violations; a pipe
194
- stage returns raw stdout so it composes with `grep`, `sort`, `tee`, and the rest.
240
+ calls return JSON with `exitCode`, `stdout`, `stderr`, `violations`, and the
241
+ network fields `network`, `networkMode`, `networkHosts`, and `networkReason`
242
+ (when networking was disabled); `externalPaths` lists the external roots the
243
+ run could write to. A pipe stage returns raw stdout so it composes with `grep`,
244
+ `sort`, `tee`, and the rest.
195
245
 
196
246
  ```js
197
247
  await tools.fs.pipe({
198
248
  stages: [
199
- { tool: "exec", args: { command: "npm", args: ["test"] } },
249
+ { tool: "command", args: { command: "npm", args: ["test"] } },
200
250
  { tool: "grep", args: { pattern: "FAIL" } },
201
251
  ],
202
252
  })
203
253
  ```
204
254
 
205
- The command asserts `fs_exec`, returns stdout/stderr in full, and treats a non-zero exit as
255
+ The command asserts `fs_command`, returns stdout/stderr in full, and treats a non-zero exit as
206
256
  a normal result. Procage requires Linux x64/arm64, glibc 2.28+, and Node 22.12+.
207
257
  On kernels before Landlock ABI 6, signal isolation relaxes to same-user. The
208
258
  trust-handoff class is waived so package tools can update workspace files such as
209
- `.git/hooks`; the executable allowlist remains the trust boundary.
259
+ `.git/hooks`; the `fs_command` permission remains the trust boundary.
210
260
 
211
261
  ## Performance and concurrency
212
262
 
@@ -234,8 +284,8 @@ gap; their input/output cost is dominated by the async I/O above.
234
284
 
235
285
  ## Background jobs
236
286
 
237
- Every `fs.*` tool accepts `background: true`. The call returns immediately with
238
- a job id and a status-file path:
287
+ Every tool except `fs.job` accepts `background: true`. The call returns
288
+ immediately with a job id and a status-file path:
239
289
 
240
290
  ```js
241
291
  const started = JSON.parse(
@@ -281,11 +331,31 @@ await tools.wait.for({
281
331
  ```
282
332
 
283
333
  Jobs are process-local: they are lost on an OpenCode server restart, and their
284
- status files may remain under `/tmp/opencode/fs-jobs/<server-pid>/`. The manager
285
- allows 8 concurrent jobs and cleans up finished jobs after one hour. Results
286
- stay in memory and are returned by `fs.job`; the status file contains only the
287
- job state and metadata. Background permission prompts can appear after the
288
- starting call returns, and a denied permission fails the job.
334
+ status files may remain under `/tmp/opencode/fs-jobs/<server-pid>/`; set the
335
+ plugin option `jobDir` to move them. The limits are global to one plugin
336
+ instance (one OpenCode server), not per session: at most 8 jobs run at once and
337
+ up to 64 are retained. Starting another evicts the oldest finished job and
338
+ deletes its status file; if no finished job is available to evict the start
339
+ fails with `busy`. Finished jobs are also cleaned up after one hour.
340
+
341
+ Each job is visible only to the session that started it: `fs.job` list, status,
342
+ wait, and cancel treat another session's id as not found. A background start or
343
+ `fs.job` call without a non-empty host session id fails with `invalid`. The
344
+ `jobDir` path is validated component by component: an existing symlink, a
345
+ non-directory component, or the filesystem root is refused, missing components
346
+ are created `0700`, and the final directory is `0700`. This is deliberately
347
+ fail-closed: a benign configured path that traverses a host symlink such as
348
+ `/home` is rejected, while the default `/tmp/opencode/fs-jobs/<pid>` path is
349
+ unaffected. A component swapped after validation remains a residual TOCTOU
350
+ race. Status files are `0600` and hold only id, tool, state, timing, and
351
+ `hasResult`; they omit the result, the raw error, and the absolute status path.
352
+ Results stay in memory and are returned by
353
+ `fs.job`, capped at 1 MiB per result. Longer text is truncated with
354
+ a `[truncated]` marker plus `truncated`/`originalBytes` metadata,
355
+ and an oversized base64/binary result becomes empty content. With 64 retained
356
+ results this can hold roughly 64 MiB of result text in the server process until
357
+ eviction. Background permission prompts can appear after the starting call
358
+ returns, and a denied permission fails the job.
289
359
 
290
360
  ## Installing from npm
291
361
 
@@ -293,18 +363,18 @@ Add the registry package directly to the plugin list:
293
363
 
294
364
  ```jsonc
295
365
  {
296
- "plugins": ["opencode-fs-plugin@3.0.0"]
366
+ "plugins": ["opencode-fs-plugin@<version>"]
297
367
  }
298
368
  ```
299
369
 
300
- `opencode plugin add opencode-fs-plugin@3.0.0` installs it and writes the config
370
+ `opencode plugin add opencode-fs-plugin@<version>` installs it and writes the config
301
371
  entry. A bare `opencode-fs-plugin` follows the `latest` tag.
302
372
 
303
373
  OpenCode manages the package under its cache, so the path is not stable. If you
304
374
  also want the packaged skill, install it into a project instead:
305
375
 
306
376
  ```bash
307
- npm install opencode-fs-plugin@3.0.0
377
+ npm install opencode-fs-plugin@<version>
308
378
  ```
309
379
 
310
380
  ```jsonc
@@ -319,7 +389,7 @@ npm install opencode-fs-plugin@3.0.0
319
389
  Download the release tarball, then install it as a normal npm package:
320
390
 
321
391
  ```bash
322
- VERSION=3.0.0
392
+ VERSION=<version>
323
393
  curl -L -o "opencode-fs-plugin-${VERSION}.tgz" \
324
394
  "https://github.com/masterjg/opencode-fs-plugin/releases/download/v${VERSION}/opencode-fs-plugin-${VERSION}.tgz"
325
395
  npm install "./opencode-fs-plugin-${VERSION}.tgz"
@@ -348,20 +418,20 @@ OpenCode installs it from Git:
348
418
 
349
419
  ```jsonc
350
420
  {
351
- "plugins": ["github:masterjg/opencode-fs-plugin#v3.0.0"]
421
+ "plugins": ["github:masterjg/opencode-fs-plugin#v<version>"]
352
422
  }
353
423
  ```
354
424
 
355
- `opencode plugin add 'github:masterjg/opencode-fs-plugin#v3.0.0'` installs the
425
+ `opencode plugin add 'github:masterjg/opencode-fs-plugin#v<version>'` installs the
356
426
  same spec and writes the config entry. The equivalent full URL is
357
- `git+https://github.com/masterjg/opencode-fs-plugin.git#v3.0.0`. A tag is
427
+ `git+https://github.com/masterjg/opencode-fs-plugin.git#v<version>`. A tag is
358
428
  checked for updates; use a full commit hash to pin it.
359
429
 
360
430
  Git plugins are installed under OpenCode's cache, so their package path is not
361
431
  stable. If you also want the packaged skill, install with npm instead:
362
432
 
363
433
  ```bash
364
- npm install "github:masterjg/opencode-fs-plugin#v3.0.0"
434
+ npm install "github:masterjg/opencode-fs-plugin#v<version>"
365
435
  ```
366
436
 
367
437
  Then use `./node_modules/opencode-fs-plugin` in `plugins` and
@@ -415,18 +485,25 @@ The skill ID is `filesystem`; `@filesystem` loads it explicitly.
415
485
  ## Permissions
416
486
 
417
487
  Every tool asserts an action named after the tool (`fs_cp`, `fs_rm`,
418
- `fs_pipe` stages, and so on), except `fs.http_request`, which reuses the
488
+ `fs_pipe` stages, and so on), except `fs.curl`, which reuses the
419
489
  built-in `webfetch` action. Internal paths use project-relative resources;
420
- external targets first require `external_directory` on the absolute boundary.
421
- `allow always` persists the same patterns as the built-in tools.
422
-
423
- `fs.exec` asserts `fs_exec` for the run, then asks `external_directory` for any
424
- blocked path and `fs_exec_network` for a refused host (the resource is the host,
425
- or `*` in ip mode) before retrying:
490
+ external targets first require `external_directory` on the absolute boundary,
491
+ computed from the canonical target rather than the symlink path.
492
+ `allow always` saves the exact resources the call asserted — project-relative
493
+ paths, absolute external boundaries, or network names/addresses. A specific
494
+ resource saves narrowly; an explicitly requested `*` remains `*`.
495
+
496
+ `fs.command` asserts `fs_command` with the executable name, asks
497
+ `external_directory` for any blocked path, and asks `fs_exec_network` for the
498
+ exact DNS name or IP address the transparent relay named. There is no `*`
499
+ fallback and no direct-IP mode; networking that cannot use the relay is
500
+ disabled:
426
501
 
427
502
  ```jsonc
428
503
  {
429
504
  "permissions": [
505
+ { "action": "fs_command", "resource": "*", "effect": "deny" },
506
+ { "action": "fs_command", "resource": "npm", "effect": "allow" },
430
507
  { "action": "external_directory", "resource": "$HOME/.npm/**", "effect": "ask" },
431
508
  { "action": "fs_exec_network", "resource": "*", "effect": "deny" },
432
509
  { "action": "fs_exec_network", "resource": "registry.npmjs.org", "effect": "allow" }
@@ -434,12 +511,12 @@ or `*` in ip mode) before retrying:
434
511
  }
435
512
  ```
436
513
 
437
- Keep both rules explicit. Plugin actions match OpenCode's base
514
+ Keep the rules explicit. Plugin actions match OpenCode's base
438
515
  `{ "action": "*", "resource": "*", "effect": "allow" }` rule, so an unlisted
439
- `fs_exec_network` or `external_directory` resource is allowed without a prompt,
440
- not asked.
516
+ `fs_command`, `fs_exec_network`, or `external_directory` resource is allowed
517
+ without a prompt, not asked.
441
518
 
442
- `fs.http_request` reuses the built-in `webfetch` permission, with the requested
519
+ `fs.curl` reuses the built-in `webfetch` permission, with the requested
443
520
  URL as the resource, so one rule set covers both tools:
444
521
 
445
522
  ```jsonc
@@ -481,18 +558,77 @@ when only some agents should be shell-free.
481
558
 
482
559
  - The sandbox root, its ancestors, `/`, `$HOME` and core system directories are
483
560
  hard stops for destructive operations.
484
- - Paths are resolved with symlink awareness. Traversing a link that escapes the
485
- project requires `external_directory`; removing or renaming the link itself is
486
- internal.
487
- - Archive extraction rejects absolute paths, `..`, and escaping symlinks.
488
- - `http_request` accepts only `http:` and `https:`, keeps TLS verification on,
489
- re-checks permissions on redirect hops, and writes downloads to a temporary
490
- file before renaming. Localhost and private addresses are not blocked by
491
- default.
561
+ - Paths resolve to their canonical target before a permission is asserted, so a
562
+ symlink that escapes the project asks `external_directory` for the real
563
+ location; removing or renaming the link itself stays internal. Single-file
564
+ output tools (archives, `gzip`, `tee`, `split`, `dd`, `pipe`) open the resolved
565
+ final component with `O_NOFOLLOW`, so a link swapped in after the check fails
566
+ instead of being followed; `cp` refuses an existing symlink at a nested entry
567
+ but its final copy call is not no-follow. Node has no `openat`, so a
568
+ concurrently swapped parent directory remains a TOCTOU gap.
569
+ - `cp` follows a top-level destination symlink to its canonical target and gates
570
+ that path. Inside a recursive copy it refuses to write through an existing
571
+ symlink (directory or file) and fails closed; a copied symlink replaces the
572
+ destination link itself. A source/destination hard-link alias is rejected.
573
+ - `mv` refuses to move a directory into itself. A cross-device move (EXDEV)
574
+ refuses a destination symlink, copies with `preserve`, and removes the source
575
+ only after every entry was copied. If nothing was copied or a
576
+ `noClobber`/`update` entry was skipped, it reports `cross-device` and preserves
577
+ the source; the partially populated destination is left in place.
578
+ - `chown` refuses the sandbox root, its ancestors, `/`, `$HOME`, and core system
579
+ directories before asserting permission or changing ownership; recursive chown
580
+ skips traversal symlinks. With `noDereference` it resolves the parent chain to
581
+ its canonical directory but leaves the final component, so a parent symlink is
582
+ gated at its real location and `lchown` changes a final symlink itself.
583
+ - Archive create writes its output through the same no-follow final open.
584
+ Extraction first plans every member: destinations are resolved in their
585
+ canonical parents, an existing final symlink is refused, and one bulk
586
+ permission check covers all targets before anything is written, so a denial
587
+ writes no archive members. A symlink member is refused over any existing
588
+ destination, and absolute names, `..`, and absolute or traversing link targets
589
+ are rejected. Extracted file modes apply the process umask and strip
590
+ setuid/setgid; directory modes also preserve the sticky bit. ZIP entries with
591
+ no Unix mode default to `0644` files and `0755` directories before the umask.
592
+ Directory modes are deduplicated by canonical target (last entry wins) and
593
+ applied deepest-first. Ordinary file and directory mode changes use opened
594
+ `O_NOFOLLOW` handles; an `EACCES` fallback for an unreadable existing
595
+ directory uses a guarded pathname `chmod`, keeping a final-component TOCTOU
596
+ race. Parent-component races remain. An abort before an archive create write
597
+ leaves no archive file. A parent directory swapped after planning can still redirect a
598
+ write, an existing destination hardlink can be written through, and an OS
599
+ error or abort can leave earlier members or a truncated file. Archive create
600
+ and extraction buffer the whole archive (extraction also buffers each member)
601
+ in memory and have no global archive-size cap, so large archives can consume
602
+ substantial memory.
603
+ - `tar` and `cpio` create resolve relative `paths` under `directory`; absolute
604
+ sources are named relative to `directory` first, then the project, and fall
605
+ back to the basename (a traversing source uses its basename). `tar`/`zip` store
606
+ files, directories, and symlinks (no hardlinks, devices, ACLs, or xattrs);
607
+ `cpio` is newc with GNU 4-byte padding, and its decoder also accepts the prior
608
+ 3.x plugin padding; strict decode rejects nonzero data after the trailer
609
+ (concatenated archives). `cpio` fields must fit 0..0xffffffff; `ar` uses 16-byte
610
+ GNU short names.
611
+ - `split` checks suffix capacity before writing: alphabetic suffixes cover
612
+ `26^suffixLength` chunks and `numeric` covers `10^suffixLength`; more chunks
613
+ fail with `invalid`.
614
+ - `curl` accepts only `http:` and `https:`, keeps TLS verification on, and
615
+ re-checks permissions on every redirect hop. A same-origin redirect keeps the
616
+ request. A cross-origin redirect is refused unless it is a bodyless `GET` or
617
+ `HEAD` whose caller headers are all in the safe set (`accept`,
618
+ `accept-language`, `cache-control`, `pragma`, `range`, `user-agent`);
619
+ credentials, custom headers, other methods, a request body, and embedded URL
620
+ credentials are refused, not stripped. A 303 rewrites `POST` to a bodyless
621
+ `GET` before that policy, so a safe resulting GET may cross origins; 301/302
622
+ rewrite `POST` after the policy, and 307/308 keep the method and body. An
623
+ HTTPS to HTTP redirect is always refused. For `output`, the resolved file's
624
+ containing directory is the permission boundary, so an external destination
625
+ asks `external_directory` for that directory. Downloads stream to a temporary
626
+ file and are renamed only after the body and checksum complete. Localhost and
627
+ private addresses are not blocked by default.
492
628
  - `rm` is permanent. `trash` uses the XDG home trash and refuses cross-device
493
629
  moves instead of silently copying.
494
- - The sandbox is a guardrail, not a kernel security boundary. Symlink races
495
- remain possible.
630
+ - The sandbox is a guardrail, not a kernel security boundary.
631
+ Parent/hardlink races and partial writes remain possible.
496
632
 
497
633
  ## Development
498
634