@warlock.js/grimoire 0.0.0-stage → 5.56.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 +52 -0
- package/LICENSE +21 -0
- package/README.md +55 -2
- package/esm/apps/check-apps.mjs +207 -0
- package/esm/apps/check-apps.mjs.map +1 -0
- package/esm/apps/index.mjs +4 -0
- package/esm/apps/match-apps.d.mts +12 -0
- package/esm/apps/match-apps.d.mts.map +1 -0
- package/esm/apps/match-apps.mjs +30 -0
- package/esm/apps/match-apps.mjs.map +1 -0
- package/esm/book/build.d.mts +14 -0
- package/esm/book/build.d.mts.map +1 -0
- package/esm/book/build.mjs +300 -0
- package/esm/book/build.mjs.map +1 -0
- package/esm/book/index.mjs +5 -0
- package/esm/book/io.mjs +162 -0
- package/esm/book/io.mjs.map +1 -0
- package/esm/book/normalize.mjs +71 -0
- package/esm/book/normalize.mjs.map +1 -0
- package/esm/book/render.mjs +262 -0
- package/esm/book/render.mjs.map +1 -0
- package/esm/book/write.d.mts +12 -0
- package/esm/book/write.d.mts.map +1 -0
- package/esm/book/write.mjs +90 -0
- package/esm/book/write.mjs.map +1 -0
- package/esm/bookmap/build.d.mts +21 -0
- package/esm/bookmap/build.d.mts.map +1 -0
- package/esm/bookmap/build.mjs +272 -0
- package/esm/bookmap/build.mjs.map +1 -0
- package/esm/bookmap/index.mjs +5 -0
- package/esm/bookmap/steps.mjs +137 -0
- package/esm/bookmap/steps.mjs.map +1 -0
- package/esm/bookmap/write.d.mts +19 -0
- package/esm/bookmap/write.d.mts.map +1 -0
- package/esm/bookmap/write.mjs +118 -0
- package/esm/bookmap/write.mjs.map +1 -0
- package/esm/check/check-grimoire.d.mts +7 -0
- package/esm/check/check-grimoire.d.mts.map +1 -0
- package/esm/check/check-grimoire.mjs +98 -0
- package/esm/check/check-grimoire.mjs.map +1 -0
- package/esm/check/format-check-report.d.mts +20 -0
- package/esm/check/format-check-report.d.mts.map +1 -0
- package/esm/check/format-check-report.mjs +55 -0
- package/esm/check/format-check-report.mjs.map +1 -0
- package/esm/check/index.mjs +4 -0
- package/esm/check/rules/book-notes.mjs +18 -0
- package/esm/check/rules/book-notes.mjs.map +1 -0
- package/esm/check/rules/criteria.mjs +48 -0
- package/esm/check/rules/criteria.mjs.map +1 -0
- package/esm/check/rules/links.mjs +196 -0
- package/esm/check/rules/links.mjs.map +1 -0
- package/esm/check/rules/lookup.mjs +41 -0
- package/esm/check/rules/lookup.mjs.map +1 -0
- package/esm/check/rules/source-files.mjs +119 -0
- package/esm/check/rules/source-files.mjs.map +1 -0
- package/esm/check/rules/versions.mjs +92 -0
- package/esm/check/rules/versions.mjs.map +1 -0
- package/esm/codes/codes.d.mts +182 -0
- package/esm/codes/codes.d.mts.map +1 -0
- package/esm/codes/codes.mjs +111 -0
- package/esm/codes/codes.mjs.map +1 -0
- package/esm/codes/index.d.mts +33 -0
- package/esm/codes/index.d.mts.map +1 -0
- package/esm/codes/index.mjs +63 -0
- package/esm/codes/index.mjs.map +1 -0
- package/esm/contracts/adapter.d.mts +209 -0
- package/esm/contracts/adapter.d.mts.map +1 -0
- package/esm/contracts/book.d.mts +233 -0
- package/esm/contracts/book.d.mts.map +1 -0
- package/esm/contracts/book.mjs +7 -0
- package/esm/contracts/book.mjs.map +1 -0
- package/esm/contracts/bookmap.d.mts +175 -0
- package/esm/contracts/bookmap.d.mts.map +1 -0
- package/esm/contracts/findings.d.mts +79 -0
- package/esm/contracts/findings.d.mts.map +1 -0
- package/esm/contracts/location.d.mts +22 -0
- package/esm/contracts/location.d.mts.map +1 -0
- package/esm/contracts/releases.d.mts +53 -0
- package/esm/contracts/releases.d.mts.map +1 -0
- package/esm/contracts/scry.d.mts +143 -0
- package/esm/contracts/scry.d.mts.map +1 -0
- package/esm/contracts/snapshot.d.mts +52 -0
- package/esm/contracts/snapshot.d.mts.map +1 -0
- package/esm/contracts/test-results.d.mts +63 -0
- package/esm/contracts/test-results.d.mts.map +1 -0
- package/esm/contracts/written.d.mts +363 -0
- package/esm/contracts/written.d.mts.map +1 -0
- package/esm/contracts/written.mjs +19 -0
- package/esm/contracts/written.mjs.map +1 -0
- package/esm/devtools/data.mjs +171 -0
- package/esm/devtools/data.mjs.map +1 -0
- package/esm/devtools/graphs.mjs +142 -0
- package/esm/devtools/graphs.mjs.map +1 -0
- package/esm/devtools/index.d.mts +42 -0
- package/esm/devtools/index.d.mts.map +1 -0
- package/esm/devtools/index.mjs +103 -0
- package/esm/devtools/index.mjs.map +1 -0
- package/esm/devtools/site.d.mts +26 -0
- package/esm/devtools/site.d.mts.map +1 -0
- package/esm/devtools/site.mjs +190 -0
- package/esm/devtools/site.mjs.map +1 -0
- package/esm/devtools/snapshot-source.mjs +70 -0
- package/esm/devtools/snapshot-source.mjs.map +1 -0
- package/esm/front-matter/index.d.mts +33 -0
- package/esm/front-matter/index.d.mts.map +1 -0
- package/esm/front-matter/index.mjs +130 -0
- package/esm/front-matter/index.mjs.map +1 -0
- package/esm/graph/index.d.mts +15 -0
- package/esm/graph/index.d.mts.map +1 -0
- package/esm/graph/index.mjs +42 -0
- package/esm/graph/index.mjs.map +1 -0
- package/esm/index.d.mts +33 -0
- package/esm/index.mjs +33 -0
- package/esm/ownership/index.d.mts +8 -0
- package/esm/ownership/index.d.mts.map +1 -0
- package/esm/ownership/index.mjs +137 -0
- package/esm/ownership/index.mjs.map +1 -0
- package/esm/paths/index.d.mts +58 -0
- package/esm/paths/index.d.mts.map +1 -0
- package/esm/paths/index.mjs +137 -0
- package/esm/paths/index.mjs.map +1 -0
- package/esm/proves/index.mjs +3 -0
- package/esm/proves/scan-proofs.d.mts +22 -0
- package/esm/proves/scan-proofs.d.mts.map +1 -0
- package/esm/proves/scan-proofs.mjs +214 -0
- package/esm/proves/scan-proofs.mjs.map +1 -0
- package/esm/releases/index.d.mts +29 -0
- package/esm/releases/index.d.mts.map +1 -0
- package/esm/releases/index.mjs +157 -0
- package/esm/releases/index.mjs.map +1 -0
- package/esm/scry/format.d.mts +14 -0
- package/esm/scry/format.d.mts.map +1 -0
- package/esm/scry/format.mjs +193 -0
- package/esm/scry/format.mjs.map +1 -0
- package/esm/scry/index.mjs +5 -0
- package/esm/scry/parse.d.mts +10 -0
- package/esm/scry/parse.d.mts.map +1 -0
- package/esm/scry/parse.mjs +108 -0
- package/esm/scry/parse.mjs.map +1 -0
- package/esm/scry/query.d.mts +11 -0
- package/esm/scry/query.d.mts.map +1 -0
- package/esm/scry/query.mjs +457 -0
- package/esm/scry/query.mjs.map +1 -0
- package/esm/tasks/index.mjs +116 -0
- package/esm/tasks/index.mjs.map +1 -0
- package/esm/test-results/criterion-status.d.mts +15 -0
- package/esm/test-results/criterion-status.d.mts.map +1 -0
- package/esm/test-results/criterion-status.mjs +17 -0
- package/esm/test-results/criterion-status.mjs.map +1 -0
- package/esm/test-results/index.d.mts +8 -0
- package/esm/test-results/index.d.mts.map +1 -0
- package/esm/test-results/index.mjs +124 -0
- package/esm/test-results/index.mjs.map +1 -0
- package/esm/vitest/index.d.mts +15 -0
- package/esm/vitest/index.d.mts.map +1 -0
- package/esm/vitest/index.mjs +146 -0
- package/esm/vitest/index.mjs.map +1 -0
- package/esm/warlock/actions.mjs +265 -0
- package/esm/warlock/actions.mjs.map +1 -0
- package/esm/warlock/adapter.d.mts +28 -0
- package/esm/warlock/adapter.d.mts.map +1 -0
- package/esm/warlock/adapter.mjs +377 -0
- package/esm/warlock/adapter.mjs.map +1 -0
- package/esm/warlock/commands.d.mts +15 -0
- package/esm/warlock/commands.d.mts.map +1 -0
- package/esm/warlock/commands.mjs +199 -0
- package/esm/warlock/commands.mjs.map +1 -0
- package/esm/warlock/index.d.mts +4 -0
- package/esm/warlock/index.mjs +5 -0
- package/esm/warlock/mcp-tools.mjs +247 -0
- package/esm/warlock/mcp-tools.mjs.map +1 -0
- package/esm/warlock/mobile-facts.d.mts +32 -0
- package/esm/warlock/mobile-facts.d.mts.map +1 -0
- package/esm/warlock/mobile-facts.mjs +185 -0
- package/esm/warlock/mobile-facts.mjs.map +1 -0
- package/esm/workspace/index.d.mts +11 -0
- package/esm/workspace/index.d.mts.map +1 -0
- package/esm/workspace/index.mjs +122 -0
- package/esm/workspace/index.mjs.map +1 -0
- package/esm/written/apps.mjs +227 -0
- package/esm/written/apps.mjs.map +1 -0
- package/esm/written/features.mjs +400 -0
- package/esm/written/features.mjs.map +1 -0
- package/esm/written/fields.mjs +173 -0
- package/esm/written/fields.mjs.map +1 -0
- package/esm/written/index.mjs +3 -0
- package/esm/written/lists.mjs +68 -0
- package/esm/written/lists.mjs.map +1 -0
- package/esm/written/markdown.mjs +173 -0
- package/esm/written/markdown.mjs.map +1 -0
- package/esm/written/parse-grimoire.d.mts +20 -0
- package/esm/written/parse-grimoire.d.mts.map +1 -0
- package/esm/written/parse-grimoire.mjs +552 -0
- package/esm/written/parse-grimoire.mjs.map +1 -0
- package/esm/written/sink.mjs +65 -0
- package/esm/written/sink.mjs.map +1 -0
- package/esm/written/tasks-releases.mjs +166 -0
- package/esm/written/tasks-releases.mjs.map +1 -0
- package/llms-full.txt +869 -0
- package/llms.txt +15 -0
- package/package.json +66 -4
- package/skills/backfill-a-grimoire/SKILL.md +128 -0
- package/skills/describe-an-app/SKILL.md +162 -0
- package/skills/document-a-file/SKILL.md +75 -0
- package/skills/index.md +26 -0
- package/skills/record-a-change/SKILL.md +139 -0
- package/skills/use-the-grimoire/SKILL.md +137 -0
- package/skills/write-a-feature/SKILL.md +168 -0
- package/ui/grimoire-static.js +136 -0
- package/ui/grimoire-view.js +1005 -0
- package/ui/grimoire.css +88 -0
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import { CASE_QUESTIONS } from "../contracts/written.mjs";
|
|
2
|
+
import { checkHeadings, findSection, lineAt, logicalLines, normalizeKey, paragraphAfterTitle, readDocument } from "./markdown.mjs";
|
|
3
|
+
import { FrontMatterReader, ID, SEP, VERSION, checks, isDate, projectFolder } from "./fields.mjs";
|
|
4
|
+
import { BULLET, bulletLines, readListLines, splitListLine } from "./lists.mjs";
|
|
5
|
+
|
|
6
|
+
//#region ../../packages/grimoire/src/written/features.ts
|
|
7
|
+
const STATUSES = [
|
|
8
|
+
"proposed",
|
|
9
|
+
"building",
|
|
10
|
+
"shipped",
|
|
11
|
+
"retired"
|
|
12
|
+
];
|
|
13
|
+
const ORIGINS = ["inferred", "confirmed"];
|
|
14
|
+
const CHANGE_WORDS = [
|
|
15
|
+
"added",
|
|
16
|
+
"changed",
|
|
17
|
+
"fixed",
|
|
18
|
+
"removed"
|
|
19
|
+
];
|
|
20
|
+
/** Step kinds, longest first so `outside service` is tried before shorter words. */
|
|
21
|
+
const STEP_TYPES = [
|
|
22
|
+
"outside service",
|
|
23
|
+
"notification",
|
|
24
|
+
"affects",
|
|
25
|
+
"event",
|
|
26
|
+
"route",
|
|
27
|
+
"page",
|
|
28
|
+
"mail",
|
|
29
|
+
"job"
|
|
30
|
+
];
|
|
31
|
+
/** A status that is missing or wrong is read as `building`: never `proposed`, which would hide findings. */
|
|
32
|
+
const FALLBACK_STATUS = "building";
|
|
33
|
+
const STEP = new RegExp(String.raw`^(\d+)\.[ \t]+(${STEP_TYPES.join("|")})[ \t]+(\S.*?)(?:[ \t]+(?:—|--)[ \t]+(\S.*))?$`);
|
|
34
|
+
const STEP_ANY_TYPE = new RegExp(String.raw`^(\d+)\.[ \t]+(\S.*?)${SEP}(\S.*)$`);
|
|
35
|
+
const STEP_FIRST_WORD = /^(\d+)\.[ \t]+(\S+)[ \t]+(\S.*)$/;
|
|
36
|
+
const NUMBERED = /^(\d+)\.(?:[ \t]|$)/;
|
|
37
|
+
const PAGE_TARGET = /^(\S+)[ \t]+\[([a-z0-9]+(?:-[a-z0-9]+)*)\]$/;
|
|
38
|
+
const ROUTE_TARGET = /^(GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS|ALL)[ \t]+(\/\S*)$/i;
|
|
39
|
+
const AFFECTS_TARGET = /^([a-z0-9]+(?:-[a-z0-9]+)*)(?:\/([a-z0-9]+(?:-[a-z0-9]+)*))?$/;
|
|
40
|
+
const CRITERION = /^[-*][ \t]+AC-(\d+)(?:[ \t]+\[([a-z0-9-]+)\])?[ \t]+([^\s[].*)$/;
|
|
41
|
+
const CHANGELOG_ENTRY = /^[-*][ \t]+(\S+)[ \t]+(\S+)[ \t]+(\S.*)$/;
|
|
42
|
+
const RELEASE_HEADING = /^##[ \t]+(\S+)[ \t]+\((.+)\)$/;
|
|
43
|
+
const UNRELEASED_HEADING = /^##[ \t]+unreleased$/i;
|
|
44
|
+
const FLOW_PREFIX = /^([a-z0-9-]+):[ \t]+(\S.*)$/;
|
|
45
|
+
const CRITERIA_SUFFIX = /[ \t]*\((AC-\d+(?:[ \t]*,[ \t]*AC-\d+)*)\)$/;
|
|
46
|
+
const FLOW_REF_IN_TEXT = /(?<![\w/-])([a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*)(?![\w/-])/g;
|
|
47
|
+
function heading(document) {
|
|
48
|
+
return document.title ? {
|
|
49
|
+
value: document.title.text,
|
|
50
|
+
at: lineAt(document.file, document.title.line)
|
|
51
|
+
} : null;
|
|
52
|
+
}
|
|
53
|
+
/** GR1019 when a front matter id differs from the folder or file name it must equal. */
|
|
54
|
+
function sameAsName(located, name, what, sink) {
|
|
55
|
+
if (located.value !== "" && located.value !== name) sink.report("GR1019", `the ${what} ${JSON.stringify(located.value)} must equal its ${JSON.stringify(name)} name.`, located.at);
|
|
56
|
+
}
|
|
57
|
+
/** The text of a changelog entry: the flow prefix, the text and the trailing criteria. */
|
|
58
|
+
function splitEntryText(text) {
|
|
59
|
+
let rest = text.trim();
|
|
60
|
+
let flow = null;
|
|
61
|
+
let criteria = [];
|
|
62
|
+
const prefix = FLOW_PREFIX.exec(rest);
|
|
63
|
+
if (prefix) {
|
|
64
|
+
flow = prefix[1] ?? null;
|
|
65
|
+
rest = prefix[2] ?? "";
|
|
66
|
+
}
|
|
67
|
+
const suffix = CRITERIA_SUFFIX.exec(rest);
|
|
68
|
+
if (suffix) {
|
|
69
|
+
criteria = (suffix[1] ?? "").split(",").map((criterion) => criterion.trim());
|
|
70
|
+
rest = rest.slice(0, suffix.index).trimEnd();
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
flow,
|
|
74
|
+
criteria,
|
|
75
|
+
text: rest
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/** `grimoire/features/<id>/README.md`. */
|
|
79
|
+
function parseFeatureReadme(file, text, folder, sink) {
|
|
80
|
+
const document = readDocument(file, text, "required", sink);
|
|
81
|
+
const fields = new FrontMatterReader(document, sink);
|
|
82
|
+
fields.onlyKeys([
|
|
83
|
+
"id",
|
|
84
|
+
"title",
|
|
85
|
+
"status",
|
|
86
|
+
"version",
|
|
87
|
+
"updated",
|
|
88
|
+
"apps",
|
|
89
|
+
"folders",
|
|
90
|
+
"origin"
|
|
91
|
+
], "feature README");
|
|
92
|
+
const id = fields.required("id", checks.id);
|
|
93
|
+
sameAsName(id, folder, "feature id", sink);
|
|
94
|
+
const readme = {
|
|
95
|
+
file,
|
|
96
|
+
id,
|
|
97
|
+
title: fields.required("title", checks.text),
|
|
98
|
+
status: fields.oneOf("status", STATUSES, FALLBACK_STATUS),
|
|
99
|
+
version: fields.required("version", checks.version),
|
|
100
|
+
updated: fields.required("updated", checks.date),
|
|
101
|
+
apps: fields.list("apps", {
|
|
102
|
+
required: true,
|
|
103
|
+
check: checks.id
|
|
104
|
+
}),
|
|
105
|
+
folders: fields.list("folders", {
|
|
106
|
+
required: true,
|
|
107
|
+
check: checks.folder,
|
|
108
|
+
map: (value) => projectFolder(value) ?? value
|
|
109
|
+
}),
|
|
110
|
+
origin: fields.optionalOneOf("origin", ORIGINS),
|
|
111
|
+
heading: heading(document),
|
|
112
|
+
summary: paragraphAfterTitle(document),
|
|
113
|
+
flows: [],
|
|
114
|
+
relations: []
|
|
115
|
+
};
|
|
116
|
+
checkHeadings(document, {
|
|
117
|
+
title: true,
|
|
118
|
+
required: [],
|
|
119
|
+
optional: ["Flows", "Affects and affected by"]
|
|
120
|
+
}, sink);
|
|
121
|
+
for (const flow of readListLines(file, findSection(document, "flows")?.lines, "Flows", sink)) {
|
|
122
|
+
if (!ID.test(flow.name)) {
|
|
123
|
+
sink.report("GR1028", `the Flows line names ${JSON.stringify(flow.name)}, which is not a flow id.`, flow.at);
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
readme.flows.push(flow);
|
|
127
|
+
}
|
|
128
|
+
for (const line of logicalLines(findSection(document, "affects and affected by")?.lines ?? [])) {
|
|
129
|
+
const relation = line.text.replace(BULLET, "").trim();
|
|
130
|
+
readme.relations.push({
|
|
131
|
+
text: relation,
|
|
132
|
+
refs: [...relation.matchAll(FLOW_REF_IN_TEXT)].map((match) => match[1] ?? ""),
|
|
133
|
+
at: lineAt(file, line.line)
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return readme;
|
|
137
|
+
}
|
|
138
|
+
/** `grimoire/features/<feature>/CHANGELOG.md`. */
|
|
139
|
+
function parseChangelog(file, text, feature, sink) {
|
|
140
|
+
const document = readDocument(file, text, "none", sink);
|
|
141
|
+
new FrontMatterReader(document, sink).onlyKeys([], "a changelog");
|
|
142
|
+
const sections = [];
|
|
143
|
+
const entries = [];
|
|
144
|
+
const seen = /* @__PURE__ */ new Set();
|
|
145
|
+
let current = null;
|
|
146
|
+
for (const line of logicalLines(document.body)) {
|
|
147
|
+
const at = lineAt(file, line.line);
|
|
148
|
+
if (/^#[ \t]/.test(line.text)) continue;
|
|
149
|
+
if (line.text.startsWith("#")) {
|
|
150
|
+
const release = RELEASE_HEADING.exec(line.text);
|
|
151
|
+
let section = null;
|
|
152
|
+
if (UNRELEASED_HEADING.test(line.text)) section = {
|
|
153
|
+
release: null,
|
|
154
|
+
date: null,
|
|
155
|
+
at
|
|
156
|
+
};
|
|
157
|
+
else if (release && isDate(release[2] ?? "")) section = {
|
|
158
|
+
release: release[1] ?? "",
|
|
159
|
+
date: release[2] ?? "",
|
|
160
|
+
at
|
|
161
|
+
};
|
|
162
|
+
if (section === null) {
|
|
163
|
+
sink.report("GR1017", `the changelog heading ${JSON.stringify(line.text)} is neither "## Unreleased" nor "## <release> (<yyyy-mm-dd>)".`, at);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
const key = section.release ?? "";
|
|
167
|
+
if (seen.has(key)) sink.report("GR1017", `the changelog heading ${JSON.stringify(line.text)} is written twice; write each section once.`, at);
|
|
168
|
+
seen.add(key);
|
|
169
|
+
sections.push(section);
|
|
170
|
+
current = section;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (!BULLET.test(line.text)) {
|
|
174
|
+
sink.report("GR1015", `the changelog line ${JSON.stringify(line.text)} is not an entry.`, at);
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
const match = CHANGELOG_ENTRY.exec(line.text);
|
|
178
|
+
const version = match?.[1] ?? "";
|
|
179
|
+
const word = match?.[2] ?? "";
|
|
180
|
+
if (!match || !VERSION.test(version)) {
|
|
181
|
+
sink.report("GR1015", `the changelog line ${JSON.stringify(line.text)} is not \`- <version> <word> <text>\`.`, at);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
if (!CHANGE_WORDS.includes(word)) {
|
|
185
|
+
sink.report("GR1016", `the changelog word ${JSON.stringify(word)} is not one of ${CHANGE_WORDS.join(", ")}.`, at);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
188
|
+
if (current === null) sink.report("GR1015", `the changelog entry ${JSON.stringify(line.text)} is not under "## Unreleased" or a release heading.`, at);
|
|
189
|
+
const parts = splitEntryText(match[3] ?? "");
|
|
190
|
+
entries.push({
|
|
191
|
+
feature,
|
|
192
|
+
version: {
|
|
193
|
+
value: version,
|
|
194
|
+
at
|
|
195
|
+
},
|
|
196
|
+
word,
|
|
197
|
+
flow: parts.flow,
|
|
198
|
+
criteria: parts.criteria,
|
|
199
|
+
text: parts.text,
|
|
200
|
+
release: current?.release ?? null,
|
|
201
|
+
date: current?.date ?? null,
|
|
202
|
+
at
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
file,
|
|
207
|
+
sections,
|
|
208
|
+
entries
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function parseSteps(file, document, sink) {
|
|
212
|
+
const steps = [];
|
|
213
|
+
const numbers = [];
|
|
214
|
+
for (const line of logicalLines(findSection(document, "steps")?.lines ?? [])) {
|
|
215
|
+
const at = lineAt(file, line.line);
|
|
216
|
+
const numbered = NUMBERED.exec(line.text);
|
|
217
|
+
if (!numbered) {
|
|
218
|
+
if (BULLET.test(line.text)) sink.report("GR1008", `the step ${JSON.stringify(line.text)} is a bullet; number steps \`1. <kind> <name>\`.`, at);
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
numbers.push({
|
|
222
|
+
number: Number(numbered[1]),
|
|
223
|
+
line: line.line
|
|
224
|
+
});
|
|
225
|
+
const match = STEP.exec(line.text);
|
|
226
|
+
if (!match) {
|
|
227
|
+
const other = STEP_ANY_TYPE.exec(line.text) ?? STEP_FIRST_WORD.exec(line.text);
|
|
228
|
+
const type = other?.[2] ?? "";
|
|
229
|
+
if (other && !STEP_TYPES.includes(type)) sink.report("GR1009", `the step kind ${JSON.stringify(type)} is not one of: ${STEP_TYPES.join(", ")}.`, at);
|
|
230
|
+
else sink.report("GR1008", `the step ${JSON.stringify(line.text)} is not \`<n>. <kind> <name>\`.`, at);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const type = match[2];
|
|
234
|
+
let target = (match[3] ?? "").trim();
|
|
235
|
+
let app = null;
|
|
236
|
+
let route = null;
|
|
237
|
+
let affects = null;
|
|
238
|
+
if (type === "page") {
|
|
239
|
+
const scoped = PAGE_TARGET.exec(target);
|
|
240
|
+
if (scoped) {
|
|
241
|
+
target = scoped[1] ?? "";
|
|
242
|
+
app = scoped[2] ?? null;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (type === "route") {
|
|
246
|
+
const routeMatch = ROUTE_TARGET.exec(target);
|
|
247
|
+
if (!routeMatch) {
|
|
248
|
+
sink.report("GR1008", `the route step ${JSON.stringify(target)} is not \`<METHOD> /path\`.`, at);
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
route = {
|
|
252
|
+
method: (routeMatch[1] ?? "").toUpperCase(),
|
|
253
|
+
path: routeMatch[2] ?? ""
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
if (type === "affects") {
|
|
257
|
+
const affectsMatch = AFFECTS_TARGET.exec(target);
|
|
258
|
+
if (!affectsMatch) {
|
|
259
|
+
sink.report("GR1008", `the affects step ${JSON.stringify(target)} is not \`<feature>\` or \`<feature>/<flow>\`.`, at);
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
affects = {
|
|
263
|
+
feature: affectsMatch[1] ?? "",
|
|
264
|
+
flow: affectsMatch[2] ?? null
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
steps.push({
|
|
268
|
+
index: Number(match[1]),
|
|
269
|
+
type,
|
|
270
|
+
target,
|
|
271
|
+
app,
|
|
272
|
+
route,
|
|
273
|
+
affects,
|
|
274
|
+
note: match[4]?.trim() ?? null,
|
|
275
|
+
at
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
const wrong = numbers.findIndex((entry, position) => entry.number !== position + 1);
|
|
279
|
+
const first = numbers[wrong];
|
|
280
|
+
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
|
+
return steps;
|
|
282
|
+
}
|
|
283
|
+
function parseCases(file, document, sink) {
|
|
284
|
+
const cases = [];
|
|
285
|
+
for (const line of bulletLines(findSection(document, "cases")?.lines ?? [])) {
|
|
286
|
+
const split = splitListLine(line.text, CASE_QUESTIONS);
|
|
287
|
+
if (split === null) {
|
|
288
|
+
sink.report("GR1011", `the case ${JSON.stringify(line.text)} is not \`- <question> <answer>\`.`, lineAt(file, line.line));
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
const question = normalizeKey(split.name);
|
|
292
|
+
cases.push({
|
|
293
|
+
question,
|
|
294
|
+
fixed: CASE_QUESTIONS.includes(question),
|
|
295
|
+
answer: split.text,
|
|
296
|
+
doesNotApply: /^does not apply\b/i.test(split.text),
|
|
297
|
+
at: lineAt(file, line.line)
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
return cases;
|
|
301
|
+
}
|
|
302
|
+
function parseCriteria(file, document, sink) {
|
|
303
|
+
const criteria = [];
|
|
304
|
+
const seen = /* @__PURE__ */ new Set();
|
|
305
|
+
for (const line of bulletLines(findSection(document, "acceptance criteria")?.lines ?? [])) {
|
|
306
|
+
const at = lineAt(file, line.line);
|
|
307
|
+
const match = CRITERION.exec(line.text);
|
|
308
|
+
if (!match) {
|
|
309
|
+
sink.report("GR1013", `the criterion ${JSON.stringify(line.text)} is not \`- AC-<n> <text>\` or \`- AC-<n> [<app>] <text>\`.`, at);
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
const number = Number(match[1]);
|
|
313
|
+
if (seen.has(number)) {
|
|
314
|
+
sink.report("GR1014", `AC-${number} is used twice in this flow.`, at);
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
seen.add(number);
|
|
318
|
+
criteria.push({
|
|
319
|
+
id: `AC-${number}`,
|
|
320
|
+
number,
|
|
321
|
+
app: match[2] ?? null,
|
|
322
|
+
text: (match[3] ?? "").trim(),
|
|
323
|
+
at
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
return criteria;
|
|
327
|
+
}
|
|
328
|
+
/** `grimoire/features/<feature>/flows/<name>.md`. */
|
|
329
|
+
function parseFlow(file, text, feature, name, sink) {
|
|
330
|
+
const document = readDocument(file, text, "required", sink);
|
|
331
|
+
const fields = new FrontMatterReader(document, sink);
|
|
332
|
+
fields.onlyKeys([
|
|
333
|
+
"id",
|
|
334
|
+
"since",
|
|
335
|
+
"status",
|
|
336
|
+
"who",
|
|
337
|
+
"origin"
|
|
338
|
+
], "flow");
|
|
339
|
+
const id = fields.required("id", checks.id);
|
|
340
|
+
sameAsName(id, name, "flow id", sink);
|
|
341
|
+
const flow = {
|
|
342
|
+
file,
|
|
343
|
+
feature,
|
|
344
|
+
id,
|
|
345
|
+
ref: `${feature}/${name}`,
|
|
346
|
+
since: fields.required("since", checks.version),
|
|
347
|
+
status: fields.oneOf("status", STATUSES, FALLBACK_STATUS),
|
|
348
|
+
who: fields.required("who", checks.text),
|
|
349
|
+
origin: fields.optionalOneOf("origin", ORIGINS),
|
|
350
|
+
heading: heading(document),
|
|
351
|
+
steps: [],
|
|
352
|
+
differs: [],
|
|
353
|
+
cases: [],
|
|
354
|
+
notHandled: [],
|
|
355
|
+
unknowns: [],
|
|
356
|
+
criteria: []
|
|
357
|
+
};
|
|
358
|
+
checkHeadings(document, {
|
|
359
|
+
title: true,
|
|
360
|
+
required: [
|
|
361
|
+
"Steps",
|
|
362
|
+
"Cases",
|
|
363
|
+
"Acceptance criteria"
|
|
364
|
+
],
|
|
365
|
+
optional: ["Differs by app", "Not handled"]
|
|
366
|
+
}, sink);
|
|
367
|
+
flow.steps = parseSteps(file, document, sink);
|
|
368
|
+
flow.differs = readListLines(file, findSection(document, "differs by app")?.lines, "Differs by app", sink);
|
|
369
|
+
flow.cases = parseCases(file, document, sink);
|
|
370
|
+
flow.notHandled = readListLines(file, findSection(document, "not handled")?.lines, "Not handled", sink, CASE_QUESTIONS);
|
|
371
|
+
flow.criteria = parseCriteria(file, document, sink);
|
|
372
|
+
for (const line of document.body) {
|
|
373
|
+
const trimmed = line.text.trim();
|
|
374
|
+
if (!line.fenced && trimmed.startsWith("Unknown:")) flow.unknowns.push({
|
|
375
|
+
text: trimmed.slice(8).trim(),
|
|
376
|
+
at: lineAt(file, line.line)
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
const cases = findSection(document, "cases");
|
|
380
|
+
if (cases !== null) {
|
|
381
|
+
const answered = /* @__PURE__ */ new Set([...flow.cases.map((entry) => entry.question), ...flow.notHandled.map((entry) => normalizeKey(entry.name))]);
|
|
382
|
+
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));
|
|
383
|
+
}
|
|
384
|
+
return flow;
|
|
385
|
+
}
|
|
386
|
+
/** `grimoire/features/<feature>/versions/v<n>.md`: free text under a title. */
|
|
387
|
+
function parseVersionBrief(file, text, feature, major, sink) {
|
|
388
|
+
const document = readDocument(file, text, "none", sink);
|
|
389
|
+
new FrontMatterReader(document, sink).onlyKeys([], "a version brief");
|
|
390
|
+
return {
|
|
391
|
+
file,
|
|
392
|
+
feature,
|
|
393
|
+
major,
|
|
394
|
+
heading: heading(document)
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
//#endregion
|
|
399
|
+
export { CHANGE_WORDS, ORIGINS, STATUSES, STEP_TYPES, parseChangelog, parseFeatureReadme, parseFlow, parseVersionBrief, splitEntryText };
|
|
400
|
+
//# sourceMappingURL=features.mjs.map
|
|
@@ -0,0 +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,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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AAK,WAAW,cAAc,MAAM,UAAU,IAAI;CAElD,KAAK,MAAM,QAAQ,SAAS,MAAM;EAChC,MAAM,UAAU,KAAK,KAAK,KAAK;EAE/B,IAAI,CAAC,KAAK,UAAU,QAAQ,WAAW,UAAU,GAC/C,KAAK,SAAS,KAAK;GACjB,MAAM,QAAQ,MAAM,CAAiB,CAAC,CAAC,KAAK;GAC5C,IAAI,OAAO,MAAM,KAAK,IAAI;EAC5B,CAAC;CAEL;CAEA,MAAM,QAAQ,YAAY,UAAU,OAAO;CAE3C,IAAI,UAAU,MAAM;EAClB,MAAM,2BAAW,IAAI,IAAI,CACvB,GAAG,KAAK,MAAM,KAAK,UAAU,MAAM,QAAQ,GAC3C,GAAG,KAAK,WAAW,KAAK,UAAU,aAAa,MAAM,IAAI,CAAC,CAC5D,CAAC;EAED,KAAK,MAAM,YAAY,gBACrB,IAAI,CAAC,SAAS,IAAI,QAAQ,GACxB,KAAK,OACH,UACA,sBAAsB,SAAS,2DAC/B,OAAO,MAAM,MAAM,IAAI,CACzB;CAGN;CAEA,OAAO;AACT;;AAKA,SAAgB,kBACd,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"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { toPosixPath } from "../paths/index.mjs";
|
|
2
|
+
import { lineAt } from "./markdown.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../packages/grimoire/src/written/fields.ts
|
|
5
|
+
/** An id: lower-case words joined by single dashes (`new-arrivals`). */
|
|
6
|
+
const ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
7
|
+
/** A feature version: `2.1`. */
|
|
8
|
+
const VERSION = /^\d+\.\d+$/;
|
|
9
|
+
/** A task id: `T-14`. */
|
|
10
|
+
const TASK_ID = /^T-\d+$/;
|
|
11
|
+
/** A flow reference: `<feature>/<flow>`. */
|
|
12
|
+
const FLOW_REF = /^[a-z0-9]+(?:-[a-z0-9]+)*\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
13
|
+
/**
|
|
14
|
+
* The separator between the name and the text of a list line: two or more
|
|
15
|
+
* spaces, or a tab with any spaces around it.
|
|
16
|
+
*/
|
|
17
|
+
const SEP = String.raw`(?:[ \t]*\t[ \t]*| {2,})`;
|
|
18
|
+
/** Whether `value` is a real calendar date written `yyyy-mm-dd`. */
|
|
19
|
+
function isDate(value) {
|
|
20
|
+
const match = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
|
|
21
|
+
if (!match) return false;
|
|
22
|
+
const year = Number(match[1]);
|
|
23
|
+
const month = Number(match[2]);
|
|
24
|
+
const day = Number(match[3]);
|
|
25
|
+
const date = new Date(Date.UTC(year, month - 1, day));
|
|
26
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A project-relative folder as written in front matter, with `\` turned
|
|
30
|
+
* into `/`, a leading `./` and trailing `/` removed. `null` when it is
|
|
31
|
+
* absolute or leaves the project.
|
|
32
|
+
*/
|
|
33
|
+
function projectFolder(value) {
|
|
34
|
+
const posix = toPosixPath(value.trim()).replace(/^(?:\.\/)+/, "").replace(/\/+$/, "");
|
|
35
|
+
if (posix === "" || posix.startsWith("/") || /^[A-Za-z]:/.test(posix)) return null;
|
|
36
|
+
if (posix.split("/").includes("..")) return null;
|
|
37
|
+
return posix;
|
|
38
|
+
}
|
|
39
|
+
/** Reads the front matter of one document against its template. */
|
|
40
|
+
var FrontMatterReader = class {
|
|
41
|
+
document;
|
|
42
|
+
sink;
|
|
43
|
+
fields;
|
|
44
|
+
constructor(document, sink) {
|
|
45
|
+
this.document = document;
|
|
46
|
+
this.sink = sink;
|
|
47
|
+
this.fields = document.fields ?? /* @__PURE__ */ new Map();
|
|
48
|
+
}
|
|
49
|
+
/** Whether the file had a front matter block at all. */
|
|
50
|
+
get present() {
|
|
51
|
+
return this.document.fields !== null;
|
|
52
|
+
}
|
|
53
|
+
at(line) {
|
|
54
|
+
return lineAt(this.document.file, line);
|
|
55
|
+
}
|
|
56
|
+
/** Where a missing key is reported: the opening `---`. */
|
|
57
|
+
get top() {
|
|
58
|
+
return this.at(1);
|
|
59
|
+
}
|
|
60
|
+
/** GR1005 for each key that is not one of `keys`. */
|
|
61
|
+
onlyKeys(keys, what) {
|
|
62
|
+
for (const field of this.fields.values()) if (!keys.includes(field.key)) this.sink.report("GR1005", keys.length === 0 ? `${what} has no front matter; the key "${field.key}" is not read.` : `the front matter key "${field.key}" is not part of the ${what} template (${keys.join(", ")}).`, this.at(field.line));
|
|
63
|
+
}
|
|
64
|
+
/** Whether the key is written. */
|
|
65
|
+
has(key) {
|
|
66
|
+
return this.fields.has(key);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A scalar value, checked with `check` (which returns the form expected
|
|
70
|
+
* when the value is wrong). Missing → GR1003 when `required` (only when
|
|
71
|
+
* the file has front matter: GR1001 already covers a file with none).
|
|
72
|
+
*/
|
|
73
|
+
scalar(key, options) {
|
|
74
|
+
const field = this.fields.get(key);
|
|
75
|
+
if (!field) {
|
|
76
|
+
if (options.required && this.present) this.sink.report("GR1003", `the front matter key "${key}" is missing.`, this.top);
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const at = this.at(field.line);
|
|
80
|
+
if (Array.isArray(field.value)) {
|
|
81
|
+
this.sink.report("GR1004", field.value.length === 0 ? `the front matter key "${key}" has no value.` : `the front matter key "${key}" must be one value, not a list.`, at);
|
|
82
|
+
return {
|
|
83
|
+
value: field.value.join(", "),
|
|
84
|
+
at
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
const expected = options.check?.(field.value) ?? null;
|
|
88
|
+
if (expected !== null) this.sink.report("GR1004", `the front matter key "${key}" is ${JSON.stringify(field.value)}; ${expected}.`, at);
|
|
89
|
+
return {
|
|
90
|
+
value: field.value,
|
|
91
|
+
at
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
/** A required scalar; a missing one becomes `""` at the top of the file. */
|
|
95
|
+
required(key, check) {
|
|
96
|
+
return this.scalar(key, check ? {
|
|
97
|
+
required: true,
|
|
98
|
+
check
|
|
99
|
+
} : { required: true }) ?? {
|
|
100
|
+
value: "",
|
|
101
|
+
at: this.top
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/** A scalar that must be one of `values`; `fallback` is used when it is missing or wrong. */
|
|
105
|
+
oneOf(key, values, fallback) {
|
|
106
|
+
const located = this.scalar(key, {
|
|
107
|
+
required: true,
|
|
108
|
+
check: (value) => values.includes(value) ? null : `use one of: ${values.join(", ")}`
|
|
109
|
+
});
|
|
110
|
+
if (located === null) return {
|
|
111
|
+
value: fallback,
|
|
112
|
+
at: this.top
|
|
113
|
+
};
|
|
114
|
+
return {
|
|
115
|
+
value: values.includes(located.value) ? located.value : fallback,
|
|
116
|
+
at: located.at
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** An optional scalar that must be one of `values`; `null` when missing or wrong. */
|
|
120
|
+
optionalOneOf(key, values) {
|
|
121
|
+
const located = this.scalar(key, {
|
|
122
|
+
required: false,
|
|
123
|
+
check: (value) => values.includes(value) ? null : `use one of: ${values.join(", ")}`
|
|
124
|
+
});
|
|
125
|
+
if (located === null || !values.includes(located.value)) return null;
|
|
126
|
+
return {
|
|
127
|
+
value: located.value,
|
|
128
|
+
at: located.at
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* A list value (`[a, b]` or `- item` lines; a single scalar is a list of
|
|
133
|
+
* one). Each item is checked with `check`; a wrong item is reported and
|
|
134
|
+
* left out unless `keepWrong` is set.
|
|
135
|
+
*/
|
|
136
|
+
list(key, options) {
|
|
137
|
+
const field = this.fields.get(key);
|
|
138
|
+
if (!field) {
|
|
139
|
+
if (options.required && this.present) this.sink.report("GR1003", `the front matter key "${key}" is missing.`, this.top);
|
|
140
|
+
return [];
|
|
141
|
+
}
|
|
142
|
+
const items = Array.isArray(field.value) ? field.value : field.value === "" ? [] : [field.value];
|
|
143
|
+
const result = [];
|
|
144
|
+
items.forEach((item, index) => {
|
|
145
|
+
const at = this.at(field.itemLines[index] ?? field.line);
|
|
146
|
+
const expected = options.check?.(item) ?? null;
|
|
147
|
+
if (expected !== null) {
|
|
148
|
+
this.sink.report("GR1004", `the "${key}" item ${JSON.stringify(item)} is wrong: ${expected}.`, at);
|
|
149
|
+
if (!options.keepWrong) return;
|
|
150
|
+
}
|
|
151
|
+
result.push({
|
|
152
|
+
value: options.map ? options.map(item) : item,
|
|
153
|
+
at
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
return result;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
/** Checks used with `FrontMatterReader`; each returns the expected form, or `null` when the value is right. */
|
|
160
|
+
const checks = {
|
|
161
|
+
id: (value) => ID.test(value) ? null : "write it in lower-case words joined by dashes",
|
|
162
|
+
version: (value) => VERSION.test(value) ? null : "write a version as <whole>.<decimal>, like 2.1",
|
|
163
|
+
date: (value) => isDate(value) ? null : "write a date as yyyy-mm-dd",
|
|
164
|
+
text: (value) => value.trim() === "" ? "write a value" : null,
|
|
165
|
+
route: (value) => value.startsWith("/") ? null : "a route path starts with /",
|
|
166
|
+
flowRef: (value) => FLOW_REF.test(value) ? null : "write it as <feature>/<flow>",
|
|
167
|
+
folder: (value) => projectFolder(value) === null ? "write a folder relative to the project root" : null,
|
|
168
|
+
name: (value) => value.trim() === "" || /\s/.test(value.trim()) ? "write it without spaces" : null
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
//#endregion
|
|
172
|
+
export { FLOW_REF, FrontMatterReader, ID, SEP, TASK_ID, VERSION, checks, isDate, projectFolder };
|
|
173
|
+
//# sourceMappingURL=fields.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/fields.ts"],"sourcesContent":["/**\n * The value grammar of the written files and the readers that turn front\n * matter fields into located values, reporting GR1003 (missing), GR1004\n * (wrong form) and GR1005 (not in the template) as they go.\n */\nimport type { Located } from \"../contracts/location\";\nimport type { FrontMatterField } from \"../front-matter\";\nimport { toPosixPath } from \"../paths\";\nimport { lineAt, type WrittenDocument } from \"./markdown\";\nimport type { FindingSink } from \"./sink\";\n\n/** An id: lower-case words joined by single dashes (`new-arrivals`). */\nexport const ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n/** A feature version: `2.1`. */\nexport const VERSION = /^\\d+\\.\\d+$/;\n/** A task id: `T-14`. */\nexport const TASK_ID = /^T-\\d+$/;\n/** A flow reference: `<feature>/<flow>`. */\nexport const FLOW_REF = /^[a-z0-9]+(?:-[a-z0-9]+)*\\/[a-z0-9]+(?:-[a-z0-9]+)*$/;\n/**\n * The separator between the name and the text of a list line: two or more\n * spaces, or a tab with any spaces around it.\n */\nexport const SEP = String.raw`(?:[ \\t]*\\t[ \\t]*| {2,})`;\n\n/** Whether `value` is a real calendar date written `yyyy-mm-dd`. */\nexport function isDate(value: string): boolean {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value);\n\n if (!match) return false;\n\n const year = Number(match[1]);\n const month = Number(match[2]);\n const day = Number(match[3]);\n const date = new Date(Date.UTC(year, month - 1, day));\n\n return (\n date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day\n );\n}\n\n/**\n * A project-relative folder as written in front matter, with `\\` turned\n * into `/`, a leading `./` and trailing `/` removed. `null` when it is\n * absolute or leaves the project.\n */\nexport function projectFolder(value: string): string | null {\n const posix = toPosixPath(value.trim())\n .replace(/^(?:\\.\\/)+/, \"\")\n .replace(/\\/+$/, \"\");\n\n if (posix === \"\" || posix.startsWith(\"/\") || /^[A-Za-z]:/.test(posix)) return null;\n if (posix.split(\"/\").includes(\"..\")) return null;\n\n return posix;\n}\n\n/** Reads the front matter of one document against its template. */\nexport class FrontMatterReader {\n private readonly fields: Map<string, FrontMatterField>;\n\n public constructor(\n private readonly document: WrittenDocument,\n private readonly sink: FindingSink,\n ) {\n this.fields = document.fields ?? new Map();\n }\n\n /** Whether the file had a front matter block at all. */\n public get present(): boolean {\n return this.document.fields !== null;\n }\n\n private at(line: number): Located<string>[\"at\"] {\n return lineAt(this.document.file, line);\n }\n\n /** Where a missing key is reported: the opening `---`. */\n private get top(): Located<string>[\"at\"] {\n return this.at(1);\n }\n\n /** GR1005 for each key that is not one of `keys`. */\n public onlyKeys(keys: readonly string[], what: string): void {\n for (const field of this.fields.values()) {\n if (!keys.includes(field.key)) {\n this.sink.report(\n \"GR1005\",\n keys.length === 0\n ? `${what} has no front matter; the key \"${field.key}\" is not read.`\n : `the front matter key \"${field.key}\" is not part of the ${what} template (${keys.join(\", \")}).`,\n this.at(field.line),\n );\n }\n }\n }\n\n /** Whether the key is written. */\n public has(key: string): boolean {\n return this.fields.has(key);\n }\n\n /**\n * A scalar value, checked with `check` (which returns the form expected\n * when the value is wrong). Missing → GR1003 when `required` (only when\n * the file has front matter: GR1001 already covers a file with none).\n */\n public scalar(\n key: string,\n options: { required: boolean; check?: (value: string) => string | null },\n ): Located<string> | null {\n const field = this.fields.get(key);\n\n if (!field) {\n if (options.required && this.present) {\n this.sink.report(\"GR1003\", `the front matter key \"${key}\" is missing.`, this.top);\n }\n\n return null;\n }\n\n const at = this.at(field.line);\n\n if (Array.isArray(field.value)) {\n this.sink.report(\n \"GR1004\",\n field.value.length === 0\n ? `the front matter key \"${key}\" has no value.`\n : `the front matter key \"${key}\" must be one value, not a list.`,\n at,\n );\n\n return { value: field.value.join(\", \"), at };\n }\n\n const expected = options.check?.(field.value) ?? null;\n\n if (expected !== null) {\n this.sink.report(\n \"GR1004\",\n `the front matter key \"${key}\" is ${JSON.stringify(field.value)}; ${expected}.`,\n at,\n );\n }\n\n return { value: field.value, at };\n }\n\n /** A required scalar; a missing one becomes `\"\"` at the top of the file. */\n public required(key: string, check?: (value: string) => string | null): Located<string> {\n return (\n this.scalar(key, check ? { required: true, check } : { required: true }) ?? {\n value: \"\",\n at: this.top,\n }\n );\n }\n\n /** A scalar that must be one of `values`; `fallback` is used when it is missing or wrong. */\n public oneOf<T extends string>(key: string, values: readonly T[], fallback: T): Located<T> {\n const located = this.scalar(key, {\n required: true,\n check: (value) => (values.includes(value as T) ? null : `use one of: ${values.join(\", \")}`),\n });\n\n if (located === null) return { value: fallback, at: this.top };\n\n return {\n value: values.includes(located.value as T) ? (located.value as T) : fallback,\n at: located.at,\n };\n }\n\n /** An optional scalar that must be one of `values`; `null` when missing or wrong. */\n public optionalOneOf<T extends string>(key: string, values: readonly T[]): Located<T> | null {\n const located = this.scalar(key, {\n required: false,\n check: (value) => (values.includes(value as T) ? null : `use one of: ${values.join(\", \")}`),\n });\n\n if (located === null || !values.includes(located.value as T)) return null;\n\n return { value: located.value as T, at: located.at };\n }\n\n /**\n * A list value (`[a, b]` or `- item` lines; a single scalar is a list of\n * one). Each item is checked with `check`; a wrong item is reported and\n * left out unless `keepWrong` is set.\n */\n public list(\n key: string,\n options: {\n required: boolean;\n check?: (value: string) => string | null;\n map?: (value: string) => string;\n keepWrong?: boolean;\n },\n ): Located<string>[] {\n const field = this.fields.get(key);\n\n if (!field) {\n if (options.required && this.present) {\n this.sink.report(\"GR1003\", `the front matter key \"${key}\" is missing.`, this.top);\n }\n\n return [];\n }\n\n const items = Array.isArray(field.value)\n ? field.value\n : field.value === \"\"\n ? []\n : [field.value];\n const result: Located<string>[] = [];\n\n items.forEach((item, index) => {\n const at = this.at(field.itemLines[index] ?? field.line);\n const expected = options.check?.(item) ?? null;\n\n if (expected !== null) {\n this.sink.report(\n \"GR1004\",\n `the \"${key}\" item ${JSON.stringify(item)} is wrong: ${expected}.`,\n at,\n );\n\n if (!options.keepWrong) return;\n }\n\n result.push({ value: options.map ? options.map(item) : item, at });\n });\n\n return result;\n }\n}\n\n/** Checks used with `FrontMatterReader`; each returns the expected form, or `null` when the value is right. */\nexport const checks = {\n id: (value: string): string | null =>\n ID.test(value) ? null : \"write it in lower-case words joined by dashes\",\n version: (value: string): string | null =>\n VERSION.test(value) ? null : \"write a version as <whole>.<decimal>, like 2.1\",\n date: (value: string): string | null => (isDate(value) ? null : \"write a date as yyyy-mm-dd\"),\n text: (value: string): string | null => (value.trim() === \"\" ? \"write a value\" : null),\n route: (value: string): string | null =>\n value.startsWith(\"/\") ? null : \"a route path starts with /\",\n flowRef: (value: string): string | null =>\n FLOW_REF.test(value) ? null : \"write it as <feature>/<flow>\",\n folder: (value: string): string | null =>\n projectFolder(value) === null ? \"write a folder relative to the project root\" : null,\n name: (value: string): string | null =>\n value.trim() === \"\" || /\\s/.test(value.trim()) ? \"write it without spaces\" : null,\n};\n"],"mappings":";;;;;AAYA,MAAa,KAAK;;AAElB,MAAa,UAAU;;AAEvB,MAAa,UAAU;;AAEvB,MAAa,WAAW;;;;;AAKxB,MAAa,MAAM,OAAO,GAAG;;AAG7B,SAAgB,OAAO,OAAwB;CAC7C,MAAM,QAAQ,4BAA4B,KAAK,KAAK;CAEpD,IAAI,CAAC,OAAO,OAAO;CAEnB,MAAM,OAAO,OAAO,MAAM,EAAE;CAC5B,MAAM,QAAQ,OAAO,MAAM,EAAE;CAC7B,MAAM,MAAM,OAAO,MAAM,EAAE;CAC3B,MAAM,OAAO,IAAI,KAAK,KAAK,IAAI,MAAM,QAAQ,GAAG,GAAG,CAAC;CAEpD,OACE,KAAK,eAAe,MAAM,QAAQ,KAAK,YAAY,MAAM,QAAQ,KAAK,KAAK,WAAW,MAAM;AAEhG;;;;;;AAOA,SAAgB,cAAc,OAA8B;CAC1D,MAAM,QAAQ,YAAY,MAAM,KAAK,CAAC,CAAC,CACpC,QAAQ,cAAc,EAAE,CAAC,CAC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