@auto-engineer/server-implementer 1.147.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/server-implementer@1.147.0 build /home/runner/work/auto-engineer/auto-engineer/packages/server-implementer
2
+ > @auto-engineer/server-implementer@1.149.0 build /home/runner/work/auto-engineer/auto-engineer/packages/server-implementer
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/server-implementer@1.146.0 test /home/runner/work/auto-engineer/auto-engineer/packages/server-implementer
2
+ > @auto-engineer/server-implementer@1.148.0 test /home/runner/work/auto-engineer/auto-engineer/packages/server-implementer
3
3
  > vitest run --reporter=dot
4
4
 
5
5
 
@@ -9,6 +9,6 @@
9
9
 
10
10
   Test Files  7 passed (7)
11
11
   Tests  46 passed (46)
12
-  Start at  19:12:32
13
-  Duration  14.26s (transform 1.60s, setup 0ms, collect 26.16s, tests 917ms, environment 2ms, prepare 5.19s)
12
+  Start at  07:23:14
13
+  Duration  16.18s (transform 1.91s, setup 0ms, collect 29.68s, tests 1.30s, environment 2ms, prepare 5.72s)
14
14
 
@@ -1,4 +1,4 @@
1
1
 
2
- > @auto-engineer/server-implementer@1.146.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/server-implementer
2
+ > @auto-engineer/server-implementer@1.148.0 type-check /home/runner/work/auto-engineer/auto-engineer/packages/server-implementer
3
3
  > tsc --noEmit
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @auto-engineer/server-implementer
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
+
17
+ - Updated dependencies [[`d38c81e`](https://github.com/BeOnAuto/auto-engineer/commit/d38c81e7bb442a39626564cf4f6d8d55b60d0a38), [`e1eebbd`](https://github.com/BeOnAuto/auto-engineer/commit/e1eebbdf4f209780e790094d2e6887c4fa809f98)]:
18
+ - @auto-engineer/message-bus@1.149.0
19
+ - @auto-engineer/model-factory@1.149.0
20
+
21
+ ## 1.148.0
22
+
23
+ ### Minor Changes
24
+
25
+ - [`d5ba3a0`](https://github.com/BeOnAuto/auto-engineer/commit/d5ba3a0e3fb0f6a9ad7a3a8b1815590ea77a5b42) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added state context instruction to generated decide handlers, preventing unnecessary narrowing when Given steps contain only state references
26
+
27
+ - [`e0cdc4e`](https://github.com/BeOnAuto/auto-engineer/commit/e0cdc4e3363ad84d4bc49996a600ac75c97ccc38) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added context-aware classification of non-command fields in generated decide.ts scaffolds, distinguishing between date-derived, state-derived, and not-yet-tested fields
28
+
29
+ - [`9195db7`](https://github.com/BeOnAuto/auto-engineer/commit/9195db78cb707d658866cee99a1c73d34fb4efde) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Extracted shared template helpers into a dedicated module for cleaner code generation
30
+
31
+ - [`abb6540`](https://github.com/BeOnAuto/auto-engineer/commit/abb6540db7196ed7935c8a8610695828f9035fc3) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added status variant hints from Given state references to the state template, helping implementers create matching discriminated union variants
32
+
33
+ - [`9195db7`](https://github.com/BeOnAuto/auto-engineer/commit/9195db78cb707d658866cee99a1c73d34fb4efde) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Extracted shared template helper functions into a dedicated module for better code reuse across generators
34
+ - Simplified template specs by removing inline duplicate definitions in favor of the shared helpers
35
+
36
+ ### Patch Changes
37
+
38
+ - [`88fb1da`](https://github.com/BeOnAuto/auto-engineer/commit/88fb1da2b222de04dd4959d87657395ee960a6ce) Thanks [@github-actions[bot]](https://github.com/github-actions%5Bbot%5D)! - - **server-generator-apollo-emmett**: skip empty file plans in scaffold output
39
+ - **server-generator-apollo-emmett**: filter state refs from given() in decide.specs.ts.ejs
40
+ - **server-generator-apollo-emmett**: move CS Given states from events to states array
41
+ - **global**: version packages
42
+ - **server-generator-apollo-emmett**: mark G1+G2 ketchup plan complete
43
+
44
+ - [`4255f6d`](https://github.com/BeOnAuto/auto-engineer/commit/4255f6db0d128979e573244a615886482ce799b0) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Updated ketchup plan for state reference fix in decide template generator
45
+ - Marked generator bug fix milestones G1 and G2 as complete
46
+
47
+ - [`62f1ea3`](https://github.com/BeOnAuto/auto-engineer/commit/62f1ea3dd1b4275211574e3df9d9a6571ae9b27a) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Fixed scaffold generation to correctly distinguish between event and state references in decision handlers
48
+ - Prevented contradictory instructions from appearing in generated code when Given clauses contain only state references
49
+
50
+ - [`ba4f5c9`](https://github.com/BeOnAuto/auto-engineer/commit/ba4f5c9749fb1c15d444e78ca9a2689817f039cb) Thanks [@rami-hatoum](https://github.com/rami-hatoum)! - - Added implementation plan for decide.ts code generation fixes in the Apollo Emmett server generator
51
+
52
+ - Updated dependencies [[`88fb1da`](https://github.com/BeOnAuto/auto-engineer/commit/88fb1da2b222de04dd4959d87657395ee960a6ce), [`d5ba3a0`](https://github.com/BeOnAuto/auto-engineer/commit/d5ba3a0e3fb0f6a9ad7a3a8b1815590ea77a5b42), [`e0cdc4e`](https://github.com/BeOnAuto/auto-engineer/commit/e0cdc4e3363ad84d4bc49996a600ac75c97ccc38), [`4255f6d`](https://github.com/BeOnAuto/auto-engineer/commit/4255f6db0d128979e573244a615886482ce799b0), [`9195db7`](https://github.com/BeOnAuto/auto-engineer/commit/9195db78cb707d658866cee99a1c73d34fb4efde), [`abb6540`](https://github.com/BeOnAuto/auto-engineer/commit/abb6540db7196ed7935c8a8610695828f9035fc3), [`9195db7`](https://github.com/BeOnAuto/auto-engineer/commit/9195db78cb707d658866cee99a1c73d34fb4efde), [`62f1ea3`](https://github.com/BeOnAuto/auto-engineer/commit/62f1ea3dd1b4275211574e3df9d9a6571ae9b27a), [`ba4f5c9`](https://github.com/BeOnAuto/auto-engineer/commit/ba4f5c9749fb1c15d444e78ca9a2689817f039cb)]:
53
+ - @auto-engineer/message-bus@1.148.0
54
+ - @auto-engineer/model-factory@1.148.0
55
+
3
56
  ## 1.147.0
4
57
 
5
58
  ### Minor Changes
package/README.md CHANGED
@@ -6,9 +6,9 @@ AI-powered code implementation that completes TODO-marked TypeScript files in ev
6
6
 
7
7
  ## Purpose
8
8
 
9
- Without `@auto-engineer/server-implementer`, you would have to manually implement scaffolded TypeScript code, run tests, interpret errors, and iterate on fixes by hand.
9
+ Without `@auto-engineer/server-implementer`, you would have to manually implement scaffolded TypeScript code in CQRS/event-sourced servers, run tests, interpret errors, and iterate on fixes by hand.
10
10
 
11
- This package automates the implementation of scaffolded CQRS/event-sourced server code. It identifies files with TODO markers, generates implementations using AI, validates with TypeScript and Vitest, and retries with error feedback until tests pass.
11
+ This package automates that loop. It scans a server project for files containing TODO markers or `IMPLEMENTATION INSTRUCTIONS`, generates implementations using an LLM, validates the output with TypeScript type-checking and Vitest, and retries with error feedback until tests pass -- up to 5 attempts per file.
12
12
 
13
13
  ---
14
14
 
@@ -18,9 +18,9 @@ This package automates the implementation of scaffolded CQRS/event-sourced serve
18
18
  pnpm add @auto-engineer/server-implementer
19
19
  ```
20
20
 
21
- ## Quick Start
21
+ ---
22
22
 
23
- Register the handler and implement server code:
23
+ ## Quick Start
24
24
 
25
25
  ### 1. Register the handlers
26
26
 
@@ -32,7 +32,7 @@ const bus = createMessageBus();
32
32
  COMMANDS.forEach(cmd => bus.registerCommand(cmd));
33
33
  ```
34
34
 
35
- ### 2. Send a command
35
+ ### 2. Implement an entire server
36
36
 
37
37
  ```typescript
38
38
  const result = await bus.dispatch({
@@ -43,11 +43,28 @@ const result = await bus.dispatch({
43
43
  requestId: 'req-123',
44
44
  });
45
45
 
46
- console.log(result);
47
- // → { type: 'ServerImplemented', data: { serverDirectory: './server' } }
46
+ if (result.type === 'ServerImplemented') {
47
+ console.log('Done:', result.data.scenesImplemented, 'scenes processed');
48
+ }
48
49
  ```
49
50
 
50
- The command processes all flows in `src/domain/narratives/` and implements TODO-marked files.
51
+ The command walks all scene directories under `src/domain/narratives/` and implements every slice it finds.
52
+
53
+ ### 3. Implement a single slice
54
+
55
+ ```typescript
56
+ const result = await bus.dispatch({
57
+ type: 'ImplementMoment',
58
+ data: {
59
+ momentPath: './server/src/domain/narratives/order/place-order',
60
+ },
61
+ requestId: 'req-456',
62
+ });
63
+
64
+ if (result.type === 'MomentImplemented') {
65
+ console.log('Files implemented:', result.data.filesImplemented);
66
+ }
67
+ ```
51
68
 
52
69
  ---
53
70
 
@@ -57,58 +74,74 @@ The command processes all flows in `src/domain/narratives/` and implements TODO-
57
74
 
58
75
  ```bash
59
76
  auto implement:server --server-directory=./server
60
- auto implement:slice --slice-path=./server/src/domain/narratives/order/place-order
77
+ auto implement:slice --moment-path=./server/src/domain/narratives/order/place-order
61
78
  ```
62
79
 
63
- ### Run Programmatically
80
+ ### Run programmatically (without the bus)
64
81
 
65
82
  ```typescript
66
- import { handleImplementSliceCommand } from '@auto-engineer/server-implementer';
83
+ import { handleImplementMomentCommand } from '@auto-engineer/server-implementer';
67
84
 
68
- const result = await handleImplementSliceCommand({
69
- type: 'ImplementSlice',
85
+ const result = await handleImplementMomentCommand({
86
+ type: 'ImplementMoment',
70
87
  data: {
71
- slicePath: './server/src/domain/narratives/order/place-order',
88
+ momentPath: './server/src/domain/narratives/order/place-order',
72
89
  aiOptions: { maxTokens: 4000 },
73
90
  },
74
- requestId: 'req-123',
91
+ requestId: 'req-789',
75
92
  });
76
93
  ```
77
94
 
78
- ### Retry with Previous Errors
95
+ ### Retry with previous errors
96
+
97
+ When an implementation attempt fails, pass the error output back as context so the next attempt can learn from it:
79
98
 
80
99
  ```typescript
81
- const retryResult = await handleImplementSliceCommand({
82
- type: 'ImplementSlice',
100
+ const retryResult = await handleImplementMomentCommand({
101
+ type: 'ImplementMoment',
83
102
  data: {
84
- slicePath: './server/src/domain/narratives/order/place-order',
103
+ momentPath: './server/src/domain/narratives/order/place-order',
85
104
  context: {
86
105
  previousOutputs: 'TypeError: Property "status" is missing...',
87
106
  attemptNumber: 2,
88
107
  },
89
108
  },
90
- requestId: 'req-124',
109
+ requestId: 'req-790',
91
110
  });
92
111
  ```
93
112
 
94
- ### Handle Errors
113
+ ### Handle errors
95
114
 
96
115
  ```typescript
97
116
  if (result.type === 'ServerImplementationFailed') {
98
117
  console.error(result.data.error);
99
118
  }
100
119
 
101
- if (result.type === 'SliceImplementationFailed') {
120
+ if (result.type === 'MomentImplementationFailed') {
102
121
  console.error(result.data.error);
103
122
  }
104
123
  ```
105
124
 
106
- ### Enable Debug Logging
125
+ ### Enable debug logging
107
126
 
108
127
  ```bash
109
128
  DEBUG=auto:server-implementer:* auto implement:server --server-directory=./server
110
129
  ```
111
130
 
131
+ Namespaces available:
132
+
133
+ | Namespace | What it logs |
134
+ |-----------|-------------|
135
+ | `auto:server-implementer:command` | Top-level command lifecycle |
136
+ | `auto:server-implementer:command:handler` | Path resolution and validation |
137
+ | `auto:server-implementer:command:process` | Scene runner progress |
138
+ | `auto:server-implementer:command:result` | Final outcome |
139
+ | `auto:server-implementer:slice` | Single-slice command lifecycle |
140
+ | `auto:server-implementer:slice:handler` | Slice path resolution |
141
+ | `auto:server-implementer:slice:process` | Per-file AI generation and retries |
142
+ | `auto:server-implementer:slice:result` | Slice outcome |
143
+ | `auto:server-implementer:scenes` | Scene directory discovery |
144
+
112
145
  ---
113
146
 
114
147
  ## API Reference
@@ -119,17 +152,19 @@ DEBUG=auto:server-implementer:* auto implement:server --server-directory=./serve
119
152
  import {
120
153
  COMMANDS,
121
154
  implementServerHandler,
122
- implementSliceHandler,
123
- handleImplementSliceCommand,
155
+ implementMomentHandler,
156
+ handleImplementMomentCommand,
124
157
  } from '@auto-engineer/server-implementer';
125
158
 
126
159
  import type {
127
160
  ImplementServerCommand,
161
+ ImplementServerEvents,
128
162
  ServerImplementedEvent,
129
163
  ServerImplementationFailedEvent,
130
- ImplementSliceCommand,
131
- SliceImplementedEvent,
132
- SliceImplementationFailedEvent,
164
+ ImplementMomentCommand,
165
+ ImplementMomentEvents,
166
+ MomentImplementedEvent,
167
+ MomentImplementationFailedEvent,
133
168
  } from '@auto-engineer/server-implementer';
134
169
  ```
135
170
 
@@ -137,8 +172,8 @@ import type {
137
172
 
138
173
  | Command | CLI Alias | Description |
139
174
  |---------|-----------|-------------|
140
- | `ImplementServer` | `implement:server` | Implement all flows in server project |
141
- | `ImplementSlice` | `implement:slice` | Implement single slice directory |
175
+ | `ImplementServer` | `implement:server` | Implement all scenes and slices in a server project |
176
+ | `ImplementMoment` | `implement:slice` | Implement a single slice directory |
142
177
 
143
178
  ### ImplementServerCommand
144
179
 
@@ -151,13 +186,18 @@ type ImplementServerCommand = Command<
151
186
  >;
152
187
  ```
153
188
 
154
- ### ImplementSliceCommand
189
+ **Events:**
190
+
191
+ - `ServerImplemented` -- `{ serverDirectory: string; scenesImplemented: number }`
192
+ - `ServerImplementationFailed` -- `{ serverDirectory: string; error: string }`
193
+
194
+ ### ImplementMomentCommand
155
195
 
156
196
  ```typescript
157
- type ImplementSliceCommand = Command<
158
- 'ImplementSlice',
197
+ type ImplementMomentCommand = Command<
198
+ 'ImplementMoment',
159
199
  {
160
- slicePath: string;
200
+ momentPath: string;
161
201
  context?: {
162
202
  previousOutputs?: string;
163
203
  attemptNumber?: number;
@@ -169,17 +209,10 @@ type ImplementSliceCommand = Command<
169
209
  >;
170
210
  ```
171
211
 
172
- ### SliceImplementedEvent
212
+ **Events:**
173
213
 
174
- ```typescript
175
- type SliceImplementedEvent = Event<
176
- 'SliceImplemented',
177
- {
178
- slicePath: string;
179
- filesImplemented: string[];
180
- }
181
- >;
182
- ```
214
+ - `MomentImplemented` -- `{ momentPath: string; filesImplemented: string[] }`
215
+ - `MomentImplementationFailed` -- `{ momentPath: string; error: string }`
183
216
 
184
217
  ---
185
218
 
@@ -187,52 +220,74 @@ type SliceImplementedEvent = Event<
187
220
 
188
221
  ```
189
222
  src/
190
- ├── index.ts
223
+ ├── index.ts # COMMANDS array, re-exports
191
224
  ├── commands/
192
- │ ├── implement-server.ts
193
- │ └── implement-slice.ts
225
+ │ ├── implement-server.ts # ImplementServer command handler
226
+ │ └── implement-slice.ts # ImplementMoment command handler
194
227
  ├── agent/
195
- │ ├── runFlows.ts
196
- │ ├── runAllSlices.ts
197
- │ ├── runSlice.ts
198
- │ └── runTests.ts
228
+ │ ├── runFlows.ts # Discovers and iterates scene directories
229
+ │ ├── runAllSlices.ts # Iterates moment directories within a scene
230
+ │ ├── runSlice.ts # Per-slice: AI generate, test, typecheck, retry
231
+ │ └── runTests.ts # Vitest runner with JSON report parsing
199
232
  ├── prompts/
200
- │ └── systemPrompt.ts
233
+ │ └── systemPrompt.ts # System prompt for AI code generation
201
234
  └── utils/
202
- └── extractCodeBlock.ts
235
+ ├── buildContextSections.ts # Formats context files into prompt sections
236
+ ├── detectImportedTypeShadowing.ts # Detects re-declared imported types
237
+ ├── detectTypeAssertions.ts # Detects forbidden `as` casts
238
+ ├── extractCodeBlock.ts # Strips markdown fences from AI output
239
+ ├── findFilesToImplement.ts # Filters + priority-sorts TODO-marked files
240
+ ├── loadContextFiles.ts # Loads all .ts files in a slice directory
241
+ └── loadSharedContext.ts # Loads shared domain types from ../../../shared
203
242
  ```
204
243
 
205
- The following diagram shows the implementation flow:
244
+ ### Implementation flow
206
245
 
207
246
  ```mermaid
208
247
  flowchart TB
209
- A[ImplementSlice] --> B[Load Slice Files]
210
- B --> C[Find TODO Markers]
211
- C --> D[Generate via AI]
212
- D --> E[Write File]
213
- E --> F[Run Tests + TypeCheck]
214
- F --> G{Pass?}
215
- G -->|Yes| H[SliceImplementedEvent]
216
- G -->|No| I{Retries < 5?}
217
- I -->|Yes| J[Build Retry Prompt]
218
- J --> D
219
- I -->|No| K[SliceImplementationFailedEvent]
248
+ A[ImplementServer command] --> B[Discover scenes in src/domain/narratives/]
249
+ B --> C[For each scene: discover slices]
250
+ C --> D[For each slice: load context files]
251
+ D --> E[Find files with TODO markers]
252
+ E --> F[Generate implementation via AI]
253
+ F --> G[Write generated code to disk]
254
+ G --> H[Run Vitest + tsc --noEmit]
255
+ H --> I{Pass?}
256
+ I -->|Yes| J[Done]
257
+ I -->|No| K{Retries left?}
258
+ K -->|Yes| L[Build retry prompt with errors]
259
+ L --> F
260
+ K -->|No| M[Report remaining failures]
220
261
  ```
221
262
 
222
- *Flow: Command loads files, identifies TODOs, generates via AI, validates, retries up to 5 times on failure.*
263
+ ### Validation checks
264
+
265
+ Each implementation pass runs three checks before accepting the output:
266
+
267
+ 1. **Vitest** -- runs spec files in the slice, parses JSON report for failures
268
+ 2. **TypeScript** -- `tsc --noEmit` filtered to errors in the slice directory
269
+ 3. **Static analysis** -- detects imported-type shadowing and forbidden `as` type assertions
270
+
271
+ Files that fail typecheck are retried up to 5 times. Files that fail tests are retried separately, also up to 5 times. If a test fix introduces a type error, a nested typecheck retry loop runs (max depth 2).
272
+
273
+ ### Implementation priority
274
+
275
+ When multiple files need implementation, they are processed in this order: `state.ts`, `events.ts`, `commands.ts`, `evolve.ts`, `decide.ts`, then alphabetically.
276
+
277
+ ### Implementation markers
223
278
 
224
- ### Implementation Markers
279
+ Files are identified for AI implementation by the presence of any of:
225
280
 
226
- Files are identified for processing by:
227
281
  - `// @auto-implement` comment
228
- - `TODO:` comments
282
+ - `TODO:` comment
229
283
  - `IMPLEMENTATION INSTRUCTIONS` text
230
284
 
231
285
  ### Dependencies
232
286
 
233
287
  | Package | Usage |
234
288
  |---------|-------|
235
- | `@auto-engineer/ai-gateway` | AI text generation |
236
- | `@auto-engineer/message-bus` | Command/event infrastructure |
237
- | `fast-glob` | File discovery |
238
- | `debug` | Debug logging |
289
+ | `@auto-engineer/model-factory` | Creates the AI model instance from environment config |
290
+ | `@auto-engineer/message-bus` | Command/event handler infrastructure |
291
+ | `ai` (Vercel AI SDK) | `generateText` for LLM calls |
292
+ | `fast-glob` | File and directory discovery |
293
+ | `debug` | Namespaced debug logging |
package/package.json CHANGED
@@ -18,8 +18,8 @@
18
18
  "debug": "^4.3.4",
19
19
  "fast-glob": "^3.3.3",
20
20
  "vite": "^5.4.1",
21
- "@auto-engineer/model-factory": "1.147.0",
22
- "@auto-engineer/message-bus": "1.147.0"
21
+ "@auto-engineer/model-factory": "1.149.0",
22
+ "@auto-engineer/message-bus": "1.149.0"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/fs-extra": "^11.0.4",
@@ -29,9 +29,9 @@
29
29
  "glob": "^11.0.3",
30
30
  "tsx": "^4.20.3",
31
31
  "typescript": "^5.8.3",
32
- "@auto-engineer/cli": "1.147.0"
32
+ "@auto-engineer/cli": "1.149.0"
33
33
  },
34
- "version": "1.147.0",
34
+ "version": "1.149.0",
35
35
  "scripts": {
36
36
  "build": "tsc && tsx ../../scripts/fix-esm-imports.ts",
37
37
  "test": "vitest run --reporter=dot",