turva-llms-txt-validator 0.8.5 → 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 +7 -5
- package/dist/src/index.js +41 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ Completed validation returns `{ target, summary, checks }`, where `target` is `h
|
|
|
86
86
|
|
|
87
87
|
The validator removes C0 and C1 control characters, bidirectional controls and invisible characters from the `detail` text, which can quote the checked site. The invisible characters are chosen by Unicode class, not from a list: every format character, which is General_Category Cf, every Default_Ignorable_Code_Point and the line and paragraph separators U+2028 and U+2029. That covers the zero-width characters, the left-to-right and right-to-left marks, the Arabic letter mark, the word joiner and the invisible math operators, the soft hyphen, the byte-order mark, the variation selectors, the combining grapheme joiner, the Hangul fillers and the tag characters U+E0000 to U+E007F. Spaces stay: the no-break space and U+2000 to U+200A. The zero-width non-joiner and joiner go too, so a quoted Persian, Malayalam or Devanagari word loses its joining marks and reads without them. The Arabic number signs U+0600 to U+0605 go as well. Until 0.8.0 only the bidi controls and the C0 and C1 controls were removed, and the invisible characters stayed in the text and in the JSON. An emoji sequence in quoted text loses its zero-width joiners and its variation selector: a family emoji reads as its members side by side, a heart written with U+FE0F shows in text style, a keycap sequence loses the selector, and a tag flag shows as its black flag. The emoji themselves, skin tone modifiers, regional indicators and combining marks stay.
|
|
88
88
|
|
|
89
|
-
With `--json`, an invalid domain or a failed fetch returns `{ "error": "...", "target": "..." }` and exits with code `2`. A network error adds `code
|
|
89
|
+
With `--json`, an invalid domain or a failed fetch returns `{ "error": "...", "target": "..." }` and exits with code `2`. A network error adds `code` when the error carries one, such as `EAI_AGAIN`. An unknown option, a second domain and a missing domain return `{ "error": "..." }` only, with no target, and also exit with code `2`. `--help` and `--version` win over argument errors, also with `--json`, and exit with code `0`. An unknown option is named by its dashes and the letters, digits and dashes after them, and the rest of the argument is not shown, so a target typed with a leading dash, as in `-u:secret@example.com`, gives `unknown option "-u" (the rest of the argument is not shown)`.
|
|
90
90
|
|
|
91
91
|
In an error report the `target` is the address given on the command line. When it parses as a URL with a host, the user name and password are removed and each query value becomes `***`. Other values follow these cases:
|
|
92
92
|
|
|
@@ -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;
|
|
@@ -2062,8 +2062,10 @@ export function validateLlmsTxt(f) {
|
|
|
2062
2062
|
itemOpen = false;
|
|
2063
2063
|
continue;
|
|
2064
2064
|
}
|
|
2065
|
-
|
|
2066
|
-
|
|
2065
|
+
// A line inside a raw HTML block is no heading for these checks either (h2Mask also holds the fenced lines,
|
|
2066
|
+
// which were skipped above, so here it only adds the HTML block lines).
|
|
2067
|
+
const h1 = !h2Mask[i] && (/^ {0,3}#(?:[ \t]|$)/.test(l) || sx.text[i]);
|
|
2068
|
+
if (misplaced === -1 && i > firstIdx && h1)
|
|
2067
2069
|
misplaced = i;
|
|
2068
2070
|
if (h1) {
|
|
2069
2071
|
inSection = false;
|
|
@@ -2144,7 +2146,7 @@ export function validateLlmsTxt(f) {
|
|
|
2144
2146
|
if (misplaced !== -1) {
|
|
2145
2147
|
const s = checks[checks.length - 1];
|
|
2146
2148
|
s.status = "warn";
|
|
2147
|
-
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";
|
|
2148
2150
|
}
|
|
2149
2151
|
// Links are collected from the prose only, for the same reason the headings are: a link
|
|
2150
2152
|
// shown inside a code fence is an example of a link, not one an agent can follow. Computed
|
|
@@ -2165,6 +2167,25 @@ export function validateLlmsTxt(f) {
|
|
|
2165
2167
|
return r;
|
|
2166
2168
|
};
|
|
2167
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);
|
|
2168
2189
|
if (links.length === 0) {
|
|
2169
2190
|
add("links", "warn", "Markdown links an agent can follow", "no markdown links found");
|
|
2170
2191
|
}
|
|
@@ -2188,7 +2209,20 @@ export function validateLlmsTxt(f) {
|
|
|
2188
2209
|
};
|
|
2189
2210
|
const relativeCount = named.filter((m) => !hasScheme(m.target)).length;
|
|
2190
2211
|
const hostless = named.length - absolute - relativeCount;
|
|
2191
|
-
|
|
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";
|
|
2192
2226
|
}
|
|
2193
2227
|
// A list line that looks like a link entry but is not one (Tek-730) turns the links check to a warn.
|
|
2194
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",
|