opencode-fs-plugin 1.6.0 → 1.6.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 +5 -0
- package/SPEC.md +2 -1
- package/package.json +1 -1
- package/skills/filesystem/SKILL.md +93 -13
package/README.md
CHANGED
|
@@ -117,6 +117,11 @@ large downloads prefer `fs.http_request({ output })`, which streams to disk.
|
|
|
117
117
|
|
|
118
118
|
There is no shell, redirection operator, nested pipe, or `find -exec`.
|
|
119
119
|
|
|
120
|
+
`fs.pipe` is sequential by design and is not a batch primitive. For independent
|
|
121
|
+
work, fan out with `Promise.all` over `tools.fs.*` (or one multi-path call).
|
|
122
|
+
`fs` domain errors resolve as `ERROR:`/`BLOCKED:` text, so check each result;
|
|
123
|
+
permission denials throw.
|
|
124
|
+
|
|
120
125
|
## Performance and concurrency
|
|
121
126
|
|
|
122
127
|
All I/O is asynchronous; the plugin never calls a synchronous `fs` API.
|
package/SPEC.md
CHANGED
|
@@ -117,7 +117,8 @@ These are not implemented:
|
|
|
117
117
|
- `sort -k` accepts field/character ranges with modifiers `bdfghiMnrV`.
|
|
118
118
|
- `tar`/`zip` extraction rejects path traversal and escaping links.
|
|
119
119
|
- `pipe` passes raw bytes and only accepts registered pipeable stages; `tar` and
|
|
120
|
-
`zip` are sink stages.
|
|
120
|
+
`zip` are sink stages. It is sequential and not a batch primitive: independent
|
|
121
|
+
calls fan out with `Promise.all` in `execute`.
|
|
121
122
|
|
|
122
123
|
## Coverage policy
|
|
123
124
|
|
package/package.json
CHANGED
|
@@ -25,7 +25,8 @@ With `execute` allowed, call it as `tools.fs.<command>`; agents without
|
|
|
25
25
|
| Regex substitution or in-place edit | `fs.sed` |
|
|
26
26
|
| Recoverable deletion | `fs.trash` |
|
|
27
27
|
| HTTP(S) fetch, API call, or file download | `fs.http_request` |
|
|
28
|
-
|
|
|
28
|
+
| Many independent fs calls | one multi-path call, else `Promise.all` in `execute` |
|
|
29
|
+
| Sequential byte pipeline | `fs.pipe` |
|
|
29
30
|
|
|
30
31
|
Do not duplicate a built-in when it already covers the job. `fs` exists for the
|
|
31
32
|
operations the built-ins do not cover, and for composable text/archive work.
|
|
@@ -112,10 +113,59 @@ host drops unknown fields, so a name typo runs with defaults.
|
|
|
112
113
|
- `fs.mktemp` needs a template ending in at least three `X`; use `suffix` for an
|
|
113
114
|
extension.
|
|
114
115
|
|
|
116
|
+
## Batch independent calls
|
|
117
|
+
|
|
118
|
+
`execute` is a JS runtime. Do not `await` independent fs calls one at a time.
|
|
119
|
+
|
|
120
|
+
1. **Use the widest native call first.** `cat`, `stat`, `hash`, `ls`, `grep`,
|
|
121
|
+
`tee`, `wc`, `chmod`, `touch`, `rm`, and `trash` take `paths` arrays. Use one
|
|
122
|
+
call when combined output is enough:
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
const stats = await tools.fs.stat({ paths: files, format: "%n %s" })
|
|
126
|
+
const sums = await tools.fs.hash({ files })
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
2. **Fan out when you need per-item results.** `Promise.all` preserves input
|
|
130
|
+
order:
|
|
131
|
+
|
|
132
|
+
```js
|
|
133
|
+
const rows = await Promise.all(files.map(async (f) => {
|
|
134
|
+
const text = String(await tools.fs.cat({ paths: [f] }))
|
|
135
|
+
return { f, text, ok: !/^(ERROR|BLOCKED):/.test(text) }
|
|
136
|
+
}))
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`fs` domain errors resolve as `ERROR:`/`BLOCKED:` text; they do not reject.
|
|
140
|
+
Permission denials and host validation throw, so use `Promise.allSettled`
|
|
141
|
+
only when those should not cancel the batch.
|
|
142
|
+
|
|
143
|
+
3. **Bound very large fan-outs.** One tool call per item is expensive; use a
|
|
144
|
+
small worker pool (for example 8) instead of `Promise.all` over thousands:
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
async function mapLimit(items, limit, fn) {
|
|
148
|
+
const out = new Array(items.length)
|
|
149
|
+
let next = 0
|
|
150
|
+
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, async () => {
|
|
151
|
+
while (next < items.length) {
|
|
152
|
+
const i = next++
|
|
153
|
+
out[i] = await fn(items[i], i)
|
|
154
|
+
}
|
|
155
|
+
}))
|
|
156
|
+
return out
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Keep `for (const x of items) { await ... }` only when each step depends on the
|
|
161
|
+
previous result, such as read → transform → write the same file. Use `fs.pipe`
|
|
162
|
+
for a sequential byte chain; use this section for independent work.
|
|
163
|
+
|
|
115
164
|
## Pipe
|
|
116
165
|
|
|
117
|
-
|
|
118
|
-
|
|
166
|
+
`fs.pipe` runs fs tools as a **sequential byte pipeline**: each stage's stdout
|
|
167
|
+
is the next stage's stdin. Use it for filter chains; use the batching pattern
|
|
168
|
+
above for parallel fan-out.
|
|
119
169
|
|
|
120
170
|
```js
|
|
121
171
|
await tools.fs.pipe({
|
|
@@ -128,17 +178,30 @@ await tools.fs.pipe({
|
|
|
128
178
|
})
|
|
129
179
|
```
|
|
130
180
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
`input`
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
181
|
+
| Field | Meaning |
|
|
182
|
+
|---|---|
|
|
183
|
+
| `stages` | 1–50 `{ tool, args }` entries; names are short (`cat`, not `fs.cat`) |
|
|
184
|
+
| `input` | Initial stdin text when the first stage is a filter |
|
|
185
|
+
| `output` | Write final stdout to a file (final `tee`) |
|
|
186
|
+
| `append` | Append to `output` instead of overwriting |
|
|
187
|
+
|
|
188
|
+
The first stage must be a source (`cat`, `http_request`, `dd`, or a path-reading
|
|
189
|
+
text tool such as `tac`, `rev`, `nl`, `base64`, `od`, `strings`) or receive
|
|
190
|
+
`input`. A filter first (`grep`, `sort`, `head`, `wc`) emits
|
|
191
|
+
`ERROR: no input files and no stdin` as pipeline data. Archive writers (`tar`,
|
|
192
|
+
`zip`, `cpio`) emit nothing downstream, so put them last. `wc` and `hash` also
|
|
193
|
+
emit their result text, so they can end a chain or feed a later stage.
|
|
194
|
+
|
|
195
|
+
Stages exchange whole buffers. Set `maxBytes` on `http_request`; for large
|
|
196
|
+
downloads prefer `fs.http_request({ output })`, which streams to disk. In-memory
|
|
197
|
+
text is allowed:
|
|
139
198
|
|
|
140
|
-
|
|
141
|
-
|
|
199
|
+
```js
|
|
200
|
+
await tools.fs.pipe({
|
|
201
|
+
input: "b\na\nb\n",
|
|
202
|
+
stages: [{ tool: "sort", args: { unique: true } }],
|
|
203
|
+
})
|
|
204
|
+
```
|
|
142
205
|
|
|
143
206
|
```js
|
|
144
207
|
await tools.fs.pipe({
|
|
@@ -149,6 +212,23 @@ await tools.fs.pipe({
|
|
|
149
212
|
})
|
|
150
213
|
```
|
|
151
214
|
|
|
215
|
+
`output` and `append` assert `fs_tee` on the destination. The result metadata
|
|
216
|
+
lists each stage's `bytesIn`, `bytesOut`, and `exitCode`; use it as the
|
|
217
|
+
verification trail.
|
|
218
|
+
|
|
219
|
+
Common pipe mistakes:
|
|
220
|
+
|
|
221
|
+
- `commands` is not a field; the field is `stages`.
|
|
222
|
+
- A bare `{ tool: "sort", args: {} }` first stage returns
|
|
223
|
+
`ERROR: no input files and no stdin`; add a source stage or `input`.
|
|
224
|
+
- Stage names are `cat`, not `fs.cat`.
|
|
225
|
+
- There is no shell, redirection operator, nested pipe, `find -exec`, or
|
|
226
|
+
`xargs`.
|
|
227
|
+
|
|
228
|
+
Pipeable filters include `head`, `tail`, `grep`, `sed`, `sort`, `uniq`, `cut`,
|
|
229
|
+
`tr`, `tee`, `gzip`, `gunzip`, `tac`, `rev`, `nl`, `paste`, `shuf`, `fold`,
|
|
230
|
+
`base64`, `od`, and `strings`. Unknown stage names fail with `unsupported`.
|
|
231
|
+
|
|
152
232
|
## Background jobs
|
|
153
233
|
|
|
154
234
|
Every tool accepts `background: true`. It returns immediately with a job id and
|