create-pmos 0.580.0 → 0.582.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 (36) hide show
  1. package/package.json +27 -33
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +26 -0
  7. package/workspace/guide/agent-capabilities.md +24 -3
  8. package/workspace/guide/cli.md +3 -2
  9. package/workspace/guide/notes.md +4 -3
  10. package/workspace/lib/bg-queue.js +7 -3
  11. package/workspace/lib/grill-runs.js +2 -0
  12. package/workspace/lib/grill.js +1 -1
  13. package/workspace/lib/headless.js +8 -2
  14. package/workspace/lib/idle-lab-engine.js +11 -3
  15. package/workspace/lib/idle-lab.js +15 -4
  16. package/workspace/lib/job-graph.js +4 -0
  17. package/workspace/lib/lab-cli.js +26 -2
  18. package/workspace/lib/live-round-meeting.js +167 -0
  19. package/workspace/lib/live-round.js +407 -0
  20. package/workspace/lib/meeting-focus.js +42 -10
  21. package/workspace/lib/orchestrator-keeprate.js +3 -0
  22. package/workspace/lib/proposals.js +5 -2
  23. package/workspace/lib/routes-briefing-premium.js +27 -2
  24. package/workspace/lib/routes-lab.js +20 -3
  25. package/workspace/lib/routes-meeting-focus.js +57 -3
  26. package/workspace/lib/routes-proposals.js +39 -3
  27. package/workspace/package-lock.json +2 -2
  28. package/workspace/package.json +1 -1
  29. package/workspace/public/pm/cozy-lab.css +12 -0
  30. package/workspace/public/pm/cozy-lab.js +42 -7
  31. package/workspace/public/pm/cozy-rec-now.css +2 -0
  32. package/workspace/public/pm/cozy-rec-now.js +27 -8
  33. package/workspace/public/pm/ini-props.js +7 -3
  34. package/workspace/run-tests.js +35 -0
  35. package/workspace/server.js +28 -0
  36. package/workspace/test-lists/live-round.json +9 -0
@@ -9,6 +9,8 @@
9
9
  * Prototype), "Where they differ" and History. A column whose source is not proven is left out with one line
10
10
  * why (lib/idle-lab.js PROVEN). A press on a round in History puts it in the Prototype column. ✓ and ✕ in the
11
11
  * header keep or drop the round shown; ⤢ presents it on a clean screen in a new tab (GET /pm/present).
12
+ * A live round (lib/live-round.js, data.live): the card shows each version as it lands (working, made, not made); its ask (group live)
13
+ * says the directions, ✓ starts it. Its compare view puts A B C side by side; a press on a column picks it, ✓ keeps that one.
12
14
  * Every specimen loads from GET /api/lab/specimen in a sandboxed frame: it cannot reach PMOS. Nothing is written before the PM's ✓. */
13
15
  import { pmGet, pmPost } from './http.js';
14
16
 
@@ -18,7 +20,7 @@ export const I = {
18
20
  proto: 'M3 4h18v14H3zM3 9h18', round: 'M3 12a9 9 0 1 0 3-6.7L3 8M3 3v5h5', scan: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 3a15 15 0 0 1 0 18M3 12h18',
19
21
  open: 'M7 17 17 7M8 7h9v9', check: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18', present: 'M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7',
20
22
  };
21
- const GROUPS = ['prototyped', 'improved', 'scanned'];
23
+ const GROUPS = ['prototyped', 'improved', 'scanned', 'live'];
22
24
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
23
25
  const when = (iso) => { const d = new Date(iso); if (isNaN(d)) return ''; const t = new Date(); const same = d.toDateString() === t.toDateString(); return same ? 'today ' + String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0') : d.getDate() + ' ' + MON[d.getMonth()]; };
24
26
  const specUrl = (file) => '/api/lab/specimen?file=' + encodeURIComponent(file);
@@ -30,6 +32,17 @@ if (typeof document !== 'undefined' && typeof document.createElement === 'functi
30
32
  }
31
33
 
32
34
  export const isLab = (p) => !!p && GROUPS.includes(p.group);
35
+ /** True while a live round (lib/live-round.js) on these proposals still makes a version: the screens read again until each one lands. */
36
+ export function workingOf(props) {
37
+ const all = props && props.groups ? props.groups.flatMap((g) => g.props || []) : [];
38
+ return all.some((p) => p && p.data && p.data.live && (p.data.live.slots || []).some((x) => x.state === 'working' || x.state === 'proving'));
39
+ }
40
+ /** One version of a live round on its card: a thumbnail once it rendered, else what is happening (honest state). */
41
+ function slotHtml(id, x) {
42
+ if (x.state === 'ok' && x.file) return `<button type="button" class="lab-th" data-lab-open="${id}" data-lab-key="${esc(x.key)}" aria-label="${esc('Open ' + x.key + ', ' + x.title + ', in the compare view')}">${thumbHtml(x.file, x.key + ' · ' + x.title)}<span class="lab-cap"><b>${esc(x.key)} · ${esc(x.title)}</b></span></button>`;
43
+ const made = x.state === 'not made';
44
+ return `<span class="lab-th lab-slot${made ? ' no' : ' wk'}"><span class="lab-thf lab-wait" aria-hidden="true">${made ? '' : '<i></i><i></i><i></i>'}</span><span class="lab-cap"><b>${esc(x.key)} · ${esc(x.title)}</b>${esc(made ? 'Not made: ' + (x.why || 'it did not render') : 'PMOS is making it')}</span></span>`;
45
+ }
33
46
 
34
47
  /** A specimen as a still thumbnail: the page drawn at desk size and scaled down, in a frame that cannot reach PMOS. */
35
48
  export function thumbHtml(file, label) {
@@ -50,7 +63,24 @@ export function cardHtml(p, { why = false } = {}) {
50
63
  const acts = (p.group !== 'scanned' ? ib(`data-lab-open="${id}"`, 'Compare it with production and the design', I.open) : '')
51
64
  + ib(`data-lab-why="${id}" aria-expanded="${why}"`, 'Drop it', I.x) + ib(`data-pp-keep="${id}"`, 'Keep it', I.check, 'ok');
52
65
  let head = '', body = '';
53
- if (p.group === 'prototyped') {
66
+ if (p.group === 'live') {
67
+ // the live round's ask: ✓ starts it, ✕ asks why first. Nothing is made before ✓.
68
+ const dirs = (d.directions || []);
69
+ const acts2 = ib(`data-lab-why="${id}" aria-expanded="${why}"`, 'Not now', I.x) + ib(`data-pp-keep="${id}"`, p.type === 'feedback' ? 'Make this round' : 'Show it', I.check, 'ok');
70
+ const body2 = p.type === 'feedback' ? `<p class="lab-tx">${esc(p.why)}</p>` : `<ul class="lab-dirs">${dirs.map((x) => `<li><b>${esc(x.key)}</b> ${esc(x.title)}</li>`).join('')}</ul>`;
71
+ const ask2 = why ? `<div class="lab-why"><label class="vh" for="labWhy-${id}">Why not? PMOS learns from it</label><input id="labWhy-${id}" data-lab-reason="${id}" maxlength="200" placeholder="Why not? PMOS learns from it (you can leave it empty)">${ib(`data-lab-drop="${id}"`, 'Drop it now', I.x, 'solid')}</div>` : '';
72
+ return `<div class="pp-p lab" data-pp="${id}"><div class="pp-ph1"><span class="pp-ic gr">${SVG(I.proto, 16)}</span><span class="w"><b>${esc(p.title)}</b>${body2}<small class="lab-ok">About a minute. Each one shows as soon as it renders.</small>${ask2}</span><span class="pp-gacts">${acts2}</span></div></div>`;
73
+ }
74
+ if (p.group === 'prototyped' && d.live) {
75
+ const sl = d.live.slots || [], wk = sl.filter((x) => x.state === 'working' || x.state === 'proving').length;
76
+ head = p.title || `Round 1 · ${sl.length} ways`;
77
+ body = `<div class="lab-ths">${sl.map((x) => slotHtml(id, x)).join('')}</div>`
78
+ + `<small class="lab-ok">${wk ? esc(wk === 1 ? 'One more is on its way.' : wk + ' are on their way.') + ' ' : ''}${d.checked ? 'Checked: ' + esc(d.checked) : ''}</small>`;
79
+ } else if (p.group === 'improved' && d.live && !d.file) {
80
+ const x = (d.live.slots || [])[0] || {};
81
+ head = p.title || `Round ${d.round} of ${d.base || ''}`;
82
+ body = `<div class="lab-ths">${slotHtml(id, x)}</div>`;
83
+ } else if (p.group === 'prototyped') {
54
84
  const sp = d.specimens || [];
55
85
  head = p.title || `Round 1 · ${sp.length} ways to do it, so you can look instead of read`;
56
86
  body = `<div class="lab-ths">${sp.map((x) => `<button type="button" class="lab-th" data-lab-open="${id}" data-lab-key="${esc(x.key)}" aria-label="${esc('Open ' + x.key + ', ' + x.title + ', in the compare view')}">${thumbHtml(x.file, x.key + ' · ' + x.title)}<span class="lab-cap"><b>${esc(x.key)} · ${esc(x.title)}</b>${esc(x.caption)}</span></button>`).join('')}</div>`
@@ -68,13 +98,13 @@ export function cardHtml(p, { why = false } = {}) {
68
98
  }
69
99
 
70
100
  /* ── the compare view (I3) ── */
71
- const C = { at: null, id: null, key: '', c: null, H: null };
101
+ const C = { at: null, id: null, key: '', c: null, H: null, timer: null };
72
102
  async function read() {
73
103
  const at = C.at || {};
74
104
  return pmGet('/api/lab/compare?ws=' + encodeURIComponent(at.ws || '') + '&board=' + encodeURIComponent(at.board || '') + '&id=' + encodeURIComponent(C.id) + (C.key ? '&key=' + encodeURIComponent(C.key) : '')).catch(() => null);
75
105
  }
76
106
  function colHtml(col) {
77
- return `<section class="lab-col${col.id === 'prototype' ? ' now' : ''}" aria-label="${esc(col.title)}"><div class="lab-ch"><b>${esc(col.title)}</b><span>${esc(col.meta || '')}</span></div>`
107
+ return `<section class="lab-col${col.id === 'prototype' || col.current ? ' now' : ''}"${/^[A-Z]$/.test(col.id) ? ` data-lab-col="${esc(col.id)}"` : ''} aria-label="${esc(col.title)}"><div class="lab-ch"><b>${esc(col.title)}</b><span>${esc(col.meta || '')}</span></div>`
78
108
  + `<span class="lab-frame"><iframe src="${esc(col.url || specUrl(col.file))}" sandbox="allow-scripts" title="${esc(col.title)}"></iframe></span>`
79
109
  + (col.read ? `<small class="lab-ok">${esc(col.read)}</small>` : '') + '</section>';
80
110
  }
@@ -94,7 +124,7 @@ function presses(c) {
94
124
  if (!c) return [];
95
125
  // ⤢ present (live round W3): the round shown, on a clean screen in a new tab (GET /pm/present, pm/cozy-present.js)
96
126
  const present = { act: 'present', label: 'Present this round', icon: I.present };
97
- return c.state === 'open' ? [present, { act: 'drop', label: 'Drop this round', icon: I.x }, { act: 'keep', label: 'Keep this round', icon: I.check, blue: true }] : [present];
127
+ return c.state === 'open' ? [present, { act: 'drop', label: 'Drop this round', icon: I.x }, { act: 'keep', label: c.live && c.key ? 'Keep ' + c.key : 'Keep this round', icon: I.check, blue: true }] : [present];
98
128
  }
99
129
  /** The present page's address for the round shown. */
100
130
  export const presentUrl = (at, c) => '/pm/present?ws=' + encodeURIComponent((at && at.ws) || '') + '&board=' + encodeURIComponent((at && at.board) || c.board || '') + '&id=' + encodeURIComponent(c.id);
@@ -112,13 +142,17 @@ async function load() {
112
142
  // two or three columns side by side need the room: the Viewer opens wide (one column stays as it is)
113
143
  if (C.c.columns.filter((x) => !x.left).length > 1 && window.czViewer.wide) window.czViewer.wide(true);
114
144
  draw();
145
+ // a live round: its versions land one by one, so the view reads again while one is made
146
+ clearTimeout(C.timer);
147
+ if (C.c.working) { const id = C.id; C.timer = setTimeout(() => { const cur = window.czViewer && window.czViewer.current(); if (C.id === id && cur && cur.id === 'lab:cmp') load(); }, 2000); }
115
148
  }
116
149
  async function act(a) {
117
150
  const c = C.c, at = C.at || {}; if (!c) return;
118
151
  const say = (m, u) => { if (C.H && C.H.toast) C.H.toast(m, u); };
119
152
  if (a === 'present') { window.open(presentUrl(at, c), '_blank', 'noopener'); return; }
120
153
  if (a === 'keep') {
121
- const r = await pmPost('/api/proposals/keep', { ws: at.ws, board: at.board || c.board, initiative: c.ini, ids: [c.id] }).catch(() => null);
154
+ // a live round keeps the ONE version shown (its key) as the experiment's kept specimen
155
+ const r = await pmPost('/api/proposals/keep', { ws: at.ws, board: at.board || c.board, initiative: c.ini, ids: [c.id], ...(c.live && c.key ? { choices: { [c.id]: c.key } } : {}) }).catch(() => null);
122
156
  if (!r || r.ok === false) { say((r && r.error) || 'Nothing was kept.'); return; }
123
157
  say(r.said, async () => { await pmPost('/api/proposals/undo', { ws: at.ws, board: at.board || c.board, batch: r.batch }).catch(() => null); await load(); if (C.H && C.H.reload) C.H.reload(); });
124
158
  } else if (a === 'drop') {
@@ -137,7 +171,8 @@ export function openCompare({ where, id, key = '', H = null } = {}) {
137
171
  b.innerHTML = '<p class="pp-none">Reading the prototype.</p>';
138
172
  b.onclick = (e) => {
139
173
  const r = e.target.closest('[data-lab-round]'); if (r) { C.id = r.dataset.labRound; C.key = ''; load(); return; }
140
- const k = e.target.closest('[data-lab-key]'); if (k) { C.key = k.dataset.labKey; load(); }
174
+ const k = e.target.closest('[data-lab-key]'); if (k) { C.key = k.dataset.labKey; load(); return; }
175
+ const col = e.target.closest('.lab-col[data-lab-col]'); if (col && C.c && C.c.live) { C.key = col.dataset.labCol; load(); }
141
176
  };
142
177
  load();
143
178
  } });
@@ -55,6 +55,8 @@
55
55
  /* the note box */
56
56
  .rn-err { margin: 0 16px 6px; font-size: var(--fs-body); color: var(--cz-late); line-height: var(--lh-body); }
57
57
  .rn-err[hidden] { display: none; }
58
+ .rn-err.ok { color: var(--cz-ink2); }
59
+ .rn-undo { border: 0; background: none; padding: 0; font: inherit; font-weight: var(--fw-strong); color: var(--cz-blueink); cursor: pointer; }
58
60
  .rn-mine { margin: 0 12px 12px; border-radius: 18px; background: var(--cz-well); padding: 8px 8px 8px 14px; display: flex; align-items: flex-end; gap: 8px; }
59
61
  .rn-mine textarea { flex: 1; min-width: 0; min-height: 36px; max-height: 120px; resize: none; border: 0; outline: 0; background: none; font: inherit; font-size: var(--fs-body); line-height: 1.45; color: var(--cz-ink); padding: 8px 0; }
60
62
  .rn-mine textarea::placeholder { color: var(--cz-ink3); }
@@ -6,14 +6,15 @@
6
6
  * To cover is the meeting's agenda in 3 to 5 topics (pm/agenda-live.js), the same as the Viewer's Agenda.
7
7
  * transcriptModel(one, { max? }) → [Line] pure: the live transcript, oldest first, with the highlight and decision marks
8
8
  * transcriptHtml(lines) → string the 420px card's feed
9
- * kindOf(text) → 'ask' | 'note' a line that ends with "?" asks Claude; anything else is kept as a note
9
+ * kindOf(text) → 'ask' | 'note' a line that ends with "?", or asks PMOS to show something ("show 3 ways to …"), asks PMOS;
10
+ * anything else is kept as a note
10
11
  * fromLine(note) → string "From the talk and last time": where an answer came from
11
12
  * mountNow(slots, ctx) → { stop, refresh, toggleTranscript } pm/cozy-rec-tab.js mounts it: with a screen the panel fills `side`, in the room
12
13
  * it fills the light `stage`; the side-panel toggle and the transcript icon go in the bar's [data-slot="now"]; the transcript card sits beside.
13
14
  *
14
15
  * The panel has no tabs and no header. Every part is silent at zero: no topics, no prompts, no counts, no answer → no line.
15
16
  * Reads: the tab's own reads (ctx.note(): GET /api/notes/one, for the highlights and the transcript; ctx.focus(): GET /api/meeting-focus, every 15 s),
16
- * redrawn on the tab's 'note', 'mode' and 'tick'. After a press, and every 3 s while Claude answers a question, it reads GET /api/meeting-focus itself. Writes, each on a press: POST /api/meeting-focus/raise (✓ raised, ✗ not now), POST /api/notes/save
17
+ * redrawn on the tab's 'note', 'mode' and 'tick'. After a press, and every 3 s while Claude answers a question, it reads GET /api/meeting-focus itself. Writes, each on a press: POST /api/meeting-focus/raise (✓ raised, ✗ not now, Undo; ✓ on a ✦ Show it? offer starts a live round), POST /api/notes/save
17
18
  * (a note, or an answer kept with +), POST /api/meeting-focus/ask (a question; the answer comes back on the next read). */
18
19
  import { pmGet, pmPost } from './http.js';
19
20
  import { agendaHtml, ensureCss as agendaCss, press as agendaPress } from './agenda-live.js';
@@ -32,10 +33,11 @@ const svg = (d, n = 17, w = 1.8, fill = false) => `<svg width="${n}" height="${n
32
33
  const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
33
34
  const mmss = (ms) => { const s = Math.max(0, Math.floor((Number(ms) || 0) / 1000)); return Math.floor(s / 60) + ':' + String(s % 60).padStart(2, '0'); };
34
35
  const FROM_WORDS = { talk: 'the talk', screen: 'the screen', prep: 'the prep', last: 'last time' };
35
- const RAISE_LABEL = { check: 'Check', 'follow-up': 'Follow-up', 'no-owner': 'No owner yet' };
36
+ const RAISE_LABEL = { check: 'Check', 'follow-up': 'Follow-up', 'no-owner': 'No owner yet', show: 'Show it?' };
37
+ const SHOW_ASK = /^(?:(?:can|could|would)\s+(?:you|pmos)\s+|please\s+|pmos[,:]?\s+)?(?:show|prototype|mock|sketch|draw)\b/i; // lib/meeting-focus.js showIntent
36
38
  export const BOX_HINT = 'Note, or ask PMOS…';
37
39
 
38
- export const kindOf = (text) => (/\?\s*$/.test(String(text || '').trim()) ? 'ask' : 'note');
40
+ export const kindOf = (text) => { const t = String(text || '').trim(); return /\?\s*$/.test(t) || SHOW_ASK.test(t) ? 'ask' : 'note'; };
39
41
 
40
42
  /** "From the talk and last time" from an answer note's `from` list; its free `src` when it names none. */
41
43
  export function fromLine(note) {
@@ -47,6 +49,7 @@ export function fromLine(note) {
47
49
  /** The small line over a Raise now prompt: "Check · from the screen", "Follow-up · from Oct 19", "No owner yet". */
48
50
  export function raiseLabel(r) {
49
51
  const head = RAISE_LABEL[r && r.kind] || 'Raise';
52
+ if (r && r.kind === 'show') return head;
50
53
  return r && r.from && r.kind !== 'no-owner' ? head + ' · from ' + String(r.from).replace(/^from\s+/i, '') : head;
51
54
  }
52
55
 
@@ -135,8 +138,9 @@ export function nowHtml(m, { room = false } = {}) {
135
138
  }
136
139
  if (m.raise.length) {
137
140
  h += `<section class="rn-sec" aria-label="Raise now">${room ? '' : '<h5>Raise now</h5>'}<div class="rn-rz">`
138
- + m.raise.map((r) => `<div class="rn-rq" data-raise="${esc(r.id)}"><span class="w"><small>${esc(r.label)}</small>${esc(r.text)}</span>`
139
- + `<button type="button" class="rn-ib" data-rn="raised" aria-label="Raised" title="Raised">${svg(P.check)}</button>`
141
+ + m.raise.map((r) => `<div class="rn-rq" data-raise="${esc(r.id)}"${r.kind === 'show' ? ' data-show="1"' : ''}><span class="w"><small>${r.kind === 'show' ? '✦ ' : ''}${esc(r.label)}</small>${esc(r.text)}</span>`
142
+ + (r.kind === 'show' ? `<button type="button" class="rn-ib" data-rn="raised" aria-label="Show it" title="Show it">${svg(P.check)}</button>`
143
+ : `<button type="button" class="rn-ib" data-rn="raised" aria-label="Raised" title="Raised">${svg(P.check)}</button>`)
140
144
  + `<button type="button" class="rn-ib" data-rn="skip" aria-label="Not now" title="Not now">${svg(P.x)}</button></div>`).join('')
141
145
  + '</div></section>';
142
146
  }
@@ -254,7 +258,18 @@ export function mountNow(slots, ctx) {
254
258
  if (own && (!f || !f.ok || !(f.now_ms > own.now_ms))) return own;
255
259
  own = null; return f;
256
260
  };
257
- const say = (msg) => { err.textContent = msg || ''; err.hidden = !msg; };
261
+ const say = (msg, ok) => { err.textContent = msg || ''; err.hidden = !msg; err.classList.toggle('ok', !!ok); };
262
+ // ✕ on a ✦ Show it? offer: "Not now" with Undo (the offer is open again)
263
+ const undoable = (id) => {
264
+ say('Not now. ', true);
265
+ const u = document.createElement('button'); u.type = 'button'; u.className = 'rn-undo'; u.textContent = 'Undo';
266
+ u.addEventListener('click', async () => {
267
+ u.disabled = true;
268
+ const r = await pmPost('/api/meeting-focus/raise', { note: noteId(), id, action: 'undo', ws: ctx.ws });
269
+ say(r && r.ok ? '' : 'Not undone: ' + ((r && r.error) || 'no answer')); read();
270
+ });
271
+ err.appendChild(u);
272
+ };
258
273
  const draw = () => {
259
274
  if (stopped) return;
260
275
  place();
@@ -322,6 +337,7 @@ export function mountNow(slots, ctx) {
322
337
  if (kindOf(text) === 'ask') {
323
338
  const r = await pmPost('/api/meeting-focus/ask', { note: noteId(), question: text, ws: ctx.ws });
324
339
  if (!r || !r.ok) { say('PMOS could not take the question: ' + ((r && r.error) || 'no answer')); return; }
340
+ if (r.state === 'offered') { ta.value = ''; ta.dispatchEvent(new Event('input')); say(''); read(); return; } // a ✦ Show it? offer: it shows on the read
325
341
  // the question shows at once; the answer arrives on a later read
326
342
  const f = focusNow() || { ok: true };
327
343
  own = { ...f, now_ms: Number(f.now_ms) || 0, asks: [...(f.asks || []), { id: r.id, question: text, state: 'working' }] };
@@ -342,12 +358,15 @@ export function mountNow(slots, ctx) {
342
358
  const act = b.getAttribute('data-rn');
343
359
  if (act === 'raised' || act === 'skip') {
344
360
  const row = b.closest('[data-raise]'); const id = row && row.getAttribute('data-raise'); if (!id) return;
361
+ const show = row.hasAttribute('data-show');
345
362
  b.disabled = true;
346
363
  const r = await pmPost('/api/meeting-focus/raise', { note: noteId(), id, action: act, ws: ctx.ws });
347
364
  if (!r || !r.ok) { b.disabled = false; say('Not saved: ' + ((r && r.error) || 'no answer')); return; }
348
365
  const f = focusNow();
349
366
  if (f) own = { ...f, now_ms: Number(f.now_ms) || 0, raise: (f.raise || []).filter((x) => x.id !== id) };
350
- say(''); draw(); read();
367
+ draw(); read();
368
+ if (show && act === 'raised') say('PMOS is making 3 ways. Each one shows on the initiative as it lands.', true);
369
+ else if (show) undoable(id); else say('');
351
370
  } else if (act === 'keep') {
352
371
  const m = nowModel(focusNow(), oneNow());
353
372
  if (!m.answer || !m.answer.body) return;
@@ -14,6 +14,8 @@
14
14
  * On a phone the findings are cards side by side, one per screen.
15
15
  * The idle lab (canvas I2 IlB): Claude prototyped it, Claude improved it, Claude scanned for it, drawn by
16
16
  * pm/cozy-lab.js cardHtml; ⤢ opens the compare view (I3), ✕ asks why first, ✓ keeps it as a document.
17
+ * The live round (lib/live-round.js): its ✦ ask "PMOS will show 3 ways" (✓ starts it), and its card, whose
18
+ * versions land one by one (working, made, not made); the list reads again every 2 s while one is made.
17
19
  * lookHtml(v) the Tasks' dashed placeholder while Claude looks and nothing is kept yet (PiA1)
18
20
  * foundDocs(v) the documents a ✓ kept from elsewhere, for the Documents fold: [{ title, meta, ref }]
19
21
  *
@@ -40,7 +42,7 @@ const md = (iso) => { const m = DAY.exec(String(iso || '')); return m ? MON[+m[2
40
42
  const span = (a, b) => (a && b && a !== b ? md(a) + ' – ' + md(b) : md(a || b));
41
43
  const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
42
44
  const clip = (s, n) => { s = String(s || ''); return s.length > n ? s.slice(0, n - 1) + '…' : s; };
43
- const GROUP = { build: 'Pull request', harness: 'Change the factory harness', description: 'Description', outcome: 'Expected outcome', prototyped: 'PMOS prototyped it', improved: 'PMOS improved it', scanned: 'PMOS scanned for it', found: 'Found elsewhere', dates: 'Dates', status: 'Looks done', names: 'Names', links: 'Links', grill: 'PMOS grilled it' };
45
+ const GROUP = { live: 'PMOS will show it', build: 'Pull request', harness: 'Change the factory harness', description: 'Description', outcome: 'Expected outcome', prototyped: 'PMOS prototyped it', improved: 'PMOS improved it', scanned: 'PMOS scanned for it', found: 'Found elsewhere', dates: 'Dates', status: 'Looks done', names: 'Names', links: 'Links', grill: 'PMOS grilled it' };
44
46
 
45
47
  /* ── the chip and the live look ── */
46
48
  export function chipOf(p) {
@@ -62,13 +64,14 @@ export function sync(v, H) {
62
64
  VW.setChip(cur.id, c ? { ...c, quiet: true, label: c.looking ? c.label : 'What PMOS proposes on ' + (v.title || 'this initiative') + '. Open', on: () => import('./batch-press.js').then((B) => B.openBatch({ ws: at.ws, board: at.board, ini: v.id, title: v.title || v.id, props: v.props },
63
65
  { pmGet, pmPost, toast: (m) => H.toast && H.toast(m), toastUndo: (m, u) => H.toast && H.toast(m, u), reload: H.reload, full: () => open(v, H) })) } : null);
64
66
  // while Claude looks, a quiet read every few seconds; a change reads the Board again
65
- if (c && c.looking && !POLL.has(v.id)) {
67
+ // a live round (lib/live-round.js) puts each version on its card as soon as it renders: read again every few seconds while one is made
68
+ if (c && (c.looking || LC.workingOf(v.props)) && !POLL.has(v.id)) {
66
69
  const t0 = v.props.t;
67
70
  POLL.set(v.id, setTimeout(async () => {
68
71
  POLL.delete(v.id);
69
72
  const r = await read(H, v.id);
70
73
  if (r && r.ok && (!r.props || r.props.t !== t0) && H.reload) await H.reload();
71
- }, 5000));
74
+ }, LC.workingOf(v.props) ? 2500 : 5000));
72
75
  }
73
76
  }
74
77
  async function read(H, id, all) {
@@ -197,6 +200,7 @@ function draw() {
197
200
  if (VW.retitle && cur.title !== t) VW.retitle(cur.id, t);
198
201
  clearTimeout(S.timer);
199
202
  if (S.props && S.props.look && !S.props.look.ended) S.timer = setTimeout(fresh, 4000);
203
+ else if (LC.workingOf(S.props)) S.timer = setTimeout(fresh, 2000); // a live round's versions land one by one
200
204
  }
201
205
  async function fresh() {
202
206
  const id = S.id, r = await read(S.H, id, S.all);
@@ -674,6 +674,11 @@ function traceChanges(changes, ctx) {
674
674
  for (const s of list) if (/\b(loadDir|readdirSync)\(path\.join\(__dirname, 'skills'\)/.test(get(s) || '')) picked.add(s);
675
675
  continue;
676
676
  }
677
+ const nk = f === 'lib/headless.js' ? newKindOnly(sget(f), lines) : null;
678
+ if (nk) { // a new headless kind: only a run whose origin starts with its prefix takes it, so the suites that name the prefix or the kind
679
+ for (const s of list) if (s === 'headless.test.js' || nk.some((x) => (get(s) || '').includes(x))) picked.add(s);
680
+ continue;
681
+ }
677
682
  let why = null;
678
683
  const before = picked.size;
679
684
  if (get(f) == null) { // removed: only the names in the suites can say who used it
@@ -697,6 +702,36 @@ function traceChanges(changes, ctx) {
697
702
  return { suites: list.filter((s) => picked.has(s)), why: `${changes.length} changed file(s) reach these suites` };
698
703
  }
699
704
 
705
+ /* live-round (W1): lib/headless.js decides the kind of EVERY spawn through kindFor(), so a change there reaches every suite. A change that
706
+ * only ADDS a kind is narrower: a new `const X_ORIGINS = Object.freeze(['p:'])`, its `if (X_ORIGINS.some(...)) return 'k';` line in kindFor,
707
+ * its TOOLS entry and its name on WRITE_DIR_KINDS or WRITE_PATH_KINDS change only runs whose origin starts with 'p:'. Returns the new
708
+ * prefixes and kinds (quoted, as the suites name them), or null when any changed line is something else. `src` is without comments. */
709
+ function newKindOnly(src, lines) {
710
+ if (src == null || !Array.isArray(lines) || !lines.length) return null;
711
+ const C = src.split('\n');
712
+ const consts = new Map(); const kinds = new Set(); const later = [];
713
+ for (const n of lines) {
714
+ const l = (C[n - 1] || '').trim();
715
+ if (!l) continue;
716
+ let m = /^const ([A-Z_]+_ORIGINS) = Object\.freeze\(\[((?:\s*'[\w-]+:',?)+)\s*\]\);$/.exec(l);
717
+ if (m) { consts.set(m[1], [...m[2].matchAll(/'([\w-]+:)'/g)].map((x) => x[1])); continue; }
718
+ m = /^if \(([A-Z_]+_ORIGINS)\.some\(\(p\) => o\.startsWith\(p\)\)\) return '([\w-]+)';$/.exec(l);
719
+ if (m) { later.push(['if', m[1], m[2]]); continue; }
720
+ m = /^'([\w-]+)': Object\.freeze\(\[[^\]]*\]\),$/.exec(l);
721
+ if (m) { later.push(['kind', m[1]]); continue; }
722
+ m = /^const (WRITE_DIR_KINDS|WRITE_PATH_KINDS) = Object\.freeze\(\[([^\]]*)\]\);$/.exec(l);
723
+ if (m) { later.push(['list', [...m[2].matchAll(/'([\w-]+)'/g)].map((x) => x[1])]); continue; }
724
+ return null;
725
+ }
726
+ for (const x of later) if (x[0] === 'if') { if (!consts.has(x[1])) return null; kinds.add(x[2]); }
727
+ if (!kinds.size) return null;
728
+ for (const x of later) {
729
+ if (x[0] === 'kind' && !kinds.has(x[1])) return null;
730
+ if (x[0] === 'list' && ![...kinds].some((k) => x[1].includes(k))) return null;
731
+ }
732
+ return [...[...consts.values()].flat(), ...kinds].map((x) => `'${x}`);
733
+ }
734
+
700
735
  /* The suites in `list` that the diff against `ref` can reach, by traceChanges() above. Returns { files, suites, why }. */
701
736
  function changedSuites(list, ref, { exact = false } = {}) {
702
737
  const git = (...a) => {
@@ -3405,6 +3405,34 @@ const idleLab = require('./lib/idle-lab-engine.js').create({
3405
3405
  env: process.env,
3406
3406
  warn: (what, e) => warnWriteFail(what, e),
3407
3407
  });
3408
+ // the live round (lib/live-round.js, initiative live-round): the PM asks to see an idea, at any moment; ✓ on its ✦ ask (or `pmos lab round`)
3409
+ // starts three headless runs at once (step 1 of the queue: never held, never on the idle clock), and each version shows under the ✦ as soon
3410
+ // as it renders. A plain spawn: a run the PM asked for is not counted or held by the capacity governor. W2 (the meeting) calls round().
3411
+ const liveRound = require('./lib/live-round.js').install({
3412
+ runtimeDir: () => STATE,
3413
+ ownRoot: path.resolve(__dirname),
3414
+ product: (ws) => { const w = workspaces.get(ws) || null; if (!w) return null; const dir = stateDirFor(w); return dir ? { w, dir } : null; },
3415
+ info: (ws, ini) => {
3416
+ const w = workspaces.get(ws); if (!w) return null;
3417
+ let row = null; try { const b = require('./lib/routes-boards.js').baseRows(w); if (b && b.ok) row = (b.rows || []).find((r) => r && r.id === ini) || null; } catch { row = null; }
3418
+ let intent = ''; try { const AF = require('./lib/artefacts.js'), dir = stateDirFor(w); const st = AF.fold(AF.readLines(AF.file(dir))); const it = AF.intentOf(st, [row && row.board ? 'board:' + row.board : null, 'portfolio'].filter(Boolean)); intent = it && it.fields.want ? it.fields.want.text : ''; } catch { intent = ''; }
3419
+ return { title: (row && row.title) || ini, board: (row && row.board) || '', description: (row && row.description) || '', intent };
3420
+ },
3421
+ spawn: (spec) => spawnSession({ name: spec.name, agent: 'claude', ws: spec.ws, origin: spec.origin, initialInput: spec.initialInput, initiative: spec.initiative,
3422
+ writePaths: spec.writePaths, addDirs: spec.addDirs, autoDelete: undefined, onDone: spec.onDone }),
3423
+ stop: (s) => { if (s && s.child) stopHeadless(s); },
3424
+ artefact: (dir, line, by) => { const AF = require('./lib/artefacts.js'); return AF.set(AF.file(dir), line, { by }); },
3425
+ warn: (what, e) => warnWriteFail(what, e),
3426
+ });
3427
+ // live round before a meeting (lib/live-round-meeting.js, initiative live-round-meeting): step 2 of the queue. A meeting in the next hour
3428
+ // whose agenda or material names an early initiative with no prototype gets round 1 (lib/live-round.js), so it waits under ✦ at minute 0.
3429
+ const meetingPrewarm = require('./lib/live-round-meeting.js').create({
3430
+ runtimeDir: () => STATE,
3431
+ queue: bgQueue, // it registers itself as the queue's step-2 job `meeting-prewarm`
3432
+ events: (now) => require('./lib/calendar-events.js').readAll(STATE, { now }),
3433
+ products: () => idleLab.products(Date.now()), // the products the idle lab reads (its 10-minute cache)
3434
+ warn: (what, e) => warnWriteFail(what, e),
3435
+ });
3408
3436
  try { const _tick = setInterval(() => { try { if (!scheduleOwner.mayRun()) return; } catch { /* no lock: run as before */ } try { refreshRun.settings(); } catch { /* the refresh tick tries again */ } try { healthTick(); } catch (e) { warnWriteFail('health tick', e); } orchTick(); bgQueue.tick(); }, TICK_MS); if (_tick.unref) _tick.unref(); } catch {}
3409
3437
 
3410
3438
  // ── Sessions: real PTYs, owned by the server, with disk-backed scrollback + metadata. ──
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "The live round (initiative live-round, 2026-11-17): a chat sentence files ONE ✦ ask, ✓ starts three runs at once, each file proven the moment it lands, a run past the 2 minute budget is not made with the reason, a feedback round is one run on the base version, the compare view puts A B C side by side, and `pmos lab round` reaches the server (lib/live-round.js, lib/lab-cli.js, lib/routes-briefing-premium.js liveAsk). A fake run: no server, model, browser or network.",
3
+ "modules": [
4
+ "live-round.test.js"
5
+ ],
6
+ "seconds": {
7
+ "live-round.test.js": 2
8
+ }
9
+ }