turva-llms-txt-validator 0.4.3 → 0.5.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 +4 -4
- package/dist/src/index.js +76 -2
- 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 that looks like a link entry but is not a Markdown link: an unclosed destination such as `- [Name](https://example.com/a.md: notes)`, or an en dash, an em dash or a bullet in place of the list marker. The detail gives the 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
|
|
|
@@ -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.0 --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.0` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.5.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.
|
|
219
219
|
|
|
220
220
|
## Development
|
|
221
221
|
|
package/dist/src/index.js
CHANGED
|
@@ -787,6 +787,71 @@ function h2Lines(lines, fenced) {
|
|
|
787
787
|
}
|
|
788
788
|
return { h2, under };
|
|
789
789
|
}
|
|
790
|
+
// Code is not markup (Tek-730, 2026-10-31). Before the HTML check reads the file, every character
|
|
791
|
+
// of an inline code span and every backslash-escaped angle bracket is blanked, so
|
|
792
|
+
// `https://fal.ai/models/<endpoint-id>/llms.txt`, `submit_<form>_form` and an escaped
|
|
793
|
+
// \<node-name\> no longer read as tags. The text it receives is the prose the links check also
|
|
794
|
+
// reads, with fenced lines already blanked, so fenced code is not markup either. Line breaks stay,
|
|
795
|
+
// so a tag split over two lines keeps its shape. The span rule is codeSpanMask's, which is
|
|
796
|
+
// CommonMark's: an unclosed backtick run, or a pair that crosses a block boundary, is literal text.
|
|
797
|
+
// A real tag, a closing tag or a comment start in prose still warns, and an autolink is still not
|
|
798
|
+
// a tag. The package turva-llms-txt-validator mirrors this from 0.5.0.
|
|
799
|
+
function blankCodeForHtml(prose) {
|
|
800
|
+
const mask = codeSpanMask(prose);
|
|
801
|
+
const out = [];
|
|
802
|
+
for (let i = 0; i < prose.length; i++) {
|
|
803
|
+
const c = prose[i];
|
|
804
|
+
out.push(c !== "\n" && (mask[i] === 1 || ((c === "<" || c === ">") && isEscaped(prose, i))) ? " " : c);
|
|
805
|
+
}
|
|
806
|
+
return out.join("");
|
|
807
|
+
}
|
|
808
|
+
// List lines that look like a link entry and are not one (Tek-730, 2026-10-31). Two measured
|
|
809
|
+
// shapes: an entry whose destination is not closed, "- [Name](https://x.example/a.md: notes)",
|
|
810
|
+
// which holds a space and so is no CommonMark link, and an entry whose marker is an en dash, an
|
|
811
|
+
// em dash or a bullet, which is no Markdown list marker. Both read as links to a person and are
|
|
812
|
+
// invisible to the parser, so the links check counted the file as fine while an agent skipped the
|
|
813
|
+
// entry. Only lines outside fences and under an H2 are read. A line counts when it opens, after
|
|
814
|
+
// optional indentation, with a list marker (a hyphen, an asterisk, a plus or a number with a
|
|
815
|
+
// period or a parenthesis) or one of the three look-alike markers, then white space and "[", and
|
|
816
|
+
// no link that collectLinks found starts at that "[". A line with one of the three look-alike
|
|
817
|
+
// markers counts whether or not its link parses, because it is no list item either way. A task
|
|
818
|
+
// list box such as "- [x] done" is not an entry. Returns the one-based line numbers.
|
|
819
|
+
function unparsedLinkEntries(lines, fenced, linkAt) {
|
|
820
|
+
const hits = [];
|
|
821
|
+
const h2 = h2Lines(lines, fenced).h2;
|
|
822
|
+
let inH2 = false, offset = 0;
|
|
823
|
+
for (let i = 0; i < lines.length; i++) {
|
|
824
|
+
const l = lines[i];
|
|
825
|
+
const start = offset;
|
|
826
|
+
offset += (fenced[i] ? 0 : l.length) + 1;
|
|
827
|
+
if (fenced[i])
|
|
828
|
+
continue;
|
|
829
|
+
if (h2[i]) {
|
|
830
|
+
inH2 = true;
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
if (/^ {0,3}#(?:[ \t]|$)/.test(l)) {
|
|
834
|
+
inH2 = false;
|
|
835
|
+
continue;
|
|
836
|
+
}
|
|
837
|
+
if (!inH2)
|
|
838
|
+
continue;
|
|
839
|
+
const m = /^[ \t]*(?:[-*+]|\d{1,9}[.)]|[\u2013\u2014\u2022])[ \t]+\[/.exec(l);
|
|
840
|
+
if (!m)
|
|
841
|
+
continue;
|
|
842
|
+
const alt = /^[ \t]*[\u2013\u2014\u2022]/.test(l);
|
|
843
|
+
const bracketAt = m[0].length - 1;
|
|
844
|
+
if (/^\[[ xX]\](?:[ \t]|$)/.test(l.slice(bracketAt)))
|
|
845
|
+
continue;
|
|
846
|
+
if (alt || !linkAt.has(start + bracketAt))
|
|
847
|
+
hits.push(i + 1);
|
|
848
|
+
}
|
|
849
|
+
return hits;
|
|
850
|
+
}
|
|
851
|
+
function unparsedEntriesNote(hits) {
|
|
852
|
+
const n = hits.length;
|
|
853
|
+
return "; " + (n === 1 ? "1 list line looks like a link entry but is not a Markdown link, so an agent will not follow it" : n + " list lines look like link entries but are not Markdown links, so an agent will not follow them") + " (line" + (n === 1 ? "" : "s") + " " + hits.slice(0, 5).join(", ") + (n > 5 ? " and " + (n - 5) + " more" : "") + ")";
|
|
854
|
+
}
|
|
790
855
|
// The text of an ATX H1, or null when the line is not one. One to three leading spaces, a
|
|
791
856
|
// single "#", then a space, a tab or the end of the line. A closing run of "#" preceded by a
|
|
792
857
|
// space or a tab is not part of the title, and the title is what remains once both ends are
|
|
@@ -1129,6 +1194,13 @@ export function validateLlmsTxt(f) {
|
|
|
1129
1194
|
const hostless = named.length - absolute - relativeCount;
|
|
1130
1195
|
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
1196
|
}
|
|
1197
|
+
// A list line that looks like a link entry but is not one (Tek-730) turns the links check to a warn.
|
|
1198
|
+
const lookalikes = unparsedLinkEntries(lines, fenced, new Set(proseLinks.map((m) => m.at)));
|
|
1199
|
+
if (lookalikes.length > 0) {
|
|
1200
|
+
const lk = checks[checks.length - 1];
|
|
1201
|
+
lk.status = "warn";
|
|
1202
|
+
lk.detail += unparsedEntriesNote(lookalikes);
|
|
1203
|
+
}
|
|
1132
1204
|
if (f.truncated) {
|
|
1133
1205
|
add("size", "warn", "Small enough to be cheap to read", "over 256 KB, read truncated");
|
|
1134
1206
|
}
|
|
@@ -1145,8 +1217,10 @@ export function validateLlmsTxt(f) {
|
|
|
1145
1217
|
// operator such as the "+" in "a <b + c > d" does not. The tag name itself is ASCII. An unquoted
|
|
1146
1218
|
// value may not start with a quote, which keeps the quoted and the unquoted form from matching
|
|
1147
1219
|
// 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
|
-
|
|
1220
|
+
// '<div class="x"', has no closing ">" and does not warn. Code is blanked first (Tek-730): a tag-like
|
|
1221
|
+
// string inside an inline code span, a fenced block or after a backslash is not markup.
|
|
1222
|
+
const htmlScan = blankCodeForHtml(proseText);
|
|
1223
|
+
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
1224
|
add("no-html", "warn", "No HTML markup in the file", "HTML tags found; llms.txt should be plain markdown");
|
|
1151
1225
|
}
|
|
1152
1226
|
else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "turva-llms-txt-validator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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",
|