ssqch 0.7.1 → 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.
Files changed (155) hide show
  1. package/README.md +8 -4
  2. package/bin/ssqch.js +14 -48
  3. package/bundled/README.md +1314 -0
  4. package/bundled/completions/bash +840 -0
  5. package/bundled/completions/elvish +286 -0
  6. package/bundled/completions/fish +182 -0
  7. package/bundled/completions/powershell +318 -0
  8. package/bundled/completions/zsh +510 -0
  9. package/bundled/ssqch.d.ts +540 -0
  10. package/bundled/starter/engines/index.edge +11 -0
  11. package/bundled/starter/engines/index.ejs +11 -0
  12. package/bundled/starter/engines/index.hbs +11 -0
  13. package/bundled/starter/engines/index.liquid +11 -0
  14. package/bundled/starter/engines/layout.edge +35 -0
  15. package/bundled/starter/engines/layout.ejs +35 -0
  16. package/bundled/starter/engines/layout.hbs +35 -0
  17. package/bundled/starter/engines/layout.liquid +35 -0
  18. package/bundled/starter/gitignore +3 -0
  19. package/bundled/starter/jsconfig.json +11 -0
  20. package/bundled/starter/src/404.md +8 -0
  21. package/bundled/starter/src/_blueprints/posts.md +5 -0
  22. package/bundled/starter/src/_data/site.json +4 -0
  23. package/bundled/starter/src/_includes/layout.jinja +35 -0
  24. package/bundled/starter/src/index.jinja +11 -0
  25. package/bundled/starter/src/posts/i-know-what-i-saw.md +11 -0
  26. package/bundled/starter/src/posts/posts.json +4 -0
  27. package/bundled/starter/src/posts/raiders-of-the-lost-path.md +27 -0
  28. package/bundled/starter/src/posts/the-cache-of-the-wild.md +26 -0
  29. package/bundled/starter/src/posts/the-stump-has-moved.md +15 -0
  30. package/bundled/starter/src/posts/upon-further-review-a-stump.md +18 -0
  31. package/bundled/starter/ssqch.config.js +29 -0
  32. package/bundled/starter-docs/engines/edge/base.edge +41 -0
  33. package/bundled/starter-docs/engines/edge/containers/details.edge +5 -0
  34. package/bundled/starter-docs/engines/edge/containers/tab.edge +4 -0
  35. package/bundled/starter-docs/engines/edge/containers/tabs.edge +5 -0
  36. package/bundled/starter-docs/engines/edge/doc.edge +59 -0
  37. package/bundled/starter-docs/engines/edge/hooks/heading.edge +2 -0
  38. package/bundled/starter-docs/engines/ejs/base.ejs +41 -0
  39. package/bundled/starter-docs/engines/ejs/containers/details.ejs +5 -0
  40. package/bundled/starter-docs/engines/ejs/containers/tab.ejs +4 -0
  41. package/bundled/starter-docs/engines/ejs/containers/tabs.ejs +5 -0
  42. package/bundled/starter-docs/engines/ejs/doc.ejs +59 -0
  43. package/bundled/starter-docs/engines/ejs/hooks/heading.ejs +2 -0
  44. package/bundled/starter-docs/engines/hbs/base.hbs +41 -0
  45. package/bundled/starter-docs/engines/hbs/containers/details.hbs +5 -0
  46. package/bundled/starter-docs/engines/hbs/containers/tab.hbs +4 -0
  47. package/bundled/starter-docs/engines/hbs/containers/tabs.hbs +5 -0
  48. package/bundled/starter-docs/engines/hbs/doc.hbs +58 -0
  49. package/bundled/starter-docs/engines/hbs/hooks/heading.hbs +2 -0
  50. package/bundled/starter-docs/engines/liquid/base.liquid +41 -0
  51. package/bundled/starter-docs/engines/liquid/containers/details.liquid +5 -0
  52. package/bundled/starter-docs/engines/liquid/containers/tab.liquid +4 -0
  53. package/bundled/starter-docs/engines/liquid/containers/tabs.liquid +5 -0
  54. package/bundled/starter-docs/engines/liquid/doc.liquid +60 -0
  55. package/bundled/starter-docs/engines/liquid/hooks/heading.liquid +2 -0
  56. package/bundled/starter-docs/gitignore +4 -0
  57. package/bundled/starter-docs/src/404.md +12 -0
  58. package/bundled/starter-docs/src/_blueprints/docs.md +5 -0
  59. package/bundled/starter-docs/src/_data/nav.yml +10 -0
  60. package/bundled/starter-docs/src/_data/site.json +5 -0
  61. package/bundled/starter-docs/src/_includes/base.jinja +41 -0
  62. package/bundled/starter-docs/src/_includes/containers/details.jinja +5 -0
  63. package/bundled/starter-docs/src/_includes/containers/tab.jinja +4 -0
  64. package/bundled/starter-docs/src/_includes/containers/tabs.jinja +5 -0
  65. package/bundled/starter-docs/src/_includes/doc.jinja +59 -0
  66. package/bundled/starter-docs/src/_includes/hooks/heading.jinja +2 -0
  67. package/bundled/starter-docs/src/assets/docs.css +257 -0
  68. package/bundled/starter-docs/src/assets/docs.js +67 -0
  69. package/bundled/starter-docs/src/docs/docs.json +1 -0
  70. package/bundled/starter-docs/src/docs/guides/deploying.md +77 -0
  71. package/bundled/starter-docs/src/docs/guides/writing.md +65 -0
  72. package/bundled/starter-docs/src/docs/index.md +29 -0
  73. package/bundled/starter-docs/src/docs/install.md +42 -0
  74. package/bundled/starter-docs/src/index.md +13 -0
  75. package/bundled/starter-docs/ssqch.config.js +40 -0
  76. package/bundled/trailheads/from-component-frameworks.md +116 -0
  77. package/bundled/trailheads/from-docusaurus.md +55 -0
  78. package/bundled/trailheads/from-eleventy.md +140 -0
  79. package/bundled/trailheads/from-hexo.md +92 -0
  80. package/bundled/trailheads/from-jekyll.md +79 -0
  81. package/bundled/trailheads/from-mkdocs.md +45 -0
  82. package/bundled/trailheads/from-zola.md +71 -0
  83. package/lib/assets.js +235 -3
  84. package/lib/chunk-3A647I3N.js +384 -0
  85. package/lib/chunk-3GYLOC6Y.js +1017 -0
  86. package/lib/chunk-3K3ANWZ2.js +118 -0
  87. package/lib/chunk-3NYSSA2C.js +22 -0
  88. package/lib/chunk-47P4YREZ.js +1287 -0
  89. package/lib/chunk-4Q6WMTER.js +32 -0
  90. package/lib/chunk-76NTVE34.js +338 -0
  91. package/lib/chunk-7PWCYHTJ.js +1350 -0
  92. package/lib/chunk-7RDRZHJD.js +217 -0
  93. package/lib/chunk-7SD7K567.js +57 -0
  94. package/lib/chunk-7XLK2GEG.js +54 -0
  95. package/lib/chunk-AD3HAW3W.js +10 -0
  96. package/lib/chunk-BEGC7YP6.js +502 -0
  97. package/lib/chunk-CMUWRPSQ.js +113 -0
  98. package/lib/chunk-CZ4XQC56.js +999 -0
  99. package/lib/chunk-D2XE2GTY.js +71 -0
  100. package/lib/chunk-DDV6JEC2.js +46 -0
  101. package/lib/chunk-DELWRJAO.js +37409 -0
  102. package/lib/chunk-DELWRJAO.js.LEGAL.txt +27 -0
  103. package/lib/chunk-F65YUXZ7.js +334 -0
  104. package/lib/chunk-FVZ5JBRI.js +115 -0
  105. package/lib/chunk-GRWMGC7D.js +4435 -0
  106. package/lib/chunk-GRWMGC7D.js.LEGAL.txt +41 -0
  107. package/lib/chunk-GUKSZ2XM.js +207 -0
  108. package/lib/chunk-HPXAZ2HU.js +251 -0
  109. package/lib/chunk-HXCLCXRT.js +20 -0
  110. package/lib/chunk-I3PS26CI.js +48 -0
  111. package/lib/chunk-IAFM5ITE.js +11 -0
  112. package/lib/chunk-II5DEH3Q.js +209 -0
  113. package/lib/chunk-IJWHOFRP.js +44 -0
  114. package/lib/chunk-LPHNACE4.js +29 -0
  115. package/lib/chunk-MI6EJWA2.js +175 -0
  116. package/lib/chunk-NCWFYT74.js +1541 -0
  117. package/lib/chunk-NKXEPHRZ.js +136 -0
  118. package/lib/chunk-NNUKIGOO.js +160 -0
  119. package/lib/chunk-R7K3D5W5.js +3957 -0
  120. package/lib/chunk-RNJFPFXE.js +29 -0
  121. package/lib/chunk-SF4I6Z7S.js +25 -0
  122. package/lib/chunk-SURPOAW7.js +44 -0
  123. package/lib/chunk-SXMJ52IK.js +572 -0
  124. package/lib/chunk-TICWN55Z.js +20 -0
  125. package/lib/chunk-TVU3OPPK.js +146 -0
  126. package/lib/chunk-UU43WIZG.js +29 -0
  127. package/lib/chunk-VJWQSYEG.js +119 -0
  128. package/lib/chunk-XMXBHXZR.js +75 -0
  129. package/lib/chunk-YTHQBMDJ.js +211 -0
  130. package/lib/cli.js +547 -0
  131. package/lib/elements.js +180 -3
  132. package/lib/image.js +27 -3
  133. package/lib/links.js +464 -3
  134. package/lib/minify.js +69 -3
  135. package/lib/redirects.js +152 -3
  136. package/lib/rss.js +139 -3
  137. package/lib/sass.js +256 -3
  138. package/lib/sitemap.js +113 -3
  139. package/lib/ssqch.js +28 -0
  140. package/package.json +83 -80
  141. package/src/serve/live.js +174 -0
  142. package/src/serve/not-found.html +31 -0
  143. package/types/globals.d.ts +3 -2
  144. package/types/image.d.ts +7 -3
  145. package/types/index.d.ts +28 -9
  146. package/types/links.d.ts +1 -1
  147. package/types/minify.d.ts +1 -1
  148. package/types/rss.d.ts +1 -1
  149. package/types/sass.d.ts +1 -1
  150. package/types/sitemap.d.ts +2 -0
  151. package/wasm/markdown.wasm +0 -0
  152. package/wasm/minify.wasm +0 -0
  153. package/wasm/sass.wasm +0 -0
  154. package/lib/index.js +0 -3
  155. package/platforms.json +0 -6
@@ -0,0 +1,29 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ buildFiles,
5
+ footprintJson,
6
+ footprintText,
7
+ kindOf,
8
+ measure,
9
+ overBudget,
10
+ urlOf
11
+ } from "./chunk-II5DEH3Q.js";
12
+ import "./chunk-7XLK2GEG.js";
13
+ import "./chunk-NKXEPHRZ.js";
14
+ import "./chunk-DDV6JEC2.js";
15
+ import "./chunk-FVZ5JBRI.js";
16
+ import "./chunk-UU43WIZG.js";
17
+ import "./chunk-CMUWRPSQ.js";
18
+ import "./chunk-GRWMGC7D.js";
19
+ import "./chunk-VJWQSYEG.js";
20
+ import "./chunk-I3PS26CI.js";
21
+ export {
22
+ buildFiles,
23
+ footprintJson,
24
+ footprintText,
25
+ kindOf,
26
+ measure,
27
+ overBudget,
28
+ urlOf
29
+ };
@@ -0,0 +1,25 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ DEFAULT_ENGINE,
5
+ ENGINES,
6
+ STARTERS,
7
+ agentsMd,
8
+ runInit,
9
+ starterEngines,
10
+ starterFiles,
11
+ write
12
+ } from "./chunk-YTHQBMDJ.js";
13
+ import "./chunk-GRWMGC7D.js";
14
+ import "./chunk-VJWQSYEG.js";
15
+ import "./chunk-I3PS26CI.js";
16
+ export {
17
+ DEFAULT_ENGINE,
18
+ ENGINES,
19
+ STARTERS,
20
+ agentsMd,
21
+ runInit,
22
+ starterEngines,
23
+ starterFiles,
24
+ write
25
+ };
@@ -0,0 +1,44 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ BUILTINS,
5
+ DEFAULTS,
6
+ configOptions,
7
+ findConfig,
8
+ loadConfig,
9
+ meant,
10
+ tomlKeyLine
11
+ } from "./chunk-R7K3D5W5.js";
12
+ import "./chunk-7XLK2GEG.js";
13
+ import "./chunk-NKXEPHRZ.js";
14
+ import "./chunk-AD3HAW3W.js";
15
+ import {
16
+ CONFIG_FILES,
17
+ dirsOf,
18
+ parseEnvironment,
19
+ shownDir,
20
+ shownOutput
21
+ } from "./chunk-DDV6JEC2.js";
22
+ import "./chunk-NCWFYT74.js";
23
+ import "./chunk-FVZ5JBRI.js";
24
+ import "./chunk-HPXAZ2HU.js";
25
+ import "./chunk-UU43WIZG.js";
26
+ import "./chunk-76NTVE34.js";
27
+ import "./chunk-CMUWRPSQ.js";
28
+ import "./chunk-GRWMGC7D.js";
29
+ import "./chunk-VJWQSYEG.js";
30
+ import "./chunk-I3PS26CI.js";
31
+ export {
32
+ BUILTINS,
33
+ CONFIG_FILES,
34
+ DEFAULTS,
35
+ configOptions,
36
+ dirsOf,
37
+ findConfig,
38
+ loadConfig,
39
+ meant,
40
+ parseEnvironment,
41
+ shownDir,
42
+ shownOutput,
43
+ tomlKeyLine
44
+ };
@@ -0,0 +1,572 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ modules
5
+ } from "./chunk-3K3ANWZ2.js";
6
+ import {
7
+ BUILTIN_FILTERS
8
+ } from "./chunk-3A647I3N.js";
9
+ import {
10
+ longHelp
11
+ } from "./chunk-F65YUXZ7.js";
12
+ import {
13
+ agentsMd,
14
+ bundled,
15
+ bundledNames,
16
+ types
17
+ } from "./chunk-YTHQBMDJ.js";
18
+ import {
19
+ configOptions
20
+ } from "./chunk-R7K3D5W5.js";
21
+ import "./chunk-7XLK2GEG.js";
22
+ import "./chunk-NKXEPHRZ.js";
23
+ import {
24
+ VERSION
25
+ } from "./chunk-AD3HAW3W.js";
26
+ import "./chunk-DDV6JEC2.js";
27
+ import "./chunk-NCWFYT74.js";
28
+ import {
29
+ closest
30
+ } from "./chunk-FVZ5JBRI.js";
31
+ import "./chunk-HPXAZ2HU.js";
32
+ import "./chunk-UU43WIZG.js";
33
+ import "./chunk-76NTVE34.js";
34
+ import "./chunk-CMUWRPSQ.js";
35
+ import {
36
+ OTHER_CONFIGS,
37
+ TABLE,
38
+ red,
39
+ toJson
40
+ } from "./chunk-GRWMGC7D.js";
41
+ import "./chunk-VJWQSYEG.js";
42
+ import "./chunk-I3PS26CI.js";
43
+
44
+ // src/commands/docs.ts
45
+ var GUIDES_URL = "https://github.com/reverentgeek/sitesquatch/blob";
46
+ var byteLength = (text) => Buffer.byteLength(text);
47
+ var ALNUM = /[\p{Alphabetic}\p{N}]/u;
48
+ var IMAGE_LINE = /^\s*(<p\b[^>]*>\s*)?<img\b[^>]*>(\s*<\/p>)?\s*$/i;
49
+ function sections(readme = bundled("README.md")) {
50
+ const out = [];
51
+ let fence = null;
52
+ for (const line of readme.split(/\r?\n/)) {
53
+ const trimmed = line.trimStart();
54
+ const marker = ["```", "~~~"].find((m) => trimmed.startsWith(m));
55
+ if (marker !== void 0) {
56
+ if (fence === null) fence = marker;
57
+ else if (fence === marker && trimmed.trimEnd().replace(new RegExp(`^\\${marker[0]}+`), "") === "") fence = null;
58
+ }
59
+ if (fence === null && marker === void 0 && IMAGE_LINE.test(line)) continue;
60
+ const hashes = line.length - line.replace(/^#+/, "").length;
61
+ if (fence === null && marker === void 0 && hashes >= 1 && hashes <= 4 && line[hashes] === " ") {
62
+ out.push({ level: hashes, title: line.slice(hashes).trim(), body: "" });
63
+ continue;
64
+ }
65
+ const last = out[out.length - 1];
66
+ if (last) last.body += line + "\n";
67
+ }
68
+ for (const section of out) section.body = section.body.replace(/^\n+|\n+$/g, "");
69
+ return out;
70
+ }
71
+ function children(all, i) {
72
+ const level = all[i].level;
73
+ const out = [];
74
+ for (let j = i + 1; j < all.length; j++) {
75
+ if (all[j].level <= level) break;
76
+ if (all[j].level === level + 1) out.push(j);
77
+ }
78
+ return out;
79
+ }
80
+ function firstSentence(text) {
81
+ let inCode = false;
82
+ let colon;
83
+ for (let i = 0; i < text.length; i++) {
84
+ const c = text[i];
85
+ if (c === "`") inCode = !inCode;
86
+ if (c === ":" && !inCode && colon === void 0 && text[i + 1] === " ") colon = i;
87
+ if (c === "." && !inCode && text[i + 1] === " ") {
88
+ const sentence = text.slice(0, i + 1);
89
+ return colon !== void 0 && byteLength(sentence) > 100 && byteLength(text.slice(0, colon)) > 25 ? `${text.slice(0, colon)}.` : sentence;
90
+ }
91
+ }
92
+ return colon !== void 0 && byteLength(text) > 100 && byteLength(text.slice(0, colon)) > 25 ? `${text.slice(0, colon)}.` : text;
93
+ }
94
+ function typedNames(dts = types()) {
95
+ const out = [];
96
+ let module = "", iface = "", doc = "", inDoc = false;
97
+ for (const line of dts.split(/\r?\n/)) {
98
+ const t = line.trim();
99
+ if (inDoc) {
100
+ if (t.startsWith("*/")) inDoc = false;
101
+ else doc += " " + t.replace(/^\*+/, "").trim();
102
+ continue;
103
+ }
104
+ if (t.startsWith("/**")) {
105
+ const rest = t.slice(3);
106
+ if (rest.endsWith("*/")) doc = rest.slice(0, -2).trim();
107
+ else {
108
+ doc = rest.trim();
109
+ inDoc = true;
110
+ }
111
+ continue;
112
+ }
113
+ let m;
114
+ if (line.startsWith('declare module "')) {
115
+ module = line.slice(16).split('"')[0];
116
+ } else if (m = /^\texport interface (\w+)/.exec(line)) {
117
+ iface = m[1];
118
+ } else if (line === " }") {
119
+ iface = "";
120
+ } else if (m = /^\texport function (\w+)/.exec(line)) {
121
+ if (!out.some((n) => n.name === m[1] && n.module === module)) out.push({ name: m[1], kind: "module export", module, summary: doc.trim() });
122
+ } else if (m = /^\t\t(\w+)\??:/.exec(line)) {
123
+ if (module === "ssqch" && (iface === "Config" || iface === "ConfigParts") && !out.some((n) => n.name === m[1] && n.kind === "config option")) {
124
+ out.push({ name: m[1], kind: "config option", module: null, summary: doc.trim() });
125
+ }
126
+ }
127
+ doc = "";
128
+ }
129
+ return out;
130
+ }
131
+ function visibleCommands(grammar) {
132
+ return grammar.commands.filter((c) => !c.hidden);
133
+ }
134
+ function names(grammar) {
135
+ const out = [];
136
+ for (const command of visibleCommands(grammar)) out.push({ name: command.name, kind: "command", module: null, summary: command.about });
137
+ const typed = typedNames();
138
+ for (const option of configOptions()) {
139
+ out.push({ name: option, kind: "config option", module: null, summary: typed.find((n) => n.kind === "config option" && n.name === option)?.summary ?? "" });
140
+ }
141
+ for (const [name, summary] of BUILTIN_FILTERS) out.push({ name, kind: "template function", module: null, summary });
142
+ const have = modules().map((m) => m.name);
143
+ out.push(...typed.filter((n) => n.kind === "module export" && n.module !== null && have.includes(n.module)));
144
+ const flag = (long, help, command) => ({ name: `--${long}`, kind: "flag", module: command, summary: help.replace(/\n/g, " ") });
145
+ out.push(...[...grammar.globals, { long: "help", help: "Print help" }, { long: "version", help: "Print version" }].map((o) => flag(o.long, o.help, null)));
146
+ for (const command of visibleCommands(grammar)) {
147
+ out.push(...[...command.options, { long: "help", help: "Print help" }].map((o) => flag(o.long, o.help, command.name)));
148
+ }
149
+ return out;
150
+ }
151
+ function words(text) {
152
+ return text.toLowerCase().split(/[^\p{Alphabetic}\p{N}]+/u).filter((w) => w !== "");
153
+ }
154
+ function slug(title) {
155
+ let out = "";
156
+ for (const c of title.toLowerCase()) {
157
+ if (ALNUM.test(c) || c === "-" || c === "_") out += c;
158
+ else if (c === " ") out += "-";
159
+ }
160
+ return out;
161
+ }
162
+ var isNameChar = (c) => c !== void 0 && (ALNUM.test(c) || c === "_" || c === "-");
163
+ var charAt = (text, i) => {
164
+ const c = text.codePointAt(i);
165
+ return c === void 0 ? void 0 : String.fromCodePoint(c);
166
+ };
167
+ function mentionsAt(text, name) {
168
+ const needle = `\`${name}`;
169
+ const found = [];
170
+ for (let i = text.indexOf(needle); i !== -1; i = text.indexOf(needle, i + needle.length)) {
171
+ if (!isNameChar(charAt(text, i + needle.length))) found.push(i);
172
+ }
173
+ return found;
174
+ }
175
+ var mentions = (text, name) => mentionsAt(text, name).length;
176
+ function blocks(body) {
177
+ const out = [];
178
+ let current = "";
179
+ let fence = null;
180
+ let header = "";
181
+ const flush = () => {
182
+ if (current.trim() !== "") out.push(current.trimEnd());
183
+ current = "";
184
+ };
185
+ const lines = body.split(/\r?\n/);
186
+ const isSeparator = (l) => l.includes("---") && [...l].every((c) => "|-: ".includes(c));
187
+ for (let n = 0; n < lines.length; n++) {
188
+ const line = lines[n];
189
+ const trimmed = line.trimStart();
190
+ if (fence !== null) {
191
+ current += line + "\n";
192
+ if (trimmed.startsWith(fence) && trimmed.trimEnd().replace(new RegExp(`^\\${fence[0]}+`), "") === "") {
193
+ fence = null;
194
+ flush();
195
+ }
196
+ continue;
197
+ }
198
+ const open = ["```", "~~~"].find((m) => trimmed.startsWith(m));
199
+ if (open !== void 0) {
200
+ flush();
201
+ fence = open;
202
+ current += line + "\n";
203
+ continue;
204
+ }
205
+ if (line.trim() === "") {
206
+ flush();
207
+ header = "";
208
+ continue;
209
+ }
210
+ if (line.startsWith("|")) {
211
+ flush();
212
+ if (isSeparator(line)) continue;
213
+ if (header === "" && n + 1 < lines.length && isSeparator(lines[n + 1])) header = `${line}
214
+ ${lines[n + 1]}
215
+ `;
216
+ else out.push(`${header}${line}`);
217
+ continue;
218
+ }
219
+ const item = trimmed.startsWith("- ") || trimmed.startsWith("* ") || /^\d+\. /.test(trimmed);
220
+ if (item && !line.startsWith(" ")) flush();
221
+ current += line + "\n";
222
+ }
223
+ flush();
224
+ return out;
225
+ }
226
+ function firstMention(block, name) {
227
+ const row = block.split("\n").at(-1) ?? "";
228
+ const text = (block.startsWith("|") ? row : block).replace(/^[|\-* ]+/, "");
229
+ const at = mentionsAt(text, name)[0];
230
+ return at === void 0 ? void 0 : byteLength(text.slice(0, at));
231
+ }
232
+ function leadsWith(block, name) {
233
+ const lead = /^(?:[-*] )?\*\*([^*]+?):?\*\*/.exec(block)?.[1];
234
+ return lead !== void 0 && words(lead).join(" ") === words(name).join(" ");
235
+ }
236
+ function passages(all, name) {
237
+ let best;
238
+ const defining = [];
239
+ all.forEach((s, i) => {
240
+ for (const block2 of blocks(s.body)) {
241
+ const n = mentions(block2, name);
242
+ const leads = leadsWith(block2, name);
243
+ if (n === 0 && !leads) continue;
244
+ const at = firstMention(block2, name);
245
+ const defines = at !== void 0 && at < 60 || leads;
246
+ if (defines) defining.push([i, block2]);
247
+ const score = n + (defines ? 1e3 : 0) + mentions(s.title, name) * 100;
248
+ if (best === void 0 || score > best[1]) best = [i, score, block2];
249
+ }
250
+ });
251
+ if (best === void 0) return void 0;
252
+ const [section, , block] = best;
253
+ let found = defining.filter(([i]) => i === section).map(([, b]) => b).slice(0, 3);
254
+ if (found.length === 0) found = [block];
255
+ return [section, found];
256
+ }
257
+ function also(all, name, not) {
258
+ const found = all.map((s, i) => [i, mentions(s.body, name) + mentions(s.title, name) * 10]).filter(([i, n]) => i !== not && n > 0);
259
+ found.sort((a, b) => b[1] - a[1] || a[0] - b[0]);
260
+ return found.map(([i]) => i).slice(0, 4);
261
+ }
262
+ function heading(all, query) {
263
+ const q = words(query);
264
+ if (q.length === 0) return void 0;
265
+ const anchor = query.replace(/^#+/, "");
266
+ const exact = all.findIndex((s) => words(s.title).join(" ") === q.join(" ") || slug(s.title) === anchor);
267
+ if (exact !== -1) return exact;
268
+ let best;
269
+ all.forEach((s, i) => {
270
+ const title = words(s.title);
271
+ if (q.every((w) => title.some((t) => t.startsWith(w))) && (best === void 0 || byteLength(s.title) < byteLength(all[best].title))) best = i;
272
+ });
273
+ return best;
274
+ }
275
+ function search(all, query) {
276
+ const q = words(query);
277
+ const found = [];
278
+ all.forEach((s, i) => {
279
+ const title = words(s.title);
280
+ for (const block of blocks(s.body)) {
281
+ const text = words(block);
282
+ const hits = q.map((w) => [...text, ...title].filter((t) => t.startsWith(w)).length);
283
+ if (hits.every((n) => n > 0)) {
284
+ const labelEnd = block.startsWith("**") ? block.indexOf(":**") : -1;
285
+ const label = labelEnd === -1 ? [] : words(block.slice(2, labelEnd));
286
+ const labeled = q.every((w) => label.some((t) => t.startsWith(w)));
287
+ const score = Math.floor(hits.reduce((a, b) => a + b, 0) * 1e5 / (byteLength(block) + 400)) + (labeled ? 1e6 : 0);
288
+ found.push([i, block, score]);
289
+ }
290
+ }
291
+ });
292
+ found.sort((a, b) => b[2] - a[2] || a[0] - b[0]);
293
+ return found.map(([i, block]) => [i, block]);
294
+ }
295
+ function foreign(query) {
296
+ return TABLE.find((e) => e.word === query || e.kind === "global" && query.startsWith(e.word) || e.kind === "global" && e.word.replace(/\.+$/, "") === query);
297
+ }
298
+ function helpOf(grammar, command) {
299
+ const found = grammar.commands.find((c) => c.name === command);
300
+ return found && longHelp(grammar, found).trimEnd();
301
+ }
302
+ function answer(grammar, all, known, rawQuery) {
303
+ let query = rawQuery.trim();
304
+ if (query.startsWith("ssqch ")) query = query.slice(6);
305
+ query = query.trim();
306
+ if (query === "") return void 0;
307
+ const blank = { query, names: [], passages: [], also: [] };
308
+ const matching = known.filter((n) => n.name === query || n.kind === "command" && n.name.toLowerCase() === query.toLowerCase());
309
+ if (matching.length) {
310
+ const command = matching.find((n) => n.kind === "command");
311
+ const help = command && helpOf(grammar, command.name);
312
+ const others2 = matching.some((n) => n.kind !== "command");
313
+ const a = { ...blank, names: matching, help };
314
+ const found = others2 ? passages(all, query) : void 0;
315
+ if (found) {
316
+ a.also = also(all, query, found[0]);
317
+ a.section = found[0];
318
+ a.passages = found[1];
319
+ }
320
+ return a;
321
+ }
322
+ const e = foreign(query);
323
+ if (e) {
324
+ const more = e.more.startsWith("ssqch docs ") ? e.more.slice(11).replace(/^"+|"+$/g, "") : void 0;
325
+ const a = (more !== void 0 && more !== query ? answer(grammar, all, known, more) : void 0) ?? blank;
326
+ return { ...a, equivalent: e, query };
327
+ }
328
+ const i = heading(all, query);
329
+ if (i !== void 0) return { ...blank, section: i };
330
+ const bare = query.replace(/^`+|`+$/g, "");
331
+ if (!/\s/.test(bare)) {
332
+ const found = passages(all, bare);
333
+ if (found) return { ...blank, also: also(all, bare, found[0]), section: found[0], passages: found[1] };
334
+ }
335
+ const hits = search(all, query);
336
+ if (hits.length === 0) return void 0;
337
+ const [section, block] = hits[0];
338
+ const others = [];
339
+ for (const [j] of hits) if (j !== section && !others.includes(j)) others.push(j);
340
+ return { ...blank, section, passages: [block], also: others.slice(0, 4) };
341
+ }
342
+ function closestName(all, known, query) {
343
+ return closest(query, [...known.map((n) => n.name), ...all.map((s) => s.title), ...TABLE.map((e) => e.word)]);
344
+ }
345
+ function what(name) {
346
+ if (name.kind === "flag") return name.module !== null ? `\`${name.name}\` (flag of ssqch ${name.module})` : `\`${name.name}\` (flag of every command)`;
347
+ return name.module !== null ? `\`${name.name}\` (from "${name.module}")` : `\`${name.name}\` (${name.kind})`;
348
+ }
349
+ function sectionText(all, i) {
350
+ const s = all[i];
351
+ let out = `${"#".repeat(Math.max(s.level, 2))} ${s.title}
352
+ `;
353
+ if (s.body !== "") out += `
354
+ ${s.body}
355
+ `;
356
+ const inside = children(all, i);
357
+ if (inside.length) out += `
358
+ In this section (ssqch docs "<title>"): ${inside.map((j) => `"${all[j].title}"`).join(", ")}
359
+ `;
360
+ return out;
361
+ }
362
+ function answerText(all, a) {
363
+ let out = "";
364
+ if (a.equivalent) {
365
+ const e = a.equivalent;
366
+ const from2 = e.from.length === 1 ? ` (${e.from[0]})` : "";
367
+ out += `\`${e.word.replace(/\.+$/, "")}\`${from2} ${e.alias ? "works in ssqch too" : "isn't ssqch's word"}. ${e.say}
368
+
369
+ `;
370
+ }
371
+ if (a.help !== void 0) out += `${a.help}
372
+
373
+ `;
374
+ const described = a.names.filter((n) => n.kind !== "command" || a.help === void 0);
375
+ for (const name of described) out += `${what(name)}: ${name.summary}
376
+ `;
377
+ if (described.length) out += "\n";
378
+ if (a.section !== void 0 && a.passages.length) {
379
+ out += `From "${all[a.section].title}" (ssqch docs "${all[a.section].title}"):
380
+
381
+ ${a.passages.join("\n\n")}
382
+ `;
383
+ } else if (a.section !== void 0) {
384
+ out += sectionText(all, a.section);
385
+ } else if (a.help === void 0 && a.equivalent) {
386
+ out += `More: ${a.equivalent.more}
387
+ `;
388
+ }
389
+ if (a.also.length) out += `
390
+ Also in: ${a.also.map((j) => `"${all[j].title}"`).join(", ")}
391
+ `;
392
+ return out.trimEnd() + "\n";
393
+ }
394
+ function answerJson(all, a) {
395
+ const out = { query: a.query, found: true };
396
+ if (a.names.length) out.names = a.names.map((n) => ({ name: n.name, kind: n.kind, module: n.module, summary: n.summary }));
397
+ if (a.equivalent) out.equivalent = { ...toJson(a.equivalent), say: a.equivalent.say };
398
+ if (a.help !== void 0) out.help = a.help;
399
+ if (a.section !== void 0) {
400
+ const s = all[a.section];
401
+ out.section = { title: s.title, anchor: slug(s.title), whole: a.passages.length === 0, text: a.passages.length === 0 ? s.body : a.passages.join("\n\n"), sections: children(all, a.section).map((j) => all[j].title) };
402
+ }
403
+ if (a.also.length) out.also = a.also.map((j) => all[j].title);
404
+ return out;
405
+ }
406
+ function card(all, known) {
407
+ let out = `ssqch ${VERSION}. \`ssqch docs <name>\` for one, \`ssqch docs --from <generator>\` for another generator's words, \`ssqch docs agents\` for an AGENTS.md.
408
+ `;
409
+ const group = (title, rows, indent) => {
410
+ if (rows.length === 0) return;
411
+ if (title !== "") out += `
412
+ ${title}
413
+ `;
414
+ const width = Math.max(...rows.map(([n]) => n.length));
415
+ for (const [name, summary] of rows) out += `${" ".repeat(indent)}${name.padEnd(width)} ${firstSentence(summary)}
416
+ `;
417
+ };
418
+ const of = (kind) => known.filter((n) => n.kind === kind).map((n) => [n.name, n.summary]);
419
+ group("Commands", of("command"), 2);
420
+ group("Config options (ssqch.config.js)", of("config option"), 2);
421
+ group("Template functions", of("template function"), 2);
422
+ const mods = [];
423
+ for (const n of known.filter((n2) => n2.kind === "module export")) if (n.module !== null && !mods.includes(n.module)) mods.push(n.module);
424
+ out += '\nModules (import { name } from "module")\n';
425
+ for (const module of mods) {
426
+ const rows = known.filter((n) => n.module === module && n.kind === "module export");
427
+ const width = Math.max(...rows.map((n) => n.name.length));
428
+ out += ` ${module}
429
+ `;
430
+ for (const n of rows) out += ` ${n.name.padEnd(width)} ${firstSentence(n.summary)}
431
+ `;
432
+ }
433
+ out += `
434
+ Topics
435
+ ${all.filter((s) => s.level === 2).map((s) => s.title).join(", ")}
436
+ `;
437
+ return out;
438
+ }
439
+ function cardJson(all, known) {
440
+ const rows = (kind) => known.filter((n) => n.kind === kind).map((n) => ({ name: n.name, summary: n.summary }));
441
+ const mods = [];
442
+ for (const n of known.filter((n2) => n2.kind === "module export")) {
443
+ const module = n.module ?? "";
444
+ const row = { name: n.name, summary: n.summary };
445
+ const found = mods.find((m) => m.name === module);
446
+ if (found) found.exports.push(row);
447
+ else mods.push({ name: module, exports: [row] });
448
+ }
449
+ return { version: VERSION, commands: rows("command"), configOptions: rows("config option"), templateFunctions: rows("template function"), modules: mods, topics: all.filter((s) => s.level === 2).map((s) => s.title) };
450
+ }
451
+ function generators() {
452
+ const out = [];
453
+ for (const g of [...TABLE.flatMap((e) => e.from), ...OTHER_CONFIGS.map(([, generator]) => generator)]) {
454
+ if (!out.includes(g)) out.push(g);
455
+ }
456
+ return out;
457
+ }
458
+ function nextStep(grammar, all, known, query) {
459
+ const ws = query.split(/[^\p{Alphabetic}\p{N}.-]+/u).filter((w) => w !== "");
460
+ const list = generators();
461
+ for (const w of ws) {
462
+ const generator = list.find((g) => g.toLowerCase() === w.toLowerCase() || g.replace(/\./g, "").toLowerCase() === w.toLowerCase());
463
+ if (generator) return `ssqch docs --from ${generator.toLowerCase()}`;
464
+ }
465
+ if (ws.length < 2) return void 0;
466
+ const word = ws.find((w) => known.some((n) => n.name === w) || answer(grammar, all, known, w)?.equivalent !== void 0);
467
+ return word === void 0 ? void 0 : `ssqch docs ${word}`;
468
+ }
469
+ function guide(generator) {
470
+ const configured = OTHER_CONFIGS.find(([, g]) => g === generator)?.[3] ?? null;
471
+ const available = bundledNames("trailheads");
472
+ const file = configured ?? (available.includes(`from-${generator.toLowerCase()}.md`) ? `from-${generator.toLowerCase()}.md` : void 0);
473
+ if (file === void 0) return void 0;
474
+ return { file, text: available.includes(file) ? bundled(`trailheads/${file}`) : null };
475
+ }
476
+ var guideUrl = (file) => `${GUIDES_URL}/v${VERSION}/docs/trailheads/${file}`;
477
+ function from(generator, json) {
478
+ const known = generators();
479
+ const found = known.find((g2) => g2.toLowerCase() === generator.toLowerCase() || g2.replace(/\./g, "").toLowerCase() === generator.toLowerCase());
480
+ if (found === void 0) {
481
+ const near = closest(generator.toLowerCase(), known.map((g2) => g2.toLowerCase()));
482
+ throw new Error(`--from ${generator}: no trailhead for that generator${near ? ` (did you mean \`${near}\`?)` : ""}. There are: ${known.map((g2) => g2.toLowerCase()).join(", ")}`);
483
+ }
484
+ const theirs = TABLE.filter((e) => e.from.includes(found));
485
+ const everyone = TABLE.filter((e) => e.from.length === 0);
486
+ const g = guide(found);
487
+ if (json) {
488
+ const rows2 = (list) => list.map((e) => ({ ...toJson(e), say: e.say }));
489
+ const value = { generator: found, words: rows2(theirs), common: rows2(everyone), trailhead: g ? { file: `docs/trailheads/${g.file}`, url: guideUrl(g.file), text: g.text } : null };
490
+ return JSON.stringify(value, null, 2) + "\n";
491
+ }
492
+ let out = `${found}'s words, and ssqch's names for them. The ones marked (works) are aliases: they do the same as ssqch's name, and say it once. The others are refused with this hint.
493
+ `;
494
+ const kinds = [["command", "Commands"], ["flag", "Flags"], ["config", "Config"], ["frontMatter", "Front matter"], ["filter", "Filters"], ["global", "In templates"]];
495
+ const shown = (e) => {
496
+ const word = e.kind === "global" && e.word.endsWith(".") ? `${e.word}*` : e.word;
497
+ return e.alias ? `${word} (works)` : word;
498
+ };
499
+ const rows = (list) => {
500
+ const width = Math.max(...list.map((e) => shown(e).length));
501
+ return list.map((e) => ` ${shown(e).padEnd(width)} ${e.say}
502
+ `).join("");
503
+ };
504
+ for (const [kind, label] of kinds) {
505
+ const list = theirs.filter((e) => e.kind === kind);
506
+ if (list.length) out += `
507
+ ${label}
508
+ ${rows(list)}`;
509
+ }
510
+ if (everyone.length) out += `
511
+ Words most generators use
512
+ ${rows(everyone)}`;
513
+ if (g && g.text !== null) out += `
514
+ The trailhead (docs/trailheads/${g.file}):
515
+
516
+ ${g.text.trimEnd()}
517
+ `;
518
+ else if (g) out += `
519
+ The trailhead: ${guideUrl(g.file)}
520
+ `;
521
+ else out += "\nThere's no trailhead for it yet; `ssqch docs trailheads` has the general route.\n";
522
+ return out;
523
+ }
524
+ function runDocs(grammar, command) {
525
+ const fail = (message) => {
526
+ process.stderr.write(`${red("error:")} ${message}
527
+ `);
528
+ return 1;
529
+ };
530
+ if (command.format !== "text" && command.format !== "json") return fail(`--format ${command.format}: use text or json`);
531
+ const json = command.format === "json";
532
+ const out = (text) => {
533
+ process.stdout.write(text);
534
+ return 0;
535
+ };
536
+ if (command.from !== void 0) {
537
+ if (command.query.length) return fail(`--from lists one generator's words; leave out \`${command.query.join(" ")}\`, or look it up without --from`);
538
+ try {
539
+ return out(from(command.from, json));
540
+ } catch (e) {
541
+ return fail(e.message);
542
+ }
543
+ }
544
+ const all = sections();
545
+ const known = names(grammar);
546
+ if (command.query.length === 0) return out(json ? JSON.stringify(cardJson(all, known), null, 2) + "\n" : card(all, known));
547
+ const query = command.query.join(" ");
548
+ if (query === "agents") {
549
+ const text = agentsMd();
550
+ return out(json ? JSON.stringify({ query, found: true, agentsMd: text }, null, 2) + "\n" : text);
551
+ }
552
+ const a = answer(grammar, all, known, query);
553
+ if (a) return out(json ? JSON.stringify(answerJson(all, a), null, 2) + "\n" : answerText(all, a));
554
+ const near = closestName(all, known, query);
555
+ const next = near === void 0 ? nextStep(grammar, all, known, query) : void 0;
556
+ if (json) {
557
+ out(JSON.stringify({ query, found: false, didYouMean: near ?? null, tryInstead: next ?? null }, null, 2) + "\n");
558
+ } else {
559
+ const hint = near ? ` (did you mean \`${near}\`?)` : "";
560
+ process.stderr.write(`${red("error:")} no tracks of "${query}" in the docs${hint}. ${next ? `Try \`${next}\`, or \`ssqch docs\` for everything.` : "`ssqch docs` lists everything."}
561
+ `);
562
+ }
563
+ return 1;
564
+ }
565
+ export {
566
+ answer,
567
+ names,
568
+ runDocs,
569
+ sections,
570
+ slug,
571
+ typedNames
572
+ };
@@ -0,0 +1,20 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+ import {
4
+ globBase,
5
+ globProblem,
6
+ globSet,
7
+ globToRegExp,
8
+ isGlob
9
+ } from "./chunk-HPXAZ2HU.js";
10
+ import "./chunk-CMUWRPSQ.js";
11
+ import "./chunk-GRWMGC7D.js";
12
+ import "./chunk-VJWQSYEG.js";
13
+ import "./chunk-I3PS26CI.js";
14
+ export {
15
+ globBase,
16
+ globProblem,
17
+ globSet,
18
+ globToRegExp,
19
+ isGlob
20
+ };