opencode-fs-plugin 1.1.0 → 1.1.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/INSTALL.md CHANGED
@@ -17,14 +17,14 @@ Add the registry package to the plugin list:
17
17
 
18
18
  ```jsonc
19
19
  {
20
- "plugins": ["opencode-fs-plugin@1.1.0"]
20
+ "plugins": ["opencode-fs-plugin@1.1.1"]
21
21
  }
22
22
  ```
23
23
 
24
24
  Or let the CLI install and configure it:
25
25
 
26
26
  ```bash
27
- opencode plugin add opencode-fs-plugin@1.1.0
27
+ opencode plugin add opencode-fs-plugin@1.1.1
28
28
  ```
29
29
 
30
30
  A bare `opencode-fs-plugin` follows `latest`. OpenCode installs it into its
@@ -36,7 +36,7 @@ Option A if you also want the skill.
36
36
  Download the release artifact and install it as a normal npm package:
37
37
 
38
38
  ```bash
39
- VERSION=1.1.0
39
+ VERSION=1.1.1
40
40
  curl -L -o "opencode-fs-plugin-${VERSION}.tgz" \
41
41
  "https://github.com/masterjg/opencode-fs-plugin/releases/download/v${VERSION}/opencode-fs-plugin-${VERSION}.tgz"
42
42
  npm install "./opencode-fs-plugin-${VERSION}.tgz"
@@ -64,20 +64,20 @@ OpenCode installs it from Git:
64
64
 
65
65
  ```jsonc
66
66
  {
67
- "plugins": ["github:masterjg/opencode-fs-plugin#v1.1.0"]
67
+ "plugins": ["github:masterjg/opencode-fs-plugin#v1.1.1"]
68
68
  }
69
69
  ```
70
70
 
71
- `opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.1.0'` installs the
71
+ `opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.1.1'` installs the
72
72
  same spec and writes the entry for you. The equivalent full URL is
73
- `git+https://github.com/masterjg/opencode-fs-plugin.git#v1.1.0`. A tag is
73
+ `git+https://github.com/masterjg/opencode-fs-plugin.git#v1.1.1`. A tag is
74
74
  checked for updates; use a full commit hash to pin it.
75
75
 
76
76
  Git plugins are installed under OpenCode's cache, so their package path is not
77
77
  stable. For a stable skill path, install the tag with npm instead:
78
78
 
79
79
  ```bash
80
- npm install "github:masterjg/opencode-fs-plugin#v1.1.0"
80
+ npm install "github:masterjg/opencode-fs-plugin#v1.1.1"
81
81
  ```
82
82
 
83
83
  Then configure `./node_modules/opencode-fs-plugin` in `plugins` as in the
@@ -174,9 +174,9 @@ and description until the model loads it.
174
174
  To let a coding agent install the plugin, use:
175
175
 
176
176
  ```text
177
- Install opencode-fs-plugin 1.1.0 with "npm install opencode-fs-plugin@1.1.0",
177
+ Install opencode-fs-plugin 1.1.1 with "npm install opencode-fs-plugin@1.1.1",
178
178
  or from its release tarball or the Git tag
179
- "github:masterjg/opencode-fs-plugin#v1.1.0". Add
179
+ "github:masterjg/opencode-fs-plugin#v1.1.1". Add
180
180
  "./node_modules/opencode-fs-plugin" to the plugins array in opencode.jsonc, add
181
181
  "./node_modules/opencode-fs-plugin/skills" to the skills array, then verify that
182
182
  the filesystem skill loads with the skill tool using id "filesystem".
package/README.md CHANGED
@@ -127,18 +127,18 @@ Add the registry package directly to the plugin list:
127
127
 
128
128
  ```jsonc
129
129
  {
130
- "plugins": ["opencode-fs-plugin@1.1.0"]
130
+ "plugins": ["opencode-fs-plugin@1.1.1"]
131
131
  }
132
132
  ```
133
133
 
134
- `opencode plugin add opencode-fs-plugin@1.1.0` installs it and writes the config
134
+ `opencode plugin add opencode-fs-plugin@1.1.1` installs it and writes the config
135
135
  entry. A bare `opencode-fs-plugin` follows the `latest` tag.
136
136
 
137
137
  OpenCode manages the package under its cache, so the path is not stable. If you
138
138
  also want the packaged skill, install it into a project instead:
139
139
 
140
140
  ```bash
141
- npm install opencode-fs-plugin@1.1.0
141
+ npm install opencode-fs-plugin@1.1.1
142
142
  ```
143
143
 
144
144
  ```jsonc
@@ -153,7 +153,7 @@ npm install opencode-fs-plugin@1.1.0
153
153
  Download the release tarball, then install it as a normal npm package:
154
154
 
155
155
  ```bash
156
- VERSION=1.1.0
156
+ VERSION=1.1.1
157
157
  curl -L -o "opencode-fs-plugin-${VERSION}.tgz" \
158
158
  "https://github.com/masterjg/opencode-fs-plugin/releases/download/v${VERSION}/opencode-fs-plugin-${VERSION}.tgz"
159
159
  npm install "./opencode-fs-plugin-${VERSION}.tgz"
@@ -182,20 +182,20 @@ OpenCode installs it from Git:
182
182
 
183
183
  ```jsonc
184
184
  {
185
- "plugins": ["github:masterjg/opencode-fs-plugin#v1.1.0"]
185
+ "plugins": ["github:masterjg/opencode-fs-plugin#v1.1.1"]
186
186
  }
187
187
  ```
188
188
 
189
- `opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.1.0'` installs the
189
+ `opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.1.1'` installs the
190
190
  same spec and writes the config entry. The equivalent full URL is
191
- `git+https://github.com/masterjg/opencode-fs-plugin.git#v1.1.0`. A tag is
191
+ `git+https://github.com/masterjg/opencode-fs-plugin.git#v1.1.1`. A tag is
192
192
  checked for updates; use a full commit hash to pin it.
193
193
 
194
194
  Git plugins are installed under OpenCode's cache, so their package path is not
195
195
  stable. If you also want the packaged skill, install with npm instead:
196
196
 
197
197
  ```bash
198
- npm install "github:masterjg/opencode-fs-plugin#v1.1.0"
198
+ npm install "github:masterjg/opencode-fs-plugin#v1.1.1"
199
199
  ```
200
200
 
201
201
  Then use `./node_modules/opencode-fs-plugin` in `plugins` and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-fs-plugin",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "type": "module",
5
5
  "description": "OpenCode 2 plugin: Linux-style filesystem and text tools under the fs namespace.",
6
6
  "repository": {
@@ -28,6 +28,10 @@ With `execute` allowed, call it as `tools.fs.<command>`; agents without
28
28
  Do not duplicate a built-in when it already covers the job. `fs` exists for the
29
29
  operations the built-ins do not cover, and for composable text/archive work.
30
30
 
31
+ Use the `fs` tool for both the operation and its verification. Do not route an
32
+ `fs` operation through a shell or `toolbox.run`, and do not use shell to check
33
+ what `fs.stat`, `fs.ls`, `fs.hash`, `fs.diff`, or `fs.cat` can confirm.
34
+
31
35
  ## Command map
32
36
 
33
37
  | Need | Command |
@@ -40,7 +44,7 @@ operations the built-ins do not cover, and for composable text/archive work.
40
44
  | Links and modes | `fs.ln`, `fs.readlink`, `fs.chmod` |
41
45
  | Hash, usage | `fs.hash`, `fs.du`, `fs.df` |
42
46
  | Predicate search | `fs.find` (`name`, `type`, `size`, `mtime`, `maxDepth`) |
43
- | Archives | `fs.tar`, `fs.zip`, `fs.unzip`, `fs.gzip`, `fs.gunzip` |
47
+ | Archives | `fs.tar` (`create`/`extract`/`list`), `fs.zip`, `fs.unzip` (`extract`/`list`), `fs.gzip`, `fs.gunzip` |
44
48
  | Compare | `fs.diff` |
45
49
  | Temp and trash | `fs.mktemp`, `fs.trash` |
46
50
  | Text filters | `fs.cat`, `fs.head`, `fs.tail`, `fs.grep`, `fs.sed`, `fs.sort`, `fs.uniq`, `fs.cut`, `fs.tr`, `fs.wc`, `fs.tee` |
@@ -59,7 +63,8 @@ Use the exact field names; scalar `path` is only valid for `fs.mkdir`.
59
63
  | `files` | `fs.hash` |
60
64
  | `left` + `right` | `fs.diff` |
61
65
  | `archive` + `paths` | `fs.tar` create, `fs.zip` create |
62
- | `archive` + `mode` | `fs.tar`, `fs.unzip` |
66
+ | `archive` + `mode` | `fs.tar` (`create`/`extract`/`list`), `fs.unzip` (`extract`/`list`) |
67
+ | `content` | `fs.tee` when there is no stdin |
63
68
  | `stages` + optional `input`/`output` | `fs.pipe` |
64
69
 
65
70
  ## Pipe
@@ -111,15 +116,26 @@ returns the status with `timedOut: true`. Jobs are process-local and lost on
111
116
  server restart. Status files live under `/tmp/opencode/fs-jobs/<server-pid>/`;
112
117
  eight jobs may run at once and finished jobs are cleaned after one hour.
113
118
 
114
- To wait without blocking the session, combine the status file with `wait_for`:
119
+ To wait without blocking the session, combine the status file with `wait_for`.
120
+ Wait for any terminal state, then read the job for the result or error:
115
121
 
116
122
  ```js
117
123
  await tools.wait.for({
118
- condition: { type: "file_contains", path: job.statusPath, pattern: '"state":"completed"' },
124
+ condition: {
125
+ type: "file_contains",
126
+ path: job.statusPath,
127
+ pattern: '"state":"(completed|failed|cancelled)"',
128
+ regex: true,
129
+ },
119
130
  timeoutMs: 600000,
131
+ intervalMs: 500,
120
132
  })
133
+ const status = JSON.parse(await tools.fs.job({ id: job.jobId }))
121
134
  ```
122
135
 
136
+ A job that produces no text returns empty content from `fs.job wait`; verify the
137
+ effect with `fs.stat`, `fs.ls`, or `fs.diff`, and use `fs.job({ id })` for state.
138
+
123
139
  ## Recipes
124
140
 
125
141
  ```js
@@ -134,9 +150,11 @@ await tools.fs.ls({ paths: ["dist"], long: true, human: true })
134
150
  await tools.fs.find({ paths: ["."], name: "*.log", size: "+10M" })
135
151
  await tools.fs.trash({ paths: ["old.log"] })
136
152
 
137
- // create and extract an archive
153
+ // create, list, and extract an archive
138
154
  await tools.fs.tar({ mode: "create", archive: "dist.tgz", paths: ["dist"], gzip: true })
155
+ await tools.fs.tar({ mode: "list", archive: "dist.tgz" })
139
156
  await tools.fs.tar({ mode: "extract", archive: "dist.tgz", directory: "out" })
157
+ await tools.fs.unzip({ archive: "bundle.zip", mode: "list" })
140
158
 
141
159
  // compare two files
142
160
  await tools.fs.diff({ left: "old.txt", right: "new.txt", unified: 3 })
@@ -152,7 +170,13 @@ await tools.fs.diff({ left: "old.txt", right: "new.txt", unified: 3 })
152
170
  - `fs.tail` has no follow mode; `fs.diff` compares files/directories only.
153
171
  - `cp -a` preserves mode and timestamps but not ACLs or xattrs.
154
172
  - `fs.tar`/`fs.zip` are file-backed; they are not pipe stages.
173
+ - `fs.tar` resolves `paths` even when `directory` is set; pass absolute sources
174
+ with `directory` or the member path may not be found.
175
+ - `fs.du` reports allocated blocks like `du`; use `fs.stat` with `%s` for
176
+ apparent file bytes.
155
177
  - `fs.trash` uses the XDG home trash only and refuses cross-device moves.
178
+ Files under `/tmp` are usually on another filesystem; use a project path or a
179
+ same-filesystem holding directory instead.
156
180
  - `fs.mktemp` uses the OS temp directory unless `tmpdir` is supplied.
157
181
 
158
182
  ## Paths and safety
@@ -181,11 +205,13 @@ hidden inside a pipeline. Do not work around a denied tool with shell.
181
205
  - `fs.grep` with no matches and `fs.diff` with differences return exit code 1;
182
206
  that is a result, not a tool failure.
183
207
  - Binary output is returned as base64 when no `output` file is supplied.
208
+ - Tools that produce no text (`cp`, `mv`, `rm`, `touch`, `chmod`, `sed -i`) return
209
+ empty content; verify the effect with `fs.stat`, `fs.ls`, or `fs.diff`.
184
210
  - Invalid arguments return `ERROR: Invalid ...`; fix the field names or option
185
211
  values rather than retrying the same call.
186
212
 
187
213
  ## Verification
188
214
 
189
215
  Use `fs.stat`, `fs.ls`, `fs.hash`, `fs.cat`, or `fs.diff` to confirm the result.
190
- Report the tool result, such as `copied: 1`, `found: 2`, or
191
- `differences: true`.
216
+ Do not verify with a shell command. Report the tool result or the verified state,
217
+ such as `copied: 1`, `found: 2`, or `differences: true`.
package/src/tools/du.ts CHANGED
@@ -50,7 +50,7 @@ export const duTool: ToolSpec<Input> = {
50
50
  : await ctx.sandbox.lstat(target.full, requested);
51
51
  const rootDev = num(rootStats.dev);
52
52
  const seen = new Set<string>();
53
- let total = usage(target.full, rootStats, seen);
53
+ let total = usage(rootStats, seen);
54
54
  const local: Row[] = [];
55
55
  if (input.all === true && !rootStats.isDirectory()) {
56
56
  local.push({ path: requested, bytes: total });
@@ -65,7 +65,7 @@ export const duTool: ToolSpec<Input> = {
65
65
  })) {
66
66
  /* v8 ignore next */
67
67
  if (input.oneFileSystem === true && num(entry.stats.dev) !== rootDev) continue;
68
- const bytes = usage(entry.path, entry.stats, seen);
68
+ const bytes = usage(entry.stats, seen);
69
69
  total += bytes;
70
70
  if (input.all === true || entry.stats.isDirectory()) {
71
71
  local.push({ path: entry.path, bytes });
@@ -89,14 +89,12 @@ export const duTool: ToolSpec<Input> = {
89
89
  },
90
90
  };
91
91
 
92
- function usage(path: string, stats: Awaited<ReturnType<typeof fs.lstat>>, seen: Set<string>): number {
93
- /* v8 ignore next */
94
- if (!stats.isFile()) return stats.isDirectory() ? num(stats.blocks) * 512 : 0;
95
- if (num(stats.nlink) > 1) {
92
+ function usage(stats: Awaited<ReturnType<typeof fs.lstat>>, seen: Set<string>): number {
93
+ if (!stats.isDirectory() && num(stats.nlink) > 1) {
96
94
  const key = `${num(stats.dev)}:${num(stats.ino)}`;
97
95
  /* v8 ignore next */
98
96
  if (seen.has(key)) return 0;
99
97
  seen.add(key);
100
98
  }
101
- return num(stats.size);
99
+ return num(stats.blocks) * 512;
102
100
  }