create-pmos 0.422.0 → 0.424.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 (102) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/board-programs-test.js +28 -0
  8. package/workspace/briefing-premium-adddoc-test.js +1 -1
  9. package/workspace/briefing-premium-board-test.js +12 -10
  10. package/workspace/briefing-premium-initiative-test.js +30 -38
  11. package/workspace/briefing-premium-products-test.js +16 -3
  12. package/workspace/changelog.json +24 -0
  13. package/workspace/guide/briefing-premium.md +1 -1
  14. package/workspace/guide/claude-proposes.md +37 -0
  15. package/workspace/guide/home.md +9 -2
  16. package/workspace/guide/index.md +1 -0
  17. package/workspace/guide/programs.md +1 -0
  18. package/workspace/guide/workflows.md +5 -1
  19. package/workspace/home-pill-test.js +138 -0
  20. package/workspace/ini-workflow-test.js +4 -4
  21. package/workspace/lib/board-premium.js +3 -2
  22. package/workspace/lib/custom-docs.js +65 -3
  23. package/workspace/lib/engine/boards.js +25 -2
  24. package/workspace/lib/headless.js +14 -1
  25. package/workspace/lib/initiative-writer.js +63 -1
  26. package/workspace/lib/plan-items.js +36 -5
  27. package/workspace/lib/pmos-verbs.js +3 -0
  28. package/workspace/lib/programs.js +11 -3
  29. package/workspace/lib/proposal-runs.js +148 -0
  30. package/workspace/lib/proposals.js +370 -0
  31. package/workspace/lib/propose-cli.js +96 -0
  32. package/workspace/lib/route-modules.js +2 -0
  33. package/workspace/lib/routes-board-premium.js +33 -0
  34. package/workspace/lib/routes-boards.js +50 -10
  35. package/workspace/lib/routes-initiatives.js +12 -0
  36. package/workspace/lib/routes-proposals.js +325 -0
  37. package/workspace/lib/routes-task-links.js +336 -0
  38. package/workspace/lib/split-merge-suggest.js +162 -0
  39. package/workspace/lib/split-merge.js +379 -0
  40. package/workspace/lib/task-cli.js +58 -5
  41. package/workspace/lib/task-items.js +14 -2
  42. package/workspace/lib/task-links.js +422 -0
  43. package/workspace/package-lock.json +2 -2
  44. package/workspace/package.json +1 -1
  45. package/workspace/premium-board-actions-test.js +4 -4
  46. package/workspace/premium-core-doc-issue-test.js +2 -2
  47. package/workspace/premium-vw-backlog-test.js +3 -3
  48. package/workspace/premium-vw-item-test.js +3 -3
  49. package/workspace/premium-vw-jira-test.js +6 -6
  50. package/workspace/product-lane-test.js +165 -0
  51. package/workspace/program-panel-test.js +1 -1
  52. package/workspace/public/pm/bd-asks.js +3 -0
  53. package/workspace/public/pm/bd-ini-panel.js +16 -6
  54. package/workspace/public/pm/bd-prog.js +6 -1
  55. package/workspace/public/pm/bd-span.js +69 -15
  56. package/workspace/public/pm/bd-views.js +3 -2
  57. package/workspace/public/pm/cozy-board.css +10 -0
  58. package/workspace/public/pm/cozy-today.css +23 -0
  59. package/workspace/public/pm/cozy-viewer.js +14 -3
  60. package/workspace/public/pm/cozy-vw-shell.css +8 -0
  61. package/workspace/public/pm/home-app.js +45 -14
  62. package/workspace/public/pm/home-ini-model.js +0 -34
  63. package/workspace/public/pm/home-ini.js +72 -204
  64. package/workspace/public/pm/home-task.js +2 -1
  65. package/workspace/public/pm/home-today.js +66 -16
  66. package/workspace/public/pm/ini-groups.js +253 -0
  67. package/workspace/public/pm/ini-links.js +519 -0
  68. package/workspace/public/pm/ini-props.js +218 -0
  69. package/workspace/public/pm/ini-tasks.js +58 -22
  70. package/workspace/public/pm/ini-versions.js +14 -9
  71. package/workspace/public/pm/ini-view-model.js +93 -4
  72. package/workspace/public/pm/ini-view.css +306 -18
  73. package/workspace/public/pm/ini-view.js +161 -36
  74. package/workspace/public/pm/premium-board.js +54 -6
  75. package/workspace/public/pm/premium-vw-item.js +2 -1
  76. package/workspace/public/pm/split-merge.css +77 -0
  77. package/workspace/public/pm/split-merge.js +265 -0
  78. package/workspace/public/pm/stage-line.js +414 -0
  79. package/workspace/public/pm/task-card.css +13 -0
  80. package/workspace/public/pm/task-card.js +42 -5
  81. package/workspace/public/pm/wf-page.css +2 -0
  82. package/workspace/public/pm/wf-page.js +2 -0
  83. package/workspace/public/pm/wf-stage.js +2 -1
  84. package/workspace/server.js +52 -3
  85. package/workspace/skills/initiative-propose.skill +45 -0
  86. package/workspace/split-merge-ui-test.js +175 -0
  87. package/workspace/stage-card-test.js +13 -12
  88. package/workspace/task-card-test.js +3 -2
  89. package/workspace/task-delete-test.js +126 -0
  90. package/workspace/task-links-test.js +239 -0
  91. package/workspace/task-milestones-test.js +1 -1
  92. package/workspace/task-plans-test.js +6 -0
  93. package/workspace/task-views-test.js +1 -1
  94. package/workspace/test-lists/bd-ini-panel.json +8 -2
  95. package/workspace/test-lists/claude-proposes.json +5 -0
  96. package/workspace/test-lists/home-sessions-pill.json +6 -0
  97. package/workspace/test-lists/product-lane.json +6 -0
  98. package/workspace/test-lists/split-merge.json +15 -0
  99. package/workspace/test-lists/task-delete.json +5 -0
  100. package/workspace/test-lists/task-links.json +6 -0
  101. package/workspace/tk-tasks-test.js +186 -57
  102. package/workspace/workflows-setup-test.js +4 -3
@@ -0,0 +1,422 @@
1
+ 'use strict';
2
+ /* task-links.js — links between tasks that move together (feedback batch 11 item 15; canvas In development, row "Task dependencies":
3
+ * DepAGrill, DepA8Suggest, DepA9Adjust, DepA1Timeline–DepA7Phone, DepA0Rules). THE ONE WRITER and THE ONE FOLD of <state>/task-links.jsonl,
4
+ * beside boards.jsonl, and the pure engine that keeps dates in line. lib/routes-task-links.js does the I/O; pm/ini-links.js draws it.
5
+ *
6
+ * A LINK says one task waits on another: { from, to, type, lag }. `from` is the task waited on, `to` the task that waits; each is a task
7
+ * uid (a Board task, a breakdown item) or a Jira key. The four types name the two ends joined, `to`'s bound on the left:
8
+ * fs finish → start `to` starts after `from` finishes (start ≥ from.due + 1 + lag) the default
9
+ * ss start → start `to` starts when `from` starts (start ≥ from.start + lag)
10
+ * ff finish → finish `to` finishes when `from` finishes (due ≥ from.due + lag)
11
+ * sf start → finish `to` finishes when `from` starts (due ≥ from.start + lag)
12
+ * A link that would loop back is refused. Claude never adds a link the PM did not approve: a proposal is only a proposal until ✓.
13
+ *
14
+ * THE RULES (DepAGrill, 16 questions):
15
+ * - Claude proposes links (the PRD's "once", "after", "with"; a Jira ticket's "depends"; the order of the plan; dates that already butt
16
+ * end to start); ✓ each or Add all; ✕ drops one for good, unless its source changes (the signature holds the source).
17
+ * - The PM's own move (a drag, the date picker): the tasks after it move just enough (slack first), and the ones after those; the toast
18
+ * says "Moved N tasks with it" with Undo. Moving earlier moves nothing: Claude proposes "Pull N tasks in".
19
+ * - A date that changes outside a drag (chat, a Jira read, a late task): inside approved links Claude moves the tasks after it quietly,
20
+ * no toast; the grey ✦ chip counts the moves since last seen, Undo all. Per initiative the quiet moves can be turned off: then every
21
+ * such move is a proposal. Claude adjusts Live only, never a draft (a draft's tasks are not here).
22
+ * - Where Claude stops: a promise would move (a ◇ milestone task, the committed end, another initiative's task). It recommends one move:
23
+ * ✓ applies it, ✕ keeps the date and the link turns orange. A Jira ticket never moves: the link turns orange with "!", and Claude
24
+ * drafts a comment to the assignee; ✓ puts it in the outbox. A Done task stays where it is.
25
+ * - A late task keeps its own date (it is a promise); the tasks after it start no earlier than tomorrow, with an orange start edge.
26
+ *
27
+ * THE LEDGER. One line per change, { at, by, kind, ... }:
28
+ * link { board, ini, from, to, type, lag, source } a link the PM approved (✓, Add all, a drag, the joint card, `pmos task link`);
29
+ * the last line for a pair wins, so the joint card's type and lag are a new line
30
+ * unlink { from, to }
31
+ * propose { board, ini, from, to, type, lag, source, why } a link an agent filed for the PM to approve (`pmos task link --propose`)
32
+ * drop { sig } a proposal or a recommendation the PM dropped (✕); a new source is a new signature
33
+ * quiet { ini, on } the PM's switch for the quiet moves of one initiative (on by default)
34
+ * moved { board, ini, batch, via: 'quiet' | 'own' | 'ask', moves: [{ task, title, from: { start, due }, to: { start, due }, why }] }
35
+ * undo { batch } Undo or Undo all of a batch
36
+ * seen { ini } the PM opened the grey chip: the moves before it are seen
37
+ * pull { board, ini, id, after, days, tasks: [task] } "Pull N tasks in": the PM moved `after` earlier by `days`
38
+ * outbox { sig, entry } the drafted Jira comment went to the outbox
39
+ *
40
+ * ledgerFile(dir) · read(dir) → fold · append(dir, actor, line)
41
+ * fold(lines) PURE → { links, proposed, drops, quiet, moved, undone, seen, pulls, sent, t }
42
+ * linksOf(F) · loops(links, from, to) · keyOf(from, to) · TYPES
43
+ * needOf(link, a, today) → { start?, due? } the earliest day numbers `to` may take, given `from` (a)
44
+ * settle(T, links, o) PURE → { moves, asks, clashes } the engine (see below)
45
+ * proposalsOf(ini, T, links, F, src) PURE → [proposal]
46
+ * viewOf(F, ini, T, o) → what r.links carries for the one view (null: nothing to show)
47
+ * decorate(rows, F, items, o) puts r.links on each Board row that has something to show
48
+ */
49
+ const fs = require('fs');
50
+ const path = require('path');
51
+ const crypto = require('crypto');
52
+
53
+ const LEDGER = 'task-links.jsonl';
54
+ const KINDS = new Set(['link', 'unlink', 'propose', 'drop', 'quiet', 'moved', 'undo', 'seen', 'pull', 'outbox']);
55
+ const TYPES = ['fs', 'ss', 'ff', 'sf'];
56
+ const TYPE_WORDS = { fs: 'Finish → start', ss: 'Start → start', ff: 'Finish → finish', sf: 'Start → finish' };
57
+ const CLOSED = new Set(['Done', "Won't do", 'Archived']);
58
+ const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
59
+ const str = (v) => (typeof v === 'string' ? v : '');
60
+ const UID_RE = /^[A-Za-z0-9][A-Za-z0-9:._-]{0,120}$/;
61
+ const MAX_LAG = 365;
62
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
63
+
64
+ /* ── days as whole numbers (UTC) ── */
65
+ const DAY = /^(\d{4})-(\d{2})-(\d{2})/;
66
+ const dn = (iso) => { const m = DAY.exec(String(iso || '')); return m ? Math.round(Date.UTC(+m[1], +m[2] - 1, +m[3]) / 864e5) : null; };
67
+ const isoN = (n) => (n == null ? '' : new Date(n * 864e5).toISOString().slice(0, 10));
68
+ const md = (n) => { if (n == null) return ''; const d = new Date(n * 864e5); return MON[d.getUTCMonth()] + ' ' + d.getUTCDate(); };
69
+ const keyOf = (from, to) => from + '>' + to;
70
+ const hash = (s) => crypto.createHash('sha1').update(String(s)).digest('hex').slice(0, 10);
71
+ const newBatch = () => 'mv-' + crypto.randomBytes(5).toString('hex');
72
+
73
+ /* ── the ledger ── */
74
+ function ledgerFile(dir) { return dir ? path.join(dir, LEDGER) : null; }
75
+ function readLines(file) {
76
+ if (!file) return [];
77
+ let text = '';
78
+ try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
79
+ const out = [];
80
+ for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l) && KINDS.has(l.kind)) out.push(l); } catch { /* a torn line is skipped */ } }
81
+ return out;
82
+ }
83
+ function read(dir) { return fold(readLines(ledgerFile(dir))); }
84
+ function append(dir, actor, ev) {
85
+ const line = { at: new Date().toISOString(), by: (actor && actor.by) || null, ...ev };
86
+ fs.appendFileSync(ledgerFile(dir), JSON.stringify(line) + '\n');
87
+ return line;
88
+ }
89
+
90
+ /** A link's fields, cleaned: → { link } | { error }. */
91
+ function cleanLink(o) {
92
+ if (!isObj(o)) return { error: 'a link is an object' };
93
+ const from = str(o.from), to = str(o.to);
94
+ if (!UID_RE.test(from) || !UID_RE.test(to)) return { error: 'from and to are task ids or Jira keys' };
95
+ if (from === to) return { error: 'A task cannot wait on itself' };
96
+ const type = o.type == null ? 'fs' : str(o.type).toLowerCase();
97
+ if (!TYPES.includes(type)) return { error: 'type is one of ' + TYPES.join(', ') };
98
+ const lag = o.lag == null || o.lag === '' ? 0 : Number(o.lag);
99
+ if (!Number.isInteger(lag) || Math.abs(lag) > MAX_LAG) return { error: `lag is whole days, between -${MAX_LAG} and ${MAX_LAG}` };
100
+ return { link: { from, to, type, lag } };
101
+ }
102
+
103
+ /** PURE. The ledger's lines, in order, into what holds now. */
104
+ function fold(lines) {
105
+ const links = new Map(); // key(from, to) → { from, to, type, lag, source, ini, board, at, by }
106
+ const proposed = new Map(); // key → the agent-filed proposal (until linked, unlinked or dropped)
107
+ const drops = new Set(); // signatures the PM dropped
108
+ const quiet = new Map(); // ini → false when the PM turned the quiet moves off
109
+ const moved = []; // the batches, oldest first
110
+ const undone = new Set(); // batch ids
111
+ const seen = new Map(); // ini → iso of the last time the PM opened the grey chip
112
+ const pulls = new Map(); // id → pull
113
+ const sent = new Map(); // sig → outbox entry id
114
+ let t = '';
115
+ for (const l of lines || []) {
116
+ if (!isObj(l) || !KINDS.has(l.kind)) continue;
117
+ if (l.at && String(l.at) > t) t = String(l.at);
118
+ if (l.kind === 'link' || l.kind === 'propose') {
119
+ const c = cleanLink(l); if (c.error) continue;
120
+ const k = keyOf(c.link.from, c.link.to);
121
+ const x = { ...c.link, source: str(l.source) || 'you', why: str(l.why), ini: str(l.ini), board: str(l.board), at: l.at || null, by: l.by || null };
122
+ if (l.kind === 'link') { links.set(k, x); proposed.delete(k); } else if (!links.has(k)) proposed.set(k, x);
123
+ } else if (l.kind === 'unlink') {
124
+ const k = keyOf(str(l.from), str(l.to)); links.delete(k); proposed.delete(k);
125
+ } else if (l.kind === 'drop' && str(l.sig)) drops.add(l.sig);
126
+ else if (l.kind === 'quiet' && str(l.ini) && typeof l.on === 'boolean') { if (l.on) quiet.delete(l.ini); else quiet.set(l.ini, false); }
127
+ else if (l.kind === 'moved' && str(l.batch) && Array.isArray(l.moves)) moved.push({ batch: l.batch, ini: str(l.ini), board: str(l.board), via: str(l.via) || 'quiet', at: l.at || null, moves: l.moves.filter(isObj) });
128
+ else if (l.kind === 'undo' && str(l.batch)) undone.add(l.batch);
129
+ else if (l.kind === 'seen' && str(l.ini)) seen.set(l.ini, l.at || '');
130
+ else if (l.kind === 'pull' && str(l.id)) pulls.set(l.id, { id: l.id, ini: str(l.ini), board: str(l.board), after: str(l.after), days: Number(l.days) || 0, tasks: Array.isArray(l.tasks) ? l.tasks.filter((x) => typeof x === 'string') : [], at: l.at || null });
131
+ else if (l.kind === 'outbox' && str(l.sig)) sent.set(l.sig, str(l.entry));
132
+ }
133
+ for (const k of proposed.keys()) { const p = proposed.get(k); if (drops.has(sigOf(p))) proposed.delete(k); }
134
+ return { links, proposed, drops, quiet, moved, undone, seen, pulls, sent, t };
135
+ }
136
+ const linksOf = (F) => [...F.links.values()];
137
+
138
+ /** Would from → to close a loop? (to already reaches from along the links.) */
139
+ function loops(links, from, to) {
140
+ const next = new Map();
141
+ for (const l of links) { if (!next.has(l.from)) next.set(l.from, []); next.get(l.from).push(l.to); }
142
+ const seen = new Set([to]), q = [to];
143
+ while (q.length) { const a = q.shift(); if (a === from) return true; for (const b of next.get(a) || []) if (!seen.has(b)) { seen.add(b); q.push(b); } }
144
+ return false;
145
+ }
146
+
147
+ /* ── the engine ── */
148
+ /** A task as the engine reads it, from a work item (routes-boards itemsOf) or a Board row's task: day numbers and what it may do. */
149
+ function taskOf(x) {
150
+ const s = dn(x.start), e = dn(x.end != null ? x.end : x.due);
151
+ return { uid: x.uid || x.key, title: str(x.title), ini: str(x.ini), status: str(x.status) || 'To do', s: s == null ? e : s, e: e == null ? s : e,
152
+ jira: x.src === 'jira' || !!x.jira, ms: !!x.milestone, closed: CLOSED.has(x.status), item: !!x.item || x.store === 'item' };
153
+ }
154
+ /** The dates the engine reads `a` at: a late open task keeps its own date, but what waits on it cannot start before tomorrow. */
155
+ function effOf(a, today) {
156
+ if (a.closed || today == null) return { s: a.s, e: a.e };
157
+ const late = a.e != null && a.e < today, unstarted = a.status === 'To do' && a.s != null && a.s < today;
158
+ return { s: unstarted ? today : a.s, e: late ? today : a.e };
159
+ }
160
+ /** The earliest day numbers `to` may take, given `from` (a, as the engine reads it). */
161
+ function needOf(l, a, today) {
162
+ const e = effOf(a, today), lag = l.lag || 0;
163
+ if (l.type === 'fs') return e.e == null ? {} : { start: e.e + 1 + lag };
164
+ if (l.type === 'ss') return e.s == null ? {} : { start: e.s + lag };
165
+ if (l.type === 'ff') return e.e == null ? {} : { due: e.e + lag };
166
+ return e.s == null ? {} : { due: e.s + lag };
167
+ }
168
+ /** How many days `b` must move later to meet the need (0: it meets it). */
169
+ function shortOf(need, b) {
170
+ let d = 0;
171
+ if (need.start != null && b.s != null) d = Math.max(d, need.start - b.s);
172
+ if (need.due != null && b.e != null) d = Math.max(d, need.due - b.e);
173
+ return d;
174
+ }
175
+ /** Is moving `b` a promise only the PM's ✓ moves? o: { ini, limit (day number: the committed end) } → the reason, or ''. */
176
+ function promiseOf(b, to, o) {
177
+ if (b.ms) return 'milestone';
178
+ if (o.ini && b.ini && b.ini !== o.ini) return 'other';
179
+ if (o.limit != null && to.e != null && to.e > o.limit && (b.e == null || b.e <= o.limit)) return 'end';
180
+ return '';
181
+ }
182
+
183
+ /**
184
+ * PURE. Keep the links: move what waits, just enough, from the seeds outward (all the links' tasks when no seed is given).
185
+ * T Map uid → task (taskOf), the tasks the links name; a uid not in T is not known here and is left alone
186
+ * links [link] the approved links
187
+ * o { seeds?: [uid], today (day number), ini (the initiative the move started in), limit?: (ini) → day number | null,
188
+ * mode: 'own' (the PM's drag: no toast here) | 'quiet', allow?: Set uid (a promise the PM's ✓ lets move) }
189
+ * → { moves: [{ uid, from: { s, e }, to: { s, e }, after, link }], asks: [{ uid, kind: 'promise', why, to: { s, e }, after, link }],
190
+ * clashes: [{ uid, kind: 'jira' | 'done', need, days, after, link }] }
191
+ * A move keeps the task's length. A Done task, a Jira ticket and a promise are not moved; what waits on them is not moved by this pass.
192
+ */
193
+ function settle(T, links, o = {}) {
194
+ const out = { moves: [], asks: [], clashes: [] };
195
+ const cur = new Map(); for (const [k, v] of T) cur.set(k, { ...v });
196
+ const by = new Map(); for (const l of links) { if (!by.has(l.from)) by.set(l.from, []); by.get(l.from).push(l); }
197
+ const allow = o.allow || new Set(), today = o.today == null ? null : o.today;
198
+ const q = (o.seeds && o.seeds.length ? o.seeds : [...new Set(links.map((l) => l.from))]).filter((u) => cur.has(u));
199
+ const asked = new Set(), clashed = new Set();
200
+ let guard = 0;
201
+ while (q.length && guard++ < 5000) {
202
+ const a = cur.get(q.shift());
203
+ for (const l of by.get(a.uid) || []) {
204
+ const b = cur.get(l.to); if (!b) continue;
205
+ const need = needOf(l, a, today), d = shortOf(need, b);
206
+ if (d <= 0) continue;
207
+ const to = { s: b.s == null ? null : b.s + d, e: b.e == null ? null : b.e + d };
208
+ if (b.closed || b.jira) { const k = l.from + '>' + l.to; if (!clashed.has(k)) { clashed.add(k); out.clashes.push({ uid: b.uid, kind: b.jira ? 'jira' : 'done', need, days: d, after: a.uid, link: l }); } continue; }
209
+ const p = allow.has(b.uid) ? '' : promiseOf(b, to, { ini: o.ini, limit: o.limit ? o.limit(b.ini) : null });
210
+ if (p) { if (!asked.has(b.uid)) { asked.add(b.uid); out.asks.push({ uid: b.uid, kind: 'promise', why: p, from: { s: b.s, e: b.e }, to, days: d, after: a.uid, link: l }); } continue; }
211
+ const prev = out.moves.find((m) => m.uid === b.uid);
212
+ if (prev) { prev.to = to; prev.after = a.uid; prev.link = l; } else out.moves.push({ uid: b.uid, from: { s: b.s, e: b.e }, to, after: a.uid, link: l });
213
+ cur.set(b.uid, { ...b, s: to.s, e: to.e });
214
+ q.push(b.uid);
215
+ }
216
+ }
217
+ return out;
218
+ }
219
+ /** The tasks a move earlier leaves room for: what waited tight on `uid` (and tight on those) and can come in by up to `days`. PURE. */
220
+ function pullOf(T, links, uid, days, today) {
221
+ const by = new Map(); for (const l of links) { if (!by.has(l.from)) by.set(l.from, []); by.get(l.from).push(l); }
222
+ const out = [], seen = new Set([uid]), q = [{ u: uid, n: days }];
223
+ while (q.length) {
224
+ const { u, n } = q.shift(), a = T.get(u); if (!a) continue;
225
+ for (const l of by.get(u) || []) {
226
+ const b = T.get(l.to); if (!b || seen.has(b.uid) || b.closed || b.jira || b.ms || b.ini !== a.ini || b.status !== 'To do') continue;
227
+ // the room: how far b may come in now that a moved earlier (a is read at its new dates)
228
+ const need = needOf(l, a, today);
229
+ let room = 0;
230
+ if (need.start != null && b.s != null) room = b.s - need.start;
231
+ else if (need.due != null && b.e != null) room = b.e - need.due;
232
+ const m = Math.min(n, room);
233
+ if (m <= 0 || (today != null && b.s != null && b.s - m <= today)) continue;
234
+ seen.add(b.uid); out.push({ uid: b.uid, days: m });
235
+ T.set(b.uid, { ...b, s: b.s == null ? null : b.s - m, e: b.e == null ? null : b.e - m });
236
+ q.push({ u: b.uid, n: m });
237
+ }
238
+ }
239
+ return out;
240
+ }
241
+
242
+ /* ── what Claude proposes ── */
243
+ const STOP = new Set(['with', 'from', 'that', 'this', 'into', 'once', 'after', 'when', 'then', 'their', 'there', 'have', 'been', 'will', 'each', 'every', 'plan', 'task', 'tasks', 'about', 'before', 'until', 'which', 'what', 'them', 'they', 'also', 'only', 'more', 'than', 'over', 'under', 'whether']);
244
+ const words = (s) => String(s || '').toLowerCase().replace(/[^a-z0-9]+/g, ' ').split(' ').filter((w) => w.length >= 4 && !STOP.has(w));
245
+ /** The task a piece of text names: the one whose title shares the most words with it — 2 at least, or 1 that no other title has. */
246
+ function namedIn(text, tasks) {
247
+ const ws = new Set(words(text)), seen = new Map();
248
+ for (const t of tasks) for (const w of new Set(words(t.title))) seen.set(w, (seen.get(w) || 0) + 1);
249
+ let best = null, score = 0;
250
+ for (const t of tasks) {
251
+ const tw = [...new Set(words(t.title))]; if (!tw.length) continue;
252
+ const hit = tw.filter((w) => ws.has(w));
253
+ const ok = hit.length >= 2 || (hit.length === 1 && hit[0].length >= 5 && seen.get(hit[0]) === 1);
254
+ if (ok && hit.length > score) { best = t; score = hit.length; }
255
+ }
256
+ return best;
257
+ }
258
+ /** The PRD's sentences that say an order: "B once A", "B after A", "after A, B", "B with A". → [{ from, to, type, text }] */
259
+ function prdOrders(text, tasks) {
260
+ const out = [];
261
+ const body = String(text || '').replace(/^---\n[\s\S]*?\n---\n?/, '').replace(/[`*_>#|]/g, ' ');
262
+ for (const raw of body.split(/(?<=[.!?;])\s+|\n+/)) {
263
+ const s = raw.replace(/\s+/g, ' ').trim(); if (s.length < 12 || s.length > 400) continue;
264
+ let m = /^(?:only\s+)?(?:once|after|when)\s+(.+?),\s*(.+)$/i.exec(s);
265
+ let A = null, Bt = null, type = 'fs';
266
+ if (m) { A = m[1]; Bt = m[2]; }
267
+ else if ((m = /^(.+?)\s+(?:only\s+)?(?:once|after)\s+(.+)$/i.exec(s))) { Bt = m[1]; A = m[2]; }
268
+ else if ((m = /^(.+?)\s+(?:together\s+)?with\s+(.+)$/i.exec(s))) { Bt = m[1]; A = m[2]; type = 'ff'; }
269
+ if (!m) continue;
270
+ const a = namedIn(A, tasks), b = namedIn(Bt, tasks);
271
+ if (a && b && a.uid !== b.uid) out.push({ from: a.uid, to: b.uid, type, text: s.length > 110 ? s.slice(0, 107) + '…' : s });
272
+ }
273
+ return out;
274
+ }
275
+ /** A proposal's signature: the pair, the type and its source, so a new source (a new PRD line, new dates) is proposed again. */
276
+ function sigOf(p) { return 'p:' + keyOf(p.from, p.to) + ':' + p.type + ':' + hash(p.source + '|' + (p.why || '')); }
277
+
278
+ /**
279
+ * PURE. What Claude proposes for one initiative, newest knowledge first; never a pair already linked (either way), a loop, a closed task,
280
+ * or a proposal the PM dropped (same source).
281
+ * T Map uid → task (taskOf) — this initiative's open tasks and tickets
282
+ * src { prd: text | '', jira: [{ id, key, depends: [id] }], order: [{ uid, order, section }] }
283
+ */
284
+ function proposalsOf(ini, T, links, F, src = {}) {
285
+ const out = [], have = new Set();
286
+ for (const l of links) { have.add(keyOf(l.from, l.to)); have.add(keyOf(l.to, l.from)); }
287
+ const mine = [...T.values()].filter((t) => t.ini === ini && !t.closed);
288
+ const push = (p) => {
289
+ const k = keyOf(p.from, p.to);
290
+ if (have.has(k) || out.some((x) => keyOf(x.from, x.to) === k || keyOf(x.to, x.from) === k)) return;
291
+ const a = T.get(p.from), b = T.get(p.to); if (!a || !b || a.closed || b.closed) return;
292
+ if (loops(links, p.from, p.to)) return;
293
+ const sig = sigOf(p); if (F.drops.has(sig)) return;
294
+ out.push({ ...p, lag: p.lag || 0, id: sig });
295
+ };
296
+ // filed by an agent (the PM asked in chat for a proposal)
297
+ for (const p of F.proposed.values()) if (p.ini === ini || T.has(p.to)) push({ from: p.from, to: p.to, type: p.type, lag: p.lag, source: 'agent', why: p.why || 'Proposed in chat' });
298
+ // the PRD's words
299
+ for (const p of prdOrders(src.prd, mine)) push({ from: p.from, to: p.to, type: p.type, source: 'prd', why: 'PRD: “' + p.text + '”' });
300
+ // Jira: a drafted ticket that depends on another
301
+ const keyOfId = new Map((src.jira || []).filter((t) => t.key).map((t) => [t.id, t.key]));
302
+ for (const t of src.jira || []) for (const d of t.depends || []) { const a = keyOfId.get(d); if (a && t.key) push({ from: a, to: t.key, type: 'fs', source: 'jira', why: 'Jira: ' + t.key + ' depends on ' + a }); }
303
+ // the order of the plan: one breakdown item after the one before it, in one section, where the dates agree
304
+ const ord = (src.order || []).filter((x) => T.has(x.uid)).sort((x, y) => String(x.section).localeCompare(String(y.section)) || x.order - y.order);
305
+ for (let i = 1; i < ord.length; i++) {
306
+ if (ord[i].section !== ord[i - 1].section) continue;
307
+ const a = T.get(ord[i - 1].uid), b = T.get(ord[i].uid);
308
+ if (a.e != null && b.s != null && a.e < b.s) push({ from: a.uid, to: b.uid, type: 'fs', source: 'plan', why: 'The order of the plan' });
309
+ }
310
+ // dates that already butt end to start (the next day, or over a weekend)
311
+ // (one per task each way: a task that already waits on one, or is already waited on, is left out — a guess, not a web)
312
+ const dated = mine.filter((t) => t.s != null && t.e != null && !t.jira), took = new Set();
313
+ for (const l of links) { took.add('to:' + l.to); took.add('from:' + l.from); }
314
+ for (const p of out) { took.add('to:' + p.to); took.add('from:' + p.from); }
315
+ for (const b of dated.slice().sort((x, y) => x.s - y.s)) {
316
+ if (took.has('to:' + b.uid)) continue;
317
+ const a = dated.find((x) => x !== b && !took.has('from:' + x.uid) && (b.s - x.e === 1 || (new Date(x.e * 864e5).getUTCDay() === 5 && b.s - x.e === 3)));
318
+ if (!a) continue;
319
+ const n = out.length;
320
+ push({ from: a.uid, to: b.uid, type: 'fs', source: 'dates', why: 'The dates meet: ' + clip(a.title, 40) + ' ends ' + md(a.e) + ', ' + clip(b.title, 40) + ' starts ' + md(b.s) });
321
+ if (out.length > n) { took.add('to:' + b.uid); took.add('from:' + a.uid); }
322
+ }
323
+ return out.slice(0, 30);
324
+ }
325
+ const clip = (s, n) => { s = String(s || ''); return s.length > n ? s.slice(0, n - 1) + '…' : s; };
326
+
327
+ /**
328
+ * What r.links carries for one initiative, or null when nothing is linked, proposed or waiting:
329
+ * { links: [{ from, to, type, lag, source, other?: { ini, title }, state: 'ok' | 'late' | 'jira' | 'promise' | 'done' }],
330
+ * proposals: [{ id, from, to, type, lag, source, why, kind: 'link' | 'pull' | 'move', ... }],
331
+ * moved: { n, batches: [{ batch, at, moves }], tasks: [uid] } the quiet moves since the PM last opened the grey chip
332
+ * asks: [{ id, kind: 'promise' | 'jira', task, why, to: { start, due }, after, text }] "Needs you"
333
+ * late: [uid] the tasks that wait on a late task (orange start edge)
334
+ * quiet: true | false }
335
+ * o: { today (iso), T (Map of every task the links name), limit(ini), titles: Map uid → { ini, title }, src }
336
+ */
337
+ function viewOf(F, ini, o) {
338
+ const T = o.T, today = dn(o.today);
339
+ const mineL = linksOf(F).filter((l) => (T.get(l.from) && T.get(l.from).ini === ini) || (T.get(l.to) && T.get(l.to).ini === ini));
340
+ const all = linksOf(F).filter((l) => T.has(l.from) && T.has(l.to));
341
+ // the state of each link now: met, or why not
342
+ const late = new Set();
343
+ const links = mineL.map((l) => {
344
+ const a = T.get(l.from), b = T.get(l.to);
345
+ const x = { from: l.from, to: l.to, type: l.type, lag: l.lag, source: l.source, state: 'ok' };
346
+ const oth = a && a.ini !== ini ? a : b && b.ini !== ini ? b : null;
347
+ if (oth) x.other = { ini: oth.ini, title: oth.title, tile: (oth.ini || '').slice(0, 2).toUpperCase() };
348
+ else if (!a || !b) x.other = { ini: '', title: (o.titles && o.titles.get(!a ? l.from : l.to)) || (!a ? l.from : l.to), tile: '' };
349
+ if (!a || !b) return x;
350
+ const d = shortOf(needOf(l, a, today), b);
351
+ const aLate = !a.closed && a.e != null && today != null && a.e < today;
352
+ if (aLate && !b.closed) { x.state = 'late'; late.add(b.uid); }
353
+ if (d > 0) x.state = b.jira ? 'jira' : b.closed ? 'done' : promiseOf(b, { e: b.e + d }, { ini, limit: o.limit ? o.limit(b.ini) : null }) || b.ms ? 'promise' : aLate ? 'late' : 'short';
354
+ return x;
355
+ });
356
+ // the late chain: everything downstream of a late task
357
+ const by = new Map(); for (const l of all) { if (!by.has(l.from)) by.set(l.from, []); by.get(l.from).push(l.to); }
358
+ const q = [...late]; while (q.length) { const u = q.shift(); for (const v of by.get(u) || []) { const t = T.get(v); if (t && !t.closed && !late.has(v)) { late.add(v); q.push(v); } } }
359
+ // Needs you: what keeping a link would move that only the PM moves, and a Jira ticket a link says starts too early
360
+ const asks = [];
361
+ const S = settle(T, all.filter((l) => T.get(l.from).ini === ini || T.get(l.to).ini === ini), { today, ini, mode: 'quiet', limit: o.limit });
362
+ for (const a of S.asks) {
363
+ const b = T.get(a.uid), id = 'a:' + a.uid + ':' + isoN(a.to.s) + ':' + isoN(a.to.e);
364
+ if (F.drops.has(id)) continue;
365
+ const word = a.why === 'milestone' ? 'It is a milestone (' + md(b.e) + ')' : a.why === 'other' ? 'It is in another initiative' : 'It would end after the committed date';
366
+ asks.push({ id, kind: 'promise', why: a.why, task: a.uid, title: b.title, ms: b.ms, days: a.days, to: { start: isoN(a.to.s), due: isoN(a.to.e) }, after: a.after,
367
+ text: word + '. Claude recommends moving it ' + (a.days === 1 ? 'a day' : a.days + ' days') + '; ' + clip((T.get(a.after) || {}).title, 40) + ' needs it.' });
368
+ }
369
+ for (const c of S.clashes) {
370
+ if (c.kind !== 'jira') continue;
371
+ const b = T.get(c.uid), a = T.get(c.after), id = 'j:' + c.uid + ':' + c.link.from + ':' + isoN(b.s);
372
+ if (F.drops.has(id)) continue;
373
+ const want = c.need.start != null ? c.need.start : b.s + c.days;
374
+ asks.push({ id, kind: 'jira', task: c.uid, title: b.title, days: c.days, after: c.after, sent: F.sent.has(id),
375
+ head: c.uid + ' starts ' + md(b.s) + ', ' + (c.days === 1 ? 'a day' : c.days + ' days') + ' too early',
376
+ text: 'Jira, so PMOS can’t move it. Claude drafted a comment asking to start ' + md(want) + '.',
377
+ comment: 'Could ' + c.uid + ' start on ' + md(want) + ' or later? It waits on "' + clip(a ? a.title : c.after, 80) + '", which finishes ' + md(effOf(a, today).e) + '.' });
378
+ }
379
+ // the proposals: Claude's links, Pull N tasks in, and (with the quiet moves off) the moves Claude would have made
380
+ const proposals = o.withProposals === false ? [] : proposalsOf(ini, T, all, F, o.src || {}).map((p) => ({ ...p, kind: 'link' }));
381
+ for (const p of F.pulls.values()) {
382
+ if (p.ini !== ini || F.drops.has('u:' + p.id)) continue;
383
+ const ok = p.tasks.filter((u) => T.has(u) && !T.get(u).closed);
384
+ if (!ok.length) continue;
385
+ proposals.unshift({ id: 'u:' + p.id, kind: 'pull', days: p.days, tasks: ok, after: p.after, why: 'You moved ' + clip((T.get(p.after) || {}).title || p.after, 40) + ' earlier' });
386
+ }
387
+ const quiet = !F.quiet.has(ini);
388
+ if (!quiet) {
389
+ const mv = S.moves;
390
+ if (mv.length) {
391
+ const id = 'm:' + hash(mv.map((m) => m.uid + isoN(m.to.s) + isoN(m.to.e)).join('|'));
392
+ if (!F.drops.has(id)) proposals.unshift({ id, kind: 'move', tasks: mv.map((m) => ({ task: m.uid, title: (T.get(m.uid) || {}).title, to: { start: isoN(m.to.s), due: isoN(m.to.e) }, from: { start: isoN(m.from.s), due: isoN(m.from.e) } })), why: 'To keep your links' });
393
+ }
394
+ }
395
+ // the quiet moves since the PM last looked
396
+ const since = F.seen.get(ini) || '';
397
+ const batches = F.moved.filter((b) => b.ini === ini && b.via === 'quiet' && !F.undone.has(b.batch) && String(b.at || '') > since).reverse();
398
+ const movedTasks = [...new Set(batches.flatMap((b) => b.moves.map((m) => m.task)))];
399
+ const moved = { n: batches.reduce((n, b) => n + b.moves.length, 0), batches, tasks: movedTasks };
400
+ if (!links.length && !proposals.length && !moved.n && !asks.length) return quiet ? null : { links, proposals, moved, asks, late: [], quiet, t: F.t };
401
+ return { links, proposals, moved, asks, late: [...late], quiet, t: F.t };
402
+ }
403
+
404
+ /** Each Board row's r.links (null rows are left as they are). items: the board's work items (Jira tickets too). o: { today, src(ini) } */
405
+ function decorate(rows, F, items, o = {}) {
406
+ if (!F || (!F.links.size && !F.proposed.size && !F.moved.length && !F.pulls.size && !o.src)) return rows;
407
+ const T = new Map();
408
+ for (const w of items || []) { if (!w || w.kind === 'Epic' || !(w.uid || w.key)) continue; const t = taskOf(w); T.set(t.uid, t); }
409
+ const ends = new Map(); for (const r of rows || []) if (r && r.id && r.end) ends.set(r.id, dn(r.end));
410
+ for (const r of rows || []) {
411
+ if (!r || !r.id || r.links !== undefined) continue;
412
+ let v = null;
413
+ try { v = viewOf(F, r.id, { T, today: o.today, limit: (ini) => (ends.has(ini) ? ends.get(ini) : null), src: o.src ? o.src(r.id, T) : {} }); } catch { v = null; }
414
+ if (v) r.links = v;
415
+ }
416
+ return rows;
417
+ }
418
+
419
+ module.exports = {
420
+ LEDGER, TYPES, TYPE_WORDS, ledgerFile, read, readLines, append, fold, cleanLink, linksOf, loops, keyOf, sigOf, taskOf, effOf, needOf, shortOf,
421
+ settle, pullOf, proposalsOf, prdOrders, viewOf, decorate, newBatch, dn, isoN, md, hash,
422
+ };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.422.0",
3
+ "version": "0.424.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.422.0",
9
+ "version": "0.424.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.422.0",
3
+ "version": "0.424.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",
@@ -51,7 +51,7 @@ const lines = (name) => {
51
51
  /** A press on a choice chip inside the dialog's pane, as a click event on the element (Playwright's pointer check races the dialog's spring). */
52
52
  const tap = (pg, sel) => pg.$eval(sel, (b) => b.click());
53
53
  // the Board's first questions (board-grill: start, file, answer, later) write only triage-answers.jsonl and the material folder; intake/draft only drafts
54
- const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive)|lifecycle|briefing-premium\/note|board-grill\/(?:start|file|answer|later)|intake\/draft|initiative-layout)$/; // initiative-layout: the card's Moves on by itself switch (premium-uncovered-features)
54
+ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive)|lifecycle|briefing-premium\/note|board-grill\/(?:start|file|answer|later)|intake\/draft|initiative-layout|proposals\/look)$/; // initiative-layout: the card's Moves on by itself switch (premium-uncovered-features); proposals/look: Create asks Claude to look for the new initiative elsewhere (batch 12 item 4)
55
55
 
56
56
  (async () => {
57
57
  const exe = findBrowser();
@@ -191,10 +191,10 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
191
191
  Stage view; the card moves a stage with Move and Back (premium-uncovered-features, canvas InStage) */
192
192
  const I = await open('/premium-initiative.html?id=pa-one&ws=' + encodeURIComponent(B.ws) + '&board=' + encodeURIComponent(B.id));
193
193
  const ip = I.page;
194
- const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
194
+ const viaMore = async (pg, label) => { const it = (l) => `#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${l}"))`, more = async () => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); }; await more(); for (let i = 0; i < 20 && !(await pg.$(it(label))) && !(await pg.$(it('Move to a stage'))); i++) { await pg.keyboard.press('Escape'); await pg.waitForTimeout(250); await more(); } if (!(await pg.$(it(label))) && (await pg.$(it('Move to a stage')))) { await pg.click(it('Move to a stage')); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v="stage"]'))); if (label === 'Stage') return; await more(); } await pg.click(it(label)); }; // the page's ⋯ holds Move to a stage; the Stage view's ⋯ holds Documents, Open the full record and Sprint (batch 11 item 20)
195
195
  const landed = await until(() => ip.evaluate(() => { const q = new URLSearchParams(location.search); return location.pathname === '/premium.html' && q.get('ini') === 'pa-one' && !!q.get('ws') && !!q.get('board') && !!document.querySelector('#czViewer .iv-sc'); }), 60000);
196
196
  ok('I0 the expand link lands on Home with the initiative selected, ws and board kept', !!landed, await ip.evaluate(() => location.href));
197
- await ip.click('#czViewer [data-cz-vw="more"]').then(() => ip.click('.cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("All tasks"))')); // the initiative's page (canvas HbC): its + drills into Tasks
197
+ // the page holds the Tasks (batch 11 item 20)
198
198
  await until(() => ip.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]')), 60000);
199
199
  await (async (pg) => { if (await pg.$('#czViewer [data-hi-view="stage"]')) await pg.click('#czViewer [data-hi-view="stage"]'); else await viaMore(pg, 'Stage'); })(ip);
200
200
  const bar = await until(() => ip.evaluate(() => { const v = document.querySelector('#czViewer:not([hidden])'); if (!v || !v.querySelector('[data-ov-move]')) return null; const cur = v.querySelector('[data-ov-move][aria-pressed="true"]'); return { moves: [...v.querySelectorAll('[data-ov-move]')].map((x) => x.dataset.ovMove), cur: cur ? cur.dataset.ovMove : '', life: [...v.querySelectorAll('[data-ov-life]')].map((x) => x.dataset.ovLife) }; }), 60000);
@@ -247,7 +247,7 @@ const ALLOWED = /^\/api\/(?:boards\/(?:asks\/(?:add|accept|decline)|move|archive
247
247
  /* P the POST allow-list and the refusals */
248
248
  const all = P.posts.concat(I.posts);
249
249
  const other = all.filter((x) => !ALLOWED.test(x.path) && x.path !== '/api/briefing-premium/seen'); // an opened popup's record (popup context slice 11, R1) is not a press
250
- ok('P1 the pages post only to the asks, move, lifecycle, archive and initiative-layout routes', all.length > 10 && !other.length, JSON.stringify(other));
250
+ ok('P1 the pages post only to the asks, move, lifecycle, archive, initiative-layout and proposals/look routes', all.length > 10 && !other.length, JSON.stringify(other));
251
251
  const noNonce = await post('/api/boards/move', { id: 'fx-bare', to: ready.model.board.stages[1] }, { 'Content-Type': 'application/json', Origin: BASE });
252
252
  const lifeNo = await post('/api/lifecycle', { initiative_id: 'fx-bare', state: 'on-hold' }, { 'Content-Type': 'application/json', Origin: BASE });
253
253
  ok('P2 a press without the launch nonce is refused', noNonce.status === 403 && lifeNo.status === 403, JSON.stringify([noNonce.status, lifeNo.status]));
@@ -114,11 +114,11 @@ const BODY = '## Purpose\n\nWhy this board exists.\n\n## Scope\n\nWhat it covers
114
114
  and a draft opens a minimal reader in the Viewer (Waiting for design) with the Issue it bar, Read and Edit */
115
115
  // Documents is shell A (XvADocs): its groups after the first are folded, so a row is unfolded before it is pressed
116
116
  const unfold = (p, sel) => p.evaluate((q) => { const n = document.querySelector(q); const f = n && !n.offsetParent && n.closest('.czs-sec') && n.closest('.czs-sec').querySelector('[data-czs-fold]'); if (f) f.click(); }, sel);
117
- const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
117
+ const viaMore = async (pg, label) => { const it = (l) => `#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${l}"))`, more = async () => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); }; await more(); for (let i = 0; i < 20 && !(await pg.$(it(label))) && !(await pg.$(it('Move to a stage'))); i++) { await pg.keyboard.press('Escape'); await pg.waitForTimeout(250); await more(); } if (!(await pg.$(it(label))) && (await pg.$(it('Move to a stage')))) { await pg.click(it('Move to a stage')); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v="stage"]'))); if (label === 'Stage') return; await more(); } await pg.click(it(label)); }; // the page's ⋯ holds Move to a stage; the Stage view's ⋯ holds Documents, Open the full record and Sprint (batch 11 item 20)
118
118
  // the initiative's page (canvas HbC): its list row opens it again when the Viewer shows something else
119
119
  const ovOpen = async (p) => { await until(() => p.evaluate(() => !!document.querySelector('#hmList [data-hm-sel^="i:"][aria-current="true"]')), 60000);
120
120
  if (!(await p.$('#czViewer:not([hidden]) [data-hi-v="page"]'))) await p.click('#hmList [data-hm-sel^="i:"][aria-current="true"]');
121
- await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-hi-v="page"] .iv')), 60000); await p.click('#czViewer [data-cz-vw="more"]').then(() => p.click('.cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("All tasks"))')); // the initiative's page (canvas HbC): its + drills into Tasks
121
+ await until(() => p.evaluate(() => !!document.querySelector('#czViewer [data-hi-v="page"] .iv')), 60000); // the page holds the Tasks (batch 11 item 20)
122
122
  // the Overview opens on Tasks; the core documents are its Documents view (premium-uncovered-features, canvas InDocs)
123
123
  if (await until(() => p.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]')), 30000)) await (async (pg) => { if (await pg.$('#czViewer [data-hi-view="docs"]')) await pg.click('#czViewer [data-hi-view="docs"]'); else await viaMore(pg, 'Documents'); })(p); };
124
124
  const I = await open('/premium-initiative.html' + iq), ip = I.page;
@@ -58,13 +58,13 @@ const SPRINTS = { ok: true, source: 'jira', readAt: '2026-10-19T09:00:00Z', velo
58
58
  await page.goto(BASE + '/premium-initiative.html?id=self-serve-v2&ws=w1&board=w1&theme=' + theme);
59
59
  // the Board's expand link lands on Home's initiative layout (premium-agreed-design); its Overview has the Sprint press, and the Viewer shows one item at a time
60
60
  S.up = await until(() => page.evaluate(() => !!document.querySelector('#czViewer .iv-sc') && !!window.__premiumViewer && !!window.__premiumVwJira), 20000);
61
- if (S.up) { await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .iv', { timeout: 30000 }); })(page); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ await page.click('#czViewer [data-cz-vw="more"]').then(() => page.click('.cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("All tasks"))')); /* the initiative's page (canvas HbC): its + drills into Tasks */ S.up = await until(() => page.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]'))); }
61
+ if (S.up) { await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .iv', { timeout: 30000 }); })(page); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ /* the page holds the Tasks (batch 11 item 20) */ S.up = await until(() => page.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]'))); }
62
62
  S.reads.length = 0;
63
63
  return { page, ctx, S };
64
64
  };
65
- const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
65
+ const viaMore = async (pg, label) => { const it = (l) => `#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${l}"))`, more = async () => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); }; await more(); for (let i = 0; i < 20 && !(await pg.$(it(label))) && !(await pg.$(it('Move to a stage'))); i++) { await pg.keyboard.press('Escape'); await pg.waitForTimeout(250); await more(); } if (!(await pg.$(it(label))) && (await pg.$(it('Move to a stage')))) { await pg.click(it('Move to a stage')); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v="stage"]'))); if (label === 'Stage') return; await more(); } await pg.click(it(label)); }; // the page's ⋯ holds Move to a stage; the Stage view's ⋯ holds Documents, Open the full record and Sprint (batch 11 item 20)
66
66
  const toSprint = async (page) => {
67
- if (!(await page.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]')))) { await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .iv', { timeout: 30000 }); })(page); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ await page.click('#czViewer [data-cz-vw="more"]').then(() => page.click('.cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("All tasks"))')); /* the initiative's page (canvas HbC): its + drills into Tasks */ }
67
+ if (!(await page.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]')))) { await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .iv', { timeout: 30000 }); })(page); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ /* the page holds the Tasks (batch 11 item 20) */ }
68
68
  await until(() => page.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v]')), 5000);
69
69
  await viaMore(page, 'Sprint');
70
70
  return until(() => page.evaluate(() => !!document.querySelector('#czViewer .obody.vw[data-vw="sprint:w1"] [data-jbl]')), 5000);
@@ -51,8 +51,8 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
51
51
  S.up = await until(() => page.evaluate(() => !!document.querySelector('#czViewer .iv-sc') && !!window.__premiumWorkItem), 20000);
52
52
  return { page, ctx, S };
53
53
  };
54
- const viaMore = async (pg, label) => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); await pg.click(`#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${label}"))`); }; // the Overview's other views, Open the full record and Sprint sit under ⋯ (XvATasks)
55
- const overview = async (page) => { await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .iv', { timeout: 30000 }); })(page); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ await page.click('#czViewer [data-cz-vw="more"]').then(() => page.click('.cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("All tasks"))')); /* the initiative's page (canvas HbC): its + drills into Tasks */ return until(() => page.evaluate(() => !!document.querySelector('#czViewer [data-cz-vw="more"]') && !!document.querySelector('#czViewer [data-ov-tk="task:t1"]'))); };
54
+ const viaMore = async (pg, label) => { const it = (l) => `#czViewer .cz-vw-menu [role="menuitem"]:has(> span:first-child:text-is("${l}"))`, more = async () => { await pg.click('#czViewer:not([hidden]) [data-cz-vw="more"]'); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer .cz-vw-menu'))); }; await more(); for (let i = 0; i < 20 && !(await pg.$(it(label))) && !(await pg.$(it('Move to a stage'))); i++) { await pg.keyboard.press('Escape'); await pg.waitForTimeout(250); await more(); } if (!(await pg.$(it(label))) && (await pg.$(it('Move to a stage')))) { await pg.click(it('Move to a stage')); await until(() => pg.evaluate(() => !!document.querySelector('#czViewer:not([hidden]) [data-hi-v="stage"]'))); if (label === 'Stage') return; await more(); } await pg.click(it(label)); }; // the page's ⋯ holds Move to a stage; the Stage view's ⋯ holds Documents, Open the full record and Sprint (batch 11 item 20)
55
+ const overview = async (page) => { await (async (g) => { const P = '#czViewer:not([hidden]) [data-hi-v="page"]', r = '#hmList [data-hm-sel^="i:"][aria-current="true"]'; for (let i = 0; i < 4 && !(await g.$(P)) && (await g.$('#czViewer:not([hidden]) [data-cz-vw="back"]')); i++) { await g.click('#czViewer [data-cz-vw="back"]'); await g.waitForTimeout(150); } if (await g.$(P)) return; if (await g.$(r)) await g.click(r); else await g.reload(); await g.waitForSelector(P + ' .iv', { timeout: 30000 }); })(page); /* ← back to the initiative's page, else its row, else the address again (an initiative the list does not show) */ /* the page holds the Tasks (batch 11 item 20) */ return until(() => page.evaluate(() => !!document.querySelector('#czViewer [data-cz-vw="more"]') && !!document.querySelector('#czViewer [data-iv-task="t1"]'))); };
56
56
  const cur = (page) => page.evaluate(() => { const p = document.querySelector('#czViewer:not([hidden]) .obody.vw'); return { on: p ? p.dataset.vw : null, title: (document.querySelector('#czVwTitle') || {}).textContent || '', n: document.querySelectorAll('#czViewer .obody.vw').length }; });
57
57
  const paneTxt = (page, id) => page.evaluate((k) => { const p = document.querySelector(`#czViewer .obody.vw[data-vw="${CSS.escape(k)}"]`); return p ? p.textContent.replace(/\s+/g, ' ') : ''; }, id);
58
58
  const INI = 'item:ini:self-serve-v2';
@@ -79,7 +79,7 @@ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
79
79
  await page.click(`#czViewer .obody.vw[data-vw="${TK}"] [data-tkc="ini"]`);
80
80
  s = await cur(page);
81
81
  ok('R9 the initiative link brings the record back, not a second one', await until(async () => (await cur(page)).on === INI) && (await cur(page)).n === 1, JSON.stringify(s));
82
- ok('R9 the task press in the Overview opens the same task view', await overview(page) && await page.click('#czViewer [data-ov-tk="task:t1"]').then(() => until(async () => (await cur(page)).on === TK && /Oct 20 → 27/.test(await paneTxt(page, TK)))), JSON.stringify(await cur(page)));
82
+ ok('R9 the task press in the Overview opens the same task view', await overview(page) && await page.click('#czViewer [data-iv-task="t1"]').then(() => until(async () => (await cur(page)).on === TK && /Oct 20 → 27/.test(await paneTxt(page, TK)))), JSON.stringify(await cur(page)));
83
83
  ok('R9 the old dialog never opens', await page.evaluate(() => { const d = document.querySelector('#dlg'); return !d || !d.classList.contains('on'); }));
84
84
  ok('R9 no page error', S.errors.length === 0, S.errors.join(' | '));
85
85
  await ctx.close();