create-pmos 0.833.0 → 0.834.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.833.0",
3
+ "version": "0.834.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,46 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.834.0",
38
+ "at": "2026-11-25T15:04:32.499Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1954,
43
+ "t": "A new bet's story map with the Release 1 line (job #1892, A419)",
44
+ "s": "A new bet's story map with the Release 1 line (job #1892, A419)",
45
+ "k": "new",
46
+ "h": "A new bet's story map with the Release 1 line (job #1892, A419)",
47
+ "try": {
48
+ "steps": [
49
+ "Open Work and open a new initiative that has no tasks yet",
50
+ "Under Story map press ✦ to let PMOS draft it, then ✓ to keep the draft",
51
+ "Press a task below the dashed line to move it into Release 1, then press ✓ Keep the map"
52
+ ],
53
+ "see": "Steps of the user's journey run left to right with tasks under each. The dashed line marks Release 1, and its count follows each move. After Keep, the tasks show in the initiative's Work breakdown,…",
54
+ "open": "/premium-board.html"
55
+ },
56
+ "i": "story-map"
57
+ },
58
+ {
59
+ "n": 2034,
60
+ "t": "Drag a task bar, an end or a milestone on the Gantt to change its dates, with Undo (job #2014)",
61
+ "s": "Drag a task bar, an end or a milestone on the Gantt to change its dates, with Undo (job #2014)",
62
+ "k": "new",
63
+ "i": "timeline-bar-drag",
64
+ "try": {
65
+ "steps": [
66
+ "Open Work, open an initiative and choose Gantt under ⋯; point at a task bar: grips show at both ends",
67
+ "Drag its right end two days later and read the tip, then let go",
68
+ "Press Undo in the toast"
69
+ ],
70
+ "see": "Dragging the right end moves only the due day, the tip names the new dates, the toast says Dates saved with Undo, and Undo puts the old due day back",
71
+ "open": "/premium-board.html"
72
+ }
73
+ }
74
+ ]
75
+ },
36
76
  {
37
77
  "v": "0.833.0",
38
78
  "at": "2026-11-25T14:46:14.436Z",
@@ -43,6 +83,7 @@
43
83
  "t": "A pressed task offers Rehearse a change too (Checker A1, job #1989)",
44
84
  "s": "A pressed task offers Rehearse a change too (Checker A1, job #1989)",
45
85
  "k": "fix",
86
+ "i": "surface-ask-card",
46
87
  "h": "A pressed task offers Rehearse a change too (Checker A1, job #1989)",
47
88
  "try": {
48
89
  "steps": [
@@ -52,30 +93,21 @@
52
93
  ],
53
94
  "see": "The Ask card's \"What PMOS can do\" line lists Why this work exists, Task descriptions and Rehearse a change. Rehearse a change asks /rehearse <task> in the card's chat.",
54
95
  "open": "/premium-board.html"
55
- },
56
- "i": "surface-ask-card"
96
+ }
57
97
  },
58
98
  {
59
99
  "n": 2029,
60
100
  "t": "Each initiative on Work names its key result; Strategy and Positioning name their OKR period",
61
101
  "s": "Each initiative on Work names its key result; Strategy and Positioning name their OKR period",
62
102
  "k": "new",
63
- "i": "tb-work-kr",
64
- "try": {
65
- "steps": [
66
- "Open Work and choose the Line tab",
67
- "Under each initiative's name, see the key result it serves, for example Serves KR1.1",
68
- "On Work, look at the Strategy card: its head names the period, such as H2 2026 · Jul–Dec · ends 31 Dec, and a Serves row lists the…"
69
- ],
70
- "see": "Each initiative on the line says which key result it serves, and the chip shows the key result's words. Strategy and Positioning name the OKR period they are for. An initiative with no key result…",
71
- "open": "/premium-board.html?work=line"
72
- }
103
+ "i": "tb-work-kr"
73
104
  },
74
105
  {
75
106
  "n": 2021,
76
107
  "t": "With the chat open, the side column folds into one-line rows (job #2017)",
77
108
  "s": "With the chat open, the side column folds into one-line rows (job #2017)",
78
109
  "k": "new",
110
+ "i": "tb-chat-open-fold",
79
111
  "h": "With the chat open, the side column folds into one-line rows (job #2017)",
80
112
  "try": {
81
113
  "steps": [
@@ -85,24 +117,14 @@
85
117
  ],
86
118
  "see": "With the chat beside the work, the side column folds into one-line rows above the main content and is never hidden. Without the chat, the page looks as before",
87
119
  "open": "/premium-board.html"
88
- },
89
- "i": "tb-chat-open-fold"
120
+ }
90
121
  },
91
122
  {
92
123
  "n": 2032,
93
124
  "t": "Next milestones on the product, program and initiative pages (job #2020)",
94
125
  "s": "Next milestones on the product, program and initiative pages (job #2020)",
95
126
  "k": "new",
96
- "i": "milestone-strip-pages",
97
- "try": {
98
- "steps": [
99
- "Open Work and press an initiative that has a milestone ahead",
100
- "Find Next milestones above Work breakdown, with the sub this initiative; drag it sideways or press +N to see more, and press a ◇ to open…",
101
- "Press the product name in the popup, then a program: each shows Next milestones for its own initiatives"
102
- ],
103
- "see": "The product, program and initiative pages each show the same Next milestones strip as Work, for their own initiatives, with its own window, scroll and +N marks. A ◇ opens the milestone. A page whose…",
104
- "open": "/premium-board.html"
105
- }
127
+ "i": "milestone-strip-pages"
106
128
  }
107
129
  ]
108
130
  },
@@ -971,25 +993,6 @@
971
993
  "k": "new"
972
994
  }
973
995
  ]
974
- },
975
- {
976
- "v": "0.805.0",
977
- "at": "2026-11-25T04:31:28.431Z",
978
- "f": 4,
979
- "prs": [
980
- {
981
- "n": 1835,
982
- "t": "Name the pages that keep their own layouts",
983
- "s": "Name the pages that keep their own layouts",
984
- "k": "x"
985
- },
986
- {
987
- "n": 1827,
988
- "t": "⋯ Change holds what the popup's four leave off (job #1821, A498)",
989
- "s": "⋯ Change holds what the popup's four leave off (job #1821, A498)",
990
- "k": "fix"
991
- }
992
- ]
993
996
  }
994
997
  ]
995
998
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@cb9aafef1
1
+ kernel-source: pmos@77f3a7971
2
2
  assembled: 2026-11-25
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-25T14:46:11Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T15:04:28Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-11-25T14:46:11Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T15:04:28Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-11-25T14:46:11Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T15:04:28Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,44 @@
1
1
  [
2
+ {
3
+ "v": "0.834.0",
4
+ "at": "2026-11-25T15:04:32.499Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1954,
9
+ "t": "A new bet's story map with the Release 1 line (job #1892, A419)",
10
+ "s": "A new bet's story map with the Release 1 line (job #1892, A419)",
11
+ "k": "new",
12
+ "h": "A new bet's story map with the Release 1 line (job #1892, A419)",
13
+ "try": {
14
+ "steps": [
15
+ "Open Work and open a new initiative that has no tasks yet",
16
+ "Under Story map press ✦ to let PMOS draft it, then ✓ to keep the draft",
17
+ "Press a task below the dashed line to move it into Release 1, then press ✓ Keep the map"
18
+ ],
19
+ "see": "Steps of the user's journey run left to right with tasks under each. The dashed line marks Release 1, and its count follows each move. After Keep, the tasks show in the initiative's Work breakdown,…",
20
+ "open": "/premium-board.html"
21
+ },
22
+ "i": "story-map"
23
+ },
24
+ {
25
+ "n": 2034,
26
+ "t": "Drag a task bar, an end or a milestone on the Gantt to change its dates, with Undo (job #2014)",
27
+ "s": "Drag a task bar, an end or a milestone on the Gantt to change its dates, with Undo (job #2014)",
28
+ "k": "new",
29
+ "i": "timeline-bar-drag",
30
+ "try": {
31
+ "steps": [
32
+ "Open Work, open an initiative and choose Gantt under ⋯; point at a task bar: grips show at both ends",
33
+ "Drag its right end two days later and read the tip, then let go",
34
+ "Press Undo in the toast"
35
+ ],
36
+ "see": "Dragging the right end moves only the due day, the tip names the new dates, the toast says Dates saved with Undo, and Undo puts the old due day back",
37
+ "open": "/premium-board.html"
38
+ }
39
+ }
40
+ ]
41
+ },
2
42
  {
3
43
  "v": "0.833.0",
4
44
  "at": "2026-11-25T14:46:14.436Z",
@@ -9,6 +49,7 @@
9
49
  "t": "A pressed task offers Rehearse a change too (Checker A1, job #1989)",
10
50
  "s": "A pressed task offers Rehearse a change too (Checker A1, job #1989)",
11
51
  "k": "fix",
52
+ "i": "surface-ask-card",
12
53
  "h": "A pressed task offers Rehearse a change too (Checker A1, job #1989)",
13
54
  "try": {
14
55
  "steps": [
@@ -18,30 +59,21 @@
18
59
  ],
19
60
  "see": "The Ask card's \"What PMOS can do\" line lists Why this work exists, Task descriptions and Rehearse a change. Rehearse a change asks /rehearse <task> in the card's chat.",
20
61
  "open": "/premium-board.html"
21
- },
22
- "i": "surface-ask-card"
62
+ }
23
63
  },
24
64
  {
25
65
  "n": 2029,
26
66
  "t": "Each initiative on Work names its key result; Strategy and Positioning name their OKR period",
27
67
  "s": "Each initiative on Work names its key result; Strategy and Positioning name their OKR period",
28
68
  "k": "new",
29
- "i": "tb-work-kr",
30
- "try": {
31
- "steps": [
32
- "Open Work and choose the Line tab",
33
- "Under each initiative's name, see the key result it serves, for example Serves KR1.1",
34
- "On Work, look at the Strategy card: its head names the period, such as H2 2026 · Jul–Dec · ends 31 Dec, and a Serves row lists the…"
35
- ],
36
- "see": "Each initiative on the line says which key result it serves, and the chip shows the key result's words. Strategy and Positioning name the OKR period they are for. An initiative with no key result…",
37
- "open": "/premium-board.html?work=line"
38
- }
69
+ "i": "tb-work-kr"
39
70
  },
40
71
  {
41
72
  "n": 2021,
42
73
  "t": "With the chat open, the side column folds into one-line rows (job #2017)",
43
74
  "s": "With the chat open, the side column folds into one-line rows (job #2017)",
44
75
  "k": "new",
76
+ "i": "tb-chat-open-fold",
45
77
  "h": "With the chat open, the side column folds into one-line rows (job #2017)",
46
78
  "try": {
47
79
  "steps": [
@@ -51,24 +83,14 @@
51
83
  ],
52
84
  "see": "With the chat beside the work, the side column folds into one-line rows above the main content and is never hidden. Without the chat, the page looks as before",
53
85
  "open": "/premium-board.html"
54
- },
55
- "i": "tb-chat-open-fold"
86
+ }
56
87
  },
57
88
  {
58
89
  "n": 2032,
59
90
  "t": "Next milestones on the product, program and initiative pages (job #2020)",
60
91
  "s": "Next milestones on the product, program and initiative pages (job #2020)",
61
92
  "k": "new",
62
- "i": "milestone-strip-pages",
63
- "try": {
64
- "steps": [
65
- "Open Work and press an initiative that has a milestone ahead",
66
- "Find Next milestones above Work breakdown, with the sub this initiative; drag it sideways or press +N to see more, and press a ◇ to open…",
67
- "Press the product name in the popup, then a program: each shows Next milestones for its own initiatives"
68
- ],
69
- "see": "The product, program and initiative pages each show the same Next milestones strip as Work, for their own initiatives, with its own window, scroll and +N marks. A ◇ opens the milestone. A page whose…",
70
- "open": "/premium-board.html"
71
- }
93
+ "i": "milestone-strip-pages"
72
94
  }
73
95
  ]
74
96
  },
@@ -57,6 +57,17 @@ On a phone or tablet, press and hold a task to select it. Then tap more tasks to
57
57
 
58
58
  In the Gantt, drag a task's bar to move its dates by whole days. If the task is selected, the bars of all the selected tasks move by the same number of days. If you drag a parent's bar, all the tasks under it move.
59
59
 
60
+ A bar you can change says "Drag to change dates" and shows a grip at each end when you point at it.
61
+
62
+ - Drag the middle of the bar to move the start and the due day together.
63
+ - Drag the left grip to change only the start. Drag the right grip to change only the due day. An end does not go past the other end.
64
+ - Drag a milestone's ◇ to move its date.
65
+ - While you drag, a tip shows the new dates, for example "24 Nov to 9 Dec". When you release, the toast says "Dates saved" and has Undo.
66
+ - With a pen or a finger, move sideways to drag. A short tap still opens the task.
67
+ - With the keyboard, press Tab until a bar is selected. Then press ← or → to move it one day. Press Shift with ← or → to change the due day, or Alt with ← or → to change the start.
68
+
69
+ A Jira ticket's dates change in PMOS only. Jira does not change. A Jira sub-task that PMOS only reads, a stage, and the bars in a read-only copy cannot be dragged.
70
+
60
71
  To move tasks to a stage, select tasks of one initiative. The stages are the stages of that initiative.
61
72
 
62
73
  PMOS does not change the stage, owner or status of a Jira ticket. It skips these tickets and tells you why.
@@ -394,6 +394,17 @@ Write the press release before the build ("working backwards"). Run it in the pr
394
394
  - The draft uses one agent run with no tools. `--no-ai`, `pmos ai off press-release` or `PMOS_AI=off` makes a draft from the record's own lines only. A failed run does the same and says why.
395
395
  - `pmos press-release count [--days 7]` prints how many drafts were written in the last days. Its last line is the number.
396
396
 
397
+ ### pmos story-map: the user's journey and the Release 1 line
398
+
399
+ A story map for a new bet: the steps of the user's journey left to right, the tasks of each step top to bottom, and a dashed line under the thinnest release that still works end to end. The initiative popup on Work shows it, and the chat reads and writes the same map. Run it in the product's repository, or pass `--root <dir>`. No running workspace is needed.
400
+
401
+ - `pmos story-map show <initiative>` prints each step with its Release 1 tasks, then the later ones after a `/`, with each task's id.
402
+ - `pmos story-map set <initiative> --text "<lines>"` writes the map: one line per step, `Step: task; task / later task`. The tasks before the `/` are Release 1. A map needs at least 2 steps and one Release 1 task. `--text -` reads the lines from stdin.
403
+ - `pmos story-map move <initiative> <task> --above|--below` moves a task across the Release 1 line.
404
+ - `pmos story-map keep <initiative>` makes every task a task of the initiative, Release 1 first, by the same Add a task as Work. It runs once per map. `pmos story-map unkeep <initiative>` deletes those tasks again, and the map stays. `pmos story-map drop <initiative>` deletes a map that is not kept.
405
+ - `pmos story-map count [--days 14]` prints how many maps were kept as a task breakdown in the last days. Its last line is the number.
406
+ - On a new bet with fewer than 3 tasks and no map, the popup shows ✦ "Map the user's journey". PMOS drafts it from the initiative's goal and sources in a read-only run, and nothing is kept until your ✓. It calls no other model, sends nothing and does not write Jira.
407
+
397
408
  ### pmos tradeoff: decide two close items and keep the reason
398
409
 
399
410
  Use it when two neighbours on the Roadmap score about the same. Run it in the product's repository, or pass `--root <dir>`, or ask the chat to "compare these two". Work shows the same cards: the line "These two are close. Compare them" between the two rows.
@@ -59,6 +59,7 @@
59
59
  {"id": "rules", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "Rules PMOS learned", "say": "The standing rules PMOS learned from your corrections, and edit or retire one.", "cmd": "/rules", "verb": "rules"},
60
60
  {"id": "line", "audience": "user", "status": "ga", "group": "Catch up", "name": "Where each initiative stands", "say": "Days in its stage, what is missing, the next move, and whether it is stuck.", "cmd": "/line", "verb": "line", "hint": "<initiative>", "ask": ["initiative"]},
61
61
  {"id": "hire", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The next hire", "say": "The role your open work most needs, and a one-page role brief to edit.", "cmd": "/hire", "verb": "hire"},
62
+ {"id": "story-map", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Story map", "say": "A new bet's user journey left to right, with the Release 1 line to move tasks across.", "cmd": "/story-map", "verb": "story-map", "hint": "<initiative>"},
62
63
  {"id": "print", "audience": "user", "status": "ga", "group": "Your product", "name": "Print or PDF", "say": "One clean page of a report or an initiative, to print or save as PDF.", "cmd": "/print", "verb": "print", "hint": "<file or initiative>"},
63
64
  {"id": "prototype", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Simulated users try the prototype", "say": "Where simulated users, one per persona, got stuck on a prototype, and the personas that walk it.", "cmd": "/prototype", "verb": "prototype", "hint": "findings <initiative>"},
64
65
  {"id": "goals", "audience": "user", "status": "ga", "group": "Your product", "name": "Starter goals", "say": "Up to three goals drafted from your own product, each with its source; keep one and it becomes a goal.", "cmd": "/goals", "verb": "goals"},
@@ -157,6 +157,9 @@ const VERBS = Object.freeze({
157
157
  // Not a pm-os-absorb verb (run: null): initiative three-line-why (bet A86) added it through the same table.
158
158
  why: Object.freeze({ module: 'why-cli.js', run: null, guide: 'cli.md',
159
159
  help: 'pmos why <initiative or task> | coverage — why the work exists in three lines: goal, problem, evidence, read from its records (pmos why help)' }),
160
+ // Not a pm-os-absorb verb (run: null): initiative story-map (job #1892, A419) added it through the same table.
161
+ 'story-map': Object.freeze({ module: 'story-map-cli.js', run: null, guide: 'cli.md',
162
+ help: 'pmos story-map show|set|move|keep|unkeep|drop|count — a new bet\'s story map: the user\'s journey and the Release 1 line (pmos story-map help)' }),
160
163
  // Not a pm-os-absorb verb (run: null): initiative tradeoff-cards (job #1918, A325) added it through the same table.
161
164
  tradeoff: Object.freeze({ module: 'tradeoff-cli.js', run: null, guide: 'cli.md',
162
165
  help: 'pmos tradeoff [list|show|keep|undo|count] — two close items on the Roadmap side by side, and the reason you kept one first (pmos tradeoff help)' }),
@@ -159,6 +159,7 @@ const MODULES = Object.freeze([
159
159
  'routes-code-map', // idea A176: the product's code map on Work, redrawn when the default branch moves (records code-map.json; read-only)
160
160
  'routes-arch-warns', // idea A54: one warning when an initiative names a risky part of the code (reads code-map.json; read-only)
161
161
  'routes-live-rows', // bet A458: chat-made task changes streamed to open pages (runtime live-events.jsonl; read-only event stream)
162
+ 'routes-story-map', // idea A419: a new bet's story map with the Release 1 line on the initiative popup (state story-maps.json; page-press POST)
162
163
  'routes-screen-layouts', // three-layouts (A317): a new screen's three layouts, the ✦ pick and its Undo (product state layouts.jsonl; page-press POST)
163
164
  'routes-team-waits', // team-waits (A364): Work › Dependencies' waits on other teams (GET, read-only; team-waits.jsonl written by pmos deps)
164
165
  'routes-connector-data', // connector-data (A150): what each connector reads and writes, from lib/connector-data.js (read only)
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+ /* routes-story-map.js — a new bet's story map on the initiative popup (initiative story-map, idea A419; lib/story-map.js).
3
+ *
4
+ * GET /api/story-map?ws&ini → { ok, ws, ini, map | null, release: [...], ask } ask: the ✦ draft words (lib/star-draft.js runs them)
5
+ * POST /api/story-map/set { ws, ini, text } → { ok, map, prev } the ✓ on PMOS's draft (by pmos) or the PM's own lines
6
+ * POST /api/story-map/move { ws, ini, task, side } → { ok, map, from } side: above | below the Release 1 line
7
+ * POST /api/story-map/keep { ws, ini } → { ok, map, added } every task to the breakdown, Release 1 first (once)
8
+ * POST /api/story-map/unkeep { ws, ini } → { ok, map, removed } Keep's Undo
9
+ * POST /api/story-map/put { ws, ini, map | null } → { ok } Undo of set and of drop: the map as it was (a kept map is never put)
10
+ *
11
+ * Every POST is a page press (pm-guard requirePagePress). The store is the product's state folder, the same one `pmos story-map` writes. */
12
+ const guard = require('./pm-guard.js');
13
+ const SM = require('./story-map.js');
14
+
15
+ module.exports = {
16
+ prefixes: ['/api/story-map'],
17
+ handle: async (req, res, url, ctx) => {
18
+ const p = url.pathname;
19
+ if (p !== '/api/story-map' && !p.startsWith('/api/story-map/')) return false;
20
+ const bad = (error, code) => { ctx.json(res, { ok: false, error }, code || 400); return true; };
21
+ const place = (wsId, ini) => {
22
+ const w = ctx.getWs ? ctx.getWs(wsId || null) : null;
23
+ if (!w) return { error: 'no such product', code: 404 };
24
+ if (!/^[a-z0-9][a-z0-9._-]{0,80}$/.test(String(ini || ''))) return { error: 'ini must name an initiative', code: 400 };
25
+ const dir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
26
+ if (!dir) return { error: 'this product has no state folder', code: 409 };
27
+ return { w, dir };
28
+ };
29
+ if (p === '/api/story-map') {
30
+ if (req.method !== 'GET') return bad('GET only', 405);
31
+ const ini = String(url.searchParams.get('ini') || '');
32
+ const at = place(url.searchParams.get('ws'), ini);
33
+ if (at.error) return bad(at.error, at.code);
34
+ const map = SM.read(at.dir, ini);
35
+ ctx.json(res, { ok: true, ws: at.w.id, ini, map, release: SM.releaseOf(map), ask: SM.askOf({ id: ini, title: String(url.searchParams.get('title') || '') || ini }) });
36
+ return true;
37
+ }
38
+ if (req.method !== 'POST') return bad('POST only', 405);
39
+ const got = await ctx.readJson(req);
40
+ if (!got.ok) return bad('invalid JSON body');
41
+ const b = got.body || {};
42
+ const g = guard.requirePagePress(req, b);
43
+ if (!g.ok) return bad(g.error, g.status);
44
+ const at = place(b.ws, b.ini);
45
+ if (at.error) return bad(at.error, at.code);
46
+ const send = (r) => { if (r.ok) ctx.json(res, r); else bad(r.error, r.status || 400); return true; };
47
+ const act = p.slice('/api/story-map/'.length);
48
+ if (act === 'set') return send(SM.set(at.dir, b.ini, String(b.text || ''), { by: b.by === 'pm' ? 'pm' : 'pmos' }));
49
+ if (act === 'move') return send(SM.moveTo(at.dir, b.ini, String(b.task || ''), String(b.side || '')));
50
+ if (act === 'keep') return send(SM.keep(ctx, at.w, b.ini, at.dir, g));
51
+ if (act === 'unkeep') return send(SM.unkeep(ctx, at.w, b.ini, at.dir, g));
52
+ if (act === 'put') {
53
+ const now = SM.read(at.dir, b.ini);
54
+ if (now && now.kept) return bad('this map is kept as the task breakdown; unkeep it first', 409);
55
+ const m = b.map && Array.isArray(b.map.steps) && !b.map.kept ? { ...b.map, ini: b.ini } : null;
56
+ SM.save(at.dir, b.ini, m);
57
+ console.info(`${SM.TAG} put ini=${b.ini} ${m ? 'steps=' + m.steps.length : 'none'}`);
58
+ return send({ ok: true, map: m });
59
+ }
60
+ return bad('no such story-map action', 404);
61
+ },
62
+ };
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+ /* story-map-cli.js — `pmos story-map …`: a new bet's story map from a terminal or the chat, on the same store the initiative popup reads
3
+ * (initiative story-map, idea A419; lib/story-map.js). Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent and Jira is not written. */
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { TAG, read, save, set, moveTo, keep, unkeep, count, releaseOf } = require('./story-map.js');
7
+
8
+ /* ── pmos story-map ── */
9
+ const COMMANDS = { 'story-map': ['show', 'set', 'move', 'keep', 'unkeep', 'drop', 'count'] };
10
+ const USAGE = [
11
+ 'usage: pmos story-map show|set|move|keep|unkeep|drop|count — a new bet\'s story map: the user\'s journey, and the Release 1 line',
12
+ ' pmos story-map show <initiative> the steps, each with its Release 1 tasks, then the later ones; prints the task ids',
13
+ ' pmos story-map set <initiative> --text "<lines>" write the map: one line per step, "Step: task; task / later task" (--text - reads stdin)',
14
+ ' pmos story-map move <initiative> <task> --above|--below move a task across the Release 1 line',
15
+ ' pmos story-map keep <initiative> make every task a task of the initiative, Release 1 first (once)',
16
+ ' pmos story-map unkeep <initiative> delete the tasks Keep added; the map stays',
17
+ ' pmos story-map drop <initiative> delete a map that is not kept',
18
+ ' pmos story-map count [--days 14] maps kept in the last days; the last line is the number',
19
+ ' every command: [--json] [--root <dir>]. Nothing is sent and Jira is not written.',
20
+ ];
21
+
22
+ function parseArgs(argv) {
23
+ const pos = [], flags = {};
24
+ for (let i = 0; i < argv.length; i++) {
25
+ const a = argv[i];
26
+ if (a === '--root' || a === '--days' || a === '--text') flags[a.slice(2)] = argv[++i];
27
+ else if (a.startsWith('--')) flags[a.slice(2)] = true;
28
+ else if (a === '-h') flags.help = true;
29
+ else pos.push(a);
30
+ }
31
+ return { pos, flags };
32
+ }
33
+
34
+ function cliCtx(root, stateDir) {
35
+ const w = { id: require('./driver.js').wsIdOf(root), name: path.basename(root), root };
36
+ return { w, ctx: { getWs: () => w, workspaceList: () => [w], stateDirFor: () => stateDir, selfRoot: path.resolve(__dirname, '..', '..') } };
37
+ }
38
+
39
+ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), stdin = null, isTTY, env } = {}) {
40
+ const args = argv[0] === 'story-map' ? argv.slice(1) : argv.slice();
41
+ const verb = args[0];
42
+ const { pos, flags } = parseArgs(args.slice(1));
43
+ if (!verb || verb === 'help' || flags.help) { for (const l of USAGE) say(l); return verb ? 0 : 2; }
44
+ if (!COMMANDS['story-map'].includes(verb)) { say(`unknown story-map command "${verb}" — one of ${COMMANDS['story-map'].join(', ')}`); return 2; }
45
+ const json = !!flags.json;
46
+ const fail = (error, code = 1) => { say(json ? JSON.stringify({ ok: false, error }) : `✗ ${error}`); return code; };
47
+ let root = flags.root ? path.resolve(cwd, flags.root) : cwd;
48
+ if (!flags.root) { let d = cwd; while (d !== path.dirname(d) && !fs.existsSync(path.join(d, '.git'))) d = path.dirname(d); root = fs.existsSync(path.join(d, '.git')) ? d : cwd; }
49
+ const driver = require('./driver.js');
50
+ const dir = driver.stateDirOf(root, { create: !['show', 'count'].includes(verb) });
51
+ if (!dir) return fail('this repository has no PMOS state folder (pmos/state, state or .pmos)');
52
+
53
+ if (verb === 'count') {
54
+ const days = Math.max(1, Math.min(365, parseInt(flags.days, 10) || 14));
55
+ const n = count(dir, { days });
56
+ if (json) say(JSON.stringify({ ok: true, days, kept: n }));
57
+ else { say(`${TAG} ${n} story map${n === 1 ? '' : 's'} kept as a task breakdown in the last ${days} days.`); say(String(n)); }
58
+ return 0;
59
+ }
60
+ const ini = pos[0];
61
+ if (!ini) { for (const l of USAGE) say(l); return 2; }
62
+ if (verb === 'show') {
63
+ const m = read(dir, ini);
64
+ if (!m) return fail(`no story map for ${ini}. Write one with pmos story-map set ${ini} --text "Step: task / later"`);
65
+ if (json) { say(JSON.stringify({ ok: true, map: m, release: releaseOf(m) })); return 0; }
66
+ say(`Story map of ${ini} · drafted by ${m.by === 'pm' ? 'you' : 'PMOS'}${m.kept ? ' · kept as ' + m.kept.tasks.length + ' tasks' : ''}`);
67
+ for (const s of m.steps) say(`${s.name}: ${s.tasks.filter((t) => t.rel === 1).map((t) => `${t.title} (${t.id})`).join('; ') || '—'}${s.tasks.some((t) => t.rel !== 1) ? ' / ' + s.tasks.filter((t) => t.rel !== 1).map((t) => `${t.title} (${t.id})`).join('; ') : ''}`);
68
+ say(`Release 1: ${releaseOf(m).length} tasks.`);
69
+ return 0;
70
+ }
71
+ if (verb === 'set') {
72
+ let text = flags.text;
73
+ if (text === '-' || text === true) text = stdin != null ? stdin : fs.readFileSync(0, 'utf8');
74
+ if (!text) return fail('give the map with --text "<lines>"', 2);
75
+ const r = set(dir, ini, text, { by: 'pmos' });
76
+ if (!r.ok) return fail(r.error);
77
+ if (json) say(JSON.stringify({ ok: true, map: r.map })); else say(`✓ story map of ${ini}: ${r.map.steps.length} steps, Release 1 has ${releaseOf(r.map).length} tasks. The initiative on Work shows it.`);
78
+ return 0;
79
+ }
80
+ if (verb === 'move') {
81
+ const side = flags.above ? 'above' : flags.below ? 'below' : '';
82
+ if (!pos[1] || !side) return fail('usage: pmos story-map move <initiative> <task> --above|--below', 2);
83
+ const r = moveTo(dir, ini, pos[1], side);
84
+ if (!r.ok) return fail(r.error);
85
+ if (json) say(JSON.stringify({ ok: true, map: r.map })); else say(`✓ ${pos[1]} is ${side} the line. Release 1 has ${releaseOf(r.map).length} tasks.`);
86
+ return 0;
87
+ }
88
+ if (verb === 'drop') {
89
+ const m = read(dir, ini);
90
+ if (!m) return fail(`no story map for ${ini}`);
91
+ if (m.kept) return fail('this map is kept as the task breakdown; unkeep it first');
92
+ save(dir, ini, null);
93
+ console.info(`${TAG} drop ini=${ini}`);
94
+ if (json) say(JSON.stringify({ ok: true })); else say(`✓ the story map of ${ini} is deleted.`);
95
+ return 0;
96
+ }
97
+ const actorLib = require('./actor.js');
98
+ const cli = { isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env: env === undefined ? process.env : env };
99
+ const g = { ok: true, actor: actorLib.fromCli(cli), cli };
100
+ const { w, ctx } = cliCtx(root, dir);
101
+ const r = verb === 'keep' ? keep(ctx, w, ini, dir, g) : unkeep(ctx, w, ini, dir, g);
102
+ if (!r.ok) return fail(r.error);
103
+ if (json) say(JSON.stringify({ ok: true, map: r.map, ...(verb === 'keep' ? { added: r.added.length } : { removed: r.removed }) }));
104
+ else say(verb === 'keep' ? `✓ ${r.added.length} tasks added to ${ini}, Release 1 first. Work shows them. Nothing was sent.` : `✓ ${r.removed} tasks taken back from ${ini}. The map stays.`);
105
+ return 0;
106
+ }
107
+
108
+ module.exports = { run, COMMANDS, USAGE };