rebilder 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +23 -14
- package/dist/bin.js +66 -18
- package/dist/bin.js.map +1 -1
- package/dist/index.d.ts +14 -7
- package/dist/index.js +66 -18
- package/dist/index.js.map +1 -1
- package/package.json +9 -4
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)
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
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.
|
|
132
|
+
declare const CLI_VERSION = "0.5.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
|
|
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;
|
|
@@ -436,6 +438,11 @@ declare const TELEMETRY_LINES: readonly string[];
|
|
|
436
438
|
* framework did they pick" would be exactly the telemetry the README says we do
|
|
437
439
|
* not collect, wearing a helpful hat.
|
|
438
440
|
*
|
|
441
|
+
* REPORTING IS WIRED IN THE GENERATED FILE, NOT IN THE CLI. The scaffold sends
|
|
442
|
+
* gateway events to the merchant's own Console from the merchant's server, and
|
|
443
|
+
* only once they set REBILDER_API_KEY. Leaving `onEvent` commented out meant
|
|
444
|
+
* free installs never reached a Console; the quickstart docs had the same bug.
|
|
445
|
+
*
|
|
439
446
|
* THE DETECTION IS PRINTED. Every scaffold says how it decided (`"next found in
|
|
440
447
|
* package.json dependencies"`), because a wrong guess with a visible reason is a
|
|
441
448
|
* thirty-second fix and a wrong guess with no reason is a bug report. `--framework`
|
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",
|
|
@@ -468,12 +466,26 @@ async function runInit(command, runtime) {
|
|
|
468
466
|
}
|
|
469
467
|
return { ...SCAFFOLDS[framework], framework, detection };
|
|
470
468
|
}
|
|
469
|
+
var INGEST_ORIGIN = "https://api.rebilder.com";
|
|
470
|
+
var CONSOLE_INSTALL_URL = "https://rebilder.com/console/install";
|
|
471
471
|
var SHARED_NOTES = [
|
|
472
472
|
"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
|
-
"The Apache-2.0 SDK serves without a Rebilder account or subscription.
|
|
474
|
-
|
|
473
|
+
"The Apache-2.0 SDK serves without a Rebilder account or subscription.",
|
|
474
|
+
`Reporting is wired in. Install \`@rebilder/events\`, create a free account, then set REBILDER_STORE_ID and REBILDER_API_KEY from ${CONSOLE_INSTALL_URL}. Without the key, nothing is sent.`,
|
|
475
|
+
`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
476
|
];
|
|
476
477
|
var CONFIG_BODY = `import type { GatewayConfig } from '@rebilder/gateway'
|
|
478
|
+
import { createHttpEventSink } from '@rebilder/events'
|
|
479
|
+
|
|
480
|
+
// Reports agent visits to your Rebilder Console. Free accounts include it.
|
|
481
|
+
// Copy both values from ${CONSOLE_INSTALL_URL} into your environment.
|
|
482
|
+
// Without REBILDER_API_KEY, nothing is sent.
|
|
483
|
+
const env = (name: string): string | undefined =>
|
|
484
|
+
(globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env?.[name]
|
|
485
|
+
const apiKey = env('REBILDER_API_KEY')
|
|
486
|
+
|
|
487
|
+
// Module scope, not per request: the sink batches (20 events, or every 2s).
|
|
488
|
+
const sink = apiKey ? createHttpEventSink({ url: '${INGEST_ORIGIN}', apiKey }) : null
|
|
477
489
|
|
|
478
490
|
/**
|
|
479
491
|
* Wiring to YOUR source of truth. Each resolver takes a URL and returns the
|
|
@@ -483,7 +495,7 @@ var CONFIG_BODY = `import type { GatewayConfig } from '@rebilder/gateway'
|
|
|
483
495
|
* call except a cache. Anything slower belongs in a build step.
|
|
484
496
|
*/
|
|
485
497
|
export const gatewayConfig: GatewayConfig = {
|
|
486
|
-
storeId: 'TODO-your-store-id',
|
|
498
|
+
storeId: env('REBILDER_STORE_ID') ?? 'TODO-your-store-id',
|
|
487
499
|
sources: {
|
|
488
500
|
// TODO: return your product fields, or null when the URL is not a PDP.
|
|
489
501
|
product: async (url) => {
|
|
@@ -492,8 +504,7 @@ export const gatewayConfig: GatewayConfig = {
|
|
|
492
504
|
},
|
|
493
505
|
// TODO: policies, catalog, document, collection \u2014 add the ones you have.
|
|
494
506
|
},
|
|
495
|
-
|
|
496
|
-
// onEvent: (event) => { void event },
|
|
507
|
+
onEvent: (event) => sink?.emit(event),
|
|
497
508
|
}
|
|
498
509
|
`;
|
|
499
510
|
function scaffold(suggestedPath, mount, notes) {
|
|
@@ -849,6 +860,20 @@ function statusOf(report) {
|
|
|
849
860
|
return report.kind === "rejected" ? "rejected" : report.result.outcome.kind;
|
|
850
861
|
}
|
|
851
862
|
|
|
863
|
+
// src/markdown-copy.ts
|
|
864
|
+
var NEGOTIATED_RESPONSE = "machine-representation.negotiated-response";
|
|
865
|
+
function markdownCopyOf(result) {
|
|
866
|
+
if (result.cost.negotiatedBytes !== null) return "page-address";
|
|
867
|
+
for (const dimension of result.dimensions) {
|
|
868
|
+
for (const check of dimension.checks) {
|
|
869
|
+
if (check.id === NEGOTIATED_RESPONSE) return check.earned > 0 ? "linked" : "none";
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
return "none";
|
|
873
|
+
}
|
|
874
|
+
var LINKED_COPY_NOTE = "Your linked Markdown copy works. Send it from the page address too for full credit.";
|
|
875
|
+
var LINKED_PARITY_NOTE = "This page does not send a Markdown copy itself. These facts come from the Markdown copy it links to.";
|
|
876
|
+
|
|
852
877
|
// src/format/json.ts
|
|
853
878
|
function renderJson(payload, ctx) {
|
|
854
879
|
return JSON.stringify(jsonValue(payload, ctx), null, 2) + "\n";
|
|
@@ -883,6 +908,10 @@ function jsonValue(payload, ctx) {
|
|
|
883
908
|
agent: payload.diff.agent,
|
|
884
909
|
browser: payload.diff.browser,
|
|
885
910
|
substanceParity: payload.diff.parity,
|
|
911
|
+
// Where the Markdown copy came from, so a consumer knows what the
|
|
912
|
+
// parity check compared: `page-address` (negotiation), `linked` (the
|
|
913
|
+
// copy the page links to, ARS 0.3), or `none`.
|
|
914
|
+
markdownCopy: payload.diff.result === null ? null : markdownCopyOf(payload.diff.result),
|
|
886
915
|
result: payload.diff.result
|
|
887
916
|
};
|
|
888
917
|
case "init":
|
|
@@ -1067,15 +1096,26 @@ function nextSteps(result) {
|
|
|
1067
1096
|
const missing = result.factProfile.core.filter((kind) => !found.has(kind));
|
|
1068
1097
|
const steps = [];
|
|
1069
1098
|
if (missing.length > 0) {
|
|
1070
|
-
steps.push(
|
|
1099
|
+
steps.push(
|
|
1100
|
+
`Check these business details: ${missing.join(", ")}. They were not detected in this capture (heuristic); verify the page before adding or changing content.`
|
|
1101
|
+
);
|
|
1071
1102
|
} else {
|
|
1072
|
-
steps.push(
|
|
1103
|
+
steps.push(
|
|
1104
|
+
"The expected core business details were detected (heuristic). Review their accuracy against your current products, services and policies."
|
|
1105
|
+
);
|
|
1073
1106
|
}
|
|
1074
1107
|
const first = result.recommendations[0];
|
|
1075
1108
|
if (first !== void 0) steps.push(`Start with: ${first.title}. ${first.detail}`);
|
|
1076
|
-
|
|
1077
|
-
steps.push(
|
|
1078
|
-
|
|
1109
|
+
const copy = markdownCopyOf(result);
|
|
1110
|
+
steps.push(
|
|
1111
|
+
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."
|
|
1112
|
+
);
|
|
1113
|
+
steps.push(
|
|
1114
|
+
"After updating your site, run rebilder check <url> again. Export --format markdown --out review.md to share the findings with your team."
|
|
1115
|
+
);
|
|
1116
|
+
steps.push(
|
|
1117
|
+
"This scan measures page readability; it does not measure customer demand, AI recommendations or sales."
|
|
1118
|
+
);
|
|
1079
1119
|
return steps;
|
|
1080
1120
|
}
|
|
1081
1121
|
|
|
@@ -1194,6 +1234,9 @@ function diffSection(diff) {
|
|
|
1194
1234
|
"Compared on price, currency, availability and title only \u2014 never description or free text.",
|
|
1195
1235
|
""
|
|
1196
1236
|
);
|
|
1237
|
+
if (diff.result !== null && markdownCopyOf(diff.result) === "linked") {
|
|
1238
|
+
out.push(LINKED_PARITY_NOTE, "");
|
|
1239
|
+
}
|
|
1197
1240
|
for (const evidence of diff.parity.evidence) {
|
|
1198
1241
|
out.push(
|
|
1199
1242
|
`- ${escapeCell(evidence.label)}: ${escapeCell(evidence.value)} (${basisLabel(evidence.basis)})`
|
|
@@ -1582,6 +1625,9 @@ function diffBlock(diff, pretty) {
|
|
|
1582
1625
|
"gray"
|
|
1583
1626
|
)
|
|
1584
1627
|
);
|
|
1628
|
+
if (diff.result !== null && markdownCopyOf(diff.result) === "linked") {
|
|
1629
|
+
lines.push(paint(` ${LINKED_PARITY_NOTE}`, "gray"));
|
|
1630
|
+
}
|
|
1585
1631
|
for (const evidence of diff.parity.evidence) {
|
|
1586
1632
|
lines.push(
|
|
1587
1633
|
` ${glyphs.bullet} ${evidence.label}: ${evidence.value} [${basisLabel(evidence.basis)}]`
|
|
@@ -1697,8 +1743,9 @@ var CHECK = `rebilder check <url...>
|
|
|
1697
1743
|
|
|
1698
1744
|
Probes each URL twice \u2014 an agent request and a browser control that differ in
|
|
1699
1745
|
the Accept header and in nothing else \u2014 plus /robots.txt, /llms.txt and
|
|
1700
|
-
/.well-known/ucp per origin.
|
|
1701
|
-
|
|
1746
|
+
/.well-known/ucp per origin. When the page does not send a Markdown copy but
|
|
1747
|
+
links one on the same site, that one copy is fetched too. Nothing else is
|
|
1748
|
+
requested. robots.txt is fetched first and obeyed.
|
|
1702
1749
|
|
|
1703
1750
|
OPTIONS
|
|
1704
1751
|
--format ${FORMATS.join("|")} default pretty
|
|
@@ -1724,7 +1771,8 @@ var DIFF = `rebilder diff <url>
|
|
|
1724
1771
|
|
|
1725
1772
|
Shows what the agent request received next to what the browser request
|
|
1726
1773
|
received: status, content type, decoded bytes, an estimated token count, and
|
|
1727
|
-
the D2.4 substance-parity comparison verbatim.
|
|
1774
|
+
the D2.4 substance-parity comparison verbatim. When the page links a Markdown
|
|
1775
|
+
copy instead of sending one, that comparison uses the linked copy.
|
|
1728
1776
|
|
|
1729
1777
|
It shows structure and numbers, never an excerpt of the page. --fail-on is not
|
|
1730
1778
|
supported: diff reports, it does not grade.
|
|
@@ -1777,7 +1825,7 @@ function helpText(topic) {
|
|
|
1777
1825
|
}
|
|
1778
1826
|
|
|
1779
1827
|
// src/cli.ts
|
|
1780
|
-
var CLI_VERSION = "0.
|
|
1828
|
+
var CLI_VERSION = "0.5.0";
|
|
1781
1829
|
async function runCli(argv, runtime) {
|
|
1782
1830
|
const caps = detectCapabilities({
|
|
1783
1831
|
env: runtime.env,
|
|
@@ -1853,7 +1901,7 @@ function buildProbe(runtime, urlCount, flags) {
|
|
|
1853
1901
|
});
|
|
1854
1902
|
}
|
|
1855
1903
|
function budgetFor(urlCount) {
|
|
1856
|
-
return Math.max(20, urlCount *
|
|
1904
|
+
return Math.max(20, urlCount * 7 + 4);
|
|
1857
1905
|
}
|
|
1858
1906
|
function policyFor(setup, base) {
|
|
1859
1907
|
return { ...base, allowHttp: setup.allowHttp || base.allowHttp };
|