@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,68 @@
|
|
|
1
|
+
import { lineAt, logicalLines } from "./markdown.mjs";
|
|
2
|
+
import { SEP } from "./fields.mjs";
|
|
3
|
+
|
|
4
|
+
//#region ../../packages/grimoire/src/written/lists.ts
|
|
5
|
+
/** A `-` or `*` bullet. */
|
|
6
|
+
const BULLET = /^[-*][ \t]+/;
|
|
7
|
+
const LIST_LINE = new RegExp(String.raw`^[-*][ \t]+(\S.*?)${SEP}(\S.*)$`);
|
|
8
|
+
const TOKEN_LINE = /^[-*][ \t]+(\S+)[ \t]+(\S.*)$/;
|
|
9
|
+
function escapeRegExp(text) {
|
|
10
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
11
|
+
}
|
|
12
|
+
/** The bullet lines of a section, continuation lines joined. */
|
|
13
|
+
function bulletLines(lines) {
|
|
14
|
+
return logicalLines(lines).filter((line) => BULLET.test(line.text));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Split one `- name text` line, or `null` when it does not have that form.
|
|
18
|
+
* Two or more spaces (or a tab) end the name. Without them, a known name
|
|
19
|
+
* (in any case, with any spaces between its words) is tried, and then the
|
|
20
|
+
* name is the first word.
|
|
21
|
+
*/
|
|
22
|
+
function splitListLine(text, known = []) {
|
|
23
|
+
const separated = LIST_LINE.exec(text);
|
|
24
|
+
if (separated) return {
|
|
25
|
+
name: (separated[1] ?? "").trim(),
|
|
26
|
+
text: (separated[2] ?? "").trim()
|
|
27
|
+
};
|
|
28
|
+
const rest = text.replace(BULLET, "").trim().replace(/\s+/g, " ").toLowerCase();
|
|
29
|
+
if (known.some((name) => name.toLowerCase() === rest)) return null;
|
|
30
|
+
for (const name of [...known].sort((left, right) => right.length - left.length)) {
|
|
31
|
+
const words = name.trim().split(/\s+/).map(escapeRegExp).join("[ \\t]+");
|
|
32
|
+
const match = new RegExp(String.raw`^[-*][ \t]+(${words})[ \t]+(\S.*)$`, "i").exec(text);
|
|
33
|
+
if (match) return {
|
|
34
|
+
name: (match[1] ?? "").trim(),
|
|
35
|
+
text: (match[2] ?? "").trim()
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const match = TOKEN_LINE.exec(text);
|
|
39
|
+
if (!match) return null;
|
|
40
|
+
return {
|
|
41
|
+
name: (match[1] ?? "").trim(),
|
|
42
|
+
text: (match[2] ?? "").trim()
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Read a list section. A bullet with a name and no text is reported with
|
|
47
|
+
* GR1028 and left out.
|
|
48
|
+
*/
|
|
49
|
+
function readListLines(file, lines, what, sink, known = []) {
|
|
50
|
+
const result = [];
|
|
51
|
+
for (const line of bulletLines(lines ?? [])) {
|
|
52
|
+
const split = splitListLine(line.text, known);
|
|
53
|
+
if (split === null) {
|
|
54
|
+
sink.report("GR1028", `the ${what} line ${JSON.stringify(line.text)} is not \`- name text\` (the name, spaces, then the text).`, lineAt(file, line.line));
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
result.push({
|
|
58
|
+
name: split.name,
|
|
59
|
+
text: split.text,
|
|
60
|
+
at: lineAt(file, line.line)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
//#endregion
|
|
67
|
+
export { BULLET, bulletLines, readListLines, splitListLine };
|
|
68
|
+
//# sourceMappingURL=lists.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lists.mjs","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/lists.ts"],"sourcesContent":["/**\n * List sections: `- name text` lines (a `-` or `*` bullet, the name,\n * spaces or a tab, the text), with indented continuation lines. Lines that\n * are not bullets are free text and are skipped.\n *\n * Two or more spaces line the texts up, but one space is read too: a\n * Markdown formatter collapses the spaces of a list line to one.\n */\nimport type { WrittenListLine } from \"../contracts/written\";\nimport { SEP } from \"./fields\";\nimport { lineAt, logicalLines, type BodyLine, type LogicalLine } from \"./markdown\";\nimport type { FindingSink } from \"./sink\";\n\n/** A `-` or `*` bullet. */\nexport const BULLET = /^[-*][ \\t]+/;\nconst LIST_LINE = new RegExp(String.raw`^[-*][ \\t]+(\\S.*?)${SEP}(\\S.*)$`);\nconst TOKEN_LINE = /^[-*][ \\t]+(\\S+)[ \\t]+(\\S.*)$/;\n\n/** Names of several words that a list line may start with (the case questions). */\nexport type ListNames = readonly string[];\n\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/** The bullet lines of a section, continuation lines joined. */\nexport function bulletLines(lines: readonly BodyLine[]): LogicalLine[] {\n return logicalLines(lines).filter((line) => BULLET.test(line.text));\n}\n\n/**\n * Split one `- name text` line, or `null` when it does not have that form.\n * Two or more spaces (or a tab) end the name. Without them, a known name\n * (in any case, with any spaces between its words) is tried, and then the\n * name is the first word.\n */\nexport function splitListLine(\n text: string,\n known: ListNames = [],\n): { name: string; text: string } | null {\n const separated = LIST_LINE.exec(text);\n\n if (separated) return { name: (separated[1] ?? \"\").trim(), text: (separated[2] ?? \"\").trim() };\n\n const rest = text.replace(BULLET, \"\").trim().replace(/\\s+/g, \" \").toLowerCase();\n\n // A known name alone (`- invalid input`) has no text.\n if (known.some((name) => name.toLowerCase() === rest)) return null;\n\n for (const name of [...known].sort((left, right) => right.length - left.length)) {\n const words = name.trim().split(/\\s+/).map(escapeRegExp).join(\"[ \\\\t]+\");\n const match = new RegExp(String.raw`^[-*][ \\t]+(${words})[ \\t]+(\\S.*)$`, \"i\").exec(text);\n\n if (match) return { name: (match[1] ?? \"\").trim(), text: (match[2] ?? \"\").trim() };\n }\n\n const match = TOKEN_LINE.exec(text);\n\n if (!match) return null;\n\n return { name: (match[1] ?? \"\").trim(), text: (match[2] ?? \"\").trim() };\n}\n\n/**\n * Read a list section. A bullet with a name and no text is reported with\n * GR1028 and left out.\n */\nexport function readListLines(\n file: string,\n lines: readonly BodyLine[] | undefined,\n what: string,\n sink: FindingSink,\n known: ListNames = [],\n): WrittenListLine[] {\n const result: WrittenListLine[] = [];\n\n for (const line of bulletLines(lines ?? [])) {\n const split = splitListLine(line.text, known);\n\n if (split === null) {\n sink.report(\n \"GR1028\",\n `the ${what} line ${JSON.stringify(line.text)} is not \\`- name text\\` (the name, spaces, then the text).`,\n lineAt(file, line.line),\n );\n continue;\n }\n\n result.push({ name: split.name, text: split.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AAO,MAAM,MAAM,GAAE,CAAE,KAAK;EAAG,OAAO,MAAM,MAAM,GAAE,CAAE,KAAK;CAAE;AACxE;;;;;AAMA,SAAgB,cACd,MACA,OACA,MACA,MACA,QAAmB,CAAC,GACD;CACnB,MAAM,SAA4B,CAAC;CAEnC,KAAK,MAAM,QAAQ,YAAY,SAAS,CAAC,CAAC,GAAG;EAC3C,MAAM,QAAQ,cAAc,KAAK,MAAM,KAAK;EAE5C,IAAI,UAAU,MAAM;GAClB,KAAK,OACH,UACA,OAAO,KAAK,QAAQ,KAAK,UAAU,KAAK,IAAI,EAAE,+DAC9C,OAAO,MAAM,KAAK,IAAI,CACxB;GACA;EACF;EAEA,OAAO,KAAK;GAAE,MAAM,MAAM;GAAM,MAAM,MAAM;GAAM,IAAI,OAAO,MAAM,KAAK,IAAI;EAAE,CAAC;CACjF;CAEA,OAAO;AACT"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { readFrontMatter } from "../front-matter/index.mjs";
|
|
2
|
+
|
|
3
|
+
//#region ../../packages/grimoire/src/written/markdown.ts
|
|
4
|
+
const HEADING = /^(#{1,6})[ \t]+(.+?)(?:[ \t]+#+)?$/;
|
|
5
|
+
const FENCE = /^[ \t]*(?:```|~~~)/;
|
|
6
|
+
const ITEM_START = /^(?:[-*][ \t]|\d+\.[ \t])/;
|
|
7
|
+
/** Lower-case a heading or a question and collapse its spaces. */
|
|
8
|
+
function normalizeKey(text) {
|
|
9
|
+
return text.trim().replace(/\s+/g, " ").toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
/** Split text into lines on `\n`, `\r\n` or a lone `\r`. A leading BOM is dropped. */
|
|
12
|
+
function splitLines(text) {
|
|
13
|
+
return text.replace(/^\uFEFF/, "").split(/\r\n|\r|\n/);
|
|
14
|
+
}
|
|
15
|
+
/** A location of a whole line. */
|
|
16
|
+
function lineAt(file, line) {
|
|
17
|
+
return {
|
|
18
|
+
file,
|
|
19
|
+
line,
|
|
20
|
+
column: null
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Read a written file: its front matter (GR1001 when `frontMatter` is
|
|
25
|
+
* `"required"` and the file has none; GR1002 for lines it cannot read),
|
|
26
|
+
* then its headings and `##` sections.
|
|
27
|
+
*/
|
|
28
|
+
function readDocument(file, text, frontMatter, sink) {
|
|
29
|
+
const raw = splitLines(text);
|
|
30
|
+
let fields = null;
|
|
31
|
+
let bodyStartLine = 1;
|
|
32
|
+
if (frontMatter === "required" || raw[0]?.trim() === "---") {
|
|
33
|
+
const result = readFrontMatter(raw.join("\n"), file);
|
|
34
|
+
if (frontMatter === "required" || result.fields !== null) {
|
|
35
|
+
for (const error of result.errors) sink.push(error);
|
|
36
|
+
fields = result.fields;
|
|
37
|
+
bodyStartLine = result.bodyStartLine;
|
|
38
|
+
}
|
|
39
|
+
if (fields === null && result.errors.length === 0 && frontMatter === "required") sink.report("GR1001", "the file has no front matter; it must start with a `---` line.", lineAt(file, 1));
|
|
40
|
+
}
|
|
41
|
+
const body = [];
|
|
42
|
+
const headings = [];
|
|
43
|
+
let inFence = false;
|
|
44
|
+
for (let index = bodyStartLine - 1; index < raw.length; index++) {
|
|
45
|
+
const text = (raw[index] ?? "").trimEnd();
|
|
46
|
+
const line = index + 1;
|
|
47
|
+
const fenceLine = FENCE.test(text);
|
|
48
|
+
if (fenceLine) inFence = !inFence;
|
|
49
|
+
const fenced = inFence || fenceLine;
|
|
50
|
+
body.push({
|
|
51
|
+
text,
|
|
52
|
+
line,
|
|
53
|
+
fenced
|
|
54
|
+
});
|
|
55
|
+
if (fenced) continue;
|
|
56
|
+
const heading = HEADING.exec(text);
|
|
57
|
+
if (heading) headings.push({
|
|
58
|
+
level: (heading[1] ?? "").length,
|
|
59
|
+
text: (heading[2] ?? "").trim(),
|
|
60
|
+
line
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const sections = [];
|
|
64
|
+
let title = null;
|
|
65
|
+
let current = null;
|
|
66
|
+
const firstBodyLine = body[0]?.line ?? bodyStartLine;
|
|
67
|
+
let headingIndex = 0;
|
|
68
|
+
for (const bodyLine of body) {
|
|
69
|
+
const heading = headings[headingIndex];
|
|
70
|
+
if (heading !== void 0 && heading.line === bodyLine.line) {
|
|
71
|
+
headingIndex++;
|
|
72
|
+
if (heading.level === 1) {
|
|
73
|
+
title ??= heading;
|
|
74
|
+
current = null;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (heading.level === 2) {
|
|
78
|
+
current = {
|
|
79
|
+
title: heading.text,
|
|
80
|
+
key: normalizeKey(heading.text),
|
|
81
|
+
line: heading.line,
|
|
82
|
+
lines: []
|
|
83
|
+
};
|
|
84
|
+
sections.push(current);
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
current?.lines.push(bodyLine);
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
file,
|
|
92
|
+
raw,
|
|
93
|
+
fields,
|
|
94
|
+
body,
|
|
95
|
+
title,
|
|
96
|
+
sections,
|
|
97
|
+
bodyStartLine: Math.min(firstBodyLine, raw.length) || 1
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/** The first section with this (normalised) title. */
|
|
101
|
+
function findSection(document, key) {
|
|
102
|
+
return document.sections.find((section) => section.key === key) ?? null;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* GR1006 for each required `##` heading that is missing (and for a missing
|
|
106
|
+
* `#` title when `title` is required); GR1007 for each `##` heading the
|
|
107
|
+
* template does not have, or one written twice.
|
|
108
|
+
*/
|
|
109
|
+
function checkHeadings(document, template, sink) {
|
|
110
|
+
const where = lineAt(document.file, document.title?.line ?? document.bodyStartLine);
|
|
111
|
+
if (template.title && document.title === null) sink.report("GR1006", "the file has no `# ` title heading.", where);
|
|
112
|
+
for (const required of template.required) if (!document.sections.some((section) => section.key === normalizeKey(required))) sink.report("GR1006", `the heading "## ${required}" is missing.`, where);
|
|
113
|
+
const known = new Set([...template.required, ...template.optional].map(normalizeKey));
|
|
114
|
+
const seen = /* @__PURE__ */ new Set();
|
|
115
|
+
for (const section of document.sections) {
|
|
116
|
+
if (!known.has(section.key)) sink.report("GR1007", `the heading "## ${section.title}" is not part of the template.`, lineAt(document.file, section.line));
|
|
117
|
+
else if (seen.has(section.key)) sink.report("GR1007", `the heading "## ${section.title}" is written twice; only the first is read.`, lineAt(document.file, section.line));
|
|
118
|
+
seen.add(section.key);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The logical lines of some body lines: a line that does not start with
|
|
123
|
+
* whitespace (or that starts a list item) opens a new logical line, and the
|
|
124
|
+
* indented lines right after it are joined to it with one space. Blank lines
|
|
125
|
+
* and fenced lines end the current one.
|
|
126
|
+
*/
|
|
127
|
+
function logicalLines(lines) {
|
|
128
|
+
const result = [];
|
|
129
|
+
let open = null;
|
|
130
|
+
for (const bodyLine of lines) {
|
|
131
|
+
const trimmed = bodyLine.text.trim();
|
|
132
|
+
if (bodyLine.fenced || trimmed === "") {
|
|
133
|
+
open = null;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const indented = /^[ \t]/.test(bodyLine.text);
|
|
137
|
+
if (open !== null && indented && !ITEM_START.test(trimmed)) {
|
|
138
|
+
open.text = `${open.text} ${trimmed}`;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
open = {
|
|
142
|
+
text: trimmed,
|
|
143
|
+
line: bodyLine.line
|
|
144
|
+
};
|
|
145
|
+
result.push(open);
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
/** The first paragraph after the `# ` title: non-blank lines up to a blank line or a heading. */
|
|
150
|
+
function paragraphAfterTitle(document) {
|
|
151
|
+
if (document.title === null) return null;
|
|
152
|
+
const parts = [];
|
|
153
|
+
for (const bodyLine of document.body) {
|
|
154
|
+
if (bodyLine.line <= document.title.line) continue;
|
|
155
|
+
const trimmed = bodyLine.text.trim();
|
|
156
|
+
if (bodyLine.fenced || trimmed.startsWith("#")) break;
|
|
157
|
+
if (trimmed === "") {
|
|
158
|
+
if (parts.length > 0) break;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
parts.push(trimmed);
|
|
162
|
+
}
|
|
163
|
+
return parts.length > 0 ? parts.join(" ") : null;
|
|
164
|
+
}
|
|
165
|
+
/** The body text after the `# ` title (or the whole body), trimmed. */
|
|
166
|
+
function textAfterTitle(document, endLine) {
|
|
167
|
+
const from = document.title?.line ?? 0;
|
|
168
|
+
return document.body.filter((bodyLine) => bodyLine.line > from && (endLine === void 0 || bodyLine.line < endLine)).map((bodyLine) => bodyLine.text).join("\n").trim();
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
//#endregion
|
|
172
|
+
export { checkHeadings, findSection, lineAt, logicalLines, normalizeKey, paragraphAfterTitle, readDocument, splitLines, textAfterTitle };
|
|
173
|
+
//# sourceMappingURL=markdown.mjs.map
|
|
@@ -0,0 +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,MAAM,QAAQ,IAAI,UAAU,GAAE,CAAE,QAAQ;EACxC,MAAM,OAAO,QAAQ;EAC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AAM;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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GrimoireFinding } from "../contracts/findings.mjs";
|
|
2
|
+
import { WrittenGrimoire } from "../contracts/written.mjs";
|
|
3
|
+
//#region ../../packages/grimoire/src/written/parse-grimoire.d.ts
|
|
4
|
+
/** What `parseGrimoire()` returns. */
|
|
5
|
+
export type ParseGrimoireResult = {
|
|
6
|
+
written: WrittenGrimoire;
|
|
7
|
+
/** Structure findings (`GR1xxx`), in file and line order. */
|
|
8
|
+
findings: GrimoireFinding[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Parse every written file under `<root>/grimoire`. A project without a
|
|
12
|
+
* `grimoire/` folder gives `written.exists === false` and no findings. Bad
|
|
13
|
+
* input never throws: each problem is a `GR1xxx` finding at its line, and
|
|
14
|
+
* the rest of the file is still read.
|
|
15
|
+
*
|
|
16
|
+
* @param root Absolute project root.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseGrimoire(root: string): Promise<ParseGrimoireResult>;
|
|
19
|
+
//#endregion
|
|
20
|
+
//# sourceMappingURL=parse-grimoire.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse-grimoire.d.mts","names":[],"sources":["../../../../../../../../packages/grimoire/src/written/parse-grimoire.ts"],"mappings":";;;;YA6BY;EACV,SAAS;;EAET,UAAU;;;;;;;;;;wBAkeU,cAAc,eAAe,QAAQ"}
|