@ultimat3/cli 31.0.0 → 31.1.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/src/cmd-pr.ts CHANGED
@@ -19,6 +19,7 @@ import { PrNotFoundError, resolvePrNumber, resolveRepo } from './gh-target';
19
19
  import { msg } from './messages';
20
20
  import type { CommandResult, JsonValue } from './output';
21
21
  import { flagBool, flagString } from './parse';
22
+ import { botsSummary } from './pr-bots';
22
23
  import type { PrReviewReport, PrThread } from './pr-threads';
23
24
  import { fetchReviewReport, replyToThread, resolveThread, THREAD_PAGE } from './pr-threads';
24
25
 
@@ -38,6 +39,9 @@ export const PR_MESSAGE_KEYS = [
38
39
  'cli.pr.review.current',
39
40
  'cli.pr.review.undecided',
40
41
  'cli.pr.review.truncated',
42
+ 'cli.pr.review.activity',
43
+ 'cli.pr.bot.blocked',
44
+ 'cli.pr.bot.notice',
41
45
  'cli.pr.thread.open',
42
46
  'cli.pr.thread.closed',
43
47
  'cli.pr.thread.outdated',
@@ -111,7 +115,11 @@ async function runReview(ctx: CommandContext): Promise<CommandResult> {
111
115
  repo: report.repo,
112
116
  pr: report.number,
113
117
  }),
114
- lines: [...decisionLines(report), ...shown.flatMap((thread) => threadLines(thread, bodyLines))],
118
+ lines: [
119
+ ...decisionLines(report),
120
+ ...activityLines(report),
121
+ ...shown.flatMap((thread) => threadLines(thread, bodyLines)),
122
+ ],
115
123
  data: reviewJson(report, shown, bodyLines, unresolved),
116
124
  };
117
125
  }
@@ -144,6 +152,43 @@ function decisionLines(report: PrReviewReport): readonly string[] {
144
152
  ];
145
153
  }
146
154
 
155
+ /**
156
+ * The rest of the conversation, in as few lines as it takes: one count, then one line per review
157
+ * bot that posted a "did not review" notice. Bodies stay in `--json` — the terminal is for the
158
+ * fact that a review is MISSING, which no thread would ever show.
159
+ */
160
+ function activityLines(report: PrReviewReport): readonly string[] {
161
+ const bots = botsSummary(report.reviews, report.comments);
162
+ const out = [
163
+ msg('cli.pr.review.activity', {
164
+ reviews: report.reviews.length,
165
+ comments: report.comments.length,
166
+ bots: bots.length,
167
+ }),
168
+ ];
169
+ for (const bot of bots) {
170
+ const notice = bot.notice;
171
+ if (notice === null) continue;
172
+ out.push(
173
+ bot.blocked
174
+ ? msg('cli.pr.bot.blocked', {
175
+ login: bot.login,
176
+ kind: notice.kind,
177
+ excerpt: notice.excerpt,
178
+ at: notice.at,
179
+ url: notice.url,
180
+ })
181
+ : msg('cli.pr.bot.notice', {
182
+ login: bot.login,
183
+ kind: notice.kind,
184
+ at: notice.at,
185
+ reviewed: bot.lastReviewAt ?? '',
186
+ }),
187
+ );
188
+ }
189
+ return out;
190
+ }
191
+
147
192
  const truncationLines = (report: PrReviewReport): readonly string[] =>
148
193
  report.truncated ? [msg('cli.pr.review.truncated', { count: THREAD_PAGE })] : [];
149
194
 
@@ -189,6 +234,12 @@ export function clampBody(
189
234
  return { lines: lines.slice(0, limit), hidden: lines.length - limit };
190
235
  }
191
236
 
237
+ /** `clampBody` as the two fields every `--json` body row carries. */
238
+ const clampedBody = (body: string, limit: number) => {
239
+ const clamped = clampBody(body, limit);
240
+ return { body: clamped.lines.join('\n'), bodyLinesHidden: clamped.hidden };
241
+ };
242
+
192
243
  function reviewJson(
193
244
  report: PrReviewReport,
194
245
  shown: readonly PrThread[],
@@ -221,6 +272,26 @@ function reviewJson(
221
272
  shown: shown.length,
222
273
  },
223
274
  truncated: report.truncated,
275
+ // Additive beside `threads`: every review with its verdict and body, every issue comment, and
276
+ // which review bots said they did NOT review — a rate-limited bot leaves no thread, so its
277
+ // silence would otherwise read as a clean review.
278
+ reviews: report.reviews.map(({ body, ...review }) => ({
279
+ ...review,
280
+ ...clampedBody(body, bodyLines),
281
+ })),
282
+ comments: report.comments.map(({ body, ...comment }) => ({
283
+ ...comment,
284
+ ...clampedBody(body, bodyLines),
285
+ })),
286
+ reviewsTruncated: report.reviewsTruncated,
287
+ commentsTruncated: report.commentsTruncated,
288
+ bots: botsSummary(report.reviews, report.comments).map(({ notice, ...bot }) => ({
289
+ ...bot,
290
+ notice:
291
+ notice === null
292
+ ? null
293
+ : { kind: notice.kind, excerpt: notice.excerpt, at: notice.at, url: notice.url },
294
+ })),
224
295
  threads: shown.map((thread) => {
225
296
  const comments = thread.comments.map((comment) => {
226
297
  const clamped = clampBody(comment.body, bodyLines);
package/src/cmd-shot.ts CHANGED
@@ -5,15 +5,12 @@
5
5
  // Never a step of `x verify`: it needs a real browser, and a gate that goes red because a machine
6
6
  // has no Chrome is a gate that fails for reasons unrelated to the change.
7
7
 
8
- import { mkdirSync } from 'node:fs';
9
8
  import { join, resolve } from 'node:path';
10
9
  import { renderFixShellArg } from '@ultimat3/core';
11
- import { systemClock } from '@ultimat3/core/adapter';
12
10
  import { appLocaleSet } from '@ultimat3/i18n/app-catalogs';
13
11
  import { IDLE_HYDRATE_TIMEOUT_MS } from '@ultimat3/render';
14
12
  import { requireAppRoot } from './app-root';
15
13
  import { appBrowser } from './browser-launcher';
16
- import type { ShotColorScheme, ShotDriver, ShotPage, ShotSession } from './browser-launcher-port';
17
14
  import { DEFAULT_PAGE_TIMEOUT_MS } from './cdp-shot-clock';
18
15
  import {
19
16
  islandShot,
@@ -34,130 +31,34 @@ import {
34
31
  } from './cmd-shot-matrix';
35
32
  import { shotSpec } from './cmd-shot-spec';
36
33
  import type { CliCommand, CommandContext } from './command';
37
- import { BadFlagError, MissingPositionalError } from './errors';
34
+ import { BadFlagError } from './errors';
38
35
  import { intFlagOr, PORT_RANGE } from './flag-number';
39
36
  import type { CommandResult } from './output';
40
37
  import type { ParsedArgs } from './parse';
41
38
  import { flagBool, flagString } from './parse';
42
39
  import { shotBrowserChoice } from './shot-browser';
43
- import { readCookieFlag, type ShotCookiePair, shotCookies } from './shot-cookie';
44
- import { acceptLanguageHeaders, localizedShotPath, readLocaleFlag } from './shot-locale';
40
+ import { readCookieFlag } from './shot-cookie';
41
+ import { localizedShotPath, readLocaleFlag } from './shot-locale';
42
+ import { readRoute, shotSlug } from './shot-route';
43
+ import { runShot } from './shot-run';
45
44
  import type { BootDevServer, ShotServer } from './shot-server';
46
45
  import { allowHostsFrom, devServerFor, SHOT_DIR } from './shot-server';
47
- import { SETTLE_POLL_MS, settleIslands } from './shot-settle';
48
- import { readThemeFlag, themeChoiceExpression } from './shot-theme';
49
- import type { IslandCount, ShotArtifacts } from './shot-verdict';
50
- import {
51
- buildVerdict,
52
- documentStatus,
53
- ISLAND_PROBE,
54
- parseIslandProbe,
55
- shotLines,
56
- shotSummary,
57
- verdictJson,
58
- } from './shot-verdict';
46
+ import { readThemeFlag } from './shot-theme';
47
+ import type { ShotArtifacts } from './shot-verdict';
48
+ import { shotLines, shotSummary, verdictJson } from './shot-verdict';
59
49
  import { parseViewports, refuseViewportWithComponent, runShotViewports } from './shot-viewport';
60
50
 
61
51
  /** Kernel-picked by default: :3000 is usually another project's dev server, not a free port. */
62
52
  const DEFAULT_PORT = 0;
63
53
 
64
- // Re-exported, not re-declared: a second declaration of a path or a host rule is a second answer.
54
+ // Re-exported, not re-declared: a second declaration of a path, a host rule, the route rule or the
55
+ // capture is a second answer. The route rule is `shot-route.ts`'s, the capture `shot-run.ts`'s.
56
+ export { readRoute, shotSlug } from './shot-route';
57
+ export type { ShotRun } from './shot-run';
58
+ export { runShot, SHOT_IMAGE, SHOT_VERDICT } from './shot-run';
65
59
  export type { BootDevServer, ShotServer };
66
60
  export { allowHostsFrom, devServerFor, SHOT_DIR };
67
61
 
68
- export const SHOT_IMAGE = 'shot.png';
69
- export const SHOT_VERDICT = 'verdict.json';
70
-
71
- /** A directory name a route can never escape: everything that is not a letter or digit is a dash. */
72
- export function shotSlug(route: string): string {
73
- const slug = route.replace(/[^a-zA-Z0-9]+/g, '-').replace(/^-+|-+$/g, '');
74
- return slug === '' ? 'root' : slug.toLowerCase();
75
- }
76
-
77
- const pathOf = (url: string): string => {
78
- try {
79
- return new URL(url).pathname;
80
- } catch {
81
- return '/';
82
- }
83
- };
84
-
85
- /**
86
- * A reserved name (RFC 2606) that resolves nowhere, so the origin check below can never be
87
- * satisfied by an accident of what the app's own host happens to be.
88
- */
89
- const ROUTE_BASE = 'http://route.invalid';
90
-
91
- /**
92
- * Where a browser would actually go. The refusal above reads `scheme:` and nothing else, and this
93
- * is the question it was standing in for: a path is a path only if resolving it lands back on the
94
- * origin it was resolved against.
95
- */
96
- const resolvedOrigin = (path: string): string => {
97
- try {
98
- return new URL(path, ROUTE_BASE).origin;
99
- } catch {
100
- // A path `new URL` will not parse is one no browser will fetch either, and reporting it as the
101
- // origin it is not is the honest answer here.
102
- return '';
103
- }
104
- };
105
-
106
- const refuseRoute = (reason: string): never => {
107
- throw new BadFlagError({
108
- flag: 'route',
109
- command: 'shot',
110
- reason,
111
- // A placeholder, because there is nothing safe to substitute: unlike an absolute URL, an
112
- // origin-escaping route carries no path the caller can be assumed to have meant.
113
- fix: 'x shot /<path> --json',
114
- });
115
- };
116
-
117
- /**
118
- * A path on the app, never a URL. `x shot https://example.com` would photograph somebody else's
119
- * site through a headless browser inside your network, which is the SSRF shape `allowHosts` exists
120
- * to refuse — so it is refused here, at the argument, where the reader can still see why.
121
- *
122
- * `scheme:` was the ONLY spelling refused until 2026-08-22, and it is one of four: `//evil/x` is a
123
- * protocol-relative URL, `\evil\x` is the same thing to every URL parser (a backslash IS a slash
124
- * for a special scheme), and a TAB inside the path is deleted by the parser before the host is
125
- * read, so `/⇥/evil/x` becomes `//evil/x`. Each one reached `new URL(route, server.url)` and came
126
- * back pointed at another host. `allowHostsFrom` one layer down could not catch any of them: it
127
- * allows a HOSTNAME, and the hostname it is given is the one the page has already left — which is
128
- * how `x shot //localhost:9200/_cat/indices` photographed whatever else was on the dev box.
129
- */
130
- export function readRoute(raw: string | undefined): string {
131
- if (raw === undefined || raw.trim() === '') {
132
- throw new MissingPositionalError({ command: 'shot', positional: 'route', example: 'x shot /' });
133
- }
134
- const route = raw.trim();
135
- if (/^[a-z][a-z0-9+.-]*:/i.test(route)) {
136
- throw new BadFlagError({
137
- flag: 'route',
138
- command: 'shot',
139
- reason: `"${route}" is an absolute URL; x shot photographs a route of the app under test`,
140
- // The path out of the URL when it parses — the refusal's own fix line has to be runnable,
141
- // and `new URL('http://')` throws, so the fallback is the route every app has.
142
- fix: `x shot ${pathOf(route)} --json`,
143
- });
144
- }
145
- const path = route.startsWith('/') ? route : `/${route}`;
146
- // Its own refusal rather than folded into the origin check: `/a\b` stays on this origin and is
147
- // still not the route that was typed — the verdict would record `/a\b` beside a picture of
148
- // `/a/b`, which is the artifact lying about its own subject.
149
- if (path.includes('\\')) {
150
- return refuseRoute(`"${route}" contains a backslash, which a URL parser reads as "/"`);
151
- }
152
- const origin = resolvedOrigin(path);
153
- if (origin !== ROUTE_BASE) {
154
- return refuseRoute(
155
- `"${route}" is not a path on the app: a browser resolves it to ${origin === '' ? 'no URL at all' : origin}`,
156
- );
157
- }
158
- return path;
159
- }
160
-
161
62
  /**
162
63
  * The three integer flags, each read with its NAME as an argument. `intFlagOr` takes the name in a
163
64
  * `name:` field, which `flag-reads.ts` counts as a declaration rather than a read — so a command
@@ -183,165 +84,6 @@ const intFlag = (
183
84
  fallback,
184
85
  );
185
86
 
186
- export interface ShotRun {
187
- readonly route: string;
188
- readonly outDir: string;
189
- readonly driver: ShotDriver;
190
- readonly boot: () => Promise<ShotServer>;
191
- readonly settleMs: number;
192
- readonly timeoutMs: number;
193
- readonly fullPage: boolean;
194
- /**
195
- * `--allow-hosts`, verbatim. The app's own host is added once the server is up and never here:
196
- * with `--port 0` the port — and therefore the origin — does not exist until after the boot.
197
- */
198
- readonly extraHosts?: string | undefined;
199
- /**
200
- * The theme the picture is of. Two things happen BEFORE navigation, because the boot script runs
201
- * inline and nothing after `goto` can reach it: `prefers-color-scheme` is emulated so the boot's
202
- * "system" branch answers the same on every box, AND the scheme is stored as the visitor's
203
- * choice under `THEME_STORAGE_KEY` (`shot-theme.ts`), because an app with `theme.defaultMode`
204
- * set answers that before the OS and only a stored choice beats it (issue #489). Absent means
205
- * neither: the box's own preference and the app's own default — what `x shot` has always done,
206
- * and the point of `defaultMode` — and `ui.shot` names one explicitly for exactly that reason.
207
- */
208
- readonly colorScheme?: ShotColorScheme | undefined;
209
- /** CSS pixels the page is laid out in; absent is the driver's default. */
210
- readonly viewport?: { readonly width: number; readonly height: number } | undefined;
211
- /**
212
- * Sent as `Accept-Language` on every request. The command always sets it — `--locale`, or the
213
- * app's default locale — so a picture never depends on the language of the machine's Chrome.
214
- */
215
- readonly acceptLanguage?: string | undefined;
216
- /**
217
- * `--cookie`: set before the first navigation, each for the server's own URL once it is up —
218
- * so a consent banner (or any cookie-held choice) is decided in the picture.
219
- */
220
- readonly cookies?: readonly ShotCookiePair[] | undefined;
221
- readonly now?: (() => Date) | undefined;
222
- /**
223
- * `--expect-status`: the document status this shot is ok with — `404` to photograph the not-found
224
- * page on purpose. Absent means any 2xx, and anything else fails the verdict with the status.
225
- */
226
- readonly expectStatus?: number | undefined;
227
- /**
228
- * Something to do with the page AFTER the islands settled and BEFORE the picture — `ui.inspect`
229
- * reads the DOM here, on the one navigation the picture already paid for. `settle` re-runs the
230
- * island poll (an action that mounts something changes the count the verdict reports); the
231
- * caller who never calls it gets the count from the first settle.
232
- */
233
- readonly act?:
234
- | ((page: ShotPage, settle: () => Promise<IslandCount | null>) => Promise<void>)
235
- | undefined;
236
- /**
237
- * The clock the settle window runs on — the same seam `SettleOptions.sleep` and
238
- * `InteractDeps.sleep` take, and the reason they had none on this path: `settleMs` was a
239
- * `Bun.sleep` here, so a caller that injected a sleep everywhere else still paid the real
240
- * 2000 ms window in wall time once per `runShot`, and a test doing it twice raced its own
241
- * per-test timeout on a slower box. Absent is `Bun.sleep`: production waits for real.
242
- */
243
- readonly sleep?: ((ms: number) => Promise<void>) | undefined;
244
- }
245
-
246
- /** Nothing here may replace the failure that caused it, so a teardown throw is swallowed. */
247
- const quietly = async (stop: () => Promise<void>): Promise<void> => {
248
- await stop().catch(() => undefined);
249
- };
250
-
251
- /**
252
- * Boot (or find) the server, photograph one route, write both artifacts. The driver and the boot
253
- * are ARGUMENTS: `bun test` drives this with `fakeBrowser()` and a stub server, so the whole
254
- * command is proved on a machine with no Chrome — which this command is explicitly excluded from
255
- * the gate for needing.
256
- */
257
- export async function runShot(options: ShotRun): Promise<ShotArtifacts> {
258
- const server = await options.boot();
259
- const sleep = options.sleep ?? ((ms: number): Promise<void> => Bun.sleep(ms));
260
- let session: ShotSession | undefined;
261
- try {
262
- const requestedUrl = new URL(options.route, server.url).toString();
263
- session = await options.driver.open({
264
- name: 'x shot',
265
- // The host the picture is of, plus whatever the caller named. Never `*`: a headless browser
266
- // inside your network is the widest SSRF surface an app can own, and a screenshot command is
267
- // not the place to open it by default. Every refusal lands in the verdict's `refused` count.
268
- rules: { allowHosts: allowHostsFrom(server.url, options.extraHosts) },
269
- clock: systemClock,
270
- timeoutMs: options.timeoutMs,
271
- ...(options.viewport === undefined ? {} : { viewport: options.viewport }),
272
- ...(options.acceptLanguage === undefined
273
- ? {}
274
- : { headers: acceptLanguageHeaders(options.acceptLanguage) }),
275
- ...(options.cookies === undefined || options.cookies.length === 0
276
- ? {}
277
- : { cookies: shotCookies(options.cookies, new URL(server.url).toString()) }),
278
- });
279
- const page = session.page;
280
- if (options.colorScheme !== undefined) {
281
- await page.colorScheme(options.colorScheme);
282
- const choice = themeChoiceExpression(options.colorScheme);
283
- if (choice !== undefined) await page.prepare(choice);
284
- }
285
- await page.goto(requestedUrl, { timeout: options.timeoutMs });
286
- // Read NOW as well as at capture: the network ring is bounded, and a page that fires a few
287
- // hundred requests while it settles evicts the document entry the verdict needs.
288
- const landedStatus = documentStatus(page.network(), page.url());
289
- if (options.settleMs > 0) await sleep(options.settleMs);
290
- // The probe may legitimately answer nothing — a page that refuses evaluation, a driver with no
291
- // JS engine. `null` says so; a `0` would read as "the route renders no islands", which is a
292
- // different and much more alarming claim.
293
- const probe = (): Promise<IslandCount | null> =>
294
- page
295
- .evaluate(ISLAND_PROBE)
296
- .then(parseIslandProbe)
297
- .catch(() => null);
298
- // The same budget again, and deliberately no new flag: `settleMs` is the deadline at which the
299
- // runtime CALLS `import()`, so a mount gets exactly as long to settle as the runtime got to
300
- // start it — and `--settle 0`, which asks for no wait, still gets none.
301
- const settle = (): Promise<IslandCount | null> =>
302
- settleIslands(probe, { windowMs: options.settleMs, pollMs: SETTLE_POLL_MS, sleep });
303
- let islands = await settle();
304
- if (options.act !== undefined) {
305
- await options.act(page, async () => {
306
- islands = await settle();
307
- return islands;
308
- });
309
- }
310
- const bytes = await page.screenshot({ fullPage: options.fullPage });
311
- // Read AFTER the capture, so an error logged while the page settled is in the verdict that
312
- // ships with the picture it explains.
313
- const verdict = buildVerdict({
314
- route: options.route,
315
- requestedUrl,
316
- finalUrl: page.url(),
317
- server: server.origin,
318
- capturedAt: (options.now ?? (() => new Date()))().toISOString(),
319
- screenshot: SHOT_IMAGE,
320
- bytes,
321
- console: page.console(),
322
- pageErrors: page.pageErrors(),
323
- pageErrorsDropped: page.pageErrorsDropped(),
324
- network: page.network(),
325
- networkDropped: page.networkDropped(),
326
- islands,
327
- landedStatus,
328
- ...(options.expectStatus === undefined ? {} : { expectStatus: options.expectStatus }),
329
- });
330
- mkdirSync(options.outDir, { recursive: true });
331
- const image = join(options.outDir, SHOT_IMAGE);
332
- const verdictFile = join(options.outDir, SHOT_VERDICT);
333
- await Bun.write(image, bytes);
334
- await Bun.write(verdictFile, `${JSON.stringify(verdictJson(verdict), null, 2)}\n`);
335
- return { verdict, image, verdictFile };
336
- } finally {
337
- // Bound to a const: narrowing a `let` does not survive into the closure below, and the session
338
- // has to be closed from inside one so a teardown throw cannot replace the real failure.
339
- const open = session;
340
- if (open !== undefined) await quietly(() => open.close());
341
- await quietly(() => server.stop());
342
- }
343
- }
344
-
345
87
  /**
346
88
  * Where the artifacts land. A relative `--out` is a path the caller typed from where they stand,
347
89
  * so it resolves against the cwd — `x build --out`'s rule. Against the app root it landed
@@ -2,7 +2,7 @@
2
2
  // read it without loading `cmd-test.ts`, which `registry.ts` imports only when the command runs.
3
3
 
4
4
  import { TEST_TYPES } from '@ultimat3/testing/test-types';
5
- import { DEFAULT_BASE } from './affected';
5
+ import { DEFAULT_BASE_HELP } from './affected-base';
6
6
  import type { CommandSpec } from './parse';
7
7
  import {
8
8
  BUDGET_RULE,
@@ -60,7 +60,7 @@ export const testSpec: CommandSpec = {
60
60
  {
61
61
  name: 'base',
62
62
  type: 'string',
63
- summary: `--affected: git ref to diff against, merge-base style (default: ${DEFAULT_BASE})`,
63
+ summary: `--affected: git ref to diff against, merge-base style (default: ${DEFAULT_BASE_HELP})`,
64
64
  },
65
65
  {
66
66
  name: 'seed',
@@ -1,7 +1,7 @@
1
1
  // `x verify`'s declaration, apart from its body: the parser, `x help` and the `errors` step
2
2
  // read it without loading `cmd-verify.ts`, which `registry.ts` imports only when the command runs.
3
3
 
4
- import { DEFAULT_BASE } from './affected';
4
+ import { DEFAULT_BASE_HELP } from './affected-base';
5
5
  import type { CommandSpec } from './parse';
6
6
  import { BUDGET_RULE, WORKER_BYTES, WORKER_CEILING, WORKER_FLOOR } from './test-workers';
7
7
 
@@ -45,7 +45,7 @@ export const verifySpec: CommandSpec = {
45
45
  name: 'base',
46
46
  type: 'string',
47
47
  subcommands: ['run'],
48
- summary: `with --changed: git ref to diff against, merge-base style, as x affected reads it (default: ${DEFAULT_BASE})`,
48
+ summary: `with --changed: git ref to diff against, merge-base style, as x affected reads it (default: ${DEFAULT_BASE_HELP})`,
49
49
  },
50
50
  {
51
51
  name: 'dirty',
@@ -0,0 +1,38 @@
1
+ // The X_* codes of the `package-shape` and `filesize` steps — what a workspace owes the repo it lives
2
+ // in — split out of `error-codes.ts` at its 500-line ceiling, as `error-codes-shot.ts` was. That
3
+ // file folds these into the CLI's one owned union and registers them in its one call.
4
+
5
+ /** Codes the workspace-shape rules declare and own. */
6
+ export const CLI_PACKAGE_ERROR_CODES = [
7
+ 'X_FILE_TOO_LONG',
8
+ 'X_PACKAGE_SHAPE',
9
+ // The build graph's own membership rule. `tsc -b` compiles referenced projects and nothing
10
+ // else, so a workspace no root reference names is one the `typecheck` step passes over without
11
+ // reading — the hole that let `scripts/` hold seven type errors under a green gate.
12
+ 'X_PACKAGE_UNREFERENCED',
13
+ 'X_RELEASE_VERSION_SKEW',
14
+ 'X_WORKSPACE_DEP_UNDECLARED',
15
+ // Two module instances of a registry-holding package inside ONE app's `node_modules`. Its own
16
+ // code and not the registry's (`X_CATALOG_UNREGISTERED`, `X_PERMISSION_UNKNOWN`): those carry a
17
+ // source-level fix, and an agent following it here edits a file that is already right — the
18
+ // repair is an install, and only `duplicate-packages.ts` can see that.
19
+ 'X_PACKAGE_DUPLICATED',
20
+ 'X_PACKAGE_TEST_ONLY_SHIPPED',
21
+ // A registry import only a SIBLING declares: hoisting resolves it until a clean install does not.
22
+ 'X_WORKSPACE_EXTERNAL_DEP_UNDECLARED',
23
+ ] as const;
24
+
25
+ export type CliPackageErrorCode = (typeof CLI_PACKAGE_ERROR_CODES)[number];
26
+
27
+ /** Their titles, typed over the list above so a code without one is a build error. */
28
+ export const CLI_PACKAGE_ERROR_TITLES: Readonly<Record<CliPackageErrorCode, string>> = {
29
+ X_FILE_TOO_LONG: 'a source file is over 500 lines',
30
+ X_PACKAGE_SHAPE: 'a workspace package is missing a contract file',
31
+ X_PACKAGE_UNREFERENCED: 'a published workspace is not in the root tsconfig build graph',
32
+ X_RELEASE_VERSION_SKEW: 'a workspace is not at the lockstep version',
33
+ X_WORKSPACE_DEP_UNDECLARED: 'a workspace imports another workspace it does not declare',
34
+ X_PACKAGE_DUPLICATED: 'two copies of one registry-holding framework package are installed',
35
+ X_PACKAGE_TEST_ONLY_SHIPPED: 'a test-only module ships in the tarball',
36
+ X_WORKSPACE_EXTERNAL_DEP_UNDECLARED:
37
+ 'a workspace imports a registry package that neither it nor the app root declares',
38
+ };
@@ -5,6 +5,8 @@
5
5
  import { registerErrorCodes } from '@ultimat3/core';
6
6
  import type { CliBoundaryErrorCode } from './error-codes-boundary';
7
7
  import { CLI_BOUNDARY_ERROR_CODES, CLI_BOUNDARY_ERROR_TITLES } from './error-codes-boundary';
8
+ import type { CliPackageErrorCode } from './error-codes-package';
9
+ import { CLI_PACKAGE_ERROR_CODES, CLI_PACKAGE_ERROR_TITLES } from './error-codes-package';
8
10
  import type { CliShotErrorCode } from './error-codes-shot';
9
11
  import { CLI_SHOT_ERROR_CODES, CLI_SHOT_ERROR_TITLES } from './error-codes-shot';
10
12
  import type { CliToolingErrorCode } from './error-codes-tooling';
@@ -51,13 +53,6 @@ export const CLI_OWNED_ERROR_CODES = [
51
53
  // repo already ran it, in which case the suite was deleted and the gate would otherwise print
52
54
  // one more green line for it.
53
55
  'X_VERIFY_SUITE_VANISHED',
54
- 'X_FILE_TOO_LONG',
55
- 'X_PACKAGE_SHAPE',
56
- // The build graph's own membership rule. `tsc -b` compiles referenced projects and nothing
57
- // else, so a workspace no root reference names is one the `typecheck` step passes over without
58
- // reading — the hole that let `scripts/` hold seven type errors under a green gate.
59
- 'X_PACKAGE_UNREFERENCED',
60
- 'X_RELEASE_VERSION_SKEW',
61
56
  // The framework's own tables, refused by name rather than by the driver's rejection: a raw
62
57
  // `permission denied for schema public` says which statement failed and neither which framework
63
58
  // table it was creating nor which package wants it.
@@ -153,12 +148,6 @@ export const CLI_OWNED_ERROR_CODES = [
153
148
  // CLI's problem alone, and core would have no `fix:` to offer for one.
154
149
  'X_SECRETS_EDITOR_MISSING',
155
150
  'X_SECRETS_EDIT_FAILED',
156
- 'X_WORKSPACE_DEP_UNDECLARED',
157
- // Two module instances of a registry-holding package inside ONE app's `node_modules`. Its own
158
- // code and not the registry's (`X_CATALOG_UNREGISTERED`, `X_PERMISSION_UNKNOWN`): those carry a
159
- // source-level fix, and an agent following it here edits a file that is already right — the
160
- // repair is an install, and only `duplicate-packages.ts` can see that.
161
- 'X_PACKAGE_DUPLICATED',
162
151
  'X_GH_UNAVAILABLE',
163
152
  'X_GH_NOT_AUTHENTICATED',
164
153
  'X_GH_COMMAND_FAILED',
@@ -198,7 +187,6 @@ export const CLI_OWNED_ERROR_CODES = [
198
187
  'X_PERMISSION_BORROWED',
199
188
  'X_ERROR_CODE_UNTHROWN_STALE',
200
189
  'X_DEV_STATE_UNWRITABLE',
201
- 'X_PACKAGE_TEST_ONLY_SHIPPED',
202
190
  'X_ISLAND_MODULE_DUPLICATED',
203
191
  'X_BACKFILL_SLICE_ENTITY',
204
192
  'X_LAYOUT_SIBLING_MODULE',
@@ -284,6 +272,7 @@ export const CLI_BORROWED_ERROR_CODES = [
284
272
  export const CLI_ERROR_CODES = [
285
273
  ...CLI_OWNED_ERROR_CODES,
286
274
  ...CLI_BOUNDARY_ERROR_CODES,
275
+ ...CLI_PACKAGE_ERROR_CODES,
287
276
  ...CLI_SHOT_ERROR_CODES,
288
277
  ...CLI_TOOLING_ERROR_CODES,
289
278
  ...CLI_BORROWED_ERROR_CODES,
@@ -294,6 +283,7 @@ type CliListedErrorCode = (typeof CLI_OWNED_ERROR_CODES)[number];
294
283
  export type CliOwnedErrorCode =
295
284
  | CliListedErrorCode
296
285
  | CliBoundaryErrorCode
286
+ | CliPackageErrorCode
297
287
  | CliShotErrorCode
298
288
  | CliToolingErrorCode;
299
289
  export type CliErrorCode = (typeof CLI_ERROR_CODES)[number];
@@ -333,10 +323,6 @@ export const CLI_ERROR_TITLES: Readonly<Record<CliListedErrorCode, string>> = {
333
323
  X_LINT_FAILED: 'Biome failed',
334
324
  X_TEST_FAILED: 'a test type failed',
335
325
  X_VERIFY_SUITE_VANISHED: 'a step the committed floor requires had nothing left to check',
336
- X_FILE_TOO_LONG: 'a source file is over 500 lines',
337
- X_PACKAGE_SHAPE: 'a workspace package is missing a contract file',
338
- X_PACKAGE_UNREFERENCED: 'a published workspace is not in the root tsconfig build graph',
339
- X_RELEASE_VERSION_SKEW: 'a workspace is not at the lockstep version',
340
326
  X_MANIFEST_STALE: 'openapi.json is stale',
341
327
  X_MANIFEST_MISSING: 'the app ships no x.manifest.json',
342
328
  X_BUDGET_UNMEASURED: 'a route declares a budget the build never measured',
@@ -370,8 +356,6 @@ export const CLI_ERROR_TITLES: Readonly<Record<CliListedErrorCode, string>> = {
370
356
  X_CLI_FLAG_UNREAD: 'a command declares a flag no code reads',
371
357
  X_SECRETS_EDITOR_MISSING: 'no $EDITOR to open the decrypted secrets in',
372
358
  X_SECRETS_EDIT_FAILED: 'the editor exited non-zero, so nothing was resealed',
373
- X_WORKSPACE_DEP_UNDECLARED: 'a workspace imports another workspace it does not declare',
374
- X_PACKAGE_DUPLICATED: 'two copies of one registry-holding framework package are installed',
375
359
  X_GH_UNAVAILABLE: 'the GitHub CLI is not runnable from here',
376
360
  X_GH_NOT_AUTHENTICATED: 'gh holds no credentials for this host',
377
361
  X_GH_COMMAND_FAILED: 'a gh invocation exited non-zero',
@@ -420,7 +404,6 @@ export const CLI_ERROR_TITLES: Readonly<Record<CliListedErrorCode, string>> = {
420
404
  X_ERROR_CODE_UNTHROWN_STALE:
421
405
  'a code UNTHROWN_CODES lists as thrown by nothing is thrown again — delete it from UNTHROWN_CODES in packages/cli/src/unthrown-codes.ts',
422
406
  X_DEV_STATE_UNWRITABLE: 'x dev cannot claim its state directory',
423
- X_PACKAGE_TEST_ONLY_SHIPPED: 'a test-only module ships in the tarball',
424
407
  X_ISLAND_MODULE_DUPLICATED: 'An island chunk bundles one module more than once',
425
408
  X_BACKFILL_SLICE_ENTITY: 'the slice holds no entity a generated backfill can sweep',
426
409
  X_LAYOUT_SIBLING_MODULE: 'a primitive module beside its directory',
@@ -484,6 +467,7 @@ registerErrorCodes(
484
467
  Object.entries({
485
468
  ...CLI_ERROR_TITLES,
486
469
  ...CLI_BOUNDARY_ERROR_TITLES,
470
+ ...CLI_PACKAGE_ERROR_TITLES,
487
471
  ...CLI_SHOT_ERROR_TITLES,
488
472
  ...CLI_TOOLING_ERROR_TITLES,
489
473
  }).map(([code, title]) => [code, { title }]),
package/src/mcp-errors.ts CHANGED
@@ -408,6 +408,8 @@ const CLI_FIXES: Readonly<Record<CliErrorCode, string>> = {
408
408
  'x verify --only manifest --json # after exporting partitions() from @ultimat3/jobs in a module listed under jobs in apps/web/api/index.ts, and its .schedule under tasks',
409
409
  X_BOUNDARY_LOADER_IMPORT:
410
410
  'export const api = defineApi({ actions: [yourActions], queries: [yourQueries] }); # in apps/web/api/index.ts — list the module there, then delete the loader import',
411
+ X_WORKSPACE_EXTERNAL_DEP_UNDECLARED:
412
+ 'x verify --only package-shape --json # each finding carries its own `bun add <package> --cwd <workspace>` line',
411
413
  };
412
414
 
413
415
  const isCliCode = (code: string): code is CliErrorCode =>
@@ -37,6 +37,10 @@ export const GATE_MESSAGES = {
37
37
  'cli.ci.tested.api': 'not tested: GitHub did not answer ({detail}) — a full run',
38
38
  'cli.ci.tested.sha':
39
39
  'not tested: no GITHUB_SHA, and git rev-parse HEAD named no commit — a full run',
40
+ // A review bot that said it did NOT review leaves no thread, so its silence reads as a clean
41
+ // review unless a line says otherwise. `notice` is the same fact once the bot reviewed after it.
42
+ 'cli.pr.bot.blocked': ' {login} did not review: {excerpt} ({kind}, {at}) — {url}',
43
+ 'cli.pr.bot.notice': ' {login} posted a {kind} notice at {at}, then reviewed at {reviewed}',
40
44
  'cli.pr.body.truncated': ' … {hidden} more line(s) — re-run with --full',
41
45
  /** The line of a thread whose anchor GitHub answers null for — a value, not a column key. */
42
46
  'cli.pr.line.unknown': '-',
@@ -47,6 +51,8 @@ export const GATE_MESSAGES = {
47
51
  'thread {id} is marked resolved on GitHub — that records the conversation, not that the finding is fixed',
48
52
  'cli.pr.review.count':
49
53
  '{unresolved} unresolved and {resolved} resolved review thread(s) on {repo}#{pr}',
54
+ 'cli.pr.review.activity':
55
+ ' {reviews} review(s), {comments} PR comment(s), {bots} review bot(s) — bodies in --json',
50
56
  'cli.pr.review.current': ' submitted against the current head {head}',
51
57
  'cli.pr.review.decision': ' review: {decision} by {author} at {submitted}',
52
58
  'cli.pr.review.none': 'no review thread is anchored to a line on {repo}#{pr}',