@ultimat3/cli 31.27.0 → 31.29.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 (134) hide show
  1. package/CLAUDE.md +4 -1
  2. package/README.md +14 -4
  3. package/package.json +29 -29
  4. package/src/app-manifest.ts +6 -1
  5. package/src/app-migrations-verdict.ts +84 -0
  6. package/src/cmd-doctor.ts +11 -3
  7. package/src/cmd-drill.ts +23 -9
  8. package/src/cmd-repro-spec.ts +13 -1
  9. package/src/cmd-repro.ts +37 -5
  10. package/src/cmd-upgrade-codemods.ts +71 -0
  11. package/src/cmd-upgrade-spec.ts +19 -5
  12. package/src/cmd-upgrade.ts +91 -34
  13. package/src/codemods/agents-dev-mcp.ts +50 -0
  14. package/src/codemods/authenticator-session-refusal.ts +214 -0
  15. package/src/codemods/biome-no-default-export.ts +58 -0
  16. package/src/codemods/bunfig-island-coverage.ts +33 -0
  17. package/src/codemods/chart-dashboard.ts +73 -0
  18. package/src/codemods/ci-e2e-browser-stock.ts +75 -0
  19. package/src/codemods/ci-e2e-browser.ts +63 -0
  20. package/src/codemods/codemod.ts +58 -0
  21. package/src/codemods/define-error-leaf.ts +73 -0
  22. package/src/codemods/docs-ci-parts.ts +65 -0
  23. package/src/codemods/docs-gate-prose.ts +53 -0
  24. package/src/codemods/docs-island-rows.ts +31 -0
  25. package/src/codemods/docs-shipped-guards.ts +100 -0
  26. package/src/codemods/docs-test-services.ts +62 -0
  27. package/src/codemods/engine-diff.ts +104 -0
  28. package/src/codemods/engine-edits.ts +111 -0
  29. package/src/codemods/engine-fs.ts +95 -0
  30. package/src/codemods/engine.ts +191 -0
  31. package/src/codemods/format-edited-hook-3122.ts +28 -0
  32. package/src/codemods/format-edited-hook.ts +152 -0
  33. package/src/codemods/helm-alerts-deploy.ts +85 -0
  34. package/src/codemods/helm-alerts-objective.ts +105 -0
  35. package/src/codemods/helm-alerts-stock.ts +108 -0
  36. package/src/codemods/index.ts +60 -0
  37. package/src/codemods/metrics-probe-healthz.ts +47 -0
  38. package/src/codemods/migrate-job-ordered.ts +81 -0
  39. package/src/codemods/migrate-job-stock.ts +41 -0
  40. package/src/codemods/pending.ts +36 -0
  41. package/src/codemods/repro-gitignore.ts +40 -0
  42. package/src/codemods/runtime-pin-lines.ts +109 -0
  43. package/src/codemods/runtime-pin.ts +116 -0
  44. package/src/codemods/solid-floor.ts +63 -0
  45. package/src/codemods/test-ports.ts +86 -0
  46. package/src/codemods/test-suites.ts +37 -0
  47. package/src/codemods/theme-toggle-mount-over.ts +70 -0
  48. package/src/codemods/vendored-guards.ts +186 -0
  49. package/src/codemods/verify-floor-skips.ts +88 -0
  50. package/src/codemods/verify-floor-steps.ts +90 -0
  51. package/src/doctor-advisory-floors.ts +113 -0
  52. package/src/doctor-guards.ts +39 -86
  53. package/src/doctor-superseded.ts +67 -0
  54. package/src/drill-schema-behind.ts +26 -0
  55. package/src/error-codes-doctor.ts +12 -4
  56. package/src/error-codes.ts +9 -0
  57. package/src/exercise-database.ts +7 -2
  58. package/src/framework-schema-apply.ts +7 -19
  59. package/src/framework-schema-stamp.ts +38 -3
  60. package/src/framework-schema-verify.ts +120 -0
  61. package/src/framework-schema-wait.ts +125 -0
  62. package/src/generate-files.ts +6 -5
  63. package/src/guards-built-in-codes.ts +36 -0
  64. package/src/guards-built-in-refusal.ts +25 -0
  65. package/src/guards-built-in.ts +134 -0
  66. package/src/guards-materialize.ts +42 -0
  67. package/src/guards-paths.ts +37 -0
  68. package/src/guards-shipped-names.ts +38 -0
  69. package/src/guards-vendored.ts +73 -0
  70. package/src/guards.ts +90 -34
  71. package/src/index.ts +10 -0
  72. package/src/lint-findings.ts +3 -3
  73. package/src/mcp-errors.ts +12 -1
  74. package/src/measure-scope.ts +23 -3
  75. package/src/messages-repro.ts +16 -2
  76. package/src/messages-upgrade.ts +15 -0
  77. package/src/messages.ts +1 -1
  78. package/src/repro-archive-collect.ts +161 -0
  79. package/src/repro-archive-write.ts +96 -0
  80. package/src/repro-archive.ts +161 -0
  81. package/src/repro-bundle.ts +8 -16
  82. package/src/repro-errors.ts +14 -2
  83. package/src/repro-framework.ts +53 -0
  84. package/src/repro-parse.ts +87 -0
  85. package/src/repro-redact.ts +218 -0
  86. package/src/repro-scrub.ts +257 -0
  87. package/src/role-pg-stats.ts +21 -0
  88. package/src/role-start.ts +4 -0
  89. package/src/runtime-queue.ts +27 -6
  90. package/src/serve-boot-probe.ts +97 -0
  91. package/src/serve-boot.ts +26 -1
  92. package/src/serve-retire.ts +16 -3
  93. package/src/superseded-match.ts +87 -0
  94. package/src/superseded.ts +84 -0
  95. package/src/templates/bun-image.ts +48 -0
  96. package/src/templates/chart-dashboard-panels.ts +178 -0
  97. package/src/templates/chart-dashboard.ts +9 -135
  98. package/src/templates/github/ci.yml.ts +1 -1
  99. package/src/templates/guard-released-forms.ts +112 -0
  100. package/src/templates/guard-runtime-pin-test.ts +54 -0
  101. package/src/templates/guard-runtime-pin.ts +189 -0
  102. package/src/templates/scaffold-claude-agents.ts +6 -6
  103. package/src/templates/scaffold-claude-commands.ts +1 -1
  104. package/src/templates/scaffold-claude-hook.ts +18 -8
  105. package/src/templates/scaffold-claude.ts +2 -2
  106. package/src/templates/scaffold-container.ts +2 -2
  107. package/src/templates/scaffold-docs.ts +26 -24
  108. package/src/templates/scaffold-guards.ts +73 -39
  109. package/src/templates/scaffold-helm-alert-deploy.ts +105 -0
  110. package/src/templates/scaffold-helm-alert-rules.ts +7 -1
  111. package/src/templates/scaffold-helm-alerts.ts +3 -0
  112. package/src/templates/scaffold-helm-migrate.ts +85 -0
  113. package/src/templates/scaffold-helm-templates.ts +2 -36
  114. package/src/templates/scaffold-helm.ts +1 -0
  115. package/src/templates/scaffold-repo.ts +2 -1
  116. package/src/unthrown-codes.ts +2 -0
  117. package/src/upgrade-bun-floor.ts +4 -0
  118. package/src/upgrade-clean-tree.ts +54 -0
  119. package/src/upgrade-gate-codemods-install.ts +40 -0
  120. package/src/upgrade-gate-codemods.ts +151 -0
  121. package/src/upgrade-gate.ts +38 -6
  122. package/src/upgrade-lock.ts +118 -0
  123. package/src/upgrade-plan.ts +2 -1
  124. package/src/upgrade-report-codemods.ts +54 -0
  125. package/src/upgrade-report.ts +52 -27
  126. package/src/upgrade-signals.ts +91 -0
  127. package/src/upgrade-unfinished.ts +61 -0
  128. package/wiki/CLI-Reference.md +70 -5
  129. package/wiki/Deployment.md +2 -1
  130. package/wiki/Interface-Rules.md +17 -8
  131. package/wiki/Known-Gaps.md +1 -1
  132. package/wiki/Observability.md +1 -0
  133. package/wiki/Project-Layout.md +4 -4
  134. package/wiki/Upgrading.md +6 -0
@@ -0,0 +1,37 @@
1
+ // Where an app's own guards are, as a leaf: the `guards/` directory and its files. Read by the gate
2
+ // (`guards.ts`), `x doctor` and the manifest's error-code projection, the last on the serving
3
+ // roles' graph — so nothing here imports a template or a runner.
4
+
5
+ // why: Bun has no synchronous stat — `statSync` answers whether `guards` is a directory.
6
+ import { statSync } from 'node:fs';
7
+ // why: Bun has no path-join primitive, and the path must carry the host's separator.
8
+ import { join } from 'node:path';
9
+
10
+ /** The directory IS the registration. An app-side list is a list an app can forget to add to. */
11
+ export const GUARD_DIR = 'guards';
12
+
13
+ /**
14
+ * Every guard file, app-root-relative and sorted, so two machines report the same findings in the
15
+ * same order. A `*.test.ts` beside a guard is its test, never a second guard — the generator emits
16
+ * one, and importing it would run the suite inside the gate.
17
+ */
18
+ export async function guardPaths(root: string): Promise<readonly string[]> {
19
+ const dir = join(root, GUARD_DIR);
20
+ // A FILE named `guards` holds no guards — never ENOTDIR out of the gate or `x doctor`; the gate
21
+ // reports it (`guardDirIsFile`), so the author's rules are not silently absent.
22
+ if (guardDirState(root) !== 'directory') return [];
23
+ const paths: string[] = [];
24
+ for await (const entry of new Bun.Glob('*.{ts,tsx}').scan({ cwd: dir, absolute: false })) {
25
+ const path = entry.split('\\').join('/');
26
+ if (/\.(?:test|d)\.tsx?$/.test(path)) continue;
27
+ paths.push(`${GUARD_DIR}/${path}`);
28
+ }
29
+ return paths.sort();
30
+ }
31
+
32
+ /** What `guards` is in this app: the directory, nothing, or something else in its place. */
33
+ export function guardDirState(root: string): 'directory' | 'absent' | 'other' {
34
+ const stat = statSync(join(root, GUARD_DIR), { throwIfNoEntry: false });
35
+ if (stat === undefined) return 'absent';
36
+ return stat.isDirectory() ? 'directory' : 'other';
37
+ }
@@ -0,0 +1,38 @@
1
+ // The names of the guards the framework ships, as a leaf: no template, no I/O. The serving roles'
2
+ // graph may hold it (`x.manifest.json` lists a built-in's code), which `templates/` never may —
3
+ // so `templates/scaffold-guards.ts` keys its `SHIPPED` table by this list, and tsc holds them equal.
4
+
5
+ export const SHIPPED_GUARD_NAMES = [
6
+ 'animated-layout-property',
7
+ 'bare-error',
8
+ 'error-declared',
9
+ 'focus-visible',
10
+ 'image-dimensions',
11
+ 'island-mount-clears',
12
+ 'island-without-states',
13
+ 'native-confirm',
14
+ 'raw-breakpoint',
15
+ 'raw-colour',
16
+ 'raw-fetch',
17
+ 'raw-interval',
18
+ 'raw-length',
19
+ 'raw-motion',
20
+ 'raw-shadow',
21
+ 'raw-z-index',
22
+ 'repo-await-in-loop',
23
+ 'repo-raw-sql',
24
+ 'repo-unbounded',
25
+ 'runtime-pin',
26
+ 'semantic-interactive',
27
+ 'unbounded-fanout',
28
+ 'undeclared-custom-property',
29
+ 'undefined-style-class',
30
+ 'untranslated-string',
31
+ 'unzoned-date',
32
+ ] as const;
33
+
34
+ export type ShippedGuardName = (typeof SHIPPED_GUARD_NAMES)[number];
35
+
36
+ /** `raw-fetch` → `X_RAW_FETCH`: `templates/guard.ts`' `guardCode` over a name already kebab. */
37
+ export const shippedGuardCode = (name: ShippedGuardName): string =>
38
+ `X_${name.toUpperCase().replaceAll('-', '_')}`;
@@ -0,0 +1,73 @@
1
+ // A copy of a shipped guard still in an app's `guards/`, judged against every form the framework
2
+ // shipped, and the one finding that names it: an unedited copy is one delete, an edited one a rename
3
+ // to the app's own guard plus a `guards/shipped.json` row, with its diff — the migration, as an edit.
4
+
5
+ import { ERROR_DOCS_URL } from '@ultimat3/core';
6
+ import { unifiedDiff } from './codemods/engine-diff';
7
+ import { SHIPPED_GUARD_CONFIG } from './guards-built-in';
8
+ import type { Finding } from './output';
9
+ import { RELEASED_GUARD_FORMS } from './templates/guard-released-forms';
10
+ import { shippedGuardForms, shippedGuardSource } from './templates/scaffold-guards';
11
+
12
+ /** A checkout on Windows may write CRLF; the rule is the same text either way. */
13
+ export const sameText = (a: string, b: string): boolean =>
14
+ a.replaceAll('\r\n', '\n') === b.replaceAll('\r\n', '\n');
15
+
16
+ /** A rule-file text's identity across checkouts: CRLF-blind, the key `RELEASED_GUARD_FORMS` holds. */
17
+ export const guardFormHash = (text: string): string =>
18
+ Bun.hash(text.replaceAll('\r\n', '\n')).toString(36);
19
+
20
+ /**
21
+ * How a form the framework shipped reports — the current template or any released before it — or
22
+ * `undefined` when `text` is no such form: the app's edit.
23
+ */
24
+ export function shippedFormSeverity(
25
+ name: string,
26
+ text: string,
27
+ released: Readonly<
28
+ Record<string, readonly (readonly [string, 'error' | 'warning'])[]>
29
+ > = RELEASED_GUARD_FORMS,
30
+ ): 'error' | 'warning' | undefined {
31
+ const current = shippedGuardForms(name).find((form) => sameText(text, form.source));
32
+ if (current !== undefined) return current.severity;
33
+ const hash = guardFormHash(text);
34
+ return (Object.hasOwn(released, name) ? released[name] : undefined)?.find(
35
+ ([known]) => known === hash,
36
+ )?.[1];
37
+ }
38
+
39
+ export interface VendoredCopy {
40
+ readonly name: string;
41
+ /** App-root-relative: `guards/<name>.ts` or `.tsx`. */
42
+ readonly path: string;
43
+ /** A form the framework shipped, current or released (`shippedFormSeverity`): nobody edited it. */
44
+ readonly identical: boolean;
45
+ /** The shipped guard → this copy, unified; absent when identical. */
46
+ readonly diff?: string;
47
+ }
48
+
49
+ /** The copy at `path`, judged against every current form of the shipped guard `name`. */
50
+ export function vendoredCopy(name: string, path: string, source: string): VendoredCopy {
51
+ if (shippedFormSeverity(name, source) !== undefined) return { name, path, identical: true };
52
+ const shipped = shippedGuardSource(name) ?? '';
53
+ return { name, path, identical: false, diff: unifiedDiff(path, shipped, source) };
54
+ }
55
+
56
+ /** The edit that resolves a copy — what the `vendored-guards` codemod would have done to it. */
57
+ export function resolvingEdit({ name, path, identical }: VendoredCopy): string {
58
+ const test = `guards/${name}.test.ts`;
59
+ if (identical) return `rm -f ${path} ${test} && x verify --only boundaries --json`;
60
+ const kept = path.replace(`guards/${name}.`, `guards/app-${name}.`);
61
+ return `mv ${path} ${kept} && x verify --only boundaries --json # then "${name}": "off" in ${SHIPPED_GUARD_CONFIG} and ${test}'s import to ./app-${name} — or rm ${path} to take the shipped rule (the diff is x doctor --json's data.guards.differs)`;
62
+ }
63
+
64
+ /** One warning per copy: a copy runs in place of the installed guard and never receives a fix. */
65
+ export const vendoredFinding = (copy: VendoredCopy): Finding => ({
66
+ code: 'X_GUARD_VENDORED',
67
+ cause: copy.identical
68
+ ? `${copy.path} is an unedited copy of the shipped ${copy.name} guard, which the framework now runs built in: the copy runs in its place, so a fix to it never reaches this app`
69
+ : `${copy.path} is an edited copy of the shipped ${copy.name} guard: it runs in place of the one the framework now runs built in, so a fix to it never reaches this app, and your edit is not yet your own guard`,
70
+ fix: resolvingEdit(copy),
71
+ docs: ERROR_DOCS_URL,
72
+ at: copy.path,
73
+ });
package/src/guards.ts CHANGED
@@ -1,24 +1,39 @@
1
1
  // An app's own convention, made into a build error (axiom 3). A file in `guards/` exports one
2
- // `guard`; the gate discovers the directory and runs each one inside the `boundaries` step. The
3
- // framework decides what a guard IS — a function returning findings, held to the error contract —
4
- // and nothing about what a guard may check.
5
-
6
- // Bun ships no equivalent for either: `existsSync` answers whether this app has a guards
7
- // directory, `join` builds the host-separator path, and `pathToFileURL` is the only spelling of an
8
- // absolute path `import()` accepts on every host.
9
- import { existsSync } from 'node:fs';
2
+ // `guard`; the gate discovers the directory and runs each one inside the `boundaries` step, beside
3
+ // every guard the framework ships (`guards-built-in.ts`). The framework decides what a guard IS —
4
+ // a function returning findings, held to the error contract — and nothing about what it checks.
5
+
6
+ // Bun ships no equivalent for either: `join` builds the host-separator path, and `pathToFileURL` is
7
+ // the only spelling of an absolute path `import()` accepts on every host.
10
8
  import { join } from 'node:path';
11
9
  import { pathToFileURL } from 'node:url';
12
10
  import { ERROR_DOCS_URL, renderCauseValue, renderThrowable } from '@ultimat3/core';
13
11
  import { fixProblem } from './error-contract';
14
12
  import { type GuardSources, guardSources } from './guard-sources';
13
+ import {
14
+ type BuiltInMode,
15
+ planBuiltIns,
16
+ readShippedConfig,
17
+ shippedConfigFindings,
18
+ vendoredPath,
19
+ } from './guards-built-in';
20
+ import { materializeGuard } from './guards-materialize';
21
+ import { GUARD_DIR, guardDirState, guardPaths } from './guards-paths';
22
+
23
+ /** The app's guard directory and its files, defined in the leaf the manifest projection reads. */
24
+ export { GUARD_DIR, guardPaths } from './guards-paths';
25
+
26
+ import { vendoredCopy, vendoredFinding } from './guards-vendored';
15
27
  import type { Finding } from './output';
16
28
  import { readVerifyFloor } from './verify-floor';
17
29
  import type { GuardBaseline } from './verify-guard-baseline';
18
- import { judgeGuardBaseline, orphanedBaselineFindings } from './verify-guard-baseline';
30
+ import { guardNameOf, judgeGuardBaseline, orphanedBaselineFindings } from './verify-guard-baseline';
19
31
 
20
- /** The directory IS the registration. An app-side list is a list an app can forget to add to. */
21
- export const GUARD_DIR = 'guards';
32
+ const compareNames = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);
33
+
34
+ /** A built-in sorts where its copy in `guards/` would have: the order an app always saw. */
35
+ const sortKey = (run: GuardRun): string =>
36
+ run.mode === undefined ? run.path : `${GUARD_DIR}/${guardNameOf(run.path)}.ts`;
22
37
 
23
38
  export interface Guard {
24
39
  /** What this app refuses, in one line. It names the rule when the guard itself is the problem. */
@@ -100,23 +115,6 @@ function findingOf(value: Record<string, unknown>, at: string): Finding {
100
115
  };
101
116
  }
102
117
 
103
- /**
104
- * Every guard file, app-root-relative and sorted, so two machines report the same findings in the
105
- * same order. A `*.test.ts` beside a guard is its test, never a second guard — the generator emits
106
- * one, and importing it would run the suite inside the gate.
107
- */
108
- export async function guardPaths(root: string): Promise<readonly string[]> {
109
- const dir = join(root, GUARD_DIR);
110
- if (!existsSync(dir)) return [];
111
- const paths: string[] = [];
112
- for await (const entry of new Bun.Glob('*.{ts,tsx}').scan({ cwd: dir, absolute: false })) {
113
- const path = entry.split('\\').join('/');
114
- if (/\.(?:test|d)\.tsx?$/.test(path)) continue;
115
- paths.push(`${GUARD_DIR}/${path}`);
116
- }
117
- return paths.sort();
118
- }
119
-
120
118
  const failed = (path: string, cause: string): Finding => ({
121
119
  code: 'X_GUARD_FAILED',
122
120
  cause,
@@ -149,6 +147,15 @@ const notAGuard = (path: string, exported: unknown): Finding => {
149
147
  );
150
148
  };
151
149
 
150
+ /** A file where `guards/` belongs: no crash, and not silence — the app's own rules are not running. */
151
+ const notADirectory: Finding = {
152
+ code: 'X_GUARD_INVALID',
153
+ cause: `${GUARD_DIR} is not a directory, so none of this app's own guards can run beside the shipped ones`,
154
+ fix: `mv ${GUARD_DIR} ${GUARD_DIR}.txt && mkdir ${GUARD_DIR} && x verify --only boundaries --json # ${GUARD_DIR}/ is the directory the gate discovers; a rule of yours goes in it as ${GUARD_DIR}/<name>.ts`,
155
+ docs: ERROR_DOCS_URL,
156
+ at: GUARD_DIR,
157
+ };
158
+
152
159
  const findingInvalid = (path: string, cause: string): Finding => ({
153
160
  code: 'X_GUARD_FINDING_INVALID',
154
161
  cause: `${path} returned a finding that is not one: ${cause}`,
@@ -169,16 +176,39 @@ export interface GuardReport {
169
176
 
170
177
  const refused = (finding: Finding): GuardReport => ({ findings: [finding], warnings: [] });
171
178
 
179
+ /** A guard to run: what findings name it by, and the module that holds it. */
180
+ interface GuardRun {
181
+ /** App-root-relative for the app's own; `@ultimat3/cli/guards/<name>.ts` for a built-in. */
182
+ readonly path: string;
183
+ /** The absolute module path `import()` reads; for a built-in, under `.x/cache/guards/`. */
184
+ readonly file: string;
185
+ /** A built-in's mode (`guards-built-in.ts`); absent for the app's own guard. */
186
+ readonly mode?: BuiltInMode;
187
+ }
188
+
172
189
  /** One guard: import it, run it, and hold what it returns to the contract. Never throws. */
173
190
  async function runGuard(
174
191
  root: string,
175
- path: string,
192
+ run: GuardRun,
193
+ sources: GuardSources,
194
+ baseline: GuardBaseline | undefined,
195
+ ): Promise<GuardReport> {
196
+ const report = await runGuardModule(root, run, sources, baseline);
197
+ // A legacy app never had this built-in gate it: everything it says is a warning on `main`.
198
+ return run.mode === 'legacy'
199
+ ? { findings: [], warnings: [...report.findings, ...report.warnings] }
200
+ : report;
201
+ }
202
+
203
+ async function runGuardModule(
204
+ root: string,
205
+ { path, file, mode }: GuardRun,
176
206
  sources: GuardSources,
177
207
  baseline: GuardBaseline | undefined,
178
208
  ): Promise<GuardReport> {
179
209
  let loaded: unknown;
180
210
  try {
181
- loaded = await import(pathToFileURL(join(root, path)).href);
211
+ loaded = await import(pathToFileURL(file).href);
182
212
  } catch (error) {
183
213
  return refused(failed(path, `${path} could not be imported: ${messageOf(error)}`));
184
214
  }
@@ -209,7 +239,9 @@ async function runGuard(
209
239
  broken.push(findingInvalid(path, `it could not be read: ${messageOf(error)}`));
210
240
  }
211
241
  }
212
- if (exported.severity === 'warning') return { findings: broken, warnings: held };
242
+ // The app's row (`guards/shipped.json`) over a built-in's own severity, either way.
243
+ const reportOnly = mode === 'warning' || (mode !== 'error' && exported.severity === 'warning');
244
+ if (reportOnly) return { findings: broken, warnings: held };
213
245
  // A gating guard under its `guardBaseline` (`verify-guard-baseline.ts`): a broken finding is
214
246
  // never counted against it — the contract fails either way.
215
247
  const judged = judgeGuardBaseline(path, held, baseline);
@@ -235,12 +267,36 @@ export const guardReport = async (
235
267
  // judges the same committed counts, and a floor problem is the `manifest` step's to report.
236
268
  const baseline = (await readVerifyFloor(root))?.guardBaseline;
237
269
  const paths = await guardPaths(root);
238
- for (const path of paths) {
239
- const report = await runGuard(root, path, sources, baseline);
270
+ const config = await readShippedConfig(root);
271
+ const { builtIn, vendored } = planBuiltIns(paths, config.severity);
272
+ const runs: GuardRun[] = paths.map((path) => ({ path, file: join(root, path) }));
273
+ for (const guard of builtIn) {
274
+ runs.push({
275
+ path: guard.display,
276
+ file: await materializeGuard(root, guard.name),
277
+ mode: guard.mode,
278
+ });
279
+ }
280
+ // By guard name, so an app holding every shipped copy reports in the order it always did.
281
+ runs.sort((a, b) => compareNames(sortKey(a), sortKey(b)));
282
+ for (const run of runs) {
283
+ const report = await runGuard(root, run, sources, baseline);
240
284
  findings.push(...report.findings);
241
285
  warnings.push(...report.warnings);
242
286
  }
243
- findings.push(...orphanedBaselineFindings(paths, baseline));
287
+ findings.push(...shippedConfigFindings(config.problems));
288
+ if (guardDirState(root) === 'other') findings.push(notADirectory);
289
+ findings.push(
290
+ ...orphanedBaselineFindings(
291
+ runs.map((run) => run.path),
292
+ baseline,
293
+ ),
294
+ );
295
+ for (const name of vendored) {
296
+ const path = vendoredPath(paths, name) ?? `${GUARD_DIR}/${name}.ts`;
297
+ const source = await Bun.file(join(root, path)).text();
298
+ warnings.push(vendoredFinding(vendoredCopy(name, path, source)));
299
+ }
244
300
  return { findings, warnings };
245
301
  };
246
302
 
package/src/index.ts CHANGED
@@ -112,6 +112,15 @@ export { DEFAULT_ORIGIN, isPrerenderable, prerenderSite } from './prerender';
112
112
  export type { PwaArtifacts } from './pwa-artifacts';
113
113
  export { loadPwaArtifacts } from './pwa-artifacts';
114
114
  export { cliVersion, SPECS } from './registry';
115
+ // What `create-ultimate repro` opens a bundle with, so the opener restates none of it.
116
+ export { BUNDLE_FORMAT, bundleReproducer } from './repro-archive';
117
+ export { ReproBundleInvalidError } from './repro-errors';
118
+ export {
119
+ frameworkCheckoutFrom,
120
+ frameworkOverrides,
121
+ isFrameworkCheckout,
122
+ } from './repro-framework';
123
+ export { parseReproSubject } from './repro-parse';
115
124
  export type { RunningRoles, WebBinding } from './role-start';
116
125
  export { DEV_BINDING, DEV_ROLES, startRoles } from './role-start';
117
126
  // `shotCommand`, `prCommand` and `ciCommand` are deliberately NOT re-exported here. They reach
@@ -153,6 +162,7 @@ export { writeSiteSeo } from './site-seo-write';
153
162
  export { eachSourceFile, isGenerated, isTest, SOURCE_GLOBS } from './source-files';
154
163
  export type { SkippedRoute, StaticReport } from './static-report';
155
164
  export { parseStaticReport } from './static-report';
165
+ export { PLACEHOLDER_DB_MODULE } from './templates/scaffold-db-client';
156
166
  export type { MigratedDatabaseOptions } from './test-database';
157
167
  export { migratedDatabase } from './test-database';
158
168
  export { filesIn, testArgs } from './test-shards';
@@ -64,7 +64,7 @@ const editFinding = (diagnostic: Diagnostic): Finding => {
64
64
  return {
65
65
  code: 'X_LINT_FAILED',
66
66
  cause: `${place} ${category}: ${message}`,
67
- fix: `bunx biome check ${quoteArg(path)} # ${category}: edit ${commentSafe(place)}, ${commentSafe(message)}`,
67
+ fix: `bunx @biomejs/biome check ${quoteArg(path)} # ${category}: edit ${commentSafe(place)}, ${commentSafe(message)}`,
68
68
  docs: ERROR_DOCS_URL,
69
69
  at: path,
70
70
  };
@@ -78,7 +78,7 @@ const writeFinding = (diagnostics: readonly Diagnostic[]): Finding => {
78
78
  code: 'X_LINT_FAILED',
79
79
  cause: places.join('; '),
80
80
  // Each path through `quoteArg`, joined after: one command, every file one argument.
81
- fix: ['bunx biome check --write', ...paths.map(quoteArg)].join(' '),
81
+ fix: ['bunx @biomejs/biome check --write', ...paths.map(quoteArg)].join(' '),
82
82
  docs: ERROR_DOCS_URL,
83
83
  ...(paths.length === 1 ? { at: paths[0] } : {}),
84
84
  };
@@ -119,7 +119,7 @@ export function lintOutcome(result: ExecResult): StepOutcome {
119
119
  {
120
120
  code: 'X_LINT_FAILED',
121
121
  cause: 'biome exited red and reported no diagnostic to read',
122
- fix: 'bunx biome check .',
122
+ fix: 'bunx @biomejs/biome check .',
123
123
  docs: ERROR_DOCS_URL,
124
124
  },
125
125
  ],
package/src/mcp-errors.ts CHANGED
@@ -79,7 +79,7 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
79
79
  X_CLI_UNEXPECTED: 'x doctor --json',
80
80
  // `-p .`: an app root has no `references`, so the gate's own step runs this form (#450).
81
81
  X_TYPECHECK_FAILED: 'bunx tsc -p . --pretty false',
82
- X_LINT_FAILED: 'bunx biome check .',
82
+ X_LINT_FAILED: 'bunx @biomejs/biome check .',
83
83
  X_TEST_FAILED: 'x test --json # the finding carries the exact bun test invocation that failed',
84
84
  X_FILE_TOO_LONG: 'x verify --json # the finding names the file to split',
85
85
  X_PACKAGE_SHAPE: 'bun run verify --json # every finding carries its own new-package.ts command',
@@ -393,6 +393,17 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
393
393
  X_PROFILE_ROUTE_FAILED: 'x routes --json',
394
394
  X_ROWS_SLICE_ENTITY:
395
395
  'x help g --json # then generate a job with the name and feature the finding names, and declare exportRows/importRows in it over the table that entity.ts declares',
396
+ X_SUPERSEDED_WORKAROUND:
397
+ 'x doctor --json # each finding names the file, the release that retired the workaround and its replacement',
398
+ X_GUARD_VENDORED: 'x upgrade --json',
399
+ X_GUARD_BUILT_IN:
400
+ 'x verify --only boundaries --json # set its severity in guards/shipped.json, or generate an app guard under another name',
401
+ X_REPRO_BUNDLE_INVALID:
402
+ 'x repro --json # lists the failing jobs and error groups; then run it again with one id and --bundle, and attach the file it writes',
403
+ X_ADVISORY_FLOOR_UNMET: 'bun update source-map-js immutable',
404
+ X_UPGRADE_CODEMODS_PENDING: 'x upgrade --json',
405
+ X_UPGRADE_LOCKED: 'cat .x/upgrade.lock',
406
+ X_APP_MIGRATIONS_UNAPPLIED: 'x db migrate --json',
396
407
  };
397
408
 
398
409
  const isCliCode = (code: string): code is CliErrorCode =>
@@ -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> {
@@ -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;
@@ -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
@@ -103,7 +103,7 @@ const CATALOG = {
103
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',
104
104
  'cli.doctor.findings': '{count} finding(s)',
105
105
  'cli.doctor.guardsDiffer':
106
- '{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:',
107
107
  // `x doctor`'s other listing: what the coverage floor in x.verify.json does not see, and why.
108
108
  'cli.doctor.coverageExclude':
109
109
  '{count} path(s) x.verify.json excludes from the coverage floor — each with the reason it gives:',