create-pmos 0.826.0 → 0.828.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 (55) hide show
  1. package/package.json +121 -55
  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/bin/pmos.js +19 -9
  7. package/workspace/changelog.json +120 -16
  8. package/workspace/guide/cli.md +42 -0
  9. package/workspace/lib/arch-warns.js +121 -0
  10. package/workspace/lib/board-cli.js +5 -1
  11. package/workspace/lib/code-map-cli.js +11 -3
  12. package/workspace/lib/features.json +3 -0
  13. package/workspace/lib/five-action-cap.js +84 -0
  14. package/workspace/lib/goals-cli.js +5 -0
  15. package/workspace/lib/people-cli.js +43 -2
  16. package/workspace/lib/pmos-verbs.js +10 -1
  17. package/workspace/lib/portfolio-cli.js +64 -0
  18. package/workspace/lib/portfolio.js +168 -0
  19. package/workspace/lib/review-reasons.js +357 -0
  20. package/workspace/lib/route-modules.js +3 -0
  21. package/workspace/lib/routes-arch-warns.js +39 -0
  22. package/workspace/lib/routes-onboard.js +18 -3
  23. package/workspace/lib/routes-portfolio.js +50 -0
  24. package/workspace/lib/routes-stakeholders.js +42 -0
  25. package/workspace/lib/routes-strategy-card.js +29 -1
  26. package/workspace/lib/routes-use-log.js +6 -1
  27. package/workspace/lib/stakeholder-map.js +232 -0
  28. package/workspace/lib/starter-goals.js +244 -0
  29. package/workspace/lib/voice-cli.js +7 -0
  30. package/workspace/package-lock.json +2 -2
  31. package/workspace/package.json +1 -1
  32. package/workspace/premium-vw-jira-test.js +6 -2
  33. package/workspace/public/pm/bd-principles.js +12 -1
  34. package/workspace/public/pm/cozy-onboard.css +4 -0
  35. package/workspace/public/pm/cozy-onboard.js +17 -1
  36. package/workspace/public/pm/cozy-pick.css +1 -0
  37. package/workspace/public/pm/cozy-pop-work.js +37 -2
  38. package/workspace/public/pm/cozy-today-app.js +48 -1
  39. package/workspace/public/pm/cozy-today-view.js +12 -4
  40. package/workspace/public/pm/five-action-cap.js +104 -0
  41. package/workspace/public/pm/pop-work-model.js +6 -0
  42. package/workspace/public/pm/portfolio.js +67 -0
  43. package/workspace/public/pm/product-switcher.js +7 -1
  44. package/workspace/public/pm/review-reasons.js +75 -0
  45. package/workspace/public/pm/stakeholder-map.js +125 -0
  46. package/workspace/public/pm/starter-goals.js +35 -0
  47. package/workspace/public/premium-portfolio.html +48 -0
  48. package/workspace/server.js +1 -1
  49. package/workspace/stage-card-tasks-test.js +11 -5
  50. package/workspace/test-lists/arch-warns.json +9 -0
  51. package/workspace/test-lists/five-action-cap.json +9 -0
  52. package/workspace/test-lists/portfolio.json +9 -0
  53. package/workspace/test-lists/review-reasons.json +9 -0
  54. package/workspace/test-lists/stakeholder-map.json +9 -0
  55. package/workspace/test-lists/starter-goals.json +9 -0
@@ -0,0 +1,244 @@
1
+ 'use strict';
2
+ /* starter-goals.js — starter goals drafted from the product's own sources, offered once after setup (initiative starter-goals, job #1916,
3
+ * idea A84; board BatchMoreBDS panel 32, agreed 2026-11-25). `pmos goals …`.
4
+ *
5
+ * WHY. A new product ends setup with one drafted goal at most (lib/onboard-fundamentals.js). Generic industry packs would fill the list with
6
+ * goals that are not the PM's. The product's own files already say what it is for, so PMOS drafts from those and nothing else.
7
+ *
8
+ * sourcesOf(root, { runtimeDir }) → { name, goalsLine, purpose, readme, tickets, setupKr } what the drafts may come from
9
+ * draftsOf(sources) PURE → [{ n, kind: 'goal', text, source: { label, ref } }] at most MAX, each with a source
10
+ * draft(root, { runtimeDir, now }) → { ok, drafted, rows } | { ok: false, why } ONCE per product; refuses when goals exist already
11
+ * view(root) → { rows } the drafts still open (state 'draft'); none decided rows (zero is silence)
12
+ * keep(root, n) · drop(root, n) · undo(root) → { ok, … } every change of the store, from the page or `pmos goals`
13
+ * CLI: pmos goals [starter|draft|keep <n>|drop <n>|undo] [--json] [--root <dir>]
14
+ *
15
+ * WHERE THE DRAFTS COME FROM. Only the product's own files:
16
+ * - project-context.md: its "Goals and metrics" line (split into its items) and the Purpose sentence that names an aim (increase, reduce …);
17
+ * - the README: the bullets of a Goals / Objectives / Success section;
18
+ * - tickets: the "Sources read during setup" lines from a tracker (Jira, Atlassian, Linear, GitHub issues) and the product's tickets in the
19
+ * stored My work read (<runtime>/my-work/read.json, items whose key carries the product's Jira key). The first 40; a word that 3 or more of
20
+ * them name becomes "Fewer tickets about <word>", sourced as the count. No target number is ever invented (the proven-only rule).
21
+ * A candidate with no source label is never offered. None equals the setup draft's key result, and no two are alike.
22
+ *
23
+ * THE STORE. <state>/starter-goals.json (pmos/state in a kit): { drafted_at, rows: [{ n, kind, text, source, state, kr? }], undo: [...] }.
24
+ * The page and `pmos goals` read and write only this, so a chat write lands where the page reads (CHAT WRITES ALWAYS LAND).
25
+ * KEEP writes the draft as `- **KR-S<n>** <text>. Source: <label>.` under `## O-S — Starter goals` in planning/okrs/okrs-starter.md, which
26
+ * lib/okr-goals.js reads like any goal file. Until then a draft is in no goal file, so no report counts it. okrs-draft.md is never touched.
27
+ * Every log line carries [starter-goals]; each keep records the use-log control starterGoalKept (the health number). */
28
+ const fs = require('fs');
29
+ const path = require('path');
30
+
31
+ const TAG = '[starter-goals]';
32
+ const MAX = 3;
33
+ const TICKETS = 40;
34
+ const THEME_MIN = 3;
35
+ const STORE = 'starter-goals.json';
36
+ const FILE = 'okrs-starter.md';
37
+ const DRAFT_FILE = 'okrs-draft.md';
38
+ const TRACKER = /\b(jira|atlassian|linear|github issues?|tickets?)\b/i;
39
+ const AIM = /\b(increase|reduce|cut|grow|improve|raise|lower|double|halve|help|make|let|enable|get|reach|keep)\b/i;
40
+ const STOP = new Set(('a an the and or but for with from into onto over under about after before when where while this that these those '
41
+ + 'their there they them then than have has had will would could should must can not no yes all any some each more most less few many '
42
+ + 'make made does done doing being been were was are is its it’s it\'s our your you we us via per new add adds added update updates updated '
43
+ + 'fix fixes fixed bug bugs task tasks story stories epic issue issues ticket tickets page pages user users test tests use used using also '
44
+ + 'show shows when what which who why how first last next only just like into need needs should able').split(/\s+/));
45
+
46
+ const one = (s, n = 200) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
47
+ const clip = (s, n) => { s = one(s, 1000); return s.length > n ? s.slice(0, n - 1).replace(/\s+\S*$/, '') + '…' : s; };
48
+ const norm = (s) => one(s, 400).toLowerCase().replace(/[^a-z0-9 ]+/g, ' ').replace(/\s+/g, ' ').trim();
49
+ const day = (t) => new Date(t).toISOString().slice(0, 10);
50
+ const log = (o, line) => { try { (o.log || ((s) => console.error(s)))(TAG + ' ' + line); } catch { /* a log line never fails a press */ } };
51
+
52
+ function pmosIn(root) { return require('./project-onboard.js').pmosIn(root); }
53
+ function planningOf(root) { const pm = pmosIn(root); return pm ? pm.planning : path.join(root, 'planning'); }
54
+ function stateDirOf(root) { const pm = pmosIn(root); return pm && pm.kit ? path.join(pm.kit, 'state') : path.join(root, 'pmos', 'state'); }
55
+ const storeFile = (root) => path.join(stateDirOf(root), STORE);
56
+ const goalFile = (root) => path.join(planningOf(root), 'okrs', FILE);
57
+ function readStore(root) { try { const v = JSON.parse(fs.readFileSync(storeFile(root), 'utf8')); return v && Array.isArray(v.rows) ? v : null; } catch { return null; } }
58
+ function writeStore(root, v) { const f = storeFile(root); fs.mkdirSync(path.dirname(f), { recursive: true }); const tmp = f + '.tmp'; fs.writeFileSync(tmp, JSON.stringify(v, null, 1) + '\n'); fs.renameSync(tmp, f); return v; }
59
+ const readText = (f) => { try { return fs.readFileSync(f, 'utf8'); } catch { return null; } };
60
+
61
+ /* ── sources ── */
62
+ function readmeGoals(root) {
63
+ let names = []; try { names = fs.readdirSync(root); } catch { return null; }
64
+ const rn = names.find((n) => /^readme(\.md)?$/i.test(n)); if (!rn) return null;
65
+ const text = readText(path.join(root, rn)) || '';
66
+ const lines = text.split('\n');
67
+ const i = lines.findIndex((l) => /^#{1,3}\s+(goals?|objectives?|success( metrics| criteria)?|what success looks like)\b/i.test(l));
68
+ if (i < 0) return null;
69
+ const heading = one(lines[i].replace(/^#+\s*/, ''), 60);
70
+ const items = [];
71
+ for (let j = i + 1; j < lines.length && !/^#{1,3}\s/.test(lines[j]); j++) { const m = /^\s*[-*+]\s+(?:\[[ x]\]\s+)?(.+)$/.exec(lines[j]); if (m) items.push(one(m[1].replace(/\*\*|`/g, ''), 200)); }
72
+ return items.length ? { file: rn, heading, items: items.slice(0, 5) } : null;
73
+ }
74
+ function setupTickets(text) {
75
+ const out = []; const s = String(text || ''); const at = s.indexOf('## Sources read during setup'); if (at < 0) return out;
76
+ for (const m of s.slice(at).matchAll(/^- (.+?)(?: — (https:\S+))? \(([^)]+)\)$/gm)) if (TRACKER.test(m[3])) out.push({ title: one(m[1], 200), label: one(m[3], 40) });
77
+ return out;
78
+ }
79
+ function myWorkTickets(runtimeDir, key) {
80
+ if (!runtimeDir || !key) return [];
81
+ let r = null; try { r = JSON.parse(fs.readFileSync(path.join(runtimeDir, 'my-work', 'read.json'), 'utf8')); } catch { return []; }
82
+ const items = (r && (r.items || (r.read && r.read.items))) || [];
83
+ return items.filter((x) => x && new RegExp('^' + key + '-\\d+$').test(String(x.key || ''))).map((x) => ({ title: one(x.title, 200), label: 'Jira' }));
84
+ }
85
+ function sourcesOf(root, { runtimeDir = null } = {}) {
86
+ const P = require('./project-onboard.js');
87
+ const ctxText = readText(path.join(planningOf(root), 'project-context.md'));
88
+ const ctx = ctxText == null ? { name: '', fields: {}, jira: null, goal: null } : P.readContext(ctxText);
89
+ const f = ctx.fields || {};
90
+ const label = (v) => (v && v.source === 'finding' && v.source_label ? v.source_label + ' · project-context.md' : 'project-context.md');
91
+ const seen = new Set(), tickets = [];
92
+ for (const t of [...setupTickets(ctxText), ...myWorkTickets(runtimeDir, ctx.jira && ctx.jira.key)]) { const k = norm(t.title); if (!k || seen.has(k)) continue; seen.add(k); tickets.push(t); }
93
+ const draftText = readText(path.join(planningOf(root), 'okrs', DRAFT_FILE)) || '';
94
+ const setupKr = ((/\*\*KR1\*\*\s*(?:PROPOSED:\s*)?(.+?)\. Measure:/.exec(draftText) || [])[1]) || (ctx.goal && ctx.goal.kr) || '';
95
+ return { name: ctx.name || path.basename(root),
96
+ goalsLine: f.goals && f.goals.value ? { value: f.goals.value, label: label(f.goals) } : null,
97
+ purpose: f.purpose && f.purpose.value ? { value: f.purpose.value, label: 'purpose · ' + label(f.purpose) } : null,
98
+ readme: readmeGoals(root), tickets: tickets.slice(0, TICKETS), setupKr };
99
+ }
100
+
101
+ /* ── drafts (PURE) ── */
102
+ function themes(tickets) {
103
+ const count = new Map();
104
+ for (const t of tickets || []) {
105
+ const words = new Set(norm(t.title).split(' ').filter((w) => w.length >= 4 && !STOP.has(w) && !/^\d+$/.test(w)));
106
+ for (const w of words) count.set(w, (count.get(w) || 0) + 1);
107
+ }
108
+ return [...count].filter(([, n]) => n >= THEME_MIN).sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0])).slice(0, 2);
109
+ }
110
+ function draftsOf(S = {}) {
111
+ const cands = [];
112
+ const add = (text, label, ref) => cands.push({ text: clip(String(text || '').replace(/[.;:]+$/, ''), 160), source: { label: one(label, 80), ref: one(ref, 120) } });
113
+ if (S.goalsLine) for (const item of String(S.goalsLine.value).split(/;|\s·\s|(?<=[a-z0-9%])\.\s+(?=[A-Z])/)) add(item, S.goalsLine.label, 'Goals and metrics');
114
+ if (S.readme) for (const item of S.readme.items) add(item, S.readme.file + ' · ' + S.readme.heading, S.readme.file);
115
+ const tickets = S.tickets || [];
116
+ for (const [w, n] of themes(tickets)) {
117
+ const where = [...new Set(tickets.map((t) => t.label))].join(', ') || 'tickets';
118
+ add('Fewer tickets about ' + w, `${n} of ${tickets.length} tickets in ${where} name “${w}”`, 'tickets read during setup');
119
+ }
120
+ if (S.purpose) { const s = String(S.purpose.value).split(/(?<=[.!?])\s+/).find((x) => AIM.test(x)); if (s) add(s, S.purpose.label, 'Purpose'); }
121
+ const out = [], seen = new Set([norm(S.setupKr)].filter(Boolean));
122
+ for (const c of cands) {
123
+ const k = norm(c.text);
124
+ if (!k || k.split(' ').length < 2 || seen.has(k)) continue;
125
+ if (!c.source.label || !c.source.ref) continue; // a draft without a source is never offered
126
+ seen.add(k); out.push({ n: out.length + 1, kind: 'goal', text: c.text, source: c.source });
127
+ if (out.length >= MAX) break;
128
+ }
129
+ return out;
130
+ }
131
+
132
+ /* ── the store ── */
133
+ /** Goal files other than the setup draft and this file: a product that has them gets no starter goals. */
134
+ function hasGoals(root) {
135
+ try { const r = require('./okr-goals.js').read(root); return (r.files || []).some((f) => ![DRAFT_FILE, FILE].includes(path.basename(f))) && (r.objectives || []).length > 0; }
136
+ catch { return false; }
137
+ }
138
+ function draft(root, o = {}) {
139
+ const now = o.now || Date.now();
140
+ const have = readStore(root);
141
+ if (have) return { ok: true, drafted: false, rows: have.rows.filter((r) => r.state === 'draft') };
142
+ if (hasGoals(root)) { log(o, `skipped root=${path.basename(root)} why=has-goals`); return { ok: false, why: 'has-goals', error: 'This product has goals already, so PMOS drafts no starter goals.' }; }
143
+ const rows = draftsOf(o.sources || sourcesOf(root, o)).map((r) => ({ ...r, state: 'draft' }));
144
+ if (!rows.length) { log(o, `none root=${path.basename(root)}`); return { ok: false, why: 'no-sources', rows: [] }; }
145
+ writeStore(root, { drafted_at: new Date(now).toISOString(), rows, undo: [] });
146
+ log(o, `drafted ${rows.length} root=${path.basename(root)} sources=${[...new Set(rows.map((r) => r.source.ref))].join('|')}`);
147
+ return { ok: true, drafted: true, rows };
148
+ }
149
+ function view(root) {
150
+ const s = readStore(root);
151
+ return { rows: s ? s.rows.filter((r) => r.state === 'draft').map(({ n, kind, text, source }) => ({ n, kind, text, source })) : [] };
152
+ }
153
+ const header = (name, today) => ['---', 'type: OKR', `title: "Starter goals: ${String(name).replace(/"/g, "'")}"`, `timestamp: ${today}`, '---', '',
154
+ `# Starter goals: ${name}`, '', `PMOS drafted these from ${name}'s own sources, and you kept each one. Change or remove a line here or in Goals.`, '',
155
+ '## O-S — Starter goals', ''].join('\n');
156
+ const krLine = (r) => `- **KR-S${r.n}** ${r.text.replace(/\n/g, ' ')}. Source: ${r.source.label}.`;
157
+ function rowOf(s, n) { return s && s.rows.find((r) => r.n === Number(n)); }
158
+
159
+ function keep(root, n, o = {}) {
160
+ const now = o.now || Date.now();
161
+ const s = readStore(root), r = rowOf(s, n);
162
+ if (!r) return { ok: false, error: 'There is no starter goal ' + n + '.' };
163
+ if (r.state !== 'draft') return { ok: false, error: 'Starter goal ' + n + ' was ' + (r.state === 'kept' ? 'kept' : 'dropped') + ' already.' };
164
+ const f = goalFile(root);
165
+ const before = readText(f);
166
+ const name = (o.sources && o.sources.name) || sourcesOf(root, o).name;
167
+ const line = krLine(r);
168
+ const after = (before == null ? header(name, day(now)) : before.replace(/\n*$/, '\n')) + line + '\n';
169
+ fs.mkdirSync(path.dirname(f), { recursive: true }); fs.writeFileSync(f, after);
170
+ r.state = 'kept'; r.kr = 'KR-S' + r.n;
171
+ s.undo.push({ act: 'keep', n: r.n, line, made: before == null, at: new Date(now).toISOString() });
172
+ writeStore(root, s);
173
+ log(o, `kept n=${r.n} file=${path.relative(root, f)}`);
174
+ try { require('./use-log.js').record(o.useDir || require('./state-root.js').defaultRoot({ env: o.env || process.env }), [{ kind: 'use', page: 'today', control: 'starterGoalKept', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ }
175
+ return { ok: true, n: r.n, kr: r.kr, file: path.relative(root, f), rows: view(root).rows };
176
+ }
177
+ function drop(root, n, o = {}) {
178
+ const s = readStore(root), r = rowOf(s, n);
179
+ if (!r) return { ok: false, error: 'There is no starter goal ' + n + '.' };
180
+ if (r.state !== 'draft') return { ok: false, error: 'Starter goal ' + n + ' was ' + (r.state === 'kept' ? 'kept' : 'dropped') + ' already.' };
181
+ r.state = 'dropped'; s.undo.push({ act: 'drop', n: r.n, at: new Date(o.now || Date.now()).toISOString() });
182
+ writeStore(root, s);
183
+ log(o, `dropped n=${r.n}`);
184
+ return { ok: true, n: r.n, rows: view(root).rows };
185
+ }
186
+ function undo(root, o = {}) {
187
+ const s = readStore(root);
188
+ const last = s && s.undo[s.undo.length - 1];
189
+ if (!last) return { ok: false, error: 'Nothing to undo.' };
190
+ const r = rowOf(s, last.n);
191
+ if (last.act === 'keep') {
192
+ const f = goalFile(root), text = readText(f);
193
+ if (text == null || !text.split('\n').includes(last.line)) { log(o, `undo-refused n=${last.n} why=edited`); return { ok: false, error: `${path.relative(root, f)} changed since, so PMOS leaves it. Remove the line yourself if you want.` }; }
194
+ const after = text.split('\n').filter((l) => l !== last.line).join('\n');
195
+ if (last.made && !/^\s*[-*]\s*\*\*KR-/m.test(after)) fs.unlinkSync(f); else fs.writeFileSync(f, after);
196
+ delete r.kr;
197
+ }
198
+ r.state = 'draft'; s.undo.pop(); writeStore(root, s);
199
+ log(o, `undone ${last.act} n=${last.n}`);
200
+ return { ok: true, act: last.act, n: last.n, rows: view(root).rows };
201
+ }
202
+
203
+ /* ── CLI ── */
204
+ const COMMANDS = { goals: ['starter', 'draft', 'keep', 'drop', 'undo'] };
205
+ const USAGE = [
206
+ 'pmos goals — starter goals PMOS drafts from your own product (its project context, README and tickets)',
207
+ ' pmos goals starter the open drafts, each with its source (the same rows as the setup page)',
208
+ ' pmos goals draft draft them once, when the product has no goals beyond the setup draft',
209
+ ' pmos goals keep <n> keep draft n: it becomes key result KR-S<n> in planning/okrs/okrs-starter.md',
210
+ ' pmos goals drop <n> drop draft n; it writes no goal',
211
+ ' pmos goals undo undo the newest keep or drop',
212
+ 'A draft counts in no report until you keep it. Nothing is sent.',
213
+ ];
214
+ function repoOf(cwd) {
215
+ let d = path.resolve(cwd);
216
+ for (;;) { if (fs.existsSync(path.join(d, '.git')) || pmosIn(d)) return d; const up = path.dirname(d); if (up === d) return path.resolve(cwd); d = up; }
217
+ }
218
+ function run(argv, o = {}) {
219
+ const say = o.say || ((s) => console.log(s));
220
+ const args = argv[0] === 'goals' ? argv.slice(1) : argv.slice();
221
+ const pos = [], flags = {};
222
+ for (let i = 0; i < args.length; i++) { const a = args[i]; if (a === '--root') flags.root = args[++i]; else if (a === '--json') flags.json = true; else pos.push(a); }
223
+ const cmd = pos[0] || 'starter';
224
+ if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return 0; }
225
+ if (!COMMANDS.goals.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos goals`); USAGE.forEach((l) => say(l)); return 2; }
226
+ const root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd()));
227
+ const opts = { ...o, runtimeDir: o.runtimeDir || (() => { try { return require('./state-root.js').defaultRoot({ env: o.env || process.env }); } catch { return null; } })() };
228
+ const r = cmd === 'starter' ? { ok: true, ...view(root) } : cmd === 'draft' ? draft(root, opts) : cmd === 'undo' ? undo(root, opts)
229
+ : (pos[1] == null ? { ok: false, error: `Say which draft: pmos goals ${cmd} <n>` } : (cmd === 'keep' ? keep : drop)(root, pos[1], opts));
230
+ if (flags.json) { say(JSON.stringify(r)); return r.ok ? 0 : 1; }
231
+ if (!r.ok) { say('✗ ' + (r.error || (r.why === 'no-sources' ? 'No source of this product names a goal yet, so PMOS drafts none.' : 'That did not work.'))); return 1; }
232
+ if (cmd === 'keep') say(`✓ Kept as ${r.kr} in ${r.file}. pmos goals undo takes it out again.`);
233
+ if (cmd === 'drop') say(`✓ Dropped starter goal ${r.n}. pmos goals undo brings it back.`);
234
+ if (cmd === 'undo') say(`✓ Undid the ${r.act} of starter goal ${r.n}.`);
235
+ const rows = r.rows || [];
236
+ if (cmd === 'starter' || cmd === 'draft') {
237
+ if (!rows.length) { say('No starter goals are open.'); return 0; }
238
+ for (const x of rows) say(`${x.n}. ${x.text} (from: ${x.source.label})`);
239
+ say('pmos goals keep <n> or drop <n>.');
240
+ }
241
+ return 0;
242
+ }
243
+
244
+ module.exports = { TAG, MAX, TICKETS, THEME_MIN, FILE, sourcesOf, draftsOf, themes, draft, view, keep, drop, undo, hasGoals, run, COMMANDS, USAGE, storeFile, goalFile };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+ /* voice-cli.js — `pmos voice`: survey comments and app-store reviews grouped by reason (initiative review-reasons, idea A427).
3
+ * A thin verb over lib/review-reasons.js run(): the same ledger (customer-voice.jsonl in the product's runs folder) that Work's
4
+ * Customer voice block reads, so what a chat adds shows on Work at the next read. Exit codes: 0 done, 1 refused, 2 usage. */
5
+ const RR = require('./review-reasons.js');
6
+
7
+ module.exports = { run: (argv, o) => RR.run(argv, o), COMMANDS: RR.COMMANDS, USAGE: RR.USAGE };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.826.0",
3
+ "version": "0.828.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.826.0",
9
+ "version": "0.828.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.826.0",
3
+ "version": "0.828.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -213,15 +213,19 @@ const TICKETS = {
213
213
  for (const theme of ['light', 'dark']) {
214
214
  const S = await open({ w: 390, h: 844, theme });
215
215
  await openSprint(S.page);
216
- await until(() => S.page.$('.jcrd[data-k="PMOS-142"]'));
216
+ // Wait for the card INSIDE the shown Viewer pane: on a busy runner the card can exist before the pane is shown, and the
217
+ // read below then found no pane and threw (#1883, 2026-11-25). A pane that never shows fails F1 with its reason instead.
218
+ await until(() => S.page.$('#czViewer:not([hidden]) .obody.vw .jcrd[data-k="PMOS-142"]'), 30000);
217
219
  await sleep(400);
218
220
  const f = await S.page.evaluate(() => {
219
221
  const pane = document.querySelector('#czViewer:not([hidden]) .obody.vw');
222
+ if (!pane || !pane.querySelector('.jcrd b')) return { missing: pane ? 'no sprint card in the Viewer pane' : 'no shown Viewer pane' };
220
223
  const small = [...pane.querySelectorAll('button.jcrd,.jseg button,.jbtn')].filter((b) => b.getBoundingClientRect().height && b.getBoundingClientRect().height < 44).map((b) => b.textContent.trim().slice(0, 30));
221
224
  const crd = getComputedStyle(pane.querySelector('.jcrd')).backgroundColor, ink = getComputedStyle(pane.querySelector('.jcrd b')).color;
222
225
  return { wide: document.documentElement.scrollWidth > innerWidth + 1, paneWide: pane.scrollWidth > pane.clientWidth + 1, small, crd, ink };
223
226
  });
224
- ok(`F1 ${theme}: 390 px has no sideways scroll and every target is 44 px or more`, !f.wide && !f.paneWide && !f.small.length, JSON.stringify(f));
227
+ ok(`F1 ${theme}: 390 px has no sideways scroll and every target is 44 px or more`, !f.missing && !f.wide && !f.paneWide && !f.small.length, JSON.stringify(f));
228
+ if (f.missing) { ok(`F2 ${theme}: cards follow the theme`, false, f.missing); await S.ctx.close(); continue; }
225
229
  const lum = (c) => { const m = c.match(/\d+(\.\d+)?/g).map(Number); return (m[0] * 299 + m[1] * 587 + m[2] * 114) / 1000; };
226
230
  ok(`F2 ${theme}: cards follow the theme`, theme === 'dark' ? lum(f.ink) > lum(f.crd) : lum(f.ink) < lum(f.crd), JSON.stringify(f));
227
231
  await S.ctx.close();
@@ -9,9 +9,11 @@
9
9
  * · Drafts after them, each with ✦, its why, its sources, and ✓ keep / ✕ drop. A press offers Undo in the Board's toast.
10
10
  * · While PMOS drafts them: one quiet line. No principle and no draft: no block (zero is silence).
11
11
  * The controls are named bdPrinKeep and bdPrinDrop (the button's name, its value the principle's id; one per row, so no id) and each press
12
- * notes that name in the local use log (noteUse), which counts their use (the bet's kill line). */
12
+ * notes that name in the local use log (noteUse), which counts their use (the bet's kill line).
13
+ * It also makes the Customer voice section (#cVoice, pm/review-reasons.js, idea A427) right after itself and mounts it with the same options. */
13
14
  import { pmPost } from './http.js';
14
15
  import { noteUse } from './use-log.js';
16
+ import * as VOICE from './review-reasons.js'; // Customer voice (idea A427) sits under the principles; this block hosts it so Work's page files stay as they are
15
17
 
16
18
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
17
19
  const SV = (d) => `<svg class="pm-ic" width="16" height="16" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
@@ -43,6 +45,7 @@ export function blockHtml(state) {
43
45
  export async function mount(host, opts = {}) {
44
46
  if (!host) return;
45
47
  const { ws = null, single = true, say = null } = opts;
48
+ voiceHost(host, opts);
46
49
  if (!single) { host.hidden = true; host.innerHTML = ''; return; }
47
50
  let r = null; try { r = await (await fetch('/api/principles' + (ws ? '?ws=' + encodeURIComponent(ws) : ''), { credentials: 'same-origin' })).json(); } catch { r = null; }
48
51
  if (!r || !r.ok) { host.hidden = true; return; } // the block is an extra: a failed read leaves the Board as it was
@@ -60,5 +63,13 @@ export async function mount(host, opts = {}) {
60
63
  };
61
64
  }
62
65
 
66
+ /** Customer voice (pm/review-reasons.js) gets its own section right after this one, made once, and draws itself there. */
67
+ function voiceHost(host, opts) {
68
+ if (!host.parentNode || typeof document === 'undefined') return;
69
+ let v = document.getElementById('cVoice');
70
+ if (!v) { v = document.createElement('section'); v.className = 'bd-sec'; v.id = 'cVoice'; v.setAttribute('aria-label', 'Customer voice'); v.hidden = true; host.after(v); }
71
+ VOICE.mount(v, opts).catch(() => { v.hidden = true; });
72
+ }
73
+
63
74
  /** Draw the block again after a read of the Board. */
64
75
  export const refresh = (host, opts) => mount(host, opts);
@@ -89,3 +89,7 @@ body.ob-on #hmChat[hidden] { display: none; }
89
89
  .ob-fund li em { font-style: normal; font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); overflow-wrap: anywhere; }
90
90
  .ob-fund li .ob-lk { align-self: flex-start; }
91
91
  @media (max-width: 760px) { .ob-fl { grid-template-columns: minmax(0, 1fr) auto; } .ob-fl em { grid-column: 1; } .ob-fl .ob-pen { grid-column: 2; } .ob-rv .ob-fld { grid-template-columns: minmax(0, 1fr); } }
92
+
93
+ /* starter goals under the fundamentals card (A84, board BatchMoreBDS panel 32): Keep and Drop stay in view, not only on hover */
94
+ .pm-ds .sg-block .pm-li .acts{display:flex}
95
+ .pm-ds .sg-said{margin:var(--space-12, 12px) 0 var(--space-8, 8px)}
@@ -7,11 +7,14 @@
7
7
  * 2. The first question is the product. The composer is open from the first screen; an answer typed before the check passes waits for it.
8
8
  * 3. ✦ one proposal for the folder, the read-only search and what needs a sign-in. ✓ runs it; ✕ asks what to change, in the composer.
9
9
  * 4. The findings as up to three source tiles, then ✦ "Set up PMOS in <folder> with this context". A missing line says so and has edit.
10
- * 5. After init: the fundamentals card (lib/onboard-fundamentals.js), each line with its source and one change; then ✦ the first initiative.
10
+ * 5. After init: the fundamentals card (lib/onboard-fundamentals.js), each line with its source and one change; under it the starter goals
11
+ * drafted from the product's own sources (pm/starter-goals.js, A84), each ✓ keep or ✕ drop with Undo in the toast; then ✦ the first initiative.
11
12
  * The calls to action are ✓ and ✕ only. Order is enforced by the server. Every press is the PM's (pmPost). Text from connectors is escaped. */
12
13
  import { pmGet, pmPost } from './http.js';
13
14
  import { adler } from './cozy-adler.js';
14
15
  import { signInTerminal } from './cozy-claude-setup.js';
16
+ import { starterBlock } from './starter-goals.js';
17
+ import { toast } from './primitives.js';
15
18
 
16
19
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
17
20
  const CHECK = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>';
@@ -170,6 +173,7 @@ export function mountOnboard(host, { ws = '', done = false } = {}) {
170
173
  return `<li data-key="${esc(l.key)}">${CHECK}<span><span>${esc(l.text)}</span>${meta ? `<em>${meta}</em>` : ''}</span></li>`; }).join('');
171
174
  return [{ mood: 'handled', body: `<p><b>${esc(d.name)}</b> is set up in <code>${esc(d.root)}</code>. I settled the basics for you:</p>`
172
175
  + `<ul class="ut-card ob-done ob-fund">${rows}</ul>${fd.error ? `<p class="ob-sub">${esc(fd.error)}</p>` : ''}`
176
+ + starterBlock(S.data.starter, { busy: !!S.busy })
173
177
  + prop('Draft the first initiative from the purpose, with its expected outcome', [], 'Nothing is final until you keep it.', 'first-yes', 'first-no', 'Draft the first initiative') }];
174
178
  }
175
179
 
@@ -282,6 +286,16 @@ export function mountOnboard(host, { ws = '', done = false } = {}) {
282
286
  } catch (e) { S.note = e.message || 'That did not finish. Try again.'; }
283
287
  S.busy = ''; draw();
284
288
  }
289
+ /** A84: keep, drop or undo one starter goal. The toast says what happened and carries Undo (the newest keep or drop). */
290
+ async function starter(a, n) {
291
+ S.busy = 'starter'; S.note = ''; draw();
292
+ const r = await post('starter', { act: a, n });
293
+ S.busy = ''; draw();
294
+ if (!r.ok) { S.note = r.error || 'That did not finish. Try again.'; draw(); return; }
295
+ const d = r.starter_did || {};
296
+ if (a === 'undo') { toast({ text: 'Undone.' }); return; }
297
+ toast({ text: a === 'keep' ? `Kept as a goal${d.file ? ' in ' + d.file : ''}.` : 'Dropped. It counts nowhere.', actionLabel: 'Undo', onAction: () => starter('undo') });
298
+ }
285
299
  function readReview() {
286
300
  const form = log.querySelector('form[data-ob-form="review"]'); if (!form) return null;
287
301
  const fields = {}; for (const [k] of FIELD_LABELS) { const i = form.querySelector(`input[name="${k}"]`); if (i) fields[k] = i.value; }
@@ -293,6 +307,8 @@ export function mountOnboard(host, { ws = '', done = false } = {}) {
293
307
  sec.addEventListener('click', (e) => {
294
308
  const ed = e.target.closest('[data-ob-edit]');
295
309
  if (ed) { S.editing.add(ed.dataset.obEdit); const keep = readReview(); draw(); if (keep) for (const [k, v] of Object.entries(keep.fields || {})) { const i = log.querySelector(`input[name="${k}"]`); if (i) i.value = v; } const i = log.querySelector(`input[name="${ed.dataset.obEdit}"]`); if (i) i.focus(); return; }
310
+ const sg = e.target.closest('[data-sg]');
311
+ if (sg) { if (!sg.disabled && !S.busy) starter(sg.dataset.sg, Number(sg.dataset.n)); return; }
296
312
  const b = e.target.closest('[data-ob]'); if (!b || b.disabled || S.busy) return;
297
313
  e.preventDefault(); act(b.dataset.ob);
298
314
  });
@@ -53,6 +53,7 @@
53
53
  .psw-b:hover, .psw-b:focus-visible { background: var(--cz-well); }
54
54
  .psw-b[aria-pressed="true"] { background: var(--cz-bluebg); box-shadow: 0 0 0 2px var(--cz-c-b6c6dc); }
55
55
  .psw-b .ppk-t { box-shadow: none; }
56
+ .psw-pf { color: var(--cz-muted, currentColor); text-decoration: none; } /* the Portfolio link at the end of the row (initiative portfolio) */
56
57
  .psw-dot { position: absolute; top: 1px; right: 1px; width: 8px; height: 8px; border-radius: 50%; background: var(--cz-blue); box-shadow: 0 0 0 2px var(--cz-card); }
57
58
  .hv-psw { padding: 0 0 var(--space-8); }
58
59
  @media (max-width: 760px) { .psw-b { width: 44px; height: 44px; } }
@@ -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 SMAP from './stakeholder-map.js'; // the People block: who decides, must agree, needs to know (stakeholder-map, A371)
40
41
  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)
41
42
 
42
43
  const CSS = new URL('./cozy-pop-work.css', import.meta.url).href, DSCSS = new URL('./bd-pop-ds.css', import.meta.url).href;
@@ -183,6 +184,19 @@ function artOf(id, ws) {
183
184
  }
184
185
  return ART.get(id);
185
186
  }
187
+ /* the architecture warning (arch-warns, A54): GET /api/arch-warns?ini=<id> once per initiative. null while reading or when there is nothing
188
+ * to say; the one shown is counted on this computer (control archWarnShown). */
189
+ const ARCH = new Map(); // id → warn | false (nothing to say) | null while reading
190
+ function archOf(id, ws) {
191
+ if (!id) return null;
192
+ if (!ARCH.has(id)) {
193
+ ARCH.set(id, null);
194
+ pmGet('/api/arch-warns?ini=' + encodeURIComponent(id) + (ws ? '&ws=' + encodeURIComponent(ws) : ''))
195
+ .then((x) => { const w = (x && x.ok && x.warn) || false; ARCH.set(id, w); if (w) noteUse('archWarnShown'); if (artRedraw) artRedraw(); })
196
+ .catch(() => ARCH.set(id, false)); // an older server has no such route: Work stays as it was
197
+ }
198
+ return ARCH.get(id) || null;
199
+ }
186
200
  /* a product's name, never its id (round 3 point 4): GET /api/workspaces once */
187
201
  let WSN = null, wsnRedraw = null;
188
202
  function productName(p, ws) {
@@ -423,7 +437,7 @@ function model(r, v0, o) {
423
437
  const id0 = keyOf(v0, o), pd = PEND.get(id0), v = pd && pd.desc != null ? { ...v0, desc: pd.desc } : v0;
424
438
  const id = id0, S = stOf(id), it = ITEMS.get(id);
425
439
  const g = o.goal || goalOf(o.ws, o.board, r.anchor || v.anchor);
426
- const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, subOpen: S.subOpen, subShut: S.subShut, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
440
+ const W = M.workOf(r, v, { ...o, goal: M.idShaped(g) ? '' : g, product: productName(o.product, o.ws), art: artOf(id, o.ws), arch: archOf(id, o.ws), open: S.open, shut: S.shut, moreOpen: S.moreOpen, farOpen: S.farOpen, focus: S.focus, subOpen: S.subOpen, subShut: S.subShut, mode: store.get(SPAN, 'full'), items: it || [], dropped: dropped() });
427
441
  if (pd && W.overview) for (const L of W.overview.lines || []) if (pd.lines[L.id] != null) { L.text = pd.lines[L.id]; delete L.ask; delete L.miss; }
428
442
  if (W.overview) for (const L of W.overview.lines || []) if (!L.text && DRAFTING.has(id0 + ':' + L.id)) { L.drafting = true; delete L.ask; delete L.miss; }
429
443
  const mk = M.marksOf(W.span, W.today, W.view); W.tx = mk.today;
@@ -477,7 +491,9 @@ function dsHtml(r, v, o, W, S, C, mode) {
477
491
  const crit = S.sel.size || dropped().has('crit:' + id) ? '' : critSugHtml(CRIT.get(id));
478
492
  // Overview (Wawan, 2026-11-23): Where it stands, The case and its facts in one block across the top; folded or open is the person's choice
479
493
  // one column (artefacts-in-more-menu, Wawan 2026-11-23): the Stages and the breakdown take the full width; the artefacts are in ⋯ (moreItems)
480
- return `<div class="pw pwd">${PD.overviewHtml(W, r, { oid: id, dropped: dropped(), open: ovOpen() })}<div class="pwd-main">${PD.stagesHtml(st, W)}${crit}${wbs}</div></div>`;
494
+ // the People block under the Overview (stakeholder-map, BatchPeopleDS panel 9): drawn from memory, read once per initiative; no name, no block
495
+ const ppl = SMAP.blockFor(id, o.ws, () => { if (artRedraw) artRedraw(); });
496
+ return `<div class="pw pwd">${PD.overviewHtml(W, r, { oid: id, dropped: dropped(), open: ovOpen() })}${ppl}<div class="pwd-main">${PD.stagesHtml(st, W)}${crit}${wbs}</div></div>`;
481
497
  }
482
498
 
483
499
  /** The grouping ✦ the PM said no to, for this initiative: 'group:<stage>'. */
@@ -722,7 +738,24 @@ async function draftDocs(s, x, h) {
722
738
  }
723
739
  /* a direct ✓ (bet 1f): the plan end, closing the open tasks, reopening. One press writes through POST /api/boards/ini-<act> with Undo; no chat
724
740
  * message, no session. Only when the route answers ask: true (the plain reading does not hold) do the words go to Ask PMOS, as before. */
741
+ /* the test task of an architecture warning (arch-warns, A54): one press adds the task to this initiative through the task route every other
742
+ * add uses, and the toast's Undo deletes it again. Nothing else is written, and the warning is read again after the add. */
743
+ async function testTask(d, x, h) {
744
+ const w = h.where ? h.where() : {}, id = x.o().id;
745
+ const res = await pmPost('/api/boards/tasks/add', { ws: w.ws, board: w.board, initiative: id, title: d.title }).catch(() => null);
746
+ if (!res || res.ok === false) { if (h.toast) h.toast((res && res.error) || 'The task was not added.'); return; }
747
+ noteUse('archWarnTask');
748
+ const uid = (res.item && (res.item.uid || res.item.id)) || '';
749
+ ARCH.delete(id);
750
+ if (h.reload) await h.reload();
751
+ undoToast(d.title + ' added.', async () => {
752
+ const u = uid ? await pmPost('/api/boards/tasks/delete', { ws: w.ws, board: w.board, task: uid }).catch(() => null) : null;
753
+ if (!u || u.ok === false) { if (h.toast) h.toast((u && u.error) || 'The undo did not land.'); return; }
754
+ if (h.reload) await h.reload();
755
+ });
756
+ }
725
757
  async function direct(d, ask, x, h) {
758
+ if (d.act === 'test-task') return testTask(d, x, h);
726
759
  const w = h.where ? h.where() : {}, id = x.o().id;
727
760
  const res = await pmPost('/api/boards/ini-' + d.act, { ws: w.ws, board: w.board, id, ...(d.to ? { to: d.to } : {}) }).catch(() => null);
728
761
  // the words go to Ask PMOS when the plain reading does not hold (ask), or when the route cannot be reached: pmPost answers
@@ -882,6 +915,8 @@ export function wire(body, h0, x0) {
882
915
  goalsRedraw = artRedraw = wsnRedraw = capRedraw = () => { if (body.isConnected && body.querySelector('.pw')) redraw(); };
883
916
  body.__pwcur = cur; body.__pwredraw = redraw; // ⋯ acts on the popup drawn now (capItems)
884
917
  wireGrip(body);
918
+ // the People block's presses (stakeholder-map), before the popup's own handler below
919
+ body.addEventListener('click', (e) => { SMAP.press(e, body, { say: (t) => { const hh = body.__pwh; if (hh && hh.toast) hh.toast(t); } }); });
885
920
  // a phone: a proposal swiped right says yes, left says no (its own hidden Yes and No presses, so the popup's writes and Undo stay theirs)
886
921
  wireSwipe(body, { on: phone, act: (row, way) => { const b = row.querySelector(way === 'right' ? '[data-sw-yes]' : '[data-sw-no]'); if (b) b.click(); } });
887
922
  body.addEventListener('submit', (e) => {
@@ -22,6 +22,7 @@ import { wireSwipe } from './cozy-phone-swipe.js';
22
22
  let DG = null; // quiet-rows-digest: pm/digest-view.js, loaded on a Monday only (on other days Today loads nothing of the digest)
23
23
  import { noteUse } from './use-log.js'; // your-move (A468): each press on a Your move row is one ym-act line in the local use log (its health number)
24
24
  import * as QB from './quiet-batch.js'; // quiet-rows: Today's batch, the popup (Approve, Skip, Change it first; nothing sent without a press)
25
+ import * as CAP from './five-action-cap.js'; // five-action-cap (A529): a row shows two actions and ⋯; which two comes from the use log, once a week
25
26
  import * as TO from './today-order.js'; // today-order (A310, board BatchMoreBDS panel 30): the same blocks in the day's order, and the pin
26
27
  import * as NL from './cozy-name-links.js'; // name-links (A536): names in a line you typed link to the person, meeting or document, with a small card
27
28
  import * as CC from './change-cues.js'; // idea A313: a short cue on the row that is done, moved or dropped, before the log draws again // the phone: rows and the proposal swipe (phone design, Ph2_today)
@@ -49,6 +50,50 @@ export function mountToday(ctx) {
49
50
  readDigest();
50
51
  readSync();
51
52
  readPin();
53
+ readCap();
54
+ }
55
+ /* five-action-cap: the two a row shows, worked out at most once a week from 30 days of use (GET /api/use-log/cap), kept in this browser */
56
+ const CAP_KEY = 'pmos.cap.today-row';
57
+ async function readCap() {
58
+ let saved = null;
59
+ try { saved = JSON.parse(localStorage.getItem(CAP_KEY) || 'null'); } catch { /* no storage: the defaults */ }
60
+ if (!CAP.due(saved, 'today-row')) { TP.setCapShown(saved.ids); return; }
61
+ const r = await ctx.pmGet('/api/use-log/cap?place=today-row').catch(() => null);
62
+ if (!r || !r.ok) return;
63
+ const ids = CAP.pick('today-row', r.counts, r.span);
64
+ try { localStorage.setItem(CAP_KEY, JSON.stringify({ ids, at: new Date().toISOString() })); } catch { /* kept for this visit only */ }
65
+ if (!saved || JSON.stringify(saved.ids) !== JSON.stringify(ids)) console.info('[five-action-cap] Today row shows ' + ids.join(', '));
66
+ TP.setCapShown(ids); draw();
67
+ }
68
+ /** A row's ⋯: the menu of what the row does not show, Change first. A press runs the row's own act; each is one today-row-more-<act> line. */
69
+ function capMenu(r, btn) {
70
+ document.querySelectorAll('.td-dp').forEach((x) => x.remove());
71
+ const j = r.job && ['Reply', 'Decide', 'Send'].includes(r.job);
72
+ const cap = CAP.todayRow([j ? 'open' : '', 'done', 'tomorrow', 'date'], [...btn.closest('.acts').querySelectorAll('[data-td]')].map((x) => x.dataset.td));
73
+ const box = document.createElement('div');
74
+ box.className = 'td-dp td-fp'; box.setAttribute('role', 'dialog'); box.setAttribute('aria-label', 'More: ' + r.title);
75
+ box.innerHTML = CAP.menuHtml(r.key, cap.more, { ...CAP.WORDS, open: r.job || 'Open' });
76
+ document.body.appendChild(box);
77
+ btn.setAttribute('aria-expanded', 'true');
78
+ const b = btn.getBoundingClientRect();
79
+ box.style.top = Math.min(innerHeight - box.offsetHeight - 12, b.bottom + 6) + 'px'; box.style.left = Math.max(12, b.right - box.offsetWidth) + 'px';
80
+ const close = (back) => { box.remove(); removeEventListener('pointerdown', out, true); if (btn.isConnected) { btn.setAttribute('aria-expanded', 'false'); if (back) btn.focus(); } };
81
+ const out = (e) => { if (!box.contains(e.target)) close(false); };
82
+ addEventListener('pointerdown', out, true);
83
+ const items = () => [...box.querySelectorAll('[role="menuitem"]')];
84
+ box.addEventListener('keydown', (e) => {
85
+ if (e.key === 'Escape') { e.stopPropagation(); close(true); return; }
86
+ if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return;
87
+ const L = items(), i = L.indexOf(document.activeElement); e.preventDefault();
88
+ L[(i + (e.key === 'ArrowDown' ? 1 : L.length - 1)) % L.length].focus();
89
+ });
90
+ box.addEventListener('click', (e) => {
91
+ const c = e.target.closest('[data-td]'); if (!c) return;
92
+ close(false);
93
+ noteUse('today-row-more-' + c.dataset.td);
94
+ run(c.dataset.td, r.key, btn, true);
95
+ });
96
+ const f = items()[0]; if (f) f.focus();
52
97
  }
53
98
  /* today-order (A310): the pinned order (GET /api/today-order, lib/today-order.js), the one store `pmos today order` writes too */
54
99
  async function readPin() {
@@ -633,7 +678,7 @@ export function mountToday(ctx) {
633
678
  // a phone: a row or the proposal swiped; the act is the one its button had on a desk, said in the toast with Undo
634
679
  wireSwipe(el, { on: phone, act: (row, way) => { const act = row.dataset[way === 'right' ? 'swRight' : 'swLeft']; if (act) run(act, row.dataset.key || '', { dataset: {}, disabled: false, isConnected: false }); } });
635
680
  }
636
- async function run(act, key, b) {
681
+ async function run(act, key, b, viaMore) {
637
682
  if (act === 'line') { console.info('[quiet-rows-line] dashed line opened'); return; } // the link opens Work › Line, which counts the open (qr-line)
638
683
  if (act === 'cal') { ctx.openCalendar(); return; }
639
684
  if (act === 'ord-pin') { pinPress(b); return; } // today-order: pin or unpin the order
@@ -721,6 +766,8 @@ export function mountToday(ctx) {
721
766
  if (act === 'q-remind') { remindQuestion(r.ref); return; }
722
767
  if (act === 'open') { open(r); return; }
723
768
  if (act === 'so-open') { signoffOpen(r); return; }
769
+ if (!viaMore && (act === 'done' || act === 'tomorrow' || act === 'date')) noteUse('today-row-' + act); // five-action-cap: a press on a shown button
770
+ if (act === 'cap-more') { capMenu(r, b); return; }
724
771
  if (act === 'date') { chooseDate(r, b); return; }
725
772
  if (act === 'file') { chooseFile(r, b); return; } // capture-to-initiative: the filed chip's change
726
773
  if (X.busy.has(key)) return;
@@ -9,7 +9,8 @@
9
9
  * (pm-tabs: All, Reply, Do, Decide, Send with counts, a zero tab left out), the capture Input (pm-input), then the groups: Your move
10
10
  * (the Now group, pm-group now: ranked rows with a ✦ why, five and a fold; its first row lit), Today (pm-group), and Later folded (pm-fold "N can wait"), PMOS handled folded last.
11
11
  * Row a ListRow (pm-li): the kind icon, the title, a why line ("for <work> · due <date>", or who waits), a late Badge (pm-badge alert),
12
- * and on hover or focus icon Buttons: first by job (Done, Reply, Decide, Send), then Move to tomorrow and Set a date. A ✦ Suggestion
12
+ * and on hover or focus icon Buttons: first by job (Done, Reply, Decide, Send), then Put off a day; three at most, the rest
13
+ * under ⋯ with Set a date in its Change group (five-action-cap, pm/five-action-cap.js). A ✦ Suggestion
13
14
  * under the row when PMOS proposes something on it (drop it, looks answered, draft them).
14
15
  * Side a Timeline block (pm-block flat) with the day's events only: past ones dashed (pm-ev over), the rest raised, the now line in the
15
16
  * alert colour, a link to Events; a meeting with a call has the play Button (join and record in one press, meeting-buddy). Below it,
@@ -18,7 +19,11 @@
18
19
 
19
20
  import { dashModel as lineDash, dashHtml as lineDashHtml } from './line-view.js'; // quiet-rows-line: Your move ends with the line's dashed line
20
21
  import { groupsHtml as questionGroups, phoneGroupsHtml as phoneQuestionGroups } from './open-questions-view.js'; // open-questions-today (A420)
21
- import { linkedHtml } from './cozy-name-links.js'; // name-links (A536): names in a line you typed link to the person, meeting or document
22
+ import { linkedHtml } from './cozy-name-links.js';
23
+ import * as CAP from './five-action-cap.js'; // five-action-cap (A529): a row shows three at most on hover, two actions and ⋯
24
+ /** The two a Today row shows (pm/five-action-cap.js pick, from the use log; the app sets it once a week). */
25
+ let CAP_SHOWN = [...CAP.PLACES['today-row'].def];
26
+ export function setCapShown(ids) { if (Array.isArray(ids) && ids.length) CAP_SHOWN = ids.slice(0, CAP.PLACES['today-row'].slots); } // name-links (A536): names in a line you typed link to the person, meeting or document
22
27
 
23
28
  /** What a right-click on a Today row names (initiative ask-anywhere): its initiative when it has one, else the row itself. */
24
29
  function askOf(r) {
@@ -94,8 +99,11 @@ export function rowHtml(r, o = {}) {
94
99
  else if (r.src === 'lab') acts = ib('lab-keep', 'Keep it: start an initiative from ' + t, I.yes, r.key) + ib('lab-drop', 'Drop it: ' + t, I.no, r.key);
95
100
  else {
96
101
  const j = JOB_ACT[r.job];
97
- acts = (j ? ib(j[0], j[1] + ': ' + t, j[2], r.key) : '') + ib('done', 'Done: ' + t, I.done, r.key)
98
- + ib('tomorrow', 'Move to tomorrow: ' + t, I.tomorrow, r.key) + ib('date', 'Set a date: ' + t, I.date, r.key, ' aria-haspopup="dialog"');
102
+ // five-action-cap: two show (a job keeps its place first) and ⋯ holds the rest, its Change group first; nothing is lost
103
+ const B = { open: j ? ib(j[0], j[1] + ': ' + t, j[2], r.key) : '', done: ib('done', 'Done: ' + t, I.done, r.key),
104
+ tomorrow: ib('tomorrow', 'Put off a day: ' + t, I.tomorrow, r.key), date: ib('date', 'Set a date: ' + t, I.date, r.key, ' aria-haspopup="dialog"') };
105
+ const cap = CAP.todayRow([j ? 'open' : '', 'done', 'tomorrow', 'date'], CAP_SHOWN);
106
+ acts = cap.shown.map((k) => B[k]).join('') + (cap.more.length ? CAP.moreButton(r.key, t) : '');
99
107
  }
100
108
  }
101
109
  const cls = ['td-li', 'pm-li', o.lit && !r.done ? 'now' : '', r.done ? 'done' : '', r.bullet === 'note' || r.src === 'note' ? 'note' : '', r.src === 'lab' ? 'lab' : '', r.member ? 'mem nest' : ''].filter(Boolean).join(' ');