@warlock.js/grimoire 5.60.0 → 5.61.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  `@warlock.js/grimoire` is new in 5.55.0 and experimental: its file layout, `GR` codes and API may change in any release until it is marked stable.
4
4
 
5
+ ## 5.61.0 - 2026-11-20
6
+
7
+ ### Added
8
+
9
+ - A flow with no writes (only pages and GET, HEAD or OPTIONS routes) may leave out the `duplicate` and `double submit` case questions; the other six are still required (`GR1012`).
10
+ - New check `GR5010` (warning): a name written in backticks in a block table's "Changes with" that is not a condition declared in the app README. Plain text is never reported.
11
+ - The dev Grimoire tab reads route, event and job facts from the running dev server, so the first open shows fresh routes without `warlock grimoire build` and without booting the app a second time. New `createWarlockAdapter({ live: true })`, `liveInspect()` and snapshot source option `liveFacts`.
12
+
13
+ ### Changed
14
+
15
+ - The dev Grimoire tab warms the book in the background when the dev server starts. On a 10,400-file app, the first open after the warm-up takes about 0.1 s instead of about 6.6 s; an open that comes before the warm-up ends still waits for it (about 6.7 s). Concurrent first requests share one build, as before. Streaming partial answers is not part of this release.
16
+
17
+ ### Fixed
18
+
19
+ - Docs: items written `name: text` in "Changes with" are checked against the app's conditions (`GR5002`); this was always so, but the docs said otherwise.
20
+
5
21
  ## 5.59.0 - 2026-11-19
6
22
 
7
23
  ### Added
@@ -3,7 +3,7 @@ import { toPosixPath } from "../paths/index.mjs";
3
3
 
4
4
  //#region ../../packages/grimoire/src/apps/check-apps.ts
5
5
  /**
6
- * GR5001–GR5009: the written apps against the sites, pages, screens, flows
6
+ * GR5001–GR5010: the written apps against the sites, pages, screens, flows
7
7
  * and conditions they mention.
8
8
  */
9
9
  /** The feature and flow a block row points at, split from `<feature>/<flow>`. */
@@ -36,11 +36,17 @@ function normalizeRoute(route) {
36
36
  function blockSlug(block) {
37
37
  return block.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
38
38
  }
39
+ /** A name that can be a condition: `vip`, `plan:pro`. Other code in backticks is not a condition. */
40
+ const CONDITION_NAME = /^[a-z][a-z0-9-]*(?::[a-z0-9-]+)?$/;
41
+ /** The condition-shaped names written in backticks in a `Changes with` text. */
42
+ function codeNames(text) {
43
+ return [...text.matchAll(/`([^`]+)`/g)].map((match) => (match[1] ?? "").trim()).filter((name) => CONDITION_NAME.test(name));
44
+ }
39
45
  function pagesOf(app) {
40
46
  return [...app.pages, ...app.screens];
41
47
  }
42
48
  /**
43
- * GR5001–GR5009. Read-only. Pages and screens are compared with the adapter's
49
+ * GR5001–GR5010. Read-only. Pages and screens are compared with the adapter's
44
50
  * facts only when the app matched a site or mobile app (`GR5005` otherwise).
45
51
  */
46
52
  function checkApps(snapshot) {
@@ -73,6 +79,17 @@ function checkApps(snapshot) {
73
79
  ...subject
74
80
  }));
75
81
  }
82
+ const named = new Set(used);
83
+ for (const name of new Set(row.changesWith.flatMap((item) => codeNames(item.text)))) {
84
+ if (declared.has(name) || named.has(name)) continue;
85
+ findings.push(createFinding({
86
+ code: "GR5010",
87
+ message: `block "${row.block}" names \`${name}\` in Changes with, which is not a condition declared in the README of app "${appId}"`,
88
+ at: row.at,
89
+ app: appId,
90
+ ...subject
91
+ }));
92
+ }
76
93
  };
77
94
  for (const layout of app.layouts) layout.blocks.forEach(checkRow);
78
95
  for (const page of pagesOf(app)) {
@@ -1 +1 @@
1
- {"version":3,"file":"check-apps.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/apps/check-apps.ts"],"sourcesContent":["/**\n * GR5001–GR5009: the written apps against the sites, pages, screens, flows\n * and conditions they mention.\n */\nimport { createFinding } from \"../codes\";\nimport type { BookFacts } from \"../contracts/adapter\";\nimport type { GrimoireFinding } from \"../contracts/findings\";\nimport type { SourceLocation } from \"../contracts/location\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type { WrittenApp, WrittenBlockRow, WrittenPage } from \"../contracts/written\";\nimport { toPosixPath } from \"../paths\";\n\ntype Subject = { feature: string | null; flow: string | null };\n\n/** The feature and flow a block row points at, split from `<feature>/<flow>`. */\nfunction flowSubject(flow: string | null): Subject {\n if (!flow) return { feature: null, flow: null };\n\n return { feature: flow.split(\"/\")[0] ?? null, flow };\n}\n\n/** The flow all blocks of a page share, else their feature when they share one, else nothing. */\nfunction pageSubject(page: WrittenPage): Subject {\n const refs = [...new Set(page.blocks.map((row) => row.flow).filter((ref) => ref !== null))];\n\n if (refs.length === 1) return flowSubject(refs[0] ?? null);\n\n const features = [...new Set(refs.map((ref) => ref.split(\"/\")[0] ?? \"\"))];\n\n return { feature: features.length === 1 ? (features[0] ?? null) : null, flow: null };\n}\n\n/** A route as the router and the page graph compare it: `[id]` and `:id` are one parameter. */\nfunction normalizeRoute(route: string): string {\n const withSlash = toPosixPath(route.trim())\n .replace(/\\[\\.\\.\\.(\\w+)\\]/g, \":$1*\")\n .replace(/\\[(\\w+)\\]/g, \":$1\");\n const trimmed = withSlash.replace(/\\/+$/, \"\");\n\n return trimmed === \"\" ? \"/\" : trimmed.startsWith(\"/\") ? trimmed : `/${trimmed}`;\n}\n\n/** The id of a block file for a table row: `New arrivals` → `new-arrivals`. */\nfunction blockSlug(block: string): string {\n return block\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\nfunction pagesOf(app: WrittenApp): WrittenPage[] {\n return [...app.pages, ...app.screens];\n}\n\n/**\n * GR5001–GR5009. Read-only. Pages and screens are compared with the adapter's\n * facts only when the app matched a site or mobile app (`GR5005` otherwise).\n */\nexport function checkApps(snapshot: GrimoireSnapshot): GrimoireFinding[] {\n const findings: GrimoireFinding[] = [];\n const facts = snapshot.book.facts;\n const flows = new Set<string>();\n\n for (const feature of snapshot.written.features) {\n for (const flow of feature.flows) flows.add(`${feature.id}/${flow.id.value}`);\n }\n\n for (const app of snapshot.written.apps) {\n const match = snapshot.apps[app.id.value] ?? null;\n const appId = app.id.value;\n const declared = new Set(app.conditions.map((line) => line.name));\n const layoutIds = new Set(app.layouts.map((layout) => layout.id));\n\n const checkRow = (row: WrittenBlockRow): void => {\n const subject = flowSubject(row.flow);\n\n if (row.flow !== null && !flows.has(row.flow)) {\n findings.push(\n createFinding({\n code: \"GR5001\",\n message: `block \"${row.block}\" points to flow \"${row.flow}\", which does not exist`,\n at: row.at,\n app: appId,\n ...subject,\n }),\n );\n }\n\n const used = [\n ...row.who.conditions,\n ...row.changesWith.flatMap((item) => (item.condition === null ? [] : [item.condition])),\n ];\n\n for (const condition of new Set(used)) {\n if (declared.has(condition)) continue;\n\n findings.push(\n createFinding({\n code: \"GR5002\",\n message: `condition \"${condition}\" is not declared in the README of app \"${appId}\"`,\n at: row.at,\n app: appId,\n ...subject,\n }),\n );\n }\n };\n\n for (const layout of app.layouts) layout.blocks.forEach(checkRow);\n\n for (const page of pagesOf(app)) {\n const subject = pageSubject(page);\n const label = `${page.type} \"${page.id}\"`;\n\n page.blocks.forEach(checkRow);\n\n for (const block of page.blockFiles) {\n if (block.flow !== null && !flows.has(block.flow.value)) {\n findings.push(\n createFinding({\n code: \"GR5001\",\n message: `block file \"${block.id}\" of ${label} points to flow \"${block.flow.value}\", which does not exist`,\n at: block.flow.at,\n app: appId,\n ...flowSubject(block.flow.value),\n }),\n );\n }\n\n if (!page.blocks.some((row) => blockSlug(row.block) === block.id)) {\n findings.push(\n createFinding({\n code: \"GR5007\",\n message: `block file \"${block.id}\" has no row in the Blocks table of ${label}`,\n at: { file: block.file, line: 1, column: null },\n app: appId,\n ...(block.flow ? flowSubject(block.flow.value) : subject),\n }),\n );\n }\n }\n\n if (page.layout !== null && !layoutIds.has(page.layout.value)) {\n findings.push(\n createFinding({\n code: \"GR5004\",\n message: `${label} names layout \"${page.layout.value}\", but ${app.dir}/layouts/${page.layout.value}.md does not exist`,\n at: page.layout.at,\n app: appId,\n ...subject,\n }),\n );\n }\n\n if (match)\n checkReached(\n page,\n label,\n subject,\n appId,\n facts,\n match,\n app.screens,\n findings,\n snapshot.routes,\n );\n }\n\n // An app folder with no README is reported as GR1021 by the parser.\n if (app.file !== null && (!match || (!match.site && !match.mobile))) {\n findings.push(\n createFinding({\n code: \"GR5005\",\n message: `the root \"${app.root.value}\" of app \"${appId}\" matches no ${app.type.value === \"site\" ? \"site\" : \"mobile app\"} the code reports`,\n at: app.root.at,\n app: appId,\n }),\n );\n continue;\n }\n\n if (!match) continue;\n\n if (match.site) {\n const routes = new Set(\n facts.pages\n .filter((item) => item.site === match.site?.id)\n .map((item) => normalizeRoute(item.route)),\n );\n\n for (const page of app.pages) {\n if (!page.route || routes.has(normalizeRoute(page.route.value))) continue;\n\n findings.push(\n createFinding({\n code: \"GR5003\",\n message: `page \"${page.id}\" has route \"${page.route.value}\", which is not a page of site \"${match.site.id}\"`,\n at: page.route.at,\n app: appId,\n ...pageSubject(page),\n }),\n );\n }\n }\n\n if (match.mobile && match.mobile.routing === \"files\") {\n const routes = new Set(match.mobile.screens.map((screen) => normalizeRoute(screen.route)));\n\n for (const screen of app.screens) {\n const where: SourceLocation | null = screen.route?.at ?? screen.screen?.at ?? null;\n const route = screen.route?.value ?? null;\n\n if (route !== null && routes.has(normalizeRoute(route))) continue;\n\n findings.push(\n createFinding({\n code: \"GR5006\",\n message:\n route === null\n ? `screen \"${screen.id}\" has no route, and mobile app \"${match.mobile.id}\" uses file-based routing`\n : `screen \"${screen.id}\" has route \"${route}\", which is not a screen of mobile app \"${match.mobile.id}\"`,\n at: where ?? { file: screen.file, line: 1, column: null },\n app: appId,\n ...pageSubject(screen),\n }),\n );\n }\n }\n }\n\n checkUncovered(snapshot, findings);\n\n return findings;\n}\n\n/**\n * GR5008: an `Also reached from` entry that names nothing the code has. A mail\n * or notification entry is not checked without route facts (`routes: missing`):\n * the booted app is what reports them, so their absence proves nothing.\n */\nfunction checkReached(\n page: WrittenPage,\n label: string,\n subject: Subject,\n appId: string,\n facts: BookFacts,\n match: NonNullable<GrimoireSnapshot[\"apps\"][string]>,\n declaredScreens: readonly WrittenPage[],\n findings: GrimoireFinding[],\n routes: GrimoireSnapshot[\"routes\"],\n): void {\n for (const entry of page.alsoReachedFrom) {\n let found = true;\n\n if (entry.type === \"mail\" || entry.type === \"notification\") {\n if (routes === \"missing\") continue;\n\n found = facts.named.some((item) => item.type === entry.type && item.name === entry.name);\n } else if (entry.type === \"page\") {\n const site = match.site;\n const wanted = normalizeRoute(entry.name);\n\n found =\n site !== null &&\n facts.pages.some(\n (item) =>\n item.site === site.id &&\n (normalizeRoute(item.route) === wanted || item.name === entry.name),\n );\n } else if (entry.type === \"screen\") {\n const wanted = normalizeRoute(entry.name);\n\n found =\n match.mobile?.screens.some((item) => normalizeRoute(item.route) === wanted) === true ||\n declaredScreens.some(\n (item) =>\n item.id === entry.name ||\n item.screen?.value === entry.name ||\n (item.route !== null && normalizeRoute(item.route.value) === wanted),\n );\n }\n\n if (found) continue;\n\n findings.push(\n createFinding({\n code: \"GR5008\",\n message: `${label} is reached from ${entry.type} \"${entry.name}\", which does not exist`,\n at: entry.at,\n app: appId,\n ...subject,\n }),\n );\n }\n}\n\n/** GR5009: a site or mobile app the code reports that no written app describes. */\nfunction checkUncovered(snapshot: GrimoireSnapshot, findings: GrimoireFinding[]): void {\n if (snapshot.written.apps.length === 0) return;\n\n const sites = new Set<string>();\n const mobiles = new Set<string>();\n\n for (const match of Object.values(snapshot.apps)) {\n if (match.site) sites.add(match.site.id);\n if (match.mobile) mobiles.add(match.mobile.id);\n }\n\n for (const site of snapshot.book.facts.sites) {\n if (sites.has(site.id)) continue;\n\n findings.push(\n createFinding({\n code: \"GR5009\",\n message: `site \"${site.id}\" (${site.root}) has no folder in grimoire/apps`,\n }),\n );\n }\n\n for (const mobile of snapshot.book.facts.mobile) {\n if (mobiles.has(mobile.id)) continue;\n\n findings.push(\n createFinding({\n code: \"GR5009\",\n message: `mobile app \"${mobile.id}\" (${mobile.root}) has no folder in grimoire/apps`,\n }),\n );\n }\n}\n"],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OAAO;EAC5C,IAAI,MAAM,IAAI,KAAK,EAAE,GAAG;EAExB,SAAS,KACP,cAAc;GACZ,MAAM;GACN,SAAS,SAAS,KAAK,GAAG,KAAK,KAAK,KAAK;EAC3C,CAAC,CACH;CACF;CAEA,KAAK,MAAM,UAAU,SAAS,KAAK,MAAM,QAAQ;EAC/C,IAAI,QAAQ,IAAI,OAAO,EAAE,GAAG;EAE5B,SAAS,KACP,cAAc;GACZ,MAAM;GACN,SAAS,eAAe,OAAO,GAAG,KAAK,OAAO,KAAK;EACrD,CAAC,CACH;CACF;AACF"}
1
+ {"version":3,"file":"check-apps.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/apps/check-apps.ts"],"sourcesContent":["/**\n * GR5001–GR5010: the written apps against the sites, pages, screens, flows\n * and conditions they mention.\n */\nimport { createFinding } from \"../codes\";\nimport type { BookFacts } from \"../contracts/adapter\";\nimport type { GrimoireFinding } from \"../contracts/findings\";\nimport type { SourceLocation } from \"../contracts/location\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport type { WrittenApp, WrittenBlockRow, WrittenPage } from \"../contracts/written\";\nimport { toPosixPath } from \"../paths\";\n\ntype Subject = { feature: string | null; flow: string | null };\n\n/** The feature and flow a block row points at, split from `<feature>/<flow>`. */\nfunction flowSubject(flow: string | null): Subject {\n if (!flow) return { feature: null, flow: null };\n\n return { feature: flow.split(\"/\")[0] ?? null, flow };\n}\n\n/** The flow all blocks of a page share, else their feature when they share one, else nothing. */\nfunction pageSubject(page: WrittenPage): Subject {\n const refs = [...new Set(page.blocks.map((row) => row.flow).filter((ref) => ref !== null))];\n\n if (refs.length === 1) return flowSubject(refs[0] ?? null);\n\n const features = [...new Set(refs.map((ref) => ref.split(\"/\")[0] ?? \"\"))];\n\n return { feature: features.length === 1 ? (features[0] ?? null) : null, flow: null };\n}\n\n/** A route as the router and the page graph compare it: `[id]` and `:id` are one parameter. */\nfunction normalizeRoute(route: string): string {\n const withSlash = toPosixPath(route.trim())\n .replace(/\\[\\.\\.\\.(\\w+)\\]/g, \":$1*\")\n .replace(/\\[(\\w+)\\]/g, \":$1\");\n const trimmed = withSlash.replace(/\\/+$/, \"\");\n\n return trimmed === \"\" ? \"/\" : trimmed.startsWith(\"/\") ? trimmed : `/${trimmed}`;\n}\n\n/** The id of a block file for a table row: `New arrivals` → `new-arrivals`. */\nfunction blockSlug(block: string): string {\n return block\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n}\n\n/** A name that can be a condition: `vip`, `plan:pro`. Other code in backticks is not a condition. */\nconst CONDITION_NAME = /^[a-z][a-z0-9-]*(?::[a-z0-9-]+)?$/;\n\n/** The condition-shaped names written in backticks in a `Changes with` text. */\nfunction codeNames(text: string): string[] {\n return [...text.matchAll(/`([^`]+)`/g)]\n .map((match) => (match[1] ?? \"\").trim())\n .filter((name) => CONDITION_NAME.test(name));\n}\n\nfunction pagesOf(app: WrittenApp): WrittenPage[] {\n return [...app.pages, ...app.screens];\n}\n\n/**\n * GR5001–GR5010. Read-only. Pages and screens are compared with the adapter's\n * facts only when the app matched a site or mobile app (`GR5005` otherwise).\n */\nexport function checkApps(snapshot: GrimoireSnapshot): GrimoireFinding[] {\n const findings: GrimoireFinding[] = [];\n const facts = snapshot.book.facts;\n const flows = new Set<string>();\n\n for (const feature of snapshot.written.features) {\n for (const flow of feature.flows) flows.add(`${feature.id}/${flow.id.value}`);\n }\n\n for (const app of snapshot.written.apps) {\n const match = snapshot.apps[app.id.value] ?? null;\n const appId = app.id.value;\n const declared = new Set(app.conditions.map((line) => line.name));\n const layoutIds = new Set(app.layouts.map((layout) => layout.id));\n\n const checkRow = (row: WrittenBlockRow): void => {\n const subject = flowSubject(row.flow);\n\n if (row.flow !== null && !flows.has(row.flow)) {\n findings.push(\n createFinding({\n code: \"GR5001\",\n message: `block \"${row.block}\" points to flow \"${row.flow}\", which does not exist`,\n at: row.at,\n app: appId,\n ...subject,\n }),\n );\n }\n\n const used = [\n ...row.who.conditions,\n ...row.changesWith.flatMap((item) => (item.condition === null ? [] : [item.condition])),\n ];\n\n for (const condition of new Set(used)) {\n if (declared.has(condition)) continue;\n\n findings.push(\n createFinding({\n code: \"GR5002\",\n message: `condition \"${condition}\" is not declared in the README of app \"${appId}\"`,\n at: row.at,\n app: appId,\n ...subject,\n }),\n );\n }\n\n // Plain text in \"Changes with\" is free; only names written as code are checked.\n const named = new Set(used);\n\n for (const name of new Set(row.changesWith.flatMap((item) => codeNames(item.text)))) {\n if (declared.has(name) || named.has(name)) continue;\n\n findings.push(\n createFinding({\n code: \"GR5010\",\n message: `block \"${row.block}\" names \\`${name}\\` in Changes with, which is not a condition declared in the README of app \"${appId}\"`,\n at: row.at,\n app: appId,\n ...subject,\n }),\n );\n }\n };\n\n for (const layout of app.layouts) layout.blocks.forEach(checkRow);\n\n for (const page of pagesOf(app)) {\n const subject = pageSubject(page);\n const label = `${page.type} \"${page.id}\"`;\n\n page.blocks.forEach(checkRow);\n\n for (const block of page.blockFiles) {\n if (block.flow !== null && !flows.has(block.flow.value)) {\n findings.push(\n createFinding({\n code: \"GR5001\",\n message: `block file \"${block.id}\" of ${label} points to flow \"${block.flow.value}\", which does not exist`,\n at: block.flow.at,\n app: appId,\n ...flowSubject(block.flow.value),\n }),\n );\n }\n\n if (!page.blocks.some((row) => blockSlug(row.block) === block.id)) {\n findings.push(\n createFinding({\n code: \"GR5007\",\n message: `block file \"${block.id}\" has no row in the Blocks table of ${label}`,\n at: { file: block.file, line: 1, column: null },\n app: appId,\n ...(block.flow ? flowSubject(block.flow.value) : subject),\n }),\n );\n }\n }\n\n if (page.layout !== null && !layoutIds.has(page.layout.value)) {\n findings.push(\n createFinding({\n code: \"GR5004\",\n message: `${label} names layout \"${page.layout.value}\", but ${app.dir}/layouts/${page.layout.value}.md does not exist`,\n at: page.layout.at,\n app: appId,\n ...subject,\n }),\n );\n }\n\n if (match)\n checkReached(\n page,\n label,\n subject,\n appId,\n facts,\n match,\n app.screens,\n findings,\n snapshot.routes,\n );\n }\n\n // An app folder with no README is reported as GR1021 by the parser.\n if (app.file !== null && (!match || (!match.site && !match.mobile))) {\n findings.push(\n createFinding({\n code: \"GR5005\",\n message: `the root \"${app.root.value}\" of app \"${appId}\" matches no ${app.type.value === \"site\" ? \"site\" : \"mobile app\"} the code reports`,\n at: app.root.at,\n app: appId,\n }),\n );\n continue;\n }\n\n if (!match) continue;\n\n if (match.site) {\n const routes = new Set(\n facts.pages\n .filter((item) => item.site === match.site?.id)\n .map((item) => normalizeRoute(item.route)),\n );\n\n for (const page of app.pages) {\n if (!page.route || routes.has(normalizeRoute(page.route.value))) continue;\n\n findings.push(\n createFinding({\n code: \"GR5003\",\n message: `page \"${page.id}\" has route \"${page.route.value}\", which is not a page of site \"${match.site.id}\"`,\n at: page.route.at,\n app: appId,\n ...pageSubject(page),\n }),\n );\n }\n }\n\n if (match.mobile && match.mobile.routing === \"files\") {\n const routes = new Set(match.mobile.screens.map((screen) => normalizeRoute(screen.route)));\n\n for (const screen of app.screens) {\n const where: SourceLocation | null = screen.route?.at ?? screen.screen?.at ?? null;\n const route = screen.route?.value ?? null;\n\n if (route !== null && routes.has(normalizeRoute(route))) continue;\n\n findings.push(\n createFinding({\n code: \"GR5006\",\n message:\n route === null\n ? `screen \"${screen.id}\" has no route, and mobile app \"${match.mobile.id}\" uses file-based routing`\n : `screen \"${screen.id}\" has route \"${route}\", which is not a screen of mobile app \"${match.mobile.id}\"`,\n at: where ?? { file: screen.file, line: 1, column: null },\n app: appId,\n ...pageSubject(screen),\n }),\n );\n }\n }\n }\n\n checkUncovered(snapshot, findings);\n\n return findings;\n}\n\n/**\n * GR5008: an `Also reached from` entry that names nothing the code has. A mail\n * or notification entry is not checked without route facts (`routes: missing`):\n * the booted app is what reports them, so their absence proves nothing.\n */\nfunction checkReached(\n page: WrittenPage,\n label: string,\n subject: Subject,\n appId: string,\n facts: BookFacts,\n match: NonNullable<GrimoireSnapshot[\"apps\"][string]>,\n declaredScreens: readonly WrittenPage[],\n findings: GrimoireFinding[],\n routes: GrimoireSnapshot[\"routes\"],\n): void {\n for (const entry of page.alsoReachedFrom) {\n let found = true;\n\n if (entry.type === \"mail\" || entry.type === \"notification\") {\n if (routes === \"missing\") continue;\n\n found = facts.named.some((item) => item.type === entry.type && item.name === entry.name);\n } else if (entry.type === \"page\") {\n const site = match.site;\n const wanted = normalizeRoute(entry.name);\n\n found =\n site !== null &&\n facts.pages.some(\n (item) =>\n item.site === site.id &&\n (normalizeRoute(item.route) === wanted || item.name === entry.name),\n );\n } else if (entry.type === \"screen\") {\n const wanted = normalizeRoute(entry.name);\n\n found =\n match.mobile?.screens.some((item) => normalizeRoute(item.route) === wanted) === true ||\n declaredScreens.some(\n (item) =>\n item.id === entry.name ||\n item.screen?.value === entry.name ||\n (item.route !== null && normalizeRoute(item.route.value) === wanted),\n );\n }\n\n if (found) continue;\n\n findings.push(\n createFinding({\n code: \"GR5008\",\n message: `${label} is reached from ${entry.type} \"${entry.name}\", which does not exist`,\n at: entry.at,\n app: appId,\n ...subject,\n }),\n );\n }\n}\n\n/** GR5009: a site or mobile app the code reports that no written app describes. */\nfunction checkUncovered(snapshot: GrimoireSnapshot, findings: GrimoireFinding[]): void {\n if (snapshot.written.apps.length === 0) return;\n\n const sites = new Set<string>();\n const mobiles = new Set<string>();\n\n for (const match of Object.values(snapshot.apps)) {\n if (match.site) sites.add(match.site.id);\n if (match.mobile) mobiles.add(match.mobile.id);\n }\n\n for (const site of snapshot.book.facts.sites) {\n if (sites.has(site.id)) continue;\n\n findings.push(\n createFinding({\n code: \"GR5009\",\n message: `site \"${site.id}\" (${site.root}) has no folder in grimoire/apps`,\n }),\n );\n }\n\n for (const mobile of snapshot.book.facts.mobile) {\n if (mobiles.has(mobile.id)) continue;\n\n findings.push(\n createFinding({\n code: \"GR5009\",\n message: `mobile app \"${mobile.id}\" (${mobile.root}) has no folder in grimoire/apps`,\n }),\n );\n }\n}\n"],"mappings":";;;;;;;;;AAe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;EAEA,IAAI,OAAO;EAEX,SAAS,KACP,cAAc;GACZ,MAAM;GACN,SAAS,GAAG,MAAM,mBAAmB,MAAM,KAAK,IAAI,MAAM,KAAK;GAC/D,IAAI,MAAM;GACV,KAAK;GACL,GAAG;EACL,CAAC,CACH;CACF;AACF;;AAGA,SAAS,eAAe,UAA4B,UAAmC;CACrF,IAAI,SAAS,QAAQ,KAAK,WAAW,GAAG;CAExC,MAAM,wBAAQ,IAAI,IAAY;CAC9B,MAAM,0BAAU,IAAI,IAAY;CAEhC,KAAK,MAAM,SAAS,OAAO,OAAO,SAAS,IAAI,GAAG;EAChD,IAAI,MAAM,MAAM,MAAM,IAAI,MAAM,KAAK,EAAE;EACvC,IAAI,MAAM,QAAQ,QAAQ,IAAI,MAAM,OAAO,EAAE;CAC/C;CAEA,KAAK,MAAM,QAAQ,SAAS,KAAK,MAAM,OAAO;EAC5C,IAAI,MAAM,IAAI,KAAK,EAAE,GAAG;EAExB,SAAS,KACP,cAAc;GACZ,MAAM;GACN,SAAS,SAAS,KAAK,GAAG,KAAK,KAAK,KAAK;EAC3C,CAAC,CACH;CACF;CAEA,KAAK,MAAM,UAAU,SAAS,KAAK,MAAM,QAAQ;EAC/C,IAAI,QAAQ,IAAI,OAAO,EAAE,GAAG;EAE5B,SAAS,KACP,cAAc;GACZ,MAAM;GACN,SAAS,eAAe,OAAO,GAAG,KAAK,OAAO,KAAK;EACrD,CAAC,CACH;CACF;AACF"}
@@ -139,6 +139,8 @@ export declare const GRIMOIRE_CODE_LIST: readonly [GrimoireCodeDefinition & {
139
139
  readonly code: "GR5008";
140
140
  }, GrimoireCodeDefinition & {
141
141
  readonly code: "GR5009";
142
+ }, GrimoireCodeDefinition & {
143
+ readonly code: "GR5010";
142
144
  }, GrimoireCodeDefinition & {
143
145
  readonly code: "GR6001";
144
146
  }, GrimoireCodeDefinition & {
@@ -1 +1 @@
1
- {"version":3,"file":"codes.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/codes/codes.ts"],"mappings":";;;qBA0Ca,8BAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqvBnB,uBAAuB;;qBAGtB,gBAAgB,SAAS,OAAO,cAAc"}
1
+ {"version":3,"file":"codes.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/codes/codes.ts"],"mappings":";;;qBA0Ca,8BAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA6vBnB,uBAAuB;;qBAGtB,gBAAgB,SAAS,OAAO,cAAc"}
@@ -27,7 +27,7 @@ const GRIMOIRE_CODE_LIST = [
27
27
  define("GR1009", "structure", "error", "A step names an unknown kind", "Use one of: page, route, mail, notification, job, event, outside service, affects.", WRITE),
28
28
  define("GR1010", "structure", "error", "Steps are not numbered 1, 2, 3 in order", "Number the steps from 1 without gaps, in the order a user meets them.", WRITE),
29
29
  define("GR1011", "structure", "error", "A case line has the wrong form", "Write cases as `- double submit two taps save once`: the question, spaces, then the answer.", WRITE),
30
- define("GR1012", "structure", "warning", "A case question is not answered", "Answer the question under Cases (or `does not apply` and why), or list it under Not handled.", WRITE),
30
+ define("GR1012", "structure", "warning", "A case question is not answered", "Answer the question under Cases (or `does not apply` and why), or list it under Not handled. A flow with no writes (only pages and GET, HEAD or OPTIONS routes) may leave out `duplicate` and `double submit`.", WRITE),
31
31
  define("GR1013", "structure", "error", "A criterion line has the wrong form", "Write criteria as `- AC-3 a guest is sent to sign in`, optionally `- AC-4 [mobile] …`.", WRITE),
32
32
  define("GR1014", "structure", "error", "A criterion id is used twice in one flow", "Give the new criterion the next free number. Never renumber existing criteria.", WRITE),
33
33
  define("GR1015", "structure", "error", "A changelog line has the wrong form", "Write entries as `- 2.1 fixed new-arrivals: what changed (AC-2)`.", RECORD),
@@ -85,6 +85,7 @@ const GRIMOIRE_CODE_LIST = [
85
85
  define("GR5007", "apps", "warning", "A block file has no row in its page's Blocks table", "Add the block to the page's Blocks table, or remove the block file.", APP),
86
86
  define("GR5008", "apps", "error", "An entry point in Also reached from does not exist", "Fix the mail, notification or page name.", APP),
87
87
  define("GR5009", "apps", "warning", "A site or mobile app has no folder in grimoire/apps", "Add `grimoire/apps/<app>/README.md` for it.", APP),
88
+ define("GR5010", "apps", "warning", "A name in backticks in Changes with is not a declared condition", "Declare the condition under Conditions in the app README, fix the name, or write it without backticks when it is not a condition.", APP),
88
89
  define("GR6001", "changelog", "error", "A release lists a changelog entry that is not stamped with it", "Move the entry under `## <release> (<date>)` in the feature's CHANGELOG.md.", RECORD),
89
90
  define("GR6002", "changelog", "error", "A changelog release section has no release file", "Write `grimoire/releases/<release>.md`, or fix the release in the heading.", RECORD),
90
91
  define("GR6003", "changelog", "error", "A changelog release date differs from the release file", "Use the date in the release file's front matter.", RECORD),
@@ -1 +1 @@
1
- {"version":3,"file":"codes.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/codes/codes.ts"],"sourcesContent":["/**\n * The catalog of stable Grimoire finding codes.\n *\n * THE SCHEME: `GR` followed by four digits. The first digit is the area:\n *\n * | Range | Area | Meaning |\n * | ------ | --------- | ----------------------------------------------------------- |\n * | GR1xxx | structure | a written file does not follow its fixed structure |\n * | GR2xxx | links | a written name points at something that does not exist |\n * | GR3xxx | files | source files: headers, owners, files no flow reaches |\n * | GR4xxx | tests | criteria, `@proves` lines and test results |\n * | GR5xxx | apps | sites, mobile apps, pages, screens and blocks |\n * | GR6xxx | changelog | feature versions, changelogs and releases |\n * | GR7xxx | tasks | task files |\n * | GR8xxx | book | building the book from the framework's facts |\n * | GR9xxx | usage | a command or query was asked something it cannot answer |\n *\n * STABILITY: a released code keeps its meaning. Titles and fixes may be\n * reworded; a code is never reused or renumbered.\n *\n * This module imports nothing, so any entry can use it.\n */\nimport type { GrimoireCodeDefinition } from \"../contracts/findings\";\n\nfunction define<const Code extends string>(\n code: Code,\n area: GrimoireCodeDefinition[\"area\"],\n severity: GrimoireCodeDefinition[\"severity\"],\n title: string,\n fix: string,\n skill: string,\n): GrimoireCodeDefinition & { readonly code: Code } {\n return { code, area, severity, title, fix, skill };\n}\n\nconst WRITE = \"write-a-feature\";\nconst RECORD = \"record-a-change\";\nconst APP = \"describe-an-app\";\nconst FILE = \"document-a-file\";\nconst USE = \"use-the-grimoire\";\n\n/** Every code, in order. */\nexport const GRIMOIRE_CODE_LIST = [\n // ── GR1xxx structure ─────────────────────────────────────────────────────\n define(\n \"GR1001\",\n \"structure\",\n \"error\",\n \"A written file has no front matter\",\n \"Start the file with the front matter block its template shows, between two `---` lines.\",\n WRITE,\n ),\n define(\n \"GR1002\",\n \"structure\",\n \"error\",\n \"The front matter cannot be read\",\n \"Write one `key: value` per line; lists as `[a, b]` or as `- item` lines under the key; close the block with `---`.\",\n WRITE,\n ),\n define(\n \"GR1003\",\n \"structure\",\n \"error\",\n \"A required front matter key is missing\",\n \"Add the key named in the message; the template of that file lists every required key.\",\n WRITE,\n ),\n define(\n \"GR1004\",\n \"structure\",\n \"error\",\n \"A front matter value has the wrong form\",\n \"Use the form the message names: dates as yyyy-mm-dd, versions as 2.1, ids in lower-case-with-dashes, a status from the list (a task status is open, waiting for approval, approved, in progress, blocked, done or dropped; a question for the owner is waiting for approval).\",\n WRITE,\n ),\n define(\n \"GR1005\",\n \"structure\",\n \"warning\",\n \"A front matter key is not part of the template\",\n \"Remove the key, or move what it says into the body of the file.\",\n WRITE,\n ),\n define(\n \"GR1006\",\n \"structure\",\n \"error\",\n \"A required heading is missing\",\n \"Add the heading named in the message, spelled as in the template.\",\n WRITE,\n ),\n define(\n \"GR1007\",\n \"structure\",\n \"warning\",\n \"A heading is not part of the template\",\n \"Use the template's headings; put the text under one of them or remove it.\",\n WRITE,\n ),\n define(\n \"GR1008\",\n \"structure\",\n \"error\",\n \"A step line has the wrong form\",\n \"Write steps as `1. route POST /wishlist`: a number, a kind, then the name used in code.\",\n WRITE,\n ),\n define(\n \"GR1009\",\n \"structure\",\n \"error\",\n \"A step names an unknown kind\",\n \"Use one of: page, route, mail, notification, job, event, outside service, affects.\",\n WRITE,\n ),\n define(\n \"GR1010\",\n \"structure\",\n \"error\",\n \"Steps are not numbered 1, 2, 3 in order\",\n \"Number the steps from 1 without gaps, in the order a user meets them.\",\n WRITE,\n ),\n define(\n \"GR1011\",\n \"structure\",\n \"error\",\n \"A case line has the wrong form\",\n \"Write cases as `- double submit two taps save once`: the question, spaces, then the answer.\",\n WRITE,\n ),\n define(\n \"GR1012\",\n \"structure\",\n \"warning\",\n \"A case question is not answered\",\n \"Answer the question under Cases (or `does not apply` and why), or list it under Not handled.\",\n WRITE,\n ),\n define(\n \"GR1013\",\n \"structure\",\n \"error\",\n \"A criterion line has the wrong form\",\n \"Write criteria as `- AC-3 a guest is sent to sign in`, optionally `- AC-4 [mobile] …`.\",\n WRITE,\n ),\n define(\n \"GR1014\",\n \"structure\",\n \"error\",\n \"A criterion id is used twice in one flow\",\n \"Give the new criterion the next free number. Never renumber existing criteria.\",\n WRITE,\n ),\n define(\n \"GR1015\",\n \"structure\",\n \"error\",\n \"A changelog line has the wrong form\",\n \"Write entries as `- 2.1 fixed new-arrivals: what changed (AC-2)`.\",\n RECORD,\n ),\n define(\n \"GR1016\",\n \"structure\",\n \"error\",\n \"A changelog entry uses an unknown word\",\n \"Use one of: added, changed, fixed, removed.\",\n RECORD,\n ),\n define(\n \"GR1017\",\n \"structure\",\n \"error\",\n \"A changelog heading has the wrong form\",\n \"Use `## Unreleased`, or `## <release> (<yyyy-mm-dd>)` for entries of a release.\",\n RECORD,\n ),\n define(\n \"GR1018\",\n \"structure\",\n \"error\",\n \"A blocks table has the wrong form\",\n \"Use the columns Block, Flow, Who sees it, Changes with; one row per part of the page.\",\n APP,\n ),\n define(\n \"GR1019\",\n \"structure\",\n \"error\",\n \"An id does not match its folder or file name\",\n \"Make the front matter `id` (or `release`) equal the folder or file name.\",\n WRITE,\n ),\n define(\n \"GR1020\",\n \"structure\",\n \"warning\",\n \"A file in the grimoire folder is not part of the layout\",\n \"Move the file to where the layout expects it, or remove it.\",\n USE,\n ),\n define(\n \"GR1021\",\n \"structure\",\n \"error\",\n \"A feature, app, page or screen folder has no README.md\",\n \"Add README.md with the front matter of its template.\",\n WRITE,\n ),\n define(\n \"GR1022\",\n \"structure\",\n \"error\",\n \"Two files use the same id\",\n \"Give each feature, app or task its own id.\",\n WRITE,\n ),\n define(\n \"GR1023\",\n \"structure\",\n \"error\",\n \"A task file is misnamed or misplaced\",\n \"Name tasks `T-<n>-<slug>.md`, in `tasks/open/` or `tasks/done/<yyyy-mm>/`.\",\n RECORD,\n ),\n define(\n \"GR1024\",\n \"structure\",\n \"error\",\n \"The collected-list markers of a release file are broken\",\n \"Keep the start and end markers in pairs, or remove both and run `warlock grimoire release` again.\",\n RECORD,\n ),\n define(\n \"GR1025\",\n \"structure\",\n \"error\",\n \"A written file cannot be read\",\n \"Save the file as UTF-8 text.\",\n USE,\n ),\n define(\n \"GR1026\",\n \"structure\",\n \"error\",\n \"The feature README lists a flow that has no file\",\n \"Add `flows/<flow>.md`, or remove the flow from the README's Flows list.\",\n WRITE,\n ),\n define(\n \"GR1027\",\n \"structure\",\n \"warning\",\n \"A flow file is not listed in the feature README\",\n \"Add the flow to the README's Flows list.\",\n WRITE,\n ),\n define(\n \"GR1028\",\n \"structure\",\n \"error\",\n \"A list line has the wrong form\",\n \"Write list lines as `- name text`: the name, spaces, then the text.\",\n WRITE,\n ),\n define(\n \"GR1029\",\n \"structure\",\n \"warning\",\n \"An image line points outside grimoire/screenshots\",\n \"Keep screenshots in `grimoire/screenshots/` and write the path relative to the Markdown file, like `![Product page](../../../screenshots/web/product.png)`.\",\n WRITE,\n ),\n define(\n \"GR1030\",\n \"structure\",\n \"warning\",\n \"A flow has no summary\",\n \"Write one or two plain sentences under the flow's `# Title`: who does what, and what they get.\",\n WRITE,\n ),\n\n // ── GR2xxx links ─────────────────────────────────────────────────────────\n define(\n \"GR2001\",\n \"links\",\n \"error\",\n \"A route step names a route that does not exist\",\n \"Fix the method and path in the flow, or add the route in code.\",\n RECORD,\n ),\n define(\n \"GR2002\",\n \"links\",\n \"error\",\n \"A page step names a page that does not exist\",\n \"Fix the route path in the flow, or add the page to one of the feature's apps. A step scoped like `page /support [web-admin]` looks only in that app.\",\n RECORD,\n ),\n define(\n \"GR2003\",\n \"links\",\n \"error\",\n \"A mail step names a mail that does not exist\",\n \"Use the mail's name as code defines it, or add the mail.\",\n RECORD,\n ),\n define(\n \"GR2004\",\n \"links\",\n \"error\",\n \"A notification step names a notification that does not exist\",\n \"Use the notification's name as code defines it, or add it.\",\n RECORD,\n ),\n define(\n \"GR2005\",\n \"links\",\n \"error\",\n \"A job step names a job that does not exist\",\n \"Use the job's name as code defines it, or add the job.\",\n RECORD,\n ),\n define(\n \"GR2006\",\n \"links\",\n \"error\",\n \"An event step names an event that does not exist\",\n \"Use the event's name as code emits it, or add the event.\",\n RECORD,\n ),\n define(\n \"GR2007\",\n \"links\",\n \"error\",\n \"An affects step names a feature or flow that does not exist\",\n \"Write `affects <feature>/<flow>` with an existing feature and flow.\",\n WRITE,\n ),\n define(\n \"GR2008\",\n \"links\",\n \"error\",\n \"A name refers to an app with no folder\",\n \"Add `grimoire/apps/<app>/README.md`, or fix the app id.\",\n APP,\n ),\n define(\n \"GR2009\",\n \"links\",\n \"warning\",\n \"A flow names an app its feature does not list\",\n \"Add the app to the feature's `apps`, or fix the app id in Differs by app or the criterion.\",\n WRITE,\n ),\n define(\n \"GR2010\",\n \"links\",\n \"error\",\n \"A changelog entry names a flow that does not exist\",\n \"Fix the flow id before the `:`, or add the flow.\",\n RECORD,\n ),\n define(\n \"GR2011\",\n \"links\",\n \"error\",\n \"A changelog entry names a criterion the flow does not have\",\n \"Fix the criterion id, or add the criterion to the flow.\",\n RECORD,\n ),\n define(\n \"GR2012\",\n \"links\",\n \"error\",\n \"A README relation names a flow that does not exist\",\n \"Fix the `<feature>/<flow>` reference in Affects and affected by.\",\n WRITE,\n ),\n define(\n \"GR2013\",\n \"links\",\n \"error\",\n \"A case names a criterion the flow does not have\",\n \"Fix the `(AC-n)` at the end of the case line, or add the criterion under Acceptance criteria.\",\n WRITE,\n ),\n define(\n \"GR2014\",\n \"links\",\n \"warning\",\n \"An image line names a screenshot file that does not exist\",\n \"Add the image under `grimoire/screenshots/`, or fix the path.\",\n WRITE,\n ),\n\n // ── GR3xxx files ─────────────────────────────────────────────────────────\n define(\n \"GR3001\",\n \"files\",\n \"warning\",\n \"A source file has no header sentence\",\n \"Start the file with a one-sentence comment saying why it exists.\",\n FILE,\n ),\n define(\n \"GR3002\",\n \"files\",\n \"warning\",\n \"A source file belongs to no feature\",\n \"Add its folder to a feature's `folders`, or tag it `@feature <id>` in its header.\",\n FILE,\n ),\n define(\n \"GR3003\",\n \"files\",\n \"error\",\n \"A source file has two owners\",\n \"Keep one owner: remove the duplicate folder from one feature, or keep one `@feature` tag.\",\n FILE,\n ),\n define(\n \"GR3004\",\n \"files\",\n \"error\",\n \"A `@feature` tag names a feature that does not exist\",\n \"Fix the tag, or write the feature.\",\n FILE,\n ),\n define(\n \"GR3005\",\n \"files\",\n \"error\",\n \"A feature's `folders` entry does not exist\",\n \"Fix the folder or file path, or remove it from `folders`.\",\n WRITE,\n ),\n define(\n \"GR3006\",\n \"files\",\n \"warning\",\n \"A file in a feature's folders is reached by no flow\",\n \"Describe the behaviour in a flow, or delete dead code.\",\n RECORD,\n ),\n\n // ── GR4xxx tests ─────────────────────────────────────────────────────────\n define(\n \"GR4001\",\n \"tests\",\n \"warning\",\n \"A criterion has no test\",\n \"Write a test with `// @proves <feature>/<flow> AC-<n>` above it, or say in the task why not.\",\n RECORD,\n ),\n define(\n \"GR4002\",\n \"tests\",\n \"error\",\n \"A `@proves` line names a flow or criterion that does not exist\",\n \"Fix the `@proves` line to name an existing `<feature>/<flow> AC-<n>`.\",\n RECORD,\n ),\n define(\n \"GR4003\",\n \"tests\",\n \"error\",\n \"A `@proves` line has the wrong form\",\n \"Write `// @proves <feature>/<flow> AC-<n>` on its own line.\",\n RECORD,\n ),\n define(\n \"GR4004\",\n \"tests\",\n \"error\",\n \"A `@proves` line is not directly above a test\",\n \"Move the line right above the `it(…)` or `test(…)` it describes.\",\n RECORD,\n ),\n define(\n \"GR4005\",\n \"tests\",\n \"warning\",\n \"One test proves two criteria\",\n \"Split the test so each proves one criterion.\",\n RECORD,\n ),\n define(\n \"GR4006\",\n \"tests\",\n \"error\",\n \"A test proving a criterion failed in its last run\",\n \"Fix the code or the test, then run the tests again.\",\n RECORD,\n ),\n define(\n \"GR4007\",\n \"tests\",\n \"warning\",\n \"A criterion's test result is older than the test file\",\n \"Run the tests again.\",\n RECORD,\n ),\n define(\n \"GR4008\",\n \"tests\",\n \"warning\",\n \"A criterion's test did not run in the last run\",\n \"Run the tests that prove the criterion.\",\n RECORD,\n ),\n define(\n \"GR4009\",\n \"tests\",\n \"warning\",\n \"Tests prove criteria but no test results are recorded\",\n \"Add `grimoireReporter()` from `@warlock.js/grimoire/vitest` to `test.reporters` in the Vitest config and run the tests; in production, ship the results file with the deploy.\",\n RECORD,\n ),\n define(\n \"GR4010\",\n \"tests\",\n \"warning\",\n \"The reporter could not match a proving test to its result\",\n \"Keep the `it(...)` or `test(...)` call on the line right under the `@proves` comment, with a plain string name.\",\n RECORD,\n ),\n\n // ── GR5xxx apps ──────────────────────────────────────────────────────────\n define(\n \"GR5001\",\n \"apps\",\n \"error\",\n \"A block points to a flow that does not exist\",\n \"Fix the `<feature>/<flow>` in the Flow column or the block file.\",\n APP,\n ),\n define(\n \"GR5002\",\n \"apps\",\n \"error\",\n \"A condition is not declared in the app README\",\n \"Add the condition under Conditions in the app README, or use a declared one.\",\n APP,\n ),\n define(\n \"GR5003\",\n \"apps\",\n \"error\",\n \"A page's route does not exist in its site\",\n \"Fix the `route` of the page file, or remove the page file if the page is gone.\",\n APP,\n ),\n define(\n \"GR5004\",\n \"apps\",\n \"error\",\n \"A page names a layout with no file\",\n \"Add `layouts/<layout>.md` to the app, or fix the page's `layout`.\",\n APP,\n ),\n define(\n \"GR5005\",\n \"apps\",\n \"error\",\n \"An app's root matches no site or mobile app\",\n \"Set `root` to the site folder (`src/web/$sites/<site>`) or the mobile app folder.\",\n APP,\n ),\n define(\n \"GR5006\",\n \"apps\",\n \"error\",\n \"A screen's route does not exist in the mobile app\",\n \"Fix the `route` of the screen file, or remove it if the screen is gone.\",\n APP,\n ),\n define(\n \"GR5007\",\n \"apps\",\n \"warning\",\n \"A block file has no row in its page's Blocks table\",\n \"Add the block to the page's Blocks table, or remove the block file.\",\n APP,\n ),\n define(\n \"GR5008\",\n \"apps\",\n \"error\",\n \"An entry point in Also reached from does not exist\",\n \"Fix the mail, notification or page name.\",\n APP,\n ),\n define(\n \"GR5009\",\n \"apps\",\n \"warning\",\n \"A site or mobile app has no folder in grimoire/apps\",\n \"Add `grimoire/apps/<app>/README.md` for it.\",\n APP,\n ),\n\n // ── GR6xxx changelog ─────────────────────────────────────────────────────\n define(\n \"GR6001\",\n \"changelog\",\n \"error\",\n \"A release lists a changelog entry that is not stamped with it\",\n \"Move the entry under `## <release> (<date>)` in the feature's CHANGELOG.md.\",\n RECORD,\n ),\n define(\n \"GR6002\",\n \"changelog\",\n \"error\",\n \"A changelog release section has no release file\",\n \"Write `grimoire/releases/<release>.md`, or fix the release in the heading.\",\n RECORD,\n ),\n define(\n \"GR6003\",\n \"changelog\",\n \"error\",\n \"A changelog release date differs from the release file\",\n \"Use the date in the release file's front matter.\",\n RECORD,\n ),\n define(\n \"GR6004\",\n \"changelog\",\n \"error\",\n \"The README `updated` is older than the newest changelog entry\",\n \"Reshape the README to describe the feature as it is now, and set `updated`.\",\n RECORD,\n ),\n define(\n \"GR6005\",\n \"changelog\",\n \"error\",\n \"The README `version` differs from the newest changelog entry\",\n \"Set `version` to the newest entry's version.\",\n RECORD,\n ),\n define(\n \"GR6006\",\n \"changelog\",\n \"warning\",\n \"A changelog word does not match its version step\",\n \"Use a whole-number version for added and removed, a decimal for changed and fixed.\",\n RECORD,\n ),\n define(\n \"GR6007\",\n \"changelog\",\n \"error\",\n \"A flow's `since` is newer than its feature's version\",\n \"Fix `since`, or the feature `version`.\",\n WRITE,\n ),\n define(\n \"GR6008\",\n \"changelog\",\n \"warning\",\n \"A new whole-number version has no brief\",\n \"Write `versions/v<n>.md` before building it.\",\n WRITE,\n ),\n\n // ── GR7xxx tasks ─────────────────────────────────────────────────────────\n define(\n \"GR7001\",\n \"tasks\",\n \"error\",\n \"A task names a feature that does not exist\",\n \"Fix the task's `feature`, or write the feature first.\",\n WRITE,\n ),\n define(\n \"GR7002\",\n \"tasks\",\n \"error\",\n \"A task names a flow that does not exist\",\n \"Fix the task's `flow`, or write the flow first.\",\n WRITE,\n ),\n define(\n \"GR7003\",\n \"tasks\",\n \"error\",\n \"A task's status does not match its folder\",\n \"Done tasks live in `tasks/done/<yyyy-mm>/` with `status: done` and `shipped`; open tasks in `tasks/open/`.\",\n RECORD,\n ),\n define(\n \"GR7004\",\n \"tasks\",\n \"error\",\n \"A task's `shipped` names a version the changelog does not have\",\n \"Fix `shipped: <feature> <version>`, or add the changelog entry.\",\n RECORD,\n ),\n define(\n \"GR7005\",\n \"tasks\",\n \"warning\",\n \"A task's brief does not exist\",\n \"Fix the `Brief:` path, or write the brief.\",\n WRITE,\n ),\n\n // ── GR8xxx book ──────────────────────────────────────────────────────────\n define(\n \"GR8001\",\n \"book\",\n \"error\",\n \"The project's source files could not be read\",\n \"Read the message; fix the file or folder it names, then build again.\",\n USE,\n ),\n define(\n \"GR8002\",\n \"book\",\n \"warning\",\n \"Route facts could not be read because the app did not boot\",\n \"Run `warlock doctor`, fix what stops the app from booting, then `warlock grimoire build`.\",\n USE,\n ),\n define(\n \"GR8003\",\n \"book\",\n \"warning\",\n \"Route facts are older than the routes files\",\n \"Run `warlock grimoire build` to refresh them.\",\n USE,\n ),\n define(\n \"GR8004\",\n \"book\",\n \"warning\",\n \"Pages or screens could not be read\",\n \"Read the message; fix the page file it names, then build again.\",\n USE,\n ),\n\n // ── GR9xxx usage ─────────────────────────────────────────────────────────\n define(\n \"GR9001\",\n \"usage\",\n \"error\",\n \"The file is not in the book\",\n \"Pass a code file under the source roots, as a project-relative path.\",\n USE,\n ),\n define(\n \"GR9002\",\n \"usage\",\n \"error\",\n \"No route matches\",\n 'Pass `\"<METHOD> <path>\"` as the route is registered; `warlock routes` lists them.',\n USE,\n ),\n define(\n \"GR9003\",\n \"usage\",\n \"error\",\n \"No feature has that id\",\n \"Use an id from `grimoire/features/`.\",\n USE,\n ),\n define(\n \"GR9004\",\n \"usage\",\n \"error\",\n \"No flow has that id\",\n \"Use `<feature>/<flow>` with a file in `grimoire/features/<feature>/flows/`.\",\n USE,\n ),\n define(\n \"GR9005\",\n \"usage\",\n \"error\",\n \"The release file has no brief yet\",\n \"Write `grimoire/releases/<release>.md` with `release` and `date` front matter and the brief, then run the command again.\",\n RECORD,\n ),\n define(\n \"GR9006\",\n \"usage\",\n \"error\",\n \"A query argument has the wrong form\",\n \"Read the command's help (`warlock scry --help`) and pass the argument in that form.\",\n USE,\n ),\n] as const;\n\n/** One registered code, as a union. */\nexport type GrimoireCode = (typeof GRIMOIRE_CODE_LIST)[number][\"code\"];\n\n/** The catalog, keyed by code. */\nexport const GRIMOIRE_CODES: Readonly<Record<GrimoireCode, GrimoireCodeDefinition>> =\n Object.fromEntries(\n GRIMOIRE_CODE_LIST.map((definition) => [definition.code, definition]),\n ) as Record<GrimoireCode, GrimoireCodeDefinition>;\n"],"mappings":";AAwBA,SAAS,OACP,MACA,MACA,UACA,OACA,KACA,OACkD;CAClD,OAAO;EAAE;EAAM;EAAM;EAAU;EAAO;EAAK;CAAM;AACnD;AAEA,MAAM,QAAQ;AACd,MAAM,SAAS;AACf,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;;AAGZ,MAAa,qBAAqB;CAEhC,OACE,UACA,aACA,SACA,sCACA,2FACA,KACF;CACA,OACE,UACA,aACA,SACA,mCACA,sHACA,KACF;CACA,OACE,UACA,aACA,SACA,0CACA,yFACA,KACF;CACA,OACE,UACA,aACA,SACA,2CACA,iRACA,KACF;CACA,OACE,UACA,aACA,WACA,kDACA,mEACA,KACF;CACA,OACE,UACA,aACA,SACA,iCACA,qEACA,KACF;CACA,OACE,UACA,aACA,WACA,yCACA,6EACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,6FACA,KACF;CACA,OACE,UACA,aACA,SACA,gCACA,sFACA,KACF;CACA,OACE,UACA,aACA,SACA,2CACA,yEACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,iGACA,KACF;CACA,OACE,UACA,aACA,WACA,mCACA,gGACA,KACF;CACA,OACE,UACA,aACA,SACA,uCACA,8FACA,KACF;CACA,OACE,UACA,aACA,SACA,4CACA,kFACA,KACF;CACA,OACE,UACA,aACA,SACA,uCACA,wEACA,MACF;CACA,OACE,UACA,aACA,SACA,0CACA,+CACA,MACF;CACA,OACE,UACA,aACA,SACA,0CACA,mFACA,MACF;CACA,OACE,UACA,aACA,SACA,qCACA,yFACA,GACF;CACA,OACE,UACA,aACA,SACA,gDACA,4EACA,KACF;CACA,OACE,UACA,aACA,WACA,2DACA,+DACA,GACF;CACA,OACE,UACA,aACA,SACA,0DACA,wDACA,KACF;CACA,OACE,UACA,aACA,SACA,6BACA,8CACA,KACF;CACA,OACE,UACA,aACA,SACA,wCACA,8EACA,MACF;CACA,OACE,UACA,aACA,SACA,2DACA,qGACA,MACF;CACA,OACE,UACA,aACA,SACA,iCACA,gCACA,GACF;CACA,OACE,UACA,aACA,SACA,oDACA,2EACA,KACF;CACA,OACE,UACA,aACA,WACA,mDACA,4CACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,yEACA,KACF;CACA,OACE,UACA,aACA,WACA,qDACA,+JACA,KACF;CACA,OACE,UACA,aACA,WACA,yBACA,kGACA,KACF;CAGA,OACE,UACA,SACA,SACA,kDACA,kEACA,MACF;CACA,OACE,UACA,SACA,SACA,gDACA,wJACA,MACF;CACA,OACE,UACA,SACA,SACA,gDACA,4DACA,MACF;CACA,OACE,UACA,SACA,SACA,gEACA,8DACA,MACF;CACA,OACE,UACA,SACA,SACA,8CACA,0DACA,MACF;CACA,OACE,UACA,SACA,SACA,oDACA,4DACA,MACF;CACA,OACE,UACA,SACA,SACA,+DACA,yEACA,KACF;CACA,OACE,UACA,SACA,SACA,0CACA,2DACA,GACF;CACA,OACE,UACA,SACA,WACA,iDACA,8FACA,KACF;CACA,OACE,UACA,SACA,SACA,sDACA,oDACA,MACF;CACA,OACE,UACA,SACA,SACA,8DACA,2DACA,MACF;CACA,OACE,UACA,SACA,SACA,sDACA,oEACA,KACF;CACA,OACE,UACA,SACA,SACA,mDACA,iGACA,KACF;CACA,OACE,UACA,SACA,WACA,6DACA,iEACA,KACF;CAGA,OACE,UACA,SACA,WACA,wCACA,oEACA,IACF;CACA,OACE,UACA,SACA,WACA,uCACA,qFACA,IACF;CACA,OACE,UACA,SACA,SACA,gCACA,6FACA,IACF;CACA,OACE,UACA,SACA,SACA,wDACA,sCACA,IACF;CACA,OACE,UACA,SACA,SACA,8CACA,6DACA,KACF;CACA,OACE,UACA,SACA,WACA,uDACA,0DACA,MACF;CAGA,OACE,UACA,SACA,WACA,2BACA,gGACA,MACF;CACA,OACE,UACA,SACA,SACA,kEACA,yEACA,MACF;CACA,OACE,UACA,SACA,SACA,uCACA,+DACA,MACF;CACA,OACE,UACA,SACA,SACA,iDACA,oEACA,MACF;CACA,OACE,UACA,SACA,WACA,gCACA,gDACA,MACF;CACA,OACE,UACA,SACA,SACA,qDACA,uDACA,MACF;CACA,OACE,UACA,SACA,WACA,yDACA,wBACA,MACF;CACA,OACE,UACA,SACA,WACA,kDACA,2CACA,MACF;CACA,OACE,UACA,SACA,WACA,yDACA,iLACA,MACF;CACA,OACE,UACA,SACA,WACA,6DACA,mHACA,MACF;CAGA,OACE,UACA,QACA,SACA,gDACA,oEACA,GACF;CACA,OACE,UACA,QACA,SACA,iDACA,gFACA,GACF;CACA,OACE,UACA,QACA,SACA,6CACA,kFACA,GACF;CACA,OACE,UACA,QACA,SACA,sCACA,qEACA,GACF;CACA,OACE,UACA,QACA,SACA,+CACA,qFACA,GACF;CACA,OACE,UACA,QACA,SACA,qDACA,2EACA,GACF;CACA,OACE,UACA,QACA,WACA,sDACA,uEACA,GACF;CACA,OACE,UACA,QACA,SACA,sDACA,4CACA,GACF;CACA,OACE,UACA,QACA,WACA,uDACA,+CACA,GACF;CAGA,OACE,UACA,aACA,SACA,iEACA,+EACA,MACF;CACA,OACE,UACA,aACA,SACA,mDACA,8EACA,MACF;CACA,OACE,UACA,aACA,SACA,0DACA,oDACA,MACF;CACA,OACE,UACA,aACA,SACA,iEACA,+EACA,MACF;CACA,OACE,UACA,aACA,SACA,gEACA,gDACA,MACF;CACA,OACE,UACA,aACA,WACA,oDACA,sFACA,MACF;CACA,OACE,UACA,aACA,SACA,wDACA,0CACA,KACF;CACA,OACE,UACA,aACA,WACA,2CACA,gDACA,KACF;CAGA,OACE,UACA,SACA,SACA,8CACA,yDACA,KACF;CACA,OACE,UACA,SACA,SACA,2CACA,mDACA,KACF;CACA,OACE,UACA,SACA,SACA,6CACA,8GACA,MACF;CACA,OACE,UACA,SACA,SACA,kEACA,mEACA,MACF;CACA,OACE,UACA,SACA,WACA,iCACA,8CACA,KACF;CAGA,OACE,UACA,QACA,SACA,gDACA,wEACA,GACF;CACA,OACE,UACA,QACA,WACA,8DACA,6FACA,GACF;CACA,OACE,UACA,QACA,WACA,+CACA,iDACA,GACF;CACA,OACE,UACA,QACA,WACA,sCACA,mEACA,GACF;CAGA,OACE,UACA,SACA,SACA,+BACA,wEACA,GACF;CACA,OACE,UACA,SACA,SACA,oBACA,uFACA,GACF;CACA,OACE,UACA,SACA,SACA,0BACA,wCACA,GACF;CACA,OACE,UACA,SACA,SACA,uBACA,+EACA,GACF;CACA,OACE,UACA,SACA,SACA,qCACA,4HACA,MACF;CACA,OACE,UACA,SACA,SACA,uCACA,uFACA,GACF;AACF;;AAMA,MAAa,iBACX,OAAO,YACL,mBAAmB,KAAK,eAAe,CAAC,WAAW,MAAM,UAAU,CAAC,CACtE"}
1
+ {"version":3,"file":"codes.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/codes/codes.ts"],"sourcesContent":["/**\n * The catalog of stable Grimoire finding codes.\n *\n * THE SCHEME: `GR` followed by four digits. The first digit is the area:\n *\n * | Range | Area | Meaning |\n * | ------ | --------- | ----------------------------------------------------------- |\n * | GR1xxx | structure | a written file does not follow its fixed structure |\n * | GR2xxx | links | a written name points at something that does not exist |\n * | GR3xxx | files | source files: headers, owners, files no flow reaches |\n * | GR4xxx | tests | criteria, `@proves` lines and test results |\n * | GR5xxx | apps | sites, mobile apps, pages, screens and blocks |\n * | GR6xxx | changelog | feature versions, changelogs and releases |\n * | GR7xxx | tasks | task files |\n * | GR8xxx | book | building the book from the framework's facts |\n * | GR9xxx | usage | a command or query was asked something it cannot answer |\n *\n * STABILITY: a released code keeps its meaning. Titles and fixes may be\n * reworded; a code is never reused or renumbered.\n *\n * This module imports nothing, so any entry can use it.\n */\nimport type { GrimoireCodeDefinition } from \"../contracts/findings\";\n\nfunction define<const Code extends string>(\n code: Code,\n area: GrimoireCodeDefinition[\"area\"],\n severity: GrimoireCodeDefinition[\"severity\"],\n title: string,\n fix: string,\n skill: string,\n): GrimoireCodeDefinition & { readonly code: Code } {\n return { code, area, severity, title, fix, skill };\n}\n\nconst WRITE = \"write-a-feature\";\nconst RECORD = \"record-a-change\";\nconst APP = \"describe-an-app\";\nconst FILE = \"document-a-file\";\nconst USE = \"use-the-grimoire\";\n\n/** Every code, in order. */\nexport const GRIMOIRE_CODE_LIST = [\n // ── GR1xxx structure ─────────────────────────────────────────────────────\n define(\n \"GR1001\",\n \"structure\",\n \"error\",\n \"A written file has no front matter\",\n \"Start the file with the front matter block its template shows, between two `---` lines.\",\n WRITE,\n ),\n define(\n \"GR1002\",\n \"structure\",\n \"error\",\n \"The front matter cannot be read\",\n \"Write one `key: value` per line; lists as `[a, b]` or as `- item` lines under the key; close the block with `---`.\",\n WRITE,\n ),\n define(\n \"GR1003\",\n \"structure\",\n \"error\",\n \"A required front matter key is missing\",\n \"Add the key named in the message; the template of that file lists every required key.\",\n WRITE,\n ),\n define(\n \"GR1004\",\n \"structure\",\n \"error\",\n \"A front matter value has the wrong form\",\n \"Use the form the message names: dates as yyyy-mm-dd, versions as 2.1, ids in lower-case-with-dashes, a status from the list (a task status is open, waiting for approval, approved, in progress, blocked, done or dropped; a question for the owner is waiting for approval).\",\n WRITE,\n ),\n define(\n \"GR1005\",\n \"structure\",\n \"warning\",\n \"A front matter key is not part of the template\",\n \"Remove the key, or move what it says into the body of the file.\",\n WRITE,\n ),\n define(\n \"GR1006\",\n \"structure\",\n \"error\",\n \"A required heading is missing\",\n \"Add the heading named in the message, spelled as in the template.\",\n WRITE,\n ),\n define(\n \"GR1007\",\n \"structure\",\n \"warning\",\n \"A heading is not part of the template\",\n \"Use the template's headings; put the text under one of them or remove it.\",\n WRITE,\n ),\n define(\n \"GR1008\",\n \"structure\",\n \"error\",\n \"A step line has the wrong form\",\n \"Write steps as `1. route POST /wishlist`: a number, a kind, then the name used in code.\",\n WRITE,\n ),\n define(\n \"GR1009\",\n \"structure\",\n \"error\",\n \"A step names an unknown kind\",\n \"Use one of: page, route, mail, notification, job, event, outside service, affects.\",\n WRITE,\n ),\n define(\n \"GR1010\",\n \"structure\",\n \"error\",\n \"Steps are not numbered 1, 2, 3 in order\",\n \"Number the steps from 1 without gaps, in the order a user meets them.\",\n WRITE,\n ),\n define(\n \"GR1011\",\n \"structure\",\n \"error\",\n \"A case line has the wrong form\",\n \"Write cases as `- double submit two taps save once`: the question, spaces, then the answer.\",\n WRITE,\n ),\n define(\n \"GR1012\",\n \"structure\",\n \"warning\",\n \"A case question is not answered\",\n \"Answer the question under Cases (or `does not apply` and why), or list it under Not handled. A flow with no writes (only pages and GET, HEAD or OPTIONS routes) may leave out `duplicate` and `double submit`.\",\n WRITE,\n ),\n define(\n \"GR1013\",\n \"structure\",\n \"error\",\n \"A criterion line has the wrong form\",\n \"Write criteria as `- AC-3 a guest is sent to sign in`, optionally `- AC-4 [mobile] …`.\",\n WRITE,\n ),\n define(\n \"GR1014\",\n \"structure\",\n \"error\",\n \"A criterion id is used twice in one flow\",\n \"Give the new criterion the next free number. Never renumber existing criteria.\",\n WRITE,\n ),\n define(\n \"GR1015\",\n \"structure\",\n \"error\",\n \"A changelog line has the wrong form\",\n \"Write entries as `- 2.1 fixed new-arrivals: what changed (AC-2)`.\",\n RECORD,\n ),\n define(\n \"GR1016\",\n \"structure\",\n \"error\",\n \"A changelog entry uses an unknown word\",\n \"Use one of: added, changed, fixed, removed.\",\n RECORD,\n ),\n define(\n \"GR1017\",\n \"structure\",\n \"error\",\n \"A changelog heading has the wrong form\",\n \"Use `## Unreleased`, or `## <release> (<yyyy-mm-dd>)` for entries of a release.\",\n RECORD,\n ),\n define(\n \"GR1018\",\n \"structure\",\n \"error\",\n \"A blocks table has the wrong form\",\n \"Use the columns Block, Flow, Who sees it, Changes with; one row per part of the page.\",\n APP,\n ),\n define(\n \"GR1019\",\n \"structure\",\n \"error\",\n \"An id does not match its folder or file name\",\n \"Make the front matter `id` (or `release`) equal the folder or file name.\",\n WRITE,\n ),\n define(\n \"GR1020\",\n \"structure\",\n \"warning\",\n \"A file in the grimoire folder is not part of the layout\",\n \"Move the file to where the layout expects it, or remove it.\",\n USE,\n ),\n define(\n \"GR1021\",\n \"structure\",\n \"error\",\n \"A feature, app, page or screen folder has no README.md\",\n \"Add README.md with the front matter of its template.\",\n WRITE,\n ),\n define(\n \"GR1022\",\n \"structure\",\n \"error\",\n \"Two files use the same id\",\n \"Give each feature, app or task its own id.\",\n WRITE,\n ),\n define(\n \"GR1023\",\n \"structure\",\n \"error\",\n \"A task file is misnamed or misplaced\",\n \"Name tasks `T-<n>-<slug>.md`, in `tasks/open/` or `tasks/done/<yyyy-mm>/`.\",\n RECORD,\n ),\n define(\n \"GR1024\",\n \"structure\",\n \"error\",\n \"The collected-list markers of a release file are broken\",\n \"Keep the start and end markers in pairs, or remove both and run `warlock grimoire release` again.\",\n RECORD,\n ),\n define(\n \"GR1025\",\n \"structure\",\n \"error\",\n \"A written file cannot be read\",\n \"Save the file as UTF-8 text.\",\n USE,\n ),\n define(\n \"GR1026\",\n \"structure\",\n \"error\",\n \"The feature README lists a flow that has no file\",\n \"Add `flows/<flow>.md`, or remove the flow from the README's Flows list.\",\n WRITE,\n ),\n define(\n \"GR1027\",\n \"structure\",\n \"warning\",\n \"A flow file is not listed in the feature README\",\n \"Add the flow to the README's Flows list.\",\n WRITE,\n ),\n define(\n \"GR1028\",\n \"structure\",\n \"error\",\n \"A list line has the wrong form\",\n \"Write list lines as `- name text`: the name, spaces, then the text.\",\n WRITE,\n ),\n define(\n \"GR1029\",\n \"structure\",\n \"warning\",\n \"An image line points outside grimoire/screenshots\",\n \"Keep screenshots in `grimoire/screenshots/` and write the path relative to the Markdown file, like `![Product page](../../../screenshots/web/product.png)`.\",\n WRITE,\n ),\n define(\n \"GR1030\",\n \"structure\",\n \"warning\",\n \"A flow has no summary\",\n \"Write one or two plain sentences under the flow's `# Title`: who does what, and what they get.\",\n WRITE,\n ),\n\n // ── GR2xxx links ─────────────────────────────────────────────────────────\n define(\n \"GR2001\",\n \"links\",\n \"error\",\n \"A route step names a route that does not exist\",\n \"Fix the method and path in the flow, or add the route in code.\",\n RECORD,\n ),\n define(\n \"GR2002\",\n \"links\",\n \"error\",\n \"A page step names a page that does not exist\",\n \"Fix the route path in the flow, or add the page to one of the feature's apps. A step scoped like `page /support [web-admin]` looks only in that app.\",\n RECORD,\n ),\n define(\n \"GR2003\",\n \"links\",\n \"error\",\n \"A mail step names a mail that does not exist\",\n \"Use the mail's name as code defines it, or add the mail.\",\n RECORD,\n ),\n define(\n \"GR2004\",\n \"links\",\n \"error\",\n \"A notification step names a notification that does not exist\",\n \"Use the notification's name as code defines it, or add it.\",\n RECORD,\n ),\n define(\n \"GR2005\",\n \"links\",\n \"error\",\n \"A job step names a job that does not exist\",\n \"Use the job's name as code defines it, or add the job.\",\n RECORD,\n ),\n define(\n \"GR2006\",\n \"links\",\n \"error\",\n \"An event step names an event that does not exist\",\n \"Use the event's name as code emits it, or add the event.\",\n RECORD,\n ),\n define(\n \"GR2007\",\n \"links\",\n \"error\",\n \"An affects step names a feature or flow that does not exist\",\n \"Write `affects <feature>/<flow>` with an existing feature and flow.\",\n WRITE,\n ),\n define(\n \"GR2008\",\n \"links\",\n \"error\",\n \"A name refers to an app with no folder\",\n \"Add `grimoire/apps/<app>/README.md`, or fix the app id.\",\n APP,\n ),\n define(\n \"GR2009\",\n \"links\",\n \"warning\",\n \"A flow names an app its feature does not list\",\n \"Add the app to the feature's `apps`, or fix the app id in Differs by app or the criterion.\",\n WRITE,\n ),\n define(\n \"GR2010\",\n \"links\",\n \"error\",\n \"A changelog entry names a flow that does not exist\",\n \"Fix the flow id before the `:`, or add the flow.\",\n RECORD,\n ),\n define(\n \"GR2011\",\n \"links\",\n \"error\",\n \"A changelog entry names a criterion the flow does not have\",\n \"Fix the criterion id, or add the criterion to the flow.\",\n RECORD,\n ),\n define(\n \"GR2012\",\n \"links\",\n \"error\",\n \"A README relation names a flow that does not exist\",\n \"Fix the `<feature>/<flow>` reference in Affects and affected by.\",\n WRITE,\n ),\n define(\n \"GR2013\",\n \"links\",\n \"error\",\n \"A case names a criterion the flow does not have\",\n \"Fix the `(AC-n)` at the end of the case line, or add the criterion under Acceptance criteria.\",\n WRITE,\n ),\n define(\n \"GR2014\",\n \"links\",\n \"warning\",\n \"An image line names a screenshot file that does not exist\",\n \"Add the image under `grimoire/screenshots/`, or fix the path.\",\n WRITE,\n ),\n\n // ── GR3xxx files ─────────────────────────────────────────────────────────\n define(\n \"GR3001\",\n \"files\",\n \"warning\",\n \"A source file has no header sentence\",\n \"Start the file with a one-sentence comment saying why it exists.\",\n FILE,\n ),\n define(\n \"GR3002\",\n \"files\",\n \"warning\",\n \"A source file belongs to no feature\",\n \"Add its folder to a feature's `folders`, or tag it `@feature <id>` in its header.\",\n FILE,\n ),\n define(\n \"GR3003\",\n \"files\",\n \"error\",\n \"A source file has two owners\",\n \"Keep one owner: remove the duplicate folder from one feature, or keep one `@feature` tag.\",\n FILE,\n ),\n define(\n \"GR3004\",\n \"files\",\n \"error\",\n \"A `@feature` tag names a feature that does not exist\",\n \"Fix the tag, or write the feature.\",\n FILE,\n ),\n define(\n \"GR3005\",\n \"files\",\n \"error\",\n \"A feature's `folders` entry does not exist\",\n \"Fix the folder or file path, or remove it from `folders`.\",\n WRITE,\n ),\n define(\n \"GR3006\",\n \"files\",\n \"warning\",\n \"A file in a feature's folders is reached by no flow\",\n \"Describe the behaviour in a flow, or delete dead code.\",\n RECORD,\n ),\n\n // ── GR4xxx tests ─────────────────────────────────────────────────────────\n define(\n \"GR4001\",\n \"tests\",\n \"warning\",\n \"A criterion has no test\",\n \"Write a test with `// @proves <feature>/<flow> AC-<n>` above it, or say in the task why not.\",\n RECORD,\n ),\n define(\n \"GR4002\",\n \"tests\",\n \"error\",\n \"A `@proves` line names a flow or criterion that does not exist\",\n \"Fix the `@proves` line to name an existing `<feature>/<flow> AC-<n>`.\",\n RECORD,\n ),\n define(\n \"GR4003\",\n \"tests\",\n \"error\",\n \"A `@proves` line has the wrong form\",\n \"Write `// @proves <feature>/<flow> AC-<n>` on its own line.\",\n RECORD,\n ),\n define(\n \"GR4004\",\n \"tests\",\n \"error\",\n \"A `@proves` line is not directly above a test\",\n \"Move the line right above the `it(…)` or `test(…)` it describes.\",\n RECORD,\n ),\n define(\n \"GR4005\",\n \"tests\",\n \"warning\",\n \"One test proves two criteria\",\n \"Split the test so each proves one criterion.\",\n RECORD,\n ),\n define(\n \"GR4006\",\n \"tests\",\n \"error\",\n \"A test proving a criterion failed in its last run\",\n \"Fix the code or the test, then run the tests again.\",\n RECORD,\n ),\n define(\n \"GR4007\",\n \"tests\",\n \"warning\",\n \"A criterion's test result is older than the test file\",\n \"Run the tests again.\",\n RECORD,\n ),\n define(\n \"GR4008\",\n \"tests\",\n \"warning\",\n \"A criterion's test did not run in the last run\",\n \"Run the tests that prove the criterion.\",\n RECORD,\n ),\n define(\n \"GR4009\",\n \"tests\",\n \"warning\",\n \"Tests prove criteria but no test results are recorded\",\n \"Add `grimoireReporter()` from `@warlock.js/grimoire/vitest` to `test.reporters` in the Vitest config and run the tests; in production, ship the results file with the deploy.\",\n RECORD,\n ),\n define(\n \"GR4010\",\n \"tests\",\n \"warning\",\n \"The reporter could not match a proving test to its result\",\n \"Keep the `it(...)` or `test(...)` call on the line right under the `@proves` comment, with a plain string name.\",\n RECORD,\n ),\n\n // ── GR5xxx apps ──────────────────────────────────────────────────────────\n define(\n \"GR5001\",\n \"apps\",\n \"error\",\n \"A block points to a flow that does not exist\",\n \"Fix the `<feature>/<flow>` in the Flow column or the block file.\",\n APP,\n ),\n define(\n \"GR5002\",\n \"apps\",\n \"error\",\n \"A condition is not declared in the app README\",\n \"Add the condition under Conditions in the app README, or use a declared one.\",\n APP,\n ),\n define(\n \"GR5003\",\n \"apps\",\n \"error\",\n \"A page's route does not exist in its site\",\n \"Fix the `route` of the page file, or remove the page file if the page is gone.\",\n APP,\n ),\n define(\n \"GR5004\",\n \"apps\",\n \"error\",\n \"A page names a layout with no file\",\n \"Add `layouts/<layout>.md` to the app, or fix the page's `layout`.\",\n APP,\n ),\n define(\n \"GR5005\",\n \"apps\",\n \"error\",\n \"An app's root matches no site or mobile app\",\n \"Set `root` to the site folder (`src/web/$sites/<site>`) or the mobile app folder.\",\n APP,\n ),\n define(\n \"GR5006\",\n \"apps\",\n \"error\",\n \"A screen's route does not exist in the mobile app\",\n \"Fix the `route` of the screen file, or remove it if the screen is gone.\",\n APP,\n ),\n define(\n \"GR5007\",\n \"apps\",\n \"warning\",\n \"A block file has no row in its page's Blocks table\",\n \"Add the block to the page's Blocks table, or remove the block file.\",\n APP,\n ),\n define(\n \"GR5008\",\n \"apps\",\n \"error\",\n \"An entry point in Also reached from does not exist\",\n \"Fix the mail, notification or page name.\",\n APP,\n ),\n define(\n \"GR5009\",\n \"apps\",\n \"warning\",\n \"A site or mobile app has no folder in grimoire/apps\",\n \"Add `grimoire/apps/<app>/README.md` for it.\",\n APP,\n ),\n define(\n \"GR5010\",\n \"apps\",\n \"warning\",\n \"A name in backticks in Changes with is not a declared condition\",\n \"Declare the condition under Conditions in the app README, fix the name, or write it without backticks when it is not a condition.\",\n APP,\n ),\n\n // ── GR6xxx changelog ─────────────────────────────────────────────────────\n define(\n \"GR6001\",\n \"changelog\",\n \"error\",\n \"A release lists a changelog entry that is not stamped with it\",\n \"Move the entry under `## <release> (<date>)` in the feature's CHANGELOG.md.\",\n RECORD,\n ),\n define(\n \"GR6002\",\n \"changelog\",\n \"error\",\n \"A changelog release section has no release file\",\n \"Write `grimoire/releases/<release>.md`, or fix the release in the heading.\",\n RECORD,\n ),\n define(\n \"GR6003\",\n \"changelog\",\n \"error\",\n \"A changelog release date differs from the release file\",\n \"Use the date in the release file's front matter.\",\n RECORD,\n ),\n define(\n \"GR6004\",\n \"changelog\",\n \"error\",\n \"The README `updated` is older than the newest changelog entry\",\n \"Reshape the README to describe the feature as it is now, and set `updated`.\",\n RECORD,\n ),\n define(\n \"GR6005\",\n \"changelog\",\n \"error\",\n \"The README `version` differs from the newest changelog entry\",\n \"Set `version` to the newest entry's version.\",\n RECORD,\n ),\n define(\n \"GR6006\",\n \"changelog\",\n \"warning\",\n \"A changelog word does not match its version step\",\n \"Use a whole-number version for added and removed, a decimal for changed and fixed.\",\n RECORD,\n ),\n define(\n \"GR6007\",\n \"changelog\",\n \"error\",\n \"A flow's `since` is newer than its feature's version\",\n \"Fix `since`, or the feature `version`.\",\n WRITE,\n ),\n define(\n \"GR6008\",\n \"changelog\",\n \"warning\",\n \"A new whole-number version has no brief\",\n \"Write `versions/v<n>.md` before building it.\",\n WRITE,\n ),\n\n // ── GR7xxx tasks ─────────────────────────────────────────────────────────\n define(\n \"GR7001\",\n \"tasks\",\n \"error\",\n \"A task names a feature that does not exist\",\n \"Fix the task's `feature`, or write the feature first.\",\n WRITE,\n ),\n define(\n \"GR7002\",\n \"tasks\",\n \"error\",\n \"A task names a flow that does not exist\",\n \"Fix the task's `flow`, or write the flow first.\",\n WRITE,\n ),\n define(\n \"GR7003\",\n \"tasks\",\n \"error\",\n \"A task's status does not match its folder\",\n \"Done tasks live in `tasks/done/<yyyy-mm>/` with `status: done` and `shipped`; open tasks in `tasks/open/`.\",\n RECORD,\n ),\n define(\n \"GR7004\",\n \"tasks\",\n \"error\",\n \"A task's `shipped` names a version the changelog does not have\",\n \"Fix `shipped: <feature> <version>`, or add the changelog entry.\",\n RECORD,\n ),\n define(\n \"GR7005\",\n \"tasks\",\n \"warning\",\n \"A task's brief does not exist\",\n \"Fix the `Brief:` path, or write the brief.\",\n WRITE,\n ),\n\n // ── GR8xxx book ──────────────────────────────────────────────────────────\n define(\n \"GR8001\",\n \"book\",\n \"error\",\n \"The project's source files could not be read\",\n \"Read the message; fix the file or folder it names, then build again.\",\n USE,\n ),\n define(\n \"GR8002\",\n \"book\",\n \"warning\",\n \"Route facts could not be read because the app did not boot\",\n \"Run `warlock doctor`, fix what stops the app from booting, then `warlock grimoire build`.\",\n USE,\n ),\n define(\n \"GR8003\",\n \"book\",\n \"warning\",\n \"Route facts are older than the routes files\",\n \"Run `warlock grimoire build` to refresh them.\",\n USE,\n ),\n define(\n \"GR8004\",\n \"book\",\n \"warning\",\n \"Pages or screens could not be read\",\n \"Read the message; fix the page file it names, then build again.\",\n USE,\n ),\n\n // ── GR9xxx usage ─────────────────────────────────────────────────────────\n define(\n \"GR9001\",\n \"usage\",\n \"error\",\n \"The file is not in the book\",\n \"Pass a code file under the source roots, as a project-relative path.\",\n USE,\n ),\n define(\n \"GR9002\",\n \"usage\",\n \"error\",\n \"No route matches\",\n 'Pass `\"<METHOD> <path>\"` as the route is registered; `warlock routes` lists them.',\n USE,\n ),\n define(\n \"GR9003\",\n \"usage\",\n \"error\",\n \"No feature has that id\",\n \"Use an id from `grimoire/features/`.\",\n USE,\n ),\n define(\n \"GR9004\",\n \"usage\",\n \"error\",\n \"No flow has that id\",\n \"Use `<feature>/<flow>` with a file in `grimoire/features/<feature>/flows/`.\",\n USE,\n ),\n define(\n \"GR9005\",\n \"usage\",\n \"error\",\n \"The release file has no brief yet\",\n \"Write `grimoire/releases/<release>.md` with `release` and `date` front matter and the brief, then run the command again.\",\n RECORD,\n ),\n define(\n \"GR9006\",\n \"usage\",\n \"error\",\n \"A query argument has the wrong form\",\n \"Read the command's help (`warlock scry --help`) and pass the argument in that form.\",\n USE,\n ),\n] as const;\n\n/** One registered code, as a union. */\nexport type GrimoireCode = (typeof GRIMOIRE_CODE_LIST)[number][\"code\"];\n\n/** The catalog, keyed by code. */\nexport const GRIMOIRE_CODES: Readonly<Record<GrimoireCode, GrimoireCodeDefinition>> =\n Object.fromEntries(\n GRIMOIRE_CODE_LIST.map((definition) => [definition.code, definition]),\n ) as Record<GrimoireCode, GrimoireCodeDefinition>;\n"],"mappings":";AAwBA,SAAS,OACP,MACA,MACA,UACA,OACA,KACA,OACkD;CAClD,OAAO;EAAE;EAAM;EAAM;EAAU;EAAO;EAAK;CAAM;AACnD;AAEA,MAAM,QAAQ;AACd,MAAM,SAAS;AACf,MAAM,MAAM;AACZ,MAAM,OAAO;AACb,MAAM,MAAM;;AAGZ,MAAa,qBAAqB;CAEhC,OACE,UACA,aACA,SACA,sCACA,2FACA,KACF;CACA,OACE,UACA,aACA,SACA,mCACA,sHACA,KACF;CACA,OACE,UACA,aACA,SACA,0CACA,yFACA,KACF;CACA,OACE,UACA,aACA,SACA,2CACA,iRACA,KACF;CACA,OACE,UACA,aACA,WACA,kDACA,mEACA,KACF;CACA,OACE,UACA,aACA,SACA,iCACA,qEACA,KACF;CACA,OACE,UACA,aACA,WACA,yCACA,6EACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,6FACA,KACF;CACA,OACE,UACA,aACA,SACA,gCACA,sFACA,KACF;CACA,OACE,UACA,aACA,SACA,2CACA,yEACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,iGACA,KACF;CACA,OACE,UACA,aACA,WACA,mCACA,kNACA,KACF;CACA,OACE,UACA,aACA,SACA,uCACA,8FACA,KACF;CACA,OACE,UACA,aACA,SACA,4CACA,kFACA,KACF;CACA,OACE,UACA,aACA,SACA,uCACA,wEACA,MACF;CACA,OACE,UACA,aACA,SACA,0CACA,+CACA,MACF;CACA,OACE,UACA,aACA,SACA,0CACA,mFACA,MACF;CACA,OACE,UACA,aACA,SACA,qCACA,yFACA,GACF;CACA,OACE,UACA,aACA,SACA,gDACA,4EACA,KACF;CACA,OACE,UACA,aACA,WACA,2DACA,+DACA,GACF;CACA,OACE,UACA,aACA,SACA,0DACA,wDACA,KACF;CACA,OACE,UACA,aACA,SACA,6BACA,8CACA,KACF;CACA,OACE,UACA,aACA,SACA,wCACA,8EACA,MACF;CACA,OACE,UACA,aACA,SACA,2DACA,qGACA,MACF;CACA,OACE,UACA,aACA,SACA,iCACA,gCACA,GACF;CACA,OACE,UACA,aACA,SACA,oDACA,2EACA,KACF;CACA,OACE,UACA,aACA,WACA,mDACA,4CACA,KACF;CACA,OACE,UACA,aACA,SACA,kCACA,yEACA,KACF;CACA,OACE,UACA,aACA,WACA,qDACA,+JACA,KACF;CACA,OACE,UACA,aACA,WACA,yBACA,kGACA,KACF;CAGA,OACE,UACA,SACA,SACA,kDACA,kEACA,MACF;CACA,OACE,UACA,SACA,SACA,gDACA,wJACA,MACF;CACA,OACE,UACA,SACA,SACA,gDACA,4DACA,MACF;CACA,OACE,UACA,SACA,SACA,gEACA,8DACA,MACF;CACA,OACE,UACA,SACA,SACA,8CACA,0DACA,MACF;CACA,OACE,UACA,SACA,SACA,oDACA,4DACA,MACF;CACA,OACE,UACA,SACA,SACA,+DACA,yEACA,KACF;CACA,OACE,UACA,SACA,SACA,0CACA,2DACA,GACF;CACA,OACE,UACA,SACA,WACA,iDACA,8FACA,KACF;CACA,OACE,UACA,SACA,SACA,sDACA,oDACA,MACF;CACA,OACE,UACA,SACA,SACA,8DACA,2DACA,MACF;CACA,OACE,UACA,SACA,SACA,sDACA,oEACA,KACF;CACA,OACE,UACA,SACA,SACA,mDACA,iGACA,KACF;CACA,OACE,UACA,SACA,WACA,6DACA,iEACA,KACF;CAGA,OACE,UACA,SACA,WACA,wCACA,oEACA,IACF;CACA,OACE,UACA,SACA,WACA,uCACA,qFACA,IACF;CACA,OACE,UACA,SACA,SACA,gCACA,6FACA,IACF;CACA,OACE,UACA,SACA,SACA,wDACA,sCACA,IACF;CACA,OACE,UACA,SACA,SACA,8CACA,6DACA,KACF;CACA,OACE,UACA,SACA,WACA,uDACA,0DACA,MACF;CAGA,OACE,UACA,SACA,WACA,2BACA,gGACA,MACF;CACA,OACE,UACA,SACA,SACA,kEACA,yEACA,MACF;CACA,OACE,UACA,SACA,SACA,uCACA,+DACA,MACF;CACA,OACE,UACA,SACA,SACA,iDACA,oEACA,MACF;CACA,OACE,UACA,SACA,WACA,gCACA,gDACA,MACF;CACA,OACE,UACA,SACA,SACA,qDACA,uDACA,MACF;CACA,OACE,UACA,SACA,WACA,yDACA,wBACA,MACF;CACA,OACE,UACA,SACA,WACA,kDACA,2CACA,MACF;CACA,OACE,UACA,SACA,WACA,yDACA,iLACA,MACF;CACA,OACE,UACA,SACA,WACA,6DACA,mHACA,MACF;CAGA,OACE,UACA,QACA,SACA,gDACA,oEACA,GACF;CACA,OACE,UACA,QACA,SACA,iDACA,gFACA,GACF;CACA,OACE,UACA,QACA,SACA,6CACA,kFACA,GACF;CACA,OACE,UACA,QACA,SACA,sCACA,qEACA,GACF;CACA,OACE,UACA,QACA,SACA,+CACA,qFACA,GACF;CACA,OACE,UACA,QACA,SACA,qDACA,2EACA,GACF;CACA,OACE,UACA,QACA,WACA,sDACA,uEACA,GACF;CACA,OACE,UACA,QACA,SACA,sDACA,4CACA,GACF;CACA,OACE,UACA,QACA,WACA,uDACA,+CACA,GACF;CACA,OACE,UACA,QACA,WACA,mEACA,qIACA,GACF;CAGA,OACE,UACA,aACA,SACA,iEACA,+EACA,MACF;CACA,OACE,UACA,aACA,SACA,mDACA,8EACA,MACF;CACA,OACE,UACA,aACA,SACA,0DACA,oDACA,MACF;CACA,OACE,UACA,aACA,SACA,iEACA,+EACA,MACF;CACA,OACE,UACA,aACA,SACA,gEACA,gDACA,MACF;CACA,OACE,UACA,aACA,WACA,oDACA,sFACA,MACF;CACA,OACE,UACA,aACA,SACA,wDACA,0CACA,KACF;CACA,OACE,UACA,aACA,WACA,2CACA,gDACA,KACF;CAGA,OACE,UACA,SACA,SACA,8CACA,yDACA,KACF;CACA,OACE,UACA,SACA,SACA,2CACA,mDACA,KACF;CACA,OACE,UACA,SACA,SACA,6CACA,8GACA,MACF;CACA,OACE,UACA,SACA,SACA,kEACA,mEACA,MACF;CACA,OACE,UACA,SACA,WACA,iCACA,8CACA,KACF;CAGA,OACE,UACA,QACA,SACA,gDACA,wEACA,GACF;CACA,OACE,UACA,QACA,WACA,8DACA,6FACA,GACF;CACA,OACE,UACA,QACA,WACA,+CACA,iDACA,GACF;CACA,OACE,UACA,QACA,WACA,sCACA,mEACA,GACF;CAGA,OACE,UACA,SACA,SACA,+BACA,wEACA,GACF;CACA,OACE,UACA,SACA,SACA,oBACA,uFACA,GACF;CACA,OACE,UACA,SACA,SACA,0BACA,wCACA,GACF;CACA,OACE,UACA,SACA,SACA,uBACA,+EACA,GACF;CACA,OACE,UACA,SACA,SACA,qCACA,4HACA,MACF;CACA,OACE,UACA,SACA,SACA,uCACA,uFACA,GACF;AACF;;AAMA,MAAa,iBACX,OAAO,YACL,mBAAmB,KAAK,eAAe,CAAC,WAAW,MAAM,UAAU,CAAC,CACtE"}
@@ -12,14 +12,20 @@ function one(query, name) {
12
12
  }
13
13
  /** Build the panel for the app at `root`. */
14
14
  async function grimoireDevtoolsPanel(context) {
15
+ const development = context.mode !== "production";
16
+ let live;
17
+ const liveAdapter = () => live ??= import("../warlock/index.mjs").then(({ createWarlockAdapter }) => createWarlockAdapter({ live: true }));
15
18
  const source = createSnapshotSource(context.root, {
16
19
  write: context.mode !== "production",
17
20
  mode: context.mode ?? "development",
18
- ...context.adapter === void 0 ? {} : { adapter: context.adapter },
21
+ ...context.adapter === void 0 ? development ? {
22
+ adapter: liveAdapter,
23
+ liveFacts: true
24
+ } : {} : { adapter: context.adapter },
19
25
  ...context.ttlMs === void 0 ? {} : { ttlMs: context.ttlMs },
20
26
  ...context.testResultsFile === void 0 ? {} : { testResultsFile: context.testResultsFile }
21
27
  });
22
- if (context.mode === "production") source.warm();
28
+ if (!development || context.adapter === void 0) source.warm();
23
29
  const answer = (read) => async (request) => read(await source.get(), request);
24
30
  /** The product map answers: the shared flag from the request, the errors fetched per request. */
25
31
  const product = (read) => async (request) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["data.summary","data.search","data.file","data.impact","data.route","data.features","data.feature","data.flowAnswer","data.stepFiles","data.apps","data.page","data.tasks","data.releases","data.release","data.check","data.checkPage","data.checkGroups","data.graphOfFile","data.graphOfFeature","data.graphOfPage","data.graphOfModules"],"sources":["../../../../../../../../packages/grimoire/src/devtools/index.ts"],"sourcesContent":["/**\n * `@warlock.js/grimoire/devtools`: the Grimoire tab of the devtools\n * dashboard. An app enables it in `src/config/devtools.ts`:\n *\n * ```ts\n * panels: [\"@warlock.js/grimoire/devtools\"]\n * ```\n *\n * The default export is a panel factory (devtools' `DevtoolsPanelExport`),\n * typed structurally here so this entry needs no `@warlock.js/devtools`\n * import. The browser view lives in the package's `ui/` folder. Data routes\n * open the snapshot with `routes: \"cached\"` (never booting the app) and keep\n * the generated book up to date; agent-written files are only read.\n */\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport path from \"node:path\";\nimport type { GrimoireCheckFilter } from \"./answers\";\nimport * as data from \"./data\";\nimport { productFeature, productFlow, productMap, type ProductErrorSummary } from \"./product-map\";\nimport { createSnapshotSource } from \"./snapshot-source\";\n\nexport { buildProductSiteData, exportGrimoireSite, exportGrimoireSiteDetailed } from \"./site\";\nexport type { ExportGrimoireSiteOptions, GrimoireSiteExport } from \"./site\";\n\n/** The parts of devtools' `DevtoolsPanelRequest` the routes read. */\nexport type GrimoirePanelRequest = {\n params: Readonly<Record<string, string>>;\n query: Readonly<Record<string, string | readonly string[]>>;\n body: unknown;\n /** `true` when the request came through a read-only share link. */\n shared?: boolean;\n};\n\n/** Devtools' `DevtoolsPanelShare`, structurally: what a share link may show. */\nexport type GrimoireDevtoolsPanelShare = {\n view: string | URL;\n routes: readonly string[];\n assets?: readonly string[];\n files?: boolean;\n};\n\n/** Devtools' `DevtoolsPanel`, structurally. */\nexport type GrimoireDevtoolsPanel = {\n id: string;\n title: string;\n view: string | URL;\n routes?: readonly {\n method?: \"GET\" | \"POST\";\n path: string;\n handler: (request: GrimoirePanelRequest) => unknown;\n }[];\n assets?: Readonly<Record<string, string | URL>>;\n /** A folder of images served next to the panel. */\n files?: { dir: string; extensions?: readonly string[] };\n /** What a read-only share link may show. */\n share?: GrimoireDevtoolsPanelShare;\n /** Safe for the production monitor: the tab only reads (see `GrimoirePanelContext.mode`). */\n production?: boolean;\n};\n\n/** What the panel factory takes: devtools passes `{ root, mode }`; the rest is for tests and custom setups. */\nexport type GrimoirePanelContext = {\n /** The app root. */\n root: string;\n /**\n * Where the dashboard runs. In `\"production\"` the tab writes no files:\n * it reads the book as it is on disk. Default: development.\n */\n mode?: \"development\" | \"production\";\n /** The adapter to open the book with. Default: the Warlock adapter, loaded on first request. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /**\n * How long an opened snapshot is reused when the book did not change (ms).\n * Default in development: 2000, longer after a slow open; the old snapshot is served while a\n * background open refreshes it. Default in production: until the book changes.\n */\n ttlMs?: number;\n /**\n * Where the test results are read from (project-relative or absolute).\n * Default `grimoire/book/test-results.json`. Set it when the deploy ships\n * the results from CI; the Vitest reporter writes there with\n * `grimoireReporter({ file })`.\n */\n testResultsFile?: string;\n /** Captured error groups of the monitor (counts only), for the product map's health. Devtools passes it. */\n errors?: () => Promise<readonly ProductErrorSummary[]>;\n};\n\n/** The first value of a query parameter. */\nfunction one(query: GrimoirePanelRequest[\"query\"], name: string): string | undefined {\n const value = query[name];\n\n return Array.isArray(value) ? value[0] : (value as string | undefined);\n}\n\n/** Build the panel for the app at `root`. */\nexport async function grimoireDevtoolsPanel(\n context: GrimoirePanelContext,\n): Promise<GrimoireDevtoolsPanel> {\n // In development the tab keeps Warlock's generated files (book, book maps, indexes) up to date, so\n // the next open is incremental. In production it writes nothing. Agent-written files are only read,\n // and cached routes never boot the app.\n const source = createSnapshotSource(context.root, {\n write: context.mode !== \"production\",\n mode: context.mode ?? \"development\",\n // The panel runs inside the app's own process. Collecting route facts there boots every connector and\n // re-imports the route and event modules, which would register them twice in the live app. So the tab\n // reads the cached facts and says \"missing\" or \"stale\" until `warlock grimoire build` runs elsewhere.\n ...(context.adapter === undefined ? {} : { adapter: context.adapter }),\n ...(context.ttlMs === undefined ? {} : { ttlMs: context.ttlMs }),\n ...(context.testResultsFile === undefined ? {} : { testResultsFile: context.testResultsFile }),\n });\n\n // In production, start opening the book now so the first tab view is fast.\n if (context.mode === \"production\") source.warm();\n\n const answer =\n <Answer>(read: (snapshot: GrimoireSnapshot, request: GrimoirePanelRequest) => Answer) =>\n async (request: GrimoirePanelRequest): Promise<Answer> =>\n read(await source.get(), request);\n\n /** The product map answers: the shared flag from the request, the errors fetched per request. */\n const product =\n <Answer>(\n read: (\n snapshot: GrimoireSnapshot,\n request: GrimoirePanelRequest,\n options: { shared: boolean; errors: readonly ProductErrorSummary[] | null },\n ) => Answer,\n ) =>\n async (request: GrimoirePanelRequest): Promise<Answer> => {\n const snapshot = await source.get();\n let errors: readonly ProductErrorSummary[] | null = null;\n\n try {\n errors = (await context.errors?.()) ?? null;\n } catch {\n errors = null;\n }\n\n return read(snapshot, request, { shared: request.shared === true, errors });\n };\n\n const number = (value: string | undefined): number | undefined => {\n if (value === undefined || value === \"\") return undefined;\n\n const parsed = Number(value);\n\n return Number.isFinite(parsed) ? parsed : undefined;\n };\n\n const checkFilter = (query: GrimoirePanelRequest[\"query\"]): GrimoireCheckFilter | null => {\n const filter: GrimoireCheckFilter = {};\n const code = one(query, \"code\");\n const feature = one(query, \"feature\");\n const flow = one(query, \"flow\");\n const severity = one(query, \"severity\");\n const state = one(query, \"state\");\n const offset = number(one(query, \"offset\"));\n const limit = number(one(query, \"limit\"));\n let any = false;\n\n if (code) {\n filter.code = code;\n any = true;\n }\n if (feature) {\n filter.feature = feature;\n any = true;\n }\n if (flow) {\n filter.flow = flow;\n any = true;\n }\n if (severity === \"error\" || severity === \"warning\") {\n filter.severity = severity;\n any = true;\n }\n if (state === \"expected\" || state === \"unexpected\") {\n filter.state = state;\n any = true;\n }\n if (offset !== undefined) {\n filter.offset = offset;\n any = true;\n }\n if (limit !== undefined) {\n filter.limit = limit;\n any = true;\n }\n\n return any ? filter : null;\n };\n\n return {\n id: \"grimoire\",\n title: \"Grimoire\",\n production: true,\n view: new URL(\"../../ui/grimoire-view.js\", import.meta.url),\n assets: {\n \"grimoire.css\": new URL(\"../../ui/grimoire.css\", import.meta.url),\n \"product-map.js\": new URL(\"../../ui/product-map.js\", import.meta.url),\n \"product-map.css\": new URL(\"../../ui/product-map.css\", import.meta.url),\n },\n files: { dir: path.join(context.root, \"grimoire\", \"screenshots\") },\n share: {\n view: new URL(\"../../ui/product-map.js\", import.meta.url),\n routes: [\"/product\", \"/product/features/:feature\", \"/product/flows/:feature/:flow\"],\n assets: [\"product-map.css\"],\n files: true,\n },\n routes: [\n { path: \"/summary\", handler: answer((snapshot) => data.summary(snapshot)) },\n {\n path: \"/search\",\n handler: answer((snapshot, { query }) => {\n const limit = Number(one(query, \"limit\"));\n\n return data.search(\n snapshot,\n one(query, \"q\") ?? \"\",\n Number.isFinite(limit) && limit > 0 ? limit : undefined,\n );\n }),\n },\n {\n path: \"/file\",\n handler: answer((snapshot, { query }) => data.file(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/impact\",\n handler: answer((snapshot, { query }) => data.impact(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/route\",\n handler: answer((snapshot, { query }) =>\n data.route(snapshot, one(query, \"method\"), one(query, \"path\")),\n ),\n },\n { path: \"/features\", handler: answer((snapshot) => data.features(snapshot)) },\n {\n path: \"/features/:feature\",\n handler: answer((snapshot, { params }) => data.feature(snapshot, params.feature)),\n },\n {\n path: \"/flows/:feature/:flow\",\n handler: answer((snapshot, { params }) =>\n data.flowAnswer(snapshot, params.feature, params.flow),\n ),\n },\n {\n path: \"/flows/:feature/:flow/steps/:index/files\",\n handler: answer((snapshot, { params, query }) =>\n data.stepFiles(snapshot, params.feature, params.flow, params.index, {\n set: one(query, \"set\"),\n offset: one(query, \"offset\"),\n limit: one(query, \"limit\"),\n }),\n ),\n },\n {\n path: \"/product\",\n handler: product((snapshot, _request, options) => productMap(snapshot, options)),\n },\n {\n path: \"/product/features/:feature\",\n handler: product((snapshot, { params }, options) =>\n productFeature(snapshot, params.feature, options),\n ),\n },\n {\n path: \"/product/flows/:feature/:flow\",\n handler: product((snapshot, { params }, options) =>\n productFlow(snapshot, params.feature, params.flow, options),\n ),\n },\n { path: \"/apps\", handler: answer((snapshot) => data.apps(snapshot)) },\n {\n path: \"/apps/:app/pages/:page\",\n handler: answer((snapshot, { params }) => data.page(snapshot, params.app, params.page)),\n },\n { path: \"/tasks\", handler: answer((snapshot) => data.tasks(snapshot)) },\n { path: \"/releases\", handler: answer((snapshot) => data.releases(snapshot)) },\n {\n path: \"/releases/:release\",\n handler: answer((snapshot, { params }) => data.release(snapshot, params.release)),\n },\n {\n path: \"/check\",\n handler: answer((snapshot, { query }) => {\n const filter = checkFilter(query);\n\n return filter === null ? data.check(snapshot) : data.checkPage(snapshot, filter);\n }),\n },\n { path: \"/check/groups\", handler: answer((snapshot) => data.checkGroups(snapshot)) },\n {\n path: \"/graph/file\",\n handler: answer((snapshot, { query }) => data.graphOfFile(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/graph/feature/:feature\",\n handler: answer((snapshot, { params }) => data.graphOfFeature(snapshot, params.feature)),\n },\n {\n path: \"/graph/page\",\n handler: answer((snapshot, { query }) =>\n data.graphOfPage(snapshot, one(query, \"app\"), one(query, \"page\")),\n ),\n },\n { path: \"/graph/modules\", handler: answer((snapshot) => data.graphOfModules(snapshot)) },\n ],\n };\n}\n\nexport default grimoireDevtoolsPanel;\n"],"mappings":";;;;;;;;AA0FA,SAAS,IAAI,OAAsC,MAAkC;CACnF,MAAM,QAAQ,MAAM;CAEpB,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAM;AAC5C;;AAGA,eAAsB,sBACpB,SACgC;CAIhC,MAAM,SAAS,qBAAqB,QAAQ,MAAM;EAChD,OAAO,QAAQ,SAAS;EACxB,MAAM,QAAQ,QAAQ;EAItB,GAAI,QAAQ,YAAY,SAAY,CAAC,IAAI,EAAE,SAAS,QAAQ,QAAQ;EACpE,GAAI,QAAQ,UAAU,SAAY,CAAC,IAAI,EAAE,OAAO,QAAQ,MAAM;EAC9D,GAAI,QAAQ,oBAAoB,SAAY,CAAC,IAAI,EAAE,iBAAiB,QAAQ,gBAAgB;CAC9F,CAAC;CAGD,IAAI,QAAQ,SAAS,cAAc,OAAO,KAAK;CAE/C,MAAM,UACK,SACT,OAAO,YACL,KAAK,MAAM,OAAO,IAAI,GAAG,OAAO;;CAGpC,MAA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M;IACN,SAAS,QAAQ,UAAU,EAAE,YAAYC,YAAiB,UAAU,IAAI,OAAO,MAAM,CAAC,CAAC;GACzF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,aAAaC,eAAoB,UAAU,OAAO,OAAO,CAAC;GACzF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,YAC3BC,YAAiB,UAAU,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,MAAM,CAAC,CAClE;GACF;GACA;IAAE,MAAM;IAAkB,SAAS,QAAQ,aAAaC,eAAoB,QAAQ,CAAC;GAAE;EACzF;CACF;AACF"}
1
+ {"version":3,"file":"index.mjs","names":["data.summary","data.search","data.file","data.impact","data.route","data.features","data.feature","data.flowAnswer","data.stepFiles","data.apps","data.page","data.tasks","data.releases","data.release","data.check","data.checkPage","data.checkGroups","data.graphOfFile","data.graphOfFeature","data.graphOfPage","data.graphOfModules"],"sources":["../../../../../../../../packages/grimoire/src/devtools/index.ts"],"sourcesContent":["/**\n * `@warlock.js/grimoire/devtools`: the Grimoire tab of the devtools\n * dashboard. An app enables it in `src/config/devtools.ts`:\n *\n * ```ts\n * panels: [\"@warlock.js/grimoire/devtools\"]\n * ```\n *\n * The default export is a panel factory (devtools' `DevtoolsPanelExport`),\n * typed structurally here so this entry needs no `@warlock.js/devtools`\n * import. The browser view lives in the package's `ui/` folder. Data routes\n * open the snapshot with `routes: \"cached\"` (never booting the app) and keep\n * the generated book up to date; agent-written files are only read.\n */\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport path from \"node:path\";\nimport type { GrimoireCheckFilter } from \"./answers\";\nimport * as data from \"./data\";\nimport { productFeature, productFlow, productMap, type ProductErrorSummary } from \"./product-map\";\nimport { createSnapshotSource } from \"./snapshot-source\";\n\nexport { buildProductSiteData, exportGrimoireSite, exportGrimoireSiteDetailed } from \"./site\";\nexport type { ExportGrimoireSiteOptions, GrimoireSiteExport } from \"./site\";\n\n/** The parts of devtools' `DevtoolsPanelRequest` the routes read. */\nexport type GrimoirePanelRequest = {\n params: Readonly<Record<string, string>>;\n query: Readonly<Record<string, string | readonly string[]>>;\n body: unknown;\n /** `true` when the request came through a read-only share link. */\n shared?: boolean;\n};\n\n/** Devtools' `DevtoolsPanelShare`, structurally: what a share link may show. */\nexport type GrimoireDevtoolsPanelShare = {\n view: string | URL;\n routes: readonly string[];\n assets?: readonly string[];\n files?: boolean;\n};\n\n/** Devtools' `DevtoolsPanel`, structurally. */\nexport type GrimoireDevtoolsPanel = {\n id: string;\n title: string;\n view: string | URL;\n routes?: readonly {\n method?: \"GET\" | \"POST\";\n path: string;\n handler: (request: GrimoirePanelRequest) => unknown;\n }[];\n assets?: Readonly<Record<string, string | URL>>;\n /** A folder of images served next to the panel. */\n files?: { dir: string; extensions?: readonly string[] };\n /** What a read-only share link may show. */\n share?: GrimoireDevtoolsPanelShare;\n /** Safe for the production monitor: the tab only reads (see `GrimoirePanelContext.mode`). */\n production?: boolean;\n};\n\n/** What the panel factory takes: devtools passes `{ root, mode }`; the rest is for tests and custom setups. */\nexport type GrimoirePanelContext = {\n /** The app root. */\n root: string;\n /**\n * Where the dashboard runs. In `\"production\"` the tab writes no files:\n * it reads the book as it is on disk. Default: development.\n */\n mode?: \"development\" | \"production\";\n /** The adapter to open the book with. Default: the Warlock adapter, loaded on first request. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /**\n * How long an opened snapshot is reused when the book did not change (ms).\n * Default in development: 2000, longer after a slow open; the old snapshot is served while a\n * background open refreshes it. Default in production: until the book changes.\n */\n ttlMs?: number;\n /**\n * Where the test results are read from (project-relative or absolute).\n * Default `grimoire/book/test-results.json`. Set it when the deploy ships\n * the results from CI; the Vitest reporter writes there with\n * `grimoireReporter({ file })`.\n */\n testResultsFile?: string;\n /** Captured error groups of the monitor (counts only), for the product map's health. Devtools passes it. */\n errors?: () => Promise<readonly ProductErrorSummary[]>;\n};\n\n/** The first value of a query parameter. */\nfunction one(query: GrimoirePanelRequest[\"query\"], name: string): string | undefined {\n const value = query[name];\n\n return Array.isArray(value) ? value[0] : (value as string | undefined);\n}\n\n/** Build the panel for the app at `root`. */\nexport async function grimoireDevtoolsPanel(\n context: GrimoirePanelContext,\n): Promise<GrimoireDevtoolsPanel> {\n // In development the tab keeps Warlock's generated files (book, book maps, indexes) up to date, so\n // the next open is incremental. In production it writes nothing. Agent-written files are only read,\n // and cached routes never boot the app.\n const development = context.mode !== \"production\";\n let live: Promise<BookAdapter> | undefined;\n const liveAdapter = (): Promise<BookAdapter> =>\n (live ??= import(\"../warlock\").then(({ createWarlockAdapter }) =>\n createWarlockAdapter({ live: true }),\n ));\n const source = createSnapshotSource(context.root, {\n write: context.mode !== \"production\",\n mode: context.mode ?? \"development\",\n // The panel runs inside the app's own process, so it never boots the app again (that would start every\n // connector twice and register the route and event modules twice). In development the default adapter\n // reads the route, event and job facts from the live registries; a custom adapter is used as given.\n ...(context.adapter === undefined\n ? development\n ? { adapter: liveAdapter, liveFacts: true }\n : {}\n : { adapter: context.adapter }),\n ...(context.ttlMs === undefined ? {} : { ttlMs: context.ttlMs }),\n ...(context.testResultsFile === undefined ? {} : { testResultsFile: context.testResultsFile }),\n });\n\n // Start opening the book now so the first tab view is fast. In development this runs in the background\n // (never awaited, failures ignored) and only with the default adapter, so a custom one is not called early.\n if (!development || context.adapter === undefined) source.warm();\n\n const answer =\n <Answer>(read: (snapshot: GrimoireSnapshot, request: GrimoirePanelRequest) => Answer) =>\n async (request: GrimoirePanelRequest): Promise<Answer> =>\n read(await source.get(), request);\n\n /** The product map answers: the shared flag from the request, the errors fetched per request. */\n const product =\n <Answer>(\n read: (\n snapshot: GrimoireSnapshot,\n request: GrimoirePanelRequest,\n options: { shared: boolean; errors: readonly ProductErrorSummary[] | null },\n ) => Answer,\n ) =>\n async (request: GrimoirePanelRequest): Promise<Answer> => {\n const snapshot = await source.get();\n let errors: readonly ProductErrorSummary[] | null = null;\n\n try {\n errors = (await context.errors?.()) ?? null;\n } catch {\n errors = null;\n }\n\n return read(snapshot, request, { shared: request.shared === true, errors });\n };\n\n const number = (value: string | undefined): number | undefined => {\n if (value === undefined || value === \"\") return undefined;\n\n const parsed = Number(value);\n\n return Number.isFinite(parsed) ? parsed : undefined;\n };\n\n const checkFilter = (query: GrimoirePanelRequest[\"query\"]): GrimoireCheckFilter | null => {\n const filter: GrimoireCheckFilter = {};\n const code = one(query, \"code\");\n const feature = one(query, \"feature\");\n const flow = one(query, \"flow\");\n const severity = one(query, \"severity\");\n const state = one(query, \"state\");\n const offset = number(one(query, \"offset\"));\n const limit = number(one(query, \"limit\"));\n let any = false;\n\n if (code) {\n filter.code = code;\n any = true;\n }\n if (feature) {\n filter.feature = feature;\n any = true;\n }\n if (flow) {\n filter.flow = flow;\n any = true;\n }\n if (severity === \"error\" || severity === \"warning\") {\n filter.severity = severity;\n any = true;\n }\n if (state === \"expected\" || state === \"unexpected\") {\n filter.state = state;\n any = true;\n }\n if (offset !== undefined) {\n filter.offset = offset;\n any = true;\n }\n if (limit !== undefined) {\n filter.limit = limit;\n any = true;\n }\n\n return any ? filter : null;\n };\n\n return {\n id: \"grimoire\",\n title: \"Grimoire\",\n production: true,\n view: new URL(\"../../ui/grimoire-view.js\", import.meta.url),\n assets: {\n \"grimoire.css\": new URL(\"../../ui/grimoire.css\", import.meta.url),\n \"product-map.js\": new URL(\"../../ui/product-map.js\", import.meta.url),\n \"product-map.css\": new URL(\"../../ui/product-map.css\", import.meta.url),\n },\n files: { dir: path.join(context.root, \"grimoire\", \"screenshots\") },\n share: {\n view: new URL(\"../../ui/product-map.js\", import.meta.url),\n routes: [\"/product\", \"/product/features/:feature\", \"/product/flows/:feature/:flow\"],\n assets: [\"product-map.css\"],\n files: true,\n },\n routes: [\n { path: \"/summary\", handler: answer((snapshot) => data.summary(snapshot)) },\n {\n path: \"/search\",\n handler: answer((snapshot, { query }) => {\n const limit = Number(one(query, \"limit\"));\n\n return data.search(\n snapshot,\n one(query, \"q\") ?? \"\",\n Number.isFinite(limit) && limit > 0 ? limit : undefined,\n );\n }),\n },\n {\n path: \"/file\",\n handler: answer((snapshot, { query }) => data.file(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/impact\",\n handler: answer((snapshot, { query }) => data.impact(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/route\",\n handler: answer((snapshot, { query }) =>\n data.route(snapshot, one(query, \"method\"), one(query, \"path\")),\n ),\n },\n { path: \"/features\", handler: answer((snapshot) => data.features(snapshot)) },\n {\n path: \"/features/:feature\",\n handler: answer((snapshot, { params }) => data.feature(snapshot, params.feature)),\n },\n {\n path: \"/flows/:feature/:flow\",\n handler: answer((snapshot, { params }) =>\n data.flowAnswer(snapshot, params.feature, params.flow),\n ),\n },\n {\n path: \"/flows/:feature/:flow/steps/:index/files\",\n handler: answer((snapshot, { params, query }) =>\n data.stepFiles(snapshot, params.feature, params.flow, params.index, {\n set: one(query, \"set\"),\n offset: one(query, \"offset\"),\n limit: one(query, \"limit\"),\n }),\n ),\n },\n {\n path: \"/product\",\n handler: product((snapshot, _request, options) => productMap(snapshot, options)),\n },\n {\n path: \"/product/features/:feature\",\n handler: product((snapshot, { params }, options) =>\n productFeature(snapshot, params.feature, options),\n ),\n },\n {\n path: \"/product/flows/:feature/:flow\",\n handler: product((snapshot, { params }, options) =>\n productFlow(snapshot, params.feature, params.flow, options),\n ),\n },\n { path: \"/apps\", handler: answer((snapshot) => data.apps(snapshot)) },\n {\n path: \"/apps/:app/pages/:page\",\n handler: answer((snapshot, { params }) => data.page(snapshot, params.app, params.page)),\n },\n { path: \"/tasks\", handler: answer((snapshot) => data.tasks(snapshot)) },\n { path: \"/releases\", handler: answer((snapshot) => data.releases(snapshot)) },\n {\n path: \"/releases/:release\",\n handler: answer((snapshot, { params }) => data.release(snapshot, params.release)),\n },\n {\n path: \"/check\",\n handler: answer((snapshot, { query }) => {\n const filter = checkFilter(query);\n\n return filter === null ? data.check(snapshot) : data.checkPage(snapshot, filter);\n }),\n },\n { path: \"/check/groups\", handler: answer((snapshot) => data.checkGroups(snapshot)) },\n {\n path: \"/graph/file\",\n handler: answer((snapshot, { query }) => data.graphOfFile(snapshot, one(query, \"path\"))),\n },\n {\n path: \"/graph/feature/:feature\",\n handler: answer((snapshot, { params }) => data.graphOfFeature(snapshot, params.feature)),\n },\n {\n path: \"/graph/page\",\n handler: answer((snapshot, { query }) =>\n data.graphOfPage(snapshot, one(query, \"app\"), one(query, \"page\")),\n ),\n },\n { path: \"/graph/modules\", handler: answer((snapshot) => data.graphOfModules(snapshot)) },\n ],\n };\n}\n\nexport default grimoireDevtoolsPanel;\n"],"mappings":";;;;;;;;AA0FA,SAAS,IAAI,OAAsC,MAAkC;CACnF,MAAM,QAAQ,MAAM;CAEpB,OAAO,MAAM,QAAQ,KAAK,IAAI,MAAM,KAAM;AAC5C;;AAGA,eAAsB,sBACpB,SACgC;CAIhC,MAAM,cAAc,QAAQ,SAAS;CACrC,IAAI;CACJ,MAAM,oBACH,SAAS,OAAO,uBAAa,CAAC,MAAM,EAAE,2BACrC,qBAAqB,EAAE,MAAM,KAAK,CAAC,CACrC;CACF,MAAM,SAAS,qBAAqB,QAAQ,MAAM;EAChD,OAAO,QAAQ,SAAS;EACxB,MAAM,QAAQ,QAAQ;EAItB,GAAI,QAAQ,YAAY,SACpB,cACE;GAAE,SAAS;GAAa,WAAW;EAAK,IACxC,CAAC,IACH,EAAE,SAAS,QAAQ,QAAQ;EAC/B,GAAI,QAAQ,UAAU,SAAY,CAAC,IAAI,EAAE,OAAO,QAAQ,MAAM;EAC9D,GAAI,QAAQ,oBAAoB,SAAY,CAAC,IAAI,EAAE,iBAAiB,QAAQ,gBAAgB;CAC9F,CAAC;CAID,IAAI,CAAC,eAAe,QAAQ,YAAY,QAAW,OAAO,KAAK;CAE/D,MAAM,UACK,SACT,OAAO,YACL,KAAK,MAAM,OAAO,IAAI,GAAG,OAAO;;CAGpC,MAAM,WAEF,SAMF,OAAO,YAAmD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EAAE,YAAYC,YAAiB,UAAU,IAAI,OAAO,MAAM,CAAC,CAAC;GACzF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,aAAaC,eAAoB,UAAU,OAAO,OAAO,CAAC;GACzF;GACA;IACE,MAAM;IACN,SAAS,QAAQ,UAAU,EAAE,YAC3BC,YAAiB,UAAU,IAAI,OAAO,KAAK,GAAG,IAAI,OAAO,MAAM,CAAC,CAClE;GACF;GACA;IAAE,MAAM;IAAkB,SAAS,QAAQ,aAAaC,eAAoB,QAAQ,CAAC;GAAE;EACzF;CACF;AACF"}
@@ -62,7 +62,9 @@ async function loadAdapter(option) {
62
62
  function createSnapshotSource(root, options = {}) {
63
63
  let cached = null;
64
64
  let opening = null;
65
+ const live = options.liveFacts === true && options.mode !== "production";
65
66
  let collected = options.collectRoutes !== true || options.mode === "production";
67
+ let liveCollected = !live;
66
68
  const resultsFile = resolveResultsFile(root, options.testResultsFile);
67
69
  const keepUntilChanged = options.mode === "production" && options.ttlMs === void 0;
68
70
  const reuseFor = (took) => options.ttlMs ?? Math.max(2e3, took * 5);
@@ -73,7 +75,21 @@ function createSnapshotSource(root, options = {}) {
73
75
  write: options.write ?? false,
74
76
  ...options.testResultsFile === void 0 ? {} : { testResultsFile: options.testResultsFile }
75
77
  };
76
- let snapshot = await openGrimoire(root, adapter, {
78
+ let snapshot;
79
+ if (!liveCollected) {
80
+ liveCollected = true;
81
+ try {
82
+ snapshot = await openGrimoire(root, adapter, {
83
+ routes: "fresh",
84
+ ...openOptions
85
+ });
86
+ } catch {
87
+ snapshot = await openGrimoire(root, adapter, {
88
+ routes: "cached",
89
+ ...openOptions
90
+ });
91
+ }
92
+ } else snapshot = await openGrimoire(root, adapter, {
77
93
  routes: "cached",
78
94
  ...openOptions
79
95
  });
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot-source.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/snapshot-source.ts"],"sourcesContent":["/**\n * Where the panel's routes get the snapshot: opened once with\n * `routes: \"cached\"` (a devtools request never boots the app) and kept in\n * memory. Concurrent requests share one open. A change stamp (the book\n * manifest plus the agent-written folders and indexes, a few `stat` calls and\n * no directory walk) tells when the book changed.\n *\n * - Production (`mode: \"production\"`): a snapshot is reused until the stamp\n * changes, with no time limit, unless `ttlMs` is set. A request that finds\n * the stamp changed waits for the new open. `warm()` opens the book ahead\n * of the first request.\n * - Development: the snapshot is reused for a short window (2 s, or five times\n * the last open when that is longer, so a slow open on a large app is not\n * repeated on every view; written files change while an agent works). A\n * request that finds the stamp changed waits for the new open. After the\n * window, with the stamp unchanged (a file edited in place), the cached\n * snapshot is served at once and one background open refreshes it (stale\n * while revalidate).\n *\n * An open that fails keeps serving the old snapshot; its error surfaces on a\n * request only when there is no snapshot at all. The panel passes\n * `write: true` in development, so the generated book stays current and the\n * next open is incremental; with `write: false` a stored book behind the\n * sources is rebuilt in memory on every open.\n */\nimport { stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport { GRIMOIRE_PATHS } from \"../paths\";\nimport { resolveResultsFile } from \"../test-results\";\nimport { openGrimoire } from \"../workspace\";\n\n/** Options of the panel's snapshot source. */\nexport type SnapshotSourceOptions = {\n /** The adapter, or a function that loads it. Default: the Warlock adapter, imported on first use. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /**\n * How long a snapshot is reused when the book did not change (ms).\n * Default in development: 2000, or five times as long as the last open took\n * when that is longer. Default in production: no limit (reused until the\n * book changes).\n */\n ttlMs?: number;\n /** Where the source runs. `\"production\"` keeps a snapshot until the book changes. Default: `\"development\"`. */\n mode?: \"development\" | \"production\";\n /** Let `openGrimoire` write the generated book and collected files (never agent-written files). Default `false`; the devtools panel passes `true`. */\n write?: boolean;\n /**\n * Where the test results are read from (project-relative or absolute).\n * Default `grimoire/book/test-results.json`. The file's modified time is part\n * of the change stamp, so results written after the snapshot opened show up\n * without a restart.\n */\n testResultsFile?: string;\n /**\n * Read the route facts once when the first open finds none (`routes: \"missing\"`), so the development tab is\n * never \"missing\" without a manual `warlock grimoire build`. The adapter's booted inspect runs at most once per\n * process; a boot that fails keeps the cached answer. Default `false`. Never set it in a process that serves the app: the boot\n * pass boots every connector and re-imports the route and event modules, which registers them twice. The devtools panel\n * does not set it; use it from a separate tool process.\n */\n collectRoutes?: boolean;\n};\n\n/** A cached, shared snapshot of one project. */\nexport type SnapshotSource = {\n get(): Promise<GrimoireSnapshot>;\n /** Forget the cached snapshot; the next `get()` opens again. */\n invalidate(): void;\n /** Start opening the book now, so the first `get()` is fast. Failures are ignored here and surface on `get()`. */\n warm(): void;\n /** Resolves when no open is running (specs and shutdown). Never rejects. */\n idle(): Promise<void>;\n};\n\n/** Files and folders whose modified time moves when the book or an agent-written file is added, removed or regenerated. */\nconst STAMPED = [\n GRIMOIRE_PATHS.bookManifest,\n GRIMOIRE_PATHS.featuresIndex,\n GRIMOIRE_PATHS.tasksIndex,\n GRIMOIRE_PATHS.features,\n GRIMOIRE_PATHS.apps,\n GRIMOIRE_PATHS.openTasks,\n GRIMOIRE_PATHS.doneTasks,\n GRIMOIRE_PATHS.releases,\n];\n\nasync function changeStamp(root: string, resultsFile: string): Promise<string> {\n const files = [...STAMPED.map((entry) => path.join(root, ...entry.split(\"/\"))), resultsFile];\n const times = await Promise.all(\n files.map(async (file) => {\n try {\n return (await stat(file)).mtimeMs;\n } catch {\n return 0;\n }\n }),\n );\n\n return times.join(\",\");\n}\n\nasync function loadAdapter(option: SnapshotSourceOptions[\"adapter\"]): Promise<BookAdapter> {\n if (option === undefined) {\n const { createWarlockAdapter } = await import(\"../warlock\");\n\n return createWarlockAdapter();\n }\n\n return typeof option === \"function\" ? option() : option;\n}\n\n/** Create the source for the project at `root`. */\nexport function createSnapshotSource(\n root: string,\n options: SnapshotSourceOptions = {},\n): SnapshotSource {\n let cached: { snapshot: GrimoireSnapshot; at: number; stamp: string; took: number } | null = null;\n let opening: Promise<GrimoireSnapshot> | null = null;\n\n let collected = options.collectRoutes !== true || options.mode === \"production\";\n const resultsFile = resolveResultsFile(root, options.testResultsFile);\n\n const keepUntilChanged = options.mode === \"production\" && options.ttlMs === undefined;\n const reuseFor = (took: number): number => options.ttlMs ?? Math.max(2000, took * 5);\n\n async function open(): Promise<GrimoireSnapshot> {\n const started = Date.now();\n const adapter = await loadAdapter(options.adapter);\n const openOptions = {\n write: options.write ?? false,\n ...(options.testResultsFile === undefined\n ? {}\n : { testResultsFile: options.testResultsFile }),\n };\n let snapshot = await openGrimoire(root, adapter, { routes: \"cached\", ...openOptions });\n\n if (!collected && snapshot.routes === \"missing\") {\n // Once per source: the route, event and job facts come from one boot pass, then live in the book.\n collected = true;\n\n try {\n snapshot = await openGrimoire(root, adapter, { routes: \"fresh\", ...openOptions });\n } catch {\n // The app did not boot (GR8002): keep the cached answer; the tab says the facts are missing.\n }\n }\n\n const at = Date.now();\n\n cached = { snapshot, at, stamp: await changeStamp(root, resultsFile), took: at - started };\n\n return snapshot;\n }\n\n /** The open in flight, or a new one; concurrent callers share it. */\n function ensureOpening(): Promise<GrimoireSnapshot> {\n opening ??= open().finally(() => {\n opening = null;\n });\n\n return opening;\n }\n\n return {\n async get() {\n if (cached === null) return ensureOpening();\n\n const known = cached;\n const changed = (await changeStamp(root, resultsFile)) !== known.stamp;\n\n if (changed || options.mode === \"production\") {\n if (!changed && (keepUntilChanged || Date.now() - known.at < reuseFor(known.took))) {\n return known.snapshot;\n }\n\n // A failed open keeps the old snapshot; the next request tries again.\n return ensureOpening().catch(() => known.snapshot);\n }\n\n if (Date.now() - known.at < reuseFor(known.took)) return known.snapshot;\n\n // Development, nothing known to have changed: serve the old snapshot now and refresh behind it.\n ensureOpening().catch(() => {});\n\n return known.snapshot;\n },\n invalidate() {\n cached = null;\n },\n warm() {\n if (cached === null) ensureOpening().catch(() => {});\n },\n async idle() {\n await opening?.catch(() => {});\n },\n };\n}\n"],"mappings":";;;;;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;GAAU,GAAG;EAAY,CAAC;EAErF,IAAI,CAAC,aAAa,SAAS,WAAW,WAAW;GAE/C,YAAY;GAEZ,IAAI;IACF,WAAW,MAAM,aAAa,MAAM,SAAS;KAAE,QAAQ;KAAS,GAAG;IAAY,CAAC;GAClF,QAAQ,CAER;EACF;EAEA,MAAM,KAAK,KAAK,IAAI;EAEpB,SAAS;GAAE;GAAU;GAAI,OAAO,MAAM,YAAY,MAAM,WAAW;GAAG,MAAM,KAAK;EAAQ;EAEzF,OAAO;CACT;;CAGA,SAAS,gBAA2C;EAClD,YAAY,KAAK,CAAC,CAAC,cAAc;GAC/B,UAAU;EACZ,CAAC;EAED,OAAO;CACT;CAEA,OAAO;EACL,MAAM,MAAM;GACV,IAAI,WAAW,MAAM,OAAO,cAAc;GAE1C,MAAM,QAAQ;GACd,MAAM,UAAW,MAAM,YAAY,MAAM,WAAW,MAAO,MAAM;GAEjE,IAAI,WAAW,QAAQ,SAAS,cAAc;IAC5C,IAAI,CAAC,YAAY,oBAAoB,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,MAAM,IAAI,IAC9E,OAAO,MAAM;IAIf,OAAO,cAAc,CAAC,CAAC,YAAY,MAAM,QAAQ;GACnD;GAEA,IAAI,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,MAAM,IAAI,GAAG,OAAO,MAAM;GAG/D,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC;GAE9B,OAAO,MAAM;EACf;EACA,aAAa;GACX,SAAS;EACX;EACA,OAAO;GACL,IAAI,WAAW,MAAM,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC;EACrD;EACA,MAAM,OAAO;GACX,MAAM,SAAS,YAAY,CAAC,CAAC;EAC/B;CACF;AACF"}
1
+ {"version":3,"file":"snapshot-source.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/devtools/snapshot-source.ts"],"sourcesContent":["/**\n * Where the panel's routes get the snapshot: opened once with\n * `routes: \"cached\"` (a devtools request never boots the app) and kept in\n * memory. Concurrent requests share one open. A change stamp (the book\n * manifest plus the agent-written folders and indexes, a few `stat` calls and\n * no directory walk) tells when the book changed.\n *\n * - Production (`mode: \"production\"`): a snapshot is reused until the stamp\n * changes, with no time limit, unless `ttlMs` is set. A request that finds\n * the stamp changed waits for the new open. `warm()` opens the book ahead\n * of the first request.\n * - Development: the snapshot is reused for a short window (2 s, or five times\n * the last open when that is longer, so a slow open on a large app is not\n * repeated on every view; written files change while an agent works). A\n * request that finds the stamp changed waits for the new open. After the\n * window, with the stamp unchanged (a file edited in place), the cached\n * snapshot is served at once and one background open refreshes it (stale\n * while revalidate).\n *\n * An open that fails keeps serving the old snapshot; its error surfaces on a\n * request only when there is no snapshot at all. The panel passes\n * `write: true` in development, so the generated book stays current and the\n * next open is incremental; with `write: false` a stored book behind the\n * sources is rebuilt in memory on every open.\n */\nimport { stat } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { BookAdapter } from \"../contracts/adapter\";\nimport type { GrimoireSnapshot } from \"../contracts/snapshot\";\nimport { GRIMOIRE_PATHS } from \"../paths\";\nimport { resolveResultsFile } from \"../test-results\";\nimport { openGrimoire } from \"../workspace\";\n\n/** Options of the panel's snapshot source. */\nexport type SnapshotSourceOptions = {\n /** The adapter, or a function that loads it. Default: the Warlock adapter, imported on first use. */\n adapter?: BookAdapter | (() => Promise<BookAdapter>);\n /**\n * How long a snapshot is reused when the book did not change (ms).\n * Default in development: 2000, or five times as long as the last open took\n * when that is longer. Default in production: no limit (reused until the\n * book changes).\n */\n ttlMs?: number;\n /** Where the source runs. `\"production\"` keeps a snapshot until the book changes. Default: `\"development\"`. */\n mode?: \"development\" | \"production\";\n /** Let `openGrimoire` write the generated book and collected files (never agent-written files). Default `false`; the devtools panel passes `true`. */\n write?: boolean;\n /**\n * Where the test results are read from (project-relative or absolute).\n * Default `grimoire/book/test-results.json`. The file's modified time is part\n * of the change stamp, so results written after the snapshot opened show up\n * without a restart.\n */\n testResultsFile?: string;\n /**\n * Read the route facts once when the first open finds none (`routes: \"missing\"`), so the development tab is\n * never \"missing\" without a manual `warlock grimoire build`. The adapter's booted inspect runs at most once per\n * process; a boot that fails keeps the cached answer. Default `false`. Never set it in a process that serves the app: the boot\n * pass boots every connector and re-imports the route and event modules, which registers them twice. The devtools panel\n * does not set it; use it from a separate tool process.\n */\n collectRoutes?: boolean;\n /**\n * The adapter reads the route, event and job facts from the running process (`createWarlockAdapter({ live: true })`),\n * which is cheap and boots nothing. The first open then collects them in the same pass as the book\n * (`routes: \"fresh\"`), so the tab never opens \"missing\" and the first open runs once. Safe in the process that\n * serves the app. Default `false`; the devtools panel sets it in development with the Warlock adapter.\n */\n liveFacts?: boolean;\n};\n\n/** A cached, shared snapshot of one project. */\nexport type SnapshotSource = {\n get(): Promise<GrimoireSnapshot>;\n /** Forget the cached snapshot; the next `get()` opens again. */\n invalidate(): void;\n /** Start opening the book now, so the first `get()` is fast. Failures are ignored here and surface on `get()`. */\n warm(): void;\n /** Resolves when no open is running (specs and shutdown). Never rejects. */\n idle(): Promise<void>;\n};\n\n/** Files and folders whose modified time moves when the book or an agent-written file is added, removed or regenerated. */\nconst STAMPED = [\n GRIMOIRE_PATHS.bookManifest,\n GRIMOIRE_PATHS.featuresIndex,\n GRIMOIRE_PATHS.tasksIndex,\n GRIMOIRE_PATHS.features,\n GRIMOIRE_PATHS.apps,\n GRIMOIRE_PATHS.openTasks,\n GRIMOIRE_PATHS.doneTasks,\n GRIMOIRE_PATHS.releases,\n];\n\nasync function changeStamp(root: string, resultsFile: string): Promise<string> {\n const files = [...STAMPED.map((entry) => path.join(root, ...entry.split(\"/\"))), resultsFile];\n const times = await Promise.all(\n files.map(async (file) => {\n try {\n return (await stat(file)).mtimeMs;\n } catch {\n return 0;\n }\n }),\n );\n\n return times.join(\",\");\n}\n\nasync function loadAdapter(option: SnapshotSourceOptions[\"adapter\"]): Promise<BookAdapter> {\n if (option === undefined) {\n const { createWarlockAdapter } = await import(\"../warlock\");\n\n return createWarlockAdapter();\n }\n\n return typeof option === \"function\" ? option() : option;\n}\n\n/** Create the source for the project at `root`. */\nexport function createSnapshotSource(\n root: string,\n options: SnapshotSourceOptions = {},\n): SnapshotSource {\n let cached: { snapshot: GrimoireSnapshot; at: number; stamp: string; took: number } | null = null;\n let opening: Promise<GrimoireSnapshot> | null = null;\n\n const live = options.liveFacts === true && options.mode !== \"production\";\n let collected = options.collectRoutes !== true || options.mode === \"production\";\n let liveCollected = !live;\n const resultsFile = resolveResultsFile(root, options.testResultsFile);\n\n const keepUntilChanged = options.mode === \"production\" && options.ttlMs === undefined;\n const reuseFor = (took: number): number => options.ttlMs ?? Math.max(2000, took * 5);\n\n async function open(): Promise<GrimoireSnapshot> {\n const started = Date.now();\n const adapter = await loadAdapter(options.adapter);\n const openOptions = {\n write: options.write ?? false,\n ...(options.testResultsFile === undefined\n ? {}\n : { testResultsFile: options.testResultsFile }),\n };\n let snapshot: GrimoireSnapshot;\n\n if (!liveCollected) {\n // One pass: the book and the live route facts together, so a first open never builds twice.\n liveCollected = true;\n\n try {\n snapshot = await openGrimoire(root, adapter, { routes: \"fresh\", ...openOptions });\n } catch {\n // The facts could not be read: fall back to what the book already holds.\n snapshot = await openGrimoire(root, adapter, { routes: \"cached\", ...openOptions });\n }\n } else {\n snapshot = await openGrimoire(root, adapter, { routes: \"cached\", ...openOptions });\n }\n\n if (!collected && snapshot.routes === \"missing\") {\n // Once per source: the route, event and job facts come from one boot pass, then live in the book.\n collected = true;\n\n try {\n snapshot = await openGrimoire(root, adapter, { routes: \"fresh\", ...openOptions });\n } catch {\n // The app did not boot (GR8002): keep the cached answer; the tab says the facts are missing.\n }\n }\n\n const at = Date.now();\n\n cached = { snapshot, at, stamp: await changeStamp(root, resultsFile), took: at - started };\n\n return snapshot;\n }\n\n /** The open in flight, or a new one; concurrent callers share it. */\n function ensureOpening(): Promise<GrimoireSnapshot> {\n opening ??= open().finally(() => {\n opening = null;\n });\n\n return opening;\n }\n\n return {\n async get() {\n if (cached === null) return ensureOpening();\n\n const known = cached;\n const changed = (await changeStamp(root, resultsFile)) !== known.stamp;\n\n if (changed || options.mode === \"production\") {\n if (!changed && (keepUntilChanged || Date.now() - known.at < reuseFor(known.took))) {\n return known.snapshot;\n }\n\n // A failed open keeps the old snapshot; the next request tries again.\n return ensureOpening().catch(() => known.snapshot);\n }\n\n if (Date.now() - known.at < reuseFor(known.took)) return known.snapshot;\n\n // Development, nothing known to have changed: serve the old snapshot now and refresh behind it.\n ensureOpening().catch(() => {});\n\n return known.snapshot;\n },\n invalidate() {\n cached = null;\n },\n warm() {\n if (cached === null) ensureOpening().catch(() => {});\n },\n async idle() {\n await opening?.catch(() => {});\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoFA,MAAM,UAAU;CACd,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;CACf,eAAe;AACjB;AAEA,eAAe,YAAY,MAAc,aAAsC;CAC7E,MAAM,QAAQ,CAAC,GAAG,QAAQ,KAAK,UAAU,KAAK,KAAK,MAAM,GAAG,MAAM,MAAM,GAAG,CAAC,CAAC,GAAG,WAAW;CAW3F,QAAO,MAVa,QAAQ,IAC1B,MAAM,IAAI,OAAO,SAAS;EACxB,IAAI;GACF,QAAQ,MAAM,KAAK,IAAI,EAAC,CAAE;EAC5B,QAAQ;GACN,OAAO;EACT;CACF,CAAC,CACH,EAEY,CAAC,KAAK,GAAG;AACvB;AAEA,eAAe,YAAY,QAAgE;CACzF,IAAI,WAAW,QAAW;EACxB,MAAM,EAAE,yBAAyB,MAAM,OAAO;EAE9C,OAAO,qBAAqB;CAC9B;CAEA,OAAO,OAAO,WAAW,aAAa,OAAO,IAAI;AACnD;;AAGA,SAAgB,qBACd,MACA,UAAiC,CAAC,GAClB;CAChB,IAAI,SAAyF;CAC7F,IAAI,UAA4C;CAEhD,MAAM,OAAO,QAAQ,cAAc,QAAQ,QAAQ,SAAS;CAC5D,IAAI,YA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,MAAM,QAAQ;GACd,MAAM,UAAW,MAAM,YAAY,MAAM,WAAW,MAAO,MAAM;GAEjE,IAAI,WAAW,QAAQ,SAAS,cAAc;IAC5C,IAAI,CAAC,YAAY,oBAAoB,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,MAAM,IAAI,IAC9E,OAAO,MAAM;IAIf,OAAO,cAAc,CAAC,CAAC,YAAY,MAAM,QAAQ;GACnD;GAEA,IAAI,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,MAAM,IAAI,GAAG,OAAO,MAAM;GAG/D,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC;GAE9B,OAAO,MAAM;EACf;EACA,aAAa;GACX,SAAS;EACX;EACA,OAAO;GACL,IAAI,WAAW,MAAM,cAAc,CAAC,CAAC,YAAY,CAAC,CAAC;EACrD;EACA,MAAM,OAAO;GACX,MAAM,SAAS,YAAY,CAAC,CAAC;EAC/B;CACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { BookAdapter } from "../contracts/adapter.mjs";
2
2
  import { MobileAppOption } from "./mobile-facts.mjs";
3
- import { InspectReport, InspectSection } from "@warlock.js/core/tooling";
3
+ import { InspectOptions, InspectReport, InspectSection } from "@warlock.js/core/tooling";
4
4
  //#region ../../packages/grimoire/src/warlock/adapter.d.ts
5
5
  /**
6
6
  * Reads the sections of the inspect report that need the app booted
@@ -21,7 +21,24 @@ export type WarlockAdapterOptions = {
21
21
  mobile?: readonly MobileAppOption[];
22
22
  /** How the booted sections are read. Default: the `warlock inspect` boot pass, run at most once. Pages never boot. */
23
23
  inspect?: WarlockInspect;
24
+ /**
25
+ * Read the route, event and job facts from the registries of the running process instead of booting the app
26
+ * (`inspect` wins when both are set). For code that runs inside `warlock dev`, such as the devtools panel;
27
+ * nothing is booted and no module is loaded twice. Default `false`.
28
+ */
29
+ live?: boolean;
30
+ };
31
+ /** The slice of `@warlock.js/core/tooling` that {@link liveInspect} reads (a seam for specs). */
32
+ export type LiveInspectTooling = {
33
+ inspectApp: (options: InspectOptions) => Promise<InspectReport>;
34
+ liveInspectOptions: () => InspectOptions;
24
35
  };
36
+ /**
37
+ * The `inspect` for code running inside the app's own process (`warlock dev`): reads the live router and the
38
+ * event listeners recorded since dev start. It never boots a connector and never imports the route or event
39
+ * modules again, so the running app is not touched.
40
+ */
41
+ export declare function liveInspect(load?: () => Promise<LiveInspectTooling>): WarlockInspect;
25
42
  /** The adapter over `inspectApp()`, `collectFiles()` and the mobile app folders. */
26
43
  export declare function createWarlockAdapter(options?: WarlockAdapterOptions): BookAdapter;
27
44
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/warlock/adapter.ts"],"mappings":";;;;;;;;;;YAwCY,kBACV,cACA,mBAAmB,qBAChB,QAAQ;;YAGD;;;;;;;;EAQV,kBAAkB;;EAElB,UAAU;;;wBAqVI,qBAAqB,UAAS,wBAA6B"}
1
+ {"version":3,"file":"adapter.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/warlock/adapter.ts"],"mappings":";;;;;;;;;;YAyCY,kBACV,cACA,mBAAmB,qBAChB,QAAQ;;YAGD;;;;;;;;EAQV,kBAAkB;;EAElB,UAAU;;;;;;EAMV;;;YAuJU;EACV,aAAa,SAAS,mBAAmB,QAAQ;EACjD,0BAA0B;;;;;;;wBAQZ,YACd,aAAY,QAAQ,sBACnB;;wBAuMa,qBAAqB,UAAS,wBAA6B"}
@@ -115,6 +115,21 @@ function bootedInspect() {
115
115
  });
116
116
  };
117
117
  }
118
+ /**
119
+ * The `inspect` for code running inside the app's own process (`warlock dev`): reads the live router and the
120
+ * event listeners recorded since dev start. It never boots a connector and never imports the route or event
121
+ * modules again, so the running app is not touched.
122
+ */
123
+ function liveInspect(load = () => import("@warlock.js/core/tooling")) {
124
+ return async (root, sections) => {
125
+ const tooling = await load();
126
+ return tooling.inspectApp({
127
+ ...tooling.liveInspectOptions(),
128
+ cwd: root,
129
+ sections
130
+ });
131
+ };
132
+ }
118
133
  /** `send-receipt.job.ts` → `send-receipt` (the stem without the role suffix). */
119
134
  function stemOf(file, ...suffixes) {
120
135
  const base = path.posix.basename(file).replace(/\.(?:d\.ts|[cm]?[jt]sx?)$/, "");
@@ -247,7 +262,7 @@ async function mobileSourceFolders(root, app) {
247
262
  }
248
263
  /** The adapter over `inspectApp()`, `collectFiles()` and the mobile app folders. */
249
264
  function createWarlockAdapter(options = {}) {
250
- const inspect = options.inspect ?? bootedInspect();
265
+ const inspect = options.inspect ?? (options.live === true ? liveInspect() : bootedInspect());
251
266
  const mobileOptions = options.mobile === void 0 ? {} : { mobile: options.mobile };
252
267
  let lastFiles = null;
253
268
  let lastPages = null;
@@ -411,5 +426,5 @@ function createWarlockAdapter(options = {}) {
411
426
  }
412
427
 
413
428
  //#endregion
414
- export { appIdentity, bookRole, createWarlockAdapter, installedVersion, warlockHost };
429
+ export { appIdentity, bookRole, createWarlockAdapter, installedVersion, liveInspect, warlockHost };
415
430
  //# sourceMappingURL=adapter.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/warlock/adapter.ts"],"sourcesContent":["/**\n * The Warlock adapter: turns core's inspect report into the book's facts.\n * It never parses app source itself: files come from `collectFiles()`,\n * routes, events and jobs from `inspectApp()` after the `warlock inspect`\n * boot pass, pages from `inspectApp()` (the web page graph, no boot), and\n * mobile apps from their folders.\n *\n * `@warlock.js/core/tooling` is imported inside the methods, never at the\n * top: this module is reached from `warlock.config.ts`.\n */\nimport { readFileSync } from \"node:fs\";\nimport { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n InspectFile,\n InspectReport,\n InspectRoute,\n InspectSection,\n} from \"@warlock.js/core/tooling\";\nimport type {\n BookAdapter,\n BookFile,\n BookHost,\n BookMobileApp,\n BookNamedThing,\n BookPage,\n BookRoute,\n BookSite,\n} from \"../contracts/adapter\";\nimport { isCodeFile, isInsideFolder, toPosixPath } from \"../paths\";\nimport { WARLOCK_LOGO_DATA_URI } from \"./logo\";\nimport { collectMobileFacts, type MobileAppOption } from \"./mobile-facts\";\n\n/**\n * Reads the sections of the inspect report that need the app booted\n * (`routes`, `events`, `jobs`) for the project at `root`. The default boots\n * the app once, the `warlock inspect` way (connectors boot, none starts).\n * `warlock mcp` passes its own, which shares the server's boot.\n */\nexport type WarlockInspect = (\n root: string,\n sections: readonly InspectSection[],\n) => Promise<InspectReport>;\n\n/** Options of `createWarlockAdapter()`. */\nexport type WarlockAdapterOptions = {\n /**\n * Mobile apps in the repository: folder, id and routing. Default: every\n * top-level folder with an `app.json` or an `app.config.*` file; it is\n * file-routed when its `package.json` lists `expo-router` (screens come\n * from the files), and code-navigated otherwise (no screens: the agent\n * declares them in `grimoire/apps/<app>/screens/`).\n */\n mobile?: readonly MobileAppOption[];\n /** How the booted sections are read. Default: the `warlock inspect` boot pass, run at most once. Pages never boot. */\n inspect?: WarlockInspect;\n};\n\n/** The `version` of a `package.json` named `name`, or `null` when the file is not that package's. */\nfunction versionIn(file: string, name: string): string | null {\n try {\n const manifest = JSON.parse(readFileSync(file, \"utf8\")) as {\n name?: unknown;\n version?: unknown;\n };\n\n return manifest.name === name && typeof manifest.version === \"string\" ? manifest.version : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The installed version of a package, read from its `package.json` without\n * going through its `exports` (published `@warlock.js/core` exports neither\n * `./package.json` nor a `require` condition). It resolves the package's\n * entry and walks up to the `package.json` with that name; when the entry\n * cannot be resolved, it looks in each `node_modules` above `from`.\n *\n * @param from Absolute folder to look from.\n * @param resolve Resolves a bare specifier to a file URL or path (`import.meta.resolve`).\n */\nexport function installedVersion(\n name: string,\n from: string,\n resolve: ((specifier: string) => string) | undefined,\n): string | null {\n try {\n const entry = resolve?.(name);\n\n if (entry !== undefined) {\n let folder = path.dirname(entry.startsWith(\"file:\") ? fileURLToPath(entry) : entry);\n\n for (;;) {\n const version = versionIn(path.join(folder, \"package.json\"), name);\n\n if (version !== null) return version;\n\n const parent = path.dirname(folder);\n\n if (parent === folder) break;\n\n folder = parent;\n }\n }\n } catch {\n // Not resolvable from here: look in the node_modules folders below.\n }\n\n for (let folder = from; ; folder = path.dirname(folder)) {\n const version = versionIn(\n path.join(folder, \"node_modules\", ...name.split(\"/\"), \"package.json\"),\n name,\n );\n\n if (version !== null) return version;\n if (path.dirname(folder) === folder) return null;\n }\n}\n\n/** The framework version, for the book manifest (a core upgrade rebuilds the book). */\nfunction coreVersion(): string {\n const resolve =\n typeof import.meta.resolve === \"function\"\n ? (specifier: string) => import.meta.resolve(specifier)\n : undefined;\n\n return (\n installedVersion(\"@warlock.js/core\", path.dirname(fileURLToPath(import.meta.url)), resolve) ??\n \"unknown\"\n );\n}\n\n/** The app's own `name` and `version` from `<root>/package.json`, or `null` when it has no name. */\nexport function appIdentity(root: string): { name: string; version: string | null } | null {\n try {\n const manifest = JSON.parse(readFileSync(path.join(root, \"package.json\"), \"utf8\")) as {\n name?: unknown;\n version?: unknown;\n };\n\n return typeof manifest.name === \"string\" && manifest.name !== \"\"\n ? {\n name: manifest.name,\n version: typeof manifest.version === \"string\" ? manifest.version : null,\n }\n : null;\n } catch {\n return null;\n }\n}\n\n/** The Warlock.js brand (logo and installed version) and the app at `root`, for the view's header and footer. */\nexport function warlockHost(root: string, frameworkVersion: string): BookHost {\n return {\n name: \"Warlock.js\",\n version: frameworkVersion === \"unknown\" ? null : frameworkVersion,\n logo: WARLOCK_LOGO_DATA_URI,\n app: appIdentity(root),\n };\n}\n\n/** Run `work` with `console.log`/`info`/`debug` on stderr, so a boot never mixes with `--json` output. */\nasync function withConsoleOnStderr<T>(work: () => Promise<T>): Promise<T> {\n const { log, info, debug } = console;\n const toStderr = (...args: unknown[]) => console.error(...args);\n\n console.log = toStderr;\n console.info = toStderr;\n console.debug = toStderr;\n\n try {\n return await work();\n } finally {\n console.log = log;\n console.info = info;\n console.debug = debug;\n }\n}\n\n/** The default booted `inspect`: one boot pass, shared by every call. */\nfunction bootedInspect(): WarlockInspect {\n let boot: Promise<unknown> | undefined;\n\n return async (root, sections) => {\n const tooling = await import(\"@warlock.js/core/tooling\");\n\n boot ??= withConsoleOnStderr(() => tooling.bootForInspect(root));\n\n const booted = (await boot) as Awaited<ReturnType<typeof tooling.bootForInspect>>;\n\n if (!booted.context.booted) {\n const failures = booted.context.moduleFailures.map(\n (failure) => `${failure.file}: ${failure.message}`,\n );\n\n throw new Error(\n `the app did not boot${failures.length > 0 ? ` (${failures.join(\"; \")})` : \"\"}. Run warlock doctor to see why.`,\n );\n }\n\n return tooling.inspectApp({ ...tooling.inspectOptionsFromBoot(booted), cwd: root, sections });\n };\n}\n\n/** `send-receipt.job.ts` → `send-receipt` (the stem without the role suffix). */\nfunction stemOf(file: string, ...suffixes: string[]): string {\n const base = path.posix.basename(file).replace(/\\.(?:d\\.ts|[cm]?[jt]sx?)$/, \"\");\n\n for (const suffix of suffixes) {\n if (base.endsWith(`.${suffix}`)) return base.slice(0, -suffix.length - 1);\n }\n\n return base;\n}\n\n/**\n * The book's role of a file: the framework's role, with CLI command files\n * (`*.command.ts`, or a file directly in `<module>/commands/`) told apart from\n * plain source.\n */\nexport function bookRole(file: Pick<InspectFile, \"file\" | \"role\">): string {\n if (file.role !== \"source\") return file.role;\n\n const stem = path.posix.basename(file.file).replace(/\\.(?:d\\.ts|[cm]?[jt]sx?)$/, \"\");\n const folders = file.file.split(\"/\").slice(0, -1);\n\n return stem.endsWith(\".command\") || (folders.length === 4 && folders[3] === \"commands\")\n ? \"command\"\n : file.role;\n}\n\nfunction toBookFile(file: InspectFile, mobile: readonly BookMobileApp[]): BookFile {\n const docs = file.exportDocs ?? {};\n const app = mobile.find((item) => isInsideFolder(file.file, item.root));\n\n return {\n file: file.file,\n module: file.module,\n type: bookRole(file),\n lines: file.lines ?? 0,\n about: file.about ?? null,\n tags: file.tags ?? {},\n exports: file.exports.map((name) => ({ name, about: docs[name] ?? null })),\n imports: file.imports.map((entry) =>\n entry.typeOnly === true\n ? { specifier: entry.specifier, file: entry.file, typeOnly: true }\n : { specifier: entry.specifier, file: entry.file },\n ),\n importedBy: [...file.importedBy],\n mobileApp: app?.id ?? null,\n };\n}\n\n/** Files by the names they export, built once per `routes()` call. */\ntype ExportIndex = () => ReadonlyMap<string, readonly string[]>;\n\nfunction exportIndex(files: ReadonlyMap<string, BookFile>): ExportIndex {\n let index: Map<string, string[]> | undefined;\n\n return () => {\n if (index) return index;\n\n index = new Map();\n\n for (const file of files.values()) {\n for (const entry of file.exports) {\n const list = index.get(entry.name) ?? [];\n\n list.push(file.file);\n index.set(entry.name, list);\n }\n }\n\n return index;\n };\n}\n\n/** The file that defines a route's handler: the controller's file for a tuple, else the file exporting the handler. */\nfunction handlerFileOf(\n route: InspectRoute,\n files: ReadonlyMap<string, BookFile>,\n pages: readonly BookPage[],\n exporters: ExportIndex,\n): string | null {\n if (route.isPage) {\n return pages.find((page) => page.route === route.path)?.file ?? null;\n }\n\n const exportsName = (file: string | null | undefined, name: string): boolean =>\n file !== null &&\n file !== undefined &&\n files.get(file)?.exports.some((entry) => entry.name === name) === true;\n const imported =\n route.sourceFile === null\n ? []\n : (files.get(route.sourceFile)?.imports ?? []).map((entry) => entry.file);\n const name = route.controller ?? route.handler;\n\n if (!name || name === \"anonymous\") return null;\n\n const fromImports = imported.find((file) => exportsName(file, name));\n\n if (fromImports) return fromImports;\n if (exportsName(route.sourceFile, name)) return route.sourceFile;\n\n // Not imported by the routes file: the one file in the project exporting it, when there is only one.\n const anywhere = [...new Set(exporters().get(name) ?? [])];\n\n return anywhere.length === 1 ? (anywhere[0] ?? null) : null;\n}\n\nfunction toBookRoute(\n route: InspectRoute,\n files: ReadonlyMap<string, BookFile>,\n pages: readonly BookPage[],\n exporters: ExportIndex,\n): BookRoute {\n const controller = route.controller ?? null;\n const action = route.action ?? null;\n const handler =\n controller !== null && action !== null && !route.handler.includes(\".\")\n ? `${controller}.${action}`\n : route.handler;\n\n return {\n method: route.method.toUpperCase(),\n path: route.path,\n name: route.name,\n sourceFile: route.sourceFile === null ? null : toPosixPath(route.sourceFile),\n handler,\n controller,\n action,\n handlerFile: handlerFileOf(route, files, pages, exporters),\n middleware: [...route.middleware],\n auth: { required: route.auth.required, userTypes: [...route.auth.userTypes] },\n isPage: route.isPage,\n description: route.description,\n };\n}\n\nasync function folderNames(dir: string): Promise<string[]> {\n try {\n return (await readdir(dir, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort();\n } catch {\n return [];\n }\n}\n\n/** The site folders of a multi-site app (`src/web/$sites/<id>`), sorted; empty for a single site. */\nfunction siteFolders(root: string): Promise<string[]> {\n return folderNames(path.join(root, \"src\", \"web\", \"$sites\"));\n}\n\n/** `web.sites` from the loaded config, or `undefined` when `src/config/web.ts` is not loaded. */\nasync function webSitesConfig(): Promise<\n Record<string, { basePath?: unknown } | undefined> | undefined\n> {\n const { config } = await import(\"@warlock.js/core\");\n const sites: unknown = config.key(\"web.sites\");\n\n return typeof sites === \"object\" && sites !== null\n ? (sites as Record<string, { basePath?: unknown }>)\n : undefined;\n}\n\n/**\n * Folders of a mobile app that hold native projects, build output or tool\n * caches, never app source. `node_modules` and dot folders are skipped too.\n */\nconst MOBILE_SKIPPED_FOLDERS = new Set([\n \"android\",\n \"ios\",\n \"build\",\n \"dist\",\n \"web-build\",\n \"coverage\",\n \"node_modules\",\n]);\n\n/**\n * The source folders of a mobile app: its top-level folders minus native\n * projects and build output (`android/`, `ios/` with Pods and builds can hold\n * hundreds of megabytes). Code files directly in the app folder (`App.tsx`)\n * are not read: `collectFiles` scans folders only.\n */\nasync function mobileSourceFolders(root: string, app: BookMobileApp): Promise<string[]> {\n return (await folderNames(path.join(root, ...app.root.split(\"/\"))))\n .filter((name) => !name.startsWith(\".\") && !MOBILE_SKIPPED_FOLDERS.has(name))\n .map((name) => `${app.root}/${name}`);\n}\n\n/** The adapter over `inspectApp()`, `collectFiles()` and the mobile app folders. */\nexport function createWarlockAdapter(options: WarlockAdapterOptions = {}): BookAdapter {\n const inspect = options.inspect ?? bootedInspect();\n const mobileOptions = options.mobile === undefined ? {} : { mobile: options.mobile };\n let lastFiles: { root: string; files: BookFile[] } | null = null;\n let lastPages: { root: string; pages: BookPage[] } | null = null;\n\n const mobileApps = (root: string) => collectMobileFacts(root, mobileOptions);\n\n /** `src` and each mobile app's source folders: what `files()` reads and the book fingerprints. */\n async function sourceFolders(root: string, mobile: readonly BookMobileApp[]): Promise<string[]> {\n const folders = await Promise.all(mobile.map((app) => mobileSourceFolders(root, app)));\n\n return [\"src\", ...folders.flat()];\n }\n\n async function files(root: string): Promise<BookFile[]> {\n const { collectFiles } = await import(\"@warlock.js/core/tooling\");\n const mobile = await mobileApps(root);\n const dirs = await sourceFolders(root, mobile);\n const collected = collectFiles(root, [], { dirs })\n .filter((file) => isCodeFile(file.file))\n .map((file) => toBookFile(file, mobile));\n\n lastFiles = { root, files: collected };\n\n return collected;\n }\n\n /** File facts for the routes: the last `files()` answer, else the book's cache, else a new scan. */\n async function currentFiles(root: string): Promise<BookFile[]> {\n if (lastFiles?.root === root) return lastFiles.files;\n\n const { loadBook } = await import(\"../book\");\n const book = await loadBook(root);\n\n return book?.facts.files ?? files(root);\n }\n\n async function pages(root: string): Promise<BookPage[]> {\n // A multi-site app's routes depend on `web.sites` (base paths), which only `src/config/web.ts` holds.\n if ((await siteFolders(root)).length > 0 && (await webSitesConfig()) === undefined) {\n throw new Error(\n \"This app has several sites (src/web/$sites), and their page routes need src/config/web.ts, which is not loaded. Run the command through the warlock CLI, which loads it.\",\n );\n }\n\n // Pages come from the web page graph: files only, never a boot.\n const { inspectApp } = await import(\"@warlock.js/core/tooling\");\n const report = await inspectApp({ cwd: root, sections: [\"pages\"] });\n const found = (report.pages ?? []).map((page): BookPage => ({\n site: page.site ?? \"default\",\n route: page.path,\n name: page.name,\n file: toPosixPath(page.file),\n setupFile: page.setupFile === null ? null : toPosixPath(page.setupFile),\n layouts: page.layouts.map(toPosixPath),\n loaders: page.loaders.map(toPosixPath),\n actions: [...page.actions],\n requires: page.guard === null ? [] : [page.guard],\n reachedFrom: null,\n }));\n\n lastPages = { root, pages: found };\n\n return found;\n }\n\n return {\n name: \"warlock\",\n version: coreVersion(),\n host: (root) => warlockHost(root, coreVersion()),\n async sourceRoots(root) {\n return sourceFolders(root, await mobileApps(root));\n },\n files,\n async routes(root) {\n const report = await inspect(root, [\"routes\"]);\n const known = new Map((await currentFiles(root)).map((file) => [file.file, file]));\n // Pages only name the file of a page route; a page problem is reported by `pages()` itself.\n const sitePages =\n lastPages?.root === root ? lastPages.pages : await pages(root).catch(() => []);\n\n const exporters = exportIndex(known);\n\n return (report.routes ?? []).map((route) => toBookRoute(route, known, sitePages, exporters));\n },\n async named(root) {\n const report = await inspect(root, [\"events\", \"jobs\", \"schedules\"]);\n const known = await currentFiles(root);\n const ofType = (type: string) => known.filter((file) => file.type === type);\n const named: BookNamedThing[] = [];\n\n // `*.mail.ts`, `*.email.ts` and the files of a `mails/` or `emails/` folder are all typed as mails.\n for (const file of ofType(\"mail\")) {\n named.push({\n type: \"mail\",\n name: stemOf(file.file, \"mail\", \"email\"),\n file: file.file,\n });\n }\n\n const jobFiles = ofType(\"job\");\n const jobFileOf = (name: string): string | null =>\n jobFiles.find((item) => {\n const stem = stemOf(item.file, \"job\");\n\n return name === stem || name.endsWith(`.${stem}`) || name.endsWith(`/${stem}`);\n })?.file ?? null;\n const seen = new Set<string>();\n\n // Queue jobs (`defineJob()`) and scheduled tasks are both jobs a flow can name.\n for (const name of [\n ...(report.jobs ?? []).map((job) => job.name),\n ...(report.schedules ?? []).map((schedule) => schedule.name),\n ]) {\n if (seen.has(name)) continue;\n\n seen.add(name);\n named.push({ type: \"job\", name, file: jobFileOf(name) });\n }\n\n // A job file the registries do not list is still a job by its file name.\n for (const file of jobFiles) {\n const name = stemOf(file.file, \"job\");\n\n if (seen.has(name) || [...seen].some((item) => jobFileOf(item) === file.file)) continue;\n\n seen.add(name);\n named.push({ type: \"job\", name, file: file.file });\n }\n\n for (const event of report.events ?? []) {\n const source = event.listeners[0]?.sourceFile;\n\n named.push({\n type: \"event\",\n name: event.event,\n file: source === undefined ? null : toPosixPath(source),\n });\n }\n\n for (const file of known) {\n if (/\\.notification\\.[cm]?[jt]sx?$/.test(file.file)) {\n named.push({\n type: \"notification\",\n name: stemOf(file.file, \"notification\"),\n file: file.file,\n });\n }\n }\n\n return named;\n },\n async sites(root): Promise<BookSite[]> {\n const multi = await siteFolders(root);\n\n if (multi.length > 0) {\n const configured = await webSitesConfig();\n\n return multi.map((id) => {\n const basePath: unknown = configured?.[id]?.basePath;\n\n return {\n id,\n root: `src/web/$sites/${id}`,\n basePath: typeof basePath === \"string\" ? basePath : null,\n };\n });\n }\n\n return (await folderNames(path.join(root, \"src\"))).includes(\"web\")\n ? [{ id: \"default\", root: \"src/web\", basePath: null }]\n : [];\n },\n pages,\n mobile: mobileApps,\n async tests(root) {\n const known = await currentFiles(root);\n const specs = known.filter((file) => file.type === \"spec\").map((file) => file.file);\n const outside: string[] = [];\n\n const walk = async (dir: string, pattern: RegExp): Promise<void> => {\n let entries;\n\n try {\n entries = await readdir(path.join(root, dir), { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n\n const relative = `${dir}/${entry.name}`;\n\n if (entry.isDirectory()) await walk(relative, pattern);\n else if (entry.isFile() && pattern.test(entry.name)) outside.push(relative);\n }\n };\n\n await walk(\"e2e\", /\\.e2e\\.(?:ts|mts|js|mjs)$/);\n await walk(\"tests\", /\\.(?:test|spec)\\.ts$/);\n\n return [...new Set([...specs, ...outside])].sort();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4DA,SAAS,UAAU,MAAc,MAA6B;CAC5D,IAAI;EACF,MAAM,WAAW,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;EAKtD,OAAO,SAAS,SAAS,QAA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AC;GACH;GAEA,QAAQ,MAAM,YAAY,KAAK,KAAK,MAAM,KAAK,CAAC,EAAC,CAAE,SAAS,KAAK,IAC7D,CAAC;IAAE,IAAI;IAAW,MAAM;IAAW,UAAU;GAAK,CAAC,IACnD,CAAC;EACP;EACA;EACA,QAAQ;EACR,MAAM,MAAM,MAAM;GAEhB,MAAM,SAAQ,MADM,aAAa,IAAI,EAClB,CAAC,QAAQ,SAAS,KAAK,SAAS,MAAM,CAAC,CAAC,KAAK,SAAS,KAAK,IAAI;GAClF,MAAM,UAAoB,CAAC;GAE3B,MAAM,OAAO,OAAO,KAAa,YAAmC;IAClE,IAAI;IAEJ,IAAI;KACF,UAAU,MAAM,QAAQ,KAAK,KAAK,MAAM,GAAG,GAAG,EAAE,eAAe,KAAK,CAAC;IACvE,QAAQ;KACN;IACF;IAEA,KAAK,MAAM,SAAS,SAAS;KAC3B,IAAI,MAAM,SAAS,kBAAkB,MAAM,KAAK,WAAW,GAAG,GAAG;KAEjE,MAAM,WAAW,GAAG,IAAI,GAAG,MAAM;KAEjC,IAAI,MAAM,YAAY,GAAG,MAAM,KAAK,UAAU,OAAO;UAChD,IAAI,MAAM,OAAO,KAAK,QAAQ,KAAK,MAAM,IAAI,GAAG,QAAQ,KAAK,QAAQ;IAC5E;GACF;GAEA,MAAM,KAAK,OAAO,2BAA2B;GAC7C,MAAM,KAAK,SAAS,sBAAsB;GAE1C,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK;EACnD;CACF;AACF"}
1
+ {"version":3,"file":"adapter.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/warlock/adapter.ts"],"sourcesContent":["/**\n * The Warlock adapter: turns core's inspect report into the book's facts.\n * It never parses app source itself: files come from `collectFiles()`,\n * routes, events and jobs from `inspectApp()` after the `warlock inspect`\n * boot pass, pages from `inspectApp()` (the web page graph, no boot), and\n * mobile apps from their folders.\n *\n * `@warlock.js/core/tooling` is imported inside the methods, never at the\n * top: this module is reached from `warlock.config.ts`.\n */\nimport { readFileSync } from \"node:fs\";\nimport { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport type {\n InspectFile,\n InspectOptions,\n InspectReport,\n InspectRoute,\n InspectSection,\n} from \"@warlock.js/core/tooling\";\nimport type {\n BookAdapter,\n BookFile,\n BookHost,\n BookMobileApp,\n BookNamedThing,\n BookPage,\n BookRoute,\n BookSite,\n} from \"../contracts/adapter\";\nimport { isCodeFile, isInsideFolder, toPosixPath } from \"../paths\";\nimport { WARLOCK_LOGO_DATA_URI } from \"./logo\";\nimport { collectMobileFacts, type MobileAppOption } from \"./mobile-facts\";\n\n/**\n * Reads the sections of the inspect report that need the app booted\n * (`routes`, `events`, `jobs`) for the project at `root`. The default boots\n * the app once, the `warlock inspect` way (connectors boot, none starts).\n * `warlock mcp` passes its own, which shares the server's boot.\n */\nexport type WarlockInspect = (\n root: string,\n sections: readonly InspectSection[],\n) => Promise<InspectReport>;\n\n/** Options of `createWarlockAdapter()`. */\nexport type WarlockAdapterOptions = {\n /**\n * Mobile apps in the repository: folder, id and routing. Default: every\n * top-level folder with an `app.json` or an `app.config.*` file; it is\n * file-routed when its `package.json` lists `expo-router` (screens come\n * from the files), and code-navigated otherwise (no screens: the agent\n * declares them in `grimoire/apps/<app>/screens/`).\n */\n mobile?: readonly MobileAppOption[];\n /** How the booted sections are read. Default: the `warlock inspect` boot pass, run at most once. Pages never boot. */\n inspect?: WarlockInspect;\n /**\n * Read the route, event and job facts from the registries of the running process instead of booting the app\n * (`inspect` wins when both are set). For code that runs inside `warlock dev`, such as the devtools panel;\n * nothing is booted and no module is loaded twice. Default `false`.\n */\n live?: boolean;\n};\n\n/** The `version` of a `package.json` named `name`, or `null` when the file is not that package's. */\nfunction versionIn(file: string, name: string): string | null {\n try {\n const manifest = JSON.parse(readFileSync(file, \"utf8\")) as {\n name?: unknown;\n version?: unknown;\n };\n\n return manifest.name === name && typeof manifest.version === \"string\" ? manifest.version : null;\n } catch {\n return null;\n }\n}\n\n/**\n * The installed version of a package, read from its `package.json` without\n * going through its `exports` (published `@warlock.js/core` exports neither\n * `./package.json` nor a `require` condition). It resolves the package's\n * entry and walks up to the `package.json` with that name; when the entry\n * cannot be resolved, it looks in each `node_modules` above `from`.\n *\n * @param from Absolute folder to look from.\n * @param resolve Resolves a bare specifier to a file URL or path (`import.meta.resolve`).\n */\nexport function installedVersion(\n name: string,\n from: string,\n resolve: ((specifier: string) => string) | undefined,\n): string | null {\n try {\n const entry = resolve?.(name);\n\n if (entry !== undefined) {\n let folder = path.dirname(entry.startsWith(\"file:\") ? fileURLToPath(entry) : entry);\n\n for (;;) {\n const version = versionIn(path.join(folder, \"package.json\"), name);\n\n if (version !== null) return version;\n\n const parent = path.dirname(folder);\n\n if (parent === folder) break;\n\n folder = parent;\n }\n }\n } catch {\n // Not resolvable from here: look in the node_modules folders below.\n }\n\n for (let folder = from; ; folder = path.dirname(folder)) {\n const version = versionIn(\n path.join(folder, \"node_modules\", ...name.split(\"/\"), \"package.json\"),\n name,\n );\n\n if (version !== null) return version;\n if (path.dirname(folder) === folder) return null;\n }\n}\n\n/** The framework version, for the book manifest (a core upgrade rebuilds the book). */\nfunction coreVersion(): string {\n const resolve =\n typeof import.meta.resolve === \"function\"\n ? (specifier: string) => import.meta.resolve(specifier)\n : undefined;\n\n return (\n installedVersion(\"@warlock.js/core\", path.dirname(fileURLToPath(import.meta.url)), resolve) ??\n \"unknown\"\n );\n}\n\n/** The app's own `name` and `version` from `<root>/package.json`, or `null` when it has no name. */\nexport function appIdentity(root: string): { name: string; version: string | null } | null {\n try {\n const manifest = JSON.parse(readFileSync(path.join(root, \"package.json\"), \"utf8\")) as {\n name?: unknown;\n version?: unknown;\n };\n\n return typeof manifest.name === \"string\" && manifest.name !== \"\"\n ? {\n name: manifest.name,\n version: typeof manifest.version === \"string\" ? manifest.version : null,\n }\n : null;\n } catch {\n return null;\n }\n}\n\n/** The Warlock.js brand (logo and installed version) and the app at `root`, for the view's header and footer. */\nexport function warlockHost(root: string, frameworkVersion: string): BookHost {\n return {\n name: \"Warlock.js\",\n version: frameworkVersion === \"unknown\" ? null : frameworkVersion,\n logo: WARLOCK_LOGO_DATA_URI,\n app: appIdentity(root),\n };\n}\n\n/** Run `work` with `console.log`/`info`/`debug` on stderr, so a boot never mixes with `--json` output. */\nasync function withConsoleOnStderr<T>(work: () => Promise<T>): Promise<T> {\n const { log, info, debug } = console;\n const toStderr = (...args: unknown[]) => console.error(...args);\n\n console.log = toStderr;\n console.info = toStderr;\n console.debug = toStderr;\n\n try {\n return await work();\n } finally {\n console.log = log;\n console.info = info;\n console.debug = debug;\n }\n}\n\n/** The default booted `inspect`: one boot pass, shared by every call. */\nfunction bootedInspect(): WarlockInspect {\n let boot: Promise<unknown> | undefined;\n\n return async (root, sections) => {\n const tooling = await import(\"@warlock.js/core/tooling\");\n\n boot ??= withConsoleOnStderr(() => tooling.bootForInspect(root));\n\n const booted = (await boot) as Awaited<ReturnType<typeof tooling.bootForInspect>>;\n\n if (!booted.context.booted) {\n const failures = booted.context.moduleFailures.map(\n (failure) => `${failure.file}: ${failure.message}`,\n );\n\n throw new Error(\n `the app did not boot${failures.length > 0 ? ` (${failures.join(\"; \")})` : \"\"}. Run warlock doctor to see why.`,\n );\n }\n\n return tooling.inspectApp({ ...tooling.inspectOptionsFromBoot(booted), cwd: root, sections });\n };\n}\n\n/** The slice of `@warlock.js/core/tooling` that {@link liveInspect} reads (a seam for specs). */\nexport type LiveInspectTooling = {\n inspectApp: (options: InspectOptions) => Promise<InspectReport>;\n liveInspectOptions: () => InspectOptions;\n};\n\n/**\n * The `inspect` for code running inside the app's own process (`warlock dev`): reads the live router and the\n * event listeners recorded since dev start. It never boots a connector and never imports the route or event\n * modules again, so the running app is not touched.\n */\nexport function liveInspect(\n load: () => Promise<LiveInspectTooling> = () => import(\"@warlock.js/core/tooling\"),\n): WarlockInspect {\n return async (root, sections) => {\n const tooling = await load();\n\n return tooling.inspectApp({ ...tooling.liveInspectOptions(), cwd: root, sections });\n };\n}\n\n/** `send-receipt.job.ts` → `send-receipt` (the stem without the role suffix). */\nfunction stemOf(file: string, ...suffixes: string[]): string {\n const base = path.posix.basename(file).replace(/\\.(?:d\\.ts|[cm]?[jt]sx?)$/, \"\");\n\n for (const suffix of suffixes) {\n if (base.endsWith(`.${suffix}`)) return base.slice(0, -suffix.length - 1);\n }\n\n return base;\n}\n\n/**\n * The book's role of a file: the framework's role, with CLI command files\n * (`*.command.ts`, or a file directly in `<module>/commands/`) told apart from\n * plain source.\n */\nexport function bookRole(file: Pick<InspectFile, \"file\" | \"role\">): string {\n if (file.role !== \"source\") return file.role;\n\n const stem = path.posix.basename(file.file).replace(/\\.(?:d\\.ts|[cm]?[jt]sx?)$/, \"\");\n const folders = file.file.split(\"/\").slice(0, -1);\n\n return stem.endsWith(\".command\") || (folders.length === 4 && folders[3] === \"commands\")\n ? \"command\"\n : file.role;\n}\n\nfunction toBookFile(file: InspectFile, mobile: readonly BookMobileApp[]): BookFile {\n const docs = file.exportDocs ?? {};\n const app = mobile.find((item) => isInsideFolder(file.file, item.root));\n\n return {\n file: file.file,\n module: file.module,\n type: bookRole(file),\n lines: file.lines ?? 0,\n about: file.about ?? null,\n tags: file.tags ?? {},\n exports: file.exports.map((name) => ({ name, about: docs[name] ?? null })),\n imports: file.imports.map((entry) =>\n entry.typeOnly === true\n ? { specifier: entry.specifier, file: entry.file, typeOnly: true }\n : { specifier: entry.specifier, file: entry.file },\n ),\n importedBy: [...file.importedBy],\n mobileApp: app?.id ?? null,\n };\n}\n\n/** Files by the names they export, built once per `routes()` call. */\ntype ExportIndex = () => ReadonlyMap<string, readonly string[]>;\n\nfunction exportIndex(files: ReadonlyMap<string, BookFile>): ExportIndex {\n let index: Map<string, string[]> | undefined;\n\n return () => {\n if (index) return index;\n\n index = new Map();\n\n for (const file of files.values()) {\n for (const entry of file.exports) {\n const list = index.get(entry.name) ?? [];\n\n list.push(file.file);\n index.set(entry.name, list);\n }\n }\n\n return index;\n };\n}\n\n/** The file that defines a route's handler: the controller's file for a tuple, else the file exporting the handler. */\nfunction handlerFileOf(\n route: InspectRoute,\n files: ReadonlyMap<string, BookFile>,\n pages: readonly BookPage[],\n exporters: ExportIndex,\n): string | null {\n if (route.isPage) {\n return pages.find((page) => page.route === route.path)?.file ?? null;\n }\n\n const exportsName = (file: string | null | undefined, name: string): boolean =>\n file !== null &&\n file !== undefined &&\n files.get(file)?.exports.some((entry) => entry.name === name) === true;\n const imported =\n route.sourceFile === null\n ? []\n : (files.get(route.sourceFile)?.imports ?? []).map((entry) => entry.file);\n const name = route.controller ?? route.handler;\n\n if (!name || name === \"anonymous\") return null;\n\n const fromImports = imported.find((file) => exportsName(file, name));\n\n if (fromImports) return fromImports;\n if (exportsName(route.sourceFile, name)) return route.sourceFile;\n\n // Not imported by the routes file: the one file in the project exporting it, when there is only one.\n const anywhere = [...new Set(exporters().get(name) ?? [])];\n\n return anywhere.length === 1 ? (anywhere[0] ?? null) : null;\n}\n\nfunction toBookRoute(\n route: InspectRoute,\n files: ReadonlyMap<string, BookFile>,\n pages: readonly BookPage[],\n exporters: ExportIndex,\n): BookRoute {\n const controller = route.controller ?? null;\n const action = route.action ?? null;\n const handler =\n controller !== null && action !== null && !route.handler.includes(\".\")\n ? `${controller}.${action}`\n : route.handler;\n\n return {\n method: route.method.toUpperCase(),\n path: route.path,\n name: route.name,\n sourceFile: route.sourceFile === null ? null : toPosixPath(route.sourceFile),\n handler,\n controller,\n action,\n handlerFile: handlerFileOf(route, files, pages, exporters),\n middleware: [...route.middleware],\n auth: { required: route.auth.required, userTypes: [...route.auth.userTypes] },\n isPage: route.isPage,\n description: route.description,\n };\n}\n\nasync function folderNames(dir: string): Promise<string[]> {\n try {\n return (await readdir(dir, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort();\n } catch {\n return [];\n }\n}\n\n/** The site folders of a multi-site app (`src/web/$sites/<id>`), sorted; empty for a single site. */\nfunction siteFolders(root: string): Promise<string[]> {\n return folderNames(path.join(root, \"src\", \"web\", \"$sites\"));\n}\n\n/** `web.sites` from the loaded config, or `undefined` when `src/config/web.ts` is not loaded. */\nasync function webSitesConfig(): Promise<\n Record<string, { basePath?: unknown } | undefined> | undefined\n> {\n const { config } = await import(\"@warlock.js/core\");\n const sites: unknown = config.key(\"web.sites\");\n\n return typeof sites === \"object\" && sites !== null\n ? (sites as Record<string, { basePath?: unknown }>)\n : undefined;\n}\n\n/**\n * Folders of a mobile app that hold native projects, build output or tool\n * caches, never app source. `node_modules` and dot folders are skipped too.\n */\nconst MOBILE_SKIPPED_FOLDERS = new Set([\n \"android\",\n \"ios\",\n \"build\",\n \"dist\",\n \"web-build\",\n \"coverage\",\n \"node_modules\",\n]);\n\n/**\n * The source folders of a mobile app: its top-level folders minus native\n * projects and build output (`android/`, `ios/` with Pods and builds can hold\n * hundreds of megabytes). Code files directly in the app folder (`App.tsx`)\n * are not read: `collectFiles` scans folders only.\n */\nasync function mobileSourceFolders(root: string, app: BookMobileApp): Promise<string[]> {\n return (await folderNames(path.join(root, ...app.root.split(\"/\"))))\n .filter((name) => !name.startsWith(\".\") && !MOBILE_SKIPPED_FOLDERS.has(name))\n .map((name) => `${app.root}/${name}`);\n}\n\n/** The adapter over `inspectApp()`, `collectFiles()` and the mobile app folders. */\nexport function createWarlockAdapter(options: WarlockAdapterOptions = {}): BookAdapter {\n const inspect = options.inspect ?? (options.live === true ? liveInspect() : bootedInspect());\n const mobileOptions = options.mobile === undefined ? {} : { mobile: options.mobile };\n let lastFiles: { root: string; files: BookFile[] } | null = null;\n let lastPages: { root: string; pages: BookPage[] } | null = null;\n\n const mobileApps = (root: string) => collectMobileFacts(root, mobileOptions);\n\n /** `src` and each mobile app's source folders: what `files()` reads and the book fingerprints. */\n async function sourceFolders(root: string, mobile: readonly BookMobileApp[]): Promise<string[]> {\n const folders = await Promise.all(mobile.map((app) => mobileSourceFolders(root, app)));\n\n return [\"src\", ...folders.flat()];\n }\n\n async function files(root: string): Promise<BookFile[]> {\n const { collectFiles } = await import(\"@warlock.js/core/tooling\");\n const mobile = await mobileApps(root);\n const dirs = await sourceFolders(root, mobile);\n const collected = collectFiles(root, [], { dirs })\n .filter((file) => isCodeFile(file.file))\n .map((file) => toBookFile(file, mobile));\n\n lastFiles = { root, files: collected };\n\n return collected;\n }\n\n /** File facts for the routes: the last `files()` answer, else the book's cache, else a new scan. */\n async function currentFiles(root: string): Promise<BookFile[]> {\n if (lastFiles?.root === root) return lastFiles.files;\n\n const { loadBook } = await import(\"../book\");\n const book = await loadBook(root);\n\n return book?.facts.files ?? files(root);\n }\n\n async function pages(root: string): Promise<BookPage[]> {\n // A multi-site app's routes depend on `web.sites` (base paths), which only `src/config/web.ts` holds.\n if ((await siteFolders(root)).length > 0 && (await webSitesConfig()) === undefined) {\n throw new Error(\n \"This app has several sites (src/web/$sites), and their page routes need src/config/web.ts, which is not loaded. Run the command through the warlock CLI, which loads it.\",\n );\n }\n\n // Pages come from the web page graph: files only, never a boot.\n const { inspectApp } = await import(\"@warlock.js/core/tooling\");\n const report = await inspectApp({ cwd: root, sections: [\"pages\"] });\n const found = (report.pages ?? []).map((page): BookPage => ({\n site: page.site ?? \"default\",\n route: page.path,\n name: page.name,\n file: toPosixPath(page.file),\n setupFile: page.setupFile === null ? null : toPosixPath(page.setupFile),\n layouts: page.layouts.map(toPosixPath),\n loaders: page.loaders.map(toPosixPath),\n actions: [...page.actions],\n requires: page.guard === null ? [] : [page.guard],\n reachedFrom: null,\n }));\n\n lastPages = { root, pages: found };\n\n return found;\n }\n\n return {\n name: \"warlock\",\n version: coreVersion(),\n host: (root) => warlockHost(root, coreVersion()),\n async sourceRoots(root) {\n return sourceFolders(root, await mobileApps(root));\n },\n files,\n async routes(root) {\n const report = await inspect(root, [\"routes\"]);\n const known = new Map((await currentFiles(root)).map((file) => [file.file, file]));\n // Pages only name the file of a page route; a page problem is reported by `pages()` itself.\n const sitePages =\n lastPages?.root === root ? lastPages.pages : await pages(root).catch(() => []);\n\n const exporters = exportIndex(known);\n\n return (report.routes ?? []).map((route) => toBookRoute(route, known, sitePages, exporters));\n },\n async named(root) {\n const report = await inspect(root, [\"events\", \"jobs\", \"schedules\"]);\n const known = await currentFiles(root);\n const ofType = (type: string) => known.filter((file) => file.type === type);\n const named: BookNamedThing[] = [];\n\n // `*.mail.ts`, `*.email.ts` and the files of a `mails/` or `emails/` folder are all typed as mails.\n for (const file of ofType(\"mail\")) {\n named.push({\n type: \"mail\",\n name: stemOf(file.file, \"mail\", \"email\"),\n file: file.file,\n });\n }\n\n const jobFiles = ofType(\"job\");\n const jobFileOf = (name: string): string | null =>\n jobFiles.find((item) => {\n const stem = stemOf(item.file, \"job\");\n\n return name === stem || name.endsWith(`.${stem}`) || name.endsWith(`/${stem}`);\n })?.file ?? null;\n const seen = new Set<string>();\n\n // Queue jobs (`defineJob()`) and scheduled tasks are both jobs a flow can name.\n for (const name of [\n ...(report.jobs ?? []).map((job) => job.name),\n ...(report.schedules ?? []).map((schedule) => schedule.name),\n ]) {\n if (seen.has(name)) continue;\n\n seen.add(name);\n named.push({ type: \"job\", name, file: jobFileOf(name) });\n }\n\n // A job file the registries do not list is still a job by its file name.\n for (const file of jobFiles) {\n const name = stemOf(file.file, \"job\");\n\n if (seen.has(name) || [...seen].some((item) => jobFileOf(item) === file.file)) continue;\n\n seen.add(name);\n named.push({ type: \"job\", name, file: file.file });\n }\n\n for (const event of report.events ?? []) {\n const source = event.listeners[0]?.sourceFile;\n\n named.push({\n type: \"event\",\n name: event.event,\n file: source === undefined ? null : toPosixPath(source),\n });\n }\n\n for (const file of known) {\n if (/\\.notification\\.[cm]?[jt]sx?$/.test(file.file)) {\n named.push({\n type: \"notification\",\n name: stemOf(file.file, \"notification\"),\n file: file.file,\n });\n }\n }\n\n return named;\n },\n async sites(root): Promise<BookSite[]> {\n const multi = await siteFolders(root);\n\n if (multi.length > 0) {\n const configured = await webSitesConfig();\n\n return multi.map((id) => {\n const basePath: unknown = configured?.[id]?.basePath;\n\n return {\n id,\n root: `src/web/$sites/${id}`,\n basePath: typeof basePath === \"string\" ? basePath : null,\n };\n });\n }\n\n return (await folderNames(path.join(root, \"src\"))).includes(\"web\")\n ? [{ id: \"default\", root: \"src/web\", basePath: null }]\n : [];\n },\n pages,\n mobile: mobileApps,\n async tests(root) {\n const known = await currentFiles(root);\n const specs = known.filter((file) => file.type === \"spec\").map((file) => file.file);\n const outside: string[] = [];\n\n const walk = async (dir: string, pattern: RegExp): Promise<void> => {\n let entries;\n\n try {\n entries = await readdir(path.join(root, dir), { withFileTypes: true });\n } catch {\n return;\n }\n\n for (const entry of entries) {\n if (entry.name === \"node_modules\" || entry.name.startsWith(\".\")) continue;\n\n const relative = `${dir}/${entry.name}`;\n\n if (entry.isDirectory()) await walk(relative, pattern);\n else if (entry.isFile() && pattern.test(entry.name)) outside.push(relative);\n }\n };\n\n await walk(\"e2e\", /\\.e2e\\.(?:ts|mts|js|mjs)$/);\n await walk(\"tests\", /\\.(?:test|spec)\\.ts$/);\n\n return [...new Set([...specs, ...outside])].sort();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmEA,SAAS,UAAU,MAAc,MAA6B;CAC5D,IAAI;EACF,MAAM,WAAW,KAAK,MAAM,aAAa,MAAM,MAAM,CAAC;EAKtD,OAAO,SAAS,SAAS,QAAQ,OAAO,SAAS,YAAY,WAAW,SAAS,UAAU;CAC7F,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;AAYA,SAAgB,iBACd,MACA,MACA,SACe;CACf,IAAI;EACF,MAAM,QAAQ,UAAU,IAAI;EAE5B,IAAI,UAAU,QAAW;GACvB,IAAI,SAAS,KAAK,QAAQ,MAAM,WAAW,OAAO,IAAI,cAAc,KAAK,IAAI,KAAK;GAElF,SAAS;IACP,MAAM,UAAU,UAAU,KAAK,KAAK,QAAQ,cAAc,GAAG,IAAI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AE,IAAI;IAAW,MAAM;IAAW,UAAU;GAAK,CAAC,IACnD,CAAC;EACP;EACA;EACA,QAAQ;EACR,MAAM,MAAM,MAAM;GAEhB,MAAM,SAAQ,MADM,aAAa,IAAI,EAClB,CAAC,QAAQ,SAAS,KAAK,SAAS,MAAM,CAAC,CAAC,KAAK,SAAS,KAAK,IAAI;GAClF,MAAM,UAAoB,CAAC;GAE3B,MAAM,OAAO,OAAO,KAAa,YAAmC;IAClE,IAAI;IAEJ,IAAI;KACF,UAAU,MAAM,QAAQ,KAAK,KAAK,MAAM,GAAG,GAAG,EAAE,eAAe,KAAK,CAAC;IACvE,QAAQ;KACN;IACF;IAEA,KAAK,MAAM,SAAS,SAAS;KAC3B,IAAI,MAAM,SAAS,kBAAkB,MAAM,KAAK,WAAW,GAAG,GAAG;KAEjE,MAAM,WAAW,GAAG,IAAI,GAAG,MAAM;KAEjC,IAAI,MAAM,YAAY,GAAG,MAAM,KAAK,UAAU,OAAO;UAChD,IAAI,MAAM,OAAO,KAAK,QAAQ,KAAK,MAAM,IAAI,GAAG,QAAQ,KAAK,QAAQ;IAC5E;GACF;GAEA,MAAM,KAAK,OAAO,2BAA2B;GAC7C,MAAM,KAAK,SAAS,sBAAsB;GAE1C,OAAO,CAAC,mBAAG,IAAI,IAAI,CAAC,GAAG,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK;EACnD;CACF;AACF"}
@@ -1,4 +1,4 @@
1
1
  import { CollectMobileFactsOptions, MobileAppOption, collectMobileFacts } from "./mobile-facts.mjs";
2
- import { WarlockAdapterOptions, WarlockInspect, createWarlockAdapter } from "./adapter.mjs";
2
+ import { LiveInspectTooling, WarlockAdapterOptions, WarlockInspect, createWarlockAdapter, liveInspect } from "./adapter.mjs";
3
3
  import { registerGrimoireCommands } from "./commands.mjs";
4
- export { type CollectMobileFactsOptions, type MobileAppOption, type WarlockAdapterOptions, type WarlockInspect, collectMobileFacts, createWarlockAdapter, registerGrimoireCommands };
4
+ export { type CollectMobileFactsOptions, type LiveInspectTooling, type MobileAppOption, type WarlockAdapterOptions, type WarlockInspect, collectMobileFacts, createWarlockAdapter, liveInspect, registerGrimoireCommands };
@@ -1,5 +1,5 @@
1
1
  import { collectMobileFacts } from "./mobile-facts.mjs";
2
- import { createWarlockAdapter } from "./adapter.mjs";
2
+ import { createWarlockAdapter, liveInspect } from "./adapter.mjs";
3
3
  import { registerGrimoireCommands } from "./commands.mjs";
4
4
 
5
- export { collectMobileFacts, createWarlockAdapter, registerGrimoireCommands };
5
+ export { collectMobileFacts, createWarlockAdapter, liveInspect, registerGrimoireCommands };
@@ -492,10 +492,30 @@ function parseFlow(file, text, feature, name, sink) {
492
492
  const cases = findSection(document, "cases");
493
493
  if (cases !== null) {
494
494
  const answered = /* @__PURE__ */ new Set([...flow.cases.map((entry) => entry.question), ...flow.notHandled.map((entry) => normalizeKey(entry.name))]);
495
- for (const question of CASE_QUESTIONS) if (!answered.has(question)) sink.report("GR1012", `the case question "${question}" is answered neither under Cases nor under Not handled.`, lineAt(file, cases.line));
495
+ const readOnly = isReadOnlyFlow(flow.steps);
496
+ for (const question of CASE_QUESTIONS) {
497
+ if (readOnly && WRITE_ONLY_QUESTIONS.includes(question)) continue;
498
+ if (!answered.has(question)) sink.report("GR1012", `the case question "${question}" is answered neither under Cases nor under Not handled.`, lineAt(file, cases.line));
499
+ }
496
500
  }
497
501
  return flow;
498
502
  }
503
+ /** Case questions a flow with no writes may leave out. */
504
+ const WRITE_ONLY_QUESTIONS = ["duplicate", "double submit"];
505
+ const SAFE_METHODS = /* @__PURE__ */ new Set([
506
+ "GET",
507
+ "HEAD",
508
+ "OPTIONS"
509
+ ]);
510
+ /**
511
+ * A flow writes nothing when it has steps and every one is a page or a route
512
+ * with a safe method (`GET`, `HEAD`, `OPTIONS`). Any other step (a write route,
513
+ * mail, job, event, affects, outside service) or no steps at all counts as a write.
514
+ */
515
+ function isReadOnlyFlow(steps) {
516
+ if (steps.length === 0) return false;
517
+ return steps.every((step) => step.type === "page" || step.type === "route" && step.route !== null && SAFE_METHODS.has(step.route.method));
518
+ }
499
519
  /** `grimoire/features/<feature>/versions/v<n>.md`: free text under a title. */
500
520
  function parseVersionBrief(file, text, feature, major, sink) {
501
521
  const document = readDocument(file, text, "none", sink);
@@ -1 +1 @@
1
- {"version":3,"file":"features.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/features.ts"],"sourcesContent":["/**\n * The files of one feature folder: `README.md`, `CHANGELOG.md`,\n * `flows/<flow>.md` and `versions/v<n>.md`.\n */\nimport type { SourceLocation } from \"../contracts/location\";\nimport {\n CASE_QUESTIONS,\n type ChangeWord,\n type StepType,\n type WrittenCase,\n type WrittenChangelog,\n type WrittenChangelogEntry,\n type WrittenChangelogSection,\n type WrittenCriterion,\n type WrittenFeatureReadme,\n type WrittenFlow,\n type WrittenOrigin,\n type WrittenStatus,\n type WrittenStep,\n type WrittenStoryStep,\n type WrittenVersionBrief,\n} from \"../contracts/written\";\nimport { FrontMatterReader, ID, SEP, VERSION, checks, isDate, projectFolder } from \"./fields\";\nimport { BULLET, bulletLines, readListLines, splitListLine } from \"./lists\";\nimport {\n checkHeadings,\n findSection,\n isImageLine,\n lineAt,\n logicalLines,\n normalizeKey,\n paragraphAfterTitle,\n readDocument,\n readScreenshots,\n withoutImages,\n type BodyLine,\n type WrittenDocument,\n} from \"./markdown\";\nimport type { FindingSink } from \"./sink\";\n\nexport const STATUSES: readonly WrittenStatus[] = [\"proposed\", \"building\", \"shipped\", \"retired\"];\nexport const ORIGINS: readonly WrittenOrigin[] = [\"inferred\", \"confirmed\"];\nexport const CHANGE_WORDS: readonly ChangeWord[] = [\"added\", \"changed\", \"fixed\", \"removed\"];\n/** Step kinds, longest first so `outside service` is tried before shorter words. */\nexport const STEP_TYPES: readonly StepType[] = [\n \"outside service\",\n \"notification\",\n \"affects\",\n \"event\",\n \"route\",\n \"page\",\n \"mail\",\n \"job\",\n];\n\n/** A status that is missing or wrong is read as `building`: never `proposed`, which would hide findings. */\nconst FALLBACK_STATUS: WrittenStatus = \"building\";\n\n// The parts of a step, a criterion and a changelog entry are split by spaces\n// or tabs: two or more line them up, one is read too (a Markdown formatter\n// collapses them).\nconst STEP = new RegExp(\n String.raw`^(\\d+)\\.[ \\t]+(${STEP_TYPES.join(\"|\")})[ \\t]+(\\S.*?)(?:[ \\t]+(?:—|--)[ \\t]+(\\S.*))?$`,\n);\nconst STEP_ANY_TYPE = new RegExp(String.raw`^(\\d+)\\.[ \\t]+(\\S.*?)${SEP}(\\S.*)$`);\nconst STEP_FIRST_WORD = /^(\\d+)\\.[ \\t]+(\\S+)[ \\t]+(\\S.*)$/;\nconst NUMBERED = /^(\\d+)\\.(?:[ \\t]|$)/;\nconst PAGE_TARGET = /^(\\S+)[ \\t]+\\[([a-z0-9]+(?:-[a-z0-9]+)*)\\]$/;\nconst ROUTE_TARGET = /^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|ALL)[ \\t]+(\\/\\S*)$/i;\nconst AFFECTS_TARGET = /^([a-z0-9]+(?:-[a-z0-9]+)*)(?:\\/([a-z0-9]+(?:-[a-z0-9]+)*))?$/;\nconst CRITERION = /^[-*][ \\t]+AC-(\\d+)(?:[ \\t]+\\[([a-z0-9-]+)\\])?[ \\t]+([^\\s[].*)$/;\nconst CHANGELOG_ENTRY = /^[-*][ \\t]+(\\S+)[ \\t]+(\\S+)[ \\t]+(\\S.*)$/;\nconst RELEASE_HEADING = /^##[ \\t]+(\\S+)[ \\t]+\\((.+)\\)$/;\nconst UNRELEASED_HEADING = /^##[ \\t]+unreleased$/i;\nconst FLOW_PREFIX = /^([a-z0-9-]+):[ \\t]+(\\S.*)$/;\nconst CRITERIA_SUFFIX = /[ \\t]*\\((AC-\\d+(?:[ \\t]*,[ \\t]*AC-\\d+)*)\\)$/;\nconst FLOW_REF_IN_TEXT =\n /(?<![\\w/-])([a-z0-9]+(?:-[a-z0-9]+)*\\/[a-z0-9]+(?:-[a-z0-9]+)*)(?![\\w/-])/g;\n\nfunction heading(document: WrittenDocument): WrittenFeatureReadme[\"heading\"] {\n return document.title\n ? { value: document.title.text, at: lineAt(document.file, document.title.line) }\n : null;\n}\n\n/** GR1019 when a front matter id differs from the folder or file name it must equal. */\nfunction sameAsName(\n located: { value: string; at: SourceLocation },\n name: string,\n what: string,\n sink: FindingSink,\n): void {\n if (located.value !== \"\" && located.value !== name) {\n sink.report(\n \"GR1019\",\n `the ${what} ${JSON.stringify(located.value)} must equal its ${JSON.stringify(name)} name.`,\n located.at,\n );\n }\n}\n\n/** The text of a changelog entry: the flow prefix, the text and the trailing criteria. */\nexport function splitEntryText(text: string): {\n flow: string | null;\n criteria: string[];\n text: string;\n} {\n let rest = text.trim();\n let flow: string | null = null;\n let criteria: string[] = [];\n const prefix = FLOW_PREFIX.exec(rest);\n\n if (prefix) {\n flow = prefix[1] ?? null;\n rest = prefix[2] ?? \"\";\n }\n\n const suffix = CRITERIA_SUFFIX.exec(rest);\n\n if (suffix) {\n criteria = (suffix[1] ?? \"\").split(\",\").map((criterion) => criterion.trim());\n rest = rest.slice(0, suffix.index).trimEnd();\n }\n\n return { flow, criteria, text: rest };\n}\n\n// ── README ─────────────────────────────────────────────────────────────────\n\n/** `## Why`: the paragraphs of the section, joined with a blank line; `null` when absent or empty. */\nfunction readWhy(document: WrittenDocument): string | null {\n const paragraphs: string[] = [];\n let open: string[] = [];\n\n const close = (): void => {\n if (open.length > 0) paragraphs.push(open.join(\" \"));\n\n open = [];\n };\n\n for (const line of findSection(document, \"why\")?.lines ?? []) {\n const trimmed = line.text.trim();\n\n if (line.fenced || trimmed === \"\") close();\n else open.push(trimmed);\n }\n\n close();\n\n return paragraphs.length > 0 ? paragraphs.join(\"\\n\\n\") : null;\n}\n\n/** `grimoire/features/<id>/README.md`. */\nexport function parseFeatureReadme(\n file: string,\n text: string,\n folder: string,\n sink: FindingSink,\n): WrittenFeatureReadme {\n const document = readDocument(file, text, \"required\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys(\n [\"id\", \"title\", \"status\", \"version\", \"updated\", \"apps\", \"folders\", \"origin\", \"audience\"],\n \"feature README\",\n );\n\n const id = fields.required(\"id\", checks.id);\n sameAsName(id, folder, \"feature id\", sink);\n\n const readme: WrittenFeatureReadme = {\n file,\n id,\n title: fields.required(\"title\", checks.text),\n status: fields.oneOf(\"status\", STATUSES, FALLBACK_STATUS),\n version: fields.required(\"version\", checks.version),\n updated: fields.required(\"updated\", checks.date),\n apps: fields.list(\"apps\", { required: true, check: checks.id }),\n folders: fields.list(\"folders\", {\n required: true,\n check: checks.folder,\n map: (value) => projectFolder(value) ?? value,\n }),\n origin: fields.optionalOneOf(\"origin\", ORIGINS),\n heading: heading(document),\n summary: paragraphAfterTitle(document),\n audience: fields.list(\"audience\", { required: false, check: checks.text }),\n why: readWhy(document),\n flows: [],\n relations: [],\n };\n\n checkHeadings(\n document,\n { title: true, required: [], optional: [\"Why\", \"Flows\", \"Affects and affected by\"] },\n sink,\n );\n\n for (const flow of readListLines(file, findSection(document, \"flows\")?.lines, \"Flows\", sink)) {\n if (!ID.test(flow.name)) {\n sink.report(\n \"GR1028\",\n `the Flows line names ${JSON.stringify(flow.name)}, which is not a flow id.`,\n flow.at,\n );\n continue;\n }\n\n readme.flows.push(flow);\n }\n\n for (const line of logicalLines(findSection(document, \"affects and affected by\")?.lines ?? [])) {\n const relation = line.text.replace(BULLET, \"\").trim();\n\n readme.relations.push({\n text: relation,\n refs: [...relation.matchAll(FLOW_REF_IN_TEXT)].map((match) => match[1] ?? \"\"),\n at: lineAt(file, line.line),\n });\n }\n\n return readme;\n}\n\n// ── CHANGELOG ──────────────────────────────────────────────────────────────\n\n/** `grimoire/features/<feature>/CHANGELOG.md`. */\nexport function parseChangelog(\n file: string,\n text: string,\n feature: string,\n sink: FindingSink,\n): WrittenChangelog {\n const document = readDocument(file, text, \"none\", sink);\n\n new FrontMatterReader(document, sink).onlyKeys([], \"a changelog\");\n\n const sections: WrittenChangelogSection[] = [];\n const entries: WrittenChangelogEntry[] = [];\n const seen = new Set<string>();\n let current: WrittenChangelogSection | null = null;\n\n for (const line of logicalLines(document.body)) {\n const at = lineAt(file, line.line);\n\n if (/^#[ \\t]/.test(line.text)) continue;\n\n if (line.text.startsWith(\"#\")) {\n const release = RELEASE_HEADING.exec(line.text);\n let section: WrittenChangelogSection | null = null;\n\n if (UNRELEASED_HEADING.test(line.text)) {\n section = { release: null, date: null, at };\n } else if (release && isDate(release[2] ?? \"\")) {\n section = { release: release[1] ?? \"\", date: release[2] ?? \"\", at };\n }\n\n if (section === null) {\n sink.report(\n \"GR1017\",\n `the changelog heading ${JSON.stringify(line.text)} is neither \"## Unreleased\" nor \"## <release> (<yyyy-mm-dd>)\".`,\n at,\n );\n continue;\n }\n\n const key = section.release ?? \"\";\n\n if (seen.has(key)) {\n sink.report(\n \"GR1017\",\n `the changelog heading ${JSON.stringify(line.text)} is written twice; write each section once.`,\n at,\n );\n }\n\n seen.add(key);\n sections.push(section);\n current = section;\n continue;\n }\n\n if (!BULLET.test(line.text)) {\n sink.report(\"GR1015\", `the changelog line ${JSON.stringify(line.text)} is not an entry.`, at);\n continue;\n }\n\n const match = CHANGELOG_ENTRY.exec(line.text);\n const version = match?.[1] ?? \"\";\n const word = match?.[2] ?? \"\";\n\n if (!match || !VERSION.test(version)) {\n sink.report(\n \"GR1015\",\n `the changelog line ${JSON.stringify(line.text)} is not \\`- <version> <word> <text>\\`.`,\n at,\n );\n continue;\n }\n\n if (!CHANGE_WORDS.includes(word as ChangeWord)) {\n sink.report(\n \"GR1016\",\n `the changelog word ${JSON.stringify(word)} is not one of ${CHANGE_WORDS.join(\", \")}.`,\n at,\n );\n continue;\n }\n\n if (current === null) {\n sink.report(\n \"GR1015\",\n `the changelog entry ${JSON.stringify(line.text)} is not under \"## Unreleased\" or a release heading.`,\n at,\n );\n }\n\n const parts = splitEntryText(match[3] ?? \"\");\n\n entries.push({\n feature,\n version: { value: version, at },\n word: word as ChangeWord,\n flow: parts.flow,\n criteria: parts.criteria,\n text: parts.text,\n release: current?.release ?? null,\n date: current?.date ?? null,\n at,\n });\n }\n\n return { file, sections, entries };\n}\n\n// ── Flows ──────────────────────────────────────────────────────────────────\n\nfunction parseSteps(file: string, document: WrittenDocument, sink: FindingSink): WrittenStep[] {\n const steps: WrittenStep[] = [];\n const numbers: { number: number; line: number }[] = [];\n\n for (const line of logicalLines(findSection(document, \"steps\")?.lines ?? [])) {\n const at = lineAt(file, line.line);\n const numbered = NUMBERED.exec(line.text);\n\n if (!numbered) {\n if (BULLET.test(line.text)) {\n sink.report(\n \"GR1008\",\n `the step ${JSON.stringify(line.text)} is a bullet; number steps \\`1. <kind> <name>\\`.`,\n at,\n );\n }\n\n continue;\n }\n\n numbers.push({ number: Number(numbered[1]), line: line.line });\n\n const match = STEP.exec(line.text);\n\n if (!match) {\n const other = STEP_ANY_TYPE.exec(line.text) ?? STEP_FIRST_WORD.exec(line.text);\n const type = other?.[2] ?? \"\";\n\n if (other && !STEP_TYPES.includes(type as StepType)) {\n sink.report(\n \"GR1009\",\n `the step kind ${JSON.stringify(type)} is not one of: ${STEP_TYPES.join(\", \")}.`,\n at,\n );\n } else {\n sink.report(\n \"GR1008\",\n `the step ${JSON.stringify(line.text)} is not \\`<n>. <kind> <name>\\`.`,\n at,\n );\n }\n\n continue;\n }\n\n const type = match[2] as StepType;\n let target = (match[3] ?? \"\").trim();\n let app: string | null = null;\n let route: WrittenStep[\"route\"] = null;\n let affects: WrittenStep[\"affects\"] = null;\n\n if (type === \"page\") {\n const scoped = PAGE_TARGET.exec(target);\n\n if (scoped) {\n target = scoped[1] ?? \"\";\n app = scoped[2] ?? null;\n }\n }\n\n if (type === \"route\") {\n const routeMatch = ROUTE_TARGET.exec(target);\n\n if (!routeMatch) {\n sink.report(\n \"GR1008\",\n `the route step ${JSON.stringify(target)} is not \\`<METHOD> /path\\`.`,\n at,\n );\n continue;\n }\n\n route = { method: (routeMatch[1] ?? \"\").toUpperCase(), path: routeMatch[2] ?? \"\" };\n }\n\n if (type === \"affects\") {\n const affectsMatch = AFFECTS_TARGET.exec(target);\n\n if (!affectsMatch) {\n sink.report(\n \"GR1008\",\n `the affects step ${JSON.stringify(target)} is not \\`<feature>\\` or \\`<feature>/<flow>\\`.`,\n at,\n );\n continue;\n }\n\n affects = { feature: affectsMatch[1] ?? \"\", flow: affectsMatch[2] ?? null };\n }\n\n steps.push({\n index: Number(match[1]),\n type,\n target,\n app,\n route,\n affects,\n note: match[4]?.trim() ?? null,\n at,\n });\n }\n\n const wrong = numbers.findIndex((entry, position) => entry.number !== position + 1);\n const first = numbers[wrong];\n\n if (first !== undefined) {\n sink.report(\n \"GR1010\",\n `step ${first.number} should be step ${wrong + 1}; number the steps 1, 2, 3 in order.`,\n lineAt(file, first.line),\n );\n }\n\n return steps;\n}\n\n/**\n * `## Story`: numbered sentences in the user's words. Indented lines continue\n * the item, image lines attach screenshots. GR1008 for any other line, GR1010\n * for numbers out of order.\n */\nfunction parseStory(\n file: string,\n document: WrittenDocument,\n sink: FindingSink,\n): WrittenStoryStep[] {\n const story: WrittenStoryStep[] = [];\n const numbers: { number: number; line: number }[] = [];\n let open: { step: WrittenStoryStep; text: string[] } | null = null;\n let continuing = false;\n\n const finish = (): void => {\n if (open !== null) open.step.text = open.text.join(\" \");\n\n open = null;\n };\n\n const attach = (line: BodyLine): void => {\n open?.step.screenshots.push(...readScreenshots(file, [line], sink));\n };\n\n for (const line of findSection(document, \"story\")?.lines ?? []) {\n const trimmed = line.text.trim();\n const at = lineAt(file, line.line);\n\n if (line.fenced) {\n continuing = false;\n continue;\n }\n\n if (trimmed === \"\") {\n continuing = false;\n continue;\n }\n\n const numbered = NUMBERED.exec(trimmed);\n\n if (numbered) {\n finish();\n\n const sentence = withoutImages(trimmed.replace(NUMBERED, \"\"));\n\n if (sentence === \"\") {\n sink.report(\n \"GR1008\",\n `the story line ${JSON.stringify(trimmed)} is not \\`<n>. <sentence>\\`.`,\n at,\n );\n continuing = false;\n continue;\n }\n\n const number = Number(numbered[1]);\n const step: WrittenStoryStep = { index: number, text: sentence, screenshots: [], at };\n\n numbers.push({ number, line: line.line });\n story.push(step);\n open = { step, text: [sentence] };\n continuing = true;\n attach(line);\n continue;\n }\n\n if (isImageLine(trimmed)) {\n if (open === null) {\n sink.report(\n \"GR1008\",\n `the story line ${JSON.stringify(trimmed)} is an image before any story step.`,\n at,\n );\n } else {\n attach(line);\n }\n\n continue;\n }\n\n if (open !== null && continuing && /^[ \\t]/.test(line.text)) {\n const more = withoutImages(trimmed);\n\n if (more !== \"\") open.text.push(more);\n\n attach(line);\n continue;\n }\n\n sink.report(\n \"GR1008\",\n `the story line ${JSON.stringify(trimmed)} is not \\`<n>. <sentence>\\`.`,\n at,\n );\n }\n\n finish();\n\n const wrong = numbers.findIndex((entry, position) => entry.number !== position + 1);\n const first = numbers[wrong];\n\n if (first !== undefined) {\n sink.report(\n \"GR1010\",\n `story step ${first.number} should be story step ${wrong + 1}; number the story steps 1, 2, 3 in order.`,\n lineAt(file, first.line),\n );\n }\n\n return story;\n}\n\nfunction parseCases(file: string, document: WrittenDocument, sink: FindingSink): WrittenCase[] {\n const cases: WrittenCase[] = [];\n\n for (const line of bulletLines(findSection(document, \"cases\")?.lines ?? [])) {\n const split = splitListLine(line.text, CASE_QUESTIONS);\n\n if (split === null) {\n sink.report(\n \"GR1011\",\n `the case ${JSON.stringify(line.text)} is not \\`- <question> <answer>\\`.`,\n lineAt(file, line.line),\n );\n continue;\n }\n\n const question = normalizeKey(split.name);\n const suffix = CRITERIA_SUFFIX.exec(split.text);\n const answer = suffix ? split.text.slice(0, suffix.index).trimEnd() : split.text;\n\n cases.push({\n question,\n fixed: (CASE_QUESTIONS as readonly string[]).includes(question),\n answer,\n doesNotApply: /^does not apply\\b/i.test(answer),\n criteria: suffix ? (suffix[1] ?? \"\").split(\",\").map((criterion) => criterion.trim()) : [],\n at: lineAt(file, line.line),\n });\n }\n\n return cases;\n}\n\nfunction parseCriteria(\n file: string,\n document: WrittenDocument,\n sink: FindingSink,\n): WrittenCriterion[] {\n const criteria: WrittenCriterion[] = [];\n const seen = new Set<number>();\n\n for (const line of bulletLines(findSection(document, \"acceptance criteria\")?.lines ?? [])) {\n const at = lineAt(file, line.line);\n const match = CRITERION.exec(line.text);\n\n if (!match) {\n sink.report(\n \"GR1013\",\n `the criterion ${JSON.stringify(line.text)} is not \\`- AC-<n> <text>\\` or \\`- AC-<n> [<app>] <text>\\`.`,\n at,\n );\n continue;\n }\n\n const number = Number(match[1]);\n\n if (seen.has(number)) {\n sink.report(\"GR1014\", `AC-${number} is used twice in this flow.`, at);\n continue;\n }\n\n seen.add(number);\n criteria.push({\n id: `AC-${number}`,\n number,\n app: match[2] ?? null,\n text: (match[3] ?? \"\").trim(),\n at,\n });\n }\n\n return criteria;\n}\n\n/** `grimoire/features/<feature>/flows/<name>.md`. */\nexport function parseFlow(\n file: string,\n text: string,\n feature: string,\n name: string,\n sink: FindingSink,\n): WrittenFlow {\n const document = readDocument(file, text, \"required\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys([\"id\", \"since\", \"status\", \"who\", \"origin\"], \"flow\");\n\n const id = fields.required(\"id\", checks.id);\n sameAsName(id, name, \"flow id\", sink);\n\n const flow: WrittenFlow = {\n file,\n feature,\n id,\n ref: `${feature}/${name}`,\n since: fields.required(\"since\", checks.version),\n status: fields.oneOf(\"status\", STATUSES, FALLBACK_STATUS),\n who: fields.required(\"who\", checks.text),\n origin: fields.optionalOneOf(\"origin\", ORIGINS),\n heading: heading(document),\n summary: paragraphAfterTitle(document),\n story: [],\n steps: [],\n differs: [],\n cases: [],\n notHandled: [],\n unknowns: [],\n criteria: [],\n };\n\n checkHeadings(\n document,\n {\n title: true,\n required: [\"Steps\", \"Cases\", \"Acceptance criteria\"],\n optional: [\"Story\", \"Differs by app\", \"Not handled\"],\n },\n sink,\n );\n\n if (flow.summary === null) {\n sink.report(\n \"GR1030\",\n \"the flow has no summary; write one or two sentences under the title.\",\n lineAt(file, document.title?.line ?? document.bodyStartLine),\n );\n }\n\n flow.story = parseStory(file, document, sink);\n flow.steps = parseSteps(file, document, sink);\n flow.differs = readListLines(\n file,\n findSection(document, \"differs by app\")?.lines,\n \"Differs by app\",\n sink,\n );\n flow.cases = parseCases(file, document, sink);\n flow.notHandled = readListLines(\n file,\n findSection(document, \"not handled\")?.lines,\n \"Not handled\",\n sink,\n CASE_QUESTIONS,\n );\n flow.criteria = parseCriteria(file, document, sink);\n\n for (const line of document.body) {\n const trimmed = line.text.trim();\n\n if (!line.fenced && trimmed.startsWith(\"Unknown:\")) {\n flow.unknowns.push({\n text: trimmed.slice(\"Unknown:\".length).trim(),\n at: lineAt(file, line.line),\n });\n }\n }\n\n const cases = findSection(document, \"cases\");\n\n if (cases !== null) {\n const answered = new Set([\n ...flow.cases.map((entry) => entry.question),\n ...flow.notHandled.map((entry) => normalizeKey(entry.name)),\n ]);\n\n for (const question of CASE_QUESTIONS) {\n if (!answered.has(question)) {\n sink.report(\n \"GR1012\",\n `the case question \"${question}\" is answered neither under Cases nor under Not handled.`,\n lineAt(file, cases.line),\n );\n }\n }\n }\n\n return flow;\n}\n\n// ── Version briefs ─────────────────────────────────────────────────────────\n\n/** `grimoire/features/<feature>/versions/v<n>.md`: free text under a title. */\nexport function parseVersionBrief(\n file: string,\n text: string,\n feature: string,\n major: number,\n sink: FindingSink,\n): WrittenVersionBrief {\n const document = readDocument(file, text, \"none\", sink);\n\n new FrontMatterReader(document, sink).onlyKeys([], \"a version brief\");\n\n return { file, feature, major, heading: heading(document) };\n}\n"],"mappings":";;;;;;AAwCA,MAAa,WAAqC;CAAC;CAAY;CAAY;CAAW;AAAS;AAC/F,MAAa,UAAoC,CAAC,YAAY,WAAW;AACzE,MAAa,eAAsC;CAAC;CAAS;CAAW;CAAS;AAAS;;AAE1F,MAAa,aAAkC;CAC7C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAM,kBAAiC;AAKvC,MAAM,OAA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MACA,MACA,SACA,OACA,MACqB;CACrB,MAAM,WAAW,aAAa,MAAM,MAAM,QAAQ,IAAI;CAEtD,IAAI,kBAAkB,UAAU,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,iBAAiB;CAEpE,OAAO;EAAE;EAAM;EAAS;EAAO,SAAS,QAAQ,QAAQ;CAAE;AAC5D"}
1
+ {"version":3,"file":"features.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/features.ts"],"sourcesContent":["/**\n * The files of one feature folder: `README.md`, `CHANGELOG.md`,\n * `flows/<flow>.md` and `versions/v<n>.md`.\n */\nimport type { SourceLocation } from \"../contracts/location\";\nimport {\n CASE_QUESTIONS,\n type ChangeWord,\n type StepType,\n type WrittenCase,\n type WrittenChangelog,\n type WrittenChangelogEntry,\n type WrittenChangelogSection,\n type WrittenCriterion,\n type WrittenFeatureReadme,\n type WrittenFlow,\n type WrittenOrigin,\n type WrittenStatus,\n type WrittenStep,\n type WrittenStoryStep,\n type WrittenVersionBrief,\n} from \"../contracts/written\";\nimport { FrontMatterReader, ID, SEP, VERSION, checks, isDate, projectFolder } from \"./fields\";\nimport { BULLET, bulletLines, readListLines, splitListLine } from \"./lists\";\nimport {\n checkHeadings,\n findSection,\n isImageLine,\n lineAt,\n logicalLines,\n normalizeKey,\n paragraphAfterTitle,\n readDocument,\n readScreenshots,\n withoutImages,\n type BodyLine,\n type WrittenDocument,\n} from \"./markdown\";\nimport type { FindingSink } from \"./sink\";\n\nexport const STATUSES: readonly WrittenStatus[] = [\"proposed\", \"building\", \"shipped\", \"retired\"];\nexport const ORIGINS: readonly WrittenOrigin[] = [\"inferred\", \"confirmed\"];\nexport const CHANGE_WORDS: readonly ChangeWord[] = [\"added\", \"changed\", \"fixed\", \"removed\"];\n/** Step kinds, longest first so `outside service` is tried before shorter words. */\nexport const STEP_TYPES: readonly StepType[] = [\n \"outside service\",\n \"notification\",\n \"affects\",\n \"event\",\n \"route\",\n \"page\",\n \"mail\",\n \"job\",\n];\n\n/** A status that is missing or wrong is read as `building`: never `proposed`, which would hide findings. */\nconst FALLBACK_STATUS: WrittenStatus = \"building\";\n\n// The parts of a step, a criterion and a changelog entry are split by spaces\n// or tabs: two or more line them up, one is read too (a Markdown formatter\n// collapses them).\nconst STEP = new RegExp(\n String.raw`^(\\d+)\\.[ \\t]+(${STEP_TYPES.join(\"|\")})[ \\t]+(\\S.*?)(?:[ \\t]+(?:—|--)[ \\t]+(\\S.*))?$`,\n);\nconst STEP_ANY_TYPE = new RegExp(String.raw`^(\\d+)\\.[ \\t]+(\\S.*?)${SEP}(\\S.*)$`);\nconst STEP_FIRST_WORD = /^(\\d+)\\.[ \\t]+(\\S+)[ \\t]+(\\S.*)$/;\nconst NUMBERED = /^(\\d+)\\.(?:[ \\t]|$)/;\nconst PAGE_TARGET = /^(\\S+)[ \\t]+\\[([a-z0-9]+(?:-[a-z0-9]+)*)\\]$/;\nconst ROUTE_TARGET = /^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|ALL)[ \\t]+(\\/\\S*)$/i;\nconst AFFECTS_TARGET = /^([a-z0-9]+(?:-[a-z0-9]+)*)(?:\\/([a-z0-9]+(?:-[a-z0-9]+)*))?$/;\nconst CRITERION = /^[-*][ \\t]+AC-(\\d+)(?:[ \\t]+\\[([a-z0-9-]+)\\])?[ \\t]+([^\\s[].*)$/;\nconst CHANGELOG_ENTRY = /^[-*][ \\t]+(\\S+)[ \\t]+(\\S+)[ \\t]+(\\S.*)$/;\nconst RELEASE_HEADING = /^##[ \\t]+(\\S+)[ \\t]+\\((.+)\\)$/;\nconst UNRELEASED_HEADING = /^##[ \\t]+unreleased$/i;\nconst FLOW_PREFIX = /^([a-z0-9-]+):[ \\t]+(\\S.*)$/;\nconst CRITERIA_SUFFIX = /[ \\t]*\\((AC-\\d+(?:[ \\t]*,[ \\t]*AC-\\d+)*)\\)$/;\nconst FLOW_REF_IN_TEXT =\n /(?<![\\w/-])([a-z0-9]+(?:-[a-z0-9]+)*\\/[a-z0-9]+(?:-[a-z0-9]+)*)(?![\\w/-])/g;\n\nfunction heading(document: WrittenDocument): WrittenFeatureReadme[\"heading\"] {\n return document.title\n ? { value: document.title.text, at: lineAt(document.file, document.title.line) }\n : null;\n}\n\n/** GR1019 when a front matter id differs from the folder or file name it must equal. */\nfunction sameAsName(\n located: { value: string; at: SourceLocation },\n name: string,\n what: string,\n sink: FindingSink,\n): void {\n if (located.value !== \"\" && located.value !== name) {\n sink.report(\n \"GR1019\",\n `the ${what} ${JSON.stringify(located.value)} must equal its ${JSON.stringify(name)} name.`,\n located.at,\n );\n }\n}\n\n/** The text of a changelog entry: the flow prefix, the text and the trailing criteria. */\nexport function splitEntryText(text: string): {\n flow: string | null;\n criteria: string[];\n text: string;\n} {\n let rest = text.trim();\n let flow: string | null = null;\n let criteria: string[] = [];\n const prefix = FLOW_PREFIX.exec(rest);\n\n if (prefix) {\n flow = prefix[1] ?? null;\n rest = prefix[2] ?? \"\";\n }\n\n const suffix = CRITERIA_SUFFIX.exec(rest);\n\n if (suffix) {\n criteria = (suffix[1] ?? \"\").split(\",\").map((criterion) => criterion.trim());\n rest = rest.slice(0, suffix.index).trimEnd();\n }\n\n return { flow, criteria, text: rest };\n}\n\n// ── README ─────────────────────────────────────────────────────────────────\n\n/** `## Why`: the paragraphs of the section, joined with a blank line; `null` when absent or empty. */\nfunction readWhy(document: WrittenDocument): string | null {\n const paragraphs: string[] = [];\n let open: string[] = [];\n\n const close = (): void => {\n if (open.length > 0) paragraphs.push(open.join(\" \"));\n\n open = [];\n };\n\n for (const line of findSection(document, \"why\")?.lines ?? []) {\n const trimmed = line.text.trim();\n\n if (line.fenced || trimmed === \"\") close();\n else open.push(trimmed);\n }\n\n close();\n\n return paragraphs.length > 0 ? paragraphs.join(\"\\n\\n\") : null;\n}\n\n/** `grimoire/features/<id>/README.md`. */\nexport function parseFeatureReadme(\n file: string,\n text: string,\n folder: string,\n sink: FindingSink,\n): WrittenFeatureReadme {\n const document = readDocument(file, text, \"required\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys(\n [\"id\", \"title\", \"status\", \"version\", \"updated\", \"apps\", \"folders\", \"origin\", \"audience\"],\n \"feature README\",\n );\n\n const id = fields.required(\"id\", checks.id);\n sameAsName(id, folder, \"feature id\", sink);\n\n const readme: WrittenFeatureReadme = {\n file,\n id,\n title: fields.required(\"title\", checks.text),\n status: fields.oneOf(\"status\", STATUSES, FALLBACK_STATUS),\n version: fields.required(\"version\", checks.version),\n updated: fields.required(\"updated\", checks.date),\n apps: fields.list(\"apps\", { required: true, check: checks.id }),\n folders: fields.list(\"folders\", {\n required: true,\n check: checks.folder,\n map: (value) => projectFolder(value) ?? value,\n }),\n origin: fields.optionalOneOf(\"origin\", ORIGINS),\n heading: heading(document),\n summary: paragraphAfterTitle(document),\n audience: fields.list(\"audience\", { required: false, check: checks.text }),\n why: readWhy(document),\n flows: [],\n relations: [],\n };\n\n checkHeadings(\n document,\n { title: true, required: [], optional: [\"Why\", \"Flows\", \"Affects and affected by\"] },\n sink,\n );\n\n for (const flow of readListLines(file, findSection(document, \"flows\")?.lines, \"Flows\", sink)) {\n if (!ID.test(flow.name)) {\n sink.report(\n \"GR1028\",\n `the Flows line names ${JSON.stringify(flow.name)}, which is not a flow id.`,\n flow.at,\n );\n continue;\n }\n\n readme.flows.push(flow);\n }\n\n for (const line of logicalLines(findSection(document, \"affects and affected by\")?.lines ?? [])) {\n const relation = line.text.replace(BULLET, \"\").trim();\n\n readme.relations.push({\n text: relation,\n refs: [...relation.matchAll(FLOW_REF_IN_TEXT)].map((match) => match[1] ?? \"\"),\n at: lineAt(file, line.line),\n });\n }\n\n return readme;\n}\n\n// ── CHANGELOG ──────────────────────────────────────────────────────────────\n\n/** `grimoire/features/<feature>/CHANGELOG.md`. */\nexport function parseChangelog(\n file: string,\n text: string,\n feature: string,\n sink: FindingSink,\n): WrittenChangelog {\n const document = readDocument(file, text, \"none\", sink);\n\n new FrontMatterReader(document, sink).onlyKeys([], \"a changelog\");\n\n const sections: WrittenChangelogSection[] = [];\n const entries: WrittenChangelogEntry[] = [];\n const seen = new Set<string>();\n let current: WrittenChangelogSection | null = null;\n\n for (const line of logicalLines(document.body)) {\n const at = lineAt(file, line.line);\n\n if (/^#[ \\t]/.test(line.text)) continue;\n\n if (line.text.startsWith(\"#\")) {\n const release = RELEASE_HEADING.exec(line.text);\n let section: WrittenChangelogSection | null = null;\n\n if (UNRELEASED_HEADING.test(line.text)) {\n section = { release: null, date: null, at };\n } else if (release && isDate(release[2] ?? \"\")) {\n section = { release: release[1] ?? \"\", date: release[2] ?? \"\", at };\n }\n\n if (section === null) {\n sink.report(\n \"GR1017\",\n `the changelog heading ${JSON.stringify(line.text)} is neither \"## Unreleased\" nor \"## <release> (<yyyy-mm-dd>)\".`,\n at,\n );\n continue;\n }\n\n const key = section.release ?? \"\";\n\n if (seen.has(key)) {\n sink.report(\n \"GR1017\",\n `the changelog heading ${JSON.stringify(line.text)} is written twice; write each section once.`,\n at,\n );\n }\n\n seen.add(key);\n sections.push(section);\n current = section;\n continue;\n }\n\n if (!BULLET.test(line.text)) {\n sink.report(\"GR1015\", `the changelog line ${JSON.stringify(line.text)} is not an entry.`, at);\n continue;\n }\n\n const match = CHANGELOG_ENTRY.exec(line.text);\n const version = match?.[1] ?? \"\";\n const word = match?.[2] ?? \"\";\n\n if (!match || !VERSION.test(version)) {\n sink.report(\n \"GR1015\",\n `the changelog line ${JSON.stringify(line.text)} is not \\`- <version> <word> <text>\\`.`,\n at,\n );\n continue;\n }\n\n if (!CHANGE_WORDS.includes(word as ChangeWord)) {\n sink.report(\n \"GR1016\",\n `the changelog word ${JSON.stringify(word)} is not one of ${CHANGE_WORDS.join(\", \")}.`,\n at,\n );\n continue;\n }\n\n if (current === null) {\n sink.report(\n \"GR1015\",\n `the changelog entry ${JSON.stringify(line.text)} is not under \"## Unreleased\" or a release heading.`,\n at,\n );\n }\n\n const parts = splitEntryText(match[3] ?? \"\");\n\n entries.push({\n feature,\n version: { value: version, at },\n word: word as ChangeWord,\n flow: parts.flow,\n criteria: parts.criteria,\n text: parts.text,\n release: current?.release ?? null,\n date: current?.date ?? null,\n at,\n });\n }\n\n return { file, sections, entries };\n}\n\n// ── Flows ──────────────────────────────────────────────────────────────────\n\nfunction parseSteps(file: string, document: WrittenDocument, sink: FindingSink): WrittenStep[] {\n const steps: WrittenStep[] = [];\n const numbers: { number: number; line: number }[] = [];\n\n for (const line of logicalLines(findSection(document, \"steps\")?.lines ?? [])) {\n const at = lineAt(file, line.line);\n const numbered = NUMBERED.exec(line.text);\n\n if (!numbered) {\n if (BULLET.test(line.text)) {\n sink.report(\n \"GR1008\",\n `the step ${JSON.stringify(line.text)} is a bullet; number steps \\`1. <kind> <name>\\`.`,\n at,\n );\n }\n\n continue;\n }\n\n numbers.push({ number: Number(numbered[1]), line: line.line });\n\n const match = STEP.exec(line.text);\n\n if (!match) {\n const other = STEP_ANY_TYPE.exec(line.text) ?? STEP_FIRST_WORD.exec(line.text);\n const type = other?.[2] ?? \"\";\n\n if (other && !STEP_TYPES.includes(type as StepType)) {\n sink.report(\n \"GR1009\",\n `the step kind ${JSON.stringify(type)} is not one of: ${STEP_TYPES.join(\", \")}.`,\n at,\n );\n } else {\n sink.report(\n \"GR1008\",\n `the step ${JSON.stringify(line.text)} is not \\`<n>. <kind> <name>\\`.`,\n at,\n );\n }\n\n continue;\n }\n\n const type = match[2] as StepType;\n let target = (match[3] ?? \"\").trim();\n let app: string | null = null;\n let route: WrittenStep[\"route\"] = null;\n let affects: WrittenStep[\"affects\"] = null;\n\n if (type === \"page\") {\n const scoped = PAGE_TARGET.exec(target);\n\n if (scoped) {\n target = scoped[1] ?? \"\";\n app = scoped[2] ?? null;\n }\n }\n\n if (type === \"route\") {\n const routeMatch = ROUTE_TARGET.exec(target);\n\n if (!routeMatch) {\n sink.report(\n \"GR1008\",\n `the route step ${JSON.stringify(target)} is not \\`<METHOD> /path\\`.`,\n at,\n );\n continue;\n }\n\n route = { method: (routeMatch[1] ?? \"\").toUpperCase(), path: routeMatch[2] ?? \"\" };\n }\n\n if (type === \"affects\") {\n const affectsMatch = AFFECTS_TARGET.exec(target);\n\n if (!affectsMatch) {\n sink.report(\n \"GR1008\",\n `the affects step ${JSON.stringify(target)} is not \\`<feature>\\` or \\`<feature>/<flow>\\`.`,\n at,\n );\n continue;\n }\n\n affects = { feature: affectsMatch[1] ?? \"\", flow: affectsMatch[2] ?? null };\n }\n\n steps.push({\n index: Number(match[1]),\n type,\n target,\n app,\n route,\n affects,\n note: match[4]?.trim() ?? null,\n at,\n });\n }\n\n const wrong = numbers.findIndex((entry, position) => entry.number !== position + 1);\n const first = numbers[wrong];\n\n if (first !== undefined) {\n sink.report(\n \"GR1010\",\n `step ${first.number} should be step ${wrong + 1}; number the steps 1, 2, 3 in order.`,\n lineAt(file, first.line),\n );\n }\n\n return steps;\n}\n\n/**\n * `## Story`: numbered sentences in the user's words. Indented lines continue\n * the item, image lines attach screenshots. GR1008 for any other line, GR1010\n * for numbers out of order.\n */\nfunction parseStory(\n file: string,\n document: WrittenDocument,\n sink: FindingSink,\n): WrittenStoryStep[] {\n const story: WrittenStoryStep[] = [];\n const numbers: { number: number; line: number }[] = [];\n let open: { step: WrittenStoryStep; text: string[] } | null = null;\n let continuing = false;\n\n const finish = (): void => {\n if (open !== null) open.step.text = open.text.join(\" \");\n\n open = null;\n };\n\n const attach = (line: BodyLine): void => {\n open?.step.screenshots.push(...readScreenshots(file, [line], sink));\n };\n\n for (const line of findSection(document, \"story\")?.lines ?? []) {\n const trimmed = line.text.trim();\n const at = lineAt(file, line.line);\n\n if (line.fenced) {\n continuing = false;\n continue;\n }\n\n if (trimmed === \"\") {\n continuing = false;\n continue;\n }\n\n const numbered = NUMBERED.exec(trimmed);\n\n if (numbered) {\n finish();\n\n const sentence = withoutImages(trimmed.replace(NUMBERED, \"\"));\n\n if (sentence === \"\") {\n sink.report(\n \"GR1008\",\n `the story line ${JSON.stringify(trimmed)} is not \\`<n>. <sentence>\\`.`,\n at,\n );\n continuing = false;\n continue;\n }\n\n const number = Number(numbered[1]);\n const step: WrittenStoryStep = { index: number, text: sentence, screenshots: [], at };\n\n numbers.push({ number, line: line.line });\n story.push(step);\n open = { step, text: [sentence] };\n continuing = true;\n attach(line);\n continue;\n }\n\n if (isImageLine(trimmed)) {\n if (open === null) {\n sink.report(\n \"GR1008\",\n `the story line ${JSON.stringify(trimmed)} is an image before any story step.`,\n at,\n );\n } else {\n attach(line);\n }\n\n continue;\n }\n\n if (open !== null && continuing && /^[ \\t]/.test(line.text)) {\n const more = withoutImages(trimmed);\n\n if (more !== \"\") open.text.push(more);\n\n attach(line);\n continue;\n }\n\n sink.report(\n \"GR1008\",\n `the story line ${JSON.stringify(trimmed)} is not \\`<n>. <sentence>\\`.`,\n at,\n );\n }\n\n finish();\n\n const wrong = numbers.findIndex((entry, position) => entry.number !== position + 1);\n const first = numbers[wrong];\n\n if (first !== undefined) {\n sink.report(\n \"GR1010\",\n `story step ${first.number} should be story step ${wrong + 1}; number the story steps 1, 2, 3 in order.`,\n lineAt(file, first.line),\n );\n }\n\n return story;\n}\n\nfunction parseCases(file: string, document: WrittenDocument, sink: FindingSink): WrittenCase[] {\n const cases: WrittenCase[] = [];\n\n for (const line of bulletLines(findSection(document, \"cases\")?.lines ?? [])) {\n const split = splitListLine(line.text, CASE_QUESTIONS);\n\n if (split === null) {\n sink.report(\n \"GR1011\",\n `the case ${JSON.stringify(line.text)} is not \\`- <question> <answer>\\`.`,\n lineAt(file, line.line),\n );\n continue;\n }\n\n const question = normalizeKey(split.name);\n const suffix = CRITERIA_SUFFIX.exec(split.text);\n const answer = suffix ? split.text.slice(0, suffix.index).trimEnd() : split.text;\n\n cases.push({\n question,\n fixed: (CASE_QUESTIONS as readonly string[]).includes(question),\n answer,\n doesNotApply: /^does not apply\\b/i.test(answer),\n criteria: suffix ? (suffix[1] ?? \"\").split(\",\").map((criterion) => criterion.trim()) : [],\n at: lineAt(file, line.line),\n });\n }\n\n return cases;\n}\n\nfunction parseCriteria(\n file: string,\n document: WrittenDocument,\n sink: FindingSink,\n): WrittenCriterion[] {\n const criteria: WrittenCriterion[] = [];\n const seen = new Set<number>();\n\n for (const line of bulletLines(findSection(document, \"acceptance criteria\")?.lines ?? [])) {\n const at = lineAt(file, line.line);\n const match = CRITERION.exec(line.text);\n\n if (!match) {\n sink.report(\n \"GR1013\",\n `the criterion ${JSON.stringify(line.text)} is not \\`- AC-<n> <text>\\` or \\`- AC-<n> [<app>] <text>\\`.`,\n at,\n );\n continue;\n }\n\n const number = Number(match[1]);\n\n if (seen.has(number)) {\n sink.report(\"GR1014\", `AC-${number} is used twice in this flow.`, at);\n continue;\n }\n\n seen.add(number);\n criteria.push({\n id: `AC-${number}`,\n number,\n app: match[2] ?? null,\n text: (match[3] ?? \"\").trim(),\n at,\n });\n }\n\n return criteria;\n}\n\n/** `grimoire/features/<feature>/flows/<name>.md`. */\nexport function parseFlow(\n file: string,\n text: string,\n feature: string,\n name: string,\n sink: FindingSink,\n): WrittenFlow {\n const document = readDocument(file, text, \"required\", sink);\n const fields = new FrontMatterReader(document, sink);\n\n fields.onlyKeys([\"id\", \"since\", \"status\", \"who\", \"origin\"], \"flow\");\n\n const id = fields.required(\"id\", checks.id);\n sameAsName(id, name, \"flow id\", sink);\n\n const flow: WrittenFlow = {\n file,\n feature,\n id,\n ref: `${feature}/${name}`,\n since: fields.required(\"since\", checks.version),\n status: fields.oneOf(\"status\", STATUSES, FALLBACK_STATUS),\n who: fields.required(\"who\", checks.text),\n origin: fields.optionalOneOf(\"origin\", ORIGINS),\n heading: heading(document),\n summary: paragraphAfterTitle(document),\n story: [],\n steps: [],\n differs: [],\n cases: [],\n notHandled: [],\n unknowns: [],\n criteria: [],\n };\n\n checkHeadings(\n document,\n {\n title: true,\n required: [\"Steps\", \"Cases\", \"Acceptance criteria\"],\n optional: [\"Story\", \"Differs by app\", \"Not handled\"],\n },\n sink,\n );\n\n if (flow.summary === null) {\n sink.report(\n \"GR1030\",\n \"the flow has no summary; write one or two sentences under the title.\",\n lineAt(file, document.title?.line ?? document.bodyStartLine),\n );\n }\n\n flow.story = parseStory(file, document, sink);\n flow.steps = parseSteps(file, document, sink);\n flow.differs = readListLines(\n file,\n findSection(document, \"differs by app\")?.lines,\n \"Differs by app\",\n sink,\n );\n flow.cases = parseCases(file, document, sink);\n flow.notHandled = readListLines(\n file,\n findSection(document, \"not handled\")?.lines,\n \"Not handled\",\n sink,\n CASE_QUESTIONS,\n );\n flow.criteria = parseCriteria(file, document, sink);\n\n for (const line of document.body) {\n const trimmed = line.text.trim();\n\n if (!line.fenced && trimmed.startsWith(\"Unknown:\")) {\n flow.unknowns.push({\n text: trimmed.slice(\"Unknown:\".length).trim(),\n at: lineAt(file, line.line),\n });\n }\n }\n\n const cases = findSection(document, \"cases\");\n\n if (cases !== null) {\n const answered = new Set([\n ...flow.cases.map((entry) => entry.question),\n ...flow.notHandled.map((entry) => normalizeKey(entry.name)),\n ]);\n\n const readOnly = isReadOnlyFlow(flow.steps);\n\n for (const question of CASE_QUESTIONS) {\n if (readOnly && (WRITE_ONLY_QUESTIONS as readonly string[]).includes(question)) continue;\n\n if (!answered.has(question)) {\n sink.report(\n \"GR1012\",\n `the case question \"${question}\" is answered neither under Cases nor under Not handled.`,\n lineAt(file, cases.line),\n );\n }\n }\n }\n\n return flow;\n}\n\n/** Case questions a flow with no writes may leave out. */\nconst WRITE_ONLY_QUESTIONS = [\"duplicate\", \"double submit\"];\n\nconst SAFE_METHODS = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\n/**\n * A flow writes nothing when it has steps and every one is a page or a route\n * with a safe method (`GET`, `HEAD`, `OPTIONS`). Any other step (a write route,\n * mail, job, event, affects, outside service) or no steps at all counts as a write.\n */\nfunction isReadOnlyFlow(steps: readonly WrittenStep[]): boolean {\n if (steps.length === 0) return false;\n\n return steps.every(\n (step) =>\n step.type === \"page\" ||\n (step.type === \"route\" && step.route !== null && SAFE_METHODS.has(step.route.method)),\n );\n}\n\n// ── Version briefs ─────────────────────────────────────────────────────────\n\n/** `grimoire/features/<feature>/versions/v<n>.md`: free text under a title. */\nexport function parseVersionBrief(\n file: string,\n text: string,\n feature: string,\n major: number,\n sink: FindingSink,\n): WrittenVersionBrief {\n const document = readDocument(file, text, \"none\", sink);\n\n new FrontMatterReader(document, sink).onlyKeys([], \"a version brief\");\n\n return { file, feature, major, heading: heading(document) };\n}\n"],"mappings":";;;;;;AAwCA,MAAa,WAAqC;CAAC;CAAY;CAAY;CAAW;AAAS;AAC/F,MAAa,UAAoC,CAAC,YAAY,WAAW;AACzE,MAAa,eAAsC;CAAC;CAAS;CAAW;CAAS;AAAS;;AAE1F,MAAa,aAAkC;CAC7C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAM,kBAAiC;AAKvC,MAAM,OAAO,IAAI,OACf,OAAO,GAAG,kBAAkB,WAAW,KAAK,GAAG,EAAE,+CACnD;AACA,MAAM,gBAAgB,IAAI,OAAO,OAAO,GAAG,wBAAwB,IAAI,QAAQ;AAC/E,MAAM,kBAAkB;AACxB,MAAM,WAAW;AACjB,MAAM,cAAc;AACpB,MAAM,eAAe;AACrB,MAAM,iBAAiB;AACvB,MAAM,YAAY;AAClB,MAAM,kBAAkB;AACxB,MAAM,kBAAkB;AACxB,MAAM,qBAAqB;AAC3B,MAAM,cAAc;AACpB,MAAM,kBAAkB;AACxB,MAAM,mBACJ;AAEF,SAAS,QAAQ,UAA4D;CAC3E,OAAO,SAAS,QACZ;EAAE,OAAO,SAAS,MAAM;EAAM,IAAI,OAAO,SAAS,MAAM,SAAS,MAAM,IAAI;CAAE,IAC7E;AACN;;AAGA,SAAS,WACP,SACA,MACA,MACA,MACM;CACN,IAAI,QAAQ,UAAU,MAAM,QAAQ,UAAU,MAC5C,KAAK,OACH,UACA,OAAO,KAAK,GAAG,KAAK,UAAU,QAAQ,KAAK,EAAE,kBAAkB,KAAK,UAAU,IAAI,EAAE,SACpF,QAAQ,EACV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flow`. The rule for what the block shows lives there. Do not restate it.
285
285
  - **Who sees it** uses the app's condition names, and the check reports a name the README does
286
- not declare (`GR5002`). **Changes with** is free text: it is not checked, but starting an item
287
- with a condition name (`vip: member prices`) keeps it readable.
286
+ not declare (`GR5002`). **Changes with** is mostly free text: starting an item
287
+ with a condition name (`vip: member prices`) is checked like Who sees it (`GR5002`), and a name written in backticks
288
+ (`` `vip` ``) that the README does not declare is a warning (`GR5010`). Plain text is never reported, so write
289
+ a condition in backticks only when it is one.
288
290
  - Do not list blocks that come from the layout.
289
291
 
290
292
  ## A layout
@@ -345,7 +347,7 @@ npx warlock grimoire check
345
347
 
346
348
  It reports a block that points to a flow that does not exist, a condition that is not declared in
347
349
  the app README, a page whose route is gone, a screen with no route (file-based apps), and a
348
- feature that lists an app with no folder here. Its codes are `GR5001` to `GR5009`;
350
+ feature that lists an app with no folder here. Its codes are `GR5001` to `GR5010`;
349
351
  `npx warlock explain GR5003` describes one.
350
352
 
351
353
 
@@ -670,6 +672,7 @@ that is still `proposed`; it does not fail the check.
670
672
 
671
673
  - **Exports, imports, importers, routes, middleware, pages:** read from the code. Trust them.
672
674
  - **Route middleware:** a route step also reaches the middleware files the matched route names (not the routes file's other imports). Roles that run by being present (migration, seed, command, main, layout, root) and spec-only helpers are not listed as unreached.
675
+ - **Dev tab route facts:** the dev tab reads routes, events and jobs from the running dev server (nothing is booted twice), so it shows `routes: fresh` on the first open; they are read once, so rebuild with `warlock grimoire build` after changing routes.
673
676
  - **Without route facts** (`routes: missing`): route, mail, notification, job and event steps are `found: null` (not checked), not resolved and not failed; `GR5008` skips mail and notification entries.
674
677
  - **Files behind a route:** every file the handler can reach through imports. It is not the exact
675
678
  call path; open the handler to see which ones it really uses.
@@ -939,7 +942,8 @@ pages, or its screens for a mobile app). Without brackets it looks in the apps t
939
942
  **Cases.** End a case line with `(AC-n)` (or `(AC-1, AC-2)`) to link it to the criterion that
940
943
  proves it; a number the flow does not have is an error (`GR2013`). Answer all eight questions (invalid input, not allowed, not found, duplicate, limits,
941
944
  expiry, double submit, outside service down), each with a case or "does not apply" and the
942
- reason. A flow that skips one gets a finding. Do not invent cases beyond the questions unless the owner described one.
945
+ reason. A flow that skips one gets a finding, except that a flow with no writes (only pages and
946
+ `GET` routes) may leave out `duplicate` and `double submit`. Do not invent cases beyond the questions unless the owner described one.
943
947
 
944
948
  **Criteria.** One per case that changes what the user gets. Number them `AC-1`, `AC-2`, … and
945
949
  never renumber. Scope one to an app with `[app-id]`.
package/package.json CHANGED
@@ -26,15 +26,15 @@
26
26
  "environment": "server"
27
27
  },
28
28
  "peerDependencies": {
29
- "@warlock.js/core": "5.60.0",
30
- "@warlock.js/web": "5.60.0"
29
+ "@warlock.js/core": "5.61.0",
30
+ "@warlock.js/web": "5.61.0"
31
31
  },
32
32
  "peerDependenciesMeta": {
33
33
  "@warlock.js/web": {
34
34
  "optional": true
35
35
  }
36
36
  },
37
- "version": "5.60.0",
37
+ "version": "5.61.0",
38
38
  "type": "module",
39
39
  "main": "./esm/index.mjs",
40
40
  "module": "./esm/index.mjs",
@@ -108,8 +108,10 @@ The first page a visitor sees.
108
108
  preferences are a few rows, not six pages.
109
109
  - **Flow** is `feature/flow`. The rule for what the block shows lives there. Do not restate it.
110
110
  - **Who sees it** uses the app's condition names, and the check reports a name the README does
111
- not declare (`GR5002`). **Changes with** is free text: it is not checked, but starting an item
112
- with a condition name (`vip: member prices`) keeps it readable.
111
+ not declare (`GR5002`). **Changes with** is mostly free text: starting an item
112
+ with a condition name (`vip: member prices`) is checked like Who sees it (`GR5002`), and a name written in backticks
113
+ (`` `vip` ``) that the README does not declare is a warning (`GR5010`). Plain text is never reported, so write
114
+ a condition in backticks only when it is one.
113
115
  - Do not list blocks that come from the layout.
114
116
 
115
117
  ## A layout
@@ -170,5 +172,5 @@ npx warlock grimoire check
170
172
 
171
173
  It reports a block that points to a flow that does not exist, a condition that is not declared in
172
174
  the app README, a page whose route is gone, a screen with no route (file-based apps), and a
173
- feature that lists an app with no folder here. Its codes are `GR5001` to `GR5009`;
175
+ feature that lists an app with no folder here. Its codes are `GR5001` to `GR5010`;
174
176
  `npx warlock explain GR5003` describes one.
@@ -85,6 +85,7 @@ that is still `proposed`; it does not fail the check.
85
85
 
86
86
  - **Exports, imports, importers, routes, middleware, pages:** read from the code. Trust them.
87
87
  - **Route middleware:** a route step also reaches the middleware files the matched route names (not the routes file's other imports). Roles that run by being present (migration, seed, command, main, layout, root) and spec-only helpers are not listed as unreached.
88
+ - **Dev tab route facts:** the dev tab reads routes, events and jobs from the running dev server (nothing is booted twice), so it shows `routes: fresh` on the first open; they are read once, so rebuild with `warlock grimoire build` after changing routes.
88
89
  - **Without route facts** (`routes: missing`): route, mail, notification, job and event steps are `found: null` (not checked), not resolved and not failed; `GR5008` skips mail and notification entries.
89
90
  - **Files behind a route:** every file the handler can reach through imports. It is not the exact
90
91
  call path; open the handler to see which ones it really uses.
@@ -177,7 +177,8 @@ pages, or its screens for a mobile app). Without brackets it looks in the apps t
177
177
  **Cases.** End a case line with `(AC-n)` (or `(AC-1, AC-2)`) to link it to the criterion that
178
178
  proves it; a number the flow does not have is an error (`GR2013`). Answer all eight questions (invalid input, not allowed, not found, duplicate, limits,
179
179
  expiry, double submit, outside service down), each with a case or "does not apply" and the
180
- reason. A flow that skips one gets a finding. Do not invent cases beyond the questions unless the owner described one.
180
+ reason. A flow that skips one gets a finding, except that a flow with no writes (only pages and
181
+ `GET` routes) may leave out `duplicate` and `double submit`. Do not invent cases beyond the questions unless the owner described one.
181
182
 
182
183
  **Criteria.** One per case that changes what the user gets. Number them `AC-1`, `AC-2`, … and
183
184
  never renumber. Scope one to an app with `[app-id]`.