rebilder 0.1.1 → 0.2.1

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/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/exit.ts","../src/args.ts","../src/commands/badge.ts","../src/commands/check.ts","../src/commands/diff.ts","../src/commands/init.ts","../src/disclosure.ts","../src/report.ts","../src/format/json.ts","../src/format/shared.ts","../src/format/junit.ts","../src/format/markdown.ts","../src/term.ts","../src/format/pretty.ts","../src/format/index.ts","../src/help.ts","../src/cli.ts","../src/runtime.ts"],"names":["name","report","score","text","policy","resolvePath"],"mappings":";;;;;;;;;AAuBO,IAAM,IAAA,GAAO;AAAA;AAAA,EAElB,EAAA,EAAI,CAAA;AAAA;AAAA,EAEJ,SAAA,EAAW,CAAA;AAAA;AAAA,EAEX,KAAA,EAAO,CAAA;AAAA;AAAA,EAEP,KAAA,EAAO,CAAA;AAAA;AAAA,EAEP,MAAA,EAAQ;AACV;AAeA,IAAM,QAAA,GAAgC,CAAC,IAAA,CAAK,KAAA,EAAO,IAAA,CAAK,MAAA,EAAQ,IAAA,CAAK,KAAA,EAAO,IAAA,CAAK,SAAA,EAAW,IAAA,CAAK,EAAE,CAAA;AAE5F,SAAS,UAAU,KAAA,EAAsC;AAC9D,EAAA,KAAA,MAAW,aAAa,QAAA,EAAU;AAChC,IAAA,IAAI,KAAA,CAAM,QAAA,CAAS,SAAS,CAAA,EAAG,OAAO,SAAA;AAAA,EACxC;AACA,EAAA,OAAO,IAAA,CAAK,EAAA;AACd;AAGO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA,EACpC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AAAA,EACd;AACF;;;AC1CO,IAAM,OAAA,GAAU,CAAC,QAAA,EAAU,MAAA,EAAQ,YAAY,OAAO;AAGtD,IAAM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AAA,CAAY,OAAA,CAAQ,KAAI,EAAG,IAAI,GAAG,MAAM,CAAA;AAAA,MAChE,CAAA,CAAA,MAAQ;AACN,QAAA,OAAO,IAAA;AAAA,MACT;AAAA,IACF,CAAA;AAAA,IACA,KAAA,EAAO,gBAAA;AAAA,IACP,GAAA,EAAK,sBAAM,IAAI,IAAA;AAAK,GACtB;AACF","file":"index.js","sourcesContent":["/**\n * exit.ts — the exit-code contract.\n *\n * THESE NUMBERS ARE A PUBLISHED INTERFACE (design §5.6). They are documented in\n * the README, they are what a CI file branches on, and they are NEVER\n * renumbered. Adding a code is a MINOR; changing what an existing one means is a\n * broken promise to every pipeline that already pinned it.\n *\n * THE 1-vs-3 SPLIT IS THE WHOLE POINT. `1` means \"we scored this page and it did\n * not meet your threshold\" — a fact about the site, actionable by the team that\n * owns it. `3` means \"we never got a score\" — DNS, a timeout, a 502, a captive\n * portal in CI. If a flaky network exits 1, the first red build that nobody can\n * explain gets the check deleted, and a deleted check protects nothing. So a\n * probe that never produced a bundle can never produce `1`, and there is a test\n * that asserts exactly that.\n *\n * `4` is the third thing that is not a score failure: we *chose* not to fetch,\n * or were told not to. An SSRF rejection, a robots disallow aimed at\n * `rebilder-ars`, a deliberate assistant opt-out, an exhausted probe budget.\n * Distinguishing it from 3 matters because 4 is deterministic and 3 is not:\n * re-running fixes a 3 and never fixes a 4.\n */\n\nexport const EXIT = {\n /** Completed; threshold met, or no threshold set. */\n OK: 0,\n /** Completed; threshold NOT met. Only ever produced by a real score. */\n THRESHOLD: 1,\n /** Usage error — unknown flag, bad value, missing argument, unparseable URL. */\n USAGE: 2,\n /** Probe failed / target unreachable. INFRASTRUCTURE, not a score failure. */\n PROBE: 3,\n /** Blocked by policy — SSRF guard, robots opt-out, exhausted probe budget. */\n POLICY: 4,\n} as const\n\nexport type ExitCode = (typeof EXIT)[keyof typeof EXIT]\n\n/**\n * Which code wins when one invocation covers several URLs.\n *\n * Ordered most-severe first and documented in the README, because \"some passed\n * and some did not\" has to collapse to one integer and an undocumented collapse\n * rule is a bug report waiting to happen. The ordering says: a mistake in the\n * command beats everything (2); a deterministic refusal beats a transient\n * failure, because re-running will not change it (4 over 3); and anything that\n * stopped us from getting a score beats a score we did get and disliked (3 over\n * 1) — the same reasoning as the 1-vs-3 split itself, applied across a set.\n */\nconst SEVERITY: readonly ExitCode[] = [EXIT.USAGE, EXIT.POLICY, EXIT.PROBE, EXIT.THRESHOLD, EXIT.OK]\n\nexport function worstExit(codes: readonly ExitCode[]): ExitCode {\n for (const candidate of SEVERITY) {\n if (codes.includes(candidate)) return candidate\n }\n return EXIT.OK\n}\n\n/** Thrown for anything that is the operator's mistake rather than the site's. */\nexport class UsageError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'UsageError'\n }\n}\n","/**\n * args.ts — `node:util` `parseArgs`, and the validation `parseArgs` does not do.\n *\n * `parseArgs` (stable since Node 20.11, which is the root `engines` floor and\n * therefore ours) gives us tokenisation and `strict: true` gives us \"unknown\n * option\" for free. Everything below it is ours: an unknown *value* for a known\n * option is the error people actually make — `--format html`, `--fail-on Z`,\n * `--concurrency 0` — and `parseArgs` will hand all three through as strings.\n *\n * EVERY FAILURE HERE IS EXIT 2, and nothing here can produce any other code.\n * That is the point of parsing being a separate phase from running: once we have\n * a `Command`, every remaining outcome is a fact about a website, and the\n * operator's mistakes are already behind us.\n *\n * `--fail-on` DEFAULTS TO NOTHING (§5.6). `rebilder check <url>` reports and\n * exits 0. A tool that fails a build by default gets added with `|| true` on the\n * first day and is then permanently decorative.\n */\n\nimport { parseArgs } from 'node:util'\nimport { UsageError } from './exit'\n\nexport const FORMATS = ['pretty', 'json', 'markdown', 'junit'] as const\nexport type Format = (typeof FORMATS)[number]\n\nexport const GRADES = ['A', 'B', 'C', 'D', 'F'] as const\nexport type Grade = (typeof GRADES)[number]\n\nexport const COMMANDS = ['check', 'diff', 'init', 'badge'] as const\nexport type CommandName = (typeof COMMANDS)[number]\n\nexport interface CheckCommand {\n name: 'check'\n urls: string[]\n format: Format\n /** `null` = no threshold, the default. Exit 1 is unreachable when null. */\n failOn: Grade | null\n out: string | null\n allowPrivate: boolean\n allowHttp: boolean\n concurrency: number\n}\n\nexport interface DiffCommand {\n name: 'diff'\n url: string\n format: Format\n out: string | null\n allowPrivate: boolean\n allowHttp: boolean\n}\n\nexport interface InitCommand {\n name: 'init'\n /** Framework override; `null` means detect from the working directory. */\n framework: string | null\n out: string | null\n format: Format\n}\n\nexport interface BadgeCommand {\n name: 'badge'\n domain: string\n format: Format\n out: string | null\n}\n\nexport type Command = CheckCommand | DiffCommand | InitCommand | BadgeCommand\n\nexport type ParseResult =\n | { kind: 'command'; command: Command }\n | { kind: 'help'; topic: CommandName | null }\n | { kind: 'version' }\n\n/* ── option table ─────────────────────────────────────────────────────────── */\n\nconst OPTIONS = {\n format: { type: 'string' },\n 'fail-on': { type: 'string' },\n out: { type: 'string' },\n 'allow-private': { type: 'boolean' },\n 'allow-http': { type: 'boolean' },\n concurrency: { type: 'string' },\n framework: { type: 'string' },\n help: { type: 'boolean', short: 'h' },\n version: { type: 'boolean', short: 'v' },\n} as const\n\n/* ── validators ───────────────────────────────────────────────────────────── */\n\nfunction asFormat(value: string | undefined, fallback: Format): Format {\n if (value === undefined) return fallback\n const match = FORMATS.find((format) => format === value)\n if (match === undefined) {\n throw new UsageError(`--format must be one of ${FORMATS.join(', ')} (received \"${value}\")`)\n }\n return match\n}\n\nfunction asGrade(value: string | undefined): Grade | null {\n if (value === undefined) return null\n // Upper-cased before matching: `--fail-on b` is not a mistake worth an error.\n const upper = value.toUpperCase()\n const match = GRADES.find((grade) => grade === upper)\n if (match === undefined) {\n throw new UsageError(`--fail-on must be one of ${GRADES.join(', ')} (received \"${value}\")`)\n }\n return match\n}\n\nconst MAX_CONCURRENCY = 8\n\nfunction asConcurrency(value: string | undefined): number {\n if (value === undefined) return 1\n if (!/^[0-9]+$/.test(value)) {\n throw new UsageError(`--concurrency must be a positive integer (received \"${value}\")`)\n }\n const parsed = Number.parseInt(value, 10)\n if (parsed < 1) throw new UsageError('--concurrency must be at least 1')\n if (parsed > MAX_CONCURRENCY) {\n // Not arbitrary politeness theatre: the probe's limiter caps concurrency per\n // host at 1 and globally at 2 regardless, so a larger number here buys\n // nothing and only reads like a promise we do not keep.\n throw new UsageError(\n `--concurrency is capped at ${MAX_CONCURRENCY}; the probe's politeness limiter allows at most 2 in-flight requests globally in any case`,\n )\n }\n return parsed\n}\n\n/**\n * A domain, not a URL and not a path. Validated by syntax before anything else\n * touches it — `rebilder badge \"https://x.com/a?b\"` should be told what is wrong\n * rather than have a snippet built around a mangled string.\n *\n * Split-and-check rather than one compound regex. The obvious pattern nests a\n * bounded quantifier inside a repeated group, which is a backtracking shape a\n * linter is right to flag; a loop over labels is linear, and it is also easier\n * to read than the lookahead soup the single-regex version needs.\n */\nconst LABEL_CHARS = /^[a-z0-9-]+$/\n\nfunction isLabel(label: string): boolean {\n if (label.length < 1 || label.length > 63) return false\n if (label.startsWith('-') || label.endsWith('-')) return false\n return LABEL_CHARS.test(label)\n}\n\nfunction isDomain(value: string): boolean {\n if (value.length === 0 || value.length > 253) return false\n const labels = value.split('.')\n // At least two labels: `localhost` is not a domain, and a single-label host is\n // exactly the shape the probe's SSRF guard refuses anyway.\n if (labels.length < 2) return false\n return labels.every(isLabel)\n}\n\nexport function normalizeDomain(input: string): string {\n let value = input.trim().toLowerCase()\n if (value.includes('://')) {\n try {\n value = new URL(value).hostname\n } catch {\n throw new UsageError(`\"${input}\" is not a domain`)\n }\n }\n value = value.replace(/\\/.*$/, '').replace(/\\.$/, '')\n if (!isDomain(value)) {\n throw new UsageError(\n `\"${input}\" is not a domain. Pass a registrable hostname such as example.com — not a URL, not a path.`,\n )\n }\n return value\n}\n\n/* ── the parser ───────────────────────────────────────────────────────────── */\n\nexport function parseCommandLine(argv: readonly string[]): ParseResult {\n let parsed: ReturnType<typeof parseArgs<{ options: typeof OPTIONS; allowPositionals: true }>>\n try {\n parsed = parseArgs({\n args: [...argv],\n options: OPTIONS,\n allowPositionals: true,\n strict: true,\n })\n } catch (error) {\n // `parseArgs` throws on unknown options and missing values. Its messages are\n // good; re-wrapping them keeps every parse failure a single error type.\n throw new UsageError(error instanceof Error ? error.message : String(error))\n }\n\n const { values, positionals } = parsed\n const [first, ...rest] = positionals\n\n if (values.version === true) return { kind: 'version' }\n\n if (values.help === true || first === undefined || first === 'help') {\n const topicCandidate = first === 'help' ? rest[0] : first\n const topic = COMMANDS.find((name) => name === topicCandidate) ?? null\n if (first === 'help' && rest[0] !== undefined && topic === null) {\n throw new UsageError(`unknown command \"${rest[0]}\". Expected one of ${COMMANDS.join(', ')}.`)\n }\n return { kind: 'help', topic }\n }\n\n const name = COMMANDS.find((command) => command === first)\n if (name === undefined) {\n throw new UsageError(`unknown command \"${first}\". Expected one of ${COMMANDS.join(', ')}.`)\n }\n\n const out = values.out ?? null\n const allowPrivate = values['allow-private'] === true\n // `--allow-private` implies plain http: the whole point is a staging host on\n // an internal network, and those are rarely on 443 with a valid certificate.\n // It is still expressible on its own for a public host that only serves http.\n const allowHttp = values['allow-http'] === true || allowPrivate\n\n switch (name) {\n case 'check': {\n if (rest.length === 0) {\n throw new UsageError('check needs at least one URL. Usage: rebilder check <url...>')\n }\n return {\n kind: 'command',\n command: {\n name: 'check',\n urls: rest,\n format: asFormat(values.format, 'pretty'),\n failOn: asGrade(values['fail-on']),\n out,\n allowPrivate,\n allowHttp,\n concurrency: asConcurrency(values.concurrency),\n },\n }\n }\n case 'diff': {\n if (rest.length === 0) throw new UsageError('diff needs a URL. Usage: rebilder diff <url>')\n if (rest.length > 1) {\n throw new UsageError(\n 'diff takes exactly one URL. It is a two-representation comparison of a single page; use `check` for a set.',\n )\n }\n if (values['fail-on'] !== undefined) {\n // Refused rather than ignored: silently dropping a flag someone put in a\n // CI file is how a check that appears to gate stops gating.\n throw new UsageError(\n '--fail-on is not supported by `diff`. diff reports what the two representations contain; it does not grade. Use `rebilder check --fail-on`.',\n )\n }\n const url = rest[0]\n if (url === undefined) throw new UsageError('diff needs a URL. Usage: rebilder diff <url>')\n return {\n kind: 'command',\n command: {\n name: 'diff',\n url,\n format: asFormat(values.format, 'pretty'),\n out,\n allowPrivate,\n allowHttp,\n },\n }\n }\n case 'init': {\n if (rest.length > 0) {\n throw new UsageError(\n `init takes no positional arguments (received \"${rest[0]}\"). Use --framework to override detection.`,\n )\n }\n return {\n kind: 'command',\n command: {\n name: 'init',\n framework: values.framework ?? null,\n out,\n format: asFormat(values.format, 'pretty'),\n },\n }\n }\n case 'badge': {\n if (rest.length === 0) {\n throw new UsageError('badge needs a domain. Usage: rebilder badge <domain>')\n }\n if (rest.length > 1) throw new UsageError('badge takes exactly one domain.')\n const domain = rest[0]\n if (domain === undefined) throw new UsageError('badge needs a domain.')\n return {\n kind: 'command',\n command: {\n name: 'badge',\n domain: normalizeDomain(domain),\n format: asFormat(values.format, 'pretty'),\n out,\n },\n }\n }\n }\n}\n","/**\n * commands/badge.ts — the embed snippet, generated locally.\n *\n * IT MAKES NO NETWORK CALL, and could not usefully make one. The badge endpoint\n * renders from the stored `index_entries` row and is architecturally incapable\n * of triggering a probe (§5.6); asking it anything from here would only tell us\n * which domains people are curious about, which is a log we have promised not to\n * keep. So this command is string construction, and the honesty lives in the\n * notes it prints rather than in a lookup.\n *\n * WHAT THE NOTES HAVE TO SAY, because a merchant pasting this into a README is\n * about to be surprised by all four:\n * - The badge only renders a grade for a **verified opted-in** domain. Anything\n * else gets a neutral \"not rated\" badge, at 200 rather than 404 (a broken\n * image on a merchant's site is a support ticket).\n * - It is served live. The owner captures nothing and freezes nothing, and it\n * degrades to \"unverified\" after 30 days without a successful re-scan.\n * - It always names its subject — `example.com · A · 94 · Mar 2026`. A\n * domain-less badge is misappropriable, and that one decision is what makes\n * the whole thing safe.\n * - No score ever comes from the query string.\n *\n * `alt` text carries the domain and the word \"score\" for the same reason the\n * image does: an image whose alt text is \"Rebilder badge\" is one someone can\n * move to a different site and have it still read correctly.\n */\n\nimport type { BadgeCommand } from '../args'\nimport type { BadgeSnippet } from '../payload'\n\nexport const BADGE_ORIGIN = 'https://rebilder.com'\n\nexport function runBadge(command: BadgeCommand): BadgeSnippet {\n const { domain } = command\n const svgUrl = `${BADGE_ORIGIN}/badge/${domain}.svg`\n const pageUrl = `${BADGE_ORIGIN}/readable/${domain}`\n const alt = `Agent Readability Score for ${domain}`\n\n return {\n domain,\n svgUrl,\n pageUrl,\n markdown: `[![${alt}](${svgUrl})](${pageUrl})`,\n html: `<a href=\"${pageUrl}\"><img src=\"${svgUrl}\" alt=\"${alt}\" height=\"20\"></a>`,\n notes: [\n 'A grade renders only for a verified opted-in domain. Every other domain gets a neutral “not rated” badge, served at 200 so it never shows as a broken image.',\n 'Verify by publishing a DNS TXT record `rebilder-verify=<token>`, or by serving `X-Rebilder-Path` from your origin where we can observe it.',\n 'The badge is served live from our data: you capture nothing and freeze nothing. It degrades to “unverified” after 30 days without a successful re-scan.',\n 'It always names its subject (`example.com · A · 94 · Mar 2026`) and it shows the ruleset hash alongside the spec version — two scores from different rulesets must not render identically.',\n 'No score ever comes from the query string. Removal from the index is free, self-serve, permanent, and never purchasable.',\n 'This command makes no network request. It builds the snippet locally, so we never learn which domain you asked about.',\n ],\n }\n}\n","/**\n * commands/check.ts — probe, score, report. The command everything else exists\n * to support.\n *\n * IT DOES TWO THINGS AND NEITHER OF THEM IS INTERPRETATION. `probe()` produces\n * an `ArsEvidence` bundle; `score()` turns that bundle into an `ArsResult`. This\n * file adds a concurrency pool and a URL loop and nothing else — no adjustment,\n * no rounding, no \"close enough to a B\". A CLI that post-processes the score is a\n * second implementation of the standard with no conformance corpus behind it.\n *\n * ONE PROBE FAILURE NEVER STOPS THE RUN. `rebilder check a b c` with `b`\n * unreachable still reports `a` and `c`; the exit code collapses per\n * `worstExit`. The alternative — abort on the first failure — makes a multi-URL\n * check useless in exactly the situation you want it, which is one flaky origin\n * in a set of ten.\n *\n * A `ProbeBudgetExceededError` is the exception, and deliberately so: it comes\n * back as a `budget-exceeded` rejection per URL rather than a thrown error, so\n * the URLs already probed still report.\n */\n\nimport { score } from '@rebilder/agent-readability'\nimport type { CheckCommand } from '../args'\nimport type { UrlReport } from '../report'\nimport type { ProbeRunner } from '../runtime'\n\nexport async function runCheck(command: CheckCommand, probe: ProbeRunner): Promise<UrlReport[]> {\n return mapWithConcurrency(command.urls, command.concurrency, (url) => probeOne(url, probe))\n}\n\nexport async function probeOne(url: string, probe: ProbeRunner): Promise<UrlReport> {\n const outcome = await probe(url)\n if (!outcome.ok) {\n return { kind: 'rejected', url, rejection: outcome.rejection, detail: outcome.detail }\n }\n return { kind: 'probed', url, result: score(outcome.evidence) }\n}\n\n/**\n * A fixed-size worker pool that preserves input order in the output.\n *\n * Order matters more than it looks: `rebilder check a b c --format junit` writes\n * a file a human reads next to the command that produced it, and a report whose\n * suites come back in completion order changes shape between runs for no reason,\n * which makes every diff of two runs noise.\n */\nexport async function mapWithConcurrency<T, R>(\n items: readonly T[],\n concurrency: number,\n worker: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length)\n let next = 0\n\n const lanes = Array.from(\n { length: Math.min(Math.max(1, concurrency), items.length) },\n async () => {\n for (;;) {\n const index = next++\n if (index >= items.length) return\n const item = items[index]\n if (item === undefined) return\n results[index] = await worker(item, index)\n }\n },\n )\n\n await Promise.all(lanes)\n return results\n}\n","/**\n * commands/diff.ts — what an agent got, next to what a browser got.\n *\n * ONE PROBE, TWO VIEWS. The evidence bundle already contains both requests\n * (§3.3: an agent probe and a browser control that differ in `Accept` and in\n * nothing else), so `diff` re-uses the bundle a `check` would have produced\n * rather than issuing its own pair. That is not only cheaper — it is the only\n * way the two commands can agree, and a diff that disagreed with the score would\n * be worse than no diff.\n *\n * IT SHOWS SHAPE, NOT CONTENT. Status, content type, decoded bytes, an estimated\n * token count, redirect count, and the D2.4 substance-parity check verbatim. No\n * body excerpt on either side. The temptation is obvious — \"here is your HTML,\n * here is your markdown\" is a great demo — but dumping a third party's page into\n * a terminal, a CI log, or a `--out` file is a copyright problem the numbers do\n * not have, and §5.3 is explicit that structure and numbers are what we show.\n *\n * The parity check is rendered from `ArsResult`, not recomputed here. §3.8's\n * comparison is normative and narrow (price, currency, availability and title\n * only, post-normalisation, never free text); reimplementing it in a CLI would\n * produce a second opinion with no fixture behind it.\n */\n\nimport { score } from '@rebilder/agent-readability'\nimport type {\n ArsCheck,\n ArsEvidence,\n ArsHttpCapture,\n ArsProbeRecord,\n ArsResult,\n} from '@rebilder/agent-readability'\nimport type { DiffCommand } from '../args'\nimport type { DiffPayload, DiffSide } from '../payload'\nimport type { UrlReport } from '../report'\nimport type { ProbeRunner } from '../runtime'\n\nconst PARITY_CHECK_ID = 'machine-representation.substance-parity'\n\nexport async function runDiff(command: DiffCommand, probe: ProbeRunner): Promise<DiffPayload> {\n const outcome = await probe(command.url)\n\n if (!outcome.ok) {\n const report: UrlReport = {\n kind: 'rejected',\n url: command.url,\n rejection: outcome.rejection,\n detail: outcome.detail,\n }\n return { url: command.url, agent: null, browser: null, parity: null, result: null, report }\n }\n\n const result = score(outcome.evidence)\n const report: UrlReport = { kind: 'probed', url: command.url, result }\n\n return {\n url: command.url,\n agent: sideOf(outcome.evidence, 'agent'),\n browser: sideOf(outcome.evidence, 'browser'),\n parity: parityCheck(result),\n result,\n report,\n }\n}\n\nfunction parityCheck(result: ArsResult): ArsCheck | null {\n for (const dimension of result.dimensions) {\n for (const check of dimension.checks) {\n if (check.id === PARITY_CHECK_ID) return check\n }\n }\n return null\n}\n\nfunction sideOf(evidence: ArsEvidence, role: 'agent' | 'browser'): DiffSide {\n const record: ArsProbeRecord = evidence.probes[role]\n const accept = record.requestHeaders['accept'] ?? '(none)'\n\n if (!record.result.ok) {\n return {\n role,\n accept,\n status: null,\n contentType: null,\n bytes: null,\n approxTokens: null,\n truncated: false,\n redirects: 0,\n error: `${record.result.error}${record.result.detail === undefined ? '' : `: ${record.result.detail}`}`,\n }\n }\n\n const capture: ArsHttpCapture = record.result.capture\n return {\n role,\n accept,\n status: capture.status,\n contentType: capture.headers['content-type']?.[0] ?? null,\n bytes: capture.bytes,\n approxTokens: approxTokensOf(capture),\n truncated: capture.truncated,\n redirects: capture.redirects.length,\n error: null,\n }\n}\n\n/**\n * chars/4, the same heuristic `ArsCostReport` uses, computed from the decoded\n * body when it is in hand and from the byte count otherwise. It is labelled\n * `est.` everywhere it renders — \"chars/4 isn't a token count\" is a fair\n * objection and the answer is the label, not an argument (§3.8).\n */\nfunction approxTokensOf(capture: ArsHttpCapture): number {\n const characters = capture.body?.length ?? capture.bytes\n return Math.round(characters / 4)\n}\n","/**\n * commands/init.ts — a gateway config scaffold for the framework it found.\n *\n * ZERO NETWORK, and that is not incidental. `init` reads `package.json` and a\n * handful of well-known filenames in the working directory and writes a file.\n * Nothing about the user's dependency list, framework choice, or repository\n * leaves the machine — a scaffolding command that phoned home with \"which\n * framework did they pick\" would be exactly the telemetry the README says we do\n * not collect, wearing a helpful hat.\n *\n * THE DETECTION IS PRINTED. Every scaffold says how it decided (`\"next found in\n * package.json dependencies\"`), because a wrong guess with a visible reason is a\n * thirty-second fix and a wrong guess with no reason is a bug report. `--framework`\n * overrides it.\n *\n * THE SCAFFOLD IS A SKELETON WITH A `TODO`, NOT A WORKING CONFIG, and it says so\n * in a comment inside the generated file. `GatewaySources` resolvers read the\n * merchant's source of truth; we cannot know what that is, and a scaffold that\n * looked complete would be a scaffold someone shipped. This is the same rule the\n * variant architecture runs on: substantive values come from source-of-truth\n * fields, never from something we generated (CLAUDE.md Hard Rule 2).\n */\n\nimport { UsageError } from '../exit'\nimport type { InitCommand } from '../args'\nimport type { Scaffold } from '../payload'\nimport type { CliRuntime } from '../runtime'\n\nexport const FRAMEWORKS = ['next', 'node', 'edge', 'shopify'] as const\nexport type Framework = (typeof FRAMEWORKS)[number]\n\ninterface Detection {\n framework: Framework\n reason: string\n}\n\nconst MARKER_FILES: readonly { file: string; framework: Framework; reason: string }[] = [\n {\n file: 'shopify.app.toml',\n framework: 'shopify',\n reason: 'shopify.app.toml in the working directory',\n },\n { file: 'next.config.ts', framework: 'next', reason: 'next.config.ts in the working directory' },\n {\n file: 'next.config.mjs',\n framework: 'next',\n reason: 'next.config.mjs in the working directory',\n },\n { file: 'next.config.js', framework: 'next', reason: 'next.config.js in the working directory' },\n { file: 'wrangler.toml', framework: 'edge', reason: 'wrangler.toml in the working directory' },\n { file: 'wrangler.jsonc', framework: 'edge', reason: 'wrangler.jsonc in the working directory' },\n]\n\nconst DEPENDENCY_MARKERS: readonly { dependency: string; framework: Framework }[] = [\n { dependency: '@shopify/shopify-app-remix', framework: 'shopify' },\n { dependency: '@shopify/shopify-api', framework: 'shopify' },\n { dependency: 'next', framework: 'next' },\n { dependency: '@cloudflare/workers-types', framework: 'edge' },\n { dependency: 'wrangler', framework: 'edge' },\n { dependency: 'hono', framework: 'edge' },\n { dependency: 'express', framework: 'node' },\n { dependency: 'fastify', framework: 'node' },\n]\n\nexport async function detectFramework(runtime: CliRuntime): Promise<Detection> {\n for (const marker of MARKER_FILES) {\n if ((await runtime.readFile(marker.file)) !== null) {\n return { framework: marker.framework, reason: `detected from ${marker.reason}` }\n }\n }\n\n const manifest = await runtime.readFile('package.json')\n if (manifest !== null) {\n let dependencies: Record<string, unknown> = {}\n try {\n const parsed: unknown = JSON.parse(manifest)\n if (typeof parsed === 'object' && parsed !== null) {\n const record = parsed as Record<string, unknown>\n dependencies = {\n ...asRecord(record['dependencies']),\n ...asRecord(record['devDependencies']),\n }\n }\n } catch {\n // A package.json we cannot parse is not an error worth stopping for — it\n // is one signal of several, and the fallback below is honest about it.\n dependencies = {}\n }\n for (const marker of DEPENDENCY_MARKERS) {\n if (marker.dependency in dependencies) {\n return {\n framework: marker.framework,\n reason: `detected from \"${marker.dependency}\" in package.json`,\n }\n }\n }\n }\n\n return {\n framework: 'node',\n reason:\n 'no framework marker found — defaulting to the Node adapter. Pass --framework next|node|edge|shopify to choose.',\n }\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n return typeof value === 'object' && value !== null ? (value as Record<string, unknown>) : {}\n}\n\nexport async function runInit(command: InitCommand, runtime: CliRuntime): Promise<Scaffold> {\n let framework: Framework\n let detection: string\n\n if (command.framework !== null) {\n const match = FRAMEWORKS.find((name) => name === command.framework)\n if (match === undefined) {\n throw new UsageError(\n `--framework must be one of ${FRAMEWORKS.join(', ')} (received \"${command.framework}\")`,\n )\n }\n framework = match\n detection = 'chosen with --framework'\n } else {\n const detected = await detectFramework(runtime)\n framework = detected.framework\n detection = detected.reason\n }\n\n return { ...SCAFFOLDS[framework], framework, detection }\n}\n\nconst SHARED_NOTES: readonly string[] = [\n 'The resolvers return your source of truth. Every substantive value — price, stock, hours, policy text — comes from these fields; the gateway never invents one.',\n 'The gateway has no concept of a plan, licence, tier or quota, and never will. Free-tier cost control happens at ingest, never at the edge.',\n 'Run `rebilder check <url>` before and after to see what changed. Content negotiation is D2.1 (10 points) and unlocks D2.3 and D2.4.',\n]\n\nconst CONFIG_BODY = `import type { GatewayConfig } from '@rebilder/gateway'\n\n/**\n * Wiring to YOUR source of truth. Each resolver takes a URL and returns the\n * fields for that page, or null to fall through to your normal HTML.\n *\n * Resolvers run on the request hot path: p95 < 50ms of compute, and no network\n * call except a cache. Anything slower belongs in a build step.\n */\nexport const gatewayConfig: GatewayConfig = {\n storeId: 'TODO-your-store-id',\n sources: {\n // TODO: return your product fields, or null when the URL is not a PDP.\n product: async (url) => {\n void url\n return null\n },\n // TODO: policies, catalog, document, collection — add the ones you have.\n },\n // Optional: emit @rebilder/events RebilderEventV0 into your observation layer.\n // onEvent: (event) => { void event },\n}\n`\n\nconst SCAFFOLDS: Record<Framework, Omit<Scaffold, 'framework' | 'detection'>> = {\n next: {\n suggestedPath: 'lib/gateway-config.ts',\n language: 'ts',\n notes: [\n 'Then add the proxy: `const gateway = createGatewayProxy(gatewayConfig)` in proxy.ts (Next 16) or middleware.ts (Next 15 and earlier), returning `(await gateway(req)) ?? NextResponse.next()`.',\n ...SHARED_NOTES,\n ],\n contents: `${CONFIG_BODY}\n/* ── proxy.ts (Next 16) or middleware.ts (Next ≤15) ───────────────────────── */\n//\n// import { NextResponse } from 'next/server'\n// import { createGatewayProxy } from '@rebilder/gateway/next'\n// import { gatewayConfig } from './lib/gateway-config'\n//\n// const gateway = createGatewayProxy(gatewayConfig)\n//\n// export default async function proxy(req: Request) {\n// return (await gateway(req)) ?? NextResponse.next()\n// }\n`,\n },\n node: {\n suggestedPath: 'gateway-config.ts',\n language: 'ts',\n notes: [\n 'Then mount it before your routes: `app.use(createGatewayMiddleware(gatewayConfig))`.',\n ...SHARED_NOTES,\n ],\n contents: `${CONFIG_BODY}\n/* ── Express ──────────────────────────────────────────────────────────────── */\n//\n// import express from 'express'\n// import { createGatewayMiddleware } from '@rebilder/gateway/node'\n// import { gatewayConfig } from './gateway-config'\n//\n// const app = express()\n// app.use(createGatewayMiddleware(gatewayConfig)) // before your routes\n`,\n },\n edge: {\n suggestedPath: 'gateway-config.ts',\n language: 'ts',\n notes: [\n 'Then export the fetch handler: `export default { fetch: createGatewayFetchHandler(gatewayConfig) }`.',\n 'On a route-mounted Worker, non-markdown requests pass through to your origin unchanged, so browsers and crawlers keep receiving the canonical HTML.',\n ...SHARED_NOTES,\n ],\n contents: `${CONFIG_BODY}\n/* ── worker.ts (Cloudflare Workers, Vercel Edge, Deno Deploy) ─────────────── */\n//\n// import { createGatewayFetchHandler } from '@rebilder/gateway/edge'\n// import { gatewayConfig } from './gateway-config'\n//\n// export default { fetch: createGatewayFetchHandler(gatewayConfig) }\n`,\n },\n shopify: {\n suggestedPath: 'app/gateway-config.ts',\n language: 'ts',\n notes: [\n 'Then mount the app-proxy handler and give it your app’s shared secret; requests are signature-verified before anything is rendered.',\n ...SHARED_NOTES,\n ],\n contents: `${CONFIG_BODY}\n/* ── Shopify app proxy ────────────────────────────────────────────────────── */\n//\n// import { createShopifyAppProxyHandler } from '@rebilder/gateway/shopify'\n// import { gatewayConfig } from './gateway-config'\n//\n// export const loader = createShopifyAppProxyHandler(gatewayConfig, {\n// sharedSecret: process.env.SHOPIFY_API_SECRET ?? '',\n// })\n`,\n },\n}\n","/**\n * disclosure.ts — the two texts that are not ours to edit for tone.\n *\n * THE NOTICE prints on every result, in every format, including `--format json`\n * and `--format junit`. It is two lines because a one-line version gets read as\n * a tagline; ARS measures the shape of a response and nothing else, and a number\n * that travels without that sentence is a number people will read as a quality\n * score for the business. (Design §3.6.)\n *\n * THE CONFLICT-OF-INTEREST DISCLOSURE prints in `--help` (design §3.7, which\n * requires it at the top of `/spec/ars`, on every scanner result, and in the CLI\n * `--help`). We author the standard and sell middleware that satisfies two of\n * its checks. Publishing the ruleset, the thresholds and the corpus is what makes\n * that auditable rather than hidden, and saying so out loud is the rest of it.\n *\n * Both are exported as constants and asserted by tests. They are not template\n * strings and they take no parameters: a disclosure whose text varies by context\n * is a disclosure someone will tune.\n */\n\n/** Design §3.6. Prints on every result, every format. */\nexport const ARS_NOTICE_LINES: readonly string[] = [\n 'ARS measures format and retrievability. It does not measure whether the',\n 'facts are true, or whether any assistant cites this page.',\n]\n\nexport const ARS_NOTICE = ARS_NOTICE_LINES.join(' ')\n\n/** Design §3.7. Prints in `--help`. */\nexport const CONFLICT_OF_INTEREST_LINES: readonly string[] = [\n 'ARS is authored by Rebilder, which sells content-negotiation middleware.',\n 'Two ARS checks (D2.1 content negotiation, D5 structured data) can be',\n 'satisfied by Rebilder’s free gateway, and reaching an A requires both.',\n 'The full ruleset, thresholds, and conformance corpus are published so this',\n 'bias is auditable rather than hidden.',\n]\n\nexport const CONFLICT_OF_INTEREST = CONFLICT_OF_INTEREST_LINES.join(' ')\n\n/**\n * The no-telemetry contract, printed in `--help` next to the disclosure.\n *\n * It is here rather than only in the README because the person who needs to read\n * it is the one deciding whether to run `--allow-private` against an internal\n * hostname inside their own CI, and they are looking at a terminal.\n */\nexport const TELEMETRY_LINES: readonly string[] = [\n 'This CLI ships zero telemetry. It never uploads a scan, a URL, a hostname,',\n 'or a result. The only requests it makes are to the target you name.',\n]\n","/**\n * report.ts — one URL's outcome, and the mapping from that outcome to an exit\n * code.\n *\n * THIS FILE IS WHERE THE 1-vs-3 SPLIT IS ACTUALLY ENFORCED, so it is small on\n * purpose and there is a test asserting the property directly: for every\n * `ArsUnscoredReason`, every `ProbeRejection`, and the opt-out outcome, the code\n * is never `EXIT.THRESHOLD`. Only a real integer score, compared against a\n * threshold the operator asked for, produces 1.\n *\n * THE THREE-WAY SPLIT OF \"WE DID NOT GET A SCORE\" mirrors `ArsOutcome`:\n * - `opt-out` — the site said no, deliberately and in well-formed robots. That\n * is a choice, not a failure, and §3.6 gives it no letter grade. Exit 4.\n * - `unscored` — a missing observation. Mostly transient (timeout, 5xx, edge\n * challenge) so exit 3, EXCEPT `robots-disallow-scanner`, which is a\n * deterministic refusal aimed at us and re-running will never change it.\n * - a probe `rejection` — we never sent the request: unparseable URL (2, the\n * operator's typo), guard refusal (4), exhausted budget (4).\n */\n\nimport type { ArsResult } from '@rebilder/agent-readability'\nimport type { ProbeRejection } from '@rebilder/agent-readability/probe'\nimport { EXIT, type ExitCode } from './exit'\nimport { GRADES, type Grade } from './args'\n\n/**\n * `'probed'` means the probe returned an evidence bundle and `score()` judged it.\n * It does NOT mean the judgment was a grade: an unscored or opted-out result is a\n * `'probed'` report carrying an `ArsResult` whose `outcome.kind` says so. The\n * discriminant answers \"did we get evidence\", and `outcome.kind` answers \"what\n * did the evidence say\" — collapsing the two is how a 403 ends up rendered as an\n * F.\n */\nexport type UrlReport =\n | { kind: 'probed'; url: string; result: ArsResult }\n | { kind: 'rejected'; url: string; rejection: ProbeRejection; detail: string }\n\n/** A .. F, best first. `indexOf` on this is the whole comparison. */\nconst ORDER: readonly Grade[] = GRADES\n\n/**\n * `--fail-on C` means \"C or better passes\". A grade strictly worse than the\n * threshold fails; the threshold grade itself passes. Stated in the README with\n * the same sentence, because the off-by-one reading (\"fail on C\" = \"C fails\") is\n * the one people assume half the time.\n */\nexport function meetsThreshold(grade: Grade, failOn: Grade): boolean {\n return ORDER.indexOf(grade) <= ORDER.indexOf(failOn)\n}\n\nexport function exitCodeFor(report: UrlReport, failOn: Grade | null): ExitCode {\n if (report.kind === 'rejected') {\n switch (report.rejection) {\n case 'invalid-url':\n return EXIT.USAGE\n case 'policy-rejected':\n case 'budget-exceeded':\n return EXIT.POLICY\n }\n }\n\n const { outcome } = report.result\n switch (outcome.kind) {\n case 'opt-out':\n return EXIT.POLICY\n case 'unscored':\n return outcome.reason === 'robots-disallow-scanner' ? EXIT.POLICY : EXIT.PROBE\n case 'scored':\n if (failOn === null) return EXIT.OK\n return meetsThreshold(outcome.grade, failOn) ? EXIT.OK : EXIT.THRESHOLD\n }\n}\n\n/* ── human-readable one-liners, shared by every formatter ─────────────────── */\n\nconst UNSCORED_TEXT: Record<string, string> = {\n 'blocked-at-edge': 'blocked at the edge (403 or challenge) — the block is itself the finding',\n unreachable: 'unreachable',\n 'non-2xx': 'the agent path did not return 2xx',\n 'too-many-redirects': 'too many redirects',\n 'robots-disallow-scanner': 'robots.txt disallows rebilder-ars — we obeyed it and did not score',\n 'robots-unavailable':\n 'robots.txt returned a persistent error; a policy we cannot read is not a policy we may assume',\n 'truncated-evidence': 'the response exceeded the 2 MiB body cap and the evidence is incomplete',\n 'evidence-incomplete': 'the evidence bundle is incomplete',\n}\n\nconst REJECTION_TEXT: Record<ProbeRejection, string> = {\n 'invalid-url': 'not a URL',\n 'policy-rejected': 'refused by the URL guard',\n 'budget-exceeded': 'the probe budget for this run is spent',\n}\n\n/** One line describing the outcome. No grade, no score — those render separately. */\nexport function outcomeSummary(report: UrlReport): string {\n if (report.kind === 'rejected') {\n return `${REJECTION_TEXT[report.rejection]}: ${report.detail}`\n }\n const { outcome } = report.result\n switch (outcome.kind) {\n case 'scored':\n return `${outcome.score}/100 ${outcome.grade}`\n case 'opt-out':\n return `OPT-OUT — a deliberate, well-formed robots disallow for the ${outcome.audience} audience. Not a failure and not a grade.`\n case 'unscored':\n return `UNSCORED — ${UNSCORED_TEXT[outcome.reason] ?? outcome.reason}${\n outcome.detail === undefined ? '' : ` (${outcome.detail})`\n }`\n }\n}\n\n/** `'scored' | 'opt-out' | 'unscored' | 'rejected'` — the coarse status. */\nexport function statusOf(report: UrlReport): 'scored' | 'opt-out' | 'unscored' | 'rejected' {\n return report.kind === 'rejected' ? 'rejected' : report.result.outcome.kind\n}\n","/**\n * format/json.ts — the machine format.\n *\n * IT EMITS THE `ArsResult` VERBATIM. Not a summary, not a flattened view: the\n * whole published contract from `@rebilder/agent-readability`, so that anything\n * downstream reads the same shape as the scanner, the MCP server and a second\n * implementation of the spec. A CLI-specific projection would be a second\n * schema to version, and the first time it drifted from `ArsResult` we would\n * have two answers to \"what did ARS say\".\n *\n * WHAT IS DELIBERATELY ABSENT: the target page's body. `ArsResult` never carries\n * it (`ArsHttpCapture.body` lives in the evidence bundle, which is not part of a\n * result, and `src/types.ts` says it must never reach a published bundle), and\n * this file does not go and get it. Piping `--format json` into a build artifact\n * must not be a way to archive somebody else's copyrighted page.\n *\n * `notice` is a FIELD, not a comment, because JSON has no comments and §3.6\n * requires the sentence on every surface — including the one a dashboard renders\n * from. A consumer that shows an ARS number has the disclaimer in the same\n * object and no excuse.\n */\n\nimport { ARS_NOTICE } from '../disclosure'\nimport type { Payload } from '../payload'\nimport { exitCodeFor, outcomeSummary, statusOf } from '../report'\nimport type { FormatContext } from './shared'\n\nexport function renderJson(payload: Payload, ctx: FormatContext): string {\n return JSON.stringify(jsonValue(payload, ctx), null, 2) + '\\n'\n}\n\nfunction jsonValue(payload: Payload, ctx: FormatContext): unknown {\n const envelope = {\n tool: 'rebilder',\n toolVersion: ctx.cliVersion,\n generatedAt: ctx.generatedAt,\n notice: ARS_NOTICE,\n }\n\n switch (payload.command) {\n case 'check':\n return {\n ...envelope,\n command: 'check',\n failOn: payload.failOn,\n results: payload.reports.map((report) => ({\n url: report.url,\n status: statusOf(report),\n summary: outcomeSummary(report),\n exitCode: exitCodeFor(report, payload.failOn),\n ...(report.kind === 'rejected'\n ? { rejection: report.rejection, detail: report.detail, result: null }\n : { rejection: null, detail: null, result: report.result }),\n })),\n }\n case 'diff':\n return {\n ...envelope,\n command: 'diff',\n url: payload.diff.url,\n status: statusOf(payload.diff.report),\n agent: payload.diff.agent,\n browser: payload.diff.browser,\n substanceParity: payload.diff.parity,\n result: payload.diff.result,\n }\n case 'init':\n return { ...envelope, command: 'init', scaffold: payload.scaffold }\n case 'badge':\n return { ...envelope, command: 'badge', badge: payload.badge }\n }\n}\n","/**\n * format/shared.ts — the small vocabulary every formatter needs, in one place so\n * the four of them cannot drift.\n *\n * THE RULE THIS FILE EXISTS TO MAKE MECHANICAL (CLAUDE.md Hard Rule 10): a\n * heuristic value never renders without its label. Not \"usually\", not \"in the\n * detailed view\" — never. So `basisLabel()` is the only way any formatter gets\n * the word, `approxTokens()` is the only way any formatter prints a token count\n * and it always carries `≈` and `est.`, and `bytesText()` is the only way any\n * formatter prints a byte figure and it renders `≥ N` whenever the capture was\n * truncated. A formatter that wants to print one of these without its label has\n * to write the code to do it, which is a diff a reviewer can see.\n */\n\nimport type { ArsBasis, ArsCheck } from '@rebilder/agent-readability'\n\nexport interface FormatContext {\n unicode: boolean\n generatedAt: string\n /** The CLI's own version, printed so a report can be traced to a build. */\n cliVersion: string\n}\n\n/**\n * The \"there is no value here\" placeholder. It respects the Unicode capability\n * for the same reason the box glyphs do: an em dash in a `LANG=C` container is\n * mojibake, and mojibake in a build log reads as a crash.\n */\nexport function absent(unicode: boolean): string {\n return unicode ? '\\u2014' : '-'\n}\n\n/** Never abbreviated to \"H\"/\"M\". The whole point is that it is readable. */\nexport function basisLabel(basis: ArsBasis): string {\n return basis === 'heuristic' ? 'heuristic' : 'measured'\n}\n\n/**\n * Decoded UTF-8 bytes. `truncated` turns the number into a lower bound, because\n * silently reporting a truncated body as a total makes the heaviest pages look\n * cheapest on D3.2 — the one number the product is built on (§3.3).\n */\nexport function bytesText(bytes: number | null, truncated: boolean, unicode: boolean): string {\n if (bytes === null) return absent(unicode)\n const formatted = `${bytes.toLocaleString('en-US')} B`\n if (!truncated) return formatted\n return `${unicode ? '≥' : '>='} ${formatted} (truncated at the 2 MiB cap)`\n}\n\n/**\n * chars/4. A heuristic, and labelled as one every single time it appears —\n * \"chars/4 isn't a token count\" is a fair objection and the answer is to stop\n * pretending otherwise, not to argue (§3.8).\n */\nexport function approxTokens(tokens: number | null, unicode: boolean): string {\n if (tokens === null) return absent(unicode)\n return `${unicode ? '≈' : '~'}${tokens.toLocaleString('en-US')} tokens (est.)`\n}\n\nexport function percent(numerator: number, denominator: number): string {\n if (denominator === 0) return '0%'\n return `${Math.round((numerator * 100) / denominator)}%`\n}\n\n/** ✔ full marks · ◐ partial · ✘ nothing earned. */\nexport function checkMark(check: ArsCheck, unicode: boolean): string {\n if (check.earned >= check.weight) return unicode ? '✔' : '+'\n if (check.earned > 0) return unicode ? '◐' : '~'\n return unicode ? '✘' : 'x'\n}\n\nexport function shortHash(hash: string): string {\n return hash.slice(0, 12)\n}\n\n/** XML text-node / attribute escaping. Used by the JUnit writer. */\nexport function escapeXml(text: string): string {\n return (\n text\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;')\n // Control characters are illegal in XML 1.0 even escaped; a page title with\n // a stray 0x08 in it would otherwise produce a file no CI parser will read.\n .replace(/[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F]/g, '')\n )\n}\n\n/** Markdown table-cell escaping: a `|` in a URL otherwise splits the row. */\nexport function escapeCell(text: string): string {\n return text.replace(/\\|/g, '\\\\|').replace(/\\r?\\n/g, ' ')\n}\n","/**\n * format/junit.ts — one XML file every CI system already knows how to read.\n *\n * THE MAPPING, AND WHY IT IS NOT THE OBVIOUS ONE.\n *\n * A `<testcase>` per ARS check, a `<testsuite>` per URL. The obvious mapping —\n * one test case per URL, pass/fail on the threshold — throws away the entire\n * report and gives a reviewer a red X with no location, which is precisely the\n * experience that gets a check deleted.\n *\n * The critical distinction is `<failure>` vs `<error>`, which is the JUnit\n * schema's own version of our 1-vs-3 split and the reason this format is worth\n * writing by hand:\n * - `<failure>` — the page was scored and a check did not earn full marks.\n * A fact about the site.\n * - `<error>` — we never got a score: unreachable, blocked, refused, opt-out.\n * Infrastructure. Every CI dashboard renders errors differently from\n * failures, and getting this backwards is what teaches a team to ignore the\n * job.\n * A run whose target was unreachable therefore produces zero failures and one\n * error, and the process exits 3 — the two signals agree.\n *\n * `--fail-on` adds ONE extra test case per URL, named for the threshold, so the\n * gate is visible in the report as its own line rather than implied by the exit\n * code. When no threshold is set that case is absent, not passing: a green\n * \"threshold met\" for a threshold nobody asked for is a lie of omission.\n */\n\nimport { ARS_NOTICE } from '../disclosure'\nimport type { Payload } from '../payload'\nimport { exitCodeFor, meetsThreshold, outcomeSummary, statusOf, type UrlReport } from '../report'\nimport type { Grade } from '../args'\nimport { EXIT } from '../exit'\nimport { basisLabel, escapeXml, type FormatContext } from './shared'\n\nconst SUITE_NAME = 'rebilder.ars'\n\nexport function renderJunit(payload: Payload, ctx: FormatContext): string {\n const suites: string[] = []\n let tests = 0\n let failures = 0\n let errors = 0\n\n if (payload.command === 'check') {\n for (const report of payload.reports) {\n const suite = checkSuite(report, payload.failOn, ctx)\n suites.push(suite.xml)\n tests += suite.tests\n failures += suite.failures\n errors += suite.errors\n }\n } else if (payload.command === 'diff') {\n const suite = checkSuite(payload.diff.report, null, ctx)\n suites.push(suite.xml)\n tests += suite.tests\n failures += suite.failures\n errors += suite.errors\n } else {\n // `init` and `badge` produce no observations, so they produce no test cases.\n // An empty testsuites element is valid and honest; inventing a passing case\n // for \"we printed a snippet\" would put a green tick in a report for work no\n // check performed.\n suites.push(\n ` <testsuite name=\"${SUITE_NAME}.${payload.command}\" tests=\"0\" failures=\"0\" errors=\"0\"/>`,\n )\n }\n\n return [\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\n `<testsuites name=\"${SUITE_NAME}\" tests=\"${tests}\" failures=\"${failures}\" errors=\"${errors}\">`,\n ...suites,\n '</testsuites>',\n '',\n ].join('\\n')\n}\n\ninterface Suite {\n xml: string\n tests: number\n failures: number\n errors: number\n}\n\nfunction checkSuite(report: UrlReport, failOn: Grade | null, ctx: FormatContext): Suite {\n const cases: string[] = []\n let tests = 0\n let failures = 0\n let errors = 0\n\n const properties = [\n ` <property name=\"notice\" value=\"${escapeXml(ARS_NOTICE)}\"/>`,\n ` <property name=\"url\" value=\"${escapeXml(report.url)}\"/>`,\n ` <property name=\"generatedAt\" value=\"${escapeXml(ctx.generatedAt)}\"/>`,\n ` <property name=\"tool\" value=\"rebilder ${escapeXml(ctx.cliVersion)}\"/>`,\n ]\n\n if (report.kind === 'probed') {\n const { result } = report\n properties.push(\n ` <property name=\"specVersion\" value=\"${escapeXml(result.specVersion)}\"/>`,\n ` <property name=\"rulesetHash\" value=\"${escapeXml(result.rulesetHash)}\"/>`,\n ` <property name=\"corpusHash\" value=\"${escapeXml(result.corpusHash)}\"/>`,\n ` <property name=\"evidenceHash\" value=\"${escapeXml(result.evidenceHash)}\"/>`,\n ` <property name=\"measuredWeight\" value=\"${result.measuredWeight}\"/>`,\n ` <property name=\"heuristicWeight\" value=\"${result.heuristicWeight}\"/>`,\n )\n }\n\n const status = statusOf(report)\n // Narrowed on `report.kind` rather than on `status`, because the compiler can\n // follow the discriminant and cannot follow a helper's return value — and a\n // cast here would be a cast around the one branch that must not be wrong.\n if (report.kind === 'rejected' || report.result.outcome.kind !== 'scored') {\n // Never scored -> exactly one ERROR case. Not a failure: see the header.\n tests += 1\n errors += 1\n cases.push(\n [\n ` <testcase classname=\"${escapeXml(report.url)}\" name=\"probe\">`,\n ` <error type=\"${escapeXml(status)}\" message=\"${escapeXml(outcomeSummary(report))}\"/>`,\n ' </testcase>',\n ].join('\\n'),\n )\n } else {\n const { result } = report\n for (const dimension of result.dimensions) {\n for (const check of dimension.checks) {\n tests += 1\n const passed = check.earned >= check.weight\n const name = `${check.id} [${basisLabel(check.basis)}] ${check.earned}/${check.weight}`\n if (passed) {\n cases.push(\n ` <testcase classname=\"${escapeXml(report.url)}\" name=\"${escapeXml(name)}\"/>`,\n )\n continue\n }\n failures += 1\n const detail = [\n check.remedy ?? '',\n ...check.evidence.map(\n (item) => `${item.label}: ${item.value} [${basisLabel(item.basis)}]`,\n ),\n ]\n .filter((line) => line.length > 0)\n .join('\\n')\n cases.push(\n [\n ` <testcase classname=\"${escapeXml(report.url)}\" name=\"${escapeXml(name)}\">`,\n ` <failure type=\"${escapeXml(check.basis)}\" message=\"${escapeXml(`${check.label} earned ${check.earned} of ${check.weight}`)}\">${escapeXml(detail)}</failure>`,\n ' </testcase>',\n ].join('\\n'),\n )\n }\n }\n\n if (failOn !== null && result.grade !== null) {\n tests += 1\n const met = meetsThreshold(result.grade, failOn)\n const name = `threshold --fail-on ${failOn}`\n if (met) {\n cases.push(` <testcase classname=\"${escapeXml(report.url)}\" name=\"${escapeXml(name)}\"/>`)\n } else {\n failures += 1\n cases.push(\n [\n ` <testcase classname=\"${escapeXml(report.url)}\" name=\"${escapeXml(name)}\">`,\n ` <failure type=\"threshold\" message=\"${escapeXml(`graded ${result.grade} (${result.score}/100); the threshold is ${failOn} or better`)}\"/>`,\n ' </testcase>',\n ].join('\\n'),\n )\n }\n }\n }\n\n const exitCode = exitCodeFor(report, failOn)\n properties.push(` <property name=\"exitCode\" value=\"${exitCode}\"/>`)\n if (exitCode === EXIT.PROBE || exitCode === EXIT.POLICY) {\n properties.push(\n ` <property name=\"notAScoreFailure\" value=\"${exitCode === EXIT.PROBE ? 'probe failure — infrastructure' : 'blocked by policy'}\"/>`,\n )\n }\n\n const xml = [\n ` <testsuite name=\"${escapeXml(report.url)}\" tests=\"${tests}\" failures=\"${failures}\" errors=\"${errors}\">`,\n ' <properties>',\n ...properties,\n ' </properties>',\n ...cases,\n ' </testsuite>',\n ].join('\\n')\n\n return { xml, tests, failures, errors }\n}\n","/**\n * format/markdown.ts — for a PR comment or a job summary.\n *\n * This is the format that gets pasted into a place other people read, which\n * changes two things about it. First, the basis column is not optional and not\n * abbreviated: someone is going to screenshot the table, and a heuristic point\n * total with no label next to it is exactly the misuse Hard Rule 10 exists to\n * prevent. Second, the §3.6 notice renders as a blockquote at the end of every\n * report, where it survives being copied — a footnote in small text does not.\n *\n * No page excerpts here either, for the same reason as everywhere else: numbers\n * and structure only.\n */\n\nimport type { ArsResult } from '@rebilder/agent-readability'\nimport { ARS_NOTICE_LINES } from '../disclosure'\nimport type { DiffPayload, Payload } from '../payload'\nimport { outcomeSummary, statusOf, type UrlReport } from '../report'\nimport {\n approxTokens,\n basisLabel,\n bytesText,\n escapeCell,\n shortHash,\n type FormatContext,\n} from './shared'\n\nexport function renderMarkdown(payload: Payload, ctx: FormatContext): string {\n switch (payload.command) {\n case 'check':\n return payload.reports.map((report) => checkSection(report)).join('\\n---\\n\\n') + notice()\n case 'diff':\n return diffSection(payload.diff) + notice()\n case 'init':\n return initSection(payload, ctx)\n case 'badge':\n return badgeSection(payload)\n }\n}\n\nfunction notice(): string {\n return `\\n${ARS_NOTICE_LINES.map((line) => `> ${line}`).join('\\n')}\\n`\n}\n\nfunction checkSection(report: UrlReport): string {\n const out: string[] = [`## ${escapeCell(report.url)}`, '']\n\n if (report.kind === 'rejected') {\n out.push(`**REJECTED** — ${outcomeSummary(report)}`, '')\n return out.join('\\n')\n }\n\n const { result } = report\n if (statusOf(report) !== 'scored') {\n out.push(outcomeSummary(report), '')\n out.push(policyLine(result), '')\n out.push(identityLine(result), '')\n return out.join('\\n')\n }\n\n out.push(\n `**${result.grade} — ${result.bandLabel}** · ${result.score}/100 · page kind \\`${result.pageKind}\\` (${result.pageKindConfidence} confidence, ${basisLabel(result.pageKindBasis)})`,\n '',\n `${result.measuredWeight} of the 100 points are measured; ${result.heuristicWeight} are heuristic.`,\n '',\n '| Check | Points | Basis |',\n '| --- | ---: | --- |',\n )\n\n for (const dimension of result.dimensions) {\n out.push(\n `| **${escapeCell(dimension.label)}** | **${dimension.earned}/${dimension.weight}** | ${basisLabel(dimension.basis)} |`,\n )\n for (const check of dimension.checks) {\n out.push(\n `| ${escapeCell(check.label)} | ${check.earned}/${check.weight} | ${basisLabel(check.basis)} |`,\n )\n }\n }\n\n out.push('', '### What an agent pays', '')\n out.push('| | Bytes | Tokens |', '| --- | --- | --- |')\n out.push(\n `| HTML | ${bytesText(result.cost.htmlBytes, result.cost.truncated, true)} | ${approxTokens(result.cost.approxHtmlTokens, true)} |`,\n )\n out.push(\n `| Negotiated | ${bytesText(result.cost.negotiatedBytes, result.cost.truncated, true)} | ${approxTokens(result.cost.approxNegotiatedTokens, true)} |`,\n )\n if (result.cost.reductionRatio !== null) {\n out.push(`| Reduction | ${result.cost.reductionRatio}% | |`)\n }\n\n if (result.flags.length > 0) {\n out.push('', '### Flags', '')\n for (const flag of result.flags) {\n out.push(`- \\`${flag.id}\\` (${flag.severity}, ${basisLabel(flag.basis)}) — ${flag.message}`)\n }\n }\n\n if (result.recommendations.length > 0) {\n out.push('', '### Fixes, most points first', '')\n out.push('| Points | Fix | Effort |', '| ---: | --- | --- |')\n for (const recommendation of result.recommendations) {\n out.push(\n `| +${recommendation.pointsAvailable} | ${escapeCell(recommendation.title)} | ${recommendation.effort} |`,\n )\n }\n }\n\n out.push('', policyLine(result), '', identityLine(result), '')\n return out.join('\\n')\n}\n\nfunction policyLine(result: ArsResult): string {\n const { policy } = result\n return `Policy: robots.txt ${policy.robotsTxtStatus} · assistant ${policy.audiences.assistant.decision} · training ${policy.audiences.training.decision} (neutral) · sitemap ${policy.sitemapDeclared ? 'declared' : 'not declared'}`\n}\n\nfunction identityLine(result: ArsResult): string {\n return `ARS ${result.specVersion} · ruleset \\`${shortHash(result.rulesetHash)}\\` · corpus \\`${shortHash(result.corpusHash)}\\` · evidence \\`${shortHash(result.evidenceHash)}\\` · vantage ${result.vantage}`\n}\n\nfunction diffSection(diff: DiffPayload): string {\n const out: string[] = [`## ${escapeCell(diff.url)} — agent view vs browser view`, '']\n if (diff.report.kind === 'rejected') {\n out.push(`**REJECTED** — ${outcomeSummary(diff.report)}`, '')\n return out.join('\\n')\n }\n out.push(\n 'The two requests differ in the `Accept` header and in nothing else — same User-Agent, same everything.',\n '',\n '| | Agent | Browser |',\n '| --- | --- | --- |',\n `| Accept | \\`${escapeCell(diff.agent?.accept ?? '—')}\\` | \\`${escapeCell(diff.browser?.accept ?? '—')}\\` |`,\n `| Status | ${diff.agent?.status ?? '—'} | ${diff.browser?.status ?? '—'} |`,\n `| Content-Type | ${escapeCell(diff.agent?.contentType ?? '—')} | ${escapeCell(diff.browser?.contentType ?? '—')} |`,\n `| Bytes | ${bytesText(diff.agent?.bytes ?? null, diff.agent?.truncated ?? false, true)} | ${bytesText(diff.browser?.bytes ?? null, diff.browser?.truncated ?? false, true)} |`,\n `| Tokens | ${approxTokens(diff.agent?.approxTokens ?? null, true)} | ${approxTokens(diff.browser?.approxTokens ?? null, true)} |`,\n `| Redirects | ${diff.agent?.redirects ?? '—'} | ${diff.browser?.redirects ?? '—'} |`,\n )\n if (diff.parity !== null) {\n out.push(\n '',\n `### Substance parity — ${diff.parity.earned}/${diff.parity.weight} (${basisLabel(diff.parity.basis)})`,\n '',\n 'Compared on price, currency, availability and title only — never description or free text.',\n '',\n )\n for (const evidence of diff.parity.evidence) {\n out.push(\n `- ${escapeCell(evidence.label)}: ${escapeCell(evidence.value)} (${basisLabel(evidence.basis)})`,\n )\n }\n }\n if (diff.result !== null) out.push('', identityLine(diff.result), '')\n return out.join('\\n')\n}\n\nfunction initSection(payload: Extract<Payload, { command: 'init' }>, ctx: FormatContext): string {\n const { scaffold } = payload\n const out = [\n `## Rebilder gateway scaffold — ${scaffold.framework}`,\n '',\n scaffold.detection,\n '',\n `Suggested path: \\`${scaffold.suggestedPath}\\``,\n '',\n '```' + scaffold.language,\n scaffold.contents.trimEnd(),\n '```',\n '',\n ]\n for (const note of scaffold.notes) out.push(`- ${note}`)\n out.push('', `<!-- generated by rebilder ${ctx.cliVersion} -->`, '')\n return out.join('\\n')\n}\n\nfunction badgeSection(payload: Extract<Payload, { command: 'badge' }>): string {\n const { badge } = payload\n const out = [\n `## Rebilder badge — ${badge.domain}`,\n '',\n '```markdown',\n badge.markdown,\n '```',\n '',\n '```html',\n badge.html,\n '```',\n '',\n ]\n for (const note of badge.notes) out.push(`- ${note}`)\n out.push('')\n return out.join('\\n')\n}\n","/**\n * term.ts — hand-rolled ANSI and box drawing. Zero runtime dependencies (§5.6).\n *\n * WHY NOT `chalk`/`picocolors`/`cli-table3`. This binary is installed with\n * `npx rebilder check` by people who have not decided to trust us yet, inside CI\n * containers where every transitive dependency is an supply-chain question they\n * have to answer on our behalf. Colour is sixteen escape sequences and a table is\n * a loop; neither is worth a dependency, and \"zero deps\" is a claim we can only\n * make if we never make an exception for the easy one.\n *\n * TWO CAPABILITIES, DECIDED SEPARATELY, because they fail in different places:\n *\n * - COLOUR is off unless stdout is a TTY, and off unconditionally when\n * `NO_COLOR` is set to anything at all (no-color.org: the variable's presence\n * is the signal, its value is not). `FORCE_COLOR` turns it back on for the\n * case that actually matters — a CI runner that renders ANSI in its log\n * viewer while presenting a pipe to the process.\n *\n * - UNICODE is decided by the locale, not by the TTY. A pipe into a file is\n * perfectly capable of holding `│`; a Windows console at code page 437 is not,\n * and neither is a `LANG=C` container. So: use box-drawing characters when the\n * locale says UTF-8, fall back to `+-|` otherwise. Getting this wrong is not\n * cosmetic — mojibake in a build log is indistinguishable from a crash.\n *\n * Everything here takes its environment as an argument. Nothing reads\n * `process.env` or `process.stdout` at module scope, so a test can render both\n * branches without touching the process.\n */\n\nexport interface TermCapabilities {\n color: boolean\n unicode: boolean\n /** Columns available for output. Clamped to a sane range. */\n width: number\n}\n\nexport interface TermEnvironment {\n env: Readonly<Record<string, string | undefined>>\n isTty: boolean\n columns?: number | undefined\n}\n\nconst MIN_WIDTH = 40\nconst MAX_WIDTH = 100\n\nexport function detectCapabilities(environment: TermEnvironment): TermCapabilities {\n const { env, isTty } = environment\n\n // no-color.org: presence is the signal. An empty string still counts.\n const noColor = env['NO_COLOR'] !== undefined\n const forceColor = env['FORCE_COLOR'] !== undefined && env['FORCE_COLOR'] !== '0'\n const dumbTerm = env['TERM'] === 'dumb'\n const color = !noColor && !dumbTerm && (forceColor || isTty)\n\n const locale = `${env['LC_ALL'] ?? ''} ${env['LC_CTYPE'] ?? ''} ${env['LANG'] ?? ''}`\n const unicode = /utf-?8/i.test(locale)\n\n const raw = environment.columns ?? 80\n const width = Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, Number.isFinite(raw) ? raw : 80))\n\n return { color, unicode, width }\n}\n\n/* ── colour ───────────────────────────────────────────────────────────────── */\n\nconst CODES = {\n reset: 0,\n bold: 1,\n dim: 2,\n red: 31,\n green: 32,\n yellow: 33,\n blue: 34,\n magenta: 35,\n cyan: 36,\n gray: 90,\n} as const\n\nexport type Style = keyof typeof CODES\n\nexport interface Painter {\n (text: string, ...styles: Style[]): string\n readonly enabled: boolean\n}\n\nexport function createPainter(enabled: boolean): Painter {\n const paint = (text: string, ...styles: Style[]): string => {\n if (!enabled || styles.length === 0) return text\n const open = styles.map((style) => `\\u001b[${CODES[style]}m`).join('')\n return `${open}${text}\\u001b[${CODES.reset}m`\n }\n return Object.assign(paint, { enabled })\n}\n\n/**\n * Visible width, ignoring escape sequences. Deliberately NOT a full grapheme\n * width implementation: that is `string-width` plus `emoji-regex` plus a Unicode\n * table, i.e. the dependency tree we refused. We control every string that goes\n * through the table renderer except the URL and the page title, and both are\n * truncated by code point before they get here, so the failure mode of this\n * approximation is a column one cell wide in the far east — not a crash, and not\n * a wrong number.\n */\nconst ANSI_RE = /\\u001b\\[[0-9;]*m/g\n\nexport function visibleWidth(text: string): number {\n // Code points, not UTF-16 units: `[...s].length` counts an astral character\n // once, `s.length` counts it twice and pads the column short by one.\n return [...text.replace(ANSI_RE, '')].length\n}\n\nexport function padEnd(text: string, width: number): string {\n const pad = width - visibleWidth(text)\n return pad > 0 ? text + ' '.repeat(pad) : text\n}\n\nexport function padStart(text: string, width: number): string {\n const pad = width - visibleWidth(text)\n return pad > 0 ? ' '.repeat(pad) + text : text\n}\n\n/** Truncates by code point (never mid-surrogate), with an ellipsis marker. */\nexport function truncate(text: string, width: number, unicode: boolean): string {\n if (visibleWidth(text) <= width) return text\n const marker = unicode ? '…' : '...'\n const budget = Math.max(0, width - marker.length)\n let out = ''\n let used = 0\n for (const codePoint of text) {\n if (used + 1 > budget) break\n out += codePoint\n used += 1\n }\n return out + marker\n}\n\n/* ── box drawing ──────────────────────────────────────────────────────────── */\n\nexport interface BoxGlyphs {\n horizontal: string\n vertical: string\n topLeft: string\n topRight: string\n bottomLeft: string\n bottomRight: string\n teeLeft: string\n teeRight: string\n bullet: string\n check: string\n cross: string\n partial: string\n arrow: string\n}\n\nconst UNICODE_GLYPHS: BoxGlyphs = {\n horizontal: '─',\n vertical: '│',\n topLeft: '┌',\n topRight: '┐',\n bottomLeft: '└',\n bottomRight: '┘',\n teeLeft: '├',\n teeRight: '┤',\n bullet: '•',\n check: '✔',\n cross: '✘',\n partial: '◐',\n arrow: '→',\n}\n\nconst ASCII_GLYPHS: BoxGlyphs = {\n horizontal: '-',\n vertical: '|',\n topLeft: '+',\n topRight: '+',\n bottomLeft: '+',\n bottomRight: '+',\n teeLeft: '+',\n teeRight: '+',\n bullet: '*',\n // One code point each, matching the Unicode set, so the status column is the\n // same width in both renderings and the table does not need two layouts.\n check: '+',\n cross: 'x',\n partial: '~',\n arrow: '>',\n}\n\nexport function glyphsFor(unicode: boolean): BoxGlyphs {\n return unicode ? UNICODE_GLYPHS : ASCII_GLYPHS\n}\n\n/** A single-rule frame. `lines` are already padded to `width` by the caller. */\nexport function frame(lines: readonly string[], width: number, glyphs: BoxGlyphs): string[] {\n const bar = glyphs.horizontal.repeat(width + 2)\n const out: string[] = [`${glyphs.topLeft}${bar}${glyphs.topRight}`]\n for (const line of lines) {\n if (line === RULE) {\n out.push(`${glyphs.teeLeft}${bar}${glyphs.teeRight}`)\n continue\n }\n out.push(`${glyphs.vertical} ${padEnd(line, width)} ${glyphs.vertical}`)\n }\n out.push(`${glyphs.bottomLeft}${bar}${glyphs.bottomRight}`)\n return out\n}\n\n/** Sentinel a caller pushes into `frame`'s lines to get a horizontal divider. */\nexport const RULE = '\u0000rule\u0000'\n","/**\n * format/pretty.ts — the terminal rendering.\n *\n * WHAT IT LEADS WITH, AND WHY IN THAT ORDER. The band, then the integer, then\n * the dimension table, then the cost, then the fixes. §3.6 says ARS is ordinal:\n * \"D — Partial\" is the finding and \"54\" is the detail, so the letter is bold and\n * the number is not, and there are no decimals anywhere. Under that, every check\n * prints its own basis word — a heuristic value never renders without its label\n * (Hard Rule 10) — and the measured/heuristic split prints under the total so\n * nobody has to go and look up how much of their score was inferred.\n *\n * WHAT IT REFUSES TO PRINT. No excerpt of the target page. Structure and\n * numbers: byte counts, offsets, statuses, check evidence values. The visceral\n * impact is in the numbers (§5.3), and a tool that dumps somebody's page into a\n * build log has a copyright problem the numbers do not.\n *\n * The renderer is pure text in, pure text out. It takes its terminal\n * capabilities as an argument and reads no environment, so the ASCII branch and\n * the no-colour branch are both one call away in a test rather than something\n * you have to arrange a TTY to see.\n */\n\nimport type { ArsCheck, ArsDimension, ArsResult } from '@rebilder/agent-readability'\nimport { ARS_NOTICE_LINES } from '../disclosure'\nimport type { BadgeSnippet, DiffPayload, Payload, Scaffold } from '../payload'\nimport { outcomeSummary, statusOf, type UrlReport } from '../report'\nimport {\n createPainter,\n glyphsFor,\n padEnd,\n padStart,\n truncate,\n visibleWidth,\n type Painter,\n type TermCapabilities,\n} from '../term'\nimport {\n absent,\n approxTokens,\n basisLabel,\n bytesText,\n checkMark,\n percent,\n shortHash,\n type FormatContext,\n} from './shared'\n\ninterface Pretty {\n caps: TermCapabilities\n paint: Painter\n}\n\nconst BASIS_COLUMN = 9 // 'heuristic'\nconst POINTS_COLUMN = 7 // '100/100'\n\n/**\n * `_ctx` is unused and stays in the signature anyway: all four renderers are\n * dispatched through one call in `./index`, and a uniform signature is what\n * keeps that dispatch a switch rather than four special cases. The terminal\n * rendering has no use for a generation timestamp — the identity footer already\n * carries the three hashes, which is what actually identifies a score.\n */\nexport function renderPretty(\n payload: Payload,\n caps: TermCapabilities,\n _ctx: FormatContext,\n): string {\n const pretty: Pretty = { caps, paint: createPainter(caps.color) }\n switch (payload.command) {\n case 'check':\n return joinBlocks(payload.reports.map((report) => checkBlock(report, pretty)))\n case 'diff':\n return joinBlocks([diffBlock(payload.diff, pretty)])\n case 'init':\n return joinBlocks([initBlock(payload.scaffold, pretty)])\n case 'badge':\n return joinBlocks([badgeBlock(payload.badge, pretty)])\n }\n}\n\n/**\n * Trailing whitespace is trimmed per line. The last column is padded so the\n * table aligns, and that padding then has nothing to its right — it is invisible\n * on screen and pure noise in a `--out` file, a git diff, or a README block that\n * a test compares byte for byte.\n */\nfunction joinBlocks(blocks: string[][]): string {\n return (\n blocks\n .map((lines) => lines.map((line) => line.replace(/[ \\t]+$/, '')).join('\\n'))\n .join('\\n\\n') + '\\n'\n )\n}\n\n/* ── check ────────────────────────────────────────────────────────────────── */\n\nfunction gradeStyle(grade: string): 'green' | 'cyan' | 'yellow' | 'red' {\n if (grade === 'A') return 'green'\n if (grade === 'B') return 'cyan'\n if (grade === 'C') return 'yellow'\n return 'red'\n}\n\nfunction checkBlock(report: UrlReport, pretty: Pretty): string[] {\n const { paint, caps } = pretty\n const glyphs = glyphsFor(caps.unicode)\n const lines: string[] = []\n const width = caps.width\n\n lines.push(paint(truncate(report.url, width, caps.unicode), 'bold'))\n lines.push(paint(glyphs.horizontal.repeat(Math.min(width, 64)), 'gray'))\n\n if (report.kind === 'rejected') {\n lines.push(`${paint('REJECTED', 'red', 'bold')} ${outcomeSummary(report)}`)\n lines.push(...noticeLines(pretty))\n return lines\n }\n\n const { result } = report\n const status = statusOf(report)\n\n if (status !== 'scored') {\n lines.push(paint(outcomeSummary(report), 'yellow'))\n lines.push('')\n lines.push(...policyLines(result, pretty))\n lines.push(...identityLines(result, pretty))\n lines.push(...noticeLines(pretty))\n return lines\n }\n\n const grade = result.grade ?? '?'\n const scoreText = `${result.score ?? 0}/100`\n lines.push(\n `${paint(grade, gradeStyle(grade), 'bold')} ${paint(result.bandLabel ?? '', 'bold')} ${paint(scoreText, 'gray')}`,\n )\n lines.push(\n paint(\n `${result.measuredWeight} of the 100 points are measured, ${result.heuristicWeight} heuristic`,\n 'gray',\n ),\n )\n lines.push(\n paint(\n `page kind: ${result.pageKind} (${result.pageKindConfidence} confidence, ${basisLabel(result.pageKindBasis)})`,\n 'gray',\n ),\n )\n lines.push('')\n\n for (const dimension of result.dimensions) {\n lines.push(...dimensionLines(dimension, pretty))\n }\n\n lines.push('')\n lines.push(...costLines(result, pretty))\n\n if (result.flags.length > 0) {\n lines.push('')\n lines.push(paint('Flags', 'bold'))\n for (const flag of result.flags) {\n const tone = flag.severity === 'warn' ? 'yellow' : 'gray'\n lines.push(\n ` ${glyphs.bullet} ${paint(flag.id, tone)} [${basisLabel(flag.basis)}] ${flag.message}`,\n )\n }\n }\n\n if (result.recommendations.length > 0) {\n lines.push('')\n lines.push(paint('Fixes, most points first', 'bold'))\n for (const recommendation of result.recommendations) {\n lines.push(\n ` ${padStart(`+${recommendation.pointsAvailable}`, 4)} ${paint(recommendation.title, 'bold')} ${paint(`(${recommendation.effort})`, 'gray')}`,\n )\n lines.push(\n paint(` ${truncate(recommendation.detail, caps.width - 8, caps.unicode)}`, 'gray'),\n )\n }\n }\n\n lines.push('')\n lines.push(...policyLines(result, pretty))\n lines.push(...identityLines(result, pretty))\n lines.push(...noticeLines(pretty))\n return lines\n}\n\nfunction dimensionLines(dimension: ArsDimension, pretty: Pretty): string[] {\n const { paint, caps } = pretty\n const lines: string[] = []\n const head = `${dimension.label}`\n const points = `${dimension.earned}/${dimension.weight}`\n const labelWidth = Math.max(10, caps.width - POINTS_COLUMN - BASIS_COLUMN - 4)\n lines.push(\n `${paint(padEnd(truncate(head, labelWidth, caps.unicode), labelWidth), 'bold')} ${padStart(points, POINTS_COLUMN)} ${padEnd(basisLabel(dimension.basis), BASIS_COLUMN)}`,\n )\n for (const check of dimension.checks) {\n lines.push(checkLine(check, pretty, labelWidth))\n }\n return lines\n}\n\nfunction checkLine(check: ArsCheck, pretty: Pretty, labelWidth: number): string {\n const { paint, caps } = pretty\n const mark = checkMark(check, caps.unicode)\n const tone = check.earned >= check.weight ? 'green' : check.earned > 0 ? 'yellow' : 'red'\n const label = ` ${mark} ${check.label}`\n const points = `${check.earned}/${check.weight}`\n return `${padEnd(truncate(label, labelWidth, caps.unicode), labelWidth)} ${paint(padStart(points, POINTS_COLUMN), tone)} ${paint(padEnd(basisLabel(check.basis), BASIS_COLUMN), 'gray')}`\n}\n\nfunction costLines(result: ArsResult, pretty: Pretty): string[] {\n const { paint, caps } = pretty\n const { cost } = result\n const lines = [paint('What an agent pays', 'bold')]\n const html = bytesText(cost.htmlBytes, cost.truncated, caps.unicode)\n const negotiated = bytesText(cost.negotiatedBytes, cost.truncated, caps.unicode)\n const byteColumn = Math.max(visibleWidth(html), visibleWidth(negotiated)) + 3\n lines.push(\n ` HTML ${padEnd(html, byteColumn)}${approxTokens(cost.approxHtmlTokens, caps.unicode)}`,\n )\n lines.push(\n ` Negotiated ${padEnd(negotiated, byteColumn)}${approxTokens(cost.approxNegotiatedTokens, caps.unicode)}`,\n )\n if (cost.reductionRatio !== null) {\n lines.push(paint(` Reduction ${cost.reductionRatio}%`, 'green'))\n }\n lines.push(\n ` First core fact at byte ${cost.firstCoreFactOffset === null ? absent(caps.unicode) : cost.firstCoreFactOffset.toLocaleString('en-US')}`,\n )\n const core = result.factProfile.core\n const found = result.facts.filter((fact) => core.includes(fact.kind)).length\n lines.push(\n paint(\n ` Core facts found ${found}/${core.length} (${percent(found, core.length)}) for a ${result.pageKind} page — heuristic`,\n 'gray',\n ),\n )\n return lines\n}\n\nfunction policyLines(result: ArsResult, pretty: Pretty): string[] {\n const { paint } = pretty\n const { policy } = result\n const parts = [\n `robots.txt ${policy.robotsTxtStatus}`,\n `assistant ${policy.audiences.assistant.decision}`,\n `training ${policy.audiences.training.decision} (neutral)`,\n `sitemap ${policy.sitemapDeclared ? 'declared' : 'not declared'}`,\n ]\n return [paint(`Policy: ${parts.join(' · ')}`, 'gray')]\n}\n\nfunction identityLines(result: ArsResult, pretty: Pretty): string[] {\n const { paint } = pretty\n return [\n paint(\n `ARS ${result.specVersion} · ruleset ${shortHash(result.rulesetHash)} · corpus ${shortHash(result.corpusHash)} · evidence ${shortHash(result.evidenceHash)} · vantage ${result.vantage}`,\n 'gray',\n ),\n ]\n}\n\nfunction noticeLines(pretty: Pretty): string[] {\n return ['', ...ARS_NOTICE_LINES.map((line) => pretty.paint(line, 'gray'))]\n}\n\n/* ── diff ─────────────────────────────────────────────────────────────────── */\n\nfunction diffBlock(diff: DiffPayload, pretty: Pretty): string[] {\n const { paint, caps } = pretty\n const glyphs = glyphsFor(caps.unicode)\n const lines: string[] = [\n paint(truncate(diff.url, caps.width, caps.unicode), 'bold'),\n paint(glyphs.horizontal.repeat(Math.min(caps.width, 64)), 'gray'),\n ]\n\n if (diff.report.kind === 'rejected') {\n lines.push(`${paint('REJECTED', 'red', 'bold')} ${outcomeSummary(diff.report)}`)\n lines.push(...noticeLines(pretty))\n return lines\n }\n\n lines.push(\n paint(\n 'The two requests differ in the Accept header and in nothing else — same User-Agent, same everything (§3.3).',\n 'gray',\n ),\n )\n lines.push('')\n\n const rows: [string, string, string][] = [\n ['', 'agent', 'browser'],\n [\n 'Accept',\n diff.agent?.accept ?? absent(caps.unicode),\n diff.browser?.accept ?? absent(caps.unicode),\n ],\n ['Status', text(diff.agent?.status, caps.unicode), text(diff.browser?.status, caps.unicode)],\n [\n 'Content-Type',\n diff.agent?.contentType ?? absent(caps.unicode),\n diff.browser?.contentType ?? absent(caps.unicode),\n ],\n [\n 'Bytes',\n bytesText(diff.agent?.bytes ?? null, diff.agent?.truncated ?? false, caps.unicode),\n bytesText(diff.browser?.bytes ?? null, diff.browser?.truncated ?? false, caps.unicode),\n ],\n [\n 'Tokens',\n approxTokens(diff.agent?.approxTokens ?? null, caps.unicode),\n approxTokens(diff.browser?.approxTokens ?? null, caps.unicode),\n ],\n [\n 'Redirects',\n text(diff.agent?.redirects, caps.unicode),\n text(diff.browser?.redirects, caps.unicode),\n ],\n [\n 'Error',\n diff.agent?.error ?? absent(caps.unicode),\n diff.browser?.error ?? absent(caps.unicode),\n ],\n ]\n\n const labelWidth = Math.max(...rows.map((row) => row[0].length)) + 2\n const columnWidth = Math.max(12, Math.floor((caps.width - labelWidth - 2) / 2))\n for (const [label, agentCell, browserCell] of rows) {\n lines.push(\n `${paint(padEnd(label, labelWidth), 'bold')}${padEnd(truncate(agentCell, columnWidth, caps.unicode), columnWidth + 2)}${truncate(browserCell, columnWidth, caps.unicode)}`,\n )\n }\n\n if (diff.parity !== null) {\n lines.push('')\n lines.push(\n `${paint('Substance parity', 'bold')} ${paint(`[${basisLabel(diff.parity.basis)}]`, 'gray')} ${diff.parity.earned}/${diff.parity.weight}`,\n )\n lines.push(\n paint(\n ' Compared on price, currency, availability and title only — never description or free text (§3.8).',\n 'gray',\n ),\n )\n for (const evidence of diff.parity.evidence) {\n lines.push(\n ` ${glyphs.bullet} ${evidence.label}: ${evidence.value} [${basisLabel(evidence.basis)}]`,\n )\n }\n }\n\n if (diff.result !== null) {\n lines.push('')\n lines.push(paint(`Score: ${outcomeSummary(diff.report)}`, 'gray'))\n lines.push(...identityLines(diff.result, pretty))\n }\n lines.push(...noticeLines(pretty))\n return lines\n}\n\nfunction text(value: number | null | undefined, unicode: boolean): string {\n return value === undefined || value === null ? absent(unicode) : String(value)\n}\n\n/* ── init and badge ───────────────────────────────────────────────────────── */\n\nfunction initBlock(scaffold: Scaffold, pretty: Pretty): string[] {\n const { paint } = pretty\n const lines = [\n paint(`Detected framework: ${scaffold.framework}`, 'bold'),\n paint(` ${scaffold.detection}`, 'gray'),\n '',\n paint(`Suggested path: ${scaffold.suggestedPath}`, 'gray'),\n '',\n scaffold.contents.trimEnd(),\n ]\n if (scaffold.notes.length > 0) {\n lines.push('')\n for (const note of scaffold.notes) lines.push(paint(` ${note}`, 'gray'))\n }\n return lines\n}\n\nfunction badgeBlock(badge: BadgeSnippet, pretty: Pretty): string[] {\n const { paint } = pretty\n const lines = [\n paint(`Badge for ${badge.domain}`, 'bold'),\n '',\n paint('Markdown', 'bold'),\n badge.markdown,\n '',\n paint('HTML', 'bold'),\n badge.html,\n '',\n ]\n for (const note of badge.notes) lines.push(paint(` ${note}`, 'gray'))\n return lines\n}\n","/**\n * format/index.ts — the one place `--format` is turned into a string.\n *\n * `--out` writes exactly what stdout would have shown, in the same format. There\n * is no separate \"file format\": a report you can read on screen and a report you\n * archive should not be two artifacts that can disagree, and the first time they\n * do, the one in the artifact store is the one nobody can reproduce.\n */\n\nimport { UsageError } from '../exit'\nimport type { Format } from '../args'\nimport type { Payload } from '../payload'\nimport type { TermCapabilities } from '../term'\nimport { renderJson } from './json'\nimport { renderJunit } from './junit'\nimport { renderMarkdown } from './markdown'\nimport { renderPretty } from './pretty'\nimport type { FormatContext } from './shared'\n\nexport type { FormatContext } from './shared'\n\nexport function render(\n payload: Payload,\n format: Format,\n caps: TermCapabilities,\n ctx: FormatContext,\n): string {\n if (format === 'junit' && (payload.command === 'init' || payload.command === 'badge')) {\n // Refused rather than emitted empty: `rebilder init --format junit` is\n // someone's mistake, and returning a valid file with nothing in it lets a\n // pipeline go green on a command that measured nothing.\n throw new UsageError(\n `--format junit reports observations about a page; \\`${payload.command}\\` makes none. Use pretty, json or markdown.`,\n )\n }\n\n switch (format) {\n case 'pretty':\n return renderPretty(payload, caps, ctx)\n case 'json':\n return renderJson(payload, ctx)\n case 'markdown':\n return renderMarkdown(payload, ctx)\n case 'junit':\n return renderJunit(payload, ctx)\n }\n}\n","/**\n * help.ts — `--help`, and the two things §3.7 requires it to carry.\n *\n * THE CONFLICT-OF-INTEREST DISCLOSURE IS NOT IN A FOOTER. It prints in the\n * general help, above the usage lines, and again in `rebilder check --help`,\n * which is the one people actually read. We wrote the standard and we sell the\n * middleware that satisfies two of its checks; putting that at the bottom in\n * grey would be a way of technically complying.\n *\n * THE EXIT-CODE TABLE IS IN THE HELP TEXT, not only in the README, because the\n * person wiring this into a pipeline is reading a terminal, and the 1-vs-3 split\n * only protects anything if they know it exists before the first flaky build.\n */\n\nimport { FORMATS, GRADES, type CommandName } from './args'\nimport { CONFLICT_OF_INTEREST_LINES, TELEMETRY_LINES } from './disclosure'\nimport { EXIT } from './exit'\n\nconst EXIT_TABLE: readonly string[] = [\n ` ${EXIT.OK} completed; threshold met, or no threshold set`,\n ` ${EXIT.THRESHOLD} completed; threshold NOT met`,\n ` ${EXIT.USAGE} usage error`,\n ` ${EXIT.PROBE} probe failed / target unreachable — infrastructure, not a score failure`,\n ` ${EXIT.POLICY} blocked by policy (SSRF guard, robots opt-out, probe budget spent)`,\n]\n\nconst GENERAL = `rebilder — the Agent Readability Score, from your machine.\n\nUSAGE\n rebilder check <url...> [--format ${FORMATS.join('|')}] [--fail-on ${GRADES.join('|')}]\n [--out <file>] [--allow-private] [--allow-http]\n [--concurrency <n>]\n rebilder diff <url> agent view vs browser view\n rebilder init gateway config scaffold for the detected framework\n rebilder badge <domain> embed snippet\n\n rebilder help <command> detail for one command\n rebilder --version\n\nEXIT CODES (a stable contract; never renumbered)\n${EXIT_TABLE.join('\\n')}\n\n The 1-vs-3 split is load-bearing. A flaky network exits 3, never 1: if an\n unreachable host failed your build as a score failure, the check would be\n deleted from CI within a week. --fail-on defaults to nothing, so plain\n \\`rebilder check <url>\\` reports and exits 0.\n\nZERO TELEMETRY\n${TELEMETRY_LINES.map((line) => ` ${line}`).join('\\n')}\n\nDISCLOSURE\n${CONFLICT_OF_INTEREST_LINES.map((line) => ` ${line}`).join('\\n')}\n\n Spec: https://rebilder.com/spec/ars Crawler policy: https://rebilder.com/bots\n`\n\nconst CHECK = `rebilder check <url...>\n\n Probes each URL twice — an agent request and a browser control that differ in\n the Accept header and in nothing else — plus /robots.txt, /llms.txt and\n /.well-known/ucp per origin. Nothing else is requested. robots.txt is fetched\n first and obeyed.\n\nOPTIONS\n --format ${FORMATS.join('|')} default pretty\n --fail-on ${GRADES.join('|')} default none. \"--fail-on C\" means C or\n better passes; a worse grade exits 1.\n --out <file> write the same rendering to a file\n --concurrency <n> URLs in flight; default 1, max 8. The\n probe's politeness limiter still allows\n at most 1 request per host and 2 globally.\n --allow-http permit plain http targets\n --allow-private permit private, loopback and link-local\n targets. Routes through a separate,\n import-time-gated entry point; it is opt-in\n per invocation, never a config default, and\n refuses to load in a hosted runtime.\n Implies --allow-http.\n\n A non-graded outcome — a deliberate robots opt-out, a 403 at the edge, an\n unreachable host — never produces exit 1. Only a real score compared against a\n threshold you set can do that.\n\nDISCLOSURE\n${CONFLICT_OF_INTEREST_LINES.map((line) => ` ${line}`).join('\\n')}\n`\n\nconst DIFF = `rebilder diff <url>\n\n Shows what the agent request received next to what the browser request\n received: status, content type, decoded bytes, an estimated token count, and\n the D2.4 substance-parity comparison verbatim.\n\n It shows structure and numbers, never an excerpt of the page. --fail-on is not\n supported: diff reports, it does not grade.\n\nOPTIONS\n --format ${FORMATS.join('|')} default pretty\n --out <file> write the same rendering to a file\n --allow-http, --allow-private as \\`check\\`\n`\n\nconst INIT = `rebilder init\n\n Writes a @rebilder/gateway config scaffold for the framework it detects in the\n working directory, and prints how it decided. Makes no network request and\n reads nothing outside the working directory.\n\nOPTIONS\n --framework next|node|edge|shopify override detection\n --out <file> write the scaffold to a file\n --format ${FORMATS.join('|')} junit is refused: init makes no observations\n\n The scaffold is a skeleton with TODOs, not a working config. The resolvers\n return YOUR source of truth — every substantive value comes from those fields,\n and the gateway never invents one.\n`\n\nconst BADGE = `rebilder badge <domain>\n\n Prints the markdown and HTML embed snippets for a domain's badge. Built\n locally: no network request, so we never learn which domain you asked about.\n\n A grade renders only for a verified opted-in domain; every other domain gets a\n neutral \"not rated\" badge at 200, not 404. The badge always names its subject,\n is served live, and degrades to \"unverified\" after 30 days without a\n successful re-scan.\n\nOPTIONS\n --format ${FORMATS.join('|')} junit is refused: badge makes no observations\n --out <file> write the snippet to a file\n`\n\nconst TOPICS: Record<CommandName, string> = {\n check: CHECK,\n diff: DIFF,\n init: INIT,\n badge: BADGE,\n}\n\nexport function helpText(topic: CommandName | null): string {\n if (topic === null) return GENERAL\n return TOPICS[topic]\n}\n","/**\n * cli.ts — parse, run, render, exit. The whole program in one readable function.\n *\n * `runCli` RETURNS an exit code rather than calling `process.exit`, and takes a\n * `CliRuntime` rather than reaching for `process`. That is what makes the exit\n * codes testable as a contract instead of as a hope: every test in\n * `tests/exit-codes.test.ts` is a call to this function with a fake probe and an\n * assertion on the integer it returned.\n *\n * THE ORDER OF OPERATIONS IS THE SAFETY PROPERTY. Parse first, and every parse\n * failure is exit 2 with nothing having been fetched. Then build the probe —\n * which for `--allow-private` is where the import-time gate in\n * `@rebilder/agent-readability/probe/local` fires, before any URL is touched.\n * Then run. Then render. Then write. A failure at any step short-circuits with\n * its own code, and no step can produce a code belonging to an earlier one.\n *\n * `--out` WRITES AFTER STDOUT, NOT INSTEAD OF IT. A CI job that redirects a\n * report to a file still wants the report in the log; making `--out` silent\n * would mean the only copy lives in an artifact nobody downloads.\n */\n\nimport { parseCommandLine, type Command } from './args'\nimport { runBadge } from './commands/badge'\nimport { runCheck } from './commands/check'\nimport { runDiff } from './commands/diff'\nimport { runInit } from './commands/init'\nimport { EXIT, UsageError, worstExit, type ExitCode } from './exit'\nimport { render, type FormatContext } from './format'\nimport { helpText } from './help'\nimport type { Payload } from './payload'\nimport { exitCodeFor } from './report'\nimport type { CliRuntime, ProbeRunner } from './runtime'\nimport { detectCapabilities } from './term'\n\n/** Kept in step with package.json by a test, so a stale constant cannot ship. */\nexport const CLI_VERSION = '0.1.1'\n\nexport async function runCli(argv: readonly string[], runtime: CliRuntime): Promise<ExitCode> {\n const caps = detectCapabilities({\n env: runtime.env,\n isTty: runtime.isTty,\n columns: runtime.columns,\n })\n\n try {\n const parsed = parseCommandLine(argv)\n\n if (parsed.kind === 'version') {\n runtime.write(`${CLI_VERSION}\\n`)\n return EXIT.OK\n }\n if (parsed.kind === 'help') {\n runtime.write(helpText(parsed.topic))\n return EXIT.OK\n }\n\n const { command } = parsed\n const { payload, exitCode } = await execute(command, runtime)\n\n const ctx: FormatContext = {\n unicode: caps.unicode,\n generatedAt: runtime.now().toISOString(),\n cliVersion: CLI_VERSION,\n }\n const rendered = render(payload, command.format, caps, ctx)\n\n runtime.write(rendered)\n if (command.out !== null) {\n await runtime.writeFile(command.out, rendered)\n }\n return exitCode\n } catch (error) {\n if (error instanceof UsageError) {\n runtime.writeError(`rebilder: ${error.message}\\n\\nRun \\`rebilder --help\\`.\\n`)\n return EXIT.USAGE\n }\n // Anything else is our bug or a genuinely broken environment (a failed\n // `--out` write, a probe module refusing to load). It is not the site's\n // fault, so it is never exit 1.\n runtime.writeError(`rebilder: ${error instanceof Error ? error.message : String(error)}\\n`)\n return EXIT.PROBE\n }\n}\n\ninterface Executed {\n payload: Payload\n exitCode: ExitCode\n}\n\nasync function execute(command: Command, runtime: CliRuntime): Promise<Executed> {\n switch (command.name) {\n case 'check': {\n const probe = await buildProbe(runtime, command.urls.length, command)\n const reports = await runCheck(command, probe)\n return {\n payload: { command: 'check', reports, failOn: command.failOn },\n exitCode: worstExit(reports.map((report) => exitCodeFor(report, command.failOn))),\n }\n }\n case 'diff': {\n const probe = await buildProbe(runtime, 1, command)\n const diff = await runDiff(command, probe)\n // `diff` never sets a threshold, so `exitCodeFor(..., null)` can only\n // return 0, 2, 3 or 4 — exit 1 is structurally unreachable here.\n return { payload: { command: 'diff', diff }, exitCode: exitCodeFor(diff.report, null) }\n }\n case 'init': {\n const scaffold = await runInit(command, runtime)\n return { payload: { command: 'init', scaffold }, exitCode: EXIT.OK }\n }\n case 'badge': {\n return { payload: { command: 'badge', badge: runBadge(command) }, exitCode: EXIT.OK }\n }\n }\n}\n\ninterface ProbeFlags {\n allowPrivate: boolean\n allowHttp: boolean\n}\n\nfunction buildProbe(\n runtime: CliRuntime,\n urlCount: number,\n flags: ProbeFlags,\n): Promise<ProbeRunner> {\n return runtime.probe({\n allowPrivate: flags.allowPrivate,\n allowHttp: flags.allowHttp,\n urlCount,\n })\n}\n","/**\n * runtime.ts — every impure thing the CLI can do, behind one injectable object.\n *\n * WHY THIS SHAPE. The test suite for a network tool is worthless if it can reach\n * the network, and \"we mocked `fetch`\" is not a guarantee — it is a hope about\n * every code path nobody thought to mock. Here the CLI holds no socket, no file\n * handle, no clock and no `process` reference at all: it holds a `CliRuntime`.\n * The tests pass one whose `probe` returns a fixture and whose `writeFile`\n * appends to an array, so a test that hits the network cannot be written by\n * accident — it has to construct the real runtime on purpose.\n *\n * THE PROBE FACTORY IS ASYNC FOR ONE REASON. `@rebilder/agent-readability/probe/local`\n * THROWS AT IMPORT TIME unless the process was started with `--allow-private`\n * (and refuses outright in a hosted runtime). That is exactly the behaviour we\n * want and it means the module cannot be imported statically — a top-level\n * `import` of it would make `rebilder check https://example.com` crash on\n * startup for everyone. So local mode is a dynamic import, reached only when the\n * flag is present, which is also what makes the permission per-invocation rather\n * than per-installation.\n */\n\nimport { readFile, writeFile } from 'node:fs/promises'\nimport { resolve as resolvePath } from 'node:path'\nimport {\n createLimiter,\n probeStrict,\n strictPolicy,\n type ProbeOutcome,\n type ProbePolicy,\n} from '@rebilder/agent-readability/probe'\n\n/** One probe of one URL. The only outbound request the CLI ever makes. */\nexport type ProbeRunner = (target: string) => Promise<ProbeOutcome>\n\nexport interface ProbeSetup {\n /** Routes through `./probe/local`. Per invocation, never a default. */\n allowPrivate: boolean\n allowHttp: boolean\n /** How many URLs this run will probe — sizes the run budget, nothing else. */\n urlCount: number\n}\n\nexport type ProbeFactory = (setup: ProbeSetup) => Promise<ProbeRunner>\n\nexport interface CliRuntime {\n env: Readonly<Record<string, string | undefined>>\n cwd: string\n isTty: boolean\n columns: number | undefined\n write(text: string): void\n writeError(text: string): void\n writeFile(path: string, contents: string): Promise<void>\n readFile(path: string): Promise<string | null>\n probe: ProbeFactory\n now(): Date\n}\n\n/**\n * The §3.3 request set is 5 requests for a cold URL (robots.txt, agent, browser,\n * /llms.txt, /.well-known/ucp) and the probe does not cache across calls, so a\n * multi-URL run needs a budget proportional to the URL count. `createLimiter`'s\n * default of 20 is a floor chosen for a single-shot caller; raising it is\n * supposed to be a decision someone made on purpose, and this is that decision,\n * written down: six per URL (five plus the robots retry) and four of slack.\n */\nexport function budgetFor(urlCount: number): number {\n return Math.max(20, urlCount * 6 + 4)\n}\n\nfunction policyFor(setup: ProbeSetup, base: ProbePolicy): ProbePolicy {\n return { ...base, allowHttp: setup.allowHttp || base.allowHttp }\n}\n\n/**\n * The real probe factory. `probeStrict` for everything public; a dynamic import\n * of `./probe/local` when — and only when — `--allow-private` was typed.\n *\n * If that import throws, the message from the package is the one the user should\n * see (it explains the argv gate and the hosted-runtime refusal in its own\n * words), so it is re-thrown unchanged rather than summarised.\n */\nexport const nodeProbeFactory: ProbeFactory = async (setup) => {\n const limiter = createLimiter({ maxProbesPerRun: budgetFor(setup.urlCount) })\n\n if (!setup.allowPrivate) {\n const policy = policyFor(setup, strictPolicy(limiter))\n return (target) => probeStrict(target, policy)\n }\n\n const local = await import('@rebilder/agent-readability/probe/local')\n const policy = policyFor(setup, local.localPolicy(limiter))\n return (target) => local.probeLocal(target, policy)\n}\n\nexport function createNodeRuntime(): CliRuntime {\n return {\n env: process.env,\n cwd: process.cwd(),\n isTty: process.stdout.isTTY === true,\n columns: process.stdout.columns,\n write: (text) => process.stdout.write(text),\n writeError: (text) => process.stderr.write(text),\n writeFile: async (path, contents) => {\n await writeFile(resolvePath(process.cwd(), path), contents, 'utf8')\n },\n readFile: async (path) => {\n try {\n return await readFile(resolvePath(process.cwd(), path), 'utf8')\n } catch {\n return null\n }\n },\n probe: nodeProbeFactory,\n now: () => new Date(),\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/exit.ts","../src/args.ts","../src/commands/badge.ts","../src/commands/check.ts","../src/commands/diff.ts","../src/commands/init.ts","../src/disclosure.ts","../src/report.ts","../src/format/json.ts","../src/format/shared.ts","../src/format/junit.ts","../src/next-steps.ts","../src/format/markdown.ts","../src/term.ts","../src/format/pretty.ts","../src/format/index.ts","../src/help.ts","../src/cli.ts","../src/runtime.ts"],"names":["name","report","score","text","policy","resolvePath"],"mappings":";;;;;;;;;AAuBO,IAAM,IAAA,GAAO;AAAA;AAAA,EAElB,EAAA,EAAI,CAAA;AAAA;AAAA,EAEJ,SAAA,EAAW,CAAA;AAAA;AAAA,EAEX,KAAA,EAAO,CAAA;AAAA;AAAA,EAEP,KAAA,EAAO,CAAA;AAAA;AAAA,EAEP,MAAA,EAAQ;AACV;AAeA,IAAM,QAAA,GAAgC,CAAC,IAAA,CAAK,KAAA,EAAO,IAAA,CAAK,MAAA,EAAQ,IAAA,CAAK,KAAA,EAAO,IAAA,CAAK,SAAA,EAAW,IAAA,CAAK,EAAE,CAAA;AAE5F,SAAS,UAAU,KAAA,EAAsC;AAC9D,EAAA,KAAA,MAAW,aAAa,QAAA,EAAU;AAChC,IAAA,IAAI,KAAA,CAAM,QAAA,CAAS,SAAS,CAAA,EAAG,OAAO,SAAA;AAAA,EACxC;AACA,EAAA,OAAO,IAAA,CAAK,EAAA;AACd;AAGO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA,EACpC,YAAY,OAAA,EAAiB;AAC3B,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AAAA,EACd;AACF;;;AC1CO,IAAM,OAAA,GAAU,CAAC,QAAA,EAAU,MAAA,EAAQ,YAAY,OAAO;AAGtD,IAAM,SAAS,CAAC,GAAA,EAAK,GAAA,EAAK,GAAA,EAAK,KAAK,GAAG;AAGvC,IAAM,QAAA,GAAW,CAAC,OAAA,EAAS,MAAA,EAAQ,QAAQ,OAAO;AAgDzD,IAAM,OAAA,G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I,IAAA;AAAK,GACtB;AACF","file":"index.js","sourcesContent":["/**\n * exit.ts — the exit-code contract.\n *\n * THESE NUMBERS ARE A PUBLISHED INTERFACE (design §5.6). They are documented in\n * the README, they are what a CI file branches on, and they are NEVER\n * renumbered. Adding a code is a MINOR; changing what an existing one means is a\n * broken promise to every pipeline that already pinned it.\n *\n * THE 1-vs-3 SPLIT IS THE WHOLE POINT. `1` means \"we scored this page and it did\n * not meet your threshold\" — a fact about the site, actionable by the team that\n * owns it. `3` means \"we never got a score\" — DNS, a timeout, a 502, a captive\n * portal in CI. If a flaky network exits 1, the first red build that nobody can\n * explain gets the check deleted, and a deleted check protects nothing. So a\n * probe that never produced a bundle can never produce `1`, and there is a test\n * that asserts exactly that.\n *\n * `4` is the third thing that is not a score failure: we *chose* not to fetch,\n * or were told not to. An SSRF rejection, a robots disallow aimed at\n * `rebilder-ars`, a deliberate assistant opt-out, an exhausted probe budget.\n * Distinguishing it from 3 matters because 4 is deterministic and 3 is not:\n * re-running fixes a 3 and never fixes a 4.\n */\n\nexport const EXIT = {\n /** Completed; threshold met, or no threshold set. */\n OK: 0,\n /** Completed; threshold NOT met. Only ever produced by a real score. */\n THRESHOLD: 1,\n /** Usage error — unknown flag, bad value, missing argument, unparseable URL. */\n USAGE: 2,\n /** Probe failed / target unreachable. INFRASTRUCTURE, not a score failure. */\n PROBE: 3,\n /** Blocked by policy — SSRF guard, robots opt-out, exhausted probe budget. */\n POLICY: 4,\n} as const\n\nexport type ExitCode = (typeof EXIT)[keyof typeof EXIT]\n\n/**\n * Which code wins when one invocation covers several URLs.\n *\n * Ordered most-severe first and documented in the README, because \"some passed\n * and some did not\" has to collapse to one integer and an undocumented collapse\n * rule is a bug report waiting to happen. The ordering says: a mistake in the\n * command beats everything (2); a deterministic refusal beats a transient\n * failure, because re-running will not change it (4 over 3); and anything that\n * stopped us from getting a score beats a score we did get and disliked (3 over\n * 1) — the same reasoning as the 1-vs-3 split itself, applied across a set.\n */\nconst SEVERITY: readonly ExitCode[] = [EXIT.USAGE, EXIT.POLICY, EXIT.PROBE, EXIT.THRESHOLD, EXIT.OK]\n\nexport function worstExit(codes: readonly ExitCode[]): ExitCode {\n for (const candidate of SEVERITY) {\n if (codes.includes(candidate)) return candidate\n }\n return EXIT.OK\n}\n\n/** Thrown for anything that is the operator's mistake rather than the site's. */\nexport class UsageError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'UsageError'\n }\n}\n","/**\n * args.ts — `node:util` `parseArgs`, and the validation `parseArgs` does not do.\n *\n * `parseArgs` (stable since Node 20.11, which is the root `engines` floor and\n * therefore ours) gives us tokenisation and `strict: true` gives us \"unknown\n * option\" for free. Everything below it is ours: an unknown *value* for a known\n * option is the error people actually make — `--format html`, `--fail-on Z`,\n * `--concurrency 0` — and `parseArgs` will hand all three through as strings.\n *\n * EVERY FAILURE HERE IS EXIT 2, and nothing here can produce any other code.\n * That is the point of parsing being a separate phase from running: once we have\n * a `Command`, every remaining outcome is a fact about a website, and the\n * operator's mistakes are already behind us.\n *\n * `--fail-on` DEFAULTS TO NOTHING (§5.6). `rebilder check <url>` reports and\n * exits 0. A tool that fails a build by default gets added with `|| true` on the\n * first day and is then permanently decorative.\n */\n\nimport { parseArgs } from 'node:util'\nimport { UsageError } from './exit'\n\nexport const FORMATS = ['pretty', 'json', 'markdown', 'junit'] as const\nexport type Format = (typeof FORMATS)[number]\n\nexport const GRADES = ['A', 'B', 'C', 'D', 'F'] as const\nexport type Grade = (typeof GRADES)[number]\n\nexport const COMMANDS = ['check', 'diff', 'init', 'badge'] as const\nexport type CommandName = (typeof COMMANDS)[number]\n\nexport interface CheckCommand {\n name: 'check'\n urls: string[]\n format: Format\n /** `null` = no threshold, the default. Exit 1 is unreachable when null. */\n failOn: Grade | null\n out: string | null\n allowPrivate: boolean\n allowHttp: boolean\n concurrency: number\n}\n\nexport interface DiffCommand {\n name: 'diff'\n url: string\n format: Format\n out: string | null\n allowPrivate: boolean\n allowHttp: boolean\n}\n\nexport interface InitCommand {\n name: 'init'\n /** Framework override; `null` means detect from the working directory. */\n framework: string | null\n out: string | null\n format: Format\n}\n\nexport interface BadgeCommand {\n name: 'badge'\n domain: string\n format: Format\n out: string | null\n}\n\nexport type Command = CheckCommand | DiffCommand | InitCommand | BadgeCommand\n\nexport type ParseResult =\n | { kind: 'command'; command: Command }\n | { kind: 'help'; topic: CommandName | null }\n | { kind: 'version' }\n\n/* ── option table ─────────────────────────────────────────────────────────── */\n\nconst OPTIONS = {\n format: { type: 'string' },\n 'fail-on': { type: 'string' },\n out: { type: 'string' },\n 'allow-private': { type: 'boolean' },\n 'allow-http': { type: 'boolean' },\n concurrency: { type: 'string' },\n framework: { type: 'string' },\n help: { type: 'boolean', short: 'h' },\n version: { type: 'boolean', short: 'v' },\n} as const\n\n/* ── validators ───────────────────────────────────────────────────────────── */\n\nfunction asFormat(value: string | undefined, fallback: Format): Format {\n if (value === undefined) return fallback\n const match = FORMATS.find((format) => format === value)\n if (match === undefined) {\n throw new UsageError(`--format must be one of ${FORMATS.join(', ')} (received \"${value}\")`)\n }\n return match\n}\n\nfunction asGrade(value: string | undefined): Grade | null {\n if (value === undefined) return null\n // Upper-cased before matching: `--fail-on b` is not a mistake worth an error.\n const upper = value.toUpperCase()\n const match = GRADES.find((grade) => grade === upper)\n if (match === undefined) {\n throw new UsageError(`--fail-on must be one of ${GRADES.join(', ')} (received \"${value}\")`)\n }\n return match\n}\n\nconst MAX_CONCURRENCY = 8\n\nfunction asConcurrency(value: string | undefined): number {\n if (value === undefined) return 1\n if (!/^[0-9]+$/.test(value)) {\n throw new UsageError(`--concurrency must be a positive integer (received \"${value}\")`)\n }\n const parsed = Number.parseInt(value, 10)\n if (parsed < 1) throw new UsageError('--concurrency must be at least 1')\n if (parsed > MAX_CONCURRENCY) {\n // Not arbitrary politeness theatre: the probe's limiter caps concurrency per\n // host at 1 and globally at 2 regardless, so a larger number here buys\n // nothing and only reads like a promise we do not keep.\n throw new UsageError(\n `--concurrency is capped at ${MAX_CONCURRENCY}; the probe's politeness limiter allows at most 2 in-flight requests globally in any case`,\n )\n }\n return parsed\n}\n\n/**\n * A domain, not a URL and not a path. Validated by syntax before anything else\n * touches it — `rebilder badge \"https://x.com/a?b\"` should be told what is wrong\n * rather than have a snippet built around a mangled string.\n *\n * Split-and-check rather than one compound regex. The obvious pattern nests a\n * bounded quantifier inside a repeated group, which is a backtracking shape a\n * linter is right to flag; a loop over labels is linear, and it is also easier\n * to read than the lookahead soup the single-regex version needs.\n */\nconst LABEL_CHARS = /^[a-z0-9-]+$/\n\nfunction isLabel(label: string): boolean {\n if (label.length < 1 || label.length > 63) return false\n if (label.startsWith('-') || label.endsWith('-')) return false\n return LABEL_CHARS.test(label)\n}\n\nfunction isDomain(value: string): boolean {\n if (value.length === 0 || value.length > 253) return false\n const labels = value.split('.')\n // At least two labels: `localhost` is not a domain, and a single-label host is\n // exactly the shape the probe's SSRF guard refuses anyway.\n if (labels.length < 2) return false\n return labels.every(isLabel)\n}\n\nexport function normalizeDomain(input: string): string {\n let value = input.trim().toLowerCase()\n if (value.includes('://')) {\n try {\n value = new URL(value).hostname\n } catch {\n throw new UsageError(`\"${input}\" is not a domain`)\n }\n }\n value = value.replace(/\\/.*$/, '').replace(/\\.$/, '')\n if (!isDomain(value)) {\n throw new UsageError(\n `\"${input}\" is not a domain. Pass a registrable hostname such as example.com — not a URL, not a path.`,\n )\n }\n return value\n}\n\n/* ── the parser ───────────────────────────────────────────────────────────── */\n\nexport function parseCommandLine(argv: readonly string[]): ParseResult {\n let parsed: ReturnType<typeof parseArgs<{ options: typeof OPTIONS; allowPositionals: true }>>\n try {\n parsed = parseArgs({\n args: [...argv],\n options: OPTIONS,\n allowPositionals: true,\n strict: true,\n })\n } catch (error) {\n // `parseArgs` throws on unknown options and missing values. Its messages are\n // good; re-wrapping them keeps every parse failure a single error type.\n throw new UsageError(error instanceof Error ? error.message : String(error))\n }\n\n const { values, positionals } = parsed\n const [first, ...rest] = positionals\n\n if (values.version === true) return { kind: 'version' }\n\n if (values.help === true || first === undefined || first === 'help') {\n const topicCandidate = first === 'help' ? rest[0] : first\n const topic = COMMANDS.find((name) => name === topicCandidate) ?? null\n if (first === 'help' && rest[0] !== undefined && topic === null) {\n throw new UsageError(`unknown command \"${rest[0]}\". Expected one of ${COMMANDS.join(', ')}.`)\n }\n return { kind: 'help', topic }\n }\n\n const name = COMMANDS.find((command) => command === first)\n if (name === undefined) {\n throw new UsageError(`unknown command \"${first}\". Expected one of ${COMMANDS.join(', ')}.`)\n }\n\n const out = values.out ?? null\n const allowPrivate = values['allow-private'] === true\n // `--allow-private` implies plain http: the whole point is a staging host on\n // an internal network, and those are rarely on 443 with a valid certificate.\n // It is still expressible on its own for a public host that only serves http.\n const allowHttp = values['allow-http'] === true || allowPrivate\n\n switch (name) {\n case 'check': {\n if (rest.length === 0) {\n throw new UsageError('check needs at least one URL. Usage: rebilder check <url...>')\n }\n return {\n kind: 'command',\n command: {\n name: 'check',\n urls: rest,\n format: asFormat(values.format, 'pretty'),\n failOn: asGrade(values['fail-on']),\n out,\n allowPrivate,\n allowHttp,\n concurrency: asConcurrency(values.concurrency),\n },\n }\n }\n case 'diff': {\n if (rest.length === 0) throw new UsageError('diff needs a URL. Usage: rebilder diff <url>')\n if (rest.length > 1) {\n throw new UsageError(\n 'diff takes exactly one URL. It is a two-representation comparison of a single page; use `check` for a set.',\n )\n }\n if (values['fail-on'] !== undefined) {\n // Refused rather than ignored: silently dropping a flag someone put in a\n // CI file is how a check that appears to gate stops gating.\n throw new UsageError(\n '--fail-on is not supported by `diff`. diff reports what the two representations contain; it does not grade. Use `rebilder check --fail-on`.',\n )\n }\n const url = rest[0]\n if (url === undefined) throw new UsageError('diff needs a URL. Usage: rebilder diff <url>')\n return {\n kind: 'command',\n command: {\n name: 'diff',\n url,\n format: asFormat(values.format, 'pretty'),\n out,\n allowPrivate,\n allowHttp,\n },\n }\n }\n case 'init': {\n if (rest.length > 0) {\n throw new UsageError(\n `init takes no positional arguments (received \"${rest[0]}\"). Use --framework to override detection.`,\n )\n }\n return {\n kind: 'command',\n command: {\n name: 'init',\n framework: values.framework ?? null,\n out,\n format: asFormat(values.format, 'pretty'),\n },\n }\n }\n case 'badge': {\n if (rest.length === 0) {\n throw new UsageError('badge needs a domain. Usage: rebilder badge <domain>')\n }\n if (rest.length > 1) throw new UsageError('badge takes exactly one domain.')\n const domain = rest[0]\n if (domain === undefined) throw new UsageError('badge needs a domain.')\n return {\n kind: 'command',\n command: {\n name: 'badge',\n domain: normalizeDomain(domain),\n format: asFormat(values.format, 'pretty'),\n out,\n },\n }\n }\n }\n}\n","/**\n * commands/badge.ts — the embed snippet, generated locally.\n *\n * IT MAKES NO NETWORK CALL, and could not usefully make one. The badge endpoint\n * renders from the stored `index_entries` row and is architecturally incapable\n * of triggering a probe (§5.6); asking it anything from here would only tell us\n * which domains people are curious about, which is a log we have promised not to\n * keep. So this command is string construction, and the honesty lives in the\n * notes it prints rather than in a lookup.\n *\n * WHAT THE NOTES HAVE TO SAY, because a merchant pasting this into a README is\n * about to be surprised by all four:\n * - The badge only renders a grade for a **verified opted-in** domain. Anything\n * else gets a neutral \"not rated\" badge, at 200 rather than 404 (a broken\n * image on a merchant's site is a support ticket).\n * - It is served live. The owner captures nothing and freezes nothing, and it\n * degrades to \"unverified\" after 30 days without a successful re-scan.\n * - It always names its subject — `example.com · A · 94 · Mar 2026`. A\n * domain-less badge is misappropriable, and that one decision is what makes\n * the whole thing safe.\n * - No score ever comes from the query string.\n *\n * `alt` text carries the domain and the word \"score\" for the same reason the\n * image does: an image whose alt text is \"Rebilder badge\" is one someone can\n * move to a different site and have it still read correctly.\n */\n\nimport type { BadgeCommand } from '../args'\nimport type { BadgeSnippet } from '../payload'\n\nexport const BADGE_ORIGIN = 'https://rebilder.com'\n\nexport function runBadge(command: BadgeCommand): BadgeSnippet {\n const { domain } = command\n const svgUrl = `${BADGE_ORIGIN}/badge/${domain}.svg`\n const pageUrl = `${BADGE_ORIGIN}/readable/${domain}`\n const alt = `Agent Readability Score for ${domain}`\n\n return {\n domain,\n svgUrl,\n pageUrl,\n markdown: `[![${alt}](${svgUrl})](${pageUrl})`,\n html: `<a href=\"${pageUrl}\"><img src=\"${svgUrl}\" alt=\"${alt}\" height=\"20\"></a>`,\n notes: [\n 'A grade renders only for a verified opted-in domain. Every other domain gets a neutral “not rated” badge, served at 200 so it never shows as a broken image.',\n 'Verify by publishing a DNS TXT record `rebilder-verify=<token>`, or by serving `X-Rebilder-Path` from your origin where we can observe it.',\n 'The badge is served live from our data: you capture nothing and freeze nothing. It degrades to “unverified” after 30 days without a successful re-scan.',\n 'It always names its subject (`example.com · A · 94 · Mar 2026`) and it shows the ruleset hash alongside the spec version — two scores from different rulesets must not render identically.',\n 'No score ever comes from the query string. Removal from the index is free, self-serve, permanent, and never purchasable.',\n 'This command makes no network request. It builds the snippet locally, so we never learn which domain you asked about.',\n ],\n }\n}\n","/**\n * commands/check.ts — probe, score, report. The command everything else exists\n * to support.\n *\n * IT DOES TWO THINGS AND NEITHER OF THEM IS INTERPRETATION. `probe()` produces\n * an `ArsEvidence` bundle; `score()` turns that bundle into an `ArsResult`. This\n * file adds a concurrency pool and a URL loop and nothing else — no adjustment,\n * no rounding, no \"close enough to a B\". A CLI that post-processes the score is a\n * second implementation of the standard with no conformance corpus behind it.\n *\n * ONE PROBE FAILURE NEVER STOPS THE RUN. `rebilder check a b c` with `b`\n * unreachable still reports `a` and `c`; the exit code collapses per\n * `worstExit`. The alternative — abort on the first failure — makes a multi-URL\n * check useless in exactly the situation you want it, which is one flaky origin\n * in a set of ten.\n *\n * A `ProbeBudgetExceededError` is the exception, and deliberately so: it comes\n * back as a `budget-exceeded` rejection per URL rather than a thrown error, so\n * the URLs already probed still report.\n */\n\nimport { score } from '@rebilder/agent-readability'\nimport type { CheckCommand } from '../args'\nimport type { UrlReport } from '../report'\nimport type { ProbeRunner } from '../runtime'\n\nexport async function runCheck(command: CheckCommand, probe: ProbeRunner): Promise<UrlReport[]> {\n return mapWithConcurrency(command.urls, command.concurrency, (url) => probeOne(url, probe))\n}\n\nexport async function probeOne(url: string, probe: ProbeRunner): Promise<UrlReport> {\n const outcome = await probe(url)\n if (!outcome.ok) {\n return { kind: 'rejected', url, rejection: outcome.rejection, detail: outcome.detail }\n }\n return { kind: 'probed', url, result: score(outcome.evidence) }\n}\n\n/**\n * A fixed-size worker pool that preserves input order in the output.\n *\n * Order matters more than it looks: `rebilder check a b c --format junit` writes\n * a file a human reads next to the command that produced it, and a report whose\n * suites come back in completion order changes shape between runs for no reason,\n * which makes every diff of two runs noise.\n */\nexport async function mapWithConcurrency<T, R>(\n items: readonly T[],\n concurrency: number,\n worker: (item: T, index: number) => Promise<R>,\n): Promise<R[]> {\n const results = new Array<R>(items.length)\n let next = 0\n\n const lanes = Array.from(\n { length: Math.min(Math.max(1, concurrency), items.length) },\n async () => {\n for (;;) {\n const index = next++\n if (index >= items.length) return\n const item = items[index]\n if (item === undefined) return\n results[index] = await worker(item, index)\n }\n },\n )\n\n await Promise.all(lanes)\n return results\n}\n","/**\n * commands/diff.ts — what an agent got, next to what a browser got.\n *\n * ONE PROBE, TWO VIEWS. The evidence bundle already contains both requests\n * (§3.3: an agent probe and a browser control that differ in `Accept` and in\n * nothing else), so `diff` re-uses the bundle a `check` would have produced\n * rather than issuing its own pair. That is not only cheaper — it is the only\n * way the two commands can agree, and a diff that disagreed with the score would\n * be worse than no diff.\n *\n * IT SHOWS SHAPE, NOT CONTENT. Status, content type, decoded bytes, an estimated\n * token count, redirect count, and the D2.4 substance-parity check verbatim. No\n * body excerpt on either side. The temptation is obvious — \"here is your HTML,\n * here is your markdown\" is a great demo — but dumping a third party's page into\n * a terminal, a CI log, or a `--out` file is a copyright problem the numbers do\n * not have, and §5.3 is explicit that structure and numbers are what we show.\n *\n * The parity check is rendered from `ArsResult`, not recomputed here. §3.8's\n * comparison is normative and narrow (price, currency, availability and title\n * only, post-normalisation, never free text); reimplementing it in a CLI would\n * produce a second opinion with no fixture behind it.\n */\n\nimport { score } from '@rebilder/agent-readability'\nimport type {\n ArsCheck,\n ArsEvidence,\n ArsHttpCapture,\n ArsProbeRecord,\n ArsResult,\n} from '@rebilder/agent-readability'\nimport type { DiffCommand } from '../args'\nimport type { DiffPayload, DiffSide } from '../payload'\nimport type { UrlReport } from '../report'\nimport type { ProbeRunner } from '../runtime'\n\nconst PARITY_CHECK_ID = 'machine-representation.substance-parity'\n\nexport async function runDiff(command: DiffCommand, probe: ProbeRunner): Promise<DiffPayload> {\n const outcome = await probe(command.url)\n\n if (!outcome.ok) {\n const report: UrlReport = {\n kind: 'rejected',\n url: command.url,\n rejection: outcome.rejection,\n detail: outcome.detail,\n }\n return { url: command.url, agent: null, browser: null, parity: null, result: null, report }\n }\n\n const result = score(outcome.evidence)\n const report: UrlReport = { kind: 'probed', url: command.url, result }\n\n return {\n url: command.url,\n agent: sideOf(outcome.evidence, 'agent'),\n browser: sideOf(outcome.evidence, 'browser'),\n parity: parityCheck(result),\n result,\n report,\n }\n}\n\nfunction parityCheck(result: ArsResult): ArsCheck | null {\n for (const dimension of result.dimensions) {\n for (const check of dimension.checks) {\n if (check.id === PARITY_CHECK_ID) return check\n }\n }\n return null\n}\n\nfunction sideOf(evidence: ArsEvidence, role: 'agent' | 'browser'): DiffSide {\n const record: ArsProbeRecord = evidence.probes[role]\n const accept = record.requestHeaders['accept'] ?? '(none)'\n\n if (!record.result.ok) {\n return {\n role,\n accept,\n status: null,\n contentType: null,\n bytes: null,\n approxTokens: null,\n truncated: false,\n redirects: 0,\n error: `${record.result.error}${record.result.detail === undefined ? '' : `: ${record.result.detail}`}`,\n }\n }\n\n const capture: ArsHttpCapture = record.result.capture\n return {\n role,\n accept,\n status: capture.status,\n contentType: capture.headers['content-type']?.[0] ?? null,\n bytes: capture.bytes,\n approxTokens: approxTokensOf(capture),\n truncated: capture.truncated,\n redirects: capture.redirects.length,\n error: null,\n }\n}\n\n/**\n * chars/4, the same heuristic `ArsCostReport` uses, computed from the decoded\n * body when it is in hand and from the byte count otherwise. It is labelled\n * `est.` everywhere it renders — \"chars/4 isn't a token count\" is a fair\n * objection and the answer is the label, not an argument (§3.8).\n */\nfunction approxTokensOf(capture: ArsHttpCapture): number {\n const characters = capture.body?.length ?? capture.bytes\n return Math.round(characters / 4)\n}\n","/**\n * commands/init.ts — a gateway config scaffold for the framework it found.\n *\n * ZERO NETWORK, and that is not incidental. `init` reads `package.json` and a\n * handful of well-known filenames in the working directory and writes a file.\n * Nothing about the user's dependency list, framework choice, or repository\n * leaves the machine — a scaffolding command that phoned home with \"which\n * framework did they pick\" would be exactly the telemetry the README says we do\n * not collect, wearing a helpful hat.\n *\n * THE DETECTION IS PRINTED. Every scaffold says how it decided (`\"next found in\n * package.json dependencies\"`), because a wrong guess with a visible reason is a\n * thirty-second fix and a wrong guess with no reason is a bug report. `--framework`\n * overrides it.\n *\n * THE SCAFFOLD IS A SKELETON WITH A `TODO`, NOT A WORKING CONFIG, and it says so\n * in a comment inside the generated file. `GatewaySources` resolvers read the\n * merchant's source of truth; we cannot know what that is, and a scaffold that\n * looked complete would be a scaffold someone shipped. This is the same rule the\n * variant architecture runs on: substantive values come from source-of-truth\n * fields, never from something we generated (CLAUDE.md Hard Rule 2).\n */\n\nimport { UsageError } from '../exit'\nimport type { InitCommand } from '../args'\nimport type { Scaffold } from '../payload'\nimport type { CliRuntime } from '../runtime'\n\nexport const FRAMEWORKS = ['next', 'node', 'edge', 'shopify'] as const\nexport type Framework = (typeof FRAMEWORKS)[number]\n\ninterface Detection {\n framework: Framework\n reason: string\n}\n\nconst MARKER_FILES: readonly { file: string; framework: Framework; reason: string }[] = [\n {\n file: 'shopify.app.toml',\n framework: 'shopify',\n reason: 'shopify.app.toml in the working directory',\n },\n { file: 'next.config.ts', framework: 'next', reason: 'next.config.ts in the working directory' },\n {\n file: 'next.config.mjs',\n framework: 'next',\n reason: 'next.config.mjs in the working directory',\n },\n { file: 'next.config.js', framework: 'next', reason: 'next.config.js in the working directory' },\n { file: 'wrangler.toml', framework: 'edge', reason: 'wrangler.toml in the working directory' },\n { file: 'wrangler.jsonc', framework: 'edge', reason: 'wrangler.jsonc in the working directory' },\n]\n\nconst DEPENDENCY_MARKERS: readonly { dependency: string; framework: Framework }[] = [\n { dependency: '@shopify/shopify-app-remix', framework: 'shopify' },\n { dependency: '@shopify/shopify-api', framework: 'shopify' },\n { dependency: 'next', framework: 'next' },\n { dependency: '@cloudflare/workers-types', framework: 'edge' },\n { dependency: 'wrangler', framework: 'edge' },\n { dependency: 'hono', framework: 'edge' },\n { dependency: 'express', framework: 'node' },\n { dependency: 'fastify', framework: 'node' },\n]\n\nexport async function detectFramework(runtime: CliRuntime): Promise<Detection> {\n for (const marker of MARKER_FILES) {\n if ((await runtime.readFile(marker.file)) !== null) {\n return { framework: marker.framework, reason: `detected from ${marker.reason}` }\n }\n }\n\n const manifest = await runtime.readFile('package.json')\n if (manifest !== null) {\n let dependencies: Record<string, unknown> = {}\n try {\n const parsed: unknown = JSON.parse(manifest)\n if (typeof parsed === 'object' && parsed !== null) {\n const record = parsed as Record<string, unknown>\n dependencies = {\n ...asRecord(record['dependencies']),\n ...asRecord(record['devDependencies']),\n }\n }\n } catch {\n // A package.json we cannot parse is not an error worth stopping for — it\n // is one signal of several, and the fallback below is honest about it.\n dependencies = {}\n }\n for (const marker of DEPENDENCY_MARKERS) {\n if (marker.dependency in dependencies) {\n return {\n framework: marker.framework,\n reason: `detected from \"${marker.dependency}\" in package.json`,\n }\n }\n }\n }\n\n return {\n framework: 'node',\n reason:\n 'no framework marker found — defaulting to the Node adapter. Pass --framework next|node|edge|shopify to choose.',\n }\n}\n\nfunction asRecord(value: unknown): Record<string, unknown> {\n return typeof value === 'object' && value !== null ? (value as Record<string, unknown>) : {}\n}\n\nexport async function runInit(command: InitCommand, runtime: CliRuntime): Promise<Scaffold> {\n let framework: Framework\n let detection: string\n\n if (command.framework !== null) {\n const match = FRAMEWORKS.find((name) => name === command.framework)\n if (match === undefined) {\n throw new UsageError(\n `--framework must be one of ${FRAMEWORKS.join(', ')} (received \"${command.framework}\")`,\n )\n }\n framework = match\n detection = 'chosen with --framework'\n } else {\n const detected = await detectFramework(runtime)\n framework = detected.framework\n detection = detected.reason\n }\n\n return { ...SCAFFOLDS[framework], framework, detection }\n}\n\nconst SHARED_NOTES: readonly string[] = [\n 'The resolvers return your source of truth. Every substantive value — price, stock, hours, policy text — comes from these fields; the gateway never invents one.',\n 'The gateway has no concept of a plan, licence, tier or quota, and never will. Free-tier cost control happens at ingest, never at the edge.',\n 'Run `rebilder check <url>` before and after to see what changed. Content negotiation is D2.1 (10 points) and unlocks D2.3 and D2.4.',\n]\n\nconst CONFIG_BODY = `import type { GatewayConfig } from '@rebilder/gateway'\n\n/**\n * Wiring to YOUR source of truth. Each resolver takes a URL and returns the\n * fields for that page, or null to fall through to your normal HTML.\n *\n * Resolvers run on the request hot path: p95 < 50ms of compute, and no network\n * call except a cache. Anything slower belongs in a build step.\n */\nexport const gatewayConfig: GatewayConfig = {\n storeId: 'TODO-your-store-id',\n sources: {\n // TODO: return your product fields, or null when the URL is not a PDP.\n product: async (url) => {\n void url\n return null\n },\n // TODO: policies, catalog, document, collection — add the ones you have.\n },\n // Optional: emit @rebilder/events RebilderEventV0 into your observation layer.\n // onEvent: (event) => { void event },\n}\n`\n\nconst SCAFFOLDS: Record<Framework, Omit<Scaffold, 'framework' | 'detection'>> = {\n next: {\n suggestedPath: 'lib/gateway-config.ts',\n language: 'ts',\n notes: [\n 'Then add the proxy: `const gateway = createGatewayProxy(gatewayConfig)` in proxy.ts (Next 16) or middleware.ts (Next 15 and earlier), returning `(await gateway(req)) ?? NextResponse.next()`.',\n ...SHARED_NOTES,\n ],\n contents: `${CONFIG_BODY}\n/* ── proxy.ts (Next 16) or middleware.ts (Next ≤15) ───────────────────────── */\n//\n// import { NextResponse } from 'next/server'\n// import { createGatewayProxy } from '@rebilder/gateway/next'\n// import { gatewayConfig } from './lib/gateway-config'\n//\n// const gateway = createGatewayProxy(gatewayConfig)\n//\n// export default async function proxy(req: Request) {\n// return (await gateway(req)) ?? NextResponse.next()\n// }\n`,\n },\n node: {\n suggestedPath: 'gateway-config.ts',\n language: 'ts',\n notes: [\n 'Then mount it before your routes: `app.use(createGatewayMiddleware(gatewayConfig))`.',\n ...SHARED_NOTES,\n ],\n contents: `${CONFIG_BODY}\n/* ── Express ──────────────────────────────────────────────────────────────── */\n//\n// import express from 'express'\n// import { createGatewayMiddleware } from '@rebilder/gateway/node'\n// import { gatewayConfig } from './gateway-config'\n//\n// const app = express()\n// app.use(createGatewayMiddleware(gatewayConfig)) // before your routes\n`,\n },\n edge: {\n suggestedPath: 'gateway-config.ts',\n language: 'ts',\n notes: [\n 'Then export the fetch handler: `export default { fetch: createGatewayFetchHandler(gatewayConfig) }`.',\n 'On a route-mounted Worker, non-markdown requests pass through to your origin unchanged, so browsers and crawlers keep receiving the canonical HTML.',\n ...SHARED_NOTES,\n ],\n contents: `${CONFIG_BODY}\n/* ── worker.ts (Cloudflare Workers, Vercel Edge, Deno Deploy) ─────────────── */\n//\n// import { createGatewayFetchHandler } from '@rebilder/gateway/edge'\n// import { gatewayConfig } from './gateway-config'\n//\n// export default { fetch: createGatewayFetchHandler(gatewayConfig) }\n`,\n },\n shopify: {\n suggestedPath: 'app/gateway-config.ts',\n language: 'ts',\n notes: [\n 'Then mount the app-proxy handler and give it your app’s shared secret; requests are signature-verified before anything is rendered.',\n ...SHARED_NOTES,\n ],\n contents: `${CONFIG_BODY}\n/* ── Shopify app proxy ────────────────────────────────────────────────────── */\n//\n// import { createShopifyAppProxyHandler } from '@rebilder/gateway/shopify'\n// import { gatewayConfig } from './gateway-config'\n//\n// export const loader = createShopifyAppProxyHandler(gatewayConfig, {\n// sharedSecret: process.env.SHOPIFY_API_SECRET ?? '',\n// })\n`,\n },\n}\n","/**\n * disclosure.ts — the texts that are not ours to edit for tone.\n *\n * THE NOTICE prints on every result, in every format, including `--format json`\n * and `--format junit`. It is two lines because a one-line version gets read as\n * a tagline; ARS measures the shape of a response and nothing else, and a number\n * that travels without that sentence is a number people will read as a quality\n * score for the business. (Design §3.6.)\n *\n * The conflict-of-interest paragraph that used to print in `--help` was removed\n * everywhere (owner decision, Aug 2026), along with spec §0.1 and the \"MUST be\n * printed\" clause that required it here. The measurement notice above is\n * unaffected: spec §0 still binds every surface that shows a grade.\n *\n * They are exported as constants and asserted by tests. They are not template\n * strings and they take no parameters: a disclosure whose text varies by context\n * is a disclosure someone will tune.\n */\n\n/** Design §3.6. Prints on every result, every format. */\nexport const ARS_NOTICE_LINES: readonly string[] = [\n 'ARS measures format and retrievability. It does not measure whether the',\n 'facts are true, or whether any assistant cites this page.',\n]\n\nexport const ARS_NOTICE = ARS_NOTICE_LINES.join(' ')\n\n/**\n * The no-telemetry contract, printed in `--help` next to the disclosure.\n *\n * It is here rather than only in the README because the person who needs to read\n * it is the one deciding whether to run `--allow-private` against an internal\n * hostname inside their own CI, and they are looking at a terminal.\n */\nexport const TELEMETRY_LINES: readonly string[] = [\n 'This CLI ships zero telemetry. It never uploads a scan, a URL, a hostname,',\n 'or a result. The only requests it makes are to the target you name.',\n]\n","/**\n * report.ts — one URL's outcome, and the mapping from that outcome to an exit\n * code.\n *\n * THIS FILE IS WHERE THE 1-vs-3 SPLIT IS ACTUALLY ENFORCED, so it is small on\n * purpose and there is a test asserting the property directly: for every\n * `ArsUnscoredReason`, every `ProbeRejection`, and the opt-out outcome, the code\n * is never `EXIT.THRESHOLD`. Only a real integer score, compared against a\n * threshold the operator asked for, produces 1.\n *\n * THE THREE-WAY SPLIT OF \"WE DID NOT GET A SCORE\" mirrors `ArsOutcome`:\n * - `opt-out` — the site said no, deliberately and in well-formed robots. That\n * is a choice, not a failure, and §3.6 gives it no letter grade. Exit 4.\n * - `unscored` — a missing observation. Mostly transient (timeout, 5xx, edge\n * challenge) so exit 3, EXCEPT `robots-disallow-scanner`, which is a\n * deterministic refusal aimed at us and re-running will never change it.\n * - a probe `rejection` — we never sent the request: unparseable URL (2, the\n * operator's typo), guard refusal (4), exhausted budget (4).\n */\n\nimport type { ArsResult } from '@rebilder/agent-readability'\nimport type { ProbeRejection } from '@rebilder/agent-readability/probe'\nimport { EXIT, type ExitCode } from './exit'\nimport { GRADES, type Grade } from './args'\n\n/**\n * `'probed'` means the probe returned an evidence bundle and `score()` judged it.\n * It does NOT mean the judgment was a grade: an unscored or opted-out result is a\n * `'probed'` report carrying an `ArsResult` whose `outcome.kind` says so. The\n * discriminant answers \"did we get evidence\", and `outcome.kind` answers \"what\n * did the evidence say\" — collapsing the two is how a 403 ends up rendered as an\n * F.\n */\nexport type UrlReport =\n | { kind: 'probed'; url: string; result: ArsResult }\n | { kind: 'rejected'; url: string; rejection: ProbeRejection; detail: string }\n\n/** A .. F, best first. `indexOf` on this is the whole comparison. */\nconst ORDER: readonly Grade[] = GRADES\n\n/**\n * `--fail-on C` means \"C or better passes\". A grade strictly worse than the\n * threshold fails; the threshold grade itself passes. Stated in the README with\n * the same sentence, because the off-by-one reading (\"fail on C\" = \"C fails\") is\n * the one people assume half the time.\n */\nexport function meetsThreshold(grade: Grade, failOn: Grade): boolean {\n return ORDER.indexOf(grade) <= ORDER.indexOf(failOn)\n}\n\nexport function exitCodeFor(report: UrlReport, failOn: Grade | null): ExitCode {\n if (report.kind === 'rejected') {\n switch (report.rejection) {\n case 'invalid-url':\n return EXIT.USAGE\n case 'policy-rejected':\n case 'budget-exceeded':\n return EXIT.POLICY\n }\n }\n\n const { outcome } = report.result\n switch (outcome.kind) {\n case 'opt-out':\n return EXIT.POLICY\n case 'unscored':\n return outcome.reason === 'robots-disallow-scanner' ? EXIT.POLICY : EXIT.PROBE\n case 'scored':\n if (failOn === null) return EXIT.OK\n return meetsThreshold(outcome.grade, failOn) ? EXIT.OK : EXIT.THRESHOLD\n }\n}\n\n/* ── human-readable one-liners, shared by every formatter ─────────────────── */\n\nconst UNSCORED_TEXT: Record<string, string> = {\n 'blocked-at-edge': 'blocked at the edge (403 or challenge) — the block is itself the finding',\n unreachable: 'unreachable',\n 'non-2xx': 'the agent path did not return 2xx',\n 'too-many-redirects': 'too many redirects',\n 'robots-disallow-scanner': 'robots.txt disallows rebilder-ars — we obeyed it and did not score',\n 'robots-unavailable':\n 'robots.txt returned a persistent error; a policy we cannot read is not a policy we may assume',\n 'truncated-evidence': 'the response exceeded the 2 MiB body cap and the evidence is incomplete',\n 'evidence-incomplete': 'the evidence bundle is incomplete',\n}\n\nconst REJECTION_TEXT: Record<ProbeRejection, string> = {\n 'invalid-url': 'not a URL',\n 'policy-rejected': 'refused by the URL guard',\n 'budget-exceeded': 'the probe budget for this run is spent',\n}\n\n/** One line describing the outcome. No grade, no score — those render separately. */\nexport function outcomeSummary(report: UrlReport): string {\n if (report.kind === 'rejected') {\n return `${REJECTION_TEXT[report.rejection]}: ${report.detail}`\n }\n const { outcome } = report.result\n switch (outcome.kind) {\n case 'scored':\n return `${outcome.score}/100 ${outcome.grade}`\n case 'opt-out':\n return `OPT-OUT — a deliberate, well-formed robots disallow for the ${outcome.audience} audience. Not a failure and not a grade.`\n case 'unscored':\n return `UNSCORED — ${UNSCORED_TEXT[outcome.reason] ?? outcome.reason}${\n outcome.detail === undefined ? '' : ` (${outcome.detail})`\n }`\n }\n}\n\n/** `'scored' | 'opt-out' | 'unscored' | 'rejected'` — the coarse status. */\nexport function statusOf(report: UrlReport): 'scored' | 'opt-out' | 'unscored' | 'rejected' {\n return report.kind === 'rejected' ? 'rejected' : report.result.outcome.kind\n}\n","/**\n * format/json.ts — the machine format.\n *\n * IT EMITS THE `ArsResult` VERBATIM. Not a summary, not a flattened view: the\n * whole published contract from `@rebilder/agent-readability`, so that anything\n * downstream reads the same shape as the scanner, the MCP server and a second\n * implementation of the spec. A CLI-specific projection would be a second\n * schema to version, and the first time it drifted from `ArsResult` we would\n * have two answers to \"what did ARS say\".\n *\n * WHAT IS DELIBERATELY ABSENT: the target page's body. `ArsResult` never carries\n * it (`ArsHttpCapture.body` lives in the evidence bundle, which is not part of a\n * result, and `src/types.ts` says it must never reach a published bundle), and\n * this file does not go and get it. Piping `--format json` into a build artifact\n * must not be a way to archive somebody else's copyrighted page.\n *\n * `notice` is a FIELD, not a comment, because JSON has no comments and §3.6\n * requires the sentence on every surface — including the one a dashboard renders\n * from. A consumer that shows an ARS number has the disclaimer in the same\n * object and no excuse.\n */\n\nimport { ARS_NOTICE } from '../disclosure'\nimport type { Payload } from '../payload'\nimport { exitCodeFor, outcomeSummary, statusOf } from '../report'\nimport type { FormatContext } from './shared'\n\nexport function renderJson(payload: Payload, ctx: FormatContext): string {\n return JSON.stringify(jsonValue(payload, ctx), null, 2) + '\\n'\n}\n\nfunction jsonValue(payload: Payload, ctx: FormatContext): unknown {\n const envelope = {\n tool: 'rebilder',\n toolVersion: ctx.cliVersion,\n generatedAt: ctx.generatedAt,\n notice: ARS_NOTICE,\n }\n\n switch (payload.command) {\n case 'check':\n return {\n ...envelope,\n command: 'check',\n failOn: payload.failOn,\n results: payload.reports.map((report) => ({\n url: report.url,\n status: statusOf(report),\n summary: outcomeSummary(report),\n exitCode: exitCodeFor(report, payload.failOn),\n ...(report.kind === 'rejected'\n ? { rejection: report.rejection, detail: report.detail, result: null }\n : { rejection: null, detail: null, result: report.result }),\n })),\n }\n case 'diff':\n return {\n ...envelope,\n command: 'diff',\n url: payload.diff.url,\n status: statusOf(payload.diff.report),\n agent: payload.diff.agent,\n browser: payload.diff.browser,\n substanceParity: payload.diff.parity,\n result: payload.diff.result,\n }\n case 'init':\n return { ...envelope, command: 'init', scaffold: payload.scaffold }\n case 'badge':\n return { ...envelope, command: 'badge', badge: payload.badge }\n }\n}\n","/**\n * format/shared.ts — the small vocabulary every formatter needs, in one place so\n * the four of them cannot drift.\n *\n * THE RULE THIS FILE EXISTS TO MAKE MECHANICAL (CLAUDE.md Hard Rule 10): a\n * heuristic value never renders without its label. Not \"usually\", not \"in the\n * detailed view\" — never. So `basisLabel()` is the only way any formatter gets\n * the word, `approxTokens()` is the only way any formatter prints a token count\n * and it always carries `≈` and `est.`, and `bytesText()` is the only way any\n * formatter prints a byte figure and it renders `≥ N` whenever the capture was\n * truncated. A formatter that wants to print one of these without its label has\n * to write the code to do it, which is a diff a reviewer can see.\n */\n\nimport type { ArsBasis, ArsCheck } from '@rebilder/agent-readability'\n\nexport interface FormatContext {\n unicode: boolean\n generatedAt: string\n /** The CLI's own version, printed so a report can be traced to a build. */\n cliVersion: string\n}\n\n/**\n * The \"there is no value here\" placeholder. It respects the Unicode capability\n * for the same reason the box glyphs do: an em dash in a `LANG=C` container is\n * mojibake, and mojibake in a build log reads as a crash.\n */\nexport function absent(unicode: boolean): string {\n return unicode ? '\\u2014' : '-'\n}\n\n/** Never abbreviated to \"H\"/\"M\". The whole point is that it is readable. */\nexport function basisLabel(basis: ArsBasis): string {\n return basis === 'heuristic' ? 'heuristic' : 'measured'\n}\n\n/**\n * Decoded UTF-8 bytes. `truncated` turns the number into a lower bound, because\n * silently reporting a truncated body as a total makes the heaviest pages look\n * cheapest on D3.2 — the one number the product is built on (§3.3).\n */\nexport function bytesText(bytes: number | null, truncated: boolean, unicode: boolean): string {\n if (bytes === null) return absent(unicode)\n const formatted = `${bytes.toLocaleString('en-US')} B`\n if (!truncated) return formatted\n return `${unicode ? '≥' : '>='} ${formatted} (truncated at the 2 MiB cap)`\n}\n\n/**\n * chars/4. A heuristic, and labelled as one every single time it appears —\n * \"chars/4 isn't a token count\" is a fair objection and the answer is to stop\n * pretending otherwise, not to argue (§3.8).\n */\nexport function approxTokens(tokens: number | null, unicode: boolean): string {\n if (tokens === null) return absent(unicode)\n return `${unicode ? '≈' : '~'}${tokens.toLocaleString('en-US')} tokens (est.)`\n}\n\nexport function percent(numerator: number, denominator: number): string {\n if (denominator === 0) return '0%'\n return `${Math.round((numerator * 100) / denominator)}%`\n}\n\n/** ✔ full marks · ◐ partial · ✘ nothing earned. */\nexport function checkMark(check: ArsCheck, unicode: boolean): string {\n if (check.earned >= check.weight) return unicode ? '✔' : '+'\n if (check.earned > 0) return unicode ? '◐' : '~'\n return unicode ? '✘' : 'x'\n}\n\nexport function shortHash(hash: string): string {\n return hash.slice(0, 12)\n}\n\n/** XML text-node / attribute escaping. Used by the JUnit writer. */\nexport function escapeXml(text: string): string {\n return (\n text\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&apos;')\n // Control characters are illegal in XML 1.0 even escaped; a page title with\n // a stray 0x08 in it would otherwise produce a file no CI parser will read.\n .replace(/[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F]/g, '')\n )\n}\n\n/** Markdown table-cell escaping: a `|` in a URL otherwise splits the row. */\nexport function escapeCell(text: string): string {\n return text.replace(/\\|/g, '\\\\|').replace(/\\r?\\n/g, ' ')\n}\n","/**\n * format/junit.ts — one XML file every CI system already knows how to read.\n *\n * THE MAPPING, AND WHY IT IS NOT THE OBVIOUS ONE.\n *\n * A `<testcase>` per ARS check, a `<testsuite>` per URL. The obvious mapping —\n * one test case per URL, pass/fail on the threshold — throws away the entire\n * report and gives a reviewer a red X with no location, which is precisely the\n * experience that gets a check deleted.\n *\n * The critical distinction is `<failure>` vs `<error>`, which is the JUnit\n * schema's own version of our 1-vs-3 split and the reason this format is worth\n * writing by hand:\n * - `<failure>` — the page was scored and a check did not earn full marks.\n * A fact about the site.\n * - `<error>` — we never got a score: unreachable, blocked, refused, opt-out.\n * Infrastructure. Every CI dashboard renders errors differently from\n * failures, and getting this backwards is what teaches a team to ignore the\n * job.\n * A run whose target was unreachable therefore produces zero failures and one\n * error, and the process exits 3 — the two signals agree.\n *\n * `--fail-on` adds ONE extra test case per URL, named for the threshold, so the\n * gate is visible in the report as its own line rather than implied by the exit\n * code. When no threshold is set that case is absent, not passing: a green\n * \"threshold met\" for a threshold nobody asked for is a lie of omission.\n */\n\nimport { ARS_NOTICE } from '../disclosure'\nimport type { Payload } from '../payload'\nimport { exitCodeFor, meetsThreshold, outcomeSummary, statusOf, type UrlReport } from '../report'\nimport type { Grade } from '../args'\nimport { EXIT } from '../exit'\nimport { basisLabel, escapeXml, type FormatContext } from './shared'\n\nconst SUITE_NAME = 'rebilder.ars'\n\nexport function renderJunit(payload: Payload, ctx: FormatContext): string {\n const suites: string[] = []\n let tests = 0\n let failures = 0\n let errors = 0\n\n if (payload.command === 'check') {\n for (const report of payload.reports) {\n const suite = checkSuite(report, payload.failOn, ctx)\n suites.push(suite.xml)\n tests += suite.tests\n failures += suite.failures\n errors += suite.errors\n }\n } else if (payload.command === 'diff') {\n const suite = checkSuite(payload.diff.report, null, ctx)\n suites.push(suite.xml)\n tests += suite.tests\n failures += suite.failures\n errors += suite.errors\n } else {\n // `init` and `badge` produce no observations, so they produce no test cases.\n // An empty testsuites element is valid and honest; inventing a passing case\n // for \"we printed a snippet\" would put a green tick in a report for work no\n // check performed.\n suites.push(\n ` <testsuite name=\"${SUITE_NAME}.${payload.command}\" tests=\"0\" failures=\"0\" errors=\"0\"/>`,\n )\n }\n\n return [\n '<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\n `<testsuites name=\"${SUITE_NAME}\" tests=\"${tests}\" failures=\"${failures}\" errors=\"${errors}\">`,\n ...suites,\n '</testsuites>',\n '',\n ].join('\\n')\n}\n\ninterface Suite {\n xml: string\n tests: number\n failures: number\n errors: number\n}\n\nfunction checkSuite(report: UrlReport, failOn: Grade | null, ctx: FormatContext): Suite {\n const cases: string[] = []\n let tests = 0\n let failures = 0\n let errors = 0\n\n const properties = [\n ` <property name=\"notice\" value=\"${escapeXml(ARS_NOTICE)}\"/>`,\n ` <property name=\"url\" value=\"${escapeXml(report.url)}\"/>`,\n ` <property name=\"generatedAt\" value=\"${escapeXml(ctx.generatedAt)}\"/>`,\n ` <property name=\"tool\" value=\"rebilder ${escapeXml(ctx.cliVersion)}\"/>`,\n ]\n\n if (report.kind === 'probed') {\n const { result } = report\n properties.push(\n ` <property name=\"specVersion\" value=\"${escapeXml(result.specVersion)}\"/>`,\n ` <property name=\"rulesetHash\" value=\"${escapeXml(result.rulesetHash)}\"/>`,\n ` <property name=\"corpusHash\" value=\"${escapeXml(result.corpusHash)}\"/>`,\n ` <property name=\"evidenceHash\" value=\"${escapeXml(result.evidenceHash)}\"/>`,\n ` <property name=\"measuredWeight\" value=\"${result.measuredWeight}\"/>`,\n ` <property name=\"heuristicWeight\" value=\"${result.heuristicWeight}\"/>`,\n )\n }\n\n const status = statusOf(report)\n // Narrowed on `report.kind` rather than on `status`, because the compiler can\n // follow the discriminant and cannot follow a helper's return value — and a\n // cast here would be a cast around the one branch that must not be wrong.\n if (report.kind === 'rejected' || report.result.outcome.kind !== 'scored') {\n // Never scored -> exactly one ERROR case. Not a failure: see the header.\n tests += 1\n errors += 1\n cases.push(\n [\n ` <testcase classname=\"${escapeXml(report.url)}\" name=\"probe\">`,\n ` <error type=\"${escapeXml(status)}\" message=\"${escapeXml(outcomeSummary(report))}\"/>`,\n ' </testcase>',\n ].join('\\n'),\n )\n } else {\n const { result } = report\n for (const dimension of result.dimensions) {\n for (const check of dimension.checks) {\n tests += 1\n const passed = check.earned >= check.weight\n const name = `${check.id} [${basisLabel(check.basis)}] ${check.earned}/${check.weight}`\n if (passed) {\n cases.push(\n ` <testcase classname=\"${escapeXml(report.url)}\" name=\"${escapeXml(name)}\"/>`,\n )\n continue\n }\n failures += 1\n const detail = [\n check.remedy ?? '',\n ...check.evidence.map(\n (item) => `${item.label}: ${item.value} [${basisLabel(item.basis)}]`,\n ),\n ]\n .filter((line) => line.length > 0)\n .join('\\n')\n cases.push(\n [\n ` <testcase classname=\"${escapeXml(report.url)}\" name=\"${escapeXml(name)}\">`,\n ` <failure type=\"${escapeXml(check.basis)}\" message=\"${escapeXml(`${check.label} earned ${check.earned} of ${check.weight}`)}\">${escapeXml(detail)}</failure>`,\n ' </testcase>',\n ].join('\\n'),\n )\n }\n }\n\n if (failOn !== null && result.grade !== null) {\n tests += 1\n const met = meetsThreshold(result.grade, failOn)\n const name = `threshold --fail-on ${failOn}`\n if (met) {\n cases.push(` <testcase classname=\"${escapeXml(report.url)}\" name=\"${escapeXml(name)}\"/>`)\n } else {\n failures += 1\n cases.push(\n [\n ` <testcase classname=\"${escapeXml(report.url)}\" name=\"${escapeXml(name)}\">`,\n ` <failure type=\"threshold\" message=\"${escapeXml(`graded ${result.grade} (${result.score}/100); the threshold is ${failOn} or better`)}\"/>`,\n ' </testcase>',\n ].join('\\n'),\n )\n }\n }\n }\n\n const exitCode = exitCodeFor(report, failOn)\n properties.push(` <property name=\"exitCode\" value=\"${exitCode}\"/>`)\n if (exitCode === EXIT.PROBE || exitCode === EXIT.POLICY) {\n properties.push(\n ` <property name=\"notAScoreFailure\" value=\"${exitCode === EXIT.PROBE ? 'probe failure — infrastructure' : 'blocked by policy'}\"/>`,\n )\n }\n\n const xml = [\n ` <testsuite name=\"${escapeXml(report.url)}\" tests=\"${tests}\" failures=\"${failures}\" errors=\"${errors}\">`,\n ' <properties>',\n ...properties,\n ' </properties>',\n ...cases,\n ' </testsuite>',\n ].join('\\n')\n\n return { xml, tests, failures, errors }\n}\n","import type { ArsResult } from '@rebilder/agent-readability'\n\n/** Guidance uses observations only; it never changes the score or machine output. */\nexport function nextSteps(result: ArsResult): string[] {\n if (result.outcome.kind !== 'scored') return []\n const found = new Set(result.facts.map((fact) => fact.kind))\n const missing = result.factProfile.core.filter((kind) => !found.has(kind))\n const steps: string[] = []\n if (missing.length > 0) {\n steps.push(`Check these business details: ${missing.join(', ')}. They were not detected in this capture (heuristic); verify the page before adding or changing content.`)\n } else {\n steps.push('The expected core business details were detected (heuristic). Review their accuracy against your current products, services and policies.')\n }\n const first = result.recommendations[0]\n if (first !== undefined) steps.push(`Start with: ${first.title}. ${first.detail}`)\n steps.push(result.cost.negotiatedBytes === null\n ? 'To connect your existing information, run rebilder init in your project. Review the generated configuration and connect your real data before deployment.'\n : 'Compare the two responses with rebilder diff <url> and confirm the same business facts reach customers and assistants.')\n steps.push('After updating your site, run rebilder check <url> again. Export --format markdown --out review.md to share the findings with your team.')\n steps.push('This scan measures page readability; it does not measure customer demand, AI recommendations or sales.')\n return steps\n}\n","import { nextSteps } from '../next-steps'\n/**\n * format/markdown.ts — for a PR comment or a job summary.\n *\n * This is the format that gets pasted into a place other people read, which\n * changes two things about it. First, the basis column is not optional and not\n * abbreviated: someone is going to screenshot the table, and a heuristic point\n * total with no label next to it is exactly the misuse Hard Rule 10 exists to\n * prevent. Second, the §3.6 notice renders as a blockquote at the end of every\n * report, where it survives being copied — a footnote in small text does not.\n *\n * No page excerpts here either, for the same reason as everywhere else: numbers\n * and structure only.\n */\n\nimport type { ArsResult } from '@rebilder/agent-readability'\nimport { ARS_NOTICE_LINES } from '../disclosure'\nimport type { DiffPayload, Payload } from '../payload'\nimport { outcomeSummary, statusOf, type UrlReport } from '../report'\nimport {\n approxTokens,\n basisLabel,\n bytesText,\n escapeCell,\n shortHash,\n type FormatContext,\n} from './shared'\n\nexport function renderMarkdown(payload: Payload, ctx: FormatContext): string {\n switch (payload.command) {\n case 'check':\n return payload.reports.map((report) => checkSection(report)).join('\\n---\\n\\n') + notice()\n case 'diff':\n return diffSection(payload.diff) + notice()\n case 'init':\n return initSection(payload, ctx)\n case 'badge':\n return badgeSection(payload)\n }\n}\n\nfunction notice(): string {\n return `\\n${ARS_NOTICE_LINES.map((line) => `> ${line}`).join('\\n')}\\n`\n}\n\nfunction checkSection(report: UrlReport): string {\n const out: string[] = [`## ${escapeCell(report.url)}`, '']\n\n if (report.kind === 'rejected') {\n out.push(`**REJECTED** — ${outcomeSummary(report)}`, '')\n return out.join('\\n')\n }\n\n const { result } = report\n if (statusOf(report) !== 'scored') {\n out.push(outcomeSummary(report), '')\n out.push(policyLine(result), '')\n out.push(identityLine(result), '')\n return out.join('\\n')\n }\n\n out.push(\n `**${result.grade} — ${result.bandLabel}** · ${result.score}/100 · page kind \\`${result.pageKind}\\` (${result.pageKindConfidence} confidence, ${basisLabel(result.pageKindBasis)})`,\n '',\n `${result.measuredWeight} of the 100 points are measured; ${result.heuristicWeight} are heuristic.`,\n '',\n '### Your next steps',\n '',\n ...nextSteps(result).map((step) => `- ${escapeCell(step)}`),\n '',\n '| Check | Points | Basis |',\n '| --- | ---: | --- |',\n )\n\n for (const dimension of result.dimensions) {\n out.push(\n `| **${escapeCell(dimension.label)}** | **${dimension.earned}/${dimension.weight}** | ${basisLabel(dimension.basis)} |`,\n )\n for (const check of dimension.checks) {\n out.push(\n `| ${escapeCell(check.label)} | ${check.earned}/${check.weight} | ${basisLabel(check.basis)} |`,\n )\n }\n }\n\n out.push('', '### What an agent pays', '')\n out.push('| | Bytes | Tokens |', '| --- | --- | --- |')\n out.push(\n `| HTML | ${bytesText(result.cost.htmlBytes, result.cost.truncated, true)} | ${approxTokens(result.cost.approxHtmlTokens, true)} |`,\n )\n out.push(\n `| Negotiated | ${bytesText(result.cost.negotiatedBytes, result.cost.truncated, true)} | ${approxTokens(result.cost.approxNegotiatedTokens, true)} |`,\n )\n if (result.cost.reductionRatio !== null) {\n out.push(`| Reduction | ${result.cost.reductionRatio}% | |`)\n }\n\n if (result.flags.length > 0) {\n out.push('', '### Flags', '')\n for (const flag of result.flags) {\n out.push(`- \\`${flag.id}\\` (${flag.severity}, ${basisLabel(flag.basis)}) — ${flag.message}`)\n }\n }\n\n if (result.recommendations.length > 0) {\n out.push('', '### Fixes, most points first', '')\n out.push('| Points | Fix | Effort |', '| ---: | --- | --- |')\n for (const recommendation of result.recommendations) {\n out.push(\n `| +${recommendation.pointsAvailable} | ${escapeCell(recommendation.title)} | ${recommendation.effort} |`,\n )\n }\n }\n\n out.push('', policyLine(result), '', identityLine(result), '')\n return out.join('\\n')\n}\n\nfunction policyLine(result: ArsResult): string {\n const { policy } = result\n return `Policy: robots.txt ${policy.robotsTxtStatus} · assistant ${policy.audiences.assistant.decision} · training ${policy.audiences.training.decision} (neutral) · sitemap ${policy.sitemapDeclared ? 'declared' : 'not declared'}`\n}\n\nfunction identityLine(result: ArsResult): string {\n return `ARS ${result.specVersion} · ruleset \\`${shortHash(result.rulesetHash)}\\` · corpus \\`${shortHash(result.corpusHash)}\\` · evidence \\`${shortHash(result.evidenceHash)}\\` · vantage ${result.vantage}`\n}\n\nfunction diffSection(diff: DiffPayload): string {\n const out: string[] = [`## ${escapeCell(diff.url)} — agent view vs browser view`, '']\n if (diff.report.kind === 'rejected') {\n out.push(`**REJECTED** — ${outcomeSummary(diff.report)}`, '')\n return out.join('\\n')\n }\n out.push(\n 'The two requests differ in the `Accept` header and in nothing else — same User-Agent, same everything.',\n '',\n '| | Agent | Browser |',\n '| --- | --- | --- |',\n `| Accept | \\`${escapeCell(diff.agent?.accept ?? '—')}\\` | \\`${escapeCell(diff.browser?.accept ?? '—')}\\` |`,\n `| Status | ${diff.agent?.status ?? '—'} | ${diff.browser?.status ?? '—'} |`,\n `| Content-Type | ${escapeCell(diff.agent?.contentType ?? '—')} | ${escapeCell(diff.browser?.contentType ?? '—')} |`,\n `| Bytes | ${bytesText(diff.agent?.bytes ?? null, diff.agent?.truncated ?? false, true)} | ${bytesText(diff.browser?.bytes ?? null, diff.browser?.truncated ?? false, true)} |`,\n `| Tokens | ${approxTokens(diff.agent?.approxTokens ?? null, true)} | ${approxTokens(diff.browser?.approxTokens ?? null, true)} |`,\n `| Redirects | ${diff.agent?.redirects ?? '—'} | ${diff.browser?.redirects ?? '—'} |`,\n )\n if (diff.parity !== null) {\n out.push(\n '',\n `### Substance parity — ${diff.parity.earned}/${diff.parity.weight} (${basisLabel(diff.parity.basis)})`,\n '',\n 'Compared on price, currency, availability and title only — never description or free text.',\n '',\n )\n for (const evidence of diff.parity.evidence) {\n out.push(\n `- ${escapeCell(evidence.label)}: ${escapeCell(evidence.value)} (${basisLabel(evidence.basis)})`,\n )\n }\n }\n if (diff.result !== null) out.push('', identityLine(diff.result), '')\n return out.join('\\n')\n}\n\nfunction initSection(payload: Extract<Payload, { command: 'init' }>, ctx: FormatContext): string {\n const { scaffold } = payload\n const out = [\n `## Rebilder gateway scaffold — ${scaffold.framework}`,\n '',\n scaffold.detection,\n '',\n `Suggested path: \\`${scaffold.suggestedPath}\\``,\n '',\n '```' + scaffold.language,\n scaffold.contents.trimEnd(),\n '```',\n '',\n ]\n for (const note of scaffold.notes) out.push(`- ${note}`)\n out.push('', `<!-- generated by rebilder ${ctx.cliVersion} -->`, '')\n return out.join('\\n')\n}\n\nfunction badgeSection(payload: Extract<Payload, { command: 'badge' }>): string {\n const { badge } = payload\n const out = [\n `## Rebilder badge — ${badge.domain}`,\n '',\n '```markdown',\n badge.markdown,\n '```',\n '',\n '```html',\n badge.html,\n '```',\n '',\n ]\n for (const note of badge.notes) out.push(`- ${note}`)\n out.push('')\n return out.join('\\n')\n}\n","/**\n * term.ts — hand-rolled ANSI and box drawing. Zero runtime dependencies (§5.6).\n *\n * WHY NOT `chalk`/`picocolors`/`cli-table3`. This binary is installed with\n * `npx rebilder check` by people who have not decided to trust us yet, inside CI\n * containers where every transitive dependency is an supply-chain question they\n * have to answer on our behalf. Colour is sixteen escape sequences and a table is\n * a loop; neither is worth a dependency, and \"zero deps\" is a claim we can only\n * make if we never make an exception for the easy one.\n *\n * TWO CAPABILITIES, DECIDED SEPARATELY, because they fail in different places:\n *\n * - COLOUR is off unless stdout is a TTY, and off unconditionally when\n * `NO_COLOR` is set to anything at all (no-color.org: the variable's presence\n * is the signal, its value is not). `FORCE_COLOR` turns it back on for the\n * case that actually matters — a CI runner that renders ANSI in its log\n * viewer while presenting a pipe to the process.\n *\n * - UNICODE is decided by the locale, not by the TTY. A pipe into a file is\n * perfectly capable of holding `│`; a Windows console at code page 437 is not,\n * and neither is a `LANG=C` container. So: use box-drawing characters when the\n * locale says UTF-8, fall back to `+-|` otherwise. Getting this wrong is not\n * cosmetic — mojibake in a build log is indistinguishable from a crash.\n *\n * Everything here takes its environment as an argument. Nothing reads\n * `process.env` or `process.stdout` at module scope, so a test can render both\n * branches without touching the process.\n */\n\nexport interface TermCapabilities {\n color: boolean\n unicode: boolean\n /** Columns available for output. Clamped to a sane range. */\n width: number\n}\n\nexport interface TermEnvironment {\n env: Readonly<Record<string, string | undefined>>\n isTty: boolean\n columns?: number | undefined\n}\n\nconst MIN_WIDTH = 40\nconst MAX_WIDTH = 100\n\nexport function detectCapabilities(environment: TermEnvironment): TermCapabilities {\n const { env, isTty } = environment\n\n // no-color.org: presence is the signal. An empty string still counts.\n const noColor = env['NO_COLOR'] !== undefined\n const forceColor = env['FORCE_COLOR'] !== undefined && env['FORCE_COLOR'] !== '0'\n const dumbTerm = env['TERM'] === 'dumb'\n const color = !noColor && !dumbTerm && (forceColor || isTty)\n\n const locale = `${env['LC_ALL'] ?? ''} ${env['LC_CTYPE'] ?? ''} ${env['LANG'] ?? ''}`\n const unicode = /utf-?8/i.test(locale)\n\n const raw = environment.columns ?? 80\n const width = Math.max(MIN_WIDTH, Math.min(MAX_WIDTH, Number.isFinite(raw) ? raw : 80))\n\n return { color, unicode, width }\n}\n\n/* ── colour ───────────────────────────────────────────────────────────────── */\n\nconst CODES = {\n reset: 0,\n bold: 1,\n dim: 2,\n red: 31,\n green: 32,\n yellow: 33,\n blue: 34,\n magenta: 35,\n cyan: 36,\n gray: 90,\n} as const\n\nexport type Style = keyof typeof CODES\n\nexport interface Painter {\n (text: string, ...styles: Style[]): string\n readonly enabled: boolean\n}\n\nexport function createPainter(enabled: boolean): Painter {\n const paint = (text: string, ...styles: Style[]): string => {\n if (!enabled || styles.length === 0) return text\n const open = styles.map((style) => `\\u001b[${CODES[style]}m`).join('')\n return `${open}${text}\\u001b[${CODES.reset}m`\n }\n return Object.assign(paint, { enabled })\n}\n\n/**\n * Visible width, ignoring escape sequences. Deliberately NOT a full grapheme\n * width implementation: that is `string-width` plus `emoji-regex` plus a Unicode\n * table, i.e. the dependency tree we refused. We control every string that goes\n * through the table renderer except the URL and the page title, and both are\n * truncated by code point before they get here, so the failure mode of this\n * approximation is a column one cell wide in the far east — not a crash, and not\n * a wrong number.\n */\nconst ANSI_RE = /\\u001b\\[[0-9;]*m/g\n\nexport function visibleWidth(text: string): number {\n // Code points, not UTF-16 units: `[...s].length` counts an astral character\n // once, `s.length` counts it twice and pads the column short by one.\n return [...text.replace(ANSI_RE, '')].length\n}\n\nexport function padEnd(text: string, width: number): string {\n const pad = width - visibleWidth(text)\n return pad > 0 ? text + ' '.repeat(pad) : text\n}\n\nexport function padStart(text: string, width: number): string {\n const pad = width - visibleWidth(text)\n return pad > 0 ? ' '.repeat(pad) + text : text\n}\n\n/** Truncates by code point (never mid-surrogate), with an ellipsis marker. */\nexport function truncate(text: string, width: number, unicode: boolean): string {\n if (visibleWidth(text) <= width) return text\n const marker = unicode ? '…' : '...'\n const budget = Math.max(0, width - marker.length)\n let out = ''\n let used = 0\n for (const codePoint of text) {\n if (used + 1 > budget) break\n out += codePoint\n used += 1\n }\n return out + marker\n}\n\n/* ── box drawing ──────────────────────────────────────────────────────────── */\n\nexport interface BoxGlyphs {\n horizontal: string\n vertical: string\n topLeft: string\n topRight: string\n bottomLeft: string\n bottomRight: string\n teeLeft: string\n teeRight: string\n bullet: string\n check: string\n cross: string\n partial: string\n arrow: string\n}\n\nconst UNICODE_GLYPHS: BoxGlyphs = {\n horizontal: '─',\n vertical: '│',\n topLeft: '┌',\n topRight: '┐',\n bottomLeft: '└',\n bottomRight: '┘',\n teeLeft: '├',\n teeRight: '┤',\n bullet: '•',\n check: '✔',\n cross: '✘',\n partial: '◐',\n arrow: '→',\n}\n\nconst ASCII_GLYPHS: BoxGlyphs = {\n horizontal: '-',\n vertical: '|',\n topLeft: '+',\n topRight: '+',\n bottomLeft: '+',\n bottomRight: '+',\n teeLeft: '+',\n teeRight: '+',\n bullet: '*',\n // One code point each, matching the Unicode set, so the status column is the\n // same width in both renderings and the table does not need two layouts.\n check: '+',\n cross: 'x',\n partial: '~',\n arrow: '>',\n}\n\nexport function glyphsFor(unicode: boolean): BoxGlyphs {\n return unicode ? UNICODE_GLYPHS : ASCII_GLYPHS\n}\n\n/** A single-rule frame. `lines` are already padded to `width` by the caller. */\nexport function frame(lines: readonly string[], width: number, glyphs: BoxGlyphs): string[] {\n const bar = glyphs.horizontal.repeat(width + 2)\n const out: string[] = [`${glyphs.topLeft}${bar}${glyphs.topRight}`]\n for (const line of lines) {\n if (line === RULE) {\n out.push(`${glyphs.teeLeft}${bar}${glyphs.teeRight}`)\n continue\n }\n out.push(`${glyphs.vertical} ${padEnd(line, width)} ${glyphs.vertical}`)\n }\n out.push(`${glyphs.bottomLeft}${bar}${glyphs.bottomRight}`)\n return out\n}\n\n/** Sentinel a caller pushes into `frame`'s lines to get a horizontal divider. */\nexport const RULE = '\u0000rule\u0000'\n","/**\n * format/pretty.ts — the terminal rendering.\n *\n * WHAT IT LEADS WITH, AND WHY IN THAT ORDER. The band, then the integer, then\n * the dimension table, then the cost, then the fixes. §3.6 says ARS is ordinal:\n * \"D — Partial\" is the finding and \"54\" is the detail, so the letter is bold and\n * the number is not, and there are no decimals anywhere. Under that, every check\n * prints its own basis word — a heuristic value never renders without its label\n * (Hard Rule 10) — and the measured/heuristic split prints under the total so\n * nobody has to go and look up how much of their score was inferred.\n *\n * WHAT IT REFUSES TO PRINT. No excerpt of the target page. Structure and\n * numbers: byte counts, offsets, statuses, check evidence values. The visceral\n * impact is in the numbers (§5.3), and a tool that dumps somebody's page into a\n * build log has a copyright problem the numbers do not.\n *\n * The renderer is pure text in, pure text out. It takes its terminal\n * capabilities as an argument and reads no environment, so the ASCII branch and\n * the no-colour branch are both one call away in a test rather than something\n * you have to arrange a TTY to see.\n */\n\nimport type { ArsCheck, ArsDimension, ArsResult } from '@rebilder/agent-readability'\nimport { ARS_NOTICE_LINES } from '../disclosure'\nimport { nextSteps } from '../next-steps'\nimport type { BadgeSnippet, DiffPayload, Payload, Scaffold } from '../payload'\nimport { outcomeSummary, statusOf, type UrlReport } from '../report'\nimport {\n createPainter,\n glyphsFor,\n padEnd,\n padStart,\n truncate,\n visibleWidth,\n type Painter,\n type TermCapabilities,\n} from '../term'\nimport {\n absent,\n approxTokens,\n basisLabel,\n bytesText,\n checkMark,\n percent,\n shortHash,\n type FormatContext,\n} from './shared'\n\ninterface Pretty {\n caps: TermCapabilities\n paint: Painter\n}\n\nconst BASIS_COLUMN = 9 // 'heuristic'\nconst POINTS_COLUMN = 7 // '100/100'\n\n/**\n * `_ctx` is unused and stays in the signature anyway: all four renderers are\n * dispatched through one call in `./index`, and a uniform signature is what\n * keeps that dispatch a switch rather than four special cases. The terminal\n * rendering has no use for a generation timestamp — the identity footer already\n * carries the three hashes, which is what actually identifies a score.\n */\nexport function renderPretty(\n payload: Payload,\n caps: TermCapabilities,\n _ctx: FormatContext,\n): string {\n const pretty: Pretty = { caps, paint: createPainter(caps.color) }\n switch (payload.command) {\n case 'check':\n return joinBlocks(payload.reports.map((report) => checkBlock(report, pretty)))\n case 'diff':\n return joinBlocks([diffBlock(payload.diff, pretty)])\n case 'init':\n return joinBlocks([initBlock(payload.scaffold, pretty)])\n case 'badge':\n return joinBlocks([badgeBlock(payload.badge, pretty)])\n }\n}\n\n/**\n * Trailing whitespace is trimmed per line. The last column is padded so the\n * table aligns, and that padding then has nothing to its right — it is invisible\n * on screen and pure noise in a `--out` file, a git diff, or a README block that\n * a test compares byte for byte.\n */\nfunction joinBlocks(blocks: string[][]): string {\n return (\n blocks\n .map((lines) => lines.map((line) => line.replace(/[ \\t]+$/, '')).join('\\n'))\n .join('\\n\\n') + '\\n'\n )\n}\n\n/* ── check ────────────────────────────────────────────────────────────────── */\n\nfunction gradeStyle(grade: string): 'green' | 'cyan' | 'yellow' | 'red' {\n if (grade === 'A') return 'green'\n if (grade === 'B') return 'cyan'\n if (grade === 'C') return 'yellow'\n return 'red'\n}\n\nfunction checkBlock(report: UrlReport, pretty: Pretty): string[] {\n const { paint, caps } = pretty\n const glyphs = glyphsFor(caps.unicode)\n const lines: string[] = []\n const width = caps.width\n\n lines.push(paint(truncate(report.url, width, caps.unicode), 'bold'))\n lines.push(paint(glyphs.horizontal.repeat(Math.min(width, 64)), 'gray'))\n\n if (report.kind === 'rejected') {\n lines.push(`${paint('REJECTED', 'red', 'bold')} ${outcomeSummary(report)}`)\n lines.push(...noticeLines(pretty))\n return lines\n }\n\n const { result } = report\n const status = statusOf(report)\n\n if (status !== 'scored') {\n lines.push(paint(outcomeSummary(report), 'yellow'))\n lines.push('')\n lines.push(...policyLines(result, pretty))\n lines.push(...identityLines(result, pretty))\n lines.push(...noticeLines(pretty))\n return lines\n }\n\n const grade = result.grade ?? '?'\n const scoreText = `${result.score ?? 0}/100`\n lines.push(\n `${paint(grade, gradeStyle(grade), 'bold')} ${paint(result.bandLabel ?? '', 'bold')} ${paint(scoreText, 'gray')}`,\n )\n lines.push(\n paint(\n `${result.measuredWeight} of the 100 points are measured, ${result.heuristicWeight} heuristic`,\n 'gray',\n ),\n )\n lines.push(\n paint(\n `page kind: ${result.pageKind} (${result.pageKindConfidence} confidence, ${basisLabel(result.pageKindBasis)})`,\n 'gray',\n ),\n )\n lines.push('')\n\n lines.push(paint('Your next steps', 'bold'))\n for (const step of nextSteps(result)) lines.push(` ${glyphs.bullet} ${step}`)\n lines.push('')\n\n for (const dimension of result.dimensions) {\n lines.push(...dimensionLines(dimension, pretty))\n }\n\n lines.push('')\n lines.push(...costLines(result, pretty))\n\n if (result.flags.length > 0) {\n lines.push('')\n lines.push(paint('Flags', 'bold'))\n for (const flag of result.flags) {\n const tone = flag.severity === 'warn' ? 'yellow' : 'gray'\n lines.push(\n ` ${glyphs.bullet} ${paint(flag.id, tone)} [${basisLabel(flag.basis)}] ${flag.message}`,\n )\n }\n }\n\n if (result.recommendations.length > 0) {\n lines.push('')\n lines.push(paint('Fixes, most points first', 'bold'))\n for (const recommendation of result.recommendations) {\n lines.push(\n ` ${padStart(`+${recommendation.pointsAvailable}`, 4)} ${paint(recommendation.title, 'bold')} ${paint(`(${recommendation.effort})`, 'gray')}`,\n )\n lines.push(\n paint(` ${truncate(recommendation.detail, caps.width - 8, caps.unicode)}`, 'gray'),\n )\n }\n }\n\n lines.push('')\n lines.push(...policyLines(result, pretty))\n lines.push(...identityLines(result, pretty))\n lines.push(...noticeLines(pretty))\n return lines\n}\n\nfunction dimensionLines(dimension: ArsDimension, pretty: Pretty): string[] {\n const { paint, caps } = pretty\n const lines: string[] = []\n const head = `${dimension.label}`\n const points = `${dimension.earned}/${dimension.weight}`\n const labelWidth = Math.max(10, caps.width - POINTS_COLUMN - BASIS_COLUMN - 4)\n lines.push(\n `${paint(padEnd(truncate(head, labelWidth, caps.unicode), labelWidth), 'bold')} ${padStart(points, POINTS_COLUMN)} ${padEnd(basisLabel(dimension.basis), BASIS_COLUMN)}`,\n )\n for (const check of dimension.checks) {\n lines.push(checkLine(check, pretty, labelWidth))\n }\n return lines\n}\n\nfunction checkLine(check: ArsCheck, pretty: Pretty, labelWidth: number): string {\n const { paint, caps } = pretty\n const mark = checkMark(check, caps.unicode)\n const tone = check.earned >= check.weight ? 'green' : check.earned > 0 ? 'yellow' : 'red'\n const label = ` ${mark} ${check.label}`\n const points = `${check.earned}/${check.weight}`\n return `${padEnd(truncate(label, labelWidth, caps.unicode), labelWidth)} ${paint(padStart(points, POINTS_COLUMN), tone)} ${paint(padEnd(basisLabel(check.basis), BASIS_COLUMN), 'gray')}`\n}\n\nfunction costLines(result: ArsResult, pretty: Pretty): string[] {\n const { paint, caps } = pretty\n const { cost } = result\n const lines = [paint('What an agent pays', 'bold')]\n const html = bytesText(cost.htmlBytes, cost.truncated, caps.unicode)\n const negotiated = bytesText(cost.negotiatedBytes, cost.truncated, caps.unicode)\n const byteColumn = Math.max(visibleWidth(html), visibleWidth(negotiated)) + 3\n lines.push(\n ` HTML ${padEnd(html, byteColumn)}${approxTokens(cost.approxHtmlTokens, caps.unicode)}`,\n )\n lines.push(\n ` Negotiated ${padEnd(negotiated, byteColumn)}${approxTokens(cost.approxNegotiatedTokens, caps.unicode)}`,\n )\n if (cost.reductionRatio !== null) {\n lines.push(paint(` Reduction ${cost.reductionRatio}%`, 'green'))\n }\n lines.push(\n ` First core fact at byte ${cost.firstCoreFactOffset === null ? absent(caps.unicode) : cost.firstCoreFactOffset.toLocaleString('en-US')}`,\n )\n const core = result.factProfile.core\n const found = result.facts.filter((fact) => core.includes(fact.kind)).length\n lines.push(\n paint(\n ` Core facts found ${found}/${core.length} (${percent(found, core.length)}) for a ${result.pageKind} page — heuristic`,\n 'gray',\n ),\n )\n return lines\n}\n\nfunction policyLines(result: ArsResult, pretty: Pretty): string[] {\n const { paint } = pretty\n const { policy } = result\n const parts = [\n `robots.txt ${policy.robotsTxtStatus}`,\n `assistant ${policy.audiences.assistant.decision}`,\n `training ${policy.audiences.training.decision} (neutral)`,\n `sitemap ${policy.sitemapDeclared ? 'declared' : 'not declared'}`,\n ]\n return [paint(`Policy: ${parts.join(' · ')}`, 'gray')]\n}\n\nfunction identityLines(result: ArsResult, pretty: Pretty): string[] {\n const { paint } = pretty\n return [\n paint(\n `ARS ${result.specVersion} · ruleset ${shortHash(result.rulesetHash)} · corpus ${shortHash(result.corpusHash)} · evidence ${shortHash(result.evidenceHash)} · vantage ${result.vantage}`,\n 'gray',\n ),\n ]\n}\n\nfunction noticeLines(pretty: Pretty): string[] {\n return ['', ...ARS_NOTICE_LINES.map((line) => pretty.paint(line, 'gray'))]\n}\n\n/* ── diff ─────────────────────────────────────────────────────────────────── */\n\nfunction diffBlock(diff: DiffPayload, pretty: Pretty): string[] {\n const { paint, caps } = pretty\n const glyphs = glyphsFor(caps.unicode)\n const lines: string[] = [\n paint(truncate(diff.url, caps.width, caps.unicode), 'bold'),\n paint(glyphs.horizontal.repeat(Math.min(caps.width, 64)), 'gray'),\n ]\n\n if (diff.report.kind === 'rejected') {\n lines.push(`${paint('REJECTED', 'red', 'bold')} ${outcomeSummary(diff.report)}`)\n lines.push(...noticeLines(pretty))\n return lines\n }\n\n lines.push(\n paint(\n 'The two requests differ in the Accept header and in nothing else — same User-Agent, same everything (§3.3).',\n 'gray',\n ),\n )\n lines.push('')\n\n const rows: [string, string, string][] = [\n ['', 'agent', 'browser'],\n [\n 'Accept',\n diff.agent?.accept ?? absent(caps.unicode),\n diff.browser?.accept ?? absent(caps.unicode),\n ],\n ['Status', text(diff.agent?.status, caps.unicode), text(diff.browser?.status, caps.unicode)],\n [\n 'Content-Type',\n diff.agent?.contentType ?? absent(caps.unicode),\n diff.browser?.contentType ?? absent(caps.unicode),\n ],\n [\n 'Bytes',\n bytesText(diff.agent?.bytes ?? null, diff.agent?.truncated ?? false, caps.unicode),\n bytesText(diff.browser?.bytes ?? null, diff.browser?.truncated ?? false, caps.unicode),\n ],\n [\n 'Tokens',\n approxTokens(diff.agent?.approxTokens ?? null, caps.unicode),\n approxTokens(diff.browser?.approxTokens ?? null, caps.unicode),\n ],\n [\n 'Redirects',\n text(diff.agent?.redirects, caps.unicode),\n text(diff.browser?.redirects, caps.unicode),\n ],\n [\n 'Error',\n diff.agent?.error ?? absent(caps.unicode),\n diff.browser?.error ?? absent(caps.unicode),\n ],\n ]\n\n const labelWidth = Math.max(...rows.map((row) => row[0].length)) + 2\n const columnWidth = Math.max(12, Math.floor((caps.width - labelWidth - 2) / 2))\n for (const [label, agentCell, browserCell] of rows) {\n lines.push(\n `${paint(padEnd(label, labelWidth), 'bold')}${padEnd(truncate(agentCell, columnWidth, caps.unicode), columnWidth + 2)}${truncate(browserCell, columnWidth, caps.unicode)}`,\n )\n }\n\n if (diff.parity !== null) {\n lines.push('')\n lines.push(\n `${paint('Substance parity', 'bold')} ${paint(`[${basisLabel(diff.parity.basis)}]`, 'gray')} ${diff.parity.earned}/${diff.parity.weight}`,\n )\n lines.push(\n paint(\n ' Compared on price, currency, availability and title only — never description or free text (§3.8).',\n 'gray',\n ),\n )\n for (const evidence of diff.parity.evidence) {\n lines.push(\n ` ${glyphs.bullet} ${evidence.label}: ${evidence.value} [${basisLabel(evidence.basis)}]`,\n )\n }\n }\n\n if (diff.result !== null) {\n lines.push('')\n lines.push(paint(`Score: ${outcomeSummary(diff.report)}`, 'gray'))\n lines.push(...identityLines(diff.result, pretty))\n }\n lines.push(...noticeLines(pretty))\n return lines\n}\n\nfunction text(value: number | null | undefined, unicode: boolean): string {\n return value === undefined || value === null ? absent(unicode) : String(value)\n}\n\n/* ── init and badge ───────────────────────────────────────────────────────── */\n\nfunction initBlock(scaffold: Scaffold, pretty: Pretty): string[] {\n const { paint } = pretty\n const lines = [\n paint(`Detected framework: ${scaffold.framework}`, 'bold'),\n paint(` ${scaffold.detection}`, 'gray'),\n '',\n paint(`Suggested path: ${scaffold.suggestedPath}`, 'gray'),\n '',\n scaffold.contents.trimEnd(),\n ]\n if (scaffold.notes.length > 0) {\n lines.push('')\n for (const note of scaffold.notes) lines.push(paint(` ${note}`, 'gray'))\n }\n return lines\n}\n\nfunction badgeBlock(badge: BadgeSnippet, pretty: Pretty): string[] {\n const { paint } = pretty\n const lines = [\n paint(`Badge for ${badge.domain}`, 'bold'),\n '',\n paint('Markdown', 'bold'),\n badge.markdown,\n '',\n paint('HTML', 'bold'),\n badge.html,\n '',\n ]\n for (const note of badge.notes) lines.push(paint(` ${note}`, 'gray'))\n return lines\n}\n","/**\n * format/index.ts — the one place `--format` is turned into a string.\n *\n * `--out` writes exactly what stdout would have shown, in the same format. There\n * is no separate \"file format\": a report you can read on screen and a report you\n * archive should not be two artifacts that can disagree, and the first time they\n * do, the one in the artifact store is the one nobody can reproduce.\n */\n\nimport { UsageError } from '../exit'\nimport type { Format } from '../args'\nimport type { Payload } from '../payload'\nimport type { TermCapabilities } from '../term'\nimport { renderJson } from './json'\nimport { renderJunit } from './junit'\nimport { renderMarkdown } from './markdown'\nimport { renderPretty } from './pretty'\nimport type { FormatContext } from './shared'\n\nexport type { FormatContext } from './shared'\n\nexport function render(\n payload: Payload,\n format: Format,\n caps: TermCapabilities,\n ctx: FormatContext,\n): string {\n if (format === 'junit' && (payload.command === 'init' || payload.command === 'badge')) {\n // Refused rather than emitted empty: `rebilder init --format junit` is\n // someone's mistake, and returning a valid file with nothing in it lets a\n // pipeline go green on a command that measured nothing.\n throw new UsageError(\n `--format junit reports observations about a page; \\`${payload.command}\\` makes none. Use pretty, json or markdown.`,\n )\n }\n\n switch (format) {\n case 'pretty':\n return renderPretty(payload, caps, ctx)\n case 'json':\n return renderJson(payload, ctx)\n case 'markdown':\n return renderMarkdown(payload, ctx)\n case 'junit':\n return renderJunit(payload, ctx)\n }\n}\n","/**\n * help.ts — `--help`.\n *\n * THE ZERO-TELEMETRY CONTRACT IS NOT IN A FOOTER. It prints in the general\n * help, where the person deciding whether to point this at an internal hostname\n * inside their own CI is actually looking. (The conflict-of-interest paragraph\n * that used to sit beside it was removed everywhere in Aug 2026, together with\n * the spec clause that required it.)\n *\n * THE EXIT-CODE TABLE IS IN THE HELP TEXT, not only in the README, because the\n * person wiring this into a pipeline is reading a terminal, and the 1-vs-3 split\n * only protects anything if they know it exists before the first flaky build.\n */\n\nimport { FORMATS, GRADES, type CommandName } from './args'\nimport { TELEMETRY_LINES } from './disclosure'\nimport { EXIT } from './exit'\n\nconst EXIT_TABLE: readonly string[] = [\n ` ${EXIT.OK} completed; threshold met, or no threshold set`,\n ` ${EXIT.THRESHOLD} completed; threshold NOT met`,\n ` ${EXIT.USAGE} usage error`,\n ` ${EXIT.PROBE} probe failed / target unreachable — infrastructure, not a score failure`,\n ` ${EXIT.POLICY} blocked by policy (SSRF guard, robots opt-out, probe budget spent)`,\n]\n\nconst GENERAL = `rebilder — help AI assistants understand your business website.\n\nUSAGE\n rebilder check <url...> [--format ${FORMATS.join('|')}] [--fail-on ${GRADES.join('|')}]\n [--out <file>] [--allow-private] [--allow-http]\n [--concurrency <n>]\n rebilder diff <url> agent view vs browser view\n rebilder init gateway config scaffold for the detected framework\n rebilder badge <domain> embed snippet\n\n rebilder help <command> detail for one command\n rebilder --version\n\nSTART HERE\n 1. Check an important product, service or location page.\n 2. Review the business details and suggested next steps in the report.\n 3. Run rebilder init in your project to prepare a website connection.\n 4. Update your site and rerun the check to verify the result.\n\n Share a report: rebilder check <url> --format markdown --out review.md\n A scan measures readability, not AI recommendations, customer demand or sales.\n\nEXIT CODES (a stable contract; never renumbered)\n${EXIT_TABLE.join('\\n')}\n\n The 1-vs-3 split is load-bearing. A flaky network exits 3, never 1: if an\n unreachable host failed your build as a score failure, the check would be\n deleted from CI within a week. --fail-on defaults to nothing, so plain\n \\`rebilder check <url>\\` reports and exits 0.\n\nZERO TELEMETRY\n${TELEMETRY_LINES.map((line) => ` ${line}`).join('\\n')}\n\n Spec: https://rebilder.com/spec/ars Crawler policy: https://rebilder.com/bots\n`\n\nconst CHECK = `rebilder check <url...>\n\n Probes each URL twice — an agent request and a browser control that differ in\n the Accept header and in nothing else — plus /robots.txt, /llms.txt and\n /.well-known/ucp per origin. Nothing else is requested. robots.txt is fetched\n first and obeyed.\n\nOPTIONS\n --format ${FORMATS.join('|')} default pretty\n --fail-on ${GRADES.join('|')} default none. \"--fail-on C\" means C or\n better passes; a worse grade exits 1.\n --out <file> write the same rendering to a file\n --concurrency <n> URLs in flight; default 1, max 8. The\n probe's politeness limiter still allows\n at most 1 request per host and 2 globally.\n --allow-http permit plain http targets\n --allow-private permit private, loopback and link-local\n targets. Routes through a separate,\n import-time-gated entry point; it is opt-in\n per invocation, never a config default, and\n refuses to load in a hosted runtime.\n Implies --allow-http.\n\n A non-graded outcome — a deliberate robots opt-out, a 403 at the edge, an\n unreachable host — never produces exit 1. Only a real score compared against a\n threshold you set can do that.\n`\n\nconst DIFF = `rebilder diff <url>\n\n Shows what the agent request received next to what the browser request\n received: status, content type, decoded bytes, an estimated token count, and\n the D2.4 substance-parity comparison verbatim.\n\n It shows structure and numbers, never an excerpt of the page. --fail-on is not\n supported: diff reports, it does not grade.\n\nOPTIONS\n --format ${FORMATS.join('|')} default pretty\n --out <file> write the same rendering to a file\n --allow-http, --allow-private as \\`check\\`\n`\n\nconst INIT = `rebilder init\n\n Writes a @rebilder/gateway config scaffold for the framework it detects in the\n working directory, and prints how it decided. Makes no network request and\n reads nothing outside the working directory.\n\nOPTIONS\n --framework next|node|edge|shopify override detection\n --out <file> write the scaffold to a file\n --format ${FORMATS.join('|')} junit is refused: init makes no observations\n\n The scaffold is a skeleton with TODOs, not a working config. The resolvers\n return YOUR source of truth — every substantive value comes from those fields,\n and the gateway never invents one.\n`\n\nconst BADGE = `rebilder badge <domain>\n\n Prints the markdown and HTML embed snippets for a domain's badge. Built\n locally: no network request, so we never learn which domain you asked about.\n\n A grade renders only for a verified opted-in domain; every other domain gets a\n neutral \"not rated\" badge at 200, not 404. The badge always names its subject,\n is served live, and degrades to \"unverified\" after 30 days without a\n successful re-scan.\n\nOPTIONS\n --format ${FORMATS.join('|')} junit is refused: badge makes no observations\n --out <file> write the snippet to a file\n`\n\nconst TOPICS: Record<CommandName, string> = {\n check: CHECK,\n diff: DIFF,\n init: INIT,\n badge: BADGE,\n}\n\nexport function helpText(topic: CommandName | null): string {\n if (topic === null) return GENERAL\n return TOPICS[topic]\n}\n","/**\n * cli.ts — parse, run, render, exit. The whole program in one readable function.\n *\n * `runCli` RETURNS an exit code rather than calling `process.exit`, and takes a\n * `CliRuntime` rather than reaching for `process`. That is what makes the exit\n * codes testable as a contract instead of as a hope: every test in\n * `tests/exit-codes.test.ts` is a call to this function with a fake probe and an\n * assertion on the integer it returned.\n *\n * THE ORDER OF OPERATIONS IS THE SAFETY PROPERTY. Parse first, and every parse\n * failure is exit 2 with nothing having been fetched. Then build the probe —\n * which for `--allow-private` is where the import-time gate in\n * `@rebilder/agent-readability/probe/local` fires, before any URL is touched.\n * Then run. Then render. Then write. A failure at any step short-circuits with\n * its own code, and no step can produce a code belonging to an earlier one.\n *\n * `--out` WRITES AFTER STDOUT, NOT INSTEAD OF IT. A CI job that redirects a\n * report to a file still wants the report in the log; making `--out` silent\n * would mean the only copy lives in an artifact nobody downloads.\n */\n\nimport { parseCommandLine, type Command } from './args'\nimport { runBadge } from './commands/badge'\nimport { runCheck } from './commands/check'\nimport { runDiff } from './commands/diff'\nimport { runInit } from './commands/init'\nimport { EXIT, UsageError, worstExit, type ExitCode } from './exit'\nimport { render, type FormatContext } from './format'\nimport { helpText } from './help'\nimport type { Payload } from './payload'\nimport { exitCodeFor } from './report'\nimport type { CliRuntime, ProbeRunner } from './runtime'\nimport { detectCapabilities } from './term'\n\n/** Kept in step with package.json by a test, so a stale constant cannot ship. */\nexport const CLI_VERSION = '0.2.1'\n\nexport async function runCli(argv: readonly string[], runtime: CliRuntime): Promise<ExitCode> {\n const caps = detectCapabilities({\n env: runtime.env,\n isTty: runtime.isTty,\n columns: runtime.columns,\n })\n\n try {\n const parsed = parseCommandLine(argv)\n\n if (parsed.kind === 'version') {\n runtime.write(`${CLI_VERSION}\\n`)\n return EXIT.OK\n }\n if (parsed.kind === 'help') {\n runtime.write(helpText(parsed.topic))\n return EXIT.OK\n }\n\n const { command } = parsed\n const { payload, exitCode } = await execute(command, runtime)\n\n const ctx: FormatContext = {\n unicode: caps.unicode,\n generatedAt: runtime.now().toISOString(),\n cliVersion: CLI_VERSION,\n }\n const rendered = render(payload, command.format, caps, ctx)\n\n runtime.write(rendered)\n if (command.out !== null) {\n await runtime.writeFile(command.out, rendered)\n }\n return exitCode\n } catch (error) {\n if (error instanceof UsageError) {\n runtime.writeError(`rebilder: ${error.message}\\n\\nRun \\`rebilder --help\\`.\\n`)\n return EXIT.USAGE\n }\n // Anything else is our bug or a genuinely broken environment (a failed\n // `--out` write, a probe module refusing to load). It is not the site's\n // fault, so it is never exit 1.\n runtime.writeError(`rebilder: ${error instanceof Error ? error.message : String(error)}\\n`)\n return EXIT.PROBE\n }\n}\n\ninterface Executed {\n payload: Payload\n exitCode: ExitCode\n}\n\nasync function execute(command: Command, runtime: CliRuntime): Promise<Executed> {\n switch (command.name) {\n case 'check': {\n const probe = await buildProbe(runtime, command.urls.length, command)\n const reports = await runCheck(command, probe)\n return {\n payload: { command: 'check', reports, failOn: command.failOn },\n exitCode: worstExit(reports.map((report) => exitCodeFor(report, command.failOn))),\n }\n }\n case 'diff': {\n const probe = await buildProbe(runtime, 1, command)\n const diff = await runDiff(command, probe)\n // `diff` never sets a threshold, so `exitCodeFor(..., null)` can only\n // return 0, 2, 3 or 4 — exit 1 is structurally unreachable here.\n return { payload: { command: 'diff', diff }, exitCode: exitCodeFor(diff.report, null) }\n }\n case 'init': {\n const scaffold = await runInit(command, runtime)\n return { payload: { command: 'init', scaffold }, exitCode: EXIT.OK }\n }\n case 'badge': {\n return { payload: { command: 'badge', badge: runBadge(command) }, exitCode: EXIT.OK }\n }\n }\n}\n\ninterface ProbeFlags {\n allowPrivate: boolean\n allowHttp: boolean\n}\n\nfunction buildProbe(\n runtime: CliRuntime,\n urlCount: number,\n flags: ProbeFlags,\n): Promise<ProbeRunner> {\n return runtime.probe({\n allowPrivate: flags.allowPrivate,\n allowHttp: flags.allowHttp,\n urlCount,\n })\n}\n","/**\n * runtime.ts — every impure thing the CLI can do, behind one injectable object.\n *\n * WHY THIS SHAPE. The test suite for a network tool is worthless if it can reach\n * the network, and \"we mocked `fetch`\" is not a guarantee — it is a hope about\n * every code path nobody thought to mock. Here the CLI holds no socket, no file\n * handle, no clock and no `process` reference at all: it holds a `CliRuntime`.\n * The tests pass one whose `probe` returns a fixture and whose `writeFile`\n * appends to an array, so a test that hits the network cannot be written by\n * accident — it has to construct the real runtime on purpose.\n *\n * THE PROBE FACTORY IS ASYNC FOR ONE REASON. `@rebilder/agent-readability/probe/local`\n * THROWS AT IMPORT TIME unless the process was started with `--allow-private`\n * (and refuses outright in a hosted runtime). That is exactly the behaviour we\n * want and it means the module cannot be imported statically — a top-level\n * `import` of it would make `rebilder check https://example.com` crash on\n * startup for everyone. So local mode is a dynamic import, reached only when the\n * flag is present, which is also what makes the permission per-invocation rather\n * than per-installation.\n */\n\nimport { readFile, writeFile } from 'node:fs/promises'\nimport { resolve as resolvePath } from 'node:path'\nimport {\n createLimiter,\n probeStrict,\n strictPolicy,\n type ProbeOutcome,\n type ProbePolicy,\n} from '@rebilder/agent-readability/probe'\n\n/** One probe of one URL. The only outbound request the CLI ever makes. */\nexport type ProbeRunner = (target: string) => Promise<ProbeOutcome>\n\nexport interface ProbeSetup {\n /** Routes through `./probe/local`. Per invocation, never a default. */\n allowPrivate: boolean\n allowHttp: boolean\n /** How many URLs this run will probe — sizes the run budget, nothing else. */\n urlCount: number\n}\n\nexport type ProbeFactory = (setup: ProbeSetup) => Promise<ProbeRunner>\n\nexport interface CliRuntime {\n env: Readonly<Record<string, string | undefined>>\n cwd: string\n isTty: boolean\n columns: number | undefined\n write(text: string): void\n writeError(text: string): void\n writeFile(path: string, contents: string): Promise<void>\n readFile(path: string): Promise<string | null>\n probe: ProbeFactory\n now(): Date\n}\n\n/**\n * The §3.3 request set is 5 requests for a cold URL (robots.txt, agent, browser,\n * /llms.txt, /.well-known/ucp) and the probe does not cache across calls, so a\n * multi-URL run needs a budget proportional to the URL count. `createLimiter`'s\n * default of 20 is a floor chosen for a single-shot caller; raising it is\n * supposed to be a decision someone made on purpose, and this is that decision,\n * written down: six per URL (five plus the robots retry) and four of slack.\n */\nexport function budgetFor(urlCount: number): number {\n return Math.max(20, urlCount * 6 + 4)\n}\n\nfunction policyFor(setup: ProbeSetup, base: ProbePolicy): ProbePolicy {\n return { ...base, allowHttp: setup.allowHttp || base.allowHttp }\n}\n\n/**\n * The real probe factory. `probeStrict` for everything public; a dynamic import\n * of `./probe/local` when — and only when — `--allow-private` was typed.\n *\n * If that import throws, the message from the package is the one the user should\n * see (it explains the argv gate and the hosted-runtime refusal in its own\n * words), so it is re-thrown unchanged rather than summarised.\n */\nexport const nodeProbeFactory: ProbeFactory = async (setup) => {\n const limiter = createLimiter({ maxProbesPerRun: budgetFor(setup.urlCount) })\n\n if (!setup.allowPrivate) {\n const policy = policyFor(setup, strictPolicy(limiter))\n return (target) => probeStrict(target, policy)\n }\n\n const local = await import('@rebilder/agent-readability/probe/local')\n const policy = policyFor(setup, local.localPolicy(limiter))\n return (target) => local.probeLocal(target, policy)\n}\n\nexport function createNodeRuntime(): CliRuntime {\n return {\n env: process.env,\n cwd: process.cwd(),\n isTty: process.stdout.isTTY === true,\n columns: process.stdout.columns,\n write: (text) => process.stdout.write(text),\n writeError: (text) => process.stderr.write(text),\n writeFile: async (path, contents) => {\n await writeFile(resolvePath(process.cwd(), path), contents, 'utf8')\n },\n readFile: async (path) => {\n try {\n return await readFile(resolvePath(process.cwd(), path), 'utf8')\n } catch {\n return null\n }\n },\n probe: nodeProbeFactory,\n now: () => new Date(),\n }\n}\n"]}