create-pmos 0.742.0 → 0.743.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 +20 -26
- 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 +19 -0
- package/workspace/guide/cli.md +1 -0
- package/workspace/guide/layout.md +2 -2
- package/workspace/lib/decision-journal.js +107 -6
- package/workspace/lib/decisions-cli.js +24 -8
- package/workspace/lib/driver-decide.js +18 -1
- package/workspace/lib/parked-reasons.js +4 -1
- package/workspace/lib/routes-proposals.js +23 -4
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/library-keys.js +41 -0
- package/workspace/public/pm/premium-library.js +5 -12
- package/workspace/server.js +2 -0
- package/workspace/test-lists/decisions-from-approvals.json +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.743.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,25 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.743.0",
|
|
38
|
+
"at": "2026-11-23T09:58:34.443Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1664,
|
|
43
|
+
"t": "Approvals, card picks, drops and parks write the decision journal, with Undo (A475)",
|
|
44
|
+
"s": "Approvals, card picks, drops and parks write the decision journal, with Undo (A475)",
|
|
45
|
+
"k": "new"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1665,
|
|
49
|
+
"t": "Every merged job keeps a PR and a cost; the verifier reaches every run; Library keys tested by pressing them (A484, A9, A437)",
|
|
50
|
+
"s": "Every merged job keeps a PR and a cost; the verifier reaches every run; Library keys tested by pressing them (A484, A9, A437)",
|
|
51
|
+
"k": "fix"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
36
55
|
{
|
|
37
56
|
"v": "0.742.0",
|
|
38
57
|
"at": "2026-11-23T09:41:15.063Z",
|
|
@@ -611,31 +630,6 @@
|
|
|
611
630
|
"k": "new"
|
|
612
631
|
}
|
|
613
632
|
]
|
|
614
|
-
},
|
|
615
|
-
{
|
|
616
|
-
"v": "0.718.0",
|
|
617
|
-
"at": "2026-11-22T23:44:48.503Z",
|
|
618
|
-
"f": 4,
|
|
619
|
-
"prs": [
|
|
620
|
-
{
|
|
621
|
-
"n": 1589,
|
|
622
|
-
"t": "Search answers first, with its source",
|
|
623
|
-
"s": "Search answers first, with its source",
|
|
624
|
-
"k": "new"
|
|
625
|
-
},
|
|
626
|
-
{
|
|
627
|
-
"n": 1592,
|
|
628
|
-
"t": "Pmos why, the three-line why of any initiative or task",
|
|
629
|
-
"s": "Pmos why, the three-line why of any initiative or task",
|
|
630
|
-
"k": "new"
|
|
631
|
-
},
|
|
632
|
-
{
|
|
633
|
-
"n": 1590,
|
|
634
|
-
"t": "One health score per product, shown only when it drops",
|
|
635
|
-
"s": "One health score per product, shown only when it drops",
|
|
636
|
-
"k": "new"
|
|
637
|
-
}
|
|
638
|
-
]
|
|
639
633
|
}
|
|
640
634
|
]
|
|
641
635
|
}
|
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-23T09:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-23T09:58:30Z"}
|
|
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-23T09:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-23T09:58:30Z"}
|
|
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-23T09:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-23T09:58:30Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.743.0",
|
|
4
|
+
"at": "2026-11-23T09:58:34.443Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1664,
|
|
9
|
+
"t": "Approvals, card picks, drops and parks write the decision journal, with Undo (A475)",
|
|
10
|
+
"s": "Approvals, card picks, drops and parks write the decision journal, with Undo (A475)",
|
|
11
|
+
"k": "new"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1665,
|
|
15
|
+
"t": "Every merged job keeps a PR and a cost; the verifier reaches every run; Library keys tested by pressing them (A484, A9, A437)",
|
|
16
|
+
"s": "Every merged job keeps a PR and a cost; the verifier reaches every run; Library keys tested by pressing them (A484, A9, A437)",
|
|
17
|
+
"k": "fix"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
},
|
|
2
21
|
{
|
|
3
22
|
"v": "0.742.0",
|
|
4
23
|
"at": "2026-11-23T09:41:15.063Z",
|
package/workspace/guide/cli.md
CHANGED
|
@@ -346,6 +346,7 @@ Write one line for each product decision, also one that is smaller than an initi
|
|
|
346
346
|
- `pmos decisions show <id>` shows one decision, its checks and its reversal.
|
|
347
347
|
- `pmos decisions check <id> <worked|didnt-work|cant-tell> --evidence "<text>"` records your verdict. With `cant-tell`, `--again <date>` sets a new date to look again.
|
|
348
348
|
- `pmos decisions record` shows how your decisions turned out: for each quarter, the decisions that worked, did not work and could not be told, and the hit rate (worked divided by worked plus did not work). It also shows the reversals and their reasons.
|
|
349
|
+
- `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.
|
|
349
350
|
- 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.
|
|
350
351
|
|
|
351
352
|
### pmos principles: the product's principles, from its decisions
|
|
@@ -241,10 +241,10 @@ A Jira date and the planned finish of an initiative get no ✓: PMOS cannot writ
|
|
|
241
241
|
|
|
242
242
|
1. To narrow the list, use the chips at the top: **Kind** (a family, such as Briefs, or one kind inside it), the product, program and project chip, and **State**. Each shows how many rows it has. When a chip hides rows, a grey line says how many; press **Show all** to clear the chips.
|
|
243
243
|
2. To group the list, press the **Group** chip and pick **New** (this week, earlier this month, older), **Work** (each program and initiative is a shelf, with one row per kind in the order of the work), **Kind** or **Product**. Press a shelf to fold it.
|
|
244
|
-
3. To find a thing, type in **Find in Library**, or press
|
|
244
|
+
3. To find a thing, type in **Find in Library**, or press `/` (when the cursor is not in a text box and no popup is open). Titles that match show at once. Under them, **Also about this** lists the documents and notes that are about your words by meaning, each with the passage that matched and the idea in bold. PMOS reads them for meaning in a normal PMOS session; until it answers, or when it cannot, they are ranked by shared words and the line says so.
|
|
245
245
|
4. A meeting note with no title shows the name PMOS gave it, with ✦. Press ✦ to keep the name or type another. A note with no work shows ✦ and the initiative it talks about: press it to link the note to that work.
|
|
246
246
|
5. To add a file, a link or a new document, press **+**. Ask PMOS opens with "Add to Library" in the box. Say what to add; PMOS fills its kind, product and work and shows you the record.
|
|
247
|
-
6. To open a thing, press its row. It opens in the popup with the chat about it. On a screen 1200 px or wider, the first press shows the record at the right: every field, the first lines, the files that link to it and its editions. Press again, press Enter or press the open button to open it. A link opens in a new browser tab.
|
|
247
|
+
6. To open a thing, press its row. It opens in the popup with the chat about it. On a screen 1200 px or wider, the first press shows the record at the right: every field, the first lines, the files that link to it and its editions. Press again, press Enter or press the open button to open it. On any screen, Enter on a row's name opens it at once. A link opens in a new browser tab.
|
|
248
248
|
|
|
249
249
|
The Library is built from the PMOS design system's blocks. The top line is the path, the product chip, then **+** and **More** (Show all, Read the Library again). The search box is always shown. The list is one card of rows, the row you picked is lit, and the record at the right is a card with its fields. On a phone a row shows the kind, the name and the day only. While the list loads, three soft lines stand in for it. When the list cannot be read, one line says why, with **Retry**.
|
|
250
250
|
|
|
@@ -23,6 +23,18 @@
|
|
|
23
23
|
* onTime, due, open, reversals: [{ id, decided, replacedBy, why }] }
|
|
24
24
|
* checkDate(text, today) → 'YYYY-MM-DD' | null a date, or +N d / w / m from today
|
|
25
25
|
*
|
|
26
|
+
* LOGGED FROM A PRESS (initiative decisions-from-approvals, bet A475). The PM's ✓ on a ✦ proposal, a picked card, a ✕ or a Drop with a
|
|
27
|
+
* reason, the Keep of an agent proposal and a hold with a reason each write one decision line by themselves, with `from` (approval, card,
|
|
28
|
+
* drop, park) and `ref` (the press it came from). Such a line has no check date unless it names an expected outcome, so it never makes a
|
|
29
|
+
* Today card by itself; it folds with state `logged`. The Undo of the press undoes the line; so does `pmos decisions undo <id>`.
|
|
30
|
+
* logFrom(root, { from, decided, ref, initiative?, why?, expected? }, { now, by, via }) → { ok, id, line?, existed? } | { ok: false, error }
|
|
31
|
+
* the same ref (not undone) is written once. Never throws
|
|
32
|
+
* undo(root, { id } | { ref }, { now, by, via }) → { ok, id, line } | { ok: false, error } one `undo` line; the fold leaves it out
|
|
33
|
+
* onLifecycle(root, rec, { now }) → result | null a lifecycle line the PM wrote: on-hold with a reason logs a park; active with reason
|
|
34
|
+
* `undo` (the hold's Undo) undoes the latest park line of that initiative
|
|
35
|
+
* loggedCount(rows, { days, now }) → number lines from presses in the last `days` days, not undone (the health number)
|
|
36
|
+
* CLI: node lib/decision-journal.js logged <root> [--days 7] prints `[decision-log] …` and the count alone on the last line
|
|
37
|
+
*
|
|
26
38
|
* A verdict is the PM's: PMOS never records one from a metric alone, and every verdict carries evidence. Nothing here sends anything.
|
|
27
39
|
*/
|
|
28
40
|
const fs = require('fs');
|
|
@@ -82,11 +94,12 @@ function checkDate(text, today) {
|
|
|
82
94
|
|
|
83
95
|
function fold(rows, { today = todayOf() } = {}) {
|
|
84
96
|
const by = new Map();
|
|
97
|
+
const undone = undoneOf(rows);
|
|
85
98
|
for (const r of rows || []) {
|
|
86
|
-
if (!r || r.type !== 'decision' || typeof r.id !== 'string' || by.has(r.id)) continue;
|
|
99
|
+
if (!r || r.type !== 'decision' || typeof r.id !== 'string' || by.has(r.id) || undone.has(r.id)) continue;
|
|
87
100
|
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 || '',
|
|
88
101
|
why: r.why || '', against: r.against || '', initiative: r.initiative || '', replaces: r.replaces || '', changed_mind: r.changed_mind || '',
|
|
89
|
-
replacedBy: '', replacedWhy: '', replacedAt: '', checks: [], verdict: null, dueAt: '', at: r.at || '', by: r.by || '' });
|
|
102
|
+
replacedBy: '', replacedWhy: '', replacedAt: '', checks: [], verdict: null, dueAt: '', at: r.at || '', by: r.by || '', from: r.from || '', ref: r.ref || '' });
|
|
90
103
|
}
|
|
91
104
|
for (const r of rows || []) {
|
|
92
105
|
if (!r || r.type !== 'check') continue;
|
|
@@ -103,17 +116,17 @@ function fold(rows, { today = todayOf() } = {}) {
|
|
|
103
116
|
}
|
|
104
117
|
const out = [...by.values()];
|
|
105
118
|
for (const e of out) {
|
|
106
|
-
e.state = e.verdict ? 'checked' : e.replacedBy ? 'replaced' : isDate(e.check)
|
|
119
|
+
e.state = e.verdict ? 'checked' : e.replacedBy ? 'replaced' : !isDate(e.check) ? 'logged' : e.check <= today ? 'due' : 'open';
|
|
107
120
|
e.days = isDate(e.check) && isDate(today) ? daysBetween(e.check, today) : 0; // > 0: days past the check date
|
|
108
121
|
}
|
|
109
122
|
return out;
|
|
110
123
|
}
|
|
111
124
|
|
|
112
|
-
const ORDER = { due: 0, open: 1,
|
|
125
|
+
const ORDER = { due: 0, open: 1, logged: 2, checked: 3, replaced: 4 };
|
|
113
126
|
/** Due checks first (oldest first), then open ones by check date, then the closed ones, newest first. */
|
|
114
127
|
function sorted(entries) {
|
|
115
128
|
return entries.slice().sort((a, b) => ORDER[a.state] - ORDER[b.state]
|
|
116
|
-
|| (a.state === 'due' || a.state === 'open' ? a.check.localeCompare(b.check) : String(b.verdict ? b.verdict.date : b.replacedAt).localeCompare(String(a.verdict ? a.verdict.date : a.replacedAt)))
|
|
129
|
+
|| (a.state === 'due' || a.state === 'open' ? a.check.localeCompare(b.check) : a.state === 'logged' ? String(b.at).localeCompare(String(a.at)) : String(b.verdict ? b.verdict.date : b.replacedAt).localeCompare(String(a.verdict ? a.verdict.date : a.replacedAt)))
|
|
117
130
|
|| a.id.localeCompare(b.id));
|
|
118
131
|
}
|
|
119
132
|
|
|
@@ -185,6 +198,83 @@ function check(root, { id, verdict, evidence, again } = {}, { now = Date.now(),
|
|
|
185
198
|
return { ok: true, line, file: rel(root, J.file) };
|
|
186
199
|
}
|
|
187
200
|
|
|
201
|
+
/* ── logged from a press (decisions-from-approvals) ── */
|
|
202
|
+
const FROM = Object.freeze(['approval', 'card', 'drop', 'park']);
|
|
203
|
+
const TAG = '[decision-log]';
|
|
204
|
+
|
|
205
|
+
/** The ids an `undo` line took out. */
|
|
206
|
+
function undoneOf(rows) {
|
|
207
|
+
const out = new Set();
|
|
208
|
+
for (const r of rows || []) if (r && r.type === 'undo' && typeof r.id === 'string') out.add(r.id);
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function logFrom(root, f = {}, { now = Date.now(), by, via } = {}) {
|
|
213
|
+
try {
|
|
214
|
+
root = path.resolve(root);
|
|
215
|
+
const from = String(f.from || '');
|
|
216
|
+
if (!FROM.includes(from)) return { ok: false, error: `from is one of ${FROM.join(', ')}` };
|
|
217
|
+
const decided = one(f.decided).slice(0, MAX.decided), ref = one(f.ref).slice(0, 160);
|
|
218
|
+
if (decided.length < 3) return { ok: false, error: 'say what was decided' };
|
|
219
|
+
if (!ref) return { ok: false, error: 'ref names the press the decision came from' };
|
|
220
|
+
const initiative = one(f.initiative), why = one(f.why).slice(0, MAX.why), expected = one(f.expected).slice(0, MAX.expected);
|
|
221
|
+
const today = todayOf(now);
|
|
222
|
+
const J = read(root);
|
|
223
|
+
const undone = undoneOf(J.rows);
|
|
224
|
+
const had = J.rows.find((r) => r && r.type === 'decision' && r.ref === ref && !undone.has(r.id));
|
|
225
|
+
if (had) return { ok: true, id: had.id, existed: true };
|
|
226
|
+
const base = today.replace(/-/g, '') + '-' + slugOf(decided);
|
|
227
|
+
const have = new Set(J.rows.filter((r) => r && r.type === 'decision').map((r) => r.id));
|
|
228
|
+
let id = base, n = 2;
|
|
229
|
+
while (have.has(id)) id = base + '-' + n++;
|
|
230
|
+
const line = { type: 'decision', id, date: today, decided, expected, check: expected.length >= 8 ? addDays(today, DEFAULT_DAYS) : '', from, ref,
|
|
231
|
+
...(initiative && ID_RE.test(initiative) ? { initiative } : {}), ...(why ? { why } : {}), at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'ui' };
|
|
232
|
+
append(J.file, line);
|
|
233
|
+
console.log(`${TAG} logged ${id} from=${from} ref=${ref}`);
|
|
234
|
+
return { ok: true, id, line, file: rel(root, J.file) };
|
|
235
|
+
} catch (e) { return { ok: false, error: 'the decision journal could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function undo(root, { id, ref } = {}, { now = Date.now(), by, via } = {}) {
|
|
239
|
+
try {
|
|
240
|
+
root = path.resolve(root);
|
|
241
|
+
const J = read(root);
|
|
242
|
+
const undone = undoneOf(J.rows);
|
|
243
|
+
const all = J.rows.filter((r) => r && r.type === 'decision' && (id ? r.id === id : ref && r.ref === ref));
|
|
244
|
+
if (!all.length) return { ok: false, error: id ? `no decision ${id} in this journal (pmos decisions list shows the ids)` : 'no decision came from that press' };
|
|
245
|
+
const live = all.filter((r) => !undone.has(r.id)).pop();
|
|
246
|
+
if (!live) return { ok: false, error: `${all[all.length - 1].id} was already undone` };
|
|
247
|
+
const line = { type: 'undo', id: live.id, at: new Date(now).toISOString(), by: by || 'agent:unknown', via: via || 'ui' };
|
|
248
|
+
append(J.file, line);
|
|
249
|
+
console.log(`${TAG} undone ${live.id}`);
|
|
250
|
+
return { ok: true, id: live.id, line, file: rel(root, J.file) };
|
|
251
|
+
} catch (e) { return { ok: false, error: 'the decision journal could not be written: ' + String((e && e.message) || e).slice(0, 160) }; }
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** A lifecycle line the PM wrote (server.js /api/lifecycle). Never throws. */
|
|
255
|
+
function onLifecycle(root, rec, { now = Date.now() } = {}) {
|
|
256
|
+
if (!rec || typeof rec.initiative_id !== 'string') return null;
|
|
257
|
+
const who = { now, by: rec.by, via: rec.via };
|
|
258
|
+
const reason = one(rec.reason);
|
|
259
|
+
if (rec.state === 'on-hold' && reason) {
|
|
260
|
+
return logFrom(root, { from: 'park', decided: `Park ${rec.initiative_id}: ${reason}`, ref: `park:${rec.initiative_id}:${rec.at || new Date(now).toISOString()}`,
|
|
261
|
+
initiative: rec.initiative_id, why: reason + (rec.back ? ` (back on ${rec.back})` : '') }, who);
|
|
262
|
+
}
|
|
263
|
+
if (rec.state === 'active' && reason.toLowerCase() === 'undo') {
|
|
264
|
+
let J; try { J = read(root); } catch { return null; }
|
|
265
|
+
const undone = undoneOf(J.rows);
|
|
266
|
+
const last = J.rows.filter((r) => r && r.type === 'decision' && r.from === 'park' && r.initiative === rec.initiative_id && !undone.has(r.id)).pop();
|
|
267
|
+
return last ? undo(root, { id: last.id }, who) : null;
|
|
268
|
+
}
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/** Lines written from presses in the last `days` days and not undone. */
|
|
273
|
+
function loggedCount(rows, { days = 7, now = Date.now() } = {}) {
|
|
274
|
+
const undone = undoneOf(rows), since = now - days * DAY;
|
|
275
|
+
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
|
+
}
|
|
277
|
+
|
|
188
278
|
const rate = (w, d) => (w + d ? Math.round((100 * w) / (w + d)) : null);
|
|
189
279
|
|
|
190
280
|
/** The track record: how the user's calls turned out, per quarter of the date each check answered. */
|
|
@@ -235,4 +325,15 @@ function stamp(root) {
|
|
|
235
325
|
return out.join('|');
|
|
236
326
|
}
|
|
237
327
|
|
|
238
|
-
module.exports = { FILE, VERDICTS, VERDICT_WORDS, DEFAULT_DAYS, ON_TIME_DAYS, read, fold: foldWithFirst, sorted, add, check, record, entriesOf, checkDate, quarterOf, todayOf, stamp, filesOf
|
|
328
|
+
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 };
|
|
330
|
+
|
|
331
|
+
if (require.main === module) {
|
|
332
|
+
const a = process.argv.slice(2);
|
|
333
|
+
if (a[0] !== 'logged') { console.error('usage: node lib/decision-journal.js logged <root> [--days 7]'); process.exit(2); }
|
|
334
|
+
const root = path.resolve(a[1] && !a[1].startsWith('--') ? a[1] : '.');
|
|
335
|
+
const i = a.indexOf('--days'), days = i > 0 ? Math.max(1, +a[i + 1] || 7) : 7;
|
|
336
|
+
const n = loggedCount(read(root).rows, { days });
|
|
337
|
+
console.log(`${TAG} ${n} decision ${n === 1 ? 'line was' : 'lines were'} logged from presses in the last ${days} days and not undone`);
|
|
338
|
+
console.log(String(n));
|
|
339
|
+
}
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* pmos decisions check <id> <worked|didnt-work|cant-tell> --evidence "<text>" [--again <date>]
|
|
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
|
+
* pmos decisions undo <id> [--json] takes a decision out of the journal (one `undo` line), e.g. one logged from a press
|
|
12
13
|
* every command: [--root <dir>] (default: this repository)
|
|
13
14
|
*
|
|
14
15
|
* 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:
|
|
@@ -18,7 +19,7 @@ const path = require('path');
|
|
|
18
19
|
const { execFileSync } = require('child_process');
|
|
19
20
|
const J = require('./decision-journal.js');
|
|
20
21
|
|
|
21
|
-
const COMMANDS = { decisions: ['add', 'list', 'show', 'check', 'record'] };
|
|
22
|
+
const COMMANDS = { decisions: ['add', 'list', 'show', 'check', 'record', 'undo'] };
|
|
22
23
|
const USAGE = [
|
|
23
24
|
'usage: pmos decisions add|list|show|check|record — a decision journal: each decision has an expected outcome and a date to check it',
|
|
24
25
|
' pmos decisions add "<what was decided>" --expect "<what should happen>" [--check <YYYY-MM-DD|+30d>] [--why "<text>"] [--against "<who disagreed, and why>"] [--initiative <id>]',
|
|
@@ -27,10 +28,11 @@ const USAGE = [
|
|
|
27
28
|
' pmos decisions show <id> [--json] one decision and its checks',
|
|
28
29
|
' pmos decisions check <id> <worked|didnt-work|cant-tell> --evidence "<text>" [--again <date>] your verdict on a decision',
|
|
29
30
|
' pmos decisions record [--json] how your decisions turned out, per quarter',
|
|
31
|
+
' pmos decisions undo <id> [--json] take a decision out of the journal, for example one logged from a press',
|
|
30
32
|
'Run it in the product\'s repository, or pass --root <dir>. The check date is 30 days after the decision unless --check says otherwise.',
|
|
31
33
|
];
|
|
32
34
|
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' };
|
|
33
|
-
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'] };
|
|
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'] };
|
|
34
36
|
const BOOL = new Set(['json', 'all']);
|
|
35
37
|
|
|
36
38
|
function parse(args) {
|
|
@@ -56,10 +58,12 @@ function line(e) {
|
|
|
56
58
|
const when = e.state === 'due' ? `check due ${e.days > 0 ? 'since ' + short(e.check) : 'today'}`
|
|
57
59
|
: e.state === 'open' ? `check on ${short(e.check)}`
|
|
58
60
|
: e.state === 'checked' ? `${J.VERDICT_WORDS[e.verdict.verdict]} (${short(e.verdict.date)})`
|
|
61
|
+
: e.state === 'logged' ? `${FROM_WORDS[e.from] || 'logged'} on ${short(e.date)}`
|
|
59
62
|
: `reversed by ${e.replacedBy}`;
|
|
60
|
-
return ` ${e.id} — ${e.decided}\n expected:
|
|
63
|
+
return ` ${e.id} — ${e.decided}\n ${e.expected ? 'expected: ' + e.expected + ' · ' : ''}${when}`;
|
|
61
64
|
}
|
|
62
|
-
const
|
|
65
|
+
const FROM_WORDS = { approval: 'approved', card: 'picked on a card', drop: 'dropped with a reason', park: 'parked with a reason' };
|
|
66
|
+
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,
|
|
63
67
|
initiative: e.initiative || null, replaces: e.replaces || null, changed_mind: e.changed_mind || null, replaced_by: e.replacedBy || null, replaced_why: e.replacedWhy || null,
|
|
64
68
|
verdict: e.verdict ? { verdict: e.verdict.verdict, evidence: e.verdict.evidence, date: e.verdict.date } : null,
|
|
65
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 });
|
|
@@ -88,17 +92,29 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
88
92
|
return 0;
|
|
89
93
|
}
|
|
90
94
|
|
|
95
|
+
if (sub === 'undo') {
|
|
96
|
+
if (pos.length !== 1) return fail('usage: pmos decisions undo <id>', 2);
|
|
97
|
+
const a = actor();
|
|
98
|
+
const r = J.undo(root, { id: pos[0] }, { now, by: a.by, via: a.via });
|
|
99
|
+
if (!r.ok) return fail(r.error);
|
|
100
|
+
if (flags.json) { say(JSON.stringify({ ok: true, id: r.id, file: r.file })); return 0; }
|
|
101
|
+
say(`✓ ${r.id} is out of the journal (${r.file}). Commit it to keep it.`);
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
91
105
|
const { entries, file } = J.entriesOf(root, { today });
|
|
92
106
|
|
|
93
107
|
if (sub === 'list') {
|
|
94
108
|
if (pos.length) return fail('pmos decisions list takes no argument', 2);
|
|
95
|
-
const shown = flags.all ? entries : entries.filter((e) => e.state === 'due' || e.state === 'open');
|
|
109
|
+
const shown = flags.all ? entries : entries.filter((e) => e.state === 'due' || e.state === 'open' || e.state === 'logged');
|
|
96
110
|
if (flags.json) { say(JSON.stringify({ ok: true, file, total: entries.length, decisions: shown.map(pub) })); return 0; }
|
|
97
111
|
if (!entries.length) { say('No decisions in this journal yet. Add one: pmos decisions add "<what was decided>" --expect "<what should happen>"'); return 0; }
|
|
98
|
-
const due = shown.filter((e) => e.state === 'due'), open = shown.filter((e) => e.state === 'open'), rest = shown.filter((e) => e.state === 'checked' || e.state === 'replaced');
|
|
99
|
-
|
|
112
|
+
const due = shown.filter((e) => e.state === 'due'), open = shown.filter((e) => e.state === 'open'), logged = shown.filter((e) => e.state === 'logged'), rest = shown.filter((e) => e.state === 'checked' || e.state === 'replaced');
|
|
113
|
+
const nLogged = entries.filter((e) => e.state === 'logged').length;
|
|
114
|
+
say(`${plural(entries.length, 'decision', 'decisions')} · ${due.length} due · ${open.length} open${nLogged ? ` · ${nLogged} logged` : ''} · ${entries.length - due.length - open.length - nLogged} closed`);
|
|
100
115
|
if (due.length) say(`\n${plural(due.length, 'check', 'checks')} due:\n` + due.map(line).join('\n'));
|
|
101
116
|
if (open.length) say('\nOpen:\n' + open.map(line).join('\n'));
|
|
117
|
+
if (logged.length) say('\nLogged from your presses:\n' + logged.map(line).join('\n') + '\n Undo one: pmos decisions undo <id>');
|
|
102
118
|
if (rest.length) say('\nClosed:\n' + rest.map(line).join('\n'));
|
|
103
119
|
if (due.length) say('\nRecord a verdict: pmos decisions check <id> worked|didnt-work|cant-tell --evidence "<what shows it>"');
|
|
104
120
|
return 0;
|
|
@@ -109,7 +125,7 @@ async function run(argv, { say = (s) => console.log(s), env = process.env, cwd =
|
|
|
109
125
|
const e = entries.find((x) => x.id === pos[0]);
|
|
110
126
|
if (!e) return fail(`no decision ${pos[0]} in this journal (pmos decisions list shows the ids)`);
|
|
111
127
|
if (flags.json) { say(JSON.stringify({ ok: true, decision: pub(e) })); return 0; }
|
|
112
|
-
say(`${e.id} (${short(e.date)})\n decided: ${e.decided}
|
|
128
|
+
say(`${e.id} (${short(e.date)})\n decided: ${e.decided}` + (e.expected ? `\n expected: ${e.expected}` : '') + (e.check ? `\n check: ${short(e.check)} · ${e.state}` : `\n ${FROM_WORDS[e.from] || e.state}`));
|
|
113
129
|
if (e.why) say(' why: ' + e.why);
|
|
114
130
|
if (e.against) say(' disagreed: ' + e.against);
|
|
115
131
|
if (e.initiative) say(' initiative: ' + e.initiative);
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
* Every other kind (evidence, sizing, assumption, stakeholders, follow-up, note) is kept as a decision only: the PM's choice to
|
|
26
26
|
* rely on it. A follow-up is never sent: the PM sends it from their own session. The driver never moves a stage by itself (D3).
|
|
27
27
|
* RETURN needs a note and DROP may carry one; each logs one correction (the north star counts it) and a return wakes a run.
|
|
28
|
+
* THE DECISION JOURNAL (decisions-from-approvals): the PM's Keep, and a Drop with a note, also write one line to the product's decision journal
|
|
29
|
+
* (lib/decision-journal.js logFrom, ref `driver:<proposal>`) when ctx.root names the product; Undo takes the line out.
|
|
28
30
|
*/
|
|
29
31
|
const fs = require('fs');
|
|
30
32
|
const path = require('path');
|
|
@@ -127,7 +129,21 @@ async function decide(verb, { file, proposal, note, actor, ctx = {}, now, auto =
|
|
|
127
129
|
} catch { /* the driver ledger already holds the correction */ }
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
|
-
|
|
132
|
+
const decision = journalOf(verb, p, text, actor, ctx, t, auto);
|
|
133
|
+
return { ok: true, proposal: D.fold(D.readLines(file)).proposals.get(p.id), wrote, warnings, ...(decision ? { decision } : {}) };
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* decisions-from-approvals (bet A475): the PM's Keep, and a Drop with a note, write one line to the product's decision journal
|
|
137
|
+
* (lib/decision-journal.js logFrom). An automatic keep and a Return write none. Never fails the decision. → the journal id or null */
|
|
138
|
+
function journalOf(verb, p, note, actor, ctx, now, auto) {
|
|
139
|
+
if (auto || !ctx.root || !actorLib.isPm(actor) || !(verb === 'keep' || (verb === 'drop' && note))) return null;
|
|
140
|
+
const DJ = require('./decision-journal.js');
|
|
141
|
+
const what = String(p.what || 'proposal').replace(/-/g, ' '), why = String(p.why || '').trim();
|
|
142
|
+
const ini = p.target && p.target.kind === 'initiative' ? p.target.id : '';
|
|
143
|
+
const r = DJ.logFrom(ctx.root, verb === 'keep'
|
|
144
|
+
? { from: 'approval', decided: `Kept the ${what} proposal${ini ? ' on ' + ini : ''}${why ? ': ' + why : ''}`, ref: `driver:${p.id}`, initiative: ini, why }
|
|
145
|
+
: { from: 'drop', decided: `Dropped the ${what} proposal${ini ? ' on ' + ini : ''}`, ref: `driver:${p.id}`, initiative: ini, why: note }, { now, by: actor.by, via: actor.via });
|
|
146
|
+
return r.ok ? r.id : null;
|
|
131
147
|
}
|
|
132
148
|
|
|
133
149
|
const jobOf = (p) => `driver:${p.what}`;
|
|
@@ -202,6 +218,7 @@ async function undo({ file, proposal, actor, ctx = {}, now, stateDir, product =
|
|
|
202
218
|
record: { kind: 'correction', run: p.run, reason: 'driver:undo', by: actorLib.isPm(actor) ? 'pm' : actor.by } }) + '\n');
|
|
203
219
|
} catch { /* the driver ledger already holds the correction */ }
|
|
204
220
|
}
|
|
221
|
+
if (ctx.root) require('./decision-journal.js').undo(ctx.root, { ref: `driver:${p.id}` }, { now: t, by: actor.by, via: actor.via }); // its journal line goes too (none for an automatic keep)
|
|
205
222
|
const s = p.auto && stateDir ? require('./autonomy.js').recordSetback(stateDir, { job: jobOf(p), product, ref: p.id, kind: 'undo' }, { now: t }) : { demoted: null };
|
|
206
223
|
return { ok: true, back, demoted: s.demoted || null };
|
|
207
224
|
}
|
|
@@ -170,8 +170,11 @@ function hold(root, { id, why, back, after } = {}, { now = Date.now(), by, via }
|
|
|
170
170
|
if (after === id) return { ok: false, error: 'an initiative cannot wait on itself' };
|
|
171
171
|
if (!ids.has(after)) return { ok: false, error: `no initiative ${after} here to wait on` };
|
|
172
172
|
}
|
|
173
|
-
|
|
173
|
+
const r = append(root, L, { initiative_id: id, state: 'on-hold', reason, ...(back ? { back: String(back) } : {}), ...(after ? { after } : {}),
|
|
174
174
|
pm: pmSlug(), by: by || 'agent:unknown', via: via || 'cli', at: new Date(now).toISOString() });
|
|
175
|
+
// decisions-from-approvals: a hold with a reason is one line in the decision journal (lib/decision-journal.js onLifecycle)
|
|
176
|
+
if (r && r.ok && r.line) { try { const d = require('./decision-journal.js').onLifecycle(root, r.line, { now }); if (d && d.ok) r.decision = d.id; } catch { /* the hold stands */ } }
|
|
177
|
+
return r;
|
|
175
178
|
}
|
|
176
179
|
|
|
177
180
|
/** Bring a parked initiative back. One `active` line marked as brought back through its way back. */
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* GET /api/proposals?ws&board&initiative[&grill=all] → { ok, props, found } props: lib/proposals.js viewOf (null: nothing to show); grill=all unfolds every grill finding
|
|
8
8
|
* POST /api/proposals/keep { ws, board, initiative, ids?: [id] | all: true, choices?: { <from>><to>: 'keep' | 'ignore' } }
|
|
9
9
|
* → { ok, batch, said, counts, props } ✓ one proposal, or ✓ in the header (all: every one Claude is sure of;
|
|
10
|
-
* Check these and a Jira ticket's comment never ride on it). One batch, one toast, one Undo.
|
|
10
|
+
* Check these and a Jira ticket's comment never ride on it). One batch, one toast, one Undo. The PM's ✓ also
|
|
11
|
+
* writes one line to the product's decision journal (`decision`: its id; `card` when choices were picked); Undo takes it out
|
|
11
12
|
* POST /api/proposals/drop { ws, board, initiative, sig, why? } → { ok } why: the PM's reason (the idle lab asks for one); ✕ on a proposal or on one item of it, for good (rule 7); the line
|
|
12
13
|
* also keeps its facts (PR.factsOf), so a re-sectioned task or a new day does not bring it back
|
|
13
14
|
* POST /api/proposals/undo { ws, board, batch } → { ok, back, kept } the whole batch; a task changed since keeps its change
|
|
@@ -27,6 +28,16 @@ const PR = require('./proposals.js');
|
|
|
27
28
|
const TL = require('./task-links.js');
|
|
28
29
|
const RB = require('./routes-boards.js');
|
|
29
30
|
const TLR = require('./routes-task-links.js');
|
|
31
|
+
const DJ = require('./decision-journal.js');
|
|
32
|
+
|
|
33
|
+
/** decisions-from-approvals (bet A475): what the PM's ✓ decided, in one line for the decision journal. PURE.
|
|
34
|
+
* want: the kept proposals; picked: the PM chose among a card's answers (body.choices). → { from, decided, why } */
|
|
35
|
+
function keepText(want, ini, picked) {
|
|
36
|
+
const names = (want || []).map((x) => String((x && (x.title || x.why || x.type || x.group)) || '').replace(/\s+/g, ' ').trim()).filter(Boolean);
|
|
37
|
+
const head = names.slice(0, 3).join('; ') + (names.length > 3 ? ` and ${names.length - 3} more` : '');
|
|
38
|
+
const why = (want || []).map((x) => String((x && x.why) || '').trim()).filter(Boolean)[0] || '';
|
|
39
|
+
return { from: picked ? 'card' : 'approval', decided: `${picked ? 'Picked' : 'Approved'} on ${ini}: ${head || plural((want || []).length, 'proposal', 'proposals')}`, why: why.slice(0, 300) };
|
|
40
|
+
}
|
|
30
41
|
|
|
31
42
|
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
32
43
|
const fail = (ctx, res, status, error, extra = {}) => { ctx.json(res, { ok: false, error, ...extra }, status); return true; };
|
|
@@ -138,6 +149,7 @@ function undoCore(ctx, p, g, id) {
|
|
|
138
149
|
if (r && r.body && r.body.ok) back++; else kept++;
|
|
139
150
|
}
|
|
140
151
|
PR.append(dir, g.actor, { kind: 'undo', batch: id });
|
|
152
|
+
try { DJ.undo(p.w.root, { ref: 'proposals:' + id }, { by: g.actor && g.actor.by, via: g.actor && g.actor.via }); } catch { /* a batch PMOS kept by itself has no journal line */ }
|
|
141
153
|
// D106: the Undo of a change an agent applied by itself is a setback of its job (lib/autonomy.js), which may demote the job
|
|
142
154
|
const line = PR.readLines(PR.ledgerFile(dir)).find((l) => l.kind === 'keep' && l.batch === id);
|
|
143
155
|
let demoted = null;
|
|
@@ -528,9 +540,13 @@ const WRITES = {
|
|
|
528
540
|
const { batch, wrote, plans, failed } = keepCore(ctx, p, g, f, ini, want, isObj(body.choices) ? body.choices : {});
|
|
529
541
|
// a draft pull request that could not open (W7): nothing was written, the proposal stays open, and the page says why
|
|
530
542
|
if (failed.length && !wrote.length) return fail(ctx, res, 409, failed[0].why);
|
|
543
|
+
// the PM's ✓ is a decision: one line in the product's decision journal, undone with this batch (decisions-from-approvals)
|
|
544
|
+
const picked = isObj(body.choices) && Object.keys(body.choices).length > 0;
|
|
545
|
+
const kt = keepText(want, ini, picked);
|
|
546
|
+
const dj = DJ.logFrom(p.w.root, { ...kt, ref: 'proposals:' + batch, initiative: ini }, { by: g.actor && g.actor.by, via: g.actor && g.actor.via });
|
|
531
547
|
const v2 = view(ctx, p, ini);
|
|
532
548
|
const left = v2 ? v2.groups.flatMap((x) => x.props).filter((x) => x.section === 'check').length : 0;
|
|
533
|
-
ctx.json(res, { ok: true, batch, said: saidOf(wrote, plans, body.all === true ? left : 0), counts: { wrote: wrote.length }, props: v2, found: PR.foundOf(PR.read(dir), ini) });
|
|
549
|
+
ctx.json(res, { ok: true, batch, ...(dj.ok ? { decision: dj.id } : {}), said: saidOf(wrote, plans, body.all === true ? left : 0), counts: { wrote: wrote.length }, props: v2, found: PR.foundOf(PR.read(dir), ini) });
|
|
534
550
|
},
|
|
535
551
|
'/api/proposals/drop': (ctx, res, body, g, p) => {
|
|
536
552
|
const sig = String(body.sig || ''), ini = String(body.initiative || '');
|
|
@@ -557,8 +573,11 @@ const WRITES = {
|
|
|
557
573
|
try { const AF = require('./artefacts.js'); AF.set(AF.file(dirOf(ctx, p.w)), { scope: 'experiment:' + ini, artefact: 'lessons', field: 'line', text: `✕ dropped "${String(of.title || '').slice(0, 140)}"${why ? ': ' + why : ''}`, sources: [{ label: 'live round' }] }, { by: g.actor && /^(pm|agent):/.test(String(g.actor.by)) ? g.actor.by : 'agent:live-round' }); } catch { /* the drop line holds it */ }
|
|
558
574
|
}
|
|
559
575
|
// the reason becomes curated memory by itself, so every later run knows it (lib/corrections-memory.js)
|
|
576
|
+
// a ✕ with a reason is a decision too (decisions-from-approvals): one line in the product's decision journal
|
|
577
|
+
let decision = null;
|
|
578
|
+
if (why) { const r = DJ.logFrom(p.w.root, { from: 'drop', decided: `Dropped on ${ini}: ${String((of && (of.title || of.why)) || 'a proposal').slice(0, 200)}`, ref: `proposals-drop:${ini}:${sig}`, initiative: ini, why }, { by: g.actor && g.actor.by, via: g.actor && g.actor.via }); if (r.ok) decision = r.id; }
|
|
560
579
|
if (why) require('./corrections-memory.js').remember(p.w.root, { what: `a ${(of && (of.group || of.type)) || ''} proposal on ${ini}`.replace(/ +/g, ' '), why, source: 'proposal:' + (which.id || sig), ini });
|
|
561
|
-
ctx.json(res, { ok: true });
|
|
580
|
+
ctx.json(res, { ok: true, ...(decision ? { decision } : {}) });
|
|
562
581
|
},
|
|
563
582
|
'/api/proposals/undo': (ctx, res, body, g, p) => {
|
|
564
583
|
const r = undoCore(ctx, p, g, String(body.batch || ''));
|
|
@@ -586,7 +605,7 @@ const WRITES = {
|
|
|
586
605
|
|
|
587
606
|
module.exports = {
|
|
588
607
|
prefixes: ['/api/proposals'],
|
|
589
|
-
viewFor, saidOf, prdRename, keepCore, undoCore, autoKeep, heldOf, keepDefault,
|
|
608
|
+
viewFor, saidOf, prdRename, keepCore, undoCore, autoKeep, heldOf, keepDefault, keepText,
|
|
590
609
|
handle: async (req, res, url, ctx) => {
|
|
591
610
|
const p0 = url.pathname;
|
|
592
611
|
if (req.method === 'GET') {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.743.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.743.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/* pm/library-keys.js — what a key and a press do on the Library page (initiative library-place, D1 and D6; A437).
|
|
2
|
+
* The page (premium-library.js) binds these to the real window and list; library-place.test.js presses the same keys on a stand-in
|
|
3
|
+
* EventTarget in node, so the tests run the handlers themselves and not a search over the source.
|
|
4
|
+
*
|
|
5
|
+
* bindSlash(target, { focus, popupOpen }) "/" anywhere but a text field, with no modifier and no popup open, puts the cursor in the search (D1)
|
|
6
|
+
* pressStep(x, { wide, pick }) a press on a row: on a desk (≥ 1200 px) the first press shows its Detail block → 'show',
|
|
7
|
+
* the second press opens it as the full popup → 'open'; a link, or a narrow screen, opens at once (D6)
|
|
8
|
+
* bindEnterOpen(target, { open }) Enter on a row's name opens the item, on any screen (D6)
|
|
9
|
+
*/
|
|
10
|
+
const TEXT = /^(INPUT|TEXTAREA|SELECT)$/;
|
|
11
|
+
|
|
12
|
+
export function slashFocuses(e, { popupOpen = false } = {}) {
|
|
13
|
+
if (!e || e.key !== '/' || e.metaKey || e.ctrlKey || e.altKey) return false;
|
|
14
|
+
const t = e.target;
|
|
15
|
+
if (t && (t.isContentEditable || TEXT.test(t.tagName || ''))) return false;
|
|
16
|
+
return !popupOpen;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function bindSlash(target, { focus, popupOpen = () => false }) {
|
|
20
|
+
const on = (e) => { if (!slashFocuses(e, { popupOpen: popupOpen() })) return; e.preventDefault(); focus(); };
|
|
21
|
+
target.addEventListener('keydown', on);
|
|
22
|
+
return on;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function pressStep(x, { wide = false, pick = null } = {}) {
|
|
26
|
+
if (!x) return null;
|
|
27
|
+
return wide && pick !== x.id && !(x.open && x.open.url) ? 'show' : 'open';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// the row element of an event target that is a row's name (data-lb-open), or null
|
|
31
|
+
export function nameRow(e) {
|
|
32
|
+
const t = e && e.target;
|
|
33
|
+
if (!e || e.key !== 'Enter' || !t || typeof t.matches !== 'function' || !t.matches('[data-lb-open]')) return null;
|
|
34
|
+
return (typeof t.closest === 'function' && t.closest('[data-lb-i]')) || null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function bindEnterOpen(target, { open }) {
|
|
38
|
+
const on = (e) => { const row = nameRow(e); if (!row) return false; e.preventDefault(); open(row); return true; };
|
|
39
|
+
target.addEventListener('keydown', on);
|
|
40
|
+
return on;
|
|
41
|
+
}
|
|
@@ -27,6 +27,7 @@ import * as SC from './scope-chip.js';
|
|
|
27
27
|
const { scopeChipHtml, openScope, matches: scopeMatches, narrowed, scopeWords, whenNames } = SC;
|
|
28
28
|
import { FAMILIES, GROUPS, STATES, view, counts, passes, matches, aboutText, stateText, dayText, when, noteOf, hiddenText } from './library-model.js';
|
|
29
29
|
import { openItem } from './library-open.js';
|
|
30
|
+
import { bindSlash, bindEnterOpen, pressStep } from './library-keys.js'; // D1 and D6: the keys and presses, tested by pressing them (A437)
|
|
30
31
|
import { STEP, nextShown, moreHtml, totalOf, logMore } from './list-cap.js'; // lists stay short (A455): one step for every long list
|
|
31
32
|
|
|
32
33
|
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
@@ -405,7 +406,7 @@ $('lbMore').onclick = () => openMenu('lbMore', moreMenu, morePress, 'pm-menu lb-
|
|
|
405
406
|
addEventListener('pp:changed', (e) => { if (e.detail && e.detail.products) { S.P = e.detail; draw(); } });
|
|
406
407
|
function press(x) {
|
|
407
408
|
if (!x) return;
|
|
408
|
-
if (wide()
|
|
409
|
+
if (pressStep(x, { wide: wide(), pick: S.pick }) === 'show') { S.pick = x.id; draw(); return; }
|
|
409
410
|
openItem(x, { from: 'Library' });
|
|
410
411
|
}
|
|
411
412
|
async function saveName(id, name) {
|
|
@@ -448,12 +449,9 @@ body.onkeydown = (e) => {
|
|
|
448
449
|
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); S.naming = null; draw(); }
|
|
449
450
|
return;
|
|
450
451
|
}
|
|
451
|
-
// Enter on a name opens the item, on any screen
|
|
452
|
-
if (e.key === 'Enter' && e.target.matches('[data-lb-open]')) {
|
|
453
|
-
e.preventDefault();
|
|
454
|
-
const row = e.target.closest('[data-lb-i]'); const x = row && S.shown[Number(row.dataset.lbI)]; if (x) openItem(x, { from: 'Library' });
|
|
455
|
-
}
|
|
456
452
|
};
|
|
453
|
+
// Enter on a name opens the item, on any screen
|
|
454
|
+
bindEnterOpen(body, { open: (row) => { const x = S.shown[Number(row.dataset.lbI)]; if (x) openItem(x, { from: 'Library' }); } });
|
|
457
455
|
pv.onclick = (e) => {
|
|
458
456
|
const x = S.pick && (S.items || []).find((i) => i.id === S.pick);
|
|
459
457
|
let b;
|
|
@@ -463,12 +461,7 @@ pv.onclick = (e) => {
|
|
|
463
461
|
};
|
|
464
462
|
qBox.addEventListener('input', () => { S.q = qBox.value.trim(); draw(); findByMeaning(); });
|
|
465
463
|
qBox.addEventListener('keydown', (e) => { if (e.key === 'Escape' && qBox.value) { e.stopPropagation(); qBox.value = ''; S.q = ''; S.meaning = null; draw(); } });
|
|
466
|
-
|
|
467
|
-
if (e.key !== '/' || e.metaKey || e.ctrlKey || e.altKey) return;
|
|
468
|
-
const t = e.target; if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName))) return;
|
|
469
|
-
if (document.body.classList.contains('cz-pop-on')) return;
|
|
470
|
-
e.preventDefault(); qBox.focus();
|
|
471
|
-
});
|
|
464
|
+
bindSlash(window, { focus: () => qBox.focus(), popupOpen: () => document.body.classList.contains('cz-pop-on') });
|
|
472
465
|
addEventListener('resize', () => { if (S.pick) drawPreview(); });
|
|
473
466
|
// the +: Ask PMOS, with the words ready to finish; PMOS adds the file, the link or the new document, fills its record and shows it to confirm
|
|
474
467
|
$('lbAdd').onclick = async () => {
|
package/workspace/server.js
CHANGED
|
@@ -10731,6 +10731,8 @@ async function handleRequest(req, res) {
|
|
|
10731
10731
|
: 'could not record the change — nothing was saved', sink, ...(wrote ? { grant, unsaved: rest } : {}) }, 500);
|
|
10732
10732
|
}
|
|
10733
10733
|
boardCache.invalidate(w.root);
|
|
10734
|
+
// decisions-from-approvals: a hold with a reason is one line in the product's decision journal; the hold's Undo takes it out
|
|
10735
|
+
try { for (const r of recs) require('./lib/decision-journal.js').onLifecycle(w.root, r); } catch { /* the lifecycle line holds the hold */ }
|
|
10734
10736
|
return json(res, bulk ? { ok: true, recorded: recs, grant, sink } : { ok: true, recorded: rec, sink });
|
|
10735
10737
|
}
|
|
10736
10738
|
if (p === '/api/doc/save' && req.method === 'POST') {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "decisions-from-approvals (bet A475): the PM approvals, card picks, drops and parks write the decision journal by themselves, with Undo (lib/decision-journal.js logFrom, undo, onLifecycle).",
|
|
3
|
+
"modules": ["decisions-from-approvals.test.js"],
|
|
4
|
+
"seconds": { "decisions-from-approvals.test.js": 2 }
|
|
5
|
+
}
|