create-pmos 0.836.0 → 0.837.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 +51 -17
- 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 +50 -2
- package/workspace/guide/cli.md +18 -0
- package/workspace/guide/layout.md +5 -1
- package/workspace/lib/built-vs-design-http.js +81 -0
- package/workspace/lib/built-vs-design.js +454 -0
- package/workspace/lib/deps-cli.js +47 -2
- package/workspace/lib/features.json +1 -0
- package/workspace/lib/needs-providers.js +1 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/prefs-sync.js +1 -0
- package/workspace/lib/review-cli.js +6 -0
- package/workspace/lib/routes-pop-work.js +4 -1
- package/workspace/lib/routes-team-waits.js +39 -2
- package/workspace/lib/team-slips.js +160 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/ask-here-ctx.js +20 -2
- package/workspace/public/pm/ask-here.css +6 -1
- package/workspace/public/pm/ask-here.js +38 -25
- package/workspace/public/pm/bd-backlog.js +34 -5
- package/workspace/public/pm/built-vs-design.css +16 -0
- package/workspace/public/pm/built-vs-design.js +95 -0
- package/workspace/public/pm/cozy-events-view.js +1 -1
- package/workspace/public/pm/cozy-home.css +10 -0
- package/workspace/public/pm/cozy-pop-work.js +6 -4
- package/workspace/public/pm/cozy-today-view.js +4 -1
- package/workspace/public/pm/goals-ds.js +3 -2
- package/workspace/public/pm/home-chat.js +19 -3
- package/workspace/public/pm/ini-tasks.js +2 -2
- package/workspace/public/pm/page-chat.js +2 -1
- package/workspace/public/pm/team-slips.js +48 -0
- package/workspace/test-lists/built-vs-design.json +9 -0
- package/workspace/test-lists/team-slips.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.837.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,54 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.837.0",
|
|
38
|
+
"at": "2026-11-25T16:11:10.474Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 2010,
|
|
43
|
+
"t": "Other teams' slips before they hit you (job #1912, A15)",
|
|
44
|
+
"s": "Other teams' slips before they hit you (job #1912, A15)",
|
|
45
|
+
"k": "new",
|
|
46
|
+
"h": "Other teams' slips before they hit you (job #1912, A15)",
|
|
47
|
+
"try": {
|
|
48
|
+
"steps": [
|
|
49
|
+
"Open Work",
|
|
50
|
+
"Press the Dependencies tab",
|
|
51
|
+
"In Upstream, press ✦ on a slip"
|
|
52
|
+
],
|
|
53
|
+
"see": "Upstream appears above Waiting on other teams only when a team your work waits on will likely slip: one row per slip with their likely new date and what of yours it hits, and 'Watching n boards your…",
|
|
54
|
+
"open": "/premium-board.html?work=deps"
|
|
55
|
+
},
|
|
56
|
+
"i": "team-slips"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"n": 2004,
|
|
60
|
+
"t": "Ask card — done-test asserts, Wawan's feedback (hide ✦, smaller text, chat text size, drag)",
|
|
61
|
+
"s": "Ask card — done-test asserts, Wawan's feedback (hide ✦, smaller text, chat text size, drag)",
|
|
62
|
+
"k": "fix",
|
|
63
|
+
"i": "ask-anywhere"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"n": 1956,
|
|
67
|
+
"t": "The built screen beside its design, each difference circled (job #1903, A380)",
|
|
68
|
+
"s": "The built screen beside its design, each difference circled (job #1903, A380)",
|
|
69
|
+
"k": "new",
|
|
70
|
+
"h": "The built screen beside its design, each difference circled (job #1903, A380)",
|
|
71
|
+
"try": {
|
|
72
|
+
"steps": [
|
|
73
|
+
"Open Work and open an initiative whose product repository has a design and a screenshot of one screen in screens/<initiative id>/…",
|
|
74
|
+
"Read its Review block: PMOS compared them by itself, the design and the built screen side by side, each difference circled and numbered",
|
|
75
|
+
"Press ✓ to accept it, or press the send-back icon on a numbered difference to make it a fix task (the chat or pmos review list also shows…"
|
|
76
|
+
],
|
|
77
|
+
"see": "The built screen sits beside its design. Only the parts that differ are circled and numbered, with a short line for each under it. ✓ closes the review with Undo; sending a circle back adds a task…",
|
|
78
|
+
"open": "/premium-board.html"
|
|
79
|
+
},
|
|
80
|
+
"i": "built-vs-design"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
36
84
|
{
|
|
37
85
|
"v": "0.836.0",
|
|
38
86
|
"at": "2026-11-25T15:53:32.838Z",
|
|
@@ -56,6 +104,7 @@
|
|
|
56
104
|
"t": "First hour for a new engineer on Work (A55)",
|
|
57
105
|
"s": "First hour for a new engineer on Work (A55)",
|
|
58
106
|
"k": "new",
|
|
107
|
+
"i": "first-hour",
|
|
59
108
|
"h": "First hour for a new engineer on Work (A55)",
|
|
60
109
|
"try": {
|
|
61
110
|
"steps": [
|
|
@@ -65,8 +114,7 @@
|
|
|
65
114
|
],
|
|
66
115
|
"see": "Up to four steps from your own records: the product from its strategy lines, the current bets, a real first task in a tested part of the code map, and who changed those parts last. A step marks done…",
|
|
67
116
|
"open": "/premium-board.html"
|
|
68
|
-
}
|
|
69
|
-
"i": "first-hour"
|
|
117
|
+
}
|
|
70
118
|
}
|
|
71
119
|
]
|
|
72
120
|
},
|
|
@@ -996,20 +1044,6 @@
|
|
|
996
1044
|
}
|
|
997
1045
|
}
|
|
998
1046
|
]
|
|
999
|
-
},
|
|
1000
|
-
{
|
|
1001
|
-
"v": "0.810.0",
|
|
1002
|
-
"at": "2026-11-25T05:54:34.966Z",
|
|
1003
|
-
"f": 4,
|
|
1004
|
-
"prs": [
|
|
1005
|
-
{
|
|
1006
|
-
"n": 1853,
|
|
1007
|
-
"t": "Try-it answers count as outcome evidence (job #1837, A487)",
|
|
1008
|
-
"s": "Try-it answers count as outcome evidence (job #1837, A487)",
|
|
1009
|
-
"k": "new",
|
|
1010
|
-
"i": "try-answers-as-evidence"
|
|
1011
|
-
}
|
|
1012
|
-
]
|
|
1013
1047
|
}
|
|
1014
1048
|
]
|
|
1015
1049
|
}
|
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-25T16:11:06Z"}
|
|
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-25T16:11:06Z"}
|
|
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-25T16:11:06Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,52 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.837.0",
|
|
4
|
+
"at": "2026-11-25T16:11:10.474Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 2010,
|
|
9
|
+
"t": "Other teams' slips before they hit you (job #1912, A15)",
|
|
10
|
+
"s": "Other teams' slips before they hit you (job #1912, A15)",
|
|
11
|
+
"k": "new",
|
|
12
|
+
"h": "Other teams' slips before they hit you (job #1912, A15)",
|
|
13
|
+
"try": {
|
|
14
|
+
"steps": [
|
|
15
|
+
"Open Work",
|
|
16
|
+
"Press the Dependencies tab",
|
|
17
|
+
"In Upstream, press ✦ on a slip"
|
|
18
|
+
],
|
|
19
|
+
"see": "Upstream appears above Waiting on other teams only when a team your work waits on will likely slip: one row per slip with their likely new date and what of yours it hits, and 'Watching n boards your…",
|
|
20
|
+
"open": "/premium-board.html?work=deps"
|
|
21
|
+
},
|
|
22
|
+
"i": "team-slips"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"n": 2004,
|
|
26
|
+
"t": "Ask card — done-test asserts, Wawan's feedback (hide ✦, smaller text, chat text size, drag)",
|
|
27
|
+
"s": "Ask card — done-test asserts, Wawan's feedback (hide ✦, smaller text, chat text size, drag)",
|
|
28
|
+
"k": "fix",
|
|
29
|
+
"i": "ask-anywhere"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"n": 1956,
|
|
33
|
+
"t": "The built screen beside its design, each difference circled (job #1903, A380)",
|
|
34
|
+
"s": "The built screen beside its design, each difference circled (job #1903, A380)",
|
|
35
|
+
"k": "new",
|
|
36
|
+
"h": "The built screen beside its design, each difference circled (job #1903, A380)",
|
|
37
|
+
"try": {
|
|
38
|
+
"steps": [
|
|
39
|
+
"Open Work and open an initiative whose product repository has a design and a screenshot of one screen in screens/<initiative id>/…",
|
|
40
|
+
"Read its Review block: PMOS compared them by itself, the design and the built screen side by side, each difference circled and numbered",
|
|
41
|
+
"Press ✓ to accept it, or press the send-back icon on a numbered difference to make it a fix task (the chat or pmos review list also shows…"
|
|
42
|
+
],
|
|
43
|
+
"see": "The built screen sits beside its design. Only the parts that differ are circled and numbered, with a short line for each under it. ✓ closes the review with Undo; sending a circle back adds a task…",
|
|
44
|
+
"open": "/premium-board.html"
|
|
45
|
+
},
|
|
46
|
+
"i": "built-vs-design"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
2
50
|
{
|
|
3
51
|
"v": "0.836.0",
|
|
4
52
|
"at": "2026-11-25T15:53:32.838Z",
|
|
@@ -22,6 +70,7 @@
|
|
|
22
70
|
"t": "First hour for a new engineer on Work (A55)",
|
|
23
71
|
"s": "First hour for a new engineer on Work (A55)",
|
|
24
72
|
"k": "new",
|
|
73
|
+
"i": "first-hour",
|
|
25
74
|
"h": "First hour for a new engineer on Work (A55)",
|
|
26
75
|
"try": {
|
|
27
76
|
"steps": [
|
|
@@ -31,8 +80,7 @@
|
|
|
31
80
|
],
|
|
32
81
|
"see": "Up to four steps from your own records: the product from its strategy lines, the current bets, a real first task in a tested part of the code map, and who changed those parts last. A step marks done…",
|
|
33
82
|
"open": "/premium-board.html"
|
|
34
|
-
}
|
|
35
|
-
"i": "first-hour"
|
|
83
|
+
}
|
|
36
84
|
}
|
|
37
85
|
]
|
|
38
86
|
},
|
package/workspace/guide/cli.md
CHANGED
|
@@ -438,6 +438,18 @@ Show where the team is short before you ask for headcount. Run it in the product
|
|
|
438
438
|
- PMOS never writes over a brief. It calls no model and sends nothing. Edit the brief and share it yourself.
|
|
439
439
|
- `pmos hire count [--days 7]` prints how many briefs were drafted in the last days. Its last line is the number.
|
|
440
440
|
|
|
441
|
+
### pmos review: a built screen beside its design
|
|
442
|
+
|
|
443
|
+
Check a built screen against the design it came from by looking, not by flipping between two files. You do not need to run anything: put the design and a screenshot of the same screen in the product's repository as `screens/<initiative>/<screen>.design.png` and `<screen>.built.png` (a build or a design export can drop them there), and PMOS compares them by itself when the initiative opens on Work, and again when either file changes. The commands below do the same by hand. Run them in the product's repository, or pass `--root <dir>`. Both files must be PNG.
|
|
444
|
+
|
|
445
|
+
- `pmos review shots <initiative> --design <design.png> --built <built.png> [--screen <name>]` lays the two side by side and circles each part that differs, numbered top to bottom, with where it is and how big ("Differs near the top right, 200 × 60 px"). Parts that match get no mark. A design made at 2x compares with a 1x screen. Both files are copied into the product's state folder, so the review keeps showing what was compared. A newer compare of the same screen replaces the older one. The initiative's **Review** block on Work shows it.
|
|
446
|
+
- `pmos review list [<initiative>] [--all]` lists the open reviews and their numbered differences; `--all` adds the accepted ones. With an initiative, it first compares the screens in `screens/<initiative>/` that changed, as the Work popup does.
|
|
447
|
+
- `pmos review note <initiative> <n> "<words>"` names difference n better, for example "button 8px lower" or "empty state missing".
|
|
448
|
+
- `pmos review accept <initiative> [--undo]` accepts the built screen and closes the review; `--undo` opens it again.
|
|
449
|
+
- `pmos review fix <initiative> <n> [--undo]` sends difference n back: the task "Fix: <its words>" is added to the initiative, the same as Add a task on the page. `--undo` takes the task away and opens the circle again.
|
|
450
|
+
- `pmos review count [--days 7]` prints how many reviews were decided (accepted, or a difference sent back) in the last days. Its last line is the number.
|
|
451
|
+
- `--screen <name>` picks one screen when an initiative has several. Every command takes `--json`. PMOS calls no model and sends nothing.
|
|
452
|
+
|
|
441
453
|
### pmos layouts: three layouts for a new screen, pick one
|
|
442
454
|
|
|
443
455
|
When an initiative adds a new screen, page or view, its Work popup shows three layouts of the same parts under the stages: **A List first**, **B Summary first** and **C Action first**, drawn with grey bars in place of data. One ✦ line recommends one and says why. Press ✓ under the one you want. It is kept on the initiative as the layout to build, the other two stay beside it, and **Undo** takes it back. PMOS finds a new screen from the record's own words: a making word (new, add, build, design, create, introduce) and, within three words, a screen word (screen, page, view, dashboard, form, popup, panel, tab, layout), in the title or the first paragraph. A done or closed initiative shows none. Run the commands in the product's repository, or pass `--root <dir>`.
|
|
@@ -618,6 +630,12 @@ Work › Dependencies lists every wait on another team, oldest first, with the d
|
|
|
618
630
|
- `pmos deps wait --team "<team>" --what "<what>" --ini <id> --since <YYYY-MM-DD>` adds a wait. `--who "<name>"` and `--email <address>` name the person Chase writes to. From a Jira link, pass `--key <KEY-1>`: one open wait per key. `--sprint "<name>" --sprint-end <YYYY-MM-DD>` names the sprint it holds up.
|
|
619
631
|
- `pmos deps done <wait id>` ends a wait. `pmos deps undo <wait id>` opens it again.
|
|
620
632
|
|
|
633
|
+
Upstream, above the waits, shows other teams' slips before they hit you. PMOS watches only the boards your open waits are on (the Jira keys of open waits). When a ticket's likely date moves past its due date, that is a slip: one row with their likely new date and what of yours it hits, and one row on Today. The ✦ move shifts your date (it opens the initiative, so its owner moves the date) when the slip lands on or past your date, else it chases them with a draft in your own mail app. The row goes once you act or wave it off; a later likely date warns again. No slip, no row.
|
|
634
|
+
|
|
635
|
+
- `pmos deps slips` lists the slips and how many boards PMOS watches. `--json` gives the same rows the page reads.
|
|
636
|
+
- `pmos deps slip --key <KEY-1> --theirs <YYYY-MM-DD> --likely <YYYY-MM-DD>` records one reading of a ticket your work waits on. `--yours <YYYY-MM-DD>` and `--yours-what "<what>"` name your date it hits; `--from "<board>"` names their board. The tracker read or the chat runs it.
|
|
637
|
+
- `pmos deps slip-done <KEY-1> --how shift|chase|skip` says you acted on the slip. `pmos deps slip-undo <KEY-1>` brings the row back.
|
|
638
|
+
|
|
621
639
|
### pmos quiet: the weekly sweep of quiet work
|
|
622
640
|
|
|
623
641
|
Once a week Today shows how many initiatives had no change in 30 days or more. The chat answers the same list from a terminal.
|
|
@@ -201,6 +201,7 @@ Under it, two blocks use the full width of the popup:
|
|
|
201
201
|
- **Stages.** Each stage of the workflow, with its dates under its name or "no dates yet", on a month scale with a red line for today. A stage's bar runs from the earliest start to the latest end of its tasks; a task with no start counts from its due date. Only a stage with no dated task uses the days the workflow moved through it. To change a stage's dates, change its tasks' dates. A stage has a bar only when it has real dates. A milestone is a diamond on its stage's row.
|
|
202
202
|
- **Layouts.** Only when the initiative adds a new screen, page or view: three layouts of the same parts side by side, **A List first**, **B Summary first** and **C Action first**, drawn with grey bars in place of data. One ✦ line recommends one and says why. Press ✓ under one to keep it as the layout to build; the other two stay, marked **Kept**, and **Undo** takes the pick back. The ✦ learns from your picks for this product. `pmos layouts` reads and writes the same picks.
|
|
203
203
|
- **Work breakdown.** **List** or **Gantt**; PMOS keeps your choice on this computer. **List** has one box on top: type a task and press Enter. Say its stage ("… in Plan"), or it goes to the stage in progress; start with ◇ to add a milestone. Each stage with tasks is one group that says how much is done, for example "1 of 3 done". Press the group to fold it, and press it again to open it. A stage whose tasks are all done is folded until you open it. In a stage, the tasks are in date order, a late task first. A done task stays in its place, in grey with a check. Stages with no tasks fold into one line at the end. Press the box before a task to mark it done, with **Undo**. Press its name to rename it: Enter saves and Escape cancels. When you point at the row, four icons show: **Who** (You, the people on this initiative, or **PMOS does it**, which gives the task to PMOS), **Due date**, **Stage** (moves the task to another stage) and ⋯ (**Status**, **Make it a milestone** and **Open the task**). Each change has **Undo**. A Jira ticket keeps its owner and stage from Jira. **Gantt** is the table described below, with its bars.
|
|
204
|
+
- **Review.** It shows only when a screen of the initiative was built and compared with its design. PMOS compares by itself: when the product's repository holds `screens/<initiative>/<screen>.design.png` beside `<screen>.built.png`, opening the initiative compares them, and again when either file changes (`pmos review shots` does it by hand). The design and the built screen sit side by side. On the built screen each difference is circled and numbered, and a short line under them says what differs, for example "1 · button 8px lower". Parts that match get no mark, and a screen that matches says **Matches its design.** ✓ accepts the built screen and closes the review, with **Undo**. The send-back icon on a line adds the task **Fix: …** to the initiative, with **Undo**; its circle turns grey, and pressing it again takes the task back. The block sits between Stages and the Work breakdown, and on a phone above **Ask PMOS**, with the two screens one above the other.
|
|
204
205
|
|
|
205
206
|
Press the rest of a row, or a milestone, to open it as a full popup in place of the work side. Its top line has ←, the path (**Work › product › initiative**), the chat button, ⋯ and ×. ← or the initiative's name goes back to the initiative, where you left it. The chat beside it is about the task or milestone itself: its own conversation, which starts with the item's status, dates, owner and notes, and the line under the chat's title reads **Task in** and the initiative. The chat button shows that chat. ← back to the initiative shows the initiative's chat again, and its sessions stay in the chat's session list. A file or a task that the chat opens itself does not change the chat. × closes the popup. A task shows its status, dates, owner, notes and what changed. A milestone also shows its date and how many days are left, the done test, **Kill if**, and the suggestion from PMOS about it when there is one.
|
|
206
207
|
|
|
@@ -324,9 +325,12 @@ Right-click any part of a page to ask PMOS about it. On a phone, press and hold
|
|
|
324
325
|
- The top line says what PMOS understood: the item, then the field or the place you pressed, for example **Instant payout to bank › Next milestone · Beta to 5% of users**. In a document it is the heading and the paragraph; on a slide it is the slide and the part, such as a chart bar.
|
|
325
326
|
- When the top line names the wrong thing, press **↑** to step out one level: the field, then the item, then the section, then the page.
|
|
326
327
|
- Under it is the item as Work holds it now, with its usual buttons. A task's date shows three later dates to move it to. Every change has Undo.
|
|
327
|
-
- Up to three questions show with ✦. Press one, or type your own question in the box.
|
|
328
|
+
- Up to three questions show with ✦. Press one, or type your own question in the box. The questions go away once you ask.
|
|
328
329
|
- **What PMOS can do** lists up to four features for that kind of item, such as **Why this work exists** for an initiative or **Strategy** for a product. One press asks it in the card, about that item, with nothing to type. A section, the page, or an item no feature acts on shows no such line.
|
|
329
330
|
- **⤢** opens the same conversation in the full chat. **×** or Escape closes the card.
|
|
331
|
+
- To move the card, hold its top line and drag it. It stays where you put it.
|
|
332
|
+
|
|
333
|
+
To change the text size of a chat, press **+** in the chat box and pick **A−**, **A** or **A+**. The size applies to every chat and follows you to your other computers.
|
|
330
334
|
|
|
331
335
|
Right-click keeps the browser's own menu in a text box, on a link, on selected text and in the terminal. Hold Shift to get the browser's menu anywhere.
|
|
332
336
|
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* built-vs-design-http.js — (not a routes-*.js module: lib/routes-pop-work.js hands it its paths) the built screen beside its design over HTTP (initiative built-vs-design, job #1903, idea A380). The store is
|
|
3
|
+
* lib/built-vs-design.js (built-vs-design.jsonl and the copied shots in the product's state folder); `pmos review` writes the same store.
|
|
4
|
+
*
|
|
5
|
+
* GET /api/built-vs-design?ws&ini → { ok, reviews: [{ id, ini, screen, at, w, h, diffs: [{ n, x, y, w, h, words, task }], more }] }
|
|
6
|
+
* the open reviews of the initiative (an accepted one is left out: zero is silence).
|
|
7
|
+
* First PMOS compares by itself each <repo>/screens/<ini>/<screen>.design.png beside
|
|
8
|
+
* <screen>.built.png whose files changed since its last review (BV.auto), so no ask is needed.
|
|
9
|
+
* GET /api/built-vs-design/shot?ws&pair&which=design|built → the stored PNG
|
|
10
|
+
* POST /api/built-vs-design { ws, ini, pair, act, n? } act ∈ accept · reopen · fix · unfix → { ok, … } | 4xx
|
|
11
|
+
* fix adds the task "Fix: <the difference>" to the initiative by the page's own Add a task (lib/routes-boards.js taskAdd); unfix takes
|
|
12
|
+
* it away again (taskDelete). A page press only (pm-guard requirePagePress). Nothing is sent anywhere. */
|
|
13
|
+
const fs = require('fs');
|
|
14
|
+
const guard = require('./pm-guard.js');
|
|
15
|
+
const BV = require('./built-vs-design.js');
|
|
16
|
+
|
|
17
|
+
const wsOf = (ctx, ws) => { try { return ctx && typeof ctx.getWs === 'function' ? ctx.getWs(ws || null) : null; } catch { return null; } };
|
|
18
|
+
const dirOf = (ctx, w, create) => { try { return w && ctx.stateDirFor ? ctx.stateDirFor(w, create ? { create: true } : undefined) : null; } catch { return null; } };
|
|
19
|
+
const pub = (p) => ({ id: p.id, ini: p.ini, screen: p.screen, at: p.at, w: p.w, h: p.h, diffs: p.diffs.map((d) => ({ n: d.n, x: d.x, y: d.y, w: d.w, h: d.h, words: d.words, task: d.task })), more: p.more || 0 });
|
|
20
|
+
|
|
21
|
+
/** The page's Add a task and Delete for one initiative, on this server. */
|
|
22
|
+
function adderFor(ctx, w, ini, g) {
|
|
23
|
+
const boards = require('./routes-boards.js');
|
|
24
|
+
const at = () => boards.initiativeWorkflow(ctx, w, ini);
|
|
25
|
+
return {
|
|
26
|
+
add: (title, notes) => {
|
|
27
|
+
const r = at(); if (!r.ok) return { ok: false, error: r.error };
|
|
28
|
+
const a = boards.taskAdd(ctx, { ws: w.id, board: r.board.id, initiative: ini, title, notes }, g);
|
|
29
|
+
return a.body && a.body.ok ? { ok: true, task: a.body.item.uid } : { ok: false, error: (a.body && a.body.error) || 'the task was not added' };
|
|
30
|
+
},
|
|
31
|
+
remove: (task) => {
|
|
32
|
+
const r = at(); if (!r.ok) return { ok: false, error: r.error };
|
|
33
|
+
const a = boards.taskDelete(ctx, { ws: w.id, board: r.board.id, task, why: 'the fix was taken back' }, g);
|
|
34
|
+
return a.body && a.body.ok ? { ok: true } : { ok: false, error: (a.body && a.body.error) || 'the task was not taken away' };
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function handle(req, res, url, ctx) {
|
|
40
|
+
const p = url.pathname;
|
|
41
|
+
if (p !== '/api/built-vs-design' && p !== '/api/built-vs-design/shot') return false;
|
|
42
|
+
const send = (code, obj) => { ctx.json(res, obj, code); return true; };
|
|
43
|
+
if (p === '/api/built-vs-design/shot') {
|
|
44
|
+
if (req.method !== 'GET') return send(405, { ok: false, error: 'GET only' });
|
|
45
|
+
const w = wsOf(ctx, url.searchParams.get('ws')), dir = dirOf(ctx, w, false);
|
|
46
|
+
const f = dir ? BV.shotFile(dir, url.searchParams.get('pair'), url.searchParams.get('which')) : null;
|
|
47
|
+
if (!f) return send(404, { ok: false, error: 'no such shot' });
|
|
48
|
+
res.writeHead(200, { 'Content-Type': 'image/png', 'Cache-Control': 'private, max-age=3600' });
|
|
49
|
+
res.end(fs.readFileSync(f));
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (req.method === 'GET') {
|
|
53
|
+
const ini = String(url.searchParams.get('ini') || '');
|
|
54
|
+
const w = wsOf(ctx, url.searchParams.get('ws'));
|
|
55
|
+
// PMOS compares by itself: a screen in <repo>/screens/<ini>/ whose design or built file changed is compared on this read
|
|
56
|
+
const found = ini && w && w.root ? BV.discover(w.root, ini) : [];
|
|
57
|
+
const dir = dirOf(ctx, w, found.length > 0);
|
|
58
|
+
if (!ini || !dir) return send(200, { ok: true, reviews: [] });
|
|
59
|
+
if (found.length) BV.auto(dir, w.root, ini);
|
|
60
|
+
return send(200, { ok: true, reviews: BV.list(dir, ini).map(pub) });
|
|
61
|
+
}
|
|
62
|
+
if (req.method !== 'POST') return send(405, { ok: false, error: 'GET or POST' });
|
|
63
|
+
const rd = await ctx.readJson(req);
|
|
64
|
+
if (!rd.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
65
|
+
const body = rd.body || {};
|
|
66
|
+
const g = guard.requirePagePress(req, body);
|
|
67
|
+
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
68
|
+
const w = wsOf(ctx, body.ws), dir = dirOf(ctx, w, false), ini = String(body.ini || ''), pair = String(body.pair || '');
|
|
69
|
+
if (!dir || !ini || !BV.PAIR_RE.test(pair)) return send(400, { ok: false, error: 'name the product, the initiative and the review' });
|
|
70
|
+
const by = (g.actor && g.actor.by) || 'pm';
|
|
71
|
+
const act = String(body.act || '');
|
|
72
|
+
let r;
|
|
73
|
+
if (act === 'accept' || act === 'reopen') r = BV.accept(dir, ini, { by, pair, undo: act === 'reopen' });
|
|
74
|
+
else if (act === 'fix' || act === 'unfix') {
|
|
75
|
+
const A = ctx.builtVsDesignAdder ? ctx.builtVsDesignAdder(w, ini) : adderFor(ctx, w, ini, { ok: true, actor: g.actor });
|
|
76
|
+
r = await BV.fix(dir, ini, body.n, { add: A.add, remove: A.remove, by, pair, undo: act === 'unfix' });
|
|
77
|
+
} else return send(400, { ok: false, error: 'act is one of accept, reopen, fix, unfix' });
|
|
78
|
+
return send(r.ok ? 200 : 400, r);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = { prefixes: ['/api/built-vs-design'], handle };
|