@ultimat3/cli 31.27.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 (107) hide show
  1. package/CLAUDE.md +3 -1
  2. package/README.md +14 -4
  3. package/package.json +29 -29
  4. package/src/app-manifest.ts +6 -1
  5. package/src/cmd-doctor.ts +11 -3
  6. package/src/cmd-repro-spec.ts +13 -1
  7. package/src/cmd-repro.ts +37 -5
  8. package/src/cmd-upgrade-codemods.ts +71 -0
  9. package/src/cmd-upgrade-spec.ts +19 -5
  10. package/src/cmd-upgrade.ts +91 -34
  11. package/src/codemods/agents-dev-mcp.ts +50 -0
  12. package/src/codemods/authenticator-session-refusal.ts +214 -0
  13. package/src/codemods/biome-no-default-export.ts +58 -0
  14. package/src/codemods/bunfig-island-coverage.ts +33 -0
  15. package/src/codemods/chart-dashboard.ts +73 -0
  16. package/src/codemods/ci-e2e-browser-stock.ts +75 -0
  17. package/src/codemods/ci-e2e-browser.ts +63 -0
  18. package/src/codemods/codemod.ts +58 -0
  19. package/src/codemods/define-error-leaf.ts +73 -0
  20. package/src/codemods/docs-ci-parts.ts +65 -0
  21. package/src/codemods/docs-gate-prose.ts +53 -0
  22. package/src/codemods/docs-island-rows.ts +31 -0
  23. package/src/codemods/docs-shipped-guards.ts +100 -0
  24. package/src/codemods/docs-test-services.ts +62 -0
  25. package/src/codemods/engine-diff.ts +104 -0
  26. package/src/codemods/engine-edits.ts +111 -0
  27. package/src/codemods/engine-fs.ts +95 -0
  28. package/src/codemods/engine.ts +191 -0
  29. package/src/codemods/format-edited-hook-3122.ts +28 -0
  30. package/src/codemods/format-edited-hook.ts +152 -0
  31. package/src/codemods/helm-alerts-objective.ts +105 -0
  32. package/src/codemods/helm-alerts-stock.ts +108 -0
  33. package/src/codemods/index.ts +56 -0
  34. package/src/codemods/metrics-probe-healthz.ts +47 -0
  35. package/src/codemods/pending.ts +36 -0
  36. package/src/codemods/repro-gitignore.ts +40 -0
  37. package/src/codemods/runtime-pin-lines.ts +109 -0
  38. package/src/codemods/runtime-pin.ts +116 -0
  39. package/src/codemods/solid-floor.ts +63 -0
  40. package/src/codemods/test-ports.ts +86 -0
  41. package/src/codemods/test-suites.ts +37 -0
  42. package/src/codemods/theme-toggle-mount-over.ts +70 -0
  43. package/src/codemods/vendored-guards.ts +186 -0
  44. package/src/codemods/verify-floor-skips.ts +88 -0
  45. package/src/codemods/verify-floor-steps.ts +90 -0
  46. package/src/doctor-advisory-floors.ts +113 -0
  47. package/src/doctor-guards.ts +39 -86
  48. package/src/doctor-superseded.ts +67 -0
  49. package/src/error-codes-doctor.ts +12 -4
  50. package/src/error-codes.ts +6 -0
  51. package/src/exercise-database.ts +7 -2
  52. package/src/generate-files.ts +6 -5
  53. package/src/guards-built-in-codes.ts +36 -0
  54. package/src/guards-built-in-refusal.ts +25 -0
  55. package/src/guards-built-in.ts +134 -0
  56. package/src/guards-materialize.ts +42 -0
  57. package/src/guards-paths.ts +37 -0
  58. package/src/guards-shipped-names.ts +38 -0
  59. package/src/guards-vendored.ts +73 -0
  60. package/src/guards.ts +90 -34
  61. package/src/index.ts +10 -0
  62. package/src/lint-findings.ts +3 -3
  63. package/src/mcp-errors.ts +11 -1
  64. package/src/measure-scope.ts +23 -3
  65. package/src/messages-repro.ts +16 -2
  66. package/src/messages-upgrade.ts +15 -0
  67. package/src/messages.ts +1 -1
  68. package/src/repro-archive-collect.ts +161 -0
  69. package/src/repro-archive-write.ts +96 -0
  70. package/src/repro-archive.ts +161 -0
  71. package/src/repro-bundle.ts +8 -16
  72. package/src/repro-errors.ts +14 -2
  73. package/src/repro-framework.ts +53 -0
  74. package/src/repro-parse.ts +87 -0
  75. package/src/repro-redact.ts +218 -0
  76. package/src/repro-scrub.ts +257 -0
  77. package/src/superseded-match.ts +87 -0
  78. package/src/superseded.ts +84 -0
  79. package/src/templates/bun-image.ts +48 -0
  80. package/src/templates/github/ci.yml.ts +1 -1
  81. package/src/templates/guard-released-forms.ts +112 -0
  82. package/src/templates/guard-runtime-pin-test.ts +54 -0
  83. package/src/templates/guard-runtime-pin.ts +189 -0
  84. package/src/templates/scaffold-claude-agents.ts +6 -6
  85. package/src/templates/scaffold-claude-commands.ts +1 -1
  86. package/src/templates/scaffold-claude-hook.ts +18 -8
  87. package/src/templates/scaffold-claude.ts +2 -2
  88. package/src/templates/scaffold-docs.ts +26 -24
  89. package/src/templates/scaffold-guards.ts +73 -39
  90. package/src/templates/scaffold-repo.ts +2 -1
  91. package/src/unthrown-codes.ts +2 -0
  92. package/src/upgrade-bun-floor.ts +4 -0
  93. package/src/upgrade-clean-tree.ts +54 -0
  94. package/src/upgrade-gate-codemods-install.ts +40 -0
  95. package/src/upgrade-gate-codemods.ts +151 -0
  96. package/src/upgrade-gate.ts +38 -6
  97. package/src/upgrade-lock.ts +118 -0
  98. package/src/upgrade-plan.ts +2 -1
  99. package/src/upgrade-report-codemods.ts +54 -0
  100. package/src/upgrade-report.ts +52 -27
  101. package/src/upgrade-signals.ts +91 -0
  102. package/src/upgrade-unfinished.ts +61 -0
  103. package/wiki/CLI-Reference.md +58 -4
  104. package/wiki/Interface-Rules.md +17 -8
  105. package/wiki/Observability.md +1 -0
  106. package/wiki/Project-Layout.md +4 -4
  107. package/wiki/Upgrading.md +5 -0
package/CLAUDE.md CHANGED
@@ -63,7 +63,8 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
63
63
  | `app-boundaries.ts` (workspaces) | `@<scope>/<app>/<rest>` resolves onto `apps/<app>/<rest>` when that is an app source, so the surface rules hold across app workspaces |
64
64
  | `app-transport.ts` / `browser-{transport,import-chain,barrel-cut}.ts` / `transport-{calls,values}.ts` / `binding-names.ts` / `import-closure.ts` / `server-barrels.ts` | `boundaries`, built in: one browser transport; a server barrel below an island is cut at its first hop † |
65
65
  | `guards.ts` / `guard-sources.ts` | an app's `guards/*.ts`, run on `boundaries`; ONE shared walk (`GuardSources`) † |
66
- | `templates/scaffold-guards.ts` | `SHIPPED`, the one list of shipped guards (`x new`, `x g guard`, `doctor-guards.ts`) † |
66
+ | `guards-built-in.ts` / `guards-built-in-refusal.ts` | shipped guards run from the installed CLI, never a copy; `guards/shipped.json` is the opt-in and the severities; `x g guard <shipped>` is `X_GUARD_BUILT_IN` |
67
+ | `templates/scaffold-guards.ts` | `SHIPPED`, the one list of shipped guards (`guards-built-in.ts`, `doctor-guards.ts`, `codemods/vendored-guards.ts`) † |
67
68
  | `error-contract.ts` / `ts-scan.ts` / `fix-scan.ts` / `fix-imports.ts` / `fix-command.ts` / `fix-path.ts` | the `errors` step: every `fix:` names a runnable command, call or existing file † |
68
69
  | `fix-sequence.ts` | `errors`: a deferring, re-run-only or `--force` fix is `X_ERROR_FIX_INVALID`, ratcheted per file † |
69
70
  | `workspace-checks.ts` / `test-only-shipped.ts` / `workspace-graph.ts` / `tsconfig-references.ts` / `publish-closure.ts` | `package-shape`, `filesize` ‡ |
@@ -195,6 +196,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
195
196
  | `cmd-docs.ts` / `docs-sources.ts` / `docs-section.ts` | `x docs`: the app's and the CLI's `@ultimat3` docs; `Page#anchor` prints a section † |
196
197
  | `cmd-env-init.ts` / `env-production.ts` / `cmd-deploy-preflight.ts` | the one writer of `.env.production`; compose pre-flight (`X_DEPLOY_ENV_MISSING`) † |
197
198
  | `cmd-upgrade.ts` / `upgrade-*.ts` | `x upgrade`: one major per run; no `requiresApp` † |
199
+ | `codemods/` / `cmd-upgrade-codemods.ts` / `upgrade-gate-codemods.ts` | a template change an app keeps, carried by a codemod (`codemod.ts`, the ONE list `codemods/index.ts`); the hop's installed CLI applies them before its gate; `scripts/template-codemods.ts` refuses a template change with none |
198
200
  | `cmd-deploy-verify.ts` / `deploy-verify-*.ts` / `cmd-status*.ts` | `x deploy verify`: the wait, the verdict, lazy sources † · `x status` |
199
201
 
200
202
  ## Adding a command
package/README.md CHANGED
@@ -43,6 +43,7 @@ Commands and the `x verify` step count, `As of 2026-08`:
43
43
  | `x i18n check\|add\|sync` | catalogs: gaps, a new locale, key sync | all three of i18n's own error fixes name it |
44
44
  | `x errors explain <CODE>` / `list` | the error table, programmatically | refuses an unregistered code instead of inventing one |
45
45
  | `x repro <id> [--write] [--verify]` / `--list` / `--from` | a dead job or a captured 5xx as a red test in `repro/` | `--verify` answers `{ reproduced, code, fingerprint }`; a mismatch is `X_REPRO_NOT_REPRODUCED`, never a crash |
46
+ | `x repro <id> --bundle` | the failure as one redacted `repro/bundle-<id>.json` for an issue | secrets masked, env values / hostnames / paths replaced; `bunx create-ultimate repro <file>` opens it |
46
47
  | `x docs "<question>"` | the framework docs and the wiki, offline | answered from the installed packages and the `wiki/` this tarball ships (`prepack`: `scripts/pack-cli-wiki.ts`), never the network; `x docs Upgrading#<anchor>` prints one whole section |
47
48
  | `x graph [--from a --to b]` / `x impact <file\|primitive\|entity>` | the app as one typed graph (`@ultimat3/manifest`'s `buildGraph` over the loaded app, its module graph and `.x/exercise.json`) · what an edit reaches | every edge `declared`, `import` or `observed`; a miss is `X_GRAPH_NODE_UNKNOWN` with the nearest three; `x affected` in an app root adds `data.tests` by import closure ([details](../../wiki/CLI-Reference.md#x-graph--x-impact)) |
48
49
  | `x client vendor <name>` / `x client customer --out <dir>` | one OpenAPI compiler (`openapi-compile.ts`), two emitters: a vendor's document into `apps/web/clients/<name>/` (`outbound()` + `t`), or the app's published document into a client with no framework import | every generated file is stamped with its source and body hash; `drift` raises `X_CLIENT_STALE` / `X_CLIENT_EDITED` ([flags](../../wiki/CLI-Reference.md#x-client)) |
@@ -180,10 +181,17 @@ is held to the same error contract shipped source is (`X_GUARD_INVALID`, `X_GUAR
180
181
  `X_GUARD_FINDING_INVALID`). A guard that exports `severity: 'warning'` is **report-only** (`As of
181
182
  31.22`): its findings ride the step as `warnings` — in `--json` and on the step line, never a
182
183
  failure — so a rule ships to every app before the apps are clean of it; a finding that breaks the
183
- contract fails either way. `repo-await-in-loop` and `repo-unbounded` ship that way. `x g guard
184
- <name>` scaffolds one with its test — the shipped guard of that name where there is one (`x new`
185
- writes all twenty-five), the blank template otherwise — and `x doctor` warns of each shipped one an
186
- app does not hold (`X_SHIPPED_GUARD_MISSING`, beside the verdict, never in it).
184
+ contract fails either way. `repo-await-in-loop` ships that way. `x g guard <name>` scaffolds the
185
+ app's own with its test.
186
+
187
+ The twenty-six shipped guards (`SHIPPED_GUARD_NAMES`) run **built in**, from the installed CLI,
188
+ never from a copy (`guards-built-in.ts`, `As of 2026-11`): `x new` writes only
189
+ `guards/shipped.json`, `{ "severity": { "<guard>": "error" | "warning" | "off" } }`, and its
190
+ presence is the opt-in. Absent (a legacy app), a shipped guard the app holds a copy of runs that
191
+ copy and one it does not reports only; a copy is one `X_GUARD_VENDORED` warning, on `boundaries`
192
+ and in `x doctor`, fix `x upgrade` — whose `vendored-guards` codemod deletes each identical copy and
193
+ keeps an edit as a row or as `guards/app-<name>.ts`. A built-in is held by `guardBaseline` under
194
+ its name like any guard.
187
195
 
188
196
  ## Layout
189
197
 
@@ -200,6 +208,8 @@ app does not hold (`X_SHIPPED_GUARD_MISSING`, beside the verdict, never in it).
200
208
  | `generate-kinds.ts` | which generators exist, and how a command line names one |
201
209
  | `guards.ts` | the app's own conventions: `guards/` discovered, run, and held to the error contract |
202
210
  | `guard-sources.ts` | one walk, one read and one Sass compile per file per gate run, shared by every guard |
211
+ | `guards-built-in.ts` | the shipped guards, run from the installed CLI: `guards/shipped.json`, the plan, the module under `.x/cache/guards/` |
212
+ | `codemods/vendored-guards.ts` | `x upgrade`'s migration off vendored copies: identical deleted, an edit kept as config or an app guard |
203
213
  | `cmd-*.ts` | one command group each |
204
214
  | `templates/` | scaffolding as typed string modules, not copied fixtures |
205
215
  | `app-load.ts` | import an app's modules so the framework registries hold it |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/cli",
3
- "version": "31.27.0",
3
+ "version": "31.28.0",
4
4
  "description": "The `x` binary: new, dev, build, verify, generate, db, mcp, doctor, deploy",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -53,34 +53,34 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@babel/core": "^8.0.9",
56
- "@ultimat3/action": "31.27.0",
57
- "@ultimat3/admin": "31.27.0",
58
- "@ultimat3/ai": "31.27.0",
59
- "@ultimat3/auth": "31.27.0",
60
- "@ultimat3/cache": "31.27.0",
61
- "@ultimat3/core": "31.27.0",
62
- "@ultimat3/db": "31.27.0",
63
- "@ultimat3/entity": "31.27.0",
64
- "@ultimat3/flags": "31.27.0",
65
- "@ultimat3/http": "31.27.0",
66
- "@ultimat3/i18n": "31.27.0",
67
- "@ultimat3/jobs": "31.27.0",
68
- "@ultimat3/mail": "31.27.0",
69
- "@ultimat3/manifest": "31.27.0",
70
- "@ultimat3/mcp": "31.27.0",
71
- "@ultimat3/money": "31.27.0",
72
- "@ultimat3/notify": "31.27.0",
73
- "@ultimat3/policy": "31.27.0",
74
- "@ultimat3/pwa": "31.27.0",
75
- "@ultimat3/query": "31.27.0",
76
- "@ultimat3/realtime": "31.27.0",
77
- "@ultimat3/render": "31.27.0",
78
- "@ultimat3/schema": "31.27.0",
79
- "@ultimat3/scraping": "31.27.0",
80
- "@ultimat3/seo": "31.27.0",
81
- "@ultimat3/storage": "31.27.0",
82
- "@ultimat3/testing": "31.27.0",
83
- "@ultimat3/time": "31.27.0",
56
+ "@ultimat3/action": "31.28.0",
57
+ "@ultimat3/admin": "31.28.0",
58
+ "@ultimat3/ai": "31.28.0",
59
+ "@ultimat3/auth": "31.28.0",
60
+ "@ultimat3/cache": "31.28.0",
61
+ "@ultimat3/core": "31.28.0",
62
+ "@ultimat3/db": "31.28.0",
63
+ "@ultimat3/entity": "31.28.0",
64
+ "@ultimat3/flags": "31.28.0",
65
+ "@ultimat3/http": "31.28.0",
66
+ "@ultimat3/i18n": "31.28.0",
67
+ "@ultimat3/jobs": "31.28.0",
68
+ "@ultimat3/mail": "31.28.0",
69
+ "@ultimat3/manifest": "31.28.0",
70
+ "@ultimat3/mcp": "31.28.0",
71
+ "@ultimat3/money": "31.28.0",
72
+ "@ultimat3/notify": "31.28.0",
73
+ "@ultimat3/policy": "31.28.0",
74
+ "@ultimat3/pwa": "31.28.0",
75
+ "@ultimat3/query": "31.28.0",
76
+ "@ultimat3/realtime": "31.28.0",
77
+ "@ultimat3/render": "31.28.0",
78
+ "@ultimat3/schema": "31.28.0",
79
+ "@ultimat3/scraping": "31.28.0",
80
+ "@ultimat3/seo": "31.28.0",
81
+ "@ultimat3/storage": "31.28.0",
82
+ "@ultimat3/testing": "31.28.0",
83
+ "@ultimat3/time": "31.28.0",
84
84
  "babel-preset-solid": "^1.9.16"
85
85
  }
86
86
  }
@@ -44,6 +44,9 @@ const RUNTIME_JOBS: Readonly<Record<string, unknown>> = { sendMailJob };
44
44
  /** Load the app, then describe it. Every command that needs facts goes through here. */
45
45
  export async function appManifest(root: string): Promise<AppManifest> {
46
46
  const loaded = await loadApp(root);
47
+ // At its point of use: every serving role evaluates this module, and the guard projection is
48
+ // facts for the file, never a boot dependency (`serve-graph.test.ts`' ceilings).
49
+ const { builtInGuardCodes, withBuiltInGuardCodes } = await import('./guards-built-in-codes');
47
50
  // Through the registrar `defineApi` uses (`define-api.ts`): the declared name wins, and the
48
51
  // same handle seated twice is one registration, so a second build of one tree is unchanged.
49
52
  primitiveRegistrar('job')(RUNTIME_JOBS);
@@ -57,7 +60,9 @@ export async function appManifest(root: string): Promise<AppManifest> {
57
60
  // imported every app module, so each `defineCatalogs()` has run and registered its locales.
58
61
  // Counting catalog files instead would be a second answer, wrong the day the two disagree.
59
62
  locales: registeredLocales(),
60
- errorCodes: loaded.errorCodes,
63
+ // The shipped guards this app runs built in raise codes its gate emits, as a vendored copy's
64
+ // did: listed, so moving the guard into the framework removes no code from the contract.
65
+ errorCodes: withBuiltInGuardCodes(loaded.errorCodes, await builtInGuardCodes(root)),
61
66
  }),
62
67
  );
63
68
  return { manifest, findings: loaded.findings };
package/src/cmd-doctor.ts CHANGED
@@ -5,14 +5,16 @@
5
5
  import { ENV_EXAMPLE_PATH, ERROR_DOCS_URL } from '@ultimat3/core';
6
6
  import { REQUIRED_BUN, versionAtLeast } from './app-root';
7
7
  import { doctorSpec } from './cmd-doctor-spec';
8
+ import { pendingCodemodFindings } from './codemods/pending';
8
9
  import type { CliCommand, CommandContext } from './command';
10
+ import { advisoryFloorFindings } from './doctor-advisory-floors';
9
11
  import { appUrlFindings } from './doctor-app-url';
10
12
  import { authStorageFindings } from './doctor-auth';
11
13
  import { browserProbe, browserWarnings, withBrowserReport } from './doctor-browser';
12
14
  import { chartAlertsProbe, NOTHING_MISSING, withChartAlertsListing } from './doctor-chart-alerts';
13
15
  import { coverageExcludesProbe, withCoverageExcludes } from './doctor-coverage';
14
16
  import { embeddedDatabaseFinding } from './doctor-database';
15
- import { missingGuardWarnings, shippedGuardsProbe, withGuardListing } from './doctor-guards';
17
+ import { shippedGuardsProbe, vendoredGuardWarnings, withGuardListing } from './doctor-guards';
16
18
  import { offlineFallbackFinding } from './doctor-offline';
17
19
  import { NO_POOLER_FACT, poolerFindings, withPoolerReport } from './doctor-pooler';
18
20
  import { doctorPort, portFindings } from './doctor-port';
@@ -21,11 +23,13 @@ import { probeFor } from './doctor-probe';
21
23
  import { redundantIndexesProbe, withRedundantIndexes } from './doctor-redundant-indexes';
22
24
  import { rollingSinceProbe, withRollingReminder } from './doctor-rolling';
23
25
  import { sealedKeyFindings } from './doctor-sealed';
26
+ import { supersededFindings } from './doctor-superseded';
24
27
  import { typescriptFindings } from './doctor-typescript';
25
28
  import { doctorWarnings, withDoctorWarnings } from './doctor-warnings';
26
29
  import { ICON_SOURCE } from './icon-assets';
27
30
  import { msg } from './messages';
28
31
  import type { CommandResult, Finding } from './output';
32
+ import { cliVersion } from './registry';
29
33
  import { quoteArg } from './shell-quote';
30
34
 
31
35
  // `src/index.ts` publishes the seam from here; its declaration lives in `doctor-probe.ts`.
@@ -184,12 +188,16 @@ export async function reportDoctor(probe: DoctorProbe): Promise<CommandResult> {
184
188
  pooler,
185
189
  );
186
190
  // Last, and beside the verdict on `main`: the 31.16.0 checks (`doctor-warnings.ts`).
187
- // A missing shipped guard among them (`X_SHIPPED_GUARD_MISSING`): a warning, so exit stays.
191
+ // A copy of a shipped guard among them (`X_GUARD_VENDORED`): a warning, so exit stays.
188
192
  const browser = await browserProbe(probe.root);
189
193
  return withDoctorWarnings(withBrowserReport(reminded, browser), [
190
194
  ...(await doctorWarnings(probe)),
191
- ...missingGuardWarnings(guardEntries),
195
+ ...vendoredGuardWarnings(guardEntries),
192
196
  ...browserWarnings(browser),
197
+ ...(probe.root === undefined ? [] : await supersededFindings(probe.root)),
198
+ ...(probe.root === undefined ? [] : await advisoryFloorFindings(probe.root)),
199
+ // An `x upgrade` driven by a CLI older than the codemod engine left files it owed.
200
+ ...(probe.root === undefined ? [] : await pendingCodemodFindings(probe.root, cliVersion())),
193
201
  ]);
194
202
  }
195
203
 
@@ -7,7 +7,7 @@ export const reproSpec: CommandSpec = {
7
7
  name: 'repro',
8
8
  summary: 'a dead job or a captured 5xx, as a failing test: x repro <id> --write --verify',
9
9
  usage:
10
- 'x repro <jobId|requestId|traceId|fingerprint> [--write] [--verify] | x repro --list [--code X_…] | x repro --from <file> [--write] [--verify] [--json]',
10
+ 'x repro <jobId|requestId|traceId|fingerprint> [--write] [--verify] | x repro <id> --bundle [--include-rows] | x repro --list [--code X_…] | x repro --from <file> [--write] [--verify] [--bundle [--include-rows]] [--json]',
11
11
  requiresApp: true,
12
12
  flags: [
13
13
  {
@@ -20,6 +20,18 @@ export const reproSpec: CommandSpec = {
20
20
  type: 'boolean',
21
21
  summary: 'run the written test and answer { reproduced, code, fingerprint }',
22
22
  },
23
+ {
24
+ name: 'bundle',
25
+ type: 'boolean',
26
+ summary:
27
+ 'write repro/bundle-<id>.json: the redacted failure, versions, schema and test, for an issue',
28
+ },
29
+ {
30
+ name: 'include-rows',
31
+ type: 'boolean',
32
+ summary:
33
+ 'bundle: real values for non-key input, row and step fields (default: stand-ins); secrets stay masked',
34
+ },
23
35
  { name: 'list', type: 'boolean', summary: 'the captured bundles, newest first' },
24
36
  { name: 'code', type: 'string', summary: 'list: only bundles of this X_* code' },
25
37
  {
package/src/cmd-repro.ts CHANGED
@@ -1,21 +1,24 @@
1
1
  // `x repro <id>` — a production failure becomes a failing test. A dead job (its row, its steps) or
2
2
  // a captured 5xx (`x_failures`, when `failureCapture` is on) is read, `--write` puts the replay in
3
- // `repro/`, and `--verify` runs it: `{ reproduced, code, fingerprint }`. `--list` shows what is held.
4
- // CLI wiring only: the reads are `repro-bundle.ts`, the sources `repro-job.ts`/`repro-request.ts`.
3
+ // `repro/`, `--verify` runs it, `--list` shows what is held, `--bundle` writes the redacted archive
4
+ // an issue carries. CLI wiring only: reads `repro-bundle.ts`, archive `repro-archive-write.ts`.
5
5
 
6
6
  import { postgresErrorGroupsStore } from '@ultimat3/admin/error-groups';
7
+ import { renderFixShellArg } from '@ultimat3/core';
7
8
  import { postgresFailureStore } from '@ultimat3/db';
8
9
  import { loadAppConfig } from './app-config-load';
9
10
  import { loadApp } from './app-load';
10
11
  import { requireAppRoot } from './app-root';
11
12
  import { reproSpec } from './cmd-repro-spec';
12
13
  import type { CliCommand, CommandContext } from './command';
13
- import { MissingPositionalError } from './errors';
14
+ import { BadFlagError, MissingPositionalError } from './errors';
14
15
  import { withJobDriver } from './jobs-driver';
15
16
  import { msg } from './messages';
16
17
  import type { CommandResult, JsonValue } from './output';
17
18
  import { findingFrom } from './output';
18
19
  import { flagBool, flagString } from './parse';
20
+ import { errorFromFile, errorFromStore } from './repro-archive-collect';
21
+ import { writeBundle } from './repro-archive-write';
19
22
  import type { ReproSubject } from './repro-bundle';
20
23
  import { resolveSubject, subjectFromFile } from './repro-bundle';
21
24
  import { ReproNotReproducedError } from './repro-errors';
@@ -162,13 +165,42 @@ export const reproCommand: CliCommand = {
162
165
  example: 'x repro --list --json',
163
166
  });
164
167
  }
168
+ const bundle = flagBool(ctx.args, 'bundle');
169
+ const includeRows = flagBool(ctx.args, 'include-rows');
170
+ if (includeRows && !bundle) {
171
+ throw new BadFlagError({
172
+ flag: 'include-rows',
173
+ command: 'repro',
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`,
176
+ });
177
+ }
178
+ if (bundle && (flagBool(ctx.args, 'write') || flagBool(ctx.args, 'verify'))) {
179
+ throw new BadFlagError({
180
+ flag: 'bundle',
181
+ command: 'repro',
182
+ 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`,
184
+ });
185
+ }
165
186
  // The app's declarations are what mask a job's input and what a written test replays against.
166
187
  await loadApp(root);
167
- if (from !== undefined) return answer(root, ctx, id ?? from, await subjectFromFile(from));
188
+ if (from !== undefined) {
189
+ const subject = await subjectFromFile(from);
190
+ if (bundle) {
191
+ return writeBundle(root, ctx, subject, await errorFromFile(from), { includeRows });
192
+ }
193
+ return answer(root, ctx, id ?? from, subject);
194
+ }
168
195
  const captureOn = (await loadAppConfig(root))?.failureCapture.enabled === true;
169
196
  return withJobDriver(root, ctx, async (driver) => {
170
197
  if (id === undefined) return list(ctx);
171
- return answer(root, ctx, id, await resolveSubject(driver, id, captureOn));
198
+ const subject = await resolveSubject(driver, id, captureOn);
199
+ if (bundle) {
200
+ const error = await errorFromStore(driver, subject);
201
+ return writeBundle(root, ctx, subject, error, { includeRows });
202
+ }
203
+ return answer(root, ctx, id, subject);
172
204
  });
173
205
  },
174
206
  };
@@ -0,0 +1,71 @@
1
+ // `x upgrade codemods`: this CLI's codemods whose version lies after `--from`, up to `--to` (its own
2
+ // version by default), over the app. A hop runs it as the CLI it just installed, so the codemods
3
+ // are the target release's; by hand it carries an app whose hop ran under a CLI with none.
4
+
5
+ import { requireAppRoot } from './app-root';
6
+ import { CODEMODS } from './codemods';
7
+ import { runCodemods } from './codemods/engine';
8
+ import { fsCodemodApp } from './codemods/engine-fs';
9
+ import type { CommandContext } from './command';
10
+ import { ok } from './command';
11
+ import { BadFlagError } from './errors';
12
+ import { msg } from './messages';
13
+ import type { CommandResult, JsonValue } from './output';
14
+ import { flagBool, flagString } from './parse';
15
+ import { cliVersion } from './registry';
16
+ import { manifestSnapshot, reinstallIfMoved } from './upgrade-gate-codemods-install';
17
+ import { releaseOf } from './upgrade-plan';
18
+ import { codemodCounts, codemodLines } from './upgrade-report-codemods';
19
+
20
+ const FIX =
21
+ 'x upgrade codemods --from 31.20.0 --dry-run --json # --from: the version the app came from, its old @ultimat3/cli pin';
22
+
23
+ const release = (ctx: CommandContext, flag: 'from' | 'to'): string | undefined => {
24
+ const value = flagString(ctx.args, flag);
25
+ if (value === undefined || releaseOf(value) !== undefined) return value;
26
+ throw new BadFlagError({
27
+ flag,
28
+ command: 'upgrade codemods',
29
+ reason: `"${value}" is not an exact release, major.minor.patch`,
30
+ fix: FIX,
31
+ });
32
+ };
33
+
34
+ export async function runUpgradeCodemods(ctx: CommandContext): Promise<CommandResult> {
35
+ const root = requireAppRoot('upgrade codemods', ctx.cwd).dir;
36
+ const from = release(ctx, 'from');
37
+ if (from === undefined) {
38
+ throw new BadFlagError({
39
+ flag: 'from',
40
+ command: 'upgrade codemods',
41
+ reason:
42
+ 'names no release, and the codemods to run are the ones after the version the app came from',
43
+ fix: FIX,
44
+ });
45
+ }
46
+ const to = release(ctx, 'to') ?? cliVersion();
47
+ const dryRun = flagBool(ctx.args, 'dry-run');
48
+ const before = await manifestSnapshot(root);
49
+ const ran = await runCodemods({
50
+ app: fsCodemodApp(root),
51
+ codemods: CODEMODS,
52
+ from,
53
+ to,
54
+ dryRun,
55
+ });
56
+ // A codemod that moved a package.json owes the install, by hand as on a hop.
57
+ const report =
58
+ !dryRun && (await reinstallIfMoved({ runner: ctx.runner, root, to, before }))
59
+ ? { ...ran, reinstalled: true as const }
60
+ : ran;
61
+ const counts = codemodCounts(report);
62
+ return ok(
63
+ 'upgrade',
64
+ msg(dryRun ? 'cli.upgrade.codemods.dryRun' : 'cli.upgrade.codemods.done', {
65
+ from,
66
+ to,
67
+ ...counts,
68
+ }),
69
+ { data: { codemods: report as unknown as JsonValue }, lines: codemodLines(report) },
70
+ );
71
+ }
@@ -3,24 +3,38 @@
3
3
 
4
4
  import type { CommandSpec } from './parse';
5
5
 
6
+ /** `run` is the hop (a bare `x upgrade`); `codemods` applies the installed release's codemods. */
7
+ export const UPGRADE_SUBCOMMANDS = ['run', 'codemods'] as const;
8
+
6
9
  export const upgradeSpec: CommandSpec = {
7
10
  name: 'upgrade',
8
11
  summary:
9
- 'move every @ultimat3/* one major in lockstep, raise the Bun floor, install, gate — and name the section to read',
10
- usage: 'x upgrade [--to <version>] [--dry-run] [--json]',
12
+ 'move every @ultimat3/* one major in lockstep, raise the Bun floor, install, apply codemods, gate — and name the section to read',
13
+ usage:
14
+ 'x upgrade [--to <version>] [--dry-run] [--json] · x upgrade codemods --from <version> [--to <version>] [--dry-run] [--json]',
11
15
  // The one command a repository with pins and no `app.config.ts` can still use: `upgrade-root.ts`
12
- // finds its root, and its report says which check it could run.
16
+ // finds its root, and its report says which check it could run. `codemods` needs the app.
17
+ subcommands: UPGRADE_SUBCOMMANDS,
18
+ defaultSubcommand: 'run',
13
19
  flags: [
14
20
  {
15
21
  name: 'to',
16
22
  type: 'string',
17
23
  summary:
18
- 'an exact release inside the next major; over a mixed set, inside the lowest pins’ next major, and only those pins move (default: the next major’s newest)',
24
+ 'an exact release inside the next major; over a mixed set, inside the lowest pins’ next major, and only those pins move (default: the next major’s newest). With codemods: the last release whose codemods run (default: this CLI’s own)',
25
+ },
26
+ {
27
+ name: 'from',
28
+ type: 'string',
29
+ subcommands: ['codemods'],
30
+ summary:
31
+ 'the release the app came from: the codemods whose version lies after it, up to --to, run',
19
32
  },
20
33
  {
21
34
  name: 'dry-run',
22
35
  type: 'boolean',
23
- summary: 'report the pins, the Bun floor edits and the section; write nothing, run no gate',
36
+ summary:
37
+ 'report the pins, the Bun floor edits, the codemods and the section; write nothing, run no gate',
24
38
  },
25
39
  ],
26
40
  };