create-pmos 0.836.0 → 0.838.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.
- package/package.json +124 -47
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +123 -2
- package/workspace/guide/cli.md +29 -0
- package/workspace/guide/home.md +1 -0
- package/workspace/guide/initiatives-and-next-steps.md +8 -0
- package/workspace/guide/layout.md +5 -1
- package/workspace/lib/built-vs-design-http.js +81 -0
- package/workspace/lib/built-vs-design.js +454 -0
- package/workspace/lib/deps-cli.js +47 -2
- package/workspace/lib/features.json +2 -0
- package/workspace/lib/hire-draft.js +4 -3
- package/workspace/lib/initiative-rows.js +3 -0
- package/workspace/lib/meeting-stance.js +199 -0
- package/workspace/lib/needs-providers.js +1 -0
- package/workspace/lib/people-cli.js +44 -1
- package/workspace/lib/pmos-verbs.js +7 -1
- package/workspace/lib/prefs-sync.js +1 -0
- package/workspace/lib/review-cli.js +6 -0
- package/workspace/lib/route-modules.js +3 -0
- package/workspace/lib/routes-meeting-stance.js +43 -0
- package/workspace/lib/routes-pop-work.js +4 -1
- package/workspace/lib/routes-segments.js +47 -0
- package/workspace/lib/routes-surface-moments.js +36 -0
- package/workspace/lib/routes-team-waits.js +39 -2
- package/workspace/lib/segments-cli.js +102 -0
- package/workspace/lib/segments.js +214 -0
- package/workspace/lib/surface-moments.js +185 -0
- package/workspace/lib/team-slips.js +160 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/ask-here-ctx.js +20 -2
- package/workspace/public/pm/ask-here.css +6 -1
- package/workspace/public/pm/ask-here.js +38 -25
- package/workspace/public/pm/bd-backlog.js +34 -5
- package/workspace/public/pm/built-vs-design.css +16 -0
- package/workspace/public/pm/built-vs-design.js +95 -0
- package/workspace/public/pm/cozy-board.css +11 -0
- package/workspace/public/pm/cozy-events-view.js +1 -1
- package/workspace/public/pm/cozy-home.css +10 -0
- package/workspace/public/pm/cozy-pop-work.js +11 -6
- package/workspace/public/pm/cozy-today-app.js +42 -1
- package/workspace/public/pm/cozy-today-model.js +70 -3
- package/workspace/public/pm/cozy-today-view.js +10 -1
- package/workspace/public/pm/goals-ds.js +3 -2
- package/workspace/public/pm/home-chat.js +19 -3
- package/workspace/public/pm/ini-tasks.js +2 -2
- package/workspace/public/pm/meeting-stance.js +113 -0
- package/workspace/public/pm/page-chat.js +2 -1
- package/workspace/public/pm/premium-board.js +2 -0
- package/workspace/public/pm/segments.js +113 -0
- package/workspace/public/pm/team-slips.js +48 -0
- package/workspace/public/premium-board.html +2 -0
- package/workspace/test-lists/built-vs-design.json +9 -0
- package/workspace/test-lists/meeting-stance.json +9 -0
- package/workspace/test-lists/segments.json +9 -0
- package/workspace/test-lists/surface-moments.json +9 -0
- package/workspace/test-lists/team-slips.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
|
+
}
|
|
@@ -41,6 +41,7 @@ const PROVIDERS = Object.freeze([
|
|
|
41
41
|
'decision-journal-needs', // decision-journal-outcome-checks: a journal decision whose check date came, with no verdict (kind 1)
|
|
42
42
|
'parked-reasons', // parked-reason-way-back (bet A446): a parked initiative whose way back is met, to bring back (kind 7)
|
|
43
43
|
'product-health', // product-health-score: a product's health score fell 10 points or more against its past week (kind 8)
|
|
44
|
+
'team-slips', // team-slips (bet A15): another team your work waits on will likely slip, with the one ✦ move (kind 7)
|
|
44
45
|
'setup-station', // setup-station: a product that has not passed Setup (tracker read, agreed goal, owner), with the next ✦ (kind 7)
|
|
45
46
|
'critical-needs', // critical-moved (bet A103): a task on an initiative's critical path moved its start or due date, with go-live (kind 7)
|
|
46
47
|
]);
|
|
@@ -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,
|
|
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)' }),
|
|
@@ -169,6 +169,9 @@ const VERBS = Object.freeze({
|
|
|
169
169
|
help: 'pmos goals [starter|draft|keep <n>|drop <n>|undo] — starter goals PMOS drafts from your own product, each with its source; keep one and it becomes a goal (pmos goals help)' }),
|
|
170
170
|
hire: Object.freeze({ module: 'hire-draft.js', run: null, guide: 'cli.md',
|
|
171
171
|
help: 'pmos hire [draft|show|count] — the role your open work most needs, per person, and a one-page role brief PMOS drafts for you to edit (pmos hire help)' }),
|
|
172
|
+
// Not a pm-os-absorb verb (run: null): initiative built-vs-design (job #1903, A380) added it through the same table.
|
|
173
|
+
review: Object.freeze({ module: 'review-cli.js', run: null, guide: 'cli.md',
|
|
174
|
+
help: 'pmos review shots|list|note|accept|fix|count — a built screen beside the design it came from, each difference circled and numbered (pmos review help)' }),
|
|
172
175
|
prototype: Object.freeze({ module: 'prototype-cli.js', run: null, guide: 'cli.md',
|
|
173
176
|
help: 'pmos prototype findings|personas|persona … — where simulated users (one per persona) got stuck on a prototype, never a score, and the personas that walk it (pmos prototype help)' }),
|
|
174
177
|
// Not a pm-os-absorb verb (run: null): initiative connector-data (job #1920, A150) added it through the same table.
|
|
@@ -200,6 +203,9 @@ const VERBS = Object.freeze({
|
|
|
200
203
|
// Not a pm-os-absorb verb (run: null): initiative positioning-draft (idea A328) added it through the same table.
|
|
201
204
|
positioning: Object.freeze({ module: 'positioning-cli.js', run: null, guide: 'cli.md',
|
|
202
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)' }),
|
|
203
209
|
// Not a pm-os-absorb verb (run: null): initiative code-map (idea A176) added it through the same table.
|
|
204
210
|
code: Object.freeze({ module: 'code-map-cli.js', run: null, guide: 'cli.md',
|
|
205
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)' }),
|
|
@@ -47,6 +47,7 @@ const KEYS = Object.freeze({
|
|
|
47
47
|
'pmos.routine.kind', 'pmos.routine.scope.v1',
|
|
48
48
|
'pmos.intel.tiles.off', 'pmos.guide.folded', 'pmos.order.notnow', 'pmos.listen.where',
|
|
49
49
|
'pmos.home.cardfold', 'pmos-report-orders-hidden', 'cz-live-side',
|
|
50
|
+
'pmos.chat.fs', // the text size of every chat (Small, Normal, Large), the + menu of the chat box
|
|
50
51
|
'pmos.pop.five', // the work popup's four toolbar actions, worked out weekly from use (idea A498, pm/pop-cap.js)
|
|
51
52
|
]),
|
|
52
53
|
prefix: Object.freeze(['pmos.board.', 'pmos.pv.tab:', 'pmos.dash.view:', 'cz-vw-fold:', 'pmos.fold:']),
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* review-cli.js — `pmos review …`: a built screen beside the design it came from (initiative built-vs-design, job #1903, idea A380). The
|
|
3
|
+
* commands, the store and the comparison are lib/built-vs-design.js; this file is the verb module lib/pmos-verbs.js names. */
|
|
4
|
+
const { run, COMMANDS, USAGE } = require('./built-vs-design.js');
|
|
5
|
+
|
|
6
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -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,6 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* POST /api/initiative/describe { ws, id, text } → { ok, id, from, text, same? } the record's description line
|
|
6
6
|
* POST /api/initiative/describe-undo { ws, id, from, to } → { ok, kept? } back to `from` while the line still says `to`
|
|
7
|
+
* /api/built-vs-design… the work popup's Review block, answered by lib/built-vs-design-http.js (built-vs-design, A380)
|
|
7
8
|
*
|
|
8
9
|
* The writer is lib/initiative-writer.js setDescription and restoreDescription, the same as `pmos initiative describe` and the ✓ on PMOS's
|
|
9
10
|
* description ✦ (lib/routes-proposals.js). Both POSTs pass pm-guard requirePagePress: the launch nonce and the page's origin, so an agent
|
|
@@ -15,6 +16,8 @@ const text = (v) => (typeof v === 'string' ? v : '');
|
|
|
15
16
|
const bad = (status, error) => ({ status, body: { ok: false, error } });
|
|
16
17
|
|
|
17
18
|
async function handle(req, res, url, ctx) {
|
|
19
|
+
// the popup's Review block (built-vs-design, A380): its routes ride on this module's prefixes, so adding them did not touch route-modules.js
|
|
20
|
+
if (url.pathname === '/api/built-vs-design' || url.pathname.startsWith('/api/built-vs-design/')) return require('./built-vs-design-http.js').handle(req, res, url, ctx);
|
|
18
21
|
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
19
22
|
const sub = url.pathname.replace(/^\/api\/initiative\/?/, '');
|
|
20
23
|
if (sub !== 'describe' && sub !== 'describe-undo') return send(bad(404, 'no such route'));
|
|
@@ -36,4 +39,4 @@ async function handle(req, res, url, ctx) {
|
|
|
36
39
|
return send({ status: 200, body: sub === 'describe' ? { ok: true, id, from: r.from || '', text: r.text, ...(r.same ? { same: true } : {}) } : { ok: true, ...(r.kept ? { kept: true } : {}) } });
|
|
37
40
|
}
|
|
38
41
|
|
|
39
|
-
module.exports = { prefixes: ['/api/initiative/describe', '/api/initiative/describe-undo'], handle };
|
|
42
|
+
module.exports = { prefixes: ['/api/initiative/describe', '/api/initiative/describe-undo', '/api/built-vs-design'], handle };
|
|
@@ -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 };
|
|
@@ -4,11 +4,48 @@
|
|
|
4
4
|
* GET /api/team-waits?ws=<id> → { ok, ws, today, waits: [lib/team-waits.js wait] } open waits, oldest first; 404 for an unknown ws
|
|
5
5
|
*
|
|
6
6
|
* Read only. The chat and a terminal write the same store with `pmos deps wait|done|undo` (lib/deps-cli.js), so what they write shows here
|
|
7
|
-
* on the next read. Nothing is sent: Chase is a draft in the PM's own mail app (public/pm/team-waits.js chaseDraft).
|
|
7
|
+
* on the next read. Nothing is sent: Chase is a draft in the PM's own mail app (public/pm/team-waits.js chaseDraft).
|
|
8
|
+
*
|
|
9
|
+
* Other teams' slips (initiative team-slips, bet A15; lib/team-slips.js is the store):
|
|
10
|
+
* GET /api/team-slips?ws=<id> → { ok, ws, today, watching, slips } the Upstream block on Work › Dependencies
|
|
11
|
+
* POST /api/team-slips/handle { ws, key, how } → { ok, line } the PM acted (shift | chase | skip): the row goes until a later likely date
|
|
12
|
+
* POST /api/team-slips/undo { ws, key } → { ok, line } Undo: the row is back
|
|
13
|
+
* A POST is a press on the page (pm-guard requirePagePress). No date is written and nothing is sent here. */
|
|
8
14
|
const TW = require('./team-waits.js');
|
|
15
|
+
const TS = require('./team-slips.js');
|
|
16
|
+
const guard = require('./pm-guard.js');
|
|
9
17
|
const { todayOf } = require('./parked-reasons.js');
|
|
10
18
|
|
|
19
|
+
const wsOf = (ctx, id) => { try { return ctx.getWs(id || null); } catch { return null; } };
|
|
20
|
+
|
|
21
|
+
async function slips(req, res, url, ctx) {
|
|
22
|
+
const p = url.pathname;
|
|
23
|
+
if (req.method === 'GET' && p === '/api/team-slips') {
|
|
24
|
+
const w = wsOf(ctx, url.searchParams.get('ws'));
|
|
25
|
+
if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
|
|
26
|
+
const today = todayOf();
|
|
27
|
+
let S = { watching: 0, slips: [] };
|
|
28
|
+
try { S = TS.slipsOf(w.root, { today }); } catch { S = { watching: 0, slips: [] }; }
|
|
29
|
+
ctx.json(res, { ok: true, ws: w.id, today, watching: S.watching, slips: S.slips });
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (p !== '/api/team-slips/handle' && p !== '/api/team-slips/undo') { ctx.json(res, { ok: false, error: 'no such route' }, 404); return true; }
|
|
33
|
+
if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
|
|
34
|
+
let body = {};
|
|
35
|
+
try { body = JSON.parse((await ctx.readBody(req)) || '{}'); } catch { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return true; }
|
|
36
|
+
const g = guard.requirePagePress(req, body);
|
|
37
|
+
if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
|
|
38
|
+
const w = wsOf(ctx, typeof body.ws === 'string' ? body.ws : '');
|
|
39
|
+
if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
|
|
40
|
+
const who = { by: (g.actor && g.actor.by) || undefined, via: (g.actor && g.actor.via) || 'ui' };
|
|
41
|
+
const r = p.endsWith('/handle') ? TS.handle(w.root, { key: String(body.key || '') }, { ...who, how: body.how }) : TS.undo(w.root, { key: String(body.key || '') }, who);
|
|
42
|
+
if (r.ok) { try { if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg(w.id); } catch { /* the next poll recounts */ } }
|
|
43
|
+
ctx.json(res, r, r.ok ? 200 : 409);
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
11
47
|
async function handle(req, res, url, ctx) {
|
|
48
|
+
if (url.pathname.startsWith('/api/team-slips')) return slips(req, res, url, ctx);
|
|
12
49
|
if (url.pathname !== '/api/team-waits') { ctx.json(res, { ok: false, error: 'no such route' }, 404); return true; }
|
|
13
50
|
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
14
51
|
let w = null;
|
|
@@ -21,4 +58,4 @@ async function handle(req, res, url, ctx) {
|
|
|
21
58
|
return true;
|
|
22
59
|
}
|
|
23
60
|
|
|
24
|
-
module.exports = { prefixes: ['/api/team-waits'], handle };
|
|
61
|
+
module.exports = { prefixes: ['/api/team-waits', '/api/team-slips'], handle };
|