@ultimat3/cli 30.9.0 → 31.1.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 (215) hide show
  1. package/CLAUDE.md +80 -64
  2. package/README.md +4 -1
  3. package/package.json +30 -29
  4. package/src/admin-registration.ts +1 -1
  5. package/src/affected-base.ts +51 -0
  6. package/src/affected.ts +34 -11
  7. package/src/app-boundaries.ts +88 -9
  8. package/src/app-load-async.ts +133 -0
  9. package/src/app-load-batch.ts +203 -0
  10. package/src/app-load-prebuilt.ts +147 -0
  11. package/src/app-load-register.ts +175 -0
  12. package/src/app-load.ts +143 -175
  13. package/src/app-loader-imports.ts +31 -0
  14. package/src/app-root.ts +13 -0
  15. package/src/app-runtime.ts +5 -1
  16. package/src/boundary-findings.ts +12 -0
  17. package/src/browser-launcher-port.ts +3 -7
  18. package/src/browser-launcher.ts +1 -1
  19. package/src/budgets-scan.ts +8 -0
  20. package/src/budgets.ts +10 -1
  21. package/src/build-registry-background.ts +59 -0
  22. package/src/build-registry.ts +207 -0
  23. package/src/cdp-shot-clock.ts +3 -11
  24. package/src/cdp-shot-driver.ts +3 -2
  25. package/src/cdp-shot-element.ts +3 -2
  26. package/src/cdp-shot-page.ts +2 -2
  27. package/src/cdp-shot-watch.ts +4 -3
  28. package/src/ci-log.ts +76 -13
  29. package/src/cmd-affected-spec.ts +7 -3
  30. package/src/cmd-affected.ts +91 -77
  31. package/src/cmd-auth.ts +3 -3
  32. package/src/cmd-ci.ts +6 -3
  33. package/src/cmd-db-recount.ts +15 -0
  34. package/src/cmd-drill.ts +10 -6
  35. package/src/cmd-exercise.ts +2 -1
  36. package/src/cmd-generate-spec.ts +6 -0
  37. package/src/cmd-generate.ts +22 -4
  38. package/src/cmd-mail.ts +1 -1
  39. package/src/cmd-pr-spec.ts +1 -1
  40. package/src/cmd-pr.ts +72 -1
  41. package/src/cmd-routes.ts +2 -2
  42. package/src/cmd-secrets-spec.ts +4 -1
  43. package/src/cmd-shot.ts +14 -262
  44. package/src/cmd-test-spec.ts +2 -2
  45. package/src/cmd-verify-spec.ts +21 -1
  46. package/src/cmd-verify.ts +16 -4
  47. package/src/coverage-source.ts +4 -1
  48. package/src/db-diagnostics.ts +8 -1
  49. package/src/dev-boot.ts +29 -15
  50. package/src/dev-dashboard-invalidations.ts +43 -0
  51. package/src/dev-dashboard.ts +13 -16
  52. package/src/dev-n-plus-one.ts +7 -3
  53. package/src/dev-rebuild.ts +2 -1
  54. package/src/dev-route-table.ts +1 -1
  55. package/src/dev-traces.ts +16 -15
  56. package/src/document-options.ts +12 -1
  57. package/src/drift-store.ts +55 -0
  58. package/src/error-catalog.ts +8 -3
  59. package/src/error-codes-boundary.ts +32 -0
  60. package/src/error-codes-package.ts +38 -0
  61. package/src/error-codes.ts +28 -40
  62. package/src/errors.ts +17 -7
  63. package/src/exercise-database.ts +13 -1
  64. package/src/exercise-findings.ts +36 -18
  65. package/src/exercise-services.ts +84 -0
  66. package/src/exercise-subject.ts +38 -13
  67. package/src/failure-capture-boot.ts +9 -5
  68. package/src/framework-schema.ts +5 -5
  69. package/src/generate-exercise.ts +1 -1
  70. package/src/generate-files.ts +27 -7
  71. package/src/generate-kinds.ts +5 -0
  72. package/src/generate-refresh.ts +53 -0
  73. package/src/generate-workspace.ts +169 -0
  74. package/src/generate-write.ts +8 -2
  75. package/src/hold.ts +19 -8
  76. package/src/image-prepare.ts +6 -2
  77. package/src/index.ts +5 -20
  78. package/src/island-bundle.ts +7 -3
  79. package/src/island-capture.ts +2 -2
  80. package/src/island-harness.ts +1 -1
  81. package/src/job-registration.ts +43 -6
  82. package/src/jobs-driver.ts +4 -5
  83. package/src/mcp-errors.ts +20 -4
  84. package/src/mcp-host.ts +5 -1
  85. package/src/mcp-ui-interact.ts +3 -0
  86. package/src/messages-gate.ts +10 -0
  87. package/src/new-shapes-generate.ts +1 -1
  88. package/src/otlp-export.ts +94 -29
  89. package/src/output.ts +24 -10
  90. package/src/page-sync.ts +3 -1
  91. package/src/pr-activity.ts +150 -0
  92. package/src/pr-bots.ts +109 -0
  93. package/src/pr-threads.ts +7 -2
  94. package/src/role-load.ts +17 -11
  95. package/src/role-start.ts +5 -4
  96. package/src/role-sync.ts +7 -8
  97. package/src/route-islands-preload.ts +46 -0
  98. package/src/route-islands.ts +6 -2
  99. package/src/runtime-admin.ts +5 -1
  100. package/src/runtime-bindings.ts +25 -19
  101. package/src/runtime-boot-ports.ts +66 -0
  102. package/src/runtime-bus.ts +29 -5
  103. package/src/runtime-cache-bus.ts +53 -0
  104. package/src/runtime-cache.ts +43 -13
  105. package/src/runtime-isr-outcome.ts +5 -4
  106. package/src/runtime-jobs.ts +2 -2
  107. package/src/runtime-keys.ts +37 -0
  108. package/src/runtime-overrides.ts +148 -42
  109. package/src/runtime-port-bindings-queue.ts +36 -0
  110. package/src/runtime-port-bindings.ts +117 -0
  111. package/src/runtime-ports.ts +164 -0
  112. package/src/runtime-purge.ts +41 -28
  113. package/src/runtime-push.ts +7 -3
  114. package/src/runtime-queue.ts +70 -55
  115. package/src/runtime-realtime.ts +5 -5
  116. package/src/runtime-render-document.ts +4 -1
  117. package/src/runtime-services.ts +110 -158
  118. package/src/runtime-storage-boot.ts +111 -0
  119. package/src/runtime-storage-upload.ts +9 -7
  120. package/src/runtime-storage.ts +7 -1
  121. package/src/serve-boot.ts +8 -4
  122. package/src/serve-entry.ts +3 -0
  123. package/src/serve-env.ts +47 -14
  124. package/src/serve-prebuilt-paths.ts +3 -0
  125. package/src/serve-prebuilt.ts +15 -4
  126. package/src/serve.ts +2 -2
  127. package/src/shot-gpu.ts +61 -0
  128. package/src/shot-route.ts +95 -0
  129. package/src/shot-run.ts +189 -0
  130. package/src/shot-verdict.ts +5 -0
  131. package/src/static-cards.ts +3 -2
  132. package/src/static-report.ts +2 -2
  133. package/src/style-bundle.ts +1 -1
  134. package/src/sync-authenticator.ts +17 -18
  135. package/src/templates/action-tests.ts +4 -4
  136. package/src/templates/backfill.ts +5 -8
  137. package/src/templates/entity.ts +3 -0
  138. package/src/templates/github/ci.yml.ts +3 -1
  139. package/src/templates/github/dependabot.yml.ts +73 -0
  140. package/src/templates/job.ts +13 -22
  141. package/src/templates/naming.ts +20 -1
  142. package/src/templates/pinned/docker-compose.yml +1 -1
  143. package/src/templates/query.ts +7 -8
  144. package/src/templates/route.ts +5 -3
  145. package/src/templates/scaffold-api.ts +1 -1
  146. package/src/templates/scaffold-auth.ts +5 -3
  147. package/src/templates/scaffold-claude-commands.ts +6 -3
  148. package/src/templates/scaffold-claude.ts +4 -4
  149. package/src/templates/scaffold-container-compose.ts +2 -4
  150. package/src/templates/scaffold-domain-package.ts +1 -1
  151. package/src/templates/scaffold-entries.ts +6 -1
  152. package/src/templates/scaffold-helm-fences.ts +3 -2
  153. package/src/templates/scaffold-helm.ts +35 -6
  154. package/src/templates/scaffold-repo.ts +47 -135
  155. package/src/templates/scaffold-runtime-ports.ts +62 -0
  156. package/src/templates/scaffold-verify-floor.ts +97 -0
  157. package/src/templates/shapes/overlay.ts +1 -1
  158. package/src/templates/sign-in-oidc.ts +5 -3
  159. package/src/templates/sign-in-shared.ts +28 -10
  160. package/src/templates/workspace.ts +75 -0
  161. package/src/test-ignores.ts +5 -2
  162. package/src/test-select.ts +4 -1
  163. package/src/tsconfig-aliases.ts +85 -0
  164. package/src/upgrade-gate.ts +30 -5
  165. package/src/upgrade-report.ts +7 -1
  166. package/src/verify-changed-facts.ts +53 -0
  167. package/src/verify-changed-scope.ts +162 -0
  168. package/src/verify-changed.ts +174 -0
  169. package/src/verify-checks.ts +33 -19
  170. package/src/verify-drift-owner.ts +30 -0
  171. package/src/verify-e2e.ts +2 -1
  172. package/src/verify-factories.ts +86 -0
  173. package/src/verify-run.ts +13 -11
  174. package/src/verify-step.ts +13 -0
  175. package/src/verify-tests.ts +58 -6
  176. package/src/workspace-external-deps.ts +164 -0
  177. package/src/write-line.ts +21 -6
  178. package/wiki/Actions.md +2 -2
  179. package/wiki/Adapters.md +400 -0
  180. package/wiki/Admin-Dashboard.md +1 -1
  181. package/wiki/Agents.md +9 -9
  182. package/wiki/Auth.md +78 -2
  183. package/wiki/Building-Your-Own-Base.md +1 -1
  184. package/wiki/CLI-Reference.md +45 -14
  185. package/wiki/Caching-And-Invalidation.md +17 -5
  186. package/wiki/Compared.md +8 -2
  187. package/wiki/Configuration.md +14 -14
  188. package/wiki/Deployment.md +28 -1
  189. package/wiki/Entities-And-Migrations.md +47 -1
  190. package/wiki/FAQ.md +8 -2
  191. package/wiki/Feature-Flags.md +1 -1
  192. package/wiki/Home.md +3 -2
  193. package/wiki/Jobs-And-Workflows.md +107 -6
  194. package/wiki/Known-Gaps.md +4 -3
  195. package/wiki/MCP-And-AI.md +18 -4
  196. package/wiki/Mail.md +14 -5
  197. package/wiki/Migrations-And-Backfills.md +29 -4
  198. package/wiki/Money.md +2 -0
  199. package/wiki/N-Plus-One-Detection.md +24 -22
  200. package/wiki/Notify.md +28 -4
  201. package/wiki/Observability.md +121 -15
  202. package/wiki/Queries-And-Live-Queries.md +2 -2
  203. package/wiki/Realtime.md +9 -4
  204. package/wiki/Routes-And-Render-Modes.md +5 -0
  205. package/wiki/Scraping.md +57 -11
  206. package/wiki/Shapes.md +2 -2
  207. package/wiki/Stability.md +7 -5
  208. package/wiki/Storage-And-Uploads.md +56 -4
  209. package/wiki/Testing.md +65 -52
  210. package/wiki/Troubleshooting.md +1 -1
  211. package/wiki/Tutorial-01-First-App.md +1 -1
  212. package/wiki/Tutorial-04-Jobs-And-Realtime.md +1 -1
  213. package/wiki/Tutorial-05-Deploy-Free.md +1 -1
  214. package/wiki/Tutorial-06-Growing-Up.md +8 -8
  215. package/wiki/Upgrading.md +136 -5
@@ -14,6 +14,7 @@ import { msg } from './messages';
14
14
  import type { CommandResult, JsonValue } from './output';
15
15
  import { flagBool } from './parse';
16
16
  import { renderTable } from './table';
17
+ import { writeLine } from './write-line';
17
18
 
18
19
  const HEADER = ['workspace', 'dir'] as const;
19
20
 
@@ -36,81 +37,94 @@ export const AFFECTED_MESSAGE_KEYS = [
36
37
  'cli.affected.testsAll',
37
38
  ] as const;
38
39
 
39
- export const affectedCommand: CliCommand = {
40
- spec: affectedSpec,
41
- async run(ctx: CommandContext): Promise<CommandResult> {
42
- // The one resolver `x test --affected` narrows with, so this command reports exactly what that
43
- // one runs. It reads `--base` before git is spawned (a malformed ref must not cost a
44
- // subprocess) and takes the diff at the CHECKOUT root, which is what git prints paths against.
45
- const { selection, root, plan } = await affectedScope({
46
- runner: ctx.runner,
47
- cwd: ctx.cwd,
48
- args: ctx.args,
49
- command: 'affected',
50
- });
51
- const params = { base: selection.base, changed: plan.changed.length };
52
- const tests = await appTestScope(ctx.cwd, root, plan.changed);
53
- const table = renderTable(
54
- HEADER,
55
- plan.workspaces.map((workspace) => [workspace.name, workspace.dir]),
56
- ).map((line) => ` ${line}`);
57
- const data: JsonValue = {
58
- base: selection.base,
59
- dirty: selection.dirty,
60
- root,
61
- changed: [...plan.changed],
62
- ignored: [...plan.ignored],
63
- rootWide: [...plan.rootWide],
64
- workspaces: plan.workspaces.map((workspace) => ({
65
- name: workspace.name,
66
- dir: workspace.dir,
67
- })),
68
- paths: plan.workspaces.map((workspace) => workspace.dir),
40
+ /**
41
+ * `--paths` is for `bun test $(x affected --paths)`, so its stdout is the directories and nothing
42
+ * else: each one written here, on fd 1, and the rest of the render — the notes and the `✓` summary,
43
+ * which a shell would split into bogus arguments — sent to fd 2 by `stream: 'stderr'`. The one
44
+ * write a command makes itself: `CommandResult` has no "bare stdout" channel, and the one sink
45
+ * `dispatch` picks per result cannot split a result across both fds. `writeOut` is injectable so a
46
+ * test reads fd 1 exactly as a shell would.
47
+ */
48
+ export function createAffectedCommand(writeOut: (line: string) => void = writeLine): CliCommand {
49
+ return { spec: affectedSpec, run: (ctx) => runAffected(ctx, writeOut) };
50
+ }
51
+
52
+ async function runAffected(
53
+ ctx: CommandContext,
54
+ writeOut: (line: string) => void,
55
+ ): Promise<CommandResult> {
56
+ // The one resolver `x test --affected` narrows with, so this command reports exactly what that
57
+ // one runs. It reads `--base` before git is spawned (a malformed ref must not cost a
58
+ // subprocess) and takes the diff at the CHECKOUT root, which is what git prints paths against.
59
+ const { selection, root, plan } = await affectedScope({
60
+ runner: ctx.runner,
61
+ cwd: ctx.cwd,
62
+ args: ctx.args,
63
+ command: 'affected',
64
+ });
65
+ const params = { base: selection.base, changed: plan.changed.length };
66
+ const tests = await appTestScope(ctx.cwd, root, plan.changed);
67
+ const table = renderTable(
68
+ HEADER,
69
+ plan.workspaces.map((workspace) => [workspace.name, workspace.dir]),
70
+ ).map((line) => ` ${line}`);
71
+ const data: JsonValue = {
72
+ base: selection.base,
73
+ dirty: selection.dirty,
74
+ root,
75
+ changed: [...plan.changed],
76
+ ignored: [...plan.ignored],
77
+ rootWide: [...plan.rootWide],
78
+ workspaces: plan.workspaces.map((workspace) => ({
79
+ name: workspace.name,
80
+ dir: workspace.dir,
81
+ })),
82
+ paths: plan.workspaces.map((workspace) => workspace.dir),
83
+ ...(tests === undefined
84
+ ? {}
85
+ : {
86
+ tests: {
87
+ app: tests.app,
88
+ all: tests.all,
89
+ forcing: [...tests.forcing],
90
+ files: [...tests.tests],
91
+ },
92
+ }),
93
+ };
94
+ const bare = flagBool(ctx.args, 'paths') && !ctx.args.json;
95
+ if (bare) for (const workspace of plan.workspaces) writeOut(workspace.dir);
96
+ return {
97
+ ...(bare ? { stream: 'stderr' as const } : {}),
98
+ // An empty answer is a fact, not a failure: a `.md`-only diff genuinely re-checks nothing,
99
+ // and reporting it red would fail a build for editing a doc. The count is in the summary and
100
+ // `data.changed`/`data.ignored` say what was looked at, so "green because nothing is
101
+ // affected" is never mistaken for "green because everything passed".
102
+ ok: true,
103
+ command: 'affected',
104
+ summary:
105
+ plan.workspaces.length === 0
106
+ ? msg('cli.affected.none', params)
107
+ : msg('cli.affected.count', { ...params, count: plan.workspaces.length }),
108
+ lines: [
109
+ ...(selection.dirty ? [msg('cli.affected.dirty')] : []),
69
110
  ...(tests === undefined
70
- ? {}
71
- : {
72
- tests: {
73
- app: tests.app,
74
- all: tests.all,
75
- forcing: [...tests.forcing],
76
- files: [...tests.tests],
77
- },
78
- }),
79
- };
80
- return {
81
- // An empty answer is a fact, not a failure: a `.md`-only diff genuinely re-checks nothing,
82
- // and reporting it red would fail a build for editing a doc. The count is in the summary and
83
- // `data.changed`/`data.ignored` say what was looked at, so "green because nothing is
84
- // affected" is never mistaken for "green because everything passed".
85
- ok: true,
86
- command: 'affected',
87
- summary:
88
- plan.workspaces.length === 0
89
- ? msg('cli.affected.none', params)
90
- : msg('cli.affected.count', { ...params, count: plan.workspaces.length }),
91
- lines: [
92
- ...(selection.dirty ? [msg('cli.affected.dirty')] : []),
93
- ...(tests === undefined
94
- ? []
95
- : [
96
- tests.all
97
- ? msg('cli.affected.testsAll', {
98
- files: `${tests.forcing.slice(0, 3).join(', ')}${tests.forcing.length > 3 ? ` (+${tests.forcing.length - 3})` : ''}`,
99
- })
100
- : msg('cli.affected.tests', { count: tests.tests.length }),
101
- ]),
102
- ...(plan.rootWide.length === 0
103
- ? []
104
- : [msg('cli.affected.rootWide', { files: plan.rootWide.join(', ') })]),
105
- ...(plan.workspaces.length === 0
106
- ? []
107
- : // `--paths` changes only what the human sees; `--json` carries both projections on
108
- // every run, so the two renderers can never state different sets.
109
- flagBool(ctx.args, 'paths')
110
- ? plan.workspaces.map((workspace) => workspace.dir)
111
- : table),
112
- ],
113
- data,
114
- };
115
- },
116
- };
111
+ ? []
112
+ : [
113
+ tests.all
114
+ ? msg('cli.affected.testsAll', {
115
+ files: `${tests.forcing.slice(0, 3).join(', ')}${tests.forcing.length > 3 ? ` (+${tests.forcing.length - 3})` : ''}`,
116
+ })
117
+ : msg('cli.affected.tests', { count: tests.tests.length }),
118
+ ]),
119
+ ...(plan.rootWide.length === 0
120
+ ? []
121
+ : [msg('cli.affected.rootWide', { files: plan.rootWide.join(', ') })]),
122
+ // `--paths` changes only what the human sees; `--json` carries both projections on every
123
+ // run, so the two renderers can never state different sets.
124
+ ...(plan.workspaces.length === 0 || bare ? [] : table),
125
+ ],
126
+ data,
127
+ };
128
+ }
129
+
130
+ export const affectedCommand: CliCommand = createAffectedCommand();
package/src/cmd-auth.ts CHANGED
@@ -12,8 +12,7 @@ import type { CliCommand, CommandContext } from './command';
12
12
  import { ok } from './command';
13
13
  import { msg } from './messages';
14
14
  import type { CommandResult } from './output';
15
- import { resolveServices } from './runtime-bindings';
16
- import { startQueue } from './runtime-queue';
15
+ import { openAppQueue } from './runtime-boot-ports';
17
16
 
18
17
  export interface OpenAuthStore extends MfaSecretStore {
19
18
  close(): Promise<void>;
@@ -25,7 +24,8 @@ export interface OpenAuthStore extends MfaSecretStore {
25
24
  * exits holding the PGlite lock breaks the next command run against this app.
26
25
  */
27
26
  async function openAppAuthStore(root: string, ctx: CommandContext): Promise<OpenAuthStore> {
28
- const queue = await startQueue(resolveServices(root, ctx.env), undefined, ctx.env);
27
+ // `runtime.ts` read: sealing asks the master key, and a KMS app's key is its `secretSource`'s.
28
+ const queue = await openAppQueue(root, ctx.env);
29
29
  return { adapter: postgresAuthAdapter(queue.db), close: () => queue.stop() };
30
30
  }
31
31
 
package/src/cmd-ci.ts CHANGED
@@ -275,9 +275,12 @@ async function inspect(
275
275
  // this repair closes — so when the log had nothing, the finding reads nothing.
276
276
  findings.push({
277
277
  ...finding,
278
- // Fenced and tagged: the log is foreign text, and a `fix:` reconstructed from it is the
279
- // log author's instruction, not this CLI's. `commentBlock` is `x pr review`'s fence.
280
- fix: commentBlock(`ci-log ${name}`, [finding.fix]).join('\n'),
278
+ // Tagged, never fenced inside the value: the log is foreign text, and a `fix:` read from it
279
+ // is the log author's instruction, not this CLI's — `source` says so to a machine, and
280
+ // `output-findings.ts` never rewrites it into a runnable `bunx x`. A `<comment>` fence
281
+ // INSIDE `fix` reached the human render as one line of markup and literal `\n` (31.0
282
+ // field report), so the value stays the clean text and the job rides on `meta.job`.
283
+ meta: { ...finding.meta, job: name },
281
284
  source: 'ci-log',
282
285
  });
283
286
  }
@@ -12,6 +12,7 @@ import {
12
12
  } from '@ultimat3/db';
13
13
  import { countersOf, describeCounter, getEntity } from '@ultimat3/entity';
14
14
  import { loadApp } from './app-load';
15
+ import { loadAppRuntime } from './app-runtime';
15
16
  import type { CommandContext } from './command';
16
17
  import { DevAlreadyRunningError, liveDevLock } from './dev-lock';
17
18
  import { BadFlagError } from './errors';
@@ -19,6 +20,7 @@ import { msg } from './messages';
19
20
  import type { CommandResult } from './output';
20
21
  import { flagBool } from './parse';
21
22
  import { resolveServices } from './runtime-bindings';
23
+ import { installBootPorts } from './runtime-boot-ports';
22
24
  import { startDb } from './runtime-queue';
23
25
  import { quoteArg } from './shell-quote';
24
26
 
@@ -54,7 +56,20 @@ function counterNamed(target: string) {
54
56
  return { parent, counter: describeCounter(counter) };
55
57
  }
56
58
 
59
+ /**
60
+ * `runtime.ts`'s boot ports first: `loadApp` evaluates the app's modules, and one that seals or
61
+ * reads a secret at module scope must see the app's own source and clock (`runtime-boot-ports.ts`).
62
+ */
57
63
  export async function runRecountCommand(ctx: CommandContext, root: string): Promise<CommandResult> {
64
+ const booted = await installBootPorts(await loadAppRuntime(root));
65
+ try {
66
+ return await recount(ctx, root);
67
+ } finally {
68
+ for (const release of booted.reverse()) await release();
69
+ }
70
+ }
71
+
72
+ async function recount(ctx: CommandContext, root: string): Promise<CommandResult> {
58
73
  const target = ctx.args.positionals[0];
59
74
  if (target === undefined) return refuse('', 'is missing: name the counter as <entity>.<column>');
60
75
  const { findings } = await loadApp(root);
package/src/cmd-drill.ts CHANGED
@@ -40,12 +40,16 @@ const READY_TIMEOUT_MS = 90_000;
40
40
  /** `@ultimat3/http`'s own default — the app's `configureHttp` is runtime code, not config. */
41
41
  const HTTP_DEFAULT_DEADLINE_MS = 30_000;
42
42
 
43
- const declarationsOf = (config: AppConfig | undefined): DrillDeclarations => ({
43
+ /**
44
+ * What the app runs on. NATS is the environment's (v31: `realtime.transport` is gone, and
45
+ * `NATS_URL` alone selects the bus), so an unset `NATS_URL` is an app with no bus to fault.
46
+ */
47
+ const declarationsOf = (
48
+ config: AppConfig | undefined,
49
+ env: Readonly<Record<string, string | undefined>>,
50
+ ): DrillDeclarations => ({
44
51
  redis: config?.cache.tiers.includes('redis') ?? false,
45
- nats:
46
- config?.realtime.transport === 'nats'
47
- ? { env: config.realtime.urlEnv ?? 'NATS_URL' }
48
- : undefined,
52
+ nats: (env['NATS_URL']?.trim() ?? '') === '' ? undefined : { env: 'NATS_URL' },
49
53
  });
50
54
 
51
55
  /** The facts the thresholds derive from; `drillBudgets` screens every number it is handed. */
@@ -116,7 +120,7 @@ export const drillCommand: CliCommand = {
116
120
  });
117
121
  }
118
122
  const config = await loadAppConfig(root);
119
- const declared = declarationsOf(config);
123
+ const declared = declarationsOf(config, ctx.env);
120
124
  // Every drill's services, decided before any process starts. A named drill's gap is thrown; in
121
125
  // a whole run an undeclared service is stated as not run — an unset URL still refuses it all.
122
126
  const planned: { drill: Drill; services: ReturnType<typeof drillServices> }[] = [];
@@ -117,7 +117,8 @@ async function exercise(
117
117
  ...(only === undefined ? entityTenantFindings(describeEntities()) : []),
118
118
  ...subjectStatic,
119
119
  ...subjectProofs,
120
- ...exerciseFindings(records),
120
+ // The fix pastes into the file the app has, or hands it the file it lacks.
121
+ ...exerciseFindings(records, overrides === undefined ? 'absent' : 'present'),
121
122
  ];
122
123
  return {
123
124
  ok: findings.length === 0,
@@ -25,6 +25,12 @@ export const generateSpec: CommandSpec = {
25
25
  { name: 'admin', type: 'boolean', summary: 'resource: also emit the admin override' },
26
26
  { name: 'locales', type: 'string', summary: 'comma-separated locales, default en' },
27
27
  { name: 'at', type: 'string', summary: 'island, admin:page: directory to write into' },
28
+ {
29
+ name: 'app',
30
+ type: 'string',
31
+ summary: 'route, island, query: app under apps/',
32
+ default: 'web',
33
+ },
28
34
  { name: 'permission', type: 'string', summary: 'admin:page: the permission it needs' },
29
35
  { name: 'oidc', type: 'string', summary: 'sign-in: an OpenID Connect provider id' },
30
36
  { name: 'password', type: 'boolean', summary: 'sign-in: an address and a password' },
@@ -17,17 +17,19 @@ import { appDisk, plannedDisk } from './generate-disk';
17
17
  import { writtenExercises } from './generate-exercise';
18
18
  import { assertFeatureExists } from './generate-feature';
19
19
  import { assertSliceToRead } from './generate-feature-required';
20
- import { generate, sliceDir } from './generate-files';
20
+ import { DEFAULT_APP, generate, sliceDir } from './generate-files';
21
21
  import { followUpEdits } from './generate-follow-ups';
22
22
  import { formatWritten } from './generate-format-written';
23
23
  import type { Generator } from './generate-kinds';
24
24
  import { readFeature, readKind, readName, readPermission, readSurface } from './generate-kinds';
25
25
  import { refusePluralTable } from './generate-plural';
26
26
  import { followReexports } from './generate-reexports';
27
+ import { manifestCanChange } from './generate-refresh';
27
28
  import { refuseShadowedTypes, refuseShadowedValues } from './generate-shadow';
28
29
  import { declaresOnlyOtherEntities } from './generate-sibling';
29
30
  import { runSignIn } from './generate-sign-in';
30
31
  import { refuseSignInFlags } from './generate-sign-in-mode';
32
+ import { isWorkspaceKind, readApp, runWorkspace } from './generate-workspace';
31
33
  import { containedPath, planWrites, writeFiles } from './generate-write';
32
34
  import { resolveDbModule } from './handle-registration';
33
35
  import { resolveCatalogModule } from './i18n-audit';
@@ -79,6 +81,8 @@ export const generateCommand: CliCommand = {
79
81
  if (kind === 'sign-in') return await runSignIn(ctx, root);
80
82
  // One chart per app, named by its `Chart.yaml`: the same shape, for the same reason.
81
83
  if (kind === 'chart-alerts') return await runChartAlerts(ctx, root);
84
+ // A workspace, not a slice: no feature, no surface, no follow-up edit (`generate-workspace.ts`).
85
+ if (isWorkspaceKind(kind)) return await runWorkspace(ctx, root, kind);
82
86
  const name = readName(ctx.args.positionals[1], kind);
83
87
  const featureFlag = readFeature(flagString(ctx.args, 'feature'), kind);
84
88
  // Both flags are resolved before a single file is planned: a bad surface or a locale that is
@@ -86,6 +90,8 @@ export const generateCommand: CliCommand = {
86
90
  const surface = readSurface(flagString(ctx.args, 'surface'), kind, name);
87
91
  const locales = resolveLocales(await namedOrAppLocales(root, flagList(ctx.args, 'locales')));
88
92
  const at = flagString(ctx.args, 'at');
93
+ // The app workspace the slice lands in; `web` unless an app-local generator names another.
94
+ const app = readApp(flagString(ctx.args, 'app'), root, kind, name);
89
95
  // Read with the two above, and refused here for their reason: the value is spliced into the
90
96
  // emitted source three times, and a value that is not a `<resource>:<verb>` is a page the app
91
97
  // cannot compile — found after the files are on disk, which is the worst place to find it.
@@ -98,7 +104,7 @@ export const generateCommand: CliCommand = {
98
104
  // And whether the app has the frame a resource's page sits in.
99
105
  const shell = existsSync(containedPath(root, SHELL_MODULE));
100
106
  // Read for the same reason: which errors the slice declares is written on THIS app's disk.
101
- const slice = sliceDir(surface, kebab(featureFlag ?? name));
107
+ const slice = sliceDir(surface, kebab(featureFlag ?? name), app);
102
108
  // A named slice that is not there is refused, never invented (X_FEATURE_UNKNOWN).
103
109
  assertFeatureExists(root, kind, featureFlag, slice, name);
104
110
  // And a read with no table to read, never handed one (X_FEATURE_REQUIRED).
@@ -135,6 +141,7 @@ export const generateCommand: CliCommand = {
135
141
  ...(sliceEntity === undefined ? {} : { sliceEntity }),
136
142
  ...(sliceRepo === undefined ? {} : { sliceRepo }),
137
143
  ...(at === undefined ? {} : { at }),
144
+ ...(app === DEFAULT_APP ? {} : { app }),
138
145
  ...(permission === undefined ? {} : { permission }),
139
146
  surface,
140
147
  live: flagBool(ctx.args, 'live'),
@@ -207,8 +214,12 @@ export const generateCommand: CliCommand = {
207
214
  const touched = refused.length === 0 ? [...plan.written, ...follow.edited] : [];
208
215
  // Re-projected after a real write, from the loaded app: named, since their bytes are not
209
216
  // knowable without the files on disk.
217
+ // By the rule the run follows (`generate-refresh.ts`): files that cannot move a manifest
218
+ // fact name no refresh, because the run will not load the app to make one.
210
219
  const refreshes =
211
- plan.written.length === 0 || refused.length > 0
220
+ plan.written.length === 0 ||
221
+ refused.length > 0 ||
222
+ !(await manifestCanChange(root, [...plan.written, ...follow.edited], planned))
212
223
  ? []
213
224
  : [MANIFEST_FILENAME, 'openapi.json'].filter((file) =>
214
225
  existsSync(containedPath(root, file)),
@@ -261,7 +272,14 @@ export const generateCommand: CliCommand = {
261
272
  // `openapi.json` rides with it (`writeAppArtifacts`): refreshing one contract and not the other
262
273
  // made this command's own output fail the `contract-diff` step.
263
274
  const artifacts: string[] = [];
264
- if (report.written.length > 0 && existsSync(containedPath(root, MANIFEST_FILENAME))) {
275
+ // And only when the run's files can move one of its facts: the load is the whole app, the one
276
+ // step of a scaffold that grows with it, and an island, a test or a stylesheet moves nothing
277
+ // it projects (`generate-refresh.ts`).
278
+ if (
279
+ report.written.length > 0 &&
280
+ existsSync(containedPath(root, MANIFEST_FILENAME)) &&
281
+ (await manifestCanChange(root, [...report.written, ...edited]))
282
+ ) {
265
283
  const { manifest, findings } = await appManifest(root);
266
284
  if (findings.length === 0) {
267
285
  artifacts.push(
package/src/cmd-mail.ts CHANGED
@@ -28,7 +28,7 @@ export const mailCommand: CliCommand = {
28
28
  throw new MissingPositionalError({
29
29
  command: 'mail preview',
30
30
  positional: 'id',
31
- example: 'x mail preview welcome --locale es',
31
+ example: 'x mail preview <id> --locale es --json # the id given to defineMail({ id })',
32
32
  });
33
33
  }
34
34
  await loadApp(root);
@@ -7,7 +7,7 @@ export const PR_SUBCOMMANDS = ['review', 'resolve', 'reply'] as const;
7
7
 
8
8
  export const prSpec: CommandSpec = {
9
9
  name: 'pr',
10
- summary: 'inline review threads: list them with their ids, resolve one, reply in one',
10
+ summary: 'reviews, comments, bots that did not review, and inline threads; resolve or reply',
11
11
  usage:
12
12
  'x pr review [--pr <n>] [--repo owner/name] [--all] [--full] | x pr resolve <thread-id> | x pr reply <thread-id> --body "…"',
13
13
  subcommands: PR_SUBCOMMANDS,
package/src/cmd-pr.ts CHANGED
@@ -19,6 +19,7 @@ import { PrNotFoundError, resolvePrNumber, resolveRepo } from './gh-target';
19
19
  import { msg } from './messages';
20
20
  import type { CommandResult, JsonValue } from './output';
21
21
  import { flagBool, flagString } from './parse';
22
+ import { botsSummary } from './pr-bots';
22
23
  import type { PrReviewReport, PrThread } from './pr-threads';
23
24
  import { fetchReviewReport, replyToThread, resolveThread, THREAD_PAGE } from './pr-threads';
24
25
 
@@ -38,6 +39,9 @@ export const PR_MESSAGE_KEYS = [
38
39
  'cli.pr.review.current',
39
40
  'cli.pr.review.undecided',
40
41
  'cli.pr.review.truncated',
42
+ 'cli.pr.review.activity',
43
+ 'cli.pr.bot.blocked',
44
+ 'cli.pr.bot.notice',
41
45
  'cli.pr.thread.open',
42
46
  'cli.pr.thread.closed',
43
47
  'cli.pr.thread.outdated',
@@ -111,7 +115,11 @@ async function runReview(ctx: CommandContext): Promise<CommandResult> {
111
115
  repo: report.repo,
112
116
  pr: report.number,
113
117
  }),
114
- lines: [...decisionLines(report), ...shown.flatMap((thread) => threadLines(thread, bodyLines))],
118
+ lines: [
119
+ ...decisionLines(report),
120
+ ...activityLines(report),
121
+ ...shown.flatMap((thread) => threadLines(thread, bodyLines)),
122
+ ],
115
123
  data: reviewJson(report, shown, bodyLines, unresolved),
116
124
  };
117
125
  }
@@ -144,6 +152,43 @@ function decisionLines(report: PrReviewReport): readonly string[] {
144
152
  ];
145
153
  }
146
154
 
155
+ /**
156
+ * The rest of the conversation, in as few lines as it takes: one count, then one line per review
157
+ * bot that posted a "did not review" notice. Bodies stay in `--json` — the terminal is for the
158
+ * fact that a review is MISSING, which no thread would ever show.
159
+ */
160
+ function activityLines(report: PrReviewReport): readonly string[] {
161
+ const bots = botsSummary(report.reviews, report.comments);
162
+ const out = [
163
+ msg('cli.pr.review.activity', {
164
+ reviews: report.reviews.length,
165
+ comments: report.comments.length,
166
+ bots: bots.length,
167
+ }),
168
+ ];
169
+ for (const bot of bots) {
170
+ const notice = bot.notice;
171
+ if (notice === null) continue;
172
+ out.push(
173
+ bot.blocked
174
+ ? msg('cli.pr.bot.blocked', {
175
+ login: bot.login,
176
+ kind: notice.kind,
177
+ excerpt: notice.excerpt,
178
+ at: notice.at,
179
+ url: notice.url,
180
+ })
181
+ : msg('cli.pr.bot.notice', {
182
+ login: bot.login,
183
+ kind: notice.kind,
184
+ at: notice.at,
185
+ reviewed: bot.lastReviewAt ?? '',
186
+ }),
187
+ );
188
+ }
189
+ return out;
190
+ }
191
+
147
192
  const truncationLines = (report: PrReviewReport): readonly string[] =>
148
193
  report.truncated ? [msg('cli.pr.review.truncated', { count: THREAD_PAGE })] : [];
149
194
 
@@ -189,6 +234,12 @@ export function clampBody(
189
234
  return { lines: lines.slice(0, limit), hidden: lines.length - limit };
190
235
  }
191
236
 
237
+ /** `clampBody` as the two fields every `--json` body row carries. */
238
+ const clampedBody = (body: string, limit: number) => {
239
+ const clamped = clampBody(body, limit);
240
+ return { body: clamped.lines.join('\n'), bodyLinesHidden: clamped.hidden };
241
+ };
242
+
192
243
  function reviewJson(
193
244
  report: PrReviewReport,
194
245
  shown: readonly PrThread[],
@@ -221,6 +272,26 @@ function reviewJson(
221
272
  shown: shown.length,
222
273
  },
223
274
  truncated: report.truncated,
275
+ // Additive beside `threads`: every review with its verdict and body, every issue comment, and
276
+ // which review bots said they did NOT review — a rate-limited bot leaves no thread, so its
277
+ // silence would otherwise read as a clean review.
278
+ reviews: report.reviews.map(({ body, ...review }) => ({
279
+ ...review,
280
+ ...clampedBody(body, bodyLines),
281
+ })),
282
+ comments: report.comments.map(({ body, ...comment }) => ({
283
+ ...comment,
284
+ ...clampedBody(body, bodyLines),
285
+ })),
286
+ reviewsTruncated: report.reviewsTruncated,
287
+ commentsTruncated: report.commentsTruncated,
288
+ bots: botsSummary(report.reviews, report.comments).map(({ notice, ...bot }) => ({
289
+ ...bot,
290
+ notice:
291
+ notice === null
292
+ ? null
293
+ : { kind: notice.kind, excerpt: notice.excerpt, at: notice.at, url: notice.url },
294
+ })),
224
295
  threads: shown.map((thread) => {
225
296
  const comments = thread.comments.map((comment) => {
226
297
  const clamped = clampBody(comment.body, bodyLines);
package/src/cmd-routes.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  // The rows are `route-table.ts`'s — the one builder the MCP dev tool `routes.list` reads too — so
5
5
  // the CLI keeps no second table.
6
6
 
7
+ import { SURFACES } from '@ultimat3/core';
7
8
  import type { Surface } from '@ultimat3/render';
8
- import { SURFACES } from '@ultimat3/render';
9
9
  import { loadApp } from './app-load';
10
10
  import { requireAppRoot } from './app-root';
11
11
  import { routesSpec } from './cmd-routes-spec';
@@ -20,7 +20,7 @@ import { plainAppRoutes, renderRouteRows, routeRows } from './route-table';
20
20
  * A closed set, because the filter was a bare `===`: `x routes --surface App` and `--surface pages`
21
21
  * matched no row and reported `0 routes` with exit 0, which is the same output an app with no
22
22
  * routes gives — so a typo and an empty route table are indistinguishable, and only one of them is
23
- * a bug the caller can see. `SURFACES` is `@ultimat3/render`'s own declaration of what a surface
23
+ * a bug the caller can see. `SURFACES` is `@ultimat3/core`'s one declaration of what a surface
24
24
  * is; a list restated here would be a second answer to it (`x g --surface` is `generate-kinds.ts`'s
25
25
  * narrower question — which surface to SCAFFOLD onto — and takes site|app alone).
26
26
  */
@@ -8,7 +8,10 @@ export const SECRETS_SUBCOMMANDS = ['show', 'init', 'edit', 'set', 'rotate'] as
8
8
 
9
9
  export const secretsSpec: CommandSpec = {
10
10
  name: 'secrets',
11
- summary: `the committed encrypted secrets, decrypted into the ${ENV_SCHEMA_EXPORT} variables of the same names`,
11
+ // The key is read from the env and the file only, and the summary says so: importing
12
+ // `apps/<app>/runtime.ts` for its `secretSource` would run the app's boot guards, which may need
13
+ // the very secrets this command edits. A KMS/Vault source is the booted app's (`runtime.ts`).
14
+ summary: `the committed encrypted secrets, decrypted into the ${ENV_SCHEMA_EXPORT} variables of the same names; the master key is ULTIMATE_SECRETS_KEY or .secrets.key only — a runtime.ts secretSource is the booted app's`,
12
15
  usage: 'x secrets [show|init|edit|set <NAME>|rotate [--drop <keyId>]] [--json]',
13
16
  requiresApp: true,
14
17
  subcommands: [...SECRETS_SUBCOMMANDS],