create-pmos 0.828.0 → 0.830.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +237 -35
- 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/board-deliveries-test.js +2 -2
- package/workspace/briefing-premium-board-test.js +1 -1
- package/workspace/briefing-premium-insights-test.js +1 -1
- package/workspace/changelog.json +236 -8
- package/workspace/guide/agent-capabilities.md +1 -1
- package/workspace/guide/backlog.md +12 -1
- package/workspace/guide/cli.md +46 -1
- package/workspace/guide/home.md +2 -1
- package/workspace/guide/layout.md +1 -0
- package/workspace/guide/settings-and-switches.md +1 -0
- package/workspace/lib/board-premium.js +1 -0
- package/workspace/lib/code-map.js +8 -2
- package/workspace/lib/critical-needs.js +162 -0
- package/workspace/lib/deps-cli.js +102 -0
- package/workspace/lib/engine/boards.js +13 -2
- package/workspace/lib/factory-floor.js +16 -8
- package/workspace/lib/features.json +17 -13
- package/workspace/lib/needs-providers.js +1 -0
- package/workspace/lib/page-one-answer.js +86 -0
- package/workspace/lib/pages-cli.js +6 -2
- package/workspace/lib/people-cli.js +9 -1
- package/workspace/lib/people-prep.js +140 -0
- package/workspace/lib/pmos-verbs.js +10 -0
- package/workspace/lib/print-cli.js +49 -0
- package/workspace/lib/print-pdf.js +96 -0
- package/workspace/lib/prototype-cli.js +86 -0
- package/workspace/lib/report-cli.js +12 -2
- package/workspace/lib/report-readers.js +5 -3
- package/workspace/lib/review-pack.js +348 -0
- package/workspace/lib/review-reasons.js +121 -9
- package/workspace/lib/route-modules.js +5 -0
- package/workspace/lib/routes-boards.js +25 -2
- package/workspace/lib/routes-report-design.js +3 -1
- package/workspace/lib/routes-review-pack.js +42 -0
- package/workspace/lib/routes-roadmap-ops.js +53 -1
- package/workspace/lib/routes-sim-users.js +66 -0
- package/workspace/lib/routes-skill-map.js +39 -0
- package/workspace/lib/routes-strategy-card.js +13 -6
- package/workspace/lib/routes-team-waits.js +24 -0
- package/workspace/lib/sim-users.js +329 -0
- package/workspace/lib/skill-map.js +199 -0
- package/workspace/lib/task-store.js +1 -1
- package/workspace/lib/team-cli.js +20 -1
- package/workspace/lib/team-waits.js +167 -0
- package/workspace/lib/tradeoff-cards.js +258 -0
- package/workspace/lib/tradeoff-cli.js +83 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/action-keys.js +1 -0
- package/workspace/public/pm/ask-here-ctx.js +25 -1
- package/workspace/public/pm/ask-here.css +7 -0
- package/workspace/public/pm/ask-here.js +15 -2
- package/workspace/public/pm/bd-backlog.css +61 -0
- package/workspace/public/pm/bd-backlog.js +99 -7
- package/workspace/public/pm/bd-work.js +12 -1
- package/workspace/public/pm/code-map.js +15 -4
- package/workspace/public/pm/cozy-board.css +5 -1
- package/workspace/public/pm/cozy-library.css +5 -0
- package/workspace/public/pm/cozy-pop-work.js +4 -1
- package/workspace/public/pm/cozy-proto.css +5 -0
- package/workspace/public/pm/cozy-proto.js +11 -3
- package/workspace/public/pm/cozy-search.js +2 -2
- package/workspace/public/pm/cozy-today-app.js +5 -2
- package/workspace/public/pm/day-time.js +8 -0
- package/workspace/public/pm/factory.js +199 -0
- package/workspace/public/pm/home-ini.js +3 -2
- package/workspace/public/pm/ini-links.js +2 -1
- package/workspace/public/pm/ini-tasks.js +5 -2
- package/workspace/public/pm/ini-view-model.js +14 -6
- package/workspace/public/pm/ini-view.js +12 -2
- package/workspace/public/pm/library-model.js +1 -1
- package/workspace/public/pm/page-one-answer.css +18 -0
- package/workspace/public/pm/page-one-answer.js +134 -0
- package/workspace/public/pm/pop-cap.js +5 -3
- package/workspace/public/pm/pop-work-model.js +8 -6
- package/workspace/public/pm/portfolio.js +1 -1
- package/workspace/public/pm/premium-board.js +23 -6
- package/workspace/public/pm/premium-library.js +27 -3
- package/workspace/public/pm/premium-report-read.js +11 -2
- package/workspace/public/pm/print-pdf.js +191 -0
- package/workspace/public/pm/range-pick.css +12 -0
- package/workspace/public/pm/range-pick.js +30 -6
- package/workspace/public/pm/review-pack.js +47 -0
- package/workspace/public/pm/review-reasons.js +19 -5
- package/workspace/public/pm/sim-users.js +34 -0
- package/workspace/public/pm/skill-map.js +57 -0
- package/workspace/public/pm/sort-order.js +3 -0
- package/workspace/public/pm/task-card.js +10 -7
- package/workspace/public/pm/team-waits.js +56 -0
- package/workspace/public/pm/tradeoff-cards.css +27 -0
- package/workspace/public/pm/tradeoff-cards.js +183 -0
- package/workspace/public/premium-board.html +3 -0
- package/workspace/public/today.html +1 -0
- package/workspace/run-tests.js +9 -1
- package/workspace/test-lists/critical-needs.json +9 -0
- package/workspace/test-lists/factory-page-ui.json +9 -0
- package/workspace/test-lists/page-one-answer.json +9 -0
- package/workspace/test-lists/people-prep.json +9 -0
- package/workspace/test-lists/print-pdf.json +9 -0
- package/workspace/test-lists/review-pack.json +9 -0
- package/workspace/test-lists/sim-users.json +9 -0
- package/workspace/test-lists/skill-map.json +9 -0
- package/workspace/test-lists/surface-ask-card.json +9 -0
- package/workspace/test-lists/task-time-optional.json +9 -0
- package/workspace/test-lists/team-waits.json +9 -0
- package/workspace/test-lists/tradeoff-cards.json +9 -0
- package/workspace/test-lists/voice-files.json +9 -0
- package/workspace/test-timings.json +25 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* team-waits.js — who waits on which team (initiative team-waits, bet A364; board BatchCodeDS panel 14, Work › Dependencies).
|
|
3
|
+
*
|
|
4
|
+
* An initiative of the product waits on another team: a security review, a data export. The wait lives in a Jira link or in a note on
|
|
5
|
+
* the initiative. This module reads both into one list, oldest first, and keeps the store the page and the chat write.
|
|
6
|
+
*
|
|
7
|
+
* waitsOf(root, { today }) → { file, waits: [wait] } open waits, oldest first
|
|
8
|
+
* wait = { id, ini, title, team, what, since, days, who, email, key, sprint, sprint_end, src }
|
|
9
|
+
* src: 'jira:<KEY>' (a Jira link, written by `pmos deps wait --key`), 'chat' (the chat or a terminal), 'parked' (a parked
|
|
10
|
+
* initiative whose reason says "waiting on <team>"), 'record' (an initiative record with `waiting_on:` and `waiting_since:`)
|
|
11
|
+
* add(root, { ini, team, what, since, who, email, key, sprint, sprint_end, src }, { now, by, via }) → { ok, id, line } | { ok: false, error }
|
|
12
|
+
* end(root, { id }, { now, by, via }) → { ok, line } | { ok: false, error } the wait is over (one `wait-end` line)
|
|
13
|
+
* back(root, { id }, { now, by, via }) → { ok, line } | { ok: false, error } Undo of end (one `wait-back` line)
|
|
14
|
+
* LATE_DAYS a wait this many days old or more is late (spec question Q1, default 14)
|
|
15
|
+
*
|
|
16
|
+
* THE STORE. `team-waits.jsonl` in the product's runs folder (planning/runs or pmos/state, lib/parked-reasons.js layoutOf). Lines are
|
|
17
|
+
* appended, never changed: { kind: 'wait' | 'wait-end' | 'wait-back', id, at, by, via, … }. A torn line has no effect.
|
|
18
|
+
* THE NOTES. Read only: nothing here writes an initiative record or a lifecycle line. A parked hold that waits on another initiative of the
|
|
19
|
+
* same product is not a team wait (pmos parked shows it). A closed or cancelled initiative has no waits.
|
|
20
|
+
* Nothing is sent: the Chase draft (public/pm/team-waits.js chaseDraft) opens in the PM's own mail app. */
|
|
21
|
+
const fs = require('fs');
|
|
22
|
+
const path = require('path');
|
|
23
|
+
const P = require('./parked-reasons.js');
|
|
24
|
+
|
|
25
|
+
const FILE = 'team-waits.jsonl';
|
|
26
|
+
const TAG = '[team-waits]';
|
|
27
|
+
const DAY = 864e5;
|
|
28
|
+
const LATE_DAYS = 14;
|
|
29
|
+
const DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
30
|
+
const KEY_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
|
|
31
|
+
const ENDED = new Set(['closed', 'cancelled']);
|
|
32
|
+
|
|
33
|
+
const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
|
|
34
|
+
const dayOf = (v) => (typeof v === 'string' && DATE.test(v.slice(0, 10)) && Number.isFinite(Date.parse(v.slice(0, 10))) ? v.slice(0, 10) : null);
|
|
35
|
+
const daysBetween = (a, b) => Math.max(0, Math.round((Date.parse(b) - Date.parse(a)) / DAY));
|
|
36
|
+
|
|
37
|
+
function jsonl(file) {
|
|
38
|
+
let text = '';
|
|
39
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
40
|
+
const out = [];
|
|
41
|
+
for (const l of text.split('\n')) { if (!l.trim()) continue; try { const r = JSON.parse(l); if (r && typeof r === 'object' && !Array.isArray(r)) out.push(r); } catch { /* a torn line */ } }
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
const fileOf = (root) => { const L = P.layoutOf(root); return L ? path.join(L.runs, FILE) : null; };
|
|
45
|
+
|
|
46
|
+
/** The initiatives of the product: Map id → { title, waiting_on, waiting_since }. */
|
|
47
|
+
function recordsOf(L) {
|
|
48
|
+
const out = new Map();
|
|
49
|
+
let files = [];
|
|
50
|
+
try { files = fs.readdirSync(L.initiatives).filter((f) => f.endsWith('.md')); } catch { return out; }
|
|
51
|
+
for (const f of files) {
|
|
52
|
+
let head = '';
|
|
53
|
+
try { head = fs.readFileSync(path.join(L.initiatives, f), 'utf8').slice(0, 6000); } catch { continue; }
|
|
54
|
+
const fm = /^---\r?\n([\s\S]*?)\r?\n---/.exec(head);
|
|
55
|
+
const get = (k) => { const m = fm && new RegExp('^' + k + ':\\s*(.*)$', 'm').exec(fm[1]); return m ? m[1].trim().replace(/^["']|["']$/g, '') : ''; };
|
|
56
|
+
const id = get('id') || f.slice(0, -3);
|
|
57
|
+
out.set(id, { title: get('title') || id, waiting_on: get('waiting_on'), waiting_since: get('waiting_since') });
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** Latest lifecycle state per initiative id. */
|
|
62
|
+
function statesOf(L) {
|
|
63
|
+
const m = new Map();
|
|
64
|
+
for (const r of jsonl(path.join(L.runs, 'lifecycle.jsonl'))) if (typeof r.initiative_id === 'string' && typeof r.state === 'string') m.set(r.initiative_id, r.state);
|
|
65
|
+
return m;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** "Security review: the pen test sign-off" → { team: 'Security review', what: 'the pen test sign-off' }. */
|
|
69
|
+
function splitOn(text) {
|
|
70
|
+
const t = clip(text, 200);
|
|
71
|
+
const m = /^([^:—–]{1,60})\s*[:—–]\s*(.+)$/.exec(t);
|
|
72
|
+
return m ? { team: m[1].trim(), what: m[2].trim() } : { team: t, what: '' };
|
|
73
|
+
}
|
|
74
|
+
/** The team a parked reason waits on: the words after "waiting on/for", "blocked by/on", "depends on". '' when none. */
|
|
75
|
+
function teamOfReason(reason) {
|
|
76
|
+
const m = /\b(?:waiting (?:on|for)|blocked (?:by|on)|depends on|dependent on)\s+(?:the\s+)?(.+)$/i.exec(String(reason || '').trim());
|
|
77
|
+
return m ? clip(m[1].replace(/[.;]+$/, ''), 120) : '';
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The store folded: Map id → wait (open or not). */
|
|
81
|
+
function foldStore(file) {
|
|
82
|
+
const m = new Map();
|
|
83
|
+
for (const r of jsonl(file)) {
|
|
84
|
+
if (typeof r.id !== 'string' || !r.id) continue;
|
|
85
|
+
if (r.kind === 'wait') m.set(r.id, { ...r, open: true });
|
|
86
|
+
else if (r.kind === 'wait-end' && m.has(r.id)) m.get(r.id).open = false;
|
|
87
|
+
else if (r.kind === 'wait-back' && m.has(r.id)) m.get(r.id).open = true;
|
|
88
|
+
}
|
|
89
|
+
return m;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function waitsOf(root, { today = P.todayOf() } = {}) {
|
|
93
|
+
root = path.resolve(root);
|
|
94
|
+
const L = P.layoutOf(root);
|
|
95
|
+
if (!L) return { file: null, waits: [] };
|
|
96
|
+
const recs = recordsOf(L), states = statesOf(L);
|
|
97
|
+
const live = (ini) => !ini || !ENDED.has(states.get(ini));
|
|
98
|
+
const titleOf = (ini) => (ini && recs.has(ini) ? recs.get(ini).title : ini || '');
|
|
99
|
+
const out = [];
|
|
100
|
+
const shape = (w) => {
|
|
101
|
+
const since = dayOf(w.since) || today;
|
|
102
|
+
const sprintEnd = dayOf(w.sprint_end);
|
|
103
|
+
return { id: w.id, ini: w.ini || '', title: titleOf(w.ini), team: clip(w.team, 80), what: clip(w.what, 160), since, days: daysBetween(since, today),
|
|
104
|
+
who: clip(w.who, 80), email: /^[^\s@]+@[^\s@]+$/.test(w.email || '') ? w.email : '', key: KEY_RE.test(w.key || '') ? w.key : '',
|
|
105
|
+
sprint: clip(w.sprint, 60), sprint_end: sprintEnd, src: w.src || 'chat' };
|
|
106
|
+
};
|
|
107
|
+
// 1. the store: Jira links and what the chat wrote
|
|
108
|
+
for (const w of foldStore(path.join(L.runs, FILE)).values()) if (w.open && live(w.ini)) out.push(shape(w));
|
|
109
|
+
// 2. the initiative notes: a parked initiative waiting on a team (not on another initiative of the product)
|
|
110
|
+
let parked = [];
|
|
111
|
+
const fromHold = new Set();
|
|
112
|
+
try { parked = P.parkedOf(root, { today }).parked; } catch { parked = []; }
|
|
113
|
+
for (const p of parked) {
|
|
114
|
+
if (p.kind !== 'waiting' || p.after || p.back) continue;
|
|
115
|
+
const team = teamOfReason(p.reason);
|
|
116
|
+
if (!team || recs.has(team)) continue;
|
|
117
|
+
fromHold.add(p.id);
|
|
118
|
+
out.push(shape({ id: 'parked:' + p.id, ini: p.id, ...splitOn(team), since: p.at, src: 'parked' }));
|
|
119
|
+
}
|
|
120
|
+
// 3. an initiative record that says `waiting_on:` (and `waiting_since:`)
|
|
121
|
+
for (const [id, r] of recs) {
|
|
122
|
+
if (!r.waiting_on || !live(id) || fromHold.has(id)) continue; // a hold already said it: say it once
|
|
123
|
+
if (recs.has(r.waiting_on)) continue; // another initiative of the product: not a team
|
|
124
|
+
out.push(shape({ id: 'record:' + id, ini: id, ...splitOn(r.waiting_on), since: r.waiting_since, src: 'record' }));
|
|
125
|
+
}
|
|
126
|
+
out.sort((a, b) => a.since.localeCompare(b.since) || a.title.localeCompare(b.title) || a.id.localeCompare(b.id));
|
|
127
|
+
return { file: path.relative(root, path.join(L.runs, FILE)).split(path.sep).join('/'), waits: out };
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function append(file, line) {
|
|
131
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
132
|
+
fs.appendFileSync(file, JSON.stringify(line) + '\n');
|
|
133
|
+
return line;
|
|
134
|
+
}
|
|
135
|
+
const stamp = (now, by, via) => ({ at: new Date(now).toISOString(), by: by || 'pm', via: via || 'cli' });
|
|
136
|
+
|
|
137
|
+
function add(root, w = {}, { now = Date.now(), by, via } = {}) {
|
|
138
|
+
const file = fileOf(path.resolve(root));
|
|
139
|
+
if (!file) return { ok: false, error: 'no initiatives folder here (planning/initiatives or pmos/state/initiatives)' };
|
|
140
|
+
const team = clip(w.team, 80), what = clip(w.what, 160);
|
|
141
|
+
if (!team && !what) return { ok: false, error: 'say which team it waits on (--team) or what it waits for (--what)' };
|
|
142
|
+
if (w.since && !dayOf(w.since)) return { ok: false, error: '--since must be a day, YYYY-MM-DD' };
|
|
143
|
+
if (w.sprint_end && !dayOf(w.sprint_end)) return { ok: false, error: '--sprint-end must be a day, YYYY-MM-DD' };
|
|
144
|
+
if (w.key && !KEY_RE.test(w.key)) return { ok: false, error: '--key must be a Jira key such as SEC-12' };
|
|
145
|
+
const open = [...foldStore(file).values()].filter((x) => x.open);
|
|
146
|
+
if (w.key) { const dup = open.find((x) => x.key === w.key); if (dup) return { ok: false, error: `${w.key} already has an open wait (${dup.id}); end it first with pmos deps done ${dup.id}` }; }
|
|
147
|
+
const id = 'w' + Date.parse(new Date(now).toISOString()).toString(36) + Math.random().toString(36).slice(2, 5);
|
|
148
|
+
const line = { kind: 'wait', id, ini: String(w.ini || ''), team, what, since: dayOf(w.since) || P.todayOf(now), who: clip(w.who, 80), email: String(w.email || ''),
|
|
149
|
+
key: w.key || '', sprint: clip(w.sprint, 60), sprint_end: dayOf(w.sprint_end) || '', src: w.key ? 'jira:' + w.key : (w.src || 'chat'), ...stamp(now, by, via) };
|
|
150
|
+
append(file, line);
|
|
151
|
+
return { ok: true, id, line };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function flip(kind, root, { id } = {}, { now = Date.now(), by, via } = {}) {
|
|
155
|
+
const file = fileOf(path.resolve(root));
|
|
156
|
+
if (!file) return { ok: false, error: 'no initiatives folder here' };
|
|
157
|
+
if (/^(parked|record):/.test(String(id || ''))) return { ok: false, error: 'that wait comes from the initiative itself: change its hold (pmos parked) or its record' };
|
|
158
|
+
const w = foldStore(file).get(String(id || ''));
|
|
159
|
+
if (!w) return { ok: false, error: `no wait ${id}` };
|
|
160
|
+
if (kind === 'wait-end' && !w.open) return { ok: false, error: `${id} is already over` };
|
|
161
|
+
if (kind === 'wait-back' && w.open) return { ok: false, error: `${id} is still open` };
|
|
162
|
+
return { ok: true, line: append(file, { kind, id: w.id, ...stamp(now, by, via) }) };
|
|
163
|
+
}
|
|
164
|
+
const end = (root, a, o) => flip('wait-end', root, a, o);
|
|
165
|
+
const back = (root, a, o) => flip('wait-back', root, a, o);
|
|
166
|
+
|
|
167
|
+
module.exports = { FILE, TAG, LATE_DAYS, waitsOf, add, end, back, teamOfReason, splitOn, fileOf };
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* tradeoff-cards.js — two close items on the Roadmap side by side, and the reason the PM kept one above the other (initiative
|
|
4
|
+
* tradeoff-cards, job #1918, idea A325; board TradeoffDS on the main canvas; done test planning/done-tests/tradeoff-cards.md).
|
|
5
|
+
*
|
|
6
|
+
* WHEN A CARD EXISTS. Two neighbours on the one ranked list (D105, lib/placements.js) whose weighted sizes (lib/opportunity-size.js:
|
|
7
|
+
* reach × frequency × worth × confidence) are within MARGIN of the larger one. A side with no complete size is never compared: zero is
|
|
8
|
+
* silence. A drag that puts one directly above another opens the same card for that pair (the page asks `cardFor`).
|
|
9
|
+
*
|
|
10
|
+
* THE SIDES. Read from the initiative's record frontmatter, never guessed; a missing value is NOT_KNOWN:
|
|
11
|
+
* goal parent_kr (or anchor) the goal it moves
|
|
12
|
+
* evidence evidence:, else its size with its source
|
|
13
|
+
* cost cost:, effort: or estimate:
|
|
14
|
+
* risk risk: or riskiest_assumption:
|
|
15
|
+
* waits waits:, else "<the other> starts after it" what waits if it goes first
|
|
16
|
+
*
|
|
17
|
+
* ✦ suggest(a, b): stronger size evidence first (measured > estimated > guess), else the bigger weighted size, else the current order.
|
|
18
|
+
* One line, from the records only. PMOS suggests; the PM chooses (the card's ✓).
|
|
19
|
+
*
|
|
20
|
+
* THE NOTES. One append-only file beside the placements ledger: <runs dir>/tradeoffs.jsonl (planning/runs/ or pmos/state/).
|
|
21
|
+
* { v: 1, eid, ev: 'kept', first, second, reason, at, by, via, moved?: { initiative, back } }
|
|
22
|
+
* { v: 1, eid, ev: 'undone', of: <eid>, at, by, via }
|
|
23
|
+
* keep() writes the note; when `first` was ranked below `second` it also writes ONE `ranked` line to the placements ledger that puts
|
|
24
|
+
* `first` directly above `second` (placements.js stays the one writer of the rank). undo() puts the rank back and marks the note undone.
|
|
25
|
+
* Nothing here changes a record file or a size line: the factor scores stay.
|
|
26
|
+
*
|
|
27
|
+
* CLI: lib/tradeoff-cli.js (pmos tradeoff, the chat's way to read and write the same store the page reads):
|
|
28
|
+
* pmos tradeoff list [--json] the close pairs and the kept reasons
|
|
29
|
+
* pmos tradeoff show <a> <b> [--json] one card
|
|
30
|
+
* pmos tradeoff keep <a> <b> --first <id> --reason "<text>" keep the order and the reason
|
|
31
|
+
* pmos tradeoff undo <note> take a kept reason back (and the rank it moved)
|
|
32
|
+
* pmos tradeoff count [--days 14] reasons kept in the last days; the last line is the number
|
|
33
|
+
* Every log line carries [tradeoff]. No model call, nothing sent. */
|
|
34
|
+
const fs = require('fs');
|
|
35
|
+
const path = require('path');
|
|
36
|
+
const crypto = require('crypto');
|
|
37
|
+
const SIZE = require('./opportunity-size.js');
|
|
38
|
+
|
|
39
|
+
const TAG = '[tradeoff]';
|
|
40
|
+
const MARGIN = 0.25;
|
|
41
|
+
const NOT_KNOWN = 'not known';
|
|
42
|
+
const MAX_REASON = 200;
|
|
43
|
+
const FILE = 'tradeoffs.jsonl';
|
|
44
|
+
const CONF = ['guess', 'estimated', 'measured'];
|
|
45
|
+
const DAY = 86400000;
|
|
46
|
+
|
|
47
|
+
const s = (v) => (v == null ? '' : String(v).trim());
|
|
48
|
+
const fmt = (n) => (n >= 100 ? Math.round(n).toLocaleString('en-US') : String(Math.round(n * 100) / 100));
|
|
49
|
+
const titleOf = (r) => (r && (r.title || r.id)) || '';
|
|
50
|
+
|
|
51
|
+
/* ── the pairs ─────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
52
|
+
|
|
53
|
+
/** Two weighted sizes are close when the gap is at most `margin` of the larger one. */
|
|
54
|
+
function close(x, y, margin = MARGIN) {
|
|
55
|
+
if (!(x > 0 && y > 0)) return false;
|
|
56
|
+
return Math.abs(x - y) <= margin * Math.max(x, y);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** rows: [{ id, title, size }] in rank order (top first). → [{ a, b, ratio }]: each close pair of neighbours, `a` ranked above `b`. */
|
|
60
|
+
function closePairs(rows, margin = MARGIN) {
|
|
61
|
+
const out = [];
|
|
62
|
+
const L = rows || [];
|
|
63
|
+
for (let i = 0; i + 1 < L.length; i++) {
|
|
64
|
+
const a = L[i], b = L[i + 1];
|
|
65
|
+
if (!(a && b && a.size && b.size && a.size.complete && b.size.complete)) continue;
|
|
66
|
+
if (!close(a.size.weighted, b.size.weighted, margin)) continue;
|
|
67
|
+
out.push({ a: a.id, b: b.id, ratio: Math.round((Math.max(a.size.weighted, b.size.weighted) / Math.min(a.size.weighted, b.size.weighted)) * 100) / 100 });
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/* ── the sides ─────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
73
|
+
|
|
74
|
+
const firstOf = (fm, keys) => { for (const k of keys) if (s(fm[k])) return s(fm[k]); return ''; };
|
|
75
|
+
function sizeWords(z) {
|
|
76
|
+
if (!z || !z.complete) return '';
|
|
77
|
+
const weak = Object.values(z.lines).find((l) => l.confidence === z.confidence) || {};
|
|
78
|
+
return `about ${fmt(z.size)} a month (${z.confidence}${weak.source ? ', ' + weak.source : ''})`;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** One side of the card. rec: { id, title, fm }; other: the other side's { id, title }. */
|
|
82
|
+
function sideOf(rec, other) {
|
|
83
|
+
const fm = (rec && rec.fm) || {};
|
|
84
|
+
const size = SIZE.sizeOf(fm);
|
|
85
|
+
return {
|
|
86
|
+
id: rec.id, title: titleOf(rec),
|
|
87
|
+
goal: firstOf(fm, ['parent_kr', 'anchor']) || NOT_KNOWN,
|
|
88
|
+
evidence: firstOf(fm, ['evidence']) || sizeWords(size) || NOT_KNOWN,
|
|
89
|
+
cost: firstOf(fm, ['cost', 'effort', 'estimate']) || NOT_KNOWN,
|
|
90
|
+
risk: firstOf(fm, ['risk', 'riskiest_assumption']) || NOT_KNOWN,
|
|
91
|
+
waits: firstOf(fm, ['waits']) || (other ? `${titleOf(other)} starts after it` : NOT_KNOWN),
|
|
92
|
+
size: size && size.complete ? { weighted: size.weighted, confidence: size.confidence } : null,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** ✦ the order the records support, and one line why. a is ranked above b now. */
|
|
97
|
+
function suggest(a, b) {
|
|
98
|
+
const ca = a.size ? CONF.indexOf(a.size.confidence) : -1, cb = b.size ? CONF.indexOf(b.size.confidence) : -1;
|
|
99
|
+
if (ca !== cb && ca >= 0 && cb >= 0) {
|
|
100
|
+
const [w, l] = ca > cb ? [a, b] : [b, a];
|
|
101
|
+
return { first: w.id, reason: `${w.title} first: its size is ${w.size.confidence}, and ${l.title}'s is ${l.size.confidence === 'guess' ? 'a guess' : l.size.confidence}.` };
|
|
102
|
+
}
|
|
103
|
+
if (a.size && b.size && a.size.weighted !== b.size.weighted) {
|
|
104
|
+
const [w, l] = a.size.weighted > b.size.weighted ? [a, b] : [b, a];
|
|
105
|
+
return { first: w.id, reason: `${w.title} first: about ${fmt(w.size.weighted)} a month against ${fmt(l.size.weighted)} for ${l.title}, weighted by how sure each is.` };
|
|
106
|
+
}
|
|
107
|
+
return { first: a.id, reason: 'Keep the current order: the records do not tell these two apart.' };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* ── the notes ─────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
111
|
+
|
|
112
|
+
function notesPath(root) {
|
|
113
|
+
const ledgers = require('./plan-ledgers.js');
|
|
114
|
+
return path.join(path.dirname(ledgers.ledgerPath(root, 'placements')), FILE);
|
|
115
|
+
}
|
|
116
|
+
function readNotes(root) {
|
|
117
|
+
let text = '';
|
|
118
|
+
try { text = fs.readFileSync(notesPath(root), 'utf8'); } catch { return []; }
|
|
119
|
+
const out = [];
|
|
120
|
+
for (const line of text.split('\n')) { if (!line.trim()) continue; try { const r = JSON.parse(line); if (r && r.eid && r.ev) out.push(r); } catch { /* a torn line is skipped */ } }
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
/** The notes still in force, newest first. */
|
|
124
|
+
function activeNotes(lines) {
|
|
125
|
+
const undone = new Set(lines.filter((l) => l.ev === 'undone').map((l) => l.of));
|
|
126
|
+
return lines.filter((l) => l.ev === 'kept' && !undone.has(l.eid)).sort((x, y) => String(y.at).localeCompare(String(x.at)));
|
|
127
|
+
}
|
|
128
|
+
/** id → the newest kept note where `id` went first: { eid, other, reason, at }. Shown once, under that row. */
|
|
129
|
+
function keptBy(notes) {
|
|
130
|
+
const out = {};
|
|
131
|
+
for (const n of notes) if (!out[n.first]) out[n.first] = { eid: n.eid, other: n.second, reason: n.reason, at: n.at };
|
|
132
|
+
return out;
|
|
133
|
+
}
|
|
134
|
+
/** The newest kept note about this pair, in either order: shown first when the pair comes up again. */
|
|
135
|
+
function pastFor(notes, a, b) {
|
|
136
|
+
return notes.find((n) => (n.first === a && n.second === b) || (n.first === b && n.second === a)) || null;
|
|
137
|
+
}
|
|
138
|
+
const newEid = () => crypto.randomBytes(9).toString('base64').replace(/[^a-z0-9]/gi, '').toLowerCase().slice(0, 12).padEnd(12, '0');
|
|
139
|
+
|
|
140
|
+
/* ── the read ──────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
141
|
+
|
|
142
|
+
function ranked(root, now) {
|
|
143
|
+
const placements = require('./placements.js');
|
|
144
|
+
let records;
|
|
145
|
+
try { const d = require('./initiative-rows.js').deriveSync(root); if (d && d.ok) records = d.rows; } catch { records = undefined; }
|
|
146
|
+
let rules;
|
|
147
|
+
try { rules = require('./plan-rules.js').readRules(root); } catch { rules = undefined; }
|
|
148
|
+
const P = placements.readPlacements(root, { now, rules, records });
|
|
149
|
+
return { ids: P.ranked || [], byInit: P.byInit || {} };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The whole answer for one repository: { pairs: [card], kept: { id: { eid, other, other_title, reason, at } }, margin }. */
|
|
153
|
+
function read(root, { now = Date.now(), margin = MARGIN } = {}) {
|
|
154
|
+
const recs = SIZE.recordsOf(root);
|
|
155
|
+
const byId = new Map(recs.map((r) => [r.id, r]));
|
|
156
|
+
const R = ranked(root, now);
|
|
157
|
+
const rows = R.ids.filter((id) => byId.has(id) && !(R.byInit[id] && R.byInit[id].dormant))
|
|
158
|
+
.map((id) => ({ id, title: byId.get(id).title, size: SIZE.sizeOf(byId.get(id).fm) }));
|
|
159
|
+
const notes = activeNotes(readNotes(root));
|
|
160
|
+
const pairs = closePairs(rows, margin).map((p) => cardOf(byId, notes, p.a, p.b, { ratio: p.ratio }));
|
|
161
|
+
const kept = {};
|
|
162
|
+
for (const [id, k] of Object.entries(keptBy(notes))) if (byId.has(id)) kept[id] = { ...k, other_title: titleOf(byId.get(k.other)) || k.other };
|
|
163
|
+
return { margin, pairs, kept };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function cardOf(byId, notes, a, b, extra = {}) {
|
|
167
|
+
const A = byId.get(a), B = byId.get(b);
|
|
168
|
+
const sa = sideOf(A, B), sb = sideOf(B, A);
|
|
169
|
+
const past = pastFor(notes, a, b);
|
|
170
|
+
return { a: sa, b: sb, suggest: suggest(sa, sb), past: past ? { eid: past.eid, first: past.first, reason: past.reason, at: past.at } : null, ...extra };
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** One card for any two initiatives on the Roadmap (a drag, or the CLI). `a` is the one ranked higher now. */
|
|
174
|
+
function cardFor(root, x, y, { now = Date.now() } = {}) {
|
|
175
|
+
const recs = SIZE.recordsOf(root);
|
|
176
|
+
const byId = new Map(recs.map((r) => [r.id, r]));
|
|
177
|
+
const R = ranked(root, now);
|
|
178
|
+
for (const id of [x, y]) if (!byId.has(id) || !R.ids.includes(id)) return { ok: false, status: 404, error: `${id} is not an initiative on the Roadmap here` };
|
|
179
|
+
if (x === y) return { ok: false, status: 400, error: 'pick two different initiatives' };
|
|
180
|
+
const [a, b] = R.ids.indexOf(x) < R.ids.indexOf(y) ? [x, y] : [y, x];
|
|
181
|
+
return { ok: true, card: cardOf(byId, activeNotes(readNotes(root)), a, b) };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* ── the writes ────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
185
|
+
|
|
186
|
+
function reasonError(reason) {
|
|
187
|
+
const r = s(reason);
|
|
188
|
+
if (!r) return 'write why in one line: the reason is kept with the list';
|
|
189
|
+
if (/[\r\n]/.test(String(reason))) return 'the reason is one line';
|
|
190
|
+
if (r.length > MAX_REASON) return `the reason is at most ${MAX_REASON} characters`;
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
function appendNote(root, rec) {
|
|
194
|
+
const file = notesPath(root);
|
|
195
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
196
|
+
fs.appendFileSync(file, JSON.stringify(rec) + '\n');
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** Keep `first` above the other of a/b, with the reason. actor: actor.js fromUi() or fromCli(). */
|
|
200
|
+
function keep(root, { a, b, first, reason } = {}, { actor, now = Date.now() } = {}) {
|
|
201
|
+
const placements = require('./placements.js');
|
|
202
|
+
const err = reasonError(reason);
|
|
203
|
+
if (err) return { ok: false, status: 400, error: err };
|
|
204
|
+
if (!a || !b || a === b) return { ok: false, status: 400, error: 'name the two initiatives' };
|
|
205
|
+
if (first !== a && first !== b) return { ok: false, status: 400, error: 'first must be one of the two' };
|
|
206
|
+
const second = first === a ? b : a;
|
|
207
|
+
const R = ranked(root, now);
|
|
208
|
+
for (const id of [a, b]) if (!R.ids.includes(id)) return { ok: false, status: 404, error: `${id} is not an initiative on the Roadmap here` };
|
|
209
|
+
let moved = null;
|
|
210
|
+
const fi = R.ids.indexOf(first), si = R.ids.indexOf(second);
|
|
211
|
+
if (fi > si) {
|
|
212
|
+
const back = R.ids[fi - 1] || null; // first's place now: after the row above it
|
|
213
|
+
const above = si > 0 ? R.ids[si - 1] : null; // directly above `second`
|
|
214
|
+
const w = placements.appendFromCli(root, [{ ev: 'ranked', initiative: first, after: above }], { actor, now });
|
|
215
|
+
if (!w.ok) return { ok: false, status: w.status || 500, error: w.error };
|
|
216
|
+
moved = { initiative: first, back };
|
|
217
|
+
}
|
|
218
|
+
const rec = { v: 1, eid: newEid(), ev: 'kept', first, second, reason: s(reason), at: new Date(now).toISOString(), by: actor.by, via: actor.via, ...(moved ? { moved } : {}) };
|
|
219
|
+
appendNote(root, rec);
|
|
220
|
+
console.info(`${TAG} kept ${first} above ${second}${moved ? ' (moved)' : ''}`);
|
|
221
|
+
return { ok: true, note: rec };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** Take a kept reason back: the rank it moved goes back, and the note is marked undone. */
|
|
225
|
+
function undo(root, eid, { actor, now = Date.now() } = {}) {
|
|
226
|
+
const placements = require('./placements.js');
|
|
227
|
+
const lines = readNotes(root);
|
|
228
|
+
const n = lines.find((l) => l.ev === 'kept' && l.eid === eid);
|
|
229
|
+
if (!n) return { ok: false, status: 404, error: `no kept reason ${eid}` };
|
|
230
|
+
if (lines.some((l) => l.ev === 'undone' && l.of === eid)) return { ok: false, status: 409, error: `${eid} was taken back already` };
|
|
231
|
+
if (n.moved) {
|
|
232
|
+
const w = placements.appendFromCli(root, [{ ev: 'ranked', initiative: n.moved.initiative, after: n.moved.back }], { actor, now });
|
|
233
|
+
if (!w.ok) return { ok: false, status: w.status || 500, error: w.error };
|
|
234
|
+
}
|
|
235
|
+
appendNote(root, { v: 1, eid: newEid(), ev: 'undone', of: eid, at: new Date(now).toISOString(), by: actor.by, via: actor.via });
|
|
236
|
+
console.info(`${TAG} undone ${eid}`);
|
|
237
|
+
return { ok: true, of: eid };
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/** The workspace whose records hold most of `ids` (the Work page's rows on screen): { id, root } | null. list: ctx.workspaceList(). */
|
|
241
|
+
function wsForIds(list, ids) {
|
|
242
|
+
const want = (ids || []).filter((x) => /^[a-z0-9][a-z0-9._-]*$/i.test(x)).slice(0, 200);
|
|
243
|
+
let best = null, bestN = 0;
|
|
244
|
+
for (const w of list || []) {
|
|
245
|
+
if (!w || !w.root) continue;
|
|
246
|
+
let n = 0;
|
|
247
|
+
for (const id of want) if (['planning/initiatives', 'pmos/state/initiatives'].some((d) => fs.existsSync(path.join(w.root, d, id + '.md')))) n++;
|
|
248
|
+
if (n > bestN) { best = w; bestN = n; }
|
|
249
|
+
}
|
|
250
|
+
return best;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function count(root, { days = 14, now = Date.now() } = {}) {
|
|
254
|
+
const from = now - days * DAY;
|
|
255
|
+
return activeNotes(readNotes(root)).filter((n) => Date.parse(n.at) >= from).length;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
module.exports = { TAG, MARGIN, NOT_KNOWN, MAX_REASON, FILE, close, closePairs, sideOf, suggest, readNotes, activeNotes, keptBy, pastFor, notesPath, read, cardFor, keep, undo, count, wsForIds };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* tradeoff-cli.js — `pmos tradeoff` (initiative tradeoff-cards, job #1918, idea A325): the chat's and the terminal's way to read and write
|
|
4
|
+
* the same trade-off store the Work page reads (lib/tradeoff-cards.js). Its own module so the verb table names a -cli file. */
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { TAG, MARGIN, read, cardFor, keep, undo, count } = require('./tradeoff-cards.js');
|
|
8
|
+
|
|
9
|
+
/* ── pmos tradeoff ─────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
10
|
+
const COMMANDS = { tradeoff: ['list', 'show', 'keep', 'undo', 'count'] };
|
|
11
|
+
const USAGE = [
|
|
12
|
+
'usage: pmos tradeoff [list|show|keep|undo|count] — two close items on the Roadmap side by side, and why you kept one first',
|
|
13
|
+
' pmos tradeoff list the close pairs and the kept reasons (writes nothing)',
|
|
14
|
+
' pmos tradeoff show <a> <b> one card: goal, evidence, cost, risk and what waits, and ✦',
|
|
15
|
+
' pmos tradeoff keep <a> <b> --first <id> --reason "<why>" keep that order and the reason with the ranked list',
|
|
16
|
+
' pmos tradeoff undo <note> take a kept reason back, and the rank it moved',
|
|
17
|
+
' pmos tradeoff count [--days 14] reasons kept in the last days; the number is the last line',
|
|
18
|
+
];
|
|
19
|
+
function repoOf(cwd) {
|
|
20
|
+
let d = path.resolve(cwd);
|
|
21
|
+
for (;;) { try { if (fs.existsSync(path.join(d, '.git'))) return d; } catch { /* look further up */ } const up = path.dirname(d); if (up === d) return path.resolve(cwd); d = up; }
|
|
22
|
+
}
|
|
23
|
+
const ROWS = [['Goal it moves', 'goal'], ['Evidence', 'evidence'], ['Cost', 'cost'], ['Risk', 'risk'], ['What waits if it goes first', 'waits']];
|
|
24
|
+
function cardLines(c) {
|
|
25
|
+
const L = [`Which goes first? ${c.a.title} (now above) or ${c.b.title}`];
|
|
26
|
+
if (c.past) L.push(`Last time: ${c.past.reason} (${String(c.past.at).slice(0, 10)})`);
|
|
27
|
+
for (const [label, k] of ROWS) L.push(` ${label}: ${c.a[k]} | ${c.b[k]}`);
|
|
28
|
+
L.push(`✦ ${c.suggest.reason}`);
|
|
29
|
+
return L;
|
|
30
|
+
}
|
|
31
|
+
function run(argv, o = {}) {
|
|
32
|
+
const say = o.say || ((x) => console.log(x)), now = o.now || Date.now();
|
|
33
|
+
const args = argv[0] === 'tradeoff' ? argv.slice(1) : argv.slice();
|
|
34
|
+
const pos = [], flags = {};
|
|
35
|
+
for (let i = 0; i < args.length; i++) { const a = args[i]; if (['--root', '--days', '--first', '--reason', '--margin'].includes(a)) flags[a.slice(2)] = args[++i]; else if (a === '--json') flags.json = true; else pos.push(a); }
|
|
36
|
+
const cmd = pos[0] || 'list';
|
|
37
|
+
if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return 0; }
|
|
38
|
+
if (!COMMANDS.tradeoff.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos tradeoff`); USAGE.forEach((l) => say(l)); return 2; }
|
|
39
|
+
const root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd()));
|
|
40
|
+
const actor = o.actor || require('./actor.js').fromCli({ env: o.env || process.env });
|
|
41
|
+
const fail = (r) => { if (flags.json) say(JSON.stringify({ ok: false, error: r.error })); else say(`✗ ${r.error}`); return r.status === 400 ? 2 : 1; };
|
|
42
|
+
if (cmd === 'count') {
|
|
43
|
+
const days = Math.max(1, Math.min(365, parseInt(flags.days, 10) || 14));
|
|
44
|
+
const n = count(root, { days, now });
|
|
45
|
+
say(`${TAG} ${n} trade-off reason${n === 1 ? '' : 's'} kept in the last ${days} days.`);
|
|
46
|
+
say(String(n));
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
if (cmd === 'list') {
|
|
50
|
+
const margin = Number(flags.margin) > 0 && Number(flags.margin) < 1 ? Number(flags.margin) : MARGIN;
|
|
51
|
+
const r = read(root, { now, margin });
|
|
52
|
+
if (flags.json) { say(JSON.stringify({ ok: true, ...r })); return 0; }
|
|
53
|
+
if (!r.pairs.length && !Object.keys(r.kept).length) { say('No two neighbours on the Roadmap are close, and no reason is kept yet.'); return 0; }
|
|
54
|
+
for (const c of r.pairs) say(`These two are close: ${c.a.title} (${c.a.id}) and ${c.b.title} (${c.b.id}). pmos tradeoff show ${c.a.id} ${c.b.id}`);
|
|
55
|
+
for (const [id, k] of Object.entries(r.kept)) say(`Kept ${id} above ${k.other_title}: ${k.reason} · ${String(k.at).slice(0, 10)} (note ${k.eid})`);
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
if (cmd === 'show') {
|
|
59
|
+
if (pos.length !== 3) { say('usage: pmos tradeoff show <a> <b>'); return 2; }
|
|
60
|
+
const r = cardFor(root, pos[1], pos[2], { now });
|
|
61
|
+
if (!r.ok) return fail(r);
|
|
62
|
+
if (flags.json) { say(JSON.stringify({ ok: true, card: r.card })); return 0; }
|
|
63
|
+
cardLines(r.card).forEach((l) => say(l));
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
66
|
+
if (cmd === 'keep') {
|
|
67
|
+
if (pos.length !== 3 || !flags.first) { say('usage: pmos tradeoff keep <a> <b> --first <id> --reason "<why>"'); return 2; }
|
|
68
|
+
const r = keep(root, { a: pos[1], b: pos[2], first: flags.first, reason: flags.reason }, { actor, now });
|
|
69
|
+
if (!r.ok) return fail(r);
|
|
70
|
+
if (flags.json) { say(JSON.stringify({ ok: true, note: r.note })); return 0; }
|
|
71
|
+
say(`✓ Kept ${r.note.first} above ${r.note.second}${r.note.moved ? ' and moved it up' : ''}: ${r.note.reason}. Undo: pmos tradeoff undo ${r.note.eid}`);
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
if (pos.length !== 2) { say('usage: pmos tradeoff undo <note>'); return 2; }
|
|
75
|
+
const r = undo(root, pos[1], { actor, now });
|
|
76
|
+
if (!r.ok) return fail(r);
|
|
77
|
+
if (flags.json) say(JSON.stringify({ ok: true, of: r.of })); else say(`✓ Took back ${r.of}.`);
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
82
|
+
|
|
83
|
+
if (require.main === module) process.exitCode = run(process.argv.slice(2));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.830.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.830.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -165,6 +165,7 @@ export function sheetHtml(here = new Set()) {
|
|
|
165
165
|
return `<div class="pm-row"><h2 class="pm-h-sm" id="akTitle">Keys</h2>`
|
|
166
166
|
+ `<button type="button" class="pm-btn" data-ak-close aria-label="Close" title="Close">${X}</button></div>`
|
|
167
167
|
+ '<p class="pm-meta">Point at an item, or tab to it, then press its key.</p>'
|
|
168
|
+
+ '<p class="pm-meta">Right-click anything (long-press on a phone) to ask PMOS about it and see what PMOS can do for it.</p>' // surface-ask-card: the Ask card, named
|
|
168
169
|
+ `<ul>${KEYS.map((k) => row(k.key.toUpperCase(), k.say, here.has(k.act))).join('')}${row('F', 'Focus on this item')}${row('?', 'This list')}</ul>`
|
|
169
170
|
+ '<p class="pm-meta"><a href="/premium-viewer.html?open=features" data-ak-features>Every feature, with its command</a></p>'; // F: pm/focus-mode.js (bet A335); the link: feature-directory
|
|
170
171
|
}
|
|
@@ -193,7 +193,8 @@ export function target(c) {
|
|
|
193
193
|
const subject = l === 'field' ? [c.field || c.at, c.value].filter(Boolean).join(': ') : '';
|
|
194
194
|
return {
|
|
195
195
|
id: c.record.id, kind: c.record.kind.replace(/\s+/g, '-'), title: c.record.title || c.record.id, subject,
|
|
196
|
-
say: 'The PM pressed ' + (l === 'field' ? (c.field || c.at || 'part') + ' of ' : '') + 'the ' + c.record.kind + ' "' + (c.record.title || c.record.id) + '" on ' + (c.page || 'this page') + '. Read that record with pmos before you answer.'
|
|
196
|
+
say: 'The PM pressed ' + (l === 'field' ? (c.field || c.at || 'part') + ' of ' : '') + 'the ' + c.record.kind + ' "' + (c.record.title || c.record.id) + '" on ' + (c.page || 'this page') + '. Read that record with pmos before you answer.'
|
|
197
|
+
+ (c.record.kind === 'person' ? ' For a 1:1, run `pmos people prep "' + (c.record.title || c.record.id) + '"` and answer from its lines, with their sources.' : ''),
|
|
197
198
|
facts: facts.filter((f) => clean(f[1])),
|
|
198
199
|
};
|
|
199
200
|
}
|
|
@@ -216,6 +217,8 @@ const Q = {
|
|
|
216
217
|
'ticket': { '': ['Is it in step with PMOS?', 'Where does it stand?', 'Who is on it?'] },
|
|
217
218
|
'meeting': { '': ['What should I settle in it?', 'What is owed to me?', 'Draft the agenda'] },
|
|
218
219
|
'event': { '': ['What should I settle in it?', 'What is owed to me?', 'Draft the agenda'] },
|
|
220
|
+
// a person (people-prep, A85): the 1:1 brief first, so it shows with nothing typed (LINE.md Rule 12); target() names its command
|
|
221
|
+
'person': { '': ['Prepare my 1:1 with them', 'What are they carrying?', 'Where are they stuck?'] },
|
|
219
222
|
};
|
|
220
223
|
const SECTION_Q = ['What needs me here?', 'What changed here this week?', 'Explain this part'];
|
|
221
224
|
/** The field kind a column or label is: due, owner, status, stage, milestone, or '' */
|
|
@@ -238,6 +241,27 @@ export function questionsOf(c) {
|
|
|
238
241
|
const fk = l === 'field' ? (c.at ? 'place' : fieldKind(c.field)) : '';
|
|
239
242
|
return (k[fk] || k['']).slice(0, 3);
|
|
240
243
|
}
|
|
244
|
+
/* ── what PMOS can do for the pressed record (initiative surface-ask-card, board SfA): the user features whose row in lib/features.json
|
|
245
|
+
* names the record's kind in `ask`. A press asks the feature's command about this record in the card's chat; nothing runs before it. ── */
|
|
246
|
+
export const MAX_ACTIONS = 4;
|
|
247
|
+
/** The card's "What PMOS can do" line: [{ id, name, prompt }], at most MAX_ACTIONS, registry order; [] at section or page level, or when no
|
|
248
|
+
* feature names the kind (zero is silence). features: GET /api/features' rows. A command with a hint takes the record's id after it. */
|
|
249
|
+
export function actionsOf(c, features) {
|
|
250
|
+
const l = level(c);
|
|
251
|
+
if (!c || l === 'page' || l === 'section' || !c.record || !c.record.kind) return [];
|
|
252
|
+
const kind = c.record.kind === 'subtask' ? 'task' : c.record.kind;
|
|
253
|
+
return (Array.isArray(features) ? features : [])
|
|
254
|
+
.filter((f) => f && f.audience === 'user' && f.cmd && Array.isArray(f.ask) && f.ask.includes(kind))
|
|
255
|
+
.slice(0, MAX_ACTIONS)
|
|
256
|
+
.map((f) => ({ id: f.id, name: f.name, prompt: f.hint ? f.cmd + ' ' + c.record.id : f.cmd }));
|
|
257
|
+
}
|
|
258
|
+
const escH = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (ch) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[ch]);
|
|
259
|
+
const BOLT = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M13 3L5 14h6l-1 7 8-11h-6z"/></svg>';
|
|
260
|
+
/** The line's markup: one button per action, its name beside a bolt; '' when there is none. Pure, so the test reads it. */
|
|
261
|
+
export function actionsHtml(actions) {
|
|
262
|
+
if (!Array.isArray(actions) || !actions.length) return '';
|
|
263
|
+
return `<div class="ah-do" role="group" aria-label="What PMOS can do">${actions.map((a) => `<button type="button" data-ah-do="${escH(a.prompt)}" data-ah-feature="${escH(a.id)}" title="${escH(a.prompt)}">${BOLT}${escH(a.name)}</button>`).join('')}</div>`;
|
|
264
|
+
}
|
|
241
265
|
const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
242
266
|
const iso = (d) => d.toISOString().slice(0, 10);
|
|
243
267
|
const label = (d) => `${DOW[d.getUTCDay()]} ${d.getUTCDate()} ${MON[d.getUTCMonth()]}`;
|
|
@@ -34,3 +34,10 @@
|
|
|
34
34
|
.ah-card.sheet .ah-grab { display: block; }
|
|
35
35
|
@media (prefers-reduced-motion: no-preference) { .ah-card { animation: ah-in 160ms cubic-bezier(.2,.7,.2,1); } }
|
|
36
36
|
@keyframes ah-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
|
|
37
|
+
/* what PMOS can do for the pressed record (surface-ask-card): the same rows as the ✦ questions, a bolt for an action */
|
|
38
|
+
.ah-do { display: flex; flex-direction: column; gap: 2px; }
|
|
39
|
+
.ah-do button { all: unset; display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--cz-ink); font-size: var(--fs-body); }
|
|
40
|
+
.ah-do button:focus-visible { outline: 2px solid var(--cz-blue); }
|
|
41
|
+
.ah-do svg { color: var(--cz-blue); flex: none; }
|
|
42
|
+
@media (hover: hover) { .ah-do button:hover { background: var(--cz-well); } }
|
|
43
|
+
.ah-card.sheet .ah-do button { min-height: 44px; }
|