rebilder 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -87,11 +87,13 @@ interface CliRuntime {
87
87
  }
88
88
  /**
89
89
  * The §3.3 request set is 5 requests for a cold URL (robots.txt, agent, browser,
90
- * /llms.txt, /.well-known/ucp) and the probe does not cache across calls, so a
91
- * multi-URL run needs a budget proportional to the URL count. `createLimiter`'s
92
- * default of 20 is a floor chosen for a single-shot caller; raising it is
93
- * supposed to be a decision someone made on purpose, and this is that decision,
94
- * written down: six per URL (five plus the robots retry) and four of slack.
90
+ * /llms.txt, /.well-known/ucp), plus one more since ARS 0.3 when the page links
91
+ * a Markdown copy instead of sending one. The probe does not cache across calls,
92
+ * so a multi-URL run needs a budget proportional to the URL count.
93
+ * `createLimiter`'s default of 20 is a floor chosen for a single-shot caller;
94
+ * raising it is supposed to be a decision someone made on purpose, and this is
95
+ * that decision, written down: seven per URL (six plus the robots retry) and
96
+ * four of slack.
95
97
  */
96
98
  declare function budgetFor(urlCount: number): number;
97
99
  /**
@@ -127,7 +129,7 @@ declare function createNodeRuntime(): CliRuntime;
127
129
  */
128
130
 
129
131
  /** Kept in step with package.json by a test, so a stale constant cannot ship. */
130
- declare const CLI_VERSION = "0.3.0";
132
+ declare const CLI_VERSION = "0.4.0";
131
133
  declare function runCli(argv: readonly string[], runtime: CliRuntime): Promise<ExitCode>;
132
134
 
133
135
  /**
@@ -413,7 +415,7 @@ declare function helpText(topic: CommandName | null): string;
413
415
  /**
414
416
  * Shared measurement context for CLI reports. The current formatters include
415
417
  * these lines; other interfaces can explain the scope through concise labels
416
- * and linked methodology (ARS 0.2 §0). Wording can evolve with the product.
418
+ * and linked methodology (ARS §0). Wording can evolve with the product.
417
419
  */
418
420
  declare const ARS_NOTICE_LINES: readonly string[];
419
421
  declare const ARS_NOTICE: string;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { parseArgs } from 'util';
2
- import { score } from '@rebilder/agent-readability';
2
+ import { DEFAULT_RULESET, score } from '@rebilder/agent-readability';
3
3
  import { readFile, writeFile } from 'fs/promises';
4
4
  import { resolve } from 'path';
5
5
  import { createLimiter, strictPolicy, probeStrict } from '@rebilder/agent-readability/probe';
@@ -335,8 +335,6 @@ function approxTokensOf(capture) {
335
335
  const characters = capture.body?.length ?? capture.bytes;
336
336
  return Math.round(characters / 4);
337
337
  }
338
-
339
- // src/commands/init.ts
340
338
  var FRAMEWORKS = [
341
339
  "next",
342
340
  "node",
@@ -471,7 +469,7 @@ async function runInit(command, runtime) {
471
469
  var SHARED_NOTES = [
472
470
  "The resolvers return your source of truth. Every substantive value \u2014 price, stock, hours, policy text \u2014 comes from these fields; the gateway never invents one.",
473
471
  "The Apache-2.0 SDK serves without a Rebilder account or subscription. Configure reporting separately.",
474
- "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."
472
+ `Run \`rebilder check <url>\` before and after to see what changed. Sending a Markdown copy from the page address is D2.1 (${DEFAULT_RULESET.weights["machine-representation.negotiated-response"] ?? 0} points) and unlocks D2.3 and D2.4.`
475
473
  ];
476
474
  var CONFIG_BODY = `import type { GatewayConfig } from '@rebilder/gateway'
477
475
 
@@ -849,6 +847,20 @@ function statusOf(report) {
849
847
  return report.kind === "rejected" ? "rejected" : report.result.outcome.kind;
850
848
  }
851
849
 
850
+ // src/markdown-copy.ts
851
+ var NEGOTIATED_RESPONSE = "machine-representation.negotiated-response";
852
+ function markdownCopyOf(result) {
853
+ if (result.cost.negotiatedBytes !== null) return "page-address";
854
+ for (const dimension of result.dimensions) {
855
+ for (const check of dimension.checks) {
856
+ if (check.id === NEGOTIATED_RESPONSE) return check.earned > 0 ? "linked" : "none";
857
+ }
858
+ }
859
+ return "none";
860
+ }
861
+ var LINKED_COPY_NOTE = "Your linked Markdown copy works. Send it from the page address too for full credit.";
862
+ var LINKED_PARITY_NOTE = "This page does not send a Markdown copy itself. These facts come from the Markdown copy it links to.";
863
+
852
864
  // src/format/json.ts
853
865
  function renderJson(payload, ctx) {
854
866
  return JSON.stringify(jsonValue(payload, ctx), null, 2) + "\n";
@@ -883,6 +895,10 @@ function jsonValue(payload, ctx) {
883
895
  agent: payload.diff.agent,
884
896
  browser: payload.diff.browser,
885
897
  substanceParity: payload.diff.parity,
898
+ // Where the Markdown copy came from, so a consumer knows what the
899
+ // parity check compared: `page-address` (negotiation), `linked` (the
900
+ // copy the page links to, ARS 0.3), or `none`.
901
+ markdownCopy: payload.diff.result === null ? null : markdownCopyOf(payload.diff.result),
886
902
  result: payload.diff.result
887
903
  };
888
904
  case "init":
@@ -1067,15 +1083,26 @@ function nextSteps(result) {
1067
1083
  const missing = result.factProfile.core.filter((kind) => !found.has(kind));
1068
1084
  const steps = [];
1069
1085
  if (missing.length > 0) {
1070
- steps.push(`Check these business details: ${missing.join(", ")}. They were not detected in this capture (heuristic); verify the page before adding or changing content.`);
1086
+ steps.push(
1087
+ `Check these business details: ${missing.join(", ")}. They were not detected in this capture (heuristic); verify the page before adding or changing content.`
1088
+ );
1071
1089
  } else {
1072
- steps.push("The expected core business details were detected (heuristic). Review their accuracy against your current products, services and policies.");
1090
+ steps.push(
1091
+ "The expected core business details were detected (heuristic). Review their accuracy against your current products, services and policies."
1092
+ );
1073
1093
  }
1074
1094
  const first = result.recommendations[0];
1075
1095
  if (first !== void 0) steps.push(`Start with: ${first.title}. ${first.detail}`);
1076
- steps.push(result.cost.negotiatedBytes === null ? "To connect your existing information, run rebilder init in your project. Review the generated configuration and connect your real data before deployment." : "Compare the two responses with rebilder diff <url> and confirm the same business facts reach customers and assistants.");
1077
- steps.push("After updating your site, run rebilder check <url> again. Export --format markdown --out review.md to share the findings with your team.");
1078
- steps.push("This scan measures page readability; it does not measure customer demand, AI recommendations or sales.");
1096
+ const copy = markdownCopyOf(result);
1097
+ steps.push(
1098
+ copy === "page-address" ? "Compare the two responses with rebilder diff <url> and confirm the same business facts reach customers and assistants." : copy === "linked" ? `${LINKED_COPY_NOTE} Run rebilder init in your project to set that up, then connect your real data before deployment.` : "To connect your existing information, run rebilder init in your project. Review the generated configuration and connect your real data before deployment."
1099
+ );
1100
+ steps.push(
1101
+ "After updating your site, run rebilder check <url> again. Export --format markdown --out review.md to share the findings with your team."
1102
+ );
1103
+ steps.push(
1104
+ "This scan measures page readability; it does not measure customer demand, AI recommendations or sales."
1105
+ );
1079
1106
  return steps;
1080
1107
  }
1081
1108
 
@@ -1194,6 +1221,9 @@ function diffSection(diff) {
1194
1221
  "Compared on price, currency, availability and title only \u2014 never description or free text.",
1195
1222
  ""
1196
1223
  );
1224
+ if (diff.result !== null && markdownCopyOf(diff.result) === "linked") {
1225
+ out.push(LINKED_PARITY_NOTE, "");
1226
+ }
1197
1227
  for (const evidence of diff.parity.evidence) {
1198
1228
  out.push(
1199
1229
  `- ${escapeCell(evidence.label)}: ${escapeCell(evidence.value)} (${basisLabel(evidence.basis)})`
@@ -1582,6 +1612,9 @@ function diffBlock(diff, pretty) {
1582
1612
  "gray"
1583
1613
  )
1584
1614
  );
1615
+ if (diff.result !== null && markdownCopyOf(diff.result) === "linked") {
1616
+ lines.push(paint(` ${LINKED_PARITY_NOTE}`, "gray"));
1617
+ }
1585
1618
  for (const evidence of diff.parity.evidence) {
1586
1619
  lines.push(
1587
1620
  ` ${glyphs.bullet} ${evidence.label}: ${evidence.value} [${basisLabel(evidence.basis)}]`
@@ -1697,8 +1730,9 @@ var CHECK = `rebilder check <url...>
1697
1730
 
1698
1731
  Probes each URL twice \u2014 an agent request and a browser control that differ in
1699
1732
  the Accept header and in nothing else \u2014 plus /robots.txt, /llms.txt and
1700
- /.well-known/ucp per origin. Nothing else is requested. robots.txt is fetched
1701
- first and obeyed.
1733
+ /.well-known/ucp per origin. When the page does not send a Markdown copy but
1734
+ links one on the same site, that one copy is fetched too. Nothing else is
1735
+ requested. robots.txt is fetched first and obeyed.
1702
1736
 
1703
1737
  OPTIONS
1704
1738
  --format ${FORMATS.join("|")} default pretty
@@ -1724,7 +1758,8 @@ var DIFF = `rebilder diff <url>
1724
1758
 
1725
1759
  Shows what the agent request received next to what the browser request
1726
1760
  received: status, content type, decoded bytes, an estimated token count, and
1727
- the D2.4 substance-parity comparison verbatim.
1761
+ the D2.4 substance-parity comparison verbatim. When the page links a Markdown
1762
+ copy instead of sending one, that comparison uses the linked copy.
1728
1763
 
1729
1764
  It shows structure and numbers, never an excerpt of the page. --fail-on is not
1730
1765
  supported: diff reports, it does not grade.
@@ -1777,7 +1812,7 @@ function helpText(topic) {
1777
1812
  }
1778
1813
 
1779
1814
  // src/cli.ts
1780
- var CLI_VERSION = "0.3.0";
1815
+ var CLI_VERSION = "0.4.0";
1781
1816
  async function runCli(argv, runtime) {
1782
1817
  const caps = detectCapabilities({
1783
1818
  env: runtime.env,
@@ -1853,7 +1888,7 @@ function buildProbe(runtime, urlCount, flags) {
1853
1888
  });
1854
1889
  }
1855
1890
  function budgetFor(urlCount) {
1856
- return Math.max(20, urlCount * 6 + 4);
1891
+ return Math.max(20, urlCount * 7 + 4);
1857
1892
  }
1858
1893
  function policyFor(setup, base) {
1859
1894
  return { ...base, allowHttp: setup.allowHttp || base.allowHttp };