turva-llms-txt-validator 0.7.0 → 0.7.2

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/README.md CHANGED
@@ -43,7 +43,7 @@ A domain, an HTTP URL or an HTTPS URL is accepted. Validation always uses the ho
43
43
  | --- | --- |
44
44
  | `--json` | Print the result as JSON instead of text. |
45
45
  | `--strict` | Exit with code `1` when the summary is `valid with warnings`. |
46
- | `--help` | Print usage and exit with code `0`. |
46
+ | `--help`, `-h` | Print usage and exit with code `0`. |
47
47
  | `--version`, `-V` | Print the installed version and exit with code `0`. |
48
48
 
49
49
  ### Read the result
@@ -222,10 +222,10 @@ The strict type check found two inputs that could leave `undefined` in a check's
222
222
  GitHub Actions publishes every version from 0.1.3 on with npm trusted publishing, and each one carries a provenance attestation. To check one, install it in an empty directory and ask npm to verify the signatures. Replace the version with the one you want to check.
223
223
 
224
224
  ```sh
225
- mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.7.0 --ignore-scripts && npm audit signatures
225
+ mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.7.2 --ignore-scripts && npm audit signatures
226
226
  ```
227
227
 
228
- `npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository `github.com/erekola/llms-txt-validator`, the workflow file `.github/workflows/publish.yml` and the commit that produced the tarball. The npm version page shows them under Provenance. Tag `v0.7.0` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.7.0 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
228
+ `npm audit signatures` checks the registry signature and the provenance attestation of each installed package that has one. The attestation of this package names three things to compare with what you expect: the repository `github.com/erekola/llms-txt-validator`, the workflow file `.github/workflows/publish.yml` and the commit that produced the tarball. The npm version page shows them under Provenance. Tag `v0.7.2` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.7.2 --jq .sha` prints it. A mismatch is a reason not to use that version. Provenance proves which workflow built a release and from which commit. It does not prove that the code is safe, so reading the source and the dependencies stays your job.
229
229
 
230
230
  ## Development
231
231
 
package/dist/bin/cli.js CHANGED
@@ -10,10 +10,10 @@ import { fileURLToPath } from "node:url";
10
10
  import { validateHost, stripControls, maskLocation } from "../src/index.js";
11
11
  const USAGE = [
12
12
  "usage: llms-txt-validate <domain-or-url> [--json] [--strict]",
13
- " --json print the result as JSON (same shape as the hosted validator for a completed validation)",
14
- " --strict exit 1 on warnings too, for CI gates",
15
- " --help print this help",
16
- " --version print the installed version and exit"
13
+ " --json print the result as JSON (same shape as the hosted validator for a completed validation)",
14
+ " --strict exit 1 on warnings too, for CI gates",
15
+ " --help, -h print this help",
16
+ " --version, -V print the installed version and exit"
17
17
  ];
18
18
  const KNOWN = new Set(["--json", "--strict", "--help", "-h", "--version", "-V"]);
19
19
  // The arguments are read strictly since 0.3.8 (Tek-496). An unknown flag such as a misspelled
package/dist/src/index.js CHANGED
@@ -3,7 +3,8 @@
3
3
  // which runs this same logic inside the turva.dev Cloudflare Worker
4
4
  // (https://github.com/erekola/turva-worker). The hosted validator stays
5
5
  // canonical: if the two ever disagree, the hosted one wins and this package
6
- // gets the fix.
6
+ // gets the fix. No tool compares the two sources: the mirror is kept by hand, and the
7
+ // test files of the two repos carry the same inputs and expectations by hand too.
7
8
  import { readFileSync } from "node:fs";
8
9
  // Version comes from package.json so the two can never drift again
9
10
  // (0.1.1 and 0.1.3 both shipped with a stale hardcoded VERSION).
@@ -113,7 +114,11 @@ export function stripControls(s) {
113
114
  return String(s).replace(/[\u0000-\u001F\u007F-\u009F]/g, "");
114
115
  }
115
116
  export function normalizeHostInput(raw) {
116
- let s = String(raw || "").trim().toLowerCase();
117
+ // The hosted validator removes tab, CR and LF from the typed address before it reads it, then trims
118
+ // (worker.ts, the /llms-txt-validator route). The URL parser would remove the same three characters
119
+ // from anywhere in the string, but the scheme test below runs first, so "ht<TAB>tps://example.com"
120
+ // was read as a host name here and as example.com there. Same order here: strip, trim, lower-case.
121
+ let s = String(raw || "").replace(/[\t\r\n]/g, "").trim().toLowerCase();
117
122
  if (!s)
118
123
  return null;
119
124
  if (!/^[a-z][a-z0-9+.-]*:\/\//.test(s))
@@ -141,9 +146,12 @@ export function normalizeHostInput(raw) {
141
146
  // as a fetch proxy, so a typed /docs/llms.txt used to be dropped without a word while the result
142
147
  // described the root file (outside retest 2026-09-26). The result now names the unused path in an
143
148
  // info check. The case of the path is kept, and the query and fragment are never returned.
144
- // Mirrors worker.ts enteredPath() (v3.176.0).
149
+ // Mirrors worker.ts enteredPath() (v3.176.0). The hosted route removes tab, CR and LF from the typed
150
+ // address before it calls enteredPath, as normalizeHostInput does, so this function removes them
151
+ // itself: "ht<TAB>tps://example.com" validates example.com and names no path. Without it the scheme
152
+ // test below did not match and the URL parser read the text as a path (audit round 25, R5-1).
145
153
  export function enteredPath(raw) {
146
- let s = String(raw || "").trim();
154
+ let s = String(raw || "").replace(/[\t\r\n]/g, "").trim();
147
155
  if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(s))
148
156
  s = "https://" + s;
149
157
  let u;
@@ -1712,7 +1720,7 @@ export function validateLlmsTxt(f) {
1712
1720
  else {
1713
1721
  const relativeCount = named.filter((m) => !/^[a-z][a-z0-9+.-]*:/i.test(m.target)).length;
1714
1722
  const hostless = named.length - absolute - relativeCount;
1715
- add("links", "warn", "Markdown links an agent can follow", named.length + " links, " + relativeCount + " relative" + (hostless > 0 ? " and " + hostless + " that are not valid http or https URLs" : "") + ". Absolute URLs travel better when the file is read out of context");
1723
+ add("links", "warn", "Markdown links an agent can follow", named.length + " link" + (named.length === 1 ? "" : "s") + ", " + relativeCount + " relative" + (hostless > 0 ? " and " + hostless + " that are not valid http or https URLs" : "") + ". Absolute URLs travel better when the file is read out of context");
1716
1724
  }
1717
1725
  // A list line that looks like a link entry but is not one (Tek-730) turns the links check to a warn.
1718
1726
  const lookalikes = unparsedLinkEntries(lines, fenced, new Set(proseLinks.map((m) => m.at)), codeSpanMask(linkText, linkBlocks), defAt, htmlLine);
@@ -2345,15 +2353,6 @@ var AFTER_HEAD_ELEMENTS = ["base", "basefont", "bgsound", "link", "meta", "nofra
2345
2353
  // Their content is not markup: script, style, title, noscript (a parser with scripting on
2346
2354
  // reads it as raw text) and noframes are raw text or RCDATA, and template content is inert.
2347
2355
  var HEAD_SKIPPED_CONTENT = ["script", "style", "title", "noscript", "noframes", "template"];
2348
- // The end of a raw text or RCDATA element: the first </name that is followed by optional
2349
- // whitespace, an optional "/" (a parser closes on </script/> too) and a ">". Returns the
2350
- // index after it, or -1 when the element never closes, which means the rest of the
2351
- // document is inside it.
2352
- function skipSpace(lower, j) {
2353
- while (j < lower.length && (lower[j] === " " || lower[j] === "\t" || lower[j] === "\n" || lower[j] === "\r" || lower[j] === "\f"))
2354
- j++;
2355
- return j;
2356
- }
2357
2356
  // True when the character ends a tag name: whitespace, "/", ">" or the end of the input.
2358
2357
  function isTagBoundary(c) {
2359
2358
  return c === undefined || c === ">" || c === "/" || c === " " || c === "\t" || c === "\n" || c === "\r" || c === "\f";
@@ -2368,6 +2367,10 @@ function endTagAt(lower, name, at) {
2368
2367
  const gt = tagEnd(lower, at);
2369
2368
  return gt === -1 ? -2 : gt + 1;
2370
2369
  }
2370
+ // The end of a raw text or RCDATA element: the first </name that is followed by optional
2371
+ // whitespace, an optional "/" (a parser closes on </script/> too) and a ">". Returns the
2372
+ // index after it, or -1 when the element never closes, which means the rest of the
2373
+ // document is inside it.
2371
2374
  function rawTextEnd(lower, name, from) {
2372
2375
  for (let at = lower.indexOf("</" + name, from); at !== -1; at = lower.indexOf("</" + name, at + name.length + 2)) {
2373
2376
  const end = endTagAt(lower, name, at);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turva-llms-txt-validator",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "Validate a site's llms.txt structure: eight checks as pass/warn/fail plus two llms.txt v2 discovery checks that read pass or info and never move the summary, JSON output. Same checks as the hosted validator at turva.dev/llms-txt-validator.",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",