@procedures/fs 0.0.0-stage → 0.2.0

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 (90) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +21 -0
  3. package/README.md +895 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/index.d.ts +17 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +17 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/module.d.ts +22 -0
  10. package/dist/module.d.ts.map +1 -0
  11. package/dist/module.js +203 -0
  12. package/dist/module.js.map +1 -0
  13. package/dist/procedures/fs/copy.d.ts +11 -0
  14. package/dist/procedures/fs/copy.d.ts.map +1 -0
  15. package/dist/procedures/fs/copy.js +21 -0
  16. package/dist/procedures/fs/copy.js.map +1 -0
  17. package/dist/procedures/fs/exists.d.ts +11 -0
  18. package/dist/procedures/fs/exists.d.ts.map +1 -0
  19. package/dist/procedures/fs/exists.js +20 -0
  20. package/dist/procedures/fs/exists.js.map +1 -0
  21. package/dist/procedures/fs/glob.d.ts +17 -0
  22. package/dist/procedures/fs/glob.d.ts.map +1 -0
  23. package/dist/procedures/fs/glob.js +85 -0
  24. package/dist/procedures/fs/glob.js.map +1 -0
  25. package/dist/procedures/fs/index.d.ts +12 -0
  26. package/dist/procedures/fs/index.d.ts.map +1 -0
  27. package/dist/procedures/fs/index.js +12 -0
  28. package/dist/procedures/fs/index.js.map +1 -0
  29. package/dist/procedures/fs/json.d.ts +11 -0
  30. package/dist/procedures/fs/json.d.ts.map +1 -0
  31. package/dist/procedures/fs/json.js +16 -0
  32. package/dist/procedures/fs/json.js.map +1 -0
  33. package/dist/procedures/fs/mkdir.d.ts +11 -0
  34. package/dist/procedures/fs/mkdir.d.ts.map +1 -0
  35. package/dist/procedures/fs/mkdir.js +39 -0
  36. package/dist/procedures/fs/mkdir.js.map +1 -0
  37. package/dist/procedures/fs/move.d.ts +11 -0
  38. package/dist/procedures/fs/move.d.ts.map +1 -0
  39. package/dist/procedures/fs/move.js +46 -0
  40. package/dist/procedures/fs/move.js.map +1 -0
  41. package/dist/procedures/fs/read.d.ts +11 -0
  42. package/dist/procedures/fs/read.d.ts.map +1 -0
  43. package/dist/procedures/fs/read.js +21 -0
  44. package/dist/procedures/fs/read.js.map +1 -0
  45. package/dist/procedures/fs/readdir.d.ts +11 -0
  46. package/dist/procedures/fs/readdir.d.ts.map +1 -0
  47. package/dist/procedures/fs/readdir.js +38 -0
  48. package/dist/procedures/fs/readdir.js.map +1 -0
  49. package/dist/procedures/fs/rm.d.ts +11 -0
  50. package/dist/procedures/fs/rm.d.ts.map +1 -0
  51. package/dist/procedures/fs/rm.js +30 -0
  52. package/dist/procedures/fs/rm.js.map +1 -0
  53. package/dist/procedures/fs/stat.d.ts +11 -0
  54. package/dist/procedures/fs/stat.d.ts.map +1 -0
  55. package/dist/procedures/fs/stat.js +29 -0
  56. package/dist/procedures/fs/stat.js.map +1 -0
  57. package/dist/procedures/fs/write.d.ts +11 -0
  58. package/dist/procedures/fs/write.d.ts.map +1 -0
  59. package/dist/procedures/fs/write.js +24 -0
  60. package/dist/procedures/fs/write.js.map +1 -0
  61. package/dist/procedures/fs.d.ts +5 -0
  62. package/dist/procedures/fs.d.ts.map +1 -0
  63. package/dist/procedures/fs.js +5 -0
  64. package/dist/procedures/fs.js.map +1 -0
  65. package/dist/register.d.ts +7 -0
  66. package/dist/register.d.ts.map +1 -0
  67. package/dist/register.js +9 -0
  68. package/dist/register.js.map +1 -0
  69. package/dist/types.d.ts +187 -0
  70. package/dist/types.d.ts.map +1 -0
  71. package/dist/types.js +197 -0
  72. package/dist/types.js.map +1 -0
  73. package/package.json +77 -3
  74. package/src/index.ts +17 -0
  75. package/src/module.ts +265 -0
  76. package/src/procedures/fs/copy.ts +24 -0
  77. package/src/procedures/fs/exists.ts +20 -0
  78. package/src/procedures/fs/glob.ts +92 -0
  79. package/src/procedures/fs/index.ts +11 -0
  80. package/src/procedures/fs/json.ts +21 -0
  81. package/src/procedures/fs/mkdir.ts +43 -0
  82. package/src/procedures/fs/move.ts +47 -0
  83. package/src/procedures/fs/read.ts +23 -0
  84. package/src/procedures/fs/readdir.ts +44 -0
  85. package/src/procedures/fs/rm.ts +31 -0
  86. package/src/procedures/fs/stat.ts +30 -0
  87. package/src/procedures/fs/write.ts +27 -0
  88. package/src/procedures/fs.ts +5 -0
  89. package/src/register.ts +11 -0
  90. package/src/types.ts +407 -0
package/dist/types.js ADDED
@@ -0,0 +1,197 @@
1
+ /**
2
+ * Type definitions for client-fs procedures
3
+ */
4
+ import { z } from "zod";
5
+ // =============================================================================
6
+ // read Types - Read file contents
7
+ // =============================================================================
8
+ export const ReadInputSchema = z.object({
9
+ /** Path to file to read */
10
+ path: z.string().describe("Path to file to read"),
11
+ /** File encoding (default: utf8) */
12
+ encoding: z.string().optional().default("utf8").describe("File encoding (default: utf8)"),
13
+ });
14
+ // =============================================================================
15
+ // write Types - Write content to file
16
+ // =============================================================================
17
+ export const WriteInputSchema = z.object({
18
+ /** Path to file to write */
19
+ path: z.string().describe("Path to file to write"),
20
+ /** Content to write */
21
+ content: z.string().describe("Content to write"),
22
+ /** File encoding (default: utf8) */
23
+ encoding: z.string().optional().default("utf8").describe("File encoding (default: utf8)"),
24
+ /** Write mode: write (overwrite) or append (default: write) */
25
+ mode: z.enum(["write", "append"]).optional().default("write").describe("Write mode: write (overwrite) or append (default: write)"),
26
+ });
27
+ export const FileTypeInputSchema = z.object({
28
+ /** Path to check */
29
+ path: z.string().describe("Path to check"),
30
+ });
31
+ // =============================================================================
32
+ // exists Types - Check if file or directory exists
33
+ // =============================================================================
34
+ export const ExistsInputSchema = z.object({
35
+ /** Path to check */
36
+ path: z.string().describe("Path to check"),
37
+ });
38
+ export var FileType;
39
+ (function (FileType) {
40
+ FileType["File"] = "file";
41
+ FileType["Directory"] = "directory";
42
+ FileType["Other"] = "other";
43
+ })(FileType || (FileType = {}));
44
+ // =============================================================================
45
+ // mkdir Types - Create directory
46
+ // =============================================================================
47
+ export const MkdirInputSchema = z.object({
48
+ /** Path of directory to create */
49
+ path: z.string().describe("Path of directory to create"),
50
+ /** Create parent directories if needed (default: true) */
51
+ recursive: z.boolean().optional().default(true).describe("Create parent directories if needed (default: true)"),
52
+ });
53
+ // =============================================================================
54
+ // rm Types - Remove file or directory
55
+ // =============================================================================
56
+ export const RmInputSchema = z.object({
57
+ /** Path to remove */
58
+ path: z.string().describe("Path to remove"),
59
+ /** Remove directories and contents recursively (default: false) */
60
+ recursive: z.boolean().optional().default(false).describe("Remove directories and contents recursively (default: false)"),
61
+ /** Ignore errors if path doesn't exist (default: false) */
62
+ force: z.boolean().optional().default(false).describe("Ignore errors if path doesn't exist (default: false)"),
63
+ });
64
+ // =============================================================================
65
+ // readdir Types - Read directory contents
66
+ // =============================================================================
67
+ export const ReaddirInputSchema = z.object({
68
+ /** Path of directory to read */
69
+ path: z.string().describe("Path of directory to read"),
70
+ /** Read subdirectories recursively (default: false) */
71
+ recursive: z.boolean().optional().default(false).describe("Read subdirectories recursively (default: false)"),
72
+ /** Include file stats with each entry (default: false) */
73
+ includeStats: z.boolean().optional().default(false).describe("Include file stats with each entry (default: false)"),
74
+ });
75
+ // =============================================================================
76
+ // stat Types - Get file or directory stats
77
+ // =============================================================================
78
+ export const StatInputSchema = z.object({
79
+ /** Path to get stats for */
80
+ path: z.string().describe("Path to get stats for"),
81
+ });
82
+ // =============================================================================
83
+ // copy Types - Copy file or directory
84
+ // =============================================================================
85
+ export const CopyInputSchema = z.object({
86
+ /** Source path */
87
+ src: z.string().describe("Source path"),
88
+ /** Destination path */
89
+ dest: z.string().describe("Destination path"),
90
+ /** Copy directories recursively (default: true) */
91
+ recursive: z.boolean().optional().default(true).describe("Copy directories recursively (default: true)"),
92
+ /** Overwrite existing files (default: false) */
93
+ overwrite: z.boolean().optional().default(false).describe("Overwrite existing files (default: false)"),
94
+ });
95
+ // =============================================================================
96
+ // move Types - Move or rename file/directory
97
+ // =============================================================================
98
+ export const MoveInputSchema = z.object({
99
+ /** Source path */
100
+ src: z.string().describe("Source path"),
101
+ /** Destination path */
102
+ dest: z.string().describe("Destination path"),
103
+ /** Overwrite existing files (default: false) */
104
+ overwrite: z.boolean().optional().default(false).describe("Overwrite existing files (default: false)"),
105
+ });
106
+ // =============================================================================
107
+ // glob Types - Find files matching glob pattern
108
+ // =============================================================================
109
+ export const GlobInputSchema = z.object({
110
+ /** Glob pattern to match */
111
+ pattern: z.string().describe("Glob pattern to match"),
112
+ /** Working directory (default: process.cwd()) */
113
+ cwd: z.string().optional().describe("Working directory (default: process.cwd())"),
114
+ /** Return absolute paths (default: false) */
115
+ absolute: z.boolean().optional().default(false).describe("Return absolute paths (default: false)"),
116
+ /** Include dotfiles (default: false) */
117
+ dot: z.boolean().optional().default(false).describe("Include dotfiles (default: false)"),
118
+ /** Glob patterns of the paths to leave out. The search does not enter the folders that they match. */
119
+ ignore: z.array(z.string()).optional().describe("Glob patterns of the paths to leave out. The search does not enter the folders that they match."),
120
+ });
121
+ // =============================================================================
122
+ // read.json Types - Read and parse JSON file
123
+ // =============================================================================
124
+ export const ReadJsonInputSchema = z.object({
125
+ /** Path to JSON file */
126
+ path: z.string().describe("Path to JSON file"),
127
+ });
128
+ // =============================================================================
129
+ // Output schemas (roadmap 2.1)
130
+ // =============================================================================
131
+ // Loose objects: a field that a schema does not name stays in the result (a strict schema would
132
+ // remove it when the output is validated).
133
+ const fileType = z.enum(FileType).describe("file, directory or other");
134
+ export const StatOutputSchema = z.looseObject({
135
+ path: z.string().describe("The path"),
136
+ type: fileType,
137
+ size: z.number().describe("The size, in bytes"),
138
+ mtime: z.string().describe("The time of the last change (ISO 8601)"),
139
+ ctime: z.string().describe("The time of the last status change (ISO 8601)"),
140
+ atime: z.string().describe("The time of the last access (ISO 8601)"),
141
+ mode: z.number().describe("The mode bits (type and permissions)"),
142
+ });
143
+ export const ReadOutputSchema = z.looseObject({
144
+ content: z.string().describe("The content of the file"),
145
+ path: z.string().describe("The path of the file"),
146
+ stats: StatOutputSchema.describe("The stats of the file"),
147
+ });
148
+ export const WriteOutputSchema = z.looseObject({
149
+ path: z.string().describe("The path of the file"),
150
+ bytesWritten: z.number().describe("The number of bytes written"),
151
+ });
152
+ export const ExistsOutputSchema = z.union([
153
+ z.looseObject({ exists: z.literal(false).describe("The path does not exist") }),
154
+ z.looseObject({
155
+ exists: z.literal(true).describe("The path exists"),
156
+ stats: StatOutputSchema.describe("The stats of the path"),
157
+ }),
158
+ ]);
159
+ export const MkdirOutputSchema = z.looseObject({
160
+ path: z.string().describe("The path of the folder"),
161
+ created: z.boolean().describe("False when the folder existed already"),
162
+ });
163
+ export const RmOutputSchema = z.looseObject({
164
+ path: z.string().describe("The path"),
165
+ removed: z.boolean().describe("False when the path did not exist (with force)"),
166
+ });
167
+ export const ReaddirOutputSchema = z.looseObject({
168
+ path: z.string().describe("The path of the folder"),
169
+ entries: z
170
+ .array(z.looseObject({
171
+ name: z.string().describe("The name of the entry"),
172
+ path: z.string().describe("The full path of the entry"),
173
+ type: fileType,
174
+ stats: StatOutputSchema.optional().describe("The stats, with includeStats"),
175
+ }))
176
+ .describe("The entries of the folder"),
177
+ });
178
+ export const CopyOutputSchema = z.looseObject({
179
+ src: z.string().describe("The source path"),
180
+ dest: z.string().describe("The destination path"),
181
+ });
182
+ export const MoveOutputSchema = z.looseObject({
183
+ src: z.string().describe("The old path"),
184
+ dest: z.string().describe("The new path"),
185
+ });
186
+ export const GlobOutputSchema = z.looseObject({
187
+ pattern: z.string().describe("The glob pattern"),
188
+ matches: z
189
+ .array(z.string())
190
+ .describe('The matching paths, sorted: relative to cwd with "/" separators, or absolute with absolute: true'),
191
+ });
192
+ export const ReadJsonOutputSchema = z.looseObject({
193
+ path: z.string().describe("The path of the file"),
194
+ data: z.unknown().describe("The parsed JSON value"),
195
+ stats: StatOutputSchema.describe("The stats of the file"),
196
+ });
197
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
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oB,GAA8B,CAAC,CAAC,WAAW,CAAC;IAC3E,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;IACjD,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IACnD,KAAK,EAAE,gBAAgB,CAAC,QAAQ,CAAC,uBAAuB,CAAC;CAC1D,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,80 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/package",
2
3
  "name": "@procedures/fs",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
4
+ "version": "0.2.0",
5
+ "description": "File system procedures: read, write, copy, move, glob, exists, mkdir and JSON read and write, callable in process, over RPC or from Claude through MCP.",
6
+ "keywords": [
7
+ "filesystem",
8
+ "fs",
9
+ "glob",
10
+ "files",
11
+ "procedures",
12
+ "rpc"
13
+ ],
14
+ "homepage": "https://mark1russell7.github.io/client/",
15
+ "bugs": {
16
+ "url": "https://github.com/mark1russell7/client/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/mark1russell7/client.git",
21
+ "directory": "packages/client-fs"
22
+ },
23
+ "license": "MIT",
24
+ "author": "Mark Russell (https://github.com/mark1russell7)",
25
+ "type": "module",
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "import": "./dist/index.js"
32
+ },
33
+ "./module": {
34
+ "types": "./dist/module.d.ts",
35
+ "import": "./dist/module.js"
36
+ },
37
+ "./register": {
38
+ "types": "./dist/register.d.ts",
39
+ "import": "./dist/register.js"
40
+ }
41
+ },
42
+ "files": [
43
+ "dist",
44
+ "src",
45
+ "!src/**/*.test.ts",
46
+ "!src/**/*.test.tsx",
47
+ "!src/**/__tests__",
48
+ "CHANGELOG.md"
49
+ ],
50
+ "sideEffects": [
51
+ "./dist/register.js"
52
+ ],
53
+ "engines": {
54
+ "node": ">=22"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public",
58
+ "provenance": true
59
+ },
60
+ "client": {
61
+ "procedures": "./dist/register.js"
62
+ },
63
+ "dependencies": {
64
+ "@procedures/client": "0.2.0",
65
+ "zod": "^4.6.5"
66
+ },
67
+ "devDependencies": {
68
+ "typescript": "^7.0.2",
69
+ "@types/node": "^22.0.0",
70
+ "@mark1russell7/cue": "^1.0.0",
71
+ "vitest": "^5.0.3"
72
+ },
73
+ "scripts": {
74
+ "build": "tsc -b",
75
+ "typecheck": "tsc --noEmit",
76
+ "clean": "rm -rf dist .tsbuildinfo",
77
+ "test": "vitest run",
78
+ "test:watch": "vitest"
79
+ }
6
80
  }
package/src/index.ts ADDED
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Client-FS - Filesystem operations as RPC procedures
3
+ *
4
+ * Provides fs.read, fs.write, fs.exists, and other filesystem procedures.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import { fsProcedures } from "@procedures/fs";
9
+ *
10
+ * // Or use via client.call
11
+ * await client.call(["fs", "read"], { path: "./file.txt" });
12
+ * await client.call(["fs", "write"], { path: "./out.txt", content: "hello" });
13
+ * ```
14
+ */
15
+
16
+ export * from "./procedures/fs.js";
17
+ export * from "./module.js";
package/src/module.ts ADDED
@@ -0,0 +1,265 @@
1
+ /**
2
+ * Module (no side effects): the procedures of this package as data, for `createRegistry()`.
3
+ *
4
+ * Procedure Registration for filesystem operations
5
+ *
6
+ * Registers fs.* procedures with the client system.
7
+ * This file is referenced by package.json's client.procedures field.
8
+ */
9
+
10
+ import { createProcedure, zodAdapter, defineModule, type Effects, type ProcedureModule, PROCEDURE_REGISTRY, registerModules, type ProcedureRegistry } from "@procedures/client";
11
+ import { read } from "./procedures/fs/read.js";
12
+ import { write } from "./procedures/fs/write.js";
13
+ import { exists } from "./procedures/fs/exists.js";
14
+ import { mkdir } from "./procedures/fs/mkdir.js";
15
+ import { rm } from "./procedures/fs/rm.js";
16
+ import { readdir } from "./procedures/fs/readdir.js";
17
+ import { stat } from "./procedures/fs/stat.js";
18
+ import { copy } from "./procedures/fs/copy.js";
19
+ import { move } from "./procedures/fs/move.js";
20
+ import { glob } from "./procedures/fs/glob.js";
21
+ import { readJson } from "./procedures/fs/json.js";
22
+ import {
23
+ ReadInputSchema,
24
+ WriteInputSchema,
25
+ ExistsInputSchema,
26
+ MkdirInputSchema,
27
+ RmInputSchema,
28
+ ReaddirInputSchema,
29
+ StatInputSchema,
30
+ CopyInputSchema,
31
+ MoveInputSchema,
32
+ GlobInputSchema,
33
+ ReadJsonInputSchema,
34
+ type ReadInput,
35
+ type ReadOutput,
36
+ type WriteInput,
37
+ type WriteOutput,
38
+ type ExistsInput,
39
+ type ExistsOutput,
40
+ type MkdirInput,
41
+ type MkdirOutput,
42
+ type RmInput,
43
+ type RmOutput,
44
+ type ReaddirInput,
45
+ type ReaddirOutput,
46
+ type StatInput,
47
+ type StatOutput,
48
+ type CopyInput,
49
+ type CopyOutput,
50
+ type MoveInput,
51
+ type MoveOutput,
52
+ type GlobInput,
53
+ type GlobOutput,
54
+ type ReadJsonInput,
55
+ type ReadJsonOutput,
56
+ ReadOutputSchema,
57
+ WriteOutputSchema,
58
+ ExistsOutputSchema,
59
+ MkdirOutputSchema,
60
+ RmOutputSchema,
61
+ ReaddirOutputSchema,
62
+ StatOutputSchema,
63
+ CopyOutputSchema,
64
+ MoveOutputSchema,
65
+ GlobOutputSchema,
66
+ ReadJsonOutputSchema,
67
+ } from "./types.js";
68
+
69
+ // =============================================================================
70
+ // Procedure Definitions
71
+ // =============================================================================
72
+
73
+ /** The effects of a procedure that reads the files of the host and changes nothing. */
74
+ const READS_FILES: Effects = { reads: ["fs"], writes: [] };
75
+
76
+ const fsReadProcedure = createProcedure()
77
+ .path(["fs", "read"])
78
+ .input(zodAdapter<ReadInput>(ReadInputSchema))
79
+ .output(zodAdapter<ReadOutput>(ReadOutputSchema))
80
+ .meta({
81
+ description: "Read file contents",
82
+ args: ["path"],
83
+ shorts: { encoding: "e" },
84
+ output: "json",
85
+ effects: READS_FILES,
86
+ })
87
+ .handler(read)
88
+ .build();
89
+
90
+ const fsWriteProcedure = createProcedure()
91
+ .path(["fs", "write"])
92
+ .input(zodAdapter<WriteInput>(WriteInputSchema))
93
+ .output(zodAdapter<WriteOutput>(WriteOutputSchema))
94
+ .meta({
95
+ description: "Write content to file",
96
+ args: ["path", "content"],
97
+ shorts: { encoding: "e", mode: "m" },
98
+ output: "json",
99
+ // It replaces the file, or appends to it. A second append adds the content again.
100
+ effects: { reads: [], writes: ["fs"] },
101
+ })
102
+ .handler(write)
103
+ .build();
104
+
105
+ const fsExistsProcedure = createProcedure()
106
+ .path(["fs", "exists"])
107
+ .input(zodAdapter<ExistsInput>(ExistsInputSchema))
108
+ .output(zodAdapter<ExistsOutput>(ExistsOutputSchema))
109
+ .meta({
110
+ description: "Check if file or directory exists",
111
+ args: ["path"],
112
+ shorts: {},
113
+ output: "json",
114
+ effects: READS_FILES,
115
+ })
116
+ .handler(exists)
117
+ .build();
118
+
119
+ const fsMkdirProcedure = createProcedure()
120
+ .path(["fs", "mkdir"])
121
+ .input(zodAdapter<MkdirInput>(MkdirInputSchema))
122
+ .output(zodAdapter<MkdirOutput>(MkdirOutputSchema))
123
+ .meta({
124
+ description: "Create directory",
125
+ args: ["path"],
126
+ shorts: { recursive: "r" },
127
+ output: "json",
128
+ // It creates only a missing folder. An existing folder gives `created: false`.
129
+ effects: { reads: ["fs"], writes: ["fs"], destructive: false, idempotent: true },
130
+ })
131
+ .handler(mkdir)
132
+ .build();
133
+
134
+ const fsRmProcedure = createProcedure()
135
+ .path(["fs", "rm"])
136
+ .input(zodAdapter<RmInput>(RmInputSchema))
137
+ .output(zodAdapter<RmOutput>(RmOutputSchema))
138
+ .meta({
139
+ description: "Remove file or directory",
140
+ args: ["path"],
141
+ shorts: { recursive: "r", force: "f" },
142
+ output: "json",
143
+ effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
144
+ })
145
+ .handler(rm)
146
+ .build();
147
+
148
+ const fsReaddirProcedure = createProcedure()
149
+ .path(["fs", "readdir"])
150
+ .input(zodAdapter<ReaddirInput>(ReaddirInputSchema))
151
+ .output(zodAdapter<ReaddirOutput>(ReaddirOutputSchema))
152
+ .meta({
153
+ description: "Read directory contents",
154
+ args: ["path"],
155
+ shorts: { recursive: "r", includeStats: "s" },
156
+ output: "json",
157
+ effects: READS_FILES,
158
+ })
159
+ .handler(readdir)
160
+ .build();
161
+
162
+ const fsStatProcedure = createProcedure()
163
+ .path(["fs", "stat"])
164
+ .input(zodAdapter<StatInput>(StatInputSchema))
165
+ .output(zodAdapter<StatOutput>(StatOutputSchema))
166
+ .meta({
167
+ description: "Get file or directory stats",
168
+ args: ["path"],
169
+ shorts: {},
170
+ output: "json",
171
+ effects: READS_FILES,
172
+ })
173
+ .handler(stat)
174
+ .build();
175
+
176
+ const fsCopyProcedure = createProcedure()
177
+ .path(["fs", "copy"])
178
+ .input(zodAdapter<CopyInput>(CopyInputSchema))
179
+ .output(zodAdapter<CopyOutput>(CopyOutputSchema))
180
+ .meta({
181
+ description: "Copy file or directory",
182
+ args: ["src", "dest"],
183
+ shorts: { recursive: "r", overwrite: "o" },
184
+ output: "json",
185
+ // With `overwrite`, it replaces the files at the destination
186
+ effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
187
+ })
188
+ .handler(copy)
189
+ .build();
190
+
191
+ const fsMoveProcedure = createProcedure()
192
+ .path(["fs", "move"])
193
+ .input(zodAdapter<MoveInput>(MoveInputSchema))
194
+ .output(zodAdapter<MoveOutput>(MoveOutputSchema))
195
+ .meta({
196
+ description: "Move or rename file/directory",
197
+ args: ["src", "dest"],
198
+ shorts: { overwrite: "o" },
199
+ output: "json",
200
+ // With `overwrite`, it replaces the destination. A second call finds no source and changes nothing.
201
+ effects: { reads: ["fs"], writes: ["fs"], idempotent: true },
202
+ })
203
+ .handler(move)
204
+ .build();
205
+
206
+ const fsGlobProcedure = createProcedure()
207
+ .path(["fs", "glob"])
208
+ .input(zodAdapter<GlobInput>(GlobInputSchema))
209
+ .output(zodAdapter<GlobOutput>(GlobOutputSchema))
210
+ .meta({
211
+ description: "Find files matching glob pattern",
212
+ args: ["pattern"],
213
+ shorts: { cwd: "c", absolute: "a", dot: "d" },
214
+ output: "json",
215
+ effects: READS_FILES,
216
+ })
217
+ .handler(glob)
218
+ .build();
219
+
220
+ const fsReadJsonProcedure = createProcedure()
221
+ .path(["fs", "read.json"])
222
+ .input(zodAdapter<ReadJsonInput>(ReadJsonInputSchema))
223
+ .output(zodAdapter<ReadJsonOutput>(ReadJsonOutputSchema))
224
+ .meta({
225
+ description: "Read and parse JSON file",
226
+ args: ["path"],
227
+ shorts: {},
228
+ output: "json",
229
+ effects: READS_FILES,
230
+ })
231
+ .handler(readJson)
232
+ .build();
233
+
234
+ // =============================================================================
235
+ // Registration
236
+ // =============================================================================
237
+
238
+ /**
239
+ * The module of this package, for `createRegistry()`: its procedures as data. Importing this
240
+ * file registers nothing. (`register.ts` registers the same procedures in the global registry.)
241
+ */
242
+ export const fsModule: ProcedureModule = defineModule("@procedures/fs", [
243
+ fsReadProcedure,
244
+ fsWriteProcedure,
245
+ fsExistsProcedure,
246
+ fsMkdirProcedure,
247
+ fsRmProcedure,
248
+ fsReaddirProcedure,
249
+ fsStatProcedure,
250
+ fsCopyProcedure,
251
+ fsMoveProcedure,
252
+ fsGlobProcedure,
253
+ fsReadJsonProcedure,
254
+ ]);
255
+
256
+ export default fsModule;
257
+
258
+ /**
259
+ * This function registers the procedures of @procedures/fs, and of the modules that it requires, in
260
+ * a registry. The default is the global registry. Importing this file registers nothing: the
261
+ * `./register` entry starts this function (ARCHITECTURE-PROPOSALS-2026-10, P9).
262
+ */
263
+ export function registerFsProcedures(registry: ProcedureRegistry = PROCEDURE_REGISTRY): void {
264
+ registerModules(registry, [fsModule]);
265
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * copy procedure
3
+ *
4
+ * Copy file or directory
5
+ */
6
+
7
+ import { copyFile, cp, constants } from "node:fs/promises";
8
+ import type { CopyInput, CopyOutput } from "../../types.js";
9
+
10
+ /**
11
+ * Copy file or directory
12
+ */
13
+ export async function copy(input: CopyInput): Promise<CopyOutput> {
14
+ const { src, dest, recursive, overwrite } = input;
15
+ const flags = overwrite ? 0 : constants.COPYFILE_EXCL;
16
+
17
+ if (recursive) {
18
+ await cp(src, dest, { recursive, force: overwrite });
19
+ } else {
20
+ await copyFile(src, dest, flags);
21
+ }
22
+
23
+ return { src, dest };
24
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * exists procedure
3
+ *
4
+ * Check if file or directory exists
5
+ */
6
+
7
+ import { type ExistsInput, type ExistsOutput } from "../../types.js";
8
+ import { stat } from "./stat.js";
9
+
10
+ /**
11
+ * Check if file or directory exists
12
+ */
13
+ export async function exists(input: ExistsInput): Promise<ExistsOutput> {
14
+ try {
15
+ const stats = await stat(input);
16
+ return { exists: true, stats };
17
+ } catch {
18
+ return { exists: false };
19
+ }
20
+ }