opencode-fs-plugin 3.4.0 → 3.5.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,22 @@ 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.
131
130
 
132
131
  There is no shell, redirection operator, nested pipe, or arbitrary `find -exec`.
133
132
 
@@ -135,23 +134,34 @@ There is no shell, redirection operator, nested pipe, or arbitrary `find -exec`.
135
134
  work, fan out with `Promise.all` over `tools.fs.*` (or one multi-path call).
136
135
  `fs` domain errors resolve as `ERROR:`/`BLOCKED:` text; permission denials throw.
137
136
 
138
- ## Exec
137
+ ## Command
139
138
 
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:
139
+ `fs.command` runs one executable inside a procage sandbox with
140
+ `shell: false`. It is closest to the shell's `command <prog>`: one program with
141
+ literal argv, not `exec` (which replaces the calling shell) and not `sh -c`
142
+ (which parses shell syntax). The executable allowlist is the `fs_command`
143
+ permission: the tool asserts that action with the bare executable name as its
144
+ resource. Deny `*` to close the set, then allow the names you need:
143
145
 
144
146
  ```jsonc
145
147
  {
146
- "package": "./repos/opencode-fs-plugin",
147
- "options": { "execAllowlist": ["npm", "uv"] }
148
+ "permissions": [
149
+ { "action": "fs_command", "resource": "*", "effect": "deny" },
150
+ { "action": "fs_command", "resource": "npm", "effect": "allow" },
151
+ { "action": "fs_command", "resource": "uv", "effect": "allow" }
152
+ ]
148
153
  }
149
154
  ```
150
155
 
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:
156
+ With no rule the base allow applies to every executable, so keep the `*` deny
157
+ when you want a closed set.
158
+
159
+ The workspace (project) is read/write/exec. **Network egress needs Linux tier
160
+ T1** (user namespaces and TPROXY). Every run gets procage's transparent relay:
161
+ there is no direct route, and every TCP or UDP flow is named to the plugin as a
162
+ DNS QNAME, TLS SNI, HTTP `Host`, QUIC SNI, or an IP literal. That exact resource
163
+ must be approved through `fs_exec_network`; the port, URL, headers, and payload
164
+ are never part of the permission. There is no separate network allowlist option:
155
165
 
156
166
  ```jsonc
157
167
  {
@@ -163,50 +173,85 @@ option; the permission rules are the allowlist:
163
173
  }
164
174
  ```
165
175
 
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.
176
+ A flow asks with its own resource. With no rule (base allow) the request is
177
+ approved silently; with a `*` deny an unlisted resource fails closed. DNS
178
+ queries are flows too: an allowed QNAME is answered through the parent resolver
179
+ (procage reads `/etc/resolv.conf` and systemd-resolved paths, including a
180
+ loopback stub), a denied one gets `REFUSED`, and TCP/853 or a known
181
+ encrypted-DNS endpoint is refused without asking. That DoH filtering is
182
+ best-effort: TCP/853 and the finite list of known DoH names are blocked, but
183
+ custom or unknown DoH endpoints on other names or ports may not be recognized.
184
+ ECH detected in TLS or QUIC is visibly refused. Allowed answers feed a
185
+ bounded per-run address-to-name cache: a later flow that names no host is
186
+ authorized by a fresh allowed name bound to its address, otherwise by the
187
+ address itself. A named flow must either match an allowed DNS answer for the
188
+ exact `(name, address)` pair or have both its name and its address allowed; a
189
+ denied named identity is never rescued by an allowed address. Allow the DNS
190
+ names a program uses. Also allow an address when the program connects to IP
191
+ literals, or when a named flow's name is allowed but that exact
192
+ `(name, address)` was not returned by an allowed DNS answer: only the cached
193
+ pair avoids the separate address check, so that named flow needs both
194
+ permissions.
195
+
196
+ External proxy settings are preserved: `HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`,
197
+ `NO_PROXY`, their lowercase forms, and the npm proxy variables are passed to the
198
+ child explicitly, because they are not in the preset's environment allowlist.
199
+ The relay treats the proxy as the destination, never its `CONNECT` target, so
200
+ an external proxy works only when `fs_exec_network` allows the proxy's address
201
+ (or its cached DNS name, which also needs its DNS query allowed). That approval
202
+ lets the proxy forward to whatever it reaches; it is not scoped to the target
203
+ URL behind the proxy. No other caller environment variable is forwarded
204
+ explicitly, but the preset's own environment allowlist still applies, and a
205
+ proxy variable may itself carry proxy credentials.
206
+
207
+ External paths are separate: a blocked path asks `external_directory` for its
208
+ containing directory (or the nearest existing ancestor), and the sandbox grants
209
+ read/write there. Only procage's structured **write** violations (`file-write-*`)
210
+ can trigger that auto-approval; read, exec, network, or unknown path failures
211
+ never do. When procage reports no write violation, no path grant is inferred and
212
+ access remains denied — pre-grant the path with `external_directory` or a rule.
213
+ A path printed by the child on stdout or stderr is reported, never auto-approved.
172
214
 
173
215
  The decision comes from your `opencode.jsonc` rules (`ask`, `allow`, `deny`), the
174
216
  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
217
+ reports `violations` and a `hint`. `fs.command` also kills every process it started
176
218
  when the run ends, including detached descendants.
177
219
 
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.
220
+ On Linux T2 and on macOS the relay is unavailable, and a relay control server
221
+ that cannot start is treated the same way. `fs.command` retries the same run once
222
+ with networking off: the policy stays `net: "none"`, no resolver sockets are
223
+ granted, and macOS gets no resolver exception. The result carries
224
+ `networkMode: "disabled"` and a `networkReason`; there is no direct-IP fallback. Every flow decision is
225
+ fail-closed: a denial, a closed control link, an oversized or malformed frame,
226
+ a missing HELLO, or a decision timeout refuses the flow. The control socket
227
+ lives in a private per-run directory and is never part of the child's known
228
+ Unix sockets.
187
229
 
188
230
  ```js
189
- await tools.fs.exec({ command: "npm", args: ["install"], timeoutMs: 300000 })
231
+ await tools.fs.command({ command: "npm", args: ["install"], timeoutMs: 300000 })
190
232
  ```
191
233
 
192
234
  `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.
235
+ calls return JSON with `exitCode`, `stdout`, `stderr`, `violations`, and the
236
+ network fields `network`, `networkMode`, `networkHosts`, and `networkReason`
237
+ (when networking was disabled); `externalPaths` lists the external roots the
238
+ run could write to. A pipe stage returns raw stdout so it composes with `grep`,
239
+ `sort`, `tee`, and the rest.
195
240
 
196
241
  ```js
197
242
  await tools.fs.pipe({
198
243
  stages: [
199
- { tool: "exec", args: { command: "npm", args: ["test"] } },
244
+ { tool: "command", args: { command: "npm", args: ["test"] } },
200
245
  { tool: "grep", args: { pattern: "FAIL" } },
201
246
  ],
202
247
  })
203
248
  ```
204
249
 
205
- The command asserts `fs_exec`, returns stdout/stderr in full, and treats a non-zero exit as
250
+ The command asserts `fs_command`, returns stdout/stderr in full, and treats a non-zero exit as
206
251
  a normal result. Procage requires Linux x64/arm64, glibc 2.28+, and Node 22.12+.
207
252
  On kernels before Landlock ABI 6, signal isolation relaxes to same-user. The
208
253
  trust-handoff class is waived so package tools can update workspace files such as
209
- `.git/hooks`; the executable allowlist remains the trust boundary.
254
+ `.git/hooks`; the `fs_command` permission remains the trust boundary.
210
255
 
211
256
  ## Performance and concurrency
212
257
 
@@ -234,8 +279,8 @@ gap; their input/output cost is dominated by the async I/O above.
234
279
 
235
280
  ## Background jobs
236
281
 
237
- Every `fs.*` tool accepts `background: true`. The call returns immediately with
238
- a job id and a status-file path:
282
+ Every tool except `fs.job` accepts `background: true`. The call returns
283
+ immediately with a job id and a status-file path:
239
284
 
240
285
  ```js
241
286
  const started = JSON.parse(
@@ -281,11 +326,12 @@ await tools.wait.for({
281
326
  ```
282
327
 
283
328
  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.
329
+ status files may remain under `/tmp/opencode/fs-jobs/<server-pid>/`; set the
330
+ plugin option `jobDir` to move them. The manager allows 8 concurrent jobs and
331
+ cleans up finished jobs after one hour. Results stay in memory and are returned
332
+ by `fs.job`; the status file contains only the job state and metadata.
333
+ Background permission prompts can appear after the starting call returns, and a
334
+ denied permission fails the job.
289
335
 
290
336
  ## Installing from npm
291
337
 
@@ -293,18 +339,18 @@ Add the registry package directly to the plugin list:
293
339
 
294
340
  ```jsonc
295
341
  {
296
- "plugins": ["opencode-fs-plugin@3.0.0"]
342
+ "plugins": ["opencode-fs-plugin@<version>"]
297
343
  }
298
344
  ```
299
345
 
300
- `opencode plugin add opencode-fs-plugin@3.0.0` installs it and writes the config
346
+ `opencode plugin add opencode-fs-plugin@<version>` installs it and writes the config
301
347
  entry. A bare `opencode-fs-plugin` follows the `latest` tag.
302
348
 
303
349
  OpenCode manages the package under its cache, so the path is not stable. If you
304
350
  also want the packaged skill, install it into a project instead:
305
351
 
306
352
  ```bash
307
- npm install opencode-fs-plugin@3.0.0
353
+ npm install opencode-fs-plugin@<version>
308
354
  ```
309
355
 
310
356
  ```jsonc
@@ -319,7 +365,7 @@ npm install opencode-fs-plugin@3.0.0
319
365
  Download the release tarball, then install it as a normal npm package:
320
366
 
321
367
  ```bash
322
- VERSION=3.0.0
368
+ VERSION=<version>
323
369
  curl -L -o "opencode-fs-plugin-${VERSION}.tgz" \
324
370
  "https://github.com/masterjg/opencode-fs-plugin/releases/download/v${VERSION}/opencode-fs-plugin-${VERSION}.tgz"
325
371
  npm install "./opencode-fs-plugin-${VERSION}.tgz"
@@ -348,20 +394,20 @@ OpenCode installs it from Git:
348
394
 
349
395
  ```jsonc
350
396
  {
351
- "plugins": ["github:masterjg/opencode-fs-plugin#v3.0.0"]
397
+ "plugins": ["github:masterjg/opencode-fs-plugin#v<version>"]
352
398
  }
353
399
  ```
354
400
 
355
- `opencode plugin add 'github:masterjg/opencode-fs-plugin#v3.0.0'` installs the
401
+ `opencode plugin add 'github:masterjg/opencode-fs-plugin#v<version>'` installs the
356
402
  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
403
+ `git+https://github.com/masterjg/opencode-fs-plugin.git#v<version>`. A tag is
358
404
  checked for updates; use a full commit hash to pin it.
359
405
 
360
406
  Git plugins are installed under OpenCode's cache, so their package path is not
361
407
  stable. If you also want the packaged skill, install with npm instead:
362
408
 
363
409
  ```bash
364
- npm install "github:masterjg/opencode-fs-plugin#v3.0.0"
410
+ npm install "github:masterjg/opencode-fs-plugin#v<version>"
365
411
  ```
366
412
 
367
413
  Then use `./node_modules/opencode-fs-plugin` in `plugins` and
@@ -415,18 +461,24 @@ The skill ID is `filesystem`; `@filesystem` loads it explicitly.
415
461
  ## Permissions
416
462
 
417
463
  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
464
+ `fs_pipe` stages, and so on), except `fs.curl`, which reuses the
419
465
  built-in `webfetch` action. Internal paths use project-relative resources;
420
466
  external targets first require `external_directory` on the absolute boundary.
421
- `allow always` persists the same patterns as the built-in tools.
467
+ `allow always` saves the exact resources the call asserted — project-relative
468
+ paths, absolute external boundaries, or network names/addresses. A specific
469
+ resource saves narrowly; an explicitly requested `*` remains `*`.
422
470
 
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:
471
+ `fs.command` asserts `fs_command` with the executable name, asks
472
+ `external_directory` for any blocked path, and asks `fs_exec_network` for the
473
+ exact DNS name or IP address the transparent relay named. There is no `*`
474
+ fallback and no direct-IP mode; networking that cannot use the relay is
475
+ disabled:
426
476
 
427
477
  ```jsonc
428
478
  {
429
479
  "permissions": [
480
+ { "action": "fs_command", "resource": "*", "effect": "deny" },
481
+ { "action": "fs_command", "resource": "npm", "effect": "allow" },
430
482
  { "action": "external_directory", "resource": "$HOME/.npm/**", "effect": "ask" },
431
483
  { "action": "fs_exec_network", "resource": "*", "effect": "deny" },
432
484
  { "action": "fs_exec_network", "resource": "registry.npmjs.org", "effect": "allow" }
@@ -434,12 +486,12 @@ or `*` in ip mode) before retrying:
434
486
  }
435
487
  ```
436
488
 
437
- Keep both rules explicit. Plugin actions match OpenCode's base
489
+ Keep the rules explicit. Plugin actions match OpenCode's base
438
490
  `{ "action": "*", "resource": "*", "effect": "allow" }` rule, so an unlisted
439
- `fs_exec_network` or `external_directory` resource is allowed without a prompt,
440
- not asked.
491
+ `fs_command`, `fs_exec_network`, or `external_directory` resource is allowed
492
+ without a prompt, not asked.
441
493
 
442
- `fs.http_request` reuses the built-in `webfetch` permission, with the requested
494
+ `fs.curl` reuses the built-in `webfetch` permission, with the requested
443
495
  URL as the resource, so one rule set covers both tools:
444
496
 
445
497
  ```jsonc
@@ -485,7 +537,7 @@ when only some agents should be shell-free.
485
537
  project requires `external_directory`; removing or renaming the link itself is
486
538
  internal.
487
539
  - Archive extraction rejects absolute paths, `..`, and escaping symlinks.
488
- - `http_request` accepts only `http:` and `https:`, keeps TLS verification on,
540
+ - `curl` accepts only `http:` and `https:`, keeps TLS verification on,
489
541
  re-checks permissions on redirect hops, and writes downloads to a temporary
490
542
  file before renaming. Localhost and private addresses are not blocked by
491
543
  default.
package/SPEC.md CHANGED
@@ -65,11 +65,11 @@ Aliases are accepted only where noted: `path` for one `paths` element (`stat`,
65
65
 
66
66
  ## HTTP requests
67
67
 
68
- - `fs.http_request` supports `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, and `HEAD`
68
+ - `fs.curl` supports `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, and `HEAD`
69
69
  over `http:`/`https:` only; other schemes fail with `unsupported`.
70
- - Requests are allowed by default. `fs.http_request` asserts the built-in
70
+ - Requests are allowed by default. `fs.curl` asserts the built-in
71
71
  `webfetch` action with the requested URL as the resource; there is no separate
72
- `fs_http_request` action. Every redirect hop re-asserts it for the new URL.
72
+ `fs_curl` action. Every redirect hop re-asserts it for the new URL.
73
73
  - Redirects are followed manually: 301/302 rewrite `POST` to `GET`, 303 always
74
74
  does, and the hop count is bounded by `maxRedirects`.
75
75
  - `output` streams the response to a temporary file in the target directory and
@@ -81,36 +81,66 @@ Aliases are accepted only where noted: `path` for one `paths` element (`stat`,
81
81
 
82
82
  ## Process execution
83
83
 
84
- - `fs.exec` is the only tool that starts processes, through `procage`; it never
84
+ - `fs.command` is the only tool that starts processes, through `procage`; it never
85
85
  uses `child_process`, `spawn`, or a shell.
86
- - `command` must be a bare executable name and must match the allowlist exactly.
87
- Default: `npm`, `npx`, `uv`, `uvx`, `pip`, `pip3`. Override with the plugin
88
- option `execAllowlist`; an empty list disables execution.
86
+ - `command` must be a bare executable name. The executable allowlist is the
87
+ `fs_command` permission: the tool asserts that action with the bare name as its
88
+ resource. With no rule the base allow applies to every executable; a `*` deny
89
+ plus name allows closes the set.
89
90
  - The policy is procage `agent_workspace` v3: the project is read/write/exec.
90
- Network is proxy-only and external paths are denied by default; there are no
91
- per-call grants.
92
- - Network is proxy-only by default: the cage gets a procage proxy whose
93
- allowlist is the hosts approved through `fs_exec_network` in this run. A
94
- refused host asks with the host as the resource, then the run retries with it
95
- added. The permission rules are the only allowlist; there is no plugin option
96
- for it.
97
- - `execNetworkMode: "ip"` opts into all-IP networking after `fs_exec_network`
98
- approval. In `ip` mode the policy also opens the resolver sockets used by
99
- systemd-resolved, nscd, and SSSD. Plain UDP DNS needs none; other Unix
100
- sockets stay blocked. Landlock ignores paths absent on the host. On T2 below
101
- Landlock ABI 9 the sockets cannot be scoped, so `no-unix-sockets` drops them
102
- and only UDP DNS remains.
103
- - Proxy mode needs Linux T1 or macOS. On T2 the cage fails with the `net-proxy`
104
- gap; `fs.exec` retries in `ip` mode and asks on a socket denial.
91
+ External paths are denied by default and there are no per-call grants.
92
+ - Network egress uses procage's transparent relay on Linux tier T1. A per-run
93
+ `AF_UNIX` control server in a 0700 directory accepts exactly one connection,
94
+ validates HELLO against the run id, and multiplexes at most 64 decisions over
95
+ the length-prefixed protocol in `src/core/relay-protocol.ts`.
96
+ - Every TCP/UDP flow is named as a DNS QNAME, TLS SNI, HTTP `Host`, QUIC SNI, or
97
+ IP literal. That exact resource is asserted with `fs_exec_network`; the port,
98
+ protocol, URL, headers, and payload never reach the permission. The permission
99
+ rules are the only network allowlist; there is no plugin option for it.
100
+ - DNS queries are decisions too. An allowed QNAME is forwarded to the parent
101
+ resolver; procage's discovery reads `/etc/resolv.conf` and systemd-resolved
102
+ paths, including a loopback stub, and the plugin leaves `relay_dns_upstream`
103
+ and `relay_resolv_conf` unset. A denied QNAME gets `REFUSED`. An allowed
104
+ answer feeds procage's bounded per-run address-to-name cache. A nameless flow
105
+ to an address is authorized by a fresh allowed name bound to it, else by the
106
+ address. A named flow requires the exact `(name, address)` from an allowed
107
+ answer plus the allowed name, or both name and address explicitly allowed; a
108
+ denied named identity is never rescued by an allowed address. Allow an address
109
+ in addition to the name when a program connects to an IP literal, or when a
110
+ named flow's exact `(name, address)` was not returned by an allowed DNS
111
+ answer. TCP/853 and the finite list of known DoH names are refused without
112
+ asking; custom or unknown DoH endpoints on other names or ports may not be
113
+ recognized, so DoH blocking is best-effort. ECH detected in TLS or QUIC is
114
+ visibly refused.
115
+ - Denials, a closed control link, a failed handshake, an oversized or malformed
116
+ frame, an exhausted in-flight window, and a decision timeout all refuse the
117
+ flow. Completed decision ids are retained in a bounded 1024-entry window so a
118
+ replay is rejected without unbounded memory. There is no direct-route
119
+ fallback.
120
+ - On Linux T2 and macOS procage reports the `net-relay` gap; a relay control
121
+ server that cannot start is treated the same way. The run retries once with
122
+ networking off (`net: "none"`), no resolver sockets, and no macOS resolver
123
+ exception, and reports `networkMode: "disabled"` plus `networkReason`.
124
+ - External proxy variables (`HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`,
125
+ `NO_PROXY`, lowercase forms, and npm proxy variables) are passed explicitly
126
+ because they are not in the preset environment allowlist. The relay treats
127
+ the proxy as the destination, never its `CONNECT` target, so the proxy's
128
+ address or cached DNS name must be allowed in `fs_exec_network`. No other
129
+ caller environment variable is forwarded explicitly; the preset's own
130
+ allowlist still applies, and a proxy variable may itself carry credentials.
105
131
  - Denied paths ask `external_directory` on their containing directory (or the
106
- nearest existing ancestor for a missing or redacted path). Access handling is
107
- bounded to twelve attempts.
132
+ nearest existing ancestor for a missing or redacted path) only when procage
133
+ reports a structured **write** violation (`file-write-*`). Read, exec,
134
+ network, and unknown operations never add a write rule; without a write
135
+ violation no path grant is inferred and access stays denied — pre-grant the
136
+ path or configure a rule. Child stdout/stderr is never parsed for paths.
137
+ Access handling is bounded to twelve attempts.
108
138
  - If a path or socket stays blocked after approval, the result reports
109
139
  `violations` plus a `hint`; stderr containing EACCES/EPERM/EROFS marks
110
- `sandboxBlocked`. Results carry `network`, `networkMode`, `networkHosts`, and
111
- `externalPaths`.
140
+ `sandboxBlocked`. Results carry `network`, `networkMode`, `networkHosts`,
141
+ `networkReason` when the relay was unavailable, and `externalPaths`.
112
142
  - `args` are passed verbatim. `cwd` resolves inside the sandbox and asserts
113
- `external_directory` when it leaves the project; the action is `fs_exec`.
143
+ `external_directory` when it leaves the project; the action is `fs_command`.
114
144
  - Timeout defaults to 120000 ms, capped at 600000. Procage ends the run and kills
115
145
  every process it started, including detached descendants; `timedOut: true`
116
146
  and exit code 124 are returned.
@@ -119,21 +149,12 @@ Aliases are accepted only where noted: `path` for one `paths` element (`stat`,
119
149
  the sandbox decision. In `fs.pipe`, the stage returns raw stdout and composes as
120
150
  a source or filter.
121
151
  - A non-zero exit is a normal result, not a tool error.
122
- - `procage` is lazy-loaded; if the host cannot load it, `fs.exec` fails with
152
+ - `procage` is lazy-loaded; if the host cannot load it, `fs.command` fails with
123
153
  `unsupported` while the other fs tools continue to work. Requires Linux
124
154
  x64/arm64, glibc 2.28+, and Node 22.12+. On kernels before Landlock ABI 6,
125
155
  signals are relaxed from self-and-children to same-user, as procage requires.
126
156
  The trust-handoff class is waived so package tools can update workspace files
127
- such as `.git/hooks`; the executable allowlist remains the trust boundary.
128
-
129
- ## Large output
130
-
131
- A direct tool result larger than the spill threshold is written to
132
- `/tmp/opencode/fs-spill/<tool>-<uuid>.out`. The threshold is a quarter of free
133
- memory, clamped to 16 MiB..512 MiB, or the `spillThresholdBytes` plugin option.
134
- The tool returns a 64 KiB preview, `outputPath`, `bytes`, and `spilled: true`,
135
- and `renderResult` appends a note with the path. `fs.cat` streams into the sink;
136
- other tools spill their finished result. Pipe stages stay in memory.
157
+ such as `.git/hooks`; the `fs_command` permission remains the trust boundary.
137
158
 
138
159
  ## Deliberate gaps
139
160
 
@@ -151,10 +172,10 @@ These are not implemented:
151
172
  - cross-filesystem `trash`; use `rm` or a mount-trash helper
152
173
  - curl protocols beyond HTTP(S), cookie jars, client certificates, proxies,
153
174
  multipart uploads, and resumable/range downloads
154
- - true streaming through pipe stages; `http_request` buffers unless `output` is set
175
+ - true streaming through pipe stages; `curl` buffers unless `output` is set
155
176
  - worker threads for CPU-bound stages (`sort`, `sed`, text diffing)
156
177
  - parallel member reads inside a single `tar`/`zip` archive; member order is fixed
157
- - process start beyond the allowlisted `exec` tool; `nohup`, `setsid`, and
178
+ - process start beyond the permission-gated `command` tool; `nohup`, `setsid`, and
158
179
  `timeout` wrappers are unavailable
159
180
  - ICMP `ping` (raw sockets) and `ip`/netlink configuration
160
181
  - `rsync`, `scp`, and other transfer protocols; use the SSH MCP for remote work