@warlock.js/grimoire 5.63.1 → 5.65.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 (197) hide show
  1. package/CHANGELOG.md +61 -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 +42 -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 +7 -0
  50. package/esm/devtools/index.d.mts.map +1 -1
  51. package/esm/devtools/index.mjs +33 -3
  52. package/esm/devtools/index.mjs.map +1 -1
  53. package/esm/devtools/matrix.mjs +207 -0
  54. package/esm/devtools/matrix.mjs.map +1 -0
  55. package/esm/devtools/product-map.d.mts.map +1 -1
  56. package/esm/devtools/product-map.mjs +87 -1
  57. package/esm/devtools/product-map.mjs.map +1 -1
  58. package/esm/devtools/site.d.mts.map +1 -1
  59. package/esm/devtools/site.mjs +12 -3
  60. package/esm/devtools/site.mjs.map +1 -1
  61. package/esm/devtools/snapshot-source.mjs +13 -3
  62. package/esm/devtools/snapshot-source.mjs.map +1 -1
  63. package/esm/git/index.d.mts +20 -0
  64. package/esm/git/index.d.mts.map +1 -0
  65. package/esm/git/index.mjs +280 -0
  66. package/esm/git/index.mjs.map +1 -0
  67. package/esm/guard/api.mjs +70 -0
  68. package/esm/guard/api.mjs.map +1 -0
  69. package/esm/guard/assertions.mjs +18 -0
  70. package/esm/guard/assertions.mjs.map +1 -0
  71. package/esm/guard/collect.mjs +139 -0
  72. package/esm/guard/collect.mjs.map +1 -0
  73. package/esm/guard/format.mjs +27 -0
  74. package/esm/guard/format.mjs.map +1 -0
  75. package/esm/guard/glob.mjs +79 -0
  76. package/esm/guard/glob.mjs.map +1 -0
  77. package/esm/guard/index.mjs +9 -0
  78. package/esm/guard/rules.mjs +310 -0
  79. package/esm/guard/rules.mjs.map +1 -0
  80. package/esm/guard/scope.mjs +95 -0
  81. package/esm/guard/scope.mjs.map +1 -0
  82. package/esm/index.d.mts +10 -3
  83. package/esm/index.mjs +6 -2
  84. package/esm/paths/index.d.mts +15 -1
  85. package/esm/paths/index.d.mts.map +1 -1
  86. package/esm/paths/index.mjs +27 -3
  87. package/esm/paths/index.mjs.map +1 -1
  88. package/esm/proves/index.mjs +2 -1
  89. package/esm/proves/scan-proofs.mjs +1 -1
  90. package/esm/proves/scan-proofs.mjs.map +1 -1
  91. package/esm/proves/scan-shows.d.mts +21 -0
  92. package/esm/proves/scan-shows.d.mts.map +1 -0
  93. package/esm/proves/scan-shows.mjs +168 -0
  94. package/esm/proves/scan-shows.mjs.map +1 -0
  95. package/esm/releases/index.d.mts.map +1 -1
  96. package/esm/releases/index.mjs +5 -3
  97. package/esm/releases/index.mjs.map +1 -1
  98. package/esm/releases/stamp.mjs +121 -0
  99. package/esm/releases/stamp.mjs.map +1 -0
  100. package/esm/rules/focused.mjs +26 -0
  101. package/esm/rules/focused.mjs.map +1 -0
  102. package/esm/rules/index.mjs +88 -0
  103. package/esm/rules/index.mjs.map +1 -0
  104. package/esm/rules/logical-css.mjs +112 -0
  105. package/esm/rules/logical-css.mjs.map +1 -0
  106. package/esm/rules/no-js-imports.mjs +22 -0
  107. package/esm/rules/no-js-imports.mjs.map +1 -0
  108. package/esm/rules/scan.mjs +196 -0
  109. package/esm/rules/scan.mjs.map +1 -0
  110. package/esm/rules/specific-errors.mjs +51 -0
  111. package/esm/rules/specific-errors.mjs.map +1 -0
  112. package/esm/rules/type-discriminator.mjs +27 -0
  113. package/esm/rules/type-discriminator.mjs.map +1 -0
  114. package/esm/scry/also-changes.mjs +107 -0
  115. package/esm/scry/also-changes.mjs.map +1 -0
  116. package/esm/scry/format.d.mts.map +1 -1
  117. package/esm/scry/format.mjs +35 -0
  118. package/esm/scry/format.mjs.map +1 -1
  119. package/esm/scry/query.d.mts.map +1 -1
  120. package/esm/scry/query.mjs +40 -2
  121. package/esm/scry/query.mjs.map +1 -1
  122. package/esm/scry/search.d.mts.map +1 -1
  123. package/esm/scry/search.mjs +43 -11
  124. package/esm/scry/search.mjs.map +1 -1
  125. package/esm/shots/approve.mjs +195 -0
  126. package/esm/shots/approve.mjs.map +1 -0
  127. package/esm/shots/drift.mjs +174 -0
  128. package/esm/shots/drift.mjs.map +1 -0
  129. package/esm/shots/png.mjs +166 -0
  130. package/esm/shots/png.mjs.map +1 -0
  131. package/esm/shots/state.mjs +43 -0
  132. package/esm/shots/state.mjs.map +1 -0
  133. package/esm/shots/store.mjs +66 -0
  134. package/esm/shots/store.mjs.map +1 -0
  135. package/esm/shots/touched.mjs +38 -0
  136. package/esm/shots/touched.mjs.map +1 -0
  137. package/esm/warlock/adapter.d.mts.map +1 -1
  138. package/esm/warlock/adapter.mjs +22 -2
  139. package/esm/warlock/adapter.mjs.map +1 -1
  140. package/esm/warlock/api-command.mjs +41 -0
  141. package/esm/warlock/api-command.mjs.map +1 -0
  142. package/esm/warlock/approve-command.mjs +80 -0
  143. package/esm/warlock/approve-command.mjs.map +1 -0
  144. package/esm/warlock/collect-off-thread.mjs +66 -0
  145. package/esm/warlock/collect-off-thread.mjs.map +1 -0
  146. package/esm/warlock/commands.d.mts +1 -1
  147. package/esm/warlock/commands.d.mts.map +1 -1
  148. package/esm/warlock/commands.mjs +61 -8
  149. package/esm/warlock/commands.mjs.map +1 -1
  150. package/esm/warlock/guard-command.mjs +116 -0
  151. package/esm/warlock/guard-command.mjs.map +1 -0
  152. package/esm/warlock/index.d.mts +2 -1
  153. package/esm/warlock/index.mjs +2 -1
  154. package/esm/warlock/languages.mjs +75 -0
  155. package/esm/warlock/languages.mjs.map +1 -0
  156. package/esm/warlock/mcp-tools.mjs +2 -2
  157. package/esm/warlock/mcp-tools.mjs.map +1 -1
  158. package/esm/warlock/release-command.mjs +65 -0
  159. package/esm/warlock/release-command.mjs.map +1 -0
  160. package/esm/warlock/shows.d.mts +35 -0
  161. package/esm/warlock/shows.d.mts.map +1 -0
  162. package/esm/warlock/shows.mjs +195 -0
  163. package/esm/warlock/shows.mjs.map +1 -0
  164. package/esm/workspace/cache.mjs +4 -1
  165. package/esm/workspace/cache.mjs.map +1 -1
  166. package/esm/workspace/derived.mjs +11 -6
  167. package/esm/workspace/derived.mjs.map +1 -1
  168. package/esm/workspace/index.d.mts.map +1 -1
  169. package/esm/workspace/index.mjs +8 -1
  170. package/esm/workspace/index.mjs.map +1 -1
  171. package/esm/workspace/stored.mjs +4 -1
  172. package/esm/workspace/stored.mjs.map +1 -1
  173. package/esm/written/features.mjs +21 -5
  174. package/esm/written/features.mjs.map +1 -1
  175. package/esm/written/index.mjs +2 -1
  176. package/esm/written/parse-grimoire.d.mts.map +1 -1
  177. package/esm/written/parse-grimoire.mjs +16 -3
  178. package/esm/written/parse-grimoire.mjs.map +1 -1
  179. package/esm/written/settings.d.mts +11 -0
  180. package/esm/written/settings.d.mts.map +1 -0
  181. package/esm/written/settings.mjs +88 -0
  182. package/esm/written/settings.mjs.map +1 -0
  183. package/llms-full.txt +282 -39
  184. package/llms.txt +2 -0
  185. package/package.json +3 -3
  186. package/skills/backfill-a-grimoire/SKILL.md +4 -0
  187. package/skills/describe-an-app/SKILL.md +4 -1
  188. package/skills/guard-a-change/SKILL.md +85 -0
  189. package/skills/index.md +7 -3
  190. package/skills/record-a-change/SKILL.md +52 -16
  191. package/skills/review-a-change/SKILL.md +53 -0
  192. package/skills/use-the-grimoire/SKILL.md +27 -18
  193. package/skills/write-a-feature/SKILL.md +42 -1
  194. package/ui/grimoire-view.js +756 -40
  195. package/ui/grimoire.css +303 -28
  196. package/ui/product-map.css +43 -7
  197. package/ui/product-map.js +212 -37
@@ -0,0 +1,207 @@
1
+ import { DEFAULT_GRIMOIRE_SETTINGS } from "../contracts/settings.mjs";
2
+
3
+ //#region ../../packages/grimoire/src/devtools/matrix.ts
4
+ /** The feature that is listed first: the project's design rules. */
5
+ const DESIGN_SYSTEM = "design-system";
6
+ /** Worst first: the state of a cell is the first of these that applies. */
7
+ const STATE_ORDER = [
8
+ "rejected",
9
+ "fail",
10
+ "changed",
11
+ "stale",
12
+ "not-run",
13
+ "no-test",
14
+ "pass"
15
+ ];
16
+ const cellKey = (ref, criterion, language) => `${ref}\n${criterion}\n${language}`;
17
+ function inputsOf(snapshot) {
18
+ const settings = snapshot.settings ?? DEFAULT_GRIMOIRE_SETTINGS;
19
+ const shots = snapshot.shots ?? null;
20
+ const captured = /* @__PURE__ */ new Map();
21
+ const approved = /* @__PURE__ */ new Map();
22
+ const drift = shots?.drift ?? [];
23
+ for (const capture of shots?.captures?.captures ?? []) captured.set(cellKey(capture.ref, capture.criterion, capture.language), capture);
24
+ for (const shot of shots?.baseline?.shots ?? []) approved.set(cellKey(shot.ref, shot.criterion, shot.language), shot.file);
25
+ return {
26
+ languages: settings.languages.length > 0 ? [...settings.languages] : [""],
27
+ shots,
28
+ captured,
29
+ approved,
30
+ mode: shots?.mode ?? settings.screenshots,
31
+ driftOf: (ref, criterion, language) => drift.filter((item) => item.ref === ref && item.criterion === criterion && (criterion === null || language === null || item.language === null || item.language === language))
32
+ };
33
+ }
34
+ function worst(states) {
35
+ return STATE_ORDER.find((state) => states.includes(state)) ?? "pass";
36
+ }
37
+ function cellOf(inputs, input) {
38
+ const { ref, criterion, language } = input;
39
+ const key = cellKey(ref, criterion, language);
40
+ const capture = inputs.captured.get(key) ?? null;
41
+ const approvedFile = inputs.approved.get(key) ?? null;
42
+ const items = inputs.driftOf(ref, criterion, language);
43
+ const baseline = inputs.shots?.baseline ?? null;
44
+ const standing = capture === null && approvedFile !== null && inputs.mode !== "all";
45
+ const shown = input.shows || input.removed && approvedFile !== null ? {
46
+ outcome: capture?.outcome ?? (standing && !input.removed ? "pass" : "not-run"),
47
+ shot: capture?.file ?? null,
48
+ approved: approvedFile,
49
+ ranAt: capture?.ranAt ?? null
50
+ } : null;
51
+ const approval = baseline === null ? null : items.some((item) => item.rejected !== null) ? "rejected" : items.length > 0 || input.removed ? "changed" : "approved";
52
+ const states = [];
53
+ if (approval === "rejected") states.push("rejected");
54
+ if (input.test === "fail" || shown?.outcome === "fail") states.push("fail");
55
+ if (approval === "changed") states.push("changed");
56
+ if (!input.removed) {
57
+ if (input.test === "stale") states.push("stale");
58
+ if (input.test === "not-run" || shown?.outcome === "not-run") states.push("not-run");
59
+ if (input.test === "no-test") states.push("no-test");
60
+ }
61
+ return {
62
+ language,
63
+ test: input.test,
64
+ shown,
65
+ approval,
66
+ drift: items.map((item) => item.id),
67
+ state: worst(states)
68
+ };
69
+ }
70
+ function removedCriteria(inputs, ref, approvedFlow, written) {
71
+ return approvedFlow.criteria.filter((criterion) => !written.has(criterion.id)).map((criterion) => ({
72
+ id: criterion.id,
73
+ text: criterion.text,
74
+ app: null,
75
+ removed: true,
76
+ cells: inputs.languages.map((language) => cellOf(inputs, {
77
+ ref,
78
+ criterion: criterion.id,
79
+ language,
80
+ test: "no-test",
81
+ shows: false,
82
+ removed: true
83
+ }))
84
+ }));
85
+ }
86
+ function flowRow(snapshot, inputs, flow) {
87
+ const bookmap = snapshot.collected.flows[flow.ref];
88
+ const status = new Map((bookmap?.criteria ?? []).map((item) => [item.id, item.status]));
89
+ const shows = new Set((inputs.shots?.shows ?? []).filter((line) => line.ref === flow.ref).map((line) => line.criterion));
90
+ const approvedFlow = inputs.shots?.baseline?.flows.find((item) => item.ref === flow.ref);
91
+ const writtenIds = new Set(flow.criteria.map((criterion) => criterion.id));
92
+ const optedOut = flow.screenshots?.value === false || (inputs.shots?.optedOut ?? []).includes(flow.ref);
93
+ return {
94
+ ref: flow.ref,
95
+ id: flow.id.value,
96
+ title: flow.heading?.value ?? flow.id.value,
97
+ status: flow.status.value,
98
+ differsIn: flow.differs.map((line) => line.name),
99
+ screenshots: !optedOut,
100
+ removed: false,
101
+ criteria: [...flow.criteria.map((criterion) => ({
102
+ id: criterion.id,
103
+ text: criterion.text,
104
+ app: criterion.app,
105
+ removed: false,
106
+ cells: inputs.languages.map((language) => cellOf(inputs, {
107
+ ref: flow.ref,
108
+ criterion: criterion.id,
109
+ language,
110
+ test: status.get(criterion.id) ?? "no-test",
111
+ shows: !optedOut && inputs.mode !== "off" && shows.has(criterion.id),
112
+ removed: false
113
+ }))
114
+ })), ...approvedFlow === void 0 ? [] : removedCriteria(inputs, flow.ref, approvedFlow, writtenIds)],
115
+ drift: inputs.driftOf(flow.ref, null, null).map((item) => item.id)
116
+ };
117
+ }
118
+ function featureRow(snapshot, inputs, feature) {
119
+ return {
120
+ id: feature.id,
121
+ title: feature.readme?.title.value ?? feature.id,
122
+ designSystem: feature.id === DESIGN_SYSTEM,
123
+ flows: feature.flows.map((flow) => flowRow(snapshot, inputs, flow))
124
+ };
125
+ }
126
+ /** Rows of the baseline that are no longer written: whole flows, and the features only they belonged to. */
127
+ function removedFlows(inputs, features, snapshot) {
128
+ const written = new Set(snapshot.written.features.flatMap((feature) => feature.flows.map((flow) => flow.ref)));
129
+ for (const approved of inputs.shots?.baseline?.flows ?? []) {
130
+ if (written.has(approved.ref)) continue;
131
+ const [featureId = "", flowId = ""] = approved.ref.split("/");
132
+ let feature = features.find((item) => item.id === featureId);
133
+ if (feature === void 0) {
134
+ feature = {
135
+ id: featureId,
136
+ title: featureId,
137
+ designSystem: featureId === DESIGN_SYSTEM,
138
+ flows: []
139
+ };
140
+ features.push(feature);
141
+ }
142
+ const flowDrift = inputs.driftOf(approved.ref, null, null).map((item) => item.id);
143
+ const criteria = removedCriteria(inputs, approved.ref, approved, /* @__PURE__ */ new Set()).map((row) => ({
144
+ ...row,
145
+ cells: row.cells.map((cell) => ({
146
+ ...cell,
147
+ drift: [.../* @__PURE__ */ new Set([...flowDrift, ...cell.drift])]
148
+ }))
149
+ }));
150
+ feature.flows.push({
151
+ ref: approved.ref,
152
+ id: flowId,
153
+ title: flowId,
154
+ status: null,
155
+ differsIn: [],
156
+ screenshots: true,
157
+ removed: true,
158
+ criteria,
159
+ drift: flowDrift
160
+ });
161
+ }
162
+ }
163
+ /** `GET /matrix`. */
164
+ function matrix(snapshot) {
165
+ const inputs = inputsOf(snapshot);
166
+ const settings = snapshot.settings ?? DEFAULT_GRIMOIRE_SETTINGS;
167
+ const features = snapshot.written.features.map((feature) => featureRow(snapshot, inputs, feature));
168
+ removedFlows(inputs, features, snapshot);
169
+ features.sort((left, right) => Number(right.designSystem) - Number(left.designSystem));
170
+ const counts = {
171
+ rejected: 0,
172
+ fail: 0,
173
+ changed: 0,
174
+ stale: 0,
175
+ "not-run": 0,
176
+ "no-test": 0,
177
+ pass: 0
178
+ };
179
+ for (const feature of features) for (const flow of feature.flows) for (const criterion of flow.criteria) for (const cell of criterion.cells) counts[cell.state] += 1;
180
+ const baseline = inputs.shots?.baseline ?? null;
181
+ return {
182
+ languages: inputs.languages,
183
+ mode: inputs.shots?.mode ?? settings.screenshots,
184
+ baseline: baseline === null ? null : { approvedAt: baseline.approvedAt },
185
+ features,
186
+ drift: inputs.shots?.drift ?? [],
187
+ counts
188
+ };
189
+ }
190
+ /** What needs a look in the bird-view: cells that failed, changed or were rejected, and the changes to whole flows. */
191
+ function attentionOf(answer) {
192
+ const flows = answer.features.reduce((total, feature) => total + feature.flows.reduce((sum, flow) => sum + flow.drift.length, 0), 0);
193
+ return answer.counts.fail + answer.counts.changed + answer.counts.rejected + flows;
194
+ }
195
+ /** Every image the matrix shows (captured and approved), as paths under `grimoire/screenshots/`, once each. */
196
+ function matrixImagePaths(answer) {
197
+ const found = /* @__PURE__ */ new Set();
198
+ for (const feature of answer.features) for (const flow of feature.flows) for (const criterion of flow.criteria) for (const cell of criterion.cells) {
199
+ if (cell.shown?.shot) found.add(cell.shown.shot);
200
+ if (cell.shown?.approved) found.add(cell.shown.approved);
201
+ }
202
+ return [...found].sort();
203
+ }
204
+
205
+ //#endregion
206
+ export { attentionOf, matrix, matrixImagePaths };
207
+ //# sourceMappingURL=matrix.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matrix.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/matrix.ts"],"sourcesContent":["/**\n * `GET /matrix`: the bird-view. Every feature, flow and acceptance criterion\n * against the app's languages, built from the snapshot. Without `@shows`\n * scenes or an approved baseline it carries the test status only.\n */\nimport type { CriterionStatus } from \"../contracts/test-results\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type {\n GrimoireMatrix,\n MatrixCell,\n MatrixCellState,\n MatrixCriterionRow,\n MatrixFeatureRow,\n MatrixFlowRow,\n} from \"../contracts/matrix\";\nimport { DEFAULT_GRIMOIRE_SETTINGS } from \"../contracts/settings\";\nimport type { ApprovedFlow, DriftItem, ShotsState } from \"../contracts/shots\";\nimport type { WrittenFeature, WrittenFlow } from \"../contracts/written\";\n\n/** The feature that is listed first: the project's design rules. */\nconst DESIGN_SYSTEM = \"design-system\";\n\n/** Worst first: the state of a cell is the first of these that applies. */\nconst STATE_ORDER: readonly MatrixCellState[] = [\n \"rejected\",\n \"fail\",\n \"changed\",\n \"stale\",\n \"not-run\",\n \"no-test\",\n \"pass\",\n];\n\n/** What the route answers: the matrix, and whether this panel may write approvals. */\nexport type GrimoireMatrixAnswer = GrimoireMatrix & {\n /** `true` in development, where Approve and Reject work; `false` in production and in a static export. */\n development: boolean;\n};\n\ntype Inputs = {\n languages: string[];\n shots: ShotsState | null;\n captured: Map<string, NonNullable<ShotsState[\"captures\"]>[\"captures\"][number]>;\n approved: Map<string, string>;\n /** The screenshot mode of this run (`changed`, `all` or `off`). */\n mode: string;\n driftOf: (ref: string, criterion: string | null, language: string | null) => DriftItem[];\n};\n\nconst cellKey = (ref: string, criterion: string, language: string): string =>\n `${ref}\\n${criterion}\\n${language}`;\n\nfunction inputsOf(snapshot: GrimoireSnapshot): Inputs {\n const settings = snapshot.settings ?? DEFAULT_GRIMOIRE_SETTINGS;\n const shots = snapshot.shots ?? null;\n const captured = new Map<string, NonNullable<ShotsState[\"captures\"]>[\"captures\"][number]>();\n const approved = new Map<string, string>();\n const drift = shots?.drift ?? [];\n\n for (const capture of shots?.captures?.captures ?? []) {\n captured.set(cellKey(capture.ref, capture.criterion, capture.language), capture);\n }\n\n for (const shot of shots?.baseline?.shots ?? []) {\n approved.set(cellKey(shot.ref, shot.criterion, shot.language), shot.file);\n }\n\n return {\n languages: settings.languages.length > 0 ? [...settings.languages] : [\"\"],\n shots,\n captured,\n approved,\n mode: shots?.mode ?? settings.screenshots,\n // A drift item without a language (a changed criterion text, a removed proof) concerns every language of the criterion.\n driftOf: (ref, criterion, language) =>\n drift.filter(\n (item) =>\n item.ref === ref &&\n item.criterion === criterion &&\n (criterion === null ||\n language === null ||\n item.language === null ||\n item.language === language),\n ),\n };\n}\n\nfunction worst(states: readonly MatrixCellState[]): MatrixCellState {\n return STATE_ORDER.find((state) => states.includes(state)) ?? \"pass\";\n}\n\ntype CellInput = {\n ref: string;\n criterion: string;\n language: string;\n test: CriterionStatus;\n /** `true` when a `@shows` scene names the criterion. */\n shows: boolean;\n /** `true` for a criterion that is no longer written. */\n removed: boolean;\n};\n\nfunction cellOf(inputs: Inputs, input: CellInput): MatrixCell {\n const { ref, criterion, language } = input;\n const key = cellKey(ref, criterion, language);\n const capture = inputs.captured.get(key) ?? null;\n const approvedFile = inputs.approved.get(key) ?? null;\n const items = inputs.driftOf(ref, criterion, language);\n const baseline = inputs.shots?.baseline ?? null;\n // In `changed` mode only touched flows are captured: with no capture, an approved image still stands.\n const standing = capture === null && approvedFile !== null && inputs.mode !== \"all\";\n const shown: MatrixCell[\"shown\"] =\n input.shows || (input.removed && approvedFile !== null)\n ? {\n outcome: capture?.outcome ?? (standing && !input.removed ? \"pass\" : \"not-run\"),\n shot: capture?.file ?? null,\n approved: approvedFile,\n ranAt: capture?.ranAt ?? null,\n }\n : null;\n const approval: MatrixCell[\"approval\"] =\n baseline === null\n ? null\n : items.some((item) => item.rejected !== null)\n ? \"rejected\"\n : items.length > 0 || input.removed\n ? \"changed\"\n : \"approved\";\n const states: MatrixCellState[] = [];\n\n if (approval === \"rejected\") states.push(\"rejected\");\n\n if (input.test === \"fail\" || shown?.outcome === \"fail\") states.push(\"fail\");\n\n if (approval === \"changed\") states.push(\"changed\");\n\n // A removed criterion has no test to speak of: it is a change until approved.\n if (!input.removed) {\n if (input.test === \"stale\") states.push(\"stale\");\n\n if (input.test === \"not-run\" || shown?.outcome === \"not-run\") states.push(\"not-run\");\n\n if (input.test === \"no-test\") states.push(\"no-test\");\n }\n\n return {\n language,\n test: input.test,\n shown,\n approval,\n drift: items.map((item) => item.id),\n state: worst(states),\n };\n}\n\nfunction removedCriteria(\n inputs: Inputs,\n ref: string,\n approvedFlow: ApprovedFlow,\n written: ReadonlySet<string>,\n): MatrixCriterionRow[] {\n return approvedFlow.criteria\n .filter((criterion) => !written.has(criterion.id))\n .map((criterion) => ({\n id: criterion.id,\n text: criterion.text,\n app: null,\n removed: true,\n cells: inputs.languages.map((language) =>\n cellOf(inputs, {\n ref,\n criterion: criterion.id,\n language,\n test: \"no-test\",\n shows: false,\n removed: true,\n }),\n ),\n }));\n}\n\nfunction flowRow(snapshot: GrimoireSnapshot, inputs: Inputs, flow: WrittenFlow): MatrixFlowRow {\n const bookmap = snapshot.collected.flows[flow.ref];\n const status = new Map((bookmap?.criteria ?? []).map((item) => [item.id, item.status]));\n const shows = new Set(\n (inputs.shots?.shows ?? [])\n .filter((line) => line.ref === flow.ref)\n .map((line) => line.criterion),\n );\n const approvedFlow = inputs.shots?.baseline?.flows.find((item) => item.ref === flow.ref);\n const writtenIds = new Set(flow.criteria.map((criterion) => criterion.id));\n const optedOut =\n flow.screenshots?.value === false || (inputs.shots?.optedOut ?? []).includes(flow.ref);\n\n return {\n ref: flow.ref,\n id: flow.id.value,\n title: flow.heading?.value ?? flow.id.value,\n status: flow.status.value,\n differsIn: flow.differs.map((line) => line.name),\n screenshots: !optedOut,\n removed: false,\n criteria: [\n ...flow.criteria.map((criterion) => ({\n id: criterion.id,\n text: criterion.text,\n app: criterion.app,\n removed: false,\n cells: inputs.languages.map((language) =>\n cellOf(inputs, {\n ref: flow.ref,\n criterion: criterion.id,\n language,\n test: status.get(criterion.id) ?? \"no-test\",\n // A flow with no screenshots (opted out, or the mode is off) never waits for a capture.\n shows: !optedOut && inputs.mode !== \"off\" && shows.has(criterion.id),\n removed: false,\n }),\n ),\n })),\n ...(approvedFlow === undefined\n ? []\n : removedCriteria(inputs, flow.ref, approvedFlow, writtenIds)),\n ],\n drift: inputs.driftOf(flow.ref, null, null).map((item) => item.id),\n };\n}\n\nfunction featureRow(\n snapshot: GrimoireSnapshot,\n inputs: Inputs,\n feature: WrittenFeature,\n): MatrixFeatureRow {\n return {\n id: feature.id,\n title: feature.readme?.title.value ?? feature.id,\n designSystem: feature.id === DESIGN_SYSTEM,\n flows: feature.flows.map((flow) => flowRow(snapshot, inputs, flow)),\n };\n}\n\n/** Rows of the baseline that are no longer written: whole flows, and the features only they belonged to. */\nfunction removedFlows(\n inputs: Inputs,\n features: MatrixFeatureRow[],\n snapshot: GrimoireSnapshot,\n): void {\n const written = new Set(\n snapshot.written.features.flatMap((feature) => feature.flows.map((flow) => flow.ref)),\n );\n\n for (const approved of inputs.shots?.baseline?.flows ?? []) {\n if (written.has(approved.ref)) continue;\n\n const [featureId = \"\", flowId = \"\"] = approved.ref.split(\"/\");\n let feature = features.find((item) => item.id === featureId);\n\n if (feature === undefined) {\n feature = {\n id: featureId,\n title: featureId,\n designSystem: featureId === DESIGN_SYSTEM,\n flows: [],\n };\n features.push(feature);\n }\n\n const flowDrift = inputs.driftOf(approved.ref, null, null).map((item) => item.id);\n // The flow's removal is the change each of its cells stands for: approving a cell approves the removal.\n const criteria = removedCriteria(inputs, approved.ref, approved, new Set()).map((row) => ({\n ...row,\n cells: row.cells.map((cell) => ({\n ...cell,\n drift: [...new Set([...flowDrift, ...cell.drift])],\n })),\n }));\n\n feature.flows.push({\n ref: approved.ref,\n id: flowId,\n title: flowId,\n status: null,\n differsIn: [],\n screenshots: true,\n removed: true,\n criteria,\n drift: flowDrift,\n });\n }\n}\n\n/** `GET /matrix`. */\nexport function matrix(snapshot: GrimoireSnapshot): GrimoireMatrix {\n const inputs = inputsOf(snapshot);\n const settings = snapshot.settings ?? DEFAULT_GRIMOIRE_SETTINGS;\n const features = snapshot.written.features.map((feature) =>\n featureRow(snapshot, inputs, feature),\n );\n\n removedFlows(inputs, features, snapshot);\n\n // The design system first; the rest keep their order.\n features.sort((left, right) => Number(right.designSystem) - Number(left.designSystem));\n\n const counts: GrimoireMatrix[\"counts\"] = {\n rejected: 0,\n fail: 0,\n changed: 0,\n stale: 0,\n \"not-run\": 0,\n \"no-test\": 0,\n pass: 0,\n };\n\n for (const feature of features)\n for (const flow of feature.flows)\n for (const criterion of flow.criteria)\n for (const cell of criterion.cells) counts[cell.state] += 1;\n\n const baseline = inputs.shots?.baseline ?? null;\n\n return {\n languages: inputs.languages,\n mode: inputs.shots?.mode ?? settings.screenshots,\n baseline: baseline === null ? null : { approvedAt: baseline.approvedAt },\n features,\n drift: inputs.shots?.drift ?? [],\n counts,\n };\n}\n\n/** What needs a look in the bird-view: cells that failed, changed or were rejected, and the changes to whole flows. */\nexport function attentionOf(answer: GrimoireMatrix): number {\n const flows = answer.features.reduce(\n (total, feature) => total + feature.flows.reduce((sum, flow) => sum + flow.drift.length, 0),\n 0,\n );\n\n return answer.counts.fail + answer.counts.changed + answer.counts.rejected + flows;\n}\n\n/** Every image the matrix shows (captured and approved), as paths under `grimoire/screenshots/`, once each. */\nexport function matrixImagePaths(answer: GrimoireMatrix): string[] {\n const found = new Set<string>();\n\n for (const feature of answer.features)\n for (const flow of feature.flows)\n for (const criterion of flow.criteria)\n for (const cell of criterion.cells) {\n if (cell.shown?.shot) found.add(cell.shown.shot);\n\n if (cell.shown?.approved) found.add(cell.shown.approved);\n }\n\n return [...found].sort();\n}\n"],"mappings":";;;;AAoBA,MAAM,gBAAgB;;AAGtB,MAAM,cAA0C;CAC9C;CACA;CAC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O,MAAM,MAAM,IAAI,KAAK,MAAM,IAAI;EAE/C,IAAI,KAAK,OAAO,UAAU,MAAM,IAAI,KAAK,MAAM,QAAQ;CACzD;CAEN,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK;AACzB"}
@@ -1 +1 @@
1
- {"version":3,"file":"product-map.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"mappings":";;YAqCY;;EAEV;EACA;EACA;EACA;EACA;EACA;EACA"}
1
+ {"version":3,"file":"product-map.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"mappings":";;YAuCY;;EAEV;EACA;EACA;EACA;EACA;EACA;EACA"}
@@ -285,6 +285,7 @@ function appearancesOf(snapshot, bookmaps) {
285
285
  }
286
286
  list.push({
287
287
  app: shown.app,
288
+ appTitle: app?.heading?.value ?? null,
288
289
  type: shown.type,
289
290
  id: shown.id,
290
291
  title,
@@ -454,7 +455,92 @@ function productFlow(snapshot, featureId, flowId, options) {
454
455
  host: snapshot.host ?? null
455
456
  };
456
457
  }
458
+ /** A reference id: `AC-6`, `T-12`, `QA 1.5.6`. */
459
+ const REFERENCE = /^(?:[A-Z]{1,5}-\d+|QA\s+\d[\w.-]*)$/;
460
+ /** A trailing parenthesised group (optionally followed by one end mark) at the end of a sentence. */
461
+ const TRAILING_GROUP = /\s*\(([^()]*)\)\s*([.!?]?)\s*$/;
462
+ /** A sentence without the reference ids written in trailing parentheses: `"Fixed the total (AC-6, T-12)."` gives `"Fixed the total."`. */
463
+ function withoutReferences(sentence) {
464
+ let text = sentence;
465
+ for (;;) {
466
+ const match = TRAILING_GROUP.exec(text);
467
+ if (match === null) break;
468
+ const parts = (match[1] ?? "").split(/[,;]/).map((part) => part.trim()).filter((part) => part !== "");
469
+ if (parts.length === 0 || !parts.every((part) => REFERENCE.test(part))) break;
470
+ text = `${text.slice(0, match.index)}${match[2] ?? ""}`;
471
+ }
472
+ return text.trim();
473
+ }
474
+ /** The first paragraph of a release brief as one plain line, or `null`. */
475
+ function firstParagraph(brief) {
476
+ const paragraph = brief.split(/\n\s*\n/).map((part) => part.trim()).find((part) => part !== "" && !part.startsWith("#"));
477
+ if (paragraph === void 0) return null;
478
+ const text = withoutReferences(paragraph.replace(/\s+/g, " ").replaceAll("`", ""));
479
+ return text === "" ? null : text;
480
+ }
481
+ /** The newest release first; the changes without a release lead. */
482
+ function newestFirst(left, right) {
483
+ if (left.release === null || right.release === null) return Number(right.release === null) - Number(left.release === null);
484
+ return (right.date ?? "").localeCompare(left.date ?? "") || compareReleases(right.release, left.release);
485
+ }
486
+ /**
487
+ * `GET /product/whats-new`: the changelog entries of every feature, grouped by
488
+ * release and then by feature, in plain words (no criterion or task ids, no
489
+ * paths). A release is one a changelog names or a file in `grimoire/releases`;
490
+ * the changes that are in no release yet only appear in the signed-in view.
491
+ */
492
+ function productWhatsNew(snapshot, options) {
493
+ const written = new Map(snapshot.written.releases.map((item) => [item.release.value, item]));
494
+ const releases = /* @__PURE__ */ new Map();
495
+ const releaseOf = (name, date) => {
496
+ const key = name ?? "";
497
+ let found = releases.get(key);
498
+ if (found === void 0) {
499
+ const file = name === null ? void 0 : written.get(name);
500
+ found = {
501
+ release: name,
502
+ date: file?.date.value ?? date,
503
+ brief: file === void 0 ? null : firstParagraph(file.brief),
504
+ features: []
505
+ };
506
+ releases.set(key, found);
507
+ }
508
+ return found;
509
+ };
510
+ for (const item of snapshot.written.releases) releaseOf(item.release.value, item.date.value);
511
+ for (const feature of snapshot.written.features) {
512
+ if (feature.readme === null) continue;
513
+ const title = feature.readme.title.value;
514
+ const flowTitles = new Map(feature.flows.map((flow) => [flow.id.value, flow.heading?.value ?? flow.id.value]));
515
+ for (const entry of feature.changelog?.entries ?? []) {
516
+ if (entry.release === null && options.shared) continue;
517
+ const release = releaseOf(entry.release, entry.date);
518
+ let group = release.features.find((item) => item.id === feature.id);
519
+ if (group === void 0) {
520
+ group = {
521
+ id: feature.id,
522
+ title,
523
+ changes: []
524
+ };
525
+ release.features.push(group);
526
+ }
527
+ group.changes.push({
528
+ word: entry.word,
529
+ flow: entry.flow === null ? null : flowTitles.get(entry.flow) ?? entry.flow,
530
+ text: withoutReferences(entry.text)
531
+ });
532
+ }
533
+ }
534
+ return {
535
+ releases: [...releases.values()].filter((release) => release.release !== null || release.features.length > 0).map((release) => ({
536
+ ...release,
537
+ features: [...release.features].sort((left, right) => left.title.localeCompare(right.title))
538
+ })).sort(newestFirst),
539
+ developer: !options.shared,
540
+ host: snapshot.host ?? null
541
+ };
542
+ }
457
543
 
458
544
  //#endregion
459
- export { compareReleases, productFeature, productFlow, productMap };
545
+ export { compareReleases, productFeature, productFlow, productMap, productWhatsNew };
460
546
  //# sourceMappingURL=product-map.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"product-map.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"sourcesContent":["/**\n * The product map answers: the Grimoire in plain words for readers who do\n * not read code. Built from the written files, the book maps, the test\n * results, the open tasks, the changelogs and (when the devtools monitor\n * reports them) the captured errors. A shared answer (`options.shared`)\n * carries no file paths, code or test names.\n */\nimport { checkGrimoire } from \"../check\";\nimport { normalizeRoutePath } from \"../bookmap\";\nimport type { FlowBookmap, FlowBookmapCriterion } from \"../contracts/bookmap\";\nimport type { GrimoireCheckReport } from \"../contracts/findings\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type {\n WrittenApp,\n WrittenFeature,\n WrittenFlow,\n WrittenScreenshot,\n WrittenStep,\n} from \"../contracts/written\";\nimport { compactStep, flowOrder, neighboursOf } from \"../scry/compact\";\nimport type {\n ProductAppearance,\n ProductFeatureAnswer,\n ProductFeatureCard,\n ProductFlowAnswer,\n ProductFlowCard,\n ProductHealth,\n ProductMapAnswer,\n ProductPlannedItem,\n ProductRelease,\n ProductScreenshot,\n ProductStrip,\n ProductStoryStep,\n} from \"./answers\";\nimport { GrimoirePanelError } from \"./data\";\n\n/** One captured error group as devtools hands it to a panel: counts only. */\nexport type ProductErrorSummary = {\n /** The route pattern (`/products/:id`), or `null` outside a request. */\n route: string | null;\n status: number | null;\n name: string | null;\n source: \"request\" | \"log\";\n count: number;\n firstSeen: number;\n lastSeen: number;\n};\n\n/** How the product map answers are built. */\nexport type ProductMapOptions = {\n /** `true` for a read-only share link: no developer detail. */\n shared: boolean;\n /** Captured error groups, or `null` when the monitor reports none. */\n errors: readonly ProductErrorSummary[] | null;\n};\n\n/** How far back captured errors count (one hour). */\nconst ERROR_WINDOW_MS = 3_600_000;\n\ntype ErrorCount = { count: number; lastSeen: number };\n\n/** Everything the answers share, computed once per request. */\ntype Context = {\n snapshot: GrimoireSnapshot;\n options: ProductMapOptions;\n report: GrimoireCheckReport;\n featureErrors: Map<string, number>;\n flowErrors: Map<string, number>;\n /** Unexpected findings by feature id. */\n featureFindings: Map<string, { errors: number; warnings: number }>;\n captured: { features: Map<string, ErrorCount>; flows: Map<string, ErrorCount> } | null;\n resultsMissing: boolean;\n};\n\nfunction addCount(map: Map<string, ErrorCount>, key: string, group: ProductErrorSummary): void {\n const known = map.get(key);\n\n map.set(key, {\n count: (known?.count ?? 0) + group.count,\n lastSeen: Math.max(known?.lastSeen ?? 0, group.lastSeen),\n });\n}\n\n/** Map the last hour's error groups to the features and flows that use their route. */\nfunction captureErrors(\n snapshot: GrimoireSnapshot,\n errors: readonly ProductErrorSummary[],\n now: number,\n): NonNullable<Context[\"captured\"]> {\n const features = new Map<string, ErrorCount>();\n const flows = new Map<string, ErrorCount>();\n const routes = snapshot.book.facts.routes ?? [];\n\n for (const group of errors) {\n if (group.route === null || group.lastSeen < now - ERROR_WINDOW_MS) continue;\n\n const path = normalizeRoutePath(group.route);\n\n for (const route of routes) {\n if (normalizeRoutePath(route.path) !== path) continue;\n\n const file = route.handlerFile ?? route.sourceFile;\n const owner = file === null ? null : (snapshot.ownership.files[file]?.owner ?? null);\n\n if (owner !== null) addCount(features, owner, group);\n }\n\n for (const feature of snapshot.written.features) {\n for (const flow of feature.flows) {\n const hit = flow.steps.some(\n (step) =>\n (step.type === \"route\" &&\n step.route !== null &&\n normalizeRoutePath(step.route.path) === path) ||\n (step.type === \"page\" && normalizeRoutePath(step.target) === path),\n );\n\n if (hit) addCount(flows, flow.ref, group);\n }\n }\n }\n\n return { features, flows };\n}\n\n/**\n * The check report of a snapshot, run once per snapshot. A share link reaches\n * these answers without an account, so a page view must not run the whole\n * check again; a changed book opens a new snapshot and a new report.\n */\nconst reports = new WeakMap<GrimoireSnapshot, GrimoireCheckReport>();\n\nfunction reportOf(snapshot: GrimoireSnapshot): GrimoireCheckReport {\n let report = reports.get(snapshot);\n\n if (report === undefined) {\n report = checkGrimoire(snapshot);\n reports.set(snapshot, report);\n }\n\n return report;\n}\n\nfunction contextOf(snapshot: GrimoireSnapshot, options: ProductMapOptions): Context {\n const report = reportOf(snapshot);\n const featureErrors = new Map<string, number>();\n const flowErrors = new Map<string, number>();\n const featureFindings = new Map<string, { errors: number; warnings: number }>();\n\n for (const finding of report.findings) {\n if (finding.expected) continue;\n\n const owner = finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0] ?? null;\n\n if (owner !== null) {\n const known = featureFindings.get(owner) ?? { errors: 0, warnings: 0 };\n\n if (finding.severity === \"error\") known.errors += 1;\n else known.warnings += 1;\n\n featureFindings.set(owner, known);\n }\n\n if (finding.severity !== \"error\") continue;\n\n const flow = finding.subject.flow;\n const feature = finding.subject.feature ?? flow?.split(\"/\")[0] ?? null;\n\n if (feature !== null) featureErrors.set(feature, (featureErrors.get(feature) ?? 0) + 1);\n if (flow !== null) flowErrors.set(flow, (flowErrors.get(flow) ?? 0) + 1);\n }\n\n return {\n snapshot,\n options,\n report,\n featureErrors,\n flowErrors,\n featureFindings,\n captured: options.errors === null ? null : captureErrors(snapshot, options.errors, Date.now()),\n resultsMissing: snapshot.results === null && snapshot.proofs.length > 0,\n };\n}\n\nconst plural = (count: number, word: string): string => `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n\n/** The traffic light and its sentence (the rules of the product map). */\nfunction healthOf(\n context: Context,\n criteria: readonly Pick<FlowBookmapCriterion, \"status\">[],\n checkErrors: number,\n captured: ErrorCount | undefined,\n): ProductHealth {\n const counts = { total: criteria.length, pass: 0, fail: 0, stale: 0, notRun: 0, noTest: 0 };\n\n for (const criterion of criteria) {\n if (criterion.status === \"pass\") counts.pass += 1;\n else if (criterion.status === \"fail\") counts.fail += 1;\n else if (criterion.status === \"stale\") counts.stale += 1;\n else if (criterion.status === \"not-run\") counts.notRun += 1;\n else counts.noTest += 1;\n }\n\n const errors =\n context.captured === null\n ? null\n : { count: captured?.count ?? 0, lastSeen: captured?.lastSeen ?? null };\n const recent = errors?.count ?? 0;\n const total = counts.total;\n let level: ProductHealth[\"level\"];\n let reason: string;\n\n if (counts.fail > 0) {\n level = \"problem\";\n reason = `${counts.fail} of ${total} checks fail`;\n } else if (checkErrors > 0) {\n level = \"problem\";\n reason = `The check found ${plural(checkErrors, \"error\")}`;\n } else if (counts.noTest > 0) {\n level = \"attention\";\n reason = `${counts.noTest} of ${total} checks have no test`;\n } else if (context.resultsMissing && total > 0) {\n // A missing results file is a missing measurement, not a product problem: a shared (business) view shows it neutral.\n if (context.options.shared) {\n level = \"unknown\";\n reason = \"Test results are not measured\";\n } else {\n level = \"attention\";\n reason = \"No test results recorded\";\n }\n } else if (counts.stale > 0 || counts.notRun > 0) {\n level = \"attention\";\n reason = \"Tests have not run since they changed\";\n } else if (recent > 0) {\n level = \"attention\";\n reason = `${plural(recent, \"error\")} in the last hour`;\n } else if (total > 0) {\n level = \"good\";\n reason = `All ${total} checks pass`;\n } else {\n level = \"unknown\";\n reason = \"No checks written yet\";\n }\n\n return { level, reason, criteria: counts, errors };\n}\n\nfunction featureHealth(context: Context, feature: WrittenFeature): ProductHealth {\n const criteria = feature.flows.flatMap(\n (flow) => context.snapshot.collected.flows[flow.ref]?.criteria ?? [],\n );\n\n return healthOf(\n context,\n criteria,\n context.featureErrors.get(feature.id) ?? 0,\n context.captured?.features.get(feature.id),\n );\n}\n\nfunction flowHealthOf(context: Context, flow: WrittenFlow): ProductHealth {\n return healthOf(\n context,\n context.snapshot.collected.flows[flow.ref]?.criteria ?? [],\n context.flowErrors.get(flow.ref) ?? 0,\n context.captured?.flows.get(flow.ref),\n );\n}\n\nfunction findFeature(snapshot: GrimoireSnapshot, id: string | undefined): WrittenFeature {\n if (id === undefined || id === \"\") throw new GrimoirePanelError(400, 'Missing \"feature\".');\n\n const feature = snapshot.written.features.find((item) => item.id === id);\n\n if (feature === undefined || feature.readme === null) {\n throw new GrimoirePanelError(404, `No feature \"${id}\" is written in grimoire/features.`);\n }\n\n return feature;\n}\n\nfunction audienceOf(feature: WrittenFeature): string[] {\n const listed = (feature.readme?.audience ?? []).map((item) => item.value);\n\n if (listed.length > 0) return listed;\n\n return [...new Set(feature.flows.map((flow) => flow.who.value))];\n}\n\n/** The health strip numbers of a feature card. */\nfunction stripOf(context: Context, feature: WrittenFeature, health: ProductHealth): ProductStrip {\n const bookmaps = feature.flows.flatMap((flow) => {\n const found = context.snapshot.collected.flows[flow.ref];\n\n return found === undefined ? [] : [found];\n });\n const places = appearancesOf(context.snapshot, bookmaps);\n\n return {\n flows: {\n total: feature.flows.length,\n shipped: feature.flows.filter((flow) => flow.status.value === \"shipped\").length,\n },\n criteria: {\n total: health.criteria.total,\n proven: health.criteria.pass,\n failing: health.criteria.fail,\n // Nothing is measured when no result was recorded, or none of the criteria has a result yet.\n measured:\n !context.resultsMissing &&\n (health.criteria.total === 0 ||\n health.criteria.pass + health.criteria.fail + health.criteria.stale > 0 ||\n health.criteria.notRun === 0),\n },\n screenshots: {\n places: places.length,\n present: places.filter((place) => place.screenshots.length > 0).length,\n },\n findings: context.featureFindings.get(feature.id) ?? { errors: 0, warnings: 0 },\n };\n}\n\nconst DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n/** Only a real `YYYY-MM-DD` day counts as a change date; a bad `updated:` value is ignored here (check reports it). */\nconst isDay = (value: string): boolean =>\n DAY.test(value) && !Number.isNaN(new Date(`${value}T00:00:00Z`).getTime());\n\n/** Compares release names by their numeric parts, so `5.9.0` comes before `5.10.0`. */\nexport function compareReleases(left: string, right: string): number {\n const parts = (value: string) => value.split(/[.\\-+]/).map((part) => part);\n const a = parts(left);\n const b = parts(right);\n\n for (let index = 0; index < Math.max(a.length, b.length); index += 1) {\n const x = a[index] ?? \"0\";\n const y = b[index] ?? \"0\";\n const numeric = /^\\d+$/.test(x) && /^\\d+$/.test(y);\n const diff = numeric ? Number(x) - Number(y) : x < y ? -1 : x > y ? 1 : 0;\n\n if (diff !== 0) return diff;\n }\n\n return 0;\n}\n\nfunction card(context: Context, feature: WrittenFeature): ProductFeatureCard {\n const readme = feature.readme;\n\n if (readme === null) throw new Error(\"A feature card needs a README.\");\n\n const health = featureHealth(context, feature);\n const entries = feature.changelog?.entries ?? [];\n const dates = [\n readme.updated.value,\n ...entries.flatMap((entry) => (entry.date === null ? [] : [entry.date])),\n ].filter(isDay);\n\n return {\n changedAt: dates.reduce((newest, date) => (date > newest ? date : newest), \"\"),\n changedIn: [\n ...new Set(entries.flatMap((entry) => (entry.release === null ? [] : [entry.release]))),\n ],\n unreleased: entries.some((entry) => entry.release === null),\n id: feature.id,\n title: readme.title.value,\n summary: readme.summary,\n audience: audienceOf(feature),\n apps: readme.apps.map((app) => app.value),\n status: readme.status.value,\n version: readme.version.value,\n flows: feature.flows.length,\n health,\n strip: stripOf(context, feature, health),\n };\n}\n\n/** `GET /product`: the feature map. */\nexport function productMap(\n snapshot: GrimoireSnapshot,\n options: ProductMapOptions,\n): ProductMapAnswer {\n const context = contextOf(snapshot, options);\n\n return {\n builtAt: snapshot.book.manifest.builtAt,\n features: snapshot.written.features\n .filter((feature) => feature.readme !== null)\n .map((feature) => card(context, feature)),\n apps: snapshot.written.apps.map((app) => ({\n id: app.id.value,\n type: app.type.value,\n title: app.heading?.value ?? null,\n })),\n releases: snapshot.written.releases\n .map((item) => ({ release: item.release.value, date: item.date.value }))\n .sort(\n (left, right) =>\n left.date.localeCompare(right.date) || compareReleases(left.release, right.release),\n ),\n developer: !options.shared,\n host: snapshot.host ?? null,\n };\n}\n\nconst slugOf = (text: string): string =>\n text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n\nfunction screenshotsOf(items: readonly WrittenScreenshot[]): ProductScreenshot[] {\n return items.flatMap((item) => (item.path === null ? [] : [{ src: item.path, alt: item.alt }]));\n}\n\n/** Where the flows are shown, with the screenshots of the block (else of the page). */\nfunction appearancesOf(\n snapshot: GrimoireSnapshot,\n bookmaps: readonly FlowBookmap[],\n): ProductAppearance[] {\n const seen = new Set<string>();\n const list: ProductAppearance[] = [];\n const apps = new Map<string, WrittenApp>(snapshot.written.apps.map((app) => [app.id.value, app]));\n\n for (const bookmap of bookmaps) {\n for (const shown of bookmap.shownBy) {\n const key = `${shown.app}|${shown.type}|${shown.id}|${shown.block}|${bookmap.ref}`;\n\n if (seen.has(key)) continue;\n\n seen.add(key);\n\n const app = apps.get(shown.app);\n let title: string | null = null;\n let route: string | null = null;\n let screenshots: ProductScreenshot[] = [];\n\n if (app !== undefined && shown.type === \"layout\") {\n title = app.layouts.find((layout) => layout.id === shown.id)?.heading?.value ?? null;\n } else if (app !== undefined) {\n const page = [...app.pages, ...app.screens].find((item) => item.id === shown.id);\n\n if (page !== undefined) {\n title = page.heading?.value ?? null;\n route = page.route?.value ?? page.screen?.value ?? null;\n\n const block =\n page.blockFiles.find((item) => item.id === slugOf(shown.block)) ??\n page.blockFiles.find((item) => item.flow?.value === bookmap.ref);\n\n screenshots = screenshotsOf(block?.screenshots ?? []);\n\n if (screenshots.length === 0) screenshots = screenshotsOf(page.screenshots);\n }\n }\n\n list.push({\n app: shown.app,\n type: shown.type,\n id: shown.id,\n title,\n route,\n block: shown.block,\n flow: bookmap.ref,\n screenshots,\n });\n }\n }\n\n return list;\n}\n\nfunction releasesOf(snapshot: GrimoireSnapshot, feature: WrittenFeature): ProductRelease[] {\n const dates = new Map(\n snapshot.written.releases.map((item) => [item.release.value, item.date.value]),\n );\n const entries = feature.changelog?.entries ?? [];\n // Unreleased entries first, then the stamped ones in file order (newest first).\n const ordered = [\n ...entries.filter((entry) => entry.release === null),\n ...entries.filter((entry) => entry.release !== null),\n ];\n const groups = new Map<string, ProductRelease>();\n\n for (const entry of ordered) {\n const key = `${entry.version.value}|${entry.release ?? \"\"}`;\n let group = groups.get(key);\n\n if (group === undefined) {\n group = {\n version: entry.version.value,\n release: entry.release,\n date: entry.date ?? (entry.release === null ? null : (dates.get(entry.release) ?? null)),\n changes: [],\n };\n groups.set(key, group);\n }\n\n group.changes.push({ word: entry.word, flow: entry.flow, text: entry.text });\n }\n\n return [...groups.values()];\n}\n\nfunction plannedOf(snapshot: GrimoireSnapshot, feature: string): ProductPlannedItem[] {\n return snapshot.collected.tasksIndex.open\n .filter((task) => task.feature === feature)\n .map((task) => ({\n id: task.id,\n title: task.title,\n type: task.type,\n status: task.status,\n flow: task.flow === null ? null : task.flow.replace(`${feature}/`, \"\"),\n }));\n}\n\nfunction flowCard(context: Context, flow: WrittenFlow): ProductFlowCard {\n return {\n id: flow.id.value,\n ref: flow.ref,\n title: flow.heading?.value ?? flow.id.value,\n summary: flow.summary,\n who: flow.who.value,\n status: flow.status.value,\n health: flowHealthOf(context, flow),\n };\n}\n\n/** `GET /product/features/:feature`. */\nexport function productFeature(\n snapshot: GrimoireSnapshot,\n id: string | undefined,\n options: ProductMapOptions,\n): ProductFeatureAnswer {\n const feature = findFeature(snapshot, id);\n const readme = feature.readme;\n\n if (readme === null) throw new Error(\"unreachable\");\n\n const context = contextOf(snapshot, options);\n const bookmaps = feature.flows.flatMap((flow) => {\n const bookmap = snapshot.collected.flows[flow.ref];\n\n return bookmap === undefined ? [] : [bookmap];\n });\n const own = snapshot.collected.features[feature.id];\n const unexpected = context.report.findings.filter(\n (finding) => (finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0]) === feature.id,\n );\n const unexpectedNow = unexpected.filter((finding) => !finding.expected);\n const errors = unexpectedNow.filter((finding) => finding.severity === \"error\").length;\n\n return {\n feature: {\n id: feature.id,\n title: readme.title.value,\n summary: readme.summary,\n why: readme.why,\n audience: audienceOf(feature),\n apps: readme.apps.map((app) => app.value),\n status: readme.status.value,\n version: readme.version.value,\n updated: readme.updated.value,\n origin: readme.origin?.value ?? null,\n },\n flows: flowOrder(feature).map((flow) => flowCard(context, flow)),\n appearances: appearancesOf(snapshot, bookmaps),\n releases: releasesOf(snapshot, feature),\n planned: plannedOf(snapshot, feature.id),\n health: featureHealth(context, feature),\n host: snapshot.host ?? null,\n developer: options.shared\n ? null\n : {\n folders: readme.folders.map((folder) => folder.value),\n routes: (own?.routes ?? []).map(({ file: _file, ...route }) => route),\n files: own?.own.length ?? 0,\n findings: {\n errors,\n warnings: unexpectedNow.length - errors,\n expected: unexpected.length - unexpectedNow.length,\n },\n },\n };\n}\n\nconst STEP_WORDS: Record<WrittenStep[\"type\"], (target: string) => string> = {\n page: (target) => `Open ${target}`,\n route: () => \"The server takes the request\",\n mail: (target) => `An email \"${target}\" is sent`,\n notification: (target) => `A notification \"${target}\" is sent`,\n job: (target) => `The job \"${target}\" runs in the background`,\n event: (target) => `The event \"${target}\" happens`,\n \"outside service\": (target) => `The outside service \"${target}\" is used`,\n affects: (target) => `This also affects ${target}`,\n};\n\nfunction storyOf(flow: WrittenFlow): ProductStoryStep[] {\n if (flow.story.length > 0) {\n return flow.story.map((step) => ({\n index: step.index,\n text: step.text,\n screenshots: screenshotsOf(step.screenshots),\n derived: false,\n }));\n }\n\n return flow.steps.map((step) => ({\n index: step.index,\n text: step.note ?? STEP_WORDS[step.type](step.target),\n screenshots: [],\n derived: true,\n }));\n}\n\nconst DOES_NOT_APPLY = /^does not apply\\b[:\\s—-]*/i;\n\n/** `GET /product/flows/:feature/:flow`. */\nexport function productFlow(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n options: ProductMapOptions,\n): ProductFlowAnswer {\n const feature = findFeature(snapshot, featureId);\n const flow = feature.flows.find((item) => item.id.value === flowId);\n\n if (flow === undefined) {\n throw new GrimoirePanelError(404, `No flow \"${flowId ?? \"\"}\" in feature \"${feature.id}\".`);\n }\n\n const context = contextOf(snapshot, options);\n const bookmap = snapshot.collected.flows[flow.ref];\n const { previous, next } = neighboursOf(feature, flow.id.value);\n\n return {\n flow: {\n ref: flow.ref,\n feature: feature.id,\n featureTitle: feature.readme?.title.value ?? feature.id,\n title: flow.heading?.value ?? flow.id.value,\n summary: flow.summary,\n who: flow.who.value,\n status: flow.status.value,\n since: flow.since.value,\n },\n story: storyOf(flow),\n proof: (bookmap?.criteria ?? []).map((criterion) => ({\n id: criterion.id,\n text: criterion.text,\n status: criterion.status,\n tests: options.shared ? null : criterion.tests,\n })),\n cases: flow.cases.map((item) => {\n const answer = item.doesNotApply\n ? item.answer.replace(DOES_NOT_APPLY, \"\").trim()\n : item.answer;\n\n return {\n question: item.question,\n answer: answer === \"\" ? \"Does not apply\" : answer,\n handled: !item.doesNotApply,\n criteria: item.criteria,\n };\n }),\n appearances: bookmap === undefined ? [] : appearancesOf(snapshot, [bookmap]),\n previous,\n next,\n health: flowHealthOf(context, flow),\n developer: options.shared\n ? null\n : {\n steps: (bookmap?.steps ?? []).map((step) => compactStep(snapshot, feature, step, flow)),\n },\n host: snapshot.host ?? null,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAyDA,MAAM,kBAAkB;AAiBxB,SAAS,SAAS,KAA8B,KAAa,OAAkC;CAC7F,MAAM,QAAQ,IAAI,IAAI,GAAG;CAEzB,IAAI,IAAI,KAAK;EACX,QAAQ,OAAO,SAAS,KAAK,MAAM;EACnC,UAAU,KAAK,IAAI,OAAO,YAAY,GAAG,MAAM,QAAQ;CACzD,CAAC;AACH;;AAGA,SAAS,cACP,UACA,QACA,KACkC;CAClC,MAAM,2BAAW,IAAI,IAAwB;CAC7C,MAAM,wBAAQ,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":["../../../../../../../../packages/grimoire/src/devtools/product-map.ts"],"sourcesContent":["/**\n * The product map answers: the Grimoire in plain words for readers who do\n * not read code. Built from the written files, the book maps, the test\n * results, the open tasks, the changelogs and (when the devtools monitor\n * reports them) the captured errors. A shared answer (`options.shared`)\n * carries no file paths, code or test names.\n */\nimport { checkGrimoire } from \"../check\";\nimport { normalizeRoutePath } from \"../bookmap\";\nimport type { FlowBookmap, FlowBookmapCriterion } from \"../contracts/bookmap\";\nimport type { GrimoireCheckReport } from \"../contracts/findings\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type {\n WrittenApp,\n WrittenFeature,\n WrittenFlow,\n WrittenScreenshot,\n WrittenStep,\n} from \"../contracts/written\";\nimport { compactStep, flowOrder, neighboursOf } from \"../scry/compact\";\nimport type {\n ProductAppearance,\n ProductFeatureAnswer,\n ProductFeatureCard,\n ProductFlowAnswer,\n ProductFlowCard,\n ProductHealth,\n ProductMapAnswer,\n ProductPlannedItem,\n ProductRelease,\n ProductScreenshot,\n ProductStrip,\n ProductStoryStep,\n ProductWhatsNewAnswer,\n ProductWhatsNewRelease,\n} from \"./answers\";\nimport { GrimoirePanelError } from \"./data\";\n\n/** One captured error group as devtools hands it to a panel: counts only. */\nexport type ProductErrorSummary = {\n /** The route pattern (`/products/:id`), or `null` outside a request. */\n route: string | null;\n status: number | null;\n name: string | null;\n source: \"request\" | \"log\";\n count: number;\n firstSeen: number;\n lastSeen: number;\n};\n\n/** How the product map answers are built. */\nexport type ProductMapOptions = {\n /** `true` for a read-only share link: no developer detail. */\n shared: boolean;\n /** Captured error groups, or `null` when the monitor reports none. */\n errors: readonly ProductErrorSummary[] | null;\n};\n\n/** How far back captured errors count (one hour). */\nconst ERROR_WINDOW_MS = 3_600_000;\n\ntype ErrorCount = { count: number; lastSeen: number };\n\n/** Everything the answers share, computed once per request. */\ntype Context = {\n snapshot: GrimoireSnapshot;\n options: ProductMapOptions;\n report: GrimoireCheckReport;\n featureErrors: Map<string, number>;\n flowErrors: Map<string, number>;\n /** Unexpected findings by feature id. */\n featureFindings: Map<string, { errors: number; warnings: number }>;\n captured: { features: Map<string, ErrorCount>; flows: Map<string, ErrorCount> } | null;\n resultsMissing: boolean;\n};\n\nfunction addCount(map: Map<string, ErrorCount>, key: string, group: ProductErrorSummary): void {\n const known = map.get(key);\n\n map.set(key, {\n count: (known?.count ?? 0) + group.count,\n lastSeen: Math.max(known?.lastSeen ?? 0, group.lastSeen),\n });\n}\n\n/** Map the last hour's error groups to the features and flows that use their route. */\nfunction captureErrors(\n snapshot: GrimoireSnapshot,\n errors: readonly ProductErrorSummary[],\n now: number,\n): NonNullable<Context[\"captured\"]> {\n const features = new Map<string, ErrorCount>();\n const flows = new Map<string, ErrorCount>();\n const routes = snapshot.book.facts.routes ?? [];\n\n for (const group of errors) {\n if (group.route === null || group.lastSeen < now - ERROR_WINDOW_MS) continue;\n\n const path = normalizeRoutePath(group.route);\n\n for (const route of routes) {\n if (normalizeRoutePath(route.path) !== path) continue;\n\n const file = route.handlerFile ?? route.sourceFile;\n const owner = file === null ? null : (snapshot.ownership.files[file]?.owner ?? null);\n\n if (owner !== null) addCount(features, owner, group);\n }\n\n for (const feature of snapshot.written.features) {\n for (const flow of feature.flows) {\n const hit = flow.steps.some(\n (step) =>\n (step.type === \"route\" &&\n step.route !== null &&\n normalizeRoutePath(step.route.path) === path) ||\n (step.type === \"page\" && normalizeRoutePath(step.target) === path),\n );\n\n if (hit) addCount(flows, flow.ref, group);\n }\n }\n }\n\n return { features, flows };\n}\n\n/**\n * The check report of a snapshot, run once per snapshot. A share link reaches\n * these answers without an account, so a page view must not run the whole\n * check again; a changed book opens a new snapshot and a new report.\n */\nconst reports = new WeakMap<GrimoireSnapshot, GrimoireCheckReport>();\n\nfunction reportOf(snapshot: GrimoireSnapshot): GrimoireCheckReport {\n let report = reports.get(snapshot);\n\n if (report === undefined) {\n report = checkGrimoire(snapshot);\n reports.set(snapshot, report);\n }\n\n return report;\n}\n\nfunction contextOf(snapshot: GrimoireSnapshot, options: ProductMapOptions): Context {\n const report = reportOf(snapshot);\n const featureErrors = new Map<string, number>();\n const flowErrors = new Map<string, number>();\n const featureFindings = new Map<string, { errors: number; warnings: number }>();\n\n for (const finding of report.findings) {\n if (finding.expected) continue;\n\n const owner = finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0] ?? null;\n\n if (owner !== null) {\n const known = featureFindings.get(owner) ?? { errors: 0, warnings: 0 };\n\n if (finding.severity === \"error\") known.errors += 1;\n else known.warnings += 1;\n\n featureFindings.set(owner, known);\n }\n\n if (finding.severity !== \"error\") continue;\n\n const flow = finding.subject.flow;\n const feature = finding.subject.feature ?? flow?.split(\"/\")[0] ?? null;\n\n if (feature !== null) featureErrors.set(feature, (featureErrors.get(feature) ?? 0) + 1);\n if (flow !== null) flowErrors.set(flow, (flowErrors.get(flow) ?? 0) + 1);\n }\n\n return {\n snapshot,\n options,\n report,\n featureErrors,\n flowErrors,\n featureFindings,\n captured: options.errors === null ? null : captureErrors(snapshot, options.errors, Date.now()),\n resultsMissing: snapshot.results === null && snapshot.proofs.length > 0,\n };\n}\n\nconst plural = (count: number, word: string): string => `${count} ${word}${count === 1 ? \"\" : \"s\"}`;\n\n/** The traffic light and its sentence (the rules of the product map). */\nfunction healthOf(\n context: Context,\n criteria: readonly Pick<FlowBookmapCriterion, \"status\">[],\n checkErrors: number,\n captured: ErrorCount | undefined,\n): ProductHealth {\n const counts = { total: criteria.length, pass: 0, fail: 0, stale: 0, notRun: 0, noTest: 0 };\n\n for (const criterion of criteria) {\n if (criterion.status === \"pass\") counts.pass += 1;\n else if (criterion.status === \"fail\") counts.fail += 1;\n else if (criterion.status === \"stale\") counts.stale += 1;\n else if (criterion.status === \"not-run\") counts.notRun += 1;\n else counts.noTest += 1;\n }\n\n const errors =\n context.captured === null\n ? null\n : { count: captured?.count ?? 0, lastSeen: captured?.lastSeen ?? null };\n const recent = errors?.count ?? 0;\n const total = counts.total;\n let level: ProductHealth[\"level\"];\n let reason: string;\n\n if (counts.fail > 0) {\n level = \"problem\";\n reason = `${counts.fail} of ${total} checks fail`;\n } else if (checkErrors > 0) {\n level = \"problem\";\n reason = `The check found ${plural(checkErrors, \"error\")}`;\n } else if (counts.noTest > 0) {\n level = \"attention\";\n reason = `${counts.noTest} of ${total} checks have no test`;\n } else if (context.resultsMissing && total > 0) {\n // A missing results file is a missing measurement, not a product problem: a shared (business) view shows it neutral.\n if (context.options.shared) {\n level = \"unknown\";\n reason = \"Test results are not measured\";\n } else {\n level = \"attention\";\n reason = \"No test results recorded\";\n }\n } else if (counts.stale > 0 || counts.notRun > 0) {\n level = \"attention\";\n reason = \"Tests have not run since they changed\";\n } else if (recent > 0) {\n level = \"attention\";\n reason = `${plural(recent, \"error\")} in the last hour`;\n } else if (total > 0) {\n level = \"good\";\n reason = `All ${total} checks pass`;\n } else {\n level = \"unknown\";\n reason = \"No checks written yet\";\n }\n\n return { level, reason, criteria: counts, errors };\n}\n\nfunction featureHealth(context: Context, feature: WrittenFeature): ProductHealth {\n const criteria = feature.flows.flatMap(\n (flow) => context.snapshot.collected.flows[flow.ref]?.criteria ?? [],\n );\n\n return healthOf(\n context,\n criteria,\n context.featureErrors.get(feature.id) ?? 0,\n context.captured?.features.get(feature.id),\n );\n}\n\nfunction flowHealthOf(context: Context, flow: WrittenFlow): ProductHealth {\n return healthOf(\n context,\n context.snapshot.collected.flows[flow.ref]?.criteria ?? [],\n context.flowErrors.get(flow.ref) ?? 0,\n context.captured?.flows.get(flow.ref),\n );\n}\n\nfunction findFeature(snapshot: GrimoireSnapshot, id: string | undefined): WrittenFeature {\n if (id === undefined || id === \"\") throw new GrimoirePanelError(400, 'Missing \"feature\".');\n\n const feature = snapshot.written.features.find((item) => item.id === id);\n\n if (feature === undefined || feature.readme === null) {\n throw new GrimoirePanelError(404, `No feature \"${id}\" is written in grimoire/features.`);\n }\n\n return feature;\n}\n\nfunction audienceOf(feature: WrittenFeature): string[] {\n const listed = (feature.readme?.audience ?? []).map((item) => item.value);\n\n if (listed.length > 0) return listed;\n\n return [...new Set(feature.flows.map((flow) => flow.who.value))];\n}\n\n/** The health strip numbers of a feature card. */\nfunction stripOf(context: Context, feature: WrittenFeature, health: ProductHealth): ProductStrip {\n const bookmaps = feature.flows.flatMap((flow) => {\n const found = context.snapshot.collected.flows[flow.ref];\n\n return found === undefined ? [] : [found];\n });\n const places = appearancesOf(context.snapshot, bookmaps);\n\n return {\n flows: {\n total: feature.flows.length,\n shipped: feature.flows.filter((flow) => flow.status.value === \"shipped\").length,\n },\n criteria: {\n total: health.criteria.total,\n proven: health.criteria.pass,\n failing: health.criteria.fail,\n // Nothing is measured when no result was recorded, or none of the criteria has a result yet.\n measured:\n !context.resultsMissing &&\n (health.criteria.total === 0 ||\n health.criteria.pass + health.criteria.fail + health.criteria.stale > 0 ||\n health.criteria.notRun === 0),\n },\n screenshots: {\n places: places.length,\n present: places.filter((place) => place.screenshots.length > 0).length,\n },\n findings: context.featureFindings.get(feature.id) ?? { errors: 0, warnings: 0 },\n };\n}\n\nconst DAY = /^\\d{4}-\\d{2}-\\d{2}$/;\n\n/** Only a real `YYYY-MM-DD` day counts as a change date; a bad `updated:` value is ignored here (check reports it). */\nconst isDay = (value: string): boolean =>\n DAY.test(value) && !Number.isNaN(new Date(`${value}T00:00:00Z`).getTime());\n\n/** Compares release names by their numeric parts, so `5.9.0` comes before `5.10.0`. */\nexport function compareReleases(left: string, right: string): number {\n const parts = (value: string) => value.split(/[.\\-+]/).map((part) => part);\n const a = parts(left);\n const b = parts(right);\n\n for (let index = 0; index < Math.max(a.length, b.length); index += 1) {\n const x = a[index] ?? \"0\";\n const y = b[index] ?? \"0\";\n const numeric = /^\\d+$/.test(x) && /^\\d+$/.test(y);\n const diff = numeric ? Number(x) - Number(y) : x < y ? -1 : x > y ? 1 : 0;\n\n if (diff !== 0) return diff;\n }\n\n return 0;\n}\n\nfunction card(context: Context, feature: WrittenFeature): ProductFeatureCard {\n const readme = feature.readme;\n\n if (readme === null) throw new Error(\"A feature card needs a README.\");\n\n const health = featureHealth(context, feature);\n const entries = feature.changelog?.entries ?? [];\n const dates = [\n readme.updated.value,\n ...entries.flatMap((entry) => (entry.date === null ? [] : [entry.date])),\n ].filter(isDay);\n\n return {\n changedAt: dates.reduce((newest, date) => (date > newest ? date : newest), \"\"),\n changedIn: [\n ...new Set(entries.flatMap((entry) => (entry.release === null ? [] : [entry.release]))),\n ],\n unreleased: entries.some((entry) => entry.release === null),\n id: feature.id,\n title: readme.title.value,\n summary: readme.summary,\n audience: audienceOf(feature),\n apps: readme.apps.map((app) => app.value),\n status: readme.status.value,\n version: readme.version.value,\n flows: feature.flows.length,\n health,\n strip: stripOf(context, feature, health),\n };\n}\n\n/** `GET /product`: the feature map. */\nexport function productMap(\n snapshot: GrimoireSnapshot,\n options: ProductMapOptions,\n): ProductMapAnswer {\n const context = contextOf(snapshot, options);\n\n return {\n builtAt: snapshot.book.manifest.builtAt,\n features: snapshot.written.features\n .filter((feature) => feature.readme !== null)\n .map((feature) => card(context, feature)),\n apps: snapshot.written.apps.map((app) => ({\n id: app.id.value,\n type: app.type.value,\n title: app.heading?.value ?? null,\n })),\n releases: snapshot.written.releases\n .map((item) => ({ release: item.release.value, date: item.date.value }))\n .sort(\n (left, right) =>\n left.date.localeCompare(right.date) || compareReleases(left.release, right.release),\n ),\n developer: !options.shared,\n host: snapshot.host ?? null,\n };\n}\n\nconst slugOf = (text: string): string =>\n text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n\nfunction screenshotsOf(items: readonly WrittenScreenshot[]): ProductScreenshot[] {\n return items.flatMap((item) => (item.path === null ? [] : [{ src: item.path, alt: item.alt }]));\n}\n\n/** Where the flows are shown, with the screenshots of the block (else of the page). */\nfunction appearancesOf(\n snapshot: GrimoireSnapshot,\n bookmaps: readonly FlowBookmap[],\n): ProductAppearance[] {\n const seen = new Set<string>();\n const list: ProductAppearance[] = [];\n const apps = new Map<string, WrittenApp>(snapshot.written.apps.map((app) => [app.id.value, app]));\n\n for (const bookmap of bookmaps) {\n for (const shown of bookmap.shownBy) {\n const key = `${shown.app}|${shown.type}|${shown.id}|${shown.block}|${bookmap.ref}`;\n\n if (seen.has(key)) continue;\n\n seen.add(key);\n\n const app = apps.get(shown.app);\n let title: string | null = null;\n let route: string | null = null;\n let screenshots: ProductScreenshot[] = [];\n\n if (app !== undefined && shown.type === \"layout\") {\n title = app.layouts.find((layout) => layout.id === shown.id)?.heading?.value ?? null;\n } else if (app !== undefined) {\n const page = [...app.pages, ...app.screens].find((item) => item.id === shown.id);\n\n if (page !== undefined) {\n title = page.heading?.value ?? null;\n route = page.route?.value ?? page.screen?.value ?? null;\n\n const block =\n page.blockFiles.find((item) => item.id === slugOf(shown.block)) ??\n page.blockFiles.find((item) => item.flow?.value === bookmap.ref);\n\n screenshots = screenshotsOf(block?.screenshots ?? []);\n\n if (screenshots.length === 0) screenshots = screenshotsOf(page.screenshots);\n }\n }\n\n list.push({\n app: shown.app,\n appTitle: app?.heading?.value ?? null,\n type: shown.type,\n id: shown.id,\n title,\n route,\n block: shown.block,\n flow: bookmap.ref,\n screenshots,\n });\n }\n }\n\n return list;\n}\n\nfunction releasesOf(snapshot: GrimoireSnapshot, feature: WrittenFeature): ProductRelease[] {\n const dates = new Map(\n snapshot.written.releases.map((item) => [item.release.value, item.date.value]),\n );\n const entries = feature.changelog?.entries ?? [];\n // Unreleased entries first, then the stamped ones in file order (newest first).\n const ordered = [\n ...entries.filter((entry) => entry.release === null),\n ...entries.filter((entry) => entry.release !== null),\n ];\n const groups = new Map<string, ProductRelease>();\n\n for (const entry of ordered) {\n const key = `${entry.version.value}|${entry.release ?? \"\"}`;\n let group = groups.get(key);\n\n if (group === undefined) {\n group = {\n version: entry.version.value,\n release: entry.release,\n date: entry.date ?? (entry.release === null ? null : (dates.get(entry.release) ?? null)),\n changes: [],\n };\n groups.set(key, group);\n }\n\n group.changes.push({ word: entry.word, flow: entry.flow, text: entry.text });\n }\n\n return [...groups.values()];\n}\n\nfunction plannedOf(snapshot: GrimoireSnapshot, feature: string): ProductPlannedItem[] {\n return snapshot.collected.tasksIndex.open\n .filter((task) => task.feature === feature)\n .map((task) => ({\n id: task.id,\n title: task.title,\n type: task.type,\n status: task.status,\n flow: task.flow === null ? null : task.flow.replace(`${feature}/`, \"\"),\n }));\n}\n\nfunction flowCard(context: Context, flow: WrittenFlow): ProductFlowCard {\n return {\n id: flow.id.value,\n ref: flow.ref,\n title: flow.heading?.value ?? flow.id.value,\n summary: flow.summary,\n who: flow.who.value,\n status: flow.status.value,\n health: flowHealthOf(context, flow),\n };\n}\n\n/** `GET /product/features/:feature`. */\nexport function productFeature(\n snapshot: GrimoireSnapshot,\n id: string | undefined,\n options: ProductMapOptions,\n): ProductFeatureAnswer {\n const feature = findFeature(snapshot, id);\n const readme = feature.readme;\n\n if (readme === null) throw new Error(\"unreachable\");\n\n const context = contextOf(snapshot, options);\n const bookmaps = feature.flows.flatMap((flow) => {\n const bookmap = snapshot.collected.flows[flow.ref];\n\n return bookmap === undefined ? [] : [bookmap];\n });\n const own = snapshot.collected.features[feature.id];\n const unexpected = context.report.findings.filter(\n (finding) => (finding.subject.feature ?? finding.subject.flow?.split(\"/\")[0]) === feature.id,\n );\n const unexpectedNow = unexpected.filter((finding) => !finding.expected);\n const errors = unexpectedNow.filter((finding) => finding.severity === \"error\").length;\n\n return {\n feature: {\n id: feature.id,\n title: readme.title.value,\n summary: readme.summary,\n why: readme.why,\n audience: audienceOf(feature),\n apps: readme.apps.map((app) => app.value),\n status: readme.status.value,\n version: readme.version.value,\n updated: readme.updated.value,\n origin: readme.origin?.value ?? null,\n },\n flows: flowOrder(feature).map((flow) => flowCard(context, flow)),\n appearances: appearancesOf(snapshot, bookmaps),\n releases: releasesOf(snapshot, feature),\n planned: plannedOf(snapshot, feature.id),\n health: featureHealth(context, feature),\n host: snapshot.host ?? null,\n developer: options.shared\n ? null\n : {\n folders: readme.folders.map((folder) => folder.value),\n routes: (own?.routes ?? []).map(({ file: _file, ...route }) => route),\n files: own?.own.length ?? 0,\n findings: {\n errors,\n warnings: unexpectedNow.length - errors,\n expected: unexpected.length - unexpectedNow.length,\n },\n },\n };\n}\n\nconst STEP_WORDS: Record<WrittenStep[\"type\"], (target: string) => string> = {\n page: (target) => `Open ${target}`,\n route: () => \"The server takes the request\",\n mail: (target) => `An email \"${target}\" is sent`,\n notification: (target) => `A notification \"${target}\" is sent`,\n job: (target) => `The job \"${target}\" runs in the background`,\n event: (target) => `The event \"${target}\" happens`,\n \"outside service\": (target) => `The outside service \"${target}\" is used`,\n affects: (target) => `This also affects ${target}`,\n};\n\nfunction storyOf(flow: WrittenFlow): ProductStoryStep[] {\n if (flow.story.length > 0) {\n return flow.story.map((step) => ({\n index: step.index,\n text: step.text,\n screenshots: screenshotsOf(step.screenshots),\n derived: false,\n }));\n }\n\n return flow.steps.map((step) => ({\n index: step.index,\n text: step.note ?? STEP_WORDS[step.type](step.target),\n screenshots: [],\n derived: true,\n }));\n}\n\nconst DOES_NOT_APPLY = /^does not apply\\b[:\\s—-]*/i;\n\n/** `GET /product/flows/:feature/:flow`. */\nexport function productFlow(\n snapshot: GrimoireSnapshot,\n featureId: string | undefined,\n flowId: string | undefined,\n options: ProductMapOptions,\n): ProductFlowAnswer {\n const feature = findFeature(snapshot, featureId);\n const flow = feature.flows.find((item) => item.id.value === flowId);\n\n if (flow === undefined) {\n throw new GrimoirePanelError(404, `No flow \"${flowId ?? \"\"}\" in feature \"${feature.id}\".`);\n }\n\n const context = contextOf(snapshot, options);\n const bookmap = snapshot.collected.flows[flow.ref];\n const { previous, next } = neighboursOf(feature, flow.id.value);\n\n return {\n flow: {\n ref: flow.ref,\n feature: feature.id,\n featureTitle: feature.readme?.title.value ?? feature.id,\n title: flow.heading?.value ?? flow.id.value,\n summary: flow.summary,\n who: flow.who.value,\n status: flow.status.value,\n since: flow.since.value,\n },\n story: storyOf(flow),\n proof: (bookmap?.criteria ?? []).map((criterion) => ({\n id: criterion.id,\n text: criterion.text,\n status: criterion.status,\n tests: options.shared ? null : criterion.tests,\n })),\n cases: flow.cases.map((item) => {\n const answer = item.doesNotApply\n ? item.answer.replace(DOES_NOT_APPLY, \"\").trim()\n : item.answer;\n\n return {\n question: item.question,\n answer: answer === \"\" ? \"Does not apply\" : answer,\n handled: !item.doesNotApply,\n criteria: item.criteria,\n };\n }),\n appearances: bookmap === undefined ? [] : appearancesOf(snapshot, [bookmap]),\n previous,\n next,\n health: flowHealthOf(context, flow),\n developer: options.shared\n ? null\n : {\n steps: (bookmap?.steps ?? []).map((step) => compactStep(snapshot, feature, step, flow)),\n },\n host: snapshot.host ?? null,\n };\n}\n\n/** A reference id: `AC-6`, `T-12`, `QA 1.5.6`. */\nconst REFERENCE = /^(?:[A-Z]{1,5}-\\d+|QA\\s+\\d[\\w.-]*)$/;\n/** A trailing parenthesised group (optionally followed by one end mark) at the end of a sentence. */\nconst TRAILING_GROUP = /\\s*\\(([^()]*)\\)\\s*([.!?]?)\\s*$/;\n\n/** A sentence without the reference ids written in trailing parentheses: `\"Fixed the total (AC-6, T-12).\"` gives `\"Fixed the total.\"`. */\nfunction withoutReferences(sentence: string): string {\n let text = sentence;\n\n for (;;) {\n const match = TRAILING_GROUP.exec(text);\n\n if (match === null) break;\n\n const parts = (match[1] ?? \"\")\n .split(/[,;]/)\n .map((part) => part.trim())\n .filter((part) => part !== \"\");\n\n if (parts.length === 0 || !parts.every((part) => REFERENCE.test(part))) break;\n\n text = `${text.slice(0, match.index)}${match[2] ?? \"\"}`;\n }\n\n return text.trim();\n}\n\n/** The first paragraph of a release brief as one plain line, or `null`. */\nfunction firstParagraph(brief: string): string | null {\n const paragraph = brief\n .split(/\\n\\s*\\n/)\n .map((part) => part.trim())\n .find((part) => part !== \"\" && !part.startsWith(\"#\"));\n\n if (paragraph === undefined) return null;\n\n const text = withoutReferences(paragraph.replace(/\\s+/g, \" \").replaceAll(\"`\", \"\"));\n\n return text === \"\" ? null : text;\n}\n\n/** The newest release first; the changes without a release lead. */\nfunction newestFirst(left: ProductWhatsNewRelease, right: ProductWhatsNewRelease): number {\n if (left.release === null || right.release === null)\n return Number(right.release === null) - Number(left.release === null);\n\n return (\n (right.date ?? \"\").localeCompare(left.date ?? \"\") ||\n compareReleases(right.release, left.release)\n );\n}\n\n/**\n * `GET /product/whats-new`: the changelog entries of every feature, grouped by\n * release and then by feature, in plain words (no criterion or task ids, no\n * paths). A release is one a changelog names or a file in `grimoire/releases`;\n * the changes that are in no release yet only appear in the signed-in view.\n */\nexport function productWhatsNew(\n snapshot: GrimoireSnapshot,\n options: ProductMapOptions,\n): ProductWhatsNewAnswer {\n const written = new Map(snapshot.written.releases.map((item) => [item.release.value, item]));\n const releases = new Map<string, ProductWhatsNewRelease>();\n\n const releaseOf = (name: string | null, date: string | null): ProductWhatsNewRelease => {\n const key = name ?? \"\";\n let found = releases.get(key);\n\n if (found === undefined) {\n const file = name === null ? undefined : written.get(name);\n\n found = {\n release: name,\n date: file?.date.value ?? date,\n brief: file === undefined ? null : firstParagraph(file.brief),\n features: [],\n };\n releases.set(key, found);\n }\n\n return found;\n };\n\n for (const item of snapshot.written.releases) releaseOf(item.release.value, item.date.value);\n\n for (const feature of snapshot.written.features) {\n if (feature.readme === null) continue;\n\n const title = feature.readme.title.value;\n const flowTitles = new Map(\n feature.flows.map((flow) => [flow.id.value, flow.heading?.value ?? flow.id.value]),\n );\n\n for (const entry of feature.changelog?.entries ?? []) {\n if (entry.release === null && options.shared) continue;\n\n const release = releaseOf(entry.release, entry.date);\n let group = release.features.find((item) => item.id === feature.id);\n\n if (group === undefined) {\n group = { id: feature.id, title, changes: [] };\n release.features.push(group);\n }\n\n group.changes.push({\n word: entry.word,\n flow: entry.flow === null ? null : (flowTitles.get(entry.flow) ?? entry.flow),\n text: withoutReferences(entry.text),\n });\n }\n }\n\n return {\n releases: [...releases.values()]\n .filter((release) => release.release !== null || release.features.length > 0)\n .map((release) => ({\n ...release,\n features: [...release.features].sort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AAQ;GAE9C,MAAM,UAAU,UAAU,MAAM,SAAS,MAAM,IAAI;GACnD,IAAI,QAAQ,QAAQ,SAAS,MAAM,SAAS,KAAK,OAAO,QAAQ,EAAE;GAElE,IAAI,UAAU,QAAW;IACvB,QAAQ;KAAE,IAAI,QAAQ;KAAI;KAAO,SAAS,CAAC;IAAE;IAC7C,QAAQ,SAAS,KAAK,KAAK;GAC7B;GAEA,MAAM,QAAQ,KAAK;IACjB,MAAM,MAAM;IACZ,MAAM,MAAM,SAAS,OAAO,OAAQ,WAAW,IAAI,MAAM,IAAI,KAAK,MAAM;IACxE,MAAM,kBAAkB,MAAM,IAAI;GACpC,CAAC;EACH;CACF;CAEA,OAAO;EACL,UAAU,CAAC,GAAG,SAAS,OAAO,CAAC,CAAC,CAC7B,QAAQ,YAAY,QAAQ,YAAY,QAAQ,QAAQ,SAAS,SAAS,CAAC,CAAC,CAC5E,KAAK,aAAa;GACjB,GAAG;GACH,UAAU,CAAC,GAAG,QAAQ,QAAQ,CAAC,CAAC,MAAM,MAAM,UAC1C,KAAK,MAAM,cAAc,MAAM,KAAK,CACtC;EACF,EAAE,CAAC,CACF,KAAK,WAAW;EACnB,WAAW,CAAC,QAAQ;EACpB,MAAM,SAAS,QAAQ;CACzB;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"site.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/site.ts"],"mappings":";;;;YAoBY;;EAEV;;EAEA,UAAU,qBAAqB,QAAQ;;EAEvC,WAAW;;;;;;EAMX;;EAEA;;;YAIU;;EAEV;;EAEA;;;KAOG;EAAe;EAAc;EAAY;EAAuB;;;;;;;wBAuJrD,qBAAqB,UAAU;;;EAmBH,QAAA;;;;;;;;;;;;;;;;;;;;wBAsPtB,2BACpB,cACA,UAAS,4BACR,QAAQ;;wBAiDW,mBACpB,cACA,UAAS,4BACR"}
1
+ {"version":3,"file":"site.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/site.ts"],"mappings":";;;;YAqBY;;EAEV;;EAEA,UAAU,qBAAqB,QAAQ;;EAEvC,WAAW;;;;;;EAMX;;EAEA;;;YAIU;;EAEV;;EAEA;;;KAOG;EAAe;EAAc;EAAY;EAAuB;;;;;;;wBA6JrD,qBAAqB,UAAU;;;EAuBH,QAAA;;;;;;;;;;;;;;;;;;;;wBAsPtB,2BACpB,cACA,UAAS,4BACR,QAAQ;;wBAqDW,mBACpB,cACA,UAAS,4BACR"}
@@ -1,7 +1,8 @@
1
1
  import { GRIMOIRE_PATHS, projectPath, toPosixPath } from "../paths/index.mjs";
2
+ import { matrix, matrixImagePaths } from "./matrix.mjs";
2
3
  import { featureGraph, fileGraph, pageGraph } from "./graphs.mjs";
3
4
  import { apps, check, checkGroups, feature, features, file, flowAnswer, graphOfModules, page, releases, summary, tasks } from "./data.mjs";
4
- import { productFeature, productFlow, productMap } from "./product-map.mjs";
5
+ import { productFeature, productFlow, productMap, productWhatsNew } from "./product-map.mjs";
5
6
  import { createSnapshotSource } from "./snapshot-source.mjs";
6
7
  import { stampOf } from "../workspace/cache.mjs";
7
8
  import path from "node:path";
@@ -39,7 +40,11 @@ function buildSiteData(snapshot) {
39
40
  ...check(snapshot),
40
41
  root: "."
41
42
  },
42
- "graph/modules": graphOfModules(snapshot)
43
+ "graph/modules": graphOfModules(snapshot),
44
+ matrix: {
45
+ ...matrix(snapshot),
46
+ development: false
47
+ }
43
48
  };
44
49
  const productOptions = {
45
50
  shared: false,
@@ -48,6 +53,8 @@ function buildSiteData(snapshot) {
48
53
  const productAnswer = attempt(() => productMap(snapshot, productOptions));
49
54
  const groups = attempt(() => checkGroups(snapshot));
50
55
  if (productAnswer !== void 0) routes.product = productAnswer;
56
+ const whatsNew = attempt(() => productWhatsNew(snapshot, productOptions));
57
+ if (whatsNew !== void 0) routes["product/whats-new"] = whatsNew;
51
58
  if (groups !== void 0) routes["check/groups"] = groups;
52
59
  const search = [];
53
60
  for (const release of snapshot.written.releases) routes[`releases/${release.release.value}`] = release;
@@ -144,6 +151,8 @@ function buildProductSiteData(snapshot) {
144
151
  const routes = {};
145
152
  const map = attempt(() => productMap(snapshot, options));
146
153
  if (map !== void 0) routes.product = map;
154
+ const whatsNew = attempt(() => productWhatsNew(snapshot, options));
155
+ if (whatsNew !== void 0) routes["product/whats-new"] = whatsNew;
147
156
  for (const feature of snapshot.written.features) {
148
157
  const answer = attempt(() => productFeature(snapshot, feature.id, options));
149
158
  if (answer !== void 0) routes[`product/features/${feature.id}`] = answer;
@@ -346,7 +355,7 @@ async function exportGrimoireSiteDetailed(root, options = {}) {
346
355
  });
347
356
  await mkdir(absolute, { recursive: true });
348
357
  await writeFile(path.join(absolute, "index.html"), html);
349
- await copyScreenshots(root, absolute, collectScreenshotPaths(snapshot.written));
358
+ await copyScreenshots(root, absolute, [...collectScreenshotPaths(snapshot.written), ...product ? [] : matrixImagePaths(matrix(snapshot))]);
350
359
  return {
351
360
  outDir,
352
361
  upToDate: false