@warlock.js/grimoire 5.61.0 → 5.63.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 (59) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/esm/book/build.d.mts +17 -0
  3. package/esm/book/build.d.mts.map +1 -1
  4. package/esm/book/build.mjs +78 -16
  5. package/esm/book/build.mjs.map +1 -1
  6. package/esm/book/index.mjs +2 -2
  7. package/esm/codes/codes.d.mts +2 -0
  8. package/esm/codes/codes.d.mts.map +1 -1
  9. package/esm/codes/codes.mjs +2 -1
  10. package/esm/codes/codes.mjs.map +1 -1
  11. package/esm/contracts/book.d.mts +7 -0
  12. package/esm/contracts/book.d.mts.map +1 -1
  13. package/esm/contracts/book.mjs.map +1 -1
  14. package/esm/contracts/scry.d.mts +29 -5
  15. package/esm/contracts/scry.d.mts.map +1 -1
  16. package/esm/contracts/snapshot.d.mts +8 -0
  17. package/esm/contracts/snapshot.d.mts.map +1 -1
  18. package/esm/devtools/snapshot-source.mjs +27 -7
  19. package/esm/devtools/snapshot-source.mjs.map +1 -1
  20. package/esm/index.d.mts +5 -3
  21. package/esm/index.mjs +4 -2
  22. package/esm/scry/error.mjs +20 -0
  23. package/esm/scry/error.mjs.map +1 -0
  24. package/esm/scry/format.d.mts.map +1 -1
  25. package/esm/scry/format.mjs +22 -1
  26. package/esm/scry/format.mjs.map +1 -1
  27. package/esm/scry/index.mjs +3 -2
  28. package/esm/scry/parse.d.mts +1 -1
  29. package/esm/scry/parse.d.mts.map +1 -1
  30. package/esm/scry/parse.mjs +12 -9
  31. package/esm/scry/parse.mjs.map +1 -1
  32. package/esm/scry/query.d.mts.map +1 -1
  33. package/esm/scry/query.mjs +77 -268
  34. package/esm/scry/query.mjs.map +1 -1
  35. package/esm/scry/search.d.mts +8 -0
  36. package/esm/scry/search.d.mts.map +1 -0
  37. package/esm/scry/search.mjs +401 -0
  38. package/esm/scry/search.mjs.map +1 -0
  39. package/esm/warlock/actions.mjs +15 -12
  40. package/esm/warlock/actions.mjs.map +1 -1
  41. package/esm/warlock/commands.mjs +14 -4
  42. package/esm/warlock/commands.mjs.map +1 -1
  43. package/esm/warlock/mcp-tools.mjs +46 -21
  44. package/esm/warlock/mcp-tools.mjs.map +1 -1
  45. package/esm/workspace/cache.mjs +13 -1
  46. package/esm/workspace/cache.mjs.map +1 -1
  47. package/esm/workspace/derived.mjs +107 -0
  48. package/esm/workspace/derived.mjs.map +1 -0
  49. package/esm/workspace/index.d.mts.map +1 -1
  50. package/esm/workspace/index.mjs +22 -18
  51. package/esm/workspace/index.mjs.map +1 -1
  52. package/esm/workspace/stored.d.mts +12 -0
  53. package/esm/workspace/stored.d.mts.map +1 -0
  54. package/esm/workspace/stored.mjs +46 -0
  55. package/esm/workspace/stored.mjs.map +1 -0
  56. package/llms-full.txt +28 -12
  57. package/package.json +3 -3
  58. package/skills/use-the-grimoire/SKILL.md +28 -12
  59. package/ui/grimoire-view.js +16 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,34 @@
2
2
 
3
3
  `@warlock.js/grimoire` is new in 5.55.0 and experimental: its file layout, `GR` codes and API may change in any release until it is marked stable.
4
4
 
5
+ ## 5.63.0 - 2026-11-22
6
+
7
+ ### Added
8
+
9
+ - `warlock scry --route "GET /chat"` finds pages and mobile screens. For `GET` and `HEAD` with no API route on the path, it looks the path up in the pages and screens and returns each one with its file, setup file, layouts and the import closure of those; a path several sites serve lists every site, and the new `--site <id>` (and an optional `site` on `grimoire_route`) keeps one. `ScryRouteResult.route` is `null` for such a page and `pages` lists the matches. A page URL is found even before the route facts were read, and the `GR9002` message names the pages on the path when the method is not `GET` or `HEAD`.
10
+ - `warlock scry --json` prints a failure as `{ "type": "error", "code", "message", "fix" }` on stdout and exits 1 (text mode still writes to stderr). The shape is the new `ScryError` type; the scry MCP tools (`grimoire_file`, `grimoire_impact`, `grimoire_route`, `grimoire_feature`, `grimoire_flow`, `grimoire_search`) return the same JSON as their error text.
11
+ - Page, screen, block and file search hits carry `app`; `--app <id>` and the `app` input of `grimoire_search` keep one app's hits.
12
+ - `GR9007` (error): the book was never built, or was built by another version. Run `warlock grimoire build`.
13
+ - `openStoredGrimoire(root, adapter)`, the read-only open behind `scry`, and `checkBook()`, the change check of `buildBook` with nothing rebuilt or written. The snapshot gains an optional `behind` field.
14
+ - `SCRY_STOP_WORDS`, the extendable list of words search leaves out.
15
+
16
+ ### Changed
17
+
18
+ - `warlock scry` and the MCP read tools only read. They answer from the book the last `warlock grimoire build` left on disk and no longer rebuild it, boot the app or write a file. Each call used to run the whole pipeline (book maps, owners, proofs, a write comparison); it now runs one change check and reads the stored book. When code, test or written files differ from the book, the answer is still the stored one and ends with `note book is stale (12 files changed); run warlock grimoire build` (in `--json`, the `notes` list). `grimoire_check` reads the stored book the same way and adds a `note` when it is behind.
19
+ - `warlock grimoire build` and `warlock grimoire check` now also write `grimoire/book/.cache/derived.json` (owners, apps, proofs, test results, book maps, annotations). It is a git-ignored cache.
20
+ - `warlock scry --route` no longer boots the app to read missing route facts; it stops with `GR9002` and tells you to run `warlock grimoire build`.
21
+ - `warlock scry --search` takes a whole sentence (a commit title, a bug report). A hit no longer needs every word: hits whose name or title is the text, starts with it or holds every word come first, and everything else is ranked by a BM25F score over the id and path words (weight 3), export names (2), the header sentence (1) and written text (1), with whole-word matching and light stemming. Ids such as `AC-5` and `WL9003` stay one word. Matching by letters in order (`newarr`) is gone. Help text, the skill and the docs tell agents to pass the whole sentence.
22
+ - `--search` prints hits in score order with the score in front of each line (features and flows first only on an equal score, then page and screen files before helper files), no longer grouped by type. The search index is built once for each opened book.
23
+ - The dev Grimoire tab reads the route facts again from the running dev server after a routes file (or a file it imports) changes, so a route edit shows as `fresh` without `warlock grimoire build`.
24
+
25
+ ### Fixed
26
+
27
+ - Search words match whole words only: `ui` no longer matches `build`. A block is found by `<app>/<page>` and its text, so a block whose long text shares a word with the query no longer matches through its id.
28
+ - A live read of the route facts that finds fewer than half of the routes the book already holds no longer replaces the stored list: the book keeps it, writes nothing for it, reports the facts `stale` and adds a note, which `warlock grimoire build` and `grimoire_build` print. `warlock grimoire build --force` trusts the read, so a real removal is still accepted. The manifest stores the route and page counts of the last read (`boot.counts`).
29
+ - Route facts where no route names its source file are reported as `route facts look incomplete; run warlock grimoire build` in `GR9002` and in `--impact` and other answers' notes.
30
+ - The dev Grimoire tab no longer reports route facts `fresh` for about a minute after a routes file changed: the files the route facts were read from are part of its change stamp, so the next view reopens at once.
31
+ - The dev Grimoire tab's route view shows the pages behind a page URL instead of failing on it.
32
+
5
33
  ## 5.61.0 - 2026-11-20
6
34
 
7
35
  ### Added
@@ -10,5 +10,22 @@ import { BuildBookOptions, BuildBookResult, LoadedBook } from "../contracts/book
10
10
  export declare function buildBook(root: string, adapter: BookAdapter, options?: BuildBookOptions): Promise<BuildBookResult>;
11
11
  /** Read the book from disk without calling an adapter; `null` when it was never built. */
12
12
  export declare function loadBook(root: string): Promise<LoadedBook | null>;
13
+ /** What `checkBook` found: the stored book, and how far the files have moved from it. */
14
+ export type BookCheck = {
15
+ /** The stored book, with its route freshness measured against the files as they are now. */
16
+ book: LoadedBook;
17
+ /** Code and test files added, changed or removed since the last build, sorted. */
18
+ changed: string[];
19
+ };
20
+ /**
21
+ * The cheap change check of `buildBook` with nothing rebuilt and nothing
22
+ * written: scans the source roots (hashing only files whose size or time
23
+ * moved) and compares them, and the tests, with the manifest. The adapter is
24
+ * asked for its source roots only, never for files or route facts. `null`
25
+ * when the book was never built (or was written by an older schema).
26
+ *
27
+ * @param root Absolute project root.
28
+ */
29
+ export declare function checkBook(root: string, adapter: BookAdapter): Promise<BookCheck | null>;
13
30
  //#endregion
14
31
  //# sourceMappingURL=build.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/book/build.ts"],"mappings":";;;;;;;;;wBAySsB,UACpB,cACA,SAAS,aACT,UAAS,mBACR,QAAQ;;wBAyKW,SAAS,eAAe,QAAQ"}
1
+ {"version":3,"file":"build.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/book/build.ts"],"mappings":";;;;;;;;;wBA8TsB,UACpB,cACA,SAAS,aACT,UAAS,mBACR,QAAQ;;wBAiMW,SAAS,eAAe,QAAQ;;YAgB1C;;EAEV,MAAM;;EAEN;;;;;;;;;;;wBAYoB,UAAU,cAAc,SAAS,cAAc,QAAQ"}
@@ -143,6 +143,14 @@ function bootState(boot, routes, inputs) {
143
143
  if (boot.collectedAt === null || routes === null) return "missing";
144
144
  return sameRecord(boot.inputs, inputs) ? "fresh" : "stale";
145
145
  }
146
+ /**
147
+ * A fresh read that found under half the routes the book already holds is not trusted over the stored list,
148
+ * unless the build was forced (`warlock grimoire build --force`): that is how a real removal is accepted.
149
+ */
150
+ function shrankTooFar(stored, read, force) {
151
+ return !force && stored !== null && read !== null && stored.length > 0 && read.length * 2 < stored.length;
152
+ }
153
+ const shrankNote = (kept, read) => `a live read found ${read} routes against the ${kept} stored; kept the stored routes; run warlock grimoire build again, or warlock grimoire build --force when the routes were removed`;
146
154
  async function writeStoredBook(root, manifest, facts) {
147
155
  if (facts !== null) {
148
156
  const cache = {
@@ -176,15 +184,26 @@ async function buildBook(root, adapter, options = {}) {
176
184
  const inputs = await hashFiles(projectRoot, Object.keys(manifest.boot.inputs), scan.files, sourceRoots);
177
185
  let routes = hasBootFacts(adapter) ? bootState(manifest.boot, facts.routes, inputs) : "missing";
178
186
  let changedBook = false;
187
+ let routeNote;
179
188
  if (mode === "fresh" && hasBootFacts(adapter) && routes !== "fresh") {
180
189
  const current = await hashFiles(projectRoot, await routeInputFiles(projectRoot, adapter, facts.files), scan.files, sourceRoots);
181
- Object.assign(facts, await collectBootFacts(projectRoot, adapter));
182
- manifest.boot = {
183
- collectedAt: now().toISOString(),
184
- inputs: current
185
- };
186
- routes = "fresh";
187
- changedBook = true;
190
+ const read = await collectBootFacts(projectRoot, adapter);
191
+ if (shrankTooFar(facts.routes, read.routes, false)) {
192
+ routeNote = shrankNote(facts.routes?.length ?? 0, read.routes?.length ?? 0);
193
+ routes = "stale";
194
+ } else {
195
+ Object.assign(facts, read);
196
+ manifest.boot = {
197
+ collectedAt: now().toISOString(),
198
+ inputs: current,
199
+ counts: {
200
+ routes: read.routes?.length ?? 0,
201
+ pages: facts.pages.length
202
+ }
203
+ };
204
+ routes = "fresh";
205
+ changedBook = true;
206
+ }
188
207
  }
189
208
  if (changedBook || scan.statMoved) {
190
209
  for (const [file, state] of Object.entries(scan.files)) manifest.files[file] = {
@@ -199,7 +218,8 @@ async function buildBook(root, adapter, options = {}) {
199
218
  root: projectRoot,
200
219
  manifest,
201
220
  facts,
202
- routes
221
+ routes,
222
+ ...routeNote ? { routeNote } : {}
203
223
  },
204
224
  rebuilt: changedBook,
205
225
  changed: []
@@ -232,18 +252,29 @@ async function buildBook(root, adapter, options = {}) {
232
252
  inputs: {}
233
253
  };
234
254
  let boot = previousBoot;
255
+ let routeNote;
235
256
  let bootFacts = {
236
257
  routes: stored?.facts.routes ?? null,
237
258
  named: stored?.facts.named ?? []
238
259
  };
239
260
  let routes = hasBootFacts(adapter) ? bootState(previousBoot, bootFacts.routes, inputs) : "missing";
240
261
  if (mode === "fresh" && hasBootFacts(adapter) && (routes !== "fresh" || options.force === true)) {
241
- bootFacts = await collectBootFacts(projectRoot, adapter);
242
- boot = {
243
- collectedAt: now().toISOString(),
244
- inputs
245
- };
246
- routes = "fresh";
262
+ const read = await collectBootFacts(projectRoot, adapter);
263
+ if (shrankTooFar(bootFacts.routes, read.routes, options.force === true)) {
264
+ routeNote = shrankNote(bootFacts.routes?.length ?? 0, read.routes?.length ?? 0);
265
+ routes = "stale";
266
+ } else {
267
+ bootFacts = read;
268
+ boot = {
269
+ collectedAt: now().toISOString(),
270
+ inputs,
271
+ counts: {
272
+ routes: read.routes?.length ?? 0,
273
+ pages: staticFacts.pages.length
274
+ }
275
+ };
276
+ routes = "fresh";
277
+ }
247
278
  }
248
279
  const facts = {
249
280
  files,
@@ -277,7 +308,8 @@ async function buildBook(root, adapter, options = {}) {
277
308
  root: projectRoot,
278
309
  manifest,
279
310
  facts,
280
- routes
311
+ routes,
312
+ ...routeNote ? { routeNote } : {}
281
313
  },
282
314
  rebuilt: true,
283
315
  changed: changedFiles(previousFiles, scan.files)
@@ -295,7 +327,37 @@ async function loadBook(root) {
295
327
  routes: stored.facts.routes === null ? "missing" : "cached"
296
328
  };
297
329
  }
330
+ /**
331
+ * The cheap change check of `buildBook` with nothing rebuilt and nothing
332
+ * written: scans the source roots (hashing only files whose size or time
333
+ * moved) and compares them, and the tests, with the manifest. The adapter is
334
+ * asked for its source roots only, never for files or route facts. `null`
335
+ * when the book was never built (or was written by an older schema).
336
+ *
337
+ * @param root Absolute project root.
338
+ */
339
+ async function checkBook(root, adapter) {
340
+ const projectRoot = path.resolve(root);
341
+ const stored = await readStoredBook(projectRoot);
342
+ if (stored === null) return null;
343
+ const { manifest, facts } = stored;
344
+ const sourceRoots = [...new Set((await adapter.sourceRoots(projectRoot)).map(cleanFolder))].sort();
345
+ const scan = await scanSourceRoots(projectRoot, sourceRoots, manifest.files);
346
+ const changed = new Set(changedFiles(manifest.files, scan.files));
347
+ const tests = await hashFiles(projectRoot, Object.keys(manifest.tests), scan.files, sourceRoots);
348
+ for (const [file, hash] of Object.entries(tests)) if (manifest.tests[file] !== hash) changed.add(file);
349
+ const inputs = await hashFiles(projectRoot, Object.keys(manifest.boot.inputs), scan.files, sourceRoots);
350
+ return {
351
+ book: {
352
+ root: projectRoot,
353
+ manifest,
354
+ facts,
355
+ routes: hasBootFacts(adapter) ? bootState(manifest.boot, facts.routes, inputs) : "missing"
356
+ },
357
+ changed: [...changed].sort()
358
+ };
359
+ }
298
360
 
299
361
  //#endregion
300
- export { WRITE_STATE_PATH, buildBook, defaultRouteInputs, grimoireVersion, loadBook };
362
+ export { WRITE_STATE_PATH, buildBook, checkBook, defaultRouteInputs, grimoireVersion, loadBook };
301
363
  //# sourceMappingURL=build.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/book/build.ts"],"sourcesContent":["/**\n * `buildBook` and `loadBook`: the freshness fingerprint, the facts cache and\n * the route (boot) cache. Entries are written by `writeBook` (write.ts).\n */\nimport { readFileSync } from \"node:fs\";\nimport { rm, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { BookAdapter, BookFacts, BookFile } from \"../contracts/adapter\";\nimport {\n BOOK_SCHEMA_VERSION,\n type BookFactsCache,\n type BookManifest,\n type BookManifestFile,\n type BuildBookOptions,\n type BuildBookResult,\n type LoadedBook,\n} from \"../contracts/book\";\nimport type { RouteFreshness } from \"../contracts/findings\";\nimport { GrimoireError } from \"../codes\";\nimport { importClosure, fileGraph } from \"../graph\";\nimport { GRIMOIRE_PATHS, isCodeFile, isInsideFolder } from \"../paths\";\nimport {\n cleanFolder,\n hashFile,\n hashIfExists,\n IO_CONCURRENCY,\n isMissing,\n listFiles,\n mapLimit,\n readJson,\n toJson,\n writeBookFile,\n} from \"./io\";\nimport {\n cleanPath,\n normalizeFiles,\n normalizeMobile,\n normalizeNamed,\n normalizePages,\n normalizeRoutes,\n normalizeSites,\n} from \"./normalize\";\nimport { entryPathsFor } from \"./render\";\n\n/** Where `writeBook` remembers what it wrote (see write.ts). */\nexport const WRITE_STATE_PATH = `${GRIMOIRE_PATHS.book}/.cache/written.json`;\n\nlet cachedVersion: string | null = null;\n\n/** The `@warlock.js/grimoire` version, from its package.json. */\nexport function grimoireVersion(): string {\n if (cachedVersion !== null) return cachedVersion;\n\n try {\n const manifest = JSON.parse(\n readFileSync(new URL(\"../../package.json\", import.meta.url), \"utf8\"),\n ) as {\n version?: unknown;\n };\n cachedVersion = typeof manifest.version === \"string\" ? manifest.version : \"0.0.0\";\n } catch {\n cachedVersion = \"0.0.0\";\n }\n\n return cachedVersion;\n}\n\nconst absolutePath = (root: string, file: string): string => path.join(root, ...file.split(\"/\"));\n\ntype StoredBook = { manifest: BookManifest; facts: BookFacts };\n\n/**\n * `facts.json` as written since type-only import edges were recorded. A cache\n * without the marker comes from an older version: it is not reused, so file\n * facts are scanned once more.\n */\ntype StoredFactsCache = BookFactsCache & { typeOnlyEdges?: boolean };\n\nasync function readStoredBook(root: string): Promise<StoredBook | null> {\n const manifest = await readJson<BookManifest>(absolutePath(root, GRIMOIRE_PATHS.bookManifest));\n const cache = await readJson<StoredFactsCache>(absolutePath(root, GRIMOIRE_PATHS.bookFactsCache));\n\n if (\n manifest === null ||\n cache === null ||\n manifest.schemaVersion !== BOOK_SCHEMA_VERSION ||\n cache.schemaVersion !== BOOK_SCHEMA_VERSION ||\n cache.typeOnlyEdges !== true ||\n typeof manifest.files !== \"object\" ||\n typeof cache.facts !== \"object\"\n ) {\n return null;\n }\n\n return { manifest, facts: cache.facts };\n}\n\n/** The current state of every code file under the source roots (images, fonts and certificates are not part of the book). */\ntype Scan = {\n files: Record<string, Omit<BookManifestFile, \"entry\">>;\n /** A file kept its hash but its size or mtime moved: the manifest needs the new stat. */\n statMoved: boolean;\n};\n\n/** Stat every code file; hash only those whose size or mtime differ from the previous manifest. */\nasync function scanSourceRoots(\n root: string,\n sourceRoots: readonly string[],\n previous: Record<string, BookManifestFile>,\n): Promise<Scan> {\n let files: string[];\n\n try {\n files = (await listFiles(root, sourceRoots)).filter(isCodeFile);\n } catch (error) {\n throw new GrimoireError(\n \"GR8001\",\n `The source roots could not be read: ${(error as Error).message}`,\n );\n }\n\n let statMoved = false;\n const states = await mapLimit(files, IO_CONCURRENCY, async (file) => {\n const absolute = absolutePath(root, file);\n\n try {\n const info = await stat(absolute);\n const before = previous[file];\n\n if (before !== undefined && before.size === info.size && before.mtimeMs === info.mtimeMs) {\n return { file, hash: before.hash, size: info.size, mtimeMs: info.mtimeMs };\n }\n\n const hash = await hashFile(absolute, info.size);\n\n if (before !== undefined && before.hash === hash) statMoved = true;\n\n return { file, hash, size: info.size, mtimeMs: info.mtimeMs };\n } catch (error) {\n // Deleted between the walk and the stat: treat it as gone.\n if (isMissing(error)) return null;\n throw new GrimoireError(\"GR8001\", `${file} could not be read: ${(error as Error).message}`);\n }\n });\n const result: Scan[\"files\"] = {};\n\n for (const state of states) {\n if (state !== null)\n result[state.file] = { hash: state.hash, size: state.size, mtimeMs: state.mtimeMs };\n }\n\n return { files: result, statMoved };\n}\n\n/** Hashes of the given files: from the scan when inside the source roots, else read (`\"\"` when missing). */\nasync function hashFiles(\n root: string,\n files: readonly string[],\n scan: Scan[\"files\"],\n sourceRoots: readonly string[],\n): Promise<Record<string, string>> {\n const hashes = await mapLimit([...new Set(files)].sort(), IO_CONCURRENCY, async (file) => {\n const scanned = scan[file];\n\n if (scanned !== undefined) return [file, scanned.hash] as const;\n // A code file inside a source root that the scan did not find is gone; any other input (a JSON config) is read.\n if (\n isCodeFile(file) &&\n sourceRoots.some((folder) => folder === \".\" || isInsideFolder(file, folder))\n )\n return [file, \"\"] as const;\n\n return [file, await hashIfExists(root, file)] as const;\n });\n\n return Object.fromEntries(hashes);\n}\n\nfunction sameRecord(left: Record<string, string>, right: Record<string, string>): boolean {\n const leftKeys = Object.keys(left);\n\n return (\n leftKeys.length === Object.keys(right).length &&\n leftKeys.every((key) => right[key] === left[key])\n );\n}\n\n/** Source files added, changed or removed between two manifests, sorted. */\nfunction changedFiles(\n previous: Record<string, BookManifestFile>,\n current: Scan[\"files\"],\n): string[] {\n const changed: string[] = [];\n\n for (const [file, state] of Object.entries(current)) {\n if (previous[file]?.hash !== state.hash) changed.push(file);\n }\n\n for (const file of Object.keys(previous)) {\n if (current[file] === undefined) changed.push(file);\n }\n\n return changed.sort();\n}\n\nconst NAMED_FILE_TYPES = new Set([\"mail\", \"job\", \"event\"]);\n\n/**\n * Files whose change makes the route cache stale: every `routes` file and\n * everything it imports, every `config` file, `warlock.config.ts`,\n * `package.json`, and every mail, job, event and notification file (the\n * named things are cached with the routes).\n */\nexport function defaultRouteInputs(files: readonly BookFile[]): string[] {\n const routesFiles = files.filter((file) => file.type === \"routes\").map((file) => file.file);\n const inputs = new Set(importClosure(fileGraph(files), routesFiles));\n\n for (const file of files) {\n if (\n file.type === \"config\" ||\n NAMED_FILE_TYPES.has(file.type) ||\n /\\.notification\\.[^/]+$/.test(file.file)\n ) {\n inputs.add(file.file);\n }\n }\n\n inputs.add(\"warlock.config.ts\");\n inputs.add(\"package.json\");\n\n return [...inputs].sort();\n}\n\n/** The route cache's input files: the adapter's list when it has one, else the default. */\nasync function routeInputFiles(\n root: string,\n adapter: BookAdapter,\n files: readonly BookFile[],\n): Promise<string[]> {\n return adapter.routeInputs\n ? (await adapter.routeInputs(root, files)).map(cleanPath)\n : defaultRouteInputs(files);\n}\n\nconst hasBootFacts = (adapter: BookAdapter): boolean =>\n typeof adapter.routes === \"function\" || typeof adapter.named === \"function\";\n\nasync function collectBootFacts(\n root: string,\n adapter: BookAdapter,\n): Promise<Pick<BookFacts, \"routes\" | \"named\">> {\n try {\n return {\n routes: adapter.routes ? normalizeRoutes(await adapter.routes(root)) : null,\n named: adapter.named ? normalizeNamed(await adapter.named(root)) : [],\n };\n } catch (error) {\n if (error instanceof GrimoireError) throw error;\n throw new GrimoireError(\"GR8002\", `Route facts could not be read: ${(error as Error).message}`);\n }\n}\n\n/** How the stored route facts relate to the current inputs. */\nfunction bootState(\n boot: BookManifest[\"boot\"],\n routes: BookFacts[\"routes\"],\n inputs: Record<string, string>,\n): \"fresh\" | \"stale\" | \"missing\" {\n if (boot.collectedAt === null || routes === null) return \"missing\";\n\n return sameRecord(boot.inputs, inputs) ? \"fresh\" : \"stale\";\n}\n\nasync function writeStoredBook(\n root: string,\n manifest: BookManifest,\n facts: BookFacts | null,\n): Promise<void> {\n if (facts !== null) {\n const cache: StoredFactsCache = {\n schemaVersion: BOOK_SCHEMA_VERSION,\n typeOnlyEdges: true,\n facts,\n };\n await writeBookFile(root, GRIMOIRE_PATHS.bookFactsCache, toJson(cache));\n }\n\n // The manifest last: a reader that sees it also sees the facts it describes.\n await writeBookFile(root, GRIMOIRE_PATHS.bookManifest, toJson(manifest));\n}\n\n/**\n * Bring the book's facts up to date and write `manifest.json` and\n * `.cache/facts.json`. Does not write entries (see `writeBook`).\n *\n * @param root Absolute project root.\n */\nexport async function buildBook(\n root: string,\n adapter: BookAdapter,\n options: BuildBookOptions = {},\n): Promise<BuildBookResult> {\n const projectRoot = path.resolve(root);\n const mode = options.routes ?? \"cached\";\n const now = options.now ?? (() => new Date());\n // `write: false` (passed by `openGrimoire({ write: false })`) computes in memory only.\n const write = options.write !== false;\n const sourceRoots = [\n ...new Set((await adapter.sourceRoots(projectRoot)).map(cleanFolder)),\n ].sort();\n const stored = await readStoredBook(projectRoot);\n const previousFiles = stored?.manifest.files ?? {};\n const scan = await scanSourceRoots(projectRoot, sourceRoots, previousFiles);\n const version = grimoireVersion();\n\n // ── The fast path: nothing under the source roots (or the tests) changed. ──\n if (stored !== null && options.force !== true) {\n const { manifest, facts } = stored;\n const sameSetup =\n manifest.grimoireVersion === version &&\n manifest.adapter.name === adapter.name &&\n manifest.adapter.version === adapter.version &&\n manifest.sourceRoots.length === sourceRoots.length &&\n manifest.sourceRoots.every((folder, index) => folder === sourceRoots[index]);\n const sameFiles =\n sameSetup &&\n Object.keys(previousFiles).length === Object.keys(scan.files).length &&\n Object.entries(scan.files).every(([file, state]) => previousFiles[file]?.hash === state.hash);\n const sameTests =\n sameFiles &&\n sameRecord(\n manifest.tests,\n await hashFiles(projectRoot, Object.keys(manifest.tests), scan.files, sourceRoots),\n );\n\n if (sameTests) {\n const inputs = await hashFiles(\n projectRoot,\n Object.keys(manifest.boot.inputs),\n scan.files,\n sourceRoots,\n );\n let routes: RouteFreshness = hasBootFacts(adapter)\n ? bootState(manifest.boot, facts.routes, inputs)\n : \"missing\";\n let changedBook = false;\n\n if (mode === \"fresh\" && hasBootFacts(adapter) && routes !== \"fresh\") {\n // The stored input list can be older than the files (a cached rebuild keeps it): work it out again.\n const current = await hashFiles(\n projectRoot,\n await routeInputFiles(projectRoot, adapter, facts.files),\n scan.files,\n sourceRoots,\n );\n Object.assign(facts, await collectBootFacts(projectRoot, adapter));\n manifest.boot = { collectedAt: now().toISOString(), inputs: current };\n routes = \"fresh\";\n changedBook = true;\n }\n\n if (changedBook || scan.statMoved) {\n for (const [file, state] of Object.entries(scan.files)) {\n manifest.files[file] = { ...state, entry: manifest.files[file]?.entry ?? null };\n }\n\n if (changedBook) manifest.builtAt = now().toISOString();\n\n if (write) await writeStoredBook(projectRoot, manifest, changedBook ? facts : null);\n }\n\n return {\n book: { root: projectRoot, manifest, facts, routes },\n rebuilt: changedBook,\n changed: [],\n };\n }\n }\n\n // ── Rebuild the static facts. ──\n let files: BookFile[];\n\n try {\n files = normalizeFiles(await adapter.files(projectRoot));\n } catch (error) {\n if (error instanceof GrimoireError) throw error;\n throw new GrimoireError(\n \"GR8001\",\n `The source files could not be read: ${(error as Error).message}`,\n );\n }\n\n let staticFacts: Omit<BookFacts, \"files\" | \"routes\" | \"named\">;\n\n try {\n staticFacts = {\n sites: adapter.sites ? normalizeSites(await adapter.sites(projectRoot)) : [],\n pages: adapter.pages ? normalizePages(await adapter.pages(projectRoot)) : [],\n mobile: adapter.mobile ? normalizeMobile(await adapter.mobile(projectRoot)) : [],\n tests: adapter.tests\n ? (await adapter.tests(projectRoot)).map(cleanPath)\n : files.filter((file) => file.type === \"spec\").map((file) => file.file),\n };\n } catch (error) {\n if (error instanceof GrimoireError) throw error;\n throw new GrimoireError(\n \"GR8004\",\n `Pages or screens could not be read: ${(error as Error).message}`,\n );\n }\n\n staticFacts.tests = [...new Set(staticFacts.tests)].sort();\n\n const inputs = await hashFiles(\n projectRoot,\n await routeInputFiles(projectRoot, adapter, files),\n scan.files,\n sourceRoots,\n );\n const previousBoot = stored?.manifest.boot ?? { collectedAt: null, inputs: {} };\n let boot = previousBoot;\n let bootFacts: Pick<BookFacts, \"routes\" | \"named\"> = {\n routes: stored?.facts.routes ?? null,\n named: stored?.facts.named ?? [],\n };\n let routes: RouteFreshness = hasBootFacts(adapter)\n ? bootState(previousBoot, bootFacts.routes, inputs)\n : \"missing\";\n\n if (mode === \"fresh\" && hasBootFacts(adapter) && (routes !== \"fresh\" || options.force === true)) {\n bootFacts = await collectBootFacts(projectRoot, adapter);\n boot = { collectedAt: now().toISOString(), inputs };\n routes = \"fresh\";\n }\n\n const facts: BookFacts = { files, ...bootFacts, ...staticFacts };\n const entries = entryPathsFor(facts);\n const manifest: BookManifest = {\n schemaVersion: BOOK_SCHEMA_VERSION,\n grimoireVersion: version,\n adapter: { name: adapter.name, version: adapter.version },\n builtAt: now().toISOString(),\n sourceRoots,\n files: Object.fromEntries(\n Object.entries(scan.files).map(([file, state]) => [\n file,\n { ...state, entry: entries.get(file) ?? null },\n ]),\n ),\n tests: await hashFiles(projectRoot, facts.tests, scan.files, sourceRoots),\n writtenHash: stored?.manifest.writtenHash ?? \"\",\n boot,\n };\n\n // A forced build rewrites every entry: forget what `writeBook` wrote.\n if (write) {\n if (options.force === true)\n await rm(absolutePath(projectRoot, WRITE_STATE_PATH), { force: true });\n\n await writeStoredBook(projectRoot, manifest, facts);\n }\n\n return {\n book: { root: projectRoot, manifest, facts, routes },\n rebuilt: true,\n changed: changedFiles(previousFiles, scan.files),\n };\n}\n\n/** Read the book from disk without calling an adapter; `null` when it was never built. */\nexport async function loadBook(root: string): Promise<LoadedBook | null> {\n const projectRoot = path.resolve(root);\n const stored = await readStoredBook(projectRoot);\n\n if (stored === null) return null;\n\n return {\n root: projectRoot,\n manifest: stored.manifest,\n facts: stored.facts,\n // Not checked against the sources here; `buildBook` tells fresh from stale.\n routes: stored.facts.routes === null ? \"missing\" : \"cached\",\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA6CA,MAAa,mBAAmB,GAAG,eAAe,KAAK;AAEvD,IAAI,gBAA+B;;AAGnC,SAAgB,kBAA0B;CACxC,IAAI,kBAAkB,MAAM,OAAO;CAEnC,IAAI;EACF,MAAM,WAAW,KAAK,MACpB,aAAa,IAAI,IAA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AAC,YAAY;EAC3B;EACA,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAChD,MACA;GAAE,GAAG;GAAO,OAAO,QAAQ,IAAI,IAAI,KAAK;EAAK,CAC/C,CAAC,CACH;EACA,OAAO,MAAM,UAAU,aAAa,MAAM,OAAO,KAAK,OAAO,WAAW;EACxE,aAAa,QAAQ,SAAS,eAAe;EAC7C;CACF;CAGA,IAAI,OAAO;EACT,IAAI,QAAQ,UAAU,MACpB,MAAM,GAAG,aAAa,aAAa,gBAAgB,GAAG,EAAE,OAAO,KAAK,CAAC;EAEvE,MAAM,gBAAgB,aAAa,UAAU,KAAK;CACpD;CAEA,OAAO;EACL,MAAM;GAAE,MAAM;GAAa;GAAU;GAAO;EAAO;EACnD,SAAS;EACT,SAAS,aAAa,eAAe,KAAK,KAAK;CACjD;AACF;;AAGA,eAAsB,SAAS,MAA0C;CACvE,MAAM,cAAc,KAAK,QAAQ,IAAI;CACrC,MAAM,SAAS,MAAM,eAAe,WAAW;CAE/C,IAAI,WAAW,MAAM,OAAO;CAE5B,OAAO;EACL,MAAM;EACN,UAAU,OAAO;EACjB,OAAO,OAAO;EAEd,QAAQ,OAAO,MAAM,WAAW,OAAO,YAAY;CACrD;AACF"}
1
+ {"version":3,"file":"build.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/book/build.ts"],"sourcesContent":["/**\n * `buildBook` and `loadBook`: the freshness fingerprint, the facts cache and\n * the route (boot) cache. Entries are written by `writeBook` (write.ts).\n */\nimport { readFileSync } from \"node:fs\";\nimport { rm, stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { BookAdapter, BookFacts, BookFile } from \"../contracts/adapter\";\nimport {\n BOOK_SCHEMA_VERSION,\n type BookFactsCache,\n type BookManifest,\n type BookManifestFile,\n type BuildBookOptions,\n type BuildBookResult,\n type LoadedBook,\n} from \"../contracts/book\";\nimport type { RouteFreshness } from \"../contracts/findings\";\nimport { GrimoireError } from \"../codes\";\nimport { importClosure, fileGraph } from \"../graph\";\nimport { GRIMOIRE_PATHS, isCodeFile, isInsideFolder } from \"../paths\";\nimport {\n cleanFolder,\n hashFile,\n hashIfExists,\n IO_CONCURRENCY,\n isMissing,\n listFiles,\n mapLimit,\n readJson,\n toJson,\n writeBookFile,\n} from \"./io\";\nimport {\n cleanPath,\n normalizeFiles,\n normalizeMobile,\n normalizeNamed,\n normalizePages,\n normalizeRoutes,\n normalizeSites,\n} from \"./normalize\";\nimport { entryPathsFor } from \"./render\";\n\n/** Where `writeBook` remembers what it wrote (see write.ts). */\nexport const WRITE_STATE_PATH = `${GRIMOIRE_PATHS.book}/.cache/written.json`;\n\nlet cachedVersion: string | null = null;\n\n/** The `@warlock.js/grimoire` version, from its package.json. */\nexport function grimoireVersion(): string {\n if (cachedVersion !== null) return cachedVersion;\n\n try {\n const manifest = JSON.parse(\n readFileSync(new URL(\"../../package.json\", import.meta.url), \"utf8\"),\n ) as {\n version?: unknown;\n };\n cachedVersion = typeof manifest.version === \"string\" ? manifest.version : \"0.0.0\";\n } catch {\n cachedVersion = \"0.0.0\";\n }\n\n return cachedVersion;\n}\n\nconst absolutePath = (root: string, file: string): string => path.join(root, ...file.split(\"/\"));\n\ntype StoredBook = { manifest: BookManifest; facts: BookFacts };\n\n/**\n * `facts.json` as written since type-only import edges were recorded. A cache\n * without the marker comes from an older version: it is not reused, so file\n * facts are scanned once more.\n */\ntype StoredFactsCache = BookFactsCache & { typeOnlyEdges?: boolean };\n\nasync function readStoredBook(root: string): Promise<StoredBook | null> {\n const manifest = await readJson<BookManifest>(absolutePath(root, GRIMOIRE_PATHS.bookManifest));\n const cache = await readJson<StoredFactsCache>(absolutePath(root, GRIMOIRE_PATHS.bookFactsCache));\n\n if (\n manifest === null ||\n cache === null ||\n manifest.schemaVersion !== BOOK_SCHEMA_VERSION ||\n cache.schemaVersion !== BOOK_SCHEMA_VERSION ||\n cache.typeOnlyEdges !== true ||\n typeof manifest.files !== \"object\" ||\n typeof cache.facts !== \"object\"\n ) {\n return null;\n }\n\n return { manifest, facts: cache.facts };\n}\n\n/** The current state of every code file under the source roots (images, fonts and certificates are not part of the book). */\ntype Scan = {\n files: Record<string, Omit<BookManifestFile, \"entry\">>;\n /** A file kept its hash but its size or mtime moved: the manifest needs the new stat. */\n statMoved: boolean;\n};\n\n/** Stat every code file; hash only those whose size or mtime differ from the previous manifest. */\nasync function scanSourceRoots(\n root: string,\n sourceRoots: readonly string[],\n previous: Record<string, BookManifestFile>,\n): Promise<Scan> {\n let files: string[];\n\n try {\n files = (await listFiles(root, sourceRoots)).filter(isCodeFile);\n } catch (error) {\n throw new GrimoireError(\n \"GR8001\",\n `The source roots could not be read: ${(error as Error).message}`,\n );\n }\n\n let statMoved = false;\n const states = await mapLimit(files, IO_CONCURRENCY, async (file) => {\n const absolute = absolutePath(root, file);\n\n try {\n const info = await stat(absolute);\n const before = previous[file];\n\n if (before !== undefined && before.size === info.size && before.mtimeMs === info.mtimeMs) {\n return { file, hash: before.hash, size: info.size, mtimeMs: info.mtimeMs };\n }\n\n const hash = await hashFile(absolute, info.size);\n\n if (before !== undefined && before.hash === hash) statMoved = true;\n\n return { file, hash, size: info.size, mtimeMs: info.mtimeMs };\n } catch (error) {\n // Deleted between the walk and the stat: treat it as gone.\n if (isMissing(error)) return null;\n throw new GrimoireError(\"GR8001\", `${file} could not be read: ${(error as Error).message}`);\n }\n });\n const result: Scan[\"files\"] = {};\n\n for (const state of states) {\n if (state !== null)\n result[state.file] = { hash: state.hash, size: state.size, mtimeMs: state.mtimeMs };\n }\n\n return { files: result, statMoved };\n}\n\n/** Hashes of the given files: from the scan when inside the source roots, else read (`\"\"` when missing). */\nasync function hashFiles(\n root: string,\n files: readonly string[],\n scan: Scan[\"files\"],\n sourceRoots: readonly string[],\n): Promise<Record<string, string>> {\n const hashes = await mapLimit([...new Set(files)].sort(), IO_CONCURRENCY, async (file) => {\n const scanned = scan[file];\n\n if (scanned !== undefined) return [file, scanned.hash] as const;\n // A code file inside a source root that the scan did not find is gone; any other input (a JSON config) is read.\n if (\n isCodeFile(file) &&\n sourceRoots.some((folder) => folder === \".\" || isInsideFolder(file, folder))\n )\n return [file, \"\"] as const;\n\n return [file, await hashIfExists(root, file)] as const;\n });\n\n return Object.fromEntries(hashes);\n}\n\nfunction sameRecord(left: Record<string, string>, right: Record<string, string>): boolean {\n const leftKeys = Object.keys(left);\n\n return (\n leftKeys.length === Object.keys(right).length &&\n leftKeys.every((key) => right[key] === left[key])\n );\n}\n\n/** Source files added, changed or removed between two manifests, sorted. */\nfunction changedFiles(\n previous: Record<string, BookManifestFile>,\n current: Scan[\"files\"],\n): string[] {\n const changed: string[] = [];\n\n for (const [file, state] of Object.entries(current)) {\n if (previous[file]?.hash !== state.hash) changed.push(file);\n }\n\n for (const file of Object.keys(previous)) {\n if (current[file] === undefined) changed.push(file);\n }\n\n return changed.sort();\n}\n\nconst NAMED_FILE_TYPES = new Set([\"mail\", \"job\", \"event\"]);\n\n/**\n * Files whose change makes the route cache stale: every `routes` file and\n * everything it imports, every `config` file, `warlock.config.ts`,\n * `package.json`, and every mail, job, event and notification file (the\n * named things are cached with the routes).\n */\nexport function defaultRouteInputs(files: readonly BookFile[]): string[] {\n const routesFiles = files.filter((file) => file.type === \"routes\").map((file) => file.file);\n const inputs = new Set(importClosure(fileGraph(files), routesFiles));\n\n for (const file of files) {\n if (\n file.type === \"config\" ||\n NAMED_FILE_TYPES.has(file.type) ||\n /\\.notification\\.[^/]+$/.test(file.file)\n ) {\n inputs.add(file.file);\n }\n }\n\n inputs.add(\"warlock.config.ts\");\n inputs.add(\"package.json\");\n\n return [...inputs].sort();\n}\n\n/** The route cache's input files: the adapter's list when it has one, else the default. */\nasync function routeInputFiles(\n root: string,\n adapter: BookAdapter,\n files: readonly BookFile[],\n): Promise<string[]> {\n return adapter.routeInputs\n ? (await adapter.routeInputs(root, files)).map(cleanPath)\n : defaultRouteInputs(files);\n}\n\nconst hasBootFacts = (adapter: BookAdapter): boolean =>\n typeof adapter.routes === \"function\" || typeof adapter.named === \"function\";\n\nasync function collectBootFacts(\n root: string,\n adapter: BookAdapter,\n): Promise<Pick<BookFacts, \"routes\" | \"named\">> {\n try {\n return {\n routes: adapter.routes ? normalizeRoutes(await adapter.routes(root)) : null,\n named: adapter.named ? normalizeNamed(await adapter.named(root)) : [],\n };\n } catch (error) {\n if (error instanceof GrimoireError) throw error;\n throw new GrimoireError(\"GR8002\", `Route facts could not be read: ${(error as Error).message}`);\n }\n}\n\n/** How the stored route facts relate to the current inputs. */\nfunction bootState(\n boot: BookManifest[\"boot\"],\n routes: BookFacts[\"routes\"],\n inputs: Record<string, string>,\n): \"fresh\" | \"stale\" | \"missing\" {\n if (boot.collectedAt === null || routes === null) return \"missing\";\n\n return sameRecord(boot.inputs, inputs) ? \"fresh\" : \"stale\";\n}\n\n/**\n * A fresh read that found under half the routes the book already holds is not trusted over the stored list,\n * unless the build was forced (`warlock grimoire build --force`): that is how a real removal is accepted.\n */\nfunction shrankTooFar(\n stored: BookFacts[\"routes\"],\n read: BookFacts[\"routes\"],\n force: boolean,\n): boolean {\n return (\n !force &&\n stored !== null &&\n read !== null &&\n stored.length > 0 &&\n read.length * 2 < stored.length\n );\n}\n\nconst shrankNote = (kept: number, read: number): string =>\n `a live read found ${read} routes against the ${kept} stored; kept the stored routes; run warlock grimoire build again, or warlock grimoire build --force when the routes were removed`;\n\nasync function writeStoredBook(\n root: string,\n manifest: BookManifest,\n facts: BookFacts | null,\n): Promise<void> {\n if (facts !== null) {\n const cache: StoredFactsCache = {\n schemaVersion: BOOK_SCHEMA_VERSION,\n typeOnlyEdges: true,\n facts,\n };\n await writeBookFile(root, GRIMOIRE_PATHS.bookFactsCache, toJson(cache));\n }\n\n // The manifest last: a reader that sees it also sees the facts it describes.\n await writeBookFile(root, GRIMOIRE_PATHS.bookManifest, toJson(manifest));\n}\n\n/**\n * Bring the book's facts up to date and write `manifest.json` and\n * `.cache/facts.json`. Does not write entries (see `writeBook`).\n *\n * @param root Absolute project root.\n */\nexport async function buildBook(\n root: string,\n adapter: BookAdapter,\n options: BuildBookOptions = {},\n): Promise<BuildBookResult> {\n const projectRoot = path.resolve(root);\n const mode = options.routes ?? \"cached\";\n const now = options.now ?? (() => new Date());\n // `write: false` (passed by `openGrimoire({ write: false })`) computes in memory only.\n const write = options.write !== false;\n const sourceRoots = [\n ...new Set((await adapter.sourceRoots(projectRoot)).map(cleanFolder)),\n ].sort();\n const stored = await readStoredBook(projectRoot);\n const previousFiles = stored?.manifest.files ?? {};\n const scan = await scanSourceRoots(projectRoot, sourceRoots, previousFiles);\n const version = grimoireVersion();\n\n // ── The fast path: nothing under the source roots (or the tests) changed. ──\n if (stored !== null && options.force !== true) {\n const { manifest, facts } = stored;\n const sameSetup =\n manifest.grimoireVersion === version &&\n manifest.adapter.name === adapter.name &&\n manifest.adapter.version === adapter.version &&\n manifest.sourceRoots.length === sourceRoots.length &&\n manifest.sourceRoots.every((folder, index) => folder === sourceRoots[index]);\n const sameFiles =\n sameSetup &&\n Object.keys(previousFiles).length === Object.keys(scan.files).length &&\n Object.entries(scan.files).every(([file, state]) => previousFiles[file]?.hash === state.hash);\n const sameTests =\n sameFiles &&\n sameRecord(\n manifest.tests,\n await hashFiles(projectRoot, Object.keys(manifest.tests), scan.files, sourceRoots),\n );\n\n if (sameTests) {\n const inputs = await hashFiles(\n projectRoot,\n Object.keys(manifest.boot.inputs),\n scan.files,\n sourceRoots,\n );\n let routes: RouteFreshness = hasBootFacts(adapter)\n ? bootState(manifest.boot, facts.routes, inputs)\n : \"missing\";\n let changedBook = false;\n let routeNote: string | undefined;\n\n if (mode === \"fresh\" && hasBootFacts(adapter) && routes !== \"fresh\") {\n // The stored input list can be older than the files (a cached rebuild keeps it): work it out again.\n const current = await hashFiles(\n projectRoot,\n await routeInputFiles(projectRoot, adapter, facts.files),\n scan.files,\n sourceRoots,\n );\n const read = await collectBootFacts(projectRoot, adapter);\n\n if (shrankTooFar(facts.routes, read.routes, false)) {\n routeNote = shrankNote(facts.routes?.length ?? 0, read.routes?.length ?? 0);\n routes = \"stale\";\n } else {\n Object.assign(facts, read);\n manifest.boot = {\n collectedAt: now().toISOString(),\n inputs: current,\n counts: { routes: read.routes?.length ?? 0, pages: facts.pages.length },\n };\n routes = \"fresh\";\n changedBook = true;\n }\n }\n\n if (changedBook || scan.statMoved) {\n for (const [file, state] of Object.entries(scan.files)) {\n manifest.files[file] = { ...state, entry: manifest.files[file]?.entry ?? null };\n }\n\n if (changedBook) manifest.builtAt = now().toISOString();\n\n if (write) await writeStoredBook(projectRoot, manifest, changedBook ? facts : null);\n }\n\n return {\n book: { root: projectRoot, manifest, facts, routes, ...(routeNote ? { routeNote } : {}) },\n rebuilt: changedBook,\n changed: [],\n };\n }\n }\n\n // ── Rebuild the static facts. ──\n let files: BookFile[];\n\n try {\n files = normalizeFiles(await adapter.files(projectRoot));\n } catch (error) {\n if (error instanceof GrimoireError) throw error;\n throw new GrimoireError(\n \"GR8001\",\n `The source files could not be read: ${(error as Error).message}`,\n );\n }\n\n let staticFacts: Omit<BookFacts, \"files\" | \"routes\" | \"named\">;\n\n try {\n staticFacts = {\n sites: adapter.sites ? normalizeSites(await adapter.sites(projectRoot)) : [],\n pages: adapter.pages ? normalizePages(await adapter.pages(projectRoot)) : [],\n mobile: adapter.mobile ? normalizeMobile(await adapter.mobile(projectRoot)) : [],\n tests: adapter.tests\n ? (await adapter.tests(projectRoot)).map(cleanPath)\n : files.filter((file) => file.type === \"spec\").map((file) => file.file),\n };\n } catch (error) {\n if (error instanceof GrimoireError) throw error;\n throw new GrimoireError(\n \"GR8004\",\n `Pages or screens could not be read: ${(error as Error).message}`,\n );\n }\n\n staticFacts.tests = [...new Set(staticFacts.tests)].sort();\n\n const inputs = await hashFiles(\n projectRoot,\n await routeInputFiles(projectRoot, adapter, files),\n scan.files,\n sourceRoots,\n );\n const previousBoot = stored?.manifest.boot ?? { collectedAt: null, inputs: {} };\n let boot = previousBoot;\n let routeNote: string | undefined;\n let bootFacts: Pick<BookFacts, \"routes\" | \"named\"> = {\n routes: stored?.facts.routes ?? null,\n named: stored?.facts.named ?? [],\n };\n let routes: RouteFreshness = hasBootFacts(adapter)\n ? bootState(previousBoot, bootFacts.routes, inputs)\n : \"missing\";\n\n if (mode === \"fresh\" && hasBootFacts(adapter) && (routes !== \"fresh\" || options.force === true)) {\n const read = await collectBootFacts(projectRoot, adapter);\n\n if (shrankTooFar(bootFacts.routes, read.routes, options.force === true)) {\n routeNote = shrankNote(bootFacts.routes?.length ?? 0, read.routes?.length ?? 0);\n routes = \"stale\";\n } else {\n bootFacts = read;\n boot = {\n collectedAt: now().toISOString(),\n inputs,\n counts: { routes: read.routes?.length ?? 0, pages: staticFacts.pages.length },\n };\n routes = \"fresh\";\n }\n }\n\n const facts: BookFacts = { files, ...bootFacts, ...staticFacts };\n const entries = entryPathsFor(facts);\n const manifest: BookManifest = {\n schemaVersion: BOOK_SCHEMA_VERSION,\n grimoireVersion: version,\n adapter: { name: adapter.name, version: adapter.version },\n builtAt: now().toISOString(),\n sourceRoots,\n files: Object.fromEntries(\n Object.entries(scan.files).map(([file, state]) => [\n file,\n { ...state, entry: entries.get(file) ?? null },\n ]),\n ),\n tests: await hashFiles(projectRoot, facts.tests, scan.files, sourceRoots),\n writtenHash: stored?.manifest.writtenHash ?? \"\",\n boot,\n };\n\n // A forced build rewrites every entry: forget what `writeBook` wrote.\n if (write) {\n if (options.force === true)\n await rm(absolutePath(projectRoot, WRITE_STATE_PATH), { force: true });\n\n await writeStoredBook(projectRoot, manifest, facts);\n }\n\n return {\n book: { root: projectRoot, manifest, facts, routes, ...(routeNote ? { routeNote } : {}) },\n rebuilt: true,\n changed: changedFiles(previousFiles, scan.files),\n };\n}\n\n/** Read the book from disk without calling an adapter; `null` when it was never built. */\nexport async function loadBook(root: string): Promise<LoadedBook | null> {\n const projectRoot = path.resolve(root);\n const stored = await readStoredBook(projectRoot);\n\n if (stored === null) return null;\n\n return {\n root: projectRoot,\n manifest: stored.manifest,\n facts: stored.facts,\n // Not checked against the sources here; `buildBook` tells fresh from stale.\n routes: stored.facts.routes === null ? \"missing\" : \"cached\",\n };\n}\n\n/** What `checkBook` found: the stored book, and how far the files have moved from it. */\nexport type BookCheck = {\n /** The stored book, with its route freshness measured against the files as they are now. */\n book: LoadedBook;\n /** Code and test files added, changed or removed since the last build, sorted. */\n changed: string[];\n};\n\n/**\n * The cheap change check of `buildBook` with nothing rebuilt and nothing\n * written: scans the source roots (hashing only files whose size or time\n * moved) and compares them, and the tests, with the manifest. The adapter is\n * asked for its source roots only, never for files or route facts. `null`\n * when the book was never built (or was written by an older schema).\n *\n * @param root Absolute project root.\n */\nexport async function checkBook(root: string, adapter: BookAdapter): Promise<BookCheck | null> {\n const projectRoot = path.resolve(root);\n const stored = await readStoredBook(projectRoot);\n\n if (stored === null) return null;\n\n const { manifest, facts } = stored;\n const sourceRoots = [\n ...new Set((await adapter.sourceRoots(projectRoot)).map(cleanFolder)),\n ].sort();\n const scan = await scanSourceRoots(projectRoot, sourceRoots, manifest.files);\n const changed = new Set(changedFiles(manifest.files, scan.files));\n const tests = await hashFiles(projectRoot, Object.keys(manifest.tests), scan.files, sourceRoots);\n\n for (const [file, hash] of Object.entries(tests)) {\n if (manifest.tests[file] !== hash) changed.add(file);\n }\n\n const inputs = await hashFiles(\n projectRoot,\n Object.keys(manifest.boot.inputs),\n scan.files,\n sourceRoots,\n );\n const routes: RouteFreshness = hasBootFacts(adapter)\n ? bootState(manifest.boot, facts.routes, inputs)\n : \"missing\";\n\n return {\n book: { root: projectRoot, manifest, facts, routes },\n changed: [...changed].sort(),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA6CA,MAAa,mBAAmB,GAAG,eAAe,KAAK;AAEvD,IAAI,gBAA+B;;AAGnC,SAAgB,kBAA0B;CACxC,IAAI,kBAAkB,MAAM,OAAO;CAEnC,IAAI;EACF,MAAM,WAAW,KAAK,MACpB,aAAa,IAAI,IA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CAAC,GAAG,OAAO,CAAC,CAAC,KAAK;CAC7B;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { packagesOf, renderModuleSummary } from "./render.mjs";
2
- import { buildBook, defaultRouteInputs, loadBook } from "./build.mjs";
2
+ import { buildBook, checkBook, defaultRouteInputs, loadBook } from "./build.mjs";
3
3
  import { writeBook } from "./write.mjs";
4
4
 
5
- export { buildBook, loadBook, packagesOf, writeBook };
5
+ export { buildBook, checkBook, loadBook, packagesOf, writeBook };
@@ -187,6 +187,8 @@ export declare const GRIMOIRE_CODE_LIST: readonly [GrimoireCodeDefinition & {
187
187
  readonly code: "GR9005";
188
188
  }, GrimoireCodeDefinition & {
189
189
  readonly code: "GR9006";
190
+ }, GrimoireCodeDefinition & {
191
+ readonly code: "GR9007";
190
192
  }];
191
193
  /** One registered code, as a union. */
192
194
  export type GrimoireCode = (typeof GRIMOIRE_CODE_LIST)[number]["code"];
@@ -1 +1 @@
1
- {"version":3,"file":"codes.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/codes/codes.ts"],"mappings":";;;qBA0Ca,8BAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA6vBnB,uBAAuB;;qBAGtB,gBAAgB,SAAS,OAAO,cAAc"}
1
+ {"version":3,"file":"codes.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/codes/codes.ts"],"mappings":";;;qBA0Ca,8BAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqwBnB,uBAAuB;;qBAGtB,gBAAgB,SAAS,OAAO,cAAc"}
@@ -108,7 +108,8 @@ const GRIMOIRE_CODE_LIST = [
108
108
  define("GR9003", "usage", "error", "No feature has that id", "Use an id from `grimoire/features/`.", USE),
109
109
  define("GR9004", "usage", "error", "No flow has that id", "Use `<feature>/<flow>` with a file in `grimoire/features/<feature>/flows/`.", USE),
110
110
  define("GR9005", "usage", "error", "The release file has no brief yet", "Write `grimoire/releases/<release>.md` with `release` and `date` front matter and the brief, then run the command again.", RECORD),
111
- define("GR9006", "usage", "error", "A query argument has the wrong form", "Read the command's help (`warlock scry --help`) and pass the argument in that form.", USE)
111
+ define("GR9006", "usage", "error", "A query argument has the wrong form", "Read the command's help (`warlock scry --help`) and pass the argument in that form.", USE),
112
+ define("GR9007", "usage", "error", "The book is not built", "Run `warlock grimoire build`, then ask again. `warlock scry` only reads the book; it never builds it.", USE)
112
113
  ];
113
114
  /** The catalog, keyed by code. */
114
115
  const GRIMOIRE_CODES = Object.fromEntries(GRIMOIRE_CODE_LIST.map((definition) => [definition.code, definition]));
@@ -1 +1 @@
1
- {"version":3,"file":"codes.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/codes/codes.ts"],"sourcesContent":["/**\n * The catalog of stable Grimoire finding codes.\n *\n * THE SCHEME: `GR` followed by four digits. The first digit is the area:\n *\n * | Range | Area | Meaning |\n * | ------ | --------- | ----------------------------------------------------------- |\n * | GR1xxx | structure | a written file does not follow its fixed structure |\n * | GR2xxx | links | a written name points at something that does not exist |\n * | GR3xxx | files | source files: headers, owners, files no flow reaches |\n * | GR4xxx | tests | criteria, `@proves` lines and test results |\n * | GR5xxx | apps | sites, mobile apps, pages, screens and blocks |\n * | GR6xxx | changelog | feature versions, changelogs and releases |\n * | GR7xxx | tasks | task files |\n * | GR8xxx | book | building the book from the framework's facts |\n * | GR9xxx | usage | a command or query was asked something it cannot answer |\n *\n * STABILITY: a released code keeps its meaning. Titles and fixes may be\n * reworded; a code is never reused or renumbered.\n *\n * This module imports nothing, so any entry can use it.\n */\nimport type { GrimoireCodeDefinition } from \"../contracts/findings\";\n\nfunction define<const Code extends string>(\n code: Code,\n area: GrimoireCodeDefinition[\"area\"],\n severity: GrimoireCodeDefinition[\"severity\"],\n title: string,\n fix: string,\n skill: string,\n): GrimoireCodeDefinition & { readonly code: Code } {\n return { code, area, severity, title, fix, skill };\n}\n\nconst WRITE = \"write-a-feature\";\nconst RECORD = \"record-a-change\";\nconst APP = \"describe-an-app\";\nconst FILE = \"document-a-file\";\nconst USE = \"use-the-grimoire\";\n\n/** Every code, in order. */\nexport const GRIMOIRE_CODE_LIST = [\n // ── GR1xxx structure ─────────────────────────────────────────────────────\n define(\n \"GR1001\",\n \"structure\",\n \"error\",\n \"A written file has no front matter\",\n \"Start the file with the front matter block its template shows, between two `---` lines.\",\n WRITE,\n ),\n define(\n \"GR1002\",\n \"structure\",\n \"error\",\n \"The front matter cannot be read\",\n \"Write one `key: value` per line; lists as `[a, b]` or as `- item` lines under the key; close the block with `---`.\",\n WRITE,\n ),\n define(\n \"GR1003\",\n \"structure\",\n \"error\",\n \"A required front matter key is missing\",\n \"Add the key named in the message; the template of that file lists every required key.\",\n WRITE,\n ),\n define(\n \"GR1004\",\n \"structure\",\n \"error\",\n \"A front matter value has the wrong form\",\n \"Use the form the message names: dates as yyyy-mm-dd, versions as 2.1, ids in lower-case-with-dashes, a status from the list (a task status is open, waiting for approval, approved, in progress, blocked, done or dropped; a question for the owner is waiting for approval).\",\n WRITE,\n ),\n define(\n \"GR1005\",\n \"structure\",\n \"warning\",\n \"A front matter key is not part of the template\",\n \"Remove the key, or move what it says into the body of the file.\",\n WRITE,\n ),\n define(\n \"GR1006\",\n \"structure\",\n \"error\",\n \"A required heading is missing\",\n \"Add the heading named in the message, spelled as in the template.\",\n WRITE,\n ),\n define(\n \"GR1007\",\n \"structure\",\n \"warning\",\n \"A heading is not part of the template\",\n \"Use the template's headings; put the text under one of them or remove it.\",\n WRITE,\n ),\n define(\n \"GR1008\",\n \"structure\",\n \"error\",\n \"A step line has the wrong form\",\n \"Write steps as `1. route POST /wishlist`: a number, a kind, then the name used in code.\",\n WRITE,\n ),\n define(\n \"GR1009\",\n \"structure\",\n \"error\",\n \"A step names an unknown kind\",\n \"Use one of: page, route, mail, notification, job, event, outside service, affects.\",\n WRITE,\n ),\n define(\n \"GR1010\",\n \"structure\",\n \"error\",\n \"Steps are not numbered 1, 2, 3 in order\",\n \"Number the steps from 1 without gaps, in the order a user meets them.\",\n WRITE,\n ),\n define(\n \"GR1011\",\n \"structure\",\n \"error\",\n \"A case line has the wrong form\",\n \"Write cases as `- double submit two taps save once`: the question, spaces, then the answer.\",\n WRITE,\n ),\n define(\n \"GR1012\",\n \"structure\",\n \"warning\",\n \"A case question is not answered\",\n \"Answer the question under Cases (or `does not apply` and why), or list it under Not handled. A flow with no writes (only pages and GET, HEAD or OPTIONS routes) may leave out `duplicate` and `double submit`.\",\n WRITE,\n ),\n define(\n \"GR1013\",\n \"structure\",\n \"error\",\n \"A criterion line has the wrong form\",\n \"Write criteria as `- AC-3 a guest is sent to sign in`, optionally `- AC-4 [mobile] …`.\",\n WRITE,\n ),\n define(\n \"GR1014\",\n \"structure\",\n \"error\",\n \"A criterion id is used twice in one flow\",\n \"Give the new criterion the next free number. Never renumber existing criteria.\",\n WRITE,\n ),\n define(\n \"GR1015\",\n \"structure\",\n \"error\",\n \"A changelog line has the wrong form\",\n \"Write entries as `- 2.1 fixed new-arrivals: what changed (AC-2)`.\",\n RECORD,\n ),\n define(\n \"GR1016\",\n \"structure\",\n \"error\",\n \"A changelog entry uses an unknown word\",\n \"Use one of: added, changed, fixed, removed.\",\n RECORD,\n ),\n define(\n \"GR1017\",\n \"structure\",\n \"error\",\n \"A changelog heading has the wrong form\",\n \"Use `## Unreleased`, or `## <release> (<yyyy-mm-dd>)` for entries of a release.\",\n RECORD,\n ),\n define(\n \"GR1018\",\n \"structure\",\n \"error\",\n \"A blocks table has the wrong form\",\n \"Use the columns Block, Flow, Who sees it, Changes with; one row per part of the page.\",\n APP,\n ),\n define(\n \"GR1019\",\n \"structure\",\n \"error\",\n \"An id does not match its folder or file name\",\n \"Make the front matter `id` (or `release`) equal the folder or file name.\",\n WRITE,\n ),\n define(\n \"GR1020\",\n \"structure\",\n \"warning\",\n \"A file in the grimoire folder is not part of the layout\",\n \"Move the file to where the layout expects it, or remove it.\",\n USE,\n ),\n define(\n \"GR1021\",\n \"structure\",\n \"error\",\n \"A feature, app, page or screen folder has no README.md\",\n \"Add README.md with the front matter of its template.\",\n WRITE,\n ),\n define(\n \"GR1022\",\n \"structure\",\n \"error\",\n \"Two files use the same id\",\n \"Give each feature, app or task its own id.\",\n WRITE,\n ),\n define(\n \"GR1023\",\n \"structure\",\n \"error\",\n \"A task file is misnamed or misplaced\",\n \"Name tasks `T-<n>-<slug>.md`, in `tasks/open/` or `tasks/done/<yyyy-mm>/`.\",\n RECORD,\n ),\n define(\n \"GR1024\",\n \"structure\",\n \"error\",\n \"The collected-list markers of a release file are broken\",\n \"Keep the start and end markers in pairs, or remove both and run `warlock grimoire release` again.\",\n RECORD,\n ),\n define(\n \"GR1025\",\n \"structure\",\n \"error\",\n \"A written file cannot be read\",\n \"Save the file as UTF-8 text.\",\n USE,\n ),\n define(\n \"GR1026\",\n \"structure\",\n \"error\",\n \"The feature README lists a flow that has no file\",\n \"Add `flows/<flow>.md`, or remove the flow from the README's Flows list.\",\n WRITE,\n ),\n define(\n \"GR1027\",\n \"structure\",\n \"warning\",\n \"A flow file is not listed in the feature README\",\n \"Add the flow to the README's Flows list.\",\n WRITE,\n ),\n define(\n \"GR1028\",\n \"structure\",\n \"error\",\n \"A list line has the wrong form\",\n \"Write list lines as `- name text`: the name, spaces, then the text.\",\n WRITE,\n ),\n define(\n \"GR1029\",\n \"structure\",\n \"warning\",\n \"An image line points outside grimoire/screenshots\",\n \"Keep screenshots in `grimoire/screenshots/` and write the path relative to the Markdown file, like `![Product page](../../../screenshots/web/product.png)`.\",\n WRITE,\n ),\n define(\n \"GR1030\",\n \"structure\",\n \"warning\",\n \"A flow has no summary\",\n \"Write one or two plain sentences under the flow's `# Title`: who does what, and what they get.\",\n WRITE,\n ),\n\n // ── GR2xxx links ─────────────────────────────────────────────────────────\n define(\n \"GR2001\",\n \"links\",\n \"error\",\n \"A route step names a route that does not exist\",\n \"Fix the method and path in the flow, or add the route in code.\",\n RECORD,\n ),\n define(\n \"GR2002\",\n \"links\",\n \"error\",\n \"A page step names a page that does not exist\",\n \"Fix the route path in the flow, or add the page to one of the feature's apps. A step scoped like `page /support [web-admin]` looks only in that app.\",\n RECORD,\n ),\n define(\n \"GR2003\",\n \"links\",\n \"error\",\n \"A mail step names a mail that does not exist\",\n \"Use the mail's name as code defines it, or add the mail.\",\n RECORD,\n ),\n define(\n \"GR2004\",\n \"links\",\n \"error\",\n \"A notification step names a notification that does not exist\",\n \"Use the notification's name as code defines it, or add it.\",\n RECORD,\n ),\n define(\n \"GR2005\",\n \"links\",\n \"error\",\n \"A job step names a job that does not exist\",\n \"Use the job's name as code defines it, or add the job.\",\n RECORD,\n ),\n define(\n \"GR2006\",\n \"links\",\n \"error\",\n \"An event step names an event that does not exist\",\n \"Use the event's name as code emits it, or add the event.\",\n RECORD,\n ),\n define(\n \"GR2007\",\n \"links\",\n \"error\",\n \"An affects step names a feature or flow that does not exist\",\n \"Write `affects <feature>/<flow>` with an existing feature and flow.\",\n WRITE,\n ),\n define(\n \"GR2008\",\n \"links\",\n \"error\",\n \"A name refers to an app with no folder\",\n \"Add `grimoire/apps/<app>/README.md`, or fix the app id.\",\n APP,\n ),\n define(\n \"GR2009\",\n \"links\",\n \"warning\",\n \"A flow names an app its feature does not list\",\n \"Add the app to the feature's `apps`, or fix the app id in Differs by app or the criterion.\",\n WRITE,\n ),\n define(\n \"GR2010\",\n \"links\",\n \"error\",\n \"A changelog entry names a flow that does not exist\",\n \"Fix the flow id before the `:`, or add the flow.\",\n RECORD,\n ),\n define(\n \"GR2011\",\n \"links\",\n \"error\",\n \"A changelog entry names a criterion the flow does not have\",\n \"Fix the criterion id, or add the criterion to the flow.\",\n RECORD,\n ),\n define(\n \"GR2012\",\n \"links\",\n \"error\",\n \"A README relation names a flow that does not exist\",\n \"Fix the `<feature>/<flow>` reference in Affects and affected by.\",\n WRITE,\n ),\n define(\n \"GR2013\",\n \"links\",\n \"error\",\n \"A case names a criterion the flow does not have\",\n \"Fix the `(AC-n)` at the end of the case line, or add the criterion under Acceptance criteria.\",\n WRITE,\n ),\n define(\n \"GR2014\",\n \"links\",\n \"warning\",\n \"An image line names a screenshot file that does not exist\",\n \"Add the image under `grimoire/screenshots/`, or fix the path.\",\n WRITE,\n ),\n\n // ── GR3xxx files ─────────────────────────────────────────────────────────\n define(\n \"GR3001\",\n \"files\",\n \"warning\",\n \"A source file has no header sentence\",\n \"Start the file with a one-sentence comment saying why it exists.\",\n FILE,\n ),\n define(\n \"GR3002\",\n \"files\",\n \"warning\",\n \"A source file belongs to no feature\",\n \"Add its folder to a feature's `folders`, or tag it `@feature <id>` in its header.\",\n FILE,\n ),\n define(\n \"GR3003\",\n \"files\",\n \"error\",\n \"A source file has two owners\",\n \"Keep one owner: remove the duplicate folder from one feature, or keep one `@feature` tag.\",\n FILE,\n ),\n define(\n \"GR3004\",\n \"files\",\n \"error\",\n \"A `@feature` tag names a feature that does not exist\",\n \"Fix the tag, or write the feature.\",\n FILE,\n ),\n define(\n \"GR3005\",\n \"files\",\n \"error\",\n \"A feature's `folders` entry does not exist\",\n \"Fix the folder or file path, or remove it from `folders`.\",\n WRITE,\n ),\n define(\n \"GR3006\",\n \"files\",\n \"warning\",\n \"A file in a feature's folders is reached by no flow\",\n \"Describe the behaviour in a flow, or delete dead code.\",\n RECORD,\n ),\n\n // ── GR4xxx tests ─────────────────────────────────────────────────────────\n define(\n \"GR4001\",\n \"tests\",\n \"warning\",\n \"A criterion has no test\",\n \"Write a test with `// @proves <feature>/<flow> AC-<n>` above it, or say in the task why not.\",\n RECORD,\n ),\n define(\n \"GR4002\",\n \"tests\",\n \"error\",\n \"A `@proves` line names a flow or criterion that does not exist\",\n \"Fix the `@proves` line to name an existing `<feature>/<flow> AC-<n>`.\",\n RECORD,\n ),\n define(\n \"GR4003\",\n \"tests\",\n \"error\",\n \"A `@proves` line has the wrong form\",\n \"Write `// @proves <feature>/<flow> AC-<n>` on its own line.\",\n RECORD,\n ),\n define(\n \"GR4004\",\n \"tests\",\n \"error\",\n \"A `@proves` line is not directly above a test\",\n \"Move the line right above the `it(…)` or `test(…)` it describes.\",\n RECORD,\n ),\n define(\n \"GR4005\",\n \"tests\",\n \"warning\",\n \"One test proves two criteria\",\n \"Split the test so each proves one criterion.\",\n RECORD,\n ),\n define(\n \"GR4006\",\n \"tests\",\n \"error\",\n \"A test proving a criterion failed in its last run\",\n \"Fix the code or the test, then run the tests again.\",\n RECORD,\n ),\n define(\n \"GR4007\",\n \"tests\",\n \"warning\",\n \"A criterion's test result is older than the test file\",\n \"Run the tests again.\",\n RECORD,\n ),\n define(\n \"GR4008\",\n \"tests\",\n \"warning\",\n \"A criterion's test did not run in the last run\",\n \"Run the tests that prove the criterion.\",\n RECORD,\n ),\n define(\n \"GR4009\",\n \"tests\",\n \"warning\",\n \"Tests prove criteria but no test results are recorded\",\n \"Add `grimoireReporter()` from `@warlock.js/grimoire/vitest` to `test.reporters` in the Vitest config and run the tests; in production, ship the results file with the deploy.\",\n RECORD,\n ),\n define(\n \"GR4010\",\n \"tests\",\n \"warning\",\n \"The reporter could not match a proving test to its result\",\n \"Keep the `it(...)` or `test(...)` call on the line right under the `@proves` comment, with a plain string name.\",\n RECORD,\n ),\n\n // ── GR5xxx apps ──────────────────────────────────────────────────────────\n define(\n \"GR5001\",\n \"apps\",\n \"error\",\n \"A block points to a flow that does not exist\",\n \"Fix the `<feature>/<flow>` in the Flow column or the block file.\",\n APP,\n ),\n define(\n \"GR5002\",\n \"apps\",\n \"error\",\n \"A condition is not declared in the app README\",\n \"Add the condition under Conditions in the app README, or use a declared one.\",\n APP,\n ),\n define(\n \"GR5003\",\n \"apps\",\n \"error\",\n \"A page's route does not exist in its site\",\n \"Fix the `route` of the page file, or remove the page file if the page is gone.\",\n APP,\n ),\n define(\n \"GR5004\",\n \"apps\",\n \"error\",\n \"A page names a layout with no file\",\n \"Add `layouts/<layout>.md` to the app, or fix the page's `layout`.\",\n APP,\n ),\n define(\n \"GR5005\",\n \"apps\",\n \"error\",\n \"An app's root matches no site or mobile app\",\n \"Set `root` to the site folder (`src/web/$sites/<site>`) or the mobile app folder.\",\n APP,\n ),\n define(\n \"GR5006\",\n \"apps\",\n \"error\",\n \"A screen's route does not exist in the mobile app\",\n \"Fix the `route` of the screen file, or remove it if the screen is gone.\",\n APP,\n ),\n define(\n \"GR5007\",\n \"apps\",\n \"warning\",\n \"A block file has no row in its page's Blocks table\",\n \"Add the block to the page's Blocks table, or remove the block file.\",\n APP,\n ),\n define(\n \"GR5008\",\n \"apps\",\n \"error\",\n \"An entry point in Also reached from does not exist\",\n \"Fix the mail, notification or page name.\",\n APP,\n ),\n define(\n \"GR5009\",\n \"apps\",\n \"warning\",\n \"A site or mobile app has no folder in grimoire/apps\",\n \"Add `grimoire/apps/<app>/README.md` for it.\",\n APP,\n ),\n define(\n \"GR5010\",\n \"apps\",\n \"warning\",\n \"A name in backticks in Changes with is not a declared condition\",\n \"Declare the condition under Conditions in the app README, fix the name, or write it without backticks when it is not a condition.\",\n APP,\n ),\n\n // ── GR6xxx changelog ─────────────────────────────────────────────────────\n define(\n \"GR6001\",\n \"changelog\",\n \"error\",\n \"A release lists a changelog entry that is not stamped with it\",\n \"Move the entry under `## <release> (<date>)` in the feature's CHANGELOG.md.\",\n RECORD,\n ),\n define(\n \"GR6002\",\n \"changelog\",\n \"error\",\n \"A changelog release section has no release file\",\n \"Write `grimoire/releases/<release>.md`, or fix the release in the heading.\",\n RECORD,\n ),\n define(\n \"GR6003\",\n \"changelog\",\n \"error\",\n \"A changelog release date differs from the release file\",\n \"Use the date in the release file's front matter.\",\n RECORD,\n ),\n define(\n \"GR6004\",\n \"changelog\",\n \"error\",\n \"The README `updated` is older than the newest changelog entry\",\n \"Reshape the README to describe the feature as it is now, and set `updated`.\",\n RECORD,\n ),\n define(\n \"GR6005\",\n \"changelog\",\n \"error\",\n \"The README `version` differs from the newest changelog entry\",\n \"Set `version` to the newest entry's version.\",\n RECORD,\n ),\n define(\n \"GR6006\",\n \"changelog\",\n \"warning\",\n \"A changelog word does not match its version step\",\n \"Use a whole-number version for added and removed, a decimal for changed and fixed.\",\n RECORD,\n ),\n define(\n \"GR6007\",\n \"changelog\",\n \"error\",\n \"A flow's `since` is newer than its feature's version\",\n \"Fix `since`, or the feature `version`.\",\n WRITE,\n ),\n define(\n \"GR6008\",\n \"changelog\",\n \"warning\",\n \"A new whole-number version has no brief\",\n \"Write `versions/v<n>.md` before building it.\",\n WRITE,\n ),\n\n // ── GR7xxx tasks ─────────────────────────────────────────────────────────\n define(\n \"GR7001\",\n \"tasks\",\n \"error\",\n \"A task names a feature that does not exist\",\n \"Fix the task's `feature`, or write the feature first.\",\n WRITE,\n ),\n define(\n \"GR7002\",\n \"tasks\",\n \"error\",\n \"A task names a flow that does not exist\",\n \"Fix the task's `flow`, or write the flow first.\",\n WRITE,\n ),\n define(\n \"GR7003\",\n \"tasks\",\n \"error\",\n \"A task's status does not match its folder\",\n \"Done tasks live in `tasks/done/<yyyy-mm>/` with `status: done` and `shipped`; open tasks in `tasks/open/`.\",\n RECORD,\n ),\n define(\n \"GR7004\",\n \"tasks\",\n \"error\",\n \"A task's `shipped` names a version the changelog does not have\",\n \"Fix `shipped: <feature> <version>`, or add the changelog entry.\",\n RECORD,\n ),\n define(\n \"GR7005\",\n \"tasks\",\n \"warning\",\n \"A task's brief does not exist\",\n \"Fix the `Brief:` path, or write the brief.\",\n WRITE,\n ),\n\n // ── GR8xxx book ──────────────────────────────────────────────────────────\n define(\n \"GR8001\",\n \"book\",\n \"error\",\n \"The project's source files could not be read\",\n \"Read the message; fix the file or folder it names, then build again.\",\n USE,\n ),\n define(\n \"GR8002\",\n \"book\",\n \"warning\",\n \"Route facts could not be read because the app did not boot\",\n \"Run `warlock doctor`, fix what stops the app from booting, then `warlock grimoire build`.\",\n USE,\n ),\n define(\n \"GR8003\",\n \"book\",\n \"warning\",\n \"Route facts are older than the routes files\",\n \"Run `warlock grimoire build` to refresh them.\",\n USE,\n ),\n define(\n \"GR8004\",\n \"book\",\n \"warning\",\n \"Pages or screens could not be read\",\n \"Read the message; fix the page file it names, then build again.\",\n USE,\n ),\n\n // ── GR9xxx usage ─────────────────────────────────────────────────────────\n define(\n \"GR9001\",\n \"usage\",\n \"error\",\n \"The file is not in the book\",\n \"Pass a code file under the source roots, as a project-relative path.\",\n USE,\n ),\n define(\n \"GR9002\",\n \"usage\",\n \"error\",\n \"No route matches\",\n 'Pass `\"<METHOD> <path>\"` as the route is registered; `warlock routes` lists them.',\n USE,\n ),\n define(\n \"GR9003\",\n \"usage\",\n \"error\",\n \"No feature has that id\",\n \"Use an id from `grimoire/features/`.\",\n USE,\n ),\n define(\n \"GR9004\",\n \"usage\",\n \"error\",\n \"No flow has that id\",\n \"Use `<feature>/<flow>` with a file in `grimoire/features/<feature>/flows/`.\",\n USE,\n ),\n define(\n \"GR9005\",\n \"usage\",\n \"error\",\n \"The release file has no brief yet\",\n \"Write `grimoire/releases/<release>.md` with `release` and `date` front matter and the brief, then run the command again.\",\n RECORD,\n ),\n define(\n \"GR9006\",\n \"usage\",\n \"error\",\n \"A query argument has the wrong form\",\n \"Read the command's help (`warlock scry --help`) and pass the argument in that form.\",\n USE,\n ),\n] as const;\n\n/** One registered code, as a union. */\nexport type GrimoireCode = (typeof GRIMOIRE_CODE_LIST)[number][\"code\"];\n\n/** The catalog, keyed by code. */\nexport const GRIMOIRE_CODES: Readonly<Record<GrimoireCode, GrimoireCodeDefinition>> =\n Object.fromEntries(\n GRIMOIRE_CODE_LIST.map((definition) => [definition.code, definition]),\n ) as Record<GrimoireCode, GrimoireCodeDefinition>;\n"],"mappings":";AAwBA,SAAS,OACP,MACA,MACA,UACA,OACA,KACA,OACkD;CAClD,OAAO;EAAE;EAAM;EAAM;EAAU;EAAO;EAAK;CAAM;AACnD;AAEA,MAAM,QAAQ;AACd,MAAM,SAAS;AACf,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;;AAGZ,MAAa,qBAAqB;CAEhC,OACE,UACA,aACA,SACA,sCACA,2FACA,KACF;CACA,OACE,UACA,aACA,SACA,mCACA,sHACA,KACF;CACA,OACE,UACA,aACA,SACA,0CACA,yFACA,KACF;CACA,OACE,UACA,aACA,SACA,2CACA,iRACA,KACF;CACA,OACE,UACA,aACA,WACA,kDACA,mEACA,KACF;CACA,OACE,UACA,aACA,SACA,iCACA,qEACA,KACF;CACA,OACE,UACA,aACA,WACA,yCACA,6EACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,6FACA,KACF;CACA,OACE,UACA,aACA,SACA,gCACA,sFACA,KACF;CACA,OACE,UACA,aACA,SACA,2CACA,yEACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,iGACA,KACF;CACA,OACE,UACA,aACA,WACA,mCACA,kNACA,KACF;CACA,OACE,UACA,aACA,SACA,uCACA,8FACA,KACF;CACA,OACE,UACA,aACA,SACA,4CACA,kFACA,KACF;CACA,OACE,UACA,aACA,SACA,uCACA,wEACA,MACF;CACA,OACE,UACA,aACA,SACA,0CACA,+CACA,MACF;CACA,OACE,UACA,aACA,SACA,0CACA,mFACA,MACF;CACA,OACE,UACA,aACA,SACA,qCACA,yFACA,GACF;CACA,OACE,UACA,aACA,SACA,gDACA,4EACA,KACF;CACA,OACE,UACA,aACA,WACA,2DACA,+DACA,GACF;CACA,OACE,UACA,aACA,SACA,0DACA,wDACA,KACF;CACA,OACE,UACA,aACA,SACA,6BACA,8CACA,KACF;CACA,OACE,UACA,aACA,SACA,wCACA,8EACA,MACF;CACA,OACE,UACA,aACA,SACA,2DACA,qGACA,MACF;CACA,OACE,UACA,aACA,SACA,iCACA,gCACA,GACF;CACA,OACE,UACA,aACA,SACA,oDACA,2EACA,KACF;CACA,OACE,UACA,aACA,WACA,mDACA,4CACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,yEACA,KACF;CACA,OACE,UACA,aACA,WACA,qDACA,+JACA,KACF;CACA,OACE,UACA,aACA,WACA,yBACA,kGACA,KACF;CAGA,OACE,UACA,SACA,SACA,kDACA,kEACA,MACF;CACA,OACE,UACA,SACA,SACA,gDACA,wJACA,MACF;CACA,OACE,UACA,SACA,SACA,gDACA,4DACA,MACF;CACA,OACE,UACA,SACA,SACA,gEACA,8DACA,MACF;CACA,OACE,UACA,SACA,SACA,8CACA,0DACA,MACF;CACA,OACE,UACA,SACA,SACA,oDACA,4DACA,MACF;CACA,OACE,UACA,SACA,SACA,+DACA,yEACA,KACF;CACA,OACE,UACA,SACA,SACA,0CACA,2DACA,GACF;CACA,OACE,UACA,SACA,WACA,iDACA,8FACA,KACF;CACA,OACE,UACA,SACA,SACA,sDACA,oDACA,MACF;CACA,OACE,UACA,SACA,SACA,8DACA,2DACA,MACF;CACA,OACE,UACA,SACA,SACA,sDACA,oEACA,KACF;CACA,OACE,UACA,SACA,SACA,mDACA,iGACA,KACF;CACA,OACE,UACA,SACA,WACA,6DACA,iEACA,KACF;CAGA,OACE,UACA,SACA,WACA,wCACA,oEACA,IACF;CACA,OACE,UACA,SACA,WACA,uCACA,qFACA,IACF;CACA,OACE,UACA,SACA,SACA,gCACA,6FACA,IACF;CACA,OACE,UACA,SACA,SACA,wDACA,sCACA,IACF;CACA,OACE,UACA,SACA,SACA,8CACA,6DACA,KACF;CACA,OACE,UACA,SACA,WACA,uDACA,0DACA,MACF;CAGA,OACE,UACA,SACA,WACA,2BACA,gGACA,MACF;CACA,OACE,UACA,SACA,SACA,kEACA,yEACA,MACF;CACA,OACE,UACA,SACA,SACA,uCACA,+DACA,MACF;CACA,OACE,UACA,SACA,SACA,iDACA,oEACA,MACF;CACA,OACE,UACA,SACA,WACA,gCACA,gDACA,MACF;CACA,OACE,UACA,SACA,SACA,qDACA,uDACA,MACF;CACA,OACE,UACA,SACA,WACA,yDACA,wBACA,MACF;CACA,OACE,UACA,SACA,WACA,kDACA,2CACA,MACF;CACA,OACE,UACA,SACA,WACA,yDACA,iLACA,MACF;CACA,OACE,UACA,SACA,WACA,6DACA,mHACA,MACF;CAGA,OACE,UACA,QACA,SACA,gDACA,oEACA,GACF;CACA,OACE,UACA,QACA,SACA,iDACA,gFACA,GACF;CACA,OACE,UACA,QACA,SACA,6CACA,kFACA,GACF;CACA,OACE,UACA,QACA,SACA,sCACA,qEACA,GACF;CACA,OACE,UACA,QACA,SACA,+CACA,qFACA,GACF;CACA,OACE,UACA,QACA,SACA,qDACA,2EACA,GACF;CACA,OACE,UACA,QACA,WACA,sDACA,uEACA,GACF;CACA,OACE,UACA,QACA,SACA,sDACA,4CACA,GACF;CACA,OACE,UACA,QACA,WACA,uDACA,+CACA,GACF;CACA,OACE,UACA,QACA,WACA,mEACA,qIACA,GACF;CAGA,OACE,UACA,aACA,SACA,iEACA,+EACA,MACF;CACA,OACE,UACA,aACA,SACA,mDACA,8EACA,MACF;CACA,OACE,UACA,aACA,SACA,0DACA,oDACA,MACF;CACA,OACE,UACA,aACA,SACA,iEACA,+EACA,MACF;CACA,OACE,UACA,aACA,SACA,gEACA,gDACA,MACF;CACA,OACE,UACA,aACA,WACA,oDACA,sFACA,MACF;CACA,OACE,UACA,aACA,SACA,wDACA,0CACA,KACF;CACA,OACE,UACA,aACA,WACA,2CACA,gDACA,KACF;CAGA,OACE,UACA,SACA,SACA,8CACA,yDACA,KACF;CACA,OACE,UACA,SACA,SACA,2CACA,mDACA,KACF;CACA,OACE,UACA,SACA,SACA,6CACA,8GACA,MACF;CACA,OACE,UACA,SACA,SACA,kEACA,mEACA,MACF;CACA,OACE,UACA,SACA,WACA,iCACA,8CACA,KACF;CAGA,OACE,UACA,QACA,SACA,gDACA,wEACA,GACF;CACA,OACE,UACA,QACA,WACA,8DACA,6FACA,GACF;CACA,OACE,UACA,QACA,WACA,+CACA,iDACA,GACF;CACA,OACE,UACA,QACA,WACA,sCACA,mEACA,GACF;CAGA,OACE,UACA,SACA,SACA,+BACA,wEACA,GACF;CACA,OACE,UACA,SACA,SACA,oBACA,uFACA,GACF;CACA,OACE,UACA,SACA,SACA,0BACA,wCACA,GACF;CACA,OACE,UACA,SACA,SACA,uBACA,+EACA,GACF;CACA,OACE,UACA,SACA,SACA,qCACA,4HACA,MACF;CACA,OACE,UACA,SACA,SACA,uCACA,uFACA,GACF;AACF;;AAMA,MAAa,iBACX,OAAO,YACL,mBAAmB,KAAK,eAAe,CAAC,WAAW,MAAM,UAAU,CAAC,CACtE"}
1
+ {"version":3,"file":"codes.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/codes/codes.ts"],"sourcesContent":["/**\n * The catalog of stable Grimoire finding codes.\n *\n * THE SCHEME: `GR` followed by four digits. The first digit is the area:\n *\n * | Range | Area | Meaning |\n * | ------ | --------- | ----------------------------------------------------------- |\n * | GR1xxx | structure | a written file does not follow its fixed structure |\n * | GR2xxx | links | a written name points at something that does not exist |\n * | GR3xxx | files | source files: headers, owners, files no flow reaches |\n * | GR4xxx | tests | criteria, `@proves` lines and test results |\n * | GR5xxx | apps | sites, mobile apps, pages, screens and blocks |\n * | GR6xxx | changelog | feature versions, changelogs and releases |\n * | GR7xxx | tasks | task files |\n * | GR8xxx | book | building the book from the framework's facts |\n * | GR9xxx | usage | a command or query was asked something it cannot answer |\n *\n * STABILITY: a released code keeps its meaning. Titles and fixes may be\n * reworded; a code is never reused or renumbered.\n *\n * This module imports nothing, so any entry can use it.\n */\nimport type { GrimoireCodeDefinition } from \"../contracts/findings\";\n\nfunction define<const Code extends string>(\n code: Code,\n area: GrimoireCodeDefinition[\"area\"],\n severity: GrimoireCodeDefinition[\"severity\"],\n title: string,\n fix: string,\n skill: string,\n): GrimoireCodeDefinition & { readonly code: Code } {\n return { code, area, severity, title, fix, skill };\n}\n\nconst WRITE = \"write-a-feature\";\nconst RECORD = \"record-a-change\";\nconst APP = \"describe-an-app\";\nconst FILE = \"document-a-file\";\nconst USE = \"use-the-grimoire\";\n\n/** Every code, in order. */\nexport const GRIMOIRE_CODE_LIST = [\n // ── GR1xxx structure ─────────────────────────────────────────────────────\n define(\n \"GR1001\",\n \"structure\",\n \"error\",\n \"A written file has no front matter\",\n \"Start the file with the front matter block its template shows, between two `---` lines.\",\n WRITE,\n ),\n define(\n \"GR1002\",\n \"structure\",\n \"error\",\n \"The front matter cannot be read\",\n \"Write one `key: value` per line; lists as `[a, b]` or as `- item` lines under the key; close the block with `---`.\",\n WRITE,\n ),\n define(\n \"GR1003\",\n \"structure\",\n \"error\",\n \"A required front matter key is missing\",\n \"Add the key named in the message; the template of that file lists every required key.\",\n WRITE,\n ),\n define(\n \"GR1004\",\n \"structure\",\n \"error\",\n \"A front matter value has the wrong form\",\n \"Use the form the message names: dates as yyyy-mm-dd, versions as 2.1, ids in lower-case-with-dashes, a status from the list (a task status is open, waiting for approval, approved, in progress, blocked, done or dropped; a question for the owner is waiting for approval).\",\n WRITE,\n ),\n define(\n \"GR1005\",\n \"structure\",\n \"warning\",\n \"A front matter key is not part of the template\",\n \"Remove the key, or move what it says into the body of the file.\",\n WRITE,\n ),\n define(\n \"GR1006\",\n \"structure\",\n \"error\",\n \"A required heading is missing\",\n \"Add the heading named in the message, spelled as in the template.\",\n WRITE,\n ),\n define(\n \"GR1007\",\n \"structure\",\n \"warning\",\n \"A heading is not part of the template\",\n \"Use the template's headings; put the text under one of them or remove it.\",\n WRITE,\n ),\n define(\n \"GR1008\",\n \"structure\",\n \"error\",\n \"A step line has the wrong form\",\n \"Write steps as `1. route POST /wishlist`: a number, a kind, then the name used in code.\",\n WRITE,\n ),\n define(\n \"GR1009\",\n \"structure\",\n \"error\",\n \"A step names an unknown kind\",\n \"Use one of: page, route, mail, notification, job, event, outside service, affects.\",\n WRITE,\n ),\n define(\n \"GR1010\",\n \"structure\",\n \"error\",\n \"Steps are not numbered 1, 2, 3 in order\",\n \"Number the steps from 1 without gaps, in the order a user meets them.\",\n WRITE,\n ),\n define(\n \"GR1011\",\n \"structure\",\n \"error\",\n \"A case line has the wrong form\",\n \"Write cases as `- double submit two taps save once`: the question, spaces, then the answer.\",\n WRITE,\n ),\n define(\n \"GR1012\",\n \"structure\",\n \"warning\",\n \"A case question is not answered\",\n \"Answer the question under Cases (or `does not apply` and why), or list it under Not handled. A flow with no writes (only pages and GET, HEAD or OPTIONS routes) may leave out `duplicate` and `double submit`.\",\n WRITE,\n ),\n define(\n \"GR1013\",\n \"structure\",\n \"error\",\n \"A criterion line has the wrong form\",\n \"Write criteria as `- AC-3 a guest is sent to sign in`, optionally `- AC-4 [mobile] …`.\",\n WRITE,\n ),\n define(\n \"GR1014\",\n \"structure\",\n \"error\",\n \"A criterion id is used twice in one flow\",\n \"Give the new criterion the next free number. Never renumber existing criteria.\",\n WRITE,\n ),\n define(\n \"GR1015\",\n \"structure\",\n \"error\",\n \"A changelog line has the wrong form\",\n \"Write entries as `- 2.1 fixed new-arrivals: what changed (AC-2)`.\",\n RECORD,\n ),\n define(\n \"GR1016\",\n \"structure\",\n \"error\",\n \"A changelog entry uses an unknown word\",\n \"Use one of: added, changed, fixed, removed.\",\n RECORD,\n ),\n define(\n \"GR1017\",\n \"structure\",\n \"error\",\n \"A changelog heading has the wrong form\",\n \"Use `## Unreleased`, or `## <release> (<yyyy-mm-dd>)` for entries of a release.\",\n RECORD,\n ),\n define(\n \"GR1018\",\n \"structure\",\n \"error\",\n \"A blocks table has the wrong form\",\n \"Use the columns Block, Flow, Who sees it, Changes with; one row per part of the page.\",\n APP,\n ),\n define(\n \"GR1019\",\n \"structure\",\n \"error\",\n \"An id does not match its folder or file name\",\n \"Make the front matter `id` (or `release`) equal the folder or file name.\",\n WRITE,\n ),\n define(\n \"GR1020\",\n \"structure\",\n \"warning\",\n \"A file in the grimoire folder is not part of the layout\",\n \"Move the file to where the layout expects it, or remove it.\",\n USE,\n ),\n define(\n \"GR1021\",\n \"structure\",\n \"error\",\n \"A feature, app, page or screen folder has no README.md\",\n \"Add README.md with the front matter of its template.\",\n WRITE,\n ),\n define(\n \"GR1022\",\n \"structure\",\n \"error\",\n \"Two files use the same id\",\n \"Give each feature, app or task its own id.\",\n WRITE,\n ),\n define(\n \"GR1023\",\n \"structure\",\n \"error\",\n \"A task file is misnamed or misplaced\",\n \"Name tasks `T-<n>-<slug>.md`, in `tasks/open/` or `tasks/done/<yyyy-mm>/`.\",\n RECORD,\n ),\n define(\n \"GR1024\",\n \"structure\",\n \"error\",\n \"The collected-list markers of a release file are broken\",\n \"Keep the start and end markers in pairs, or remove both and run `warlock grimoire release` again.\",\n RECORD,\n ),\n define(\n \"GR1025\",\n \"structure\",\n \"error\",\n \"A written file cannot be read\",\n \"Save the file as UTF-8 text.\",\n USE,\n ),\n define(\n \"GR1026\",\n \"structure\",\n \"error\",\n \"The feature README lists a flow that has no file\",\n \"Add `flows/<flow>.md`, or remove the flow from the README's Flows list.\",\n WRITE,\n ),\n define(\n \"GR1027\",\n \"structure\",\n \"warning\",\n \"A flow file is not listed in the feature README\",\n \"Add the flow to the README's Flows list.\",\n WRITE,\n ),\n define(\n \"GR1028\",\n \"structure\",\n \"error\",\n \"A list line has the wrong form\",\n \"Write list lines as `- name text`: the name, spaces, then the text.\",\n WRITE,\n ),\n define(\n \"GR1029\",\n \"structure\",\n \"warning\",\n \"An image line points outside grimoire/screenshots\",\n \"Keep screenshots in `grimoire/screenshots/` and write the path relative to the Markdown file, like `![Product page](../../../screenshots/web/product.png)`.\",\n WRITE,\n ),\n define(\n \"GR1030\",\n \"structure\",\n \"warning\",\n \"A flow has no summary\",\n \"Write one or two plain sentences under the flow's `# Title`: who does what, and what they get.\",\n WRITE,\n ),\n\n // ── GR2xxx links ─────────────────────────────────────────────────────────\n define(\n \"GR2001\",\n \"links\",\n \"error\",\n \"A route step names a route that does not exist\",\n \"Fix the method and path in the flow, or add the route in code.\",\n RECORD,\n ),\n define(\n \"GR2002\",\n \"links\",\n \"error\",\n \"A page step names a page that does not exist\",\n \"Fix the route path in the flow, or add the page to one of the feature's apps. A step scoped like `page /support [web-admin]` looks only in that app.\",\n RECORD,\n ),\n define(\n \"GR2003\",\n \"links\",\n \"error\",\n \"A mail step names a mail that does not exist\",\n \"Use the mail's name as code defines it, or add the mail.\",\n RECORD,\n ),\n define(\n \"GR2004\",\n \"links\",\n \"error\",\n \"A notification step names a notification that does not exist\",\n \"Use the notification's name as code defines it, or add it.\",\n RECORD,\n ),\n define(\n \"GR2005\",\n \"links\",\n \"error\",\n \"A job step names a job that does not exist\",\n \"Use the job's name as code defines it, or add the job.\",\n RECORD,\n ),\n define(\n \"GR2006\",\n \"links\",\n \"error\",\n \"An event step names an event that does not exist\",\n \"Use the event's name as code emits it, or add the event.\",\n RECORD,\n ),\n define(\n \"GR2007\",\n \"links\",\n \"error\",\n \"An affects step names a feature or flow that does not exist\",\n \"Write `affects <feature>/<flow>` with an existing feature and flow.\",\n WRITE,\n ),\n define(\n \"GR2008\",\n \"links\",\n \"error\",\n \"A name refers to an app with no folder\",\n \"Add `grimoire/apps/<app>/README.md`, or fix the app id.\",\n APP,\n ),\n define(\n \"GR2009\",\n \"links\",\n \"warning\",\n \"A flow names an app its feature does not list\",\n \"Add the app to the feature's `apps`, or fix the app id in Differs by app or the criterion.\",\n WRITE,\n ),\n define(\n \"GR2010\",\n \"links\",\n \"error\",\n \"A changelog entry names a flow that does not exist\",\n \"Fix the flow id before the `:`, or add the flow.\",\n RECORD,\n ),\n define(\n \"GR2011\",\n \"links\",\n \"error\",\n \"A changelog entry names a criterion the flow does not have\",\n \"Fix the criterion id, or add the criterion to the flow.\",\n RECORD,\n ),\n define(\n \"GR2012\",\n \"links\",\n \"error\",\n \"A README relation names a flow that does not exist\",\n \"Fix the `<feature>/<flow>` reference in Affects and affected by.\",\n WRITE,\n ),\n define(\n \"GR2013\",\n \"links\",\n \"error\",\n \"A case names a criterion the flow does not have\",\n \"Fix the `(AC-n)` at the end of the case line, or add the criterion under Acceptance criteria.\",\n WRITE,\n ),\n define(\n \"GR2014\",\n \"links\",\n \"warning\",\n \"An image line names a screenshot file that does not exist\",\n \"Add the image under `grimoire/screenshots/`, or fix the path.\",\n WRITE,\n ),\n\n // ── GR3xxx files ─────────────────────────────────────────────────────────\n define(\n \"GR3001\",\n \"files\",\n \"warning\",\n \"A source file has no header sentence\",\n \"Start the file with a one-sentence comment saying why it exists.\",\n FILE,\n ),\n define(\n \"GR3002\",\n \"files\",\n \"warning\",\n \"A source file belongs to no feature\",\n \"Add its folder to a feature's `folders`, or tag it `@feature <id>` in its header.\",\n FILE,\n ),\n define(\n \"GR3003\",\n \"files\",\n \"error\",\n \"A source file has two owners\",\n \"Keep one owner: remove the duplicate folder from one feature, or keep one `@feature` tag.\",\n FILE,\n ),\n define(\n \"GR3004\",\n \"files\",\n \"error\",\n \"A `@feature` tag names a feature that does not exist\",\n \"Fix the tag, or write the feature.\",\n FILE,\n ),\n define(\n \"GR3005\",\n \"files\",\n \"error\",\n \"A feature's `folders` entry does not exist\",\n \"Fix the folder or file path, or remove it from `folders`.\",\n WRITE,\n ),\n define(\n \"GR3006\",\n \"files\",\n \"warning\",\n \"A file in a feature's folders is reached by no flow\",\n \"Describe the behaviour in a flow, or delete dead code.\",\n RECORD,\n ),\n\n // ── GR4xxx tests ─────────────────────────────────────────────────────────\n define(\n \"GR4001\",\n \"tests\",\n \"warning\",\n \"A criterion has no test\",\n \"Write a test with `// @proves <feature>/<flow> AC-<n>` above it, or say in the task why not.\",\n RECORD,\n ),\n define(\n \"GR4002\",\n \"tests\",\n \"error\",\n \"A `@proves` line names a flow or criterion that does not exist\",\n \"Fix the `@proves` line to name an existing `<feature>/<flow> AC-<n>`.\",\n RECORD,\n ),\n define(\n \"GR4003\",\n \"tests\",\n \"error\",\n \"A `@proves` line has the wrong form\",\n \"Write `// @proves <feature>/<flow> AC-<n>` on its own line.\",\n RECORD,\n ),\n define(\n \"GR4004\",\n \"tests\",\n \"error\",\n \"A `@proves` line is not directly above a test\",\n \"Move the line right above the `it(…)` or `test(…)` it describes.\",\n RECORD,\n ),\n define(\n \"GR4005\",\n \"tests\",\n \"warning\",\n \"One test proves two criteria\",\n \"Split the test so each proves one criterion.\",\n RECORD,\n ),\n define(\n \"GR4006\",\n \"tests\",\n \"error\",\n \"A test proving a criterion failed in its last run\",\n \"Fix the code or the test, then run the tests again.\",\n RECORD,\n ),\n define(\n \"GR4007\",\n \"tests\",\n \"warning\",\n \"A criterion's test result is older than the test file\",\n \"Run the tests again.\",\n RECORD,\n ),\n define(\n \"GR4008\",\n \"tests\",\n \"warning\",\n \"A criterion's test did not run in the last run\",\n \"Run the tests that prove the criterion.\",\n RECORD,\n ),\n define(\n \"GR4009\",\n \"tests\",\n \"warning\",\n \"Tests prove criteria but no test results are recorded\",\n \"Add `grimoireReporter()` from `@warlock.js/grimoire/vitest` to `test.reporters` in the Vitest config and run the tests; in production, ship the results file with the deploy.\",\n RECORD,\n ),\n define(\n \"GR4010\",\n \"tests\",\n \"warning\",\n \"The reporter could not match a proving test to its result\",\n \"Keep the `it(...)` or `test(...)` call on the line right under the `@proves` comment, with a plain string name.\",\n RECORD,\n ),\n\n // ── GR5xxx apps ──────────────────────────────────────────────────────────\n define(\n \"GR5001\",\n \"apps\",\n \"error\",\n \"A block points to a flow that does not exist\",\n \"Fix the `<feature>/<flow>` in the Flow column or the block file.\",\n APP,\n ),\n define(\n \"GR5002\",\n \"apps\",\n \"error\",\n \"A condition is not declared in the app README\",\n \"Add the condition under Conditions in the app README, or use a declared one.\",\n APP,\n ),\n define(\n \"GR5003\",\n \"apps\",\n \"error\",\n \"A page's route does not exist in its site\",\n \"Fix the `route` of the page file, or remove the page file if the page is gone.\",\n APP,\n ),\n define(\n \"GR5004\",\n \"apps\",\n \"error\",\n \"A page names a layout with no file\",\n \"Add `layouts/<layout>.md` to the app, or fix the page's `layout`.\",\n APP,\n ),\n define(\n \"GR5005\",\n \"apps\",\n \"error\",\n \"An app's root matches no site or mobile app\",\n \"Set `root` to the site folder (`src/web/$sites/<site>`) or the mobile app folder.\",\n APP,\n ),\n define(\n \"GR5006\",\n \"apps\",\n \"error\",\n \"A screen's route does not exist in the mobile app\",\n \"Fix the `route` of the screen file, or remove it if the screen is gone.\",\n APP,\n ),\n define(\n \"GR5007\",\n \"apps\",\n \"warning\",\n \"A block file has no row in its page's Blocks table\",\n \"Add the block to the page's Blocks table, or remove the block file.\",\n APP,\n ),\n define(\n \"GR5008\",\n \"apps\",\n \"error\",\n \"An entry point in Also reached from does not exist\",\n \"Fix the mail, notification or page name.\",\n APP,\n ),\n define(\n \"GR5009\",\n \"apps\",\n \"warning\",\n \"A site or mobile app has no folder in grimoire/apps\",\n \"Add `grimoire/apps/<app>/README.md` for it.\",\n APP,\n ),\n define(\n \"GR5010\",\n \"apps\",\n \"warning\",\n \"A name in backticks in Changes with is not a declared condition\",\n \"Declare the condition under Conditions in the app README, fix the name, or write it without backticks when it is not a condition.\",\n APP,\n ),\n\n // ── GR6xxx changelog ─────────────────────────────────────────────────────\n define(\n \"GR6001\",\n \"changelog\",\n \"error\",\n \"A release lists a changelog entry that is not stamped with it\",\n \"Move the entry under `## <release> (<date>)` in the feature's CHANGELOG.md.\",\n RECORD,\n ),\n define(\n \"GR6002\",\n \"changelog\",\n \"error\",\n \"A changelog release section has no release file\",\n \"Write `grimoire/releases/<release>.md`, or fix the release in the heading.\",\n RECORD,\n ),\n define(\n \"GR6003\",\n \"changelog\",\n \"error\",\n \"A changelog release date differs from the release file\",\n \"Use the date in the release file's front matter.\",\n RECORD,\n ),\n define(\n \"GR6004\",\n \"changelog\",\n \"error\",\n \"The README `updated` is older than the newest changelog entry\",\n \"Reshape the README to describe the feature as it is now, and set `updated`.\",\n RECORD,\n ),\n define(\n \"GR6005\",\n \"changelog\",\n \"error\",\n \"The README `version` differs from the newest changelog entry\",\n \"Set `version` to the newest entry's version.\",\n RECORD,\n ),\n define(\n \"GR6006\",\n \"changelog\",\n \"warning\",\n \"A changelog word does not match its version step\",\n \"Use a whole-number version for added and removed, a decimal for changed and fixed.\",\n RECORD,\n ),\n define(\n \"GR6007\",\n \"changelog\",\n \"error\",\n \"A flow's `since` is newer than its feature's version\",\n \"Fix `since`, or the feature `version`.\",\n WRITE,\n ),\n define(\n \"GR6008\",\n \"changelog\",\n \"warning\",\n \"A new whole-number version has no brief\",\n \"Write `versions/v<n>.md` before building it.\",\n WRITE,\n ),\n\n // ── GR7xxx tasks ─────────────────────────────────────────────────────────\n define(\n \"GR7001\",\n \"tasks\",\n \"error\",\n \"A task names a feature that does not exist\",\n \"Fix the task's `feature`, or write the feature first.\",\n WRITE,\n ),\n define(\n \"GR7002\",\n \"tasks\",\n \"error\",\n \"A task names a flow that does not exist\",\n \"Fix the task's `flow`, or write the flow first.\",\n WRITE,\n ),\n define(\n \"GR7003\",\n \"tasks\",\n \"error\",\n \"A task's status does not match its folder\",\n \"Done tasks live in `tasks/done/<yyyy-mm>/` with `status: done` and `shipped`; open tasks in `tasks/open/`.\",\n RECORD,\n ),\n define(\n \"GR7004\",\n \"tasks\",\n \"error\",\n \"A task's `shipped` names a version the changelog does not have\",\n \"Fix `shipped: <feature> <version>`, or add the changelog entry.\",\n RECORD,\n ),\n define(\n \"GR7005\",\n \"tasks\",\n \"warning\",\n \"A task's brief does not exist\",\n \"Fix the `Brief:` path, or write the brief.\",\n WRITE,\n ),\n\n // ── GR8xxx book ──────────────────────────────────────────────────────────\n define(\n \"GR8001\",\n \"book\",\n \"error\",\n \"The project's source files could not be read\",\n \"Read the message; fix the file or folder it names, then build again.\",\n USE,\n ),\n define(\n \"GR8002\",\n \"book\",\n \"warning\",\n \"Route facts could not be read because the app did not boot\",\n \"Run `warlock doctor`, fix what stops the app from booting, then `warlock grimoire build`.\",\n USE,\n ),\n define(\n \"GR8003\",\n \"book\",\n \"warning\",\n \"Route facts are older than the routes files\",\n \"Run `warlock grimoire build` to refresh them.\",\n USE,\n ),\n define(\n \"GR8004\",\n \"book\",\n \"warning\",\n \"Pages or screens could not be read\",\n \"Read the message; fix the page file it names, then build again.\",\n USE,\n ),\n\n // ── GR9xxx usage ─────────────────────────────────────────────────────────\n define(\n \"GR9001\",\n \"usage\",\n \"error\",\n \"The file is not in the book\",\n \"Pass a code file under the source roots, as a project-relative path.\",\n USE,\n ),\n define(\n \"GR9002\",\n \"usage\",\n \"error\",\n \"No route matches\",\n 'Pass `\"<METHOD> <path>\"` as the route is registered; `warlock routes` lists them.',\n USE,\n ),\n define(\n \"GR9003\",\n \"usage\",\n \"error\",\n \"No feature has that id\",\n \"Use an id from `grimoire/features/`.\",\n USE,\n ),\n define(\n \"GR9004\",\n \"usage\",\n \"error\",\n \"No flow has that id\",\n \"Use `<feature>/<flow>` with a file in `grimoire/features/<feature>/flows/`.\",\n USE,\n ),\n define(\n \"GR9005\",\n \"usage\",\n \"error\",\n \"The release file has no brief yet\",\n \"Write `grimoire/releases/<release>.md` with `release` and `date` front matter and the brief, then run the command again.\",\n RECORD,\n ),\n define(\n \"GR9006\",\n \"usage\",\n \"error\",\n \"A query argument has the wrong form\",\n \"Read the command's help (`warlock scry --help`) and pass the argument in that form.\",\n USE,\n ),\n define(\n \"GR9007\",\n \"usage\",\n \"error\",\n \"The book is not built\",\n \"Run `warlock grimoire build`, then ask again. `warlock scry` only reads the book; it never builds it.\",\n USE,\n ),\n] as const;\n\n/** One registered code, as a union. */\nexport type GrimoireCode = (typeof GRIMOIRE_CODE_LIST)[number][\"code\"];\n\n/** The catalog, keyed by code. */\nexport const GRIMOIRE_CODES: Readonly<Record<GrimoireCode, GrimoireCodeDefinition>> =\n Object.fromEntries(\n GRIMOIRE_CODE_LIST.map((definition) => [definition.code, definition]),\n ) as Record<GrimoireCode, GrimoireCodeDefinition>;\n"],"mappings":";AAwBA,SAAS,OACP,MACA,MACA,UACA,OACA,KACA,OACkD;CAClD,OAAO;EAAE;EAAM;EAAM;EAAU;EAAO;EAAK;CAAM;AACnD;AAEA,MAAM,QAAQ;AACd,MAAM,SAAS;AACf,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;;AAGZ,MAAa,qBAAqB;CAEhC,OACE,UACA,aACA,SACA,sCACA,2FACA,KACF;CACA,OACE,UACA,aACA,SACA,mCACA,sHACA,KACF;CACA,OACE,UACA,aACA,SACA,0CACA,yFACA,KACF;CACA,OACE,UACA,aACA,SACA,2CACA,iRACA,KACF;CACA,OACE,UACA,aACA,WACA,kDACA,mEACA,KACF;CACA,OACE,UACA,aACA,SACA,iCACA,qEACA,KACF;CACA,OACE,UACA,aACA,WACA,yCACA,6EACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,6FACA,KACF;CACA,OACE,UACA,aACA,SACA,gCACA,sFACA,KACF;CACA,OACE,UACA,aACA,SACA,2CACA,yEACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,iGACA,KACF;CACA,OACE,UACA,aACA,WACA,mCACA,kNACA,KACF;CACA,OACE,UACA,aACA,SACA,uCACA,8FACA,KACF;CACA,OACE,UACA,aACA,SACA,4CACA,kFACA,KACF;CACA,OACE,UACA,aACA,SACA,uCACA,wEACA,MACF;CACA,OACE,UACA,aACA,SACA,0CACA,+CACA,MACF;CACA,OACE,UACA,aACA,SACA,0CACA,mFACA,MACF;CACA,OACE,UACA,aACA,SACA,qCACA,yFACA,GACF;CACA,OACE,UACA,aACA,SACA,gDACA,4EACA,KACF;CACA,OACE,UACA,aACA,WACA,2DACA,+DACA,GACF;CACA,OACE,UACA,aACA,SACA,0DACA,wDACA,KACF;CACA,OACE,UACA,aACA,SACA,6BACA,8CACA,KACF;CACA,OACE,UACA,aACA,SACA,wCACA,8EACA,MACF;CACA,OACE,UACA,aACA,SACA,2DACA,qGACA,MACF;CACA,OACE,UACA,aACA,SACA,iCACA,gCACA,GACF;CACA,OACE,UACA,aACA,SACA,oDACA,2EACA,KACF;CACA,OACE,UACA,aACA,WACA,mDACA,4CACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,yEACA,KACF;CACA,OACE,UACA,aACA,WACA,qDACA,+JACA,KACF;CACA,OACE,UACA,aACA,WACA,yBACA,kGACA,KACF;CAGA,OACE,UACA,SACA,SACA,kDACA,kEACA,MACF;CACA,OACE,UACA,SACA,SACA,gDACA,wJACA,MACF;CACA,OACE,UACA,SACA,SACA,gDACA,4DACA,MACF;CACA,OACE,UACA,SACA,SACA,gEACA,8DACA,MACF;CACA,OACE,UACA,SACA,SACA,8CACA,0DACA,MACF;CACA,OACE,UACA,SACA,SACA,oDACA,4DACA,MACF;CACA,OACE,UACA,SACA,SACA,+DACA,yEACA,KACF;CACA,OACE,UACA,SACA,SACA,0CACA,2DACA,GACF;CACA,OACE,UACA,SACA,WACA,iDACA,8FACA,KACF;CACA,OACE,UACA,SACA,SACA,sDACA,oDACA,MACF;CACA,OACE,UACA,SACA,SACA,8DACA,2DACA,MACF;CACA,OACE,UACA,SACA,SACA,sDACA,oEACA,KACF;CACA,OACE,UACA,SACA,SACA,mDACA,iGACA,KACF;CACA,OACE,UACA,SACA,WACA,6DACA,iEACA,KACF;CAGA,OACE,UACA,SACA,WACA,wCACA,oEACA,IACF;CACA,OACE,UACA,SACA,WACA,uCACA,qFACA,IACF;CACA,OACE,UACA,SACA,SACA,gCACA,6FACA,IACF;CACA,OACE,UACA,SACA,SACA,wDACA,sCACA,IACF;CACA,OACE,UACA,SACA,SACA,8CACA,6DACA,KACF;CACA,OACE,UACA,SACA,WACA,uDACA,0DACA,MACF;CAGA,OACE,UACA,SACA,WACA,2BACA,gGACA,MACF;CACA,OACE,UACA,SACA,SACA,kEACA,yEACA,MACF;CACA,OACE,UACA,SACA,SACA,uCACA,+DACA,MACF;CACA,OACE,UACA,SACA,SACA,iDACA,oEACA,MACF;CACA,OACE,UACA,SACA,WACA,gCACA,gDACA,MACF;CACA,OACE,UACA,SACA,SACA,qDACA,uDACA,MACF;CACA,OACE,UACA,SACA,WACA,yDACA,wBACA,MACF;CACA,OACE,UACA,SACA,WACA,kDACA,2CACA,MACF;CACA,OACE,UACA,SACA,WACA,yDACA,iLACA,MACF;CACA,OACE,UACA,SACA,WACA,6DACA,mHACA,MACF;CAGA,OACE,UACA,QACA,SACA,gDACA,oEACA,GACF;CACA,OACE,UACA,QACA,SACA,iDACA,gFACA,GACF;CACA,OACE,UACA,QACA,SACA,6CACA,kFACA,GACF;CACA,OACE,UACA,QACA,SACA,sCACA,qEACA,GACF;CACA,OACE,UACA,QACA,SACA,+CACA,qFACA,GACF;CACA,OACE,UACA,QACA,SACA,qDACA,2EACA,GACF;CACA,OACE,UACA,QACA,WACA,sDACA,uEACA,GACF;CACA,OACE,UACA,QACA,SACA,sDACA,4CACA,GACF;CACA,OACE,UACA,QACA,WACA,uDACA,+CACA,GACF;CACA,OACE,UACA,QACA,WACA,mEACA,qIACA,GACF;CAGA,OACE,UACA,aACA,SACA,iEACA,+EACA,MACF;CACA,OACE,UACA,aACA,SACA,mDACA,8EACA,MACF;CACA,OACE,UACA,aACA,SACA,0DACA,oDACA,MACF;CACA,OACE,UACA,aACA,SACA,iEACA,+EACA,MACF;CACA,OACE,UACA,aACA,SACA,gEACA,gDACA,MACF;CACA,OACE,UACA,aACA,WACA,oDACA,sFACA,MACF;CACA,OACE,UACA,aACA,SACA,wDACA,0CACA,KACF;CACA,OACE,UACA,aACA,WACA,2CACA,gDACA,KACF;CAGA,OACE,UACA,SACA,SACA,8CACA,yDACA,KACF;CACA,OACE,UACA,SACA,SACA,2CACA,mDACA,KACF;CACA,OACE,UACA,SACA,SACA,6CACA,8GACA,MACF;CACA,OACE,UACA,SACA,SACA,kEACA,mEACA,MACF;CACA,OACE,UACA,SACA,WACA,iCACA,8CACA,KACF;CAGA,OACE,UACA,QACA,SACA,gDACA,wEACA,GACF;CACA,OACE,UACA,QACA,WACA,8DACA,6FACA,GACF;CACA,OACE,UACA,QACA,WACA,+CACA,iDACA,GACF;CACA,OACE,UACA,QACA,WACA,sCACA,mEACA,GACF;CAGA,OACE,UACA,SACA,SACA,+BACA,wEACA,GACF;CACA,OACE,UACA,SACA,SACA,oBACA,uFACA,GACF;CACA,OACE,UACA,SACA,SACA,0BACA,wCACA,GACF;CACA,OACE,UACA,SACA,SACA,uBACA,+EACA,GACF;CACA,OACE,UACA,SACA,SACA,qCACA,4HACA,MACF;CACA,OACE,UACA,SACA,SACA,uCACA,uFACA,GACF;CACA,OACE,UACA,SACA,SACA,yBACA,yGACA,GACF;AACF;;AAMA,MAAa,iBACX,OAAO,YACL,mBAAmB,KAAK,eAAe,CAAC,WAAW,MAAM,UAAU,CAAC,CACtE"}
@@ -165,6 +165,11 @@ export type BookManifest = {
165
165
  /** ISO time the routes were read, or `null` when never. */
166
166
  collectedAt: string | null;
167
167
  inputs: Record<string, string>;
168
+ /** How many routes and pages the last read found; absent in books written before it was stored. */
169
+ counts?: {
170
+ routes: number;
171
+ pages: number;
172
+ };
168
173
  };
169
174
  };
170
175
  /**
@@ -183,6 +188,8 @@ export type LoadedBook = {
183
188
  manifest: BookManifest;
184
189
  facts: BookFacts;
185
190
  routes: RouteFreshness;
191
+ /** Set when a live read of the route facts was refused (it found far fewer routes than the book holds); the book keeps its list. */
192
+ routeNote?: string;
186
193
  };
187
194
  /** Options of `buildBook()`. */
188
195
  export type BuildBookOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"book.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/book.ts"],"mappings":";;;;qBAoBa;;YAGD;EACV;EACA;EACA;;;;;;;YAQU;EACV,sBAAsB;;EAEtB;EACA;EACA,MAAM;EACN;;EAEA;;EAEA;;EAEA;;EAEA;EACA;IAAW;IAAc;;;EAEzB;;EAEA;;EAEA;;EAEA;;;;;;EAMA,SAAS;IAAiB;;;EAE1B;IAAS;IAAc;IAAe;;;EAEtC;IAAW;IAAa;IAAe;;;;YAI7B;EACV,sBAAsB;;EAEtB,SAAS,gBAAgB;IAAiB;;;;YAIhC;EACV,sBAAsB;EACtB,MAAM;EACN,OAAO;;;YAIG;EACV,sBAAsB;EACtB,KAAK,KAAK;EACV,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;YA2BC;EACV;;EAEA;EACA;IAAS;IAAc,MAAM;IAAc;IAAe;;EAC1D,QAAQ;;EAER;IAAU;IAAgB;;;;YAIhB;;EAEV;;EAEA;EACA;;EAEA;;;;;;;;YASU;EACV,sBAAsB;;EAEtB;EACA;IAAW;IAAc;;;EAEzB;EACA;;EAEA,OAAO,eAAe;;EAEtB,OAAO;;EAEP;;;;;;EAMA;;IAEE;IACA,QAAQ;;;;;;;;YASA;EACV,sBAAsB;EACtB,OAAO;;;YAIG;;EAEV;EACA,UAAU;EACV,OAAO;EACP,QAAQ;;;YAIE;;;;;;;EAOV;;EAEA;;EAEA,YAAY;;EAEZ;;;YAIU;EACV,MAAM;;EAEN;;EAEA;;;;;;;YAQU;;EAEV;;EAEA,OAAO;EACP,OAAO;IAAiB;IAAwB;IAAsB;;;;YAI5D;;EAEV;;EAEA"}
1
+ {"version":3,"file":"book.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/book.ts"],"mappings":";;;;qBAoBa;;YAGD;EACV;EACA;EACA;;;;;;;YAQU;EACV,sBAAsB;;EAEtB;EACA;EACA,MAAM;EACN;;EAEA;;EAEA;;EAEA;;EAEA;EACA;IAAW;IAAc;;;EAEzB;;EAEA;;EAEA;;EAEA;;;;;;EAMA,SAAS;IAAiB;;;EAE1B;IAAS;IAAc;IAAe;;;EAEtC;IAAW;IAAa;IAAe;;;;YAI7B;EACV,sBAAsB;;EAEtB,SAAS,gBAAgB;IAAiB;;;;YAIhC;EACV,sBAAsB;EACtB,MAAM;EACN,OAAO;;;YAIG;EACV,sBAAsB;EACtB,KAAK,KAAK;EACV,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;YA2BC;EACV;;EAEA;EACA;IAAS;IAAc,MAAM;IAAc;IAAe;;EAC1D,QAAQ;;EAER;IAAU;IAAgB;;;;YAIhB;;EAEV;;EAEA;EACA;;EAEA;;;;;;;;YASU;EACV,sBAAsB;;EAEtB;EACA;IAAW;IAAc;;;EAEzB;EACA;;EAEA,OAAO,eAAe;;EAEtB,OAAO;;EAEP;;;;;;EAMA;;IAEE;IACA,QAAQ;;IAER;MAAW;MAAgB;;;;;;;;;YASnB;EACV,sBAAsB;EACtB,OAAO;;;YAIG;;EAEV;EACA,UAAU;EACV,OAAO;EACP,QAAQ;;EAER;;;YAIU;;;;;;;EAOV;;EAEA;;EAEA,YAAY;;EAEZ;;;YAIU;EACV,MAAM;;EAEN;;EAEA;;;;;;;YAQU;;EAEV;;EAEA,OAAO;EACP,OAAO;IAAiB;IAAwB;IAAsB;;;;YAI5D;;EAEV;;EAEA"}