@oscaner-skills/cdd-engine 4.2.0 → 4.4.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/README.md +38 -9
- package/README.zh-CN.md +44 -10
- package/dist/contract/completion-criterion.js +351 -0
- package/dist/contract/declare.js +181 -43
- package/dist/contract/doc.js +84 -271
- package/dist/contract/frontmatter.js +2 -1
- package/dist/contract/home-extractors.js +49 -316
- package/dist/contract/invariants.js +400 -296
- package/dist/contract/judge.js +74 -49
- package/dist/contract/lint.js +3 -2
- package/dist/contract/liveness-signal.js +103 -0
- package/dist/contract/markdown-document.js +410 -0
- package/dist/contract/markdown-tree-types.js +6 -0
- package/dist/contract/markdown-tree.js +137 -0
- package/dist/contract/project.js +1 -1
- package/dist/contract/rules.js +106 -0
- package/dist/contract/selector-engine.js +332 -0
- package/dist/contract/selector-spec.js +74 -0
- package/dist/contract/skill-anatomy.js +29 -1
- package/dist/contract/task-block-grammar.js +285 -0
- package/dist/contract/task-blocks.js +65 -0
- package/dist/contract/translate.js +21 -0
- package/dist/contract/wave-width.js +15 -0
- package/dist/face/board-view.js +382 -172
- package/dist/face/capsule.js +73 -88
- package/dist/face/cli.js +152 -38
- package/dist/face/declare.js +42 -19
- package/dist/face/gate.js +119 -40
- package/dist/face/init.js +84 -25
- package/dist/face/lifecycle.js +540 -123
- package/dist/face/plugins.js +70 -2
- package/dist/face/preview.js +69 -18
- package/dist/face/route-render.js +60 -21
- package/dist/face/termination.js +135 -261
- package/dist/face/words.js +139 -13
- package/dist/infra/atomic.js +15 -0
- package/dist/infra/git.js +25 -0
- package/dist/infra/proc.js +150 -0
- package/dist/infra/round-log.js +104 -0
- package/dist/infra/runtime.js +16 -4
- package/dist/infra/workspace.js +7 -2
- package/dist/render/brief.js +15 -17
- package/dist/render/skeleton.js +41 -28
- package/dist/render/templates.js +128 -84
- package/dist/session/faces.js +47 -20
- package/dist/session/graph.js +13 -37
- package/dist/session/handoff-schema.js +16 -8
- package/dist/session/inflight.js +282 -0
- package/dist/session/ledger.js +603 -145
- package/dist/session/line-identity.js +33 -0
- package/dist/session/next.js +140 -80
- package/dist/session/pipeline.js +247 -0
- package/dist/session/preflight.js +276 -68
- package/dist/session/reviewed-identity.js +54 -0
- package/dist/session/round-naming.js +56 -8
- package/dist/session/run.js +364 -80
- package/dist/session/wave.js +94 -14
- package/package.json +13 -3
package/dist/contract/doc.js
CHANGED
|
@@ -29,18 +29,15 @@
|
|
|
29
29
|
// Module-level exports are types / the class family / one composition root — zero
|
|
30
30
|
// behavior-carrying bare functions (the plan's zero-bare-function discipline).
|
|
31
31
|
import { declaredRegistries } from "./declare.js";
|
|
32
|
-
import { DesignBodyExtractor,
|
|
32
|
+
import { DesignBodyExtractor, HeadingScanner } from "./home-extractors.js";
|
|
33
|
+
import { MarkdownTree } from "./markdown-tree.js";
|
|
33
34
|
import { Projector } from "./project.js";
|
|
34
35
|
/** The projection carrier — one Projector instance over the declared registries,
|
|
35
36
|
* shared by the four parser classes (each binds its own doc-type faces). */
|
|
36
37
|
const projector = new Projector(declaredRegistries);
|
|
37
|
-
/** The home-driven extractors — the fixed structure rules of the
|
|
38
|
-
*
|
|
39
|
-
* those surfaces. */
|
|
40
|
-
const taskExtractor = new TaskExtractor();
|
|
38
|
+
/** The home-driven extractors — the fixed structure rules of the design / section
|
|
39
|
+
* homes (spec §3.2), shared by the parsers that read those surfaces. */
|
|
41
40
|
const designExtractor = new DesignBodyExtractor();
|
|
42
|
-
const graphExtractor = new GraphExtractor();
|
|
43
|
-
const tableExtractor = new TableExtractor();
|
|
44
41
|
const headingScanner = new HeadingScanner();
|
|
45
42
|
// ---------------------------------------------------------------------------
|
|
46
43
|
// the shared markdown primitives — one home for the link/token/table-row parsers
|
|
@@ -82,32 +79,6 @@ export class MarkdownPrimitives {
|
|
|
82
79
|
versionTokens(line) {
|
|
83
80
|
return MarkdownPrimitives.versionTokensOf(line);
|
|
84
81
|
}
|
|
85
|
-
/** The cells of one `|…|` table line (trimmed, wrapper bars excluded); null for a
|
|
86
|
-
* non-table line or a separator row. The separator-row rule is the
|
|
87
|
-
* TableExtractor's (the table home's fixed structure rule — one home). */
|
|
88
|
-
tableRowCells(line) {
|
|
89
|
-
const trimmed = line.trim();
|
|
90
|
-
if (!trimmed.startsWith("|") || !trimmed.endsWith("|"))
|
|
91
|
-
return null;
|
|
92
|
-
if (TableExtractor.isSeparatorRow(trimmed))
|
|
93
|
-
return null;
|
|
94
|
-
return trimmed
|
|
95
|
-
.split("|")
|
|
96
|
-
.slice(1, -1)
|
|
97
|
-
.map((cell) => cell.trim());
|
|
98
|
-
}
|
|
99
|
-
/** The non-separator `|…|` rows of a line run (the first row is the column
|
|
100
|
-
* header). The table-line / separator recognition is the TableExtractor's
|
|
101
|
-
* table-home rule; this method only splits the recognized rows into cells. */
|
|
102
|
-
tableRows(lines) {
|
|
103
|
-
const rows = [];
|
|
104
|
-
for (const line of tableExtractor.tableLinesOf(lines)) {
|
|
105
|
-
const cells = this.tableRowCells(line);
|
|
106
|
-
if (cells !== null)
|
|
107
|
-
rows.push([...cells]);
|
|
108
|
-
}
|
|
109
|
-
return rows;
|
|
110
|
-
}
|
|
111
82
|
}
|
|
112
83
|
// ---------------------------------------------------------------------------
|
|
113
84
|
// the DocType base — parse + projection consumption + chain root
|
|
@@ -140,149 +111,44 @@ export class DocType extends MarkdownPrimitives {
|
|
|
140
111
|
this.#slicesByAnchor = new Map(this.slices.slices.map((slice) => [slice.anchor, slice]));
|
|
141
112
|
}
|
|
142
113
|
// -------------------------------------------------------------------------
|
|
143
|
-
// shared extraction primitives (parse-only, never judgment)
|
|
114
|
+
// shared extraction primitives (parse-only, never judgment) — every one reads
|
|
115
|
+
// the ONE markdown tree, never a raw line scan
|
|
144
116
|
// -------------------------------------------------------------------------
|
|
145
|
-
/**
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
let openHeading = null;
|
|
149
|
-
let openRank = null;
|
|
150
|
-
let openBody = [];
|
|
151
|
-
const close = () => {
|
|
152
|
-
if (openHeading !== null && openRank !== null)
|
|
153
|
-
blocks.push({ heading: openHeading, rank: openRank, body: openBody });
|
|
154
|
-
openHeading = null;
|
|
155
|
-
openRank = null;
|
|
156
|
-
openBody = [];
|
|
157
|
-
};
|
|
158
|
-
for (const line of lines) {
|
|
159
|
-
const rank = this.headingRank(line);
|
|
160
|
-
if (rank !== null) {
|
|
161
|
-
close();
|
|
162
|
-
openHeading = line;
|
|
163
|
-
openRank = rank;
|
|
164
|
-
}
|
|
165
|
-
else if (openHeading !== null) {
|
|
166
|
-
openBody.push(line);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
close();
|
|
170
|
-
return blocks;
|
|
117
|
+
/** The document's tree — the caller's instance, or one built from the lines. */
|
|
118
|
+
treeOf(lines, tree) {
|
|
119
|
+
return tree ?? MarkdownTree.parse(lines.join("\n"));
|
|
171
120
|
}
|
|
172
|
-
/** The rank-2 section blocks in document order — the
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return headingScanner.sectionsOf(this.registry, lines);
|
|
121
|
+
/** The rank-2 section blocks in document order — the registry's declared section
|
|
122
|
+
* anchors decide WHICH `##` headings are sections (spec §3.2), read off the
|
|
123
|
+
* tree's section nodes. An undeclared prose rank-2 heading is not a section, and
|
|
124
|
+
* a declared conditional `##` heading is one. */
|
|
125
|
+
sectionsOf(tree) {
|
|
126
|
+
return [...headingScanner.sectionsOf(this.registry, tree)];
|
|
179
127
|
}
|
|
180
|
-
/** The `### Task N:` blocks in document order
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
taskBlocks(blocks) {
|
|
187
|
-
const out = [];
|
|
188
|
-
for (const block of blocks) {
|
|
189
|
-
const lines = [block.heading, ...block.body];
|
|
190
|
-
const extracted = taskExtractor.extract(this.registry, lines);
|
|
191
|
-
const headings = extracted["### Task N:"] ?? [];
|
|
192
|
-
if (headings.length === 0)
|
|
193
|
-
continue;
|
|
194
|
-
const ids = extracted["Task id token"] ?? [];
|
|
195
|
-
const id = Number(ids[0] ?? "");
|
|
196
|
-
if (Number.isNaN(id))
|
|
197
|
-
continue;
|
|
198
|
-
const fields = this.#taskFieldsOf(block.body, this.#taskFieldMarkers(extracted));
|
|
199
|
-
out.push({
|
|
200
|
-
id,
|
|
201
|
-
heading: block.heading,
|
|
202
|
-
fields,
|
|
203
|
-
steps: this.#taskStepsOf(extracted["Step action"] ?? [], new Set(extracted["Step checkable"] ?? [])),
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
return out;
|
|
128
|
+
/** The `### Task N:` blocks in document order — the ONE block-structure parse
|
|
129
|
+
* face (the tree's `tasks()`, P21 §7). The parse normalizes the heading shape and
|
|
130
|
+
* the legacy bullet shape into one `TaskBlock` record, so the graph, the brief
|
|
131
|
+
* and the judging plane all read the same structure. */
|
|
132
|
+
taskBlocksOf(tree) {
|
|
133
|
+
return [...tree.tasks()];
|
|
207
134
|
}
|
|
208
|
-
/** The
|
|
209
|
-
*
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
135
|
+
/** The parsed table of one declared table section (empty when the section or its
|
|
136
|
+
* table is absent) — the ONE table-section read all four doc types expose (the
|
|
137
|
+
* overall's three tables and the shared `## Change history` lineage face ride
|
|
138
|
+
* it). The column header is the tree's first table row; the cells come from the
|
|
139
|
+
* mdast cell nodes (never a `|` split), so an escaped pipe stays inside its cell. */
|
|
140
|
+
tableSection(tree, heading) {
|
|
141
|
+
for (const section of this.sectionsOf(tree)) {
|
|
142
|
+
if (!this.sectionConforms(section.heading, heading))
|
|
214
143
|
continue;
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
* from the extractor's field-anchor map; the remainder and continuation
|
|
222
|
-
* handling mirror the retired grammar's behavior exactly. */
|
|
223
|
-
#taskFieldsOf(body, markers) {
|
|
224
|
-
const fields = [];
|
|
225
|
-
let openKey = null;
|
|
226
|
-
let openLines = [];
|
|
227
|
-
const close = () => {
|
|
228
|
-
if (openKey !== null)
|
|
229
|
-
fields.push({ key: openKey, lines: openLines });
|
|
230
|
-
openKey = null;
|
|
231
|
-
openLines = [];
|
|
232
|
-
};
|
|
233
|
-
for (const line of body) {
|
|
234
|
-
const anchor = markers.get(line);
|
|
235
|
-
if (anchor !== undefined) {
|
|
236
|
-
close();
|
|
237
|
-
openKey = anchor.slice(2, -2);
|
|
238
|
-
openLines = [line.slice(`- ${anchor}:`.length).trim()];
|
|
239
|
-
}
|
|
240
|
-
else if (openKey !== null && line.trim().length > 0) {
|
|
241
|
-
openLines.push(line.trim());
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
close();
|
|
245
|
-
return fields;
|
|
246
|
-
}
|
|
247
|
-
/** Parse a block's recognized step lines into step records — the lines come
|
|
248
|
-
* from the extractor's `Step action` bucket (the registry's `^- ` shape, so
|
|
249
|
-
* no `- `-bullet re-recognition here); the action cell is a value read after
|
|
250
|
-
* the anchor's bullet prefix (mirroring the `#taskIdOf` slot read), and
|
|
251
|
-
* membership in the `Step checkable` bucket marks which lines carry a
|
|
252
|
-
* verbatim `— checkable:` clause that the split then reads off. */
|
|
253
|
-
#taskStepsOf(stepLines, checkableLines) {
|
|
254
|
-
const steps = [];
|
|
255
|
-
for (const line of stepLines) {
|
|
256
|
-
const text = line.trim().slice(2).trim();
|
|
257
|
-
const checkableMarker = checkableLines.has(line) ? text.indexOf("— checkable:") : -1;
|
|
258
|
-
if (checkableMarker === -1) {
|
|
259
|
-
steps.push({ action: text, checkable: null });
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
steps.push({
|
|
263
|
-
action: text.slice(0, checkableMarker).trim(),
|
|
264
|
-
checkable: text.slice(checkableMarker + "— checkable:".length).trim(),
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return steps;
|
|
269
|
-
}
|
|
270
|
-
/** Parse a section's table: the column-header row + the data rows. The header
|
|
271
|
-
* row is the one the registry's `… columns` anchors claim (the TableExtractor's
|
|
272
|
-
* declared-home set); a table with no registered column anchor falls back to
|
|
273
|
-
* the first row, the shape's positional default. The data rows are every
|
|
274
|
-
* remaining row plus any leading row ahead of the declared header — a
|
|
275
|
-
* mispositioned header never silently drops a data row. */
|
|
276
|
-
parseTable(lines) {
|
|
277
|
-
const rows = this.tableRows(lines);
|
|
278
|
-
const declaredHeader = tableExtractor.headerLineOf(this.registry, lines);
|
|
279
|
-
if (declaredHeader === null) {
|
|
280
|
-
const headerRow = rows.length > 0 ? rows[0] : null;
|
|
281
|
-
return { heading: "", headerRow, rows: rows.slice(1) };
|
|
144
|
+
const table = tree.tableUnder(section.heading);
|
|
145
|
+
return {
|
|
146
|
+
heading: section.heading,
|
|
147
|
+
headerRow: table?.header ?? null,
|
|
148
|
+
rows: table?.body.map((row) => [...row]) ?? [],
|
|
149
|
+
};
|
|
282
150
|
}
|
|
283
|
-
|
|
284
|
-
const dataRows = rows.filter((row) => row.join("|") !== (headerCells ?? []).join("|"));
|
|
285
|
-
return { heading: "", headerRow: headerCells, rows: dataRows };
|
|
151
|
+
return { heading: "", headerRow: null, rows: [] };
|
|
286
152
|
}
|
|
287
153
|
/** The slice of one registered anchor (undefined when the anchor is not registered here). */
|
|
288
154
|
sliceOf(anchor) {
|
|
@@ -295,13 +161,6 @@ export class DocType extends MarkdownPrimitives {
|
|
|
295
161
|
return slice.valuePattern.test(heading);
|
|
296
162
|
return heading.startsWith(anchor);
|
|
297
163
|
}
|
|
298
|
-
headingRank(line) {
|
|
299
|
-
const match = line.match(/^(#+)\s/);
|
|
300
|
-
if (match === null)
|
|
301
|
-
return null;
|
|
302
|
-
const rank = match[1].length;
|
|
303
|
-
return rank <= 4 ? rank : null;
|
|
304
|
-
}
|
|
305
164
|
}
|
|
306
165
|
// ---------------------------------------------------------------------------
|
|
307
166
|
// the four concrete doc types
|
|
@@ -312,16 +171,16 @@ export class DocType extends MarkdownPrimitives {
|
|
|
312
171
|
*/
|
|
313
172
|
export class OverallDocType extends DocType {
|
|
314
173
|
docTypeName = "overall";
|
|
315
|
-
parse(lines, head = null) {
|
|
174
|
+
parse(lines, head = null, tree) {
|
|
175
|
+
const document = this.treeOf(lines, tree);
|
|
316
176
|
const title = head?.title ?? "";
|
|
317
|
-
const sections = this.
|
|
177
|
+
const sections = this.sectionsOf(document);
|
|
318
178
|
const tables = {
|
|
319
|
-
"File paths": this
|
|
320
|
-
"Issue inventory": this
|
|
321
|
-
"Phase inventory": this
|
|
322
|
-
"Change history": this
|
|
179
|
+
"File paths": this.tableSection(document, "## File paths"),
|
|
180
|
+
"Issue inventory": this.tableSection(document, "## Issue inventory"),
|
|
181
|
+
"Phase inventory": this.tableSection(document, "## Phase inventory"),
|
|
182
|
+
"Change history": this.tableSection(document, "## Change history"),
|
|
323
183
|
};
|
|
324
|
-
const graphEdges = this.#graphEdges(sections);
|
|
325
184
|
const phases = this.#phaseRows(tables["Phase inventory"]);
|
|
326
185
|
return {
|
|
327
186
|
docType: "overall",
|
|
@@ -329,7 +188,6 @@ export class OverallDocType extends DocType {
|
|
|
329
188
|
title,
|
|
330
189
|
sections,
|
|
331
190
|
tables,
|
|
332
|
-
graphEdges,
|
|
333
191
|
chain: {
|
|
334
192
|
docType: "overall",
|
|
335
193
|
programLink: null,
|
|
@@ -338,32 +196,6 @@ export class OverallDocType extends DocType {
|
|
|
338
196
|
},
|
|
339
197
|
};
|
|
340
198
|
}
|
|
341
|
-
/** The `## Dependency graph` edge lines — the graph-home occurrence map (the
|
|
342
|
-
* declared Hard/Soft edge anchors) identified by the extractor; the from/to
|
|
343
|
-
* token grammar stays the preserved graph-edge primitive. */
|
|
344
|
-
#graphEdges(sections) {
|
|
345
|
-
for (const section of sections) {
|
|
346
|
-
if (!this.sectionConforms(section.heading, "## Dependency graph"))
|
|
347
|
-
continue;
|
|
348
|
-
const extracted = graphExtractor.extract(this.registry, section.lines);
|
|
349
|
-
const edgeLines = new Set([
|
|
350
|
-
...(extracted["Hard edge"] ?? []),
|
|
351
|
-
...(extracted["Soft edge"] ?? []),
|
|
352
|
-
]);
|
|
353
|
-
const edges = [];
|
|
354
|
-
const edgePattern = /^P(\d+(?:\.\d+)*)\s*->\s*P(\d+(?:\.\d+)*)$/;
|
|
355
|
-
for (const line of section.lines) {
|
|
356
|
-
const trimmed = line.trim();
|
|
357
|
-
if (!edgeLines.has(trimmed))
|
|
358
|
-
continue;
|
|
359
|
-
const match = trimmed.match(edgePattern);
|
|
360
|
-
if (match !== null)
|
|
361
|
-
edges.push({ text: trimmed, from: `P${match[1]}`, to: `P${match[2]}` });
|
|
362
|
-
}
|
|
363
|
-
return edges;
|
|
364
|
-
}
|
|
365
|
-
return [];
|
|
366
|
-
}
|
|
367
199
|
/** The Phase-inventory rows as chain phases — header-driven column mapping. */
|
|
368
200
|
#phaseRows(table) {
|
|
369
201
|
if (table.headerRow === null)
|
|
@@ -399,16 +231,6 @@ export class OverallDocType extends DocType {
|
|
|
399
231
|
const idCell = row.find((cell) => pattern?.test(cell.trim()) === true);
|
|
400
232
|
return idCell === undefined ? "" : idCell.trim();
|
|
401
233
|
}
|
|
402
|
-
/** The parsed table of one overall table section (empty when the section is absent). */
|
|
403
|
-
#tableSection(sections, heading) {
|
|
404
|
-
for (const section of sections) {
|
|
405
|
-
if (this.sectionConforms(section.heading, heading)) {
|
|
406
|
-
const table = this.parseTable(section.lines);
|
|
407
|
-
return { heading: section.heading, headerRow: table.headerRow, rows: table.rows };
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
return { heading: "", headerRow: null, rows: [] };
|
|
411
|
-
}
|
|
412
234
|
}
|
|
413
235
|
/**
|
|
414
236
|
* The plan doc type — parses the head and the `### Task N:` task blocks. A plan
|
|
@@ -417,15 +239,17 @@ export class OverallDocType extends DocType {
|
|
|
417
239
|
*/
|
|
418
240
|
export class PlanDocType extends DocType {
|
|
419
241
|
docTypeName = "plan";
|
|
420
|
-
parse(lines, head = null) {
|
|
242
|
+
parse(lines, head = null, tree) {
|
|
243
|
+
const document = this.treeOf(lines, tree);
|
|
421
244
|
const title = head?.title ?? "";
|
|
422
|
-
const
|
|
245
|
+
const sections = this.sectionsOf(document);
|
|
423
246
|
return {
|
|
424
247
|
docType: "plan",
|
|
425
248
|
head,
|
|
426
249
|
title,
|
|
427
|
-
sections
|
|
428
|
-
taskBlocks: this.
|
|
250
|
+
sections,
|
|
251
|
+
taskBlocks: this.taskBlocksOf(document),
|
|
252
|
+
tables: { "Change history": this.tableSection(document, "## Change history") },
|
|
429
253
|
chain: this.chainRoot(head),
|
|
430
254
|
};
|
|
431
255
|
}
|
|
@@ -447,67 +271,54 @@ export class PlanDocType extends DocType {
|
|
|
447
271
|
*/
|
|
448
272
|
export class PhaseSpecDocType extends DocType {
|
|
449
273
|
docTypeName = "phase-spec";
|
|
450
|
-
parse(lines, head = null) {
|
|
274
|
+
parse(lines, head = null, tree) {
|
|
275
|
+
const document = this.treeOf(lines, tree);
|
|
451
276
|
const title = head?.title ?? "";
|
|
452
|
-
const blocks = this.headingBlocks(lines);
|
|
453
277
|
return {
|
|
454
278
|
docType: "phase-spec",
|
|
455
279
|
head,
|
|
456
280
|
title,
|
|
457
|
-
sections: this.
|
|
458
|
-
design: this.
|
|
281
|
+
sections: this.sectionsOf(document),
|
|
282
|
+
design: this.designOf(document),
|
|
283
|
+
tables: { "Change history": this.tableSection(document, "## Change history") },
|
|
459
284
|
chain: this.chainRoot(head),
|
|
460
285
|
};
|
|
461
286
|
}
|
|
462
287
|
/** The design double-layer skeleton — the `### N.` groups + their `#### N.M`
|
|
463
|
-
* items
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
|
|
468
|
-
const
|
|
469
|
-
const
|
|
470
|
-
const
|
|
471
|
-
const
|
|
472
|
-
|
|
288
|
+
* items of the `## Design` section, read off the tree's heading nodes through the
|
|
289
|
+
* registry's declared design-body selectors (WHICH headings are groups/items is
|
|
290
|
+
* declared data, never a hand-written grammar). The number/text decomposition
|
|
291
|
+
* stays the DesignBodyExtractor's (one home). */
|
|
292
|
+
designOf(tree) {
|
|
293
|
+
const head = this.#selectorOf("## Design");
|
|
294
|
+
const groupSelector = this.#selectorOf("### N. group heading");
|
|
295
|
+
const itemSelector = this.#selectorOf("#### N.M item heading");
|
|
296
|
+
const design = head === undefined ? null : tree.resolve(head);
|
|
297
|
+
if (design === null || groupSelector === undefined || itemSelector === undefined)
|
|
298
|
+
return [];
|
|
473
299
|
const groups = [];
|
|
474
|
-
let
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
let inDesign = false;
|
|
478
|
-
const close = () => {
|
|
479
|
-
if (openNumber !== null) {
|
|
480
|
-
groups.push({ number: openNumber, heading: openHeading, items: openItems });
|
|
481
|
-
}
|
|
482
|
-
openNumber = null;
|
|
483
|
-
openHeading = "";
|
|
484
|
-
openItems = [];
|
|
485
|
-
};
|
|
486
|
-
for (const block of blocks) {
|
|
487
|
-
const rank = this.headingRank(block.heading);
|
|
488
|
-
if (rank === 2) {
|
|
489
|
-
if (inDesign)
|
|
490
|
-
break;
|
|
491
|
-
if (designHeadings.has(block.heading))
|
|
492
|
-
inDesign = true;
|
|
300
|
+
let open = null;
|
|
301
|
+
for (const heading of tree.headings()) {
|
|
302
|
+
if (heading.line <= design.line)
|
|
493
303
|
continue;
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
openNumber = group.number;
|
|
501
|
-
openHeading = group.heading;
|
|
304
|
+
if (heading.depth === 2)
|
|
305
|
+
break;
|
|
306
|
+
if (tree.matches(groupSelector, heading.text)) {
|
|
307
|
+
const group = designExtractor.groupOf(heading.text);
|
|
308
|
+
open = { number: group.number, heading: group.heading, items: [] };
|
|
309
|
+
groups.push(open);
|
|
502
310
|
continue;
|
|
503
311
|
}
|
|
504
|
-
if (
|
|
505
|
-
|
|
312
|
+
if (open !== null && tree.matches(itemSelector, heading.text)) {
|
|
313
|
+
open.items.push(designExtractor.itemOf(heading.text));
|
|
506
314
|
}
|
|
507
315
|
}
|
|
508
|
-
close();
|
|
509
316
|
return groups;
|
|
510
317
|
}
|
|
318
|
+
/** The declared selector of one registry anchor (undefined when unregistered). */
|
|
319
|
+
#selectorOf(anchor) {
|
|
320
|
+
return this.registry.elements.find((element) => element.anchor === anchor)?.selector;
|
|
321
|
+
}
|
|
511
322
|
/** The phase-spec's cross-doc chain root: the `program:` slug reference plus the
|
|
512
323
|
* `parent-version:` lineage tokens. The reference is a SLUG (the parent
|
|
513
324
|
* overall's `slug:`), so it never rides the file-path resolution faces. */
|
|
@@ -528,13 +339,15 @@ export class PhaseSpecDocType extends DocType {
|
|
|
528
339
|
*/
|
|
529
340
|
export class SingleSpecDocType extends DocType {
|
|
530
341
|
docTypeName = "single-spec";
|
|
531
|
-
parse(lines, head = null) {
|
|
342
|
+
parse(lines, head = null, tree) {
|
|
343
|
+
const document = this.treeOf(lines, tree);
|
|
532
344
|
const title = head?.title ?? "";
|
|
533
345
|
return {
|
|
534
346
|
docType: "single-spec",
|
|
535
347
|
head,
|
|
536
348
|
title,
|
|
537
|
-
sections: this.
|
|
349
|
+
sections: this.sectionsOf(document),
|
|
350
|
+
tables: { "Change history": this.tableSection(document, "## Change history") },
|
|
538
351
|
chain: this.chainRoot(head),
|
|
539
352
|
};
|
|
540
353
|
}
|
|
@@ -88,7 +88,8 @@ export class FrontMatterHead {
|
|
|
88
88
|
get date() {
|
|
89
89
|
return this.value("date");
|
|
90
90
|
}
|
|
91
|
-
/**
|
|
91
|
+
/** A residual head key — no registry declares `status` any more; read so an
|
|
92
|
+
* existing document degrades to a shorter head instead of erroring. */
|
|
92
93
|
get status() {
|
|
93
94
|
return this.value("status");
|
|
94
95
|
}
|