@rebilder/agent-readability 0.1.1 → 0.3.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 +29 -0
- package/README.md +40 -158
- package/dist/index.cjs +266 -55
- package/dist/index.d.cts +206 -56
- package/dist/index.d.ts +206 -56
- package/dist/index.js +259 -54
- package/dist/index.js.map +1 -1
- package/dist/probe/index.cjs +106 -69
- package/dist/probe/index.d.cts +14 -9
- package/dist/probe/index.d.ts +14 -9
- package/dist/probe/index.js +106 -67
- package/dist/probe/index.js.map +1 -1
- package/dist/probe/local.cjs +106 -69
- package/dist/probe/local.d.cts +1 -1
- package/dist/probe/local.d.ts +1 -1
- package/dist/probe/local.js +106 -67
- package/dist/probe/local.js.map +1 -1
- package/dist/{types-B2FhQ1YC.d.ts → robots-policy-DE8jix-e.d.cts} +62 -9
- package/dist/{types-B2FhQ1YC.d.cts → robots-policy-DE8jix-e.d.ts} +62 -9
- package/package.json +22 -8
- package/dist/index.cjs.map +0 -1
- package/dist/probe/index.cjs.map +0 -1
- package/dist/probe/local.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/types.ts
|
|
4
|
-
var ARS_SPEC_VERSION = "0.
|
|
4
|
+
var ARS_SPEC_VERSION = "0.2.0";
|
|
5
5
|
|
|
6
6
|
// src/profiles.ts
|
|
7
7
|
var PROFILE_BY_KIND = {
|
|
@@ -66,13 +66,13 @@ function deepFreeze(value) {
|
|
|
66
66
|
return Object.freeze(value);
|
|
67
67
|
}
|
|
68
68
|
var WEIGHTS = {
|
|
69
|
-
// D1 Retrievability —
|
|
70
|
-
"retrievability.reachable":
|
|
71
|
-
"retrievability.robots-policy":
|
|
72
|
-
"retrievability.render-independence":
|
|
73
|
-
// D2 Machine representation —
|
|
74
|
-
"machine-representation.negotiated-response":
|
|
75
|
-
"machine-representation.declared-alternates":
|
|
69
|
+
// D1 Retrievability — 28
|
|
70
|
+
"retrievability.reachable": 11,
|
|
71
|
+
"retrievability.robots-policy": 10,
|
|
72
|
+
"retrievability.render-independence": 7,
|
|
73
|
+
// D2 Machine representation — 18
|
|
74
|
+
"machine-representation.negotiated-response": 9,
|
|
75
|
+
"machine-representation.declared-alternates": 3,
|
|
76
76
|
"machine-representation.vary-accept": 3,
|
|
77
77
|
"machine-representation.substance-parity": 3,
|
|
78
78
|
// D3 Fact coverage — 20
|
|
@@ -81,16 +81,20 @@ var WEIGHTS = {
|
|
|
81
81
|
// D4 Fact position — 10
|
|
82
82
|
"fact-position.first-core-fact-offset": 5,
|
|
83
83
|
"fact-position.front-window": 5,
|
|
84
|
-
// D5 Structured data —
|
|
85
|
-
"structured-data.present":
|
|
86
|
-
"structured-data.required-properties":
|
|
87
|
-
"structured-data.text-agreement":
|
|
88
|
-
// D6 Contract & discovery —
|
|
84
|
+
// D5 Structured data — 6
|
|
85
|
+
"structured-data.present": 2,
|
|
86
|
+
"structured-data.required-properties": 3,
|
|
87
|
+
"structured-data.text-agreement": 1,
|
|
88
|
+
// D6 Contract & discovery — 10
|
|
89
89
|
"contract-discovery.canonical": 4,
|
|
90
|
-
"contract-discovery.cache-validators":
|
|
91
|
-
"contract-discovery.llms-txt":
|
|
92
|
-
"contract-discovery.sitemap":
|
|
93
|
-
"contract-discovery.machine-endpoint":
|
|
90
|
+
"contract-discovery.cache-validators": 2,
|
|
91
|
+
"contract-discovery.llms-txt": 1,
|
|
92
|
+
"contract-discovery.sitemap": 1,
|
|
93
|
+
"contract-discovery.machine-endpoint": 2,
|
|
94
|
+
// D7 Evidence density — 8
|
|
95
|
+
"evidence-density.quantities": 4,
|
|
96
|
+
"evidence-density.definitions": 2,
|
|
97
|
+
"evidence-density.comparisons": 2
|
|
94
98
|
};
|
|
95
99
|
var CHECK_META = {
|
|
96
100
|
"retrievability.reachable": {
|
|
@@ -187,18 +191,34 @@ var CHECK_META = {
|
|
|
187
191
|
dimension: "contract-discovery",
|
|
188
192
|
label: "Declared machine endpoint",
|
|
189
193
|
basis: "measured"
|
|
194
|
+
},
|
|
195
|
+
"evidence-density.quantities": {
|
|
196
|
+
dimension: "evidence-density",
|
|
197
|
+
label: "Quantities an answer can quote",
|
|
198
|
+
basis: "measured"
|
|
199
|
+
},
|
|
200
|
+
"evidence-density.definitions": {
|
|
201
|
+
dimension: "evidence-density",
|
|
202
|
+
label: "Labelled term and value pairs",
|
|
203
|
+
basis: "heuristic"
|
|
204
|
+
},
|
|
205
|
+
"evidence-density.comparisons": {
|
|
206
|
+
dimension: "evidence-density",
|
|
207
|
+
label: "Comparable rows",
|
|
208
|
+
basis: "measured"
|
|
190
209
|
}
|
|
191
210
|
};
|
|
192
211
|
var DIMENSION_META = {
|
|
193
|
-
retrievability: { label: "Retrievability", weight:
|
|
194
|
-
"machine-representation": { label: "Machine representation", weight:
|
|
212
|
+
retrievability: { label: "Retrievability", weight: 28 },
|
|
213
|
+
"machine-representation": { label: "Machine representation", weight: 18 },
|
|
195
214
|
"fact-coverage": { label: "Fact coverage", weight: 20 },
|
|
196
215
|
"fact-position": { label: "Fact position", weight: 10 },
|
|
197
|
-
"structured-data": { label: "Structured data", weight:
|
|
198
|
-
"contract-discovery": { label: "Contract & discovery", weight:
|
|
216
|
+
"structured-data": { label: "Structured data", weight: 6 },
|
|
217
|
+
"contract-discovery": { label: "Contract & discovery", weight: 10 },
|
|
218
|
+
"evidence-density": { label: "Evidence density", weight: 8 }
|
|
199
219
|
};
|
|
200
|
-
var ARS_MEASURED_WEIGHT =
|
|
201
|
-
var ARS_HEURISTIC_WEIGHT =
|
|
220
|
+
var ARS_MEASURED_WEIGHT = 63;
|
|
221
|
+
var ARS_HEURISTIC_WEIGHT = 37;
|
|
202
222
|
var ARS_HEURISTIC_WEIGHT_CEILING = 40;
|
|
203
223
|
var THRESHOLDS = {
|
|
204
224
|
/**
|
|
@@ -230,6 +250,31 @@ var THRESHOLDS = {
|
|
|
230
250
|
* `ratio = 100 × bytes / byteReference[pageKind]`; above the last threshold, 0.
|
|
231
251
|
*/
|
|
232
252
|
"fact-coverage.context-cost": [100, 6, 200, 5, 500, 3, 1500, 1],
|
|
253
|
+
/**
|
|
254
|
+
* D7.1 quantities, 4 pts. AT-LEAST over the count of DISTINCT quantity tokens
|
|
255
|
+
* in the agent's counted text: a currency amount, a percentage, a number
|
|
256
|
+
* carrying a unit, or an ISO date. Distinct, because a price repeated in a
|
|
257
|
+
* header, a buy box and a footer is one fact stated three times, and counting
|
|
258
|
+
* it three times would reward the repetition this score exists to discourage.
|
|
259
|
+
* Saturates at 12 so a specification table cannot outscore a page that simply
|
|
260
|
+
* states its facts.
|
|
261
|
+
*/
|
|
262
|
+
"evidence-density.quantities": [12, 4, 6, 3, 3, 2, 1, 1],
|
|
263
|
+
/**
|
|
264
|
+
* D7.2 definitions, 2 pts. AT-LEAST over the count of `term: value` pairs the
|
|
265
|
+
* agent can read as a labelled fact, counting markdown bold-label lines,
|
|
266
|
+
* list items with a leading label, and HTML definition lists.
|
|
267
|
+
*/
|
|
268
|
+
"evidence-density.definitions": [6, 2, 2, 1],
|
|
269
|
+
/**
|
|
270
|
+
* D7.3 comparisons, 2 pts. AT-LEAST over the number of comparable ROWS: a
|
|
271
|
+
* table with at least two data columns contributes its data-row count, minus
|
|
272
|
+
* the header. One row is not a comparison, so the band starts at two; three
|
|
273
|
+
* options laid side by side is a full comparison and pays out. Calibrated
|
|
274
|
+
* against fixture `060`, where a three-row size table is exactly the shape
|
|
275
|
+
* this check exists to reward, and `063`, where one row is not.
|
|
276
|
+
*/
|
|
277
|
+
"evidence-density.comparisons": [3, 2, 2, 1],
|
|
233
278
|
/** D4.1 first-core-fact byte offset, 5 pts. AT-MOST over the offset in bytes; else 0. */
|
|
234
279
|
"fact-position.first-core-fact-offset": [512, 5, 2048, 4, 8192, 2, 32768, 1],
|
|
235
280
|
/**
|
|
@@ -370,7 +415,7 @@ var BANDS = [
|
|
|
370
415
|
}
|
|
371
416
|
];
|
|
372
417
|
var DEFAULT_RULESET = deepFreeze({
|
|
373
|
-
version: "0.
|
|
418
|
+
version: "0.2.0",
|
|
374
419
|
weights: WEIGHTS,
|
|
375
420
|
thresholds: THRESHOLDS,
|
|
376
421
|
audienceTokens: AUDIENCE_TOKENS,
|
|
@@ -2836,7 +2881,7 @@ var TEMPLATES = [
|
|
|
2836
2881
|
id: "publish-llms-txt",
|
|
2837
2882
|
title: "Publish /llms.txt",
|
|
2838
2883
|
effort: "config",
|
|
2839
|
-
detail: "An H1 title, a short summary, and links to the pages that matter. It is worth
|
|
2884
|
+
detail: "An H1 title, a short summary, and links to the pages that matter. It is worth 1 point of 100, deliberately: content negotiation is the mechanism that measurably improves retrieval, and we have observed no citation lift from llms.txt alone.",
|
|
2840
2885
|
checks: ["contract-discovery.llms-txt"],
|
|
2841
2886
|
unlocks: NO_UNLOCKS
|
|
2842
2887
|
},
|
|
@@ -2855,6 +2900,30 @@ var TEMPLATES = [
|
|
|
2855
2900
|
detail: "A feed, an OpenAPI document, /.well-known/ucp \u2014 anything an agent can call \u2014 declared with a `Link` header or a `<link>`. ARS probes /robots.txt, /llms.txt and /.well-known/ucp and guesses at no other path.",
|
|
2856
2901
|
checks: ["contract-discovery.machine-endpoint"],
|
|
2857
2902
|
unlocks: NO_UNLOCKS
|
|
2903
|
+
},
|
|
2904
|
+
{
|
|
2905
|
+
id: "state-quantities",
|
|
2906
|
+
title: "State the numbers in text",
|
|
2907
|
+
effort: "template",
|
|
2908
|
+
detail: "Price, sizes, weights, hours, fees, lead times, dates \u2014 written out where an agent reads them, not left in an image or implied by a paragraph. An assistant builds a cited answer out of quantities it can lift; distinct ones count, so saying the same price three times is one number.",
|
|
2909
|
+
checks: ["evidence-density.quantities"],
|
|
2910
|
+
unlocks: NO_UNLOCKS
|
|
2911
|
+
},
|
|
2912
|
+
{
|
|
2913
|
+
id: "label-facts",
|
|
2914
|
+
title: "Label each fact with its term",
|
|
2915
|
+
effort: "template",
|
|
2916
|
+
detail: 'A line that reads "Returns: 60 days" travels whole into an answer. The same fact inside a sentence has to be inferred, and an assistant that has to infer it usually leaves it out. Specification lists, definition lists and labelled bullets all count.',
|
|
2917
|
+
checks: ["evidence-density.definitions"],
|
|
2918
|
+
unlocks: NO_UNLOCKS
|
|
2919
|
+
},
|
|
2920
|
+
{
|
|
2921
|
+
id: "add-comparison-rows",
|
|
2922
|
+
title: "Put the options side by side",
|
|
2923
|
+
effort: "template",
|
|
2924
|
+
detail: "Sizes, tiers, models, plans \u2014 one row each, in a table with at least two columns. One row states a fact; two or more let an assistant contrast them, which is the question people actually ask it.",
|
|
2925
|
+
checks: ["evidence-density.comparisons"],
|
|
2926
|
+
unlocks: NO_UNLOCKS
|
|
2858
2927
|
}
|
|
2859
2928
|
];
|
|
2860
2929
|
var EFFORT_ORDER = ["config", "template", "engineering"];
|
|
@@ -2958,44 +3027,50 @@ function deepFreeze2(value) {
|
|
|
2958
3027
|
return Object.freeze(value);
|
|
2959
3028
|
}
|
|
2960
3029
|
var SUBPOINTS = deepFreeze2({
|
|
2961
|
-
/** D1.1,
|
|
2962
|
-
reachable: { status2xx:
|
|
2963
|
-
/** D1.2,
|
|
2964
|
-
robotsPolicy: { assistantAllowed:
|
|
3030
|
+
/** D1.1, 11 = 5 + 3 + 3. */
|
|
3031
|
+
reachable: { status2xx: 5, withinRedirectLimit: 3, noAcceptConditionalRedirect: 3 },
|
|
3032
|
+
/** D1.2, 10 = 6 + 2 + 1 + 1. A disallowed assistant audience scores 0 for all four (§3.7). */
|
|
3033
|
+
robotsPolicy: { assistantAllowed: 6, parsesClean: 2, noOrphanRules: 1, sitemapDeclared: 1 },
|
|
2965
3034
|
/**
|
|
2966
|
-
* D1.3,
|
|
3035
|
+
* D1.3, 7. AT-LEAST band over `100 × coreFactsInHtml / coreProfileSize`, plus
|
|
2967
3036
|
* the `<noscript>` floor: a page whose facts are all client-rendered but which
|
|
2968
3037
|
* ships a non-empty `<noscript>` has told a JS-less caller something, and §3.8
|
|
2969
3038
|
* says that earns partial credit.
|
|
2970
3039
|
*/
|
|
2971
3040
|
renderIndependence: {
|
|
2972
|
-
band: [100,
|
|
3041
|
+
band: [100, 7, 75, 5, 50, 3, 25, 1],
|
|
2973
3042
|
noscriptFloor: 1
|
|
2974
3043
|
},
|
|
2975
|
-
/** D2.1,
|
|
2976
|
-
negotiatedResponse: { full:
|
|
2977
|
-
/** D2.2,
|
|
2978
|
-
declaredAlternates: { full:
|
|
3044
|
+
/** D2.1, 9. All-or-nothing: a machine media type AND a body that is not HTML. */
|
|
3045
|
+
negotiatedResponse: { full: 9 },
|
|
3046
|
+
/** D2.2, 3. All-or-nothing. */
|
|
3047
|
+
declaredAlternates: { full: 3 },
|
|
2979
3048
|
/** D2.3, 3. All-or-nothing, and 0 unless D2.1 > 0. */
|
|
2980
3049
|
varyAccept: { full: 3 },
|
|
2981
3050
|
/** D2.4, 3. All-or-nothing, and 0 unless D2.1 > 0 and a browser capture exists. */
|
|
2982
3051
|
substanceParity: { full: 3 },
|
|
2983
|
-
/** D5.1,
|
|
2984
|
-
structuredDataPresent: { clean:
|
|
2985
|
-
/** D5.2,
|
|
2986
|
-
requiredProperties: { recognisedType:
|
|
2987
|
-
/** D5.3,
|
|
2988
|
-
textAgreement: { full:
|
|
3052
|
+
/** D5.1, 2. Structured data present AND parsing; a partly-broken graph scores 1. */
|
|
3053
|
+
structuredDataPresent: { clean: 2, partial: 1 },
|
|
3054
|
+
/** D5.2, 3 = 1 (a recognised type) + 2 (required-property completeness, scaled). */
|
|
3055
|
+
requiredProperties: { recognisedType: 1, completeness: 2 },
|
|
3056
|
+
/** D5.3, 1. All-or-nothing. */
|
|
3057
|
+
textAgreement: { full: 1 },
|
|
2989
3058
|
/** D6.1, 4 = 2 + 1 + 1. */
|
|
2990
3059
|
canonical: { present: 2, absolute: 1, consistentAcrossProbes: 1 },
|
|
2991
|
-
/** D6.2,
|
|
2992
|
-
cacheValidators: { saneCacheControl:
|
|
2993
|
-
/**
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
3060
|
+
/** D6.2, 2 = 1 + 1. */
|
|
3061
|
+
cacheValidators: { saneCacheControl: 1, validator: 1 },
|
|
3062
|
+
/**
|
|
3063
|
+
* D6.3, 1. `specShaped` — an H1 and at least one Markdown link — is the whole
|
|
3064
|
+
* point. `present` is 0 in 0.2: at two points 0.1 could pay one for the file
|
|
3065
|
+
* existing and one for it being usable, but at one point that split would make
|
|
3066
|
+
* "exists" and "usable" score identically, which is a distinction the standard
|
|
3067
|
+
* would then be printing a remedy for and paying nothing to fix.
|
|
3068
|
+
*/
|
|
3069
|
+
llmsTxt: { present: 0, specShaped: 1 },
|
|
3070
|
+
/** D6.4, 1. All-or-nothing. */
|
|
3071
|
+
sitemap: { full: 1 },
|
|
3072
|
+
/** D6.5, 2. All-or-nothing over any ONE declared machine endpoint. */
|
|
3073
|
+
machineEndpoint: { full: 2 }
|
|
2999
3074
|
});
|
|
3000
3075
|
var SHA256_K = [
|
|
3001
3076
|
1116352408,
|
|
@@ -3181,7 +3256,7 @@ function evidenceHash(evidence) {
|
|
|
3181
3256
|
})
|
|
3182
3257
|
);
|
|
3183
3258
|
}
|
|
3184
|
-
var ARS_CORPUS_HASH = sha256Hex("ars-0.
|
|
3259
|
+
var ARS_CORPUS_HASH = sha256Hex("ars-0.2-corpus-unfrozen");
|
|
3185
3260
|
function parseLinkHeaders(values) {
|
|
3186
3261
|
const out = [];
|
|
3187
3262
|
for (const value of values) {
|
|
@@ -3648,6 +3723,105 @@ function checkContextCost(context) {
|
|
|
3648
3723
|
remedy: earned === full ? void 0 : "Serve a representation sized to the facts. The reference is what a page of this kind reasonably costs, not an absolute budget."
|
|
3649
3724
|
};
|
|
3650
3725
|
}
|
|
3726
|
+
var QUANTITY = new RegExp(
|
|
3727
|
+
[
|
|
3728
|
+
String.raw`[$£€¥]\s?\d[\d,]*(?:\.\d+)?`,
|
|
3729
|
+
String.raw`\d[\d,]*(?:\.\d+)?\s?%`,
|
|
3730
|
+
String.raw`\d[\d,]*(?:\.\d+)?\s?(?:kg|g|lb|lbs|oz|mm|cm|m|km|mi|in|ft|ml|l|kb|mb|gb|tb|hz|w|kw|v|°c|°f|hours?|hrs?|minutes?|mins?|seconds?|secs?|days?|weeks?|months?|years?)\b`,
|
|
3731
|
+
String.raw`\d{4}-\d{2}-\d{2}`
|
|
3732
|
+
].join("|"),
|
|
3733
|
+
"giu"
|
|
3734
|
+
);
|
|
3735
|
+
var DEFINITION_LINE = /^\s*(?:[-*+]\s+)?(?:\*\*)?[A-Za-z][A-Za-z0-9 /&'()-]{1,40}(?:\*\*)?\s*:\s*\S/;
|
|
3736
|
+
var LABELLED_BLOCK_TAGS = /* @__PURE__ */ new Set(["li", "dt", "dd", "p", "td", "th", "div"]);
|
|
3737
|
+
function checkQuantities(context) {
|
|
3738
|
+
const table = context.ruleset.thresholds["evidence-density.quantities"];
|
|
3739
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3740
|
+
for (const match of context.agent.text.matchAll(QUANTITY)) {
|
|
3741
|
+
seen.add(match[0].toLowerCase().replace(/\s+/g, ""));
|
|
3742
|
+
}
|
|
3743
|
+
const count = seen.size;
|
|
3744
|
+
const earned = atLeast(table, count);
|
|
3745
|
+
const full = atLeast(table, Number.MAX_SAFE_INTEGER);
|
|
3746
|
+
return {
|
|
3747
|
+
earned,
|
|
3748
|
+
evidence: [measured("Distinct quantities an answer could quote", `${count}`)],
|
|
3749
|
+
remedy: earned === full ? void 0 : "State the numbers a reader would ask for, in text: price, sizes, hours, fees, dates. A quantity an agent can lift is what a cited answer is built from."
|
|
3750
|
+
};
|
|
3751
|
+
}
|
|
3752
|
+
function labelledSegments(context) {
|
|
3753
|
+
const doc = context.agent.doc;
|
|
3754
|
+
if (doc === null) return context.agent.text.split("\n");
|
|
3755
|
+
const byElement = /* @__PURE__ */ new Map();
|
|
3756
|
+
for (const node of doc.texts) {
|
|
3757
|
+
if (node.excludedBy !== null) continue;
|
|
3758
|
+
if (node.text.trim().length === 0) continue;
|
|
3759
|
+
let at = node.parent;
|
|
3760
|
+
for (let hops = 0; at >= 0 && hops <= MAX_ANCESTOR_HOPS; hops += 1) {
|
|
3761
|
+
const element = doc.elements[at];
|
|
3762
|
+
if (element === void 0) break;
|
|
3763
|
+
if (LABELLED_BLOCK_TAGS.has(element.tag)) {
|
|
3764
|
+
const parts = byElement.get(at);
|
|
3765
|
+
if (parts === void 0) byElement.set(at, [node.text]);
|
|
3766
|
+
else parts.push(node.text);
|
|
3767
|
+
break;
|
|
3768
|
+
}
|
|
3769
|
+
at = element.parent;
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
const segments = [];
|
|
3773
|
+
for (const parts of byElement.values()) {
|
|
3774
|
+
segments.push(parts.join(" ").replace(/\s+/g, " ").trim());
|
|
3775
|
+
}
|
|
3776
|
+
return segments;
|
|
3777
|
+
}
|
|
3778
|
+
var MAX_ANCESTOR_HOPS = 256;
|
|
3779
|
+
function checkDefinitions(context) {
|
|
3780
|
+
const table = context.ruleset.thresholds["evidence-density.definitions"];
|
|
3781
|
+
let count = 0;
|
|
3782
|
+
for (const line of labelledSegments(context)) {
|
|
3783
|
+
if (DEFINITION_LINE.test(line)) count += 1;
|
|
3784
|
+
}
|
|
3785
|
+
const earned = atLeast(table, count);
|
|
3786
|
+
const full = atLeast(table, Number.MAX_SAFE_INTEGER);
|
|
3787
|
+
return {
|
|
3788
|
+
earned,
|
|
3789
|
+
evidence: [heuristic("Labelled term and value pairs", `${count}`)],
|
|
3790
|
+
remedy: earned === full ? void 0 : 'Label your facts. A line that reads "Returns: 60 days" is liftable whole; the same fact inside a paragraph has to be inferred.'
|
|
3791
|
+
};
|
|
3792
|
+
}
|
|
3793
|
+
function checkComparisons(context) {
|
|
3794
|
+
const table = context.ruleset.thresholds["evidence-density.comparisons"];
|
|
3795
|
+
let rows = 0;
|
|
3796
|
+
const doc = context.agent.doc;
|
|
3797
|
+
if (doc !== null) {
|
|
3798
|
+
const cellsByRow = /* @__PURE__ */ new Map();
|
|
3799
|
+
for (const element of doc.elements) {
|
|
3800
|
+
if (element.tag !== "td" && element.tag !== "th") continue;
|
|
3801
|
+
const row = doc.elements[element.parent];
|
|
3802
|
+
if (row === void 0 || row.tag !== "tr") continue;
|
|
3803
|
+
cellsByRow.set(element.parent, (cellsByRow.get(element.parent) ?? 0) + 1);
|
|
3804
|
+
}
|
|
3805
|
+
for (const cells of cellsByRow.values()) if (cells >= 2) rows += 1;
|
|
3806
|
+
rows = Math.max(0, rows - 1);
|
|
3807
|
+
} else {
|
|
3808
|
+
let pipeRows = 0;
|
|
3809
|
+
for (const line of context.agent.text.split("\n")) {
|
|
3810
|
+
const trimmed = line.trim();
|
|
3811
|
+
if (!trimmed.startsWith("|") || !trimmed.endsWith("|")) continue;
|
|
3812
|
+
if (/^\|[\s:|-]+\|$/.test(trimmed)) continue;
|
|
3813
|
+
if (trimmed.split("|").length - 2 >= 2) pipeRows += 1;
|
|
3814
|
+
}
|
|
3815
|
+
rows = Math.max(0, pipeRows - 1);
|
|
3816
|
+
}
|
|
3817
|
+
const earned = atLeast(table, rows);
|
|
3818
|
+
const full = atLeast(table, Number.MAX_SAFE_INTEGER);
|
|
3819
|
+
return {
|
|
3820
|
+
earned,
|
|
3821
|
+
evidence: [measured("Comparable rows", `${rows}`)],
|
|
3822
|
+
remedy: earned === full ? void 0 : "Put options side by side in a table with a row each. An assistant comparing two things reaches for rows it can line up."
|
|
3823
|
+
};
|
|
3824
|
+
}
|
|
3651
3825
|
function coreOffsets(context) {
|
|
3652
3826
|
const offsets = [];
|
|
3653
3827
|
for (const fact of context.facts)
|
|
@@ -3893,7 +4067,7 @@ function checkLlmsTxt(context) {
|
|
|
3893
4067
|
return {
|
|
3894
4068
|
earned: 0,
|
|
3895
4069
|
evidence: [measured("/llms.txt", body === null ? "absent or non-2xx" : "empty")],
|
|
3896
|
-
remedy: "Publish /llms.txt: an H1 title, a short summary, and links to the pages that matter. It is worth
|
|
4070
|
+
remedy: "Publish /llms.txt: an H1 title, a short summary, and links to the pages that matter. It is worth 1 point of 100, deliberately."
|
|
3897
4071
|
};
|
|
3898
4072
|
}
|
|
3899
4073
|
const hasTitle = /^#\s+\S/m.test(body);
|
|
@@ -4023,7 +4197,8 @@ var DIMENSION_ORDER = [
|
|
|
4023
4197
|
"fact-coverage",
|
|
4024
4198
|
"fact-position",
|
|
4025
4199
|
"structured-data",
|
|
4026
|
-
"contract-discovery"
|
|
4200
|
+
"contract-discovery",
|
|
4201
|
+
"evidence-density"
|
|
4027
4202
|
];
|
|
4028
4203
|
function buildDimensions(checks) {
|
|
4029
4204
|
return DIMENSION_ORDER.map((id) => {
|
|
@@ -4439,7 +4614,10 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4439
4614
|
buildCheck(ruleset, "contract-discovery.cache-validators", checkCacheValidators(context)),
|
|
4440
4615
|
buildCheck(ruleset, "contract-discovery.llms-txt", checkLlmsTxt(context)),
|
|
4441
4616
|
buildCheck(ruleset, "contract-discovery.sitemap", checkSitemap(context)),
|
|
4442
|
-
buildCheck(ruleset, "contract-discovery.machine-endpoint", checkMachineEndpoint(context))
|
|
4617
|
+
buildCheck(ruleset, "contract-discovery.machine-endpoint", checkMachineEndpoint(context)),
|
|
4618
|
+
buildCheck(ruleset, "evidence-density.quantities", checkQuantities(context)),
|
|
4619
|
+
buildCheck(ruleset, "evidence-density.definitions", checkDefinitions(context)),
|
|
4620
|
+
buildCheck(ruleset, "evidence-density.comparisons", checkComparisons(context))
|
|
4443
4621
|
];
|
|
4444
4622
|
const dimensions = buildDimensions(checks);
|
|
4445
4623
|
const total = dimensions.reduce((sum, dimension) => sum + dimension.earned, 0);
|
|
@@ -4518,11 +4696,42 @@ function decideScannerToken(robots, path) {
|
|
|
4518
4696
|
return null;
|
|
4519
4697
|
}
|
|
4520
4698
|
|
|
4699
|
+
// src/probe/headers.ts
|
|
4700
|
+
var AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
|
|
4701
|
+
var BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
|
|
4702
|
+
var ASSET_ACCEPT = "text/plain,*/*;q=0.5";
|
|
4703
|
+
|
|
4704
|
+
// src/robots-policy.ts
|
|
4705
|
+
var ARS_ROBOTS_TOKEN = "rebilder-ars";
|
|
4706
|
+
function robotsDisallowsScanner(robotsBody, path) {
|
|
4707
|
+
const robots = parseRobots(robotsBody);
|
|
4708
|
+
for (const group of robots.groups) {
|
|
4709
|
+
if (!group.agents.some((agent) => agent.toLowerCase() === ARS_ROBOTS_TOKEN)) continue;
|
|
4710
|
+
let best = null;
|
|
4711
|
+
for (const value of group.allow) {
|
|
4712
|
+
if (!pathMatches(value, path)) continue;
|
|
4713
|
+
if (best === null || value.length > best.value.length) best = { field: "allow", value };
|
|
4714
|
+
}
|
|
4715
|
+
for (const value of group.disallow) {
|
|
4716
|
+
if (!pathMatches(value, path)) continue;
|
|
4717
|
+
if (best === null || value.length > best.value.length) best = { field: "disallow", value };
|
|
4718
|
+
}
|
|
4719
|
+
if (best !== null && best.field === "disallow") {
|
|
4720
|
+
return `User-agent: ${ARS_ROBOTS_TOKEN} / Disallow: ${best.value}`;
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
return null;
|
|
4724
|
+
}
|
|
4725
|
+
|
|
4726
|
+
exports.AGENT_ACCEPT = AGENT_ACCEPT;
|
|
4521
4727
|
exports.ARS_CORPUS_HASH = ARS_CORPUS_HASH;
|
|
4522
4728
|
exports.ARS_HEURISTIC_WEIGHT = ARS_HEURISTIC_WEIGHT;
|
|
4523
4729
|
exports.ARS_HEURISTIC_WEIGHT_CEILING = ARS_HEURISTIC_WEIGHT_CEILING;
|
|
4524
4730
|
exports.ARS_MEASURED_WEIGHT = ARS_MEASURED_WEIGHT;
|
|
4731
|
+
exports.ARS_ROBOTS_TOKEN = ARS_ROBOTS_TOKEN;
|
|
4525
4732
|
exports.ARS_SPEC_VERSION = ARS_SPEC_VERSION;
|
|
4733
|
+
exports.ASSET_ACCEPT = ASSET_ACCEPT;
|
|
4734
|
+
exports.BROWSER_ACCEPT = BROWSER_ACCEPT;
|
|
4526
4735
|
exports.CHECK_META = CHECK_META;
|
|
4527
4736
|
exports.DEFAULT_RULESET = DEFAULT_RULESET;
|
|
4528
4737
|
exports.DIMENSION_META = DIMENSION_META;
|
|
@@ -4534,10 +4743,12 @@ exports.classify = classify;
|
|
|
4534
4743
|
exports.evidenceHash = evidenceHash;
|
|
4535
4744
|
exports.minorUnitDigits = minorUnitDigits;
|
|
4536
4745
|
exports.parseMoneyText = parseMoneyText;
|
|
4746
|
+
exports.parseRobots = parseRobots;
|
|
4747
|
+
exports.pathMatches = pathMatches;
|
|
4537
4748
|
exports.profileFor = profileFor;
|
|
4538
4749
|
exports.recommend = recommend;
|
|
4750
|
+
exports.robotsDisallowsScanner = robotsDisallowsScanner;
|
|
4539
4751
|
exports.rulesetHash = rulesetHash;
|
|
4540
4752
|
exports.score = score;
|
|
4541
4753
|
exports.sha256Hex = sha256Hex;
|
|
4542
|
-
|
|
4543
|
-
//# sourceMappingURL=index.cjs.map
|
|
4754
|
+
exports.utf8Length = utf8Length;
|