opencode-fs-plugin 0.0.0-stage → 1.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.
Files changed (51) hide show
  1. package/INSTALL.md +186 -0
  2. package/LICENSE +225 -0
  3. package/README.md +265 -2
  4. package/SPEC.md +45 -0
  5. package/package.json +63 -4
  6. package/skills/filesystem/SKILL.md +153 -0
  7. package/src/core/errors.ts +81 -0
  8. package/src/core/format.ts +100 -0
  9. package/src/core/fsutil.ts +228 -0
  10. package/src/core/mode.ts +107 -0
  11. package/src/core/parallel.ts +76 -0
  12. package/src/core/permissions.ts +134 -0
  13. package/src/core/sandbox.ts +270 -0
  14. package/src/core/schema.ts +16 -0
  15. package/src/core/stream.ts +84 -0
  16. package/src/core/types.ts +51 -0
  17. package/src/index.ts +172 -0
  18. package/src/tools/cat.ts +90 -0
  19. package/src/tools/chmod.ts +93 -0
  20. package/src/tools/cp.ts +136 -0
  21. package/src/tools/cut.ts +93 -0
  22. package/src/tools/df.ts +78 -0
  23. package/src/tools/diff.ts +136 -0
  24. package/src/tools/du.ts +102 -0
  25. package/src/tools/find.ts +181 -0
  26. package/src/tools/grep.ts +205 -0
  27. package/src/tools/gzip.ts +164 -0
  28. package/src/tools/hash.ts +84 -0
  29. package/src/tools/head.ts +78 -0
  30. package/src/tools/ln.ts +98 -0
  31. package/src/tools/ls.ts +178 -0
  32. package/src/tools/mkdir.ts +70 -0
  33. package/src/tools/mktemp.ts +83 -0
  34. package/src/tools/mv.ts +135 -0
  35. package/src/tools/pipe.ts +107 -0
  36. package/src/tools/readlink.ts +90 -0
  37. package/src/tools/rm.ts +91 -0
  38. package/src/tools/rmdir.ts +117 -0
  39. package/src/tools/sed.ts +151 -0
  40. package/src/tools/sort.ts +73 -0
  41. package/src/tools/stat.ts +157 -0
  42. package/src/tools/tail.ts +74 -0
  43. package/src/tools/tar.ts +195 -0
  44. package/src/tools/tee.ts +51 -0
  45. package/src/tools/touch.ts +130 -0
  46. package/src/tools/tr.ts +123 -0
  47. package/src/tools/trash.ts +86 -0
  48. package/src/tools/truncate.ts +96 -0
  49. package/src/tools/uniq.ts +76 -0
  50. package/src/tools/wc.ts +97 -0
  51. package/src/tools/zip.ts +231 -0
package/INSTALL.md ADDED
@@ -0,0 +1,186 @@
1
+ # Installing the plugin and filesystem skill
2
+
3
+ The plugin ships the skill at:
4
+
5
+ ```text
6
+ skills/filesystem/SKILL.md
7
+ ```
8
+
9
+ OpenCode does not search inside an installed plugin package automatically, so
10
+ the plugin must be loaded and the skill directory must be registered.
11
+
12
+ ## Install the plugin
13
+
14
+ ### From npm
15
+
16
+ Add the registry package to the plugin list:
17
+
18
+ ```jsonc
19
+ {
20
+ "plugins": ["opencode-fs-plugin@1.0.1"]
21
+ }
22
+ ```
23
+
24
+ Or let the CLI install and configure it:
25
+
26
+ ```bash
27
+ opencode plugin add opencode-fs-plugin@1.0.1
28
+ ```
29
+
30
+ A bare `opencode-fs-plugin` follows `latest`. OpenCode installs it into its
31
+ cache, which has no stable skill path; use the npm-install-in-a-project route in
32
+ Option A if you also want the skill.
33
+
34
+ ### From a release tarball
35
+
36
+ Download the release artifact and install it as a normal npm package:
37
+
38
+ ```bash
39
+ VERSION=1.0.1
40
+ curl -L -o "opencode-fs-plugin-${VERSION}.tgz" \
41
+ "https://github.com/masterjg/opencode-fs-plugin/releases/download/v${VERSION}/opencode-fs-plugin-${VERSION}.tgz"
42
+ npm install "./opencode-fs-plugin-${VERSION}.tgz"
43
+ ```
44
+
45
+ Add the installed directory to the OpenCode config:
46
+
47
+ ```jsonc
48
+ {
49
+ "plugins": ["./node_modules/opencode-fs-plugin"]
50
+ }
51
+ ```
52
+
53
+ Plugin paths resolve from the config file that contains them, so use an absolute
54
+ path in the global config. The tarball contains `src/`, `skills/`, `SPEC.md` and
55
+ `INSTALL.md`; npm installs its runtime dependencies. Do not unpack it by hand.
56
+
57
+ OpenCode does not accept the release asset URL or a `.tgz` file directly in
58
+ `plugins`; install it with npm first and point at the installed directory.
59
+
60
+ ### From a Git tag
61
+
62
+ Every release is tagged `v<version>`. Add the tag directly to the plugin list;
63
+ OpenCode installs it from Git:
64
+
65
+ ```jsonc
66
+ {
67
+ "plugins": ["github:masterjg/opencode-fs-plugin#v1.0.1"]
68
+ }
69
+ ```
70
+
71
+ `opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.0.1'` installs the
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.0.1`. A tag is
74
+ checked for updates; use a full commit hash to pin it.
75
+
76
+ Git plugins are installed under OpenCode's cache, so their package path is not
77
+ stable. For a stable skill path, install the tag with npm instead:
78
+
79
+ ```bash
80
+ npm install "github:masterjg/opencode-fs-plugin#v1.0.1"
81
+ ```
82
+
83
+ Then configure `./node_modules/opencode-fs-plugin` in `plugins` as in the
84
+ tarball section, and use the packaged skill path below.
85
+
86
+ ### From a source checkout
87
+
88
+ ```jsonc
89
+ {
90
+ "plugins": ["./repos/opencode-fs-plugin"]
91
+ }
92
+ ```
93
+
94
+ Use the absolute path if the checkout is outside the config directory.
95
+
96
+ ## Install the skill
97
+
98
+ If you already use the config-repo copy at
99
+ `~/.config/opencode/skills/filesystem`, keep that one; it is already discovered.
100
+ The plugin copy is for standalone installs and for keeping the skill versioned
101
+ with the tools.
102
+
103
+ ### Option A — register the packaged skills directory
104
+
105
+ For an npm, release-tarball, or Git-tag install in a project:
106
+
107
+ ```jsonc
108
+ {
109
+ "skills": ["./node_modules/opencode-fs-plugin/skills"]
110
+ }
111
+ ```
112
+
113
+ For a source checkout:
114
+
115
+ ```jsonc
116
+ {
117
+ "skills": ["~/.config/opencode/repos/opencode-fs-plugin/skills"]
118
+ }
119
+ ```
120
+
121
+ A plugin loaded straight from a `github:` spec has no stable package path, so
122
+ register the skill only for the tarball and npm installs above. Use an absolute
123
+ skill path when the plugin is installed globally, because relative skill paths
124
+ resolve from the active OpenCode working directory, not from the config file.
125
+ The skill ID is `filesystem`, derived from the directory name, not from the
126
+ frontmatter display name.
127
+
128
+ ### Option B — symlink into the global discovery directory
129
+
130
+ OpenCode automatically discovers skills under `~/.config/opencode/skills`.
131
+
132
+ From a source checkout:
133
+
134
+ ```bash
135
+ PLUGIN="${HOME}/.config/opencode/repos/opencode-fs-plugin"
136
+ mkdir -p "${HOME}/.config/opencode/skills"
137
+ ln -s "${PLUGIN}/skills/filesystem" "${HOME}/.config/opencode/skills/filesystem"
138
+ ```
139
+
140
+ From a project install:
141
+
142
+ ```bash
143
+ mkdir -p "${HOME}/.config/opencode/skills"
144
+ ln -s "$(pwd)/node_modules/opencode-fs-plugin/skills/filesystem" \
145
+ "${HOME}/.config/opencode/skills/filesystem"
146
+ ```
147
+
148
+ Use a symlink rather than a copy so updates to the installed package update the
149
+ active skill.
150
+
151
+ If `~/.config/opencode/skills/filesystem` already exists as a regular directory,
152
+ keep that copy or replace it deliberately; do not create a duplicate ID by
153
+ accident.
154
+
155
+ ## Verify
156
+
157
+ Start a Worker session and load it explicitly:
158
+
159
+ ```text
160
+ @filesystem
161
+ ```
162
+
163
+ Or call the `skill` tool with:
164
+
165
+ ```json
166
+ { "id": "filesystem" }
167
+ ```
168
+
169
+ The skill is advertised with its `description`; OpenCode shows only the ID, name
170
+ and description until the model loads it.
171
+
172
+ ## Agent installation prompt
173
+
174
+ To let a coding agent install the plugin, use:
175
+
176
+ ```text
177
+ Install opencode-fs-plugin 1.0.1 with "npm install opencode-fs-plugin@1.0.1",
178
+ or from its release tarball or the Git tag
179
+ "github:masterjg/opencode-fs-plugin#v1.0.1". Add
180
+ "./node_modules/opencode-fs-plugin" to the plugins array in opencode.jsonc, add
181
+ "./node_modules/opencode-fs-plugin/skills" to the skills array, then verify that
182
+ the filesystem skill loads with the skill tool using id "filesystem".
183
+ ```
184
+
185
+ The agent should edit `opencode.jsonc` and verify the load; it should not copy
186
+ the Markdown by hand.
package/LICENSE ADDED
@@ -0,0 +1,225 @@
1
+ Eclipse Public License - v 2.0
2
+ THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC
3
+ LICENSE (“AGREEMENT”). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM
4
+ CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
5
+
6
+ 1. DEFINITIONS
7
+ “Contribution” means:
8
+
9
+ a) in the case of the initial Contributor, the initial content Distributed under
10
+ this Agreement, and b) in the case of each subsequent Contributor:
11
+ i) changes to the Program, and
12
+ ii) additions to the Program;
13
+ where such changes and/or additions to the Program originate from and are
14
+ Distributed by that particular Contributor. A Contribution “originates” from a
15
+ Contributor if it was added to the Program by such Contributor itself or anyone
16
+ acting on such Contributor's behalf. Contributions do not include changes or
17
+ additions to the Program that are not Modified Works. “Contributor” means any
18
+ person or entity that Distributes the Program.
19
+
20
+ “Licensed Patents” mean patent claims licensable by a Contributor which are
21
+ necessarily infringed by the use or sale of its Contribution alone or when
22
+ combined with the Program.
23
+
24
+ “Program” means the Contributions Distributed in accordance with this Agreement.
25
+
26
+ “Recipient” means anyone who receives the Program under this Agreement or any
27
+ Secondary License (as applicable), including Contributors.
28
+
29
+ “Derivative Works” shall mean any work, whether in Source Code or other form,
30
+ that is based on (or derived from) the Program and for which the editorial
31
+ revisions, annotations, elaborations, or other modifications represent, as a
32
+ whole, an original work of authorship.
33
+
34
+ “Modified Works” shall mean any work in Source Code or other form that results
35
+ from an addition to, deletion from, or modification of the contents of the
36
+ Program, including, for purposes of clarity any new file in Source Code form
37
+ that contains any contents of the Program. Modified Works shall not include
38
+ works that contain only declarations, interfaces, types, classes, structures, or
39
+ files of the Program solely in each case in order to link to, bind by name, or
40
+ subclass the Program or Modified Works thereof.
41
+
42
+ “Distribute” means the acts of a) distributing or b) making available in any
43
+ manner that enables the transfer of a copy.
44
+
45
+ “Source Code” means the form of a Program preferred for making modifications,
46
+ including but not limited to software source code, documentation source, and
47
+ configuration files.
48
+
49
+ “Secondary License” means either the GNU General Public License, Version 2.0, or
50
+ any later versions of that license, including any exceptions or additional
51
+ permissions as identified by the initial Contributor.
52
+
53
+ 2. GRANT OF RIGHTS
54
+ a) Subject to the terms of this Agreement, each Contributor hereby grants
55
+ Recipient a non-exclusive, worldwide, royalty-free copyright license to
56
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
57
+ Distribute and sublicense the Contribution of such Contributor, if any, and such
58
+ Derivative Works. b) Subject to the terms of this Agreement, each Contributor
59
+ hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license
60
+ under Licensed Patents to make, use, sell, offer to sell, import and otherwise
61
+ transfer the Contribution of such Contributor, if any, in Source Code or other
62
+ form. This patent license shall apply to the combination of the Contribution and
63
+ the Program if, at the time the Contribution is added by the Contributor, such
64
+ addition of the Contribution causes such combination to be covered by the
65
+ Licensed Patents. The patent license shall not apply to any other combinations
66
+ which include the Contribution. No hardware per se is licensed hereunder. c)
67
+ Recipient understands that although each Contributor grants the licenses to its
68
+ Contributions set forth herein, no assurances are provided by any Contributor
69
+ that the Program does not infringe the patent or other intellectual property
70
+ rights of any other entity. Each Contributor disclaims any liability to
71
+ Recipient for claims brought by any other entity based on infringement of
72
+ intellectual property rights or otherwise. As a condition to exercising the
73
+ rights and licenses granted hereunder, each Recipient hereby assumes sole
74
+ responsibility to secure any other intellectual property rights needed, if any.
75
+ For example, if a third party patent license is required to allow Recipient to
76
+ Distribute the Program, it is Recipient's responsibility to acquire that license
77
+ before distributing the Program. d) Each Contributor represents that to its
78
+ knowledge it has sufficient copyright rights in its Contribution, if any, to
79
+ grant the copyright license set forth in this Agreement. e) Notwithstanding the
80
+ terms of any Secondary License, no Contributor makes additional grants to any
81
+ Recipient (other than those set forth in this Agreement) as a result of such
82
+ Recipient's receipt of the Program under the terms of a Secondary License (if
83
+ permitted under the terms of Section 3). 3. REQUIREMENTS
84
+ 3.1 If a Contributor Distributes the Program in any form, then:
85
+
86
+ a) the Program must also be made available as Source Code, in accordance with
87
+ section 3.2, and the Contributor must accompany the Program with a statement
88
+ that the Source Code for the Program is available under this Agreement, and
89
+ informs Recipients how to obtain it in a reasonable manner on or through a
90
+ medium customarily used for software exchange; and b) the Contributor may
91
+ Distribute the Program under a license different than this Agreement, provided
92
+ that such license: i) effectively disclaims on behalf of all other Contributors
93
+ all warranties and conditions, express and implied, including warranties or
94
+ conditions of title and non-infringement, and implied warranties or conditions
95
+ of merchantability and fitness for a particular purpose; ii) effectively
96
+ excludes on behalf of all other Contributors all liability for damages,
97
+ including direct, indirect, special, incidental and consequential damages, such
98
+ as lost profits; iii) does not attempt to limit or alter the recipients' rights
99
+ in the Source Code under section 3.2; and iv) requires any subsequent
100
+ distribution of the Program by any party to be under a license that satisfies
101
+ the requirements of this section 3. 3.2 When the Program is Distributed as
102
+ Source Code:
103
+
104
+ a) it must be made available under this Agreement, or if the Program (i) is
105
+ combined with other material in a separate file or files made available under a
106
+ Secondary License, and (ii) the initial Contributor attached to the Source Code
107
+ the notice described in Exhibit A of this Agreement, then the Program may be
108
+ made available under the terms of such Secondary Licenses, and b) a copy of this
109
+ Agreement must be included with each copy of the Program.
110
+ 3.3 Contributors may not remove or alter any copyright, patent, trademark,
111
+ attribution notices, disclaimers of warranty, or limitations of liability
112
+ (‘notices’) contained within the Program from any copy of the Program which they
113
+ Distribute, provided that Contributors may add their own appropriate notices.
114
+
115
+ 4. COMMERCIAL DISTRIBUTION
116
+ Commercial distributors of software may accept certain responsibilities with
117
+ respect to end users, business partners and the like. While this license is
118
+ intended to facilitate the commercial use of the Program, the Contributor who
119
+ includes the Program in a commercial product offering should do so in a manner
120
+ which does not create potential liability for other Contributors. Therefore, if
121
+ a Contributor includes the Program in a commercial product offering, such
122
+ Contributor (“Commercial Contributor”) hereby agrees to defend and indemnify
123
+ every other Contributor (“Indemnified Contributor”) against any losses, damages
124
+ and costs (collectively “Losses”) arising from claims, lawsuits and other legal
125
+ actions brought by a third party against the Indemnified Contributor to the
126
+ extent caused by the acts or omissions of such Commercial Contributor in
127
+ connection with its distribution of the Program in a commercial product
128
+ offering. The obligations in this section do not apply to any claims or Losses
129
+ relating to any actual or alleged intellectual property infringement. In order
130
+ to qualify, an Indemnified Contributor must: a) promptly notify the Commercial
131
+ Contributor in writing of such claim, and b) allow the Commercial Contributor to
132
+ control, and cooperate with the Commercial Contributor in, the defense and any
133
+ related settlement negotiations. The Indemnified Contributor may participate in
134
+ any such claim at its own expense.
135
+
136
+ For example, a Contributor might include the Program in a commercial product
137
+ offering, Product X. That Contributor is then a Commercial Contributor. If that
138
+ Commercial Contributor then makes performance claims, or offers warranties
139
+ related to Product X, those performance claims and warranties are such
140
+ Commercial Contributor's responsibility alone. Under this section, the
141
+ Commercial Contributor would have to defend claims against the other
142
+ Contributors related to those performance claims and warranties, and if a court
143
+ requires any other Contributor to pay any damages as a result, the Commercial
144
+ Contributor must pay those damages.
145
+
146
+ 5. NO WARRANTY
147
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY
148
+ APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN “AS IS” BASIS, WITHOUT WARRANTIES
149
+ OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
150
+ LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
151
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
152
+ responsible for determining the appropriateness of using and distributing the
153
+ Program and assumes all risks associated with its exercise of rights under this
154
+ Agreement, including but not limited to the risks and costs of program errors,
155
+ compliance with applicable laws, damage to or loss of data, programs or
156
+ equipment, and unavailability or interruption of operations.
157
+
158
+ 6. DISCLAIMER OF LIABILITY
159
+ EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT PERMITTED BY
160
+ APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY
161
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
162
+ DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY
163
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
164
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
165
+ THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF
166
+ THE POSSIBILITY OF SUCH DAMAGES.
167
+
168
+ 7. GENERAL
169
+ If any provision of this Agreement is invalid or unenforceable under applicable
170
+ law, it shall not affect the validity or enforceability of the remainder of the
171
+ terms of this Agreement, and without further action by the parties hereto, such
172
+ provision shall be reformed to the minimum extent necessary to make such
173
+ provision valid and enforceable.
174
+
175
+ If Recipient institutes patent litigation against any entity (including a
176
+ cross-claim or counterclaim in a lawsuit) alleging that the Program itself
177
+ (excluding combinations of the Program with other software or hardware)
178
+ infringes such Recipient's patent(s), then such Recipient's rights granted under
179
+ Section 2(b) shall terminate as of the date such litigation is filed.
180
+
181
+ All Recipient's rights under this Agreement shall terminate if it fails to
182
+ comply with any of the material terms or conditions of this Agreement and does
183
+ not cure such failure in a reasonable period of time after becoming aware of
184
+ such noncompliance. If all Recipient's rights under this Agreement terminate,
185
+ Recipient agrees to cease use and distribution of the Program as soon as
186
+ reasonably practicable. However, Recipient's obligations under this Agreement
187
+ and any licenses granted by Recipient relating to the Program shall continue and
188
+ survive.
189
+
190
+ Everyone is permitted to copy and distribute copies of this Agreement, but in
191
+ order to avoid inconsistency the Agreement is copyrighted and may only be
192
+ modified in the following manner. The Agreement Steward reserves the right to
193
+ publish new versions (including revisions) of this Agreement from time to time.
194
+ No one other than the Agreement Steward has the right to modify this Agreement.
195
+ The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation
196
+ may assign the responsibility to serve as the Agreement Steward to a suitable
197
+ separate entity. Each new version of the Agreement will be given a
198
+ distinguishing version number. The Program (including Contributions) may always
199
+ be Distributed subject to the version of the Agreement under which it was
200
+ received. In addition, after a new version of the Agreement is published,
201
+ Contributor may elect to Distribute the Program (including its Contributions)
202
+ under the new version.
203
+
204
+ Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives
205
+ no rights or licenses to the intellectual property of any Contributor under this
206
+ Agreement, whether expressly, by implication, estoppel or otherwise. All rights
207
+ in the Program not expressly granted under this Agreement are reserved. Nothing
208
+ in this Agreement is intended to be enforceable by any entity that is not a
209
+ Contributor or Recipient. No third-party beneficiary rights are created under
210
+ this Agreement.
211
+
212
+ Exhibit A – Form of Secondary Licenses Notice
213
+ “This Source Code may also be made available under the following Secondary
214
+ Licenses when the conditions for such availability set forth in the Eclipse
215
+ Public License, v. 2.0 are satisfied: {name license(s), version(s), and
216
+ exceptions or additional permissions here}.”
217
+
218
+ Simply including a copy of this Agreement, including this Exhibit A is not
219
+ sufficient to license the Source Code under Secondary Licenses.
220
+
221
+ If it is not possible or desirable to put the notice in a particular file, then
222
+ You may include the notice in a location (such as a LICENSE file in a relevant
223
+ directory) where a recipient would be likely to look for such a notice.
224
+
225
+ You may add additional accurate notices of copyright ownership.
package/README.md CHANGED
@@ -1,3 +1,266 @@
1
- # Temporary Holding Version
1
+ # opencode-fs-plugin
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ An OpenCode 2 plugin that adds a Linux-style filesystem and text toolkit under
4
+ the `fs` namespace. It is a maintained fork of
5
+ [`kiu345/opencode-fs-plugin`](https://github.com/kiu345/opencode-fs-plugin),
6
+ rewritten with async I/O, permission integration, a symlink-aware sandbox, and
7
+ unit, end-to-end and coverage tests.
8
+
9
+ ## Tools
10
+
11
+ | Native command | Tool | Main options |
12
+ |---|---|---|
13
+ | `mkdir` | `fs.mkdir` | `parents`, `mode`, `verbose` |
14
+ | `rmdir` | `fs.rmdir` | `parents`, `ignoreNonEmpty`, `verbose` |
15
+ | `rm` | `fs.rm` | `recursive`, `force`, `dir`, `verbose` |
16
+ | `cp` | `fs.cp` | `recursive`, `archive`, `force`, `noClobber`, `update`, `preserve`, `dereference`, `verbose` |
17
+ | `mv` | `fs.mv` | `force`, `noClobber`, `update`, `verbose` |
18
+ | `ls` | `fs.ls` | `all`, `almostAll`, `long`, `human`, `recursive`, `directory`, `inode`, `classify`, `sortBy`, `reverse`, `onePerLine` |
19
+ | `stat` | `fs.stat` | `follow`, `format`, `filesystem` |
20
+ | `touch` | `fs.touch` | `accessOnly`, `modifyOnly`, `noCreate`, `date`, `timestamp`, `reference`, `noDereference` |
21
+ | `truncate` | `fs.truncate` | `size`, `reference`, `noCreate`, `noDereference` |
22
+ | `ln` | `fs.ln` | `symbolic`, `force`, `noDereference`, `relative`, `verbose` |
23
+ | `readlink` | `fs.readlink` | `mode` (`raw`, `canonical`, `existing`, `missing`), `noNewline` |
24
+ | `chmod` | `fs.chmod` | octal/symbolic mode, `reference`, `recursive`, `noDereference`, `verbose`, `changes`, `silent` |
25
+ | `sha256sum`/`md5sum` | `fs.hash` | `algorithm`, `tag`; hashes files or stdin |
26
+ | `du` | `fs.du` | `summarize`, `all`, `human`, `total`, `maxDepth`, `follow`, `oneFileSystem` |
27
+ | `df` | `fs.df` | `human`, `inodes`, `printType`, `all` |
28
+ | `find` | `fs.find` | `name`, `iname`, `pathPattern`, `type`, `size`, `mtime`, `mmin`, `maxDepth`, `minDepth`, `empty`, `perm`, `newer`, `follow`, `print0`, `sort` |
29
+ | `cat` | `fs.cat` | `number`, `numberNonBlank`, `squeezeBlank`, `showEnds`, `showTabs`, `showNonPrinting` |
30
+ | `head` | `fs.head` | `lines`, `bytes`, `quiet`, `verbose` |
31
+ | `tail` | `fs.tail` | `lines`, `bytes`, `fromStart`, `quiet`, `verbose` |
32
+ | `tee` | `fs.tee` | `append`, `content` |
33
+ | `wc` | `fs.wc` | `lines`, `words`, `bytes`, `chars`, `maxLineLength` |
34
+ | `sort` | `fs.sort` | `numeric`, `reverse`, `unique`, `ignoreCase`, `ignoreLeadingBlanks`, `field`, `separator` |
35
+ | `uniq` | `fs.uniq` | `count`, `repeated`, `uniqueOnly`, `ignoreCase`, `skipFields`, `skipChars` |
36
+ | `cut` | `fs.cut` | `fields`, `characters`, `bytes`, `delimiter`, `outputDelimiter`, `complement`, `onlyDelimited` |
37
+ | `tr` | `fs.tr` | `set1`, `set2`, `delete`, `squeeze`, `complement`; ranges and classes |
38
+ | `sed` | `fs.sed` | `script`, `expressions`, `inPlace`, `extendedRegexp`, `quiet`; `s///` subset |
39
+ | `grep` | `fs.grep` | `recursive`, `include`, `exclude`, `ignoreCase`, `invert`, `lineNumbers`, `withFilename`, `noFilename`, `filesWithMatches`, `filesWithoutMatch`, `count`, `onlyMatching`, `word`, `line`, `fixed`, `context`, `before`, `after`, `maxCount`, `noMessages` |
40
+ | `tar` | `fs.tar` | `create`/`extract`/`list`, `gzip`, `directory`, `stripComponents`, `exclude`, `verbose` |
41
+ | `zip` | `fs.zip` | `archive`, `paths`, `level` |
42
+ | `unzip` | `fs.unzip` | `extract`/`list`, `directory`, `overwrite`, `noOverwrite` |
43
+ | `gzip` | `fs.gzip` | `keep`, `force`, `stdout`, `level` |
44
+ | `gunzip` | `fs.gunzip` | `keep`, `force`, `stdout`, `suffix` |
45
+ | `mktemp` | `fs.mktemp` | `template`, `directory`, `tmpdir`, `suffix` |
46
+ | `trash` | `fs.trash` | XDG home trash |
47
+ | `diff` | `fs.diff` | `unified`, `brief`, `recursive`, `ignoreWhitespace`, `ignoreCase`, `exclude` |
48
+ | shell pipe | `fs.pipe` | `stages`, `input`, `output`, `append` |
49
+
50
+ ## Pipe
51
+
52
+ `fs.pipe` joins registered tools through byte buffers. Stages run in order;
53
+ only pipeable tools can be used. `output` and `append` behave like a final
54
+ `tee`.
55
+
56
+ ```js
57
+ await tools.fs.pipe({
58
+ stages: [
59
+ { tool: "cat", args: { paths: ["app.log"] } },
60
+ { tool: "grep", args: { pattern: "ERROR", lineNumbers: true } },
61
+ { tool: "sort", args: { unique: true } },
62
+ ],
63
+ output: "errors.txt",
64
+ })
65
+ ```
66
+
67
+ There is no shell, redirection operator, nested pipe, or `find -exec`.
68
+
69
+ ## Installing from npm
70
+
71
+ Add the registry package directly to the plugin list:
72
+
73
+ ```jsonc
74
+ {
75
+ "plugins": ["opencode-fs-plugin@1.0.1"]
76
+ }
77
+ ```
78
+
79
+ `opencode plugin add opencode-fs-plugin@1.0.1` installs it and writes the config
80
+ entry. A bare `opencode-fs-plugin` follows the `latest` tag.
81
+
82
+ OpenCode manages the package under its cache, so the path is not stable. If you
83
+ also want the packaged skill, install it into a project instead:
84
+
85
+ ```bash
86
+ npm install opencode-fs-plugin@1.0.1
87
+ ```
88
+
89
+ ```jsonc
90
+ {
91
+ "plugins": ["./node_modules/opencode-fs-plugin"],
92
+ "skills": ["./node_modules/opencode-fs-plugin/skills"]
93
+ }
94
+ ```
95
+
96
+ ## Installing from a release
97
+
98
+ Download the release tarball, then install it as a normal npm package:
99
+
100
+ ```bash
101
+ VERSION=1.0.1
102
+ curl -L -o "opencode-fs-plugin-${VERSION}.tgz" \
103
+ "https://github.com/masterjg/opencode-fs-plugin/releases/download/v${VERSION}/opencode-fs-plugin-${VERSION}.tgz"
104
+ npm install "./opencode-fs-plugin-${VERSION}.tgz"
105
+ ```
106
+
107
+ Point OpenCode at the installed directory:
108
+
109
+ ```jsonc
110
+ {
111
+ "plugins": ["./node_modules/opencode-fs-plugin"]
112
+ }
113
+ ```
114
+
115
+ Relative paths resolve from the config file that contains them, so use an
116
+ absolute path in the global config. The tarball contains `src/`, `skills/`,
117
+ `SPEC.md` and `INSTALL.md`; npm installs its runtime dependencies. Do not unpack
118
+ it by hand.
119
+
120
+ OpenCode does not accept the release asset URL or a `.tgz` file directly in
121
+ `plugins`; install it with npm first and point at the installed directory.
122
+
123
+ ## Installing from a Git tag
124
+
125
+ Every release is tagged `v<version>`. Add the tag directly to the plugin list;
126
+ OpenCode installs it from Git:
127
+
128
+ ```jsonc
129
+ {
130
+ "plugins": ["github:masterjg/opencode-fs-plugin#v1.0.1"]
131
+ }
132
+ ```
133
+
134
+ `opencode plugin add 'github:masterjg/opencode-fs-plugin#v1.0.1'` installs the
135
+ same spec and writes the config entry. The equivalent full URL is
136
+ `git+https://github.com/masterjg/opencode-fs-plugin.git#v1.0.1`. A tag is
137
+ checked for updates; use a full commit hash to pin it.
138
+
139
+ Git plugins are installed under OpenCode's cache, so their package path is not
140
+ stable. If you also want the packaged skill, install with npm instead:
141
+
142
+ ```bash
143
+ npm install "github:masterjg/opencode-fs-plugin#v1.0.1"
144
+ ```
145
+
146
+ Then use `./node_modules/opencode-fs-plugin` in `plugins` and
147
+ `./node_modules/opencode-fs-plugin/skills` in `skills`.
148
+
149
+ ## Loading from a checkout
150
+
151
+ ```jsonc
152
+ {
153
+ "plugins": [
154
+ "./repos/opencode-fs-plugin"
155
+ ]
156
+ }
157
+ ```
158
+
159
+ The plugin exports TypeScript source directly and targets Node 22+.
160
+
161
+ ## Skill discovery
162
+
163
+ The plugin ships `skills/filesystem/SKILL.md`. OpenCode does not search inside a
164
+ plugin package automatically, so register the directory once:
165
+
166
+ ```jsonc
167
+ {
168
+ "skills": [
169
+ "~/.config/opencode/repos/opencode-fs-plugin/skills"
170
+ ]
171
+ }
172
+ ```
173
+
174
+ If the plugin was installed from the release tarball, the npm registry, or with
175
+ `npm install` from a Git tag into a project's `node_modules`, point at the
176
+ packaged skill instead:
177
+
178
+ ```jsonc
179
+ {
180
+ "skills": [
181
+ "./node_modules/opencode-fs-plugin/skills"
182
+ ]
183
+ }
184
+ ```
185
+
186
+ Relative skill paths resolve from the active working directory, not the config
187
+ file; use an absolute path for a global install. Alternatively, symlink
188
+ `skills/filesystem` into `~/.config/opencode/skills`; OpenCode discovers that
189
+ directory automatically. See [INSTALL.md](INSTALL.md) for all options,
190
+ verification, and an agent-ready installation prompt.
191
+
192
+ The skill ID is `filesystem`; `@filesystem` loads it explicitly.
193
+
194
+ ## Permissions
195
+
196
+ Every tool asserts an action named after the tool (`fs_cp`, `fs_rm`,
197
+ `fs_pipe` stages, and so on). Internal paths use project-relative resources;
198
+ external targets first require `external_directory` on the absolute boundary.
199
+ `allow always` persists the same patterns as the built-in tools.
200
+
201
+ Agent rules can use wildcards:
202
+
203
+ ```jsonc
204
+ {
205
+ "permissions": [
206
+ { "action": "fs_*", "resource": "*", "effect": "deny" }
207
+ ]
208
+ }
209
+ ```
210
+
211
+ To direct agents to this toolkit instead of the built-in shell, deny `shell`:
212
+
213
+ ```jsonc
214
+ {
215
+ "permissions": [
216
+ { "action": "shell", "resource": "*", "effect": "deny" }
217
+ ]
218
+ }
219
+ ```
220
+
221
+ This removes the built-in shell tool; MCP servers and other tools that run
222
+ commands are unaffected. Apply it globally or under `agents.<id>.permissions`
223
+ when only some agents should be shell-free.
224
+
225
+ ## Safety
226
+
227
+ - The sandbox root, its ancestors, `/`, `$HOME` and core system directories are
228
+ hard stops for destructive operations.
229
+ - Paths are resolved with symlink awareness. Traversing a link that escapes the
230
+ project requires `external_directory`; removing or renaming the link itself is
231
+ internal.
232
+ - Archive extraction rejects absolute paths, `..`, and escaping symlinks.
233
+ - `rm` is permanent. `trash` uses the XDG home trash and refuses cross-device
234
+ moves instead of silently copying.
235
+ - The sandbox is a guardrail, not a kernel security boundary. Symlink races
236
+ remain possible.
237
+
238
+ ## Development
239
+
240
+ ```bash
241
+ npm install
242
+ npm run typecheck
243
+ npm test
244
+ npm run coverage
245
+ ```
246
+
247
+ `npm run coverage` enforces 100% statements, branches, functions and lines.
248
+ A small number of OS-error branches are marked with `/* v8 ignore next */` when
249
+ they cannot be produced deterministically; all tool logic and normal error
250
+ paths are exercised.
251
+
252
+ ## Releases
253
+
254
+ Every push to `main` runs `.github/workflows/release.yml`. It reads the version
255
+ from `package.json`, runs typecheck and the 100% coverage gate, packs the npm
256
+ tarball, uploads it as a workflow artifact, publishes it to npm with provenance
257
+ when the version is new, and creates a GitHub release tagged `v<version>` when
258
+ that release does not exist yet. Bump the version in `package.json` to publish a
259
+ new release; an unchanged version is skipped with a notice.
260
+
261
+ The npm step reads the `NPM_TOKEN` repository secret, which must be an npm
262
+ automation token with publish access to `opencode-fs-plugin`.
263
+
264
+ ## License
265
+
266
+ EPL-2.0. The original project and this fork remain under the same license.