@ultimat3/cli 31.31.0 → 31.33.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 (170) hide show
  1. package/package.json +29 -29
  2. package/src/admin-registration.ts +6 -5
  3. package/src/affected.ts +3 -2
  4. package/src/api-registration.ts +7 -5
  5. package/src/app-agents-md.ts +1 -1
  6. package/src/app-boundaries.ts +12 -8
  7. package/src/app-layout.ts +6 -5
  8. package/src/app-load.ts +1 -1
  9. package/src/app-manifest.ts +1 -1
  10. package/src/app-mcp.ts +11 -9
  11. package/src/app-openapi.ts +7 -5
  12. package/src/app-reload-graph.ts +9 -7
  13. package/src/app-runtime.ts +9 -6
  14. package/src/async-pages.ts +6 -5
  15. package/src/browser-launcher.ts +9 -5
  16. package/src/browser-transport.ts +8 -5
  17. package/src/budgets.ts +4 -3
  18. package/src/cdp-shot-driver.ts +21 -5
  19. package/src/cdp-shot-errors.ts +7 -5
  20. package/src/cdp-shot-page.ts +6 -5
  21. package/src/cdp-shot-watch.ts +7 -5
  22. package/src/ci-log.ts +6 -5
  23. package/src/ci-runs.ts +7 -3
  24. package/src/cmd-auth.ts +5 -4
  25. package/src/cmd-build.ts +13 -7
  26. package/src/cmd-ci.ts +9 -6
  27. package/src/cmd-clean.ts +9 -6
  28. package/src/cmd-db-backfill.ts +8 -5
  29. package/src/cmd-db-branch.ts +3 -2
  30. package/src/cmd-db.ts +2 -2
  31. package/src/cmd-deploy-compose.ts +8 -5
  32. package/src/cmd-deploy.ts +2 -1
  33. package/src/cmd-dev.ts +1 -0
  34. package/src/cmd-env.ts +1 -1
  35. package/src/cmd-errors.ts +2 -3
  36. package/src/cmd-generate.ts +2 -0
  37. package/src/cmd-i18n.ts +8 -6
  38. package/src/cmd-jobs.ts +3 -2
  39. package/src/cmd-manifest.ts +1 -0
  40. package/src/cmd-new.ts +2 -0
  41. package/src/cmd-planned.ts +2 -1
  42. package/src/cmd-pr.ts +7 -6
  43. package/src/cmd-registries.ts +5 -4
  44. package/src/cmd-repro.ts +8 -2
  45. package/src/cmd-secrets.ts +1 -1
  46. package/src/cmd-shot-island.ts +4 -2
  47. package/src/cmd-shot.ts +1 -0
  48. package/src/cmd-tasks.ts +7 -5
  49. package/src/cmd-test.ts +13 -8
  50. package/src/db-backfill.ts +4 -3
  51. package/src/db-branch.ts +2 -2
  52. package/src/db-generate.ts +1 -1
  53. package/src/db-schema-refresh.ts +5 -4
  54. package/src/db-seed.ts +3 -2
  55. package/src/dev-child-watch.ts +7 -6
  56. package/src/dev-environment.ts +6 -5
  57. package/src/dev-lock.ts +5 -2
  58. package/src/dev-n-plus-one.ts +7 -5
  59. package/src/dev-reload.ts +7 -5
  60. package/src/dev-restart-retire.ts +7 -5
  61. package/src/dev-supervisor.ts +9 -6
  62. package/src/dev-watch-tree.ts +9 -7
  63. package/src/dev-watch.ts +7 -5
  64. package/src/document-styles.ts +7 -5
  65. package/src/drift.ts +9 -5
  66. package/src/duplicate-packages.ts +12 -6
  67. package/src/error-contract.ts +4 -2
  68. package/src/error-fixes.ts +7 -6
  69. package/src/error-unthrown.ts +7 -5
  70. package/src/errors.ts +11 -10
  71. package/src/fix-imports.ts +1 -1
  72. package/src/flag-number.ts +2 -1
  73. package/src/flag-reads.ts +1 -1
  74. package/src/framework-schema-apply.ts +7 -5
  75. package/src/framework-scope.ts +1 -1
  76. package/src/generate-files.ts +1 -1
  77. package/src/generate-follow-ups.ts +8 -5
  78. package/src/generate-kinds.ts +2 -2
  79. package/src/generate-shadow.ts +6 -4
  80. package/src/generate-sibling.ts +6 -4
  81. package/src/gh-target.ts +3 -2
  82. package/src/guards.ts +4 -3
  83. package/src/handle-registration.ts +4 -3
  84. package/src/i18n-audit.ts +4 -4
  85. package/src/i18n-registration.ts +7 -4
  86. package/src/import-closure.ts +7 -6
  87. package/src/island-bundle.ts +7 -6
  88. package/src/island-cache-inputs.ts +2 -1
  89. package/src/island-capture.ts +5 -4
  90. package/src/island-realtime-state.ts +6 -5
  91. package/src/island-realtime.ts +8 -6
  92. package/src/island-shot-errors.ts +2 -1
  93. package/src/island-shot.ts +6 -5
  94. package/src/load-findings.ts +8 -5
  95. package/src/local-cli.ts +8 -6
  96. package/src/mcp-db-target.ts +2 -2
  97. package/src/mcp-errors.ts +3 -1
  98. package/src/mcp-ui-diff.ts +8 -5
  99. package/src/mcp-ui-inspect.ts +8 -6
  100. package/src/mcp-ui-interact.ts +9 -6
  101. package/src/mcp-ui.ts +11 -9
  102. package/src/measure-database.ts +8 -6
  103. package/src/measure-paths.ts +7 -5
  104. package/src/measure-scope.ts +10 -8
  105. package/src/migrations.ts +2 -0
  106. package/src/page-navigation.ts +9 -7
  107. package/src/page-speculation.ts +8 -6
  108. package/src/parse.ts +3 -3
  109. package/src/path-segments.ts +2 -1
  110. package/src/pr-threads.ts +2 -1
  111. package/src/prerender.ts +4 -4
  112. package/src/role-start.ts +3 -2
  113. package/src/role-sync.ts +2 -1
  114. package/src/runtime-assets.ts +8 -6
  115. package/src/runtime-bindings.ts +2 -0
  116. package/src/runtime-cache.ts +7 -5
  117. package/src/runtime-live-feed.ts +7 -5
  118. package/src/runtime-overrides.ts +7 -5
  119. package/src/runtime-queue.ts +6 -5
  120. package/src/schema-drift.ts +11 -14
  121. package/src/script-csp.ts +4 -2
  122. package/src/secrets-rotation.ts +7 -5
  123. package/src/serve-boot.ts +8 -6
  124. package/src/serve.ts +8 -5
  125. package/src/server-barrels.ts +7 -5
  126. package/src/shell-quote.ts +8 -1
  127. package/src/shot-locale.ts +2 -1
  128. package/src/shot-route.ts +2 -1
  129. package/src/shot-theme.ts +8 -6
  130. package/src/site-config.ts +2 -1
  131. package/src/site-llms-pages.ts +8 -2
  132. package/src/source-list-edit.ts +8 -6
  133. package/src/static-cards.ts +2 -2
  134. package/src/static-report.ts +22 -18
  135. package/src/sync-authenticator.ts +6 -5
  136. package/src/templates/admin-page.ts +8 -5
  137. package/src/templates/admin.ts +6 -5
  138. package/src/templates/guard-animated-layout-property.ts +7 -5
  139. package/src/templates/guard-focus-visible.ts +7 -5
  140. package/src/templates/guard-image-dimensions.ts +8 -5
  141. package/src/templates/guard-island-without-states.ts +5 -3
  142. package/src/templates/guard-semantic-interactive.ts +1 -0
  143. package/src/templates/island.ts +9 -6
  144. package/src/templates/resource-form-island.ts +3 -2
  145. package/src/templates/resource-page.ts +8 -6
  146. package/src/templates/route.ts +1 -0
  147. package/src/templates/scaffold-docs.ts +7 -6
  148. package/src/templates/scaffold-entries.ts +7 -5
  149. package/src/templates/scaffold-errors.ts +8 -6
  150. package/src/templates/scaffold-repo.ts +5 -4
  151. package/src/templates/scaffold-shell.ts +7 -5
  152. package/src/templates/scaffold-site.ts +7 -5
  153. package/src/test-housekeeping.ts +3 -6
  154. package/src/test-select.ts +3 -3
  155. package/src/ts-scan.ts +6 -4
  156. package/src/tsconfig-references.ts +6 -6
  157. package/src/verify-checks.ts +9 -9
  158. package/src/verify-e2e.ts +8 -6
  159. package/src/verify-floor.ts +8 -8
  160. package/src/verify-pace.ts +3 -1
  161. package/src/verify-role-load.ts +8 -5
  162. package/src/verify-services.ts +2 -1
  163. package/src/verify-tests.ts +2 -2
  164. package/src/verify-typecheck.ts +7 -5
  165. package/src/version-loader.ts +1 -1
  166. package/src/worker-bundle.ts +7 -5
  167. package/src/workspace-checks.ts +6 -3
  168. package/src/workspace-external-deps.ts +4 -2
  169. package/src/workspace-graph.ts +4 -3
  170. package/src/write-line.ts +1 -1
package/src/cmd-ci.ts CHANGED
@@ -1,8 +1,11 @@
1
- // `x ci` — one command instead of three. `gh run view` prints a tree of ticks and one cross, and
2
- // the error is inside a per-job log that is mostly setup noise; for a `verify` job that log tail IS
3
- // the findings block, with its `X_*` codes and executable `fix:` lines already in it. So this
4
- // command fetches the runs, opens only the failed steps' log, and hands back the findings the gate
5
- // already wrote — in the same three-line shape every other Ultimate error is printed in.
1
+ // `x ci` — one command instead of three: the failed runs' findings, read off their logs, in
2
+ // the three-line shape every Ultimate error is printed in.
3
+ //
4
+ // `gh run view` prints a tree of ticks and one cross, and the error is inside a per-job log that is
5
+ // mostly setup noise; for a `verify` job that log tail IS the findings block, with its `X_*` codes
6
+ // and executable `fix:` lines already in it. So this command fetches the runs, opens only the
7
+ // failed steps' log, and hands back the findings the gate already wrote — in the same three-line
8
+ // shape every other Ultimate error is printed in.
6
9
 
7
10
  import { renderThrowable, UltimateError } from '@ultimat3/core';
8
11
  import { parseDuration } from '@ultimat3/time';
@@ -75,7 +78,7 @@ export class CiRunNotFoundError extends UltimateError {
75
78
  super({
76
79
  code: 'X_CI_RUN_NOT_FOUND',
77
80
  cause: `no workflow run on ${input.repo} for branch "${input.branch}"${matching}`,
78
- fix: `x ci --branch main --repo ${input.repo} --json`,
81
+ fix: `x ci --branch main --repo ${quoteArg(input.repo)} --json`,
79
82
  });
80
83
  }
81
84
  }
package/src/cmd-clean.ts CHANGED
@@ -1,9 +1,12 @@
1
- // `x clean` — every test leftover the framework knows of, cleared on demand (#738): the migrated
2
- // test-database templates under `.x/test-db`, the whole `.x/cache`, the `.x` folders a process
3
- // started in a source folder once wrote beside the code, and — with `TEST_DATABASE_URL` set — the
4
- // probe databases whose run is over. The test runner sweeps the same set before every run, keeping
5
- // the newest two of each cache (`test-housekeeping.ts`); this is the same sweep, keeping none.
6
- // Never touched: `.x/pgdata` (the dev database), `.x/storage`, the build output.
1
+ // `x clean` — every test leftover the framework knows of, cleared on demand (#738): the same
2
+ // sweep the test runner makes before every run, keeping none.
3
+ //
4
+ // The set: the migrated test-database templates under `.x/test-db`, the whole `.x/cache`, the `.x`
5
+ // folders a process started in a source folder once wrote beside the code, and — with
6
+ // `TEST_DATABASE_URL` set — the probe databases whose run is over. The test runner sweeps the same
7
+ // set before every run, keeping the newest two of each cache (`test-housekeeping.ts`); this is the
8
+ // same sweep, keeping none. Never touched: `.x/pgdata` (the dev database), `.x/storage`, the build
9
+ // output.
7
10
 
8
11
  import { requireAppRoot } from './app-root';
9
12
  import { cleanSpec } from './cmd-clean-spec';
@@ -47,11 +47,14 @@ const SHAPE_OF_FLAG = Object.freeze<Record<string, BackfillShape>>({
47
47
  });
48
48
 
49
49
  /** One runnable line per shape, so a refusal hands back the invocation the caller meant. */
50
- const FIX_OF_SHAPE = Object.freeze<Record<BackfillShape, string>>({
51
- list: 'x db backfill --list --json',
52
- pending: 'x db backfill --pending --json',
53
- pass: 'x db backfill --all --write --json',
54
- });
50
+ // Null-prototype: a shape that is not one of these reads `undefined`, never an `Object` member.
51
+ const FIX_OF_SHAPE: Readonly<Record<BackfillShape, string>> = Object.freeze(
52
+ Object.assign(Object.create(null) as object, {
53
+ list: 'x db backfill --list --json',
54
+ pending: 'x db backfill --pending --json',
55
+ pass: 'x db backfill --all --write --json',
56
+ } satisfies Record<BackfillShape, string>),
57
+ );
55
58
 
56
59
  const refuseShape = (flag: string, reason: string, fix: string): never => {
57
60
  throw new BadFlagError({ flag, command: 'db', reason, fix });
@@ -1,8 +1,9 @@
1
1
  // `x db branch list|create|delete` — the wiring alone: which verb, which database, which refusal.
2
+ //
2
3
  // A VERB is required and comes from a closed set, so a branch name can never be read as one:
3
4
  // `x db branch ls` used to clone a database called `ls`, because the argument was the name. One
4
- // verb each across every `x` registry (#709): `list` and `delete`, no `ls`/`drop` alias.
5
- // The facts (what a branch is, per mode) are `db-branch.ts`; the client lifetime is here.
5
+ // verb each across every `x` registry (#709): `list` and `delete`, no `ls`/`drop` alias. The facts
6
+ // (what a branch is, per mode) are `db-branch.ts`; the client lifetime is here.
6
7
 
7
8
  import { ERROR_DOCS_URL, nearestName } from '@ultimat3/core';
8
9
  import { type DbClient, postgresClient } from '@ultimat3/db';
package/src/cmd-db.ts CHANGED
@@ -8,8 +8,8 @@
8
8
  // a release phase. Until 1.2.0 these shelled out to `bunx drizzle-kit` — a second engine with a
9
9
  // second journal, declared in no `package.json` and fetched unpinned at run time.
10
10
 
11
- // `node:fs/promises` for `rm` — `Bun.file().delete()` takes one file, and `x db reset` removes a
12
- // directory tree. `node:path` for `join` — Bun exposes no path joiner.
11
+ // why: `node:fs/promises` for `rm` — `Bun.file().delete()` takes one file, and `x db reset` removes
12
+ // a directory tree. `node:path` for `join` — Bun exposes no path joiner.
13
13
  import { rm } from 'node:fs/promises';
14
14
  import { join } from 'node:path';
15
15
  import { NotImplementedError, resolveEnvironment } from '@ultimat3/core';
@@ -1,8 +1,11 @@
1
- // The compose half of `x deploy`, read off the app's compose file: which serving roles can start
2
- // their new container BEFORE the old one stops (the sequence is `cmd-deploy-start-first.ts`), and
3
- // what the file demands of `.env.production` — read by the deploy's pre-flight and `x env init`.
4
- // `docker compose up -d <role>` alone is stop-first — it recreates, so the role serves nothing
5
- // between the old container's exit and the new one's healthcheck.
1
+ // The compose half of `x deploy`, read off the app's compose file: which serving roles can
2
+ // start first, and what the file demands of `.env.production`.
3
+ //
4
+ // A start-first role starts its new container BEFORE the old one stops (the sequence is
5
+ // `cmd-deploy-start-first.ts`); the `.env.production` demands are read by the deploy's pre-flight
6
+ // and `x env init`. `docker compose up -d <role>` alone is stop-first — it
7
+ // recreates, so the role serves nothing between the old container's exit and the new one's
8
+ // healthcheck.
6
9
 
7
10
  /**
8
11
  * How one serving role is rolled. `start-first` is the zero-downtime path; `stop-first` is
package/src/cmd-deploy.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  // not know the name of a cloud, a KV store or an edge runtime (axiom 7). What it emits is a plan
3
3
  // anything that runs containers can execute.
4
4
 
5
+ // why: Bun ships no path API; `join` builds the host-separator paths to the app's deploy files.
5
6
  import { join } from 'node:path';
6
7
  import { ERROR_DOCS_URL } from '@ultimat3/core';
7
8
  import { loadEnvSchema } from './app-env';
@@ -209,7 +210,7 @@ export function planDeploy(
209
210
  flag: 'image',
210
211
  command: 'deploy',
211
212
  reason: `"${image}" pins a digest, and docker/helm renders repository:tag with no digest branch`,
212
- fix: `x deploy --method helm --image ${image.slice(0, image.lastIndexOf('@'))}:<tag> --json`,
213
+ fix: `x deploy --method helm --image ${quoteArg(image.slice(0, image.lastIndexOf('@')))}:<tag> --json`,
213
214
  });
214
215
  }
215
216
  // Helm splits a `--set-string` argument on `,` and reads `=` as key/value: an image built from
package/src/cmd-dev.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  // mounted alongside the app — mounted, never re-implemented — so an agent can introspect it.
4
4
  // No Docker, no env setup: an unset variable means the embedded default.
5
5
 
6
+ // why: Bun ships no path API; `join` builds the host-separator paths under the app root.
6
7
  import { join } from 'node:path';
7
8
  import { METRICS_PATH } from '@ultimat3/core';
8
9
  import { MANIFEST_FILENAME } from '@ultimat3/manifest';
package/src/cmd-env.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  // which variables exist, the answer to "does this process have them?", and (`init`,
3
3
  // `cmd-env-init.ts`) the deploy's `.env.production`. All read the one `defineEnv` declaration.
4
4
 
5
- // Bun ships no path-join primitive, and `.env.example` is written app-root-relative.
5
+ // why: Bun ships no path-join primitive, and `.env.example` is written app-root-relative.
6
6
  import { join } from 'node:path';
7
7
  import {
8
8
  checkEnv,
package/src/cmd-errors.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { nearestName, singleLine } from '@ultimat3/core';
2
1
  // `x errors explain <CODE>` / `x errors list` — the error table, programmatically. An agent that
3
2
  // hits an `X_*` code should not have to leave the terminal to learn what it means, and a code it
4
- // invented should come back refused: the answer to an unregistered code is "no such code", never
5
- // a plausible-sounding explanation an agent would then act on.
3
+ // invented should come back refused: "no such code", never a plausible-sounding explanation.
6
4
 
5
+ import { nearestName, singleLine } from '@ultimat3/core';
7
6
  import type { ErrorExplanation } from '@ultimat3/mcp';
8
7
  import { withRecent } from './cmd-errors-recent';
9
8
  import { errorsSpec } from './cmd-errors-spec';
@@ -2,6 +2,8 @@
2
2
  // emits a TODO has moved the work, not done it; every file this writes typechecks, and every
3
3
  // primitive arrives with the test that pins its distant invariants (policy, idempotency, budget).
4
4
 
5
+ // why: the follow-up filters ask "is it on disk?" synchronously, inside `.filter()`, and Bun's
6
+ // only existence check, `Bun.file().exists()`, is async.
5
7
  import { existsSync } from 'node:fs';
6
8
  import { MANIFEST_FILENAME } from '@ultimat3/manifest';
7
9
  import { indexBindingFindings } from './api-registration';
package/src/cmd-i18n.ts CHANGED
@@ -2,10 +2,11 @@
2
2
  // X_CATALOG_MISSING_KEYS and X_CATALOG_INVALID fix line already names. CLI wiring only: the
3
3
  // facts come from `i18n-audit.ts`, the audit itself from `@ultimat3/i18n`'s own `auditCatalogs`.
4
4
 
5
- // `node:` and not Bun: Bun has no exclusive-create write, and `open(path, 'wx')` is the only one
6
- // there is — `Bun.write` overwrites, so an existence check before it is a race a second `x i18n
7
- // add` wins. `mkdir` comes with it because `open` does not create the parent directory `Bun.write`
8
- // would, and `node:path` because Bun exposes no path API to build what either of them takes.
5
+ // why: `node:` and not Bun: Bun has no exclusive-create write, and `open(path, 'wx')` is the only
6
+ // one there is — `Bun.write` overwrites, so an existence check before it is a race a second
7
+ // `x i18n add` wins. `mkdir` comes with it because `open` does not create the parent directory
8
+ // `Bun.write` would, and `node:path` because Bun exposes no path API to build what either of them
9
+ // takes.
9
10
  import { type FileHandle, mkdir, open } from 'node:fs/promises';
10
11
  import { dirname, join } from 'node:path';
11
12
  import { DEFAULT_LOCALE, stringField } from '@ultimat3/core';
@@ -38,6 +39,7 @@ import {
38
39
  } from './i18n-registration';
39
40
  import { msg } from './messages';
40
41
  import type { CommandResult, Finding, JsonValue } from './output';
42
+ import { quoteArg } from './shell-quote';
41
43
  import { renderTable } from './table';
42
44
  import { catalogPath, resolveLocales } from './templates/locales';
43
45
 
@@ -104,7 +106,7 @@ function requireLocalePositional(ctx: CommandContext, sub: string): string {
104
106
  function resolveOneLocale(ctx: CommandContext, sub: string): string {
105
107
  const raw = requireLocalePositional(ctx, sub);
106
108
  const resolved = resolveLocales([raw], {
107
- fix: `x i18n ${sub} es`,
109
+ fix: `x i18n ${quoteArg(sub)} es`,
108
110
  command: 'i18n',
109
111
  flag: 'locale',
110
112
  });
@@ -315,7 +317,7 @@ async function runSync(root: string, ctx: CommandContext): Promise<CommandResult
315
317
  flag: 'locale',
316
318
  command: 'i18n',
317
319
  reason: `no catalog for "${locale}" at ${catalogPath(locale)}`,
318
- fix: `x i18n add ${locale}`,
320
+ fix: `x i18n add ${quoteArg(locale)}`,
319
321
  });
320
322
  }
321
323
 
package/src/cmd-jobs.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // `x jobs list|show|retry|cancel|delete|promote|resolve-step|pause|resume` — introspect and
2
- // recover the job queue, bound to `@ultimat3/jobs`'s own introspection so the CLI, `/_x` and MCP
3
- // report identically.
2
+ // recover the job queue, bound to `@ultimat3/jobs`'s own introspection so the CLI, `/_x` and
3
+ // MCP report identically.
4
+ //
4
5
  // CLI wiring only: the driver-injected logic is `jobs-report.ts`, the `--json` shapes
5
6
  // `jobs-json.ts`, the table `jobs-table.ts`, the queue `jobs-driver.ts` — shared with `x db`.
6
7
 
@@ -2,6 +2,7 @@
2
2
  // conventions are hand-written: nothing in this file writes prose, and nothing else in the app is
3
3
  // allowed to hand-edit these two files.
4
4
 
5
+ // why: Bun ships no path API; `join` builds the host-separator path to the manifest file.
5
6
  import { join } from 'node:path';
6
7
  import type { Manifest } from '@ultimat3/manifest';
7
8
  import { MANIFEST_FILENAME } from '@ultimat3/manifest';
package/src/cmd-new.ts CHANGED
@@ -2,6 +2,8 @@
2
2
  // streaming dashboard, an admin app with MCP on, and an example feature slice with passing tests.
3
3
  // Interactive-free: every choice is a flag with a default, because an agent cannot answer prompts.
4
4
 
5
+ // why: the target is a DIRECTORY, which `Bun.file().exists()` answers false for; Bun ships no
6
+ // path API, and `isAbsolute`/`join`/`relative`/`resolve` place the new app.
5
7
  import { existsSync } from 'node:fs';
6
8
  import { isAbsolute, join, relative, resolve } from 'node:path';
7
9
  import { ERROR_DOCS_URL, renderThrowable } from '@ultimat3/core';
@@ -7,6 +7,7 @@ import { NotImplementedError } from '@ultimat3/core';
7
7
  import type { CliCommand } from './command';
8
8
  import type { CommandResult } from './output';
9
9
  import type { CommandSpec } from './parse';
10
+ import { quoteArg } from './shell-quote';
10
11
 
11
12
  export interface PlannedCommand {
12
13
  readonly name: string;
@@ -97,7 +98,7 @@ export function plannedSubcommand(command: string, subcommand: string): NotImple
97
98
  cause: `x ${command} ${subcommand} is not implemented in this build`,
98
99
  // `x help <command>`, not `x <command> --help`: for a command that declares subcommands and no
99
100
  // default, the latter is refused by the parser before help is ever rendered.
100
- fix: planned?.fix ?? `x help ${command}`,
101
+ fix: planned?.fix ?? `x help ${quoteArg(command.split(' '))}`,
101
102
  });
102
103
  }
103
104
 
package/src/cmd-pr.ts CHANGED
@@ -1,9 +1,10 @@
1
- // `x pr review|resolve|reply` — the inline review, in a terminal. `gh pr view --comments` prints
2
- // ISSUE comments, so the findings a reviewer anchored to a line are invisible to it and the thread
3
- // id needed to resolve one exists nowhere a human can copy. This command is the one place that
4
- // query lives, and the one place the two facts a reviewer's verdict hides behind are stated: a
5
- // `reviewDecision` outlives the push that answered it, and a RESOLVED thread is a closed
6
- // conversation rather than a fixed finding.
1
+ // `x pr review|resolve|reply` — the inline review, in a terminal.
2
+ //
3
+ // `gh pr view --comments` prints ISSUE comments, so the findings a reviewer anchored to a line are
4
+ // invisible to it and the thread id needed to resolve one exists nowhere a human can copy. This
5
+ // command is the one place that query lives, and the one place the two facts a reviewer's verdict
6
+ // hides behind are stated: a `reviewDecision` outlives the push that answered it, and a RESOLVED
7
+ // thread is a closed conversation rather than a fixed finding.
7
8
 
8
9
  import { PR_SUBCOMMANDS, prSpec } from './cmd-pr-spec';
9
10
  import type { CliCommand, CommandContext } from './command';
@@ -1,8 +1,9 @@
1
1
  // `x actions`, `x queries`, `x entities` — the declaration registries as a table or as JSON.
2
- // Replaces grepping a source tree, which is what an agent does when the framework has no answer
3
- // to "what actions/queries/entities exist". One table, one generic command body: the three
4
- // commands differ only in which registry they read, a row's columns, and (for a query only) the
5
- // one extra field `show` surfaces that its descriptor does not already carry.
2
+ //
3
+ // Replaces grepping a source tree, which is what an agent does when the framework has no answer to
4
+ // "what actions/queries/entities exist". One table, one generic command body: the three commands
5
+ // differ only in which registry they read, a row's columns, and (for a query only) the one extra
6
+ // field `show` surfaces that its descriptor does not already carry.
6
7
 
7
8
  import type { ActionDescriptor, AnyAction } from '@ultimat3/action';
8
9
  import { describeActions, getAction, jsonSchemaOf } from '@ultimat3/action';
package/src/cmd-repro.ts CHANGED
@@ -172,7 +172,10 @@ export const reproCommand: CliCommand = {
172
172
  flag: 'include-rows',
173
173
  command: 'repro',
174
174
  reason: 'it chooses what a bundle carries, and no --bundle was asked for',
175
- fix: `x repro ${id === undefined ? '--from <file>' : renderFixShellArg(id, '<id>')} --bundle --include-rows`,
175
+ fix:
176
+ id === undefined
177
+ ? 'x repro --from <file> --bundle --include-rows'
178
+ : `x repro ${renderFixShellArg(id, '<id>')} --bundle --include-rows`,
176
179
  });
177
180
  }
178
181
  if (bundle && (flagBool(ctx.args, 'write') || flagBool(ctx.args, 'verify'))) {
@@ -180,7 +183,10 @@ export const reproCommand: CliCommand = {
180
183
  flag: 'bundle',
181
184
  command: 'repro',
182
185
  reason: 'a bundle is written for an issue, and --write/--verify run the test in this app',
183
- fix: `x repro ${id === undefined ? '--from <file>' : renderFixShellArg(id, '<id>')} --bundle`,
186
+ fix:
187
+ id === undefined
188
+ ? 'x repro --from <file> --bundle'
189
+ : `x repro ${renderFixShellArg(id, '<id>')} --bundle`,
184
190
  });
185
191
  }
186
192
  // The app's declarations are what mask a job's input and what a written test replays against.
@@ -3,7 +3,7 @@
3
3
  // the envelope comes from `@ultimat3/core`; this file owns the terminal, the temporary plaintext
4
4
  // buffer, and the `.gitignore` rule that keeps the master key out of the repository.
5
5
 
6
- // Bun ships no temp-directory primitive and no path join. `rmSync` is the synchronous half: a
6
+ // why: Bun ships no temp-directory primitive and no path join. `rmSync` is the synchronous half: a
7
7
  // signal handler that awaited would be racing the default action it is trying to beat.
8
8
  import { rmSync } from 'node:fs';
9
9
  import { mkdtemp } from 'node:fs/promises';
@@ -9,6 +9,7 @@
9
9
 
10
10
  // why: no Bun native joins or resolves a path; `--out` is resolved against the app root.
11
11
  import { join, resolve } from 'node:path';
12
+ import { renderFixShellArg } from '@ultimat3/core';
12
13
  import type { IslandStatesManifest, IslandViewport } from '@ultimat3/testing';
13
14
  import { findIslandStates } from '@ultimat3/testing';
14
15
  import { appBrowser } from './browser-launcher';
@@ -26,6 +27,7 @@ import {
26
27
  islandVerdictJson,
27
28
  } from './island-verdict';
28
29
  import type { CommandResult } from './output';
30
+ import { quoteArg } from './shell-quote';
29
31
  import type { ShotCookiePair } from './shot-cookie';
30
32
  import type { ShotServer } from './shot-server';
31
33
  import { SHOT_DIR } from './shot-server';
@@ -71,7 +73,7 @@ export function readStateFlag(
71
73
  flag: 'state',
72
74
  command: 'shot',
73
75
  reason: `${manifest.island} declares no state "${wanted}" — it declares ${known.join(', ')}`,
74
- fix: `x shot --island ${manifest.name} --state ${known[0] ?? '<id>'} --json`,
76
+ fix: `x shot --island ${quoteArg(manifest.name)} --state ${renderFixShellArg(known[0], '<id>')} --json`,
75
77
  });
76
78
  }
77
79
 
@@ -85,7 +87,7 @@ export function refuseRouteWithIsland(route: string | undefined, island: string)
85
87
  flag: 'island',
86
88
  command: 'shot',
87
89
  reason: `--island ${island} photographs a component and "${route ?? ''}" is a route; x shot takes one subject`,
88
- fix: `x shot --island ${island} --json`,
90
+ fix: `x shot --island ${quoteArg(island)} --json`,
89
91
  });
90
92
  }
91
93
 
package/src/cmd-shot.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  // Never a step of `x verify`: it needs a real browser, and a gate that goes red because a machine
6
6
  // has no Chrome is a gate that fails for reasons unrelated to the change.
7
7
 
8
+ // why: Bun ships no path API; `resolve` anchors `--out` at the caller's cwd, `join` the files.
8
9
  import { join, resolve } from 'node:path';
9
10
  import { renderFixShellArg } from '@ultimat3/core';
10
11
  import { appLocaleSet } from '@ultimat3/i18n/app-catalogs';
package/src/cmd-tasks.ts CHANGED
@@ -1,8 +1,10 @@
1
- // `x tasks [list|show <name>]` — introspect scheduled cron tasks: cadence, timezone, the jobs
2
- // each enqueues, the occurrence the scheduler LAST dispatched (off the queue's own record) and
3
- // real next-occurrence instants from `@ultimat3/time`'s cron math instead of an agent reading
4
- // `0 3 * * *` and guessing. CLI wiring only; the pure computation lives in `tasks-facts.ts` — the
5
- // same split `cmd-jobs.ts` makes against `jobs-report.ts`.
1
+ // `x tasks [list|show <name>]` — introspect scheduled cron tasks: cadence, timezone, enqueued
2
+ // jobs, last dispatch and real next occurrences. CLI wiring only (`tasks-facts.ts`).
3
+ //
4
+ // The last dispatch is read off the queue's own record, and the next occurrences are real instants
5
+ // from `@ultimat3/time`'s cron math instead of an agent reading `0 3 * * *` and guessing. The
6
+ // pure computation lives in `tasks-facts.ts` — the same split `cmd-jobs.ts` makes against
7
+ // `jobs-report.ts`.
6
8
 
7
9
  import { nearestName, systemClock } from '@ultimat3/core';
8
10
  import type { JobDriver, TaskFire, TaskHandle } from '@ultimat3/jobs';
package/src/cmd-test.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  // `x test`'s command surface: the flags and the one positional it accepts, and the refusals that
2
- // happen before a single process starts. Which files run is test-select.ts, how they are split and
3
- // spawned is test-shards.ts — this file only turns argv into their inputs, so a parsing bug can
4
- // never be read as a sharding one. `--affected` is the one narrowing decided here rather than
5
- // there, because it is a fact about a git diff and not about a path: what the diff touches is
6
- // `affected.ts` (workspaces) and, in an app root, `affected-tests.ts` (import closure); this file
7
- // only maps that answer onto the paths discovery yields.
2
+ // happen before a single process starts.
3
+ //
4
+ // Which files run is test-select.ts, how they are split and spawned is test-shards.ts — this file
5
+ // only turns argv into their inputs, so a parsing bug can never be read as a sharding one.
6
+ // `--affected` is the one narrowing decided here rather than there, because it is a fact about a
7
+ // git diff and not about a path: what the diff touches is `affected.ts` (workspaces) and, in an app
8
+ // root, `affected-tests.ts` (import closure); this file only maps that answer onto the paths
9
+ // discovery yields.
8
10
 
9
11
  import { JOB_SIM_SEED_ENV, TEST_TYPES } from '@ultimat3/testing';
10
12
  import type { AffectedScope } from './affected';
@@ -98,7 +100,7 @@ function readOnlyType(positionals: readonly string[]): TestType | undefined {
98
100
  flag: 'type',
99
101
  command: 'test',
100
102
  reason: `takes at most one test type, got ${positionals.length}: ${positionals.join(' ')}`,
101
- fix: `x test ${type} --filter ${quoteArg(second)}`,
103
+ fix: `x test ${quoteArg(type)} --filter ${quoteArg(second)}`,
102
104
  });
103
105
  }
104
106
 
@@ -119,7 +121,10 @@ async function readAffectedScope(ctx: CommandContext): Promise<AffectedScope | u
119
121
  flag: idle,
120
122
  command: 'test',
121
123
  reason: 'only narrows a run together with --affected, and on its own it changes nothing',
122
- fix: `x test --affected --${idle}${idle === 'base' ? ` ${DEFAULT_BASE}` : ''}`,
124
+ fix:
125
+ idle === 'base'
126
+ ? `x test --affected --base ${quoteArg(DEFAULT_BASE)}`
127
+ : 'x test --affected --dirty',
123
128
  });
124
129
  }
125
130
  return undefined;
@@ -1,6 +1,7 @@
1
- // `x db backfill`, everything except the argv: the ledger `--list` reports, the declared-minus-
2
- // completed diff `--pending` reports, and the gate-plus-enqueue `<name>`/`--all` performs. A
3
- // driver plus plain strings in, plain data out — the `cmd-jobs.ts` / `jobs-report.ts` split
1
+ // `x db backfill`, everything except the argv: the ledger `--list` reports, the pending diff
2
+ // `--pending` reports, and the gate-plus-enqueue `<name>`/`--all` performs.
3
+ //
4
+ // A driver plus plain strings in, plain data out — the `cmd-jobs.ts` / `jobs-report.ts` split
4
5
  // repeated, so every projection here is testable with no `ParsedArgs`, no app boot and no queue.
5
6
  // `cmd-db.ts` is the CLI wiring and nothing else.
6
7
  //
package/src/db-branch.ts CHANGED
@@ -3,8 +3,8 @@
3
3
  // Plain inputs, plain rows — no `ParsedArgs`, no `CommandResult` — so every rule here is testable
4
4
  // against a temp directory and a recording client, and `cmd-db-branch.ts` owns only the wiring.
5
5
 
6
- // `node:fs/promises` for `readdir`/`rm`/`stat` — Bun exposes no directory listing, no recursive
7
- // delete and no birthtime. `node:path` for the joiner Bun also does not have.
6
+ // why: `node:fs/promises` for `readdir`/`rm`/`stat` — Bun exposes no directory listing, no
7
+ // recursive delete and no birthtime. `node:path` for the joiner Bun also does not have.
8
8
  import { readdir, rm, stat } from 'node:fs/promises';
9
9
  import { basename, dirname, join } from 'node:path';
10
10
  import type { DbClient } from '@ultimat3/db';
@@ -2,7 +2,7 @@
2
2
  // migration files already declare, written as one reversible `.sql` plus the two sidecars the gate
3
3
  // reads back — the snapshot the next generation diffs against, and the schema hash `drift` checks.
4
4
 
5
- // `node:path` — Bun ships no path joiner of its own, and these paths are built, not opened.
5
+ // why: `node:path` — Bun ships no path joiner of its own, and these paths are built, not opened.
6
6
  import { join } from 'node:path';
7
7
  import type { GeneratedMigration, UnrenderedDeclaration } from '@ultimat3/db';
8
8
  import {
@@ -1,8 +1,9 @@
1
1
  // The schema dump, regenerated on behalf of a command: `x db gen` and `x db migrate` both end by
2
- // making `packages/db/schema/` equal to what the migrations produce. Split from
3
- // `db-schema-dump.ts`, which replays and writes; this decides what a command REPORTS when the dump
4
- // was written, was already right, was not owed, or could not be produced — and holds the two
5
- // findings that are about the dump as a whole rather than about one file in it.
2
+ // making `packages/db/schema/` equal to what the migrations produce.
3
+ //
4
+ // Split from `db-schema-dump.ts`, which replays and writes; this decides what a command REPORTS
5
+ // when the dump was written, was already right, was not owed, or could not be produced — and holds
6
+ // the two findings that are about the dump as a whole rather than about one file in it.
6
7
 
7
8
  import { ERROR_DOCS_URL, renderThrowable } from '@ultimat3/core';
8
9
  import type { Migration } from '@ultimat3/db';
package/src/db-seed.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  // The decisions a seed itself owns are `@ultimat3/entity`'s: `seedTiersFor` is the one table saying
6
6
  // which tiers an environment runs, and two copies of "may this seed run" would be two answers.
7
7
 
8
- // `node:path` for the joiner and the app-root-relative spelling every finding is keyed by; Bun
8
+ // why: `node:path` for the joiner and the app-root-relative spelling every finding is keyed by; Bun
9
9
  // exposes neither.
10
10
  import { relative, sep } from 'node:path';
11
11
  import type { Environment } from '@ultimat3/core';
@@ -16,6 +16,7 @@ import { BadFlagError } from './errors';
16
16
  import type { Finding, JsonValue } from './output';
17
17
  import { findingFrom } from './output';
18
18
  import { hasPathSegment } from './path-segments';
19
+ import { quoteArg } from './shell-quote';
19
20
  import { isTest } from './source-files';
20
21
  import { renderTable } from './table';
21
22
 
@@ -74,7 +75,7 @@ export class SeedEnvironmentError extends UltimateError {
74
75
  super({
75
76
  code: 'X_SEED_ENVIRONMENT',
76
77
  cause: `seed "${input.seed}" is tier ${input.tier} and ULTIMATE_ENV resolved ${input.environment}, where x db seed runs ${input.tiers.join(', ')} — ULTIMATE_SEED_TIER=${input.tier} says this deploy takes it anyway`,
77
- fix: `x db seed ${input.seed} --tier ${input.tier} --json`,
78
+ fix: `x db seed ${quoteArg(input.seed)} --tier ${quoteArg(input.tier)} --json`,
78
79
  });
79
80
  }
80
81
  }
@@ -1,9 +1,10 @@
1
- // A supervised `x dev` child that outlives what it serves stops itself. Two facts nothing else in
2
- // the child watched: its SUPERVISOR is gone (SIGKILLed, so it forwarded nothing — the child was
3
- // reparented to init and served forever), and its APP ROOT is gone (the jobs worker, the outbox
4
- // relay and the scheduler then poll an embedded database whose directory no longer exists, at
5
- // 100% CPU, measured at ~50 MB/s of heap growth). Found on a laptop, 2026-09-29: two children of
6
- // `cmd-dev-restart.live.test.ts`, six hours old, ppid 1, cwd deleted, one at 7 GB.
1
+ // A supervised `x dev` child that outlives what it serves stops itself.
2
+ //
3
+ // Two facts nothing else in the child watched: its SUPERVISOR is gone (SIGKILLed, so it forwarded
4
+ // nothing — the child was reparented to init and served forever), and its APP ROOT is gone (the
5
+ // jobs worker, the outbox relay and the scheduler then poll an embedded database whose directory no
6
+ // longer exists, at 100% CPU, measured at ~50 MB/s of heap growth). Found on a laptop, 2026-09-29:
7
+ // two children of `cmd-dev-restart.live.test.ts`, six hours old, ppid 1, cwd deleted, one at 7 GB.
7
8
  //
8
9
  // Both facts and the stop itself hold on Windows: the supervisor is asked for by pid
9
10
  // (`process.kill(pid, 0)`), since a Windows child's ppid never changes, and a stop arrives as a
@@ -1,8 +1,9 @@
1
- // Single responsibility: whether `x dev` must declare `ULTIMATE_ENV` for the app it is about to
2
- // boot, and the one-liner side effect that declares it. Split out of `cmd-dev.ts` (which the
3
- // filesize gate holds to ~500 lines) rather than folded into it — this is one decision with one
4
- // consumer, and keeping it separate is what lets a test pin the decision without paying for a
5
- // whole app boot.
1
+ // Whether `x dev` must declare `ULTIMATE_ENV` for the app it is about to boot, and the one-liner
2
+ // side effect that declares it.
3
+ //
4
+ // Split out of `cmd-dev.ts` (which the filesize gate holds to ~500 lines) rather than folded into
5
+ // it — this is one decision with one consumer, and keeping it separate is what lets a test pin the
6
+ // decision without paying for a whole app boot.
6
7
 
7
8
  import { ENVIRONMENT_KEY } from '@ultimat3/core';
8
9
 
package/src/dev-lock.ts CHANGED
@@ -14,6 +14,9 @@
14
14
  // The lock file is what makes the second one nameable at all: nothing else in the process can tell
15
15
  // "another dev server owns this directory" from "the database is broken".
16
16
 
17
+ // why: Bun has no hard link, rename, mkdir or unlink — and `linkSync` is the one-syscall atomic
18
+ // create-if-absent the claim rests on. Sync because `clearLock` runs from `() => void` shutdown
19
+ // callbacks. Bun ships no path API either.
17
20
  import { linkSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
18
21
  import { join } from 'node:path';
19
22
  import { stringField, UltimateError } from '@ultimat3/core';
@@ -200,8 +203,8 @@ export class DevPortInUseError extends UltimateError {
200
203
  cause: `:${input.port} is already bound by ${named}, so the web role cannot listen — on a machine running several projects this is usually another one's dev server, not a stale copy of this one`,
201
204
  fix:
202
205
  holder.pid === undefined
203
- ? `x dev --port ${input.suggestion}`
204
- : `x dev --port ${input.suggestion} # or free it, if that pid is yours: kill ${holder.pid}`,
206
+ ? `x dev --port ${quoteArg(String(input.suggestion))}`
207
+ : `x dev --port ${quoteArg(String(input.suggestion))} # or free it, if that pid is yours: kill ${holder.pid}`,
205
208
  meta: { port: input.port, ...holder },
206
209
  });
207
210
  }
@@ -1,9 +1,11 @@
1
1
  // The N+1 ledger: one count per statement shape per request, and a verdict once a shape crosses
2
- // the threshold. Counting state hangs off the request's own `Ctx` in a `WeakMap`, so it is
3
- // collected with the request and never swept. Installed by `x dev` and by nothing else — a
4
- // production process pays the one `undefined` branch `@ultimat3/db`'s seam already costs (axiom 6).
5
- // It counts and it warns once; what a verdict *means* — which code, which `fix:` — is
6
- // `statement-loop.ts`'s, so all four surfaces read one answer.
2
+ // the threshold. Installed by `x dev` and by nothing else.
3
+ //
4
+ // Counting state hangs off the request's own `Ctx` in a `WeakMap`, so it is collected with the
5
+ // request and never swept. Installed by `x dev` and by nothing else — a production process pays the
6
+ // one `undefined` branch `@ultimat3/db`'s seam already costs (axiom 6). It counts and it warns
7
+ // once; what a verdict *means* — which code, which `fix:` — is `statement-loop.ts`'s, so all four
8
+ // surfaces read one answer.
7
9
 
8
10
  import type { Ctx, StatementAttribution, DbStatementEvent as StatementEvent } from '@ultimat3/core';
9
11
  import { assert, tryUseContext } from '@ultimat3/core';