create-pmos 0.791.0 → 0.793.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 +43 -27
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +42 -0
- package/workspace/guide/cli.md +9 -0
- package/workspace/guide/initiatives-and-next-steps.md +2 -2
- package/workspace/guide/layout.md +1 -1
- package/workspace/lib/decision-journal-needs.js +27 -4
- package/workspace/lib/decision-journal.js +274 -8
- package/workspace/lib/decisions-cli.js +72 -8
- package/workspace/lib/routes-boards.js +8 -3
- package/workspace/lib/settings-store.js +3 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-events.css +3 -4
- package/workspace/public/pm/cozy-pop-work.js +3 -1
- package/workspace/public/pm/cozy-routine.css +5 -3
- package/workspace/public/pm/cozy-routine.js +1 -0
- package/workspace/public/premium-events.html +3 -3
- package/workspace/public/premium-routine.html +2 -2
- package/workspace/test-lists/decisions-come-back.json +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.793.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,48 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.793.0",
|
|
38
|
+
"at": "2026-11-24T19:07:01.516Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1805,
|
|
43
|
+
"t": "Decisions come back at their threshold or review date",
|
|
44
|
+
"s": "Decisions come back at their threshold or review date",
|
|
45
|
+
"k": "new",
|
|
46
|
+
"h": "Decisions come back at their threshold or review date",
|
|
47
|
+
"try": {
|
|
48
|
+
"steps": [
|
|
49
|
+
"On Work, drop a ✦ proposal with ✕ and say why",
|
|
50
|
+
"In the chat, ask: when does that decision come back?",
|
|
51
|
+
"On Today, when a decision comes back, press Keep, then Undo"
|
|
52
|
+
],
|
|
53
|
+
"see": "The chat names the date or goal number PMOS drafted from your reason. When the decision comes back, Today shows one quiet row with why you decided it; Keep moves it to its next date and Undo puts it…",
|
|
54
|
+
"open": "/premium-board.html"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"n": 1804,
|
|
59
|
+
"t": "Close-open counts Jira tickets left to Jira; an unreachable direct route sends the words to Ask PMOS (job #1792)",
|
|
60
|
+
"s": "Close-open counts Jira tickets left to Jira; an unreachable direct route sends the words to Ask PMOS (job #1792)",
|
|
61
|
+
"k": "fix"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"v": "0.792.0",
|
|
67
|
+
"at": "2026-11-24T18:56:18.725Z",
|
|
68
|
+
"f": 4,
|
|
69
|
+
"prs": [
|
|
70
|
+
{
|
|
71
|
+
"n": 1806,
|
|
72
|
+
"t": "Events and Routine sit on the system layouts, tuned so nothing moves (A334)",
|
|
73
|
+
"s": "Events and Routine sit on the system layouts, tuned so nothing moves (A334)",
|
|
74
|
+
"k": "new"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
},
|
|
36
78
|
{
|
|
37
79
|
"v": "0.791.0",
|
|
38
80
|
"at": "2026-11-24T18:45:09.361Z",
|
|
@@ -437,32 +479,6 @@
|
|
|
437
479
|
"h": "Every page, chat rule, guide page and release note says Today and Work, not Today and Work"
|
|
438
480
|
}
|
|
439
481
|
]
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
"v": "0.773.0",
|
|
443
|
-
"at": "2026-11-24T10:11:16.212Z",
|
|
444
|
-
"f": 4,
|
|
445
|
-
"prs": [
|
|
446
|
-
{
|
|
447
|
-
"n": 1738,
|
|
448
|
-
"t": "The chat box has a quiet focus and a round Send inside it",
|
|
449
|
-
"s": "The chat box has a quiet focus and a round Send inside it",
|
|
450
|
-
"k": "fix"
|
|
451
|
-
}
|
|
452
|
-
]
|
|
453
|
-
},
|
|
454
|
-
{
|
|
455
|
-
"v": "0.772.0",
|
|
456
|
-
"at": "2026-11-24T09:30:28.206Z",
|
|
457
|
-
"f": 4,
|
|
458
|
-
"prs": [
|
|
459
|
-
{
|
|
460
|
-
"n": 1734,
|
|
461
|
-
"t": "Every task opens the one-column task detail, Jira tickets too",
|
|
462
|
-
"s": "Every task opens the one-column task detail, Jira tickets too",
|
|
463
|
-
"k": "new"
|
|
464
|
-
}
|
|
465
|
-
]
|
|
466
482
|
}
|
|
467
483
|
]
|
|
468
484
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T19:06:58Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T19:06:58Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-11-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-24T19:06:58Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,46 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.793.0",
|
|
4
|
+
"at": "2026-11-24T19:07:01.516Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1805,
|
|
9
|
+
"t": "Decisions come back at their threshold or review date",
|
|
10
|
+
"s": "Decisions come back at their threshold or review date",
|
|
11
|
+
"k": "new",
|
|
12
|
+
"h": "Decisions come back at their threshold or review date",
|
|
13
|
+
"try": {
|
|
14
|
+
"steps": [
|
|
15
|
+
"On Work, drop a ✦ proposal with ✕ and say why",
|
|
16
|
+
"In the chat, ask: when does that decision come back?",
|
|
17
|
+
"On Today, when a decision comes back, press Keep, then Undo"
|
|
18
|
+
],
|
|
19
|
+
"see": "The chat names the date or goal number PMOS drafted from your reason. When the decision comes back, Today shows one quiet row with why you decided it; Keep moves it to its next date and Undo puts it…",
|
|
20
|
+
"open": "/premium-board.html"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"n": 1804,
|
|
25
|
+
"t": "Close-open counts Jira tickets left to Jira; an unreachable direct route sends the words to Ask PMOS (job #1792)",
|
|
26
|
+
"s": "Close-open counts Jira tickets left to Jira; an unreachable direct route sends the words to Ask PMOS (job #1792)",
|
|
27
|
+
"k": "fix"
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"v": "0.792.0",
|
|
33
|
+
"at": "2026-11-24T18:56:18.725Z",
|
|
34
|
+
"f": 4,
|
|
35
|
+
"prs": [
|
|
36
|
+
{
|
|
37
|
+
"n": 1806,
|
|
38
|
+
"t": "Events and Routine sit on the system layouts, tuned so nothing moves (A334)",
|
|
39
|
+
"s": "Events and Routine sit on the system layouts, tuned so nothing moves (A334)",
|
|
40
|
+
"k": "new"
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
2
44
|
{
|
|
3
45
|
"v": "0.791.0",
|
|
4
46
|
"at": "2026-11-24T18:45:09.361Z",
|
package/workspace/guide/cli.md
CHANGED
|
@@ -388,6 +388,15 @@ Write one line for each product decision, also one that is smaller than an initi
|
|
|
388
388
|
- `pmos decisions undo <id>` takes a decision out of the journal. PMOS also writes a line by itself when you press ✓ on a ✦ proposal, pick an answer on a card, drop a proposal with a reason, keep an agent's proposal, or park an initiative with a reason. `pmos decisions list` shows those lines under "Logged from your presses". The Undo of the press takes its line out too.
|
|
389
389
|
- On the check date, the decision shows on Today as a gate that waits for you, with the command to record the verdict. PMOS never records a verdict for you.
|
|
390
390
|
|
|
391
|
+
**Decisions come back.** A decision can carry a threshold (the line it must hold) and a review trigger: a date, a goal number crossing a line, or both. When the trigger is reached, the decision shows again on Today, at most 3 a day, with why you made it. You keep it or change it.
|
|
392
|
+
|
|
393
|
+
- `pmos decisions add … --threshold "<the line it must hold>" --review <date|+30d> --metric "<goal id> < <number>"` sets the trigger when you add a decision. All three are optional.
|
|
394
|
+
- `pmos decisions trigger <id> [--threshold "<text>"] [--review <date|+30d>] [--metric "<goal id> < <number>"]` sets the trigger later. `--off` stops the decision from coming back.
|
|
395
|
+
- If you set no trigger, PMOS drafts one from the decision's own words. An expected outcome with a number gives the threshold and the check date. A decision dropped with a reason comes back 90 days later. `pmos decisions show <id>` says when the trigger was drafted and from what.
|
|
396
|
+
- `pmos decisions keep <id>` keeps a decision that came back. It comes back again after the same gap, or on `--next <date>`. `pmos decisions undo <id> --step` undoes the Keep.
|
|
397
|
+
- `pmos decisions change <id> "<new decision>" --changed-mind "<what changed>"` replaces a decision that came back.
|
|
398
|
+
- `pmos decisions back-days [0|30|60|90|180]` sets the days after which a dropped decision comes back. 0 means never.
|
|
399
|
+
|
|
391
400
|
### pmos principles: the product's principles, from its decisions
|
|
392
401
|
|
|
393
402
|
PMOS drafts 4 to 6 principles for a product from its past decisions. Each draft cites the decisions it came from. You keep or drop each one, on the product's Work page or here. Run the commands in the product's repository, or pass `--root <dir>`. The principles are kept in `principles.jsonl` in the product's records folder.
|
|
@@ -53,10 +53,10 @@ Each step says what you can do with it. The control sits under the step.
|
|
|
53
53
|
Three suggestions on the initiative popup change the record directly, with Undo. They send nothing to Ask PMOS and start no agent run:
|
|
54
54
|
|
|
55
55
|
- **Move the plan end.** ✓ moves the due day of the open task that sets the plan end today.
|
|
56
|
-
- **Close them** (a closed initiative with open tasks). All its open PMOS tasks go to Done. Jira tickets stay with Jira.
|
|
56
|
+
- **Close them** (a closed initiative with open tasks). All its open PMOS tasks go to Done. Jira tickets stay with Jira: the message tells you how many open Jira tickets PMOS left to Jira.
|
|
57
57
|
- **Reopen.** An initiative in Won't do comes out of Won't do. An initiative in its last stage goes back to the stage it came from.
|
|
58
58
|
|
|
59
|
-
When PMOS cannot do the change by itself (for example, a Done task sets the plan end), it sends the words to Ask PMOS as before.
|
|
59
|
+
When PMOS cannot do the change by itself (for example, a Done task sets the plan end), or the workspace server cannot be reached, it sends the words to Ask PMOS as before.
|
|
60
60
|
|
|
61
61
|
### Prepare, then go
|
|
62
62
|
|
|
@@ -27,7 +27,7 @@ The workspace has one stylesheet for each part: `pm/brand.css`, `pm/charts.css`,
|
|
|
27
27
|
|
|
28
28
|
These pages are on the UI system: the meeting buddy, the recording tab, the audience tab, the extension's capture popup and the Welcome page. On a moved page, `pm/ds-bridge.css` points the old colour names at the system's colours, so the parts that other modules draw there follow the system too. While a screen is shared, the recording tab's stage uses the Dark theme.
|
|
29
29
|
|
|
30
|
-
**Five page layouts.** Every page is one of five layouts in `ui/`: Single column (`pm-layout-single`), Main + side (`pm-layout-side`), Main + open item (`pm-layout-open`), Full popup (`pm-layout-popup`) and Reading (`pm-layout-reading`). A page picks one and fills its slots with blocks. Gaps, widths and corners come from the system's tokens, so a change to a layout or a token reaches every page that uses it. The chat is always the slide-over, never a slot. On a phone every layout is one column. `ui/pages.md` says which page uses which layout; pages move onto them one at a time.
|
|
30
|
+
**Five page layouts.** Every page is one of five layouts in `ui/`: Single column (`pm-layout-single`), Main + side (`pm-layout-side`), Main + open item (`pm-layout-open`), Full popup (`pm-layout-popup`) and Reading (`pm-layout-reading`). A page picks one and fills its slots with blocks. Gaps, widths and corners come from the system's tokens, so a change to a layout or a token reaches every page that uses it. The chat is always the slide-over, never a slot. On a phone every layout is one column. `ui/pages.md` says which page uses which layout; pages move onto them one at a time. Work, Library and Routine use Main + open item, and Events uses Main + side. A page can tune a layout with its own widths, for example the Events list stops at 1100 px, so a page looks the same after it moves.
|
|
31
31
|
|
|
32
32
|
Every block has three states, and one part of the UI system draws all three (`State` in `ui/components/`). The Viewer uses it for every tab:
|
|
33
33
|
|
|
@@ -2,22 +2,28 @@
|
|
|
2
2
|
/* decision-journal-needs.js — the needs provider of the decision journal (initiative decision-journal-outcome-checks, done test C4).
|
|
3
3
|
* lib/needs-providers.js folds these rows into server.js deriveNeeds, and from there into /api/needs and Today.
|
|
4
4
|
*
|
|
5
|
-
* kinds: decision-check
|
|
5
|
+
* kinds: decision-check, decision-back
|
|
6
6
|
* rowsFor(w, { lead }) → rows · sig(w) → string
|
|
7
7
|
*
|
|
8
8
|
* decision-check one row per journal decision whose check date is today or past, with no verdict (lib/decision-journal.js fold, state
|
|
9
9
|
* `due`). Kind 1 (a gate is owed). The act is the command that records the verdict. The row goes when a verdict is
|
|
10
10
|
* recorded, when cant-tell moves the date, or when a later decision replaces it.
|
|
11
11
|
*
|
|
12
|
+
* decision-back (decisions-come-back) one row per open or logged decision whose review trigger was reached (lib/decision-journal.js
|
|
13
|
+
* comeBack: its review date came, or its goal number crossed the line). Kind 7, quiet: at most DAILY_MAX rows, the oldest
|
|
14
|
+
* first. It carries what was decided, why and what was expected. Acts: Keep (moves it to its next date; Undo is
|
|
15
|
+
* `pmos decisions undo <id> --step`) and Change (a new decision that replaces it). A due decision has its decision-check row
|
|
16
|
+
* instead, never both.
|
|
17
|
+
*
|
|
12
18
|
* The journal is repository-wide, so a tree that is not the lead returns []. Nothing here writes or sends. */
|
|
13
19
|
const J = require('./decision-journal.js');
|
|
14
20
|
|
|
15
21
|
const NAME = 'decision-journal-needs';
|
|
16
22
|
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; };
|
|
17
23
|
|
|
18
|
-
function rowsFor(w, { lead } = {}) {
|
|
24
|
+
function rowsFor(w, { lead, today = J.todayOf(), dropBackDays } = {}) {
|
|
19
25
|
if (!lead || !w || !w.root) return [];
|
|
20
|
-
const { entries, file } = J.entriesOf(w.root, { today:
|
|
26
|
+
const { entries, file } = J.entriesOf(w.root, { today, dropBackDays: dropBackDays == null ? dropBack() : dropBackDays });
|
|
21
27
|
return entries.filter((e) => e.state === 'due').map((e) => {
|
|
22
28
|
const cause = `Did it work? You decided: ${clip(e.decided, 140)}. You expected: ${clip(e.expected, 140)}.`;
|
|
23
29
|
return {
|
|
@@ -25,9 +31,26 @@ function rowsFor(w, { lead } = {}) {
|
|
|
25
31
|
today: { kind: 1, source: NAME, cause, evidence: `${file} · check date ${e.check}`,
|
|
26
32
|
act: { label: 'Check', cli: `pmos decisions check ${e.id} worked|didnt-work|cant-tell --evidence "<what shows it>"` } },
|
|
27
33
|
};
|
|
34
|
+
}).concat(backRows(w, entries, file));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const dropBack = () => J.dropBackSetting();
|
|
38
|
+
|
|
39
|
+
function backRows(w, entries, file) {
|
|
40
|
+
return entries.filter((e) => e.back).sort((a, b) => String(a.back.on).localeCompare(String(b.back.on)) || a.id.localeCompare(b.id)).slice(0, J.DAILY_MAX).map((e) => {
|
|
41
|
+
const t = e.trigger || {};
|
|
42
|
+
const cause = `Still the right call? You decided: ${clip(e.decided, 140)}.` + (e.why ? ` Why: ${clip(e.why, 140)}.` : '') + (e.expected ? ` You expected: ${clip(e.expected, 140)}.` : '')
|
|
43
|
+
+ ` It came back because ${e.back.why}.`;
|
|
44
|
+
const line = [t.threshold ? `holds while it never ${t.threshold}` : '', t.metric ? `watches ${J.metricWords(t.metric)}` : '', t.drafted ? `drafted by PMOS from ${t.source}` : ''].filter(Boolean).join(' · ');
|
|
45
|
+
return {
|
|
46
|
+
run_id: `${NAME}:back:${w.id}:${e.id}`, kind: 'decision-back', initiative_id: e.initiative || null, question: cause, doc: file, ws: w.id,
|
|
47
|
+
today: { kind: 7, source: NAME, cause, evidence: `${file} · decided ${e.date}${line ? ' · ' + line : ''}`,
|
|
48
|
+
act: { label: 'Keep', cli: `pmos decisions keep ${e.id}`, undo: `pmos decisions undo ${e.id} --step` },
|
|
49
|
+
alt: { label: 'Change', cli: `pmos decisions change ${e.id} "<the new decision>" --changed-mind "<what changed>"` } },
|
|
50
|
+
};
|
|
28
51
|
});
|
|
29
52
|
}
|
|
30
53
|
// the date is in the signature: a decision becomes due at midnight with no change to the file
|
|
31
54
|
function sig(w) { return w && w.root ? J.stamp(w.root) + '@' + J.todayOf() : ''; }
|
|
32
55
|
|
|
33
|
-
module.exports = { kinds: ['decision-check'], rowsFor, sig };
|
|
56
|
+
module.exports = { kinds: ['decision-check', 'decision-back'], rowsFor, sig };
|
|
@@ -35,6 +35,25 @@
|
|
|
35
35
|
* loggedCount(rows, { days, now }) → number lines from presses in the last `days` days, not undone (the health number)
|
|
36
36
|
* CLI: node lib/decision-journal.js logged <root> [--days 7] prints `[decision-log] …` and the count alone on the last line
|
|
37
37
|
*
|
|
38
|
+
* COMING BACK (initiative decisions-come-back, bet A509). A decision may carry a THRESHOLD (the line it must hold, in words) and a REVIEW
|
|
39
|
+
* TRIGGER: a date to look again (`review_on`), a goal number crossing a line (`metric` { rid, op, value }, read from the newest good reading
|
|
40
|
+
* in <state>/metric-reads.jsonl), or both. More lines:
|
|
41
|
+
* { type: 'trigger', id, threshold?, review_on?, metric?, off?, at, by, via } the PM sets or turns off a decision's trigger later
|
|
42
|
+
* { type: 'review', id, choice: keep | change, next?, to?, at, by, via } the PM's answer when the decision came back
|
|
43
|
+
* { type: 'undo-step', id, of, at, by, via } undoes the trigger or review line written at `of`
|
|
44
|
+
* A decision with no trigger of its own gets one DRAFTED from its evidence (draftTrigger, never written): an expected outcome with a number
|
|
45
|
+
* gives the threshold on the other side of that number and the check date; a drop with a reason comes back `dropBackDays` (Settings
|
|
46
|
+
* decisions.dropBack, default 90) after the decision. A trigger the PM set or turned off always wins over a draft.
|
|
47
|
+
* draftTrigger(entry, { dropBackDays }) → { threshold, review_on, metric: null, drafted: true, source } | null
|
|
48
|
+
* comeBack(entry, { today, reading }) → { why, on } | null an open or logged decision whose review date came, or whose metric's newest
|
|
49
|
+
* reading is past the line and newer than the last Keep. Due, checked, replaced: never
|
|
50
|
+
* setTrigger(root, { id, threshold?, review?, metric?, off? }, who) · keep(root, { id, next? }, who) · change(root, { id, decided, expected?,
|
|
51
|
+
* changed_mind }, who) · undoStep(root, { id }, who) each appends one line (change: the new decision and a review line)
|
|
52
|
+
* entriesOf(root, { today, dropBackDays }) also sets e.trigger (set or drafted, or null) and e.back (comeBack) on every entry
|
|
53
|
+
* CLI: node lib/decision-journal.js triggers <root> the share of live decisions with a trigger, alone on the last line
|
|
54
|
+
* node lib/decision-journal.js answered <root> [--days 30] Keep and Change answers in the window, alone on the last line
|
|
55
|
+
* Reading, drafting and coming back write nothing: only the PM's press or command appends a line.
|
|
56
|
+
*
|
|
38
57
|
* A verdict is the PM's: PMOS never records one from a metric alone, and every verdict carries evidence. Nothing here sends anything.
|
|
39
58
|
*/
|
|
40
59
|
const fs = require('fs');
|
|
@@ -99,7 +118,16 @@ function fold(rows, { today = todayOf() } = {}) {
|
|
|
99
118
|
if (!r || r.type !== 'decision' || typeof r.id !== 'string' || by.has(r.id) || undone.has(r.id)) continue;
|
|
100
119
|
by.set(r.id, { id: r.id, date: r.date || String(r.at || '').slice(0, 10), decided: r.decided || '', expected: r.expected || '', check: r.check || '',
|
|
101
120
|
why: r.why || '', against: r.against || '', initiative: r.initiative || '', replaces: r.replaces || '', changed_mind: r.changed_mind || '',
|
|
102
|
-
replacedBy: '', replacedWhy: '', replacedAt: '', checks: [], verdict: null, dueAt: '', at: r.at || '', by: r.by || '', from: r.from || '', ref: r.ref || ''
|
|
121
|
+
replacedBy: '', replacedWhy: '', replacedAt: '', checks: [], verdict: null, dueAt: '', at: r.at || '', by: r.by || '', from: r.from || '', ref: r.ref || '',
|
|
122
|
+
own: r.threshold || r.review_on || r.metric ? { threshold: r.threshold || '', review_on: r.review_on || '', metric: r.metric || null, at: r.at || '' } : null, reviews: [] });
|
|
123
|
+
}
|
|
124
|
+
const gone = stepsUndone(rows);
|
|
125
|
+
for (const r of rows || []) {
|
|
126
|
+
if (!r || (r.type !== 'trigger' && r.type !== 'review') || gone.has(r.id + '|' + r.at)) continue;
|
|
127
|
+
const e = by.get(r.id);
|
|
128
|
+
if (!e) continue;
|
|
129
|
+
if (r.type === 'trigger') e.own = r.off ? { off: true, at: r.at || '' } : { threshold: r.threshold || '', review_on: r.review_on || '', metric: r.metric || null, at: r.at || '' };
|
|
130
|
+
else if (r.choice === 'keep' || r.choice === 'change') e.reviews.push(r);
|
|
103
131
|
}
|
|
104
132
|
for (const r of rows || []) {
|
|
105
133
|
if (!r || r.type !== 'check') continue;
|
|
@@ -155,6 +183,8 @@ function add(root, f = {}, { now = Date.now(), by, via } = {}) {
|
|
|
155
183
|
if (!check) return { ok: false, error: '--check is a date (YYYY-MM-DD) or a time from today (+30d, +2w, +3m)' };
|
|
156
184
|
if (check <= today) return { ok: false, error: 'the check date must be after today: an outcome needs time to show' };
|
|
157
185
|
}
|
|
186
|
+
const T = triggerOf(f, today);
|
|
187
|
+
if (T.error) return { ok: false, error: T.error };
|
|
158
188
|
const why = one(f.why), against = one(f.against), initiative = one(f.initiative), replaces = one(f.replaces), changed = one(f.changed_mind);
|
|
159
189
|
if (why.length > MAX.why || against.length > MAX.against || changed.length > MAX.changed) return { ok: false, error: 'keep --why, --against and --changed-mind under 600 characters each' };
|
|
160
190
|
if (initiative && !ID_RE.test(initiative)) return { ok: false, error: '--initiative takes the initiative\'s id' };
|
|
@@ -171,7 +201,7 @@ function add(root, f = {}, { now = Date.now(), by, via } = {}) {
|
|
|
171
201
|
const have = new Set(E.map((e) => e.id));
|
|
172
202
|
while (have.has(id)) id = base + '-' + n++;
|
|
173
203
|
const line = { type: 'decision', id, date: today, decided, expected, check, ...(why ? { why } : {}), ...(against ? { against } : {}),
|
|
174
|
-
...(initiative ? { initiative } : {}), ...(replaces ? { replaces, changed_mind: changed } : {}), at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'cli' };
|
|
204
|
+
...(initiative ? { initiative } : {}), ...(replaces ? { replaces, changed_mind: changed } : {}), ...T.fields, at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'cli' };
|
|
175
205
|
try { append(J.file, line); } catch (e) { return { ok: false, error: 'the decision journal could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
|
|
176
206
|
return { ok: true, id, line, file: rel(root, J.file) };
|
|
177
207
|
}
|
|
@@ -275,6 +305,228 @@ function loggedCount(rows, { days = 7, now = Date.now() } = {}) {
|
|
|
275
305
|
return (rows || []).filter((r) => r && r.type === 'decision' && FROM.includes(r.from) && !undone.has(r.id) && Date.parse(r.at) >= since && Date.parse(r.at) <= now).length;
|
|
276
306
|
}
|
|
277
307
|
|
|
308
|
+
/* ── coming back (decisions-come-back) ── */
|
|
309
|
+
const BACK_TAG = '[decision-back]';
|
|
310
|
+
const DROP_BACK_DAYS = 90;
|
|
311
|
+
const DAILY_MAX = 3;
|
|
312
|
+
const MIN_GAP = 7;
|
|
313
|
+
const OPS = Object.freeze(['<', '<=', '>', '>=']);
|
|
314
|
+
const METRIC_RE = /^([a-z0-9][a-z0-9._:-]{0,79})\s*(<=|>=|<|>)\s*(-?\d+(?:\.\d+)?)\s*%?$/i;
|
|
315
|
+
|
|
316
|
+
/** "<goal id> <op> <number>" → { rid, op, value } | null */
|
|
317
|
+
function parseMetric(text) {
|
|
318
|
+
const m = METRIC_RE.exec(one(text));
|
|
319
|
+
return m ? { rid: m[1], op: m[2], value: +m[3] } : null;
|
|
320
|
+
}
|
|
321
|
+
const crosses = (v, m) => Number.isFinite(v) && (m.op === '<' ? v < m.value : m.op === '<=' ? v <= m.value : m.op === '>' ? v > m.value : v >= m.value);
|
|
322
|
+
const metricWords = (m) => m ? `${m.rid} ${m.op} ${m.value}` : '';
|
|
323
|
+
|
|
324
|
+
/** The trigger fields of an add or a trigger command, checked. → { fields } | { error } */
|
|
325
|
+
function triggerOf(f, today) {
|
|
326
|
+
const fields = {};
|
|
327
|
+
const threshold = one(f.threshold);
|
|
328
|
+
if (threshold) {
|
|
329
|
+
if (threshold.length < 3 || threshold.length > MAX.decided) return { error: `--threshold says the line the decision must hold, in 3 to ${MAX.decided} characters` };
|
|
330
|
+
fields.threshold = threshold;
|
|
331
|
+
}
|
|
332
|
+
if (f.review != null && f.review !== '') {
|
|
333
|
+
const d = checkDate(f.review, today);
|
|
334
|
+
if (!d || d <= today) return { error: '--review is a date after today (YYYY-MM-DD, or +30d, +2w, +3m)' };
|
|
335
|
+
fields.review_on = d;
|
|
336
|
+
}
|
|
337
|
+
if (f.metric != null && f.metric !== '') {
|
|
338
|
+
const m = parseMetric(f.metric);
|
|
339
|
+
if (!m) return { error: '--metric is a goal id, a sign and a number, for example "weekly-signups < 50"' };
|
|
340
|
+
fields.metric = m;
|
|
341
|
+
}
|
|
342
|
+
return { fields };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** The steps (trigger and review lines) an `undo-step` line took back, as "id|at". */
|
|
346
|
+
function stepsUndone(rows) {
|
|
347
|
+
const out = new Set();
|
|
348
|
+
for (const r of rows || []) if (r && r.type === 'undo-step' && typeof r.id === 'string' && typeof r.of === 'string') out.add(r.id + '|' + r.of);
|
|
349
|
+
return out;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const UP = /\b(at least|more than|over|above|exceed(?:s|ing)?|reach(?:es)?|hit(?:s)?|grow(?:s)? to|rise(?:s)? to|>=?)\s*([$€£]?\d[\d,]*(?:\.\d+)?\s*%?)/i;
|
|
353
|
+
const DOWN = /\b(at most|less than|fewer than|under|below|no more than|drop(?:s)? to|fall(?:s)? to|<=?)\s*([$€£]?\d[\d,]*(?:\.\d+)?\s*%?)/i;
|
|
354
|
+
const ANY_NUM = /([$€£]?\d[\d,]*(?:\.\d+)?\s*%?)/;
|
|
355
|
+
const clipTo = (s, n) => { const t = one(s); return t.length > n ? t.slice(0, n - 1).replace(/\s+\S*$/, '') + '…' : t; };
|
|
356
|
+
|
|
357
|
+
/** A trigger drafted from the decision's own evidence, or null. Never written: it shows as drafted until the PM sets one. */
|
|
358
|
+
function draftTrigger(e, { dropBackDays = DROP_BACK_DAYS } = {}) {
|
|
359
|
+
if (!e) return null;
|
|
360
|
+
const ex = one(e.expected);
|
|
361
|
+
if (ex) {
|
|
362
|
+
const up = UP.exec(ex), down = DOWN.exec(ex), any = ANY_NUM.exec(ex);
|
|
363
|
+
const n = (up && up[2]) || (down && down[2]) || (any && any[1]);
|
|
364
|
+
if (n) {
|
|
365
|
+
const num = one(n);
|
|
366
|
+
const threshold = up ? `falls below ${num}` : down ? `goes above ${num}` : `misses ${num}`;
|
|
367
|
+
return { threshold, review_on: isDate(e.check) ? e.check : '', metric: null, drafted: true, source: `expected: ${clipTo(ex, 140)}` };
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const days = Number.isFinite(+dropBackDays) ? Math.max(0, Math.round(+dropBackDays)) : DROP_BACK_DAYS;
|
|
371
|
+
if (e.from === 'drop' && one(e.why) && days > 0 && isDate(e.date)) {
|
|
372
|
+
return { threshold: `the reason no longer holds: ${clipTo(e.why, 140)}`, review_on: addDays(e.date, days), metric: null, drafted: true, source: `dropped because: ${clipTo(e.why, 140)}` };
|
|
373
|
+
}
|
|
374
|
+
return null;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** The trigger in force: the PM's own (set or off) wins over a draft. */
|
|
378
|
+
function triggerIn(e, o) {
|
|
379
|
+
if (e.own) return e.own.off ? null : { threshold: e.own.threshold, review_on: e.own.review_on, metric: e.own.metric, drafted: false, source: '', at: e.own.at };
|
|
380
|
+
return draftTrigger(e, o);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
const lastKeep = (e) => { const k = (e.reviews || []).filter((r) => r.choice === 'keep'); return k.length ? k[k.length - 1] : null; };
|
|
384
|
+
|
|
385
|
+
/** Whether a decision is back, and why. reading: the newest good reading of its metric goal ({ value, day, at }) or null. */
|
|
386
|
+
function comeBack(e, { today = todayOf(), reading = null } = {}) {
|
|
387
|
+
if (!e || (e.state !== 'open' && e.state !== 'logged')) return null;
|
|
388
|
+
if ((e.reviews || []).some((r) => r.choice === 'change')) return null;
|
|
389
|
+
const t = e.trigger !== undefined ? e.trigger : triggerIn(e, {});
|
|
390
|
+
if (!t) return null;
|
|
391
|
+
const k = lastKeep(e);
|
|
392
|
+
const keptAfter = k && String(k.at) > String(t.at || '');
|
|
393
|
+
const date = keptAfter ? k.next : t.review_on;
|
|
394
|
+
if (isDate(date) && date <= today) return { why: `its review date ${date} came`, on: date };
|
|
395
|
+
if (t.metric && reading && Number.isFinite(reading.value)) {
|
|
396
|
+
const since = String(k ? k.at : '') > String(t.at || e.at || '') ? String(k.at) : String(t.at || e.at || '');
|
|
397
|
+
if (String(reading.at || '') > since && crosses(reading.value, t.metric)) return { why: `${t.metric.rid} read ${reading.value} on ${reading.day || String(reading.at).slice(0, 10)}, past ${t.metric.op} ${t.metric.value}`, on: reading.day || String(reading.at).slice(0, 10) };
|
|
398
|
+
}
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** The folder metric-reads.jsonl lives in for this repository (the state folder), or null. */
|
|
403
|
+
function stateDirOf(root) {
|
|
404
|
+
for (const r of [['pmos', 'state'], ['state'], ['.pmos']]) { const d = path.join(root, ...r); try { if (fs.statSync(d).isDirectory()) return d; } catch { /* next */ } }
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
/** rid → the newest good reading, for the goals some trigger watches. */
|
|
408
|
+
function readingsOf(root, rids) {
|
|
409
|
+
const out = new Map();
|
|
410
|
+
if (!rids.size) return out;
|
|
411
|
+
const dir = stateDirOf(root);
|
|
412
|
+
if (!dir) return out;
|
|
413
|
+
try {
|
|
414
|
+
const F = require('./metric-reads.js').read(dir);
|
|
415
|
+
for (const rid of rids) { const x = F.rids.get(rid); if (x && x.good && Number.isFinite(x.good.value)) out.set(rid, { value: x.good.value, day: x.good.day || '', at: x.good.at || '' }); }
|
|
416
|
+
} catch { /* no readings */ }
|
|
417
|
+
return out;
|
|
418
|
+
}
|
|
419
|
+
function metricFile(root) { const d = stateDirOf(root); return d ? path.join(d, 'metric-reads.jsonl') : null; }
|
|
420
|
+
|
|
421
|
+
/** Settings › decisions.dropBack: the days after which a dropped decision comes back (0: never). */
|
|
422
|
+
function dropBackSetting(env = process.env) {
|
|
423
|
+
try { const v = require('./settings-store.js').get(require('./state-root.js').defaultRoot({ env }), 'decisions.dropBack'); return Number.isFinite(+v) ? +v : DROP_BACK_DAYS; } catch { return DROP_BACK_DAYS; }
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Sets trigger and back on each entry. */
|
|
427
|
+
function withBack(root, entries, { today = todayOf(), dropBackDays = DROP_BACK_DAYS } = {}) {
|
|
428
|
+
for (const e of entries) e.trigger = triggerIn(e, { dropBackDays });
|
|
429
|
+
const rids = new Set(entries.filter((e) => e.trigger && e.trigger.metric).map((e) => e.trigger.metric.rid));
|
|
430
|
+
const R = readingsOf(root, rids);
|
|
431
|
+
for (const e of entries) e.back = comeBack(e, { today, reading: e.trigger && e.trigger.metric ? R.get(e.trigger.metric.rid) || null : null });
|
|
432
|
+
return entries;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function liveEntry(root, id, today) {
|
|
436
|
+
const J = read(root);
|
|
437
|
+
const e = fold(J.rows, { today }).find((x) => x.id === id);
|
|
438
|
+
if (!e) return { J, error: `no decision ${id} in this journal (pmos decisions list shows the ids)` };
|
|
439
|
+
if (e.state === 'checked' || e.state === 'replaced') return { J, error: `${id} is closed (${e.state}); it does not come back` };
|
|
440
|
+
return { J, e };
|
|
441
|
+
}
|
|
442
|
+
const fail = (e) => ({ ok: false, error: 'the decision journal could not be written: ' + String((e && e.message) || e).slice(0, 160) });
|
|
443
|
+
|
|
444
|
+
function setTrigger(root, f = {}, { now = Date.now(), by, via } = {}) {
|
|
445
|
+
root = path.resolve(root);
|
|
446
|
+
const today = todayOf(now);
|
|
447
|
+
const { J, e, error } = liveEntry(root, f.id, today);
|
|
448
|
+
if (error) return { ok: false, error };
|
|
449
|
+
let fields;
|
|
450
|
+
if (f.off) fields = { off: true };
|
|
451
|
+
else {
|
|
452
|
+
const T = triggerOf(f, today);
|
|
453
|
+
if (T.error) return { ok: false, error: T.error };
|
|
454
|
+
if (!T.fields.review_on && !T.fields.metric) return { ok: false, error: 'a trigger needs --review <date> or --metric "<goal id> < <number>" (or --off to turn it off)' };
|
|
455
|
+
fields = T.fields;
|
|
456
|
+
}
|
|
457
|
+
const line = { type: 'trigger', id: e.id, ...fields, at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'cli' };
|
|
458
|
+
try { append(J.file, line); } catch (err) { return fail(err); }
|
|
459
|
+
console.log(`${BACK_TAG} trigger ${e.id}${fields.off ? ' off' : ''}`);
|
|
460
|
+
return { ok: true, id: e.id, line, file: rel(root, J.file) };
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function keep(root, { id, next } = {}, { now = Date.now(), by, via, dropBackDays = DROP_BACK_DAYS } = {}) {
|
|
464
|
+
root = path.resolve(root);
|
|
465
|
+
const today = todayOf(now);
|
|
466
|
+
const { J, e, error } = liveEntry(root, id, today);
|
|
467
|
+
if (error) return { ok: false, error };
|
|
468
|
+
let nextDay = '';
|
|
469
|
+
if (next != null && next !== '') {
|
|
470
|
+
nextDay = checkDate(next, today);
|
|
471
|
+
if (!nextDay || nextDay <= today) return { ok: false, error: '--next is a date after today (YYYY-MM-DD, or +30d, +2w, +3m)' };
|
|
472
|
+
} else {
|
|
473
|
+
const t = triggerIn(e, { dropBackDays });
|
|
474
|
+
if (!t) return { ok: false, error: `${id} has no review trigger, so there is nothing to keep (pmos decisions trigger ${id} --review +30d sets one)` };
|
|
475
|
+
if (t.review_on) {
|
|
476
|
+
const k = lastKeep(e), from = k && k.next && String(k.at) > String(t.at || '') ? String(k.at).slice(0, 10) : e.date;
|
|
477
|
+
const prev = k && k.next && String(k.at) > String(t.at || '') ? k.next : t.review_on;
|
|
478
|
+
nextDay = addDays(today, Math.max(MIN_GAP, isDate(from) && isDate(prev) ? daysBetween(from, prev) : DEFAULT_DAYS));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
const line = { type: 'review', id: e.id, choice: 'keep', ...(nextDay ? { next: nextDay } : {}), at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'cli' };
|
|
482
|
+
try { append(J.file, line); } catch (err) { return fail(err); }
|
|
483
|
+
console.log(`${BACK_TAG} keep ${e.id}${nextDay ? ' next ' + nextDay : ''}`);
|
|
484
|
+
return { ok: true, id: e.id, line, file: rel(root, J.file) };
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
function change(root, { id, decided, expected, changed_mind } = {}, o = {}) {
|
|
488
|
+
root = path.resolve(root);
|
|
489
|
+
const today = todayOf(o.now || Date.now());
|
|
490
|
+
const { e, error } = liveEntry(root, id, today);
|
|
491
|
+
if (error) return { ok: false, error };
|
|
492
|
+
const r = add(root, { decided, expected: one(expected) || e.expected, replaces: id, changed_mind }, o);
|
|
493
|
+
if (!r.ok) return r;
|
|
494
|
+
const J = read(root);
|
|
495
|
+
const line = { type: 'review', id, choice: 'change', to: r.id, at: new Date(o.now || Date.now()).toISOString(), by: o.by || 'agent:unknown', via: o.via || 'cli' };
|
|
496
|
+
try { append(J.file, line); } catch (err) { return fail(err); }
|
|
497
|
+
console.log(`${BACK_TAG} change ${id} to ${r.id}`);
|
|
498
|
+
return { ok: true, id, to: r.id, line, file: r.file };
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
function undoStep(root, { id } = {}, { now = Date.now(), by, via } = {}) {
|
|
502
|
+
try {
|
|
503
|
+
root = path.resolve(root);
|
|
504
|
+
const J = read(root);
|
|
505
|
+
const gone = stepsUndone(J.rows);
|
|
506
|
+
const steps = J.rows.filter((r) => r && (r.type === 'trigger' || r.type === 'review') && r.id === id && typeof r.at === 'string' && !gone.has(r.id + '|' + r.at));
|
|
507
|
+
const last = steps.pop();
|
|
508
|
+
if (!last) return { ok: false, error: `${id} has no Keep, Change or trigger to undo` };
|
|
509
|
+
const line = { type: 'undo-step', id, of: last.at, at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'cli' };
|
|
510
|
+
append(J.file, line);
|
|
511
|
+
let also = null;
|
|
512
|
+
if (last.type === 'review' && last.choice === 'change' && last.to) { const u = undo(root, { id: last.to }, { now, by, via }); if (u.ok) also = last.to; }
|
|
513
|
+
console.log(`${BACK_TAG} undo ${id} ${last.type}${last.choice ? ' ' + last.choice : ''}`);
|
|
514
|
+
return { ok: true, id, undid: last.type === 'review' ? last.choice : 'trigger', also, line, file: rel(root, J.file) };
|
|
515
|
+
} catch (e) { return fail(e); }
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/** The health number: live decisions (open, logged, due) with a trigger, set or drafted. */
|
|
519
|
+
function triggerShare(entries) {
|
|
520
|
+
const live = (entries || []).filter((e) => e.state === 'open' || e.state === 'logged' || e.state === 'due');
|
|
521
|
+
const withT = live.filter((e) => e.trigger), drafted = withT.filter((e) => e.trigger.drafted);
|
|
522
|
+
return { live: live.length, withTrigger: withT.length, drafted: drafted.length, pct: live.length ? Math.round((100 * withT.length) / live.length) : 0 };
|
|
523
|
+
}
|
|
524
|
+
/** The outcome number: Keep and Change answers in the last `days` days, not undone. */
|
|
525
|
+
function answeredCount(rows, { days = 30, now = Date.now() } = {}) {
|
|
526
|
+
const gone = stepsUndone(rows), since = now - days * DAY;
|
|
527
|
+
return (rows || []).filter((r) => r && r.type === 'review' && (r.choice === 'keep' || r.choice === 'change') && !gone.has(r.id + '|' + r.at) && Date.parse(r.at) >= since && Date.parse(r.at) <= now).length;
|
|
528
|
+
}
|
|
529
|
+
|
|
278
530
|
const rate = (w, d) => (w + d ? Math.round((100 * w) / (w + d)) : null);
|
|
279
531
|
|
|
280
532
|
/** The track record: how the user's calls turned out, per quarter of the date each check answered. */
|
|
@@ -313,26 +565,40 @@ function foldWithFirst(rows, opts) {
|
|
|
313
565
|
}
|
|
314
566
|
|
|
315
567
|
/** Every entry of a repository's journal, sorted for a reader. */
|
|
316
|
-
function entriesOf(root, { today = todayOf() } = {}) {
|
|
568
|
+
function entriesOf(root, { today = todayOf(), dropBackDays = DROP_BACK_DAYS } = {}) {
|
|
317
569
|
const J = read(root);
|
|
318
|
-
return { entries: sorted(foldWithFirst(J.rows, { today })), file: rel(path.resolve(root), J.file) };
|
|
570
|
+
return { entries: withBack(path.resolve(root), sorted(foldWithFirst(J.rows, { today })), { today, dropBackDays }), file: rel(path.resolve(root), J.file) };
|
|
319
571
|
}
|
|
320
572
|
|
|
321
573
|
/** A signature that changes when a journal file changes. */
|
|
322
574
|
function stamp(root) {
|
|
323
575
|
const out = [];
|
|
324
|
-
for (const f of filesOf(path.resolve(root)).all) { try { const st = fs.statSync(f); out.push(st.mtimeMs + ':' + st.size); } catch { /* none */ } }
|
|
576
|
+
for (const f of [...filesOf(path.resolve(root)).all, metricFile(path.resolve(root))].filter(Boolean)) { try { const st = fs.statSync(f); out.push(st.mtimeMs + ':' + st.size); } catch { /* none */ } }
|
|
325
577
|
return out.join('|');
|
|
326
578
|
}
|
|
327
579
|
|
|
328
580
|
module.exports = { FILE, VERDICTS, VERDICT_WORDS, DEFAULT_DAYS, ON_TIME_DAYS, FROM, TAG, read, fold: foldWithFirst, sorted, add, check, record, entriesOf, checkDate, quarterOf, todayOf, stamp, filesOf,
|
|
329
|
-
logFrom, undo, onLifecycle, loggedCount
|
|
581
|
+
logFrom, undo, onLifecycle, loggedCount,
|
|
582
|
+
BACK_TAG, DROP_BACK_DAYS, DAILY_MAX, OPS, parseMetric, draftTrigger, comeBack, setTrigger, keep, change, undoStep, triggerShare, answeredCount, dropBackSetting, metricWords };
|
|
330
583
|
|
|
331
584
|
if (require.main === module) {
|
|
332
585
|
const a = process.argv.slice(2);
|
|
333
|
-
if (
|
|
586
|
+
if (!['logged', 'triggers', 'answered'].includes(a[0])) { console.error('usage: node lib/decision-journal.js logged|triggers|answered <root> [--days N]'); process.exit(2); }
|
|
334
587
|
const root = path.resolve(a[1] && !a[1].startsWith('--') ? a[1] : '.');
|
|
335
|
-
const i = a.indexOf('--days')
|
|
588
|
+
const i = a.indexOf('--days');
|
|
589
|
+
if (a[0] === 'triggers') {
|
|
590
|
+
const S = triggerShare(entriesOf(root, { dropBackDays: dropBackSetting() }).entries);
|
|
591
|
+
console.log(`${BACK_TAG} ${S.withTrigger} of ${S.live} live decisions have a review trigger (${S.drafted} drafted by PMOS)`);
|
|
592
|
+
console.log(String(S.pct));
|
|
593
|
+
process.exit(0);
|
|
594
|
+
}
|
|
595
|
+
if (a[0] === 'answered') {
|
|
596
|
+
const d = i > 0 ? Math.max(1, +a[i + 1] || 30) : 30, n = answeredCount(read(root).rows, { days: d });
|
|
597
|
+
console.log(`${BACK_TAG} ${n} ${n === 1 ? 'decision that came back was' : 'decisions that came back were'} kept or changed in the last ${d} days`);
|
|
598
|
+
console.log(String(n));
|
|
599
|
+
process.exit(0);
|
|
600
|
+
}
|
|
601
|
+
const days = i > 0 ? Math.max(1, +a[i + 1] || 7) : 7;
|
|
336
602
|
const n = loggedCount(read(root).rows, { days });
|
|
337
603
|
console.log(`${TAG} ${n} decision ${n === 1 ? 'line was' : 'lines were'} logged from presses in the last ${days} days and not undone`);
|
|
338
604
|
console.log(String(n));
|
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
* the verdict on a decision; cant-tell --again sets a new date to look again
|
|
11
11
|
* pmos decisions record [--json] the track record: per quarter, worked, didn't work, can't tell and the hit rate
|
|
12
12
|
* pmos decisions undo <id> [--json] takes a decision out of the journal (one `undo` line), e.g. one logged from a press
|
|
13
|
+
* pmos decisions undo <id> --step undoes the latest Keep, Change or trigger of a decision (the Undo of Today's Keep)
|
|
14
|
+
* pmos decisions trigger <id> [--threshold "<text>"] [--review <date|+30d>] [--metric "<goal id> < <number>"] | --off
|
|
15
|
+
* when the decision comes back on Today (decisions-come-back); add takes the same three
|
|
16
|
+
* pmos decisions keep <id> [--next <date|+30d>] it came back and still holds: look again on the next date (the same gap again by default)
|
|
17
|
+
* pmos decisions change <id> "<new decision>" --changed-mind "<what changed>" [--expect "<text>"] it came back and no longer holds
|
|
18
|
+
* pmos decisions back-days [0|30|60|90|180] the days after which a decision dropped with a reason comes back (Settings, default 90)
|
|
13
19
|
* every command: [--root <dir>] (default: this repository)
|
|
14
20
|
*
|
|
15
21
|
* The agent runs add and check only after the PM said yes in the chat; the line names who wrote it (lib/actor.js). A verdict is the PM's:
|
|
@@ -19,9 +25,9 @@ const path = require('path');
|
|
|
19
25
|
const { execFileSync } = require('child_process');
|
|
20
26
|
const J = require('./decision-journal.js');
|
|
21
27
|
|
|
22
|
-
const COMMANDS = { decisions: ['add', 'list', 'show', 'check', 'record', 'undo'] };
|
|
28
|
+
const COMMANDS = { decisions: ['add', 'list', 'show', 'check', 'record', 'undo', 'trigger', 'keep', 'change', 'back-days'] };
|
|
23
29
|
const USAGE = [
|
|
24
|
-
'usage: pmos decisions add|list|show|check|record — a decision journal: each decision has an expected outcome and a date to check it',
|
|
30
|
+
'usage: pmos decisions add|list|show|check|record|trigger|keep|change — a decision journal: each decision has an expected outcome and a date to check it',
|
|
25
31
|
' pmos decisions add "<what was decided>" --expect "<what should happen>" [--check <YYYY-MM-DD|+30d>] [--why "<text>"] [--against "<who disagreed, and why>"] [--initiative <id>]',
|
|
26
32
|
' pmos decisions add "<new decision>" --expect "<text>" --replaces <id> --changed-mind "<the evidence that changed your mind>"',
|
|
27
33
|
' pmos decisions list [--all] [--json] due checks first, then the open ones',
|
|
@@ -29,11 +35,16 @@ const USAGE = [
|
|
|
29
35
|
' pmos decisions check <id> <worked|didnt-work|cant-tell> --evidence "<text>" [--again <date>] your verdict on a decision',
|
|
30
36
|
' pmos decisions record [--json] how your decisions turned out, per quarter',
|
|
31
37
|
' pmos decisions undo <id> [--json] take a decision out of the journal, for example one logged from a press',
|
|
38
|
+
' pmos decisions trigger <id> [--threshold "<line it must hold>"] [--review <date|+30d>] [--metric "<goal id> < <number>"] | --off when it comes back',
|
|
39
|
+
' pmos decisions keep <id> [--next <date|+30d>] it came back and still holds; undo with: pmos decisions undo <id> --step',
|
|
40
|
+
' pmos decisions change <id> "<new decision>" --changed-mind "<what changed>" [--expect "<text>"]',
|
|
41
|
+
' pmos decisions back-days [0|30|60|90|180] the days after which a dropped decision comes back (default 90)',
|
|
32
42
|
'Run it in the product\'s repository, or pass --root <dir>. The check date is 30 days after the decision unless --check says otherwise.',
|
|
33
43
|
];
|
|
34
44
|
const VERDICT = { worked: 'worked', validated: 'worked', 'didnt-work': 'didnt-work', "didn't-work": 'didnt-work', refuted: 'didnt-work', 'cant-tell': 'cant-tell', "can't-tell": 'cant-tell', inconclusive: 'cant-tell' };
|
|
35
|
-
const ALLOWED = { add: ['json', 'root', 'expect', 'check', 'why', 'against', 'initiative', 'replaces', 'changed-mind'], list: ['json', 'root', 'all'], show: ['json', 'root'], check: ['json', 'root', 'evidence', 'again'], record: ['json', 'root'], undo: ['json', 'root']
|
|
36
|
-
|
|
45
|
+
const ALLOWED = { add: ['json', 'root', 'expect', 'check', 'why', 'against', 'initiative', 'replaces', 'changed-mind', 'threshold', 'review', 'metric'], list: ['json', 'root', 'all'], show: ['json', 'root'], check: ['json', 'root', 'evidence', 'again'], record: ['json', 'root'], undo: ['json', 'root', 'step'],
|
|
46
|
+
trigger: ['json', 'root', 'threshold', 'review', 'metric', 'off'], keep: ['json', 'root', 'next'], change: ['json', 'root', 'changed-mind', 'expect'], 'back-days': ['json'] };
|
|
47
|
+
const BOOL = new Set(['json', 'all', 'step', 'off']);
|
|
37
48
|
|
|
38
49
|
function parse(args) {
|
|
39
50
|
const pos = [], flags = {};
|
|
@@ -60,13 +71,20 @@ function line(e) {
|
|
|
60
71
|
: e.state === 'checked' ? `${J.VERDICT_WORDS[e.verdict.verdict]} (${short(e.verdict.date)})`
|
|
61
72
|
: e.state === 'logged' ? `${FROM_WORDS[e.from] || 'logged'} on ${short(e.date)}`
|
|
62
73
|
: `reversed by ${e.replacedBy}`;
|
|
63
|
-
return ` ${e.id} — ${e.decided}\n ${e.expected ? 'expected: ' + e.expected + ' · ' : ''}${when}`;
|
|
74
|
+
return ` ${e.id} — ${e.decided}\n ${e.expected ? 'expected: ' + e.expected + ' · ' : ''}${when}${e.back ? ' · back now: ' + e.back.why : e.trigger && e.trigger.review_on ? ' · comes back ' + short(e.trigger.review_on) : ''}`;
|
|
75
|
+
}
|
|
76
|
+
const trig = (t) => t ? { threshold: t.threshold || null, review_on: t.review_on || null, metric: t.metric || null, drafted: !!t.drafted, source: t.source || null } : null;
|
|
77
|
+
function trigWords(t) {
|
|
78
|
+
if (!t) return 'no review trigger';
|
|
79
|
+
return [t.threshold ? `holds while it never ${t.threshold}` : '', t.review_on ? `comes back ${short(t.review_on)}` : '', t.metric ? `or when ${J.metricWords(t.metric)}` : ''].filter(Boolean).join(' · ')
|
|
80
|
+
+ (t.drafted ? ` (drafted by PMOS from ${t.source}; set your own with pmos decisions trigger)` : '');
|
|
64
81
|
}
|
|
65
82
|
const FROM_WORDS = { approval: 'approved', card: 'picked on a card', drop: 'dropped with a reason', park: 'parked with a reason' };
|
|
66
83
|
const pub = (e) => ({ id: e.id, state: e.state, from: e.from || null, ref: e.ref || null, date: e.date, decided: e.decided, expected: e.expected, check: e.check, why: e.why || null, against: e.against || null,
|
|
67
84
|
initiative: e.initiative || null, replaces: e.replaces || null, changed_mind: e.changed_mind || null, replaced_by: e.replacedBy || null, replaced_why: e.replacedWhy || null,
|
|
68
85
|
verdict: e.verdict ? { verdict: e.verdict.verdict, evidence: e.verdict.evidence, date: e.verdict.date } : null,
|
|
69
|
-
checks: e.checks.map((c) => ({ verdict: c.verdict, evidence: c.evidence, date: c.date, ...(c.again ? { again: c.again } : {}) })), days_past: e.state === 'due' ? e.days : 0
|
|
86
|
+
checks: e.checks.map((c) => ({ verdict: c.verdict, evidence: c.evidence, date: c.date, ...(c.again ? { again: c.again } : {}) })), days_past: e.state === 'due' ? e.days : 0,
|
|
87
|
+
trigger: trig(e.trigger), back: e.back || null, reviews: (e.reviews || []).map((r) => ({ choice: r.choice, at: r.at, ...(r.next ? { next: r.next } : {}), ...(r.to ? { to: r.to } : {}) })) });
|
|
70
88
|
|
|
71
89
|
async function run(argv, { say = (s) => console.log(s), env = process.env, cwd = process.cwd(), now = Date.now(), isTTY } = {}) {
|
|
72
90
|
const args = argv[0] === 'decisions' ? argv.slice(1) : argv.slice();
|
|
@@ -84,7 +102,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
84
102
|
if (pos.length !== 1) return fail('usage: pmos decisions add "<what was decided>" --expect "<what should happen>" (put the decision in quotes)', 2);
|
|
85
103
|
const a = actor();
|
|
86
104
|
const r = J.add(root, { decided: pos[0], expected: flags.expect, check: flags.check, why: flags.why, against: flags.against, initiative: flags.initiative,
|
|
87
|
-
replaces: flags.replaces, changed_mind: flags['changed-mind'] }, { now, by: a.by, via: a.via });
|
|
105
|
+
replaces: flags.replaces, changed_mind: flags['changed-mind'], threshold: flags.threshold, review: flags.review, metric: flags.metric }, { now, by: a.by, via: a.via });
|
|
88
106
|
if (!r.ok) return fail(r.error);
|
|
89
107
|
if (flags.json) { say(JSON.stringify({ ok: true, id: r.id, check: r.line.check, file: r.file })); return 0; }
|
|
90
108
|
say(`✓ ${r.id}: check on ${short(r.line.check)}${r.line.replaces ? ` · replaces ${r.line.replaces}` : ''} (${r.file}). Commit it to keep it.`);
|
|
@@ -92,6 +110,49 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
92
110
|
return 0;
|
|
93
111
|
}
|
|
94
112
|
|
|
113
|
+
if (sub === 'back-days') {
|
|
114
|
+
const SS = require('./settings-store.js'), dir = require('./state-root.js').defaultRoot({ env });
|
|
115
|
+
if (pos.length > 1) return fail('usage: pmos decisions back-days [0|30|60|90|180]', 2);
|
|
116
|
+
if (pos.length) {
|
|
117
|
+
const r = SS.set(dir, 'decisions.dropBack', Number(pos[0]));
|
|
118
|
+
if (!r.ok) return fail(r.error || 'back-days is one of 0, 30, 60, 90, 180');
|
|
119
|
+
}
|
|
120
|
+
const v = SS.get(dir, 'decisions.dropBack');
|
|
121
|
+
say(flags.json ? JSON.stringify({ ok: true, days: v }) : v ? `A decision dropped with a reason comes back ${v} days later.` : 'Dropped decisions do not come back by themselves.');
|
|
122
|
+
return 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (sub === 'trigger' || sub === 'keep' || sub === 'change') {
|
|
126
|
+
const a = actor(), who = { now, by: a.by, via: a.via, dropBackDays: J.dropBackSetting(env) };
|
|
127
|
+
let r;
|
|
128
|
+
if (sub === 'trigger') {
|
|
129
|
+
if (pos.length !== 1) return fail('usage: pmos decisions trigger <id> [--threshold "<text>"] [--review <date|+30d>] [--metric "<goal id> < <number>"] | --off', 2);
|
|
130
|
+
r = J.setTrigger(root, { id: pos[0], threshold: flags.threshold, review: flags.review, metric: flags.metric, off: !!flags.off }, who);
|
|
131
|
+
} else if (sub === 'keep') {
|
|
132
|
+
if (pos.length !== 1) return fail('usage: pmos decisions keep <id> [--next <date|+30d>]', 2);
|
|
133
|
+
r = J.keep(root, { id: pos[0], next: flags.next }, who);
|
|
134
|
+
} else {
|
|
135
|
+
if (pos.length !== 2) return fail('usage: pmos decisions change <id> "<the new decision>" --changed-mind "<what changed>" (put the new decision in quotes)', 2);
|
|
136
|
+
r = J.change(root, { id: pos[0], decided: pos[1], expected: flags.expect, changed_mind: flags['changed-mind'] }, who);
|
|
137
|
+
}
|
|
138
|
+
if (!r.ok) return fail(r.error);
|
|
139
|
+
if (flags.json) { say(JSON.stringify({ ok: true, id: r.id, ...(r.to ? { to: r.to } : {}), line: r.line, file: r.file })); return 0; }
|
|
140
|
+
if (sub === 'trigger') say(r.line.off ? `✓ ${r.id} will not come back by itself (${r.file}).` : `✓ ${r.id} comes back ${[r.line.review_on ? 'on ' + short(r.line.review_on) : '', r.line.metric ? 'when ' + J.metricWords(r.line.metric) : ''].filter(Boolean).join(' or ')} (${r.file}).`);
|
|
141
|
+
else if (sub === 'keep') say(`✓ Kept ${r.id}${r.line.next ? `; it comes back on ${short(r.line.next)}` : ''}. Undo: pmos decisions undo ${r.id} --step`);
|
|
142
|
+
else say(`✓ ${r.to} replaces ${r.id}. Undo: pmos decisions undo ${r.id} --step`);
|
|
143
|
+
return 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (sub === 'undo' && flags.step) {
|
|
147
|
+
if (pos.length !== 1) return fail('usage: pmos decisions undo <id> --step', 2);
|
|
148
|
+
const a = actor();
|
|
149
|
+
const r = J.undoStep(root, { id: pos[0] }, { now, by: a.by, via: a.via });
|
|
150
|
+
if (!r.ok) return fail(r.error);
|
|
151
|
+
if (flags.json) { say(JSON.stringify({ ok: true, id: r.id, undid: r.undid, also: r.also, file: r.file })); return 0; }
|
|
152
|
+
say(`✓ Undid the ${r.undid} on ${r.id}${r.also ? ` and took ${r.also} out` : ''} (${r.file}).`);
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
95
156
|
if (sub === 'undo') {
|
|
96
157
|
if (pos.length !== 1) return fail('usage: pmos decisions undo <id>', 2);
|
|
97
158
|
const a = actor();
|
|
@@ -102,7 +163,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
102
163
|
return 0;
|
|
103
164
|
}
|
|
104
165
|
|
|
105
|
-
const { entries, file } = J.entriesOf(root, { today });
|
|
166
|
+
const { entries, file } = J.entriesOf(root, { today, dropBackDays: J.dropBackSetting(env) });
|
|
106
167
|
|
|
107
168
|
if (sub === 'list') {
|
|
108
169
|
if (pos.length) return fail('pmos decisions list takes no argument', 2);
|
|
@@ -132,6 +193,9 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
132
193
|
if (e.replaces) say(` replaces ${e.replaces}: ${e.changed_mind}`);
|
|
133
194
|
for (const c of e.checks) say(` ${short(c.date)}: ${J.VERDICT_WORDS[c.verdict]} — ${c.evidence}${c.again ? ` (look again on ${short(c.again)})` : ''}`);
|
|
134
195
|
if (e.replacedBy) say(` reversed by ${e.replacedBy} on ${short(e.replacedAt)}: ${e.replacedWhy}`);
|
|
196
|
+
if (e.state === 'open' || e.state === 'logged' || e.state === 'due') say(' comes back: ' + trigWords(e.trigger));
|
|
197
|
+
for (const r of e.reviews || []) say(` ${short(String(r.at).slice(0, 10))}: ${r.choice === 'keep' ? 'kept' + (r.next ? ', back on ' + short(r.next) : '') : 'changed to ' + r.to}`);
|
|
198
|
+
if (e.back) say(` back now: ${e.back.why}. Keep: pmos decisions keep ${e.id} · Change: pmos decisions change ${e.id} "<new decision>" --changed-mind "<what changed>"`);
|
|
135
199
|
return 0;
|
|
136
200
|
}
|
|
137
201
|
|
|
@@ -2124,8 +2124,9 @@ const WRITES = {
|
|
|
2124
2124
|
* POST /api/boards/ini-plan-end { ws, board, id, to } → { ok, task, title, from: { due }, to, said } | { ok: true, same: true, said }
|
|
2125
2125
|
* The plan end is not stored: it is the latest due day of the initiative's PMOS tasks and breakdown items. The open one that sets it
|
|
2126
2126
|
* today gets `to` as its due day. A Done task that sets it, or no dated task at all, is { ask: true }.
|
|
2127
|
-
* POST /api/boards/ini-close-open { ws, board, id } → { ok, closed: [{ task, title, from }], said }
|
|
2128
|
-
* Every open PMOS task and breakdown item goes to Done. A Jira ticket is Jira's and is never written here
|
|
2127
|
+
* POST /api/boards/ini-close-open { ws, board, id } → { ok, closed: [{ task, title, from }], jira, said }
|
|
2128
|
+
* Every open PMOS task and breakdown item goes to Done. A Jira ticket is Jira's and is never written here: `jira` counts the open
|
|
2129
|
+
* ones left to Jira, and `said` says so. Undo: tasks/state with
|
|
2129
2130
|
* each `from`.
|
|
2130
2131
|
* POST /api/boards/ini-reopen { ws, board, id } → { ok, did: 'wontdo' | 'stage', to, undo: { route, body }, said }
|
|
2131
2132
|
* Won't do: out of Won't do, back to the stage it was in. The last stage: back to the stage of the last move into it, else the stage
|
|
@@ -2174,6 +2175,10 @@ Object.assign(WRITES, {
|
|
|
2174
2175
|
const f = directFrame(ctx, res, body);
|
|
2175
2176
|
if (!f) return;
|
|
2176
2177
|
const open = workOfIni(f.p, body.id).filter((x) => OPEN_STATES.includes(x.state));
|
|
2178
|
+
// the open Jira tickets of the initiative stay Jira's: never written here, counted in the answer (direct-plain-actions C2)
|
|
2179
|
+
let jira = 0;
|
|
2180
|
+
try { jira = itemsOf(f.p.w, f.p.fr, f.p.board, [f.row]).filter((x) => x.src === 'jira' && x.kind !== 'Epic' && x.ini === body.id && x.status !== 'Done').length; } catch { jira = 0; }
|
|
2181
|
+
const left = jira ? ' ' + jira + (jira === 1 ? ' Jira ticket is' : ' Jira tickets are') + ' left to Jira.' : '';
|
|
2177
2182
|
if (!open.length) return askBack(ctx, res, 'it has no open PMOS task: the open ones are Jira tickets, and Jira owns them');
|
|
2178
2183
|
const closed = [], failed = [];
|
|
2179
2184
|
for (const x of open) {
|
|
@@ -2181,7 +2186,7 @@ Object.assign(WRITES, {
|
|
|
2181
2186
|
if (r.body && r.body.ok !== false) closed.push({ task: x.id, title: x.title, from: x.state }); else failed.push(x.title);
|
|
2182
2187
|
}
|
|
2183
2188
|
if (!closed.length) return fail(ctx, res, 500, 'no task was closed: ' + failed.join(', '));
|
|
2184
|
-
ctx.json(res, { ok: true, closed, said: closed.length + (closed.length === 1 ? ' task' : ' tasks') + ' closed.' + (failed.length ? ' Not closed: ' + failed.join(', ') + '.' : '') });
|
|
2189
|
+
ctx.json(res, { ok: true, closed, jira, said: closed.length + (closed.length === 1 ? ' task' : ' tasks') + ' closed.' + (failed.length ? ' Not closed: ' + failed.join(', ') + '.' : '') + left });
|
|
2185
2190
|
},
|
|
2186
2191
|
'/api/boards/ini-reopen': (ctx, res, body, g) => {
|
|
2187
2192
|
const f = directFrame(ctx, res, body);
|
|
@@ -109,6 +109,9 @@ const DEFS = Object.freeze({
|
|
|
109
109
|
// report-reader-review: PMOS reads each report draft as the CFO, the engineer and the sceptic and files their questions under the ✦
|
|
110
110
|
// (lib/report-readers.js). On by default (Wawan, 2026-11-24: "Yes, on every report draft").
|
|
111
111
|
'critic.reports': one('checks', 'computer', ['on', 'off'], 'on'),
|
|
112
|
+
// decisions-come-back: the days after which a decision dropped with a reason comes back on Today (0: never). 90 by default (2026-11-24).
|
|
113
|
+
// `pmos decisions back-days [n]` reads and sets it (lib/decision-journal.js dropBackSetting).
|
|
114
|
+
'decisions.dropBack': one('checks', 'computer', [0, 30, 60, 90, 180], 90),
|
|
112
115
|
// Background use with no dollar limit (Wawan 2026-11-17: the runs use the subscription plan). On: the step-5 spend hold never holds
|
|
113
116
|
// (lib/bg-queue.js spendHold); the usage-limit hold a failed run leaves is the brake. `pmos grill cap unlimited` sets it.
|
|
114
117
|
'ai.unlimited': bool('checks', 'computer', false),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.793.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.793.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -19,9 +19,8 @@
|
|
|
19
19
|
.evp-menu button:focus-visible { outline: none; box-shadow: var(--glow); }
|
|
20
20
|
|
|
21
21
|
/* Main + side */
|
|
22
|
-
.evp-grid {
|
|
23
|
-
.evp-
|
|
24
|
-
.evp-side { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; }
|
|
22
|
+
.pm-ds .evp-grid.pm-layout-side { grid-template-columns: minmax(0, 1100px) var(--width-side); } /* the system's Main + side (reading-layouts, A334), tuned: the list stops at 1100 px and the month stays beside it down to 760 px */
|
|
23
|
+
.pm-ds .evp-side.pm-side { position: static; } /* the month scrolls with the page, as before */
|
|
25
24
|
#evpList { display: flex; flex-direction: column; gap: var(--space-16); }
|
|
26
25
|
#evpList:empty, #evpHid:empty { display: none; }
|
|
27
26
|
|
|
@@ -167,7 +166,7 @@ button.evp-t { cursor: pointer; }
|
|
|
167
166
|
|
|
168
167
|
/* the phone: the month and Show go under the dates */
|
|
169
168
|
@media (max-width: 760px) {
|
|
170
|
-
.evp-grid { grid-template-columns: minmax(0, 1fr); }
|
|
169
|
+
.pm-ds .evp-grid.pm-layout-side { grid-template-columns: minmax(0, 1fr); }
|
|
171
170
|
.evp .evp-r { flex-wrap: wrap; row-gap: var(--space-4); padding: var(--space-8) var(--space-12); }
|
|
172
171
|
.evp .evp-r .txt { flex: 1 1 calc(100% - 100px); }
|
|
173
172
|
.evp-sug, .evp-src { margin-left: var(--space-16); padding-left: var(--space-16); }
|
|
@@ -685,7 +685,9 @@ async function draftDocs(s, x, h) {
|
|
|
685
685
|
async function direct(d, ask, x, h) {
|
|
686
686
|
const w = h.where ? h.where() : {}, id = x.o().id;
|
|
687
687
|
const res = await pmPost('/api/boards/ini-' + d.act, { ws: w.ws, board: w.board, id, ...(d.to ? { to: d.to } : {}) }).catch(() => null);
|
|
688
|
-
|
|
688
|
+
// the words go to Ask PMOS when the plain reading does not hold (ask), or when the route cannot be reached: pmPost answers
|
|
689
|
+
// { ok: false } with no status when the server is not there, and an older server answers 404 for a route it does not have (C4)
|
|
690
|
+
if (!res || res.ask || (res.ok === false && (!res.status || res.status === 404))) { toAsk(ask, h); return; }
|
|
689
691
|
if (res.ok === false) { if (h.toast) h.toast(res.error || 'Nothing was changed.'); return; }
|
|
690
692
|
if (h.reload) await h.reload();
|
|
691
693
|
if (res.same) { if (h.toast) h.toast(res.said || 'Nothing to change.'); return; }
|
|
@@ -12,9 +12,11 @@
|
|
|
12
12
|
.rt-top { display: flex; align-items: center; gap: var(--space-12); min-height: 32px; }
|
|
13
13
|
.rt-top .rt-sp { flex: 1; }
|
|
14
14
|
/* Main + open item: the table stays, the open routine sits at the right */
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
.
|
|
15
|
+
/* The system's Main + open item (reading-layouts, A334), tuned so nothing moves: the open routine is 400 px wide, the table's blocks sit 12 px
|
|
16
|
+
apart, and the Detail is its own card, so the item slot draws none. The slot is .pm-item only while a routine is open (cozy-routine.js). */
|
|
17
|
+
.pm-ds .rt-mi.pm-layout-open:has(>.pm-item) { grid-template-columns: minmax(0, 1fr) 400px; }
|
|
18
|
+
.pm-ds .rt-main.pm-main { gap: var(--space-12); }
|
|
19
|
+
.pm-ds .rt-mi > .rt-aside.pm-item { background: none; border-radius: 0; box-shadow: none; padding: 0; }
|
|
18
20
|
.rt-aside:empty { display: none; }
|
|
19
21
|
.rt-aside { position: sticky; top: var(--space-16); min-width: 0; }
|
|
20
22
|
/* PMOS did */
|
|
@@ -328,6 +328,7 @@ function drawDetail() {
|
|
|
328
328
|
host.innerHTML = r ? detailHtml(detailOf(r)) : '';
|
|
329
329
|
const sec = host.querySelector('.rt-detail'); if (sec) { sec.dataset.key = r.key; if (keep) sec.classList.remove('pm-motion-enter'); }
|
|
330
330
|
if (page) page.classList.toggle('rt-open', !!r);
|
|
331
|
+
host.classList.toggle('pm-item', !!r); // the layout's item slot only while a routine is open (reading-layouts, A334)
|
|
331
332
|
}
|
|
332
333
|
/** Show a routine in the Detail (a desk), or open it in full (a phone, or a second press on the open one). */
|
|
333
334
|
function show(r) {
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
</div>
|
|
39
39
|
</span>
|
|
40
40
|
</div>
|
|
41
|
-
<div class="evp-grid">
|
|
42
|
-
<div class="evp-left">
|
|
41
|
+
<div class="evp-grid pm-layout-side">
|
|
42
|
+
<div class="evp-left pm-main">
|
|
43
43
|
<form class="evp-new" id="evpAdd" hidden aria-label="Your own date">
|
|
44
44
|
<input class="pm-input" name="what" type="text" placeholder="What, for example: Call Rina about the contract" aria-label="What" autocomplete="off" />
|
|
45
45
|
<input class="pm-input" name="when" type="date" aria-label="When" />
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
<div id="evpHid"></div>
|
|
50
50
|
<div id="evpList" aria-live="polite"><p class="evp-quiet pm-meta" role="status">Reading the dates.</p></div>
|
|
51
51
|
</div>
|
|
52
|
-
<aside class="evp-side" aria-label="The month">
|
|
52
|
+
<aside class="evp-side pm-side" aria-label="The month">
|
|
53
53
|
<div id="evpMonth"></div>
|
|
54
54
|
<div id="evpShow"></div>
|
|
55
55
|
</aside>
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
<span class="rt-sp"></span>
|
|
31
31
|
<button type="button" class="pm-btn" id="rtAdd" aria-label="Ask PMOS for a new routine" title="Ask PMOS for a new routine"><svg class="pm-ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M12 5v14M5 12h14"/></svg></button>
|
|
32
32
|
</div>
|
|
33
|
-
<div class="rt-mi">
|
|
34
|
-
<div class="rt-main">
|
|
33
|
+
<div class="rt-mi pm-layout-open">
|
|
34
|
+
<div class="rt-main pm-main">
|
|
35
35
|
<div id="rtDid"></div>
|
|
36
36
|
<div id="rtTable"><p class="rt-quiet pm-meta">Reading what repeats.</p></div>
|
|
37
37
|
</div>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "decisions-come-back (bet A509): each journal decision gets a threshold and a review trigger (date or goal number), drafted from its evidence, and comes back on Today with Keep, Change and Undo (lib/decision-journal.js comeBack, lib/decision-journal-needs.js decision-back).",
|
|
3
|
+
"modules": ["decisions-come-back.test.js"],
|
|
4
|
+
"seconds": { "decisions-come-back.test.js": 2 }
|
|
5
|
+
}
|