@warlock.js/grimoire 0.0.0-stage → 5.55.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/LICENSE +21 -0
  3. package/README.md +55 -2
  4. package/esm/apps/check-apps.mjs +207 -0
  5. package/esm/apps/check-apps.mjs.map +1 -0
  6. package/esm/apps/index.mjs +4 -0
  7. package/esm/apps/match-apps.d.mts +12 -0
  8. package/esm/apps/match-apps.d.mts.map +1 -0
  9. package/esm/apps/match-apps.mjs +30 -0
  10. package/esm/apps/match-apps.mjs.map +1 -0
  11. package/esm/book/build.d.mts +14 -0
  12. package/esm/book/build.d.mts.map +1 -0
  13. package/esm/book/build.mjs +300 -0
  14. package/esm/book/build.mjs.map +1 -0
  15. package/esm/book/index.mjs +5 -0
  16. package/esm/book/io.mjs +162 -0
  17. package/esm/book/io.mjs.map +1 -0
  18. package/esm/book/normalize.mjs +71 -0
  19. package/esm/book/normalize.mjs.map +1 -0
  20. package/esm/book/render.mjs +262 -0
  21. package/esm/book/render.mjs.map +1 -0
  22. package/esm/book/write.d.mts +12 -0
  23. package/esm/book/write.d.mts.map +1 -0
  24. package/esm/book/write.mjs +90 -0
  25. package/esm/book/write.mjs.map +1 -0
  26. package/esm/bookmap/build.d.mts +21 -0
  27. package/esm/bookmap/build.d.mts.map +1 -0
  28. package/esm/bookmap/build.mjs +272 -0
  29. package/esm/bookmap/build.mjs.map +1 -0
  30. package/esm/bookmap/index.mjs +5 -0
  31. package/esm/bookmap/steps.mjs +137 -0
  32. package/esm/bookmap/steps.mjs.map +1 -0
  33. package/esm/bookmap/write.d.mts +19 -0
  34. package/esm/bookmap/write.d.mts.map +1 -0
  35. package/esm/bookmap/write.mjs +118 -0
  36. package/esm/bookmap/write.mjs.map +1 -0
  37. package/esm/check/check-grimoire.d.mts +7 -0
  38. package/esm/check/check-grimoire.d.mts.map +1 -0
  39. package/esm/check/check-grimoire.mjs +98 -0
  40. package/esm/check/check-grimoire.mjs.map +1 -0
  41. package/esm/check/format-check-report.d.mts +20 -0
  42. package/esm/check/format-check-report.d.mts.map +1 -0
  43. package/esm/check/format-check-report.mjs +55 -0
  44. package/esm/check/format-check-report.mjs.map +1 -0
  45. package/esm/check/index.mjs +4 -0
  46. package/esm/check/rules/book-notes.mjs +18 -0
  47. package/esm/check/rules/book-notes.mjs.map +1 -0
  48. package/esm/check/rules/criteria.mjs +48 -0
  49. package/esm/check/rules/criteria.mjs.map +1 -0
  50. package/esm/check/rules/links.mjs +196 -0
  51. package/esm/check/rules/links.mjs.map +1 -0
  52. package/esm/check/rules/lookup.mjs +41 -0
  53. package/esm/check/rules/lookup.mjs.map +1 -0
  54. package/esm/check/rules/source-files.mjs +119 -0
  55. package/esm/check/rules/source-files.mjs.map +1 -0
  56. package/esm/check/rules/versions.mjs +92 -0
  57. package/esm/check/rules/versions.mjs.map +1 -0
  58. package/esm/codes/codes.d.mts +182 -0
  59. package/esm/codes/codes.d.mts.map +1 -0
  60. package/esm/codes/codes.mjs +111 -0
  61. package/esm/codes/codes.mjs.map +1 -0
  62. package/esm/codes/index.d.mts +33 -0
  63. package/esm/codes/index.d.mts.map +1 -0
  64. package/esm/codes/index.mjs +63 -0
  65. package/esm/codes/index.mjs.map +1 -0
  66. package/esm/contracts/adapter.d.mts +209 -0
  67. package/esm/contracts/adapter.d.mts.map +1 -0
  68. package/esm/contracts/book.d.mts +233 -0
  69. package/esm/contracts/book.d.mts.map +1 -0
  70. package/esm/contracts/book.mjs +7 -0
  71. package/esm/contracts/book.mjs.map +1 -0
  72. package/esm/contracts/bookmap.d.mts +175 -0
  73. package/esm/contracts/bookmap.d.mts.map +1 -0
  74. package/esm/contracts/findings.d.mts +79 -0
  75. package/esm/contracts/findings.d.mts.map +1 -0
  76. package/esm/contracts/location.d.mts +22 -0
  77. package/esm/contracts/location.d.mts.map +1 -0
  78. package/esm/contracts/releases.d.mts +53 -0
  79. package/esm/contracts/releases.d.mts.map +1 -0
  80. package/esm/contracts/scry.d.mts +143 -0
  81. package/esm/contracts/scry.d.mts.map +1 -0
  82. package/esm/contracts/snapshot.d.mts +52 -0
  83. package/esm/contracts/snapshot.d.mts.map +1 -0
  84. package/esm/contracts/test-results.d.mts +63 -0
  85. package/esm/contracts/test-results.d.mts.map +1 -0
  86. package/esm/contracts/written.d.mts +363 -0
  87. package/esm/contracts/written.d.mts.map +1 -0
  88. package/esm/contracts/written.mjs +19 -0
  89. package/esm/contracts/written.mjs.map +1 -0
  90. package/esm/devtools/data.mjs +171 -0
  91. package/esm/devtools/data.mjs.map +1 -0
  92. package/esm/devtools/graphs.mjs +142 -0
  93. package/esm/devtools/graphs.mjs.map +1 -0
  94. package/esm/devtools/index.d.mts +35 -0
  95. package/esm/devtools/index.d.mts.map +1 -0
  96. package/esm/devtools/index.mjs +102 -0
  97. package/esm/devtools/index.mjs.map +1 -0
  98. package/esm/devtools/site.d.mts +26 -0
  99. package/esm/devtools/site.d.mts.map +1 -0
  100. package/esm/devtools/site.mjs +190 -0
  101. package/esm/devtools/site.mjs.map +1 -0
  102. package/esm/devtools/snapshot-source.mjs +70 -0
  103. package/esm/devtools/snapshot-source.mjs.map +1 -0
  104. package/esm/front-matter/index.d.mts +33 -0
  105. package/esm/front-matter/index.d.mts.map +1 -0
  106. package/esm/front-matter/index.mjs +130 -0
  107. package/esm/front-matter/index.mjs.map +1 -0
  108. package/esm/graph/index.d.mts +15 -0
  109. package/esm/graph/index.d.mts.map +1 -0
  110. package/esm/graph/index.mjs +42 -0
  111. package/esm/graph/index.mjs.map +1 -0
  112. package/esm/index.d.mts +33 -0
  113. package/esm/index.mjs +33 -0
  114. package/esm/ownership/index.d.mts +8 -0
  115. package/esm/ownership/index.d.mts.map +1 -0
  116. package/esm/ownership/index.mjs +137 -0
  117. package/esm/ownership/index.mjs.map +1 -0
  118. package/esm/paths/index.d.mts +58 -0
  119. package/esm/paths/index.d.mts.map +1 -0
  120. package/esm/paths/index.mjs +137 -0
  121. package/esm/paths/index.mjs.map +1 -0
  122. package/esm/proves/index.mjs +3 -0
  123. package/esm/proves/scan-proofs.d.mts +22 -0
  124. package/esm/proves/scan-proofs.d.mts.map +1 -0
  125. package/esm/proves/scan-proofs.mjs +214 -0
  126. package/esm/proves/scan-proofs.mjs.map +1 -0
  127. package/esm/releases/index.d.mts +29 -0
  128. package/esm/releases/index.d.mts.map +1 -0
  129. package/esm/releases/index.mjs +157 -0
  130. package/esm/releases/index.mjs.map +1 -0
  131. package/esm/scry/format.d.mts +14 -0
  132. package/esm/scry/format.d.mts.map +1 -0
  133. package/esm/scry/format.mjs +193 -0
  134. package/esm/scry/format.mjs.map +1 -0
  135. package/esm/scry/index.mjs +5 -0
  136. package/esm/scry/parse.d.mts +10 -0
  137. package/esm/scry/parse.d.mts.map +1 -0
  138. package/esm/scry/parse.mjs +108 -0
  139. package/esm/scry/parse.mjs.map +1 -0
  140. package/esm/scry/query.d.mts +11 -0
  141. package/esm/scry/query.d.mts.map +1 -0
  142. package/esm/scry/query.mjs +457 -0
  143. package/esm/scry/query.mjs.map +1 -0
  144. package/esm/tasks/index.mjs +116 -0
  145. package/esm/tasks/index.mjs.map +1 -0
  146. package/esm/test-results/criterion-status.d.mts +15 -0
  147. package/esm/test-results/criterion-status.d.mts.map +1 -0
  148. package/esm/test-results/criterion-status.mjs +17 -0
  149. package/esm/test-results/criterion-status.mjs.map +1 -0
  150. package/esm/test-results/index.d.mts +8 -0
  151. package/esm/test-results/index.d.mts.map +1 -0
  152. package/esm/test-results/index.mjs +124 -0
  153. package/esm/test-results/index.mjs.map +1 -0
  154. package/esm/vitest/index.d.mts +15 -0
  155. package/esm/vitest/index.d.mts.map +1 -0
  156. package/esm/vitest/index.mjs +146 -0
  157. package/esm/vitest/index.mjs.map +1 -0
  158. package/esm/warlock/actions.mjs +265 -0
  159. package/esm/warlock/actions.mjs.map +1 -0
  160. package/esm/warlock/adapter.d.mts +28 -0
  161. package/esm/warlock/adapter.d.mts.map +1 -0
  162. package/esm/warlock/adapter.mjs +377 -0
  163. package/esm/warlock/adapter.mjs.map +1 -0
  164. package/esm/warlock/commands.d.mts +15 -0
  165. package/esm/warlock/commands.d.mts.map +1 -0
  166. package/esm/warlock/commands.mjs +199 -0
  167. package/esm/warlock/commands.mjs.map +1 -0
  168. package/esm/warlock/index.d.mts +4 -0
  169. package/esm/warlock/index.mjs +5 -0
  170. package/esm/warlock/mcp-tools.mjs +247 -0
  171. package/esm/warlock/mcp-tools.mjs.map +1 -0
  172. package/esm/warlock/mobile-facts.d.mts +32 -0
  173. package/esm/warlock/mobile-facts.d.mts.map +1 -0
  174. package/esm/warlock/mobile-facts.mjs +185 -0
  175. package/esm/warlock/mobile-facts.mjs.map +1 -0
  176. package/esm/workspace/index.d.mts +11 -0
  177. package/esm/workspace/index.d.mts.map +1 -0
  178. package/esm/workspace/index.mjs +122 -0
  179. package/esm/workspace/index.mjs.map +1 -0
  180. package/esm/written/apps.mjs +227 -0
  181. package/esm/written/apps.mjs.map +1 -0
  182. package/esm/written/features.mjs +400 -0
  183. package/esm/written/features.mjs.map +1 -0
  184. package/esm/written/fields.mjs +173 -0
  185. package/esm/written/fields.mjs.map +1 -0
  186. package/esm/written/index.mjs +3 -0
  187. package/esm/written/lists.mjs +68 -0
  188. package/esm/written/lists.mjs.map +1 -0
  189. package/esm/written/markdown.mjs +173 -0
  190. package/esm/written/markdown.mjs.map +1 -0
  191. package/esm/written/parse-grimoire.d.mts +20 -0
  192. package/esm/written/parse-grimoire.d.mts.map +1 -0
  193. package/esm/written/parse-grimoire.mjs +552 -0
  194. package/esm/written/parse-grimoire.mjs.map +1 -0
  195. package/esm/written/sink.mjs +65 -0
  196. package/esm/written/sink.mjs.map +1 -0
  197. package/esm/written/tasks-releases.mjs +166 -0
  198. package/esm/written/tasks-releases.mjs.map +1 -0
  199. package/llms-full.txt +869 -0
  200. package/llms.txt +15 -0
  201. package/package.json +66 -4
  202. package/skills/backfill-a-grimoire/SKILL.md +128 -0
  203. package/skills/describe-an-app/SKILL.md +162 -0
  204. package/skills/document-a-file/SKILL.md +75 -0
  205. package/skills/index.md +26 -0
  206. package/skills/record-a-change/SKILL.md +139 -0
  207. package/skills/use-the-grimoire/SKILL.md +137 -0
  208. package/skills/write-a-feature/SKILL.md +168 -0
  209. package/ui/grimoire-static.js +136 -0
  210. package/ui/grimoire-view.js +1005 -0
  211. package/ui/grimoire.css +88 -0
@@ -0,0 +1,33 @@
1
+ import { GrimoireCodeDefinition, GrimoireFinding, GrimoireFindingInput } from "../contracts/findings.mjs";
2
+ import { GRIMOIRE_CODES, GRIMOIRE_CODE_LIST, GrimoireCode } from "./codes.mjs";
3
+ //#region ../../packages/grimoire/src/codes/index.d.ts
4
+ /** Base URL of the code reference; each code is an anchor on that page. */
5
+ export declare const GRIMOIRE_CODES_DOCS_URL = "https://warlock.js.org/v/latest/grimoire/guides/04-check/";
6
+ /** Whether `value` is a registered Grimoire code. */
7
+ export declare function isGrimoireCode(value: unknown): value is GrimoireCode;
8
+ /**
9
+ * The catalog entry for a code, or `undefined` for an unknown one. Case and
10
+ * surrounding whitespace are ignored (`explainGrimoireCode(" gr2001 ")`).
11
+ */
12
+ export declare function explainGrimoireCode(code: string): GrimoireCodeDefinition | undefined;
13
+ /** The docs URL of a code. */
14
+ export declare function grimoireCodeDocsUrl(code: string): string;
15
+ /**
16
+ * Build a finding, filling `severity` and `hint` from the catalog. Throws on
17
+ * an unknown code, so a rule cannot report a code nobody can look up.
18
+ * `expected` starts `false`; `checkGrimoire()` sets it for proposed features
19
+ * and flows.
20
+ */
21
+ export declare function createFinding(input: GrimoireFindingInput): GrimoireFinding;
22
+ /**
23
+ * An error a command or query reports with a Grimoire code (`GR9001` for a
24
+ * file not in the book, `GR9005` for a release with no brief). The CLI prints
25
+ * the message and the code's fix, and exits 1.
26
+ */
27
+ export declare class GrimoireError extends Error {
28
+ readonly code: GrimoireCode;
29
+ constructor(code: GrimoireCode, message: string);
30
+ }
31
+ //#endregion
32
+ export { GRIMOIRE_CODES, GRIMOIRE_CODE_LIST, type GrimoireCode };
33
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/codes/index.ts"],"mappings":";;;;qBAUa;;wBAGG,eAAe,iBAAiB,SAAS;;;;;wBAQzC,oBAAoB,eAAe;;wBAOnC,oBAAoB;;;;;;;wBAUpB,cAAc,OAAO,uBAAuB;;;;;;qBA2B/C,sBAAsB;WACjB,MAAM;EAEtB,YAAmB,MAAM,cAAc"}
@@ -0,0 +1,63 @@
1
+ import { GRIMOIRE_CODES, GRIMOIRE_CODE_LIST } from "./codes.mjs";
2
+
3
+ //#region ../../packages/grimoire/src/codes/index.ts
4
+ /** Base URL of the code reference; each code is an anchor on that page. */
5
+ const GRIMOIRE_CODES_DOCS_URL = "https://warlock.js.org/v/latest/grimoire/guides/04-check/";
6
+ /** Whether `value` is a registered Grimoire code. */
7
+ function isGrimoireCode(value) {
8
+ return typeof value === "string" && Object.prototype.hasOwnProperty.call(GRIMOIRE_CODES, value);
9
+ }
10
+ /**
11
+ * The catalog entry for a code, or `undefined` for an unknown one. Case and
12
+ * surrounding whitespace are ignored (`explainGrimoireCode(" gr2001 ")`).
13
+ */
14
+ function explainGrimoireCode(code) {
15
+ const normalized = code.trim().toUpperCase();
16
+ return isGrimoireCode(normalized) ? GRIMOIRE_CODES[normalized] : void 0;
17
+ }
18
+ /** The docs URL of a code. */
19
+ function grimoireCodeDocsUrl(code) {
20
+ return `${GRIMOIRE_CODES_DOCS_URL}#${code.trim().toLowerCase()}`;
21
+ }
22
+ /**
23
+ * Build a finding, filling `severity` and `hint` from the catalog. Throws on
24
+ * an unknown code, so a rule cannot report a code nobody can look up.
25
+ * `expected` starts `false`; `checkGrimoire()` sets it for proposed features
26
+ * and flows.
27
+ */
28
+ function createFinding(input) {
29
+ const definition = explainGrimoireCode(input.code);
30
+ if (!definition) throw new Error(`Unknown Grimoire code ${JSON.stringify(input.code)}.`);
31
+ return {
32
+ code: definition.code,
33
+ severity: input.severity ?? definition.severity,
34
+ message: input.message,
35
+ at: input.at ?? null,
36
+ expected: false,
37
+ subject: {
38
+ feature: input.feature ?? null,
39
+ flow: input.flow ?? null,
40
+ app: input.app ?? null,
41
+ task: input.task ?? null,
42
+ file: input.file ?? input.at?.file ?? null
43
+ },
44
+ hint: definition.fix
45
+ };
46
+ }
47
+ /**
48
+ * An error a command or query reports with a Grimoire code (`GR9001` for a
49
+ * file not in the book, `GR9005` for a release with no brief). The CLI prints
50
+ * the message and the code's fix, and exits 1.
51
+ */
52
+ var GrimoireError = class extends Error {
53
+ code;
54
+ constructor(code, message) {
55
+ super(message);
56
+ this.name = "GrimoireError";
57
+ this.code = code;
58
+ }
59
+ };
60
+
61
+ //#endregion
62
+ export { GRIMOIRE_CODES, GRIMOIRE_CODES_DOCS_URL, GRIMOIRE_CODE_LIST, GrimoireError, createFinding, explainGrimoireCode, grimoireCodeDocsUrl, isGrimoireCode };
63
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/codes/index.ts"],"sourcesContent":["import type {\n GrimoireCodeDefinition,\n GrimoireFinding,\n GrimoireFindingInput,\n} from \"../contracts/findings\";\nimport { GRIMOIRE_CODES, GRIMOIRE_CODE_LIST, type GrimoireCode } from \"./codes\";\n\nexport { GRIMOIRE_CODES, GRIMOIRE_CODE_LIST, type GrimoireCode };\n\n/** Base URL of the code reference; each code is an anchor on that page. */\nexport const GRIMOIRE_CODES_DOCS_URL = \"https://warlock.js.org/v/latest/grimoire/guides/04-check/\";\n\n/** Whether `value` is a registered Grimoire code. */\nexport function isGrimoireCode(value: unknown): value is GrimoireCode {\n return typeof value === \"string\" && Object.prototype.hasOwnProperty.call(GRIMOIRE_CODES, value);\n}\n\n/**\n * The catalog entry for a code, or `undefined` for an unknown one. Case and\n * surrounding whitespace are ignored (`explainGrimoireCode(\" gr2001 \")`).\n */\nexport function explainGrimoireCode(code: string): GrimoireCodeDefinition | undefined {\n const normalized = code.trim().toUpperCase();\n\n return isGrimoireCode(normalized) ? GRIMOIRE_CODES[normalized] : undefined;\n}\n\n/** The docs URL of a code. */\nexport function grimoireCodeDocsUrl(code: string): string {\n return `${GRIMOIRE_CODES_DOCS_URL}#${code.trim().toLowerCase()}`;\n}\n\n/**\n * Build a finding, filling `severity` and `hint` from the catalog. Throws on\n * an unknown code, so a rule cannot report a code nobody can look up.\n * `expected` starts `false`; `checkGrimoire()` sets it for proposed features\n * and flows.\n */\nexport function createFinding(input: GrimoireFindingInput): GrimoireFinding {\n const definition = explainGrimoireCode(input.code);\n\n if (!definition) throw new Error(`Unknown Grimoire code ${JSON.stringify(input.code)}.`);\n\n return {\n code: definition.code,\n severity: input.severity ?? definition.severity,\n message: input.message,\n at: input.at ?? null,\n expected: false,\n subject: {\n feature: input.feature ?? null,\n flow: input.flow ?? null,\n app: input.app ?? null,\n task: input.task ?? null,\n file: input.file ?? input.at?.file ?? null,\n },\n hint: definition.fix,\n };\n}\n\n/**\n * An error a command or query reports with a Grimoire code (`GR9001` for a\n * file not in the book, `GR9005` for a release with no brief). The CLI prints\n * the message and the code's fix, and exits 1.\n */\nexport class GrimoireError extends Error {\n public readonly code: GrimoireCode;\n\n public constructor(code: GrimoireCode, message: string) {\n super(message);\n this.name = \"GrimoireError\";\n this.code = code;\n }\n}\n"],"mappings":";;;;AAUA,MAAa,0BAA0B;;AAGvC,SAAgB,eAAe,OAAuC;CACpE,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,eAAe,KAAK,gBAAgB,KAAK;AAChG;;;;;AAMA,SAAgB,oBAAoB,MAAkD;CACpF,MAAM,aAAa,KAAK,KAAK,CAAC,CAAC,YAAY;CAE3C,OAAO,eAAe,UAAU,IAAI,eAAe,cAAc;AACnE;;AAGA,SAAgB,oBAAoB,MAAsB;CACxD,OAAO,GAAG,wBAAwB,GAAG,KAAK,KAAK,CAAC,CAAC,YAAY;AAC/D;;;;;;;AAQA,SAAgB,cAAc,OAA8C;CAC1E,MAAM,aAAa,oBAAoB,MAAM,IAAI;CAEjD,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,yBAAyB,KAAK,UAAU,MAAM,IAAI,EAAE,EAAE;CAEvF,OAAO;EACL,MAAM,WAAW;EACjB,UAAU,MAAM,YAAY,WAAW;EACvC,SAAS,MAAM;EACf,IAAI,MAAM,MAAM;EAChB,UAAU;EACV,SAAS;GACP,SAAS,MAAM,WAAW;GAC1B,MAAM,MAAM,QAAQ;GACpB,KAAK,MAAM,OAAO;GAClB,MAAM,MAAM,QAAQ;GACpB,MAAM,MAAM,QAAQ,MAAM,IAAI,QAAQ;EACxC;EACA,MAAM,WAAW;CACnB;AACF;;;;;;AAOA,IAAa,gBAAb,cAAmC,MAAM;CACvC,AAAgB;CAEhB,AAAO,YAAY,MAAoB,SAAiB;EACtD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF"}
@@ -0,0 +1,209 @@
1
+ //#region ../../packages/grimoire/src/contracts/adapter.d.ts
2
+ /**
3
+ * The adapter contract: how a framework hands its facts to Grimoire.
4
+ *
5
+ * The root entry never reads application source on its own. An adapter (only
6
+ * the Warlock one, `@warlock.js/grimoire/warlock`, ships today) turns the
7
+ * framework's own report into these shapes. For Warlock that report is
8
+ * `inspectApp()` from `@warlock.js/core/tooling`; the adapter is a mapping,
9
+ * never a second parser.
10
+ *
11
+ * All paths are project-relative POSIX paths.
12
+ */
13
+ /**
14
+ * The role of a source file, from the framework's naming conventions. The
15
+ * Warlock adapter passes `InspectFile.role` through unchanged; any other
16
+ * string is allowed so a new role never breaks the book.
17
+ */
18
+ export type BookFileType = "controller" | "service" | "repository" | "model" | "use-case" | "seed" | "request" | "mail" | "job" | "event" | "client" | "migration" | "schema" | "resource" | "hook" | "component" | "util" | "type" | "config" | "locale" | "main" | "routes" | "worker" | "page" | "setup" | "layout" | "root" | "spec" | "source" | (string & {});
19
+ /** One public export of a file. */
20
+ export type BookExport = {
21
+ /** Export name; `default` and `*` stand for default and star exports. */
22
+ name: string;
23
+ /** First sentence of the comment above the export, or `null`. */
24
+ about: string | null;
25
+ };
26
+ /** One import of a file. */
27
+ export type BookImport = {
28
+ /** The specifier as written (`../models/product.model`, `@warlock.js/core`). */
29
+ specifier: string;
30
+ /** The project file it resolves to, or `null` for a package or an unresolved alias. */
31
+ file: string | null;
32
+ };
33
+ /** Facts about one source file. Code files only (`.ts`, `.tsx`, `.js`, …). */
34
+ export type BookFile = {
35
+ file: string;
36
+ /** `src/app/<module>`, or the containing top-level folder (`src/config`, `mobile/app`). */
37
+ module: string;
38
+ type: BookFileType;
39
+ lines: number;
40
+ /** The header sentence (first sentence of the comment at the top of the file), or `null`. */
41
+ about: string | null;
42
+ /** `@tag value` lines of the header comment, by tag name without `@` (`{ feature: ["auth"] }`). */
43
+ tags: Record<string, string[]>;
44
+ exports: BookExport[];
45
+ imports: BookImport[];
46
+ /** Project files that import this one. */
47
+ importedBy: string[];
48
+ /** The mobile app id when the file belongs to a mobile app's root, otherwise `null`. */
49
+ mobileApp: string | null;
50
+ };
51
+ /** One HTTP route. Mirrors `InspectRoute`, trimmed to what the book shows. */
52
+ export type BookRoute = {
53
+ /** Uppercase method; `ALL` for a route on every method. */
54
+ method: string;
55
+ /** Path as registered (`/products/:id`). */
56
+ path: string;
57
+ name: string | null;
58
+ /** The routes file that registered it, or `null`. */
59
+ sourceFile: string | null;
60
+ /** Handler function name, `Controller.action` for a controller tuple, `anonymous` when unnamed. */
61
+ handler: string;
62
+ /** Controller class name of a `[controller, "action"]` tuple, or `null`. */
63
+ controller: string | null;
64
+ action: string | null;
65
+ /** The file that defines the handler (resolved by the adapter), or `null` when unknown. */
66
+ handlerFile: string | null;
67
+ /** Middleware names in run order. */
68
+ middleware: string[];
69
+ /** Whether a guard requires a signed-in user, and which user types it accepts (empty = any). */
70
+ auth: {
71
+ required: boolean;
72
+ userTypes: string[];
73
+ };
74
+ /** Whether a page route registered it (the page itself is in `pages`). */
75
+ isPage: boolean;
76
+ description: string | null;
77
+ };
78
+ /**
79
+ * One site of a web app. A single-site app has one site with id `default`
80
+ * and root `src/web`; multi-site apps have one per `web.sites` key, rooted at
81
+ * `src/web/$sites/<key>`.
82
+ */
83
+ export type BookSite = {
84
+ id: string;
85
+ root: string;
86
+ /** URL prefix of the site, or `null`. */
87
+ basePath: string | null;
88
+ };
89
+ /** How a page can be reached from somewhere else. */
90
+ export type BookPageLink = {
91
+ type: "link" | "redirect";
92
+ /** The file that holds the link or redirect. */
93
+ from: string;
94
+ line: number;
95
+ };
96
+ /** One page of a site, from the web page graph (`discoverPageGraph`). */
97
+ export type BookPage = {
98
+ /** Site id (`default` in a single-site app). */
99
+ site: string;
100
+ /** Route path (`/products/:id`). */
101
+ route: string;
102
+ name: string | null;
103
+ /** The `*.page.tsx` file. */
104
+ file: string;
105
+ /** The `*.setup.ts` file holding the page's logic, or `null`. */
106
+ setupFile: string | null;
107
+ /** Layout files, outermost first. */
108
+ layouts: string[];
109
+ /** Files on the chain that export a loader. */
110
+ loaders: string[];
111
+ /** Action names (`default` for `action`). */
112
+ actions: string[];
113
+ /** What the page requires before it renders (`user`, middleware names). Empty when nothing. */
114
+ requires: string[];
115
+ /**
116
+ * Links and redirects that point at this page, read as plain values.
117
+ * `null` when the adapter cannot tell (shown as "unknown").
118
+ */
119
+ reachedFrom: BookPageLink[] | null;
120
+ };
121
+ /** One screen of a mobile app that uses file-based routing. */
122
+ export type BookScreen = {
123
+ /** Route as the router derives it from the file (`/products/[id]`). */
124
+ route: string;
125
+ file: string;
126
+ /** Layout files (`_layout.tsx`), outermost first. */
127
+ layouts: string[];
128
+ };
129
+ /** A mobile app that lives in the same repository. */
130
+ export type BookMobileApp = {
131
+ /** Id used by the book (`mobile`); the folder name of its root by default. */
132
+ id: string;
133
+ /** Project-relative root (`mobile`). */
134
+ root: string;
135
+ /**
136
+ * `files`: screens come from the file structure (`screens` is filled).
137
+ * `code`: navigation is defined in code; screens are declared by the agent
138
+ * in `grimoire/apps/<app>/screens/` and `screens` is empty.
139
+ */
140
+ routing: "files" | "code";
141
+ /** Folder that holds the file-based routes (`mobile/app`), or `null`. */
142
+ routesDir: string | null;
143
+ screens: BookScreen[];
144
+ };
145
+ /** The kinds of named thing a flow step may point at. */
146
+ export type BookNamedType = "mail" | "job" | "event" | "notification";
147
+ /** A mail, job, event or notification as code names it. */
148
+ export type BookNamedThing = {
149
+ type: BookNamedType;
150
+ /** The name a flow step uses (`order-confirmation`, `orders.shipped`). */
151
+ name: string;
152
+ /** The file that defines it, or `null` when only a registry knows it. */
153
+ file: string | null;
154
+ };
155
+ /** Everything an adapter reports, as one value. The builder caches it. */
156
+ export type BookFacts = {
157
+ files: BookFile[];
158
+ /** `null` when route facts were never collected (no `routes()` or a file-only build). */
159
+ routes: BookRoute[] | null;
160
+ sites: BookSite[];
161
+ pages: BookPage[];
162
+ mobile: BookMobileApp[];
163
+ named: BookNamedThing[];
164
+ /** Test files to scan for `@proves` lines (inside and outside the source roots). */
165
+ tests: string[];
166
+ };
167
+ /**
168
+ * What a framework adapter provides. Only `files` and `sourceRoots` are
169
+ * required; a missing method means "this framework has none of those".
170
+ *
171
+ * Every method receives the absolute project root. Only `routes` may load or
172
+ * boot the application: the builder caches its result and calls it only when
173
+ * the route cache is stale and the caller asked for fresh routes.
174
+ */
175
+ export type BookAdapter = {
176
+ /** Adapter name, stored in the book manifest (`warlock`). */
177
+ name: string;
178
+ /** Adapter version (the framework version); a change rebuilds the book. */
179
+ version: string;
180
+ /** Project-relative folders whose code files the book mirrors (`["src", "mobile"]`). */
181
+ sourceRoots(root: string): Promise<string[]>;
182
+ /** Facts for every code file under the source roots. Never executes app code. */
183
+ files(root: string): Promise<BookFile[]>;
184
+ /** HTTP routes. May boot the app. */
185
+ routes?(root: string): Promise<BookRoute[]>;
186
+ /**
187
+ * Files whose change makes the route cache stale, given the current file
188
+ * facts. Default (when absent): every `routes` file and everything it
189
+ * imports, every `config` file, `warlock.config.ts` and `package.json`.
190
+ */
191
+ routeInputs?(root: string, files: readonly BookFile[]): Promise<string[]>;
192
+ /** Sites of the web app. Static. */
193
+ sites?(root: string): Promise<BookSite[]>;
194
+ /** Pages of every site. Static (reads files only). */
195
+ pages?(root: string): Promise<BookPage[]>;
196
+ /** Mobile apps in the repository, with screens when they use file-based routing. Static. */
197
+ mobile?(root: string): Promise<BookMobileApp[]>;
198
+ /**
199
+ * Mails, jobs, events and notifications by the names code uses. May read a
200
+ * registry that needs the app booted: the builder caches it with the routes
201
+ * (same staleness rule, plus any change to a `mail`, `job`, `event` or
202
+ * `notification` file).
203
+ */
204
+ named?(root: string): Promise<BookNamedThing[]>;
205
+ /** Test files to scan for `@proves` lines. Static. */
206
+ tests?(root: string): Promise<string[]>;
207
+ };
208
+ //#endregion
209
+ //# sourceMappingURL=adapter.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/adapter.ts"],"mappings":";;;;;;;;;;;;;;;;;YAiBY;;YAiCA;;EAEV;;EAEA;;;YAIU;;EAEV;;EAEA;;;YAIU;EACV;;EAEA;EACA,MAAM;EACN;;EAEA;;EAEA,MAAM;EACN,SAAS;EACT,SAAS;;EAET;;EAEA;;;YAIU;;EAEV;;EAEA;EACA;;EAEA;;EAEA;;EAEA;EACA;;EAEA;;EAEA;;EAEA;IAAQ;IAAmB;;;EAE3B;EACA;;;;;;;YAQU;EACV;EACA;;EAEA;;;YAIU;EACV;;EAEA;EACA;;;YAIU;;EAEV;;EAEA;EACA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;EAEA;;;;;EAKA,aAAa;;;YAIH;;EAEV;EACA;;EAEA;;;YAIU;;EAEV;;EAEA;;;;;;EAMA;;EAEA;EACA,SAAS;;;YAIC;;YAGA;EACV,MAAM;;EAEN;;EAEA;;;YAIU;EACV,OAAO;;EAEP,QAAQ;EACR,OAAO;EACP,OAAO;EACP,QAAQ;EACR,OAAO;;EAEP;;;;;;;;;;YAWU;;EAEV;;EAEA;;EAEA,YAAY,eAAe;;EAE3B,MAAM,eAAe,QAAQ;;EAE7B,QAAQ,eAAe,QAAQ;;;;;;EAM/B,aAAa,cAAc,gBAAgB,aAAa;;EAExD,OAAO,eAAe,QAAQ;;EAE9B,OAAO,eAAe,QAAQ;;EAE9B,QAAQ,eAAe,QAAQ;;;;;;;EAO/B,OAAO,eAAe,QAAQ;;EAE9B,OAAO,eAAe"}
@@ -0,0 +1,233 @@
1
+ import { BookFacts, BookFileType, BookMobileApp, BookPage, BookScreen, BookSite } from "./adapter.mjs";
2
+ import { RouteFreshness } from "./findings.mjs";
3
+ //#region ../../packages/grimoire/src/contracts/book.d.ts
4
+ /** The version of every book and collected JSON shape. Bumped only for a breaking change. */
5
+ export declare const BOOK_SCHEMA_VERSION = 1;
6
+ /** A route as a book entry or list shows it. */
7
+ export type BookRouteRef = {
8
+ method: string;
9
+ path: string;
10
+ name: string | null;
11
+ };
12
+ /**
13
+ * `grimoire/book/<mirror path>.json`: one per code file.
14
+ * `src/app/auth/controllers/login.controller.ts` →
15
+ * `grimoire/book/app/auth/controllers/login.controller.json`.
16
+ */
17
+ export type BookEntry = {
18
+ schemaVersion: typeof BOOK_SCHEMA_VERSION;
19
+ /** The source file. */
20
+ file: string;
21
+ module: string;
22
+ type: BookFileType;
23
+ lines: number;
24
+ /** The header sentence, or `null`. */
25
+ about: string | null;
26
+ /** The feature that owns the file, or `null`. */
27
+ feature: string | null;
28
+ /** Features that import the file without owning it. */
29
+ borrowedBy: string[];
30
+ /** `<feature>/<flow>` of every flow whose steps reach the file. */
31
+ flows: string[];
32
+ exports: {
33
+ name: string;
34
+ about: string | null;
35
+ }[];
36
+ /** External packages it imports (`@warlock.js/core`, `dayjs`), by package name. */
37
+ packages: string[];
38
+ /** Project files it imports. */
39
+ imports: string[];
40
+ /** Project files that import it. */
41
+ importedBy: string[];
42
+ /**
43
+ * Routes this file registers (`via: "registers"`, a routes file) or handles
44
+ * (`via: "handles"`, the handler's file). Routes that only reach the file
45
+ * through imports are answered by `scry --impact`, not stored here.
46
+ */
47
+ routes: (BookRouteRef & {
48
+ via: "registers" | "handles";
49
+ })[];
50
+ /** Pages this file is the page, setup or layout file of: `<site> <route>`. */
51
+ pages: {
52
+ site: string;
53
+ route: string;
54
+ via: "page" | "setup" | "layout";
55
+ }[];
56
+ /** Mobile screens this file is the screen or layout file of. */
57
+ screens: {
58
+ app: string;
59
+ route: string;
60
+ via: "screen" | "layout";
61
+ }[];
62
+ };
63
+ /** `grimoire/book/app/routes.json`: every route, grouped by the module of its routes file. */
64
+ export type BookRoutesFile = {
65
+ schemaVersion: typeof BOOK_SCHEMA_VERSION;
66
+ /** Module (`src/app/catalog`) → routes, in registration order. `(none)` holds routes with no source file. */
67
+ modules: Record<string, (BookRouteRef & {
68
+ handlerFile: string | null;
69
+ })[]>;
70
+ };
71
+ /** `grimoire/book/web/<site>.pages.json`: the pages of one site. */
72
+ export type BookSitePagesFile = {
73
+ schemaVersion: typeof BOOK_SCHEMA_VERSION;
74
+ site: BookSite;
75
+ pages: BookPage[];
76
+ };
77
+ /** `grimoire/book/mobile/<app>.screens.json`: one mobile app and its screens. */
78
+ export type BookMobileScreensFile = {
79
+ schemaVersion: typeof BOOK_SCHEMA_VERSION;
80
+ app: Omit<BookMobileApp, "screens">;
81
+ screens: BookScreen[];
82
+ };
83
+ /**
84
+ * The data behind `grimoire/book/<module>/index.md`, the module summary.
85
+ *
86
+ * The Markdown is:
87
+ *
88
+ * ```md
89
+ * # src/app/catalog
90
+ *
91
+ * Feature: catalog. 14 files, 820 lines.
92
+ *
93
+ * ## Files
94
+ * - controllers/new-arrivals.controller.ts controller Answers the new arrivals request.
95
+ *
96
+ * ## Routes
97
+ * - GET /products/new-arrivals
98
+ *
99
+ * ## Used by
100
+ * - src/app/orders (3 files)
101
+ * ```
102
+ *
103
+ * Sections with nothing in them are left out. Files are listed by path
104
+ * relative to the module, in path order; the header sentence is omitted when
105
+ * the file has none.
106
+ */
107
+ export type BookModuleSummary = {
108
+ module: string;
109
+ /** Owning features of the module's files, most files first. */
110
+ features: string[];
111
+ files: {
112
+ file: string;
113
+ type: BookFileType;
114
+ lines: number;
115
+ about: string | null;
116
+ }[];
117
+ routes: BookRouteRef[];
118
+ /** Other modules importing files of this one, with how many of their files do. */
119
+ usedBy: {
120
+ module: string;
121
+ files: number;
122
+ }[];
123
+ };
124
+ /** One source file as the manifest remembers it. */
125
+ export type BookManifestFile = {
126
+ /** sha256 of the content (hex). */
127
+ hash: string;
128
+ /** Size and modification time, to skip hashing unchanged files. */
129
+ size: number;
130
+ mtimeMs: number;
131
+ /** The book entry path (`grimoire/book/...json`), or `null` for a file with no entry. */
132
+ entry: string | null;
133
+ };
134
+ /**
135
+ * `grimoire/book/manifest.json`: the fingerprint that says whether the book is
136
+ * fresh. The book is fresh when the grimoire version, adapter name and version
137
+ * and `schemaVersion` match, the set of files under the source roots is the
138
+ * same, every file's hash matches, and the written-files hash matches.
139
+ */
140
+ export type BookManifest = {
141
+ schemaVersion: typeof BOOK_SCHEMA_VERSION;
142
+ /** `@warlock.js/grimoire` version that wrote the book. */
143
+ grimoireVersion: string;
144
+ adapter: {
145
+ name: string;
146
+ version: string;
147
+ };
148
+ /** ISO time of the last build that changed anything. */
149
+ builtAt: string;
150
+ sourceRoots: string[];
151
+ /** Every file under the source roots (code or not), by project-relative path. */
152
+ files: Record<string, BookManifestFile>;
153
+ /** Test files scanned for `@proves`, with their hashes. */
154
+ tests: Record<string, string>;
155
+ /** `WrittenGrimoire.hash` the ownership and book maps were built from. */
156
+ writtenHash: string;
157
+ /**
158
+ * The cache of facts that need the app booted (routes, named things). It is
159
+ * stale when any input's hash differs from the one stored here, or an input
160
+ * was added or removed.
161
+ */
162
+ boot: {
163
+ /** ISO time the routes were read, or `null` when never. */
164
+ collectedAt: string | null;
165
+ inputs: Record<string, string>;
166
+ };
167
+ };
168
+ /**
169
+ * `grimoire/book/.cache/facts.json`: the adapter's last answer, so a file-only
170
+ * question never calls the adapter's `routes()` and loading the book reads one
171
+ * file. Machine use only.
172
+ */
173
+ export type BookFactsCache = {
174
+ schemaVersion: typeof BOOK_SCHEMA_VERSION;
175
+ facts: BookFacts;
176
+ };
177
+ /** The book as `loadBook()` returns it. */
178
+ export type LoadedBook = {
179
+ /** Absolute project root. */
180
+ root: string;
181
+ manifest: BookManifest;
182
+ facts: BookFacts;
183
+ routes: RouteFreshness;
184
+ };
185
+ /** Options of `buildBook()`. */
186
+ export type BuildBookOptions = {
187
+ /**
188
+ * `fresh`: refresh stale route facts (may boot the app through the adapter).
189
+ * `cached`: never boot; reuse cached route facts, reported `stale` when their
190
+ * inputs changed and `missing` when there are none.
191
+ * Default `cached`. `warlock grimoire build` and `check` pass `fresh`.
192
+ */
193
+ routes?: "fresh" | "cached";
194
+ /** Rebuild every entry even when the manifest says the book is fresh. */
195
+ force?: boolean;
196
+ /** Clock for `builtAt`. */
197
+ now?: () => Date;
198
+ /** `false` computes the book in memory only and writes nothing. Default `true`. */
199
+ write?: boolean;
200
+ };
201
+ /** What `buildBook()` did. */
202
+ export type BuildBookResult = {
203
+ book: LoadedBook;
204
+ /** `false` when the manifest matched: the adapter was not called and nothing was written. */
205
+ rebuilt: boolean;
206
+ /** Source files added, changed or removed since the previous manifest. */
207
+ changed: string[];
208
+ };
209
+ /**
210
+ * What the book entries need from the written files: owner, borrowers and
211
+ * flows per source file. `openGrimoire()` computes it (ownership and book
212
+ * maps) and hands it to `writeBook()`.
213
+ */
214
+ export type BookAnnotations = {
215
+ /** `WrittenGrimoire.hash` it was computed from; stored in the manifest. */
216
+ writtenHash: string;
217
+ /** Test file → sha256, stored in the manifest. */
218
+ tests: Record<string, string>;
219
+ files: Record<string, {
220
+ feature: string | null;
221
+ borrowedBy: string[];
222
+ flows: string[];
223
+ }>;
224
+ };
225
+ /** What `writeBook()` wrote. Unchanged files are not rewritten. */
226
+ export type WriteBookResult = {
227
+ /** Book files created or changed (entries, summaries, lists), project-relative. */
228
+ written: string[];
229
+ /** Book files removed because their source is gone. */
230
+ removed: string[];
231
+ };
232
+ //#endregion
233
+ //# sourceMappingURL=book.d.mts.map
@@ -0,0 +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;;;;;;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"}
@@ -0,0 +1,7 @@
1
+ //#region ../../packages/grimoire/src/contracts/book.ts
2
+ /** The version of every book and collected JSON shape. Bumped only for a breaking change. */
3
+ const BOOK_SCHEMA_VERSION = 1;
4
+
5
+ //#endregion
6
+ export { BOOK_SCHEMA_VERSION };
7
+ //# sourceMappingURL=book.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"book.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/book.ts"],"sourcesContent":["/**\n * The generated book under `grimoire/book/`. Warlock writes every file here;\n * the folder is ignored by git and rebuilt when sources or written files\n * change. Paths of the files are decided by `bookEntryPath()` and the\n * constants in `src/paths`.\n *\n * JSON files carry no timestamps except `manifest.json`, so an unchanged\n * project rewrites nothing and golden files stay stable.\n */\nimport type {\n BookFacts,\n BookFileType,\n BookMobileApp,\n BookPage,\n BookScreen,\n BookSite,\n} from \"./adapter\";\nimport type { RouteFreshness } from \"./findings\";\n\n/** The version of every book and collected JSON shape. Bumped only for a breaking change. */\nexport const BOOK_SCHEMA_VERSION = 1;\n\n/** A route as a book entry or list shows it. */\nexport type BookRouteRef = {\n method: string;\n path: string;\n name: string | null;\n};\n\n/**\n * `grimoire/book/<mirror path>.json`: one per code file.\n * `src/app/auth/controllers/login.controller.ts` →\n * `grimoire/book/app/auth/controllers/login.controller.json`.\n */\nexport type BookEntry = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n /** The source file. */\n file: string;\n module: string;\n type: BookFileType;\n lines: number;\n /** The header sentence, or `null`. */\n about: string | null;\n /** The feature that owns the file, or `null`. */\n feature: string | null;\n /** Features that import the file without owning it. */\n borrowedBy: string[];\n /** `<feature>/<flow>` of every flow whose steps reach the file. */\n flows: string[];\n exports: { name: string; about: string | null }[];\n /** External packages it imports (`@warlock.js/core`, `dayjs`), by package name. */\n packages: string[];\n /** Project files it imports. */\n imports: string[];\n /** Project files that import it. */\n importedBy: string[];\n /**\n * Routes this file registers (`via: \"registers\"`, a routes file) or handles\n * (`via: \"handles\"`, the handler's file). Routes that only reach the file\n * through imports are answered by `scry --impact`, not stored here.\n */\n routes: (BookRouteRef & { via: \"registers\" | \"handles\" })[];\n /** Pages this file is the page, setup or layout file of: `<site> <route>`. */\n pages: { site: string; route: string; via: \"page\" | \"setup\" | \"layout\" }[];\n /** Mobile screens this file is the screen or layout file of. */\n screens: { app: string; route: string; via: \"screen\" | \"layout\" }[];\n};\n\n/** `grimoire/book/app/routes.json`: every route, grouped by the module of its routes file. */\nexport type BookRoutesFile = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n /** Module (`src/app/catalog`) → routes, in registration order. `(none)` holds routes with no source file. */\n modules: Record<string, (BookRouteRef & { handlerFile: string | null })[]>;\n};\n\n/** `grimoire/book/web/<site>.pages.json`: the pages of one site. */\nexport type BookSitePagesFile = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n site: BookSite;\n pages: BookPage[];\n};\n\n/** `grimoire/book/mobile/<app>.screens.json`: one mobile app and its screens. */\nexport type BookMobileScreensFile = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n app: Omit<BookMobileApp, \"screens\">;\n screens: BookScreen[];\n};\n\n/**\n * The data behind `grimoire/book/<module>/index.md`, the module summary.\n *\n * The Markdown is:\n *\n * ```md\n * # src/app/catalog\n *\n * Feature: catalog. 14 files, 820 lines.\n *\n * ## Files\n * - controllers/new-arrivals.controller.ts controller Answers the new arrivals request.\n *\n * ## Routes\n * - GET /products/new-arrivals\n *\n * ## Used by\n * - src/app/orders (3 files)\n * ```\n *\n * Sections with nothing in them are left out. Files are listed by path\n * relative to the module, in path order; the header sentence is omitted when\n * the file has none.\n */\nexport type BookModuleSummary = {\n module: string;\n /** Owning features of the module's files, most files first. */\n features: string[];\n files: { file: string; type: BookFileType; lines: number; about: string | null }[];\n routes: BookRouteRef[];\n /** Other modules importing files of this one, with how many of their files do. */\n usedBy: { module: string; files: number }[];\n};\n\n/** One source file as the manifest remembers it. */\nexport type BookManifestFile = {\n /** sha256 of the content (hex). */\n hash: string;\n /** Size and modification time, to skip hashing unchanged files. */\n size: number;\n mtimeMs: number;\n /** The book entry path (`grimoire/book/...json`), or `null` for a file with no entry. */\n entry: string | null;\n};\n\n/**\n * `grimoire/book/manifest.json`: the fingerprint that says whether the book is\n * fresh. The book is fresh when the grimoire version, adapter name and version\n * and `schemaVersion` match, the set of files under the source roots is the\n * same, every file's hash matches, and the written-files hash matches.\n */\nexport type BookManifest = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n /** `@warlock.js/grimoire` version that wrote the book. */\n grimoireVersion: string;\n adapter: { name: string; version: string };\n /** ISO time of the last build that changed anything. */\n builtAt: string;\n sourceRoots: string[];\n /** Every file under the source roots (code or not), by project-relative path. */\n files: Record<string, BookManifestFile>;\n /** Test files scanned for `@proves`, with their hashes. */\n tests: Record<string, string>;\n /** `WrittenGrimoire.hash` the ownership and book maps were built from. */\n writtenHash: string;\n /**\n * The cache of facts that need the app booted (routes, named things). It is\n * stale when any input's hash differs from the one stored here, or an input\n * was added or removed.\n */\n boot: {\n /** ISO time the routes were read, or `null` when never. */\n collectedAt: string | null;\n inputs: Record<string, string>;\n };\n};\n\n/**\n * `grimoire/book/.cache/facts.json`: the adapter's last answer, so a file-only\n * question never calls the adapter's `routes()` and loading the book reads one\n * file. Machine use only.\n */\nexport type BookFactsCache = {\n schemaVersion: typeof BOOK_SCHEMA_VERSION;\n facts: BookFacts;\n};\n\n/** The book as `loadBook()` returns it. */\nexport type LoadedBook = {\n /** Absolute project root. */\n root: string;\n manifest: BookManifest;\n facts: BookFacts;\n routes: RouteFreshness;\n};\n\n/** Options of `buildBook()`. */\nexport type BuildBookOptions = {\n /**\n * `fresh`: refresh stale route facts (may boot the app through the adapter).\n * `cached`: never boot; reuse cached route facts, reported `stale` when their\n * inputs changed and `missing` when there are none.\n * Default `cached`. `warlock grimoire build` and `check` pass `fresh`.\n */\n routes?: \"fresh\" | \"cached\";\n /** Rebuild every entry even when the manifest says the book is fresh. */\n force?: boolean;\n /** Clock for `builtAt`. */\n now?: () => Date;\n /** `false` computes the book in memory only and writes nothing. Default `true`. */\n write?: boolean;\n};\n\n/** What `buildBook()` did. */\nexport type BuildBookResult = {\n book: LoadedBook;\n /** `false` when the manifest matched: the adapter was not called and nothing was written. */\n rebuilt: boolean;\n /** Source files added, changed or removed since the previous manifest. */\n changed: string[];\n};\n\n/**\n * What the book entries need from the written files: owner, borrowers and\n * flows per source file. `openGrimoire()` computes it (ownership and book\n * maps) and hands it to `writeBook()`.\n */\nexport type BookAnnotations = {\n /** `WrittenGrimoire.hash` it was computed from; stored in the manifest. */\n writtenHash: string;\n /** Test file → sha256, stored in the manifest. */\n tests: Record<string, string>;\n files: Record<string, { feature: string | null; borrowedBy: string[]; flows: string[] }>;\n};\n\n/** What `writeBook()` wrote. Unchanged files are not rewritten. */\nexport type WriteBookResult = {\n /** Book files created or changed (entries, summaries, lists), project-relative. */\n written: string[];\n /** Book files removed because their source is gone. */\n removed: string[];\n};\n"],"mappings":";;AAoBA,MAAa,sBAAsB"}