@warlock.js/grimoire 5.63.0 → 5.64.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 (194) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/esm/book/build.d.mts.map +1 -1
  3. package/esm/book/build.mjs +24 -2
  4. package/esm/book/build.mjs.map +1 -1
  5. package/esm/check/check-grimoire.d.mts.map +1 -1
  6. package/esm/check/check-grimoire.mjs +11 -1
  7. package/esm/check/check-grimoire.mjs.map +1 -1
  8. package/esm/check/rules/api-snapshot.mjs +39 -0
  9. package/esm/check/rules/api-snapshot.mjs.map +1 -0
  10. package/esm/check/rules/code-rules.mjs +45 -0
  11. package/esm/check/rules/code-rules.mjs.map +1 -0
  12. package/esm/check/rules/drift.mjs +54 -0
  13. package/esm/check/rules/drift.mjs.map +1 -0
  14. package/esm/check/rules/focused-tests.mjs +39 -0
  15. package/esm/check/rules/focused-tests.mjs.map +1 -0
  16. package/esm/check/rules/shows.mjs +52 -0
  17. package/esm/check/rules/shows.mjs.map +1 -0
  18. package/esm/codes/codes.d.mts +48 -0
  19. package/esm/codes/codes.d.mts.map +1 -1
  20. package/esm/codes/codes.mjs +26 -1
  21. package/esm/codes/codes.mjs.map +1 -1
  22. package/esm/contracts/adapter.d.mts +6 -0
  23. package/esm/contracts/adapter.d.mts.map +1 -1
  24. package/esm/contracts/guard.d.mts +104 -0
  25. package/esm/contracts/guard.d.mts.map +1 -0
  26. package/esm/contracts/index.mjs +5 -0
  27. package/esm/contracts/matrix.d.mts +75 -0
  28. package/esm/contracts/matrix.d.mts.map +1 -0
  29. package/esm/contracts/scry.d.mts +21 -0
  30. package/esm/contracts/scry.d.mts.map +1 -1
  31. package/esm/contracts/settings.d.mts +71 -0
  32. package/esm/contracts/settings.d.mts.map +1 -0
  33. package/esm/contracts/settings.mjs +67 -0
  34. package/esm/contracts/settings.mjs.map +1 -0
  35. package/esm/contracts/shots.d.mts +146 -0
  36. package/esm/contracts/shots.d.mts.map +1 -0
  37. package/esm/contracts/snapshot.d.mts +10 -0
  38. package/esm/contracts/snapshot.d.mts.map +1 -1
  39. package/esm/contracts/written.d.mts +13 -0
  40. package/esm/contracts/written.d.mts.map +1 -1
  41. package/esm/contracts/written.mjs +7 -1
  42. package/esm/contracts/written.mjs.map +1 -1
  43. package/esm/devtools/approvals.mjs +59 -0
  44. package/esm/devtools/approvals.mjs.map +1 -0
  45. package/esm/devtools/data.mjs +2 -0
  46. package/esm/devtools/data.mjs.map +1 -1
  47. package/esm/devtools/graphs.mjs +13 -3
  48. package/esm/devtools/graphs.mjs.map +1 -1
  49. package/esm/devtools/index.d.mts.map +1 -1
  50. package/esm/devtools/index.mjs +32 -2
  51. package/esm/devtools/index.mjs.map +1 -1
  52. package/esm/devtools/matrix.mjs +207 -0
  53. package/esm/devtools/matrix.mjs.map +1 -0
  54. package/esm/devtools/product-map.d.mts.map +1 -1
  55. package/esm/devtools/product-map.mjs +87 -1
  56. package/esm/devtools/product-map.mjs.map +1 -1
  57. package/esm/devtools/site.d.mts.map +1 -1
  58. package/esm/devtools/site.mjs +12 -3
  59. package/esm/devtools/site.mjs.map +1 -1
  60. package/esm/devtools/snapshot-source.mjs +5 -1
  61. package/esm/devtools/snapshot-source.mjs.map +1 -1
  62. package/esm/git/index.d.mts +20 -0
  63. package/esm/git/index.d.mts.map +1 -0
  64. package/esm/git/index.mjs +280 -0
  65. package/esm/git/index.mjs.map +1 -0
  66. package/esm/guard/api.mjs +70 -0
  67. package/esm/guard/api.mjs.map +1 -0
  68. package/esm/guard/assertions.mjs +18 -0
  69. package/esm/guard/assertions.mjs.map +1 -0
  70. package/esm/guard/collect.mjs +139 -0
  71. package/esm/guard/collect.mjs.map +1 -0
  72. package/esm/guard/format.mjs +27 -0
  73. package/esm/guard/format.mjs.map +1 -0
  74. package/esm/guard/glob.mjs +79 -0
  75. package/esm/guard/glob.mjs.map +1 -0
  76. package/esm/guard/index.mjs +9 -0
  77. package/esm/guard/rules.mjs +310 -0
  78. package/esm/guard/rules.mjs.map +1 -0
  79. package/esm/guard/scope.mjs +95 -0
  80. package/esm/guard/scope.mjs.map +1 -0
  81. package/esm/index.d.mts +10 -3
  82. package/esm/index.mjs +6 -2
  83. package/esm/paths/index.d.mts +15 -1
  84. package/esm/paths/index.d.mts.map +1 -1
  85. package/esm/paths/index.mjs +27 -3
  86. package/esm/paths/index.mjs.map +1 -1
  87. package/esm/proves/index.mjs +2 -1
  88. package/esm/proves/scan-proofs.mjs +1 -1
  89. package/esm/proves/scan-proofs.mjs.map +1 -1
  90. package/esm/proves/scan-shows.d.mts +21 -0
  91. package/esm/proves/scan-shows.d.mts.map +1 -0
  92. package/esm/proves/scan-shows.mjs +168 -0
  93. package/esm/proves/scan-shows.mjs.map +1 -0
  94. package/esm/releases/index.d.mts.map +1 -1
  95. package/esm/releases/index.mjs +5 -3
  96. package/esm/releases/index.mjs.map +1 -1
  97. package/esm/releases/stamp.mjs +121 -0
  98. package/esm/releases/stamp.mjs.map +1 -0
  99. package/esm/rules/focused.mjs +26 -0
  100. package/esm/rules/focused.mjs.map +1 -0
  101. package/esm/rules/index.mjs +88 -0
  102. package/esm/rules/index.mjs.map +1 -0
  103. package/esm/rules/logical-css.mjs +112 -0
  104. package/esm/rules/logical-css.mjs.map +1 -0
  105. package/esm/rules/no-js-imports.mjs +22 -0
  106. package/esm/rules/no-js-imports.mjs.map +1 -0
  107. package/esm/rules/scan.mjs +196 -0
  108. package/esm/rules/scan.mjs.map +1 -0
  109. package/esm/rules/specific-errors.mjs +51 -0
  110. package/esm/rules/specific-errors.mjs.map +1 -0
  111. package/esm/rules/type-discriminator.mjs +27 -0
  112. package/esm/rules/type-discriminator.mjs.map +1 -0
  113. package/esm/scry/also-changes.mjs +106 -0
  114. package/esm/scry/also-changes.mjs.map +1 -0
  115. package/esm/scry/format.d.mts.map +1 -1
  116. package/esm/scry/format.mjs +22 -0
  117. package/esm/scry/format.mjs.map +1 -1
  118. package/esm/scry/query.d.mts.map +1 -1
  119. package/esm/scry/query.mjs +7 -2
  120. package/esm/scry/query.mjs.map +1 -1
  121. package/esm/scry/search.d.mts.map +1 -1
  122. package/esm/scry/search.mjs +43 -11
  123. package/esm/scry/search.mjs.map +1 -1
  124. package/esm/shots/approve.mjs +195 -0
  125. package/esm/shots/approve.mjs.map +1 -0
  126. package/esm/shots/drift.mjs +174 -0
  127. package/esm/shots/drift.mjs.map +1 -0
  128. package/esm/shots/png.mjs +166 -0
  129. package/esm/shots/png.mjs.map +1 -0
  130. package/esm/shots/state.mjs +43 -0
  131. package/esm/shots/state.mjs.map +1 -0
  132. package/esm/shots/store.mjs +66 -0
  133. package/esm/shots/store.mjs.map +1 -0
  134. package/esm/shots/touched.mjs +38 -0
  135. package/esm/shots/touched.mjs.map +1 -0
  136. package/esm/warlock/adapter.d.mts.map +1 -1
  137. package/esm/warlock/adapter.mjs +15 -2
  138. package/esm/warlock/adapter.mjs.map +1 -1
  139. package/esm/warlock/api-command.mjs +41 -0
  140. package/esm/warlock/api-command.mjs.map +1 -0
  141. package/esm/warlock/approve-command.mjs +80 -0
  142. package/esm/warlock/approve-command.mjs.map +1 -0
  143. package/esm/warlock/commands.d.mts +1 -1
  144. package/esm/warlock/commands.d.mts.map +1 -1
  145. package/esm/warlock/commands.mjs +61 -8
  146. package/esm/warlock/commands.mjs.map +1 -1
  147. package/esm/warlock/guard-command.mjs +116 -0
  148. package/esm/warlock/guard-command.mjs.map +1 -0
  149. package/esm/warlock/index.d.mts +2 -1
  150. package/esm/warlock/index.mjs +2 -1
  151. package/esm/warlock/languages.mjs +75 -0
  152. package/esm/warlock/languages.mjs.map +1 -0
  153. package/esm/warlock/mcp-tools.mjs +2 -2
  154. package/esm/warlock/mcp-tools.mjs.map +1 -1
  155. package/esm/warlock/release-command.mjs +65 -0
  156. package/esm/warlock/release-command.mjs.map +1 -0
  157. package/esm/warlock/shows.d.mts +35 -0
  158. package/esm/warlock/shows.d.mts.map +1 -0
  159. package/esm/warlock/shows.mjs +195 -0
  160. package/esm/warlock/shows.mjs.map +1 -0
  161. package/esm/workspace/cache.mjs +4 -1
  162. package/esm/workspace/cache.mjs.map +1 -1
  163. package/esm/workspace/derived.mjs +11 -6
  164. package/esm/workspace/derived.mjs.map +1 -1
  165. package/esm/workspace/index.d.mts.map +1 -1
  166. package/esm/workspace/index.mjs +8 -1
  167. package/esm/workspace/index.mjs.map +1 -1
  168. package/esm/workspace/stored.mjs +4 -1
  169. package/esm/workspace/stored.mjs.map +1 -1
  170. package/esm/written/features.mjs +21 -5
  171. package/esm/written/features.mjs.map +1 -1
  172. package/esm/written/index.mjs +2 -1
  173. package/esm/written/parse-grimoire.d.mts.map +1 -1
  174. package/esm/written/parse-grimoire.mjs +16 -3
  175. package/esm/written/parse-grimoire.mjs.map +1 -1
  176. package/esm/written/settings.d.mts +11 -0
  177. package/esm/written/settings.d.mts.map +1 -0
  178. package/esm/written/settings.mjs +88 -0
  179. package/esm/written/settings.mjs.map +1 -0
  180. package/llms-full.txt +276 -39
  181. package/llms.txt +2 -0
  182. package/package.json +3 -3
  183. package/skills/backfill-a-grimoire/SKILL.md +4 -0
  184. package/skills/describe-an-app/SKILL.md +4 -1
  185. package/skills/guard-a-change/SKILL.md +85 -0
  186. package/skills/index.md +7 -3
  187. package/skills/record-a-change/SKILL.md +52 -16
  188. package/skills/review-a-change/SKILL.md +53 -0
  189. package/skills/use-the-grimoire/SKILL.md +21 -18
  190. package/skills/write-a-feature/SKILL.md +42 -1
  191. package/ui/grimoire-view.js +756 -40
  192. package/ui/grimoire.css +303 -28
  193. package/ui/product-map.css +43 -7
  194. package/ui/product-map.js +212 -37
@@ -0,0 +1,71 @@
1
+ import { Located, SourceLocation } from "./location.mjs";
2
+ //#region ../../packages/grimoire/src/contracts/settings.d.ts
3
+ /**
4
+ * When `@shows` scenes capture screenshots:
5
+ * - `changed`: only the flows of the features the change touches (git diff against the base);
6
+ * - `all`: every `@shows` scene (run this before a release);
7
+ * - `off`: no scene runs and nothing is captured.
8
+ */
9
+ export type ScreenshotMode = "changed" | "all" | "off";
10
+ /** Every screenshot mode, in the order the docs list them. */
11
+ export declare const SCREENSHOT_MODES: readonly ScreenshotMode[];
12
+ /**
13
+ * A code rule: a repeated correction turned into a check.
14
+ * - `logical-css`: no physical directions (`margin-left`, `text-align: left`, `ml-4`, `text-left`, `left-0`), so RTL works;
15
+ * - `specific-errors`: no generic user-facing error text ("Something went wrong") on its own;
16
+ * - `type-discriminator`: discriminator fields are named `type`, never `kind`;
17
+ * - `no-js-imports`: relative import paths carry no `.js` extension.
18
+ */
19
+ export type CodeRuleName = "logical-css" | "specific-errors" | "type-discriminator" | "no-js-imports";
20
+ /** Every code rule. */
21
+ export declare const CODE_RULES: readonly CodeRuleName[];
22
+ /**
23
+ * A part of the project a change may touch only when its task names it
24
+ * (`- Touches: auth, migrations`). `public-api` has no globs: it is the
25
+ * difference between the routes and `grimoire/approved/api.json`.
26
+ * `dependencies` counts only added or changed dependency entries of a
27
+ * `package.json`, not every edit of the file.
28
+ */
29
+ export type ProtectedArea = {
30
+ name: string;
31
+ /** Project-relative globs (`**` crosses folders, `*` stays inside one). */
32
+ globs: string[];
33
+ };
34
+ /** The built-in protected areas. A `protected` line in the settings with the same name replaces its globs. */
35
+ export declare const DEFAULT_PROTECTED_AREAS: readonly ProtectedArea[];
36
+ /** `grimoire/settings.md` as written (`WrittenGrimoire.settings`); `GrimoireSettings` is it with the defaults filled in. */
37
+ export type WrittenSettings = {
38
+ file: string;
39
+ languages: Located<string>[];
40
+ screenshots: Located<ScreenshotMode> | null;
41
+ /** `null` when the key is not written; `[]` when written empty. */
42
+ rules: Located<CodeRuleName>[] | null;
43
+ /** `- <name> <glob> [<glob>…]` lines of `protected`. */
44
+ protected: {
45
+ name: string;
46
+ globs: string[];
47
+ at: SourceLocation;
48
+ }[];
49
+ };
50
+ /** The settings every reader uses: the written file with its defaults filled in. */
51
+ export type GrimoireSettings = {
52
+ /** `grimoire/settings.md` when written, else `null`. */
53
+ file: string | null;
54
+ /** The app's languages, in order (`["en", "ar"]`); empty when the app names none. */
55
+ languages: string[];
56
+ /** Where `languages` came from: the settings file, the adapter's `languages()`, or nowhere. */
57
+ languagesFrom: "settings" | "adapter" | "none";
58
+ screenshots: ScreenshotMode;
59
+ /**
60
+ * The code rules written in `rules`, or `null` when the key is not written:
61
+ * then `grimoire check` runs none and `grimoire guard` runs every rule on
62
+ * the lines a change adds. `[]` turns them off everywhere.
63
+ */
64
+ rules: CodeRuleName[] | null;
65
+ /** The built-in areas with the written lines applied. */
66
+ protected: ProtectedArea[];
67
+ };
68
+ /** What a project without `grimoire/settings.md` (and an adapter with no languages) gets. */
69
+ export declare const DEFAULT_GRIMOIRE_SETTINGS: GrimoireSettings;
70
+ //#endregion
71
+ //# sourceMappingURL=settings.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/settings.ts"],"mappings":";;;;;;;;YA0BY;;qBAGC,2BAA2B;;;;;;;;YAS5B;;qBAOC,qBAAqB;;;;;;;;YActB;EACV;;EAEA;;;qBAIW,kCAAkC;;YAanC;EACV;EACA,WAAW;EACX,aAAa,QAAQ;;EAErB,OAAO,QAAQ;;EAEf;IAAa;IAAc;IAAiB,IAAI;;;;YAItC;;EAEV;;EAEA;;EAEA;EACA,aAAa;;;;;;EAMb,OAAO;;EAEP,WAAW;;;qBAIA,2BAA2B"}
@@ -0,0 +1,67 @@
1
+ //#region ../../packages/grimoire/src/contracts/settings.ts
2
+ /** Every screenshot mode, in the order the docs list them. */
3
+ const SCREENSHOT_MODES = [
4
+ "changed",
5
+ "all",
6
+ "off"
7
+ ];
8
+ /** Every code rule. */
9
+ const CODE_RULES = [
10
+ "logical-css",
11
+ "specific-errors",
12
+ "type-discriminator",
13
+ "no-js-imports"
14
+ ];
15
+ /** The built-in protected areas. A `protected` line in the settings with the same name replaces its globs. */
16
+ const DEFAULT_PROTECTED_AREAS = [
17
+ {
18
+ name: "migrations",
19
+ globs: ["**/migrations/**", "**/*.migration.ts"]
20
+ },
21
+ {
22
+ name: "auth",
23
+ globs: ["src/app/auth/**", "src/config/auth.ts"]
24
+ },
25
+ {
26
+ name: "config",
27
+ globs: [
28
+ "src/config/**",
29
+ "warlock.config.ts",
30
+ ".env.example"
31
+ ]
32
+ },
33
+ {
34
+ name: "lockfile",
35
+ globs: [
36
+ "pnpm-lock.yaml",
37
+ "package-lock.json",
38
+ "yarn.lock",
39
+ "bun.lock",
40
+ "bun.lockb"
41
+ ]
42
+ },
43
+ {
44
+ name: "dependencies",
45
+ globs: ["package.json", "**/package.json"]
46
+ },
47
+ {
48
+ name: "public-api",
49
+ globs: []
50
+ }
51
+ ];
52
+ /** What a project without `grimoire/settings.md` (and an adapter with no languages) gets. */
53
+ const DEFAULT_GRIMOIRE_SETTINGS = {
54
+ file: null,
55
+ languages: [],
56
+ languagesFrom: "none",
57
+ screenshots: "changed",
58
+ rules: null,
59
+ protected: DEFAULT_PROTECTED_AREAS.map((area) => ({
60
+ name: area.name,
61
+ globs: [...area.globs]
62
+ }))
63
+ };
64
+
65
+ //#endregion
66
+ export { CODE_RULES, DEFAULT_GRIMOIRE_SETTINGS, DEFAULT_PROTECTED_AREAS, SCREENSHOT_MODES };
67
+ //# sourceMappingURL=settings.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settings.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/settings.ts"],"sourcesContent":["/**\n * Project settings: `grimoire/settings.md`, a front-matter-only written file\n * (the same grammar as every other written file), read once per snapshot.\n *\n * ```md\n * ---\n * languages: [en, ar]\n * screenshots: changed\n * rules: [logical-css, specific-errors, type-discriminator, no-js-imports]\n * protected:\n * - payments src/app/payments/** src/config/payments.ts\n * ---\n * ```\n *\n * Every key is optional; a project without the file gets\n * {@link DEFAULT_GRIMOIRE_SETTINGS} (with the adapter's languages).\n */\n\nimport type { Located, SourceLocation } from \"./location\";\n\n/**\n * When `@shows` scenes capture screenshots:\n * - `changed`: only the flows of the features the change touches (git diff against the base);\n * - `all`: every `@shows` scene (run this before a release);\n * - `off`: no scene runs and nothing is captured.\n */\nexport type ScreenshotMode = \"changed\" | \"all\" | \"off\";\n\n/** Every screenshot mode, in the order the docs list them. */\nexport const SCREENSHOT_MODES: readonly ScreenshotMode[] = [\"changed\", \"all\", \"off\"];\n\n/**\n * A code rule: a repeated correction turned into a check.\n * - `logical-css`: no physical directions (`margin-left`, `text-align: left`, `ml-4`, `text-left`, `left-0`), so RTL works;\n * - `specific-errors`: no generic user-facing error text (\"Something went wrong\") on its own;\n * - `type-discriminator`: discriminator fields are named `type`, never `kind`;\n * - `no-js-imports`: relative import paths carry no `.js` extension.\n */\nexport type CodeRuleName =\n | \"logical-css\"\n | \"specific-errors\"\n | \"type-discriminator\"\n | \"no-js-imports\";\n\n/** Every code rule. */\nexport const CODE_RULES: readonly CodeRuleName[] = [\n \"logical-css\",\n \"specific-errors\",\n \"type-discriminator\",\n \"no-js-imports\",\n];\n\n/**\n * A part of the project a change may touch only when its task names it\n * (`- Touches: auth, migrations`). `public-api` has no globs: it is the\n * difference between the routes and `grimoire/approved/api.json`.\n * `dependencies` counts only added or changed dependency entries of a\n * `package.json`, not every edit of the file.\n */\nexport type ProtectedArea = {\n name: string;\n /** Project-relative globs (`**` crosses folders, `*` stays inside one). */\n globs: string[];\n};\n\n/** The built-in protected areas. A `protected` line in the settings with the same name replaces its globs. */\nexport const DEFAULT_PROTECTED_AREAS: readonly ProtectedArea[] = [\n { name: \"migrations\", globs: [\"**/migrations/**\", \"**/*.migration.ts\"] },\n { name: \"auth\", globs: [\"src/app/auth/**\", \"src/config/auth.ts\"] },\n { name: \"config\", globs: [\"src/config/**\", \"warlock.config.ts\", \".env.example\"] },\n {\n name: \"lockfile\",\n globs: [\"pnpm-lock.yaml\", \"package-lock.json\", \"yarn.lock\", \"bun.lock\", \"bun.lockb\"],\n },\n { name: \"dependencies\", globs: [\"package.json\", \"**/package.json\"] },\n { name: \"public-api\", globs: [] },\n];\n\n/** `grimoire/settings.md` as written (`WrittenGrimoire.settings`); `GrimoireSettings` is it with the defaults filled in. */\nexport type WrittenSettings = {\n file: string;\n languages: Located<string>[];\n screenshots: Located<ScreenshotMode> | null;\n /** `null` when the key is not written; `[]` when written empty. */\n rules: Located<CodeRuleName>[] | null;\n /** `- <name> <glob> [<glob>…]` lines of `protected`. */\n protected: { name: string; globs: string[]; at: SourceLocation }[];\n};\n\n/** The settings every reader uses: the written file with its defaults filled in. */\nexport type GrimoireSettings = {\n /** `grimoire/settings.md` when written, else `null`. */\n file: string | null;\n /** The app's languages, in order (`[\"en\", \"ar\"]`); empty when the app names none. */\n languages: string[];\n /** Where `languages` came from: the settings file, the adapter's `languages()`, or nowhere. */\n languagesFrom: \"settings\" | \"adapter\" | \"none\";\n screenshots: ScreenshotMode;\n /**\n * The code rules written in `rules`, or `null` when the key is not written:\n * then `grimoire check` runs none and `grimoire guard` runs every rule on\n * the lines a change adds. `[]` turns them off everywhere.\n */\n rules: CodeRuleName[] | null;\n /** The built-in areas with the written lines applied. */\n protected: ProtectedArea[];\n};\n\n/** What a project without `grimoire/settings.md` (and an adapter with no languages) gets. */\nexport const DEFAULT_GRIMOIRE_SETTINGS: GrimoireSettings = {\n file: null,\n languages: [],\n languagesFrom: \"none\",\n screenshots: \"changed\",\n rules: null,\n protected: DEFAULT_PROTECTED_AREAS.map((area) => ({ name: area.name, globs: [...area.globs] })),\n};\n"],"mappings":";;AA6BA,MAAa,mBAA8C;CAAC;CAAW;CAAO;AAAK;;AAgBnF,MAAa,aAAsC;CACjD;CACA;CACA;CACA;AACF;;AAgBA,MAAa,0BAAoD;CAC/D;EAAE,MAAM;EAAc,OAAO,CAAC,oBAAoB,mBAAmB;CAAE;CACvE;EAAE,MAAM;EAAQ,OAAO,CAAC,mBAAmB,oBAAoB;CAAE;CACjE;EAAE,MAAM;EAAU,OAAO;GAAC;GAAiB;GAAqB;EAAc;CAAE;CAChF;EACE,MAAM;EACN,OAAO;GAAC;GAAkB;GAAqB;GAAa;GAAY;EAAW;CACrF;CACA;EAAE,MAAM;EAAgB,OAAO,CAAC,gBAAgB,iBAAiB;CAAE;CACnE;EAAE,MAAM;EAAc,OAAO,CAAC;CAAE;AAClC;;AAiCA,MAAa,4BAA8C;CACzD,MAAM;CACN,WAAW,CAAC;CACZ,eAAe;CACf,aAAa;CACb,OAAO;CACP,WAAW,wBAAwB,KAAK,UAAU;EAAE,MAAM,KAAK;EAAM,OAAO,CAAC,GAAG,KAAK,KAAK;CAAE,EAAE;AAChG"}
@@ -0,0 +1,146 @@
1
+ import { SourceLocation } from "./location.mjs";
2
+ import { GrimoireFinding } from "./findings.mjs";
3
+ import { ScreenshotMode } from "./settings.mjs";
4
+ import { CriterionId, FlowRef } from "./written.mjs";
5
+ //#region ../../packages/grimoire/src/contracts/shots.d.ts
6
+ /** One `// @shows <feature>/<flow> AC-<n>` line, as the scanner reads it. */
7
+ export type ShowsLine = {
8
+ feature: string;
9
+ flow: string;
10
+ ref: FlowRef;
11
+ criterion: CriterionId;
12
+ /** The `shows(…)` call right under the comment, or `null` when there is none (`GR4013`). */
13
+ call: {
14
+ line: number;
15
+ } | null;
16
+ at: SourceLocation;
17
+ };
18
+ /** The result of one scene in one language. */
19
+ export type ShotOutcome = "pass" | "fail";
20
+ /** One capture: a scene run in one language. */
21
+ export type ShotCapture = {
22
+ ref: FlowRef;
23
+ criterion: CriterionId;
24
+ /** The language the scene ran in; `""` when the app names no language. */
25
+ language: string;
26
+ /** Path under `grimoire/screenshots/` (`captured/contact/send-message/AC-2.ar.png`), or `null` when the scene failed before the capture. */
27
+ file: string | null;
28
+ /** sha256 of the PNG bytes, or `null` with `file`. */
29
+ sha256: string | null;
30
+ outcome: ShotOutcome;
31
+ /** The scene's error message when it failed, else `null`. */
32
+ error: string | null;
33
+ viewport: {
34
+ name: string;
35
+ width: number;
36
+ height: number;
37
+ };
38
+ /** Project-relative browser test file. */
39
+ spec: string;
40
+ /** ISO time of the run. */
41
+ ranAt: string;
42
+ };
43
+ /**
44
+ * `grimoire/screenshots/captured/index.json`. A run replaces the captures of
45
+ * the criteria and languages it ran and keeps the others, so a `changed` run
46
+ * never forgets the rest.
47
+ */
48
+ export type ShotCaptureIndex = {
49
+ schemaVersion: 1;
50
+ updatedAt: string;
51
+ captures: ShotCapture[];
52
+ };
53
+ /** One approved image. */
54
+ export type ApprovedShot = {
55
+ ref: FlowRef;
56
+ criterion: CriterionId;
57
+ language: string;
58
+ /** Path under `grimoire/screenshots/` (`approved/contact/send-message/AC-2.ar.png`). */
59
+ file: string;
60
+ sha256: string;
61
+ approvedAt: string;
62
+ };
63
+ /** The approved shape of one flow. */
64
+ export type ApprovedFlow = {
65
+ ref: FlowRef;
66
+ criteria: {
67
+ id: CriterionId;
68
+ text: string;
69
+ }[];
70
+ /** Case questions written under `## Cases`, lower-case. */
71
+ cases: string[];
72
+ };
73
+ /** The approved proving tests (`@proves` lines with their test names). */
74
+ export type ApprovedProof = {
75
+ ref: FlowRef;
76
+ criterion: CriterionId;
77
+ /** Project-relative test file. */
78
+ testFile: string;
79
+ testName: string | null;
80
+ };
81
+ /** A change the owner rejected: it stays an error (`GR4019`) until the code no longer has it. */
82
+ export type RejectedChange = {
83
+ /** The {@link DriftItem} id. */
84
+ id: string;
85
+ rejectedAt: string;
86
+ /** Why, in the owner's words, or `null`. */
87
+ note: string | null;
88
+ };
89
+ /**
90
+ * `grimoire/approved/baseline.json`, in git. Written only by
91
+ * `warlock grimoire approve` / `reject` and the tab's Approve and Reject
92
+ * buttons; never by an agent.
93
+ */
94
+ export type ApprovedBaseline = {
95
+ schemaVersion: 1;
96
+ /** ISO time of the last approval. */
97
+ approvedAt: string;
98
+ flows: ApprovedFlow[];
99
+ proofs: ApprovedProof[];
100
+ shots: ApprovedShot[];
101
+ rejected: RejectedChange[];
102
+ };
103
+ /** What changed since the approval. */
104
+ export type DriftType = "shot-changed" | "shot-added" | "shot-removed" | "flow-added" | "flow-removed" | "criterion-added" | "criterion-removed" | "criterion-changed" | "case-added" | "case-removed" | "proof-removed";
105
+ /** One difference from the approved baseline: "changed, not approved" in the bird-view. */
106
+ export type DriftItem = {
107
+ /**
108
+ * Stable id, what approve and reject take:
109
+ * `<type>:<feature>/<flow>[:<AC-n>][:<language>|:<case>]`
110
+ * (`shot-changed:contact/send-message:AC-2:ar`).
111
+ */
112
+ id: string;
113
+ type: DriftType;
114
+ ref: FlowRef;
115
+ criterion: CriterionId | null;
116
+ /** For shot items; `""` when the app names no language. */
117
+ language: string | null;
118
+ /** For case items: the case question. */
119
+ case: string | null;
120
+ /** The approved text (a criterion's text, a test name), or `null`. */
121
+ before: string | null;
122
+ /** The text now, or `null` when removed. */
123
+ after: string | null;
124
+ /** For shot items: the approved and the captured image, paths under `grimoire/screenshots/`. */
125
+ approvedShot: string | null;
126
+ capturedShot: string | null;
127
+ /** Set when the owner rejected this change. */
128
+ rejected: RejectedChange | null;
129
+ };
130
+ /** Everything about visual proof that a snapshot carries (`GrimoireSnapshot.shots`). */
131
+ export type ShotsState = {
132
+ mode: ScreenshotMode;
133
+ shows: ShowsLine[];
134
+ /** `GR4013` / `GR4014` findings from reading the `@shows` lines. */
135
+ showsFindings: GrimoireFinding[];
136
+ /** `null` when no scene ever ran. */
137
+ captures: ShotCaptureIndex | null;
138
+ /** `null` until the first approval. */
139
+ baseline: ApprovedBaseline | null;
140
+ /** Empty while `baseline` is `null`. */
141
+ drift: DriftItem[];
142
+ /** Flows whose front matter says `screenshots: false`. */
143
+ optedOut: FlowRef[];
144
+ };
145
+ //#endregion
146
+ //# sourceMappingURL=shots.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shots.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/shots.ts"],"mappings":";;;;;;YA6BY;EACV;EACA;EACA,KAAK;EACL,WAAW;;EAEX;IAAQ;;EACR,IAAI;;;YAIM;;YAGA;EACV,KAAK;EACL,WAAW;;EAEX;;EAEA;;EAEA;EACA,SAAS;;EAET;EACA;IAAY;IAAc;IAAe;;;EAEzC;;EAEA;;;;;;;YAQU;EACV;EACA;EACA,UAAU;;;YAIA;EACV,KAAK;EACL,WAAW;EACX;;EAEA;EACA;EACA;;;YAIU;EACV,KAAK;EACL;IAAY,IAAI;IAAa;;;EAE7B;;;YAIU;EACV,KAAK;EACL,WAAW;;EAEX;EACA;;;YAIU;;EAEV;EACA;;EAEA;;;;;;;YAQU;EACV;;EAEA;EACA,OAAO;EACP,QAAQ;EACR,OAAO;EACP,UAAU;;;YAIA;;YAcA;;;;;;EAMV;EACA,MAAM;EACN,KAAK;EACL,WAAW;;EAEX;;EAEA;;EAEA;;EAEA;;EAEA;EACA;;EAEA,UAAU;;;YAIA;EACV,MAAM;EACN,OAAO;;EAEP,eAAe;;EAEf,UAAU;;EAEV,UAAU;;EAEV,OAAO;;EAEP,UAAU"}
@@ -1,9 +1,11 @@
1
1
  import { BookHost, BookMobileApp, BookSite } from "./adapter.mjs";
2
2
  import { GrimoireFinding, RouteFreshness } from "./findings.mjs";
3
3
  import { BookAnnotations, LoadedBook } from "./book.mjs";
4
+ import { GrimoireSettings } from "./settings.mjs";
4
5
  import { WrittenGrimoire } from "./written.mjs";
5
6
  import { ProofLine, TestResultsStore } from "./test-results.mjs";
6
7
  import { CollectedFiles, Ownership } from "./bookmap.mjs";
8
+ import { ShotsState } from "./shots.mjs";
7
9
  //#region ../../packages/grimoire/src/contracts/snapshot.d.ts
8
10
  export type GrimoireSnapshot = {
9
11
  /** Absolute project root. */
@@ -38,6 +40,14 @@ export type GrimoireSnapshot = {
38
40
  };
39
41
  /** What the adapter's `host()` reported (framework brand, app name and version); `null` or absent when it reports none. */
40
42
  host?: BookHost | null;
43
+ /**
44
+ * `grimoire/settings.md` with its defaults, and the adapter's languages when
45
+ * the file names none. Absent in snapshots made before 5.64; readers use
46
+ * `DEFAULT_GRIMOIRE_SETTINGS` then.
47
+ */
48
+ settings?: GrimoireSettings;
49
+ /** `@shows` lines, captures, the approved baseline and the drift from it. Absent when not loaded. */
50
+ shots?: ShotsState;
41
51
  };
42
52
  /** Options of `openGrimoire()`. */
43
53
  export type OpenGrimoireOptions = {
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/snapshot.ts"],"mappings":";;;;;;;YAYY;;EAEV;EACA,SAAS;;EAET,WAAW;EACX,MAAM;EACN,WAAW;;EAEX,MAAM,eAAe;EACrB,QAAQ;;EAER,eAAe;;EAEf,SAAS;;;;;EAKT;EACA,WAAW;EACX,aAAa;EACb,QAAQ;;;;;;EAMR;IAAW;;;EAEX,OAAO;;;YAIG;;EAEV;;EAEA;;EAEA;;;;;;EAMA;EACA,YAAY;;;YAIF,gBAAgB,UAAU,qBAAqB;;;;;;;YAQ/C;EACV;EACA;EACA,MAAM;EACN,QAAQ"}
1
+ {"version":3,"file":"snapshot.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/snapshot.ts"],"mappings":";;;;;;;;;YAcY;;EAEV;EACA,SAAS;;EAET,WAAW;EACX,MAAM;EACN,WAAW;;EAEX,MAAM,eAAe;EACrB,QAAQ;;EAER,eAAe;;EAEf,SAAS;;;;;EAKT;EACA,WAAW;EACX,aAAa;EACb,QAAQ;;;;;;EAMR;IAAW;;;EAEX,OAAO;;;;;;EAMP,WAAW;;EAEX,QAAQ;;;YAIE;;EAEV;;EAEA;;EAEA;;;;;;EAMA;EACA,YAAY;;;YAIF,gBAAgB,UAAU,qBAAqB;;;;;;;YAQ/C;EACV;EACA;EACA,MAAM;EACN,QAAQ"}
@@ -1,4 +1,5 @@
1
1
  import { Located, SourceLocation } from "./location.mjs";
2
+ import { WrittenSettings } from "./settings.mjs";
2
3
  //#region ../../packages/grimoire/src/contracts/written.d.ts
3
4
  /** Status of a feature or a flow. */
4
5
  export type WrittenStatus = "proposed" | "building" | "shipped" | "retired";
@@ -138,6 +139,14 @@ export type WrittenStep = {
138
139
  export declare const CASE_QUESTIONS: readonly ["invalid input", "not allowed", "not found", "duplicate", "limits", "expiry", "double submit", "outside service down"];
139
140
  /** One fixed case question. */
140
141
  export type CaseQuestion = (typeof CASE_QUESTIONS)[number];
142
+ /**
143
+ * The case questions a flow with a `page` step answers as well: what the user
144
+ * sees when the request never arrives, or fails on the server. Other flows
145
+ * may answer them; there they are not required.
146
+ */
147
+ export declare const UI_CASE_QUESTIONS: readonly ["server unreachable", "server error"];
148
+ /** One case question of a flow with a page step. */
149
+ export type UiCaseQuestion = (typeof UI_CASE_QUESTIONS)[number];
141
150
  /** One `- <question> <answer>` line of `## Cases`. */
142
151
  export type WrittenCase = {
143
152
  /** The question, lower-case (`double submit`), or the owner's own case label. */
@@ -203,6 +212,8 @@ export type WrittenFlow = {
203
212
  at: SourceLocation;
204
213
  }[];
205
214
  criteria: WrittenCriterion[];
215
+ /** Front matter `screenshots`: `false` opts the flow out of `@shows` captures. `null` when not written (captured). */
216
+ screenshots: Located<boolean> | null;
206
217
  };
207
218
  /** `grimoire/features/<feature>/versions/v<n>.md`: the brief before a whole-number version. */
208
219
  export type WrittenVersionBrief = {
@@ -397,6 +408,8 @@ export type WrittenGrimoire = {
397
408
  apps: WrittenApp[];
398
409
  tasks: WrittenTask[];
399
410
  releases: WrittenRelease[];
411
+ /** `grimoire/settings.md`, or `null` when the project has none. */
412
+ settings: WrittenSettings | null;
400
413
  /**
401
414
  * sha256 over the path and content of every written file, in path order.
402
415
  * The book manifest stores it to know when ownership and book maps change.
@@ -1 +1 @@
1
- {"version":3,"file":"written.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/written.ts"],"mappings":";;;YAeY;;YAGA;;YAGA;;YAGA;;YAGA;;;;;;YAOA;;EAEV;;EAEA;;EAEA;EACA,IAAI;;;YAIM;;EAEV;;EAEA;EACA,IAAI;;;YAMM;EACV;;EAEA,IAAI;EACJ,OAAO;EACP,QAAQ,QAAQ;EAChB,SAAS,QAAQ;;EAEjB,SAAS;;EAET,MAAM;;EAEN,SAAS;EACT,QAAQ,QAAQ;;EAEhB,SAAS;;EAET;;;;;;EAMA,UAAU;;EAEV;;EAEA,OAAO;;EAEP;IAAa;IAAc,MAAM;IAAW,IAAI;;;;YAItC;;;;;;YAOA;EACV;EACA,SAAS,QAAQ;EACjB,MAAM;;EAEN;;EAEA,UAAU;;EAEV;;EAEA;;EAEA;EACA,IAAI;;;;;;YAOM;EACV;EACA;EACA,IAAI;;;YAIM;EACV;EACA,UAAU;EACV,SAAS;;;YAIC;;YAWA;;EAEV;EACA,MAAM;;EAEN;;;;;EAKA;;EAEA;IAAS;IAAgB;;;EAEzB;IAAW;IAAiB;;;EAE5B;EACA,IAAI;;;qBAIO;;YAYD,uBAAuB;;YAGvB;;EAEV;;EAEA;EACA;;EAEA;;EAEA,UAAU;EACV,IAAI;;;;;;;YAQM;EACV;;EAEA;EACA,aAAa;EACb,IAAI;;;YAIM;EACV,IAAI;EACJ;;EAEA;EACA;EACA,IAAI;;;YAIM;EACV;EACA;;EAEA,IAAI;;EAEJ,KAAK;;EAEL,OAAO,QAAQ;EACf,QAAQ,QAAQ;;EAEhB,KAAK;EACL,QAAQ,QAAQ;EAChB,SAAS;;EAET;;EAEA,OAAO;EACP,OAAO;;EAEP,SAAS;EACT,OAAO;;EAEP,YAAY;;EAEZ;IAAY;IAAc,IAAI;;EAC9B,UAAU;;;YAIA;EACV;EACA;;EAEA;EACA,SAAS;;;YAIC;EACV;;EAEA;;EAEA,QAAQ;EACR,WAAW;EACX,OAAO;EACP,UAAU;;;YAMA;EACV;EACA;;;YAIU;EACV;EACA;;;YAIU;EACV;;EAEA,MAAM;EACN,KAAK;;EAEL,aAAa;EACb,IAAI;;;YAIM;EACV;EACA;;EAEA;;EAEA,QAAQ,QAAQ;EAChB,SAAS;EACT,QAAQ;;;YAIE;EACV;EACA;;EAEA;EACA;EACA,MAAM,QAAQ;EACd,SAAS;;EAET,SAAS;;EAET,aAAa;;;YAIH;;EAEV;EACA;EACA,IAAI;;;;;;YAOM;EACV;EACA;EACA;;EAEA;;EAEA,OAAO;;EAEP,QAAQ;;EAER,QAAQ;;EAER,QAAQ,QAAQ;EAChB,SAAS;;EAET;;EAEA,aAAa;EACb,QAAQ;EACR,iBAAiB;EACjB,YAAY;;;YAIF;;EAEV;;EAEA;;EAEA,IAAI;EACJ,MAAM;;EAEN,MAAM;;EAEN,QAAQ,QAAQ;EAChB,SAAS;;EAET,YAAY;EACZ,SAAS;EACT,OAAO;EACP,SAAS;;YAKC;YAEA;;;;;YAaA;EACV;;EAEA;;EAEA;;EAEA,IAAI;EACJ,MAAM,QAAQ;EACd,SAAS;;EAET,MAAM;EACN,MAAM;EACN,QAAQ,QAAQ;;EAEhB,SAAS;IAAU;IAAiB,SAAS;;EAC7C,SAAS;;EAET;IAAU;IAAa;IAAe,IAAI;;;EAE1C;;;qBAMW;qBACA;;YAGD;EACV;EACA,SAAS;EACT,MAAM;EACN;EACA,UAAU;EACV;EACA,IAAI;;;YAIM;EACV;;EAEA,SAAS;;EAET,MAAM;EACN,SAAS;;EAET;;EAEA;IAAa,OAAO;IAAgB,KAAK;IAAgB,SAAS;;;;YAMxD;;EAEV;;EAEA;EACA,UAAU;EACV,MAAM;EACN,OAAO;EACP,UAAU;;;;;EAKV"}
1
+ {"version":3,"file":"written.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/written.ts"],"mappings":";;;;YAgBY;;YAGA;;YAGA;;YAGA;;YAGA;;;;;;YAOA;;EAEV;;EAEA;;EAEA;EACA,IAAI;;;YAIM;;EAEV;;EAEA;EACA,IAAI;;;YAMM;EACV;;EAEA,IAAI;EACJ,OAAO;EACP,QAAQ,QAAQ;EAChB,SAAS,QAAQ;;EAEjB,SAAS;;EAET,MAAM;;EAEN,SAAS;EACT,QAAQ,QAAQ;;EAEhB,SAAS;;EAET;;;;;;EAMA,UAAU;;EAEV;;EAEA,OAAO;;EAEP;IAAa;IAAc,MAAM;IAAW,IAAI;;;;YAItC;;;;;;YAOA;EACV;EACA,SAAS,QAAQ;EACjB,MAAM;;EAEN;;EAEA,UAAU;;EAEV;;EAEA;;EAEA;EACA,IAAI;;;;;;YAOM;EACV;EACA;EACA,IAAI;;;YAIM;EACV;EACA,UAAU;EACV,SAAS;;;YAIC;;YAWA;;EAEV;EACA,MAAM;;EAEN;;;;;EAKA;;EAEA;IAAS;IAAgB;;;EAEzB;IAAW;IAAiB;;;EAE5B;EACA,IAAI;;;qBAIO;;YAYD,uBAAuB;;;;;;qBAOtB;;YAGD,yBAAyB;;YAGzB;;EAEV;;EAEA;EACA;;EAEA;;EAEA,UAAU;EACV,IAAI;;;;;;;YAQM;EACV;;EAEA;EACA,aAAa;EACb,IAAI;;;YAIM;EACV,IAAI;EACJ;;EAEA;EACA;EACA,IAAI;;;YAIM;EACV;EACA;;EAEA,IAAI;;EAEJ,KAAK;;EAEL,OAAO,QAAQ;EACf,QAAQ,QAAQ;;EAEhB,KAAK;EACL,QAAQ,QAAQ;EAChB,SAAS;;EAET;;EAEA,OAAO;EACP,OAAO;;EAEP,SAAS;EACT,OAAO;;EAEP,YAAY;;EAEZ;IAAY;IAAc,IAAI;;EAC9B,UAAU;;EAEV,aAAa;;;YAIH;EACV;EACA;;EAEA;EACA,SAAS;;;YAIC;EACV;;EAEA;;EAEA,QAAQ;EACR,WAAW;EACX,OAAO;EACP,UAAU;;;YAMA;EACV;EACA;;;YAIU;EACV;EACA;;;YAIU;EACV;;EAEA,MAAM;EACN,KAAK;;EAEL,aAAa;EACb,IAAI;;;YAIM;EACV;EACA;;EAEA;;EAEA,QAAQ,QAAQ;EAChB,SAAS;EACT,QAAQ;;;YAIE;EACV;EACA;;EAEA;EACA;EACA,MAAM,QAAQ;EACd,SAAS;;EAET,SAAS;;EAET,aAAa;;;YAIH;;EAEV;EACA;EACA,IAAI;;;;;;YAOM;EACV;EACA;EACA;;EAEA;;EAEA,OAAO;;EAEP,QAAQ;;EAER,QAAQ;;EAER,QAAQ,QAAQ;EAChB,SAAS;;EAET;;EAEA,aAAa;EACb,QAAQ;EACR,iBAAiB;EACjB,YAAY;;;YAIF;;EAEV;;EAEA;;EAEA,IAAI;EACJ,MAAM;;EAEN,MAAM;;EAEN,QAAQ,QAAQ;EAChB,SAAS;;EAET,YAAY;EACZ,SAAS;EACT,OAAO;EACP,SAAS;;YAKC;YAEA;;;;;YAaA;EACV;;EAEA;;EAEA;;EAEA,IAAI;EACJ,MAAM,QAAQ;EACd,SAAS;;EAET,MAAM;EACN,MAAM;EACN,QAAQ,QAAQ;;EAEhB,SAAS;IAAU;IAAiB,SAAS;;EAC7C,SAAS;;EAET;IAAU;IAAa;IAAe,IAAI;;;EAE1C;;;qBAMW;qBACA;;YAGD;EACV;EACA,SAAS;EACT,MAAM;EACN;EACA,UAAU;EACV;EACA,IAAI;;;YAIM;EACV;;EAEA,SAAS;;EAET,MAAM;EACN,SAAS;;EAET;;EAEA;IAAa,OAAO;IAAgB,KAAK;IAAgB,SAAS;;;;YAMxD;;EAEV;;EAEA;EACA,UAAU;EACV,MAAM;EACN,OAAO;EACP,UAAU;;EAEV,UAAU;;;;;EAKV"}
@@ -10,10 +10,16 @@ const CASE_QUESTIONS = [
10
10
  "double submit",
11
11
  "outside service down"
12
12
  ];
13
+ /**
14
+ * The case questions a flow with a `page` step answers as well: what the user
15
+ * sees when the request never arrives, or fails on the server. Other flows
16
+ * may answer them; there they are not required.
17
+ */
18
+ const UI_CASE_QUESTIONS = ["server unreachable", "server error"];
13
19
  /** Markers around the list Warlock writes into a release file. */
14
20
  const COLLECTED_START_MARKER = "<!-- grimoire:collected:start -->";
15
21
  const COLLECTED_END_MARKER = "<!-- grimoire:collected:end -->";
16
22
 
17
23
  //#endregion
18
- export { CASE_QUESTIONS, COLLECTED_END_MARKER, COLLECTED_START_MARKER };
24
+ export { CASE_QUESTIONS, COLLECTED_END_MARKER, COLLECTED_START_MARKER, UI_CASE_QUESTIONS };
19
25
  //# sourceMappingURL=written.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"written.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/written.ts"],"sourcesContent":["/**\n * The agent-written files under `grimoire/`, as the parser (`parseGrimoire`)\n * returns them. Warlock reads these files and never edits them, except the\n * collected list between the markers of a release file.\n *\n * Every value that a check may point at carries its location. Absent\n * optional values are `null`, never `undefined`.\n *\n * The grammar of each file is fixed (see the docs page \"Written files\"):\n * front matter between `---` lines (`key: value`, inline lists `[a, b]` or\n * `- item` lines under the key), then Markdown with fixed headings.\n */\nimport type { Located, SourceLocation } from \"./location\";\n\n/** Status of a feature or a flow. */\nexport type WrittenStatus = \"proposed\" | \"building\" | \"shipped\" | \"retired\";\n\n/** Whether the description was written from the code (`inferred`) or confirmed by the owner. */\nexport type WrittenOrigin = \"inferred\" | \"confirmed\";\n\n/** A feature version: `<whole>.<decimal>` (`2.1`). */\nexport type FeatureVersion = string;\n\n/** A flow reference: `<feature>/<flow>`. */\nexport type FlowRef = string;\n\n/** A criterion id: `AC-<n>`. */\nexport type CriterionId = string;\n\n/**\n * An image line `![<alt>](<path>)` in a written file, outside code fences.\n * The path is written relative to the Markdown file (so it renders on a git\n * host) and must point inside `grimoire/screenshots/` (`GR1029` otherwise).\n */\nexport type WrittenScreenshot = {\n /** The alt text; `\"\"` when none is written. */\n alt: string;\n /** As written in the file. */\n written: string;\n /** Path under `grimoire/screenshots/` (`web/product-page.png`), or `null` when it points elsewhere. */\n path: string | null;\n at: SourceLocation;\n};\n\n/** One `- name text` line of a list section. */\nexport type WrittenListLine = {\n /** The first word or phrase (a flow id, an app id, a condition name, a question). */\n name: string;\n /** The rest of the line, continuation lines joined with a space. */\n text: string;\n at: SourceLocation;\n};\n\n// ── Features ───────────────────────────────────────────────────────────────\n\n/** `grimoire/features/<id>/README.md`. */\nexport type WrittenFeatureReadme = {\n file: string;\n /** Front matter `id`; must equal the folder name. */\n id: Located<string>;\n title: Located<string>;\n status: Located<WrittenStatus>;\n version: Located<FeatureVersion>;\n /** `yyyy-mm-dd`. */\n updated: Located<string>;\n /** App ids under `grimoire/apps/`. */\n apps: Located<string>[];\n /** Project-relative folders whose files the feature owns; an entry with a code-file extension names one file. */\n folders: Located<string>[];\n origin: Located<WrittenOrigin> | null;\n /** The `# Heading`. */\n heading: Located<string> | null;\n /** The paragraph under the heading, or `null`. */\n summary: string | null;\n /**\n * Front matter `audience`: who the feature is for, in the owner's words\n * (`[shoppers, store staff]`). Empty when not written; readers then use the\n * flows' `who` values.\n */\n audience: Located<string>[];\n /** `## Why`: the paragraphs of the optional section, joined with a blank line, or `null`. */\n why: string | null;\n /** `## Flows`: `- <flow-id> <what it does>`. */\n flows: WrittenListLine[];\n /** `## Affects and affected by`: free lines; references `<feature>/<flow>` are read from them. */\n relations: { text: string; refs: FlowRef[]; at: SourceLocation }[];\n};\n\n/** A changed-word of a changelog entry. */\nexport type ChangeWord = \"added\" | \"changed\" | \"fixed\" | \"removed\";\n\n/**\n * One changelog entry:\n * `- <version> <word> [<flow>: ]<text>[ (AC-n[, AC-m])]`, continuation\n * lines indented.\n */\nexport type WrittenChangelogEntry = {\n feature: string;\n version: Located<FeatureVersion>;\n word: ChangeWord;\n /** The flow id named before `:`, or `null`. */\n flow: string | null;\n /** Criteria named in the trailing parentheses. */\n criteria: CriterionId[];\n /** The text without the flow prefix and the criteria. */\n text: string;\n /** `null` while under `## Unreleased`; the section's release once the agent moved it. */\n release: string | null;\n /** `yyyy-mm-dd` of the release section, or `null`. */\n date: string | null;\n at: SourceLocation;\n};\n\n/**\n * A changelog section: `## Unreleased`, or `## <release> (<yyyy-mm-dd>)`\n * for a release the agent stamped.\n */\nexport type WrittenChangelogSection = {\n release: string | null;\n date: string | null;\n at: SourceLocation;\n};\n\n/** `grimoire/features/<id>/CHANGELOG.md`, newest first. */\nexport type WrittenChangelog = {\n file: string;\n sections: WrittenChangelogSection[];\n entries: WrittenChangelogEntry[];\n};\n\n/** Flow step kinds. `affects` names an effect on another feature. */\nexport type StepType =\n | \"page\"\n | \"route\"\n | \"mail\"\n | \"notification\"\n | \"job\"\n | \"event\"\n | \"outside service\"\n | \"affects\";\n\n/** One `<n>. <kind> <target>[ — note]` line of `## Steps`. */\nexport type WrittenStep = {\n /** The number written before the dot. */\n index: number;\n type: StepType;\n /** The name as written (`POST /wishlist`, `/products/:id`, `order-confirmation`, `catalog/stock`). */\n target: string;\n /**\n * For a page step written `/support [web-admin]`: the app the page is in\n * (the target is then the path alone). `null` for every other step.\n */\n app: string | null;\n /** For a route step: the uppercase method and the path. */\n route: { method: string; path: string } | null;\n /** For an affects step: the feature and, when given, the flow. */\n affects: { feature: string; flow: string | null } | null;\n /** Text after ` — ` (or ` -- `), or `null`. */\n note: string | null;\n at: SourceLocation;\n};\n\n/** The fixed case questions every flow answers (in `## Cases` or `## Not handled`). */\nexport const CASE_QUESTIONS = [\n \"invalid input\",\n \"not allowed\",\n \"not found\",\n \"duplicate\",\n \"limits\",\n \"expiry\",\n \"double submit\",\n \"outside service down\",\n] as const;\n\n/** One fixed case question. */\nexport type CaseQuestion = (typeof CASE_QUESTIONS)[number];\n\n/** One `- <question> <answer>` line of `## Cases`. */\nexport type WrittenCase = {\n /** The question, lower-case (`double submit`), or the owner's own case label. */\n question: string;\n /** Whether `question` is one of {@link CASE_QUESTIONS}. */\n fixed: boolean;\n answer: string;\n /** The answer starts with `does not apply`. */\n doesNotApply: boolean;\n /** Criteria named in a trailing `(AC-n[, AC-m])` of the answer (removed from `answer`). Empty when none. */\n criteria: CriterionId[];\n at: SourceLocation;\n};\n\n/**\n * One `<n>. <sentence>` line of the optional `## Story` section: a step in\n * the user's words, for readers who do not read code. Continuation lines are\n * joined; image lines inside the item attach screenshots.\n */\nexport type WrittenStoryStep = {\n index: number;\n /** The sentence, without image lines. */\n text: string;\n screenshots: WrittenScreenshot[];\n at: SourceLocation;\n};\n\n/** One `- AC-<n>[ [app-id]] <text>` line of `## Acceptance criteria`. */\nexport type WrittenCriterion = {\n id: CriterionId;\n number: number;\n /** The app the criterion is scoped to, or `null` for every app. */\n app: string | null;\n text: string;\n at: SourceLocation;\n};\n\n/** `grimoire/features/<feature>/flows/<id>.md`. */\nexport type WrittenFlow = {\n file: string;\n feature: string;\n /** Front matter `id`; must equal the file name without `.md`. */\n id: Located<string>;\n /** `<feature>/<id>`. */\n ref: FlowRef;\n /** The feature version that introduced the flow. */\n since: Located<FeatureVersion>;\n status: Located<WrittenStatus>;\n /** Who walks the flow (`customer`, `guest`, `admin`, `system`). Free text. */\n who: Located<string>;\n origin: Located<WrittenOrigin> | null;\n heading: Located<string> | null;\n /** The paragraph under the `# Title`: what the flow does, in one or two sentences. `null` when not written (`GR1030`). */\n summary: string | null;\n /** `## Story`: the steps in the user's words. Empty when the section is not written. */\n story: WrittenStoryStep[];\n steps: WrittenStep[];\n /** `## Differs by app`: `- <app-id> <what differs>`. */\n differs: WrittenListLine[];\n cases: WrittenCase[];\n /** `## Not handled`: questions the code does not handle yet. */\n notHandled: WrittenListLine[];\n /** Every line starting with `Unknown:` anywhere in the flow. */\n unknowns: { text: string; at: SourceLocation }[];\n criteria: WrittenCriterion[];\n};\n\n/** `grimoire/features/<feature>/versions/v<n>.md`: the brief before a whole-number version. */\nexport type WrittenVersionBrief = {\n file: string;\n feature: string;\n /** The whole number from the file name (`3` for `v3.md`). */\n major: number;\n heading: Located<string> | null;\n};\n\n/** One feature folder. */\nexport type WrittenFeature = {\n id: string;\n /** `grimoire/features/<id>`. */\n dir: string;\n /** `null` when the folder has no README (a structure error). */\n readme: WrittenFeatureReadme | null;\n changelog: WrittenChangelog | null;\n flows: WrittenFlow[];\n versions: WrittenVersionBrief[];\n};\n\n// ── Apps ───────────────────────────────────────────────────────────────────\n\n/** Who sees a block: `everyone`, or condition names of the app. */\nexport type WrittenWho = {\n everyone: boolean;\n conditions: string[];\n};\n\n/** One `Changes with` item: `<condition>: <text>`, or free text with no condition. */\nexport type WrittenChangesWith = {\n condition: string | null;\n text: string;\n};\n\n/** One row of a `## Blocks` table: `| Block | Flow | Who sees it | Changes with |`. */\nexport type WrittenBlockRow = {\n block: string;\n /** `<feature>/<flow>`, or `null` for `—`. */\n flow: FlowRef | null;\n who: WrittenWho;\n /** Empty for `—`. Items are separated by `;`. */\n changesWith: WrittenChangesWith[];\n at: SourceLocation;\n};\n\n/** `grimoire/apps/<app>/layouts/<id>.md`. */\nexport type WrittenLayout = {\n file: string;\n app: string;\n /** The file name without `.md`. */\n id: string;\n /** Front matter `origin`, when given. */\n origin: Located<WrittenOrigin> | null;\n heading: Located<string> | null;\n blocks: WrittenBlockRow[];\n};\n\n/** `grimoire/apps/<app>/pages/<page>/blocks/<id>.md`. */\nexport type WrittenBlockFile = {\n file: string;\n app: string;\n /** The page or screen folder name. */\n page: string;\n id: string;\n flow: Located<FlowRef> | null;\n heading: Located<string> | null;\n /** `- <key> <value>` lines. */\n details: WrittenListLine[];\n /** Image lines of the file (what the block looks like). */\n screenshots: WrittenScreenshot[];\n};\n\n/** One `- <kind> <name>` line of `## Also reached from`. */\nexport type WrittenEntryPoint = {\n /** `mail`, `notification`, `page`, `screen`, `outside service`, or another word. */\n type: string;\n name: string;\n at: SourceLocation;\n};\n\n/**\n * `grimoire/apps/<app>/pages/<id>/README.md` (a site page) or\n * `grimoire/apps/<app>/screens/<id>/README.md` (a mobile screen).\n */\nexport type WrittenPage = {\n file: string;\n app: string;\n type: \"page\" | \"screen\";\n /** The folder name. */\n id: string;\n /** Front matter `route`: the page's route path, or a screen's file-based route. */\n route: Located<string> | null;\n /** Front matter `screen`: the screen name used by code-defined navigation. */\n screen: Located<string> | null;\n /** Front matter `layout`: a file in the app's `layouts/`. */\n layout: Located<string> | null;\n /** Front matter `origin`, when given. */\n origin: Located<WrittenOrigin> | null;\n heading: Located<string> | null;\n /** The paragraph under the heading, or `null`. */\n purpose: string | null;\n /** Image lines of the README (what the page or screen looks like). */\n screenshots: WrittenScreenshot[];\n blocks: WrittenBlockRow[];\n alsoReachedFrom: WrittenEntryPoint[];\n blockFiles: WrittenBlockFile[];\n};\n\n/** `grimoire/apps/<id>/README.md` and everything under that folder. */\nexport type WrittenApp = {\n /** `grimoire/apps/<id>`. */\n dir: string;\n /** `README.md`, or `null` when missing (a structure error). */\n file: string | null;\n /** Front matter `id`; must equal the folder name. */\n id: Located<string>;\n type: Located<\"site\" | \"mobile\">;\n /** Project-relative root of the site or mobile app (`src/web/$sites/client`, `mobile`). */\n root: Located<string>;\n /** Front matter `origin`, when given. */\n origin: Located<WrittenOrigin> | null;\n heading: Located<string> | null;\n /** `## Conditions`: `- <name> <meaning>`. */\n conditions: WrittenListLine[];\n layouts: WrittenLayout[];\n pages: WrittenPage[];\n screens: WrittenPage[];\n};\n\n// ── Tasks ──────────────────────────────────────────────────────────────────\n\nexport type TaskType = \"bug\" | \"feature\" | \"decision\" | \"chore\";\n\nexport type TaskStatus =\n | \"open\"\n | \"waiting for approval\"\n | \"approved\"\n | \"in progress\"\n | \"blocked\"\n | \"done\"\n | \"dropped\";\n\n/**\n * `grimoire/tasks/open/T-<n>-<slug>.md` or\n * `grimoire/tasks/done/<yyyy-mm>/T-<n>-<slug>.md`.\n */\nexport type WrittenTask = {\n file: string;\n /** Which folder holds it. */\n folder: \"open\" | \"done\";\n /** `yyyy-mm` of the done folder, or `null` for open tasks. */\n month: string | null;\n /** `T-<n>`. */\n id: Located<string>;\n type: Located<TaskType>;\n feature: Located<string> | null;\n /** Flow id within `feature`, or a full `<feature>/<flow>`; stored as written. */\n flow: Located<string> | null;\n apps: Located<string>[];\n status: Located<TaskStatus>;\n /** `shipped: <feature> <version>`, once done. */\n shipped: Located<{ feature: string; version: FeatureVersion }> | null;\n heading: Located<string> | null;\n /** `- <Key>: <value>` lines of the body (`Asked by`, `Why`, `Brief`, `Decision needed`, …). */\n fields: { key: string; value: string; at: SourceLocation }[];\n /** The `Decision needed` value, or `null`. */\n decisionNeeded: string | null;\n};\n\n// ── Releases ───────────────────────────────────────────────────────────────\n\n/** Markers around the list Warlock writes into a release file. */\nexport const COLLECTED_START_MARKER = \"<!-- grimoire:collected:start -->\";\nexport const COLLECTED_END_MARKER = \"<!-- grimoire:collected:end -->\";\n\n/** One line of a release file's collected list, read back. */\nexport type WrittenReleaseListed = {\n feature: string;\n version: FeatureVersion;\n word: ChangeWord;\n flow: string | null;\n criteria: CriterionId[];\n text: string;\n at: SourceLocation;\n};\n\n/** `grimoire/releases/<release>.md`. */\nexport type WrittenRelease = {\n file: string;\n /** Front matter `release`; must equal the file name without `.md`. */\n release: Located<string>;\n /** `yyyy-mm-dd`. */\n date: Located<string>;\n heading: Located<string> | null;\n /** The agent's brief: the text between the heading and the collected list. */\n brief: string;\n /** The list between the markers; `null` when the release command has not run yet. */\n collected: { start: SourceLocation; end: SourceLocation; entries: WrittenReleaseListed[] } | null;\n};\n\n// ── Everything ─────────────────────────────────────────────────────────────\n\n/** Every written file of a project, parsed. */\nexport type WrittenGrimoire = {\n /** Absolute project root. */\n root: string;\n /** `false` when the project has no `grimoire/` folder (book-only mode). */\n exists: boolean;\n features: WrittenFeature[];\n apps: WrittenApp[];\n tasks: WrittenTask[];\n releases: WrittenRelease[];\n /**\n * sha256 over the path and content of every written file, in path order.\n * The book manifest stores it to know when ownership and book maps change.\n */\n hash: string;\n};\n"],"mappings":";;AAmKA,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAqPA,MAAa,yBAAyB;AACtC,MAAa,uBAAuB"}
1
+ {"version":3,"file":"written.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/contracts/written.ts"],"sourcesContent":["/**\n * The agent-written files under `grimoire/`, as the parser (`parseGrimoire`)\n * returns them. Warlock reads these files and never edits them, except the\n * collected list between the markers of a release file.\n *\n * Every value that a check may point at carries its location. Absent\n * optional values are `null`, never `undefined`.\n *\n * The grammar of each file is fixed (see the docs page \"Written files\"):\n * front matter between `---` lines (`key: value`, inline lists `[a, b]` or\n * `- item` lines under the key), then Markdown with fixed headings.\n */\nimport type { Located, SourceLocation } from \"./location\";\nimport type { WrittenSettings } from \"./settings\";\n\n/** Status of a feature or a flow. */\nexport type WrittenStatus = \"proposed\" | \"building\" | \"shipped\" | \"retired\";\n\n/** Whether the description was written from the code (`inferred`) or confirmed by the owner. */\nexport type WrittenOrigin = \"inferred\" | \"confirmed\";\n\n/** A feature version: `<whole>.<decimal>` (`2.1`). */\nexport type FeatureVersion = string;\n\n/** A flow reference: `<feature>/<flow>`. */\nexport type FlowRef = string;\n\n/** A criterion id: `AC-<n>`. */\nexport type CriterionId = string;\n\n/**\n * An image line `![<alt>](<path>)` in a written file, outside code fences.\n * The path is written relative to the Markdown file (so it renders on a git\n * host) and must point inside `grimoire/screenshots/` (`GR1029` otherwise).\n */\nexport type WrittenScreenshot = {\n /** The alt text; `\"\"` when none is written. */\n alt: string;\n /** As written in the file. */\n written: string;\n /** Path under `grimoire/screenshots/` (`web/product-page.png`), or `null` when it points elsewhere. */\n path: string | null;\n at: SourceLocation;\n};\n\n/** One `- name text` line of a list section. */\nexport type WrittenListLine = {\n /** The first word or phrase (a flow id, an app id, a condition name, a question). */\n name: string;\n /** The rest of the line, continuation lines joined with a space. */\n text: string;\n at: SourceLocation;\n};\n\n// ── Features ───────────────────────────────────────────────────────────────\n\n/** `grimoire/features/<id>/README.md`. */\nexport type WrittenFeatureReadme = {\n file: string;\n /** Front matter `id`; must equal the folder name. */\n id: Located<string>;\n title: Located<string>;\n status: Located<WrittenStatus>;\n version: Located<FeatureVersion>;\n /** `yyyy-mm-dd`. */\n updated: Located<string>;\n /** App ids under `grimoire/apps/`. */\n apps: Located<string>[];\n /** Project-relative folders whose files the feature owns; an entry with a code-file extension names one file. */\n folders: Located<string>[];\n origin: Located<WrittenOrigin> | null;\n /** The `# Heading`. */\n heading: Located<string> | null;\n /** The paragraph under the heading, or `null`. */\n summary: string | null;\n /**\n * Front matter `audience`: who the feature is for, in the owner's words\n * (`[shoppers, store staff]`). Empty when not written; readers then use the\n * flows' `who` values.\n */\n audience: Located<string>[];\n /** `## Why`: the paragraphs of the optional section, joined with a blank line, or `null`. */\n why: string | null;\n /** `## Flows`: `- <flow-id> <what it does>`. */\n flows: WrittenListLine[];\n /** `## Affects and affected by`: free lines; references `<feature>/<flow>` are read from them. */\n relations: { text: string; refs: FlowRef[]; at: SourceLocation }[];\n};\n\n/** A changed-word of a changelog entry. */\nexport type ChangeWord = \"added\" | \"changed\" | \"fixed\" | \"removed\";\n\n/**\n * One changelog entry:\n * `- <version> <word> [<flow>: ]<text>[ (AC-n[, AC-m])]`, continuation\n * lines indented.\n */\nexport type WrittenChangelogEntry = {\n feature: string;\n version: Located<FeatureVersion>;\n word: ChangeWord;\n /** The flow id named before `:`, or `null`. */\n flow: string | null;\n /** Criteria named in the trailing parentheses. */\n criteria: CriterionId[];\n /** The text without the flow prefix and the criteria. */\n text: string;\n /** `null` while under `## Unreleased`; the section's release once the agent moved it. */\n release: string | null;\n /** `yyyy-mm-dd` of the release section, or `null`. */\n date: string | null;\n at: SourceLocation;\n};\n\n/**\n * A changelog section: `## Unreleased`, or `## <release> (<yyyy-mm-dd>)`\n * for a release the agent stamped.\n */\nexport type WrittenChangelogSection = {\n release: string | null;\n date: string | null;\n at: SourceLocation;\n};\n\n/** `grimoire/features/<id>/CHANGELOG.md`, newest first. */\nexport type WrittenChangelog = {\n file: string;\n sections: WrittenChangelogSection[];\n entries: WrittenChangelogEntry[];\n};\n\n/** Flow step kinds. `affects` names an effect on another feature. */\nexport type StepType =\n | \"page\"\n | \"route\"\n | \"mail\"\n | \"notification\"\n | \"job\"\n | \"event\"\n | \"outside service\"\n | \"affects\";\n\n/** One `<n>. <kind> <target>[ — note]` line of `## Steps`. */\nexport type WrittenStep = {\n /** The number written before the dot. */\n index: number;\n type: StepType;\n /** The name as written (`POST /wishlist`, `/products/:id`, `order-confirmation`, `catalog/stock`). */\n target: string;\n /**\n * For a page step written `/support [web-admin]`: the app the page is in\n * (the target is then the path alone). `null` for every other step.\n */\n app: string | null;\n /** For a route step: the uppercase method and the path. */\n route: { method: string; path: string } | null;\n /** For an affects step: the feature and, when given, the flow. */\n affects: { feature: string; flow: string | null } | null;\n /** Text after ` — ` (or ` -- `), or `null`. */\n note: string | null;\n at: SourceLocation;\n};\n\n/** The fixed case questions every flow answers (in `## Cases` or `## Not handled`). */\nexport const CASE_QUESTIONS = [\n \"invalid input\",\n \"not allowed\",\n \"not found\",\n \"duplicate\",\n \"limits\",\n \"expiry\",\n \"double submit\",\n \"outside service down\",\n] as const;\n\n/** One fixed case question. */\nexport type CaseQuestion = (typeof CASE_QUESTIONS)[number];\n\n/**\n * The case questions a flow with a `page` step answers as well: what the user\n * sees when the request never arrives, or fails on the server. Other flows\n * may answer them; there they are not required.\n */\nexport const UI_CASE_QUESTIONS = [\"server unreachable\", \"server error\"] as const;\n\n/** One case question of a flow with a page step. */\nexport type UiCaseQuestion = (typeof UI_CASE_QUESTIONS)[number];\n\n/** One `- <question> <answer>` line of `## Cases`. */\nexport type WrittenCase = {\n /** The question, lower-case (`double submit`), or the owner's own case label. */\n question: string;\n /** Whether `question` is one of {@link CASE_QUESTIONS}. */\n fixed: boolean;\n answer: string;\n /** The answer starts with `does not apply`. */\n doesNotApply: boolean;\n /** Criteria named in a trailing `(AC-n[, AC-m])` of the answer (removed from `answer`). Empty when none. */\n criteria: CriterionId[];\n at: SourceLocation;\n};\n\n/**\n * One `<n>. <sentence>` line of the optional `## Story` section: a step in\n * the user's words, for readers who do not read code. Continuation lines are\n * joined; image lines inside the item attach screenshots.\n */\nexport type WrittenStoryStep = {\n index: number;\n /** The sentence, without image lines. */\n text: string;\n screenshots: WrittenScreenshot[];\n at: SourceLocation;\n};\n\n/** One `- AC-<n>[ [app-id]] <text>` line of `## Acceptance criteria`. */\nexport type WrittenCriterion = {\n id: CriterionId;\n number: number;\n /** The app the criterion is scoped to, or `null` for every app. */\n app: string | null;\n text: string;\n at: SourceLocation;\n};\n\n/** `grimoire/features/<feature>/flows/<id>.md`. */\nexport type WrittenFlow = {\n file: string;\n feature: string;\n /** Front matter `id`; must equal the file name without `.md`. */\n id: Located<string>;\n /** `<feature>/<id>`. */\n ref: FlowRef;\n /** The feature version that introduced the flow. */\n since: Located<FeatureVersion>;\n status: Located<WrittenStatus>;\n /** Who walks the flow (`customer`, `guest`, `admin`, `system`). Free text. */\n who: Located<string>;\n origin: Located<WrittenOrigin> | null;\n heading: Located<string> | null;\n /** The paragraph under the `# Title`: what the flow does, in one or two sentences. `null` when not written (`GR1030`). */\n summary: string | null;\n /** `## Story`: the steps in the user's words. Empty when the section is not written. */\n story: WrittenStoryStep[];\n steps: WrittenStep[];\n /** `## Differs by app`: `- <app-id> <what differs>`. */\n differs: WrittenListLine[];\n cases: WrittenCase[];\n /** `## Not handled`: questions the code does not handle yet. */\n notHandled: WrittenListLine[];\n /** Every line starting with `Unknown:` anywhere in the flow. */\n unknowns: { text: string; at: SourceLocation }[];\n criteria: WrittenCriterion[];\n /** Front matter `screenshots`: `false` opts the flow out of `@shows` captures. `null` when not written (captured). */\n screenshots: Located<boolean> | null;\n};\n\n/** `grimoire/features/<feature>/versions/v<n>.md`: the brief before a whole-number version. */\nexport type WrittenVersionBrief = {\n file: string;\n feature: string;\n /** The whole number from the file name (`3` for `v3.md`). */\n major: number;\n heading: Located<string> | null;\n};\n\n/** One feature folder. */\nexport type WrittenFeature = {\n id: string;\n /** `grimoire/features/<id>`. */\n dir: string;\n /** `null` when the folder has no README (a structure error). */\n readme: WrittenFeatureReadme | null;\n changelog: WrittenChangelog | null;\n flows: WrittenFlow[];\n versions: WrittenVersionBrief[];\n};\n\n// ── Apps ───────────────────────────────────────────────────────────────────\n\n/** Who sees a block: `everyone`, or condition names of the app. */\nexport type WrittenWho = {\n everyone: boolean;\n conditions: string[];\n};\n\n/** One `Changes with` item: `<condition>: <text>`, or free text with no condition. */\nexport type WrittenChangesWith = {\n condition: string | null;\n text: string;\n};\n\n/** One row of a `## Blocks` table: `| Block | Flow | Who sees it | Changes with |`. */\nexport type WrittenBlockRow = {\n block: string;\n /** `<feature>/<flow>`, or `null` for `—`. */\n flow: FlowRef | null;\n who: WrittenWho;\n /** Empty for `—`. Items are separated by `;`. */\n changesWith: WrittenChangesWith[];\n at: SourceLocation;\n};\n\n/** `grimoire/apps/<app>/layouts/<id>.md`. */\nexport type WrittenLayout = {\n file: string;\n app: string;\n /** The file name without `.md`. */\n id: string;\n /** Front matter `origin`, when given. */\n origin: Located<WrittenOrigin> | null;\n heading: Located<string> | null;\n blocks: WrittenBlockRow[];\n};\n\n/** `grimoire/apps/<app>/pages/<page>/blocks/<id>.md`. */\nexport type WrittenBlockFile = {\n file: string;\n app: string;\n /** The page or screen folder name. */\n page: string;\n id: string;\n flow: Located<FlowRef> | null;\n heading: Located<string> | null;\n /** `- <key> <value>` lines. */\n details: WrittenListLine[];\n /** Image lines of the file (what the block looks like). */\n screenshots: WrittenScreenshot[];\n};\n\n/** One `- <kind> <name>` line of `## Also reached from`. */\nexport type WrittenEntryPoint = {\n /** `mail`, `notification`, `page`, `screen`, `outside service`, or another word. */\n type: string;\n name: string;\n at: SourceLocation;\n};\n\n/**\n * `grimoire/apps/<app>/pages/<id>/README.md` (a site page) or\n * `grimoire/apps/<app>/screens/<id>/README.md` (a mobile screen).\n */\nexport type WrittenPage = {\n file: string;\n app: string;\n type: \"page\" | \"screen\";\n /** The folder name. */\n id: string;\n /** Front matter `route`: the page's route path, or a screen's file-based route. */\n route: Located<string> | null;\n /** Front matter `screen`: the screen name used by code-defined navigation. */\n screen: Located<string> | null;\n /** Front matter `layout`: a file in the app's `layouts/`. */\n layout: Located<string> | null;\n /** Front matter `origin`, when given. */\n origin: Located<WrittenOrigin> | null;\n heading: Located<string> | null;\n /** The paragraph under the heading, or `null`. */\n purpose: string | null;\n /** Image lines of the README (what the page or screen looks like). */\n screenshots: WrittenScreenshot[];\n blocks: WrittenBlockRow[];\n alsoReachedFrom: WrittenEntryPoint[];\n blockFiles: WrittenBlockFile[];\n};\n\n/** `grimoire/apps/<id>/README.md` and everything under that folder. */\nexport type WrittenApp = {\n /** `grimoire/apps/<id>`. */\n dir: string;\n /** `README.md`, or `null` when missing (a structure error). */\n file: string | null;\n /** Front matter `id`; must equal the folder name. */\n id: Located<string>;\n type: Located<\"site\" | \"mobile\">;\n /** Project-relative root of the site or mobile app (`src/web/$sites/client`, `mobile`). */\n root: Located<string>;\n /** Front matter `origin`, when given. */\n origin: Located<WrittenOrigin> | null;\n heading: Located<string> | null;\n /** `## Conditions`: `- <name> <meaning>`. */\n conditions: WrittenListLine[];\n layouts: WrittenLayout[];\n pages: WrittenPage[];\n screens: WrittenPage[];\n};\n\n// ── Tasks ──────────────────────────────────────────────────────────────────\n\nexport type TaskType = \"bug\" | \"feature\" | \"decision\" | \"chore\";\n\nexport type TaskStatus =\n | \"open\"\n | \"waiting for approval\"\n | \"approved\"\n | \"in progress\"\n | \"blocked\"\n | \"done\"\n | \"dropped\";\n\n/**\n * `grimoire/tasks/open/T-<n>-<slug>.md` or\n * `grimoire/tasks/done/<yyyy-mm>/T-<n>-<slug>.md`.\n */\nexport type WrittenTask = {\n file: string;\n /** Which folder holds it. */\n folder: \"open\" | \"done\";\n /** `yyyy-mm` of the done folder, or `null` for open tasks. */\n month: string | null;\n /** `T-<n>`. */\n id: Located<string>;\n type: Located<TaskType>;\n feature: Located<string> | null;\n /** Flow id within `feature`, or a full `<feature>/<flow>`; stored as written. */\n flow: Located<string> | null;\n apps: Located<string>[];\n status: Located<TaskStatus>;\n /** `shipped: <feature> <version>`, once done. */\n shipped: Located<{ feature: string; version: FeatureVersion }> | null;\n heading: Located<string> | null;\n /** `- <Key>: <value>` lines of the body (`Asked by`, `Why`, `Brief`, `Decision needed`, …). */\n fields: { key: string; value: string; at: SourceLocation }[];\n /** The `Decision needed` value, or `null`. */\n decisionNeeded: string | null;\n};\n\n// ── Releases ───────────────────────────────────────────────────────────────\n\n/** Markers around the list Warlock writes into a release file. */\nexport const COLLECTED_START_MARKER = \"<!-- grimoire:collected:start -->\";\nexport const COLLECTED_END_MARKER = \"<!-- grimoire:collected:end -->\";\n\n/** One line of a release file's collected list, read back. */\nexport type WrittenReleaseListed = {\n feature: string;\n version: FeatureVersion;\n word: ChangeWord;\n flow: string | null;\n criteria: CriterionId[];\n text: string;\n at: SourceLocation;\n};\n\n/** `grimoire/releases/<release>.md`. */\nexport type WrittenRelease = {\n file: string;\n /** Front matter `release`; must equal the file name without `.md`. */\n release: Located<string>;\n /** `yyyy-mm-dd`. */\n date: Located<string>;\n heading: Located<string> | null;\n /** The agent's brief: the text between the heading and the collected list. */\n brief: string;\n /** The list between the markers; `null` when the release command has not run yet. */\n collected: { start: SourceLocation; end: SourceLocation; entries: WrittenReleaseListed[] } | null;\n};\n\n// ── Everything ─────────────────────────────────────────────────────────────\n\n/** Every written file of a project, parsed. */\nexport type WrittenGrimoire = {\n /** Absolute project root. */\n root: string;\n /** `false` when the project has no `grimoire/` folder (book-only mode). */\n exists: boolean;\n features: WrittenFeature[];\n apps: WrittenApp[];\n tasks: WrittenTask[];\n releases: WrittenRelease[];\n /** `grimoire/settings.md`, or `null` when the project has none. */\n settings: WrittenSettings | null;\n /**\n * sha256 over the path and content of every written file, in path order.\n * The book manifest stores it to know when ownership and book maps change.\n */\n hash: string;\n};\n"],"mappings":";;AAoKA,MAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AAUA,MAAa,oBAAoB,CAAC,sBAAsB,cAAc;;AAuPtE,MAAa,yBAAyB;AACtC,MAAa,uBAAuB"}
@@ -0,0 +1,59 @@
1
+ import { GrimoireError } from "../codes/index.mjs";
2
+ import { approveItems, rejectItems, selectDrift } from "../shots/approve.mjs";
3
+ import { GrimoirePanelError } from "./data.mjs";
4
+
5
+ //#region ../../packages/grimoire/src/devtools/approvals.ts
6
+ /**
7
+ * The Approve and Reject buttons of the Bird view: `POST /approve` and
8
+ * `POST /reject` with `{ ids: string[], language?: string, note?: string }`.
9
+ * Development only: in production the panel refuses both. `ids` hold change
10
+ * ids, `<feature>/<flow>` targets or `"all"`.
11
+ */
12
+ function readBody(body) {
13
+ const record = typeof body === "object" && body !== null ? body : null;
14
+ const ids = record?.ids;
15
+ if (!Array.isArray(ids) || ids.length === 0 || ids.some((id) => typeof id !== "string" || id === "")) throw new GrimoirePanelError(400, "Send { ids: string[] } with at least one change id.");
16
+ const request = { ids: ids.map((id) => id === "--all" ? "all" : id) };
17
+ if (record?.language !== void 0) {
18
+ if (typeof record.language !== "string") throw new GrimoirePanelError(400, "language must be a string.");
19
+ request.language = record.language;
20
+ }
21
+ if (record?.note !== void 0) {
22
+ if (typeof record.note !== "string") throw new GrimoirePanelError(400, "note must be a string.");
23
+ request.note = record.note;
24
+ }
25
+ return request;
26
+ }
27
+ function asPanelError(error) {
28
+ if (error instanceof GrimoireError) throw new GrimoirePanelError(error.code === "GR9010" ? 404 : 400, error.message);
29
+ throw error;
30
+ }
31
+ async function approveFromPanel(snapshot, body) {
32
+ const request = readBody(body);
33
+ try {
34
+ if (snapshot.shots?.baseline == null && request.ids.includes("all")) return { done: await approveItems(snapshot, [], void 0, { createWhenMissing: true }) };
35
+ const items = selectDrift(snapshot, {
36
+ targets: request.ids,
37
+ ...request.language === void 0 ? {} : { language: request.language }
38
+ });
39
+ return { done: await approveItems(snapshot, items) };
40
+ } catch (error) {
41
+ return asPanelError(error);
42
+ }
43
+ }
44
+ async function rejectFromPanel(snapshot, body) {
45
+ const request = readBody(body);
46
+ try {
47
+ const items = selectDrift(snapshot, {
48
+ targets: request.ids,
49
+ ...request.language === void 0 ? {} : { language: request.language }
50
+ });
51
+ return { done: await rejectItems(snapshot, items, request.note?.trim() || null) };
52
+ } catch (error) {
53
+ return asPanelError(error);
54
+ }
55
+ }
56
+
57
+ //#endregion
58
+ export { approveFromPanel, rejectFromPanel };
59
+ //# sourceMappingURL=approvals.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approvals.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/approvals.ts"],"sourcesContent":["/**\n * The Approve and Reject buttons of the Bird view: `POST /approve` and\n * `POST /reject` with `{ ids: string[], language?: string, note?: string }`.\n * Development only: in production the panel refuses both. `ids` hold change\n * ids, `<feature>/<flow>` targets or `\"all\"`.\n */\nimport { GrimoireError } from \"../codes\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport { approveItems, rejectItems, selectDrift } from \"../shots/approve\";\nimport { GrimoirePanelError } from \"./data\";\n\n/** What a button sends. `ids` are change ids, `<feature>/<flow>` targets, or `\"all\"`. */\nexport type ApprovalRequest = { ids: string[]; language?: string; note?: string };\n\n/** What the panel answers: the ids it approved or rejected. */\nexport type ApprovalAnswer = { done: string[] };\n\nfunction readBody(body: unknown): ApprovalRequest {\n const record =\n typeof body === \"object\" && body !== null ? (body as Record<string, unknown>) : null;\n const ids = record?.ids;\n\n if (\n !Array.isArray(ids) ||\n ids.length === 0 ||\n ids.some((id) => typeof id !== \"string\" || id === \"\")\n ) {\n throw new GrimoirePanelError(400, \"Send { ids: string[] } with at least one change id.\");\n }\n\n // \"--all\" (the command line's spelling) is the same target as \"all\".\n const request: ApprovalRequest = {\n ids: (ids as string[]).map((id) => (id === \"--all\" ? \"all\" : id)),\n };\n\n if (record?.language !== undefined) {\n if (typeof record.language !== \"string\") {\n throw new GrimoirePanelError(400, \"language must be a string.\");\n }\n\n request.language = record.language;\n }\n\n if (record?.note !== undefined) {\n if (typeof record.note !== \"string\")\n throw new GrimoirePanelError(400, \"note must be a string.\");\n\n request.note = record.note;\n }\n\n return request;\n}\n\nfunction asPanelError(error: unknown): never {\n if (error instanceof GrimoireError) {\n throw new GrimoirePanelError(error.code === \"GR9010\" ? 404 : 400, error.message);\n }\n\n throw error;\n}\n\nexport async function approveFromPanel(\n snapshot: GrimoireSnapshot,\n body: unknown,\n): Promise<ApprovalAnswer> {\n const request = readBody(body);\n\n try {\n // \"Approve all\" with nothing approved yet creates the baseline from the current state.\n if (snapshot.shots?.baseline == null && request.ids.includes(\"all\")) {\n return { done: await approveItems(snapshot, [], undefined, { createWhenMissing: true }) };\n }\n\n const items = selectDrift(snapshot, {\n targets: request.ids,\n ...(request.language === undefined ? {} : { language: request.language }),\n });\n\n return { done: await approveItems(snapshot, items) };\n } catch (error) {\n return asPanelError(error);\n }\n}\n\nexport async function rejectFromPanel(\n snapshot: GrimoireSnapshot,\n body: unknown,\n): Promise<ApprovalAnswer> {\n const request = readBody(body);\n\n try {\n const items = selectDrift(snapshot, {\n targets: request.ids,\n ...(request.language === undefined ? {} : { language: request.language }),\n });\n\n return { done: await rejectItems(snapshot, items, request.note?.trim() || null) };\n } catch (error) {\n return asPanelError(error);\n }\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAS,SAAS,MAAgC;CAChD,MAAM,SACJ,OAAO,SAAS,YAAY,SAAS,OAAQ,OAAmC;CAClF,MAAM,MAAM,QAAQ;CAEpB,IACE,CAAC,MAAM,QAAQ,GAAG,KAClB,IAAI,WAAW,KACf,IAAI,MAAM,OAAO,OAAO,OAAO,YAAY,OAAO,EAAE,GAEpD,MAAM,IAAI,mBAAmB,KAAK,qDAAqD;CAIzF,MAAM,UAA2B,EAC/B,KAAM,IAAiB,KAAK,OAAQ,OAAO,UAAU,QAAQ,EAAG,EAClE;CAEA,IAAI,QAAQ,aAAa,QAAW;EAClC,IAAI,OAAO,OAAO,aAAa,UAC7B,MAAM,IAAI,mBAAmB,KAAK,4BAA4B;EAGhE,QAAQ,WAAW,OAAO;CAC5B;CAEA,IAAI,QAAQ,SAAS,QAAW;EAC9B,IAAI,OAAO,OAAO,SAAS,UACzB,MAAM,IAAI,mBAAmB,KAAK,wBAAwB;EAE5D,QAAQ,OAAO,OAAO;CACxB;CAEA,OAAO;AACT;AAEA,SAAS,aAAa,OAAuB;CAC3C,IAAI,iBAAiB,eACnB,MAAM,IAAI,mBAAmB,MAAM,SAAS,WAAW,MAAM,KAAK,MAAM,OAAO;CAGjF,MAAM;AACR;AAEA,eAAsB,iBACpB,UACA,MACyB;CACzB,MAAM,UAAU,SAAS,IAAI;CAE7B,IAAI;EAEF,IAAI,SAAS,OAAO,YAAY,QAAQ,QAAQ,IAAI,SAAS,KAAK,GAChE,OAAO,EAAE,MAAM,MAAM,aAAa,UAAU,CAAC,GAAG,QAAW,EAAE,mBAAmB,KAAK,CAAC,EAAE;EAG1F,MAAM,QAAQ,YAAY,UAAU;GAClC,SAAS,QAAQ;GACjB,GAAI,QAAQ,aAAa,SAAY,CAAC,IAAI,EAAE,UAAU,QAAQ,SAAS;EACzE,CAAC;EAED,OAAO,EAAE,MAAM,MAAM,aAAa,UAAU,KAAK,EAAE;CACrD,SAAS,OAAO;EACd,OAAO,aAAa,KAAK;CAC3B;AACF;AAEA,eAAsB,gBACpB,UACA,MACyB;CACzB,MAAM,UAAU,SAAS,IAAI;CAE7B,IAAI;EACF,MAAM,QAAQ,YAAY,UAAU;GAClC,SAAS,QAAQ;GACjB,GAAI,QAAQ,aAAa,SAAY,CAAC,IAAI,EAAE,UAAU,QAAQ,SAAS;EACzE,CAAC;EAED,OAAO,EAAE,MAAM,MAAM,YAAY,UAAU,OAAO,QAAQ,MAAM,KAAK,KAAK,IAAI,EAAE;CAClF,SAAS,OAAO;EACd,OAAO,aAAa,KAAK;CAC3B;AACF"}
@@ -6,6 +6,7 @@ import { scry } from "../scry/query.mjs";
6
6
  import "../scry/index.mjs";
7
7
  import { STEP_FILE_SETS, compactFlow, stepFilePage } from "../scry/compact.mjs";
8
8
  import { featureFileGroups, featureMap, featureProofs } from "./feature-map.mjs";
9
+ import { attentionOf, matrix } from "./matrix.mjs";
9
10
  import { featureGraph, fileGraph, moduleGraph, pageGraph } from "./graphs.mjs";
10
11
 
11
12
  //#region ../../packages/grimoire/src/devtools/data.ts
@@ -71,6 +72,7 @@ function summary(snapshot) {
71
72
  screens: written.apps.reduce((total, app) => total + app.screens.length, 0)
72
73
  },
73
74
  releases: written.releases.length,
75
+ birdView: attentionOf(matrix(snapshot)),
74
76
  results: testResultsInfo(snapshot),
75
77
  host: snapshot.host ?? null
76
78
  };