@rebilder/agent-readability 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 +17 -0
- package/README.md +5 -4
- package/dist/index.cjs +1275 -196
- package/dist/index.d.cts +317 -14
- package/dist/index.d.ts +317 -14
- package/dist/index.js +1259 -197
- package/dist/index.js.map +1 -1
- package/dist/probe/index.cjs +850 -12
- package/dist/probe/index.d.cts +15 -11
- package/dist/probe/index.d.ts +15 -11
- package/dist/probe/index.js +850 -12
- package/dist/probe/index.js.map +1 -1
- package/dist/probe/local.cjs +850 -12
- package/dist/probe/local.d.cts +2 -2
- package/dist/probe/local.d.ts +2 -2
- package/dist/probe/local.js +850 -12
- package/dist/probe/local.js.map +1 -1
- package/dist/{robots-policy-DE8jix-e.d.cts → robots-policy-C7cfPpu2.d.cts} +15 -6
- package/dist/{robots-policy-DE8jix-e.d.ts → robots-policy-C7cfPpu2.d.ts} +15 -6
- package/package.json +9 -4
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.
|
|
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.
|
|
446
|
+
version: "0.3.0",
|
|
419
447
|
weights: WEIGHTS,
|
|
420
448
|
thresholds: THRESHOLDS,
|
|
421
449
|
audienceTokens: AUDIENCE_TOKENS,
|
|
@@ -724,10 +752,9 @@ function parseStartTag(html, start) {
|
|
|
724
752
|
}
|
|
725
753
|
return { tag, attrs, selfClosing, end: i };
|
|
726
754
|
}
|
|
727
|
-
function findRawTextEnd(
|
|
755
|
+
function findRawTextEnd(lowerHtml, from, tag) {
|
|
728
756
|
const needle = `</${tag}`;
|
|
729
|
-
const
|
|
730
|
-
const at = lower.indexOf(needle, from);
|
|
757
|
+
const at = lowerHtml.indexOf(needle, from);
|
|
731
758
|
return at === -1 ? -1 : at;
|
|
732
759
|
}
|
|
733
760
|
function ownExclusion(tag, attrs) {
|
|
@@ -791,6 +818,7 @@ function tokenizeHtml(html) {
|
|
|
791
818
|
};
|
|
792
819
|
let i = 0;
|
|
793
820
|
let textStart = 0;
|
|
821
|
+
let lowerHtml = null;
|
|
794
822
|
while (i < html.length) {
|
|
795
823
|
const lt = html.indexOf("<", i);
|
|
796
824
|
if (lt === -1) break;
|
|
@@ -842,7 +870,8 @@ function tokenizeHtml(html) {
|
|
|
842
870
|
const isRcdata = RCDATA_ELEMENTS.has(parsed.tag);
|
|
843
871
|
if (isRawText || isRcdata) {
|
|
844
872
|
const contentStart = i;
|
|
845
|
-
|
|
873
|
+
lowerHtml ??= html.toLowerCase();
|
|
874
|
+
const close = findRawTextEnd(lowerHtml, contentStart, parsed.tag);
|
|
846
875
|
const contentEnd = close === -1 ? html.length : close;
|
|
847
876
|
if (contentEnd > contentStart) {
|
|
848
877
|
const wasTop = stack.length;
|
|
@@ -2366,7 +2395,10 @@ function parseRobots(text) {
|
|
|
2366
2395
|
else current.disallow.push(value);
|
|
2367
2396
|
continue;
|
|
2368
2397
|
}
|
|
2369
|
-
if (field === "crawl-delay" || field === "host" || field === "clean-param")
|
|
2398
|
+
if (field === "crawl-delay" || field === "host" || field === "clean-param" || field === "content-signal") {
|
|
2399
|
+
if (field === "content-signal" && current !== null) openingGroup = false;
|
|
2400
|
+
continue;
|
|
2401
|
+
}
|
|
2370
2402
|
malformedLines++;
|
|
2371
2403
|
}
|
|
2372
2404
|
return { groups, sitemaps, malformedLines, orphanRules };
|
|
@@ -2782,7 +2814,15 @@ var TEMPLATES = [
|
|
|
2782
2814
|
effort: "config",
|
|
2783
2815
|
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
2816
|
checks: ["machine-representation.negotiated-response"],
|
|
2785
|
-
|
|
2817
|
+
// Vary is gated on negotiation itself, so it stays locked while D2.1 is
|
|
2818
|
+
// short of full, including the ARS 0.3 partial credit for a linked copy.
|
|
2819
|
+
// Parity also opens on a linked copy, so it is unlocked only from zero.
|
|
2820
|
+
unlocks: (state) => {
|
|
2821
|
+
const earned = earnedOf(state, "machine-representation.negotiated-response");
|
|
2822
|
+
const full = state.get("machine-representation.negotiated-response")?.weight ?? 0;
|
|
2823
|
+
if (earned >= full) return [];
|
|
2824
|
+
return earned === 0 ? ["machine-representation.vary-accept", "machine-representation.substance-parity"] : ["machine-representation.vary-accept"];
|
|
2825
|
+
}
|
|
2786
2826
|
},
|
|
2787
2827
|
{
|
|
2788
2828
|
id: "declare-alternates",
|
|
@@ -3041,8 +3081,14 @@ var SUBPOINTS = deepFreeze2({
|
|
|
3041
3081
|
band: [100, 7, 75, 5, 50, 3, 25, 1],
|
|
3042
3082
|
noscriptFloor: 1
|
|
3043
3083
|
},
|
|
3044
|
-
/**
|
|
3045
|
-
|
|
3084
|
+
/**
|
|
3085
|
+
* D2.1, 9 for a machine copy served at the page's own address on `Accept`
|
|
3086
|
+
* negotiation: a machine media type AND a body that is not HTML. ARS 0.3: 6
|
|
3087
|
+
* when the page does not negotiate but the Markdown copy it declares as an
|
|
3088
|
+
* alternate was fetched and is real. Less than full because only agents that
|
|
3089
|
+
* look for the link reach it, and they pay a second request to do so.
|
|
3090
|
+
*/
|
|
3091
|
+
negotiatedResponse: { full: 9, linkedCopy: 6 },
|
|
3046
3092
|
/** D2.2, 3. All-or-nothing. */
|
|
3047
3093
|
declaredAlternates: { full: 3 },
|
|
3048
3094
|
/** D2.3, 3. All-or-nothing, and 0 unless D2.1 > 0. */
|
|
@@ -3251,12 +3297,14 @@ function evidenceHash(evidence) {
|
|
|
3251
3297
|
parityConfirm: redactProbe(evidence.probes.parityConfirm),
|
|
3252
3298
|
robotsTxt: redactProbe(evidence.probes.robotsTxt),
|
|
3253
3299
|
llmsTxt: redactProbe(evidence.probes.llmsTxt),
|
|
3254
|
-
wellKnownUcp: redactProbe(evidence.probes.wellKnownUcp)
|
|
3300
|
+
wellKnownUcp: redactProbe(evidence.probes.wellKnownUcp),
|
|
3301
|
+
// ARS 0.3, and only when present, so a 0.2 bundle hashes as it did.
|
|
3302
|
+
...evidence.probes.markdownAlternate === void 0 ? {} : { markdownAlternate: redactProbe(evidence.probes.markdownAlternate) }
|
|
3255
3303
|
}
|
|
3256
3304
|
})
|
|
3257
3305
|
);
|
|
3258
3306
|
}
|
|
3259
|
-
var ARS_CORPUS_HASH = sha256Hex("ars-0.
|
|
3307
|
+
var ARS_CORPUS_HASH = sha256Hex("ars-0.3-corpus-unfrozen");
|
|
3260
3308
|
function parseLinkHeaders(values) {
|
|
3261
3309
|
const out = [];
|
|
3262
3310
|
for (const value of values) {
|
|
@@ -3318,6 +3366,51 @@ function measured(label, value) {
|
|
|
3318
3366
|
function heuristic(label, value) {
|
|
3319
3367
|
return { label, value, basis: "heuristic" };
|
|
3320
3368
|
}
|
|
3369
|
+
var FACT_NAMES = {
|
|
3370
|
+
title: "name or title",
|
|
3371
|
+
description: "description",
|
|
3372
|
+
updated: "last-updated date",
|
|
3373
|
+
published: "publish date",
|
|
3374
|
+
price: "price",
|
|
3375
|
+
currency: "currency",
|
|
3376
|
+
availability: "availability",
|
|
3377
|
+
brand: "brand",
|
|
3378
|
+
sku: "SKU",
|
|
3379
|
+
shipping: "shipping details",
|
|
3380
|
+
returns: "returns policy",
|
|
3381
|
+
"org-name": "business name",
|
|
3382
|
+
address: "address",
|
|
3383
|
+
hours: "opening hours",
|
|
3384
|
+
phone: "phone number",
|
|
3385
|
+
email: "email address",
|
|
3386
|
+
"service-area": "service area",
|
|
3387
|
+
author: "author",
|
|
3388
|
+
section: "section",
|
|
3389
|
+
authority: "publisher",
|
|
3390
|
+
"primary-action-url": "main action link (such as Buy, Book, Contact or Install)",
|
|
3391
|
+
eligibility: "eligibility",
|
|
3392
|
+
duration: "duration",
|
|
3393
|
+
"question-answer": "questions and answers",
|
|
3394
|
+
"item-count": "number of items",
|
|
3395
|
+
"item-link": "links to the items"
|
|
3396
|
+
};
|
|
3397
|
+
function factName(kind) {
|
|
3398
|
+
return FACT_NAMES[kind] ?? kind;
|
|
3399
|
+
}
|
|
3400
|
+
function factList(kinds) {
|
|
3401
|
+
return kinds.map(factName).join(", ");
|
|
3402
|
+
}
|
|
3403
|
+
function plainBytes(bytes) {
|
|
3404
|
+
if (bytes < 1024) return `${bytes} bytes`;
|
|
3405
|
+
return `${divRoundHalfUp(bytes, 1024)} KB`;
|
|
3406
|
+
}
|
|
3407
|
+
var ROBOTS_STATUS = {
|
|
3408
|
+
ok: "found",
|
|
3409
|
+
missing: "not found (nothing is blocked)",
|
|
3410
|
+
error: "the server returned an error",
|
|
3411
|
+
unparseable: "found, but it could not be read"
|
|
3412
|
+
};
|
|
3413
|
+
var COUNTS_ONCE_COPY = "only once the page sends AI assistants a Markdown copy, so 0 for now";
|
|
3321
3414
|
function checkReachable(context) {
|
|
3322
3415
|
const { agentCapture, browserCapture, ruleset } = context;
|
|
3323
3416
|
const split = SUBPOINTS.reachable;
|
|
@@ -3327,17 +3420,17 @@ function checkReachable(context) {
|
|
|
3327
3420
|
const sameFinalUrl = browserCapture !== null && browserCapture.finalUrl === agentCapture.finalUrl;
|
|
3328
3421
|
const earned = (status2xx ? split.status2xx : 0) + (withinLimit ? split.withinRedirectLimit : 0) + (sameFinalUrl ? split.noAcceptConditionalRedirect : 0);
|
|
3329
3422
|
const evidence = [
|
|
3330
|
-
measured("
|
|
3331
|
-
measured("
|
|
3423
|
+
measured("Status code AI assistants got", String(agentCapture.status)),
|
|
3424
|
+
measured("Redirects on the way", `${hops} (up to ${ruleset.maxRedirects} allowed)`),
|
|
3332
3425
|
measured(
|
|
3333
|
-
"
|
|
3334
|
-
browserCapture === null ? "not
|
|
3426
|
+
"Same address for AI assistants and browsers",
|
|
3427
|
+
browserCapture === null ? "not checked, because this scan has no browser request to compare" : yesNo(sameFinalUrl)
|
|
3335
3428
|
)
|
|
3336
3429
|
];
|
|
3337
3430
|
return sameFinalUrl ? { earned, evidence } : {
|
|
3338
3431
|
earned,
|
|
3339
3432
|
evidence,
|
|
3340
|
-
remedy: "
|
|
3433
|
+
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
3434
|
};
|
|
3342
3435
|
}
|
|
3343
3436
|
function checkRobotsPolicy(context) {
|
|
@@ -3346,21 +3439,22 @@ function checkRobotsPolicy(context) {
|
|
|
3346
3439
|
const decision = policy.audiences.assistant;
|
|
3347
3440
|
const parsesClean = robots === null || robots.malformedLines === 0;
|
|
3348
3441
|
const noOrphanRules = robots === null || robots.orphanRules === 0;
|
|
3442
|
+
const rule = decision.matchedGroup === null ? "" : ` (User-agent: ${decision.matchedGroup}${decision.matchedRule === null ? "" : `, ${decision.matchedRule}`})`;
|
|
3349
3443
|
const evidence = [
|
|
3350
|
-
measured("robots.txt", policy.robotsTxtStatus),
|
|
3444
|
+
measured("robots.txt", ROBOTS_STATUS[policy.robotsTxtStatus]),
|
|
3351
3445
|
measured(
|
|
3352
|
-
"
|
|
3353
|
-
decision.
|
|
3446
|
+
"AI assistants allowed",
|
|
3447
|
+
decision.decision === "disallow" ? `no${rule}` : decision.matchedGroup === null ? "yes, no rule mentions them" : `yes${rule}`
|
|
3354
3448
|
),
|
|
3355
|
-
measured("
|
|
3449
|
+
measured("Lines that could not be read", robots === null ? "none" : String(robots.malformedLines)),
|
|
3356
3450
|
measured(
|
|
3357
|
-
"Rules
|
|
3358
|
-
robots === null ? "
|
|
3451
|
+
"Rules outside a User-agent group",
|
|
3452
|
+
robots === null ? "none" : String(robots.orphanRules)
|
|
3359
3453
|
),
|
|
3360
|
-
measured("Sitemap
|
|
3454
|
+
measured("Sitemap listed", yesNo(policy.sitemapDeclared)),
|
|
3361
3455
|
measured(
|
|
3362
|
-
"
|
|
3363
|
-
policy.trainingOptOut ? "blocked
|
|
3456
|
+
"AI training crawlers",
|
|
3457
|
+
policy.trainingOptOut ? "blocked, which does not affect this score" : "allowed"
|
|
3364
3458
|
)
|
|
3365
3459
|
];
|
|
3366
3460
|
if (decision.decision === "disallow") {
|
|
@@ -3368,20 +3462,20 @@ function checkRobotsPolicy(context) {
|
|
|
3368
3462
|
id: "robots-contradiction",
|
|
3369
3463
|
severity: "warn",
|
|
3370
3464
|
basis: "measured",
|
|
3371
|
-
message: "robots.txt
|
|
3372
|
-
evidence: [evidence[1] ?? measured("
|
|
3465
|
+
message: "Your robots.txt blocks AI assistants with a rule written for all crawlers. That looks accidental, and it keeps assistants out.",
|
|
3466
|
+
evidence: [evidence[1] ?? measured("AI assistants allowed", "no")]
|
|
3373
3467
|
});
|
|
3374
3468
|
return {
|
|
3375
3469
|
earned: 0,
|
|
3376
3470
|
evidence,
|
|
3377
|
-
remedy: "
|
|
3471
|
+
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
3472
|
};
|
|
3379
3473
|
}
|
|
3380
3474
|
const earned = split.assistantAllowed + (parsesClean ? split.parsesClean : 0) + (noOrphanRules ? split.noOrphanRules : 0) + (policy.sitemapDeclared ? split.sitemapDeclared : 0);
|
|
3381
3475
|
return {
|
|
3382
3476
|
earned,
|
|
3383
3477
|
evidence,
|
|
3384
|
-
remedy: policy.sitemapDeclared ? void 0 : "Add a `Sitemap:` line to robots.txt
|
|
3478
|
+
remedy: policy.sitemapDeclared ? void 0 : "Add a `Sitemap:` line to robots.txt so assistants can find the rest of your pages."
|
|
3385
3479
|
};
|
|
3386
3480
|
}
|
|
3387
3481
|
function checkRenderIndependence(context) {
|
|
@@ -3391,7 +3485,7 @@ function checkRenderIndependence(context) {
|
|
|
3391
3485
|
if (structural === null || structural.doc === null) {
|
|
3392
3486
|
return {
|
|
3393
3487
|
earned: 0,
|
|
3394
|
-
evidence: [heuristic("HTML
|
|
3488
|
+
evidence: [heuristic("HTML page", "not checked, because no HTML was returned")]
|
|
3395
3489
|
};
|
|
3396
3490
|
}
|
|
3397
3491
|
const found = /* @__PURE__ */ new Set();
|
|
@@ -3412,42 +3506,143 @@ function checkRenderIndependence(context) {
|
|
|
3412
3506
|
id: "render-dependent",
|
|
3413
3507
|
severity: "info",
|
|
3414
3508
|
basis: "heuristic",
|
|
3415
|
-
message: `${found.size} of ${coreSize}
|
|
3416
|
-
evidence: [heuristic("
|
|
3509
|
+
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.`,
|
|
3510
|
+
evidence: [heuristic("Key facts in the HTML", `${found.size} of ${coreSize}`)]
|
|
3417
3511
|
});
|
|
3418
3512
|
}
|
|
3419
3513
|
return {
|
|
3420
3514
|
earned,
|
|
3421
3515
|
evidence: [
|
|
3422
|
-
heuristic("
|
|
3423
|
-
heuristic("
|
|
3516
|
+
heuristic("Key facts in the HTML before JavaScript runs", `${found.size} of ${coreSize}`),
|
|
3517
|
+
heuristic("Fallback text for visitors without JavaScript", yesNo(hasNoscript)),
|
|
3424
3518
|
heuristic(
|
|
3425
|
-
"
|
|
3426
|
-
"
|
|
3519
|
+
"How we checked",
|
|
3520
|
+
"we read the HTML your server sends and do not run JavaScript, so facts added by scripts count as missing"
|
|
3427
3521
|
)
|
|
3428
3522
|
],
|
|
3429
|
-
remedy: earned === full ? void 0 : "
|
|
3523
|
+
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
3524
|
};
|
|
3431
3525
|
}
|
|
3432
3526
|
var MACHINE_KINDS = /* @__PURE__ */ new Set(["markdown", "text", "json"]);
|
|
3527
|
+
function isMachineCopy(capture) {
|
|
3528
|
+
const representation = buildRepresentation(capture);
|
|
3529
|
+
return representation !== null && MACHINE_KINDS.has(representation.kind) && !representation.looksLikeHtml;
|
|
3530
|
+
}
|
|
3531
|
+
var MARKDOWN_MEDIA = /* @__PURE__ */ new Set(["text/markdown", "text/x-markdown"]);
|
|
3532
|
+
function isMarkdownType(type) {
|
|
3533
|
+
return type !== null && MARKDOWN_MEDIA.has((type.split(";")[0] ?? "").trim().toLowerCase());
|
|
3534
|
+
}
|
|
3535
|
+
function declaredMarkdownAlternates(captures) {
|
|
3536
|
+
const out = [];
|
|
3537
|
+
const add = (raw, base) => {
|
|
3538
|
+
try {
|
|
3539
|
+
const url = new URL(raw, base);
|
|
3540
|
+
url.hash = "";
|
|
3541
|
+
const href = url.toString();
|
|
3542
|
+
if (!out.includes(href)) out.push(href);
|
|
3543
|
+
} catch {
|
|
3544
|
+
}
|
|
3545
|
+
};
|
|
3546
|
+
for (const capture of captures) {
|
|
3547
|
+
if (capture === null) continue;
|
|
3548
|
+
for (const link of parseLinkHeaders(headerAll(capture.headers, "link"))) {
|
|
3549
|
+
if (link.rel.includes("alternate") && isMarkdownType(link.type)) add(link.url, capture.finalUrl);
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
for (const capture of captures) {
|
|
3553
|
+
if (capture === null) continue;
|
|
3554
|
+
const representation = buildRepresentation(capture);
|
|
3555
|
+
if (representation === null || representation.doc === null) continue;
|
|
3556
|
+
for (const link of representation.doc.links) {
|
|
3557
|
+
if (!link.rel.includes("alternate") || link.href === null) continue;
|
|
3558
|
+
if (isMarkdownType(link.type)) add(link.href, capture.finalUrl);
|
|
3559
|
+
}
|
|
3560
|
+
}
|
|
3561
|
+
return out;
|
|
3562
|
+
}
|
|
3563
|
+
function markdownAlternateTarget(agent, browser, origin) {
|
|
3564
|
+
if (agent === null || agent.status < 200 || agent.status >= 300) return null;
|
|
3565
|
+
if (isMachineCopy(agent)) return null;
|
|
3566
|
+
const own = /* @__PURE__ */ new Set([agent.finalUrl, agent.requestedUrl]);
|
|
3567
|
+
for (const href of declaredMarkdownAlternates([browser, agent])) {
|
|
3568
|
+
let sameOrigin = false;
|
|
3569
|
+
try {
|
|
3570
|
+
sameOrigin = new URL(href).origin === origin;
|
|
3571
|
+
} catch {
|
|
3572
|
+
sameOrigin = false;
|
|
3573
|
+
}
|
|
3574
|
+
if (sameOrigin && !own.has(href)) return href;
|
|
3575
|
+
}
|
|
3576
|
+
return null;
|
|
3577
|
+
}
|
|
3578
|
+
function linkedCopyOf(evidence, agent, browser) {
|
|
3579
|
+
const url = markdownAlternateTarget(agent, browser, evidence.target.origin);
|
|
3580
|
+
if (url === null) return null;
|
|
3581
|
+
const record = evidence.probes.markdownAlternate ?? null;
|
|
3582
|
+
if (record === null) return { url, status: "unchecked", representation: null, reason: null };
|
|
3583
|
+
if (!record.result.ok) {
|
|
3584
|
+
if (record.result.error === "policy-rejected") {
|
|
3585
|
+
return { url, status: "unchecked", representation: null, reason: null };
|
|
3586
|
+
}
|
|
3587
|
+
return { url, status: "broken", representation: null, reason: record.result.error };
|
|
3588
|
+
}
|
|
3589
|
+
const capture = record.result.capture;
|
|
3590
|
+
if (capture.requestedUrl !== url) {
|
|
3591
|
+
return { url, status: "unchecked", representation: null, reason: null };
|
|
3592
|
+
}
|
|
3593
|
+
if (capture.status < 200 || capture.status >= 300) {
|
|
3594
|
+
return { url, status: "broken", representation: null, reason: `HTTP ${capture.status}` };
|
|
3595
|
+
}
|
|
3596
|
+
if (!isMachineCopy(capture)) {
|
|
3597
|
+
return { url, status: "broken", representation: null, reason: "it returned HTML, not Markdown" };
|
|
3598
|
+
}
|
|
3599
|
+
return { url, status: "checked", representation: buildRepresentation(capture), reason: null };
|
|
3600
|
+
}
|
|
3601
|
+
var MEDIA_NAMES = {
|
|
3602
|
+
"text/markdown": "Markdown",
|
|
3603
|
+
"text/x-markdown": "Markdown",
|
|
3604
|
+
"text/html": "HTML",
|
|
3605
|
+
"text/plain": "plain text",
|
|
3606
|
+
"application/json": "JSON",
|
|
3607
|
+
"*/*": "anything else"
|
|
3608
|
+
};
|
|
3609
|
+
function acceptSummary(accept) {
|
|
3610
|
+
const names = [];
|
|
3611
|
+
for (const entry of accept.split(",")) {
|
|
3612
|
+
const type = (entry.split(";")[0] ?? "").trim().toLowerCase();
|
|
3613
|
+
if (type === "") continue;
|
|
3614
|
+
const name = MEDIA_NAMES[type] ?? type;
|
|
3615
|
+
if (!names.includes(name)) names.push(name);
|
|
3616
|
+
}
|
|
3617
|
+
const [first, ...rest] = names;
|
|
3618
|
+
if (first === void 0) return accept;
|
|
3619
|
+
return rest.length === 0 ? first : `${first} first, then ${rest.join(", ")}`;
|
|
3620
|
+
}
|
|
3433
3621
|
function checkNegotiatedResponse(context) {
|
|
3434
|
-
const { agent } = context;
|
|
3622
|
+
const { agent, linkedCopy } = context;
|
|
3435
3623
|
const typeIsMachine = MACHINE_KINDS.has(agent.kind);
|
|
3436
3624
|
const bodyIsHtml = agent.looksLikeHtml;
|
|
3437
|
-
const
|
|
3625
|
+
const linkedWorks = linkedCopy !== null && linkedCopy.status === "checked";
|
|
3626
|
+
const earned = context.negotiated ? SUBPOINTS.negotiatedResponse.full : linkedWorks ? SUBPOINTS.negotiatedResponse.linkedCopy : 0;
|
|
3627
|
+
const asked = context.evidence.probes.agent.requestHeaders["accept"] ?? context.evidence.probes.agent.requestHeaders["Accept"] ?? null;
|
|
3438
3628
|
return {
|
|
3439
3629
|
earned,
|
|
3440
3630
|
evidence: [
|
|
3441
|
-
measured("
|
|
3442
|
-
measured("
|
|
3443
|
-
measured(
|
|
3444
|
-
|
|
3445
|
-
context.evidence.probes.agent.requestHeaders["accept"] ?? context.evidence.probes.agent.requestHeaders["Accept"] ?? "not recorded"
|
|
3446
|
-
)
|
|
3631
|
+
measured("We asked for", asked === null ? "not recorded" : acceptSummary(asked)),
|
|
3632
|
+
measured("Format we got", agent.contentType ?? "not stated"),
|
|
3633
|
+
measured("Content was HTML", yesNo(bodyIsHtml)),
|
|
3634
|
+
...linkedCopy === null ? [] : [measured("Linked Markdown copy", linkedCopyLine(linkedCopy))]
|
|
3447
3635
|
],
|
|
3448
|
-
remedy:
|
|
3636
|
+
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
3637
|
};
|
|
3450
3638
|
}
|
|
3639
|
+
function linkedCopyLine(copy) {
|
|
3640
|
+
if (copy.status === "checked") {
|
|
3641
|
+
return `loaded as Markdown from ${copy.url} (${plainBytes(copy.representation?.bytes ?? 0)})`;
|
|
3642
|
+
}
|
|
3643
|
+
if (copy.status === "broken") return `did not load as Markdown from ${copy.url} (${copy.reason ?? "error"})`;
|
|
3644
|
+
return `linked at ${copy.url}, not checked in this scan`;
|
|
3645
|
+
}
|
|
3451
3646
|
function checkDeclaredAlternates(context) {
|
|
3452
3647
|
const { agentCapture, browserCapture, structural } = context;
|
|
3453
3648
|
const links = parseLinkHeaders([
|
|
@@ -3462,45 +3657,54 @@ function checkDeclaredAlternates(context) {
|
|
|
3462
3657
|
for (const link of structural.doc.links) {
|
|
3463
3658
|
if (!link.rel.includes("alternate")) continue;
|
|
3464
3659
|
if (link.type === null || link.href === null) continue;
|
|
3465
|
-
documentAlternates.push(`${link.type}
|
|
3660
|
+
documentAlternates.push(`${link.type} at ${link.href}`);
|
|
3466
3661
|
}
|
|
3467
3662
|
}
|
|
3468
3663
|
const total = headerAlternates.length + documentAlternates.length;
|
|
3664
|
+
const broken = context.linkedCopy !== null && context.linkedCopy.status === "broken";
|
|
3665
|
+
if (broken && context.linkedCopy !== null) {
|
|
3666
|
+
return {
|
|
3667
|
+
earned: 0,
|
|
3668
|
+
evidence: [measured("Linked Markdown copy", linkedCopyLine(context.linkedCopy))],
|
|
3669
|
+
remedy: `The Markdown copy this page links to did not load (${context.linkedCopy.reason ?? "error"}). Fix the file or the link.`
|
|
3670
|
+
};
|
|
3671
|
+
}
|
|
3469
3672
|
return {
|
|
3470
3673
|
earned: total > 0 ? SUBPOINTS.declaredAlternates.full : 0,
|
|
3471
3674
|
evidence: [
|
|
3472
3675
|
measured(
|
|
3473
|
-
|
|
3474
|
-
headerAlternates.length === 0 ? "none" : headerAlternates.map((link) => `${link.type ?? "?"}
|
|
3676
|
+
"Link header pointing to the Markdown copy",
|
|
3677
|
+
headerAlternates.length === 0 ? "none" : headerAlternates.map((link) => `${link.type ?? "?"} at ${link.url}`).join(", ")
|
|
3475
3678
|
),
|
|
3476
3679
|
measured(
|
|
3477
|
-
|
|
3680
|
+
"Link tag in the page pointing to the Markdown copy",
|
|
3478
3681
|
documentAlternates.length === 0 ? "none" : documentAlternates.join(", ")
|
|
3479
3682
|
)
|
|
3480
3683
|
],
|
|
3481
|
-
remedy: total > 0 ? void 0 : '
|
|
3684
|
+
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
3685
|
};
|
|
3483
3686
|
}
|
|
3484
|
-
function checkVaryAccept(context
|
|
3687
|
+
function checkVaryAccept(context) {
|
|
3688
|
+
const negotiated = context.negotiated;
|
|
3485
3689
|
const { agentCapture, browserCapture } = context;
|
|
3486
3690
|
const agentVary = headerTokens(header(agentCapture.headers, "vary"));
|
|
3487
3691
|
const browserVary = browserCapture === null ? [] : headerTokens(header(browserCapture.headers, "vary"));
|
|
3488
3692
|
const declared = agentVary.includes("accept") || browserVary.includes("accept");
|
|
3489
3693
|
const evidence = [
|
|
3490
|
-
measured("Vary
|
|
3694
|
+
measured("Vary header sent to AI assistants", header(agentCapture.headers, "vary") ?? "not sent"),
|
|
3491
3695
|
measured(
|
|
3492
|
-
"Vary
|
|
3493
|
-
browserCapture === null ? "
|
|
3696
|
+
"Vary header sent to browsers",
|
|
3697
|
+
browserCapture === null ? "not checked" : header(browserCapture.headers, "vary") ?? "not sent"
|
|
3494
3698
|
)
|
|
3495
3699
|
];
|
|
3496
|
-
if (negotiated
|
|
3700
|
+
if (!negotiated) {
|
|
3497
3701
|
return {
|
|
3498
3702
|
earned: 0,
|
|
3499
3703
|
evidence: [
|
|
3500
3704
|
...evidence,
|
|
3501
3705
|
measured(
|
|
3502
|
-
"
|
|
3503
|
-
"
|
|
3706
|
+
"Counts",
|
|
3707
|
+
context.linkedCopy?.status === "checked" ? "only when the page address itself sends the Markdown copy, so 0 for now" : COUNTS_ONCE_COPY
|
|
3504
3708
|
)
|
|
3505
3709
|
]
|
|
3506
3710
|
};
|
|
@@ -3510,17 +3714,27 @@ function checkVaryAccept(context, negotiated) {
|
|
|
3510
3714
|
id: "vary-missing",
|
|
3511
3715
|
severity: "warn",
|
|
3512
3716
|
basis: "measured",
|
|
3513
|
-
message: "
|
|
3717
|
+
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
3718
|
evidence
|
|
3515
3719
|
});
|
|
3516
3720
|
}
|
|
3517
3721
|
return {
|
|
3518
3722
|
earned: declared ? SUBPOINTS.varyAccept.full : 0,
|
|
3519
3723
|
evidence,
|
|
3520
|
-
remedy: declared ? void 0 : "Send `Vary: Accept` on every response from
|
|
3724
|
+
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
3725
|
};
|
|
3522
3726
|
}
|
|
3523
3727
|
var PARITY_KINDS = ["price", "currency", "availability", "title"];
|
|
3728
|
+
function linkedCopyFacts(context, copy) {
|
|
3729
|
+
if (copy.representation === null) return [];
|
|
3730
|
+
return extractFacts(copy.representation, {
|
|
3731
|
+
profile: context.profile,
|
|
3732
|
+
ruleset: context.ruleset,
|
|
3733
|
+
baseUrl: copy.representation.finalUrl,
|
|
3734
|
+
origin: context.evidence.target.origin,
|
|
3735
|
+
currencyHint: currencyHintOf(context.structural, context.agent)
|
|
3736
|
+
});
|
|
3737
|
+
}
|
|
3524
3738
|
function factView(facts) {
|
|
3525
3739
|
const best = /* @__PURE__ */ new Map();
|
|
3526
3740
|
const observed = /* @__PURE__ */ new Map();
|
|
@@ -3556,48 +3770,48 @@ function divergentKinds(left, right, kinds) {
|
|
|
3556
3770
|
}
|
|
3557
3771
|
return { compared, divergent };
|
|
3558
3772
|
}
|
|
3559
|
-
function checkSubstanceParity(context
|
|
3773
|
+
function checkSubstanceParity(context) {
|
|
3560
3774
|
const { agentFacts, browserFacts, browser, evidence: bundle } = context;
|
|
3561
|
-
|
|
3775
|
+
const linked = !context.negotiated && context.linkedCopy?.status === "checked" ? context.linkedCopy : null;
|
|
3776
|
+
const htmlFacts = browser !== null ? browserFacts : agentFacts;
|
|
3777
|
+
if (!context.negotiated && linked === null || linked === null && browser === null) {
|
|
3562
3778
|
return {
|
|
3563
3779
|
earned: 0,
|
|
3564
3780
|
evidence: [
|
|
3565
3781
|
heuristic(
|
|
3566
|
-
"
|
|
3567
|
-
negotiated
|
|
3782
|
+
"Counts",
|
|
3783
|
+
!context.negotiated ? COUNTS_ONCE_COPY : "not checked, because this scan has no browser request to compare"
|
|
3568
3784
|
)
|
|
3569
3785
|
]
|
|
3570
3786
|
};
|
|
3571
3787
|
}
|
|
3572
|
-
const agentValues = factView(agentFacts);
|
|
3573
|
-
const browserValues = factView(browserFacts);
|
|
3788
|
+
const agentValues = factView(linked === null ? agentFacts : linkedCopyFacts(context, linked));
|
|
3789
|
+
const browserValues = factView(linked === null ? browserFacts : htmlFacts);
|
|
3574
3790
|
const { compared, divergent } = divergentKinds(agentValues, browserValues, PARITY_KINDS);
|
|
3575
3791
|
const evidenceLines = [
|
|
3576
3792
|
heuristic(
|
|
3577
|
-
"
|
|
3578
|
-
compared.length === 0 ? "none
|
|
3793
|
+
"Facts compared",
|
|
3794
|
+
compared.length === 0 ? "none appear in both the Markdown copy and the page" : factList(compared)
|
|
3579
3795
|
),
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3796
|
+
...compared.length === 0 ? [] : [
|
|
3797
|
+
heuristic(
|
|
3798
|
+
"Values",
|
|
3799
|
+
divergent.length === 0 ? "match" : divergent.map(
|
|
3800
|
+
(entry) => `${factName(entry.kind)}: Markdown copy ${entry.left}, page ${entry.right}`
|
|
3801
|
+
).join("; ")
|
|
3802
|
+
)
|
|
3803
|
+
]
|
|
3584
3804
|
];
|
|
3585
3805
|
if (compared.length === 0) {
|
|
3586
3806
|
return {
|
|
3587
3807
|
earned: 0,
|
|
3588
|
-
evidence:
|
|
3589
|
-
|
|
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."
|
|
3808
|
+
evidence: evidenceLines,
|
|
3809
|
+
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
3810
|
};
|
|
3597
3811
|
}
|
|
3598
3812
|
if (divergent.length === 0)
|
|
3599
3813
|
return { earned: SUBPOINTS.substanceParity.full, evidence: evidenceLines };
|
|
3600
|
-
const confirm = bundle.probes.parityConfirm;
|
|
3814
|
+
const confirm = linked === null ? bundle.probes.parityConfirm : null;
|
|
3601
3815
|
const confirmCapture = confirm !== null && confirm.result.ok ? confirm.result.capture : null;
|
|
3602
3816
|
const confirmRep = confirmCapture === null ? null : buildRepresentation(confirmCapture);
|
|
3603
3817
|
if (confirmRep === null) {
|
|
@@ -3605,9 +3819,9 @@ function checkSubstanceParity(context, negotiated) {
|
|
|
3605
3819
|
earned: 0,
|
|
3606
3820
|
evidence: [
|
|
3607
3821
|
...evidenceLines,
|
|
3608
|
-
heuristic("
|
|
3822
|
+
heuristic("Second look", "not taken, so this difference was seen once and is not flagged")
|
|
3609
3823
|
],
|
|
3610
|
-
remedy: "The
|
|
3824
|
+
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
3825
|
};
|
|
3612
3826
|
}
|
|
3613
3827
|
const confirmFacts = extractFacts(confirmRep, {
|
|
@@ -3629,8 +3843,8 @@ function checkSubstanceParity(context, negotiated) {
|
|
|
3629
3843
|
evidence: [
|
|
3630
3844
|
...evidenceLines,
|
|
3631
3845
|
heuristic(
|
|
3632
|
-
"
|
|
3633
|
-
"the difference
|
|
3846
|
+
"Second look",
|
|
3847
|
+
"the difference was gone, so we treat it as a value that changed between requests"
|
|
3634
3848
|
)
|
|
3635
3849
|
]
|
|
3636
3850
|
};
|
|
@@ -3640,14 +3854,14 @@ function checkSubstanceParity(context, negotiated) {
|
|
|
3640
3854
|
severity: "warn",
|
|
3641
3855
|
basis: "heuristic",
|
|
3642
3856
|
message: reproduced.divergent.map(
|
|
3643
|
-
(entry) => `The
|
|
3857
|
+
(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
3858
|
).join(" "),
|
|
3645
3859
|
evidence: evidenceLines
|
|
3646
3860
|
});
|
|
3647
3861
|
return {
|
|
3648
3862
|
earned: 0,
|
|
3649
|
-
evidence: [...evidenceLines, heuristic("
|
|
3650
|
-
remedy: "
|
|
3863
|
+
evidence: [...evidenceLines, heuristic("Second look", "the difference was still there")],
|
|
3864
|
+
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
3865
|
};
|
|
3652
3866
|
}
|
|
3653
3867
|
function coverageMath(context) {
|
|
@@ -3689,19 +3903,23 @@ function checkCoreFacts(context, math) {
|
|
|
3689
3903
|
return {
|
|
3690
3904
|
earned,
|
|
3691
3905
|
evidence: [
|
|
3906
|
+
heuristic("Key facts for this kind of page", factList(context.profile.core)),
|
|
3907
|
+
heuristic("Found", `${math.coreFound} of ${context.profile.core.length}`),
|
|
3908
|
+
heuristic("Missing", missing.length === 0 ? "none" : factList(missing)),
|
|
3692
3909
|
heuristic(
|
|
3693
|
-
"
|
|
3694
|
-
`${math.
|
|
3910
|
+
"Extra facts found",
|
|
3911
|
+
`${math.extendedFound} of ${context.profile.extended.length}`
|
|
3695
3912
|
),
|
|
3696
|
-
heuristic("Extended facts found", `${math.extendedFound}/${context.profile.extended.length}`),
|
|
3697
|
-
heuristic("Coverage", `${math.coveragePct}%`),
|
|
3698
3913
|
heuristic(
|
|
3699
|
-
"
|
|
3700
|
-
`${math.
|
|
3914
|
+
"Credit for the facts",
|
|
3915
|
+
`${math.coveragePct}% (a fact stated in both the text and structured data counts in full)`
|
|
3701
3916
|
),
|
|
3702
|
-
|
|
3917
|
+
heuristic(
|
|
3918
|
+
"Credit kept for length",
|
|
3919
|
+
`${math.densityPct}% (${math.coreFound + math.extendedFound} facts in ${plainBytes(context.agent.bytes)}; the more text around each fact, the less is kept)`
|
|
3920
|
+
)
|
|
3703
3921
|
],
|
|
3704
|
-
remedy: missing.length
|
|
3922
|
+
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
3923
|
};
|
|
3706
3924
|
}
|
|
3707
3925
|
function checkContextCost(context) {
|
|
@@ -3714,13 +3932,19 @@ function checkContextCost(context) {
|
|
|
3714
3932
|
earned,
|
|
3715
3933
|
evidence: [
|
|
3716
3934
|
measured(
|
|
3717
|
-
"
|
|
3718
|
-
`${context.agent.bytes}${context.agent.truncated ? " (
|
|
3935
|
+
"Size AI assistants had to read",
|
|
3936
|
+
`${plainBytes(context.agent.bytes)}${context.agent.truncated ? " or more (cut off at the limit)" : ""}`
|
|
3937
|
+
),
|
|
3938
|
+
measured(
|
|
3939
|
+
`Typical size for a ${context.profile.pageKind === "unknown" ? "general" : context.profile.pageKind} page`,
|
|
3940
|
+
plainBytes(reference)
|
|
3719
3941
|
),
|
|
3720
|
-
measured(
|
|
3721
|
-
|
|
3942
|
+
measured(
|
|
3943
|
+
"Compared with typical",
|
|
3944
|
+
ratio <= 100 ? "at or under typical" : `about ${divRoundHalfUp(ratio, 100)} times typical`
|
|
3945
|
+
)
|
|
3722
3946
|
],
|
|
3723
|
-
remedy: earned === full ? void 0 : "
|
|
3947
|
+
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
3948
|
};
|
|
3725
3949
|
}
|
|
3726
3950
|
var QUANTITY = new RegExp(
|
|
@@ -3745,8 +3969,10 @@ function checkQuantities(context) {
|
|
|
3745
3969
|
const full = atLeast(table, Number.MAX_SAFE_INTEGER);
|
|
3746
3970
|
return {
|
|
3747
3971
|
earned,
|
|
3748
|
-
evidence: [
|
|
3749
|
-
|
|
3972
|
+
evidence: [
|
|
3973
|
+
measured("Different numbers an answer could quote", `${count} (prices, sizes, percentages, dates)`)
|
|
3974
|
+
],
|
|
3975
|
+
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
3976
|
};
|
|
3751
3977
|
}
|
|
3752
3978
|
function labelledSegments(context) {
|
|
@@ -3786,8 +4012,8 @@ function checkDefinitions(context) {
|
|
|
3786
4012
|
const full = atLeast(table, Number.MAX_SAFE_INTEGER);
|
|
3787
4013
|
return {
|
|
3788
4014
|
earned,
|
|
3789
|
-
evidence: [heuristic(
|
|
3790
|
-
remedy: earned === full ? void 0 : 'Label your facts. A line
|
|
4015
|
+
evidence: [heuristic('Labelled facts, like "Returns: 60 days"', `${count}`)],
|
|
4016
|
+
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
4017
|
};
|
|
3792
4018
|
}
|
|
3793
4019
|
function checkComparisons(context) {
|
|
@@ -3818,8 +4044,8 @@ function checkComparisons(context) {
|
|
|
3818
4044
|
const full = atLeast(table, Number.MAX_SAFE_INTEGER);
|
|
3819
4045
|
return {
|
|
3820
4046
|
earned,
|
|
3821
|
-
evidence: [measured("
|
|
3822
|
-
remedy: earned === full ? void 0 :
|
|
4047
|
+
evidence: [measured("Table rows that compare options", `${rows}`)],
|
|
4048
|
+
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
4049
|
};
|
|
3824
4050
|
}
|
|
3825
4051
|
function coreOffsets(context) {
|
|
@@ -3833,19 +4059,17 @@ function checkFirstCoreFactOffset(context, offsets) {
|
|
|
3833
4059
|
if (first === void 0) {
|
|
3834
4060
|
return {
|
|
3835
4061
|
earned: 0,
|
|
3836
|
-
evidence: [heuristic("First
|
|
4062
|
+
evidence: [heuristic("First key fact", "none found, so there is nothing to place")]
|
|
3837
4063
|
};
|
|
3838
4064
|
}
|
|
4065
|
+
const firstKind = context.facts.find((fact) => fact.offset === first)?.kind;
|
|
3839
4066
|
return {
|
|
3840
4067
|
earned: atMost(context.ruleset.thresholds["fact-position.first-core-fact-offset"], first),
|
|
3841
4068
|
evidence: [
|
|
3842
|
-
measured("
|
|
3843
|
-
heuristic(
|
|
3844
|
-
"Which fact",
|
|
3845
|
-
context.facts.find((fact) => fact.offset === first)?.kind ?? "unknown"
|
|
3846
|
-
)
|
|
4069
|
+
measured("First key fact appears", first === 0 ? "at the very start" : `after ${plainBytes(first)}`),
|
|
4070
|
+
heuristic("Which fact", firstKind === void 0 ? "unknown" : factName(firstKind))
|
|
3847
4071
|
],
|
|
3848
|
-
remedy: first <= 512 ? void 0 : "
|
|
4072
|
+
remedy: first <= 512 ? void 0 : "Put the key facts near the top of what AI assistants receive. Assistants often read only the start."
|
|
3849
4073
|
};
|
|
3850
4074
|
}
|
|
3851
4075
|
function checkFrontWindow(context, offsets) {
|
|
@@ -3857,8 +4081,8 @@ function checkFrontWindow(context, offsets) {
|
|
|
3857
4081
|
return {
|
|
3858
4082
|
earned: 0,
|
|
3859
4083
|
evidence: [
|
|
3860
|
-
measured("
|
|
3861
|
-
heuristic("
|
|
4084
|
+
measured("Opening section", `the first ${plainBytes(size)}`),
|
|
4085
|
+
heuristic("Key facts in it", "none found, so there is nothing to place")
|
|
3862
4086
|
]
|
|
3863
4087
|
};
|
|
3864
4088
|
}
|
|
@@ -3867,11 +4091,13 @@ function checkFrontWindow(context, offsets) {
|
|
|
3867
4091
|
return {
|
|
3868
4092
|
earned: atLeast(context.ruleset.thresholds["fact-position.front-window"], pct),
|
|
3869
4093
|
evidence: [
|
|
3870
|
-
measured(
|
|
3871
|
-
|
|
3872
|
-
|
|
4094
|
+
measured(
|
|
4095
|
+
"Opening section",
|
|
4096
|
+
`the first ${plainBytes(size)} (a ${divisor === 5 ? "fifth" : `1/${divisor}`} of the page, at least ${plainBytes(floor)})`
|
|
4097
|
+
),
|
|
4098
|
+
heuristic("Key facts in it", `${inside} of the ${offsets.length} found (${pct}%)`)
|
|
3873
4099
|
],
|
|
3874
|
-
remedy: pct >= 90 ? void 0 : "
|
|
4100
|
+
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
4101
|
};
|
|
3876
4102
|
}
|
|
3877
4103
|
function checkStructuredDataPresent(context) {
|
|
@@ -3880,7 +4106,7 @@ function checkStructuredDataPresent(context) {
|
|
|
3880
4106
|
if (structural === null) {
|
|
3881
4107
|
return {
|
|
3882
4108
|
earned: 0,
|
|
3883
|
-
evidence: [measured("HTML
|
|
4109
|
+
evidence: [measured("HTML page", "not checked, because no HTML was returned")]
|
|
3884
4110
|
};
|
|
3885
4111
|
}
|
|
3886
4112
|
const { blocks, parsed } = structural.jsonLd;
|
|
@@ -3898,11 +4124,11 @@ function checkStructuredDataPresent(context) {
|
|
|
3898
4124
|
return {
|
|
3899
4125
|
earned,
|
|
3900
4126
|
evidence: [
|
|
3901
|
-
measured("JSON-LD blocks", `${parsed} of ${blocks}
|
|
3902
|
-
measured("Microdata
|
|
3903
|
-
measured("RDFa
|
|
4127
|
+
measured("JSON-LD blocks that could be read", `${parsed} of ${blocks}`),
|
|
4128
|
+
measured("Microdata items", String(microdata)),
|
|
4129
|
+
measured("RDFa items", String(rdfa))
|
|
3904
4130
|
],
|
|
3905
|
-
remedy: earned === split.clean ? void 0 : blocks > parsed ? "
|
|
4131
|
+
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
4132
|
};
|
|
3907
4133
|
}
|
|
3908
4134
|
function scoredNode(context) {
|
|
@@ -3920,14 +4146,11 @@ function checkRequiredProperties(context) {
|
|
|
3920
4146
|
return {
|
|
3921
4147
|
earned: 0,
|
|
3922
4148
|
evidence: [
|
|
3923
|
-
measured("
|
|
3924
|
-
measured("
|
|
3925
|
-
measured(
|
|
3926
|
-
"Scope",
|
|
3927
|
-
"JSON-LD only in 0.1 \u2014 microdata satisfies D5.1 but is not walked for required properties"
|
|
3928
|
-
)
|
|
4149
|
+
measured("Schema.org type", "none found"),
|
|
4150
|
+
measured("Properties we look for", required.join(", ") || "none"),
|
|
4151
|
+
measured("Where we look", "JSON-LD. Microdata counts toward the check above, not this one.")
|
|
3929
4152
|
],
|
|
3930
|
-
remedy:
|
|
4153
|
+
remedy: "Give the JSON-LD a schema.org type that matches the page, such as Product, LocalBusiness or Article, with the properties listed."
|
|
3931
4154
|
};
|
|
3932
4155
|
}
|
|
3933
4156
|
const satisfied = required.filter((path) => hasPath(node, path));
|
|
@@ -3936,14 +4159,11 @@ function checkRequiredProperties(context) {
|
|
|
3936
4159
|
return {
|
|
3937
4160
|
earned: split.recognisedType + completeness,
|
|
3938
4161
|
evidence: [
|
|
3939
|
-
measured("
|
|
3940
|
-
measured(
|
|
3941
|
-
|
|
3942
|
-
`${satisfied.length}/${required.length}${missing.length === 0 ? "" : ` \u2014 missing ${missing.join(", ")}`}`
|
|
3943
|
-
),
|
|
3944
|
-
measured("Table", `ruleset.requiredProperties.${context.profile.pageKind}`)
|
|
4162
|
+
measured("Schema.org type", node.types.join(", ")),
|
|
4163
|
+
measured("Properties present", `${satisfied.length} of ${required.length}`),
|
|
4164
|
+
measured("Missing", missing.length === 0 ? "none" : missing.join(", "))
|
|
3945
4165
|
],
|
|
3946
|
-
remedy: missing.length === 0 ? void 0 : `Add ${missing.join(", ")} to the ${node.types[0] ?? "
|
|
4166
|
+
remedy: missing.length === 0 ? void 0 : `Add ${missing.join(", ")} to the ${node.types[0] ?? "main"} item in your JSON-LD.`
|
|
3947
4167
|
};
|
|
3948
4168
|
}
|
|
3949
4169
|
function checkTextAgreement(context) {
|
|
@@ -3953,19 +4173,23 @@ function checkTextAgreement(context) {
|
|
|
3953
4173
|
const { compared, divergent } = divergentKinds(fromJsonLd, fromPage, PARITY_KINDS);
|
|
3954
4174
|
const evidenceLines = [
|
|
3955
4175
|
heuristic(
|
|
3956
|
-
"
|
|
3957
|
-
compared.length === 0 ? "none
|
|
4176
|
+
"Facts compared",
|
|
4177
|
+
compared.length === 0 ? "none appear in both the structured data and the page text" : factList(compared)
|
|
3958
4178
|
),
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
4179
|
+
...compared.length === 0 ? [] : [
|
|
4180
|
+
heuristic(
|
|
4181
|
+
"Values",
|
|
4182
|
+
divergent.length === 0 ? "match" : divergent.map(
|
|
4183
|
+
(entry) => `${factName(entry.kind)}: structured data ${entry.left}, page ${entry.right}`
|
|
4184
|
+
).join("; ")
|
|
4185
|
+
)
|
|
4186
|
+
]
|
|
3963
4187
|
];
|
|
3964
4188
|
if (compared.length === 0) {
|
|
3965
4189
|
return {
|
|
3966
4190
|
earned: 0,
|
|
3967
|
-
evidence:
|
|
3968
|
-
remedy: "State the
|
|
4191
|
+
evidence: evidenceLines,
|
|
4192
|
+
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
4193
|
};
|
|
3970
4194
|
}
|
|
3971
4195
|
if (divergent.length > 0) {
|
|
@@ -3974,14 +4198,14 @@ function checkTextAgreement(context) {
|
|
|
3974
4198
|
severity: "warn",
|
|
3975
4199
|
basis: "heuristic",
|
|
3976
4200
|
message: divergent.map(
|
|
3977
|
-
(entry) => `The structured data
|
|
4201
|
+
(entry) => `The structured data says ${factName(entry.kind)} ${entry.left}; the visible page says ${entry.right}.`
|
|
3978
4202
|
).join(" "),
|
|
3979
4203
|
evidence: evidenceLines
|
|
3980
4204
|
});
|
|
3981
4205
|
return {
|
|
3982
4206
|
earned: 0,
|
|
3983
4207
|
evidence: evidenceLines,
|
|
3984
|
-
remedy: "
|
|
4208
|
+
remedy: "Build the structured data from the same source as the visible page, so the two cannot disagree."
|
|
3985
4209
|
};
|
|
3986
4210
|
}
|
|
3987
4211
|
return { earned: SUBPOINTS.textAgreement.full, evidence: evidenceLines };
|
|
@@ -4011,22 +4235,22 @@ function checkCanonical(context) {
|
|
|
4011
4235
|
id: "canonical-mismatch",
|
|
4012
4236
|
severity: "warn",
|
|
4013
4237
|
basis: "measured",
|
|
4014
|
-
message: `The
|
|
4238
|
+
message: `The Markdown copy and the HTML page name different main addresses: ${agentCanonical} and ${htmlCanonical}.`,
|
|
4015
4239
|
evidence: [
|
|
4016
|
-
measured("
|
|
4017
|
-
measured("HTML
|
|
4240
|
+
measured("Main address given to AI assistants", agentCanonical),
|
|
4241
|
+
measured("Main address in the HTML", htmlCanonical)
|
|
4018
4242
|
]
|
|
4019
4243
|
});
|
|
4020
4244
|
}
|
|
4021
4245
|
return {
|
|
4022
4246
|
earned: (present ? split.present : 0) + (absolute ? split.absolute : 0) + (consistent ? split.consistentAcrossProbes : 0),
|
|
4023
4247
|
evidence: [
|
|
4024
|
-
measured("Canonical
|
|
4025
|
-
measured("Canonical
|
|
4026
|
-
measured("
|
|
4027
|
-
measured("Same
|
|
4248
|
+
measured("Canonical address in the HTML", htmlCanonical ?? "none"),
|
|
4249
|
+
measured("Canonical address AI assistants got", agentCanonical ?? "none"),
|
|
4250
|
+
measured("Full address with https://", yesNo(absolute)),
|
|
4251
|
+
measured("Same for AI assistants and browsers", yesNo(consistent))
|
|
4028
4252
|
],
|
|
4029
|
-
remedy: consistent ? void 0 :
|
|
4253
|
+
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
4254
|
};
|
|
4031
4255
|
}
|
|
4032
4256
|
function checkCacheValidators(context) {
|
|
@@ -4046,11 +4270,11 @@ function checkCacheValidators(context) {
|
|
|
4046
4270
|
return {
|
|
4047
4271
|
earned: (sane ? split.saneCacheControl : 0) + (validator ? split.validator : 0),
|
|
4048
4272
|
evidence: [
|
|
4049
|
-
measured("Cache-Control", cacheControl ?? "
|
|
4050
|
-
measured("ETag", etag ?? "
|
|
4051
|
-
measured("Last-Modified", lastModified ?? "
|
|
4273
|
+
measured("Cache-Control header", cacheControl ?? "not sent"),
|
|
4274
|
+
measured("ETag header", etag ?? "not sent"),
|
|
4275
|
+
measured("Last-Modified header", lastModified ?? "not sent")
|
|
4052
4276
|
],
|
|
4053
|
-
remedy: sane && validator ? void 0 : "Send a `Cache-Control`
|
|
4277
|
+
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
4278
|
};
|
|
4055
4279
|
}
|
|
4056
4280
|
function bodyOf(probe) {
|
|
@@ -4066,8 +4290,8 @@ function checkLlmsTxt(context) {
|
|
|
4066
4290
|
if (body === null || body.trim().length === 0) {
|
|
4067
4291
|
return {
|
|
4068
4292
|
earned: 0,
|
|
4069
|
-
evidence: [measured("/llms.txt", body === null ? "
|
|
4070
|
-
remedy: "Publish /llms.txt
|
|
4293
|
+
evidence: [measured("/llms.txt", body === null ? "not found" : "empty")],
|
|
4294
|
+
remedy: "Publish /llms.txt with a `#` title, a short summary and links to your main pages."
|
|
4071
4295
|
};
|
|
4072
4296
|
}
|
|
4073
4297
|
const hasTitle = /^#\s+\S/m.test(body);
|
|
@@ -4077,24 +4301,24 @@ function checkLlmsTxt(context) {
|
|
|
4077
4301
|
return {
|
|
4078
4302
|
earned: specShaped ? split.specShaped : split.present,
|
|
4079
4303
|
evidence: [
|
|
4080
|
-
measured("/llms.txt",
|
|
4081
|
-
measured("
|
|
4082
|
-
measured("
|
|
4304
|
+
measured("/llms.txt", `found, ${body.length} characters`),
|
|
4305
|
+
measured("Has a # title", yesNo(hasTitle)),
|
|
4306
|
+
measured("Has links", yesNo(hasLinks))
|
|
4083
4307
|
],
|
|
4084
|
-
remedy: specShaped ? void 0 : "
|
|
4308
|
+
remedy: specShaped ? void 0 : "Start /llms.txt with a `#` title and add at least one link written as `[name](url)`."
|
|
4085
4309
|
};
|
|
4086
4310
|
}
|
|
4087
4311
|
function checkSitemap(context) {
|
|
4088
4312
|
return {
|
|
4089
4313
|
earned: context.policy.sitemapDeclared ? SUBPOINTS.sitemap.full : 0,
|
|
4090
4314
|
evidence: [
|
|
4091
|
-
measured("Sitemap
|
|
4315
|
+
measured("Sitemap listed in robots.txt", yesNo(context.policy.sitemapDeclared)),
|
|
4092
4316
|
measured(
|
|
4093
|
-
"Sitemaps
|
|
4094
|
-
context.robots === null ? "
|
|
4317
|
+
"Sitemaps",
|
|
4318
|
+
context.robots === null ? "none" : context.robots.sitemaps.join(", ") || "none"
|
|
4095
4319
|
)
|
|
4096
4320
|
],
|
|
4097
|
-
remedy: context.policy.sitemapDeclared ? void 0 : "
|
|
4321
|
+
remedy: context.policy.sitemapDeclared ? void 0 : "Add a line like `Sitemap: https://example.com/sitemap.xml` to robots.txt."
|
|
4098
4322
|
};
|
|
4099
4323
|
}
|
|
4100
4324
|
var ENDPOINT_TYPES = [
|
|
@@ -4137,17 +4361,17 @@ function checkMachineEndpoint(context) {
|
|
|
4137
4361
|
]);
|
|
4138
4362
|
for (const link of links) {
|
|
4139
4363
|
if (link.rel.some((rel) => ENDPOINT_RELS.includes(rel)))
|
|
4140
|
-
declarations.push(`Link
|
|
4364
|
+
declarations.push(`Link header (${link.rel.join(" ")}) at ${link.url}`);
|
|
4141
4365
|
else if (link.type !== null && ENDPOINT_TYPES.includes(link.type))
|
|
4142
|
-
declarations.push(`Link
|
|
4366
|
+
declarations.push(`Link header (${link.type}) at ${link.url}`);
|
|
4143
4367
|
}
|
|
4144
4368
|
if (context.structural !== null && context.structural.doc !== null) {
|
|
4145
4369
|
for (const link of context.structural.doc.links) {
|
|
4146
4370
|
if (link.href === null) continue;
|
|
4147
4371
|
if (link.rel.some((rel) => ENDPOINT_RELS.includes(rel)))
|
|
4148
|
-
declarations.push(
|
|
4372
|
+
declarations.push(`link tag (${link.rel.join(" ")}) at ${link.href}`);
|
|
4149
4373
|
else if (link.type !== null && ENDPOINT_TYPES.includes(link.type))
|
|
4150
|
-
declarations.push(
|
|
4374
|
+
declarations.push(`link tag (${link.type}) at ${link.href}`);
|
|
4151
4375
|
}
|
|
4152
4376
|
}
|
|
4153
4377
|
const llms = bodyOf(context.evidence.probes.llmsTxt);
|
|
@@ -4157,21 +4381,19 @@ function checkMachineEndpoint(context) {
|
|
|
4157
4381
|
while ((match = MARKDOWN_LINK.exec(llms)) !== null) {
|
|
4158
4382
|
const url = (match[1] ?? "").toLowerCase();
|
|
4159
4383
|
if (ENDPOINT_PATH_MARKERS.some((marker) => url.includes(marker)))
|
|
4160
|
-
declarations.push(`llms.txt
|
|
4384
|
+
declarations.push(`llms.txt link to ${match?.[1] ?? url}`);
|
|
4161
4385
|
}
|
|
4162
4386
|
}
|
|
4163
4387
|
const ucp = bodyOf(context.evidence.probes.wellKnownUcp);
|
|
4164
4388
|
if (ucp !== null && ucp.trim().length > 0) declarations.push("/.well-known/ucp");
|
|
4389
|
+
const unique = [...new Set(declarations)];
|
|
4165
4390
|
return {
|
|
4166
4391
|
earned: declarations.length > 0 ? SUBPOINTS.machineEndpoint.full : 0,
|
|
4167
4392
|
evidence: [
|
|
4168
|
-
measured(
|
|
4169
|
-
|
|
4170
|
-
declarations.length === 0 ? "none" : declarations.join("; ")
|
|
4171
|
-
),
|
|
4172
|
-
measured("Probed paths", "/robots.txt, /llms.txt, /.well-known/ucp \u2014 ARS probes no others")
|
|
4393
|
+
measured("Feeds or APIs we found", unique.length === 0 ? "none" : unique.join("; ")),
|
|
4394
|
+
measured("Where we looked", "link tags, Link headers, /llms.txt and /.well-known/ucp")
|
|
4173
4395
|
],
|
|
4174
|
-
remedy: declarations.length > 0 ? void 0 : "
|
|
4396
|
+
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
4397
|
};
|
|
4176
4398
|
}
|
|
4177
4399
|
function weightOf(ruleset, id) {
|
|
@@ -4376,7 +4598,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4376
4598
|
id: "training-opt-out",
|
|
4377
4599
|
severity: "info",
|
|
4378
4600
|
basis: "measured",
|
|
4379
|
-
message: "This site blocks
|
|
4601
|
+
message: "This site blocks AI training crawlers but lets AI assistants in. That does not affect the score.",
|
|
4380
4602
|
evidence: [
|
|
4381
4603
|
measured("Training audience", policy.audiences.training.matchedRule ?? "disallowed"),
|
|
4382
4604
|
measured("Effect on this score", "none")
|
|
@@ -4390,7 +4612,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4390
4612
|
id: "scanner-blocked",
|
|
4391
4613
|
severity: "info",
|
|
4392
4614
|
basis: "measured",
|
|
4393
|
-
message: "robots.txt
|
|
4615
|
+
message: "robots.txt asks Rebilder\u2019s scanner not to read this site, so we did not score the page.",
|
|
4394
4616
|
evidence: [measured("Matched rule", scannerDecision)]
|
|
4395
4617
|
});
|
|
4396
4618
|
return nonGrade(
|
|
@@ -4418,7 +4640,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4418
4640
|
id: "assistant-opt-out",
|
|
4419
4641
|
severity: "info",
|
|
4420
4642
|
basis: "measured",
|
|
4421
|
-
message: "This site
|
|
4643
|
+
message: "This site\u2019s robots.txt blocks AI assistants by name. We respect that choice and do not grade the page.",
|
|
4422
4644
|
evidence: [
|
|
4423
4645
|
measured("Matched group", policy.audiences.assistant.matchedGroup ?? "(named group)"),
|
|
4424
4646
|
measured("Matched rule", policy.audiences.assistant.matchedRule ?? "Disallow")
|
|
@@ -4441,7 +4663,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4441
4663
|
id: "scanner-blocked",
|
|
4442
4664
|
severity: "warn",
|
|
4443
4665
|
basis: "measured",
|
|
4444
|
-
message: "The
|
|
4666
|
+
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
4667
|
evidence: [measured("Probe error", agentProbe.result.error)]
|
|
4446
4668
|
});
|
|
4447
4669
|
}
|
|
@@ -4461,7 +4683,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4461
4683
|
id: "scanner-blocked",
|
|
4462
4684
|
severity: "warn",
|
|
4463
4685
|
basis: "measured",
|
|
4464
|
-
message: `The
|
|
4686
|
+
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
4687
|
evidence: [measured("HTTP status", String(agentCapture.status))]
|
|
4466
4688
|
});
|
|
4467
4689
|
return nonGrade(
|
|
@@ -4503,7 +4725,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4503
4725
|
id: "body-truncated",
|
|
4504
4726
|
severity: "warn",
|
|
4505
4727
|
basis: "measured",
|
|
4506
|
-
message: `
|
|
4728
|
+
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
4729
|
evidence: [
|
|
4508
4730
|
measured("Body cap", `${ruleset.maxBodyBytes} bytes`),
|
|
4509
4731
|
measured("Bytes read", `\u2265 ${agentCapture.bytes}`)
|
|
@@ -4549,7 +4771,10 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4549
4771
|
const browserFacts = browser === null || browser === agent ? [] : extractFacts(browser, { ...extractContext, baseUrl: browser.finalUrl });
|
|
4550
4772
|
const structuralFacts = structural === agent ? agentFacts : structural === browser ? browserFacts : [];
|
|
4551
4773
|
const facts = mergeFacts(agentFacts, structuralFacts);
|
|
4774
|
+
const negotiated = isMachineCopy(agentCapture);
|
|
4552
4775
|
const context = {
|
|
4776
|
+
negotiated,
|
|
4777
|
+
linkedCopy: negotiated ? null : linkedCopyOf(evidence, agentCapture, browserCapture),
|
|
4553
4778
|
evidence,
|
|
4554
4779
|
ruleset,
|
|
4555
4780
|
agentCapture,
|
|
@@ -4572,18 +4797,18 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4572
4797
|
id: "paywalled",
|
|
4573
4798
|
severity: "info",
|
|
4574
4799
|
basis: "measured",
|
|
4575
|
-
message: `This page
|
|
4800
|
+
message: `This page says it is behind a paywall (${paywall}). We scored the part we were shown.`,
|
|
4576
4801
|
evidence: [measured("Paywall signal", paywall)]
|
|
4577
4802
|
});
|
|
4578
4803
|
}
|
|
4579
4804
|
const math = coverageMath(context);
|
|
4580
4805
|
const offsets = coreOffsets(context);
|
|
4581
|
-
const
|
|
4806
|
+
const negotiatedResponse = checkNegotiatedResponse(context);
|
|
4582
4807
|
const checks = [
|
|
4583
4808
|
buildCheck(ruleset, "retrievability.reachable", checkReachable(context)),
|
|
4584
4809
|
buildCheck(ruleset, "retrievability.robots-policy", checkRobotsPolicy(context)),
|
|
4585
4810
|
buildCheck(ruleset, "retrievability.render-independence", checkRenderIndependence(context)),
|
|
4586
|
-
buildCheck(ruleset, "machine-representation.negotiated-response",
|
|
4811
|
+
buildCheck(ruleset, "machine-representation.negotiated-response", negotiatedResponse),
|
|
4587
4812
|
buildCheck(
|
|
4588
4813
|
ruleset,
|
|
4589
4814
|
"machine-representation.declared-alternates",
|
|
@@ -4592,12 +4817,12 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4592
4817
|
buildCheck(
|
|
4593
4818
|
ruleset,
|
|
4594
4819
|
"machine-representation.vary-accept",
|
|
4595
|
-
checkVaryAccept(context
|
|
4820
|
+
checkVaryAccept(context)
|
|
4596
4821
|
),
|
|
4597
4822
|
buildCheck(
|
|
4598
4823
|
ruleset,
|
|
4599
4824
|
"machine-representation.substance-parity",
|
|
4600
|
-
checkSubstanceParity(context
|
|
4825
|
+
checkSubstanceParity(context)
|
|
4601
4826
|
),
|
|
4602
4827
|
buildCheck(ruleset, "fact-coverage.core-facts", checkCoreFacts(context, math)),
|
|
4603
4828
|
buildCheck(ruleset, "fact-coverage.context-cost", checkContextCost(context)),
|
|
@@ -4625,7 +4850,7 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4625
4850
|
const grade = band?.grade ?? "F";
|
|
4626
4851
|
const perToken = ruleset.thresholds["cost.approx-bytes-per-token"]?.[0] ?? 4;
|
|
4627
4852
|
const htmlBytes = structural?.bytes ?? agent.bytes;
|
|
4628
|
-
const negotiatedBytes = negotiated
|
|
4853
|
+
const negotiatedBytes = negotiated ? agent.bytes : null;
|
|
4629
4854
|
const cost = {
|
|
4630
4855
|
htmlBytes,
|
|
4631
4856
|
negotiatedBytes,
|
|
@@ -4723,6 +4948,843 @@ function robotsDisallowsScanner(robotsBody, path) {
|
|
|
4723
4948
|
return null;
|
|
4724
4949
|
}
|
|
4725
4950
|
|
|
4951
|
+
// src/site-signals.ts
|
|
4952
|
+
var EDGE_CHALLENGE_VENDOR_LABEL = {
|
|
4953
|
+
cloudflare: "Cloudflare",
|
|
4954
|
+
vercel: "Vercel",
|
|
4955
|
+
datadome: "DataDome",
|
|
4956
|
+
human: "HUMAN"
|
|
4957
|
+
};
|
|
4958
|
+
var BODY_SCAN_CHARS = 256 * 1024;
|
|
4959
|
+
function headerValues(input, name) {
|
|
4960
|
+
const direct = input.headers[name];
|
|
4961
|
+
if (direct !== void 0) return direct.map((value) => value.toLowerCase());
|
|
4962
|
+
const target = name.toLowerCase();
|
|
4963
|
+
const out = [];
|
|
4964
|
+
for (const [key, values] of Object.entries(input.headers)) {
|
|
4965
|
+
if (key.toLowerCase() === target) {
|
|
4966
|
+
for (const value of values) out.push(value.toLowerCase());
|
|
4967
|
+
}
|
|
4968
|
+
}
|
|
4969
|
+
return out;
|
|
4970
|
+
}
|
|
4971
|
+
function hasToken(values, token) {
|
|
4972
|
+
return values.some(
|
|
4973
|
+
(value) => value.split(",").map((part) => part.trim()).includes(token)
|
|
4974
|
+
);
|
|
4975
|
+
}
|
|
4976
|
+
function isRobotsTxtTarget(input) {
|
|
4977
|
+
for (const raw of [input.requestedUrl, input.finalUrl]) {
|
|
4978
|
+
if (typeof raw !== "string" || raw.length === 0) continue;
|
|
4979
|
+
try {
|
|
4980
|
+
if (new URL(raw).pathname.toLowerCase() === "/robots.txt") return true;
|
|
4981
|
+
} catch {
|
|
4982
|
+
const path = (raw.split("#")[0]?.split("?")[0] ?? "").toLowerCase();
|
|
4983
|
+
if (path === "/robots.txt" || path.endsWith("/robots.txt")) return true;
|
|
4984
|
+
}
|
|
4985
|
+
}
|
|
4986
|
+
return false;
|
|
4987
|
+
}
|
|
4988
|
+
function detectEdgeChallenge(input) {
|
|
4989
|
+
const status = input.status;
|
|
4990
|
+
const body = typeof input.body === "string" ? input.body.slice(0, BODY_SCAN_CHARS) : "";
|
|
4991
|
+
const server = headerValues(input, "server");
|
|
4992
|
+
const contentTypes = headerValues(input, "content-type");
|
|
4993
|
+
const isHtmlContent = contentTypes.some(
|
|
4994
|
+
(value) => value.includes("text/html") || value.includes("application/xhtml+xml")
|
|
4995
|
+
);
|
|
4996
|
+
const lowerBodyHead = body.slice(0, 4096).toLowerCase();
|
|
4997
|
+
const isPlainTextWithoutMarkup = contentTypes.some((value) => value.includes("text/plain")) && !lowerBodyHead.includes("<html") && !lowerBodyHead.includes("<script") && !lowerBodyHead.includes("<!doctype html");
|
|
4998
|
+
const isRobotsHtmlChallenge = isRobotsTxtTarget(input) && isHtmlContent;
|
|
4999
|
+
if (hasToken(headerValues(input, "cf-mitigated"), "challenge")) {
|
|
5000
|
+
return { vendor: "cloudflare", signal: "cf-mitigated: challenge", status };
|
|
5001
|
+
}
|
|
5002
|
+
if ((status === 403 || status === 429 || status === 503 || isRobotsHtmlChallenge && status === 200) && !isPlainTextWithoutMarkup && server.some((value) => value.includes("cloudflare")) && body.includes("/cdn-cgi/challenge-platform/")) {
|
|
5003
|
+
return { vendor: "cloudflare", signal: "Cloudflare challenge page", status };
|
|
5004
|
+
}
|
|
5005
|
+
if (hasToken(headerValues(input, "x-vercel-mitigated"), "challenge")) {
|
|
5006
|
+
return { vendor: "vercel", signal: "x-vercel-mitigated: challenge", status };
|
|
5007
|
+
}
|
|
5008
|
+
if ((status < 200 || status >= 300 || isRobotsHtmlChallenge && status === 200) && !isPlainTextWithoutMarkup && server.some((value) => value.includes("vercel")) && body.includes("Vercel Security Checkpoint")) {
|
|
5009
|
+
return { vendor: "vercel", signal: "Vercel Security Checkpoint page", status };
|
|
5010
|
+
}
|
|
5011
|
+
if ((status === 401 || status === 403) && headerValues(input, "x-datadome").length > 0) {
|
|
5012
|
+
return { vendor: "datadome", signal: `x-datadome with HTTP ${status}`, status };
|
|
5013
|
+
}
|
|
5014
|
+
if ((status === 403 || status === 429 || isRobotsHtmlChallenge && status === 200) && !isPlainTextWithoutMarkup && body.includes("px-captcha") && body.includes("_pxAppId")) {
|
|
5015
|
+
return { vendor: "human", signal: "HUMAN block page", status };
|
|
5016
|
+
}
|
|
5017
|
+
return null;
|
|
5018
|
+
}
|
|
5019
|
+
var DETAIL_PREFIX = "edge-challenge";
|
|
5020
|
+
var DETAIL_PATTERN = /^edge-challenge; vendor=([a-z]+); status=(\d{3}); signal=(.{1,120})$/;
|
|
5021
|
+
function challengeDetail(challenge) {
|
|
5022
|
+
return `${DETAIL_PREFIX}; vendor=${challenge.vendor}; status=${challenge.status}; signal=${challenge.signal.slice(0, 120)}`;
|
|
5023
|
+
}
|
|
5024
|
+
function parseChallengeDetail(detail) {
|
|
5025
|
+
if (typeof detail !== "string") return null;
|
|
5026
|
+
const match = DETAIL_PATTERN.exec(detail);
|
|
5027
|
+
if (match === null) return null;
|
|
5028
|
+
const vendor = match[1];
|
|
5029
|
+
if (!(vendor in EDGE_CHALLENGE_VENDOR_LABEL)) return null;
|
|
5030
|
+
return { vendor, status: Number(match[2]), signal: match[3] ?? "" };
|
|
5031
|
+
}
|
|
5032
|
+
function edgeChallengeOf(evidence) {
|
|
5033
|
+
if (typeof evidence !== "object" || evidence === null) return null;
|
|
5034
|
+
const agent = evidence.probes?.agent?.result;
|
|
5035
|
+
if (typeof agent !== "object" || agent === null) return null;
|
|
5036
|
+
const result = agent;
|
|
5037
|
+
if (result.ok !== false || result.error !== "challenge") return null;
|
|
5038
|
+
return parseChallengeDetail(result.detail);
|
|
5039
|
+
}
|
|
5040
|
+
function robotsEdgeChallengeOf(evidence) {
|
|
5041
|
+
if (typeof evidence !== "object" || evidence === null) return null;
|
|
5042
|
+
const robots = evidence.probes?.robotsTxt?.result;
|
|
5043
|
+
if (typeof robots !== "object" || robots === null) return null;
|
|
5044
|
+
const result = robots;
|
|
5045
|
+
if (result.ok === false && result.error === "challenge") {
|
|
5046
|
+
return parseChallengeDetail(result.detail);
|
|
5047
|
+
}
|
|
5048
|
+
if (result.ok === true && result.capture !== void 0 && typeof result.capture === "object") {
|
|
5049
|
+
return detectEdgeChallenge(result.capture);
|
|
5050
|
+
}
|
|
5051
|
+
return null;
|
|
5052
|
+
}
|
|
5053
|
+
var CLOUDFLARE_MANAGED_MARKER = "# begin cloudflare managed content";
|
|
5054
|
+
function parseContentSignals(robotsTxt) {
|
|
5055
|
+
let cloudflareManaged = false;
|
|
5056
|
+
const rules = [];
|
|
5057
|
+
let currentAgents = [];
|
|
5058
|
+
let openingGroup = false;
|
|
5059
|
+
for (const rawLine of robotsTxt.split(/\r?\n/)) {
|
|
5060
|
+
const trimmedRaw = rawLine.trim();
|
|
5061
|
+
if (trimmedRaw.toLowerCase().includes(CLOUDFLARE_MANAGED_MARKER)) {
|
|
5062
|
+
cloudflareManaged = true;
|
|
5063
|
+
}
|
|
5064
|
+
const withoutComment = rawLine.split("#")[0] ?? "";
|
|
5065
|
+
const line = withoutComment.trim();
|
|
5066
|
+
if (line.length === 0) continue;
|
|
5067
|
+
const colon = line.indexOf(":");
|
|
5068
|
+
if (colon <= 0) continue;
|
|
5069
|
+
const field = line.slice(0, colon).trim().toLowerCase();
|
|
5070
|
+
const value = line.slice(colon + 1).trim();
|
|
5071
|
+
if (field === "user-agent") {
|
|
5072
|
+
if (!openingGroup) {
|
|
5073
|
+
currentAgents = [];
|
|
5074
|
+
openingGroup = true;
|
|
5075
|
+
}
|
|
5076
|
+
if (value.length > 0) currentAgents.push(value.toLowerCase());
|
|
5077
|
+
continue;
|
|
5078
|
+
}
|
|
5079
|
+
if (field === "allow" || field === "disallow") {
|
|
5080
|
+
openingGroup = false;
|
|
5081
|
+
continue;
|
|
5082
|
+
}
|
|
5083
|
+
if (field === "content-signal") {
|
|
5084
|
+
if (currentAgents.length > 0) openingGroup = false;
|
|
5085
|
+
const parsed = {};
|
|
5086
|
+
for (const part of value.split(",")) {
|
|
5087
|
+
const eq = part.indexOf("=");
|
|
5088
|
+
if (eq <= 0) continue;
|
|
5089
|
+
const key = part.slice(0, eq).trim().toLowerCase();
|
|
5090
|
+
const val = part.slice(eq + 1).trim().toLowerCase();
|
|
5091
|
+
if (key.length > 0 && val.length > 0) {
|
|
5092
|
+
parsed[key] = val;
|
|
5093
|
+
}
|
|
5094
|
+
}
|
|
5095
|
+
rules.push({
|
|
5096
|
+
agents: [...currentAgents],
|
|
5097
|
+
raw: value,
|
|
5098
|
+
signals: parsed
|
|
5099
|
+
});
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5102
|
+
let search = null;
|
|
5103
|
+
let aiInput = null;
|
|
5104
|
+
let aiTrain = null;
|
|
5105
|
+
const wildcardRules = rules.filter((rule) => rule.agents.includes("*"));
|
|
5106
|
+
const summarySource = wildcardRules.length > 0 ? wildcardRules : rules.filter((rule) => rule.agents.length === 0);
|
|
5107
|
+
for (const rule of summarySource) {
|
|
5108
|
+
if (rule.signals["search"] !== void 0) search = rule.signals["search"];
|
|
5109
|
+
if (rule.signals["ai-input"] !== void 0) aiInput = rule.signals["ai-input"];
|
|
5110
|
+
if (rule.signals["ai-train"] !== void 0) aiTrain = rule.signals["ai-train"];
|
|
5111
|
+
}
|
|
5112
|
+
return {
|
|
5113
|
+
present: rules.length > 0,
|
|
5114
|
+
cloudflareManaged,
|
|
5115
|
+
rules,
|
|
5116
|
+
summary: { search, aiInput, aiTrain }
|
|
5117
|
+
};
|
|
5118
|
+
}
|
|
5119
|
+
var ROBOTS_DIRECTIVES = /* @__PURE__ */ new Set([
|
|
5120
|
+
"all",
|
|
5121
|
+
"noindex",
|
|
5122
|
+
"nofollow",
|
|
5123
|
+
"none",
|
|
5124
|
+
"noarchive",
|
|
5125
|
+
"nosnippet",
|
|
5126
|
+
"notranslate",
|
|
5127
|
+
"noimageindex",
|
|
5128
|
+
"unavailable_after",
|
|
5129
|
+
"max-snippet",
|
|
5130
|
+
"max-image-preview",
|
|
5131
|
+
"max-video-preview",
|
|
5132
|
+
"indexifembedded",
|
|
5133
|
+
"noai",
|
|
5134
|
+
"noimageai"
|
|
5135
|
+
]);
|
|
5136
|
+
var AGENT_META_NAMES = new Set(
|
|
5137
|
+
[
|
|
5138
|
+
...DEFAULT_RULESET.audienceTokens.assistant,
|
|
5139
|
+
...DEFAULT_RULESET.audienceTokens.training,
|
|
5140
|
+
...DEFAULT_RULESET.audienceTokens.search,
|
|
5141
|
+
"googlebot",
|
|
5142
|
+
"bingbot"
|
|
5143
|
+
].map((token) => token.toLowerCase())
|
|
5144
|
+
);
|
|
5145
|
+
function splitRobotTokens(directives) {
|
|
5146
|
+
return directives.toLowerCase().split(",").map((part) => part.trim()).filter((part) => part.length > 0);
|
|
5147
|
+
}
|
|
5148
|
+
function blocksIndexing(directives) {
|
|
5149
|
+
return splitRobotTokens(directives).some((part) => part === "noindex" || part === "none");
|
|
5150
|
+
}
|
|
5151
|
+
function extractRestrictions(directives) {
|
|
5152
|
+
const found = [];
|
|
5153
|
+
for (const part of splitRobotTokens(directives)) {
|
|
5154
|
+
if (part === "nosnippet") found.push("nosnippet");
|
|
5155
|
+
else if (/^max-snippet\s*:\s*0$/.test(part)) found.push("max-snippet:0");
|
|
5156
|
+
else if (part === "noai") found.push("noai");
|
|
5157
|
+
else if (part === "noimageai") found.push("noimageai");
|
|
5158
|
+
}
|
|
5159
|
+
return found;
|
|
5160
|
+
}
|
|
5161
|
+
function parseHeaderRobots(values) {
|
|
5162
|
+
const noindex = [];
|
|
5163
|
+
const restrictions = [];
|
|
5164
|
+
for (const value of values) {
|
|
5165
|
+
const trimmed = value.trim();
|
|
5166
|
+
const prefixed = /^\s*([A-Za-z0-9_.-]+)\s*:\s*(.*)$/.exec(value);
|
|
5167
|
+
const prefix = prefixed?.[1]?.toLowerCase();
|
|
5168
|
+
let agent = "robots";
|
|
5169
|
+
let directiveBody = value;
|
|
5170
|
+
if (prefixed !== null && prefix !== void 0 && !ROBOTS_DIRECTIVES.has(prefix)) {
|
|
5171
|
+
agent = prefix;
|
|
5172
|
+
directiveBody = prefixed[2] ?? "";
|
|
5173
|
+
}
|
|
5174
|
+
if (blocksIndexing(directiveBody)) {
|
|
5175
|
+
noindex.push({ agent, source: "header", value: trimmed });
|
|
5176
|
+
}
|
|
5177
|
+
for (const directive of extractRestrictions(directiveBody)) {
|
|
5178
|
+
restrictions.push({ agent, source: "header", directive, value: trimmed });
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
return { noindex, restrictions };
|
|
5182
|
+
}
|
|
5183
|
+
function summarizeCanonicals(canonicals) {
|
|
5184
|
+
let htmlCount = 0;
|
|
5185
|
+
let headerCount = 0;
|
|
5186
|
+
const distinct = /* @__PURE__ */ new Set();
|
|
5187
|
+
for (const entry of canonicals) {
|
|
5188
|
+
if (entry.source === "html") htmlCount++;
|
|
5189
|
+
else headerCount++;
|
|
5190
|
+
distinct.add(entry.url);
|
|
5191
|
+
}
|
|
5192
|
+
return {
|
|
5193
|
+
duplicateCanonical: htmlCount > 1 || headerCount > 1,
|
|
5194
|
+
conflictingCanonical: distinct.size > 1
|
|
5195
|
+
};
|
|
5196
|
+
}
|
|
5197
|
+
function indexSignalsOf(capture) {
|
|
5198
|
+
const parsedHeaders = parseHeaderRobots(headerAll(capture.headers, "x-robots-tag"));
|
|
5199
|
+
const noindex = [...parsedHeaders.noindex];
|
|
5200
|
+
const restrictions = [...parsedHeaders.restrictions];
|
|
5201
|
+
const canonicals = [];
|
|
5202
|
+
let canonical = null;
|
|
5203
|
+
for (const link of parseLinkHeaders(headerAll(capture.headers, "link"))) {
|
|
5204
|
+
if (link.rel.includes("canonical")) {
|
|
5205
|
+
const resolved = absoluteUrl(link.url, capture.finalUrl);
|
|
5206
|
+
if (resolved !== null) {
|
|
5207
|
+
canonicals.push({ source: "header", url: resolved });
|
|
5208
|
+
if (canonical === null) canonical = resolved;
|
|
5209
|
+
}
|
|
5210
|
+
}
|
|
5211
|
+
}
|
|
5212
|
+
const representation = buildRepresentation(capture);
|
|
5213
|
+
const doc = representation?.doc ?? null;
|
|
5214
|
+
if (doc !== null) {
|
|
5215
|
+
for (const meta of doc.metas) {
|
|
5216
|
+
const name = meta.name;
|
|
5217
|
+
if (name === null || meta.content === null) continue;
|
|
5218
|
+
const targetAgent = name === "robots" ? "robots" : AGENT_META_NAMES.has(name) ? name : null;
|
|
5219
|
+
if (targetAgent === null) continue;
|
|
5220
|
+
if (blocksIndexing(meta.content)) {
|
|
5221
|
+
noindex.push({ agent: targetAgent, source: "meta", value: meta.content });
|
|
5222
|
+
}
|
|
5223
|
+
for (const directive of extractRestrictions(meta.content)) {
|
|
5224
|
+
restrictions.push({
|
|
5225
|
+
agent: targetAgent,
|
|
5226
|
+
source: "meta",
|
|
5227
|
+
directive,
|
|
5228
|
+
value: meta.content
|
|
5229
|
+
});
|
|
5230
|
+
}
|
|
5231
|
+
}
|
|
5232
|
+
for (const link of doc.links) {
|
|
5233
|
+
if (link.rel.includes("canonical") && link.href !== null) {
|
|
5234
|
+
const resolved = absoluteUrl(link.href, capture.finalUrl);
|
|
5235
|
+
if (resolved !== null) {
|
|
5236
|
+
canonicals.push({ source: "html", url: resolved });
|
|
5237
|
+
if (canonical === null) canonical = resolved;
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5240
|
+
}
|
|
5241
|
+
}
|
|
5242
|
+
const { duplicateCanonical, conflictingCanonical } = summarizeCanonicals(canonicals);
|
|
5243
|
+
return {
|
|
5244
|
+
status: capture.status,
|
|
5245
|
+
finalUrl: capture.finalUrl,
|
|
5246
|
+
redirected: capture.redirects.length > 0,
|
|
5247
|
+
noindex,
|
|
5248
|
+
canonical,
|
|
5249
|
+
restrictions,
|
|
5250
|
+
nosnippet: restrictions.some((r) => r.directive === "nosnippet"),
|
|
5251
|
+
maxSnippetZero: restrictions.some((r) => r.directive === "max-snippet:0"),
|
|
5252
|
+
noai: restrictions.some((r) => r.directive === "noai"),
|
|
5253
|
+
noimageai: restrictions.some((r) => r.directive === "noimageai"),
|
|
5254
|
+
canonicals,
|
|
5255
|
+
duplicateCanonical,
|
|
5256
|
+
conflictingCanonical,
|
|
5257
|
+
payPerCrawl: capture.status === 402
|
|
5258
|
+
};
|
|
5259
|
+
}
|
|
5260
|
+
function pageIndexSignals(evidence) {
|
|
5261
|
+
const browser = evidence.probes.browser.result;
|
|
5262
|
+
const agent = evidence.probes.agent.result;
|
|
5263
|
+
const capture = browser.ok ? browser.capture : agent.ok ? agent.capture : null;
|
|
5264
|
+
if (capture === null) return null;
|
|
5265
|
+
const signals = indexSignalsOf(capture);
|
|
5266
|
+
if (browser.ok && agent.ok) {
|
|
5267
|
+
const agentRobots = parseHeaderRobots(headerAll(agent.capture.headers, "x-robots-tag"));
|
|
5268
|
+
const seenNoindex = new Set(signals.noindex.map((d) => `${d.agent}|${d.source}|${d.value}`));
|
|
5269
|
+
for (const directive of agentRobots.noindex) {
|
|
5270
|
+
const key = `${directive.agent}|${directive.source}|${directive.value}`;
|
|
5271
|
+
if (!seenNoindex.has(key)) {
|
|
5272
|
+
seenNoindex.add(key);
|
|
5273
|
+
signals.noindex.push(directive);
|
|
5274
|
+
}
|
|
5275
|
+
}
|
|
5276
|
+
const seenRestrictions = new Set(
|
|
5277
|
+
signals.restrictions.map((d) => `${d.agent}|${d.source}|${d.directive}|${d.value}`)
|
|
5278
|
+
);
|
|
5279
|
+
for (const directive of agentRobots.restrictions) {
|
|
5280
|
+
const key = `${directive.agent}|${directive.source}|${directive.directive}|${directive.value}`;
|
|
5281
|
+
if (!seenRestrictions.has(key)) {
|
|
5282
|
+
seenRestrictions.add(key);
|
|
5283
|
+
signals.restrictions.push(directive);
|
|
5284
|
+
}
|
|
5285
|
+
}
|
|
5286
|
+
signals.nosnippet = signals.restrictions.some((r) => r.directive === "nosnippet");
|
|
5287
|
+
signals.maxSnippetZero = signals.restrictions.some((r) => r.directive === "max-snippet:0");
|
|
5288
|
+
signals.noai = signals.restrictions.some((r) => r.directive === "noai");
|
|
5289
|
+
signals.noimageai = signals.restrictions.some((r) => r.directive === "noimageai");
|
|
5290
|
+
const seenCanonicals = new Set(signals.canonicals.map((c) => `${c.source}|${c.url}`));
|
|
5291
|
+
let canonicalsAdded = false;
|
|
5292
|
+
for (const link of parseLinkHeaders(headerAll(agent.capture.headers, "link"))) {
|
|
5293
|
+
if (!link.rel.includes("canonical")) continue;
|
|
5294
|
+
const resolved = absoluteUrl(link.url, agent.capture.finalUrl);
|
|
5295
|
+
if (resolved === null) continue;
|
|
5296
|
+
const key = `header|${resolved}`;
|
|
5297
|
+
if (!seenCanonicals.has(key)) {
|
|
5298
|
+
seenCanonicals.add(key);
|
|
5299
|
+
signals.canonicals.push({ source: "header", url: resolved });
|
|
5300
|
+
if (signals.canonical === null) signals.canonical = resolved;
|
|
5301
|
+
canonicalsAdded = true;
|
|
5302
|
+
}
|
|
5303
|
+
}
|
|
5304
|
+
if (canonicalsAdded) {
|
|
5305
|
+
const summary = summarizeCanonicals(signals.canonicals);
|
|
5306
|
+
signals.duplicateCanonical = summary.duplicateCanonical;
|
|
5307
|
+
signals.conflictingCanonical = summary.conflictingCanonical;
|
|
5308
|
+
}
|
|
5309
|
+
if (agent.capture.status === 402) {
|
|
5310
|
+
signals.payPerCrawl = true;
|
|
5311
|
+
}
|
|
5312
|
+
}
|
|
5313
|
+
return signals;
|
|
5314
|
+
}
|
|
5315
|
+
var SPA_MOUNT_ROOT_IDS = /* @__PURE__ */ new Set(["root", "app", "__next", "__nuxt"]);
|
|
5316
|
+
var NOSCRIPT_JS_PATTERNS = [
|
|
5317
|
+
/\benable\s+javascript\b/i,
|
|
5318
|
+
/\bjavascript\s+(?:is\s+required|must\s+be\s+enabled|is\s+disabled)\b/i,
|
|
5319
|
+
/\brequires?\s+javascript\b/i,
|
|
5320
|
+
/\bturn\s+on\s+javascript\b/i,
|
|
5321
|
+
/\bwithout\s+javascript\b/i,
|
|
5322
|
+
/\bdoes\s+not\s+support\s+javascript\b/i,
|
|
5323
|
+
/\bneed\s+javascript\b/i
|
|
5324
|
+
];
|
|
5325
|
+
function hasAncestorTag(doc, startIndex, tags) {
|
|
5326
|
+
let current = startIndex;
|
|
5327
|
+
for (let hops = 0; hops < 128 && current >= 0; hops++) {
|
|
5328
|
+
const el = doc.elements[current];
|
|
5329
|
+
if (el === void 0) break;
|
|
5330
|
+
if (tags.has(el.tag)) return true;
|
|
5331
|
+
current = el.parent;
|
|
5332
|
+
}
|
|
5333
|
+
return false;
|
|
5334
|
+
}
|
|
5335
|
+
var NON_BODY_TEXT_TAGS = /* @__PURE__ */ new Set(["title", "noscript"]);
|
|
5336
|
+
function detectSpaJsDependency(html) {
|
|
5337
|
+
const doc = tokenizeHtml(html);
|
|
5338
|
+
const emptyMountRoots = [];
|
|
5339
|
+
for (const el of doc.elements) {
|
|
5340
|
+
const id = el.attrs["id"]?.trim().toLowerCase();
|
|
5341
|
+
if (id === void 0 || !SPA_MOUNT_ROOT_IDS.has(id)) continue;
|
|
5342
|
+
const text = elementText(doc, el.index);
|
|
5343
|
+
if (text.length === 0) {
|
|
5344
|
+
const selector = `#${el.attrs["id"]?.trim() ?? id}`;
|
|
5345
|
+
if (!emptyMountRoots.includes(selector)) emptyMountRoots.push(selector);
|
|
5346
|
+
}
|
|
5347
|
+
}
|
|
5348
|
+
let jsRequiredNoscript = false;
|
|
5349
|
+
let noscriptSnippet = null;
|
|
5350
|
+
for (const el of doc.elements) {
|
|
5351
|
+
if (el.tag !== "noscript") continue;
|
|
5352
|
+
const text = elementText(doc, el.index);
|
|
5353
|
+
if (text.length === 0) continue;
|
|
5354
|
+
if (NOSCRIPT_JS_PATTERNS.some((pattern) => pattern.test(text))) {
|
|
5355
|
+
jsRequiredNoscript = true;
|
|
5356
|
+
if (noscriptSnippet === null) noscriptSnippet = text.slice(0, 200);
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
const visibleParts = [];
|
|
5360
|
+
for (const node of doc.texts) {
|
|
5361
|
+
if (node.excludedBy !== null) continue;
|
|
5362
|
+
if (hasAncestorTag(doc, node.parent, NON_BODY_TEXT_TAGS)) continue;
|
|
5363
|
+
visibleParts.push(node.text);
|
|
5364
|
+
}
|
|
5365
|
+
const visibleBodyText = visibleParts.join(" ").replace(/\s+/g, " ").trim();
|
|
5366
|
+
const visibleWordCount = visibleBodyText.length === 0 ? 0 : visibleBodyText.split(/\s+/).filter(Boolean).length;
|
|
5367
|
+
const visibleTextBytes = utf8Length(visibleBodyText);
|
|
5368
|
+
let scriptBytes = 0;
|
|
5369
|
+
let externalScriptCount = 0;
|
|
5370
|
+
let hasNextData = false;
|
|
5371
|
+
let hasNextFlight = false;
|
|
5372
|
+
let hydrationPayloadBytes = 0;
|
|
5373
|
+
const nextDataElements = /* @__PURE__ */ new Set();
|
|
5374
|
+
for (const el of doc.elements) {
|
|
5375
|
+
if (el.tag !== "script") continue;
|
|
5376
|
+
const typeAttr = el.attrs["type"]?.trim().toLowerCase() ?? "";
|
|
5377
|
+
if (typeAttr === "application/ld+json") continue;
|
|
5378
|
+
if (typeof el.attrs["src"] === "string" && el.attrs["src"].trim().length > 0) {
|
|
5379
|
+
externalScriptCount++;
|
|
5380
|
+
}
|
|
5381
|
+
if (el.attrs["id"]?.trim().toLowerCase() === "__next_data__") {
|
|
5382
|
+
hasNextData = true;
|
|
5383
|
+
nextDataElements.add(el.index);
|
|
5384
|
+
}
|
|
5385
|
+
}
|
|
5386
|
+
for (const node of doc.texts) {
|
|
5387
|
+
if (node.excludedBy !== "script") continue;
|
|
5388
|
+
scriptBytes += node.bytes;
|
|
5389
|
+
if (nextDataElements.has(node.parent)) {
|
|
5390
|
+
hydrationPayloadBytes += node.bytes;
|
|
5391
|
+
} else if (node.text.includes("__next_f")) {
|
|
5392
|
+
hasNextFlight = true;
|
|
5393
|
+
hydrationPayloadBytes += node.bytes;
|
|
5394
|
+
}
|
|
5395
|
+
}
|
|
5396
|
+
const unrenderedHydrationPayload = (hasNextData || hasNextFlight) && hydrationPayloadBytes >= 1024 && (visibleWordCount < 50 || visibleWordCount < 100 && visibleTextBytes > 0 && hydrationPayloadBytes / visibleTextBytes >= 4);
|
|
5397
|
+
const scriptToTextRatio = visibleTextBytes > 0 ? Number((scriptBytes / visibleTextBytes).toFixed(2)) : scriptBytes > 0 ? null : 0;
|
|
5398
|
+
const lowTextToScriptRatio = visibleWordCount < 40 && (scriptBytes >= 2048 || externalScriptCount >= 2) || visibleWordCount < 80 && visibleTextBytes > 0 && scriptBytes / visibleTextBytes >= 20;
|
|
5399
|
+
const reasons = [];
|
|
5400
|
+
if (emptyMountRoots.length > 0) reasons.push("empty-mount-root");
|
|
5401
|
+
if (jsRequiredNoscript) reasons.push("noscript-js-required");
|
|
5402
|
+
if (unrenderedHydrationPayload) reasons.push("unrendered-next-payload");
|
|
5403
|
+
if (lowTextToScriptRatio) reasons.push("low-text-vs-script");
|
|
5404
|
+
const likelySpaShell = emptyMountRoots.length > 0 && visibleWordCount < 50 || jsRequiredNoscript && visibleWordCount < 80 || unrenderedHydrationPayload || reasons.length >= 2;
|
|
5405
|
+
return {
|
|
5406
|
+
likelySpaShell,
|
|
5407
|
+
reasons,
|
|
5408
|
+
emptyMountRoots,
|
|
5409
|
+
jsRequiredNoscript,
|
|
5410
|
+
noscriptSnippet,
|
|
5411
|
+
hasNextData,
|
|
5412
|
+
hasNextFlight,
|
|
5413
|
+
hydrationPayloadBytes,
|
|
5414
|
+
unrenderedHydrationPayload,
|
|
5415
|
+
visibleWordCount,
|
|
5416
|
+
visibleTextBytes,
|
|
5417
|
+
scriptBytes,
|
|
5418
|
+
externalScriptCount,
|
|
5419
|
+
scriptToTextRatio,
|
|
5420
|
+
lowTextToScriptRatio
|
|
5421
|
+
};
|
|
5422
|
+
}
|
|
5423
|
+
var SAAS_QUOTA_UNITS = [
|
|
5424
|
+
"seats",
|
|
5425
|
+
"users",
|
|
5426
|
+
"projects",
|
|
5427
|
+
"pages",
|
|
5428
|
+
"sites",
|
|
5429
|
+
"requests",
|
|
5430
|
+
"tokens",
|
|
5431
|
+
"credits",
|
|
5432
|
+
"calls",
|
|
5433
|
+
"events",
|
|
5434
|
+
"contacts",
|
|
5435
|
+
"workspaces",
|
|
5436
|
+
"domains",
|
|
5437
|
+
"rows"
|
|
5438
|
+
];
|
|
5439
|
+
var QUOTA_UNIT_CANONICAL = {
|
|
5440
|
+
seat: "seats",
|
|
5441
|
+
seats: "seats",
|
|
5442
|
+
user: "users",
|
|
5443
|
+
users: "users",
|
|
5444
|
+
project: "projects",
|
|
5445
|
+
projects: "projects",
|
|
5446
|
+
page: "pages",
|
|
5447
|
+
pages: "pages",
|
|
5448
|
+
site: "sites",
|
|
5449
|
+
sites: "sites",
|
|
5450
|
+
request: "requests",
|
|
5451
|
+
requests: "requests",
|
|
5452
|
+
token: "tokens",
|
|
5453
|
+
tokens: "tokens",
|
|
5454
|
+
credit: "credits",
|
|
5455
|
+
credits: "credits",
|
|
5456
|
+
call: "calls",
|
|
5457
|
+
calls: "calls",
|
|
5458
|
+
event: "events",
|
|
5459
|
+
events: "events",
|
|
5460
|
+
contact: "contacts",
|
|
5461
|
+
contacts: "contacts",
|
|
5462
|
+
workspace: "workspaces",
|
|
5463
|
+
workspaces: "workspaces",
|
|
5464
|
+
domain: "domains",
|
|
5465
|
+
domains: "domains",
|
|
5466
|
+
row: "rows",
|
|
5467
|
+
rows: "rows"
|
|
5468
|
+
};
|
|
5469
|
+
var PRICE_TOKEN_PATTERN = /(?:[$€£¥] ?\d[\d,.]*|\b(?:USD|EUR|GBP|CAD|AUD) \d[\d,.]*)/gi;
|
|
5470
|
+
var TIER_CONTAINER_TAGS = /* @__PURE__ */ new Set(["article", "section", "div", "li"]);
|
|
5471
|
+
var TIER_ATTR_HINT = /(?:^|[-_\s])(plan|tier|pricing[-_]?card|price[-_]?card|package)(?:$|[-_\s])/i;
|
|
5472
|
+
var TIER_TEXT_HINT = /\b(?:free|custom pricing|custom|contact sales|enterprise|talk to sales)\b/i;
|
|
5473
|
+
var ICON_CLASS_HINT = /(?:icon|check|tick|cross|dash|minus|yes|no|fa-|lucide|heroicon|badge)/i;
|
|
5474
|
+
var TOGGLE_ELEMENT_TAGS = /* @__PURE__ */ new Set(["button", "input", "label", "select", "div", "span", "fieldset"]);
|
|
5475
|
+
var ANNUAL_PRICE_CONTEXT = /\b(?:billed (?:annually|yearly)|annual billing|per year|annually|yearly)\b|\/(?:yr|year)\b/i;
|
|
5476
|
+
var MONTHLY_PRICE_CONTEXT = /\b(?:billed monthly|monthly billing|per month|monthly)\b|\/(?:mo|month)\b/i;
|
|
5477
|
+
var CADENCE_PATTERNS = [
|
|
5478
|
+
/\/(?:mo|month|yr|year|quarter|week|day|seat|user|member)\b/gi,
|
|
5479
|
+
/\bper (?:month|mo|year|yr|quarter|week|day|hour|seat|user|member|workspace|project|site|domain|request|call|credit|token|contact|unit)\b/gi,
|
|
5480
|
+
/\bbilled (?:annually|yearly|monthly|quarterly)\b/gi,
|
|
5481
|
+
/\bone-time\b/gi
|
|
5482
|
+
];
|
|
5483
|
+
var QUOTA_MODIFIER_WORDS = /* @__PURE__ */ new Set([
|
|
5484
|
+
"active",
|
|
5485
|
+
"custom",
|
|
5486
|
+
"monthly",
|
|
5487
|
+
"annual",
|
|
5488
|
+
"api",
|
|
5489
|
+
"team",
|
|
5490
|
+
"tracked",
|
|
5491
|
+
"monitored",
|
|
5492
|
+
"included",
|
|
5493
|
+
"free",
|
|
5494
|
+
"extra",
|
|
5495
|
+
"total",
|
|
5496
|
+
"concurrent",
|
|
5497
|
+
"unique"
|
|
5498
|
+
]);
|
|
5499
|
+
var QUOTA_QUANTITY_TOKEN = /^(?:unlimited|\d[\d,.]*[kmb]?\+?)$/i;
|
|
5500
|
+
var QUOTA_VALUE_CELL = /^(?:unlimited|up to \d[\d,.]*[kmb]?|\d[\d,.]*[kmb]?\+?)$/i;
|
|
5501
|
+
function isAncestorOf(doc, ancestor, descendant) {
|
|
5502
|
+
let current = descendant;
|
|
5503
|
+
for (let hops = 0; hops < 128 && current >= 0; hops++) {
|
|
5504
|
+
if (current === ancestor) return true;
|
|
5505
|
+
current = doc.elements[current]?.parent ?? -1;
|
|
5506
|
+
}
|
|
5507
|
+
return false;
|
|
5508
|
+
}
|
|
5509
|
+
function collectOfferRecords(nodes) {
|
|
5510
|
+
const offers = [];
|
|
5511
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5512
|
+
const visit = (obj, depth) => {
|
|
5513
|
+
if (depth > 8 || obj === null || typeof obj !== "object") return;
|
|
5514
|
+
if (Array.isArray(obj)) {
|
|
5515
|
+
for (const item of obj) visit(item, depth + 1);
|
|
5516
|
+
return;
|
|
5517
|
+
}
|
|
5518
|
+
if (seen.has(obj)) return;
|
|
5519
|
+
seen.add(obj);
|
|
5520
|
+
const rec = obj;
|
|
5521
|
+
const rawType = rec["@type"];
|
|
5522
|
+
const types = typeof rawType === "string" ? [rawType.replace(/^https?:\/\/schema\.org\//, "")] : Array.isArray(rawType) ? rawType.filter((t) => typeof t === "string").map((t) => t.replace(/^https?:\/\/schema\.org\//, "")) : [];
|
|
5523
|
+
if (types.includes("Offer")) offers.push(rec);
|
|
5524
|
+
if (rec["offers"] !== void 0) visit(rec["offers"], depth + 1);
|
|
5525
|
+
};
|
|
5526
|
+
for (const node of nodes) {
|
|
5527
|
+
if (!seen.has(node.value)) {
|
|
5528
|
+
seen.add(node.value);
|
|
5529
|
+
if (node.types.includes("Offer")) offers.push(node.value);
|
|
5530
|
+
}
|
|
5531
|
+
if (node.value["offers"] !== void 0) visit(node.value["offers"], 1);
|
|
5532
|
+
}
|
|
5533
|
+
return offers;
|
|
5534
|
+
}
|
|
5535
|
+
function hasOfferPrice(offer) {
|
|
5536
|
+
if (offer["price"] !== void 0 && offer["price"] !== null && String(offer["price"]).trim() !== "") {
|
|
5537
|
+
return true;
|
|
5538
|
+
}
|
|
5539
|
+
const spec = offer["priceSpecification"];
|
|
5540
|
+
const specs = Array.isArray(spec) ? spec : spec !== void 0 && spec !== null ? [spec] : [];
|
|
5541
|
+
return specs.some((entry) => {
|
|
5542
|
+
if (entry === null || typeof entry !== "object") return false;
|
|
5543
|
+
const record = entry;
|
|
5544
|
+
return record["price"] !== void 0 && String(record["price"]).trim() !== "" || record["minPrice"] !== void 0 && String(record["minPrice"]).trim() !== "";
|
|
5545
|
+
});
|
|
5546
|
+
}
|
|
5547
|
+
function normalizePriceMatch(raw) {
|
|
5548
|
+
return raw.replace(/[.,]+$/, "").replace(/\s+/g, "").toUpperCase();
|
|
5549
|
+
}
|
|
5550
|
+
function directChildrenOfTag(doc, parentIndex, tag) {
|
|
5551
|
+
const out = [];
|
|
5552
|
+
for (const el of doc.elements) {
|
|
5553
|
+
if (el.parent === parentIndex && el.tag === tag) out.push(el);
|
|
5554
|
+
}
|
|
5555
|
+
return out;
|
|
5556
|
+
}
|
|
5557
|
+
function descendantsOf(doc, ancestorIndex) {
|
|
5558
|
+
const out = [];
|
|
5559
|
+
for (let i = ancestorIndex + 1; i < doc.elements.length; i++) {
|
|
5560
|
+
const el = doc.elements[i];
|
|
5561
|
+
if (el === void 0) continue;
|
|
5562
|
+
if (el.depth <= (doc.elements[ancestorIndex]?.depth ?? 0)) break;
|
|
5563
|
+
if (isAncestorOf(doc, ancestorIndex, el.index)) out.push(el);
|
|
5564
|
+
}
|
|
5565
|
+
return out;
|
|
5566
|
+
}
|
|
5567
|
+
function quotaUnitFromLabel(label) {
|
|
5568
|
+
const words = label.toLowerCase().replace(/[^a-z0-9\s]/g, " ").split(/\s+/).filter(Boolean);
|
|
5569
|
+
for (const word of words) {
|
|
5570
|
+
const mapped = QUOTA_UNIT_CANONICAL[word];
|
|
5571
|
+
if (mapped !== void 0) return mapped;
|
|
5572
|
+
}
|
|
5573
|
+
return null;
|
|
5574
|
+
}
|
|
5575
|
+
function auditPricingAndLimits(html, jsonLdNodes) {
|
|
5576
|
+
const doc = tokenizeHtml(html);
|
|
5577
|
+
const nodes = jsonLdNodes !== void 0 ? jsonLdNodes : parseJsonLd(doc.jsonLd).nodes;
|
|
5578
|
+
const offerRecords = collectOfferRecords(nodes);
|
|
5579
|
+
const jsonLdOfferCount = offerRecords.length;
|
|
5580
|
+
const jsonLdPricedOfferCount = offerRecords.filter(hasOfferPrice).length;
|
|
5581
|
+
const visibleParts = [];
|
|
5582
|
+
for (const node of doc.texts) {
|
|
5583
|
+
if (node.excludedBy !== null) continue;
|
|
5584
|
+
if (hasAncestorTag(doc, node.parent, NON_BODY_TEXT_TAGS)) continue;
|
|
5585
|
+
visibleParts.push(node.text);
|
|
5586
|
+
}
|
|
5587
|
+
const visibleText = visibleParts.join(" ").replace(/\s+/g, " ").trim();
|
|
5588
|
+
const priceMatches = [];
|
|
5589
|
+
PRICE_TOKEN_PATTERN.lastIndex = 0;
|
|
5590
|
+
let match;
|
|
5591
|
+
while ((match = PRICE_TOKEN_PATTERN.exec(visibleText)) !== null) {
|
|
5592
|
+
priceMatches.push({ raw: match[0], index: match.index });
|
|
5593
|
+
}
|
|
5594
|
+
const visiblePriceCount = priceMatches.length;
|
|
5595
|
+
const distinctVisiblePriceCount = new Set(priceMatches.map((m) => normalizePriceMatch(m.raw))).size;
|
|
5596
|
+
const candidateCards = [];
|
|
5597
|
+
for (const el of doc.elements) {
|
|
5598
|
+
if (!TIER_CONTAINER_TAGS.has(el.tag) || el.excludedBy !== null) continue;
|
|
5599
|
+
const hasDataPlan = el.attrs["data-plan"] !== void 0 || el.attrs["data-tier"] !== void 0 || el.attrs["data-pricing-tier"] !== void 0;
|
|
5600
|
+
const hintStr = `${el.attrs["class"] ?? ""} ${el.attrs["id"] ?? ""}`;
|
|
5601
|
+
if (!hasDataPlan && !TIER_ATTR_HINT.test(hintStr)) continue;
|
|
5602
|
+
const text = elementText(doc, el.index);
|
|
5603
|
+
if (text.length === 0) continue;
|
|
5604
|
+
PRICE_TOKEN_PATTERN.lastIndex = 0;
|
|
5605
|
+
if (PRICE_TOKEN_PATTERN.test(text) || TIER_TEXT_HINT.test(text)) {
|
|
5606
|
+
candidateCards.push(el);
|
|
5607
|
+
}
|
|
5608
|
+
}
|
|
5609
|
+
const leafCards = candidateCards.filter(
|
|
5610
|
+
(card) => !candidateCards.some((other) => other.index !== card.index && isAncestorOf(doc, card.index, other.index))
|
|
5611
|
+
);
|
|
5612
|
+
let iconOnlyCellCount = 0;
|
|
5613
|
+
let pricingTableTierCount = 0;
|
|
5614
|
+
const unitCounts = {};
|
|
5615
|
+
const incrementUnit = (unit) => {
|
|
5616
|
+
unitCounts[unit] = (unitCounts[unit] ?? 0) + 1;
|
|
5617
|
+
};
|
|
5618
|
+
for (const el of doc.elements) {
|
|
5619
|
+
if (el.tag !== "table" || el.excludedBy !== null) continue;
|
|
5620
|
+
const tableDescendants = descendantsOf(doc, el.index);
|
|
5621
|
+
const rows = tableDescendants.filter((child) => child.tag === "tr");
|
|
5622
|
+
if (rows.length === 0) continue;
|
|
5623
|
+
const tableText = elementText(doc, el.index);
|
|
5624
|
+
PRICE_TOKEN_PATTERN.lastIndex = 0;
|
|
5625
|
+
const tableHasPrices = PRICE_TOKEN_PATTERN.test(tableText);
|
|
5626
|
+
for (const row of rows) {
|
|
5627
|
+
const cells = [
|
|
5628
|
+
...directChildrenOfTag(doc, row.index, "th"),
|
|
5629
|
+
...directChildrenOfTag(doc, row.index, "td")
|
|
5630
|
+
].sort((a, b) => a.index - b.index);
|
|
5631
|
+
if (cells.length >= 3 && tableHasPrices) {
|
|
5632
|
+
const thCount = cells.filter((c) => c.tag === "th").length;
|
|
5633
|
+
if (thCount >= 3) {
|
|
5634
|
+
pricingTableTierCount = Math.max(pricingTableTierCount, thCount - 1);
|
|
5635
|
+
}
|
|
5636
|
+
}
|
|
5637
|
+
const firstCell = cells[0];
|
|
5638
|
+
const rowQuotaUnit = firstCell !== void 0 && cells.length >= 2 ? quotaUnitFromLabel(elementText(doc, firstCell.index)) : null;
|
|
5639
|
+
for (let cellIdx = 0; cellIdx < cells.length; cellIdx++) {
|
|
5640
|
+
const cell = cells[cellIdx];
|
|
5641
|
+
if (cell === void 0 || cell.tag !== "td") continue;
|
|
5642
|
+
const cellText = elementText(doc, cell.index);
|
|
5643
|
+
if (cellIdx > 0 && rowQuotaUnit !== null && QUOTA_VALUE_CELL.test(cellText)) {
|
|
5644
|
+
incrementUnit(rowQuotaUnit);
|
|
5645
|
+
}
|
|
5646
|
+
if (cells.length >= 2 && cellText.length === 0) {
|
|
5647
|
+
const cellDescendants = descendantsOf(doc, cell.index);
|
|
5648
|
+
const hasIconOnly = cellDescendants.some((desc) => {
|
|
5649
|
+
if (desc.tag === "svg") return true;
|
|
5650
|
+
if (desc.tag === "img" && (desc.attrs["alt"] ?? "").trim().length === 0) return true;
|
|
5651
|
+
if ((desc.tag === "i" || desc.tag === "span") && ICON_CLASS_HINT.test(desc.attrs["class"] ?? "")) {
|
|
5652
|
+
return true;
|
|
5653
|
+
}
|
|
5654
|
+
return false;
|
|
5655
|
+
});
|
|
5656
|
+
if (hasIconOnly) iconOnlyCellCount++;
|
|
5657
|
+
}
|
|
5658
|
+
}
|
|
5659
|
+
}
|
|
5660
|
+
}
|
|
5661
|
+
const visibleTierCount = Math.max(leafCards.length, pricingTableTierCount, distinctVisiblePriceCount);
|
|
5662
|
+
const iconOnlyFeatureMatrix = iconOnlyCellCount > 0;
|
|
5663
|
+
let hasBillingToggleHint = false;
|
|
5664
|
+
let sawMonthlyControl = false;
|
|
5665
|
+
let sawAnnualControl = false;
|
|
5666
|
+
for (const el of doc.elements) {
|
|
5667
|
+
if (!TOGGLE_ELEMENT_TAGS.has(el.tag) || el.excludedBy !== null) continue;
|
|
5668
|
+
const role = el.attrs["role"]?.toLowerCase() ?? "";
|
|
5669
|
+
const isInteractive = el.tag === "button" || el.tag === "input" || el.tag === "label" || el.tag === "select" || role === "switch" || role === "tab" || role === "tablist" || role === "radiogroup";
|
|
5670
|
+
if (!isInteractive) continue;
|
|
5671
|
+
const labelText = [
|
|
5672
|
+
elementText(doc, el.index),
|
|
5673
|
+
el.attrs["aria-label"] ?? "",
|
|
5674
|
+
el.attrs["name"] ?? "",
|
|
5675
|
+
el.attrs["id"] ?? "",
|
|
5676
|
+
el.attrs["data-billing"] ?? "",
|
|
5677
|
+
el.attrs["data-period"] ?? ""
|
|
5678
|
+
].join(" ").toLowerCase();
|
|
5679
|
+
const hasMonthly = /\b(?:monthly|month)\b/.test(labelText);
|
|
5680
|
+
const hasAnnual = /\b(?:annual(?:ly)?|yearly|year)\b/.test(labelText);
|
|
5681
|
+
if (hasMonthly && hasAnnual) {
|
|
5682
|
+
hasBillingToggleHint = true;
|
|
5683
|
+
break;
|
|
5684
|
+
}
|
|
5685
|
+
if (hasMonthly) sawMonthlyControl = true;
|
|
5686
|
+
if (hasAnnual) sawAnnualControl = true;
|
|
5687
|
+
}
|
|
5688
|
+
if (sawMonthlyControl && sawAnnualControl) hasBillingToggleHint = true;
|
|
5689
|
+
let monthlyPricePresent = false;
|
|
5690
|
+
let annualPricePresent = false;
|
|
5691
|
+
for (let i = 0; i < priceMatches.length; i++) {
|
|
5692
|
+
const pm = priceMatches[i];
|
|
5693
|
+
if (pm === void 0) continue;
|
|
5694
|
+
const nextPriceIndex = priceMatches[i + 1]?.index ?? visibleText.length;
|
|
5695
|
+
const contextEnd = Math.min(nextPriceIndex, pm.index + 48);
|
|
5696
|
+
const context = visibleText.slice(pm.index, contextEnd);
|
|
5697
|
+
if (ANNUAL_PRICE_CONTEXT.test(context)) {
|
|
5698
|
+
annualPricePresent = true;
|
|
5699
|
+
} else if (MONTHLY_PRICE_CONTEXT.test(context)) {
|
|
5700
|
+
monthlyPricePresent = true;
|
|
5701
|
+
}
|
|
5702
|
+
}
|
|
5703
|
+
const billingToggleSinglePeriodOnly = hasBillingToggleHint && monthlyPricePresent !== annualPricePresent;
|
|
5704
|
+
const billingCadences = [];
|
|
5705
|
+
const seenCadences = /* @__PURE__ */ new Set();
|
|
5706
|
+
for (const pattern of CADENCE_PATTERNS) {
|
|
5707
|
+
pattern.lastIndex = 0;
|
|
5708
|
+
let cadenceMatch;
|
|
5709
|
+
while ((cadenceMatch = pattern.exec(visibleText)) !== null) {
|
|
5710
|
+
const normalized = cadenceMatch[0].replace(/\s+/g, " ").trim().toLowerCase();
|
|
5711
|
+
if (normalized.length > 0 && !seenCadences.has(normalized)) {
|
|
5712
|
+
seenCadences.add(normalized);
|
|
5713
|
+
billingCadences.push(normalized);
|
|
5714
|
+
}
|
|
5715
|
+
}
|
|
5716
|
+
}
|
|
5717
|
+
const words = visibleText.toLowerCase().split(/[^a-z0-9.,+]+/).map((token) => token.replace(/^[.,]+/, "").replace(/[.,]+$/, "")).filter((token) => token.length > 0);
|
|
5718
|
+
for (let i = 0; i + 1 < words.length; i++) {
|
|
5719
|
+
const qty = words[i];
|
|
5720
|
+
if (qty === void 0 || !QUOTA_QUANTITY_TOKEN.test(qty)) continue;
|
|
5721
|
+
const next = words[i + 1];
|
|
5722
|
+
if (next === void 0) continue;
|
|
5723
|
+
const direct = QUOTA_UNIT_CANONICAL[next];
|
|
5724
|
+
if (direct !== void 0) {
|
|
5725
|
+
incrementUnit(direct);
|
|
5726
|
+
i += 1;
|
|
5727
|
+
continue;
|
|
5728
|
+
}
|
|
5729
|
+
if (QUOTA_MODIFIER_WORDS.has(next)) {
|
|
5730
|
+
const after = words[i + 2];
|
|
5731
|
+
const modified = after !== void 0 ? QUOTA_UNIT_CANONICAL[after] : void 0;
|
|
5732
|
+
if (modified !== void 0) {
|
|
5733
|
+
incrementUnit(modified);
|
|
5734
|
+
i += 2;
|
|
5735
|
+
}
|
|
5736
|
+
}
|
|
5737
|
+
}
|
|
5738
|
+
const detectedQuotaUnits = SAAS_QUOTA_UNITS.filter((unit) => (unitCounts[unit] ?? 0) > 0);
|
|
5739
|
+
const featureLimitCount = detectedQuotaUnits.reduce((sum, unit) => sum + (unitCounts[unit] ?? 0), 0);
|
|
5740
|
+
return {
|
|
5741
|
+
jsonLdOfferCount,
|
|
5742
|
+
jsonLdPricedOfferCount,
|
|
5743
|
+
visibleTierCount,
|
|
5744
|
+
visiblePriceCount,
|
|
5745
|
+
iconOnlyFeatureMatrix,
|
|
5746
|
+
iconOnlyCellCount,
|
|
5747
|
+
hasBillingToggleHint,
|
|
5748
|
+
billingToggleSinglePeriodOnly,
|
|
5749
|
+
billingCadences,
|
|
5750
|
+
featureLimitCount,
|
|
5751
|
+
featureLimitUnits: unitCounts,
|
|
5752
|
+
detectedQuotaUnits
|
|
5753
|
+
};
|
|
5754
|
+
}
|
|
5755
|
+
function declaredPageFacts(evidence) {
|
|
5756
|
+
const browser = evidence.probes.browser.result;
|
|
5757
|
+
const agent = evidence.probes.agent.result;
|
|
5758
|
+
const capture = browser.ok ? browser.capture : agent.ok ? agent.capture : null;
|
|
5759
|
+
if (capture === null) return null;
|
|
5760
|
+
const representation = buildRepresentation(capture);
|
|
5761
|
+
if (representation === null) return null;
|
|
5762
|
+
const extract = (kinds, currencyHint) => {
|
|
5763
|
+
const profile = {
|
|
5764
|
+
pageKind: "unknown",
|
|
5765
|
+
core: kinds,
|
|
5766
|
+
extended: [],
|
|
5767
|
+
byteReference: DEFAULT_RULESET.maxBodyBytes
|
|
5768
|
+
};
|
|
5769
|
+
return extractFacts(representation, {
|
|
5770
|
+
profile,
|
|
5771
|
+
ruleset: DEFAULT_RULESET,
|
|
5772
|
+
baseUrl: capture.finalUrl,
|
|
5773
|
+
origin: evidence.target.origin,
|
|
5774
|
+
currencyHint
|
|
5775
|
+
});
|
|
5776
|
+
};
|
|
5777
|
+
const currency = extract(["currency"], void 0).find((fact) => fact.kind === "currency");
|
|
5778
|
+
const facts = extract(["updated", "price"], currency?.normalized);
|
|
5779
|
+
let updated = null;
|
|
5780
|
+
const priceSources = [];
|
|
5781
|
+
for (const fact of facts) {
|
|
5782
|
+
if (fact.kind === "updated" && updated === null) updated = fact.normalized;
|
|
5783
|
+
if (fact.kind === "price" && !priceSources.includes(fact.source)) priceSources.push(fact.source);
|
|
5784
|
+
}
|
|
5785
|
+
return { updated, priceSources };
|
|
5786
|
+
}
|
|
5787
|
+
|
|
4726
5788
|
exports.AGENT_ACCEPT = AGENT_ACCEPT;
|
|
4727
5789
|
exports.ARS_CORPUS_HASH = ARS_CORPUS_HASH;
|
|
4728
5790
|
exports.ARS_HEURISTIC_WEIGHT = ARS_HEURISTIC_WEIGHT;
|
|
@@ -4735,19 +5797,36 @@ exports.BROWSER_ACCEPT = BROWSER_ACCEPT;
|
|
|
4735
5797
|
exports.CHECK_META = CHECK_META;
|
|
4736
5798
|
exports.DEFAULT_RULESET = DEFAULT_RULESET;
|
|
4737
5799
|
exports.DIMENSION_META = DIMENSION_META;
|
|
5800
|
+
exports.EDGE_CHALLENGE_VENDOR_LABEL = EDGE_CHALLENGE_VENDOR_LABEL;
|
|
4738
5801
|
exports.PROFILES = PROFILES;
|
|
5802
|
+
exports.SAAS_QUOTA_UNITS = SAAS_QUOTA_UNITS;
|
|
4739
5803
|
exports.SUBPOINTS = SUBPOINTS;
|
|
5804
|
+
exports.auditPricingAndLimits = auditPricingAndLimits;
|
|
4740
5805
|
exports.bandFor = bandFor;
|
|
4741
5806
|
exports.canonicalJson = canonicalJson;
|
|
5807
|
+
exports.challengeDetail = challengeDetail;
|
|
4742
5808
|
exports.classify = classify;
|
|
5809
|
+
exports.decideRobots = decideRobots;
|
|
5810
|
+
exports.declaredMarkdownAlternates = declaredMarkdownAlternates;
|
|
5811
|
+
exports.declaredPageFacts = declaredPageFacts;
|
|
5812
|
+
exports.detectEdgeChallenge = detectEdgeChallenge;
|
|
5813
|
+
exports.detectSpaJsDependency = detectSpaJsDependency;
|
|
5814
|
+
exports.edgeChallengeOf = edgeChallengeOf;
|
|
4743
5815
|
exports.evidenceHash = evidenceHash;
|
|
5816
|
+
exports.indexSignalsOf = indexSignalsOf;
|
|
5817
|
+
exports.isMachineCopy = isMachineCopy;
|
|
5818
|
+
exports.markdownAlternateTarget = markdownAlternateTarget;
|
|
4744
5819
|
exports.minorUnitDigits = minorUnitDigits;
|
|
5820
|
+
exports.pageIndexSignals = pageIndexSignals;
|
|
5821
|
+
exports.parseChallengeDetail = parseChallengeDetail;
|
|
5822
|
+
exports.parseContentSignals = parseContentSignals;
|
|
4745
5823
|
exports.parseMoneyText = parseMoneyText;
|
|
4746
5824
|
exports.parseRobots = parseRobots;
|
|
4747
5825
|
exports.pathMatches = pathMatches;
|
|
4748
5826
|
exports.profileFor = profileFor;
|
|
4749
5827
|
exports.recommend = recommend;
|
|
4750
5828
|
exports.robotsDisallowsScanner = robotsDisallowsScanner;
|
|
5829
|
+
exports.robotsEdgeChallengeOf = robotsEdgeChallengeOf;
|
|
4751
5830
|
exports.rulesetHash = rulesetHash;
|
|
4752
5831
|
exports.score = score;
|
|
4753
5832
|
exports.sha256Hex = sha256Hex;
|