@codemation/cli 0.0.5 → 0.0.11

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 (40) hide show
  1. package/README.md +20 -26
  2. package/dist/{CliBin-C3ar49fj.js → CliBin-BAnFX1wL.js} +1105 -366
  3. package/dist/bin.js +1 -1
  4. package/dist/index.d.ts +655 -207
  5. package/dist/index.js +1 -1
  6. package/package.json +14 -6
  7. package/src/CliProgramFactory.ts +23 -8
  8. package/src/Program.ts +7 -3
  9. package/src/bootstrap/CodemationCliApplicationSession.ts +17 -19
  10. package/src/commands/DevCommand.ts +203 -171
  11. package/src/commands/ServeWebCommand.ts +26 -1
  12. package/src/commands/ServeWorkerCommand.ts +46 -30
  13. package/src/commands/devCommandLifecycle.types.ts +7 -11
  14. package/src/database/ConsumerDatabaseConnectionResolver.ts +55 -9
  15. package/src/database/DatabaseMigrationsApplyService.ts +2 -2
  16. package/src/dev/Builder.ts +1 -14
  17. package/src/dev/CliDevProxyServer.ts +457 -0
  18. package/src/dev/CliDevProxyServerFactory.ts +10 -0
  19. package/src/dev/DevApiRuntimeFactory.ts +44 -0
  20. package/src/dev/DevApiRuntimeHost.ts +130 -0
  21. package/src/dev/DevApiRuntimeServer.ts +107 -0
  22. package/src/dev/DevApiRuntimeTypes.ts +24 -0
  23. package/src/dev/DevAuthSettingsLoader.ts +9 -3
  24. package/src/dev/DevBootstrapSummaryFetcher.ts +1 -1
  25. package/src/dev/DevHttpProbe.ts +2 -2
  26. package/src/dev/DevNextHostEnvironmentBuilder.ts +35 -5
  27. package/src/dev/DevRebuildQueue.ts +54 -0
  28. package/src/dev/DevRebuildQueueFactory.ts +7 -0
  29. package/src/dev/DevSessionPortsResolver.ts +2 -2
  30. package/src/dev/DevSessionServices.ts +0 -4
  31. package/src/dev/DevSourceChangeClassifier.ts +33 -13
  32. package/src/dev/ListenPortConflictDescriber.ts +83 -0
  33. package/src/dev/WatchRootsResolver.ts +6 -4
  34. package/src/runtime/NextHostConsumerServerCommandFactory.ts +11 -2
  35. package/src/user/CliDatabaseUrlDescriptor.ts +2 -2
  36. package/src/user/UserAdminCliBootstrap.ts +9 -21
  37. package/codemation-cli-0.0.3.tgz +0 -0
  38. package/src/dev/DevSourceRestartCoordinator.ts +0 -48
  39. package/src/dev/DevelopmentGatewayNotifier.ts +0 -35
  40. package/src/dev/RuntimeToolEntrypointResolver.ts +0 -47
package/README.md CHANGED
@@ -8,7 +8,7 @@ It is intentionally **thin**: no DI container. [`CliProgramFactory`](./src/CliPr
8
8
 
9
9
  ## How it fits in the monorepo
10
10
 
11
- The CLI **orchestrates** other packages. It does not embed the full Next UI or engineit **spawns** or **calls into** them as needed.
11
+ The CLI **orchestrates** other packages. It does not embed the full Next UI or engine, but it now owns the dev runtime control plane directly instead of delegating dev hot-swap to separate workspace packages.
12
12
 
13
13
  ```text
14
14
  Consumer project (your repo)
@@ -43,35 +43,28 @@ The CLI **orchestrates** other packages. It does not embed the full Next UI or e
43
43
  │ uses / spawns
44
44
 
45
45
  ┌────────────────────┬─────────────────────┬────────────────────────────┐
46
- │ @codemation/host │ @codemation/next-host│ @codemation/dev-gateway
47
- │ (plugin discovery, │ (production: │ (dev: HTTP gateway binary)
48
- │ logging, workflow │ `pnpm exec next │
46
+ │ @codemation/host │ @codemation/next-host│ CLI-owned dev runtime
47
+ │ (plugin discovery, │ (production: │ (stable proxy +
48
+ │ logging, workflow │ `pnpm exec next │ disposable API runtime)
49
49
  │ path helpers) │ start` cwd) │ │
50
50
  └─────────┬──────────┴──────────┬──────────┴─────────────┬────────────────┘
51
51
  │ │ │
52
52
  │ │ │
53
53
  ▼ │ ▼
54
54
  ┌───────────────────┐ │ ┌─────────────────────┐
55
- │ Engine & types │ │ │ @codemation/
56
- │ via host (not a │ │ │ runtime-dev
57
- │ direct cli dep) │ │ │ (dev child process)
55
+ │ Engine & types │ │ │ Worker runtime
56
+ │ via host (not a │ │ │ via CLI + host
57
+ │ direct cli dep) │ │ │ (`serve worker`)
58
58
  └───────────────────┘ │ └─────────────────────┘
59
-
60
-
61
- ┌───────────────────┐
62
- │ @codemation/ │
63
- │ worker-cli │
64
- │ (`serve worker`) │
65
- └───────────────────┘
66
59
  ```
67
60
 
68
61
  **Reading the diagram**
69
62
 
70
63
  - **Vertical flow**: the binary loads `CliProgramFactory`, builds `CliProgram`, then Commander dispatches to a **command class** (`commands/*`).
71
- - **Horizontal row**: shared **libraries** the CLI imports for discovery, logging, and path logic; **next-host** is where `serve web` runs the production Next server; **dev-gateway** + **runtime-dev** are the dev-time split (gateway + disposable runtime child).
64
+ - **Horizontal row**: shared **libraries** the CLI imports for discovery, logging, and path logic; **next-host** is where `serve web` runs the production Next server; the CLI now also owns the stable dev proxy and disposable in-process API runtime used by `codemation dev`. `serve worker` stays inside the CLI/host container flow instead of delegating to a separate worker package.
72
65
  - **Consumer tree**: `ConsumerOutputBuilder` transpiles sources into `.codemation/output/build` and writes the entry `index.js`; `ConsumerBuildArtifactsPublisher` writes plugins and updates the manifest consumed by the host at runtime.
73
66
 
74
- For **framework author vs consumer** dev modes (`CODEMATION_DEV_MODE`), see [`docs/development-modes.md`](../../docs/development-modes.md) at the repo root.
67
+ For **default consumer dev** vs **framework UI watch mode** (`codemation dev` vs `codemation dev --watch-framework`), see [`docs/development-modes.md`](../../docs/development-modes.md) at the repo root.
75
68
 
76
69
  ---
77
70
 
@@ -87,16 +80,17 @@ For **framework author vs consumer** dev modes (`CODEMATION_DEV_MODE`), see [`do
87
80
 
88
81
  ## Commands (overview)
89
82
 
90
- | Command | Purpose |
91
- | -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
92
- | `codemation dev` (default) | Dev session: ports, lock, optional UI proxy, spawn **dev-gateway** + **runtime-dev**, watch consumer sources and restart on change. |
93
- | `codemation build` | Emit consumer output under `.codemation/output/build`, discover plugins, write manifest. |
94
- | `codemation serve web` | Run consumer build if needed, then **`next start`** from `@codemation/next-host` with env pointing at the manifest. |
95
- | `codemation serve worker` | Spawn **`@codemation/worker-cli`** in the consumer root. |
96
- | `codemation user create` | Create/update a DB user when auth is local (uses consumer config / `DATABASE_URL`). Dispatches `UpsertLocalBootstrapUserCommand` via the host `CommandBus` (password minimum 8 characters, same as invite acceptance). |
97
- | `codemation user list` | List users via `ListUserAccountsQuery` and the host `QueryBus` (same auth/DB requirements as `user create`). |
98
-
99
- Programmatic bootstrap: [`CodemationCliApplicationSession`](./src/bootstrap/CodemationCliApplicationSession.ts) opens `CodemationApplication` with `bootCli` (no HTTP/WebSocket); use `getCommandBus()` for other admin commands later.
83
+ | Command | Purpose |
84
+ | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
85
+ | `codemation dev` (default) | Dev session: ports, lock, packaged UI proxy, stable CLI-owned dev endpoint, watch consumer sources, and hot-swap a disposable in-process API runtime on change. |
86
+ | `codemation dev --watch-framework` | Framework-author dev session: same runtime/proxy flow, but runs **`next dev`** for `@codemation/next-host` UI HMR. |
87
+ | `codemation build` | Emit consumer output under `.codemation/output/build`, discover plugins, write manifest. |
88
+ | `codemation serve web` | Run consumer build if needed, then **`next start`** from `@codemation/next-host` with env pointing at the manifest. |
89
+ | `codemation serve worker` | Load `AppConfig`, build the app container in-process, and start the configured queue-backed worker runtime. |
90
+ | `codemation user create` | Create/update a DB user when auth is local (uses consumer config / `DATABASE_URL`). Dispatches `UpsertLocalBootstrapUserCommand` via the host `CommandBus` (password minimum 8 characters, same as invite acceptance). |
91
+ | `codemation user list` | List users via `ListUserAccountsQuery` and the host `QueryBus` (same auth/DB requirements as `user create`). |
92
+
93
+ Programmatic bootstrap: [`CodemationCliApplicationSession`](./src/bootstrap/CodemationCliApplicationSession.ts) builds an app container for command/query access (no HTTP/WebSocket servers); migrations and startup side effects remain explicit after container creation.
100
94
 
101
95
  Use `codemation --help` and `codemation <command> --help` for flags (`--consumer-root`, build targets, etc.).
102
96