@molecule/app-filesystem 1.0.2 → 1.0.4

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 (3) hide show
  1. package/LICENSE +111 -24
  2. package/README.md +232 -232
  3. package/package.json +4 -4
package/LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  Apache License
2
3
  Version 2.0, January 2004
3
4
  http://www.apache.org/licenses/
@@ -34,21 +35,33 @@
34
35
 
35
36
  "Work" shall mean the work of authorship, whether in Source or
36
37
  Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work.
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
38
40
 
39
41
  "Derivative Works" shall mean any work, whether in Source or Object
40
42
  form, that is based on (or derived from) the Work and for which the
41
43
  editorial revisions, annotations, elaborations, or other modifications
42
- represent, as a whole, an original work of authorship.
43
-
44
- "Contribution" shall mean any work of authorship, including the
45
- original version of the Work and any modifications or additions
46
- to that Work, that is intentionally submitted to the Licensor for
47
- inclusion in the Work by the copyright owner or by an individual or
48
- Legal Entity authorized to submit on behalf of the copyright owner.
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
49
62
 
50
63
  "Contributor" shall mean Licensor and any individual or Legal Entity
51
- on behalf of whom a Contribution has been received by the Licensor and
64
+ on behalf of whom a Contribution has been received by Licensor and
52
65
  subsequently incorporated within the Work.
53
66
 
54
67
  2. Grant of Copyright License. Subject to the terms and conditions of
@@ -61,8 +74,18 @@
61
74
  3. Grant of Patent License. Subject to the terms and conditions of
62
75
  this License, each Contributor hereby grants to You a perpetual,
63
76
  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
- patent license to make, have made, use, offer to sell, sell, import,
65
- and otherwise transfer the Work.
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
66
89
 
67
90
  4. Redistribution. You may reproduce and distribute copies of the
68
91
  Work or Derivative Works thereof in any medium, with or without
@@ -84,23 +107,87 @@
84
107
  (d) If the Work includes a "NOTICE" text file as part of its
85
108
  distribution, then any Derivative Works that You distribute must
86
109
  include a readable copy of the attribution notices contained
87
- within such NOTICE file.
88
-
89
- 5. Submission of Contributions.
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
90
138
 
91
139
  6. Trademarks. This License does not grant permission to use the trade
92
- names, trademarks, service marks, or product names of the Licensor.
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
93
143
 
94
144
  7. Disclaimer of Warranty. Unless required by applicable law or
95
- agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
-
98
- 8. Limitation of Liability. In no event and under no legal theory shall
99
- any Contributor be liable to You for damages.
100
-
101
- 9. Accepting Warranty or Additional Liability.
102
-
103
- Copyright 2026 Molecule Dev, Inc.
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
104
191
 
105
192
  Licensed under the Apache License, Version 2.0 (the "License");
106
193
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -3,15 +3,11 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-08-04T01:50:44.576Z
6
+ Generated: 2026-11-08T06:24:41.456Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-filesystem
10
10
 
11
- > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
- > It is written to be read by coding agents as much as by people, and is generated from this
13
- > package's source — edit `src/index.ts` JSDoc, not this file.
14
-
15
11
  Device filesystem access interface for molecule.dev.
16
12
 
17
13
  Framework-agnostic core for app-scoped file storage through a swappable
@@ -23,6 +19,10 @@ directories (`'documents' | 'data' | 'cache' | 'external' | 'library' |
23
19
  `getBasename`, `getDirname`, `getMimeType`, `formatFileSize`) work
24
20
  without a provider.
25
21
 
22
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
23
+ > It is written to be read by coding agents as much as by people, and is generated from this
24
+ > package's source — edit `src/index.ts` JSDoc, not this file.
25
+
26
26
  ## Quick Start
27
27
 
28
28
  ```typescript
@@ -55,6 +55,63 @@ npm install @molecule/app-filesystem @molecule/app-bond @molecule/app-i18n
55
55
 
56
56
  ### Interfaces
57
57
 
58
+ #### `FileInfo`
59
+
60
+ Metadata about a file or directory (name, path, size, timestamps, type).
61
+
62
+ ```typescript
63
+ interface FileInfo {
64
+ /** File name */
65
+ name: string
66
+ /** Full path */
67
+ path: string
68
+ /** File URI */
69
+ uri: string
70
+ /** File size in bytes */
71
+ size: number
72
+ /** Creation time (ISO string) */
73
+ createdAt?: string
74
+ /** Modification time (ISO string) */
75
+ modifiedAt?: string
76
+ /** Whether this is a directory */
77
+ isDirectory: boolean
78
+ /** Whether this is a file */
79
+ isFile: boolean
80
+ /** MIME type (if available) */
81
+ mimeType?: string
82
+ }
83
+ ```
84
+
85
+ #### `ReadOptions`
86
+
87
+ Options for reading a file (target directory and text encoding).
88
+
89
+ ```typescript
90
+ interface ReadOptions {
91
+ /** Directory to read from */
92
+ directory?: Directory
93
+ /** File encoding */
94
+ encoding?: Encoding
95
+ }
96
+ ```
97
+
98
+ #### `WriteOptions`
99
+
100
+ Options for writing a file (directory, encoding, recursive creation, append mode).
101
+
102
+ ```typescript
103
+ interface WriteOptions {
104
+ /** Directory to write to */
105
+ directory?: Directory
106
+ /** File encoding */
107
+ encoding?: Encoding
108
+ /** Whether to create parent directories */
109
+ recursive?: boolean
110
+ /** Whether to append to existing file */
111
+ append?: boolean
112
+ }
113
+ ```
114
+
58
115
  #### `CopyOptions`
59
116
 
60
117
  Copy/move options
@@ -70,43 +127,40 @@ interface CopyOptions {
70
127
  }
71
128
  ```
72
129
 
73
- #### `DeleteOptions`
130
+ #### `ListOptions`
74
131
 
75
- Options for deleting a file or directory (directory type, recursive deletion).
132
+ Options for listing directory contents (directory type, hidden files).
76
133
 
77
134
  ```typescript
78
- interface DeleteOptions {
135
+ interface ListOptions {
79
136
  /** Directory type */
80
137
  directory?: Directory
81
- /** Delete directory contents recursively */
82
- recursive?: boolean
138
+ /** Whether to include hidden files */
139
+ includeHidden?: boolean
83
140
  }
84
141
  ```
85
142
 
86
- #### `FileInfo`
143
+ #### `StatOptions`
87
144
 
88
- Metadata about a file or directory (name, path, size, timestamps, type).
145
+ Options for getting file/directory metadata (target directory type).
89
146
 
90
147
  ```typescript
91
- interface FileInfo {
92
- /** File name */
93
- name: string
94
- /** Full path */
95
- path: string
96
- /** File URI */
97
- uri: string
98
- /** File size in bytes */
99
- size: number
100
- /** Creation time (ISO string) */
101
- createdAt?: string
102
- /** Modification time (ISO string) */
103
- modifiedAt?: string
104
- /** Whether this is a directory */
105
- isDirectory: boolean
106
- /** Whether this is a file */
107
- isFile: boolean
108
- /** MIME type (if available) */
109
- mimeType?: string
148
+ interface StatOptions {
149
+ /** Directory type */
150
+ directory?: Directory
151
+ }
152
+ ```
153
+
154
+ #### `DeleteOptions`
155
+
156
+ Options for deleting a file or directory (directory type, recursive deletion).
157
+
158
+ ```typescript
159
+ interface DeleteOptions {
160
+ /** Directory type */
161
+ directory?: Directory
162
+ /** Delete directory contents recursively */
163
+ recursive?: boolean
110
164
  }
111
165
  ```
112
166
 
@@ -258,60 +312,6 @@ interface FilesystemProvider {
258
312
  }
259
313
  ```
260
314
 
261
- #### `ListOptions`
262
-
263
- Options for listing directory contents (directory type, hidden files).
264
-
265
- ```typescript
266
- interface ListOptions {
267
- /** Directory type */
268
- directory?: Directory
269
- /** Whether to include hidden files */
270
- includeHidden?: boolean
271
- }
272
- ```
273
-
274
- #### `ReadOptions`
275
-
276
- Options for reading a file (target directory and text encoding).
277
-
278
- ```typescript
279
- interface ReadOptions {
280
- /** Directory to read from */
281
- directory?: Directory
282
- /** File encoding */
283
- encoding?: Encoding
284
- }
285
- ```
286
-
287
- #### `StatOptions`
288
-
289
- Options for getting file/directory metadata (target directory type).
290
-
291
- ```typescript
292
- interface StatOptions {
293
- /** Directory type */
294
- directory?: Directory
295
- }
296
- ```
297
-
298
- #### `WriteOptions`
299
-
300
- Options for writing a file (directory, encoding, recursive creation, append mode).
301
-
302
- ```typescript
303
- interface WriteOptions {
304
- /** Directory to write to */
305
- directory?: Directory
306
- /** File encoding */
307
- encoding?: Encoding
308
- /** Whether to create parent directories */
309
- recursive?: boolean
310
- /** Whether to append to existing file */
311
- append?: boolean
312
- }
313
- ```
314
-
315
315
  ### Types
316
316
 
317
317
  #### `Directory`
@@ -338,201 +338,199 @@ type Encoding = 'utf8' | 'ascii' | 'base64'
338
338
 
339
339
  ### Functions
340
340
 
341
- #### `appendFile(path, data, options)`
341
+ #### `setProvider(provider)`
342
342
 
343
- Append text content to a file.
343
+ Set the filesystem provider.
344
344
 
345
345
  ```typescript
346
- function appendFile(path: string, data: string, options?: WriteOptions): Promise<void>
346
+ function setProvider(provider: FilesystemProvider): void
347
347
  ```
348
348
 
349
- - `path` — The file path to append to.
350
- - `data` — The text content to append.
351
- - `options` — Write options (directory, encoding).
352
-
353
- **Returns:** A promise that resolves when the data is appended.
349
+ - `provider` — FilesystemProvider implementation to register.
354
350
 
355
- #### `copy(from, to, options)`
351
+ #### `getProvider()`
356
352
 
357
- Copy a file to a new location.
353
+ Get the current filesystem provider.
358
354
 
359
355
  ```typescript
360
- function copy(from: string, to: string, options?: CopyOptions): Promise<void>
356
+ function getProvider(): FilesystemProvider
361
357
  ```
362
358
 
363
- - `from` — The source file path.
364
- - `to` — The destination file path.
365
- - `options` — Copy options (source/dest directories, overwrite).
366
-
367
- **Returns:** A promise that resolves when the file is copied.
359
+ **Returns:** The active FilesystemProvider instance.
368
360
 
369
- #### `deleteFile(path, options)`
361
+ #### `hasProvider()`
370
362
 
371
- Delete a file.
363
+ Check if a filesystem provider has been registered.
372
364
 
373
365
  ```typescript
374
- function deleteFile(path: string, options?: DeleteOptions): Promise<void>
366
+ function hasProvider(): boolean
375
367
  ```
376
368
 
377
- - `path` — The file path to delete.
378
- - `options` — Delete options (directory, recursive).
379
-
380
- **Returns:** A promise that resolves when the file is deleted.
369
+ **Returns:** Whether a FilesystemProvider has been bonded.
381
370
 
382
- #### `exists(path, options)`
371
+ #### `readFile(path, options)`
383
372
 
384
- Check if a file or directory exists.
373
+ Read a file as text.
385
374
 
386
375
  ```typescript
387
- function exists(path: string, options?: StatOptions): Promise<boolean>
376
+ function readFile(path: string, options?: ReadOptions): Promise<string>
388
377
  ```
389
378
 
390
- - `path` — The path to check.
391
- - `options` — Stat options (directory).
379
+ - `path` — The file path to read.
380
+ - `options` — Read options (directory, encoding).
392
381
 
393
- **Returns:** Whether the path exists.
382
+ **Returns:** The file contents as a string.
394
383
 
395
- #### `formatFileSize(bytes)`
384
+ #### `readFileAsBlob(path, options)`
396
385
 
397
- Format a byte count as a human-readable file size string (e.g., '1.5 MB').
386
+ Read a file as binary data.
398
387
 
399
388
  ```typescript
400
- function formatFileSize(bytes: number): string
389
+ function readFileAsBlob(path: string, options?: Omit<ReadOptions, 'encoding'>): Promise<Blob>
401
390
  ```
402
391
 
403
- - `bytes` — The size in bytes.
392
+ - `path` — The file path to read.
393
+ - `options` — Read options (directory).
404
394
 
405
- **Returns:** A formatted string with the appropriate unit (B, KB, MB, GB, TB).
395
+ **Returns:** The file contents as a Blob.
406
396
 
407
- #### `getAvailableSpace(directory)`
397
+ #### `writeFile(path, data, options)`
408
398
 
409
- Get available storage space in bytes for a directory.
399
+ Write text content to a file.
410
400
 
411
401
  ```typescript
412
- function getAvailableSpace(directory?: Directory): Promise<number>
402
+ function writeFile(path: string, data: string, options?: WriteOptions): Promise<void>
413
403
  ```
414
404
 
415
- - `directory` — The directory type to check (defaults to app data).
405
+ - `path` — The file path to write to.
406
+ - `data` — The text content to write.
407
+ - `options` — Write options (directory, encoding, recursive, append).
416
408
 
417
- **Returns:** The available space in bytes.
409
+ **Returns:** A promise that resolves when the file is written.
418
410
 
419
- #### `getBasename(path)`
411
+ #### `writeFileFromBlob(path, data, options)`
420
412
 
421
- Get the filename without its extension from a path.
413
+ Write binary data to a file.
422
414
 
423
415
  ```typescript
424
- function getBasename(path: string): string
416
+ function writeFileFromBlob(
417
+ path: string,
418
+ data: Blob,
419
+ options?: Omit<WriteOptions, 'encoding'>,
420
+ ): Promise<void>
425
421
  ```
426
422
 
427
- - `path` — The file path.
423
+ - `path` — The file path to write to.
424
+ - `data` — The binary data to write as a Blob.
425
+ - `options` — Write options (directory, recursive).
428
426
 
429
- **Returns:** The base filename without extension (e.g., 'readme' from '/docs/readme.md').
427
+ **Returns:** A promise that resolves when the file is written.
430
428
 
431
- #### `getCapabilities()`
429
+ #### `appendFile(path, data, options)`
432
430
 
433
- Get the platform's filesystem capabilities.
431
+ Append text content to a file.
434
432
 
435
433
  ```typescript
436
- function getCapabilities(): Promise<FilesystemCapabilities>
434
+ function appendFile(path: string, data: string, options?: WriteOptions): Promise<void>
437
435
  ```
438
436
 
439
- **Returns:** The capabilities indicating available directories, picker support, and size limits.
437
+ - `path` — The file path to append to.
438
+ - `data` — The text content to append.
439
+ - `options` — Write options (directory, encoding).
440
440
 
441
- #### `getDirname(path)`
441
+ **Returns:** A promise that resolves when the data is appended.
442
442
 
443
- Get the directory portion of a file path.
443
+ #### `deleteFile(path, options)`
444
+
445
+ Delete a file.
444
446
 
445
447
  ```typescript
446
- function getDirname(path: string): string
448
+ function deleteFile(path: string, options?: DeleteOptions): Promise<void>
447
449
  ```
448
450
 
449
- - `path` — The file path.
451
+ - `path` — The file path to delete.
452
+ - `options` — Delete options (directory, recursive).
450
453
 
451
- **Returns:** The parent directory path (e.g., '/docs' from '/docs/readme.md').
454
+ **Returns:** A promise that resolves when the file is deleted.
452
455
 
453
- #### `getExtension(path)`
456
+ #### `mkdir(path, options)`
454
457
 
455
- Extract the file extension from a path, without the leading dot.
458
+ Create a directory.
456
459
 
457
460
  ```typescript
458
- function getExtension(path: string): string
461
+ function mkdir(path: string, options?: WriteOptions): Promise<void>
459
462
  ```
460
463
 
461
- - `path` — The file path or filename.
464
+ - `path` — The directory path to create.
465
+ - `options` — Write options (directory, recursive for parent directories).
462
466
 
463
- **Returns:** The lowercase extension (e.g., 'txt'), or empty string if none.
467
+ **Returns:** A promise that resolves when the directory is created.
464
468
 
465
- #### `getMimeType(path)`
469
+ #### `rmdir(path, options)`
466
470
 
467
- Infer a MIME type from a file extension. Supports common image, document,
468
- text, media, and archive formats. Falls back to 'application/octet-stream'.
471
+ Remove a directory.
469
472
 
470
473
  ```typescript
471
- function getMimeType(path: string): string
474
+ function rmdir(path: string, options?: DeleteOptions): Promise<void>
472
475
  ```
473
476
 
474
- - `path` — The file path or extension to look up.
477
+ - `path` — The directory path to remove.
478
+ - `options` — Delete options (directory, recursive for contents).
475
479
 
476
- **Returns:** The inferred MIME type string.
480
+ **Returns:** A promise that resolves when the directory is removed.
477
481
 
478
- #### `getProvider()`
482
+ #### `readdir(path, options)`
479
483
 
480
- Get the current filesystem provider.
484
+ List directory contents.
481
485
 
482
486
  ```typescript
483
- function getProvider(): FilesystemProvider
487
+ function readdir(path: string, options?: ListOptions): Promise<FileInfo[]>
484
488
  ```
485
489
 
486
- **Returns:** The active FilesystemProvider instance.
490
+ - `path` — The directory path to list.
491
+ - `options` — List options (directory, include hidden files).
487
492
 
488
- #### `getUri(path, options)`
493
+ **Returns:** An array of FileInfo objects for each entry.
489
494
 
490
- Get the platform-specific URI for a file path.
495
+ #### `stat(path, options)`
496
+
497
+ Get file or directory metadata.
491
498
 
492
499
  ```typescript
493
- function getUri(path: string, options?: StatOptions): Promise<string>
500
+ function stat(path: string, options?: StatOptions): Promise<FileInfo>
494
501
  ```
495
502
 
496
- - `path` — The file path to resolve.
503
+ - `path` — The path to stat.
497
504
  - `options` — Stat options (directory).
498
505
 
499
- **Returns:** The file's platform URI string.
500
-
501
- #### `hasProvider()`
502
-
503
- Check if a filesystem provider has been registered.
504
-
505
- ```typescript
506
- function hasProvider(): boolean
507
- ```
508
-
509
- **Returns:** Whether a FilesystemProvider has been bonded.
506
+ **Returns:** The FileInfo with size, dates, and type information.
510
507
 
511
- #### `joinPath(segments)`
508
+ #### `exists(path, options)`
512
509
 
513
- Join multiple path segments into a single normalized path.
514
- Collapses duplicate slashes and removes trailing slashes.
510
+ Check if a file or directory exists.
515
511
 
516
512
  ```typescript
517
- function joinPath(segments?: string[]): string
513
+ function exists(path: string, options?: StatOptions): Promise<boolean>
518
514
  ```
519
515
 
520
- - `segments` — The path segments to join.
516
+ - `path` — The path to check.
517
+ - `options` — Stat options (directory).
521
518
 
522
- **Returns:** The joined and normalized path.
519
+ **Returns:** Whether the path exists.
523
520
 
524
- #### `mkdir(path, options)`
521
+ #### `copy(from, to, options)`
525
522
 
526
- Create a directory.
523
+ Copy a file to a new location.
527
524
 
528
525
  ```typescript
529
- function mkdir(path: string, options?: WriteOptions): Promise<void>
526
+ function copy(from: string, to: string, options?: CopyOptions): Promise<void>
530
527
  ```
531
528
 
532
- - `path` — The directory path to create.
533
- - `options` — Write options (directory, recursive for parent directories).
529
+ - `from` — The source file path.
530
+ - `to` — The destination file path.
531
+ - `options` — Copy options (source/dest directories, overwrite).
534
532
 
535
- **Returns:** A promise that resolves when the directory is created.
533
+ **Returns:** A promise that resolves when the file is copied.
536
534
 
537
535
  #### `move(from, to, options)`
538
536
 
@@ -548,112 +546,114 @@ function move(from: string, to: string, options?: CopyOptions): Promise<void>
548
546
 
549
547
  **Returns:** A promise that resolves when the file is moved.
550
548
 
551
- #### `readdir(path, options)`
549
+ #### `getUri(path, options)`
552
550
 
553
- List directory contents.
551
+ Get the platform-specific URI for a file path.
554
552
 
555
553
  ```typescript
556
- function readdir(path: string, options?: ListOptions): Promise<FileInfo[]>
554
+ function getUri(path: string, options?: StatOptions): Promise<string>
557
555
  ```
558
556
 
559
- - `path` — The directory path to list.
560
- - `options` — List options (directory, include hidden files).
557
+ - `path` — The file path to resolve.
558
+ - `options` — Stat options (directory).
561
559
 
562
- **Returns:** An array of FileInfo objects for each entry.
560
+ **Returns:** The file's platform URI string.
563
561
 
564
- #### `readFile(path, options)`
562
+ #### `getAvailableSpace(directory)`
565
563
 
566
- Read a file as text.
564
+ Get available storage space in bytes for a directory.
567
565
 
568
566
  ```typescript
569
- function readFile(path: string, options?: ReadOptions): Promise<string>
567
+ function getAvailableSpace(directory?: Directory): Promise<number>
570
568
  ```
571
569
 
572
- - `path` — The file path to read.
573
- - `options` — Read options (directory, encoding).
570
+ - `directory` — The directory type to check (defaults to app data).
574
571
 
575
- **Returns:** The file contents as a string.
572
+ **Returns:** The available space in bytes.
576
573
 
577
- #### `readFileAsBlob(path, options)`
574
+ #### `getCapabilities()`
578
575
 
579
- Read a file as binary data.
576
+ Get the platform's filesystem capabilities.
580
577
 
581
578
  ```typescript
582
- function readFileAsBlob(path: string, options?: Omit<ReadOptions, 'encoding'>): Promise<Blob>
579
+ function getCapabilities(): Promise<FilesystemCapabilities>
583
580
  ```
584
581
 
585
- - `path` — The file path to read.
586
- - `options` — Read options (directory).
582
+ **Returns:** The capabilities indicating available directories, picker support, and size limits.
587
583
 
588
- **Returns:** The file contents as a Blob.
584
+ #### `formatFileSize(bytes)`
589
585
 
590
- #### `rmdir(path, options)`
586
+ Format a byte count as a human-readable file size string (e.g., '1.5 MB').
591
587
 
592
- Remove a directory.
588
+ ```typescript
589
+ function formatFileSize(bytes: number): string
590
+ ```
591
+
592
+ - `bytes` — The size in bytes.
593
+
594
+ **Returns:** A formatted string with the appropriate unit (B, KB, MB, GB, TB).
595
+
596
+ #### `getExtension(path)`
597
+
598
+ Extract the file extension from a path, without the leading dot.
593
599
 
594
600
  ```typescript
595
- function rmdir(path: string, options?: DeleteOptions): Promise<void>
601
+ function getExtension(path: string): string
596
602
  ```
597
603
 
598
- - `path` — The directory path to remove.
599
- - `options` — Delete options (directory, recursive for contents).
604
+ - `path` — The file path or filename.
600
605
 
601
- **Returns:** A promise that resolves when the directory is removed.
606
+ **Returns:** The lowercase extension (e.g., 'txt'), or empty string if none.
602
607
 
603
- #### `setProvider(provider)`
608
+ #### `getBasename(path)`
604
609
 
605
- Set the filesystem provider.
610
+ Get the filename without its extension from a path.
606
611
 
607
612
  ```typescript
608
- function setProvider(provider: FilesystemProvider): void
613
+ function getBasename(path: string): string
609
614
  ```
610
615
 
611
- - `provider` — FilesystemProvider implementation to register.
616
+ - `path` — The file path.
612
617
 
613
- #### `stat(path, options)`
618
+ **Returns:** The base filename without extension (e.g., 'readme' from '/docs/readme.md').
614
619
 
615
- Get file or directory metadata.
620
+ #### `getDirname(path)`
621
+
622
+ Get the directory portion of a file path.
616
623
 
617
624
  ```typescript
618
- function stat(path: string, options?: StatOptions): Promise<FileInfo>
625
+ function getDirname(path: string): string
619
626
  ```
620
627
 
621
- - `path` — The path to stat.
622
- - `options` — Stat options (directory).
628
+ - `path` — The file path.
623
629
 
624
- **Returns:** The FileInfo with size, dates, and type information.
630
+ **Returns:** The parent directory path (e.g., '/docs' from '/docs/readme.md').
625
631
 
626
- #### `writeFile(path, data, options)`
632
+ #### `joinPath(segments)`
627
633
 
628
- Write text content to a file.
634
+ Join multiple path segments into a single normalized path.
635
+ Collapses duplicate slashes and removes trailing slashes.
629
636
 
630
637
  ```typescript
631
- function writeFile(path: string, data: string, options?: WriteOptions): Promise<void>
638
+ function joinPath(...segments: string[]): string
632
639
  ```
633
640
 
634
- - `path` — The file path to write to.
635
- - `data` — The text content to write.
636
- - `options` — Write options (directory, encoding, recursive, append).
641
+ - `segments` — The path segments to join.
637
642
 
638
- **Returns:** A promise that resolves when the file is written.
643
+ **Returns:** The joined and normalized path.
639
644
 
640
- #### `writeFileFromBlob(path, data, options)`
645
+ #### `getMimeType(path)`
641
646
 
642
- Write binary data to a file.
647
+ Infer a MIME type from a file extension. Supports common image, document,
648
+ text, media, and archive formats. Falls back to 'application/octet-stream'.
643
649
 
644
650
  ```typescript
645
- function writeFileFromBlob(
646
- path: string,
647
- data: Blob,
648
- options?: Omit<WriteOptions, 'encoding'>,
649
- ): Promise<void>
651
+ function getMimeType(path: string): string
650
652
  ```
651
653
 
652
- - `path` — The file path to write to.
653
- - `data` — The binary data to write as a Blob.
654
- - `options` — Write options (directory, recursive).
654
+ - `path` — The file path or extension to look up.
655
655
 
656
- **Returns:** A promise that resolves when the file is written.
656
+ **Returns:** The inferred MIME type string.
657
657
 
658
658
  ## Injection Notes
659
659
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-filesystem",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Device filesystem access interface for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,10 +33,10 @@
33
33
  "@molecule/app-i18n": "^1.0.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@molecule/app-bond": "1.0.2",
37
- "@types/node": "26.1.2",
36
+ "@molecule/app-bond": "1.0.5",
37
+ "@types/node": "26.6.5",
38
38
  "typescript": "6.0.3",
39
- "vitest": "4.1.11"
39
+ "vitest": "4.1.12"
40
40
  },
41
41
  "repository": {
42
42
  "type": "git",