create-pmos 0.847.0 → 0.849.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 +52 -109
- 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 +51 -12
- package/workspace/guide/cli.md +21 -0
- package/workspace/lib/balance-cli.js +58 -5
- package/workspace/lib/balance-target.js +228 -0
- package/workspace/lib/change-request-cli.js +160 -0
- package/workspace/lib/change-requests.js +136 -0
- package/workspace/lib/features.json +2 -1
- package/workspace/lib/needs-providers.js +2 -0
- package/workspace/lib/pmos-verbs.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/test-lists/balance-rebalance.json +9 -0
- package/workspace/test-lists/change-requests.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.849.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.849.0",
|
|
38
|
+
"at": "2026-11-25T18:55:50.990Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 2057,
|
|
43
|
+
"t": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
|
|
44
|
+
"s": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
|
|
45
|
+
"k": "new",
|
|
46
|
+
"h": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
|
|
47
|
+
"try": {
|
|
48
|
+
"steps": [
|
|
49
|
+
"On Today, find the row in Your move that proposes a target mix for the top of your roadmap, drawn from the roadmap itself. Press its ✦ to…",
|
|
50
|
+
"The row then names the rank move that closes the most gap. Press its ✦, check the Roadmap on Work, then press Undo",
|
|
51
|
+
"Open the chat (Ask PMOS). On a desk the chat opens from the menu button at the bottom left, then the speech bubble. Say: set my roadmap…"
|
|
52
|
+
],
|
|
53
|
+
"see": "When the top of the roadmap leans one way, Today proposes a target mix by itself and ✦ saves it. Then a Today row names the one rank move that closes the most gap. ✦ makes that rank move and Undo…",
|
|
54
|
+
"open": "/today.html"
|
|
55
|
+
},
|
|
56
|
+
"i": "balance-rebalance"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"v": "0.848.0",
|
|
62
|
+
"at": "2026-11-25T18:33:59.152Z",
|
|
63
|
+
"f": 4,
|
|
64
|
+
"prs": [
|
|
65
|
+
{
|
|
66
|
+
"n": 2037,
|
|
67
|
+
"t": "Pmos change-request records a stakeholder's ask with what it would break (job #2024)",
|
|
68
|
+
"s": "Pmos change-request records a stakeholder's ask with what it would break (job #2024)",
|
|
69
|
+
"k": "new",
|
|
70
|
+
"i": "change-requests",
|
|
71
|
+
"h": "Pmos change-request records a stakeholder's ask with what it would break (job #2024)",
|
|
72
|
+
"try": {
|
|
73
|
+
"steps": [
|
|
74
|
+
"On Today, find the row in Your move for an open change request: who asked, what they asked and what it would break",
|
|
75
|
+
"Press its ✦ to approve, then press Undo",
|
|
76
|
+
"Open the chat (Ask PMOS). On a desk the chat opens from the menu button at the bottom left, then the speech bubble. Say: Dana asks to move…"
|
|
77
|
+
],
|
|
78
|
+
"see": "Each open change request is a Today row by itself, naming who asked and what it would break. Approve records your answer and Undo takes it back. A new ask from the chat is recorded with an id and…",
|
|
79
|
+
"open": "/today.html"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
36
84
|
{
|
|
37
85
|
"v": "0.847.0",
|
|
38
86
|
"at": "2026-11-25T18:22:14.213Z",
|
|
@@ -49,6 +97,7 @@
|
|
|
49
97
|
"t": "One RAID list per initiative, read from its own records (A101)",
|
|
50
98
|
"s": "One RAID list per initiative, read from its own records (A101)",
|
|
51
99
|
"k": "new",
|
|
100
|
+
"i": "raid-fold",
|
|
52
101
|
"h": "One RAID list per initiative, read from its own records (A101)",
|
|
53
102
|
"try": {
|
|
54
103
|
"steps": [
|
|
@@ -58,24 +107,14 @@
|
|
|
58
107
|
],
|
|
59
108
|
"see": "The Overview has one RAID line, for example '2 of 5 have not moved in 14 days: Late: Ship the copy (due 12 Nov)'. An initiative where everything moved has no RAID line. The chat shows each risk,…",
|
|
60
109
|
"open": "/premium-board.html"
|
|
61
|
-
}
|
|
62
|
-
"i": "raid-fold"
|
|
110
|
+
}
|
|
63
111
|
},
|
|
64
112
|
{
|
|
65
113
|
"n": 2044,
|
|
66
114
|
"t": "Work checks for new rows instead of re-reading the board every 2 s",
|
|
67
115
|
"s": "Work checks for new rows instead of re-reading the board every 2 s",
|
|
68
116
|
"k": "imp",
|
|
69
|
-
"i": "page-open-200ms"
|
|
70
|
-
"try": {
|
|
71
|
-
"steps": [
|
|
72
|
-
"Open Today, then Work, then an initiative from Work.",
|
|
73
|
-
"Change something on the initiative (a task title), wait a second, then open Work again.",
|
|
74
|
-
"Open the same initiative again."
|
|
75
|
-
],
|
|
76
|
-
"see": "each page shows its rows at once, in about the blink of an eye; the change you made shows on Work and on the initiative.",
|
|
77
|
-
"open": "/premium-board.html"
|
|
78
|
-
}
|
|
117
|
+
"i": "page-open-200ms"
|
|
79
118
|
}
|
|
80
119
|
]
|
|
81
120
|
},
|
|
@@ -1010,102 +1049,6 @@
|
|
|
1010
1049
|
}
|
|
1011
1050
|
}
|
|
1012
1051
|
]
|
|
1013
|
-
},
|
|
1014
|
-
{
|
|
1015
|
-
"v": "0.825.0",
|
|
1016
|
-
"at": "2026-11-25T10:33:55.582Z",
|
|
1017
|
-
"f": 4,
|
|
1018
|
-
"prs": [
|
|
1019
|
-
{
|
|
1020
|
-
"n": 1939,
|
|
1021
|
-
"t": "Settings › What PMOS does alone, one read-only table of each kind of action (A513)",
|
|
1022
|
-
"s": "Settings › What PMOS does alone, one read-only table of each kind of action (A513)",
|
|
1023
|
-
"k": "new",
|
|
1024
|
-
"i": "does-alone"
|
|
1025
|
-
},
|
|
1026
|
-
{
|
|
1027
|
-
"n": 1949,
|
|
1028
|
-
"t": "Names in a Today line link to the person, meeting or document (job #1915, A536)",
|
|
1029
|
-
"s": "Names in a Today line link to the person, meeting or document (job #1915, A536)",
|
|
1030
|
-
"k": "new",
|
|
1031
|
-
"i": "name-links",
|
|
1032
|
-
"h": "Names in a Today line link to the person, meeting or document (job #1915, A536)",
|
|
1033
|
-
"try": {
|
|
1034
|
-
"steps": [
|
|
1035
|
-
"Open Today",
|
|
1036
|
-
"In the capture line type a line that names a person from People or a meeting you took notes in, for example 'Follow up on Azhar's notes…",
|
|
1037
|
-
"Point at or tap the underlined name"
|
|
1038
|
-
],
|
|
1039
|
-
"see": "The names that match one record are underlined. A small card shows the record (a meeting's date, people and notes) with one press: Open the notes, Open the document, or Ask PMOS about the person. A…",
|
|
1040
|
-
"open": "/today.html"
|
|
1041
|
-
}
|
|
1042
|
-
},
|
|
1043
|
-
{
|
|
1044
|
-
"n": 1953,
|
|
1045
|
-
"t": "What each connector reads and writes (job #1920, A150)",
|
|
1046
|
-
"s": "What each connector reads and writes (job #1920, A150)",
|
|
1047
|
-
"k": "new",
|
|
1048
|
-
"i": "connector-data",
|
|
1049
|
-
"h": "What each connector reads and writes (job #1920, A150)",
|
|
1050
|
-
"try": {
|
|
1051
|
-
"steps": [
|
|
1052
|
-
"On Today, open Settings from the rail and go to Connectors.",
|
|
1053
|
-
"Read the one line under Jira (or any connector you have).",
|
|
1054
|
-
"Press the arrow on that row to open its page."
|
|
1055
|
-
],
|
|
1056
|
-
"see": "Each connected row says in one line what PMOS reads and writes. The page shows What PMOS reads, What PMOS writes and What leaves this computer, with a switch only where PMOS can really stop the read.",
|
|
1057
|
-
"open": "/today.html"
|
|
1058
|
-
}
|
|
1059
|
-
},
|
|
1060
|
-
{
|
|
1061
|
-
"n": 1941,
|
|
1062
|
-
"t": "Hold the phone chat mic to talk (job #1891, A13)",
|
|
1063
|
-
"s": "Hold the phone chat mic to talk (job #1891, A13)",
|
|
1064
|
-
"k": "new",
|
|
1065
|
-
"i": "hold-to-talk",
|
|
1066
|
-
"h": "Hold the phone chat mic to talk (job #1891, A13)",
|
|
1067
|
-
"try": {
|
|
1068
|
-
"steps": [
|
|
1069
|
-
"On a phone, open Today and its chat.",
|
|
1070
|
-
"Press and hold the mic, say what to change (for example: move <one of your tasks> a day), and let go.",
|
|
1071
|
-
"Press Undo under PMOS's answer, then hold again and slide left before letting go."
|
|
1072
|
-
],
|
|
1073
|
-
"see": "Your words show above the mic while you hold it; letting go sends them like typing, so the change is done with Undo (a question gets an answer); sliding left cancels and nothing is sent.",
|
|
1074
|
-
"open": "/today.html"
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
|
-
]
|
|
1078
|
-
},
|
|
1079
|
-
{
|
|
1080
|
-
"v": "0.824.0",
|
|
1081
|
-
"at": "2026-11-25T09:50:46.868Z",
|
|
1082
|
-
"f": 4,
|
|
1083
|
-
"prs": [
|
|
1084
|
-
{
|
|
1085
|
-
"n": 1945,
|
|
1086
|
-
"t": "Job-graph lists report-variants, so main is green again",
|
|
1087
|
-
"s": "Job-graph lists report-variants, so main is green again",
|
|
1088
|
-
"k": "fix",
|
|
1089
|
-
"i": "report-three-audiences"
|
|
1090
|
-
},
|
|
1091
|
-
{
|
|
1092
|
-
"n": 1922,
|
|
1093
|
-
"t": "Balance meter on Work's Initiatives and Backlog lists (job #1859, board BalanceDS)",
|
|
1094
|
-
"s": "Balance meter on Work's Initiatives and Backlog lists (job #1859, board BalanceDS)",
|
|
1095
|
-
"k": "new",
|
|
1096
|
-
"i": "balance-meter",
|
|
1097
|
-
"h": "Balance meter on Work's Initiatives and Backlog lists (job #1859, board BalanceDS)",
|
|
1098
|
-
"try": {
|
|
1099
|
-
"steps": [
|
|
1100
|
-
"Open Work and look under the Initiatives header",
|
|
1101
|
-
"Press a kind in the bar's legend, then press it again",
|
|
1102
|
-
"Open the Backlog tab in Work and look under its header"
|
|
1103
|
-
],
|
|
1104
|
-
"see": "On Work, the bar and its counts sit under each list header, largest first. A press shows only that kind, and a second press shows all of them again. A ✦ note shows only when one kind is over 60% of…",
|
|
1105
|
-
"open": "/premium-board.html"
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
]
|
|
1109
1052
|
}
|
|
1110
1053
|
]
|
|
1111
1054
|
}
|
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-25T18:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-25T18:55:46Z"}
|
|
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-25T18:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-25T18:55:46Z"}
|
|
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-25T18:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-25T18:55:46Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,52 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.849.0",
|
|
4
|
+
"at": "2026-11-25T18:55:50.990Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 2057,
|
|
9
|
+
"t": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
|
|
10
|
+
"s": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
|
|
11
|
+
"k": "new",
|
|
12
|
+
"h": "A target mix for the roadmap and the rank move that closes the gap (job #2051)",
|
|
13
|
+
"try": {
|
|
14
|
+
"steps": [
|
|
15
|
+
"On Today, find the row in Your move that proposes a target mix for the top of your roadmap, drawn from the roadmap itself. Press its ✦ to…",
|
|
16
|
+
"The row then names the rank move that closes the most gap. Press its ✦, check the Roadmap on Work, then press Undo",
|
|
17
|
+
"Open the chat (Ask PMOS). On a desk the chat opens from the menu button at the bottom left, then the speech bubble. Say: set my roadmap…"
|
|
18
|
+
],
|
|
19
|
+
"see": "When the top of the roadmap leans one way, Today proposes a target mix by itself and ✦ saves it. Then a Today row names the one rank move that closes the most gap. ✦ makes that rank move and Undo…",
|
|
20
|
+
"open": "/today.html"
|
|
21
|
+
},
|
|
22
|
+
"i": "balance-rebalance"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"v": "0.848.0",
|
|
28
|
+
"at": "2026-11-25T18:33:59.152Z",
|
|
29
|
+
"f": 4,
|
|
30
|
+
"prs": [
|
|
31
|
+
{
|
|
32
|
+
"n": 2037,
|
|
33
|
+
"t": "Pmos change-request records a stakeholder's ask with what it would break (job #2024)",
|
|
34
|
+
"s": "Pmos change-request records a stakeholder's ask with what it would break (job #2024)",
|
|
35
|
+
"k": "new",
|
|
36
|
+
"i": "change-requests",
|
|
37
|
+
"h": "Pmos change-request records a stakeholder's ask with what it would break (job #2024)",
|
|
38
|
+
"try": {
|
|
39
|
+
"steps": [
|
|
40
|
+
"On Today, find the row in Your move for an open change request: who asked, what they asked and what it would break",
|
|
41
|
+
"Press its ✦ to approve, then press Undo",
|
|
42
|
+
"Open the chat (Ask PMOS). On a desk the chat opens from the menu button at the bottom left, then the speech bubble. Say: Dana asks to move…"
|
|
43
|
+
],
|
|
44
|
+
"see": "Each open change request is a Today row by itself, naming who asked and what it would break. Approve records your answer and Undo takes it back. A new ask from the chat is recorded with an id and…",
|
|
45
|
+
"open": "/today.html"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
2
50
|
{
|
|
3
51
|
"v": "0.847.0",
|
|
4
52
|
"at": "2026-11-25T18:22:14.213Z",
|
|
@@ -15,6 +63,7 @@
|
|
|
15
63
|
"t": "One RAID list per initiative, read from its own records (A101)",
|
|
16
64
|
"s": "One RAID list per initiative, read from its own records (A101)",
|
|
17
65
|
"k": "new",
|
|
66
|
+
"i": "raid-fold",
|
|
18
67
|
"h": "One RAID list per initiative, read from its own records (A101)",
|
|
19
68
|
"try": {
|
|
20
69
|
"steps": [
|
|
@@ -24,24 +73,14 @@
|
|
|
24
73
|
],
|
|
25
74
|
"see": "The Overview has one RAID line, for example '2 of 5 have not moved in 14 days: Late: Ship the copy (due 12 Nov)'. An initiative where everything moved has no RAID line. The chat shows each risk,…",
|
|
26
75
|
"open": "/premium-board.html"
|
|
27
|
-
}
|
|
28
|
-
"i": "raid-fold"
|
|
76
|
+
}
|
|
29
77
|
},
|
|
30
78
|
{
|
|
31
79
|
"n": 2044,
|
|
32
80
|
"t": "Work checks for new rows instead of re-reading the board every 2 s",
|
|
33
81
|
"s": "Work checks for new rows instead of re-reading the board every 2 s",
|
|
34
82
|
"k": "imp",
|
|
35
|
-
"i": "page-open-200ms"
|
|
36
|
-
"try": {
|
|
37
|
-
"steps": [
|
|
38
|
-
"Open Today, then Work, then an initiative from Work.",
|
|
39
|
-
"Change something on the initiative (a task title), wait a second, then open Work again.",
|
|
40
|
-
"Open the same initiative again."
|
|
41
|
-
],
|
|
42
|
-
"see": "each page shows its rows at once, in about the blink of an eye; the change you made shows on Work and on the initiative.",
|
|
43
|
-
"open": "/premium-board.html"
|
|
44
|
-
}
|
|
83
|
+
"i": "page-open-200ms"
|
|
45
84
|
}
|
|
46
85
|
]
|
|
47
86
|
},
|
package/workspace/guide/cli.md
CHANGED
|
@@ -536,6 +536,16 @@ See if a list leans too far one way, for example all features and no fixes. PMOS
|
|
|
536
536
|
- A note shows only when one kind is more than your line of the list, and the list has 5 or more items. The line is 60% unless `--max <percent>` says otherwise. `--json` prints the counts as JSON.
|
|
537
537
|
- Work shows the same mix as a thin bar under the header of the **Initiatives** list and of the **Backlog**. Press a kind in its legend to show only those items.
|
|
538
538
|
|
|
539
|
+
### pmos balance target: a target mix for the roadmap
|
|
540
|
+
|
|
541
|
+
Say the mix you want at the top of the roadmap, and see which rank move gets you closer to it. PMOS never moves a rank by itself.
|
|
542
|
+
|
|
543
|
+
- `pmos balance target feature:50,fix:30,debt:20` saves the mix you want for the first 6 ranked initiatives of this repository. `--front <N>` sets another number. The kinds are feature, fix, debt, discovery and other, and the parts must add up to 100.
|
|
544
|
+
- `pmos balance target` shows the saved target. `pmos balance target --undo` puts the previous target back, and `pmos balance target --clear` removes it.
|
|
545
|
+
- `pmos balance gap` shows the mix of the top of the roadmap beside the target, and the gap in points (half the sum of the differences). It names at most 2 rank moves that close the most gap: an initiative of a kind under its target, from below the top, moved above one of a kind over its target. Each move is a `pmos initiative after` or `pmos initiative top` command, with the command that undoes it. `--json` prints the same as JSON.
|
|
546
|
+
- When the top of the roadmap is 15 points or more from the target and a move closes some of the gap, Today shows the best move in **Your move**. Press ✦ to make the move, and Undo to put the initiative back.
|
|
547
|
+
- With no target saved, Today can propose one in **Your move**: the mix of your whole roadmap, with the largest kind at most 60%, in steps of 10. It shows only when the top of the roadmap is 15 points or more from that mix and a rank move would help. Press ✦ to save it, and Undo to take it back.
|
|
548
|
+
|
|
539
549
|
### pmos decisions: a decision journal
|
|
540
550
|
|
|
541
551
|
Write one line for each product decision, also one that is smaller than an initiative. Each decision has an expected outcome and a date to check it. Run the commands in the product's repository, or pass `--root <dir>`. The journal is `decision-journal.jsonl` in the runs folder (`pmos/state/` in a product, `planning/runs/` in PMOS itself). Commit it to keep it.
|
|
@@ -688,6 +698,17 @@ Once a week Today shows how many initiatives had no change in 30 days or more. T
|
|
|
688
698
|
|
|
689
699
|
Every command takes `--json` and `--root <repository>`. Exit codes: 0 done, 1 off or refused, 2 usage.
|
|
690
700
|
|
|
701
|
+
### pmos change-request: record a stakeholder's ask
|
|
702
|
+
|
|
703
|
+
- `pmos change-request add <initiative> "<ask>" --from <name>` — records the ask, who asked and the initiative. Add the change it asks for and PMOS works out what it would break or help, each effect with its source: `--end YYYY-MM-DD` (the initiative's end), `--move <task> --by <days>` (or `--start` / `--due`), or `--cut [task]` (the whole initiative, or one task).
|
|
704
|
+
- `pmos change-request decide <id> approve|reject [--note "…"]` — records the PM's answer. Approve records the answer only: make the change with `pmos task set` or `pmos task state`.
|
|
705
|
+
- `pmos change-request undo <id>` — takes the last answer back. The request is open again.
|
|
706
|
+
- `pmos change-request list [--all]` — open requests first. `--all` shows the answered ones too.
|
|
707
|
+
- `pmos change-request show <id>` — the ask, its effects with their sources, and the answer.
|
|
708
|
+
- `pmos change-request count [--days N]` — the requests recorded in the last N days (7).
|
|
709
|
+
|
|
710
|
+
A change request never changes a date, a task or an initiative, and PMOS sends nothing. Every command takes `--json`. Exit codes: 0 done, 1 refused, 2 usage.
|
|
711
|
+
|
|
691
712
|
### pmos metrics: metric drafts and readings
|
|
692
713
|
|
|
693
714
|
PMOS's background run files its drafts with these commands. The server pins the product, program or initiative and the run, so the commands refuse outside that run. You keep and drop drafts on the page.
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* pmos balance show [--by kind|outcome] [--max <percent>] [--json] the roadmap: the live initiatives of this repository
|
|
5
5
|
* pmos balance show --file <items.json> [--by …] [--max …] [--json] any list: a JSON array of items (ideas, backlog tasks), each with
|
|
6
6
|
* its own kind, lane or type field, and an outcome field
|
|
7
|
+
* pmos balance target [<kind>:<pct>,…] [--front N] [--undo | --clear] [--json] the mix you want at the top of the roadmap (balance-rebalance)
|
|
8
|
+
* pmos balance gap [--json] how far the top of the roadmap is from it, and the 1-2 rank moves
|
|
9
|
+
* that close the most gap (lib/balance-target.js)
|
|
7
10
|
* every command: [--root <dir>] (default: this repository)
|
|
8
11
|
*
|
|
9
12
|
* It prints the counts, one bar of the mix, and a quiet note only when one kind passes the line (default 60%). Each run writes one
|
|
@@ -13,15 +16,19 @@ const fs = require('fs');
|
|
|
13
16
|
const path = require('path');
|
|
14
17
|
const B = require('./list-balance.js');
|
|
15
18
|
|
|
16
|
-
const COMMANDS = { balance: ['show'] };
|
|
19
|
+
const COMMANDS = { balance: ['show', 'target', 'gap'] };
|
|
17
20
|
const USAGE = [
|
|
18
21
|
'usage: pmos balance show — the mix of a list in one line: feature, fix, debt, discovery, or with and without an expected outcome',
|
|
19
22
|
' pmos balance show [--by kind|outcome] [--max <percent>] [--json] the roadmap: the live initiatives of this repository',
|
|
20
23
|
' pmos balance show --file <items.json> [--by kind|outcome] [--json] any list: a JSON array of items with a kind, lane or type field',
|
|
24
|
+
' pmos balance target feature:50,fix:30,debt:20 [--front 6] save the mix you want for the first N ranked initiatives',
|
|
25
|
+
' pmos balance target [--undo | --clear] show it, put the previous one back, or remove it',
|
|
26
|
+
' pmos balance gap how far the top of the roadmap is from the target, and the rank moves that close it',
|
|
21
27
|
'A note shows only when one kind is over the line (--max, default 60%). Run it in the product\'s repository, or pass --root <dir>.',
|
|
28
|
+
'PMOS never moves a rank by itself: gap names the move, and you make it with pmos initiative after|top.',
|
|
22
29
|
];
|
|
23
|
-
const ALLOWED = ['json', 'root', 'by', 'max', 'file'];
|
|
24
|
-
const BOOL = new Set(['json']);
|
|
30
|
+
const ALLOWED = { show: ['json', 'root', 'by', 'max', 'file'], target: ['json', 'root', 'front', 'undo', 'clear'], gap: ['json', 'root'] };
|
|
31
|
+
const BOOL = new Set(['json', 'undo', 'clear']);
|
|
25
32
|
|
|
26
33
|
function parse(args) {
|
|
27
34
|
const pos = [], flags = {};
|
|
@@ -56,14 +63,15 @@ function bar(R) {
|
|
|
56
63
|
return R.parts.map((p, i) => (GLYPH[p.key] || '·').repeat(cells[i])).join('');
|
|
57
64
|
}
|
|
58
65
|
|
|
59
|
-
async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), log = (s) => console.error(s) } = {}) {
|
|
66
|
+
async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), log = (s) => console.error(s), env = process.env, stateDir = null, actor = null } = {}) {
|
|
60
67
|
const args = argv[0] === 'balance' ? argv.slice(1) : argv.slice();
|
|
61
68
|
const sub = args[0];
|
|
62
69
|
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
|
|
63
70
|
if (!COMMANDS.balance.includes(sub)) { say(`unknown balance command "${sub}". Use one of: ${COMMANDS.balance.join(', ')}`); return 2; }
|
|
64
71
|
const { pos, flags } = parse(args.slice(1));
|
|
65
|
-
for (const k of Object.keys(flags)) if (!ALLOWED.includes(k)) { say(`✗ --${k} is not an option of pmos balance ${sub}`); return 2; }
|
|
72
|
+
for (const k of Object.keys(flags)) if (!ALLOWED[sub].includes(k)) { say(`✗ --${k} is not an option of pmos balance ${sub}`); return 2; }
|
|
66
73
|
const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
|
|
74
|
+
if (sub === 'target' || sub === 'gap') return targetRun(sub, pos, flags, { say, cwd, log, env, stateDir, actor, fail });
|
|
67
75
|
if (pos.length) return fail('usage: pmos balance show [--by kind|outcome] [--file <items.json>]', 2);
|
|
68
76
|
if (flags.by !== undefined && !['kind', 'outcome'].includes(flags.by)) return fail('--by is kind or outcome', 2);
|
|
69
77
|
if (flags.max !== undefined && !(Number(flags.max) > 0 && Number(flags.max) < 100)) return fail('--max is a percent between 1 and 99', 2);
|
|
@@ -86,4 +94,49 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), log
|
|
|
86
94
|
return 0;
|
|
87
95
|
}
|
|
88
96
|
|
|
97
|
+
/** `pmos balance target` and `pmos balance gap` (initiative balance-rebalance): lib/balance-target.js does the work. */
|
|
98
|
+
function targetRun(sub, pos, flags, { say, cwd, log, env, stateDir, actor, fail }) {
|
|
99
|
+
const T = require('./balance-target.js');
|
|
100
|
+
const root = path.resolve(flags.root || repoRoot(cwd));
|
|
101
|
+
const runtime = stateDir || require('./state-root.js').defaultRoot({ env });
|
|
102
|
+
const by = (actor || require('./actor.js').fromCli({ env })).by;
|
|
103
|
+
const json = !!flags.json;
|
|
104
|
+
const done = (o, text) => { if (json) say(JSON.stringify({ ok: true, ...o })); else for (const l of text) say(l); return 0; };
|
|
105
|
+
const savedWords = (s) => s ? `${T.mixWords(s.target)} for the top ${s.front} of the roadmap` : 'none';
|
|
106
|
+
if (sub === 'target') {
|
|
107
|
+
if (flags.undo && flags.clear) return fail('--undo or --clear, not both', 2);
|
|
108
|
+
if ((flags.undo || flags.clear) && (pos.length || flags.front !== undefined)) return fail(`--${flags.undo ? 'undo' : 'clear'} takes no mix`, 2);
|
|
109
|
+
if (pos.length > 1) return fail('usage: pmos balance target feature:50,fix:30,debt:20 [--front 6]', 2);
|
|
110
|
+
if (flags.undo || flags.clear) {
|
|
111
|
+
const r = flags.undo ? T.undoTarget(runtime, root, { by }) : T.clearTarget(runtime, root, { by });
|
|
112
|
+
if (!r.ok) return fail(r.error);
|
|
113
|
+
return done({ target: r.saved }, [flags.undo ? `✓ Target put back: ${savedWords(r.saved)}.` : '✓ Target removed. pmos balance target --undo puts it back.']);
|
|
114
|
+
}
|
|
115
|
+
if (!pos.length) {
|
|
116
|
+
if (flags.front !== undefined) return fail('--front goes with a mix, e.g. pmos balance target feature:50,fix:50 --front 8', 2);
|
|
117
|
+
const s = T.targetOf(runtime, root);
|
|
118
|
+
return done({ target: s }, [s ? `Target: ${savedWords(s)}.` : 'No target yet. Save one: pmos balance target feature:50,fix:30,debt:20']);
|
|
119
|
+
}
|
|
120
|
+
const p = T.parseTarget(pos[0]);
|
|
121
|
+
if (!p.ok) return fail(p.error, 2);
|
|
122
|
+
const r = T.setTarget(runtime, root, p.target, { front: flags.front === undefined ? undefined : Number(flags.front), by });
|
|
123
|
+
if (!r.ok) return fail(r.error, 2);
|
|
124
|
+
const g = T.gapOf(T.ranked(root), r.saved.target, r.saved.front);
|
|
125
|
+
return done({ target: r.saved, gap: g.gap }, [`✓ Target saved: ${savedWords(r.saved)}.`, `The top of the roadmap is ${g.gap} points from it. pmos balance gap names the moves. Undo: pmos balance target --undo`]);
|
|
126
|
+
}
|
|
127
|
+
// gap
|
|
128
|
+
if (pos.length) return fail('usage: pmos balance gap', 2);
|
|
129
|
+
const s = T.targetOf(runtime, root);
|
|
130
|
+
if (!s) return done({ target: null, gap: null, moves: [] }, ['No target yet. Save one: pmos balance target feature:50,fix:30,debt:20']);
|
|
131
|
+
T.used(runtime, root, 'gap');
|
|
132
|
+
try { log(`${B.TAG} gap`); } catch { /* no log */ }
|
|
133
|
+
const list = T.ranked(root), g = T.gapOf(list, s.target, s.front), moves = T.movesOf(list, s.target, s.front);
|
|
134
|
+
const out = [`Top ${g.front.length} of the roadmap: ${T.mixWords(g.mix)}. Target: ${T.mixWords(s.target)}.`, `Gap: ${g.gap} point${g.gap === 1 ? '' : 's'}.`];
|
|
135
|
+
if (!g.gap) out.push('On target.');
|
|
136
|
+
else if (!moves.length) out.push('No rank move closes it: no initiative of an under-target kind waits below the top.');
|
|
137
|
+
else for (const m of moves) out.push(`✦ Move ${m.id} (${B.KIND_LABEL[m.kind]}) above ${m.above}: the gap goes to ${m.gapAfter}. ${m.cli} · Undo: ${m.undo}`);
|
|
138
|
+
if (moves.length) out.push('Nothing moved. Make a move with its command.');
|
|
139
|
+
return done({ target: s, mix: g.mix, gap: g.gap, front: g.front.map((x) => x.id), moves, moved: false }, out);
|
|
140
|
+
}
|
|
141
|
+
|
|
89
142
|
module.exports = { run, COMMANDS, USAGE, bar };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* balance-target.js — a target mix for the roadmap, and the rank move that closes the most gap (initiative balance-rebalance, bet A65,
|
|
3
|
+
* job #2051). `pmos balance target|gap` (lib/balance-cli.js) is its CLI; lib/list-balance.js gives the kind of each initiative.
|
|
4
|
+
*
|
|
5
|
+
* parseTarget('feature:50,fix:30,debt:20') → { ok, target: { feature: 50, fix: 30, debt: 20 } } | { ok: false, error }
|
|
6
|
+
* known kinds only (list-balance KINDS), whole percents, adding up to 100.
|
|
7
|
+
* setTarget(runtime, root, target, { front, by }) · clearTarget(runtime, root, { by }) · undoTarget(runtime, root, { by })
|
|
8
|
+
* append-only `<runtime>/balance-targets.jsonl`; one line per write. Undo takes the last set or clear back.
|
|
9
|
+
* targetOf(runtime, root) → { target, front, at, by } | null
|
|
10
|
+
* ranked(root) → [{ id, title, kind }] the live initiatives in Roadmap order (D105), finished ones left out
|
|
11
|
+
* gapOf(list, target, front) → { front: [...], mix: { kind: pct }, gap } gap = half the sum of |actual − target|, in points
|
|
12
|
+
* movesOf(list, target, front, { max }) → the best rank moves, at most `max` (2): an under-target initiative from below the front
|
|
13
|
+
* moved just above an over-target one in it. Each: { id, above, kind, pushes, gapAfter, closes, cli, undo }. Only moves that close gap.
|
|
14
|
+
* count(runtime, { days }) → target and gap uses recorded in the last N days (the health number)
|
|
15
|
+
* needs provider (lib/needs-providers.js): kinds ['balance-gap'] · rowsFor(w, { lead }) · sig(w)
|
|
16
|
+
* one Today row (kind 7) when a target is saved, the front is ROW_GAP points or more off it, and a move closes some of the gap.
|
|
17
|
+
* Its ✦ is the rank move (`pmos initiative after|top`), with Undo.
|
|
18
|
+
* With no target saved: one row (kind 7) that proposes a target drawn from the roadmap (proposeTarget), when the front is
|
|
19
|
+
* ROW_GAP points or more off that proposal and a move would close some of it. Its ✦ saves the proposal (`pmos balance target …`),
|
|
20
|
+
* with Undo (`pmos balance target --undo`). Otherwise no row.
|
|
21
|
+
* proposeTarget(list, front) → { feature: 60, fix: 30, … } | null the mix of the whole live roadmap, the largest kind
|
|
22
|
+
* capped at the balance line (60%) and the rest given to the other kinds it holds, in steps of 10. null when it holds one kind.
|
|
23
|
+
*
|
|
24
|
+
* Reading writes nothing in the repository. Nothing here moves a rank by itself or sends anything: a move is a command the PM presses.
|
|
25
|
+
*/
|
|
26
|
+
const fs = require('fs');
|
|
27
|
+
const path = require('path');
|
|
28
|
+
const B = require('./list-balance.js');
|
|
29
|
+
|
|
30
|
+
const FILE = 'balance-targets.jsonl';
|
|
31
|
+
const DEFAULT_FRONT = 6;
|
|
32
|
+
const ROW_GAP = 15;
|
|
33
|
+
const KIND = 'balance-gap';
|
|
34
|
+
const fileOf = (runtime) => path.join(runtime, FILE);
|
|
35
|
+
const log = (s) => { try { process.stderr.write('[balance] ' + s + '\n'); } catch { /* a closed stream */ } };
|
|
36
|
+
|
|
37
|
+
function lines(runtime) {
|
|
38
|
+
let raw = '';
|
|
39
|
+
try { raw = fs.readFileSync(fileOf(runtime), 'utf8'); } catch { return []; }
|
|
40
|
+
const out = [];
|
|
41
|
+
for (const l of raw.split('\n')) { if (!l.trim()) continue; try { out.push(JSON.parse(l)); } catch { /* a torn line */ } }
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
function append(runtime, line) {
|
|
45
|
+
fs.mkdirSync(runtime, { recursive: true });
|
|
46
|
+
fs.appendFileSync(fileOf(runtime), JSON.stringify({ at: new Date().toISOString(), ...line }) + '\n');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function parseTarget(text) {
|
|
50
|
+
const s = String(text == null ? '' : text).trim();
|
|
51
|
+
if (!s) return { ok: false, error: 'say the mix, e.g. feature:50,fix:30,debt:20' };
|
|
52
|
+
const target = {};
|
|
53
|
+
for (const part of s.split(/[,\s]+/).filter(Boolean)) {
|
|
54
|
+
const m = /^([a-z-]+)[:=](\d{1,3})%?$/i.exec(part);
|
|
55
|
+
if (!m) return { ok: false, error: `"${part}" is not kind:percent, e.g. feature:50` };
|
|
56
|
+
const k = m[1].toLowerCase();
|
|
57
|
+
if (!B.KINDS.includes(k)) return { ok: false, error: `${k} is not a kind. Use ${B.KINDS.join(', ')}` };
|
|
58
|
+
if (k in target) return { ok: false, error: `${k} is named twice` };
|
|
59
|
+
target[k] = Number(m[2]);
|
|
60
|
+
}
|
|
61
|
+
const sum = Object.values(target).reduce((a, b) => a + b, 0);
|
|
62
|
+
if (sum !== 100) return { ok: false, error: `the parts add up to ${sum}, not 100` };
|
|
63
|
+
return { ok: true, target };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const keyOf = (root) => path.resolve(root);
|
|
67
|
+
/** The saved target of a repository, folded from its lines: each set or clear is a state; undo takes the last one back. */
|
|
68
|
+
function targetOf(runtime, root) {
|
|
69
|
+
const at = keyOf(root), stack = [];
|
|
70
|
+
for (const l of lines(runtime)) {
|
|
71
|
+
if (l.root !== at) continue;
|
|
72
|
+
if (l.ev === 'set') stack.push({ target: l.target, front: l.front || DEFAULT_FRONT, at: l.at, by: l.by });
|
|
73
|
+
else if (l.ev === 'clear') stack.push(null);
|
|
74
|
+
else if (l.ev === 'undo') stack.pop();
|
|
75
|
+
}
|
|
76
|
+
return stack.length ? stack[stack.length - 1] : null;
|
|
77
|
+
}
|
|
78
|
+
function writes(runtime, root) { return lines(runtime).filter((l) => l.root === keyOf(root) && ['set', 'clear'].includes(l.ev)).length - lines(runtime).filter((l) => l.root === keyOf(root) && l.ev === 'undo').length; }
|
|
79
|
+
|
|
80
|
+
function setTarget(runtime, root, target, { front, by } = {}) {
|
|
81
|
+
const f = front == null ? DEFAULT_FRONT : Number(front);
|
|
82
|
+
if (!Number.isInteger(f) || f < 2 || f > 50) return { ok: false, error: '--front is a whole number from 2 to 50' };
|
|
83
|
+
append(runtime, { ev: 'set', root: keyOf(root), target, front: f, by: by || 'agent:unknown' });
|
|
84
|
+
log(`target set ${Object.entries(target).map(([k, v]) => k + ':' + v).join(',')} front ${f}`);
|
|
85
|
+
return { ok: true, saved: targetOf(runtime, root) };
|
|
86
|
+
}
|
|
87
|
+
function clearTarget(runtime, root, { by } = {}) {
|
|
88
|
+
if (!targetOf(runtime, root)) return { ok: false, error: 'no target is saved for this repository' };
|
|
89
|
+
append(runtime, { ev: 'clear', root: keyOf(root), by: by || 'agent:unknown' });
|
|
90
|
+
log('target clear');
|
|
91
|
+
return { ok: true, saved: null };
|
|
92
|
+
}
|
|
93
|
+
function undoTarget(runtime, root, { by } = {}) {
|
|
94
|
+
if (writes(runtime, root) <= 0) return { ok: false, error: 'no target change to take back' };
|
|
95
|
+
append(runtime, { ev: 'undo', root: keyOf(root), by: by || 'agent:unknown' });
|
|
96
|
+
log('target undo');
|
|
97
|
+
return { ok: true, saved: targetOf(runtime, root) };
|
|
98
|
+
}
|
|
99
|
+
/** One use of `gap` (target writes count by themselves). */
|
|
100
|
+
function used(runtime, root, what) { try { append(runtime, { ev: 'use', root: keyOf(root), what }); } catch { /* a read-only runtime */ } }
|
|
101
|
+
function count(runtime, { days = 7, now = Date.now() } = {}) {
|
|
102
|
+
const since = now - days * 86400000;
|
|
103
|
+
return lines(runtime).filter((l) => ['set', 'clear', 'undo', 'use'].includes(l.ev) && Date.parse(l.at) >= since).length;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The live initiatives of a repository in Roadmap order (one ranked list, D105). Finished ones are left out. */
|
|
107
|
+
function ranked(root) {
|
|
108
|
+
const rowsLib = require('./initiative-rows.js'), P = require('./placements.js'), PR = require('./plan-rules.js');
|
|
109
|
+
const d = rowsLib.deriveSync(root);
|
|
110
|
+
if (!d.ok) return [];
|
|
111
|
+
const rows = new Map(d.rows.map((r) => [r.id, r]));
|
|
112
|
+
const placed = P.readPlacements(root, { now: Date.now(), rules: PR.readRules(root), records: d.rows });
|
|
113
|
+
return placed.ranked.map((id) => rows.get(id)).filter((r) => r && !r.accepted && !r.stopped)
|
|
114
|
+
.map((r) => ({ id: r.id, title: r.title || r.id, kind: B.kindOf(r) }));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function gapOf(list, target, front = DEFAULT_FRONT) {
|
|
118
|
+
const f = (list || []).slice(0, front), n = f.length;
|
|
119
|
+
const mix = Object.fromEntries(B.KINDS.map((k) => [k, n ? Math.round((f.filter((x) => x.kind === k).length / n) * 100) : 0]));
|
|
120
|
+
const exact = (k) => (n ? (f.filter((x) => x.kind === k).length / n) * 100 : 0);
|
|
121
|
+
const gap = n ? Math.round(B.KINDS.reduce((s, k) => s + Math.abs(exact(k) - (target[k] || 0)), 0) / 2) : 0;
|
|
122
|
+
return { front: f, mix, gap };
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function movesOf(list, target, front = DEFAULT_FRONT, { max = 2 } = {}) {
|
|
126
|
+
const L = list || [];
|
|
127
|
+
if (L.length <= front) return [];
|
|
128
|
+
const now = gapOf(L, target, front), n = now.front.length;
|
|
129
|
+
const share = (k) => (now.front.filter((x) => x.kind === k).length / n) * 100;
|
|
130
|
+
const under = (k) => share(k) < (target[k] || 0), over = (k) => share(k) > (target[k] || 0);
|
|
131
|
+
const best = new Map();
|
|
132
|
+
for (let ui = front; ui < L.length; ui++) {
|
|
133
|
+
const u = L[ui];
|
|
134
|
+
if (!under(u.kind)) continue;
|
|
135
|
+
for (let oi = 0; oi < front; oi++) {
|
|
136
|
+
const o = L[oi];
|
|
137
|
+
if (!over(o.kind) || o.kind === u.kind) continue;
|
|
138
|
+
const moved = L.filter((x) => x.id !== u.id);
|
|
139
|
+
moved.splice(oi, 0, u);
|
|
140
|
+
const after = gapOf(moved, target, front).gap;
|
|
141
|
+
if (after >= now.gap) continue;
|
|
142
|
+
const m = { id: u.id, title: u.title, kind: u.kind, above: o.id, pushes: L[front - 1].id, gapAfter: after, closes: now.gap - after,
|
|
143
|
+
cli: oi === 0 ? `pmos initiative top ${u.id}` : `pmos initiative after ${u.id} ${L[oi - 1].id}`,
|
|
144
|
+
undo: `pmos initiative after ${u.id} ${L[ui - 1].id}` };
|
|
145
|
+
const was = best.get(u.id);
|
|
146
|
+
// the move that closes the most; on a tie, the one that lifts it least far (the lowest over-target one in the front)
|
|
147
|
+
if (!was || m.closes > was.closes || (m.closes === was.closes && oi > L.findIndex((x) => x.id === was.above))) best.set(u.id, m);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return [...best.values()].sort((a, b) => b.closes - a.closes || L.findIndex((x) => x.id === a.id) - L.findIndex((x) => x.id === b.id)).slice(0, max);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const label = (k) => B.KIND_LABEL[k] || k;
|
|
154
|
+
const mixWords = (o) => B.KINDS.filter((k) => o[k]).map((k) => `${label(k)} ${o[k]}%`).join(' · ') || 'nothing';
|
|
155
|
+
|
|
156
|
+
/* ── the needs provider: an off-target roadmap is a Today row by itself ─────────────────────────────────────────────── */
|
|
157
|
+
/** The Today row for workspace `ws` (pure): [] unless a target is saved, the gap is ROW_GAP or more and a move closes some of it. */
|
|
158
|
+
function rowsOf(ws, saved, list) {
|
|
159
|
+
if (!saved || !saved.target) return [];
|
|
160
|
+
const g = gapOf(list, saved.target, saved.front);
|
|
161
|
+
if (g.gap < ROW_GAP) return [];
|
|
162
|
+
const m = movesOf(list, saved.target, saved.front, { max: 1 })[0];
|
|
163
|
+
if (!m) return [];
|
|
164
|
+
const cause = `The top ${g.front.length} of your roadmap is ${g.gap} points off your target mix (${mixWords(g.mix)}; target ${mixWords(saved.target)}). Moving ${m.id} (${label(m.kind)}) above ${m.above} closes ${m.closes}.`;
|
|
165
|
+
return [{
|
|
166
|
+
run_id: `${KIND}:${ws}:${m.id}:${m.above}`, kind: KIND, initiative_id: m.id, question: cause, doc: null, ws,
|
|
167
|
+
today: { kind: 7, source: 'balance-target', cause, evidence: `pmos balance gap · target saved ${String(saved.at || '').slice(0, 10)}`,
|
|
168
|
+
act: { label: `Move ${m.id} up`, cli: m.cli, undo: m.undo } },
|
|
169
|
+
}];
|
|
170
|
+
}
|
|
171
|
+
/** A target drawn from the roadmap: its whole mix, the largest kind capped at the balance line, in steps of 10. Pure. */
|
|
172
|
+
function proposeTarget(list, front = DEFAULT_FRONT) {
|
|
173
|
+
const L = list || [];
|
|
174
|
+
if (L.length <= front) return null;
|
|
175
|
+
const n = Object.fromEntries(B.KINDS.map((k) => [k, L.filter((x) => x.kind === k).length]));
|
|
176
|
+
const present = B.KINDS.filter((k) => n[k] > 0);
|
|
177
|
+
if (present.length < 2) return null;
|
|
178
|
+
const share = Object.fromEntries(present.map((k) => [k, (n[k] / L.length) * 100]));
|
|
179
|
+
const top = present.reduce((a, b) => (share[b] > share[a] ? b : a));
|
|
180
|
+
if (share[top] > B.DEFAULT_MAX) {
|
|
181
|
+
const rest = 100 - share[top], spare = share[top] - B.DEFAULT_MAX;
|
|
182
|
+
share[top] = B.DEFAULT_MAX;
|
|
183
|
+
for (const k of present) if (k !== top) share[k] += spare * (share[k] / rest);
|
|
184
|
+
}
|
|
185
|
+
// whole steps of 10 that add up to 100: round down, then give the leftover steps to the largest remainders
|
|
186
|
+
const t = Object.fromEntries(present.map((k) => [k, Math.floor(share[k] / 10) * 10]));
|
|
187
|
+
let left = 100 - Object.values(t).reduce((a, b) => a + b, 0);
|
|
188
|
+
for (const k of [...present].sort((a, b) => (share[b] % 10) - (share[a] % 10) || B.KINDS.indexOf(a) - B.KINDS.indexOf(b))) { if (left <= 0) break; t[k] += 10; left -= 10; }
|
|
189
|
+
for (const k of present) if (!t[k]) delete t[k];
|
|
190
|
+
return Object.keys(t).length >= 2 ? t : null;
|
|
191
|
+
}
|
|
192
|
+
const targetText = (t) => B.KINDS.filter((k) => t[k]).map((k) => `${k}:${t[k]}`).join(',');
|
|
193
|
+
/** The proposal row (pure): [] unless the front is ROW_GAP or more off the proposed target and a move would close some of it. */
|
|
194
|
+
function proposalRowsOf(ws, list, front = DEFAULT_FRONT) {
|
|
195
|
+
const t = proposeTarget(list, front);
|
|
196
|
+
if (!t) return [];
|
|
197
|
+
const g = gapOf(list, t, front);
|
|
198
|
+
if (g.gap < ROW_GAP || !movesOf(list, t, front, { max: 1 }).length) return [];
|
|
199
|
+
const cause = `The top ${g.front.length} of your roadmap is ${mixWords(g.mix)}. Save a target mix of ${mixWords(t)}, drawn from your whole roadmap, and PMOS names the rank move that closes the ${g.gap}-point gap.`;
|
|
200
|
+
return [{
|
|
201
|
+
run_id: `${KIND}:${ws}:propose:${targetText(t)}`, kind: KIND, initiative_id: null, question: cause, doc: null, ws,
|
|
202
|
+
today: { kind: 7, source: 'balance-target', cause, evidence: `pmos balance show · ${list.length} live initiatives`,
|
|
203
|
+
act: { label: 'Save this target', cli: `pmos balance target ${targetText(t)}`, undo: 'pmos balance target --undo' } },
|
|
204
|
+
}];
|
|
205
|
+
}
|
|
206
|
+
const runtimeNow = () => require('./state-root.js').defaultRoot({ env: process.env });
|
|
207
|
+
function rowsFor(w, { lead } = {}) {
|
|
208
|
+
if (!lead || !w || !w.root) return [];
|
|
209
|
+
const saved = targetOf(runtimeNow(), w.root);
|
|
210
|
+
return saved ? rowsOf(w.id, saved, ranked(w.root)) : proposalRowsOf(w.id, ranked(w.root));
|
|
211
|
+
}
|
|
212
|
+
function sig(w) {
|
|
213
|
+
let t = '-';
|
|
214
|
+
try { const st = fs.statSync(fileOf(runtimeNow())); t = st.size + ':' + st.mtimeMs; } catch { /* no target yet */ }
|
|
215
|
+
let p = '-';
|
|
216
|
+
try { p = String(require('./plan-ledgers.js').ledgerSig(w.root, 'placements')); } catch { /* no ledger */ }
|
|
217
|
+
return t + '|' + p + '|' + new Date().toISOString().slice(0, 10);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
module.exports = { FILE, DEFAULT_FRONT, ROW_GAP, KIND, kinds: [KIND], fileOf, parseTarget, targetOf, setTarget, clearTarget, undoTarget, used, count,
|
|
221
|
+
ranked, gapOf, movesOf, mixWords, proposeTarget, proposalRowsOf, rowsOf, rowsFor, sig };
|
|
222
|
+
|
|
223
|
+
if (require.main === module) {
|
|
224
|
+
const a = process.argv.slice(2);
|
|
225
|
+
if (a[0] !== 'count') { console.log('usage: node lib/balance-target.js count [--days N]'); process.exit(2); }
|
|
226
|
+
const i = a.indexOf('--days'), days = i >= 0 ? Math.max(1, Number(a[i + 1]) || 7) : 7;
|
|
227
|
+
console.log(String(count(runtimeNow(), { days })));
|
|
228
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* change-request-cli.js — `pmos change-request`: a stakeholder's ask, recorded with what it would break or help (initiative change-requests).
|
|
3
|
+
*
|
|
4
|
+
* pmos change-request add <initiative> "<ask>" --from <name> [--end YYYY-MM-DD | --move <task> --by <days> | --cut [task]]
|
|
5
|
+
* pmos change-request decide <id> approve|reject [--note "…"]
|
|
6
|
+
* pmos change-request undo <id>
|
|
7
|
+
* pmos change-request list [--all]
|
|
8
|
+
* pmos change-request show <id>
|
|
9
|
+
* pmos change-request count [--days N]
|
|
10
|
+
* every command takes --json; add also takes --root <repository> and --today YYYY-MM-DD
|
|
11
|
+
*
|
|
12
|
+
* The store is lib/change-requests.js. With a date or a cut, add runs the rehearse engine (lib/rehearse.js) through its guard
|
|
13
|
+
* (lib/rehearse-guard.js), so every effect it keeps names its source. Nothing here changes a date, a task or an initiative, and
|
|
14
|
+
* nothing is sent. Exit codes: 0 done, 1 refused, 2 usage. */
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const path = require('path');
|
|
17
|
+
const CR = require('./change-requests.js');
|
|
18
|
+
|
|
19
|
+
const COMMANDS = { 'change-request': ['add', 'decide', 'undo', 'list', 'show', 'count'] };
|
|
20
|
+
const USAGE = [
|
|
21
|
+
'usage: pmos change-request add|decide|undo|list|show|count — a stakeholder\'s ask, recorded with what it would break or help. Nothing changes.',
|
|
22
|
+
' pmos change-request add <initiative> "<ask>" --from <name> record the ask, and who asked',
|
|
23
|
+
' [--end YYYY-MM-DD | --move <task> --by <days> | --cut [task]] the change it asks for: PMOS works out what it breaks or helps',
|
|
24
|
+
' pmos change-request decide <id> approve|reject [--note "…"] the PM\'s answer (it records the answer only)',
|
|
25
|
+
' pmos change-request undo <id> take the last answer back; the request is open again',
|
|
26
|
+
' pmos change-request list [--all] open requests first',
|
|
27
|
+
' pmos change-request show <id> the ask, its effects and the answer',
|
|
28
|
+
' pmos change-request count [--days N] requests recorded in the last N days (7)',
|
|
29
|
+
'Approve does not make the change. Make it with `pmos task set` or `pmos task state` after the PM says yes.',
|
|
30
|
+
];
|
|
31
|
+
const VALUE = new Set(['from', 'end', 'move', 'by', 'start', 'due', 'cut', 'note', 'root', 'today', 'days']);
|
|
32
|
+
const BOOL = new Set(['json', 'all']);
|
|
33
|
+
|
|
34
|
+
function parse(args) {
|
|
35
|
+
const pos = [], flags = {};
|
|
36
|
+
for (let i = 0; i < args.length; i++) {
|
|
37
|
+
const m = /^--([a-z-]+)(?:=(.*))?$/.exec(args[i]);
|
|
38
|
+
if (!m) { pos.push(args[i]); continue; }
|
|
39
|
+
if (m[2] !== undefined) flags[m[1]] = m[2];
|
|
40
|
+
else if (VALUE.has(m[1]) && args[i + 1] !== undefined && !/^--[a-z]/.test(args[i + 1])) flags[m[1]] = args[++i];
|
|
41
|
+
else flags[m[1]] = true;
|
|
42
|
+
}
|
|
43
|
+
return { pos, flags };
|
|
44
|
+
}
|
|
45
|
+
/** The repository this runs in: the nearest folder up from cwd that holds .git (no program is run), else cwd. */
|
|
46
|
+
function repoRoot(cwd) {
|
|
47
|
+
let d = path.resolve(cwd);
|
|
48
|
+
for (;;) {
|
|
49
|
+
if (fs.existsSync(path.join(d, '.git'))) return d;
|
|
50
|
+
const up = path.dirname(d);
|
|
51
|
+
if (up === d) return path.resolve(cwd);
|
|
52
|
+
d = up;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const day = (s) => String(s || '').slice(0, 16).replace('T', ' ');
|
|
56
|
+
const STATE = { open: 'open', approved: 'approved', rejected: 'rejected' };
|
|
57
|
+
|
|
58
|
+
function lineOf(r) {
|
|
59
|
+
const fx = r.change ? (r.counts ? `${r.counts.breaks || 0} breaks · ${r.counts.helps || 0} helps` : 'no effect') : 'no date';
|
|
60
|
+
return `${r.id} · ${STATE[r.state]} · ${r.ini} · "${r.ask}" — ${r.from} · ${fx}`;
|
|
61
|
+
}
|
|
62
|
+
function showOf(r) {
|
|
63
|
+
const out = [`${r.id} · ${STATE[r.state]}`, `Ask: "${r.ask}"`, `From: ${r.from} · initiative ${r.ini} · ${day(r.at)}`];
|
|
64
|
+
if (!r.change) out.push('No date effect was worked out: the ask names no date or cut.');
|
|
65
|
+
else if (!r.effects.length) out.push('Nothing else moves.');
|
|
66
|
+
else for (const e of r.effects) out.push(`${e.tone === 'breaks' ? '✗' : e.tone === 'helps' ? '✓' : '·'} ${e.text}${e.evidence && e.evidence.length ? ' (' + e.evidence.map((s) => s.ref).join(', ') + ')' : ''}`);
|
|
67
|
+
if (r.answer) out.push(`Answer: ${r.answer.answer} · ${r.answer.by} · ${day(r.answer.at)}${r.answer.note ? ' · ' + r.answer.note : ''}`);
|
|
68
|
+
return out;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = process.env, stateDir = null, snapshot = null, root: rootIn = null, actor = null } = {}) {
|
|
72
|
+
const args = argv[0] === 'change-request' ? argv.slice(1) : argv.slice();
|
|
73
|
+
const verb = args[0];
|
|
74
|
+
if (!verb || ['help', '--help', '-h'].includes(verb)) { for (const l of USAGE) say(l); return verb ? 0 : 1; }
|
|
75
|
+
if (!COMMANDS['change-request'].includes(verb)) { say(`unknown change-request command "${verb}" — one of ${COMMANDS['change-request'].join(', ')}`); return 2; }
|
|
76
|
+
const { pos, flags } = parse(args.slice(1));
|
|
77
|
+
for (const k of Object.keys(flags)) if (!VALUE.has(k) && !BOOL.has(k)) { say(`unknown option --${k}`); return 2; }
|
|
78
|
+
for (const k of Object.keys(flags)) if (VALUE.has(k) && k !== 'cut' && flags[k] === true) { say(`--${k} needs a value`); return 2; }
|
|
79
|
+
const json = !!flags.json, runtime = stateDir || require('./state-root.js').defaultRoot({ env });
|
|
80
|
+
const by = (actor || require('./actor.js').fromCli({ env })).by;
|
|
81
|
+
const fail = (error, code = 1) => { if (json) say(JSON.stringify({ ok: false, error })); else say('✗ ' + error); return code; };
|
|
82
|
+
const done = (o, text) => { if (json) say(JSON.stringify({ ok: true, ...o })); else for (const l of text) say(l); return 0; };
|
|
83
|
+
|
|
84
|
+
if (verb === 'count') {
|
|
85
|
+
const days = Math.max(1, Number(flags.days) || 7);
|
|
86
|
+
const n = CR.count(runtime, { days });
|
|
87
|
+
return done({ count: n, days }, [`${n} change request${n === 1 ? '' : 's'} recorded in the last ${days} days.`]);
|
|
88
|
+
}
|
|
89
|
+
if (verb === 'list') {
|
|
90
|
+
const all = CR.read(runtime), shown = flags.all ? all : all.filter((r) => r.state === 'open');
|
|
91
|
+
if (!shown.length) return done({ requests: [] }, [flags.all || !all.length ? 'No change request yet.' : `No open change request. ${all.length} answered: \`pmos change-request list --all\`.`]);
|
|
92
|
+
return done({ requests: shown }, shown.map(lineOf));
|
|
93
|
+
}
|
|
94
|
+
if (verb === 'show') {
|
|
95
|
+
if (pos.length !== 1) return fail('usage: pmos change-request show <id>', 2);
|
|
96
|
+
const r = CR.find(runtime, pos[0]);
|
|
97
|
+
return r ? done({ request: r }, showOf(r)) : fail(`no change request ${pos[0]}`);
|
|
98
|
+
}
|
|
99
|
+
if (verb === 'decide') {
|
|
100
|
+
if (pos.length !== 2 || !CR.ANSWERS.includes(pos[1])) return fail('usage: pmos change-request decide <id> approve|reject [--note "…"]', 2);
|
|
101
|
+
const got = CR.decide(runtime, pos[0], pos[1], { by, note: typeof flags.note === 'string' ? flags.note : '' });
|
|
102
|
+
if (!got.ok) return fail(got.error);
|
|
103
|
+
const tail = pos[1] === 'approve' ? 'Recorded. Nothing changed yet: make the change with `pmos task set` or `pmos task state`.' : 'Recorded. Tell ' + got.request.from + ' in your own words.';
|
|
104
|
+
return done({ request: got.request, changed: false }, [`✓ ${got.request.id} ${got.request.state}. ${tail}`, `Undo: pmos change-request undo ${got.request.id}`]);
|
|
105
|
+
}
|
|
106
|
+
if (verb === 'undo') {
|
|
107
|
+
if (pos.length !== 1) return fail('usage: pmos change-request undo <id>', 2);
|
|
108
|
+
const got = CR.undo(runtime, pos[0], { by });
|
|
109
|
+
return got.ok ? done({ request: got.request }, [`✓ ${got.request.id} is ${got.request.state} again.`]) : fail(got.error);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// add
|
|
113
|
+
const [ini, ...rest] = pos, ask = rest.join(' ').trim();
|
|
114
|
+
if (!ini || !ask) return fail('usage: pmos change-request add <initiative> "<ask>" --from <name> [--end YYYY-MM-DD | --move <task> --by <days> | --cut [task]]', 2);
|
|
115
|
+
if (typeof flags.from !== 'string' || !flags.from.trim()) return fail('say who asked, with --from <name>', 2);
|
|
116
|
+
const asks = ['end', 'move', 'cut'].filter((k) => flags[k] !== undefined);
|
|
117
|
+
if (asks.length > 1) return fail('one change per request: --end, --move or --cut', 2);
|
|
118
|
+
if (flags.by !== undefined && flags.move === undefined) return fail('--by goes with --move <task>', 2);
|
|
119
|
+
const root = rootIn || (flags.root ? path.resolve(cwd, flags.root) : repoRoot(cwd));
|
|
120
|
+
const snap = snapshot || require('./rehearse-read.js').snapshotOf(root, { today: typeof flags.today === 'string' ? flags.today : undefined });
|
|
121
|
+
const known = (snap.rows || []).some((r) => r.id === ini) || fs.existsSync(path.join(root, 'planning', 'initiatives', ini + '.md'));
|
|
122
|
+
if (!known) return fail(`no initiative ${ini}. \`pmos initiative list\` names them.`);
|
|
123
|
+
|
|
124
|
+
let change = null, effects = [], counts = null, missing = [], dropped = 0;
|
|
125
|
+
if (asks.length) {
|
|
126
|
+
if (flags.end !== undefined) change = { kind: 'end', ini, to: flags.end };
|
|
127
|
+
else if (flags.move !== undefined) {
|
|
128
|
+
if (flags.by === undefined && !flags.start && !flags.due) return fail('say how far: --by <days>, --start or --due', 2);
|
|
129
|
+
if (flags.by !== undefined && !/^-?\d+$/.test(String(flags.by))) return fail('--by takes whole days, e.g. --by 3 or --by -2', 2);
|
|
130
|
+
change = { kind: 'move', task: flags.move, ...(flags.by !== undefined ? { days: Number(flags.by) } : {}), ...(flags.start ? { start: flags.start } : {}), ...(flags.due ? { due: flags.due } : {}) };
|
|
131
|
+
} else change = flags.cut === true ? { kind: 'cut', ini } : { kind: 'cut', task: flags.cut };
|
|
132
|
+
const RH = require('./rehearse.js'), G = require('./rehearse-guard.js');
|
|
133
|
+
const r = RH.rehearse(snap, change);
|
|
134
|
+
if (!r.ok) return fail(r.error, /^(say how|--)/.test(r.error) ? 2 : 1);
|
|
135
|
+
const g = await G.guarded(r, { root, stateDir: runtime, env });
|
|
136
|
+
if (g.off) missing.push('the rehearsal (off: ' + g.off + ')');
|
|
137
|
+
else if (g.held) missing.push('the rehearsal (its replay did not pass)');
|
|
138
|
+
else {
|
|
139
|
+
effects = g.effects.map((e) => ({ tone: e.tone, kind: e.kind, ini: e.ini || null, text: e.text, evidence: (e.evidence || []).map((s) => ({ label: s.label, ref: s.ref, quote: s.quote || '' })) }));
|
|
140
|
+
counts = { breaks: 0, helps: 0, moves: 0 };
|
|
141
|
+
for (const e of effects) counts[e.tone]++;
|
|
142
|
+
dropped = g.dropped.length;
|
|
143
|
+
}
|
|
144
|
+
missing.push(...(r.missing || []));
|
|
145
|
+
}
|
|
146
|
+
const got = CR.add(runtime, { ask, from: flags.from, ini, change, effects, counts, missing, by, root });
|
|
147
|
+
if (!got.ok) return fail(got.error, 2);
|
|
148
|
+
const q = got.request, text = [`✓ ${q.id} recorded: "${q.ask}" — ${q.from}, on ${q.ini}.`];
|
|
149
|
+
if (!change) text.push('No date effect was worked out: the ask names no date or cut.');
|
|
150
|
+
else if (!counts) text.push('No effect was worked out: ' + missing[0] + '.');
|
|
151
|
+
else {
|
|
152
|
+
text.push(effects.length ? `It would break ${counts.breaks} and help ${counts.helps}:` : 'Nothing else moves.');
|
|
153
|
+
for (const e of effects) text.push(` ${e.tone === 'breaks' ? '✗' : e.tone === 'helps' ? '✓' : '·'} ${e.text}`);
|
|
154
|
+
if (dropped) text.push(`${dropped === 1 ? '1 effect is' : dropped + ' effects are'} not kept: PMOS could not find its source.`);
|
|
155
|
+
}
|
|
156
|
+
text.push(`Nothing changed. Answer with pmos change-request decide ${q.id} approve|reject`);
|
|
157
|
+
return done({ request: q, changed: false }, text);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* change-requests.js — a stakeholder's ask, recorded as a change request (initiative change-requests, idea A105).
|
|
3
|
+
*
|
|
4
|
+
* Someone outside the team asks for a change ("can checkout end on the 30th?"). PMOS records who asked, on which initiative, what
|
|
5
|
+
* they asked and, when the ask names a date or a cut, what it would break or help, from the rehearse engine (lib/rehearse.js) with
|
|
6
|
+
* the source of each effect. The PM answers approve or reject; Undo takes the answer back.
|
|
7
|
+
*
|
|
8
|
+
* A change request never changes a date, a task or an initiative, and never sends anything. Approve records the answer only: the PM
|
|
9
|
+
* (or the session, after the PM says yes) makes the change with `pmos task set`, `pmos task state` or the PM's own act.
|
|
10
|
+
*
|
|
11
|
+
* fileOf(runtime) <runtime>/change-requests.jsonl (append-only: add, decide, undo)
|
|
12
|
+
* read(runtime) → [request] every request folded from its lines, open first, then newest first
|
|
13
|
+
* add(runtime, o) → { ok, request } | { ok:false, error }
|
|
14
|
+
* o: { ask, from, ini, change?, effects?, counts?, missing?, by, at? } change is a rehearse change, or null for an ask with no date
|
|
15
|
+
* decide(runtime, id, answer, o) → { ok, request } | { ok:false, error } answer: approve | reject; o: { by, note?, at? }
|
|
16
|
+
* undo(runtime, id, o) → { ok, request } | { ok:false, error } the last answer back; the request is open again
|
|
17
|
+
* count(runtime, { days, now }) → number requests recorded in the last N days (the health number)
|
|
18
|
+
*
|
|
19
|
+
* node lib/change-requests.js count --days 7 prints that number (health_read)
|
|
20
|
+
*
|
|
21
|
+
* needs provider (lib/needs-providers.js): kinds ['change-request'] · rowsFor(w, { lead }) · sig(w)
|
|
22
|
+
* Each open request recorded for workspace w's repository is one Today row (kind 1) by itself, with no typed ask: who asked,
|
|
23
|
+
* what, and what it would break. Its ✦ approves (records the answer only), with Undo. rowsOf(ws, requests, root) is the pure part.
|
|
24
|
+
*
|
|
25
|
+
* Each write logs one `[change-requests]` line to stderr. Nothing is sent. */
|
|
26
|
+
const fs = require('fs');
|
|
27
|
+
const path = require('path');
|
|
28
|
+
const crypto = require('crypto');
|
|
29
|
+
|
|
30
|
+
const FILE = 'change-requests.jsonl';
|
|
31
|
+
const ANSWERS = ['approve', 'reject'];
|
|
32
|
+
const fileOf = (runtime) => path.join(runtime, FILE);
|
|
33
|
+
const log = (s) => { try { process.stderr.write('[change-requests] ' + s + '\n'); } catch { /* a closed stream */ } };
|
|
34
|
+
|
|
35
|
+
function lines(runtime) {
|
|
36
|
+
let raw = '';
|
|
37
|
+
try { raw = fs.readFileSync(fileOf(runtime), 'utf8'); } catch { return []; }
|
|
38
|
+
const out = [];
|
|
39
|
+
for (const l of raw.split('\n')) { if (!l.trim()) continue; try { out.push(JSON.parse(l)); } catch { /* a torn line */ } }
|
|
40
|
+
return out;
|
|
41
|
+
}
|
|
42
|
+
function append(runtime, line) {
|
|
43
|
+
fs.mkdirSync(runtime, { recursive: true });
|
|
44
|
+
fs.appendFileSync(fileOf(runtime), JSON.stringify(line) + '\n');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Every request, folded from its lines: open requests first, then the newest first. */
|
|
48
|
+
function read(runtime) {
|
|
49
|
+
const byId = new Map();
|
|
50
|
+
for (const l of lines(runtime)) {
|
|
51
|
+
if (l.ev === 'add' && l.id && !byId.has(l.id)) {
|
|
52
|
+
byId.set(l.id, { id: l.id, at: l.at, by: l.by, root: l.root || null, from: l.from, ini: l.ini, ask: l.ask, change: l.change || null, effects: l.effects || [], counts: l.counts || null, missing: l.missing || [], state: 'open', answers: [] });
|
|
53
|
+
} else if (l.ev === 'decide' && byId.has(l.id)) {
|
|
54
|
+
const r = byId.get(l.id);
|
|
55
|
+
r.answers.push({ answer: l.answer, by: l.by, at: l.at, note: l.note || '' });
|
|
56
|
+
r.state = l.answer === 'approve' ? 'approved' : 'rejected';
|
|
57
|
+
} else if (l.ev === 'undo' && byId.has(l.id)) {
|
|
58
|
+
const r = byId.get(l.id);
|
|
59
|
+
r.answers.pop();
|
|
60
|
+
const last = r.answers[r.answers.length - 1];
|
|
61
|
+
r.state = last ? (last.answer === 'approve' ? 'approved' : 'rejected') : 'open';
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
const all = [...byId.values()];
|
|
65
|
+
for (const r of all) r.answer = r.answers[r.answers.length - 1] || null;
|
|
66
|
+
return all.sort((a, b) => (a.state === 'open' ? 0 : 1) - (b.state === 'open' ? 0 : 1) || String(b.at).localeCompare(String(a.at)));
|
|
67
|
+
}
|
|
68
|
+
const find = (runtime, id) => read(runtime).find((r) => r.id === id) || null;
|
|
69
|
+
|
|
70
|
+
function add(runtime, o = {}) {
|
|
71
|
+
const ask = String(o.ask || '').trim(), from = String(o.from || '').trim(), ini = String(o.ini || '').trim();
|
|
72
|
+
if (!ask) return { ok: false, error: 'say what was asked, e.g. pmos change-request add checkout "End on the 30th" --from Dana' };
|
|
73
|
+
if (!from) return { ok: false, error: 'say who asked, with --from <name>' };
|
|
74
|
+
if (!ini) return { ok: false, error: 'say which initiative the ask is about' };
|
|
75
|
+
const id = 'cr-' + crypto.randomBytes(3).toString('hex');
|
|
76
|
+
const line = { ev: 'add', id, at: o.at || new Date().toISOString(), by: o.by || 'agent:unknown', root: o.root ? path.resolve(o.root) : null, from, ini, ask, change: o.change || null, effects: o.effects || [], counts: o.counts || null, missing: o.missing || [] };
|
|
77
|
+
append(runtime, line);
|
|
78
|
+
log(`add ${id} ${ini} from ${from}${line.change ? ' · ' + line.effects.length + ' effects' : ' · no date effect'}`);
|
|
79
|
+
return { ok: true, request: find(runtime, id) };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function decide(runtime, id, answer, o = {}) {
|
|
83
|
+
if (!ANSWERS.includes(answer)) return { ok: false, error: 'answer approve or reject' };
|
|
84
|
+
const r = find(runtime, id);
|
|
85
|
+
if (!r) return { ok: false, error: `no change request ${id}` };
|
|
86
|
+
if (r.state !== 'open') return { ok: false, error: `${id} is already ${r.state}. \`pmos change-request undo ${id}\` takes that answer back first.` };
|
|
87
|
+
append(runtime, { ev: 'decide', id, at: o.at || new Date().toISOString(), by: o.by || 'agent:unknown', answer, note: String(o.note || '').trim() });
|
|
88
|
+
log(`decide ${id} ${answer}`);
|
|
89
|
+
return { ok: true, request: find(runtime, id) };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function undo(runtime, id, o = {}) {
|
|
93
|
+
const r = find(runtime, id);
|
|
94
|
+
if (!r) return { ok: false, error: `no change request ${id}` };
|
|
95
|
+
if (!r.answers.length) return { ok: false, error: `${id} has no answer to take back` };
|
|
96
|
+
append(runtime, { ev: 'undo', id, at: o.at || new Date().toISOString(), by: o.by || 'agent:unknown' });
|
|
97
|
+
log(`undo ${id}`);
|
|
98
|
+
return { ok: true, request: find(runtime, id) };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function count(runtime, { days = 7, now = Date.now() } = {}) {
|
|
102
|
+
const since = now - days * 86400000;
|
|
103
|
+
return read(runtime).filter((r) => Date.parse(r.at) >= since).length;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* ── the needs provider: an open request is a Today row by itself ─────────────────────────────────────────────────── */
|
|
107
|
+
const KIND = 'change-request';
|
|
108
|
+
const clip = (x, n) => String(x == null ? '' : x).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
109
|
+
/** The Today rows for workspace `ws` at repository `root`: one per open request recorded there. Pure. */
|
|
110
|
+
function rowsOf(ws, requests, root) {
|
|
111
|
+
const at = root ? path.resolve(root) : null;
|
|
112
|
+
return (requests || []).filter((r) => r.state === 'open' && (!r.root || !at || r.root === at)).map((r) => {
|
|
113
|
+
const fx = !r.change ? 'It names no date or cut.' : r.counts && r.counts.breaks ? `It would break ${r.counts.breaks}${r.counts.helps ? ' and help ' + r.counts.helps : ''}: ${clip((r.effects.find((e) => e.tone === 'breaks') || {}).text, 120)}` : 'Nothing else moves.';
|
|
114
|
+
const cause = `${clip(r.from, 40)} asks: "${clip(r.ask, 120)}" on ${r.ini}. ${fx}`;
|
|
115
|
+
return {
|
|
116
|
+
run_id: `${KIND}:${ws}:${r.id}`, kind: KIND, initiative_id: r.ini, question: cause, doc: null, ws,
|
|
117
|
+
today: { kind: 1, source: 'change-requests', cause, evidence: `Change request ${r.id} · ${String(r.at).slice(0, 10)}${r.effects.length ? ' · ' + r.effects.length + ' effects with sources' : ''}`,
|
|
118
|
+
act: { label: 'Approve', cli: `pmos change-request decide ${r.id} approve`, undo: `pmos change-request undo ${r.id}` } },
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
const runtimeNow = () => require('./state-root.js').defaultRoot({ env: process.env });
|
|
123
|
+
function rowsFor(w, { lead } = {}) {
|
|
124
|
+
if (!lead || !w || !w.root) return [];
|
|
125
|
+
return rowsOf(w.id, read(runtimeNow()), w.root);
|
|
126
|
+
}
|
|
127
|
+
function sig() { try { const st = fs.statSync(fileOf(runtimeNow())); return st.size + ':' + st.mtimeMs; } catch { return '-'; } }
|
|
128
|
+
|
|
129
|
+
module.exports = { FILE, ANSWERS, KIND, kinds: [KIND], fileOf, read, find, add, decide, undo, count, rowsOf, rowsFor, sig };
|
|
130
|
+
|
|
131
|
+
if (require.main === module) {
|
|
132
|
+
const a = process.argv.slice(2);
|
|
133
|
+
if (a[0] !== 'count') { console.log('usage: node lib/change-requests.js count [--days N]'); process.exit(2); }
|
|
134
|
+
const i = a.indexOf('--days'), days = i >= 0 ? Math.max(1, Number(a[i + 1]) || 7) : 7;
|
|
135
|
+
console.log(String(count(require('./state-root.js').defaultRoot({ env: process.env }), { days })));
|
|
136
|
+
}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
{"id": "goal", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Give PMOS a goal", "say": "PMOS asks a few questions, then works on the goal after you press Start.", "cmd": "/goal", "phrases": ["work on this until", "keep going until", "make it happen"], "since": "0.560.0"},
|
|
6
6
|
{"id": "why", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Why this work exists", "say": "Three lines on an initiative or a task: its goal, its problem and the evidence.", "cmd": "/why", "verb": "why", "hint": "<initiative or task>", "phrases": ["why does this exist", "why are we doing", "why are we building", "what is the point of", "reason for this work", "why this initiative"], "phone": true, "since": "0.700.0", "ask": ["initiative", "task"]},
|
|
7
7
|
{"id": "rehearse", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Rehearse a change", "say": "Move a task by some days and see what else slips, before anything changes.", "cmd": "/rehearse", "verb": "rehearse", "sub": "move", "hint": "<task> <days>", "ask": ["task"], "place": "board", "phrases": ["what if slips", "what happens if slips", "what if move", "push back", "delay by", "slips a week", "what breaks if", "move the date", "what if we cut"], "since": "0.600.0"},
|
|
8
|
+
{"id": "change-request", "audience": "user", "status": "beta", "group": "Plan and decide", "name": "Record a change request", "say": "Record a stakeholder's ask with who asked and what it would break, then approve or reject it.", "cmd": "/change-request", "verb": "change-request"},
|
|
8
9
|
{"id": "decisions", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Decision journal", "say": "Write one line per decision, with what you expect and the date to check it.", "cmd": "/decide", "verb": "decisions", "sub": "add", "hint": "<the decision>", "phrases": ["we decided", "log a decision", "record a decision", "note the decision", "decision journal", "list decisions"], "since": "0.640.0"},
|
|
9
10
|
{"id": "questions", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Open questions", "say": "Every question nobody has answered yet, oldest first, in one list.", "cmd": "/questions", "verb": "questions", "phrases": ["open questions", "unanswered questions", "what is still open", "questions nobody answered", "what do we not know"], "phone": true, "since": "0.660.0"},
|
|
10
11
|
{"id": "press-release", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Press release and FAQ", "say": "A one-page press release and FAQ for a bet, drafted from its record, for you to edit.", "cmd": "/press-release", "verb": "press-release", "hint": "<initiative>", "phrases": ["press release", "working backwards", "write the faq", "announce this"], "since": "0.690.0", "ask": ["initiative"]},
|
|
@@ -68,7 +69,7 @@
|
|
|
68
69
|
{"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>"},
|
|
69
70
|
{"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"},
|
|
70
71
|
{"id": "approver", "audience": "user", "status": "ga", "group": "Before you ship", "name": "What an approver asks", "say": "What each approver asked or objected to before, ahead of the next sign-off.", "cmd": "/approver", "verb": "approver", "hint": "<name>"},
|
|
71
|
-
{"id": "balance", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The mix of a list", "say": "Feature, fix, debt or discovery in one line,
|
|
72
|
+
{"id": "balance", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "The mix of a list", "say": "Feature, fix, debt or discovery in one line, a target mix for the roadmap, and the rank move that closes the gap.", "cmd": "/balance", "verb": "balance"},
|
|
72
73
|
{"id": "layouts", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Three layouts for a new screen", "say": "Three layouts of a new screen side by side, the one that fits your picks, and the one you keep to build.", "cmd": "/layouts", "verb": "layouts"},
|
|
73
74
|
{"id": "declined", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Asks you declined", "say": "Asks closed without being done, each with a kind reply draft PMOS never sends.", "cmd": "/declined", "verb": "declined"},
|
|
74
75
|
{"id": "sprint", "audience": "user", "status": "ga", "group": "Catch up", "name": "Sprint retro", "say": "A closed sprint's retro from its close numbers, and its one tracked change.", "cmd": "/sprint", "verb": "sprint"},
|
|
@@ -44,6 +44,8 @@ const PROVIDERS = Object.freeze([
|
|
|
44
44
|
'team-slips', // team-slips (bet A15): another team your work waits on will likely slip, with the one ✦ move (kind 7)
|
|
45
45
|
'setup-station', // setup-station: a product that has not passed Setup (tracker read, agreed goal, owner), with the next ✦ (kind 7)
|
|
46
46
|
'critical-needs', // critical-moved (bet A103): a task on an initiative's critical path moved its start or due date, with go-live (kind 7)
|
|
47
|
+
'change-requests', // change-requests (bet A105): a stakeholder's open change request, with what it would break; ✦ approves with Undo (kind 1)
|
|
48
|
+
'balance-target', // balance-rebalance (bet A65): the top of the roadmap is 15 points or more off the target mix, with the one ✦ rank move (kind 7)
|
|
47
49
|
]);
|
|
48
50
|
/** Kinds that already mean something in the needs queue. A provider may not reuse one. */
|
|
49
51
|
const RESERVED_KINDS = Object.freeze(['question', 'accept', 'outcome', 'keep', 'evidence', 'plan-flag', 'provider-error']);
|
|
@@ -113,6 +113,8 @@ const VERBS = Object.freeze({
|
|
|
113
113
|
ai: Object.freeze({ module: 'ai-cli.js', run: null, guide: 'cli.md',
|
|
114
114
|
help: 'pmos ai status|off|on|log … — the AI jobs: their kill switch, replay state and audit (pmos ai help)' }),
|
|
115
115
|
// Not a pm-os-absorb verb (run: null): the AI-ideas round (2026-11-03, feature 5, plan-rehearsal) added it through the same table.
|
|
116
|
+
'change-request': Object.freeze({ module: 'change-request-cli.js', run: null, guide: 'cli.md',
|
|
117
|
+
help: 'pmos change-request add|decide|undo|list|show|count … — a stakeholder\'s ask, recorded with what it would break or help; approve records the answer only (pmos change-request help)' }),
|
|
116
118
|
rehearse: Object.freeze({ module: 'rehearse-cli.js', run: null, guide: 'cli.md',
|
|
117
119
|
help: 'pmos rehearse move|end|cut|log … — what a change would break or help in other initiatives, goals and dates, before the PM approves it (pmos rehearse help)' }),
|
|
118
120
|
// Not a pm-os-absorb verb (run: null): Grill and Forecast part G-A (Claude grills an initiative by itself) added it through the same table.
|
|
@@ -202,7 +204,7 @@ const VERBS = Object.freeze({
|
|
|
202
204
|
help: 'pmos approver list|show|brief — what each approver asked or objected to before, from the sign-offs and the decision journal, before the next sign-off (pmos approver help)' }),
|
|
203
205
|
// Not a pm-os-absorb verb (run: null): initiative balance-meter (bet A448) added it through the same table.
|
|
204
206
|
balance: Object.freeze({ module: 'balance-cli.js', run: null, guide: 'cli.md',
|
|
205
|
-
help: 'pmos balance show — the mix of a list in one line
|
|
207
|
+
help: 'pmos balance show|target|gap — the mix of a list in one line, a target mix for the roadmap, and the rank move that closes the gap (pmos balance help)' }),
|
|
206
208
|
// Not a pm-os-absorb verb (run: null): initiative product-principles-draft (bet A352) added it through the same table.
|
|
207
209
|
principles: Object.freeze({ module: 'principles-cli.js', run: null, guide: 'cli.md',
|
|
208
210
|
help: 'pmos principles list|sources|draft|keep|drop|undo|add — the product\'s principles, drafted from its decisions, each citing them; keep or drop each (pmos principles help)' }),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.849.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.849.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "balance-rebalance (bet A65, job #2051): a target mix for the roadmap and the rank move that closes the gap. `pmos balance target|gap` on a temporary repository, the needs provider, and the must-nots (no rank moves by itself, nothing sent). No browser, no model.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"balance-rebalance.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"balance-rebalance.test.js": 3
|
|
8
|
+
}
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "change-requests (bet A105, job #2024): a stakeholder's ask recorded as a change request. The store, `pmos change-request` on the recorded rehearse snapshot, and the must-nots (no date, task or initiative write, nothing sent). No browser, no model.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"change-requests.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"change-requests.test.js": 3
|
|
8
|
+
}
|
|
9
|
+
}
|