turva-llms-txt-validator 0.8.6 → 0.9.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.
- package/README.md +6 -4
- package/dist/src/index.js +38 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,11 +107,13 @@ In an error report the `target` is the address given on the command line. When i
|
|
|
107
107
|
| 2 | Response is plain text | Body looks like an HTML page | The media type, read without its parameters, with only spaces, tabs and line breaks removed from its ends and only ASCII letters lowercased, is neither `text/plain` nor `text/markdown` |
|
|
108
108
|
| 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, whether written with `#` or underlined with `=` | none |
|
|
109
109
|
| 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 |
|
|
110
|
-
| 5 | H2 sections group the content | none | No H2 sections, no section with a Markdown link list, a heading
|
|
111
|
-
| 6 | Markdown links have names and
|
|
110
|
+
| 5 | H2 sections group the content | none | No H2 sections, no section with a Markdown link list, or a second H1. An H3 or deeper heading in the top section, before the first H2, is allowed |
|
|
111
|
+
| 6 | Markdown links have names and HTTP or HTTPS targets, absolute or relative | none | Missing links, empty names, a `Base URL:` line in the top section whose value is not an absolute HTTP or HTTPS URL, targets with a scheme 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, followed by a space or a tab and an opening bracket, whether or not its link parses. A line with such a character and no opening bracket is not counted, and a no-break space does not count as the space. When the read was truncated, the last line read is not counted, because the read limit may have cut it. The detail has one sentence per kind, each with its count and the first five line numbers |
|
|
112
112
|
| 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 |
|
|
113
113
|
| 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 |
|
|
114
114
|
|
|
115
|
+
Since 0.9.0 the checks follow llms.txt v2.1. A relative link in a file list passes. An optional standalone `Base URL: https://example.com/` line in the top section, before the first H2, names the address that relative links resolve against. Without that line they resolve against the address the file was fetched from, so the links check passes and its detail says that they break when the file is read from disk or a mirror. A `Base URL:` line whose value is not an absolute HTTP or HTTPS URL is a warning that names its line. A section may open with a summary paragraph before its file list, and a section named `Optional` is read like any other.
|
|
116
|
+
|
|
115
117
|
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. The response bytes are always decoded as UTF-8, and the `charset` parameter of the media type is not used.
|
|
116
118
|
|
|
117
119
|
### How links, headings and list items are read
|
|
@@ -253,12 +255,12 @@ The strict type check found two inputs that could leave `undefined` in a check's
|
|
|
253
255
|
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.
|
|
254
256
|
|
|
255
257
|
```sh
|
|
256
|
-
mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.
|
|
258
|
+
mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.9.0 --ignore-scripts && npm audit signatures
|
|
257
259
|
```
|
|
258
260
|
|
|
259
261
|
`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, the workflow file `.github/workflows/publish.yml` and the commit that produced the tarball. Versions up to and including 0.8.4 were built in `github.com/erekola/llms-txt-validator`, before the repository moved to the turva-dev organization on 2026-11-25. Every later release is built in `github.com/turva-dev/llms-txt-validator`. The npm version page shows them under Provenance.
|
|
260
262
|
|
|
261
|
-
Tag `v0.
|
|
263
|
+
Tag `v0.9.0` must point at that same commit, and `gh api repos/turva-dev/llms-txt-validator/commits/v0.9.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.
|
|
262
264
|
|
|
263
265
|
## Development
|
|
264
266
|
|
package/dist/src/index.js
CHANGED
|
@@ -2019,9 +2019,9 @@ export function validateLlmsTxt(f) {
|
|
|
2019
2019
|
const h2Count = hm.h2.filter(Boolean).length;
|
|
2020
2020
|
// A section counts when it carries a file list. An H2 followed by a paragraph satisfied
|
|
2021
2021
|
// this check until 2026-08-29, and the format puts each section's links in a list.
|
|
2022
|
-
// A
|
|
2023
|
-
//
|
|
2024
|
-
//
|
|
2022
|
+
// A second H1 anywhere is out of place, because the format has one H1. Since llms.txt v2.1
|
|
2023
|
+
// (decision P1, 2026-11-30) an H3 or deeper heading in the top section, before the first H2, is allowed,
|
|
2024
|
+
// so only an H1 is named. A second H1 passed until 2026-09-27 (Tek-496).
|
|
2025
2025
|
let sectionsWithList = 0, misplaced = -1;
|
|
2026
2026
|
{
|
|
2027
2027
|
let inSection = false, counted = false, seenH2 = false, itemOpen = false, itemGap = false, itemEmpty = false, emptyOuter = false, afterFence = false;
|
|
@@ -2065,7 +2065,7 @@ export function validateLlmsTxt(f) {
|
|
|
2065
2065
|
// A line inside a raw HTML block is no heading for these checks either (h2Mask also holds the fenced lines,
|
|
2066
2066
|
// which were skipped above, so here it only adds the HTML block lines).
|
|
2067
2067
|
const h1 = !h2Mask[i] && (/^ {0,3}#(?:[ \t]|$)/.test(l) || sx.text[i]);
|
|
2068
|
-
if (misplaced === -1 && i > firstIdx &&
|
|
2068
|
+
if (misplaced === -1 && i > firstIdx && h1)
|
|
2069
2069
|
misplaced = i;
|
|
2070
2070
|
if (h1) {
|
|
2071
2071
|
inSection = false;
|
|
@@ -2146,7 +2146,7 @@ export function validateLlmsTxt(f) {
|
|
|
2146
2146
|
if (misplaced !== -1) {
|
|
2147
2147
|
const s = checks[checks.length - 1];
|
|
2148
2148
|
s.status = "warn";
|
|
2149
|
-
s.detail += ". The heading at line " + (misplaced + 1) + " is out of place, because the format has one H1
|
|
2149
|
+
s.detail += ". The heading at line " + (misplaced + 1) + " is out of place, because the format has one H1";
|
|
2150
2150
|
}
|
|
2151
2151
|
// Links are collected from the prose only, for the same reason the headings are: a link
|
|
2152
2152
|
// shown inside a code fence is an example of a link, not one an agent can follow. Computed
|
|
@@ -2167,6 +2167,25 @@ export function validateLlmsTxt(f) {
|
|
|
2167
2167
|
return r;
|
|
2168
2168
|
};
|
|
2169
2169
|
const absolute = named.filter((m) => isAbs(m.target)).length;
|
|
2170
|
+
// llms.txt v2.1 (decision P1, 2026-11-30): file lists may hold relative links next to an optional standalone
|
|
2171
|
+
// "Base URL:" line in the top section, before the first H2. The first such line outside fences and raw HTML
|
|
2172
|
+
// blocks counts. A value that is not an absolute http or https URL is a warn; relative links are no longer one.
|
|
2173
|
+
let baseValue = null, baseLine = -1;
|
|
2174
|
+
{
|
|
2175
|
+
const firstH2 = hm.h2.findIndex(Boolean);
|
|
2176
|
+
const stop = firstH2 === -1 ? lines.length : firstH2;
|
|
2177
|
+
for (let i = 0; i < stop; i++) {
|
|
2178
|
+
if (h2Mask[i])
|
|
2179
|
+
continue;
|
|
2180
|
+
const bm = /^ {0,3}Base URL:[ \t]*(.*?)[ \t]*$/.exec(lines[i]);
|
|
2181
|
+
if (bm) {
|
|
2182
|
+
baseValue = bm[1];
|
|
2183
|
+
baseLine = i + 1;
|
|
2184
|
+
break;
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
const baseValid = baseValue !== null && isAbs(baseValue);
|
|
2170
2189
|
if (links.length === 0) {
|
|
2171
2190
|
add("links", "warn", "Markdown links an agent can follow", "no markdown links found");
|
|
2172
2191
|
}
|
|
@@ -2190,7 +2209,20 @@ export function validateLlmsTxt(f) {
|
|
|
2190
2209
|
};
|
|
2191
2210
|
const relativeCount = named.filter((m) => !hasScheme(m.target)).length;
|
|
2192
2211
|
const hostless = named.length - absolute - relativeCount;
|
|
2193
|
-
|
|
2212
|
+
if (hostless > 0) {
|
|
2213
|
+
add("links", "warn", "Markdown links an agent can follow", named.length + " link" + (named.length === 1 ? "" : "s") + ", " + relativeCount + " relative and " + hostless + " that are not valid http or https URLs. Absolute URLs travel better when the file is read out of context");
|
|
2214
|
+
}
|
|
2215
|
+
else if (baseValid) {
|
|
2216
|
+
add("links", "pass", "Markdown links an agent can follow", named.length + " link" + (named.length === 1 ? "" : "s") + ", " + relativeCount + " relative and " + absolute + " absolute. The relative links resolve against the Base URL line");
|
|
2217
|
+
}
|
|
2218
|
+
else {
|
|
2219
|
+
add("links", "pass", "Markdown links an agent can follow", named.length + " link" + (named.length === 1 ? "" : "s") + ", " + relativeCount + " relative and " + absolute + " absolute. The relative links resolve against the address the file was fetched from and break when the file is read from disk or a mirror. A Base URL line keeps them working");
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
if (baseValue !== null && !baseValid) {
|
|
2223
|
+
const bl = checks[checks.length - 1];
|
|
2224
|
+
bl.status = "warn";
|
|
2225
|
+
bl.detail += ". The Base URL line at line " + baseLine + " is not an absolute http or https URL";
|
|
2194
2226
|
}
|
|
2195
2227
|
// A list line that looks like a link entry but is not one (Tek-730) turns the links check to a warn.
|
|
2196
2228
|
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.
|
|
3
|
+
"version": "0.9.0",
|
|
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",
|