create-pmos 0.423.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 (47) hide show
  1. package/package.json +13 -13
  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/briefing-premium-products-test.js +16 -3
  8. package/workspace/changelog.json +12 -0
  9. package/workspace/guide/claude-proposes.md +37 -0
  10. package/workspace/guide/index.md +1 -0
  11. package/workspace/home-pill-test.js +138 -0
  12. package/workspace/lib/headless.js +14 -1
  13. package/workspace/lib/pmos-verbs.js +3 -0
  14. package/workspace/lib/proposal-runs.js +148 -0
  15. package/workspace/lib/proposals.js +370 -0
  16. package/workspace/lib/propose-cli.js +96 -0
  17. package/workspace/lib/route-modules.js +1 -0
  18. package/workspace/lib/routes-board-premium.js +11 -0
  19. package/workspace/lib/routes-boards.js +1 -1
  20. package/workspace/lib/routes-proposals.js +325 -0
  21. package/workspace/lib/routes-task-links.js +35 -28
  22. package/workspace/package-lock.json +2 -2
  23. package/workspace/package.json +1 -1
  24. package/workspace/premium-board-actions-test.js +2 -2
  25. package/workspace/public/pm/bd-asks.js +3 -0
  26. package/workspace/public/pm/cozy-today.css +23 -0
  27. package/workspace/public/pm/cozy-viewer.js +14 -3
  28. package/workspace/public/pm/cozy-vw-shell.css +8 -0
  29. package/workspace/public/pm/home-app.js +20 -6
  30. package/workspace/public/pm/home-task.js +2 -1
  31. package/workspace/public/pm/home-today.js +66 -16
  32. package/workspace/public/pm/ini-groups.js +30 -5
  33. package/workspace/public/pm/ini-links.js +6 -48
  34. package/workspace/public/pm/ini-props.js +218 -0
  35. package/workspace/public/pm/ini-view-model.js +6 -1
  36. package/workspace/public/pm/ini-view.css +47 -0
  37. package/workspace/public/pm/ini-view.js +23 -6
  38. package/workspace/public/pm/premium-vw-item.js +2 -1
  39. package/workspace/public/pm/task-card.css +13 -0
  40. package/workspace/public/pm/task-card.js +37 -2
  41. package/workspace/server.js +37 -2
  42. package/workspace/skills/initiative-propose.skill +45 -0
  43. package/workspace/stage-card-test.js +1 -1
  44. package/workspace/task-links-test.js +26 -14
  45. package/workspace/test-lists/claude-proposes.json +5 -0
  46. package/workspace/test-lists/home-sessions-pill.json +6 -0
  47. package/workspace/tk-tasks-test.js +13 -0
@@ -0,0 +1,218 @@
1
+ /* pm/ini-props.js — what Claude proposes on one initiative, under its one blue ✦ (feedback batch 12 items 2, 3 and 4; canvas In development,
2
+ * rows "Populate initiative" (PiA0–PiA5, devPiRules) and "Task proposals" (TpA1–TpA6, devTpRules)). The fold, the engines and the routes
3
+ * are lib/proposals.js and lib/routes-proposals.js; the Board's row carries r.props (null: nothing to show) and r.found (what a ✓ kept).
4
+ *
5
+ * chipOf(props) → the Viewer's chip after the title: { n, looking, label } | null (zero is silence)
6
+ * sync(v, H) after each draw of the initiative: the ✦ in the Viewer's header, and a quiet read while Claude is looking
7
+ * open(v, H) the ✦'s press: "Claude proposes N" as a drill-in. Groups in order: Found elsewhere, Dates, Looks done, Names,
8
+ * Links. ✓ in the header keeps every proposal Claude is sure of; Check these and Not placed need their own ✓.
9
+ * Each proposal: ⌄ its items, ✓ keep, ✕ drop for good; ✕ on one item drops that item. One toast with Undo.
10
+ * lookHtml(v) the Tasks' dashed placeholder while Claude looks and nothing is kept yet (PiA1)
11
+ * foundDocs(v) the documents a ✓ kept from elsewhere, for the Documents fold: [{ title, meta, ref }]
12
+ *
13
+ * The host gives H.where() → { ws, board }, H.reload(), H.toast(text, undo?). Nothing is written until the PM's ✓. */
14
+ import { pmGet, pmPost } from './http.js';
15
+ import { taskTitle } from './ini-links.js';
16
+
17
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
18
+ const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
19
+ const I = {
20
+ spark: 'M12 3l1.8 4.7L18.5 9.5l-4.7 1.8L12 16l-1.8-4.7L5.5 9.5l4.7-1.8z',
21
+ check: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18', down: 'M6 9l6 6 6-6', up: 'M6 15l6-6 6 6', stop: 'M7 7h10v10H7z',
22
+ doc: 'M7 3h7l5 5v13H7zM14 3v5h5', tasks: 'M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01', stage: 'M5 21V4M5 4h12l-2 4 2 4H5',
23
+ link: 'M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1',
24
+ cal: 'M4 5h16v15H4zM8 3v4M16 3v4M4 10h16', done: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M8 12l3 3 5-6', name: 'M4 20h4L19 9l-4-4L4 16zM13 7l4 4',
25
+ ask: 'M4 5h16v11H9l-5 4z', maybe: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M9.5 9.5a2.5 2.5 0 1 1 3.5 2.3c-.6.3-1 .9-1 1.6M12 17h.01', keep: 'M5 12l5 5 9-10', ignore: 'M5 12h14',
26
+ };
27
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
28
+ const DAY = /^(\d{4})-(\d{2})-(\d{2})/;
29
+ const md = (iso) => { const m = DAY.exec(String(iso || '')); return m ? MON[+m[2] - 1] + ' ' + +m[3] : ''; };
30
+ const span = (a, b) => (a && b && a !== b ? md(a) + ' – ' + md(b) : md(a || b));
31
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
32
+ const clip = (s, n) => { s = String(s || ''); return s.length > n ? s.slice(0, n - 1) + '…' : s; };
33
+ const GROUP = { found: 'Found elsewhere', dates: 'Dates', status: 'Looks done', names: 'Names', links: 'Links' };
34
+
35
+ /* ── the chip and the live look ── */
36
+ export function chipOf(p) {
37
+ if (!p) return null;
38
+ const looking = !!(p.look && !p.look.ended);
39
+ if (!p.n && !looking) return null;
40
+ return { n: p.n || 0, looking, label: p.n ? 'Claude proposes ' + p.n + (looking ? ', and is still looking' : '') + '. Open' : 'Claude is looking for this initiative. Open' };
41
+ }
42
+ const POLL = new Map(); // initiative id → timer, while Claude looks
43
+ export function sync(v, H) {
44
+ const VW = typeof window !== 'undefined' ? window.czViewer : null;
45
+ if (!v || !v.id || !VW) return;
46
+ const cur = VW.current(), body = VW.body();
47
+ if (!cur || !body || !body.querySelector(`[data-iv="${CSS.escape(v.id)}"]`)) return;
48
+ const c = chipOf(v.props);
49
+ VW.setChip(cur.id, c ? { ...c, on: () => open(v, H) } : null);
50
+ // while Claude looks, a quiet read every few seconds; a change reads the Board again
51
+ if (c && c.looking && !POLL.has(v.id)) {
52
+ const t0 = v.props.t;
53
+ POLL.set(v.id, setTimeout(async () => {
54
+ POLL.delete(v.id);
55
+ const r = await read(H, v.id);
56
+ if (r && r.ok && (!r.props || r.props.t !== t0) && H.reload) await H.reload();
57
+ }, 5000));
58
+ }
59
+ }
60
+ async function read(H, id) {
61
+ const at = H.where ? H.where() : {};
62
+ return pmGet('/api/proposals?ws=' + encodeURIComponent(at.ws || '') + '&board=' + encodeURIComponent(at.board || '') + '&initiative=' + encodeURIComponent(id)).catch(() => null);
63
+ }
64
+ async function write(H, route, body) {
65
+ const at = H.where ? H.where() : {};
66
+ return pmPost(route, { ws: at.ws, board: at.board, ...body }).catch(() => null);
67
+ }
68
+ export function lookHtml(v) {
69
+ if (!v || !v.props || !v.props.look || v.props.look.ended) return '';
70
+ return `<div class="pp-ph"><p>Documents, tasks and dates show here when Claude has looked everywhere. Nothing is kept until you say so.</p></div>`;
71
+ }
72
+ export function foundDocs(v) {
73
+ const f = v && v.found;
74
+ return f && f.docs ? f.docs.map((d) => ({ title: d.title, meta: [d.source, md(d.at)].filter(Boolean).join(' · '), ref: d.ref || '' })) : [];
75
+ }
76
+
77
+ /* ── the Viewer ── */
78
+ const S = { id: null, props: null, open: new Set(), choices: {}, H: null, title: '', timer: null };
79
+ const titleOf = (p) => {
80
+ if (p.title) return p.title;
81
+ const n = p.items.length;
82
+ if (p.group === 'found') return p.type === 'stage' ? 'Stage: ' + ((p.data && p.data.stage) || '') : p.type === 'docs' ? plural(n, 'document', 'documents') : p.type === 'tasks' ? plural(n, 'task', 'tasks') : p.type === 'link' ? 'Already in another initiative' : p.type === 'maybe' ? 'Maybe this initiative' : plural(n, 'thing', 'things') + ' not placed';
83
+ if (p.group === 'status') return plural(n, 'task looks', 'tasks look') + ' done';
84
+ if (p.group === 'names') return 'Tidy ' + plural(n, 'name', 'names');
85
+ return '';
86
+ };
87
+ const iconOf = (p) => (p.group === 'found' ? (p.type === 'stage' ? I.stage : p.type === 'docs' ? I.doc : p.type === 'tasks' ? I.tasks : p.type === 'link' ? I.link : I.maybe)
88
+ : p.group === 'dates' ? I.cal : p.group === 'status' ? I.done : p.group === 'names' ? I.name : I.link);
89
+ const ib = (attr, label, icon, cls = '') => `<button type="button" class="pp-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon, 16, 2.2)}</button>`;
90
+ function itemHtml(p, x) {
91
+ let t = '', m = '';
92
+ if (p.group === 'found') {
93
+ if (p.type === 'stage') { t = x.stage; m = [span(x.start, x.due), x.source].filter(Boolean).join(' · '); }
94
+ else if (p.type === 'docs') { t = x.title; m = [x.source, md(x.at)].filter(Boolean).join(' · '); }
95
+ else if (p.type === 'tasks') { t = (x.wbs && !String(x.title || '').startsWith(x.wbs) ? x.wbs + ' ' : '') + (x.title || x.jira || ''); m = [x.jira ? 'Jira epic ' + x.jira : '', x.stage, span(x.start, x.due), x.owner].filter(Boolean).join(' · '); }
96
+ else { t = x.title; m = x.other ? 'In ' + x.other.title : x.why || ''; }
97
+ } else if (p.group === 'dates') { t = x.title || x.task; m = (x.from && x.from.due ? md(x.from.due) + ' → ' : '') + span(x.to && x.to.start, x.to && x.to.due) + (x.jira ? ' · Jira: a drafted comment' : '') + (x.ms ? ' · ◇ a promise' : ''); }
98
+ else if (p.group === 'status') { t = x.title || taskTitle(p.ini, x.task); m = x.jira ? 'Jira: a drafted comment' : ''; }
99
+ else if (p.group === 'names') { t = x.to; m = 'Was: ' + (x.from || '') + (x.jira ? ' · Jira: a drafted comment' : ''); }
100
+ return `<div class="pp-it"><span class="w"><b>${esc(clip(t, 90))}</b>${m ? `<small>${esc(m)}</small>` : ''}</span>${x.sig ? ib(`data-pp-dropit="${esc(x.sig)}"`, 'Leave this one out', I.x) : ''}</div>`;
101
+ }
102
+ function linkHtml(p, l) {
103
+ const pick = S.choices[l.key] || l.rec;
104
+ const seg = l.clash ? '' : `<span class="pp-seg" role="group" aria-label="This link">`
105
+ + `<button type="button" data-pp-ch="${esc(l.key)}" data-v="keep" aria-pressed="${pick === 'keep'}" aria-label="Keep the link: move it too" title="Keep the link: move it too">${SVG(I.keep, 14, 2.2)}${l.rec === 'keep' ? `<i>${SVG(I.spark, 9, 2)}</i>` : ''}</button>`
106
+ + `<button type="button" data-pp-ch="${esc(l.key)}" data-v="ignore" aria-pressed="${pick === 'ignore'}" aria-label="Ignore the link: it stays where it is" title="Ignore the link: it stays where it is">${SVG(I.ignore, 14, 2.2)}${l.rec === 'ignore' ? `<i>${SVG(I.spark, 9, 2)}</i>` : ''}</button></span>`;
107
+ const mv = (l.moves || []).map((m) => m.title + ' to ' + span(m.to.start, m.to.due)).join(', ');
108
+ return `<div class="pp-it pp-lk"><span class="w"><b>${esc(clip(l.toTitle, 70))}</b><small>${esc(l.why)}${mv ? ' · ' + esc(mv) : ''}</small></span>${seg}</div>`;
109
+ }
110
+ function propHtml(p) {
111
+ if (p.group === 'links') {
112
+ const l = p.link || {}, a = taskTitle(p.ini || S.id, l.from), b = taskTitle(p.ini || S.id, l.to);
113
+ const t = l.kind === 'link' ? clip(b, 40) + ' waits on ' + clip(a, 40) : l.kind === 'pull' ? 'Pull ' + plural((l.tasks || []).length, 'task', 'tasks') + ' in' : 'Move ' + plural((l.tasks || []).length, 'task', 'tasks') + ' to keep your links';
114
+ return `<div class="pp-p" data-pp="${esc(p.id)}"><div class="pp-ph1"><span class="pp-ic">${SVG(I.link, 16)}</span><span class="w"><b>${esc(t)}</b><small>${esc(p.why)}</small></span>`
115
+ + ib(`data-pp-keep="${esc(p.id)}"`, 'Keep it', I.check, 'ok') + ib(`data-pp-droplk="${esc(l.id || '')}"`, 'Drop it', I.x) + '</div></div>';
116
+ }
117
+ const op = S.open.has(p.id), n = p.items.length + (p.links || []).length;
118
+ const src = (p.sources || []).map((s) => s.label).join(', ');
119
+ const tag = p.section === 'check' ? 'Check these' : p.section === 'unplaced' ? 'Not placed' : '';
120
+ const plan = p.plan ? 'Plan ' + md(p.plan.from) + ' → ' + md(p.plan.to) + (p.plan.ms ? ' · the ◇ stays where it is' : '') : '';
121
+ const ask = p.ask && p.ask.owner ? ib(`data-pp-ask="${esc(p.id)}"`, 'Ask ' + p.ask.owner + ' why it slipped', I.ask) : '';
122
+ return `<div class="pp-p${p.section !== 'sure' ? ' chk' : ''}" data-pp="${esc(p.id)}">`
123
+ + `<div class="pp-ph1"><span class="pp-ic">${SVG(iconOf(p), 16)}</span><span class="w"><b>${esc(titleOf(p))}</b><small>${esc(p.why)}</small>`
124
+ + (src || tag || plan ? `<small class="pp-src">${[tag ? `<em>${esc(tag)}</em>` : '', esc(plan), esc(src)].filter(Boolean).join(' · ')}</small>` : '') + '</span>'
125
+ + ask + (n ? ib(`data-pp-more="${esc(p.id)}" aria-expanded="${op}"`, op ? 'Hide what it holds' : 'Show what it holds', op ? I.up : I.down) : '')
126
+ + ib(`data-pp-keep="${esc(p.id)}"`, 'Keep it', I.check, 'ok') + ib(`data-pp-drop="${esc(p.sig || '')}"`, 'Drop it for good', I.x) + '</div>'
127
+ + (op ? `<div class="pp-its">${p.items.map((x) => itemHtml(p, x)).join('')}${(p.links || []).map((l) => linkHtml(p, l)).join('')}</div>` : '')
128
+ + '</div>';
129
+ }
130
+ function lookBlock(L) {
131
+ if (!L || L.ended) return '';
132
+ const rows = L.sources.map((s) => `<li class="${s.state === 'reading' ? 'on' : ''}"><b>${esc(s.name)}</b><span>${s.state === 'reading' ? 'Reading…' : esc(s.what || plural(s.n, 'find', 'finds'))}</span></li>`).join('');
133
+ return `<div class="pp-look"><div class="pp-lh">${SVG(I.spark, 14, 2)}<b>${L.why === 'check' ? 'Claude is checking the late tasks' : 'Claude is looking for this initiative'}</b>${ib('data-pp-stop', 'Stop looking', I.stop)}</div>`
134
+ + (rows ? `<ul>${rows}</ul>` : '<p>It starts with your connected sources.</p>') + '</div>';
135
+ }
136
+ function bodyHtml(P) {
137
+ const VW = window.czViewer;
138
+ if (!P || (!P.n && !(P.look && !P.look.ended))) return '<p class="pp-none">Nothing waits here now.</p>';
139
+ const secs = (P.groups || []).map((g) => ({ id: g.group, title: GROUP[g.group] || g.group, count: g.props.length, open: true, html: g.props.map(propHtml).join('') }));
140
+ return `<div class="pp">${lookBlock(P.look)}${VW.czSections(secs, { key: 'props' })}</div>`;
141
+ }
142
+ function presses(P) { return P && P.sure ? [{ act: 'all', label: 'Keep all ' + P.sure + ' Claude is sure of', icon: I.check, solid: true }] : []; }
143
+ function draw() {
144
+ const VW = window.czViewer, b = VW.body(), cur = VW.current();
145
+ if (!b || !cur || cur.id !== 'pp:' + S.id) return;
146
+ const top = b.scrollTop;
147
+ b.innerHTML = bodyHtml(S.props);
148
+ b.scrollTop = top;
149
+ VW.setPresses(cur.id, presses(S.props));
150
+ const t = 'Claude proposes' + (S.props && S.props.n ? ' ' + S.props.n : '');
151
+ if (VW.retitle && cur.title !== t) VW.retitle(cur.id, t);
152
+ clearTimeout(S.timer);
153
+ if (S.props && S.props.look && !S.props.look.ended) S.timer = setTimeout(fresh, 4000);
154
+ }
155
+ async function fresh() {
156
+ const id = S.id, r = await read(S.H, id);
157
+ if (S.id !== id || !r || r.ok === false) return;
158
+ S.props = r.props; draw();
159
+ }
160
+ const say = (m, undo) => { if (S.H && S.H.toast) S.H.toast(m, undo); };
161
+ const after = () => { if (S.H && S.H.reload) Promise.resolve(S.H.reload()).catch(() => {}); };
162
+ async function keep(ids, all) {
163
+ const res = await write(S.H, '/api/proposals/keep', { initiative: S.id, ...(all ? { all: true } : { ids }), choices: S.choices });
164
+ if (!res || res.ok === false) { say((res && res.error) || 'Nothing was kept.'); return; }
165
+ S.props = res.props; draw(); after();
166
+ const batch = res.batch, H = S.H, id = S.id;
167
+ say(res.said, async () => {
168
+ const u = await write(H, '/api/proposals/undo', { batch });
169
+ if (!u || u.ok === false) { if (H.toast) H.toast((u && u.error) || 'The undo did not land.'); return; }
170
+ if (u.kept && H.toast) H.toast(plural(u.kept, 'change was', 'changes were') + ' kept: the task changed since.');
171
+ if (S.id === id) await fresh();
172
+ if (H.reload) await H.reload();
173
+ });
174
+ if (!S.props || (!S.props.n && !(S.props.look && !S.props.look.ended))) window.czViewer.back();
175
+ }
176
+ async function drop(sig) {
177
+ const res = await write(S.H, '/api/proposals/drop', { initiative: S.id, sig });
178
+ if (!res || res.ok === false) { say((res && res.error) || 'Nothing was changed.'); return; }
179
+ await fresh(); after();
180
+ }
181
+ async function onPress(e) {
182
+ const b = e.target.closest('button'); if (!b) return;
183
+ const d = b.dataset;
184
+ if (d.ppMore) { if (S.open.has(d.ppMore)) S.open.delete(d.ppMore); else S.open.add(d.ppMore); draw(); return; }
185
+ if (d.ppCh) { S.choices[d.ppCh] = d.v; draw(); return; }
186
+ if (d.ppKeep) { b.disabled = true; await keep([d.ppKeep], false); return; }
187
+ if (d.ppDrop) { b.disabled = true; await drop(d.ppDrop); return; }
188
+ if (d.ppDropit) { b.disabled = true; await drop(d.ppDropit); return; }
189
+ if ('ppDroplk' in d) {
190
+ b.disabled = true;
191
+ const res = await write(S.H, '/api/task-links/drop', { initiative: S.id, id: d.ppDroplk });
192
+ if (!res || res.ok === false) { say((res && res.error) || 'Nothing was changed.'); b.disabled = false; return; }
193
+ await fresh(); after(); return;
194
+ }
195
+ if ('ppStop' in d) {
196
+ b.disabled = true;
197
+ const res = await write(S.H, '/api/proposals/stop', { initiative: S.id });
198
+ if (!res || res.ok === false) say((res && res.error) || 'Claude could not be stopped.');
199
+ else say('Claude stopped looking. What it found so far stays here.');
200
+ await fresh(); after(); return;
201
+ }
202
+ if (d.ppAsk) {
203
+ const p = (S.props.groups || []).flatMap((g) => g.props).find((x) => x.id === d.ppAsk); if (!p) return;
204
+ const q = 'Hi ' + p.ask.owner + ', ' + p.items.map((x) => x.title).slice(0, 3).join(', ') + (p.items.length > 1 ? ' are' : ' is') + ' past ' + (p.items.length > 1 ? 'their' : 'its') + ' date. What is it waiting on, and when do you expect it?';
205
+ try { await navigator.clipboard.writeText(q); say('A question for ' + p.ask.owner + ' is copied. Paste it where you talk.'); } catch { say(q); }
206
+ }
207
+ }
208
+ /** The ✦'s press: the drill-in. v: the initiative's view (id, title, props). */
209
+ export function open(v, H) {
210
+ const VW = window.czViewer; if (!VW || !v || !v.id) return;
211
+ S.id = v.id; S.props = v.props; S.H = H; S.open = new Set(); S.choices = {}; S.title = v.title;
212
+ VW.drill();
213
+ VW.open({ id: 'pp:' + v.id, kind: 'Claude proposes', title: 'Claude proposes' + (v.props && v.props.n ? ' ' + v.props.n : ''), sub: v.title, icon: I.spark,
214
+ presses: presses(v.props),
215
+ onPress: (act) => { if (act === 'all') keep([], true); },
216
+ render: (b) => { b.innerHTML = bodyHtml(S.props); if (!b.__pp) { b.__pp = true; } b.onclick = onPress; draw(); if (!S.props || S.props.look) fresh(); },
217
+ onClose: () => { clearTimeout(S.timer); if (S.id === v.id) S.id = null; } });
218
+ }
@@ -172,6 +172,9 @@ export function iniView(r, ctx = {}) {
172
172
  moves.forEach((m, i) => { const j = idx(m.to); if (j < 0) return; ran[j].from = m.at; const nx = moves[i + 1]; ran[j].to = nx ? nx.at : null; });
173
173
  if (cur >= 0 && tr.since) ran[cur].from = tr.since;
174
174
  if (list.length && !ran[0].from && r.start) ran[0].from = String(r.start).slice(0, 10);
175
+ // the dates a past stage really ran, as Claude found them elsewhere and the PM kept (batch 12 item 4): they lead over the board's moves
176
+ const fr = (r.found && r.found.ran) || {};
177
+ list.forEach((s, i) => { const f = fr[s.key] || fr[s.name]; if (!f) return; if (f.from) ran[i].from = f.from; if (f.to) ran[i].to = f.to; });
175
178
 
176
179
  /* the stage card */
177
180
  const st = cur >= 0 ? list[cur] : null;
@@ -265,7 +268,9 @@ export function iniView(r, ctx = {}) {
265
268
  const today2 = (n) => String(n).padStart(2, '0');
266
269
  return { vs: r.__vs || null, links: r.__vs && r.__vs.draft ? null : r.links || null, id: r.id || null, key: r.key, title: r.title, today: today.getFullYear() + '-' + today2(today.getMonth() + 1) + '-' + today2(today.getDate()), summary, stage, tasks, docs: ctx.docs != null ? ctx.docs : null, linked: linkedOf(r),
267
270
  // split or merge (batch 11 item 14): Claude's suggestion for it, and where its work went when it was merged
268
- suggest: r.suggest || null, merged: mergedOf(r) };
271
+ suggest: r.suggest || null, merged: mergedOf(r),
272
+ // what Claude proposes under the one blue ✦, and what a ✓ kept from elsewhere (batch 12 items 2, 3 and 4; pm/ini-props.js)
273
+ props: r.props || null, found: r.found || null };
269
274
  }
270
275
  /** A merged initiative's closing line (XsmA7Closed): the one that stays and the day. null for every other row. */
271
276
  export function mergedOf(r) {
@@ -564,6 +564,10 @@ button.lk-mt:hover { color: var(--cz-ink) !important; }
564
564
  .tkc.ivq.vs-pop.sheet .lk-m { width: 100%; box-sizing: border-box; }
565
565
  /* Group by and Send to Jira in Tasks (feedback batch 11 item 20; canvas In development, row "Tasks takes over the old All tasks panel"): pm/ini-groups.js */
566
566
  .iv-ib.ig-by.on { background: var(--cz-bluebg); color: var(--cz-blueink); }
567
+ /* the stage the stage card showed, while Tasks is grouped another way (batch 12 item 0): its name and a ✕ */
568
+ .iv-th .ig-only { display: inline-flex; align-items: center; gap: 4px; height: 28px; max-width: 160px; padding: 0 8px 0 10px; border: 0; border-radius: 999px; background: var(--cz-bluebg); color: var(--cz-blueink); font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-right: 4px; }
569
+ .iv-th .ig-only svg { flex: none; opacity: .75; }
570
+ .iv-th .ig-only:hover svg { opacity: 1; }
567
571
  .iv-wsw, .ig-dz { position: relative; }
568
572
  .iv-wsw { display: flex; align-items: center; }
569
573
  .iv-wsw > .iv-ws { flex: 1; min-width: 0; }
@@ -603,3 +607,46 @@ button.lk-mt:hover { color: var(--cz-ink) !important; }
603
607
  .iv-th .ivx-seg { background: transparent; padding: 0; }
604
608
  .iv-th .ivx-seg .ivx-sb[aria-pressed="true"] { box-shadow: none; background: transparent !important; }
605
609
  }
610
+
611
+ /* ── what Claude proposes, under the one blue ✦ after the title (batch 12 items 2, 3 and 4; canvas PiA1–PiA5, TpA1–TpA5; pm/ini-props.js) ── */
612
+ .pp { display: flex; flex-direction: column; gap: 10px; color: var(--cz-ink); font-family: var(--cz-sans); }
613
+ .pp button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; }
614
+ .pp-p { border-radius: 14px; padding: 4px 0; }
615
+ .pp-p + .pp-p { border-top: 1px solid var(--cz-hair); }
616
+ .pp-ph1 { display: flex; align-items: flex-start; gap: 8px; padding: 6px 2px 6px 4px; }
617
+ .pp-ph1 .w, .pp-it .w { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
618
+ .pp-ph1 b { font-size: 13.5px; font-weight: 800; }
619
+ .pp-ph1 small, .pp-it small { font-size: 12.5px; color: var(--cz-ink2); line-height: 1.4; }
620
+ .pp-ph1 .pp-src { color: var(--cz-ink3); }
621
+ .pp-ph1 .pp-src em { font-style: normal; font-weight: 700; color: var(--cz-risk); }
622
+ .pp-ic { width: 28px; height: 28px; border-radius: 9px; background: var(--cz-bluebg); color: var(--cz-blueink); display: inline-flex; align-items: center; justify-content: center; flex: none; }
623
+ .pp-p.chk .pp-ic { background: var(--cz-well); color: var(--cz-ink2); }
624
+ .pp .pp-ib { width: 32px; height: 32px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: var(--cz-ink2); flex: none; }
625
+ .pp .pp-ib:hover { background: var(--cz-well); color: var(--cz-ink); }
626
+ .pp .pp-ib.ok { color: var(--cz-blueink); }
627
+ .pp .pp-ib:focus-visible, .pp-seg button:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
628
+ .pp-its { display: flex; flex-direction: column; gap: 2px; margin: 0 0 4px 40px; }
629
+ .pp-it { display: flex; align-items: center; gap: 8px; padding: 4px 0 4px 8px; border-left: 2px solid var(--cz-hair); }
630
+ .pp-it b { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
631
+ .pp-seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: var(--cz-well); flex: none; }
632
+ .pp-seg button { position: relative; width: 30px; height: 26px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; color: var(--cz-ink3); }
633
+ .pp-seg button[aria-pressed="true"] { background: var(--cz-card); color: var(--cz-ink); box-shadow: var(--cz-vlift); }
634
+ .pp-seg button i { position: absolute; top: -2px; right: -1px; color: var(--cz-blue); line-height: 0; }
635
+ .pp-look { border-radius: 14px; background: var(--cz-bluebg); color: var(--cz-blueink); padding: 6px 6px 10px 12px; }
636
+ .pp-lh { display: flex; align-items: center; gap: 8px; }
637
+ .pp-lh b { flex: 1; font-size: 13px; font-weight: 800; }
638
+ .pp-look ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
639
+ .pp-look li { display: flex; gap: 8px; font-size: 12.5px; color: var(--cz-ink2); }
640
+ .pp-look li b { min-width: 84px; font-weight: 700; color: var(--cz-ink); }
641
+ .pp-look li.on span { color: var(--cz-blueink); }
642
+ .pp-look p { margin: 4px 0 0; font-size: 12.5px; }
643
+ .pp-none { margin: 8px 0; font-size: 13px; color: var(--cz-ink3); }
644
+ .pp-ph { border: 1.5px dashed var(--cz-hair); border-radius: 14px; padding: 14px 16px; }
645
+ .pp-ph p { margin: 0; font-size: 13px; color: var(--cz-ink2); }
646
+ /* the documents a ✓ kept from elsewhere, inline under Documents */
647
+ .iv-fds { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
648
+ .iv-fd { display: flex !important; flex-direction: column; gap: 1px; padding: 6px 8px !important; border-radius: 10px !important; color: var(--cz-ink); text-decoration: none; }
649
+ .iv-fd:hover { background: var(--cz-well) !important; }
650
+ .iv-fd b { font-size: 13px; font-weight: 700; }
651
+ .iv-fd small { font-size: 12px; color: var(--cz-ink3); }
652
+ @media (max-width: 760px) { .pp .pp-ib { width: 40px; height: 40px; } .pp-its { margin-left: 12px; } }
@@ -30,7 +30,8 @@
30
30
  import { wfIcon } from './wf-model.js';
31
31
  import * as TV from './ini-tasks.js'; // Tasks as List, Timeline or Kanban, and the quick status and dates (batch 9 item 5b)
32
32
  import * as VS from './ini-versions.js'; // planned versus actual: the version chip, Make live, a draft's writes (batch 11 item 8)
33
- import * as LK from './ini-links.js'; // links between tasks, Claude's proposals and quiet moves (batch 11 item 15)
33
+ import * as LK from './ini-links.js'; // links between tasks and quiet moves (batch 11 item 15)
34
+ import * as PP from './ini-props.js'; // what Claude proposes, under the one blue ✦ after the title (batch 12 items 2, 3 and 4)
34
35
  import * as G from './ini-groups.js'; // Group by and Send to Jira, in place of the old All tasks panel (batch 11 item 20)
35
36
  import { cardHtml as smCard, mergedHtml as smMerged } from './split-merge.js'; // split or merge: Claude's card, the merged summary (batch 11 item 14)
36
37
  import { lineHtml, fitLine } from './stage-line.js'; // the stage card's one line (batch 11 item 21)
@@ -185,6 +186,8 @@ function tasksHtml(v0, o) {
185
186
  o = { ...o, lk };
186
187
  const head = `<div class="iv-th"><b>Tasks</b>${cnt ? `<span class="n">${esc(cnt)}</span>` : ''}${LK.headHtml(lk)}${VS.headHtml(v.vs)}<span class="iv-sp"></span>${T.empty ? '' : TV.headExtraHtml(v, mode) + G.headHtml(v) + TV.switchHtml(mode)}${VS.liveHtml(v.vs)}${add}</div>`
187
188
  + (o.adding ? `<form class="iv-addf" data-iv-addform><input id="ivAddTask" type="text" maxlength="160" autocomplete="off" placeholder="A task for ${esc(v.title)}${o.addHint ? esc(', ' + o.addHint) : ''}" aria-label="New task"><button type="submit" class="iv-go" aria-label="Add the task" title="Add (Enter). Esc cancels.">${SVG(P.check, 16, 2.2)}</button></form>` : '');
189
+ // while Claude looks for a new initiative elsewhere, Tasks waits for what it finds (PiA1)
190
+ if (T.empty && PP.lookHtml(v)) return head + PP.lookHtml(v);
188
191
  if (T.empty) {
189
192
  const sk = T.empty.stages.map((s) => `<span class="iv-sk"><span class="iv-no dash${s.ms ? ' ms' : ''}" aria-hidden="true">${s.ms ? '' : s.n}</span>${esc(s.name)}${s.now ? ' <i>· now</i>' : ''}</span>`).join('');
190
193
  return head + `<div class="iv-empty">${sk}<p class="iv-q">Claude drafts the breakdown, one section per stage. Nothing is saved until you keep it.</p>`
@@ -196,15 +199,22 @@ function tasksHtml(v0, o) {
196
199
  if (mode === 'timeline') return top + `<div class="iv-tk">${TV.timelineHtml(v, q, fold)}</div>`;
197
200
  if (mode === 'kanban') return top + `<div class="iv-tk">${TV.kanbanHtml(v, q, fold)}</div>`;
198
201
  const ol = T.by === 'mine' ? { ...o, gdrag: !!o.quick } : o;
202
+ // the stage the card showed has no task: say so, and the ✕ in the header shows every stage again (batch 12 item 0)
203
+ if (T.only && !T.sections.length) return top + `<p class="iv-q ig-none">No tasks in ${esc(T.only)} yet.</p>`;
199
204
  return top + `<div class="iv-wbs">${T.sections.map((s) => sectionHtml(v, s, ol)).join('')}</div>`;
200
205
  }
201
206
  function foldsHtml(v, o) {
202
207
  const rows = [];
203
- if (o.docs && o.docs.n) {
204
- const op = o.docs.html ? isOpen(v, 'docs', false) : false;
205
- rows.push(`<button type="button" class="iv-fr" ${o.docs.html ? `data-iv-fold="docs" aria-expanded="${op}"` : 'data-iv-docs'}><b>Documents</b><span class="n">${o.docs.n}</span>${chev(op)}</button>` + (op ? `<div class="iv-fb">${o.docs.html}</div>` : ''));
208
+ // the documents a ✓ kept from elsewhere (batch 12 item 4) list inline under Documents, each with its source and date
209
+ const fd = PP.foundDocs(v);
210
+ const fdHtml = fd.map((d) => (/^https?:\/\//.test(d.ref) ? `<a class="iv-fd" href="${esc(d.ref)}" target="_blank" rel="noopener">` : '<span class="iv-fd">') + `<b>${esc(d.title)}</b>${d.meta ? `<small>${esc(d.meta)}</small>` : ''}` + (/^https?:\/\//.test(d.ref) ? '</a>' : '</span>')).join('');
211
+ if ((o.docs && o.docs.n) || fd.length) {
212
+ const n = ((o.docs && o.docs.n) || 0) + fd.length, inl = !!(o.docs && o.docs.html) || fd.length > 0;
213
+ const op = inl ? isOpen(v, 'docs', false) : false;
214
+ const own = o.docs && o.docs.n ? (o.docs.html || `<button type="button" class="iv-fd" data-iv-docs><b>Core documents</b><small>${o.docs.n}</small></button>`) : '';
215
+ rows.push(`<button type="button" class="iv-fr" ${inl ? `data-iv-fold="docs" aria-expanded="${op}"` : 'data-iv-docs'}><b>Documents</b><span class="n">${n}</span>${chev(op)}</button>` + (op ? `<div class="iv-fb">${own}${fd.length ? `<div class="iv-fds">${fdHtml}</div>` : ''}</div>` : ''));
206
216
  }
207
- const L = v.linked || [];
217
+ const L = (v.linked || []).concat(((v.found && v.found.linked) || []).map((x) => ({ kind: 'found', label: x.label, title: x.title, ref: x.ref })));
208
218
  if (L.length) {
209
219
  const op = isOpen(v, 'linked', false);
210
220
  const chip = (x) => (x.kind === 'doc' ? `<button type="button" class="iv-chip" data-iv-doc="${esc(x.path)}" title="${esc(x.path)}">${esc(x.label)}</button>` : `<span class="iv-chip"${x.title ? ` title="${esc(x.title)}"` : ''}>${esc(x.label)}</span>`);
@@ -212,7 +222,9 @@ function foldsHtml(v, o) {
212
222
  }
213
223
  return rows.length ? `<div class="iv-folds">${rows.join('')}</div>` : '';
214
224
  }
225
+ const VIEWED = new Map(); // initiative id → the view drawn last (the ✦ in the Viewer's header reads it)
215
226
  export function viewHtml(v, o = {}) {
227
+ if (v && v.id) VIEWED.set(v.id, v);
216
228
  // a merged initiative leads with where its work went, and draws no stage or tasks (they moved; its folds stay); an open one shows Claude's split or merge card under the summary (batch 11 item 14)
217
229
  const top = v.merged ? smMerged(v.merged) : summaryHtml(v.summary, o) + (o.sm !== false ? smCard(v.suggest, v.title) : '');
218
230
  return `<div class="iv" data-iv="${esc(v.id || v.key || '')}">${top}${v.merged ? '' : stageHtml(v.stage, o, v.id || v.key || '') + tasksHtml(v, o)}${foldsHtml(v, o)}${o.tail || ''}</div>`;
@@ -223,12 +235,15 @@ export function wireView(body, h) {
223
235
  if (!body) return;
224
236
  const idOf = () => { const n = body.querySelector('[data-iv]'); return n ? n.dataset.iv : null; };
225
237
  body.__iv = LK.wrap(VS.wrap(h, body, (id) => SHOWN.get(id)), idOf);
238
+ // the one blue ✦ after the title (pm/ini-props.js), drawn again with each draw of the initiative
239
+ const chip = () => { const id = idOf(); if (id && VIEWED.has(id)) PP.sync(VIEWED.get(id), body.__iv || {}); };
240
+ chip();
226
241
  G.attach(body, body.__iv); // the layout and the drafted tickets of the initiative shown (batch 11 item 20)
227
242
  if (body.__ivWired) return;
228
243
  body.__ivWired = true;
229
244
  // the stage line's labels are checked as drawn (pm/stage-line.js fitLine): after each draw and when the panel changes width
230
245
  if (typeof MutationObserver === 'function') {
231
- let q = 0; const fit = () => { if (q) return; q = requestAnimationFrame(() => { q = 0; fitLine(body); }); };
246
+ let q = 0; const fit = () => { if (q) return; q = requestAnimationFrame(() => { q = 0; fitLine(body); chip(); }); };
232
247
  new MutationObserver(fit).observe(body, { childList: true, subtree: true });
233
248
  if (typeof ResizeObserver === 'function') new ResizeObserver(fit).observe(body);
234
249
  fit();
@@ -312,6 +327,8 @@ function later(b, pick) {
312
327
  }
313
328
  /** Show a stage (and one task of it) in Tasks: its section opens in the List and the Timeline, the Kanban turns to it. */
314
329
  function showIn(b, id, H, key, uid) {
330
+ // grouped by epic (or any grouping but Stage) there is no stage section to open: Tasks shows that stage's tasks only (batch 12 item 0)
331
+ if (key != null && !uid && G.onlyStage(id, key)) { if (H.redraw) H.redraw(); later(b, (root) => root.querySelector('.iv-th')); return; }
315
332
  if (key != null) { FOLD.set(id + '|sec:' + (key || 'none'), true); TV.setKanbanStage(id, key); }
316
333
  if (uid) { const v = SHOWN.get(id), f = v && findRow(v, uid); if (f && f.fold) FOLD.set(id + '|' + f.fold, true); }
317
334
  if (H.redraw) H.redraw();
@@ -7,7 +7,7 @@
7
7
  * 'reading' while the board derives, and the tab asks again. Inside a tab a task opens its own tab and the initiative link opens the initiative's. */
8
8
  import { vwOpen, vwStyle, vwClose } from './premium-viewer.js';
9
9
  import { esc, iniId, taskId, stateOf, readingHtml, errorHtml, iniHtml, taskHtml, findTask, cardTask } from './premium-vw-item-model.js';
10
- import { mountCard, boardSaver, checkOf, cardStyle, toastUndo, placeOf, deleteEntry } from './task-card.js';
10
+ import { mountCard, boardSaver, checkOf, cardStyle, toastUndo, placeOf, deleteEntry, historyFor } from './task-card.js';
11
11
  import { pmPost } from './http.js';
12
12
  import { setCheck } from './cozy-viewer.js';
13
13
 
@@ -104,6 +104,7 @@ export function openWorkItem(o) {
104
104
  openIni: (id) => openWorkItem({ kind: 'initiative', id, title: id === m.id ? m.title : '', ws: ctx.ws, board: ctx.board }),
105
105
  iniTitleOf: (id) => ((lists.inis || []).find((x) => x.id === id) || {}).title || id,
106
106
  inis: () => lists.inis || [], owners: () => lists.owners || [], groups: () => lists.groups, sections: () => lists.sections,
107
+ history: historyFor({ ws, board, t, post: (p, b) => pmPost(p, b) }), // what Claude changed with your ✓ (batch 12, TpA6)
107
108
  });
108
109
  check();
109
110
  // the pickers' lists: the board's initiatives and owners, the initiative's groups (read once, after the card shows)
@@ -84,3 +84,16 @@
84
84
  /* the ◇ milestone toggle after a divider (feedback batch 11 item 3, canvas XmlA2Flag) */
85
85
  .tkc .seg .vr { width: 1px; height: 20px; background: var(--cz-hair); margin: 0 3px; align-self: center; }
86
86
  .tkc .seg .ivq-ms.on { width: auto; padding: 0 12px 0 9px; gap: 6px; background: var(--cz-bluebg); color: var(--cz-blueink); font-weight: 800; font-size: 13px; box-shadow: inset 0 0 0 1.5px var(--cz-blue); }
87
+ /* History (batch 12 items 2 and 3, canvas TpA6): what Claude changed with the PM's ✓; folded, hidden at zero */
88
+ .tkc .tkc-h { padding-top: 4px; }
89
+ .tkc .tkc-hh { display: flex; align-items: center; gap: 6px; width: 100%; font: inherit; background: none; border: 0; padding: 6px 0; color: var(--cz-ink); cursor: pointer; text-align: left; }
90
+ .tkc .tkc-hh b { font-size: 13px; font-weight: 800; }
91
+ .tkc .tkc-hh .n { font-size: 12px; font-weight: 700; color: var(--cz-ink3); }
92
+ .tkc .tkc-hh svg { margin-left: auto; color: var(--cz-ink3); }
93
+ .tkc .tkc-h ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
94
+ .tkc .tkc-h li { display: flex; align-items: flex-start; gap: 8px; }
95
+ .tkc .tkc-h li .w { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
96
+ .tkc .tkc-h li b { font-size: 13px; font-weight: 700; }
97
+ .tkc .tkc-h li small { font-size: 12px; color: var(--cz-ink3); line-height: 1.4; }
98
+ .tkc .tkc-hu { width: 30px; height: 30px; border-radius: 999px; border: 0; background: none; color: var(--cz-ink2); display: inline-flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
99
+ .tkc .tkc-hu:hover { background: var(--cz-well); color: var(--cz-ink); }
@@ -8,6 +8,8 @@
8
8
  * Notes the PM's words, edited in place;
9
9
  * where it sits one row: initiative › section › breakdown item. The row opens the initiative; the move icon beside it changes the
10
10
  * section (the workflow stage the task sits in), the PM's group, or the initiative.
11
+ * History N what Claude changed with the PM's ✓ (batch 12 items 2 and 3, canvas TpA6): field, before → after, why and where it read
12
+ * it; Undo on a change of the last 7 days. Folded; hidden at zero. h.history: { load() → [entry], undo(batch) → { ok } }
11
13
  * Every change saves at once and says so in a toast with Undo. A Jira ticket is not drawn here: it opens the ticket Viewer (tk-view.js).
12
14
  * cardHtml(t, o) → markup pure, for a node test: t is a task (taskOf), o the open picker and its lists
13
15
  * taskOf(row, extra) → t a row of /api/boards/items or of the initiative model, in one shape
@@ -181,7 +183,22 @@ export function cardHtml(t, o = {}) {
181
183
  const move = canMove(t, o) ? `<span class="anc"><button type="button" class="ovmv${mOpen ? ' open' : ''}" data-tkc="move" aria-label="Move it: section, group or initiative" title="Move it" aria-expanded="${mOpen}" aria-haspopup="menu">${ico(I.drag, 17)}</button>${mOpen ? movePop(t, o) : ''}</span>` : '';
182
184
  const where = t.ini ? `<div class="ovw tk-ini"><button type="button" class="go" data-tkc="ini" aria-label="Open ${esc(t.iniTitle || t.ini)}"><span class="tl" aria-hidden="true">${ico(I.flag, 15)}</span>`
183
185
  + `<span class="tx"><b>${esc(t.iniTitle || t.ini)}</b>${path.length ? `<small>${path.join('<span class="sep" aria-hidden="true">›</span>')}</small>` : ''}</span><span class="cv">${ico(I.chev, 15)}</span></button>${move}</div>` : '';
184
- return `<div class="tkc s-${sk}">${facts}${notes}${where}<p class="tkc-msg" role="status">${esc(o.msg || '')}</p></div>`;
186
+ return `<div class="tkc s-${sk}">${facts}${notes}${where}${historyHtml(o.hist, o.histOpen, now)}<p class="tkc-msg" role="status">${esc(o.msg || '')}</p></div>`;
187
+ }
188
+
189
+ /** History (canvas TpA6): Claude's approved changes to the task, newest first (lib/proposals.js historyOf). Zero is silence. */
190
+ const FIELD = { due: 'Due', status: 'Status', name: 'Name', notes: 'Notes', add: 'Added' };
191
+ const valOf = (f, v) => (v == null || v === '' ? '—' : typeof v === 'object' ? [short(v.start), short(v.due)].filter(Boolean).join(' – ') || '—' : f === 'notes' ? 'edited' : String(v));
192
+ export function historyHtml(hist, open, now = Date.now()) {
193
+ const L = (hist || []).filter((x) => x && !x.undone);
194
+ if (!L.length) return '';
195
+ const rows = L.map((x) => {
196
+ const recent = now - (Date.parse(x.at) || 0) < 7 * 864e5;
197
+ const what = x.field === 'add' ? 'Added from ' + (x.source || 'your sources') : (FIELD[x.field] || x.field) + ': ' + valOf(x.field, x.from) + ' → ' + valOf(x.field, x.to);
198
+ return `<li><span class="w"><b>${esc(what)}</b><small>${esc(['Claude, kept by you ' + short(String(x.at).slice(0, 10)), x.why, x.field !== 'add' && x.source ? x.source : ''].filter(Boolean).join(' · '))}</small></span>`
199
+ + (recent && x.batch ? `<button type="button" class="tkc-hu" data-tkc-hundo="${esc(x.batch)}" aria-label="Undo this change" title="Undo">${ico('<path d="M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3"/>', 15)}</button>` : '') + '</li>';
200
+ }).join('');
201
+ return `<div class="ovb tkc-h"><button type="button" class="tkc-hh" data-tkc-hist aria-expanded="${!!open}"><b>History</b><span class="n">${L.length}</span>${ico(open ? '<path d="M6 9l6 6 6-6"/>' : I.chev, 14)}</button>${open ? `<ul>${rows}</ul>` : ''}</div>`;
185
202
  }
186
203
 
187
204
  /* ── the page: one card, every change saved at once with Undo ── */
@@ -209,7 +226,7 @@ export function mountCard(el, t, h) {
209
226
  const draw = () => {
210
227
  const keep = document.activeElement && el.contains(document.activeElement) && document.activeElement.matches('[data-tkc-notes]');
211
228
  if (keep) return; // never redraw under the PM's typing
212
- el.innerHTML = cardHtml(t, { ...st, ...lists(), now: h.now ? h.now() : Date.now() });
229
+ el.innerHTML = cardHtml(t, { ...st, ...lists(), hist: st.hist, histOpen: st.histOpen, now: h.now ? h.now() : Date.now() });
213
230
  const f = el.querySelector('.tkc-new input'); if (f && (st.open === 'owner' || st.open === 'group')) f.focus();
214
231
  };
215
232
  const word = (kind) => (WORDS[kind] || (() => 'Saved'))(t, h);
@@ -237,6 +254,12 @@ export function mountCard(el, t, h) {
237
254
  el.onclick = (e) => {
238
255
  const b = e.target.closest('button'); if (!b || b.disabled || !el.contains(b)) return;
239
256
  const d = b.dataset;
257
+ if ('tkcHist' in d) { st.histOpen = !st.histOpen; draw(); return; }
258
+ if (d.tkcHundo && h.history) {
259
+ b.disabled = true;
260
+ Promise.resolve(h.history.undo(d.tkcHundo)).catch(() => null).then((r) => { st.msg = r && r.ok !== false ? '' : (r && r.error) || 'The undo did not land.'; loadHist(); if (h.changed) h.changed(t); });
261
+ return;
262
+ }
240
263
  if (d.tkcState) { if (d.tkcState !== t.status) { st.open = null; change('status', { status: d.tkcState }); } return; }
241
264
  if ('tkcMs' in d) { st.open = null; change('milestone', { milestone: !t.milestone }); return; }
242
265
  if (d.tkcDay != null && b.closest('.tkc-dp')) { pick(d.tkcDay); return; }
@@ -272,7 +295,9 @@ export function mountCard(el, t, h) {
272
295
  // a press outside an open picker closes it (a popover opens under its control and leaves the same way)
273
296
  const away = (e) => { if (!el.isConnected) { document.removeEventListener('pointerdown', away, true); return; } if (st.open && !e.target.closest('.anc')) { st.open = null; draw(); } };
274
297
  document.addEventListener('pointerdown', away, true);
298
+ const loadHist = () => { if (h.history) Promise.resolve(h.history.load()).catch(() => null).then((L) => { st.hist = Array.isArray(L) ? L : []; draw(); }); };
275
299
  draw();
300
+ loadHist();
276
301
  return { draw, setStatus: (s) => change('status', { status: s }), task: t };
277
302
  }
278
303
 
@@ -305,6 +330,16 @@ export function toastUndo(msg, undo) {
305
330
  clearTimeout(toastUndo.t); toastUndo.t = setTimeout(() => el.classList.remove('on', 'act'), undo ? 8000 : 4200);
306
331
  }
307
332
 
333
+ /** h.history for a board task: GET /api/proposals/history and POST /api/proposals/undo (lib/routes-proposals.js). o: { ws, board, t, post } */
334
+ export function historyFor(o) {
335
+ const { ws, board, t, post } = o;
336
+ if (!t || t.jira || !t.uid || !board) return null;
337
+ return {
338
+ load: () => fetch('/api/proposals/history?board=' + encodeURIComponent(board) + (ws ? '&ws=' + encodeURIComponent(ws) : '') + '&task=' + encodeURIComponent(t.uid), { credentials: 'same-origin' })
339
+ .then((r) => r.json()).then((j) => (j && j.ok ? j.history : [])).catch(() => []),
340
+ undo: (batch) => post('/api/proposals/undo', { ws, board, batch }),
341
+ };
342
+ }
308
343
  /** The board's routes behind h.save. o: { ws, board, t, post(path, body) → Promise<json> } */
309
344
  export function boardSaver(o) {
310
345
  const { ws, board, t, post } = o;
@@ -2860,6 +2860,41 @@ const msReviewer = require('./lib/milestone-review.js').create({
2860
2860
  warn: (what, e) => warnWriteFail(what, e),
2861
2861
  });
2862
2862
  const msReviewTick = () => { try { msReviewer.tick({}); } catch (e) { warnWriteFail('milestone review tick', e); } };
2863
+ // feedback batch 12 items 2, 3 and 4 (canvas In development, Populate initiative and Task proposals): Claude's runs that file what an
2864
+ // initiative's blue ✦ proposes (lib/proposal-runs.js). An initiative just added is looked for in every connected source; each morning the
2865
+ // initiatives with a late or at-risk task are checked. The run's only write is `pmos propose`; the PM's ✓ writes. PMOS_PROPOSE=off.
2866
+ const proposalCtx = () => ({ getWs, stateDirFor, workspaceList: () => [...workspaces.values()], runtimeDir: STATE, selfRoot: EMBEDDED_SELF ? SELF_ROOT : null });
2867
+ const proposalRuns = require('./lib/proposal-runs.js').create({
2868
+ workspaces: () => [...workspaces.values()],
2869
+ isLead: (w) => isPlanNeedsTree(w),
2870
+ stateDirFor: (w) => stateDirFor(w),
2871
+ boardOf: (w, id) => require('./lib/routes-boards.js').boardIndex(proposalCtx(), w).of(id),
2872
+ created: (w) => require('./lib/plan-ledgers.js').readLines(w.root, 'placements').lines.map((x) => x.rec).filter((r) => r && r.ev === 'created').map((r) => ({ initiative: r.initiative, at: r.at })),
2873
+ checks: (w, day) => {
2874
+ const RB = require('./lib/routes-boards.js'), TLR = require('./lib/routes-task-links.js'), PR = require('./lib/proposals.js'), ctx = proposalCtx(), today = PR.dn(day), out = new Map();
2875
+ for (const b of RB.frameFor(ctx, w).boards) {
2876
+ const f = TLR.frame(ctx, w, b); if (!f) continue;
2877
+ for (const x of f.items) {
2878
+ if (!x || !x.uid || x.kind === 'Epic') continue;
2879
+ const t = PR.taskOf(x), late = PR.lateOf(t, today); if (!late || !t.ini) continue;
2880
+ if (!out.has(t.ini)) out.set(t.ini, { ini: t.ini, board: b.id, tasks: [] });
2881
+ out.get(t.ini).tasks.push(`${t.uid} · ${t.title} · due ${PR.isoN(t.e)} · ${late}${t.owner ? ' · ' + t.owner : ''}${t.jira ? ' · Jira' : ''}`);
2882
+ }
2883
+ }
2884
+ return [...out.values()];
2885
+ },
2886
+ rowOf: (w, id) => { const r = require('./lib/routes-boards.js').initiativeWorkflow(proposalCtx(), w, id); if (!r.ok) return null;
2887
+ return { title: r.row.title || id, intent: r.row.intent || r.row.why || '', stage: r.row.stage || '', stages: (r.row.wfStages || []).map((s) => ({ key: s.key, name: s.name })) }; },
2888
+ open: (now) => require('./lib/driver-run.js').dayCheckOpen(proSettings(), now, (n, q) => proactiveLib.inQuietHours(n, q)),
2889
+ headlessOff: () => headlessLib.switchedOff(process.env),
2890
+ env: process.env,
2891
+ promptFor: (skillId) => { const h = homeWorkspace(); const t = taskById(skillId, h ? h.root : SELF_ROOT); return t && t.prompt ? t.prompt : null; },
2892
+ spawn: (spec) => orchSpawn.spawn({ name: spec.name, agent: 'claude', ws: spec.ws, origin: spec.origin, initialInput: spec.initialInput, initiative: spec.initiative, extraEnv: spec.env, autoDelete: undefined, onDone: spec.onDone }),
2893
+ spawnNow: (spec) => spawnSession({ name: spec.name, agent: 'claude', ws: spec.ws, origin: spec.origin, initialInput: spec.initialInput, initiative: spec.initiative, extraEnv: spec.env, autoDelete: undefined, onDone: spec.onDone }),
2894
+ stop: (s) => { if (s && s.child) stopHeadless(s); },
2895
+ warn: (what, e) => warnWriteFail(what, e),
2896
+ });
2897
+ const proposalTick = () => { try { proposalRuns.tick({}); } catch (e) { warnWriteFail('proposal tick', e); } };
2863
2898
  // core-documents: every 30 minutes inside the working hours, ONE headless run per due core document of the portfolio and of each board
2864
2899
  // (at most 3 at once, once per document per day, never one the PM writes). The run writes a draft with `pmos coredoc write`; nothing is sent.
2865
2900
  // PMOS_CORE_DOCS_NOW (a local date-time) fixes its clock for the suites.
@@ -2958,7 +2993,7 @@ const gated = (id, fn) => () => { let g = { ok: true }; try { g = refreshRun.job
2958
2993
  // data-refresh-settings: the seed schedules move to Settings › Data refresh (refreshRun.settings(), once) BEFORE checkDueSchedules reads
2959
2994
  // schedules.json, so a schedule that is moving never fires once more from the old list on the first tick after an upgrade.
2960
2995
  const scheduleOwner = require('./lib/schedule-owner.js').create({ port: PORT });
2961
- try { const _tick = setInterval(() => { try { if (!scheduleOwner.mayRun()) return; } catch { /* no lock: run as before */ } try { refreshRun.settings(); } catch { /* the refresh tick tries again */ } checkDueSchedules(); proactiveTick(); try { prepareTick({ manual: false }); } catch { /* the next tick tries again */ } try { dayTick(); } catch (e) { warnWriteFail('day run tick', e); } try { refreshRun.tick(); } catch (e) { warnWriteFail('refresh tick', e); } try { healthTick(); } catch (e) { warnWriteFail('health tick', e); } gated('sync', () => autoSync.tick().catch(() => {}))(); dashboardScheduleTick(); orchTick(); gated('driver', driverTick)(); gated('scan', scanTick)(); gated('finder', reportFinderTick)(); gated('coredocs', coreDocsTick)(); msReviewTick(); reportDesignTick(); reportStructureTick(); }, TICK_MS); if (_tick.unref) _tick.unref(); } catch {}
2996
+ try { const _tick = setInterval(() => { try { if (!scheduleOwner.mayRun()) return; } catch { /* no lock: run as before */ } try { refreshRun.settings(); } catch { /* the refresh tick tries again */ } checkDueSchedules(); proactiveTick(); try { prepareTick({ manual: false }); } catch { /* the next tick tries again */ } try { dayTick(); } catch (e) { warnWriteFail('day run tick', e); } try { refreshRun.tick(); } catch (e) { warnWriteFail('refresh tick', e); } try { healthTick(); } catch (e) { warnWriteFail('health tick', e); } gated('sync', () => autoSync.tick().catch(() => {}))(); dashboardScheduleTick(); orchTick(); gated('driver', driverTick)(); gated('scan', scanTick)(); gated('finder', reportFinderTick)(); gated('coredocs', coreDocsTick)(); msReviewTick(); gated('propose', proposalTick)(); reportDesignTick(); reportStructureTick(); }, TICK_MS); if (_tick.unref) _tick.unref(); } catch {}
2962
2997
 
2963
2998
  // ── Sessions: real PTYs, owned by the server, with disk-backed scrollback + metadata. ──
2964
2999
  /** @type {Map<string, {id,ws,name,agent,cwd,state,note,created,pty,buf,cols,rows,clients:Set}>} */
@@ -10069,7 +10104,7 @@ async function handleRequest(req, res) {
10069
10104
  // pm-os-absorb Runs 2–5 — the planning layer's routes, one file per run (lib/route-modules.js). Last, so none shadows a route above.
10070
10105
  // meeting-notes Run 1: the Notes routes keep notes in the per-user runtime directory and start the agent-summary session.
10071
10106
  if (req.method === 'POST' && !(req.headers && req.headers['x-pmos-session'])) orchGate.touch(); // agent-orchestrator: a page press by the PM
10072
- if (await routeModules.dispatch(req, res, url, { orchestrator: { gate: orchGate, running: () => orchSpawn.running(), health: orchHealth, keepRate: orchKeepRate }, json, readBody, getWs, invalidateNeedsAgg, boardCache, consoleState, stateDirFor, sessionList, initiativeIndex,
10107
+ if (await routeModules.dispatch(req, res, url, { orchestrator: { gate: orchGate, running: () => orchSpawn.running(), health: orchHealth, keepRate: orchKeepRate }, proposalRuns, json, readBody, getWs, invalidateNeedsAgg, boardCache, consoleState, stateDirFor, sessionList, initiativeIndex,
10073
10108
  runtimeDir: STATE, homeRoot: HOME_ENABLED ? SELF_ROOT : null, spawnSession, jevModelOpts, sendToSession, endSupersededRuns, proSettings,
10074
10109
  // premium-chat-session: every premium chat panel is an interactive Claude Code session the PM talks to (text as typed, `/` kept)
10075
10110
  chatSessions,