@rebilder/agent-readability 0.2.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.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  // src/types.ts
4
- var ARS_SPEC_VERSION = "0.2.0";
4
+ var ARS_SPEC_VERSION = "0.3.0";
5
5
 
6
6
  // src/profiles.ts
7
7
  var PROFILE_BY_KIND = {
@@ -349,33 +349,61 @@ var ACTION_LEXICON = [
349
349
  "book now",
350
350
  "buy",
351
351
  "buy now",
352
+ "call",
352
353
  "call now",
354
+ "check availability",
355
+ "check out",
353
356
  "checkout",
354
357
  "contact",
355
358
  "contact us",
359
+ "create account",
360
+ "create an account",
356
361
  "donate",
357
362
  "download",
358
363
  "email us",
364
+ "enquire",
365
+ "enrol",
359
366
  "enroll",
367
+ "free trial",
368
+ "get a demo",
360
369
  "get a quote",
370
+ "get directions",
371
+ "get in touch",
361
372
  "get quote",
362
373
  "get started",
374
+ "get the app",
375
+ "get tickets",
376
+ "hire",
377
+ "inquire",
378
+ "install",
363
379
  "join",
364
380
  "make an appointment",
381
+ "message us",
365
382
  "order",
366
383
  "order now",
384
+ "order online",
385
+ "pre-order",
386
+ "preorder",
367
387
  "purchase",
368
388
  "register",
389
+ "rent",
369
390
  "request",
370
391
  "request a demo",
371
392
  "request a quote",
372
393
  "reserve",
373
394
  "schedule",
395
+ "shop",
396
+ "shop now",
374
397
  "sign up",
375
398
  "signup",
376
399
  "start",
377
400
  "start free trial",
378
- "subscribe"
401
+ "subscribe",
402
+ "talk to sales",
403
+ "talk to us",
404
+ "text us",
405
+ "try",
406
+ "upgrade"
379
407
  ];
380
408
  var BANDS = [
381
409
  {
@@ -415,7 +443,7 @@ var BANDS = [
415
443
  }
416
444
  ];
417
445
  var DEFAULT_RULESET = deepFreeze({
418
- version: "0.2.0",
446
+ version: "0.3.0",
419
447
  weights: WEIGHTS,
420
448
  thresholds: THRESHOLDS,
421
449
  audienceTokens: AUDIENCE_TOKENS,
@@ -2782,7 +2810,15 @@ var TEMPLATES = [
2782
2810
  effort: "config",
2783
2811
  detail: "Return Markdown, plain text or JSON with a matching Content-Type when the request asks for one, and keep the same URL. This is the single largest recoverable block in ARS, and it is also what makes Vary: Accept and the substance-parity check scoreable at all.",
2784
2812
  checks: ["machine-representation.negotiated-response"],
2785
- unlocks: (state) => earnedOf(state, "machine-representation.negotiated-response") === 0 ? ["machine-representation.vary-accept", "machine-representation.substance-parity"] : []
2813
+ // Vary is gated on negotiation itself, so it stays locked while D2.1 is
2814
+ // short of full, including the ARS 0.3 partial credit for a linked copy.
2815
+ // Parity also opens on a linked copy, so it is unlocked only from zero.
2816
+ unlocks: (state) => {
2817
+ const earned = earnedOf(state, "machine-representation.negotiated-response");
2818
+ const full = state.get("machine-representation.negotiated-response")?.weight ?? 0;
2819
+ if (earned >= full) return [];
2820
+ return earned === 0 ? ["machine-representation.vary-accept", "machine-representation.substance-parity"] : ["machine-representation.vary-accept"];
2821
+ }
2786
2822
  },
2787
2823
  {
2788
2824
  id: "declare-alternates",
@@ -3041,8 +3077,14 @@ var SUBPOINTS = deepFreeze2({
3041
3077
  band: [100, 7, 75, 5, 50, 3, 25, 1],
3042
3078
  noscriptFloor: 1
3043
3079
  },
3044
- /** D2.1, 9. All-or-nothing: a machine media type AND a body that is not HTML. */
3045
- negotiatedResponse: { full: 9 },
3080
+ /**
3081
+ * D2.1, 9 for a machine copy served at the page's own address on `Accept`
3082
+ * negotiation: a machine media type AND a body that is not HTML. ARS 0.3: 6
3083
+ * when the page does not negotiate but the Markdown copy it declares as an
3084
+ * alternate was fetched and is real. Less than full because only agents that
3085
+ * look for the link reach it, and they pay a second request to do so.
3086
+ */
3087
+ negotiatedResponse: { full: 9, linkedCopy: 6 },
3046
3088
  /** D2.2, 3. All-or-nothing. */
3047
3089
  declaredAlternates: { full: 3 },
3048
3090
  /** D2.3, 3. All-or-nothing, and 0 unless D2.1 > 0. */
@@ -3251,12 +3293,14 @@ function evidenceHash(evidence) {
3251
3293
  parityConfirm: redactProbe(evidence.probes.parityConfirm),
3252
3294
  robotsTxt: redactProbe(evidence.probes.robotsTxt),
3253
3295
  llmsTxt: redactProbe(evidence.probes.llmsTxt),
3254
- wellKnownUcp: redactProbe(evidence.probes.wellKnownUcp)
3296
+ wellKnownUcp: redactProbe(evidence.probes.wellKnownUcp),
3297
+ // ARS 0.3, and only when present, so a 0.2 bundle hashes as it did.
3298
+ ...evidence.probes.markdownAlternate === void 0 ? {} : { markdownAlternate: redactProbe(evidence.probes.markdownAlternate) }
3255
3299
  }
3256
3300
  })
3257
3301
  );
3258
3302
  }
3259
- var ARS_CORPUS_HASH = sha256Hex("ars-0.2-corpus-unfrozen");
3303
+ var ARS_CORPUS_HASH = sha256Hex("ars-0.3-corpus-unfrozen");
3260
3304
  function parseLinkHeaders(values) {
3261
3305
  const out = [];
3262
3306
  for (const value of values) {
@@ -3318,6 +3362,51 @@ function measured(label, value) {
3318
3362
  function heuristic(label, value) {
3319
3363
  return { label, value, basis: "heuristic" };
3320
3364
  }
3365
+ var FACT_NAMES = {
3366
+ title: "name or title",
3367
+ description: "description",
3368
+ updated: "last-updated date",
3369
+ published: "publish date",
3370
+ price: "price",
3371
+ currency: "currency",
3372
+ availability: "availability",
3373
+ brand: "brand",
3374
+ sku: "SKU",
3375
+ shipping: "shipping details",
3376
+ returns: "returns policy",
3377
+ "org-name": "business name",
3378
+ address: "address",
3379
+ hours: "opening hours",
3380
+ phone: "phone number",
3381
+ email: "email address",
3382
+ "service-area": "service area",
3383
+ author: "author",
3384
+ section: "section",
3385
+ authority: "publisher",
3386
+ "primary-action-url": "main action link (such as Buy, Book, Contact or Install)",
3387
+ eligibility: "eligibility",
3388
+ duration: "duration",
3389
+ "question-answer": "questions and answers",
3390
+ "item-count": "number of items",
3391
+ "item-link": "links to the items"
3392
+ };
3393
+ function factName(kind) {
3394
+ return FACT_NAMES[kind] ?? kind;
3395
+ }
3396
+ function factList(kinds) {
3397
+ return kinds.map(factName).join(", ");
3398
+ }
3399
+ function plainBytes(bytes) {
3400
+ if (bytes < 1024) return `${bytes} bytes`;
3401
+ return `${divRoundHalfUp(bytes, 1024)} KB`;
3402
+ }
3403
+ var ROBOTS_STATUS = {
3404
+ ok: "found",
3405
+ missing: "not found (nothing is blocked)",
3406
+ error: "the server returned an error",
3407
+ unparseable: "found, but it could not be read"
3408
+ };
3409
+ var COUNTS_ONCE_COPY = "only once the page sends AI assistants a Markdown copy, so 0 for now";
3321
3410
  function checkReachable(context) {
3322
3411
  const { agentCapture, browserCapture, ruleset } = context;
3323
3412
  const split = SUBPOINTS.reachable;
@@ -3327,17 +3416,17 @@ function checkReachable(context) {
3327
3416
  const sameFinalUrl = browserCapture !== null && browserCapture.finalUrl === agentCapture.finalUrl;
3328
3417
  const earned = (status2xx ? split.status2xx : 0) + (withinLimit ? split.withinRedirectLimit : 0) + (sameFinalUrl ? split.noAcceptConditionalRedirect : 0);
3329
3418
  const evidence = [
3330
- measured("HTTP status on the agent path", String(agentCapture.status)),
3331
- measured("Redirect hops", `${hops} (limit ${ruleset.maxRedirects})`),
3419
+ measured("Status code AI assistants got", String(agentCapture.status)),
3420
+ measured("Redirects on the way", `${hops} (up to ${ruleset.maxRedirects} allowed)`),
3332
3421
  measured(
3333
- "Both probes resolved to the same URL",
3334
- browserCapture === null ? "not comparable \u2014 no browser-control capture in this bundle" : yesNo(sameFinalUrl)
3422
+ "Same address for AI assistants and browsers",
3423
+ browserCapture === null ? "not checked, because this scan has no browser request to compare" : yesNo(sameFinalUrl)
3335
3424
  )
3336
3425
  ];
3337
3426
  return sameFinalUrl ? { earned, evidence } : {
3338
3427
  earned,
3339
3428
  evidence,
3340
- remedy: "Serve the same URL to both Accept headers. An Accept-conditional redirect sends the agent somewhere the browser never goes, and caches key on the URL."
3429
+ remedy: "Send AI assistants and browsers to the same address. A redirect that depends on the Accept header sends assistants to a page browsers never see."
3341
3430
  };
3342
3431
  }
3343
3432
  function checkRobotsPolicy(context) {
@@ -3346,21 +3435,22 @@ function checkRobotsPolicy(context) {
3346
3435
  const decision = policy.audiences.assistant;
3347
3436
  const parsesClean = robots === null || robots.malformedLines === 0;
3348
3437
  const noOrphanRules = robots === null || robots.orphanRules === 0;
3438
+ const rule = decision.matchedGroup === null ? "" : ` (User-agent: ${decision.matchedGroup}${decision.matchedRule === null ? "" : `, ${decision.matchedRule}`})`;
3349
3439
  const evidence = [
3350
- measured("robots.txt", policy.robotsTxtStatus),
3440
+ measured("robots.txt", ROBOTS_STATUS[policy.robotsTxtStatus]),
3351
3441
  measured(
3352
- "Assistant audience",
3353
- decision.matchedGroup === null ? `${decision.decision} (no matching group)` : `${decision.decision} via User-agent: ${decision.matchedGroup}${decision.matchedRule === null ? "" : ` / ${decision.matchedRule}`}`
3442
+ "AI assistants allowed",
3443
+ decision.decision === "disallow" ? `no${rule}` : decision.matchedGroup === null ? "yes, no rule mentions them" : `yes${rule}`
3354
3444
  ),
3355
- measured("Malformed lines", robots === null ? "n/a" : String(robots.malformedLines)),
3445
+ measured("Lines that could not be read", robots === null ? "none" : String(robots.malformedLines)),
3356
3446
  measured(
3357
- "Rules before any User-agent line",
3358
- robots === null ? "n/a" : String(robots.orphanRules)
3447
+ "Rules outside a User-agent group",
3448
+ robots === null ? "none" : String(robots.orphanRules)
3359
3449
  ),
3360
- measured("Sitemap: declared", yesNo(policy.sitemapDeclared)),
3450
+ measured("Sitemap listed", yesNo(policy.sitemapDeclared)),
3361
3451
  measured(
3362
- "Training-crawler policy (never scored)",
3363
- policy.trainingOptOut ? "blocked \u2014 neutral, no effect on this score" : "allowed"
3452
+ "AI training crawlers",
3453
+ policy.trainingOptOut ? "blocked, which does not affect this score" : "allowed"
3364
3454
  )
3365
3455
  ];
3366
3456
  if (decision.decision === "disallow") {
@@ -3368,20 +3458,20 @@ function checkRobotsPolicy(context) {
3368
3458
  id: "robots-contradiction",
3369
3459
  severity: "warn",
3370
3460
  basis: "measured",
3371
- message: "robots.txt disallows assistant crawlers through a group that does not name one, so it reads as a blanket rule rather than a deliberate choice. Assistant traffic is blocked as a side effect.",
3372
- evidence: [evidence[1] ?? measured("Assistant audience", decision.decision)]
3461
+ message: "Your robots.txt blocks AI assistants with a rule written for all crawlers. That looks accidental, and it keeps assistants out.",
3462
+ evidence: [evidence[1] ?? measured("AI assistants allowed", "no")]
3373
3463
  });
3374
3464
  return {
3375
3465
  earned: 0,
3376
3466
  evidence,
3377
- remedy: "Name the assistant crawlers you mean to allow or block in their own robots.txt group. A blanket disallow blocks assistant fetches that users triggered on purpose."
3467
+ remedy: "Your robots.txt blocks AI assistants with a rule meant for all crawlers. If you want assistants to read your pages, give them their own group that allows them, such as ChatGPT-User and Claude-User."
3378
3468
  };
3379
3469
  }
3380
3470
  const earned = split.assistantAllowed + (parsesClean ? split.parsesClean : 0) + (noOrphanRules ? split.noOrphanRules : 0) + (policy.sitemapDeclared ? split.sitemapDeclared : 0);
3381
3471
  return {
3382
3472
  earned,
3383
3473
  evidence,
3384
- remedy: policy.sitemapDeclared ? void 0 : "Add a `Sitemap:` line to robots.txt. It is the one place an agent looks to find the rest of the site."
3474
+ remedy: policy.sitemapDeclared ? void 0 : "Add a `Sitemap:` line to robots.txt so assistants can find the rest of your pages."
3385
3475
  };
3386
3476
  }
3387
3477
  function checkRenderIndependence(context) {
@@ -3391,7 +3481,7 @@ function checkRenderIndependence(context) {
3391
3481
  if (structural === null || structural.doc === null) {
3392
3482
  return {
3393
3483
  earned: 0,
3394
- evidence: [heuristic("HTML representation", "none in this bundle \u2014 not evaluated")]
3484
+ evidence: [heuristic("HTML page", "not checked, because no HTML was returned")]
3395
3485
  };
3396
3486
  }
3397
3487
  const found = /* @__PURE__ */ new Set();
@@ -3412,42 +3502,143 @@ function checkRenderIndependence(context) {
3412
3502
  id: "render-dependent",
3413
3503
  severity: "info",
3414
3504
  basis: "heuristic",
3415
- message: `${found.size} of ${coreSize} core facts for this page kind were present in the HTML without running JavaScript. A caller that does not execute scripts sees the rest as missing.`,
3416
- evidence: [heuristic("Core facts in the served HTML", `${found.size}/${coreSize}`)]
3505
+ message: `${found.size} of ${coreSize} key facts for this kind of page were in the HTML before any JavaScript ran. An assistant that does not run scripts sees the rest as missing.`,
3506
+ evidence: [heuristic("Key facts in the HTML", `${found.size} of ${coreSize}`)]
3417
3507
  });
3418
3508
  }
3419
3509
  return {
3420
3510
  earned,
3421
3511
  evidence: [
3422
- heuristic("Core facts present without JavaScript", `${found.size}/${coreSize}`),
3423
- heuristic("<noscript> fallback with content", yesNo(hasNoscript)),
3512
+ heuristic("Key facts in the HTML before JavaScript runs", `${found.size} of ${coreSize}`),
3513
+ heuristic("Fallback text for visitors without JavaScript", yesNo(hasNoscript)),
3424
3514
  heuristic(
3425
- "Basis",
3426
- "inferred \u2014 ARS never executes JavaScript, so this measures the served HTML, not what a browser would render"
3515
+ "How we checked",
3516
+ "we read the HTML your server sends and do not run JavaScript, so facts added by scripts count as missing"
3427
3517
  )
3428
3518
  ],
3429
- remedy: earned === full ? void 0 : "Render the core facts for this page kind into the HTML the server sends. Agents do not run your JavaScript."
3519
+ remedy: earned === full ? void 0 : "Put the key facts in the HTML your server sends. Most AI assistants do not run JavaScript, so facts added by scripts are invisible to them."
3430
3520
  };
3431
3521
  }
3432
3522
  var MACHINE_KINDS = /* @__PURE__ */ new Set(["markdown", "text", "json"]);
3523
+ function isMachineCopy(capture) {
3524
+ const representation = buildRepresentation(capture);
3525
+ return representation !== null && MACHINE_KINDS.has(representation.kind) && !representation.looksLikeHtml;
3526
+ }
3527
+ var MARKDOWN_MEDIA = /* @__PURE__ */ new Set(["text/markdown", "text/x-markdown"]);
3528
+ function isMarkdownType(type) {
3529
+ return type !== null && MARKDOWN_MEDIA.has((type.split(";")[0] ?? "").trim().toLowerCase());
3530
+ }
3531
+ function declaredMarkdownAlternates(captures) {
3532
+ const out = [];
3533
+ const add = (raw, base) => {
3534
+ try {
3535
+ const url = new URL(raw, base);
3536
+ url.hash = "";
3537
+ const href = url.toString();
3538
+ if (!out.includes(href)) out.push(href);
3539
+ } catch {
3540
+ }
3541
+ };
3542
+ for (const capture of captures) {
3543
+ if (capture === null) continue;
3544
+ for (const link of parseLinkHeaders(headerAll(capture.headers, "link"))) {
3545
+ if (link.rel.includes("alternate") && isMarkdownType(link.type)) add(link.url, capture.finalUrl);
3546
+ }
3547
+ }
3548
+ for (const capture of captures) {
3549
+ if (capture === null) continue;
3550
+ const representation = buildRepresentation(capture);
3551
+ if (representation === null || representation.doc === null) continue;
3552
+ for (const link of representation.doc.links) {
3553
+ if (!link.rel.includes("alternate") || link.href === null) continue;
3554
+ if (isMarkdownType(link.type)) add(link.href, capture.finalUrl);
3555
+ }
3556
+ }
3557
+ return out;
3558
+ }
3559
+ function markdownAlternateTarget(agent, browser, origin) {
3560
+ if (agent === null || agent.status < 200 || agent.status >= 300) return null;
3561
+ if (isMachineCopy(agent)) return null;
3562
+ const own = /* @__PURE__ */ new Set([agent.finalUrl, agent.requestedUrl]);
3563
+ for (const href of declaredMarkdownAlternates([browser, agent])) {
3564
+ let sameOrigin = false;
3565
+ try {
3566
+ sameOrigin = new URL(href).origin === origin;
3567
+ } catch {
3568
+ sameOrigin = false;
3569
+ }
3570
+ if (sameOrigin && !own.has(href)) return href;
3571
+ }
3572
+ return null;
3573
+ }
3574
+ function linkedCopyOf(evidence, agent, browser) {
3575
+ const url = markdownAlternateTarget(agent, browser, evidence.target.origin);
3576
+ if (url === null) return null;
3577
+ const record = evidence.probes.markdownAlternate ?? null;
3578
+ if (record === null) return { url, status: "unchecked", representation: null, reason: null };
3579
+ if (!record.result.ok) {
3580
+ if (record.result.error === "policy-rejected") {
3581
+ return { url, status: "unchecked", representation: null, reason: null };
3582
+ }
3583
+ return { url, status: "broken", representation: null, reason: record.result.error };
3584
+ }
3585
+ const capture = record.result.capture;
3586
+ if (capture.requestedUrl !== url) {
3587
+ return { url, status: "unchecked", representation: null, reason: null };
3588
+ }
3589
+ if (capture.status < 200 || capture.status >= 300) {
3590
+ return { url, status: "broken", representation: null, reason: `HTTP ${capture.status}` };
3591
+ }
3592
+ if (!isMachineCopy(capture)) {
3593
+ return { url, status: "broken", representation: null, reason: "it returned HTML, not Markdown" };
3594
+ }
3595
+ return { url, status: "checked", representation: buildRepresentation(capture), reason: null };
3596
+ }
3597
+ var MEDIA_NAMES = {
3598
+ "text/markdown": "Markdown",
3599
+ "text/x-markdown": "Markdown",
3600
+ "text/html": "HTML",
3601
+ "text/plain": "plain text",
3602
+ "application/json": "JSON",
3603
+ "*/*": "anything else"
3604
+ };
3605
+ function acceptSummary(accept) {
3606
+ const names = [];
3607
+ for (const entry of accept.split(",")) {
3608
+ const type = (entry.split(";")[0] ?? "").trim().toLowerCase();
3609
+ if (type === "") continue;
3610
+ const name = MEDIA_NAMES[type] ?? type;
3611
+ if (!names.includes(name)) names.push(name);
3612
+ }
3613
+ const [first, ...rest] = names;
3614
+ if (first === void 0) return accept;
3615
+ return rest.length === 0 ? first : `${first} first, then ${rest.join(", ")}`;
3616
+ }
3433
3617
  function checkNegotiatedResponse(context) {
3434
- const { agent } = context;
3618
+ const { agent, linkedCopy } = context;
3435
3619
  const typeIsMachine = MACHINE_KINDS.has(agent.kind);
3436
3620
  const bodyIsHtml = agent.looksLikeHtml;
3437
- const earned = typeIsMachine && !bodyIsHtml ? SUBPOINTS.negotiatedResponse.full : 0;
3621
+ const linkedWorks = linkedCopy !== null && linkedCopy.status === "checked";
3622
+ const earned = context.negotiated ? SUBPOINTS.negotiatedResponse.full : linkedWorks ? SUBPOINTS.negotiatedResponse.linkedCopy : 0;
3623
+ const asked = context.evidence.probes.agent.requestHeaders["accept"] ?? context.evidence.probes.agent.requestHeaders["Accept"] ?? null;
3438
3624
  return {
3439
3625
  earned,
3440
3626
  evidence: [
3441
- measured("Content-Type on the agent probe", agent.contentType ?? "absent"),
3442
- measured("Body is HTML", yesNo(bodyIsHtml)),
3443
- measured(
3444
- "Request Accept header",
3445
- context.evidence.probes.agent.requestHeaders["accept"] ?? context.evidence.probes.agent.requestHeaders["Accept"] ?? "not recorded"
3446
- )
3627
+ measured("We asked for", asked === null ? "not recorded" : acceptSummary(asked)),
3628
+ measured("Format we got", agent.contentType ?? "not stated"),
3629
+ measured("Content was HTML", yesNo(bodyIsHtml)),
3630
+ ...linkedCopy === null ? [] : [measured("Linked Markdown copy", linkedCopyLine(linkedCopy))]
3447
3631
  ],
3448
- remedy: earned > 0 ? void 0 : typeIsMachine ? "The response declared a machine media type but the body is HTML. Send the representation the Content-Type promises." : "Return a machine representation \u2014 Markdown, plain text or JSON \u2014 when the request Accept header asks for one, with a matching Content-Type."
3632
+ remedy: context.negotiated ? void 0 : linkedWorks ? "Your linked Markdown copy works. For full credit, also send it from the page address when an AI assistant asks for Markdown, so assistants get it without a second request." : typeIsMachine ? "Your server labels this response as Markdown, text or JSON but sends HTML. Send the format the Content-Type header names." : "When an AI assistant asks for Markdown, answer from the same address with a Markdown copy of the page and `Content-Type: text/markdown`. Assistants get your facts without the menus, scripts and styling, which are usually most of the page."
3449
3633
  };
3450
3634
  }
3635
+ function linkedCopyLine(copy) {
3636
+ if (copy.status === "checked") {
3637
+ return `loaded as Markdown from ${copy.url} (${plainBytes(copy.representation?.bytes ?? 0)})`;
3638
+ }
3639
+ if (copy.status === "broken") return `did not load as Markdown from ${copy.url} (${copy.reason ?? "error"})`;
3640
+ return `linked at ${copy.url}, not checked in this scan`;
3641
+ }
3451
3642
  function checkDeclaredAlternates(context) {
3452
3643
  const { agentCapture, browserCapture, structural } = context;
3453
3644
  const links = parseLinkHeaders([
@@ -3462,45 +3653,54 @@ function checkDeclaredAlternates(context) {
3462
3653
  for (const link of structural.doc.links) {
3463
3654
  if (!link.rel.includes("alternate")) continue;
3464
3655
  if (link.type === null || link.href === null) continue;
3465
- documentAlternates.push(`${link.type} \u2192 ${link.href}`);
3656
+ documentAlternates.push(`${link.type} at ${link.href}`);
3466
3657
  }
3467
3658
  }
3468
3659
  const total = headerAlternates.length + documentAlternates.length;
3660
+ const broken = context.linkedCopy !== null && context.linkedCopy.status === "broken";
3661
+ if (broken && context.linkedCopy !== null) {
3662
+ return {
3663
+ earned: 0,
3664
+ evidence: [measured("Linked Markdown copy", linkedCopyLine(context.linkedCopy))],
3665
+ remedy: `The Markdown copy this page links to did not load (${context.linkedCopy.reason ?? "error"}). Fix the file or the link.`
3666
+ };
3667
+ }
3469
3668
  return {
3470
3669
  earned: total > 0 ? SUBPOINTS.declaredAlternates.full : 0,
3471
3670
  evidence: [
3472
3671
  measured(
3473
- 'Link: rel="alternate" (typed)',
3474
- headerAlternates.length === 0 ? "none" : headerAlternates.map((link) => `${link.type ?? "?"} \u2192 ${link.url}`).join(", ")
3672
+ "Link header pointing to the Markdown copy",
3673
+ headerAlternates.length === 0 ? "none" : headerAlternates.map((link) => `${link.type ?? "?"} at ${link.url}`).join(", ")
3475
3674
  ),
3476
3675
  measured(
3477
- '<link rel="alternate"> (typed)',
3676
+ "Link tag in the page pointing to the Markdown copy",
3478
3677
  documentAlternates.length === 0 ? "none" : documentAlternates.join(", ")
3479
3678
  )
3480
3679
  ],
3481
- remedy: total > 0 ? void 0 : 'Declare the machine representation: `Link: <\u2026>; rel="alternate"; type="text/markdown"` or a `<link rel="alternate">` in the HTML. An endpoint an agent cannot find is an endpoint that does not exist.'
3680
+ remedy: total > 0 ? void 0 : 'Tell assistants where the Markdown copy is. Add `<link rel="alternate" type="text/markdown" href="\u2026">` to the page, or send the same thing as a `Link` header.'
3482
3681
  };
3483
3682
  }
3484
- function checkVaryAccept(context, negotiated) {
3683
+ function checkVaryAccept(context) {
3684
+ const negotiated = context.negotiated;
3485
3685
  const { agentCapture, browserCapture } = context;
3486
3686
  const agentVary = headerTokens(header(agentCapture.headers, "vary"));
3487
3687
  const browserVary = browserCapture === null ? [] : headerTokens(header(browserCapture.headers, "vary"));
3488
3688
  const declared = agentVary.includes("accept") || browserVary.includes("accept");
3489
3689
  const evidence = [
3490
- measured("Vary on the agent response", header(agentCapture.headers, "vary") ?? "absent"),
3690
+ measured("Vary header sent to AI assistants", header(agentCapture.headers, "vary") ?? "not sent"),
3491
3691
  measured(
3492
- "Vary on the browser response",
3493
- browserCapture === null ? "no browser capture" : header(browserCapture.headers, "vary") ?? "absent"
3692
+ "Vary header sent to browsers",
3693
+ browserCapture === null ? "not checked" : header(browserCapture.headers, "vary") ?? "not sent"
3494
3694
  )
3495
3695
  ];
3496
- if (negotiated === 0) {
3696
+ if (!negotiated) {
3497
3697
  return {
3498
3698
  earned: 0,
3499
3699
  evidence: [
3500
3700
  ...evidence,
3501
3701
  measured(
3502
- "Scored",
3503
- "no \u2014 this check is 0 unless a machine representation was served (D2.1)"
3702
+ "Counts",
3703
+ context.linkedCopy?.status === "checked" ? "only when the page address itself sends the Markdown copy, so 0 for now" : COUNTS_ONCE_COPY
3504
3704
  )
3505
3705
  ]
3506
3706
  };
@@ -3510,17 +3710,27 @@ function checkVaryAccept(context, negotiated) {
3510
3710
  id: "vary-missing",
3511
3711
  severity: "warn",
3512
3712
  basis: "measured",
3513
- message: "The same URL returns different representations by Accept but does not send `Vary: Accept`. A shared cache can serve the Markdown to a browser, or the HTML to an agent.",
3713
+ message: "This address sends the Markdown copy or the HTML depending on what is asked for, but does not send `Vary: Accept`. A shared cache can hand the Markdown to a shopper, or the HTML to an assistant.",
3514
3714
  evidence
3515
3715
  });
3516
3716
  }
3517
3717
  return {
3518
3718
  earned: declared ? SUBPOINTS.varyAccept.full : 0,
3519
3719
  evidence,
3520
- remedy: declared ? void 0 : "Send `Vary: Accept` on every response from a URL that negotiates on Accept."
3720
+ remedy: declared ? void 0 : "Send `Vary: Accept` on every response from an address that serves a Markdown copy, so caches keep the two versions apart."
3521
3721
  };
3522
3722
  }
3523
3723
  var PARITY_KINDS = ["price", "currency", "availability", "title"];
3724
+ function linkedCopyFacts(context, copy) {
3725
+ if (copy.representation === null) return [];
3726
+ return extractFacts(copy.representation, {
3727
+ profile: context.profile,
3728
+ ruleset: context.ruleset,
3729
+ baseUrl: copy.representation.finalUrl,
3730
+ origin: context.evidence.target.origin,
3731
+ currencyHint: currencyHintOf(context.structural, context.agent)
3732
+ });
3733
+ }
3524
3734
  function factView(facts) {
3525
3735
  const best = /* @__PURE__ */ new Map();
3526
3736
  const observed = /* @__PURE__ */ new Map();
@@ -3556,48 +3766,48 @@ function divergentKinds(left, right, kinds) {
3556
3766
  }
3557
3767
  return { compared, divergent };
3558
3768
  }
3559
- function checkSubstanceParity(context, negotiated) {
3769
+ function checkSubstanceParity(context) {
3560
3770
  const { agentFacts, browserFacts, browser, evidence: bundle } = context;
3561
- if (negotiated === 0 || browser === null) {
3771
+ const linked = !context.negotiated && context.linkedCopy?.status === "checked" ? context.linkedCopy : null;
3772
+ const htmlFacts = browser !== null ? browserFacts : agentFacts;
3773
+ if (!context.negotiated && linked === null || linked === null && browser === null) {
3562
3774
  return {
3563
3775
  earned: 0,
3564
3776
  evidence: [
3565
3777
  heuristic(
3566
- "Comparable",
3567
- negotiated === 0 ? "no \u2014 there is one representation, so there is nothing to compare (this is the designed 84-point ceiling for a page with no content negotiation)" : "no \u2014 no browser-control capture in this bundle"
3778
+ "Counts",
3779
+ !context.negotiated ? COUNTS_ONCE_COPY : "not checked, because this scan has no browser request to compare"
3568
3780
  )
3569
3781
  ]
3570
3782
  };
3571
3783
  }
3572
- const agentValues = factView(agentFacts);
3573
- const browserValues = factView(browserFacts);
3784
+ const agentValues = factView(linked === null ? agentFacts : linkedCopyFacts(context, linked));
3785
+ const browserValues = factView(linked === null ? browserFacts : htmlFacts);
3574
3786
  const { compared, divergent } = divergentKinds(agentValues, browserValues, PARITY_KINDS);
3575
3787
  const evidenceLines = [
3576
3788
  heuristic(
3577
- "Compared facts",
3578
- compared.length === 0 ? "none present in both representations" : compared.join(", ")
3789
+ "Facts compared",
3790
+ compared.length === 0 ? "none appear in both the Markdown copy and the page" : factList(compared)
3579
3791
  ),
3580
- heuristic(
3581
- "Values",
3582
- divergent.length === 0 ? "agree" : divergent.map((entry) => `${entry.kind}: agent ${entry.left} / HTML ${entry.right}`).join("; ")
3583
- )
3792
+ ...compared.length === 0 ? [] : [
3793
+ heuristic(
3794
+ "Values",
3795
+ divergent.length === 0 ? "match" : divergent.map(
3796
+ (entry) => `${factName(entry.kind)}: Markdown copy ${entry.left}, page ${entry.right}`
3797
+ ).join("; ")
3798
+ )
3799
+ ]
3584
3800
  ];
3585
3801
  if (compared.length === 0) {
3586
3802
  return {
3587
3803
  earned: 0,
3588
- evidence: [
3589
- ...evidenceLines,
3590
- heuristic(
3591
- "Scored",
3592
- "no \u2014 a comparison needs at least one comparable fact in both representations"
3593
- )
3594
- ],
3595
- remedy: "State the same core facts in both representations. ARS could not compare them, so it could not award the parity points."
3804
+ evidence: evidenceLines,
3805
+ remedy: "State the same key facts, such as name and price, in the Markdown copy and in the page, so the two can be checked against each other."
3596
3806
  };
3597
3807
  }
3598
3808
  if (divergent.length === 0)
3599
3809
  return { earned: SUBPOINTS.substanceParity.full, evidence: evidenceLines };
3600
- const confirm = bundle.probes.parityConfirm;
3810
+ const confirm = linked === null ? bundle.probes.parityConfirm : null;
3601
3811
  const confirmCapture = confirm !== null && confirm.result.ok ? confirm.result.capture : null;
3602
3812
  const confirmRep = confirmCapture === null ? null : buildRepresentation(confirmCapture);
3603
3813
  if (confirmRep === null) {
@@ -3605,9 +3815,9 @@ function checkSubstanceParity(context, negotiated) {
3605
3815
  earned: 0,
3606
3816
  evidence: [
3607
3817
  ...evidenceLines,
3608
- heuristic("Confirming probe", "absent \u2014 divergence observed once and NOT flagged")
3818
+ heuristic("Second look", "not taken, so this difference was seen once and is not flagged")
3609
3819
  ],
3610
- remedy: "The two representations reported different values for a core fact. ARS did not flag it, because a single observation cannot distinguish a divergence from an inventory change."
3820
+ remedy: "The Markdown copy and the page showed different values for a key fact. That can happen when a price or stock level changes between requests. If it repeats, build both from the same source."
3611
3821
  };
3612
3822
  }
3613
3823
  const confirmFacts = extractFacts(confirmRep, {
@@ -3629,8 +3839,8 @@ function checkSubstanceParity(context, negotiated) {
3629
3839
  evidence: [
3630
3840
  ...evidenceLines,
3631
3841
  heuristic(
3632
- "Confirming probe",
3633
- "the difference did not reproduce \u2014 treated as a value that changed between requests"
3842
+ "Second look",
3843
+ "the difference was gone, so we treat it as a value that changed between requests"
3634
3844
  )
3635
3845
  ]
3636
3846
  };
@@ -3640,14 +3850,14 @@ function checkSubstanceParity(context, negotiated) {
3640
3850
  severity: "warn",
3641
3851
  basis: "heuristic",
3642
3852
  message: reproduced.divergent.map(
3643
- (entry) => `The agent representation reported ${entry.kind} ${entry.left}; the HTML representation reported ${entry.right} at capture time, on two captures taken apart.`
3853
+ (entry) => `The Markdown copy showed ${factName(entry.kind)} ${entry.left}; the HTML page showed ${entry.right}. We saw the same difference on two requests taken apart.`
3644
3854
  ).join(" "),
3645
3855
  evidence: evidenceLines
3646
3856
  });
3647
3857
  return {
3648
3858
  earned: 0,
3649
- evidence: [...evidenceLines, heuristic("Confirming probe", "the difference reproduced")],
3650
- remedy: "Serve the same values in both representations. ARS reports what each one said; it does not assert which is correct."
3859
+ evidence: [...evidenceLines, heuristic("Second look", "the difference was still there")],
3860
+ remedy: "Show the same values in the Markdown copy and the page, ideally by building both from one source. We report what each version said and do not judge which is right."
3651
3861
  };
3652
3862
  }
3653
3863
  function coverageMath(context) {
@@ -3689,19 +3899,23 @@ function checkCoreFacts(context, math) {
3689
3899
  return {
3690
3900
  earned,
3691
3901
  evidence: [
3902
+ heuristic("Key facts for this kind of page", factList(context.profile.core)),
3903
+ heuristic("Found", `${math.coreFound} of ${context.profile.core.length}`),
3904
+ heuristic("Missing", missing.length === 0 ? "none" : factList(missing)),
3692
3905
  heuristic(
3693
- "Core facts found",
3694
- `${math.coreFound}/${context.profile.core.length}${missing.length === 0 ? "" : ` \u2014 missing ${missing.join(", ")}`}`
3906
+ "Extra facts found",
3907
+ `${math.extendedFound} of ${context.profile.extended.length}`
3695
3908
  ),
3696
- heuristic("Extended facts found", `${math.extendedFound}/${context.profile.extended.length}`),
3697
- heuristic("Coverage", `${math.coveragePct}%`),
3698
3909
  heuristic(
3699
- "Density band",
3700
- `${math.densityPct}% (${math.factsPerKiB100} hundredths of a fact per KiB)`
3910
+ "Credit for the facts",
3911
+ `${math.coveragePct}% (a fact stated in both the text and structured data counts in full)`
3701
3912
  ),
3702
- measured("Bytes the agent received", String(context.agent.bytes))
3913
+ heuristic(
3914
+ "Credit kept for length",
3915
+ `${math.densityPct}% (${math.coreFound + math.extendedFound} facts in ${plainBytes(context.agent.bytes)}; the more text around each fact, the less is kept)`
3916
+ )
3703
3917
  ],
3704
- remedy: missing.length === 0 ? void 0 : `State ${missing.join(", ")} in the representation the agent receives. A fact only the HTML carries is a fact the caller never saw.`
3918
+ remedy: missing.length > 0 ? `Add the ${factList(missing)} to what AI assistants receive. An assistant can only repeat what the page states.${missing.includes("primary-action-url") ? " For the main action link, use a label that starts with a common action word, such as Buy, Book, Order, Contact, Sign up, Get started or Request a quote." : ""}` : earned === weight ? void 0 : math.coveragePct < 100 ? "Repeat the key facts in both the visible text and the structured data. A fact stated once gets half credit." : "Your key facts are all there, but there is a lot of page around them, so this keeps only part of its credit. A Markdown copy for AI assistants that leads with the facts is the simplest fix; trimming the page also helps."
3705
3919
  };
3706
3920
  }
3707
3921
  function checkContextCost(context) {
@@ -3714,13 +3928,19 @@ function checkContextCost(context) {
3714
3928
  earned,
3715
3929
  evidence: [
3716
3930
  measured(
3717
- "Bytes the agent received",
3718
- `${context.agent.bytes}${context.agent.truncated ? " (truncated at the cap)" : ""}`
3931
+ "Size AI assistants had to read",
3932
+ `${plainBytes(context.agent.bytes)}${context.agent.truncated ? " or more (cut off at the limit)" : ""}`
3933
+ ),
3934
+ measured(
3935
+ `Typical size for a ${context.profile.pageKind === "unknown" ? "general" : context.profile.pageKind} page`,
3936
+ plainBytes(reference)
3719
3937
  ),
3720
- measured("Byte reference for this page kind", `${reference} (${context.profile.pageKind})`),
3721
- measured("Ratio", `${ratio}% of the reference`)
3938
+ measured(
3939
+ "Compared with typical",
3940
+ ratio <= 100 ? "at or under typical" : `about ${divRoundHalfUp(ratio, 100)} times typical`
3941
+ )
3722
3942
  ],
3723
- remedy: earned === full ? void 0 : "Serve a representation sized to the facts. The reference is what a page of this kind reasonably costs, not an absolute budget."
3943
+ remedy: earned === full ? void 0 : "Send AI assistants a Markdown copy, which carries the facts without the page code, or make the page lighter. Scripts, inline styles and repeated menus are usually most of the size."
3724
3944
  };
3725
3945
  }
3726
3946
  var QUANTITY = new RegExp(
@@ -3745,8 +3965,10 @@ function checkQuantities(context) {
3745
3965
  const full = atLeast(table, Number.MAX_SAFE_INTEGER);
3746
3966
  return {
3747
3967
  earned,
3748
- evidence: [measured("Distinct quantities an answer could quote", `${count}`)],
3749
- remedy: earned === full ? void 0 : "State the numbers a reader would ask for, in text: price, sizes, hours, fees, dates. A quantity an agent can lift is what a cited answer is built from."
3968
+ evidence: [
3969
+ measured("Different numbers an answer could quote", `${count} (prices, sizes, percentages, dates)`)
3970
+ ],
3971
+ remedy: earned === full ? void 0 : "Write the numbers people ask about in the page text: prices, sizes, hours, fees and dates. Assistants quote numbers they can read."
3750
3972
  };
3751
3973
  }
3752
3974
  function labelledSegments(context) {
@@ -3786,8 +4008,8 @@ function checkDefinitions(context) {
3786
4008
  const full = atLeast(table, Number.MAX_SAFE_INTEGER);
3787
4009
  return {
3788
4010
  earned,
3789
- evidence: [heuristic("Labelled term and value pairs", `${count}`)],
3790
- remedy: earned === full ? void 0 : 'Label your facts. A line that reads "Returns: 60 days" is liftable whole; the same fact inside a paragraph has to be inferred.'
4011
+ evidence: [heuristic('Labelled facts, like "Returns: 60 days"', `${count}`)],
4012
+ remedy: earned === full ? void 0 : 'Label your facts. A line like "Returns: 60 days" can be quoted as it is. The same fact inside a paragraph has to be worked out.'
3791
4013
  };
3792
4014
  }
3793
4015
  function checkComparisons(context) {
@@ -3818,8 +4040,8 @@ function checkComparisons(context) {
3818
4040
  const full = atLeast(table, Number.MAX_SAFE_INTEGER);
3819
4041
  return {
3820
4042
  earned,
3821
- evidence: [measured("Comparable rows", `${rows}`)],
3822
- remedy: earned === full ? void 0 : "Put options side by side in a table with a row each. An assistant comparing two things reaches for rows it can line up."
4043
+ evidence: [measured("Table rows that compare options", `${rows}`)],
4044
+ remedy: earned === full ? void 0 : 'Put options side by side in a table, one row each. Assistants answering "which one?" use rows they can line up.'
3823
4045
  };
3824
4046
  }
3825
4047
  function coreOffsets(context) {
@@ -3833,19 +4055,17 @@ function checkFirstCoreFactOffset(context, offsets) {
3833
4055
  if (first === void 0) {
3834
4056
  return {
3835
4057
  earned: 0,
3836
- evidence: [heuristic("First core fact", "none found \u2014 nothing to position")]
4058
+ evidence: [heuristic("First key fact", "none found, so there is nothing to place")]
3837
4059
  };
3838
4060
  }
4061
+ const firstKind = context.facts.find((fact) => fact.offset === first)?.kind;
3839
4062
  return {
3840
4063
  earned: atMost(context.ruleset.thresholds["fact-position.first-core-fact-offset"], first),
3841
4064
  evidence: [
3842
- measured("Byte offset of the first core fact", String(first)),
3843
- heuristic(
3844
- "Which fact",
3845
- context.facts.find((fact) => fact.offset === first)?.kind ?? "unknown"
3846
- )
4065
+ measured("First key fact appears", first === 0 ? "at the very start" : `after ${plainBytes(first)}`),
4066
+ heuristic("Which fact", firstKind === void 0 ? "unknown" : factName(firstKind))
3847
4067
  ],
3848
- remedy: first <= 512 ? void 0 : "Move the core facts to the top of the representation. A caller that stops reading early stops before them."
4068
+ remedy: first <= 512 ? void 0 : "Put the key facts near the top of what AI assistants receive. Assistants often read only the start."
3849
4069
  };
3850
4070
  }
3851
4071
  function checkFrontWindow(context, offsets) {
@@ -3857,8 +4077,8 @@ function checkFrontWindow(context, offsets) {
3857
4077
  return {
3858
4078
  earned: 0,
3859
4079
  evidence: [
3860
- measured("Front window", `${size} bytes`),
3861
- heuristic("Core facts inside it", "none found \u2014 nothing to position")
4080
+ measured("Opening section", `the first ${plainBytes(size)}`),
4081
+ heuristic("Key facts in it", "none found, so there is nothing to place")
3862
4082
  ]
3863
4083
  };
3864
4084
  }
@@ -3867,11 +4087,13 @@ function checkFrontWindow(context, offsets) {
3867
4087
  return {
3868
4088
  earned: atLeast(context.ruleset.thresholds["fact-position.front-window"], pct),
3869
4089
  evidence: [
3870
- measured("Front window", `${size} bytes (max(${floor}, bytes/${divisor}))`),
3871
- heuristic("Core facts inside it", `${inside}/${offsets.length} found (${pct}%)`),
3872
- heuristic("Core facts in this page kind", String(context.profile.core.length))
4090
+ measured(
4091
+ "Opening section",
4092
+ `the first ${plainBytes(size)} (a ${divisor === 5 ? "fifth" : `1/${divisor}`} of the page, at least ${plainBytes(floor)})`
4093
+ ),
4094
+ heuristic("Key facts in it", `${inside} of the ${offsets.length} found (${pct}%)`)
3873
4095
  ],
3874
- remedy: pct >= 90 ? void 0 : "Front-load the core facts. Everything after the window costs the caller a full read."
4096
+ remedy: pct >= 90 ? void 0 : "Move the key facts into the first part of the page. Facts further down cost an assistant a full read."
3875
4097
  };
3876
4098
  }
3877
4099
  function checkStructuredDataPresent(context) {
@@ -3880,7 +4102,7 @@ function checkStructuredDataPresent(context) {
3880
4102
  if (structural === null) {
3881
4103
  return {
3882
4104
  earned: 0,
3883
- evidence: [measured("HTML representation", "none in this bundle \u2014 not evaluated")]
4105
+ evidence: [measured("HTML page", "not checked, because no HTML was returned")]
3884
4106
  };
3885
4107
  }
3886
4108
  const { blocks, parsed } = structural.jsonLd;
@@ -3898,11 +4120,11 @@ function checkStructuredDataPresent(context) {
3898
4120
  return {
3899
4121
  earned,
3900
4122
  evidence: [
3901
- measured("JSON-LD blocks", `${parsed} of ${blocks} parsed`),
3902
- measured("Microdata itemtype scopes", String(microdata)),
3903
- measured("RDFa typeof scopes", String(rdfa))
4123
+ measured("JSON-LD blocks that could be read", `${parsed} of ${blocks}`),
4124
+ measured("Microdata items", String(microdata)),
4125
+ measured("RDFa items", String(rdfa))
3904
4126
  ],
3905
- remedy: earned === split.clean ? void 0 : blocks > parsed ? "One or more JSON-LD blocks did not parse. A block that does not parse is not structured data." : "Add JSON-LD for this page. It is the one machine representation every consumer already reads."
4127
+ remedy: earned === split.clean ? void 0 : blocks > parsed ? "At least one JSON-LD block has a syntax error, so it cannot be read. Check it with a JSON validator." : "Add a JSON-LD block describing this page, such as a schema.org Product with its price. Search engines and some AI assistants read it."
3906
4128
  };
3907
4129
  }
3908
4130
  function scoredNode(context) {
@@ -3920,14 +4142,11 @@ function checkRequiredProperties(context) {
3920
4142
  return {
3921
4143
  earned: 0,
3922
4144
  evidence: [
3923
- measured("Recognised schema.org type", "none"),
3924
- measured("Required properties for this page kind", required.join(", ") || "none"),
3925
- measured(
3926
- "Scope",
3927
- "JSON-LD only in 0.1 \u2014 microdata satisfies D5.1 but is not walked for required properties"
3928
- )
4145
+ measured("Schema.org type", "none found"),
4146
+ measured("Properties we look for", required.join(", ") || "none"),
4147
+ measured("Where we look", "JSON-LD. Microdata counts toward the check above, not this one.")
3929
4148
  ],
3930
- remedy: 'Declare a schema.org type in JSON-LD. Choosing no type does not avoid this check \u2014 an unrecognised page still scores against "any recognised type present".'
4149
+ remedy: "Give the JSON-LD a schema.org type that matches the page, such as Product, LocalBusiness or Article, with the properties listed."
3931
4150
  };
3932
4151
  }
3933
4152
  const satisfied = required.filter((path) => hasPath(node, path));
@@ -3936,14 +4155,11 @@ function checkRequiredProperties(context) {
3936
4155
  return {
3937
4156
  earned: split.recognisedType + completeness,
3938
4157
  evidence: [
3939
- measured("Scored node @type", node.types.join(", ")),
3940
- measured(
3941
- "Required properties",
3942
- `${satisfied.length}/${required.length}${missing.length === 0 ? "" : ` \u2014 missing ${missing.join(", ")}`}`
3943
- ),
3944
- measured("Table", `ruleset.requiredProperties.${context.profile.pageKind}`)
4158
+ measured("Schema.org type", node.types.join(", ")),
4159
+ measured("Properties present", `${satisfied.length} of ${required.length}`),
4160
+ measured("Missing", missing.length === 0 ? "none" : missing.join(", "))
3945
4161
  ],
3946
- remedy: missing.length === 0 ? void 0 : `Add ${missing.join(", ")} to the ${node.types[0] ?? "top-level"} node.`
4162
+ remedy: missing.length === 0 ? void 0 : `Add ${missing.join(", ")} to the ${node.types[0] ?? "main"} item in your JSON-LD.`
3947
4163
  };
3948
4164
  }
3949
4165
  function checkTextAgreement(context) {
@@ -3953,19 +4169,23 @@ function checkTextAgreement(context) {
3953
4169
  const { compared, divergent } = divergentKinds(fromJsonLd, fromPage, PARITY_KINDS);
3954
4170
  const evidenceLines = [
3955
4171
  heuristic(
3956
- "Compared facts",
3957
- compared.length === 0 ? "none stated both in structured data and on the page" : compared.join(", ")
4172
+ "Facts compared",
4173
+ compared.length === 0 ? "none appear in both the structured data and the page text" : factList(compared)
3958
4174
  ),
3959
- heuristic(
3960
- "Values",
3961
- divergent.length === 0 ? "agree" : divergent.map((entry) => `${entry.kind}: structured data ${entry.left} / page ${entry.right}`).join("; ")
3962
- )
4175
+ ...compared.length === 0 ? [] : [
4176
+ heuristic(
4177
+ "Values",
4178
+ divergent.length === 0 ? "match" : divergent.map(
4179
+ (entry) => `${factName(entry.kind)}: structured data ${entry.left}, page ${entry.right}`
4180
+ ).join("; ")
4181
+ )
4182
+ ]
3963
4183
  ];
3964
4184
  if (compared.length === 0) {
3965
4185
  return {
3966
4186
  earned: 0,
3967
- evidence: [...evidenceLines, heuristic("Scored", "no \u2014 nothing was comparable")],
3968
- remedy: "State the core facts in both the structured data and the visible page, so the two can be checked against each other."
4187
+ evidence: evidenceLines,
4188
+ remedy: "State the key facts, such as name and price, in both the structured data and the visible page, so the two can be checked against each other."
3969
4189
  };
3970
4190
  }
3971
4191
  if (divergent.length > 0) {
@@ -3974,14 +4194,14 @@ function checkTextAgreement(context) {
3974
4194
  severity: "warn",
3975
4195
  basis: "heuristic",
3976
4196
  message: divergent.map(
3977
- (entry) => `The structured data reported ${entry.kind} ${entry.left}; the visible page reported ${entry.right}.`
4197
+ (entry) => `The structured data says ${factName(entry.kind)} ${entry.left}; the visible page says ${entry.right}.`
3978
4198
  ).join(" "),
3979
4199
  evidence: evidenceLines
3980
4200
  });
3981
4201
  return {
3982
4202
  earned: 0,
3983
4203
  evidence: evidenceLines,
3984
- remedy: "Generate the structured data from the same source as the rendered page, so the two cannot drift."
4204
+ remedy: "Build the structured data from the same source as the visible page, so the two cannot disagree."
3985
4205
  };
3986
4206
  }
3987
4207
  return { earned: SUBPOINTS.textAgreement.full, evidence: evidenceLines };
@@ -4011,22 +4231,22 @@ function checkCanonical(context) {
4011
4231
  id: "canonical-mismatch",
4012
4232
  severity: "warn",
4013
4233
  basis: "measured",
4014
- message: `The two representations of this URL declare different canonicals: ${agentCanonical} and ${htmlCanonical}.`,
4234
+ message: `The Markdown copy and the HTML page name different main addresses: ${agentCanonical} and ${htmlCanonical}.`,
4015
4235
  evidence: [
4016
- measured("Agent probe canonical", agentCanonical),
4017
- measured("HTML canonical", htmlCanonical)
4236
+ measured("Main address given to AI assistants", agentCanonical),
4237
+ measured("Main address in the HTML", htmlCanonical)
4018
4238
  ]
4019
4239
  });
4020
4240
  }
4021
4241
  return {
4022
4242
  earned: (present ? split.present : 0) + (absolute ? split.absolute : 0) + (consistent ? split.consistentAcrossProbes : 0),
4023
4243
  evidence: [
4024
- measured("Canonical (HTML)", htmlCanonical ?? "absent"),
4025
- measured("Canonical (agent representation)", agentCanonical ?? "absent"),
4026
- measured("Absolute", yesNo(absolute)),
4027
- measured("Same across both probes", yesNo(consistent))
4244
+ measured("Canonical address in the HTML", htmlCanonical ?? "none"),
4245
+ measured("Canonical address AI assistants got", agentCanonical ?? "none"),
4246
+ measured("Full address with https://", yesNo(absolute)),
4247
+ measured("Same for AI assistants and browsers", yesNo(consistent))
4028
4248
  ],
4029
- remedy: consistent ? void 0 : agentCanonical === null ? 'Declare the canonical on the machine representation too \u2014 `Link: <https://\u2026>; rel="canonical"`. A representation with no canonical cannot be attributed to a page.' : "Declare one canonical URL and use it in both representations."
4249
+ remedy: consistent && absolute ? void 0 : htmlCanonical === null ? 'Add `<link rel="canonical" href="https://\u2026">` with the full address of the page, so assistants know which address to cite.' : agentCanonical === null ? 'Your Markdown copy has no canonical address. Send `Link: <https://\u2026>; rel="canonical"` with it, pointing at the page.' : !consistent ? "Use one canonical address, written in full, for the page and its Markdown copy." : "Write the canonical address in full, starting with https://."
4030
4250
  };
4031
4251
  }
4032
4252
  function checkCacheValidators(context) {
@@ -4046,11 +4266,11 @@ function checkCacheValidators(context) {
4046
4266
  return {
4047
4267
  earned: (sane ? split.saneCacheControl : 0) + (validator ? split.validator : 0),
4048
4268
  evidence: [
4049
- measured("Cache-Control", cacheControl ?? "absent"),
4050
- measured("ETag", etag ?? "absent"),
4051
- measured("Last-Modified", lastModified ?? "absent")
4269
+ measured("Cache-Control header", cacheControl ?? "not sent"),
4270
+ measured("ETag header", etag ?? "not sent"),
4271
+ measured("Last-Modified header", lastModified ?? "not sent")
4052
4272
  ],
4053
- remedy: sane && validator ? void 0 : "Send a `Cache-Control` a cache can act on, plus an `ETag` or `Last-Modified`. Repeat fetches are most of agent traffic."
4273
+ remedy: sane && validator ? void 0 : "Send a `Cache-Control` header with a lifetime, plus an `ETag` or `Last-Modified` header, so repeat visits can skip unchanged pages."
4054
4274
  };
4055
4275
  }
4056
4276
  function bodyOf(probe) {
@@ -4066,8 +4286,8 @@ function checkLlmsTxt(context) {
4066
4286
  if (body === null || body.trim().length === 0) {
4067
4287
  return {
4068
4288
  earned: 0,
4069
- evidence: [measured("/llms.txt", body === null ? "absent or non-2xx" : "empty")],
4070
- remedy: "Publish /llms.txt: an H1 title, a short summary, and links to the pages that matter. It is worth 1 point of 100, deliberately."
4289
+ evidence: [measured("/llms.txt", body === null ? "not found" : "empty")],
4290
+ remedy: "Publish /llms.txt with a `#` title, a short summary and links to your main pages."
4071
4291
  };
4072
4292
  }
4073
4293
  const hasTitle = /^#\s+\S/m.test(body);
@@ -4077,24 +4297,24 @@ function checkLlmsTxt(context) {
4077
4297
  return {
4078
4298
  earned: specShaped ? split.specShaped : split.present,
4079
4299
  evidence: [
4080
- measured("/llms.txt", `${body.length} characters`),
4081
- measured("H1 title", yesNo(hasTitle)),
4082
- measured("Markdown links", yesNo(hasLinks))
4300
+ measured("/llms.txt", `found, ${body.length} characters`),
4301
+ measured("Has a # title", yesNo(hasTitle)),
4302
+ measured("Has links", yesNo(hasLinks))
4083
4303
  ],
4084
- remedy: specShaped ? void 0 : "Give /llms.txt an H1 title and at least one Markdown link."
4304
+ remedy: specShaped ? void 0 : "Start /llms.txt with a `#` title and add at least one link written as `[name](url)`."
4085
4305
  };
4086
4306
  }
4087
4307
  function checkSitemap(context) {
4088
4308
  return {
4089
4309
  earned: context.policy.sitemapDeclared ? SUBPOINTS.sitemap.full : 0,
4090
4310
  evidence: [
4091
- measured("Sitemap: in robots.txt", yesNo(context.policy.sitemapDeclared)),
4311
+ measured("Sitemap listed in robots.txt", yesNo(context.policy.sitemapDeclared)),
4092
4312
  measured(
4093
- "Sitemaps declared",
4094
- context.robots === null ? "n/a" : context.robots.sitemaps.join(", ") || "none"
4313
+ "Sitemaps",
4314
+ context.robots === null ? "none" : context.robots.sitemaps.join(", ") || "none"
4095
4315
  )
4096
4316
  ],
4097
- remedy: context.policy.sitemapDeclared ? void 0 : "Declare `Sitemap:` in robots.txt."
4317
+ remedy: context.policy.sitemapDeclared ? void 0 : "Add a line like `Sitemap: https://example.com/sitemap.xml` to robots.txt."
4098
4318
  };
4099
4319
  }
4100
4320
  var ENDPOINT_TYPES = [
@@ -4137,17 +4357,17 @@ function checkMachineEndpoint(context) {
4137
4357
  ]);
4138
4358
  for (const link of links) {
4139
4359
  if (link.rel.some((rel) => ENDPOINT_RELS.includes(rel)))
4140
- declarations.push(`Link rel=${link.rel.join(" ")} \u2192 ${link.url}`);
4360
+ declarations.push(`Link header (${link.rel.join(" ")}) at ${link.url}`);
4141
4361
  else if (link.type !== null && ENDPOINT_TYPES.includes(link.type))
4142
- declarations.push(`Link type=${link.type} \u2192 ${link.url}`);
4362
+ declarations.push(`Link header (${link.type}) at ${link.url}`);
4143
4363
  }
4144
4364
  if (context.structural !== null && context.structural.doc !== null) {
4145
4365
  for (const link of context.structural.doc.links) {
4146
4366
  if (link.href === null) continue;
4147
4367
  if (link.rel.some((rel) => ENDPOINT_RELS.includes(rel)))
4148
- declarations.push(`<link rel="${link.rel.join(" ")}"> \u2192 ${link.href}`);
4368
+ declarations.push(`link tag (${link.rel.join(" ")}) at ${link.href}`);
4149
4369
  else if (link.type !== null && ENDPOINT_TYPES.includes(link.type))
4150
- declarations.push(`<link type="${link.type}"> \u2192 ${link.href}`);
4370
+ declarations.push(`link tag (${link.type}) at ${link.href}`);
4151
4371
  }
4152
4372
  }
4153
4373
  const llms = bodyOf(context.evidence.probes.llmsTxt);
@@ -4157,21 +4377,19 @@ function checkMachineEndpoint(context) {
4157
4377
  while ((match = MARKDOWN_LINK.exec(llms)) !== null) {
4158
4378
  const url = (match[1] ?? "").toLowerCase();
4159
4379
  if (ENDPOINT_PATH_MARKERS.some((marker) => url.includes(marker)))
4160
- declarations.push(`llms.txt \u2192 ${match?.[1] ?? url}`);
4380
+ declarations.push(`llms.txt link to ${match?.[1] ?? url}`);
4161
4381
  }
4162
4382
  }
4163
4383
  const ucp = bodyOf(context.evidence.probes.wellKnownUcp);
4164
4384
  if (ucp !== null && ucp.trim().length > 0) declarations.push("/.well-known/ucp");
4385
+ const unique = [...new Set(declarations)];
4165
4386
  return {
4166
4387
  earned: declarations.length > 0 ? SUBPOINTS.machineEndpoint.full : 0,
4167
4388
  evidence: [
4168
- measured(
4169
- "Declared machine endpoints",
4170
- declarations.length === 0 ? "none" : declarations.join("; ")
4171
- ),
4172
- measured("Probed paths", "/robots.txt, /llms.txt, /.well-known/ucp \u2014 ARS probes no others")
4389
+ measured("Feeds or APIs we found", unique.length === 0 ? "none" : unique.join("; ")),
4390
+ measured("Where we looked", "link tags, Link headers, /llms.txt and /.well-known/ucp")
4173
4391
  ],
4174
- remedy: declarations.length > 0 ? void 0 : "Declare one machine endpoint \u2014 a feed, an OpenAPI document, /.well-known/ucp \u2014 with a `Link` header or a `<link>`. ARS does not guess at paths."
4392
+ remedy: declarations.length > 0 ? void 0 : "Point to a product feed, API or calendar from the page with a `<link>` tag or a `Link` header. We only count ones the page names."
4175
4393
  };
4176
4394
  }
4177
4395
  function weightOf(ruleset, id) {
@@ -4376,7 +4594,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
4376
4594
  id: "training-opt-out",
4377
4595
  severity: "info",
4378
4596
  basis: "measured",
4379
- message: "This site blocks model-training crawlers while allowing assistant fetches. That is neutral in ARS: it never lowers the score.",
4597
+ message: "This site blocks AI training crawlers but lets AI assistants in. That does not affect the score.",
4380
4598
  evidence: [
4381
4599
  measured("Training audience", policy.audiences.training.matchedRule ?? "disallowed"),
4382
4600
  measured("Effect on this score", "none")
@@ -4390,7 +4608,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
4390
4608
  id: "scanner-blocked",
4391
4609
  severity: "info",
4392
4610
  basis: "measured",
4393
- message: "robots.txt disallows the rebilder-ars scanner. We obeyed it and did not score this page.",
4611
+ message: "robots.txt asks Rebilder\u2019s scanner not to read this site, so we did not score the page.",
4394
4612
  evidence: [measured("Matched rule", scannerDecision)]
4395
4613
  });
4396
4614
  return nonGrade(
@@ -4418,7 +4636,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
4418
4636
  id: "assistant-opt-out",
4419
4637
  severity: "info",
4420
4638
  basis: "measured",
4421
- message: "This site names assistant crawlers in robots.txt and disallows them. ARS records the choice and does not grade the page.",
4639
+ message: "This site\u2019s robots.txt blocks AI assistants by name. We respect that choice and do not grade the page.",
4422
4640
  evidence: [
4423
4641
  measured("Matched group", policy.audiences.assistant.matchedGroup ?? "(named group)"),
4424
4642
  measured("Matched rule", policy.audiences.assistant.matchedRule ?? "Disallow")
@@ -4441,7 +4659,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
4441
4659
  id: "scanner-blocked",
4442
4660
  severity: "warn",
4443
4661
  basis: "measured",
4444
- message: "The origin answered the agent probe with a challenge or a block. ARS reports the evidence and does not grade the page.",
4662
+ message: "The site answered our scanner with a bot check or a block, so we did not grade the page. AI assistants may be blocked the same way.",
4445
4663
  evidence: [measured("Probe error", agentProbe.result.error)]
4446
4664
  });
4447
4665
  }
@@ -4461,7 +4679,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
4461
4679
  id: "scanner-blocked",
4462
4680
  severity: "warn",
4463
4681
  basis: "measured",
4464
- message: `The origin answered the agent probe with HTTP ${agentCapture.status}. ARS reports the evidence and does not grade the page.`,
4682
+ message: `The site answered our scanner with HTTP ${agentCapture.status}, so we did not grade the page. AI assistants may be blocked the same way.`,
4465
4683
  evidence: [measured("HTTP status", String(agentCapture.status))]
4466
4684
  });
4467
4685
  return nonGrade(
@@ -4503,7 +4721,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
4503
4721
  id: "body-truncated",
4504
4722
  severity: "warn",
4505
4723
  basis: "measured",
4506
- message: `A response exceeded the ${ruleset.maxBodyBytes}-byte body cap and was truncated. The fact set and the byte count would both be wrong, so the page is not scored.`,
4724
+ message: `The page is larger than our ${plainBytes(ruleset.maxBodyBytes)} reading limit, so we did not score it. The facts and sizes would both be incomplete.`,
4507
4725
  evidence: [
4508
4726
  measured("Body cap", `${ruleset.maxBodyBytes} bytes`),
4509
4727
  measured("Bytes read", `\u2265 ${agentCapture.bytes}`)
@@ -4549,7 +4767,10 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
4549
4767
  const browserFacts = browser === null || browser === agent ? [] : extractFacts(browser, { ...extractContext, baseUrl: browser.finalUrl });
4550
4768
  const structuralFacts = structural === agent ? agentFacts : structural === browser ? browserFacts : [];
4551
4769
  const facts = mergeFacts(agentFacts, structuralFacts);
4770
+ const negotiated = isMachineCopy(agentCapture);
4552
4771
  const context = {
4772
+ negotiated,
4773
+ linkedCopy: negotiated ? null : linkedCopyOf(evidence, agentCapture, browserCapture),
4553
4774
  evidence,
4554
4775
  ruleset,
4555
4776
  agentCapture,
@@ -4572,18 +4793,18 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
4572
4793
  id: "paywalled",
4573
4794
  severity: "info",
4574
4795
  basis: "measured",
4575
- message: `This page declares a paywall (${paywall}). ARS scores the portion it was served and does not attempt to reach the gated part.`,
4796
+ message: `This page says it is behind a paywall (${paywall}). We scored the part we were shown.`,
4576
4797
  evidence: [measured("Paywall signal", paywall)]
4577
4798
  });
4578
4799
  }
4579
4800
  const math = coverageMath(context);
4580
4801
  const offsets = coreOffsets(context);
4581
- const negotiated = checkNegotiatedResponse(context);
4802
+ const negotiatedResponse = checkNegotiatedResponse(context);
4582
4803
  const checks = [
4583
4804
  buildCheck(ruleset, "retrievability.reachable", checkReachable(context)),
4584
4805
  buildCheck(ruleset, "retrievability.robots-policy", checkRobotsPolicy(context)),
4585
4806
  buildCheck(ruleset, "retrievability.render-independence", checkRenderIndependence(context)),
4586
- buildCheck(ruleset, "machine-representation.negotiated-response", negotiated),
4807
+ buildCheck(ruleset, "machine-representation.negotiated-response", negotiatedResponse),
4587
4808
  buildCheck(
4588
4809
  ruleset,
4589
4810
  "machine-representation.declared-alternates",
@@ -4592,12 +4813,12 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
4592
4813
  buildCheck(
4593
4814
  ruleset,
4594
4815
  "machine-representation.vary-accept",
4595
- checkVaryAccept(context, negotiated.earned)
4816
+ checkVaryAccept(context)
4596
4817
  ),
4597
4818
  buildCheck(
4598
4819
  ruleset,
4599
4820
  "machine-representation.substance-parity",
4600
- checkSubstanceParity(context, negotiated.earned)
4821
+ checkSubstanceParity(context)
4601
4822
  ),
4602
4823
  buildCheck(ruleset, "fact-coverage.core-facts", checkCoreFacts(context, math)),
4603
4824
  buildCheck(ruleset, "fact-coverage.context-cost", checkContextCost(context)),
@@ -4625,7 +4846,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
4625
4846
  const grade = band?.grade ?? "F";
4626
4847
  const perToken = ruleset.thresholds["cost.approx-bytes-per-token"]?.[0] ?? 4;
4627
4848
  const htmlBytes = structural?.bytes ?? agent.bytes;
4628
- const negotiatedBytes = negotiated.earned > 0 ? agent.bytes : null;
4849
+ const negotiatedBytes = negotiated ? agent.bytes : null;
4629
4850
  const cost = {
4630
4851
  htmlBytes,
4631
4852
  negotiatedBytes,
@@ -4740,7 +4961,10 @@ exports.SUBPOINTS = SUBPOINTS;
4740
4961
  exports.bandFor = bandFor;
4741
4962
  exports.canonicalJson = canonicalJson;
4742
4963
  exports.classify = classify;
4964
+ exports.declaredMarkdownAlternates = declaredMarkdownAlternates;
4743
4965
  exports.evidenceHash = evidenceHash;
4966
+ exports.isMachineCopy = isMachineCopy;
4967
+ exports.markdownAlternateTarget = markdownAlternateTarget;
4744
4968
  exports.minorUnitDigits = minorUnitDigits;
4745
4969
  exports.parseMoneyText = parseMoneyText;
4746
4970
  exports.parseRobots = parseRobots;
@@ -4752,5 +4976,3 @@ exports.rulesetHash = rulesetHash;
4752
4976
  exports.score = score;
4753
4977
  exports.sha256Hex = sha256Hex;
4754
4978
  exports.utf8Length = utf8Length;
4755
- //# sourceMappingURL=index.cjs.map
4756
- //# sourceMappingURL=index.cjs.map