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