create-pmos 0.828.0 → 0.830.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 (113) hide show
  1. package/package.json +237 -35
  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/board-deliveries-test.js +2 -2
  7. package/workspace/briefing-premium-board-test.js +1 -1
  8. package/workspace/briefing-premium-insights-test.js +1 -1
  9. package/workspace/changelog.json +236 -8
  10. package/workspace/guide/agent-capabilities.md +1 -1
  11. package/workspace/guide/backlog.md +12 -1
  12. package/workspace/guide/cli.md +46 -1
  13. package/workspace/guide/home.md +2 -1
  14. package/workspace/guide/layout.md +1 -0
  15. package/workspace/guide/settings-and-switches.md +1 -0
  16. package/workspace/lib/board-premium.js +1 -0
  17. package/workspace/lib/code-map.js +8 -2
  18. package/workspace/lib/critical-needs.js +162 -0
  19. package/workspace/lib/deps-cli.js +102 -0
  20. package/workspace/lib/engine/boards.js +13 -2
  21. package/workspace/lib/factory-floor.js +16 -8
  22. package/workspace/lib/features.json +17 -13
  23. package/workspace/lib/needs-providers.js +1 -0
  24. package/workspace/lib/page-one-answer.js +86 -0
  25. package/workspace/lib/pages-cli.js +6 -2
  26. package/workspace/lib/people-cli.js +9 -1
  27. package/workspace/lib/people-prep.js +140 -0
  28. package/workspace/lib/pmos-verbs.js +10 -0
  29. package/workspace/lib/print-cli.js +49 -0
  30. package/workspace/lib/print-pdf.js +96 -0
  31. package/workspace/lib/prototype-cli.js +86 -0
  32. package/workspace/lib/report-cli.js +12 -2
  33. package/workspace/lib/report-readers.js +5 -3
  34. package/workspace/lib/review-pack.js +348 -0
  35. package/workspace/lib/review-reasons.js +121 -9
  36. package/workspace/lib/route-modules.js +5 -0
  37. package/workspace/lib/routes-boards.js +25 -2
  38. package/workspace/lib/routes-report-design.js +3 -1
  39. package/workspace/lib/routes-review-pack.js +42 -0
  40. package/workspace/lib/routes-roadmap-ops.js +53 -1
  41. package/workspace/lib/routes-sim-users.js +66 -0
  42. package/workspace/lib/routes-skill-map.js +39 -0
  43. package/workspace/lib/routes-strategy-card.js +13 -6
  44. package/workspace/lib/routes-team-waits.js +24 -0
  45. package/workspace/lib/sim-users.js +329 -0
  46. package/workspace/lib/skill-map.js +199 -0
  47. package/workspace/lib/task-store.js +1 -1
  48. package/workspace/lib/team-cli.js +20 -1
  49. package/workspace/lib/team-waits.js +167 -0
  50. package/workspace/lib/tradeoff-cards.js +258 -0
  51. package/workspace/lib/tradeoff-cli.js +83 -0
  52. package/workspace/package-lock.json +2 -2
  53. package/workspace/package.json +1 -1
  54. package/workspace/public/pm/action-keys.js +1 -0
  55. package/workspace/public/pm/ask-here-ctx.js +25 -1
  56. package/workspace/public/pm/ask-here.css +7 -0
  57. package/workspace/public/pm/ask-here.js +15 -2
  58. package/workspace/public/pm/bd-backlog.css +61 -0
  59. package/workspace/public/pm/bd-backlog.js +99 -7
  60. package/workspace/public/pm/bd-work.js +12 -1
  61. package/workspace/public/pm/code-map.js +15 -4
  62. package/workspace/public/pm/cozy-board.css +5 -1
  63. package/workspace/public/pm/cozy-library.css +5 -0
  64. package/workspace/public/pm/cozy-pop-work.js +4 -1
  65. package/workspace/public/pm/cozy-proto.css +5 -0
  66. package/workspace/public/pm/cozy-proto.js +11 -3
  67. package/workspace/public/pm/cozy-search.js +2 -2
  68. package/workspace/public/pm/cozy-today-app.js +5 -2
  69. package/workspace/public/pm/day-time.js +8 -0
  70. package/workspace/public/pm/factory.js +199 -0
  71. package/workspace/public/pm/home-ini.js +3 -2
  72. package/workspace/public/pm/ini-links.js +2 -1
  73. package/workspace/public/pm/ini-tasks.js +5 -2
  74. package/workspace/public/pm/ini-view-model.js +14 -6
  75. package/workspace/public/pm/ini-view.js +12 -2
  76. package/workspace/public/pm/library-model.js +1 -1
  77. package/workspace/public/pm/page-one-answer.css +18 -0
  78. package/workspace/public/pm/page-one-answer.js +134 -0
  79. package/workspace/public/pm/pop-cap.js +5 -3
  80. package/workspace/public/pm/pop-work-model.js +8 -6
  81. package/workspace/public/pm/portfolio.js +1 -1
  82. package/workspace/public/pm/premium-board.js +23 -6
  83. package/workspace/public/pm/premium-library.js +27 -3
  84. package/workspace/public/pm/premium-report-read.js +11 -2
  85. package/workspace/public/pm/print-pdf.js +191 -0
  86. package/workspace/public/pm/range-pick.css +12 -0
  87. package/workspace/public/pm/range-pick.js +30 -6
  88. package/workspace/public/pm/review-pack.js +47 -0
  89. package/workspace/public/pm/review-reasons.js +19 -5
  90. package/workspace/public/pm/sim-users.js +34 -0
  91. package/workspace/public/pm/skill-map.js +57 -0
  92. package/workspace/public/pm/sort-order.js +3 -0
  93. package/workspace/public/pm/task-card.js +10 -7
  94. package/workspace/public/pm/team-waits.js +56 -0
  95. package/workspace/public/pm/tradeoff-cards.css +27 -0
  96. package/workspace/public/pm/tradeoff-cards.js +183 -0
  97. package/workspace/public/premium-board.html +3 -0
  98. package/workspace/public/today.html +1 -0
  99. package/workspace/run-tests.js +9 -1
  100. package/workspace/test-lists/critical-needs.json +9 -0
  101. package/workspace/test-lists/factory-page-ui.json +9 -0
  102. package/workspace/test-lists/page-one-answer.json +9 -0
  103. package/workspace/test-lists/people-prep.json +9 -0
  104. package/workspace/test-lists/print-pdf.json +9 -0
  105. package/workspace/test-lists/review-pack.json +9 -0
  106. package/workspace/test-lists/sim-users.json +9 -0
  107. package/workspace/test-lists/skill-map.json +9 -0
  108. package/workspace/test-lists/surface-ask-card.json +9 -0
  109. package/workspace/test-lists/task-time-optional.json +9 -0
  110. package/workspace/test-lists/team-waits.json +9 -0
  111. package/workspace/test-lists/tradeoff-cards.json +9 -0
  112. package/workspace/test-lists/voice-files.json +9 -0
  113. package/workspace/test-timings.json +25 -0
@@ -0,0 +1,199 @@
1
+ /* pm/factory.js — Work › Factory: the stations, and the work they make (initiative factory-page-ui, slice C of the Factory page; boards
2
+ * FxFloor and FxStation on the main canvas; brief /mnt/project-files/factory-page/BRIEF.md, agreed by the PM 2026-11-25).
3
+ * Pure: Node imports it (factory-page-ui.test.js). The page reads only the saved snapshot (GET /api/factory, lib/factory-floor.js), so it
4
+ * opens in 200 ms or less.
5
+ *
6
+ * THE MODEL (keep the two apart): the work is what gets made (goals → initiatives at a stage of their own workflow); the factory is who makes
7
+ * it. PMOS's stations in flow order: Intake, Shape, Plan, Track, Evaluate; then Check (PMOS checking its own work) and You (only what no
8
+ * record can decide).
9
+ *
10
+ * floorModel(products, { now }) → { none, at, lastRun, made, stations: [5 working], you, check, held: { signoffs, drafts, inis }, stale }
11
+ * statusLine(M, { now }) → { alert, text, sub } red only while something is held, and it names who must act
12
+ * goalsModel(rows) → { stages: [names], goals: [{ name, n, segs: [{ stage, n, c }] }] } | null rows: { goal, stage, stages }
13
+ * floorHtml(M, { goals, now }) → the page: status line, five tiles, the You tile, the Check tile, What the factory is making
14
+ * stationHtml(st, { undone }) → the popup body: Waiting (what each item waits on), Made this week (Undo), Cost this week
15
+ * minutesText(n) → "14 min" · "1 h 5 min"
16
+ *
17
+ * The words say PMOS. Every button shows an icon only and carries its aria-label. Zero is silence: a number row of 0 is not drawn, and a
18
+ * station with nothing waiting and nothing made stays grey and silent. Text from records goes through esc(). */
19
+ export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
20
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
21
+ const SV = (d) => `<svg viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false"><path d="${d}"/></svg>`;
22
+ const IC = {
23
+ intake: 'M4 4h16v6H4zM8 14h8M10 18h4', shape: 'M12 3l9 5-9 5-9-5zM3 13l9 5 9-5', plan: 'M4 5h16M4 12h10M4 19h6',
24
+ track: 'M3 12h4l3-8 4 16 3-8h4', evaluate: 'M4 20V10M10 20V4M16 20v-7M22 20H2', check: 'M5 12.5l4.5 4.5L19 7', you: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 16 0',
25
+ open: 'M9 6l6 6-6 6', go: 'M5 12h14M13 6l6 6-6 6', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', more: 'M7 10l5 5 5-5',
26
+ };
27
+
28
+ export const FLOW = Object.freeze(['intake', 'shape', 'plan', 'track', 'evaluate']);
29
+ export const NAMES = Object.freeze({ intake: 'Intake', shape: 'Shape', plan: 'Plan', track: 'Track', evaluate: 'Evaluate', check: 'Check', you: 'You' });
30
+ export const DOES = Object.freeze({
31
+ intake: 'Asks → initiatives', shape: 'Problem, evidence, PRD', plan: 'Milestones, tasks, owners, dates', track: 'Tracker, follow-ups, slips',
32
+ evaluate: 'Outcome reading, lessons', check: 'PMOS checking its own work', you: 'Sign-offs and calls only a person can make',
33
+ });
34
+ const STALE_MS = 36 * 3600000; // a snapshot older than a day and a half says when it is from
35
+
36
+ export function minutesText(n) {
37
+ const m = Math.max(0, Math.round(Number(n) || 0));
38
+ if (m < 60) return m + ' min';
39
+ return Math.floor(m / 60) + ' h' + (m % 60 ? ' ' + (m % 60) + ' min' : '');
40
+ }
41
+ const pad = (n) => String(n).padStart(2, '0');
42
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
43
+ const dayOf = (d) => d.getDate() + ' ' + MON[d.getMonth()];
44
+ /** "at 00:09" today, "on 24 Nov at 00:09" another day (the computer's own time). */
45
+ export function whenText(iso, now = Date.now()) {
46
+ const t = Date.parse(iso || ''); if (!Number.isFinite(t)) return '';
47
+ const d = new Date(t), n = new Date(now), hm = pad(d.getHours()) + ':' + pad(d.getMinutes());
48
+ return d.toDateString() === n.toDateString() ? 'at ' + hm : 'on ' + dayOf(d) + ' at ' + hm;
49
+ }
50
+
51
+ /** One model over the picked products: numbers add up, items keep their product (ws). */
52
+ export function floorModel(products, { now = Date.now() } = {}) {
53
+ const snaps = (Array.isArray(products) ? products : []).filter((p) => p && p.snapshot && Array.isArray(p.snapshot.stations));
54
+ const st = new Map([...FLOW, 'check', 'you'].map((k) => [k, { key: k, name: NAMES[k], waiting: 0, made: 0, undone: 0, minutes: 0, runs: 0, items: [], madeItems: [] }]));
55
+ let at = null, lastRun = null;
56
+ for (const p of snaps) {
57
+ const s = p.snapshot;
58
+ if (s.at && (!at || s.at > at)) at = s.at;
59
+ if (s.lastRun && (!lastRun || s.lastRun > lastRun)) lastRun = s.lastRun;
60
+ for (const x of s.stations) {
61
+ const m = st.get(x.key); if (!m) continue;
62
+ for (const k of ['waiting', 'made', 'undone', 'minutes', 'runs']) m[k] += Number(x[k]) || 0;
63
+ m.items.push(...(x.items || []).map((i) => ({ ...i, ws: p.ws })));
64
+ m.madeItems.push(...(x.madeItems || []).map((i) => ({ ...i, ws: p.ws })));
65
+ }
66
+ }
67
+ for (const m of st.values()) m.madeItems.sort((a, b) => String(b.at || '').localeCompare(String(a.at || '')));
68
+ const stations = FLOW.map((k) => st.get(k));
69
+ // the red edge: the station that holds the most (the first in flow order on a tie); none while nothing waits
70
+ const top = stations.reduce((b, s) => (s.waiting > (b ? b.waiting : 0) ? s : b), null);
71
+ for (const s of stations) { s.quiet = !s.waiting && !s.made; s.con = !!top && s === top; }
72
+ const you = st.get('you');
73
+ const signoffs = you.items.filter((i) => i.kind === 'signoff');
74
+ const drafts = you.items.filter((i) => i.code === 'pm-open');
75
+ const inis = new Set([...signoffs.map((i) => i.ini && i.ws + '|' + i.ini), ...drafts.filter((i) => i.kind === 'initiative').map((i) => i.ws + '|' + i.id)].filter(Boolean));
76
+ // the snapshot counts open sign-offs past the item cap too: the You station's waiting is the whole number
77
+ const nSign = Math.max(signoffs.length, you.waiting - drafts.length);
78
+ return {
79
+ none: !snaps.length, at, lastRun, stations, you, check: st.get('check'),
80
+ made: stations.reduce((n, s) => n + s.made, 0),
81
+ held: { signoffs: nSign, drafts: drafts.length, inis: inis.size, any: you.waiting > 0 },
82
+ stale: !!at && now - Date.parse(at) > STALE_MS,
83
+ };
84
+ }
85
+
86
+ /** The status line: red only while something is held, and then it names who must act (the PM, on Today). */
87
+ export function statusLine(M, { now = Date.now() } = {}) {
88
+ if (!M || M.none) return { alert: false, text: 'The factory has not run here yet. Its numbers show after its first run.', sub: '' };
89
+ const when = whenText(M.lastRun, now);
90
+ const lead = when ? `The factory ran ${when}` : 'The factory did not run this week';
91
+ let text = M.made ? `${lead} and made ${plural(M.made, 'thing', 'things')} this week.` : `${lead}. It made nothing this week.`;
92
+ const H = M.held;
93
+ if (H.any) {
94
+ const parts = [H.signoffs ? plural(H.signoffs, 'sign-off', 'sign-offs') : '', H.drafts ? plural(H.drafts, 'draft', 'drafts') : ''].filter(Boolean).join(' and ');
95
+ const n = H.signoffs + H.drafts;
96
+ text += ` It is waiting on you: ${parts}${H.inis ? ` ${n === 1 ? 'holds' : 'hold'} ${plural(H.inis, 'initiative', 'initiatives')}` : ''}.`;
97
+ }
98
+ const t = Date.parse(M.at || '');
99
+ const sub = M.stale && Number.isFinite(t) ? `These numbers are from ${dayOf(new Date(t))}. The next run brings new ones.` : '';
100
+ return { alert: !!H.any, text, sub };
101
+ }
102
+
103
+ /** Initiatives by goal, coloured by stage. Stage order: where each stage stands in its own workflow (the first seen on a tie). */
104
+ export function goalsModel(rows) {
105
+ const R = (Array.isArray(rows) ? rows : []).filter((r) => r && r.stage);
106
+ if (!R.length) return null;
107
+ const pos = new Map();
108
+ for (const r of R) {
109
+ const list = Array.isArray(r.stages) && r.stages.length ? r.stages : [r.stage];
110
+ list.forEach((n, i) => { const p = pos.get(n); if (!p) pos.set(n, { i, first: pos.size }); else if (i < p.i) p.i = i; });
111
+ }
112
+ const stages = [...pos.entries()].sort((a, b) => a[1].i - b[1].i || a[1].first - b[1].first).map(([n]) => n)
113
+ .filter((n) => R.some((r) => r.stage === n));
114
+ const by = new Map();
115
+ for (const r of R) { const g = r.goal || ''; if (!by.has(g)) by.set(g, []); by.get(g).push(r); }
116
+ const goals = [...by.entries()].sort((a, b) => (a[0] ? 0 : 1) - (b[0] ? 0 : 1) || b[1].length - a[1].length || a[0].localeCompare(b[0]))
117
+ .map(([g, list]) => ({ name: g || 'No goal', n: list.length,
118
+ segs: stages.map((s, c) => ({ stage: s, n: list.filter((r) => r.stage === s).length, c })).filter((x) => x.n) }));
119
+ return { stages, goals };
120
+ }
121
+
122
+ const kv = (label, v) => `<div class="ff-kv"><span>${esc(label)}</span><b>${esc(v)}</b></div>`;
123
+ function tileHtml(s) {
124
+ const rows = s.quiet ? '' : [s.waiting ? kv('Waiting', s.waiting) : '', s.made ? kv('Made this week', s.made) : '',
125
+ s.minutes ? kv('PMOS time', minutesText(s.minutes)) : '', s.undone ? kv('You undid', s.undone) : ''].join('');
126
+ return `<section class="ff-st${s.quiet ? ' quiet' : ''}${s.con ? ' con' : ''}" data-fx-tile="${s.key}" aria-label="${esc(s.name)}">`
127
+ + `<header><span class="ff-ic">${SV(IC[s.key])}</span><b>${esc(s.name)}</b>`
128
+ + `<button type="button" class="ff-open" data-fx-st="${s.key}" aria-label="Open ${esc(s.name)}" title="Open ${esc(s.name)}">${SV(IC.open)}</button></header>`
129
+ + `<p class="ff-does">${esc(DOES[s.key])}</p>${rows}</section>`;
130
+ }
131
+ function youHtml(M) {
132
+ const Y = M.you, H = M.held;
133
+ const line = Y.waiting
134
+ ? `${plural(Y.waiting, 'thing waits', 'things wait')} on you.${H.inis ? ` ${Y.waiting === 1 ? 'It holds' : 'They hold'} ${plural(H.inis, 'initiative', 'initiatives')}.` : ''}`
135
+ : 'Nothing waits on you.';
136
+ const done = Y.made ? ` You answered ${Y.made} this week.` : '';
137
+ return `<section class="ff-side ff-you${Y.waiting ? ' con' : ' quiet'}" aria-label="You">`
138
+ + `<header><span class="ff-ic">${SV(IC.you)}</span><b>You</b>`
139
+ + `<a class="ff-open ff-go" href="/today.html" aria-label="Answer them on Today" title="Answer them on Today">${SV(IC.go)}</a></header>`
140
+ + `<p class="ff-does">${esc(DOES.you)}</p><p class="ff-line">${esc(line + done)}</p></section>`;
141
+ }
142
+ function checkHtml(M) {
143
+ const C = M.check, undone = M.stations.reduce((n, s) => n + s.undone, 0);
144
+ const parts = [C.made ? `${C.made} checked this week` : '', C.waiting ? `${C.waiting} wait for a check` : '', undone ? `${undone} undone this week` : ''].filter(Boolean);
145
+ return `<section class="ff-side ff-check${parts.length ? '' : ' quiet'}" aria-label="Check">`
146
+ + `<header><span class="ff-ic">${SV(IC.check)}</span><b>Check</b>`
147
+ + `<button type="button" class="ff-open" data-fx-st="check" aria-label="Open Check" title="Open Check">${SV(IC.open)}</button></header>`
148
+ + `<p class="ff-does">${esc(DOES.check)}</p><p class="ff-line">${esc(parts.length ? parts.join(' · ') : 'Nothing to check this week.')}</p></section>`;
149
+ }
150
+ function goalsHtml(G) {
151
+ if (!G || !G.goals.length) return '';
152
+ const row = (g) => `<li class="ff-goal"><span class="ff-gn">${esc(g.name)}</span><span class="ff-gc">${plural(g.n, 'initiative', 'initiatives')}</span>`
153
+ + `<span class="ff-seg" role="img" aria-label="${esc(g.segs.map((x) => `${x.stage}: ${x.n}`).join(', '))}">`
154
+ // one equal mark per initiative, so a stage's width is its count (no inline style)
155
+ + g.segs.map((x) => Array.from({ length: x.n }, () => `<i class="c${x.c % 6}" title="${esc(x.stage)}: ${x.n}"></i>`).join('')).join('') + '</span></li>';
156
+ const legend = G.stages.map((s, c) => `<span><i class="c${c % 6}"></i>${esc(s)}</span>`).join('');
157
+ return `<section class="ff-goals" aria-label="What the factory is making"><h3>What the factory is making <small>initiatives by goal, coloured by stage</small></h3>`
158
+ + `<ul>${G.goals.map(row).join('')}</ul><p class="ff-legend">${legend}</p>`
159
+ + `<p class="ff-note">Each initiative’s stage, tasks and milestones open from Work › Initiatives.</p></section>`;
160
+ }
161
+
162
+ /** The page. o.goals: goalsModel(…) or null (no section). */
163
+ export function floorHtml(M, { goals = null, now = Date.now() } = {}) {
164
+ const S = statusLine(M, { now });
165
+ const andon = `<p class="bd-andon ff-andon${S.alert ? ' alert' : ''}" role="status"><span class="bd-lamp" aria-hidden="true"></span><span>${esc(S.text)}`
166
+ + `${S.sub ? `<small>${esc(S.sub)}</small>` : ''}</span></p>`;
167
+ if (M.none) return `<div class="ff">${andon}${goalsHtml(goals)}</div>`;
168
+ const flow = M.stations.map(tileHtml).join('<span class="ff-arr" aria-hidden="true">›</span>');
169
+ return `<div class="ff">${andon}<div class="ff-flow" aria-label="Stations in flow order">${flow}</div>`
170
+ + `<div class="ff-sides">${youHtml(M)}${checkHtml(M)}</div>${goalsHtml(goals)}</div>`;
171
+ }
172
+
173
+ const STATE = { applied: 'applied by PMOS', kept: 'kept', undone: 'undone', proposed: 'drafted', dropped: 'dropped', expired: 'not answered', sent: 'sent' };
174
+ const FIRST = 5;
175
+ /** The station popup's body. o.undone: Set of '<ws>|<ref>' the PM undid on this page (the snapshot shows it at the next run). */
176
+ export function stationHtml(st, { undone = new Set() } = {}) {
177
+ if (!st) return '';
178
+ const wait = st.items.length
179
+ ? `<section class="fx-sec"><h4>Waiting <span>${st.waiting}</span></h4><ul>${st.items.map((i) => `<li><b>${esc(i.title || i.id)}</b><span>${esc(i.text || '')}</span></li>`).join('')}</ul>`
180
+ + (st.waiting > st.items.length ? `<p class="fx-more">${st.waiting - st.items.length} more are not listed.</p>` : '') + '</section>'
181
+ : '';
182
+ const made = (i) => {
183
+ const gone = undone.has((i.ws || '') + '|' + i.ref);
184
+ const btn = i.undo && i.ref && !gone
185
+ ? `<button type="button" class="ff-undo" data-fx-undo="${esc(i.ref)}" data-fx-ws="${esc(i.ws || '')}" aria-label="Undo ${esc(i.title)}" title="Undo">${SV(IC.undo)}</button>` : '';
186
+ return `<li><b>${esc(i.title)}</b><span>${esc(gone ? 'undone' : STATE[i.state] || i.state || '')}</span>${btn}</li>`;
187
+ };
188
+ const M = st.madeItems || [];
189
+ const madeSec = M.length
190
+ ? `<section class="fx-sec"><h4>Made this week <span>${st.made}</span></h4><ul>${M.slice(0, FIRST).map(made).join('')}</ul>`
191
+ + (M.length > FIRST ? `<details class="fx-fold"><summary>${M.length - FIRST} more</summary><ul>${M.slice(FIRST).map(made).join('')}</ul></details>` : '')
192
+ + '</section>'
193
+ : st.made ? `<section class="fx-sec"><h4>Made this week <span>${st.made}</span></h4><p class="fx-more">Background runs; nothing here to undo.</p></section>` : '';
194
+ const cost = [st.minutes ? `${minutesText(st.minutes)} of PMOS time over ${plural(st.runs, 'run', 'runs')}` : '',
195
+ st.made ? `you undid ${st.undone} of ${st.made}` : '', 'tokens not recorded yet'].filter(Boolean).join(' · ');
196
+ const costSec = `<section class="fx-sec"><h4>Cost this week</h4><p>${esc(cost.charAt(0).toUpperCase() + cost.slice(1))}</p></section>`;
197
+ const none = !wait && !madeSec ? '<p class="fx-more">Nothing waited here and nothing was made this week.</p>' : '';
198
+ return `<div class="fx-sheet">${none}${wait}${madeSec}${costSec}</div>`;
199
+ }
@@ -394,9 +394,10 @@ async function setDates(id, uid, patch) {
394
394
  const r = await C.pmPost('/api/boards/tasks/edit', { ...body, ...patch });
395
395
  if (!r || r.ok === false) { undoToast(LE.notSaved(r), () => setDates(id, uid, patch), 12000, 'Try again'); return; }
396
396
  await C.load(); redrawView();
397
- const back = {}; for (const f of Object.keys(patch)) back[f] = f === 'milestone' ? (r.from && 'milestone' in r.from ? !!r.from.milestone : !patch.milestone) : k ? (f === 'due' ? k.end : k[f]) || '' : r.from && f in r.from ? r.from[f] || '' : ''; // a Jira ticket's days come back in from (batch 11 item 23)
397
+ const back = {}; for (const f of Object.keys(patch)) back[f] = /_time$/.test(f) ? (r.from && r.from[f]) || '' : f === 'milestone' ? (r.from && 'milestone' in r.from ? !!r.from.milestone : !patch.milestone) : k ? (f === 'due' ? k.end : k[f]) || '' : r.from && f in r.from ? r.from[f] || '' : ''; // a Jira ticket's days come back in from (batch 11 item 23)
398
398
  if ('milestone' in patch) { undoToast((patch.milestone ? 'Milestone: ' : 'Not a milestone: ') + (k ? k.title : uid) + '.', async () => { const u = await C.pmPost('/api/boards/tasks/edit', { ...body, ...back }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); }); return; }
399
- if (k || (r.from && ('start' in r.from || 'due' in r.from))) undoToast('Dates saved: ' + (k ? k.title : uid + ', kept in PMOS') + '.', async () => { const u = await C.pmPost('/api/boards/tasks/edit', { ...body, ...back }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
399
+ const tOnly = Object.keys(patch).every((f) => /_time$/.test(f)); // a time alone (task-time-optional) says so
400
+ if (k || (r.from && ('start' in r.from || 'due' in r.from))) undoToast((tOnly ? 'Time saved: ' : 'Dates saved: ') + (k ? k.title : uid + ', kept in PMOS') + '.', async () => { const u = await C.pmPost('/api/boards/tasks/edit', { ...body, ...back }); if (!u || u.ok === false) C.toast((u && u.error) || 'The undo did not land.'); await C.load(); redrawView(); });
400
401
  else C.toast('Dates saved.');
401
402
  }
402
403
  /** ⋯ of the page: the ONE initiative menu (pm/ini-more.js; batch 16 item 5c: seven entries), the same words and order as the Board's panel.
@@ -504,7 +504,8 @@ export function wrap(H, idOf) {
504
504
  const W = { ...H };
505
505
  W.dates = (uid, patch) => {
506
506
  const id = idOf(), lk = id && VIEWS.get(id);
507
- if (lk && !/^dt:/.test(String(uid)) && lk.links.some((l) => l.from === uid || l.to === uid) && !('milestone' in patch)) return ownMove(W, id, uid, patch);
507
+ // a time alone (task-time-optional) moves no day, so it is no linked move
508
+ if (lk && !/^dt:/.test(String(uid)) && lk.links.some((l) => l.from === uid || l.to === uid) && !('milestone' in patch) && ('start' in patch || 'due' in patch)) return ownMove(W, id, uid, patch);
508
509
  return H.dates && H.dates(uid, patch);
509
510
  };
510
511
  return W;
@@ -212,7 +212,9 @@ const ttitle = (k) => `<button type="button" class="iv-tt" data-iv-ticket="${esc
212
212
  export function dateBtn(x, o) {
213
213
  if (!o.quick || !x.uid) return x.days ? `<span class="${x.late ? 'w' : ''}">${daysHtml(x)}</span>` : '';
214
214
  const one = x.ms && !x.jira ? ' data-one="1"' : '';
215
- const a = `data-iv-date="${esc(x.uid)}" data-s="${esc(x.start)}" data-e="${esc(x.end)}" data-t="${esc(x.title)}"${one} title="${one ? 'The milestone\'s date' : x.jira || x.jkey ? 'Start and due, kept in PMOS. Jira is not changed' : 'Start and due'}"`;
215
+ // the optional time (task-time-optional): a PMOS task's own, not a Jira ticket's or a draft's
216
+ const tm = !x.jira && !x.jkey && !x.dr ? ` data-tm="1" data-st="${esc(x.start_time || '')}" data-dt="${esc(x.due_time || '')}"` : '';
217
+ const a = `data-iv-date="${esc(x.uid)}" data-s="${esc(x.start)}" data-e="${esc(x.end)}" data-t="${esc(x.title)}"${one}${tm} title="${one ? 'The milestone\'s date' : x.jira || x.jkey ? 'Start and due, kept in PMOS. Jira is not changed' : 'Start and due'}"`;
216
218
  // a milestone with no due date: a dashed chip asks for it, shown always (canvas XmlA6Suggest)
217
219
  if (msNoDate(x)) return `<button type="button" class="iv-dc ms" ${a} aria-label="${esc('Set the due date: ' + x.title)}">${SVG(P.cal, 13)}Set the due date</button>`;
218
220
  return x.days ? `<button type="button" class="iv-dc${x.late ? ' w' : ''}" ${a} aria-label="${esc((one ? 'Milestone date: ' : 'Dates: ') + x.days + '. Change')}">${daysHtml(x)}</button>`
@@ -671,7 +673,8 @@ export function datePop(anchor, uid, H) {
671
673
  if (sheet) st.head = `<div class="ivd-h">${one ? SVG(P.dia, 15, 2.2) : SVG(P.cal, 15, 2)}<b>${one ? 'Date' : 'Dates'}</b><button type="button" class="iv-ib" data-ivd-x aria-label="Close" title="Close">${SVG('M6 6l12 12M18 6L6 18', 16, 2)}</button></div>`
672
674
  + (nm ? `<p class="ivd-s">${esc(nm + (one ? ' · one date: the milestone' : ''))}</p>` : '');
673
675
  const el = openPop(anchor, datePickerHtml(t, st), (b) => { if ('ivdX' in b.dataset) closePop(); }, sheet ? { sheet: true } : {});
674
- mountRange(el.querySelector('.tkc-dp'), { ...t, one, field: st.field, head: st.head, onPick: (p, done) => { Object.assign(t, p); if (done) closePop(); if (H.dates) H.dates(uid, p); } });
676
+ mountRange(el.querySelector('.tkc-dp'), { ...t, one, field: st.field, head: st.head,
677
+ time: anchor.dataset.tm === '1', start_time: anchor.dataset.st || '', due_time: anchor.dataset.dt || '', onPick: (p, done) => { Object.assign(t, p); if (done) closePop(); if (H.dates) H.dates(uid, p); } });
675
678
  el.querySelector('.rp-g [tabindex="0"]')?.focus({ preventScroll: true });
676
679
  }
677
680
  function menuPop(anchor, label, items, go) {
@@ -34,11 +34,13 @@
34
34
  * 12 over the plan: the dates line turns amber with the days over; a skipped stage keeps its place, with its reason.
35
35
  * 18 each section carries its dates: done stages when they ran, now from when to the plan end, later ones "Plan <date>", amber when missed.
36
36
  * 19 a big section shows the 3 most urgent first, then folds the rest by the next WBS level, each with its count; done folds last. */
37
- import { ticketGroups } from './tk-model.js'; // the drafted Jira tickets by epic (kit 2, T1): By epic's groups
37
+ import { ticketGroups } from './tk-model.js';
38
+ import { isTime, withTime } from './day-time.js'; // a task's optional time on its start and due (task-time-optional) // the drafted Jira tickets by epic (kit 2, T1): By epic's groups
38
39
 
39
40
  import { stageSource } from './stage-chip.js'; // W1: what set the one stage, and when it was read
40
41
  const endWord = (r) => (r && r.oneStage && ['shipped', 'on-hold', 'cancelled'].includes(r.oneStage.stage) ? r.oneStage.label : '');
41
- import { lineOf } from './stage-line.js'; // the stage card's one line (batch 11 item 21)
42
+ import { lineOf } from './stage-line.js';
43
+ import { iniAnswer } from './page-one-answer.js'; // page-one-answer (A308): the initiative opens with one sentence, what needs you, the rest folded // the stage card's one line (batch 11 item 21)
42
44
  import { provenStatus, fromLine, NO_SIGNAL } from './status-proof.js'; // T3: a status renders only with its source and read time
43
45
 
44
46
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
@@ -126,11 +128,15 @@ const jDays = (k, today) => { const e = k.due || k.sprintEnd || ''; return k.sta
126
128
  const jiraBucket = (st) => (/^(done|closed|resolved|released)$/i.test(String(st || '')) ? 'Done' : /progress|review|test|\bqa\b|doing|started|block/i.test(String(st || '')) ? 'In progress' : 'To do');
127
129
  /** k: the task as stored; J: the Jira ticket its title names, when PMOS read that ticket (0.442.0 hotfix, Wawan 13:02 and 13:03). A linked task's
128
130
  * status is the ticket's; its start and due stay the PM's, kept in PMOS: Jira's start and due show only while the task has none of its own. */
129
- function rowOf(k0, today, J = null) {
131
+ export function rowOf(k0, today, J = null) {
130
132
  const k = J ? { ...k0, status: jiraBucket(J.status), start: k0.start || J.start || '', end: k0.end || J.due || '' } : k0; // never the sprint's end: a task with no date shows none, and is not late (Wawan, 2026-11-19)
131
133
  const closed = CLOSED.has(k.status), d = dayOf(k.end), late = !closed && !!d && d < today;
132
134
  // start and end both (batch 7 item 6): "Oct 15 – Oct 28", one day once, "from Oct 15" with no end
133
- const days = k.start && k.end ? span(k.start, k.end, today) : k.start ? 'from ' + dateY(k.start, today) : d ? dateY(k.end, today) : '';
135
+ // a time shows after its day only when one is set (task-time-optional); a PMOS task's own, never a Jira ticket's
136
+ const st = !J && isTime(k0.start_time) ? k0.start_time : '', dt = !J && isTime(k0.due_time) ? k0.due_time : '';
137
+ const sDay = withTime(dateY(k.start, today), st), dDay = withTime(dateY(k.end, today), dt);
138
+ const days = !st && !dt ? (k.start && k.end ? span(k.start, k.end, today) : k.start ? 'from ' + dateY(k.start, today) : d ? dateY(k.end, today) : '')
139
+ : k.start && k.end ? (k.start === k.end && !st ? dDay : sDay + ' – ' + dDay) : k.start ? 'from ' + sDay : d ? dDay : '';
134
140
  const due = days ? days + (late ? ', ' + plural(between(d, today), 'day', 'days') + ' late' : '') : '';
135
141
  const who = ownerName(k.owner);
136
142
  // the List's meta draws the dates as their own press (batch 9 item 5b): days is the dates alone, lateText what follows them
@@ -138,7 +144,7 @@ function rowOf(k0, today, J = null) {
138
144
  days, lateText: late ? plural(between(d, today), 'day', 'days') + ' late' : '', item: !!k.item, ms: !!k.milestone, // ms: the ◇ flag (batch 11 item 3)
139
145
  start: k.start || '', end: k.end || '', since: k.since || '', owner: who, av: initials(k.owner),
140
146
  // the open row's date chips (batch 18 item 16): each day alone; rank: the PM's order inside its stage (a task-order line)
141
- startText: k.start ? dateY(k.start, today) : '', dueText: d ? dateY(k.end, today) : '', rank: Number.isFinite(k.rank) ? k.rank : null,
147
+ startText: k.start ? sDay : '', dueText: d ? dDay : '', ...(st && k.start ? { start_time: st } : {}), ...(dt && d ? { due_time: dt } : {}), rank: Number.isFinite(k.rank) ? k.rank : null,
142
148
  sub: [k.status === 'In progress' ? 'In progress' : '', due, who && who !== 'You' ? who : ''].filter(Boolean).join(' · '), wbs: wbsOf(k.title), canCheck: !!k.uid && !k.draft && !J, order: k.order,
143
149
  // 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
150
  cmp: k.cmp || null, added: !!k.added, dr: !!k.draft,
@@ -362,7 +368,9 @@ export function iniView(r, ctx = {}) {
362
368
  // split or merge (batch 11 item 14): Claude's suggestion for it, and where its work went when it was merged
363
369
  suggest: r.suggest || null, merged: mergedOf(r),
364
370
  // what Claude proposes under the one blue ✦, and what a ✓ kept from elsewhere (batch 12 items 2, 3 and 4; pm/ini-props.js)
365
- props: r.props || null, found: r.found || null };
371
+ props: r.props || null, found: r.found || null,
372
+ // page-one-answer (A308): what waits on you here, then your own open tasks that are late or due today; others' late tasks wait on others
373
+ answer: iniAnswer(rows, { wait: wait ? { title: wait.primary && wait.primary.label ? String(wait.primary.label).replace(/^✦\s*/, '') : 'Waits on you', sub: wait.text || '' } : null, today }) };
366
374
  }
367
375
  /** A merged initiative's closing line (XsmA7Closed): the one that stays and the day. null for every other row. */
368
376
  export function mergedOf(r) {
@@ -47,6 +47,8 @@ import * as AB from './ini-about.js'; // About: the description and the succes
47
47
  import { headerFlags } from './grill-words.js'; // the grill findings on the header (workspace grill W3)
48
48
  import * as ED from './ini-edit.js'; // a task changed where it sits in the List: open in place, ⋯, + per stage, drag (batch 18 item 16)
49
49
  import { ticks } from './ini-view-model.js'; // W1: a task group ticks only when every task in it is done
50
+ import * as PA from './page-one-answer.js';
51
+ import { pmPost } from './http.js'; // page-one-answer (A308): the answer block that opens the initiative
50
52
  import * as IA from './ini-agent.js'; // agent-run (board AwB): the Experiment, Claude's work with Undo, Coming up; the D107 gate
51
53
 
52
54
  const CSS = new URL('./ini-view.css', import.meta.url).href;
@@ -426,7 +428,9 @@ export function viewHtml(v, o = {}) {
426
428
  // a merged initiative leads with where its work went, and draws no stage or tasks (they moved; its folds stay); an open one shows Claude's split or merge card under the summary (batch 11 item 14)
427
429
  if (v.merged) return `<div class="iv" data-iv="${esc(v.id || v.key || '')}"><div class="iv-cols"><div class="iv-cl">${smMerged(v.merged)}</div><div class="iv-cr">${foldsHtml(v, o)}${o.tail || ''}</div></div></div>`;
428
430
  // One reading column: summary, milestones and proposals, then content-sized Tasks and document folds.
429
- return `<div class="iv" data-iv="${esc(v.id || v.key || '')}"><div class="iv-cols"><div class="iv-cl">${ctrlHtml(v, o)}${o.sm !== false ? smCard(v.suggest, v.title) : ''}</div>`
431
+ // page-one-answer (A308): one sentence first, then only what needs you, the rest in one fold (closed until you open it)
432
+ const pk = (v.id || v.key || '') + '|', poa = v.answer && !(typeof window !== 'undefined' && window.PMOS_READONLY) ? PA.answerHtml(v.answer, { open: FOLD.get(pk + 'poa') === true, more: FOLD.get(pk + 'poamore') === true, page: 'initiative' }) : '';
433
+ return `<div class="iv" data-iv="${esc(v.id || v.key || '')}">${poa}<div class="iv-cols"><div class="iv-cl">${ctrlHtml(v, o)}${o.sm !== false ? smCard(v.suggest, v.title) : ''}</div>`
430
434
  + `<div class="iv-cr">${v.id ? IA.sectionsHtml(AM, v, v.id, { all: IA.allOpen(v.id), cuAll: IA.cuOpen(v.id) }) : ''}<section class="iv-tasks" aria-label="Tasks">${tasksHtml(v, o)}</section>${foldsHtml(v, o)}${o.tail || ''}</div></div></div>`;
431
435
  }
432
436
 
@@ -447,7 +451,7 @@ export function wireView(body, h) {
447
451
  window.addEventListener('pmos:lab-version', onLab);
448
452
  }
449
453
  // the one blue ✦ after the title (pm/ini-props.js), drawn again with each draw of the initiative
450
- const chip = () => { const id = idOf(); if (id && VIEWED.has(id)) PP.sync(VIEWED.get(id), body.__iv || {}); drafts(id); about(id); agent(id); fitMission(body); };
454
+ const chip = () => { const id = idOf(); if (id && VIEWED.has(id)) PP.sync(VIEWED.get(id), body.__iv || {}); drafts(id); about(id); agent(id); fitMission(body); if (id) PA.reportCalls('initiative', pmPost, body); };
451
455
  // agent-run (AwB): the experiment and Claude's work, read every 30 s at most; they draw alone (and the gate with them) when they change
452
456
  const wsOf = () => { const H = body.__iv || {}; return ((H.where && H.where()) || {}).ws || ''; };
453
457
  const agent = (id) => { if (id && VIEWED.has(id)) IA.want(wsOf(), id, () => paintAgent(id), (VIEWED.get(id) || {}).title); };
@@ -501,6 +505,12 @@ export function wireView(body, h) {
501
505
  const root = b.closest('[data-iv]'); if (!root) return;
502
506
  const id = root.dataset.iv;
503
507
  const d = b.dataset;
508
+ // page-one-answer: a Needs you row opens its task (or brings the summary's ask into sight); the fold and "N more" open in place
509
+ if (d.poa) {
510
+ e.preventDefault();
511
+ if (d.poa === 'open') { if (d.poaAct === 'task' && d.poaKey && H.openTask) H.openTask(d.poaKey, b); else { const c = root.querySelector('.iv-cl'); if (c) c.scrollIntoView({ block: 'start' }); } return; }
512
+ FOLD.set(id + '|' + (d.poa === 'fold' ? 'poa' : 'poamore'), d.poa === 'fold' ? b.getAttribute('aria-expanded') !== 'true' : true); if (H.redraw) H.redraw(); return;
513
+ }
504
514
  // agent-run (AwB): edit a line of the experiment, Undo a change of Claude's, the rest of Claude's work
505
515
  if (d.iaEdit) { e.preventDefault(); IA.edit(b); return; }
506
516
  // the Specimens line opens the newest round's compare view, kept or not (2026-11-17: a round kept too early had no way back)
@@ -23,7 +23,7 @@
23
23
  */
24
24
 
25
25
  export const COLUMNS = ['Name', 'Kind', 'Product', 'About', 'By', 'State', 'Updated'];
26
- export const FAMILIES = [['plans', 'Plans and specs'], ['briefs', 'Briefs'], ['meetings', 'Meeting notes'], ['protos', 'Prototypes and designs'], ['checks', 'Checks'], ['links', 'Links']];
26
+ export const FAMILIES = [['plans', 'Plans and specs'], ['briefs', 'Briefs'], ['meetings', 'Meeting notes'], ['protos', 'Prototypes and designs'], ['checks', 'Checks'], ['links', 'Links'], ['reports', 'Reports']];
27
27
  export const GROUPS = [['new', 'New'], ['work', 'Work'], ['kind', 'Kind'], ['product', 'Product']];
28
28
  export const STATES = ['Draft', 'Final', 'Issued'];
29
29
  const MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
@@ -0,0 +1,18 @@
1
+ /* page-one-answer.css — every page opens with one answer (pm/page-one-answer.js, idea A308; board BatchPagesDS panel 1). Komorebi tokens only.
2
+ * The sentence, then only what needs you (pm-li rows with a blue dot), then one dashed fold line with the rest. No primary button. */
3
+ .poa { display: flex; flex-direction: column; gap: var(--space-8); margin: 0 0 var(--space-16); }
4
+ .poa-said { display: flex; flex-direction: column; gap: var(--space-4); }
5
+ .poa-line { margin: 0; font-size: var(--fs-panel); color: var(--ink); }
6
+ .poa-needs h2 { margin: 0 0 var(--space-4); font-size: var(--fs-label); }
7
+ .poa .pm-li.poa-r { display: flex; align-items: flex-start; gap: var(--space-12); }
8
+ .poa-dot { flex: none; width: var(--space-8); height: var(--space-8); margin-top: var(--space-8); border-radius: var(--radius-pill); background: var(--blue); }
9
+ .poa-rest .poa-dot { background: var(--line); }
10
+ .poa .txt { display: flex; flex-direction: column; min-width: 0; }
11
+ .poa-t { all: unset; cursor: pointer; font-size: var(--fs-row); color: var(--ink); }
12
+ @media (hover: hover) {
13
+ .poa-t:hover { text-decoration: underline; }
14
+ }
15
+ .poa-t:focus-visible, .poa-fold:focus-visible, .poa-more:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
16
+ .poa .w { font-size: var(--fs-meta); color: var(--muted); }
17
+ .poa-fold { display: flex; align-items: center; gap: var(--space-8); border-top: 1px dashed var(--line); padding-top: var(--space-8); color: var(--muted); font-size: var(--fs-meta); }
18
+ .poa-fold[aria-expanded="true"] svg { transform: rotate(180deg); }
@@ -0,0 +1,134 @@
1
+ /* pm/page-one-answer.js — every page opens with one answer (initiative page-one-answer, job #1889, idea A308; board BatchPagesDS panel 1,
2
+ * agreed 2026-11-25). The top of Today, Work, Board and each initiative:
3
+ * 1. one sentence answers the page's question: it counts what needs you, then the rest ("2 things need you; the other 9 are moving.");
4
+ * 2. under it, only what needs you (pm-li rows, a press opens the item);
5
+ * 3. the rest folds into one line, closed by default ("9 moving · 2 waiting on others");
6
+ * 4. zero is silence: nothing needs you → "All moving." and no list.
7
+ * The block holds no primary button: it never adds a call to act to a first view (firstViewCalls counts them for `pmos pages calls`).
8
+ * Pure but firstViewCalls and reportCalls: Node imports it (page-one-answer.test.js).
9
+ *
10
+ * answerOf({ needs, moving, waiting, scope, day }) → { said, needs, moving, waiting, rest, scope, day }
11
+ * boardAnswer(rows, { stateOf, grill, scope, day }) → the Work and Board answer, from the initiative rows on screen
12
+ * iniAnswer(rows, { wait, scope, day }) → an initiative's answer, from its task rows (ini-view-model rowOf) and what waits on you
13
+ * todayAnswer(L, { day }) → Today's answer, from the log's model (Your move is its list)
14
+ * answerHtml(A, { open, list, page }) → the block; '' with no answer
15
+ * firstViewCalls(root, win) → { n, labels } the calls to act above the fold
16
+ * reportCalls(page, post) → logs [page-one-answer] once per page load; posts only a count over one (or the fix of one) */
17
+ export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
18
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
19
+ export const ALL_MOVING = 'All moving.';
20
+ export const SHOW = 5; // the Needs you rows shown before "N more"
21
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
22
+ const WD = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
23
+ /** "Wed 25 Nov" */
24
+ export function dayWord(now = Date.now()) { const d = new Date(now); return `${WD[d.getDay()]} ${d.getDate()} ${MON[d.getMonth()]}`; }
25
+ const dayKey = (d) => `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
26
+
27
+ /** The sentence and its parts. needs: [{ key, title, sub }]; moving and waiting: counts. */
28
+ export function answerOf({ needs = [], moving = 0, waiting = 0, scope = '', day = '' } = {}) {
29
+ const N = (needs || []).filter((x) => x && x.title), m = Math.max(0, moving | 0), w = Math.max(0, waiting | 0), rest = m + w;
30
+ const said = !N.length ? ALL_MOVING
31
+ : `${plural(N.length, 'thing needs', 'things need')} you` + (rest ? `; the other ${rest} ${rest === 1 ? 'is' : 'are'} moving.` : '.');
32
+ return { said, needs: N, moving: m, waiting: w, rest, scope: String(scope || ''), day: String(day || '') };
33
+ }
34
+
35
+ /** Work and Board. rows: the initiative rows on screen. stateOf(r) → { state: 'done'|'late'|'risk'|'wait'|'none'|'on', why } (bd-work.js
36
+ * rowState). grill(id) → { open, later } the first questions still open. A closed row is not counted. */
37
+ export function boardAnswer(rows, { stateOf, grill = () => null, scope = '', day = '' } = {}) {
38
+ const needs = [], restRows = [];
39
+ let moving = 0, waiting = 0;
40
+ for (const r of rows || []) {
41
+ if (!r) continue;
42
+ const s = (stateOf && stateOf(r)) || { state: 'on', why: '' };
43
+ if (s.state === 'done') continue;
44
+ const g = grill(r.id || r.key) || null, q = g && g.open > 0 && !g.later ? g.open : 0;
45
+ if (s.state === 'late' || s.state === 'risk' || q) {
46
+ const why = s.state === 'late' ? (s.why || 'Late') : s.state === 'risk' ? (s.why || 'Due soon') : plural(q, 'first question open', 'first questions open');
47
+ needs.push({ key: r.key || r.id, title: r.title || r.name || r.id, sub: why, rank: s.state === 'late' ? 0 : s.state === 'risk' ? 1 : 2 });
48
+ } else if (s.state === 'wait') { waiting += 1; restRows.push({ key: r.key || r.id, title: r.title || r.name || r.id, sub: 'Waiting on others' }); }
49
+ else { moving += 1; restRows.push({ key: r.key || r.id, title: r.title || r.name || r.id, sub: '' }); }
50
+ }
51
+ needs.sort((a, b) => a.rank - b.rank);
52
+ return { ...answerOf({ needs, moving, waiting, scope, day }), restRows };
53
+ }
54
+
55
+ /** An initiative. rows: its task rows (ini-view-model rowOf: { uid, title, closed, late, owner: 'You' | name, end, due }). wait: what waits on
56
+ * you there ({ title, sub }) or null. Yours, open, and late or due today need you; another's late task waits on others; the rest moves. */
57
+ export function iniAnswer(rows, { wait = null, scope = '', day = '', today = new Date() } = {}) {
58
+ const t = dayKey(today), needs = [], restRows = [];
59
+ let moving = 0, waiting = 0;
60
+ if (wait && wait.title) needs.push({ key: '', title: wait.title, sub: wait.sub || '', act: 'summary' });
61
+ for (const x of rows || []) {
62
+ if (!x || x.closed) continue;
63
+ const mine = x.owner === 'You', dueNow = !!x.end && String(x.end).slice(0, 10) <= t;
64
+ if (mine && (x.late || dueNow)) needs.push({ key: x.uid || '', title: x.title, sub: x.late ? x.lateText || 'Late' : 'Due today', act: 'task' });
65
+ else if (!mine && x.owner && x.late) { waiting += 1; restRows.push({ key: x.uid || '', title: x.title, sub: x.owner + ' · ' + (x.lateText || 'late'), act: 'task' }); }
66
+ else { moving += 1; restRows.push({ key: x.uid || '', title: x.title, sub: x.owner && x.owner !== 'You' ? x.owner : '', act: 'task' }); }
67
+ }
68
+ return { ...answerOf({ needs, moving, waiting, scope, day }), restRows };
69
+ }
70
+
71
+ /** Today: Your move is its Needs you list (cozy-today-model.js yourMove); the day's other rows and Later are the rest. */
72
+ export function todayAnswer(L, { day = '' } = {}) {
73
+ const needs = ((L && (L.move || L.first)) || []).map((r) => ({ key: r.key, title: r.title, sub: r.why || '' }));
74
+ const moving = ((L && L.todayRows) || []).length + ((L && L.wait) || []).length;
75
+ return answerOf({ needs, moving, waiting: 0, scope: '', day }); // the page's own head says the day: said once
76
+ }
77
+
78
+ const CHEV = '<svg viewBox="0 0 24 24" width="14" height="14" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M7 10l5 5 5-5"/></svg>';
79
+ const row = (x, page) => `<div class="pm-li poa-r" data-poa-key="${esc(x.key)}"><span class="poa-dot" aria-hidden="true"></span><span class="txt">`
80
+ + `<button type="button" class="t poa-t" data-poa="open" data-poa-key="${esc(x.key)}"${x.act ? ` data-poa-act="${esc(x.act)}"` : ''} aria-label="${esc('Open ' + x.title)}">${esc(x.title)}</button>`
81
+ + `${x.sub ? `<span class="w pm-meta">${esc(x.sub)}</span>` : ''}</span></div>`;
82
+
83
+ /** The block. o.list === false: the page draws its own Needs you list under the sentence (Today's Your move). o.open: the fold is open. */
84
+ export function answerHtml(A, o = {}) {
85
+ if (!A || !A.said) return '';
86
+ const page = o.page || '';
87
+ const meta = [A.scope, A.day].filter(Boolean).join(' · ');
88
+ let h = `<section class="poa pm-block" aria-label="What needs you" data-poa-page="${esc(page)}"><div class="poa-said"><p class="poa-line">${esc(A.said)}</p>${meta ? `<span class="pm-meta">${esc(meta)}</span>` : ''}</div>`;
89
+ // zero is silence: no Needs you list, no count of zero
90
+ if (A.needs.length && o.list !== false) {
91
+ const shown = o.more ? A.needs : A.needs.slice(0, SHOW), more = A.needs.length - shown.length;
92
+ h += `<div class="poa-needs"><h2 class="pm-h-sm">Needs you</h2><div class="rows">${shown.map((x) => row(x, page)).join('')}</div>`
93
+ + (more > 0 ? `<button type="button" class="pm-fold poa-more" data-poa="more" aria-expanded="false">${esc(more + ' more')}${CHEV}</button>` : '') + '</div>';
94
+ }
95
+ const parts = [A.moving ? A.moving + ' moving' : '', A.waiting ? A.waiting + ' waiting on others' : ''].filter(Boolean);
96
+ if (parts.length && o.list !== false) {
97
+ h += `<button type="button" class="pm-fold poa-fold" data-poa="fold" aria-expanded="${!!o.open}">${CHEV}<span>${esc(parts.join(' · '))}</span></button>`;
98
+ if (o.open && (A.restRows || []).length) h += `<div class="rows poa-rest">${A.restRows.map((x) => row(x, page)).join('')}</div>`;
99
+ }
100
+ return h + '</section>';
101
+ }
102
+
103
+ /* ── the one-call check ── */
104
+ export const CALL_SEL = '.pm-btn.primary, [data-call]';
105
+ /** The calls to act that show in the first view: a primary button or a [data-call] whose box starts above the fold and is drawn. */
106
+ export function firstViewCalls(root, win) {
107
+ const W = win || (typeof window !== 'undefined' ? window : null);
108
+ if (!root || !W) return { n: 0, labels: [] };
109
+ const fold = W.innerHeight || 0, labels = [];
110
+ for (const el of root.querySelectorAll(CALL_SEL)) {
111
+ const b = el.getBoundingClientRect ? el.getBoundingClientRect() : null;
112
+ if (!b || b.width === 0 || b.height === 0 || b.top >= fold || b.bottom <= 0) continue;
113
+ labels.push(String(el.getAttribute('aria-label') || el.textContent || '').trim().slice(0, 60));
114
+ }
115
+ return { n: labels.length, labels };
116
+ }
117
+ const REPORTED = new Set();
118
+ /** Once per page load: counts the first view's calls and says it in the console. It posts to the local record (lib/page-one-answer.js) only a count over one, or the next count of a page it flagged. */
119
+ export function reportCalls(page, post, root) {
120
+ if (!page || REPORTED.has(page) || typeof document === 'undefined') return null;
121
+ REPORTED.add(page);
122
+ const C = firstViewCalls(root || document.body);
123
+ console.info(`[page-one-answer] page=${page} calls=${C.n}`);
124
+ if (C.n > 1) console.warn(`[page-one-answer] ${page}: the first view has ${C.n} calls to act (${C.labels.join(', ')}); one is the most it should have`);
125
+ // Nothing is written on a plain load: post only a page with more than one call, or one that this browser posted as flagged before
126
+ // (so `pmos pages calls` clears it once it is fixed).
127
+ const key = 'pmos.poa.flagged.' + page;
128
+ let was = false; try { was = localStorage.getItem(key) === '1'; } catch { /* no storage */ }
129
+ if (typeof post === 'function' && (C.n > 1 || was)) {
130
+ try { if (C.n > 1) localStorage.setItem(key, '1'); else localStorage.removeItem(key); } catch { /* no storage */ }
131
+ Promise.resolve().then(() => post('/api/page-calls', { page, calls: C.n, labels: C.labels })).catch(() => {});
132
+ }
133
+ return C;
134
+ }
@@ -9,7 +9,7 @@
9
9
  * due(saved, now) → true when the four are worked out again: none saved, or saved a week or more ago
10
10
  * toolbarHtml(ids, o) → the toolbar: the four icon buttons (data-pw-act). o: { picked, jiraPicked }
11
11
  * pickLineHtml(act, n) → the line while picking: "Pick the tasks to change · Esc to stop", then "Who for 2 tasks" with its button
12
- * moreGroups(o) → [{ group, items: [{ act, label, icon }] }] for ⋯. Plan and Jira only while rows are picked (Move the
12
+ * moreGroups(o) → [{ group, items: [{ act, label, icon }] }] for ⋯. Print (Print or PDF) always, last. Plan and Jira only while rows are picked (Move the
13
13
  * dates always: with nothing picked it moves every open task); View always. o: { bar, picked, one, oneJira,
14
14
  * allJira, oneOpen, view, src, tl }. An action that does not apply is not there. bar (the toolbar's ids,
15
15
  * default DEFAULT): Who, Set the date or Stage left off it go in a first group, Change, while rows are
@@ -33,7 +33,7 @@ export const IC = {
33
33
  stage: 'M5 7h14M5 12h10M5 17h6', shift: 'M4 12h14M14 8l4 4-4 4', epic: 'M13 3L5 14h6l-1 7 8-11h-6z',
34
34
  sprint: 'M4 12h11M11 8l4 4-4 4M19 6v12', flag: 'M6 21V4M6 4h11l-2 4 2 4H6', gantt: 'M4 6h9M8 12h10M6 18h7', cols: 'M4 5h16v14H4zM9 5v14M15 5v14',
35
35
  span: 'M4 12h16M4 8v8M20 8v8', parts: 'M5 7h14M5 12h14M5 17h14', jira: 'M12 3l9 9-9 9-9-9zM12 8l4 4-4 4-4-4z', full: 'M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5',
36
- tree: 'M6 5v14M6 12h8M6 19h8', done: 'M5 12.5l4.5 4.5L19 7.5', src: 'M4 6h16l-6 7v5l-4 2v-7z',
36
+ tree: 'M6 5v14M6 12h8M6 19h8', 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', done: 'M5 12.5l4.5 4.5L19 7.5', src: 'M4 6h16l-6 7v5l-4 2v-7z',
37
37
  };
38
38
  /** The toolbar's candidates, in the order the default and a tie keep. `pick: true` acts on picked rows (with none picked it starts picking). */
39
39
  export const ACTIONS = Object.freeze({
@@ -99,7 +99,9 @@ export function moreGroups(o = {}) {
99
99
  if (o.src) view.push(it('src', 'Source', IC.src));
100
100
  view.push(it('parts', 'Every part', IC.parts));
101
101
  const jira = o.picked && o.one && o.oneJira ? [it('jira', 'Status in Jira', IC.jira)] : [];
102
- return [{ group: 'Change', items: change }, { group: 'Plan', items: plan }, { group: 'View', items: view }, { group: 'Jira', items: jira }].filter((g) => g.items.length);
102
+ // Print or PDF (job #1911, A379): always, on a desk and a phone; it prints the popup in the one print layout (pm/print-pdf.js)
103
+ const print = [it('print', 'Print or PDF', IC.print)];
104
+ return [{ group: 'Change', items: change }, { group: 'Plan', items: plan }, { group: 'View', items: view }, { group: 'Jira', items: jira }, { group: 'Print', items: print }].filter((g) => g.items.length);
103
105
  }
104
106
  export const iconOf = (d, w = 14) => SV(d, w);
105
107