opencode-fs-plugin 1.6.1 → 1.6.3
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/package.json +1 -1
- package/skills/filesystem/SKILL.md +29 -46
package/package.json
CHANGED
|
@@ -113,6 +113,25 @@ host drops unknown fields, so a name typo runs with defaults.
|
|
|
113
113
|
- `fs.mktemp` needs a template ending in at least three `X`; use `suffix` for an
|
|
114
114
|
extension.
|
|
115
115
|
|
|
116
|
+
### Shell patterns and their fs equivalents
|
|
117
|
+
|
|
118
|
+
| Shell pattern | Use |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `sed -n '1,80p' f` | `fs.head({ paths: [f], lines: 80 })` |
|
|
121
|
+
| `sed -n '20,40p' f` | `fs.pipe({ stages: [{ tool: "cat", args: { paths: [f] } }, { tool: "head", args: { lines: 40 } }, { tool: "tail", args: { lines: 21 } }] })` |
|
|
122
|
+
| `sed 's/a/b/'` / `sed -i` | `fs.sed({ script, paths, inPlace })` |
|
|
123
|
+
| `head -n N f` / `tail -n N f` | `fs.head` / `fs.tail` |
|
|
124
|
+
| `wc -l f` | `fs.wc({ paths: [f], lines: true })` |
|
|
125
|
+
| `sha256sum f` | `fs.hash({ files: [f] })` |
|
|
126
|
+
| `find ... -exec rm -rf {} +` | `fs.find(...)`, then `fs.rm({ paths, recursive: true })` or `fs.trash` |
|
|
127
|
+
| `cat > f <<EOF` | built-in `write` or `fs.tee({ paths: [f], content })` |
|
|
128
|
+
| `rg pattern path` | `fs.grep({ pattern, paths })` or the built-in `grep` |
|
|
129
|
+
| `ls -l f` | `fs.ls({ paths: [f], long: true })` |
|
|
130
|
+
|
|
131
|
+
`sed -n` applied to another command's stdout has no fs equivalent; keep that in
|
|
132
|
+
the command pipeline. `fs.find` has no `-exec` by design; list the paths, then
|
|
133
|
+
delete or trash them explicitly.
|
|
134
|
+
|
|
116
135
|
## Batch independent calls
|
|
117
136
|
|
|
118
137
|
`execute` is a JS runtime. Do not `await` independent fs calls one at a time.
|
|
@@ -277,59 +296,23 @@ const status = JSON.parse(await tools.fs.job({ id: job.jobId }))
|
|
|
277
296
|
A job that produces no text returns empty content from `fs.job wait`; verify the
|
|
278
297
|
effect with `fs.stat`, `fs.ls`, or `fs.diff`, and use `fs.job({ id })` for state.
|
|
279
298
|
|
|
280
|
-
##
|
|
281
|
-
|
|
282
|
-
`execute` is always available and is the orchestration layer for every `fs` tool.
|
|
283
|
-
Use ordinary JavaScript for iteration, conditionals, retries, and parallel calls.
|
|
284
|
-
Do not use a shell or `toolbox.run` for batching.
|
|
285
|
-
|
|
286
|
-
Sequential is the safe default for writes, destructive work, ordering, and
|
|
287
|
-
permission prompts:
|
|
288
|
-
|
|
289
|
-
```js
|
|
290
|
-
const files = (
|
|
291
|
-
await tools.fs.find({
|
|
292
|
-
paths: ["src"],
|
|
293
|
-
name: "*.sh",
|
|
294
|
-
type: "f",
|
|
295
|
-
print0: true,
|
|
296
|
-
})
|
|
297
|
-
).split("\0").filter(Boolean)
|
|
298
|
-
|
|
299
|
-
for (const file of files) {
|
|
300
|
-
await tools.fs.chmod({ paths: [file], mode: "640" })
|
|
301
|
-
}
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
Use `Promise.all` only for independent work. It rejects on the first failure
|
|
305
|
-
while the other calls continue, so prefer `Promise.allSettled` when partial
|
|
306
|
-
results are useful. Bound concurrency to about 4–8:
|
|
307
|
-
|
|
308
|
-
```js
|
|
309
|
-
async function mapLimit(items, limit, fn) {
|
|
310
|
-
const results = []
|
|
311
|
-
for (let i = 0; i < items.length; i += limit) {
|
|
312
|
-
results.push(...(await Promise.all(items.slice(i, i + limit).map(fn))))
|
|
313
|
-
}
|
|
314
|
-
return results
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const stats = await mapLimit(files, 4, (file) =>
|
|
318
|
-
tools.fs.stat({ paths: [file], format: "%n %s" }),
|
|
319
|
-
)
|
|
320
|
-
```
|
|
299
|
+
## Orchestration notes
|
|
321
300
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
301
|
+
`execute` is the orchestration layer for every `fs` tool. Each batched call still
|
|
302
|
+
asserts its own `fs_<tool>` and `external_directory` permission, so fan-out does
|
|
303
|
+
not bypass permissions. Code Mode has no timers: use `wait_for` for time-based
|
|
304
|
+
waits and `background: true` for long jobs. Writes and destructive operations
|
|
305
|
+
may fan out too when their targets are independent; keep ordering only when a
|
|
306
|
+
later step depends on an earlier result.
|
|
325
307
|
|
|
326
308
|
## Performance
|
|
327
309
|
|
|
328
310
|
All `fs` I/O is asynchronous. Independent work is parallelized automatically
|
|
329
311
|
within each call, up to `os.availableParallelism()`: tree copies, hashing,
|
|
330
312
|
gzip/gunzip, grep reads, `find`/`du`/`grep -r`/`chmod -R`/`chown -R` traversal,
|
|
331
|
-
`diff -r`, `ls` formatting, `ps` /proc scans, and `split` writes. Do not
|
|
332
|
-
|
|
313
|
+
`diff -r`, `ls` formatting, `ps` /proc scans, and `split` writes. Do not
|
|
314
|
+
re-implement that internal concurrency; fan out separate tool calls only as
|
|
315
|
+
described in Batch independent calls.
|
|
333
316
|
|
|
334
317
|
The limit comes from the plugin `concurrency` option or
|
|
335
318
|
`OPENCODE_FS_CONCURRENCY`. CPU-bound `sort`, `sed`, and text diffing stay
|