create-pmos 0.688.0 → 0.690.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.
Files changed (52) hide show
  1. package/package.json +26 -14
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-insights-test.js +23 -1
  7. package/workspace/briefing-premium-test.js +3 -0
  8. package/workspace/changelog.json +25 -0
  9. package/workspace/guide/breakdown.md +24 -1
  10. package/workspace/guide/cli.md +2 -0
  11. package/workspace/guide/initiatives-and-next-steps.md +13 -1
  12. package/workspace/guide/intelligence-okr-goals.md +1 -1
  13. package/workspace/guide/settings-and-switches.md +1 -1
  14. package/workspace/lib/board-premium.js +13 -3
  15. package/workspace/lib/engine/boards.js +18 -3
  16. package/workspace/lib/initiative-premium.js +7 -4
  17. package/workspace/lib/jira-cli.js +21 -2
  18. package/workspace/lib/jira-epics.js +125 -0
  19. package/workspace/lib/jira-status.js +18 -3
  20. package/workspace/lib/kind-scope.js +73 -0
  21. package/workspace/lib/route-modules.js +1 -0
  22. package/workspace/lib/routes-boards.js +109 -6
  23. package/workspace/lib/routes-intake.js +7 -3
  24. package/workspace/lib/routes-jira-epics.js +65 -0
  25. package/workspace/lib/settings-store.js +3 -0
  26. package/workspace/lib/task-cli.js +25 -7
  27. package/workspace/lib/task-store.js +2 -2
  28. package/workspace/package-lock.json +2 -2
  29. package/workspace/package.json +1 -1
  30. package/workspace/public/pm/bd-asks.js +4 -3
  31. package/workspace/public/pm/bd-backlog.js +25 -4
  32. package/workspace/public/pm/bd-ini-panel.js +1 -1
  33. package/workspace/public/pm/bd-pop-ds.css +22 -0
  34. package/workspace/public/pm/bd-pop-ds.js +48 -11
  35. package/workspace/public/pm/bd-sprint-ds.js +5 -4
  36. package/workspace/public/pm/bd-sprint.js +10 -3
  37. package/workspace/public/pm/bd-work-ds.css +4 -0
  38. package/workspace/public/pm/cozy-pop-work.css +12 -0
  39. package/workspace/public/pm/cozy-pop-work.js +172 -9
  40. package/workspace/public/pm/cozy-settings.js +9 -0
  41. package/workspace/public/pm/home-app.js +1 -1
  42. package/workspace/public/pm/home-ini-model.js +1 -1
  43. package/workspace/public/pm/home-ini.js +6 -3
  44. package/workspace/public/pm/ini-view-model.js +12 -1
  45. package/workspace/public/pm/pop-work-model.js +40 -7
  46. package/workspace/public/pm/premium-initiative-head.js +17 -6
  47. package/workspace/public/pm/premium-insights.js +1 -1
  48. package/workspace/public/pm/work-select.js +73 -0
  49. package/workspace/public/pm/work-tree.js +111 -0
  50. package/workspace/skills/jira-epic.skill +35 -0
  51. package/workspace/test-lists/kind-scopes-lifecycle-stages.json +9 -0
  52. package/workspace/test-lists/work-subtasks.json +11 -0
@@ -27,6 +27,8 @@ import * as SW from './cozy-status-when.js'; // When did this happen? after a
27
27
  import * as DP from './cozy-day-pick.js'; // the app's own day field, "15 Oct 2026"
28
28
  const { localToday } = DP;
29
29
  import * as AK from './artefact-kind.js';
30
+ import * as WT from './work-tree.js'; // subtasks, the epic check and its fix (initiative work-subtasks)
31
+ import * as SEL from './work-select.js'; // select several rows and move them together (WorkBulkDS)
30
32
  import * as PD from './bd-pop-ds.js'; // the popup on a computer, built from the design system's blocks (initiative work-ds-popup) // the Kind of a file and one row per kind (round 3 point 16), shared with the Library // the rename and its Undo, the same write as the old List (batch 18 item 16)
31
33
 
32
34
  const CSS = new URL('./cozy-pop-work.css', import.meta.url).href, DSCSS = new URL('./bd-pop-ds.css', import.meta.url).href;
@@ -52,10 +54,13 @@ const store = {
52
54
  // 'pw-cols2': a column choice saved before round 3 (Status and Date hidden by an older tune menu) no longer hides them (round 3 point 5)
53
55
  const COLS = 'pw-cols2', SPAN = 'pw-span', BIG = 'pw-big', TLW = 'pw-tlw';
54
56
  const cols = () => ({ status: true, date: true, tl: true, kind: true, when: true, ...store.get(COLS, {}) });
55
- const ST = new Map(); // initiative id → { open, shut, moreOpen, farOpen, details, top }
57
+ const ST = new Map(); // initiative id → { open, shut, moreOpen, farOpen, details, top, subOpen, subShut, sel, anchor, tickAsk }
58
+ let RSEL = new Set(); // the rows picked in the initiative drawn last (WorkBulkDS)
56
59
  const LOOSE = 'pw-loose'; // the initiatives whose Not in a stage row the PM opened (round 3 point 21), remembered on this computer
57
60
  const stOf = (id) => {
58
- if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(), moreOpen: new Set(), farOpen: false, details: null, top: 0, msAdd: false, focus: '' });
61
+ if (!ST.has(id)) ST.set(id, { open: new Set((store.get(LOOSE, []) || []).includes(id) ? [''] : []), shut: new Set(), moreOpen: new Set(), farOpen: false, details: null, top: 0, msAdd: false, focus: '',
62
+ // subtasks and the bulk move (initiative work-subtasks): the parents the PM opened or folded, the picked rows, the parent ticked
63
+ subOpen: new Set(), subShut: new Set(), sel: new Set(), anchor: '', tickAsk: '' });
59
64
  return ST.get(id);
60
65
  };
61
66
  const looseKeep = (id, on) => { const L = (store.get(LOOSE, []) || []).filter((x) => x !== id); if (on) L.push(id); store.set(LOOSE, L.slice(-200)); };
@@ -207,6 +212,12 @@ const xOf = (W) => { const a = Date.parse(W.span.a), b = Date.parse(W.span.b); r
207
212
  function barHtml(x, W) {
208
213
  const X = xOf(W);
209
214
  if (x.kind === 'stage') return x.start || x.end ? CB.stageBar({ start: x.start, end: x.end, tone: x.tone, late: x.late, ms: x.ms, name: x.name, gaps: x.gaps, marks: x.open ? [] : x.marks }, X, { today: W.today }) : '';
215
+ // a parent (WorkSubtasksDS): one outlined bar from its earliest subtask start to its latest end, filled as its subtasks finish
216
+ if (x.kids) {
217
+ if (!x.start && !x.end) return '';
218
+ const l = Math.max(0, X(x.start || x.end)), r = Math.min(100, X(x.end || x.start) + 0.6), f = x.nLeaf ? Math.round((x.nDone / x.nLeaf) * 100) : 0;
219
+ return `<i class="pw-pbar${x.done ? ' dn' : ''}" style="left:${l.toFixed(2)}%;width:${Math.max(0.8, r - l).toFixed(2)}%" title="${esc(x.title + ': ' + x.count)}"><b style="width:${f}%"></b></i>`;
220
+ }
210
221
  return CB.taskBar(x, X, W.today);
211
222
  }
212
223
  function rowHtml(x, W, C, sugRows) {
@@ -224,7 +235,10 @@ function rowHtml(x, W, C, sugRows) {
224
235
  if (x.kind === 'more') return `<div class="pw-tr pw-dr" role="row"><span class="pw-it"><button type="button" class="pw-dn" data-pw-more="${esc(x.key)}" aria-expanded="false">${esc(x.label)}${SVG(P.right, 14)}</button></span>${C.status ? '<span></span>' : ''}${C.date ? '<span></span>' : ''}${C.tl ? '<div class="pw-tl"></div>' : ''}</div>`;
225
236
  const s = sugRows.get(x.uid);
226
237
  const title = x.jira ? `<span class="pw-tt">${esc(x.title)}</span>` : `<button type="button" class="pw-tt" data-pw-name="${esc(x.uid)}" aria-label="${esc('Rename ' + x.title)}">${esc(x.title)}</button>`;
227
- return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}${x.lit ? ' lit' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"><span class="pw-it"><i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${RO ? '' : ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov') + ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
238
+ // subtasks (WorkSubtasksDS): indent one step per level, a parent's fold and count; a Jira row's key chip and the epic check's dot (WorkJiraDS)
239
+ const chev = x.kids ? `<button type="button" class="pw-chev" data-pw-sub="${esc(x.uid)}" aria-expanded="${!!x.open}" aria-label="${esc((x.open ? 'Fold ' : 'Open ') + x.title)}">${SVG(x.open ? P.down : P.right, 13)}</button>` : '';
240
+ const more2 = (x.kids ? `<small class="pw-cnt">${esc(x.count)}</small>` : '') + PD.keyChip(x) + PD.epicDot(x, W.epics || []);
241
+ return `<div class="pw-tr pw-kr${x.done ? ' done' : ''}${x.lit ? ' lit' : ''}${x.kids ? ' par' : ''}${RSEL.has(String(x.uid)) ? ' sel' : ''}" role="row" data-pw-row="${esc(x.uid)}" data-pw-sec="${esc(x.sec)}"${x.depth ? ` style="--pw-d:${x.depth}"` : ''}><span class="pw-it">${chev}<i class="pw-bul${x.ms ? ' ms' : ''}" aria-hidden="true"></i>${title}${more2}${RO ? '' : ib(`data-pw-open="${esc(x.uid)}"`, 'Open the task', P.open, 'xs hov') + ib(`data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu"`, 'More for ' + x.title, P.more, 'xs hov')}</span>${stc}${dtc}${tl}</div>`
228
242
  + (s ? `<div class="pw-tr pw-sugrow" role="row"><span class="pw-it">${sugLine(s, true)}</span></div>` : '');
229
243
  }
230
244
  function breakdownHtml(W, C, mode, full, S) {
@@ -287,8 +301,9 @@ const keyOf = (v, o) => String((o && o.id) || (v && (v.id || v.key)) || '');
287
301
  function model(r, v, o) {
288
302
  const id = keyOf(v, o), S = stOf(id), it = ITEMS.get(id);
289
303
  const g = o.goal || goalOf(o.ws, o.board, r.anchor || v.anchor);
290
- const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
304
+ const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, subOpen: S.subOpen, subShut: S.subShut, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
291
305
  const mk = M.marksOf(W.span, W.today); W.tx = mk.today;
306
+ W.epics = (r.epics || []).filter(Boolean); RSEL = S.sel; // the epic check and the picked rows, for the Gantt rows (initiative work-subtasks)
292
307
  return { W, S, id };
293
308
  }
294
309
  export function html(r, v, o = {}) {
@@ -312,15 +327,39 @@ function stagesOf(r, v, o, S) {
312
327
  }
313
328
  function dsHtml(r, v, o, W, S, C, mode) {
314
329
  const id = keyOf(v, o), view = store.get(VIEW, 'list') === 'gantt' ? 'gantt' : 'list';
315
- const st = stagesOf(r, v, { ...o, today: W.today, focus: S.focus }, S);
330
+ const st = stagesOf(r, v, { ...o, today: W.today, focus: S.focus, subOpen: S.subOpen, subShut: S.subShut }, S);
331
+ // the epic check (WorkJiraDS): the initiative's epics, the ✦ fix unless the PM said no to it; ticking a parent asks once
332
+ const epics = (r.epics || []).filter(Boolean), fix = dropped().has('epic:' + id) ? null : WT.epicFix(st, epics);
333
+ const askRow = S.tickAsk ? st.find((x) => x.uid === S.tickAsk) : null, ask = askRow ? { x: askRow, n: openUnder(stagesOf(r, v, { ...o, today: W.today, subAll: true }), askRow.uid).length } : null;
334
+ const head = (vw) => PD.wbsHead(vw, epics[0] || '', epics[0] ? jiraUrlOf(st, epics[0]) : '');
316
335
  const wbs = view === 'gantt'
317
- ? breakdownHtml(W, C, mode, false, S).replace('<h3>Work breakdown</h3>', PD.wbsHead('gantt')).replace('class="pw-sec"', 'class="pw-sec pm-block pwd-blk pwd-wbs"')
318
- : `<section class="pm-block pwd-blk pwd-wbs" aria-label="Work breakdown">${PD.wbsHead('list')}${PD.listHtml(st, W, { looseN: W.looseN })}</section>`;
336
+ ? breakdownHtml(W, C, mode, false, S).replace('<h3>Work breakdown</h3>', head('gantt') + (S.sel.size ? SEL.barHtml(S.sel.size) : '')).replace('class="pw-sec"', 'class="pw-sec pm-block pwd-blk pwd-wbs"')
337
+ : `<section class="pm-block pwd-blk pwd-wbs" aria-label="Work breakdown">${S.sel.size ? '' : head('list')}${PD.listHtml(st, W, { looseN: W.looseN, epics, fix, ask, sel: S.sel, nested: st.some((x) => x.kids) })}</section>`;
319
338
  const mg = mergeOf(W.artefacts), merge = mg ? `<div class="pw-sugs pw-amg" role="list" aria-label="PMOS suggests">${sugLine({ id: mg.id, say: mg.say, merge: mg })}</div>` : '';
320
339
  return `<div class="pw pwd">${'<div class="pwd-main">'}${PD.standsHtml(W, r)}${PD.stagesHtml(st, W)}${wbs}</div>`
321
340
  + `<aside class="pwd-side">${PD.caseHtml(W, { oid: id, dropped: dropped() })}${PD.artsHtml(W.artefacts, { merge })}</aside></div>`;
322
341
  }
323
342
 
343
+ /** The open rows under a parent, at any depth (a parent ticked asks to tick them too). */
344
+ /** A tick on a parent with open subtasks: ask once (true), else write the tick (false). */
345
+ function askKids(c, x, W, S, uid) {
346
+ if (S.tickAsk === uid) return false;
347
+ const kids = openUnder(stagesOf(c.r, c.v, { ...(x.o() || {}), today: W.today, subAll: true }), uid);
348
+ if (!kids.length) return false;
349
+ S.tickAsk = uid; return true;
350
+ }
351
+ function openUnder(rows, uid) {
352
+ const out = [], kids = new Map();
353
+ for (const x of rows || []) if (x.kind === 'task' && x.up) { if (!kids.has(x.up)) kids.set(x.up, []); kids.get(x.up).push(x); }
354
+ const walk = (u) => { for (const k of kids.get(u) || []) { if (!k.done && !k.jira) out.push(k); walk(k.uid); } };
355
+ walk(uid);
356
+ return out;
357
+ }
358
+ /** A Jira link for a key, from any row that carries a link to the same site. */
359
+ function jiraUrlOf(rows, key) {
360
+ const r = (rows || []).find((x) => x && x.jurl && /\/browse\//.test(x.jurl));
361
+ return r ? r.jurl.replace(/\/browse\/[^/?#]+/, '/browse/' + key) : '';
362
+ }
324
363
  /* ── a phone (board Ph2_init; build brief nav-structure/phone/build-brief-v2.md item 8): the popup's content in a phone layout. No cards and
325
364
  * no table: the stage and its days over, the gate line, ✦ Overview with the lines that are written and one proposal for the ones that are not,
326
365
  * the status line and PMOS's proposals, the Work breakdown as rows with a status dot (grey done, blue in progress, an empty ring to do), the
@@ -496,6 +535,13 @@ export function wire(body, h0, x0) {
496
535
  body.addEventListener('scroll', () => { if (!body.querySelector(':scope > .pw, .pw:not(.pw-sp)')) return; const c = cur(); if (c) c.S.top = body.scrollTop; }, { passive: true });
497
536
  body.addEventListener('click', async (e) => {
498
537
  if (!live(e)) return;
538
+ // select several rows (WorkBulkDS): Cmd or Ctrl-click adds one, Shift-click a range; with rows picked, a click adds or takes out one
539
+ { const rw = e.target.closest('[data-pw-row]'), c0 = rw && !e.target.closest('a, input, textarea, [data-pw-tick], [data-pw-sub], [data-pw-row-more], .acts') ? cur() : null;
540
+ if (rw && c0 && !RO && (e.shiftKey || e.metaKey || e.ctrlKey || c0.S.sel.size)) {
541
+ const order = [...body.querySelectorAll('[data-pw-row]')].map((el) => el.dataset.pwRow);
542
+ const pk = SEL.pick(c0.S.sel, order, rw.dataset.pwRow, { shift: e.shiftKey, meta: e.metaKey || e.ctrlKey, anchor: c0.S.anchor });
543
+ if (pk) { e.preventDefault(); c0.S.sel = pk.sel; c0.S.anchor = pk.anchor; redraw(); return; }
544
+ } }
499
545
  const b = e.target.closest('button, [data-pw-line]');
500
546
  // a List row (work-ds-popup): a press on the rest of the row opens the task
501
547
  if (!b) { const li = e.target.closest('[data-pwli]'); if (li && !e.target.closest('input, textarea')) { const c0 = cur(); if (c0) openSmall(li.dataset.pwli, c0, body.__pwh, body.__pwx, body); } return; }
@@ -529,7 +575,19 @@ export function wire(body, h0, x0) {
529
575
  if (d.pwVer) { if (ARTOPEN.has(d.pwVer)) ARTOPEN.delete(d.pwVer); else ARTOPEN.add(d.pwVer); redraw(); return; }
530
576
  if (d.pwRowMore) { rowMenu(b, d.pwRowMore, c, h, body); return; }
531
577
  // quick edit in the row (work-ds-quick-edit, WorkStatesDS 1 and 3): the tick, Who and Stage
532
- if (d.pwTick) { b.disabled = true; if (h.status) await h.status(d.pwTick, 'Done'); return; }
578
+ // a parent ticked asks once whether to tick its open subtasks too (WorkSubtasksDS)
579
+ // ticking a parent with open subtasks asks once (WorkSubtasksDS); otherwise the tick writes as before
580
+ if (d.pwTick) { if (askKids(c, x, W, S, d.pwTick)) return redraw(); b.disabled = true; S.tickAsk = ''; if (h.status) await h.status(d.pwTick, 'Done'); return; }
581
+ if (d.pwTickAll) {
582
+ const all = stagesOf(c.r, c.v, { ...(x.o() || {}), today: W.today, subAll: true }), row = all.find((q) => q.uid === d.pwTickAll);
583
+ const ids = openUnder(all, d.pwTickAll).map((q) => q.uid).concat(row && !row.jira && !row.done ? [row.uid] : []);
584
+ S.tickAsk = ''; await runBulk(ids, 'done', null, c, h, x); return;
585
+ }
586
+ if ('pwTickNo' in d) { const u = S.tickAsk; S.tickAsk = ''; redraw(); if (u && h.status) await h.status(u, 'Done'); return; }
587
+ if (d.pwSub) { const u = d.pwSub, open = b.getAttribute('aria-expanded') === 'true'; S.subOpen.delete(u); S.subShut.delete(u); (open ? S.subShut : S.subOpen).add(u); redraw(); return; }
588
+ if ('pwEpicFix' in d) { b.disabled = true; await epicFix(c, h, x); return; }
589
+ if ('pwEpicDrop' in d) { const dd = dropped(); dd.add('epic:' + c.id); store.set(DROP, [...dd].slice(-200)); redraw(); return; }
590
+ if (d.wsOp) { await bulkPress(b, d.wsOp, c, h, x); return; }
533
591
  if (d.pwWho) { whoMenu(b, d.pwWho, c, h, x); return; }
534
592
  if (d.pwStage) { stageMenu(b, d.pwStage, c, h, x); return; }
535
593
  if ('pwAddty' in d) { S.msAdd = !S.msAdd; const f = b.closest('.pw-add'), k = f && f.querySelector('[data-pw-add]') && f.querySelector('[data-pw-add]').dataset.pwAdd; redraw(); if (k != null) setTimeout(() => { const i = body.querySelector(`[data-pw-add="${window.CSS.escape(k)}"]`); if (i) i.focus(); }, 0); return; }
@@ -547,10 +605,14 @@ export function wire(body, h0, x0) {
547
605
  body.addEventListener('keydown', async (e) => {
548
606
  if (!live(e)) return;
549
607
  const t = e.target, h = body.__pwh;
608
+ if (e.key === 'Escape') { const c0 = cur(); if (c0 && (c0.S.sel.size || c0.S.tickAsk)) { e.preventDefault(); c0.S.sel.clear(); c0.S.tickAsk = ''; redraw(); return; } }
550
609
  if (t.matches && t.matches('[data-pw-line]') && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); t.click(); return; }
551
610
  // the List's one capture Input (work-ds-popup): the task goes to the stage it names ("… in Plan"), else the stage in progress
552
611
  if (t.matches && t.matches('[data-pw-cap]') && e.key === 'Enter') {
553
612
  e.preventDefault(); const v0 = t.value.trim(), c = cur(); if (!v0 || !h.addTask || !c) return;
613
+ // "under Batch 2: TM web" adds a subtask (WorkSubtasksDS): it takes its parent's stage
614
+ const all = stagesOf(c.r, c.v, { ...(body.__pwx.o() || {}), today: c.W.today, subAll: true }), un = WT.parseUnder(v0, all);
615
+ if (un) { await addUnder(un, all, c, h, body.__pwx); setTimeout(() => { const f = body.querySelector('[data-pw-cap]'); if (f) { f.value = ''; f.focus(); } }, 0); return; }
554
616
  const ms = /^◇\s*/.test(v0), k = PD.stageKeyOf(v0.replace(/^◇\s*/, ''), stagesOf(c.r, c.v, { ...(body.__pwx.o() || {}), today: c.W.today }));
555
617
  if (!k || !k.title) return;
556
618
  await h.addTask(k.title, t, { section: k.key, name: k.name, ...(ms ? { milestone: true } : {}) });
@@ -726,8 +788,13 @@ function rowMenu(btn, uid, c, h, body) {
726
788
  const row = c.W.rows.find((x) => x.uid === uid) || {};
727
789
  openPop(btn, 'pw-rowm', `<button type="button" class="hi-mi" role="menuitem" data-k="status">${SVG(P.box, 14, 2)} Status: ${esc(row.status || 'To do')}</button>`
728
790
  + `<button type="button" class="hi-mi" role="menuitem" data-k="kind">${SVG(row.ms ? P.box : P.dia, 14, 2)} ${row.ms ? 'Make it a task' : 'Make it a milestone'}</button>`
729
- + `<button type="button" class="hi-mi" role="menuitem" data-k="open">${SVG(P.open, 14)} Open the task</button>` + jiraNote(row), (b) => {
791
+ + `<button type="button" class="hi-mi" role="menuitem" data-k="open">${SVG(P.open, 14)} Open the task</button>`
792
+ // subtasks (WorkSubtasksDS): make it a subtask of another task, or move it out of its parent
793
+ + (row.jsub ? '' : `<button type="button" class="hi-mi" role="menuitem" data-k="under" aria-haspopup="menu">${SVG(P.right, 14)} Make subtask of…</button>`)
794
+ + (row.up && !row.jsub ? `<button type="button" class="hi-mi" role="menuitem" data-k="out">${SVG(P.show, 14)} Move out of ${esc(((c.W.rows.find((q) => q.uid === row.up) || {}).title) || 'its parent')}</button>` : '') + jiraNote(row), (b) => {
730
795
  const k = b.dataset.k;
796
+ if (k === 'under') { parentMenu(btn, [uid], c, h, body.__pwx); return; }
797
+ if (k === 'out') { closePop(); runBulk([uid], 'parent', '', c, h, body.__pwx); return; }
731
798
  // Status opens its own list (and its "when did this happen" line) in place of this menu
732
799
  if (k === 'status') { statusMenu(btn, uid, h, c); return; }
733
800
  closePop();
@@ -735,6 +802,102 @@ function rowMenu(btn, uid, c, h, body) {
735
802
  else if (k === 'open') openSmall(uid, c, h, body.__pwx, body);
736
803
  }, { menu: true, label: 'Task' });
737
804
  }
805
+ /* ── subtasks and the bulk move (initiative work-subtasks; WorkSubtasksDS, WorkBulkDS) ── */
806
+ const atOf = (h, x) => { const o = (x && x.o && x.o()) || {}, w = h.where ? h.where() : {}; return { ws: w.ws || o.ws, board: w.board || o.board, ini: o.id }; };
807
+ /** One bulk write (POST /api/boards/tasks/bulk) with one Undo; the picked rows clear. */
808
+ async function runBulk(ids, op, value, c, h, x, label) {
809
+ const at = atOf(h, x);
810
+ if (c && c.S) { c.S.sel.clear(); c.S.anchor = ''; }
811
+ await SEL.bulk(pmPost, { ws: at.ws, board: at.board }, ids, op, value, { say: (m, u) => (u ? undoToast(m, u) : h.toast ? h.toast(m) : undoToast(m)), reload: async () => { if (h.reload) await h.reload(); else if (h.redraw) h.redraw(); } }, label);
812
+ }
813
+ /** The parents a task can go under: the other tasks of this work, not the picked ones and not under them. "A new parent…" and the top level. */
814
+ function parentMenu(btn, ids, c, h, x) {
815
+ const all = stagesOf(c.r, c.v, { ...((x && x.o && x.o()) || {}), today: c.W.today, subAll: true }).filter((r) => r.kind === 'task' && !r.jsub);
816
+ const pick = new Set(ids), under = new Set();
817
+ const kids = new Map(); for (const r of all) if (r.up) { if (!kids.has(r.up)) kids.set(r.up, []); kids.get(r.up).push(r.uid); }
818
+ const walk = (u) => { for (const k of kids.get(u) || []) { under.add(k); walk(k); } };
819
+ for (const u of ids) walk(u);
820
+ const L = all.filter((r) => !pick.has(r.uid) && !under.has(r.uid)).slice(0, 60);
821
+ const n = ids.length;
822
+ openPop(btn, 'pw-under', `<p class="hi-small">${esc('Move ' + (n === 1 ? 'it' : n + ' tasks') + ' under')}</p>`
823
+ + `<button type="button" class="hi-mi" role="menuitem" data-new>${SVG(P.plus, 14)} A new parent…</button>`
824
+ + L.map((r, i) => `<button type="button" class="hi-mi" role="menuitem" data-i="${i}" style="padding-left:${10 + Math.min(r.depth || 0, 3) * 14}px">${esc(r.title)}${r.kids ? ` <span class="hi-small">${esc(String(r.kids))}</span>` : ''}</button>`).join('')
825
+ + `<button type="button" class="hi-mi" role="menuitem" data-top>Top level (no parent)</button>`, async (b) => {
826
+ if ('new' in b.dataset) { newParent(btn, ids, all, c, h, x); return; }
827
+ closePop();
828
+ if ('top' in b.dataset) { await runBulk(ids, 'parent', '', c, h, x, 'the top level'); return; }
829
+ const r = L[+b.dataset.i]; if (r) await runBulk(ids, 'parent', r.uid, c, h, x, r.title);
830
+ }, { menu: true, label: 'Under a parent' });
831
+ }
832
+ /** A new parent: its name, then it is made in the stage of the first picked task and the picked tasks move under it. */
833
+ function newParent(btn, ids, all, c, h, x) {
834
+ openPop(btn, 'pw-newp', `<label class="hi-small" for="pw-newp-in">The new parent's name</label><input id="pw-newp-in" class="pm-input" data-newp maxlength="200" autocomplete="off" placeholder="Batch 2 · go-live 1 Dec"><div class="pm-row"><button type="button" class="pm-btn primary" data-go aria-label="Make it and move the tasks under it" title="Make it">${SVG(P.plus, 14)}</button></div>`, async (b) => {
835
+ if (!('go' in b.dataset)) return;
836
+ const inp = document.querySelector('[data-newp]'), name = inp ? inp.value.trim() : '';
837
+ if (!name) return;
838
+ closePop();
839
+ const at = atOf(h, x), first = all.find((r) => r.uid === ids[0]);
840
+ const r = await pmPost('/api/boards/tasks/add', { ws: at.ws, board: at.board, initiative: at.ini, title: name, ...(first && first.sec ? { section: first.sec } : {}) }).catch(() => null);
841
+ if (!r || r.ok === false || !r.item) { (h.toast || undoToast)((r && r.error) || 'The parent was not made.'); return; }
842
+ await runBulk(ids, 'parent', r.item.uid, c, h, x, name);
843
+ }, { label: 'A new parent', focus: '[data-newp]' });
844
+ }
845
+ /** "under Batch 2: TM web": a new task under that parent, in its stage. Undo takes it back. */
846
+ async function addUnder(un, all, c, h, x) {
847
+ const at = atOf(h, x), p = all.find((r) => r.uid === un.parent);
848
+ const r = await pmPost('/api/boards/tasks/add', { ws: at.ws, board: at.board, initiative: at.ini, title: un.title, parent: un.parent, ...(p && p.sec ? { section: p.sec } : {}) }).catch(() => null);
849
+ if (!r || r.ok === false || !r.item) { (h.toast || undoToast)((r && r.error) || 'The subtask was not added.'); return; }
850
+ c.S.subOpen.add(un.parent); c.S.subShut.delete(un.parent);
851
+ undoToast(`Added under ${un.parentTitle}: ${un.title}.`, async () => { await pmPost('/api/boards/tasks/undo-add', { ws: at.ws, board: at.board, task: r.item.uid }).catch(() => null); if (h.reload) await h.reload(); });
852
+ if (h.reload) await h.reload();
853
+ }
854
+ /** The bar's presses (WorkBulkDS): under a parent, stage, who, move dates, done, clear. */
855
+ async function bulkPress(btn, op, c, h, x) {
856
+ const S = c.S, ids = [...S.sel];
857
+ if (op === 'clear') { S.sel.clear(); S.anchor = ''; if (h.redraw) h.redraw(); return; }
858
+ if (!ids.length) return;
859
+ if (op === 'done') { await runBulk(ids, 'done', null, c, h, x); return; }
860
+ if (op === 'parent') { parentMenu(btn, ids, c, h, x); return; }
861
+ if (op === 'section') {
862
+ const L = PD.stageList(stagesOf(c.r, c.v, { ...((x && x.o && x.o()) || {}), today: c.W.today }), '');
863
+ openPop(btn, 'pw-bstage', L.map((s2, i) => `<button type="button" class="hi-mi" role="menuitem" data-i="${i}">${esc(s2.name)}</button>`).join('') || '<p class="hi-small">This work has no stages.</p>', async (b) => {
864
+ const s2 = L[+b.dataset.i]; closePop(); if (s2) await runBulk(ids, 'section', s2.key, c, h, x, s2.name);
865
+ }, { menu: true, label: 'Stage' });
866
+ return;
867
+ }
868
+ if (op === 'owner') {
869
+ const L = PD.whoOf(c.W.rows, '').filter((p) => !p.pmos);
870
+ openPop(btn, 'pw-bwho', L.map((p, i) => `<button type="button" class="hi-mi" role="menuitem" data-i="${i}">${SVG(PD.I.who, 14, 2)} ${esc(p.label)}</button>`).join(''), async (b) => {
871
+ const p = L[+b.dataset.i]; closePop(); if (p) await runBulk(ids, 'owner', p.k === 'You' ? '' : p.k, c, h, x, p.label);
872
+ }, { menu: true, label: 'Who' });
873
+ return;
874
+ }
875
+ if (op === 'shift') {
876
+ const Q = [[-7, '1 week earlier'], [-1, '1 day earlier'], [1, '1 day later'], [7, '1 week later']];
877
+ openPop(btn, 'pw-bshift', Q.map(([n, l]) => `<button type="button" class="hi-mi" role="menuitem" data-n="${n}">${esc(l)}</button>`).join('')
878
+ + `<label class="hi-small" for="pw-bshift-in">Or a number of days (+3, -2, 1w)</label><input id="pw-bshift-in" class="pm-input" data-bshift maxlength="12" autocomplete="off"><div class="pm-row"><button type="button" class="pm-btn primary" data-go aria-label="Move the dates" title="Move the dates">${SVG(P.check, 14)}</button></div>`, async (b) => {
879
+ let n = b.dataset.n != null ? +b.dataset.n : null;
880
+ if ('go' in b.dataset) { const i = document.querySelector('[data-bshift]'); n = SEL.shiftOf(i ? i.value : ''); if (n == null) return; }
881
+ if (n == null) return;
882
+ closePop(); await runBulk(ids, 'shift', n, c, h, x);
883
+ }, { label: 'Move dates' });
884
+ }
885
+ }
886
+ /** The epic check's ✦ fix (WorkJiraDS): every flagged ticket goes under the initiative's epic; Undo withdraws what Jira has not done yet. */
887
+ async function epicFix(c, h, x) {
888
+ const o = (x && x.o && x.o()) || {}, at = atOf(h, x), epics = (c.r.epics || []).filter(Boolean);
889
+ const st = stagesOf(c.r, c.v, { ...o, today: c.W.today, subAll: true }), fx = WT.epicFix(st, epics);
890
+ if (!fx) return;
891
+ const tickets = fx.keys.map((k) => { const r = st.find((q) => WT.keyOf(q) === k) || {}; return { key: k, from: r.jepic || '', who: r.jassignee || '' }; });
892
+ const r = await pmPost('/api/jira-epics/fix', { ws: at.ws, ini: at.ini, epic: fx.epic, tickets }).catch(() => null);
893
+ const say = (m, u) => (u ? undoToast(m, u) : h.toast ? h.toast(m) : undoToast(m));
894
+ if (!r || r.ok === false) { say((r && r.error) || 'The fix was not asked.'); if (h.redraw) h.redraw(); return; }
895
+ const dd = dropped(); dd.add('epic:' + c.id); store.set(DROP, [...dd].slice(-200));
896
+ const words = [r.direct.length ? (r.direct.length === 1 ? r.direct[0] + ' moves' : r.direct.length + ' tickets move') + ' under ' + fx.epic + ' in Jira now.' : '',
897
+ r.draft.length ? (r.draft.length === 1 ? r.draft[0].key + ' is' : r.draft.length + ' tickets are') + ' in today\'s Jira draft for ' + [...new Set(r.draft.map((q) => q.who || 'their owner'))].join(', ') + '.' : ''].filter(Boolean).join(' ');
898
+ say(words, async () => { const u = await pmPost('/api/jira-epics/undo', { ws: at.ws, ids: r.ids }).catch(() => null); dd.delete('epic:' + c.id); store.set(DROP, [...dd].slice(-200)); say(u && u.kept && u.kept.length ? 'Put back, except ' + u.kept.join(', ') + ': Jira already has it.' : 'Put back.'); if (h.redraw) h.redraw(); });
899
+ if (h.redraw) h.redraw();
900
+ }
738
901
  /* Who (WorkStatesDS 1): You, the people who own this initiative's tasks, and "PMOS does it". A name writes the owner (Undo puts the old one
739
902
  * back, POST /api/boards/tasks/edit with `from`); PMOS does it gives the task to PMOS (POST /api/backlog/give; Undo is /api/backlog/stop). */
740
903
  function whoMenu(btn, uid, c, h, x) {
@@ -111,6 +111,7 @@ function general() {
111
111
  const upd = ready() ? `<div class="ev-card ev-upd">${adFace('needs-you')}<span class="pm-badge blue">Update</span><p><b>PMOS ${esc(latest())} is ready.</b> <span class="ev-mut">${esc(firstLine())}</span></p><button type="button" class="ev-btn sm" data-ev-go="updates">What's new</button><button type="button" class="ev-btn sm dark" data-ev-upd="update">${appBehind() ? 'Restart to update' : 'Update'}</button></div>` : '';
112
112
  return trow('Theme', 'Auto follows your computer', seg('Theme', 'theme', theme, [['light', 'Light'], ['dark', 'Dark'], ['auto', 'Auto']]))
113
113
  + trow('Product', 'Which products Today, Work and Goals read', `<button type="button" class="ev-pick" data-ev-products aria-haspopup="menu">${esc(pname)} ${svg(ICON.down, 14)}</button>`)
114
+ + trow('New work starts as', 'The kind a new initiative starts as. Project hides Triage, Discover and the product documents. Each initiative can change it.', seg('New work starts as', 'work.role', roleVal(), [['product', 'Product'], ['project', 'Project'], ['sdlc', 'Full SDLC']]))
114
115
  + trow('Your day', 'When the end-of-day card shows', `<label class="ev-vh" for="evDay">Your day ends at</label><select id="evDay" class="ev-inp" data-ev-day>${hours.map((h) => `<option value="${h}"${h === end ? ' selected' : ''}>${pad(h)}:00</option>`).join('')}</select>`)
115
116
  + trow('Your impact', 'Adler’s sprout and your impact log. Only you see it. Nothing leaves PMOS.', sw(impactOn(), 'data-ev-impact', 'Your impact'))
116
117
  + trow('Agents write to Jira', 'Only after you press Commit. Never on their own.', (ready() ? '' : adFace('needs-you', 24)) + '<span class="pm-badge">Fixed</span>')
@@ -119,6 +120,9 @@ function general() {
119
120
  + trow('Adler', 'How much of PMOS’s face shows, motion, celebrations, quiet hours and Dress for the day', subBtn('adler'))
120
121
  + trow('Jev and Laya', 'The TypeSafe key, Laya on this computer and the repositories it reads', subBtn('jl'));
121
122
  }
123
+ /* Your role (initiative kind-scopes-lifecycle-stages): work.role, the kind a new initiative starts as when its name gives no cue */
124
+ const roleVal = () => { const r = T.set && Array.isArray(T.set.settings) ? T.set.settings.find((x) => x.key === 'work.role') : null; return r && r.value ? r.value : 'product'; };
125
+ const ROLE_SAY = { product: 'Saved. New initiatives start as Product work.', project: 'Saved. New initiatives start as Project work: Triage, Discover and the product documents stay folded away.', sdlc: 'Saved. New initiatives start as Full SDLC work.' };
122
126
  /* General › Extras (U4): the row's › opens the sub-panel; its ‹ comes back to General */
123
127
  const subBtn = (k) => `<button type="button" class="ev-ib pm-btn" data-ev-sub="${k}" aria-label="${esc(SUBS[k])}" title="${esc(SUBS[k])}">${svg(CHEV, 18)}</button>`;
124
128
  const subHead = (k) => `<div class="ev-dr-hd"><button type="button" class="ev-ib pm-btn" data-ev-sub="" aria-label="Back to ${esc((SECTIONS.find((x) => x[0] === T.sec) || SECTIONS[0])[1])}" title="Back">${svg(BACK, 18)}</button><h4 class="ev-grow">${esc(SUBS[k])}</h4></div>`;
@@ -621,6 +625,11 @@ async function press(e) {
621
625
  if (t.dataset.evGo) { T.sec = t.dataset.evGo; T.sub = ''; draw(); return; }
622
626
  if (t.dataset.evSub !== undefined) { const k = t.dataset.evSub, was = T.sub; T.sub = k; T.dress = false; T.more = false; T.bday = false; T.msg = ''; draw(); const f = T.el.querySelector(k ? '[data-ev-sub=""]' : `[data-ev-sub="${was}"]`); if (f) f.focus(); return; }
623
627
  if (t.dataset.evSeg && t.dataset.evSeg.startsWith('claude.way:')) { await saveWay(t.dataset.evSeg.slice(11), t.dataset.v); return; }
628
+ if (t.dataset.evSeg === 'work.role') {
629
+ const r = await pmPost('/api/settings', { key: 'work.role', value: t.dataset.v });
630
+ const row = r && r.ok && T.set && Array.isArray(T.set.settings) ? T.set.settings.find((x) => x.key === 'work.role') : null; if (row) row.value = r.value;
631
+ T.msg = r && r.ok ? ROLE_SAY[t.dataset.v] || 'Saved.' : (r && r.error) || 'Not saved.'; draw(); return;
632
+ }
624
633
  if (t.dataset.evSeg === 'theme') { const M = await import('./cozy-nav.js'); M.setTheme(t.dataset.v); draw(); return; }
625
634
  if (t.dataset.evSeg && t.dataset.evSeg.startsWith('grill.')) {
626
635
  const key = t.dataset.evSeg, value = key === 'grill.cap' ? Number(t.dataset.v) : t.dataset.v;
@@ -783,7 +783,7 @@ function iniViewOf(id) {
783
783
  const p = programOf(S.D.programs || [], row.ws || (B.board || {}).ws || '', id);
784
784
  const IM = S.IM && S.IMid === id ? S.IM : null; // W1: the page model's gate line (the spec ladder), when the page model is read
785
785
  return iniView(rowFor({ ...row, trail: t || row.trail || null }), { steps: B.steps || STEPS, today: B.today, usual: WFM.usualOf(S.D.trail, row),
786
- gate: IM && !(row.wf && row.wf.id && row.wf.id !== 'product-feature') ? gateOf(IM.gateSteps || IM.checks) : null,
786
+ gate: IM && !(row.wf && row.wf.id && row.wf.id !== 'product-feature') ? gateOf(IM.gateSteps || IM.checks, IM.scope) : null,
787
787
  ask: need ? { title: need.name, n: H.needsOf(S.D).filter((r) => r.ini === id).length, propose: (need.row && need.row.propose) || null } : null, program: p ? { id: p.id, title: p.title } : null, jiraReadAt: ((B.jira || {}).readAt) || '',
788
788
  // the card (batch 18 item 1): Claude's line while a session works on it, the stakeholders
789
789
  claude: (() => { const w = S.D.sessions.find((s) => H.iniOfSession(s) === id && s.shown === 'working'); return w ? 'I’m working on “' + H.nameOf(w) + '”. I’ll say here when it is ready.' : ''; })(),
@@ -132,7 +132,7 @@ export function docRows(M) {
132
132
  const kind = custom ? (d.link ? (/Slides/.test(d.link.kind || '') ? 'Slides' : 'Linked') : 'Added') : KIND[d.key] || 'Document';
133
133
  const phase = phases.includes(d.cat) ? d.cat : null;
134
134
  return { key: d.key, title: d.title, kind, chip: CHIP[kind] || 'Other', core: !custom, phase, st: d.st || 'missing', state: d.state || '', by: d.by || '', when: d.when || (d.added ? 'added ' + d.added : ''), path: d.path || null,
135
- slot: d.slot || '', act: d.act || null, running: !!d.running, link: d.link || null, look: LOOK.has(d.st), what: d.what || '', ...(d.other ? { other: true } : {}) };
135
+ slot: d.slot || '', act: d.act || null, running: !!d.running, link: d.link || null, look: LOOK.has(d.st) && !d.hidden, what: d.what || '', ...(d.other ? { other: true } : {}), ...(d.hidden ? { hidden: true } : {}) };
136
136
  });
137
137
  }
138
138
  /** The pill a document row shows: its state, Skipped (an earlier stage did without it), Not started. */
@@ -560,15 +560,18 @@ function docRowHtml(d, cur, later, phases) {
560
560
  function docsView(id, M) {
561
561
  const rows = MD.docRows(M), { phases, cur } = MD.docPhases(M);
562
562
  if (!rows.length) return '<div class="hi-v hi-v2" data-hi-v="docs">' + VW().czSummary({ text: M.docs && M.docs.missing ? 'The core documents could not be read.' : 'This initiative has no core document yet.', primary: { label: 'Add a document', act: 'adddoc' } }) + '</div>';
563
- const G = MD.docGroups(rows, M.acts && M.acts.stage, { ...X.doc, phases, cur });
564
- const look = rows.filter((d) => d.look), miss = rows.filter((d) => !d.path && d.act && d.act.kind === 'draft' && !d.running);
563
+ // the kind's scope (lib/kind-scope.js): a project's product documents are hidden. They fold into one closed section at the end, never dropped
564
+ const shown = rows.filter((d) => !d.hidden), hid = rows.filter((d) => d.hidden);
565
+ const G = MD.docGroups(shown, M.acts && M.acts.stage, { ...X.doc, phases, cur });
566
+ const look = shown.filter((d) => d.look), miss = shown.filter((d) => !d.path && d.act && d.act.kind === 'draft' && !d.running);
565
567
  const said = look.slice(0, 2).map((d) => d.title + ' ' + String(MD.docPill(d, cur, phases)[0] || '').toLowerCase()).concat(miss.filter((d) => !d.look).slice(0, 1).map((d) => 'The ' + d.title + ' is not written yet'));
566
568
  const first = miss[0] || null, open = !first && look.find((d) => d.path);
567
569
  const pri = first ? { label: 'Draft the ' + first.title, act: 'draft:' + first.key } : open ? { label: 'Open ' + open.title, act: 'open:' + open.key } : null;
568
570
  const sum = VW().czSummary({ line: look.length ? look.length + (look.length === 1 ? ' needs a look' : ' need a look') : '', tone: look.length ? 'warn' : '',
569
571
  text: said.length ? said.map((x) => x.replace(/^./, (c) => c.toUpperCase())).join('. ') + '.' : 'Every document is in place for ' + (cur || 'this stage') + '.',
570
572
  meta: rows.length + (rows.length === 1 ? ' document' : ' documents') + ' · filter and sort are under More', extra: M.docs && M.docs.cap ? `<p class="czs-meta" data-ov-dsum>${esc(M.docs.cap)}</p>` : '', primary: pri });
571
- const secs = VW().czSections(G.map((g, i) => ({ id: 'd:' + (g.key || i), title: g.title || 'Documents', count: g.rows.length, open: i === 0, html: g.rows.map((d) => docRowHtml(d, cur, g.later, phases)).join('') })), { key: 'docs' });
573
+ const secs = VW().czSections(G.map((g, i) => ({ id: 'd:' + (g.key || i), title: g.title || 'Documents', count: g.rows.length, open: i === 0, html: g.rows.map((d) => docRowHtml(d, cur, g.later, phases)).join('') }))
574
+ .concat(hid.length ? [{ id: 'd:hidden', title: 'Product documents', count: hid.length, open: false, html: hid.map((d) => docRowHtml(d, cur, false, phases)).join('') }] : []), { key: 'docs' });
572
575
  return '<div class="hi-v hi-v2" data-hi-v="docs">' + sum + (secs || '<p class="hi-empty">No document matches.</p>') + '</div>';
573
576
  }
574
577
  function stageView(id, M, ask) {
@@ -143,7 +143,18 @@ function rowOf(k0, today, J = null) {
143
143
  // planned versus actual (batch 11 item 8, pm/ini-versions.js): the compared version's days where they differ, ⊕ added after it, a draft's task
144
144
  cmp: k.cmp || null, added: !!k.added, dr: !!k.draft,
145
145
  // jkey: the key of the Jira ticket the task is linked to, only when PMOS read that ticket; jst: its own Jira status (it owns the status)
146
- jkey: J ? J.key : '', jst: J ? String(J.raw || J.status || '') : '', jmove: J && J.move ? J.move : null, _k: k0, _t: today }; // jmove: a move asked in PMOS (lib/jira-moves.js)
146
+ jkey: J ? J.key : '', jst: J ? String(J.raw || J.status || '') : '', jmove: J && J.move ? J.move : null, _k: k0, _t: today, // jmove: a move asked in PMOS (lib/jira-moves.js)
147
+ // subtasks and the Jira chip and epic check (initiative work-subtasks): the parent task; the ticket's link, epic (undefined: not read),
148
+ // assignee, type and sub-tasks, from the sprint read (J) or the read of the ticket the task names (k0.jira, lib/board-premium.js jiraOf)
149
+ parent: k0.parent || '', ...jiraFields(J, k0.jira) };
150
+ }
151
+ function jiraFields(J, R) {
152
+ if (!J && !R) return {};
153
+ const pick = (k) => (J && J[k] != null && J[k] !== '' ? J[k] : R && R[k] != null ? R[k] : '');
154
+ const read = (J && 'epic' in J) || (R && 'epic' in R);
155
+ // ckey: the key the row's chip shows: the linked ticket's, else the one the task names that PMOS read (the task keeps its own status then)
156
+ return { ckey: (J && J.key) || (R && R.key) || '', jurl: pick('url'), jassignee: pick('assignee'), jtype: pick('type'), ...(read ? { jepic: pick('epic') || '', jepicName: pick('epicName') } : {}),
157
+ ...(J && J.sub || (R && R.parentTicket) ? { jsubOf: (J && J.parentTicket) || R.parentTicket || '' } : {}), jsubs: (R && R.subs) || (J && J.subs) || [] };
147
158
  }
148
159
  /** The Jira keys a task's title holds ("MSD-4376 Navigation tabs" → ['MSD-4376']). A task whose title names a ticket PMOS read IS that ticket
149
160
  * (linkOf): it shows the Jira mark and the key once, its status is Jira's, and the ticket's own row does not show again (batch 11 item 4,
@@ -29,6 +29,7 @@
29
29
 
30
30
  import { gapsOf } from './cozy-bar.js';
31
31
  import { provenStatus, NO_SIGNAL } from './status-proof.js';
32
+ import * as WT from './work-tree.js'; // subtasks: nesting and the roll-up (initiative work-subtasks)
32
33
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
33
34
  const DAY = 864e5;
34
35
  const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
@@ -295,7 +296,24 @@ function taskRow(x, t) {
295
296
  const dl = x.end ? dateLate(x.end, t, !x.closed) : { text: x.start ? 'from ' + dayText(x.start, t) : '', late: false };
296
297
  const st = taskStatus(x);
297
298
  return { kind: 'task', uid: x.uid, title: x.title, who: x.owner || '', status: st, date: dl.text, late: dl.late, start: x.start || '', end: x.end || '', since: x.since || '', done: !!x.closed, ms: !!x.ms, jira: !!x.jkey, canCheck: !!x.canCheck,
298
- prog: /progress|review/i.test(st), wont: !!x.wont || st === "Won't do" };
299
+ prog: /progress|review/i.test(st), wont: !!x.wont || st === "Won't do",
300
+ // subtasks and Jira (initiative work-subtasks): the parent, the chip's key and link, the epic as read, the assignee, a Jira sub-task
301
+ parent: x.parent || '', ckey: x.ckey || x.jkey || '', jurl: x.jurl || '', ...(x.jepic !== undefined ? { jepic: x.jepic, jepicName: x.jepicName || '' } : {}), jassignee: x.jassignee || '', jtype: x.jtype || '',
302
+ ...(x.jsub ? { jsub: true } : {}), ...(x.jsubOf ? { jsubOf: x.jsubOf } : {}) };
303
+ }
304
+ /** The tasks of every stage, nested (initiative work-subtasks): the read Jira sub-tasks join as rows under their ticket, and a task that names
305
+ * a sub-task's key with no parent of its own sits under its ticket's row. → { T: Map uid → node, isChild(x), rx(x) (a parent with its roll-up) } */
306
+ function treeOf(secs) {
307
+ const all0 = [];
308
+ for (const s of secs) all0.push(...tasksOf(s), ...(s.done || []));
309
+ const keyed = new Map(); for (const x of all0) { const k = x.ckey || x.jkey; if (k && !keyed.has(k)) keyed.set(k, x); }
310
+ const extra = [];
311
+ for (const x of all0) for (const sr of WT.subRows(x)) if (!keyed.has(sr.uid)) { keyed.set(sr.uid, sr); extra.push(sr); }
312
+ const T = WT.nest(all0.map((x) => (!x.parent && x.jsubOf && keyed.has(x.jsubOf) && keyed.get(x.jsubOf) !== x ? { ...x, parent: keyed.get(x.jsubOf).uid } : x)).concat(extra));
313
+ const node = (x) => T.get(String(x.uid));
314
+ const isChild = (x) => { const n = node(x); return !!(n && n.up); };
315
+ const rx = (x) => { const n = node(x); if (!n || !n.kids.length) return x; const r = WT.rollup(n); return { ...x, start: r.start, end: r.end, closed: r.done, status: r.done ? 'Done' : x.status === 'Done' ? 'In progress' : x.status }; };
316
+ return { T, node, isChild, rx };
299
317
  }
300
318
  /** o.focus: the task a Today row opened (round 3 item 11b): its stage, its done fold and the far stages open, and its row lit. */
301
319
  const holds = (list, f) => !!f && (list || []).some((x) => x && String(x.uid) === f);
@@ -316,11 +334,26 @@ export function breakdownOf(r, v, o = {}) {
316
334
  // offers to put them in the stage in progress, the one stage PMOS can name for each
317
335
  const looseUnder = null;
318
336
  const loose = [];
337
+ const TR = treeOf(secs), subOpen = o.subOpen || new Set(), subShut = o.subShut || new Set();
338
+ // one row and, when it is open, its subtasks under it by date (initiative work-subtasks); depth caps the indent at INDENT_MAX
339
+ const emit = (x, d, sec) => {
340
+ const n = TR.node(x), r = n && n.kids.length ? WT.rollup(n) : null;
341
+ const hasF = !!(f && n && WT.under(n).some((y) => String(y.uid) === f));
342
+ const open = r ? (hasF || o.subAll ? true : subShut.has(String(x.uid)) ? false : subOpen.has(String(x.uid)) ? true : r.kids <= WT.FOLD_KIDS) : false;
343
+ rows.push(lit({ ...x, sec, depth: Math.min(d, WT.INDENT_MAX), ...(n && n.up ? { up: String(n.up.x.uid) } : {}), ...(r ? { kids: r.kids, nLeaf: r.n, nDone: r.nDone, count: r.nDone + ' of ' + r.n + ' done', open } : {}) }));
344
+ if (!r || !open) return;
345
+ const kids = n.kids.map((k) => taskRow(TR.rx(k.x), t)).sort((a, b) => (a.start || a.end || '9999').localeCompare(b.start || b.end || '9999') || (a.end || '9999').localeCompare(b.end || '9999'));
346
+ for (const k of kids) emit(k, d + 1, sec);
347
+ };
319
348
  const stageRow = (s, i) => {
320
- const ts = (s.top || []).concat(...(s.groups || []).map((g) => g.rows || []));
349
+ // a child sits in its parent's stage: the stage holds its top-level tasks, and each counts as done when everything under it is done
350
+ const roots = (s.top || []).concat(...(s.groups || []).map((g) => g.rows || []), s.done || []).filter((x) => !TR.isChild(x)).map(TR.rx);
351
+ const ts = roots.filter((x) => !x.closed), sDone = roots.filter((x) => x.closed);
321
352
  const lz = looseUnder === s ? looseTs : [];
322
- const all = ts.concat(s.done || []);
323
- const nDone = (s.done || []).length, n = all.length;
353
+ const all = ts.concat(sDone);
354
+ const leaves = (x) => { const nd = TR.node(x); return nd && nd.kids.length ? WT.rollup(nd) : { n: 1, nDone: x.closed ? 1 : 0 }; };
355
+ const nDone = all.reduce((k, x) => k + leaves(x).nDone, 0), n = all.reduce((k, x) => k + leaves(x).n, 0);
356
+ const deep = all.concat(...all.map((x) => WT.under(TR.node(x))));
324
357
  const [ta, tb] = taskSpan(all);
325
358
  const rn = ran[i] || {};
326
359
  let a = '', b = '';
@@ -335,14 +368,14 @@ export function breakdownOf(r, v, o = {}) {
335
368
  const dl = b && (s.status === 'now' || s.status === 'next') ? dateLate(b, t, live || ts.some((x) => !x.closed)) : { text: b && s.status === 'done' ? '' : '', late: false };
336
369
  // a finished stage (every task done) folds until the PM opens it; the List opens every other stage with tasks
337
370
  const finished = n > 0 && nDone === n;
338
- const isOpen = holds(all, f) ? true : shut.has(s.key) ? false : open.has(s.key) ? true : !finished && (o.openAll || s.status === 'now');
371
+ const isOpen = holds(deep, f) ? true : shut.has(s.key) ? false : open.has(s.key) ? true : !finished && (o.openAll || s.status === 'now');
339
372
  // the count holds every task drawn under the stage: its own and the ones in no stage that sit under it (design check, 2026-11-19)
340
373
  const nAll = n + lz.length;
341
374
  const count = nAll ? (s.status === 'next' && !nDone ? plural(nAll, 'task', 'tasks') : nDone + ' of ' + nAll + ' done') : '';
342
375
  const has = n + lz.length > 0;
343
376
  // the bar's gap line and its ◇s (pm/cozy-bar.js stageBar): the stage's dated tasks, and its milestone tasks
344
377
  const gaps = a && b ? gapsOf(all.filter((x) => !x.wont).map((x) => [x.start || x.end, x.end || x.start]).filter(([p]) => p), a, b) : [];
345
- const marks = all.filter((x) => x.ms && !x.wont && x.end).map((x) => ({ uid: x.uid, title: x.title, end: x.end, done: !!x.closed, late: !!x.late && !x.closed }));
378
+ const marks = deep.filter((x) => x.ms && !x.wont && x.end).map((x) => ({ uid: x.uid, title: x.title, end: x.end, done: !!x.closed, late: !!x.late && !x.closed }));
346
379
  rows.push({ kind: 'stage', key: s.key, n: s.n, name: s.name, ms: !!s.ms, status: STATUS[s.status] || '', count, date: dl.text, late: dl.late, start: a, end: b, gaps, marks, tone: s.status === 'done' ? 'dn' : s.status === 'now' ? 'now' : '',
347
380
  done: s.status === 'done', open: (isOpen || lz.length > 0) && has, can: has, now: s.status === 'now', skip: s.status === 'skip' });
348
381
  if (!((isOpen || lz.length > 0) && has)) return;
@@ -356,7 +389,7 @@ export function breakdownOf(r, v, o = {}) {
356
389
  const keep = new Set(hot.concat(rest.slice(0, NEXT)));
357
390
  shown = all2.filter((x) => keep.has(x));
358
391
  }
359
- for (const x of shown) rows.push(lit({ ...x, sec: s.key }));
392
+ for (const x of shown) emit(x, 0, s.key);
360
393
  if (shown.length < all2.length) rows.push({ kind: 'more', key: s.key, n: all2.length - shown.length, label: plural(all2.length - shown.length, 'more task', 'more tasks') });
361
394
  for (const x of lz.slice().sort(urgent)) { rows.push(lit({ ...taskRow(x, t), sec: '', loose: s.key })); loose.push({ uid: x.uid, title: x.title, to: s.key, name: s.name }); }
362
395
  };
@@ -56,8 +56,11 @@ const GATE_SAY = {
56
56
  review: { done: 'reviewed', no: 'not reviewed' },
57
57
  approved: { done: 'PRD approved', no: 'PRD not approved' },
58
58
  };
59
- /** steps: the model's gateSteps (lib/initiative-premium.js: the ladder's spec rungs in order), else the engine checks. */
60
- export function gateOf(steps) {
59
+ /** steps: the model's gateSteps (lib/initiative-premium.js: the ladder's spec rungs in order), else the engine checks. scope: the model's
60
+ * scope (lib/kind-scope.js). A project's gate is "Plan before start" (the Project control in the Viewer, lib/kind-control.js), and its
61
+ * product documents are hidden, so it gets no PRD gate line here. */
62
+ export function gateOf(steps, scope) {
63
+ if (scope && scope.kind === 'project') return null;
61
64
  const parts = [];
62
65
  const list = (steps || []).filter((x) => x && GATE_SAY[x.k]);
63
66
  const keys = list.some((x) => !GATE_KEYS.has(x.k)) ? list.map((x) => x.k) : ['prototype', 'spec', 'contract'];
@@ -91,6 +94,7 @@ export function stageKey(name) {
91
94
  }
92
95
  const dayOf = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
93
96
  const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
97
+ const listOf = (a) => (a.length < 2 ? a.join('') : a.slice(0, -1).join(', ') + ' and ' + a[a.length - 1]);
94
98
 
95
99
  /** The card's model. M: the page model; now: ms. */
96
100
  /** The steps of the initiative's own workflow (D99): Product feature is the eight above; another workflow sends its stages on the row
@@ -102,7 +106,13 @@ function stepsOf(m) {
102
106
  }
103
107
  export function headModel(M, now = Date.now()) {
104
108
  const m = M || {}, head = m.head || {}, acts = m.acts || {}, ov = m.overview || {};
105
- const own = stepsOf(m), LIST = own || STEPS;
109
+ const own = stepsOf(m);
110
+ // the kind's scope (lib/kind-scope.js): a stage the kind hides is left off the eight, never the current one; Move to a stage still has it
111
+ const sc = !own && m.scope && m.scope.stages ? m.scope : null;
112
+ const key0 = own ? null : m.oneStage && m.oneStage.step ? m.oneStage.step : stageKey(head.stage || acts.stage);
113
+ const hide = new Set(sc ? (sc.hidden || []).filter((k) => k !== key0) : []);
114
+ const LIST = own || STEPS.filter((s) => !hide.has(s.key));
115
+ const hidden = STEPS.filter((s) => hide.has(s.key)).map((s) => s.label);
106
116
  // W1: on Product feature the stage is the one stage (lib/one-stage.js: the PM's word, Jira, the plan, the files); Shipped, On hold and
107
117
  // Cancelled stand on the step under them and name themselves
108
118
  const one = m.oneStage && m.oneStage.step ? m.oneStage : null;
@@ -155,7 +165,7 @@ export function headModel(M, now = Date.now()) {
155
165
  const done = items.filter((x) => x.kind === 'done'), rest = items.filter((x) => x.kind !== 'done');
156
166
  const life = acts.life || null;
157
167
  const turn = rest.some((x) => x.kind === 'you') ? 'you' : life === 'hold' || life === 'cancelled' || rest.some((x) => x.kind === 'risk') ? 'stalled'
158
- : rest.some((x) => x.kind === 'jira') || (!own && (key === 'build' || key === 'deliver')) ? 'jira' : 'agents';
168
+ : rest.some((x) => x.kind === 'jira') || (!own && ((key === 'build' && !(sc && sc.stages.build === 'owned')) || key === 'deliver')) ? 'jira' : 'agents'; // Full SDLC owns Build: the factory, not Jira
159
169
  const TURN = { you: 'Your turn', agents: 'Agents working', jira: 'Engineers on it', stalled: life === 'hold' ? 'On hold' : life === 'cancelled' ? 'Cancelled' : 'Stalled' };
160
170
  // time in the stage: a record that holds it (stageSince, usualDays) first, then the planned finish, then say it is not recorded
161
171
  let time = '', over = false, clock = null;
@@ -182,10 +192,11 @@ export function headModel(M, now = Date.now()) {
182
192
  const payoff = !cur ? '' : own ? (next ? next.label + ' starts.' : 'It is the last stage of ' + m.wf.name + '.') + anchor : PAYOFF[cur.key] + anchor;
183
193
  return {
184
194
  key, at, total: LIST.length, turn, turnLabel: TURN[turn],
185
- source: stageSource(m), gate: own ? null : gateOf(m.gateSteps || m.checks),
195
+ source: stageSource(m), gate: own ? null : gateOf(m.gateSteps || m.checks, sc), hidden,
186
196
  stage: cur ? (at + 1) + ' of ' + LIST.length + ' · ' + cur.label : head.stage ? head.stage + ' · not on the lifecycle' : 'No stage on record',
187
197
  prev: prev ? prev.label : '', cur: cur ? cur.label : head.stage || '', toReach: next ? next.label : cur ? 'Done' : '',
188
- ladderAria: cur ? 'Stage ' + (at + 1) + ' of ' + LIST.length + ': ' + cur.label + '.' + (next ? ' Next stage: ' + next.label + '.' : '') : 'No stage on the lifecycle.',
198
+ ladderAria: (cur ? 'Stage ' + (at + 1) + ' of ' + LIST.length + ': ' + cur.label + '.' + (next ? ' Next stage: ' + next.label + '.' : '') : 'No stage on the lifecycle.')
199
+ + (hidden.length ? ' ' + listOf(hidden) + (hidden.length === 1 ? ' is' : ' are') + ' hidden for ' + (sc.kind === 'project' ? 'project' : sc.kind) + ' work; Move to a stage still reaches ' + (hidden.length === 1 ? 'it' : 'them') + '.' : ''),
189
200
  // one bar a stage of its workflow; a stage PMOS judged it skips stays as a dashed bar (stage card D)
190
201
  steps: own ? m.wfStages.map((s) => ({ label: s.name, ms: !!s.milestone, cls: s.status === 'skipped' && !(m.wfStage && s.key === m.wfStage.key) ? 'skip' : s.status === 'done' ? 'done' : s.status === 'current' ? 'now' : '' }))
191
202
  : LIST.map((s, i) => ({ label: s.label, ms: !!s.ms, cls: at < 0 ? '' : i < at ? 'done' : i === at ? 'now' : '' })),
@@ -3,7 +3,7 @@
3
3
  * north-star, input or guardrail), what Claude drafted for this product (GET /api/metric-drafts, one ✓ to keep each), the key results grouped by
4
4
  * objective with the health budgets, then "Did it work?" (to judge and in their window; a drafted verdict with ✓ Keep and Undo, POST
5
5
  * /api/insights-records/verdict and /verdict-undo; decided ones fold). A key result with no reading is not a table row: it waits in "Waiting on a
6
- * source", one row per source (U3). ⋯ holds Reports and dashboards (the old Library, in a side panel) and Export CSV. The old ?tab=goals|outcomes|library links land on the matching section or panel; ?goal= and ?dash= still work.
6
+ * source", one row per source (U3). ⋯ holds Reports and dashboards (the old Library, in a side panel) and Export CSV. The old ?tab=goals|outcomes|library links land on the matching section or panel; ?goal= opens that goal. (No code reads ?dash=: a dashboard opens from the View chip.)
7
7
  * Before it, the premium Insights in the Agreed design's frames (initiative premium-agreed-design): AgInsGoals, AgInsPeriod,
8
8
  * AgInsNewGoal, AgInsNewDash, AgInsChart, AgInsOutcomes, AgInsVerdict, AgInsLibrary and AgInsPhone.
9
9
  *