create-pmos 0.785.0 → 0.786.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 +45 -14
- 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 +44 -0
- package/workspace/guide/cli.md +11 -0
- package/workspace/guide/home.md +2 -1
- package/workspace/guide/jira.md +8 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/quiet-cli.js +81 -0
- package/workspace/lib/quiet-sweep.js +228 -0
- package/workspace/lib/routes-backlog.js +21 -1
- package/workspace/lib/routes-your-move.js +39 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/bd-sprint.js +29 -1
- package/workspace/public/pm/home-app.js +9 -1
- package/workspace/public/pm/live-feed.js +1 -0
- package/workspace/public/pm/quiet-view.js +107 -0
- package/workspace/test-lists/quiet-sweep.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.786.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,50 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.786.0",
|
|
38
|
+
"at": "2026-11-24T17:39:55.270Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1779,
|
|
43
|
+
"t": "A weekly sweep of quiet work — keep, park or close each initiative quiet 30 days",
|
|
44
|
+
"s": "A weekly sweep of quiet work — keep, park or close each initiative quiet 30 days",
|
|
45
|
+
"k": "new",
|
|
46
|
+
"h": "A weekly sweep of quiet work — keep, park or close each initiative quiet 30 days",
|
|
47
|
+
"try": {
|
|
48
|
+
"steps": [
|
|
49
|
+
"Open Today and press the row that says how many initiatives are quiet 30 days or more",
|
|
50
|
+
"Press Park on one row, then Undo in the message",
|
|
51
|
+
"Open Work and find an initiative you parked or closed"
|
|
52
|
+
],
|
|
53
|
+
"see": "One list of quiet initiatives, most quiet first, each with Keep, Park and Close; the row leaves the list at once, Undo puts it back, and Work shows the parked one on hold",
|
|
54
|
+
"open": "/today.html"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"n": 1788,
|
|
59
|
+
"t": "The One change block on a past sprint (sprint-retro-one-change, step 2)",
|
|
60
|
+
"s": "The One change block on a past sprint (sprint-retro-one-change, step 2)",
|
|
61
|
+
"k": "new",
|
|
62
|
+
"h": "The One change block on a past sprint (sprint-retro-one-change, step 2)",
|
|
63
|
+
"try": {
|
|
64
|
+
"steps": [
|
|
65
|
+
"Open Work, then Backlog, and press the sprint name to pick a past sprint",
|
|
66
|
+
"Read the One change block beside Lessons, or ask the chat on Today: what was the retro of our last sprint?"
|
|
67
|
+
],
|
|
68
|
+
"see": "The block (and the chat) give done of total, why work was carried (never started, started, in review, carried twice, added after the start), names one change for the next sprint, and for a sprint…",
|
|
69
|
+
"open": "/premium-board.html"
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"n": 1789,
|
|
74
|
+
"t": "A published read-only Board opens no live stream",
|
|
75
|
+
"s": "A published read-only Board opens no live stream",
|
|
76
|
+
"k": "fix"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
36
80
|
{
|
|
37
81
|
"v": "0.785.0",
|
|
38
82
|
"at": "2026-11-24T17:13:04.909Z",
|
|
@@ -408,19 +452,6 @@
|
|
|
408
452
|
"k": "fix"
|
|
409
453
|
}
|
|
410
454
|
]
|
|
411
|
-
},
|
|
412
|
-
{
|
|
413
|
-
"v": "0.766.0",
|
|
414
|
-
"at": "2026-11-24T07:23:50.157Z",
|
|
415
|
-
"f": 4,
|
|
416
|
-
"prs": [
|
|
417
|
-
{
|
|
418
|
-
"n": 1723,
|
|
419
|
-
"t": "The chat beside a task is about the task",
|
|
420
|
-
"s": "The chat beside a task is about the task",
|
|
421
|
-
"k": "fix"
|
|
422
|
-
}
|
|
423
|
-
]
|
|
424
455
|
}
|
|
425
456
|
]
|
|
426
457
|
}
|
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-24T17:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T17:39:51Z"}
|
|
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-24T17:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T17:39:51Z"}
|
|
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-24T17:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T17:39:51Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,48 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.786.0",
|
|
4
|
+
"at": "2026-11-24T17:39:55.270Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1779,
|
|
9
|
+
"t": "A weekly sweep of quiet work — keep, park or close each initiative quiet 30 days",
|
|
10
|
+
"s": "A weekly sweep of quiet work — keep, park or close each initiative quiet 30 days",
|
|
11
|
+
"k": "new",
|
|
12
|
+
"h": "A weekly sweep of quiet work — keep, park or close each initiative quiet 30 days",
|
|
13
|
+
"try": {
|
|
14
|
+
"steps": [
|
|
15
|
+
"Open Today and press the row that says how many initiatives are quiet 30 days or more",
|
|
16
|
+
"Press Park on one row, then Undo in the message",
|
|
17
|
+
"Open Work and find an initiative you parked or closed"
|
|
18
|
+
],
|
|
19
|
+
"see": "One list of quiet initiatives, most quiet first, each with Keep, Park and Close; the row leaves the list at once, Undo puts it back, and Work shows the parked one on hold",
|
|
20
|
+
"open": "/today.html"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"n": 1788,
|
|
25
|
+
"t": "The One change block on a past sprint (sprint-retro-one-change, step 2)",
|
|
26
|
+
"s": "The One change block on a past sprint (sprint-retro-one-change, step 2)",
|
|
27
|
+
"k": "new",
|
|
28
|
+
"h": "The One change block on a past sprint (sprint-retro-one-change, step 2)",
|
|
29
|
+
"try": {
|
|
30
|
+
"steps": [
|
|
31
|
+
"Open Work, then Backlog, and press the sprint name to pick a past sprint",
|
|
32
|
+
"Read the One change block beside Lessons, or ask the chat on Today: what was the retro of our last sprint?"
|
|
33
|
+
],
|
|
34
|
+
"see": "The block (and the chat) give done of total, why work was carried (never started, started, in review, carried twice, added after the start), names one change for the next sprint, and for a sprint…",
|
|
35
|
+
"open": "/premium-board.html"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"n": 1789,
|
|
40
|
+
"t": "A published read-only Board opens no live stream",
|
|
41
|
+
"s": "A published read-only Board opens no live stream",
|
|
42
|
+
"k": "fix"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
2
46
|
{
|
|
3
47
|
"v": "0.785.0",
|
|
4
48
|
"at": "2026-11-24T17:13:04.909Z",
|
package/workspace/guide/cli.md
CHANGED
|
@@ -441,6 +441,17 @@ An initiative on hold keeps why it is parked and what brings it back: a return d
|
|
|
441
441
|
- `pmos parked hold <id> --why "<reason>"` parks an initiative. `--back <YYYY-MM-DD>` sets a return day. `--after <id>` names the initiative that must finish first.
|
|
442
442
|
- `pmos parked back <id>` brings it back to the Roadmap. To undo, park it again.
|
|
443
443
|
- `pmos parked coverage` shows how many parked initiatives say why and what brings them back, and the percent on the last line.
|
|
444
|
+
|
|
445
|
+
### pmos quiet: the weekly sweep of quiet work
|
|
446
|
+
|
|
447
|
+
Once a week Today shows how many initiatives had no change in 30 days or more. The chat answers the same list from a terminal.
|
|
448
|
+
|
|
449
|
+
- `pmos quiet list` shows the quiet initiatives, most quiet first. Each one shows what PMOS suggests: **Close** when it is on its workflow's last stage, else **Park**.
|
|
450
|
+
- `pmos quiet keep <id>` keeps it. The sweep does not show it again for 30 days.
|
|
451
|
+
- `pmos quiet park <id>` parks it. The reason says how long it was quiet. Use `--why "<reason>"` to give your own reason.
|
|
452
|
+
- `pmos quiet close <id>` closes it. Use `--why "<reason>"` to say why.
|
|
453
|
+
- `pmos quiet undo <id>` undoes the newest answer of that initiative.
|
|
454
|
+
|
|
444
455
|
### pmos rehearse: rehearse a change
|
|
445
456
|
|
|
446
457
|
- `pmos rehearse move <task> --by <days>` — the task moves later by whole days, or earlier with a minus (`--by -2`).
|
package/workspace/guide/home.md
CHANGED
|
@@ -55,6 +55,7 @@ Today, Work, Insights and the Viewer use one typeface, Plus Jakarta Sans, with t
|
|
|
55
55
|
- **One press per initiative.** An initiative's proposals are one row, for example "Checkout: 6 changes to keep" with "3 dates, 2 names, 1 link" under it. Press it to see them grouped as Dates, Names, Done and Links. ✓ keeps all of them, with one Undo for the batch. ✕ drops them, then offers three reasons and **Say why**. A proposal that needs your own check keeps its own ✓ and ✕. **See every change** opens the full list on the initiative.
|
|
56
56
|
- **An ask expires after 14 days with no answer.** PMOS leaves it as it was and writes why in the initiative's History. Your move says it once: "2 asks expired after 14 days with no answer." Dates computed from your tasks never expire: PMOS reads them again each time.
|
|
57
57
|
- **Done** lists what PMOS finished by itself in the last 14 days, one line each with Undo.
|
|
58
|
+
- **Quiet work, once a week.** One row says how many initiatives had no change in 30 days or more on all your products, for example "37 initiatives quiet 30 days or more". Press it to see one list, most quiet first. Each row says how long it was quiet and on which stage, and what PMOS suggests (✦): **Close** when it is on its workflow's last stage, else **Park**. Each row has three presses: **Keep** (still on; the sweep leaves it alone for 30 days), **Park** (on hold, with a reason that says how long it was quiet) and **Close**. The row leaves the list at once, and the message shows **Undo**. An initiative that waits on another live initiative is not quiet. After you open the list, the row goes away until next week. With nothing quiet, there is no row. From a terminal: `pmos quiet list`.
|
|
58
59
|
- **What moved last week.** Once a week, one row says how many dates and scope changes (tasks added, removed or put back) happened last week on all your products, and how many have no source, for example "Last week: 14 moves in dates and scope" with "3 with no source. See who to ask." under it. Press it to see one list, grouped by product, with the moves that have no source first. Each move shows its source (your own change, the tracker, or the Jira ticket, meeting note or document it names), or **No source** and the owner to ask. A move PMOS made with no reason is always **No source**. A moved date also says how far it is from the task's first plan, for example "30 days behind the first plan (due 1 Nov)", so a slip stays in sight after the date moves. After you open the list, the row goes away until next week. In a week with no moves, there is no row. From a terminal: `node workspace/lib/week-moves.js list` in a product's repository, or `--week <Monday>` for an earlier week.
|
|
59
60
|
- An outbox draft opens with who it is for and the words. **Copy** puts the words on the clipboard, so you send them from your own tool. ✕ discards it, with Undo. Nothing leaves PMOS by itself.
|
|
60
61
|
|
|
@@ -159,7 +160,7 @@ Press the name in the Viewer's header. The name becomes a field.
|
|
|
159
160
|
|
|
160
161
|
- Type the new name. Press Enter or the check to save it. Press Esc to stop without a change. An empty name is not saved.
|
|
161
162
|
- The new name shows at once in the list, the chat header, the Viewer, Work and the Timeline. The message **Renamed** has **Undo**.
|
|
162
|
-
- **A change from the chat shows at once.** When you ask the chat to add, move, close or delete a task, the row changes on Today, Work and an open task popup within a second, without the page reading its lists again. A change you make in one tab of the workspace shows in its other open tabs as soon as it is saved. A change that is not saved does not show in the other tabs.
|
|
163
|
+
- **A change from the chat shows at once.** When you ask the chat to add, move, close or delete a task, the row changes on Today, Work and an open task popup within a second, without the page reading its lists again. A change you make in one tab of the workspace shows in its other open tabs as soon as it is saved. A change that is not saved does not show in the other tabs. A published read-only Board does not follow these changes: it shows the board as it was published.
|
|
163
164
|
- An initiative of another product renames in that product's own repository, the same as on Work.
|
|
164
165
|
- Only the name changes. The id, the record file, the links and the history stay the same.
|
|
165
166
|
- An initiative with a Jira epic shows **Rename the Jira epic too**. It is off by default. When you select it, Today opens the initiative's chat with the request typed. Send it to let your agent rename the epic in Jira. PMOS does not change Jira itself.
|
package/workspace/guide/jira.md
CHANGED
|
@@ -243,6 +243,14 @@ pmos jira query --sprint "<name>"
|
|
|
243
243
|
pmos jira sync --sprint "<name>" --from <file|->
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
+
A past sprint that PMOS saw open and then closed also shows **✦ One change** beside Lessons. PMOS writes it from its own close numbers:
|
|
247
|
+
|
|
248
|
+
- **Carried**: why work moved on: never started, started, in review, carried two sprints in a row, or added after the start.
|
|
249
|
+
- **The change**: one change for the next sprint, aimed at the biggest reason with 2 or more tickets, and the number it should bring down. ✕ drops it. Undo takes the drop back.
|
|
250
|
+
- **The check**: when the previous sprint had a change, whether it helped, with its number before and after.
|
|
251
|
+
|
|
252
|
+
The chat answers and changes the same block with `pmos sprint retro` and `pmos sprint change` ([the command reference](cli.md)).
|
|
253
|
+
|
|
246
254
|
## Each sprint's goal and summary
|
|
247
255
|
|
|
248
256
|
The check then writes a goal and a short summary for each sprint, from the tickets it read. The Sprints tab shows them above the sprint's items, with one row for each group of related work.
|
|
@@ -178,6 +178,9 @@ const VERBS = Object.freeze({
|
|
|
178
178
|
// Not a pm-os-absorb verb (run: null): initiative parked-reason-way-back (bet A446) added it through the same table.
|
|
179
179
|
parked: Object.freeze({ module: 'parked-cli.js', run: null, guide: 'cli.md',
|
|
180
180
|
help: 'pmos parked list|hold|back|coverage — parked initiatives: why each is parked, what brings it back, and bringing it back (pmos parked help)' }),
|
|
181
|
+
// Not a pm-os-absorb verb (run: null): initiative quiet-work-sweep (bet A503) added it through the same table.
|
|
182
|
+
quiet: Object.freeze({ module: 'quiet-cli.js', run: null, guide: 'cli.md',
|
|
183
|
+
help: 'pmos quiet list|keep|park|close|undo — the weekly sweep of initiatives quiet 30 days or more: keep, park or close each (pmos quiet help)' }),
|
|
181
184
|
// Not a pm-os-absorb verb (run: null): chief-unit-owners (Wawan 2026-11-18) added both through the same table.
|
|
182
185
|
units: Object.freeze({ module: 'units-cli.js', run: null, guide: 'cli.md',
|
|
183
186
|
help: 'pmos units [list|show <unit>] — the programs, products and projects, who owns each initiative, and each owner\'s brief (pmos units help)' }),
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* quiet-cli.js — `pmos quiet`: the weekly sweep of quiet work (initiative quiet-work-sweep, bet A503; lib/quiet-sweep.js).
|
|
3
|
+
*
|
|
4
|
+
* pmos quiet list [--json] the initiatives quiet 30 days or more, most quiet first, each with what PMOS suggests
|
|
5
|
+
* pmos quiet keep <id> still on: the sweep leaves it alone for 30 days
|
|
6
|
+
* pmos quiet park <id> [--why "<reason>"] park it (one on-hold line; the reason says how long it was quiet unless you give one)
|
|
7
|
+
* pmos quiet close <id> [--why "<reason>"] close it (one closed line)
|
|
8
|
+
* pmos quiet undo <id> undo the newest sweep answer of that initiative
|
|
9
|
+
* every command: [--root <dir>] (default: this repository)
|
|
10
|
+
*
|
|
11
|
+
* The chat's way to answer the same list Today shows; the agent runs keep, park and close only after the PM said so in the chat.
|
|
12
|
+
* Exit codes: 0 done, 1 refused, 2 usage. Nothing is sent. */
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const { execFileSync } = require('child_process');
|
|
15
|
+
const Q = require('./quiet-sweep.js');
|
|
16
|
+
|
|
17
|
+
const COMMANDS = { quiet: ['list', 'keep', 'park', 'close', 'undo'] };
|
|
18
|
+
const USAGE = [
|
|
19
|
+
'usage: pmos quiet list|keep|park|close|undo — the weekly sweep of initiatives quiet 30 days or more',
|
|
20
|
+
' pmos quiet list [--json] the quiet initiatives, most quiet first, with what PMOS suggests',
|
|
21
|
+
' pmos quiet keep <id> still on: the sweep leaves it alone for 30 days',
|
|
22
|
+
' pmos quiet park <id> [--why "<reason>"] park it with a reason',
|
|
23
|
+
' pmos quiet close <id> [--why "<reason>"] close it',
|
|
24
|
+
' pmos quiet undo <id> undo the newest sweep answer of that initiative',
|
|
25
|
+
'Today shows the same list once a week. Run it in the product\'s repository, or pass --root <dir>.',
|
|
26
|
+
];
|
|
27
|
+
const ALLOWED = { list: ['json', 'root'], keep: ['json', 'root'], park: ['json', 'root', 'why'], close: ['json', 'root', 'why'], undo: ['json', 'root'] };
|
|
28
|
+
const BOOL = new Set(['json']);
|
|
29
|
+
const SAID = { keep: 'kept: the sweep leaves it alone for 30 days', park: 'parked', close: 'closed', undo: 'undone' };
|
|
30
|
+
|
|
31
|
+
function parse(args) {
|
|
32
|
+
const pos = [], flags = {};
|
|
33
|
+
for (let i = 0; i < args.length; i++) {
|
|
34
|
+
const a = args[i];
|
|
35
|
+
if (!a.startsWith('--')) { pos.push(a); continue; }
|
|
36
|
+
const k = a.slice(2);
|
|
37
|
+
if (BOOL.has(k)) flags[k] = true;
|
|
38
|
+
else flags[k] = args[i + 1] !== undefined && !String(args[i + 1]).startsWith('--') ? args[++i] : '';
|
|
39
|
+
}
|
|
40
|
+
return { pos, flags };
|
|
41
|
+
}
|
|
42
|
+
function repoRoot(cwd) {
|
|
43
|
+
try { return execFileSync('git', ['rev-parse', '--show-toplevel'], { cwd, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || cwd; } catch { return cwd; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async function run(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd(), now = Date.now(), isTTY, sweep } = {}) {
|
|
47
|
+
const args = argv[0] === 'quiet' ? argv.slice(1) : argv.slice();
|
|
48
|
+
const sub = args[0];
|
|
49
|
+
if (!sub || ['help', '--help', '-h'].includes(sub)) { for (const l of USAGE) say(l); return sub ? 0 : 1; }
|
|
50
|
+
if (!COMMANDS.quiet.includes(sub)) { say(`unknown quiet command "${sub}". Use one of: ${COMMANDS.quiet.join(', ')}`); return 2; }
|
|
51
|
+
const { pos, flags } = parse(args.slice(1));
|
|
52
|
+
for (const k of Object.keys(flags)) if (!ALLOWED[sub].includes(k)) { say(`✗ --${k} is not an option of pmos quiet ${sub}`); return 2; }
|
|
53
|
+
const root = path.resolve(flags.root || repoRoot(cwd));
|
|
54
|
+
const fail = (error, code = 1) => { say(flags.json ? JSON.stringify({ ok: false, error }) : '✗ ' + error); return code; };
|
|
55
|
+
|
|
56
|
+
if (sub === 'list') {
|
|
57
|
+
if (pos.length) return fail('pmos quiet list takes no argument', 2);
|
|
58
|
+
const s = (sweep || Q.sweepRoot)(root, { now });
|
|
59
|
+
if (!s.ok) return fail(s.error);
|
|
60
|
+
if (flags.json) { say(JSON.stringify(s)); return 0; }
|
|
61
|
+
if (!s.total) { say('Nothing is quiet 30 days or more.'); return 0; }
|
|
62
|
+
say(`${s.total} of ${s.live} live initiatives quiet ${Q.QUIET_DAYS} days or more`);
|
|
63
|
+
for (const it of s.items.slice(0, 50)) say(` ✦ ${it.suggest === 'close' ? 'Close' : 'Park'} · ${it.id} — ${it.title}\n ${it.why}`);
|
|
64
|
+
if (s.total > 50) say(` … ${s.total - 50} more`);
|
|
65
|
+
say('\nAnswer one: pmos quiet keep|park|close <id>');
|
|
66
|
+
return 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (pos.length !== 1) return fail(`usage: pmos quiet ${sub} <id>${sub === 'park' || sub === 'close' ? ' [--why "<reason>"]' : ''}`, 2);
|
|
70
|
+
const id = pos[0];
|
|
71
|
+
const a = require('./actor.js').fromCli({ isTTY: isTTY === undefined ? !!(process.stdin.isTTY && process.stdout.isTTY) : isTTY, env });
|
|
72
|
+
const opts = { now, by: a.by, via: a.via };
|
|
73
|
+
const r = sub === 'keep' ? Q.keep(root, { id }, opts) : sub === 'park' ? Q.park(root, { id, why: flags.why }, opts)
|
|
74
|
+
: sub === 'close' ? Q.close(root, { id, why: flags.why }, opts) : Q.undo(root, { id }, opts);
|
|
75
|
+
if (!r.ok) return fail(r.error);
|
|
76
|
+
if (flags.json) { say(JSON.stringify({ ok: true, file: r.file, line: r.line })); return 0; }
|
|
77
|
+
say(`${Q.TAG} ✓ ${id} ${SAID[sub]} (${r.file}). Undo: pmos quiet undo ${id}. Commit it to keep it.`);
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* quiet-sweep.js — the weekly sweep of quiet work (bet A503, initiative quiet-work-sweep).
|
|
4
|
+
*
|
|
5
|
+
* Work nobody touched for a month still reads as open, so the real work hides behind it (PMOS itself: 467 of 749 live initiatives had
|
|
6
|
+
* no dated change in 30 days on 2026-11-24). Once a week Today's Your move shows one row, "N initiatives quiet 30 days or more", and the
|
|
7
|
+
* list gives each one three presses: Keep (still on), Park (with a reason) or Close, each with Undo. Zero quiet initiatives is no row.
|
|
8
|
+
* Works on any product built with PMOS, in either layout (planning/initiatives or pmos/state/initiatives).
|
|
9
|
+
*
|
|
10
|
+
* QUIET_DAYS = 30 · KEEP_DAYS = 30 · SHOW = 20
|
|
11
|
+
* quietOf(rows, { kept, stopped, now }) PURE → { total, items: [{ id, title, quietDays, station, workflow, suggest, why }] }
|
|
12
|
+
* rows: lib/line.js lineOf rows (GET /api/line's cached rows). Quiet = live, not ended, a dated last change QUIET_DAYS or more
|
|
13
|
+
* ago, and not waiting on another live initiative (that wait is expected). "Can't tell" with no dated change is left out (a guess
|
|
14
|
+
* never makes a row). kept: Map id → ISO time of the newest Keep; a Keep hides the row for KEEP_DAYS. stopped: Set of ids whose
|
|
15
|
+
* latest lifecycle line is not active (parked or closed since the line was read). Most quiet first.
|
|
16
|
+
* suggest: 'close' when it sits on its workflow's last stage (its work is done, only the close is missing), else 'park'.
|
|
17
|
+
* weekOf(now) → 'YYYY-MM-DD', the Monday of that week (local time): the row's key, so it shows once a week
|
|
18
|
+
* rowOf(sweep, { looked, week }) PURE → the Your move row { key, go: 'quiet', week, title, sub } or null (none quiet, or looked)
|
|
19
|
+
* keptOf(root) · stoppedOf(root) read the ledgers (quiet-sweep.jsonl, lifecycle.jsonl)
|
|
20
|
+
* keep(root, { id, undo }, { now, by, via }) → { ok, file, line } one `keep` (or `unkeep`) line in quiet-sweep.jsonl
|
|
21
|
+
* park(root, { id, why }, opts) → lib/parked-reasons.js hold, with a default reason that says how long it was quiet
|
|
22
|
+
* close(root, { id, why }, opts) → { ok, file, line } one `closed` lifecycle line (D70), the same shape POST /api/lifecycle writes
|
|
23
|
+
* reopen(root, { id }, opts) → { ok, file, line } the Undo of park and close: one `active` lifecycle line
|
|
24
|
+
* lastAnswer(root, id) → { act: 'keep' | 'park' | 'close', at } | null the newest sweep answer still standing (for Undo)
|
|
25
|
+
* undo(root, { id }, opts) → unkeep a Keep, or reopen a park or close the sweep made
|
|
26
|
+
* answered(root, { days, now }) → how many sweep answers (keep, park, close) in the last `days` days: the kill number
|
|
27
|
+
* CLI: node lib/quiet-sweep.js count [root] the health number (quiet initiatives) on its last line
|
|
28
|
+
* node lib/quiet-sweep.js answered [root] [--days N] sweep answers in the last N days (default 14) on its last line
|
|
29
|
+
*
|
|
30
|
+
* The page parks and closes through POST /api/lifecycle (the PM's press) and keeps through POST /api/quiet/keep; `pmos quiet` is the
|
|
31
|
+
* chat's way (lib/quiet-cli.js). Every line this module writes or prints carries `[quiet-sweep]` in the log. Nothing is sent. */
|
|
32
|
+
const fs = require('fs');
|
|
33
|
+
const path = require('path');
|
|
34
|
+
|
|
35
|
+
const TAG = '[quiet-sweep]';
|
|
36
|
+
const FILE = 'quiet-sweep.jsonl';
|
|
37
|
+
const LIFE = 'lifecycle.jsonl';
|
|
38
|
+
const QUIET_DAYS = 30;
|
|
39
|
+
const KEEP_DAYS = 30;
|
|
40
|
+
const SHOW = 20;
|
|
41
|
+
const DAY = 864e5;
|
|
42
|
+
const ID_RE = /^[a-z0-9][a-z0-9._-]*$/i;
|
|
43
|
+
|
|
44
|
+
const P = () => require('./parked-reasons.js');
|
|
45
|
+
const rel = (root, f) => path.relative(root, f).split(path.sep).join('/');
|
|
46
|
+
const clip = (s, n) => { const t = String(s || '').replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).replace(/\s+\S*$/, '') + '…' : t; };
|
|
47
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
48
|
+
|
|
49
|
+
function jsonl(file) {
|
|
50
|
+
let text = '';
|
|
51
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
52
|
+
const out = [];
|
|
53
|
+
for (const l of text.split('\n')) { if (!l.trim()) continue; try { const r = JSON.parse(l); if (r && typeof r === 'object') out.push(r); } catch { /* a torn line */ } }
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The quiet initiatives of a product's line, most quiet first. */
|
|
58
|
+
function quietOf(rows, { kept = new Map(), stopped = new Set(), now = Date.now() } = {}) {
|
|
59
|
+
const items = [];
|
|
60
|
+
for (const r of Array.isArray(rows) ? rows : []) {
|
|
61
|
+
if (!r || !r.id || !r.live || r.ended) continue;
|
|
62
|
+
if (r.flag === 'waiting') continue;
|
|
63
|
+
const q = Number(r.quietDays);
|
|
64
|
+
if (!Number.isFinite(q) || q < QUIET_DAYS) continue;
|
|
65
|
+
if (stopped.has(r.id)) continue;
|
|
66
|
+
const k = Date.parse(kept.get(r.id) || '');
|
|
67
|
+
if (Number.isFinite(k) && now - k < KEEP_DAYS * DAY) continue;
|
|
68
|
+
const st = r.station || null;
|
|
69
|
+
const last = !!(st && st.n && st.of && st.n === st.of);
|
|
70
|
+
items.push({ id: r.id, title: r.title || r.id, quietDays: q, station: st ? st.name : null, workflow: r.workflow || null, ws: r.ws || '',
|
|
71
|
+
suggest: last ? 'close' : 'park',
|
|
72
|
+
why: last ? `On its last stage (${st.name}) and quiet ${q} days: only the close is missing.` : `Quiet ${q} days${st ? ' on ' + st.name : ''}.` });
|
|
73
|
+
}
|
|
74
|
+
items.sort((a, b) => b.quietDays - a.quietDays || a.id.localeCompare(b.id));
|
|
75
|
+
return { total: items.length, items };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The Monday of `now`'s week, local time. */
|
|
79
|
+
function weekOf(now = Date.now()) {
|
|
80
|
+
const d = new Date(now);
|
|
81
|
+
d.setHours(12, 0, 0, 0);
|
|
82
|
+
d.setDate(d.getDate() - ((d.getDay() + 6) % 7));
|
|
83
|
+
return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0');
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Today's Your move row, or null: none quiet (zero is silence), or the PM opened this week's list. */
|
|
87
|
+
function rowOf(sweep, { looked = '', week = weekOf() } = {}) {
|
|
88
|
+
const n = sweep && sweep.total ? sweep.total : 0;
|
|
89
|
+
if (!n || looked === week) return null;
|
|
90
|
+
return { key: 'quiet:' + week, go: 'quiet', week,
|
|
91
|
+
title: plural(n, 'initiative', 'initiatives') + ' quiet ' + QUIET_DAYS + ' days or more',
|
|
92
|
+
sub: 'Keep, park or close each one. Undo stays open.' };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function ledgerDir(root) { const L = P().layoutOf(root); return L ? L.runs : null; }
|
|
96
|
+
|
|
97
|
+
/** id → ISO time of the newest Keep (an `unkeep` after it takes it back). */
|
|
98
|
+
function keptOf(root) {
|
|
99
|
+
const dir = ledgerDir(root); const out = new Map();
|
|
100
|
+
if (!dir) return out;
|
|
101
|
+
for (const r of jsonl(path.join(dir, FILE))) {
|
|
102
|
+
if (typeof r.initiative_id !== 'string') continue;
|
|
103
|
+
if (r.act === 'keep') out.set(r.initiative_id, r.at);
|
|
104
|
+
else if (r.act === 'unkeep') out.delete(r.initiative_id);
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The ids whose latest lifecycle line is not `active`: parked, closed or cancelled since the line was read. */
|
|
110
|
+
function stoppedOf(root) {
|
|
111
|
+
const dir = ledgerDir(root); const latest = new Map();
|
|
112
|
+
if (!dir) return new Set();
|
|
113
|
+
for (const r of jsonl(path.join(dir, LIFE))) if (typeof r.initiative_id === 'string' && typeof r.state === 'string') latest.set(r.initiative_id, r.state);
|
|
114
|
+
return new Set([...latest].filter(([, s]) => s !== 'active').map(([id]) => id));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function pmSlug() { try { return require('./actor.js').PM_SLUG || 'pm'; } catch { return 'pm'; } }
|
|
118
|
+
function append(root, file, line) {
|
|
119
|
+
try {
|
|
120
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
121
|
+
const st = (() => { try { return fs.lstatSync(file); } catch { return null; } })();
|
|
122
|
+
if (st && !st.isFile()) return { ok: false, error: path.basename(file) + ' is not a plain file — nothing was saved' };
|
|
123
|
+
fs.appendFileSync(file, JSON.stringify(line) + '\n');
|
|
124
|
+
console.info(`${TAG} ${line.act || line.state} ${line.initiative_id}`);
|
|
125
|
+
return { ok: true, file: rel(root, file), line };
|
|
126
|
+
} catch (e) { return { ok: false, error: path.basename(file) + ' could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
|
|
127
|
+
}
|
|
128
|
+
function check(root, id) {
|
|
129
|
+
const L = P().layoutOf(root);
|
|
130
|
+
if (!L) return { error: 'this folder has no initiatives (planning/initiatives or pmos/state/initiatives)' };
|
|
131
|
+
if (!ID_RE.test(String(id || ''))) return { error: 'name the initiative by its id' };
|
|
132
|
+
if (fs.existsSync(path.join(L.initiatives, id + '.md'))) return { L };
|
|
133
|
+
// the file name is the id in both layouts, unless the record's frontmatter says another `id:`
|
|
134
|
+
let files = []; try { files = fs.readdirSync(L.initiatives).filter((f) => f.endsWith('.md')); } catch { files = []; }
|
|
135
|
+
const re = new RegExp('^id:\\s*["\']?' + id.replace(/[.]/g, '\\.') + '["\']?\\s*$', 'm');
|
|
136
|
+
for (const f of files) {
|
|
137
|
+
let head = ''; try { head = fs.readFileSync(path.join(L.initiatives, f), 'utf8').slice(0, 2000); } catch { continue; }
|
|
138
|
+
const fm = /^---\n([\s\S]*?)\n---/.exec(head);
|
|
139
|
+
if (fm && re.test(fm[1])) return { L };
|
|
140
|
+
}
|
|
141
|
+
return { error: `no initiative ${id} here` };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Still on: one `keep` line; the row stays away for KEEP_DAYS. `undo` writes `unkeep`. */
|
|
145
|
+
function keep(root, { id, undo = false } = {}, { now = Date.now(), by, via } = {}) {
|
|
146
|
+
root = path.resolve(root);
|
|
147
|
+
const c = check(root, id); if (c.error) return { ok: false, error: c.error };
|
|
148
|
+
return append(root, path.join(c.L.runs, FILE), { initiative_id: id, act: undo ? 'unkeep' : 'keep', week: weekOf(now), pm: pmSlug(), by: by || 'agent:unknown', via: via || 'cli', at: new Date(now).toISOString() });
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Park it: one on-hold line through lib/parked-reasons.js, with the reason given or one that says how long it was quiet. */
|
|
152
|
+
function park(root, { id, why, days } = {}, opts = {}) {
|
|
153
|
+
const reason = String(why || '').trim() || `Quiet${Number.isFinite(days) ? ' ' + days + ' days' : ''}; parked in the weekly sweep`;
|
|
154
|
+
const r = P().hold(path.resolve(root), { id, why: reason }, opts);
|
|
155
|
+
if (r && r.ok) console.info(`${TAG} park ${id}`);
|
|
156
|
+
return r;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function lifeLine(root, id, state, reason, { now = Date.now(), by, via } = {}) {
|
|
160
|
+
root = path.resolve(root);
|
|
161
|
+
const c = check(root, id); if (c.error) return { ok: false, error: c.error };
|
|
162
|
+
return append(root, path.join(c.L.runs, LIFE), { initiative_id: id, state, reason: clip(reason, 500), pm: pmSlug(), by: by || 'agent:unknown', via: via || 'cli', at: new Date(now).toISOString() });
|
|
163
|
+
}
|
|
164
|
+
/** Close it: one `closed` lifecycle line. */
|
|
165
|
+
function close(root, { id, why } = {}, opts = {}) { return lifeLine(root, id, 'closed', String(why || '').trim() || 'Closed in the weekly sweep of quiet work', opts); }
|
|
166
|
+
/** The Undo of park and close: one `active` lifecycle line. */
|
|
167
|
+
// reason 'undo': the decision journal takes the park's decision out again (lib/decision-journal.js onLifecycle), as the Board's Undo does
|
|
168
|
+
function reopen(root, { id } = {}, opts = {}) {
|
|
169
|
+
const r = lifeLine(root, id, 'active', 'undo', opts);
|
|
170
|
+
if (r.ok) { try { require('./decision-journal.js').onLifecycle(path.resolve(root), r.line, { now: opts.now }); } catch { /* the lifecycle line holds the undo */ } }
|
|
171
|
+
return r;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const SWEPT = /weekly sweep/i;
|
|
175
|
+
/** The newest sweep answer still standing for one initiative, or null. */
|
|
176
|
+
function lastAnswer(root, id) {
|
|
177
|
+
const dir = ledgerDir(path.resolve(root)); if (!dir) return null;
|
|
178
|
+
let best = null;
|
|
179
|
+
for (const r of jsonl(path.join(dir, FILE))) if (r.initiative_id === id) best = r.act === 'keep' ? { act: 'keep', at: r.at } : r.act === 'unkeep' ? null : best;
|
|
180
|
+
let life = null;
|
|
181
|
+
for (const r of jsonl(path.join(dir, LIFE))) if (r.initiative_id === id) life = r;
|
|
182
|
+
if (life && (life.state === 'on-hold' || life.state === 'closed') && SWEPT.test(String(life.reason || ''))) {
|
|
183
|
+
const a = { act: life.state === 'closed' ? 'close' : 'park', at: life.at };
|
|
184
|
+
if (!best || String(a.at || '') >= String(best.at || '')) best = a;
|
|
185
|
+
}
|
|
186
|
+
return best;
|
|
187
|
+
}
|
|
188
|
+
/** Undo the newest sweep answer of one initiative. */
|
|
189
|
+
function undo(root, { id } = {}, opts = {}) {
|
|
190
|
+
const a = lastAnswer(root, id);
|
|
191
|
+
if (!a) return { ok: false, error: `${id} has no answer from the weekly sweep to undo` };
|
|
192
|
+
return a.act === 'keep' ? keep(root, { id, undo: true }, opts) : reopen(root, { id }, opts);
|
|
193
|
+
}
|
|
194
|
+
/** Sweep answers in the last `days` days: keeps in quiet-sweep.jsonl, parks and closes in lifecycle.jsonl whose reason names the sweep. */
|
|
195
|
+
function answered(root, { days = 14, now = Date.now() } = {}) {
|
|
196
|
+
const dir = ledgerDir(path.resolve(root)); if (!dir) return 0;
|
|
197
|
+
const since = now - days * DAY, inside = (r) => Date.parse(r.at) >= since;
|
|
198
|
+
const keeps = jsonl(path.join(dir, FILE)).filter((r) => r.act === 'keep' && inside(r)).length;
|
|
199
|
+
const life = jsonl(path.join(dir, LIFE)).filter((r) => (r.state === 'on-hold' || r.state === 'closed') && SWEPT.test(String(r.reason || '')) && inside(r)).length;
|
|
200
|
+
return keeps + life;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** The whole sweep of one repository from its own line (the CLI; the server uses its cached line rows instead). */
|
|
204
|
+
function sweepRoot(root, { now = Date.now() } = {}) {
|
|
205
|
+
root = path.resolve(root);
|
|
206
|
+
const L = require('./line.js').lineOf(root, { now });
|
|
207
|
+
if (!L.ok) return { ok: false, error: L.error || 'the line could not be read' };
|
|
208
|
+
const live = (L.rows || []).filter((r) => r.live && !r.ended).length;
|
|
209
|
+
return { ok: true, live, ...quietOf(L.rows, { kept: keptOf(root), stopped: stoppedOf(root), now }) };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
module.exports = { TAG, FILE, QUIET_DAYS, KEEP_DAYS, SHOW, quietOf, weekOf, rowOf, keptOf, stoppedOf, keep, park, close, reopen, lastAnswer, undo, answered, sweepRoot };
|
|
213
|
+
|
|
214
|
+
if (require.main === module) {
|
|
215
|
+
const [cmd, rootArg, ...rest] = process.argv.slice(2);
|
|
216
|
+
if (cmd === 'answered') {
|
|
217
|
+
const i = rest.indexOf('--days');
|
|
218
|
+
const days = i >= 0 ? Math.max(1, parseInt(rest[i + 1], 10) || 14) : 14;
|
|
219
|
+
const n = answered(rootArg || '.', { days });
|
|
220
|
+
console.log(`${TAG} ${n} quiet initiatives answered (keep, park or close) in the last ${days} days`);
|
|
221
|
+
console.log(String(n));
|
|
222
|
+
} else if (cmd !== 'count') { console.log('usage: node lib/quiet-sweep.js count [root] | answered [root] [--days N]'); process.exitCode = 2; }
|
|
223
|
+
else {
|
|
224
|
+
const s = sweepRoot(rootArg || '.');
|
|
225
|
+
if (!s.ok) { console.log(`${TAG} ${s.error}`); process.exitCode = 1; }
|
|
226
|
+
else { console.log(`${TAG} ${s.total} of ${s.live} live initiatives quiet ${QUIET_DAYS} days or more`); console.log(String(s.total)); }
|
|
227
|
+
}
|
|
228
|
+
}
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
* lib/sprint-history.js detailOf. GET /api/backlog also carries sprintList (the picker, SpH1) and
|
|
20
20
|
* sprintTrend (the carried-over line and bars), and sprintNow (This sprint: every task in the
|
|
21
21
|
* active sprint's dates, Jira and not, done ones too; lib/sprint-now.js).
|
|
22
|
+
* POST /api/backlog/sprint-retro { ws, board, sprint, ev: pick|drop|undo, reason? } the PM's override of a closed sprint's one tracked
|
|
23
|
+
* change (lib/sprint-retro.js; GET /api/backlog/sprint carries the retro as sprint.retro)
|
|
22
24
|
* POST /api/backlog/rank { ws, board, order: [id] } the Backlog's one rank across initiatives (a backlog-rank line on the board
|
|
23
25
|
* ledger; D105). GET /api/backlog carries it as backlogRank, each task's inSprint and touched (its last
|
|
24
26
|
* change), and sprintNext (the earliest future sprint, as Jira holds it).
|
|
@@ -42,6 +44,7 @@ const SO = require('./sprint-overview.js');
|
|
|
42
44
|
const SH = require('./sprint-history.js');
|
|
43
45
|
const RR = require('./rollover-reasons.js');
|
|
44
46
|
const SN = require('./sprint-now.js');
|
|
47
|
+
const SR = require('./sprint-retro.js');
|
|
45
48
|
/** The PM's own name for Who (PMOS_PM_NAME, else git's user.name: the name Home greets them by); '' when neither is set. */
|
|
46
49
|
const pmNameOf = () => { try { return require('./routes-board-publish.js').sharedBy() || ''; } catch { return ''; } };
|
|
47
50
|
|
|
@@ -224,9 +227,14 @@ async function handle(req, res, url, ctx) {
|
|
|
224
227
|
const name = text(url.searchParams.get('sprint')).slice(0, 120);
|
|
225
228
|
const d = name ? SH.detailOf(name, L._sin) : null;
|
|
226
229
|
if (!d) return send(bad(404, 'PMOS knows no sprint of that name on this board'));
|
|
230
|
+
// the retro and its one tracked change (initiative sprint-retro-one-change), in the board's own sprint order
|
|
231
|
+
if (d.state === 'closed') {
|
|
232
|
+
const order = (L.sprintList || []).filter((x) => x.state === 'closed').map((x) => x.name);
|
|
233
|
+
try { d.retro = SR.retroOf(L._sin.lines, name, { order, overrides: SR.readOverrides(L._w.root) }); } catch { d.retro = null; }
|
|
234
|
+
}
|
|
227
235
|
return send({ status: 200, body: { ok: true, ws: L.ws, board: L.board, sprint: d } });
|
|
228
236
|
}
|
|
229
|
-
if (!['give', 'stop', 'decide', 'undo', 'decline', 'place', 'rank', 'sprint-draft', 'sprint-note', 'sprint-reason'].includes(sub)) return send(bad(404, 'no such route'));
|
|
237
|
+
if (!['give', 'stop', 'decide', 'undo', 'decline', 'place', 'rank', 'sprint-draft', 'sprint-note', 'sprint-retro', 'sprint-reason'].includes(sub)) return send(bad(404, 'no such route'));
|
|
230
238
|
if (req.method !== 'POST') return send(bad(405, 'POST only'));
|
|
231
239
|
const read = await ctx.readJson(req);
|
|
232
240
|
if (!read.ok || !read.body || typeof read.body !== 'object') return send(bad(400, 'the body must be a JSON object'));
|
|
@@ -272,6 +280,18 @@ async function handle(req, res, url, ctx) {
|
|
|
272
280
|
return send({ status: 200, body: { ok: true, was } });
|
|
273
281
|
}
|
|
274
282
|
|
|
283
|
+
// the PM's override of a closed sprint's tracked change (initiative sprint-retro-one-change): ✕ drops it, Undo takes the ✕ back
|
|
284
|
+
if (sub === 'sprint-retro') {
|
|
285
|
+
const sprint = text(body.sprint).slice(0, 120), ev = text(body.ev);
|
|
286
|
+
const closed = (L.sprintList || []).filter((x) => x.state === 'closed').map((x) => x.name);
|
|
287
|
+
if (!sprint || !closed.includes(sprint)) return send(bad(404, 'no closed sprint of that name on this board'));
|
|
288
|
+
if (!['pick', 'drop', 'undo'].includes(ev)) return send(bad(400, 'ev is pick, drop or undo'));
|
|
289
|
+
const r = SR.appendOverride(L._w.root, { sprint, ev, reason: ev === 'pick' ? text(body.reason) : null, by: g.actor.by });
|
|
290
|
+
if (!r.ok) return send(bad(400, r.error));
|
|
291
|
+
let retro = null; try { retro = SR.retroOf(L._sin.lines, sprint, { order: closed, overrides: SR.readOverrides(L._w.root) }); } catch { retro = null; }
|
|
292
|
+
return send({ status: 200, body: { ok: true, retro } });
|
|
293
|
+
}
|
|
294
|
+
|
|
275
295
|
if (sub === 'place') {
|
|
276
296
|
const key = text(body.key).toUpperCase(), to = text(body.to);
|
|
277
297
|
if (!/^[A-Z][A-Z0-9_]*-\d+$/.test(key)) return send(bad(400, 'key is a Jira key like IDPF-3340'));
|
|
@@ -28,7 +28,11 @@
|
|
|
28
28
|
* GET /api/digest?ws=<id> → { ok, ws, rows, did, lapsed } | { ok, ws, off: true } (quiet-rows slice C: the weekly digest, built on the
|
|
29
29
|
* page by pm/digest-view.js). rows: the cached line; did: the autonomy ledger's applied changes of the last
|
|
30
30
|
* 14 days ({ title, ini, at, undone, checked: PASS | FAIL | null, src }); lapsed: the queued or blocked
|
|
31
|
-
* drafts waiting to send for this product, older than 7 days (lib/digest-parts.js). With the setting digest.on false it reads nothing.
|
|
31
|
+
* drafts waiting to send for this product, older than 7 days (lib/digest-parts.js). With the setting digest.on false it reads nothing.
|
|
32
|
+
* GET /api/quiet?ws=<id> → { ok, ws, name, week, total, shown, items: [lib/quiet-sweep.js quietOf item], row } (quiet-work-sweep, bet A503:
|
|
33
|
+
* the initiatives quiet 30 days or more, from the cached line; most quiet first, at most SHOW of them)
|
|
34
|
+
* POST /api/quiet/keep { ws, id, undo? } → { ok, line } still on: one keep (or unkeep) line in quiet-sweep.jsonl, the page's press.
|
|
35
|
+
* Park and close go through POST /api/lifecycle, the PM's press. */
|
|
32
36
|
const YM = require('./your-move.js');
|
|
33
37
|
|
|
34
38
|
const localDay = (ms = Date.now()) => { const d = new Date(ms); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
|
|
@@ -156,12 +160,44 @@ function youOf(ctx, w, today) {
|
|
|
156
160
|
return [...out];
|
|
157
161
|
}
|
|
158
162
|
|
|
163
|
+
/** quiet-work-sweep (bet A503): the weekly sweep of quiet work, read from the cached line; Keep is the one write here. */
|
|
164
|
+
async function quietRoute(req, res, url, ctx) {
|
|
165
|
+
const QS = require('./quiet-sweep.js');
|
|
166
|
+
const keepIt = url.pathname === '/api/quiet/keep';
|
|
167
|
+
if (req.method !== (keepIt ? 'POST' : 'GET')) { ctx.json(res, { ok: false, error: keepIt ? 'POST only' : 'GET only' }, 405); return true; }
|
|
168
|
+
let body = {};
|
|
169
|
+
if (keepIt) {
|
|
170
|
+
const got = await ctx.readJson(req);
|
|
171
|
+
if (!got.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return true; }
|
|
172
|
+
body = got.body || {};
|
|
173
|
+
}
|
|
174
|
+
let w = null;
|
|
175
|
+
try { w = ctx.getWs((keepIt ? body.ws : url.searchParams.get('ws')) || null); } catch { w = null; }
|
|
176
|
+
if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
|
|
177
|
+
if (keepIt) {
|
|
178
|
+
const g = require('./pm-guard.js').requirePagePress(req, body);
|
|
179
|
+
if (!g.ok) { ctx.json(res, { ok: false, error: g.error }, g.status); return true; }
|
|
180
|
+
const r = QS.keep(w.root, { id: String(body.id || ''), undo: body.undo === true }, { by: g.actor && g.actor.by, via: (g.actor && g.actor.via) || 'page' });
|
|
181
|
+
ctx.json(res, r, r.ok ? 200 : 400);
|
|
182
|
+
return true;
|
|
183
|
+
}
|
|
184
|
+
let rows = [];
|
|
185
|
+
// ctx.quietLine: a test's line rows instead of the cached child-process read
|
|
186
|
+
try { rows = await (ctx.quietLine || lineRows)(w); } catch (e) { ctx.json(res, { ok: false, error: 'the line could not be read: ' + (e && e.message) }, 500); return true; }
|
|
187
|
+
const S = QS.quietOf(rows, { kept: QS.keptOf(w.root), stopped: QS.stoppedOf(w.root) });
|
|
188
|
+
const week = QS.weekOf();
|
|
189
|
+
console.info(QS.TAG + ' read ws=' + w.id + ' quiet=' + S.total);
|
|
190
|
+
ctx.json(res, { ok: true, ws: w.id, name: w.name || w.id, week, total: S.total, shown: Math.min(S.total, QS.SHOW), items: S.items.slice(0, QS.SHOW), row: QS.rowOf(S, { week }) });
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
|
|
159
194
|
const digestParts = (ctx, w, now) => require('./digest-parts.js').partsOf(ctx, w, lineRows, now); // quiet-rows-digest (reads only)
|
|
160
195
|
|
|
161
196
|
module.exports = {
|
|
162
|
-
expire, questions, asksOf, lineRows, digestParts,
|
|
163
|
-
prefixes: ['/api/your-move', '/api/line', '/api/digest'],
|
|
197
|
+
expire, questions, asksOf, lineRows, digestParts, quietRoute,
|
|
198
|
+
prefixes: ['/api/your-move', '/api/line', '/api/digest', '/api/quiet'],
|
|
164
199
|
handle: async (req, res, url, ctx) => {
|
|
200
|
+
if (url.pathname === '/api/quiet' || url.pathname === '/api/quiet/keep') return quietRoute(req, res, url, ctx);
|
|
165
201
|
if (url.pathname === '/api/digest') {
|
|
166
202
|
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
167
203
|
let w = null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.786.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.786.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
* one ✦ line on the carried-over work and its bars. A past sprint shows frozen (SpH2): the snapshot mark, done of total, carried to
|
|
17
17
|
* which sprint, points, the goal result, its themes, What happened (PMOS-written, editable) and Lessons (the PM's), and the list below is
|
|
18
18
|
* that sprint's tickets with their state at close. A sprint PMOS never saw (SpH3) says so once, with an icon to read it from Jira now.
|
|
19
|
+
* ✦ One change (initiative sprint-retro-one-change): why work was carried, the one change tracked into the next sprint (✕ drops it,
|
|
20
|
+
* with Undo), and whether the previous sprint's change helped (lib/sprint-retro.js, sprint.retro on GET /api/backlog/sprint).
|
|
19
21
|
* pm/bd-backlog.js calls bandHtml() while the chip is on, themeOf() for the list, pastOn()/pastListHtml() for a past sprint's list, and
|
|
20
22
|
* press() first on each press in the Backlog. */
|
|
21
23
|
import * as SK from './bk-sprint.js';
|
|
@@ -209,9 +211,27 @@ function pastHtml(o, H, x, deps) {
|
|
|
209
211
|
const carriedCol = x.carried ? `<div class="sbo-b"><h4>Carried to ${esc(to)}</h4><ul><li><span>${x.carried} open ${x.carried === 1 ? 'ticket' : 'tickets'}</span>`
|
|
210
212
|
+ (x.carriedTo && H.list.some((y) => y.name === x.carriedTo) ? `<button type="button" class="bk-lnk" data-spgo="${esc(x.carriedTo)}">open ${esc(to)}</button>` : '') + '</li>'
|
|
211
213
|
+ (whyLine ? `<li class="sbo-why"><span>${esc(whyLine)}</span></li>` : '') + '</ul></div>' : '';
|
|
212
|
-
const pl = `<div class="sbo-pl">${pblock('happened', 'What happened', happened, !note.happened, 'PMOS writes this when the sprint closes.')}${carriedCol}${pblock('lessons', 'Lessons', lessons, false, 'Add what the team learned. Kept with the snapshot.')}</div>`;
|
|
214
|
+
const pl = `<div class="sbo-pl">${pblock('happened', 'What happened', happened, !note.happened, 'PMOS writes this when the sprint closes.')}${carriedCol}${pblock('lessons', 'Lessons', lessons, false, 'Add what the team learned. Kept with the snapshot.')}${d && d.retro ? retroHtml(d.retro, to) : ''}</div>`;
|
|
213
215
|
return `<section class="sbo-band sbo-past" aria-label="${esc(SK.labelOf(x.name))}, snapshot"><div class="sbo-top">${sum}${th}</div>${pl}</section>`;
|
|
214
216
|
}
|
|
217
|
+
/** One change (initiative sprint-retro-one-change): why work was carried, the one change PMOS tracks into the next sprint, and whether the
|
|
218
|
+
* previous sprint's change helped. Built from the system's sbo-b block. Zero is silence: nothing to say draws nothing. */
|
|
219
|
+
const RESULT = { helped: ['It helped.', 'green'], same: ['No change.', 'amber'], worse: ['It got worse.', 'red'] };
|
|
220
|
+
export function retroHtml(x, to) {
|
|
221
|
+
if (!x || !x.reasons) return '';
|
|
222
|
+
const r = x.reasons, L = [];
|
|
223
|
+
const parts = [r.never && `${r.never} never started`, r.started && `${r.started} started`, r.review && `${r.review} in review`, r.twice && `${r.twice} carried two sprints in a row`].filter(Boolean);
|
|
224
|
+
if (r.carried && parts.length) L.push(`<li><span>Carried: ${esc(parts.join(' · '))}${r.added ? esc(` · ${r.added} added after the start`) : ''}</span></li>`);
|
|
225
|
+
if (x.change) L.push(`<li><span>${esc(x.change.text)} <span class="sbo-meta">${esc(x.change.number)}: ${x.change.count}</span></span>`
|
|
226
|
+
+ `<button type="button" class="bk-ib" data-spretro="drop" aria-label="Drop this change" title="Drop this change">${SV(I.x)}</button></li>`);
|
|
227
|
+
else if (x.by === 'dropped') L.push('<li><span>No change tracked: you dropped it.</span></li>');
|
|
228
|
+
if (x.check) {
|
|
229
|
+
const [w, c] = RESULT[x.check.result] || RESULT.same;
|
|
230
|
+
L.push(`<li><span><i class="bk-dot ${c}"></i>Last sprint's change: ${esc(x.check.number)} went from ${x.check.before} to ${x.check.after}. ${w}</span></li>`);
|
|
231
|
+
}
|
|
232
|
+
if (!L.length) return '';
|
|
233
|
+
return `<div class="sbo-b"><h4><span class="sbo-s" aria-hidden="true">${SPARK}</span>One change${x.change ? ' for ' + esc(to) : ''}</h4><ul>${L.join('')}</ul></div>`;
|
|
234
|
+
}
|
|
215
235
|
/** True while the band shows a past sprint that has a snapshot: the list below is its tickets (pastListHtml). */
|
|
216
236
|
export const pastOn = () => !!(CURP && CURP.x.kept !== 'none');
|
|
217
237
|
/** The past sprint's tickets with their state at close (SpH2), in the Backlog's own table. '' while the snapshot is read. */
|
|
@@ -282,6 +302,14 @@ export async function press(e, deps) {
|
|
|
282
302
|
for (const ms of [60000, 150000, 300000]) setTimeout(() => { DET.delete(k); deps.load(); }, ms);
|
|
283
303
|
return true;
|
|
284
304
|
}
|
|
305
|
+
if (CURP && CURP.d && hit('data-spretro')) {
|
|
306
|
+
const at = { ws: CURP.H.ws, board: CURP.H.board, sprint: CURP.x.name }, k = at.ws + '|' + at.board + '|' + at.sprint;
|
|
307
|
+
const r = await deps.post('/api/backlog/sprint-retro', { ...at, ev: 'drop' });
|
|
308
|
+
if (!r || r.ok === false) { deps.say((r && r.error) || 'The change was not dropped.'); return true; }
|
|
309
|
+
DET.delete(k);
|
|
310
|
+
deps.say('No change tracked for ' + SK.labelOf(at.sprint) + '.', async () => { await deps.post('/api/backlog/sprint-retro', { ...at, ev: 'undo' }); DET.delete(k); deps.load(); });
|
|
311
|
+
await deps.load(); return true;
|
|
312
|
+
}
|
|
285
313
|
if (CURP && (b = hit('data-sppedit'))) { EDIT = EDIT === b.dataset.sppedit ? '' : b.dataset.sppedit; deps.draw(); const ta = document.querySelector('[data-spta]'); if (ta) ta.focus(); return true; }
|
|
286
314
|
if (CURP && (b = hit('data-sppsave'))) {
|
|
287
315
|
const k = b.dataset.sppsave, ta = document.querySelector(`[data-spta="${k}"]`), words = ta ? ta.value.trim() : '';
|
|
@@ -448,6 +448,8 @@ function rankIn() {
|
|
|
448
448
|
for (const l of S.lab || []) extra.push({ key: 'lab:' + l.ws, go: 'lab', ws: l.ws, board: l.board, title: l.n + (l.n === 1 ? ' Lab finding' : ' Lab findings') + ' to keep or drop', sub: l.say || 'Keep one to start an initiative, or let it go.' });
|
|
449
449
|
// weekly-what-moved (A441): last week's date and scope moves of every product, one row until the PM opens the list (pm/moves-view.js)
|
|
450
450
|
if (S.movesRow) extra.push(S.movesRow);
|
|
451
|
+
// quiet-work-sweep (A503): the initiatives quiet 30 days or more on every product, one row a week until the PM opens the list (pm/quiet-view.js)
|
|
452
|
+
if (S.quietRow) extra.push(S.quietRow);
|
|
451
453
|
// try-what-shipped: one row while the updates brought changes to try (beta only; GET /api/try says the row, pm/try-view.js opens the list)
|
|
452
454
|
if (S.tryRow) extra.push(S.tryRow);
|
|
453
455
|
return { products, programs: S.D.programs || [], move: S.move || {}, mentions: MEN.mentionsOf(S.D).waiting, outbox: S.outbox || [], gaps: (S.wait && S.wait.gaps) || [], extra };
|
|
@@ -476,12 +478,17 @@ async function readMove() {
|
|
|
476
478
|
S.moves = mv.filter((r) => r && r.ok);
|
|
477
479
|
const prevMoves = JSON.stringify(S.movesRow || null);
|
|
478
480
|
try { const MV = await import('./moves-view.js'); S.movesRow = MV.rowOf(S.moves, { looked: MV.lookedWeek() }); } catch { S.movesRow = null; }
|
|
481
|
+
// quiet-work-sweep (A503): each product's quiet initiatives (GET /api/quiet, from the cached line), folded into one Your move row
|
|
482
|
+
const qs = await Promise.all(L.map((ws) => pmGet('/api/quiet' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)));
|
|
483
|
+
S.quiet = qs.filter((r) => r && r.ok);
|
|
484
|
+
const prevQuiet = JSON.stringify(S.quietRow || null);
|
|
485
|
+
try { const QV = await import('./quiet-view.js'); S.quietRow = QV.rowOf(S.quiet, { looked: QV.lookedWeek() }); } catch { S.quietRow = null; }
|
|
479
486
|
const prevTry = JSON.stringify(S.tryRow || null);
|
|
480
487
|
try { const TV = await import('./try-view.js'); S.tryRow = TV.rowOf(await pmGet('/api/try').catch(() => null)); } catch { S.tryRow = null; }
|
|
481
488
|
const ob = await pmGet('/api/outbox').catch(() => null);
|
|
482
489
|
const outbox = ob && ob.ok && Array.isArray(ob.entries) ? ob.entries.filter((e) => e && (e.state === 'queued' || e.state === 'blocked')) : [];
|
|
483
490
|
const lab = labs.filter(Boolean);
|
|
484
|
-
const same = JSON.stringify(next) === JSON.stringify(S.move || null) && JSON.stringify(outbox) === JSON.stringify(S.outbox || []) && JSON.stringify(lab) === JSON.stringify(S.lab || []) && prevMoves === JSON.stringify(S.movesRow || null) && prevTry === JSON.stringify(S.tryRow || null);
|
|
491
|
+
const same = JSON.stringify(next) === JSON.stringify(S.move || null) && JSON.stringify(outbox) === JSON.stringify(S.outbox || []) && JSON.stringify(lab) === JSON.stringify(S.lab || []) && prevMoves === JSON.stringify(S.movesRow || null) && prevQuiet === JSON.stringify(S.quietRow || null) && prevTry === JSON.stringify(S.tryRow || null);
|
|
485
492
|
S.move = next; S.outbox = outbox; S.lab = lab;
|
|
486
493
|
if (!same) { redrawLater(); drawList(); }
|
|
487
494
|
// a demotion notice is said once: drawn now, then marked seen so the next read leaves it out
|
|
@@ -519,6 +526,7 @@ async function movePress(b) {
|
|
|
519
526
|
if (r.go === 'impact') { S.day = false; S.sel = 'impact'; if (isPhone()) S.phoneChat = true; openTarget(homeTarget()); drawList(); return; }
|
|
520
527
|
if (r.go === 'loose') { VW.drill(); LPV.open(lpHost); return; }
|
|
521
528
|
if (r.go === 'moves') { VW.drill(); import('./moves-view.js').then((MV) => { MV.openMoves(S.moves || [], { toast }); S.movesRow = null; drawList(); }); return; }
|
|
529
|
+
if (r.go === 'quiet') { VW.drill(); import('./quiet-view.js').then((QV) => { QV.openQuiet(S.quiet || [], { pmPost, toast, toastUndo }); S.quietRow = null; drawList(); }); return; }
|
|
522
530
|
if (r.go === 'try') { VW.drill(); import('./try-view.js').then((TV) => TV.openTry({ toast, toastUndo, onChange: (l) => { S.tryRow = TV.rowOf({ ...l, ok: true, row: l.total ? { ...S.tryRow, title: l.total + (l.total === 1 ? ' new thing to try' : ' new things to try') } : null }); drawList(); } })); return; }
|
|
523
531
|
if (r.go === 'lab') { VW.drill(); import('./cozy-lab-ins.js').then((LB) => LB.openLab({ where: () => ({ ws: r.ws, board: r.board }), iniHref: (id) => '/premium-initiative.html?' + (r.ws ? 'ws=' + encodeURIComponent(r.ws) + '&' : '') + 'id=' + encodeURIComponent(id), toast: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) })); return; }
|
|
524
532
|
return;
|
|
@@ -27,6 +27,7 @@ export function opOf(ev) {
|
|
|
27
27
|
let started = false;
|
|
28
28
|
export function start(g = globalThis) {
|
|
29
29
|
if (started || !g || typeof g.EventSource !== 'function') return false;
|
|
30
|
+
if (g.PMOS_READONLY) return false; // a published, read-only board (pm/readonly-boot.js) reads nothing from the server
|
|
30
31
|
started = true;
|
|
31
32
|
let es;
|
|
32
33
|
try { es = new g.EventSource('/api/live-rows'); } catch { started = false; return false; }
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/* pm/quiet-view.js — the weekly sweep of quiet work (initiative quiet-work-sweep, bet A503; lib/quiet-sweep.js, GET /api/quiet).
|
|
2
|
+
* Pure apart from openQuiet: Node imports it (quiet-sweep.test.js Q7).
|
|
3
|
+
*
|
|
4
|
+
* rowOf(lists, { looked }) → Today's Your move row ({ key, go: 'quiet', week, title, sub }) or null: null when nothing is quiet
|
|
5
|
+
* (zero is silence) and once the PM opened this week's list. lists: each product's GET /api/quiet answer.
|
|
6
|
+
* listHtml(lists, { esc }) → one row per quiet initiative, most quiet first, grouped by product: how long it was quiet, what PMOS
|
|
7
|
+
* suggests (✦), and three icon presses: Keep, Park, Close
|
|
8
|
+
* openQuiet(lists, H) the list in the Viewer, with its presses. H: { pmPost, toast, toastUndo, onChange }
|
|
9
|
+
* lookedWeek() · markLooked(week) which week the PM opened (this browser only; a missing store reads as not looked)
|
|
10
|
+
* Keep is POST /api/quiet/keep; Park and Close are POST /api/lifecycle (the PM's press), each with Undo. Nothing is sent. */
|
|
11
|
+
|
|
12
|
+
const KEY = 'pmos.quiet.looked';
|
|
13
|
+
const escDefault = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
14
|
+
const ICON = 'M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z';
|
|
15
|
+
const svg = (d) => `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="${d}"/></svg>`;
|
|
16
|
+
const ACTS = [
|
|
17
|
+
{ act: 'keep', label: 'Keep: still on', icon: 'M20 6 9 17l-5-5' },
|
|
18
|
+
{ act: 'park', label: 'Park it', icon: 'M10 4H6v16h4zM18 4h-4v16h4z' },
|
|
19
|
+
{ act: 'close', label: 'Close it', icon: 'M18 6 6 18M6 6l12 12' },
|
|
20
|
+
];
|
|
21
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
22
|
+
const ok = (l) => l && l.ok && Array.isArray(l.items);
|
|
23
|
+
const UNDO_REASON = 'undo'; // the decision journal takes a park's decision out again on this word (lib/decision-journal.js)
|
|
24
|
+
|
|
25
|
+
export function lookedWeek() { try { return localStorage.getItem(KEY) || ''; } catch { return ''; } }
|
|
26
|
+
export function markLooked(week) { try { if (week) localStorage.setItem(KEY, week); } catch { /* this browser keeps no store */ } }
|
|
27
|
+
|
|
28
|
+
/** Today's Your move row for this week's quiet work, or null. */
|
|
29
|
+
export function rowOf(lists, { looked = '' } = {}) {
|
|
30
|
+
const L = (lists || []).filter(ok);
|
|
31
|
+
const total = L.reduce((s, l) => s + (l.total || 0), 0);
|
|
32
|
+
if (!total) return null;
|
|
33
|
+
const week = (L.find((l) => l.week) || {}).week || '';
|
|
34
|
+
if (week && looked === week) return null;
|
|
35
|
+
return { key: 'quiet:' + week, go: 'quiet', week,
|
|
36
|
+
title: plural(total, 'initiative', 'initiatives') + ' quiet 30 days or more',
|
|
37
|
+
sub: 'Keep, park or close each one. Undo stays open.' };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function itemHtml(it, ws, esc) {
|
|
41
|
+
const where = [it.station ? 'on ' + it.station : '', it.workflow ? '(' + it.workflow + ')' : ''].filter(Boolean).join(' ');
|
|
42
|
+
const btns = ACTS.map((a) => {
|
|
43
|
+
const sug = it.suggest === a.act;
|
|
44
|
+
const label = (sug ? '✦ ' : '') + a.label;
|
|
45
|
+
return `<button type="button" class="ev-btn sm${sug ? ' pri' : ''}" data-qs-act="${a.act}" data-qs-id="${esc(it.id)}" data-qs-ws="${esc(ws)}" aria-label="${esc(label)}" title="${esc(label)}">${svg(a.icon)}</button>`;
|
|
46
|
+
}).join('');
|
|
47
|
+
return `<li class="mv-row" data-qs-row="${esc(it.id)}"><span class="mv-say">${esc(it.title)}</span>`
|
|
48
|
+
+ `<br><span class="yd-exp">Quiet ${esc(String(it.quietDays))} days${where ? ' ' + esc(where) : ''} · ✦ ${esc(it.suggest === 'close' ? 'Close' : 'Park')}: ${esc(it.why)}</span>`
|
|
49
|
+
+ `<span class="try-acts">${btns}</span></li>`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** The list, one section per product; a product with nothing quiet is left out. */
|
|
53
|
+
export function listHtml(lists, { esc = escDefault } = {}) {
|
|
54
|
+
const L = (lists || []).filter(ok).filter((l) => l.items.length);
|
|
55
|
+
if (!L.length) return '<p class="yd-exp">Nothing is quiet 30 days or more.</p>';
|
|
56
|
+
const many = L.length > 1;
|
|
57
|
+
return L.map((l) => {
|
|
58
|
+
const head = many ? `<h3>${esc(l.name || l.ws)}</h3>` : '';
|
|
59
|
+
const more = l.total > l.items.length ? ` The ${esc(String(l.items.length))} most quiet show here; answer them and the next ones come.` : '';
|
|
60
|
+
const sum = `<p class="yd-exp">${esc(plural(l.total, 'initiative', 'initiatives'))} with no change in 30 days or more.${more} Keep leaves one alone for 30 days.</p>`;
|
|
61
|
+
return `<section class="mv-prod">${head}${sum}<ul class="mv-list">${l.items.map((it) => itemHtml(it, l.ws || '', esc)).join('')}</ul></section>`;
|
|
62
|
+
}).join('');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const SAID = { keep: 'Kept. The sweep leaves it alone for 30 days.', park: 'Parked.', close: 'Closed.' };
|
|
66
|
+
|
|
67
|
+
/** The list in the Viewer; opening it marks the week as looked. */
|
|
68
|
+
export function openQuiet(lists, H = {}) {
|
|
69
|
+
const VW = window.czViewer;
|
|
70
|
+
const toast = H.toast || (() => {});
|
|
71
|
+
const row = rowOf(lists);
|
|
72
|
+
if (row) markLooked(row.week);
|
|
73
|
+
if (!VW) { toast('The list could not open here.'); return; }
|
|
74
|
+
let L = (lists || []).filter(ok).map((l) => ({ ...l, items: l.items.slice() }));
|
|
75
|
+
const send = async (path, body) => {
|
|
76
|
+
const r = await H.pmPost(path, body).catch((e) => ({ ok: false, error: String((e && e.message) || e) }));
|
|
77
|
+
if (!r || !r.ok) { toast('Not saved: ' + ((r && r.error) || 'the workspace did not answer') + '.'); return false; }
|
|
78
|
+
return true;
|
|
79
|
+
};
|
|
80
|
+
const answer = (act, ws, it) => (act === 'keep' ? send('/api/quiet/keep', { ws: ws || undefined, id: it.id })
|
|
81
|
+
: send('/api/lifecycle', { ws: ws || undefined, initiative_id: it.id, state: act === 'park' ? 'on-hold' : 'closed',
|
|
82
|
+
reason: act === 'park' ? 'Quiet ' + it.quietDays + ' days; parked in the weekly sweep' : 'Closed in the weekly sweep of quiet work' }));
|
|
83
|
+
const takeBack = (act, ws, it) => (act === 'keep' ? send('/api/quiet/keep', { ws: ws || undefined, id: it.id, undo: true })
|
|
84
|
+
: send('/api/lifecycle', { ws: ws || undefined, initiative_id: it.id, state: 'active', reason: UNDO_REASON }));
|
|
85
|
+
VW.open({ id: 'quiet:' + ((row && row.week) || ''), kind: 'Quiet work', title: 'Quiet 30 days or more', icon: ICON, presses: [],
|
|
86
|
+
render: (b) => {
|
|
87
|
+
const draw = () => { b.innerHTML = listHtml(L); };
|
|
88
|
+
draw();
|
|
89
|
+
// the presses are real <button>s in b; one listener on the document reads them (a re-render drops its old one), as pm/try-view.js does
|
|
90
|
+
if (b._qsOff) b._qsOff();
|
|
91
|
+
const onPress = async (ev) => {
|
|
92
|
+
const t = ev.target && ev.target.closest && ev.target.closest('[data-qs-act]'); if (!t || t.disabled || !b.contains(t)) return;
|
|
93
|
+
const act = t.dataset.qsAct, ws = t.dataset.qsWs || '', id = t.dataset.qsId;
|
|
94
|
+
const l = L.find((x) => (x.ws || '') === ws); const it = l && l.items.find((x) => x.id === id); if (!it) return;
|
|
95
|
+
t.disabled = true;
|
|
96
|
+
if (!(await answer(act, ws, it))) { t.disabled = false; return; }
|
|
97
|
+
const at = l.items.indexOf(it);
|
|
98
|
+
l.items.splice(at, 1); l.total = Math.max(0, l.total - 1);
|
|
99
|
+
draw();
|
|
100
|
+
if (H.onChange) H.onChange(L);
|
|
101
|
+
const undo = async () => { if (await takeBack(act, ws, it)) { l.items.splice(Math.min(at, l.items.length), 0, it); l.total += 1; draw(); if (H.onChange) H.onChange(L); } };
|
|
102
|
+
if (H.toastUndo) H.toastUndo(SAID[act], undo); else toast(SAID[act]);
|
|
103
|
+
};
|
|
104
|
+
b.ownerDocument.addEventListener('click', onPress);
|
|
105
|
+
b._qsOff = () => b.ownerDocument.removeEventListener('click', onPress);
|
|
106
|
+
} });
|
|
107
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "The weekly sweep of quiet work (initiative quiet-work-sweep, bet A503, done test Q1-Q8): the quiet list over the line's rows, the keep ledger, park/close/undo writers, GET /api/quiet and POST /api/quiet/keep, the pmos quiet verb and Today's row. Temp repositories in both layouts. No server, network or browser.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"quiet-sweep.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"quiet-sweep.test.js": 3
|
|
8
|
+
}
|
|
9
|
+
}
|