@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/output.ts CHANGED
@@ -33,8 +33,10 @@ export interface Finding {
33
33
  readonly at?: string;
34
34
  /**
35
35
  * Where the finding's TEXT came from, when not from this process. `'ci-log'` is `x ci` reading
36
- * a finding back out of a CI log that anyone who can push a branch writes: its `fix` is fenced
37
- * and must never be run as this CLI's own instruction.
36
+ * a finding back out of a CI log that anyone who can push a branch writes: its `fix` is the
37
+ * log's instruction, never this CLI's, and is never rewritten into a runnable one. The value
38
+ * stays the clean text — the provenance is this field, `meta.job`, and the `[from=ci-log …]`
39
+ * marker `renderFinding` prints on the head; never markup inside `fix`.
38
40
  */
39
41
  readonly source?: 'ci-log';
40
42
  /**
@@ -203,7 +205,7 @@ export function renderFinding(finding: Finding, indent = ''): string {
203
205
  : undefined;
204
206
  const stepLabel = typeof stepValue === 'string' ? ` [step=${singleLine(stepValue)}]` : '';
205
207
  const pathLabel = finding.at === undefined ? '' : ` (${singleLine(finding.at)})`;
206
- const head = `${code}${pathLabel}${stepLabel}`;
208
+ const head = `${code}${pathLabel}${stepLabel}${fromLabel(finding)}`;
207
209
  const lines = [
208
210
  `${indent}${head}`,
209
211
  `${indent} cause: ${singleLine(finding.cause)}`,
@@ -213,6 +215,22 @@ export function renderFinding(finding: Finding, indent = ''): string {
213
215
  return lines.join('\n');
214
216
  }
215
217
 
218
+ /**
219
+ * The provenance marker for a finding read out of a CI log, printed LAST on the head so the
220
+ * human render still says which findings came from outside (`x ci`) while `fix` stays the clean
221
+ * command. Brackets in a job name become parentheses: the marker must stay one bracketed token,
222
+ * and `ci-log`'s `LOCATOR` stands aside for exactly that token.
223
+ */
224
+ function fromLabel(finding: Finding): string {
225
+ if (finding.source !== 'ci-log') return '';
226
+ const job = finding.meta?.['job'];
227
+ const named =
228
+ typeof job === 'string' && job !== ''
229
+ ? ` ${singleLine(job).replaceAll('[', '(').replaceAll(']', ')')}`
230
+ : '';
231
+ return ` [from=ci-log${named}]`;
232
+ }
233
+
216
234
  /** Same format, but titled with the error's own summary line when it has one. */
217
235
  export function renderUltimateError(error: UltimateErrorShape, indent = ''): string {
218
236
  const summary = summaryOf(error);
@@ -0,0 +1,150 @@
1
+ // The rest of a pull request's conversation, beside its inline threads: every review with its
2
+ // verdict and body, and every ISSUE comment. A bot that said "I did not review this" says it in one
3
+ // of these two places and never in a thread, so `x pr review` asks for both in the same round trip.
4
+
5
+ import { t } from '@ultimat3/schema';
6
+
7
+ /** The newest reviews, and the newest issue comments, one page each. */
8
+ export const ACTIVITY_PAGE = 50;
9
+
10
+ /**
11
+ * The fragment `REVIEW_QUERY` (`pr-threads.ts`) splices into its `pullRequest` selection. `last`,
12
+ * not `first`: a long pull request's oldest conversation is the least likely to still matter, and
13
+ * a bot's "review limit" notice is by construction among the newest.
14
+ */
15
+ export const ACTIVITY_FIELDS =
16
+ `reviews(last:${ACTIVITY_PAGE}){totalCount nodes{id state body submittedAt url ` +
17
+ 'author{login __typename} commit{oid}}} ' +
18
+ `comments(last:${ACTIVITY_PAGE}){totalCount nodes{id body createdAt updatedAt url ` +
19
+ 'author{login __typename}}}';
20
+
21
+ const ACTOR = t.nullable(t.object({ login: t.string, __typename: t.string }));
22
+
23
+ /** The two connections, as `REVIEW_RESPONSE` declares them inside `pullRequest`. */
24
+ export const ACTIVITY_SCHEMA = {
25
+ reviews: t.object({
26
+ totalCount: t.number,
27
+ nodes: t.array(
28
+ t.object({
29
+ id: t.string,
30
+ state: t.string,
31
+ body: t.string,
32
+ submittedAt: t.nullable(t.string),
33
+ url: t.string,
34
+ author: ACTOR,
35
+ commit: t.nullable(t.object({ oid: t.string })),
36
+ }),
37
+ ),
38
+ }),
39
+ comments: t.object({
40
+ totalCount: t.number,
41
+ nodes: t.array(
42
+ t.object({
43
+ id: t.string,
44
+ body: t.string,
45
+ createdAt: t.string,
46
+ updatedAt: t.string,
47
+ url: t.string,
48
+ author: ACTOR,
49
+ }),
50
+ ),
51
+ }),
52
+ } as const;
53
+
54
+ /** One submitted review: a verdict (`APPROVED`, `CHANGES_REQUESTED`, `COMMENTED`, …) and its body. */
55
+ export interface PrReviewEntry {
56
+ readonly id: string;
57
+ readonly state: string;
58
+ readonly author: string;
59
+ readonly isBot: boolean;
60
+ readonly submittedAt: string | null;
61
+ readonly commit: string | null;
62
+ /** Submitted against a commit that is no longer the head — the same rule as `PrReview.stale`. */
63
+ readonly stale: boolean;
64
+ readonly url: string;
65
+ readonly body: string;
66
+ }
67
+
68
+ /** One comment on the pull request itself, not anchored to a line. */
69
+ export interface PrIssueComment {
70
+ readonly id: string;
71
+ readonly author: string;
72
+ readonly isBot: boolean;
73
+ readonly createdAt: string;
74
+ /** A bot edits its summary comment in place, so this — not `createdAt` — dates what it says. */
75
+ readonly updatedAt: string;
76
+ readonly url: string;
77
+ readonly body: string;
78
+ }
79
+
80
+ export interface PrActivity {
81
+ readonly reviews: readonly PrReviewEntry[];
82
+ readonly comments: readonly PrIssueComment[];
83
+ /** More reviews exist than one page holds. */
84
+ readonly reviewsTruncated: boolean;
85
+ /** More issue comments exist than one page holds. */
86
+ readonly commentsTruncated: boolean;
87
+ }
88
+
89
+ type Actor = { readonly login: string; readonly __typename: string } | null;
90
+
91
+ /** GitHub answers `null` for a deleted account; the row is kept under the name GitHub shows. */
92
+ const loginOf = (author: Actor): string => author?.login ?? 'ghost';
93
+
94
+ /** GraphQL types an app account `Bot`; a REST-shaped login ends in `[bot]`. Either is a bot. */
95
+ const isBot = (author: Actor): boolean =>
96
+ author !== null && (author.__typename === 'Bot' || author.login.endsWith('[bot]'));
97
+
98
+ interface ActivityInput {
99
+ readonly reviews: {
100
+ readonly totalCount: number;
101
+ readonly nodes: readonly {
102
+ readonly id: string;
103
+ readonly state: string;
104
+ readonly body: string;
105
+ readonly submittedAt: string | null;
106
+ readonly url: string;
107
+ readonly author: Actor;
108
+ readonly commit: { readonly oid: string } | null;
109
+ }[];
110
+ };
111
+ readonly comments: {
112
+ readonly totalCount: number;
113
+ readonly nodes: readonly {
114
+ readonly id: string;
115
+ readonly body: string;
116
+ readonly createdAt: string;
117
+ readonly updatedAt: string;
118
+ readonly url: string;
119
+ readonly author: Actor;
120
+ }[];
121
+ };
122
+ }
123
+
124
+ /** The parsed connections as rows, oldest first — the order the conversation happened in. */
125
+ export function activityOf(pull: ActivityInput, headSha: string): PrActivity {
126
+ return {
127
+ reviews: pull.reviews.nodes.map((review) => ({
128
+ id: review.id,
129
+ state: review.state,
130
+ author: loginOf(review.author),
131
+ isBot: isBot(review.author),
132
+ submittedAt: review.submittedAt,
133
+ commit: review.commit?.oid ?? null,
134
+ stale: review.commit?.oid !== headSha,
135
+ url: review.url,
136
+ body: review.body,
137
+ })),
138
+ comments: pull.comments.nodes.map((comment) => ({
139
+ id: comment.id,
140
+ author: loginOf(comment.author),
141
+ isBot: isBot(comment.author),
142
+ createdAt: comment.createdAt,
143
+ updatedAt: comment.updatedAt,
144
+ url: comment.url,
145
+ body: comment.body,
146
+ })),
147
+ reviewsTruncated: pull.reviews.totalCount > pull.reviews.nodes.length,
148
+ commentsTruncated: pull.comments.totalCount > pull.comments.nodes.length,
149
+ };
150
+ }
package/src/pr-bots.ts ADDED
@@ -0,0 +1,109 @@
1
+ // Which review bots spoke on a pull request, and whether one of them said it did NOT review it. A
2
+ // rate-limited or skipped bot leaves no thread and no verdict, so its silence reads exactly like a
3
+ // clean review unless something reads the notice it posted instead.
4
+
5
+ import type { PrIssueComment, PrReviewEntry } from './pr-activity';
6
+
7
+ export type BotNoticeKind = 'rate-limited' | 'skipped';
8
+
9
+ export interface BotNotice {
10
+ readonly kind: BotNoticeKind;
11
+ /** The notice's own heading or first line, so a reader sees which notice without the body. */
12
+ readonly excerpt: string;
13
+ }
14
+
15
+ export interface BotSummary {
16
+ readonly login: string;
17
+ readonly reviews: number;
18
+ readonly comments: number;
19
+ /** The bot's newest review that is not itself a notice; `null` when it never reviewed. */
20
+ readonly lastReviewAt: string | null;
21
+ /** The newest "did not review" notice it posted, wherever it posted it. */
22
+ readonly notice: (BotNotice & { readonly at: string; readonly url: string }) | null;
23
+ /** A notice exists and no review of the bot's came after it: its review is missing, not clean. */
24
+ readonly blocked: boolean;
25
+ }
26
+
27
+ /**
28
+ * The notices, known by their MARKERS and never by a phrase in prose: a review that discusses
29
+ * "rate limit exceeded" in an upstream API is a review, not a bot refusing to give one.
30
+ * CodeRabbit's own HTML comment tags come first; otherwise the notice is a markdown heading
31
+ * (quoted or not) that BEGINS with the notice's title.
32
+ */
33
+ const MARKERS: readonly { readonly kind: BotNoticeKind; readonly pattern: RegExp }[] = [
34
+ { kind: 'rate-limited', pattern: /<!--[^>]*rate limited by coderabbit\.ai[^>]*-->/i },
35
+ { kind: 'skipped', pattern: /<!--[^>]*skip review by coderabbit\.ai[^>]*-->/i },
36
+ ];
37
+ const HEADINGS: readonly { readonly kind: BotNoticeKind; readonly pattern: RegExp }[] = [
38
+ { kind: 'rate-limited', pattern: /^(?:rate limit exceeded|review limit reached)\b/i },
39
+ { kind: 'skipped', pattern: /^review skipped\b/i },
40
+ ];
41
+
42
+ /** A markdown heading line, quoted or not, as its title text; `undefined` for any other line. */
43
+ const headingOf = (line: string): string | undefined => {
44
+ const match = /^[>\s]*#{1,6}\s+(.+)$/.exec(line);
45
+ return match?.[1]?.replaceAll('*', '').trim();
46
+ };
47
+
48
+ /**
49
+ * The notice an ISSUE COMMENT states, or `null` for every ordinary body. A formal review is never
50
+ * passed here: whatever its body says, a submitted review is the bot having reviewed.
51
+ */
52
+ export function botNotice(body: string): BotNotice | null {
53
+ const headings = body
54
+ .replaceAll('\r\n', '\n')
55
+ .split('\n')
56
+ .flatMap((line) => {
57
+ const title = headingOf(line);
58
+ return title === undefined ? [] : [title];
59
+ });
60
+ for (const title of headings) {
61
+ const rule = HEADINGS.find((candidate) => candidate.pattern.test(title));
62
+ if (rule !== undefined) return { kind: rule.kind, excerpt: title.slice(0, 200) };
63
+ }
64
+ const marker = MARKERS.find((candidate) => candidate.pattern.test(body));
65
+ if (marker === undefined) return null;
66
+ return { kind: marker.kind, excerpt: (headings[0] ?? '').slice(0, 200) };
67
+ }
68
+
69
+ interface Spoken {
70
+ readonly at: string;
71
+ readonly url: string;
72
+ readonly notice: BotNotice | null;
73
+ }
74
+
75
+ const newest = <T extends { readonly at: string }>(rows: readonly T[]): T | null =>
76
+ rows.reduce<T | null>((best, row) => (best === null || row.at > best.at ? row : best), null);
77
+
78
+ /** One row per bot that reviewed or commented, in the order each first appears. */
79
+ export function botsSummary(
80
+ reviews: readonly PrReviewEntry[],
81
+ comments: readonly PrIssueComment[],
82
+ ): readonly BotSummary[] {
83
+ const logins: string[] = [];
84
+ for (const row of [...reviews, ...comments]) {
85
+ if (row.isBot && !logins.includes(row.author)) logins.push(row.author);
86
+ }
87
+ return logins.map((login) => {
88
+ const own = reviews.filter((review) => review.isBot && review.author === login);
89
+ const said = comments.filter((comment) => comment.isBot && comment.author === login);
90
+ // Issue comments only: a submitted review is the bot having reviewed, whatever it says.
91
+ const spoken: readonly Spoken[] = said.map((comment) => ({
92
+ at: comment.updatedAt,
93
+ url: comment.url,
94
+ notice: botNotice(comment.body),
95
+ }));
96
+ const lastReview = newest(own.map((review) => ({ at: review.submittedAt ?? '' })));
97
+ const latest = newest(spoken.filter((entry) => entry.notice !== null));
98
+ const notice =
99
+ latest?.notice == null ? null : { ...latest.notice, at: latest.at, url: latest.url };
100
+ return {
101
+ login,
102
+ reviews: own.length,
103
+ comments: said.length,
104
+ lastReviewAt: lastReview?.at ?? null,
105
+ notice,
106
+ blocked: notice !== null && (lastReview === null || lastReview.at <= notice.at),
107
+ };
108
+ });
109
+ }
package/src/pr-threads.ts CHANGED
@@ -1,12 +1,14 @@
1
1
  // The GraphQL a review lives behind, and the rows it becomes. `gh pr view --comments` shows ISSUE
2
2
  // comments; the findings a reviewer anchored to a line are `reviewThreads`, and the thread id that
3
3
  // resolves one exists in no REST response and in no web URL — this file is where that query stops
4
- // being folklore.
4
+ // being folklore. Reviews and issue comments ride the same document (`pr-activity.ts`).
5
5
 
6
6
  import { t } from '@ultimat3/schema';
7
7
  import type { GhHost } from './gh';
8
8
  import { GhResponseInvalidError, ghGraphql } from './gh';
9
9
  import type { GhRepo } from './gh-target';
10
+ import type { PrActivity } from './pr-activity';
11
+ import { ACTIVITY_FIELDS, ACTIVITY_SCHEMA, activityOf } from './pr-activity';
10
12
 
11
13
  /**
12
14
  * How many threads one page holds. The query is built from it, so the report and the request can
@@ -28,6 +30,7 @@ export const REVIEW_QUERY =
28
30
  'pullRequest(number:$n){number url headRefOid reviewDecision ' +
29
31
  'commits(last:1){nodes{commit{oid committedDate}}} ' +
30
32
  'latestOpinionatedReviews(first:20){nodes{state submittedAt author{login} commit{oid}}} ' +
33
+ `${ACTIVITY_FIELDS} ` +
31
34
  `reviewThreads(first:${THREAD_PAGE}){pageInfo{hasNextPage} nodes{id isResolved isOutdated ` +
32
35
  `path line originalLine comments(first:${COMMENT_PAGE}){totalCount ` +
33
36
  'nodes{author{login} createdAt body}}}}}}}';
@@ -59,6 +62,7 @@ const REVIEW_RESPONSE = t.object({
59
62
  }),
60
63
  ),
61
64
  }),
65
+ ...ACTIVITY_SCHEMA,
62
66
  reviewThreads: t.object({
63
67
  pageInfo: t.object({ hasNextPage: t.boolean }),
64
68
  nodes: t.array(
@@ -118,7 +122,7 @@ export interface PrReview {
118
122
  readonly stale: boolean;
119
123
  }
120
124
 
121
- export interface PrReviewReport {
125
+ export interface PrReviewReport extends PrActivity {
122
126
  readonly repo: string;
123
127
  readonly number: number;
124
128
  readonly url: string;
@@ -201,6 +205,7 @@ export async function fetchReviewReport(
201
205
  headCommittedAt: head?.committedDate ?? null,
202
206
  reviewDecision: pull.reviewDecision,
203
207
  decidingReview: decidingReview(reviews, pull.reviewDecision),
208
+ ...activityOf(pull, pull.headRefOid),
204
209
  truncated: pull.reviewThreads.pageInfo.hasNextPage,
205
210
  threads: orderThreads(
206
211
  pull.reviewThreads.nodes.map((thread) => ({
@@ -0,0 +1,61 @@
1
+ // The GPU backend the photographed page could reach, read from `navigator.gpu` inside the page.
2
+ // A WebGPU canvas that came out blank on a headless machine with no adapter is a fact about the
3
+ // machine, not the app — and a picture alone cannot tell the two apart. Recorded, never gating.
4
+
5
+ import type { StandardSchemaV1 } from '@ultimat3/schema';
6
+ import { t, validate } from '@ultimat3/schema';
7
+ import type { JsonValue } from './output';
8
+
9
+ export interface ShotGpu {
10
+ /** `navigator.gpu` exists — the browser exposes WebGPU at all. */
11
+ readonly api: boolean;
12
+ /** `requestAdapter()` answered an adapter: WebGPU is usable on this page, on this machine. */
13
+ readonly available: boolean;
14
+ /** The adapter's `info` (vendor, architecture, device, description), or `null` with none. */
15
+ readonly adapter: string | null;
16
+ /** A software adapter (SwiftShader and kin): it renders, at a speed no user sees. */
17
+ readonly fallback: boolean;
18
+ }
19
+
20
+ /**
21
+ * An expression, never a closure: `CdpPageLike.evaluate` takes the string form and awaits the
22
+ * promise. `requestAdapter()` is raced against a bound so a browser that never answers cannot
23
+ * hold a capture whose picture is already taken. `adapter.info` is current Chrome; older ones
24
+ * spell the flag `isFallbackAdapter` on the adapter, which is why both are read.
25
+ */
26
+ export const GPU_PROBE =
27
+ '(async function(){var g=navigator.gpu;' +
28
+ 'if(!g)return{api:false,available:false,adapter:null,fallback:false};var a=null;' +
29
+ 'try{a=await Promise.race([g.requestAdapter(),' +
30
+ 'new Promise(function(r){setTimeout(function(){r(null);},2000);})]);}catch(e){a=null;}' +
31
+ 'if(!a)return{api:true,available:false,adapter:null,fallback:false};var i=a.info||{};' +
32
+ 'var n=[i.vendor,i.architecture,i.device,i.description].filter(function(s){return !!s;})' +
33
+ '.join(" ");return{api:true,available:true,adapter:n===""?null:n,' +
34
+ 'fallback:!!(a.isFallbackAdapter||i.isFallbackAdapter)};})()';
35
+
36
+ const gpuProbeSchema: StandardSchemaV1<unknown, ShotGpu> = t.object({
37
+ api: t.boolean,
38
+ available: t.boolean,
39
+ adapter: t.nullable(t.string),
40
+ fallback: t.boolean,
41
+ }) as unknown as StandardSchemaV1<unknown, ShotGpu>;
42
+
43
+ /** Parsed, never cast: a page can answer anything. `null` for a shape that does not fit. */
44
+ export function parseGpuProbe(value: unknown): ShotGpu | null {
45
+ const result = validate(gpuProbeSchema, value);
46
+ return result.issues === undefined ? result.value : null;
47
+ }
48
+
49
+ /** `null` when the page refused the probe — "not read" is never reported as "no GPU". */
50
+ export const readShotGpu = (page: {
51
+ evaluate(expression: string): Promise<unknown>;
52
+ }): Promise<ShotGpu | null> =>
53
+ page
54
+ .evaluate(GPU_PROBE)
55
+ .then(parseGpuProbe)
56
+ .catch(() => null);
57
+
58
+ export const gpuJson = (gpu: ShotGpu | null | undefined): JsonValue =>
59
+ gpu === null || gpu === undefined
60
+ ? null
61
+ : { api: gpu.api, available: gpu.available, adapter: gpu.adapter, fallback: gpu.fallback };
@@ -0,0 +1,95 @@
1
+ // `x shot`'s subject: the one route argument read and refused before anything boots, and the
2
+ // directory name a route photographs into. A path on the app, never a URL — the SSRF shape
3
+ // `allowHosts` exists to refuse is refused here, at the argument, where the reader can see why.
4
+
5
+ import { BadFlagError, MissingPositionalError } from './errors';
6
+
7
+ /** A directory name a route can never escape: everything that is not a letter or digit is a dash. */
8
+ export function shotSlug(route: string): string {
9
+ const slug = route.replace(/[^a-zA-Z0-9]+/g, '-').replace(/^-+|-+$/g, '');
10
+ return slug === '' ? 'root' : slug.toLowerCase();
11
+ }
12
+
13
+ const pathOf = (url: string): string => {
14
+ try {
15
+ return new URL(url).pathname;
16
+ } catch {
17
+ return '/';
18
+ }
19
+ };
20
+
21
+ /**
22
+ * A reserved name (RFC 2606) that resolves nowhere, so the origin check below can never be
23
+ * satisfied by an accident of what the app's own host happens to be.
24
+ */
25
+ const ROUTE_BASE = 'http://route.invalid';
26
+
27
+ /**
28
+ * Where a browser would actually go. The refusal above reads `scheme:` and nothing else, and this
29
+ * is the question it was standing in for: a path is a path only if resolving it lands back on the
30
+ * origin it was resolved against.
31
+ */
32
+ const resolvedOrigin = (path: string): string => {
33
+ try {
34
+ return new URL(path, ROUTE_BASE).origin;
35
+ } catch {
36
+ // A path `new URL` will not parse is one no browser will fetch either, and reporting it as the
37
+ // origin it is not is the honest answer here.
38
+ return '';
39
+ }
40
+ };
41
+
42
+ const refuseRoute = (reason: string): never => {
43
+ throw new BadFlagError({
44
+ flag: 'route',
45
+ command: 'shot',
46
+ reason,
47
+ // A placeholder, because there is nothing safe to substitute: unlike an absolute URL, an
48
+ // origin-escaping route carries no path the caller can be assumed to have meant.
49
+ fix: 'x shot /<path> --json',
50
+ });
51
+ };
52
+
53
+ /**
54
+ * A path on the app, never a URL. `x shot https://example.com` would photograph somebody else's
55
+ * site through a headless browser inside your network, which is the SSRF shape `allowHosts` exists
56
+ * to refuse — so it is refused here, at the argument, where the reader can still see why.
57
+ *
58
+ * `scheme:` was the ONLY spelling refused until 2026-08-22, and it is one of four: `//evil/x` is a
59
+ * protocol-relative URL, `\evil\x` is the same thing to every URL parser (a backslash IS a slash
60
+ * for a special scheme), and a TAB inside the path is deleted by the parser before the host is
61
+ * read, so `/⇥/evil/x` becomes `//evil/x`. Each one reached `new URL(route, server.url)` and came
62
+ * back pointed at another host. `allowHostsFrom` one layer down could not catch any of them: it
63
+ * allows a HOSTNAME, and the hostname it is given is the one the page has already left — which is
64
+ * how `x shot //localhost:9200/_cat/indices` photographed whatever else was on the dev box.
65
+ */
66
+ export function readRoute(raw: string | undefined): string {
67
+ if (raw === undefined || raw.trim() === '') {
68
+ throw new MissingPositionalError({ command: 'shot', positional: 'route', example: 'x shot /' });
69
+ }
70
+ const route = raw.trim();
71
+ if (/^[a-z][a-z0-9+.-]*:/i.test(route)) {
72
+ throw new BadFlagError({
73
+ flag: 'route',
74
+ command: 'shot',
75
+ reason: `"${route}" is an absolute URL; x shot photographs a route of the app under test`,
76
+ // The path out of the URL when it parses — the refusal's own fix line has to be runnable,
77
+ // and `new URL('http://')` throws, so the fallback is the route every app has.
78
+ fix: `x shot ${pathOf(route)} --json`,
79
+ });
80
+ }
81
+ const path = route.startsWith('/') ? route : `/${route}`;
82
+ // Its own refusal rather than folded into the origin check: `/a\b` stays on this origin and is
83
+ // still not the route that was typed — the verdict would record `/a\b` beside a picture of
84
+ // `/a/b`, which is the artifact lying about its own subject.
85
+ if (path.includes('\\')) {
86
+ return refuseRoute(`"${route}" contains a backslash, which a URL parser reads as "/"`);
87
+ }
88
+ const origin = resolvedOrigin(path);
89
+ if (origin !== ROUTE_BASE) {
90
+ return refuseRoute(
91
+ `"${route}" is not a path on the app: a browser resolves it to ${origin === '' ? 'no URL at all' : origin}`,
92
+ );
93
+ }
94
+ return path;
95
+ }