turva-llms-txt-validator 0.7.0 → 0.7.1

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.1 --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.1` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.7.1 --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))
@@ -1712,7 +1717,7 @@ export function validateLlmsTxt(f) {
1712
1717
  else {
1713
1718
  const relativeCount = named.filter((m) => !/^[a-z][a-z0-9+.-]*:/i.test(m.target)).length;
1714
1719
  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");
1720
+ 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
1721
  }
1717
1722
  // A list line that looks like a link entry but is not one (Tek-730) turns the links check to a warn.
1718
1723
  const lookalikes = unparsedLinkEntries(lines, fenced, new Set(proseLinks.map((m) => m.at)), codeSpanMask(linkText, linkBlocks), defAt, htmlLine);
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.1",
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",