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,121 @@
1
+ 'use strict';
2
+ /* arch-warns.js — one warning when an initiative is planned against risky code (idea A54, factory job #1978; board BatchMoreBDS panel 15).
3
+ *
4
+ * namesOf(map, text) PURE → the map's parts the text names, in the map's own order
5
+ * warnOf(map, text) PURE → { part, dir, what, tested, why, at, more } | null (the riskiest named part, or nothing)
6
+ * sayOf(w) PURE → "This initiative touches Payments, a risky part: no tests, 6 fixes in 30 days. Add a test task first?"
7
+ * whyOf(w, { path }) PURE → the second line: where the name was read and when the map was read
8
+ * taskOf(w) PURE → "Add tests for Payments", the one step the ✦ offers
9
+ * read(root, dir, id, o) → the warning for one initiative, from its record and the stored map; null when there is nothing to say
10
+ * warnsOf(root, dir, o) → [{ id, warn }] for every initiative that has one (`pmos code warns`)
11
+ *
12
+ * WHAT IS RISKY IS THE CODE MAP'S CALL, never this file's: a part is risky only when lib/code-map.js riskOf gave it a reason (no tests, or
13
+ * many recent fixes), and the warning says that reason in those words. A part that is fine is never named, so most initiatives see nothing
14
+ * (zero is silence).
15
+ *
16
+ * WHAT COUNTS AS TOUCHING: the initiative's own record (planning/initiatives/<id>.md, or pmos/state/initiatives/ in a kit) names the part —
17
+ * its folder path anywhere in the record, or the folder's last word as a whole word. A folder whose name says nothing about the product
18
+ * (lib, src, api, …) counts only when the record names its path, so "the api" in a sentence does not warn about a folder called api.
19
+ * A record that is closed, cancelled, killed or done warns about nothing.
20
+ *
21
+ * READS ONLY. It opens the stored map (code-map.json) and the record, and writes no file: the test task is written by the PM's own press,
22
+ * through the task routes, and the use-log lines are the page's (pm/cozy-pop-work.js). */
23
+ const fs = require('fs');
24
+ const path = require('path');
25
+ const CM = require('./code-map.js');
26
+ const IW = require('./item-why.js');
27
+
28
+ const TAG = '[arch-warns]';
29
+ /* a folder name that says nothing about this product: it warns only when the record names the path itself */
30
+ const PLAIN = new Set(['lib', 'src', 'app', 'apps', 'api', 'web', 'www', 'code', 'core', 'main', 'bin', 'cli', 'ui', 'test', 'tests', 'doc', 'docs',
31
+ 'public', 'static', 'assets', 'scripts', 'script', 'tools', 'util', 'utils', 'common', 'shared', 'server', 'client', 'packages', 'pkg', 'internal', 'build']);
32
+ const STOPPED = /^(closed|cancell?ed|killed|done|accepted)\b/i;
33
+ const MIN_WORD = 4;
34
+ const say = (s) => { try { console.log(TAG + ' ' + s); } catch { /* no console */ } };
35
+
36
+ const lastSeg = (dir) => String(dir || '').split('/').filter(Boolean).pop() || '';
37
+ const esc = (s) => String(s).replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
38
+ /** Does `text` name this part? Its folder path anywhere, else the folder's last word as a whole word. PURE. */
39
+ function named(p, text) {
40
+ const t = String(text || '');
41
+ if (!t) return false;
42
+ const dir = String(p.dir || '');
43
+ if (dir && dir.includes('/') && new RegExp(esc(dir), 'i').test(t)) return true;
44
+ if (dir && new RegExp('(^|[\\s`"\'(/])' + esc(dir) + '/', 'i').test(t)) return true;
45
+ const w = lastSeg(dir) || String(p.name || '');
46
+ if (!w || w.length < MIN_WORD || PLAIN.has(w.toLowerCase())) return false;
47
+ return new RegExp('(^|[^A-Za-z0-9])' + esc(w) + 's?([^A-Za-z0-9]|$)', 'i').test(t);
48
+ }
49
+
50
+ /** The parts of the map that this text names, in the map's own order. PURE. */
51
+ function namesOf(map, text) {
52
+ const parts = (map && Array.isArray(map.parts) ? map.parts : []);
53
+ return parts.filter((p) => p && named(p, text));
54
+ }
55
+
56
+ /** The one warning for this text, or null. The part with no tests comes first, then the one with the most fixes. PURE. */
57
+ function warnOf(map, text) {
58
+ const risky = namesOf(map, text).filter((p) => p.risky && p.why);
59
+ if (!risky.length) return null;
60
+ const rank = (p) => (p.tests ? 1 : 0) * 1e6 - (p.fixes || 0);
61
+ const list = risky.slice().sort((a, b) => rank(a) - rank(b));
62
+ const p = list[0];
63
+ return { part: p.name, dir: p.dir || '', what: p.note || p.kind || '', tested: p.tested || '', why: p.why, at: (map && map.at) || '', more: list.length - 1 };
64
+ }
65
+
66
+ /** The ✦ line. PURE. */
67
+ function sayOf(w) {
68
+ if (!w) return '';
69
+ return 'This initiative touches ' + w.part + ', a risky part: ' + w.why + '. Add a test task first?';
70
+ }
71
+ /** Under it: where the name was read, when the code was read, and the other risky parts it names. PURE. */
72
+ function whyOf(w, o = {}) {
73
+ if (!w) return '';
74
+ const where = o.path ? 'Its record (' + o.path + ') names ' + w.part : 'Its record names ' + w.part;
75
+ const dir = w.dir && w.dir !== w.part ? ' (' + w.dir + ')' : '';
76
+ const when = w.at ? ' PMOS read the code on ' + String(w.at).slice(0, 10) + ': ' + w.why + '.' : ' The code map says: ' + w.why + '.';
77
+ const more = w.more > 0 ? ' It names ' + w.more + ' other risky ' + (w.more === 1 ? 'part' : 'parts') + ' too.' : '';
78
+ return where + dir + '.' + when + more;
79
+ }
80
+ /** The one step the ✦ offers. PURE. */
81
+ const taskOf = (w) => (w ? 'Add tests for ' + w.part : '');
82
+
83
+ const readText = (f) => { try { return fs.readFileSync(f, 'utf8'); } catch { return null; } };
84
+
85
+ /** The warning for one initiative: its record and the stored map, nothing else. o: { map } to read the map once for many. */
86
+ function read(root, dir, id, o = {}) {
87
+ const map = o.map !== undefined ? o.map : CM.view(dir);
88
+ if (!map || !Array.isArray(map.parts) || !map.parts.length) return null; // no repository, or not read yet: silence
89
+ const f = IW.recordPathOf(root, id);
90
+ if (!f) return null;
91
+ const text = readText(f);
92
+ if (!text) return null;
93
+ const fm = IW.frontOf(text);
94
+ if (STOPPED.test(String(fm.status || '')) || String(fm.state || '').toLowerCase() === 'done') return null; // done work gets no advice
95
+ const w = warnOf(map, text);
96
+ if (!w) return null;
97
+ return Object.assign(w, { id, path: path.relative(root, f).split(path.sep).join('/') });
98
+ }
99
+
100
+ /** Every initiative with a warning, newest record first. o: { ids } to read only some. */
101
+ function warnsOf(root, dir, o = {}) {
102
+ const map = o.map !== undefined ? o.map : CM.view(dir);
103
+ if (!map) return [];
104
+ let ids = o.ids;
105
+ if (!Array.isArray(ids)) { try { ids = IW.activeIds(root); } catch { ids = []; } }
106
+ const out = [];
107
+ for (const id of ids || []) { const w = read(root, dir, id, { map }); if (w) out.push(w); }
108
+ return out;
109
+ }
110
+
111
+ /** `pmos code warns [<id>]`: one line per initiative with a warning. → 0, or 1 when there is no map. */
112
+ function runWarns(root, dir, id, out = (s) => console.log(s)) {
113
+ const map = CM.view(dir);
114
+ if (!map) { out('There is no code map yet. Run `pmos code map` first.'); return 1; }
115
+ const list = id ? [read(root, dir, id, { map })].filter(Boolean) : warnsOf(root, dir, { map });
116
+ if (!list.length) { out(id ? id + ' names no risky part of the code.' : 'No initiative names a risky part of the code.'); return 0; }
117
+ for (const w of list) out(w.id + ': ' + sayOf(w).replace(/ Add a test task first\?$/, '') + ' — ' + taskOf(w));
118
+ return 0;
119
+ }
120
+
121
+ module.exports = { TAG, PLAIN, MIN_WORD, named, namesOf, warnOf, sayOf, whyOf, taskOf, read, warnsOf, runWarns, say };
@@ -25,6 +25,7 @@ const USAGE = [
25
25
  ' pmos board --mine your own items',
26
26
  ' pmos board --init <initiative> one initiative',
27
27
  ' pmos board --json the answer of GET /api/board, for scripts',
28
+ ' pmos board actions [--json] what Work and Today show (five in a header, three on a row) and what ⋯ holds',
28
29
  'Done shows the last 14 days. Tasks and breakdown items both show; `pmos task list <initiative>` lists one initiative\'s tasks with their dates.',
29
30
  ];
30
31
  const BOOL = new Set(['json', 'mine', 'help']);
@@ -93,8 +94,11 @@ function addTasks(out, root, now) {
93
94
  out.counts = { todo: out.board.todo.length, doing: out.board.doing.length, review: out.board.review.length, done: out.board.done.length, doneOlder: out.board.doneOlder };
94
95
  }
95
96
 
96
- async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now } = {}) {
97
+ async function run(argv, io = {}) {
98
+ const { say = (s) => console.log(s), cwd = process.cwd(), now } = io;
97
99
  const args = argv[0] === 'board' ? argv.slice(1) : argv.slice();
100
+ // five-action-cap (A529): what Work and Today show, and what ⋯ holds (lib/five-action-cap.js reads the local use log)
101
+ if (args[0] === 'actions') return require('./five-action-cap.js').run(args, { out: say, err: say, ...(io.dir !== undefined ? { dir: io.dir } : {}), ...(now ? { now } : {}) });
98
102
  const { pos, flags } = parse(args);
99
103
  if (flags.help) { for (const l of USAGE) say(l); return 0; }
100
104
  for (const k of Object.keys(flags)) {
@@ -6,6 +6,7 @@
6
6
  * pmos code map [--json] draw the map again now from the default branch (read-only git)
7
7
  * pmos code describe --part <name> --text "<…>" say what a part is in your own words (the chat writes it for the PM); "" puts PMOS's back
8
8
  * pmos code count the number of parts in the map, on the last line
9
+ * pmos code warns [<initiative>] which initiatives name a risky part, and the test task to add (lib/arch-warns.js)
9
10
  * every command: [--root <dir>] (default: this repository)
10
11
  *
11
12
  * Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent, and nothing in the repository is written. */
@@ -13,16 +14,17 @@ const path = require('path');
13
14
  const fs = require('fs');
14
15
  const CM = require('./code-map.js');
15
16
 
16
- const COMMANDS = { code: ['show', 'map', 'describe', 'count'] };
17
+ const COMMANDS = { code: ['show', 'map', 'describe', 'count', 'warns'] };
17
18
  const USAGE = [
18
19
  'usage: pmos code show|map|describe|count — the product\'s code map: one line per main part',
19
20
  ' pmos code show [--json] what each part is, how it is tested, who changed it last; ! marks a risky part',
20
21
  ' pmos code map [--json] draw the map again now from the default branch',
21
22
  ' pmos code describe --part api --text "<what it is>" say what a part is; --text "" puts PMOS\'s words back',
22
23
  ' pmos code count the number of parts in the map',
24
+ ' pmos code warns [<initiative>] which initiatives name a risky part, and the test task to add',
23
25
  'Run it in the product\'s repository, or pass --root <dir>.',
24
26
  ];
25
- const ALLOWED = { show: ['json', 'root'], map: ['json', 'root'], describe: ['json', 'root', 'part', 'text'], count: ['json', 'root'] };
27
+ const ALLOWED = { show: ['json', 'root'], map: ['json', 'root'], describe: ['json', 'root', 'part', 'text'], count: ['json', 'root'], warns: ['json', 'root'] };
26
28
  const BOOL = new Set(['json']);
27
29
 
28
30
  function parse(args) {
@@ -63,7 +65,8 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
63
65
  if (!COMMANDS.code.includes(sub)) { say(`unknown code command "${sub}". Use one of: ${COMMANDS.code.join(', ')}`); return 2; }
64
66
  const { pos, flags } = parse(args.slice(1));
65
67
  for (const k of Object.keys(flags)) if (!ALLOWED[sub].includes(k)) { say(`✗ --${k} is not an option of pmos code ${sub}`); return 2; }
66
- if (pos.length) { say(`✗ pmos code ${sub} takes options, not an argument (pmos code help)`); return 2; }
68
+ if (pos.length && sub !== 'warns') { say(`✗ pmos code ${sub} takes options, not an argument (pmos code help)`); return 2; }
69
+ if (pos.length > 1) { say('✗ pmos code warns takes one initiative id at most (pmos code help)'); return 2; }
67
70
  const root = path.resolve(flags.root || repoRoot(cwd));
68
71
  const dir = recordsDirOf(root);
69
72
  const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
@@ -77,6 +80,11 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), now
77
80
  for (const p of CM.view(dir).parts) say(lineOf(p));
78
81
  return 0;
79
82
  }
83
+ if (sub === 'warns') {
84
+ const AW = require('./arch-warns.js');
85
+ if (flags.json) { const m = CM.view(dir); say(JSON.stringify({ ok: true, warns: pos[0] ? [AW.read(root, dir, pos[0], { map: m })].filter(Boolean) : AW.warnsOf(root, dir, { map: m }) })); return 0; }
86
+ return AW.runWarns(root, dir, pos[0] || '', say);
87
+ }
80
88
  const map = CM.view(dir);
81
89
  if (sub === 'count') { say(flags.json ? JSON.stringify({ ok: true, parts: map ? map.parts.length : 0 }) : String(map ? map.parts.length : 0)); return 0; }
82
90
  if (sub === 'show') {
@@ -43,6 +43,7 @@
43
43
  {"id": "mention", "audience": "user", "status": "ga", "group": "Catch up", "name": "Mentions that wait on you", "say": "What waits on you in your tools, with a reply PMOS drafts for you to send.", "cmd": "/mention", "verb": "mention"},
44
44
  {"id": "workflow", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Workflows", "say": "The workflows of this product, a new workflow draft, and moving an initiative to another one.", "cmd": "/workflow", "verb": "workflow"},
45
45
  {"id": "blueprint", "audience": "user", "status": "ga", "group": "Your product", "name": "Every feature and its state", "say": "Every feature of the product with a status worked out from its evidence.", "cmd": "/blueprint", "verb": "blueprint"},
46
+ {"id": "portfolio", "audience": "user", "status": "ga", "group": "Your product", "name": "Portfolio", "say": "Every product side by side: bets, odds, spend and outcomes, with one recommendation.", "cmd": "/portfolio", "verb": "portfolio"},
46
47
  {"id": "program", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Programs", "say": "Make and change programs: charter, milestones, order, capacity and steering.", "cmd": "/program", "verb": "program"},
47
48
  {"id": "extension", "audience": "user", "status": "ga", "group": "Find your way", "name": "Google Meet extension", "say": "The folder of the Chrome extension for Google Meet and the three steps to load it.", "cmd": "/extension", "verb": "extension"},
48
49
  {"id": "team", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "The role agents", "say": "Who owns what among the role agents, what each works on, and pause or resume them.", "cmd": "/team", "verb": "team"},
@@ -56,6 +57,7 @@
56
57
  {"id": "rules", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "Rules PMOS learned", "say": "The standing rules PMOS learned from your corrections, and edit or retire one.", "cmd": "/rules", "verb": "rules"},
57
58
  {"id": "line", "audience": "user", "status": "ga", "group": "Catch up", "name": "Where each initiative stands", "say": "Days in its stage, what is missing, the next move, and whether it is stuck.", "cmd": "/line", "verb": "line", "hint": "<initiative>"},
58
59
  {"id": "hire", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The next hire", "say": "The role your open work most needs, and a one-page role brief to edit.", "cmd": "/hire", "verb": "hire"},
60
+ {"id": "goals", "audience": "user", "status": "ga", "group": "Your product", "name": "Starter goals", "say": "Up to three goals drafted from your own product, each with its source; keep one and it becomes a goal.", "cmd": "/goals", "verb": "goals"},
59
61
  {"id": "approver", "audience": "user", "status": "ga", "group": "Before you ship", "name": "What an approver asks", "say": "What each approver asked or objected to before, ahead of the next sign-off.", "cmd": "/approver", "verb": "approver", "hint": "<name>"},
60
62
  {"id": "balance", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The mix of a list", "say": "Feature, fix, debt or discovery in one line, with a note when one kind is over your line.", "cmd": "/balance", "verb": "balance"},
61
63
  {"id": "declined", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Asks you declined", "say": "Asks closed without being done, each with a kind reply draft PMOS never sends.", "cmd": "/declined", "verb": "declined"},
@@ -70,6 +72,7 @@
70
72
  {"id": "artefacts", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The seven artefacts", "say": "Intent, Goal, Narrative, Experiment, Specimens, Done test and Lessons of an initiative.", "cmd": "/artefacts", "verb": "artefacts", "hint": "<initiative>"},
71
73
  {"id": "forecast", "audience": "user", "status": "ga", "group": "Your product", "name": "Goal forecasts", "say": "A goal forecast's kept baseline, and the forecasts that turned.", "cmd": "/forecast", "verb": "forecast"},
72
74
  {"id": "git-identity", "audience": "user", "status": "ga", "group": "Find your way", "name": "Your git identity", "say": "Which git identity and GitHub login this repository uses.", "cmd": "/git-identity", "verb": "git-identity"},
75
+ {"id": "voice", "audience": "user", "status": "ga", "group": "Your product", "name": "Customer voice", "say": "Survey comments and app-store reviews grouped by reason, the fastest-growing first.", "cmd": "/voice", "verb": "voice"},
73
76
  {"id": "signal", "audience": "user", "status": "ga", "group": "Your product", "name": "Customer signals", "say": "The customer signals behind each roadmap item.", "cmd": "/signal", "verb": "signal", "hint": "<item>"},
74
77
  {"id": "launcher", "audience": "user", "status": "ga", "group": "Find your way", "name": "Start without a terminal", "say": "A PMOS app and a login item, so the workspace starts by itself.", "cmd": "/launcher", "verb": "launcher"},
75
78
  {"id": "verify-work", "audience": "agent", "status": "ga", "group": "What PMOS did", "name": "Mark integrated work", "say": "A build run marks work items integrated from the default branch.", "cmd": "/verify-work", "verb": "verify-work"},
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+ /* five-action-cap.js — the server side of the five-action limit on Work and Today (five-action-cap, idea A529; the rule is
3
+ * public/pm/five-action-cap.js). It reads the local use log only; it writes nothing.
4
+ *
5
+ * fold(lines, place, now) → { counts: { done: n, … }, span } PURE: the `<place>-<action>` presses of the last 30 days, and span = the
6
+ * whole days since the log's oldest line (the shown ones are worked out only at 30 or more). GET /api/use-log/cap?place=
7
+ * shownRate(lines, days, now) → { shown, more, pct } PURE: Today row presses on a shown button (`today-row-<act>`) and under ⋯
8
+ * (`today-row-more-<act>`) in the last `days` days; pct = shown out of both, 100 with none (the health number)
9
+ * actions(lines, now) → [{ place, label, shown, more, from }] PURE: each place's shown actions and what ⋯ holds, for `pmos board actions`
10
+ * run(argv, io) → exit code: `pmos board actions [--json]`
11
+ *
12
+ * node lib/five-action-cap.js count [--days 7] the health number: the percent of Today row presses on a shown button (last line)
13
+ */
14
+ const UL = require('./use-log.js');
15
+
16
+ const DAY = 864e5;
17
+ const KEEP_DAYS = 30;
18
+ const PLACE_RE = /^[a-z][a-z-]{1,30}$/;
19
+ let CAP = null;
20
+ /** The pure rule (ESM) loaded once. */
21
+ async function rule() { if (!CAP) CAP = await import('../public/pm/five-action-cap.js'); return CAP; }
22
+
23
+ function fold(lines, place, now = Date.now()) {
24
+ if (!PLACE_RE.test(String(place || ''))) return { counts: {}, span: 0 };
25
+ const from = now - KEEP_DAYS * DAY, counts = {}, re = new RegExp('^' + place + '-(?:more-)?([a-z]{1,20})$');
26
+ let first = Infinity;
27
+ for (const l of lines || []) {
28
+ const t = Date.parse(l && l.at);
29
+ if (t < first) first = t; // the span is the whole log's age, so a full log reads as full (pm/five-action-cap.js FULL_DAYS)
30
+ if (!(t >= from)) continue;
31
+ const m = l.kind === 'use' && re.exec(l.control || '');
32
+ if (m) counts[m[1]] = (counts[m[1]] || 0) + 1;
33
+ }
34
+ return { counts, span: first === Infinity ? 0 : Math.floor((now - first) / DAY) };
35
+ }
36
+
37
+ function shownRate(lines, days = 7, now = Date.now()) {
38
+ const from = now - Math.max(1, Number(days) || 7) * DAY;
39
+ let shown = 0, more = 0;
40
+ for (const l of lines || []) {
41
+ if (!l || l.kind !== 'use' || !(Date.parse(l.at) >= from)) continue;
42
+ const c = String(l.control || '');
43
+ if (/^today-row-more-[a-z]+$/.test(c)) more++;
44
+ else if (/^today-row-(?!more$)[a-z]+$/.test(c)) shown++;
45
+ }
46
+ return { shown, more, pct: shown + more ? Math.round((shown / (shown + more)) * 100) : 100 };
47
+ }
48
+
49
+ async function actions(lines, now = Date.now()) {
50
+ const C = await rule();
51
+ return Object.entries(C.PLACES).map(([place, P]) => {
52
+ const f = fold(lines, place, now), shown = C.pick(place, f.counts, f.span);
53
+ const more = place === 'today-row' ? C.todayRow(P.acts, shown).more : [];
54
+ return { place, label: P.label, max: P.max, shown, more, from: f.span >= C.FULL_DAYS ? 'use' : 'default' };
55
+ });
56
+ }
57
+
58
+ async function run(argv, io = {}) {
59
+ const out = io.out || ((s) => process.stdout.write(s + '\n')), err = io.err || ((s) => process.stderr.write(s + '\n'));
60
+ const json = argv.includes('--json');
61
+ const bad = argv.filter((a) => a !== '--json' && a !== 'actions');
62
+ if (bad.length) { err('usage: pmos board actions [--json] — what Work and Today show, and what ⋯ holds'); return 2; }
63
+ const dir = io.dir !== undefined ? io.dir : require('./state-root.js').defaultRoot({ env: process.env });
64
+ const rows = await actions(UL.readLines(dir), io.now || Date.now());
65
+ if (json) { out(JSON.stringify({ ok: true, places: rows }, null, 2)); return 0; }
66
+ for (const r of rows) {
67
+ const C = await rule();
68
+ const words = (k) => C.WORDS[k] || k;
69
+ out(`${r.label} (${r.max} at most, ${r.from === 'use' ? 'from your use in 30 days' : 'the defaults until 30 days of use'}): ${r.shown.map(words).join(', ')}${r.more.length ? ' · ⋯ ' + r.more.map((g) => g.group + ': ' + g.items.map(words).join(', ')).join(' · ') : ''}`);
70
+ }
71
+ return 0;
72
+ }
73
+
74
+ module.exports = { fold, shownRate, actions, run, KEEP_DAYS };
75
+
76
+ if (require.main === module) {
77
+ const cmd = process.argv[2];
78
+ if (cmd !== 'count') { console.error('usage: node lib/five-action-cap.js count [--days 7] (the percent of Today row presses on a shown button)'); process.exit(2); }
79
+ const i = process.argv.indexOf('--days'), days = i > 0 ? Number(process.argv[i + 1]) || 7 : 7;
80
+ const dir = require('./state-root.js').defaultRoot({ env: process.env });
81
+ const r = shownRate(UL.readLines(dir), days);
82
+ console.log(`[five-action-cap] shown ${r.shown}, under ⋯ ${r.more}, last ${days} days`);
83
+ console.log(String(r.pct));
84
+ }
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+ /* goals-cli.js — `pmos goals …`: the starter goals PMOS drafts from your own product (initiative starter-goals, job #1916, A84).
3
+ * The logic and the store are lib/starter-goals.js; this file is only the verb, so the verb table names a *-cli.js module. */
4
+ const SG = require('./starter-goals.js');
5
+ module.exports = { run: SG.run, COMMANDS: SG.COMMANDS, USAGE: SG.USAGE };
@@ -6,6 +6,8 @@
6
6
  * pmos people show <person> [--json] one person's page: interactions, tone, shared work, notes, handles
7
7
  * pmos people record --file <sightings.json> (agent session) append what the session saw
8
8
  * pmos people settings [--json] whether calendar attendee names are kept
9
+ * pmos people map <initiative> [--json] who decides, must agree, needs to know, and when each last heard (A371)
10
+ * pmos people keep|drop|told|undo <initiative> <person> [--group decides|agree|know] the PM's word on one name (lib/stakeholder-map.js)
9
11
  *
10
12
  * The same module the People place reads (lib/people-store.js), so a terminal line and the page cannot disagree.
11
13
  * `list` and `show` first record the names this repository's records hold (plan item owners, Live notes speakers), as
@@ -20,14 +22,17 @@ const path = require('path');
20
22
  const store = require('./people-store');
21
23
  const { parseArgs } = require('./schedule-cli');
22
24
 
23
- const COMMANDS = { people: ['list', 'show', 'record', 'settings'] };
25
+ const COMMANDS = { people: ['list', 'show', 'record', 'settings', 'map', 'keep', 'drop', 'told', 'undo'] };
24
26
  const USAGE = [
25
27
  'usage: pmos people [list|show|record|settings] — the people you work with in this repository',
26
28
  ' pmos people [list] [--json] each person, and what waits for you in the review list',
27
29
  ' pmos people show <person> [--json] one person: interactions, tone, shared work, notes and handles',
28
30
  ' pmos people record --file <sightings.json> (agent session) record the people a session saw',
29
31
  ' pmos people settings [--json] whether calendar attendee names are kept (calendar names: on|off)',
30
- 'Nothing here removes a person, merges, sets a tone or writes a note. Do that in People.',
32
+ ' pmos people map <initiative> [--json] who decides, who must agree, who needs to know, and when each last heard from you',
33
+ ' pmos people keep <initiative> <person> [--group decides|agree|know] keep a name on the map (in that group)',
34
+ ' pmos people drop|told|undo <initiative> <person> take a name off, mark that you sent them an update, or take back the last of these',
35
+ 'Nothing here removes a person, merges, sets a tone or writes a note. Do that in People. PMOS never sends an update: you do.',
31
36
  ];
32
37
  const BOOL = new Set(['json', 'help']);
33
38
 
@@ -128,7 +133,43 @@ async function run(argv, { say = console.log, cwd = process.cwd(), env = process
128
133
  if (!r.ok) say(`✗ ${r.error}`);
129
134
  return r.ok ? 0 : 1;
130
135
  }
136
+ if (sub === 'map' || SM_ACTS.includes(sub)) return mapCmd(sub, pos, flags, { say, root, json, fail, now });
131
137
  return fail(`pmos people ${sub} is not a command. ${USAGE[0]}`, 2);
132
138
  }
133
139
 
140
+ const SM_ACTS = ['keep', 'drop', 'told', 'undo'];
141
+ /** `pmos people map` and the four presses on one name (initiative stakeholder-map): the store the Work popup's People block reads. */
142
+ function mapCmd(sub, pos, flags, { say, root, json, fail, now }) {
143
+ const SM = require('./stakeholder-map.js');
144
+ const ini = String(pos[1] || '');
145
+ if (!ini) return fail(`usage: pmos people ${sub} <initiative>${sub === 'map' ? '' : ' <person>'}`, 2);
146
+ if (sub === 'map') {
147
+ const m = SM.read(root, ini, { now });
148
+ if (json) { say(JSON.stringify({ ok: true, ...m })); return 0; }
149
+ say(`People · ${m.title} · ${m.rows.length} ${m.rows.length === 1 ? 'name' : 'names'}${m.drafts ? ` · ${m.drafts} draft${m.drafts === 1 ? '' : 's'} to keep or drop` : ''}`);
150
+ if (!m.rows.length) { say('No names yet. PMOS lists the record\'s decider, the sign-offs and the people whose Jira, notes or mail name this initiative.'); return 0; }
151
+ for (const g of SM.GROUPS) {
152
+ const rows = m.rows.filter((r) => r.group === g);
153
+ if (!rows.length) continue;
154
+ say(SM.GROUP_WORD[g][0].toUpperCase() + SM.GROUP_WORD[g].slice(1) + ':');
155
+ for (const r of rows) {
156
+ const heard = r.days == null ? 'no update on record' : r.days === 0 ? 'last heard today' : `last heard ${r.days} day${r.days === 1 ? '' : 's'} ago`;
157
+ say(` ${r.name} (${r.id}) · ${heard}${r.kept ? '' : ' · draft: ' + r.why}`);
158
+ if (r.update) say(` ✦ draft update, for you to send: ${r.update}`);
159
+ }
160
+ }
161
+ return 0;
162
+ }
163
+ const who = String(pos.slice(2).join(' ') || '');
164
+ if (!who) return fail(`usage: pmos people ${sub} <initiative> <person>`, 2);
165
+ const m = SM.read(root, ini, { now });
166
+ const row = m.rows.find((r) => r.id === who.toLowerCase()) || m.rows.find((r) => SM.same(r.name, who));
167
+ const r = SM.act(SM.recordsDirOf(root), { ini, person: row ? row.id : null, name: row ? row.name : who, kind: sub, group: flags.group != null ? flags.group : sub === 'keep' && row ? row.group : undefined }, { by: 'pm', now });
168
+ if (json) { say(JSON.stringify(r)); return r.ok ? 0 : 1; }
169
+ if (!r.ok) return fail(r.error);
170
+ const word = { keep: `kept${r.line.group ? ' · ' + SM.GROUP_WORD[r.line.group] : ''}`, drop: 'taken off the map', told: 'marked: you sent them an update today', undo: 'your last press taken back' }[sub];
171
+ say(`✓ ${r.line.name || r.line.person} ${word}`);
172
+ return 0;
173
+ }
174
+
134
175
  module.exports = { run, COMMANDS, USAGE };
@@ -50,7 +50,7 @@ const VERBS = Object.freeze({
50
50
  help: 'pmos docs [list|link|unlink|find] … — is each linked document the same as, ahead of or behind its Google Docs and Confluence copy, and record a sync (pmos docs help)' }),
51
51
  // Not a pm-os-absorb verb (run: null): people-directory added it through the same table.
52
52
  people: Object.freeze({ module: 'people-cli.js', run: null, guide: 'cli.md',
53
- help: 'pmos people list|show|record|settings … — the people you work with in this repository (pmos people help)' }),
53
+ help: 'pmos people list|show|record|settings|map|keep|drop|told|undo … — the people you work with in this repository, and who decides on each initiative (pmos people help)' }),
54
54
  // Not a pm-os-absorb verb (run: null): initiative dry-run-tickets-before-build added it through the same table.
55
55
  signoff: Object.freeze({ module: 'signoff-cli.js', run: null, guide: 'cli.md',
56
56
  help: 'pmos signoff ask|answer|drop|evidence|list … — the sign-offs an initiative waits on; a stage\'s sign-offs are Your move rows on Today (pmos signoff help)' }),
@@ -158,6 +158,9 @@ const VERBS = Object.freeze({
158
158
  why: Object.freeze({ module: 'why-cli.js', run: null, guide: 'cli.md',
159
159
  help: 'pmos why <initiative or task> | coverage — why the work exists in three lines: goal, problem, evidence, read from its records (pmos why help)' }),
160
160
  // Not a pm-os-absorb verb (run: null): initiative next-hire-draft (job #1876, A75) added it through the same table.
161
+ // Not a pm-os-absorb verb (run: null): initiative starter-goals (job #1916, A84) added it through the same table.
162
+ goals: Object.freeze({ module: 'goals-cli.js', run: null, guide: 'cli.md',
163
+ help: 'pmos goals [starter|draft|keep <n>|drop <n>|undo] — starter goals PMOS drafts from your own product, each with its source; keep one and it becomes a goal (pmos goals help)' }),
161
164
  hire: Object.freeze({ module: 'hire-draft.js', run: null, guide: 'cli.md',
162
165
  help: 'pmos hire [draft|show|count] — the role your open work most needs, per person, and a one-page role brief PMOS drafts for you to edit (pmos hire help)' }),
163
166
  // Not a pm-os-absorb verb (run: null): initiative connector-data (job #1920, A150) added it through the same table.
@@ -210,6 +213,9 @@ const VERBS = Object.freeze({
210
213
  driver: Object.freeze({ module: 'driver-cli.js', run: null, guide: 'cli.md',
211
214
  help: 'pmos driver propose|status|exits|keep|return|drop|undo|pause|resume|mode … — the Initiative Driver: class A and B changes apply with Undo, the rest wait for you (pmos driver help)' }),
212
215
  // one-change-record-no-source-no-auto: everything PMOS changed by itself, in one record (lib/change-record.js)
216
+ // Not a pm-os-absorb verb (run: null): initiative portfolio (bet A56) added it through the same table.
217
+ portfolio: Object.freeze({ module: 'portfolio-cli.js', run: null, guide: 'cli.md',
218
+ help: 'pmos portfolio [--json] | keep|not-now|undo <key> — every product side by side: bets, odds, spend, outcome so far, and one recommendation (pmos portfolio help)' }),
213
219
  health: Object.freeze({ module: 'product-health-cli.js', run: null, guide: 'cli.md',
214
220
  help: 'pmos health [score|trend|drops] — this product\'s health score (0 to 100), its trend this month and its past drops (pmos health help)' }),
215
221
  // Not a pm-os-absorb verb (run: null): initiative setup-station (product line slice 5) added it through the same table.
@@ -240,6 +246,9 @@ const VERBS = Object.freeze({
240
246
  // Not a pm-os-absorb verb (run: null): feedback batch 25 item 1 added it through the same table.
241
247
  'git-identity': Object.freeze({ module: 'git-identity-cli.js', run: null, guide: 'cli.md',
242
248
  help: 'pmos git-identity [set --name <n> --email <e> --login <gh>] — which git identity and GitHub login this repository uses; save your choice for it' }),
249
+ // Not a pm-os-absorb verb (run: null): initiative review-reasons (job #1913, A427) added it through the same table.
250
+ voice: Object.freeze({ module: 'voice-cli.js', run: null, guide: 'cli.md',
251
+ help: 'pmos voice add|import|reason|list|file|undo|count — survey comments and app-store reviews grouped by reason; Work shows them as Customer voice (pmos voice help)' }),
243
252
  // Not a pm-os-absorb verb (run: null): roadmap-signal-verb (bet A157) added it through the same table.
244
253
  signal: Object.freeze({ module: 'signal-cli.js', run: null, guide: 'cli.md',
245
254
  help: 'pmos signal add|remove|list|count — the customer signals behind each roadmap item; Work shows the count (pmos signal help)' }),
@@ -0,0 +1,64 @@
1
+ 'use strict';
2
+ /* portfolio-cli.js — `pmos portfolio`: every registered product side by side, and the answer to its one recommendation (initiative portfolio).
3
+ * The work is in lib/portfolio.js; the page (/premium-portfolio.html) reads the same rows and writes the same store.
4
+ *
5
+ * pmos portfolio [--json] one line per product (bets, odds, spend, outcome) and the ✦ recommendation, if any
6
+ * pmos portfolio keep|not-now <key> answer the recommendation: Keep hides it while its facts hold, Not now for 7 days
7
+ * pmos portfolio undo <key> take the last answer back
8
+ *
9
+ * The products are the workspace's registered ones (workspaces.json in the state folder), and this repository when it has a PMOS state
10
+ * folder. Reading changes no product's files. Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent. */
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+ const PF = require('./portfolio.js');
14
+
15
+ const COMMANDS = { portfolio: ['keep', 'not-now', 'undo'] };
16
+ const USAGE = [
17
+ 'usage: pmos portfolio [--json] | keep|not-now|undo <key> — every product side by side: bets, odds, spend, outcome so far',
18
+ ' pmos portfolio [--json] one line per product and PMOS\'s one recommendation',
19
+ ' pmos portfolio keep <key> keep the recommendation (it stays hidden while its facts hold)',
20
+ ' pmos portfolio not-now <key> not now: hidden for 7 days',
21
+ ' pmos portfolio undo <key> take the last answer back',
22
+ ].join('\n');
23
+
24
+ const stateOf = (env) => require('./state-root.js').defaultRoot({ env });
25
+
26
+ /** The registered products, and this repository when it has a PMOS state folder and is not registered. */
27
+ function productsOf(dir, cwd) {
28
+ const driver = require('./driver.js');
29
+ let reg = [];
30
+ try { reg = JSON.parse(fs.readFileSync(path.join(dir, 'workspaces.json'), 'utf8')); } catch { reg = []; }
31
+ const out = [], seen = new Set();
32
+ const add = (root, ws, name) => {
33
+ const r = path.resolve(root);
34
+ if (seen.has(r) || !driver.stateDirOf(r)) return;
35
+ seen.add(r);
36
+ out.push({ ws: ws || driver.wsIdOf(r), name: name || path.basename(r), root: r });
37
+ };
38
+ for (const x of Array.isArray(reg) ? reg : []) if (x && typeof x.root === 'string') { try { if (fs.statSync(x.root).isDirectory()) add(x.root, x.id, x.name); } catch { /* gone */ } }
39
+ if (cwd) add(cwd);
40
+ return out;
41
+ }
42
+
43
+ function run(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd(), now = Date.now() } = {}) {
44
+ const args = argv[0] === 'portfolio' ? argv.slice(1) : argv.slice();
45
+ const dir = stateOf(env);
46
+ const sub = args[0] && !args[0].startsWith('--') ? args[0] : null;
47
+ if (sub === 'help') { say(USAGE); return 0; }
48
+ if (sub) {
49
+ if (!PF.KINDS.includes(sub) || !args[1]) { say(USAGE); return 2; }
50
+ const r = PF.decide(dir, { key: args[1], kind: sub, by: 'cli' }, { now });
51
+ if (!r.ok) { say(r.error); return 1; }
52
+ console.info(`${PF.TAG} ${sub} key=${args[1]}`);
53
+ say(sub === 'undo' ? 'Taken back: the recommendation shows again.' : sub === 'keep' ? `Kept. To take it back: pmos portfolio undo ${args[1]}` : `Not now: hidden for ${PF.NOT_NOW_DAYS} days. To take it back: pmos portfolio undo ${args[1]}`);
54
+ return 0;
55
+ }
56
+ const v = PF.view(productsOf(dir, cwd), dir, { now });
57
+ try { require('./use-log.js').record(dir, [{ kind: 'use', page: 'premium-portfolio', control: 'portfolio', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ }
58
+ console.info(`${PF.TAG} products=${v.rows.length} show=${v.show} rec=${v.rec ? 1 : 0}`);
59
+ if (args.includes('--json')) { say(JSON.stringify(v, null, 2)); return 0; }
60
+ for (const l of PF.lines(v)) say(l);
61
+ return 0;
62
+ }
63
+
64
+ module.exports = { COMMANDS, USAGE, run, productsOf };