@warlock.js/grimoire 0.0.0-stage → 5.55.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 (211) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/LICENSE +21 -0
  3. package/README.md +55 -2
  4. package/esm/apps/check-apps.mjs +207 -0
  5. package/esm/apps/check-apps.mjs.map +1 -0
  6. package/esm/apps/index.mjs +4 -0
  7. package/esm/apps/match-apps.d.mts +12 -0
  8. package/esm/apps/match-apps.d.mts.map +1 -0
  9. package/esm/apps/match-apps.mjs +30 -0
  10. package/esm/apps/match-apps.mjs.map +1 -0
  11. package/esm/book/build.d.mts +14 -0
  12. package/esm/book/build.d.mts.map +1 -0
  13. package/esm/book/build.mjs +300 -0
  14. package/esm/book/build.mjs.map +1 -0
  15. package/esm/book/index.mjs +5 -0
  16. package/esm/book/io.mjs +162 -0
  17. package/esm/book/io.mjs.map +1 -0
  18. package/esm/book/normalize.mjs +71 -0
  19. package/esm/book/normalize.mjs.map +1 -0
  20. package/esm/book/render.mjs +262 -0
  21. package/esm/book/render.mjs.map +1 -0
  22. package/esm/book/write.d.mts +12 -0
  23. package/esm/book/write.d.mts.map +1 -0
  24. package/esm/book/write.mjs +90 -0
  25. package/esm/book/write.mjs.map +1 -0
  26. package/esm/bookmap/build.d.mts +21 -0
  27. package/esm/bookmap/build.d.mts.map +1 -0
  28. package/esm/bookmap/build.mjs +272 -0
  29. package/esm/bookmap/build.mjs.map +1 -0
  30. package/esm/bookmap/index.mjs +5 -0
  31. package/esm/bookmap/steps.mjs +137 -0
  32. package/esm/bookmap/steps.mjs.map +1 -0
  33. package/esm/bookmap/write.d.mts +19 -0
  34. package/esm/bookmap/write.d.mts.map +1 -0
  35. package/esm/bookmap/write.mjs +118 -0
  36. package/esm/bookmap/write.mjs.map +1 -0
  37. package/esm/check/check-grimoire.d.mts +7 -0
  38. package/esm/check/check-grimoire.d.mts.map +1 -0
  39. package/esm/check/check-grimoire.mjs +98 -0
  40. package/esm/check/check-grimoire.mjs.map +1 -0
  41. package/esm/check/format-check-report.d.mts +20 -0
  42. package/esm/check/format-check-report.d.mts.map +1 -0
  43. package/esm/check/format-check-report.mjs +55 -0
  44. package/esm/check/format-check-report.mjs.map +1 -0
  45. package/esm/check/index.mjs +4 -0
  46. package/esm/check/rules/book-notes.mjs +18 -0
  47. package/esm/check/rules/book-notes.mjs.map +1 -0
  48. package/esm/check/rules/criteria.mjs +48 -0
  49. package/esm/check/rules/criteria.mjs.map +1 -0
  50. package/esm/check/rules/links.mjs +196 -0
  51. package/esm/check/rules/links.mjs.map +1 -0
  52. package/esm/check/rules/lookup.mjs +41 -0
  53. package/esm/check/rules/lookup.mjs.map +1 -0
  54. package/esm/check/rules/source-files.mjs +119 -0
  55. package/esm/check/rules/source-files.mjs.map +1 -0
  56. package/esm/check/rules/versions.mjs +92 -0
  57. package/esm/check/rules/versions.mjs.map +1 -0
  58. package/esm/codes/codes.d.mts +182 -0
  59. package/esm/codes/codes.d.mts.map +1 -0
  60. package/esm/codes/codes.mjs +111 -0
  61. package/esm/codes/codes.mjs.map +1 -0
  62. package/esm/codes/index.d.mts +33 -0
  63. package/esm/codes/index.d.mts.map +1 -0
  64. package/esm/codes/index.mjs +63 -0
  65. package/esm/codes/index.mjs.map +1 -0
  66. package/esm/contracts/adapter.d.mts +209 -0
  67. package/esm/contracts/adapter.d.mts.map +1 -0
  68. package/esm/contracts/book.d.mts +233 -0
  69. package/esm/contracts/book.d.mts.map +1 -0
  70. package/esm/contracts/book.mjs +7 -0
  71. package/esm/contracts/book.mjs.map +1 -0
  72. package/esm/contracts/bookmap.d.mts +175 -0
  73. package/esm/contracts/bookmap.d.mts.map +1 -0
  74. package/esm/contracts/findings.d.mts +79 -0
  75. package/esm/contracts/findings.d.mts.map +1 -0
  76. package/esm/contracts/location.d.mts +22 -0
  77. package/esm/contracts/location.d.mts.map +1 -0
  78. package/esm/contracts/releases.d.mts +53 -0
  79. package/esm/contracts/releases.d.mts.map +1 -0
  80. package/esm/contracts/scry.d.mts +143 -0
  81. package/esm/contracts/scry.d.mts.map +1 -0
  82. package/esm/contracts/snapshot.d.mts +52 -0
  83. package/esm/contracts/snapshot.d.mts.map +1 -0
  84. package/esm/contracts/test-results.d.mts +63 -0
  85. package/esm/contracts/test-results.d.mts.map +1 -0
  86. package/esm/contracts/written.d.mts +363 -0
  87. package/esm/contracts/written.d.mts.map +1 -0
  88. package/esm/contracts/written.mjs +19 -0
  89. package/esm/contracts/written.mjs.map +1 -0
  90. package/esm/devtools/data.mjs +171 -0
  91. package/esm/devtools/data.mjs.map +1 -0
  92. package/esm/devtools/graphs.mjs +142 -0
  93. package/esm/devtools/graphs.mjs.map +1 -0
  94. package/esm/devtools/index.d.mts +35 -0
  95. package/esm/devtools/index.d.mts.map +1 -0
  96. package/esm/devtools/index.mjs +102 -0
  97. package/esm/devtools/index.mjs.map +1 -0
  98. package/esm/devtools/site.d.mts +26 -0
  99. package/esm/devtools/site.d.mts.map +1 -0
  100. package/esm/devtools/site.mjs +190 -0
  101. package/esm/devtools/site.mjs.map +1 -0
  102. package/esm/devtools/snapshot-source.mjs +70 -0
  103. package/esm/devtools/snapshot-source.mjs.map +1 -0
  104. package/esm/front-matter/index.d.mts +33 -0
  105. package/esm/front-matter/index.d.mts.map +1 -0
  106. package/esm/front-matter/index.mjs +130 -0
  107. package/esm/front-matter/index.mjs.map +1 -0
  108. package/esm/graph/index.d.mts +15 -0
  109. package/esm/graph/index.d.mts.map +1 -0
  110. package/esm/graph/index.mjs +42 -0
  111. package/esm/graph/index.mjs.map +1 -0
  112. package/esm/index.d.mts +33 -0
  113. package/esm/index.mjs +33 -0
  114. package/esm/ownership/index.d.mts +8 -0
  115. package/esm/ownership/index.d.mts.map +1 -0
  116. package/esm/ownership/index.mjs +137 -0
  117. package/esm/ownership/index.mjs.map +1 -0
  118. package/esm/paths/index.d.mts +58 -0
  119. package/esm/paths/index.d.mts.map +1 -0
  120. package/esm/paths/index.mjs +137 -0
  121. package/esm/paths/index.mjs.map +1 -0
  122. package/esm/proves/index.mjs +3 -0
  123. package/esm/proves/scan-proofs.d.mts +22 -0
  124. package/esm/proves/scan-proofs.d.mts.map +1 -0
  125. package/esm/proves/scan-proofs.mjs +214 -0
  126. package/esm/proves/scan-proofs.mjs.map +1 -0
  127. package/esm/releases/index.d.mts +29 -0
  128. package/esm/releases/index.d.mts.map +1 -0
  129. package/esm/releases/index.mjs +157 -0
  130. package/esm/releases/index.mjs.map +1 -0
  131. package/esm/scry/format.d.mts +14 -0
  132. package/esm/scry/format.d.mts.map +1 -0
  133. package/esm/scry/format.mjs +193 -0
  134. package/esm/scry/format.mjs.map +1 -0
  135. package/esm/scry/index.mjs +5 -0
  136. package/esm/scry/parse.d.mts +10 -0
  137. package/esm/scry/parse.d.mts.map +1 -0
  138. package/esm/scry/parse.mjs +108 -0
  139. package/esm/scry/parse.mjs.map +1 -0
  140. package/esm/scry/query.d.mts +11 -0
  141. package/esm/scry/query.d.mts.map +1 -0
  142. package/esm/scry/query.mjs +457 -0
  143. package/esm/scry/query.mjs.map +1 -0
  144. package/esm/tasks/index.mjs +116 -0
  145. package/esm/tasks/index.mjs.map +1 -0
  146. package/esm/test-results/criterion-status.d.mts +15 -0
  147. package/esm/test-results/criterion-status.d.mts.map +1 -0
  148. package/esm/test-results/criterion-status.mjs +17 -0
  149. package/esm/test-results/criterion-status.mjs.map +1 -0
  150. package/esm/test-results/index.d.mts +8 -0
  151. package/esm/test-results/index.d.mts.map +1 -0
  152. package/esm/test-results/index.mjs +124 -0
  153. package/esm/test-results/index.mjs.map +1 -0
  154. package/esm/vitest/index.d.mts +15 -0
  155. package/esm/vitest/index.d.mts.map +1 -0
  156. package/esm/vitest/index.mjs +146 -0
  157. package/esm/vitest/index.mjs.map +1 -0
  158. package/esm/warlock/actions.mjs +265 -0
  159. package/esm/warlock/actions.mjs.map +1 -0
  160. package/esm/warlock/adapter.d.mts +28 -0
  161. package/esm/warlock/adapter.d.mts.map +1 -0
  162. package/esm/warlock/adapter.mjs +377 -0
  163. package/esm/warlock/adapter.mjs.map +1 -0
  164. package/esm/warlock/commands.d.mts +15 -0
  165. package/esm/warlock/commands.d.mts.map +1 -0
  166. package/esm/warlock/commands.mjs +199 -0
  167. package/esm/warlock/commands.mjs.map +1 -0
  168. package/esm/warlock/index.d.mts +4 -0
  169. package/esm/warlock/index.mjs +5 -0
  170. package/esm/warlock/mcp-tools.mjs +247 -0
  171. package/esm/warlock/mcp-tools.mjs.map +1 -0
  172. package/esm/warlock/mobile-facts.d.mts +32 -0
  173. package/esm/warlock/mobile-facts.d.mts.map +1 -0
  174. package/esm/warlock/mobile-facts.mjs +185 -0
  175. package/esm/warlock/mobile-facts.mjs.map +1 -0
  176. package/esm/workspace/index.d.mts +11 -0
  177. package/esm/workspace/index.d.mts.map +1 -0
  178. package/esm/workspace/index.mjs +122 -0
  179. package/esm/workspace/index.mjs.map +1 -0
  180. package/esm/written/apps.mjs +227 -0
  181. package/esm/written/apps.mjs.map +1 -0
  182. package/esm/written/features.mjs +400 -0
  183. package/esm/written/features.mjs.map +1 -0
  184. package/esm/written/fields.mjs +173 -0
  185. package/esm/written/fields.mjs.map +1 -0
  186. package/esm/written/index.mjs +3 -0
  187. package/esm/written/lists.mjs +68 -0
  188. package/esm/written/lists.mjs.map +1 -0
  189. package/esm/written/markdown.mjs +173 -0
  190. package/esm/written/markdown.mjs.map +1 -0
  191. package/esm/written/parse-grimoire.d.mts +20 -0
  192. package/esm/written/parse-grimoire.d.mts.map +1 -0
  193. package/esm/written/parse-grimoire.mjs +552 -0
  194. package/esm/written/parse-grimoire.mjs.map +1 -0
  195. package/esm/written/sink.mjs +65 -0
  196. package/esm/written/sink.mjs.map +1 -0
  197. package/esm/written/tasks-releases.mjs +166 -0
  198. package/esm/written/tasks-releases.mjs.map +1 -0
  199. package/llms-full.txt +869 -0
  200. package/llms.txt +15 -0
  201. package/package.json +66 -4
  202. package/skills/backfill-a-grimoire/SKILL.md +128 -0
  203. package/skills/describe-an-app/SKILL.md +162 -0
  204. package/skills/document-a-file/SKILL.md +75 -0
  205. package/skills/index.md +26 -0
  206. package/skills/record-a-change/SKILL.md +139 -0
  207. package/skills/use-the-grimoire/SKILL.md +137 -0
  208. package/skills/write-a-feature/SKILL.md +168 -0
  209. package/ui/grimoire-static.js +136 -0
  210. package/ui/grimoire-view.js +1005 -0
  211. package/ui/grimoire.css +88 -0
@@ -0,0 +1,265 @@
1
+ import { GrimoireError, createFinding, explainGrimoireCode } from "../codes/index.mjs";
2
+ import { projectPath } from "../paths/index.mjs";
3
+ import { parseGrimoire } from "../written/parse-grimoire.mjs";
4
+ import "../written/index.mjs";
5
+ import { loadBook } from "../book/build.mjs";
6
+ import "../book/index.mjs";
7
+ import { openGrimoire, runGrimoire } from "../workspace/index.mjs";
8
+ import { writeRelease } from "../releases/index.mjs";
9
+ import { checkGrimoire } from "../check/check-grimoire.mjs";
10
+ import { formatCheckReport } from "../check/format-check-report.mjs";
11
+ import "../check/index.mjs";
12
+ import { formatScryResult } from "../scry/format.mjs";
13
+ import { parseScryQuery } from "../scry/parse.mjs";
14
+ import { scry } from "../scry/query.mjs";
15
+ import "../scry/index.mjs";
16
+ import path from "node:path";
17
+ import { createHash } from "node:crypto";
18
+ import { readFile, readdir } from "node:fs/promises";
19
+
20
+ //#region ../../packages/grimoire/src/warlock/actions.ts
21
+ /**
22
+ * What `warlock grimoire …` and `warlock scry …` do, as functions that write
23
+ * to an `io` and return the exit code, so specs run them without a process.
24
+ * Loaded lazily by the commands: it pulls in every Grimoire module.
25
+ */
26
+ const plural = (count, word, many = `${word}s`) => `${count} ${count === 1 ? word : many}`;
27
+ /** Print a Grimoire error the way every command does, and return exit code 1. */
28
+ function reportError(io, error) {
29
+ if (error instanceof GrimoireError) {
30
+ io.err(`${error.code} ${error.message}`);
31
+ const fix = explainGrimoireCode(error.code)?.fix;
32
+ if (fix) io.err(` fix: ${fix}`);
33
+ return 1;
34
+ }
35
+ throw error;
36
+ }
37
+ function printJson(io, value) {
38
+ io.out(JSON.stringify(value, null, 2));
39
+ }
40
+ /**
41
+ * Open with fresh routes; when the app does not boot (`GR8002`), open again
42
+ * with the cached ones and return the boot problem as a warning finding.
43
+ */
44
+ async function withFreshRoutes(open) {
45
+ try {
46
+ return {
47
+ value: await open("fresh"),
48
+ bootProblem: null
49
+ };
50
+ } catch (error) {
51
+ if (!(error instanceof GrimoireError) || error.code !== "GR8002") throw error;
52
+ return {
53
+ value: await open("cached"),
54
+ bootProblem: createFinding({
55
+ code: "GR8002",
56
+ message: `${error.message.charAt(0).toLowerCase()}${error.message.slice(1)}`
57
+ })
58
+ };
59
+ }
60
+ }
61
+ /** Whether the book holds route facts already (a `--route` question with none boots once). */
62
+ async function hasRouteFacts(root) {
63
+ return (await loadBook(root))?.facts.routes != null;
64
+ }
65
+ /** sha256 of a project file, `""` when it is missing (the book's boot-cache rule). */
66
+ async function inputHash(root, file) {
67
+ try {
68
+ return createHash("sha256").update(await readFile(path.join(root, ...file.split("/")))).digest("hex");
69
+ } catch {
70
+ return "";
71
+ }
72
+ }
73
+ /** File names whose appearance makes the route facts stale: routes files and named mails, jobs, events, notifications. */
74
+ const BOOT_INPUT = /^(?:routes|.+\.(?:mail|job|event|notification))\.[cm]?[jt]sx?$/;
75
+ /** Every boot-cache candidate under `src/`: a new one makes the route facts stale. */
76
+ async function routesFiles(root, dir = "src") {
77
+ let entries;
78
+ try {
79
+ entries = await readdir(path.join(root, ...dir.split("/")), { withFileTypes: true });
80
+ } catch {
81
+ return [];
82
+ }
83
+ const found = [];
84
+ for (const entry of entries) {
85
+ if (entry.name === "node_modules" || entry.name.startsWith(".")) continue;
86
+ const file = `${dir}/${entry.name}`;
87
+ if (entry.isDirectory()) found.push(...await routesFiles(root, file));
88
+ else if (BOOT_INPUT.test(entry.name) || file.startsWith("src/config/") && /\.[cm]?[jt]sx?$/.test(entry.name)) found.push(file);
89
+ }
90
+ return found;
91
+ }
92
+ /**
93
+ * Whether `build` or `check` will have to boot the app: `force`, no book, no
94
+ * route facts yet, or a route-cache input changed, appeared or went away.
95
+ * Reads files only and never calls the adapter, so it runs before anything
96
+ * is loaded.
97
+ */
98
+ async function needsBoot(root, force) {
99
+ if (force) return true;
100
+ const book = await loadBook(root);
101
+ if (!book || book.facts.routes === null || book.manifest.boot.collectedAt === null) return true;
102
+ const inputs = book.manifest.boot.inputs;
103
+ for (const [file, hash] of Object.entries(inputs)) if (await inputHash(root, file) !== hash) return true;
104
+ return (await routesFiles(root)).some((file) => inputs[file] === void 0);
105
+ }
106
+ /** Whether the app has several sites, whose page routes need `src/config/web.ts` loaded. */
107
+ async function isMultiSite(root) {
108
+ try {
109
+ return (await readdir(path.join(root, "src", "web", "$sites"), { withFileTypes: true })).some((entry) => entry.isDirectory());
110
+ } catch {
111
+ return false;
112
+ }
113
+ }
114
+ function buildSummary(run) {
115
+ const snapshot = run.snapshot;
116
+ const tasks = snapshot.collected.tasksIndex;
117
+ const bookmaps = run.collected.written.filter((file) => file.endsWith("bookmap.json")).length;
118
+ return {
119
+ book: !run.rebuilt && run.book.written.length + run.book.removed.length + run.collected.written.length + run.collected.removed.length === 0 ? "book up to date" : `book ${plural(snapshot.book.facts.files.length, "file")} (${run.book.written.length} written, ${run.book.removed.length} removed), routes ${snapshot.routes}`,
120
+ collected: `features ${snapshot.collected.featuresIndex.features.length} (bookmaps written: ${bookmaps}) tasks ${tasks.open.length - tasks.waiting.length} open, ${tasks.waiting.length} waiting, ${tasks.done.length} done`
121
+ };
122
+ }
123
+ /**
124
+ * The `--out` folder of the static site, project-relative. A folder outside
125
+ * the project, or the project itself (its own `index.html`), is refused.
126
+ */
127
+ function siteFolder(root, out) {
128
+ const folder = projectPath(root, out.trim());
129
+ if (out.trim() === "" || folder === "" || folder === ".." || folder.startsWith("../") || path.isAbsolute(folder)) throw new GrimoireError("GR9006", `--out ${JSON.stringify(out)} is not a folder inside the project. Pass a project-relative folder, like --out public/grimoire.`);
130
+ return folder;
131
+ }
132
+ /** `time 4.2s`, the last line of `build` and `check`. */
133
+ function elapsedLine(started) {
134
+ return `time ${((Date.now() - started) / 1e3).toFixed(1)}s`;
135
+ }
136
+ /** `warlock grimoire build [--force] [--site [--out <dir>]] [--json]`. */
137
+ async function runBuild(context, options = {}) {
138
+ const { root, adapter, io } = context;
139
+ const started = Date.now();
140
+ try {
141
+ const force = options.force === true;
142
+ const outDir = typeof options.out === "string" ? siteFolder(root, options.out) : void 0;
143
+ const { value: run, bootProblem } = await withFreshRoutes((routes) => runGrimoire(root, adapter, {
144
+ routes,
145
+ force
146
+ }));
147
+ let site = null;
148
+ if (options.site === true || typeof options.out === "string") {
149
+ const { exportGrimoireSite } = await import("../devtools/index.mjs");
150
+ site = await exportGrimoireSite(root, {
151
+ adapter,
152
+ snapshot: run.snapshot,
153
+ ...outDir === void 0 ? {} : { outDir }
154
+ });
155
+ }
156
+ if (options.json === true) {
157
+ printJson(io, {
158
+ rebuilt: run.rebuilt,
159
+ changed: run.changed,
160
+ written: [...run.book.written, ...run.collected.written],
161
+ removed: [...run.book.removed, ...run.collected.removed],
162
+ routes: run.snapshot.routes,
163
+ site,
164
+ problems: bootProblem === null ? [] : [bootProblem]
165
+ });
166
+ return 0;
167
+ }
168
+ const summary = buildSummary(run);
169
+ if (bootProblem !== null) {
170
+ io.err(`${bootProblem.code} ${bootProblem.message}`);
171
+ io.err(` fix: ${bootProblem.hint}`);
172
+ }
173
+ io.out(summary.book);
174
+ io.out(summary.collected);
175
+ if (site !== null) io.out(`site ${site}/index.html`);
176
+ io.out(elapsedLine(started));
177
+ return 0;
178
+ } catch (error) {
179
+ return reportError(io, error);
180
+ }
181
+ }
182
+ /** Add a boot problem to a check report as an unexpected warning. */
183
+ function withProblem(report, problem) {
184
+ if (problem === null) return report;
185
+ const firstExpected = report.findings.findIndex((finding) => finding.expected);
186
+ const findings = [...report.findings];
187
+ findings.splice(firstExpected === -1 ? findings.length : firstExpected, 0, problem);
188
+ return {
189
+ ...report,
190
+ findings,
191
+ counts: {
192
+ ...report.counts,
193
+ warnings: report.counts.warnings + 1
194
+ }
195
+ };
196
+ }
197
+ /** `warlock grimoire check [--all] [--json]`: exit 1 only when the report is not ok. */
198
+ async function runCheck(context, options = {}) {
199
+ const { root, adapter, io } = context;
200
+ const started = Date.now();
201
+ try {
202
+ const { value: run, bootProblem } = await withFreshRoutes((routes) => runGrimoire(root, adapter, { routes }));
203
+ const report = withProblem(checkGrimoire(run.snapshot), bootProblem);
204
+ if (options.json === true) printJson(io, report);
205
+ else {
206
+ for (const line of formatCheckReport(report, { all: options.all === true })) io.out(line);
207
+ io.out(buildSummary(run).book);
208
+ io.out(elapsedLine(started));
209
+ }
210
+ return report.ok ? 0 : 1;
211
+ } catch (error) {
212
+ return reportError(io, error);
213
+ }
214
+ }
215
+ /** `warlock grimoire release <release> [--json]`. */
216
+ async function runRelease(context, release, options = {}) {
217
+ const { root, io } = context;
218
+ try {
219
+ const name = release?.trim() ?? "";
220
+ if (name === "" || /[\\/]/.test(name) || name.startsWith(".")) throw new GrimoireError("GR9006", `Pass the release name, like warlock grimoire release 1.1.0 (got ${JSON.stringify(release ?? "")}). It must match a file in grimoire/releases/.`);
221
+ const { written } = await parseGrimoire(root);
222
+ const outcome = await writeRelease(root, written, name);
223
+ if (options.json === true) {
224
+ printJson(io, outcome);
225
+ return 0;
226
+ }
227
+ const entries = outcome.collection.entries;
228
+ const listed = entries.map((entry) => `${entry.feature} ${entry.version} ${entry.word}`).join(", ");
229
+ io.out(`${outcome.file}: ${plural(entries.length, "entry", "entries")} collected${entries.length > 0 ? ` (${listed})` : ""}${outcome.changed ? "" : ", file unchanged"}`);
230
+ const unreleased = outcome.unreleased;
231
+ if (unreleased.length > 0) {
232
+ const names = unreleased.map((entry) => `${entry.feature} ${entry.version}`).join(", ");
233
+ const verb = unreleased.length === 1 ? "entry is" : "entries are";
234
+ io.out(`note: ${unreleased.length} ${verb} still unreleased: ${names}. To ship them in ${name}, move them under "## ${name} (${outcome.collection.date})" in each feature's CHANGELOG.md and run this command again.`);
235
+ }
236
+ return 0;
237
+ } catch (error) {
238
+ return reportError(io, error);
239
+ }
240
+ }
241
+ /** Open the snapshot for a scry question: cached routes, fresh once when a route question finds none. */
242
+ async function openForScry(root, adapter, query) {
243
+ const routes = query.type === "route" && !await hasRouteFacts(root) ? "fresh" : "cached";
244
+ return openGrimoire(root, adapter, { routes });
245
+ }
246
+ /** Answer a parsed query (shared by the CLI and the MCP tools). */
247
+ async function answer(root, adapter, query) {
248
+ return scry(await openForScry(root, adapter, query), query);
249
+ }
250
+ /** `warlock scry <file> | --impact … | --route … | --feature … | --flow … | --search … [--limit n] [--all] [--json]`. */
251
+ async function runScry(context, args, options = {}) {
252
+ const { root, adapter, io } = context;
253
+ try {
254
+ const result = await answer(root, adapter, parseScryQuery(args, options));
255
+ if (options.json === true) printJson(io, result);
256
+ else for (const line of formatScryResult(result, { all: options.all === true })) io.out(line);
257
+ return 0;
258
+ } catch (error) {
259
+ return reportError(io, error);
260
+ }
261
+ }
262
+
263
+ //#endregion
264
+ export { answer, hasRouteFacts, isMultiSite, needsBoot, reportError, runBuild, runCheck, runRelease, runScry };
265
+ //# sourceMappingURL=actions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actions.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/warlock/actions.ts"],"sourcesContent":["/**\n * What `warlock grimoire …` and `warlock scry …` do, as functions that write\n * to an `io` and return the exit code, so specs run them without a process.\n * Loaded lazily by the commands: it pulls in every Grimoire module.\n */\nimport { createHash } from \"node:crypto\";\nimport { readdir, readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { checkGrimoire, formatCheckReport } from \"../check\";\nimport { createFinding, explainGrimoireCode, GrimoireError } from \"../codes\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireCheckReport, GrimoireFinding } from \"../contracts/findings\";\nimport type { ScryQuery, ScryResult } from \"../contracts/scry\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport { loadBook } from \"../book\";\nimport { projectPath } from \"../paths\";\nimport { writeRelease } from \"../releases\";\nimport { formatScryResult, parseScryQuery, scry } from \"../scry\";\nimport { openGrimoire, runGrimoire, type GrimoireRun } from \"../workspace\";\nimport { parseGrimoire } from \"../written\";\n\n/** Where a command writes: `out` for its answer, `err` for problems. */\nexport type CommandIO = {\n out(line: string): void;\n err(line: string): void;\n};\n\n/** The project and adapter a command runs against. */\nexport type CommandContext = {\n /** Absolute project root. */\n root: string;\n adapter: BookAdapter;\n io: CommandIO;\n};\n\ntype Options = Readonly<Record<string, string | boolean | number>>;\n\nconst plural = (count: number, word: string, many = `${word}s`): string =>\n `${count} ${count === 1 ? word : many}`;\n\n/** Print a Grimoire error the way every command does, and return exit code 1. */\nexport function reportError(io: CommandIO, error: unknown): number {\n if (error instanceof GrimoireError) {\n io.err(`${error.code} ${error.message}`);\n\n const fix = explainGrimoireCode(error.code)?.fix;\n\n if (fix) io.err(` fix: ${fix}`);\n\n return 1;\n }\n\n throw error;\n}\n\nfunction printJson(io: CommandIO, value: unknown): void {\n io.out(JSON.stringify(value, null, 2));\n}\n\n/**\n * Open with fresh routes; when the app does not boot (`GR8002`), open again\n * with the cached ones and return the boot problem as a warning finding.\n */\nasync function withFreshRoutes<T>(\n open: (routes: \"fresh\" | \"cached\") => Promise<T>,\n): Promise<{ value: T; bootProblem: GrimoireFinding | null }> {\n try {\n return { value: await open(\"fresh\"), bootProblem: null };\n } catch (error) {\n if (!(error instanceof GrimoireError) || error.code !== \"GR8002\") throw error;\n\n return {\n value: await open(\"cached\"),\n // Finding messages start lower-case, like every other line of the check report.\n bootProblem: createFinding({\n code: \"GR8002\",\n message: `${error.message.charAt(0).toLowerCase()}${error.message.slice(1)}`,\n }),\n };\n }\n}\n\n/** Whether the book holds route facts already (a `--route` question with none boots once). */\nexport async function hasRouteFacts(root: string): Promise<boolean> {\n return (await loadBook(root))?.facts.routes != null;\n}\n\n/** sha256 of a project file, `\"\"` when it is missing (the book's boot-cache rule). */\nasync function inputHash(root: string, file: string): Promise<string> {\n try {\n return createHash(\"sha256\")\n .update(await readFile(path.join(root, ...file.split(\"/\"))))\n .digest(\"hex\");\n } catch {\n return \"\";\n }\n}\n\n/** File names whose appearance makes the route facts stale: routes files and named mails, jobs, events, notifications. */\nconst BOOT_INPUT = /^(?:routes|.+\\.(?:mail|job|event|notification))\\.[cm]?[jt]sx?$/;\n\n/** Every boot-cache candidate under `src/`: a new one makes the route facts stale. */\nasync function routesFiles(root: string, dir = \"src\"): Promise<string[]> {\n let entries;\n\n try {\n entries = await readdir(path.join(root, ...dir.split(\"/\")), { withFileTypes: true });\n } catch {\n return [];\n }\n\n const found: string[] = [];\n\n for (const entry of entries) {\n if (entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n\n const file = `${dir}/${entry.name}`;\n\n if (entry.isDirectory()) found.push(...(await routesFiles(root, file)));\n else if (\n BOOT_INPUT.test(entry.name) ||\n (file.startsWith(\"src/config/\") && /\\.[cm]?[jt]sx?$/.test(entry.name))\n )\n found.push(file);\n }\n\n return found;\n}\n\n/**\n * Whether `build` or `check` will have to boot the app: `force`, no book, no\n * route facts yet, or a route-cache input changed, appeared or went away.\n * Reads files only and never calls the adapter, so it runs before anything\n * is loaded.\n */\nexport async function needsBoot(root: string, force: boolean): Promise<boolean> {\n if (force) return true;\n\n const book = await loadBook(root);\n\n if (!book || book.facts.routes === null || book.manifest.boot.collectedAt === null) return true;\n\n const inputs = book.manifest.boot.inputs;\n\n for (const [file, hash] of Object.entries(inputs)) {\n if ((await inputHash(root, file)) !== hash) return true;\n }\n\n return (await routesFiles(root)).some((file) => inputs[file] === undefined);\n}\n\n/** Whether the app has several sites, whose page routes need `src/config/web.ts` loaded. */\nexport async function isMultiSite(root: string): Promise<boolean> {\n try {\n return (await readdir(path.join(root, \"src\", \"web\", \"$sites\"), { withFileTypes: true })).some(\n (entry) => entry.isDirectory(),\n );\n } catch {\n return false;\n }\n}\n\nfunction buildSummary(run: GrimoireRun): { book: string; collected: string } {\n const snapshot = run.snapshot;\n const tasks = snapshot.collected.tasksIndex;\n const bookmaps = run.collected.written.filter((file) => file.endsWith(\"bookmap.json\")).length;\n const nothing =\n !run.rebuilt &&\n run.book.written.length +\n run.book.removed.length +\n run.collected.written.length +\n run.collected.removed.length ===\n 0;\n const book = nothing\n ? \"book up to date\"\n : `book ${plural(snapshot.book.facts.files.length, \"file\")} (${run.book.written.length} written, ${run.book.removed.length} removed), routes ${snapshot.routes}`;\n\n return {\n book,\n // `waiting` is a part of `open`: count each task once, as the devtools tab does.\n collected: `features ${snapshot.collected.featuresIndex.features.length} (bookmaps written: ${bookmaps}) tasks ${tasks.open.length - tasks.waiting.length} open, ${tasks.waiting.length} waiting, ${tasks.done.length} done`,\n };\n}\n\n/**\n * The `--out` folder of the static site, project-relative. A folder outside\n * the project, or the project itself (its own `index.html`), is refused.\n */\nfunction siteFolder(root: string, out: string): string {\n const folder = projectPath(root, out.trim());\n\n if (\n out.trim() === \"\" ||\n folder === \"\" ||\n folder === \"..\" ||\n folder.startsWith(\"../\") ||\n path.isAbsolute(folder)\n ) {\n throw new GrimoireError(\n \"GR9006\",\n `--out ${JSON.stringify(out)} is not a folder inside the project. Pass a project-relative folder, like --out public/grimoire.`,\n );\n }\n\n return folder;\n}\n\n/** `time 4.2s`, the last line of `build` and `check`. */\nfunction elapsedLine(started: number): string {\n return `time ${((Date.now() - started) / 1000).toFixed(1)}s`;\n}\n\n/** `warlock grimoire build [--force] [--site [--out <dir>]] [--json]`. */\nexport async function runBuild(context: CommandContext, options: Options = {}): Promise<number> {\n const { root, adapter, io } = context;\n const started = Date.now();\n\n try {\n const force = options.force === true;\n const outDir = typeof options.out === \"string\" ? siteFolder(root, options.out) : undefined;\n const { value: run, bootProblem } = await withFreshRoutes((routes) =>\n runGrimoire(root, adapter, { routes, force }),\n );\n let site: string | null = null;\n\n if (options.site === true || typeof options.out === \"string\") {\n const { exportGrimoireSite } = await import(\"../devtools\");\n\n site = await exportGrimoireSite(root, {\n adapter,\n snapshot: run.snapshot,\n ...(outDir === undefined ? {} : { outDir }),\n });\n }\n\n if (options.json === true) {\n printJson(io, {\n rebuilt: run.rebuilt,\n changed: run.changed,\n written: [...run.book.written, ...run.collected.written],\n removed: [...run.book.removed, ...run.collected.removed],\n routes: run.snapshot.routes,\n site,\n problems: bootProblem === null ? [] : [bootProblem],\n });\n\n return 0;\n }\n\n const summary = buildSummary(run);\n\n // The app's own boot output comes before this point; the summary is always the last lines.\n if (bootProblem !== null) {\n io.err(`${bootProblem.code} ${bootProblem.message}`);\n io.err(` fix: ${bootProblem.hint}`);\n }\n\n io.out(summary.book);\n io.out(summary.collected);\n\n if (site !== null) io.out(`site ${site}/index.html`);\n\n io.out(elapsedLine(started));\n\n return 0;\n } catch (error) {\n return reportError(io, error);\n }\n}\n\n/** Add a boot problem to a check report as an unexpected warning. */\nfunction withProblem(\n report: GrimoireCheckReport,\n problem: GrimoireFinding | null,\n): GrimoireCheckReport {\n if (problem === null) return report;\n\n const firstExpected = report.findings.findIndex((finding) => finding.expected);\n const findings = [...report.findings];\n\n findings.splice(firstExpected === -1 ? findings.length : firstExpected, 0, problem);\n\n return {\n ...report,\n findings,\n counts: { ...report.counts, warnings: report.counts.warnings + 1 },\n };\n}\n\n/** `warlock grimoire check [--all] [--json]`: exit 1 only when the report is not ok. */\nexport async function runCheck(context: CommandContext, options: Options = {}): Promise<number> {\n const { root, adapter, io } = context;\n const started = Date.now();\n\n try {\n const { value: run, bootProblem } = await withFreshRoutes((routes) =>\n runGrimoire(root, adapter, { routes }),\n );\n const report = withProblem(checkGrimoire(run.snapshot), bootProblem);\n\n if (options.json === true) printJson(io, report);\n else {\n for (const line of formatCheckReport(report, { all: options.all === true })) io.out(line);\n\n // The app's own boot output comes before the report; the summary is always the last lines.\n io.out(buildSummary(run).book);\n io.out(elapsedLine(started));\n }\n\n return report.ok ? 0 : 1;\n } catch (error) {\n return reportError(io, error);\n }\n}\n\n/** `warlock grimoire release <release> [--json]`. */\nexport async function runRelease(\n context: CommandContext,\n release: string | undefined,\n options: Options = {},\n): Promise<number> {\n const { root, io } = context;\n\n try {\n const name = release?.trim() ?? \"\";\n\n if (name === \"\" || /[\\\\/]/.test(name) || name.startsWith(\".\")) {\n throw new GrimoireError(\n \"GR9006\",\n `Pass the release name, like warlock grimoire release 1.1.0 (got ${JSON.stringify(release ?? \"\")}). It must match a file in grimoire/releases/.`,\n );\n }\n\n const { written } = await parseGrimoire(root);\n const outcome = await writeRelease(root, written, name);\n\n if (options.json === true) {\n printJson(io, outcome);\n return 0;\n }\n\n const entries = outcome.collection.entries;\n const listed = entries\n .map((entry) => `${entry.feature} ${entry.version} ${entry.word}`)\n .join(\", \");\n\n io.out(\n `${outcome.file}: ${plural(entries.length, \"entry\", \"entries\")} collected${\n entries.length > 0 ? ` (${listed})` : \"\"\n }${outcome.changed ? \"\" : \", file unchanged\"}`,\n );\n\n const unreleased = outcome.unreleased;\n\n if (unreleased.length > 0) {\n const names = unreleased.map((entry) => `${entry.feature} ${entry.version}`).join(\", \");\n const verb = unreleased.length === 1 ? \"entry is\" : \"entries are\";\n\n io.out(\n `note: ${unreleased.length} ${verb} still unreleased: ${names}. To ship them in ${name}, move them under \"## ${name} (${outcome.collection.date})\" in each feature's CHANGELOG.md and run this command again.`,\n );\n }\n\n return 0;\n } catch (error) {\n return reportError(io, error);\n }\n}\n\n/** Open the snapshot for a scry question: cached routes, fresh once when a route question finds none. */\nasync function openForScry(\n root: string,\n adapter: BookAdapter,\n query: ScryQuery,\n): Promise<GrimoireSnapshot> {\n const routes: \"fresh\" | \"cached\" =\n query.type === \"route\" && !(await hasRouteFacts(root)) ? \"fresh\" : \"cached\";\n\n return openGrimoire(root, adapter, { routes });\n}\n\n/** Answer a parsed query (shared by the CLI and the MCP tools). */\nexport async function answer(\n root: string,\n adapter: BookAdapter,\n query: ScryQuery,\n): Promise<ScryResult> {\n return scry(await openForScry(root, adapter, query), query);\n}\n\n/** `warlock scry <file> | --impact … | --route … | --feature … | --flow … | --search … [--limit n] [--all] [--json]`. */\nexport async function runScry(\n context: CommandContext,\n args: readonly string[],\n options: Options = {},\n): Promise<number> {\n const { root, adapter, io } = context;\n\n try {\n const query = parseScryQuery(args, options);\n const result = await answer(root, adapter, query);\n\n if (options.json === true) printJson(io, result);\n else for (const line of formatScryResult(result, { all: options.all === true })) io.out(line);\n\n return 0;\n } catch (error) {\n return reportError(io, error);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,MAAM,UAAU,OAAe,MAAc,OAAO,GAAG,KAAK,OAC1D,GAAG,MAAM,GAAG,UAAU,IAAI,OAAO;;AAGnC,SAAgB,YAAY,IAAe,OAAwB;CACjE,IAAI,iBAAiB,eAAe;EAClC,GAAG,IAAI,GAAG,MAAM,KAAK,IAAI,MAAM,SAAS;EAExC,MAAM,MAAM,oBAAoB,MAAM,IAAI,CAAC,EAAE;EAE7C,IAAI,KAAK,GAAG,IAAI,UAAU,KAAK;EAE/B,OAAO;CACT;CAEA,MAAM;AACR;AAEA,SAAS,UAAU,IAAe,OAAsB;CACtD,GAAG,IAAI,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;AACvC;;;;;AAMA,eAAe,gBACb,MAC4D;CAC5D,IAAI;EACF,OAAO;GAAE,OAAO,MAAM,KAAK,OAAO;GAAG,aAAa;EAAK;CACzD,SAAS,OAAO;EACd,IAAI,EAAE,iBAAiB,kBAAkB,MAAM,SAAS,UAAU,MAAM;EAExE,OAAO;GACL,OAAO,MAAM,KAAK,QAAQ;GAE1B,aAAa,cAAc;IACzB,MAAM;IACN,SAAS,GAAG,MAAM,QAAQ,OAAO,CAAC,CAAC,CAAC,YAAY,IAAI,MAAM,QAAQ,MAAM,CAAC;GAC3E,CAAC;EACH;CACF;AACF;;AAGA,eAAsB,cAAc,MAAgC;CAClE,QAAQ,MAAM,SAAS,IAAI,EAAC,EAAG,MAAM,UAAU;AACjD;;AAGA,eAAe,UAAU,MA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O;CAE9B,IAAI;EAEF,MAAM,SAAS,MAAM,OAAO,MAAM,SADpB,eAAe,MAAM,OACY,CAAC;EAEhD,IAAI,QAAQ,SAAS,MAAM,UAAU,IAAI,MAAM;OAC1C,KAAK,MAAM,QAAQ,iBAAiB,QAAQ,EAAE,KAAK,QAAQ,QAAQ,KAAK,CAAC,GAAG,GAAG,IAAI,IAAI;EAE5F,OAAO;CACT,SAAS,OAAO;EACd,OAAO,YAAY,IAAI,KAAK;CAC9B;AACF"}
@@ -0,0 +1,28 @@
1
+ import { BookAdapter } from "../contracts/adapter.mjs";
2
+ import { MobileAppOption } from "./mobile-facts.mjs";
3
+ import { InspectReport, InspectSection } from "@warlock.js/core/tooling";
4
+ //#region ../../packages/grimoire/src/warlock/adapter.d.ts
5
+ /**
6
+ * Reads the sections of the inspect report that need the app booted
7
+ * (`routes`, `events`, `jobs`) for the project at `root`. The default boots
8
+ * the app once, the `warlock inspect` way (connectors boot, none starts).
9
+ * `warlock mcp` passes its own, which shares the server's boot.
10
+ */
11
+ export type WarlockInspect = (root: string, sections: readonly InspectSection[]) => Promise<InspectReport>;
12
+ /** Options of `createWarlockAdapter()`. */
13
+ export type WarlockAdapterOptions = {
14
+ /**
15
+ * Mobile apps in the repository: folder, id and routing. Default: every
16
+ * top-level folder with an `app.json` or an `app.config.*` file; it is
17
+ * file-routed when its `package.json` lists `expo-router` (screens come
18
+ * from the files), and code-navigated otherwise (no screens: the agent
19
+ * declares them in `grimoire/apps/<app>/screens/`).
20
+ */
21
+ mobile?: readonly MobileAppOption[];
22
+ /** How the booted sections are read. Default: the `warlock inspect` boot pass, run at most once. Pages never boot. */
23
+ inspect?: WarlockInspect;
24
+ };
25
+ /** The adapter over `inspectApp()`, `collectFiles()` and the mobile app folders. */
26
+ export declare function createWarlockAdapter(options?: WarlockAdapterOptions): BookAdapter;
27
+ //#endregion
28
+ //# sourceMappingURL=adapter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/warlock/adapter.ts"],"mappings":";;;;;;;;;;YAsCY,kBACV,cACA,mBAAmB,qBAChB,QAAQ;;YAGD;;;;;;;;EAQV,kBAAkB;;EAElB,UAAU;;;wBAoSI,qBAAqB,UAAS,wBAA6B"}