@ultimat3/cli 31.1.0 → 31.2.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.
package/CLAUDE.md CHANGED
@@ -55,7 +55,7 @@ Commands: `bun test ./packages/cli/` (repo root: the preload),
55
55
  | `verify-factories.ts` | `unit` lints `<app>/packages/db/factories.ts` (`X_TEST_FACTORY_INVALID`) |
56
56
  | `boundary-findings.ts` / `app-boundaries.ts` / `boundary-cuts.ts` / `package-boundaries.ts` | surface + layer rules, `X_BOUNDARY_PACKAGE_TO_APP`; a `fix:` is the concrete cut † |
57
57
  | `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 |
58
- | `app-transport.ts` / `browser-transport.ts` / `transport-calls.ts` / `import-closure.ts` / `server-barrels.ts` | `boundaries`, built in: one browser transport; never a `guards/` file † |
58
+ | `app-transport.ts` / `browser-transport.ts` / `transport-calls.ts` / `transport-values.ts` / `binding-names.ts` / `import-closure.ts` / `server-barrels.ts` | `boundaries`, built in: one browser transport; never a `guards/` file † |
59
59
  | `guards.ts` / `guard-sources.ts` | an app's `guards/*.ts`, run on `boundaries`; ONE shared walk (`GuardSources`) † |
60
60
  | `templates/scaffold-guards.ts` | `SHIPPED`, the one list of shipped guards (`x new`, `x g guard`, `doctor-guards.ts`) † |
61
61
  | `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 |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/cli",
3
- "version": "31.1.0",
3
+ "version": "31.2.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.1.0",
57
- "@ultimat3/admin": "31.1.0",
58
- "@ultimat3/ai": "31.1.0",
59
- "@ultimat3/auth": "31.1.0",
60
- "@ultimat3/cache": "31.1.0",
61
- "@ultimat3/core": "31.1.0",
62
- "@ultimat3/db": "31.1.0",
63
- "@ultimat3/entity": "31.1.0",
64
- "@ultimat3/flags": "31.1.0",
65
- "@ultimat3/http": "31.1.0",
66
- "@ultimat3/i18n": "31.1.0",
67
- "@ultimat3/jobs": "31.1.0",
68
- "@ultimat3/mail": "31.1.0",
69
- "@ultimat3/manifest": "31.1.0",
70
- "@ultimat3/mcp": "31.1.0",
71
- "@ultimat3/money": "31.1.0",
72
- "@ultimat3/notify": "31.1.0",
73
- "@ultimat3/policy": "31.1.0",
74
- "@ultimat3/pwa": "31.1.0",
75
- "@ultimat3/query": "31.1.0",
76
- "@ultimat3/realtime": "31.1.0",
77
- "@ultimat3/render": "31.1.0",
78
- "@ultimat3/schema": "31.1.0",
79
- "@ultimat3/scraping": "31.1.0",
80
- "@ultimat3/seo": "31.1.0",
81
- "@ultimat3/storage": "31.1.0",
82
- "@ultimat3/testing": "31.1.0",
83
- "@ultimat3/time": "31.1.0",
56
+ "@ultimat3/action": "31.2.0",
57
+ "@ultimat3/admin": "31.2.0",
58
+ "@ultimat3/ai": "31.2.0",
59
+ "@ultimat3/auth": "31.2.0",
60
+ "@ultimat3/cache": "31.2.0",
61
+ "@ultimat3/core": "31.2.0",
62
+ "@ultimat3/db": "31.2.0",
63
+ "@ultimat3/entity": "31.2.0",
64
+ "@ultimat3/flags": "31.2.0",
65
+ "@ultimat3/http": "31.2.0",
66
+ "@ultimat3/i18n": "31.2.0",
67
+ "@ultimat3/jobs": "31.2.0",
68
+ "@ultimat3/mail": "31.2.0",
69
+ "@ultimat3/manifest": "31.2.0",
70
+ "@ultimat3/mcp": "31.2.0",
71
+ "@ultimat3/money": "31.2.0",
72
+ "@ultimat3/notify": "31.2.0",
73
+ "@ultimat3/policy": "31.2.0",
74
+ "@ultimat3/pwa": "31.2.0",
75
+ "@ultimat3/query": "31.2.0",
76
+ "@ultimat3/realtime": "31.2.0",
77
+ "@ultimat3/render": "31.2.0",
78
+ "@ultimat3/schema": "31.2.0",
79
+ "@ultimat3/scraping": "31.2.0",
80
+ "@ultimat3/seo": "31.2.0",
81
+ "@ultimat3/storage": "31.2.0",
82
+ "@ultimat3/testing": "31.2.0",
83
+ "@ultimat3/time": "31.2.0",
84
84
  "babel-preset-solid": "^1.9.16"
85
85
  }
86
86
  }
@@ -0,0 +1,124 @@
1
+ // The names an object destructuring BINDS, read off masked source: `{ fetch: f }` binds `f`, never
2
+ // `fetch`; `{ fetch }`, `{ fetch = d }`, `{ a: { fetch } }` and `{ ...fetch }` bind `fetch`. Only a
3
+ // pattern in a binding position counts — a `const`/`let`/`var` declaration or a parameter list —
4
+ // so `make({ fetch })`, the very hand-off the transport rule reports, binds nothing.
5
+
6
+ /** Opening bracket → its closer. A `Map`: a char read off source never reaches a prototype. */
7
+ const PAIRS: ReadonlyMap<string, string> = new Map([
8
+ ['(', ')'],
9
+ ['[', ']'],
10
+ ['{', '}'],
11
+ ]);
12
+
13
+ /** The index of the bracket closing the one at `open`, or `-1`. Exact on masked text only. */
14
+ function closing(masked: string, open: number): number {
15
+ const stack: string[] = [];
16
+ for (let at = open; at < masked.length; at += 1) {
17
+ const char = masked[at] ?? '';
18
+ const close = PAIRS.get(char);
19
+ if (close !== undefined) stack.push(close);
20
+ else if (char === stack[stack.length - 1]) {
21
+ stack.pop();
22
+ if (stack.length === 0) return at;
23
+ }
24
+ }
25
+ return -1;
26
+ }
27
+
28
+ /** The index of the unmatched `(` enclosing `index`, or `-1`. */
29
+ function enclosingParen(masked: string, index: number): number {
30
+ let depth = 0;
31
+ for (let at = index - 1; at >= 0; at -= 1) {
32
+ const char = masked[at] ?? '';
33
+ if (char === ')' || char === ']' || char === '}') depth += 1;
34
+ else if (char === '(' || char === '[' || char === '{') {
35
+ if (depth === 0) return char === '(' ? at : -1;
36
+ depth -= 1;
37
+ }
38
+ }
39
+ return -1;
40
+ }
41
+
42
+ /** `text` split on commas at depth zero — a pattern's entries. */
43
+ function topLevel(text: string, separator: string): readonly string[] {
44
+ const parts: string[] = [];
45
+ let depth = 0;
46
+ let from = 0;
47
+ for (let at = 0; at < text.length; at += 1) {
48
+ const char = text[at] ?? '';
49
+ if ('([{'.includes(char)) depth += 1;
50
+ else if (')]}'.includes(char)) depth -= 1;
51
+ else if (char === separator && depth === 0) {
52
+ parts.push(text.slice(from, at));
53
+ from = at + 1;
54
+ }
55
+ }
56
+ parts.push(text.slice(from));
57
+ return parts;
58
+ }
59
+
60
+ /** The first `=` at depth zero that is no `==`/`=>`, or `-1`: where a default starts. */
61
+ function defaultAt(text: string): number {
62
+ let depth = 0;
63
+ for (let at = 0; at < text.length; at += 1) {
64
+ const char = text[at] ?? '';
65
+ if ('([{'.includes(char)) depth += 1;
66
+ else if (')]}'.includes(char)) depth -= 1;
67
+ else if (char === '=' && depth === 0 && !/[=>]/.test(text[at + 1] ?? '')) {
68
+ return /[=!<>]/.test(text[at - 1] ?? '') ? -1 : at;
69
+ }
70
+ }
71
+ return -1;
72
+ }
73
+
74
+ /** The names one binding target binds: an identifier, or a nested object or array pattern. */
75
+ function targetNames(raw: string): readonly string[] {
76
+ const cut = defaultAt(raw);
77
+ const target = (cut < 0 ? raw : raw.slice(0, cut))
78
+ .trim()
79
+ .replace(/^\.\.\./, '')
80
+ .trim();
81
+ if (target.startsWith('{')) return patternNames(target.slice(1, -1), 'object');
82
+ if (target.startsWith('[')) return patternNames(target.slice(1, -1), 'array');
83
+ const name = /^[\w$]+/.exec(target)?.[0];
84
+ return name === undefined ? [] : [name];
85
+ }
86
+
87
+ function patternNames(body: string, kind: 'object' | 'array'): readonly string[] {
88
+ return topLevel(body, ',').flatMap((entry) => {
89
+ if (kind === 'array') return targetNames(entry);
90
+ const [key, ...rest] = topLevel(entry, ':');
91
+ // `key: target` binds the target; a shorthand `name` or `name = d` binds the name.
92
+ return rest.length === 0 ? targetNames(key ?? '') : targetNames(rest.join(':'));
93
+ });
94
+ }
95
+
96
+ /** Cheap, before any bracket is matched: a declaration keyword, or a `(`/`,` a parameter follows. */
97
+ function mayBind(masked: string, open: number): 'declared' | 'parameter' | undefined {
98
+ const head = masked.slice(Math.max(0, open - 8), open);
99
+ if (/\b(?:const|let|var)\s*$/.test(head)) return 'declared';
100
+ return /[(,]\s*$/.test(masked.slice(Math.max(0, open - 64), open)) ? 'parameter' : undefined;
101
+ }
102
+
103
+ /** A `{` after `(`/`,` is a parameter when its list is followed by a body, an arrow or a type. */
104
+ function isParameter(masked: string, open: number, close: number): boolean {
105
+ const paren = enclosingParen(masked, open);
106
+ if (paren < 0) return false;
107
+ const end = closing(masked, paren);
108
+ if (end < close) return false;
109
+ // A call's arguments are followed by neither: `make({ fetch }).then(go)`, `make({ fetch });`.
110
+ return /^\s*(?:=>|\{|:(?!:))/.test(masked.slice(end + 1, end + 64));
111
+ }
112
+
113
+ /** Every name the object patterns in binding positions of `masked` bind. */
114
+ export function destructuredNames(masked: string): ReadonlySet<string> {
115
+ const names = new Set<string>();
116
+ for (let open = masked.indexOf('{'); open >= 0; open = masked.indexOf('{', open + 1)) {
117
+ const position = mayBind(masked, open);
118
+ if (position === undefined) continue;
119
+ const close = closing(masked, open);
120
+ if (close < 0 || (position === 'parameter' && !isParameter(masked, open, close))) continue;
121
+ for (const name of patternNames(masked.slice(open + 1, close), 'object')) names.add(name);
122
+ }
123
+ return names;
124
+ }
@@ -13,6 +13,9 @@
13
13
  // imported by either; a request made inside an installed package (the walk ends at the package
14
14
  // boundary); a fetch reached through a computed member (`globalThis['fetch']`); and a bare
15
15
  // `fetch(` in a file that also binds a local `fetch` (`bindsFetch`). A floor, not a proof.
16
+ //
17
+ // The global `fetch` PASSED ON — `rpc({ fetch })`, `const f = window.fetch` — is the same bypass
18
+ // one module later (`transport-values.ts`), reported with a fix that removes the hand-off.
16
19
 
17
20
  import { ERROR_DOCS_URL, maskLiterals } from '@ultimat3/core';
18
21
  import { commentSafe } from './comment-safe';
@@ -24,9 +27,12 @@ import { barrelImports } from './server-barrels';
24
27
  import { isTest } from './source-files';
25
28
  import type { TransportCall, TransportShape } from './transport-calls';
26
29
  import { transportCalls } from './transport-calls';
30
+ import { fetchValues } from './transport-values';
27
31
 
28
32
  export interface Bypass extends TransportCall {
29
33
  readonly file: string;
34
+ /** The global handed on as a value rather than called here (`transport-values.ts`). */
35
+ readonly passed?: boolean;
30
36
  }
31
37
 
32
38
  export interface ServerBarrel extends BarrelImport {
@@ -90,6 +96,10 @@ export function checkBrowserTransport(input: TransportInput): {
90
96
  if (input.seams.get(call.shape) === file) continue;
91
97
  bypasses.push({ ...call, file });
92
98
  }
99
+ for (const value of fetchValues(source)) {
100
+ if (input.seams.get(value.shape) === file) continue;
101
+ bypasses.push({ ...value, file, passed: true });
102
+ }
93
103
  for (const found of barrelImports(source, input.barrels)) {
94
104
  if (input.ownsBarrel?.(file, found.barrel) === true) continue;
95
105
  barrels.push({ ...found, file });
@@ -137,6 +147,7 @@ const siteOf = (site: { readonly file: string; readonly line: number }): string
137
147
  * command re-reads the tree; the comment is the edit, because only the finding knows the line.
138
148
  */
139
149
  export function bypassFinding(bypass: Bypass, context: FindingContext): Finding {
150
+ if (bypass.passed === true) return passedFinding(bypass, context);
140
151
  const holder = context.holder(bypass.shape);
141
152
  const site = siteOf(bypass);
142
153
  return {
@@ -148,6 +159,23 @@ export function bypassFinding(bypass: Bypass, context: FindingContext): Finding
148
159
  };
149
160
  }
150
161
 
162
+ /**
163
+ * The global handed to another module: the request happens THERE, through a property no rule reads,
164
+ * so the edit is here — stop handing it on (a typed client already sends through the seam) — and
165
+ * the module that took it is the one to move onto the replacement.
166
+ */
167
+ function passedFinding(bypass: Bypass, context: FindingContext): Finding {
168
+ const holder = context.holder(bypass.shape);
169
+ const site = siteOf(bypass);
170
+ return {
171
+ code: 'X_BROWSER_TRANSPORT_BYPASS',
172
+ at: `${bypass.file}:${bypass.line}`,
173
+ cause: `${site} passes the global ${bypass.spelled} as a value in browser-reachable code; whatever receives it calls it directly, and ${holder === undefined ? 'no module may' : `only ${holder} may`}, so those requests skip the page's record store, idempotency header and principal fence`,
174
+ fix: `${context.rerun} # after deleting ${bypass.spelled} at ${site} (rpc() and queryClient() send through clientTransport when given none) and making the module that took it use ${REPLACEMENT.get(bypass.shape) ?? ''}`,
175
+ docs: ERROR_DOCS_URL,
176
+ };
177
+ }
178
+
151
179
  export function barrelFinding(site: ServerBarrel, context: FindingContext): Finding {
152
180
  const at = siteOf(site);
153
181
  return {
package/src/cmd-doctor.ts CHANGED
@@ -25,6 +25,7 @@ import { rollingSinceProbe, withRollingReminder } from './doctor-rolling';
25
25
  import { rowSecurityProbe } from './doctor-row-security';
26
26
  import type { SealedKeysFact } from './doctor-sealed';
27
27
  import { sealedKeyFindings, sealedKeysProbe } from './doctor-sealed';
28
+ import { typescriptFindings, typescriptProbe } from './doctor-typescript';
28
29
  import { PORT_RANGE, portPairAfter, readIntFlag } from './flag-number';
29
30
  import { machineSecretFindings } from './framework-env';
30
31
  import { ICON_SOURCE } from './icon-assets';
@@ -37,6 +38,7 @@ import { syncPortFor } from './role-sync';
37
38
  import { checkMigrationDrift } from './schema-drift';
38
39
  import { portFromEnv } from './serve-env';
39
40
  import { quoteArg } from './shell-quote';
41
+ import type { TypescriptLag } from './typescript-floor';
40
42
 
41
43
  /**
42
44
  * The injection seam `runDoctor` reads instead of the environment. Not a semver surface —
@@ -106,6 +108,8 @@ export interface DoctorProbe {
106
108
  authStorage(): Promise<AuthStorageFact>;
107
109
  /** The statement bound the session really reads, and what a pooler refused (`doctor-pooler.ts`). */
108
110
  pooler(): Promise<PoolerFact>;
111
+ /** Each manifest whose `typescript` range lags the scaffold's (`doctor-typescript.ts`). */
112
+ typescript(): Promise<readonly TypescriptLag[]>;
109
113
  /** With `database.rowSecurity` on, whether the serving role is exempt (`doctor-row-security.ts`). */
110
114
  rowSecurity?(): Promise<readonly Finding[]>;
111
115
  }
@@ -221,6 +225,9 @@ export async function runDoctor(probe: DoctorProbe): Promise<readonly Finding[]>
221
225
  );
222
226
  return findings;
223
227
  }
228
+ // Right after the runtime and for its reason: a compiler a major behind reds typecheck and build
229
+ // on the framework's own files, and every finding below is read through a gate that cannot pass.
230
+ findings.push(...typescriptFindings(await probe.typescript()));
224
231
  if (!probe.exists(ENV_DEVELOPMENT)) {
225
232
  findings.push(
226
233
  finding(
@@ -421,6 +428,7 @@ export function probeFor(
421
428
  root === undefined ? { columns: undefined, keys: undefined } : sealedKeysProbe(root),
422
429
  authStorage: () => authStorageProbe(process.env['DATABASE_URL'], env),
423
430
  pooler: () => poolerProbe(process.env['DATABASE_URL'], env),
431
+ typescript: async () => (root === undefined ? [] : typescriptProbe(root)),
424
432
  rowSecurity: async () =>
425
433
  root === undefined ? [] : rowSecurityProbe(root, process.env['DATABASE_URL'], env),
426
434
  };
@@ -36,6 +36,7 @@ import { entityTenantFindings } from './exercise-static';
36
36
  import { subjectFindings, subjectProofFindings } from './exercise-subject';
37
37
  import { readIntFlag } from './flag-number';
38
38
  import { msg } from './messages';
39
+ import { withOfflinePorts } from './offline-ports';
39
40
  import type { CommandResult, JsonValue } from './output';
40
41
 
41
42
  /**
@@ -70,8 +71,19 @@ async function exercise(
70
71
  root: string,
71
72
  seed: number | undefined,
72
73
  ): Promise<CommandResult> {
73
- const only = ctx.args.positionals[0];
74
74
  const loaded = await loadApp(root);
75
+ // `runtime.ts`'s ports, as a boot reads them — an `auditSink` declared there is what lets an
76
+ // `audit: true` primitive run — through `offline-ports.ts`, so the pass reaches no real backend.
77
+ return withOfflinePorts(root, () => exercisePass(ctx, root, seed, loaded));
78
+ }
79
+
80
+ async function exercisePass(
81
+ ctx: CommandContext,
82
+ root: string,
83
+ seed: number | undefined,
84
+ loaded: Awaited<ReturnType<typeof loadApp>>,
85
+ ): Promise<CommandResult> {
86
+ const only = ctx.args.positionals[0];
75
87
  const overrides = await readExerciseOverrides(root);
76
88
  const cores = registeredEntityCores();
77
89
  const entities: readonly SeedEntity[] = Object.values(cores);
@@ -17,6 +17,7 @@ import { msg } from './messages';
17
17
  import type { CommandResult } from './output';
18
18
  import { flagBool, flagString } from './parse';
19
19
  import { posixRelative } from './posix-path';
20
+ import { typescriptLags } from './typescript-floor';
20
21
  import { applyAgentsLink, planAgentsLink } from './upgrade-agents-link';
21
22
  import type { BunEdit, BunManual } from './upgrade-bun-floor';
22
23
  import { editBunSites, floorOf, isBunSite } from './upgrade-bun-floor';
@@ -154,6 +155,8 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
154
155
  const top = await requireCleanTree(ctx.runner, root);
155
156
  const manifests = await readManifests(root);
156
157
  const pins = readPins(manifests);
158
+ // Reported, never written: a compiler is the app's to move, and the line names the command.
159
+ const typescript = typescriptLags(manifests);
157
160
  const versions = await publishedVersions(ctx.runner, root);
158
161
  const hop = planHop({ pins, versions, ...(to === undefined ? {} : { to }) });
159
162
 
@@ -176,8 +179,12 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
176
179
  gate: undefined,
177
180
  scripts: [],
178
181
  then,
182
+ typescript,
179
183
  }),
180
- lines: [msg('cli.upgrade.then', { then })],
184
+ lines: [
185
+ ...typescript.map((lag) => msg('cli.upgrade.typescript', { ...lag })),
186
+ msg('cli.upgrade.then', { then }),
187
+ ],
181
188
  });
182
189
  }
183
190
 
@@ -199,7 +206,16 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
199
206
  const held = manifests.find((manifest) => manifest.file === 'package.json')?.text ?? '';
200
207
  const bunFrom = /"engines"\s*:\s*\{[^}]*?"bun"\s*:\s*"([^"]*)"/.exec(held)?.[1] ?? null;
201
208
  const agentsMd = await planAgentsLink(root);
202
- const shared = { hop, pins, bunFrom, bunTo: bunRange ?? null, writes, app, agentsMd };
209
+ const shared = {
210
+ hop,
211
+ pins,
212
+ bunFrom,
213
+ bunTo: bunRange ?? null,
214
+ writes,
215
+ app,
216
+ agentsMd,
217
+ typescript,
218
+ };
203
219
  const scriptNames = app ? [] : repoScripts(held);
204
220
 
205
221
  if (dryRun) {
@@ -214,7 +230,15 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
214
230
  scripts: named,
215
231
  then,
216
232
  }),
217
- lines: humanLines({ hop, writes, gate: undefined, scripts: named, then, agentsMd }),
233
+ lines: humanLines({
234
+ hop,
235
+ writes,
236
+ gate: undefined,
237
+ scripts: named,
238
+ then,
239
+ agentsMd,
240
+ typescript,
241
+ }),
218
242
  });
219
243
  }
220
244
 
@@ -248,7 +272,7 @@ export const createUpgradeCommand = (write: (line: string) => void): CliCommand
248
272
  const then = thenLine({ hop, dryRun: false, app, gate, scripts });
249
273
  const extra = {
250
274
  data: report({ ...shared, done, dryRun: false, gate, scripts, then }),
251
- lines: humanLines({ hop, writes, gate, scripts, then, agentsMd }),
275
+ lines: humanLines({ hop, writes, gate, scripts, then, agentsMd, typescript }),
252
276
  };
253
277
  const span = { from: hop.from, to: hop.to };
254
278
  if (gate !== undefined) {
@@ -0,0 +1,31 @@
1
+ // `x doctor`'s TypeScript check: every manifest whose `typescript` range lags the one `x new`
2
+ // scaffolds is `X_TYPESCRIPT_VERSION`, its fix the `bun add` that moves exactly that manifest.
3
+ // The rule is `typescript-floor.ts`'s; this file reads the manifests and words the finding.
4
+
5
+ import { ERROR_DOCS_URL } from '@ultimat3/core';
6
+ import type { Finding } from './output';
7
+ import type { TypescriptLag } from './typescript-floor';
8
+ import { typescriptLags } from './typescript-floor';
9
+ import { readManifests } from './upgrade-pins';
10
+
11
+ /**
12
+ * The I/O half: the root manifest and every workspace's, the set `x upgrade` moves pins in. An
13
+ * unreadable root manifest is not this check's to report — `bun install` names its line — so it
14
+ * reads as nothing to judge rather than a second finding about the same file.
15
+ */
16
+ export async function typescriptProbe(root: string): Promise<readonly TypescriptLag[]> {
17
+ try {
18
+ return typescriptLags(await readManifests(root));
19
+ } catch {
20
+ return [];
21
+ }
22
+ }
23
+
24
+ export const typescriptFindings = (lags: readonly TypescriptLag[]): readonly Finding[] =>
25
+ lags.map((lag) => ({
26
+ code: 'X_TYPESCRIPT_VERSION',
27
+ at: lag.file,
28
+ cause: `${lag.file} declares ${lag.field}.typescript ${JSON.stringify(lag.from)}, below the ${lag.to} \`x new\` scaffolds; @ultimat3/* ships source and .d.ts checked by that compiler, so typecheck and build go red on framework files this app never wrote`,
29
+ fix: lag.fix,
30
+ docs: ERROR_DOCS_URL,
31
+ }));
@@ -236,6 +236,7 @@ export const CLI_OWNED_ERROR_CODES = [
236
236
  'X_APP_ROOT_NESTED',
237
237
  'X_WORKSPACE_NAME_TAKEN',
238
238
  'X_PARTITIONS_UNMAINTAINED',
239
+ 'X_TYPESCRIPT_VERSION',
239
240
  ] as const;
240
241
 
241
242
  /**
@@ -458,6 +459,7 @@ export const CLI_ERROR_TITLES: Readonly<Record<CliListedErrorCode, string>> = {
458
459
  X_WORKSPACE_NAME_TAKEN:
459
460
  'x g app or x g package was given a name the other workspace kind already holds',
460
461
  X_PARTITIONS_UNMAINTAINED: 'a partitioned entity with no partitions() job',
462
+ X_TYPESCRIPT_VERSION: 'The app declares a TypeScript older than the one x new scaffolds',
461
463
  };
462
464
 
463
465
  // One unconditional call, so a second package claiming one of the CLI's codes throws
@@ -0,0 +1,49 @@
1
+ // `errors.explain`'s rows for `x shot` and the `ui.*` MCP tools — the capture family, split out of
2
+ // `mcp-errors.ts` under the 500-line ceiling. Spread into `CLI_FIXES` there, whose
3
+ // `Record<CliErrorCode, string>` is still what makes a code without a row a build error.
4
+
5
+ import type { CliErrorCode } from './error-codes';
6
+
7
+ export const SHOT_FIXES = {
8
+ X_SHOT_BROWSER_MISSING:
9
+ 'export CHROME_PATH=/usr/bin/google-chrome # macOS: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; Windows PowerShell: $env:CHROME_PATH = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"',
10
+ X_UI_SHOT_ROUTE_UNKNOWN:
11
+ 'x routes --json # then call the ui.* tool with one of its path values',
12
+ X_UI_SHOT_ROUTE_UNBUDGETED:
13
+ "x build --target static --json && x verify --only budgets --json # after declaring budget: { js: '<n>kb' } in the route file",
14
+ // The four `ui.interact` refusals. None can be repaired by a command — each is a change to the
15
+ // step list the agent sends — so each names the command that SHOWS what a valid resend needs.
16
+ X_UI_INTERACT_STEPS_INVALID:
17
+ 'x help shot --json # then resend ui.interact with at most 12 one-key steps, type.text under 500 chars and wait under 5000 ms',
18
+ X_UI_INTERACT_SECRET_FIELD:
19
+ 'x shot --all-islands --json # or --island <name>: a declared state renders the filled form without the secret ever being typed',
20
+ X_UI_INTERACT_LEFT_APP:
21
+ 'x routes --json # then resend ui.interact with steps that stay on one of its paths',
22
+ X_UI_INTERACT_STEP_FAILED:
23
+ 'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
24
+ X_SHOT_HOST_REFUSED: 'x shot /route --allow-hosts cdn.example.com --json',
25
+ X_SHOT_ELEMENT_MISSING:
26
+ 'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
27
+ X_SHOT_ELEMENT_UNREADY:
28
+ 'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
29
+ X_SHOT_KEY_INVALID: 'x help shot --json # a chord is modifiers then one key: Meta+K',
30
+ // The three `ui.diff` codes. Every capture it can compare was written by `x shot` or a `ui.*`
31
+ // tool under `.x/shot/`, so the runnable half is the command that writes one there.
32
+ X_UI_DIFF_PATH_OUTSIDE:
33
+ 'x shot / --json # then pass the image path it answers, relative to the app root: ui.diff reads .x/shot/ and nothing else',
34
+ X_UI_DIFF_FILE_MISSING:
35
+ 'x shot / --json # then diff the image path it answers; a capture ui.shot wrote is listed in its own answer',
36
+ X_UI_DIFF_SIZE_MISMATCH:
37
+ 'x shot / --json # photograph both captures at one viewport with one fullPage setting, then diff those two',
38
+ // The four island-capture codes. Each one's real repair is an edit to the app's own states file
39
+ // or component, which no command can perform — so each names the command that REPRODUCES it with
40
+ // the file and the reason attached, which is the runnable half.
41
+ X_SHOT_ISLAND_STATES_EMPTY:
42
+ 'x help shot --json # then export the manifest from the states file the cause names',
43
+ X_SHOT_ISLAND_UNPHOTOGRAPHABLE:
44
+ 'x help shot --json # the cause names the assertion that did not hold; --settle buys the slow ones more time',
45
+ X_SHOT_ISLAND_UNSTUBBED_REQUEST:
46
+ 'x help shot --json # the cause lists every request the state must answer under routes',
47
+ X_SHOT_ISLAND_MISSING:
48
+ 'x help shot --json # every absent picture carries its own named refusal in the run above',
49
+ } as const satisfies Partial<Record<CliErrorCode, string>>;
package/src/mcp-errors.ts CHANGED
@@ -7,6 +7,7 @@ import type { ErrorExplanation } from '@ultimat3/mcp';
7
7
  import type { CliErrorCode } from './error-codes';
8
8
  import { CLI_ERROR_CODES } from './error-codes';
9
9
  import { codeFixes, codeFixScan } from './error-fixes';
10
+ import { SHOT_FIXES } from './mcp-errors-shot';
10
11
 
11
12
  /**
12
13
  * One runnable command per CLI code. Typed over `CliErrorCode`, so a new code fails the build.
@@ -70,47 +71,8 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
70
71
  'x verify --json # the package-shape finding carries the dependency line to add',
71
72
  X_PACKAGE_DUPLICATED:
72
73
  'x i18n check --json # the finding names both copies and the package.json to pin',
73
- X_SHOT_BROWSER_MISSING:
74
- 'export CHROME_PATH=/usr/bin/google-chrome # macOS: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; Windows PowerShell: $env:CHROME_PATH = "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"',
75
- X_UI_SHOT_ROUTE_UNKNOWN:
76
- 'x routes --json # then call the ui.* tool with one of its path values',
77
- X_UI_SHOT_ROUTE_UNBUDGETED:
78
- "x build --target static --json && x verify --only budgets --json # after declaring budget: { js: '<n>kb' } in the route file",
79
- // The four `ui.interact` refusals. None can be repaired by a command — each is a change to the
80
- // step list the agent sends — so each names the command that SHOWS what a valid resend needs.
81
- X_UI_INTERACT_STEPS_INVALID:
82
- 'x help shot --json # then resend ui.interact with at most 12 one-key steps, type.text under 500 chars and wait under 5000 ms',
83
- X_UI_INTERACT_SECRET_FIELD:
84
- 'x shot --all-islands --json # or --island <name>: a declared state renders the filled form without the secret ever being typed',
85
- X_UI_INTERACT_LEFT_APP:
86
- 'x routes --json # then resend ui.interact with steps that stay on one of its paths',
87
- X_UI_INTERACT_STEP_FAILED:
88
- 'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
89
- X_SHOT_HOST_REFUSED: 'x shot /route --allow-hosts cdn.example.com --json',
90
- X_SHOT_ELEMENT_MISSING:
91
- 'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
92
- X_SHOT_ELEMENT_UNREADY:
93
- 'x routes --json # then run ui.inspect on the route first and copy a selector it reports with count >= 1',
94
- X_SHOT_KEY_INVALID: 'x help shot --json # a chord is modifiers then one key: Meta+K',
95
- // The three `ui.diff` codes. Every capture it can compare was written by `x shot` or a `ui.*`
96
- // tool under `.x/shot/`, so the runnable half is the command that writes one there.
97
- X_UI_DIFF_PATH_OUTSIDE:
98
- 'x shot / --json # then pass the image path it answers, relative to the app root: ui.diff reads .x/shot/ and nothing else',
99
- X_UI_DIFF_FILE_MISSING:
100
- 'x shot / --json # then diff the image path it answers; a capture ui.shot wrote is listed in its own answer',
101
- X_UI_DIFF_SIZE_MISMATCH:
102
- 'x shot / --json # photograph both captures at one viewport with one fullPage setting, then diff those two',
103
- // The four island-capture codes. Each one's real repair is an edit to the app's own states file
104
- // or component, which no command can perform — so each names the command that REPRODUCES it with
105
- // the file and the reason attached, which is the runnable half.
106
- X_SHOT_ISLAND_STATES_EMPTY:
107
- 'x help shot --json # then export the manifest from the states file the cause names',
108
- X_SHOT_ISLAND_UNPHOTOGRAPHABLE:
109
- 'x help shot --json # the cause names the assertion that did not hold; --settle buys the slow ones more time',
110
- X_SHOT_ISLAND_UNSTUBBED_REQUEST:
111
- 'x help shot --json # the cause lists every request the state must answer under routes',
112
- X_SHOT_ISLAND_MISSING:
113
- 'x help shot --json # every absent picture carries its own named refusal in the run above',
74
+ // `x shot` and the `ui.*` tools: their own family, in `mcp-errors-shot.ts`.
75
+ ...SHOT_FIXES,
114
76
  X_GH_UNAVAILABLE: 'gh auth login # install first from https://cli.github.com',
115
77
  X_GH_NOT_AUTHENTICATED: 'gh auth login',
116
78
  X_GH_COMMAND_FAILED: 'x ci --json # the finding carries the gh invocation that failed',
@@ -410,6 +372,8 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
410
372
  'export const api = defineApi({ actions: [yourActions], queries: [yourQueries] }); # in apps/web/api/index.ts — list the module there, then delete the loader import',
411
373
  X_WORKSPACE_EXTERNAL_DEP_UNDECLARED:
412
374
  'x verify --only package-shape --json # each finding carries its own `bun add <package> --cwd <workspace>` line',
375
+ X_TYPESCRIPT_VERSION:
376
+ 'x doctor --json # each X_TYPESCRIPT_VERSION finding names its manifest and the bun add that moves it',
413
377
  };
414
378
 
415
379
  const isCliCode = (code: string): code is CliErrorCode =>
@@ -4,17 +4,21 @@
4
4
  // context (`useRequestHeader('cookie')` throws X_NO_REQUEST outside one), an actor the app chose
5
5
  // (`defineMeasurementActor()` in `app.config.ts`, core's `measurementActor()` otherwise), and a
6
6
  // server to answer — the app's own API pipeline, dispatched IN PROCESS through core's
7
- // `withInProcessFetch`, because no server is listening during a build (plan 101 slice 11 m).
7
+ // `withInProcessFetch`, because no server is listening during a build (plan 101 slice 11 m) — and
8
+ // `runtime.ts`'s ports as `offline-ports.ts` decides them, for every render the build runs.
8
9
 
9
10
  import type { Actor, Ctx } from '@ultimat3/core';
10
11
  import { actorLabel, measurementActor, runWithContext, withInProcessFetch } from '@ultimat3/core';
11
12
  import { defineHttpConfig, httpPipeline, httpRouter, requestContext } from '@ultimat3/http';
12
13
  import { apiRoutes } from './api-routes';
14
+ import { installOfflinePorts } from './offline-ports';
13
15
 
14
- /** One build's measurement scope: its actor, and a runner that renders inside it. */
16
+ /** One build's measurement scope: its actor, a runner that renders inside it, and its release. */
15
17
  export interface MeasureScope {
16
18
  readonly actor: Actor;
17
19
  run<T>(fn: () => T): T;
20
+ /** Releases the ports `measureScope` installed. Once, when the build's renders are done. */
21
+ close(): Promise<void>;
18
22
  }
19
23
 
20
24
  /** A scope's in-process API: the app's own table, as `actor` — or, `null`, as nobody. */
@@ -45,15 +49,24 @@ function inProcessRunner(input: ScopeInput, actor: Actor | null): <T>(fn: () =>
45
49
  return <T>(fn: () => T): T => withInProcessFetch(dispatch, () => runWithContext(request, fn));
46
50
  }
47
51
 
52
+ /** A measurement scope's input: the app at `root`, whose `runtime.ts` the build honours. */
53
+ interface MeasureInput extends ScopeInput {
54
+ readonly root: string;
55
+ }
56
+
48
57
  /**
49
58
  * The scope for `origin`. The pipeline is the app's API table and nothing else: a page's data
50
59
  * comes from its actions and queries, and a route the render reaches that is not one of them
51
60
  * answers 404 — which the render reports, and the route is filed unmeasured with that reason.
52
61
  * For a render that is WEIGHED and discarded only: its output is never published.
53
62
  */
54
- export async function measureScope(input: ScopeInput): Promise<MeasureScope> {
63
+ export async function measureScope(input: MeasureInput): Promise<MeasureScope> {
55
64
  const actor = await measurementActor();
56
- return { actor, run: inProcessRunner(input, actor) };
65
+ // Installed here rather than per render: the published (`site/`) renders read the same ports, and
66
+ // a page whose `load` calls an `audit: true` query was unmeasured with `X_AUDIT_SINK_MISSING`
67
+ // for an app that declared its sink in `runtime.ts`, as upgrade entry 43 says to.
68
+ const close = await installOfflinePorts(input.root);
69
+ return { actor, run: inProcessRunner(input, actor), close };
57
70
  }
58
71
 
59
72
  /**
@@ -26,6 +26,8 @@ export const UPGRADE_MESSAGES = {
26
26
  'AGENTS.md: differs from CLAUDE.md, left alone. Merge what only AGENTS.md says into CLAUDE.md, then: ln -sf CLAUDE.md AGENTS.md',
27
27
  'cli.upgrade.bunEdited': 'bun floor: {path} {from} -> {to}',
28
28
  'cli.upgrade.bunManual': 'bun floor, by hand: {path}:{line} — {why}',
29
+ 'cli.upgrade.typescript':
30
+ 'typescript, by hand: {file} declares {from}, below the {to} the framework is checked with — run: {fix}',
29
31
  'cli.upgrade.done': '{from} -> {to}: the gate is green',
30
32
  'cli.upgrade.dryRun': '{from} -> {to}: nothing written, no gate run',
31
33
  'cli.upgrade.guard': 'guard, yours to take or leave: {fix}',