opencode-fs-plugin 2.0.0 → 3.0.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
@@ -89,7 +89,9 @@ Prefer the canonical names.
89
89
  ## Pipe
90
90
 
91
91
  `fs.pipe` joins registered tools through byte buffers. Stages run in order;
92
- only pipeable tools can be used. `output` and `append` behave like a final
92
+ only pipeable tools can be used. Each stage asserts its own `fs_<tool>` action
93
+ before it runs, so a disabled stage cannot be hidden inside a pipe. `output` and
94
+ `append` behave like a final
93
95
  `tee`.
94
96
 
95
97
  ```js
@@ -284,18 +286,18 @@ Add the registry package directly to the plugin list:
284
286
 
285
287
  ```jsonc
286
288
  {
287
- "plugins": ["opencode-fs-plugin@2.0.0"]
289
+ "plugins": ["opencode-fs-plugin@3.0.0"]
288
290
  }
289
291
  ```
290
292
 
291
- `opencode plugin add opencode-fs-plugin@2.0.0` installs it and writes the config
293
+ `opencode plugin add opencode-fs-plugin@3.0.0` installs it and writes the config
292
294
  entry. A bare `opencode-fs-plugin` follows the `latest` tag.
293
295
 
294
296
  OpenCode manages the package under its cache, so the path is not stable. If you
295
297
  also want the packaged skill, install it into a project instead:
296
298
 
297
299
  ```bash
298
- npm install opencode-fs-plugin@2.0.0
300
+ npm install opencode-fs-plugin@3.0.0
299
301
  ```
300
302
 
301
303
  ```jsonc
@@ -310,7 +312,7 @@ npm install opencode-fs-plugin@2.0.0
310
312
  Download the release tarball, then install it as a normal npm package:
311
313
 
312
314
  ```bash
313
- VERSION=2.0.0
315
+ VERSION=3.0.0
314
316
  curl -L -o "opencode-fs-plugin-${VERSION}.tgz" \
315
317
  "https://github.com/masterjg/opencode-fs-plugin/releases/download/v${VERSION}/opencode-fs-plugin-${VERSION}.tgz"
316
318
  npm install "./opencode-fs-plugin-${VERSION}.tgz"
@@ -339,20 +341,20 @@ OpenCode installs it from Git:
339
341
 
340
342
  ```jsonc
341
343
  {
342
- "plugins": ["github:masterjg/opencode-fs-plugin#v2.0.0"]
344
+ "plugins": ["github:masterjg/opencode-fs-plugin#v3.0.0"]
343
345
  }
344
346
  ```
345
347
 
346
- `opencode plugin add 'github:masterjg/opencode-fs-plugin#v2.0.0'` installs the
348
+ `opencode plugin add 'github:masterjg/opencode-fs-plugin#v3.0.0'` installs the
347
349
  same spec and writes the config entry. The equivalent full URL is
348
- `git+https://github.com/masterjg/opencode-fs-plugin.git#v2.0.0`. A tag is
350
+ `git+https://github.com/masterjg/opencode-fs-plugin.git#v3.0.0`. A tag is
349
351
  checked for updates; use a full commit hash to pin it.
350
352
 
351
353
  Git plugins are installed under OpenCode's cache, so their package path is not
352
354
  stable. If you also want the packaged skill, install with npm instead:
353
355
 
354
356
  ```bash
355
- npm install "github:masterjg/opencode-fs-plugin#v2.0.0"
357
+ npm install "github:masterjg/opencode-fs-plugin#v3.0.0"
356
358
  ```
357
359
 
358
360
  Then use `./node_modules/opencode-fs-plugin` in `plugins` and
@@ -406,7 +408,8 @@ The skill ID is `filesystem`; `@filesystem` loads it explicitly.
406
408
  ## Permissions
407
409
 
408
410
  Every tool asserts an action named after the tool (`fs_cp`, `fs_rm`,
409
- `fs_pipe` stages, and so on). Internal paths use project-relative resources;
411
+ `fs_pipe` stages, and so on), except `fs.http_request`, which reuses the
412
+ built-in `webfetch` action. Internal paths use project-relative resources;
410
413
  external targets first require `external_directory` on the absolute boundary.
411
414
  `allow always` persists the same patterns as the built-in tools.
412
415
 
@@ -429,19 +432,19 @@ Keep both rules explicit. Plugin actions match OpenCode's base
429
432
  `fs_exec_network` or `external_directory` resource is allowed without a prompt,
430
433
  not asked.
431
434
 
432
- `fs.http_request` is allowed by default, like `fetch`. Its resource is the
433
- request host (`example.com:8443`), so requests can be restricted per host:
435
+ `fs.http_request` reuses the built-in `webfetch` permission, with the requested
436
+ URL as the resource, so one rule set covers both tools:
434
437
 
435
438
  ```jsonc
436
439
  {
437
440
  "permissions": [
438
- { "action": "fs_http_request", "resource": "api.github.com", "effect": "allow" },
439
- { "action": "fs_http_request", "resource": "*", "effect": "ask" }
441
+ { "action": "webfetch", "resource": "*", "effect": "deny" },
442
+ { "action": "webfetch", "resource": "https://api.github.com/*", "effect": "allow" }
440
443
  ]
441
444
  }
442
445
  ```
443
446
 
444
- Redirects re-assert the rule against each new host.
447
+ Redirects re-assert the rule against each new URL.
445
448
 
446
449
  Agent rules can use wildcards:
447
450
 
package/SPEC.md CHANGED
@@ -67,8 +67,9 @@ Aliases are accepted only where noted: `path` for one `paths` element (`stat`,
67
67
 
68
68
  - `fs.http_request` 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. The permission resource is the request host,
71
- and every redirect hop re-asserts `fs_http_request` for the new host.
70
+ - Requests are allowed by default. `fs.http_request` asserts the built-in
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
73
  - Redirects are followed manually: 301/302 rewrite `POST` to `GET`, 303 always
73
74
  does, and the hop count is bounded by `maxRedirects`.
74
75
  - `output` streams the response to a temporary file in the target directory and
@@ -168,7 +169,9 @@ These are not implemented:
168
169
  - `sort -k` accepts field/character ranges with modifiers `bdfghiMnrV`.
169
170
  - `tar`/`zip` extraction rejects path traversal and escaping links.
170
171
  - `pipe` passes raw bytes and only accepts registered pipeable stages; `tar` and
171
- `zip` are sink stages. It is sequential and not a batch primitive: independent
172
+ `zip` are sink stages. Each stage asserts its own `fs_<tool>` action before it
173
+ runs, so per-tool denial also applies inside a pipe. It is sequential and not a
174
+ batch primitive: independent
172
175
  calls fan out with `Promise.all` in `execute`.
173
176
 
174
177
  ## Coverage policy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-fs-plugin",
3
- "version": "2.0.0",
3
+ "version": "3.0.1",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=22.12"
@@ -482,10 +482,9 @@ hidden inside a pipeline. Do not work around a denied tool with shell.
482
482
  `fs_exec_network` with the refused host (or `*` in `ip` mode), then retries.
483
483
  There are no per-call grants and no shell.
484
484
 
485
- `fs_http_request` is allowed by default, like `fetch`. Its resource is the
486
- request host; rules can allow one host and ask or deny the rest. Each redirect
487
- hop is checked against the new host. Nothing blocks localhost or private
488
- addresses by default.
485
+ `fs_http_request` reuses the built-in `webfetch` permission with the requested
486
+ URL as the resource, so one rule set covers both; each redirect hop is checked
487
+ against its URL. Nothing blocks localhost or private addresses by default.
489
488
 
490
489
  ## Errors and output
491
490
 
@@ -194,13 +194,13 @@ async function request(
194
194
  url: URL,
195
195
  options: RequestOptions,
196
196
  ): Promise<{ response: Response; finalUrl: string }> {
197
- const gate = ctx.permissionFor("fs_http_request");
197
+ const gate = ctx.permissionFor("webfetch");
198
198
  let current = url;
199
199
  let method = options.method;
200
200
  let body = options.body;
201
201
 
202
202
  for (let redirects = 0; ; redirects++) {
203
- await gate.assertTrusted([current.host]);
203
+ await gate.assertTrusted([current.toString()]);
204
204
  const response = await fetch(current, {
205
205
  method,
206
206
  headers: options.headers,
package/src/tools/pipe.ts CHANGED
@@ -91,6 +91,7 @@ export const pipeTool: ToolSpec<Input> = {
91
91
  }
92
92
  const parsed = parseSchema(tool.schema, stage.args ?? {}, `${stage.tool} arguments`);
93
93
  const gate = ctx.permissionFor(`fs_${tool.name}`);
94
+ await gate.assertTrusted([]);
94
95
  const result = await tool.run(
95
96
  { ...ctx, permission: gate },
96
97
  parsed,