turva-llms-txt-validator 0.6.0 → 0.7.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 CHANGED
@@ -114,12 +114,19 @@ Some failures stop the file checks early. For example, an HTML response is repor
114
114
  Links are read the way CommonMark reads them for the forms listed here.
115
115
 
116
116
  - A link inside inline code, after an escaped bracket or in an image does not count.
117
- - Inline code pairs only inside one block, the way CommonMark reads blocks. A blank line, a heading, a list item, a thematic break and a setext underline each end a block. An empty list item or a numbered item that does not start at 1 does not end a paragraph, unless the line closes an open list item, so a backtick pair across such a line is inline code. Block quotes and HTML blocks are not read as blocks here, so a backtick pair across the start of one, or across lines inside a block quote, stays inline code. CommonMark ends the block at a block quote and at an HTML block that can interrupt a paragraph.
118
- - A fence indented past three columns inside a list item hides what it holds, closed or not, as long as it sits less than four columns past the item's content column. Further in, CommonMark reads indented code, and this validator still counts a link in it. One gap remains for a fence opened on a list marker line, at four or more columns or by a tab: its closing line at 0 to 3 columns reads as a new opening fence, so the lines after it are skipped until the next fence.
117
+ - Inline code pairs only inside one block, the way CommonMark reads blocks. A blank line, a heading, a list item, a block quote line, a thematic break and a setext underline each end a block. The lines of one block quote belong to one block, an empty quote line ends it, and a lazy line after a quote line goes on with it, so a backtick pair inside one quote is inline code and a pair across the edge of a quote is not. An empty list item or a numbered item that does not start at 1 does not end a paragraph, unless the line closes an open list item, so a backtick pair across such a line is inline code. The content of a quote is not read further. Raw HTML blocks are not blocks for the HTML check, so there a backtick pair across one is still inline code, while the links check treats the lines of an HTML block as blank and the block as the end of the paragraph before it.
118
+ - A fence inside a list item counts as a fence, closed or not, in either fence character, on the marker line or up to three columns past the item's content column. It ends when the item closes. Four or more columns past that column is indented code.
119
119
  - A link in an ordered list, a target in angle brackets and a target with a title in double or single quotes do count.
120
120
  - A title in parentheses is not read, so `[Guide](https://example.org/guide (Overview))` is not collected.
121
- - An unbracketed target ends at its first closing parenthesis, so `https://example.org/docs_(v2)` is read only up to `https://example.org/docs_(v2`. Write a target that contains parentheses in angle brackets.
122
- - A link reference definition or label that spans several lines, and an image used as a reference, are not handled.
121
+ - An unbracketed target keeps balanced parentheses, so `https://example.org/docs_(v2)` is read whole. A target with an unbalanced parenthesis is not a link, and neither is a reference definition whose destination is unbalanced. Write a target with an unbalanced parenthesis in angle brackets or escape the parenthesis. The nesting depth is not limited, where CommonMark stops at 32.
122
+ - A link reference definition or label that spans several lines is not handled. A reference image whose label has a definition is skipped like an inline image. An empty target, `[Guide]()` or `[Guide](<>)`, is a link with an empty target and counts as a relative link.
123
+ - A link written inside the description text of an image, as in `![alt [Guide](https://example.org/a)](https://example.org/img.png)`, does not count. An image without a target (`![alt [Guide](https://example.org/a)]`) is read the way CommonMark reads it: the inner link counts.
124
+ - A pair of brackets inside a code span, as in `` [`Array[T]` reference](https://example.org/a) ``, neither closes nor opens a label. A link label ends where its paragraph ends, so a heading, a bullet or a number starting at 1, a quote or a fence that can interrupt the paragraph means there is no link.
125
+ - A shortcut reference `[Guide]` counts after a colon in the same line and after an inline target that did not parse, as in `[Guide](not a link)`. A `[Guide]:` at the start of a definition line does not resolve against itself.
126
+ - A link reference definition opens only where a block starts, for example after a blank line, a heading, a fence or a thematic break, at the start of a quote, as a list item or right after another definition. A line that continues a paragraph or a list item is not a definition. A definition indented four columns or more inside a list item is not read. A link written in the destination of a definition line is still counted as a link.
127
+ - Labels match by Unicode case folding. Character references in a target need their semicolon: `https&#58;//example.org` decodes, `https&#58//example.org` stays as written. A no-break or ideographic space is part of a target. Only an ASCII space, a tab or another control character ends one.
128
+ - The lines of a raw HTML block (types 1 to 7 of CommonMark, written at the start of the line and outside quotes and list items) hold no links, definitions or list items for the checks. The no-HTML check still reads them. A fence opener inside an HTML block is still read as a fence.
129
+ - A title, a link name or a summary whose text is only character references to white space, code spans of white space or empty quote markers counts as empty: `# &#32;`, `` [` `](https://example.org/a) ``, `>>` and `> >`. A line with only a no-break or ideographic space is not a blank line.
123
130
  - A quote escaped with a backslash inside a link title, as in `[A](https://example.org/a "Ti\"tle\"")`, is not recognised, so that link is dropped. A title that spans a line break is dropped the same way.
124
131
  - Nested brackets in a link label, as in `[A [x] B](https://example.org/a)`, drop the link. A link label cannot span a blank line.
125
132
  - A backslash escape in a target is resolved before the URL test, so `https\://example.org/guide` is read as `https://example.org/guide`.
@@ -127,13 +134,14 @@ Links are read the way CommonMark reads them for the forms listed here.
127
134
 
128
135
  A heading is an H2 when `##` is followed by a space or a tab, or when it is one line of text underlined with hyphens. The text line must follow a blank line or the start of the file. A list item above a line of hyphens is not an H2, and neither is a line of hyphens after a blank line.
129
136
 
130
- A link in a four-space indented code block counts as a link, but such a block does not count as a file list under an H2.
137
+ A link in a four-space indented code block counts as a link unless a backtick pair encloses it. Such a block does not count as a file list under an H2, inside a list item (five or more spaces after the marker, or six columns after a blank line under `- item`) or outside one.
131
138
 
132
139
  A link on a line that continues a list item, such as the line after a bare `-`, counts as that item's link:
133
140
 
134
141
  - After a bare marker the next line counts only when it is indented to the item's content column, which is 2 for `-` and 3 for `1.`. A blank line right after a bare marker ends the item.
135
142
  - After a blank line inside an item, a line counts only when it is indented to the content column, where the item's text starts, so `- item` needs 4 columns.
136
- - A code fence indented less than that column ends the item. A fence indented to it keeps the item open, and the line after the fence then counts only when it is indented to that column too.
143
+ - A code fence indented less than that column ends the item. A fence indented to it keeps the item open, and a lazy continuation cannot follow a fence, so the line after it needs the indent too.
144
+ - In a nested list, the content column of any item still open is enough for a line after a blank line or a fence.
137
145
 
138
146
  ### Home-page discovery
139
147
 
@@ -144,7 +152,7 @@ These checks are labelled **v2** in the output. They look for link relations in
144
152
  | 9 | Home page points to its llms.txt | `rel="describedby"` has a non-empty target | `info` |
145
153
  | 10 | Home page points to a Markdown version | `rel="alternate"` has media type `text/markdown` and a non-empty target | `info` |
146
154
 
147
- 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.
155
+ 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. A `Link` header value that has an `anchor` parameter is used only when the anchor is empty or resolves to the home page address, because an anchored value describes another resource.
148
156
 
149
157
  The validator does not follow the links inside `llms.txt`, crawl the site or test whether an AI agent can complete a task there.
150
158
 
@@ -191,7 +199,7 @@ The default validation requests two documents: `https://<host>/llms.txt` and `ht
191
199
  - Timeout: eight seconds per document, shared across its redirect chain.
192
200
  - Read limit: 256 KiB, which is 262,144 bytes, per response. A file cut there gets the size note "over 256 KiB, read truncated".
193
201
  - 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.
194
- - 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.
202
+ - 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, and one trailing dot on a redirect target is removed the same way.
195
203
 
196
204
  **DNS resolution is not checked for private addresses.** A syntactically public domain can resolve to a private IP, so if you expose this package through a service that accepts untrusted domains, enforce private-address restrictions at the network layer. Local and CI runs use their own network policy. The hosted validator runs on the Cloudflare edge.
197
205
 
@@ -214,10 +222,10 @@ The strict type check found two inputs that could leave `undefined` in a check's
214
222
  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.
215
223
 
216
224
  ```sh
217
- mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.6.0 --ignore-scripts && npm audit signatures
225
+ mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.7.0 --ignore-scripts && npm audit signatures
218
226
  ```
219
227
 
220
- `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.6.0` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.6.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.
228
+ `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.7.0` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.7.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.
221
229
 
222
230
  ## Development
223
231
 
@@ -233,7 +241,7 @@ npm test
233
241
 
234
242
  ## Hosted version and source
235
243
 
236
- The [hosted validator](https://turva.dev/llms-txt-validator) accepts any public domain in the browser. For any host other than turva.dev itself it requests the same two documents, `/llms.txt` and the home page. For turva.dev it validates the site's own files directly, without a request. It runs the same checks. Its source is in the [turva.dev Cloudflare Worker](https://github.com/erekola/turva-worker). The hosted validator is the canonical implementation: if results diverge, this package is updated to match it.
244
+ The [hosted validator](https://turva.dev/llms-txt-validator) accepts any public domain in the browser. For any host other than turva.dev itself it requests the same two documents, `/llms.txt` and the home page. For turva.dev it validates the site's own files directly, without a request. The hosted validator reads www.turva.dev the same way and reports https://turva.dev/llms.txt as the target. This package requests www.turva.dev as typed, follows its redirect and reports https://www.turva.dev/llms.txt. It runs the same checks. Its source is in the [turva.dev Cloudflare Worker](https://github.com/erekola/turva-worker). The hosted validator is the canonical implementation: if results diverge, this package is updated to match it.
237
245
 
238
246
  The hosted version also returns JSON with the same result shape for a completed validation. Its errors are shaped differently: an `error` field, plus a `docs` link when the `url` parameter is missing, with HTTP status 400 and no `target`. The site-wide rate limiter can also answer HTTP 429 as plain text, with a `Retry-After` header, before the validator runs, and that answer is not JSON.
239
247
 
@@ -54,7 +54,7 @@ export declare function enteredPath(raw: unknown): string;
54
54
  export declare function isValidPublicHost(host: string | null | undefined): boolean;
55
55
  export declare function fetchLlmsTxt(host: string, opts?: FetchOptions): Promise<FetchedLlmsTxt | FetchRedirect>;
56
56
  export declare function validateLlmsTxt(f: LlmsTxtInput): LlmsCheck[];
57
- export declare function findLinkRelations(html: string, linkHeader: string, readCut?: boolean): LinkRelations;
57
+ export declare function findLinkRelations(html: string, linkHeader: string, readCut?: boolean, homeUrls?: readonly string[]): LinkRelations;
58
58
  export declare function validateV2Discovery(found: LinkRelations | null, unreadReason?: string): LlmsCheck[];
59
59
  export declare function summarizeChecks(checks: LlmsCheck[]): ChecksSummary;
60
60
  export declare function validateHost(input: unknown, opts?: ValidateHostOptions): Promise<ValidationResult>;