@ultimat3/cli 31.0.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.
Files changed (49) hide show
  1. package/CLAUDE.md +6 -1
  2. package/package.json +29 -29
  3. package/src/affected-base.ts +51 -0
  4. package/src/affected.ts +29 -10
  5. package/src/binding-names.ts +124 -0
  6. package/src/browser-transport.ts +28 -0
  7. package/src/ci-log.ts +76 -13
  8. package/src/cmd-affected-spec.ts +7 -3
  9. package/src/cmd-affected.ts +91 -77
  10. package/src/cmd-ci.ts +6 -3
  11. package/src/cmd-doctor.ts +8 -0
  12. package/src/cmd-exercise.ts +13 -1
  13. package/src/cmd-pr-spec.ts +1 -1
  14. package/src/cmd-pr.ts +72 -1
  15. package/src/cmd-shot.ts +13 -271
  16. package/src/cmd-test-spec.ts +2 -2
  17. package/src/cmd-upgrade.ts +28 -4
  18. package/src/cmd-verify-spec.ts +2 -2
  19. package/src/doctor-typescript.ts +31 -0
  20. package/src/error-codes-package.ts +38 -0
  21. package/src/error-codes.ts +7 -21
  22. package/src/mcp-errors-shot.ts +49 -0
  23. package/src/mcp-errors.ts +7 -41
  24. package/src/measure-scope.ts +17 -4
  25. package/src/messages-gate.ts +6 -0
  26. package/src/messages-upgrade.ts +2 -0
  27. package/src/offline-ports.ts +106 -0
  28. package/src/output.ts +21 -3
  29. package/src/pr-activity.ts +150 -0
  30. package/src/pr-bots.ts +109 -0
  31. package/src/pr-threads.ts +7 -2
  32. package/src/prerender.ts +2 -2
  33. package/src/runtime-storage-boot.ts +41 -7
  34. package/src/shot-gpu.ts +61 -0
  35. package/src/shot-route.ts +95 -0
  36. package/src/shot-run.ts +189 -0
  37. package/src/shot-verdict.ts +5 -0
  38. package/src/templates/scaffold-repo.ts +2 -1
  39. package/src/templates/sign-in-oidc.ts +24 -9
  40. package/src/transport-calls.ts +7 -3
  41. package/src/transport-values.ts +59 -0
  42. package/src/tsconfig-aliases.ts +85 -0
  43. package/src/typescript-floor.ts +83 -0
  44. package/src/upgrade-report.ts +8 -1
  45. package/src/verify-changed-scope.ts +3 -2
  46. package/src/verify-checks.ts +2 -0
  47. package/src/workspace-external-deps.ts +164 -0
  48. package/wiki/CLI-Reference.md +12 -8
  49. package/wiki/Upgrading.md +24 -5
@@ -14,6 +14,7 @@ import { msg } from './messages';
14
14
  import type { CommandResult, JsonValue } from './output';
15
15
  import { flagBool } from './parse';
16
16
  import { renderTable } from './table';
17
+ import { writeLine } from './write-line';
17
18
 
18
19
  const HEADER = ['workspace', 'dir'] as const;
19
20
 
@@ -36,81 +37,94 @@ export const AFFECTED_MESSAGE_KEYS = [
36
37
  'cli.affected.testsAll',
37
38
  ] as const;
38
39
 
39
- export const affectedCommand: CliCommand = {
40
- spec: affectedSpec,
41
- async run(ctx: CommandContext): Promise<CommandResult> {
42
- // The one resolver `x test --affected` narrows with, so this command reports exactly what that
43
- // one runs. It reads `--base` before git is spawned (a malformed ref must not cost a
44
- // subprocess) and takes the diff at the CHECKOUT root, which is what git prints paths against.
45
- const { selection, root, plan } = await affectedScope({
46
- runner: ctx.runner,
47
- cwd: ctx.cwd,
48
- args: ctx.args,
49
- command: 'affected',
50
- });
51
- const params = { base: selection.base, changed: plan.changed.length };
52
- const tests = await appTestScope(ctx.cwd, root, plan.changed);
53
- const table = renderTable(
54
- HEADER,
55
- plan.workspaces.map((workspace) => [workspace.name, workspace.dir]),
56
- ).map((line) => ` ${line}`);
57
- const data: JsonValue = {
58
- base: selection.base,
59
- dirty: selection.dirty,
60
- root,
61
- changed: [...plan.changed],
62
- ignored: [...plan.ignored],
63
- rootWide: [...plan.rootWide],
64
- workspaces: plan.workspaces.map((workspace) => ({
65
- name: workspace.name,
66
- dir: workspace.dir,
67
- })),
68
- paths: plan.workspaces.map((workspace) => workspace.dir),
40
+ /**
41
+ * `--paths` is for `bun test $(x affected --paths)`, so its stdout is the directories and nothing
42
+ * else: each one written here, on fd 1, and the rest of the render — the notes and the `✓` summary,
43
+ * which a shell would split into bogus arguments — sent to fd 2 by `stream: 'stderr'`. The one
44
+ * write a command makes itself: `CommandResult` has no "bare stdout" channel, and the one sink
45
+ * `dispatch` picks per result cannot split a result across both fds. `writeOut` is injectable so a
46
+ * test reads fd 1 exactly as a shell would.
47
+ */
48
+ export function createAffectedCommand(writeOut: (line: string) => void = writeLine): CliCommand {
49
+ return { spec: affectedSpec, run: (ctx) => runAffected(ctx, writeOut) };
50
+ }
51
+
52
+ async function runAffected(
53
+ ctx: CommandContext,
54
+ writeOut: (line: string) => void,
55
+ ): Promise<CommandResult> {
56
+ // The one resolver `x test --affected` narrows with, so this command reports exactly what that
57
+ // one runs. It reads `--base` before git is spawned (a malformed ref must not cost a
58
+ // subprocess) and takes the diff at the CHECKOUT root, which is what git prints paths against.
59
+ const { selection, root, plan } = await affectedScope({
60
+ runner: ctx.runner,
61
+ cwd: ctx.cwd,
62
+ args: ctx.args,
63
+ command: 'affected',
64
+ });
65
+ const params = { base: selection.base, changed: plan.changed.length };
66
+ const tests = await appTestScope(ctx.cwd, root, plan.changed);
67
+ const table = renderTable(
68
+ HEADER,
69
+ plan.workspaces.map((workspace) => [workspace.name, workspace.dir]),
70
+ ).map((line) => ` ${line}`);
71
+ const data: JsonValue = {
72
+ base: selection.base,
73
+ dirty: selection.dirty,
74
+ root,
75
+ changed: [...plan.changed],
76
+ ignored: [...plan.ignored],
77
+ rootWide: [...plan.rootWide],
78
+ workspaces: plan.workspaces.map((workspace) => ({
79
+ name: workspace.name,
80
+ dir: workspace.dir,
81
+ })),
82
+ paths: plan.workspaces.map((workspace) => workspace.dir),
83
+ ...(tests === undefined
84
+ ? {}
85
+ : {
86
+ tests: {
87
+ app: tests.app,
88
+ all: tests.all,
89
+ forcing: [...tests.forcing],
90
+ files: [...tests.tests],
91
+ },
92
+ }),
93
+ };
94
+ const bare = flagBool(ctx.args, 'paths') && !ctx.args.json;
95
+ if (bare) for (const workspace of plan.workspaces) writeOut(workspace.dir);
96
+ return {
97
+ ...(bare ? { stream: 'stderr' as const } : {}),
98
+ // An empty answer is a fact, not a failure: a `.md`-only diff genuinely re-checks nothing,
99
+ // and reporting it red would fail a build for editing a doc. The count is in the summary and
100
+ // `data.changed`/`data.ignored` say what was looked at, so "green because nothing is
101
+ // affected" is never mistaken for "green because everything passed".
102
+ ok: true,
103
+ command: 'affected',
104
+ summary:
105
+ plan.workspaces.length === 0
106
+ ? msg('cli.affected.none', params)
107
+ : msg('cli.affected.count', { ...params, count: plan.workspaces.length }),
108
+ lines: [
109
+ ...(selection.dirty ? [msg('cli.affected.dirty')] : []),
69
110
  ...(tests === undefined
70
- ? {}
71
- : {
72
- tests: {
73
- app: tests.app,
74
- all: tests.all,
75
- forcing: [...tests.forcing],
76
- files: [...tests.tests],
77
- },
78
- }),
79
- };
80
- return {
81
- // An empty answer is a fact, not a failure: a `.md`-only diff genuinely re-checks nothing,
82
- // and reporting it red would fail a build for editing a doc. The count is in the summary and
83
- // `data.changed`/`data.ignored` say what was looked at, so "green because nothing is
84
- // affected" is never mistaken for "green because everything passed".
85
- ok: true,
86
- command: 'affected',
87
- summary:
88
- plan.workspaces.length === 0
89
- ? msg('cli.affected.none', params)
90
- : msg('cli.affected.count', { ...params, count: plan.workspaces.length }),
91
- lines: [
92
- ...(selection.dirty ? [msg('cli.affected.dirty')] : []),
93
- ...(tests === undefined
94
- ? []
95
- : [
96
- tests.all
97
- ? msg('cli.affected.testsAll', {
98
- files: `${tests.forcing.slice(0, 3).join(', ')}${tests.forcing.length > 3 ? ` (+${tests.forcing.length - 3})` : ''}`,
99
- })
100
- : msg('cli.affected.tests', { count: tests.tests.length }),
101
- ]),
102
- ...(plan.rootWide.length === 0
103
- ? []
104
- : [msg('cli.affected.rootWide', { files: plan.rootWide.join(', ') })]),
105
- ...(plan.workspaces.length === 0
106
- ? []
107
- : // `--paths` changes only what the human sees; `--json` carries both projections on
108
- // every run, so the two renderers can never state different sets.
109
- flagBool(ctx.args, 'paths')
110
- ? plan.workspaces.map((workspace) => workspace.dir)
111
- : table),
112
- ],
113
- data,
114
- };
115
- },
116
- };
111
+ ? []
112
+ : [
113
+ tests.all
114
+ ? msg('cli.affected.testsAll', {
115
+ files: `${tests.forcing.slice(0, 3).join(', ')}${tests.forcing.length > 3 ? ` (+${tests.forcing.length - 3})` : ''}`,
116
+ })
117
+ : msg('cli.affected.tests', { count: tests.tests.length }),
118
+ ]),
119
+ ...(plan.rootWide.length === 0
120
+ ? []
121
+ : [msg('cli.affected.rootWide', { files: plan.rootWide.join(', ') })]),
122
+ // `--paths` changes only what the human sees; `--json` carries both projections on every
123
+ // run, so the two renderers can never state different sets.
124
+ ...(plan.workspaces.length === 0 || bare ? [] : table),
125
+ ],
126
+ data,
127
+ };
128
+ }
129
+
130
+ export const affectedCommand: CliCommand = createAffectedCommand();
package/src/cmd-ci.ts CHANGED
@@ -275,9 +275,12 @@ async function inspect(
275
275
  // this repair closes — so when the log had nothing, the finding reads nothing.
276
276
  findings.push({
277
277
  ...finding,
278
- // Fenced and tagged: the log is foreign text, and a `fix:` reconstructed from it is the
279
- // log author's instruction, not this CLI's. `commentBlock` is `x pr review`'s fence.
280
- fix: commentBlock(`ci-log ${name}`, [finding.fix]).join('\n'),
278
+ // Tagged, never fenced inside the value: the log is foreign text, and a `fix:` read from it
279
+ // is the log author's instruction, not this CLI's — `source` says so to a machine, and
280
+ // `output-findings.ts` never rewrites it into a runnable `bunx x`. A `<comment>` fence
281
+ // INSIDE `fix` reached the human render as one line of markup and literal `\n` (31.0
282
+ // field report), so the value stays the clean text and the job rides on `meta.job`.
283
+ meta: { ...finding.meta, job: name },
281
284
  source: 'ci-log',
282
285
  });
283
286
  }
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);
@@ -7,7 +7,7 @@ export const PR_SUBCOMMANDS = ['review', 'resolve', 'reply'] as const;
7
7
 
8
8
  export const prSpec: CommandSpec = {
9
9
  name: 'pr',
10
- summary: 'inline review threads: list them with their ids, resolve one, reply in one',
10
+ summary: 'reviews, comments, bots that did not review, and inline threads; resolve or reply',
11
11
  usage:
12
12
  'x pr review [--pr <n>] [--repo owner/name] [--all] [--full] | x pr resolve <thread-id> | x pr reply <thread-id> --body "…"',
13
13
  subcommands: PR_SUBCOMMANDS,
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);