create-pmos 0.604.0 → 0.605.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.604.0",
3
+ "version": "0.605.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -33,6 +33,19 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.605.0",
38
+ "at": "2026-11-18T10:51:31.052Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1350,
43
+ "t": "Delete a prototype version from the chat or the Viewer, with Undo",
44
+ "s": "Delete a prototype version from the chat or the Viewer, with Undo",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
36
49
  {
37
50
  "v": "0.604.0",
38
51
  "at": "2026-11-18T10:31:31.776Z",
@@ -303,19 +316,6 @@
303
316
  "k": "fix"
304
317
  }
305
318
  ]
306
- },
307
- {
308
- "v": "0.585.0",
309
- "at": "2026-11-17T08:31:27.900Z",
310
- "f": 4,
311
- "prs": [
312
- {
313
- "n": 1320,
314
- "t": "The live round's ✦ carries its board, and ✓ without a board is placed on the initiative's board",
315
- "s": "The live round's ✦ carries its board, and ✓ without a board is placed on the initiative's board",
316
- "k": "fix"
317
- }
318
- ]
319
319
  }
320
320
  ]
321
321
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@7601647c
1
+ kernel-source: pmos@814cd4fd
2
2
  assembled: 2026-11-18
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-18T10:31:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-18T10:51:28Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-18T10:31:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-18T10:51:28Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-18T10:31:28Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-18T10:51:28Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,17 @@
1
1
  [
2
+ {
3
+ "v": "0.605.0",
4
+ "at": "2026-11-18T10:51:31.052Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1350,
9
+ "t": "Delete a prototype version from the chat or the Viewer, with Undo",
10
+ "s": "Delete a prototype version from the chat or the Viewer, with Undo",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
2
15
  {
3
16
  "v": "0.604.0",
4
17
  "at": "2026-11-18T10:31:31.776Z",
@@ -241,6 +241,8 @@ The idle lab run uses only the first three commands:
241
241
  - `pmos lab file <group> --json -`: a run files one result. It waits until the run ends and the proof passes.
242
242
  - `pmos lab status`: in a run, what it filed. Outside a run, this month's idle lab runs and spend.
243
243
  - `pmos lab round <initiative> --brief "<what to show>" [--one] [--base B] [--dirs "A: …|B: …|C: …"] [--of <round> [--from n]] [--propose] [--chat] [--ws <id>]`: a live round. With `--one`, PMOS makes one version with its flow, swimlane and copy, and shows it on the Viewer's canvas as soon as it renders; without it, PMOS starts three runs at once, one version each, side by side. With `--base B`, PMOS makes one new round of B from the brief: of the current prototype, or of the round that `--of` names (and its version n with `--from n`). With `--propose`, PMOS files the ✦ ask instead, and your ✓ starts it. With `--chat`, the initiative chat started it: the chat is told when the version renders, and the version becomes the initiative's prototype (a round from a terminal without it waits for your ✓). A background lab run cannot use this command. See [The live round](agent-capabilities.md).
244
+ - `pmos lab delete <initiative> [--file <round>/<A>/<a>.html | --version <n> [--key A]] [--ws <id>]`: delete one prototype version. Without `--file` or `--version`, PMOS deletes the prototype now. The version goes out of the Viewer and is not used for the next version. Its folder, with your edits, is kept aside, so the command prints the Undo. The Viewer's trash in the version bar does the same. A background lab run cannot use this command.
245
+ - `pmos lab undo <batch> [--ws <id>]`: bring a deleted version back, with its edits.
244
246
 
245
247
  ### pmos outcomes: expected outcomes
246
248
 
@@ -249,8 +249,12 @@ function compareOf(P, id, { key = '', titleOf = () => '', proven = PROVEN } = {}
249
249
  const keptP = new Set(); for (const k of P.kept) if (!P.undone.has(k.batch)) for (const x of k.ids) keptP.add(x);
250
250
  const PRsig = require('./proposals.js').sigOf;
251
251
  const stateOf = (x) => (keptP.has(x.id) ? 'kept' : P.drops.has(PRsig(x)) ? 'dropped' : 'open');
252
- const rounds = [...P.props.values()].filter((x) => x.group === 'improved' && x.ini === p.ini && root && x.data && x.data.of === root.id).sort((a, b) => a.data.round - b.data.round);
253
- const specs = root ? root.data.specimens || [] : [];
252
+ // a deleted version (lib/proposals.js removedOf) is left out everywhere: its round, its tray thumbnail, its History line
253
+ const gone = require('./proposals.js').removedOf(P);
254
+ if (p.group === 'improved' && p.data && p.data.file && gone.has(p.data.file)) return null;
255
+ const rounds = [...P.props.values()].filter((x) => x.group === 'improved' && x.ini === p.ini && root && x.data && x.data.of === root.id && !(x.data.file && gone.has(x.data.file))).sort((a, b) => a.data.round - b.data.round);
256
+ const specs = (root ? root.data.specimens || [] : []).filter((x) => !(x && x.file && gone.has(x.file)));
257
+ if (p.group === 'prototyped' && root && (root.data.specimens || []).length && !specs.length && !(p.data && p.data.live && (p.data.live.slots || []).some((x) => x.state === 'working' || x.state === 'proving'))) return null;
254
258
  const k = p.group === 'improved' ? p.data.base : (specs.find((s) => s.key === key) || specs[0] || {}).key || '';
255
259
  const spec = specs.find((s) => s.key === k) || null;
256
260
  const file = p.group === 'improved' ? p.data.file : spec && spec.file;
@@ -268,6 +272,7 @@ function compareOf(P, id, { key = '', titleOf = () => '', proven = PROVEN } = {}
268
272
  // being made, or not made, says so in one line (honest state). ✓ keeps the one shown (key) as the kept specimen.
269
273
  if (p.group === 'prototyped' && p.data && p.data.live) {
270
274
  for (const s of p.data.live.slots || []) {
275
+ if (s.file && gone.has(s.file)) continue;
271
276
  if (s.state === 'ok' && s.file) cols.push({ id: s.key, title: s.key + ' · ' + s.title, meta: 'round 1', file: s.file, read: s.dims ? 'rendered at ' + s.dims : '', current: s.key === k });
272
277
  else cols.push({ id: s.key, title: s.key + ' · ' + s.title, left: s.state === 'not made' ? 'Not made: ' + (s.why || 'it did not render') : 'PMOS is still making it.' });
273
278
  }
@@ -283,7 +288,7 @@ function compareOf(P, id, { key = '', titleOf = () => '', proven = PROVEN } = {}
283
288
  const pins = (c.pins || []).filter((x) => shown.has(x.vs)).map((x, i) => ({ n: i + 1, vs: x.vs, text: x.text }));
284
289
  const history = [];
285
290
  for (const r of rounds.slice().reverse()) history.push({ id: r.id, round: r.data.round, at: r.at, state: stateOf(r), meta: r.data.said || r.data.changed || '', current: r.id === p.id });
286
- if (root) history.push({ id: root.id, round: 1, at: root.at, state: stateOf(root), meta: specs.map((s) => s.key).join(', ') + (specs.length ? ': ' : '') + specs.map((s) => s.title).join(' · '), current: root.id === p.id, keys: specs.map((s) => ({ key: s.key, title: s.title })) });
291
+ if (root && specs.length) history.push({ id: root.id, round: 1, at: root.at, state: stateOf(root), meta: specs.map((s) => s.key).join(', ') + (specs.length ? ': ' : '') + specs.map((s) => s.title).join(' · '), current: root.id === p.id, keys: specs.map((s) => ({ key: s.key, title: s.title })) });
287
292
  const name = titleOf(p.ini) || p.ini;
288
293
  const live = !!(p.data && p.data.live);
289
294
  // what the version says about itself (its <meta name="pmos-changed">, lib/live-round.js saidOf) comes first; else what was asked
@@ -308,13 +313,16 @@ function roundsOf(P, ini) {
308
313
  const keptP = new Set(); for (const k of P.kept) if (!P.undone.has(k.batch)) for (const x of k.ids) keptP.add(x);
309
314
  const PRsig = require('./proposals.js').sigOf;
310
315
  const stateOf = (x) => (keptP.has(x.id) ? 'kept' : P.drops.has(PRsig(x)) ? 'dropped' : 'open');
311
- const all = [...P.props.values()];
316
+ const all = [...P.props.values()], gone = require('./proposals.js').removedOf(P);
312
317
  return all.filter((x) => x.group === 'prototyped' && x.ini === ini).sort((a, b) => String(b.at).localeCompare(String(a.at))).map((root) => {
313
318
  const d = root.data || {}, slots = (d.live && d.live.slots) || [];
314
- const keys = slots.length ? slots.filter((s) => s.state === 'ok' && s.file).map((s) => s.key) : (d.specimens || []).map((s) => s.key);
315
- const n = 1 + all.filter((x) => x.group === 'improved' && x.ini === ini && x.data && x.data.of === root.id).length;
316
- return { id: root.id, at: root.at, state: stateOf(root), keys, made: keys.length, rounds: n, working: slots.some((s) => s.state === 'working' || s.state === 'proving') };
317
- });
319
+ const keys = slots.length ? slots.filter((s) => s.state === 'ok' && s.file && !gone.has(s.file)).map((s) => s.key) : (d.specimens || []).filter((s) => !(s.file && gone.has(s.file))).map((s) => s.key);
320
+ const more = all.filter((x) => x.group === 'improved' && x.ini === ini && x.data && x.data.of === root.id && !(x.data.file && gone.has(x.data.file))).sort((a, b) => String(b.at).localeCompare(String(a.at)));
321
+ const working = slots.some((s) => s.state === 'working' || s.state === 'proving');
322
+ // every version of the round deleted: the round is gone too; its first versions deleted but later ones kept: it opens on the newest
323
+ if (!keys.length && !more.length && !working && (slots.length || (d.specimens || []).length)) return null;
324
+ return { id: !keys.length && !working && more.length ? more[0].id : root.id, at: root.at, state: stateOf(root), keys, made: keys.length, rounds: (keys.length ? 1 : 0) + more.length, working };
325
+ }).filter(Boolean);
318
326
  }
319
327
 
320
328
  module.exports = { LEDGER, GROUPS, TITLES, LOOSE, PROVEN, specimenDir, specimenPath, specimenUrl, result, loose, ledgerFile, readLines, read, append, fold, looseOpen, labOf, compareOf, roundsOf, fmtMs };
@@ -6,6 +6,8 @@
6
6
  * pmos lab page <n> [--from <line>] print a page this run already read, from a line
7
7
  * pmos lab file <group> --json <file|-> one result of this run. It waits until the run ends; then PMOS proves it and files it under ✦
8
8
  * pmos lab status in a run: what this run filed. Outside a run: this month's idle lab runs and spend
9
+ * pmos lab delete <ini> [--file <f> | --version <n> [--key A]] [--ws <id>] delete one prototype version (batch 31 item 9): the chat's agent
10
+ * runs it when the PM asks; it prints the batch, and `pmos lab undo <batch>` brings the version back
9
11
  * pmos lab round <ini> --brief "…" [--base B] [--dirs "A: …|B: …|C: …"] [--propose] [--chat] [--ws <id>]
10
12
  * --chat: the initiative chat's own agent started it, so the chat is told when the version renders
11
13
  * the live round (lib/live-round.js): the running server starts three runs now, or one on B; --propose
@@ -18,7 +20,7 @@ const path = require('path');
18
20
  const dns = require('dns');
19
21
  const E = require('./idle-lab-engine.js');
20
22
 
21
- const COMMANDS = { lab: ['page', 'file', 'status', 'round'] };
23
+ const COMMANDS = { lab: ['page', 'file', 'status', 'round', 'delete', 'undo'] };
22
24
  const GROUPS = { 'prototype-new': ['prototyped'], 'prototype-improve': ['improved'], 'scan-new': ['scanned', 'scan'], 'scan-improve': ['scanned', 'scan'] };
23
25
  const USAGE = [
24
26
  'usage: pmos lab page|file|status — the idle lab: PMOS prototypes and scans while you are away; each result waits under ✦ for your ✓',
@@ -33,6 +35,9 @@ const USAGE = [
33
35
  ' pmos lab round <initiative> --brief "<what to show>" [--one] [--base B] [--dirs "A: …|B: …|C: …"] [--propose] [--chat] [--of <round> [--from n]] [--ws <id>]',
34
36
  ' the live round: three versions now (--one: one, with its flow, swimlane and copy; --base B: the next',
35
37
  ' version of B from the brief), each shown as soon as it renders. --propose files the ✦ ask instead',
38
+ ' pmos lab delete <initiative> [--file <round>/<A>/<a>.html | --version <n> [--key A]] [--ws <id>]',
39
+ ' delete one prototype version (no --file or --version: the prototype now). It prints the batch',
40
+ ' pmos lab undo <batch> [--ws <id>] bring a deleted version back',
36
41
  'A specimen must open and render; every claim must quote what was read. What is not proven is dropped. Nothing is sent.',
37
42
  ];
38
43
  const flag = (args, k) => { const i = args.indexOf('--' + k); return i >= 0 ? (args[i + 1] === undefined || args[i + 1].startsWith('--') ? true : args[i + 1]) : undefined; };
@@ -149,6 +154,28 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, stdin
149
154
  return 0;
150
155
  }
151
156
 
157
+ if (verb === 'delete' || verb === 'undo') {
158
+ if (run) { say('✗ a lab run cannot delete a version'); return 1; }
159
+ const a1 = args[1] && !args[1].startsWith('--') ? args[1] : '', ws = flag(args, 'ws');
160
+ if (!a1) { say(verb === 'delete' ? 'usage: pmos lab delete <initiative> [--file <round>/<A>/<a>.html | --version <n> [--key A]] [--ws <id>]' : 'usage: pmos lab undo <batch> [--ws <id>]'); return 2; }
161
+ if (typeof call !== 'function') { say('✗ no PMOS server answers: start PMOS, then ask again'); return 1; }
162
+ let by = ''; try { by = require('./actor.js').fromCli({ env }).by || ''; } catch { by = ''; }
163
+ const file = flag(args, 'file'), n = flag(args, 'version'), key = flag(args, 'key');
164
+ if (n !== undefined && !/^\d{1,3}$/.test(String(n))) { say('✗ --version is the version number: 1, 2, 3 …'); return 2; }
165
+ if (key !== undefined && !/^[A-C]$/i.test(String(key))) { say('✗ --key is the letter of one of the ways: A, B or C'); return 2; }
166
+ const body = verb === 'delete'
167
+ ? { ini: a1, ...(typeof file === 'string' ? { file } : {}), ...(n !== undefined ? { n: Number(n) } : {}), ...(typeof key === 'string' ? { key: key.toUpperCase() } : {}) }
168
+ : { batch: a1 };
169
+ if (typeof ws === 'string') body.ws = ws;
170
+ if (by) body.by = by;
171
+ let r = null; try { r = await call('POST', verb === 'delete' ? '/api/lab/delete' : '/api/lab/restore', body); } catch { r = null; }
172
+ if (!r) { say('✗ no PMOS server answers: start PMOS, then ask again'); return 1; }
173
+ if (!r.ok) { say('✗ ' + (r.error || 'nothing changed')); return 1; }
174
+ if (verb === 'undo') { say('✓ ' + r.said); return 0; }
175
+ say(`✓ ${r.said} Undo: pmos lab undo ${r.batch}${typeof ws === 'string' ? ' --ws ' + ws : ''}`);
176
+ return 0;
177
+ }
178
+
152
179
  if (verb === 'status') {
153
180
  if (run && env.PMOS_LAB_PENDING) {
154
181
  let lines = [];
@@ -17,6 +17,9 @@ function presentOf(P, id, { titleOf = () => '' } = {}) {
17
17
  const frames = p.group === 'prototyped'
18
18
  ? (p.data.specimens || []).filter((s) => s && s.file).map((s) => ({ key: String(s.key || ''), title: String(s.title || ''), file: s.file }))
19
19
  : p.data.file ? [{ key: String(p.data.base || ''), title: String(p.data.changed || ''), file: p.data.file }] : [];
20
+ // a deleted version (lib/proposals.js removedOf) is not presented
21
+ const gone = require('./proposals.js').removedOf(P);
22
+ for (let i = frames.length - 1; i >= 0; i--) if (gone.has(frames[i].file)) frames.splice(i, 1);
20
23
  if (!frames.length) return null;
21
24
  return { ini: p.ini, board: p.board || '', id: p.id, title: titleOf(p.ini) || p.ini, round: p.group === 'improved' ? p.data.round : 1, frames };
22
25
  }
@@ -103,6 +103,10 @@ const CHANGE_RE = /^\s*(?:please\s+|can you\s+|could you\s+|now\s+)?(change|make
103
103
  // as a change of the prototype when the sentence names it (the prototype, a version, a screen, the layout, the design, or its letter)
104
104
  const WORK_RE = /^\s*(?:please\s+|can you\s+|could you\s+|now\s+|ok(?:ay)?,?\s+|yes,?\s+)?(improv|updat|refin|rework|redo|rebuild|redesign|restyl|polish|fix|adjust|tweak|iterat|apply|continu|cover|base|follow|align|writ)\w*/i;
105
105
  const PROTO_NOUN_RE = /\b(prototype|version|screens?|page|layout|design|mock ?up|ui|viewer|canvas|flow|swimlane|copy)\b/i;
106
+ // batch 31 item 9 (Wawan 2026-11-18, "delete it" about the prototype): asking to delete a version is never a change round, even though
107
+ // "remove" and "drop" are change words. The chat's agent deletes it with `pmos lab delete` instead. With an element pointed at, "delete it"
108
+ // stays a change of that element.
109
+ const DELETE_RE = /\b(?:delete|remove|discard|trash|drop|throw away|get rid of)\s+(?:(?:the|this|that|current|whole|entire|old|first|last|latest|my|of)\s+)*(?:prototypes?|versions?|rounds?|ways?|variants?)\b|\b(?:delete|discard|trash)\s+(?:it|this|that|them)\s*[.!]?\s*$|\b(?:delete|remove|discard)\s+(?:version\s*\d{1,3}|v\d{1,3}|[A-C])\b/i;
106
110
  const COUNT_RE = /\b(\d|two|three|a few|some|(?:a )?couple of)\s+(ways|options|versions|takes|directions|variants)\b/i;
107
111
  const WORDS = { two: 2, three: 3, 'a few': 3, some: 3, 'couple of': 2, 'a couple of': 2 };
108
112
  /** PURE. The marks the canvas puts before the PM's words (pm/cozy-proto.js through pm/home-chat.js): "[On: Screen list · screen-list]" for
@@ -127,6 +131,7 @@ function intentOf(text, { waiting = null } = {}) {
127
131
  if (!t || t.startsWith('/')) return null;
128
132
  const keys = waiting ? (waiting.keys || []) : [];
129
133
  const extra = { ...(mk.point ? { point: mk.point } : {}), ...(mk.from ? { from: mk.from } : {}) };
134
+ if (!mk.point && DELETE_RE.test(t)) return null;
130
135
  const f = FEEDBACK_RE.exec(t);
131
136
  if (f && keys.includes(f[1].toUpperCase())) return { kind: 'feedback', base: f[1].toUpperCase(), brief: t, ...extra };
132
137
  if (NEW_RE.test(t)) {
@@ -194,8 +199,12 @@ function baseOf(P, ini, key, { from = null, of = '' } = {}) {
194
199
  if (!root) return null;
195
200
  const rounds = all.filter((p) => p.group === 'improved' && p.data && p.data.of === root.id).sort((a, b) => (a.data.round || 0) - (b.data.round || 0));
196
201
  const spec = root.data.specimens.find((s) => s.key === key);
197
- const mine = rounds.filter((r) => r.data.base === key && r.data.file);
198
- const pick = from === 1 ? null : from ? mine.find((r) => Number(r.data.round) === Number(from)) : mine[mine.length - 1];
202
+ // a deleted version (lib/proposals.js removedOf) is never built on: its folder is gone
203
+ const gone = PR.removedOf(P);
204
+ const mine = rounds.filter((r) => r.data.base === key && r.data.file && !gone.has(r.data.file));
205
+ let pick = from === 1 ? null : from ? mine.find((r) => Number(r.data.round) === Number(from)) : mine[mine.length - 1];
206
+ if (!pick && gone.has(spec.file)) pick = mine[mine.length - 1];
207
+ if (!pick && gone.has(spec.file)) return null;
199
208
  const n = rounds.length ? Math.max(...rounds.map((r) => Number(r.data.round) || 1)) + 1 : 2;
200
209
  return { of: root.id, round: n, file: pick ? pick.data.file : spec.file, title: spec.title, from: pick ? Number(pick.data.round) : 1 };
201
210
  }
@@ -420,16 +429,20 @@ function contextOf(cur, { ini, ws = '', rt = null, versions = [] } = {}) {
420
429
  const vs = (versions || []).filter((v) => v && v.file).slice(0, 6);
421
430
  if (!vs.length) return '';
422
431
  const at = (v) => { const a = (rt && LAB.specimenPath(rt, v.file)) || v.file; return path.dirname(a); };
423
- const lines = vs.map((v, i) => `${i + 1}. ${v.n > 1 ? 'Version ' + v.n + ' of ' + v.key : v.key + (v.ways > 1 ? ' (one of ' + v.ways + ' ways)' : '')}${v.from === 'cli' ? ', started from a terminal (often a test)' : ''}: "${one(v.said || v.title, 120)}", asked as "${one(v.brief, 160)}". Files: ${at(v)}. Continue it with --base ${v.key} --of ${v.of}${v.n > 1 ? ' --from ' + v.n : ''}`);
432
+ const lines = vs.map((v, i) => `${i + 1}. ${v.n > 1 ? 'Version ' + v.n + ' of ' + v.key : v.key + (v.ways > 1 ? ' (one of ' + v.ways + ' ways)' : '')}${v.from === 'cli' ? ', started from a terminal (often a test)' : ''}: "${one(v.said || v.title, 120)}", asked as "${one(v.brief, 160)}". Files: ${at(v)}. Continue it with --base ${v.key} --of ${v.of}${v.n > 1 ? ' --from ' + v.n : ''}; delete it with --file ${v.file}`);
424
433
  return `[PMOS] This initiative has prototype versions in the Viewer, but the PM has not chosen one yet:\n${lines.join('\n')}\n`
425
434
  + `To change, improve or rebuild the prototype, in any words, pick the version the PM means (read its files and the brief; when the PM names a document such as the PRD, the one built from it), then run exactly: \`pmos lab round ${ini}${wsf} --base <letter> --of <round> [--from <n>] --chat --brief "<what to change, under 600 characters>"\` `
426
- + 'and say in one line which version you continue and what will change. If you cannot tell which one, ask the PM in one line, naming two at most. ' + never;
435
+ + 'and say in one line which version you continue and what will change. If you cannot tell which one, ask the PM in one line, naming two at most. '
436
+ + `When the PM asks to delete a version, run \`pmos lab delete ${ini}${wsf} --file <its file>\` yourself (its --file is on its line), never delete a folder by hand, and say in one line that "undo" brings it back. ` + never;
427
437
  }
438
+ // batch 31 item 9 (Wawan 2026-11-18): "delete it" deletes the version; the agent does it, never by hand, and the PM can undo it
439
+ const del = (c) => `When the PM asks to delete or remove this version (or another one), run \`pmos lab delete ${ini}${wsf} --file ${c.file}\` yourself (another version: --version <n> --key <letter> instead of --file), `
440
+ + 'never delete the folder by hand, and say in one line what was deleted and that "undo" brings it back (`pmos lab undo <batch>`, the batch it prints). ';
428
441
  const abs = (rt && LAB.specimenPath(rt, cur.file)) || cur.file, dir = path.dirname(abs);
429
442
  return `[PMOS] This initiative's prototype is Version ${cur.n} (${cur.key}${cur.said ? ': "' + one(cur.said, 140) + '"' : ''}), open in the Viewer beside this chat. `
430
443
  + `Its files are in ${dir}: ${path.basename(abs)} (the prototype), flow.json, lanes.json, copy.json, tweaks.json, and edits.json (the PM's own edits in the Viewer). Read them to answer questions about it. `
431
444
  + `To change, improve or rebuild it, in any words, run exactly: \`pmos lab round ${ini}${wsf} --base ${cur.key} --chat --brief "<what to change, with the PM's words and anything you read, under 600 characters>"\` `
432
- + `and say in one line what will change: PMOS makes Version ${cur.n + 1} in about a minute and tells you when it is in the Viewer. ` + never;
445
+ + `and say in one line what will change: PMOS makes Version ${cur.n + 1} in about a minute and tells you when it is in the Viewer. ` + del(cur) + never;
433
446
  }
434
447
 
435
448
  /* ── the proposal line of a round ── */
@@ -737,6 +750,6 @@ function running(ini) { return inst ? inst.running(ini) : false; }
737
750
  function stopRound(id) { return inst ? inst.stop(id) : { ok: false, error: NOT_READY }; }
738
751
  function status() { return inst ? inst.status() : []; }
739
752
 
740
- module.exports = { JOB, ORIGIN, STALL_MS, progressOf, KEYS, DEFAULT_DIRECTIONS, ONE_DIRECTION, PARTS, FROM, marksOf, intentOf, parseDirs, askOf, waiting, baseOf, currentOf: PR.currentOf, contextOf, scaffoldOf, promptOf, saidOf, roundLine,
753
+ module.exports = { DELETE_RE, JOB, ORIGIN, STALL_MS, progressOf, KEYS, DEFAULT_DIRECTIONS, ONE_DIRECTION, PARTS, FROM, marksOf, intentOf, parseDirs, askOf, waiting, baseOf, currentOf: PR.currentOf, contextOf, scaffoldOf, promptOf, saidOf, roundLine,
741
754
  flowOf, lanesOf, tweaksOf, copyOf, changesOf, partsAt, editsOf, styleWords, STYLE_OK,
742
755
  create, install, round, startNow, proposeNow, cancel, stopRound, dropCard, running, status };
@@ -53,6 +53,9 @@
53
53
  * initiative changes; it folds as a drop of that signature (a newer filing with new evidence comes back), and the line keeps the
54
54
  * reason for History. Computed date proposals (datesOf) are read fresh each time and never expire
55
55
  * epoch { } the first scan of lib/proposal-runs.js: only initiatives made after it are looked for
56
+ * remove { ini, id, file, n, key, batch } the PM (or the chat's agent for the PM) deleted one prototype version (batch 31 item 9,
57
+ * Wawan 2026-11-18: "should be able to delete the prototype"). Its folder moves out of the specimens folder (lib/routes-lab.js);
58
+ * every reader leaves the version out (removedOf). `undo { batch }` gives it back
56
59
  *
57
60
  * A WRITE (in keep.wrote): { op, task?, title?, from?, to?, why, source?, ... } op ∈ add · dates · state · rename · notes · stage · ran ·
58
61
  * doc · linked · epics · unlink · outbox · prd. The fold reads the kept doc, linked and ran writes as the initiative's own (they have no
@@ -69,6 +72,7 @@
69
72
  * viewOf(F, ini, o) → what r.props carries (null: nothing to show)
70
73
  * 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
74
  * currentOf(F, ini) PURE → the initiative's prototype now: the newest proven version, or the one the PM kept since | null
75
+ * removedOf(F) PURE → Set of the deleted versions' files (<round>/<key>/<key>.html); an undone delete is not in it
72
76
  * historyOf(F, uid) → [entry] Claude's approved changes to one task, newest first, each with its reason and source
73
77
  * decorate(rows, F, items, o) puts r.props and r.found on each Board row that has something
74
78
  */
@@ -77,7 +81,7 @@ const path = require('path');
77
81
  const crypto = require('crypto');
78
82
 
79
83
  const LEDGER = 'proposals.jsonl';
80
- const KINDS = new Set(['epoch', 'look', 'src', 'end', 'propose', 'drop', 'keep', 'undo', 'expire']);
84
+ const KINDS = new Set(['epoch', 'look', 'src', 'end', 'propose', 'drop', 'keep', 'undo', 'expire', 'remove']);
81
85
  /* chief-of-staff C3: a filed ✦ with no answer for this many days expires (left as it was, the reason kept) */
82
86
  const EXPIRE_DAYS = 14;
83
87
  const EXPIRE_WHY = 'No answer in 14 days, so I left it as it was.';
@@ -245,6 +249,7 @@ function fold(lines) {
245
249
  const undone = new Set();
246
250
  const looks = new Map(); // ini → { run, why, at, ended, ok, stopped, sources: Map source → { state, n, what } }
247
251
  const expired = []; // expire lines, oldest first (History and Your move's "N expired")
252
+ const removes = []; // remove lines, oldest first: a deleted prototype version (removedOf)
248
253
  let t = '', epoch = '';
249
254
  for (const l of lines || []) {
250
255
  if (!isObj(l) || !KINDS.has(l.kind)) continue;
@@ -259,8 +264,9 @@ function fold(lines) {
259
264
  else if (l.kind === 'keep' && str(l.batch)) kept.push({ batch: l.batch, ini, board: str(l.board), ids: Array.isArray(l.ids) ? l.ids : [], wrote: Array.isArray(l.wrote) ? l.wrote.filter(isObj) : [], at: l.at || '', by: l.by || null });
260
265
  else if (l.kind === 'undo' && str(l.batch)) undone.add(l.batch);
261
266
  else if (l.kind === 'expire' && str(l.sig)) { drops.add(l.sig); expired.push({ ini, id: str(l.id), sig: l.sig, group: str(l.group), title: str(l.title), why: str(l.why) || EXPIRE_WHY, at: l.at || '' }); }
267
+ else if (l.kind === 'remove' && str(l.file) && str(l.batch)) removes.push({ ini, id: str(l.id), file: l.file, n: Number(l.n) || 1, key: str(l.key), batch: l.batch, at: l.at || '', by: l.by || null });
262
268
  }
263
- return { props, drops, dropWhy, kept, undone, looks, epoch, t, expired };
269
+ return { props, drops, dropWhy, kept, undone, looks, epoch, t, expired, removes };
264
270
  }
265
271
  /**
266
272
  * PURE. What the PM taught one job on one initiative (OS evaluation T1, the learning edge): the reasons given with ✕ and the rewrites made
@@ -300,6 +306,12 @@ function lessonsOn(lines, { match, on }) {
300
306
  }
301
307
  return out;
302
308
  }
309
+ /** PURE. The deleted prototype versions' files; a delete that was undone gives its version back. */
310
+ function removedOf(F) {
311
+ const s = new Set();
312
+ for (const r of (F && F.removes) || []) if (!(F.undone && F.undone.has(r.batch))) s.add(r.file);
313
+ return s;
314
+ }
303
315
  /** The kept proposal ids (a batch undone gives its proposals back). */
304
316
  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
317
  /** PURE. The initiative's prototype now (prototype by chatting, fix 2026-11-18): the newest proven one-version live round or version of it,
@@ -312,13 +324,14 @@ function currentOf(F, ini) {
312
324
  const exp = new Set((F.expired || []).map((x) => x.sig));
313
325
  const closed = (p) => { const g = sigOf(p); return F.drops.has(g) && !exp.has(g); };
314
326
  const live = (p) => !!p && p.ini === ini && isObj(p.data) && isObj(p.data.live);
327
+ const gone = removedOf(F); // a deleted version is never the prototype
315
328
  const of = (p, file, at) => {
316
329
  const d = p.data;
317
330
  if (p.group === 'prototyped') {
318
- const s = (Array.isArray(d.specimens) ? d.specimens : []).find((x) => isObj(x) && str(x.file) && (!file || x.file === file));
331
+ const s = (Array.isArray(d.specimens) ? d.specimens : []).find((x) => isObj(x) && str(x.file) && !gone.has(x.file) && (!file || x.file === file));
319
332
  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
333
  }
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 };
334
+ if (p.group === 'improved' && str(d.file) && !gone.has(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
335
  return null;
323
336
  };
324
337
  const out = [];
@@ -338,23 +351,25 @@ function currentOf(F, ini) {
338
351
  try { files.push(decodeURIComponent(str(w.ref).split(/[?&]file=/)[1].split('&')[0])); } catch { /* not a specimen link */ }
339
352
  }
340
353
  // a keep that wrote no document (2026-11-18: a ✓ on a round of three kept nothing) keeps the round's first version
341
- for (const id of k.ids) { const p = F.props.get(String(id)); if (!live(p)) continue; for (const file of files.length ? files : ['']) { const c = of(p, file, k.at); if (c) out.push(c); } }
354
+ // (that first version, not the next way: when it was deleted, the keep keeps nothing; batch 31 item 9)
355
+ const first = (p) => (p.group === 'prototyped' ? str(((p.data.specimens || [])[0] || {}).file) : str(p.data.file));
356
+ for (const id of k.ids) { const p = F.props.get(String(id)); if (!live(p)) continue; for (const file of files.length ? files : [first(p)]) { const c = of(p, file, k.at); if (c) out.push(c); } }
342
357
  }
343
358
  out.sort((a, b) => String(b.at).localeCompare(String(a.at)));
344
359
  return out[0] || null;
345
360
  }
346
- /** PURE. Every proven version of the live rounds on `ini`, newest first, at most n: { of (the round's first proposal), key, n, file, said,
361
+ /** PURE. Every proven version of the live rounds on `ini`, newest first, at most n: { id (its own proposal), of (the round's first proposal), key, n, file, said,
347
362
  * title, brief, from, ways (how many versions its round made), at }. The chat lists them when no version is the prototype yet, so it
348
363
  * can continue the one the PM means (2026-11-18: the PRD round had three ways and none kept; the chat built a new one instead). */
349
364
  function versionsOf(F, ini, n = 6) {
350
365
  if (!F || !F.props) return [];
351
- const out = [];
366
+ const out = [], gone = removedOf(F);
352
367
  for (const p of F.props.values()) {
353
368
  const d = p.data || {};
354
369
  if (p.ini !== ini || !isObj(d.live)) continue;
355
370
  const from = str(d.live.from), ways = (d.live.slots || []).length || 1;
356
- if (p.group === 'prototyped') for (const s of Array.isArray(d.specimens) ? d.specimens : []) { if (isObj(s) && str(s.file)) out.push({ of: p.id, key: str(s.key), n: 1, file: s.file, said: str(s.caption), title: str(s.title), brief: str(d.live.brief), from, ways, at: p.at }); }
357
- else if (p.group === 'improved' && str(d.file)) out.push({ of: str(d.of), key: str(d.base), n: Number(d.round) || 2, file: d.file, said: str(d.said), title: '', brief: str(d.changed), from, ways: 1, at: p.at });
371
+ if (p.group === 'prototyped') for (const s of Array.isArray(d.specimens) ? d.specimens : []) { if (isObj(s) && str(s.file) && !gone.has(s.file)) out.push({ id: p.id, of: p.id, key: str(s.key), n: 1, file: s.file, said: str(s.caption), title: str(s.title), brief: str(d.live.brief), from, ways, at: p.at }); }
372
+ else if (p.group === 'improved' && str(d.file) && !gone.has(d.file)) out.push({ id: p.id, of: str(d.of), key: str(d.base), n: Number(d.round) || 2, file: d.file, said: str(d.said), title: '', brief: str(d.changed), from, ways: 1, at: p.at });
358
373
  }
359
374
  out.sort((a, b) => String(b.at).localeCompare(String(a.at)) || a.key.localeCompare(b.key));
360
375
  return out.slice(0, n);
@@ -566,5 +581,5 @@ function decorate(rows, F, items, o = {}) {
566
581
 
567
582
  module.exports = {
568
583
  LEDGER, GROUPS, TYPES, SOURCES, SOURCE_NAMES, RISK_DAYS, ledgerFile, read, readLines, append, fold, lessonsOf, clean, idOf, sigOf, itemSig, factsOf, tidyName, taskOf, lateOf,
569
- datesOf, viewOf, foundOf, currentOf, versionsOf, historyOf, decorate, keptIds, newBatch, dn, isoN, md, hash, workday, staleOf, expiredSince, EXPIRE_DAYS, EXPIRE_WHY,
584
+ datesOf, viewOf, foundOf, currentOf, versionsOf, removedOf, historyOf, decorate, keptIds, newBatch, dn, isoN, md, hash, workday, staleOf, expiredSince, EXPIRE_DAYS, EXPIRE_WHY,
570
585
  };
@@ -20,6 +20,9 @@
20
20
  * adds the canvas runtime (lib/proto-runtime.js) inside the same sandbox, so the canvas can point, pin, play and edit through postMessage.
21
21
  * POST /api/lab/edit { ws, file, copy?: { key: text }, vars?: { --var: value }, styles?: { el: { prop: value } | null } } → { ok } the PM's in-place copy edits, tweaks and inspector styles,
22
22
  * kept with the version (edits.json next to it); the next version reads them
23
+ * POST /api/lab/delete { ws, ini, file? | n?, key? } → { ok, batch, said, deleted, next } delete one prototype version (no file and no n:
24
+ * the prototype now); next: what the Viewer opens instead, or null. `pmos lab delete` reaches it too
25
+ * POST /api/lab/restore { ws, batch } → { ok, said, back } Undo of that delete (`pmos lab undo <batch>`)
23
26
  * POST /api/lab/comment { ws, ini, file, el?, label?, text, x?, y?, send? } → { ok, id } a comment pinned to an element (send: it was
24
27
  * sent to PMOS as the next change; else it is kept for the team)
25
28
  *
@@ -240,6 +243,47 @@ const WRITES = {
240
243
  },
241
244
  };
242
245
  const COMMENTS = 'lab-comments.jsonl';
246
+ /* ── delete a prototype version (batch 31 item 9, Wawan 2026-11-18: "should be able to delete the prototype") ──
247
+ * Asked in the chat ("delete version 1"), the chat's agent runs `pmos lab delete`; in the Viewer, the trash in the version bar. No
248
+ * confirm: Undo is the safety (the delete-task rule). The version's folder (<round>/<key>/: the prototype, its flow, lanes, copy, tweaks and
249
+ * the PM's edits.json) moves to <runtime>/idle-lab/removed/<batch>/, out of the specimens folder, so nothing serves or builds on it; the
250
+ * ledger's remove line hides it from every reader (lib/proposals.js removedOf). Undo moves it back and writes undo { batch }. */
251
+ const REMOVED = ['idle-lab', 'removed'];
252
+ /** PURE. The version `b` names on `ini`: { file } exactly, { n, key? } the newest such version, or nothing: the prototype now. */
253
+ function versionOf(F, ini, b) {
254
+ const all = PR.versionsOf(F, ini, 500), f = typeof b.file === 'string' ? b.file : '';
255
+ if (f) return all.find((v) => v.file === f) || null;
256
+ const n = Number(b.n) || 0, key = /^[A-C]$/i.test(String(b.key || '')) ? String(b.key).toUpperCase() : '';
257
+ if (n) return all.find((v) => v.n === n && (!key || v.key === key)) || null;
258
+ const cur = PR.currentOf(F, ini);
259
+ return cur ? all.find((v) => v.file === cur.file) || null : null;
260
+ }
261
+ function removeVersion(ctx, res, b, actor, dir) {
262
+ const ini = String(b.ini || ''); if (!ID_RE.test(ini)) return fail(ctx, res, 400, 'ini names the initiative');
263
+ if (!ctx.runtimeDir) return fail(ctx, res, 409, 'PMOS has no runtime folder');
264
+ const path = require('path'), F = PR.read(dir), v = versionOf(F, ini, b);
265
+ if (!v) return fail(ctx, res, 404, b.file || b.n ? 'That version is not here: it was deleted, or it was never made' : 'This initiative has no prototype version to delete');
266
+ const abs = LAB.specimenPath(ctx.runtimeDir, v.file); if (!abs) return fail(ctx, res, 400, 'That is not a prototype version');
267
+ const batch = PR.newBatch(), src = path.dirname(abs), dst = path.join(ctx.runtimeDir, ...REMOVED, batch, path.relative(LAB.specimenDir(ctx.runtimeDir), src));
268
+ try { if (fs.existsSync(src)) { fs.mkdirSync(path.dirname(dst), { recursive: true }); fs.renameSync(src, dst); } } catch { return fail(ctx, res, 500, 'The version was not deleted: its folder could not be moved'); }
269
+ PR.append(dir, actor, { kind: 'remove', ini, id: v.id, file: v.file, n: v.n, key: v.key, batch });
270
+ // what the Viewer opens next: the prototype now, else the newest version left, else nothing (the Viewer closes)
271
+ const F2 = PR.read(dir), cur = PR.currentOf(F2, ini), left = PR.versionsOf(F2, ini, 1)[0] || null, next = cur || left;
272
+ const name = `Version ${v.n}${v.ways > 1 || v.n === 1 ? ' (' + v.key + ')' : ''}`;
273
+ ctx.json(res, { ok: true, batch, said: `Deleted ${name}.`, deleted: { file: v.file, n: v.n, key: v.key }, next: next ? { id: next.id, key: next.key, n: next.n } : null });
274
+ return true;
275
+ }
276
+ function restoreVersion(ctx, res, b, actor, dir) {
277
+ const batch = String(b.batch || ''), F = PR.read(dir), r = (F.removes || []).find((x) => x.batch === batch);
278
+ if (!r || F.undone.has(batch)) return fail(ctx, res, 409, 'Nothing to undo');
279
+ const path = require('path'), abs = ctx.runtimeDir ? LAB.specimenPath(ctx.runtimeDir, r.file) : null;
280
+ if (!abs) return fail(ctx, res, 409, 'Nothing to undo');
281
+ const dst = path.dirname(abs), src = path.join(ctx.runtimeDir, ...REMOVED, batch, path.relative(LAB.specimenDir(ctx.runtimeDir), dst));
282
+ try { if (fs.existsSync(src)) { if (fs.existsSync(dst)) return fail(ctx, res, 409, 'A version is already in its place'); fs.mkdirSync(path.dirname(dst), { recursive: true }); fs.renameSync(src, dst); } } catch { return fail(ctx, res, 500, 'The version was not brought back'); }
283
+ PR.append(dir, actor, { kind: 'undo', batch });
284
+ ctx.json(res, { ok: true, said: `Version ${r.n} is back.`, back: { id: r.id, key: r.key, n: r.n } });
285
+ return true;
286
+ }
243
287
  /** The experiment's kept specimen, when `file` is the initiative's current version: "Version n, with your edits in the Viewer (…)". */
244
288
  function keptEdited(dir, file, ed, g) {
245
289
  const F = PR.read(dir);
@@ -291,12 +335,22 @@ module.exports = {
291
335
  if (req.method === 'GET') { const fn = READS[p0]; if (!fn) return fail(ctx, res, 404, 'not found'); return fn(ctx, res, url); }
292
336
  if (req.method !== 'POST') return fail(ctx, res, 405, 'GET or POST only');
293
337
  const fn = WRITES[p0];
294
- if (!fn && p0 !== '/api/lab/round') return fail(ctx, res, 404, 'not found');
338
+ if (!fn && !['/api/lab/round', '/api/lab/delete', '/api/lab/restore'].includes(p0)) return fail(ctx, res, 404, 'not found');
295
339
  const got = await ctx.readJson(req);
296
340
  if (!got.ok || !isObj(got.body)) return fail(ctx, res, 400, 'the body must be a JSON object');
297
341
  // the live round (lib/live-round.js): `pmos lab round` reaches it with no Origin (D98: an agent does what it was asked; the PM's own
298
342
  // terminal too). It starts a round, or with propose: true only files the ✦ ask the PM's ✓ starts. Never a write of a record.
299
343
  if (p0 === '/api/lab/round') return liveRound(ctx, res, got.body);
344
+ // delete and undo a prototype version: the trash in the Viewer (a page press), or `pmos lab delete|undo` from the chat's agent (D98,
345
+ // no Origin: the same door as the live round). A request from another site always carries its Origin, so it meets the page press.
346
+ if (p0 === '/api/lab/delete' || p0 === '/api/lab/restore') {
347
+ let actor;
348
+ if (req.headers.origin) { const g = guard.requirePagePress(req, got.body); if (!g.ok) return fail(ctx, res, g.status, g.error); actor = g.actor; }
349
+ else actor = { by: /^(pm|agent):[\w.:-]{1,80}$/.test(String(got.body.by || '')) ? got.body.by : 'agent:cli' };
350
+ const w = wsOf(ctx, typeof got.body.ws === 'string' && got.body.ws ? got.body.ws : null); if (!w) return fail(ctx, res, 404, 'no such workspace');
351
+ const dir = dirOf(ctx, w); if (!dir) return fail(ctx, res, 409, 'This repository has no PMOS state folder.');
352
+ return (p0 === '/api/lab/delete' ? removeVersion : restoreVersion)(ctx, res, got.body, actor, dir);
353
+ }
300
354
  const g = guard.requirePagePress(req, got.body);
301
355
  if (!g.ok) return fail(ctx, res, g.status, g.error);
302
356
  const w = wsOf(ctx, typeof got.body.ws === 'string' ? got.body.ws : null); if (!w) return fail(ctx, res, 404, 'no such workspace');
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.604.0",
3
+ "version": "0.605.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.604.0",
9
+ "version": "0.605.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.604.0",
3
+ "version": "0.605.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -139,7 +139,7 @@ function draw() {
139
139
  const VW = window.czViewer, b = VW && VW.body(), cur = VW && VW.current();
140
140
  if (!b || !cur || cur.id !== 'lab:cmp' || !C.c) return;
141
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 } });
142
+ if (C.c.live) PC.draw(b, C.c, { at: C.at, H: { ...(C.H || {}), load, go: (id, key) => { C.id = id; C.key = key || ''; load(); } } });
143
143
  else b.innerHTML = bodyHtml(C.c);
144
144
  VW.setPresses(cur.id, presses(C.c));
145
145
  if (VW.retitle) VW.retitle(cur.id, C.c.title);
@@ -38,6 +38,7 @@ const I = {
38
38
  keep: 'M6 4h12v16l-6-4-6 4z', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1',
39
39
  text: 'M4 7V5h16v2M12 5v14M9 19h6', flow: 'M3 4h6v5H3zM15 4h6v5h-6zM9 15h6v5H9zM9 6.5h6M18 9v3h-6v3', lanes: 'M3 6h18M3 12h18M3 18h18M6 4h4v4H6zM13 10h4v4h-4z',
40
40
  left: 'M3 4h18v16H3zM9 4v16', right: 'M3 4h18v16H3zM15 4v16', own: 'M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5', undo: 'M3 7v6h6M21 17a9 9 0 0 0-15-6.7L3 13', select: 'M4 3l7 18 2.5-7.5L21 11z',
41
+ trash: 'M5 7h14M10 11v6M14 11v6M7 7l1 13h8l1-13M9 7V4h6v3',
41
42
  attach: 'M20 11l-8.5 8.5a5 5 0 0 1-7-7L13 4a3.5 3.5 0 0 1 5 5l-8.5 8.5a2 2 0 0 1-3-3L14 7', star: 'M12 3l2.2 6.3H21l-5.4 4 2 6.4L12 15.8 6.4 19.7l2-6.4L3 9.3h6.8z',
42
43
  };
43
44
  const ib = (attr, label, icon, cls = '') => `<button type="button" class="pc-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon, 16)}</button>`;
@@ -181,12 +182,15 @@ function barHtml(c, v) {
181
182
  const ver = !old ? `<span class="pc-ver">${older ? ib(`data-lab-round="${esc(older.id)}"`, 'Earlier version', I.prev) : ''}<b>Latest · version ${c.round || 1}</b></span>`
182
183
  : `<span class="pc-ver">${ib(`data-lab-round="${esc(older ? older.id : '')}"${older ? '' : ' disabled'}`, 'Earlier version', I.prev)}<b>Version ${c.round}</b>${ib(`data-lab-round="${esc(newer ? newer.id : '')}"`, 'Later version', I.next)}`
183
184
  + ib(`data-lab-round="${esc(newest.id)}"`, 'Back to latest', I.latest) + ib(`data-pc-from="${c.round}"`, 'Continue from version ' + c.round, I.cont) + '</span>';
185
+ // delete this version (batch 31 item 9): icon-only, no confirm; the toast's Undo brings it back
186
+ const vname = 'version ' + (c.round || 1) + ((c.columns || []).filter((x) => /^[A-C]$/.test(x.id)).length > 1 ? ' (' + c.key + ')' : '');
187
+ const del = c.file && !c.working ? ib(`data-pc-del="${esc(c.file)}"`, 'Delete ' + vname, I.trash) : '';
184
188
  const z = Math.round((V.zoom || 1) * 100), u = c.updated || {};
185
189
  return `<div class="pc-bar" role="toolbar" aria-label="Prototype tools"><span class="pc-grp">${tool('point', 'Select a layer', I.select, 'V')}${tool('comment', 'Comment', I.comment, 'C')}${tool('draw', 'Draw a sketch', I.draw, 'D')}</span>`
186
190
  + `<span class="pc-grp" aria-label="Show or hide panels">${tog('data-pc-left', V.left, (V.left ? 'Hide' : 'Show') + ' pages and layers ([)', I.left)}${tog('data-pc-insp', V.insp && !V.side, (V.insp ? 'Hide' : 'Show') + ' the inspector (])', I.right)}</span>`
187
191
  // the page copy, the flow and who does what each sit behind one press, closed by default (Wawan 2026-11-18), like the page copy before
188
192
  + `<span class="pc-grp" aria-label="Side panels">${tog('data-pc-side="copy"', V.side === 'copy', 'Page copy', I.text, u.copy ? ' upd' : '')}${tog('data-pc-side="flow"', V.side === 'flow', 'The flow', I.flow, u.flow ? ' upd' : '')}${tog('data-pc-side="lanes"', V.side === 'lanes', 'Who does what', I.lanes, u.lanes ? ' upd' : '')}</span>`
189
- + `${ver}<span class="pc-sp"></span>`
193
+ + `${ver}${del}<span class="pc-sp"></span>`
190
194
  + `<span class="pc-grp">${ib('data-pc-zoom="-1"', 'Zoom out', I.minus)}<span class="pc-z" aria-live="polite">${z}%</span>${ib('data-pc-zoom="1"', 'Zoom in', I.plus)}${ib('data-pc-zoom="0"', 'Fit to the Viewer', I.fit)}</span>`
191
195
  + `${ib('data-pc-play', 'Play the prototype', I.play, 'blue')}</div>`;
192
196
  }
@@ -440,6 +444,7 @@ function wire(root) {
440
444
  if (d.pcSug) { if (d.pcSug === 'link') testLink(); store.set(d.pcSugk, '1'); V.sig = ''; draw(V.body, V.c); return; }
441
445
  if (d.pcInk) { if (d.pcInk === 'clear') clearInk(); else attachInk(); return; }
442
446
  if (d.pcTray) { tray(d.pcTray); return; }
447
+ if (d.pcDel) { delVersion(d.pcDel); return; }
443
448
  if (d.pcPlayx) { if (d.pcPlayx === 'close') { V.play = null; const p = root.querySelector('.pc-play'); if (p) p.remove(); } else startPlay(V.play.id, 0); return; }
444
449
  });
445
450
  // a number or a list takes effect when it is changed (an arrow press, Enter, leaving the field), not on every key
@@ -540,6 +545,23 @@ async function tray(a) {
540
545
  if (V.H && V.H.load) V.H.load();
541
546
  }
542
547
 
548
+ /** Delete the version shown (POST /api/lab/delete): the Viewer opens the prototype now, or the newest version left, or closes. Undo in
549
+ * the toast brings it back (POST /api/lab/restore) and opens it again. */
550
+ async function delVersion(file) {
551
+ const at = V.at || {}, c = V.c; if (!c || !file) return;
552
+ const go = (n) => { if (n && V.H && V.H.go) V.H.go(n.id, n.key); else if (!n && typeof window !== 'undefined' && window.czViewer) window.czViewer.close(); };
553
+ const r = await pmPost('/api/lab/delete', { ws: at.ws, ini: c.ini, file }).catch(() => null);
554
+ if (!r || r.ok === false) { say((r && r.error) || 'Nothing was deleted.'); return; }
555
+ say(r.said, async () => {
556
+ const u = await pmPost('/api/lab/restore', { ws: at.ws, batch: r.batch }).catch(() => null);
557
+ if (!u || u.ok === false) { say((u && u.error) || 'It did not come back.'); return; }
558
+ if (V.H && V.H.reload) V.H.reload();
559
+ if (V.H && V.H.go && window.czViewer && window.czViewer.current() && window.czViewer.current().id === 'lab:cmp') V.H.go(u.back.id, u.back.key);
560
+ });
561
+ if (V.H && V.H.reload) V.H.reload();
562
+ go(r.next);
563
+ }
564
+
543
565
  /* ── Draw: a sketch goes with the next message as the reference ── */
544
566
  function ink(root) {
545
567
  const cv = root.querySelector('.pc-ink'); if (!cv) return;
@@ -0,0 +1,7 @@
1
+ {
2
+ "_comment": "Batch 31 item 9: delete a prototype version, from the chat (`pmos lab delete`) or the Viewer's trash, with Undo (lib/proposals.js removedOf, lib/routes-lab.js /api/lab/delete and /api/lab/restore, lib/lab-cli.js). Backend and source reads only.",
3
+ "modules": [
4
+ "prototype-delete.test.js"
5
+ ],
6
+ "seconds": { "prototype-delete.test.js": 1 }
7
+ }