@warlock.js/grimoire 5.56.0 → 5.58.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 +35 -0
- package/esm/book/build.d.mts.map +1 -1
- package/esm/book/build.mjs +2 -1
- package/esm/book/build.mjs.map +1 -1
- package/esm/book/render.mjs +10 -0
- package/esm/book/render.mjs.map +1 -1
- package/esm/bookmap/build.d.mts.map +1 -1
- package/esm/bookmap/build.mjs +2 -2
- package/esm/bookmap/build.mjs.map +1 -1
- package/esm/bookmap/steps.mjs +53 -38
- package/esm/bookmap/steps.mjs.map +1 -1
- package/esm/check/check-grimoire.d.mts.map +1 -1
- package/esm/check/check-grimoire.mjs +4 -1
- package/esm/check/check-grimoire.mjs.map +1 -1
- package/esm/check/rules/criteria.mjs +21 -2
- package/esm/check/rules/criteria.mjs.map +1 -1
- package/esm/check/rules/screenshots.mjs +57 -0
- package/esm/check/rules/screenshots.mjs.map +1 -0
- package/esm/codes/codes.d.mts +12 -0
- package/esm/codes/codes.d.mts.map +1 -1
- package/esm/codes/codes.mjs +6 -0
- package/esm/codes/codes.mjs.map +1 -1
- package/esm/contracts/adapter.d.mts +6 -0
- package/esm/contracts/adapter.d.mts.map +1 -1
- package/esm/contracts/book.d.mts +2 -0
- package/esm/contracts/book.d.mts.map +1 -1
- package/esm/contracts/book.mjs.map +1 -1
- package/esm/contracts/bookmap.d.mts +19 -1
- package/esm/contracts/bookmap.d.mts.map +1 -1
- package/esm/contracts/snapshot.d.mts +11 -0
- package/esm/contracts/snapshot.d.mts.map +1 -1
- package/esm/contracts/test-results.d.mts +34 -0
- package/esm/contracts/test-results.d.mts.map +1 -1
- package/esm/contracts/written.d.mts +44 -0
- package/esm/contracts/written.d.mts.map +1 -1
- package/esm/contracts/written.mjs.map +1 -1
- package/esm/devtools/data.mjs +126 -4
- package/esm/devtools/data.mjs.map +1 -1
- package/esm/devtools/index.d.mts +31 -1
- package/esm/devtools/index.d.mts.map +1 -1
- package/esm/devtools/index.mjs +94 -5
- package/esm/devtools/index.mjs.map +1 -1
- package/esm/devtools/product-map.d.mts +14 -0
- package/esm/devtools/product-map.d.mts.map +1 -0
- package/esm/devtools/product-map.mjs +385 -0
- package/esm/devtools/product-map.mjs.map +1 -0
- package/esm/devtools/site.d.mts.map +1 -1
- package/esm/devtools/site.mjs +97 -21
- package/esm/devtools/site.mjs.map +1 -1
- package/esm/devtools/snapshot-source.mjs +71 -22
- package/esm/devtools/snapshot-source.mjs.map +1 -1
- package/esm/graph/index.d.mts +10 -1
- package/esm/graph/index.d.mts.map +1 -1
- package/esm/graph/index.mjs +3 -2
- package/esm/graph/index.mjs.map +1 -1
- package/esm/index.d.mts +4 -4
- package/esm/paths/index.d.mts +2 -0
- package/esm/paths/index.d.mts.map +1 -1
- package/esm/paths/index.mjs +3 -1
- package/esm/paths/index.mjs.map +1 -1
- package/esm/scry/compact.mjs +169 -0
- package/esm/scry/compact.mjs.map +1 -0
- package/esm/scry/format.d.mts.map +1 -1
- package/esm/scry/format.mjs +7 -1
- package/esm/scry/format.mjs.map +1 -1
- package/esm/scry/query.d.mts.map +1 -1
- package/esm/scry/query.mjs +12 -1
- package/esm/scry/query.mjs.map +1 -1
- package/esm/test-results/index.d.mts +7 -2
- package/esm/test-results/index.d.mts.map +1 -1
- package/esm/test-results/index.mjs +79 -12
- package/esm/test-results/index.mjs.map +1 -1
- package/esm/vitest/index.d.mts +6 -0
- package/esm/vitest/index.d.mts.map +1 -1
- package/esm/vitest/index.mjs +22 -6
- package/esm/vitest/index.mjs.map +1 -1
- package/esm/warlock/adapter.d.mts.map +1 -1
- package/esm/warlock/adapter.mjs +6 -2
- package/esm/warlock/adapter.mjs.map +1 -1
- package/esm/warlock/mcp-tools.mjs +48 -12
- package/esm/warlock/mcp-tools.mjs.map +1 -1
- package/esm/workspace/index.d.mts.map +1 -1
- package/esm/workspace/index.mjs +4 -2
- package/esm/workspace/index.mjs.map +1 -1
- package/esm/written/apps.mjs +4 -2
- package/esm/written/apps.mjs.map +1 -1
- package/esm/written/features.mjs +119 -6
- package/esm/written/features.mjs.map +1 -1
- package/esm/written/markdown.mjs +66 -1
- package/esm/written/markdown.mjs.map +1 -1
- package/esm/written/parse-grimoire.d.mts.map +1 -1
- package/esm/written/parse-grimoire.mjs +1 -1
- package/esm/written/parse-grimoire.mjs.map +1 -1
- package/llms-full.txt +77 -2
- package/package.json +3 -3
- package/skills/backfill-a-grimoire/SKILL.md +5 -0
- package/skills/describe-an-app/SKILL.md +12 -0
- package/skills/record-a-change/SKILL.md +8 -0
- package/skills/use-the-grimoire/SKILL.md +15 -0
- package/skills/write-a-feature/SKILL.md +37 -2
- package/ui/grimoire-static.js +4 -0
- package/ui/grimoire-view.js +2283 -428
- package/ui/grimoire.css +1036 -45
- package/ui/product-map.css +636 -0
- package/ui/product-map.js +817 -0
package/esm/written/features.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CASE_QUESTIONS } from "../contracts/written.mjs";
|
|
2
|
-
import { checkHeadings, findSection, lineAt, logicalLines, normalizeKey, paragraphAfterTitle, readDocument } from "./markdown.mjs";
|
|
2
|
+
import { checkHeadings, findSection, isImageLine, lineAt, logicalLines, normalizeKey, paragraphAfterTitle, readDocument, readScreenshots, withoutImages } from "./markdown.mjs";
|
|
3
3
|
import { FrontMatterReader, ID, SEP, VERSION, checks, isDate, projectFolder } from "./fields.mjs";
|
|
4
4
|
import { BULLET, bulletLines, readListLines, splitListLine } from "./lists.mjs";
|
|
5
5
|
|
|
@@ -75,6 +75,22 @@ function splitEntryText(text) {
|
|
|
75
75
|
text: rest
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
+
/** `## Why`: the paragraphs of the section, joined with a blank line; `null` when absent or empty. */
|
|
79
|
+
function readWhy(document) {
|
|
80
|
+
const paragraphs = [];
|
|
81
|
+
let open = [];
|
|
82
|
+
const close = () => {
|
|
83
|
+
if (open.length > 0) paragraphs.push(open.join(" "));
|
|
84
|
+
open = [];
|
|
85
|
+
};
|
|
86
|
+
for (const line of findSection(document, "why")?.lines ?? []) {
|
|
87
|
+
const trimmed = line.text.trim();
|
|
88
|
+
if (line.fenced || trimmed === "") close();
|
|
89
|
+
else open.push(trimmed);
|
|
90
|
+
}
|
|
91
|
+
close();
|
|
92
|
+
return paragraphs.length > 0 ? paragraphs.join("\n\n") : null;
|
|
93
|
+
}
|
|
78
94
|
/** `grimoire/features/<id>/README.md`. */
|
|
79
95
|
function parseFeatureReadme(file, text, folder, sink) {
|
|
80
96
|
const document = readDocument(file, text, "required", sink);
|
|
@@ -87,7 +103,8 @@ function parseFeatureReadme(file, text, folder, sink) {
|
|
|
87
103
|
"updated",
|
|
88
104
|
"apps",
|
|
89
105
|
"folders",
|
|
90
|
-
"origin"
|
|
106
|
+
"origin",
|
|
107
|
+
"audience"
|
|
91
108
|
], "feature README");
|
|
92
109
|
const id = fields.required("id", checks.id);
|
|
93
110
|
sameAsName(id, folder, "feature id", sink);
|
|
@@ -110,13 +127,22 @@ function parseFeatureReadme(file, text, folder, sink) {
|
|
|
110
127
|
origin: fields.optionalOneOf("origin", ORIGINS),
|
|
111
128
|
heading: heading(document),
|
|
112
129
|
summary: paragraphAfterTitle(document),
|
|
130
|
+
audience: fields.list("audience", {
|
|
131
|
+
required: false,
|
|
132
|
+
check: checks.text
|
|
133
|
+
}),
|
|
134
|
+
why: readWhy(document),
|
|
113
135
|
flows: [],
|
|
114
136
|
relations: []
|
|
115
137
|
};
|
|
116
138
|
checkHeadings(document, {
|
|
117
139
|
title: true,
|
|
118
140
|
required: [],
|
|
119
|
-
optional: [
|
|
141
|
+
optional: [
|
|
142
|
+
"Why",
|
|
143
|
+
"Flows",
|
|
144
|
+
"Affects and affected by"
|
|
145
|
+
]
|
|
120
146
|
}, sink);
|
|
121
147
|
for (const flow of readListLines(file, findSection(document, "flows")?.lines, "Flows", sink)) {
|
|
122
148
|
if (!ID.test(flow.name)) {
|
|
@@ -280,6 +306,82 @@ function parseSteps(file, document, sink) {
|
|
|
280
306
|
if (first !== void 0) sink.report("GR1010", `step ${first.number} should be step ${wrong + 1}; number the steps 1, 2, 3 in order.`, lineAt(file, first.line));
|
|
281
307
|
return steps;
|
|
282
308
|
}
|
|
309
|
+
/**
|
|
310
|
+
* `## Story`: numbered sentences in the user's words. Indented lines continue
|
|
311
|
+
* the item, image lines attach screenshots. GR1008 for any other line, GR1010
|
|
312
|
+
* for numbers out of order.
|
|
313
|
+
*/
|
|
314
|
+
function parseStory(file, document, sink) {
|
|
315
|
+
const story = [];
|
|
316
|
+
const numbers = [];
|
|
317
|
+
let open = null;
|
|
318
|
+
let continuing = false;
|
|
319
|
+
const finish = () => {
|
|
320
|
+
if (open !== null) open.step.text = open.text.join(" ");
|
|
321
|
+
open = null;
|
|
322
|
+
};
|
|
323
|
+
const attach = (line) => {
|
|
324
|
+
open?.step.screenshots.push(...readScreenshots(file, [line], sink));
|
|
325
|
+
};
|
|
326
|
+
for (const line of findSection(document, "story")?.lines ?? []) {
|
|
327
|
+
const trimmed = line.text.trim();
|
|
328
|
+
const at = lineAt(file, line.line);
|
|
329
|
+
if (line.fenced) {
|
|
330
|
+
continuing = false;
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (trimmed === "") {
|
|
334
|
+
continuing = false;
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
const numbered = NUMBERED.exec(trimmed);
|
|
338
|
+
if (numbered) {
|
|
339
|
+
finish();
|
|
340
|
+
const sentence = withoutImages(trimmed.replace(NUMBERED, ""));
|
|
341
|
+
if (sentence === "") {
|
|
342
|
+
sink.report("GR1008", `the story line ${JSON.stringify(trimmed)} is not \`<n>. <sentence>\`.`, at);
|
|
343
|
+
continuing = false;
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
const number = Number(numbered[1]);
|
|
347
|
+
const step = {
|
|
348
|
+
index: number,
|
|
349
|
+
text: sentence,
|
|
350
|
+
screenshots: [],
|
|
351
|
+
at
|
|
352
|
+
};
|
|
353
|
+
numbers.push({
|
|
354
|
+
number,
|
|
355
|
+
line: line.line
|
|
356
|
+
});
|
|
357
|
+
story.push(step);
|
|
358
|
+
open = {
|
|
359
|
+
step,
|
|
360
|
+
text: [sentence]
|
|
361
|
+
};
|
|
362
|
+
continuing = true;
|
|
363
|
+
attach(line);
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
if (isImageLine(trimmed)) {
|
|
367
|
+
if (open === null) sink.report("GR1008", `the story line ${JSON.stringify(trimmed)} is an image before any story step.`, at);
|
|
368
|
+
else attach(line);
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (open !== null && continuing && /^[ \t]/.test(line.text)) {
|
|
372
|
+
const more = withoutImages(trimmed);
|
|
373
|
+
if (more !== "") open.text.push(more);
|
|
374
|
+
attach(line);
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
sink.report("GR1008", `the story line ${JSON.stringify(trimmed)} is not \`<n>. <sentence>\`.`, at);
|
|
378
|
+
}
|
|
379
|
+
finish();
|
|
380
|
+
const wrong = numbers.findIndex((entry, position) => entry.number !== position + 1);
|
|
381
|
+
const first = numbers[wrong];
|
|
382
|
+
if (first !== void 0) sink.report("GR1010", `story step ${first.number} should be story step ${wrong + 1}; number the story steps 1, 2, 3 in order.`, lineAt(file, first.line));
|
|
383
|
+
return story;
|
|
384
|
+
}
|
|
283
385
|
function parseCases(file, document, sink) {
|
|
284
386
|
const cases = [];
|
|
285
387
|
for (const line of bulletLines(findSection(document, "cases")?.lines ?? [])) {
|
|
@@ -289,11 +391,14 @@ function parseCases(file, document, sink) {
|
|
|
289
391
|
continue;
|
|
290
392
|
}
|
|
291
393
|
const question = normalizeKey(split.name);
|
|
394
|
+
const suffix = CRITERIA_SUFFIX.exec(split.text);
|
|
395
|
+
const answer = suffix ? split.text.slice(0, suffix.index).trimEnd() : split.text;
|
|
292
396
|
cases.push({
|
|
293
397
|
question,
|
|
294
398
|
fixed: CASE_QUESTIONS.includes(question),
|
|
295
|
-
answer
|
|
296
|
-
doesNotApply: /^does not apply\b/i.test(
|
|
399
|
+
answer,
|
|
400
|
+
doesNotApply: /^does not apply\b/i.test(answer),
|
|
401
|
+
criteria: suffix ? (suffix[1] ?? "").split(",").map((criterion) => criterion.trim()) : [],
|
|
297
402
|
at: lineAt(file, line.line)
|
|
298
403
|
});
|
|
299
404
|
}
|
|
@@ -348,6 +453,8 @@ function parseFlow(file, text, feature, name, sink) {
|
|
|
348
453
|
who: fields.required("who", checks.text),
|
|
349
454
|
origin: fields.optionalOneOf("origin", ORIGINS),
|
|
350
455
|
heading: heading(document),
|
|
456
|
+
summary: paragraphAfterTitle(document),
|
|
457
|
+
story: [],
|
|
351
458
|
steps: [],
|
|
352
459
|
differs: [],
|
|
353
460
|
cases: [],
|
|
@@ -362,8 +469,14 @@ function parseFlow(file, text, feature, name, sink) {
|
|
|
362
469
|
"Cases",
|
|
363
470
|
"Acceptance criteria"
|
|
364
471
|
],
|
|
365
|
-
optional: [
|
|
472
|
+
optional: [
|
|
473
|
+
"Story",
|
|
474
|
+
"Differs by app",
|
|
475
|
+
"Not handled"
|
|
476
|
+
]
|
|
366
477
|
}, sink);
|
|
478
|
+
if (flow.summary === null) sink.report("GR1030", "the flow has no summary; write one or two sentences under the title.", lineAt(file, document.title?.line ?? document.bodyStartLine));
|
|
479
|
+
flow.story = parseStory(file, document, sink);
|
|
367
480
|
flow.steps = parseSteps(file, document, sink);
|
|
368
481
|
flow.differs = readListLines(file, findSection(document, "differs by app")?.lines, "Differs by app", sink);
|
|
369
482
|
flow.cases = parseCases(file, document, 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 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 lineAt,\n logicalLines,\n normalizeKey,\n paragraphAfterTitle,\n readDocument,\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/** `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\"],\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 flows: [],\n relations: [],\n };\n\n checkHeadings(\n document,\n { title: true, required: [], optional: [\"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\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\n cases.push({\n question,\n fixed: (CASE_QUESTIONS as readonly string[]).includes(question),\n answer: split.text,\n doesNotApply: /^does not apply\\b/i.test(split.text),\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 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: [\"Differs by app\", \"Not handled\"],\n },\n sink,\n );\n\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":";;;;;;AAmCA,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,K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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,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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
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import { readFrontMatter } from "../front-matter/index.mjs";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
|
|
3
4
|
//#region ../../packages/grimoire/src/written/markdown.ts
|
|
5
|
+
/**
|
|
6
|
+
* One pass over a written file's lines: front matter, headings, `##`
|
|
7
|
+
* sections and the logical lines of a list section. Every parser of a
|
|
8
|
+
* written file starts from the `WrittenDocument` this module builds, so a
|
|
9
|
+
* file is split once and scanned line by line, never re-scanned whole.
|
|
10
|
+
*/
|
|
4
11
|
const HEADING = /^(#{1,6})[ \t]+(.+?)(?:[ \t]+#+)?$/;
|
|
5
12
|
const FENCE = /^[ \t]*(?:```|~~~)/;
|
|
6
13
|
const ITEM_START = /^(?:[-*][ \t]|\d+\.[ \t])/;
|
|
14
|
+
const IMAGE = /!\[([^\]]*)\]\(\s*<?([^)\s>]+)>?(?:\s+(?:"[^"]*"|'[^']*'))?\s*\)/g;
|
|
15
|
+
const IMAGE_ONLY = /^(?:!\[[^\]]*\]\([^)]*\)\s*)+$/;
|
|
16
|
+
/** Where screenshots live, relative to the project root. */
|
|
17
|
+
const SCREENSHOTS_DIR = "grimoire/screenshots/";
|
|
7
18
|
/** Lower-case a heading or a question and collapse its spaces. */
|
|
8
19
|
function normalizeKey(text) {
|
|
9
20
|
return text.trim().replace(/\s+/g, " ").toLowerCase();
|
|
@@ -158,6 +169,7 @@ function paragraphAfterTitle(document) {
|
|
|
158
169
|
if (parts.length > 0) break;
|
|
159
170
|
continue;
|
|
160
171
|
}
|
|
172
|
+
if (IMAGE_ONLY.test(trimmed)) continue;
|
|
161
173
|
parts.push(trimmed);
|
|
162
174
|
}
|
|
163
175
|
return parts.length > 0 ? parts.join(" ") : null;
|
|
@@ -167,7 +179,60 @@ function textAfterTitle(document, endLine) {
|
|
|
167
179
|
const from = document.title?.line ?? 0;
|
|
168
180
|
return document.body.filter((bodyLine) => bodyLine.line > from && (endLine === void 0 || bodyLine.line < endLine)).map((bodyLine) => bodyLine.text).join("\n").trim();
|
|
169
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* The path under `grimoire/screenshots/` an image line points at, or `null`
|
|
184
|
+
* when it points elsewhere. The path is relative to the Markdown file, or
|
|
185
|
+
* starts with `/grimoire/screenshots/`.
|
|
186
|
+
*/
|
|
187
|
+
function screenshotPath(file, written) {
|
|
188
|
+
const target = written.replace(/[?#].*$/, "").replace(/\\/g, "/");
|
|
189
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(target) || target.startsWith("//")) return null;
|
|
190
|
+
const resolved = target.startsWith("/") ? path.posix.normalize(target.slice(1)) : path.posix.join(path.posix.dirname(file.replace(/\\/g, "/")), target);
|
|
191
|
+
const normal = path.posix.normalize(resolved);
|
|
192
|
+
if (!normal.startsWith(SCREENSHOTS_DIR) || normal.length === 21) return null;
|
|
193
|
+
return normal.slice(21);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The image lines `` of some body lines, outside code fences.
|
|
197
|
+
* GR1029 (warning) for a path that is not inside `grimoire/screenshots/`;
|
|
198
|
+
* the screenshot is kept with `path: null`.
|
|
199
|
+
*/
|
|
200
|
+
function readScreenshots(file, lines, sink) {
|
|
201
|
+
const screenshots = [];
|
|
202
|
+
for (const bodyLine of lines) {
|
|
203
|
+
if (bodyLine.fenced) continue;
|
|
204
|
+
for (const match of bodyLine.text.matchAll(IMAGE)) {
|
|
205
|
+
const written = match[2] ?? "";
|
|
206
|
+
const resolved = screenshotPath(file, decodeUri(written));
|
|
207
|
+
const at = lineAt(file, bodyLine.line);
|
|
208
|
+
if (resolved === null) sink.report("GR1029", `the image ${JSON.stringify(written)} is not inside grimoire/screenshots/.`, at);
|
|
209
|
+
screenshots.push({
|
|
210
|
+
alt: (match[1] ?? "").trim(),
|
|
211
|
+
written,
|
|
212
|
+
path: resolved,
|
|
213
|
+
at
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return screenshots;
|
|
218
|
+
}
|
|
219
|
+
/** `%20` and the like in an image path; a malformed escape is kept as written. */
|
|
220
|
+
function decodeUri(value) {
|
|
221
|
+
try {
|
|
222
|
+
return decodeURI(value);
|
|
223
|
+
} catch {
|
|
224
|
+
return value;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/** A line that holds only image markup. */
|
|
228
|
+
function isImageLine(text) {
|
|
229
|
+
return IMAGE_ONLY.test(text.trim());
|
|
230
|
+
}
|
|
231
|
+
/** The line with its image markup removed, trimmed. */
|
|
232
|
+
function withoutImages(text) {
|
|
233
|
+
return text.replace(IMAGE, "").replace(/\s+/g, " ").trim();
|
|
234
|
+
}
|
|
170
235
|
|
|
171
236
|
//#endregion
|
|
172
|
-
export { checkHeadings, findSection, lineAt, logicalLines, normalizeKey, paragraphAfterTitle, readDocument, splitLines, textAfterTitle };
|
|
237
|
+
export { checkHeadings, findSection, isImageLine, lineAt, logicalLines, normalizeKey, paragraphAfterTitle, readDocument, readScreenshots, screenshotPath, splitLines, textAfterTitle, withoutImages };
|
|
173
238
|
//# sourceMappingURL=markdown.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/markdown.ts"],"sourcesContent":["/**\n * One pass over a written file's lines: front matter, headings, `##`\n * sections and the logical lines of a list section. Every parser of a\n * written file starts from the `WrittenDocument` this module builds, so a\n * file is split once and scanned line by line, never re-scanned whole.\n */\nimport type { SourceLocation } from \"../contracts/location\";\nimport { readFrontMatter, type FrontMatterField } from \"../front-matter\";\nimport type { FindingSink } from \"./sink\";\n\n/** One line of the body, trailing whitespace (and `\\r`) removed. */\nexport type BodyLine = {\n text: string;\n /** 1-based line in the file. */\n line: number;\n /** Inside a fenced code block (the fence lines included). */\n fenced: boolean;\n};\n\n/** A Markdown heading outside code fences. */\nexport type Heading = {\n level: number;\n text: string;\n line: number;\n};\n\n/** A `##` heading and the body lines up to the next `#` or `##` heading. */\nexport type Section = {\n title: string;\n /** `title` lower-cased with single spaces, for comparing with the template. */\n key: string;\n line: number;\n lines: BodyLine[];\n};\n\n/** A written file split into its parts. */\nexport type WrittenDocument = {\n file: string;\n /** Every line of the file, `\\r` removed, trailing whitespace kept. */\n raw: string[];\n /** `null` when the file has no front matter (or it was never closed). */\n fields: Map<string, FrontMatterField> | null;\n /** The body lines (after the front matter). */\n body: BodyLine[];\n /** The first `#` heading. */\n title: Heading | null;\n /** Every `##` section, in order. */\n sections: Section[];\n /** 1-based line of the body's first line. */\n bodyStartLine: number;\n};\n\n/** A list item with its indented continuation lines joined by one space. */\nexport type LogicalLine = {\n text: string;\n line: number;\n};\n\nconst HEADING = /^(#{1,6})[ \\t]+(.+?)(?:[ \\t]+#+)?$/;\nconst FENCE = /^[ \\t]*(?:```|~~~)/;\nconst ITEM_START = /^(?:[-*][ \\t]|\\d+\\.[ \\t])/;\n\n/** Lower-case a heading or a question and collapse its spaces. */\nexport function normalizeKey(text: string): string {\n return text.trim().replace(/\\s+/g, \" \").toLowerCase();\n}\n\n/** Split text into lines on `\\n`, `\\r\\n` or a lone `\\r`. A leading BOM is dropped. */\nexport function splitLines(text: string): string[] {\n return text.replace(/^\\uFEFF/, \"\").split(/\\r\\n|\\r|\\n/);\n}\n\n/** A location of a whole line. */\nexport function lineAt(file: string, line: number): SourceLocation {\n return { file, line, column: null };\n}\n\n/**\n * Read a written file: its front matter (GR1001 when `frontMatter` is\n * `\"required\"` and the file has none; GR1002 for lines it cannot read),\n * then its headings and `##` sections.\n */\nexport function readDocument(\n file: string,\n text: string,\n frontMatter: \"required\" | \"none\",\n sink: FindingSink,\n): WrittenDocument {\n const raw = splitLines(text);\n let fields: Map<string, FrontMatterField> | null = null;\n let bodyStartLine = 1;\n\n if (frontMatter === \"required\" || raw[0]?.trim() === \"---\") {\n const result = readFrontMatter(raw.join(\"\\n\"), file);\n\n // A file with no front matter in its template may start with a `---`\n // rule that is never closed: that is body text, not a broken block.\n if (frontMatter === \"required\" || result.fields !== null) {\n for (const error of result.errors) sink.push(error);\n\n fields = result.fields;\n bodyStartLine = result.bodyStartLine;\n }\n\n if (fields === null && result.errors.length === 0 && frontMatter === \"required\") {\n sink.report(\n \"GR1001\",\n \"the file has no front matter; it must start with a `---` line.\",\n lineAt(file, 1),\n );\n }\n }\n\n const body: BodyLine[] = [];\n const headings: Heading[] = [];\n let inFence = false;\n\n for (let index = bodyStartLine - 1; index < raw.length; index++) {\n const text = (raw[index] ?? \"\").trimEnd();\n const line = index + 1;\n const fenceLine = FENCE.test(text);\n\n if (fenceLine) inFence = !inFence;\n\n const fenced = inFence || fenceLine;\n body.push({ text, line, fenced });\n\n if (fenced) continue;\n\n const heading = HEADING.exec(text);\n\n if (heading)\n headings.push({ level: (heading[1] ?? \"\").length, text: (heading[2] ?? \"\").trim(), line });\n }\n\n const sections: Section[] = [];\n let title: Heading | null = null;\n let current: Section | null = null;\n const firstBodyLine = body[0]?.line ?? bodyStartLine;\n let headingIndex = 0;\n\n for (const bodyLine of body) {\n const heading = headings[headingIndex];\n\n if (heading !== undefined && heading.line === bodyLine.line) {\n headingIndex++;\n\n if (heading.level === 1) {\n title ??= heading;\n current = null;\n continue;\n }\n\n if (heading.level === 2) {\n current = {\n title: heading.text,\n key: normalizeKey(heading.text),\n line: heading.line,\n lines: [],\n };\n sections.push(current);\n continue;\n }\n }\n\n current?.lines.push(bodyLine);\n }\n\n return {\n file,\n raw,\n fields,\n body,\n title,\n sections,\n bodyStartLine: Math.min(firstBodyLine, raw.length) || 1,\n };\n}\n\n/** The first section with this (normalised) title. */\nexport function findSection(document: WrittenDocument, key: string): Section | null {\n return document.sections.find((section) => section.key === key) ?? null;\n}\n\n/**\n * GR1006 for each required `##` heading that is missing (and for a missing\n * `#` title when `title` is required); GR1007 for each `##` heading the\n * template does not have, or one written twice.\n */\nexport function checkHeadings(\n document: WrittenDocument,\n template: { title: boolean; required: readonly string[]; optional: readonly string[] },\n sink: FindingSink,\n): void {\n const where = lineAt(document.file, document.title?.line ?? document.bodyStartLine);\n\n if (template.title && document.title === null) {\n sink.report(\"GR1006\", \"the file has no `# ` title heading.\", where);\n }\n\n for (const required of template.required) {\n if (!document.sections.some((section) => section.key === normalizeKey(required))) {\n sink.report(\"GR1006\", `the heading \"## ${required}\" is missing.`, where);\n }\n }\n\n const known = new Set([...template.required, ...template.optional].map(normalizeKey));\n const seen = new Set<string>();\n\n for (const section of document.sections) {\n if (!known.has(section.key)) {\n sink.report(\n \"GR1007\",\n `the heading \"## ${section.title}\" is not part of the template.`,\n lineAt(document.file, section.line),\n );\n } else if (seen.has(section.key)) {\n sink.report(\n \"GR1007\",\n `the heading \"## ${section.title}\" is written twice; only the first is read.`,\n lineAt(document.file, section.line),\n );\n }\n\n seen.add(section.key);\n }\n}\n\n/**\n * The logical lines of some body lines: a line that does not start with\n * whitespace (or that starts a list item) opens a new logical line, and the\n * indented lines right after it are joined to it with one space. Blank lines\n * and fenced lines end the current one.\n */\nexport function logicalLines(lines: readonly BodyLine[]): LogicalLine[] {\n const result: LogicalLine[] = [];\n let open: LogicalLine | null = null;\n\n for (const bodyLine of lines) {\n const trimmed = bodyLine.text.trim();\n\n if (bodyLine.fenced || trimmed === \"\") {\n open = null;\n continue;\n }\n\n const indented = /^[ \\t]/.test(bodyLine.text);\n\n if (open !== null && indented && !ITEM_START.test(trimmed)) {\n open.text = `${open.text} ${trimmed}`;\n continue;\n }\n\n open = { text: trimmed, line: bodyLine.line };\n result.push(open);\n }\n\n return result;\n}\n\n/** The first paragraph after the `# ` title: non-blank lines up to a blank line or a heading. */\nexport function paragraphAfterTitle(document: WrittenDocument): string | null {\n if (document.title === null) return null;\n\n const parts: string[] = [];\n\n for (const bodyLine of document.body) {\n if (bodyLine.line <= document.title.line) continue;\n\n const trimmed = bodyLine.text.trim();\n\n if (bodyLine.fenced || trimmed.startsWith(\"#\")) break;\n\n if (trimmed === \"\") {\n if (parts.length > 0) break;\n continue;\n }\n\n parts.push(trimmed);\n }\n\n return parts.length > 0 ? parts.join(\" \") : null;\n}\n\n/** The body text after the `# ` title (or the whole body), trimmed. */\nexport function textAfterTitle(document: WrittenDocument, endLine?: number): string {\n const from = document.title?.line ?? 0;\n\n return document.body\n .filter(\n (bodyLine) => bodyLine.line > from && (endLine === undefined || bodyLine.line < endLine),\n )\n .map((bodyLine) => bodyLine.text)\n .join(\"\\n\")\n .trim();\n}\n"],"mappings":";;;AA0DA,MAAM,UAAU;AAChB,MAAM,QAAQ;AACd,MAAM,aAAa;;AAGnB,SAAgB,aAAa,MAAsB;CACjD,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,QAAQ,GAAG,CAAC,CAAC,YAAY;AACtD;;AAGA,SAAgB,WAAW,MAAwB;CACjD,OAAO,KAAK,QAAQ,WAAW,EAAE,CAAC,CAAC,MAAM,YAAY;AACvD;;AAGA,SAAgB,OAAO,MAAc,MAA8B;CACjE,OAAO;EAAE;EAAM;EAAM,QAAQ;CAAK;AACpC;;;;;;AAOA,SAAgB,aACd,MACA,MACA,aACA,MACiB;CACjB,MAAM,MAAM,WAAW,IAAI;CAC3B,IAAI,SAA+C;CACnD,IAAI,gBAAgB;CAEpB,IAAI,gBAAgB,cAAc,IAAI,EAAE,EAAE,KAAK,MAAM,OAAO;EAC1D,MAAM,SAAS,gBAAgB,IAAI,KAAK,IAAI,GAAG,IAAI;EAInD,IAAI,gBAAgB,cAAc,OAAO,WAAW,MAAM;GACxD,KAAK,MAAM,SAAS,OAAO,QAAQ,KAAK,KAAK,KAAK;GAElD,SAAS,OAAO;GAChB,gBAAgB,OAAO;EACzB;EAEA,IAAI,WAAW,QAAQ,OAAO,OAAO,WAAW,KAAK,gBAAgB,YACnE,KAAK,OACH,UACA,kEACA,OAAO,MAAM,CAAC,CAChB;CAEJ;CAEA,MAAM,OAAmB,CAAC;CAC1B,MAAM,WAAsB,CAAC;CAC7B,IAAI,UAAU;CAEd,KAAK,IAAI,QAAQ,gBAAgB,GAAG,QAAQ,IAAI,QAAQ,SAAS;EAC/D,MAA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AM,OAAO;CAEpC,MAAM,QAAkB,CAAC;CAEzB,KAAK,MAAM,YAAY,SAAS,MAAM;EACpC,IAAI,SAAS,QAAQ,SAAS,MAAM,MAAM;EAE1C,MAAM,UAAU,SAAS,KAAK,KAAK;EAEnC,IAAI,SAAS,UAAU,QAAQ,WAAW,GAAG,GAAG;EAEhD,IAAI,YAAY,IAAI;GAClB,IAAI,MAAM,SAAS,GAAG;GACtB;EACF;EAEA,MAAM,KAAK,OAAO;CACpB;CAEA,OAAO,MAAM,SAAS,IAAI,MAAM,KAAK,GAAG,IAAI;AAC9C;;AAGA,SAAgB,eAAe,UAA2B,SAA0B;CAClF,MAAM,OAAO,SAAS,OAAO,QAAQ;CAErC,OAAO,SAAS,KACb,QACE,aAAa,SAAS,OAAO,SAAS,YAAY,UAAa,SAAS,OAAO,QAClF,CAAC,CACA,KAAK,aAAa,SAAS,IAAI,CAAC,CAChC,KAAK,IAAI,CAAC,CACV,KAAK;AACV"}
|
|
1
|
+
{"version":3,"file":"markdown.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/markdown.ts"],"sourcesContent":["/**\n * One pass over a written file's lines: front matter, headings, `##`\n * sections and the logical lines of a list section. Every parser of a\n * written file starts from the `WrittenDocument` this module builds, so a\n * file is split once and scanned line by line, never re-scanned whole.\n */\nimport path from \"node:path\";\nimport type { SourceLocation } from \"../contracts/location\";\nimport type { WrittenScreenshot } from \"../contracts/written\";\nimport { readFrontMatter, type FrontMatterField } from \"../front-matter\";\nimport type { FindingSink } from \"./sink\";\n\n/** One line of the body, trailing whitespace (and `\\r`) removed. */\nexport type BodyLine = {\n text: string;\n /** 1-based line in the file. */\n line: number;\n /** Inside a fenced code block (the fence lines included). */\n fenced: boolean;\n};\n\n/** A Markdown heading outside code fences. */\nexport type Heading = {\n level: number;\n text: string;\n line: number;\n};\n\n/** A `##` heading and the body lines up to the next `#` or `##` heading. */\nexport type Section = {\n title: string;\n /** `title` lower-cased with single spaces, for comparing with the template. */\n key: string;\n line: number;\n lines: BodyLine[];\n};\n\n/** A written file split into its parts. */\nexport type WrittenDocument = {\n file: string;\n /** Every line of the file, `\\r` removed, trailing whitespace kept. */\n raw: string[];\n /** `null` when the file has no front matter (or it was never closed). */\n fields: Map<string, FrontMatterField> | null;\n /** The body lines (after the front matter). */\n body: BodyLine[];\n /** The first `#` heading. */\n title: Heading | null;\n /** Every `##` section, in order. */\n sections: Section[];\n /** 1-based line of the body's first line. */\n bodyStartLine: number;\n};\n\n/** A list item with its indented continuation lines joined by one space. */\nexport type LogicalLine = {\n text: string;\n line: number;\n};\n\nconst HEADING = /^(#{1,6})[ \\t]+(.+?)(?:[ \\t]+#+)?$/;\nconst FENCE = /^[ \\t]*(?:```|~~~)/;\nconst ITEM_START = /^(?:[-*][ \\t]|\\d+\\.[ \\t])/;\nconst IMAGE = /!\\[([^\\]]*)\\]\\(\\s*<?([^)\\s>]+)>?(?:\\s+(?:\"[^\"]*\"|'[^']*'))?\\s*\\)/g;\nconst IMAGE_ONLY = /^(?:!\\[[^\\]]*\\]\\([^)]*\\)\\s*)+$/;\n/** Where screenshots live, relative to the project root. */\nconst SCREENSHOTS_DIR = \"grimoire/screenshots/\";\n\n/** Lower-case a heading or a question and collapse its spaces. */\nexport function normalizeKey(text: string): string {\n return text.trim().replace(/\\s+/g, \" \").toLowerCase();\n}\n\n/** Split text into lines on `\\n`, `\\r\\n` or a lone `\\r`. A leading BOM is dropped. */\nexport function splitLines(text: string): string[] {\n return text.replace(/^\\uFEFF/, \"\").split(/\\r\\n|\\r|\\n/);\n}\n\n/** A location of a whole line. */\nexport function lineAt(file: string, line: number): SourceLocation {\n return { file, line, column: null };\n}\n\n/**\n * Read a written file: its front matter (GR1001 when `frontMatter` is\n * `\"required\"` and the file has none; GR1002 for lines it cannot read),\n * then its headings and `##` sections.\n */\nexport function readDocument(\n file: string,\n text: string,\n frontMatter: \"required\" | \"none\",\n sink: FindingSink,\n): WrittenDocument {\n const raw = splitLines(text);\n let fields: Map<string, FrontMatterField> | null = null;\n let bodyStartLine = 1;\n\n if (frontMatter === \"required\" || raw[0]?.trim() === \"---\") {\n const result = readFrontMatter(raw.join(\"\\n\"), file);\n\n // A file with no front matter in its template may start with a `---`\n // rule that is never closed: that is body text, not a broken block.\n if (frontMatter === \"required\" || result.fields !== null) {\n for (const error of result.errors) sink.push(error);\n\n fields = result.fields;\n bodyStartLine = result.bodyStartLine;\n }\n\n if (fields === null && result.errors.length === 0 && frontMatter === \"required\") {\n sink.report(\n \"GR1001\",\n \"the file has no front matter; it must start with a `---` line.\",\n lineAt(file, 1),\n );\n }\n }\n\n const body: BodyLine[] = [];\n const headings: Heading[] = [];\n let inFence = false;\n\n for (let index = bodyStartLine - 1; index < raw.length; index++) {\n const text = (raw[index] ?? \"\").trimEnd();\n const line = index + 1;\n const fenceLine = FENCE.test(text);\n\n if (fenceLine) inFence = !inFence;\n\n const fenced = inFence || fenceLine;\n body.push({ text, line, fenced });\n\n if (fenced) continue;\n\n const heading = HEADING.exec(text);\n\n if (heading)\n headings.push({ level: (heading[1] ?? \"\").length, text: (heading[2] ?? \"\").trim(), line });\n }\n\n const sections: Section[] = [];\n let title: Heading | null = null;\n let current: Section | null = null;\n const firstBodyLine = body[0]?.line ?? bodyStartLine;\n let headingIndex = 0;\n\n for (const bodyLine of body) {\n const heading = headings[headingIndex];\n\n if (heading !== undefined && heading.line === bodyLine.line) {\n headingIndex++;\n\n if (heading.level === 1) {\n title ??= heading;\n current = null;\n continue;\n }\n\n if (heading.level === 2) {\n current = {\n title: heading.text,\n key: normalizeKey(heading.text),\n line: heading.line,\n lines: [],\n };\n sections.push(current);\n continue;\n }\n }\n\n current?.lines.push(bodyLine);\n }\n\n return {\n file,\n raw,\n fields,\n body,\n title,\n sections,\n bodyStartLine: Math.min(firstBodyLine, raw.length) || 1,\n };\n}\n\n/** The first section with this (normalised) title. */\nexport function findSection(document: WrittenDocument, key: string): Section | null {\n return document.sections.find((section) => section.key === key) ?? null;\n}\n\n/**\n * GR1006 for each required `##` heading that is missing (and for a missing\n * `#` title when `title` is required); GR1007 for each `##` heading the\n * template does not have, or one written twice.\n */\nexport function checkHeadings(\n document: WrittenDocument,\n template: { title: boolean; required: readonly string[]; optional: readonly string[] },\n sink: FindingSink,\n): void {\n const where = lineAt(document.file, document.title?.line ?? document.bodyStartLine);\n\n if (template.title && document.title === null) {\n sink.report(\"GR1006\", \"the file has no `# ` title heading.\", where);\n }\n\n for (const required of template.required) {\n if (!document.sections.some((section) => section.key === normalizeKey(required))) {\n sink.report(\"GR1006\", `the heading \"## ${required}\" is missing.`, where);\n }\n }\n\n const known = new Set([...template.required, ...template.optional].map(normalizeKey));\n const seen = new Set<string>();\n\n for (const section of document.sections) {\n if (!known.has(section.key)) {\n sink.report(\n \"GR1007\",\n `the heading \"## ${section.title}\" is not part of the template.`,\n lineAt(document.file, section.line),\n );\n } else if (seen.has(section.key)) {\n sink.report(\n \"GR1007\",\n `the heading \"## ${section.title}\" is written twice; only the first is read.`,\n lineAt(document.file, section.line),\n );\n }\n\n seen.add(section.key);\n }\n}\n\n/**\n * The logical lines of some body lines: a line that does not start with\n * whitespace (or that starts a list item) opens a new logical line, and the\n * indented lines right after it are joined to it with one space. Blank lines\n * and fenced lines end the current one.\n */\nexport function logicalLines(lines: readonly BodyLine[]): LogicalLine[] {\n const result: LogicalLine[] = [];\n let open: LogicalLine | null = null;\n\n for (const bodyLine of lines) {\n const trimmed = bodyLine.text.trim();\n\n if (bodyLine.fenced || trimmed === \"\") {\n open = null;\n continue;\n }\n\n const indented = /^[ \\t]/.test(bodyLine.text);\n\n if (open !== null && indented && !ITEM_START.test(trimmed)) {\n open.text = `${open.text} ${trimmed}`;\n continue;\n }\n\n open = { text: trimmed, line: bodyLine.line };\n result.push(open);\n }\n\n return result;\n}\n\n/** The first paragraph after the `# ` title: non-blank lines up to a blank line or a heading. */\nexport function paragraphAfterTitle(document: WrittenDocument): string | null {\n if (document.title === null) return null;\n\n const parts: string[] = [];\n\n for (const bodyLine of document.body) {\n if (bodyLine.line <= document.title.line) continue;\n\n const trimmed = bodyLine.text.trim();\n\n if (bodyLine.fenced || trimmed.startsWith(\"#\")) break;\n\n if (trimmed === \"\") {\n if (parts.length > 0) break;\n continue;\n }\n\n // An image line is not text: a screenshot may sit right under the title.\n if (IMAGE_ONLY.test(trimmed)) continue;\n\n parts.push(trimmed);\n }\n\n return parts.length > 0 ? parts.join(\" \") : null;\n}\n\n/** The body text after the `# ` title (or the whole body), trimmed. */\nexport function textAfterTitle(document: WrittenDocument, endLine?: number): string {\n const from = document.title?.line ?? 0;\n\n return document.body\n .filter(\n (bodyLine) => bodyLine.line > from && (endLine === undefined || bodyLine.line < endLine),\n )\n .map((bodyLine) => bodyLine.text)\n .join(\"\\n\")\n .trim();\n}\n\n/**\n * The path under `grimoire/screenshots/` an image line points at, or `null`\n * when it points elsewhere. The path is relative to the Markdown file, or\n * starts with `/grimoire/screenshots/`.\n */\nexport function screenshotPath(file: string, written: string): string | null {\n const target = written.replace(/[?#].*$/, \"\").replace(/\\\\/g, \"/\");\n\n if (/^[a-z][a-z0-9+.-]*:/i.test(target) || target.startsWith(\"//\")) return null;\n\n const resolved = target.startsWith(\"/\")\n ? path.posix.normalize(target.slice(1))\n : path.posix.join(path.posix.dirname(file.replace(/\\\\/g, \"/\")), target);\n const normal = path.posix.normalize(resolved);\n\n if (!normal.startsWith(SCREENSHOTS_DIR) || normal.length === SCREENSHOTS_DIR.length) return null;\n\n return normal.slice(SCREENSHOTS_DIR.length);\n}\n\n/**\n * The image lines `` of some body lines, outside code fences.\n * GR1029 (warning) for a path that is not inside `grimoire/screenshots/`;\n * the screenshot is kept with `path: null`.\n */\nexport function readScreenshots(\n file: string,\n lines: readonly BodyLine[],\n sink: FindingSink,\n): WrittenScreenshot[] {\n const screenshots: WrittenScreenshot[] = [];\n\n for (const bodyLine of lines) {\n if (bodyLine.fenced) continue;\n\n for (const match of bodyLine.text.matchAll(IMAGE)) {\n const written = match[2] ?? \"\";\n const resolved = screenshotPath(file, decodeUri(written));\n const at = lineAt(file, bodyLine.line);\n\n if (resolved === null) {\n sink.report(\n \"GR1029\",\n `the image ${JSON.stringify(written)} is not inside grimoire/screenshots/.`,\n at,\n );\n }\n\n screenshots.push({ alt: (match[1] ?? \"\").trim(), written, path: resolved, at });\n }\n }\n\n return screenshots;\n}\n\n/** `%20` and the like in an image path; a malformed escape is kept as written. */\nfunction decodeUri(value: string): string {\n try {\n return decodeURI(value);\n } catch {\n return value;\n }\n}\n\n/** A line that holds only image markup. */\nexport function isImageLine(text: string): boolean {\n return IMAGE_ONLY.test(text.trim());\n}\n\n/** The line with its image markup removed, trimmed. */\nexport function withoutImages(text: string): string {\n return text.replace(IMAGE, \"\").replace(/\\s+/g, \" \").trim();\n}\n"],"mappings":";;;;;;;;;;AA4DA,MAAM,UAAU;AAChB,MAAM,QAAQ;AACd,MAAM,aAAa;AACnB,MAAM,QAAQ;AACd,MAAM,aAAa;;AAEnB,MAAM,kBAAkB;;AAGxB,SAAgB,aAAa,MAAsB;CACjD,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,QAAQ,GAAG,CAAC,CAAC,YAAY;AACtD;;AAGA,SAAgB,WAAW,MAAwB;CACjD,OAAO,KAAK,QAAQ,WAAW,EAAE,CAAC,CAAC,MAAM,YAAY;AACvD;;AAGA,SAAgB,OAAO,MAAc,MAA8B;CACjE,OAAO;EAAE;EAAM;EAAM,QAAQ;CAAK;AACpC;;;;;;AAOA,SAAgB,aACd,MACA,MACA,aACA,MACiB;CACjB,MAAM,MAAM,WAAW,IAAI;CAC3B,IAAI,SAA+C;CACnD,IAAI,gBAAgB;CAEpB,IAAI,gBAAgB,cAAc,IAAI,EAAE,EAAE,KAAK,MAAM,OAAO;EAC1D,MAAM,SAAS,gBAAgB,IAAI,KAAK,IAAI,GAAG,IAAI;EAInD,IAAI,gBAAgB,cAAc,OAAO,WAAW,MAAM;GACxD,KAAK,MAAM,SAAS,OAAO,QAAQ,KAAK,KAAK,KAAK;GAElD,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KAAK,MAAM,QAAQ,KAAK,QAAQ,OAAO,GAAG,CAAC,GAAG,MAAM;CACxE,MAAM,SAAS,KAAK,MAAM,UAAU,QAAQ;CAE5C,IAAI,CAAC,OAAO,WAAW,eAAe,KAAK,OAAO,WAAW,IAAwB,OAAO;CAE5F,OAAO,OAAO,MAAM,EAAsB;AAC5C;;;;;;AAOA,SAAgB,gBACd,MACA,OACA,MACqB;CACrB,MAAM,cAAmC,CAAC;CAE1C,KAAK,MAAM,YAAY,OAAO;EAC5B,IAAI,SAAS,QAAQ;EAErB,KAAK,MAAM,SAAS,SAAS,KAAK,SAAS,KAAK,GAAG;GACjD,MAAM,UAAU,MAAM,MAAM;GAC5B,MAAM,WAAW,eAAe,MAAM,UAAU,OAAO,CAAC;GACxD,MAAM,KAAK,OAAO,MAAM,SAAS,IAAI;GAErC,IAAI,aAAa,MACf,KAAK,OACH,UACA,aAAa,KAAK,UAAU,OAAO,EAAE,wCACrC,EACF;GAGF,YAAY,KAAK;IAAE,MAAM,MAAM,MAAM,GAAE,CAAE,KAAK;IAAG;IAAS,MAAM;IAAU;GAAG,CAAC;EAChF;CACF;CAEA,OAAO;AACT;;AAGA,SAAS,UAAU,OAAuB;CACxC,IAAI;EACF,OAAO,UAAU,KAAK;CACxB,QAAQ;EACN,OAAO;CACT;AACF;;AAGA,SAAgB,YAAY,MAAuB;CACjD,OAAO,WAAW,KAAK,KAAK,KAAK,CAAC;AACpC;;AAGA,SAAgB,cAAc,MAAsB;CAClD,OAAO,KAAK,QAAQ,OAAO,EAAE,CAAC,CAAC,QAAQ,QAAQ,GAAG,CAAC,CAAC,KAAK;AAC3D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-grimoire.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/parse-grimoire.ts"],"mappings":";;;;YA6BY;EACV,SAAS;;EAET,UAAU;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"parse-grimoire.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/parse-grimoire.ts"],"mappings":";;;;YA6BY;EACV,SAAS;;EAET,UAAU;;;;;;;;;;wBAmeU,cAAc,eAAe,QAAQ"}
|
|
@@ -89,7 +89,7 @@ var Walker = class {
|
|
|
89
89
|
for (const name of top.files) this.unknown(`${GRIMOIRE_DIR}/${name}`);
|
|
90
90
|
for (const name of top.dirs) {
|
|
91
91
|
const dir = `${GRIMOIRE_DIR}/${name}`;
|
|
92
|
-
if (name === "book") continue;
|
|
92
|
+
if (name === "book" || name === "screenshots") continue;
|
|
93
93
|
else if (name === "features") await this.walkFeatures(dir);
|
|
94
94
|
else if (name === "apps") await this.walkApps(dir);
|
|
95
95
|
else if (name === "tasks") await this.walkTasks(dir);
|