create-pmos 0.818.0 → 0.820.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 +48 -23
- 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 +47 -9
- package/workspace/guide/cli.md +21 -0
- package/workspace/guide/layout.md +2 -0
- package/workspace/lib/driver-run.js +4 -2
- package/workspace/lib/factory-cli.js +25 -1
- package/workspace/lib/factory-floor.js +245 -0
- package/workspace/lib/hire-draft.js +172 -0
- package/workspace/lib/pick-cli.js +75 -0
- package/workspace/lib/pmos-verbs.js +6 -0
- package/workspace/lib/routes-factory-metrics.js +22 -1
- package/workspace/lib/routes-search.js +17 -1
- package/workspace/lib/time-box-pick.js +141 -0
- package/workspace/lib/waiting-on.js +2 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-search.js +1 -0
- package/workspace/run-tests.js +37 -4
- package/workspace/test-lists/factory-floor.json +9 -0
- package/workspace/test-lists/next-hire-draft.json +9 -0
- package/workspace/test-lists/time-box-pick-chat.json +9 -0
- package/workspace/test-timings.json +499 -114
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.820.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": {
|
|
@@ -34,8 +34,32 @@
|
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
36
|
{
|
|
37
|
-
"v": "0.
|
|
38
|
-
"at": "2026-11-
|
|
37
|
+
"v": "0.820.0",
|
|
38
|
+
"at": "2026-11-25T09:08:51.103Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1880,
|
|
43
|
+
"t": "Pmos hire drafts the next hire from the work that waits (job #1876)",
|
|
44
|
+
"s": "Pmos hire drafts the next hire from the work that waits (job #1876)",
|
|
45
|
+
"k": "new",
|
|
46
|
+
"h": "Pmos hire drafts the next hire from the work that waits (job #1876)",
|
|
47
|
+
"try": {
|
|
48
|
+
"steps": [
|
|
49
|
+
"Open Today and ask the chat: draft the next hire",
|
|
50
|
+
"Open the file it names, under planning/hires",
|
|
51
|
+
"Read the role, why now, the 90-day outcomes and the work it takes"
|
|
52
|
+
],
|
|
53
|
+
"see": "One page names the role most loaded or missing (open tasks and waiting asks per person, or work with no owner), why now with the numbers, three outcomes for 90 days from the initiatives that carry…",
|
|
54
|
+
"open": "/today.html"
|
|
55
|
+
},
|
|
56
|
+
"i": "next-hire-draft"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
"v": "0.819.0",
|
|
62
|
+
"at": "2026-11-25T08:28:20.856Z",
|
|
39
63
|
"f": 4,
|
|
40
64
|
"prs": [
|
|
41
65
|
{
|
|
@@ -43,6 +67,7 @@
|
|
|
43
67
|
"t": "Pmos approver shows what each approver asked before",
|
|
44
68
|
"s": "Pmos approver shows what each approver asked before",
|
|
45
69
|
"k": "new",
|
|
70
|
+
"i": "approver-memory",
|
|
46
71
|
"h": "Pmos approver shows what each approver asked before",
|
|
47
72
|
"try": {
|
|
48
73
|
"steps": [
|
|
@@ -51,24 +76,37 @@
|
|
|
51
76
|
],
|
|
52
77
|
"see": "The chat lists what that person had to sign off, what they answered and what they objected to, newest first, each with its source. A person with nothing recorded is left out.",
|
|
53
78
|
"open": "/premium-board.html"
|
|
54
|
-
}
|
|
55
|
-
"i": "approver-memory"
|
|
79
|
+
}
|
|
56
80
|
},
|
|
57
81
|
{
|
|
58
82
|
"n": 1867,
|
|
59
83
|
"t": "Each report draft in each reader's language",
|
|
60
84
|
"s": "Each report draft in each reader's language",
|
|
61
85
|
"k": "new",
|
|
62
|
-
"i": "report-reader-language"
|
|
86
|
+
"i": "report-reader-language"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"n": 1868,
|
|
90
|
+
"t": "The factory numbers snapshot per station (job #1862)",
|
|
91
|
+
"s": "The factory numbers snapshot per station (job #1862)",
|
|
92
|
+
"k": "new",
|
|
93
|
+
"i": "factory-floor-snapshot",
|
|
94
|
+
"h": "The factory numbers snapshot per station (job #1862)",
|
|
63
95
|
"try": {
|
|
64
96
|
"steps": [
|
|
65
|
-
"On Today,
|
|
66
|
-
"Open
|
|
67
|
-
"Compare a number and an initiative id with the original."
|
|
97
|
+
"On Today, open Ask PMOS and ask: what did each factory station make this week?",
|
|
98
|
+
"Open Work and compare the initiatives it names as waiting with their rows."
|
|
68
99
|
],
|
|
69
|
-
"see": "
|
|
100
|
+
"see": "PMOS answers per station (Intake, Shape, Plan, Track, Evaluate, Check, You) with what waits, what it made this week, its PMOS time and what you undid; tokens and money say not recorded yet.",
|
|
70
101
|
"open": "/today.html"
|
|
71
102
|
}
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"n": 1875,
|
|
106
|
+
"t": "I have N minutes — one pick in Ctrl K, the chat and pmos pick (job #1873)",
|
|
107
|
+
"s": "I have N minutes — one pick in Ctrl K, the chat and pmos pick (job #1873)",
|
|
108
|
+
"k": "new",
|
|
109
|
+
"i": "time-box-pick-chat"
|
|
72
110
|
}
|
|
73
111
|
]
|
|
74
112
|
},
|
|
@@ -423,19 +461,6 @@
|
|
|
423
461
|
"k": "fix"
|
|
424
462
|
}
|
|
425
463
|
]
|
|
426
|
-
},
|
|
427
|
-
{
|
|
428
|
-
"v": "0.792.0",
|
|
429
|
-
"at": "2026-11-24T18:56:18.725Z",
|
|
430
|
-
"f": 4,
|
|
431
|
-
"prs": [
|
|
432
|
-
{
|
|
433
|
-
"n": 1806,
|
|
434
|
-
"t": "Events and Routine sit on the system layouts, tuned so nothing moves (A334)",
|
|
435
|
-
"s": "Events and Routine sit on the system layouts, tuned so nothing moves (A334)",
|
|
436
|
-
"k": "new"
|
|
437
|
-
}
|
|
438
|
-
]
|
|
439
464
|
}
|
|
440
465
|
]
|
|
441
466
|
}
|
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-25T09:08:47Z"}
|
|
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-25T09:08:47Z"}
|
|
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-25T09:08:47Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
|
-
"v": "0.
|
|
4
|
-
"at": "2026-11-
|
|
3
|
+
"v": "0.820.0",
|
|
4
|
+
"at": "2026-11-25T09:08:51.103Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1880,
|
|
9
|
+
"t": "Pmos hire drafts the next hire from the work that waits (job #1876)",
|
|
10
|
+
"s": "Pmos hire drafts the next hire from the work that waits (job #1876)",
|
|
11
|
+
"k": "new",
|
|
12
|
+
"h": "Pmos hire drafts the next hire from the work that waits (job #1876)",
|
|
13
|
+
"try": {
|
|
14
|
+
"steps": [
|
|
15
|
+
"Open Today and ask the chat: draft the next hire",
|
|
16
|
+
"Open the file it names, under planning/hires",
|
|
17
|
+
"Read the role, why now, the 90-day outcomes and the work it takes"
|
|
18
|
+
],
|
|
19
|
+
"see": "One page names the role most loaded or missing (open tasks and waiting asks per person, or work with no owner), why now with the numbers, three outcomes for 90 days from the initiatives that carry…",
|
|
20
|
+
"open": "/today.html"
|
|
21
|
+
},
|
|
22
|
+
"i": "next-hire-draft"
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"v": "0.819.0",
|
|
28
|
+
"at": "2026-11-25T08:28:20.856Z",
|
|
5
29
|
"f": 4,
|
|
6
30
|
"prs": [
|
|
7
31
|
{
|
|
@@ -9,6 +33,7 @@
|
|
|
9
33
|
"t": "Pmos approver shows what each approver asked before",
|
|
10
34
|
"s": "Pmos approver shows what each approver asked before",
|
|
11
35
|
"k": "new",
|
|
36
|
+
"i": "approver-memory",
|
|
12
37
|
"h": "Pmos approver shows what each approver asked before",
|
|
13
38
|
"try": {
|
|
14
39
|
"steps": [
|
|
@@ -17,24 +42,37 @@
|
|
|
17
42
|
],
|
|
18
43
|
"see": "The chat lists what that person had to sign off, what they answered and what they objected to, newest first, each with its source. A person with nothing recorded is left out.",
|
|
19
44
|
"open": "/premium-board.html"
|
|
20
|
-
}
|
|
21
|
-
"i": "approver-memory"
|
|
45
|
+
}
|
|
22
46
|
},
|
|
23
47
|
{
|
|
24
48
|
"n": 1867,
|
|
25
49
|
"t": "Each report draft in each reader's language",
|
|
26
50
|
"s": "Each report draft in each reader's language",
|
|
27
51
|
"k": "new",
|
|
28
|
-
"i": "report-reader-language"
|
|
52
|
+
"i": "report-reader-language"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"n": 1868,
|
|
56
|
+
"t": "The factory numbers snapshot per station (job #1862)",
|
|
57
|
+
"s": "The factory numbers snapshot per station (job #1862)",
|
|
58
|
+
"k": "new",
|
|
59
|
+
"i": "factory-floor-snapshot",
|
|
60
|
+
"h": "The factory numbers snapshot per station (job #1862)",
|
|
29
61
|
"try": {
|
|
30
62
|
"steps": [
|
|
31
|
-
"On Today,
|
|
32
|
-
"Open
|
|
33
|
-
"Compare a number and an initiative id with the original."
|
|
63
|
+
"On Today, open Ask PMOS and ask: what did each factory station make this week?",
|
|
64
|
+
"Open Work and compare the initiatives it names as waiting with their rows."
|
|
34
65
|
],
|
|
35
|
-
"see": "
|
|
66
|
+
"see": "PMOS answers per station (Intake, Shape, Plan, Track, Evaluate, Check, You) with what waits, what it made this week, its PMOS time and what you undid; tokens and money say not recorded yet.",
|
|
36
67
|
"open": "/today.html"
|
|
37
68
|
}
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"n": 1875,
|
|
72
|
+
"t": "I have N minutes — one pick in Ctrl K, the chat and pmos pick (job #1873)",
|
|
73
|
+
"s": "I have N minutes — one pick in Ctrl K, the chat and pmos pick (job #1873)",
|
|
74
|
+
"k": "new",
|
|
75
|
+
"i": "time-box-pick-chat"
|
|
38
76
|
}
|
|
39
77
|
]
|
|
40
78
|
},
|
package/workspace/guide/cli.md
CHANGED
|
@@ -158,6 +158,18 @@ The session commands must name who read or wrote. In a workspace session that is
|
|
|
158
158
|
|
|
159
159
|
Nothing here writes a record, sends anything or calls a model.
|
|
160
160
|
|
|
161
|
+
### pmos pick
|
|
162
|
+
|
|
163
|
+
`pmos pick --minutes 30` picks the one ask from Your move and Waiting on others that fits in 30 minutes and unblocks the most others. It prints one line: what to do, about how long it takes, and why. When nothing fits, it names the shortest ask and its time. The chat can run it when you tell it how long you have.
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
pmos pick --minutes 30 # the repository you are in
|
|
167
|
+
pmos pick --minutes 15 --json # the pick as JSON
|
|
168
|
+
pmos pick --minutes 60 --root <dir> # read a repository folder without a server
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
It calls no model, sends nothing and changes nothing. It exits with 0 when it read the asks, 1 when it could not read them, and 2 when `--minutes` is missing.
|
|
172
|
+
|
|
161
173
|
## PMOS's proposals and checks
|
|
162
174
|
|
|
163
175
|
### pmos propose: the one ✦ on each initiative
|
|
@@ -349,6 +361,15 @@ Write the press release before the build ("working backwards"). Run it in the pr
|
|
|
349
361
|
- The draft uses one agent run with no tools. `--no-ai`, `pmos ai off press-release` or `PMOS_AI=off` makes a draft from the record's own lines only. A failed run does the same and says why.
|
|
350
362
|
- `pmos press-release count [--days 7]` prints how many drafts were written in the last days. Its last line is the number.
|
|
351
363
|
|
|
364
|
+
### pmos hire: draft the next hire from the work that waits
|
|
365
|
+
|
|
366
|
+
Show where the team is short before you ask for headcount. Run it in the product's repository, or pass `--root <dir>`, or ask the chat to "draft the next hire". No running workspace is needed.
|
|
367
|
+
|
|
368
|
+
- `pmos hire show` lists, per role, the open tasks and the asks that wait on someone, divided by the people in that role, most per person first. Each owner's role comes from People. An owner with no role is under "No role recorded", and work with no owner is its own group. It writes nothing.
|
|
369
|
+
- `pmos hire draft` names the role with the most open work per person, when it reaches 6 and no other role ties, and writes a one-page role brief to `planning/hires/<day>-<role>.md` (`pmos/planning/hires/` in a kit): the role, why now with the counts, three outcomes for 90 days from the initiatives that carry most of that work, and the work it takes. When no role is clearly loaded, it says so and writes nothing.
|
|
370
|
+
- PMOS never writes over a brief. It calls no model and sends nothing. Edit the brief and share it yourself.
|
|
371
|
+
- `pmos hire count [--days 7]` prints how many briefs were drafted in the last days. Its last line is the number.
|
|
372
|
+
|
|
352
373
|
### pmos why: why the work exists, in three lines
|
|
353
374
|
|
|
354
375
|
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.
|
|
@@ -310,6 +310,8 @@ When the words you type in Search point clearly to one thing, the first row is t
|
|
|
310
310
|
|
|
311
311
|
When you type a question, such as "why do some customers still use a spreadsheet instead of the app?", and no one sentence holds all your words, the first row says "Finding an answer in your work…". After a few seconds it shows a short answer, written only from passages of your own files, and the names of the files it used. Press Enter on the answer to open the first of them. To go deeper, pick "Ask PMOS" in the next row. When your files do not answer the question, the row goes away and the matches stay.
|
|
312
312
|
|
|
313
|
+
When you say how long you have, such as "I have 30 minutes" or "half an hour", the first row is one pick: the ask from Your move or Waiting on others that fits in that time and unblocks the most others, about how long it takes, and why. Press Enter on it to open its initiative, or Today when it has none. PMOS counts a fixed time for each kind of ask (2 minutes to name an owner or send a nudge, 5 for a session that asks, 10 for a gate, 15 for work to check, 30 for a cycle review). When nothing fits, the row names the shortest ask and its time. The chat can give the same pick when you tell it "I have 30 minutes". PMOS calls no model to pick, and it sends and changes nothing.
|
|
314
|
+
|
|
313
315
|
## Ask about what you point at
|
|
314
316
|
|
|
315
317
|
Right-click any part of a page to ask PMOS about it. On a phone, press and hold it. A small Ask card opens next to it.
|
|
@@ -143,7 +143,7 @@ function create(deps) {
|
|
|
143
143
|
session = deps.spawn({
|
|
144
144
|
name: `Driver · ${kind} ${group.target.id}`, ws: w.id, origin: `drive:${kind}:${group.target.id}`, initialInput: prompt + '\r',
|
|
145
145
|
initiative: kind === 'initiative' ? group.target.id : undefined,
|
|
146
|
-
onDone: (r) => endRun(file, runId, group.target, r, group.wakes),
|
|
146
|
+
onDone: (r) => endRun(file, runId, group.target, r, group.wakes, w),
|
|
147
147
|
});
|
|
148
148
|
} catch (e) { warn('driver run', e); }
|
|
149
149
|
D.append(file, { ev: 'run-start', run: runId, target: group.target, board, wakes: group.wakes, session: session ? session.id : null }, { now });
|
|
@@ -166,7 +166,7 @@ function create(deps) {
|
|
|
166
166
|
// The task ledger is bookkeeping for the restart: a failed write is reported and never stops or fails a run.
|
|
167
167
|
function taskLedger(fn) { try { fn(); } catch (e) { warn('orchestrator task ledger', e); } }
|
|
168
168
|
|
|
169
|
-
function endRun(file, runId, target, r, wakeKeys) {
|
|
169
|
+
function endRun(file, runId, target, r, wakeKeys, w) {
|
|
170
170
|
active.delete(runId);
|
|
171
171
|
const res = (r && r.result) || {};
|
|
172
172
|
const ok = !!(r && !r.timedOut && !r.stopped && r.code === 0 && res.ok && !res.isError);
|
|
@@ -178,6 +178,8 @@ function create(deps) {
|
|
|
178
178
|
agent_run: agentRun(runId, target, ok) });
|
|
179
179
|
} catch (e) { warn('driver run end', e); }
|
|
180
180
|
taskLedger(() => tasksEnd(path.dirname(file), wakeKeys, { ok, reason }));
|
|
181
|
+
// factory-floor-snapshot: the factory's numbers are saved after each run, so the Factory page reads one file (lib/factory-floor.js)
|
|
182
|
+
if (w && w.root) { try { require('./factory-floor.js').save(w.root, { stateDir: path.dirname(file), runtimeDir: deps.runtimeDir || null, ws: w.id, name: w.name || w.id }); } catch (e) { warn('[factory-floor] snapshot', e); } }
|
|
181
183
|
}
|
|
182
184
|
|
|
183
185
|
/* `sweepNow` (Refresh now, data-refresh-settings R8) runs the unblock sweep at once, inside or outside the window. */
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* factory-cli.js — `pmos factory`: one view of everything PMOS changed by itself (initiative one-change-record-no-source-no-auto).
|
|
3
|
+
*
|
|
4
|
+
* pmos factory [--json] [--root <dir>]
|
|
5
|
+
* The factory floor (initiative factory-floor-snapshot): per station (Intake, Shape, Plan, Track, Evaluate, Check, You) what waits now,
|
|
6
|
+
* what it made in the last 7 days, PMOS minutes and how many changes were undone (lib/factory-floor.js). It folds the ledgers fresh;
|
|
7
|
+
* the Factory page reads the copy the Driver saves after each run. --json prints the snapshot.
|
|
3
8
|
*
|
|
4
9
|
* pmos factory today [--days N] [--json] [--unsourced] [--root <dir>]
|
|
5
10
|
* Per line (product, project, SDLC) and station: changes, applied by PMOS, kept, undone, ignored, applied with no source, and
|
|
@@ -13,6 +18,7 @@ const CR = require('./change-record.js');
|
|
|
13
18
|
|
|
14
19
|
const COMMANDS = { factory: ['today'] };
|
|
15
20
|
const USAGE = [
|
|
21
|
+
'usage: pmos factory [--json] — per station: what waits, what it made in 7 days, PMOS minutes and what was undone',
|
|
16
22
|
'usage: pmos factory today [--days N] [--json] [--unsourced] — everything PMOS changed by itself, in one record',
|
|
17
23
|
' pmos factory today per line and station: changes, applied, kept, undone, ignored, with no source, runs (today)',
|
|
18
24
|
' pmos factory today --days 7 the same over the last 7 days',
|
|
@@ -27,7 +33,8 @@ const num = (v, n = 6) => String(v).padStart(n);
|
|
|
27
33
|
function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = process.env, now = Date.now(), runtimeDir } = {}) {
|
|
28
34
|
const args = argv[0] === 'factory' ? argv.slice(1) : argv.slice();
|
|
29
35
|
const verb = args[0];
|
|
30
|
-
if (
|
|
36
|
+
if (['help', '--help', '-h'].includes(verb)) { for (const l of USAGE) say(l); return 0; }
|
|
37
|
+
if (!verb || verb.startsWith('--')) return floor(args, { say, cwd, env, now, runtimeDir });
|
|
31
38
|
if (!COMMANDS.factory.includes(verb)) { say(`unknown factory command "${verb}" — one of ${COMMANDS.factory.join(', ')}`); return 2; }
|
|
32
39
|
const d = flag(args, 'days');
|
|
33
40
|
const days = d === undefined ? 1 : Number(d);
|
|
@@ -55,4 +62,21 @@ function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), env = pro
|
|
|
55
62
|
return 0;
|
|
56
63
|
}
|
|
57
64
|
|
|
65
|
+
/** `pmos factory [--json]`: the factory floor of this repository, folded now (lib/factory-floor.js). */
|
|
66
|
+
function floor(args, { say, cwd, env, now, runtimeDir }) {
|
|
67
|
+
const FF = require('./factory-floor.js');
|
|
68
|
+
const root = typeof flag(args, 'root') === 'string' ? path.resolve(cwd, flag(args, 'root')) : repoRoot(cwd);
|
|
69
|
+
let rt = runtimeDir;
|
|
70
|
+
if (rt === undefined) { try { rt = require('./state-root.js').defaultRoot({ env }); } catch { rt = null; } }
|
|
71
|
+
const S = FF.build(root, { runtimeDir: rt, now });
|
|
72
|
+
if (!S) { say('✗ this repository has no PMOS state folder (pmos/state, state or .pmos)'); return 1; }
|
|
73
|
+
if (flag(args, 'json')) { say(JSON.stringify({ ok: true, ...S })); return 0; }
|
|
74
|
+
say(`The factory, last ${S.days} days: ${S.runs} Driver ${S.runs === 1 ? 'run' : 'runs'}`);
|
|
75
|
+
say(' ' + pad('Station', 10) + ['waiting', 'made', 'undone', 'minutes'].map((h) => h.padStart(9)).join(''));
|
|
76
|
+
for (const s of S.stations) say(' ' + pad(s.name, 10) + [s.waiting, s.made, s.undone, s.minutes].map((v) => num(v, 9)).join(''));
|
|
77
|
+
if (S.unplaced.made || S.unplaced.minutes) say(` not placed: ${S.unplaced.made} made, ${S.unplaced.minutes} minutes`);
|
|
78
|
+
say(` tokens and money: ${FF.NOT_RECORDED}`);
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
58
82
|
module.exports = { run, COMMANDS, USAGE };
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* factory-floor.js — the factory's numbers per product and per station, saved ahead so the Factory page opens in 200 ms or less
|
|
3
|
+
* (initiative factory-floor-snapshot, slice B of the Factory page; brief agreed by the PM 2026-11-25).
|
|
4
|
+
*
|
|
5
|
+
* THE MODEL (keep the two apart): the work is what gets made (goals, programs, initiatives, their breakdown); the factory is who makes it.
|
|
6
|
+
* PMOS's stations, in flow order: Intake (asks become initiatives), Shape (problem, evidence, assumptions, PRD), Plan (milestones, tasks,
|
|
7
|
+
* owners, dates), Track (tracker, follow-ups, slips, moves), Evaluate (outcome reading, lessons), Check (PMOS checking its own work) and
|
|
8
|
+
* You (only what no record can decide).
|
|
9
|
+
*
|
|
10
|
+
* STATIONS · WHAT_STATION the stations and the Driver proposal kinds each one makes
|
|
11
|
+
* stationOfJob(job) PURE → a station key | null a change-record job (`driver:<what>`, `propose:<group>`, `ai:<role>`, `outbox`)
|
|
12
|
+
* stationOfCode(code) PURE → a station key | null a Driver blocker code: the station the item waits at
|
|
13
|
+
* compute(input, { now, days, ws, name }) PURE → the snapshot (below). input: read(root, …)
|
|
14
|
+
* read(root, { runtimeDir }) → the ledgers of one repository; no write
|
|
15
|
+
* build(root, { runtimeDir, now, ws, name }) → compute(read(root)) for one repository
|
|
16
|
+
* fileOf(stateDir) → <state folder>/factory-floor.json
|
|
17
|
+
* save(root, { … }) → { ok, file, snapshot } | { ok: false, error } THE ONLY WRITER of the snapshot
|
|
18
|
+
* load(root) → the saved snapshot | null reads one file, folds nothing
|
|
19
|
+
* ageMinutes(root, now) → whole minutes since the snapshot was saved, or -1 (the health number)
|
|
20
|
+
*
|
|
21
|
+
* THE SNAPSHOT { v: 1, at, ws, name, days, from, stations: [{ key, name, waiting, made, undone, minutes, items }], unplaced: { made, minutes },
|
|
22
|
+
* runs, tokens: null, money: null, usage: 'not recorded yet' }
|
|
23
|
+
* waiting what waits at the station now. Intake to Evaluate: the initiatives and Work tasks whose agent blocker of the latest sweep day
|
|
24
|
+
* belongs to it (one per target). Check: the Driver drafts of ended runs the Checker has not graded yet. You: the open sign-offs
|
|
25
|
+
* and the Driver drafts that have waited on the PM for a day (pm-open).
|
|
26
|
+
* made what the station made in the last `days` days, whatever happened to it next (one row per change, lib/change-record.js, so a change
|
|
27
|
+
* PMOS applied by itself is counted once), plus its background runs (tracker reads, outcome runs, lessons, milestone reviews).
|
|
28
|
+
* Check: the Checker's verdicts. You: sign-offs answered and Driver drafts the PM decided.
|
|
29
|
+
* undone of what it made, how many were undone.
|
|
30
|
+
* minutes PMOS minutes of the Driver's runs that ended in the window (run-start to run-end), split evenly over the stations of what each
|
|
31
|
+
* run filed; a run that filed nothing counts for the station of the blocker that woke it; else it is unplaced.
|
|
32
|
+
* items up to MAX_ITEMS waiting items: { kind, id, title, code, text }, what each one waits on.
|
|
33
|
+
* tokens and money stay null ("not recorded yet") until each run records its usage (a later slice). An honest gap, never a guess.
|
|
34
|
+
*
|
|
35
|
+
* Every log line carries [factory-floor]. Nothing here sends anything, and the factory graph never writes it (D65): the server writes it
|
|
36
|
+
* after a Driver run. */
|
|
37
|
+
const fs = require('fs');
|
|
38
|
+
const path = require('path');
|
|
39
|
+
|
|
40
|
+
const FILE = 'factory-floor.json';
|
|
41
|
+
const DAY = 86400000;
|
|
42
|
+
const DAYS = 7;
|
|
43
|
+
const MAX_ITEMS = 50;
|
|
44
|
+
const LOG = '[factory-floor]';
|
|
45
|
+
const NOT_RECORDED = 'not recorded yet';
|
|
46
|
+
const STATIONS = Object.freeze([
|
|
47
|
+
{ key: 'intake', name: 'Intake' }, { key: 'shape', name: 'Shape' }, { key: 'plan', name: 'Plan' }, { key: 'track', name: 'Track' },
|
|
48
|
+
{ key: 'evaluate', name: 'Evaluate' }, { key: 'check', name: 'Check' }, { key: 'you', name: 'You' },
|
|
49
|
+
]);
|
|
50
|
+
// The brief's map of Driver proposal kinds. `note` is a remark, not a made thing: an initiative note is Shape's, a Work task note is Track's.
|
|
51
|
+
const WHAT_STATION = Object.freeze({
|
|
52
|
+
overlap: 'intake',
|
|
53
|
+
problem: 'shape', evidence: 'shape', assumption: 'shape', doc: 'shape', artefact: 'shape',
|
|
54
|
+
sizing: 'plan', stakeholders: 'plan', 'next-step': 'plan',
|
|
55
|
+
'follow-up': 'track', move: 'track',
|
|
56
|
+
});
|
|
57
|
+
// The ✦ groups (lib/proposals.js GROUPS) and the rest of the change record.
|
|
58
|
+
const GROUP_STATION = Object.freeze({ found: 'intake', description: 'shape', dates: 'plan', status: 'track', names: 'track', links: 'track', tidy: 'track',
|
|
59
|
+
default: 'track', ask: 'track', outcome: 'evaluate' });
|
|
60
|
+
// The background runs that make something of their own (lib/bg-queue.js JOBS): tracker reads, outcome runs, lessons, milestone reviews.
|
|
61
|
+
const RUN_STATION = Object.freeze({ refresh: 'track', outcomes: 'evaluate', impact: 'evaluate', 'metric-reads': 'evaluate', improve: 'evaluate', milestones: 'plan' });
|
|
62
|
+
// The Driver's blocker codes (lib/driver.js detect, lib/line-driver.js blockerOf): the station each waiting item stands at.
|
|
63
|
+
const CODE_STATION = Object.freeze({
|
|
64
|
+
'no-anchor': 'intake',
|
|
65
|
+
'no-problem': 'shape', 'no-evidence': 'shape', 'no-prd': 'shape', 'no-done-criteria': 'shape', 'doc-due': 'shape', 'doc-stale': 'shape',
|
|
66
|
+
'work-no-next-step': 'plan',
|
|
67
|
+
'no-ticket-movement': 'track', 'ticket-blocked': 'track', stalled: 'track', 'work-overdue': 'track', 'work-waiting': 'track', 'work-untouched': 'track',
|
|
68
|
+
'exit-missing': 'track',
|
|
69
|
+
'check-by-passed': 'evaluate', 'kill-tripped': 'evaluate',
|
|
70
|
+
});
|
|
71
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
72
|
+
const ms = (iso) => { const t = Date.parse(iso || ''); return Number.isFinite(t) ? t : null; };
|
|
73
|
+
const one = (s, n) => String(s == null ? '' : s).replace(/\s+/g, ' ').trim().slice(0, n);
|
|
74
|
+
|
|
75
|
+
function stationOfJob(job, { kind } = {}) {
|
|
76
|
+
const [k, name = ''] = String(job || '').split(':');
|
|
77
|
+
if (k === 'driver') return name === 'note' ? (kind === 'work' ? 'track' : 'shape') : WHAT_STATION[name] || null;
|
|
78
|
+
if (k === 'propose') return GROUP_STATION[name] || null;
|
|
79
|
+
if (k === 'ai') return name === 'improve' ? 'evaluate' : null;
|
|
80
|
+
if (k === 'outbox') return 'track';
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
const stationOfCode = (code) => CODE_STATION[String(code || '')] || null;
|
|
84
|
+
|
|
85
|
+
/* ── the fold ── */
|
|
86
|
+
function compute(input = {}, { now = Date.now(), days = DAYS, ws = null, name = null } = {}) {
|
|
87
|
+
const D = require('./driver.js');
|
|
88
|
+
const CR = require('./change-record.js');
|
|
89
|
+
const from = now - days * DAY;
|
|
90
|
+
const inWin = (at) => { const t = ms(at); return t != null && t >= from && t <= now + 60000; };
|
|
91
|
+
const st = new Map(STATIONS.map((s) => [s.key, { key: s.key, name: s.name, waiting: 0, made: 0, undone: 0, minutes: 0, items: [], _targets: new Set() }]));
|
|
92
|
+
const unplaced = { made: 0, minutes: 0 };
|
|
93
|
+
const wait = (key, item) => {
|
|
94
|
+
const s = st.get(key);
|
|
95
|
+
const tk = `${item.kind}:${item.id}`;
|
|
96
|
+
if (s._targets.has(tk)) return;
|
|
97
|
+
s._targets.add(tk); s.waiting++;
|
|
98
|
+
if (s.items.length < MAX_ITEMS) s.items.push(item);
|
|
99
|
+
};
|
|
100
|
+
const driverLines = Array.isArray(input.driver) ? input.driver : [];
|
|
101
|
+
const state = D.fold(driverLines);
|
|
102
|
+
|
|
103
|
+
// MADE and UNDONE: one row per change (lib/change-record.js), placed by its job
|
|
104
|
+
const { rows } = CR.rows(input, { now });
|
|
105
|
+
for (const r of rows) {
|
|
106
|
+
if (!inWin(r.at)) continue;
|
|
107
|
+
const dp = r.ref ? state.proposals.get(r.ref) : null;
|
|
108
|
+
const key = stationOfJob(r.job, { kind: dp ? dp.target.kind : 'initiative' });
|
|
109
|
+
if (!key) { unplaced.made++; continue; }
|
|
110
|
+
const s = st.get(key);
|
|
111
|
+
s.made++;
|
|
112
|
+
if (r.state === 'undone') s.undone++;
|
|
113
|
+
}
|
|
114
|
+
for (const l of Array.isArray(input.bgQueue) ? input.bgQueue : []) {
|
|
115
|
+
if (!isObj(l) || l.kind !== 'done' || !inWin(l.at) || (ws && l.ws && l.ws !== ws)) continue;
|
|
116
|
+
const key = RUN_STATION[String(l.job || '')];
|
|
117
|
+
if (key) st.get(key).made++;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// WAITING at a working station: the agent blockers of the latest sweep day, one per target
|
|
121
|
+
let lastDay = null;
|
|
122
|
+
for (const b of state.blockers) if (b.owner === 'agent' && (!lastDay || b.day > lastDay)) lastDay = b.day;
|
|
123
|
+
for (const b of state.blockers) {
|
|
124
|
+
if (b.owner !== 'agent' || b.day !== lastDay || !b.target) continue;
|
|
125
|
+
const key = stationOfCode(b.code);
|
|
126
|
+
if (key) wait(key, { kind: b.target.kind, id: b.target.id, title: one(b.title || b.target.id, 120), code: b.code, text: one(b.text, 200) });
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// CHECK: the Checker's verdicts made; the drafts of ended runs it has not graded yet wait
|
|
130
|
+
const checks = Array.isArray(input.checker) ? input.checker : [];
|
|
131
|
+
const checked = new Map();
|
|
132
|
+
for (const c of checks) {
|
|
133
|
+
if (!isObj(c) || typeof c.proposal !== 'string' || !['pass', 'flag', 'none'].includes(c.verdict)) continue;
|
|
134
|
+
if (!checked.has(c.proposal)) checked.set(c.proposal, c);
|
|
135
|
+
if (c.verdict !== 'none' && inWin(c.at)) st.get('check').made++;
|
|
136
|
+
}
|
|
137
|
+
for (const d of require('./orchestrator-checker.js').due(state, checked, { now })) {
|
|
138
|
+
wait('check', { kind: d.target.kind, id: d.target.id, title: d.target.id, code: 'unchecked', text: `${d.proposals.length} ${d.proposals.length === 1 ? 'draft' : 'drafts'} not checked yet` });
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// YOU: open sign-offs and Driver drafts that waited a day (pm-open); answered sign-offs and the PM's decisions are what You made
|
|
142
|
+
const SO = require('./signoffs.js');
|
|
143
|
+
for (const s of SO.fold(Array.isArray(input.signoffs) ? input.signoffs : [])) {
|
|
144
|
+
if (s.state === 'open') { const you = st.get('you'); you.waiting++; if (you.items.length < MAX_ITEMS) you.items.push({ kind: 'signoff', id: s.id, title: one(s.what, 120), code: 'signoff', text: one(`${s.who}: ${s.what}`, 200), ini: s.ini || null }); }
|
|
145
|
+
else if (s.state === 'answered' && inWin(s.answeredAt)) st.get('you').made++;
|
|
146
|
+
}
|
|
147
|
+
for (const p of D.openProposals(state)) {
|
|
148
|
+
if (!p.at || now - Date.parse(p.at) < D.PM_WAIT_MS) continue;
|
|
149
|
+
wait('you', { kind: p.target.kind, id: p.target.id, title: p.target.id, code: 'pm-open', text: `Drafts have waited on you since ${p.at.slice(0, 10)}` });
|
|
150
|
+
}
|
|
151
|
+
for (const p of state.proposals.values()) {
|
|
152
|
+
if (p.decided_by && String(p.decided_by).startsWith('pm:') && !p.auto && inWin(p.decided_at)) st.get('you').made++;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// MINUTES: the Driver's runs that ended in the window
|
|
156
|
+
const wakeOf = new Map(state.wakes.map((w) => [w.key, w]));
|
|
157
|
+
let runs = 0;
|
|
158
|
+
for (const r of state.runs.values()) {
|
|
159
|
+
if (!r.end || !inWin(r.end)) continue;
|
|
160
|
+
const t0 = ms(r.start), t1 = ms(r.end);
|
|
161
|
+
if (t0 == null || t1 == null || t1 < t0) continue;
|
|
162
|
+
runs++;
|
|
163
|
+
const mins = (t1 - t0) / 60000;
|
|
164
|
+
let keys = [...new Set([...state.proposals.values()].filter((p) => p.run === r.run).map((p) => stationOfJob('driver:' + p.what, { kind: p.target.kind })).filter(Boolean))];
|
|
165
|
+
if (!keys.length) {
|
|
166
|
+
for (const k of r.wakes) {
|
|
167
|
+
const w = wakeOf.get(k);
|
|
168
|
+
const key = w && (w.blocker ? stationOfCode(w.blocker) : w.reason === 'created' ? 'intake' : w.reason === 'moved' ? 'track' : null);
|
|
169
|
+
if (key) { keys = [key]; break; }
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (!keys.length) { unplaced.minutes += mins; continue; }
|
|
173
|
+
for (const k of keys) st.get(k).minutes += mins / keys.length;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const stations = [...st.values()].map(({ _targets, ...s }) => ({ ...s, minutes: Math.round(s.minutes) }));
|
|
177
|
+
return { v: 1, at: new Date(now).toISOString(), ws, name, days, from: new Date(from).toISOString(), stations,
|
|
178
|
+
unplaced: { made: unplaced.made, minutes: Math.round(unplaced.minutes) }, runs, tokens: null, money: null, usage: NOT_RECORDED };
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* ── the read (no write) ── */
|
|
182
|
+
function linesOf(file) {
|
|
183
|
+
let text = '';
|
|
184
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
185
|
+
const out = [];
|
|
186
|
+
for (const raw of text.split('\n')) { if (!raw.trim()) continue; try { const l = JSON.parse(raw); if (isObj(l)) out.push(l); } catch { /* a torn line is skipped */ } }
|
|
187
|
+
return out;
|
|
188
|
+
}
|
|
189
|
+
/** The ledgers of one repository. `stateDir` is the state folder the caller already knows (the Driver's ledger folder); else the rule
|
|
190
|
+
* lib/driver.js stateDirOf uses. No write. */
|
|
191
|
+
function read(root, { runtimeDir = null, stateDir = null } = {}) {
|
|
192
|
+
const dir = stateDir || require('./driver.js').stateDirOf(root);
|
|
193
|
+
const pick = (name) => [dir, runtimeDir].filter(Boolean).map((d) => path.join(d, name)).find((f) => fs.existsSync(f)) || null;
|
|
194
|
+
const ob = runtimeDir ? path.join(runtimeDir, 'outbox', 'outbox.jsonl') : null;
|
|
195
|
+
const at = (name) => (dir ? linesOf(path.join(dir, name)) : []);
|
|
196
|
+
return {
|
|
197
|
+
stateDir: dir,
|
|
198
|
+
autonomy: at('autonomy.jsonl'), proposals: at('proposals.jsonl'), driver: at('driver.jsonl'), checker: at('checker.jsonl'),
|
|
199
|
+
signoffs: dir ? linesOf(require('./signoffs.js').fileOf(dir)) : [],
|
|
200
|
+
bgQueue: pick('bg-queue.jsonl') ? linesOf(pick('bg-queue.jsonl')) : [],
|
|
201
|
+
outbox: ob && fs.existsSync(ob) ? linesOf(ob) : [],
|
|
202
|
+
checks: require('./change-record.js').checksOf(root),
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function build(root, { runtimeDir = null, stateDir = null, now = Date.now(), days = DAYS, ws, name = null } = {}) {
|
|
206
|
+
const input = read(root, { runtimeDir, stateDir });
|
|
207
|
+
if (!input.stateDir) return null;
|
|
208
|
+
const id = ws || require('./driver.js').wsIdOf(root);
|
|
209
|
+
input.outbox = input.outbox.filter((l) => !l.ws || l.ws === id);
|
|
210
|
+
return compute(input, { now, days, ws: id, name });
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const fileOf = (stateDir) => path.join(stateDir, FILE);
|
|
214
|
+
/** THE ONLY WRITER of the snapshot: build it and write it whole (a temporary file renamed over the old one, so a read never sees half). */
|
|
215
|
+
function save(root, opts = {}) {
|
|
216
|
+
const dir = opts.stateDir || require('./driver.js').stateDirOf(root);
|
|
217
|
+
if (!dir) return { ok: false, error: 'no PMOS state folder' };
|
|
218
|
+
const snapshot = build(root, { ...opts, stateDir: dir });
|
|
219
|
+
const file = fileOf(dir);
|
|
220
|
+
const tmp = `${file}.${process.pid}.tmp`;
|
|
221
|
+
fs.writeFileSync(tmp, JSON.stringify(snapshot) + '\n');
|
|
222
|
+
fs.renameSync(tmp, file);
|
|
223
|
+
return { ok: true, file, snapshot };
|
|
224
|
+
}
|
|
225
|
+
/** The saved snapshot, or null. It reads one file and folds nothing. */
|
|
226
|
+
function load(root, { stateDir = null } = {}) {
|
|
227
|
+
const dir = stateDir || require('./driver.js').stateDirOf(root);
|
|
228
|
+
if (!dir) return null;
|
|
229
|
+
try { const s = JSON.parse(fs.readFileSync(fileOf(dir), 'utf8')); return isObj(s) && s.v === 1 ? s : null; } catch { return null; }
|
|
230
|
+
}
|
|
231
|
+
function ageMinutes(root, now = Date.now()) {
|
|
232
|
+
const s = load(root);
|
|
233
|
+
const t = s && ms(s.at);
|
|
234
|
+
return t == null ? -1 : Math.max(0, Math.floor((now - t) / 60000));
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
module.exports = { STATIONS, WHAT_STATION, GROUP_STATION, RUN_STATION, CODE_STATION, FILE, DAYS, LOG, NOT_RECORDED, MAX_ITEMS,
|
|
238
|
+
stationOfJob, stationOfCode, compute, read, build, fileOf, save, load, ageMinutes };
|
|
239
|
+
|
|
240
|
+
// `node lib/factory-floor.js age <checkout>`: the health number, minutes since the snapshot was saved (-1 when there is none)
|
|
241
|
+
if (require.main === module) {
|
|
242
|
+
const [verb, root = '.'] = process.argv.slice(2);
|
|
243
|
+
if (verb !== 'age') { console.log('usage: node lib/factory-floor.js age <checkout>'); process.exit(2); }
|
|
244
|
+
console.log(String(ageMinutes(path.resolve(root))));
|
|
245
|
+
}
|