rebilder 0.2.1 → 0.3.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/CHANGELOG.md +32 -0
- package/README.md +44 -60
- package/dist/bin.js +388 -133
- package/dist/bin.js.map +1 -1
- package/dist/index.d.ts +16 -21
- package/dist/index.js +388 -133
- package/dist/index.js.map +1 -1
- package/package.json +12 -7
- package/dist/index.cjs +0 -1668
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -503
package/dist/index.d.cts
DELETED
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
import { ProbeOutcome, ProbeRejection } from '@rebilder/agent-readability/probe';
|
|
2
|
-
import { ArsResult, ArsCheck } from '@rebilder/agent-readability';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* exit.ts — the exit-code contract.
|
|
6
|
-
*
|
|
7
|
-
* THESE NUMBERS ARE A PUBLISHED INTERFACE (design §5.6). They are documented in
|
|
8
|
-
* the README, they are what a CI file branches on, and they are NEVER
|
|
9
|
-
* renumbered. Adding a code is a MINOR; changing what an existing one means is a
|
|
10
|
-
* broken promise to every pipeline that already pinned it.
|
|
11
|
-
*
|
|
12
|
-
* THE 1-vs-3 SPLIT IS THE WHOLE POINT. `1` means "we scored this page and it did
|
|
13
|
-
* not meet your threshold" — a fact about the site, actionable by the team that
|
|
14
|
-
* owns it. `3` means "we never got a score" — DNS, a timeout, a 502, a captive
|
|
15
|
-
* portal in CI. If a flaky network exits 1, the first red build that nobody can
|
|
16
|
-
* explain gets the check deleted, and a deleted check protects nothing. So a
|
|
17
|
-
* probe that never produced a bundle can never produce `1`, and there is a test
|
|
18
|
-
* that asserts exactly that.
|
|
19
|
-
*
|
|
20
|
-
* `4` is the third thing that is not a score failure: we *chose* not to fetch,
|
|
21
|
-
* or were told not to. An SSRF rejection, a robots disallow aimed at
|
|
22
|
-
* `rebilder-ars`, a deliberate assistant opt-out, an exhausted probe budget.
|
|
23
|
-
* Distinguishing it from 3 matters because 4 is deterministic and 3 is not:
|
|
24
|
-
* re-running fixes a 3 and never fixes a 4.
|
|
25
|
-
*/
|
|
26
|
-
declare const EXIT: {
|
|
27
|
-
/** Completed; threshold met, or no threshold set. */
|
|
28
|
-
readonly OK: 0;
|
|
29
|
-
/** Completed; threshold NOT met. Only ever produced by a real score. */
|
|
30
|
-
readonly THRESHOLD: 1;
|
|
31
|
-
/** Usage error — unknown flag, bad value, missing argument, unparseable URL. */
|
|
32
|
-
readonly USAGE: 2;
|
|
33
|
-
/** Probe failed / target unreachable. INFRASTRUCTURE, not a score failure. */
|
|
34
|
-
readonly PROBE: 3;
|
|
35
|
-
/** Blocked by policy — SSRF guard, robots opt-out, exhausted probe budget. */
|
|
36
|
-
readonly POLICY: 4;
|
|
37
|
-
};
|
|
38
|
-
type ExitCode = (typeof EXIT)[keyof typeof EXIT];
|
|
39
|
-
declare function worstExit(codes: readonly ExitCode[]): ExitCode;
|
|
40
|
-
/** Thrown for anything that is the operator's mistake rather than the site's. */
|
|
41
|
-
declare class UsageError extends Error {
|
|
42
|
-
constructor(message: string);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* runtime.ts — every impure thing the CLI can do, behind one injectable object.
|
|
47
|
-
*
|
|
48
|
-
* WHY THIS SHAPE. The test suite for a network tool is worthless if it can reach
|
|
49
|
-
* the network, and "we mocked `fetch`" is not a guarantee — it is a hope about
|
|
50
|
-
* every code path nobody thought to mock. Here the CLI holds no socket, no file
|
|
51
|
-
* handle, no clock and no `process` reference at all: it holds a `CliRuntime`.
|
|
52
|
-
* The tests pass one whose `probe` returns a fixture and whose `writeFile`
|
|
53
|
-
* appends to an array, so a test that hits the network cannot be written by
|
|
54
|
-
* accident — it has to construct the real runtime on purpose.
|
|
55
|
-
*
|
|
56
|
-
* THE PROBE FACTORY IS ASYNC FOR ONE REASON. `@rebilder/agent-readability/probe/local`
|
|
57
|
-
* THROWS AT IMPORT TIME unless the process was started with `--allow-private`
|
|
58
|
-
* (and refuses outright in a hosted runtime). That is exactly the behaviour we
|
|
59
|
-
* want and it means the module cannot be imported statically — a top-level
|
|
60
|
-
* `import` of it would make `rebilder check https://example.com` crash on
|
|
61
|
-
* startup for everyone. So local mode is a dynamic import, reached only when the
|
|
62
|
-
* flag is present, which is also what makes the permission per-invocation rather
|
|
63
|
-
* than per-installation.
|
|
64
|
-
*/
|
|
65
|
-
|
|
66
|
-
/** One probe of one URL. The only outbound request the CLI ever makes. */
|
|
67
|
-
type ProbeRunner = (target: string) => Promise<ProbeOutcome>;
|
|
68
|
-
interface ProbeSetup {
|
|
69
|
-
/** Routes through `./probe/local`. Per invocation, never a default. */
|
|
70
|
-
allowPrivate: boolean;
|
|
71
|
-
allowHttp: boolean;
|
|
72
|
-
/** How many URLs this run will probe — sizes the run budget, nothing else. */
|
|
73
|
-
urlCount: number;
|
|
74
|
-
}
|
|
75
|
-
type ProbeFactory = (setup: ProbeSetup) => Promise<ProbeRunner>;
|
|
76
|
-
interface CliRuntime {
|
|
77
|
-
env: Readonly<Record<string, string | undefined>>;
|
|
78
|
-
cwd: string;
|
|
79
|
-
isTty: boolean;
|
|
80
|
-
columns: number | undefined;
|
|
81
|
-
write(text: string): void;
|
|
82
|
-
writeError(text: string): void;
|
|
83
|
-
writeFile(path: string, contents: string): Promise<void>;
|
|
84
|
-
readFile(path: string): Promise<string | null>;
|
|
85
|
-
probe: ProbeFactory;
|
|
86
|
-
now(): Date;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* The §3.3 request set is 5 requests for a cold URL (robots.txt, agent, browser,
|
|
90
|
-
* /llms.txt, /.well-known/ucp) and the probe does not cache across calls, so a
|
|
91
|
-
* multi-URL run needs a budget proportional to the URL count. `createLimiter`'s
|
|
92
|
-
* default of 20 is a floor chosen for a single-shot caller; raising it is
|
|
93
|
-
* supposed to be a decision someone made on purpose, and this is that decision,
|
|
94
|
-
* written down: six per URL (five plus the robots retry) and four of slack.
|
|
95
|
-
*/
|
|
96
|
-
declare function budgetFor(urlCount: number): number;
|
|
97
|
-
/**
|
|
98
|
-
* The real probe factory. `probeStrict` for everything public; a dynamic import
|
|
99
|
-
* of `./probe/local` when — and only when — `--allow-private` was typed.
|
|
100
|
-
*
|
|
101
|
-
* If that import throws, the message from the package is the one the user should
|
|
102
|
-
* see (it explains the argv gate and the hosted-runtime refusal in its own
|
|
103
|
-
* words), so it is re-thrown unchanged rather than summarised.
|
|
104
|
-
*/
|
|
105
|
-
declare const nodeProbeFactory: ProbeFactory;
|
|
106
|
-
declare function createNodeRuntime(): CliRuntime;
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* cli.ts — parse, run, render, exit. The whole program in one readable function.
|
|
110
|
-
*
|
|
111
|
-
* `runCli` RETURNS an exit code rather than calling `process.exit`, and takes a
|
|
112
|
-
* `CliRuntime` rather than reaching for `process`. That is what makes the exit
|
|
113
|
-
* codes testable as a contract instead of as a hope: every test in
|
|
114
|
-
* `tests/exit-codes.test.ts` is a call to this function with a fake probe and an
|
|
115
|
-
* assertion on the integer it returned.
|
|
116
|
-
*
|
|
117
|
-
* THE ORDER OF OPERATIONS IS THE SAFETY PROPERTY. Parse first, and every parse
|
|
118
|
-
* failure is exit 2 with nothing having been fetched. Then build the probe —
|
|
119
|
-
* which for `--allow-private` is where the import-time gate in
|
|
120
|
-
* `@rebilder/agent-readability/probe/local` fires, before any URL is touched.
|
|
121
|
-
* Then run. Then render. Then write. A failure at any step short-circuits with
|
|
122
|
-
* its own code, and no step can produce a code belonging to an earlier one.
|
|
123
|
-
*
|
|
124
|
-
* `--out` WRITES AFTER STDOUT, NOT INSTEAD OF IT. A CI job that redirects a
|
|
125
|
-
* report to a file still wants the report in the log; making `--out` silent
|
|
126
|
-
* would mean the only copy lives in an artifact nobody downloads.
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
/** Kept in step with package.json by a test, so a stale constant cannot ship. */
|
|
130
|
-
declare const CLI_VERSION = "0.2.1";
|
|
131
|
-
declare function runCli(argv: readonly string[], runtime: CliRuntime): Promise<ExitCode>;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* args.ts — `node:util` `parseArgs`, and the validation `parseArgs` does not do.
|
|
135
|
-
*
|
|
136
|
-
* `parseArgs` (stable since Node 20.11, which is the root `engines` floor and
|
|
137
|
-
* therefore ours) gives us tokenisation and `strict: true` gives us "unknown
|
|
138
|
-
* option" for free. Everything below it is ours: an unknown *value* for a known
|
|
139
|
-
* option is the error people actually make — `--format html`, `--fail-on Z`,
|
|
140
|
-
* `--concurrency 0` — and `parseArgs` will hand all three through as strings.
|
|
141
|
-
*
|
|
142
|
-
* EVERY FAILURE HERE IS EXIT 2, and nothing here can produce any other code.
|
|
143
|
-
* That is the point of parsing being a separate phase from running: once we have
|
|
144
|
-
* a `Command`, every remaining outcome is a fact about a website, and the
|
|
145
|
-
* operator's mistakes are already behind us.
|
|
146
|
-
*
|
|
147
|
-
* `--fail-on` DEFAULTS TO NOTHING (§5.6). `rebilder check <url>` reports and
|
|
148
|
-
* exits 0. A tool that fails a build by default gets added with `|| true` on the
|
|
149
|
-
* first day and is then permanently decorative.
|
|
150
|
-
*/
|
|
151
|
-
declare const FORMATS: readonly ["pretty", "json", "markdown", "junit"];
|
|
152
|
-
type Format = (typeof FORMATS)[number];
|
|
153
|
-
declare const GRADES: readonly ["A", "B", "C", "D", "F"];
|
|
154
|
-
type Grade = (typeof GRADES)[number];
|
|
155
|
-
declare const COMMANDS: readonly ["check", "diff", "init", "badge"];
|
|
156
|
-
type CommandName = (typeof COMMANDS)[number];
|
|
157
|
-
interface CheckCommand {
|
|
158
|
-
name: 'check';
|
|
159
|
-
urls: string[];
|
|
160
|
-
format: Format;
|
|
161
|
-
/** `null` = no threshold, the default. Exit 1 is unreachable when null. */
|
|
162
|
-
failOn: Grade | null;
|
|
163
|
-
out: string | null;
|
|
164
|
-
allowPrivate: boolean;
|
|
165
|
-
allowHttp: boolean;
|
|
166
|
-
concurrency: number;
|
|
167
|
-
}
|
|
168
|
-
interface DiffCommand {
|
|
169
|
-
name: 'diff';
|
|
170
|
-
url: string;
|
|
171
|
-
format: Format;
|
|
172
|
-
out: string | null;
|
|
173
|
-
allowPrivate: boolean;
|
|
174
|
-
allowHttp: boolean;
|
|
175
|
-
}
|
|
176
|
-
interface InitCommand {
|
|
177
|
-
name: 'init';
|
|
178
|
-
/** Framework override; `null` means detect from the working directory. */
|
|
179
|
-
framework: string | null;
|
|
180
|
-
out: string | null;
|
|
181
|
-
format: Format;
|
|
182
|
-
}
|
|
183
|
-
interface BadgeCommand {
|
|
184
|
-
name: 'badge';
|
|
185
|
-
domain: string;
|
|
186
|
-
format: Format;
|
|
187
|
-
out: string | null;
|
|
188
|
-
}
|
|
189
|
-
type Command = CheckCommand | DiffCommand | InitCommand | BadgeCommand;
|
|
190
|
-
type ParseResult = {
|
|
191
|
-
kind: 'command';
|
|
192
|
-
command: Command;
|
|
193
|
-
} | {
|
|
194
|
-
kind: 'help';
|
|
195
|
-
topic: CommandName | null;
|
|
196
|
-
} | {
|
|
197
|
-
kind: 'version';
|
|
198
|
-
};
|
|
199
|
-
declare function normalizeDomain(input: string): string;
|
|
200
|
-
declare function parseCommandLine(argv: readonly string[]): ParseResult;
|
|
201
|
-
|
|
202
|
-
/**
|
|
203
|
-
* report.ts — one URL's outcome, and the mapping from that outcome to an exit
|
|
204
|
-
* code.
|
|
205
|
-
*
|
|
206
|
-
* THIS FILE IS WHERE THE 1-vs-3 SPLIT IS ACTUALLY ENFORCED, so it is small on
|
|
207
|
-
* purpose and there is a test asserting the property directly: for every
|
|
208
|
-
* `ArsUnscoredReason`, every `ProbeRejection`, and the opt-out outcome, the code
|
|
209
|
-
* is never `EXIT.THRESHOLD`. Only a real integer score, compared against a
|
|
210
|
-
* threshold the operator asked for, produces 1.
|
|
211
|
-
*
|
|
212
|
-
* THE THREE-WAY SPLIT OF "WE DID NOT GET A SCORE" mirrors `ArsOutcome`:
|
|
213
|
-
* - `opt-out` — the site said no, deliberately and in well-formed robots. That
|
|
214
|
-
* is a choice, not a failure, and §3.6 gives it no letter grade. Exit 4.
|
|
215
|
-
* - `unscored` — a missing observation. Mostly transient (timeout, 5xx, edge
|
|
216
|
-
* challenge) so exit 3, EXCEPT `robots-disallow-scanner`, which is a
|
|
217
|
-
* deterministic refusal aimed at us and re-running will never change it.
|
|
218
|
-
* - a probe `rejection` — we never sent the request: unparseable URL (2, the
|
|
219
|
-
* operator's typo), guard refusal (4), exhausted budget (4).
|
|
220
|
-
*/
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* `'probed'` means the probe returned an evidence bundle and `score()` judged it.
|
|
224
|
-
* It does NOT mean the judgment was a grade: an unscored or opted-out result is a
|
|
225
|
-
* `'probed'` report carrying an `ArsResult` whose `outcome.kind` says so. The
|
|
226
|
-
* discriminant answers "did we get evidence", and `outcome.kind` answers "what
|
|
227
|
-
* did the evidence say" — collapsing the two is how a 403 ends up rendered as an
|
|
228
|
-
* F.
|
|
229
|
-
*/
|
|
230
|
-
type UrlReport = {
|
|
231
|
-
kind: 'probed';
|
|
232
|
-
url: string;
|
|
233
|
-
result: ArsResult;
|
|
234
|
-
} | {
|
|
235
|
-
kind: 'rejected';
|
|
236
|
-
url: string;
|
|
237
|
-
rejection: ProbeRejection;
|
|
238
|
-
detail: string;
|
|
239
|
-
};
|
|
240
|
-
/**
|
|
241
|
-
* `--fail-on C` means "C or better passes". A grade strictly worse than the
|
|
242
|
-
* threshold fails; the threshold grade itself passes. Stated in the README with
|
|
243
|
-
* the same sentence, because the off-by-one reading ("fail on C" = "C fails") is
|
|
244
|
-
* the one people assume half the time.
|
|
245
|
-
*/
|
|
246
|
-
declare function meetsThreshold(grade: Grade, failOn: Grade): boolean;
|
|
247
|
-
declare function exitCodeFor(report: UrlReport, failOn: Grade | null): ExitCode;
|
|
248
|
-
/** One line describing the outcome. No grade, no score — those render separately. */
|
|
249
|
-
declare function outcomeSummary(report: UrlReport): string;
|
|
250
|
-
/** `'scored' | 'opt-out' | 'unscored' | 'rejected'` — the coarse status. */
|
|
251
|
-
declare function statusOf(report: UrlReport): 'scored' | 'opt-out' | 'unscored' | 'rejected';
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* payload.ts — what a command produced, before anyone decided how to print it.
|
|
255
|
-
*
|
|
256
|
-
* The commands compute; the formatters render. Nothing in `commands/` knows
|
|
257
|
-
* whether it is being asked for a terminal table or a JUnit file, and nothing in
|
|
258
|
-
* `format/` knows how to reach a network. The seam exists because `--format`
|
|
259
|
-
* multiplies the number of paths through the program by four, and the only way
|
|
260
|
-
* to test four formats of five outcomes without twenty end-to-end runs is to be
|
|
261
|
-
* able to build a payload in one line.
|
|
262
|
-
*/
|
|
263
|
-
|
|
264
|
-
/** One side of `rebilder diff`: what the agent, or the browser, actually got. */
|
|
265
|
-
interface DiffSide {
|
|
266
|
-
role: 'agent' | 'browser';
|
|
267
|
-
/** The only header that differs between the two probes (§3.3). */
|
|
268
|
-
accept: string;
|
|
269
|
-
status: number | null;
|
|
270
|
-
contentType: string | null;
|
|
271
|
-
/** Decoded UTF-8 bytes — the normative measurement (§3.3). */
|
|
272
|
-
bytes: number | null;
|
|
273
|
-
/** HEURISTIC: chars/4. Always rendered with ≈ and an "est." label. */
|
|
274
|
-
approxTokens: number | null;
|
|
275
|
-
/** True when the 2 MiB cap was hit; bytes then render as "≥ N". */
|
|
276
|
-
truncated: boolean;
|
|
277
|
-
redirects: number;
|
|
278
|
-
error: string | null;
|
|
279
|
-
}
|
|
280
|
-
interface DiffPayload {
|
|
281
|
-
url: string;
|
|
282
|
-
/** `null` when the probe never produced a bundle. */
|
|
283
|
-
agent: DiffSide | null;
|
|
284
|
-
browser: DiffSide | null;
|
|
285
|
-
/** The D2.4 substance-parity check, verbatim — the authoritative comparison. */
|
|
286
|
-
parity: ArsCheck | null;
|
|
287
|
-
/** Present whenever the probe returned a bundle, even for an unscored outcome. */
|
|
288
|
-
result: ArsResult | null;
|
|
289
|
-
report: UrlReport;
|
|
290
|
-
}
|
|
291
|
-
interface Scaffold {
|
|
292
|
-
framework: string;
|
|
293
|
-
/** How the framework was determined. Printed: a guess that hides is a guess. */
|
|
294
|
-
detection: string;
|
|
295
|
-
/** Suggested path for `--out`, relative to the working directory. */
|
|
296
|
-
suggestedPath: string;
|
|
297
|
-
language: 'ts' | 'js' | 'toml';
|
|
298
|
-
contents: string;
|
|
299
|
-
notes: readonly string[];
|
|
300
|
-
}
|
|
301
|
-
interface BadgeSnippet {
|
|
302
|
-
domain: string;
|
|
303
|
-
svgUrl: string;
|
|
304
|
-
pageUrl: string;
|
|
305
|
-
markdown: string;
|
|
306
|
-
html: string;
|
|
307
|
-
notes: readonly string[];
|
|
308
|
-
}
|
|
309
|
-
type Payload = {
|
|
310
|
-
command: 'check';
|
|
311
|
-
reports: UrlReport[];
|
|
312
|
-
failOn: Grade | null;
|
|
313
|
-
} | {
|
|
314
|
-
command: 'diff';
|
|
315
|
-
diff: DiffPayload;
|
|
316
|
-
} | {
|
|
317
|
-
command: 'init';
|
|
318
|
-
scaffold: Scaffold;
|
|
319
|
-
} | {
|
|
320
|
-
command: 'badge';
|
|
321
|
-
badge: BadgeSnippet;
|
|
322
|
-
};
|
|
323
|
-
|
|
324
|
-
/**
|
|
325
|
-
* term.ts — hand-rolled ANSI and box drawing. Zero runtime dependencies (§5.6).
|
|
326
|
-
*
|
|
327
|
-
* WHY NOT `chalk`/`picocolors`/`cli-table3`. This binary is installed with
|
|
328
|
-
* `npx rebilder check` by people who have not decided to trust us yet, inside CI
|
|
329
|
-
* containers where every transitive dependency is an supply-chain question they
|
|
330
|
-
* have to answer on our behalf. Colour is sixteen escape sequences and a table is
|
|
331
|
-
* a loop; neither is worth a dependency, and "zero deps" is a claim we can only
|
|
332
|
-
* make if we never make an exception for the easy one.
|
|
333
|
-
*
|
|
334
|
-
* TWO CAPABILITIES, DECIDED SEPARATELY, because they fail in different places:
|
|
335
|
-
*
|
|
336
|
-
* - COLOUR is off unless stdout is a TTY, and off unconditionally when
|
|
337
|
-
* `NO_COLOR` is set to anything at all (no-color.org: the variable's presence
|
|
338
|
-
* is the signal, its value is not). `FORCE_COLOR` turns it back on for the
|
|
339
|
-
* case that actually matters — a CI runner that renders ANSI in its log
|
|
340
|
-
* viewer while presenting a pipe to the process.
|
|
341
|
-
*
|
|
342
|
-
* - UNICODE is decided by the locale, not by the TTY. A pipe into a file is
|
|
343
|
-
* perfectly capable of holding `│`; a Windows console at code page 437 is not,
|
|
344
|
-
* and neither is a `LANG=C` container. So: use box-drawing characters when the
|
|
345
|
-
* locale says UTF-8, fall back to `+-|` otherwise. Getting this wrong is not
|
|
346
|
-
* cosmetic — mojibake in a build log is indistinguishable from a crash.
|
|
347
|
-
*
|
|
348
|
-
* Everything here takes its environment as an argument. Nothing reads
|
|
349
|
-
* `process.env` or `process.stdout` at module scope, so a test can render both
|
|
350
|
-
* branches without touching the process.
|
|
351
|
-
*/
|
|
352
|
-
interface TermCapabilities {
|
|
353
|
-
color: boolean;
|
|
354
|
-
unicode: boolean;
|
|
355
|
-
/** Columns available for output. Clamped to a sane range. */
|
|
356
|
-
width: number;
|
|
357
|
-
}
|
|
358
|
-
interface TermEnvironment {
|
|
359
|
-
env: Readonly<Record<string, string | undefined>>;
|
|
360
|
-
isTty: boolean;
|
|
361
|
-
columns?: number | undefined;
|
|
362
|
-
}
|
|
363
|
-
declare function detectCapabilities(environment: TermEnvironment): TermCapabilities;
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* format/shared.ts — the small vocabulary every formatter needs, in one place so
|
|
367
|
-
* the four of them cannot drift.
|
|
368
|
-
*
|
|
369
|
-
* THE RULE THIS FILE EXISTS TO MAKE MECHANICAL (CLAUDE.md Hard Rule 10): a
|
|
370
|
-
* heuristic value never renders without its label. Not "usually", not "in the
|
|
371
|
-
* detailed view" — never. So `basisLabel()` is the only way any formatter gets
|
|
372
|
-
* the word, `approxTokens()` is the only way any formatter prints a token count
|
|
373
|
-
* and it always carries `≈` and `est.`, and `bytesText()` is the only way any
|
|
374
|
-
* formatter prints a byte figure and it renders `≥ N` whenever the capture was
|
|
375
|
-
* truncated. A formatter that wants to print one of these without its label has
|
|
376
|
-
* to write the code to do it, which is a diff a reviewer can see.
|
|
377
|
-
*/
|
|
378
|
-
|
|
379
|
-
interface FormatContext {
|
|
380
|
-
unicode: boolean;
|
|
381
|
-
generatedAt: string;
|
|
382
|
-
/** The CLI's own version, printed so a report can be traced to a build. */
|
|
383
|
-
cliVersion: string;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
/**
|
|
387
|
-
* format/index.ts — the one place `--format` is turned into a string.
|
|
388
|
-
*
|
|
389
|
-
* `--out` writes exactly what stdout would have shown, in the same format. There
|
|
390
|
-
* is no separate "file format": a report you can read on screen and a report you
|
|
391
|
-
* archive should not be two artifacts that can disagree, and the first time they
|
|
392
|
-
* do, the one in the artifact store is the one nobody can reproduce.
|
|
393
|
-
*/
|
|
394
|
-
|
|
395
|
-
declare function render(payload: Payload, format: Format, caps: TermCapabilities, ctx: FormatContext): string;
|
|
396
|
-
|
|
397
|
-
/**
|
|
398
|
-
* help.ts — `--help`.
|
|
399
|
-
*
|
|
400
|
-
* THE ZERO-TELEMETRY CONTRACT IS NOT IN A FOOTER. It prints in the general
|
|
401
|
-
* help, where the person deciding whether to point this at an internal hostname
|
|
402
|
-
* inside their own CI is actually looking. (The conflict-of-interest paragraph
|
|
403
|
-
* that used to sit beside it was removed everywhere in Aug 2026, together with
|
|
404
|
-
* the spec clause that required it.)
|
|
405
|
-
*
|
|
406
|
-
* THE EXIT-CODE TABLE IS IN THE HELP TEXT, not only in the README, because the
|
|
407
|
-
* person wiring this into a pipeline is reading a terminal, and the 1-vs-3 split
|
|
408
|
-
* only protects anything if they know it exists before the first flaky build.
|
|
409
|
-
*/
|
|
410
|
-
|
|
411
|
-
declare function helpText(topic: CommandName | null): string;
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* disclosure.ts — the texts that are not ours to edit for tone.
|
|
415
|
-
*
|
|
416
|
-
* THE NOTICE prints on every result, in every format, including `--format json`
|
|
417
|
-
* and `--format junit`. It is two lines because a one-line version gets read as
|
|
418
|
-
* a tagline; ARS measures the shape of a response and nothing else, and a number
|
|
419
|
-
* that travels without that sentence is a number people will read as a quality
|
|
420
|
-
* score for the business. (Design §3.6.)
|
|
421
|
-
*
|
|
422
|
-
* The conflict-of-interest paragraph that used to print in `--help` was removed
|
|
423
|
-
* everywhere (owner decision, Aug 2026), along with spec §0.1 and the "MUST be
|
|
424
|
-
* printed" clause that required it here. The measurement notice above is
|
|
425
|
-
* unaffected: spec §0 still binds every surface that shows a grade.
|
|
426
|
-
*
|
|
427
|
-
* They are exported as constants and asserted by tests. They are not template
|
|
428
|
-
* strings and they take no parameters: a disclosure whose text varies by context
|
|
429
|
-
* is a disclosure someone will tune.
|
|
430
|
-
*/
|
|
431
|
-
/** Design §3.6. Prints on every result, every format. */
|
|
432
|
-
declare const ARS_NOTICE_LINES: readonly string[];
|
|
433
|
-
declare const ARS_NOTICE: string;
|
|
434
|
-
/**
|
|
435
|
-
* The no-telemetry contract, printed in `--help` next to the disclosure.
|
|
436
|
-
*
|
|
437
|
-
* It is here rather than only in the README because the person who needs to read
|
|
438
|
-
* it is the one deciding whether to run `--allow-private` against an internal
|
|
439
|
-
* hostname inside their own CI, and they are looking at a terminal.
|
|
440
|
-
*/
|
|
441
|
-
declare const TELEMETRY_LINES: readonly string[];
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* commands/init.ts — a gateway config scaffold for the framework it found.
|
|
445
|
-
*
|
|
446
|
-
* ZERO NETWORK, and that is not incidental. `init` reads `package.json` and a
|
|
447
|
-
* handful of well-known filenames in the working directory and writes a file.
|
|
448
|
-
* Nothing about the user's dependency list, framework choice, or repository
|
|
449
|
-
* leaves the machine — a scaffolding command that phoned home with "which
|
|
450
|
-
* framework did they pick" would be exactly the telemetry the README says we do
|
|
451
|
-
* not collect, wearing a helpful hat.
|
|
452
|
-
*
|
|
453
|
-
* THE DETECTION IS PRINTED. Every scaffold says how it decided (`"next found in
|
|
454
|
-
* package.json dependencies"`), because a wrong guess with a visible reason is a
|
|
455
|
-
* thirty-second fix and a wrong guess with no reason is a bug report. `--framework`
|
|
456
|
-
* overrides it.
|
|
457
|
-
*
|
|
458
|
-
* THE SCAFFOLD IS A SKELETON WITH A `TODO`, NOT A WORKING CONFIG, and it says so
|
|
459
|
-
* in a comment inside the generated file. `GatewaySources` resolvers read the
|
|
460
|
-
* merchant's source of truth; we cannot know what that is, and a scaffold that
|
|
461
|
-
* looked complete would be a scaffold someone shipped. This is the same rule the
|
|
462
|
-
* variant architecture runs on: substantive values come from source-of-truth
|
|
463
|
-
* fields, never from something we generated (CLAUDE.md Hard Rule 2).
|
|
464
|
-
*/
|
|
465
|
-
|
|
466
|
-
declare const FRAMEWORKS: readonly ["next", "node", "edge", "shopify"];
|
|
467
|
-
type Framework = (typeof FRAMEWORKS)[number];
|
|
468
|
-
interface Detection {
|
|
469
|
-
framework: Framework;
|
|
470
|
-
reason: string;
|
|
471
|
-
}
|
|
472
|
-
declare function detectFramework(runtime: CliRuntime): Promise<Detection>;
|
|
473
|
-
|
|
474
|
-
/**
|
|
475
|
-
* commands/badge.ts — the embed snippet, generated locally.
|
|
476
|
-
*
|
|
477
|
-
* IT MAKES NO NETWORK CALL, and could not usefully make one. The badge endpoint
|
|
478
|
-
* renders from the stored `index_entries` row and is architecturally incapable
|
|
479
|
-
* of triggering a probe (§5.6); asking it anything from here would only tell us
|
|
480
|
-
* which domains people are curious about, which is a log we have promised not to
|
|
481
|
-
* keep. So this command is string construction, and the honesty lives in the
|
|
482
|
-
* notes it prints rather than in a lookup.
|
|
483
|
-
*
|
|
484
|
-
* WHAT THE NOTES HAVE TO SAY, because a merchant pasting this into a README is
|
|
485
|
-
* about to be surprised by all four:
|
|
486
|
-
* - The badge only renders a grade for a **verified opted-in** domain. Anything
|
|
487
|
-
* else gets a neutral "not rated" badge, at 200 rather than 404 (a broken
|
|
488
|
-
* image on a merchant's site is a support ticket).
|
|
489
|
-
* - It is served live. The owner captures nothing and freezes nothing, and it
|
|
490
|
-
* degrades to "unverified" after 30 days without a successful re-scan.
|
|
491
|
-
* - It always names its subject — `example.com · A · 94 · Mar 2026`. A
|
|
492
|
-
* domain-less badge is misappropriable, and that one decision is what makes
|
|
493
|
-
* the whole thing safe.
|
|
494
|
-
* - No score ever comes from the query string.
|
|
495
|
-
*
|
|
496
|
-
* `alt` text carries the domain and the word "score" for the same reason the
|
|
497
|
-
* image does: an image whose alt text is "Rebilder badge" is one someone can
|
|
498
|
-
* move to a different site and have it still read correctly.
|
|
499
|
-
*/
|
|
500
|
-
|
|
501
|
-
declare const BADGE_ORIGIN = "https://rebilder.com";
|
|
502
|
-
|
|
503
|
-
export { ARS_NOTICE, ARS_NOTICE_LINES, BADGE_ORIGIN, type BadgeCommand, type BadgeSnippet, CLI_VERSION, COMMANDS, type CheckCommand, type CliRuntime, type Command, type CommandName, type DiffCommand, type DiffPayload, type DiffSide, EXIT, type ExitCode, FORMATS, FRAMEWORKS, type Format, type FormatContext, type Framework, GRADES, type Grade, type InitCommand, type ParseResult, type Payload, type ProbeFactory, type ProbeRunner, type ProbeSetup, type Scaffold, TELEMETRY_LINES, type TermCapabilities, type UrlReport, UsageError, budgetFor, createNodeRuntime, detectCapabilities, detectFramework, exitCodeFor, helpText, meetsThreshold, nodeProbeFactory, normalizeDomain, outcomeSummary, parseCommandLine, render, runCli, statusOf, worstExit };
|