opencode-fs-plugin 1.2.0 → 1.2.2
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 +9 -9
- package/README.md +8 -8
- package/SPEC.md +3 -2
- package/package.json +1 -1
- package/skills/filesystem/SKILL.md +10 -4
- package/src/tools/find.ts +24 -5
- package/src/tools/ls.ts +2 -1
- package/src/tools/readlink.ts +22 -2
- package/src/tools/sort.ts +1 -1
- package/src/tools/stat.ts +3 -2
- package/src/tools/tar.ts +2 -1
- package/src/tools/zip.ts +3 -1
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.2.
|
|
20
|
+
"plugins": ["opencode-fs-plugin@1.2.2"]
|
|
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.2.
|
|
27
|
+
opencode plugin add opencode-fs-plugin@1.2.2
|
|
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.2.
|
|
39
|
+
VERSION=1.2.2
|
|
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.2.
|
|
67
|
+
"plugins": ["github:masterjg/opencode-fs-plugin#v1.2.2"]
|
|
68
68
|
}
|
|
69
69
|
```
|
|
70
70
|
|
|
71
|
-
`opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.2.
|
|
71
|
+
`opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.2.2'` 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.2.
|
|
73
|
+
`git+https://github.com/masterjg/opencode-fs-plugin.git#v1.2.2`. 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.2.
|
|
80
|
+
npm install "github:masterjg/opencode-fs-plugin#v1.2.2"
|
|
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.2.
|
|
177
|
+
Install opencode-fs-plugin 1.2.2 with "npm install opencode-fs-plugin@1.2.2",
|
|
178
178
|
or from its release tarball or the Git tag
|
|
179
|
-
"github:masterjg/opencode-fs-plugin#v1.2.
|
|
179
|
+
"github:masterjg/opencode-fs-plugin#v1.2.2". 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.2.
|
|
130
|
+
"plugins": ["opencode-fs-plugin@1.2.2"]
|
|
131
131
|
}
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
`opencode plugin add opencode-fs-plugin@1.2.
|
|
134
|
+
`opencode plugin add opencode-fs-plugin@1.2.2` 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.2.
|
|
141
|
+
npm install opencode-fs-plugin@1.2.2
|
|
142
142
|
```
|
|
143
143
|
|
|
144
144
|
```jsonc
|
|
@@ -153,7 +153,7 @@ npm install opencode-fs-plugin@1.2.0
|
|
|
153
153
|
Download the release tarball, then install it as a normal npm package:
|
|
154
154
|
|
|
155
155
|
```bash
|
|
156
|
-
VERSION=1.2.
|
|
156
|
+
VERSION=1.2.2
|
|
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.2.
|
|
185
|
+
"plugins": ["github:masterjg/opencode-fs-plugin#v1.2.2"]
|
|
186
186
|
}
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
`opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.2.
|
|
189
|
+
`opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.2.2'` 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.2.
|
|
191
|
+
`git+https://github.com/masterjg/opencode-fs-plugin.git#v1.2.2`. 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.2.
|
|
198
|
+
npm install "github:masterjg/opencode-fs-plugin#v1.2.2"
|
|
199
199
|
```
|
|
200
200
|
|
|
201
201
|
Then use `./node_modules/opencode-fs-plugin` in `plugins` and
|
package/SPEC.md
CHANGED
|
@@ -45,8 +45,9 @@ These are not implemented:
|
|
|
45
45
|
%x %X %y %Y %z %Z %w %W %t %T %C %L`, plus `\n`, `\t`, `\\` and `%%`.
|
|
46
46
|
`%C` returns `?` because Node does not expose the SELinux file context.
|
|
47
47
|
- `chmod` supports octal modes and symbolic `[ugoa]*[-+=][rwxXst]*` clauses.
|
|
48
|
-
- `find -size`
|
|
49
|
-
|
|
48
|
+
- `find -size` accepts `c` (bytes), `w` (2-byte words), `b` (512-byte blocks),
|
|
49
|
+
and binary `K`/`M`/`G`/... suffixes; `-mtime`/`-mmin` accept `+N` (older),
|
|
50
|
+
`-N` (newer), and exact `N`. `newerXY` uses `XY:path`.
|
|
50
51
|
- `sort -k` accepts field/character ranges with modifiers `bdfghiMnrV`.
|
|
51
52
|
- `tar`/`zip` extraction rejects path traversal and escaping links.
|
|
52
53
|
- `pipe` passes raw bytes and only accepts registered pipeable stages; `tar` and
|
package/package.json
CHANGED
|
@@ -52,10 +52,16 @@ what `fs.stat`, `fs.ls`, `fs.hash`, `fs.diff`, or `fs.cat` can confirm.
|
|
|
52
52
|
| Compose filters | `fs.pipe` |
|
|
53
53
|
| Background jobs | `background: true`, then `fs.job` |
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
Recent parity additions:
|
|
56
|
+
|
|
57
|
+
| Tool | Added |
|
|
58
|
+
|---|---|
|
|
59
|
+
| `fs.sort` | `generalNumeric`, `humanNumeric`, `version`, `dictionary`, `ignoreNonPrinting`, `stable`, `check`, `checkQuiet`, `zeroTerminated`, GNU `keys` ranges |
|
|
60
|
+
| `fs.ls` | `size`, `numericIds`, `noGroup`, `noOwner`, `slash`, `quote`, `versionSort`, `extensionSort`, `fullTime`, `timeStyle`, `hide`, `ignore`, `groupDirectoriesFirst` |
|
|
61
|
+
| `fs.find` | `lname`/`ilname`, `regex`/`iregex`, `uid`/`gid`/`user`/`group`, `links`, `inum`, `samefile`, `fstype`, `newerXY`, `printf`; `c`/`w`/`b` size suffixes |
|
|
62
|
+
| `fs.stat` | `terse`, extended tokens `%f`, `%m`, `%r`, `%w`, `%W`, `%C` |
|
|
63
|
+
| `fs.tail` | bounded `follow`, `timeoutMs`, `intervalMs`, `maxBytes` |
|
|
64
|
+
| `fs.tar`/`fs.zip` | `input`/`member` stream input and pipe sink support |
|
|
59
65
|
|
|
60
66
|
## Argument shapes
|
|
61
67
|
|
package/src/tools/find.ts
CHANGED
|
@@ -9,7 +9,6 @@ import picomatch from "picomatch";
|
|
|
9
9
|
import { Type, type Static } from "@sinclair/typebox";
|
|
10
10
|
import { FsError } from "../core/errors.js";
|
|
11
11
|
import { lookupGroup, lookupUser, modeString, num, typeName, walk } from "../core/fsutil.js";
|
|
12
|
-
import { parseSize } from "../core/format.js";
|
|
13
12
|
import { textResult, type ToolSpec } from "../core/types.js";
|
|
14
13
|
|
|
15
14
|
const Schema = Type.Object(
|
|
@@ -104,8 +103,8 @@ let groupMap: Map<string, number> | undefined;
|
|
|
104
103
|
export const findTool: ToolSpec<Input> = {
|
|
105
104
|
name: "find",
|
|
106
105
|
description:
|
|
107
|
-
"Find entries with Linux-like predicates: `-name`, `-iname`, `-path`, `-lname`, `-
|
|
108
|
-
"`-type`, `-size`, `-mtime`, `-mmin`, `-maxdepth`, `-mindepth`, `-empty`, `-perm`, " +
|
|
106
|
+
"Find entries with Linux-like predicates: `-name`, `-iname`, `-path`, `-lname`, `-ilname`, " +
|
|
107
|
+
"`-regex`, `-iregex`, `-type`, `-size`, `-mtime`, `-mmin`, `-maxdepth`, `-mindepth`, `-empty`, `-perm`, " +
|
|
109
108
|
"`-uid`, `-gid`, `-user`, `-group`, `-links`, `-inum`, `-samefile`, `-fstype`, `-newer`, " +
|
|
110
109
|
"`-newerXY`, `-printf`, `-L`, `-print0`.",
|
|
111
110
|
schema: Schema,
|
|
@@ -117,7 +116,10 @@ export const findTool: ToolSpec<Input> = {
|
|
|
117
116
|
const patterns: Patterns = {
|
|
118
117
|
nameMatch: input.name === undefined ? undefined : picomatch(input.name, { dot: true }),
|
|
119
118
|
inameMatch: input.iname === undefined ? undefined : picomatch(input.iname, { dot: true, nocase: true }),
|
|
120
|
-
|
|
119
|
+
// GNU find lets `*` cross path separators in `-path`.
|
|
120
|
+
pathMatch: input.pathPattern === undefined
|
|
121
|
+
? undefined
|
|
122
|
+
: picomatch(input.pathPattern, { dot: true, bash: true }),
|
|
121
123
|
lnameMatch: input.lname === undefined ? undefined : picomatch(input.lname, { dot: true }),
|
|
122
124
|
ilnameMatch: input.ilname === undefined ? undefined : picomatch(input.ilname, { dot: true, nocase: true }),
|
|
123
125
|
regex: input.regex === undefined ? undefined : new RegExp(input.regex),
|
|
@@ -202,7 +204,7 @@ async function matches(
|
|
|
202
204
|
if (input.size !== undefined) {
|
|
203
205
|
const sign = input.size.startsWith("+") ? 1 : input.size.startsWith("-") ? -1 : 0;
|
|
204
206
|
const body = sign === 0 ? input.size : input.size.slice(1);
|
|
205
|
-
const size =
|
|
207
|
+
const size = parseFindSize(body);
|
|
206
208
|
if (sign === 1 && stats.size <= size) return false;
|
|
207
209
|
if (sign === -1 && stats.size >= size) return false;
|
|
208
210
|
if (sign === 0 && stats.size !== size) return false;
|
|
@@ -415,6 +417,23 @@ async function printf(
|
|
|
415
417
|
return output;
|
|
416
418
|
}
|
|
417
419
|
|
|
420
|
+
function parseFindSize(value: string): number {
|
|
421
|
+
const match = /^(\d+(?:\.\d+)?)([cwbkMGTPE]?)$/.exec(value);
|
|
422
|
+
if (match === null) throw new FsError(`Invalid size: ${value}`, "invalid");
|
|
423
|
+
const units: Record<string, number> = {
|
|
424
|
+
c: 1,
|
|
425
|
+
w: 2,
|
|
426
|
+
b: 512,
|
|
427
|
+
k: 1024,
|
|
428
|
+
M: 1024 ** 2,
|
|
429
|
+
G: 1024 ** 3,
|
|
430
|
+
T: 1024 ** 4,
|
|
431
|
+
P: 1024 ** 5,
|
|
432
|
+
E: 1024 ** 6,
|
|
433
|
+
};
|
|
434
|
+
return Math.ceil(Number(match[1]) * (units[match[2] as string] ?? 1));
|
|
435
|
+
}
|
|
436
|
+
|
|
418
437
|
function countMatches(value: number, expression: string): boolean {
|
|
419
438
|
if (expression.startsWith("+")) return value > Number(expression.slice(1));
|
|
420
439
|
if (expression.startsWith("-")) return value < Number(expression.slice(1));
|
package/src/tools/ls.ts
CHANGED
|
@@ -65,7 +65,8 @@ export const lsTool: ToolSpec<Input> = {
|
|
|
65
65
|
name: "ls",
|
|
66
66
|
description:
|
|
67
67
|
"List files and directories with Linux `ls` semantics (`-a`, `-A`, `-l`, `-h`, `-R`, " +
|
|
68
|
-
"`-d`, `-i`, `-F`, `-t`, `-S`, `-r`, `-1
|
|
68
|
+
"`-d`, `-i`, `-F`, `-t`, `-S`, `-r`, `-1`, `-s`, `-n`, `-g`, `-o`, `-p`, `-Q`, `-v`, `-X`, " +
|
|
69
|
+
"`--time-style`, `--hide`, `--ignore`, `--group-directories-first`).",
|
|
69
70
|
schema: Schema,
|
|
70
71
|
pipeable: false,
|
|
71
72
|
mutates: false,
|
package/src/tools/readlink.ts
CHANGED
|
@@ -82,8 +82,28 @@ async function resolveLink(
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
if (mode === "canonical") {
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
try {
|
|
86
|
+
return await fs.realpath(full);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
/* v8 ignore next */
|
|
89
|
+
if (!isMissing(error)) throw fromErrno(error);
|
|
90
|
+
const parent = await ctx.sandbox.resolveParent(requested);
|
|
91
|
+
let current = path.join(parent.full, path.basename(full));
|
|
92
|
+
for (let depth = 0; depth < 40; depth++) {
|
|
93
|
+
let stats: Awaited<ReturnType<typeof fs.lstat>>;
|
|
94
|
+
try {
|
|
95
|
+
stats = await fs.lstat(current);
|
|
96
|
+
} catch {
|
|
97
|
+
return current;
|
|
98
|
+
}
|
|
99
|
+
/* v8 ignore next -- a dangling target normally fails lstat first */
|
|
100
|
+
if (!stats.isSymbolicLink()) return current;
|
|
101
|
+
const link = await fs.readlink(current);
|
|
102
|
+
current = path.resolve(path.dirname(current), link);
|
|
103
|
+
}
|
|
104
|
+
/* v8 ignore next -- realpath already rejects cycles; this bounds manual resolution */
|
|
105
|
+
throw new FsError(`Too many symbolic links: "${requested}".`, "io");
|
|
106
|
+
}
|
|
87
107
|
}
|
|
88
108
|
const target = await ctx.sandbox.resolveForCreate(requested);
|
|
89
109
|
return target.full;
|
package/src/tools/sort.ts
CHANGED
|
@@ -42,7 +42,7 @@ export const sortTool: ToolSpec<Input> = {
|
|
|
42
42
|
name: "sort",
|
|
43
43
|
description:
|
|
44
44
|
"Sort records with Linux `sort` semantics (`-n`, `-g`, `-h`, `-V`, `-r`, `-u`, `-f`, " +
|
|
45
|
-
"`-d`, `-i`, `-b`, `-s`, `-c`, `-C`, `-z`, `-k
|
|
45
|
+
"`-d`, `-i`, `-b`, `-s`, `-c`, `-C`, `-z`, `-k` key ranges, `-t`).",
|
|
46
46
|
schema: Schema,
|
|
47
47
|
pipeable: "filter",
|
|
48
48
|
mutates: false,
|
package/src/tools/stat.ts
CHANGED
|
@@ -25,8 +25,9 @@ type Input = Static<typeof Schema>;
|
|
|
25
25
|
export const statTool: ToolSpec<Input> = {
|
|
26
26
|
name: "stat",
|
|
27
27
|
description:
|
|
28
|
-
"Display file or filesystem status with Linux `stat` semantics (`-L`, `-c`, `-f`). " +
|
|
29
|
-
"Supports
|
|
28
|
+
"Display file or filesystem status with Linux `stat` semantics (`-L`, `-c`, `-t`, `-f`). " +
|
|
29
|
+
"Supports common and extended tokens for path, size, type, mode, owner, times, birth time, " +
|
|
30
|
+
"device, inode, mount point, filesystem type and SELinux context.",
|
|
30
31
|
schema: Schema,
|
|
31
32
|
pipeable: false,
|
|
32
33
|
mutates: false,
|
package/src/tools/tar.ts
CHANGED
|
@@ -41,7 +41,8 @@ export const tarTool: ToolSpec<Input> = {
|
|
|
41
41
|
name: "tar",
|
|
42
42
|
description:
|
|
43
43
|
"Create, list or extract tar archives with common `tar` semantics (`-c`, `-x`, `-t`, `-f`, " +
|
|
44
|
-
"`-z`, `-C`, `--strip-components`, `--exclude`).
|
|
44
|
+
"`-z`, `-C`, `--strip-components`, `--exclude`). Create accepts `input`/`member` stream data " +
|
|
45
|
+
"and can consume pipe stdin; extraction rejects path escapes.",
|
|
45
46
|
schema: Schema,
|
|
46
47
|
pipeable: "sink",
|
|
47
48
|
mutates: true,
|
package/src/tools/zip.ts
CHANGED
|
@@ -41,7 +41,9 @@ type UnzipInput = Static<typeof UnzipSchema>;
|
|
|
41
41
|
|
|
42
42
|
export const zipTool: ToolSpec<ZipInput> = {
|
|
43
43
|
name: "zip",
|
|
44
|
-
description:
|
|
44
|
+
description:
|
|
45
|
+
"Create ZIP archives with common `zip` semantics (`-r` is implicit, compression level 0-9). " +
|
|
46
|
+
"Accepts `input`/`member` stream data and can consume pipe stdin.",
|
|
45
47
|
schema: ZipSchema,
|
|
46
48
|
pipeable: "sink",
|
|
47
49
|
mutates: true,
|