create-pmos 0.716.0 → 0.718.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 +39 -33
- 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 +38 -0
- package/workspace/guide/cli.md +14 -0
- package/workspace/guide/layout.md +4 -0
- package/workspace/guide/reports.md +2 -2
- package/workspace/lib/item-why.js +235 -0
- package/workspace/lib/needs-providers.js +1 -0
- package/workspace/lib/pmos-verbs.js +5 -0
- package/workspace/lib/product-health-cli.js +13 -0
- package/workspace/lib/product-health.js +259 -0
- package/workspace/lib/routes-search.js +4 -2
- package/workspace/lib/search-answer.js +164 -0
- package/workspace/lib/why-cli.js +79 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-search.js +18 -2
- package/workspace/public/pm/premium-chart-draw.js +37 -13
- package/workspace/test-lists/chart-headline-point.json +9 -0
- package/workspace/test-lists/item-why.json +9 -0
- package/workspace/test-lists/product-health.json +9 -0
- package/workspace/test-lists/search-answers-first.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.718.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,44 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.718.0",
|
|
38
|
+
"at": "2026-11-22T23:44:48.503Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1589,
|
|
43
|
+
"t": "Search answers first, with its source",
|
|
44
|
+
"s": "Search answers first, with its source",
|
|
45
|
+
"k": "new"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"n": 1592,
|
|
49
|
+
"t": "Pmos why, the three-line why of any initiative or task",
|
|
50
|
+
"s": "Pmos why, the three-line why of any initiative or task",
|
|
51
|
+
"k": "new"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"n": 1590,
|
|
55
|
+
"t": "One health score per product, shown only when it drops",
|
|
56
|
+
"s": "One health score per product, shown only when it drops",
|
|
57
|
+
"k": "new"
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"v": "0.717.0",
|
|
63
|
+
"at": "2026-11-22T21:55:40.797Z",
|
|
64
|
+
"f": 4,
|
|
65
|
+
"prs": [
|
|
66
|
+
{
|
|
67
|
+
"n": 1588,
|
|
68
|
+
"t": "Every chart says its point and lights the one reading it names (job #1587)",
|
|
69
|
+
"s": "Every chart says its point and lights the one reading it names (job #1587)",
|
|
70
|
+
"k": "new"
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
36
74
|
{
|
|
37
75
|
"v": "0.716.0",
|
|
38
76
|
"at": "2026-11-22T20:55:20.302Z",
|
|
@@ -446,38 +484,6 @@
|
|
|
446
484
|
"k": "new"
|
|
447
485
|
}
|
|
448
486
|
]
|
|
449
|
-
},
|
|
450
|
-
{
|
|
451
|
-
"v": "0.682.0",
|
|
452
|
-
"at": "2026-11-22T07:57:47.146Z",
|
|
453
|
-
"f": 4,
|
|
454
|
-
"prs": [
|
|
455
|
-
{
|
|
456
|
-
"n": 1487,
|
|
457
|
-
"t": "Design drift guard counts token bypasses, with a ratchet",
|
|
458
|
-
"s": "Design drift guard counts token bypasses, with a ratchet",
|
|
459
|
-
"k": "new"
|
|
460
|
-
},
|
|
461
|
-
{
|
|
462
|
-
"n": 1478,
|
|
463
|
-
"t": "Work breakdown keeps done tasks in date order and folds a finished stage",
|
|
464
|
-
"s": "Work breakdown keeps done tasks in date order and folds a finished stage",
|
|
465
|
-
"k": "new"
|
|
466
|
-
}
|
|
467
|
-
]
|
|
468
|
-
},
|
|
469
|
-
{
|
|
470
|
-
"v": "0.679.0",
|
|
471
|
-
"at": "2026-11-22T06:54:44.843Z",
|
|
472
|
-
"f": 4,
|
|
473
|
-
"prs": [
|
|
474
|
-
{
|
|
475
|
-
"n": 1475,
|
|
476
|
-
"t": "Next milestones labels never overlap, and the strip scrolls apart from the table",
|
|
477
|
-
"s": "/mnt/project-files/milestones-strip/after-1440.png, all 9 milestones from 20 Nov 2026 to 15 Nov 2027 on one width, 0 overlaps (measured from the labels' bounding boxes), no horizontal scroll.",
|
|
478
|
-
"k": "fix"
|
|
479
|
-
}
|
|
480
|
-
]
|
|
481
487
|
}
|
|
482
488
|
]
|
|
483
489
|
}
|
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-22T23:44:43Z"}
|
|
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-22T23:44:43Z"}
|
|
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-22T23:44:43Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.718.0",
|
|
4
|
+
"at": "2026-11-22T23:44:48.503Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1589,
|
|
9
|
+
"t": "Search answers first, with its source",
|
|
10
|
+
"s": "Search answers first, with its source",
|
|
11
|
+
"k": "new"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"n": 1592,
|
|
15
|
+
"t": "Pmos why, the three-line why of any initiative or task",
|
|
16
|
+
"s": "Pmos why, the three-line why of any initiative or task",
|
|
17
|
+
"k": "new"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"n": 1590,
|
|
21
|
+
"t": "One health score per product, shown only when it drops",
|
|
22
|
+
"s": "One health score per product, shown only when it drops",
|
|
23
|
+
"k": "new"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"v": "0.717.0",
|
|
29
|
+
"at": "2026-11-22T21:55:40.797Z",
|
|
30
|
+
"f": 4,
|
|
31
|
+
"prs": [
|
|
32
|
+
{
|
|
33
|
+
"n": 1588,
|
|
34
|
+
"t": "Every chart says its point and lights the one reading it names (job #1587)",
|
|
35
|
+
"s": "Every chart says its point and lights the one reading it names (job #1587)",
|
|
36
|
+
"k": "new"
|
|
37
|
+
}
|
|
38
|
+
]
|
|
39
|
+
},
|
|
2
40
|
{
|
|
3
41
|
"v": "0.716.0",
|
|
4
42
|
"at": "2026-11-22T20:55:20.302Z",
|
package/workspace/guide/cli.md
CHANGED
|
@@ -212,6 +212,12 @@ Before you share a spec, a strategy, a roadmap or a report, PMOS reads it as a s
|
|
|
212
212
|
- `pmos factory today --unsourced` prints one number on its last line: the percent of changes PMOS applied by itself that cite no source.
|
|
213
213
|
- A change that cites no source never applies by itself. It waits for you, as a change others see does.
|
|
214
214
|
|
|
215
|
+
### pmos health: one health score for this product
|
|
216
|
+
|
|
217
|
+
- `pmos health score` shows this product's health score from 0 to 100 and its three parts: checks (the passing share of the latest runs of your product's own checks), pull requests stuck on failing checks, and setbacks this week (reverts, fixes after a merge, failed checks, missed outcomes). The score is on the last line. When nothing is recorded yet, it says so and prints -1.
|
|
218
|
+
- `pmos health trend` shows the score of each day this month. `pmos health drops` shows each past drop and how many days it took to recover.
|
|
219
|
+
- Today shows a card only when the score falls 10 points or more below the best of the past week. While the score holds, there is no card.
|
|
220
|
+
|
|
215
221
|
### pmos autonomy: what agents applied by themselves
|
|
216
222
|
|
|
217
223
|
- `pmos autonomy status` lists what agents applied in the last 14 days (D106), each with its id, and the jobs that went back to propose.
|
|
@@ -272,6 +278,14 @@ The idle lab run uses only the first three commands:
|
|
|
272
278
|
- `pmos lab critic checks [--root <dir>]`: the checks the critic uses for the product in that folder. No server is needed.
|
|
273
279
|
- `pmos lab critic label <run> <n> real|noise`: your word on finding `n` of a critic run. `pmos lab critic stats` counts the runs, the findings, and how many you called real or noise.
|
|
274
280
|
|
|
281
|
+
### pmos why: why the work exists, in three lines
|
|
282
|
+
|
|
283
|
+
Anyone can run it, not only the PM: an engineer or a stakeholder who wants to know why an initiative or a task exists. Run it in the product's repository, or pass `--root <dir>`. It reads the records on disk, needs no running workspace and changes nothing.
|
|
284
|
+
|
|
285
|
+
- `pmos why <initiative or task>` prints the goal, the problem and the evidence, one line each. A task id (`<initiative>.<10 characters>`) shows the why of its initiative. `pmos why show <id>` does the same. Add `--from` to see the file and section each line came from.
|
|
286
|
+
- Each line comes from the initiative's own record or its PRD: the goal from Goal, the problem from Intent or the PRD's Problem, the evidence from an Evidence section or the first problem sentence that names a number or a link. A line the records do not hold says "not written". PMOS does not guess it.
|
|
287
|
+
- `pmos why coverage` says how many active initiatives have all three lines and which lines the others miss. Its last line is the percent, so a script can read it.
|
|
288
|
+
|
|
275
289
|
### pmos outcomes: expected outcomes
|
|
276
290
|
|
|
277
291
|
Run them in the product's repository, or pass `--root <dir>`.
|
|
@@ -263,6 +263,10 @@ Reports are routine jobs, so they live in Routine.
|
|
|
263
263
|
|
|
264
264
|
The Board shows initiatives by stage, with programs, a timeline and a list. Intelligence shows the goals from each product's OKR file. A panel on either page (an initiative, a program, a goal, the chat) can dock on the left or the right: drag its header to that half of the window, or press **Arrange** in its header. Each kind of panel stays on its side after a reload. [Programs on the Board](programs.md) and [Intelligence reads your OKR file](intelligence-okr-goals.md) explain them.
|
|
265
265
|
|
|
266
|
+
## Search answers first
|
|
267
|
+
|
|
268
|
+
When the words you type in Search point clearly to one thing, the first row is the answer: one sentence from your own files, then where it came from. Type an initiative's name and the answer is its goal, with its check date. Ask "when is the pilot launch" and the answer is the sentence in your plan that holds the date. Press Enter on the answer to open its source. PMOS copies the sentence as it is written and does not write it. When no one sentence holds all your words, or two initiatives match equally, there is no answer row, and the matches show as before.
|
|
269
|
+
|
|
266
270
|
## Keys
|
|
267
271
|
|
|
268
272
|
| Key | What it does |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "Reports and dashboards: set up, shape, design, draft and issue"
|
|
4
4
|
description: "Set up a report by asking, shape what it says, design how it looks, draft and issue a cadence report, and the ready-made dashboards."
|
|
5
|
-
timestamp: 2026-11-
|
|
5
|
+
timestamp: 2026-11-22
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Reports and dashboards
|
|
@@ -386,7 +386,7 @@ An order is a default order of slides, for example the Weekly Review order. The
|
|
|
386
386
|
|
|
387
387
|
The library also has seven report templates: weekly-review, program-kickoff, meeting-recap, portfolio-snapshot, quarterly-review, decision-brief and incident-review. A template is a default order of slides, not a fixed structure. `pmos report library --template <id>` draws one template with placeholder words, and `pmos report make <id> --template <id>` starts a report from it. The writer uses its order and adds or drops slides when the findings say so. A recurring report keeps the outline its readers agreed, so the template is used only for a report that has none.
|
|
388
388
|
|
|
389
|
-
A slide can also hold a PMOS component instead of a layout: today, the KR metric tile of the Insights page, as a line, bars, a meter or a number. PMOS draws it from the KR metric record when the report is written and keeps a dated snapshot with the report, so an old issue shows the figures of its day. The slide says when the snapshot was taken, and the PowerPoint file draws the same tile.
|
|
389
|
+
A slide can also hold a PMOS component instead of a layout: today, the KR metric tile of the Insights page, as a line, bars, a meter or a number. PMOS draws it from the KR metric record when the report is written and keeps a dated snapshot with the report, so an old issue shows the figures of its day. The slide says when the snapshot was taken, and the PowerPoint file draws the same tile. Above the tile, one line answers it, for example "Signups is 14, 6 short of the target of 20." or, with no target, "Signups is 12, down 4 from its high of 16 on 2 Nov." The line and the bars mark only the reading that line names.
|
|
390
390
|
|
|
391
391
|
### The window
|
|
392
392
|
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* item-why.js — "Why are we building this?" in three lines, for anyone (initiative three-line-why, bet A86).
|
|
3
|
+
*
|
|
4
|
+
* whyOf({ id, front, body, prd, recordPath, prdPath }) → { id, title, goal, problem, evidence, complete }
|
|
5
|
+
* each line is { text, from } | null. `from` names the file and the section the line was read from.
|
|
6
|
+
* frontOf(text) · sectionsOf(text) the record's frontmatter as { key: value }; its `## ` sections as Map title → text
|
|
7
|
+
* initiativeIdOf(ref) → id a task id `<initiative>.<10 characters>` reads as its initiative
|
|
8
|
+
* recordPathOf(root, id) → path | null planning/initiatives/<id>.md, else pmos/state/initiatives/<id>.md (kit layout)
|
|
9
|
+
* readWhy(root, ref) → why | null reads the record and the PRD it names, from disk
|
|
10
|
+
* activeIds(root) → [id] every record that is not closed, cancelled or accepted (lifecycle.jsonl, acceptances.jsonl)
|
|
11
|
+
* coverage(root) → { active, complete, percent, missing: [{ id, lines: ['goal'|'problem'|'evidence'] }] }
|
|
12
|
+
*
|
|
13
|
+
* THE LINES, in the order each is tried. A line the records do not hold is null: nothing is made up from the title.
|
|
14
|
+
* goal : the record's Goal · the PRD's Goal or Goals · `outcome_metric`
|
|
15
|
+
* problem : the record's Intent · the PRD's Problem · a "Why it exists", "Why this exists" or "The defect" section
|
|
16
|
+
* evidence : an Evidence, "Why it exists", "Why this exists" or "The finding" section of the record, else of the PRD · else the first
|
|
17
|
+
* sentence of the problem's own text that holds a number or a link (the record names what it saw)
|
|
18
|
+
* Each line is the first one or two sentences, markdown taken off, at most MAX characters, one line.
|
|
19
|
+
*
|
|
20
|
+
* Reads only. No server, no network, no writes. Works on PMOS-self and on any product in kit layout.
|
|
21
|
+
*/
|
|
22
|
+
const fs = require('fs');
|
|
23
|
+
const path = require('path');
|
|
24
|
+
|
|
25
|
+
const MAX = 200;
|
|
26
|
+
const LAYOUTS = [['planning', 'initiatives'], ['pmos', 'state', 'initiatives']];
|
|
27
|
+
const LEDGER_DIRS = [['planning', 'runs'], ['pmos', 'state']];
|
|
28
|
+
const TASK_ID = /^([A-Za-z0-9][A-Za-z0-9._-]*)\.[A-Za-z0-9_-]{10}$/;
|
|
29
|
+
const ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/;
|
|
30
|
+
const STOPPED = new Set(['closed', 'cancelled', 'canceled', 'killed']);
|
|
31
|
+
|
|
32
|
+
const unquote = (v) => {
|
|
33
|
+
const t = String(v == null ? '' : v).trim();
|
|
34
|
+
if (/^".*"$/.test(t)) return t.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
|
35
|
+
if (/^'.*'$/.test(t)) return t.slice(1, -1).replace(/''/g, "'");
|
|
36
|
+
return t;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/** The leading frontmatter as { key: value } (one line per key; quotes taken off). */
|
|
40
|
+
function frontOf(text) {
|
|
41
|
+
const L = String(text || '').split('\n'); const out = {};
|
|
42
|
+
if (!/^---\s*$/.test(L[0] || '')) return out;
|
|
43
|
+
for (let i = 1; i < L.length && !/^---\s*$/.test(L[i]); i++) {
|
|
44
|
+
const m = L[i].match(/^([A-Za-z_][\w-]*):\s*(.*)$/); if (m) out[m[1]] = unquote(m[2]);
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** The body after the frontmatter. */
|
|
50
|
+
function bodyOf(text) {
|
|
51
|
+
const s = String(text || '');
|
|
52
|
+
const m = s.match(/^---\s*\n[\s\S]*?\n---\s*(\n|$)/);
|
|
53
|
+
return m ? s.slice(m[0].length) : s;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Every `## ` section as Map lower-case title (numbering such as "2." taken off) → its text. The first of a title wins. */
|
|
57
|
+
function sectionsOf(text) {
|
|
58
|
+
const out = new Map(); let title = null; let buf = [];
|
|
59
|
+
const flush = () => { if (title !== null && !out.has(title)) out.set(title, buf.join('\n').trim()); };
|
|
60
|
+
for (const line of bodyOf(text).split('\n')) {
|
|
61
|
+
const m = line.match(/^##\s+(.+?)\s*$/);
|
|
62
|
+
if (m && !/^###/.test(line)) { flush(); title = m[1].replace(/^[\d.]+\s*/, '').trim().toLowerCase(); buf = []; }
|
|
63
|
+
else if (title !== null) buf.push(line);
|
|
64
|
+
}
|
|
65
|
+
flush();
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Markdown taken off: links keep their text, bold, italics, code marks, list bullets, quotes and table pipes go. */
|
|
70
|
+
function plain(s) {
|
|
71
|
+
return String(s || '')
|
|
72
|
+
.replace(/<!--[\s\S]*?-->/g, ' ')
|
|
73
|
+
.replace(/!\[[^\]]*\]\([^)]*\)/g, ' ')
|
|
74
|
+
.replace(/\[([^\]]+)\]\([^)]*\)/g, '$1')
|
|
75
|
+
.replace(/`+([^`]*)`+/g, '$1')
|
|
76
|
+
.replace(/(\*\*|__)(.+?)\1/g, '$2')
|
|
77
|
+
.replace(/(^|[\s(])[*_]([^*_\s][^*_]*?)[*_](?=[\s).,;:!?]|$)/g, '$1$2')
|
|
78
|
+
.replace(/^\s{0,3}(?:[-*+]|\d+\.)\s+/gm, '')
|
|
79
|
+
.replace(/^\s*>\s?/gm, '')
|
|
80
|
+
.replace(/^\s*\|.*\|\s*$/gm, ' ')
|
|
81
|
+
.replace(/^#+\s+/gm, '')
|
|
82
|
+
.replace(/\s+/g, ' ')
|
|
83
|
+
.trim();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** The sentences of a text (a period, question or exclamation mark followed by a space and a capital, digit or quote). */
|
|
87
|
+
function sentences(s) {
|
|
88
|
+
return String(s || '').split(/(?<=[.!?])\s+(?=[A-Z0-9"'(“])/).map((x) => x.trim()).filter(Boolean);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** One line of at most MAX characters: the first sentence, and the second when both fit; cut on a word with an ellipsis. */
|
|
92
|
+
function clip(text) {
|
|
93
|
+
const all = sentences(plain(text));
|
|
94
|
+
if (!all.length) return '';
|
|
95
|
+
let out = all[0];
|
|
96
|
+
if (all[1] && out.length + 1 + all[1].length <= MAX) out = `${out} ${all[1]}`;
|
|
97
|
+
if (out.length > MAX) { const cut = out.slice(0, MAX - 1); const sp = cut.lastIndexOf(' '); out = `${(sp > MAX * 0.6 ? cut.slice(0, sp) : cut).replace(/[\s,;:–—-]+$/, '')}…`; }
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const SEEN = /\d|https?:\/\/|\]\(|#\d+|\bPR\b|\bissue\b/;
|
|
102
|
+
/** The first sentence of a text that names what was seen: a number, a link or a PR. */
|
|
103
|
+
function evidenceSentence(raw) {
|
|
104
|
+
// Links are read from the raw text (plain() keeps only their words), then the sentence itself from the plain text.
|
|
105
|
+
for (const para of String(raw || '').split(/\n\s*\n/)) {
|
|
106
|
+
for (const s of sentences(plain(para))) if (SEEN.test(s) || (/\]\(/.test(para) && s.length > 20)) return s;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const line = (text, file, section) => (text ? { text: clip(text), from: section ? `${file} › ${section}` : file } : null);
|
|
112
|
+
|
|
113
|
+
/** The first section of `secs` whose title is in `names` and holds text: { name, text } | null. */
|
|
114
|
+
function pick(secs, names) {
|
|
115
|
+
for (const n of names) { const t = secs && secs.get(n); if (t && plain(t)) return { name: n, text: t }; }
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const cap = (n) => n.charAt(0).toUpperCase() + n.slice(1);
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The three lines of one initiative. `body` and `prd` are whole file texts (frontmatter allowed); `front` defaults to the body's.
|
|
122
|
+
*/
|
|
123
|
+
function whyOf({ id, front, body, prd, recordPath, prdPath } = {}) {
|
|
124
|
+
const fm = front || frontOf(body);
|
|
125
|
+
const rec = sectionsOf(body);
|
|
126
|
+
const doc = prd ? sectionsOf(prd) : new Map();
|
|
127
|
+
const recFile = recordPath || 'record';
|
|
128
|
+
const prdFile = prdPath || 'PRD';
|
|
129
|
+
|
|
130
|
+
let goal = null;
|
|
131
|
+
const g1 = pick(rec, ['goal']);
|
|
132
|
+
const g2 = !g1 && pick(doc, ['goal', 'goals']);
|
|
133
|
+
if (g1) goal = line(g1.text, recFile, 'Goal');
|
|
134
|
+
else if (g2) goal = line(g2.text, prdFile, cap(g2.name));
|
|
135
|
+
else if (fm.outcome_metric) goal = line(fm.outcome_metric, recFile, 'outcome_metric');
|
|
136
|
+
|
|
137
|
+
let problem = null; let problemRaw = null; let problemFrom = null;
|
|
138
|
+
const p1 = pick(rec, ['intent']);
|
|
139
|
+
const p2 = !p1 && pick(doc, ['problem']);
|
|
140
|
+
const p3 = !p1 && !p2 && pick(rec, ['problem', 'why it exists', 'why this exists', 'the defect']);
|
|
141
|
+
if (p1) { problemRaw = p1.text; problemFrom = [recFile, 'Intent']; }
|
|
142
|
+
else if (p2) { problemRaw = p2.text; problemFrom = [prdFile, 'Problem']; }
|
|
143
|
+
else if (p3) { problemRaw = p3.text; problemFrom = [recFile, cap(p3.name)]; }
|
|
144
|
+
if (problemRaw) problem = line(problemRaw, ...problemFrom);
|
|
145
|
+
|
|
146
|
+
let evidence = null;
|
|
147
|
+
const EV = ['evidence', 'why it exists', 'why this exists', 'the finding'];
|
|
148
|
+
const e1 = pick(rec, EV.filter((n) => !(p3 && p3.name === n)));
|
|
149
|
+
const e2 = !e1 && pick(doc, ['evidence']);
|
|
150
|
+
if (e1) evidence = line(e1.text, recFile, cap(e1.name));
|
|
151
|
+
else if (e2) evidence = line(e2.text, prdFile, 'Evidence');
|
|
152
|
+
else if (problemRaw) { const s = evidenceSentence(problemRaw); if (s) evidence = line(s, ...problemFrom); }
|
|
153
|
+
|
|
154
|
+
return {
|
|
155
|
+
id: id || fm.id || null,
|
|
156
|
+
title: fm.title || null,
|
|
157
|
+
goal, problem, evidence,
|
|
158
|
+
complete: !!(goal && problem && evidence),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** A task id `<initiative>.<10 characters>` reads as its initiative; anything else is the id itself. */
|
|
163
|
+
function initiativeIdOf(ref) {
|
|
164
|
+
const s = String(ref || '').trim();
|
|
165
|
+
const m = s.match(TASK_ID);
|
|
166
|
+
return m ? m[1] : s;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function recordPathOf(root, id) {
|
|
170
|
+
if (!ID_RE.test(String(id || ''))) return null;
|
|
171
|
+
for (const parts of LAYOUTS) { const f = path.join(root, ...parts, `${id}.md`); if (fs.existsSync(f)) return f; }
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const readText = (f) => { try { return fs.readFileSync(f, 'utf8'); } catch { return null; } };
|
|
176
|
+
const rel = (root, f) => path.relative(root, f).split(path.sep).join('/');
|
|
177
|
+
|
|
178
|
+
/** The why of an initiative or a task, read from disk; null when there is no record. */
|
|
179
|
+
function readWhy(root, ref) {
|
|
180
|
+
let id = String(ref || '').trim();
|
|
181
|
+
let f = recordPathOf(root, id);
|
|
182
|
+
if (!f) { id = initiativeIdOf(id); f = recordPathOf(root, id); }
|
|
183
|
+
if (!f) return null;
|
|
184
|
+
const body = readText(f) || '';
|
|
185
|
+
const fm = frontOf(body);
|
|
186
|
+
let prd = null; let prdPath = null;
|
|
187
|
+
if (fm.prd_path && !/^(n\/a|na|none|-)$/i.test(fm.prd_path)) {
|
|
188
|
+
const p = String(fm.prd_path).replace(/^\/+/, '');
|
|
189
|
+
for (const base of [root, path.join(root, 'pmos')]) { const t = readText(path.join(base, p)); if (t != null) { prd = t; prdPath = p; break; } }
|
|
190
|
+
}
|
|
191
|
+
return whyOf({ id, front: fm, body, prd, recordPath: rel(root, f), prdPath });
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function readJsonl(f) {
|
|
195
|
+
const t = readText(f); if (!t) return [];
|
|
196
|
+
const out = [];
|
|
197
|
+
for (const l of t.split('\n')) { if (!l.trim()) continue; try { out.push(JSON.parse(l)); } catch { /* a torn line is skipped */ } }
|
|
198
|
+
return out;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/** Every record id that is not closed, cancelled or accepted: the newest lifecycle line decides, an accepted line ends it. */
|
|
202
|
+
function activeIds(root) {
|
|
203
|
+
const ids = new Set();
|
|
204
|
+
for (const parts of LAYOUTS) {
|
|
205
|
+
let names = []; try { names = fs.readdirSync(path.join(root, ...parts)); } catch { continue; }
|
|
206
|
+
for (const n of names) if (n.endsWith('.md') && n !== 'README.md' && n !== 'index.md' && n !== 'log.md') ids.add(n.slice(0, -3));
|
|
207
|
+
}
|
|
208
|
+
const state = new Map();
|
|
209
|
+
for (const parts of LEDGER_DIRS) {
|
|
210
|
+
for (const r of readJsonl(path.join(root, ...parts, 'lifecycle.jsonl'))) {
|
|
211
|
+
if (!r || typeof r.initiative_id !== 'string') continue;
|
|
212
|
+
const prev = state.get(r.initiative_id);
|
|
213
|
+
if (!prev || String(r.at || '') >= String(prev.at || '')) state.set(r.initiative_id, { state: String(r.state || ''), at: r.at });
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const accepted = new Set();
|
|
217
|
+
for (const parts of LEDGER_DIRS) {
|
|
218
|
+
for (const r of readJsonl(path.join(root, ...parts, 'acceptances.jsonl'))) if (r && typeof r.initiative_id === 'string' && r.accepted !== false) accepted.add(r.initiative_id);
|
|
219
|
+
}
|
|
220
|
+
return [...ids].filter((id) => !accepted.has(id) && !STOPPED.has((state.get(id) || {}).state)).sort();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** The share of active initiatives whose why reads all three lines. */
|
|
224
|
+
function coverage(root) {
|
|
225
|
+
const ids = activeIds(root);
|
|
226
|
+
const missing = []; let complete = 0;
|
|
227
|
+
for (const id of ids) {
|
|
228
|
+
const w = readWhy(root, id);
|
|
229
|
+
if (w && w.complete) { complete++; continue; }
|
|
230
|
+
missing.push({ id, lines: w ? ['goal', 'problem', 'evidence'].filter((k) => !w[k]) : ['goal', 'problem', 'evidence'] });
|
|
231
|
+
}
|
|
232
|
+
return { active: ids.length, complete, percent: ids.length ? Math.round((complete / ids.length) * 100) : 0, missing };
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
module.exports = { MAX, whyOf, frontOf, sectionsOf, plain, clip, initiativeIdOf, recordPathOf, readWhy, activeIds, coverage };
|
|
@@ -40,6 +40,7 @@ const PROVIDERS = Object.freeze([
|
|
|
40
40
|
'factory-needs', // factory-builder-inner-loop: a work item blocked after the Builder's CI-fix rounds, with the reason (kind 8)
|
|
41
41
|
'decision-journal-needs', // decision-journal-outcome-checks: a journal decision whose check date came, with no verdict (kind 1)
|
|
42
42
|
'parked-reasons', // parked-reason-way-back (bet A446): a parked initiative whose way back is met, to bring back (kind 7)
|
|
43
|
+
'product-health', // product-health-score: a product's health score fell 10 points or more against its past week (kind 8)
|
|
43
44
|
]);
|
|
44
45
|
/** Kinds that already mean something in the needs queue. A provider may not reuse one. */
|
|
45
46
|
const RESERVED_KINDS = Object.freeze(['question', 'accept', 'outcome', 'keep', 'evidence', 'plan-flag', 'provider-error']);
|
|
@@ -133,6 +133,9 @@ const VERBS = Object.freeze({
|
|
|
133
133
|
// Not a pm-os-absorb verb (run: null): initiative page-fix-count-first (bet A462) added it through the same table.
|
|
134
134
|
pages: Object.freeze({ module: 'pages-cli.js', run: null, guide: 'cli.md',
|
|
135
135
|
help: 'pmos pages [show|check] — each page\'s fixes, reverts and restores in the last 14 days, and a feature change that adds to a page that keeps breaking (pmos pages help)' }),
|
|
136
|
+
// Not a pm-os-absorb verb (run: null): initiative three-line-why (bet A86) added it through the same table.
|
|
137
|
+
why: Object.freeze({ module: 'why-cli.js', run: null, guide: 'cli.md',
|
|
138
|
+
help: 'pmos why <initiative or task> | coverage — why the work exists in three lines: goal, problem, evidence, read from its records (pmos why help)' }),
|
|
136
139
|
// Not a pm-os-absorb verb (run: null): initiative outcome-for-every-initiative added it through the same table.
|
|
137
140
|
outcomes: Object.freeze({ module: 'outcomes-cli.js', run: null, guide: 'cli.md',
|
|
138
141
|
help: 'pmos outcomes list|propose|declare|record|live — every initiative\'s expected outcome and check date: Claude\'s cited drafts, the PM\'s yes, the verdict when a check is due, and the version a place runs (pmos outcomes help)' }),
|
|
@@ -150,6 +153,8 @@ const VERBS = Object.freeze({
|
|
|
150
153
|
driver: Object.freeze({ module: 'driver-cli.js', run: null, guide: 'cli.md',
|
|
151
154
|
help: 'pmos driver propose|status|keep|return|drop|undo|pause|resume|mode … — the Initiative Driver: class A and B changes apply with Undo, the rest wait for you (pmos driver help)' }),
|
|
152
155
|
// one-change-record-no-source-no-auto: everything PMOS changed by itself, in one record (lib/change-record.js)
|
|
156
|
+
health: Object.freeze({ module: 'product-health-cli.js', run: null, guide: 'cli.md',
|
|
157
|
+
help: 'pmos health [score|trend|drops] — this product\'s health score (0 to 100), its trend this month and its past drops (pmos health help)' }),
|
|
153
158
|
factory: Object.freeze({ module: 'factory-cli.js', run: null, guide: 'cli.md',
|
|
154
159
|
help: 'pmos factory today [--days N] — everything PMOS changed by itself, per line and station, with what cites no source (pmos factory help)' }),
|
|
155
160
|
// D106 (Full autonomy now): what agents do by themselves, and the goals they work on until done
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* product-health-cli.js — `pmos health`: this product's health score, its trend and its past drops (initiative product-health-score).
|
|
3
|
+
* The work is in lib/product-health.js; this file is the verb's entry in lib/pmos-verbs.js. Read-only except the day's score line. */
|
|
4
|
+
const PH = require('./product-health.js');
|
|
5
|
+
|
|
6
|
+
const COMMANDS = { health: ['score', 'trend', 'drops'] };
|
|
7
|
+
const USAGE = PH.USAGE;
|
|
8
|
+
function run(argv, { say = (s) => console.log(s) } = {}) {
|
|
9
|
+
const args = argv[0] === 'health' ? argv.slice(1) : argv.slice();
|
|
10
|
+
return PH.cli(args, { say });
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
module.exports = { COMMANDS, USAGE, run };
|