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.
Files changed (61) hide show
  1. package/package.json +124 -47
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +123 -2
  7. package/workspace/guide/cli.md +29 -0
  8. package/workspace/guide/home.md +1 -0
  9. package/workspace/guide/initiatives-and-next-steps.md +8 -0
  10. package/workspace/guide/layout.md +5 -1
  11. package/workspace/lib/built-vs-design-http.js +81 -0
  12. package/workspace/lib/built-vs-design.js +454 -0
  13. package/workspace/lib/deps-cli.js +47 -2
  14. package/workspace/lib/features.json +2 -0
  15. package/workspace/lib/hire-draft.js +4 -3
  16. package/workspace/lib/initiative-rows.js +3 -0
  17. package/workspace/lib/meeting-stance.js +199 -0
  18. package/workspace/lib/needs-providers.js +1 -0
  19. package/workspace/lib/people-cli.js +44 -1
  20. package/workspace/lib/pmos-verbs.js +7 -1
  21. package/workspace/lib/prefs-sync.js +1 -0
  22. package/workspace/lib/review-cli.js +6 -0
  23. package/workspace/lib/route-modules.js +3 -0
  24. package/workspace/lib/routes-meeting-stance.js +43 -0
  25. package/workspace/lib/routes-pop-work.js +4 -1
  26. package/workspace/lib/routes-segments.js +47 -0
  27. package/workspace/lib/routes-surface-moments.js +36 -0
  28. package/workspace/lib/routes-team-waits.js +39 -2
  29. package/workspace/lib/segments-cli.js +102 -0
  30. package/workspace/lib/segments.js +214 -0
  31. package/workspace/lib/surface-moments.js +185 -0
  32. package/workspace/lib/team-slips.js +160 -0
  33. package/workspace/package-lock.json +2 -2
  34. package/workspace/package.json +1 -1
  35. package/workspace/public/pm/ask-here-ctx.js +20 -2
  36. package/workspace/public/pm/ask-here.css +6 -1
  37. package/workspace/public/pm/ask-here.js +38 -25
  38. package/workspace/public/pm/bd-backlog.js +34 -5
  39. package/workspace/public/pm/built-vs-design.css +16 -0
  40. package/workspace/public/pm/built-vs-design.js +95 -0
  41. package/workspace/public/pm/cozy-board.css +11 -0
  42. package/workspace/public/pm/cozy-events-view.js +1 -1
  43. package/workspace/public/pm/cozy-home.css +10 -0
  44. package/workspace/public/pm/cozy-pop-work.js +11 -6
  45. package/workspace/public/pm/cozy-today-app.js +42 -1
  46. package/workspace/public/pm/cozy-today-model.js +70 -3
  47. package/workspace/public/pm/cozy-today-view.js +10 -1
  48. package/workspace/public/pm/goals-ds.js +3 -2
  49. package/workspace/public/pm/home-chat.js +19 -3
  50. package/workspace/public/pm/ini-tasks.js +2 -2
  51. package/workspace/public/pm/meeting-stance.js +113 -0
  52. package/workspace/public/pm/page-chat.js +2 -1
  53. package/workspace/public/pm/premium-board.js +2 -0
  54. package/workspace/public/pm/segments.js +113 -0
  55. package/workspace/public/pm/team-slips.js +48 -0
  56. package/workspace/public/premium-board.html +2 -0
  57. package/workspace/test-lists/built-vs-design.json +9 -0
  58. package/workspace/test-lists/meeting-stance.json +9 -0
  59. package/workspace/test-lists/segments.json +9 -0
  60. package/workspace/test-lists/surface-moments.json +9 -0
  61. package/workspace/test-lists/team-slips.json +9 -0
@@ -0,0 +1,454 @@
1
+ 'use strict';
2
+ /* built-vs-design.js — the built screen beside the design it came from (initiative built-vs-design, factory job #1903, idea A380; agreed board
3
+ * BatchDesignDS panel 17, Wawan 2026-11-25). `pmos review …`, the work popup's Review block (pm/built-vs-design.js) and
4
+ * lib/built-vs-design-http.js (answered through lib/routes-pop-work.js) read and write this one store.
5
+ *
6
+ * THE COMPARISON IS PIXEL WORK, NOT A MODEL. Two PNG files (any product's: a design export, a screenshot a build committed) are read by the
7
+ * small PNG reader below (zlib only, no dependency), laid on one grid of the built screen's cells (the design scaled to the built width, so a
8
+ * design made at 2x compares cell for cell), and a cell whose mean colour differs by more than THRESHOLD is marked. Marked cells that touch
9
+ * (or nearly touch) form one region; each region is one numbered circle, top to bottom, left to right. Matching parts get no mark. A region's
10
+ * first words say where it is and how big ("differs near the top right, 200 × 60 px"); the agent or the chat can name it better with
11
+ * `pmos review note` ("button 8px lower").
12
+ *
13
+ * THE STORE. <state folder>/built-vs-design.jsonl, append-only, in the product's own state folder (lib/driver.js stateDirOf, the folder the
14
+ * server's stateDirFor gives the same product), and the copied shots in <state folder>/built-vs-design/<pair>/design.png and built.png, so a
15
+ * review keeps showing what was compared after the files move on. Lines:
16
+ * { kind: 'pair', id, ini, screen, at, by, src, w, h, diffs: [{ n, x, y, w, h, words }] } x, y, w, h: fractions of the built screen
17
+ * { kind: 'note', pair, n, words, at, by } · { kind: 'fix', pair, n, task, at, by } · { kind: 'unfix', pair, n, at, by }
18
+ * { kind: 'accept', pair, at, by } · { kind: 'reopen', pair, at, by }
19
+ * A newer pair of the same initiative and screen replaces the older one. An accepted pair is closed: the Review block no longer draws it.
20
+ *
21
+ * readPng(buf) PURE → { w, h, data: RGBA } | throws · writePng(w, h, rgba) PURE → Buffer (tests and fixtures)
22
+ * diffOf(design, built, o?) PURE → { cell, regions: [{ n, x, y, w, h, px: { x, y, w, h }, words }], more }
23
+ * wordsOf(px, W, H) PURE → string
24
+ * fold(lines) PURE → [pair + { open, accepted, fixes: { n: task }, notes }]
25
+ * compare(stateDir, { ini, screen?, design, built, by? }, now?) → { ok, pair } | { ok: false, error } (src: a hash of the two files)
26
+ * discover(root, ini) → [{ screen, design, built }]: <root>/screens/<ini>/<screen>.design.png beside <screen>.built.png
27
+ * auto(stateDir, root, ini, now?) → { ran, errors }: PMOS COMPARES BY ITSELF (LINE.md Rule 12, no chat-only features). Each discovered
28
+ * screen whose files changed since its last review is compared; the Work popup's read runs it, so the Review block shows with no ask.
29
+ * list(stateDir, ini?, { all? }) → [pair] · find(stateDir, ini, screen?) → pair | null · shotFile(stateDir, pairId, which) → path | null
30
+ * note(stateDir, ini, n, words, o) · accept(stateDir, ini, o) · reopen(...) · fix(stateDir, ini, n, { add, by, screen? }) · unfix(...)
31
+ * count(stateDir, { days, now }) → reviews decided (accept or fix) in the last days
32
+ * run(argv, o) — `pmos review` (COMMANDS, USAGE; lib/review-cli.js is the verb module)
33
+ * Every write logs one `[built-vs-design]` line (the health number's tag). Nothing is sent anywhere. */
34
+ const fs = require('fs');
35
+ const path = require('path');
36
+ const zlib = require('zlib');
37
+ const crypto = require('crypto');
38
+
39
+ const TAG = '[built-vs-design]';
40
+ const FILE = 'built-vs-design.jsonl';
41
+ const DIR = 'built-vs-design';
42
+ const THRESHOLD = 24; // mean colour difference of a cell (0-255) that counts as changed
43
+ const MAX_CIRCLES = 9; // circles drawn; more are counted, not drawn
44
+ const GRID = 96; // cells across the built screen (a cell is at least 4 px)
45
+ const ID_RE = /^[a-z0-9][a-z0-9-]{0,79}$/;
46
+ const SCREEN_RE = /^[a-z0-9][a-z0-9-]{0,59}$/;
47
+ const PAIR_RE = /^[a-f0-9]{12}$/;
48
+ const SIG = Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]);
49
+ const log = (...a) => { try { console.error(TAG, ...a); } catch { /* a log line is never a reason to fail */ } };
50
+
51
+ /* ── the PNG reader: 8-bit grey, RGB, palette, grey + alpha and RGBA; not interlaced ── */
52
+ function readPng(buf) {
53
+ if (!Buffer.isBuffer(buf) || buf.length < 33 || !buf.subarray(0, 8).equals(SIG)) throw new Error('it is not a PNG file');
54
+ let off = 8, w = 0, h = 0, depth = 0, type = -1, inter = 0, pal = null, trns = null;
55
+ const idat = [];
56
+ while (off + 8 <= buf.length) {
57
+ const len = buf.readUInt32BE(off), kind = buf.toString('latin1', off + 4, off + 8), d = buf.subarray(off + 8, off + 8 + len);
58
+ if (d.length !== len) throw new Error('the PNG file is cut short');
59
+ if (kind === 'IHDR') { w = d.readUInt32BE(0); h = d.readUInt32BE(4); depth = d[8]; type = d[9]; inter = d[12]; }
60
+ else if (kind === 'PLTE') pal = d;
61
+ else if (kind === 'tRNS') trns = d;
62
+ else if (kind === 'IDAT') idat.push(d);
63
+ else if (kind === 'IEND') break;
64
+ off += 12 + len;
65
+ }
66
+ if (!w || !h) throw new Error('the PNG file has no size');
67
+ if (w * h > 40e6) throw new Error('the PNG file is too big to compare');
68
+ if (depth !== 8) throw new Error(`a ${depth}-bit PNG is not read; save it as 8-bit`);
69
+ if (inter) throw new Error('an interlaced PNG is not read; save it without interlacing');
70
+ const CH = { 0: 1, 2: 3, 3: 1, 4: 2, 6: 4 }[type];
71
+ if (!CH) throw new Error('the PNG colour type is not read');
72
+ if (type === 3 && !pal) throw new Error('the PNG palette is missing');
73
+ let raw;
74
+ try { raw = zlib.inflateSync(Buffer.concat(idat)); } catch { throw new Error('the PNG data cannot be read'); }
75
+ const stride = w * CH;
76
+ if (raw.length < (stride + 1) * h) throw new Error('the PNG data is cut short');
77
+ const px = Buffer.alloc(stride * h);
78
+ for (let y = 0; y < h; y++) {
79
+ const f = raw[y * (stride + 1)], src = raw.subarray(y * (stride + 1) + 1, (y + 1) * (stride + 1)), o = y * stride;
80
+ for (let i = 0; i < stride; i++) {
81
+ const a = i >= CH ? px[o + i - CH] : 0, b = y ? px[o - stride + i] : 0, c = y && i >= CH ? px[o - stride + i - CH] : 0;
82
+ let v = src[i];
83
+ if (f === 1) v += a;
84
+ else if (f === 2) v += b;
85
+ else if (f === 3) v += (a + b) >> 1;
86
+ else if (f === 4) { const p = a + b - c, pa = Math.abs(p - a), pb = Math.abs(p - b), pc = Math.abs(p - c); v += pa <= pb && pa <= pc ? a : pb <= pc ? b : c; }
87
+ else if (f !== 0) throw new Error('the PNG data has an unknown filter');
88
+ px[o + i] = v & 255;
89
+ }
90
+ }
91
+ const data = Buffer.alloc(w * h * 4);
92
+ for (let i = 0, j = 0; i < w * h; i++, j += 4) {
93
+ const s = i * CH;
94
+ if (type === 6) { data[j] = px[s]; data[j + 1] = px[s + 1]; data[j + 2] = px[s + 2]; data[j + 3] = px[s + 3]; }
95
+ else if (type === 2) { data[j] = px[s]; data[j + 1] = px[s + 1]; data[j + 2] = px[s + 2]; data[j + 3] = 255; }
96
+ else if (type === 0) { data[j] = data[j + 1] = data[j + 2] = px[s]; data[j + 3] = 255; }
97
+ else if (type === 4) { data[j] = data[j + 1] = data[j + 2] = px[s]; data[j + 3] = px[s + 1]; }
98
+ else { const k = px[s]; data[j] = pal[k * 3] || 0; data[j + 1] = pal[k * 3 + 1] || 0; data[j + 2] = pal[k * 3 + 2] || 0; data[j + 3] = trns && k < trns.length ? trns[k] : 255; }
99
+ }
100
+ return { w, h, data };
101
+ }
102
+
103
+ const CRC = (() => { const t = new Int32Array(256); for (let n = 0; n < 256; n++) { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; t[n] = c; } return t; })();
104
+ function crc(b) { let c = -1; for (let i = 0; i < b.length; i++) c = CRC[(c ^ b[i]) & 255] ^ (c >>> 8); return (c ^ -1) >>> 0; }
105
+ function chunk(kind, d) { const l = Buffer.alloc(4); l.writeUInt32BE(d.length); const kd = Buffer.concat([Buffer.from(kind, 'latin1'), d]); const c = Buffer.alloc(4); c.writeUInt32BE(crc(kd)); return Buffer.concat([l, kd, c]); }
106
+ /** An 8-bit RGBA PNG of w × h pixels (filter 0 on every row). */
107
+ function writePng(w, h, rgba) {
108
+ const hd = Buffer.alloc(13); hd.writeUInt32BE(w, 0); hd.writeUInt32BE(h, 4); hd[8] = 8; hd[9] = 6;
109
+ const raw = Buffer.alloc((w * 4 + 1) * h);
110
+ for (let y = 0; y < h; y++) Buffer.from(rgba.buffer, rgba.byteOffset + y * w * 4, w * 4).copy(raw, y * (w * 4 + 1) + 1);
111
+ return Buffer.concat([SIG, chunk('IHDR', hd), chunk('IDAT', zlib.deflateSync(raw)), chunk('IEND', Buffer.alloc(0))]);
112
+ }
113
+
114
+ /* ── the comparison ── */
115
+ /** The mean RGB of the rectangle [x0, x1) × [y0, y1) of an image, alpha laid over white; null when the rectangle is outside it. */
116
+ function meanOf(img, x0, y0, x1, y1) {
117
+ x0 = Math.max(0, Math.floor(x0)); y0 = Math.max(0, Math.floor(y0)); x1 = Math.min(img.w, Math.ceil(x1)); y1 = Math.min(img.h, Math.ceil(y1));
118
+ if (x1 <= x0 || y1 <= y0) return null;
119
+ let r = 0, g = 0, b = 0, n = 0;
120
+ const step = Math.max(1, Math.floor(Math.min(x1 - x0, y1 - y0) / 6));
121
+ for (let y = y0; y < y1; y += step) for (let x = x0; x < x1; x += step) {
122
+ const i = (y * img.w + x) * 4, a = img.data[i + 3] / 255;
123
+ r += img.data[i] * a + 255 * (1 - a); g += img.data[i + 1] * a + 255 * (1 - a); b += img.data[i + 2] * a + 255 * (1 - a); n++;
124
+ }
125
+ return [r / n, g / n, b / n];
126
+ }
127
+ const SIDE = (f) => (f < 1 / 3 ? 0 : f < 2 / 3 ? 1 : 2);
128
+ /** Where a region is and how big, in plain words. */
129
+ function wordsOf(px, W, H) {
130
+ const cx = (px.x + px.w / 2) / W, cy = (px.y + px.h / 2) / H;
131
+ const v = ['top', 'middle', 'bottom'][SIDE(cy)], hz = ['left', 'centre', 'right'][SIDE(cx)];
132
+ const at = v === 'middle' && hz === 'centre' ? 'the middle' : v === 'middle' ? `the ${hz}` : hz === 'centre' ? `the ${v}` : `the ${v} ${hz}`;
133
+ return `Differs near ${at}, ${Math.round(px.w)} × ${Math.round(px.h)} px`;
134
+ }
135
+ /** A part that moved leaves two marks: where it was and where it is. Two boxes that line up (their spans across overlap by 70 % of the
136
+ * smaller) and lie close (a gap of at most MOVE_GAP px, or twice the smaller box) are one difference. */
137
+ const MOVE_GAP = 48;
138
+ function mergeMoved(B) {
139
+ const ov = (a0, a1, b0, b1) => Math.max(0, Math.min(a1, b1) - Math.max(a0, b0));
140
+ const near = (a, b) => {
141
+ const xo = ov(a.x, a.x + a.w, b.x, b.x + b.w) / Math.min(a.w, b.w), yo = ov(a.y, a.y + a.h, b.y, b.y + b.h) / Math.min(a.h, b.h);
142
+ const gy = Math.max(a.y, b.y) - Math.min(a.y + a.h, b.y + b.h), gx = Math.max(a.x, b.x) - Math.min(a.x + a.w, b.x + b.w);
143
+ return (xo >= 0.7 && gy <= Math.max(MOVE_GAP, 2 * Math.min(a.h, b.h))) || (yo >= 0.7 && gx <= Math.max(MOVE_GAP, 2 * Math.min(a.w, b.w)));
144
+ };
145
+ const L = B.slice();
146
+ for (let again = true; again;) {
147
+ again = false;
148
+ for (let i = 0; i < L.length && !again; i++) for (let j = i + 1; j < L.length && !again; j++) {
149
+ if (!near(L[i], L[j])) continue;
150
+ const a = L[i], b = L[j], x = Math.min(a.x, b.x), y = Math.min(a.y, b.y);
151
+ L[i] = { x, y, w: Math.max(a.x + a.w, b.x + b.w) - x, h: Math.max(a.y + a.h, b.y + b.h) - y };
152
+ L.splice(j, 1); again = true;
153
+ }
154
+ }
155
+ return L;
156
+ }
157
+ /** The differences of the built screen from its design: numbered regions on the built screen, matching parts unmarked. */
158
+ function diffOf(design, built, o = {}) {
159
+ const W = built.w, H = built.h;
160
+ const cell = Math.max(4, Math.round(W / (o.grid || GRID)));
161
+ const k = design.w / W; // design pixels per built pixel: a design made at 2x compares cell for cell
162
+ const cols = Math.ceil(W / cell), rows = Math.ceil(Math.max(H, design.h / k) / cell);
163
+ const thr = o.threshold || THRESHOLD;
164
+ const mark = new Uint8Array(cols * rows);
165
+ for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) {
166
+ const x0 = c * cell, y0 = r * cell, x1 = x0 + cell, y1 = y0 + cell;
167
+ const a = meanOf(built, x0, y0, x1, y1), b = meanOf(design, x0 * k, y0 * k, x1 * k, y1 * k);
168
+ if (!a && !b) continue;
169
+ // one screen is longer than the other: the part only one has differs unless it is blank (white)
170
+ const d = a && b ? Math.max(Math.abs(a[0] - b[0]), Math.abs(a[1] - b[1]), Math.abs(a[2] - b[2]))
171
+ : 255 - Math.min(...(a || b));
172
+ if (d > thr) mark[r * cols + c] = 1;
173
+ }
174
+ // regions: marked cells that touch, or lie one cell apart, are one region (8 neighbours, reach 2)
175
+ const seen = new Uint8Array(cols * rows), boxes = [];
176
+ for (let i = 0; i < mark.length; i++) {
177
+ if (!mark[i] || seen[i]) continue;
178
+ const q = [i]; seen[i] = 1;
179
+ let c0 = cols, r0 = rows, c1 = -1, r1 = -1, n = 0;
180
+ while (q.length) {
181
+ const j = q.pop(), r = Math.floor(j / cols), c = j % cols; n++;
182
+ c0 = Math.min(c0, c); c1 = Math.max(c1, c); r0 = Math.min(r0, r); r1 = Math.max(r1, r);
183
+ for (let dr = -2; dr <= 2; dr++) for (let dc = -2; dc <= 2; dc++) {
184
+ const rr = r + dr, cc = c + dc, jj = rr * cols + cc;
185
+ if (rr < 0 || cc < 0 || rr >= rows || cc >= cols || seen[jj] || !mark[jj]) continue;
186
+ seen[jj] = 1; q.push(jj);
187
+ }
188
+ }
189
+ boxes.push({ c0, r0, c1, r1, n });
190
+ }
191
+ const Hs = rows * cell;
192
+ const regions = mergeMoved(boxes
193
+ .map((b) => { const x = b.c0 * cell, y = b.r0 * cell, w = Math.min(W, (b.c1 + 1) * cell) - x, h = Math.min(Hs, (b.r1 + 1) * cell) - y; return { x, y, w, h }; }))
194
+ .map((px) => ({ px }))
195
+ .sort((a, b) => a.px.y - b.px.y || a.px.x - b.px.x);
196
+ const shown = regions.slice(0, MAX_CIRCLES).map((r, i) => ({
197
+ n: i + 1, x: r.px.x / W, y: r.px.y / Math.max(H, 1), w: r.px.w / W, h: r.px.h / Math.max(H, 1), px: r.px, words: wordsOf(r.px, W, H),
198
+ }));
199
+ return { cell, regions: shown, more: Math.max(0, regions.length - MAX_CIRCLES) };
200
+ }
201
+
202
+ /* ── the store ── */
203
+ const fileOf = (dir) => path.join(dir, FILE);
204
+ function readLines(dir) {
205
+ try { return fs.readFileSync(fileOf(dir), 'utf8').split('\n').filter(Boolean).map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter(Boolean); } catch { return []; }
206
+ }
207
+ function append(dir, line) { fs.mkdirSync(dir, { recursive: true }); fs.appendFileSync(fileOf(dir), JSON.stringify(line) + '\n'); }
208
+ /** Every pair with its state; the newest pair of an initiative's screen is the live one (older ones are closed). */
209
+ function fold(lines) {
210
+ const pairs = new Map(), live = new Map();
211
+ for (const l of lines) {
212
+ if (l.kind === 'pair' && PAIR_RE.test(l.id || '')) { pairs.set(l.id, { ...l, accepted: false, fixes: {}, notes: {} }); live.set(l.ini + '|' + l.screen, l.id); continue; }
213
+ const p = pairs.get(l.pair); if (!p) continue;
214
+ if (l.kind === 'accept') { p.accepted = true; p.decidedAt = l.at; }
215
+ else if (l.kind === 'reopen') p.accepted = false;
216
+ else if (l.kind === 'note' && l.words) p.notes[l.n] = String(l.words);
217
+ else if (l.kind === 'fix' && l.task) p.fixes[l.n] = String(l.task);
218
+ else if (l.kind === 'unfix') delete p.fixes[l.n];
219
+ }
220
+ return [...pairs.values()].map((p) => {
221
+ const newest = live.get(p.ini + '|' + p.screen) === p.id;
222
+ return { ...p, newest, open: newest && !p.accepted, diffs: (p.diffs || []).map((d) => ({ ...d, words: p.notes[d.n] || d.words, task: p.fixes[d.n] || '' })) };
223
+ });
224
+ }
225
+ function list(dir, ini, { all = false } = {}) { return fold(readLines(dir)).filter((p) => (!ini || p.ini === ini) && (all ? p.newest : p.open)); }
226
+ function find(dir, ini, screen) {
227
+ const L = fold(readLines(dir)).filter((p) => p.ini === ini && p.newest && (!screen || p.screen === screen));
228
+ return L.length ? L.sort((a, b) => String(b.at).localeCompare(String(a.at)))[0] : null;
229
+ }
230
+ function shotFile(dir, pairId, which) {
231
+ if (!PAIR_RE.test(String(pairId || '')) || !['design', 'built'].includes(which)) return null;
232
+ const f = path.join(dir, DIR, pairId, which + '.png');
233
+ return fs.existsSync(f) ? f : null;
234
+ }
235
+ function slug(s) { return String(s || '').toLowerCase().replace(/\.[a-z0-9]+$/, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 60) || 'screen'; }
236
+
237
+ /** Compare two PNG files and keep the review. Nothing is stored when either file cannot be read. */
238
+ function compare(dir, { ini, screen, design, built, by = 'agent' } = {}, now = Date.now()) {
239
+ if (!ID_RE.test(String(ini || ''))) return { ok: false, error: 'name the initiative by its id (lowercase, for example checkout-redesign)' };
240
+ if (!dir) return { ok: false, error: 'this product has no PMOS state folder' };
241
+ const read = (f, what) => {
242
+ if (!f) return { error: `--${what} <file.png> is missing` };
243
+ if (!/\.png$/i.test(f)) return { error: `the ${what} file must be a PNG (${path.basename(f)})` };
244
+ let buf; try { buf = fs.readFileSync(f); } catch { return { error: `the ${what} file cannot be read: ${f}` }; }
245
+ try { return { buf, img: readPng(buf) }; } catch (e) { return { error: `the ${what} file: ${e.message}` }; }
246
+ };
247
+ const D = read(design, 'design'); if (D.error) return { ok: false, error: D.error };
248
+ const B = read(built, 'built'); if (B.error) return { ok: false, error: B.error };
249
+ const sc = screen ? slug(screen) : slug(path.basename(built));
250
+ if (!SCREEN_RE.test(sc)) return { ok: false, error: 'the screen name is not usable' };
251
+ const at = new Date(now).toISOString();
252
+ const id = crypto.createHash('sha1').update(ini + '|' + sc + '|' + at + '|' + crypto.randomBytes(4).toString('hex')).digest('hex').slice(0, 12);
253
+ const R = diffOf(D.img, B.img);
254
+ const pd = path.join(dir, DIR, id);
255
+ fs.mkdirSync(pd, { recursive: true });
256
+ fs.writeFileSync(path.join(pd, 'design.png'), D.buf);
257
+ fs.writeFileSync(path.join(pd, 'built.png'), B.buf);
258
+ const src = crypto.createHash('sha1').update(D.buf).update(B.buf).digest('hex').slice(0, 16);
259
+ const line = { kind: 'pair', id, ini, screen: sc, at, by, src, w: B.img.w, h: B.img.h, dw: D.img.w, dh: D.img.h,
260
+ diffs: R.regions.map((r) => ({ n: r.n, x: +r.x.toFixed(4), y: +r.y.toFixed(4), w: +r.w.toFixed(4), h: +r.h.toFixed(4), words: r.words })), more: R.more };
261
+ append(dir, line);
262
+ log('compare', ini, sc, R.regions.length);
263
+ return { ok: true, pair: fold(readLines(dir)).find((p) => p.id === id) };
264
+ }
265
+ /** The screens an initiative keeps in its product repository: <root>/screens/<ini>/<screen>.design.png beside <screen>.built.png.
266
+ * A builder or a release drops the built screenshot there; the design export drops the design. PURE over the folder. */
267
+ const SHOTS_DIR = 'screens';
268
+ function discover(root, ini) {
269
+ if (!root || !ID_RE.test(String(ini || ''))) return [];
270
+ const d = path.join(root, SHOTS_DIR, ini);
271
+ let names; try { names = fs.readdirSync(d); } catch { return []; }
272
+ const out = [];
273
+ for (const n of names) {
274
+ const m = /^(.+)\.design\.png$/i.exec(n); if (!m) continue;
275
+ const b = names.find((x) => x.toLowerCase() === (m[1] + '.built.png').toLowerCase()); if (!b) continue;
276
+ const screen = slug(m[1]); if (!SCREEN_RE.test(screen)) continue;
277
+ out.push({ screen, design: path.join(d, n), built: path.join(d, b) });
278
+ }
279
+ return out.sort((a, b) => a.screen.localeCompare(b.screen));
280
+ }
281
+ /** PMOS compares by itself: each screen found by discover() whose two files changed since its last review (or that has none) is
282
+ * compared now. Nothing runs when the files are the same, so an accepted review stays accepted until a new screenshot lands.
283
+ * → { ran: [screen], errors: [{ screen, error }] } */
284
+ function auto(dir, root, ini, now = Date.now()) {
285
+ const ran = [], errors = [];
286
+ if (!dir) return { ran, errors };
287
+ const found = discover(root, ini); if (!found.length) return { ran, errors };
288
+ const have = fold(readLines(dir)).filter((p) => p.ini === ini && p.newest);
289
+ for (const f of found) {
290
+ let src; try { src = crypto.createHash('sha1').update(fs.readFileSync(f.design)).update(fs.readFileSync(f.built)).digest('hex').slice(0, 16); } catch { continue; }
291
+ const last = have.find((p) => p.screen === f.screen);
292
+ if (last && last.src === src) continue;
293
+ const r = compare(dir, { ini, screen: f.screen, design: f.design, built: f.built, by: 'pmos' }, now);
294
+ if (r.ok) ran.push(f.screen); else errors.push({ screen: f.screen, error: r.error });
295
+ }
296
+ return { ran, errors };
297
+ }
298
+ function pairFor(dir, ini, screen, { closed = false } = {}) {
299
+ const p = find(dir, ini, screen);
300
+ if (!p) return { error: `${ini} has no built screen compared${screen ? ' named ' + screen : ''}; pmos review shots compares one` };
301
+ if (!closed && p.accepted) return { error: `the review of ${p.screen} is already accepted; pmos review accept ${ini} --undo opens it again` };
302
+ return { p };
303
+ }
304
+ const diffN = (p, n) => (p.diffs || []).find((d) => d.n === Number(n));
305
+ function note(dir, ini, n, words, { by = 'agent', screen, now = Date.now() } = {}) {
306
+ const w = String(words || '').replace(/\s+/g, ' ').trim().slice(0, 120);
307
+ if (!w) return { ok: false, error: 'give the words for the difference' };
308
+ const { p, error } = pairFor(dir, ini, screen); if (error) return { ok: false, error };
309
+ if (!diffN(p, n)) return { ok: false, error: `${p.screen} has no difference ${n}` };
310
+ append(dir, { kind: 'note', pair: p.id, n: Number(n), words: w, at: new Date(now).toISOString(), by });
311
+ log('note', ini, n);
312
+ return { ok: true, pair: p.id, n: Number(n), words: w };
313
+ }
314
+ function accept(dir, ini, { by = 'agent', screen, pair, undo = false, now = Date.now() } = {}) {
315
+ const p = pair ? fold(readLines(dir)).find((x) => x.id === pair && x.ini === ini) : find(dir, ini, screen);
316
+ if (!p) return { ok: false, error: `${ini} has no built screen compared` };
317
+ if (undo ? !p.accepted : p.accepted) return { ok: false, error: undo ? `the review of ${p.screen} is open` : `the review of ${p.screen} is already accepted` };
318
+ append(dir, { kind: undo ? 'reopen' : 'accept', pair: p.id, at: new Date(now).toISOString(), by });
319
+ log(undo ? 'reopen' : 'accept', ini, p.screen);
320
+ return { ok: true, pair: p.id, screen: p.screen };
321
+ }
322
+ /** Send circle n back as a fix: add(title, notes) adds the task to the initiative (the page's own Add a task) and gives { ok, task } or
323
+ * { ok: false, error }; the circle records the task. undo: the task is taken away by remove(task) and the circle is open again. */
324
+ async function fix(dir, ini, n, { add, remove, by = 'agent', screen, pair, undo = false, now = Date.now() } = {}) {
325
+ const p = pair ? fold(readLines(dir)).find((x) => x.id === pair && x.ini === ini && x.open) : pairFor(dir, ini, screen).p;
326
+ if (!p) return { ok: false, error: `${ini} has no open review${screen ? ' of ' + screen : ''}` };
327
+ const d = diffN(p, n); if (!d) return { ok: false, error: `${p.screen} has no difference ${n}` };
328
+ const at = new Date(now).toISOString();
329
+ if (undo) {
330
+ if (!d.task) return { ok: false, error: `difference ${n} was not sent back` };
331
+ if (remove) { const r = await remove(d.task); if (!r || r.ok === false) return { ok: false, error: (r && r.error) || 'the fix task was not taken away' }; }
332
+ append(dir, { kind: 'unfix', pair: p.id, n: d.n, at, by });
333
+ log('unfix', ini, n);
334
+ return { ok: true, pair: p.id, n: d.n, task: d.task };
335
+ }
336
+ if (d.task) return { ok: false, error: `difference ${n} is already the task ${d.task}` };
337
+ if (typeof add !== 'function') return { ok: false, error: 'no way to add the task here' };
338
+ const title = 'Fix: ' + d.words.replace(/^Differs/, 'differs');
339
+ const r = await add(title.slice(0, 200), `Built screen ${p.screen} beside its design: difference ${d.n}.`);
340
+ if (!r || r.ok === false || !r.task) return { ok: false, error: (r && r.error) || 'the task was not added' };
341
+ append(dir, { kind: 'fix', pair: p.id, n: d.n, task: r.task, at, by });
342
+ log('fix', ini, n);
343
+ return { ok: true, pair: p.id, n: d.n, task: r.task, title };
344
+ }
345
+ /** Reviews decided (an accept, or a circle sent back) in the last `days` days. */
346
+ function count(dir, { days = 7, now = Date.now() } = {}) {
347
+ const from = now - days * 864e5;
348
+ return readLines(dir).filter((l) => (l.kind === 'accept' || l.kind === 'fix') && Date.parse(l.at) >= from).length;
349
+ }
350
+
351
+ /* ── pmos review ── */
352
+ const COMMANDS = { review: ['shots', 'list', 'note', 'accept', 'fix', 'count'] };
353
+ const USAGE = [
354
+ 'usage: pmos review shots|list|note|accept|fix|count — a built screen beside the design it came from, with each difference circled',
355
+ ' pmos review shots <initiative> --design <design.png> --built <built.png> [--screen <name>]',
356
+ ' compare the two PNG files and keep the review; the initiative\'s Review block on Work shows it',
357
+ ' pmos review list [<initiative>] [--all] the open reviews and their numbered differences (--all: accepted ones too)',
358
+ ' pmos review note <initiative> <n> "<words>" name difference n better, for example "button 8px lower"',
359
+ ' pmos review accept <initiative> [--undo] the built screen is right: close the review (--undo opens it again)',
360
+ ' pmos review fix <initiative> <n> [--undo] send difference n back: the task "Fix: <its words>" is added to the initiative',
361
+ ' pmos review count [--days 7] reviews decided in the last days; the number is the last line',
362
+ ' every command: [--screen <name>] [--root <dir>] [--json]',
363
+ 'Only PNG files are compared. Nothing is sent anywhere.',
364
+ ];
365
+ function repoOf(cwd) {
366
+ let d = path.resolve(cwd);
367
+ 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; }
368
+ }
369
+ /** The page's Add a task and Delete, run outside HTTP (lib/task-cli.js does the same). */
370
+ function boardAdder(root, stateDir, ini, cli) {
371
+ const boards = require('./routes-boards.js'), driver = require('./driver.js'), actor = require('./actor.js');
372
+ const w = { id: driver.wsIdOf(root), name: path.basename(root), root };
373
+ const ctx = { getWs: () => w, workspaceList: () => [w], stateDirFor: () => stateDir, selfRoot: path.resolve(__dirname, '..', '..') };
374
+ const g = { ok: true, actor: actor.fromCli(cli), cli };
375
+ // rows not read yet: read them now, as pmos task add does (lib/task-cli.js rowOf)
376
+ const at = () => { let r = boards.initiativeWorkflow(ctx, w, ini); if (r.pending) { try { require('./initiative-rows.js').deriveNow(root); } catch { /* answered below */ } r = boards.initiativeWorkflow(ctx, w, ini); } return r; };
377
+ return {
378
+ add: (title, notes) => {
379
+ const r = at();
380
+ if (!r.ok) return { ok: false, error: r.error };
381
+ const a = boards.taskAdd(ctx, { ws: w.id, board: r.board.id, initiative: ini, title, notes }, g);
382
+ return a.body && a.body.ok ? { ok: true, task: a.body.item.uid } : { ok: false, error: (a.body && a.body.error) || 'the write was refused' };
383
+ },
384
+ remove: (task) => {
385
+ const r = at();
386
+ if (!r.ok) return { ok: false, error: r.error };
387
+ const a = boards.taskDelete(ctx, { ws: w.id, board: r.board.id, task, why: 'the fix was taken back' }, g);
388
+ return a.body && a.body.ok ? { ok: true } : { ok: false, error: (a.body && a.body.error) || 'the write was refused' };
389
+ },
390
+ };
391
+ }
392
+ const sayPair = (say, p) => {
393
+ say(`${p.ini} · ${p.screen}: ${p.diffs.length ? p.diffs.length + (p.diffs.length === 1 ? ' difference' : ' differences') : 'matches its design'}${p.accepted ? ' · accepted' : ''}`);
394
+ for (const d of p.diffs) say(` ${d.n} · ${d.words}${d.task ? ' · sent back as ' + d.task : ''}`);
395
+ if (p.more) say(` and ${p.more} more, not circled`);
396
+ };
397
+ async function run(argv, o = {}) {
398
+ const say = o.say || ((s) => console.log(s)), now = o.now || Date.now();
399
+ const args = argv[0] === 'review' ? argv.slice(1) : argv.slice();
400
+ const pos = [], flags = {};
401
+ const VAL = new Set(['root', 'days', 'design', 'built', 'screen']);
402
+ for (let i = 0; i < args.length; i++) {
403
+ const a = args[i];
404
+ if (a.startsWith('--') && VAL.has(a.slice(2))) flags[a.slice(2)] = args[++i];
405
+ else if (a === '--json' || a === '--all' || a === '--undo') flags[a.slice(2)] = true;
406
+ else if (a.startsWith('--')) { say(`✗ unknown option ${a}`); return 2; }
407
+ else pos.push(a);
408
+ }
409
+ const cmd = pos[0];
410
+ if (!cmd || cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return cmd ? 0 : 2; }
411
+ if (!COMMANDS.review.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos review`); USAGE.forEach((l) => say(l)); return 2; }
412
+ const root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd()));
413
+ const dir = o.stateDir || require('./driver.js').stateDirOf(root, { create: cmd === 'shots' });
414
+ const out = (r, text) => { if (flags.json) say(JSON.stringify(r)); else if (!r.ok) say('✗ ' + r.error); else text(); return r.ok ? 0 : 1; };
415
+ if (!dir) return out({ ok: false, error: 'this repository has no PMOS state folder (pmos/state, state or .pmos)' });
416
+ const [, ini, n] = pos;
417
+ if (cmd === 'count') {
418
+ const k = count(dir, { days: Math.max(1, Math.min(365, parseInt(flags.days, 10) || 7)), now });
419
+ say(`${TAG} ${k} ${k === 1 ? 'review' : 'reviews'} decided in the last ${parseInt(flags.days, 10) || 7} days.`);
420
+ say(String(k));
421
+ return 0;
422
+ }
423
+ if (cmd === 'list') {
424
+ if (ini) auto(dir, root, ini, now); // the same comparison the Work popup's read runs by itself
425
+ const L = list(dir, ini, { all: !!flags.all });
426
+ if (flags.json) { say(JSON.stringify({ ok: true, reviews: L })); return 0; }
427
+ if (!L.length) { say(ini ? `${ini} has no open review.` : 'No open review.'); return 0; }
428
+ for (const p of L) sayPair(say, p);
429
+ return 0;
430
+ }
431
+ if (!ini) { say(`usage: pmos review ${cmd} <initiative> …`); return 2; }
432
+ const cli = { isTTY: o.isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : o.isTTY, env: o.env || process.env };
433
+ const by = (() => { try { return require('./actor.js').fromCli(cli).by || 'agent'; } catch { return 'agent'; } })();
434
+ if (cmd === 'shots') {
435
+ const r = compare(dir, { ini, screen: flags.screen, design: flags.design && path.resolve(o.cwd || process.cwd(), flags.design), built: flags.built && path.resolve(o.cwd || process.cwd(), flags.built), by }, now);
436
+ return out(r, () => { sayPair(say, r.pair); say('The initiative\'s Review block on Work shows it. Nothing was sent.'); });
437
+ }
438
+ if (cmd === 'note') {
439
+ const r = note(dir, ini, n, pos.slice(3).join(' '), { by, screen: flags.screen, now });
440
+ return out(r, () => say(`✓ ${r.n} · ${r.words}`));
441
+ }
442
+ // a review decided from the chat counts like a press on the page (the health number, use-log control builtVsDesign)
443
+ const used = (r) => { if (r.ok && !flags.undo) { try { require('./use-log.js').record(o.useLogDir || require('./state-root.js').defaultRoot({ env: o.env || process.env }), [{ kind: 'use', page: 'premium-board', control: 'builtVsDesign', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ } } return r; };
444
+ if (cmd === 'accept') {
445
+ const r = used(accept(dir, ini, { by, screen: flags.screen, undo: !!flags.undo, now }));
446
+ return out(r, () => say(flags.undo ? `✓ The review of ${r.screen} is open again.` : `✓ Accepted ${r.screen}. Undo: pmos review accept ${ini} --undo`));
447
+ }
448
+ // fix
449
+ const A = o.adder || boardAdder(root, dir, ini, cli);
450
+ const r = used(await fix(dir, ini, n, { add: A.add, remove: A.remove, by, screen: flags.screen, undo: !!flags.undo, now }));
451
+ return out(r, () => say(flags.undo ? `✓ Difference ${r.n} is open again; ${r.task} was taken away.` : `✓ Added ${r.task} · ${r.title}. Undo: pmos review fix ${ini} ${r.n} --undo`));
452
+ }
453
+
454
+ module.exports = { TAG, FILE, DIR, THRESHOLD, MAX_CIRCLES, readPng, writePng, diffOf, wordsOf, fold, readLines, compare, discover, auto, SHOTS_DIR, list, find, shotFile, note, accept, fix, count, run, COMMANDS, USAGE, PAIR_RE };
@@ -8,6 +8,11 @@
8
8
  * add one wait (from a Jira link: pass --key; one open wait per key)
9
9
  * pmos deps done <wait id> the wait is over
10
10
  * pmos deps undo <wait id> Undo of done: the wait is open again
11
+ * pmos deps slips [--json] other teams' slips on the boards your open waits are on (team-slips, A15)
12
+ * pmos deps slip --key <JIRA-1> --theirs YYYY-MM-DD --likely YYYY-MM-DD [--yours YYYY-MM-DD] [--yours-what "<what>"] [--from "<board>"]
13
+ * one reading of a ticket your work waits on (the tracker read or the chat)
14
+ * pmos deps slip-done <JIRA-1> [--how shift|chase|skip] you acted on the slip: its row goes until a later likely date
15
+ * pmos deps slip-undo <JIRA-1> Undo of slip-done: the row is back
11
16
  * every command: [--root <dir>] (default: this repository)
12
17
  *
13
18
  * Waits that come from the initiative itself (a parked hold "waiting on <team>", or `waiting_on:` in its record) are listed too; change them
@@ -15,23 +20,30 @@
15
20
  const path = require('path');
16
21
  const fs = require('fs');
17
22
  const TW = require('./team-waits.js');
23
+ const TS = require('./team-slips.js');
18
24
  const { todayOf } = require('./parked-reasons.js');
19
25
 
20
- const COMMANDS = { deps: ['waits', 'wait', 'done', 'undo'] };
26
+ const COMMANDS = { deps: ['waits', 'wait', 'done', 'undo', 'slips', 'slip', 'slip-done', 'slip-undo'] };
21
27
  const USAGE = [
22
- 'usage: pmos deps waits|wait|done|undo — what your work waits on outside the team (Work › Dependencies)',
28
+ 'usage: pmos deps waits|wait|done|undo|slips|slip|slip-done|slip-undo — what your work waits on outside the team (Work › Dependencies)',
23
29
  ' pmos deps waits [--json] every open wait on another team, oldest first, with the day it started',
24
30
  ' pmos deps wait --team "<team>" [--what "<what>"] [--ini <id>] [--since YYYY-MM-DD] [--who "<name>"] [--email <address>]',
25
31
  ' [--key <JIRA-1>] [--sprint "<name>" --sprint-end YYYY-MM-DD]',
26
32
  ' add a wait; from a Jira link pass --key (one open wait per key)',
27
33
  ' pmos deps done <wait id> the wait is over',
28
34
  ' pmos deps undo <wait id> the wait is open again',
35
+ ' pmos deps slips [--json] other teams\' slips on the boards your open waits are on',
36
+ ' pmos deps slip --key <JIRA-1> --theirs YYYY-MM-DD --likely YYYY-MM-DD [--yours YYYY-MM-DD] [--yours-what "<what>"] [--from "<board>"]',
37
+ ' one reading of a ticket your work waits on',
38
+ ' pmos deps slip-done <JIRA-1> [--how shift|chase|skip] you acted on the slip (Undo: pmos deps slip-undo <JIRA-1>)',
29
39
  'Run it in the product\'s repository, or pass --root <dir>.',
30
40
  ];
31
41
  const ALLOWED = {
32
42
  waits: ['json', 'root'],
33
43
  wait: ['json', 'root', 'team', 'what', 'ini', 'since', 'who', 'email', 'key', 'sprint', 'sprint-end'],
34
44
  done: ['json', 'root'], undo: ['json', 'root'],
45
+ slips: ['json', 'root'], slip: ['json', 'root', 'key', 'theirs', 'likely', 'yours', 'yours-what', 'from'],
46
+ 'slip-done': ['json', 'root', 'how'], 'slip-undo': ['json', 'root'],
35
47
  };
36
48
  const BOOL = new Set(['json']);
37
49
 
@@ -90,6 +102,39 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
90
102
  return 0;
91
103
  }
92
104
 
105
+ if (sub === 'slips') {
106
+ if (pos.length) return fail('pmos deps slips takes no argument', 2);
107
+ const today = todayOf(now);
108
+ const { file, watching, slips } = TS.slipsOf(root, { today });
109
+ if (flags.json) { say(JSON.stringify({ ok: true, file, today, watching, slips })); return 0; }
110
+ if (!slips.length) { say(watching ? `No slip on the ${watching} ${watching === 1 ? 'board' : 'boards'} your work waits on.` : 'No open wait has a Jira key, so PMOS watches no board.'); return 0; }
111
+ say(`${slips.length} ${slips.length === 1 ? 'slip' : 'slips'} · watching ${watching} ${watching === 1 ? 'board' : 'boards'} your work waits on`);
112
+ for (const x of slips) {
113
+ say(` ▲ ${x.team} will likely slip to ${x.likely} (${x.late} ${x.late === 1 ? 'day' : 'days'} late)${x.yours ? ` · your ${x.yours_what} is ${x.yours}` : ''}`);
114
+ say(` ${x.key} on ${x.from}: was ${x.theirs} · ✦ ${x.move === 'shift' ? 'shift your date to ' + x.shift_to : 'chase ' + (x.who || x.team)} · pmos deps slip-done ${x.key} --how ${x.move}`);
115
+ }
116
+ return 0;
117
+ }
118
+ if (sub === 'slip') {
119
+ if (pos.length) return fail('usage: pmos deps slip --key <JIRA-1> --theirs YYYY-MM-DD --likely YYYY-MM-DD …', 2);
120
+ const a = actor();
121
+ const r = TS.read(root, { key: flags.key, theirs: flags.theirs, likely: flags.likely, yours: flags.yours, yours_what: flags['yours-what'], from: flags.from }, { now, by: a.by, via: a.via });
122
+ if (!r.ok) return fail(r.error);
123
+ if (flags.json) { say(JSON.stringify({ ok: true, line: r.line })); return 0; }
124
+ const slip = r.line.likely > r.line.theirs;
125
+ say(`${TS.TAG} ✓ ${r.line.key}: was ${r.line.theirs}, likely ${r.line.likely}.${slip ? ' That is a slip: Today and Work › Dependencies show it.' : ' No slip.'}`);
126
+ return 0;
127
+ }
128
+ if (sub === 'slip-done' || sub === 'slip-undo') {
129
+ if (pos.length !== 1) return fail(`usage: pmos deps ${sub} <JIRA-1>`, 2);
130
+ const a = actor();
131
+ const r = sub === 'slip-done' ? TS.handle(root, { key: pos[0] }, { now, by: a.by, via: a.via, how: flags.how || 'skip' }) : TS.undo(root, { key: pos[0] }, { now, by: a.by, via: a.via });
132
+ if (!r.ok) return fail(r.error);
133
+ if (flags.json) { say(JSON.stringify({ ok: true, line: r.line })); return 0; }
134
+ say(sub === 'slip-done' ? `${TS.TAG} ✓ ${pos[0]}: acted on (${r.line.how}). The row goes until a later likely date. Undo: pmos deps slip-undo ${pos[0]}` : `${TS.TAG} ✓ ${pos[0]}: the row is back.`);
135
+ return 0;
136
+ }
137
+
93
138
  if (pos.length !== 1) return fail(`usage: pmos deps ${sub} <wait id>`, 2);
94
139
  const a = actor();
95
140
  const r = (sub === 'done' ? TW.end : TW.back)(root, { id: pos[0] }, { now, by: a.by, via: a.via });
@@ -16,6 +16,7 @@
16
16
  {"id": "parked", "audience": "user", "status": "ga", "group": "Catch up", "name": "Parked work", "say": "Each initiative on hold, why it is parked and what brings it back.", "cmd": "/parked", "verb": "parked", "sub": "list", "phrases": ["parked work", "what is on hold", "what is parked", "paused initiatives"], "since": "0.700.0"},
17
17
  {"id": "people", "audience": "user", "status": "ga", "group": "Catch up", "name": "People you work with", "say": "Each person with their role, how often you talk and their tone.", "cmd": "/people", "verb": "people", "sub": "list", "phrases": ["who do I work with", "stakeholders list", "people on this", "who is involved"], "since": "0.610.0"},
18
18
  {"id": "strategy", "audience": "user", "status": "ga", "group": "Your product", "name": "Five-line strategy", "say": "Who it is for, the problem, the bet, how you win and what you will not do.", "cmd": "/strategy", "verb": "strategy", "sub": "show", "place": "board", "phrases": ["our strategy", "product strategy", "draft the strategy", "how we win"], "since": "0.776.0", "ask": ["product"]},
19
+ {"id": "segments", "audience": "user", "status": "ga", "group": "Your product", "name": "Segments", "say": "A few user groups with their size and health, and the roadmap items that serve each.", "cmd": "/segments", "verb": "segments", "sub": "list", "place": "board", "since": "0.822.0"},
19
20
  {"id": "code", "audience": "user", "status": "ga", "group": "Your product", "name": "Code map", "say": "One line per main part of the code: what it is, how it is tested, who changed it last.", "cmd": "/code", "verb": "code", "sub": "show", "place": "board", "since": "0.826.0", "ask": ["product"]},
20
21
  {"id": "connectors", "audience": "user", "status": "ga", "group": "Your product", "name": "What connectors read and write", "say": "What PMOS reads and writes through each connector, and what leaves this computer.", "cmd": "/connectors", "verb": "connectors", "sub": "data", "since": "0.825.0"},
21
22
  {"id": "positioning", "audience": "user", "status": "ga", "group": "Your product", "name": "Positioning and key messages", "say": "A positioning statement and key messages, each citing a strategy line.", "cmd": "/positioning", "verb": "positioning", "sub": "list", "phrases": ["positioning statement", "key messages", "messaging for"], "since": "0.740.0"},
@@ -59,6 +60,7 @@
59
60
  {"id": "rules", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "Rules PMOS learned", "say": "The standing rules PMOS learned from your corrections, and edit or retire one.", "cmd": "/rules", "verb": "rules"},
60
61
  {"id": "line", "audience": "user", "status": "ga", "group": "Catch up", "name": "Where each initiative stands", "say": "Days in its stage, what is missing, the next move, and whether it is stuck.", "cmd": "/line", "verb": "line", "hint": "<initiative>", "ask": ["initiative"]},
61
62
  {"id": "hire", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The next hire", "say": "The role your open work most needs, and a one-page role brief to edit.", "cmd": "/hire", "verb": "hire"},
63
+ {"id": "review", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Built beside its design", "say": "The built screen beside its design, each difference circled and numbered. Accept it, or send a difference back as a fix.", "cmd": "/built-vs-design", "verb": "review", "sub": "list", "hint": "<initiative>", "place": "board"},
62
64
  {"id": "story-map", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Story map", "say": "A new bet's user journey left to right, with the Release 1 line to move tasks across.", "cmd": "/story-map", "verb": "story-map", "hint": "<initiative>"},
63
65
  {"id": "print", "audience": "user", "status": "ga", "group": "Your product", "name": "Print or PDF", "say": "One clean page of a report or an initiative, to print or save as PDF.", "cmd": "/print", "verb": "print", "hint": "<file or initiative>"},
64
66
  {"id": "prototype", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Simulated users try the prototype", "say": "Where simulated users, one per persona, got stuck on a prototype, and the personas that walk it.", "cmd": "/prototype", "verb": "prototype", "hint": "findings <initiative>"},
@@ -93,10 +93,11 @@ function dirOf(root) {
93
93
  const kit = fs.existsSync(path.join(root, 'pmos', 'state'));
94
94
  return path.join(root, ...(kit ? ['pmos', 'planning'] : ['planning']), 'hires');
95
95
  }
96
- function sourcesOf(root, { now }) {
96
+ /** records: the open records to count as asks; leave it out to read them from the repository (slow on a big one: contradictions.forRepo). */
97
+ function sourcesOf(root, { now, records = null } = {}) {
97
98
  let tasks = []; try { tasks = require('./away-handover.js').tasksNow(root); } catch { tasks = []; }
98
99
  let people = []; try { const v = require('./people-store.js').view(root, { now }); people = v.ok ? v.people || [] : []; } catch { people = []; }
99
- let asks = []; try { asks = require('./open-questions.js').read(root, { now }).lines || []; } catch { asks = []; }
100
+ let asks = []; try { asks = require('./open-questions.js').read(root, { now, records }).lines || []; } catch { asks = []; }
100
101
  let titles = {}; try { for (const i of require('./live-notes.js').loadInitiatives(root).open) titles[i.id] = i.title; } catch { titles = {}; }
101
102
  return { tasks, people, asks, titles };
102
103
  }
@@ -169,4 +170,4 @@ function run(argv, o = {}) {
169
170
  return 0;
170
171
  }
171
172
 
172
- module.exports = { TAG, LOAD_MIN, NO_ROLE, NO_OWNER, gapOf, briefOf, draft, count, run, COMMANDS, USAGE };
173
+ module.exports = { TAG, LOAD_MIN, NO_ROLE, NO_OWNER, gapOf, sourcesOf, briefOf, draft, count, run, COMMANDS, USAGE };
@@ -234,6 +234,9 @@ function anchorsOf(root) {
234
234
  try {
235
235
  const file = engine.layout(root).budgets;
236
236
  budgets = { ok: true, text: fs.readFileSync(file, 'utf8'), path: path.relative(root, file) };
237
+ // D67: the domain registry (domains.md) sits beside the budgets. Without it, every declared domain:<id> resolved as unknown here,
238
+ // so list() left domains out and the writer refused them (anchor-ids, Checker A3).
239
+ if (typeof A.withDomains === 'function') A.withDomains(budgets, path.dirname(file), root);
237
240
  } catch {
238
241
  // Not at the engine's path. A kit vendors the registry to pmos/planning/okrs/ (build-kit.sh; server.js budgetsFor), so
239
242
  // look there too: without it every health:<id> in a kit repository was refused as undeclared.