create-pmos 0.812.0 → 0.813.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.812.0",
3
+ "version": "0.813.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,29 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.813.0",
38
+ "at": "2026-11-25T06:39:24.149Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1866,
43
+ "t": "Where the week went, one quiet Friday card on Today",
44
+ "s": "Where the week went, one quiet Friday card on Today",
45
+ "k": "new",
46
+ "h": "Where the week went, one quiet Friday card on Today",
47
+ "try": {
48
+ "steps": [
49
+ "On a Friday, open Today",
50
+ "Find the row Where your week went in Your move and open it"
51
+ ],
52
+ "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",
53
+ "open": "/today.html"
54
+ },
55
+ "i": "week-went-summary"
56
+ }
57
+ ]
58
+ },
36
59
  {
37
60
  "v": "0.812.0",
38
61
  "at": "2026-11-25T06:24:25.632Z",
@@ -50,6 +73,7 @@
50
73
  "t": "Pmos balance shows the mix of a list in one line",
51
74
  "s": "Pmos balance shows the mix of a list in one line",
52
75
  "k": "new",
76
+ "i": "balance-meter",
53
77
  "h": "Pmos balance shows the mix of a list in one line",
54
78
  "try": {
55
79
  "steps": [
@@ -58,8 +82,7 @@
58
82
  ],
59
83
  "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
84
  "open": "/today.html"
61
- },
62
- "i": "balance-meter"
85
+ }
63
86
  }
64
87
  ]
65
88
  },
@@ -377,19 +400,6 @@
377
400
  "k": "new"
378
401
  }
379
402
  ]
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
403
  }
394
404
  ]
395
405
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@910ccacd2
1
+ kernel-source: pmos@b2e2ef88a
2
2
  assembled: 2026-11-25
3
3
  mode: vendor
@@ -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-25T06:24:21Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T06:39:21Z"}
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-25T06:24:21Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T06:39:21Z"}
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-25T06:24:21Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-25T06:39:21Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,27 @@
1
1
  [
2
+ {
3
+ "v": "0.813.0",
4
+ "at": "2026-11-25T06:39:24.149Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1866,
9
+ "t": "Where the week went, one quiet Friday card on Today",
10
+ "s": "Where the week went, one quiet Friday card on Today",
11
+ "k": "new",
12
+ "h": "Where the week went, one quiet Friday card on Today",
13
+ "try": {
14
+ "steps": [
15
+ "On a Friday, open Today",
16
+ "Find the row Where your week went in Your move and open it"
17
+ ],
18
+ "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",
19
+ "open": "/today.html"
20
+ },
21
+ "i": "week-went-summary"
22
+ }
23
+ ]
24
+ },
2
25
  {
3
26
  "v": "0.812.0",
4
27
  "at": "2026-11-25T06:24:25.632Z",
@@ -16,6 +39,7 @@
16
39
  "t": "Pmos balance shows the mix of a list in one line",
17
40
  "s": "Pmos balance shows the mix of a list in one line",
18
41
  "k": "new",
42
+ "i": "balance-meter",
19
43
  "h": "Pmos balance shows the mix of a list in one line",
20
44
  "try": {
21
45
  "steps": [
@@ -24,8 +48,7 @@
24
48
  ],
25
49
  "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
50
  "open": "/today.html"
27
- },
28
- "i": "balance-meter"
51
+ }
29
52
  }
30
53
  ]
31
54
  },
@@ -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.
@@ -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.812.0",
3
+ "version": "0.813.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.812.0",
9
+ "version": "0.813.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.812.0",
3
+ "version": "0.813.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -450,6 +450,8 @@ function rankIn() {
450
450
  if (S.movesRow) extra.push(S.movesRow);
451
451
  // quiet-work-sweep (A503): the initiatives quiet 30 days or more on every product, one row a week until the PM opens the list (pm/quiet-view.js)
452
452
  if (S.quietRow) extra.push(S.quietRow);
453
+ // week-went-summary (A342): where the PM's week went, every product in one row from Friday to Sunday until opened (pm/week-went-view.js)
454
+ if (S.weekRow) extra.push(S.weekRow);
453
455
  // try-what-shipped: one row while the updates brought changes to try (beta only; GET /api/try says the row, pm/try-view.js opens the list)
454
456
  if (S.tryRow) extra.push(S.tryRow);
455
457
  return { products, programs: S.D.programs || [], move: S.move || {}, mentions: MEN.mentionsOf(S.D).waiting, outbox: S.outbox || [], gaps: (S.wait && S.wait.gaps) || [], extra };
@@ -483,12 +485,19 @@ async function readMove() {
483
485
  S.quiet = qs.filter((r) => r && r.ok);
484
486
  const prevQuiet = JSON.stringify(S.quietRow || null);
485
487
  try { const QV = await import('./quiet-view.js'); S.quietRow = QV.rowOf(S.quiet, { looked: QV.lookedWeek() }); } catch { S.quietRow = null; }
488
+ // week-went-summary (A342): each product's week (GET /api/week-went), read only from Friday to Sunday, folded into one Your move row
489
+ const prevWeek = JSON.stringify(S.weekRow || null);
490
+ if ([5, 6, 0].includes(new Date().getDay())) {
491
+ const wk = await Promise.all(L.map((ws) => pmGet('/api/week-went' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)));
492
+ S.week = wk.filter((r) => r && r.ok);
493
+ try { const WV = await import('./week-went-view.js'); S.weekRow = WV.rowOf(S.week, { looked: WV.lookedWeek() }); } catch { S.weekRow = null; }
494
+ } else S.weekRow = null;
486
495
  const prevTry = JSON.stringify(S.tryRow || null);
487
496
  try { const TV = await import('./try-view.js'); S.tryRow = TV.rowOf(await pmGet('/api/try').catch(() => null)); } catch { S.tryRow = null; }
488
497
  const ob = await pmGet('/api/outbox').catch(() => null);
489
498
  const outbox = ob && ob.ok && Array.isArray(ob.entries) ? ob.entries.filter((e) => e && (e.state === 'queued' || e.state === 'blocked')) : [];
490
499
  const lab = labs.filter(Boolean);
491
- const same = JSON.stringify(next) === JSON.stringify(S.move || null) && JSON.stringify(outbox) === JSON.stringify(S.outbox || []) && JSON.stringify(lab) === JSON.stringify(S.lab || []) && prevMoves === JSON.stringify(S.movesRow || null) && prevQuiet === JSON.stringify(S.quietRow || null) && prevTry === JSON.stringify(S.tryRow || null);
500
+ const same = JSON.stringify(next) === JSON.stringify(S.move || null) && JSON.stringify(outbox) === JSON.stringify(S.outbox || []) && JSON.stringify(lab) === JSON.stringify(S.lab || []) && prevMoves === JSON.stringify(S.movesRow || null) && prevQuiet === JSON.stringify(S.quietRow || null) && prevWeek === JSON.stringify(S.weekRow || null) && prevTry === JSON.stringify(S.tryRow || null);
492
501
  S.move = next; S.outbox = outbox; S.lab = lab;
493
502
  if (!same) { redrawLater(); drawList(); }
494
503
  // a demotion notice is said once: drawn now, then marked seen so the next read leaves it out
@@ -526,6 +535,7 @@ async function movePress(b) {
526
535
  if (r.go === 'impact') { S.day = false; S.sel = 'impact'; if (isPhone()) S.phoneChat = true; openTarget(homeTarget()); drawList(); return; }
527
536
  if (r.go === 'loose') { VW.drill(); LPV.open(lpHost); return; }
528
537
  if (r.go === 'moves') { VW.drill(); import('./moves-view.js').then((MV) => { MV.openMoves(S.moves || [], { toast }); S.movesRow = null; drawList(); }); return; }
538
+ if (r.go === 'week') { VW.drill(); import('./week-went-view.js').then((WV) => { WV.openWeek(S.week || [], { toast }); S.weekRow = null; drawList(); }); return; }
529
539
  if (r.go === 'quiet') { VW.drill(); import('./quiet-view.js').then((QV) => { QV.openQuiet(S.quiet || [], { pmPost, toast, toastUndo }); S.quietRow = null; drawList(); }); return; }
530
540
  if (r.go === 'try') { VW.drill(); import('./try-view.js').then((TV) => TV.openTry({ toast, toastUndo, onChange: (l) => { S.tryRow = TV.rowOf({ ...l, ok: true, row: l.total ? { ...S.tryRow, title: l.total + (l.total === 1 ? ' new thing to try' : ' new things to try') } : null }); drawList(); } })); return; }
531
541
  if (r.go === 'lab') { VW.drill(); import('./cozy-lab-ins.js').then((LB) => LB.openLab({ where: () => ({ ws: r.ws, board: r.board }), iniHref: (id) => '/premium-initiative.html?' + (r.ws ? 'ws=' + encodeURIComponent(r.ws) + '&' : '') + 'id=' + encodeURIComponent(id), toast: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)) })); return; }
@@ -0,0 +1,99 @@
1
+ /* pm/week-went-view.js — where the PM's week went (initiative week-went-summary, idea A342; lib/week-went.js, GET /api/week-went).
2
+ * Pure apart from openWeek: Node imports it (week-went.test.js W4, N1).
3
+ *
4
+ * foldOf(lists) → { week, meetings, minutes, decisions, reviews, writing, done, moves, top, line, total } | null
5
+ * every product's GET /api/week-went answer as one week: the calendar meetings and the notes are the
6
+ * runtime's, so they count once (from the first answer); decisions, reviews, tasks done and moves sum
7
+ * rowOf(lists, { looked, day }) → Today's Your move row ({ key, go: 'week', week, title, sub }) or null: only on Friday, Saturday or
8
+ * Sunday (day: 0-6, Sunday 0, the browser's day by default), null for an empty week (zero is silence) and
9
+ * once the PM opened this week's card
10
+ * cardHtml(fold, { esc }) → the card: one row per kind, most first, then the line on what moved
11
+ * openWeek(lists, H) the card in the Viewer. H: { toast }. Opening it marks the week as looked and logs the use-log control
12
+ * weekWentOpen (the health number). It reads nothing more, writes nothing to a product and sends nothing.
13
+ * lookedWeek() · markLooked(week) which week the PM opened (this browser only; a missing store reads as not looked) */
14
+
15
+ const KEY = 'pmos.weekwent.looked';
16
+ const escDefault = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
17
+ const ICON = 'M3 3v18h18M7 15l4-4 3 3 5-6';
18
+ const ok = (l) => l && l.ok && l.week;
19
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
20
+ const WEEKEND = new Set([5, 6, 0]); // Friday, Saturday, Sunday
21
+
22
+ /** Hours and minutes, short: 45 min, 2 h, 9 h 30 min. */
23
+ export function hoursOf(min) {
24
+ const m = Math.max(0, Math.round(Number(min) || 0));
25
+ if (m < 60) return m + ' min';
26
+ const h = Math.floor(m / 60), r = m % 60;
27
+ return h + ' h' + (r ? ' ' + r + ' min' : '');
28
+ }
29
+
30
+ export function lookedWeek() { try { return localStorage.getItem(KEY) || ''; } catch { return ''; } }
31
+ export function markLooked(week) { try { if (week) localStorage.setItem(KEY, week); } catch { /* this browser keeps no store */ } }
32
+
33
+ /** Every product's answer as one week. */
34
+ export function foldOf(lists) {
35
+ const L = (lists || []).filter(ok);
36
+ if (!L.length) return null;
37
+ const week = L[0].week, rt = L[0].runtime || {};
38
+ const f = { week, meetings: rt.meetings || 0, minutes: rt.minutes || 0, writing: rt.writing || 0, decisions: 0, reviews: 0, done: 0, moves: 0, top: null };
39
+ for (const l of L.filter((x) => x.week === week)) {
40
+ const p = l.product || {};
41
+ f.decisions += p.decisions || 0; f.reviews += p.reviews || 0; f.done += p.done || 0; f.moves += p.moves || 0;
42
+ if (p.top && (!f.top || p.top.n > f.top.n)) f.top = { ...p.top, product: L.length > 1 ? l.name || l.ws : '' };
43
+ }
44
+ f.total = f.meetings + f.decisions + f.reviews + f.writing + f.done;
45
+ f.line = lineOf(f);
46
+ return f;
47
+ }
48
+
49
+ /** The one sentence on what moved, over every product (lib/week-went.js lineOf, said the same way). */
50
+ function lineOf({ done = 0, top = null, moves = 0 }) {
51
+ const bits = [];
52
+ 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 : ''));
53
+ if (moves) bits.push(plural(moves, 'date or scope change', 'dates or scope changes'));
54
+ return bits.length ? 'What moved: ' + bits.join('; ') + '.' : 'Nothing moved on the plan this week.';
55
+ }
56
+
57
+ /** Today's Your move row for this week, or null. */
58
+ export function rowOf(lists, { looked = '', day = new Date().getDay() } = {}) {
59
+ if (!WEEKEND.has(day)) return null;
60
+ const f = foldOf(lists);
61
+ if (!f || !f.total) return null;
62
+ if (looked === f.week) return null;
63
+ const head = [];
64
+ if (f.meetings) head.push(hoursOf(f.minutes) + ' in ' + plural(f.meetings, 'meeting', 'meetings'));
65
+ if (f.decisions) head.push(plural(f.decisions, 'decision', 'decisions'));
66
+ if (!head.length && f.done) head.push(plural(f.done, 'task', 'tasks') + ' done');
67
+ if (!head.length && f.reviews) head.push(plural(f.reviews, 'review', 'reviews'));
68
+ if (!head.length && f.writing) head.push(plural(f.writing, 'note', 'notes') + ' written');
69
+ return { key: 'week:' + f.week, go: 'week', week: f.week, title: 'Where your week went: ' + head.join(', '), sub: 'Your week by kind, and what moved.' };
70
+ }
71
+
72
+ /** The card: one row per kind with its count, most first, then what moved. A kind with nothing is left out (zero is silence). */
73
+ export function cardHtml(f, { esc = escDefault } = {}) {
74
+ if (!f || !f.total) return '<p class="yd-exp">Nothing to show for this week yet.</p>';
75
+ const kinds = [
76
+ { k: 'meetings', n: f.meetings, say: plural(f.meetings, 'meeting', 'meetings') + (f.meetings ? ', ' + hoursOf(f.minutes) : '') },
77
+ { k: 'decisions', n: f.decisions, say: plural(f.decisions, 'decision', 'decisions') },
78
+ { k: 'reviews', n: f.reviews, say: plural(f.reviews, 'review of what PMOS proposed', 'reviews of what PMOS proposed') },
79
+ { k: 'writing', n: f.writing, say: plural(f.writing, 'note written', 'notes written') },
80
+ { k: 'done', n: f.done, say: plural(f.done, 'task done', 'tasks done') },
81
+ ].filter((x) => x.n > 0);
82
+ // most first: where the week went is the order
83
+ kinds.sort((a, b) => b.n - a.n);
84
+ const bars = kinds.map((x) => `<li class="mv-row" data-ww="${esc(x.k)}"><span class="mv-say">${esc(x.say)}</span></li>`).join('');
85
+ return `<p class="yd-exp">The week of ${esc(f.week)}, from what PMOS already reads. Nothing was sent.</p><ul class="mv-list">${bars}</ul>`
86
+ + `<p class="yd-exp">${esc(f.line)}</p>`;
87
+ }
88
+
89
+ /** The card in the Viewer; opening it marks the week as looked. */
90
+ export function openWeek(lists, H = {}) {
91
+ const VW = window.czViewer;
92
+ const toast = H.toast || (() => {});
93
+ const f = foldOf(lists);
94
+ if (f) markLooked(f.week);
95
+ import('./use-log.js').then((U) => { if (U.startUseLog) U.startUseLog(); if (U.noteUse) U.noteUse('weekWentOpen'); }).catch(() => {}); // the health number, local only
96
+ if (!VW) { toast('The card could not open here.'); return; }
97
+ VW.open({ id: 'week:' + ((f && f.week) || ''), kind: 'Your week', title: 'Where your week went', icon: ICON, presses: [],
98
+ render: (b) => { b.innerHTML = cardHtml(f); } });
99
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Where the week went (initiative week-went-summary, done test W1-W5, N1, N2): the pure split, the read-only route in process on a scratch repository and runtime folder, the Today row and the card. No server, browser, model or network.",
3
+ "modules": [
4
+ "week-went.test.js"
5
+ ],
6
+ "seconds": {
7
+ "week-went.test.js": 5
8
+ }
9
+ }