create-pmos 0.522.0 → 0.524.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 (65) hide show
  1. package/bin/create-pmos.js +26 -1
  2. package/package.json +57 -47
  3. package/payload/KIT-VERSION +1 -1
  4. package/payload/planning/evals/eval-calibration.md +1 -1
  5. package/payload/planning/okrs/health-budgets.md +1 -1
  6. package/payload/state/discoveries.md +1 -1
  7. package/workspace/changelog.json +56 -0
  8. package/workspace/guide/agent-capabilities.md +6 -3
  9. package/workspace/guide/home.md +1 -1
  10. package/workspace/guide/horizon-scan.md +2 -2
  11. package/workspace/guide/idle-lab.md +46 -0
  12. package/workspace/guide/index.md +2 -0
  13. package/workspace/guide/moments.md +43 -0
  14. package/workspace/guide/welcome.md +37 -28
  15. package/workspace/lib/bg-queue.js +226 -0
  16. package/workspace/lib/connector-read.js +19 -0
  17. package/workspace/lib/driver-run.js +8 -1
  18. package/workspace/lib/first-reveal.js +311 -0
  19. package/workspace/lib/headless.js +2 -2
  20. package/workspace/lib/idle-lab.js +275 -0
  21. package/workspace/lib/moments.js +241 -0
  22. package/workspace/lib/morning-goals.js +191 -0
  23. package/workspace/lib/onboard-fundamentals.js +205 -0
  24. package/workspace/lib/onboarding-progress.js +13 -1
  25. package/workspace/lib/orchestrator-spawn.js +9 -2
  26. package/workspace/lib/project-onboard.js +93 -22
  27. package/workspace/lib/proposals.js +9 -5
  28. package/workspace/lib/refresh-run.js +2 -1
  29. package/workspace/lib/route-modules.js +4 -0
  30. package/workspace/lib/routes-lab.js +137 -0
  31. package/workspace/lib/routes-loose.js +1 -0
  32. package/workspace/lib/routes-moments.js +42 -0
  33. package/workspace/lib/routes-morning-goals.js +109 -0
  34. package/workspace/lib/routes-onboard.js +45 -8
  35. package/workspace/lib/routes-proposals.js +12 -2
  36. package/workspace/lib/routes-reveal.js +73 -0
  37. package/workspace/lib/scan-run.js +4 -3
  38. package/workspace/lib/scan.js +5 -3
  39. package/workspace/package-lock.json +2 -2
  40. package/workspace/package.json +1 -1
  41. package/workspace/project-onboard-flow-test.js +70 -57
  42. package/workspace/public/pm/cozy-ev.css +3 -0
  43. package/workspace/public/pm/cozy-lab-ins.js +87 -0
  44. package/workspace/public/pm/cozy-lab.css +86 -0
  45. package/workspace/public/pm/cozy-lab.js +138 -0
  46. package/workspace/public/pm/cozy-nav.js +22 -8
  47. package/workspace/public/pm/cozy-onboard.css +31 -0
  48. package/workspace/public/pm/cozy-onboard.js +217 -111
  49. package/workspace/public/pm/cozy-reveal.css +52 -0
  50. package/workspace/public/pm/cozy-reveal.js +130 -0
  51. package/workspace/public/pm/home-app.js +38 -3
  52. package/workspace/public/pm/home-impact.css +12 -0
  53. package/workspace/public/pm/home-moment.js +41 -0
  54. package/workspace/public/pm/ini-props.js +15 -6
  55. package/workspace/public/pm/premium-board.js +2 -0
  56. package/workspace/public/pm/premium-first.js +1 -1
  57. package/workspace/public/pm/premium-insights.js +6 -1
  58. package/workspace/public/pm/quiet-place.js +31 -0
  59. package/workspace/public/premium-intelligence.html +3 -0
  60. package/workspace/replaced-tests.json +14 -0
  61. package/workspace/server.js +46 -5
  62. package/workspace/test-files.json +2 -0
  63. package/workspace/test-lists/first-reveal.json +9 -0
  64. package/workspace/test-lists/idle-lab.json +9 -0
  65. package/workspace/test-lists/morning-goals.json +9 -0
@@ -0,0 +1,87 @@
1
+ /* pm/cozy-lab-ins.js — Intelligence › Lab (build U, idle-lab B+C 2026-11-04; canvas main, In development I1 IlBC). One section under "Did it work?".
2
+ * Top to bottom: Claude's ✦ line for the week (the idle time it used, how many you kept, what fits no initiative), the ✦ that fit no
3
+ * initiative (✓ keep, ✕ drop with an optional reason, Undo in the toast), then two cards side by side: "What Claude did in the background"
4
+ * (every background job this week, links only: a result on an initiative waits there, said once) and "You kept" with "Next time you step
5
+ * away" (read only: to skip one, say so in chat). Hidden while GET /api/lab answers null, so the Lab appears only once there is something
6
+ * (zero is silence; onboarding A4, gradual exposure). Every press is icon-only.
7
+ *
8
+ * mount({ el, where() → { ws, board }, iniHref(id), toast(text, undo?) }) then load() after each read of the page
9
+ * load() reads GET /api/lab and draws */
10
+ import { pmGet, pmPost } from './http.js';
11
+ import * as LC from './cozy-lab.js';
12
+
13
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
14
+ 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>`;
15
+ const ICON = { prototyped: LC.I.proto, improved: LC.I.round, scanned: LC.I.scan, loose: LC.I.scan, job: 'M4 6h16M4 12h10M4 18h7' };
16
+ const S = { H: null, lab: null, why: null };
17
+ const ib = (attr, label, icon, cls = '') => `<button type="button" class="lab-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon, 16, 2.2)}</button>`;
18
+
19
+ function looseHtml(p) {
20
+ const why = S.why === p.id, id = esc(p.id);
21
+ const src = (p.sources || []).filter((s) => /^https?:\/\//.test(s.ref || '')).map((s) => `<a href="${esc(s.ref)}" target="_blank" rel="noopener noreferrer">${esc(s.label)}</a>`).join(', ');
22
+ const ask = p.type === 'start' && p.data ? ` Start an initiative <i>“${esc(p.data.title)}”</i>${p.data.stage ? ', ' + esc(p.data.stage) : ''}?` : '';
23
+ return `<div class="lab-card lab-lo" data-lab-id="${id}"><div class="lab-bar"><span class="lab-sp" aria-hidden="true">✦</span><b>${esc(p.title)}</b><span class="lab-acts">`
24
+ + ib(`data-lab-why="${id}" aria-expanded="${why}"`, 'Drop it', LC.I.x) + ib(`data-lab-keep="${id}"`, p.type === 'start' ? 'Start it' : 'Keep it', LC.I.check, 'ok') + '</span></div>'
25
+ + `<p class="lab-tx">${esc(p.why)}${ask}</p><small class="lab-ok">Read: ${(p.sources || []).length} ${(p.sources || []).length === 1 ? 'page' : 'pages'}${p.data && p.data.refreshed ? ' · ' + esc(p.data.refreshed) : ''}${src ? ' · ' + src : ''}</small>`
26
+ + (why ? `<div class="lab-why"><label class="vh" for="labLw-${id}">Why drop it? Claude learns from it</label><input id="labLw-${id}" data-lab-reason="${id}" maxlength="200" placeholder="Why not? Claude learns from it (you can leave it empty)">${ib(`data-lab-drop="${id}"`, 'Drop it now', LC.I.x, 'solid')}</div>` : '')
27
+ + '</div>';
28
+ }
29
+ function pillOf(r) {
30
+ if (r.state === 'kept') return '<span class="lab-pill ok">kept</span>';
31
+ if (r.state === 'dropped') return `<span class="lab-pill">dropped${r.why ? ' · “' + esc(r.why) + '”' : ''}</span>`;
32
+ if (r.kind === 'loose') return '<span class="lab-pill y">✦ above</span>';
33
+ if (r.ini) return `<a class="lab-pill y" href="${esc(S.H.iniHref(r.ini))}">✦ on initiative</a>`;
34
+ return '';
35
+ }
36
+ function recRow(r) {
37
+ const open = r.compare ? ib(`data-lab-cmp="${esc(r.id)}" data-lab-board="${esc(r.board || '')}"`, 'Open in the compare view', LC.I.open) : '';
38
+ const pill = r.kind === 'job' ? (r.ini ? `<a class="lab-pill" href="${esc(S.H.iniHref(r.ini))}">initiative</a>` : '') : pillOf(r);
39
+ return `<div class="lab-row"><span class="lab-ico">${SVG(ICON[r.kind] || ICON.job, 18)}</span><span class="w"><b>${esc(r.title)}</b><small>${esc(r.meta || '')}</small></span>${pill}${open}</div>`;
40
+ }
41
+ function html(L) {
42
+ const k = L.kept;
43
+ const keptCard = k ? `<div class="lab-card"><small>You kept</small><b class="lab-big">${k.kept} of ${k.filed}</b><small>${[k.proto[1] ? 'prototypes ' + k.proto[0] + ' of ' + k.proto[1] : '', k.scan[1] ? 'scans ' + k.scan[0] + ' of ' + k.scan[1] : ''].filter(Boolean).join(' · ')}. Claude learns from each reason you give.</small></div>` : '';
44
+ const next = L.next.length ? `<div class="lab-card"><b>Next time you step away</b>${L.next.map((x) => `<div class="lab-row"><span class="lab-dot open"></span><span class="w">${esc(x.title)}${x.why ? `<small>${esc(x.why)}</small>` : ''}</span></div>`).join('')}<small>Claude picks these by itself. To skip one, say so in chat.</small></div>` : '';
45
+ const rec = L.record.length ? `<div class="lab-card lab-rec"><div class="lab-bar"><b>What Claude did in the background</b><small>this week, every job</small></div>${L.record.map(recRow).join('')}${L.more ? `<small>and ${L.more} more</small>` : ''}</div>` : '';
46
+ return `<h2 class="ins-h3" id="hLab">Lab</h2>`
47
+ + (L.say ? `<p class="lab-say"><span aria-hidden="true">✦</span> ${esc(L.say)}</p>` : '')
48
+ + L.loose.map(looseHtml).join('')
49
+ + (rec || keptCard || next ? `<div class="lab-2">${rec}${keptCard || next ? `<div class="lab-side">${keptCard}${next}</div>` : ''}</div>` : '');
50
+ }
51
+ function draw() {
52
+ const el = S.H && S.H.el; if (!el) return;
53
+ if (!S.lab) { el.hidden = true; el.innerHTML = ''; return; }
54
+ el.hidden = false; el.innerHTML = html(S.lab);
55
+ }
56
+ export async function load() {
57
+ if (!S.H) return;
58
+ const at = S.H.where() || {};
59
+ const r = await pmGet('/api/lab?ws=' + encodeURIComponent(at.ws || '') + '&board=' + encodeURIComponent(at.board || '')).catch(() => null);
60
+ // a failed read draws nothing (quiet): the section is an extra, the page around it stays
61
+ S.lab = r && r.ok ? r.lab : null; draw();
62
+ }
63
+ async function post(route, body) { const at = S.H.where() || {}; return pmPost(route, { ws: at.ws, ...body }).catch(() => null); }
64
+ async function press(e) {
65
+ const b = e.target.closest('button'); if (!b || b.disabled) return;
66
+ const d = b.dataset, say = (m, u) => S.H.toast(m, u);
67
+ if (d.labWhy) { S.why = S.why === d.labWhy ? null : d.labWhy; draw(); const i = S.H.el.querySelector(`[data-lab-reason="${CSS.escape(d.labWhy)}"]`); if (i) i.focus(); return; }
68
+ if (d.labDrop) {
69
+ const i = S.H.el.querySelector(`[data-lab-reason="${CSS.escape(d.labDrop)}"]`); b.disabled = true; S.why = null;
70
+ const r = await post('/api/lab/drop', { id: d.labDrop, ...(i && i.value.trim() ? { why: i.value.trim() } : {}) });
71
+ if (!r || r.ok === false) { say((r && r.error) || 'Nothing was changed.'); b.disabled = false; return; }
72
+ say('Dropped.', async () => { await post('/api/lab/undo', { batch: r.batch }); await load(); }); await load(); return;
73
+ }
74
+ if (d.labKeep) {
75
+ b.disabled = true;
76
+ const r = await post('/api/lab/keep', { id: d.labKeep });
77
+ if (!r || r.ok === false) { say((r && r.error) || 'Nothing was kept.'); b.disabled = false; return; }
78
+ say(r.said, async () => { await post('/api/lab/undo', { batch: r.batch }); await load(); }); await load(); return;
79
+ }
80
+ if (d.labCmp) { const at = S.H.where() || {}; LC.openCompare({ where: { ws: at.ws, board: d.labBoard || at.board }, id: d.labCmp, H: { toast: S.H.toast, reload: load } }); }
81
+ }
82
+ export function mount(H) {
83
+ S.H = H;
84
+ if (!H.el) return;
85
+ H.el.addEventListener('click', press);
86
+ H.el.addEventListener('keydown', (e) => { if (e.key === 'Enter' && e.target.matches('[data-lab-reason]')) { e.preventDefault(); const x = e.target.closest('.lab-card').querySelector('[data-lab-drop]'); if (x) x.click(); } });
87
+ }
@@ -0,0 +1,86 @@
1
+ /* cozy-lab.css — the idle lab on the screen (build U, idle-lab B+C 2026-11-04; canvas main, In development I1 IlBC, I2 IlB, I3 IlCompare).
2
+ * The ✦ cards under an initiative's blue ✦ (pm/cozy-lab.js cardHtml, inside pm/ini-props.js), the compare view in the Viewer
3
+ * (openCompare) and Intelligence › Lab (pm/cozy-lab-ins.js). Agreed type roles only (--fs-/--fw-/--lh-), the cozy tokens for colour.
4
+ * Loaded once by pm/cozy-lab.js. */
5
+ .lab-sec .vh, .lab-cmp .vh, .pp-p.lab .vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
6
+
7
+ /* ── the ✦ cards (I2) ── */
8
+ .pp-p.lab .w { gap: 6px; }
9
+ .lab-ths { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 4px; }
10
+ .lab-th { display: flex; flex-direction: column; border: 1px solid var(--cz-hair); border-radius: 12px; overflow: hidden; background: var(--cz-card); text-align: left; cursor: pointer; }
11
+ .lab-th:hover { border-color: var(--cz-blue); }
12
+ .lab-th:focus-visible, .lab-ib:focus-visible, .lab-key:focus-visible, .lab-hr:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
13
+ .lab-thf { display: block; position: relative; height: 112px; overflow: hidden; background: var(--cz-well); pointer-events: none; }
14
+ .lab-thf iframe { position: absolute; left: 0; top: 0; width: 1280px; height: 800px; border: 0; transform: scale(.14); transform-origin: 0 0; background: var(--cz-card); }
15
+ .lab-cap { display: flex; flex-direction: column; gap: 1px; padding: 8px 10px; font-size: var(--fs-meta); line-height: var(--lh-meta); color: var(--cz-ink2); }
16
+ .lab-cap b { font-size: var(--fs-meta); font-weight: var(--fw-strong); color: var(--cz-ink); }
17
+ .lab-tx { margin: 0; font-size: var(--fs-body); line-height: var(--lh-body); color: var(--cz-ink2); }
18
+ .lab-tx b { font-weight: var(--fw-strong); color: var(--cz-ink); }
19
+ .lab-ok { font-size: var(--fs-meta); line-height: var(--lh-meta); color: var(--cz-ok); }
20
+ .lab-ok a, .lab-tx a { color: inherit; }
21
+ .lab-why { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
22
+ .lab-why input { flex: 1; min-width: 0; min-height: 36px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); font: inherit; font-size: var(--fs-meta); line-height: var(--lh-meta); }
23
+ .lab-why input:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 1px; }
24
+ .pp .pp-ib.solid, .lab-ib.solid { background: var(--cz-solid); color: var(--cz-onsolid); }
25
+
26
+ /* ── the compare view (I3) ── */
27
+ .lab-cmp { display: flex; flex-direction: column; gap: 14px; font-family: var(--cz-sans); color: var(--cz-ink); }
28
+ .lab-say { margin: 0; display: flex; gap: 8px; align-items: baseline; padding: 10px 12px; border-radius: 14px; background: var(--cz-bluebg); color: var(--cz-ink2); font-size: var(--fs-body); line-height: var(--lh-body); }
29
+ .lab-say > span { color: var(--cz-blueink); font-weight: var(--fw-strong); }
30
+ .lab-cols { display: grid; grid-template-columns: repeat(var(--n, 1), minmax(0, 1fr)); gap: 14px; }
31
+ .lab-col { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--cz-hair); border-radius: 16px; background: var(--cz-card); }
32
+ .lab-col.now { border-color: var(--cz-blue); }
33
+ .lab-ch { display: flex; align-items: baseline; gap: 8px; }
34
+ .lab-ch b { font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
35
+ .lab-ch span { font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
36
+ .lab-frame { display: block; border: 1px solid var(--cz-hair); border-radius: 12px; overflow: hidden; background: var(--cz-card); }
37
+ .lab-frame iframe { display: block; width: 100%; height: 460px; border: 0; }
38
+ .lab-left { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
39
+ .lab-left b { font-weight: var(--fw-strong); color: var(--cz-ink2); }
40
+ .lab-below { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; }
41
+ .lab-below > .lab-hist:only-child { grid-column: 1 / -1; }
42
+ .lab-card { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border: 1px solid var(--cz-hair); border-radius: 16px; background: var(--cz-card); font-size: var(--fs-body); line-height: var(--lh-body); }
43
+ .lab-card > b { font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
44
+ .lab-card small { font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
45
+ .lab-hn { font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
46
+ .lab-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--cz-hair); font-size: var(--fs-body); line-height: var(--lh-row); color: var(--cz-ink); }
47
+ .lab-card > b + .lab-row, .lab-hn + .lab-row, .lab-bar + .lab-row { border-top: 0; }
48
+ .lab-row .w { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
49
+ .lab-row .w b { font-weight: var(--fw-strong); }
50
+ .lab-hr { width: 100%; text-align: left; font: inherit; color: inherit; background: none; border: 0; border-top: 1px solid var(--cz-hair); cursor: pointer; border-radius: 0; }
51
+ .lab-hr[aria-current="true"] .w b { color: var(--cz-blueink); }
52
+ .lab-pin { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; background: var(--cz-blueink); color: var(--cz-onsolid); font-size: var(--fs-badge); font-weight: var(--fw-strong); line-height: var(--lh-badge); }
53
+ .lab-pin.production { background: var(--cz-risk); }
54
+ .lab-pin.design { background: var(--cz-ok); }
55
+ .lab-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--cz-blue); }
56
+ .lab-dot.kept { background: var(--cz-ok); }
57
+ .lab-dot.dropped { background: var(--cz-ink3); }
58
+ .lab-keys { display: inline-flex; gap: 4px; padding: 0 0 6px 19px; }
59
+ .lab-key { min-width: 32px; height: 28px; padding: 0 8px; border-radius: 999px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink2); font: inherit; font-size: var(--fs-meta); font-weight: var(--fw-strong); cursor: pointer; }
60
+ .lab-key[aria-pressed="true"] { background: var(--cz-bluebg); color: var(--cz-blueink); border-color: transparent; }
61
+
62
+ /* ── Intelligence › Lab (I1) ── */
63
+ .lab-sec { gap: 14px; }
64
+ .lab-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
65
+ .lab-bar b { font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
66
+ .lab-bar small { font-size: var(--fs-meta); color: var(--cz-ink3); }
67
+ .lab-sp { color: var(--cz-blueink); font-weight: var(--fw-strong); }
68
+ .lab-acts { margin-left: auto; display: inline-flex; gap: 4px; }
69
+ .lab-ib { width: 32px; height: 32px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; flex: none; color: var(--cz-ink2); background: none; border: 1px solid var(--cz-hair); cursor: pointer; padding: 0; }
70
+ .lab-ib.ok { background: var(--cz-blueink); color: var(--cz-onsolid); border-color: transparent; }
71
+ .lab-ib:hover { color: var(--cz-ink); }
72
+ .lab-ico { width: 34px; height: 34px; border-radius: 10px; background: var(--cz-well); color: var(--cz-ink2); display: inline-flex; align-items: center; justify-content: center; flex: none; }
73
+ .lab-pill { display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; background: var(--cz-well); color: var(--cz-ink2); font-size: var(--fs-badge); font-weight: var(--fw-strong); line-height: var(--lh-badge); white-space: nowrap; text-decoration: none; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
74
+ .lab-pill.ok { background: var(--cz-okbg); color: var(--cz-ok); }
75
+ .lab-pill.y { background: var(--cz-bluebg); color: var(--cz-blueink); }
76
+ .lab-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; align-items: start; }
77
+ .lab-2 > .lab-rec:only-child { grid-column: 1 / -1; }
78
+ .lab-side { display: flex; flex-direction: column; gap: 14px; }
79
+ .lab-big { font-size: var(--fs-page); font-weight: var(--fw-strong); line-height: var(--lh-page); }
80
+
81
+ @media (max-width: 760px) {
82
+ .lab-cols, .lab-below, .lab-2 { grid-template-columns: 1fr; }
83
+ .lab-frame iframe { height: 380px; }
84
+ .lab-ib { width: 44px; height: 44px; }
85
+ .lab-ths { grid-template-columns: 1fr 1fr; }
86
+ }
@@ -0,0 +1,138 @@
1
+ /* pm/cozy-lab.js — the idle lab on the screen (build U, idle-lab B+C 2026-11-04; canvas main, In development I2 IlB, I3 IlCompare).
2
+ *
3
+ * isLab(p) a proposal of the idle lab (group prototyped, improved or scanned; lib/idle-lab.js result)
4
+ * cardHtml(p, { why }) its ✦ card under the initiative's blue ✦ (pm/ini-props.js draws the list): "Claude prototyped it" shows round 1
5
+ * as thumbnails, each one a press that opens the compare view; "Claude improved it" says what changed and from
6
+ * what; "Claude scanned for it" is a finding to attach as evidence, with the pages it read. Icon-only presses:
7
+ * ⤢ compare, ✕ drop (it asks why first: Claude learns from it; the reason is optional), ✓ keep.
8
+ * openCompare({ where: { ws, board }, id, key?, H? }) the compare view in the Viewer: the ✦ line, the columns (Production, Design,
9
+ * Prototype), "Where they differ" and History. A column whose source is not proven is left out with one line
10
+ * why (lib/idle-lab.js PROVEN). A press on a round in History puts it in the Prototype column. ✓ and ✕ in the
11
+ * header keep or drop the round shown.
12
+ * Every specimen loads from GET /api/lab/specimen in a sandboxed frame: it cannot reach PMOS. Nothing is written before the PM's ✓. */
13
+ import { pmGet, pmPost } from './http.js';
14
+
15
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
16
+ 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>`;
17
+ export const I = {
18
+ 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
+ open: 'M7 17 17 7M8 7h9v9', check: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18',
20
+ };
21
+ const GROUPS = ['prototyped', 'improved', 'scanned'];
22
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
23
+ 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
+ const specUrl = (file) => '/api/lab/specimen?file=' + encodeURIComponent(file);
25
+ 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>`;
26
+
27
+ // the look, loaded once (cozy-lab.css)
28
+ if (typeof document !== 'undefined' && typeof document.createElement === 'function' && document.head && !document.querySelector('link[data-lab-css]')) {
29
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = new URL('./cozy-lab.css', import.meta.url).href; l.dataset.labCss = '1'; document.head.appendChild(l);
30
+ }
31
+
32
+ export const isLab = (p) => !!p && GROUPS.includes(p.group);
33
+
34
+ /** A specimen as a still thumbnail: the page drawn at desk size and scaled down, in a frame that cannot reach PMOS. */
35
+ export function thumbHtml(file, label) {
36
+ return `<span class="lab-thf" aria-hidden="true"><iframe src="${esc(specUrl(file))}" sandbox="allow-scripts" loading="lazy" tabindex="-1" title="${esc(label)}"></iframe></span>`;
37
+ }
38
+ function srcLine(p) {
39
+ const s = p.sources || [];
40
+ if (p.group === 'scanned') {
41
+ const d = p.data || {}, n = d.pages || s.length;
42
+ const links = s.filter((x) => /^https?:\/\//.test(x.ref || '')).map((x) => `<a href="${esc(x.ref)}" target="_blank" rel="noopener noreferrer">${esc(x.label)}</a>`).join(', ');
43
+ return `Read: ${n} ${n === 1 ? 'page' : 'pages'}${d.refreshed ? ' · ' + esc(d.refreshed) : ''}${links ? ' · ' + links : ''}`;
44
+ }
45
+ return esc(s.map((x) => x.label).join(', '));
46
+ }
47
+ /** The ✦ card. why: the ✕ was pressed, so the card asks why before it drops. */
48
+ export function cardHtml(p, { why = false } = {}) {
49
+ const d = p.data || {}, id = esc(p.id);
50
+ const acts = (p.group !== 'scanned' ? ib(`data-lab-open="${id}"`, 'Compare it with production and the design', I.open) : '')
51
+ + ib(`data-lab-why="${id}" aria-expanded="${why}"`, 'Drop it', I.x) + ib(`data-pp-keep="${id}"`, 'Keep it', I.check, 'ok');
52
+ let head = '', body = '';
53
+ if (p.group === 'prototyped') {
54
+ const sp = d.specimens || [];
55
+ head = p.title || `Round 1 · ${sp.length} ways to do it, so you can look instead of read`;
56
+ 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>`
57
+ + `<small class="lab-ok">Checked: ${esc(d.checked || '')}${p.sources && p.sources.length ? ' · built from ' + srcLine(p) : ''}</small>`;
58
+ } else if (p.group === 'improved') {
59
+ head = p.title || `Round ${d.round} of ${d.base || ''}`;
60
+ body = `<p class="lab-tx">${esc(p.why)} <b>${esc(d.changed || '')}</b></p><small class="lab-ok">Source: ${srcLine(p)}${d.checked ? ' · ' + esc(d.checked) : ''}</small>`;
61
+ } else {
62
+ head = p.title || 'Attach as evidence';
63
+ body = `<p class="lab-tx">${esc(p.why)}</p><small class="lab-ok">${srcLine(p)}</small>`;
64
+ }
65
+ const ask = why ? `<div class="lab-why"><label class="vh" for="labWhy-${id}">Why drop it? Claude learns from it</label><input id="labWhy-${id}" data-lab-reason="${id}" maxlength="200" placeholder="Why not? Claude learns from it (you can leave it empty)">${ib(`data-lab-drop="${id}"`, 'Drop it now', I.x, 'solid')}</div>` : '';
66
+ const icon = p.group === 'prototyped' ? I.proto : p.group === 'improved' ? I.round : I.scan;
67
+ return `<div class="pp-p lab" data-pp="${id}"><div class="pp-ph1"><span class="pp-ic gr">${SVG(icon, 16)}</span><span class="w"><b>${esc(head)}</b>${body}${ask}</span><span class="pp-gacts">${acts}</span></div></div>`;
68
+ }
69
+
70
+ /* ── the compare view (I3) ── */
71
+ const C = { at: null, id: null, key: '', c: null, H: null };
72
+ async function read() {
73
+ const at = C.at || {};
74
+ 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
+ }
76
+ 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>`
78
+ + `<span class="lab-frame"><iframe src="${esc(col.url || specUrl(col.file))}" sandbox="allow-scripts" title="${esc(col.title)}"></iframe></span>`
79
+ + (col.read ? `<small class="lab-ok">${esc(col.read)}</small>` : '') + '</section>';
80
+ }
81
+ function bodyHtml(c) {
82
+ const shown = c.columns.filter((x) => !x.left), left = c.columns.filter((x) => x.left);
83
+ const pins = c.pins.length ? `<section class="lab-card"><b>Where they differ</b>${c.pins.map((p) => `<div class="lab-row"><span class="lab-pin ${esc(p.vs)}">${p.n}</span><span>${esc(p.text)}</span></div>`).join('')}</section>` : '';
84
+ const hist = `<section class="lab-card lab-hist" aria-label="History"><b>History</b><span class="lab-hn">Press a round to show it in the Prototype column</span>`
85
+ + c.history.map((h) => `<button type="button" class="lab-row lab-hr" data-lab-round="${esc(h.id)}" aria-current="${h.current}"><span class="lab-dot ${esc(h.state)}"></span><span class="w"><b>Round ${h.round}</b> · ${esc(when(h.at))}<small>${esc(h.state === 'kept' ? 'you kept it · ' : h.state === 'dropped' ? 'you dropped it · ' : '')}${esc(h.meta)}</small></span></button>`
86
+ + (h.keys && h.current ? `<span class="lab-keys">${h.keys.map((k) => `<button type="button" class="lab-key" data-lab-key="${esc(k.key)}" aria-pressed="${k.key === c.key}" aria-label="${esc('Show ' + k.key + ', ' + k.title)}">${esc(k.key)}</button>`).join('')}</span>` : '')).join('')
87
+ + '</section>';
88
+ return `<div class="lab-cmp">${c.say ? `<p class="lab-say"><span aria-hidden="true">✦</span> ${esc(c.say)}</p>` : ''}`
89
+ + `<div class="lab-cols" style="--n:${shown.length}">${shown.map(colHtml).join('')}</div>`
90
+ + (left.length ? `<ul class="lab-left">${left.map((x) => `<li><b>${esc(x.title)}</b> ${esc(x.left)}</li>`).join('')}</ul>` : '')
91
+ + `<div class="lab-below">${pins}${hist}</div></div>`;
92
+ }
93
+ function presses(c) {
94
+ return c && c.state === 'open' ? [{ act: 'drop', label: 'Drop this round', icon: I.x }, { act: 'keep', label: 'Keep this round', icon: I.check, blue: true }] : [];
95
+ }
96
+ function draw() {
97
+ const VW = window.czViewer, b = VW && VW.body(), cur = VW && VW.current();
98
+ if (!b || !cur || cur.id !== 'lab:cmp' || !C.c) return;
99
+ b.innerHTML = bodyHtml(C.c);
100
+ VW.setPresses(cur.id, presses(C.c));
101
+ if (VW.retitle) VW.retitle(cur.id, C.c.title);
102
+ }
103
+ async function load() {
104
+ const r = await read();
105
+ if (!r || r.ok === false) { const b = window.czViewer && window.czViewer.body(); if (b) b.innerHTML = `<p class="pp-none">${esc((r && r.error) || 'The prototype could not be read.')}</p>`; return; }
106
+ C.c = r.compare; C.key = r.compare.key;
107
+ // two or three columns side by side need the room: the Viewer opens wide (one column stays as it is)
108
+ if (C.c.columns.filter((x) => !x.left).length > 1 && window.czViewer.wide) window.czViewer.wide(true);
109
+ draw();
110
+ }
111
+ async function act(a) {
112
+ const c = C.c, at = C.at || {}; if (!c) return;
113
+ const say = (m, u) => { if (C.H && C.H.toast) C.H.toast(m, u); };
114
+ if (a === 'keep') {
115
+ const r = await pmPost('/api/proposals/keep', { ws: at.ws, board: at.board || c.board, initiative: c.ini, ids: [c.id] }).catch(() => null);
116
+ if (!r || r.ok === false) { say((r && r.error) || 'Nothing was kept.'); return; }
117
+ 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(); });
118
+ } else if (a === 'drop') {
119
+ const r = await pmPost('/api/proposals/drop', { ws: at.ws, board: at.board || c.board, initiative: c.ini, sig: c.sig }).catch(() => null);
120
+ if (!r || r.ok === false) { say((r && r.error) || 'Nothing was changed.'); return; }
121
+ say('Dropped round ' + c.round + '.');
122
+ }
123
+ await load(); if (C.H && C.H.reload) C.H.reload();
124
+ }
125
+ export function openCompare({ where, id, key = '', H = null } = {}) {
126
+ const VW = window.czViewer; if (!VW || !id) return;
127
+ Object.assign(C, { at: where || {}, id, key, c: null, H });
128
+ VW.drill();
129
+ VW.open({ id: 'lab:cmp', kind: 'Prototype', title: 'Prototype', icon: I.proto, presses: [], onPress: (a) => act(a),
130
+ render: (b) => {
131
+ b.innerHTML = '<p class="pp-none">Reading the prototype.</p>';
132
+ b.onclick = (e) => {
133
+ const r = e.target.closest('[data-lab-round]'); if (r) { C.id = r.dataset.labRound; C.key = ''; load(); return; }
134
+ const k = e.target.closest('[data-lab-key]'); if (k) { C.key = k.dataset.labKey; load(); }
135
+ };
136
+ load();
137
+ } });
138
+ }
@@ -21,7 +21,8 @@
21
21
  */
22
22
  import { esc, svg, ICON, wsQ } from './cozy-evui.js';
23
23
  import { fabLabel, bannerOf } from './cozy-evmodel.js';
24
- import { mountToastFaces, loadPrefs, adlerPeek, asleep } from './cozy-adler.js'; // Adler (batch 16 item 2): every toast carries his S face; Settings > Adler is read once
24
+ import { mountToastFaces, loadPrefs, adlerPeek, asleep } from './cozy-adler.js';
25
+ import { pmPost } from './http.js'; // Adler (batch 16 item 2): every toast carries his S face; Settings > Adler is read once
25
26
 
26
27
  export const PLACES = [
27
28
  { key: 'home', label: 'Home', href: '/premium.html', d: ICON.home },
@@ -31,7 +32,11 @@ export const PLACES = [
31
32
  export { fabLabel };
32
33
  const THEME_KEY = 'pmos.c3.theme';
33
34
  const CSS = new URL('./cozy-ev.css', import.meta.url).href;
34
- const N = { news: 0, stale: null, here: 'home', calls: 0 };
35
+ const N = { news: 0, stale: null, here: 'home', calls: 0, fresh: new Set() };
36
+ /* A place that just opened (onboarding B3, ObA4Gradual; GET /api/moments places[p].dot): its menu row gets one soft blue dot until the PM
37
+ * first opens it. Reports live in Intelligence, so their dot is on the Intelligence row. */
38
+ const ROW_OF = { board: 'board', insights: 'insights', reports: 'insights' };
39
+ export const freshRows = (places) => new Set(Object.entries(places || {}).filter(([, v]) => v && v.dot).map(([k]) => ROW_OF[k]).filter(Boolean));
35
40
 
36
41
  const store = { get(k) { try { return localStorage.getItem(k); } catch { return null; } }, set(k, v) { try { if (v) localStorage.setItem(k, v); else localStorage.removeItem(k); } catch { /* a private window */ } } };
37
42
  /** The theme the PM picked on this device: light, dark or auto. */
@@ -50,8 +55,9 @@ export function setTheme(pick, doc = document, { keep = true } = {}) {
50
55
  export function menuHtml(here, o = {}) {
51
56
  const news = o.news > 0, dot = (c) => `<i class="ev-md ${c}" aria-hidden="true"></i>`;
52
57
  return PLACES.map((p) => {
53
- const you = p.key === 'home' && news;
54
- const lab = you ? ` aria-label="${p.label}. ${o.news} new for you in Your day"` : '';
58
+ const opened = p.key !== here && !!(o.fresh && o.fresh.has(p.key));
59
+ const you = (p.key === 'home' && news) || opened;
60
+ const lab = p.key === 'home' && news ? ` aria-label="${p.label}. ${o.news} new for you in Your day"` : opened ? ` aria-label="${p.label}. New: it has something to show now"` : '';
55
61
  return `<a href="${p.href}"${p.key === here ? ' aria-current="page"' : ''}${lab}>${svg(p.d, 18)}${p.key === here ? `<b>${p.label}</b>` : `<span>${p.label}</span>`}${you ? dot('you') : ''}</a>`;
56
62
  }).join('')
57
63
  + '<div class="ev-tray">'
@@ -88,10 +94,11 @@ export function mountNav(here, doc = document, opts = {}) {
88
94
  mountToastFaces(doc); loadPrefs();
89
95
  const fab = w.querySelector('#czFab'), menu = w.querySelector('#czMenu'), scrim = w.querySelector('#czScrim');
90
96
  const draw = () => {
91
- menu.innerHTML = menuHtml(here, { news: N.news, stale: N.stale });
92
- w.querySelector('#czFdYou').hidden = !(N.news > 0) || !menu.hidden;
97
+ menu.innerHTML = menuHtml(here, { news: N.news, stale: N.stale, fresh: N.fresh });
98
+ const opened = [...N.fresh].some((k) => k !== here);
99
+ w.querySelector('#czFdYou').hidden = !(N.news > 0 || opened) || !menu.hidden;
93
100
  w.querySelector('#czFdRisk').hidden = !N.stale || !menu.hidden;
94
- if (menu.hidden) fab.setAttribute('aria-label', fabLabel(here, false, N.stale, N.news) + (earsOn() ? '. ' + callWords(N.calls) : ''));
101
+ if (menu.hidden) fab.setAttribute('aria-label', fabLabel(here, false, N.stale, N.news) + (opened ? '. A place has something new to show' : '') + (earsOn() ? '. ' + callWords(N.calls) : ''));
95
102
  drawEars();
96
103
  };
97
104
  // AdP6: the ears are drawn once and kept while the count stays above zero, so a redraw never replays them
@@ -132,7 +139,14 @@ export function mountNav(here, doc = document, opts = {}) {
132
139
  }, true);
133
140
  const read = async () => {
134
141
  if (doc.hidden) return;
135
- const [n, s] = await Promise.all([getj('/api/news-for-you' + wsQ()), getj('/api/sources' + wsQ())]);
142
+ const [n, s, mo] = await Promise.all([getj('/api/news-for-you' + wsQ()), getj('/api/sources' + wsQ()), getj('/api/moments')]);
143
+ if (mo && mo.ok) {
144
+ // the place the PM is on is visited: its dot clears (Intelligence also clears the reports dot, they live here)
145
+ const mine = Object.keys(ROW_OF).filter((k) => ROW_OF[k] === here && mo.places && mo.places[k] && mo.places[k].dot);
146
+ for (const k of mine) { mo.places[k].dot = false; pmPost('/api/moments/visit', { place: k }).catch(() => {}); }
147
+ N.fresh = freshRows(mo.places);
148
+ doc.dispatchEvent(new CustomEvent('cz:moments', { detail: mo }));
149
+ }
136
150
  if (n && n.ok) { N.news = n.count || 0; doc.dispatchEvent(new CustomEvent('cz:news-for-you', { detail: n })); }
137
151
  if (s && s.ok) { N.stale = bannerOf(s.sources); doc.dispatchEvent(new CustomEvent('cz:sources', { detail: s })); } // Your day's failed source (AdP5)
138
152
  if (menu.hidden || !menu.contains(doc.activeElement)) draw();
@@ -58,3 +58,34 @@ body.ob-on #hmChat[hidden] { display: none; }
58
58
  .cs-checklist[hidden] { display: none; }
59
59
  .cs-checklist p { margin: 0; font-size: var(--fs-meta); color: var(--cz-ink2); line-height: var(--lh-meta); }
60
60
  .cs-checklist .ut-btn { align-self: flex-start; text-decoration: none; }
61
+ /* onboarding build B1: the ✦ proposals (✓ ✕ only), the source tiles and the fundamentals card */
62
+ .ob-prop { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px 12px; max-width: 720px; box-sizing: border-box; }
63
+ .ob-pt { margin: 0; display: flex; gap: 8px; align-items: baseline; font-size: var(--fs-body); font-weight: var(--fw-strong); color: var(--cz-ink); line-height: var(--lh-body); }
64
+ .ob-spark { color: var(--cz-blueink); flex: none; }
65
+ .ob-pl { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; }
66
+ .ob-pl > li { padding: 8px 0; border-top: 1px solid var(--cz-hair); font-size: var(--fs-body); line-height: var(--lh-body); color: var(--cz-ink); overflow-wrap: anywhere; }
67
+ .ob-pl > li b { color: var(--cz-ink2); font-size: var(--fs-meta); line-height: var(--lh-meta); margin-right: 6px; }
68
+ .ob-pl a, .ob-fund a { color: var(--cz-blueink); }
69
+ .ob-yn { display: flex; gap: 8px; justify-content: flex-end; padding-top: 2px; }
70
+ .ob-yn .ob-no { background: var(--cz-well); color: var(--cz-ink2); }
71
+ .ob-yn .ut-ib { width: 44px; height: 44px; }
72
+ .ob-lk { font: inherit; font-size: var(--fs-meta); line-height: var(--lh-meta); border: 0; padding: 0; background: none; color: var(--cz-blueink); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
73
+ .ob-lk:disabled { color: var(--cz-ink3); cursor: default; }
74
+ .ob-fl { display: grid; grid-template-columns: 90px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
75
+ .ob-fl > span { min-width: 0; }
76
+ .ob-fl em { grid-column: 2; font-style: normal; font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); }
77
+ .ob-fl .ob-pen { grid-column: 3; grid-row: 1; }
78
+ .ob-miss { color: var(--cz-ink3); }
79
+ .ob-rv .ob-fld { grid-template-columns: 90px minmax(0, 1fr); border-top: 0; padding: 0; }
80
+ .ob-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; max-width: 720px; }
81
+ .ob-tile { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; min-width: 0; }
82
+ .ob-tile .ob-ts { font-size: var(--fs-label); font-weight: var(--fw-strong); color: var(--cz-blueink); line-height: var(--lh-label); }
83
+ .ob-tile b { font-size: var(--fs-body); line-height: var(--lh-body); color: var(--cz-ink); overflow-wrap: anywhere; }
84
+ .ob-tile b a { color: inherit; text-decoration: none; }
85
+ .ob-tile > span:last-child { font-size: var(--fs-meta); color: var(--cz-ink2); line-height: var(--lh-meta); }
86
+ .ob-fund li { align-items: flex-start; }
87
+ .ob-fund li svg { margin-top: 3px; }
88
+ .ob-fund li > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
89
+ .ob-fund li em { font-style: normal; font-size: var(--fs-meta); color: var(--cz-ink3); line-height: var(--lh-meta); overflow-wrap: anywhere; }
90
+ .ob-fund li .ob-lk { align-self: flex-start; }
91
+ @media (max-width: 760px) { .ob-fl { grid-template-columns: minmax(0, 1fr) auto; } .ob-fl em { grid-column: 1; } .ob-fl .ob-pen { grid-column: 2; } .ob-rv .ob-fld { grid-template-columns: minmax(0, 1fr); } }