create-pmos 0.831.0 → 0.833.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 (59) hide show
  1. package/package.json +140 -41
  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 +139 -21
  7. package/workspace/guide/backlog.md +2 -1
  8. package/workspace/guide/cli.md +19 -0
  9. package/workspace/guide/initiatives-and-next-steps.md +2 -0
  10. package/workspace/guide/layout.md +4 -1
  11. package/workspace/guide/positioning.md +1 -1
  12. package/workspace/guide/programs.md +2 -1
  13. package/workspace/lib/events-place.js +11 -4
  14. package/workspace/lib/features.json +3 -1
  15. package/workspace/lib/layouts-cli.js +6 -0
  16. package/workspace/lib/line.js +7 -1
  17. package/workspace/lib/list-balance.js +18 -3
  18. package/workspace/lib/pmos-verbs.js +6 -0
  19. package/workspace/lib/route-modules.js +2 -0
  20. package/workspace/lib/routes-events-place.js +19 -1
  21. package/workspace/lib/routes-screen-layouts.js +56 -0
  22. package/workspace/lib/routes-strategy-card.js +6 -2
  23. package/workspace/lib/routes-switches.js +35 -0
  24. package/workspace/lib/switch-owners.js +152 -0
  25. package/workspace/lib/switches-cli.js +85 -0
  26. package/workspace/lib/three-layouts.js +214 -0
  27. package/workspace/lib/work-kr.js +77 -0
  28. package/workspace/package-lock.json +2 -2
  29. package/workspace/package.json +1 -1
  30. package/workspace/public/pm/bd-backlog.css +11 -0
  31. package/workspace/public/pm/bd-goal.js +33 -0
  32. package/workspace/public/pm/bd-ini-panel.js +15 -5
  33. package/workspace/public/pm/bd-pop-ds.css +16 -0
  34. package/workspace/public/pm/bd-positioning.js +6 -4
  35. package/workspace/public/pm/bd-prog-panel.js +16 -5
  36. package/workspace/public/pm/bd-strategy.js +15 -3
  37. package/workspace/public/pm/bd-work-ds.css +6 -0
  38. package/workspace/public/pm/bd-work.js +34 -8
  39. package/workspace/public/pm/cozy-events-view.js +8 -4
  40. package/workspace/public/pm/cozy-pop-work.js +8 -3
  41. package/workspace/public/pm/cozy-today-app.js +28 -1
  42. package/workspace/public/pm/cozy-today-model.js +13 -5
  43. package/workspace/public/pm/cozy-today-view.js +10 -1
  44. package/workspace/public/pm/line-view.js +13 -1
  45. package/workspace/public/pm/list-balance.js +16 -2
  46. package/workspace/public/pm/ms-strip.js +137 -0
  47. package/workspace/public/pm/page-chat.css +19 -0
  48. package/workspace/public/pm/page-chat.js +2 -0
  49. package/workspace/public/pm/premium-board.js +7 -1
  50. package/workspace/public/pm/side-fold.js +94 -0
  51. package/workspace/public/pm/switch-owners.js +70 -0
  52. package/workspace/public/pm/three-layouts.js +66 -0
  53. package/workspace/public/premium-board.html +2 -0
  54. package/workspace/stage-card-tasks-test.js +1 -0
  55. package/workspace/test-lists/ms-strip.json +9 -0
  56. package/workspace/test-lists/side-fold.json +9 -0
  57. package/workspace/test-lists/switch-owners.json +9 -0
  58. package/workspace/test-lists/three-layouts.json +9 -0
  59. package/workspace/test-lists/work-kr.json +9 -0
@@ -0,0 +1,214 @@
1
+ 'use strict';
2
+ /* three-layouts.js — three layouts for a new screen, pick one (initiative three-layouts, job #1904, idea A317; board BatchDesignDS panel 19,
3
+ * agreed by Wawan 2026-11-25). The store, the rule that finds a new screen, the ✦ recommendation and `pmos layouts`.
4
+ *
5
+ * When a piece of work adds a screen, the first layout drawn is usually the one that ships. This puts three different layouts of the same
6
+ * parts in front of the PM before the build: A List first, B Summary first, C Action first. Each is drawn with grey sample bars, never the
7
+ * product's data and never the board's example names. The PM picks one; the pick is kept on the initiative as the one to build and the
8
+ * other two are kept beside it. Each pick counts for this product, and the ✦ recommends the kind picked most. No model call; nothing is sent.
9
+ *
10
+ * KINDS the three layouts: { key, letter, name, order: [part], says }
11
+ * optionsOf() PURE → [layout] a copy of KINDS with each part's tall flag (the list is the tall part)
12
+ * isNewScreen({ title, intro, state }) PURE → bool a making word then, within three words, a screen word, in the title or the first
13
+ * paragraph; never a done one
14
+ * tasteOf(lines) PURE → { picks: n, by: { key: n }, last: key | null } the product's picks that still stand
15
+ * recOf(taste) PURE → { key, letter, name, why } most picked (a tie goes to the latest pick); none yet: Summary first
16
+ * pickedOf(lines, ini) PURE → { key, kept: [key], at } | null
17
+ * pickLine({ ini, key, title, by }) PURE → { line } | { error } undoLine({ ini, by }) → { line }
18
+ * fileOf(stateDir) · readLines(stateDir) · append(stateDir, line)
19
+ * recordOf(root, ini) → { id, title, intro, state, path } | null the initiative's record (planning/initiatives or pmos/state/initiatives)
20
+ * viewOf(root, ini, { stateDir }) → { ok, none: true } | { ok, layouts, rec, picked, kept, taste } what the Work popup and `show` read
21
+ * CLI: pmos layouts show <id> | pick <id> <A|B|C> | undo <id> | taste [--root <repo>] [--json]
22
+ * STATE: <product state dir>/layouts.jsonl, append-only, one line per pick or undo: { at, ini, act: 'pick'|'undo', key?, kept?, title?, by }.
23
+ * Every log line carries [three-layouts]. */
24
+ const fs = require('fs');
25
+ const path = require('path');
26
+
27
+ const TAG = '[three-layouts]';
28
+ const FILE = 'layouts.jsonl';
29
+ const ID_RE = /^[a-z0-9][a-z0-9._-]{0,119}$/;
30
+ const KINDS = Object.freeze([
31
+ Object.freeze({ key: 'list', letter: 'A', name: 'List first', order: Object.freeze(['list', 'summary', 'action']), says: 'the rows fill the screen; the summary and the main action sit under them' }),
32
+ Object.freeze({ key: 'summary', letter: 'B', name: 'Summary first', order: Object.freeze(['summary', 'list', 'action']), says: 'one line of answer on top, the rows under it, the main action last' }),
33
+ Object.freeze({ key: 'action', letter: 'C', name: 'Action first', order: Object.freeze(['action', 'summary', 'list']), says: 'the main action on top, then the summary, then the rows' }),
34
+ ]);
35
+ const PART_NAME = Object.freeze({ summary: 'the summary', list: 'the list', action: 'the main action' });
36
+ const DEFAULT = 'summary';
37
+ // a making word, then at most three words, then a screen word: "Add a Layouts page", "A new settings screen", "Build the onboarding view".
38
+ // "Add a column to the Work page" (five words between) and "Make the Today page load faster" (make is not a making word) are not.
39
+ const NEW_SCREEN_RE = /\b(new|add|adds|adding|build|builds|design|designs|create|creates|introduce|introduces)\b(?:[\s,/-]+[\w'’&.-]+){0,3}?[\s,/-]+(screens?|pages?|views?|dashboards?|forms?|popups?|panels?|tabs?|layouts?)\b/i;
40
+ const CLOSED_RE = /^(done|closed|cancel+ed|stopped|killed|shipped|won'?t do|archived)\b/i;
41
+ const one = (s, n = 240) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
42
+ const kindOf = (k) => { const s = String(k || '').trim().toLowerCase(); return KINDS.find((x) => x.key === s || x.letter.toLowerCase() === s) || null; };
43
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
44
+
45
+ /** PURE. The three layouts, each part with its tall flag. */
46
+ function optionsOf() {
47
+ return KINDS.map((k) => ({ key: k.key, letter: k.letter, name: k.name, says: k.says, parts: k.order.map((p) => ({ part: p, name: PART_NAME[p], tall: p === 'list' })) }));
48
+ }
49
+
50
+ /** PURE. The record says it adds a screen: a screen word and a making word in the title, or both in the first paragraph. Never a done one. */
51
+ function isNewScreen(r) {
52
+ if (!r) return false;
53
+ if (CLOSED_RE.test(one(r.state || r.status, 40))) return false;
54
+ return NEW_SCREEN_RE.test(one(r.title)) || NEW_SCREEN_RE.test(one(r.intro, 400));
55
+ }
56
+
57
+ /** PURE. The picks of a product that still stand: the last line of each initiative decides. */
58
+ function standing(lines) {
59
+ const by = new Map();
60
+ for (const l of lines || []) {
61
+ if (!l || !ID_RE.test(String(l.ini || ''))) continue;
62
+ if (l.act === 'pick' && kindOf(l.key)) by.set(l.ini, l);
63
+ else if (l.act === 'undo') by.delete(l.ini);
64
+ }
65
+ return [...by.values()].sort((a, b) => String(a.at).localeCompare(String(b.at)));
66
+ }
67
+ function tasteOf(lines) {
68
+ const S = standing(lines), by = {};
69
+ for (const l of S) by[l.key] = (by[l.key] || 0) + 1;
70
+ return { picks: S.length, by, last: S.length ? S[S.length - 1].key : null };
71
+ }
72
+ /** PURE. The ✦: the kind picked most in this product; a tie goes to the latest pick of the tied kinds. None yet: Summary first. */
73
+ function recOf(taste) {
74
+ const T = taste || { picks: 0, by: {}, last: null };
75
+ if (!T.picks) {
76
+ const k = kindOf(DEFAULT);
77
+ return { key: k.key, letter: k.letter, name: k.name, why: `${k.letter} puts the answer first, as the design principles say (summary first).` };
78
+ }
79
+ const top = Math.max(...Object.values(T.by));
80
+ const tied = KINDS.filter((k) => T.by[k.key] === top).map((k) => k.key);
81
+ const key = tied.length === 1 ? tied[0] : tied.includes(T.last) ? T.last : tied[0];
82
+ const k = kindOf(key);
83
+ const why = T.picks === 1 ? `${k.letter} fits how you picked last time (${k.name.toLowerCase()}).`
84
+ : `${k.letter} fits how you pick for this product: ${k.name.toLowerCase()} in ${T.by[key]} of your ${plural(T.picks, 'pick', 'picks')}.`;
85
+ return { key: k.key, letter: k.letter, name: k.name, why };
86
+ }
87
+ function pickedOf(lines, ini) {
88
+ const l = standing(lines).find((x) => x.ini === ini);
89
+ return l ? { key: l.key, kept: KINDS.map((k) => k.key).filter((k) => k !== l.key), at: l.at } : null;
90
+ }
91
+ function pickLine({ ini, key, title, by } = {}, now = new Date()) {
92
+ if (!ID_RE.test(String(ini || ''))) return { error: 'ini is an initiative id' };
93
+ const k = kindOf(key);
94
+ if (!k) return { error: 'the layout is A, B or C' };
95
+ return { line: { at: now.toISOString(), ini, act: 'pick', key: k.key, kept: KINDS.map((x) => x.key).filter((x) => x !== k.key), title: one(title, 160), by: one(by, 80) || 'pm' } };
96
+ }
97
+ function undoLine({ ini, by } = {}, now = new Date()) {
98
+ if (!ID_RE.test(String(ini || ''))) return { error: 'ini is an initiative id' };
99
+ return { line: { at: now.toISOString(), ini, act: 'undo', by: one(by, 80) || 'pm' } };
100
+ }
101
+
102
+ /* ── the store ── */
103
+ const fileOf = (dir) => (dir ? path.join(dir, FILE) : null);
104
+ function readLines(dir) {
105
+ const f = fileOf(dir); if (!f) return [];
106
+ let raw = ''; try { raw = fs.readFileSync(f, 'utf8'); } catch { return []; }
107
+ const out = [];
108
+ for (const s of raw.split('\n')) { if (!s.trim()) continue; try { out.push(JSON.parse(s)); } catch { /* a torn line is skipped */ } }
109
+ return out;
110
+ }
111
+ function append(dir, line) {
112
+ const f = fileOf(dir); if (!f) throw new Error('no state folder');
113
+ fs.mkdirSync(dir, { recursive: true });
114
+ fs.appendFileSync(f, JSON.stringify(line) + '\n');
115
+ }
116
+ function stateDirOf(root, create = false) {
117
+ try { return require('./driver.js').stateDirOf(root, { create }); } catch { return null; }
118
+ }
119
+
120
+ /** The initiative's record: title, the first paragraph of its body, its state. null when there is none. */
121
+ function recordOf(root, ini) {
122
+ if (!ID_RE.test(String(ini || ''))) return null;
123
+ const I = require('./item-why.js');
124
+ const f = I.recordPathOf(root, ini);
125
+ if (!f) return null;
126
+ let text = ''; try { text = fs.readFileSync(f, 'utf8'); } catch { return null; }
127
+ const fm = I.frontOf(text);
128
+ const body = text.replace(/^---\s*\n[\s\S]*?\n---\s*(\n|$)/, '');
129
+ const intro = body.split(/\n\s*\n/).map((p) => p.trim()).find((p) => p && !/^#/.test(p)) || '';
130
+ return { id: ini, title: one(fm.title || ini, 200), intro: one(intro, 400), state: one(fm.state || fm.status, 60), path: path.relative(root, f).split(path.sep).join('/') };
131
+ }
132
+
133
+ /** What the Work popup and `pmos layouts show` read. Writes nothing. */
134
+ function viewOf(root, ini, { stateDir } = {}) {
135
+ const r = recordOf(root, ini);
136
+ const lines = readLines(stateDir || stateDirOf(root));
137
+ const picked = r ? pickedOf(lines, ini) : null;
138
+ // a picked one stays: the pick is kept on the work item even when its words change later
139
+ if (!r || (!picked && !isNewScreen(r))) return { ok: true, none: true };
140
+ const taste = tasteOf(lines);
141
+ return { ok: true, ini, title: r.title, layouts: optionsOf(), rec: recOf(taste), picked: picked ? picked.key : null, kept: picked ? picked.kept : [], taste };
142
+ }
143
+
144
+ /* ── pmos layouts ── */
145
+ const COMMANDS = { layouts: ['show', 'pick', 'undo', 'taste'] };
146
+ const USAGE = [
147
+ 'usage: pmos layouts show <initiative> | pick <initiative> <A|B|C> | undo <initiative> | taste — three layouts for a new screen, pick one',
148
+ ' pmos layouts show <id> the three layouts, the ✦ recommendation and the pick (an initiative that adds no screen has none)',
149
+ ' pmos layouts pick <id> <A|B|C> keep one as the layout to build; the other two stay on the initiative',
150
+ ' pmos layouts undo <id> take the pick back',
151
+ ' pmos layouts taste the picks of this product, by kind; the ✦ recommends the kind picked most',
152
+ 'Nothing is sent and no model is called. The Work popup shows the same layouts under the stages.',
153
+ ];
154
+ function repoOf(cwd) {
155
+ let d = path.resolve(cwd);
156
+ 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; }
157
+ }
158
+ function used(o, now) {
159
+ try { const dir = o.runtimeDir || require('./state-root.js').defaultRoot({ env: o.env || process.env }); require('./use-log.js').record(dir, [{ kind: 'use', page: 'premium-board', control: 'layoutPick', device: 'desk' }], now); } catch { /* a count, never a reason to fail */ }
160
+ }
161
+ const describe = (V, say) => {
162
+ for (const L of V.layouts) {
163
+ const mark = V.picked === L.key ? ' ✓ picked' : V.picked ? ' (kept)' : V.rec.key === L.key ? ' ✦' : '';
164
+ say(`${L.letter} ${L.name}: ${L.parts.map((p) => p.name).join(', then ')}.${mark}`);
165
+ }
166
+ if (!V.picked) say(`✦ ${V.rec.why}`);
167
+ };
168
+ function run(argv, o = {}) {
169
+ const say = o.say || ((s) => console.log(s)), now = o.now ? new Date(o.now) : new Date();
170
+ const args = argv[0] === 'layouts' ? argv.slice(1) : argv.slice();
171
+ const pos = [], flags = {};
172
+ for (let i = 0; i < args.length; i++) { const a = args[i]; if (a === '--root') flags.root = args[++i]; else if (a === '--json') flags.json = true; else pos.push(a); }
173
+ const cmd = pos[0] || 'help';
174
+ if (cmd === 'help' || cmd === '--help') { USAGE.forEach((l) => say(l)); return 0; }
175
+ if (!COMMANDS.layouts.includes(cmd)) { say(`✗ ${cmd} is not a command of pmos layouts`); USAGE.forEach((l) => say(l)); return 2; }
176
+ const root = path.resolve(flags.root || o.root || repoOf(o.cwd || process.cwd()));
177
+ const dir = o.stateDir || stateDirOf(root, cmd === 'pick' || cmd === 'undo');
178
+ if (cmd === 'taste') {
179
+ const T = tasteOf(readLines(dir)), R = recOf(T);
180
+ if (flags.json) { say(JSON.stringify({ ok: true, ...T, rec: R })); return 0; }
181
+ if (!T.picks) say('No layout picked for this product yet.');
182
+ else say(KINDS.map((k) => `${k.letter} ${k.name}: ${T.by[k.key] || 0}`).join(' · '));
183
+ say(`✦ ${R.why}`);
184
+ return 0;
185
+ }
186
+ const ini = String(pos[1] || '').trim();
187
+ if (!ini) { say('✗ name the initiative: pmos layouts ' + cmd + ' <id>'); return 2; }
188
+ const r = recordOf(root, ini);
189
+ if (!r) { say(`✗ no initiative ${ini} here: nothing was written`); return 1; }
190
+ if (cmd === 'show') {
191
+ const V = viewOf(root, ini, { stateDir: dir });
192
+ if (flags.json) { say(JSON.stringify(V)); return 0; }
193
+ if (V.none) { say(`${r.title} does not add a screen, so it has no layouts.`); return 0; }
194
+ describe(V, say);
195
+ return 0;
196
+ }
197
+ if (cmd === 'undo') {
198
+ if (!pickedOf(readLines(dir), ini)) { say(`No layout is picked for ${r.title}. Nothing was written.`); return 0; }
199
+ append(dir, undoLine({ ini, by: o.by || 'pm:cli' }, now).line);
200
+ console.log(`${TAG} undo ini=${ini}`);
201
+ say(`↺ The pick for ${r.title} is taken back.`);
202
+ return 0;
203
+ }
204
+ const p = pickLine({ ini, key: pos[2], title: r.title, by: o.by || 'pm:cli' }, now);
205
+ if (p.error) { say(`✗ ${p.error}: nothing was written`); return 1; }
206
+ append(dir, p.line);
207
+ console.log(`${TAG} pick ini=${ini} key=${p.line.key}`);
208
+ used(o, now.getTime());
209
+ const k = kindOf(p.line.key);
210
+ say(`✓ ${k.letter} ${k.name} is the layout to build for ${r.title}. The other two stay on it. pmos layouts undo ${ini} takes it back.`);
211
+ return 0;
212
+ }
213
+
214
+ module.exports = { TAG, FILE, KINDS, DEFAULT, optionsOf, isNewScreen, tasteOf, recOf, pickedOf, pickLine, undoLine, fileOf, readLines, append, stateDirOf, recordOf, viewOf, kindOf, run, COMMANDS, USAGE };
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+ /* work-kr.js — each initiative on Work names its key result, and the Strategy card names its period (job tb-work-kr; board TbWork on
3
+ * Exploring 3, page balanced, Wawan "build" 2026-11-25). It reads the OKR files only (lib/okr-goals.js); it writes nothing.
4
+ *
5
+ * periodHead(period, now) → { label, months, ends, left, text } | null PURE: "H2 2026 · Jul–Dec · ends 31 Dec · 5 weeks left"
6
+ * servesOf(objectives) → [{ token, title, krs: [{ token, title }] }] PURE: the objectives and key results, in the file's order
7
+ * krOf(anchor, objectives) → { token, title, objective: { token, title } } | null PURE: the key result a parent_kr names, else null
8
+ * forRoot(root, now) → { period, serves, objectives } the OKR files of a workspace, read once (nothing when none)
9
+ * count(rows) → { named, live, pct } PURE: live line rows that name a key result
10
+ *
11
+ * node lib/work-kr.js count [--root <dir>] the health number: the percent of live initiatives on the line that name a key result (last line)
12
+ *
13
+ * NOTHING IS GUESSED. A key result shows only when the anchor names one the OKR file declares (okr-goals matchAnchor); a health budget,
14
+ * a domain, an unknown id or no anchor shows nothing. A period shows only when an OKR file names one. Strategy lines get no per-line tag. */
15
+ const OG = require('./okr-goals.js');
16
+
17
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
18
+ const DAY = 864e5;
19
+
20
+ function periodHead(period, now = Date.now()) {
21
+ if (!period || !period.label || !(period.from > 0) || !(period.to > 0)) return null;
22
+ const a = new Date(period.from), b = new Date(period.to);
23
+ const months = MON[a.getUTCMonth()] + (a.getUTCFullYear() !== b.getUTCFullYear() ? ' ' + a.getUTCFullYear() : '') + '–' + MON[b.getUTCMonth()];
24
+ const endDay = b.getUTCDate() + ' ' + MON[b.getUTCMonth()];
25
+ const toEnd = period.to + DAY - now; // the period ends at the end of its last day
26
+ let ends, left = null;
27
+ if (toEnd <= 0) ends = 'ended ' + endDay;
28
+ else {
29
+ const w = Math.floor(toEnd / (7 * DAY));
30
+ if (w < 1) ends = 'ends this week';
31
+ else { ends = 'ends ' + endDay; left = w + (w === 1 ? ' week left' : ' weeks left'); }
32
+ }
33
+ return { label: period.label, months, ends, left, text: [period.label, months, ends, left].filter(Boolean).join(' · ') };
34
+ }
35
+
36
+ function servesOf(objectives) {
37
+ return (objectives || []).filter((o) => o && (o.krs || []).length).map((o) => ({
38
+ token: String(o.token || ''), title: String(o.title || ''),
39
+ krs: o.krs.map((k) => ({ token: String(k.token || ''), title: String(k.title || '') })),
40
+ }));
41
+ }
42
+
43
+ function krOf(anchor, objectives) {
44
+ const s = String(anchor || '').trim();
45
+ if (!s) return null;
46
+ let hit = null;
47
+ try { hit = OG.matchAnchor(s, objectives || []); } catch { hit = null; }
48
+ if (!hit || !hit.k) return null;
49
+ return { token: String(hit.k.token || ''), title: String(hit.k.title || ''), objective: { token: String(hit.o.token || ''), title: String(hit.o.title || '') } };
50
+ }
51
+
52
+ function forRoot(root, now = Date.now()) {
53
+ let r = null;
54
+ try { r = OG.read(root); } catch { r = null; }
55
+ if (!r || !r.ok) return { period: null, serves: [], objectives: [] };
56
+ return { period: periodHead(r.period, now), serves: servesOf(r.objectives), objectives: r.objectives || [] };
57
+ }
58
+
59
+ function count(rows) {
60
+ const live = (rows || []).filter((r) => r && r.live);
61
+ const named = live.filter((r) => r.kr && r.kr.token).length;
62
+ return { named, live: live.length, pct: live.length ? Math.round((named / live.length) * 100) : 0 };
63
+ }
64
+
65
+ module.exports = { periodHead, servesOf, krOf, forRoot, count };
66
+
67
+ if (require.main === module) {
68
+ const cmd = process.argv[2];
69
+ if (cmd !== 'count') { console.error('usage: node lib/work-kr.js count [--root <dir>] (the percent of live initiatives on the line that name a key result)'); process.exit(2); }
70
+ const i = process.argv.indexOf('--root');
71
+ const root = i > 0 && process.argv[i + 1] ? require('path').resolve(process.argv[i + 1]) : require('path').resolve(__dirname, '..', '..');
72
+ const L = require('./line.js').lineOf(root);
73
+ if (!L.ok) { console.error('[work-kr] the line could not be read: ' + (L.error || 'no reason given')); process.exit(1); }
74
+ const c = count(L.rows);
75
+ console.log(`[work-kr] ${c.named} of ${c.live} live initiatives on the line name a key result`);
76
+ console.log(String(c.pct));
77
+ }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.831.0",
3
+ "version": "0.833.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.831.0",
9
+ "version": "0.833.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.831.0",
3
+ "version": "0.833.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -271,6 +271,9 @@ textarea.bk-rvl-ed, .bk-rvl textarea.bd { resize: vertical; min-height: 180px; }
271
271
  .pm-ds .ln-name { all: unset; cursor: pointer; font-weight: var(--fw-strong); color: var(--ink); line-height: 1.4; overflow-wrap: anywhere; }
272
272
  .pm-ds .ln-name:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
273
273
  .pm-ds .ln-name:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 2px; }
274
+ .pm-ds .ln-kr { display: flex; width: fit-content; margin-top: 4px; height: 22px; font-size: var(--fs-meta); color: var(--muted); text-decoration: none; } /* tb-work-kr: the key result under the name */
275
+ .pm-ds .ln-kr:hover { color: var(--blue); }
276
+ .pm-ds .ln-kr:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
274
277
  .pm-ds .ln-c-days .ln-d { display: block; color: var(--ink); white-space: nowrap; }
275
278
  .pm-ds .ln-c-days .ln-sub { display: block; font-size: var(--fs-meta); line-height: 18px; color: var(--muted); }
276
279
  .pm-ds .ln-c-days.ln-over .ln-d, .pm-ds .ln-c-days.ln-over .ln-sub { color: var(--alert); }
@@ -278,6 +281,14 @@ textarea.bk-rvl-ed, .bk-rvl textarea.bd { resize: vertical; min-height: 180px; }
278
281
  .pm-ds .ln-c-fin { color: var(--ink); line-height: 1.4; }
279
282
  .pm-ds .ln-t .pm-badge.ln-ok { background: var(--leaf-tint); color: var(--leaf); }
280
283
  .pm-ds .ln-t .pm-badge.ln-late { background: none; box-shadow: inset 0 0 0 1px var(--alert); color: var(--alert); }
284
+ /* tb-work-kr (board TbWork): the Strategy card's Serves row, each objective with its key results as chips */
285
+ .pm-ds .bd-serves { padding: 0 var(--space-16) var(--space-12); }
286
+ .pm-ds .bd-serves > .pm-meta { margin: 0 0 4px; }
287
+ .pm-ds .bd-serves ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
288
+ .pm-ds .bd-serves-o { display: flex; flex-direction: column; gap: 4px; }
289
+ .pm-ds .bd-serves-o .t { font-weight: var(--fw-strong); overflow-wrap: anywhere; }
290
+ .pm-ds .bd-serves-k { display: flex; flex-wrap: wrap; gap: 4px; }
291
+ .pm-ds .bd-serves-k .pm-chip { height: auto; min-height: 22px; white-space: normal; overflow-wrap: anywhere; }
281
292
 
282
293
  /* ── Work › Factory (factory-page-ui; boards FxFloor and FxStation on the main canvas) ── pm/factory.js draws it. Komorebi tokens only.
283
294
  * Every class starts with ff- (the page) or fx- (the station popup). Zero is silence: a quiet station is grey and has no numbers. */
@@ -3,6 +3,8 @@
3
3
  * readGoals(ws, rows) → Promise<{ goals, of } | null> GET /api/artefacts/goals: the Goal artefact of each anchor the rows carry (D107, derived)
4
4
  * goalGroups(rows, R) → [{ key, goal, rows }] | null PURE. The rows under each goal, key results in the file's order, then the health budgets,
5
5
  * then "No goal yet". null when no row's anchor names a goal (zero is silence)
6
+ * objectiveGroups(rows, R, sort) → [{ key, name, rows, empty }] | null Work › Initiatives: the rows under their key result's objective (TbInitiatives)
7
+ * servesOf(r, R) → 'Serves KR1.1' | '' the line under a row's name there. PURE
6
8
  * goalHeadHtml(g, o) → the Track's goal row: the goal icon, its name, "KR-A1 · no reading yet", the spread of its initiatives over the steps,
7
9
  * and in the Next column its target and where the reading comes from. o: { steps, plain, open }
8
10
  * asGroups(rows, R, sort) → [{ kind: 'goal', key, goal, name, rows }] | null goalGroups shaped as the Board's groups, so every view draws them
@@ -49,6 +51,37 @@ export function goalGroups(rows, R) {
49
51
  return none.rows.length ? G.concat(none) : G;
50
52
  }
51
53
 
54
+ /** Work › Initiatives (board TbInitiatives, Exploring 3 page balanced): the rows under the OBJECTIVE their key result serves, in the OKR file's
55
+ * order (by the objective's id), named "O1 · Sign-in is fast and nobody is locked out"; then each health budget as its own group; then "No goal yet". PURE.
56
+ * A key result whose goal names no objective keeps its own group, so no head is ever empty. → [{ key, name, rows, empty }] | null */
57
+ export function objectiveGroups(rows, R, sort) {
58
+ const G = goalGroups(rows, R);
59
+ if (!G) return null;
60
+ const out = new Map();
61
+ const put = (k, name, pos, rs, empty, id) => { if (!out.has(k)) out.set(k, { key: k, name, pos, id: id || '', rows: [], empty: !!empty }); out.get(k).rows.push(...rs); };
62
+ for (const g of G) {
63
+ const x = g.goal;
64
+ if (!x) put(NONE, 'No goal yet', 3e9, g.rows, true);
65
+ else if (x.kind === 'kr' && x.objective) { const o = objOf(x); put('obj:' + (o.id || x.objective), (o.token ? o.token + ' · ' : '') + x.objective, o.id ? 0 : 1e9, g.rows, false, o.id); }
66
+ else put(g.key, x.title, x.kind === 'budget' ? 2e9 : 1e9, g.rows);
67
+ }
68
+ return [...out.values()].sort((a, b) => a.pos - b.pos || String(a.id).localeCompare(String(b.id), undefined, { numeric: true }) || String(a.name).localeCompare(String(b.name)))
69
+ .map(({ key, name, rows: rs, empty }) => ({ key, name, rows: sort ? sort(rs) : rs, empty }));
70
+ }
71
+ /** A key result's objective, from its goal key "o1::kr1-1" (lib/board-goals.js: the objective's id, then the key result's): its id and the token
72
+ * the OKR file writes ("O1"; "O-A" for an id of letters). Both '' when the key names none. PURE. */
73
+ export function objOf(x) {
74
+ const id = /^([^:]+)::/.exec(String((x && x.key) || '')); if (!id) return { id: '', token: '' };
75
+ const m = /^o(\d+)$/i.exec(id[1]);
76
+ return { id: id[1], token: m ? 'O' + m[1] : 'O-' + id[1].toUpperCase() };
77
+ }
78
+ /** The line under a row's name on Work › Initiatives: "Serves KR1.1", or the health budget it is anchored to. '' when its anchor names no goal. PURE. */
79
+ export function servesOf(r, R) {
80
+ const k = R && R.of ? R.of[String((r && r.anchor) || '')] : null, x = k && (R.goals || []).find((g) => g.key === k);
81
+ if (!x) return '';
82
+ return 'Serves ' + (x.kind === 'kr' ? x.token || x.title : x.title);
83
+ }
84
+
52
85
  /** The goal's fold, as the program and product heads fold (pm/bd-prog.js fold, data-fold). */
53
86
  export function goalHeadHtml(g, o = {}) {
54
87
  const x = g.goal, open = o.open !== false, steps = o.steps || [], N = steps.length || 8;
@@ -44,6 +44,7 @@ import { sigListHtml } from './bd-views.js'; // the customer signals behind th
44
44
  import * as PW from './cozy-pop-work.js'; // what the popup shows for work (slice 3 of the six-place navigation): in the popup, in place of the old page
45
45
  import * as PP from './ini-props.js'; // everything PMOS suggests, as a drill-in (the popup's ⋯)
46
46
  import { stageName } from './stage-chip.js';
47
+ import * as MS from './ms-strip.js'; // Next milestones on the product and initiative pages (job #2020, Wawan 2026-11-25 13:02Z)
47
48
  import { iniMore as iniMoreOf, iniText, stagePick, deleteSaid, DELETE_MS } from './ini-more.js'; // the one initiative ⋯ menu and stage picker (batch 14 item 5, batch 16 item 5c)
48
49
 
49
50
  let O = null;
@@ -191,13 +192,15 @@ function dashFor(r) {
191
192
  function iniBody(r, body) {
192
193
  const h = dashFor(r);
193
194
  if (h && h.shows()) return h.html(() => '');
194
- if (PW.on(body)) return PW.html(r, viewOf(r), popOpts(r)) + sigListHtml(r);
195
+ // Next milestones for this initiative (job #2020), above its Work breakdown
196
+ const strip = MS.stripHtml([r], 'ini:' + r.key, { sub: 'this initiative', one: true, lw: MS.lineWidth(body), ro: !!window.PMOS_READONLY });
197
+ if (PW.on(body)) return MS.insertStrip(PW.html(r, viewOf(r), popOpts(r)) + sigListHtml(r), strip);
195
198
  const md = (v) => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][+v.slice(5, 7) - 1] + ' ' + +v.slice(8, 10) + (+v.slice(0, 4) !== new Date().getFullYear() ? ' ’' + v.slice(2, 4) : '');
196
199
  const self = !!((O.M() || {}).board || {}).self, M = O.M() || {};
197
200
  // what left the ⋯ for the thing it changes (batch 16 item 5c): the workflow chip, the dashed +, the stage chip, the dates chip, Jira's ↻
198
201
  // the same parts and presses as Home's page (UI grill U1): the next stage is a press, Core documents a fold, the tail under Linked
199
202
  const v = viewOf(r), docs = ((r.id && PAGE.get(r.id)) || {}).docs || [];
200
- return viewHtml(v, { add: !!(r.id && O.addTask), adding: adding === r.key, addHint: adding === r.key && addDates ? md(addDates.start) + ' to ' + md(addDates.due) : '', openTask: !!O.openTask, quick: !!(O.setTask && O.setDates), hold: !!O.hold,
203
+ return strip + viewHtml(v, { add: !!(r.id && O.addTask), adding: adding === r.key, addHint: adding === r.key && addDates ? md(addDates.start) + ' to ' + md(addDates.due) : '', openTask: !!O.openTask, quick: !!(O.setTask && O.setDates), hold: !!O.hold,
201
204
  next: !!(r.id && v.stage.next && O.moreAct && !self && !window.PMOS_READONLY), docs: docs.length ? { n: docs.length } : null, tail: TL.tailHtml(r, { VW, today: M.today }) + sigListHtml(r),
202
205
  wf: !!r.id && !self && !r.ended, person: !!r.id, stagePick: !!r.id, planDates: !!r.id, jira: !!M.jira });
203
206
  }
@@ -224,9 +227,11 @@ function popExtra(r) {
224
227
  }
225
228
  /** The product one level up, in the same popup (board 27): its programs, then the initiatives in no program, with the timeline. A row goes one
226
229
  * level down. Read from the Board's own model, so nothing new is fetched. */
230
+ /** The Board's rows of a product's initiatives. */
231
+ function productRows(ws) { const M = O.M() || {}, B = M.board || {}; return (M.rows || []).filter((x) => x.id && !x.archived && (x.ws || B.ws || '') === ws); }
227
232
  function productOf(ws) {
228
233
  const M = O.M() || {}, B = M.board || {}, today = M.today;
229
- const all = (M.rows || []).filter((x) => x.id && !x.archived && (x.ws || B.ws || '') === ws); // the board's own row (no id) is not work
234
+ const all = productRows(ws); // the board's own row (no id) is not work
230
235
  const progs = new Map(), loose = [];
231
236
  for (const x of all) { const p = O.programOf ? O.programOf(x) : null; if (p) { if (!progs.has(p.id)) progs.set(p.id, { p, rows: [] }); progs.get(p.id).rows.push(x); } else loose.push(x); }
232
237
  const lo = (rs) => rs.map((x) => String(x.start || '').slice(0, 10)).filter(Boolean).sort()[0] || '';
@@ -247,12 +252,16 @@ function openProduct(r) {
247
252
  const M = O.M() || {}, ws = r.ws || (M.board || {}).ws || '';
248
253
  const L0 = productOf(ws);
249
254
  VW.drill();
255
+ // the product's Next milestones (job #2020): its own initiatives, its own window
256
+ const page = (body, L) => MS.insertStrip(PW.levelHtml(L, { today: L.today, add: false }), MS.stripHtml(productRows(ws), 'product:' + ws, { sub: 'this product', lw: MS.lineWidth(body), ro: !!window.PMOS_READONLY }));
250
257
  VW.open({ kind: 'Product', title: L0.title, icon: 'goal', id: 'product:' + ws, back: true,
251
258
  render: (body) => {
252
259
  const L = productOf(ws);
253
- body.innerHTML = PW.levelHtml(L, { today: L.today, add: false });
260
+ body.innerHTML = page(body, L);
261
+ const redraw = () => { const t = body.scrollTop, L2 = productOf(ws); body.innerHTML = page(body, L2); body.scrollTop = t; };
262
+ MS.wireStrip(body, redraw);
254
263
  PW.wireLevel(body, {
255
- redraw: () => { const t = body.scrollTop, L2 = productOf(ws); body.innerHTML = PW.levelHtml(L2, { today: L2.today, add: false }); body.scrollTop = t; },
264
+ redraw,
256
265
  go: (kind, id, b) => { if (kind === 'program' && O.openProgram) { VW.drill(); O.openProgram(id, b); } else if (kind === 'ini' && O.openIniId) { const x = O.rowOf(id); VW.drill(); if (x && x.id) O.openIniId(x.id); } },
257
266
  }, () => productOf(ws));
258
267
  } });
@@ -305,6 +314,7 @@ function wire(body, key) {
305
314
  doc: (path) => O.viewDoc(path, (O.rowOf(key) || {}).ws), // the initiative's own workspace, not the board's (round 3 point 17)
306
315
  redraw,
307
316
  };
317
+ MS.wireStrip(body, redraw); // the Next milestones strip's +N, Fit, wheel and drag (job #2020)
308
318
  // in the popup: what the popup shows for work (pm/cozy-pop-work.js), with the same handlers; else the old page
309
319
  if (PW.on(body)) {
310
320
  PW.wire(body, { ...H, ...popExtra(O.rowOf(key)) }, { r: () => O.rowOf(key), v: () => { const r = O.rowOf(key); return r ? viewOf(r) : null; }, o: () => { const r = O.rowOf(key); return r ? popOpts(r) : {}; } });
@@ -139,3 +139,19 @@ div.pwd-art { cursor: default; }
139
139
  /* the grill run the chat said started: running, or failed and why (pm/grill-words.js runStateLine) */
140
140
  .pwd-grun { margin: var(--space-4) 0 0; color: var(--cz-blueink); }
141
141
  .pwd-grun.bad { color: var(--cz-red); }
142
+
143
+ /* ── Layouts: a new screen's three layouts side by side, the ✦ line under them (three-layouts, A317; BatchDesignDS panel 19) ── */
144
+ .tl-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-8); margin: 0; padding: 0; list-style: none; }
145
+ .tl-tile { display: flex; flex-direction: column; gap: var(--space-8); padding: var(--space-8); border-radius: var(--radius-sm); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
146
+ .tl-tile.on { box-shadow: inset 0 0 0 2px var(--blue); }
147
+ .tl-tile.kept { opacity: .6; }
148
+ .tl-th { gap: var(--space-8); font-size: var(--fs-meta); }
149
+ .tl-bars { display: grid; gap: 3px; }
150
+ .tl-bar { display: block; height: 10px; border-radius: 2px; background: var(--well); }
151
+ .tl-bar.tall { height: 22px; }
152
+ .tl-tile > .pm-btn { align-self: flex-start; }
153
+ .tl-line { margin: 0; }
154
+ /* one ✓ shows, on the recommended tile (panel 19); the other two show theirs on hover or focus, and always on a touch screen */
155
+ .tl-tile:not(.on) > .pm-btn { opacity: 0; transition: opacity var(--duration-quick) var(--ease-out); }
156
+ .tl-tile:hover > .pm-btn, .tl-tile > .pm-btn:focus-visible { opacity: 1; }
157
+ @media (hover: none) { .tl-tile:not(.on) > .pm-btn { opacity: 1; } }
@@ -27,14 +27,16 @@ const kindWord = (l) => (l.kind === 'positioning' ? 'Positioning' : 'Message');
27
27
 
28
28
  /** The part's markup. state = { kept, draft, busy, left, open }. Pure, so the test reads it.
29
29
  * Collapsed (the default): the positioning statement only, and a fold "N key messages" (bdPosMore) that opens the rest. Where a line comes
30
- * from sits in its tooltip, not under it, so the part stays short; a line whose strategy changed still says so. */
30
+ * from sits in its tooltip, not under it, so the part stays short; a line whose strategy changed still says so. state.period (the strategy's
31
+ * OKR period, lib/work-kr.js) puts its label beside the title, "Positioning · H2 2026" (tb-work-kr). */
31
32
  export function partHtml(state) {
32
33
  const kept = Array.isArray(state.kept) ? state.kept : [];
33
34
  const d = state.draft && state.draft.state === 'ready' ? state.draft : null;
34
35
  const pending = state.busy || (state.draft && state.draft.state === 'pending');
35
36
  const keptIds = new Set(kept.map((l) => l.id));
36
37
  const fresh = d ? d.lines.filter((l) => !keptIds.has(l.id) && !(state.left || []).includes(l.id)) : [];
37
- const head = `<div class="head"><h4 class="pm-h-sm" style="flex:1">Positioning${kept.length || fresh.length || pending ? '' : ' <span class="pm-meta">· not drafted yet</span>'}${pending ? ' <span class="pm-meta">· drafting…</span>' : ''}</h4>`
38
+ const per = state.period && state.period.label ? ` <span class="pm-meta" data-pos-period>· ${esc(state.period.label)}</span>` : ''; // tb-work-kr: the period it is for
39
+ const head = `<div class="head"><h4 class="pm-h-sm" style="flex:1">Positioning${per}${kept.length || fresh.length || pending ? '' : ' <span class="pm-meta">· not drafted yet</span>'}${pending ? ' <span class="pm-meta">· drafting…</span>' : ''}</h4>`
38
40
  + (pending ? '' : btn('bdPosDraft', kept.length || d ? I.again : I.spark, kept.length || d ? 'Draft again from the strategy' : 'Draft positioning from the strategy')) + '</div>';
39
41
  const tip = (l) => ` title="${esc(kindWord(l) + ' · ' + fromLine(l))}"`;
40
42
  const keptRow = (l) => `<div class="pm-li" role="listitem" data-pos="${esc(l.id)}"${tip(l)}><span class="txt"><span class="t">${esc(l.text)}</span>${l.stale ? '<span class="w">The strategy changed since you kept this</span>' : ''}</span>${btn('bdPosDrop', I.x, 'Drop this line', 'outline', ` data-id="${esc(l.id)}"`)}</div>`;
@@ -52,12 +54,12 @@ export function partHtml(state) {
52
54
  /** Draw the part into `host` and wire its presses. */
53
55
  export async function mount(host, opts = {}) {
54
56
  if (!host) return;
55
- const { ws = null, say = null } = opts;
57
+ const { ws = null, say = null, period = null } = opts;
56
58
  const q = ws ? '?ws=' + encodeURIComponent(ws) : '';
57
59
  const get = async () => { try { return await (await fetch(API + q, { credentials: 'same-origin' })).json(); } catch { return null; } };
58
60
  const r = await get();
59
61
  if (!r || !r.ok || !r.complete) { host.hidden = true; host.innerHTML = ''; return; } // an extra: no strategy, no part
60
- const S = { kept: r.kept, draft: r.draft, busy: false, left: [], open: host.dataset.open === '1' };
62
+ const S = { kept: r.kept, draft: r.draft, busy: false, left: [], open: host.dataset.open === '1', period };
61
63
  const draw = () => { host.hidden = false; host.innerHTML = partHtml(S); };
62
64
  let tries = 0;
63
65
  const poll = async () => {
@@ -41,6 +41,7 @@ import * as MD from './metric-drafts.js'; // the goal Claude drafts when the c
41
41
  import * as DB from './dash-view.js'; // the page model's parts: the reports and the proposals (batch 17 item 1)
42
42
  import { stageName } from './stage-chip.js'; // W1: the one stage
43
43
  import * as PV from './prog-page.js';
44
+ import * as MS from './ms-strip.js'; // Next milestones on the program page (job #2020, Wawan 2026-11-25 13:02Z)
44
45
  import * as PW from './cozy-pop-work.js'; // in the popup: the program one level up, the same three parts as an initiative (slice 3, board 26) // the one program page: the top and four tabs (batch 21 item 2, canvas RdProgL–RdProgP)
45
46
 
46
47
  const SV = (d, w) => `<svg viewBox="0 0 24 24" width="${w || 18}" height="${w || 18}" aria-hidden="true"><path d="${d}"/></svg>`;
@@ -414,11 +415,11 @@ function draw(keepFocus) {
414
415
  const p = progOf(cur.id); if (!p) { VW.close(); return; }
415
416
  readAway(p); readMore(p); readDrafts(p);
416
417
  const b = VW.body(); if (!b) return;
417
- if (PW.inPop(b)) { const t = b.scrollTop, L = levelOf(cur.id); if (L) { b.innerHTML = PW.levelHtml(L, { today: L.today, add: false }); b.scrollTop = t; } return; } // the program in the popup (board 26)
418
+ if (PW.inPop(b)) { const t = b.scrollTop, L = levelOf(cur.id); if (L) { b.innerHTML = levelPage(b, cur.id, L); b.scrollTop = t; } return; } // the program in the popup (board 26)
418
419
  const f = keepFocus && document.activeElement && b.contains(document.activeElement) ? document.activeElement : null;
419
420
  const sel = f ? (f.dataset.pp ? `[data-pp="${f.dataset.pp}"]` + (f.dataset.fold ? `[data-fold="${CSS.escape(f.dataset.fold)}"]` : '') + (f.dataset.key ? `[data-key="${CSS.escape(f.dataset.key)}"]` : '') + (f.dataset.ms ? `[data-ms="${CSS.escape(f.dataset.ms)}"]` : '') : f.dataset.czsFold ? `[data-czs-fold="${CSS.escape(f.dataset.czsFold)}"]` : null) : null;
420
421
  const top = b.scrollTop;
421
- b.innerHTML = viewHtml(p);
422
+ b.innerHTML = progStrip(b, p.id) + viewHtml(p);
422
423
  b.scrollTop = top;
423
424
  const again = sel && b.querySelector(sel); if (again) again.focus();
424
425
  }
@@ -513,12 +514,21 @@ function levelOf(id) {
513
514
  const doneWhen = lastMs ? lastMs.name.replace(/\.$/, '') + (by ? ', by ' + by : '') + '.' : by ? 'Its initiatives are delivered by ' + by + '.' : '';
514
515
  return { kind: 'program', id: p.id, title: p.title, summary: said, why: p.why || '', goal: p.goal || '', done: doneWhen, facts, rows, docs, today };
515
516
  }
517
+ /** The program's Next milestones (job #2020): the Board's rows of its initiatives, its own window. */
518
+ function progStrip(body, id) {
519
+ const p = progOf(id); if (!p) return '';
520
+ const rows = programState(p, rowsOf).inis.map((i) => i.row).filter(Boolean);
521
+ return MS.stripHtml(rows, 'program:' + id, { sub: 'this program', lw: MS.lineWidth(body), ro: !!window.PMOS_READONLY });
522
+ }
523
+ const levelPage = (body, id, L) => MS.insertStrip(PW.levelHtml(L, { today: L.today, add: false }), progStrip(body, id));
516
524
  function levelDraw(body, id, from) {
517
525
  cur = { id, from: from || (cur && cur.id === id && cur.from) || null };
518
526
  const L = levelOf(id); if (!L) { body.innerHTML = ''; return; }
519
- body.innerHTML = PW.levelHtml(L, { today: L.today, add: false });
527
+ body.innerHTML = levelPage(body, id, L);
528
+ const redraw = () => { const t = body.scrollTop; const L2 = levelOf(id); if (L2) { body.innerHTML = levelPage(body, id, L2); body.scrollTop = t; } };
529
+ MS.wireStrip(body, redraw);
520
530
  PW.wireLevel(body, {
521
- redraw: () => { const t = body.scrollTop; const L2 = levelOf(id); if (L2) { body.innerHTML = PW.levelHtml(L2, { today: L2.today, add: false }); body.scrollTop = t; } },
531
+ redraw,
522
532
  go: (kind, iid) => { if (kind === 'ini') { VW.drill(); O.openIni(iid, null); } },
523
533
  doc: (path) => { const a = document.createElement('button'); a.dataset.doc = path; a.hidden = true; document.body.appendChild(a); a.click(); a.remove(); },
524
534
  art: (a) => { if (!a || !a.charter) return false; const q = progOf(id); if (q) openCharter(q); return true; },
@@ -535,7 +545,8 @@ function oldDraw(body, id, from) {
535
545
  {
536
546
  cur = { id, from: from && !(VW.body() && VW.body().contains(from)) ? from : (cur && cur.id === id && cur.from) || null };
537
547
  body.classList.add('pp-vw');
538
- const q = progOf(id); if (q) { readAway(q); readMore(q); readDrafts(q); body.innerHTML = viewHtml(q); }
548
+ const q = progOf(id); if (q) { readAway(q); readMore(q); readDrafts(q); body.innerHTML = progStrip(body, id) + viewHtml(q); }
549
+ MS.wireStrip(body, () => draw(true));
539
550
  PV.wirePage(body, { redraw: () => draw(true) }); // the tabs and the proposals fold (pm/prog-page.js)
540
551
  { // the reports' and the goals' presses (pm/dash-view.js: listeners once per body, this page's h each time)
541
552
  DB.wireDash(body, { d: () => cur && dashOf(cur.id).d, get open() { return cur ? dashOf(cur.id).open : new Set(); }, ws: (progOf(id) || {}).home || board().ws || '', board: board().id || '',