create-pmos 0.812.0 → 0.814.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 +40 -45
- 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 +39 -2
- package/workspace/guide/home.md +1 -0
- package/workspace/guide/layout.md +12 -0
- package/workspace/lib/routes-your-move.js +26 -2
- package/workspace/lib/week-went.js +129 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/ask-here-ctx.js +311 -0
- package/workspace/public/pm/ask-here.css +36 -0
- package/workspace/public/pm/ask-here.js +195 -0
- package/workspace/public/pm/bd-backlog.js +1 -1
- package/workspace/public/pm/cozy-events-view.js +9 -1
- package/workspace/public/pm/cozy-nav.js +2 -0
- package/workspace/public/pm/cozy-today-view.js +10 -4
- package/workspace/public/pm/home-app.js +18 -2
- package/workspace/public/pm/premium-library.js +3 -1
- package/workspace/public/pm/premium-vw-doc.js +1 -1
- package/workspace/public/pm/premium-vw-slides.js +7 -2
- package/workspace/public/pm/week-went-view.js +99 -0
- package/workspace/test-lists/ask-anywhere.json +9 -0
- package/workspace/test-lists/week-went-summary.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.814.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,43 @@
|
|
|
33
33
|
"audit"
|
|
34
34
|
],
|
|
35
35
|
"pmosChanges": [
|
|
36
|
+
{
|
|
37
|
+
"v": "0.814.0",
|
|
38
|
+
"at": "2026-11-25T07:02:21.301Z",
|
|
39
|
+
"f": 4,
|
|
40
|
+
"prs": [
|
|
41
|
+
{
|
|
42
|
+
"n": 1854,
|
|
43
|
+
"t": "Ask PMOS about anything you press (right-click / long-press), A528",
|
|
44
|
+
"s": "Ask PMOS about anything you press (right-click / long-press), A528",
|
|
45
|
+
"k": "new",
|
|
46
|
+
"i": "ask-anywhere"
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"v": "0.813.0",
|
|
52
|
+
"at": "2026-11-25T06:39:24.149Z",
|
|
53
|
+
"f": 4,
|
|
54
|
+
"prs": [
|
|
55
|
+
{
|
|
56
|
+
"n": 1866,
|
|
57
|
+
"t": "Where the week went, one quiet Friday card on Today",
|
|
58
|
+
"s": "Where the week went, one quiet Friday card on Today",
|
|
59
|
+
"k": "new",
|
|
60
|
+
"i": "week-went-summary",
|
|
61
|
+
"h": "Where the week went, one quiet Friday card on Today",
|
|
62
|
+
"try": {
|
|
63
|
+
"steps": [
|
|
64
|
+
"On a Friday, open Today",
|
|
65
|
+
"Find the row Where your week went in Your move and open it"
|
|
66
|
+
],
|
|
67
|
+
"see": "One card splits your week: hours in meetings, decisions, reviews, notes written and tasks done, with one line on what moved. Nothing is sent, and the row is gone until next Friday",
|
|
68
|
+
"open": "/today.html"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
},
|
|
36
73
|
{
|
|
37
74
|
"v": "0.812.0",
|
|
38
75
|
"at": "2026-11-25T06:24:25.632Z",
|
|
@@ -50,6 +87,7 @@
|
|
|
50
87
|
"t": "Pmos balance shows the mix of a list in one line",
|
|
51
88
|
"s": "Pmos balance shows the mix of a list in one line",
|
|
52
89
|
"k": "new",
|
|
90
|
+
"i": "balance-meter",
|
|
53
91
|
"h": "Pmos balance shows the mix of a list in one line",
|
|
54
92
|
"try": {
|
|
55
93
|
"steps": [
|
|
@@ -58,8 +96,7 @@
|
|
|
58
96
|
],
|
|
59
97
|
"see": "The chat names the counts by kind (Feature, Fix, Debt, Discovery) with one bar of the mix. A note shows only when one kind is over 60% of the list.",
|
|
60
98
|
"open": "/today.html"
|
|
61
|
-
}
|
|
62
|
-
"i": "balance-meter"
|
|
99
|
+
}
|
|
63
100
|
}
|
|
64
101
|
]
|
|
65
102
|
},
|
|
@@ -348,48 +385,6 @@
|
|
|
348
385
|
"k": "new"
|
|
349
386
|
}
|
|
350
387
|
]
|
|
351
|
-
},
|
|
352
|
-
{
|
|
353
|
-
"v": "0.789.0",
|
|
354
|
-
"at": "2026-11-24T18:21:37.096Z",
|
|
355
|
-
"f": 4,
|
|
356
|
-
"prs": [
|
|
357
|
-
{
|
|
358
|
-
"n": 1801,
|
|
359
|
-
"t": "Scope cuts S2, S6, S7 checks",
|
|
360
|
-
"s": "Scope cuts S2, S6, S7 checks",
|
|
361
|
-
"k": "x",
|
|
362
|
-
"h": "Scope cuts S2, S6, S7 checks",
|
|
363
|
-
"try": {
|
|
364
|
-
"steps": [
|
|
365
|
-
"Open Work and open an initiative whose end date is still ahead but whose tasks run past it",
|
|
366
|
-
"Press its ✦ and find Cut to keep the date",
|
|
367
|
-
"Keep it, then press Undo"
|
|
368
|
-
],
|
|
369
|
-
"see": "The ✦ lists the tasks that finish after the date, each with its forecast and the new dates after the date; Keep moves them and adds a note, and Undo puts them back",
|
|
370
|
-
"open": "/premium-board.html"
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
{
|
|
374
|
-
"n": 1791,
|
|
375
|
-
"t": "Status in one line, 12 words at most, the full text kept in the log (status-line, job #1775)",
|
|
376
|
-
"s": "Status in one line, 12 words at most, the full text kept in the log (status-line, job #1775)",
|
|
377
|
-
"k": "new"
|
|
378
|
-
}
|
|
379
|
-
]
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
"v": "0.788.0",
|
|
383
|
-
"at": "2026-11-24T18:07:52.786Z",
|
|
384
|
-
"f": 4,
|
|
385
|
-
"prs": [
|
|
386
|
-
{
|
|
387
|
-
"n": 1783,
|
|
388
|
-
"t": "Stuck work gets one prepared next step under the ✦",
|
|
389
|
-
"s": "Stuck work gets one prepared next step under the ✦",
|
|
390
|
-
"k": "new"
|
|
391
|
-
}
|
|
392
|
-
]
|
|
393
388
|
}
|
|
394
389
|
]
|
|
395
390
|
}
|
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-25T07:02:18Z"}
|
|
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-25T07:02:18Z"}
|
|
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-25T07:02:18Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.814.0",
|
|
4
|
+
"at": "2026-11-25T07:02:21.301Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1854,
|
|
9
|
+
"t": "Ask PMOS about anything you press (right-click / long-press), A528",
|
|
10
|
+
"s": "Ask PMOS about anything you press (right-click / long-press), A528",
|
|
11
|
+
"k": "new",
|
|
12
|
+
"i": "ask-anywhere"
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"v": "0.813.0",
|
|
18
|
+
"at": "2026-11-25T06:39:24.149Z",
|
|
19
|
+
"f": 4,
|
|
20
|
+
"prs": [
|
|
21
|
+
{
|
|
22
|
+
"n": 1866,
|
|
23
|
+
"t": "Where the week went, one quiet Friday card on Today",
|
|
24
|
+
"s": "Where the week went, one quiet Friday card on Today",
|
|
25
|
+
"k": "new",
|
|
26
|
+
"i": "week-went-summary",
|
|
27
|
+
"h": "Where the week went, one quiet Friday card on Today",
|
|
28
|
+
"try": {
|
|
29
|
+
"steps": [
|
|
30
|
+
"On a Friday, open Today",
|
|
31
|
+
"Find the row Where your week went in Your move and open it"
|
|
32
|
+
],
|
|
33
|
+
"see": "One card splits your week: hours in meetings, decisions, reviews, notes written and tasks done, with one line on what moved. Nothing is sent, and the row is gone until next Friday",
|
|
34
|
+
"open": "/today.html"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
2
39
|
{
|
|
3
40
|
"v": "0.812.0",
|
|
4
41
|
"at": "2026-11-25T06:24:25.632Z",
|
|
@@ -16,6 +53,7 @@
|
|
|
16
53
|
"t": "Pmos balance shows the mix of a list in one line",
|
|
17
54
|
"s": "Pmos balance shows the mix of a list in one line",
|
|
18
55
|
"k": "new",
|
|
56
|
+
"i": "balance-meter",
|
|
19
57
|
"h": "Pmos balance shows the mix of a list in one line",
|
|
20
58
|
"try": {
|
|
21
59
|
"steps": [
|
|
@@ -24,8 +62,7 @@
|
|
|
24
62
|
],
|
|
25
63
|
"see": "The chat names the counts by kind (Feature, Fix, Debt, Discovery) with one bar of the mix. A note shows only when one kind is over 60% of the list.",
|
|
26
64
|
"open": "/today.html"
|
|
27
|
-
}
|
|
28
|
-
"i": "balance-meter"
|
|
65
|
+
}
|
|
29
66
|
}
|
|
30
67
|
]
|
|
31
68
|
},
|
package/workspace/guide/home.md
CHANGED
|
@@ -51,6 +51,7 @@ Today, Work, Insights and the Viewer use one typeface, Plus Jakarta Sans, with t
|
|
|
51
51
|
- **Today's batch.** Everything other people will see (a review request, Jira tickets, a follow-up, a closed ask) is one row: "Today's batch: 5 to send". Press it to open the batch full size. **Back** returns to Today. The drafts are in groups by kind, and each one says who will see it. ✎ **Change it first** opens the draft, ✕ **Skip** drops it (with Undo), and ✓ **Approve** sends it. When more than one draft waits, PMOS suggests **Approve and send all**. Nothing is sent until you press. If no channel is connected yet, the draft stays in the batch and says so. A draft you leave for 7 days lapses and is not sent. On a phone the batch shows one draft at a time, full text first: swipe right to approve, left to skip.
|
|
52
52
|
- **The dashed line.** Your move ends with one dashed line, for example "9 more move in the line by themselves · none stuck" (or "· 1 stuck"). It counts the live initiatives of your products that do not wait on you. Press it to open the Line on Work. With nothing on the line there is no dashed line.
|
|
53
53
|
- **The weekly digest.** On a Monday the Overview sentence ends with "Last week's digest is ready to read." Press it to read last week in the Viewer: one sentence on the line, What moved (each initiative that reached a new station, and what put it there), What PMOS did by itself (with what you undid and what the Checker sampled), Not sent (drafts that lapsed after 7 days) and Next week (initiatives that reach their station's limit). A section with nothing is left out. The digest is only to read: anything that needs you is already in Your move. The switch in its header, or **Weekly digest** in Settings › General, turns it off; off means PMOS does not make it.
|
|
54
|
+
- **Where your week went.** From Friday to Sunday, Your move shows one quiet row, for example "Where your week went: 9 h in 12 meetings, 3 decisions". Open it to see your week by kind, most first: meetings and their hours (from your calendar), decisions, reviews of what PMOS proposed, notes you typed and tasks you moved to Done. One line says what moved: the tasks done, the initiative with the most of them, and the dates or scope changes. It reads only what PMOS already holds. It calls no model, sends nothing and writes nothing. A week with nothing in it gives no row, and the row is gone once you open it that week.
|
|
54
55
|
- **When a product drifts from Jira.** When fewer than 95% of a product's tasks that name a Jira ticket match the last Jira read, the Overview says so in one ✦ row: "idpf differs from Jira on 7 of 128 tasks (94%). Take Jira's value on all 7". What differs is a value someone set by hand in PMOS: an owner, a done day or a state. Press ✓ to make PMOS say what Jira says for all of them, or press the arrow to see each difference and ✓ only the ones you want. The message that shows has Undo, which puts back what PMOS said. Press ✕ to keep what PMOS says; the row comes back only when the number changes. A product at 95% or more shows no row. PMOS changes nothing in Jira.
|
|
55
56
|
- **One press per initiative.** An initiative's proposals are one row, for example "Checkout: 6 changes to keep" with "3 dates, 2 names, 1 link" under it. Press it to see them grouped as Dates, Names, Done and Links. ✓ keeps all of them, with one Undo for the batch. ✕ drops them, then offers three reasons and **Say why**. A proposal that needs your own check keeps its own ✓ and ✕. **See every change** opens the full list on the initiative.
|
|
56
57
|
- **An ask expires after 14 days with no answer.** PMOS leaves it as it was and writes why in the initiative's History. Your move says it once: "2 asks expired after 14 days with no answer." Dates computed from your tasks never expire: PMOS reads them again each time.
|
|
@@ -310,6 +310,18 @@ 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
|
+
## Ask about what you point at
|
|
314
|
+
|
|
315
|
+
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.
|
|
316
|
+
|
|
317
|
+
- The top line says what PMOS understood: the item, then the field or the place you pressed, for example **Instant payout to bank › Next milestone · Beta to 5% of users**. In a document it is the heading and the paragraph; on a slide it is the slide and the part, such as a chart bar.
|
|
318
|
+
- When the top line names the wrong thing, press **↑** to step out one level: the field, then the item, then the section, then the page.
|
|
319
|
+
- Under it is the item as Work holds it now, with its usual buttons. A task's date shows three later dates to move it to. Every change has Undo.
|
|
320
|
+
- Up to three questions show with ✦. Press one, or type your own question in the box.
|
|
321
|
+
- **⤢** opens the same conversation in the full chat. **×** or Escape closes the card.
|
|
322
|
+
|
|
323
|
+
Right-click keeps the browser's own menu in a text box, on a link, on selected text and in the terminal. Hold Shift to get the browser's menu anywhere.
|
|
324
|
+
|
|
313
325
|
## Keys
|
|
314
326
|
|
|
315
327
|
| Key | What it does |
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
* drafts waiting to send for this product, older than 7 days (lib/digest-parts.js). With the setting digest.on false it reads nothing.
|
|
32
32
|
* GET /api/quiet?ws=<id> → { ok, ws, name, week, total, shown, items: [lib/quiet-sweep.js quietOf item], row } (quiet-work-sweep, bet A503:
|
|
33
33
|
* the initiatives quiet 30 days or more, from the cached line; most quiet first, at most SHOW of them)
|
|
34
|
+
* GET /api/week-went?ws=<id> → { ok, ws, name, week, runtime: { meetings, minutes, writing }, product: { decisions, reviews, done,
|
|
35
|
+
* moves, top }, line } (week-went-summary, idea A342: where the PM's week went, lib/week-went.js; READ ONLY)
|
|
34
36
|
* POST /api/quiet/keep { ws, id, undo? } → { ok, line } still on: one keep (or unkeep) line in quiet-sweep.jsonl, the page's press.
|
|
35
37
|
* Park and close go through POST /api/lifecycle, the PM's press. */
|
|
36
38
|
const YM = require('./your-move.js');
|
|
@@ -191,12 +193,34 @@ async function quietRoute(req, res, url, ctx) {
|
|
|
191
193
|
return true;
|
|
192
194
|
}
|
|
193
195
|
|
|
196
|
+
/** week-went-summary (idea A342): where the PM's week went, for one product, plus the runtime's calendar and notes. Reads only. */
|
|
197
|
+
async function weekWentRoute(req, res, url, ctx) {
|
|
198
|
+
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
199
|
+
let w = null;
|
|
200
|
+
try { w = ctx.getWs(url.searchParams.get('ws') || null); } catch { w = null; }
|
|
201
|
+
if (!w || !w.root) { ctx.json(res, { ok: false, error: 'no such workspace' }, 404); return true; }
|
|
202
|
+
const WW = require('./week-went.js');
|
|
203
|
+
let rows = [];
|
|
204
|
+
try { const IR = require('./initiative-rows.js').rowsFor(w.root); rows = IR && IR.ok ? IR.rows : []; } catch { rows = []; }
|
|
205
|
+
try {
|
|
206
|
+
const r = WW.read({ root: w.root, runtimeDir: ctx.runtimeDir, stateDir: ctx.stateDirFor ? ctx.stateDirFor(w) : null, ws: w.id, name: w.name || w.id, rows },
|
|
207
|
+
{ now: ctx.now ? ctx.now() : Date.now() });
|
|
208
|
+
console.info(WW.TAG + ' read ws=' + w.id + ' week=' + r.week + ' meetings=' + r.runtime.meetings + ' done=' + r.product.done);
|
|
209
|
+
ctx.json(res, { ok: true, ws: w.id, name: w.name || w.id, ...r });
|
|
210
|
+
} catch (e) {
|
|
211
|
+
console.warn(WW.TAG + ' could not read the week of ' + w.id + ': ' + ((e && e.message) || e));
|
|
212
|
+
ctx.json(res, { ok: false, error: 'The week could not be read.' }, 500);
|
|
213
|
+
}
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
|
|
194
217
|
const digestParts = (ctx, w, now) => require('./digest-parts.js').partsOf(ctx, w, lineRows, now); // quiet-rows-digest (reads only)
|
|
195
218
|
|
|
196
219
|
module.exports = {
|
|
197
|
-
expire, questions, asksOf, lineRows, digestParts, quietRoute,
|
|
198
|
-
prefixes: ['/api/your-move', '/api/line', '/api/digest', '/api/quiet'],
|
|
220
|
+
expire, questions, asksOf, lineRows, digestParts, quietRoute, weekWentRoute,
|
|
221
|
+
prefixes: ['/api/your-move', '/api/line', '/api/digest', '/api/quiet', '/api/week-went'],
|
|
199
222
|
handle: async (req, res, url, ctx) => {
|
|
223
|
+
if (url.pathname === '/api/week-went') return weekWentRoute(req, res, url, ctx);
|
|
200
224
|
if (url.pathname === '/api/quiet' || url.pathname === '/api/quiet/keep') return quietRoute(req, res, url, ctx);
|
|
201
225
|
if (url.pathname === '/api/digest') {
|
|
202
226
|
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* week-went.js — where the PM's week went (initiative week-went-summary, idea A342). READ ONLY: it writes nothing and sends nothing.
|
|
4
|
+
*
|
|
5
|
+
* A PM ends the week busy and unsure where the time went. PMOS already holds the records: the calendar, the decision journal, the ✦
|
|
6
|
+
* reviews, the notes and the task ledger. From Friday to Sunday Today's Your move shows one quiet row that puts them side by side, with
|
|
7
|
+
* one line on what moved (pm/week-went-view.js). No model call. Works on any product built with PMOS, in either layout.
|
|
8
|
+
*
|
|
9
|
+
* weekNow(now) → { week, from, to } this week: its Monday (local, YYYY-MM-DD) from 00:00 to `now`
|
|
10
|
+
* splitOf(src, { from, to }) PURE → { parts: { meetings, minutes, decisions, reviews, writing, done }, moved, line, total }
|
|
11
|
+
* src: { events, decisions, proposals, notes, tasks, moves, titles }
|
|
12
|
+
* events calendar events ({ at, end }): lib/calendar-events.js readAll. A meeting counts once; its minutes are end − at,
|
|
13
|
+
* 30 when it has no end, and at most 8 hours (an all-day block is not 24 hours of meetings).
|
|
14
|
+
* decisions decision-journal.jsonl lines: a `decision` line not written by an agent
|
|
15
|
+
* proposals proposals.jsonl lines: a `keep` or `drop` the PM made (by pm:…): a ✦ review
|
|
16
|
+
* notes lib/notes.js list() rows: a note the PM typed or edited this week, not a recorded meeting (that is a meeting)
|
|
17
|
+
* tasks initiative-tasks.jsonl lines: a `task-update` to Done by the PM (by pm:…), at its `happened` day when it has one
|
|
18
|
+
* moves the week's date and scope moves (lib/week-moves.js movesOf total)
|
|
19
|
+
* titles initiative id → title, for the line
|
|
20
|
+
* moved: { done, top: { ini, title, n } | null, moves }; line: the one sentence on what moved; total: the sum of the counts.
|
|
21
|
+
* read({ root, runtimeDir, stateDir, ws, name, rows }, { now }) → { week, from, to, runtime: { meetings, minutes, writing },
|
|
22
|
+
* product: { decisions, reviews, done, moves, top } , line } one product's part
|
|
23
|
+
* CLI: node lib/week-went.js count [<root>] this week's total on its last line
|
|
24
|
+
* Every log line carries [week-went]. */
|
|
25
|
+
const fs = require('fs');
|
|
26
|
+
const path = require('path');
|
|
27
|
+
|
|
28
|
+
const TAG = '[week-went]';
|
|
29
|
+
const DAY = 864e5;
|
|
30
|
+
const MAX_MIN = 8 * 60;
|
|
31
|
+
const isPm = (by) => /^pm:/.test(String(by || ''));
|
|
32
|
+
const isAgent = (by) => /^(agent:|pmos:|claude\b)/i.test(String(by || ''));
|
|
33
|
+
const DONE = /^(done|closed|resolved|complete|completed)$/i;
|
|
34
|
+
const msOf = (s) => { const t = Date.parse(s); return Number.isFinite(t) ? t : NaN; };
|
|
35
|
+
const inside = (t, from, to) => Number.isFinite(t) && t >= from && t < to;
|
|
36
|
+
const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
|
|
37
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
38
|
+
const localDay = (ms) => { const d = new Date(ms); return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`; };
|
|
39
|
+
/** A day YYYY-MM-DD read as local noon (a `happened` day has no hour). */
|
|
40
|
+
const dayMs = (s) => { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3], 12).getTime() : NaN; };
|
|
41
|
+
|
|
42
|
+
/** This week: its Monday (local) from 00:00 up to now. */
|
|
43
|
+
function weekNow(now = Date.now()) {
|
|
44
|
+
const d = new Date(now); d.setHours(0, 0, 0, 0); d.setDate(d.getDate() - ((d.getDay() + 6) % 7));
|
|
45
|
+
return { week: localDay(d.getTime()), from: d.getTime(), to: now };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The week's split and the line on what moved. PURE. */
|
|
49
|
+
function splitOf(src = {}, { from, to } = {}) {
|
|
50
|
+
let meetings = 0, minutes = 0;
|
|
51
|
+
for (const e of src.events || []) {
|
|
52
|
+
const a = msOf(e && e.at); if (!inside(a, from, to)) continue;
|
|
53
|
+
const b = msOf(e.end);
|
|
54
|
+
meetings += 1;
|
|
55
|
+
minutes += Number.isFinite(b) && b > a ? Math.min(MAX_MIN, Math.round((b - a) / 60000)) : 30;
|
|
56
|
+
}
|
|
57
|
+
const decisions = (src.decisions || []).filter((l) => l && l.type === 'decision' && !isAgent(l.by) && inside(msOf(l.at), from, to)).length;
|
|
58
|
+
const reviews = (src.proposals || []).filter((l) => l && (l.kind === 'keep' || l.kind === 'drop') && isPm(l.by) && inside(msOf(l.at), from, to)).length;
|
|
59
|
+
const writing = (src.notes || []).filter((n) => n && !(n.segments > 0) && !(n.meeting_ms > 0) && inside(msOf(n.updated_at), from, to)).length;
|
|
60
|
+
// a task's initiative is on its `task` line; a later update may move it (task-update { initiative })
|
|
61
|
+
const iniOf = new Map();
|
|
62
|
+
for (const l of src.tasks || []) if (l && (l.kind === 'task' || l.kind === 'task-update') && l.initiative && (l.id || l.task)) iniOf.set(l.kind === 'task' ? l.id : l.task, l.initiative);
|
|
63
|
+
const doneBy = new Map(); let done = 0;
|
|
64
|
+
const seen = new Set();
|
|
65
|
+
for (const l of src.tasks || []) {
|
|
66
|
+
if (!l || l.kind !== 'task-update' || !DONE.test(String(l.state || '')) || !isPm(l.by)) continue;
|
|
67
|
+
const t = l.happened ? dayMs(l.happened) : msOf(l.at);
|
|
68
|
+
if (!inside(t, from, to) || seen.has(l.task)) continue; // a task done twice in one week is one task done
|
|
69
|
+
seen.add(l.task); done += 1;
|
|
70
|
+
const ini = iniOf.get(l.task) || null;
|
|
71
|
+
if (ini) doneBy.set(ini, (doneBy.get(ini) || 0) + 1);
|
|
72
|
+
}
|
|
73
|
+
let top = null;
|
|
74
|
+
for (const [ini, n] of doneBy) if (!top || n > top.n) top = { ini, title: (src.titles && src.titles[ini]) || ini, n };
|
|
75
|
+
const moves = Math.max(0, Number(src.moves) || 0);
|
|
76
|
+
return { parts: { meetings, minutes, decisions, reviews, writing, done }, moved: { done, top, moves }, line: lineOf({ done, top, moves }),
|
|
77
|
+
total: meetings + decisions + reviews + writing + done };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The one sentence on what moved. */
|
|
81
|
+
function lineOf({ done = 0, top = null, moves = 0 } = {}) {
|
|
82
|
+
const bits = [];
|
|
83
|
+
if (done) bits.push(plural(done, 'task', 'tasks') + ' done' + (top && done > 1 && top.n > 1 ? ', most on ' + top.title + ' (' + top.n + ')' : top ? ' on ' + top.title : ''));
|
|
84
|
+
if (moves) bits.push(plural(moves, 'date or scope change', 'dates or scope changes'));
|
|
85
|
+
return bits.length ? 'What moved: ' + bits.join('; ') + '.' : 'Nothing moved on the plan this week.';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const jsonl = (f) => { try { return fs.readFileSync(f, 'utf8').split('\n').filter(Boolean).map((s) => { try { return JSON.parse(s); } catch { return null; } }).filter(Boolean); } catch { return []; } };
|
|
89
|
+
|
|
90
|
+
/** One product's part of the week, plus the runtime's calendar and notes. Every source that cannot be read gives nothing. */
|
|
91
|
+
function read(w = {}, { now = Date.now() } = {}) {
|
|
92
|
+
const W = weekNow(now);
|
|
93
|
+
const root = w.root || null;
|
|
94
|
+
const src = { events: [], decisions: [], proposals: [], notes: [], tasks: [], moves: 0, titles: {} };
|
|
95
|
+
if (w.runtimeDir) {
|
|
96
|
+
try { src.events = require('./calendar-events.js').readAll(w.runtimeDir, { now }); } catch { src.events = []; }
|
|
97
|
+
try { src.notes = require('./notes.js').list(w.runtimeDir, { now }).notes || []; } catch { src.notes = []; }
|
|
98
|
+
}
|
|
99
|
+
if (root) {
|
|
100
|
+
try { src.decisions = require('./decision-journal.js').read(root).rows || []; } catch { src.decisions = []; }
|
|
101
|
+
try { const s = require('./task-store.js').storeFor(root); src.tasks = s ? jsonl(s.file) : []; } catch { src.tasks = []; }
|
|
102
|
+
}
|
|
103
|
+
const dir = w.stateDir || (root ? (() => { try { return require('./driver.js').stateDirOf(root); } catch { return null; } })() : null);
|
|
104
|
+
if (dir) src.proposals = jsonl(path.join(dir, 'proposals.jsonl'));
|
|
105
|
+
for (const r of w.rows || []) if (r && r.id) src.titles[r.id] = r.title || r.id;
|
|
106
|
+
if (root) {
|
|
107
|
+
try {
|
|
108
|
+
const WM = require('./week-moves.js');
|
|
109
|
+
const f = require('./drift-facts.js').factsOf({ id: w.ws || 'ws', name: w.name || w.ws || 'ws', root }, { stateDir: dir, rows: w.rows || [] });
|
|
110
|
+
src.moves = WM.movesOf(f, W).total || 0;
|
|
111
|
+
} catch { src.moves = 0; }
|
|
112
|
+
}
|
|
113
|
+
const S = splitOf(src, W);
|
|
114
|
+
return { week: W.week, from: W.from, to: W.to,
|
|
115
|
+
runtime: { meetings: S.parts.meetings, minutes: S.parts.minutes, writing: S.parts.writing },
|
|
116
|
+
product: { decisions: S.parts.decisions, reviews: S.parts.reviews, done: S.parts.done, moves: S.moved.moves, top: S.moved.top },
|
|
117
|
+
line: S.line };
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
module.exports = { TAG, MAX_MIN, weekNow, splitOf, lineOf, read };
|
|
121
|
+
|
|
122
|
+
if (require.main === module) {
|
|
123
|
+
const [cmd, root] = process.argv.slice(2);
|
|
124
|
+
if (cmd !== 'count') { console.error('usage: node lib/week-went.js count [<root>]'); process.exit(2); }
|
|
125
|
+
const r = read({ root: path.resolve(root || process.cwd()) });
|
|
126
|
+
const n = r.runtime.meetings + r.runtime.writing + r.product.decisions + r.product.reviews + r.product.done;
|
|
127
|
+
console.log(TAG + ' week ' + r.week + ' ' + r.line);
|
|
128
|
+
console.log(n);
|
|
129
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.814.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.814.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED