bokata 3.0.0-beta.5 → 3.0.0-beta.7
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/.agents/skills/bokata-acceptance-criteria/SKILL.md +6 -6
- package/.agents/skills/bokata-feature-map/SKILL.md +4 -4
- package/.agents/skills/bokata-feature-map/resources/features-template.md +5 -5
- package/.agents/skills/bokata-feature-mapper/SKILL.md +1 -1
- package/.agents/skills/bokata-feature-slicer/SKILL.md +19 -14
- package/.agents/skills/bokata-feature-slicer/resources/breakdown-strategies.md +15 -7
- package/.agents/skills/bokata-feature-slicer/resources/output-template-bites.md +3 -3
- package/.agents/skills/bokata-feature-slicer/resources/{phase-2-increments.md → phase-2-options.md} +1 -1
- package/.agents/skills/bokata-feature-slicer/resources/phase-3-skeleton.md +7 -6
- package/.agents/skills/bokata-feature-slicer/resources/phase-4-bites.md +7 -7
- package/.agents/skills/bokata-plan/SKILL.md +30 -28
- package/.agents/skills/bokata-plan/resources/plan-template.md +13 -13
- package/.agents/skills/bokata-render/SKILL.md +21 -21
- package/.agents/skills/bokata-render/assets/story-map.html +91 -91
- package/.agents/skills/bokata-render/scripts/render.mjs +219 -159
- package/.agents/skills/bokata-shape/SKILL.md +2 -2
- package/.agents/skills/bokata-slice/SKILL.md +230 -277
- package/.agents/skills/bokata-slice/resources/appetite-template.md +71 -0
- package/.agents/skills/bokata-slice/resources/proposed-slices.md +50 -0
- package/.agents/skills/bokata-spec/SKILL.md +256 -0
- package/.agents/skills/bokata-spec/resources/slice-template.md +49 -0
- package/.agents/skills/bokata-status/SKILL.md +30 -24
- package/.agents/skills/bokata-tdd/SKILL.md +12 -12
- package/README.md +496 -199
- package/agents/bokata-product-designer.md +11 -9
- package/agents/bokata-product-engineer.md +14 -12
- package/agents/bokata-product-manager.md +12 -10
- package/agents/code-executor.md +25 -21
- package/agents/feature-slicer.md +1 -1
- package/bin/bokata.js +1 -1
- package/package.json +1 -1
- package/src/config.js +1 -1
- package/src/install.js +4 -2
- package/.agents/skills/bokata-slice/resources/inc-template.md +0 -36
- package/.agents/skills/bokata-slice/resources/slice-template.md +0 -69
- /package/.agents/skills/bokata-feature-slicer/resources/{output-template-increments.md → output-template-options.md} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Renders <docs>/<initiative>/story-map.html from features.md,
|
|
2
|
+
// Renders <docs>/<initiative>/story-map.html from features.md, appetites/<nn>-<name>.md (+ its folder) and plan.md.
|
|
3
3
|
// Deterministic and stateless: the same markdown always gives the same HTML (apart from the date).
|
|
4
4
|
// No dependencies, Node >= 18. Usage:
|
|
5
5
|
// node render.mjs <initiative-dir> [--lang en|es] [--date YYYY-MM-DD] [--out file] [--check]
|
|
@@ -23,13 +23,20 @@ export class RenderError extends Error {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
//
|
|
26
|
+
// Appetites written by hand (or in Spanish) say the same things with other words.
|
|
27
27
|
const FIELD_ALIASES = { 'depende de': 'depends on', valor: 'value', comprobación: 'check' };
|
|
28
28
|
const OPTION_ID = /F\d+-\d+\.\d+/g;
|
|
29
|
-
// Bite IDs: letters per Feature (F1-a, F1-ab), d<n> for deferred, w<n> for the skeleton bites of
|
|
29
|
+
// Bite IDs: letters per Feature (F1-a, F1-ab), d<n> for deferred, w<n> for the skeleton bites of Slice 1.
|
|
30
30
|
const BITE_ID = /\bF\d+-(?:[a-z]+|[dw]\d+)\b/g;
|
|
31
31
|
const PRIORITIES = ['skeleton', 'must-have', 'nice-to-have', 'deferred'];
|
|
32
|
-
|
|
32
|
+
// What a slice's optional `## Learned` entries may be tagged with, and the IDs their `Affects:` line may name.
|
|
33
|
+
const LEARNED_KINDS = ['technical', 'user', 'business', 'uncertainty'];
|
|
34
|
+
const BITE_ID_OR_OPTION = /\bF\d+-(?:[a-z]+|[dw]\d+|\d+\.\d+)\b/g;
|
|
35
|
+
// An slice is proposed (a row of `### Proposed slices`, no file) until bokata-spec specifies it:
|
|
36
|
+
// then its slice-<n>.md says specified, bokata-plan sets planned, the executor sets done. (Older appetites say
|
|
37
|
+
// `sliced` for what is now `specified`.)
|
|
38
|
+
const SLICE_STATES = ['specified', 'planned', 'done'];
|
|
39
|
+
const LEGACY_STATES = { sliced: 'specified' };
|
|
33
40
|
|
|
34
41
|
const read = (file) => fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n');
|
|
35
42
|
const esc = (s) =>
|
|
@@ -37,7 +44,7 @@ const esc = (s) =>
|
|
|
37
44
|
const norm = (s) => s.toLowerCase().replace(/\s+/g, ' ').trim();
|
|
38
45
|
const plain = (s) => s.replace(/\*\*/g, '').replace(/`/g, '').trim();
|
|
39
46
|
|
|
40
|
-
// ——— a small markdown → HTML for the
|
|
47
|
+
// ——— a small markdown → HTML for the slice pages (the subset the appetites use) ———
|
|
41
48
|
|
|
42
49
|
const inline = (s) =>
|
|
43
50
|
esc(s)
|
|
@@ -186,17 +193,17 @@ export function parseFeatures(file) {
|
|
|
186
193
|
return { initiative, features };
|
|
187
194
|
}
|
|
188
195
|
|
|
189
|
-
// ———
|
|
196
|
+
// ——— appetites/<nn>-<name>.md ———
|
|
190
197
|
|
|
191
|
-
// ———
|
|
198
|
+
// ——— appetites/<nn>-<name>.md (the index) + appetites/<nn>-<name>/ (slices, slicing, notes) ———
|
|
192
199
|
|
|
193
200
|
const sectionName = (heading) => heading.split(/[\s—:]/)[0].toLowerCase();
|
|
194
201
|
|
|
195
202
|
// An option line of slicing/F<k>.md:
|
|
196
|
-
// - F1-1.2 <name> — <what changes> · <strategy> · [covers R1 …] · [skeleton | deferred (…) · F1-a] [→
|
|
203
|
+
// - F1-1.2 <name> — <what changes> · <strategy> · [covers R1 …] · [skeleton | deferred (…) · F1-a] [→ Slice n] [→ target]
|
|
197
204
|
// Read from the end: the trailing "meta" pieces first, then the strategy, and what is left is the description.
|
|
198
|
-
// (Older
|
|
199
|
-
const META = /^(?:covers\b.*|cubre\b.*|skeleton|esqueleto|deferred\b.*|(?:(?:paquete|package|bite)\s+)?(?:F\d+-(?:[a-z]+|[dw]\d+))?(?:\s*→\s*(?:
|
|
205
|
+
// (Older appetites wrote "paquete F6-e → objetivo" for "F6-e → target": both are accepted.)
|
|
206
|
+
const META = /^(?:covers\b.*|cubre\b.*|skeleton|esqueleto|deferred\b.*|(?:(?:paquete|package|bite)\s+)?(?:F\d+-(?:[a-z]+|[dw]\d+))?(?:\s*→\s*(?:Slice\s*\d+|target|objetivo))*)$/;
|
|
200
207
|
export function optionTail(raw, id) {
|
|
201
208
|
const text = raw.replace(/^\s*-\s+/, '').slice(id.length).trim();
|
|
202
209
|
const dash = text.indexOf(' — ');
|
|
@@ -205,8 +212,8 @@ export function optionTail(raw, id) {
|
|
|
205
212
|
const name = dash < 0 ? parts.shift() : text.slice(0, dash);
|
|
206
213
|
const keep = dash < 0 ? 0 : 1; // the description is never a strategy or a meta piece
|
|
207
214
|
let target = false;
|
|
208
|
-
// "<strategy> →
|
|
209
|
-
const glued = parts.length > keep && !META.test(parts[parts.length - 1]) && parts[parts.length - 1].match(/(?:\s*→\s*(?:
|
|
215
|
+
// "<strategy> → Slice 1": the arrows may be glued to the last piece with no " · " before them
|
|
216
|
+
const glued = parts.length > keep && !META.test(parts[parts.length - 1]) && parts[parts.length - 1].match(/(?:\s*→\s*(?:Slice\s*\d+|target|objetivo))+\s*$/);
|
|
210
217
|
if (glued) {
|
|
211
218
|
if (/target|objetivo/.test(glued[0])) target = true;
|
|
212
219
|
parts[parts.length - 1] = parts[parts.length - 1].slice(0, glued.index);
|
|
@@ -219,26 +226,26 @@ export function optionTail(raw, id) {
|
|
|
219
226
|
return { name: plain(name), desc: plain(parts.join(' · ')), strategy: plain(strategy), target };
|
|
220
227
|
}
|
|
221
228
|
|
|
222
|
-
export function
|
|
229
|
+
export function parseAppetite(file) {
|
|
223
230
|
const base = path.basename(file, '.md');
|
|
224
231
|
const fm = base.match(/^(\d+)-(.+)$/);
|
|
225
|
-
if (!fm) throw new RenderError(file, 0, '
|
|
232
|
+
if (!fm) throw new RenderError(file, 0, 'appetite files are named <nn>-<name>.md');
|
|
226
233
|
const dir = path.join(path.dirname(file), base);
|
|
227
|
-
const
|
|
234
|
+
const appetite = {
|
|
228
235
|
file,
|
|
229
236
|
base,
|
|
230
237
|
dir,
|
|
231
238
|
nn: parseInt(fm[1], 10),
|
|
232
239
|
status: 'open',
|
|
233
240
|
options: new Map(),
|
|
234
|
-
|
|
241
|
+
slices: [],
|
|
235
242
|
bites: [],
|
|
236
243
|
proposed: []
|
|
237
244
|
};
|
|
238
245
|
|
|
239
246
|
// ---- the index ----
|
|
240
247
|
let section = 'header';
|
|
241
|
-
let
|
|
248
|
+
let slice = null;
|
|
242
249
|
let fence = false;
|
|
243
250
|
read(file)
|
|
244
251
|
.split('\n')
|
|
@@ -248,36 +255,36 @@ export function parseSlice(file) {
|
|
|
248
255
|
if (/^```/.test(raw)) fence = !fence;
|
|
249
256
|
if (!fence && (m = raw.match(/^##\s+(.+?)\s*$/))) {
|
|
250
257
|
section = sectionName(m[1]);
|
|
251
|
-
|
|
258
|
+
slice = null;
|
|
252
259
|
return;
|
|
253
260
|
}
|
|
254
|
-
if (section === 'header' && (m = raw.match(/^-\s*Status:\s*(\w+)/)))
|
|
261
|
+
if (section === 'header' && (m = raw.match(/^-\s*Status:\s*(\w+)/))) appetite.status = m[1].toLowerCase() === 'closed' ? 'done' : m[1].toLowerCase();
|
|
255
262
|
|
|
256
|
-
if (section === '
|
|
257
|
-
if ((m = raw.match(/^###\s+
|
|
263
|
+
if (section === 'slices') {
|
|
264
|
+
if ((m = raw.match(/^###\s+Slice\s+(\d+)\s*(?:[—–:-]\s*)?(.*)$/))) {
|
|
258
265
|
const tags = [...m[2].matchAll(/\*\*\[([^\]]+)\]\*\*/g)].map((t) => t[1].trim());
|
|
259
266
|
const name = plain(m[2].replace(/\*\*\[[^\]]+\]\*\*/g, '')).replace(/\s+/g, ' ');
|
|
260
|
-
|
|
261
|
-
if (
|
|
262
|
-
|
|
267
|
+
slice = { n: parseInt(m[1], 10), name, tags, outcome: '', bites: [], options: [], line: n };
|
|
268
|
+
if (appetite.slices.some((x) => x.n === slice.n)) throw new RenderError(file, n, `Slice ${slice.n} appears twice`);
|
|
269
|
+
appetite.slices.push(slice);
|
|
263
270
|
return;
|
|
264
271
|
}
|
|
265
272
|
if (/^###\s/.test(raw)) {
|
|
266
|
-
|
|
273
|
+
slice = null;
|
|
267
274
|
return;
|
|
268
275
|
}
|
|
269
|
-
if (
|
|
276
|
+
if (slice && !fence) {
|
|
270
277
|
const clean = raw.replace(/<!--.*?-->/g, '');
|
|
271
|
-
if ((m = clean.match(/^-\s*Outcome:\s*(.*)$/)))
|
|
272
|
-
else if ((m = clean.match(/^-\s*Bites:\s*(.*)$/)))
|
|
273
|
-
else if ((m = clean.match(/^-\s*Options:\s*(.*)$/)))
|
|
278
|
+
if ((m = clean.match(/^-\s*Outcome:\s*(.*)$/))) slice.outcome = plain(m[1]);
|
|
279
|
+
else if ((m = clean.match(/^-\s*Bites:\s*(.*)$/))) slice.bites = m[1].match(BITE_ID) || [];
|
|
280
|
+
else if ((m = clean.match(/^-\s*Options:\s*(.*)$/))) slice.options = clean.match(OPTION_ID) || []; // an Slice with no bites: its options are drawn loose
|
|
274
281
|
}
|
|
275
282
|
}
|
|
276
283
|
|
|
277
284
|
if (section === 'backlog') {
|
|
278
|
-
// the proposed
|
|
279
|
-
if ((m = raw.match(/^\|\s*
|
|
280
|
-
|
|
285
|
+
// the proposed slices of `### Proposed slices`
|
|
286
|
+
if ((m = raw.match(/^\|\s*Slice\s+(\d+)\s*[—–:-]\s*(.+?)\s*\|\s*(.*?)\s*\|\s*(.*?)\s*\|\s*(.*?)\s*\|\s*$/))) {
|
|
287
|
+
appetite.proposed.push({ n: parseInt(m[1], 10), name: plain(m[2]), bites: m[3].match(BITE_ID) || [], gains: plain(m[4]), why: m[5], line: n });
|
|
281
288
|
}
|
|
282
289
|
// A bite line starts with its ID and a dot; older backlogs (flat option lists) have none and draw nothing.
|
|
283
290
|
if (/^\s*-\s+~?(?:\*\*)?F\d+-(?:[a-z]+|[dw]\d+)\s+·/.test(raw)) {
|
|
@@ -286,15 +293,15 @@ export function parseSlice(file) {
|
|
|
286
293
|
);
|
|
287
294
|
if (!b) throw new RenderError(file, n, `not a bite line (expected "- **F1-a · <title>** (must-have) — F1-1.2 · depends on: … · value: … · check: …"): ${raw.trim().slice(0, 70)}`);
|
|
288
295
|
const [, , id, title, priority, reason, tail, rest] = b;
|
|
289
|
-
const taken = tail.match(/
|
|
296
|
+
const taken = tail.match(/Slice\s*(\d+)/)?.[1]; // canonical "→ Slice n"; hand-edited appetites vary
|
|
290
297
|
const parts = rest.split(' · ');
|
|
291
298
|
const fields = {};
|
|
292
299
|
for (const part of parts.slice(1)) {
|
|
293
300
|
const kv = part.match(/^(depends on|depende de|value|valor|check|comprobación):\s*(.*)$/);
|
|
294
301
|
if (kv) fields[FIELD_ALIASES[kv[1]] || kv[1]] = kv[2].trim();
|
|
295
302
|
}
|
|
296
|
-
if (
|
|
297
|
-
|
|
303
|
+
if (appetite.bites.some((x) => x.id === id)) throw new RenderError(file, n, `bite ${id} appears twice`);
|
|
304
|
+
appetite.bites.push({
|
|
298
305
|
id,
|
|
299
306
|
title: plain(title),
|
|
300
307
|
priority,
|
|
@@ -311,7 +318,7 @@ export function parseSlice(file) {
|
|
|
311
318
|
});
|
|
312
319
|
|
|
313
320
|
// ---- slicing/F<k>.md: the Steps, the options (with what they say) and the User Task each belongs to ----
|
|
314
|
-
|
|
321
|
+
appetite.steps = new Map(); // "F1-3" -> { f, n, name, kind, desc, note, ut }
|
|
315
322
|
const sdir = path.join(dir, 'slicing');
|
|
316
323
|
if (fs.existsSync(sdir)) {
|
|
317
324
|
for (const f of fs.readdirSync(sdir).filter((x) => x.endsWith('.md')).sort()) {
|
|
@@ -325,40 +332,41 @@ export function parseSlice(file) {
|
|
|
325
332
|
if ((m = raw.match(/^#{2,5}\s+User Task(?:\s+[\d.]+)?:\s*(.+?)\s*$/))) currentUT = plain(m[1]);
|
|
326
333
|
else if (code && (m = raw.match(/^\s*-\s+\*\*S(\d+)\s+(.+?)\*\*(?:\s+·\s+([A-Za-z]+))?(?:\s+—\s+(.*))?$/))) {
|
|
327
334
|
const [desc, note] = (m[4] || '').split(' · note: ');
|
|
328
|
-
|
|
335
|
+
appetite.steps.set(`${code}-${m[1]}`, { f: code, n: parseInt(m[1], 10), name: plain(m[2]), kind: m[3] || '', desc: plain(desc), note: plain(note || ''), ut: currentUT });
|
|
329
336
|
} else if ((m = raw.match(/^\s*-\s+(F\d+-\d+\.\d+)\s+(.+?)(?:\s+—\s|$)/))) {
|
|
330
337
|
if (!currentUT) throw new RenderError(sfile, i + 1, `option ${m[1]} is not under a "### User Task:" heading`);
|
|
331
|
-
|
|
338
|
+
appetite.options.set(m[1], { id: m[1], ut: currentUT, file: sfile, line: i + 1, ...optionTail(raw, m[1]) });
|
|
332
339
|
}
|
|
333
340
|
});
|
|
334
341
|
}
|
|
335
342
|
}
|
|
336
343
|
|
|
337
344
|
// ---- pruned.md: the options cut with a reason (they are gone from slicing/) ----
|
|
338
|
-
|
|
345
|
+
appetite.pruned = [];
|
|
339
346
|
const pfile = path.join(dir, 'pruned.md');
|
|
340
347
|
if (fs.existsSync(pfile)) {
|
|
341
348
|
read(pfile)
|
|
342
349
|
.split('\n')
|
|
343
350
|
.forEach((raw, i) => {
|
|
344
351
|
const m = raw.match(/^\s*-\s+(F\d+-\d+\.\d+)\s+(.+?)\s+—\s+`(\w+)`:\s*(.*)$/);
|
|
345
|
-
if (m)
|
|
352
|
+
if (m) appetite.pruned.push({ id: m[1], name: plain(m[2]), cat: m[3], reason: m[4].trim(), file: pfile, line: i + 1 });
|
|
346
353
|
});
|
|
347
354
|
}
|
|
348
355
|
|
|
349
|
-
// ----
|
|
350
|
-
for (const
|
|
351
|
-
const ifile = path.join(dir, `
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
356
|
+
// ---- slice-<n>.md: State, Unknowns, scenarios, Pending and the body of each slice ----
|
|
357
|
+
for (const sliceRec of appetite.slices) {
|
|
358
|
+
const ifile = path.join(dir, `slice-${sliceRec.n}.md`);
|
|
359
|
+
sliceRec.detailFile = fs.existsSync(ifile) ? ifile : null;
|
|
360
|
+
sliceRec.stateRaw = null;
|
|
361
|
+
sliceRec.stateLine = 0;
|
|
362
|
+
sliceRec.scenarios = [];
|
|
363
|
+
sliceRec.pending = [];
|
|
364
|
+
sliceRec.learned = []; // { kind, text, affects: [ids] | null, line, file }
|
|
365
|
+
sliceRec.unknowns = '';
|
|
366
|
+
sliceRec.body = [];
|
|
367
|
+
if (!sliceRec.detailFile) continue;
|
|
360
368
|
const lines = read(ifile).split('\n');
|
|
361
|
-
|
|
369
|
+
sliceRec.body = lines.slice(1);
|
|
362
370
|
let sec = '';
|
|
363
371
|
let fenced = false;
|
|
364
372
|
lines.forEach((raw, i) => {
|
|
@@ -366,39 +374,48 @@ export function parseSlice(file) {
|
|
|
366
374
|
if (/^```/.test(raw)) fenced = !fenced;
|
|
367
375
|
if (!fenced && (m = raw.match(/^##\s+(.+?)\s*$/))) sec = sectionName(m[1]);
|
|
368
376
|
if (i < 12 && (m = raw.match(/^-\s*State:\s*(\S+)/))) {
|
|
369
|
-
|
|
370
|
-
|
|
377
|
+
sliceRec.stateRaw = LEGACY_STATES[m[1].toLowerCase()] || m[1].toLowerCase();
|
|
378
|
+
sliceRec.stateLine = i + 1;
|
|
379
|
+
}
|
|
380
|
+
if (i < 12 && (m = raw.match(/^-\s*Unknowns:\s*(.*)$/))) sliceRec.unknowns = m[1].trim();
|
|
381
|
+
if ((m = raw.match(/^\s*Scenario(?: Outline)?:\s*(.+?)\s*$/))) sliceRec.scenarios.push(m[1]);
|
|
382
|
+
if (sec === 'pending' && !fenced && (m = raw.match(/^\s*-\s+(.*)$/))) sliceRec.pending.push(plain(m[1]));
|
|
383
|
+
// ## Learned: "- <technical|user|business|uncertainty>: <what>" then "Affects: <bite or option IDs | none>"
|
|
384
|
+
if (sec === 'learned' && !fenced) {
|
|
385
|
+
if ((m = raw.match(/^-\s+([A-Za-z]+)\s*:\s*(.*)$/))) sliceRec.learned.push({ kind: m[1].toLowerCase(), text: plain(m[2]), affects: null, line: i + 1, file: ifile });
|
|
386
|
+
else if ((m = raw.match(/^\s*(?:-\s+)?Affects:\s*(.*)$/i)) && sliceRec.learned.length) {
|
|
387
|
+
const last = sliceRec.learned[sliceRec.learned.length - 1];
|
|
388
|
+
last.affects = /^none\b/i.test(m[1].trim()) ? [] : m[1].match(BITE_ID_OR_OPTION) || [];
|
|
389
|
+
last.affectsLine = i + 1;
|
|
390
|
+
}
|
|
371
391
|
}
|
|
372
|
-
if (i < 12 && (m = raw.match(/^-\s*Unknowns:\s*(.*)$/))) incRec.unknowns = m[1].trim();
|
|
373
|
-
if ((m = raw.match(/^\s*Scenario(?: Outline)?:\s*(.+?)\s*$/))) incRec.scenarios.push(m[1]);
|
|
374
|
-
if (sec === 'pending' && !fenced && (m = raw.match(/^\s*-\s+(.*)$/))) incRec.pending.push(plain(m[1]));
|
|
375
392
|
});
|
|
376
393
|
}
|
|
377
|
-
return
|
|
394
|
+
return appetite;
|
|
378
395
|
}
|
|
379
396
|
|
|
380
397
|
|
|
381
398
|
// ——— plan.md ———
|
|
382
399
|
|
|
383
400
|
export function parsePlan(file) {
|
|
384
|
-
const plan = {
|
|
401
|
+
const plan = { appetites: new Map() };
|
|
385
402
|
if (!fs.existsSync(file)) return plan;
|
|
403
|
+
let appetite = null;
|
|
386
404
|
let slice = null;
|
|
387
|
-
let inc = null;
|
|
388
405
|
read(file).split('\n').forEach((raw) => {
|
|
389
406
|
let m;
|
|
390
|
-
if ((m = raw.match(/^##\s+
|
|
407
|
+
if ((m = raw.match(/^##\s+Appetite\s+(\d+)/))) {
|
|
408
|
+
appetite = parseInt(m[1], 10);
|
|
409
|
+
if (!plan.appetites.has(appetite)) plan.appetites.set(appetite, new Map());
|
|
410
|
+
slice = null;
|
|
411
|
+
} else if ((m = raw.match(/^###\s+Slice\s+(\d+)/))) {
|
|
391
412
|
slice = parseInt(m[1], 10);
|
|
392
|
-
if (
|
|
393
|
-
inc = null;
|
|
394
|
-
} else if ((m = raw.match(/^###\s+Inc\s+(\d+)/))) {
|
|
395
|
-
inc = parseInt(m[1], 10);
|
|
396
|
-
if (slice !== null) plan.slices.get(slice).set(inc, plan.slices.get(slice).get(inc) || []);
|
|
413
|
+
if (appetite !== null) plan.appetites.get(appetite).set(slice, plan.appetites.get(appetite).get(slice) || []);
|
|
397
414
|
} else if (/^##\s/.test(raw)) {
|
|
415
|
+
appetite = null;
|
|
398
416
|
slice = null;
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
plan.slices.get(slice).get(inc).push({ done: m[1] !== ' ', text: m[2].trim() });
|
|
417
|
+
} else if (appetite !== null && slice !== null && (m = raw.match(/^\s*-\s+\[( |x|X)\]\s+(.*)$/))) {
|
|
418
|
+
plan.appetites.get(appetite).get(slice).push({ done: m[1] !== ' ', text: m[2].trim() });
|
|
402
419
|
}
|
|
403
420
|
});
|
|
404
421
|
return plan;
|
|
@@ -412,13 +429,13 @@ function stateOf(steps) {
|
|
|
412
429
|
return { state: done === steps.length ? 'done' : done > 0 ? 'building' : 'planned', done, total: steps.length };
|
|
413
430
|
}
|
|
414
431
|
|
|
415
|
-
// The state of an
|
|
416
|
-
// steps of its section in plan.md say planned / building / done; with no steps, its own State (default
|
|
417
|
-
function
|
|
418
|
-
if (
|
|
432
|
+
// The state of an slice: `State: done` in its slice-<n>.md (or a done appetite) wins; otherwise the checked
|
|
433
|
+
// steps of its section in plan.md say planned / building / done; with no steps, its own State (default specified).
|
|
434
|
+
function sliceState(appetite, slice, steps) {
|
|
435
|
+
if (appetite.status === 'done' || slice.stateRaw === 'done') return { state: 'done', done: 0, total: 0 };
|
|
419
436
|
const fromPlan = stateOf(steps);
|
|
420
437
|
if (fromPlan) return fromPlan;
|
|
421
|
-
return { state:
|
|
438
|
+
return { state: slice.stateRaw === 'planned' ? 'planned' : 'specified', done: 0, total: 0 };
|
|
422
439
|
}
|
|
423
440
|
|
|
424
441
|
export function buildModel(dir) {
|
|
@@ -432,63 +449,63 @@ export function buildModel(dir) {
|
|
|
432
449
|
t.col = i + 1;
|
|
433
450
|
});
|
|
434
451
|
|
|
435
|
-
const
|
|
436
|
-
const
|
|
437
|
-
const
|
|
452
|
+
const appetitesDir = path.join(dir, 'appetites');
|
|
453
|
+
const appetiteFiles = fs.existsSync(appetitesDir) ? fs.readdirSync(appetitesDir).filter((f) => /^\d+-.+\.md$/.test(f)).sort() : [];
|
|
454
|
+
const appetites = appetiteFiles.map((f) => parseAppetite(path.join(appetitesDir, f))).sort((a, b) => a.nn - b.nn);
|
|
438
455
|
const planFile = path.join(dir, 'plan.md');
|
|
439
456
|
const plan = parsePlan(planFile);
|
|
440
457
|
|
|
441
458
|
const taskOf = (featureCode, ut) => (features.find((f) => f.code === featureCode)?.tasks || []).find((t) => norm(t.name) === norm(ut)) || null;
|
|
442
459
|
const issues = [];
|
|
443
460
|
|
|
444
|
-
for (const
|
|
445
|
-
for (const opt of
|
|
461
|
+
for (const appetite of appetites) {
|
|
462
|
+
for (const opt of appetite.options.values()) {
|
|
446
463
|
opt.feature = opt.id.match(/^(F\d+)-/)[1];
|
|
447
464
|
opt.task = taskOf(opt.feature, opt.ut);
|
|
448
465
|
if (!opt.task) throw new RenderError(opt.file, opt.line, `User Task "${opt.ut}" is not a User Task of ${opt.feature} in features.md`);
|
|
449
466
|
}
|
|
450
|
-
// the trace of the
|
|
467
|
+
// the trace of the appetite: its Steps in order, each with its live options and the ones pruned from it
|
|
451
468
|
const stepOf = (id) => id.replace(/\.\d+$/, '');
|
|
452
469
|
const trace = new Map();
|
|
453
470
|
const stepRec = (key, ut) => {
|
|
454
471
|
if (!trace.has(key)) {
|
|
455
472
|
const [f, n] = key.split('-');
|
|
456
|
-
const base =
|
|
473
|
+
const base = appetite.steps.get(key) || { f, n: parseInt(n, 10), name: `Step ${n}`, kind: '', desc: '', note: '', ut };
|
|
457
474
|
const task = taskOf(f, base.ut);
|
|
458
|
-
if (!task &&
|
|
475
|
+
if (!task && appetite.steps.has(key)) issues.push({ file: appetite.file, line: 0, text: `${appetite.base}/slicing/${f}.md: Step S${n} is under User Task "${base.ut}", which is not a User Task of ${f} in features.md` });
|
|
459
476
|
trace.set(key, { ...base, task, options: [] });
|
|
460
477
|
}
|
|
461
478
|
return trace.get(key);
|
|
462
479
|
};
|
|
463
|
-
for (const key of
|
|
464
|
-
for (const o of
|
|
480
|
+
for (const key of appetite.steps.keys()) stepRec(key);
|
|
481
|
+
for (const o of appetite.options.values()) {
|
|
465
482
|
stepRec(stepOf(o.id), o.ut).options.push({ id: o.id, name: o.name, desc: o.desc, strategy: o.strategy, target: o.target, state: 'live' });
|
|
466
483
|
}
|
|
467
|
-
for (const p of
|
|
484
|
+
for (const p of appetite.pruned) {
|
|
468
485
|
const st = trace.get(stepOf(p.id));
|
|
469
486
|
if (!st) {
|
|
470
|
-
if (
|
|
487
|
+
if (appetite.steps.size) issues.push({ file: p.file, line: p.line, text: `pruned option ${p.id} has no Step in ${appetite.base}/slicing/` });
|
|
471
488
|
continue;
|
|
472
489
|
}
|
|
473
490
|
st.options.push({ id: p.id, name: p.name, cat: p.cat, reason: p.reason, state: 'pruned' });
|
|
474
491
|
}
|
|
475
492
|
const num = (id) => parseInt(id.match(/\.(\d+)$/)[1], 10);
|
|
476
493
|
for (const st of trace.values()) st.options.sort((a, b) => num(a.id) - num(b.id));
|
|
477
|
-
|
|
494
|
+
appetite.trace = [...trace.values()].sort((a, b) => a.f.localeCompare(b.f, undefined, { numeric: true }) || a.n - b.n);
|
|
478
495
|
|
|
479
|
-
const byId = new Map(
|
|
496
|
+
const byId = new Map(appetite.bites.map((b) => [b.id, b]));
|
|
480
497
|
const optionOwner = new Map();
|
|
481
|
-
for (const bite of
|
|
482
|
-
const first =
|
|
498
|
+
for (const bite of appetite.bites) {
|
|
499
|
+
const first = appetite.options.get(bite.options[0]);
|
|
483
500
|
if (!first) {
|
|
484
|
-
throw new RenderError(
|
|
501
|
+
throw new RenderError(appetite.file, bite.line, `bite ${bite.id}: its first option ${bite.options[0] || '(none)'} is not in ${appetite.base}/slicing/`);
|
|
485
502
|
}
|
|
486
503
|
bite.feature = bite.id.match(/^(F\d+)-/)[1];
|
|
487
504
|
bite.task = first.task;
|
|
488
505
|
bite.resolved = bite.options.map((id) => {
|
|
489
|
-
const o =
|
|
490
|
-
if (!o) issues.push({ file:
|
|
491
|
-
if (optionOwner.has(id)) issues.push({ file:
|
|
506
|
+
const o = appetite.options.get(id);
|
|
507
|
+
if (!o) issues.push({ file: appetite.file, line: bite.line, text: `bite ${bite.id}: option ${id} is not in ${appetite.base}/slicing/` });
|
|
508
|
+
if (optionOwner.has(id)) issues.push({ file: appetite.file, line: bite.line, text: `option ${id} is in two bites (${optionOwner.get(id)} and ${bite.id})` });
|
|
492
509
|
optionOwner.set(id, bite.id);
|
|
493
510
|
return { id, name: o ? o.name : '(not in the slicing)', task: o ? o.task : null };
|
|
494
511
|
});
|
|
@@ -496,79 +513,109 @@ export function buildModel(dir) {
|
|
|
496
513
|
bite.others = others;
|
|
497
514
|
}
|
|
498
515
|
const taker = new Map();
|
|
499
|
-
for (const
|
|
500
|
-
for (const id of
|
|
501
|
-
if (!byId.has(id)) throw new RenderError(
|
|
502
|
-
if (taker.has(id)) issues.push({ file:
|
|
503
|
-
taker.set(id,
|
|
516
|
+
for (const slice of appetite.slices) {
|
|
517
|
+
for (const id of slice.bites) {
|
|
518
|
+
if (!byId.has(id)) throw new RenderError(appetite.file, slice.line, `Slice ${slice.n}: bite ${id} has no line in ## Backlog`);
|
|
519
|
+
if (taker.has(id)) issues.push({ file: appetite.file, line: slice.line, text: `bite ${id} is taken by Slice ${taker.get(id)} and Slice ${slice.n}` });
|
|
520
|
+
taker.set(id, slice.n);
|
|
504
521
|
}
|
|
505
|
-
if (
|
|
506
|
-
throw new RenderError(
|
|
522
|
+
if (slice.bites.length === 0 && slice.options.length === 0 && slice.tags.length === 0) {
|
|
523
|
+
throw new RenderError(appetite.file, slice.line, `Slice ${slice.n} has no Bites: line (every Slice is made of bites; the skeleton ones are F<n>-w<k>)`);
|
|
507
524
|
}
|
|
508
|
-
for (const id of
|
|
509
|
-
if (!
|
|
525
|
+
for (const id of slice.options) {
|
|
526
|
+
if (!appetite.options.has(id)) issues.push({ file: appetite.file, line: slice.line, text: `Slice ${slice.n}: option ${id} is not in ${appetite.base}/slicing/` });
|
|
510
527
|
}
|
|
511
|
-
const steps = plan.
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
if (!
|
|
515
|
-
else if (
|
|
516
|
-
else if (
|
|
517
|
-
if (
|
|
518
|
-
if (steps && steps.length &&
|
|
528
|
+
const steps = plan.appetites.get(appetite.nn)?.get(slice.n) || null;
|
|
529
|
+
slice.steps = steps;
|
|
530
|
+
slice.st = sliceState(appetite, slice, steps);
|
|
531
|
+
if (!slice.detailFile) issues.push({ file: appetite.file, line: slice.line, text: `Slice ${slice.n} has no ${appetite.base}/slice-${slice.n}.md` });
|
|
532
|
+
else if (slice.stateRaw === null) issues.push({ file: slice.detailFile, line: 1, text: 'no "- State:" line in the first lines' });
|
|
533
|
+
else if (slice.stateRaw === 'draft') issues.push({ file: slice.detailFile, line: slice.stateLine, text: `Slice ${slice.n} is listed in the index but its file is still a draft (the ACs were never approved): finish \`bokata-spec\` or take the Slice out of ## Slices` });
|
|
534
|
+
else if (!SLICE_STATES.includes(slice.stateRaw)) issues.push({ file: slice.detailFile, line: slice.stateLine, text: `unknown State "${slice.stateRaw}" (specified | planned | done)` });
|
|
535
|
+
if (steps && steps.length && slice.stateRaw === 'done') issues.push({ file: planFile, line: 0, text: `Appetite ${appetite.nn} · Slice ${slice.n} is done but still has a section in plan.md — delete it` });
|
|
536
|
+
if (steps && steps.length && steps.every((s) => s.done) && slice.stateRaw !== 'done') issues.push({ file: slice.detailFile || appetite.file, line: slice.stateLine || slice.line, text: `every step of Slice ${slice.n} is checked: set "- State: done" and clean its section of plan.md` });
|
|
519
537
|
}
|
|
520
|
-
for (const bite of
|
|
538
|
+
for (const bite of appetite.bites) {
|
|
521
539
|
bite.takenBy = taker.get(bite.id) ?? bite.takenLine ?? null;
|
|
522
540
|
if (bite.takenLine !== null && taker.has(bite.id) && taker.get(bite.id) !== bite.takenLine) {
|
|
523
|
-
issues.push({ file:
|
|
541
|
+
issues.push({ file: appetite.file, line: bite.line, text: `bite ${bite.id} says → Slice ${bite.takenLine} but Slice ${taker.get(bite.id)} lists it` });
|
|
524
542
|
}
|
|
525
|
-
if (bite.takenLine !== null && !
|
|
526
|
-
issues.push({ file:
|
|
543
|
+
if (bite.takenLine !== null && !appetite.slices.some((i) => i.n === bite.takenLine)) {
|
|
544
|
+
issues.push({ file: appetite.file, line: bite.line, text: `bite ${bite.id} says → Slice ${bite.takenLine}, which is not in ## Slices` });
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
// The proposed slices are edited by hand: say what a hand edit may have broken.
|
|
548
|
+
const rowOf = new Map();
|
|
549
|
+
for (const p of appetite.proposed) {
|
|
550
|
+
if (appetite.slices.some((i) => i.n === p.n)) issues.push({ file: appetite.file, line: p.line, text: `proposed Slice ${p.n} is already in ## Slices — drop its row (or renumber it)` });
|
|
551
|
+
if (appetite.proposed.some((q) => q !== p && q.n === p.n && q.line < p.line)) issues.push({ file: appetite.file, line: p.line, text: `Slice ${p.n} appears twice in ### Proposed slices` });
|
|
552
|
+
for (const id of p.bites) {
|
|
553
|
+
const b = byId.get(id);
|
|
554
|
+
if (!b) issues.push({ file: appetite.file, line: p.line, text: `proposed Slice ${p.n}: bite ${id} has no line in ## Backlog` });
|
|
555
|
+
else if (taker.has(id)) issues.push({ file: appetite.file, line: p.line, text: `proposed Slice ${p.n}: bite ${id} is already taken by Slice ${taker.get(id)}` });
|
|
556
|
+
if (rowOf.has(id) && rowOf.get(id) !== p.n) issues.push({ file: appetite.file, line: p.line, text: `bite ${id} is in two proposed slices (Slice ${rowOf.get(id)} and Slice ${p.n})` });
|
|
557
|
+
rowOf.set(id, p.n);
|
|
527
558
|
}
|
|
528
559
|
}
|
|
529
|
-
|
|
530
|
-
for (const p of
|
|
560
|
+
appetite.proposed = appetite.proposed.filter((p) => !appetite.slices.some((i) => i.n === p.n));
|
|
561
|
+
for (const p of appetite.proposed) {
|
|
531
562
|
for (const id of p.bites) {
|
|
532
563
|
const b = byId.get(id);
|
|
533
|
-
if (b && b.takenBy === null) b.
|
|
564
|
+
if (b && b.takenBy === null) b.proposedSlice = p.n;
|
|
534
565
|
}
|
|
535
566
|
}
|
|
536
|
-
// the tasks each
|
|
537
|
-
for (const
|
|
538
|
-
const ofBites =
|
|
539
|
-
|
|
567
|
+
// the tasks each Slice touches
|
|
568
|
+
for (const slice of appetite.slices) {
|
|
569
|
+
const ofBites = slice.bites.map((id) => byId.get(id));
|
|
570
|
+
slice.biteRecs = ofBites;
|
|
540
571
|
const opts = [];
|
|
541
572
|
const seen = new Set();
|
|
542
573
|
for (const b of ofBites) for (const o of b.resolved) if (!seen.has(o.id)) (seen.add(o.id), opts.push(o));
|
|
543
|
-
for (const id of
|
|
574
|
+
for (const id of slice.options) {
|
|
544
575
|
if (seen.has(id)) continue;
|
|
545
|
-
const o =
|
|
576
|
+
const o = appetite.options.get(id);
|
|
546
577
|
seen.add(id);
|
|
547
578
|
opts.push({ id, name: o ? o.name : '(not in the slicing)', task: o ? o.task : null });
|
|
548
579
|
}
|
|
549
|
-
|
|
580
|
+
slice.resolvedOptions = opts;
|
|
550
581
|
const fromTags = [];
|
|
551
582
|
if (ofBites.length === 0 && opts.length === 0) {
|
|
552
|
-
// the oldest
|
|
553
|
-
for (const tag of
|
|
583
|
+
// the oldest appetites only name the User Tasks, as **[User Task]** tags of the Slice heading
|
|
584
|
+
for (const tag of slice.tags) {
|
|
554
585
|
const task = tasks.find((x) => norm(x.name) === norm(tag));
|
|
555
|
-
if (!task) throw new RenderError(
|
|
586
|
+
if (!task) throw new RenderError(appetite.file, slice.line, `Slice ${slice.n}: User Task "${tag}" is not in features.md`);
|
|
556
587
|
fromTags.push(task);
|
|
557
588
|
}
|
|
558
589
|
}
|
|
559
590
|
const ids = new Set([...ofBites.flatMap((b) => [b.task, ...b.others]), ...opts.map((o) => o.task), ...fromTags].filter(Boolean).map((t) => t.id));
|
|
560
|
-
|
|
591
|
+
slice.taskIds = [...ids];
|
|
561
592
|
}
|
|
562
593
|
}
|
|
563
|
-
|
|
594
|
+
// ---- ## Learned: a known kind, an Affects: line, and Affects IDs that name something of the initiative ----
|
|
595
|
+
const known = new Set();
|
|
596
|
+
for (const a of appetites) {
|
|
597
|
+
for (const b of a.bites) known.add(b.id);
|
|
598
|
+
for (const id of a.options.keys()) known.add(id);
|
|
599
|
+
for (const p of a.pruned) known.add(p.id);
|
|
600
|
+
}
|
|
601
|
+
for (const a of appetites) {
|
|
602
|
+
for (const slice of a.slices) {
|
|
603
|
+
for (const l of slice.learned || []) {
|
|
604
|
+
if (!LEARNED_KINDS.includes(l.kind)) issues.push({ file: l.file, line: l.line, text: `Learned: "${l.kind}" is not one of ${LEARNED_KINDS.join(' | ')}` });
|
|
605
|
+
else if (!l.affects) issues.push({ file: l.file, line: l.line, text: 'Learned: this entry has no "Affects:" line (bite or option IDs, or none)' });
|
|
606
|
+
else for (const id of l.affects) if (!known.has(id)) issues.push({ file: l.file, line: l.affectsLine, text: `Learned: Affects names ${id}, which is no bite or option of this initiative` });
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
return { initiative, features, tasks, appetites, plan, issues, planFile };
|
|
564
611
|
}
|
|
565
612
|
|
|
566
613
|
// ——— data for the page ———
|
|
567
614
|
|
|
568
|
-
const
|
|
615
|
+
const appetiteName = (base) => base.replace(/^\d+-/, '');
|
|
569
616
|
|
|
570
617
|
function dataOf(model, lang, date) {
|
|
571
|
-
const { features,
|
|
618
|
+
const { features, appetites, plan } = model;
|
|
572
619
|
const out = {
|
|
573
620
|
lang,
|
|
574
621
|
date,
|
|
@@ -581,16 +628,16 @@ function dataOf(model, lang, date) {
|
|
|
581
628
|
systemTasks: f.systemTasks,
|
|
582
629
|
tasks: f.tasks.map((t) => ({ id: t.id, name: t.name, desc: t.description }))
|
|
583
630
|
})),
|
|
584
|
-
|
|
631
|
+
appetites: []
|
|
585
632
|
};
|
|
586
|
-
for (const s of
|
|
633
|
+
for (const s of appetites) {
|
|
587
634
|
const k = (id) => `${s.nn}-${id}`;
|
|
588
635
|
const sl = {
|
|
589
636
|
nn: s.nn,
|
|
590
|
-
name:
|
|
637
|
+
name: appetiteName(s.base),
|
|
591
638
|
base: s.base,
|
|
592
639
|
status: s.status,
|
|
593
|
-
|
|
640
|
+
slices: [],
|
|
594
641
|
bites: [],
|
|
595
642
|
trace: s.trace.map((st) => ({ f: st.f, n: st.n, name: st.name, kind: st.kind, desc: st.desc, note: st.note, task: st.task ? st.task.id : null, options: st.options }))
|
|
596
643
|
};
|
|
@@ -602,7 +649,7 @@ function dataOf(model, lang, date) {
|
|
|
602
649
|
priority: b.priority,
|
|
603
650
|
reason: b.reason,
|
|
604
651
|
taken: b.takenBy,
|
|
605
|
-
|
|
652
|
+
proposedSlice: b.proposedSlice || null,
|
|
606
653
|
value: b.value,
|
|
607
654
|
check: b.check,
|
|
608
655
|
dependsOn: b.dependsOn,
|
|
@@ -610,11 +657,11 @@ function dataOf(model, lang, date) {
|
|
|
610
657
|
anchor: b.task.id,
|
|
611
658
|
others: b.others.map((t) => t.id),
|
|
612
659
|
feature: b.feature,
|
|
613
|
-
source: `
|
|
660
|
+
source: `appetites/${s.base}.md:${b.line}`
|
|
614
661
|
});
|
|
615
662
|
}
|
|
616
|
-
for (const i of s.
|
|
617
|
-
sl.
|
|
663
|
+
for (const i of s.slices) {
|
|
664
|
+
sl.slices.push({
|
|
618
665
|
key: `${s.nn}-${i.n}`,
|
|
619
666
|
n: i.n,
|
|
620
667
|
name: i.name,
|
|
@@ -627,13 +674,14 @@ function dataOf(model, lang, date) {
|
|
|
627
674
|
tasks: i.taskIds,
|
|
628
675
|
unknowns: i.unknowns,
|
|
629
676
|
pending: i.pending,
|
|
677
|
+
learned: i.learned.map((l) => ({ kind: l.kind, text: l.text, affects: l.affects || [] })),
|
|
630
678
|
body: markdown(i.body),
|
|
631
|
-
source: i.detailFile ? `
|
|
679
|
+
source: i.detailFile ? `appetites/${s.base}/slice-${i.n}.md` : `appetites/${s.base}.md:${i.line}`,
|
|
632
680
|
proposed: false
|
|
633
681
|
});
|
|
634
682
|
}
|
|
635
683
|
for (const p of s.proposed) {
|
|
636
|
-
sl.
|
|
684
|
+
sl.slices.push({
|
|
637
685
|
key: `${s.nn}-${p.n}`,
|
|
638
686
|
n: p.n,
|
|
639
687
|
name: p.name,
|
|
@@ -647,44 +695,56 @@ function dataOf(model, lang, date) {
|
|
|
647
695
|
unknowns: '',
|
|
648
696
|
pending: [],
|
|
649
697
|
body: p.why ? `<p><b>Why this order:</b> ${inline(p.why)}</p>` : '',
|
|
650
|
-
source: `
|
|
698
|
+
source: `appetites/${s.base}.md:${p.line} (## Backlog › Proposed slices)`,
|
|
651
699
|
proposed: true
|
|
652
700
|
});
|
|
653
701
|
}
|
|
654
|
-
out.
|
|
702
|
+
out.appetites.push(sl);
|
|
655
703
|
}
|
|
656
704
|
return out;
|
|
657
705
|
}
|
|
658
706
|
|
|
707
|
+
// The next thing to do, in the order the flow goes: an unchecked plan step; a specified Slice with no plan
|
|
708
|
+
// (bokata-plan); with nothing in flight, the first proposed slice (bokata-spec).
|
|
659
709
|
function nextStep(model) {
|
|
660
|
-
for (const
|
|
661
|
-
if (
|
|
662
|
-
const sections = model.plan.
|
|
710
|
+
for (const appetite of model.appetites) {
|
|
711
|
+
if (appetite.status !== 'open') continue;
|
|
712
|
+
const sections = model.plan.appetites.get(appetite.nn);
|
|
663
713
|
if (!sections) continue;
|
|
664
714
|
for (const steps of sections.values()) {
|
|
665
715
|
const open = steps.find((s) => !s.done);
|
|
666
|
-
if (open) return { text: `${open.text.replace(/`/g, '')} — ${
|
|
716
|
+
if (open) return { text: `${open.text.replace(/`/g, '')} — ${appetite.base}`, link: 'plan.md' };
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
for (const appetite of model.appetites) {
|
|
720
|
+
if (appetite.status !== 'open') continue;
|
|
721
|
+
const specified = appetite.slices.find((i) => i.st.state === 'specified');
|
|
722
|
+
if (specified) return { text: `bokata-plan — Slice ${specified.n} ${specified.name} (${appetite.base})`, link: `${appetite.base}/slice-${specified.n}.md` };
|
|
723
|
+
const inFlight = appetite.slices.some((i) => i.st.state !== 'done');
|
|
724
|
+
if (!inFlight && appetite.proposed.length) {
|
|
725
|
+
const p = appetite.proposed[0];
|
|
726
|
+
return { text: `bokata-spec — Slice ${p.n} ${p.name} (${appetite.base})`, link: `${appetite.base}.md` };
|
|
667
727
|
}
|
|
668
728
|
}
|
|
669
729
|
return null;
|
|
670
730
|
}
|
|
671
731
|
|
|
672
732
|
function counts(model) {
|
|
673
|
-
let
|
|
674
|
-
let
|
|
733
|
+
let sliceTotal = 0;
|
|
734
|
+
let sliceDone = 0;
|
|
675
735
|
let stepTotal = 0;
|
|
676
736
|
let stepDone = 0;
|
|
677
737
|
let bitesLeft = 0;
|
|
678
|
-
for (const s of model.
|
|
679
|
-
for (const i of s.
|
|
680
|
-
|
|
681
|
-
if (i.st.state === 'done')
|
|
738
|
+
for (const s of model.appetites) {
|
|
739
|
+
for (const i of s.slices) {
|
|
740
|
+
sliceTotal += 1;
|
|
741
|
+
if (i.st.state === 'done') sliceDone += 1;
|
|
682
742
|
stepTotal += i.st.total;
|
|
683
743
|
stepDone += i.st.done;
|
|
684
744
|
}
|
|
685
745
|
bitesLeft += s.bites.filter((b) => b.takenBy === null).length;
|
|
686
746
|
}
|
|
687
|
-
return {
|
|
747
|
+
return { sliceTotal, sliceDone, stepTotal, stepDone, bitesLeft };
|
|
688
748
|
}
|
|
689
749
|
|
|
690
750
|
export function render(dir, { lang = 'en', date = new Date().toISOString().slice(0, 10) } = {}) {
|
|
@@ -699,7 +759,7 @@ export function render(dir, { lang = 'en', date = new Date().toISOString().slice
|
|
|
699
759
|
const html = fs.readFileSync(TEMPLATE, 'utf8').replace(/\{\{(\w+)\}\}/g, (_, key) => String(values[key] ?? ''));
|
|
700
760
|
return {
|
|
701
761
|
html,
|
|
702
|
-
summary: `story-map.html updated (${c.
|
|
762
|
+
summary: `story-map.html updated (${c.sliceDone}/${c.sliceTotal} slices, ${c.stepDone}/${c.stepTotal} steps, ${c.bitesLeft} bites left)`
|
|
703
763
|
};
|
|
704
764
|
}
|
|
705
765
|
|
|
@@ -712,11 +772,11 @@ export function check(dir) {
|
|
|
712
772
|
if (!(err instanceof RenderError)) throw err;
|
|
713
773
|
return { problems: [{ file: err.file, line: err.line, text: err.reason }], summary: '' };
|
|
714
774
|
}
|
|
715
|
-
const bites = model.
|
|
716
|
-
const
|
|
775
|
+
const bites = model.appetites.reduce((n, s) => n + s.bites.length, 0);
|
|
776
|
+
const slices = model.appetites.reduce((n, s) => n + s.slices.length, 0);
|
|
717
777
|
return {
|
|
718
778
|
problems: model.issues,
|
|
719
|
-
summary: `ok — ${model.features.length} Features, ${model.
|
|
779
|
+
summary: `ok — ${model.features.length} Features, ${model.appetites.length} appetites, ${slices} slices, ${bites} bites`
|
|
720
780
|
};
|
|
721
781
|
}
|
|
722
782
|
|