create-pmos 0.591.0 → 0.593.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.
- package/package.json +27 -27
- package/payload/KIT-VERSION +2 -2
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/payload/state/log.md +1 -1
- package/workspace/changelog.json +26 -0
- package/workspace/guide/agent-capabilities.md +24 -12
- package/workspace/guide/cli.md +2 -2
- package/workspace/lib/autonomy.js +3 -0
- package/workspace/lib/idle-lab.js +17 -5
- package/workspace/lib/lab-cli.js +8 -6
- package/workspace/lib/live-round.js +351 -68
- package/workspace/lib/proposals.js +46 -2
- package/workspace/lib/proto-runtime.js +104 -0
- package/workspace/lib/routes-briefing-premium.js +33 -16
- package/workspace/lib/routes-lab.js +73 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-home.css +8 -0
- package/workspace/public/pm/cozy-lab.js +15 -7
- package/workspace/public/pm/cozy-proto.css +143 -0
- package/workspace/public/pm/cozy-proto.js +474 -0
- package/workspace/public/pm/home-app.js +2 -0
- package/workspace/public/pm/home-chat.js +39 -5
- package/workspace/server.js +2 -0
|
@@ -67,7 +67,8 @@
|
|
|
67
67
|
* tidyName(from, to) → '' when `to` keeps the standard (rule 5), else the reason it does not
|
|
68
68
|
* datesOf(ini, T, o) PURE → the date proposals for one initiative (rule 1: late, or due within 3 days and not started)
|
|
69
69
|
* viewOf(F, ini, o) → what r.props carries (null: nothing to show)
|
|
70
|
-
* foundOf(F, ini) → { docs, linked, ran } the kept found items, as the initiative's own
|
|
70
|
+
* foundOf(F, ini) → { docs, linked, ran } the kept found items, as the initiative's own (a live round's prototype: only the current one)
|
|
71
|
+
* currentOf(F, ini) PURE → the initiative's prototype now: the newest proven version, or the one the PM kept since | null
|
|
71
72
|
* historyOf(F, uid) → [entry] Claude's approved changes to one task, newest first, each with its reason and source
|
|
72
73
|
* decorate(rows, F, items, o) puts r.props and r.found on each Board row that has something
|
|
73
74
|
*/
|
|
@@ -301,17 +302,60 @@ function lessonsOn(lines, { match, on }) {
|
|
|
301
302
|
}
|
|
302
303
|
/** The kept proposal ids (a batch undone gives its proposals back). */
|
|
303
304
|
const keptIds = (F) => { const s = new Set(); for (const k of F.kept) if (!F.undone.has(k.batch)) for (const id of k.ids) s.add(id); return s; };
|
|
305
|
+
/** PURE. The initiative's prototype now (prototype by chatting, fix 2026-11-18): the newest proven one-version live round or version of it,
|
|
306
|
+
* or the version the PM kept from the tray since. A keep PMOS made by itself (agent:auto) never counts: a test round it kept became the
|
|
307
|
+
* initiative's design. A round started in a terminal (from cli, a test) counts only once the PM keeps it. A version the PM closed (✕) is
|
|
308
|
+
* not current; one that only expired still is.
|
|
309
|
+
* → { id, of, key, n, file, title, said, brief, at } | null (file: <round>/<key>/<key>.html under the specimens folder) */
|
|
310
|
+
function currentOf(F, ini) {
|
|
311
|
+
if (!F || !F.props) return null;
|
|
312
|
+
const exp = new Set((F.expired || []).map((x) => x.sig));
|
|
313
|
+
const closed = (p) => { const g = sigOf(p); return F.drops.has(g) && !exp.has(g); };
|
|
314
|
+
const live = (p) => !!p && p.ini === ini && isObj(p.data) && isObj(p.data.live);
|
|
315
|
+
const of = (p, file, at) => {
|
|
316
|
+
const d = p.data;
|
|
317
|
+
if (p.group === 'prototyped') {
|
|
318
|
+
const s = (Array.isArray(d.specimens) ? d.specimens : []).find((x) => isObj(x) && str(x.file) && (!file || x.file === file));
|
|
319
|
+
return s ? { id: p.id, of: p.id, key: str(s.key), n: 1, file: s.file, title: str(s.title), said: str(s.caption), brief: str(d.live.brief), at } : null;
|
|
320
|
+
}
|
|
321
|
+
if (p.group === 'improved' && str(d.file) && (!file || d.file === file)) return { id: p.id, of: str(d.of), key: str(d.base), n: Number(d.round) || 2, file: d.file, title: '', said: str(d.said), brief: str(d.changed), at };
|
|
322
|
+
return null;
|
|
323
|
+
};
|
|
324
|
+
const out = [];
|
|
325
|
+
for (const p of F.props.values()) {
|
|
326
|
+
if (!live(p) || closed(p)) continue;
|
|
327
|
+
// a round of several ways waits in the tray: only the PM's keep makes one of them the prototype
|
|
328
|
+
if (p.group === 'prototyped' && !((p.data.live.slots || []).length === 1)) continue;
|
|
329
|
+
// a round started in a terminal (`pmos lab round` without --chat: a test, a check) waits for the PM's keep too
|
|
330
|
+
if (p.data.live.from === 'cli') continue;
|
|
331
|
+
const c = of(p, '', p.at); if (c) out.push(c);
|
|
332
|
+
}
|
|
333
|
+
for (const k of F.kept || []) {
|
|
334
|
+
if (k.ini !== ini || (F.undone && F.undone.has(k.batch)) || k.by === 'agent:auto') continue;
|
|
335
|
+
for (const w of k.wrote) {
|
|
336
|
+
if (w.op !== 'doc' || w.kind !== 'prototype' || !/[?&]file=/.test(str(w.ref))) continue;
|
|
337
|
+
let file = ''; try { file = decodeURIComponent(str(w.ref).split(/[?&]file=/)[1].split('&')[0]); } catch { file = ''; }
|
|
338
|
+
for (const id of k.ids) { const p = F.props.get(String(id)); const c = live(p) ? of(p, file, k.at) : null; if (c) out.push(c); }
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
out.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
342
|
+
return out[0] || null;
|
|
343
|
+
}
|
|
304
344
|
/** What was kept that has no other store: the found documents, the Linked entries and the dates past stages ran. */
|
|
305
345
|
function foundOf(F, ini) {
|
|
306
346
|
const docs = [], linked = [], ran = {};
|
|
307
347
|
for (const k of F.kept) {
|
|
308
348
|
if (k.ini !== ini || F.undone.has(k.batch)) continue;
|
|
309
349
|
for (const w of k.wrote) {
|
|
350
|
+
if (w.op === 'doc' && w.source === 'PMOS, live round') continue; // a live round's prototype: only the current one, below
|
|
310
351
|
if (w.op === 'doc') docs.push({ id: w.id, title: w.title, source: w.source || '', at: w.at || '', ref: w.ref || '', kind: w.kind || 'doc', ...(w.claude ? { claude: true } : {}) });
|
|
311
352
|
else if (w.op === 'linked') linked.push({ id: w.id, label: w.title, ref: w.ref || '', title: w.why || '' });
|
|
312
353
|
else if (w.op === 'ran' && str(w.stage)) ran[w.stage] = { from: w.from || null, to: w.to || null, source: w.source || '' };
|
|
313
354
|
}
|
|
314
355
|
}
|
|
356
|
+
// the initiative's prototype is the version it is at now, never an older round someone kept (2026-11-18)
|
|
357
|
+
const cur = currentOf(F, ini);
|
|
358
|
+
if (cur) docs.push({ id: 'fd-proto-' + hash(ini), title: one(`Prototype · Version ${cur.n}${cur.said || cur.title ? ': ' + (cur.said || cur.title) : ''}`, 140), source: 'PMOS, live round', at: cur.at, ref: '/api/lab/specimen?file=' + encodeURIComponent(cur.file), kind: 'prototype', claude: true, version: cur.n });
|
|
315
359
|
docs.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
316
360
|
return docs.length || linked.length || Object.keys(ran).length ? { docs, linked, ran } : null;
|
|
317
361
|
}
|
|
@@ -504,5 +548,5 @@ function decorate(rows, F, items, o = {}) {
|
|
|
504
548
|
|
|
505
549
|
module.exports = {
|
|
506
550
|
LEDGER, GROUPS, TYPES, SOURCES, SOURCE_NAMES, RISK_DAYS, ledgerFile, read, readLines, append, fold, lessonsOf, clean, idOf, sigOf, itemSig, factsOf, tidyName, taskOf, lateOf,
|
|
507
|
-
datesOf, viewOf, foundOf, historyOf, decorate, keptIds, newBatch, dn, isoN, md, hash, workday, staleOf, expiredSince, EXPIRE_DAYS, EXPIRE_WHY,
|
|
551
|
+
datesOf, viewOf, foundOf, currentOf, historyOf, decorate, keptIds, newBatch, dn, isoN, md, hash, workday, staleOf, expiredSince, EXPIRE_DAYS, EXPIRE_WHY,
|
|
508
552
|
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* proto-runtime.js — the canvas runtime inside a prototype frame (initiative live-round-iterative, design Prototype by chatting, B3).
|
|
3
|
+
* GET /api/lab/specimen?rt=1 (lib/routes-lab.js) adds it to the prototype's HTML, inside the same sandbox CSP (no same origin, no network):
|
|
4
|
+
* the page still cannot reach PMOS. It talks to the canvas (pm/cozy-proto.js) only through postMessage, and only with its parent.
|
|
5
|
+
*
|
|
6
|
+
* What it does, from the data attributes the run writes (lib/live-round.js promptOf):
|
|
7
|
+
* data-screen one screen shows at a time; the first is the start data-go a tap moves to that screen
|
|
8
|
+
* data-el what the PM can point at, comment on or tap in Play data-label its name in plain words
|
|
9
|
+
* data-copy text the Page copy card edits in place :root vars what Tweaks change
|
|
10
|
+
* Parent → frame { pmos: 1, t }: mode (view | point | comment | play), screen, copy, copyAll, vars, hint, sel, pins.
|
|
11
|
+
* Frame → parent { pmos: 1, t }: ready (screens, els, copy), screen, point, pin, tap.
|
|
12
|
+
*
|
|
13
|
+
* withRuntime(html) → html with the runtime's <script> before </body> (or at the end) */
|
|
14
|
+
function runtime() {
|
|
15
|
+
/* eslint-disable no-var */
|
|
16
|
+
var mode = 'view', P = window.parent;
|
|
17
|
+
var css = document.createElement('style');
|
|
18
|
+
css.textContent = '[data-screen]:not(.pmos-on){display:none!important}'
|
|
19
|
+
+ '.pmos-hov{outline:2px solid #4a72d9!important;outline-offset:2px;cursor:pointer!important}'
|
|
20
|
+
+ '.pmos-sel{outline:2px solid #4a72d9!important;outline-offset:2px}'
|
|
21
|
+
+ '.pmos-hint{outline:3px dashed #d99a1e!important;outline-offset:3px}'
|
|
22
|
+
+ '.pmos-pin{position:absolute;z-index:2147483646;width:20px;height:20px;margin:-10px 0 0 -10px;border-radius:50%;background:#c0472e;color:#fff;font:600 11px/20px system-ui,sans-serif;text-align:center;pointer-events:none;box-shadow:0 1px 3px rgba(0,0,0,.25)}'
|
|
23
|
+
+ 'body.pmos-point *,body.pmos-comment *{cursor:crosshair!important}';
|
|
24
|
+
(document.head || document.documentElement).appendChild(css);
|
|
25
|
+
var post = function (m) { m.pmos = 1; try { P.postMessage(m, '*'); } catch (e) { /* the canvas is gone */ } };
|
|
26
|
+
var screens = function () { return Array.prototype.slice.call(document.querySelectorAll('[data-screen]')); };
|
|
27
|
+
var show = function (id) {
|
|
28
|
+
var all = screens(); if (!all.length) return;
|
|
29
|
+
var on = all.filter(function (s) { return s.getAttribute('data-screen') === id; })[0] || all[0];
|
|
30
|
+
all.forEach(function (s) { s.classList.toggle('pmos-on', s === on); });
|
|
31
|
+
window.scrollTo(0, 0);
|
|
32
|
+
post({ t: 'screen', id: on.getAttribute('data-screen') });
|
|
33
|
+
};
|
|
34
|
+
var elOf = function (n) { return n && n.closest ? n.closest('[data-el]') : null; };
|
|
35
|
+
var info = function (e) { return e ? { el: e.getAttribute('data-el') || '', label: e.getAttribute('data-label') || (e.textContent || '').trim().slice(0, 40) } : { el: '', label: '' }; };
|
|
36
|
+
var hov = null;
|
|
37
|
+
document.addEventListener('mouseover', function (ev) {
|
|
38
|
+
if (mode !== 'point' && mode !== 'comment') return;
|
|
39
|
+
var e = elOf(ev.target); if (hov && hov !== e) hov.classList.remove('pmos-hov');
|
|
40
|
+
hov = e; if (e) e.classList.add('pmos-hov');
|
|
41
|
+
}, true);
|
|
42
|
+
document.addEventListener('click', function (ev) {
|
|
43
|
+
var e = elOf(ev.target), go = ev.target.closest && ev.target.closest('[data-go],a[href^="#"]');
|
|
44
|
+
if (mode === 'point') { ev.preventDefault(); ev.stopPropagation(); if (!e) return; sel(e.getAttribute('data-el')); var i = info(e); i.t = 'point'; post(i); return; }
|
|
45
|
+
if (mode === 'comment') {
|
|
46
|
+
ev.preventDefault(); ev.stopPropagation();
|
|
47
|
+
var h = Math.max(1, document.documentElement.scrollHeight), w = Math.max(1, document.documentElement.clientWidth), c = info(e);
|
|
48
|
+
c.t = 'pin'; c.x = ev.pageX / w; c.y = ev.pageY / h; post(c); return;
|
|
49
|
+
}
|
|
50
|
+
if (mode === 'play') {
|
|
51
|
+
ev.preventDefault(); ev.stopPropagation();
|
|
52
|
+
post({ t: 'tap', el: e ? e.getAttribute('data-el') || '' : '', go: go ? (go.getAttribute('data-go') || (go.getAttribute('href') || '').slice(1)) : '' });
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (go) { ev.preventDefault(); show(go.getAttribute('data-go') || (go.getAttribute('href') || '').slice(1)); }
|
|
56
|
+
}, true);
|
|
57
|
+
var sel = function (id) {
|
|
58
|
+
Array.prototype.forEach.call(document.querySelectorAll('.pmos-sel'), function (x) { x.classList.remove('pmos-sel'); });
|
|
59
|
+
if (!id) return;
|
|
60
|
+
var e = document.querySelector('[data-el="' + String(id).replace(/[^A-Za-z0-9_-]/g, '') + '"]'); if (e) e.classList.add('pmos-sel');
|
|
61
|
+
};
|
|
62
|
+
var pins = function (list) {
|
|
63
|
+
Array.prototype.forEach.call(document.querySelectorAll('.pmos-pin'), function (x) { x.remove(); });
|
|
64
|
+
var h = document.documentElement.scrollHeight, w = document.documentElement.clientWidth;
|
|
65
|
+
(list || []).forEach(function (p) {
|
|
66
|
+
var d = document.createElement('span'); d.className = 'pmos-pin'; d.textContent = String(p.n);
|
|
67
|
+
var e = p.el ? document.querySelector('[data-el="' + String(p.el).replace(/[^A-Za-z0-9_-]/g, '') + '"]') : null;
|
|
68
|
+
if (e && e.offsetParent === null) return; // on another screen
|
|
69
|
+
if (e) { var r = e.getBoundingClientRect(); d.style.left = (r.right + window.scrollX - 4) + 'px'; d.style.top = (r.top + window.scrollY + 4) + 'px'; }
|
|
70
|
+
else if (p.x != null && p.y != null) { d.style.left = (p.x * w) + 'px'; d.style.top = (p.y * h) + 'px'; } else return;
|
|
71
|
+
document.body.appendChild(d);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
window.addEventListener('message', function (ev) {
|
|
75
|
+
if (ev.source !== P) return;
|
|
76
|
+
var m = ev.data || {}; if (!m || m.pmos !== 1) return;
|
|
77
|
+
if (m.t === 'mode') { mode = m.mode; document.body.classList.toggle('pmos-point', mode === 'point'); document.body.classList.toggle('pmos-comment', mode === 'comment'); if (hov) { hov.classList.remove('pmos-hov'); hov = null; } }
|
|
78
|
+
else if (m.t === 'screen') show(m.id);
|
|
79
|
+
else if (m.t === 'copy' || m.t === 'copyAll') {
|
|
80
|
+
var all = m.t === 'copy' ? (function () { var o = {}; o[m.key] = m.text; return o; })() : (m.copy || {});
|
|
81
|
+
Object.keys(all).forEach(function (k) { Array.prototype.forEach.call(document.querySelectorAll('[data-copy="' + k.replace(/[^A-Za-z0-9_.-]/g, '') + '"]'), function (x) { x.textContent = String(all[k]); }); });
|
|
82
|
+
} else if (m.t === 'vars') Object.keys(m.vars || {}).forEach(function (k) { if (/^--[A-Za-z0-9-]+$/.test(k)) document.documentElement.style.setProperty(k, String(m.vars[k])); });
|
|
83
|
+
else if (m.t === 'hint') {
|
|
84
|
+
Array.prototype.forEach.call(document.querySelectorAll('.pmos-hint'), function (x) { x.classList.remove('pmos-hint'); });
|
|
85
|
+
(m.els || []).forEach(function (id) { var e = document.querySelector('[data-el="' + String(id).replace(/[^A-Za-z0-9_-]/g, '') + '"]'); if (e) e.classList.add('pmos-hint'); });
|
|
86
|
+
setTimeout(function () { Array.prototype.forEach.call(document.querySelectorAll('.pmos-hint'), function (x) { x.classList.remove('pmos-hint'); }); }, 1600);
|
|
87
|
+
} else if (m.t === 'sel') sel(m.el);
|
|
88
|
+
else if (m.t === 'pins') pins(m.pins);
|
|
89
|
+
});
|
|
90
|
+
var start = function () {
|
|
91
|
+
var all = screens(); if (all.length) all[0].classList.add('pmos-on');
|
|
92
|
+
var copy = {}; Array.prototype.forEach.call(document.querySelectorAll('[data-copy]'), function (x) { var k = x.getAttribute('data-copy'); if (!(k in copy)) copy[k] = (x.textContent || '').trim(); });
|
|
93
|
+
post({ t: 'ready', screens: all.map(function (s) { return { id: s.getAttribute('data-screen'), label: s.getAttribute('data-label') || '' }; }),
|
|
94
|
+
els: Array.prototype.map.call(document.querySelectorAll('[data-el]'), function (e) { return info(e); }), copy: copy });
|
|
95
|
+
};
|
|
96
|
+
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', start); else start();
|
|
97
|
+
}
|
|
98
|
+
const SCRIPT = '<script>(' + runtime.toString() + ')();</script>';
|
|
99
|
+
/** The prototype's HTML with the runtime added before </body> (or at the end). */
|
|
100
|
+
function withRuntime(html) {
|
|
101
|
+
const s = String(html || ''), i = s.toLowerCase().lastIndexOf('</body>');
|
|
102
|
+
return i >= 0 ? s.slice(0, i) + SCRIPT + s.slice(i) : s + SCRIPT;
|
|
103
|
+
}
|
|
104
|
+
module.exports = { withRuntime, SCRIPT };
|
|
@@ -69,28 +69,44 @@ function grillAsk(ctx, key, text, wsId) {
|
|
|
69
69
|
: '[PMOS] The grill run did not start: ' + ((r && r.error) || 'no answer') + '. Say so in one line, and what would let it run.';
|
|
70
70
|
return { text: note + '\n\nThe PM says: ' + q, started: !!(r && r.ok) };
|
|
71
71
|
}
|
|
72
|
-
/** The live round (lib/live-round.js,
|
|
73
|
-
* ("B, but lead with the risk") in an initiative's chat.
|
|
74
|
-
*
|
|
75
|
-
* `pmos lab round --
|
|
76
|
-
function liveAsk(ctx, key, text, wsId) {
|
|
72
|
+
/** The live round (lib/live-round.js, initiatives live-round and live-round-iterative): "prototype this", "show 3 ways", or a change sentence
|
|
73
|
+
* on the version open ("make the alert orange", "B, but lead with the risk") in an initiative's chat. One version starts at once, no ✦ ask;
|
|
74
|
+
* a change sentence starts its next round at once; "N ways" goes to the chat's Claude with one rule: choose N directions and start them with
|
|
75
|
+
* `pmos lab round --dirs`, and build nothing in the chat. → { text, filed, live?: { id, ws, board } } | null */
|
|
76
|
+
function liveAsk(ctx, key, text, wsId, refs = []) {
|
|
77
77
|
const k = String(key || ''), q = String(text == null ? '' : text);
|
|
78
78
|
if (!/^init:/.test(k)) return null;
|
|
79
79
|
const ini = k.replace(/^init:/, '').replace(/:\d+$/, '');
|
|
80
80
|
const LR = require('./live-round.js'), PR = require('./proposals.js');
|
|
81
81
|
let w = null; try { w = ctx.getWs ? ctx.getWs(wsId || null) : null; } catch { w = null; }
|
|
82
82
|
const dir = w && ctx.stateDirFor ? ctx.stateDirFor(w) : null;
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
const P = dir ? PR.read(dir) : null;
|
|
84
|
+
// the version the initiative is at now (lib/proposals.js currentOf): a change sentence means it even when no round waits (2026-11-18)
|
|
85
|
+
const cur = P ? PR.currentOf(P, ini) : null, open = P ? LR.waiting(P, ini) : null;
|
|
86
|
+
const it = LR.intentOf(q, { waiting: open || (cur ? { keys: [cur.key] } : null) });
|
|
87
|
+
// every other message on an initiative with a prototype carries where it is and how to change it, so the chat never hunts for files
|
|
88
|
+
const ctxLine = cur && w ? LR.contextOf(cur, { ini, ws: w.id, rt: ctx.runtimeDir || null }) : '';
|
|
89
|
+
if (!it || !w) return ctxLine ? { text: ctxLine + '\n\nThe PM says: ' + q, filed: false } : null;
|
|
90
|
+
// Wawan 2026-11-17 20:25, "iterative, like Claude Code design work": the round starts at once, no ✦ ask and no ✓. One version unless the
|
|
91
|
+
// PM asked for several; a change sentence while one is open is its next round. The Viewer shows it; the chat says what changed.
|
|
92
|
+
const live = (r) => (r && r.ok && r.round ? { id: r.round.proposal, ws: w.id, board: '' } : null);
|
|
93
|
+
const next = `From now on, when the PM asks to change the prototype, run \`pmos lab round ${ini} --ws ${w.id} --base <its letter> --chat --brief "<the PM's words>"\` and say in one line what will change; a question about it you answer yourself. Never write the prototype or an HTML file yourself.`;
|
|
85
94
|
if (it.kind === 'feedback') {
|
|
86
|
-
const r = LR.
|
|
87
|
-
const note = r.ok ? `[PMOS]
|
|
88
|
-
: '[PMOS] The
|
|
89
|
-
return { text: note + '\n\nThe PM says: ' + q, filed: !!r.ok };
|
|
95
|
+
const r = LR.startNow({ ws: w.id, ini, brief: q, base: it.base, from: 'chat', refs });
|
|
96
|
+
const note = r.ok ? `[PMOS] PMOS is making the next version of ${it.base} (version ${r.round.n}) now, about a minute${it.point ? ', about the element the PM pointed at (' + (it.point.label || it.point.el) + ')' : ''}; it replaces the one in the Viewer when it renders, and you will be told what changed. Say in one line what will change. Do not build it here.`
|
|
97
|
+
: '[PMOS] The new version did not start: ' + r.error + '. Say so in one line.';
|
|
98
|
+
return { text: note + '\n\nThe PM says: ' + q, filed: !!r.ok, live: live(r) };
|
|
90
99
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
if (it.count === 1) {
|
|
101
|
+
const r = LR.startNow({ ws: w.id, ini, brief: q, from: 'chat', count: 1, refs });
|
|
102
|
+
const note = r.ok ? '[PMOS] PMOS is making one prototype of this now (about a minute). It opens in the Viewer beside this chat as soon as it renders, and you will be told what was made. Say so in one line. Do not write HTML or build anything in this chat. ' + next
|
|
103
|
+
: '[PMOS] The prototype did not start: ' + r.error + '. Say so in one line, and what would let it run.';
|
|
104
|
+
return { text: note + '\n\nThe PM says: ' + q, filed: !!r.ok, live: live(r) };
|
|
105
|
+
}
|
|
106
|
+
const n = it.count === 2 ? 'two' : 'three', dirs = it.count === 2 ? 'A: <direction>|B: <direction>' : 'A: <direction>|B: <direction>|C: <direction>';
|
|
107
|
+
const note = `[PMOS] The PM asked to see ${n} ways. Do not write HTML or build anything in this chat. Choose ${n} clearly different directions, one short line each, then start them with exactly this one command: `
|
|
108
|
+
+ `\`pmos lab round ${ini} --ws ${w.id} --chat --brief "<the PM's sentence>" --dirs "${dirs}"\`. `
|
|
109
|
+
+ `Then say in one line that the ${n} ways show side by side in the Viewer as each one renders, and that the PM picks one by naming it or pressing it. ` + next;
|
|
94
110
|
return { text: note + '\n\nThe PM says: ' + q, filed: false };
|
|
95
111
|
}
|
|
96
112
|
function iniInfoOf(ctx, key, wsId) {
|
|
@@ -166,9 +182,10 @@ async function post(req, res, url, ctx) {
|
|
|
166
182
|
if (!att.ok) { ctx.json(res, { ok: false, error: att.error }, att.status); return true; }
|
|
167
183
|
// batch 20 item 13: the PM can start a grill any time by asking for it in an initiative's chat; it also runs by itself
|
|
168
184
|
// the live round: "show 3 ways" or feedback on a round that waits (lib/live-round.js); a grill ask comes first
|
|
169
|
-
const g2 = grillAsk(ctx, b.key, b.text, wsId) || liveAsk(ctx, b.key, b.text, wsId);
|
|
185
|
+
const g2 = grillAsk(ctx, b.key, b.text, wsId) || liveAsk(ctx, b.key, b.text, wsId, att.paths);
|
|
170
186
|
const a = (ctx.chatSessions ? Ag.chat : Ag.ask)({ runtimeDir, key: b.key, text: Files.withFiles(g2 ? g2.text : b.text, att.paths), context: b.context, sessions: ctx.chatSessions, reportInfo: () => reportInfoOf(ctx, wsId, b.report), model: /^work:/.test(String(b.key || '')) ? WP.peekModel() : /^board:/.test(String(b.key || '')) ? BoardP.peekModel() : /^ins:/.test(String(b.key || '')) ? InsP.peekModel() : /^(init|doc):/.test(String(b.key || '')) ? InitP.peekModel() : sk || (/^src:/.test(String(b.key || '')) && !(b.key === 'src:this-page' && url.searchParams.get('ws'))) ? Prod.peekModel() : BP.peekModel(root), spawnSession: ctx.spawnSession, wsId, iniInfo: () => iniInfoOf(ctx, b.key, wsId) });
|
|
171
|
-
|
|
187
|
+
// a prototype round the sentence started: the page opens it in the Viewer (pm/home-app.js iniTarget onSent)
|
|
188
|
+
ctx.json(res, g2 && g2.live && a.body && a.body.ok ? { ...a.body, live: g2.live } : a.body, a.status);
|
|
172
189
|
return true;
|
|
173
190
|
}
|
|
174
191
|
let r;
|
|
@@ -14,6 +14,13 @@
|
|
|
14
14
|
* POST /api/lab/undo { ws, batch } → { ok } Undo of a keep or a drop (a started initiative stays: close it on the Board)
|
|
15
15
|
* POST /api/lab/round { ws?, board?, ini, brief, base?, dirs?, propose? } → the live round (lib/live-round.js): `pmos lab round` starts one,
|
|
16
16
|
* or with propose: true files its ✦ ask. No page press needed (D98); it writes no record.
|
|
17
|
+
* Prototype by chatting (initiative live-round-iterative): the compare view of a live round carries its version's companions as data
|
|
18
|
+
* (data: { flow, lanes, copy, tweaks, edits }, lib/live-round.js partsAt) and the initiative's comments; GET /api/lab/specimen with rt=1
|
|
19
|
+
* adds the canvas runtime (lib/proto-runtime.js) inside the same sandbox, so the canvas can point, pin, play and edit through postMessage.
|
|
20
|
+
* POST /api/lab/edit { ws, file, copy?: { key: text }, vars?: { --var: value } } → { ok } the PM's in-place copy edits and tweaks,
|
|
21
|
+
* kept with the version (edits.json next to it); the next version reads them
|
|
22
|
+
* POST /api/lab/comment { ws, ini, file, el?, label?, text, x?, y?, send? } → { ok, id } a comment pinned to an element (send: it was
|
|
23
|
+
* sent to PMOS as the next change; else it is kept for the team)
|
|
17
24
|
*
|
|
18
25
|
* The week's record lists every background job: the idle lab, the grill runs (lib/grill.js), the AI jobs through lib/ai-guard.js, and
|
|
19
26
|
* whatever the shared queue reports (ctx.bgQueue.record({ ws, since }) → [{ job, title, meta?, at, ini?, board? }], when it is there).
|
|
@@ -114,6 +121,12 @@ const READS = {
|
|
|
114
121
|
const c = LAB.compareOf(PR.read(dir), id, { key: url.searchParams.get('key') || '', titleOf: (ini) => (T.get(ini) || {}).title || '' });
|
|
115
122
|
if (!c) return fail(ctx, res, 404, 'That prototype is no longer here');
|
|
116
123
|
for (const col of c.columns) if (col.file) col.url = LAB.specimenUrl(col.file);
|
|
124
|
+
if (c.live) {
|
|
125
|
+
// the version's companions as data, and the comments on the initiative (Prototype by chatting)
|
|
126
|
+
const abs = c.file ? LAB.specimenPath(ctx.runtimeDir, c.file) : null;
|
|
127
|
+
if (abs) { c.url = LAB.specimenUrl(c.file); c.data = require('./live-round.js').partsAt(abs); }
|
|
128
|
+
c.comments = commentsOf(dir, c.ini);
|
|
129
|
+
}
|
|
117
130
|
ctx.json(res, { ok: true, compare: c });
|
|
118
131
|
return true;
|
|
119
132
|
},
|
|
@@ -141,6 +154,8 @@ const READS = {
|
|
|
141
154
|
let html = null;
|
|
142
155
|
try { html = f ? fs.readFileSync(f) : null; } catch { html = null; }
|
|
143
156
|
if (!html) return fail(ctx, res, 404, 'That specimen is not in the idle lab folder');
|
|
157
|
+
// the canvas runtime (lib/proto-runtime.js): only on rt=1, inside the same sandbox CSP, so the page still cannot reach PMOS
|
|
158
|
+
if (url.searchParams.get('rt') === '1') html = require('./proto-runtime.js').withRuntime(html.toString('utf8'));
|
|
144
159
|
res.writeHead(200, { 'Content-Type': 'text/html; charset=utf-8', 'Content-Security-Policy': CSP, 'X-Content-Type-Options': 'nosniff', 'Cache-Control': 'private, no-cache', 'Referrer-Policy': 'no-referrer' });
|
|
145
160
|
res.end(html);
|
|
146
161
|
return true;
|
|
@@ -181,14 +196,71 @@ const WRITES = {
|
|
|
181
196
|
ctx.json(res, { ok: true });
|
|
182
197
|
return true;
|
|
183
198
|
},
|
|
199
|
+
'/api/lab/edit': (ctx, res, body, g, w, dir) => {
|
|
200
|
+
const abs = liveFile(ctx, body.file); if (!abs) return fail(ctx, res, 404, 'That version is not in the live round folder');
|
|
201
|
+
const LR = require('./live-round.js'), f = require('path').join(require('path').dirname(abs), 'edits.json');
|
|
202
|
+
let was = {}; try { was = JSON.parse(fs.readFileSync(f, 'utf8')); } catch { was = {}; }
|
|
203
|
+
const add = LR.editsOf({ copy: body.copy, vars: body.vars }), old = LR.editsOf(was);
|
|
204
|
+
const next = { copy: { ...old.copy, ...add.copy }, vars: { ...old.vars, ...add.vars } };
|
|
205
|
+
try { fs.writeFileSync(f, JSON.stringify(next, null, 1)); } catch { return fail(ctx, res, 500, 'The edit was not saved'); }
|
|
206
|
+
// the edits are part of the version the initiative is at (2026-11-18: they lived only in edits.json): its kept line says so, once per
|
|
207
|
+
// new line edited (not on every key press)
|
|
208
|
+
const n0 = Object.keys(old.copy).length + Object.keys(old.vars).length, n1 = Object.keys(next.copy).length + Object.keys(next.vars).length;
|
|
209
|
+
if (n1 > n0) try { keptEdited(dir, String(body.file), next, g); } catch { /* edits.json holds them */ }
|
|
210
|
+
ctx.json(res, { ok: true, edits: next });
|
|
211
|
+
return true;
|
|
212
|
+
},
|
|
213
|
+
'/api/lab/comment': (ctx, res, body, g, w, dir) => {
|
|
214
|
+
const ini = String(body.ini || ''), text = typeof body.text === 'string' ? body.text.replace(/\s+/g, ' ').trim().slice(0, 500) : '';
|
|
215
|
+
if (!ID_RE.test(ini) || !text) return fail(ctx, res, 400, 'ini and text name the initiative and the comment');
|
|
216
|
+
if (!liveFile(ctx, body.file)) return fail(ctx, res, 404, 'That version is not in the live round folder');
|
|
217
|
+
const id = 'cm' + Date.now().toString(36) + require('crypto').randomBytes(2).toString('hex');
|
|
218
|
+
const num = (v) => (Number.isFinite(Number(v)) ? Math.max(0, Math.min(1, Number(v))) : null);
|
|
219
|
+
const line = { at: new Date().toISOString(), by: (g.actor && g.actor.by) || null, id, ini, file: String(body.file), el: /^[A-Za-z0-9][A-Za-z0-9_-]{0,59}$/.test(String(body.el || '')) ? body.el : '',
|
|
220
|
+
label: String(body.label || '').replace(/\s+/g, ' ').trim().slice(0, 80), text, x: num(body.x), y: num(body.y), send: body.send === true };
|
|
221
|
+
try { fs.appendFileSync(require('path').join(dir, COMMENTS), JSON.stringify(line) + '\n'); } catch { return fail(ctx, res, 500, 'The comment was not saved'); }
|
|
222
|
+
ctx.json(res, { ok: true, id });
|
|
223
|
+
return true;
|
|
224
|
+
},
|
|
184
225
|
};
|
|
226
|
+
const COMMENTS = 'lab-comments.jsonl';
|
|
227
|
+
/** The experiment's kept specimen, when `file` is the initiative's current version: "Version n, with your edits in the Viewer (…)". */
|
|
228
|
+
function keptEdited(dir, file, ed, g) {
|
|
229
|
+
const F = PR.read(dir);
|
|
230
|
+
let ini = '';
|
|
231
|
+
for (const p of F.props.values()) {
|
|
232
|
+
const d = p.data || {};
|
|
233
|
+
if (!isObj(d.live)) continue;
|
|
234
|
+
if ((p.group === 'improved' && d.file === file) || (p.group === 'prototyped' && (d.specimens || []).some((x) => x && x.file === file))) { ini = p.ini; break; }
|
|
235
|
+
}
|
|
236
|
+
const cur = ini ? PR.currentOf(F, ini) : null;
|
|
237
|
+
if (!cur || cur.file !== file) return;
|
|
238
|
+
const nc = Object.keys(ed.copy).length, nv = Object.keys(ed.vars).length;
|
|
239
|
+
const what = [nc ? nc + (nc === 1 ? ' line of copy' : ' lines of copy') : '', nv ? nv + (nv === 1 ? ' tweak' : ' tweaks') : ''].filter(Boolean).join(' and ');
|
|
240
|
+
const AF = require('./artefacts.js'), by = (g.actor && /^(pm|agent):/.test(String(g.actor.by || ''))) ? g.actor : { by: 'agent:live-round' };
|
|
241
|
+
AF.set(AF.file(dir), { scope: 'experiment:' + ini, artefact: 'specimens', field: 'kept', text: `Version ${cur.n}, with your edits in the Viewer (${what}): ${cur.said || cur.title || ''} (${LAB.specimenUrl(file)})`.slice(0, 600), sources: [{ label: 'live round', ref: LAB.specimenUrl(file) }] }, by);
|
|
242
|
+
}
|
|
243
|
+
/** A live round's version file, by its specimen path (<round>/<key>/<key>.html): the absolute path, or null. */
|
|
244
|
+
function liveFile(ctx, file) {
|
|
245
|
+
const f = String(file || '');
|
|
246
|
+
if (!/^lr[0-9a-z]+\/[A-C]\/[a-c]\.html$/.test(f)) return null;
|
|
247
|
+
const abs = LAB.specimenPath(ctx.runtimeDir, f);
|
|
248
|
+
try { return abs && fs.statSync(abs).isFile() ? abs : null; } catch { return null; }
|
|
249
|
+
}
|
|
250
|
+
/** The comments on an initiative's prototype, oldest first, the last 60. */
|
|
251
|
+
function commentsOf(dir, ini) {
|
|
252
|
+
let lines = []; try { lines = fs.readFileSync(require('path').join(dir, COMMENTS), 'utf8').split('\n'); } catch { return []; }
|
|
253
|
+
const out = [];
|
|
254
|
+
for (const l of lines) { if (!l) continue; try { const c = JSON.parse(l); if (c && c.ini === ini) out.push({ id: c.id, at: c.at, by: c.by, file: c.file, el: c.el, label: c.label, text: c.text, x: c.x, y: c.y, send: !!c.send }); } catch { /* a torn line */ } }
|
|
255
|
+
return out.slice(-60);
|
|
256
|
+
}
|
|
185
257
|
/** POST /api/lab/round { ws?, board?, ini, brief, base?, dirs?, propose?, from?, by? } → { ok, round, runs } | { ok, id, said } (propose) */
|
|
186
258
|
function liveRound(ctx, res, b) {
|
|
187
259
|
const LR = require('./live-round.js');
|
|
188
260
|
const w = wsOf(ctx, typeof b.ws === 'string' && b.ws ? b.ws : null); if (!w) return fail(ctx, res, 404, 'no such workspace');
|
|
189
261
|
const by = /^(pm|agent):[\w.:-]{1,80}$/.test(String(b.by || '')) ? b.by : 'agent:cli';
|
|
190
262
|
const input = { ws: w.id, board: typeof b.board === 'string' ? b.board : '', ini: String(b.ini || ''), brief: String(b.brief || ''), base: /^[A-C]$/i.test(String(b.base || '')) ? String(b.base).toUpperCase() : '',
|
|
191
|
-
dirs: typeof b.dirs === 'string' ? b.dirs : '', from: b.from === 'meeting' ? 'meeting' : b.propose ? 'chat' : 'cli', by };
|
|
263
|
+
dirs: typeof b.dirs === 'string' ? b.dirs : '', from: b.from === 'meeting' ? 'meeting' : b.from === 'chat' || b.propose ? 'chat' : 'cli', by, ...(b.one === true ? { count: 1 } : {}) };
|
|
192
264
|
const r = b.propose === true ? LR.proposeNow(input) : LR.startNow(input);
|
|
193
265
|
if (!r.ok) return fail(ctx, res, 409, r.error);
|
|
194
266
|
ctx.json(res, r);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.593.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.593.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -346,6 +346,14 @@ form.hm-box textarea { min-height: 48px; border: 0; background: none; resize: no
|
|
|
346
346
|
.hm-ath { width: 22px; height: 22px; border-radius: 6px; object-fit: cover; margin-left: -6px; }
|
|
347
347
|
.hm-att button { border: 0; background: none; cursor: pointer; width: 28px; height: 28px; border-radius: 999px; color: var(--cz-ink3); }
|
|
348
348
|
@media (pointer: coarse), (max-width: 760px) { .hm-att button { width: 44px; height: 44px; margin: -8px -6px -8px -10px; } .hm-tb .hm-tool { width: 44px; height: 44px; } }
|
|
349
|
+
/* Prototype by chatting (pm/cozy-proto.js): the element pointed at and "From version n" in the box and in a bubble; a reply's Version n tag */
|
|
350
|
+
.hm-markc { color: var(--cz-blueink); background: var(--cz-bluebg); }
|
|
351
|
+
.hm-markc svg { flex: none; }
|
|
352
|
+
.hm-marks { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
|
|
353
|
+
.hm-mark { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; background: var(--cz-card); color: var(--cz-blueink); font-size: var(--fs-meta); font-weight: var(--fw-strong); line-height: var(--lh-meta); }
|
|
354
|
+
.hm-ver { display: inline-flex; align-items: center; height: 24px; margin: 0 0 4px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); font: inherit; font-size: var(--fs-meta); font-weight: var(--fw-strong); cursor: pointer; }
|
|
355
|
+
.hm-ver:hover { border-color: var(--cz-blue); color: var(--cz-blueink); }
|
|
356
|
+
.hm-ver:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
|
|
349
357
|
.hm-chat.hm-drop { outline: 2px dashed var(--cz-blue); outline-offset: -8px; }
|
|
350
358
|
.hm-scope { display: flex; align-items: center; gap: 8px; }
|
|
351
359
|
.hm-scope .sp { flex: 1; }
|
|
@@ -10,15 +10,18 @@
|
|
|
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
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
|
|
13
|
+
* says the directions, ✓ starts it. Its compare view is the one canvas of Prototype by chatting (pm/cozy-proto.js): the prototype, its
|
|
14
|
+
* flow, its copy and who does what, with A B C in a tray when the PM asked for several; ✓ keeps the one shown.
|
|
14
15
|
* Every specimen loads from GET /api/lab/specimen in a sandboxed frame: it cannot reach PMOS. Nothing is written before the PM's ✓. */
|
|
15
16
|
import { pmGet, pmPost } from './http.js';
|
|
17
|
+
import * as PC from './cozy-proto.js'; // a live round's compare view is the one canvas (Prototype by chatting)
|
|
16
18
|
|
|
17
19
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
18
20
|
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
21
|
export const I = {
|
|
20
22
|
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',
|
|
21
23
|
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',
|
|
24
|
+
prev: 'M15 6l-6 6 6 6', next: 'M9 6l6 6-6 6',
|
|
22
25
|
};
|
|
23
26
|
const GROUPS = ['prototyped', 'improved', 'scanned', 'live'];
|
|
24
27
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
@@ -102,7 +105,7 @@ export function cardHtml(p, { why = false } = {}) {
|
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
/* ── the compare view (I3) ── */
|
|
105
|
-
const C = { at: null, id: null, key: '', c: null, H: null, timer: null };
|
|
108
|
+
const C = { at: null, id: null, key: '', c: null, H: null, timer: null, wided: false };
|
|
106
109
|
async function read() {
|
|
107
110
|
const at = C.at || {};
|
|
108
111
|
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);
|
|
@@ -135,7 +138,9 @@ export const presentUrl = (at, c) => '/pm/present?ws=' + encodeURIComponent((at
|
|
|
135
138
|
function draw() {
|
|
136
139
|
const VW = window.czViewer, b = VW && VW.body(), cur = VW && VW.current();
|
|
137
140
|
if (!b || !cur || cur.id !== 'lab:cmp' || !C.c) return;
|
|
138
|
-
|
|
141
|
+
// a live round: the one canvas (pm/cozy-proto.js) draws and keeps its frame while the view reads again
|
|
142
|
+
if (C.c.live) PC.draw(b, C.c, { at: C.at, H: { ...(C.H || {}), load } });
|
|
143
|
+
else b.innerHTML = bodyHtml(C.c);
|
|
139
144
|
VW.setPresses(cur.id, presses(C.c));
|
|
140
145
|
if (VW.retitle) VW.retitle(cur.id, C.c.title);
|
|
141
146
|
}
|
|
@@ -143,8 +148,8 @@ async function load() {
|
|
|
143
148
|
const r = await read();
|
|
144
149
|
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; }
|
|
145
150
|
C.c = r.compare; C.key = r.compare.key;
|
|
146
|
-
// two or three columns side by side need the room: the Viewer opens wide (one column stays as it is)
|
|
147
|
-
if (C.c.columns.filter((x) => !x.left).length > 1 && window.czViewer.wide) window.czViewer.wide(true);
|
|
151
|
+
// the canvas, or two or three columns side by side, need the room: the Viewer opens wide (one idle-lab column stays as it is)
|
|
152
|
+
if ((C.c.live || C.c.columns.filter((x) => !x.left).length > 1) && window.czViewer.wide && !C.wided) { C.wided = true; window.czViewer.wide(true); }
|
|
148
153
|
draw();
|
|
149
154
|
// a live round: its versions land one by one, so the view reads again while one is made
|
|
150
155
|
clearTimeout(C.timer);
|
|
@@ -168,13 +173,16 @@ async function act(a) {
|
|
|
168
173
|
}
|
|
169
174
|
export function openCompare({ where, id, key = '', H = null } = {}) {
|
|
170
175
|
const VW = window.czViewer; if (!VW || !id) return;
|
|
171
|
-
|
|
176
|
+
// already open (the chat started the next version, or a Version n tag): the canvas switches in place and keeps its frame
|
|
177
|
+
const cur = VW.current();
|
|
178
|
+
if (cur && cur.id === 'lab:cmp' && C.c) { Object.assign(C, { at: where || C.at, id, key, H: H || C.H }); load(); return; }
|
|
179
|
+
Object.assign(C, { at: where || {}, id, key, c: null, H, wided: false });
|
|
172
180
|
VW.drill();
|
|
173
181
|
VW.open({ id: 'lab:cmp', kind: 'Prototype', title: 'Prototype', icon: I.proto, presses: [], onPress: (a) => act(a),
|
|
174
182
|
render: (b) => {
|
|
175
183
|
b.innerHTML = '<p class="pp-none">Reading the prototype.</p>';
|
|
176
184
|
b.onclick = (e) => {
|
|
177
|
-
const r = e.target.closest('[data-lab-round]'); if (r) { C.id = r.dataset.labRound; C.key = ''; load(); return; }
|
|
185
|
+
const r = e.target.closest('[data-lab-round]'); if (r) { if (!r.dataset.labRound) return; C.id = r.dataset.labRound; C.key = ''; load(); return; }
|
|
178
186
|
const k = e.target.closest('[data-lab-key]'); if (k) { C.key = k.dataset.labKey; load(); return; }
|
|
179
187
|
const col = e.target.closest('.lab-col[data-lab-col]'); if (col && C.c && C.c.live) { C.key = col.dataset.labCol; load(); }
|
|
180
188
|
};
|