@ultimat3/cli 31.26.0 → 31.28.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 (206) hide show
  1. package/CLAUDE.md +47 -37
  2. package/README.md +19 -8
  3. package/package.json +29 -29
  4. package/src/app-manifest.ts +6 -1
  5. package/src/app-mcp.ts +17 -3
  6. package/src/cmd-cache-spec.ts +5 -2
  7. package/src/cmd-db-spec.ts +2 -3
  8. package/src/cmd-db.ts +0 -2
  9. package/src/cmd-deploy-verify-sample.ts +93 -0
  10. package/src/cmd-deploy-verify.ts +2 -41
  11. package/src/cmd-dev-spec.ts +15 -1
  12. package/src/cmd-dev.ts +31 -4
  13. package/src/cmd-doctor.ts +15 -4
  14. package/src/cmd-exercise-spec.ts +7 -1
  15. package/src/cmd-exercise.ts +22 -10
  16. package/src/cmd-generate.ts +2 -0
  17. package/src/cmd-jobs-spec.ts +3 -6
  18. package/src/cmd-jobs.ts +1 -7
  19. package/src/cmd-logs-spec.ts +2 -1
  20. package/src/cmd-logs.ts +9 -28
  21. package/src/cmd-planned.ts +11 -45
  22. package/src/cmd-profile-frames.ts +99 -0
  23. package/src/cmd-profile-spec.ts +24 -0
  24. package/src/cmd-profile.ts +164 -0
  25. package/src/cmd-repro-spec.ts +13 -1
  26. package/src/cmd-repro.ts +37 -5
  27. package/src/cmd-status-sample.ts +57 -0
  28. package/src/cmd-status-spec.ts +30 -0
  29. package/src/cmd-status.ts +108 -0
  30. package/src/cmd-token-spec.ts +5 -2
  31. package/src/cmd-token.ts +7 -3
  32. package/src/cmd-upgrade-codemods.ts +71 -0
  33. package/src/cmd-upgrade-spec.ts +19 -5
  34. package/src/cmd-upgrade.ts +91 -34
  35. package/src/codemods/agents-dev-mcp.ts +50 -0
  36. package/src/codemods/authenticator-session-refusal.ts +214 -0
  37. package/src/codemods/biome-no-default-export.ts +58 -0
  38. package/src/codemods/bunfig-island-coverage.ts +33 -0
  39. package/src/codemods/chart-dashboard.ts +73 -0
  40. package/src/codemods/ci-e2e-browser-stock.ts +75 -0
  41. package/src/codemods/ci-e2e-browser.ts +63 -0
  42. package/src/codemods/codemod.ts +58 -0
  43. package/src/codemods/define-error-leaf.ts +73 -0
  44. package/src/codemods/docs-ci-parts.ts +65 -0
  45. package/src/codemods/docs-gate-prose.ts +53 -0
  46. package/src/codemods/docs-island-rows.ts +31 -0
  47. package/src/codemods/docs-shipped-guards.ts +100 -0
  48. package/src/codemods/docs-test-services.ts +62 -0
  49. package/src/codemods/engine-diff.ts +104 -0
  50. package/src/codemods/engine-edits.ts +111 -0
  51. package/src/codemods/engine-fs.ts +95 -0
  52. package/src/codemods/engine.ts +191 -0
  53. package/src/codemods/format-edited-hook-3122.ts +28 -0
  54. package/src/codemods/format-edited-hook.ts +152 -0
  55. package/src/codemods/helm-alerts-objective.ts +105 -0
  56. package/src/codemods/helm-alerts-stock.ts +108 -0
  57. package/src/codemods/index.ts +56 -0
  58. package/src/codemods/metrics-probe-healthz.ts +47 -0
  59. package/src/codemods/pending.ts +36 -0
  60. package/src/codemods/repro-gitignore.ts +40 -0
  61. package/src/codemods/runtime-pin-lines.ts +109 -0
  62. package/src/codemods/runtime-pin.ts +116 -0
  63. package/src/codemods/solid-floor.ts +63 -0
  64. package/src/codemods/test-ports.ts +86 -0
  65. package/src/codemods/test-suites.ts +37 -0
  66. package/src/codemods/theme-toggle-mount-over.ts +70 -0
  67. package/src/codemods/vendored-guards.ts +186 -0
  68. package/src/codemods/verify-floor-skips.ts +88 -0
  69. package/src/codemods/verify-floor-steps.ts +90 -0
  70. package/src/coverage-island.ts +121 -0
  71. package/src/coverage-lcov.ts +49 -5
  72. package/src/coverage-remap.ts +146 -0
  73. package/src/db-replay-engine-prepared.ts +66 -0
  74. package/src/db-replay-engine-template.ts +156 -0
  75. package/src/db-replay-engine.ts +4 -0
  76. package/src/db-replay-scratch-reap.ts +54 -0
  77. package/src/deploy-verify-flags.ts +9 -2
  78. package/src/deploy-verify-grade.ts +10 -3
  79. package/src/dev-boot.ts +14 -1
  80. package/src/dev-dashboard-guard.ts +57 -10
  81. package/src/dev-host.ts +46 -0
  82. package/src/dev-tls-cache.ts +103 -0
  83. package/src/dev-tls-der.ts +69 -0
  84. package/src/dev-tls.ts +120 -0
  85. package/src/doctor-advisory-floors.ts +113 -0
  86. package/src/doctor-browser.ts +60 -0
  87. package/src/doctor-guards.ts +39 -86
  88. package/src/doctor-superseded.ts +67 -0
  89. package/src/error-codes-doctor.ts +12 -4
  90. package/src/error-codes-verify.ts +47 -0
  91. package/src/error-codes.ts +20 -23
  92. package/src/exercise-database.ts +47 -9
  93. package/src/exercise-push-device.ts +51 -0
  94. package/src/exercise-route-api.ts +74 -0
  95. package/src/exercise-routes.ts +14 -5
  96. package/src/exercise-services.ts +3 -1
  97. package/src/exercise-shard-flag.ts +47 -0
  98. package/src/fix-command.ts +2 -2
  99. package/src/generate-factories.ts +5 -11
  100. package/src/generate-feature-required.ts +9 -4
  101. package/src/generate-files.ts +26 -7
  102. package/src/generate-kinds.ts +5 -1
  103. package/src/guards-built-in-codes.ts +36 -0
  104. package/src/guards-built-in-refusal.ts +25 -0
  105. package/src/guards-built-in.ts +134 -0
  106. package/src/guards-materialize.ts +42 -0
  107. package/src/guards-paths.ts +37 -0
  108. package/src/guards-shipped-names.ts +38 -0
  109. package/src/guards-vendored.ts +73 -0
  110. package/src/guards.ts +105 -34
  111. package/src/index.ts +10 -0
  112. package/src/island-bundle-options.ts +48 -0
  113. package/src/island-bundle.ts +18 -46
  114. package/src/island-link.ts +5 -0
  115. package/src/island-outputs.ts +5 -0
  116. package/src/lint-findings.ts +3 -3
  117. package/src/mcp-errors-verify.ts +35 -0
  118. package/src/mcp-errors.ts +21 -20
  119. package/src/mcp-host-logs.ts +121 -0
  120. package/src/mcp-host.ts +12 -73
  121. package/src/measure-scope.ts +23 -3
  122. package/src/messages-floor.ts +19 -0
  123. package/src/messages-repro.ts +16 -2
  124. package/src/messages-status.ts +10 -0
  125. package/src/messages-upgrade.ts +15 -0
  126. package/src/messages.ts +22 -1
  127. package/src/registry.ts +4 -0
  128. package/src/repro-archive-collect.ts +161 -0
  129. package/src/repro-archive-write.ts +96 -0
  130. package/src/repro-archive.ts +161 -0
  131. package/src/repro-bundle.ts +8 -16
  132. package/src/repro-errors.ts +14 -2
  133. package/src/repro-framework.ts +53 -0
  134. package/src/repro-parse.ts +87 -0
  135. package/src/repro-redact.ts +218 -0
  136. package/src/repro-scrub.ts +257 -0
  137. package/src/role-start-types.ts +7 -0
  138. package/src/role-start.ts +4 -0
  139. package/src/serve-boot.ts +7 -1
  140. package/src/serve-env-tls.ts +57 -0
  141. package/src/solid-loader.ts +27 -10
  142. package/src/superseded-match.ts +87 -0
  143. package/src/superseded.ts +84 -0
  144. package/src/templates/bun-image.ts +48 -0
  145. package/src/templates/generate-export-rows.ts +136 -0
  146. package/src/templates/generate-import-rows.ts +186 -0
  147. package/src/templates/generate-rows-slice.ts +95 -0
  148. package/src/templates/github/ci.yml.ts +5 -1
  149. package/src/templates/guard-released-forms.ts +112 -0
  150. package/src/templates/guard-runtime-pin-test.ts +54 -0
  151. package/src/templates/guard-runtime-pin.ts +189 -0
  152. package/src/templates/scaffold-claude-agents.ts +6 -6
  153. package/src/templates/scaffold-claude-commands.ts +1 -1
  154. package/src/templates/scaffold-claude-hook.ts +18 -8
  155. package/src/templates/scaffold-claude.ts +2 -2
  156. package/src/templates/scaffold-db-package.ts +3 -0
  157. package/src/templates/scaffold-docs.ts +34 -30
  158. package/src/templates/scaffold-guards.ts +73 -39
  159. package/src/templates/scaffold-repo.ts +4 -8
  160. package/src/templates/scaffold-site.ts +4 -1
  161. package/src/templates/scaffold-suites.ts +72 -0
  162. package/src/templates/scaffold-test-services.ts +35 -10
  163. package/src/templates/scaffold-verify-floor.ts +53 -31
  164. package/src/templates/shapes/api.ts +4 -0
  165. package/src/templates/slice-foundation.ts +3 -3
  166. package/src/unthrown-codes.ts +3 -1
  167. package/src/upgrade-bun-floor.ts +4 -0
  168. package/src/upgrade-clean-tree.ts +54 -0
  169. package/src/upgrade-gate-codemods-install.ts +40 -0
  170. package/src/upgrade-gate-codemods.ts +151 -0
  171. package/src/upgrade-gate.ts +44 -7
  172. package/src/upgrade-guards-baseline.ts +43 -0
  173. package/src/upgrade-guards.ts +37 -2
  174. package/src/upgrade-lock.ts +118 -0
  175. package/src/upgrade-plan.ts +2 -1
  176. package/src/upgrade-report-codemods.ts +54 -0
  177. package/src/upgrade-report.ts +55 -27
  178. package/src/upgrade-signals.ts +91 -0
  179. package/src/upgrade-unfinished.ts +61 -0
  180. package/src/verify-coverage-run.ts +42 -11
  181. package/src/verify-e2e.ts +115 -4
  182. package/src/verify-floor.ts +27 -0
  183. package/src/verify-guard-baseline.ts +109 -0
  184. package/src/verify-live.ts +72 -0
  185. package/src/verify-merge-skips.ts +51 -0
  186. package/src/verify-merge.ts +36 -2
  187. package/src/verify-run.ts +48 -7
  188. package/src/verify-services.ts +287 -0
  189. package/src/verify-skip-reason.ts +53 -0
  190. package/src/verify-strict.ts +108 -0
  191. package/src/verify-test-command.ts +129 -0
  192. package/src/verify-tests.ts +39 -126
  193. package/types/babel-modules.d.ts +2 -0
  194. package/wiki/CLI-Reference.md +200 -27
  195. package/wiki/Caching-And-Invalidation.md +1 -1
  196. package/wiki/Entities-And-Migrations.md +1 -1
  197. package/wiki/Interface-Rules.md +17 -8
  198. package/wiki/Jobs-And-Workflows.md +3 -3
  199. package/wiki/Known-Gaps.md +5 -1
  200. package/wiki/MCP-And-AI.md +1 -1
  201. package/wiki/Observability.md +1 -0
  202. package/wiki/PWA-And-Offline.md +1 -1
  203. package/wiki/Project-Layout.md +4 -4
  204. package/wiki/Troubleshooting.md +3 -3
  205. package/wiki/Tutorial-05-Deploy-Free.md +2 -2
  206. package/wiki/Upgrading.md +8 -0
@@ -27,6 +27,23 @@ interface ScopeInput {
27
27
  readonly buildId: string;
28
28
  }
29
29
 
30
+ const originOf = (url: string | undefined): string | undefined =>
31
+ url !== undefined && URL.canParse(url) ? new URL(url).origin : undefined;
32
+
33
+ /**
34
+ * Whether `url` is the app's own: the build's origin, or the `APP_URL` its typed client posts to
35
+ * (read at the call — `withAppUrl` may set it after the scope is built). Any other host is a call
36
+ * out the page makes in production too — a CMS, a vendor API — and reaches the network: answered by
37
+ * the app's pipeline it was a 404, and the route was filed unmeasured for a fetch it never made.
38
+ */
39
+ function ownedBy(origin: string): (url: string) => boolean {
40
+ return (url) => {
41
+ const target = originOf(url);
42
+ if (target === undefined) return false;
43
+ return target === originOf(origin) || target === originOf(process.env['APP_URL'] || undefined);
44
+ };
45
+ }
46
+
30
47
  function inProcessRunner(input: ScopeInput, actor: Actor | null): <T>(fn: () => T) => T {
31
48
  // No rate limit: every request here is this build's own render, and a limiter would need a
32
49
  // deployment scope a build does not have (`X_RATE_LIMIT_SCOPE_UNSET`).
@@ -46,7 +63,9 @@ function inProcessRunner(input: ScopeInput, actor: Actor | null): <T>(fn: () =>
46
63
  const dispatch = (url: string, init: RequestInit): Promise<Response> =>
47
64
  pipeline.handle(new Request(url, init), { role: 'web' });
48
65
  const request: Ctx = ctx;
49
- return <T>(fn: () => T): T => withInProcessFetch(dispatch, () => runWithContext(request, fn));
66
+ const owns = ownedBy(input.origin);
67
+ return <T>(fn: () => T): T =>
68
+ withInProcessFetch(dispatch, () => runWithContext(request, fn), owns);
50
69
  }
51
70
 
52
71
  /** A measurement scope's input: the app at `root`, whose `runtime.ts` the build honours. */
@@ -56,8 +75,9 @@ interface MeasureInput extends ScopeInput {
56
75
 
57
76
  /**
58
77
  * The scope for `origin`. The pipeline is the app's API table and nothing else: a page's data
59
- * comes from its actions and queries, and a route the render reaches that is not one of them
60
- * answers 404 — which the render reports, and the route is filed unmeasured with that reason.
78
+ * comes from its actions and queries, and a route on the app's origin the render reaches that is
79
+ * not one of them answers 404 — which the render reports, and the route is filed unmeasured with
80
+ * that reason. Another host's url is not the app's (`ownedBy`), and reaches the network.
61
81
  * For a render that is WEIGHED and discarded only: its output is never published.
62
82
  */
63
83
  export async function measureScope(input: MeasureInput): Promise<MeasureScope> {
@@ -0,0 +1,19 @@
1
+ // The suite floor's rows of the CLI catalog (`messages.ts` composes them): why a step ran no
2
+ // check, and the strict-floor notices. Data only — `msg()` is the one lookup.
3
+
4
+ export const FLOOR_MESSAGES = {
5
+ // One line per step that ran no check (`verify-skip-reason.ts`), under the step table.
6
+ 'cli.verify.skip.line': 'skipped: {step} — {reason}',
7
+ 'cli.verify.skip.noTypedFiles': 'no *.{type}.test.ts file in this tree',
8
+ 'cli.verify.skip.noEval': 'not an app root, and no *.eval.test.ts file',
9
+ 'cli.verify.skip.noApp': 'no {file} here, so there is no app to load',
10
+ 'cli.verify.skip.noPackages': 'no workspace package under packages/',
11
+ 'cli.verify.skip.noManifest': 'no {file} committed, so there is no contract to diff',
12
+ 'cli.verify.skip.noRoadmap': 'no {file} here',
13
+ 'cli.verify.skip.nothing': 'the step found nothing to check here',
14
+ // Without `strict`, a warning and never red: an existing app meets it on `main` (X_BREAKING_ON_MAIN).
15
+ 'cli.verify.unwaived':
16
+ 'not strict: {names} ran no check here — give each a suite, or a "skip" why in x.verify.json, then set "strict": true',
17
+ // A `skip` why over a step that ran: the reason is stale, and only a commit can drop it.
18
+ 'cli.verify.waiverStale': 'x.verify.json "skip" excuses {step}, which ran here — drop its entry',
19
+ } as const;
@@ -1,5 +1,5 @@
1
- // The `x repro` rows of the CLI catalog (`messages.ts` composes them). Data only — `msg()` is the
2
- // one lookup.
1
+ // The `x repro` rows of the CLI catalog (`messages.ts` composes them), and `create-ultimate repro`'s.
2
+ // Data only — `msg()` is the one lookup.
3
3
 
4
4
  export const REPRO_MESSAGES = {
5
5
  'cli.repro.job': 'job {name} ({id}) died with {code} at step {step}',
@@ -8,4 +8,18 @@ export const REPRO_MESSAGES = {
8
8
  'cli.repro.reproduced': ' reproduced: {file} fails with {code}',
9
9
  'cli.repro.notReproduced': ' not reproduced: {file} ended in {got}',
10
10
  'cli.repro.listed': '{count} captured bundle(s)',
11
+ 'cli.repro.bundled': 'wrote the repro bundle {file}',
12
+ 'cli.repro.bundleMasked':
13
+ ' {count} field(s) masked or stood in — the bundle lists them under masked',
14
+ 'cli.repro.bundleScrubbed': ' {env} env value(s) and {hosts} hostname(s) found and replaced',
15
+ 'cli.repro.bundleReadFirst':
16
+ ' read {file} before you attach it to an issue: it is all that leaves',
17
+ 'cli.repro.opened': 'opened {code} from {bundle} into {dir}',
18
+ 'cli.repro.openedFramework':
19
+ ' @ultimat3/* linked from {framework} (the bundle was made on {versions})',
20
+ 'cli.repro.openedRegistry':
21
+ ' @ultimat3/* from the registry: pass --framework <checkout> to run on framework source',
22
+ 'cli.repro.openedStandIn':
23
+ ' stand in {name} in apps/web/api and the entities in repro/bundle.json schema, then:',
24
+ 'cli.repro.openedNext': ' cd {dir} && bun install && bun test ./{file}',
11
25
  } as const;
@@ -0,0 +1,10 @@
1
+ // The `x status` rows of the CLI catalog (`messages.ts` composes them): what the running
2
+ // deployment records about its builds, and which roles record nothing. Data only.
3
+
4
+ export const STATUS_MESSAGES = {
5
+ 'cli.status.summary': '{workers} live worker(s) read, {origins} origin(s) sampled',
6
+ 'cli.status.workers': 'workers: {count} live · builds {builds}',
7
+ 'cli.status.origin': '{origin}: {samples} sample(s) · builds {builds} · status {statuses}',
8
+ 'cli.status.unrecorded':
9
+ 'no fleet-wide record of {roles}: pass each one’s health origin to --url to read its build',
10
+ } as const;
@@ -58,4 +58,19 @@ export const UPGRADE_MESSAGES = {
58
58
  'read the section, close each finding by its fix, re-check with x verify --json, commit this hop to {to}, then re-run x upgrade --json for the next one',
59
59
  'cli.upgrade.then.walk':
60
60
  'review the diff and commit this hop to {to}, then re-run x upgrade --json to take the next one, {next}',
61
+ // `upgrade-report.ts` / `cmd-upgrade-codemods.ts`: the codemods a hop applied, and what they left.
62
+ 'cli.upgrade.codemods.done':
63
+ '{count} codemod(s) after {from} up to {to}: {changed} file(s) changed, {skipped} left for you',
64
+ 'cli.upgrade.codemods.dryRun':
65
+ '{count} codemod(s) after {from} up to {to} would change {changed} file(s) and leave {skipped} for you; nothing written',
66
+ 'cli.upgrade.codemod':
67
+ 'codemod {id} ({since}): {changed} changed, {skipped} left for you — {summary}',
68
+ 'cli.upgrade.codemod.changed': ' changed: {path}',
69
+ 'cli.upgrade.codemod.skipped': ' left for you: {path} — {reason}',
70
+ 'cli.upgrade.codemods.failed':
71
+ 'codemods not applied: the installed CLI answered {code}: {cause} — fix: {fix}',
72
+ 'cli.upgrade.codemods.fromDriver':
73
+ 'the installed CLI applies no codemods of its own, so this CLI applied its list',
74
+ // `upgrade-report.ts`: a workaround the hop's framework made unnecessary (`doctor-superseded.ts`).
75
+ 'cli.upgrade.superseded': 'superseded workaround{at}: {cause} — fix: {fix}',
61
76
  } as const;
package/src/messages.ts CHANGED
@@ -5,10 +5,12 @@
5
5
 
6
6
  import { CLIENT_MESSAGES } from './messages-client';
7
7
  import { DB_MESSAGES } from './messages-db';
8
+ import { FLOOR_MESSAGES } from './messages-floor';
8
9
  import { GATE_MESSAGES } from './messages-gate';
9
10
  import { OPS_MESSAGES } from './messages-ops';
10
11
  import { REPRO_MESSAGES } from './messages-repro';
11
12
  import { SHOT_MESSAGES } from './messages-shot';
13
+ import { STATUS_MESSAGES } from './messages-status';
12
14
  import { UPGRADE_MESSAGES } from './messages-upgrade';
13
15
 
14
16
  const CATALOG = {
@@ -73,6 +75,12 @@ const CATALOG = {
73
75
  'cli.dev.roles': ' roles {roles}',
74
76
  'cli.dev.panels': ' panels {panels}',
75
77
  'cli.dev.introspect': ' introspect {url}',
78
+ 'cli.dev.introspectUnreachable':
79
+ ' introspect none on {url} — /_x answers loopback only; x dev --host 0.0.0.0 keeps loopback bound beside it',
80
+ 'cli.dev.tls':
81
+ ' tls cert {path} — trust it once: curl --cacert {path}, or add it to the OS keychain',
82
+ 'cli.profile.done': 'profiled {route}: {runs} run(s), {samples} sample(s), status {status}',
83
+ 'cli.profile.frame': ' {percent}% {name} {at}',
76
84
  'cli.dev.manifest': ' manifest {path}',
77
85
  'cli.dev.mcp': ' mcp POST {path}',
78
86
  // `x stop` (`cmd-stop.ts`): the lock's holder, and only it.
@@ -95,7 +103,7 @@ const CATALOG = {
95
103
  'wake off, pickup within idlePollMaxMs ({ms} ms by default): a transaction pooler delivers no notification. For the wake, give this role a direct or session-pooled DATABASE_URL and unset DATABASE_POOLER',
96
104
  'cli.doctor.findings': '{count} finding(s)',
97
105
  'cli.doctor.guardsDiffer':
98
- '{count} shipped guard(s) differ from the current template — an older copy or your own edit; each line rewrites one and its test, review the diff before keeping it:',
106
+ '{count} shipped guard(s) still have a copy in guards/, which runs in place of the built-in guard and never receives a fix. Each line is the edit that resolves one:',
99
107
  // `x doctor`'s other listing: what the coverage floor in x.verify.json does not see, and why.
100
108
  'cli.doctor.coverageExclude':
101
109
  '{count} path(s) x.verify.json excludes from the coverage floor — each with the reason it gives:',
@@ -110,6 +118,10 @@ const CATALOG = {
110
118
  // `x doctor`'s warnings: beside the verdict on `main`, red on `next` (`doctor-warnings.ts`).
111
119
  'cli.doctor.warnings': '{count} warning(s) — not in the verdict until the next major:',
112
120
  'cli.doctor.warning': ' {code}: {cause} — fix: {fix}',
121
+ // `x doctor`'s browser report (`doctor-browser.ts`): the e2e driver's Chrome, or how to get one.
122
+ 'cli.doctor.browserFound': 'e2e browser: {path}',
123
+ 'cli.doctor.browserMissing':
124
+ 'e2e browser: none found, so every e2eTest skips — install one: {install}',
113
125
  'cli.docs.code': '{code} is an error code — x errors explain answers it',
114
126
  'cli.docs.exports': 'exports: {list}',
115
127
  'cli.docs.installed': 'installed: {list}',
@@ -280,6 +292,13 @@ const CATALOG = {
280
292
  'cli.secrets.dropped':
281
293
  'dropped retired master key {kid} from {path} — {count} retired key(s) still declared',
282
294
  'cli.secrets.ring': 'retired master key(s) that still open sealed values: {kids}',
295
+ // `verify-live.ts`: the `live` step's warnings about the test stack it found, started or could not.
296
+ 'cli.verify.services.started':
297
+ 'this run started {services} ({command}) — left running for the next run; stop it with {stop}',
298
+ 'cli.verify.services.unavailable': '{code}: {cause} — fix: {fix}',
299
+ // `upgrade-report.ts`: a guard the tree breaks, kept at its measured count (`upgrade-guards.ts`).
300
+ 'cli.upgrade.guardBaselined':
301
+ 'guard installed at its baseline: guards/{name}.ts reports {count} finding(s), now "guardBaseline" in x.verify.json — fix them and lower it, it only falls',
283
302
  ...CLIENT_MESSAGES,
284
303
  ...REPRO_MESSAGES,
285
304
  ...DB_MESSAGES,
@@ -287,6 +306,8 @@ const CATALOG = {
287
306
  ...UPGRADE_MESSAGES,
288
307
  ...GATE_MESSAGES,
289
308
  ...OPS_MESSAGES,
309
+ ...FLOOR_MESSAGES,
310
+ ...STATUS_MESSAGES,
290
311
  } as const;
291
312
 
292
313
  export type MessageKey = keyof typeof CATALOG;
package/src/registry.ts CHANGED
@@ -27,6 +27,7 @@ import { explainSpec } from './cmd-explain-spec';
27
27
  import { fixSpec } from './cmd-fix-spec';
28
28
  import { generateSpec } from './cmd-generate-spec';
29
29
  import { graphSpec } from './cmd-graph-spec';
30
+ import { profileSpec } from './cmd-profile-spec';
30
31
  // Registered here, not by whichever command body happens to load: `dispatch` renders a CLI code's
31
32
  // title for a refusal raised before any body is imported.
32
33
  import './error-codes';
@@ -47,6 +48,7 @@ import { reproSpec } from './cmd-repro-spec';
47
48
  import { routesSpec } from './cmd-routes-spec';
48
49
  import { secretsSpec } from './cmd-secrets-spec';
49
50
  import { shotSpec } from './cmd-shot-spec';
51
+ import { statusSpec } from './cmd-status-spec';
50
52
  import { stopSpec } from './cmd-stop-spec';
51
53
  import { tasksSpec } from './cmd-tasks-spec';
52
54
  import { testSpec } from './cmd-test-spec';
@@ -135,6 +137,8 @@ export const LAZY_COMMANDS: readonly LazyCommand[] = [
135
137
  lazy(logsSpec, async () => (await import('./cmd-logs')).logsCommand),
136
138
  lazy(cacheSpec, async () => (await import('./cmd-cache')).cacheCommand),
137
139
  lazy(explainSpec, async () => (await import('./cmd-explain')).explainCommand),
140
+ lazy(profileSpec, async () => (await import('./cmd-profile')).profileCommand),
141
+ lazy(statusSpec, async () => (await import('./cmd-status')).statusCommand),
138
142
  ];
139
143
 
140
144
  /**
@@ -0,0 +1,161 @@
1
+ // Single responsibility: the reads `x repro --bundle` makes beyond the subject — the installed
2
+ // `@ultimat3/*` versions, what the scrubber must hide (dotenv values, config hostnames, the home
3
+ // directory, the machine's name), the error's cause and stack, and the app's declarations by name.
4
+
5
+ // why: Bun exposes neither the home directory nor the machine's hostname.
6
+ import { homedir, hostname } from 'node:os';
7
+ // why: Bun exposes no path-join primitive.
8
+ import { join } from 'node:path';
9
+ import { getAction } from '@ultimat3/action';
10
+ import { postgresErrorGroupsStore } from '@ultimat3/admin/error-groups';
11
+ import { isJsonObject } from '@ultimat3/core';
12
+ import { getEntity, sealedFields } from '@ultimat3/entity';
13
+ import type { JobDriver } from '@ultimat3/jobs';
14
+ import { getJob, inspectJob } from '@ultimat3/jobs';
15
+ import { getQuery } from '@ultimat3/query';
16
+ import { appConfigExport } from './app-config-load';
17
+ import type { ReproErrorFacts } from './repro-archive';
18
+ import type { ReproSubject } from './repro-bundle';
19
+ import type { ReproLookups } from './repro-redact';
20
+ import type { ScrubSources } from './repro-scrub';
21
+ import { hostOf } from './repro-scrub';
22
+ import { parseDotenv } from './root-env';
23
+
24
+ /** Where an installed `@ultimat3/*` manifest sits: the root, a workspace, or Bun's isolated store. */
25
+ const MANIFEST_GLOBS = [
26
+ 'node_modules/@ultimat3/*/package.json',
27
+ '{apps,packages}/*/node_modules/@ultimat3/*/package.json',
28
+ 'node_modules/.bun/*/node_modules/@ultimat3/*/package.json',
29
+ ];
30
+
31
+ /** Every installed `@ultimat3/*` package and the versions found of it, names and versions sorted. */
32
+ export async function installedFramework(root: string): Promise<Record<string, string[]>> {
33
+ const found = new Map<string, Set<string>>();
34
+ for (const pattern of MANIFEST_GLOBS) {
35
+ for await (const path of new Bun.Glob(pattern).scan({ cwd: root, dot: true })) {
36
+ const parsed: unknown = await Bun.file(join(root, path))
37
+ .json()
38
+ .catch(() => undefined);
39
+ if (!isJsonObject(parsed)) continue;
40
+ const { name, version } = parsed;
41
+ if (typeof name !== 'string' || typeof version !== 'string') continue;
42
+ if (!name.startsWith('@ultimat3/')) continue;
43
+ found.set(name, (found.get(name) ?? new Set()).add(version));
44
+ }
45
+ }
46
+ return Object.fromEntries(
47
+ [...found.keys()].sort().map((name) => [name, [...(found.get(name) ?? [])].sort()]),
48
+ );
49
+ }
50
+
51
+ /** Every hostname a config value names: a URL anywhere, or a string under a host-like key. */
52
+ function configHosts(value: unknown, key: string, out: Set<string>, depth = 0): void {
53
+ if (depth > 16) return;
54
+ if (typeof value === 'string') {
55
+ const host = hostOf(value);
56
+ if (host !== undefined) out.add(host);
57
+ else if (/^(?:host|hostname|domain|origin)s?$/i.test(key) && value.trim() !== '') {
58
+ out.add(value.trim().toLowerCase());
59
+ }
60
+ return;
61
+ }
62
+ if (Array.isArray(value)) for (const entry of value) configHosts(entry, key, out, depth + 1);
63
+ else if (isJsonObject(value)) {
64
+ for (const [name, entry] of Object.entries(value)) configHosts(entry, name, out, depth + 1);
65
+ }
66
+ }
67
+
68
+ /** Every `.env*` file's values at the app root, by name; two files holding one name keep both. */
69
+ async function dotenvValues(root: string): Promise<[string, string][]> {
70
+ const files: string[] = [];
71
+ for await (const path of new Bun.Glob('.env*').scan({ cwd: root, dot: true })) files.push(path);
72
+ const out: [string, string][] = [];
73
+ for (const path of files.sort()) {
74
+ out.push(...parseDotenv(await Bun.file(join(root, path)).text()));
75
+ }
76
+ return out;
77
+ }
78
+
79
+ export async function scrubSourcesOf(
80
+ root: string,
81
+ env: Readonly<Record<string, string | undefined>>,
82
+ ): Promise<ScrubSources> {
83
+ const hosts = new Set<string>();
84
+ configHosts(await appConfigExport(root, 'config'), '', hosts);
85
+ const machine = hostname().toLowerCase();
86
+ if (machine !== '') hosts.add(machine);
87
+ const homes = [env['HOME'], env['USERPROFILE'], homedir()].filter(
88
+ (home): home is string => typeof home === 'string' && home.length > 1,
89
+ );
90
+ return {
91
+ root,
92
+ homes,
93
+ env: [
94
+ ...(await dotenvValues(root)).map(([name, value]) => ({
95
+ name,
96
+ value,
97
+ from: 'dotenv' as const,
98
+ })),
99
+ ...Object.entries(env).map(([name, value]) => ({ name, value, from: 'process' as const })),
100
+ ],
101
+ hosts: [...hosts],
102
+ };
103
+ }
104
+
105
+ /** `{ cause, stack }` beside the subject in a `--from` file (`data.error` or `error`), when there. */
106
+ export async function errorFromFile(path: string): Promise<ReproErrorFacts> {
107
+ const parsed: unknown = await Bun.file(path)
108
+ .json()
109
+ .catch(() => undefined);
110
+ const data = isJsonObject(parsed) && isJsonObject(parsed['data']) ? parsed['data'] : parsed;
111
+ const error = isJsonObject(data) ? data['error'] : undefined;
112
+ if (!isJsonObject(error)) return { cause: null, stack: null };
113
+ const text = (value: unknown): string | null => (typeof value === 'string' ? value : null);
114
+ return { cause: text(error['cause']), stack: text(error['stack']) };
115
+ }
116
+
117
+ /** The job row's last error and stack, or the error group's redacted sample for a request. */
118
+ export async function errorFromStore(
119
+ driver: JobDriver,
120
+ subject: ReproSubject,
121
+ ): Promise<ReproErrorFacts> {
122
+ if (subject.kind === 'job') {
123
+ const trace = await inspectJob(driver, subject.failure.jobId);
124
+ return { cause: trace?.lastError ?? null, stack: trace?.stack ?? null };
125
+ }
126
+ // A group store that cannot answer leaves the bundle without a stack, as `--list` leaves a count.
127
+ const group = await postgresErrorGroupsStore()
128
+ .get(subject.bundle.fingerprint)
129
+ .catch(() => undefined);
130
+ return sampleFacts(group?.sample, subject.bundle.requestId);
131
+ }
132
+
133
+ /**
134
+ * The error group's sample is its LATEST failure, not necessarily this one: its cause and stack
135
+ * are this subject's only when the sample's request is the subject's own. Otherwise, nothing.
136
+ */
137
+ export function sampleFacts(
138
+ sample:
139
+ | { readonly requestId: string | null; readonly cause: string; readonly stack: string | null }
140
+ | undefined,
141
+ requestId: string | null,
142
+ ): ReproErrorFacts {
143
+ if (sample === undefined || requestId === null || sample.requestId !== requestId) {
144
+ return { cause: null, stack: null };
145
+ }
146
+ return { cause: sample.cause, stack: sample.stack };
147
+ }
148
+
149
+ /** The registries `loadApp` filled: what the redaction asks by name. */
150
+ export const registryLookups: ReproLookups = {
151
+ inputSchema(kind, name) {
152
+ if (kind === 'job') return getJob(name)?.input;
153
+ return kind === 'action' ? getAction(name)?.input : getQuery(name)?.input;
154
+ },
155
+ entity(name) {
156
+ const entry = getEntity(name);
157
+ if (entry === undefined) return undefined;
158
+ const sealed = entry.core === undefined ? [] : sealedFields(entry.core);
159
+ return { description: entry.describe(), sealed: sealed.map((field) => field.property) };
160
+ },
161
+ };
@@ -0,0 +1,96 @@
1
+ // Single responsibility: `x repro --bundle`'s answer — redact the subject, read what the scrubber
2
+ // must hide and what the framework is, assemble the one JSON document and write it under `repro/`.
3
+ // The parts are `repro-redact.ts`, `repro-archive-collect.ts`, `repro-scrub.ts`, `repro-archive.ts`.
4
+
5
+ // why: Bun has no rename or unlink; an atomic write needs both.
6
+ import { rename, rm } from 'node:fs/promises';
7
+ // why: Bun exposes no path-join primitive.
8
+ import { join } from 'node:path';
9
+ import type { CommandContext } from './command';
10
+ import { msg } from './messages';
11
+ import type { CommandResult, JsonValue } from './output';
12
+ import type { ReproErrorFacts } from './repro-archive';
13
+ import { bundleFileOf, reproArchive } from './repro-archive';
14
+ import { installedFramework, registryLookups, scrubSourcesOf } from './repro-archive-collect';
15
+ import type { ReproSubject } from './repro-bundle';
16
+ import type { RedactOptions, ReproLookups } from './repro-redact';
17
+ import { redactSubject } from './repro-redact';
18
+ import { scrubberFor } from './repro-scrub';
19
+ import { loadVersion } from './version-loader';
20
+
21
+ /** The three file operations an atomic write needs; the system's by default, a recorder in tests. */
22
+ export interface AtomicIo {
23
+ write(path: string, text: string): Promise<void>;
24
+ rename(from: string, to: string): Promise<void>;
25
+ remove(path: string): Promise<void>;
26
+ }
27
+
28
+ const systemIo: AtomicIo = {
29
+ write: async (path, text) => {
30
+ await Bun.write(path, text);
31
+ },
32
+ rename: (from, to) => rename(from, to),
33
+ remove: (path) => rm(path, { force: true }),
34
+ };
35
+
36
+ /**
37
+ * `text` at `path` or nothing new: a temp file beside it, renamed over it (`core`'s
38
+ * `writeOwnerOnlyFile` shape). A kill mid-write leaves the temp file, never a truncated bundle.
39
+ */
40
+ export async function writeAtomically(
41
+ path: string,
42
+ text: string,
43
+ io: AtomicIo = systemIo,
44
+ ): Promise<void> {
45
+ const temp = `${path}.${crypto.randomUUID()}.tmp`;
46
+ try {
47
+ await io.write(temp, text);
48
+ await io.rename(temp, path);
49
+ } catch (error) {
50
+ await io.remove(temp);
51
+ throw error;
52
+ }
53
+ }
54
+
55
+ export async function writeBundle(
56
+ root: string,
57
+ ctx: CommandContext,
58
+ subject: ReproSubject,
59
+ error: ReproErrorFacts,
60
+ options: RedactOptions,
61
+ lookups: ReproLookups = registryLookups,
62
+ ): Promise<CommandResult> {
63
+ const redacted = redactSubject(subject, lookups, options);
64
+ const scrubber = scrubberFor(await scrubSourcesOf(root, ctx.env));
65
+ const { document, scrubbed } = reproArchive({
66
+ ...redacted,
67
+ error,
68
+ framework: {
69
+ packages: await installedFramework(root),
70
+ cli: loadVersion(),
71
+ bun: ctx.bunVersion,
72
+ platform: `${process.platform}-${process.arch}`,
73
+ },
74
+ scrubber,
75
+ });
76
+ const file = bundleFileOf(subject);
77
+ await writeAtomically(join(root, file), `${JSON.stringify(document, null, 2)}\n`);
78
+ return {
79
+ ok: true,
80
+ command: 'repro',
81
+ summary: msg('cli.repro.bundled', { file }),
82
+ lines: [
83
+ msg('cli.repro.bundleMasked', { count: redacted.masked.length }),
84
+ msg('cli.repro.bundleScrubbed', { env: scrubbed.env.length, hosts: scrubbed.hosts }),
85
+ msg('cli.repro.bundleReadFirst', { file }),
86
+ ],
87
+ data: {
88
+ kind: subject.kind,
89
+ file,
90
+ masked: [...redacted.masked],
91
+ dropped: [...redacted.dropped],
92
+ scrubbed: { env: [...scrubbed.env], hosts: scrubbed.hosts },
93
+ includeRows: options.includeRows,
94
+ } satisfies Record<string, JsonValue>,
95
+ };
96
+ }
@@ -0,0 +1,161 @@
1
+ // Single responsibility: the repro bundle's one JSON document, assembled from parts already read —
2
+ // the redacted subject, the error, the framework versions, the touched declarations and the
3
+ // reproducer test — then passed whole through the scrubber. Pure and deterministic: no clock, no
4
+ // machine fact beyond the platform, keys in a fixed order, so two runs write the same bytes.
5
+
6
+ import type { EntityDescription } from '@ultimat3/entity';
7
+ import { API_INDEX } from './app-root';
8
+ import type { ReproSubject } from './repro-bundle';
9
+ import { jobTestSource } from './repro-job';
10
+ import { requestTestSource } from './repro-request';
11
+ import type { Scrubber, ScrubReport } from './repro-scrub';
12
+ import { reproFile } from './repro-write';
13
+ import { PLACEHOLDER_DB_MODULE } from './templates/scaffold-db-client';
14
+
15
+ /** The format tag `create-ultimate repro` checks before it opens anything. */
16
+ export const BUNDLE_FORMAT = 'x-repro-bundle/1';
17
+
18
+ /** What the bundle says about itself, first — the user reads this before sending it. */
19
+ export const READ_FIRST: readonly string[] = [
20
+ 'Read this whole file before you attach it to an issue: it is everything that leaves your machine.',
21
+ 'It holds: the installed @ultimat3/* versions, the declarations of the entities the failing call read,',
22
+ 'the error code, cause and stack frames, the test that replays it (reproducer), and the failing call',
23
+ '(subject): its keys and ids as they were; every other input, row and step value a [redacted] stand-in',
24
+ 'the replay fills, the actor org a placeholder. With --include-rows those values are real: read them.',
25
+ 'Always masked: secret-named keys, .sensitive() fields, sealed columns. Replaced: the app root (.), home',
26
+ '(~), secret-named / URL / dotenv env values ([env:NAME]), config and env-URL hostnames ([host]), URL',
27
+ 'credentials and query values, emails ([email]), IP addresses ([ip]), other absolute paths (<abs>/file).',
28
+ 'NOT found: a value this machine never knew — a production-only secret, a customer name in a cause.',
29
+ 'Edit any value you still do not want to send. Opening a bundle never runs code from it.',
30
+ 'A maintainer opens it with: bunx create-ultimate repro <this file>',
31
+ ];
32
+
33
+ export interface ReproErrorFacts {
34
+ readonly cause: string | null;
35
+ readonly stack: string | null;
36
+ }
37
+
38
+ export interface FrameworkFacts {
39
+ /** Every installed `@ultimat3/*` package, each with the versions found (more than one is a finding). */
40
+ readonly packages: Readonly<Record<string, readonly string[]>>;
41
+ readonly cli: string;
42
+ readonly bun: string;
43
+ readonly platform: string;
44
+ }
45
+
46
+ export interface ReproArchiveInput {
47
+ readonly subject: ReproSubject;
48
+ readonly entities: readonly EntityDescription[];
49
+ readonly dropped: readonly string[];
50
+ readonly masked: readonly string[];
51
+ readonly error: ReproErrorFacts;
52
+ readonly framework: FrameworkFacts;
53
+ readonly scrubber: Scrubber;
54
+ }
55
+
56
+ /** The subject's own id: never the argument typed, which may be a path to a file. */
57
+ export const subjectIdOf = (subject: ReproSubject): string =>
58
+ subject.kind === 'job' ? subject.failure.jobId : (subject.bundle.requestId ?? subject.bundle.id);
59
+
60
+ /**
61
+ * Where the bundle lands in the app: beside the written repro tests, named by the WHOLE subject id
62
+ * (an id past 48 characters keeps its first and last 24). Never its first 12 alone: those are a
63
+ * UUIDv7's millisecond, so two failures of one millisecond overwrote each other. The written test's
64
+ * name (`reproFile`) is left as it is: apps commit those, and a rename would duplicate them.
65
+ */
66
+ export function bundleFileOf(subject: ReproSubject): string {
67
+ const id = subjectIdOf(subject)
68
+ .toLowerCase()
69
+ .replace(/[^a-z0-9]/g, '');
70
+ const short = id.length > 48 ? `${id.slice(0, 24)}${id.slice(-24)}` : id;
71
+ return `repro/bundle-${short || 'unnamed'}.json`;
72
+ }
73
+
74
+ /** The frames of a stack — its `at …` lines, trimmed — each through `location`. */
75
+ const framesOf = (stack: string | null, scrubber: Scrubber): string[] =>
76
+ (stack ?? '')
77
+ .split('\n')
78
+ .map((line) => line.trim())
79
+ .filter((line) => line.startsWith('at '))
80
+ .map((line) => scrubber.location(line));
81
+
82
+ /**
83
+ * The reproducer, rendered from a subject alone — never from a bundle's own `reproducer` text,
84
+ * which a stranger could have written — against the scaffold's API index and `dbPackage` (the
85
+ * placeholder in a bundle; the scratch app's own when `create-ultimate repro` opens one).
86
+ */
87
+ export function bundleReproducer(
88
+ subject: ReproSubject,
89
+ dbPackage: string = PLACEHOLDER_DB_MODULE,
90
+ ): { file: string; source: string[] } {
91
+ const id = subjectIdOf(subject);
92
+ const imports = [`../${API_INDEX.replace(/\/index\.ts$/, '')}`];
93
+ const source =
94
+ subject.kind === 'job'
95
+ ? jobTestSource(subject.failure, { id, imports })
96
+ : requestTestSource(subject.bundle, { id, imports, build: null, dbPackage });
97
+ return { file: reproFile(subject), source: source.split('\n') };
98
+ }
99
+
100
+ export interface ReproArchive {
101
+ readonly document: unknown;
102
+ readonly scrubbed: ScrubReport;
103
+ }
104
+
105
+ /**
106
+ * The fields the replay looks a primitive up by, kept OUT of the scrubber: a scrubbed `name` or
107
+ * `primitive` (a dotenv value that happens to be `createPost`) is a bundle that replays nothing,
108
+ * and none of them is data. Blanked before the scrub, put back after it.
109
+ */
110
+ function scrubbedSubject(subject: ReproSubject, scrubber: Scrubber): ReproSubject {
111
+ if (subject.kind === 'job') {
112
+ const { name, code, step, jobId } = subject.failure;
113
+ const blank = { ...subject.failure, name: '', code: null, step: null, jobId: '' };
114
+ const clean = scrubber.value(blank) as typeof blank;
115
+ return { kind: 'job', failure: { ...clean, name, code, step, jobId } };
116
+ }
117
+ const { primitive, name, code, fingerprint, id } = subject.bundle;
118
+ const blank = { ...subject.bundle, name: '', code: '', fingerprint: '', id: '' };
119
+ const clean = scrubber.value(blank) as typeof blank;
120
+ return { kind: 'request', bundle: { ...clean, primitive, name, code, fingerprint, id } };
121
+ }
122
+
123
+ export function reproArchive(input: ReproArchiveInput): ReproArchive {
124
+ const { subject, scrubber } = input;
125
+ // The subject is scrubbed BEFORE the reproducer is rendered from it, so the test's literal holds
126
+ // the same tokens the `subject` section does; the reproducer is then never scrubbed again — its
127
+ // import lines are the scratch app's, and nothing in it came from anywhere but the subject.
128
+ const clean = scrubbedSubject(subject, scrubber);
129
+ const code = clean.kind === 'job' ? clean.failure.code : clean.bundle.code;
130
+ const data = scrubber.value({
131
+ error: {
132
+ cause: input.error.cause === null ? null : scrubber.location(input.error.cause),
133
+ frames: framesOf(input.error.stack, scrubber),
134
+ },
135
+ schema: { entities: input.entities },
136
+ masked: input.masked,
137
+ dropped: input.dropped,
138
+ }) as {
139
+ error: { cause: string | null; frames: string[] };
140
+ schema: unknown;
141
+ masked: unknown;
142
+ dropped: unknown;
143
+ };
144
+ const document = {
145
+ format: BUNDLE_FORMAT,
146
+ readFirst: READ_FIRST,
147
+ kind: clean.kind,
148
+ id: subjectIdOf(clean),
149
+ code,
150
+ fingerprint: clean.kind === 'job' ? null : clean.bundle.fingerprint,
151
+ framework: input.framework,
152
+ error: { code, ...data.error },
153
+ schema: data.schema,
154
+ masked: data.masked,
155
+ dropped: data.dropped,
156
+ subject: clean.kind === 'job' ? clean.failure : clean.bundle,
157
+ reproducer: bundleReproducer(clean),
158
+ scrubbed: scrubber.report(),
159
+ };
160
+ return { document, scrubbed: scrubber.report() };
161
+ }