create-pmos 0.829.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 (55) hide show
  1. package/package.json +120 -36
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-board-test.js +1 -1
  7. package/workspace/briefing-premium-insights-test.js +1 -1
  8. package/workspace/changelog.json +119 -22
  9. package/workspace/guide/agent-capabilities.md +1 -1
  10. package/workspace/guide/backlog.md +12 -1
  11. package/workspace/guide/cli.md +12 -0
  12. package/workspace/guide/home.md +1 -1
  13. package/workspace/guide/layout.md +1 -0
  14. package/workspace/lib/code-map.js +8 -2
  15. package/workspace/lib/factory-floor.js +16 -8
  16. package/workspace/lib/features.json +14 -13
  17. package/workspace/lib/people-cli.js +9 -1
  18. package/workspace/lib/people-prep.js +140 -0
  19. package/workspace/lib/pmos-verbs.js +2 -0
  20. package/workspace/lib/print-cli.js +49 -0
  21. package/workspace/lib/print-pdf.js +96 -0
  22. package/workspace/lib/review-reasons.js +121 -9
  23. package/workspace/lib/route-modules.js +1 -0
  24. package/workspace/lib/routes-report-design.js +3 -1
  25. package/workspace/lib/routes-skill-map.js +39 -0
  26. package/workspace/lib/routes-strategy-card.js +13 -6
  27. package/workspace/lib/skill-map.js +199 -0
  28. package/workspace/lib/team-cli.js +20 -1
  29. package/workspace/package-lock.json +2 -2
  30. package/workspace/package.json +1 -1
  31. package/workspace/public/pm/action-keys.js +1 -0
  32. package/workspace/public/pm/ask-here-ctx.js +25 -1
  33. package/workspace/public/pm/ask-here.css +7 -0
  34. package/workspace/public/pm/ask-here.js +15 -2
  35. package/workspace/public/pm/bd-backlog.css +61 -0
  36. package/workspace/public/pm/bd-backlog.js +62 -8
  37. package/workspace/public/pm/bd-work.js +12 -1
  38. package/workspace/public/pm/code-map.js +15 -4
  39. package/workspace/public/pm/cozy-board.css +5 -1
  40. package/workspace/public/pm/cozy-pop-work.js +2 -0
  41. package/workspace/public/pm/cozy-search.js +2 -2
  42. package/workspace/public/pm/factory.js +199 -0
  43. package/workspace/public/pm/pop-cap.js +5 -3
  44. package/workspace/public/pm/premium-board.js +4 -0
  45. package/workspace/public/pm/premium-report-read.js +11 -2
  46. package/workspace/public/pm/print-pdf.js +191 -0
  47. package/workspace/public/pm/review-reasons.js +19 -5
  48. package/workspace/public/pm/skill-map.js +57 -0
  49. package/workspace/public/premium-board.html +2 -0
  50. package/workspace/test-lists/factory-page-ui.json +9 -0
  51. package/workspace/test-lists/people-prep.json +9 -0
  52. package/workspace/test-lists/print-pdf.json +9 -0
  53. package/workspace/test-lists/skill-map.json +9 -0
  54. package/workspace/test-lists/surface-ask-card.json +9 -0
  55. package/workspace/test-lists/voice-files.json +9 -0
@@ -320,6 +320,7 @@ Right-click any part of a page to ask PMOS about it. On a phone, press and hold
320
320
  - When the top line names the wrong thing, press **↑** to step out one level: the field, then the item, then the section, then the page.
321
321
  - Under it is the item as Work holds it now, with its usual buttons. A task's date shows three later dates to move it to. Every change has Undo.
322
322
  - Up to three questions show with ✦. Press one, or type your own question in the box.
323
+ - **What PMOS can do** lists up to four features for that kind of item, such as **Why this work exists** for an initiative or **Strategy** for a product. One press asks it in the card, about that item, with nothing to type. A section, the page, or an item no feature acts on shows no such line.
323
324
  - **⤢** opens the same conversation in the full chat. **×** or Escape closes the card.
324
325
 
325
326
  Right-click keeps the browser's own menu in a text box, on a link, on selected text and in the terminal. Hold Shift to get the browser's menu anywhere.
@@ -20,6 +20,8 @@
20
20
  * · A folder that is mostly tests (tests/, test/, spec/ …) is not a part; each test file in it counts for the part whose name appears
21
21
  * in its path. Code files at the top level form a part "(top level)" when there are 3 or more.
22
22
  * · At most MAX_PARTS parts, most code files first; the rest are counted in `more`.
23
+ * · PMOS's own kit folder (a top-level pmos/ holding the kit's AGENTS.md) is PMOS, not the product: never a part.
24
+ * · A repository with fewer than MIN_CODE code files in its parts (a PM's records folder with a script or two) gets no map at all.
23
25
  * · Risky: no test files, or RISKY_FIXES or more fix commits touching the part in the last 30 days that are at least half of its
24
26
  * commits there (a busy, well-kept part is not risky only for being busy). */
25
27
  const fs = require('fs');
@@ -29,6 +31,7 @@ const { execFile } = require('child_process');
29
31
  const MAP_FILE = 'code-map.json';
30
32
  const NOTES_FILE = 'code-map-notes.jsonl';
31
33
  const MAX_PARTS = 12;
34
+ const MIN_CODE = 20; // fewer code files than this in the whole repository: a records or notes folder, not a product's code — no map
32
35
  const RISKY_FIXES = 5;
33
36
  const FIX_DAYS = 30;
34
37
  const FIX_SHARE = 0.5; // fixes must be at least half the part's commits in the window, so a busy part is not risky only for being busy
@@ -65,7 +68,9 @@ function keyOf(f, open) {
65
68
 
66
69
  /** Group a repository's files into its main parts. PURE. */
67
70
  function partsOf(files) {
68
- const list = (Array.isArray(files) ? files : []).map(String).filter((f) => f && !skipped(f) && !f.split('/').pop().startsWith('.'));
71
+ const all = (Array.isArray(files) ? files : []).map(String);
72
+ const kit = all.includes('pmos/AGENTS.md'); // the vendored PMOS kit (kit/build-kit.sh): PMOS's files, not the product's
73
+ const list = all.filter((f) => f && !skipped(f) && !f.split('/').pop().startsWith('.') && !(kit && f.startsWith('pmos/')));
69
74
  // a container opens only when it has sub-folders with code (a flat src/ stays one part)
70
75
  const open = new Set();
71
76
  for (const f of list) { const s = f.split('/'); if (CONTAINERS.has(s[0]) && s.length > 2 && isCode(f)) open.add(s[0]); }
@@ -90,6 +95,7 @@ function partsOf(files) {
90
95
  if (hit) { hit.tests++; hit.testsOutside++; }
91
96
  }
92
97
  parts.sort((a, b) => b.code - a.code || a.name.localeCompare(b.name));
98
+ if (parts.reduce((n, p) => n + p.code, 0) < MIN_CODE) return { parts: [], more: 0 };
93
99
  const more = Math.max(0, parts.length - MAX_PARTS);
94
100
  return { parts: parts.slice(0, MAX_PARTS).map(({ _tests, ...p }) => p), more };
95
101
  }
@@ -244,4 +250,4 @@ function describe(dir, name, text, now = Date.now()) {
244
250
  return { ok: true, part: p.name, map: view(dir) };
245
251
  }
246
252
 
247
- module.exports = { partsOf, summarize, riskOf, build, headOf, read, save, view, describe, findPart, isTest, MAP_FILE, NOTES_FILE, MAX_PARTS, RISKY_FIXES, FIX_DAYS, FIX_SHARE };
253
+ module.exports = { partsOf, summarize, riskOf, build, headOf, read, save, view, describe, findPart, isTest, MAP_FILE, NOTES_FILE, MAX_PARTS, RISKY_FIXES, FIX_DAYS, FIX_SHARE, MIN_CODE };
@@ -18,8 +18,8 @@
18
18
  * load(root) → the saved snapshot | null reads one file, folds nothing
19
19
  * ageMinutes(root, now) → whole minutes since the snapshot was saved, or -1 (the health number)
20
20
  *
21
- * THE SNAPSHOT { v: 1, at, ws, name, days, from, stations: [{ key, name, waiting, made, undone, minutes, items }], unplaced: { made, minutes },
22
- * runs, tokens: null, money: null, usage: 'not recorded yet' }
21
+ * THE SNAPSHOT { v: 1, at, ws, name, days, from, stations: [{ key, name, waiting, made, undone, minutes, runs, items, madeItems }],
22
+ * unplaced: { made, minutes }, runs, lastRun, tokens: null, money: null, usage: 'not recorded yet' }
23
23
  * waiting what waits at the station now. Intake to Evaluate: the initiatives and Work tasks whose agent blocker of the latest sweep day
24
24
  * belongs to it (one per target). Check: the Driver drafts of ended runs the Checker has not graded yet. You: the open sign-offs
25
25
  * and the Driver drafts that have waited on the PM for a day (pm-open).
@@ -30,6 +30,8 @@
30
30
  * minutes PMOS minutes of the Driver's runs that ended in the window (run-start to run-end), split evenly over the stations of what each
31
31
  * run filed; a run that filed nothing counts for the station of the blocker that woke it; else it is unplaced.
32
32
  * items up to MAX_ITEMS waiting items: { kind, id, title, code, text }, what each one waits on.
33
+ * madeItems the newest MAX_MADE change rows it made: { ref, title, at, state, ini, undo } (undo: the Factory page offers Undo on it).
34
+ * runs the Driver runs whose minutes went to the station. lastRun: when the newest run of the window ended (the page's status line).
33
35
  * tokens and money stay null ("not recorded yet") until each run records its usage (a later slice). An honest gap, never a guess.
34
36
  *
35
37
  * Every log line carries [factory-floor]. Nothing here sends anything, and the factory graph never writes it (D65): the server writes it
@@ -41,6 +43,9 @@ const FILE = 'factory-floor.json';
41
43
  const DAY = 86400000;
42
44
  const DAYS = 7;
43
45
  const MAX_ITEMS = 50;
46
+ const MAX_MADE = 30; // the station popup's "Made this week": the newest 30 rows (factory-page-ui)
47
+ // a change the PM can undo from the station popup (POST /api/autonomy/undo): applied by PMOS, inside its Undo, with a ref that route knows
48
+ const canUndo = (r) => r.state === 'applied' && /^(p|pk|im)-/.test(String(r.ref || ''));
44
49
  const LOG = '[factory-floor]';
45
50
  const NOT_RECORDED = 'not recorded yet';
46
51
  const STATIONS = Object.freeze([
@@ -88,7 +93,7 @@ function compute(input = {}, { now = Date.now(), days = DAYS, ws = null, name =
88
93
  const CR = require('./change-record.js');
89
94
  const from = now - days * DAY;
90
95
  const inWin = (at) => { const t = ms(at); return t != null && t >= from && t <= now + 60000; };
91
- const st = new Map(STATIONS.map((s) => [s.key, { key: s.key, name: s.name, waiting: 0, made: 0, undone: 0, minutes: 0, items: [], _targets: new Set() }]));
96
+ const st = new Map(STATIONS.map((s) => [s.key, { key: s.key, name: s.name, waiting: 0, made: 0, undone: 0, minutes: 0, runs: 0, items: [], madeItems: [], _targets: new Set() }]));
92
97
  const unplaced = { made: 0, minutes: 0 };
93
98
  const wait = (key, item) => {
94
99
  const s = st.get(key);
@@ -110,6 +115,7 @@ function compute(input = {}, { now = Date.now(), days = DAYS, ws = null, name =
110
115
  const s = st.get(key);
111
116
  s.made++;
112
117
  if (r.state === 'undone') s.undone++;
118
+ s.madeItems.push({ ref: r.ref || null, title: one(r.title || r.job, 120), at: r.at, state: r.state, ini: r.ini || null, undo: canUndo(r) });
113
119
  }
114
120
  for (const l of Array.isArray(input.bgQueue) ? input.bgQueue : []) {
115
121
  if (!isObj(l) || l.kind !== 'done' || !inWin(l.at) || (ws && l.ws && l.ws !== ws)) continue;
@@ -154,12 +160,13 @@ function compute(input = {}, { now = Date.now(), days = DAYS, ws = null, name =
154
160
 
155
161
  // MINUTES: the Driver's runs that ended in the window
156
162
  const wakeOf = new Map(state.wakes.map((w) => [w.key, w]));
157
- let runs = 0;
163
+ let runs = 0, lastRun = null;
158
164
  for (const r of state.runs.values()) {
159
165
  if (!r.end || !inWin(r.end)) continue;
160
166
  const t0 = ms(r.start), t1 = ms(r.end);
161
167
  if (t0 == null || t1 == null || t1 < t0) continue;
162
168
  runs++;
169
+ if (!lastRun || t1 > ms(lastRun)) lastRun = new Date(t1).toISOString();
163
170
  const mins = (t1 - t0) / 60000;
164
171
  let keys = [...new Set([...state.proposals.values()].filter((p) => p.run === r.run).map((p) => stationOfJob('driver:' + p.what, { kind: p.target.kind })).filter(Boolean))];
165
172
  if (!keys.length) {
@@ -170,12 +177,13 @@ function compute(input = {}, { now = Date.now(), days = DAYS, ws = null, name =
170
177
  }
171
178
  }
172
179
  if (!keys.length) { unplaced.minutes += mins; continue; }
173
- for (const k of keys) st.get(k).minutes += mins / keys.length;
180
+ for (const k of keys) { st.get(k).minutes += mins / keys.length; st.get(k).runs++; }
174
181
  }
175
182
 
176
- const stations = [...st.values()].map(({ _targets, ...s }) => ({ ...s, minutes: Math.round(s.minutes) }));
183
+ const newest = (a, b) => String(b.at || '').localeCompare(String(a.at || ''));
184
+ const stations = [...st.values()].map(({ _targets, ...s }) => ({ ...s, minutes: Math.round(s.minutes), madeItems: s.madeItems.sort(newest).slice(0, MAX_MADE) }));
177
185
  return { v: 1, at: new Date(now).toISOString(), ws, name, days, from: new Date(from).toISOString(), stations,
178
- unplaced: { made: unplaced.made, minutes: Math.round(unplaced.minutes) }, runs, tokens: null, money: null, usage: NOT_RECORDED };
186
+ unplaced: { made: unplaced.made, minutes: Math.round(unplaced.minutes) }, runs, lastRun, tokens: null, money: null, usage: NOT_RECORDED };
179
187
  }
180
188
 
181
189
  /* ── the read (no write) ── */
@@ -234,7 +242,7 @@ function ageMinutes(root, now = Date.now()) {
234
242
  return t == null ? -1 : Math.max(0, Math.floor((now - t) / 60000));
235
243
  }
236
244
 
237
- module.exports = { STATIONS, WHAT_STATION, GROUP_STATION, RUN_STATION, CODE_STATION, FILE, DAYS, LOG, NOT_RECORDED, MAX_ITEMS,
245
+ module.exports = { STATIONS, WHAT_STATION, GROUP_STATION, RUN_STATION, CODE_STATION, FILE, DAYS, LOG, NOT_RECORDED, MAX_ITEMS, MAX_MADE,
238
246
  stationOfJob, stationOfCode, compute, read, build, fileOf, save, load, ageMinutes };
239
247
 
240
248
  // `node lib/factory-floor.js age <checkout>`: the health number, minutes since the snapshot was saved (-1 when there is none)
@@ -1,31 +1,31 @@
1
1
  {
2
- "about": "The user features of PMOS, one row each, for the chat's / menu, the typed-words suggestion, the What PMOS can do directory, Ctrl+K and the ? sheet (initiative feature-directory). Only audience user rows are shown. A row with cmd names a pmos verb (lib/pmos-verbs.js) that its prompt runs; place is a page key of the menu (pm/cozy-nav.js). since is the first version that has the feature. features.test.js F1 checks every row.",
2
+ "about": "The user features of PMOS, one row each, for the chat's / menu, the typed-words suggestion, the What PMOS can do directory, Ctrl+K and the ? sheet (initiative feature-directory). Only audience user rows are shown. A row with cmd names a pmos verb (lib/pmos-verbs.js) that its prompt runs; place is a page key of the menu (pm/cozy-nav.js). since is the first version that has the feature. ask lists the record kinds the Ask card offers the feature on (pm/ask-here-ctx.js actionsOf: one press asks it about the pressed record). features.test.js F1 checks every row.",
3
3
  "groups": ["Plan and decide", "Before you ship", "Catch up", "Your product", "What PMOS did", "Find your way"],
4
4
  "features": [
5
5
  {"id": "goal", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Give PMOS a goal", "say": "PMOS asks a few questions, then works on the goal after you press Start.", "cmd": "/goal", "phrases": ["work on this until", "keep going until", "make it happen"], "since": "0.560.0"},
6
- {"id": "why", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Why this work exists", "say": "Three lines on an initiative or a task: its goal, its problem and the evidence.", "cmd": "/why", "verb": "why", "hint": "<initiative or task>", "phrases": ["why does this exist", "why are we doing", "why are we building", "what is the point of", "reason for this work", "why this initiative"], "phone": true, "since": "0.700.0"},
6
+ {"id": "why", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Why this work exists", "say": "Three lines on an initiative or a task: its goal, its problem and the evidence.", "cmd": "/why", "verb": "why", "hint": "<initiative or task>", "phrases": ["why does this exist", "why are we doing", "why are we building", "what is the point of", "reason for this work", "why this initiative"], "phone": true, "since": "0.700.0", "ask": ["initiative", "task"]},
7
7
  {"id": "rehearse", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Rehearse a change", "say": "Move a task by some days and see what else slips, before anything changes.", "cmd": "/rehearse", "verb": "rehearse", "sub": "move", "hint": "<task> <days>", "place": "board", "phrases": ["what if slips", "what happens if slips", "what if move", "push back", "delay by", "slips a week", "what breaks if", "move the date", "what if we cut"], "since": "0.600.0"},
8
8
  {"id": "decisions", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Decision journal", "say": "Write one line per decision, with what you expect and the date to check it.", "cmd": "/decide", "verb": "decisions", "sub": "add", "hint": "<the decision>", "phrases": ["we decided", "log a decision", "record a decision", "note the decision", "decision journal", "list decisions"], "since": "0.640.0"},
9
9
  {"id": "questions", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Open questions", "say": "Every question nobody has answered yet, oldest first, in one list.", "cmd": "/questions", "verb": "questions", "phrases": ["open questions", "unanswered questions", "what is still open", "questions nobody answered", "what do we not know"], "phone": true, "since": "0.660.0"},
10
- {"id": "press-release", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Press release and FAQ", "say": "A one-page press release and FAQ for a bet, drafted from its record, for you to edit.", "cmd": "/press-release", "verb": "press-release", "hint": "<initiative>", "phrases": ["press release", "working backwards", "write the faq", "announce this"], "since": "0.690.0"},
11
- {"id": "launch", "audience": "user", "status": "ga", "group": "Before you ship", "name": "What is not ready", "say": "Before a launch date: the tasks, sign-offs and documents still open.", "cmd": "/launch", "verb": "launch", "sub": "check", "hint": "<initiative>", "phrases": ["ready to launch", "what is not ready", "before launch", "launch checklist", "can we ship", "ready to ship", "is it ready for launch"], "since": "0.650.0"},
12
- {"id": "ready", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Ready for engineers", "say": "The five basics the engineers need before the tickets go to them.", "cmd": "/ready", "verb": "ready", "sub": "check", "hint": "<initiative>", "phrases": ["ready for engineering", "ready for engineers", "ready for dev", "hand over to engineers", "ready for development"], "since": "0.650.0"},
13
- {"id": "critic", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Critic before you share", "say": "Reads a document as a sceptical reviewer and lists the hardest questions.", "cmd": "/critic", "verb": "critic", "hint": "<document>", "phrases": ["poke holes", "review this doc", "critique this", "before I share", "hardest questions", "sceptical review", "skeptical review", "what would they ask"], "since": "0.680.0"},
10
+ {"id": "press-release", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Press release and FAQ", "say": "A one-page press release and FAQ for a bet, drafted from its record, for you to edit.", "cmd": "/press-release", "verb": "press-release", "hint": "<initiative>", "phrases": ["press release", "working backwards", "write the faq", "announce this"], "since": "0.690.0", "ask": ["initiative"]},
11
+ {"id": "launch", "audience": "user", "status": "ga", "group": "Before you ship", "name": "What is not ready", "say": "Before a launch date: the tasks, sign-offs and documents still open.", "cmd": "/launch", "verb": "launch", "sub": "check", "hint": "<initiative>", "phrases": ["ready to launch", "what is not ready", "before launch", "launch checklist", "can we ship", "ready to ship", "is it ready for launch"], "since": "0.650.0", "ask": ["initiative"]},
12
+ {"id": "ready", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Ready for engineers", "say": "The five basics the engineers need before the tickets go to them.", "cmd": "/ready", "verb": "ready", "sub": "check", "hint": "<initiative>", "phrases": ["ready for engineering", "ready for engineers", "ready for dev", "hand over to engineers", "ready for development"], "since": "0.650.0", "ask": ["initiative"]},
13
+ {"id": "critic", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Critic before you share", "say": "Reads a document as a sceptical reviewer and lists the hardest questions.", "cmd": "/critic", "verb": "critic", "hint": "<document>", "phrases": ["poke holes", "review this doc", "critique this", "before I share", "hardest questions", "sceptical review", "skeptical review", "what would they ask"], "since": "0.680.0", "ask": ["document"]},
14
14
  {"id": "missed", "audience": "user", "status": "ga", "group": "Catch up", "name": "What you might have missed", "say": "What each of the last weeks would have shown you, in one list.", "cmd": "/missed", "verb": "drift", "sub": "show", "phrases": ["what did I miss", "what have I missed", "catch me up", "while I was away", "what changed this week", "what changed since"], "phone": true, "since": "0.620.0"},
15
15
  {"id": "past", "audience": "user", "status": "ga", "group": "Catch up", "name": "Ask about the past", "say": "The decisions, notes and records that answer a question, each with its source.", "cmd": "/past", "verb": "past", "sub": "ask", "hint": "<question>", "phrases": ["when did we decide", "why did we decide", "who decided", "what did we agree", "last time we", "history of"], "phone": true, "since": "0.630.0"},
16
16
  {"id": "parked", "audience": "user", "status": "ga", "group": "Catch up", "name": "Parked work", "say": "Each initiative on hold, why it is parked and what brings it back.", "cmd": "/parked", "verb": "parked", "sub": "list", "phrases": ["parked work", "what is on hold", "what is parked", "paused initiatives"], "since": "0.700.0"},
17
17
  {"id": "people", "audience": "user", "status": "ga", "group": "Catch up", "name": "People you work with", "say": "Each person with their role, how often you talk and their tone.", "cmd": "/people", "verb": "people", "sub": "list", "phrases": ["who do I work with", "stakeholders list", "people on this", "who is involved"], "since": "0.610.0"},
18
- {"id": "strategy", "audience": "user", "status": "ga", "group": "Your product", "name": "Five-line strategy", "say": "Who it is for, the problem, the bet, how you win and what you will not do.", "cmd": "/strategy", "verb": "strategy", "sub": "show", "place": "board", "phrases": ["our strategy", "product strategy", "draft the strategy", "how we win"], "since": "0.776.0"},
19
- {"id": "code", "audience": "user", "status": "ga", "group": "Your product", "name": "Code map", "say": "One line per main part of the code: what it is, how it is tested, who changed it last.", "cmd": "/code", "verb": "code", "sub": "show", "place": "board", "since": "0.826.0"},
18
+ {"id": "strategy", "audience": "user", "status": "ga", "group": "Your product", "name": "Five-line strategy", "say": "Who it is for, the problem, the bet, how you win and what you will not do.", "cmd": "/strategy", "verb": "strategy", "sub": "show", "place": "board", "phrases": ["our strategy", "product strategy", "draft the strategy", "how we win"], "since": "0.776.0", "ask": ["product"]},
19
+ {"id": "code", "audience": "user", "status": "ga", "group": "Your product", "name": "Code map", "say": "One line per main part of the code: what it is, how it is tested, who changed it last.", "cmd": "/code", "verb": "code", "sub": "show", "place": "board", "since": "0.826.0", "ask": ["product"]},
20
20
  {"id": "connectors", "audience": "user", "status": "ga", "group": "Your product", "name": "What connectors read and write", "say": "What PMOS reads and writes through each connector, and what leaves this computer.", "cmd": "/connectors", "verb": "connectors", "sub": "data", "since": "0.825.0"},
21
21
  {"id": "positioning", "audience": "user", "status": "ga", "group": "Your product", "name": "Positioning and key messages", "say": "A positioning statement and key messages, each citing a strategy line.", "cmd": "/positioning", "verb": "positioning", "sub": "list", "phrases": ["positioning statement", "key messages", "messaging for"], "since": "0.740.0"},
22
22
  {"id": "principles", "audience": "user", "status": "ga", "group": "Your product", "name": "Product principles", "say": "Four to six principles drafted from your past decisions, each citing them.", "cmd": "/principles", "verb": "principles", "sub": "list", "phrases": ["product principles", "our principles", "design principles for"], "since": "0.720.0"},
23
23
  {"id": "glossary", "audience": "user", "status": "ga", "group": "Your product", "name": "Glossary", "say": "The product's own words; every page shows a word's meaning on hover.", "cmd": "/glossary", "verb": "glossary", "sub": "list", "hint": "<word>", "phrases": ["define the word", "glossary", "add to glossary", "meaning of the word"], "since": "0.690.0"},
24
- {"id": "health", "audience": "user", "status": "ga", "group": "Your product", "name": "Health score", "say": "This product's health from 0 to 100, and the three parts that make it.", "cmd": "/health", "verb": "health", "sub": "score", "phrases": ["health score", "how healthy is", "product health"], "phone": true, "since": "0.737.0"},
24
+ {"id": "health", "audience": "user", "status": "ga", "group": "Your product", "name": "Health score", "say": "This product's health from 0 to 100, and the three parts that make it.", "cmd": "/health", "verb": "health", "sub": "score", "phrases": ["health score", "how healthy is", "product health"], "phone": true, "since": "0.737.0", "ask": ["product"]},
25
25
  {"id": "outcomes", "audience": "user", "status": "ga", "group": "Your product", "name": "Did it work?", "say": "Each initiative's expected outcome and the date to check it.", "cmd": "/outcomes", "verb": "outcomes", "sub": "list", "phrases": ["did it work", "expected outcome", "outcomes due", "check the outcome"], "since": "0.640.0"},
26
26
  {"id": "changed", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "What PMOS changed by itself", "say": "Every change PMOS made on its own today, with its source and its Undo.", "cmd": "/changed", "verb": "factory", "sub": "today", "phrases": ["what did pmos change", "what did you change", "changes pmos made", "what did the agents do"], "phone": true, "since": "0.700.0"},
27
27
  {"id": "autonomy", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "What agents applied", "say": "What agents applied by themselves in the last 14 days, each with its Undo.", "cmd": "/applied", "verb": "autonomy", "sub": "status", "phrases": ["what did agents apply", "applied by themselves", "auto applied"], "since": "0.680.0"},
28
- {"id": "describe", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Task descriptions", "say": "What, why and done-when for each task, drafted from its sources.", "cmd": "/describe", "verb": "task", "sub": "describe", "hint": "<task>", "place": "board", "phrases": ["describe this task", "task description", "write the description", "what is this task about"], "since": "0.770.0"},
28
+ {"id": "describe", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Task descriptions", "say": "What, why and done-when for each task, drafted from its sources.", "cmd": "/describe", "verb": "task", "sub": "describe", "hint": "<task>", "place": "board", "phrases": ["describe this task", "task description", "write the description", "what is this task about"], "since": "0.770.0", "ask": ["task"]},
29
29
  {"id": "search", "audience": "user", "status": "ga", "group": "Find your way", "name": "Search and ask", "say": "Ctrl+K finds work, pages and features, and answers questions from your files.", "keys": "Ctrl K", "since": "0.737.0"},
30
30
  {"id": "action-keys", "audience": "user", "status": "ga", "group": "Find your way", "name": "Keys for the five common actions", "say": "Yes, open, next sprint, park and undo, one key each. Press ? to see them.", "keys": "?", "since": "0.730.0"},
31
31
  {"id": "guide", "audience": "user", "status": "ga", "group": "Find your way", "name": "The Guide", "say": "How each part of PMOS works, page by page.", "action": "guide", "since": "0.500.0"},
@@ -38,7 +38,7 @@
38
38
  {"id": "report", "audience": "user", "status": "ga", "group": "Your product", "name": "Draft and issue a report", "say": "Draft a cadence report with every number filled in, then issue it.", "cmd": "/report", "verb": "report", "hint": "<cadence>"},
39
39
  {"id": "jira", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Jira tickets from the spec", "say": "Draft Jira tickets from the PRD, approve them and see their status.", "cmd": "/jira", "verb": "jira"},
40
40
  {"id": "docs", "audience": "user", "status": "ga", "group": "Your product", "name": "Linked documents in step", "say": "Is each linked document the same as, ahead of or behind its Google Docs or Confluence copy.", "cmd": "/docs", "verb": "docs"},
41
- {"id": "signoff", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Sign-offs", "say": "Ask for, answer and list the sign-offs an initiative waits on.", "cmd": "/signoff", "verb": "signoff", "hint": "<initiative>"},
41
+ {"id": "signoff", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Sign-offs", "say": "Ask for, answer and list the sign-offs an initiative waits on.", "cmd": "/signoff", "verb": "signoff", "hint": "<initiative>", "ask": ["initiative"]},
42
42
  {"id": "my-work", "audience": "user", "status": "ga", "group": "Catch up", "name": "Your assigned work", "say": "The Jira tickets and plan items assigned to you, ranked.", "cmd": "/my-work", "verb": "my-work"},
43
43
  {"id": "tracker", "audience": "user", "status": "ga", "group": "Catch up", "name": "When the tracker was last read", "say": "When tracker items were last read and how much matches the last Jira read.", "cmd": "/tracker", "verb": "tracker"},
44
44
  {"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"},
@@ -56,8 +56,9 @@
56
56
  {"id": "away", "audience": "user", "status": "ga", "group": "Catch up", "name": "Away days", "say": "Set your away days, read the handover note and see what moved while you were away.", "cmd": "/away", "verb": "away"},
57
57
  {"id": "try", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "Try what shipped", "say": "The changes your recent updates brought, how to try each, and your answer.", "cmd": "/try", "verb": "try"},
58
58
  {"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"},
59
- {"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>"},
59
+ {"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>", "ask": ["initiative"]},
60
60
  {"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"},
61
+ {"id": "print", "audience": "user", "status": "ga", "group": "Your product", "name": "Print or PDF", "say": "One clean page of a report or an initiative, to print or save as PDF.", "cmd": "/print", "verb": "print", "hint": "<file or initiative>"},
61
62
  {"id": "prototype", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Simulated users try the prototype", "say": "Where simulated users, one per persona, got stuck on a prototype, and the personas that walk it.", "cmd": "/prototype", "verb": "prototype", "hint": "findings <initiative>"},
62
63
  {"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"},
63
64
  {"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>"},
@@ -72,7 +73,7 @@
72
73
  {"id": "setup", "audience": "user", "status": "ga", "group": "Find your way", "name": "Set up a new product", "say": "The tracker read, an agreed goal and an owner for a new product.", "cmd": "/setup", "verb": "setup"},
73
74
  {"id": "loop", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "A goal agents work on", "say": "Start, check and stop a goal agents work on until it is done.", "cmd": "/loop", "verb": "loop"},
74
75
  {"id": "scan", "audience": "user", "status": "ga", "group": "Catch up", "name": "Horizon scan", "say": "The portfolio watch list and what the scan found.", "cmd": "/scan", "verb": "scan"},
75
- {"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>"},
76
+ {"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>", "ask": ["initiative"]},
76
77
  {"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"},
77
78
  {"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"},
78
79
  {"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"},
@@ -8,6 +8,7 @@
8
8
  * pmos people settings [--json] whether calendar attendee names are kept
9
9
  * pmos people map <initiative> [--json] who decides, must agree, needs to know, and when each last heard (A371)
10
10
  * pmos people keep|drop|told|undo <initiative> <person> [--group decides|agree|know] the PM's word on one name (lib/stakeholder-map.js)
11
+ * pmos people prep <person> [--days N] [--json] a 1:1 brief from the tasks they own (lib/people-prep.js, idea A85)
11
12
  *
12
13
  * The same module the People place reads (lib/people-store.js), so a terminal line and the page cannot disagree.
13
14
  * `list` and `show` first record the names this repository's records hold (plan item owners, Live notes speakers), as
@@ -22,7 +23,7 @@ const path = require('path');
22
23
  const store = require('./people-store');
23
24
  const { parseArgs } = require('./schedule-cli');
24
25
 
25
- const COMMANDS = { people: ['list', 'show', 'record', 'settings', 'map', 'keep', 'drop', 'told', 'undo'] };
26
+ const COMMANDS = { people: ['list', 'show', 'record', 'settings', 'map', 'keep', 'drop', 'told', 'undo', 'prep'] };
26
27
  const USAGE = [
27
28
  'usage: pmos people [list|show|record|settings] — the people you work with in this repository',
28
29
  ' pmos people [list] [--json] each person, and what waits for you in the review list',
@@ -32,6 +33,7 @@ const USAGE = [
32
33
  ' pmos people map <initiative> [--json] who decides, who must agree, who needs to know, and when each last heard from you',
33
34
  ' pmos people keep <initiative> <person> [--group decides|agree|know] keep a name on the map (in that group)',
34
35
  ' 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',
36
+ ' pmos people prep <person> [--days N] [--json] a 1:1 brief: what they shipped, where they are stuck, one thing to recognise',
35
37
  'Nothing here removes a person, merges, sets a tone or writes a note. Do that in People. PMOS never sends an update: you do.',
36
38
  ];
37
39
  const BOOL = new Set(['json', 'help']);
@@ -64,6 +66,12 @@ const toneWord = (t) => (t.confirmed ? t.confirmed : t.proposed ? `${t.proposed}
64
66
  const handleText = (h) => `${h.kind} ${h.value}`;
65
67
 
66
68
  async function run(argv, { say = console.log, cwd = process.cwd(), env = process.env, now = Date.now() } = {}) {
69
+ // a 1:1 brief reads only the tasks (lib/people-prep.js): its own options, before the people store is scanned
70
+ if (argv[1] === 'prep') {
71
+ const rest = argv.slice(2), r = rest.indexOf('--root');
72
+ const root = r >= 0 && rest[r + 1] ? path.resolve(cwd, rest[r + 1]) : repoRoot(cwd);
73
+ return require('./people-prep.js').run(r >= 0 ? rest.filter((_, i) => i !== r && i !== r + 1) : rest, { say, root, env, now });
74
+ }
67
75
  const { pos, flags } = parse(argv.slice(1));
68
76
  const sub = pos[0] || 'list';
69
77
  if (flags.help || sub === 'help') { USAGE.forEach((l) => say(l)); return 0; }
@@ -0,0 +1,140 @@
1
+ 'use strict';
2
+ /* people-prep.js — a 1:1 brief for one person, from the tasks they own (idea A85, factory job #1997, initiative people-prep).
3
+ *
4
+ * prepOf(tasks, who, { today, days }) PURE → { who, owners, shipped, stuck, recognise, days }
5
+ * linesOf(p) PURE → the brief as lines, each with its source
6
+ * matchOf(owners, who) PURE → the owner names that are this person
7
+ * tasksAll(root, stateDir) → every task of the repository: the Board's tasks and the breakdown items, read the way
8
+ * `pmos task list` reads them (lib/routes-boards.js foldOf, lib/task-items.js rowsOf)
9
+ * run(argv, o) → `pmos people prep <person> [--days N] [--json]` (lib/people-cli.js routes it here)
10
+ *
11
+ * THE THREE PARTS. Shipped: their tasks that went to Done in the last `days` days, by the day the state changed, newest first. Stuck:
12
+ * their open tasks (To do, In progress) past the due day, or marked blocked; each says which. Recognise: one Done task of those days,
13
+ * the newest that landed on or before its due day, else the newest Done. Nothing Done, no recognition: nothing is made up.
14
+ * Every line names its source: the task id and its initiative.
15
+ *
16
+ * WHO. An owner matches when its name, with case and a `person:` prefix ignored, is the name asked for. A one-word name also matches a
17
+ * first name, but only when exactly one owner has that first name, so "Dan" never picks up Dana's tasks and "Sam" asks which Sam.
18
+ *
19
+ * READS ONLY. The task ledger and the plan items are read, never written. The one write is a local use-log line (control peoplePrep, the
20
+ * health number), in the runtime folder outside every repository. */
21
+ const path = require('path');
22
+
23
+ const TAG = '[people-prep]';
24
+ const DAYS = 14;
25
+ const DONE = 'Done';
26
+ const OPEN = new Set(['To do', 'In progress']);
27
+ const DAY = 86400000;
28
+
29
+ const nameOf = (o) => String(o == null ? '' : o).replace(/^person:/i, '').replace(/\s+/g, ' ').trim();
30
+ const low = (s) => nameOf(s).toLowerCase().replace(/[-_]+/g, ' '); // a People id (dana-lee) reads as the name
31
+ const dayOf = (v) => { const s = String(v || '').slice(0, 10); return /^\d{4}-\d{2}-\d{2}$/.test(s) ? s : ''; };
32
+ const daysBetween = (a, b) => Math.round((Date.parse(b + 'T00:00:00Z') - Date.parse(a + 'T00:00:00Z')) / DAY);
33
+
34
+ /** The owner names that are this person. PURE. */
35
+ function matchOf(owners, who) {
36
+ const q = low(who);
37
+ if (!q) return [];
38
+ const all = [...new Set((owners || []).map(nameOf).filter(Boolean))];
39
+ const exact = all.filter((o) => low(o) === q);
40
+ if (exact.length || q.includes(' ')) return exact;
41
+ const first = all.filter((o) => low(o).split(' ')[0] === q);
42
+ const people = new Set(first.map(low));
43
+ return people.size === 1 ? first : [];
44
+ }
45
+ /** Several owners share that first name: who they are, so the brief can ask which one. PURE. */
46
+ function ambiguousOf(owners, who) {
47
+ const q = low(who);
48
+ if (!q || q.includes(' ')) return [];
49
+ const first = [...new Set((owners || []).map(nameOf).filter((o) => low(o).split(' ')[0] === q && low(o) !== q))];
50
+ return first.length > 1 ? first.sort() : [];
51
+ }
52
+
53
+ const src = (t) => 'task ' + t.id + (t.initiative ? ' on ' + t.initiative : '');
54
+
55
+ /** The brief. tasks: [{ id, title, state, owner, due, since, blocked, initiative }]. PURE. */
56
+ function prepOf(tasks, who, { today, days = DAYS } = {}) {
57
+ const t0 = dayOf(today) || new Date().toISOString().slice(0, 10);
58
+ const list = Array.isArray(tasks) ? tasks.filter((t) => t && t.id && t.title) : [];
59
+ const owners = matchOf(list.map((t) => t.owner), who);
60
+ const mine = new Set(owners.map(low));
61
+ const own = list.filter((t) => mine.has(low(t.owner)));
62
+ const from = new Date(Date.parse(t0 + 'T00:00:00Z') - days * DAY).toISOString().slice(0, 10);
63
+ const shipped = own.filter((t) => t.state === DONE && dayOf(t.since) && dayOf(t.since) >= from && dayOf(t.since) <= t0)
64
+ .sort((a, b) => dayOf(b.since).localeCompare(dayOf(a.since)) || String(a.id).localeCompare(String(b.id)))
65
+ .map((t) => ({ id: t.id, title: t.title, initiative: t.initiative || '', on: dayOf(t.since), due: dayOf(t.due), source: src(t) }));
66
+ const stuck = own.filter((t) => OPEN.has(t.state) && (t.blocked || (dayOf(t.due) && dayOf(t.due) < t0)))
67
+ .map((t) => {
68
+ const late = dayOf(t.due) && dayOf(t.due) < t0 ? daysBetween(dayOf(t.due), t0) : 0;
69
+ const why = [late ? late + (late === 1 ? ' day late' : ' days late') : '', t.blocked ? 'blocked' + (t.reason ? ': ' + String(t.reason).slice(0, 120) : '') : ''].filter(Boolean).join(', ');
70
+ return { id: t.id, title: t.title, initiative: t.initiative || '', state: t.state, late, blocked: !!t.blocked, why, source: src(t) };
71
+ })
72
+ .sort((a, b) => b.late - a.late || String(a.id).localeCompare(String(b.id)));
73
+ const onTime = shipped.filter((s) => s.due && s.on <= s.due);
74
+ const pick = onTime[0] || shipped[0] || null;
75
+ const recognise = pick ? { ...pick, why: pick.due && pick.on <= pick.due ? (pick.on < pick.due ? 'landed ' + daysBetween(pick.on, pick.due) + (daysBetween(pick.on, pick.due) === 1 ? ' day' : ' days') + ' before its due day' : 'landed on its due day') : 'the newest one Done' } : null;
76
+ return { who: nameOf(who), owners, ambiguous: owners.length ? [] : ambiguousOf(list.map((t) => t.owner), who), days, today: t0, shipped, stuck, recognise };
77
+ }
78
+
79
+ /** The brief as lines. PURE. */
80
+ function linesOf(p) {
81
+ const name = p.owners[0] || p.who;
82
+ if (!p.owners.length) {
83
+ if (p.ambiguous && p.ambiguous.length) return [`More than one person is called ${p.who}: ${p.ambiguous.join(', ')}. Name one in full.`];
84
+ return [`No task names ${p.who} as its owner, so there is nothing to prepare from the tasks. pmos people show ${p.who} lists what else PMOS knows.`];
85
+ }
86
+ const out = [`1:1 with ${name} · the last ${p.days} days`];
87
+ out.push(p.shipped.length ? `Shipped (${p.shipped.length}):` : `Shipped: nothing Done in the last ${p.days} days.`);
88
+ for (const s of p.shipped) out.push(` ${s.on} ${s.title} — ${s.source}`);
89
+ out.push(p.stuck.length ? `Stuck (${p.stuck.length}):` : 'Stuck: no open task is late or blocked.');
90
+ for (const s of p.stuck) out.push(` ${s.title} · ${s.why} — ${s.source}`);
91
+ if (p.recognise) out.push(`Recognise: ${p.recognise.title}, ${p.recognise.why} — ${p.recognise.source}`);
92
+ return out;
93
+ }
94
+
95
+ /** Every task of the repository, read the way `pmos task list` reads them. */
96
+ function tasksAll(root, stateDir) {
97
+ const SR = require('./stage-read.js');
98
+ const { w, ctx } = SR.cliCtx(root, stateDir);
99
+ const out = [];
100
+ try {
101
+ const F = require('./routes-boards.js').foldOf(ctx, w);
102
+ for (const t of (F.tasks || new Map()).values()) {
103
+ if (!t || t.kind === 'Epic') continue;
104
+ out.push({ id: t.id, title: t.title, state: t.state, owner: t.owner || '', due: t.due || '', since: t.since || '', blocked: false, initiative: t.initiative || '' });
105
+ }
106
+ } catch { /* no board ledger: the breakdown items alone */ }
107
+ try {
108
+ for (const x of require('./task-items.js').rowsOf(root, { has: () => true }, null)) {
109
+ out.push({ id: x.uid, title: x.title, state: x.status, owner: x.owner || '', due: x.end || '', since: x.since || '', blocked: !!x.blocked, reason: x.reason || '', initiative: x.ini || '' });
110
+ }
111
+ } catch { /* no plan items */ }
112
+ return out;
113
+ }
114
+
115
+ const USAGE = 'usage: pmos people prep <person> [--days N] [--json] a 1:1 brief: what they shipped, where they are stuck, one thing to recognise';
116
+
117
+ /** `pmos people prep <person> [--days N] [--json]`. argv: the words after `prep`. → exit code */
118
+ function run(argv, { say = console.log, root, stateDir, today, env = process.env, now = Date.now(), useDir } = {}) {
119
+ const pos = [], flags = {};
120
+ for (let i = 0; i < argv.length; i++) {
121
+ const a = argv[i];
122
+ if (a === '--json') flags.json = true;
123
+ else if (a === '--days') flags.days = argv[++i];
124
+ else if (a.startsWith('--')) { say(`✗ --${a.slice(2)} is not an option of pmos people prep`); return 2; }
125
+ else pos.push(a);
126
+ }
127
+ const who = pos.join(' ').trim();
128
+ if (!who) { say(USAGE); return 2; }
129
+ const days = flags.days === undefined ? DAYS : Number(flags.days);
130
+ if (!Number.isInteger(days) || days < 1 || days > 90) { say('✗ --days is a whole number from 1 to 90'); return 2; }
131
+ const dir = stateDir === undefined ? require('./driver.js').stateDirOf(root) : stateDir;
132
+ const p = prepOf(tasksAll(root, dir), who, { today: today || new Date(now).toISOString().slice(0, 10), days });
133
+ try { console.error(`${TAG} ${p.owners.length ? 'prepared' : 'no owner'}: ${p.shipped.length} shipped, ${p.stuck.length} stuck`); } catch { /* no console */ }
134
+ try { require('./use-log.js').record(useDir || require('./state-root.js').defaultRoot({ env }), [{ kind: 'use', page: 'people', control: 'peoplePrep', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ }
135
+ if (flags.json) { say(JSON.stringify({ ok: true, ...p })); return 0; }
136
+ for (const l of linesOf(p)) say(l);
137
+ return 0;
138
+ }
139
+
140
+ module.exports = { TAG, DAYS, prepOf, linesOf, matchOf, ambiguousOf, tasksAll, run, USAGE };
@@ -171,6 +171,8 @@ const VERBS = Object.freeze({
171
171
  // Not a pm-os-absorb verb (run: null): initiative connector-data (job #1920, A150) added it through the same table.
172
172
  connectors: Object.freeze({ module: 'connectors-cli.js', run: null, guide: 'cli.md',
173
173
  help: 'pmos connectors data [<connector>] — what PMOS reads and writes through each connector, and what leaves this computer (pmos connectors help)' }),
174
+ print: Object.freeze({ module: 'print-cli.js', run: null, guide: 'cli.md',
175
+ help: 'pmos print <file.md|initiative id> [--out file.html] — one clean page to print or save as PDF (pmos print help)' }),
174
176
  // Not a pm-os-absorb verb (run: null): initiative press-release-faq (bet A362) added it through the same table.
175
177
  'press-release': Object.freeze({ module: 'press-release-cli.js', run: null, guide: 'cli.md',
176
178
  help: 'pmos press-release <initiative> | count — a one-page press release and FAQ for a bet, drafted from its record, for you to edit (pmos press-release help)' }),
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+ /* print-cli.js — `pmos print` (initiative print-pdf, job #1911, idea A379). The page comes from lib/print-pdf.js printFile: the same layout
3
+ * as Print or PDF in the workspace. One .html file is written; the PM opens it and chooses Save as PDF. Nothing is sent. */
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { TAG, brandOf, fileOf, printFile } = require('./print-pdf.js');
7
+
8
+ const COMMANDS = { print: ['brand'] };
9
+ const USAGE = [
10
+ 'usage: pmos print <file.md | initiative id> [--out <file.html>] — one clean page to print or save as PDF',
11
+ ' pmos print <initiative id> the initiative\'s record as a print page: title, date and page N of M on every page',
12
+ ' pmos print <file.md> --out x.html any report or document of the product; default <name>.print.html here',
13
+ ' pmos print brand the brand printed at the top right (the product\'s own design system), or none',
14
+ 'Open the page and choose Save as PDF. Nothing is sent.',
15
+ ];
16
+ function repoOf(cwd) {
17
+ let d = path.resolve(cwd);
18
+ for (;;) { try { if (fs.existsSync(path.join(d, '.git'))) return d; } catch { /* look further up */ } const up = path.dirname(d); if (up === d) return path.resolve(cwd); d = up; }
19
+ }
20
+ function used(o) {
21
+ try { const dir = o.stateDir || require('./state-root.js').defaultRoot({ env: o.env || process.env }); require('./use-log.js').record(dir, [{ kind: 'use', page: 'today', control: 'print-pdf', device: 'desk' }], o.now || Date.now()); } catch { /* a count, never a reason to fail */ }
22
+ }
23
+ async function run(argv, o = {}) {
24
+ const say = o.say || ((s) => console.log(s));
25
+ const args = argv[0] === 'print' ? argv.slice(1) : argv.slice();
26
+ const pos = [], flags = {};
27
+ for (let i = 0; i < args.length; i++) { const a = args[i]; if (a === '--root' || a === '--out' || a === '--date') flags[a.slice(2)] = args[++i]; else if (a === '--json') flags.json = true; else pos.push(a); }
28
+ const cmd = pos[0] || 'help';
29
+ if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return pos[0] ? 0 : 2; }
30
+ const root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd()));
31
+ if (cmd === 'brand') {
32
+ const b = brandOf(root);
33
+ if (flags.json) { say(JSON.stringify({ ok: true, brand: b })); return 0; }
34
+ say(b ? `Printed pages show the brand ${b}.` : 'No brand: this product has no design system of its own, so printed pages show none.');
35
+ return 0;
36
+ }
37
+ const file = fileOf(root, cmd);
38
+ const r = await printFile(root, file, { date: flags.date });
39
+ if (!r.ok) { say('✗ ' + r.error); return 1; }
40
+ const out = path.resolve(o.cwd || process.cwd(), flags.out || path.basename(file).replace(/\.md$/i, '') + '.print.html');
41
+ fs.writeFileSync(out, r.html);
42
+ used(o);
43
+ console.log(`${TAG} printed ${path.relative(root, file)} out=${path.basename(out)}`);
44
+ if (flags.json) { say(JSON.stringify({ ok: true, title: r.title, out })); return 0; }
45
+ say(`✓ Wrote ${out}: "${r.title}". Open it and choose Save as PDF.`);
46
+ return 0;
47
+ }
48
+
49
+ module.exports = { run, COMMANDS, USAGE };
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+ /* print-pdf.js — Print or PDF, the Node side (initiative print-pdf, job #1911, idea A379; board BatchMoreADS panel 26). The layout itself is
3
+ * public/pm/print-pdf.js (layoutHtml, cleanHtml), loaded here with import(), so the terminal, the page and a report sent as a copy print
4
+ * the same page.
5
+ *
6
+ * brandOf(root) → the product's own design system brand name (its design-system/brand/tokens.json `name`, idea A1), or '' when
7
+ * the product has none or only PMOS's own. Read only.
8
+ * sectionsHtml(md) PURE → { title, sections: [{ h, html }] } from a markdown file (lib/report-export.js parseReport, sectionsOf)
9
+ * printFile(root, rel, { date }) → Promise { ok, title, html } | { ok: false, error } a file inside the product only
10
+ * fileOf(root, what) → the file `pmos print` prints: a path, or an initiative id (planning/initiatives/<id>.md, a kit's
11
+ * pmos/planning/initiatives or pmos/state/initiatives)
12
+ *
13
+ * THE ROUTE (lib/routes-report-design.js owns the prefix and hands it here): GET /api/print?ws=<id> → { ok, brand }. Read only; nothing is written or sent.
14
+ *
15
+ * THE COMMAND (lib/print-cli.js): pmos print <file.md | initiative id> [--out <file.html>] [--json] · pmos print brand. It writes one .html file (default
16
+ * <name>.print.html in the current folder); the PM opens it and chooses Save as PDF. A file outside the product is refused (exit 1) and
17
+ * nothing is written. Each print logs one `[print-pdf]` line and one use-log line (control print-pdf), the count the kill reads. */
18
+ const fs = require('fs');
19
+ const path = require('path');
20
+ const { pathToFileURL } = require('url');
21
+
22
+ const TAG = '[print-pdf]';
23
+ const PAGE_JS = path.join(__dirname, '..', 'public', 'pm', 'print-pdf.js');
24
+ let page = null;
25
+ const layout = () => (page = page || import(pathToFileURL(PAGE_JS).href));
26
+
27
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
28
+ const inline = (s) => esc(s).replace(/\*\*([^*]+)\*\*/g, '<b>$1</b>');
29
+
30
+ /* ── the brand ── */
31
+ function brandOf(root) {
32
+ if (!root) return '';
33
+ let DS; try { DS = require('./design-system.js'); } catch { return ''; }
34
+ const own = path.resolve(DS.OWN);
35
+ for (const p of DS.PLACES || []) {
36
+ const d = path.join(root, p);
37
+ if (path.resolve(d) === own) continue;
38
+ try { const j = JSON.parse(fs.readFileSync(path.join(d, 'brand', 'tokens.json'), 'utf8')); const n = String((j && j.name) || '').trim(); if (n && n !== 'PMOS Brand') return n.slice(0, 80); } catch { /* no brand there */ }
39
+ }
40
+ return '';
41
+ }
42
+
43
+ /* ── markdown to sections ── */
44
+ function blockHtml(blocks) {
45
+ let out = '', list = false;
46
+ for (const b of blocks) {
47
+ if (b.t !== 'li' && list) { out += '</ul>'; list = false; }
48
+ if (b.t === 'li') { if (!list) { out += '<ul>'; list = true; } out += `<li>${inline(b.text)}</li>`; }
49
+ else if (b.t === 'h') out += `<h3>${inline(b.text)}</h3>`;
50
+ else if (b.t === 'p') out += `<p>${inline(b.text)}</p>`;
51
+ else if (b.t === 'table') out += `<table>${b.rows.map((r, i) => `<tr>${r.map((c) => (i ? `<td>${inline(c)}</td>` : `<th>${inline(c)}</th>`)).join('')}</tr>`).join('')}</table>`;
52
+ }
53
+ return out + (list ? '</ul>' : '');
54
+ }
55
+ function sectionsHtml(md) {
56
+ const RE = require('./report-export.js');
57
+ const rep = RE.parseReport(md);
58
+ return { title: rep.title, sections: RE.sectionsOf(rep).map((s) => ({ h: s.heading === rep.title ? '' : s.heading, html: blockHtml(s.blocks) })) };
59
+ }
60
+
61
+ const inside = (root, abs) => { const r = path.relative(path.resolve(root), abs); return !!r && !r.startsWith('..') && !path.isAbsolute(r); };
62
+
63
+ function fileOf(root, what) {
64
+ const w = String(what || '').trim();
65
+ if (!w) return null;
66
+ if (/^[a-z0-9][a-z0-9-]{0,80}$/.test(w) && !/\.md$/.test(w)) {
67
+ for (const d of ['planning/initiatives', 'pmos/planning/initiatives', 'pmos/state/initiatives']) {
68
+ const f = path.join(root, d, w + '.md');
69
+ if (fs.existsSync(f)) return f;
70
+ }
71
+ }
72
+ return path.resolve(root, w);
73
+ }
74
+
75
+ async function printFile(root, file, { date = '' } = {}) {
76
+ const abs = path.resolve(root, file);
77
+ if (!inside(root, abs)) return { ok: false, error: 'That file is outside this product. PMOS prints only the product\'s own files.' };
78
+ let md;
79
+ try { md = fs.readFileSync(abs, 'utf8'); } catch { return { ok: false, error: 'No such file: ' + path.relative(root, abs) }; }
80
+ const { title, sections } = sectionsHtml(md);
81
+ const L = await layout();
82
+ return { ok: true, title, html: L.layoutHtml({ title, date: date || L.dateLine(), brand: brandOf(root), sections }) };
83
+ }
84
+
85
+ /* ── the route ── */
86
+ const prefixes = ['/api/print'];
87
+ async function handle(req, res, url, ctx) {
88
+ if (url.pathname !== '/api/print') return false;
89
+ if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
90
+ let w = null;
91
+ try { w = ctx.getWs ? ctx.getWs(url.searchParams.get('ws') || null) : null; } catch { w = null; }
92
+ ctx.json(res, { ok: true, brand: w && w.root ? brandOf(w.root) : '' });
93
+ return true;
94
+ }
95
+
96
+ module.exports = { TAG, brandOf, sectionsHtml, fileOf, printFile, prefixes, handle };