ssqch 0.12.0 → 0.13.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.
Files changed (130) hide show
  1. package/bundled/completions/bash +66 -8
  2. package/bundled/completions/elvish +23 -4
  3. package/bundled/completions/fish +36 -25
  4. package/bundled/completions/powershell +25 -4
  5. package/bundled/completions/zsh +44 -10
  6. package/bundled/docs/agents.md +2 -2
  7. package/bundled/docs/build-summary.md +1 -1
  8. package/bundled/docs/comparing-builds.md +2 -2
  9. package/bundled/docs/configuring.md +3 -6
  10. package/bundled/docs/deploying.md +1 -1
  11. package/bundled/docs/field-guide.md +4 -4
  12. package/bundled/docs/github-pages.md +1 -0
  13. package/bundled/docs/index.md +1 -1
  14. package/bundled/docs/install.md +1 -1
  15. package/bundled/docs/known-gaps.md +1 -1
  16. package/bundled/docs/markdown.md +8 -12
  17. package/bundled/docs/nav.yml +5 -1
  18. package/bundled/docs/netlify.md +4 -2
  19. package/bundled/docs/patrol.md +48 -0
  20. package/bundled/docs/plugins.md +6 -6
  21. package/bundled/docs/robots.md +72 -0
  22. package/bundled/docs/seo.md +2 -38
  23. package/bundled/docs/serving-markdown.md +142 -0
  24. package/bundled/docs/template-languages.md +1 -1
  25. package/bundled/docs/templates.md +1 -1
  26. package/bundled/docs/trailheads/from-hugo.md +5 -3
  27. package/bundled/docs/trailheads/from-jekyll.md +54 -13
  28. package/bundled/docs/trailheads/from-mkdocs.md +15 -12
  29. package/bundled/docs/trailheads/from-vitepress.md +13 -11
  30. package/bundled/docs/trailheads.md +3 -3
  31. package/bundled/docs/where-values-come-from.md +5 -5
  32. package/bundled/docs/writing-plugins.md +69 -0
  33. package/bundled/ssqch.d.ts +111 -43
  34. package/bundled/starter/engines/index.edge +1 -0
  35. package/bundled/starter/engines/index.ejs +1 -0
  36. package/bundled/starter/engines/index.hbs +1 -0
  37. package/bundled/starter/engines/index.liquid +1 -0
  38. package/bundled/starter/engines/layout.edge +7 -0
  39. package/bundled/starter/engines/layout.ejs +4 -0
  40. package/bundled/starter/engines/layout.hbs +4 -0
  41. package/bundled/starter/engines/layout.liquid +4 -0
  42. package/bundled/starter/src/_data/site.json +1 -0
  43. package/bundled/starter/src/_includes/layout.jinja +4 -0
  44. package/bundled/starter/src/index.jinja +1 -0
  45. package/bundled/starter/ssqch.config.js +14 -1
  46. package/bundled/starter-docs/engines/edge/base.edge +7 -0
  47. package/bundled/starter-docs/engines/edge/doc.edge +4 -0
  48. package/bundled/starter-docs/engines/ejs/base.ejs +4 -0
  49. package/bundled/starter-docs/engines/ejs/doc.ejs +4 -0
  50. package/bundled/starter-docs/engines/hbs/base.hbs +4 -0
  51. package/bundled/starter-docs/engines/hbs/doc.hbs +3 -0
  52. package/bundled/starter-docs/engines/liquid/base.liquid +4 -0
  53. package/bundled/starter-docs/engines/liquid/doc.liquid +4 -0
  54. package/bundled/starter-docs/src/_data/site.json +1 -0
  55. package/bundled/starter-docs/src/_includes/base.jinja +4 -0
  56. package/bundled/starter-docs/src/_includes/doc.jinja +4 -0
  57. package/bundled/starter-docs/src/assets/docs.css +4 -0
  58. package/bundled/starter-docs/src/assets/docs.js +17 -0
  59. package/bundled/starter-docs/ssqch.config.js +14 -1
  60. package/lib/assets.js +9 -9
  61. package/lib/chunk-25WERNDD.js +112 -0
  62. package/lib/{chunk-4ZMNLWE4.js → chunk-2BJFGKOE.js} +2 -2
  63. package/lib/chunk-2FKYWYAB.js +268 -0
  64. package/lib/{chunk-M2BBE2C3.js → chunk-3ZTRIO6O.js} +18 -17
  65. package/lib/{chunk-57HLSKZS.js → chunk-4AZFCSGJ.js} +2 -2
  66. package/lib/{chunk-ULQHJ4TS.js → chunk-55WXDGO4.js} +3 -3
  67. package/lib/{chunk-JX43SJHU.js → chunk-6FY77I4M.js} +24 -22
  68. package/lib/{chunk-RY3KLUQ3.js → chunk-6OUCRDYI.js} +267 -202
  69. package/lib/{chunk-EVFNYUTR.js → chunk-6U5VIQVY.js} +5 -5
  70. package/lib/{chunk-N3IZ44XY.js → chunk-7U5GWTEH.js} +88 -54
  71. package/lib/{chunk-VTYQ3JKL.js → chunk-AIJNG6MJ.js} +2 -2
  72. package/lib/{chunk-IIBZPHAW.js → chunk-C2Q7JKFI.js} +8 -8
  73. package/lib/{chunk-6CSH757V.js → chunk-DFJFHULZ.js} +33 -8
  74. package/lib/{chunk-XVV7JJK7.js → chunk-ENWDM2RW.js} +40 -39
  75. package/lib/{chunk-JUALMFW3.js → chunk-ER72RPD6.js} +1 -1
  76. package/lib/{chunk-RFREB3SI.js → chunk-F3JPNFCZ.js} +7 -7
  77. package/lib/{chunk-LLOA3QXV.js → chunk-FENJHLNM.js} +3 -2
  78. package/lib/{chunk-UU43WIZG.js → chunk-FJML7INB.js} +4 -2
  79. package/lib/{chunk-IZCF4UH3.js → chunk-FQZDUDFK.js} +1 -1
  80. package/lib/{chunk-GVHQ37JE.js → chunk-GSNRAGKQ.js} +10 -5
  81. package/lib/{chunk-L2IY4P6O.js → chunk-GU7BBYWB.js} +3 -3
  82. package/lib/{chunk-RGYJQYW3.js → chunk-HDKU6LRI.js} +32 -5
  83. package/lib/{chunk-IQUGLVZY.js → chunk-K5WZ2VYK.js} +4 -4
  84. package/lib/{chunk-JVT5ZRRH.js → chunk-OOKBXQAY.js} +5 -5
  85. package/lib/{chunk-MOLTDO5A.js → chunk-SNQOHNXE.js} +1 -1
  86. package/lib/{chunk-Z3XH4KWX.js → chunk-SPIFZBIW.js} +1 -1
  87. package/lib/{chunk-FNNXRVSU.js → chunk-T5IUI7W7.js} +10 -10
  88. package/lib/{chunk-5HEZ3WUQ.js → chunk-TGSVSG2G.js} +2 -2
  89. package/lib/{chunk-3GROJ3TY.js → chunk-U2KEMVXO.js} +24 -17
  90. package/lib/{chunk-4B3N44SN.js → chunk-UHRBPZ4A.js} +3 -3
  91. package/lib/{chunk-GWWA5Y3X.js → chunk-ULCT3PAV.js} +1 -1
  92. package/lib/{chunk-7RGEWDLF.js → chunk-UZNUS7RP.js} +10 -8
  93. package/lib/{chunk-DZ5F5XSI.js → chunk-V3G2QGL3.js} +10 -105
  94. package/lib/{chunk-DOHOKUGB.js → chunk-VILOEVK7.js} +50 -26
  95. package/lib/{chunk-DXMDXHV7.js → chunk-WGAIE3DD.js} +15 -14
  96. package/lib/{chunk-G3RFQDKO.js → chunk-WUCRAV36.js} +8 -6
  97. package/lib/{chunk-52ROOMBZ.js → chunk-XYAWJTHM.js} +9 -9
  98. package/lib/{chunk-L3K7MMFC.js → chunk-YA23NDMW.js} +2 -2
  99. package/lib/{chunk-R7PBREXL.js → chunk-YNJNMQWU.js} +8 -5
  100. package/lib/{chunk-AK7ZKSZP.js → chunk-ZMG25MXF.js} +17 -16
  101. package/lib/cli.js +56 -34
  102. package/lib/elements.js +9 -9
  103. package/lib/from-hugo.js +36 -0
  104. package/lib/from-jekyll.js +41 -0
  105. package/lib/from-mkdocs.js +49 -0
  106. package/lib/from-vitepress.js +49 -0
  107. package/lib/image.js +10 -10
  108. package/lib/links.js +9 -9
  109. package/lib/llms.js +521 -47
  110. package/lib/minify.js +10 -10
  111. package/lib/redirects.js +9 -9
  112. package/lib/robots.js +87 -0
  113. package/lib/rss.js +22 -12
  114. package/lib/sass.js +10 -10
  115. package/lib/sitemap.js +22 -33
  116. package/lib/ssqch.js +5 -5
  117. package/lib/vue.js +14 -13
  118. package/package.json +21 -1
  119. package/types/from-hugo.d.ts +5 -0
  120. package/types/from-jekyll.d.ts +11 -0
  121. package/types/from-mkdocs.d.ts +11 -0
  122. package/types/from-vitepress.d.ts +5 -0
  123. package/types/index.d.ts +45 -29
  124. package/types/llms.d.ts +12 -8
  125. package/types/robots.d.ts +13 -0
  126. package/types/sass.d.ts +1 -1
  127. package/types/sitemap.d.ts +3 -5
  128. package/wasm/markdown.wasm +0 -0
  129. /package/lib/{chunk-JX43SJHU.js.LEGAL.txt → chunk-6FY77I4M.js.LEGAL.txt} +0 -0
  130. /package/lib/{chunk-R7PBREXL.js.LEGAL.txt → chunk-YNJNMQWU.js.LEGAL.txt} +0 -0
@@ -17,6 +17,10 @@ sidebar: true
17
17
  {{ content }}
18
18
 
19
19
  <footer class="page-footer">
20
+ {% set copy = markdownCopy(page.url) %}
21
+ {% if copy %}
22
+ <p class="page-markdown"><a href="{{ copy }}">View as Markdown</a> <button type="button" data-copy-markdown="{{ copy }}" hidden>Copy as Markdown</button></p>
23
+ {% endif %}
20
24
  {% if site.editUrl %}
21
25
  <p><a href="{{ site.editUrl }}{{ page.inputPath | replace('./', '') }}">Edit this page</a></p>
22
26
  {% endif %}
@@ -237,6 +237,10 @@ summary { font-weight: 600; cursor: pointer; }
237
237
  .tabs [role="tablist"] ~ .tab { border-top: 0; }
238
238
 
239
239
  .page-footer { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--border); }
240
+ /* The page as Markdown, for agents: a link, and a button docs.js turns on. */
241
+ .page-markdown { display: flex; align-items: center; gap: 1rem; font-size: 0.9rem; }
242
+ .page-markdown button { padding: 0.25rem 0.7rem; border: 1px solid var(--muted); border-radius: 0.375rem; background: none; color: var(--text); font: inherit; cursor: pointer; }
243
+ .page-markdown button:hover { background: var(--selected); }
240
244
  .pager { display: flex; justify-content: space-between; gap: 1rem; }
241
245
  .footnotes { margin-top: 2.5rem; font-size: 0.9rem; color: var(--muted); }
242
246
 
@@ -65,3 +65,20 @@ const { PagefindUI } = /** @type {any} */ (window);
65
65
  if (PagefindUI && document.getElementById("search")) {
66
66
  new PagefindUI({ element: "#search", showSubResults: true });
67
67
  }
68
+
69
+ // Copy as Markdown: the page's Markdown copy (llmsPlugin() writes it), for pasting into a chat
70
+ // with an agent. The button stays hidden where there's no clipboard to copy to.
71
+ for (const button of document.querySelectorAll("[data-copy-markdown]")) {
72
+ if (!navigator.clipboard) continue;
73
+ button.hidden = false;
74
+ button.addEventListener("click", async () => {
75
+ try {
76
+ const response = await fetch(button.dataset.copyMarkdown);
77
+ await navigator.clipboard.writeText(await response.text());
78
+ button.textContent = "Copied";
79
+ } catch {
80
+ button.textContent = "Couldn't copy";
81
+ }
82
+ setTimeout(() => { button.textContent = "Copy as Markdown"; }, 2000);
83
+ });
84
+ }
@@ -1,8 +1,14 @@
1
1
  // A documentation site. `ssqch serve` serves it with live reload, and
2
2
  // `ssqch build` builds it into dist/. ssqch.d.ts gives your editor the types.
3
- import { defineConfig } from "ssqch";
3
+ import { defineConfig, readData } from "ssqch";
4
4
  import { linksPlugin } from "ssqch/links";
5
+ import { llmsPlugin } from "ssqch/llms";
5
6
  import { minifyPlugin } from "ssqch/minify";
7
+ import { robotsPlugin } from "ssqch/robots";
8
+ import { sitemapPlugin } from "ssqch/sitemap";
9
+
10
+ // The site's address, from src/_data/site.json: put yours there.
11
+ const { url } = readData("src/_data/site.json");
6
12
 
7
13
  // Search is Pagefind (https://pagefind.app), which indexes the built pages.
8
14
  // It's a program of its own that npx fetches, so it's opt-in:
@@ -35,6 +41,13 @@ export default defineConfig(({ env }) => ({
35
41
  plugins: [
36
42
  // Broken internal links (and anchors) fail a production build.
37
43
  linksPlugin({ ignore: ["/pagefind/"] }),
44
+ // What crawlers and agents read: sitemap.xml, robots.txt, and llms.txt with a
45
+ // Markdown copy of each page (each page links its copy). `ssqch patrol` checks them.
46
+ sitemapPlugin({ url }),
47
+ // `false` keeps that kind of AI crawler out: training (collecting pages to train
48
+ // models), search (AI search answers) or fetch (a page a person asked about).
49
+ robotsPlugin({ ai: { training: true, search: true, fetch: true } }),
50
+ llmsPlugin({ url }),
38
51
  env === "production" && minifyPlugin(),
39
52
  ],
40
53
  }));
package/lib/assets.js CHANGED
@@ -2,28 +2,28 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  Options
5
- } from "./chunk-MOLTDO5A.js";
5
+ } from "./chunk-SNQOHNXE.js";
6
6
  import {
7
7
  BUILTINS,
8
8
  blake3Hex,
9
9
  rewriteHtml
10
- } from "./chunk-DOHOKUGB.js";
11
- import "./chunk-GWWA5Y3X.js";
12
- import "./chunk-EVFNYUTR.js";
10
+ } from "./chunk-VILOEVK7.js";
11
+ import "./chunk-ULCT3PAV.js";
12
+ import "./chunk-6U5VIQVY.js";
13
13
  import "./chunk-AD3HAW3W.js";
14
14
  import "./chunk-YCOTX2VM.js";
15
15
  import "./chunk-DDV6JEC2.js";
16
- import "./chunk-RY3KLUQ3.js";
16
+ import "./chunk-6OUCRDYI.js";
17
+ import "./chunk-SPIFZBIW.js";
17
18
  import "./chunk-FVZ5JBRI.js";
18
- import "./chunk-Z3XH4KWX.js";
19
- import "./chunk-UU43WIZG.js";
20
- import "./chunk-57HLSKZS.js";
19
+ import "./chunk-FJML7INB.js";
20
+ import "./chunk-4AZFCSGJ.js";
21
21
  import "./chunk-CMUWRPSQ.js";
22
22
  import {
23
23
  bail,
24
24
  warn,
25
25
  warning
26
- } from "./chunk-R7PBREXL.js";
26
+ } from "./chunk-YNJNMQWU.js";
27
27
  import {
28
28
  displayPath
29
29
  } from "./chunk-VJWQSYEG.js";
@@ -0,0 +1,112 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+
4
+ // src/content.ts
5
+ var HEADING = /<h([1-6])(\s[^>]*)?>(.*?)<\/h[1-6]\s*>/gis;
6
+ var ID_ATTR = /(?:^|\s)id\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+))/i;
7
+ var TAG = /<(\/?)([A-Za-z][A-Za-z0-9-]*)([^>]*)>|<!--.*?-->/gs;
8
+ var HIDDEN = /\saria-hidden\s*=\s*["']?true|\sclass\s*=\s*["'][^"']*\bheader-anchor\b/i;
9
+ var CODE = /<!--.*?-->|<(pre|script|style|template|textarea)\b.*?<\/(?:pre|script|style|template|textarea)\s*>/gis;
10
+ var CODE_WITH_HEADING = /<code\b(?:(?!<\/code\s*>).)*?<h[1-6][\s>](?:(?!<\/code\s*>).)*<\/code\s*>/gis;
11
+ var VOID = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
12
+ function headings(html) {
13
+ if (!html.includes("<h") && !html.includes("<H")) return [];
14
+ const out = [];
15
+ for (const found of html.replace(CODE, "").replace(CODE_WITH_HEADING, "").matchAll(HEADING)) {
16
+ const id = ID_ATTR.exec(found[2] ?? "");
17
+ const value = id ? id[1] ?? id[2] ?? id[3] : void 0;
18
+ out.push({ level: Number(found[1]), id: value === void 0 ? void 0 : decodeEntities(value), text: htmlText(found[3]) });
19
+ }
20
+ return out;
21
+ }
22
+ function htmlText(html) {
23
+ let text = "";
24
+ let hidden = 0;
25
+ let last = 0;
26
+ for (const found of html.matchAll(TAG)) {
27
+ if (hidden === 0) text += html.slice(last, found.index);
28
+ last = found.index + found[0].length;
29
+ if (found[2] === void 0) continue;
30
+ const name = found[2].toLowerCase();
31
+ const attrs = found[3] ?? "";
32
+ if (VOID.has(name) || attrs.endsWith("/")) {
33
+ if (name === "br" && hidden === 0) text += " ";
34
+ continue;
35
+ }
36
+ if (found[1] === "/") hidden = Math.max(0, hidden - 1);
37
+ else if (hidden > 0 || HIDDEN.test(attrs)) hidden++;
38
+ }
39
+ if (hidden === 0) text += html.slice(last);
40
+ return splitWhitespace(decodeEntities(text)).join(" ");
41
+ }
42
+ function splitWhitespace(text) {
43
+ return text.split(/[\t-\r \u0085\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]+/).filter((word) => word !== "");
44
+ }
45
+ var ENTITY = /&(#[0-9]{1,7}|#[xX][0-9A-Fa-f]{1,6}|[A-Za-z]+);/g;
46
+ var NAMED = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\xA0" };
47
+ function decodeEntities(s) {
48
+ if (!s.includes("&")) return s;
49
+ return s.replace(ENTITY, (whole, name) => {
50
+ if (Object.hasOwn(NAMED, name)) return NAMED[name];
51
+ if (name[0] !== "#") return whole;
52
+ const code = name[1] === "x" || name[1] === "X" ? Number.parseInt(name.slice(2), 16) : Number.parseInt(name.slice(1), 10);
53
+ return code <= 1114111 && !(code >= 55296 && code <= 57343) ? String.fromCodePoint(code) : whole;
54
+ });
55
+ }
56
+ function escapeText(s) {
57
+ return s.replace(/[&<>"]/g, (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : c === ">" ? "&gt;" : "&quot;");
58
+ }
59
+ function escapeHtml(s) {
60
+ return s.replace(/[&<>"']/g, (c) => c === "&" ? "&amp;" : c === "<" ? "&lt;" : c === ">" ? "&gt;" : c === '"' ? "&quot;" : "&#39;");
61
+ }
62
+ function excerpt(html) {
63
+ const more = /<!--\s*more\s*-->/.exec(html);
64
+ if (more) return html.slice(0, more.index).trim();
65
+ return /<p(?:\s[^>]*)?>.*?<\/p>/is.exec(html)?.[0];
66
+ }
67
+ function toc(list, from, to, ordered, markup = {}) {
68
+ const tag = ordered ? "ol" : "ul";
69
+ const attr = (name, value) => value ? ` ${name}="${escapeHtml(value)}"` : "";
70
+ const open = (outer) => `<${tag}${outer ? attr("id", markup.id) + attr("class", markup.class) : attr("class", markup.sublistClass)}>`;
71
+ const link = attr("class", markup.linkClass);
72
+ const items = [];
73
+ for (const v of list) {
74
+ const h = v;
75
+ if (typeof h?.level !== "number") continue;
76
+ const level = Math.trunc(h.level);
77
+ const id = typeof h.id === "string" && h.id !== "" ? h.id : void 0;
78
+ if (id !== void 0 && level >= from && level <= to) items.push({ level, id, text: String(h.text) });
79
+ }
80
+ let out = "";
81
+ const stack = [];
82
+ for (const h of items) {
83
+ if (!stack.length) {
84
+ out += open(true);
85
+ stack.push(h.level);
86
+ } else {
87
+ while (stack.length > 1 && h.level < stack[stack.length - 1]) {
88
+ out += `</li></${tag}>`;
89
+ stack.pop();
90
+ }
91
+ if (h.level > stack[stack.length - 1]) {
92
+ out += open(false);
93
+ stack.push(h.level);
94
+ } else {
95
+ out += "</li>";
96
+ }
97
+ }
98
+ out += `<li${attr("class", markup.itemClass?.replaceAll("{level}", String(h.level)))}><a href="#${escapeHtml(h.id ?? "")}"${link}>${escapeText(h.text)}</a>`;
99
+ }
100
+ for (const _ of stack) out += `</li></${tag}>`;
101
+ return out;
102
+ }
103
+
104
+ export {
105
+ headings,
106
+ htmlText,
107
+ splitWhitespace,
108
+ decodeEntities,
109
+ escapeText,
110
+ excerpt,
111
+ toc
112
+ };
@@ -6,10 +6,10 @@ import {
6
6
  import {
7
7
  compareRuns,
8
8
  runsText
9
- } from "./chunk-RGYJQYW3.js";
9
+ } from "./chunk-HDKU6LRI.js";
10
10
  import {
11
11
  red
12
- } from "./chunk-R7PBREXL.js";
12
+ } from "./chunk-YNJNMQWU.js";
13
13
  import {
14
14
  compareText
15
15
  } from "./chunk-VJWQSYEG.js";
@@ -0,0 +1,268 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ htmlText
5
+ } from "./chunk-25WERNDD.js";
6
+ import {
7
+ count
8
+ } from "./chunk-6U5VIQVY.js";
9
+ import "./chunk-DDV6JEC2.js";
10
+ import {
11
+ markdown
12
+ } from "./chunk-6OUCRDYI.js";
13
+ import "./chunk-SPIFZBIW.js";
14
+ import "./chunk-FVZ5JBRI.js";
15
+ import "./chunk-FJML7INB.js";
16
+ import "./chunk-4AZFCSGJ.js";
17
+ import "./chunk-CMUWRPSQ.js";
18
+ import {
19
+ bail
20
+ } from "./chunk-YNJNMQWU.js";
21
+ import {
22
+ compareText
23
+ } from "./chunk-VJWQSYEG.js";
24
+ import "./chunk-I3PS26CI.js";
25
+
26
+ // src/patrol.ts
27
+ import fs from "node:fs";
28
+ import path from "node:path";
29
+ var LLMS_LIMIT = 5e4;
30
+ var COPY_LONG = 5e4;
31
+ var COPY_CUT = 1e5;
32
+ var walk = (dir, rel = "") => fs.readdirSync(path.join(dir, rel), { withFileTypes: true }).flatMap((e) => {
33
+ const r = rel ? `${rel}/${e.name}` : e.name;
34
+ return e.isDirectory() ? walk(dir, r) : e.isFile() ? [r] : [];
35
+ }).sort(compareText);
36
+ var urlOf = (file) => `/${file.replace(/(^|\/)index\.html?$/, "$1")}`;
37
+ var textOf = (html) => htmlText(html.replace(/<(script|style|svg|template|noscript)\b[\s\S]*?<\/\1\s*>/gi, " "));
38
+ function part(html, name) {
39
+ const open = new RegExp(`<${name}\\b[^>]*>`, "i").exec(html);
40
+ if (!open) return void 0;
41
+ const close = html.toLowerCase().lastIndexOf(`</${name}`);
42
+ return close > open.index ? { start: open.index, html: html.slice(open.index + open[0].length, close) } : void 0;
43
+ }
44
+ var words = (text) => text.toLowerCase().split(/[^\p{L}\p{N}]+/u).filter((w) => w.length > 1);
45
+ function covered(a, b) {
46
+ if (!a.length) return 1;
47
+ const have = /* @__PURE__ */ new Map();
48
+ for (const w of b) have.set(w, (have.get(w) ?? 0) + 1);
49
+ let hits = 0;
50
+ for (const w of a) {
51
+ const n = have.get(w) ?? 0;
52
+ if (n > 0) {
53
+ hits++;
54
+ have.set(w, n - 1);
55
+ }
56
+ }
57
+ return hits / a.length;
58
+ }
59
+ function linksIn(md) {
60
+ const out = [];
61
+ let fence;
62
+ for (const line of md.split("\n")) {
63
+ const marker = /^\s{0,3}(`{3,}|~{3,})/.exec(line)?.[1];
64
+ if (fence !== void 0) {
65
+ if (marker && marker[0] === fence[0] && marker.length >= fence.length && line.trim() === marker) fence = void 0;
66
+ continue;
67
+ }
68
+ if (marker) {
69
+ fence = marker;
70
+ continue;
71
+ }
72
+ const ref = /^ {0,3}\[[^\]]+\]:\s*<?([^\s>]+)/.exec(line);
73
+ if (ref) out.push(ref[1]);
74
+ for (const m of line.replace(/`+[^`]*`+/g, "").matchAll(/\]\(\s*<?([^\s)>]+)/g)) out.push(m[1]);
75
+ }
76
+ return out;
77
+ }
78
+ function prose(md) {
79
+ let fence;
80
+ return md.split("\n").filter((line) => {
81
+ const marker = /^\s{0,3}(`{3,}|~{3,})/.exec(line)?.[1];
82
+ if (fence !== void 0) {
83
+ if (marker && marker[0] === fence[0] && marker.length >= fence.length && line.trim() === marker) fence = void 0;
84
+ return false;
85
+ }
86
+ if (marker) {
87
+ fence = marker;
88
+ return false;
89
+ }
90
+ return true;
91
+ }).map((line) => line.replace(/`+[^`]*`+/g, "")).join("\n");
92
+ }
93
+ function fencesClose(md) {
94
+ let fence;
95
+ for (const line of md.split("\n")) {
96
+ const marker = /^\s{0,3}(`{3,}|~{3,})/.exec(line)?.[1];
97
+ if (fence === void 0) {
98
+ if (marker) fence = marker;
99
+ } else if (marker && marker[0] === fence[0] && marker.length >= fence.length && line.trim() === marker) fence = void 0;
100
+ }
101
+ return fence === void 0;
102
+ }
103
+ var relative = (href) => !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(href) && !href.startsWith("#") && !href.startsWith("/");
104
+ function patrol(dir) {
105
+ let stat;
106
+ try {
107
+ stat = fs.statSync(dir);
108
+ } catch {
109
+ bail(`${dir} isn't there: build the site first (\`ssqch build\`), or name a build folder`);
110
+ }
111
+ if (!stat.isDirectory()) bail(`${dir} is a file, not a build folder`);
112
+ const files = walk(dir);
113
+ const has = new Set(files);
114
+ const read = (file) => fs.readFileSync(path.join(dir, file), "utf8");
115
+ const found = /* @__PURE__ */ new Map();
116
+ const say = (code, message, file) => {
117
+ const f = found.get(code) ?? { code, message, files: [] };
118
+ if (file !== void 0) f.files.push(file);
119
+ found.set(code, f);
120
+ };
121
+ const pages = files.filter((f) => /\.html?$/i.test(f) && !/(^|\/)404\.html?$/i.test(f));
122
+ const robots = has.has("robots.txt") ? read("robots.txt") : void 0;
123
+ const sitemapFile = has.has("sitemap.xml") ? "sitemap.xml" : void 0;
124
+ const sitemapLine = robots && /^\s*sitemap:\s*(\S+)/im.exec(robots)?.[1];
125
+ const sitemap = sitemapFile ? read(sitemapFile) : void 0;
126
+ const locs = sitemap ? [...sitemap.matchAll(/<loc>\s*([^<\s]+)\s*<\/loc>/g)].map((m) => m[1].replace(/&amp;/g, "&")) : [];
127
+ const origins = /* @__PURE__ */ new Set();
128
+ for (const u of [sitemapLine, ...locs.slice(0, 1)]) {
129
+ try {
130
+ if (u) origins.add(new URL(u).origin);
131
+ } catch {
132
+ }
133
+ }
134
+ const fileOf = (href) => {
135
+ let p;
136
+ if (href.startsWith("/") && !href.startsWith("//")) p = href;
137
+ else {
138
+ try {
139
+ const u = new URL(href);
140
+ if (!origins.has(u.origin)) return void 0;
141
+ p = u.pathname;
142
+ } catch {
143
+ return void 0;
144
+ }
145
+ }
146
+ p = decodeURIComponent(p.replace(/[?#].*$/, "")).replace(/^\/+/, "");
147
+ if (has.has(p)) return p;
148
+ if (has.has(`${p.replace(/\/$/, "")}/index.html`.replace(/^\//, ""))) return `${p.replace(/\/$/, "")}/index.html`.replace(/^\//, "");
149
+ return "";
150
+ };
151
+ if (!robots) say("no-robots", "no robots.txt: crawlers find no sitemap line and no rules for AI crawlers (robotsPlugin() writes one)");
152
+ if (!sitemapFile && !sitemapLine) say("no-sitemap", "no sitemap.xml, and robots.txt names none (sitemapPlugin({ url }) writes one)");
153
+ if (!has.has("404.html")) say("no-404", "no 404.html: a missing page gets the host's error page, or worse, a 200");
154
+ else if (has.has("index.html") && read("404.html") === read("index.html")) say("no-404", "404.html is the home page: a missing page should say it's missing");
155
+ const llms = has.has("llms.txt") ? read("llms.txt") : void 0;
156
+ const listed = /* @__PURE__ */ new Set();
157
+ if (llms === void 0) say("no-llms", "no llms.txt: an agent gets no map of the site (llmsPlugin() writes one, with a Markdown copy of each page)");
158
+ else {
159
+ if (!/^?# \S/.test(llms)) say("llms-shape", "llms.txt doesn't start with a `# ` heading (the site's name), which llmstxt.org's format requires", "llms.txt");
160
+ if (llms.length > LLMS_LIMIT) say("llms-long", `llms.txt is ${count(llms.length)} characters, over ${count(LLMS_LIMIT)}: more than an agent reads before deciding where to go (link section files from it instead)`, "llms.txt");
161
+ for (const href of linksIn(llms)) {
162
+ if (relative(href)) {
163
+ say("relative-links", "links that aren't whole addresses (or from the site's root): they break once the text is read on its own", "llms.txt");
164
+ continue;
165
+ }
166
+ const file = fileOf(href);
167
+ if (file === void 0) continue;
168
+ if (file === "") say("llms-broken", `llms.txt links to files that aren't in the build`, href);
169
+ else {
170
+ if (!/\.(md|markdown|txt)$/i.test(file)) say("llms-html", "llms.txt links to pages, not their Markdown: an agent reads Markdown without the page's chrome", href);
171
+ listed.add(file);
172
+ }
173
+ }
174
+ }
175
+ let copies = 0;
176
+ const pageUrls = [];
177
+ for (const file of pages) {
178
+ const html = read(file);
179
+ if (/<meta\s[^>]*http-equiv=["']?refresh/i.test(html)) continue;
180
+ pageUrls.push(urlOf(file));
181
+ const h1 = (html.match(/<h1[\s>]/gi) ?? []).length;
182
+ if (h1 === 0) say("no-h1", "pages with no <h1>: an agent takes the first heading as what the page is about", file);
183
+ else if (h1 > 1) say("h1s", "pages with more than one <h1>", file);
184
+ if (!/<meta\s[^>]*name=["']?description["']?[^>]*content=["']?[^"'\s>]/i.test(html) && !/<meta\s[^>]*content=["']?[^"'>]+["']?[^>]*name=["']?description/i.test(html)) say("no-description", 'pages with no <meta name="description">: what search results and agents show for a link', file);
185
+ const body = part(html, "body")?.html ?? html;
186
+ const content = part(body, "main") ?? part(body, "article");
187
+ if (!content) say("no-main", "pages with their content in neither <main> nor <article>: an agent can't tell the page from its navigation", file);
188
+ else {
189
+ const before = words(textOf(body.slice(0, content.start))).length;
190
+ const all = words(textOf(body)).length;
191
+ if (all > 0 && before / all > 0.5) say("content-late", "pages whose <main> comes after most of their text (navigation first): an agent with a short read sees the menus", file);
192
+ }
193
+ const linked = /<link\s[^>]*rel=["']?alternate["']?[^>]*type=["']?text\/markdown["']?[^>]*>/i.exec(html)?.[0] ?? /<link\s[^>]*type=["']?text\/markdown["']?[^>]*rel=["']?alternate["']?[^>]*>/i.exec(html)?.[0];
194
+ const href = linked ? /href=["']?([^"'\s>]+)/i.exec(linked)?.[1] : void 0;
195
+ let copy;
196
+ if (href !== void 0) {
197
+ const target = fileOf(href.startsWith("/") || /^[a-z]+:/i.test(href) ? href : `/${path.posix.join(path.posix.dirname(file), href)}`);
198
+ if (target === "") {
199
+ say("copy-missing", "pages that link a Markdown copy that isn't in the build", file);
200
+ continue;
201
+ }
202
+ copy = target;
203
+ } else {
204
+ const guess = file.replace(/\.html?$/i, ".md");
205
+ if (has.has(guess)) copy = guess;
206
+ }
207
+ if (!copy) continue;
208
+ copies++;
209
+ const md = read(copy);
210
+ if (md.length > COPY_CUT) say("copy-cut-off", `Markdown copies over ${count(COPY_CUT)} characters, where Claude Code's fetch stops reading`, copy);
211
+ else if (md.length > COPY_LONG) say("copy-long", `Markdown copies over ${count(COPY_LONG)} characters: long for one fetch`, copy);
212
+ if (!fencesClose(md)) say("copy-fence", "Markdown copies with a code fence that never closes: the rest reads as code", copy);
213
+ if (linksIn(md).some(relative)) say("relative-links", "links that aren't whole addresses (or from the site's root): they break once the text is read on its own", copy);
214
+ if ([...linksIn(md), ...[...prose(md).matchAll(/<(?:img|a|source)\b[^>]*\s(?:src|href)\s*=\s*["']([^"']+)["']/gi)].map((m) => m[1])].some((href2) => !relative(href2) && fileOf(href2) === "")) say("copy-broken", "Markdown copies that link the site's own files that aren't in the build (an image's source path, say)", copy);
215
+ if (content) {
216
+ const page = words(textOf(content.html));
217
+ const own = words(textOf(markdown(md)));
218
+ if (page.length >= 20 && (covered(own, page) < 0.8 || covered(page, own) < 0.5)) say("copy-differs", "Markdown copies that don't say what their page says (under 80% of the copy's words on the page, or under half the page's in the copy)", copy);
219
+ }
220
+ }
221
+ if (llms !== void 0 && locs.length && listed.size) {
222
+ const copyFor = (file) => file.replace(/\.html?$/i, ".md");
223
+ const inList = locs.filter((loc) => {
224
+ const file = fileOf(loc);
225
+ return !file || listed.has(file) || listed.has(copyFor(file));
226
+ }).length;
227
+ if (inList / locs.length < 0.95) say("llms-coverage", `llms.txt lists ${count(inList)} of the sitemap's ${count(locs.length)} pages: under 95%, so an agent misses some (llmsPlugin() lists them all)`, "llms.txt");
228
+ }
229
+ return {
230
+ pages: pageUrls.length,
231
+ signs: { robots: robots !== void 0, sitemap: sitemapFile !== void 0 || Boolean(sitemapLine), llms: llms !== void 0, notFound: has.has("404.html") },
232
+ copies,
233
+ findings: [...found.values()].map((f) => ({ ...f, files: [...new Set(f.files)] }))
234
+ };
235
+ }
236
+ function patrolText(p, shown) {
237
+ const sign = (name, there) => `${name} ${there ? "posted" : "missing"}`;
238
+ let out = `Patrol of ${shown}: ${p.pages} page${p.pages === 1 ? "" : "s"}, ${p.copies} with a Markdown copy
239
+ `;
240
+ out += ` ${[sign("robots.txt", p.signs.robots), sign("sitemap", p.signs.sitemap), sign("llms.txt", p.signs.llms), sign("404.html", p.signs.notFound)].join(", ")}
241
+ `;
242
+ if (!p.findings.length) return `${out}
243
+ All clear: nothing on the trail for an agent to trip on.
244
+ `;
245
+ out += "\n";
246
+ for (const f of p.findings) {
247
+ const n = f.files.length;
248
+ out += `warn[${f.code}]: ${f.message}${n > 1 ? ` (${n})` : ""}
249
+ `;
250
+ for (const file of f.files.slice(0, 5)) out += ` ${file}
251
+ `;
252
+ if (n > 5) out += ` and ${n - 5} more (--format json lists them all)
253
+ `;
254
+ }
255
+ const files = new Set(p.findings.flatMap((f) => f.files)).size;
256
+ out += `
257
+ ${p.findings.length} kind${p.findings.length === 1 ? "" : "s"} of warning${files ? ` in ${files} file${files === 1 ? "" : "s"}` : ""}. \`ssqch docs "what patrol checks"\` says what each code means.
258
+ `;
259
+ return out;
260
+ }
261
+ function patrolJson(p, output) {
262
+ return { schemaVersion: 1, output, pages: p.pages, copies: p.copies, signs: p.signs, warnings: p.findings.map((f) => ({ code: f.code, message: f.message, files: f.files })) };
263
+ }
264
+ export {
265
+ patrol,
266
+ patrolJson,
267
+ patrolText
268
+ };
@@ -2,26 +2,27 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  OUTPUT_LIST
5
- } from "./chunk-JX43SJHU.js";
6
- import "./chunk-L3K7MMFC.js";
7
- import "./chunk-DZ5F5XSI.js";
5
+ } from "./chunk-6FY77I4M.js";
6
+ import "./chunk-YA23NDMW.js";
7
+ import "./chunk-V3G2QGL3.js";
8
8
  import "./chunk-4Q6WMTER.js";
9
- import "./chunk-4B3N44SN.js";
10
- import "./chunk-DOHOKUGB.js";
11
- import "./chunk-GWWA5Y3X.js";
9
+ import "./chunk-UHRBPZ4A.js";
10
+ import "./chunk-25WERNDD.js";
11
+ import "./chunk-VILOEVK7.js";
12
+ import "./chunk-ULCT3PAV.js";
12
13
  import {
13
14
  count
14
- } from "./chunk-EVFNYUTR.js";
15
+ } from "./chunk-6U5VIQVY.js";
15
16
  import "./chunk-AD3HAW3W.js";
16
17
  import "./chunk-YCOTX2VM.js";
17
18
  import "./chunk-DDV6JEC2.js";
18
- import "./chunk-RY3KLUQ3.js";
19
+ import "./chunk-6OUCRDYI.js";
20
+ import "./chunk-SPIFZBIW.js";
19
21
  import "./chunk-FVZ5JBRI.js";
20
- import "./chunk-Z3XH4KWX.js";
21
- import "./chunk-UU43WIZG.js";
22
- import "./chunk-57HLSKZS.js";
22
+ import "./chunk-FJML7INB.js";
23
+ import "./chunk-4AZFCSGJ.js";
23
24
  import "./chunk-CMUWRPSQ.js";
24
- import "./chunk-R7PBREXL.js";
25
+ import "./chunk-YNJNMQWU.js";
25
26
  import "./chunk-VJWQSYEG.js";
26
27
  import "./chunk-I3PS26CI.js";
27
28
 
@@ -38,8 +39,8 @@ var PHOTO = `
38
39
  || || / \\ ||
39
40
  || || / \\ ||
40
41
  `;
41
- function lastSiting(root, now) {
42
- const none = "No confirmed sitings here yet. `ssqch build` would be the first.";
42
+ function lastSighting(root, now) {
43
+ const none = "No confirmed sightings here yet. `ssqch build` would be the first.";
43
44
  let list;
44
45
  try {
45
46
  list = JSON.parse(fs.readFileSync(path.join(root, OUTPUT_LIST), "utf8")) ?? {};
@@ -61,17 +62,17 @@ function lastSiting(root, now) {
61
62
  const minutes = Math.max(0, Math.floor((now - newest) / 6e4));
62
63
  const unit = (n, name) => `${n} ${name}${n === 1 ? "" : "s"} ago`;
63
64
  const ago = minutes === 0 ? "just now" : minutes < 60 ? unit(minutes, "minute") : minutes < 1440 ? unit(Math.floor(minutes / 60), "hour") : unit(Math.floor(minutes / 1440), "day");
64
- return `Last confirmed siting: ${count(pages.length)} page${pages.length === 1 ? "" : "s"} in ${output}/, ${ago}.`;
65
+ return `Last confirmed sighting: ${count(pages.length)} page${pages.length === 1 ? "" : "s"} in ${output}/, ${ago}.`;
65
66
  }
66
67
  function runSighting(root) {
67
68
  process.stdout.write(`${PHOTO}
68
69
  Image quality meets cryptozoological standards.
69
70
 
70
- ${lastSiting(root, Date.now())}
71
+ ${lastSighting(root, Date.now())}
71
72
  `);
72
73
  return 0;
73
74
  }
74
75
  export {
75
- lastSiting,
76
+ lastSighting,
76
77
  runSighting
77
78
  };
@@ -2,7 +2,7 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  BuildError
5
- } from "./chunk-R7PBREXL.js";
5
+ } from "./chunk-YNJNMQWU.js";
6
6
  import {
7
7
  realPath
8
8
  } from "./chunk-VJWQSYEG.js";
@@ -15,7 +15,7 @@ import os from "node:os";
15
15
  import { registerHooks } from "node:module";
16
16
  import { fileURLToPath, pathToFileURL } from "node:url";
17
17
  var SELF = path.dirname(path.dirname(fileURLToPath(new URL("../src/modules.ts", import.meta.url).href)));
18
- var BUILT_IN = ["ssqch/image", "ssqch/rss", "ssqch/assets", "ssqch/links", "ssqch/sitemap", "ssqch/redirects", "ssqch/sass", "ssqch/elements", "ssqch/minify", "ssqch/llms", "ssqch/vue"];
18
+ var BUILT_IN = ["ssqch/image", "ssqch/rss", "ssqch/assets", "ssqch/links", "ssqch/sitemap", "ssqch/redirects", "ssqch/sass", "ssqch/elements", "ssqch/minify", "ssqch/llms", "ssqch/vue", "ssqch/robots", "ssqch/from-vitepress", "ssqch/from-mkdocs", "ssqch/from-jekyll", "ssqch/from-hugo"];
19
19
  var COMPILED = fs.existsSync(path.join(SELF, "lib", "ssqch.js"));
20
20
  var API = COMPILED ? pathToFileURL(path.join(SELF, "lib", "ssqch.js")).href : new URL("./exports/ssqch.ts", new URL("../src/modules.ts", import.meta.url).href).href;
21
21
  var builtInUrl = (specifier) => COMPILED ? pathToFileURL(path.join(SELF, "lib", `${specifier.slice(6)}.js`)) : new URL(`./exports/${specifier.slice(6)}.ts`, new URL("../src/modules.ts", import.meta.url).href);
@@ -2,7 +2,7 @@ import { createRequire as __ssqchCreateRequire } from "node:module";
2
2
  const require = __ssqchCreateRequire(import.meta.url);
3
3
  import {
4
4
  Options
5
- } from "./chunk-MOLTDO5A.js";
5
+ } from "./chunk-SNQOHNXE.js";
6
6
  import {
7
7
  BUILTINS,
8
8
  addImagePlugin,
@@ -11,10 +11,10 @@ import {
11
11
  imageOptionsFor,
12
12
  meant,
13
13
  parseFormat
14
- } from "./chunk-DOHOKUGB.js";
14
+ } from "./chunk-VILOEVK7.js";
15
15
  import {
16
16
  bail
17
- } from "./chunk-R7PBREXL.js";
17
+ } from "./chunk-YNJNMQWU.js";
18
18
 
19
19
  // src/modules/image.ts
20
20
  import fs from "node:fs";