@auto-engineer/file-store 1.148.0 → 1.149.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > @auto-engineer/file-store@1.148.0 build /home/runner/work/auto-engineer/auto-engineer/packages/file-store
2
+ > @auto-engineer/file-store@1.149.0 build /home/runner/work/auto-engineer/auto-engineer/packages/file-store
3
3
  > tsc && tsx ../../scripts/fix-esm-imports.ts
4
4
 
5
5
  Fixed ESM imports in dist/
@@ -1,5 +1,5 @@
1
1
 
2
- > @auto-engineer/file-store@1.147.0 test /home/runner/work/auto-engineer/auto-engineer/packages/file-store
2
+ > @auto-engineer/file-store@1.148.0 test /home/runner/work/auto-engineer/auto-engineer/packages/file-store
3
3
  > vitest run --reporter=dot
4
4
 
5
5
 
@@ -9,6 +9,6 @@
9
9
 
10
10
   Test Files  1 passed (1)
11
11
   Tests  5 passed (5)
12
-  Start at  21:35:26
13
-  Duration  1.64s (transform 292ms, setup 0ms, collect 295ms, tests 71ms, environment 0ms, prepare 528ms)
12
+  Start at  07:22:16
13
+  Duration  2.14s (transform 388ms, setup 0ms, collect 342ms, tests 186ms, environment 0ms, prepare 579ms)
14
14
 
@@ -1,4 +1,4 @@
1
1
 
2
- > @auto-engineer/file-store@1.147.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/file-store
2
+ > @auto-engineer/file-store@1.148.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/file-store
3
3
  > tsc --noEmit
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @auto-engineer/file-store
2
2
 
3
+ ## 1.149.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`e1eebbd`](https://github.com/BeOnAuto/auto-engineer/commit/e1eebbdf4f209780e790094d2e6887c4fa809f98) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: add Given state ref hints to state.ts.ejs
8
+ - **server-generator-apollo-emmett**: context-aware nonCommandField instructions
9
+ - **server-generator-apollo-emmett**: add state context instruction
10
+ - **server-generator-apollo-emmett**: extract shared template helpers
11
+ - **server-generator-apollo-emmett**: filter state refs from hasGivenEvents in decide.ts.ejs
12
+
13
+ ### Patch Changes
14
+
15
+ - [`d38c81e`](https://github.com/BeOnAuto/auto-engineer/commit/d38c81e7bb442a39626564cf4f6d8d55b60d0a38) Thanks [@SamHatoum](https://github.com/SamHatoum)! -
16
+
3
17
  ## 1.148.0
4
18
 
5
19
  ### Minor Changes
package/README.md CHANGED
@@ -6,9 +6,17 @@ Platform-agnostic file storage abstraction with in-memory and Node.js implementa
6
6
 
7
7
  ## Purpose
8
8
 
9
- Without `@auto-engineer/file-store`, you would have to write platform-specific file operations, handle path normalization across operating systems, and create separate test implementations for file-dependent code.
9
+ Without `@auto-engineer/file-store`, you would have to write platform-specific file operations, handle path normalization across operating systems, and maintain separate test doubles for every component that touches the filesystem.
10
10
 
11
- This package provides unified interfaces for file system operations. The in-memory implementation enables testing without touching the disk, while the Node.js implementation handles real file operations with automatic directory creation.
11
+ This package defines a single `IFileStore` interface that both `InMemoryFileStore` and `NodeFileStore` implement. Code that depends on `IFileStore` can run against the in-memory store in tests and the Node store in production with no changes. All paths are normalized to POSIX format, and all reads return `null` for missing files instead of throwing.
12
+
13
+ ## Key Concepts
14
+
15
+ - **Binary-first API** -- Core operations use `Uint8Array` for cross-platform compatibility. The Node store adds text convenience methods via `IExtendedFileStore`.
16
+ - **Null over exceptions** -- `read()` and `readText()` return `null` for missing files rather than throwing.
17
+ - **POSIX normalization** -- All paths use forward slashes, even on Windows.
18
+ - **Auto directory creation** -- `write()` and `writeText()` create parent directories automatically.
19
+ - **Two entry points** -- The main entry point (`"."`) is platform-agnostic; the `"./node"` entry point requires Node.js built-ins.
12
20
 
13
21
  ---
14
22
 
@@ -36,7 +44,7 @@ console.log(new TextDecoder().decode(data!));
36
44
 
37
45
  ## How-to Guides
38
46
 
39
- ### Use In-Memory Store for Testing
47
+ ### Use the In-Memory Store for Testing
40
48
 
41
49
  ```typescript
42
50
  import { InMemoryFileStore } from '@auto-engineer/file-store';
@@ -48,7 +56,7 @@ const exists = await store.exists('/input.txt');
48
56
  const tree = await store.listTree('/');
49
57
  ```
50
58
 
51
- ### Use Node Store for Production
59
+ ### Use the Node Store for Production
52
60
 
53
61
  ```typescript
54
62
  import { NodeFileStore } from '@auto-engineer/file-store/node';
@@ -59,7 +67,7 @@ await store.writeText('config.json', JSON.stringify({ key: 'value' }));
59
67
  const text = await store.readText('config.json');
60
68
  ```
61
69
 
62
- ### List Directory Tree
70
+ ### List a Directory Tree with Pruning
63
71
 
64
72
  ```typescript
65
73
  import { NodeFileStore } from '@auto-engineer/file-store/node';
@@ -69,10 +77,16 @@ const tree = await store.listTree('/project', {
69
77
  pruneDirRegex: /node_modules|\.git/,
70
78
  includeSizes: true,
71
79
  });
80
+
81
+ for (const entry of tree) {
82
+ console.log(`${entry.type} ${entry.path} (${entry.size} bytes)`);
83
+ }
72
84
  ```
73
85
 
74
86
  ### Dependency Injection
75
87
 
88
+ Accept `IFileStore` in your constructors so callers can swap implementations:
89
+
76
90
  ```typescript
77
91
  import type { IFileStore } from '@auto-engineer/file-store';
78
92
 
@@ -91,52 +105,66 @@ class DocumentManager {
91
105
 
92
106
  ### Package Exports
93
107
 
108
+ | Entry Point | Import Path | Exports |
109
+ |-------------|-------------|---------|
110
+ | Main (`.`) | `@auto-engineer/file-store` | `InMemoryFileStore`, `IFileStore`, `IExtendedFileStore` |
111
+ | Node (`./node`) | `@auto-engineer/file-store/node` | `NodeFileStore`, `IFileStore`, `IExtendedFileStore` |
112
+
94
113
  ```typescript
114
+ // Platform-agnostic (no Node.js dependency)
95
115
  import { InMemoryFileStore, type IFileStore, type IExtendedFileStore } from '@auto-engineer/file-store';
96
116
 
117
+ // Node.js only
97
118
  import { NodeFileStore } from '@auto-engineer/file-store/node';
98
119
  ```
99
120
 
100
- ### Entry Points
121
+ ### `IFileStore` Interface
101
122
 
102
- | Entry Point | Import Path | Description |
103
- |-------------|-------------|-------------|
104
- | Main | `@auto-engineer/file-store` | Platform-agnostic (InMemoryFileStore, types) |
105
- | Node | `@auto-engineer/file-store/node` | Node.js-specific (NodeFileStore) |
123
+ The base interface implemented by both stores.
106
124
 
107
- ### IFileStore Interface
125
+ | Method | Signature | Description |
126
+ |--------|-----------|-------------|
127
+ | `write` | `(path: string, data: Uint8Array) => Promise<void>` | Write binary data. Creates parent directories. |
128
+ | `read` | `(path: string) => Promise<Uint8Array \| null>` | Read binary data. Returns `null` if missing. |
129
+ | `exists` | `(path: string) => Promise<boolean>` | Check whether a file or directory exists. |
130
+ | `listTree` | `(root?: string, opts?: ListTreeOpts) => Promise<TreeEntry[]>` | Recursively list files and directories. |
131
+ | `remove` | `(path: string) => Promise<void>` | Delete a file. |
108
132
 
109
- ```typescript
110
- interface IFileStore {
111
- write(path: string, data: Uint8Array): Promise<void>;
112
- read(path: string): Promise<Uint8Array | null>;
113
- exists(path: string): Promise<boolean>;
114
- listTree(root?: string, opts?: ListTreeOptions): Promise<TreeEntry[]>;
115
- remove(path: string): Promise<void>;
116
- }
117
- ```
133
+ #### `listTree` Options
134
+
135
+ | Option | Type | Default | Description |
136
+ |--------|------|---------|-------------|
137
+ | `followSymlinkDirs` | `boolean` | `true` | Traverse symlinked directories |
138
+ | `includeSizes` | `boolean` | `true` | Include file sizes in results |
139
+ | `pruneDirRegex` | `RegExp` | -- | Skip directories whose path matches |
118
140
 
119
- ### IExtendedFileStore Interface
141
+ #### `listTree` Return Type
120
142
 
121
143
  ```typescript
122
- interface IExtendedFileStore extends IFileStore {
123
- ensureDir(path: string): Promise<void>;
124
- readdir(path: string): Promise<DirEntry[]>;
125
- readText(path: string): Promise<string | null>;
126
- writeText(path: string, text: string): Promise<void>;
127
- join(...parts: string[]): string;
128
- dirname(p: string): string;
129
- fromHere(relative: string, base?: string): string;
130
- }
144
+ Array<{ path: string; type: 'file' | 'dir'; size: number }>
131
145
  ```
132
146
 
133
- ### ListTree Options
147
+ ### `IExtendedFileStore` Interface
134
148
 
135
- | Option | Type | Default | Description |
136
- |--------|------|---------|-------------|
137
- | `followSymlinkDirs` | `boolean` | `true` | Traverse symlinked directories |
138
- | `includeSizes` | `boolean` | `true` | Include file sizes |
139
- | `pruneDirRegex` | `RegExp` | - | Skip matching directories |
149
+ Extends `IFileStore` with convenience methods. Implemented by `NodeFileStore`.
150
+
151
+ | Method | Signature | Description |
152
+ |--------|-----------|-------------|
153
+ | `ensureDir` | `(path: string) => Promise<void>` | Create a directory recursively (like `mkdir -p`). |
154
+ | `readdir` | `(path: string) => Promise<Array<{ name: string; type: 'file' \| 'dir' }>>` | List immediate children of a directory. |
155
+ | `readText` | `(path: string) => Promise<string \| null>` | Read a file as UTF-8 text. Returns `null` if missing. |
156
+ | `writeText` | `(path: string, text: string) => Promise<void>` | Write a UTF-8 text file. Creates parent directories. |
157
+ | `join` | `(...parts: string[]) => string` | Join path segments, returning a POSIX path. Handles `file://` URLs. |
158
+ | `dirname` | `(p: string) => string` | Return the directory portion of a path as a POSIX path. |
159
+ | `fromHere` | `(relative: string, base?: string) => string` | Resolve a relative path from a base directory (defaults to `__dirname`). |
160
+
161
+ ### `InMemoryFileStore` Class
162
+
163
+ Implements `IFileStore`. Stores files in a `Map<string, Uint8Array>`. Paths are normalized to start with `/`. The `remove` method deletes the path and any files beneath it (prefix match), so it works for both files and directories.
164
+
165
+ ### `NodeFileStore` Class
166
+
167
+ Implements `IExtendedFileStore`. Delegates to `node:fs/promises`. Paths can be absolute, relative (resolved against `process.cwd()`), or `file://` URLs. All returned paths use POSIX separators.
140
168
 
141
169
  ---
142
170
 
@@ -144,21 +172,45 @@ interface IExtendedFileStore extends IFileStore {
144
172
 
145
173
  ```
146
174
  src/
147
- ├── index.ts
148
- ├── node.ts
149
- ├── types.ts
150
- ├── path.ts
151
- ├── InMemoryFileStore.ts
152
- └── NodeFileStore.ts
175
+ ├── index.ts # Main entry: exports InMemoryFileStore + types
176
+ ├── node.ts # Node entry: exports NodeFileStore + types
177
+ ├── types.ts # IFileStore and IExtendedFileStore interfaces
178
+ ├── path.ts # toPosix() helper
179
+ ├── InMemoryFileStore.ts # In-memory implementation (Map-backed)
180
+ └── NodeFileStore.ts # Node.js fs implementation
153
181
  ```
154
182
 
155
- ### Key Concepts
156
-
157
- - **Binary-first API**: Core operations use `Uint8Array` for compatibility
158
- - **Null over exceptions**: Read returns `null` for missing files
159
- - **POSIX normalization**: All paths use forward slashes
160
- - **Auto directory creation**: Write creates parent directories
183
+ ```mermaid
184
+ classDiagram
185
+ class IFileStore {
186
+ <<interface>>
187
+ +write(path, data) Promise~void~
188
+ +read(path) Promise~Uint8Array | null~
189
+ +exists(path) Promise~boolean~
190
+ +listTree(root, opts) Promise~TreeEntry[]~
191
+ +remove(path) Promise~void~
192
+ }
193
+ class IExtendedFileStore {
194
+ <<interface>>
195
+ +ensureDir(path) Promise~void~
196
+ +readdir(path) Promise~DirEntry[]~
197
+ +readText(path) Promise~string | null~
198
+ +writeText(path, text) Promise~void~
199
+ +join(parts) string
200
+ +dirname(p) string
201
+ +fromHere(relative, base) string
202
+ }
203
+ IExtendedFileStore --|> IFileStore
204
+ InMemoryFileStore ..|> IFileStore
205
+ NodeFileStore ..|> IExtendedFileStore
206
+
207
+ class InMemoryFileStore {
208
+ -files Map~string, Uint8Array~
209
+ }
210
+ class NodeFileStore {
211
+ }
212
+ ```
161
213
 
162
214
  ### Dependencies
163
215
 
164
- This package has **zero external dependencies**. It uses only Node.js built-in modules.
216
+ This package has **zero external dependencies**. The Node entry point uses only Node.js built-in modules (`node:fs/promises`, `node:path`, `node:url`).
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "publishConfig": {
18
18
  "access": "public"
19
19
  },
20
- "version": "1.148.0",
20
+ "version": "1.149.0",
21
21
  "scripts": {
22
22
  "build": "tsc && tsx ../../scripts/fix-esm-imports.ts",
23
23
  "test": "vitest run --reporter=dot",