create-pmos 0.837.0 → 0.839.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 (45) hide show
  1. package/package.json +83 -58
  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/changelog.json +82 -4
  7. package/workspace/guide/cli.md +11 -0
  8. package/workspace/guide/home.md +2 -0
  9. package/workspace/guide/initiatives-and-next-steps.md +8 -0
  10. package/workspace/guide/reports.md +9 -1
  11. package/workspace/lib/features.json +1 -0
  12. package/workspace/lib/hire-draft.js +4 -3
  13. package/workspace/lib/initiative-rows.js +3 -0
  14. package/workspace/lib/meeting-stance.js +199 -0
  15. package/workspace/lib/people-cli.js +44 -1
  16. package/workspace/lib/pmos-verbs.js +4 -1
  17. package/workspace/lib/report-translate.js +26 -1
  18. package/workspace/lib/report-variants.js +14 -1
  19. package/workspace/lib/route-modules.js +3 -0
  20. package/workspace/lib/routes-meeting-stance.js +43 -0
  21. package/workspace/lib/routes-reports.js +20 -3
  22. package/workspace/lib/routes-segments.js +47 -0
  23. package/workspace/lib/routes-surface-moments.js +36 -0
  24. package/workspace/lib/routes-today.js +15 -1
  25. package/workspace/lib/segments-cli.js +102 -0
  26. package/workspace/lib/segments.js +214 -0
  27. package/workspace/lib/surface-moments.js +185 -0
  28. package/workspace/lib/tracker-digest.js +12 -1
  29. package/workspace/package-lock.json +2 -2
  30. package/workspace/package.json +1 -1
  31. package/workspace/public/pm/cozy-board.css +11 -0
  32. package/workspace/public/pm/cozy-pop-work.js +5 -2
  33. package/workspace/public/pm/cozy-today-app.js +61 -2
  34. package/workspace/public/pm/cozy-today-model.js +70 -3
  35. package/workspace/public/pm/cozy-today-view.js +6 -0
  36. package/workspace/public/pm/meeting-stance.js +113 -0
  37. package/workspace/public/pm/premium-board.js +2 -0
  38. package/workspace/public/pm/premium-report-read.js +61 -3
  39. package/workspace/public/pm/segments.js +113 -0
  40. package/workspace/public/pm/standup-line.js +37 -0
  41. package/workspace/public/premium-board.html +2 -0
  42. package/workspace/test-lists/meeting-stance.json +9 -0
  43. package/workspace/test-lists/segments.json +9 -0
  44. package/workspace/test-lists/surface-moments.json +9 -0
  45. package/workspace/test-lists/surface-reports.json +9 -0
@@ -0,0 +1,199 @@
1
+ 'use strict';
2
+ /* meeting-stance.js — before the meeting on a contested decision, where each person stands (initiative meeting-stance, job #1897, idea A333;
3
+ * board BatchPeopleDS panel 10, agreed 2026-11-25). THE ONE WRITER and THE ONE FOLD of meeting-stance.jsonl. lib/people-cli.js is the verb
4
+ * (`pmos people stance`), lib/routes-meeting-stance.js the routes, public/pm/meeting-stance.js the block under People on the Work popup.
5
+ *
6
+ * THE CONTESTED DECISION. The newest decision in the journal (lib/decision-journal.js) of this initiative that is still live (not checked,
7
+ * not replaced, not undone) and that someone argued against (its `against`). A decision nobody argued against is not contested: no block.
8
+ * THE TWO QUESTIONS, drafted from it (nothing invented):
9
+ * 1. the decision as a yes/no question "Launch on 9 Dec?"
10
+ * 2. the objection, and whether it changes the answer "Support cost of the old flow: does it change your answer?"
11
+ * WHO IS ASKED. The people who decide or must agree on the stakeholder map (lib/stakeholder-map.js), kept or draft, not dropped. None: no block.
12
+ *
13
+ * PMOS NEVER SENDS THE QUESTIONS. The PM copies them and sends them, then presses "I sent them" (one `sent` line, with the people it went
14
+ * to, so the grid's columns stay fixed). Each answer is one `answer` line (yes, no, or '' to clear), from a press on the grid or the chat.
15
+ * `undo` takes back the last line for that decision. The GRID marks an answer that differs from its row's majority; agreement is plain.
16
+ * The ✦ SETTLE LINE names the question whose answers split most (a tie: the objection); when every answer agrees there is none.
17
+ *
18
+ * contestedOf(entries, ini) → entry | null
19
+ * questionsOf(entry) → [q1, q2]
20
+ * readLines(dir) · fold(lines, ini, decision) → { asked, people, answers: Map id → [a1, a2] }
21
+ * stanceOf({ ini, title, entries, rows, lines, now }) → null | { ini, title, decision, questions, people, asked, askedWord, grid, answered,
22
+ * total, settle, draft } grid: [{ q, n, cells: [{ id, name, says, diff }] }]
23
+ * act(dir, { ini, decision, kind, person, name, q, says, people }, { by, now }) → { ok, line } | { ok: false, error } kind ∈ sent · answer · undo
24
+ * count(dir) → question sets marked as sent (the health number)
25
+ * read(root, ini, o) → stanceOf(...) read from a product checkout, or null
26
+ * CLI: node lib/meeting-stance.js count <product checkout> prints `[meeting-stance] sent N` and N alone on the last line
27
+ *
28
+ * Append-only: one line per press { at, by, kind, ini, decision, person?, name?, q?, says?, people? }. Nothing here reads a connector,
29
+ * the outbox or the network, and nothing here sends anything.
30
+ */
31
+ const fs = require('fs');
32
+ const path = require('path');
33
+
34
+ const FILE = 'meeting-stance.jsonl';
35
+ const TAG = '[meeting-stance]';
36
+ const KINDS = ['sent', 'answer', 'undo'];
37
+ const SAYS = ['yes', 'no', ''];
38
+ const DAY = 86400000;
39
+ const ID_RE = /^[a-z0-9][a-z0-9-]{0,79}$/;
40
+ const DEC_RE = /^[A-Za-z0-9][\w.:-]{0,119}$/;
41
+
42
+ const one = (v, max = 200) => { const s = String(v == null ? '' : v).replace(/\s+/g, ' ').trim(); return s.length > max ? s.slice(0, max - 1).trimEnd() + '…' : s; };
43
+ const cap = (s) => s ? s[0].toUpperCase() + s.slice(1) : s;
44
+ const bare = (s) => one(s, 400).replace(/[.!;,\s]+$/, '');
45
+
46
+ /** The objection's words without the name it starts with ("Lee: support cost …" → "support cost …"). */
47
+ function objectionOf(against) {
48
+ const s = one(against, 400);
49
+ let w = null;
50
+ try { w = require('./approver-memory.js').whoOf(s); } catch { w = null; }
51
+ return { who: w && w.who ? w.who : null, text: one((w && w.text) || s, 400) };
52
+ }
53
+
54
+ /** The newest live journal decision of this initiative that someone argued against. */
55
+ function contestedOf(entries, ini) {
56
+ const live = (entries || []).filter((e) => e && e.initiative === ini && one(e.against) && !['checked', 'replaced', 'undone'].includes(e.state) && !e.undone);
57
+ live.sort((a, b) => String(b.date || '').localeCompare(String(a.date || '')) || String(b.id).localeCompare(String(a.id)));
58
+ return live[0] || null;
59
+ }
60
+
61
+ /** The two short questions for a contested decision. */
62
+ function questionsOf(entry) {
63
+ if (!entry) return [];
64
+ const d = bare(entry.decided).replace(/\?+$/, '');
65
+ const q1 = one(cap(d) + '?', 120);
66
+ const o = bare(objectionOf(entry.against).text);
67
+ const q2 = one(cap(o) + ': does it change your answer?', 160);
68
+ return [q1, q2];
69
+ }
70
+
71
+ function readLines(dir) {
72
+ if (!dir) return [];
73
+ let text = '';
74
+ try { text = fs.readFileSync(path.join(dir, FILE), 'utf8'); } catch { return []; }
75
+ const out = [];
76
+ for (const l of text.split('\n')) {
77
+ if (!l.trim()) continue;
78
+ try { const o = JSON.parse(l); if (o && KINDS.includes(o.kind) && o.ini && o.decision) out.push(o); } catch { /* a torn line is skipped */ }
79
+ }
80
+ return out;
81
+ }
82
+
83
+ /** The PM's presses on one decision, folded. An undo takes back the last line. */
84
+ function fold(lines, ini, decision) {
85
+ const steps = [];
86
+ for (const l of lines || []) {
87
+ if (l.ini !== ini || l.decision !== decision) continue;
88
+ if (l.kind === 'undo') steps.pop(); else steps.push(l);
89
+ }
90
+ const out = { asked: null, people: [], answers: new Map() };
91
+ for (const l of steps) {
92
+ if (l.kind === 'sent') { out.asked = String(l.at || '').slice(0, 10) || null; out.people = Array.isArray(l.people) ? l.people.filter((p) => p && p.id) : []; }
93
+ else if (l.kind === 'answer' && l.person && (l.q === 1 || l.q === 2)) {
94
+ const a = out.answers.get(l.person) || ['', ''];
95
+ a[l.q - 1] = SAYS.includes(l.says) ? l.says : '';
96
+ out.answers.set(l.person, a);
97
+ }
98
+ }
99
+ return out;
100
+ }
101
+
102
+ /** "asked Mon" within the week, else "asked 18 Nov". */
103
+ function askedWord(date, now) {
104
+ if (!date) return '';
105
+ const t = Date.parse(date + 'T00:00:00Z');
106
+ const today = Date.parse(new Date(now).toISOString().slice(0, 10) + 'T00:00:00Z');
107
+ const days = Math.round((today - t) / DAY);
108
+ if (days === 0) return 'asked today';
109
+ const d = new Date(t);
110
+ if (days > 0 && days < 7) return 'asked ' + d.toLocaleDateString('en-GB', { weekday: 'short', timeZone: 'UTC' });
111
+ return 'asked ' + d.toLocaleDateString('en-GB', { day: 'numeric', month: 'short', timeZone: 'UTC' });
112
+ }
113
+
114
+ /** The text the PM copies and sends. */
115
+ function draftOf(title, questions) {
116
+ return `Two quick questions before we meet on ${one(title, 120)}, yes or no is enough:\n1. ${questions[0]}\n2. ${questions[1]}`;
117
+ }
118
+
119
+ function stanceOf({ ini, title, entries = [], rows = [], lines = [], now = Date.now() } = {}) {
120
+ const e = contestedOf(entries, ini);
121
+ if (!e) return null;
122
+ const questions = questionsOf(e);
123
+ const f = fold(lines, ini, e.id);
124
+ const people = f.asked && f.people.length ? f.people.map((p) => ({ id: p.id, name: one(p.name || p.id, 80) }))
125
+ : (rows || []).filter((r) => r && (r.group === 'decides' || r.group === 'agree')).map((r) => ({ id: r.id, name: one(r.name, 80) }));
126
+ if (!people.length) return null;
127
+ const grid = questions.map((q, i) => {
128
+ const says = people.map((p) => (f.answers.get(p.id) || ['', ''])[i] || '');
129
+ const yes = says.filter((s) => s === 'yes').length, no = says.filter((s) => s === 'no').length;
130
+ const odd = yes && no && yes !== no ? (yes < no ? 'yes' : 'no') : null;
131
+ return { q, n: i + 1, split: yes && no ? Math.min(yes, no) / (yes + no) : 0,
132
+ cells: people.map((p, j) => ({ id: p.id, name: p.name, says: says[j], diff: !!odd && says[j] === odd })) };
133
+ });
134
+ const answered = people.filter((p) => { const a = f.answers.get(p.id); return a && a[0] && a[1]; }).length;
135
+ const top = grid.filter((r) => r.split > 0).sort((a, b) => b.split - a.split || b.n - a.n)[0]; // a tie goes to the objection: it is the open point
136
+ const settle = top ? 'Settle one point: ' + top.q.replace(/^./, (c) => c.toLowerCase()) : null;
137
+ return { ini, title: one(title || ini, 120), decision: { id: e.id, decided: one(e.decided, 300), against: one(e.against, 400), date: e.date || null },
138
+ questions, people, asked: f.asked, askedWord: askedWord(f.asked, now), grid: grid.map(({ split, ...r }) => r), answered, total: people.length,
139
+ settle, draft: draftOf(title || ini, questions) };
140
+ }
141
+
142
+ function act(dir, input = {}, { by = 'pm', now = Date.now() } = {}) {
143
+ const kind = String(input.kind || '');
144
+ if (!KINDS.includes(kind)) return { ok: false, error: 'sent, answer or undo' };
145
+ const ini = String(input.ini || ''), decision = String(input.decision || '');
146
+ if (!ID_RE.test(ini)) return { ok: false, error: 'Name the initiative by its id.' };
147
+ if (!DEC_RE.test(decision)) return { ok: false, error: 'Name the decision by its id in the journal.' };
148
+ const line = { at: new Date(now).toISOString(), by, kind, ini, decision };
149
+ if (kind === 'sent') {
150
+ const people = (Array.isArray(input.people) ? input.people : []).map((p) => ({ id: String((p && p.id) || ''), name: one(p && p.name, 80) })).filter((p) => ID_RE.test(p.id));
151
+ if (!people.length) return { ok: false, error: 'Name the people you sent the questions to.' };
152
+ line.people = people.slice(0, 20);
153
+ } else if (kind === 'answer') {
154
+ const person = String(input.person || '');
155
+ if (!ID_RE.test(person)) return { ok: false, error: 'Name the person by their id.' };
156
+ const q = Number(input.q);
157
+ if (q !== 1 && q !== 2) return { ok: false, error: 'The question is 1 or 2.' };
158
+ const says = String(input.says == null ? '' : input.says).trim().toLowerCase().replace(/^clear$/, '');
159
+ if (!SAYS.includes(says)) return { ok: false, error: 'The answer is yes, no or clear.' };
160
+ Object.assign(line, { person, q, says });
161
+ if (input.name) line.name = one(input.name, 80);
162
+ } else if (!readLines(dir).some((l) => l.ini === ini && l.decision === decision)) return { ok: false, error: 'Nothing to undo for this decision.' };
163
+ if (!dir) return { ok: false, error: 'This product has no records folder.' };
164
+ try { fs.mkdirSync(dir, { recursive: true }); fs.appendFileSync(path.join(dir, FILE), JSON.stringify(line) + '\n'); } catch (e) { return { ok: false, error: 'could not save: ' + ((e && e.message) || e) }; }
165
+ try { console.error(`${TAG} ${kind} ${ini} ${decision}${line.person ? ' ' + line.person + ' q' + line.q + ' ' + (line.says || 'clear') : ''}`); } catch { /* no console */ }
166
+ return { ok: true, line };
167
+ }
168
+
169
+ /** Question sets marked as sent and not undone. */
170
+ function count(dir) {
171
+ const lines = readLines(dir);
172
+ const keys = new Set(lines.map((l) => l.ini + '|' + l.decision));
173
+ let n = 0;
174
+ for (const k of keys) { const [ini, d] = k.split('|'); if (fold(lines, ini, d).asked) n++; }
175
+ return n;
176
+ }
177
+
178
+ /** Everything stanceOf needs, read from the checkout at `root`. o: { now, people, stateDir, dir }. */
179
+ function read(root, ini, o = {}) {
180
+ const SM = require('./stakeholder-map.js');
181
+ const now = o.now || Date.now();
182
+ let entries = [];
183
+ try { entries = require('./decision-journal.js').entriesOf(root, { today: new Date(now).toISOString().slice(0, 10) }).entries; } catch { entries = []; }
184
+ if (!contestedOf(entries, ini)) return null;
185
+ const map = SM.read(root, ini, { now, people: o.people, stateDir: o.stateDir, dir: o.dir });
186
+ const dir = o.dir || SM.recordsDirOf(root);
187
+ return stanceOf({ ini, title: map.title, entries, rows: map.rows, lines: readLines(dir), now });
188
+ }
189
+
190
+ module.exports = { FILE, TAG, KINDS, contestedOf, questionsOf, objectionOf, readLines, fold, askedWord, draftOf, stanceOf, act, count, read };
191
+
192
+ if (require.main === module) {
193
+ const [cmd, root] = process.argv.slice(2);
194
+ if (cmd !== 'count' || !root) { console.error('usage: node lib/meeting-stance.js count <product checkout>'); process.exit(2); }
195
+ const SM = require('./stakeholder-map.js');
196
+ const n = count(SM.recordsDirOf(path.resolve(root)));
197
+ console.log(`${TAG} sent ${n}`);
198
+ console.log(String(n));
199
+ }
@@ -8,6 +8,8 @@
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 stance <initiative> [sent | answer <person> <1|2> <yes|no|clear> | undo] [--json] before the meeting: the two questions
12
+ * for the contested decision and where each person stands (A333, lib/meeting-stance.js)
11
13
  * pmos people prep <person> [--days N] [--json] a 1:1 brief from the tasks they own (lib/people-prep.js, idea A85)
12
14
  *
13
15
  * The same module the People place reads (lib/people-store.js), so a terminal line and the page cannot disagree.
@@ -23,7 +25,7 @@ const path = require('path');
23
25
  const store = require('./people-store');
24
26
  const { parseArgs } = require('./schedule-cli');
25
27
 
26
- const COMMANDS = { people: ['list', 'show', 'record', 'settings', 'map', 'keep', 'drop', 'told', 'undo', 'prep'] };
28
+ const COMMANDS = { people: ['list', 'show', 'record', 'settings', 'map', 'keep', 'drop', 'told', 'undo', 'stance', 'prep'] };
27
29
  const USAGE = [
28
30
  'usage: pmos people [list|show|record|settings] — the people you work with in this repository',
29
31
  ' pmos people [list] [--json] each person, and what waits for you in the review list',
@@ -32,6 +34,8 @@ const USAGE = [
32
34
  ' pmos people settings [--json] whether calendar attendee names are kept (calendar names: on|off)',
33
35
  ' pmos people map <initiative> [--json] who decides, who must agree, who needs to know, and when each last heard from you',
34
36
  ' pmos people keep <initiative> <person> [--group decides|agree|know] keep a name on the map (in that group)',
37
+ ' pmos people stance <initiative> [--json] before the meeting: the two questions for the contested decision, or where each person stands',
38
+ ' pmos people stance <initiative> sent | answer <person> <1|2> <yes|no|clear> | undo you sent the questions, one answer, or take back the last',
35
39
  ' 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
40
  ' pmos people prep <person> [--days N] [--json] a 1:1 brief: what they shipped, where they are stuck, one thing to recognise',
37
41
  'Nothing here removes a person, merges, sets a tone or writes a note. Do that in People. PMOS never sends an update: you do.',
@@ -142,6 +146,7 @@ async function run(argv, { say = console.log, cwd = process.cwd(), env = process
142
146
  return r.ok ? 0 : 1;
143
147
  }
144
148
  if (sub === 'map' || SM_ACTS.includes(sub)) return mapCmd(sub, pos, flags, { say, root, json, fail, now });
149
+ if (sub === 'stance') return stanceCmd(pos, { say, root, json, fail, now });
145
150
  return fail(`pmos people ${sub} is not a command. ${USAGE[0]}`, 2);
146
151
  }
147
152
 
@@ -180,4 +185,42 @@ function mapCmd(sub, pos, flags, { say, root, json, fail, now }) {
180
185
  return 0;
181
186
  }
182
187
 
188
+ /** `pmos people stance` (initiative meeting-stance): the store the Work popup's "before the meeting" block reads. PMOS never sends. */
189
+ function stanceCmd(pos, { say, root, json, fail, now }) {
190
+ const MS = require('./meeting-stance.js');
191
+ const SM = require('./stakeholder-map.js');
192
+ const ini = String(pos[1] || ''), what = String(pos[2] || '');
193
+ const usage = 'usage: pmos people stance <initiative> [sent | answer <person> <1|2> <yes|no|clear> | undo]';
194
+ if (!ini) return fail(usage, 2);
195
+ const s = MS.read(root, ini, { now });
196
+ if (!what) {
197
+ if (json) { say(JSON.stringify({ ok: true, stance: s })); return 0; }
198
+ if (!s) { say('No contested decision on this initiative. PMOS drafts questions for a live journal decision someone argued against.'); return 0; }
199
+ say(`Before the meeting · ${s.title} · ${s.decision.decided}`);
200
+ if (!s.asked) {
201
+ say(`✦ PMOS drafted two questions for ${s.people.map((p) => p.name).join(', ')}. Send them yourself, then run: pmos people stance ${ini} sent`);
202
+ s.questions.forEach((q, i) => say(` ${i + 1}. ${q}`));
203
+ return 0;
204
+ }
205
+ for (const r of s.grid) say(` ${r.n}. ${r.q} ` + r.cells.map((c) => `${c.name}: ${c.says || '—'}${c.diff ? ' (differs)' : ''}`).join(' · '));
206
+ if (s.settle) say(`✦ ${s.settle}`);
207
+ say(`${s.answered} of ${s.total} answered · ${s.askedWord}`);
208
+ return 0;
209
+ }
210
+ if (!s) return fail('No contested decision on this initiative.');
211
+ const input = { ini, decision: s.decision.id, kind: what };
212
+ if (what === 'sent') input.people = s.people;
213
+ else if (what === 'answer') {
214
+ const who = String(pos[3] || ''), q = pos[4], says = pos[5];
215
+ const p = s.people.find((x) => x.id === who.toLowerCase()) || s.people.find((x) => SM.same(x.name, who));
216
+ if (!p) return fail(`${who || 'That person'} is not asked on this decision: ${s.people.map((x) => x.id).join(', ')}`);
217
+ Object.assign(input, { person: p.id, name: p.name, q, says });
218
+ } else if (what !== 'undo') return fail(usage, 2);
219
+ const r = MS.act(SM.recordsDirOf(root), input, { by: 'pm', now });
220
+ if (json) { say(JSON.stringify(r)); return r.ok ? 0 : 1; }
221
+ if (!r.ok) return fail(r.error);
222
+ say(what === 'sent' ? `✓ marked: you sent the questions to ${r.line.people.map((p) => p.name).join(', ')}` : what === 'answer' ? `✓ ${r.line.name || r.line.person} on question ${r.line.q}: ${r.line.says || 'cleared'}` : '✓ your last press taken back');
223
+ return 0;
224
+ }
225
+
183
226
  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|map|keep|drop|told|undo … — the people you work with in this repository, and who decides on each initiative (pmos people help)' }),
53
+ help: 'pmos people list|show|record|settings|map|keep|drop|told|undo|stance|prep … — the people you work with in this repository, who decides on each initiative, where each stands before a meeting, and a 1:1 brief (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)' }),
@@ -203,6 +203,9 @@ const VERBS = Object.freeze({
203
203
  // Not a pm-os-absorb verb (run: null): initiative positioning-draft (idea A328) added it through the same table.
204
204
  positioning: Object.freeze({ module: 'positioning-cli.js', run: null, guide: 'cli.md',
205
205
  help: 'pmos positioning strategy|list|keep|drop — the product\'s positioning and key messages, each citing its strategy lines (pmos positioning help)' }),
206
+ // Not a pm-os-absorb verb (run: null): initiative segments (idea A327, job #1893) added it through the same table.
207
+ segments: Object.freeze({ module: 'segments-cli.js', run: null, guide: 'cli.md',
208
+ help: 'pmos segments list|draft|add|keep|rename|drop|undo|tag|untag — the product\'s user groups, their size and health, and the roadmap items that serve each (pmos segments help)' }),
206
209
  // Not a pm-os-absorb verb (run: null): initiative code-map (idea A176) added it through the same table.
207
210
  code: Object.freeze({ module: 'code-map-cli.js', run: null, guide: 'cli.md',
208
211
  help: 'pmos code show|map|describe|count — the product\'s code map: one line per main part, what it is, how it is tested, who changed it last (pmos code help)' }),
@@ -26,6 +26,7 @@
26
26
  * promptOf({ body, language, reader }) PURE · answerOf(answer) PURE → markdown | null
27
27
  * copyPath(rel, code) PURE · copyText({ fm, body, rel, language, code, reader, sha }) PURE → the file
28
28
  * alsoOf(root, rel) → [{ code, language, reader, path }] the copies on disk beside a draft (the ⋯ menu's Also in …)
29
+ * hintOf(audience, have) PURE · languageHint(root, cadence) → [{ language, code }] a language the readers name with no copy yet (the ✦)
29
30
  * definitionLanguages(root, cadence) → [{ language, code, reader }] · setLanguage(root, cadence, entry, { off }) → { ok, languages, path } | { ok:false, error }
30
31
  * translate({ root, rel, ask, runtime?, env?, guard? }) → Promise<{ written, refused, skipped, off? }>
31
32
  * attach(ctxFactory) hook onDraftWritten once; ctx: { workspaceList, runtimeDir, spawnScheduled|spawnSession }
@@ -151,6 +152,30 @@ function definitionLanguages(root, cadence, state = null) {
151
152
  return languagesOf(fmMap(bodyOf(t).fm).languages || '');
152
153
  }
153
154
 
155
+ /** PURE. The languages a report's readers name (its definition's `audience`, for example "Leadership; Dita reads Indonesian") that are not
156
+ * English and not on its `languages:` line yet: the ✦ on the draft (initiative surface-reports). [{ language, code }], at most 3. */
157
+ function hintOf(audience, have = []) {
158
+ const t = String(audience == null ? '' : audience).toLowerCase();
159
+ if (!t.trim()) return [];
160
+ const had = new Set((have || []).map((x) => x && x.code).filter(Boolean));
161
+ const out = [];
162
+ const names = [...Object.entries(LANGS).map(([c, n]) => [n.toLowerCase(), c]), ...Object.entries(ALIASES).filter(([a]) => a !== 'bahasa')]; // bare "bahasa" names no one language
163
+ for (const [name, code] of names) {
164
+ if (code === 'en' || had.has(code) || out.some((x) => x.code === code)) continue;
165
+ if (new RegExp('(^|[^a-z])' + name.replace(/ /g, '\\s+') + '([^a-z]|$)').test(t)) out.push({ language: LANGS[code], code });
166
+ }
167
+ return out.slice(0, 3);
168
+ }
169
+
170
+ /** The ✦ hint of a report: hintOf(its definition's audience, its languages). Read-only; [] when there is no definition. */
171
+ function languageHint(root, cadence, state = null) {
172
+ let st = state;
173
+ if (!st) { try { st = require('./report-draft.js').stateRel(root); } catch { return []; } }
174
+ let t = ''; try { t = fs.readFileSync(defFile(root, st, cadence), 'utf8'); } catch { return []; }
175
+ const fm = fmMap(bodyOf(t).fm);
176
+ return hintOf(fm.audience || '', languagesOf(fm.languages || ''));
177
+ }
178
+
154
179
  /** Add or remove one `<Language>[ for <reader>]` entry on a definition's `languages:` line. */
155
180
  function setLanguage(root, cadence, entry, { off = false, state = null } = {}) {
156
181
  if (!/^[a-z][a-z0-9-]{0,39}$/.test(String(cadence || ''))) return { ok: false, error: 'the cadence is a report id, for example weekly' };
@@ -235,4 +260,4 @@ function attach(ctxFactory) {
235
260
  });
236
261
  }
237
262
 
238
- module.exports = { JOB, ORIGIN, LANGS, codeOf, languagesOf, bodyOf, shaOf, namesOf, keeps, promptOf, answerOf, copyPath, copyText, alsoOf, definitionLanguages, setLanguage, translate, attach };
263
+ module.exports = { JOB, ORIGIN, LANGS, codeOf, languagesOf, bodyOf, shaOf, namesOf, keeps, promptOf, answerOf, copyPath, copyText, alsoOf, definitionLanguages, hintOf, languageHint, setLanguage, translate, attach };
@@ -19,6 +19,8 @@
19
19
  * addsNothing(orig, version) PURE → { ok, why? } · sourcesOf(body, rel) PURE → [line]
20
20
  * promptOf({ body, audience }) PURE · versionPath(rel, id) PURE · versionText({ fm, body, rel, audience, sha }) PURE
21
21
  * latestDraft(root, cadence) → rel | null
22
+ * versionsOf(root, rel) → [{ audience, label, path }] the versions on disk beside a draft, in AUDIENCES order (GET /api/report/draft
23
+ * `versions`; the report view's Draft | For … tabs, pm/premium-report-read.js). A file must say `variant_of` to count.
22
24
  * variants({ root, rel, ask, audiences?, env?, runtime?, guard? }) → Promise<{ written, refused, skipped, off? }>
23
25
  */
24
26
  const fs = require('fs');
@@ -98,6 +100,17 @@ function latestDraft(root, cadence, state = null) {
98
100
  return files.length ? `${st}/reports/${cadence}/${files[files.length - 1]}` : null;
99
101
  }
100
102
 
103
+ /** The versions on disk beside a draft, in AUDIENCES order. Read-only. */
104
+ function versionsOf(root, rel) {
105
+ const out = [];
106
+ for (const A of AUDIENCES) {
107
+ const p = versionPath(rel, A.id);
108
+ let fm = ''; try { fm = RT.bodyOf(fs.readFileSync(path.resolve(String(root), p), 'utf8')).fm; } catch { continue; }
109
+ if (/^variant_of:\s*\S/m.test(fm || '')) out.push({ audience: A.id, label: 'For ' + A.label, path: p });
110
+ }
111
+ return out;
112
+ }
113
+
101
114
  function guardOf() { try { return require('./ai-guard.js'); } catch { return null; } }
102
115
 
103
116
  /** One draft → one version per audience. ask(prompt, { key }) → the answer text, or null. */
@@ -124,4 +137,4 @@ async function variants({ root, rel, ask, audiences = AUDIENCES, env = process.e
124
137
  return res;
125
138
  }
126
139
 
127
- module.exports = { JOB, AUDIENCES, audiencesOf, addsNothing, sourcesOf, promptOf, versionPath, versionText, latestDraft, variants };
140
+ module.exports = { JOB, AUDIENCES, audiencesOf, addsNothing, sourcesOf, promptOf, versionPath, versionText, latestDraft, versionsOf, variants };
@@ -147,16 +147,19 @@ const MODULES = Object.freeze([
147
147
  'routes-next-prompt', // batch 26 item 2: the chat's suggested next prompt and Sharper card (lib/next-prompt.js, through lib/ai-guard.js)
148
148
  'routes-drift', // weekly-drift-check: What would I have missed, Home's weekly ✦ and its ⋯ drop and Undo (runtime drift/drift.jsonl; page-press POST)
149
149
  'routes-moments', // onboarding B3 gradual exposure: the day's ✦ in Home's chat, the menu dots, a quiet place's one line (onboarding-progress record; page-press POST)
150
+ 'routes-surface-moments', // surface-moments (job #1985, LINE.md Rule 12): the ✦ moments in Your move on Today (page-press POST)
150
151
  'routes-spec-critic', // spec-critic: the sceptical reviewer's hardest questions on a document before it is shared (runtime spec-critic.jsonl)
151
152
  'routes-jira-epics', // work-subtasks: the epic check's fix, direct on tickets assigned to the PM, the day's draft for the rest (tracker/jira/epics.jsonl; page-press POST)
152
153
  'routes-use-log', // bet A466: the local use log, page opens and controls pressed, on this computer only (runtime use-log.jsonl; page-press POST)
153
154
  'routes-strategy-card', // bet A458: a product's five-line strategy above its Board, and the gentle "doesn't fit" note on new work (records strategy-card.jsonl; page-press POST)
155
+ 'routes-segments', // idea A327: a product's user groups and the roadmap items that serve each, kept or renamed on Work (records segments.jsonl; page-press POST)
154
156
  'routes-principles', // bet A352: a product's principles drafted from its decisions, kept or dropped on the Board (records principles.jsonl; page-press POST)
155
157
  'routes-switches', // idea A263: who has which switch, per customer, on Work; turning one waits for the PM's own press (records switches.jsonl; page-press POST)
156
158
  'routes-prefs', // bet A461: view preferences that follow the person to the phone and other browsers (runtime view-prefs.json; page-press POST)
157
159
  'routes-skill-map', // bet A208: the team skill map on Work, for the person and their lead only (records skill-map.jsonl; page-press POST)
158
160
  'routes-first-hour', // bet A55: the first hour for a new engineer on Work (records first-hour.jsonl; page-press POST)
159
161
  'routes-stakeholders', // bet A371: an initiative's stakeholder map, decides / must agree / needs to know, in the Work popup (records stakeholders.jsonl; page-press POST)
162
+ 'routes-meeting-stance', // bet A333: before the meeting, the two questions for a contested decision and where each person stands, in the Work popup (records meeting-stance.jsonl; page-press POST)
160
163
  'routes-code-map', // idea A176: the product's code map on Work, redrawn when the default branch moves (records code-map.json; read-only)
161
164
  'routes-arch-warns', // idea A54: one warning when an initiative names a risky part of the code (reads code-map.json; read-only)
162
165
  'routes-live-rows', // bet A458: chat-made task changes streamed to open pages (runtime live-events.jsonl; read-only event stream)
@@ -0,0 +1,43 @@
1
+ 'use strict';
2
+ /* routes-meeting-stance.js — where each person stands on an initiative's contested decision, over HTTP (initiative meeting-stance, job
3
+ * #1897, idea A333). The store and the fold are lib/meeting-stance.js (meeting-stance.jsonl in the product's records folder,
4
+ * lib/records-dir.js); the verb is `pmos people stance`.
5
+ *
6
+ * GET /api/meeting-stance?ini=<id>&ws=<id> → { ok, stance } stance is null when no decision of the initiative is contested
7
+ * POST /api/meeting-stance { ws, ini, decision, act, person?, name?, q?, says?, people? } → { ok, line } | 400 act ∈ sent · answer · undo
8
+ *
9
+ * WHO WRITES. A page press: pm-guard requirePagePress checks the page's Origin and launch nonce. The chat writes with `pmos people stance`.
10
+ * Nothing here reads a connector or sends anything: the PM sends the questions, and "I sent them" only records that. */
11
+ const guard = require('./pm-guard.js');
12
+ const MS = require('./meeting-stance.js');
13
+ const { recordsDirFor } = require('./records-dir.js');
14
+
15
+ const INI_RE = /^[a-z0-9][a-z0-9-]{0,79}$/;
16
+ function wsOf(ctx, ws) { try { return ctx && typeof ctx.getWs === 'function' ? ctx.getWs(ws || null) : null; } catch { return null; } }
17
+ const rootOf = (ctx, w) => (ctx && ctx.repoRoot) || (w && w.root) || (ctx && ctx.selfRoot) || null;
18
+ function stateDirOf(ctx, w) { try { return ctx && typeof ctx.stateDirFor === 'function' && w ? ctx.stateDirFor(w) : null; } catch { return null; } }
19
+
20
+ async function handle(req, res, url, ctx) {
21
+ if (url.pathname !== '/api/meeting-stance') return false;
22
+ const send = (status, body) => { ctx.json(res, body, status); return true; };
23
+ if (req.method === 'GET') {
24
+ const ini = String(url.searchParams.get('ini') || '');
25
+ if (!INI_RE.test(ini)) return send(400, { ok: false, error: 'Name the initiative: ?ini=<id>.' });
26
+ const wsId = url.searchParams.get('ws') || null;
27
+ const w = wsOf(ctx, wsId), root = rootOf(ctx, w);
28
+ if (!root) return send(404, { ok: false, error: 'no such workspace' });
29
+ const stance = MS.read(root, ini, { stateDir: stateDirOf(ctx, w), dir: recordsDirFor(ctx, wsId), people: ctx.people || undefined });
30
+ return send(200, { ok: true, stance });
31
+ }
32
+ if (req.method !== 'POST') return send(405, { ok: false, error: 'GET or POST' });
33
+ const rd = await ctx.readJson(req);
34
+ if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
35
+ const body = rd.body || {};
36
+ const g = guard.requirePagePress(req, body);
37
+ if (!g.ok) return send(g.status, { ok: false, error: g.error });
38
+ const r = MS.act(recordsDirFor(ctx, body.ws || null), { ini: body.ini, decision: body.decision, kind: String(body.act || ''), person: body.person,
39
+ name: body.name, q: body.q, says: body.says, people: body.people }, { by: (g.actor && g.actor.by) || 'pm' });
40
+ return r.ok ? send(200, { ok: true, line: r.line }) : send(400, { ok: false, error: r.error });
41
+ }
42
+
43
+ module.exports = { prefixes: ['/api/meeting-stance'], handle };
@@ -4,10 +4,12 @@
4
4
  * GET /api/report?ws= the report files of the repository, drafts and issued, of every cadence,
5
5
  * with the `sig` the page watches (public/pm/sig-watch.js, 10 s)
6
6
  * GET /api/report/draft?ws=&cadence=&slot= one report file as it is now: its markdown, its note texts, its blob sha, and `also`:
7
- * the translated copies beside it (lib/report-translate.js alsoOf)
7
+ * the translated copies beside it (lib/report-translate.js alsoOf), and `versions`: the
8
+ * versions for executives, engineers and customers (lib/report-variants.js versionsOf)
8
9
  * POST /api/report/draft { ws, cadence, slot?, redraft? } Draft now, and Redraft (the notes are kept)
9
10
  * POST /api/report/note { ws, cadence, slot, id, text } one note, by initiative id (or report.headline, report.asks, report.changelog)
10
11
  * POST /api/report/issue { ws, cadence, slot, sha } Issue: the PM's act (R25)
12
+ * POST /api/report/language { ws, cadence, language, off? } add (or with off, remove) one language on the definition (the ✦ on the draft)
11
13
  *
12
14
  * WHICH GUARD. A draft and a note are page writes, not PM-only acts: both call pm-guard.js requirePagePress. Issue is a
13
15
  * PM-only act (D86 point 2) and calls requirePmPress with act 'issue', then issues.appendFromUi with the guard's actor.
@@ -31,6 +33,9 @@ const RD = require('./report-draft.js');
31
33
  const issues = require('./issues.js');
32
34
  const RN = require('./report-needs.js');
33
35
  /** The translated copies beside a draft; none when the module is not installed. */
36
+ /** A language the report's readers name with no copy yet (the ✦ on the draft, initiative surface-reports); none without the module. */
37
+ const langHintOf = (root, cadence) => { try { return require('./report-translate.js').languageHint(root, cadence); } catch { return []; } };
38
+ const versionsOf = (root, rel) => { try { return require('./report-variants.js').versionsOf(root, rel); } catch { return []; } };
34
39
  const alsoOf = (root, rel) => { try { return require('./report-translate.js').alsoOf(root, rel); } catch { return []; } };
35
40
 
36
41
  const CADENCE_RE = /^[a-z][a-z0-9-]{0,39}$/;
@@ -78,11 +83,11 @@ const cadenceSlot = (src) => {
78
83
 
79
84
  async function handle(req, res, url, ctx) {
80
85
  const p = url.pathname;
81
- if (p !== '/api/report' && p !== '/api/report/draft' && p !== '/api/report/note' && p !== '/api/report/issue') return refuse(ctx, res, 404, 'no such report route');
86
+ if (p !== '/api/report' && p !== '/api/report/draft' && p !== '/api/report/note' && p !== '/api/report/issue' && p !== '/api/report/language') return refuse(ctx, res, 404, 'no such report route');
82
87
 
83
88
  /* ── reads ─────────────────────────────────────────────────────────────────────────────────────────────────── */
84
89
  if (req.method === 'GET') {
85
- if (p === '/api/report/note' || p === '/api/report/issue') return refuse(ctx, res, 405, `${p} takes POST`);
90
+ if (p === '/api/report/note' || p === '/api/report/issue' || p === '/api/report/language') return refuse(ctx, res, 405, `${p} takes POST`);
86
91
  const w = wsFrom(ctx, url.searchParams.get('ws'));
87
92
  if (!w) return refuse(ctx, res, 404, 'no such workspace');
88
93
  let list;
@@ -101,6 +106,8 @@ async function handle(req, res, url, ctx) {
101
106
  ok: true, ws: w.id, sig: list.sig, cadence: cs.cadence, slot: cs.slot, exists: true, path: hit.path, status: hit.status,
102
107
  sha: RN.blobSha(file.buf), markdown: file.text, notes: RD.readNotes(file.text), issued: pageReport(hit).issued, edited: hit.edited, flags: pageFlags(list.flags),
103
108
  also: alsoOf(w.root, hit.path),
109
+ versions: versionsOf(w.root, hit.path),
110
+ langHint: langHintOf(w.root, cs.cadence),
104
111
  });
105
112
  return true;
106
113
  }
@@ -146,6 +153,16 @@ async function handle(req, res, url, ctx) {
146
153
  return done({ slot: draft.slot, path: r.path, sha: r.sha });
147
154
  }
148
155
 
156
+ // A language for the report's readers (the ✦ on the draft, initiative surface-reports): the definition's `languages:` line, through the
157
+ // one writer of lib/report-translate.js. off: true takes it out again (Undo). The next draft gets a copy; nothing runs or is sent here.
158
+ if (p === '/api/report/language') {
159
+ const lang = typeof body.language === 'string' ? body.language.trim().slice(0, 40) : '';
160
+ if (!lang) return refuse(ctx, res, 400, 'language is required, for example Indonesian');
161
+ let r; try { r = require('./report-translate.js').setLanguage(root, cs.cadence, lang, { off: body.off === true }); } catch (e) { r = { ok: false, error: String((e && e.message) || e).slice(0, 160) }; }
162
+ if (!r || !r.ok) return failed({ status: 400, error: (r && r.error) || 'the language was not saved' });
163
+ return done({ languages: r.languages.map((x) => x.language), path: r.path });
164
+ }
165
+
149
166
  if (p === '/api/report/note') {
150
167
  if (!cs.slot) return refuse(ctx, res, 400, 'slot must be a date, YYYY-MM-DD');
151
168
  const id = String(body.id || '');
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+ /* routes-segments.js — a product's user groups over HTTP (idea A327, initiative segments). The store is lib/segments.js (segments.jsonl in
3
+ * the product's records folder, lib/records-dir.js); the verb is `pmos segments`.
4
+ *
5
+ * GET /api/segments?ws=<id> → { ok, rows, total, line, offer } rows: the groups not dropped, most users first, each with
6
+ * roadmap (its live tagged initiatives); line: the one imbalance line, or null;
7
+ * offer: { items } when no group exists yet and 3+ roadmap items are live, else null
8
+ * POST /api/segments { ws, act, gid, to? } → { ok, group } | 400 act ∈ keep · rename · drop · undo
9
+ *
10
+ * The live initiatives are the product's own (lib/list-balance.js roadmapItems: not stopped, not accepted); ctx.segmentsLive overrides
11
+ * them in a test. WHO WRITES. A page press: pm-guard requirePagePress checks the page's Origin and launch nonce. The chat drafts and tags
12
+ * with `pmos segments`. Nothing here is sent anywhere. */
13
+ const path = require('path');
14
+ const guard = require('./pm-guard.js');
15
+ const SG = require('./segments.js');
16
+ const { recordsDirFor } = require('./records-dir.js');
17
+
18
+ const CHECKOUT = path.join(__dirname, '..', '..');
19
+ const PAGE_ACTS = ['keep', 'rename', 'drop', 'undo'];
20
+ function wsOf(ctx, ws) { try { return ctx && typeof ctx.getWs === 'function' ? ctx.getWs(ws || null) : null; } catch { return null; } }
21
+ const rootFor = (ctx, w) => (ctx && ctx.repoRoot) || (w && w.root) || CHECKOUT;
22
+ function liveOf(ctx, w) {
23
+ if (ctx && Array.isArray(ctx.segmentsLive)) return ctx.segmentsLive;
24
+ try { return require('./list-balance.js').roadmapItems(rootFor(ctx, w)).map((x) => x.id); } catch { return []; }
25
+ }
26
+
27
+ async function handle(req, res, url, ctx) {
28
+ if (url.pathname !== '/api/segments') return false;
29
+ const send = (status, body) => { ctx.json(res, body, status); return true; };
30
+ if (req.method === 'GET') {
31
+ const wsId = url.searchParams.get('ws') || null;
32
+ const v = SG.view(recordsDirFor(ctx, wsId), liveOf(ctx, wsOf(ctx, wsId)));
33
+ return send(200, { ok: true, rows: v.rows, total: v.total, line: v.line, offer: v.offer });
34
+ }
35
+ if (req.method !== 'POST') return send(405, { ok: false, error: 'GET or POST' });
36
+ const rd = await ctx.readJson(req);
37
+ if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
38
+ const body = rd.body || {};
39
+ const g = guard.requirePagePress(req, body);
40
+ if (!g.ok) return send(g.status, { ok: false, error: g.error });
41
+ const a = String(body.act || '');
42
+ if (!PAGE_ACTS.includes(a)) return send(400, { ok: false, error: 'act is one of: ' + PAGE_ACTS.join(', ') });
43
+ const r = SG.act(recordsDirFor(ctx, body.ws || null), a, { gid: body.gid, to: body.to });
44
+ return r.ok ? send(200, { ok: true, group: r.group }) : send(400, { ok: false, error: r.error });
45
+ }
46
+
47
+ module.exports = { prefixes: ['/api/segments'], handle, PAGE_ACTS };
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+ /* routes-surface-moments.js — the moments in Your move over HTTP (initiative surface-moments, job #1985; LINE.md Rule 12). lib/surface-moments.js
3
+ * holds the rules; pm/cozy-today-app.js asks for the rows and draws them.
4
+ *
5
+ * GET /api/surface-moments?ws=&free=&away=&awayWord=&awayFrom=&steer=&steerDay=&steerWord= → { ok, ws, rows: [row] } reads only
6
+ * POST /api/surface-moments { ws, kind, until?, job?, id?, file?, undo? } → { ok, said, file?, undo? } | 4xx
7
+ *
8
+ * WHO WRITES. A page press only: pm-guard requirePagePress checks the page's Origin and launch nonce before any ✓ or Undo. Nothing here
9
+ * sends anything. */
10
+ const guard = require('./pm-guard.js');
11
+ const SM = require('./surface-moments.js');
12
+
13
+ async function handle(req, res, url, ctx) {
14
+ if (url.pathname !== '/api/surface-moments') return false;
15
+ const send = (status, body) => { ctx.json(res, body, status); return true; };
16
+ if (req.method === 'GET') {
17
+ let w = null; try { w = ctx.getWs(url.searchParams.get('ws') || null); } catch { w = null; }
18
+ if (!w || !w.root) return send(404, { ok: false, error: 'no such workspace' });
19
+ const q = Object.fromEntries(['free', 'away', 'awayWord', 'awayFrom', 'steer', 'steerDay', 'steerWord'].map((k) => [k, url.searchParams.get(k) || '']));
20
+ let rows = [];
21
+ try { rows = SM.read(ctx, w, q); } catch (e) { return send(500, { ok: false, error: 'the moments could not be read: ' + (e && e.message) }); }
22
+ return send(200, { ok: true, ws: w.id, rows });
23
+ }
24
+ if (req.method !== 'POST') return send(405, { ok: false, error: 'GET or POST' });
25
+ const rd = await ctx.readJson(req);
26
+ if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
27
+ const body = rd.body || {};
28
+ const g = guard.requirePagePress(req, body);
29
+ if (!g.ok) return send(g.status, { ok: false, error: g.error });
30
+ let w = null; try { w = ctx.getWs(body.ws || null); } catch { w = null; }
31
+ if (!w || !w.root) return send(404, { ok: false, error: 'no such workspace' });
32
+ const r = SM.act(ctx, w, body);
33
+ return r.ok ? send(200, r) : send(400, { ok: false, error: r.error });
34
+ }
35
+
36
+ module.exports = { prefixes: ['/api/surface-moments'], handle };
@@ -10,14 +10,28 @@
10
10
  *
11
11
  * `banner` holds the sources that could not be read. An unreadable source is said here and never turned into an empty
12
12
  * list. `sig` changes whenever the list changes.
13
+ *
14
+ * GET /api/standup?ws=<id> → { ok, ws, read, line, lines }: the standup digest of the stored Jira reads (lib/tracker-digest.js gather),
15
+ * its one sentence for Today's Overview (lineOf; null when nothing moved) and its lines for the reading view. Read-only.
13
16
  */
14
17
  const path = require('path');
15
18
  const today = require('./today.js');
16
19
 
17
20
  module.exports = {
18
- prefixes: ['/api/today', '/api/today-order'],
21
+ prefixes: ['/api/today', '/api/today-order', '/api/standup'],
19
22
  handle: async (req, res, url, ctx) => {
20
23
  if (url.pathname === '/api/today-order') return require('./today-order.js').handle(req, res, url, ctx);
24
+ // the standup from the stored Jira reads (initiative surface-reports): Today's Overview line before noon, and the digest it opens.
25
+ // Read-only: the moves file is written by `pmos jira sync`, never here.
26
+ if (url.pathname === '/api/standup') {
27
+ if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
28
+ const w = ctx.getWs(url.searchParams.get('ws'));
29
+ if (!w) { ctx.json(res, { ok: false, error: 'no workspace is registered' }, 404); return true; }
30
+ const TD = require('./tracker-digest.js');
31
+ let d; try { d = TD.gather(w.root, { now: Date.now() }); } catch (e) { ctx.json(res, { ok: false, error: String((e && e.message) || e).slice(0, 160) }, 500); return true; }
32
+ ctx.json(res, { ok: true, ws: w.id, read: !!(d && d.read), line: TD.lineOf(d), lines: d && d.read ? TD.render(d) : [] });
33
+ return true;
34
+ }
21
35
  if (url.pathname !== '/api/today') return false;
22
36
  if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
23
37
  const w = ctx.getWs(url.searchParams.get('ws'));