create-pmos 0.604.0 → 0.606.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 +1 -1
- 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/workspace/changelog.json +26 -0
- package/workspace/guide/agent-capabilities.md +3 -3
- package/workspace/guide/cli.md +2 -0
- package/workspace/lib/idle-lab.js +16 -8
- package/workspace/lib/lab-cli.js +28 -1
- package/workspace/lib/lab-present.js +3 -0
- package/workspace/lib/live-round.js +19 -6
- package/workspace/lib/proposals.js +25 -10
- package/workspace/lib/routes-lab.js +55 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-lab.js +1 -1
- package/workspace/public/pm/cozy-proto.css +23 -14
- package/workspace/public/pm/cozy-proto.js +129 -89
- package/workspace/test-lists/prototype-delete.json +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.606.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,32 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.606.0",
|
|
38
|
+
"at": "2026-11-18T11:27:58.320Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1348,
|
|
43
|
+
"t": "Readable flow and who does what panels, copy panel width, tweaks in the inspector",
|
|
44
|
+
"s": "Readable flow and who does what panels, copy panel width, tweaks in the inspector",
|
|
45
|
+
"k": "fix"
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"v": "0.605.0",
|
|
51
|
+
"at": "2026-11-18T10:51:31.052Z",
|
|
52
|
+
"f": 4,
|
|
53
|
+
"prs": [
|
|
54
|
+
{
|
|
55
|
+
"n": 1350,
|
|
56
|
+
"t": "Delete a prototype version from the chat or the Viewer, with Undo",
|
|
57
|
+
"s": "Delete a prototype version from the chat or the Viewer, with Undo",
|
|
58
|
+
"k": "new"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
36
62
|
{
|
|
37
63
|
"v": "0.604.0",
|
|
38
64
|
"at": "2026-11-18T10:31:31.776Z",
|
|
@@ -290,32 +316,6 @@
|
|
|
290
316
|
"k": "fix"
|
|
291
317
|
}
|
|
292
318
|
]
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
"v": "0.586.0",
|
|
296
|
-
"at": "2026-11-17T09:31:31.443Z",
|
|
297
|
-
"f": 4,
|
|
298
|
-
"prs": [
|
|
299
|
-
{
|
|
300
|
-
"n": 1321,
|
|
301
|
-
"t": "A headless prototype run may write in a folder whose path has a space",
|
|
302
|
-
"s": "A headless prototype run may write in a folder whose path has a space",
|
|
303
|
-
"k": "fix"
|
|
304
|
-
}
|
|
305
|
-
]
|
|
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
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-18T11:27:55Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-18T11:27:55Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-18T11:27:55Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.606.0",
|
|
4
|
+
"at": "2026-11-18T11:27:58.320Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1348,
|
|
9
|
+
"t": "Readable flow and who does what panels, copy panel width, tweaks in the inspector",
|
|
10
|
+
"s": "Readable flow and who does what panels, copy panel width, tweaks in the inspector",
|
|
11
|
+
"k": "fix"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"v": "0.605.0",
|
|
17
|
+
"at": "2026-11-18T10:51:31.052Z",
|
|
18
|
+
"f": 4,
|
|
19
|
+
"prs": [
|
|
20
|
+
{
|
|
21
|
+
"n": 1350,
|
|
22
|
+
"t": "Delete a prototype version from the chat or the Viewer, with Undo",
|
|
23
|
+
"s": "Delete a prototype version from the chat or the Viewer, with Undo",
|
|
24
|
+
"k": "new"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
2
28
|
{
|
|
3
29
|
"v": "0.604.0",
|
|
4
30
|
"at": "2026-11-18T10:31:31.776Z",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "What PMOS does behind the scenes, and what stays yours"
|
|
4
4
|
description: "Every job PMOS runs by itself, what agents apply by themselves with Undo (D106), long-running goals, the team of role agents, the live round, the idle lab, and the PM-only acts."
|
|
5
|
-
timestamp: 2026-11-
|
|
5
|
+
timestamp: 2026-11-18
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# What PMOS does behind the scenes
|
|
@@ -198,10 +198,10 @@ You can ask to see an idea at any moment: alone while you work on an initiative,
|
|
|
198
198
|
2. **The Viewer is one canvas, like a design tool.** The prototype is in the middle, at its own size. Three panels sit around it:
|
|
199
199
|
- **Pages, screens and layers** (left). A page is one format or page of the prototype, for example "One Raffles Place LED". A page has screens: its states, for example "Default" and "Sponsor sold". Layers lists the blocks of the screen shown. Tap a screen to show it, or tap a layer to select it. Press [ to hide or show this panel.
|
|
200
200
|
- **Exact values** (right): the inspector for the selected layer. Set its text, font, size, weight, line height, letter spacing, colour, fill, corner, padding and alignment. The prototype changes at once. PMOS keeps the change with the version, and the next version keeps it. The chat shows one quiet line, for example "You set Temperature to 56px · Bold. Kept as yours." The undo press in the panel clears that layer's changes. Press ] to hide or show the inspector.
|
|
201
|
-
- **Page copy, The flow and Who does what**: one press each in the toolbar, closed by default. One opens at a time, in the inspector's place. Page copy lists every word on the screen: edit a line in place. The flow shows screens as cards, decisions as diamonds and branches to the other scenarios: tap a screen to see it, or a side branch to play that scenario. Who does what
|
|
201
|
+
- **Page copy, The flow and Who does what**: one press each in the toolbar, closed by default. One opens at a time, in the inspector's place. Page copy lists every word on the screen: edit a line in place. The flow shows screens as cards, decisions as diamonds and branches to the other scenarios: tap a screen to see it, or a side branch to play that scenario. Who does what has one column for each role, with the steps going down in order. The role names stay at the top when you scroll. Both diagrams show at the normal text size. A long one scrolls in the panel. Press the arrows at the top of the panel to make it wider. A press with a dot, or a panel that says **Updated**, is what the last version changed.
|
|
202
202
|
- Zoom out, zoom in and fit are in the toolbar. The design opens on the latest version: the toolbar says **Latest · version n**.
|
|
203
203
|
3. **Change it in one sentence.** For example, "make the alert orange". PMOS makes the next version of the prototype and its flow, swimlane and copy, and the chat says what changed, then "Also updated: step 3, the swimlane and the copy". ‹ › in the toolbar walks the versions. On an older version, **Back to latest** returns, and **Continue from version n** makes your next change start from that version.
|
|
204
|
-
4. **Select, then say.** Select (V) is on when the Viewer opens. Tap a block in the prototype, or a layer in the list. It is selected in both places, its exact values show in the inspector, and it goes into the chat box as a chip, for example "Temperature". Your next sentence changes that block. Sliders that the version offers
|
|
204
|
+
4. **Select, then say.** Select (V) is on when the Viewer opens. Tap a block in the prototype, or a layer in the list. It is selected in both places, its exact values show in the inspector, and it goes into the chat box as a chip, for example "Temperature". Your next sentence changes that block. Sliders that the version offers (spacing, corner radius, colour) show in the inspector: under **Page** when no layer is selected, and under **This layer** for the selected one. Nothing shows under the prototype.
|
|
205
205
|
5. **Comment.** Press Comment (C) and tap an element. Write the comment, then send it to PMOS as the next change, or keep it for the team. A kept comment stays pinned, with **Make this change** beside it.
|
|
206
206
|
6. **Draw or attach an image.** Press Draw (D), sketch over the prototype, then attach the sketch. It goes with your next message. An image you attach does the same. PMOS builds from it (its layout, hierarchy and colours) unless your words say otherwise, for example "only the colours".
|
|
207
207
|
7. **Play.** Press Play to run the prototype through a path of the flow. It shows only the prototype, with no design notes. Pick where it plays: on a phone, on a desktop, or at its own size. The flow sits beside it: pick a path, and tap a step to go there. ← and → move a step, and so do the arrows under the prototype. On a screen with taps, tap where the user would tap; a tap that misses shows where to tap. Restart is under the prototype. Stop (Esc) goes back to the design.
|
package/workspace/guide/cli.md
CHANGED
|
@@ -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
|
-
|
|
253
|
-
const
|
|
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
|
|
316
|
-
|
|
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 };
|
package/workspace/lib/lab-cli.js
CHANGED
|
@@ -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
|
-
|
|
198
|
-
const
|
|
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. '
|
|
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
|
-
|
|
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 &&
|
|
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.
|
|
3
|
+
"version": "0.606.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.606.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -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);
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
.pc-sel { margin: 0; display: flex; align-items: center; gap: 6px; font-size: var(--fs-meta); color: var(--cz-ink2); max-width: 300px; }
|
|
94
94
|
.pc-sel b { color: var(--cz-blueink); font-weight: var(--fw-strong); white-space: nowrap; }
|
|
95
95
|
.pc-sel .pc-ib { width: 26px; height: 26px; margin-left: auto; }
|
|
96
|
-
|
|
97
|
-
.pc-
|
|
98
|
-
.pc-
|
|
99
|
-
.pc-
|
|
96
|
+
/* the run's tweaks, in the inspector (Page, or This layer) */
|
|
97
|
+
.pc-rng { display: grid; grid-template-columns: 1fr 44px; align-items: center; gap: 6px; }
|
|
98
|
+
.pc-ir .pc-rng input { height: auto; padding: 0; border: 0; accent-color: var(--cz-blueink); }
|
|
99
|
+
.pc-rng em { font-style: normal; text-align: right; color: var(--cz-ink3); }
|
|
100
100
|
.pc-cdraft { display: flex; flex-direction: column; gap: 6px; max-width: 300px; }
|
|
101
101
|
.pc-cdraft label { font-size: var(--fs-meta); color: var(--cz-ink2); }
|
|
102
102
|
.pc-cdraft textarea { font: inherit; font-size: var(--fs-body); padding: 8px 10px; border-radius: 10px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); resize: vertical; }
|
|
@@ -111,37 +111,45 @@
|
|
|
111
111
|
.pc-star { color: var(--cz-blueink); font-weight: var(--fw-strong); }
|
|
112
112
|
|
|
113
113
|
/* the flow and the swimlane (SVG) */
|
|
114
|
-
|
|
115
|
-
.pc-
|
|
116
|
-
.pc-flow
|
|
114
|
+
/* drawn at their real size, top to bottom; a big one scrolls inside the panel, never shrinks (Wawan 2026-11-18) */
|
|
115
|
+
.pc-svgw { overflow: auto; min-height: 0; flex: 0 1 auto; overscroll-behavior: contain; }
|
|
116
|
+
.pc-flow, .pc-lanes { display: block; max-width: none; color: var(--cz-ink3); font-family: var(--cz-sans); }
|
|
117
|
+
.pc-flow text, .pc-lanes text { font-size: 13px; fill: var(--cz-ink); }
|
|
117
118
|
.pc-sn { cursor: pointer; }
|
|
118
119
|
.pc-sn rect { fill: var(--cz-card); stroke: var(--cz-hair); stroke-width: 1.2; }
|
|
119
120
|
.pc-sn.br rect { stroke: var(--cz-ok); stroke-dasharray: 4 3; }
|
|
120
121
|
.pc-sn.on rect, .pc-sn:hover rect, .pc-sn:focus-visible rect { stroke: var(--cz-blue); stroke-width: 2; }
|
|
121
|
-
.pc-sn .k { font-size:
|
|
122
|
+
.pc-sn .k { font-size: 10px; font-weight: var(--fw-strong); letter-spacing: .06em; fill: var(--cz-ink3); }
|
|
122
123
|
.pc-dn path { fill: var(--cz-bluebg); stroke: var(--cz-blueink); stroke-width: 1.2; }
|
|
123
|
-
.pc-dn text { font-size:
|
|
124
|
+
.pc-dn text { font-size: 12px; }
|
|
124
125
|
.pc-e path { fill: none; stroke: currentColor; stroke-width: 1.3; }
|
|
125
126
|
.pc-e.br path { stroke-dasharray: 4 3; }
|
|
126
127
|
.pc-e .hit { stroke: transparent; stroke-width: 12; stroke-dasharray: none; cursor: pointer; }
|
|
127
128
|
.pc-e[data-pc-scen]:hover path:not(.hit), .pc-e[data-pc-scen]:focus-visible path:not(.hit) { stroke: var(--cz-blue); }
|
|
128
|
-
.pc-e text { font-size:
|
|
129
|
+
.pc-e text { font-size: 11px; fill: var(--cz-ink3); paint-order: stroke; stroke: var(--cz-card); stroke-width: 4px; stroke-linejoin: round; } /* a label is never drawn over a line */
|
|
129
130
|
.pc-ln rect { fill: var(--cz-card); }
|
|
130
131
|
.pc-ln.alt rect { fill: var(--cz-well); }
|
|
131
|
-
.pc-
|
|
132
|
+
.pc-lhd { position: sticky; top: 0; z-index: 1; display: flex; }
|
|
133
|
+
.pc-lhd b { flex: none; box-sizing: border-box; padding: 8px 6px; background: var(--cz-card); border-bottom: 1px solid var(--cz-hair); text-align: center; font-size: var(--fs-meta); line-height: var(--lh-label); font-weight: var(--fw-strong); color: var(--cz-ink2); }
|
|
134
|
+
.pc-lhd b.alt { background: var(--cz-well); }
|
|
135
|
+
.pc-ln text { font-weight: var(--fw-strong); font-size: 12px; fill: var(--cz-ink2); }
|
|
132
136
|
.pc-ar { fill: none; stroke: currentColor; stroke-width: 1.3; }
|
|
133
137
|
.pc-bx rect { fill: var(--cz-bluebg); stroke: transparent; }
|
|
134
138
|
.pc-bx[data-pc-screen] { cursor: pointer; }
|
|
135
139
|
.pc-bx[data-pc-screen]:hover rect, .pc-bx:focus-visible rect { stroke: var(--cz-blue); stroke-width: 1.5; }
|
|
136
140
|
.pc-bx.ch rect { stroke: var(--cz-ok); stroke-width: 1.5; stroke-dasharray: 4 3; }
|
|
137
141
|
.pc-bx circle { fill: var(--cz-blueink); }
|
|
138
|
-
.pc-bx .n { fill: var(--cz-onsolid); font-size:
|
|
142
|
+
.pc-bx .n { fill: var(--cz-onsolid); font-size: 11px; font-weight: var(--fw-strong); }
|
|
139
143
|
.pc-scens { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
140
144
|
.pc-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink2); font: inherit; font-size: var(--fs-meta); cursor: pointer; }
|
|
141
145
|
.pc-chip[aria-pressed="true"] { background: var(--cz-bluebg); color: var(--cz-blueink); border-color: transparent; }
|
|
142
146
|
|
|
143
147
|
/* the page copy: a side panel over the canvas, behind the toolbar's Page copy press (closed by default) */
|
|
144
|
-
.pc-
|
|
148
|
+
.pc-rightw { flex: none; display: flex; min-width: 0; } /* sized by its panel, never by the longest line of copy in it (Wawan 2026-11-18) */
|
|
149
|
+
.pc-side { box-sizing: border-box; width: 420px; max-width: 46vw; padding: 14px; gap: 8px; }
|
|
150
|
+
.pc-side.wide { width: 760px; max-width: 62vw; }
|
|
151
|
+
.pc-side > h3 { flex: none; }
|
|
152
|
+
.pc-side > .pc-copy { flex: none; }
|
|
145
153
|
.pc-side h3 { display: flex; align-items: center; gap: 8px; }
|
|
146
154
|
.pc-side h3 .pc-ib { margin-left: auto; width: 28px; height: 28px; }
|
|
147
155
|
.pc .pc-ib.upd { position: relative; }
|
|
@@ -190,7 +198,8 @@
|
|
|
190
198
|
|
|
191
199
|
@media (max-width: 760px) {
|
|
192
200
|
.pc-dbody { flex-direction: column; }
|
|
193
|
-
.pc-
|
|
201
|
+
.pc-rightw { display: block; }
|
|
202
|
+
.pc-left, .pc-insp, .pc-side, .pc-side.wide { width: 100%; max-width: none; max-height: none; }
|
|
194
203
|
.pc-pmain { flex-direction: column; }
|
|
195
204
|
.pc-pflow { width: 100%; }
|
|
196
205
|
.pc .pc-ib { width: 44px; height: 44px; }
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* page is a data-page, its screens are its states, its layers are the data-el blocks of the screen shown); the inspector on the right
|
|
11
11
|
* (Exact values: text, font, size, weight, line height, spacing, colour, fill, corner, padding, align), saved with the version in
|
|
12
12
|
* edits.json (styles) and kept by the next version; a change says "You set … Kept as yours." once in the chat ('pmos:note').
|
|
13
|
-
* The cards, which update together: the prototype in a phone or desktop frame (
|
|
13
|
+
* The cards, which update together: the prototype in a phone or desktop frame (the comments,
|
|
14
14
|
* the ✦ test-link suggestion); the flow (screens as cards, decisions as diamonds, drawn as SVG from flow.json: a screen shows that moment
|
|
15
15
|
* on the prototype, a branch plays its scenario); the page copy, in its side panel (copy.json, edited in place: the prototype changes as the PM types and
|
|
16
16
|
* the edit is kept with the version, POST /api/lab/edit); who does what (lanes.json as a swimlane with arrows: a step shows its screen).
|
|
@@ -37,19 +37,20 @@ const I = {
|
|
|
37
37
|
restart: 'M4 12a8 8 0 1 0 2.3-5.6L4 9M4 4v5h5', x: 'M6 6l12 12M18 6L6 18', check: 'M5 12l5 5 9-10', send: 'M12 19V5M6 11l6-6 6 6',
|
|
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
|
+
wide: 'M15 4h5v5M9 20H4v-5M20 4l-6 6M4 20l6-6', narrow: 'M14 10h5M14 10V5M10 14H5M10 14v5M14 10l6-6M10 14l-6 6',
|
|
40
41
|
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',
|
|
42
|
+
trash: 'M5 7h14M10 11v6M14 11v6M7 7l1 13h8l1-13M9 7V4h6v3',
|
|
41
43
|
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
44
|
};
|
|
43
45
|
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>`;
|
|
44
46
|
const store = { get: (k) => { try { return localStorage.getItem(k); } catch { return null; } }, set: (k, v) => { try { if (v == null) localStorage.removeItem(k); else localStorage.setItem(k, v); } catch { /* private window */ } } };
|
|
45
47
|
const human = (k) => String(k || '').replace(/[-_.]+/g, ' ').replace(/^./, (c) => c.toUpperCase());
|
|
46
|
-
/** A label in
|
|
47
|
-
function lines(text, x, y, n, dy = 14) {
|
|
48
|
-
const w = String(text || '').split(/\s+/), out =
|
|
48
|
+
/** A label in up to m lines (two by default) of about n characters each (the last one cut with …), as SVG tspans. */
|
|
49
|
+
function lines(text, x, y, n, dy = 14, m = 2) {
|
|
50
|
+
const w = String(text || '').split(/\s+/), out = Array(m).fill('');
|
|
49
51
|
let i = 0;
|
|
50
|
-
for (const word of w) { if (i
|
|
51
|
-
if (out[
|
|
52
|
-
if (out[0].length > n) out[0] = out[0].slice(0, n - 1) + '…';
|
|
52
|
+
for (const word of w) { if (i < m - 1 && out[i] && (out[i] + ' ' + word).length > n) i += 1; out[i] = out[i] ? out[i] + ' ' + word : word; }
|
|
53
|
+
for (let k = 0; k < m; k += 1) if (out[k].length > n) out[k] = out[k].slice(0, n - 1).trimEnd() + '…';
|
|
53
54
|
return out.filter(Boolean).map((t, k) => `<tspan x="${x}" y="${y + k * dy}">${esc(t)}</tspan>`).join('');
|
|
54
55
|
}
|
|
55
56
|
const fire = (name, detail) => { try { window.dispatchEvent(new CustomEvent(name, { detail })); } catch { /* old browser */ } };
|
|
@@ -60,92 +61,99 @@ if (typeof document !== 'undefined' && typeof document.createElement === 'functi
|
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
/* ── layout (PURE) ── */
|
|
63
|
-
|
|
64
|
+
/* Both diagrams are drawn TOP TO BOTTOM at their real size, so they fit a side panel at the normal text size and scroll when long
|
|
65
|
+
* (Wawan 2026-11-18: "who does what so tiny user can't even read it", "the flow too small and still have overlap component"). */
|
|
66
|
+
const SW = 156, SH = 56, DH = 76, GX = 28, PAD = 16, TR = 20, GT = 18, GB = 12, GY = 30, CHX = 14;
|
|
64
67
|
/** The width of a decision diamond: wide enough for its words in two lines inside the shape (2026-11-18: "What does th" was cut). */
|
|
65
|
-
const diaW = (t) => Math.max(
|
|
68
|
+
const diaW = (t) => Math.max(140, Math.min(220, Math.ceil(String(t || '').length / 2) * 7 / 0.55 + 16));
|
|
69
|
+
/** Where a line leaves (bottom) or enters (top) a box at x: on the edge of the shape, a diamond's slanted side included. */
|
|
70
|
+
const portY = (n, x, bottom) => {
|
|
71
|
+
if (n.kind !== 'decision') return bottom ? n.y + n.h : n.y;
|
|
72
|
+
const k = Math.abs(x - (n.x + n.w / 2)) / (n.w / 2), half = (n.h / 2) * (1 - k);
|
|
73
|
+
return n.y + n.h / 2 + (bottom ? half : -half);
|
|
74
|
+
};
|
|
66
75
|
/** PURE. flow → { w, h, nodes: [{ id, kind, title, x, y, w, h, main, chars }], edges: [{ from, to, label, d, lx, ly, main, anchor }] }.
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
76
|
+
* Layers top to bottom (a box one layer below the deepest one that leads to it); the main scenario first in its layer. Every line runs only in the
|
|
77
|
+
* gaps between layers (each line its own track, so no two share a segment and a label sits on its own track) and, when it skips a
|
|
78
|
+
* layer or goes back, in its own channel at the side: forward on the left, back on the right. So a line never runs through a box, and
|
|
79
|
+
* labels never sit on each other (Wawan 2026-11-18: "still have overlap component"). */
|
|
70
80
|
export function flowLayout(flow) {
|
|
71
81
|
const f = flow || {}, nodes = [...(f.screens || []).map((s) => ({ ...s, kind: 'screen' })), ...(f.decisions || []).map((d) => ({ ...d, kind: 'decision' }))];
|
|
72
82
|
if (!nodes.length) return { w: 0, h: 0, nodes: [], edges: [] };
|
|
73
83
|
const by = new Map(nodes.map((n) => [n.id, n])), out = new Map(nodes.map((n) => [n.id, []]));
|
|
74
84
|
for (const e of f.edges || []) if (by.has(e.from) && by.has(e.to)) out.get(e.from).push(e);
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
for (const
|
|
85
|
+
// a line back to a screen already on the way (found walking from the first screen) goes back; the rest go forward, and each box sits one
|
|
86
|
+
// layer below the deepest box that leads to it, so a walk through the screens is one column down and a skip is a side line
|
|
87
|
+
const seen = [], state = new Map(), backE = new Set();
|
|
88
|
+
const walk = (u) => { state.set(u, 1); seen.push(u); for (const e of out.get(u)) { const s2 = state.get(e.to); if (s2 === 1) backE.add(e); else if (!s2) walk(e.to); } state.set(u, 2); };
|
|
89
|
+
walk(nodes[0].id);
|
|
90
|
+
for (const n of nodes) if (!state.has(n.id)) walk(n.id);
|
|
91
|
+
const lay = new Map(seen.map((id) => [id, 0])), indeg = new Map(seen.map((id) => [id, 0]));
|
|
92
|
+
for (const id of seen) for (const e of out.get(id)) if (!backE.has(e)) indeg.set(e.to, indeg.get(e.to) + 1);
|
|
93
|
+
const topo = seen.filter((id) => !indeg.get(id));
|
|
94
|
+
for (let i = 0; i < topo.length; i += 1) for (const e of out.get(topo[i])) if (!backE.has(e)) { lay.set(e.to, Math.max(lay.get(e.to), lay.get(topo[i]) + 1)); indeg.set(e.to, indeg.get(e.to) - 1); if (!indeg.get(e.to)) topo.push(e.to); }
|
|
79
95
|
const steps = new Set(((f.scenarios || [])[0] || { steps: [] }).steps.map((s) => s.screen));
|
|
80
|
-
// the main row: the first scenario's screens and the decisions between them (no scenario: the first node of each column)
|
|
81
96
|
const onMain = new Set();
|
|
82
97
|
if (steps.size) {
|
|
83
98
|
for (const n of nodes) if (steps.has(n.id)) onMain.add(n.id);
|
|
84
|
-
for (const n of nodes) if (n.kind === 'decision' &&
|
|
85
|
-
}
|
|
86
|
-
const rowsUsed = new Map(); // column → next free row
|
|
87
|
-
const taken = new Set();
|
|
88
|
-
for (const n of [...nodes].sort((x, y) => (onMain.has(y.id) ? 1 : 0) - (onMain.has(x.id) ? 1 : 0))) {
|
|
89
|
-
const c = col.get(n.id);
|
|
90
|
-
let r = onMain.has(n.id) || (!steps.size && !taken.has(c + ':0')) ? 0 : Math.max(1, rowsUsed.get(c) || 1);
|
|
91
|
-
while (taken.has(c + ':' + r)) r += 1;
|
|
92
|
-
taken.add(c + ':' + r); rowsUsed.set(c, Math.max(rowsUsed.get(c) || 1, r + 1));
|
|
93
|
-
n.c = c; n.r = r;
|
|
99
|
+
for (const n of nodes) if (n.kind === 'decision' && out.get(n.id).some((e) => steps.has(e.to)) && (f.edges || []).some((e) => e.to === n.id && steps.has(e.from))) onMain.add(n.id);
|
|
94
100
|
}
|
|
95
|
-
for (const n of nodes) { n.w = n.kind === 'decision' ? diaW(n.title) : SW; n.h = n.kind === 'decision' ? DH : SH; }
|
|
96
|
-
const
|
|
97
|
-
for (let
|
|
98
|
-
const
|
|
99
|
-
// the
|
|
101
|
+
for (const n of nodes) { n.l = lay.get(n.id); n.w = n.kind === 'decision' ? diaW(n.title) : SW; n.h = n.kind === 'decision' ? DH : SH; n.main = !steps.size || onMain.has(n.id); }
|
|
102
|
+
const nl = Math.max(...nodes.map((n) => n.l)) + 1, layers = [];
|
|
103
|
+
for (let k = 0; k < nl; k += 1) layers[k] = seen.map((id) => by.get(id)).filter((n) => n.l === k).sort((a, b) => (onMain.has(b.id) ? 1 : 0) - (onMain.has(a.id) ? 1 : 0));
|
|
104
|
+
const lw = layers.map((L) => L.reduce((s, n) => s + n.w, 0) + GX * Math.max(0, L.length - 1)), maxW = Math.max(...lw);
|
|
105
|
+
// the lines: one layer down goes straight across the gap between; anything else takes a channel at the side
|
|
100
106
|
const raw = (f.edges || []).map((e) => ({ e, a: by.get(e.from), b: by.get(e.to) })).filter((x) => x.a && x.b);
|
|
101
|
-
const
|
|
102
|
-
const
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
107
|
+
for (const x of raw) x.kind = x.b.l === x.a.l + 1 ? 'down' : x.b.l > x.a.l ? 'left' : 'right';
|
|
108
|
+
const left = raw.filter((x) => x.kind === 'left'), right = raw.filter((x) => x.kind === 'right');
|
|
109
|
+
const x0 = PAD + (left.length ? left.length * CHX + 10 : 0);
|
|
110
|
+
layers.forEach((L, k) => { let x = x0 + (maxW - lw[k]) / 2; for (const n of L) { n.x = x; x += n.w + GX; } });
|
|
111
|
+
const cxOf = (n) => n.x + n.w / 2;
|
|
112
|
+
left.forEach((x, i) => { x.cx = x0 - 10 - i * CHX; });
|
|
113
|
+
right.forEach((x, i) => { x.cx = x0 + maxW + 10 + i * CHX; });
|
|
114
|
+
// ports: the lines leaving (or entering) one box spread along its edge in the order of where they go (or come from)
|
|
115
|
+
const toward = (x, from) => (x.kind === 'left' ? -1e6 : x.kind === 'right' ? 1e6 + x.cx : cxOf(from ? x.a : x.b));
|
|
116
|
+
for (const n of nodes) {
|
|
117
|
+
const spread = (list, key) => { const span = n.kind === 'decision' ? n.w * 0.4 : n.w * 0.7; list.sort((p, r) => p.o - r.o).forEach((x, i) => { x[key] = cxOf(n) + (list.length > 1 ? -span / 2 + (span * i) / (list.length - 1) : 0); }); };
|
|
118
|
+
spread(raw.filter((x) => x.a === n).map((x) => Object.assign(x, { o: toward(x, false) })), 'x1');
|
|
119
|
+
spread(raw.filter((x) => x.b === n).map((x) => Object.assign(x, { o: toward(x, true) })), 'x2');
|
|
120
|
+
}
|
|
121
|
+
// tracks: gap k is the one above layer k (gap nl is under the last); each line takes one track in each gap it crosses
|
|
122
|
+
const gaps = Array.from({ length: nl + 1 }, () => []);
|
|
123
|
+
for (const x of [...raw].sort((p, r) => p.x1 - r.x1 || p.x2 - r.x2)) { x.g1 = x.a.l + 1; gaps[x.g1].push(x); if (x.kind !== 'down') { x.g2 = x.b.l; gaps[x.g2].push(x); } }
|
|
124
|
+
const gh = gaps.map((g, k) => (g.length ? GT + (g.length - 1) * TR + GB : k === 0 || k === nl ? 0 : GY));
|
|
125
|
+
const lh = layers.map((L) => Math.max(...L.map((n) => n.h)));
|
|
126
|
+
let y = PAD; const gy = [];
|
|
127
|
+
for (let k = 0; k <= nl; k += 1) { gy[k] = y; y += gh[k]; if (k < nl) { for (const n of layers[k]) n.y = y + (lh[k] - n.h) / 2; y += lh[k]; } }
|
|
128
|
+
const track = (x, g) => gy[g] + GT + gaps[g].indexOf(x) * TR;
|
|
129
|
+
const edges = raw.map((x) => {
|
|
130
|
+
const { e, a, b } = x, y1 = portY(a, x.x1, true), y2 = portY(b, x.x2, false), t1 = track(x, x.g1);
|
|
131
|
+
let d;
|
|
132
|
+
if (x.kind === 'down') d = `M${x.x1} ${y1}V${t1}H${x.x2}V${y2 - 2}`;
|
|
133
|
+
else { const t2 = track(x, x.g2); d = `M${x.x1} ${y1}V${t1}H${x.cx}V${t2}H${x.x2}V${y2 - 2}`; }
|
|
134
|
+
// the label sits on the line's first track, beside where it leaves the box, toward where it goes
|
|
135
|
+
const nx = x.kind === 'down' ? x.x2 : x.cx, dir = nx < x.x1 - 1 ? -1 : 1;
|
|
136
|
+
return { from: e.from, to: e.to, label: e.label || '', d, lx: x.x1 + dir * 6, ly: t1 - 5, anchor: dir < 0 ? 'end' : 'start', main: a.main && b.main && x.kind === 'down' };
|
|
130
137
|
});
|
|
131
|
-
const w =
|
|
132
|
-
return { w, h, nodes: nodes.map(({ id, kind, title, x, y, w: nw, h: nh, main: m }) => ({ id, kind, title, x, y, w: nw, h: nh, main: m, chars: kind === 'decision' ? Math.floor((nw * 0.55) /
|
|
138
|
+
const w = (right.length ? x0 + maxW + 10 + right.length * CHX : x0 + maxW) + PAD;
|
|
139
|
+
return { w, h: y + PAD, nodes: nodes.map(({ id, kind, title, x: nx, y: ny, w: nw, h: nh, main: m }) => ({ id, kind, title, x: nx, y: ny, w: nw, h: nh, main: m, chars: kind === 'decision' ? Math.floor((nw * 0.55) / 7) : 22 })), edges };
|
|
133
140
|
}
|
|
134
|
-
const
|
|
135
|
-
/** PURE. lanes → { w, h, lanes: [{ id, name,
|
|
136
|
-
* the order of n; an arrow from each step to the next.
|
|
141
|
+
const LCW = 132, BW = 116, BH = 58, LHH = 0, BG = 22;
|
|
142
|
+
/** PURE. lanes → { w, h, bw, bh, lanes: [{ id, name, x }], boxes: [{ n, title, screen, x, y, lane }], arrows: [{ d }] }: one COLUMN per lane
|
|
143
|
+
* (its name in a header that stays on top while the steps scroll), one row per step in the order of n, going down; an arrow from each step to the next. Narrow enough for a side
|
|
144
|
+
* panel at the normal text size; more lanes scroll sideways. */
|
|
137
145
|
export function lanesLayout(lanes) {
|
|
138
146
|
const L = (lanes && lanes.lanes) || [];
|
|
139
147
|
const steps = [];
|
|
140
148
|
L.forEach((l, i) => { for (const s of l.steps || []) steps.push({ ...s, lane: i }); });
|
|
141
149
|
steps.sort((a, b) => a.n - b.n);
|
|
142
|
-
const boxes = steps.map((s,
|
|
150
|
+
const boxes = steps.map((s, r) => ({ n: s.n, title: s.title, screen: s.screen || '', lane: s.lane, x: s.lane * LCW + (LCW - BW) / 2, y: LHH + 12 + r * (BH + BG) }));
|
|
143
151
|
const arrows = [];
|
|
144
152
|
for (let i = 0; i + 1 < boxes.length; i += 1) {
|
|
145
|
-
const a = boxes[i], b = boxes[i + 1], x1 = a.x + BW, y1 = a.y + BH
|
|
146
|
-
arrows.push({ d: a.lane === b.lane ? `M${x1} ${y1}
|
|
153
|
+
const a = boxes[i], b = boxes[i + 1], x1 = a.x + BW / 2, y1 = a.y + BH, x2 = b.x + BW / 2, y2 = b.y, my = y1 + BG / 2;
|
|
154
|
+
arrows.push({ d: a.lane === b.lane ? `M${x1} ${y1}V${y2 - 2}` : `M${x1} ${y1}V${my}H${x2}V${y2 - 2}` });
|
|
147
155
|
}
|
|
148
|
-
return { w:
|
|
156
|
+
return { w: L.length * LCW, h: LHH + 12 + boxes.length * (BH + BG), bw: BW, bh: BH, lanes: L.map((l, i) => ({ id: l.id, name: l.name, x: i * LCW })), boxes, arrows };
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
/* ── state ── */
|
|
@@ -154,7 +162,7 @@ export function lanesLayout(lanes) {
|
|
|
154
162
|
* presses, closed by default; one shows at a time, in the inspector's place. The device switch is only for Play. */
|
|
155
163
|
const V = { body: null, c: null, at: null, H: null, last: null, mode: 'point', pdev: store.get('pmos.pc.pdev') || 'own', zoom: Number(store.get('pmos.pc.zoom')) || 0,
|
|
156
164
|
sel: null, looks: null, screen: '', frameUrl: '', ready: null, edits: { copy: {}, vars: {}, styles: {} }, pend: null, saveT: null, draft: null, drawing: false, strokes: 0,
|
|
157
|
-
play: null, sig: '', side: null, left: store.get('pmos.pc.left') !== '0', insp: store.get('pmos.pc.insp') !== '0', noteT: null };
|
|
165
|
+
play: null, sig: '', side: null, wide: store.get('pmos.pc.wide') === '1', left: store.get('pmos.pc.left') !== '0', insp: store.get('pmos.pc.insp') !== '0', noteT: null };
|
|
158
166
|
const ARROW = '<marker id="pcArr" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0L10 5L0 10z" fill="currentColor"/></marker>';
|
|
159
167
|
const frameUrl = (c) => (c && c.url ? c.url + '&rt=1' : '');
|
|
160
168
|
const toFrame = (m, f) => { const fr = f || (V.body && V.body.querySelector('.pc-frame iframe')); if (fr && fr.contentWindow) fr.contentWindow.postMessage({ pmos: 1, ...m }, '*'); };
|
|
@@ -181,12 +189,15 @@ function barHtml(c, v) {
|
|
|
181
189
|
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
190
|
: `<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
191
|
+ 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>';
|
|
192
|
+
// delete this version (batch 31 item 9): icon-only, no confirm; the toast's Undo brings it back
|
|
193
|
+
const vname = 'version ' + (c.round || 1) + ((c.columns || []).filter((x) => /^[A-C]$/.test(x.id)).length > 1 ? ' (' + c.key + ')' : '');
|
|
194
|
+
const del = c.file && !c.working ? ib(`data-pc-del="${esc(c.file)}"`, 'Delete ' + vname, I.trash) : '';
|
|
184
195
|
const z = Math.round((V.zoom || 1) * 100), u = c.updated || {};
|
|
185
196
|
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
197
|
+ `<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
198
|
// 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
199
|
+ `<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>`
|
|
200
|
+
+ `${ver}${del}<span class="pc-sp"></span>`
|
|
190
201
|
+ `<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
202
|
+ `${ib('data-pc-play', 'Play the prototype', I.play, 'blue')}</div>`;
|
|
192
203
|
}
|
|
@@ -210,8 +221,6 @@ function progressHtml(c) {
|
|
|
210
221
|
}
|
|
211
222
|
if (typeof document !== 'undefined' && typeof setInterval === 'function') setInterval(() => { for (const el of document.querySelectorAll('[data-pc-clock]')) el.textContent = clock(el.dataset.pcClock); }, 1000);
|
|
212
223
|
function protoCard(c, v, making) {
|
|
213
|
-
const data = v.data || {}, tw = ((data.tweaks && data.tweaks.tweaks) || []).filter((t) => !t.el || (V.sel && t.el === V.sel.el));
|
|
214
|
-
const tweaks = tw.length ? `<div class="pc-tw" aria-label="Tweaks">${tw.map((t) => { const val = parseFloat(V.edits.vars[t.var]) || t.value; return `<label><span>${esc(t.label)}</span><input type="range" min="${t.min}" max="${t.max}" step="${t.step}" value="${val}" data-pc-var="${esc(t.var)}" data-pc-unit="${esc(t.unit)}"><em>${esc(val + t.unit)}</em></label>`; }).join('')}</div>` : '';
|
|
215
224
|
const sel = V.sel && !(V.insp && !V.side) ? `<p class="pc-sel">${SVG(I.point, 14)}<b>${esc(V.sel.label || V.sel.el)}</b> is in the chat box: say the change.${ib('data-pc-unsel', 'Clear the element', I.x)}</p>` : '';
|
|
216
225
|
const cm = (c.comments || []).filter((x) => !x.send);
|
|
217
226
|
const draft = V.draft ? `<div class="pc-cdraft"><label for="pcCm">Comment${V.draft.label ? ' on ' + esc(V.draft.label) : ''}</label><textarea id="pcCm" rows="2" maxlength="500" placeholder="Say what should change"></textarea><span>${ib('data-pc-cm="send"', 'Send to PMOS as the next change', I.send, 'blue')}${ib('data-pc-cm="keep"', 'Keep for the team', I.keep)}${ib('data-pc-cm="x"', 'Cancel', I.x)}</span></div>` : '';
|
|
@@ -219,7 +228,7 @@ function protoCard(c, v, making) {
|
|
|
219
228
|
const sug = suggestion(c);
|
|
220
229
|
const draw = V.mode === 'draw' ? `<canvas class="pc-ink" aria-label="Sketch over the prototype"></canvas><span class="pc-inkacts">${ib('data-pc-ink="attach"', 'Attach the sketch to your next message', I.attach, 'blue')}${ib('data-pc-ink="clear"', 'Clear the sketch', I.x)}</span>` : '';
|
|
221
230
|
const lost = c.notMade ? `<p class="pc-making pc-lost">Version ${c.round} was not made: ${esc(c.notMade)}.${c.fallbackN ? ` This is version ${c.fallbackN}.` : ''} Ask in the chat for it in smaller steps, one screen or format at a time.</p>` : '';
|
|
222
|
-
return { pre: lost + (making ? progressHtml(c) : ''), dev: `<div class="pc-frame" data-pc-frame>${v.url ? '' : '<p class="pc-none">PMOS is making it.</p>'}</div>${draw}`, post: sel +
|
|
231
|
+
return { pre: lost + (making ? progressHtml(c) : ''), dev: `<div class="pc-frame" data-pc-frame>${v.url ? '' : '<p class="pc-none">PMOS is making it.</p>'}</div>${draw}`, post: sel + draft + list + sug };
|
|
223
232
|
}
|
|
224
233
|
function suggestion(c) {
|
|
225
234
|
// the design sprint runs silently: PMOS recommends good practice as ONE ✦ (canvas PbcChat), here: test it with people once it settles
|
|
@@ -228,19 +237,21 @@ function suggestion(c) {
|
|
|
228
237
|
if (N < 3 || c.working || store.get(key)) return '';
|
|
229
238
|
return `<div class="pc-sug"><span class="pc-star" aria-hidden="true">✦</span><p>Version ${c.round} answers the brief. Try it on 3 to 5 people it is for before more polish.</p>${ib(`data-pc-sug="link" data-pc-sugk="${esc(key)}"`, 'Get a test link', I.link, 'blue')}${ib(`data-pc-sug="no" data-pc-sugk="${esc(key)}"`, 'Not now', I.x)}</div>`;
|
|
230
239
|
}
|
|
240
|
+
/** The press that makes the flow or who does what panel wider (or back), so a big diagram shows more at the same text size. */
|
|
241
|
+
const wideIb = () => ib('data-pc-wide', V.wide ? 'Narrower panel' : 'Wider panel', V.wide ? I.narrow : I.wide);
|
|
231
242
|
function flowCard(c, v) {
|
|
232
243
|
if (V.side !== 'flow') return '';
|
|
233
|
-
const close = ib('data-pc-side="flow"', 'Close the flow', I.x);
|
|
244
|
+
const close = wideIb() + ib('data-pc-side="flow"', 'Close the flow', I.x);
|
|
234
245
|
const f = (v.data || {}).flow, st = (c.parts || {}).flow;
|
|
235
|
-
if (!f) return `<section class="pc-card pc-flowc pc-side" aria-label="The flow"><h3>The flow ${close}</h3><p class="pc-none">${esc(st === 'working' ? 'PMOS is drawing it.' : st && st !== 'ok' ? 'Not made this time: ' + st.replace(/^not made: /, '') : 'No flow for this version.')}</p></section>`;
|
|
246
|
+
if (!f) return `<section class="pc-card pc-flowc pc-side${V.wide ? ' wide' : ''}" aria-label="The flow"><h3>The flow ${close}</h3><p class="pc-none">${esc(st === 'working' ? 'PMOS is drawing it.' : st && st !== 'ok' ? 'Not made this time: ' + st.replace(/^not made: /, '') : 'No flow for this version.')}</p></section>`;
|
|
236
247
|
const L = flowLayout(f), scen = f.scenarios || [];
|
|
237
248
|
const branchOf = (to) => { for (let i = 1; i < scen.length; i += 1) if (scen[i].steps.some((s) => s.screen === to)) return scen[i].id; return ''; };
|
|
238
249
|
const nodes = L.nodes.map((n) => n.kind === 'decision'
|
|
239
|
-
? `<g class="pc-dn"><path d="M${n.x + n.w / 2} ${n.y}L${n.x + n.w} ${n.y + n.h / 2}L${n.x + n.w / 2} ${n.y + n.h}L${n.x} ${n.y + n.h / 2}Z"/><text text-anchor="middle">${lines(n.title, n.x + n.w / 2, n.y + n.h / 2 + (String(n.title).length > n.chars ? -
|
|
240
|
-
: `<g class="pc-sn${n.main ? '' : ' br'}${V.screen === n.id ? ' on' : ''}" data-pc-screen="${esc(n.id)}" role="button" tabindex="0" aria-label="${esc('Show ' + n.title + ' on the prototype')}"><rect x="${n.x}" y="${n.y}" width="${n.w}" height="${n.h}" rx="8"/><text x="${n.x + 10}" y="${n.y +
|
|
250
|
+
? `<g class="pc-dn"><path d="M${n.x + n.w / 2} ${n.y}L${n.x + n.w} ${n.y + n.h / 2}L${n.x + n.w / 2} ${n.y + n.h}L${n.x} ${n.y + n.h / 2}Z"/><text text-anchor="middle">${lines(n.title, n.x + n.w / 2, n.y + n.h / 2 + (String(n.title).length > n.chars ? -3 : 4), n.chars, 14)}</text></g>`
|
|
251
|
+
: `<g class="pc-sn${n.main ? '' : ' br'}${V.screen === n.id ? ' on' : ''}" data-pc-screen="${esc(n.id)}" role="button" tabindex="0" aria-label="${esc('Show ' + n.title + ' on the prototype')}"><rect x="${n.x}" y="${n.y}" width="${n.w}" height="${n.h}" rx="8"/><text x="${n.x + 10}" y="${n.y + 16}" class="k">SCREEN</text><text>${lines(n.title, n.x + 10, n.y + 33, n.chars, 15)}</text></g>`).join('');
|
|
241
252
|
const edges = L.edges.map((e) => { const sc = e.main ? '' : branchOf(e.to); return `<g class="pc-e${e.main ? '' : ' br'}"${sc ? ` data-pc-scen="${esc(sc)}" role="button" tabindex="0" aria-label="${esc('Play ' + (scen.find((x) => x.id === sc) || {}).name)}"` : ''}><path d="${e.d}" marker-end="url(#pcArr)"/>${sc ? `<path class="hit" d="${e.d}"/>` : ''}${e.label ? `<text x="${e.lx}" y="${e.ly}" text-anchor="${e.anchor || 'middle'}">${esc(e.label)}</text>` : ''}</g>`; }).join('');
|
|
242
253
|
const chips = scen.length ? `<div class="pc-scens">${scen.map((s, i) => `<button type="button" class="pc-chip" data-pc-scen="${esc(s.id)}" title="${esc(s.description || '')}">${SVG(I.play, 12)}${esc(i === 0 ? s.name : s.name)}</button>`).join('')}</div>` : '';
|
|
243
|
-
return `<section class="pc-card pc-flowc pc-side" aria-label="The flow"><h3>The flow ${upd(c, 'flow')}${close}</h3><div class="pc-svgw"><svg class="pc-flow" width="
|
|
254
|
+
return `<section class="pc-card pc-flowc pc-side${V.wide ? ' wide' : ''}" aria-label="The flow"><h3>The flow ${upd(c, 'flow')}${close}</h3><div class="pc-svgw"><svg class="pc-flow" width="${L.w}" height="${L.h}" viewBox="0 0 ${L.w} ${L.h}"><defs>${ARROW}</defs>${edges}${nodes}</svg></div>`
|
|
244
255
|
+ `<p class="pc-hint">Tap a screen to see it on the prototype. Tap a side branch to play that scenario.</p>${chips}</section>`;
|
|
245
256
|
}
|
|
246
257
|
function copyCard(c, v) {
|
|
@@ -254,14 +265,15 @@ function copyCard(c, v) {
|
|
|
254
265
|
}
|
|
255
266
|
function lanesCard(c, v) {
|
|
256
267
|
if (V.side !== 'lanes') return '';
|
|
257
|
-
const close = ib('data-pc-side="lanes"', 'Close who does what', I.x);
|
|
268
|
+
const close = wideIb() + ib('data-pc-side="lanes"', 'Close who does what', I.x);
|
|
258
269
|
const l = (v.data || {}).lanes, st = (c.parts || {}).lanes;
|
|
259
|
-
if (!l) return `<section class="pc-card pc-lanesc pc-side" aria-label="Who does what"><h3>Who does what ${close}</h3><p class="pc-none">${esc(st === 'working' ? 'PMOS is drawing it.' : st && st !== 'ok' ? 'Not made this time: ' + st.replace(/^not made: /, '') : 'No swimlane for this version.')}</p></section>`;
|
|
270
|
+
if (!l) return `<section class="pc-card pc-lanesc pc-side${V.wide ? ' wide' : ''}" aria-label="Who does what"><h3>Who does what ${close}</h3><p class="pc-none">${esc(st === 'working' ? 'PMOS is drawing it.' : st && st !== 'ok' ? 'Not made this time: ' + st.replace(/^not made: /, '') : 'No swimlane for this version.')}</p></section>`;
|
|
260
271
|
const L = lanesLayout(l), chg = new Set((c.updated && c.updated.steps) || []);
|
|
261
|
-
const lanes = L.lanes.map((x, i) => `<g class="pc-ln${i % 2 ? ' alt' : ''}"><rect x="
|
|
262
|
-
const
|
|
272
|
+
const lanes = L.lanes.map((x, i) => `<g class="pc-ln${i % 2 ? ' alt' : ''}"><rect x="${x.x}" y="0" width="${LCW}" height="${L.h}"/></g>`).join('');
|
|
273
|
+
const heads = `<div class="pc-lhd" style="width:${L.w}px">${L.lanes.map((x, i) => `<b class="${i % 2 ? 'alt' : ''}" style="width:${LCW}px">${esc(x.name)}</b>`).join('')}</div>`;
|
|
274
|
+
const boxes = L.boxes.map((b) => `<g class="pc-bx${chg.has(b.n) ? ' ch' : ''}${b.screen ? '' : ' ns'}"${b.screen ? ` data-pc-screen="${esc(b.screen)}" role="button" tabindex="0" aria-label="${esc('Show step ' + b.n + ' on the prototype')}"` : ''}><rect x="${b.x}" y="${b.y}" width="${L.bw}" height="${L.bh}" rx="8"/><text text-anchor="middle">${lines(b.title, b.x + L.bw / 2, b.y + (b.title.length > 30 ? 18 : b.title.length > 15 ? 25 : 33), 15, 15, 3)}</text><circle cx="${b.x}" cy="${b.y}" r="9"/><text class="n" x="${b.x}" y="${b.y + 3.5}" text-anchor="middle">${b.n}</text></g>`).join('');
|
|
263
275
|
const arrows = L.arrows.map((a) => `<path class="pc-ar" d="${a.d}" marker-end="url(#pcArr)"/>`).join('');
|
|
264
|
-
return `<section class="pc-card pc-lanesc pc-side" aria-label="Who does what"><h3>Who does what ${upd(c, 'lanes')}${close}</h3><div class="pc-svgw"
|
|
276
|
+
return `<section class="pc-card pc-lanesc pc-side${V.wide ? ' wide' : ''}" aria-label="Who does what"><h3>Who does what ${upd(c, 'lanes')}${close}</h3><div class="pc-svgw">${heads}<svg class="pc-lanes" width="${L.w}" height="${L.h}" viewBox="0 0 ${L.w} ${L.h}"><defs>${ARROW}</defs>${lanes}${arrows}${boxes}</svg></div><p class="pc-hint">Tap a step to see it on the prototype.</p></section>`;
|
|
265
277
|
}
|
|
266
278
|
|
|
267
279
|
|
|
@@ -294,10 +306,18 @@ export function styleWords(ps) {
|
|
|
294
306
|
const W = Object.fromEntries(WEIGHTS);
|
|
295
307
|
return Object.entries(ps || {}).map(([k, v]) => (k === 'weight' ? W[v] || v : k === 'size' || k === 'color' ? v : k + ' ' + v)).join(' · ');
|
|
296
308
|
}
|
|
297
|
-
|
|
309
|
+
/** The run's tweaks (tweaks.json: a CSS variable with a range) as inspector rows: the page's with no layer selected, a layer's with it.
|
|
310
|
+
* They sit in the inspector, not under the prototype (Wawan 2026-11-18: the Spacing slider under the canvas, "remove this things"). */
|
|
311
|
+
function tweakRows(v) {
|
|
312
|
+
const tw = (((v && v.data) || {}).tweaks || {}).tweaks || [], el = V.sel ? V.sel.el : '';
|
|
313
|
+
const mine = tw.filter((t) => (el ? t.el === el : !t.el));
|
|
314
|
+
if (!mine.length) return '';
|
|
315
|
+
return `<div class="pc-isec pc-tw"><b>${el ? 'This layer' : 'Page'}</b>${mine.map((t) => { const val = parseFloat(V.edits.vars[t.var]) || t.value; return `<label class="pc-ir"><span>${esc(t.label)}</span><span class="pc-rng"><input type="range" min="${t.min}" max="${t.max}" step="${t.step || 1}" value="${val}" data-pc-var="${esc(t.var)}" data-pc-unit="${esc(t.unit || '')}" aria-label="${esc(t.label)}"><em>${esc(val + (t.unit || ''))}</em></span></label>`; }).join('')}</div>`;
|
|
316
|
+
}
|
|
317
|
+
function inspHtml(v) {
|
|
298
318
|
if (V.side || !V.insp) return '';
|
|
299
319
|
const hide = ib('data-pc-insp', 'Hide the inspector', I.right);
|
|
300
|
-
if (!V.sel) return `<aside class="pc-insp" aria-label="Exact values"><div class="pc-lh"><span>Exact values</span>${hide}</div><p class="pc-hint">Select a layer on the prototype, or in Layers, to set its exact values. For anything else, say it in the chat.</p
|
|
320
|
+
if (!V.sel) return `<aside class="pc-insp" aria-label="Exact values"><div class="pc-lh"><span>Exact values</span>${hide}</div><p class="pc-hint">Select a layer on the prototype, or in Layers, to set its exact values. For anything else, say it in the chat.</p>${tweakRows(v)}</aside>`;
|
|
301
321
|
const el = V.sel.el, mine = V.edits.styles[el] || {}, lk = V.looks || {}, val = (k, d = '') => (k in mine ? mine[k] : k in lk ? lk[k] : d);
|
|
302
322
|
const num = (v) => String(parseFloat(v) || 0), colr = (v) => (/^#[0-9a-f]{6}$/i.test(v) ? v : lk.fillPick || '');
|
|
303
323
|
const id = (k) => 'pcS-' + k;
|
|
@@ -317,10 +337,11 @@ function inspHtml() {
|
|
|
317
337
|
+ `${fld('corner', 'Corner', nIn('corner', 'px', '1', '0', '200'))}`
|
|
318
338
|
+ `<div class="pc-ir"><span>Padding</span><span class="pc-two">${nIn('padding', 'px', '1', '0', '200', '0')}${nIn('padding', 'px', '1', '0', '200', '1')}</span></div>`
|
|
319
339
|
+ `${fld('align', 'Align', sel('align', [['left', 'Left'], ['center', 'Centre'], ['right', 'Right']], val('align', 'left')))}</div>`
|
|
340
|
+
+ tweakRows(v)
|
|
320
341
|
+ `<p class="pc-ifoot">${changed ? `Saved with version ${esc((V.v && V.v.round) || (V.c && V.c.round) || 1)}. The next version keeps it.` : 'Your changes are saved with this version.'}${changed ? ib(`data-pc-unstyle="${esc(el)}"`, 'Undo this layer\'s changes', I.undo) : ''}</p>`
|
|
321
342
|
+ '</aside>';
|
|
322
343
|
}
|
|
323
|
-
function rightHtml(c, v) { return copyCard(c, v) + flowCard(c, v) + lanesCard(c, v) + inspHtml(); }
|
|
344
|
+
function rightHtml(c, v) { return copyCard(c, v) + flowCard(c, v) + lanesCard(c, v) + inspHtml(v); }
|
|
324
345
|
|
|
325
346
|
/* ── draw ── */
|
|
326
347
|
/** Draw or update the canvas. body: the Viewer's body; c: GET /api/lab/compare's compare (live); o: { at, H } */
|
|
@@ -336,7 +357,7 @@ export function draw(body, c, o = {}) {
|
|
|
336
357
|
if (!root) { body.innerHTML = '<div class="pc"></div>'; root = body.querySelector('.pc'); wire(root); }
|
|
337
358
|
V.body = body;
|
|
338
359
|
// keep the frame (and what the PM typed) while the canvas reads again every 2 seconds
|
|
339
|
-
const sig = JSON.stringify([c.id, c.key, c.round, c.file, v.file, c.working, c.progress, c.notMade, c.updated, c.parts, (c.comments || []).length, V.mode, V.sel && V.sel.el, V.looks, !!V.ready, V.screen, V.left, V.insp, V.side, !!V.draft, (c.history || []).length, c.state]);
|
|
360
|
+
const sig = JSON.stringify([c.id, c.key, c.round, c.file, v.file, c.working, c.progress, c.notMade, c.updated, c.parts, (c.comments || []).length, V.mode, V.sel && V.sel.el, V.looks, !!V.ready, V.screen, V.left, V.insp, V.side, V.wide, !!V.draft, (c.history || []).length, c.state]);
|
|
340
361
|
const focus = document.activeElement && root.contains(document.activeElement) && document.activeElement.matches('[data-pc-copy],textarea,input,select');
|
|
341
362
|
if (sig === V.sig && root.firstChild) return;
|
|
342
363
|
if (focus && prevFile === v.file) return; // the PM is typing in this version: draw on a later read
|
|
@@ -419,6 +440,7 @@ function wire(root) {
|
|
|
419
440
|
const d = b.dataset;
|
|
420
441
|
if (d.pcMode) { setMode(V.mode === d.pcMode ? 'view' : d.pcMode); return; }
|
|
421
442
|
if (d.pcSide) { V.side = V.side === d.pcSide ? null : d.pcSide; V.sig = ''; draw(V.body, V.c); return; }
|
|
443
|
+
if ('pcWide' in d) { V.wide = !V.wide; store.set('pmos.pc.wide', V.wide ? '1' : null); V.sig = ''; draw(V.body, V.c); return; }
|
|
422
444
|
if ('pcLeft' in d) { panel('left'); return; }
|
|
423
445
|
if ('pcInsp' in d) { panel('insp'); return; }
|
|
424
446
|
if (d.pcPage) { const L = layersOf(V.ready, V.screen), first = ((V.ready && V.ready.screens) || []).find((x) => x.page === d.pcPage); if (first && first.id !== L.screen) { V.screen = first.id; toFrame({ t: 'screen', id: first.id }); } return; }
|
|
@@ -440,6 +462,7 @@ function wire(root) {
|
|
|
440
462
|
if (d.pcSug) { if (d.pcSug === 'link') testLink(); store.set(d.pcSugk, '1'); V.sig = ''; draw(V.body, V.c); return; }
|
|
441
463
|
if (d.pcInk) { if (d.pcInk === 'clear') clearInk(); else attachInk(); return; }
|
|
442
464
|
if (d.pcTray) { tray(d.pcTray); return; }
|
|
465
|
+
if (d.pcDel) { delVersion(d.pcDel); return; }
|
|
443
466
|
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
467
|
});
|
|
445
468
|
// a number or a list takes effect when it is changed (an arrow press, Enter, leaving the field), not on every key
|
|
@@ -540,6 +563,23 @@ async function tray(a) {
|
|
|
540
563
|
if (V.H && V.H.load) V.H.load();
|
|
541
564
|
}
|
|
542
565
|
|
|
566
|
+
/** Delete the version shown (POST /api/lab/delete): the Viewer opens the prototype now, or the newest version left, or closes. Undo in
|
|
567
|
+
* the toast brings it back (POST /api/lab/restore) and opens it again. */
|
|
568
|
+
async function delVersion(file) {
|
|
569
|
+
const at = V.at || {}, c = V.c; if (!c || !file) return;
|
|
570
|
+
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(); };
|
|
571
|
+
const r = await pmPost('/api/lab/delete', { ws: at.ws, ini: c.ini, file }).catch(() => null);
|
|
572
|
+
if (!r || r.ok === false) { say((r && r.error) || 'Nothing was deleted.'); return; }
|
|
573
|
+
say(r.said, async () => {
|
|
574
|
+
const u = await pmPost('/api/lab/restore', { ws: at.ws, batch: r.batch }).catch(() => null);
|
|
575
|
+
if (!u || u.ok === false) { say((u && u.error) || 'It did not come back.'); return; }
|
|
576
|
+
if (V.H && V.H.reload) V.H.reload();
|
|
577
|
+
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);
|
|
578
|
+
});
|
|
579
|
+
if (V.H && V.H.reload) V.H.reload();
|
|
580
|
+
go(r.next);
|
|
581
|
+
}
|
|
582
|
+
|
|
543
583
|
/* ── Draw: a sketch goes with the next message as the reference ── */
|
|
544
584
|
function ink(root) {
|
|
545
585
|
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
|
+
}
|