turva-llms-txt-validator 0.4.2 → 0.4.3
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 +7 -3
- package/dist/bin/cli.js +1 -1
- package/dist/src/index.js +12 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -201,17 +201,21 @@ The source is TypeScript under `src/` and `bin/`, compiled with `tsc` to `dist/`
|
|
|
201
201
|
|
|
202
202
|
GitHub Actions tests Node.js 22 and 24 on Ubuntu and Node.js 22 on Windows. A version tag starts the release workflow, `.github/workflows/publish.yml`. It runs the type check and the tests, fails when the tag and `package.json` name different versions, publishes with npm trusted publishing over OIDC and creates the GitHub release from the CHANGELOG section. npm writes a provenance attestation. No npm token is stored in the repository or in the workflow.
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
## From JavaScript to TypeScript
|
|
205
|
+
|
|
206
|
+
Up to 0.3.21 the package was plain JavaScript modules, starting with `src/index.mjs`. Version 0.4.0, released on 21 October 2026, ports it to TypeScript compiled to `dist/`, and the entry point moved to `dist/src/index.js` behind the same `exports` name. The compiled library has the same 12 493 JavaScript tokens as 0.3.21, apart from the relative path to `package.json`. A differential run fed both versions 4 160 000 generated `llms.txt` inputs and 832 000 HTML heads and found no difference. The CLI kept its flags, its output and its exit codes.
|
|
207
|
+
|
|
208
|
+
The strict type check found two inputs that could leave `undefined` in a check's detail. Neither `fetchLlmsTxt` nor `validateHost` produces them, and 0.4.1 fixed both. Each release is described in [CHANGELOG.md](https://github.com/erekola/llms-txt-validator/blob/main/CHANGELOG.md).
|
|
205
209
|
|
|
206
210
|
## Verify a release
|
|
207
211
|
|
|
208
212
|
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.
|
|
209
213
|
|
|
210
214
|
```sh
|
|
211
|
-
mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.4.
|
|
215
|
+
mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.4.3 --ignore-scripts && npm audit signatures
|
|
212
216
|
```
|
|
213
217
|
|
|
214
|
-
`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.4.
|
|
218
|
+
`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.4.3` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.4.3 --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.
|
|
215
219
|
|
|
216
220
|
## Development
|
|
217
221
|
|
package/dist/bin/cli.js
CHANGED
|
@@ -65,7 +65,7 @@ try {
|
|
|
65
65
|
// published link cannot write an escape sequence to the terminal. A check's reflected
|
|
66
66
|
// value, when it has one, is printed ahead of the sentence, the same position the old
|
|
67
67
|
// concatenated string put it in, so text output reads the same while the JSON field stays
|
|
68
|
-
// separate (round 3 Tek-542, mirrored from worker.
|
|
68
|
+
// separate (round 3 Tek-542, mirrored from worker.ts decision 19, Tek-526).
|
|
69
69
|
console.log(result.target);
|
|
70
70
|
for (const c of result.checks)
|
|
71
71
|
console.log(" " + mark[c.status] + " " + c.label + " (" + (c.value !== undefined ? c.value + " " : "") + c.detail + ")");
|
package/dist/src/index.js
CHANGED
|
@@ -17,7 +17,7 @@ const UA = "turva-llms-txt-validator/" + VERSION + " (+https://turva.dev/llms-tx
|
|
|
17
17
|
// pair leaves half of it, and the character is lost. How the half is written depends on
|
|
18
18
|
// the runtime: Node's UTF-8 encoder replaces it with U+FFFD, and the hosted validator in
|
|
19
19
|
// workerd wrote three bytes that were not valid UTF-8 (round 16 S3-1 and S3-2, measured
|
|
20
|
-
// there 2026-09-03). Mirrors worker.
|
|
20
|
+
// there 2026-09-03). Mirrors worker.ts cut().
|
|
21
21
|
export function cut(s, n) {
|
|
22
22
|
s = String(s).slice(0, n);
|
|
23
23
|
return /[\uD800-\uDBFF]$/.test(s) ? s.slice(0, -1) : s;
|
|
@@ -29,7 +29,7 @@ export function cut(s, n) {
|
|
|
29
29
|
// https://user:password@host/ kept both in the check's detail and in the returned location (outside
|
|
30
30
|
// review, 2026-09-22). A target the URL parser refuses is masked by hand: nothing after the first ?
|
|
31
31
|
// or # survives, and when the target has a scheme or starts with two slashes, everything up to the
|
|
32
|
-
// last @ before them is shown as ***. Mirrors worker.
|
|
32
|
+
// last @ before them is shown as ***. Mirrors worker.ts maskLocation().
|
|
33
33
|
export function maskLocation(href, base) {
|
|
34
34
|
let u = null;
|
|
35
35
|
try {
|
|
@@ -101,14 +101,14 @@ export function maskLocation(href, base) {
|
|
|
101
101
|
// Unicode bidi controls (U+202A to U+202E, U+2066 to U+2069) have no place in a check's
|
|
102
102
|
// detail: text quoted from the fetched file could otherwise read in a different order here
|
|
103
103
|
// than in the file itself, and the right-to-left override is the classic way to do that
|
|
104
|
-
// (round 19, V6-U1). Mirrors worker.
|
|
104
|
+
// (round 19, V6-U1). Mirrors worker.ts stripBidi().
|
|
105
105
|
export function stripBidi(s) {
|
|
106
106
|
return String(s).replace(/[\u202A-\u202E\u2066-\u2069]/g, "");
|
|
107
107
|
}
|
|
108
108
|
// C0 and C1 control characters leave a check's detail as well. JSON escapes them, but a program
|
|
109
109
|
// that prints a detail to a terminal passes ESC through, so a published link could carry a
|
|
110
110
|
// sequence that clears the screen (Tek-496).
|
|
111
|
-
// Mirrors worker.
|
|
111
|
+
// Mirrors worker.ts stripControls().
|
|
112
112
|
export function stripControls(s) {
|
|
113
113
|
return String(s).replace(/[\u0000-\u001F\u007F-\u009F]/g, "");
|
|
114
114
|
}
|
|
@@ -132,7 +132,7 @@ export function normalizeHostInput(raw) {
|
|
|
132
132
|
if (u.username || u.password)
|
|
133
133
|
return null;
|
|
134
134
|
// One trailing dot names the same host in absolute form, so "example.com." is read as
|
|
135
|
-
// example.com instead of refused (round 19, K7-P5). Mirrors worker.
|
|
135
|
+
// example.com instead of refused (round 19, K7-P5). Mirrors worker.ts normalizeHostInput().
|
|
136
136
|
const typedHost = u.hostname;
|
|
137
137
|
return typedHost.length > 1 && typedHost.endsWith(".") ? typedHost.slice(0, -1) : typedHost;
|
|
138
138
|
}
|
|
@@ -141,7 +141,7 @@ export function normalizeHostInput(raw) {
|
|
|
141
141
|
// as a fetch proxy, so a typed /docs/llms.txt used to be dropped without a word while the result
|
|
142
142
|
// described the root file (outside retest 2026-09-26). The result now names the unused path in an
|
|
143
143
|
// info check. The case of the path is kept, and the query and fragment are never returned.
|
|
144
|
-
// Mirrors worker.
|
|
144
|
+
// Mirrors worker.ts enteredPath() (v3.176.0).
|
|
145
145
|
export function enteredPath(raw) {
|
|
146
146
|
let s = String(raw || "").trim();
|
|
147
147
|
if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(s))
|
|
@@ -850,7 +850,7 @@ export function validateLlmsTxt(f) {
|
|
|
850
850
|
add("http-status", "fail", "File exists at /llms.txt", "expected HTTP 200, got " + f.status);
|
|
851
851
|
return checks;
|
|
852
852
|
}
|
|
853
|
-
// An accepted redirect is shown masked as well (round 19, K7-2, mirrored from worker.
|
|
853
|
+
// An accepted redirect is shown masked as well (round 19, K7-2, mirrored from worker.ts
|
|
854
854
|
// v3.164.0): a query value or a fragment in a same-host Location used to reach this
|
|
855
855
|
// detail as sent. An input with redirectedFrom and no finalUrl, which fetchLlmsTxt never returns but a
|
|
856
856
|
// caller of this function can pass, names the address it was redirected from alone instead of ending
|
|
@@ -906,7 +906,7 @@ export function validateLlmsTxt(f) {
|
|
|
906
906
|
// Read the same way as the H1 check and the "late" blockquote search below: at most three
|
|
907
907
|
// leading spaces, per CommonMark. A trim-first prefix test used to erase the difference, so
|
|
908
908
|
// a four-space or tab-indented code block right after the title passed as the summary until
|
|
909
|
-
// 2026-09-27 (Tek-496, mirrored from worker.
|
|
909
|
+
// 2026-09-27 (Tek-496, mirrored from worker.ts).
|
|
910
910
|
// A blockquote marker is 0-3 leading spaces plus ">", optionally followed by one space that
|
|
911
911
|
// is then part of the marker and not the content; CommonMark reads ">Summary" and a tab the
|
|
912
912
|
// same way, and four or more leading spaces stay indented code, not a blockquote (outside
|
|
@@ -930,7 +930,7 @@ export function validateLlmsTxt(f) {
|
|
|
930
930
|
}
|
|
931
931
|
else {
|
|
932
932
|
// A blockquote further down, before the first H2, is a summary in the wrong place and not a
|
|
933
|
-
// missing one, and the detail says which (outside retest 2026-09-26, mirrored from worker.
|
|
933
|
+
// missing one, and the detail says which (outside retest 2026-09-26, mirrored from worker.ts
|
|
934
934
|
// v3.176.0). The status is warn either way, because the format places the summary directly
|
|
935
935
|
// after the title.
|
|
936
936
|
const fence = fenceMask(lines);
|
|
@@ -2244,17 +2244,17 @@ export async function validateHost(input, opts = {}) {
|
|
|
2244
2244
|
discovery = validateV2Discovery(null, "the home page could not be read, so this was not measured");
|
|
2245
2245
|
}
|
|
2246
2246
|
const checks = validateLlmsTxt(fetched).concat(discovery);
|
|
2247
|
-
// A path in the typed address is not used, and the result says so first (mirrored from worker.
|
|
2247
|
+
// A path in the typed address is not used, and the result says so first (mirrored from worker.ts
|
|
2248
2248
|
// v3.176.0). Information moves no summary and no exit code.
|
|
2249
2249
|
const unusedPath = enteredPath(input);
|
|
2250
2250
|
// The typed path goes on its own field with the same 120 character cut it always had (VREG,
|
|
2251
|
-
// round 3 Tek-542, mirrored from worker.
|
|
2251
|
+
// round 3 Tek-542, mirrored from worker.ts decision 19, Tek-526), instead of being built into
|
|
2252
2252
|
// the sentence, so a JSON caller reads the raw value from one field instead of parsing it
|
|
2253
2253
|
// back out of a message meant for people.
|
|
2254
2254
|
if (unusedPath)
|
|
2255
2255
|
checks.unshift({ id: "input-path", status: "info", label: "Path in the address you entered", value: cut(unusedPath, 120), detail: "This path is not used, because the validator always reads /llms.txt at the root of the host." });
|
|
2256
2256
|
// Text quoted from the fetched file leaves without bidirectional controls (round 19,
|
|
2257
|
-
// V6-U1, mirrored from worker.
|
|
2257
|
+
// V6-U1, mirrored from worker.ts v3.164.0): a site's own H1 or summary could otherwise
|
|
2258
2258
|
// read in another order here than in the file itself.
|
|
2259
2259
|
const stripped = checks.map((c) => (typeof c.detail === "string" ? { ...c, detail: stripControls(stripBidi(c.detail)) } : c));
|
|
2260
2260
|
return { target: "https://" + host + "/llms.txt", summary: summarizeChecks(stripped), checks: stripped };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turva-llms-txt-validator",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
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",
|