@auto-engineer/dev-server 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.
Files changed (3) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +162 -78
  3. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,5 +1,58 @@
1
1
  # @auto-engineer/dev-server
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/cli@1.149.0
19
+ - @auto-engineer/message-bus@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/cli@1.148.0
54
+ - @auto-engineer/message-bus@1.148.0
55
+
3
56
  ## 1.147.0
4
57
 
5
58
  ### Minor Changes
package/README.md CHANGED
@@ -1,14 +1,12 @@
1
1
  # @auto-engineer/dev-server
2
2
 
3
- Development server commands for starting and managing client/server processes with file watching.
3
+ Command handlers for starting, restarting, and managing development processes (server, client, Storybook) with file watching, port cleanup, and dependency installation.
4
4
 
5
5
  ---
6
6
 
7
7
  ## Purpose
8
8
 
9
- Without `@auto-engineer/dev-server`, you would have to manually manage process spawning, file watching for auto-restart, and process cleanup when developing client/server applications.
10
-
11
- This package provides command handlers that integrate with the CLI pipeline system to start development processes with optional file watching for automatic restarts on code changes.
9
+ Provides a set of message-bus command handlers that manage the lifecycle of development processes. Each handler spawns a child process, optionally waits for HTTP readiness, and emits structured events on success or failure. The server command includes file watching with debounced auto-restart on code changes.
12
10
 
13
11
  ---
14
12
 
@@ -20,9 +18,7 @@ pnpm add @auto-engineer/dev-server
20
18
 
21
19
  ## Quick Start
22
20
 
23
- Register the handlers and start a development server:
24
-
25
- ### 1. Register the handlers
21
+ ### 1. Register all command handlers
26
22
 
27
23
  ```typescript
28
24
  import { COMMANDS } from '@auto-engineer/dev-server';
@@ -32,179 +28,267 @@ const bus = createMessageBus();
32
28
  COMMANDS.forEach(cmd => bus.registerCommand(cmd));
33
29
  ```
34
30
 
35
- ### 2. Send a command
31
+ ### 2. Dispatch a command
36
32
 
37
33
  ```typescript
38
34
  const result = await bus.dispatch({
39
35
  type: 'StartServer',
40
36
  data: {
41
37
  serverDirectory: './server',
38
+ port: 4000,
42
39
  watch: true,
43
40
  },
44
- requestId: 'req-123',
41
+ requestId: 'req-1',
45
42
  });
46
-
47
- console.log(result);
48
- // → { type: 'ServerStarted', data: { serverDirectory: './server', pid: 12345, watching: true } }
43
+ // result.type === 'ServerStarted' | 'ServerStartFailed'
49
44
  ```
50
45
 
51
- The server starts with file watching enabled, automatically restarting on code changes.
52
-
53
46
  ---
54
47
 
55
48
  ## How-to Guides
56
49
 
57
- ### Run via CLI
50
+ ### Start the server with watch mode
51
+
52
+ ```bash
53
+ auto start:server --server-directory=./server --watch --watch-directories=./server/src,./shared
54
+ ```
55
+
56
+ The server process restarts automatically when watched files change. Restarts are debounced (default 2000ms).
57
+
58
+ ### Start client and Storybook
58
59
 
59
60
  ```bash
60
- auto start:server --server-directory=./server
61
61
  auto start:client --client-directory=./client
62
+ auto start:storybook --storybook-directory=./client --port=6006
62
63
  ```
63
64
 
64
- ### Run with Watch Mode
65
+ Both commands wait for HTTP readiness before emitting their success event.
66
+
67
+ ### Restart a running process
65
68
 
66
69
  ```bash
67
- auto start:server --server-directory=./server --watch --watch-directories=./server,./shared
70
+ auto restart:server --server-directory=./server
71
+ auto restart:client --client-directory=./client
72
+ auto restart:storybook --storybook-directory=./client
68
73
  ```
69
74
 
70
- ### Run with Custom Command
75
+ Restart commands kill the existing port holder before spawning a new process.
76
+
77
+ ### Install dependencies
71
78
 
72
79
  ```bash
73
- auto start:server --server-directory=./server --command="pnpm dev"
74
- auto start:client --client-directory=./client --command="npm run dev"
80
+ auto install:client --base-dir=./client
81
+ auto install:server --base-dir=./server
75
82
  ```
76
83
 
77
- ### Handle Errors
84
+ ### Execute an ad-hoc command
78
85
 
79
- ```typescript
80
- if (result.type === 'ServerStartFailed') {
81
- console.error(result.data.error);
82
- }
86
+ ```bash
87
+ auto exec --base-dir=./client --command="pnpm build"
83
88
  ```
84
89
 
85
- ### Enable Debug Logging
90
+ ### Rebuild the component database
91
+
92
+ ```bash
93
+ auto rebuild:component-db --base-dir=./client
94
+ ```
95
+
96
+ ### Reset everything
97
+
98
+ ```bash
99
+ auto reset
100
+ ```
101
+
102
+ Kills processes on ports 4000, 6006, and 8080, clears pipeline messages, and dispatches a `Clean` command.
103
+
104
+ ### Enable debug logging
86
105
 
87
106
  ```bash
88
107
  DEBUG=auto:dev-server:* auto start:server --server-directory=./server
89
108
  ```
90
109
 
110
+ Each command uses its own debug namespace (e.g., `auto:dev-server:start-server`, `auto:dev-server:restart-client`).
111
+
91
112
  ---
92
113
 
93
114
  ## API Reference
94
115
 
95
- ### Exports
116
+ ### COMMANDS
96
117
 
97
118
  ```typescript
98
- import {
99
- COMMANDS,
100
- startServerCommandHandler,
101
- startClientCommandHandler,
102
- } from '@auto-engineer/dev-server';
103
-
104
- import type {
105
- StartServerCommand,
106
- StartClientCommand,
107
- ServerStartedEvent,
108
- ServerStartFailedEvent,
109
- ClientStartedEvent,
110
- ClientStartFailedEvent,
111
- } from '@auto-engineer/dev-server';
119
+ import { COMMANDS } from '@auto-engineer/dev-server';
112
120
  ```
113
121
 
122
+ Array of all 13 command handlers, ready to register on a message bus.
123
+
114
124
  ### Commands
115
125
 
116
- | Command | CLI Alias | Description |
117
- |---------|-----------|-------------|
118
- | `StartServer` | `start:server` | Start development server with optional file watching |
119
- | `StartClient` | `start:client` | Start development client process |
126
+ | Command | Alias | Description | Default Port |
127
+ |---------|-------|-------------|-------------|
128
+ | `StartServer` | `start:server` | Start server with optional file watching | 4000 |
129
+ | `StartClient` | `start:client` | Start client process | 8080 |
130
+ | `StartStorybook` | `start:storybook` | Start Storybook dev server | 6006 |
131
+ | `RestartServer` | `restart:server` | Kill port holder and restart server | 4000 |
132
+ | `RestartClient` | `restart:client` | Kill port holder and restart client | 8080 |
133
+ | `RestartStorybook` | `restart:storybook` | Kill port holder and restart Storybook | 6006 |
134
+ | `ExecuteCommand` | `exec` | Run an ad-hoc shell command | -- |
135
+ | `RebuildComponentDB` | `rebuild:component-db` | Rebuild component DB from Storybook manifests | -- |
136
+ | `InstallClientDependencies` | `install:client` | Install client dependencies | -- |
137
+ | `InstallServerDependencies` | `install:server` | Install server dependencies | -- |
138
+ | `ResetPipeline` | `reset:pipeline` | Clear all pipeline messages and state | -- |
139
+ | `Clean` | `clean` | Remove generated directories, restore `.context` | -- |
140
+ | `Reset` | `reset` | Kill servers, clear pipeline, dispatch Clean | -- |
120
141
 
121
142
  ### StartServerCommand
122
143
 
123
144
  ```typescript
145
+ import type { StartServerCommand } from '@auto-engineer/dev-server';
146
+
124
147
  type StartServerCommand = Command<
125
148
  'StartServer',
126
149
  {
127
150
  serverDirectory: string;
128
151
  command?: string; // default: 'pnpm start'
152
+ port?: number; // default: 4000
129
153
  watch?: boolean; // default: true
130
- watchDirectories?: string[];
154
+ watchDirectories?: string[]; // default: [serverDirectory/src]
131
155
  debounceMs?: number; // default: 2000
132
156
  }
133
157
  >;
134
158
  ```
135
159
 
160
+ Events: `ServerStarted`, `ServerStartFailed`, `ServerRestarting`, `ServerRestarted`
161
+
136
162
  ### StartClientCommand
137
163
 
138
164
  ```typescript
165
+ import type { StartClientCommand } from '@auto-engineer/dev-server';
166
+
139
167
  type StartClientCommand = Command<
140
168
  'StartClient',
141
169
  {
142
170
  clientDirectory: string;
143
171
  command?: string; // default: 'pnpm start'
172
+ port?: number; // default: 8080
144
173
  }
145
174
  >;
146
175
  ```
147
176
 
148
- ### ServerStartedEvent
177
+ Events: `ClientStarted`, `ClientStartFailed`
178
+
179
+ ### StartStorybookCommand
149
180
 
150
181
  ```typescript
151
- type ServerStartedEvent = Event<
152
- 'ServerStarted',
182
+ import type { StartStorybookCommand } from '@auto-engineer/dev-server';
183
+
184
+ type StartStorybookCommand = Command<
185
+ 'StartStorybook',
153
186
  {
154
- serverDirectory: string;
155
- pid: number;
156
- port?: number;
157
- watching: boolean;
187
+ storybookDirectory: string;
188
+ command?: string; // default: 'pnpm storybook'
189
+ port?: number; // default: 6006
190
+ fast?: boolean; // default: false (sets STORYBOOK_FAST=1)
158
191
  }
159
192
  >;
160
193
  ```
161
194
 
162
- ### ClientStartedEvent
195
+ Events: `StorybookStarted`, `StorybookStartFailed`
196
+
197
+ ### ExecuteCommandCommand
163
198
 
164
199
  ```typescript
165
- type ClientStartedEvent = Event<
166
- 'ClientStarted',
200
+ import type { ExecuteCommandCommand } from '@auto-engineer/dev-server';
201
+
202
+ type ExecuteCommandCommand = Command<
203
+ 'ExecuteCommand',
167
204
  {
168
- clientDirectory: string;
169
- pid: number;
170
- port?: number;
205
+ baseDir: string;
206
+ command: string;
171
207
  }
172
208
  >;
173
209
  ```
174
210
 
211
+ Events: `CommandExecuted` (includes stdout/stderr/exitCode), `CommandFailed`
212
+
213
+ ### Named handler exports
214
+
215
+ Each command handler is also exported individually:
216
+
217
+ ```typescript
218
+ import {
219
+ startServerCommandHandler,
220
+ startClientCommandHandler,
221
+ startStorybookCommandHandler,
222
+ restartServerCommandHandler,
223
+ restartClientCommandHandler,
224
+ restartStorybookCommandHandler,
225
+ executeCommandHandler,
226
+ rebuildComponentDBCommandHandler,
227
+ installClientDependenciesCommandHandler,
228
+ installServerDependenciesCommandHandler,
229
+ resetPipelineCommandHandler,
230
+ cleanCommandHandler,
231
+ resetCommandHandler,
232
+ } from '@auto-engineer/dev-server';
233
+ ```
234
+
175
235
  ---
176
236
 
177
237
  ## Architecture
178
238
 
179
239
  ```
180
240
  src/
181
- ├── index.ts
241
+ ├── index.ts # COMMANDS array + re-exports
242
+ ├── ensure-installed.ts # Auto-install node_modules if missing
243
+ ├── port-cleanup.ts # Kill processes holding a port (SIGTERM → SIGKILL)
244
+ ├── wait-for-http.ts # Poll localhost until HTTP responds (<500)
182
245
  └── commands/
183
- ├── start-server.ts
184
- └── start-client.ts
246
+ ├── start-server.ts # Spawn server + chokidar file watcher
247
+ ├── start-client.ts # Spawn client, wait for HTTP ready
248
+ ├── start-storybook.ts # Spawn Storybook, write settings, wait for HTTP
249
+ ├── restart-server.ts # Kill port → delegate to StartServer
250
+ ├── restart-client.ts # Kill port → delegate to StartClient
251
+ ├── restart-storybook.ts # Kill port → delegate to StartStorybook
252
+ ├── execute-command.ts # Run arbitrary shell command
253
+ ├── build-component-db.ts # Rebuild component DB, parse artifact URL
254
+ ├── install-client-dependencies.ts
255
+ ├── install-server-dependencies.ts
256
+ ├── reset-pipeline.ts # Clear pipeline messages
257
+ ├── clean.ts # Remove server/client dirs, restore .context
258
+ ├── reset.ts # Kill ports 4000/6006/8080, clear, clean
259
+ └── storybook-settings.ts # Default Storybook settings JSON
185
260
  ```
186
261
 
187
- The following diagram shows the server watch flow:
188
-
189
262
  ```mermaid
190
263
  flowchart TB
191
- A[StartServer] --> B[Spawn Process]
192
- B --> C{Watch Mode?}
193
- C -->|Yes| D[Start Watcher]
194
- C -->|No| E[ServerStartedEvent]
195
- D --> E
196
- D --> F[File Change]
197
- F --> G[Kill Process]
198
- G --> B
264
+ A[StartServer command] --> B[Kill port holder]
265
+ B --> C[Spawn process]
266
+ C --> D[Wait for HTTP ready]
267
+ D --> E{Watch mode?}
268
+ E -->|Yes| F[Start chokidar watcher]
269
+ E -->|No| G[ServerStarted event]
270
+ F --> G
271
+ F --> H[File change detected]
272
+ H --> I[Debounce]
273
+ I --> J[Kill process]
274
+ J --> C
199
275
  ```
200
276
 
201
- *Flow: Command spawns process, optionally starts file watcher which restarts on changes.*
277
+ ```mermaid
278
+ flowchart TB
279
+ R[RestartServer command] --> K[Kill port holder]
280
+ K --> L[Delegate to StartServer handler]
281
+ L --> M{Result?}
282
+ M -->|ServerStarted| N[ServerRestarted event]
283
+ M -->|ServerStartFailed| O[ServerRestartFailed event]
284
+ ```
202
285
 
203
286
  ### Dependencies
204
287
 
205
288
  | Package | Usage |
206
289
  |---------|-------|
207
- | `@auto-engineer/message-bus` | Command/event infrastructure |
208
- | `chokidar` | File system watching |
209
- | `execa` | Process execution |
210
- | `debug` | Debug logging |
290
+ | `@auto-engineer/cli` | TUI service registry integration |
291
+ | `@auto-engineer/message-bus` | `defineCommandHandler`, `Command`/`Event` types |
292
+ | `chokidar` | File system watching for server auto-restart |
293
+ | `execa` | Process spawning |
294
+ | `debug` | Namespaced debug logging (`auto:dev-server:*`) |
package/package.json CHANGED
@@ -18,16 +18,16 @@
18
18
  "chokidar": "^3.6.0",
19
19
  "debug": "^4.4.1",
20
20
  "execa": "^9.5.2",
21
- "@auto-engineer/cli": "1.147.0",
22
- "@auto-engineer/message-bus": "1.147.0"
21
+ "@auto-engineer/cli": "1.149.0",
22
+ "@auto-engineer/message-bus": "1.149.0"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"
26
26
  },
27
27
  "devDependencies": {
28
- "@auto-engineer/cli": "1.147.0"
28
+ "@auto-engineer/cli": "1.149.0"
29
29
  },
30
- "version": "1.147.0",
30
+ "version": "1.149.0",
31
31
  "scripts": {
32
32
  "build": "tsc && tsx ../../scripts/fix-esm-imports.ts",
33
33
  "test": "vitest run --reporter=dot",