create-pmos 0.422.0 → 0.424.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 (102) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/board-programs-test.js +28 -0
  8. package/workspace/briefing-premium-adddoc-test.js +1 -1
  9. package/workspace/briefing-premium-board-test.js +12 -10
  10. package/workspace/briefing-premium-initiative-test.js +30 -38
  11. package/workspace/briefing-premium-products-test.js +16 -3
  12. package/workspace/changelog.json +24 -0
  13. package/workspace/guide/briefing-premium.md +1 -1
  14. package/workspace/guide/claude-proposes.md +37 -0
  15. package/workspace/guide/home.md +9 -2
  16. package/workspace/guide/index.md +1 -0
  17. package/workspace/guide/programs.md +1 -0
  18. package/workspace/guide/workflows.md +5 -1
  19. package/workspace/home-pill-test.js +138 -0
  20. package/workspace/ini-workflow-test.js +4 -4
  21. package/workspace/lib/board-premium.js +3 -2
  22. package/workspace/lib/custom-docs.js +65 -3
  23. package/workspace/lib/engine/boards.js +25 -2
  24. package/workspace/lib/headless.js +14 -1
  25. package/workspace/lib/initiative-writer.js +63 -1
  26. package/workspace/lib/plan-items.js +36 -5
  27. package/workspace/lib/pmos-verbs.js +3 -0
  28. package/workspace/lib/programs.js +11 -3
  29. package/workspace/lib/proposal-runs.js +148 -0
  30. package/workspace/lib/proposals.js +370 -0
  31. package/workspace/lib/propose-cli.js +96 -0
  32. package/workspace/lib/route-modules.js +2 -0
  33. package/workspace/lib/routes-board-premium.js +33 -0
  34. package/workspace/lib/routes-boards.js +50 -10
  35. package/workspace/lib/routes-initiatives.js +12 -0
  36. package/workspace/lib/routes-proposals.js +325 -0
  37. package/workspace/lib/routes-task-links.js +336 -0
  38. package/workspace/lib/split-merge-suggest.js +162 -0
  39. package/workspace/lib/split-merge.js +379 -0
  40. package/workspace/lib/task-cli.js +58 -5
  41. package/workspace/lib/task-items.js +14 -2
  42. package/workspace/lib/task-links.js +422 -0
  43. package/workspace/package-lock.json +2 -2
  44. package/workspace/package.json +1 -1
  45. package/workspace/premium-board-actions-test.js +4 -4
  46. package/workspace/premium-core-doc-issue-test.js +2 -2
  47. package/workspace/premium-vw-backlog-test.js +3 -3
  48. package/workspace/premium-vw-item-test.js +3 -3
  49. package/workspace/premium-vw-jira-test.js +6 -6
  50. package/workspace/product-lane-test.js +165 -0
  51. package/workspace/program-panel-test.js +1 -1
  52. package/workspace/public/pm/bd-asks.js +3 -0
  53. package/workspace/public/pm/bd-ini-panel.js +16 -6
  54. package/workspace/public/pm/bd-prog.js +6 -1
  55. package/workspace/public/pm/bd-span.js +69 -15
  56. package/workspace/public/pm/bd-views.js +3 -2
  57. package/workspace/public/pm/cozy-board.css +10 -0
  58. package/workspace/public/pm/cozy-today.css +23 -0
  59. package/workspace/public/pm/cozy-viewer.js +14 -3
  60. package/workspace/public/pm/cozy-vw-shell.css +8 -0
  61. package/workspace/public/pm/home-app.js +45 -14
  62. package/workspace/public/pm/home-ini-model.js +0 -34
  63. package/workspace/public/pm/home-ini.js +72 -204
  64. package/workspace/public/pm/home-task.js +2 -1
  65. package/workspace/public/pm/home-today.js +66 -16
  66. package/workspace/public/pm/ini-groups.js +253 -0
  67. package/workspace/public/pm/ini-links.js +519 -0
  68. package/workspace/public/pm/ini-props.js +218 -0
  69. package/workspace/public/pm/ini-tasks.js +58 -22
  70. package/workspace/public/pm/ini-versions.js +14 -9
  71. package/workspace/public/pm/ini-view-model.js +93 -4
  72. package/workspace/public/pm/ini-view.css +306 -18
  73. package/workspace/public/pm/ini-view.js +161 -36
  74. package/workspace/public/pm/premium-board.js +54 -6
  75. package/workspace/public/pm/premium-vw-item.js +2 -1
  76. package/workspace/public/pm/split-merge.css +77 -0
  77. package/workspace/public/pm/split-merge.js +265 -0
  78. package/workspace/public/pm/stage-line.js +414 -0
  79. package/workspace/public/pm/task-card.css +13 -0
  80. package/workspace/public/pm/task-card.js +42 -5
  81. package/workspace/public/pm/wf-page.css +2 -0
  82. package/workspace/public/pm/wf-page.js +2 -0
  83. package/workspace/public/pm/wf-stage.js +2 -1
  84. package/workspace/server.js +52 -3
  85. package/workspace/skills/initiative-propose.skill +45 -0
  86. package/workspace/split-merge-ui-test.js +175 -0
  87. package/workspace/stage-card-test.js +13 -12
  88. package/workspace/task-card-test.js +3 -2
  89. package/workspace/task-delete-test.js +126 -0
  90. package/workspace/task-links-test.js +239 -0
  91. package/workspace/task-milestones-test.js +1 -1
  92. package/workspace/task-plans-test.js +6 -0
  93. package/workspace/task-views-test.js +1 -1
  94. package/workspace/test-lists/bd-ini-panel.json +8 -2
  95. package/workspace/test-lists/claude-proposes.json +5 -0
  96. package/workspace/test-lists/home-sessions-pill.json +6 -0
  97. package/workspace/test-lists/product-lane.json +6 -0
  98. package/workspace/test-lists/split-merge.json +15 -0
  99. package/workspace/test-lists/task-delete.json +5 -0
  100. package/workspace/test-lists/task-links.json +6 -0
  101. package/workspace/tk-tasks-test.js +186 -57
  102. package/workspace/workflows-setup-test.js +4 -3
@@ -34,6 +34,8 @@
34
34
  * check { state: 'todo'|'prog'|'done'|'wont'|'arch', label, title?, disabled? }: a task's check box in the tile's place (canvas XetX1Rest);
35
35
  * a press runs onPress('check', button). setCheck(id, check) changes it while the item is shown.
36
36
  * sub one quiet line under the title: what the item is when the title is its parent's name (a program's "Charter", canvas MsBCharter)
37
+ * chip { n, label, on(button) }: the blue ✦ with its count right after the title (what Claude proposes on an initiative, batch 12
38
+ * items 2, 3 and 4, canvas In development PiA0/TpA1). Hidden at zero. setChip(id, chip) changes it while the item is shown.
37
39
  * presses [{ act, label, icon, text?, solid? }]: the item's own presses before ⋯ (a program's charter icon, canvas MsB0Entry; the
38
40
  * charter's Save, MsBCharter). text draws the word beside the icon (not on a phone); solid is the one dark primary.
39
41
  * onPress(act, button) runs them. setPresses(id, list) changes them while the item is shown (Save shows only after a change).
@@ -125,10 +127,11 @@ export function headHtml(it) {
125
127
  ? `<button type="button" class="cz-vw-pri${x.text && !phone ? '' : ' i'}" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 15, 2.2)}${x.text && !phone ? `<span>${esc(x.text)}</span>` : ''}</button>`
126
128
  : `<button type="button" class="cz-vw-ib" data-cz-vw="press" data-cz-vw-p="${esc(x.act)}" aria-label="${esc(x.label)}" title="${esc(x.label)}">${svg(path(x.icon), 18)}</button>`).join('');
127
129
  const sub = o.sub ? `<p class="cz-vw-sub">${esc(o.sub)}</p>` : '';
130
+ const chip = o.chip && (o.chip.n > 0 || o.chip.looking) ? `<button type="button" class="cz-vw-chip${o.chip.looking ? ' live' : ''}" data-cz-vw="chip" aria-haspopup="dialog" aria-label="${esc(o.chip.label || 'Claude proposes ' + o.chip.n + '. Open')}" title="${esc(o.chip.label || 'Claude proposes')}">${svg(ICONS.spark, 13, 2)}${o.chip.n > 0 ? `<b>${esc(o.chip.n)}</b>` : ''}</button>` : '';
128
131
  return (o.canBack || phone ? ib('back', o.canBack ? 'Back' : 'Close the viewer', P.back) : '')
129
132
  + (o.check ? `<button type="button" class="cz-vw-tile cz-vw-chk s-${esc(o.check.state || 'todo')}" data-cz-vw="press" data-cz-vw-p="check" aria-label="${esc(o.check.label || 'Mark done')}" title="${esc(o.check.title || o.check.label || 'Mark done')}"${o.check.disabled ? ' disabled' : ''}><span class="bx"></span></button>`
130
133
  : `<span class="cz-vw-tile" aria-hidden="true">${svg(path(o.icon), 17)}</span>`)
131
- + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : esc(o.title || '')}</h3>${sub}</div>`)
134
+ + (o.renaming ? renHtml(o) : `<div class="cz-vw-t">${kind}<h3 class="cz-vw-title${chip ? ' has-chip' : ''}" id="czVwTitle">${o.rename ? `<button type="button" class="cz-vw-rn" data-cz-vw-rn aria-label="${esc('Rename ' + (o.title || ''))}" title="Rename">${esc(o.title || '')}</button>` : chip ? `<span class="cz-vw-tt">${esc(o.title || '')}</span>` : esc(o.title || '')}${chip}</h3>${sub}</div>`)
132
135
  + disc + own + add + more
133
136
  + (phone ? '' : ib('wide', o.isWide ? 'Back to the side' : 'Open wide', o.isWide ? P.side : P.wide, ` aria-pressed="${o.isWide ? 'true' : 'false'}"`))
134
137
  + (phone ? '' : `<button type="button" class="cz-vw-ib" data-cz-vw="close" aria-label="Close the viewer" title="Close">${svg(P.close, 18)}</button>`);
@@ -362,6 +365,7 @@ function mount() {
362
365
  else if (a === 'back') guarded(() => { if (V.stack.length) back(); else close(); }, b);
363
366
  else if (a === 'press') { if (V.cur && typeof V.cur.onPress === 'function') V.cur.onPress(b.dataset.czVwP, b); }
364
367
  else if (a === 'more') moreMenu(b);
368
+ else if (a === 'chip') { if (V.cur && V.cur.chip && typeof V.cur.chip.on === 'function') V.cur.chip.on(b); }
365
369
  else if (a === 'add') { if (V.cur && V.cur.add && typeof V.cur.add.on === 'function') V.cur.add.on(b); }
366
370
  else if (a === 'wide') wide();
367
371
  else if (a === 'discuss') discuss();
@@ -435,6 +439,13 @@ async function saveRename() {
435
439
  endRename(); emit();
436
440
  }
437
441
  /** The item's own presses change while it is shown (the charter's Save shows only after a change). */
442
+ export function setChip(id, chip) {
443
+ if (!V.cur || V.cur.id !== String(id)) return;
444
+ const was = V.cur.chip, on = !!(chip && (chip.n > 0 || chip.looking)), n = on ? chip.n || 0 : -1;
445
+ V.cur.chip = on ? chip : null;
446
+ if (V.cur.args) V.cur.args = { ...V.cur.args, chip: V.cur.chip };
447
+ if ((was ? was.n || 0 : -1) !== n || (was && chip && (was.label !== chip.label || !!was.looking !== !!chip.looking))) { if (!V.cur.renaming) redraw(); }
448
+ }
438
449
  export function setPresses(id, list) { if (V.cur && V.cur.id === String(id)) { V.cur.presses = list || null; if (V.cur.args) V.cur.args = { ...V.cur.args, presses: list || null }; if (!V.cur.renaming) redraw(); } }
439
450
  /** A task's check box changes while it is shown (a status move from the card, canvas XetX1Done). */
440
451
  export function setCheck(id, check) { if (V.cur && V.cur.id === String(id)) { V.cur.check = check || null; if (V.cur.args) V.cur.args = { ...V.cur.args, check: check || null }; if (!V.cur.renaming) redraw(); } }
@@ -457,7 +468,7 @@ export function open(it) {
457
468
  V.drill = false;
458
469
  const sameKind = V.cur && kindKey(V.cur.kind) === kindKey(o.kind);
459
470
  leave();
460
- V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
471
+ V.cur = { id: o.id == null ? null : String(o.id), kind: o.kind || '', title: o.title || '', icon: o.icon, url: o.url || '', full: !!o.full, onClose: o.onClose, more: o.more, discuss: o.discuss, discussHome: !!o.discussHome, add: o.add || null, sub: o.sub || '', check: o.check || null, presses: o.presses || null, chip: o.chip && (o.chip.n > 0 || o.chip.looking) ? o.chip : null, onPress: o.onPress, guard: o.guard, rename: o.rename && typeof o.rename.save === 'function' ? o.rename : null, args: o };
461
472
  el.setAttribute('aria-label', 'Viewer: ' + (o.kind || o.title || 'item'));
462
473
  redraw();
463
474
  const m = el.querySelector('.cz-vw-menu'); if (m) m.remove();
@@ -512,4 +523,4 @@ if (typeof window !== 'undefined' && typeof window.addEventListener === 'functio
512
523
  e.preventDefault(); e.stopImmediatePropagation(); guarded(close);
513
524
  }, true);
514
525
  }
515
- if (typeof window !== 'undefined') window.czViewer = { open, close, back, drill, setPresses, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
526
+ if (typeof window !== 'undefined') window.czViewer = { open, close, back, drill, setPresses, setChip, setCheck, isOpen, current, body, onChange, placeholder, retitle, czSummary, czSections, widthOf, setWidth, wide, railOn, ICONS };
@@ -152,3 +152,11 @@ body.cz-vw-rail [data-cz-vw-list] > :not(.cz-vw-railbar), body.cz-vw-rail #hmLis
152
152
  .czs-ib { width: 44px; }
153
153
  }
154
154
  @media (prefers-reduced-motion: reduce) { .cz-vw * { transition: none !important; } }
155
+
156
+ /* the blue ✦ after an initiative's title: what Claude proposes (batch 12 items 2, 3 and 4, canvas PiA0/TpA1); hidden at zero */
157
+ .cz-vw-title.has-chip { display: flex; align-items: center; gap: 6px; min-width: 0; }
158
+ .cz-vw-title.has-chip > .cz-vw-tt, .cz-vw-title.has-chip > .cz-vw-rn { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
159
+ .cz-vw-chip { display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 8px 0 6px; border-radius: 999px; border: 0; background: var(--cz-bluebg); color: var(--cz-blueink); font: inherit; font-size: 12px; font-weight: 800; flex: none; cursor: pointer; }
160
+ .cz-vw-chip:not(:has(b)) { padding: 0 6px; }
161
+ .cz-vw-chip:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
162
+ @media (max-width: 760px) { .cz-vw-chip { min-height: 32px; } }
@@ -36,10 +36,11 @@ import * as L from './home-list.js';
36
36
  import * as TD from './home-today.js';
37
37
  import * as YD from './home-day.js'; // Your day in the Viewer (XvAPhDay)
38
38
  import { canDictate, dictate } from './home-dictate.js';
39
- import { mountIni, iniList, iniOverview, iniPage } from './home-ini.js'; // the initiative's page, its stage move, Tasks and Core documents (premium-uncovered-features, HbC)
39
+ import { mountIni, iniList, iniOverview, iniPage, iniAddTask } from './home-ini.js'; // the initiative's page, its stage move, Tasks and Core documents (premium-uncovered-features, HbC)
40
40
  import * as MEN from './home-mentions.js'; // @Mentions, the permanent row at the top of Home and its Viewer (Viewer kit, XvANew)
41
41
  import { mountRecRow, clockOf as recClock } from './home-rec-row.js';
42
42
  import { mountSesName } from './home-ses-name.js'; // session names A: tap the session's name to rename it (canvas XmsNames)
43
+ import * as SM from './split-merge.js'; // split one initiative in two, or merge two: Claude suggests, the PM approves (batch 11 item 14)
43
44
  import * as PM from './prog-move.js'; // move an initiative out of its program, or to another (canvas LpA1More, LpA2Other, LpA4Phone)
44
45
  import * as PO from './prog-order.js'; // a program's order on Home: the grip, hold-then-drag on a phone, ✦ Claude's order from the dates (canvas RoAPhone)
45
46
  import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
@@ -93,7 +94,7 @@ const S = {
93
94
  doneOpen: false, stepsMore: false, sheet: false, rec: {}, pin: new Set(JSON.parse(store.get('pmos.home.pin') || '[]')),
94
95
  cardFold: store.get('pmos.home.cardfold') === '1', // the card's checklist folded to one line (AgInitSpec), kept in this browser
95
96
  // the one list (premium-uncovered-features): the filter, the picked product, which groups and initiatives are open, kept in this browser
96
- filter: 'today', product: store.get('pmos.home.product') || null, kidsOff: new Set(), rest: new Set(), cap: false, day: false,
97
+ filter: 'today', product: store.get('pmos.home.product') || null, kidsOff: new Set(), rest: new Set(), cap: false, day: false, ses: null,
97
98
  pg: (() => { try { return JSON.parse(store.get('pmos.home.pg') || '{}') || {}; } catch { return {}; } })(),
98
99
  eodHidden: store.get('pmos.home.eod') === L.dayOf(), phoneChat: false,
99
100
  };
@@ -241,7 +242,7 @@ function rowHtml(r, o = {}) {
241
242
  const kids = r.kids && S.kids.has(r.id) ? `<div class="hm-kids" role="group" aria-label="In ${esc(r.name)}">${r.kids.map((k) => rowHtml(k, { kid: true })).join('') || '<p class="hm-none">Nothing here now.</p>'}</div>` : '';
242
243
  return `<div class="hm-r${sel ? ' sel' : ''}${o.kid ? ' kid' : ''} st-${esc(r.state)}" data-id="${esc(r.id)}">`
243
244
  + `<button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"${sel ? ' aria-current="true"' : ''}><i class="hm-dot ${dotCls(r.state)}" aria-hidden="true"></i>${tileHtml(r)}`
244
- + `<span class="hm-rt"><b>${esc(r.name)}</b><em>${esc(r.hint || '')}</em></span></button>${chip}${end}</div>${kids}`;
245
+ + `<span class="hm-rt"><b>${r.kind === 'ini' ? SM.nameHtml(r.board, r.name) : esc(r.name)}</b><em>${esc(r.hint || '')}</em></span></button>${chip}${end}</div>${kids}`;
245
246
  }
246
247
  /* ── the one list (premium-uncovered-features: HmMyWork, HmProducts, HmDay, HmMic, HmReview, HmPhone) ── */
247
248
  const NOW = () => S.D.now || Date.now();
@@ -266,13 +267,10 @@ function homeListHtml() {
266
267
  const M = L.homeList(S.D, { now: NOW(), filter: S.filter, product: S.product && L.productsOf(S.D).some((p) => p.key === S.product) ? S.product : null });
267
268
  S.M = M;
268
269
  const R = L.reviewModel(S.D, NOW());
269
- // the first initiative where it is your turn shows what is under it, until the PM closes it
270
- const firstTurn = M.groups.filter((g) => g.kind === 'product' || g.kind === 'program').flatMap((g) => g.inis).find((x) => x.turn);
271
- const open = (id) => S.kids.has(id) || (!!firstTurn && firstTurn.id === id && !S.kidsOff.has(id));
272
270
  // a group is open until the PM folds it; another product starts folded; "Not in an initiative" starts folded on a phone (HvAC, HvACDesk)
273
271
  const pOpen = (g) => (g.key in S.pg ? !!S.pg[g.key] : g.kind === 'loose' ? !isPhone() : g.kind === 'program' || g.primary || M.products.length === 1 || (!!S.product && !!g.product && S.product === g.product.key));
274
272
  return TD.listHtml(M, todayModel(), {
275
- sel: S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null), selHead: S.head, isOpen: open, pOpen, restOpen: (k) => S.rest.has(k), cap: S.cap, pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
273
+ sel: S.sel || (S.ini && S.ini !== 'product' ? 'i:' + S.ini : null), selHead: S.head, ses: S.ses, pOpen, restOpen: (k) => S.rest.has(k), cap: S.cap, pin: S.pin, avHtml, ready: S.ready, err: S.D.err.length ? S.D.err[0] : '',
276
274
  product: S.product, review: R, mic: canDictate(), phone: isPhone(), day: S.day, top: S.ready ? RECROW.html() + MEN.rowHtml(S.D, { sel: S.sel }) : '',
277
275
  });
278
276
  }
@@ -322,7 +320,9 @@ function imRowOf(id) {
322
320
  return { id, key: 'board:' + id, title: M.title || id, lane: M.lane || null, track: { k, key: k >= 0 ? STEPS[k].key : null, label: stage },
323
321
  tasks: ((M.tasks && M.tasks.rows) || []).filter((x) => x.pmos && x.uid).map((x) => ({ uid: x.uid, title: x.title, status: x.state || 'To do', start: x.start || '', end: x.end || '', owner: x.owner || '' })) };
324
322
  }
325
- function iniRowOf(id) { return H.boardRows(S.D).find((r) => r.id === id) || (otherIni(id) || {}).row || null; }
323
+ // an archived one opens too, from its link: a merged initiative's page says where its work went (batch 11 item 14, XsmA7Closed)
324
+ const goneRowOf = (id) => ((((S.D.board || {}).initiatives || {}).gone || {}).archived || []).find((r) => r.id === id) || null;
325
+ function iniRowOf(id) { return H.boardRows(S.D).find((r) => r.id === id) || (otherIni(id) || {}).row || goneRowOf(id); }
326
326
  /** An initiative of another product Home reads (D.others): its row, and the workspace and board it is read from. Null for the board's own. */
327
327
  function otherIni(id) {
328
328
  if (!id || id === 'product' || H.boardRows(S.D).some((r) => r.id === id)) return null;
@@ -704,7 +704,8 @@ function overviewAsk(id) {
704
704
  }
705
705
  /** Turn into a program (P7), from the page's ⋯: a charter named after the initiative, which joins it; then the program opens here. */
706
706
  async function turnProgram(id) {
707
- const res = await pmPost('/api/programs/turn', { ws: boardWs() || null, initiative: id, title: iniTitle(id) }).catch(() => null);
707
+ // the initiative's own workspace, never the board's: its member line must sit beside it, or Home keeps it under its product (batch 11 item 18)
708
+ const res = await pmPost('/api/programs/turn', { ws: (otherIni(id) || {}).ws || boardWs() || null, initiative: id, title: iniTitle(id) }).catch(() => null);
708
709
  if (!res || !res.ok || !res.program) { toast((res && res.error) || 'The program was not made. Try again.'); return; }
709
710
  toast('Now a program · ' + iniTitle(id) + '.');
710
711
  await load(); goProgram(res.program.id);
@@ -719,6 +720,20 @@ function moveItems(id, openList) {
719
720
  stateOf: (p) => (((S.M && S.M.groups) || []).find((g) => g.kind === 'program' && g.program.id === p.id) || {}).st || null,
720
721
  reload: async () => { await load(); if (S.ini === id && VW.isOpen()) iniPage(); } });
721
722
  }
723
+ /** Split or merge (pm/split-merge.js; canvas XsmA1Menu, XsmA1Suggest): the context of one initiative on Home. Only this board's rows: a
724
+ * merge stays on one board. After the write Home reads again and opens the one the PM lands on. openList is home-ini.js's menu. */
725
+ function smCtx(id, openList) {
726
+ const row = iniRowOf(id) || { id }, B = S.D.board || {}, ws = row.ws || (B.board || {}).ws || '';
727
+ return { row, rows: () => H.boardRows(S.D), ws, board: row.boardId || (B.board || {}).id || '', product: H.productName(S.D), program: programOf(S.D.programs || [], ws, id), pmPost,
728
+ say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)), openList: openList || (() => {}),
729
+ reload: async () => { await load(); if (S.ini && VW.isOpen()) iniPage(); },
730
+ openIni: async (to) => { for (let i = 0; i < 8 && !iniRowOf(to); i++) { await new Promise((ok) => setTimeout(ok, 900)); await load(); } if (iniRowOf(to)) goIni(to); } };
731
+ }
732
+ function smItems(id, openList) {
733
+ const B = S.D.board || {};
734
+ if ((B.board || {}).self || otherIni(id)) return [];
735
+ return SM.menuItems(smCtx(id, openList));
736
+ }
722
737
  /** A program's conversation (?ask=program:<id>, a program task's row): Claude with the program as its scope. task names the open row. */
723
738
  function programTarget(id, task) {
724
739
  const pr = (S.D.programs || []).find((p) => p && p.id === id) || { id, title: (P.get('label') || '').slice(0, 80) || id };
@@ -883,14 +898,13 @@ function openReviewVw() {
883
898
  },
884
899
  }));
885
900
  }
886
- /* New → A task: the PM names the initiative first. An initiative's task is added in its Tasks view (home-ini.js, the box there);
901
+ /* New → A task: the PM names the initiative first. An initiative's task is added in its page's Tasks field, the cursor in it (XtaA4NewTask);
887
902
  * "Not in an initiative" opens the capture box in the list, on the PM's own list (POST /api/pm-items/add). The box is not on Home otherwise. */
888
903
  async function addTaskIn(id) {
889
904
  if (!id) { S.cap = true; drawList(); const i = $('#hmCap'); if (i) i.focus(); return; }
890
905
  await goIni(id);
891
906
  if (S.ini !== id) return;
892
- iniOverview('tasks');
893
- setTimeout(() => { const n = document.querySelector('#czViewer #ovTask'); if (n) n.focus(); }, 0);
907
+ iniAddTask();
894
908
  }
895
909
  async function capture(text) {
896
910
  const line = String(text || '').trim(); if (!line) return false;
@@ -1414,7 +1428,11 @@ $('#hmDesk').onclick = (e) => { if (S.sheet && e.target === $('#hmDesk')) sheet(
1414
1428
  $('#hmList').onclick = (e) => { // delegated: every press on the list is a <button>
1415
1429
  const b = e.target.closest('button'); if (!b) return;
1416
1430
  const d = b.dataset;
1417
- if (d.hmSel) { if (S.day) S.day = false; select(d.hmSel); return; }
1431
+ if (d.hmSes) { sesPill(d.hmSes === S.ses ? null : d.hmSes); return; } // an initiative's pill: what sits in it, under it (a sheet on a phone)
1432
+ if ('hmSesx' in d) { sesPill(null); return; }
1433
+ if (d.hmSesnew) { sesPill(null, false); newIn(d.hmSesnew); return; }
1434
+ if (S.ses && !b.closest('.hv-spp, .hv-sps')) sesPill(null, false); // a press anywhere else in the list closes it
1435
+ if (d.hmSel) { if (S.ses) sesPill(null, false); if (S.day) S.day = false; select(d.hmSel); return; }
1418
1436
  if ('hrMentions' in d) { if (S.day) S.day = false; S.sel = 'mentions'; drawList(); MEN.openMentions(menCtx()); return; }
1419
1437
  if ('hmDay' in d) { day(!S.day); return; }
1420
1438
  if ('hmDayx' in d) { day(false); return; }
@@ -1445,6 +1463,19 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
1445
1463
  if (d.hmRecopen) { openMeeting({ note: d.hmRecopen }); return; }
1446
1464
  };
1447
1465
  $('#hmList').addEventListener('keydown', (e) => { if (e.key === 'Escape' && e.target.id === 'hmCap' && S.cap) { e.stopPropagation(); S.cap = false; drawList(); } else if (e.key === 'Escape' && S.day) { e.stopPropagation(); day(false); } });
1466
+ /** Open (id) or close (null) the list behind an initiative's pill (batch 12 item 6). Closing gives the focus back to the pill, unless the
1467
+ * press that closed it goes somewhere else (back false). */
1468
+ function sesPill(id, back = true) {
1469
+ const was = S.ses;
1470
+ S.ses = id || null;
1471
+ drawList();
1472
+ const f = id ? $('#hmList .hv-spp .hm-rm, #hmList .hv-sps .hm-rm') : back && was ? $(`#hmList [data-hm-ses="${CSS.escape(was)}"]`) : null;
1473
+ if (f) f.focus();
1474
+ }
1475
+ // Escape closes it wherever the focus is (a redraw of the list can drop the focus to the page); a press outside the list closes it too
1476
+ window.addEventListener('keydown', (e) => { if (e.key === 'Escape' && S.ses && menuEl.hidden) { e.preventDefault(); e.stopPropagation(); sesPill(null); } }, true); // before the Viewer's own Escape
1477
+ // a press outside the list (the chat, the Viewer) closes an open pill list too
1478
+ document.addEventListener('pointerdown', (e) => { if (S.ses && !e.target.closest('#hmList')) sesPill(null, false); });
1448
1479
  $('#hmList').addEventListener('submit', async (e) => { // the capture box: Enter adds the task
1449
1480
  if (e.target.id !== 'hmCapF') return;
1450
1481
  e.preventDefault();
@@ -1513,7 +1544,7 @@ function cta() {
1513
1544
  mountIni({ S, VW, pmGet, pmPost, toast, rowOf: (id) => iniRowOf(id), renameIni: (id, pre) => iniRenameOf(id, pre), renameTask: (t) => taskRenameOf(t), load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT,
1514
1545
  // the initiative's page (HbCDesk): its card, its header and its ⋯
1515
1546
  openBoardTask: (t) => openBoardTask(t),
1516
- cardHtml: (id, o) => cardHtml(id, o), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), moveItems: (id, openList) => moveItems(id, openList), talk: () => talk(), view: (id) => iniViewOf(id), head: (id) => (S.H = headOf(id)), goProgram: (id) => goProgram(id),
1547
+ cardHtml: (id, o) => cardHtml(id, o), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), moveItems: (id, openList) => moveItems(id, openList), smItems: (id, openList) => smItems(id, openList), smPress: (id, act) => SM.press(smCtx(id), act), goIni: (id) => goIni(id), talk: () => talk(), view: (id) => iniViewOf(id), head: (id) => (S.H = headOf(id)), goProgram: (id) => goProgram(id),
1517
1548
  foldCard: () => { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); } });
1518
1549
  /* The program panel in Home's Viewer (HbCProg): Home's board model and programs; an initiative of it opens here, with ← back to the program.
1519
1550
  * Read on the first program press, never at start: the panel's modules load premium-shell.js, whose start reads ?session= for the old dialog. */
@@ -3,8 +3,6 @@
3
3
  *
4
4
  * moveModel(h, M, L, now) the stage move: the exit items of the stage, the next and previous stage, whether it can move by itself
5
5
  * taskRows(M, L, now) the initiative's tasks with the stage each belongs to, its owner and its date
6
- * taskGroups(rows, L, by) the Tasks card's groups: by stage, by the PM's own groups, by owner, by status, or none
7
- * listTasks(rows) the list column's Tasks group: the open tasks, soonest first, and the "All tasks" line
8
6
  * docRows(M) the core documents with their kind, phase and whether they need a look
9
7
  * docGroups(rows, stage, o) the Documents card's groups: by stage (now, earlier, Later), by kind, or none; o.filter narrows them
10
8
  * docChips(rows) the filter chips: All, Needs a look, then one per kind that is there
@@ -15,7 +13,6 @@ import { STEPS, stageKey } from './premium-initiative-head.js';
15
13
 
16
14
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
17
15
  const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
18
- const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
19
16
  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; };
20
17
  const midnight = (ms) => { const d = new Date(ms); return new Date(d.getFullYear(), d.getMonth(), d.getDate()); };
21
18
 
@@ -101,37 +98,6 @@ export function taskRows(M, L, now = Date.now(), o = {}) {
101
98
  owner: t.owner || '', av: initials(t.owner), due: due.text, late: due.late, start: t.start || '', end: t.end || '', group: (lay.of || {})[t.key] || '', src: t.src || '', blocked: !!t.blocked, canCheck: !!(t.pmos && t.uid) };
102
99
  });
103
100
  }
104
- // a task hangs under no workflow stage (Wawan, 2026-10-25), so there is no "by stage"; a layout that saved 'stage' reads as Your groups
105
- export const BY_LABEL = { epic: 'Epic', mine: 'Your groups', owner: 'Owner', status: 'Status', none: 'No groups' }; // epic: tk-model.js ticketGroups
106
- const STATUS = TASK_STATES;
107
- const shut = (r) => (r.closed != null ? r.closed : r.done);
108
- const order = (rows) => rows.filter((r) => !shut(r)).concat(rows.filter((r) => shut(r)));
109
- export function taskGroups(rows, L, by) {
110
- const lay = L || { names: [] }, b = BY_LABEL[by] ? by : 'mine';
111
- const g = (key, title, list, o = {}) => ({ key, title, rows: order(list), open: list.filter((r) => !shut(r)).length, ...o });
112
- if (b === 'none') return [g('all', null, rows)];
113
- if (b === 'mine') {
114
- const out = (lay.names || []).map((n) => g('g:' + n, n, rows.filter((r) => r.group === n), { mine: true }));
115
- const rest = rows.filter((r) => !r.group || !(lay.names || []).includes(r.group));
116
- if (rest.length || !out.length) out.push(g('g:', out.length ? 'Not in a group' : 'Not in a group yet', rest, { loose: true }));
117
- return out;
118
- }
119
- if (b === 'owner') {
120
- const names = [...new Set(rows.map((r) => r.owner || ''))].sort((x, y) => (!x) - (!y) || x.localeCompare(y));
121
- return names.map((n) => g('o:' + n, n || 'No owner', rows.filter((r) => (r.owner || '') === n)));
122
- }
123
- if (b === 'status') {
124
- const keys = STATUS.concat([...new Set(rows.map((r) => r.state || 'No status').filter((s) => !STATUS.includes(s)))]);
125
- return keys.map((s) => g('s:' + s, s, rows.filter((r) => (r.state || 'No status') === s))).filter((x) => x.rows.length);
126
- }
127
- return [g('all', null, rows)];
128
- }
129
- export function listTasks(rows) {
130
- const open = rows.filter((r) => !shut(r) && !r.req);
131
- const top = open.slice().sort((a, b) => (a.end || '9999').localeCompare(b.end || '9999')).slice(0, 3);
132
- const jira = rows.filter((r) => r.jira).length, reqs = rows.filter((r) => r.req).length;
133
- return { top, open: open.length, all: rows.length, sub: [plural(rows.length, 'task', 'tasks'), jira ? jira + ' from Jira' : '', reqs ? plural(reqs, 'PRD requirement', 'PRD requirements') : ''].filter(Boolean).join(' · ') };
134
- }
135
101
 
136
102
  /* ── documents ── */
137
103
  const KIND = { record: 'Record', problem: 'Spec', research: 'Research', rice: 'Plan doc', prd: 'PRD', rubric: 'Rubric', design: 'Design', stories: 'Spec', risks: 'Plan doc', launch: 'Plan doc', review: 'Review', update: 'Report', explainer: 'Notes', outcome: 'Report', brd: 'BRD' };