@soederpop/luca 0.0.5 → 0.0.7

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 (211) hide show
  1. package/CLAUDE.md +10 -1
  2. package/bun.lock +1 -1
  3. package/commands/build-bootstrap.ts +78 -0
  4. package/commands/build-scaffolds.ts +24 -2
  5. package/commands/try-all-challenges.ts +543 -0
  6. package/commands/try-challenge.ts +100 -0
  7. package/docs/README.md +52 -80
  8. package/docs/TABLE-OF-CONTENTS.md +82 -51
  9. package/docs/apis/clients/elevenlabs.md +232 -8
  10. package/docs/apis/clients/graph.md +59 -8
  11. package/docs/apis/clients/openai.md +362 -2
  12. package/docs/apis/clients/rest.md +122 -2
  13. package/docs/apis/clients/websocket.md +71 -17
  14. package/docs/apis/features/agi/assistant.md +9 -3
  15. package/docs/apis/features/agi/assistants-manager.md +2 -2
  16. package/docs/apis/features/agi/claude-code.md +153 -14
  17. package/docs/apis/features/agi/conversation-history.md +15 -3
  18. package/docs/apis/features/agi/conversation.md +133 -20
  19. package/docs/apis/features/agi/openai-codex.md +90 -12
  20. package/docs/apis/features/agi/skills-library.md +23 -5
  21. package/docs/apis/features/node/container-link.md +59 -0
  22. package/docs/apis/features/node/content-db.md +1 -1
  23. package/docs/apis/features/node/disk-cache.md +1 -1
  24. package/docs/apis/features/node/dns.md +1 -0
  25. package/docs/apis/features/node/docker.md +2 -1
  26. package/docs/apis/features/node/esbuild.md +4 -3
  27. package/docs/apis/features/node/file-manager.md +13 -4
  28. package/docs/apis/features/node/fs.md +726 -171
  29. package/docs/apis/features/node/git.md +1 -0
  30. package/docs/apis/features/node/google-auth.md +23 -4
  31. package/docs/apis/features/node/google-calendar.md +14 -2
  32. package/docs/apis/features/node/google-docs.md +15 -2
  33. package/docs/apis/features/node/google-drive.md +21 -3
  34. package/docs/apis/features/node/google-sheets.md +14 -2
  35. package/docs/apis/features/node/grep.md +2 -0
  36. package/docs/apis/features/node/helpers.md +29 -0
  37. package/docs/apis/features/node/ink.md +2 -2
  38. package/docs/apis/features/node/networking.md +39 -4
  39. package/docs/apis/features/node/os.md +28 -0
  40. package/docs/apis/features/node/postgres.md +26 -4
  41. package/docs/apis/features/node/proc.md +37 -28
  42. package/docs/apis/features/node/process-manager.md +33 -5
  43. package/docs/apis/features/node/repl.md +1 -1
  44. package/docs/apis/features/node/runpod.md +1 -0
  45. package/docs/apis/features/node/secure-shell.md +7 -0
  46. package/docs/apis/features/node/semantic-search.md +12 -5
  47. package/docs/apis/features/node/sqlite.md +26 -4
  48. package/docs/apis/features/node/telegram.md +30 -5
  49. package/docs/apis/features/node/tts.md +17 -2
  50. package/docs/apis/features/node/ui.md +1 -1
  51. package/docs/apis/features/node/vault.md +4 -9
  52. package/docs/apis/features/node/vm.md +3 -12
  53. package/docs/apis/features/node/window-manager.md +128 -20
  54. package/docs/apis/features/web/asset-loader.md +13 -1
  55. package/docs/apis/features/web/container-link.md +59 -0
  56. package/docs/apis/features/web/esbuild.md +4 -3
  57. package/docs/apis/features/web/helpers.md +29 -0
  58. package/docs/apis/features/web/network.md +16 -2
  59. package/docs/apis/features/web/speech.md +16 -2
  60. package/docs/apis/features/web/vault.md +4 -9
  61. package/docs/apis/features/web/vm.md +3 -12
  62. package/docs/apis/features/web/voice.md +18 -1
  63. package/docs/apis/servers/express.md +18 -2
  64. package/docs/apis/servers/mcp.md +29 -4
  65. package/docs/apis/servers/websocket.md +34 -6
  66. package/docs/bootstrap/CLAUDE.md +100 -0
  67. package/docs/bootstrap/SKILL.md +222 -0
  68. package/docs/bootstrap/templates/about-command.ts +41 -0
  69. package/docs/bootstrap/templates/docs-models.ts +22 -0
  70. package/docs/bootstrap/templates/docs-readme.md +43 -0
  71. package/docs/bootstrap/templates/example-feature.ts +53 -0
  72. package/docs/bootstrap/templates/health-endpoint.ts +15 -0
  73. package/docs/bootstrap/templates/luca-cli.ts +25 -0
  74. package/docs/challenges/caching-proxy.md +16 -0
  75. package/docs/challenges/content-db-round-trip.md +14 -0
  76. package/docs/challenges/custom-command.md +9 -0
  77. package/docs/challenges/file-watcher-pipeline.md +11 -0
  78. package/docs/challenges/grep-audit-report.md +15 -0
  79. package/docs/challenges/multi-feature-dashboard.md +14 -0
  80. package/docs/challenges/process-orchestrator.md +17 -0
  81. package/docs/challenges/rest-api-server-with-client.md +12 -0
  82. package/docs/challenges/script-runner-with-vm.md +11 -0
  83. package/docs/challenges/simple-rest-api.md +15 -0
  84. package/docs/challenges/websocket-serve-and-client.md +11 -0
  85. package/docs/challenges/yaml-config-system.md +14 -0
  86. package/docs/command-system-overhaul.md +94 -0
  87. package/docs/examples/assistant/CORE.md +18 -0
  88. package/docs/examples/assistant/hooks.ts +3 -0
  89. package/docs/examples/assistant/tools.ts +10 -0
  90. package/docs/examples/window-manager-layouts.md +180 -0
  91. package/docs/in-memory-fs.md +4 -0
  92. package/docs/models.ts +13 -10
  93. package/docs/philosophy.md +4 -3
  94. package/docs/reports/console-hmr-design.md +170 -0
  95. package/docs/reports/helper-semantic-search.md +72 -0
  96. package/docs/scaffolds/client.md +29 -20
  97. package/docs/scaffolds/command.md +64 -50
  98. package/docs/scaffolds/endpoint.md +31 -36
  99. package/docs/scaffolds/feature.md +28 -18
  100. package/docs/scaffolds/selector.md +91 -0
  101. package/docs/scaffolds/server.md +18 -9
  102. package/docs/selectors.md +115 -0
  103. package/docs/sessions/custom-command/attempt-log-2.md +195 -0
  104. package/docs/sessions/file-watcher-pipeline/attempt-log-1.md +728 -0
  105. package/docs/sessions/file-watcher-pipeline/attempt-log-2.md +555 -0
  106. package/docs/sessions/grep-audit-report/attempt-log-1.md +289 -0
  107. package/docs/sessions/multi-feature-dashboard/attempt-log-2.md +679 -0
  108. package/docs/sessions/rest-api-server-with-client/attempt-log-1.md +1 -0
  109. package/docs/sessions/rest-api-server-with-client/attempt-log-3.md +920 -0
  110. package/docs/sessions/simple-rest-api/attempt-log-1.md +593 -0
  111. package/docs/sessions/websocket-serve-and-client/attempt-log-2.md +995 -0
  112. package/docs/tutorials/00-bootstrap.md +148 -0
  113. package/docs/tutorials/07-endpoints.md +7 -7
  114. package/docs/tutorials/08-commands.md +153 -72
  115. package/luca.cli.ts +3 -0
  116. package/package.json +6 -5
  117. package/public/index.html +1430 -0
  118. package/scripts/examples/using-ollama.ts +2 -1
  119. package/scripts/update-introspection-data.ts +2 -2
  120. package/src/agi/endpoints/experts.ts +1 -1
  121. package/src/agi/features/assistant.ts +7 -0
  122. package/src/agi/features/assistants-manager.ts +5 -5
  123. package/src/agi/features/claude-code.ts +263 -3
  124. package/src/agi/features/conversation-history.ts +7 -1
  125. package/src/agi/features/conversation.ts +26 -3
  126. package/src/agi/features/openai-codex.ts +26 -2
  127. package/src/agi/features/openapi.ts +6 -1
  128. package/src/agi/features/skills-library.ts +9 -1
  129. package/src/bootstrap/generated.ts +540 -0
  130. package/src/cli/cli.ts +64 -21
  131. package/src/client.ts +23 -357
  132. package/src/clients/civitai/index.ts +1 -1
  133. package/src/clients/client-template.ts +1 -1
  134. package/src/clients/comfyui/index.ts +13 -2
  135. package/src/clients/elevenlabs/index.ts +2 -1
  136. package/src/clients/graph.ts +87 -0
  137. package/src/clients/openai/index.ts +10 -1
  138. package/src/clients/rest.ts +207 -0
  139. package/src/clients/websocket.ts +176 -0
  140. package/src/command.ts +281 -34
  141. package/src/commands/bootstrap.ts +181 -0
  142. package/src/commands/chat.ts +5 -4
  143. package/src/commands/describe.ts +225 -2
  144. package/src/commands/help.ts +35 -9
  145. package/src/commands/index.ts +3 -0
  146. package/src/commands/introspect.ts +92 -2
  147. package/src/commands/prompt.ts +5 -6
  148. package/src/commands/run.ts +33 -10
  149. package/src/commands/save-api-docs.ts +49 -0
  150. package/src/commands/scaffold.ts +169 -23
  151. package/src/commands/select.ts +94 -0
  152. package/src/commands/serve.ts +10 -1
  153. package/src/container.ts +15 -0
  154. package/src/endpoint.ts +19 -0
  155. package/src/graft.ts +181 -0
  156. package/src/introspection/generated.agi.ts +12458 -8968
  157. package/src/introspection/generated.node.ts +10573 -7145
  158. package/src/introspection/generated.web.ts +1 -1
  159. package/src/introspection/index.ts +26 -0
  160. package/src/node/container.ts +6 -7
  161. package/src/node/features/content-db.ts +49 -2
  162. package/src/node/features/disk-cache.ts +16 -9
  163. package/src/node/features/dns.ts +16 -3
  164. package/src/node/features/docker.ts +16 -4
  165. package/src/node/features/esbuild.ts +20 -0
  166. package/src/node/features/file-manager.ts +184 -29
  167. package/src/node/features/fs.ts +704 -248
  168. package/src/node/features/git.ts +21 -8
  169. package/src/node/features/grep.ts +23 -3
  170. package/src/node/features/helpers.ts +372 -43
  171. package/src/node/features/networking.ts +39 -4
  172. package/src/node/features/opener.ts +28 -15
  173. package/src/node/features/os.ts +76 -0
  174. package/src/node/features/port-exposer.ts +11 -1
  175. package/src/node/features/postgres.ts +17 -1
  176. package/src/node/features/proc.ts +4 -1
  177. package/src/node/features/python.ts +63 -14
  178. package/src/node/features/repl.ts +11 -7
  179. package/src/node/features/runpod.ts +16 -3
  180. package/src/node/features/secure-shell.ts +27 -2
  181. package/src/node/features/semantic-search.ts +12 -1
  182. package/src/node/features/ui.ts +5 -69
  183. package/src/node/features/vm.ts +17 -0
  184. package/src/node/features/window-manager.ts +68 -20
  185. package/src/node.ts +5 -0
  186. package/src/scaffolds/generated.ts +492 -290
  187. package/src/scaffolds/template.ts +9 -0
  188. package/src/schemas/base.ts +46 -5
  189. package/src/selector.ts +282 -0
  190. package/src/server.ts +11 -0
  191. package/src/servers/express.ts +27 -12
  192. package/src/servers/socket.ts +45 -11
  193. package/src/web/clients/socket.ts +4 -1
  194. package/src/web/container.ts +2 -1
  195. package/src/web/features/network.ts +7 -1
  196. package/src/web/features/voice-recognition.ts +16 -1
  197. package/test/clients-servers.test.ts +2 -1
  198. package/test/command.test.ts +267 -0
  199. package/test-integration/assistants-manager.test.ts +10 -20
  200. package/tmp/.cache/luca-disk-cache/content-v2/sha512/1b/b5/c75b28794f00f94c4d609a98978e9420e9b7146d204a7fbf5b0b30477292581705d207c0100dabaac27eef540aaaece3374af75104a93219d4ec8bfb44e7 +1 -0
  201. package/tmp/.cache/luca-disk-cache/content-v2/sha512/da/df/1d90ce4e042abeb035a197832c6d6893420a747a056be773eb00e4f745a037d505c8db13dde7d36b36b6b893addbb7df0f5fe9f0c13e665f20056447318b +1 -0
  202. package/tmp/.cache/luca-disk-cache/content-v2/sha512/ed/04/e1d0c2a58c2db29b3921ca2affb3ea4febe831c53b38ebc21019fb799823aba6ed5b4611873d2cd25d422d49955b852a9c326da0d678899bc1c2c2960901 +1 -0
  203. package/tmp/.cache/luca-disk-cache/index-v5/00/13/572aa4c9a94f99eda999695d050cdd0ca7fe2d23a50af03234d4c8ce0791 +2 -0
  204. package/tmp/.cache/luca-disk-cache/index-v5/75/a9/cb61dc0f0589e8ec10a9aca27b834bc73884c479941042d22a2b22324cd3 +2 -0
  205. package/tmp/.cache/luca-disk-cache/index-v5/9f/0f/8b1f915ee64cfff7667dd96acd7a5ac0a96aa91a346e19cefd45909a9c9c +2 -0
  206. package/docs/apis/features/node/launcher-app-command-listener.md +0 -145
  207. package/docs/examples/launcher-app-command-listener.md +0 -120
  208. package/docs/tasks/web-container-helper-discovery.md +0 -71
  209. package/docs/todos.md +0 -1
  210. package/scripts/test-command-listener.ts +0 -123
  211. package/src/node/features/launcher-app-command-listener.ts +0 -389
@@ -10,121 +10,138 @@ container.feature('fs')
10
10
 
11
11
  ## Methods
12
12
 
13
- ### readFileAsync
13
+ ### readFile
14
14
 
15
- Asynchronously reads a file and returns its contents as a Buffer.
15
+ Synchronously reads a file and returns its contents as a string.
16
16
 
17
17
  **Parameters:**
18
18
 
19
19
  | Name | Type | Required | Description |
20
20
  |------|------|----------|-------------|
21
21
  | `path` | `string` | ✓ | The file path relative to the container's working directory |
22
+ | `encoding` | `BufferEncoding | null` | | The encoding to use. Pass null to get a raw Buffer. |
22
23
 
23
- **Returns:** `void`
24
+ **Returns:** `string | Buffer`
24
25
 
25
26
  ```ts
26
- const fs = container.feature('fs')
27
- const buffer = await fs.readFileAsync('data.txt')
28
- console.log(buffer.toString())
27
+ const content = fs.readFile('README.md')
28
+ const buffer = fs.readFile('image.png', null)
29
29
  ```
30
30
 
31
31
 
32
32
 
33
- ### readdir
33
+ ### readFileAsync
34
34
 
35
- Asynchronously reads the contents of a directory.
35
+ Asynchronously reads a file and returns its contents as a string.
36
36
 
37
37
  **Parameters:**
38
38
 
39
39
  | Name | Type | Required | Description |
40
40
  |------|------|----------|-------------|
41
- | `path` | `string` | ✓ | The directory path relative to the container's working directory |
41
+ | `path` | `string` | ✓ | The file path relative to the container's working directory |
42
+ | `encoding` | `BufferEncoding | null` | | The encoding to use. Pass null to get a raw Buffer. |
42
43
 
43
- **Returns:** `void`
44
+ **Returns:** `Promise<string | Buffer>`
44
45
 
45
46
  ```ts
46
- const fs = container.feature('fs')
47
- const entries = await fs.readdir('src')
48
- console.log(entries) // ['index.ts', 'utils.ts', 'components']
47
+ const content = await fs.readFileAsync('data.txt')
48
+ const buffer = await fs.readFileAsync('image.png', null)
49
49
  ```
50
50
 
51
51
 
52
52
 
53
- ### walk
53
+ ### readJson
54
54
 
55
- Recursively walks a directory and returns an array of relative path names for each file and directory.
55
+ Synchronously reads and parses a JSON file.
56
56
 
57
57
  **Parameters:**
58
58
 
59
59
  | Name | Type | Required | Description |
60
60
  |------|------|----------|-------------|
61
- | `basePath` | `string` | ✓ | The base directory path to start walking from |
62
- | `options` | `WalkOptions` | | Options to configure the walk behavior |
61
+ | `path` | `string` | ✓ | The path to the JSON file |
63
62
 
64
- `WalkOptions` properties:
63
+ **Returns:** `void`
64
+
65
+ ```ts
66
+ const config = fs.readJson('config.json')
67
+ console.log(config.version)
68
+ ```
65
69
 
66
- | Property | Type | Description |
67
- |----------|------|-------------|
68
- | `directories` | `boolean` | Whether to include directories in results |
69
- | `files` | `boolean` | Whether to include files in results |
70
- | `exclude` | `string | string[]` | ] - Patterns to exclude from results |
71
- | `include` | `string | string[]` | ] - Patterns to include in results |
70
+
71
+
72
+ ### readJsonAsync
73
+
74
+ Asynchronously reads and parses a JSON file.
75
+
76
+ **Parameters:**
77
+
78
+ | Name | Type | Required | Description |
79
+ |------|------|----------|-------------|
80
+ | `path` | `string` | ✓ | The path to the JSON file |
72
81
 
73
82
  **Returns:** `void`
74
83
 
75
84
  ```ts
76
- const result = fs.walk('src', { files: true, directories: false })
77
- console.log(result.files) // ['src/index.ts', 'src/utils.ts', 'src/components/Button.tsx']
85
+ const config = await fs.readJsonAsync('config.json')
86
+ console.log(config.version)
78
87
  ```
79
88
 
80
89
 
81
90
 
82
- ### walkAsync
91
+ ### readdirSync
83
92
 
84
- Asynchronously and recursively walks a directory and returns an array of relative path names.
93
+ Synchronously reads the contents of a directory.
85
94
 
86
95
  **Parameters:**
87
96
 
88
97
  | Name | Type | Required | Description |
89
98
  |------|------|----------|-------------|
90
- | `baseDir` | `string` | ✓ | The base directory path to start walking from |
91
- | `options` | `WalkOptions` | | Options to configure the walk behavior |
99
+ | `path` | `string` | ✓ | The directory path relative to the container's working directory |
92
100
 
93
- `WalkOptions` properties:
101
+ **Returns:** `void`
94
102
 
95
- | Property | Type | Description |
96
- |----------|------|-------------|
97
- | `directories` | `boolean` | Whether to include directories in results |
98
- | `files` | `boolean` | Whether to include files in results |
99
- | `exclude` | `string | string[]` | ] - Patterns to exclude from results |
100
- | `include` | `string | string[]` | ] - Patterns to include in results |
103
+ ```ts
104
+ const entries = fs.readdirSync('src')
105
+ console.log(entries) // ['index.ts', 'utils.ts', 'components']
106
+ ```
107
+
108
+
109
+
110
+ ### readdir
111
+
112
+ Asynchronously reads the contents of a directory.
113
+
114
+ **Parameters:**
115
+
116
+ | Name | Type | Required | Description |
117
+ |------|------|----------|-------------|
118
+ | `path` | `string` | ✓ | The directory path relative to the container's working directory |
101
119
 
102
120
  **Returns:** `void`
103
121
 
104
122
  ```ts
105
- const result = await fs.walkAsync('src', { exclude: ['node_modules'] })
106
- console.log(`Found ${result.files.length} files and ${result.directories.length} directories`)
123
+ const entries = await fs.readdir('src')
124
+ console.log(entries) // ['index.ts', 'utils.ts', 'components']
107
125
  ```
108
126
 
109
127
 
110
128
 
111
- ### ensureFileAsync
129
+ ### writeFile
112
130
 
113
- Asynchronously ensures a file exists with the specified content, creating directories as needed.
131
+ Synchronously writes content to a file.
114
132
 
115
133
  **Parameters:**
116
134
 
117
135
  | Name | Type | Required | Description |
118
136
  |------|------|----------|-------------|
119
- | `path` | `string` | ✓ | The file path where the file should be created |
120
- | `content` | `string` | ✓ | The content to write to the file |
121
- | `overwrite` | `any` | | Whether to overwrite the file if it already exists |
137
+ | `path` | `string` | ✓ | The file path where content should be written |
138
+ | `content` | `Buffer | string` | ✓ | The content to write to the file |
122
139
 
123
140
  **Returns:** `void`
124
141
 
125
142
  ```ts
126
- await fs.ensureFileAsync('config/settings.json', '{}', true)
127
- // Creates config directory and settings.json file with '{}' content
143
+ fs.writeFile('output.txt', 'Hello World')
144
+ fs.writeFile('data.bin', Buffer.from([1, 2, 3, 4]))
128
145
  ```
129
146
 
130
147
 
@@ -149,6 +166,46 @@ await fs.writeFileAsync('data.bin', Buffer.from([1, 2, 3, 4]))
149
166
 
150
167
 
151
168
 
169
+ ### writeJson
170
+
171
+ Synchronously writes an object to a file as JSON.
172
+
173
+ **Parameters:**
174
+
175
+ | Name | Type | Required | Description |
176
+ |------|------|----------|-------------|
177
+ | `path` | `string` | ✓ | The file path where the JSON should be written |
178
+ | `data` | `any` | ✓ | The data to serialize as JSON |
179
+ | `indent` | `number` | | The number of spaces to use for indentation |
180
+
181
+ **Returns:** `void`
182
+
183
+ ```ts
184
+ fs.writeJson('config.json', { version: '1.0.0', debug: false })
185
+ ```
186
+
187
+
188
+
189
+ ### writeJsonAsync
190
+
191
+ Asynchronously writes an object to a file as JSON.
192
+
193
+ **Parameters:**
194
+
195
+ | Name | Type | Required | Description |
196
+ |------|------|----------|-------------|
197
+ | `path` | `string` | ✓ | The file path where the JSON should be written |
198
+ | `data` | `any` | ✓ | The data to serialize as JSON |
199
+ | `indent` | `number` | | The number of spaces to use for indentation |
200
+
201
+ **Returns:** `void`
202
+
203
+ ```ts
204
+ await fs.writeJsonAsync('config.json', { version: '1.0.0', debug: false })
205
+ ```
206
+
207
+
208
+
152
209
  ### appendFile
153
210
 
154
211
  Synchronously appends content to a file.
@@ -187,102 +244,96 @@ await fs.appendFileAsync('log.txt', 'New line\n')
187
244
 
188
245
 
189
246
 
190
- ### ensureFolder
247
+ ### ensureFile
191
248
 
192
- Synchronously ensures a directory exists, creating parent directories as needed.
249
+ Synchronously ensures a file exists with the specified content, creating directories as needed.
193
250
 
194
251
  **Parameters:**
195
252
 
196
253
  | Name | Type | Required | Description |
197
254
  |------|------|----------|-------------|
198
- | `path` | `string` | ✓ | The directory path to create |
255
+ | `path` | `string` | ✓ | The file path where the file should be created |
256
+ | `content` | `string` | ✓ | The content to write to the file |
257
+ | `overwrite` | `any` | | Whether to overwrite the file if it already exists |
199
258
 
200
259
  **Returns:** `void`
201
260
 
202
261
  ```ts
203
- fs.ensureFolder('logs/debug')
204
- // Creates logs and logs/debug directories if they don't exist
262
+ fs.ensureFile('logs/app.log', '', false)
205
263
  ```
206
264
 
207
265
 
208
266
 
209
- ### mkdirp
267
+ ### ensureFileAsync
268
+
269
+ Asynchronously ensures a file exists with the specified content, creating directories as needed.
210
270
 
211
271
  **Parameters:**
212
272
 
213
273
  | Name | Type | Required | Description |
214
274
  |------|------|----------|-------------|
215
- | `folder` | `string` | ✓ | Parameter folder |
275
+ | `path` | `string` | ✓ | The file path where the file should be created |
276
+ | `content` | `string` | ✓ | The content to write to the file |
277
+ | `overwrite` | `any` | | Whether to overwrite the file if it already exists |
216
278
 
217
279
  **Returns:** `void`
218
280
 
281
+ ```ts
282
+ await fs.ensureFileAsync('config/settings.json', '{}', true)
283
+ ```
219
284
 
220
285
 
221
- ### ensureFile
222
286
 
223
- Synchronously ensures a file exists with the specified content, creating directories as needed.
287
+ ### ensureFolder
288
+
289
+ Synchronously ensures a directory exists, creating parent directories as needed.
224
290
 
225
291
  **Parameters:**
226
292
 
227
293
  | Name | Type | Required | Description |
228
294
  |------|------|----------|-------------|
229
- | `path` | `string` | ✓ | The file path where the file should be created |
230
- | `content` | `string` | ✓ | The content to write to the file |
231
- | `overwrite` | `any` | | Whether to overwrite the file if it already exists |
295
+ | `path` | `string` | ✓ | The directory path to create |
232
296
 
233
297
  **Returns:** `void`
234
298
 
235
299
  ```ts
236
- fs.ensureFile('logs/app.log', '', false)
237
- // Creates logs directory and app.log file if they don't exist
300
+ fs.ensureFolder('logs/debug')
238
301
  ```
239
302
 
240
303
 
241
304
 
242
- ### findUp
305
+ ### ensureFolderAsync
243
306
 
244
- Synchronously finds a file by walking up the directory tree from the current working directory.
307
+ Asynchronously ensures a directory exists, creating parent directories as needed.
245
308
 
246
309
  **Parameters:**
247
310
 
248
311
  | Name | Type | Required | Description |
249
312
  |------|------|----------|-------------|
250
- | `fileName` | `string` | ✓ | The name of the file to search for |
251
- | `options` | `{ cwd?: string }` | | Options for the search |
252
-
253
- `{ cwd?: string }` properties:
254
-
255
- | Property | Type | Description |
256
- |----------|------|-------------|
257
- | `cwd` | `any` | The directory to start searching from (defaults to container.cwd) |
313
+ | `path` | `string` | ✓ | The directory path to create |
258
314
 
259
- **Returns:** `string | null`
315
+ **Returns:** `void`
260
316
 
261
317
  ```ts
262
- const packageJson = fs.findUp('package.json')
263
- if (packageJson) {
264
- console.log(`Found package.json at: ${packageJson}`)
265
- }
318
+ await fs.ensureFolderAsync('logs/debug')
266
319
  ```
267
320
 
268
321
 
269
322
 
270
- ### existsAsync
323
+ ### mkdirp
271
324
 
272
- Asynchronously checks if a file or directory exists.
325
+ Alias for ensureFolder. Synchronously creates a directory and all parent directories.
273
326
 
274
327
  **Parameters:**
275
328
 
276
329
  | Name | Type | Required | Description |
277
330
  |------|------|----------|-------------|
278
- | `path` | `string` | ✓ | The path to check for existence |
331
+ | `folder` | `string` | ✓ | The directory path to create |
279
332
 
280
333
  **Returns:** `void`
281
334
 
282
335
  ```ts
283
- if (await fs.existsAsync('config.json')) {
284
- console.log('Config file exists!')
285
- }
336
+ fs.mkdirp('deep/nested/path')
286
337
  ```
287
338
 
288
339
 
@@ -309,185 +360,530 @@ if (fs.exists('config.json')) {
309
360
 
310
361
  ### existsSync
311
362
 
363
+ Alias for exists. Synchronously checks if a file or directory exists.
364
+
312
365
  **Parameters:**
313
366
 
314
367
  | Name | Type | Required | Description |
315
368
  |------|------|----------|-------------|
316
- | `path` | `string` | ✓ | Parameter path |
369
+ | `path` | `string` | ✓ | The path to check for existence |
317
370
 
318
371
  **Returns:** `boolean`
319
372
 
373
+ ```ts
374
+ if (fs.existsSync('config.json')) {
375
+ console.log('Config file exists!')
376
+ }
377
+ ```
378
+
320
379
 
321
380
 
322
- ### rm
381
+ ### existsAsync
323
382
 
324
- Asynchronously removes a file.
383
+ Asynchronously checks if a file or directory exists.
325
384
 
326
385
  **Parameters:**
327
386
 
328
387
  | Name | Type | Required | Description |
329
388
  |------|------|----------|-------------|
330
- | `path` | `string` | ✓ | The path of the file to remove |
389
+ | `path` | `string` | ✓ | The path to check for existence |
331
390
 
332
391
  **Returns:** `void`
333
392
 
334
393
  ```ts
335
- await fs.rm('temp/cache.tmp')
394
+ if (await fs.existsAsync('config.json')) {
395
+ console.log('Config file exists!')
396
+ }
336
397
  ```
337
398
 
338
399
 
339
400
 
340
- ### readJson
401
+ ### stat
341
402
 
342
- Synchronously reads and parses a JSON file.
403
+ Synchronously returns the stat object for a file or directory.
343
404
 
344
405
  **Parameters:**
345
406
 
346
407
  | Name | Type | Required | Description |
347
408
  |------|------|----------|-------------|
348
- | `path` | `string` | ✓ | The path to the JSON file |
409
+ | `path` | `string` | ✓ | The path to stat |
349
410
 
350
411
  **Returns:** `void`
351
412
 
352
413
  ```ts
353
- const config = fs.readJson('config.json')
354
- console.log(config.version)
414
+ const info = fs.stat('package.json')
415
+ console.log(info.size, info.mtime)
355
416
  ```
356
417
 
357
418
 
358
419
 
359
- ### readFile
420
+ ### statAsync
360
421
 
361
- Synchronously reads a file and returns its contents as a string.
422
+ Asynchronously returns the stat object for a file or directory.
362
423
 
363
424
  **Parameters:**
364
425
 
365
426
  | Name | Type | Required | Description |
366
427
  |------|------|----------|-------------|
367
- | `path` | `string` | ✓ | The path to the file |
428
+ | `path` | `string` | ✓ | The path to stat |
368
429
 
369
430
  **Returns:** `void`
370
431
 
371
432
  ```ts
372
- const content = fs.readFile('README.md')
373
- console.log(content)
433
+ const info = await fs.statAsync('package.json')
434
+ console.log(info.size, info.mtime)
374
435
  ```
375
436
 
376
437
 
377
438
 
378
- ### rmdir
439
+ ### isFile
379
440
 
380
- Asynchronously removes a directory and all its contents.
441
+ Synchronously checks if a path is a file.
381
442
 
382
443
  **Parameters:**
383
444
 
384
445
  | Name | Type | Required | Description |
385
446
  |------|------|----------|-------------|
386
- | `dirPath` | `string` | ✓ | The path of the directory to remove |
447
+ | `path` | `string` | ✓ | The path to check |
387
448
 
388
- **Returns:** `void`
449
+ **Returns:** `boolean`
389
450
 
390
451
  ```ts
391
- await fs.rmdir('temp/cache')
392
- // Removes the cache directory and all its contents
452
+ if (fs.isFile('package.json')) {
453
+ console.log('It is a file')
454
+ }
393
455
  ```
394
456
 
395
457
 
396
458
 
397
- ### findUpAsync
459
+ ### isFileAsync
398
460
 
399
- Asynchronously finds a file by walking up the directory tree.
461
+ Asynchronously checks if a path is a file.
400
462
 
401
463
  **Parameters:**
402
464
 
403
465
  | Name | Type | Required | Description |
404
466
  |------|------|----------|-------------|
405
- | `fileName` | `string` | ✓ | The name of the file to search for |
406
- | `options` | `{ cwd?: string; multiple?: boolean }` | | Options for the search |
407
-
408
- `{ cwd?: string; multiple?: boolean }` properties:
467
+ | `path` | `string` | ✓ | The path to check |
409
468
 
410
- | Property | Type | Description |
411
- |----------|------|-------------|
412
- | `cwd` | `any` | The directory to start searching from (defaults to container.cwd) |
413
- | `multiple` | `any` | Whether to find multiple instances of the file |
414
-
415
- **Returns:** `Promise<string | string[] | null>`
469
+ **Returns:** `Promise<boolean>`
416
470
 
417
471
  ```ts
418
- const packageJson = await fs.findUpAsync('package.json')
419
- const allPackageJsons = await fs.findUpAsync('package.json', { multiple: true })
472
+ if (await fs.isFileAsync('package.json')) {
473
+ console.log('It is a file')
474
+ }
420
475
  ```
421
476
 
422
477
 
423
478
 
424
- ## State (Zod v4 schema)
479
+ ### isDirectory
425
480
 
426
- | Property | Type | Description |
427
- |----------|------|-------------|
428
- | `enabled` | `boolean` | Whether this feature is currently enabled |
481
+ Synchronously checks if a path is a directory.
429
482
 
430
- ## Examples
483
+ **Parameters:**
431
484
 
432
- **features.fs**
485
+ | Name | Type | Required | Description |
486
+ |------|------|----------|-------------|
487
+ | `path` | `string` | ✓ | The path to check |
488
+
489
+ **Returns:** `boolean`
433
490
 
434
491
  ```ts
435
- const fs = container.feature('fs')
436
- const content = fs.readFile('package.json')
437
- const exists = fs.exists('tsconfig.json')
438
- await fs.ensureFileAsync('output/result.json', '{}')
492
+ if (fs.isDirectory('src')) {
493
+ console.log('It is a directory')
494
+ }
439
495
  ```
440
496
 
441
497
 
442
498
 
443
- **readFileAsync**
499
+ ### isDirectoryAsync
444
500
 
445
- ```ts
446
- const fs = container.feature('fs')
447
- const buffer = await fs.readFileAsync('data.txt')
448
- console.log(buffer.toString())
449
- ```
501
+ Asynchronously checks if a path is a directory.
450
502
 
503
+ **Parameters:**
451
504
 
505
+ | Name | Type | Required | Description |
506
+ |------|------|----------|-------------|
507
+ | `path` | `string` | ✓ | The path to check |
452
508
 
453
- **readdir**
509
+ **Returns:** `Promise<boolean>`
454
510
 
455
511
  ```ts
456
- const fs = container.feature('fs')
457
- const entries = await fs.readdir('src')
458
- console.log(entries) // ['index.ts', 'utils.ts', 'components']
512
+ if (await fs.isDirectoryAsync('src')) {
513
+ console.log('It is a directory')
514
+ }
459
515
  ```
460
516
 
461
517
 
462
518
 
463
- **walk**
519
+ ### rmSync
464
520
 
465
- ```ts
466
- const result = fs.walk('src', { files: true, directories: false })
467
- console.log(result.files) // ['src/index.ts', 'src/utils.ts', 'src/components/Button.tsx']
468
- ```
521
+ Synchronously removes a file.
469
522
 
523
+ **Parameters:**
470
524
 
525
+ | Name | Type | Required | Description |
526
+ |------|------|----------|-------------|
527
+ | `path` | `string` | ✓ | The path of the file to remove |
471
528
 
472
- **walkAsync**
529
+ **Returns:** `void`
473
530
 
474
531
  ```ts
475
- const result = await fs.walkAsync('src', { exclude: ['node_modules'] })
476
- console.log(`Found ${result.files.length} files and ${result.directories.length} directories`)
532
+ fs.rmSync('temp/cache.tmp')
477
533
  ```
478
534
 
479
535
 
480
536
 
481
- **ensureFileAsync**
482
-
483
- ```ts
484
- await fs.ensureFileAsync('config/settings.json', '{}', true)
485
- // Creates config directory and settings.json file with '{}' content
486
- ```
537
+ ### rm
487
538
 
539
+ Asynchronously removes a file.
488
540
 
541
+ **Parameters:**
489
542
 
490
- **writeFileAsync**
543
+ | Name | Type | Required | Description |
544
+ |------|------|----------|-------------|
545
+ | `path` | `string` | ✓ | The path of the file to remove |
546
+
547
+ **Returns:** `void`
548
+
549
+ ```ts
550
+ await fs.rm('temp/cache.tmp')
551
+ ```
552
+
553
+
554
+
555
+ ### rmdirSync
556
+
557
+ Synchronously removes a directory and all its contents.
558
+
559
+ **Parameters:**
560
+
561
+ | Name | Type | Required | Description |
562
+ |------|------|----------|-------------|
563
+ | `dirPath` | `string` | ✓ | The path of the directory to remove |
564
+
565
+ **Returns:** `void`
566
+
567
+ ```ts
568
+ fs.rmdirSync('temp/cache')
569
+ ```
570
+
571
+
572
+
573
+ ### rmdir
574
+
575
+ Asynchronously removes a directory and all its contents.
576
+
577
+ **Parameters:**
578
+
579
+ | Name | Type | Required | Description |
580
+ |------|------|----------|-------------|
581
+ | `dirPath` | `string` | ✓ | The path of the directory to remove |
582
+
583
+ **Returns:** `void`
584
+
585
+ ```ts
586
+ await fs.rmdir('temp/cache')
587
+ ```
588
+
589
+
590
+
591
+ ### copy
592
+
593
+ Synchronously copies a file or directory. Auto-detects whether the source is a file or directory and handles each appropriately (recursive for directories).
594
+
595
+ **Parameters:**
596
+
597
+ | Name | Type | Required | Description |
598
+ |------|------|----------|-------------|
599
+ | `src` | `string` | ✓ | The source path to copy from |
600
+ | `dest` | `string` | ✓ | The destination path to copy to |
601
+ | `options` | `{ overwrite?: boolean }` | | Copy options |
602
+
603
+ `{ overwrite?: boolean }` properties:
604
+
605
+ | Property | Type | Description |
606
+ |----------|------|-------------|
607
+ | `overwrite` | `any` | Whether to overwrite existing files at the destination |
608
+
609
+ **Returns:** `void`
610
+
611
+ ```ts
612
+ fs.copy('src/config.json', 'backup/config.json')
613
+ fs.copy('src', 'backup/src')
614
+ ```
615
+
616
+
617
+
618
+ ### copyAsync
619
+
620
+ Asynchronously copies a file or directory. Auto-detects whether the source is a file or directory and handles each appropriately (recursive for directories).
621
+
622
+ **Parameters:**
623
+
624
+ | Name | Type | Required | Description |
625
+ |------|------|----------|-------------|
626
+ | `src` | `string` | ✓ | The source path to copy from |
627
+ | `dest` | `string` | ✓ | The destination path to copy to |
628
+ | `options` | `{ overwrite?: boolean }` | | Copy options |
629
+
630
+ `{ overwrite?: boolean }` properties:
631
+
632
+ | Property | Type | Description |
633
+ |----------|------|-------------|
634
+ | `overwrite` | `any` | Whether to overwrite existing files at the destination |
635
+
636
+ **Returns:** `void`
637
+
638
+ ```ts
639
+ await fs.copyAsync('src/config.json', 'backup/config.json')
640
+ await fs.copyAsync('src', 'backup/src')
641
+ ```
642
+
643
+
644
+
645
+ ### move
646
+
647
+ Synchronously moves (renames) a file or directory. Falls back to copy + delete for cross-device moves.
648
+
649
+ **Parameters:**
650
+
651
+ | Name | Type | Required | Description |
652
+ |------|------|----------|-------------|
653
+ | `src` | `string` | ✓ | The source path to move from |
654
+ | `dest` | `string` | ✓ | The destination path to move to |
655
+
656
+ **Returns:** `void`
657
+
658
+ ```ts
659
+ fs.move('temp/draft.txt', 'final/document.txt')
660
+ fs.move('old-dir', 'new-dir')
661
+ ```
662
+
663
+
664
+
665
+ ### moveAsync
666
+
667
+ Asynchronously moves (renames) a file or directory. Falls back to copy + delete for cross-device moves.
668
+
669
+ **Parameters:**
670
+
671
+ | Name | Type | Required | Description |
672
+ |------|------|----------|-------------|
673
+ | `src` | `string` | ✓ | The source path to move from |
674
+ | `dest` | `string` | ✓ | The destination path to move to |
675
+
676
+ **Returns:** `void`
677
+
678
+ ```ts
679
+ await fs.moveAsync('temp/draft.txt', 'final/document.txt')
680
+ await fs.moveAsync('old-dir', 'new-dir')
681
+ ```
682
+
683
+
684
+
685
+ ### walk
686
+
687
+ Recursively walks a directory and returns arrays of file and directory paths. By default paths are absolute. Pass `relative: true` to get paths relative to `basePath`. Supports filtering with exclude and include glob patterns.
688
+
689
+ **Parameters:**
690
+
691
+ | Name | Type | Required | Description |
692
+ |------|------|----------|-------------|
693
+ | `basePath` | `string` | ✓ | The base directory path to start walking from |
694
+ | `options` | `WalkOptions` | | Options to configure the walk behavior |
695
+
696
+ `WalkOptions` properties:
697
+
698
+ | Property | Type | Description |
699
+ |----------|------|-------------|
700
+ | `directories` | `boolean` | Whether to include directories in results |
701
+ | `files` | `boolean` | Whether to include files in results |
702
+ | `exclude` | `string | string[]` | ] - Glob patterns to exclude (e.g. 'node_modules', '*.log') |
703
+ | `include` | `string | string[]` | ] - Glob patterns to include (only matching paths are returned) |
704
+ | `relative` | `boolean` | When true, returned paths are relative to `baseDir` instead of absolute. |
705
+
706
+ **Returns:** `void`
707
+
708
+ ```ts
709
+ const result = fs.walk('src', { files: true, directories: false })
710
+ const filtered = fs.walk('.', { exclude: ['node_modules', '.git'], include: ['*.ts'] })
711
+ const relative = fs.walk('inbox', { relative: true }) // => { files: ['contact-1.json', ...] }
712
+ ```
713
+
714
+
715
+
716
+ ### walkAsync
717
+
718
+ Asynchronously and recursively walks a directory and returns arrays of file and directory paths. By default paths are absolute. Pass `relative: true` to get paths relative to `baseDir`. Supports filtering with exclude and include glob patterns.
719
+
720
+ **Parameters:**
721
+
722
+ | Name | Type | Required | Description |
723
+ |------|------|----------|-------------|
724
+ | `baseDir` | `string` | ✓ | The base directory path to start walking from |
725
+ | `options` | `WalkOptions` | | Options to configure the walk behavior |
726
+
727
+ `WalkOptions` properties:
728
+
729
+ | Property | Type | Description |
730
+ |----------|------|-------------|
731
+ | `directories` | `boolean` | Whether to include directories in results |
732
+ | `files` | `boolean` | Whether to include files in results |
733
+ | `exclude` | `string | string[]` | ] - Glob patterns to exclude (e.g. 'node_modules', '.git') |
734
+ | `include` | `string | string[]` | ] - Glob patterns to include (only matching paths are returned) |
735
+ | `relative` | `boolean` | When true, returned paths are relative to `baseDir` instead of absolute. |
736
+
737
+ **Returns:** `void`
738
+
739
+ ```ts
740
+ const result = await fs.walkAsync('src', { exclude: ['node_modules'] })
741
+ const files = await fs.walkAsync('inbox', { relative: true })
742
+ // files.files => ['contact-1.json', 'subfolder/file.txt', ...]
743
+ ```
744
+
745
+
746
+
747
+ ### findUp
748
+
749
+ Synchronously finds a file by walking up the directory tree from the current working directory.
750
+
751
+ **Parameters:**
752
+
753
+ | Name | Type | Required | Description |
754
+ |------|------|----------|-------------|
755
+ | `fileName` | `string` | ✓ | The name of the file to search for |
756
+ | `options` | `{ cwd?: string }` | | Options for the search |
757
+
758
+ `{ cwd?: string }` properties:
759
+
760
+ | Property | Type | Description |
761
+ |----------|------|-------------|
762
+ | `cwd` | `any` | The directory to start searching from (defaults to container.cwd) |
763
+
764
+ **Returns:** `string | null`
765
+
766
+ ```ts
767
+ const packageJson = fs.findUp('package.json')
768
+ if (packageJson) {
769
+ console.log(`Found package.json at: ${packageJson}`)
770
+ }
771
+ ```
772
+
773
+
774
+
775
+ ### findUpAsync
776
+
777
+ Asynchronously finds a file by walking up the directory tree.
778
+
779
+ **Parameters:**
780
+
781
+ | Name | Type | Required | Description |
782
+ |------|------|----------|-------------|
783
+ | `fileName` | `string` | ✓ | The name of the file to search for |
784
+ | `options` | `{ cwd?: string; multiple?: boolean }` | | Options for the search |
785
+
786
+ `{ cwd?: string; multiple?: boolean }` properties:
787
+
788
+ | Property | Type | Description |
789
+ |----------|------|-------------|
790
+ | `cwd` | `any` | The directory to start searching from (defaults to container.cwd) |
791
+ | `multiple` | `any` | Whether to find multiple instances of the file |
792
+
793
+ **Returns:** `Promise<string | string[] | null>`
794
+
795
+ ```ts
796
+ const packageJson = await fs.findUpAsync('package.json')
797
+ const allPackageJsons = await fs.findUpAsync('package.json', { multiple: true })
798
+ ```
799
+
800
+
801
+
802
+ ## State (Zod v4 schema)
803
+
804
+ | Property | Type | Description |
805
+ |----------|------|-------------|
806
+ | `enabled` | `boolean` | Whether this feature is currently enabled |
807
+
808
+ ## Examples
809
+
810
+ **features.fs**
811
+
812
+ ```ts
813
+ const fs = container.feature('fs')
814
+ const content = fs.readFile('package.json')
815
+ const exists = fs.exists('tsconfig.json')
816
+ await fs.writeFileAsync('output.txt', 'Hello World')
817
+ fs.writeFile('sync-output.txt', 'Hello Sync')
818
+ fs.copy('src', 'backup/src')
819
+ ```
820
+
821
+
822
+
823
+ **readFile**
824
+
825
+ ```ts
826
+ const content = fs.readFile('README.md')
827
+ const buffer = fs.readFile('image.png', null)
828
+ ```
829
+
830
+
831
+
832
+ **readFileAsync**
833
+
834
+ ```ts
835
+ const content = await fs.readFileAsync('data.txt')
836
+ const buffer = await fs.readFileAsync('image.png', null)
837
+ ```
838
+
839
+
840
+
841
+ **readJson**
842
+
843
+ ```ts
844
+ const config = fs.readJson('config.json')
845
+ console.log(config.version)
846
+ ```
847
+
848
+
849
+
850
+ **readJsonAsync**
851
+
852
+ ```ts
853
+ const config = await fs.readJsonAsync('config.json')
854
+ console.log(config.version)
855
+ ```
856
+
857
+
858
+
859
+ **readdirSync**
860
+
861
+ ```ts
862
+ const entries = fs.readdirSync('src')
863
+ console.log(entries) // ['index.ts', 'utils.ts', 'components']
864
+ ```
865
+
866
+
867
+
868
+ **readdir**
869
+
870
+ ```ts
871
+ const entries = await fs.readdir('src')
872
+ console.log(entries) // ['index.ts', 'utils.ts', 'components']
873
+ ```
874
+
875
+
876
+
877
+ **writeFile**
878
+
879
+ ```ts
880
+ fs.writeFile('output.txt', 'Hello World')
881
+ fs.writeFile('data.bin', Buffer.from([1, 2, 3, 4]))
882
+ ```
883
+
884
+
885
+
886
+ **writeFileAsync**
491
887
 
492
888
  ```ts
493
889
  await fs.writeFileAsync('output.txt', 'Hello World')
@@ -496,6 +892,22 @@ await fs.writeFileAsync('data.bin', Buffer.from([1, 2, 3, 4]))
496
892
 
497
893
 
498
894
 
895
+ **writeJson**
896
+
897
+ ```ts
898
+ fs.writeJson('config.json', { version: '1.0.0', debug: false })
899
+ ```
900
+
901
+
902
+
903
+ **writeJsonAsync**
904
+
905
+ ```ts
906
+ await fs.writeJsonAsync('config.json', { version: '1.0.0', debug: false })
907
+ ```
908
+
909
+
910
+
499
911
  **appendFile**
500
912
 
501
913
  ```ts
@@ -512,30 +924,61 @@ await fs.appendFileAsync('log.txt', 'New line\n')
512
924
 
513
925
 
514
926
 
927
+ **ensureFile**
928
+
929
+ ```ts
930
+ fs.ensureFile('logs/app.log', '', false)
931
+ ```
932
+
933
+
934
+
935
+ **ensureFileAsync**
936
+
937
+ ```ts
938
+ await fs.ensureFileAsync('config/settings.json', '{}', true)
939
+ ```
940
+
941
+
942
+
515
943
  **ensureFolder**
516
944
 
517
945
  ```ts
518
946
  fs.ensureFolder('logs/debug')
519
- // Creates logs and logs/debug directories if they don't exist
520
947
  ```
521
948
 
522
949
 
523
950
 
524
- **ensureFile**
951
+ **ensureFolderAsync**
525
952
 
526
953
  ```ts
527
- fs.ensureFile('logs/app.log', '', false)
528
- // Creates logs directory and app.log file if they don't exist
954
+ await fs.ensureFolderAsync('logs/debug')
529
955
  ```
530
956
 
531
957
 
532
958
 
533
- **findUp**
959
+ **mkdirp**
534
960
 
535
961
  ```ts
536
- const packageJson = fs.findUp('package.json')
537
- if (packageJson) {
538
- console.log(`Found package.json at: ${packageJson}`)
962
+ fs.mkdirp('deep/nested/path')
963
+ ```
964
+
965
+
966
+
967
+ **exists**
968
+
969
+ ```ts
970
+ if (fs.exists('config.json')) {
971
+ console.log('Config file exists!')
972
+ }
973
+ ```
974
+
975
+
976
+
977
+ **existsSync**
978
+
979
+ ```ts
980
+ if (fs.existsSync('config.json')) {
981
+ console.log('Config file exists!')
539
982
  }
540
983
  ```
541
984
 
@@ -551,38 +994,84 @@ if (await fs.existsAsync('config.json')) {
551
994
 
552
995
 
553
996
 
554
- **exists**
997
+ **stat**
555
998
 
556
999
  ```ts
557
- if (fs.exists('config.json')) {
558
- console.log('Config file exists!')
1000
+ const info = fs.stat('package.json')
1001
+ console.log(info.size, info.mtime)
1002
+ ```
1003
+
1004
+
1005
+
1006
+ **statAsync**
1007
+
1008
+ ```ts
1009
+ const info = await fs.statAsync('package.json')
1010
+ console.log(info.size, info.mtime)
1011
+ ```
1012
+
1013
+
1014
+
1015
+ **isFile**
1016
+
1017
+ ```ts
1018
+ if (fs.isFile('package.json')) {
1019
+ console.log('It is a file')
559
1020
  }
560
1021
  ```
561
1022
 
562
1023
 
563
1024
 
564
- **rm**
1025
+ **isFileAsync**
565
1026
 
566
1027
  ```ts
567
- await fs.rm('temp/cache.tmp')
1028
+ if (await fs.isFileAsync('package.json')) {
1029
+ console.log('It is a file')
1030
+ }
568
1031
  ```
569
1032
 
570
1033
 
571
1034
 
572
- **readJson**
1035
+ **isDirectory**
573
1036
 
574
1037
  ```ts
575
- const config = fs.readJson('config.json')
576
- console.log(config.version)
1038
+ if (fs.isDirectory('src')) {
1039
+ console.log('It is a directory')
1040
+ }
577
1041
  ```
578
1042
 
579
1043
 
580
1044
 
581
- **readFile**
1045
+ **isDirectoryAsync**
582
1046
 
583
1047
  ```ts
584
- const content = fs.readFile('README.md')
585
- console.log(content)
1048
+ if (await fs.isDirectoryAsync('src')) {
1049
+ console.log('It is a directory')
1050
+ }
1051
+ ```
1052
+
1053
+
1054
+
1055
+ **rmSync**
1056
+
1057
+ ```ts
1058
+ fs.rmSync('temp/cache.tmp')
1059
+ ```
1060
+
1061
+
1062
+
1063
+ **rm**
1064
+
1065
+ ```ts
1066
+ await fs.rm('temp/cache.tmp')
1067
+ ```
1068
+
1069
+
1070
+
1071
+ **rmdirSync**
1072
+
1073
+ ```ts
1074
+ fs.rmdirSync('temp/cache')
586
1075
  ```
587
1076
 
588
1077
 
@@ -591,7 +1080,73 @@ console.log(content)
591
1080
 
592
1081
  ```ts
593
1082
  await fs.rmdir('temp/cache')
594
- // Removes the cache directory and all its contents
1083
+ ```
1084
+
1085
+
1086
+
1087
+ **copy**
1088
+
1089
+ ```ts
1090
+ fs.copy('src/config.json', 'backup/config.json')
1091
+ fs.copy('src', 'backup/src')
1092
+ ```
1093
+
1094
+
1095
+
1096
+ **copyAsync**
1097
+
1098
+ ```ts
1099
+ await fs.copyAsync('src/config.json', 'backup/config.json')
1100
+ await fs.copyAsync('src', 'backup/src')
1101
+ ```
1102
+
1103
+
1104
+
1105
+ **move**
1106
+
1107
+ ```ts
1108
+ fs.move('temp/draft.txt', 'final/document.txt')
1109
+ fs.move('old-dir', 'new-dir')
1110
+ ```
1111
+
1112
+
1113
+
1114
+ **moveAsync**
1115
+
1116
+ ```ts
1117
+ await fs.moveAsync('temp/draft.txt', 'final/document.txt')
1118
+ await fs.moveAsync('old-dir', 'new-dir')
1119
+ ```
1120
+
1121
+
1122
+
1123
+ **walk**
1124
+
1125
+ ```ts
1126
+ const result = fs.walk('src', { files: true, directories: false })
1127
+ const filtered = fs.walk('.', { exclude: ['node_modules', '.git'], include: ['*.ts'] })
1128
+ const relative = fs.walk('inbox', { relative: true }) // => { files: ['contact-1.json', ...] }
1129
+ ```
1130
+
1131
+
1132
+
1133
+ **walkAsync**
1134
+
1135
+ ```ts
1136
+ const result = await fs.walkAsync('src', { exclude: ['node_modules'] })
1137
+ const files = await fs.walkAsync('inbox', { relative: true })
1138
+ // files.files => ['contact-1.json', 'subfolder/file.txt', ...]
1139
+ ```
1140
+
1141
+
1142
+
1143
+ **findUp**
1144
+
1145
+ ```ts
1146
+ const packageJson = fs.findUp('package.json')
1147
+ if (packageJson) {
1148
+ console.log(`Found package.json at: ${packageJson}`)
1149
+ }
595
1150
  ```
596
1151
 
597
1152