turva-llms-txt-validator 0.4.3 → 0.5.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 +6 -6
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +125 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,9 +103,9 @@ In an error report the `target` is the address given on the command line. When i
|
|
|
103
103
|
| 3 | First non-empty line is a Markdown H1, written `# Title` or as one line of text underlined with `=` | Missing H1, a title indented as a code block, or an H1 with no text | none |
|
|
104
104
|
| 4 | Blockquote summary follows the title | none | Missing summary, a blockquote block in which no line has text after the `>`, or a blockquote after other text but before the first H2, named by its line |
|
|
105
105
|
| 5 | H2 sections group the content | none | No H2 sections, no section with a Markdown link list, a heading between the title and the first H2, or a second H1 |
|
|
106
|
-
| 6 | Markdown links have names and absolute HTTP or HTTPS targets | none | Missing links, empty names, relative targets or targets that do not parse as HTTP or HTTPS URLs |
|
|
106
|
+
| 6 | Markdown links have names and absolute HTTP or HTTPS targets | none | Missing links, empty names, relative targets or targets that do not parse as HTTP or HTTPS URLs, or a list line under an H2 of one of two kinds. The first kind looks like a link entry but is not a Markdown link, such as an unclosed destination in `- [Name](https://example.com/a.md: notes)`. The second kind opens with an en dash, an em dash or a bullet instead of a list marker, whether or not its link parses. The detail has one sentence per kind, each with its count and the first five line numbers |
|
|
107
107
|
| 7 | File is small enough to read cheaply | none | Over 50 KiB, which is 51,200 bytes, or truncated at the 256 KiB read limit |
|
|
108
|
-
| 8 | File contains no HTML markup | none | An opening tag with its closing `>`, a closing tag or an HTML comment is found
|
|
108
|
+
| 8 | File contains no HTML markup | none | An opening tag with its closing `>`, a closing tag or an HTML comment is found in the prose. Inline code spans, fenced code and backslash-escaped angle brackets such as `\<node-name\>` are not read, so `<endpoint-id>` in a code span does not warn. An attribute name is any run of characters other than white space, quotes, `<`, `>`, `/` and `=` that holds a Unicode letter, a Unicode digit or the character `_`, so `<div @click="x">` warns. Autolinks such as `<https://example.com>` and prose such as `a <b + c` are not tags. A tag still open at the end of the file, such as `<div class="x"`, has no closing `>` and does not warn |
|
|
109
109
|
|
|
110
110
|
Some failures stop the file checks early. For example, an HTML response is reported as a failed plain-text check rather than parsed as Markdown.
|
|
111
111
|
|
|
@@ -142,7 +142,7 @@ These checks are labelled **v2** in the output. They look for link relations in
|
|
|
142
142
|
| 9 | Home page points to its llms.txt | `rel="describedby"` has a non-empty target | `info` |
|
|
143
143
|
| 10 | Home page points to a Markdown version | `rel="alternate"` has media type `text/markdown` and a non-empty target | `info` |
|
|
144
144
|
|
|
145
|
-
The validator detects these declarations without fetching their targets. It reads the first 65,536 UTF-16 code units of the head after comments and the contents of script, style, title, noscript, noframes and template elements have been set aside. When a relation is missing from a longer head, the result says that only that part was read. A target is shown with its credentials and fragment removed and its query values masked.
|
|
145
|
+
The validator detects these declarations without fetching their targets. It reads the first 65,536 UTF-16 code units of the head after comments and the contents of script, style, title, noscript, noframes and template elements have been set aside. When a relation is missing from a longer head, the result says that only that part was read. The home page itself is read up to 256 KiB. When it was cut there and no relation is found in the part that was read, the info text says "in the first 256 KiB of the home page, the part that was read, or in the Link header". A target is shown with its credentials and fragment removed and its query values masked.
|
|
146
146
|
|
|
147
147
|
The validator does not follow the links inside `llms.txt`, crawl the site or test whether an AI agent can complete a task there.
|
|
148
148
|
|
|
@@ -187,7 +187,7 @@ Any CI runner with Node.js 22 or newer can run the same command. Omit `--strict`
|
|
|
187
187
|
The default validation requests two documents: `https://<host>/llms.txt` and `https://<host>/`. Redirects may add requests, but linked pages and discovery targets are never fetched. The validator stores no results.
|
|
188
188
|
|
|
189
189
|
- Timeout: eight seconds per document, shared across its redirect chain.
|
|
190
|
-
- Read limit: 256 KiB, which is 262,144 bytes, per response.
|
|
190
|
+
- Read limit: 256 KiB, which is 262,144 bytes, per response. A file cut there gets the size note "over 256 KiB, read truncated".
|
|
191
191
|
- Redirects: up to four hops, over HTTPS, to the same host or its `www`/apex equivalent. Off-site redirects, embedded credentials and unsupported ports are rejected. A redirect target is reported with its credentials and fragment removed and its query values masked, whether the redirect was followed or rejected.
|
|
192
192
|
- Host checks: IP literals, bracketed IPv6 addresses, localhost and the internal-use TLDs `localdomain`, `local`, `internal`, `home`, `lan`, `corp`, `test`, `invalid`, `arpa` and `onion` are rejected before a request is sent. An address that holds `@`, `?` or `#` is not repeated in the error message, because it can carry a user name, a password or a query value. One trailing dot on the host you give, as in `example.com.`, is removed first. Redirect targets are checked too.
|
|
193
193
|
|
|
@@ -212,10 +212,10 @@ The strict type check found two inputs that could leave `undefined` in a check's
|
|
|
212
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.
|
|
213
213
|
|
|
214
214
|
```sh
|
|
215
|
-
mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.
|
|
215
|
+
mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.5.1 --ignore-scripts && npm audit signatures
|
|
216
216
|
```
|
|
217
217
|
|
|
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.
|
|
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.5.1` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.5.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.
|
|
219
219
|
|
|
220
220
|
## Development
|
|
221
221
|
|
package/dist/src/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export type LinkRelations = {
|
|
|
16
16
|
describedby: string | null;
|
|
17
17
|
markdown: string | null;
|
|
18
18
|
headCut?: boolean;
|
|
19
|
+
readCut?: boolean;
|
|
19
20
|
};
|
|
20
21
|
export type FetchedLlmsTxt = {
|
|
21
22
|
redirect?: undefined;
|
|
@@ -53,7 +54,7 @@ export declare function enteredPath(raw: unknown): string;
|
|
|
53
54
|
export declare function isValidPublicHost(host: string | null | undefined): boolean;
|
|
54
55
|
export declare function fetchLlmsTxt(host: string, opts?: FetchOptions): Promise<FetchedLlmsTxt | FetchRedirect>;
|
|
55
56
|
export declare function validateLlmsTxt(f: LlmsTxtInput): LlmsCheck[];
|
|
56
|
-
export declare function findLinkRelations(html: string, linkHeader: string): LinkRelations;
|
|
57
|
+
export declare function findLinkRelations(html: string, linkHeader: string, readCut?: boolean): LinkRelations;
|
|
57
58
|
export declare function validateV2Discovery(found: LinkRelations | null, unreadReason?: string): LlmsCheck[];
|
|
58
59
|
export declare function summarizeChecks(checks: LlmsCheck[]): ChecksSummary;
|
|
59
60
|
export declare function validateHost(input: unknown, opts?: ValidateHostOptions): Promise<ValidationResult>;
|
package/dist/src/index.js
CHANGED
|
@@ -174,7 +174,7 @@ export function isValidPublicHost(host) {
|
|
|
174
174
|
}
|
|
175
175
|
// opts.path and opts.accept were added for the v2 discovery checks, which need the
|
|
176
176
|
// site's home page as well as its llms.txt. Nothing else moved: the redirect budget,
|
|
177
|
-
// the same-host rule, the credential and port rejections and the 256
|
|
177
|
+
// the same-host rule, the credential and port rejections and the 256 KiB cap are the
|
|
178
178
|
// guards this function was measured against.
|
|
179
179
|
export async function fetchLlmsTxt(host, opts = {}) {
|
|
180
180
|
const timeoutMs = opts.timeoutMs ?? 8000;
|
|
@@ -270,32 +270,37 @@ function isEscaped(s, i) {
|
|
|
270
270
|
}
|
|
271
271
|
// Inline code spans, marked per character across the whole document, so a link written inside
|
|
272
272
|
// backticks is read as the code it is (outside audit 2026-09-26, Tek-496), including when the
|
|
273
|
-
// span itself crosses a real line ending: a fenceless "`[a](b)\ncontinued`"
|
|
274
|
-
// only on its own line, so the second line escaped the mask and its bracket read as a
|
|
275
|
-
//
|
|
276
|
-
//
|
|
277
|
-
//
|
|
278
|
-
//
|
|
279
|
-
// backticks in two different list items used to enclose a real hyperlink between them).
|
|
280
|
-
//
|
|
281
|
-
//
|
|
282
|
-
//
|
|
283
|
-
//
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return true;
|
|
292
|
-
}
|
|
293
|
-
return false;
|
|
273
|
+
// span itself crosses a real line ending. V2 (Tek-526): a fenceless "`[a](b)\ncontinued`" was
|
|
274
|
+
// masked only on its own line, so the second line escaped the mask and its bracket read as a
|
|
275
|
+
// real link. A span opens with a run of backticks and closes with the next run of the same
|
|
276
|
+
// length anywhere in the text; a pair that crosses a block boundary, a blank line (blank or
|
|
277
|
+
// made only of spaces and tabs), a heading line or a new list item, is not a code span in
|
|
278
|
+
// CommonMark, so it is left unmasked and its backticks stay literal (VREG2, round 3 Tek-542:
|
|
279
|
+
// backticks in two different list items used to enclose a real hyperlink between them). Such a
|
|
280
|
+
// pair consumes neither run: its closer is still free to open a span of its own in its own
|
|
281
|
+
// block. Until 2026-11-04 the scan jumped past the closer, so a stray backtick moved the mask by
|
|
282
|
+
// one run, a link inside the next real span counted as a link and text after it could count as
|
|
283
|
+
// code (Tek-745). An escaped first backtick is literal and the rest of its run still opens, while
|
|
284
|
+
// a closing run is never escaped, because a backslash inside a code span is literal. Each run
|
|
285
|
+
// carries the number of boundary lines before it, read once per line, so comparing two runs
|
|
286
|
+
// costs nothing however far apart they sit. Runs are grouped by length and every group is read
|
|
287
|
+
// with one forward pointer, so the scan stays linear on a document of unmatched runs. Mirrored
|
|
288
|
+
// from the hosted validator at turva.dev in 0.5.1.
|
|
289
|
+
function endsInlineBlock(line) {
|
|
290
|
+
return /^[ \t]*$/.test(line) || /^ {0,3}(#{1,6}(?:[ \t]|$)|[-*+][ \t]|\d{1,9}[.)][ \t])/.test(line);
|
|
294
291
|
}
|
|
295
292
|
function codeSpanMask(text) {
|
|
296
293
|
const mask = new Uint8Array(text.length);
|
|
297
294
|
const runs = [];
|
|
295
|
+
let block = 0;
|
|
298
296
|
for (let i = 0; i < text.length;) {
|
|
297
|
+
if (text[i] === "\n") {
|
|
298
|
+
const next = text.indexOf("\n", i + 1);
|
|
299
|
+
if (endsInlineBlock(text.slice(i + 1, next < 0 ? text.length : next)))
|
|
300
|
+
block++;
|
|
301
|
+
i++;
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
299
304
|
if (text[i] !== "`") {
|
|
300
305
|
i++;
|
|
301
306
|
continue;
|
|
@@ -303,7 +308,7 @@ function codeSpanMask(text) {
|
|
|
303
308
|
let j = i;
|
|
304
309
|
while (j < text.length && text[j] === "`")
|
|
305
310
|
j++;
|
|
306
|
-
runs.push({ at: i, len: j - i, escaped: isEscaped(text, i) });
|
|
311
|
+
runs.push({ at: i, len: j - i, escaped: isEscaped(text, i), block });
|
|
307
312
|
i = j;
|
|
308
313
|
}
|
|
309
314
|
const byLen = new Map();
|
|
@@ -323,10 +328,9 @@ function codeSpanMask(text) {
|
|
|
323
328
|
if (p === list.length)
|
|
324
329
|
continue;
|
|
325
330
|
const close = runs[list[p]];
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
mask.fill(1, start, end);
|
|
331
|
+
if (close.block !== r.block)
|
|
332
|
+
continue;
|
|
333
|
+
mask.fill(1, r.escaped ? r.at + 1 : r.at, close.at + close.len);
|
|
330
334
|
k = list[p];
|
|
331
335
|
}
|
|
332
336
|
return mask;
|
|
@@ -787,6 +791,80 @@ function h2Lines(lines, fenced) {
|
|
|
787
791
|
}
|
|
788
792
|
return { h2, under };
|
|
789
793
|
}
|
|
794
|
+
// Code is not markup (Tek-730, 2026-10-31). Before the HTML check reads the file, every character
|
|
795
|
+
// of an inline code span and every backslash-escaped angle bracket is blanked, so
|
|
796
|
+
// `https://fal.ai/models/<endpoint-id>/llms.txt`, `submit_<form>_form` and an escaped
|
|
797
|
+
// \<node-name\> no longer read as tags. The text it receives is the prose the links check also
|
|
798
|
+
// reads, with fenced lines already blanked, so fenced code is not markup either. Line breaks stay,
|
|
799
|
+
// so a tag split over two lines keeps its shape. The span rule is codeSpanMask's, which is
|
|
800
|
+
// CommonMark's: an unclosed backtick run, or a pair that crosses a block boundary, is literal text.
|
|
801
|
+
// A real tag, a closing tag or a comment start in prose still warns, and an autolink is still not
|
|
802
|
+
// a tag. The package turva-llms-txt-validator mirrors this from 0.5.0.
|
|
803
|
+
function blankCodeForHtml(prose) {
|
|
804
|
+
const mask = codeSpanMask(prose);
|
|
805
|
+
const out = [];
|
|
806
|
+
for (let i = 0; i < prose.length; i++) {
|
|
807
|
+
const c = prose[i];
|
|
808
|
+
out.push(c !== "\n" && (mask[i] === 1 || ((c === "<" || c === ">") && isEscaped(prose, i))) ? " " : c);
|
|
809
|
+
}
|
|
810
|
+
return out.join("");
|
|
811
|
+
}
|
|
812
|
+
// List lines that look like a link entry and are not one (Tek-730, 2026-10-31). Two measured
|
|
813
|
+
// shapes: an entry whose destination is not closed, "- [Name](https://x.example/a.md: notes)",
|
|
814
|
+
// which holds a space and so is no CommonMark link, and an entry whose marker is an en dash, an
|
|
815
|
+
// em dash or a bullet, which is no Markdown list marker. Both read as links to a person and are
|
|
816
|
+
// invisible to the parser, so the links check counted the file as fine while an agent skipped the
|
|
817
|
+
// entry. Only lines outside fences and under an H2 are read. A line counts when it opens, after
|
|
818
|
+
// optional indentation, with a list marker (a hyphen, an asterisk, a plus or a number with a
|
|
819
|
+
// period or a parenthesis) or one of the three look-alike markers, then white space and "[", and
|
|
820
|
+
// no link that collectLinks found starts at that "[". A line with one of the three look-alike
|
|
821
|
+
// markers counts whether or not its link parses, because it is no list item either way. A task
|
|
822
|
+
// list box such as "- [x] done" is not an entry. Returns the one-based line numbers by kind,
|
|
823
|
+
// because the two kinds need different words: a look-alike marker with a link that parses is
|
|
824
|
+
// counted as a link and is still no list item (Tek-745).
|
|
825
|
+
function unparsedLinkEntries(lines, fenced, linkAt) {
|
|
826
|
+
const unparsed = [], marker = [];
|
|
827
|
+
const h2 = h2Lines(lines, fenced).h2;
|
|
828
|
+
let inH2 = false, offset = 0;
|
|
829
|
+
for (let i = 0; i < lines.length; i++) {
|
|
830
|
+
const l = lines[i];
|
|
831
|
+
const start = offset;
|
|
832
|
+
offset += (fenced[i] ? 0 : l.length) + 1;
|
|
833
|
+
if (fenced[i])
|
|
834
|
+
continue;
|
|
835
|
+
if (h2[i]) {
|
|
836
|
+
inH2 = true;
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
if (/^ {0,3}#(?:[ \t]|$)/.test(l)) {
|
|
840
|
+
inH2 = false;
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
if (!inH2)
|
|
844
|
+
continue;
|
|
845
|
+
const m = /^[ \t]*(?:[-*+]|\d{1,9}[.)]|[\u2013\u2014\u2022])[ \t]+\[/.exec(l);
|
|
846
|
+
if (!m)
|
|
847
|
+
continue;
|
|
848
|
+
const alt = /^[ \t]*[\u2013\u2014\u2022]/.test(l);
|
|
849
|
+
const bracketAt = m[0].length - 1;
|
|
850
|
+
if (/^\[[ xX]\](?:[ \t]|$)/.test(l.slice(bracketAt)))
|
|
851
|
+
continue;
|
|
852
|
+
if (alt)
|
|
853
|
+
marker.push(i + 1);
|
|
854
|
+
else if (!linkAt.has(start + bracketAt))
|
|
855
|
+
unparsed.push(i + 1);
|
|
856
|
+
}
|
|
857
|
+
return { unparsed, marker };
|
|
858
|
+
}
|
|
859
|
+
function entryLineList(hits) {
|
|
860
|
+
const n = hits.length;
|
|
861
|
+
return " (line" + (n === 1 ? "" : "s") + " " + hits.slice(0, 5).join(", ") + (n > 5 ? " and " + (n - 5) + " more" : "") + ")";
|
|
862
|
+
}
|
|
863
|
+
function unparsedEntriesNote(found) {
|
|
864
|
+
const u = found.unparsed.length, k = found.marker.length;
|
|
865
|
+
return (u > 0 ? "; " + (u === 1 ? "1 list line looks like a link entry but is not a Markdown link" : u + " list lines look like link entries but are not Markdown links") + entryLineList(found.unparsed) : "")
|
|
866
|
+
+ (k > 0 ? "; " + (k === 1 ? "1 list line opens with a dash or bullet that is not a Markdown list marker" : k + " list lines open with a dash or bullet that is not a Markdown list marker") + entryLineList(found.marker) : "");
|
|
867
|
+
}
|
|
790
868
|
// The text of an ATX H1, or null when the line is not one. One to three leading spaces, a
|
|
791
869
|
// single "#", then a space, a tab or the end of the line. A closing run of "#" preceded by a
|
|
792
870
|
// space or a tab is not part of the title, and the title is what remains once both ends are
|
|
@@ -1129,8 +1207,15 @@ export function validateLlmsTxt(f) {
|
|
|
1129
1207
|
const hostless = named.length - absolute - relativeCount;
|
|
1130
1208
|
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");
|
|
1131
1209
|
}
|
|
1210
|
+
// A list line that looks like a link entry but is not one (Tek-730) turns the links check to a warn.
|
|
1211
|
+
const lookalikes = unparsedLinkEntries(lines, fenced, new Set(proseLinks.map((m) => m.at)));
|
|
1212
|
+
if (lookalikes.unparsed.length + lookalikes.marker.length > 0) {
|
|
1213
|
+
const lk = checks[checks.length - 1];
|
|
1214
|
+
lk.status = "warn";
|
|
1215
|
+
lk.detail += unparsedEntriesNote(lookalikes);
|
|
1216
|
+
}
|
|
1132
1217
|
if (f.truncated) {
|
|
1133
|
-
add("size", "warn", "Small enough to be cheap to read", "over 256
|
|
1218
|
+
add("size", "warn", "Small enough to be cheap to read", "over 256 KiB, read truncated");
|
|
1134
1219
|
}
|
|
1135
1220
|
else if (f.bytes <= 51200) {
|
|
1136
1221
|
add("size", "pass", "Small enough to be cheap to read", f.bytes + " bytes");
|
|
@@ -1145,8 +1230,10 @@ export function validateLlmsTxt(f) {
|
|
|
1145
1230
|
// operator such as the "+" in "a <b + c > d" does not. The tag name itself is ASCII. An unquoted
|
|
1146
1231
|
// value may not start with a quote, which keeps the quoted and the unquoted form from matching
|
|
1147
1232
|
// the same text, so the scan stays linear. A tag still open at the end of the file, as in
|
|
1148
|
-
// '<div class="x"', has no closing ">" and does not warn.
|
|
1149
|
-
|
|
1233
|
+
// '<div class="x"', has no closing ">" and does not warn. Code is blanked first (Tek-730): a tag-like
|
|
1234
|
+
// string inside an inline code span, a fenced block or after a backslash is not markup.
|
|
1235
|
+
const htmlScan = blankCodeForHtml(proseText);
|
|
1236
|
+
if (/<[a-zA-Z][a-zA-Z0-9-]*(?:\s+[^\s"'<>\/=\p{L}\p{N}_]*[\p{L}\p{N}_][^\s"'<>\/=]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|(?!["'])[^\s<>]+))?)*\s*\/?>|<\/[a-zA-Z][a-zA-Z0-9-]*\s*>|<!--/u.test(htmlScan)) {
|
|
1150
1237
|
add("no-html", "warn", "No HTML markup in the file", "HTML tags found; llms.txt should be plain markdown");
|
|
1151
1238
|
}
|
|
1152
1239
|
else {
|
|
@@ -2139,7 +2226,7 @@ function nextLinkValue(s, from) {
|
|
|
2139
2226
|
// as a Link response header. That is a property of the site, not of the file, so these
|
|
2140
2227
|
// two carry their own status, "info". They are never a warn and never a fail, the
|
|
2141
2228
|
// summary line is unchanged, and --strict keeps exiting on warnings only.
|
|
2142
|
-
export function findLinkRelations(html, linkHeader) {
|
|
2229
|
+
export function findLinkRelations(html, linkHeader, readCut = false) {
|
|
2143
2230
|
const found = { describedby: null, markdown: null };
|
|
2144
2231
|
// Only the head, and only what a parser would put there: a commented-out link element,
|
|
2145
2232
|
// one inside a script or a template, and one the parser moves into the body are all not
|
|
@@ -2189,6 +2276,11 @@ export function findLinkRelations(html, linkHeader) {
|
|
|
2189
2276
|
// reported as missing from the part read, not from the page (Tek-496).
|
|
2190
2277
|
if (whole.length > 65536)
|
|
2191
2278
|
found.headCut = true;
|
|
2279
|
+
// The home page itself is read up to the 256 KiB limit, and headOfDocument drops comments and
|
|
2280
|
+
// scripts before the head is measured, so a page cut inside one of those reaches this point with
|
|
2281
|
+
// a short head. Such a result reports what was read as well (Tek-745).
|
|
2282
|
+
if (readCut)
|
|
2283
|
+
found.readCut = true;
|
|
2192
2284
|
return found;
|
|
2193
2285
|
}
|
|
2194
2286
|
// A caller that passes null without a reason gets a neutral one instead of an undefined detail (Tek-668,
|
|
@@ -2204,7 +2296,7 @@ export function validateV2Discovery(found, unreadReason = "the home page was not
|
|
|
2204
2296
|
// A target is shown through maskLocation, as a redirect target is, so a user name, a password,
|
|
2205
2297
|
// a query value or a fragment in a published link stays out of the report; until 2026-09-27 it
|
|
2206
2298
|
// was only cut (Tek-496). A relative target stays relative.
|
|
2207
|
-
const where = found.headCut ? "in the first 65,536 characters of the head, the part that was read, or in the Link header" : "in the head or the Link header";
|
|
2299
|
+
const where = found.headCut ? "in the first 65,536 characters of the head, the part that was read, or in the Link header" : found.readCut ? "in the first 256 KiB of the home page, the part that was read, or in the Link header" : "in the head or the Link header";
|
|
2208
2300
|
add("v2-describedby", found.describedby ? "pass" : "info", "Home page points to its llms.txt (v2)", found.describedby ? 'rel="describedby" to ' + cut(maskLocation(found.describedby), 120) : 'no rel="describedby" ' + where + '; v2 recommends it so an agent finds the file without guessing');
|
|
2209
2301
|
add("v2-markdown-alternate", found.markdown ? "pass" : "info", "Home page points to a markdown version (v2)", found.markdown ? 'rel="alternate" type="text/markdown" to ' + cut(maskLocation(found.markdown), 120) : 'no rel="alternate" type="text/markdown" ' + where + '; v2 recommends it so an agent finds the markdown form without guessing');
|
|
2210
2302
|
return checks;
|
|
@@ -2238,7 +2330,7 @@ export async function validateHost(input, opts = {}) {
|
|
|
2238
2330
|
? validateV2Discovery(null, "the home page redirects away from this host, so this was not measured")
|
|
2239
2331
|
: home.status !== 200
|
|
2240
2332
|
? validateV2Discovery(null, "the home page returned HTTP " + home.status + ", so this was not measured")
|
|
2241
|
-
: validateV2Discovery(findLinkRelations(home.text, home.linkHeader));
|
|
2333
|
+
: validateV2Discovery(findLinkRelations(home.text, home.linkHeader, home.truncated));
|
|
2242
2334
|
}
|
|
2243
2335
|
catch {
|
|
2244
2336
|
discovery = validateV2Discovery(null, "the home page could not be read, so this was not measured");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turva-llms-txt-validator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|