create-pmos 0.829.0 → 0.831.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 (69) hide show
  1. package/package.json +149 -49
  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-board-test.js +1 -1
  7. package/workspace/briefing-premium-insights-test.js +1 -1
  8. package/workspace/changelog.json +148 -22
  9. package/workspace/guide/agent-capabilities.md +1 -1
  10. package/workspace/guide/backlog.md +12 -1
  11. package/workspace/guide/cli.md +20 -1
  12. package/workspace/guide/home.md +1 -1
  13. package/workspace/guide/layout.md +3 -0
  14. package/workspace/lib/anchor-id.js +226 -0
  15. package/workspace/lib/artefacts-cli.js +25 -1
  16. package/workspace/lib/code-map.js +8 -2
  17. package/workspace/lib/factory-floor.js +16 -8
  18. package/workspace/lib/features.json +14 -13
  19. package/workspace/lib/initiative-cli.js +67 -2
  20. package/workspace/lib/lessons-draft.js +242 -0
  21. package/workspace/lib/people-cli.js +9 -1
  22. package/workspace/lib/people-prep.js +140 -0
  23. package/workspace/lib/pmos-verbs.js +2 -0
  24. package/workspace/lib/prefs-sync.js +1 -1
  25. package/workspace/lib/print-cli.js +49 -0
  26. package/workspace/lib/print-pdf.js +96 -0
  27. package/workspace/lib/review-reasons.js +121 -9
  28. package/workspace/lib/route-modules.js +1 -0
  29. package/workspace/lib/routes-c3-strategy.js +2 -1
  30. package/workspace/lib/routes-proposals.js +2 -2
  31. package/workspace/lib/routes-report-design.js +3 -1
  32. package/workspace/lib/routes-skill-map.js +39 -0
  33. package/workspace/lib/routes-strategy-card.js +13 -6
  34. package/workspace/lib/skill-map.js +199 -0
  35. package/workspace/lib/team-cli.js +20 -1
  36. package/workspace/package-lock.json +2 -2
  37. package/workspace/package.json +1 -1
  38. package/workspace/public/pm/action-keys.js +1 -0
  39. package/workspace/public/pm/ask-here-ctx.js +25 -1
  40. package/workspace/public/pm/ask-here.css +7 -0
  41. package/workspace/public/pm/ask-here.js +15 -2
  42. package/workspace/public/pm/bd-backlog.css +61 -0
  43. package/workspace/public/pm/bd-backlog.js +62 -8
  44. package/workspace/public/pm/bd-work.js +12 -1
  45. package/workspace/public/pm/card-fold.js +123 -0
  46. package/workspace/public/pm/code-map.js +15 -4
  47. package/workspace/public/pm/cozy-board.css +5 -1
  48. package/workspace/public/pm/cozy-ev.css +7 -0
  49. package/workspace/public/pm/cozy-nav.js +2 -0
  50. package/workspace/public/pm/cozy-pop-work.js +2 -0
  51. package/workspace/public/pm/cozy-search.js +2 -2
  52. package/workspace/public/pm/factory.js +199 -0
  53. package/workspace/public/pm/pop-cap.js +5 -3
  54. package/workspace/public/pm/premium-board.js +4 -0
  55. package/workspace/public/pm/premium-report-read.js +11 -2
  56. package/workspace/public/pm/print-pdf.js +191 -0
  57. package/workspace/public/pm/readonly.js +2 -0
  58. package/workspace/public/pm/review-reasons.js +19 -5
  59. package/workspace/public/pm/skill-map.js +57 -0
  60. package/workspace/public/premium-board.html +2 -0
  61. package/workspace/test-lists/anchor-id.json +9 -0
  62. package/workspace/test-lists/card-fold.json +9 -0
  63. package/workspace/test-lists/factory-page-ui.json +9 -0
  64. package/workspace/test-lists/lessons-on-close.json +9 -0
  65. package/workspace/test-lists/people-prep.json +9 -0
  66. package/workspace/test-lists/print-pdf.json +9 -0
  67. package/workspace/test-lists/skill-map.json +9 -0
  68. package/workspace/test-lists/surface-ask-card.json +9 -0
  69. package/workspace/test-lists/voice-files.json +9 -0
@@ -21,9 +21,10 @@ import * as WS from './work-select.js'; // the bulk move with one Undo, shared
21
21
  import * as IF from './inline-fields.js'; // a task's sprint and priority, set in the row (initiative inline-sprint-priority)
22
22
  import * as LE from './live-edit.js'; // a task's status or days show at once in the list, before it is read again; a failed save is put back
23
23
  import { noteUse } from './use-log.js'; // the sprint draft's presses, counted on this computer only (sprint-draft-capacity)
24
- import { pmGet } from './http.js';
24
+ import { pmGet } from './http.js'; // Work › Factory and Work › Dependencies read through the page's own GET helper
25
25
  import * as TWV from './team-waits.js'; // team-waits (A364): Work › Dependencies, the waits on other teams (GET /api/team-waits)
26
- import * as LV from './line-view.js';
26
+ import * as LV from './line-view.js'; // quiet-rows slice B: the Line tab, every initiative by station (GET /api/line)
27
+ import * as FV from './factory.js'; // Work › Factory (factory-page-ui): the stations and the work they make, from GET /api/factory
27
28
  import * as LB from './list-balance.js'; // the balance meter under the Backlog header (bet A448, board BalanceDS) // quiet-rows slice B: the Line tab, every initiative by station (GET /api/line)
28
29
  import * as BD from './bd-backlog-ds.js'; // the Backlog from the system's parts (WorkBacklogDS) // the sprint overview while "This sprint" is on (initiative sprint-overview)
29
30
 
@@ -70,15 +71,18 @@ export function tabOf() {
70
71
  if (q === 'backlog') return 'bk';
71
72
  if (q === 'sprint') return 'sp';
72
73
  if (q === 'line') return 'ln';
74
+ if (q === 'factory') return 'fx';
73
75
  if (q === 'deps') return 'dp';
74
76
  if (q === 'initiatives') return 'ini';
75
77
  const v = (get(KEY, {}) || {})[scopeKey()];
76
- return v === 'bk' || v === 'sp' || v === 'ln' || v === 'dp' ? v : 'ini';
78
+ return v === 'bk' || v === 'sp' || v === 'ln' || v === 'fx' || v === 'dp' ? v : 'ini';
77
79
  }
78
80
  /** Is a task tab (Backlog or This sprint) the view now? */
79
81
  export const on = () => tabOf() === 'bk' || tabOf() === 'sp';
80
82
  /** Is the Line tab the view now? (quiet-rows slice B) */
81
83
  export const lineOn = () => tabOf() === 'ln';
84
+ /** Is the Factory tab the view now? (factory-page-ui) */
85
+ export const factoryOn = () => tabOf() === 'fx';
82
86
  /** Is the Dependencies tab the view now? (team-waits) */
83
87
  export const depsOn = () => tabOf() === 'dp';
84
88
  function setOn(v) {
@@ -130,8 +134,9 @@ export async function load() {
130
134
  /** Work's three tab names: a desk says "This sprint" and no count; a phone says "Backlog 14" and "Sprint" (PhoneWorkDS, job 1540).
131
135
  * Zero is silence: no count when the Backlog is empty or not read yet. */
132
136
  // the Line (quiet-rows-line) is a five-column table for a desk; a phone keeps its three tabs (Today's dashed line is desk-only too)
137
+ // the Factory (factory-page-ui) sits beside Line, a desk's too: its tiles are a row of five
133
138
  // Dependencies (team-waits) is a desk tab as well: a phone keeps its three
134
- export const tabNames = (phone, n) => [['ini', 'Initiatives'], ...(phone ? [] : [['ln', 'Line']]), ['bk', 'Backlog' + (phone && n > 0 ? ` <span class="bk-swn">${Number(n)}</span>` : '')], ['sp', phone ? 'Sprint' : 'This sprint'], ...(phone ? [] : [['dp', 'Dependencies']])];
139
+ export const tabNames = (phone, n) => [['ini', 'Initiatives'], ...(phone ? [] : [['ln', 'Line'], ['fx', 'Factory']]), ['bk', 'Backlog' + (phone && n > 0 ? ` <span class="bk-swn">${Number(n)}</span>` : '')], ['sp', phone ? 'Sprint' : 'This sprint'], ...(phone ? [] : [['dp', 'Dependencies']])];
135
140
  const phoneNow = () => typeof matchMedia === 'function' && matchMedia('(max-width: 760px)').matches;
136
141
  function drawSwitch() {
137
142
  if (!sw) return;
@@ -142,13 +147,14 @@ function drawSwitch() {
142
147
  sw.innerHTML = tabNames(ph, ph && DATA ? backlogOf().length : 0).map(([k, n]) => tb(k, n)).join('');
143
148
  }
144
149
  function apply() {
145
- const bk = on(), ln = lineOn(), dp = depsOn();
150
+ const bk = on(), ln = lineOn(), fx = factoryOn(), dp = depsOn();
146
151
  if (tabOf() === 'sp') CHIPS.add('sprint');
147
152
  document.body.classList.toggle('sp-on', tabOf() === 'sp');
148
- document.body.classList.toggle('bk-on', bk || ln || dp);
149
- if (host) host.hidden = !(bk || ln || dp);
153
+ document.body.classList.toggle('bk-on', bk || ln || fx || dp);
154
+ if (host) host.hidden = !(bk || ln || fx || dp);
150
155
  drawSwitch();
151
156
  if (ln) { closeAll(); drawLine(); return; }
157
+ if (fx) { closeAll(); drawFactory(); return; }
152
158
  if (dp) { closeAll(); drawDeps(); return; }
153
159
  if (bk) { if (!DATA || scopeKey() !== lastScope) { lastScope = scopeKey(); host.innerHTML = '<p class="bk-wait">Reading the tasks…</p>'; load(); } else draw(); }
154
160
  else closeAll();
@@ -186,6 +192,54 @@ function linePress(e) {
186
192
  return false;
187
193
  }
188
194
 
195
+ /* ── the Factory tab (factory-page-ui, boards FxFloor and FxStation) ── the saved snapshot per product, from GET /api/factory ── */
196
+ const FX = { got: null, key: '', used: false, undone: new Set(), sheet: null, at: 0 };
197
+ async function readFactory() {
198
+ const ws = [...new Set(A.scope().map((s) => s.ws || ''))];
199
+ const got = await Promise.all(ws.map((w) => Promise.resolve(pmGet('/api/factory' + (w ? '?ws=' + encodeURIComponent(w) : ''))).catch(() => null)));
200
+ return got.filter((r) => r && r.ok).flatMap((r) => r.products || []);
201
+ }
202
+ const fxModel = () => FV.floorModel(FX.got || []);
203
+ function drawFactory() {
204
+ if (!host) return;
205
+ const k = scopeKey();
206
+ if (!FX.used) { FX.used = true; noteUse('factoryOpen'); console.info('[factory-page] factory tab opened'); }
207
+ // the snapshot changes only after a Driver run: a read a minute old is still the newest
208
+ if (!FX.got || FX.key !== k || Date.now() - FX.at > 60000) {
209
+ const first = !FX.got || FX.key !== k;
210
+ FX.key = k; FX.at = Date.now();
211
+ if (first) host.innerHTML = '<p class="bk-wait">Reading the factory…</p>';
212
+ readFactory().then((g) => { FX.got = g; if (factoryOn()) drawFactory(); });
213
+ if (first) return;
214
+ }
215
+ const goals = A && A.work ? FV.goalsModel(A.work()) : null;
216
+ host.innerHTML = FV.floorHtml(fxModel(), { goals });
217
+ }
218
+ function openStation(key) {
219
+ const st = key === 'check' ? fxModel().check : fxModel().stations.find((s) => s.key === key);
220
+ if (!st) return;
221
+ const body = document.createElement('div');
222
+ const fill = () => { body.innerHTML = FV.stationHtml(st, { undone: FX.undone }); };
223
+ fill();
224
+ body.addEventListener('click', async (e) => {
225
+ const b = e.target.closest('[data-fx-undo]'); if (!b || b.disabled) return;
226
+ b.disabled = true;
227
+ const r = await AP().post('/api/autonomy/undo', { ws: b.dataset.fxWs || undefined, ref: b.dataset.fxUndo }).catch(() => null);
228
+ if (r && r.ok) { FX.undone.add((b.dataset.fxWs || '') + '|' + b.dataset.fxUndo); fill(); if (AP().say) AP().say('Undone.'); }
229
+ else { b.disabled = false; if (AP().say) AP().say((r && r.error) || 'The change could not be undone. Try again in a moment.'); }
230
+ });
231
+ import('./primitives.js').then((P) => {
232
+ if (FX.sheet && FX.sheet.open) FX.sheet.close(); // one item, one panel (panel rule)
233
+ FX.sheet = P.sheet({ title: FV.NAMES[key], sub: FV.DOES[key], body: [body], attrs: { 'data-fx-sheet': key } });
234
+ });
235
+ }
236
+ /** A press in the Factory tab: a station's open button. true when it was one. */
237
+ function factoryPress(e) {
238
+ if (!factoryOn()) return false;
239
+ const b = e.target.closest('[data-fx-st]');
240
+ if (b) { openStation(b.dataset.fxSt); return true; }
241
+ return !!e.target.closest('.ff');
242
+ }
189
243
  /* ── the Dependencies tab (team-waits, board BatchCodeDS panel 14) ── the pick's waits on other teams, from GET /api/team-waits ── */
190
244
  const DP = { got: null, key: '', used: false, rows: [] };
191
245
  async function readDeps() {
@@ -831,7 +885,7 @@ export function sync(api) {
831
885
  sw.addEventListener('click', (e) => { const b = e.target.closest('[data-bksw]'); if (b) setOn(b.dataset.bksw); });
832
886
  host = document.createElement('div'); host.id = 'bkBody'; host.className = 'bk-host'; host.hidden = true;
833
887
  ib.insertAdjacentElement('afterend', host);
834
- host.addEventListener('click', (e) => { if (linePress(e) || depsPress(e)) return; press(e); });
888
+ host.addEventListener('click', (e) => { if (linePress(e) || factoryPress(e) || depsPress(e)) return; press(e); });
835
889
  host.addEventListener('change', (e) => { if (e.target.closest('[data-bkck]')) press(e); });
836
890
  host.addEventListener('keydown', (e) => { const c = e.target.closest('[data-bkcap]'); if (c && e.key === 'Enter') { e.preventDefault(); capture(c); } });
837
891
  dragWire();
@@ -18,6 +18,7 @@
18
18
  import { stageOfRow, stagesOfRow, wfOf, catOfRow, posOf } from './bd-wf.js';
19
19
  import { stageName as oneStageName } from './stage-chip.js';
20
20
  import { stateGlyph } from './state-glyph.js';
21
+ import * as PR from './print-pdf.js'; // Print or PDF (job #1911, A379)
21
22
 
22
23
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
23
24
  const SV = (d, n) => `<svg viewBox="0 0 24 24"${n ? ` width="${n}" height="${n}"` : ''} aria-hidden="true"><path d="${d}"/></svg>`;
@@ -339,7 +340,7 @@ export function ticksOf(W) {
339
340
  }
340
341
 
341
342
  /* ── markup ──────────────────────────────────────────────────────────────────────────────────────────────────── */
342
- const I = { hide: 'M13 6l6 6-6 6M6 6l6 6-6 6', show: 'M11 6l-6 6 6 6M18 6l-6 6 6 6', chev: 'M7 10l5 5 5-5', sort: 'M12 5v14M6 13l6 6 6-6', x: 'M6 6l12 12M18 6L6 18',
343
+ const I = { print: 'M7 9V4h10v5M7 17H5a1 1 0 0 1-1-1v-6a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v6a1 1 0 0 1-1 1h-2M7 14h10v6H7z', hide: 'M13 6l6 6-6 6M6 6l6 6-6 6', show: 'M11 6l-6 6 6 6M18 6l-6 6 6 6', chev: 'M7 10l5 5 5-5', sort: 'M12 5v14M6 13l6 6 6-6', x: 'M6 6l12 12M18 6L6 18',
343
344
  back: 'M15 6l-6 6 6 6', on: 'M10 8l4 4-4 4', today: 'M12 3v18M7 8l-4 4 4 4M17 8l4 4-4 4', tune: 'M4 7h10M18 7h2M4 17h4M12 17h8M14 5v4M8 15v4' };
344
345
 
345
346
  function cellHtml(r, k, o) {
@@ -415,6 +416,7 @@ export function listHtml(rows, o = {}) {
415
416
  const nav = (k, label, d) => `<button type="button" class="pm-btn" data-wknav="${k}" aria-label="${label}" title="${label}">${SV(d, 16)}</button>`;
416
417
  const head = `<div class="head"><h2 class="pm-h">Initiatives</h2><span class="sp"></span>`
417
418
  + (tl ? `<div class="pm-tabs" role="tablist" aria-label="Scale of the timeline">${scale}</div>${nav('back', 'Earlier', I.back)}${nav('today', 'Go to today', I.today)}${nav('on', 'Later', I.on)}` : '')
419
+ + `<button type="button" class="pm-btn" data-wkprint aria-label="Print or PDF" title="Print or PDF">${SV(I.print, 16)}</button>` // job #1911 (A379): the roadmap list in the one print layout
418
420
  + `<button type="button" class="pm-btn" data-wkmenu aria-haspopup="dialog" aria-label="Choose columns, sort and filter" title="Choose columns, sort and filter">${SV(I.tune, 16)}${filterCount() ? `<i class="wk-fc" aria-hidden="true">${filterCount()}</i>` : ''}</button></div>`;
419
421
  const ncol = 1 + keys.length + (tl ? 1 : 0);
420
422
  let h = `<section class="pm-block wk-blk" aria-label="Initiatives">${head}${o.above || ''}${showingHtml(every.length - rows.length)}`
@@ -499,6 +501,13 @@ export function menuHtml(o = {}) {
499
501
  + `<div class="wk-ft"><span>PMOS remembers this</span>${differs ? '<button type="button" class="wk-rs" data-wkreset>Reset</button>' : ''}</div></div>`;
500
502
  }
501
503
 
504
+ /** Print or PDF on Work's list (job #1911, A379): the list as shown, in the one print layout (pm/print-pdf.js). */
505
+ function printList(btn) {
506
+ const sec = btn && btn.closest ? btn.closest('.wk-blk') : null;
507
+ let ws = ''; try { ws = new URLSearchParams(location.search).get('ws') || ''; } catch { ws = ''; }
508
+ if (sec) PR.printPage(sec, { title: 'Roadmap', ws });
509
+ }
510
+
502
511
  /** What a press in the list or the menu means, or null when it is not Work's own. → { kind, ... } */
503
512
  export function pressOf(t) {
504
513
  const q = (s) => t.closest && t.closest(s);
@@ -513,6 +522,7 @@ export function pressOf(t) {
513
522
  if ((b = q('[data-wkspick]'))) return { kind: 'span', span: b.dataset.wkspick };
514
523
  if (q('[data-wkspan]')) return { kind: 'spanmenu' };
515
524
  if ((b = q('[data-wknav]'))) return { kind: 'nav', dir: b.dataset.wknav };
525
+ if (q('[data-wkprint]')) return { kind: 'print', el: q('[data-wkprint]') };
516
526
  if (q('[data-wkmenu]')) return { kind: 'menu', el: q('[data-wkmenu]') };
517
527
  if ((b = q('[data-wktl]'))) return { kind: 'timeline', on: b.dataset.wktl === 'on' };
518
528
  if ((b = q('[data-wkstage]'))) return { kind: 'stage', key: b.dataset.wkstage, el: b };
@@ -543,6 +553,7 @@ export function apply(p) {
543
553
  else if (p.kind === 'closed') SHUT = !SHUT;
544
554
  else if (p.kind === 'card') CARD = CARD === p.key ? null : p.key;
545
555
  else if (p.kind === 'nav') { if (p.dir === 'today') toToday(); else step(p.dir === 'back' ? -1 : 1, LAST ? LAST.rows : []); }
556
+ else if (p.kind === 'print') { printList(p.el); return false; }
546
557
  else if (p.kind === 'menu') return false;
547
558
  else if (p.kind === 'inside') return false;
548
559
  else return false;
@@ -0,0 +1,123 @@
1
+ /* pm/card-fold.js — the big summary cards fold away (initiative card-fold).
2
+ *
3
+ * One shared fold for every big summary card: Strategy, Where it stands and North Star, on every page. An icon-only button at the
4
+ * right of the card's head folds the card to its head line; Where it stands keeps its first sentence on that line. A ✦ suggestion
5
+ * inside a folded card stays visible as a small "✦ 1" beside the head, which opens the card again. Zero suggestions: no mark.
6
+ * The fold is kept per page and per card in localStorage under 'pmos.fold:<page>:<card>'. That prefix is on the view-prefs allowlist
7
+ * (lib/prefs-sync.js), so the fold follows the person to their other browsers. No card's own markup or content changes: the module
8
+ * finds the cards by their aria-label and adds the button, so a card that redraws itself gets its button back on the next frame.
9
+ * A card that is being edited (it holds an input or a text box) never folds, so the PM can always see what they type.
10
+ *
11
+ * startCardFold(doc) called once by the menu (pm/cozy-nav.js mountNav), which every page mounts; a second call does nothing
12
+ * cardOf(label) PURE: the card's key for an aria-label, or '' when the card does not fold
13
+ * foldKey(page, card) PURE: the storage key · pageOf(path) PURE: '/premium-board.html' → 'premium-board'
14
+ * sugCount(section) the ✦ suggestions inside a card · enhance(section, doc) add the fold to one card · sweep(doc) every card
15
+ * btnHtml(card, folded, n, title) PURE: the head's fold controls */
16
+
17
+ export const CARDS = Object.freeze({ 'Strategy': 'strategy', 'Where it stands': 'stands', 'North Star': 'northstar' });
18
+ export const PREFIX = 'pmos.fold:';
19
+ const SEL = 'section.pm-block[aria-label]';
20
+ const SUG = '.pm-sug';
21
+ const EDITING = 'input, textarea, select, [contenteditable="true"], [contenteditable=""]';
22
+ const CHEV_UP = 'M7 14l5-5 5 5';
23
+ const CHEV_DOWN = 'M7 10l5 5 5-5';
24
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
25
+ const SV = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
26
+
27
+ export const cardOf = (label) => CARDS[String(label || '').trim()] || '';
28
+ export const pageOf = (path) => (String(path || '').split('/').pop() || 'index').replace(/\.html?$/i, '') || 'index';
29
+ export const foldKey = (page, card) => PREFIX + page + ':' + card;
30
+
31
+ /** PURE: the fold button, and when folded with suggestions inside, the small ✦ count that opens the card. */
32
+ export function btnHtml(card, folded, n, title) {
33
+ const t = String(title || card);
34
+ const mark = folded && n > 0
35
+ ? `<button type="button" class="pm-fold-sug" data-card-fold-sug="${esc(card)}" aria-label="${esc(n + (n === 1 ? ' suggestion' : ' suggestions') + ' from PMOS in ' + t + '. Open')}" title="${esc(n === 1 ? '1 suggestion waits inside' : n + ' suggestions wait inside')}">✦ ${n}</button>`
36
+ : '';
37
+ const label = (folded ? 'Open ' : 'Fold ') + t;
38
+ return mark + `<button type="button" class="pm-btn pm-fold-btn" data-card-fold="${esc(card)}" aria-expanded="${folded ? 'false' : 'true'}" aria-label="${esc(label)}" title="${esc(label)}">${SV(folded ? CHEV_DOWN : CHEV_UP)}</button>`;
39
+ }
40
+
41
+ /** The ✦ suggestions inside a card. */
42
+ export const sugCount = (sec) => (sec && sec.querySelectorAll ? sec.querySelectorAll(SUG).length : 0);
43
+
44
+ const store = (doc) => { try { return doc.defaultView.localStorage; } catch { return null; } };
45
+ const isFolded = (doc, key) => { const ls = store(doc); try { return !!ls && ls.getItem(key) === '1'; } catch { return false; } };
46
+ function setFolded(doc, key, on) {
47
+ const ls = store(doc); if (!ls) return;
48
+ try { if (on) ls.setItem(key, '1'); else ls.removeItem(key); } catch { /* storage blocked: the fold lasts for this page only */ }
49
+ }
50
+
51
+ /** The card's head: its .head row, else its first heading. */
52
+ function headOf(sec) {
53
+ for (const el of Array.from(sec.children || [])) {
54
+ if (el.classList && el.classList.contains('head')) return el;
55
+ if (/^H[1-6]$/.test(el.tagName || '')) return el;
56
+ }
57
+ return null;
58
+ }
59
+
60
+ /** Add the fold to one card, or bring its state up to date. Returns true when the card can fold. */
61
+ export function enhance(sec, doc) {
62
+ const card = cardOf(sec.getAttribute('aria-label'));
63
+ if (!card || sec.classList.contains('flat')) return false; // a one-line card (not written yet, drafting) has nothing to fold
64
+ const head = headOf(sec);
65
+ if (!head) return false;
66
+ const key = foldKey(pageOf(doc.defaultView && doc.defaultView.location ? doc.defaultView.location.pathname : ''), card);
67
+ const editing = !!sec.querySelector(EDITING);
68
+ const folded = !editing && isFolded(doc, key);
69
+ const n = folded ? sugCount(sec) : 0;
70
+ const sig = (folded ? 'f' : 'o') + n + (editing ? 'e' : '');
71
+ if (sec.dataset.cardFold === sig && head.querySelector('[data-card-fold]')) return true;
72
+ sec.dataset.cardFold = sig;
73
+ head.setAttribute('data-fold-head', '');
74
+ head.querySelectorAll('[data-card-fold], [data-card-fold-sug]').forEach((b) => b.remove());
75
+ if (!editing) {
76
+ const box = doc.createElement('span');
77
+ box.className = 'pm-fold-ctl';
78
+ box.innerHTML = btnHtml(card, folded, n, sec.getAttribute('aria-label'));
79
+ head.appendChild(box);
80
+ }
81
+ // Where it stands keeps its first sentence line on the folded head
82
+ const one = card === 'stands' ? Array.from(sec.children).find((el) => el !== head && el.tagName === 'P') : null;
83
+ sec.querySelectorAll(':scope > [data-fold-one]').forEach((el) => { if (el !== one) el.removeAttribute('data-fold-one'); });
84
+ if (one) one.setAttribute('data-fold-one', '');
85
+ sec.classList.toggle('pm-folded', folded);
86
+ return true;
87
+ }
88
+
89
+ /** Every card on the page. */
90
+ export function sweep(doc) {
91
+ let n = 0;
92
+ doc.querySelectorAll(SEL).forEach((sec) => { if (enhance(sec, doc)) n++; });
93
+ return n;
94
+ }
95
+
96
+ let started = false;
97
+ export function startCardFold(doc = typeof document !== 'undefined' ? document : null) {
98
+ if (started || !doc || !doc.body) return false;
99
+ started = true;
100
+ const win = doc.defaultView;
101
+ let queued = false;
102
+ const later = () => {
103
+ if (queued) return; queued = true;
104
+ const run = () => { queued = false; try { sweep(doc); } catch (e) { try { console.info('[card-fold] ' + e.message); } catch { /* no console */ } } };
105
+ if (win && win.requestAnimationFrame) win.requestAnimationFrame(run); else setTimeout(run, 16);
106
+ };
107
+ if (win) doc.defaultView.addEventListener('click', (e) => { // capture on the window, as focus mode does
108
+ const b = e.target && e.target.closest && e.target.closest('[data-card-fold], [data-card-fold-sug]');
109
+ if (!b) return;
110
+ const sec = b.closest(SEL);
111
+ if (!sec) return;
112
+ e.preventDefault();
113
+ const card = cardOf(sec.getAttribute('aria-label'));
114
+ const key = foldKey(pageOf(win && win.location ? win.location.pathname : ''), card);
115
+ setFolded(doc, key, b.hasAttribute('data-card-fold') ? !sec.classList.contains('pm-folded') : false);
116
+ enhance(sec, doc);
117
+ const again = sec.querySelector('[data-card-fold]');
118
+ if (again && again.focus) again.focus();
119
+ }, true);
120
+ if (win && win.MutationObserver) new win.MutationObserver(later).observe(doc.body, { childList: true, subtree: true });
121
+ later();
122
+ return true;
123
+ }
@@ -4,6 +4,7 @@
4
4
  * mount(host, { ws, single }) → draws the map into `host`; a Work page that shows several products at once shows none
5
5
  * mapHtml(map) → the markup (pure, so the test reads it); '' when there is nothing to show
6
6
  *
7
+ * Closed by default: one line ("Code · 6 parts · 1 tinted") until the PM opens it.
7
8
  * Built from the board's parts: a pm-block with its head, the part boxes of panel 13 (card ground, small radius, a 1px line; cozy-board.css .bd-cm-) in a grid,
8
9
  * and a pm-meta foot. Each box: the part's name, what it is (the PM's own words from `pmos code describe` when given), how it is tested and
9
10
  * who changed it last. A risky part (no tests, or many recent fixes) is tinted with the alert colour and says why; the rest are plain.
@@ -34,12 +35,21 @@ export function boxHtml(p) {
34
35
  return `<div class="bd-cm-part" role="listitem"${risk} title="${esc(p.dir || p.name)}"><b>${esc(p.name)}</b>${lines}</div>`;
35
36
  }
36
37
 
37
- export function mapHtml(map) {
38
+ /** The one line the closed card shows: how many parts, and how many are tinted. */
39
+ export function sumOf(map) {
40
+ const n = map.parts.length + (map.more || 0);
41
+ const r = map.parts.filter((p) => p.risky).length;
42
+ return `${n} part${n === 1 ? '' : 's'}${r ? ` · ${r} tinted` : ''}`;
43
+ }
44
+
45
+ /** Closed by default (the PM, 2026-11-25: "should be hidden by default"): a <details> whose summary is the head and one line. */
46
+ export function mapHtml(map, { open = false } = {}) {
38
47
  if (!map || !Array.isArray(map.parts) || !map.parts.length) return '';
39
48
  const more = map.more ? `<span class="pm-meta">and ${map.more} smaller part${map.more === 1 ? '' : 's'}</span>` : '';
40
- return `<section class="pm-block bd-cm" aria-label="Code"><div class="head">${SV(CODE)}<h3 class="pm-h-sm">Code</h3></div>`
49
+ return `<details class="pm-block bd-cm" aria-label="Code"${open ? ' open' : ''}><summary class="head">${SV(CODE)}<h3 class="pm-h-sm">Code</h3><span class="pm-meta bd-cm-sum">${esc(sumOf(map))}</span></summary>`
50
+ + '<p class="pm-meta bd-cm-say">The main parts of this product\'s code, read from its repository: what each is, how it is tested, who changed it last. Tinted: no tests, or mostly fixes lately.</p>'
41
51
  + `<div role="list" class="bd-cm-grid">${map.parts.map(boxHtml).join('')}</div>`
42
- + `<div class="pm-row bd-cm-foot">${more}<span class="pm-meta">Read from the repo on ${esc(dayOf(map.at))}</span></div></section>`;
52
+ + `<div class="pm-row bd-cm-foot">${more}<span class="pm-meta">Read from the repo on ${esc(dayOf(map.at))}</span></div></details>`;
43
53
  }
44
54
 
45
55
  /** Draw the map into `host`. While PMOS draws it for the first time, read again now and then (at most ~2 minutes). */
@@ -51,7 +61,8 @@ export async function mount(host, opts = {}) {
51
61
  let r = null;
52
62
  try { r = await (await fetch('/api/code-map' + (ws ? '?ws=' + encodeURIComponent(ws) : ''), { credentials: 'same-origin' })).json(); } catch { r = null; }
53
63
  if (!r || !r.ok) { host.hidden = true; return; } // an extra: a failed read leaves Work as it was
54
- const html = mapHtml(r.map);
64
+ const was = host.querySelector && host.querySelector('details.bd-cm');
65
+ const html = mapHtml(r.map, { open: !!(was && was.open) }); // a redraw keeps the card as the PM left it
55
66
  host.hidden = !html;
56
67
  if (host.innerHTML !== html) host.innerHTML = html;
57
68
  const tries = Number(host.dataset.polls || 0);
@@ -1628,10 +1628,14 @@ html.ro body.wk-on .bd-hd { display: none; } /* find and tune moved to the top
1628
1628
  .bd-bc .s.ln { color: var(--cz-ink2); }
1629
1629
  .bd-lrow .s.ln { color: var(--cz-ink2); white-space: normal; }
1630
1630
  /* the product's code map (pm/code-map.js, idea A176, board BatchCodeDS panel 13): one box per main part; a risky part takes the alert tint */
1631
- .bd-cm .head h3 { flex: 1; }
1632
1631
  .bd-cm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-8); }
1633
1632
  .bd-cm-part { min-width: 0; background: var(--card); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--line); padding: 6px 8px; font: var(--fw-regular) var(--fs-meta)/var(--lh-meta) var(--cz-sans); }
1634
1633
  .bd-cm-part[data-risky] { background: color-mix(in srgb, var(--alert) 12%, var(--card)); }
1635
1634
  .bd-cm-part b { display: block; font-weight: var(--fw-strong); }
1636
1635
  .bd-cm-l { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1637
1636
  .bd-cm-foot { gap: var(--space-8); margin-top: var(--space-8); }
1637
+ .bd-cm-say { margin: var(--space-8) 0; }
1638
+ .bd-cm > summary { cursor: pointer; list-style: none; }
1639
+ .bd-cm > summary::-webkit-details-marker { display: none; }
1640
+ .bd-cm > summary h3 { flex: 0 1 auto; }
1641
+ .bd-cm > summary .bd-cm-sum { flex: 1; }
@@ -570,3 +570,10 @@ body.pm-focus .cz-pop-card { inset: 0; border-radius: 0; }
570
570
  ::highlight(pm-term) { text-decoration: underline dotted; text-underline-offset: var(--space-4); } /* the text's own colour: --muted means another thing inside .c3 */
571
571
  .gl-tip.pm-ds { position: fixed; z-index: 90; max-width: min(calc(var(--space-64) * 5), calc(100vw - var(--space-16))); background: var(--card); color: var(--ink); border-radius: var(--radius-md); box-shadow: var(--lift); padding: var(--space-8) var(--space-12); font-size: var(--fs-meta); line-height: var(--lh-meta); left: var(--fr-gl-x, 0); top: var(--fr-gl-y, 0); pointer-events: auto; }
572
572
  .gl-tip.pm-ds .gl-m { margin: var(--space-4) 0 0; }
573
+
574
+ /* ── card fold (pm/card-fold.js, initiative card-fold): Strategy, Where it stands and North Star fold to their head line. The fold button
575
+ * sits at the right of the head; a folded card keeps a small ✦ count when a suggestion waits inside. Tokens only. ── */
576
+ .pm-fold-ctl { display: inline-flex; align-items: center; gap: var(--space-8); margin-left: auto; flex: none; }
577
+ .pm-folded > :not([data-fold-head]):not([data-fold-one]) { display: none !important; }
578
+ .pm-folded > [data-fold-one] { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0; color: var(--muted); }
579
+ .pm-fold-sug { border: 0; cursor: pointer; display: inline-flex; align-items: center; padding: var(--space-4) var(--space-8); border-radius: var(--radius-pill); background: var(--blue-tint); color: var(--blue); font: inherit; font-size: var(--fs-badge); font-weight: var(--fw-strong); }
@@ -49,6 +49,7 @@ import { startUseLog } from './use-log.js'; // bet A466: every page mounts the
49
49
  import { startActionKeys } from './action-keys.js'; // bet A477: y o s p z act on the item under the pointer, ? lists the keys
50
50
  import { startGlossary } from './glossary.js'; // bet A386: a product's own words show their meaning on hover (a long press on a phone)
51
51
  import { startFocusMode } from './focus-mode.js'; // bet A335: f shows only the item under the pointer and its chat; f again puts the page back
52
+ import { startCardFold } from './card-fold.js'; // card-fold: Strategy, Where it stands and North Star fold to one line, kept per person
52
53
 
53
54
  /* The six places (slice 1). A place shows once it has an href: Events, Library and Routine get theirs when their slice ships. Until then
54
55
  * Today is today.html (slice 5; Home before it), Work is the Board and Goals is premium-goals.html (slice 9; Intelligence before it); the keys stay the pages' own (home, board, insights). */
@@ -209,6 +210,7 @@ export function mountNav(here, doc = document, opts = {}) {
209
210
  askHere(doc, () => import('./ask-here.js')); // ask-anywhere: a right-click (a phone: a long-press) asks PMOS about what was pressed
210
211
  startActionKeys(doc);
211
212
  startFocusMode(doc);
213
+ startCardFold(doc);
212
214
  startGlossary(doc);
213
215
  const fab = w.querySelector('#czFab'), menu = w.querySelector('#czMenu'), scrim = w.querySelector('#czScrim');
214
216
  const draw = () => {
@@ -37,6 +37,7 @@ import * as IF from './inline-fields.js'; // a task's sprint and priority, set
37
37
  import * as SD from './star-draft.js'; // a ✦ draft runs as a PMOS background job and lands on its line (star-buttons-act-directly A7)
38
38
  import * as CAP from './pop-cap.js'; // five actions at most: Ask PMOS and the toolbar's four, the rest under ⋯ (popup-cap, idea A498)
39
39
  import { noteUse } from './use-log.js';
40
+ import * as PR from './print-pdf.js'; // Print or PDF under ⋯ (job #1911, A379)
40
41
  import * as SMAP from './stakeholder-map.js'; // the People block: who decides, must agree, needs to know (stakeholder-map, A371)
41
42
  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)
42
43
 
@@ -1381,6 +1382,7 @@ function capItems(body, hh) {
1381
1382
  if (act === 'big') return big(c, x, h);
1382
1383
  if (act === 'src') return srcMenu(a, c, x, h);
1383
1384
  if (act === 'parts') { if (hh && hh.allParts) hh.allParts(); }
1385
+ if (act === 'print') return PR.printPage(body.querySelector('.pw'), { title: (c.v && c.v.title) || (c.r && (c.r.title || c.r.name)) || '', ws: atOf(h, x).ws }); // job #1911: Print or PDF
1384
1386
  };
1385
1387
  const out = [];
1386
1388
  for (const g of G) { out.push({ head: g.group }); for (const it of g.items) out.push({ label: it.label, icon: it.icon, on: (a) => { run(it.act, a); } }); }
@@ -40,7 +40,7 @@ function mount() {
40
40
  const d = document.createElement('div');
41
41
  d.innerHTML = '<div class="ev-sp-scrim" id="evSpScrim" hidden></div>'
42
42
  + '<div class="ev-sp" id="evSearch" role="dialog" aria-modal="true" aria-label="Search" hidden>'
43
- + `<div class="ev-sp-in">${svg(ICON.search, 20)}<label for="evQ" class="ev-vh">Search PMOS</label><input id="evQ" type="text" autocomplete="off" spellcheck="false" placeholder="Search initiatives, documents, slides, reports, artifacts and meetings" role="combobox" aria-expanded="true" aria-controls="evRes" aria-autocomplete="list"><span class="ev-kbd">Esc</span><button type="button" class="ev-ib x" data-ev="close" aria-label="Close search">${svg(ICON.close, 18)}</button></div>`
43
+ + `<div class="ev-sp-in">${svg(ICON.search, 20)}<label for="evQ" class="ev-vh">Search or ask PMOS</label><input id="evQ" type="text" autocomplete="off" spellcheck="false" placeholder="Search or ask: initiatives, documents, reports, meetings…" role="combobox" aria-expanded="true" aria-controls="evRes" aria-autocomplete="list"><span class="ev-kbd">Esc</span><button type="button" class="ev-ib x" data-ev="close" aria-label="Close search">${svg(ICON.close, 18)}</button></div>`
44
44
  + '<div class="ev-sp-chips" id="evChips" role="group" aria-label="Kind"></div>'
45
45
  + '<div class="ev-sp-list" id="evRes" role="listbox" aria-label="Results"></div>'
46
46
  + `<div class="ev-sp-ft"><span><span class="ev-kbd" role="img" aria-label="Arrow up">${svg(ARROW.up, 12)}</span> <span class="ev-kbd" role="img" aria-label="Arrow down">${svg(ARROW.down, 12)}</span> move</span><span><span class="ev-kbd" role="img" aria-label="Enter">${svg(ARROW.enter, 12)}</span> open</span><span class="ev-r">Searches your work. Opens in the Viewer when it can.</span></div>`
@@ -74,7 +74,7 @@ export function openSearch(o = {}) {
74
74
  if (o.q != null) S.q = String(o.q);
75
75
  el.hidden = false; document.getElementById('evSpScrim').hidden = false; el.setAttribute('data-esc-layer', '');
76
76
  const q = el.querySelector('#evQ'); q.value = S.q; q.focus(); q.select();
77
- q.placeholder = S.scope ? 'Search ' + S.scope.name + ', then everywhere' : 'Search initiatives, documents, slides, reports, artifacts and meetings';
77
+ q.placeholder = S.scope ? 'Search or ask: ' + S.scope.name + ', then everywhere' : 'Search or ask: initiatives, documents, reports, meetings…';
78
78
  if (!S.boards) getj('/api/boards/backlog?limit=200' + wsQ('&')).then((b) => { S.boards = b && b.ok && Array.isArray(b.rows) ? b : { rows: [] }; draw(); });
79
79
  if (!S.sessions) getj('/api/sessions').then((s) => { S.sessions = s && Array.isArray(s.sessions) ? s.sessions.filter((x) => !x.automatic && x.shown !== 'exited') : []; draw(); });
80
80
  run();