@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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * types.ts — the public contract of the Agent Readability Score, ARS 0.1.
2
+ * types.ts — the public contract of the Agent Readability Score, ARS 0.2.
3
3
  *
4
4
  * Transcribed from `docs/design/universal-gateway-and-public-surfaces.md` §3.9,
5
5
  * which is the decided contract. Where §3.9 abbreviates (it writes `id: string`
@@ -9,7 +9,7 @@
9
9
  * nothing else departs from the design.
10
10
  *
11
11
  * WHY THE TYPES MATTER MORE THAN USUAL HERE. ARS is published as a standard
12
- * (`docs/spec/ars-0.1.md`, rendered at `/spec/ars`), and its determinism
12
+ * (`docs/spec/ars-0.2.md`, rendered at `/spec/ars`), and its determinism
13
13
  * guarantee is stated as: *for a given `evidenceHash`, `rulesetHash` and
14
14
  * `corpusHash`, `score()` returns a byte-identical `ArsResult` in any conformant
15
15
  * implementation, in any language.* A second implementation in Go or Python
@@ -23,8 +23,20 @@
23
23
  * clock, no network, no randomness, no LLM. The ESLint rule in
24
24
  * `eslint.config.mjs` enforces that at build time.
25
25
  */
26
- /** The spec version this package implements. See §3.1 for the versioning rules. */
27
- declare const ARS_SPEC_VERSION: "0.1.0";
26
+ /**
27
+ * The spec version this package implements. See §3.1 for the versioning rules.
28
+ *
29
+ * THIS IS THE SECOND PLACE THE VERSION IS WRITTEN — `DEFAULT_RULESET.version` is
30
+ * the first — and the two are asserted equal in `tests/score.test.ts` for the
31
+ * same reason `SUBPOINTS` is asserted against `WEIGHTS`: they disagreed once,
32
+ * during the 0.2 rebalance, and the visible symptom was every result printing
33
+ * `specVersion: '0.1.0'` next to a 0.2 `rulesetHash`. A score whose two identity
34
+ * fields name different versions is worse than one that names neither.
35
+ *
36
+ * It cannot simply be re-exported from the ruleset: `types.ts` is the bottom of
37
+ * the import graph and `ruleset.ts` imports from it.
38
+ */
39
+ declare const ARS_SPEC_VERSION: "0.2.0";
28
40
  /**
29
41
  * Where the scan was taken from.
30
42
  * - `public` — an anonymous third-party scan. The only vantage that is robots-gated.
@@ -37,7 +49,7 @@ type ArsVantage = 'public' | 'authenticated' | 'self';
37
49
  /**
38
50
  * Whether a check's earned points come from an observation or from an inference.
39
51
  * Published per check, and the total heuristic weight is capped at 40 of 100
40
- * (36 in 0.1) and printed. See §3.4.
52
+ * (37 in 0.2) and printed. See §5.1.
41
53
  */
42
54
  type ArsBasis = 'measured' | 'heuristic';
43
55
  type ArsGrade = 'A' | 'B' | 'C' | 'D' | 'F';
@@ -175,9 +187,9 @@ interface ArsFactObservation {
175
187
  /** Observed in ≥2 sources (e.g. JSON-LD and visible text). §3.6. */
176
188
  corroborated: boolean;
177
189
  }
178
- type ArsDimensionId = 'retrievability' | 'machine-representation' | 'fact-coverage' | 'fact-position' | 'structured-data' | 'contract-discovery';
190
+ type ArsDimensionId = 'retrievability' | 'machine-representation' | 'fact-coverage' | 'fact-position' | 'structured-data' | 'contract-discovery' | 'evidence-density';
179
191
  /**
180
- * Every check id in ARS 0.1, in dimension order, matching the §3.4 table row for
192
+ * Every check id in ARS 0.2, in dimension order, matching the §5.1 table row for
181
193
  * row. The `<dimension>.<check>` shape is normative: the prefix IS the
182
194
  * `ArsDimensionId`, so a check's dimension is derivable from its id and the two
183
195
  * can never disagree. §3.9 demonstrates the format with
@@ -188,7 +200,7 @@ type ArsDimensionId = 'retrievability' | 'machine-representation' | 'fact-covera
188
200
  * ids are published in the spec and appear in every `expected.json`; an
189
201
  * unconstrained string in a frozen contract is a typo waiting to ship.
190
202
  */
191
- type ArsCheckId = 'retrievability.reachable' | 'retrievability.robots-policy' | 'retrievability.render-independence' | 'machine-representation.negotiated-response' | 'machine-representation.declared-alternates' | 'machine-representation.vary-accept' | 'machine-representation.substance-parity' | 'fact-coverage.core-facts' | 'fact-coverage.context-cost' | 'fact-position.first-core-fact-offset' | 'fact-position.front-window' | 'structured-data.present' | 'structured-data.required-properties' | 'structured-data.text-agreement' | 'contract-discovery.canonical' | 'contract-discovery.cache-validators' | 'contract-discovery.llms-txt' | 'contract-discovery.sitemap' | 'contract-discovery.machine-endpoint';
203
+ type ArsCheckId = 'retrievability.reachable' | 'retrievability.robots-policy' | 'retrievability.render-independence' | 'machine-representation.negotiated-response' | 'machine-representation.declared-alternates' | 'machine-representation.vary-accept' | 'machine-representation.substance-parity' | 'fact-coverage.core-facts' | 'fact-coverage.context-cost' | 'fact-position.first-core-fact-offset' | 'fact-position.front-window' | 'structured-data.present' | 'structured-data.required-properties' | 'structured-data.text-agreement' | 'contract-discovery.canonical' | 'contract-discovery.cache-validators' | 'contract-discovery.llms-txt' | 'contract-discovery.sitemap' | 'contract-discovery.machine-endpoint' | 'evidence-density.quantities' | 'evidence-density.definitions' | 'evidence-density.comparisons';
192
204
  interface ArsCheckEvidence {
193
205
  label: string;
194
206
  value: string;
@@ -342,4 +354,45 @@ interface ArsRuleset {
342
354
  bands: readonly ArsBand[];
343
355
  }
344
356
 
345
- export { type ArsDimensionId as A, type ArsUnscoredReason as B, type ArsVantage as C, type ArsBasis as a, type ArsFactProfile as b, type ArsRuleset as c, type ArsBand as d, type ArsEvidence as e, type ArsResult as f, type ArsRecommendation as g, type ArsPageKind as h, ARS_SPEC_VERSION as i, type ArsAudience as j, type ArsAudienceDecision as k, type ArsCheck as l, type ArsCheckEvidence as m, type ArsCheckId as n, type ArsCostReport as o, type ArsDimension as p, type ArsFactKind as q, type ArsFactObservation as r, type ArsFlag as s, type ArsFlagId as t, type ArsGrade as u, type ArsHttpCapture as v, type ArsOutcome as w, type ArsPolicyReport as x, type ArsProbeError as y, type ArsProbeRecord as z };
357
+ /**
358
+ * The two request identities the standard is defined in terms of, in a leaf
359
+ * module so a browser can import them without pulling in the Node probe.
360
+ *
361
+ * D2.4 IS THE REASON THESE ARE NORMATIVE. It compares what an origin serves an
362
+ * agent against what it serves a browser, and the comparison is only meaningful
363
+ * because the two requests differ in exactly one header. A probe that invents
364
+ * its own `Accept` strings is measuring a different thing and reporting it under
365
+ * the same name — which is worse than not measuring it, because the number still
366
+ * looks like an ARS number.
367
+ */
368
+ declare const AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
369
+ declare const BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
370
+ declare const ASSET_ACCEPT = "text/plain,*/*;q=0.5";
371
+
372
+ /**
373
+ * The robots.txt token this scanner answers to. Matched case-insensitively.
374
+ *
375
+ * IT IS NOT VERSIONED, DELIBERATELY. A site that disallowed us under ARS 0.1 is
376
+ * still refusing us under 0.2. Versioning the refusal token would let a spec
377
+ * bump quietly re-open sites that already said no.
378
+ */
379
+ declare const ARS_ROBOTS_TOKEN = "rebilder-ars";
380
+ /**
381
+ * Has this origin refused this path, by name? Returns the matching rule as a
382
+ * human-readable string, or `null` when it has not.
383
+ *
384
+ * ONLY A GROUP THAT NAMES THE TOKEN COUNTS. A blanket `User-agent: *` disallow
385
+ * is not a decision about us — it is the accidental case, which §3.7 scores with
386
+ * a `robots-contradiction` flag rather than treating as consent or as refusal.
387
+ * Reading a generic bot block as a refusal would also make the honest thing
388
+ * (asking first) indistinguishable from the useless thing (refusing to look at
389
+ * most of the web), and a scanner nobody can run is not a safer scanner.
390
+ *
391
+ * Rule selection uses `pathMatches`, the same matcher the scorer uses, so the
392
+ * fetch gate and the published audience decision can never disagree about what
393
+ * a pattern means. Longest match wins, `allow` beating `disallow` at equal
394
+ * length by virtue of being tested first.
395
+ */
396
+ declare function robotsDisallowsScanner(robotsBody: string, path: string): string | null;
397
+
398
+ export { type ArsDimensionId as A, type ArsPolicyReport as B, type ArsProbeError as C, type ArsProbeRecord as D, type ArsUnscoredReason as E, type ArsVantage as F, BROWSER_ACCEPT as G, robotsDisallowsScanner as H, type ArsBasis as a, type ArsFactProfile as b, type ArsRuleset as c, type ArsBand as d, type ArsEvidence as e, type ArsResult as f, type ArsRecommendation as g, type ArsPageKind as h, AGENT_ACCEPT as i, ARS_ROBOTS_TOKEN as j, ARS_SPEC_VERSION as k, ASSET_ACCEPT as l, type ArsAudience as m, type ArsAudienceDecision as n, type ArsCheck as o, type ArsCheckEvidence as p, type ArsCheckId as q, type ArsCostReport as r, type ArsDimension as s, type ArsFactKind as t, type ArsFactObservation as u, type ArsFlag as v, type ArsFlagId as w, type ArsGrade as x, type ArsHttpCapture as y, type ArsOutcome as z };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * types.ts — the public contract of the Agent Readability Score, ARS 0.1.
2
+ * types.ts — the public contract of the Agent Readability Score, ARS 0.2.
3
3
  *
4
4
  * Transcribed from `docs/design/universal-gateway-and-public-surfaces.md` §3.9,
5
5
  * which is the decided contract. Where §3.9 abbreviates (it writes `id: string`
@@ -9,7 +9,7 @@
9
9
  * nothing else departs from the design.
10
10
  *
11
11
  * WHY THE TYPES MATTER MORE THAN USUAL HERE. ARS is published as a standard
12
- * (`docs/spec/ars-0.1.md`, rendered at `/spec/ars`), and its determinism
12
+ * (`docs/spec/ars-0.2.md`, rendered at `/spec/ars`), and its determinism
13
13
  * guarantee is stated as: *for a given `evidenceHash`, `rulesetHash` and
14
14
  * `corpusHash`, `score()` returns a byte-identical `ArsResult` in any conformant
15
15
  * implementation, in any language.* A second implementation in Go or Python
@@ -23,8 +23,20 @@
23
23
  * clock, no network, no randomness, no LLM. The ESLint rule in
24
24
  * `eslint.config.mjs` enforces that at build time.
25
25
  */
26
- /** The spec version this package implements. See §3.1 for the versioning rules. */
27
- declare const ARS_SPEC_VERSION: "0.1.0";
26
+ /**
27
+ * The spec version this package implements. See §3.1 for the versioning rules.
28
+ *
29
+ * THIS IS THE SECOND PLACE THE VERSION IS WRITTEN — `DEFAULT_RULESET.version` is
30
+ * the first — and the two are asserted equal in `tests/score.test.ts` for the
31
+ * same reason `SUBPOINTS` is asserted against `WEIGHTS`: they disagreed once,
32
+ * during the 0.2 rebalance, and the visible symptom was every result printing
33
+ * `specVersion: '0.1.0'` next to a 0.2 `rulesetHash`. A score whose two identity
34
+ * fields name different versions is worse than one that names neither.
35
+ *
36
+ * It cannot simply be re-exported from the ruleset: `types.ts` is the bottom of
37
+ * the import graph and `ruleset.ts` imports from it.
38
+ */
39
+ declare const ARS_SPEC_VERSION: "0.2.0";
28
40
  /**
29
41
  * Where the scan was taken from.
30
42
  * - `public` — an anonymous third-party scan. The only vantage that is robots-gated.
@@ -37,7 +49,7 @@ type ArsVantage = 'public' | 'authenticated' | 'self';
37
49
  /**
38
50
  * Whether a check's earned points come from an observation or from an inference.
39
51
  * Published per check, and the total heuristic weight is capped at 40 of 100
40
- * (36 in 0.1) and printed. See §3.4.
52
+ * (37 in 0.2) and printed. See §5.1.
41
53
  */
42
54
  type ArsBasis = 'measured' | 'heuristic';
43
55
  type ArsGrade = 'A' | 'B' | 'C' | 'D' | 'F';
@@ -175,9 +187,9 @@ interface ArsFactObservation {
175
187
  /** Observed in ≥2 sources (e.g. JSON-LD and visible text). §3.6. */
176
188
  corroborated: boolean;
177
189
  }
178
- type ArsDimensionId = 'retrievability' | 'machine-representation' | 'fact-coverage' | 'fact-position' | 'structured-data' | 'contract-discovery';
190
+ type ArsDimensionId = 'retrievability' | 'machine-representation' | 'fact-coverage' | 'fact-position' | 'structured-data' | 'contract-discovery' | 'evidence-density';
179
191
  /**
180
- * Every check id in ARS 0.1, in dimension order, matching the §3.4 table row for
192
+ * Every check id in ARS 0.2, in dimension order, matching the §5.1 table row for
181
193
  * row. The `<dimension>.<check>` shape is normative: the prefix IS the
182
194
  * `ArsDimensionId`, so a check's dimension is derivable from its id and the two
183
195
  * can never disagree. §3.9 demonstrates the format with
@@ -188,7 +200,7 @@ type ArsDimensionId = 'retrievability' | 'machine-representation' | 'fact-covera
188
200
  * ids are published in the spec and appear in every `expected.json`; an
189
201
  * unconstrained string in a frozen contract is a typo waiting to ship.
190
202
  */
191
- type ArsCheckId = 'retrievability.reachable' | 'retrievability.robots-policy' | 'retrievability.render-independence' | 'machine-representation.negotiated-response' | 'machine-representation.declared-alternates' | 'machine-representation.vary-accept' | 'machine-representation.substance-parity' | 'fact-coverage.core-facts' | 'fact-coverage.context-cost' | 'fact-position.first-core-fact-offset' | 'fact-position.front-window' | 'structured-data.present' | 'structured-data.required-properties' | 'structured-data.text-agreement' | 'contract-discovery.canonical' | 'contract-discovery.cache-validators' | 'contract-discovery.llms-txt' | 'contract-discovery.sitemap' | 'contract-discovery.machine-endpoint';
203
+ type ArsCheckId = 'retrievability.reachable' | 'retrievability.robots-policy' | 'retrievability.render-independence' | 'machine-representation.negotiated-response' | 'machine-representation.declared-alternates' | 'machine-representation.vary-accept' | 'machine-representation.substance-parity' | 'fact-coverage.core-facts' | 'fact-coverage.context-cost' | 'fact-position.first-core-fact-offset' | 'fact-position.front-window' | 'structured-data.present' | 'structured-data.required-properties' | 'structured-data.text-agreement' | 'contract-discovery.canonical' | 'contract-discovery.cache-validators' | 'contract-discovery.llms-txt' | 'contract-discovery.sitemap' | 'contract-discovery.machine-endpoint' | 'evidence-density.quantities' | 'evidence-density.definitions' | 'evidence-density.comparisons';
192
204
  interface ArsCheckEvidence {
193
205
  label: string;
194
206
  value: string;
@@ -342,4 +354,45 @@ interface ArsRuleset {
342
354
  bands: readonly ArsBand[];
343
355
  }
344
356
 
345
- export { type ArsDimensionId as A, type ArsUnscoredReason as B, type ArsVantage as C, type ArsBasis as a, type ArsFactProfile as b, type ArsRuleset as c, type ArsBand as d, type ArsEvidence as e, type ArsResult as f, type ArsRecommendation as g, type ArsPageKind as h, ARS_SPEC_VERSION as i, type ArsAudience as j, type ArsAudienceDecision as k, type ArsCheck as l, type ArsCheckEvidence as m, type ArsCheckId as n, type ArsCostReport as o, type ArsDimension as p, type ArsFactKind as q, type ArsFactObservation as r, type ArsFlag as s, type ArsFlagId as t, type ArsGrade as u, type ArsHttpCapture as v, type ArsOutcome as w, type ArsPolicyReport as x, type ArsProbeError as y, type ArsProbeRecord as z };
357
+ /**
358
+ * The two request identities the standard is defined in terms of, in a leaf
359
+ * module so a browser can import them without pulling in the Node probe.
360
+ *
361
+ * D2.4 IS THE REASON THESE ARE NORMATIVE. It compares what an origin serves an
362
+ * agent against what it serves a browser, and the comparison is only meaningful
363
+ * because the two requests differ in exactly one header. A probe that invents
364
+ * its own `Accept` strings is measuring a different thing and reporting it under
365
+ * the same name — which is worse than not measuring it, because the number still
366
+ * looks like an ARS number.
367
+ */
368
+ declare const AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
369
+ declare const BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
370
+ declare const ASSET_ACCEPT = "text/plain,*/*;q=0.5";
371
+
372
+ /**
373
+ * The robots.txt token this scanner answers to. Matched case-insensitively.
374
+ *
375
+ * IT IS NOT VERSIONED, DELIBERATELY. A site that disallowed us under ARS 0.1 is
376
+ * still refusing us under 0.2. Versioning the refusal token would let a spec
377
+ * bump quietly re-open sites that already said no.
378
+ */
379
+ declare const ARS_ROBOTS_TOKEN = "rebilder-ars";
380
+ /**
381
+ * Has this origin refused this path, by name? Returns the matching rule as a
382
+ * human-readable string, or `null` when it has not.
383
+ *
384
+ * ONLY A GROUP THAT NAMES THE TOKEN COUNTS. A blanket `User-agent: *` disallow
385
+ * is not a decision about us — it is the accidental case, which §3.7 scores with
386
+ * a `robots-contradiction` flag rather than treating as consent or as refusal.
387
+ * Reading a generic bot block as a refusal would also make the honest thing
388
+ * (asking first) indistinguishable from the useless thing (refusing to look at
389
+ * most of the web), and a scanner nobody can run is not a safer scanner.
390
+ *
391
+ * Rule selection uses `pathMatches`, the same matcher the scorer uses, so the
392
+ * fetch gate and the published audience decision can never disagree about what
393
+ * a pattern means. Longest match wins, `allow` beating `disallow` at equal
394
+ * length by virtue of being tested first.
395
+ */
396
+ declare function robotsDisallowsScanner(robotsBody: string, path: string): string | null;
397
+
398
+ export { type ArsDimensionId as A, type ArsPolicyReport as B, type ArsProbeError as C, type ArsProbeRecord as D, type ArsUnscoredReason as E, type ArsVantage as F, BROWSER_ACCEPT as G, robotsDisallowsScanner as H, type ArsBasis as a, type ArsFactProfile as b, type ArsRuleset as c, type ArsBand as d, type ArsEvidence as e, type ArsResult as f, type ArsRecommendation as g, type ArsPageKind as h, AGENT_ACCEPT as i, ARS_ROBOTS_TOKEN as j, ARS_SPEC_VERSION as k, ASSET_ACCEPT as l, type ArsAudience as m, type ArsAudienceDecision as n, type ArsCheck as o, type ArsCheckEvidence as p, type ArsCheckId as q, type ArsCostReport as r, type ArsDimension as s, type ArsFactKind as t, type ArsFactObservation as u, type ArsFlag as v, type ArsFlagId as w, type ArsGrade as x, type ArsHttpCapture as y, type ArsOutcome as z };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@rebilder/agent-readability",
3
- "version": "0.1.1",
3
+ "version": "0.3.0",
4
4
  "private": false,
5
- "description": "The Agent Readability Score (ARS 0.1). A pure, deterministic scorer at \".\" — no network, no clock, no randomness, no LLM — and a server-only probe at \"./probe\". Zero runtime dependencies.",
5
+ "description": "Score how well AI agents can read a web page. The reference implementation of the Rebilder Agent Readability Spec (ARS): deterministic, no dependencies, with a safe fetcher for live pages.",
6
6
  "license": "Apache-2.0",
7
7
  "homepage": "https://rebilder.com/spec/ars",
8
8
  "bugs": {
@@ -10,22 +10,36 @@
10
10
  "email": "support@rebilder.com"
11
11
  },
12
12
  "keywords": [
13
- "ars",
13
+ "ai",
14
+ "llm",
15
+ "ai-agents",
14
16
  "agent-readability",
17
+ "ars",
15
18
  "seo",
16
19
  "llms-txt",
17
- "agents",
18
- "scoring",
19
- "spec"
20
+ "markdown",
21
+ "structured-data",
22
+ "audit"
20
23
  ],
21
24
  "type": "module",
22
25
  "sideEffects": false,
23
26
  "main": "./dist/index.cjs",
24
27
  "module": "./dist/index.js",
25
28
  "types": "./dist/index.d.ts",
29
+ "typesVersions": {
30
+ "*": {
31
+ "probe": [
32
+ "./dist/probe/index.d.ts"
33
+ ],
34
+ "probe/local": [
35
+ "./dist/probe/local.d.ts"
36
+ ]
37
+ }
38
+ },
26
39
  "files": [
27
40
  "dist",
28
- "README.md"
41
+ "README.md",
42
+ "CHANGELOG.md"
29
43
  ],
30
44
  "exports": {
31
45
  ".": {
@@ -64,7 +78,7 @@
64
78
  "access": "public"
65
79
  },
66
80
  "engines": {
67
- "node": ">=20.11.0"
81
+ "node": ">=22"
68
82
  },
69
83
  "devDependencies": {
70
84
  "@types/node": "^22.9.0",