turva-llms-txt-validator 0.7.2 → 0.7.4

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,18 +114,18 @@ 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 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.
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. A backtick pair inside one quote is therefore 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. A backtick pair across such a line is therefore 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. 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. It may sit 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
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
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
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.
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. A heading, a bullet or a number starting at 1, a quote or a fence that can interrupt the paragraph therefore means there is no link.
125
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.
126
+ - A link reference definition opens only where a block starts. It can open, for example, after a blank line, a heading, a fence or a thematic break. It can also open 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
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.
128
+ - Here a raw HTML block is one of types 1 to 7 of CommonMark, written at the start of the line and outside quotes and list items. Its lines 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
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.
130
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.
131
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.
@@ -152,7 +152,11 @@ These checks are labelled **v2** in the output. They look for link relations in
152
152
  | 9 | Home page points to its llms.txt | `rel="describedby"` has a non-empty target | `info` |
153
153
  | 10 | Home page points to a Markdown version | `rel="alternate"` has media type `text/markdown` and a non-empty target | `info` |
154
154
 
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.
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.
156
+
157
+ 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.
158
+
159
+ A `Link` header value that has an `anchor` parameter is used only when the anchor is empty or resolves to the home page address. This is because an anchored value describes another resource.
156
160
 
157
161
  The validator does not follow the links inside `llms.txt`, crawl the site or test whether an AI agent can complete a task there.
158
162
 
@@ -209,7 +213,7 @@ For vulnerability reporting and supported versions, see [SECURITY.md](https://gi
209
213
 
210
214
  The source is TypeScript under `src/` and `bin/`, compiled with `tsc` to `dist/`. The tarball ships only `dist/src/index.js`, `dist/src/index.d.ts`, `dist/bin/cli.js`, the README, the license, the third-party notices and `package.json`, which npm always includes. `dist/` is generated, and `npm pack` builds it through the `prepack` script.
211
215
 
212
- GitHub Actions tests Node.js 22, 24 and 26 on Ubuntu and Node.js 22 on Windows. A version tag starts the release workflow, `.github/workflows/publish.yml`. It runs the type check and the tests, fails when the tag and `package.json` name different versions, publishes with npm trusted publishing over OIDC and creates the GitHub release from the CHANGELOG section. npm writes a provenance attestation. No npm token is stored in the repository or in the workflow.
216
+ GitHub Actions tests Node.js 22, 24 and 26 on Ubuntu and Node.js 22 on Windows. A version tag starts the release workflow, `.github/workflows/publish.yml`. It runs the type check and the tests, and it fails when the tag and `package.json` name different versions. It then publishes with npm trusted publishing over OIDC and creates the GitHub release from the CHANGELOG section. npm writes a provenance attestation. No npm token is stored in the repository or in the workflow.
213
217
 
214
218
  ## From JavaScript to TypeScript
215
219
 
@@ -222,10 +226,12 @@ The strict type check found two inputs that could leave `undefined` in a check's
222
226
  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.
223
227
 
224
228
  ```sh
225
- mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.7.2 --ignore-scripts && npm audit signatures
229
+ mkdir verify-llms && cd verify-llms && npm init -y && npm install turva-llms-txt-validator@0.7.4 --ignore-scripts && npm audit signatures
226
230
  ```
227
231
 
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.2` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.7.2 --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.
232
+ `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.
233
+
234
+ Tag `v0.7.4` must point at that same commit, and `gh api repos/erekola/llms-txt-validator/commits/v0.7.4 --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.
229
235
 
230
236
  ## Development
231
237
 
package/dist/src/index.js CHANGED
@@ -185,6 +185,16 @@ export function isValidPublicHost(host) {
185
185
  // the same-host rule, the credential and port rejections and the 256 KiB cap are the
186
186
  // guards this function was measured against.
187
187
  export async function fetchLlmsTxt(host, opts = {}) {
188
+ // Host-shape check at the entry: the same normalizeHostInput and isValidPublicHost that validateHost
189
+ // applies, so a direct caller gets the answer validateHost would give (upper case, one trailing dot
190
+ // and a raw IDN name are accepted and fetched in their normalised form). The helper is exported, so
191
+ // without this a direct caller could make the first request to an IP literal or an internal-use name.
192
+ // It checks the shape of the name only and does not resolve it. The refusal reuses the unsafe-target
193
+ // result with no status and no location: nothing was requested, and the typed host is not echoed back.
194
+ const normalized = normalizeHostInput(host);
195
+ if (!normalized || !isValidPublicHost(normalized))
196
+ return { redirect: true, reason: "unsafe-target", status: 0, location: "" };
197
+ host = normalized;
188
198
  const timeoutMs = opts.timeoutMs ?? 8000;
189
199
  const cap = opts.cap ?? 262144;
190
200
  const reqApex = host.startsWith("www.") ? host.slice(4) : host;
@@ -1391,6 +1401,8 @@ function isAbsoluteHttpUrl(t) {
1391
1401
  function redirectFailDetail(f) {
1392
1402
  if (f.reason === "off-host")
1393
1403
  return "redirects to " + f.location + ", a different host. llms.txt is host-scoped, so validate that host directly";
1404
+ if (f.reason === "unsafe-target" && !f.location)
1405
+ return "the host is not a public domain name, so no request was made";
1394
1406
  if (f.reason === "unsafe-target")
1395
1407
  return "redirects to an unsupported target (" + f.location + "). Only https redirects to the same site are followed";
1396
1408
  if (f.reason === "too-many")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turva-llms-txt-validator",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
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",