create-pmos 0.702.0 → 0.704.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.702.0",
3
+ "version": "0.704.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,21 @@
34
34
  ],
35
35
  "pmosChanges": [
36
36
  {
37
- "v": "0.702.0",
38
- "at": "2026-11-22T10:47:57.549Z",
37
+ "v": "0.704.0",
38
+ "at": "2026-11-22T11:01:29.367Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1534,
43
+ "t": "A weekly what-moved list in Your move (A441)",
44
+ "s": "A weekly what-moved list in Your move (A441)",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.703.0",
51
+ "at": "2026-11-22T10:51:01.624Z",
39
52
  "f": 4,
40
53
  "prs": [
41
54
  {
@@ -43,6 +56,12 @@
43
56
  "t": "Lists stay short, 50 rows a step from one shared block (A455)",
44
57
  "s": "Lists stay short, 50 rows a step from one shared block (A455)",
45
58
  "k": "new"
59
+ },
60
+ {
61
+ "n": 1530,
62
+ "t": "Esc and Stage in Backlog and This sprint; tests for the Gantt parent bar and the bulk stage move",
63
+ "s": "Esc and Stage in Backlog and This sprint; tests for the Gantt parent bar and the bulk stage move",
64
+ "k": "fix"
46
65
  }
47
66
  ]
48
67
  },
@@ -423,25 +442,6 @@
423
442
  "k": "new"
424
443
  }
425
444
  ]
426
- },
427
- {
428
- "v": "0.658.0",
429
- "at": "2026-11-22T03:38:17.292Z",
430
- "f": 4,
431
- "prs": [
432
- {
433
- "n": 1441,
434
- "t": "Goals is built from the design system's blocks",
435
- "s": "Goals is built from the design system's blocks",
436
- "k": "new"
437
- },
438
- {
439
- "n": 1443,
440
- "t": "Events is built from the design system's blocks",
441
- "s": "Events is built from the design system's blocks",
442
- "k": "new"
443
- }
444
- ]
445
445
  }
446
446
  ]
447
447
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@6e3bdc58
1
+ kernel-source: pmos@91a27644
2
2
  assembled: 2026-11-22
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-22T10:47:54Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T11:01:25Z"}
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-22T10:47:54Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T11:01:25Z"}
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-22T10:47:54Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T11:01:25Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,7 +1,20 @@
1
1
  [
2
2
  {
3
- "v": "0.702.0",
4
- "at": "2026-11-22T10:47:57.549Z",
3
+ "v": "0.704.0",
4
+ "at": "2026-11-22T11:01:29.367Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1534,
9
+ "t": "A weekly what-moved list in Your move (A441)",
10
+ "s": "A weekly what-moved list in Your move (A441)",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.703.0",
17
+ "at": "2026-11-22T10:51:01.624Z",
5
18
  "f": 4,
6
19
  "prs": [
7
20
  {
@@ -9,6 +22,12 @@
9
22
  "t": "Lists stay short, 50 rows a step from one shared block (A455)",
10
23
  "s": "Lists stay short, 50 rows a step from one shared block (A455)",
11
24
  "k": "new"
25
+ },
26
+ {
27
+ "n": 1530,
28
+ "t": "Esc and Stage in Backlog and This sprint; tests for the Gantt parent bar and the bulk stage move",
29
+ "s": "Esc and Stage in Backlog and This sprint; tests for the Gantt parent bar and the bulk stage move",
30
+ "k": "fix"
12
31
  }
13
32
  ]
14
33
  },
@@ -21,6 +21,8 @@ In the terminal, `pmos task set <task> --parent <task>` sets the parent, and `--
21
21
 
22
22
  To select tasks, Cmd-click or Ctrl-click each one, or Shift-click to select a range. This works in the Work breakdown's List and Gantt, in Work › Backlog and in This sprint. A bar shows the number of selected tasks. Use it to put the tasks under a parent, move them to a stage, give them to a person, move their dates by a number of days, or mark them done. One **Undo** puts all of them back. Press Esc to clear the selection.
23
23
 
24
+ To move tasks to a stage, select tasks of one initiative. The stages are the stages of that initiative.
25
+
24
26
  PMOS does not change the stage, owner or status of a Jira ticket. It skips these tickets and tells you why.
25
27
 
26
28
  ## Jira tickets in the breakdown
@@ -49,6 +49,7 @@ Home, the Board, Insights and the Viewer use one typeface, Plus Jakarta Sans, wi
49
49
  - **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.
50
50
  - **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.
51
51
  - **Done** lists what PMOS finished by itself in the last 14 days, one line each with Undo.
52
+ - **What moved last week.** Once a week, one row says how many dates and scope changes (tasks added, removed or put back) happened last week on all your products, and how many have no source, for example "Last week: 14 moves in dates and scope" with "3 with no source. See who to ask." under it. Press it to see one list, grouped by product, with the moves that have no source first. Each move shows its source (your own change, the tracker, or the Jira ticket, meeting note or document it names), or **No source** and the owner to ask. A move PMOS made with no reason is always **No source**. After you open the list, the row goes away until next week. In a week with no moves, there is no row. From a terminal: `node workspace/lib/week-moves.js list` in a product's repository.
52
53
  - An outbox draft opens with who it is for and the words. **Copy** puts the words on the clipboard, so you send them from your own tool. ✕ discards it, with Undo. Nothing leaves PMOS by itself.
53
54
 
54
55
  ## Mentions
@@ -10,7 +10,8 @@
10
10
  * - the initiative rows (lib/initiative-rows.js: live, accepted, stopped, last activity, the record) minus the ones the PM deleted;
11
11
  * - closing: the boards ledger's ini-end lines (a dated "won't do"), the acceptances ledger and the row's stopped date;
12
12
  * - Jira: the snapshot each linked initiative keeps (lib/jira-status.js), its ticket table line cited.
13
- * A source that cannot be read is named in notRead, never guessed. */
13
+ * Each task line also keeps who wrote it (by), its reason (why), the owner it names, tracker and what it cites, for the weekly what-moved
14
+ * list (lib/week-moves.js). A source that cannot be read is named in notRead, never guessed. */
14
15
  const fs = require('fs');
15
16
  const path = require('path');
16
17
 
@@ -32,6 +33,13 @@ function jsonLines(file) {
32
33
  }
33
34
  const atOf = (o) => { const t = Date.parse(o && o.at); return Number.isFinite(t) ? t : null; };
34
35
  const lineSrc = (root, file, l) => ({ ref: rel(root, file) + ':' + l.n, quote: cut(l.text) });
36
+ /** What a task line cites by itself: its `src`/`source`/`sources` (a string, a { label, ref } or a list of either). [] when none. */
37
+ function citesOf(o) {
38
+ const out = [];
39
+ const add = (s) => { if (typeof s === 'string' && s.trim()) out.push(s.trim().slice(0, 120)); else if (s && typeof s === 'object' && !Array.isArray(s)) { const t = [s.label, s.ref].filter((v) => typeof v === 'string' && v.trim()).join(' '); if (t) out.push(t.slice(0, 120)); } };
40
+ for (const k of ['src', 'source', 'sources']) { const v = o[k]; if (Array.isArray(v)) v.forEach(add); else add(v); }
41
+ return out;
42
+ }
35
43
 
36
44
  function tasksOf(root, boardFile, storeFile, notRead) {
37
45
  const board = boardFile ? jsonLines(boardFile) : [];
@@ -56,7 +64,10 @@ function tasksOf(root, boardFile, storeFile, notRead) {
56
64
  if (!t) continue;
57
65
  if (o.kind === 'task-update' && typeof o.initiative === 'string' && o.initiative) t.initiative = o.initiative;
58
66
  if (o.kind === 'task-update' && typeof o.title === 'string' && o.title.trim()) t.title = o.title.trim();
59
- t.lines.push({ at, kind: o.kind, state: typeof o.state === 'string' ? (o.state === 'In review' ? 'In progress' : o.state) : undefined, due: typeof o.due === 'string' ? o.due : undefined, src: lineSrc(root, file, l) });
67
+ t.lines.push({ at, kind: o.kind, state: typeof o.state === 'string' ? (o.state === 'In review' ? 'In progress' : o.state) : undefined, due: typeof o.due === 'string' ? o.due : undefined, src: lineSrc(root, file, l),
68
+ // who wrote it, why, the owner it names and what it cites: lib/week-moves.js reads them (initiative weekly-what-moved)
69
+ by: typeof o.by === 'string' ? o.by : '', why: typeof o.why === 'string' ? o.why : '', owner: typeof o.owner === 'string' ? o.owner : undefined,
70
+ tracker: o.tracker === true, cites: citesOf(o) });
60
71
  }
61
72
  for (const t of tasks.values()) { const m = milestone.get(t.id); t.milestone = !!(m && m.v); }
62
73
  return { tasks: [...tasks.values()], board: board || [] };
@@ -8,6 +8,8 @@
8
8
  * POST /api/drift/drop { id } → { ok } ⋯ "Not right, drop it": it never comes back (PRD R5)
9
9
  * POST /api/drift/undo { id } → { ok } the drop taken back
10
10
  * POST /api/drift/looked { week } → { ok } the card was shown for that week
11
+ * GET /api/drift/moves?ws=<id>[&week=YYYY-MM-DD] → { ok, ws, name, week, notRead, moves, total, unsourced } the weekly what-moved list of
12
+ * one product (initiative weekly-what-moved, lib/week-moves.js): last week by default; read-only
11
13
  *
12
14
  * THE SWITCH. PMOS_DRIFT=off, or the shared guard's switch (lib/ai-guard.js off: PMOS_AI, the ai settings): every GET answers { ok, on: false }
13
15
  * and every POST 409. WHO WRITES: a POST that carries an agent session header is refused (403); pm-guard requirePagePress checks the page. */
@@ -34,6 +36,29 @@ async function handle(req, res, url, ctx) {
34
36
  const F = dir ? D.read(dir) : D.fold([]);
35
37
  return send({ status: 200, body: { ok: true, on: true, check: D.checkView(F, D.weekOf(nowMs(ctx))) } });
36
38
  }
39
+ if (what === 'moves') {
40
+ // the weekly what-moved list (initiative weekly-what-moved, lib/week-moves.js): read-only, no model, so the drift switch does not gate it
41
+ if (req.method !== 'GET') return send(bad(405, 'GET only'));
42
+ let w = null;
43
+ try { w = ctx.getWs(url.searchParams.get('ws') || null); } catch { w = null; }
44
+ if (!w || !w.root) return send(bad(404, 'no such workspace'));
45
+ const day = url.searchParams.get('week');
46
+ if (day && !/^\d{4}-\d{2}-\d{2}$/.test(day)) return send(bad(400, 'week is a day YYYY-MM-DD'));
47
+ const WM = require('./week-moves.js');
48
+ try {
49
+ const W = day ? WM.weekOfDay(day) : WM.lastWeek(nowMs(ctx));
50
+ const stateDir = ctx.stateDirFor ? ctx.stateDirFor(w) : null;
51
+ // the rows as already read (no synchronous derive on a request): while they are being read, titles fall back to the initiative id
52
+ let rows = [];
53
+ try { const IR = require('./initiative-rows.js').rowsFor(w.root); rows = IR && IR.ok ? IR.rows : []; } catch { rows = []; }
54
+ const f = require('./drift-facts.js').factsOf({ id: w.id, name: w.name || w.id, root: w.root }, { stateDir, rows });
55
+ const r = WM.movesOf(f, W);
56
+ return send({ status: 200, body: { ok: true, ws: w.id, name: w.name || w.id, week: W.week, notRead: f.notRead, moves: r.moves, total: r.total, unsourced: r.unsourced } });
57
+ } catch (e) {
58
+ console.warn(WM.TAG + ' could not read the moves of ' + w.id + ': ' + ((e && e.message) || e));
59
+ return send(bad(500, 'The moves could not be read.'));
60
+ }
61
+ }
37
62
  if (!['drop', 'undo', 'looked'].includes(what)) return send(bad(404, 'no such drift route'));
38
63
  if (req.method !== 'POST') return send(bad(405, 'POST only'));
39
64
  if (req.headers && req.headers['x-pmos-session']) return send(bad(403, 'Only you drop an item, from the page.'));
@@ -0,0 +1,147 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* week-moves.js — the weekly what-moved list (initiative weekly-what-moved; bet A441). READ-ONLY: it writes nothing anywhere.
4
+ *
5
+ * Once a week the PM sees one short list of every date and scope change of the past week, on every product: each with its source, or a
6
+ * "No source" flag and the owner to ask. Products record about 5 to 20 such moves a week (proof T38), so one list stays readable.
7
+ *
8
+ * movesOf(facts, { from, to }) → { from, to, moves: [row], total, unsourced } PURE. facts: lib/drift-facts.js factsOf, one or a list
9
+ * lastWeek(now) → { week, from, to } the Monday (local) of the week before the week of now, and its bounds in ms
10
+ * weekOfDay(day) → { week, from, to } the week that holds YYYY-MM-DD
11
+ * forRepo(root, { week? , now? }) → movesOf of one checkout (its state folder found as `pmos drift` finds it)
12
+ *
13
+ * A ROW: { at, kind, product, name, ini, iniTitle, task, title, n, titles, was, now, say, by, source, sourced, owner, toPm, why, ref, quote }
14
+ * kind date (a due date that moved: was → now; a date set for the first time is not a move) · added · removed · restored (scope)
15
+ * n the scope rows of one initiative, one kind, one writer and one source fold into one row: n tasks, the first titles in `titles`
16
+ * by who made it: 'you' (the PM), 'the tracker', 'PMOS' (an agent), or the name a line carries
17
+ * source what it rests on: 'Your own change', the tracker, the kind of source its reason names (lib/source-guard.js kindOf), or what the
18
+ * line cites; null when it rests on nothing. An agent's move with no reason, "No reason found…", or only the plan itself (two
19
+ * dates that meet are a guess) is not sourced.
20
+ * owner who to ask: the task's owner, else the PM ('you', toPm) when the plan names nobody or names an agent
21
+ * ref path:line of the line it came from, and `quote` that line's text (lib/drift-facts.js)
22
+ *
23
+ * CLI: node lib/week-moves.js list|count [<root>] [--week YYYY-MM-DD] [--json]. `count` ends with the number of moves on its last line.
24
+ * Every log line carries [moves]. */
25
+ const path = require('path');
26
+ const D = require('./drift.js');
27
+ const SG = require('./source-guard.js');
28
+
29
+ const TAG = '[moves]';
30
+ const SCOPE = { task: 'added', 'task-remove': 'removed', 'task-restore': 'restored' };
31
+ const SCOPE_WORDS = { added: ['task added', 'tasks added'], removed: ['task removed', 'tasks removed'], restored: ['task put back', 'tasks put back'] };
32
+ const NO_REASON = /^\s*no reason\b/i;
33
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
34
+ const isDate = (s) => /^\d{4}-\d{2}-\d{2}/.test(String(s || ''));
35
+ const clip = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).trimEnd() + '…' : t; };
36
+ /** 5 Nov, or 5 Nov 2027 when the year is not `year`. */
37
+ function short(s, year) {
38
+ if (!isDate(s)) return 'none';
39
+ const [y, m, d] = String(s).slice(0, 10).split('-').map(Number);
40
+ return d + ' ' + MON[m - 1] + (year && y !== year ? ' ' + y : '');
41
+ }
42
+
43
+ /** The week before the week of `now` (the PM's Monday, local time). */
44
+ function lastWeek(now = Date.now()) { const week = D.prevWeek(D.weekOf(now)); return { week, from: D.weekStart(week), to: D.weekEnd(week) }; }
45
+ /** The week that holds the day YYYY-MM-DD. */
46
+ function weekOfDay(day) { const week = D.weekOf(D.weekStart(String(day).slice(0, 10)) + 12 * 3600000); return { week, from: D.weekStart(week), to: D.weekEnd(week) }; }
47
+
48
+ /** Who made a line, and what it rests on. PURE. */
49
+ function sourceOf(l) {
50
+ const by = String(l.by || '');
51
+ if (l.tracker || /^tracker:/.test(by)) { const t = by.replace(/^tracker:/, '') || 'jira'; const name = t === 'jira' ? 'Jira' : t; return { by: 'the tracker', source: name, sourced: true }; }
52
+ if (/^pm:/.test(by)) return { by: 'you', source: 'Your own change', sourced: true };
53
+ const agent = !by || /^(agent:|pmos:|claude\b)/i.test(by);
54
+ const cites = (l.cites || []).filter((c) => !NO_REASON.test(c) && !SG.noReason(c));
55
+ if (cites.length) return { by: agent ? 'PMOS' : by, source: clip(cites[0], 80), sourced: true };
56
+ const why = String(l.why || '');
57
+ if (!agent) return { by, source: by + "'s own change", sourced: true }; // a named person changed it: they are the source to ask
58
+ if (!why.trim() || SG.noReason(why) || NO_REASON.test(why)) return { by: 'PMOS', source: null, sourced: false };
59
+ const kind = SG.kindOf(why);
60
+ if (kind === 'other' || kind === 'plan') return { by: 'PMOS', source: null, sourced: false };
61
+ return { by: 'PMOS', source: SG.KIND_NAMES[kind] || kind, sourced: true };
62
+ }
63
+
64
+ /** Who to ask about a task: its owner, else the PM. */
65
+ function ownerOf(owner) {
66
+ const o = String(owner || '').trim();
67
+ if (!o || /^(pm:|agent:|claude\b|pmos\b)/i.test(o) || o === 'you') return { owner: 'you', toPm: true };
68
+ return { owner: clip(o, 60), toPm: false };
69
+ }
70
+
71
+ /** The date and scope moves of one product inside [from, to). PURE. */
72
+ function productMoves(f, from, to) {
73
+ const titles = new Map((f.initiatives || []).map((i) => [i.id, i.title || i.id]));
74
+ const rows = [], scope = new Map();
75
+ for (const t of f.tasks || []) {
76
+ const lines = (t.lines || []).filter((l) => Number.isFinite(l.at)).slice().sort((a, b) => a.at - b.at);
77
+ let due, owner;
78
+ for (const l of lines) {
79
+ if (typeof l.owner === 'string' && l.owner.trim()) owner = l.owner;
80
+ const inWeek = l.at >= from && l.at < to;
81
+ const base = () => ({ at: new Date(l.at).toISOString(), product: f.ws, name: f.name || f.ws, ini: t.initiative, iniTitle: titles.get(t.initiative) || t.initiative,
82
+ task: t.id, title: t.title, why: clip(l.why, 200), ref: (l.src && l.src.ref) || '', quote: (l.src && l.src.quote) || '', ...sourceOf(l), ...ownerOf(owner) });
83
+ if (inWeek && SCOPE[l.kind]) {
84
+ const b = base(), kind = SCOPE[l.kind];
85
+ const key = [t.initiative, kind, b.by, b.source || ''].join('|');
86
+ const g = scope.get(key);
87
+ if (g) { g.n++; if (g.titles.length < 3) g.titles.push(t.title); if (b.at > g.at) g.at = b.at; if (!b.toPm && g.toPm) { g.owner = b.owner; g.toPm = false; } }
88
+ else scope.set(key, { ...b, kind, n: 1, titles: [t.title], was: null, now: null });
89
+ }
90
+ if (l.due !== undefined) {
91
+ const next = isDate(l.due) ? String(l.due).slice(0, 10) : '';
92
+ if (inWeek && l.kind === 'task-update' && due !== undefined && next !== due) rows.push({ ...base(), kind: 'date', n: 1, titles: [t.title], was: due || null, now: next || null });
93
+ due = next;
94
+ }
95
+ }
96
+ }
97
+ return rows.concat([...scope.values()]);
98
+ }
99
+
100
+ function sayOf(r, year) {
101
+ if (r.kind === 'date') return r.now ? (r.was ? `Due ${short(r.was, year)} → ${short(r.now, year)}` : `Due set to ${short(r.now, year)}`) : `Due ${short(r.was, year)} taken off`;
102
+ const w = SCOPE_WORDS[r.kind];
103
+ return r.n === 1 ? w[0][0].toUpperCase() + w[0].slice(1) : `${r.n} ${w[1]}`;
104
+ }
105
+
106
+ /** facts: one lib/drift-facts.js factsOf result, or a list of them. → { from, to, moves, total, unsourced } PURE. */
107
+ function movesOf(facts, { from, to } = {}) {
108
+ const list = Array.isArray(facts) ? facts : [facts];
109
+ const year = new Date(Number.isFinite(from) ? from : Date.now()).getFullYear();
110
+ const moves = [];
111
+ for (const f of list) if (f) moves.push(...productMoves(f, from, to));
112
+ moves.sort((a, b) => (a.sourced === b.sourced ? 0 : a.sourced ? 1 : -1) || String(a.name).localeCompare(String(b.name)) || (a.at < b.at ? 1 : a.at > b.at ? -1 : 0));
113
+ for (const m of moves) m.say = sayOf(m, year);
114
+ const total = moves.reduce((s, m) => s + m.n, 0), unsourced = moves.filter((m) => !m.sourced).reduce((s, m) => s + m.n, 0);
115
+ return { from: new Date(from).toISOString(), to: new Date(to).toISOString(), moves, total, unsourced };
116
+ }
117
+
118
+ /** One checkout's list for a week (last week when none is named). Reads its ledgers; writes nothing. */
119
+ function forRepo(root, { week, now = Date.now(), name } = {}) {
120
+ const Dr = require('./driver.js');
121
+ const stateDir = Dr.stateDirOf(root);
122
+ const W = week ? weekOfDay(week) : lastWeek(now);
123
+ const f = require('./drift-facts.js').factsOf({ id: Dr.wsIdOf(root), name: name || path.basename(root), root }, { stateDir });
124
+ return { week: W.week, notRead: f.notRead, ...movesOf(f, W) };
125
+ }
126
+
127
+ function main(argv, { say = (s) => console.log(s), cwd = process.cwd(), now = Date.now() } = {}) {
128
+ const pos = [], flags = {};
129
+ for (let i = 0; i < argv.length; i++) { const a = argv[i]; if (a === '--json') flags.json = true; else if (a === '--week') flags.week = argv[++i]; else pos.push(a); }
130
+ const [sub = 'list', rootArg] = pos;
131
+ if (!['list', 'count'].includes(sub) || (flags.week !== undefined && !/^\d{4}-\d{2}-\d{2}$/.test(String(flags.week)))) {
132
+ say('usage: node lib/week-moves.js list|count [<root>] [--week YYYY-MM-DD] [--json] — last week\'s date and scope moves, each with its source or "No source"');
133
+ return 2;
134
+ }
135
+ const root = path.resolve(cwd, rootArg || '.');
136
+ let r;
137
+ try { r = forRepo(root, { week: flags.week, now }); } catch (e) { say(`${TAG} could not read ${root}: ${(e && e.message) || e}`); return 1; }
138
+ if (flags.json) { say(JSON.stringify(sub === 'count' ? { week: r.week, total: r.total, unsourced: r.unsourced, notRead: r.notRead } : r)); return 0; }
139
+ if (sub === 'list') for (const m of r.moves) say(`${m.sourced ? ' ' : '!'} ${m.name} · ${m.iniTitle} · ${m.say} · ${m.n === 1 ? m.title : m.titles.join(', ')} · ${m.sourced ? m.source : 'No source · ask ' + m.owner} [${m.ref}]`);
140
+ say(`${TAG} week of ${r.week}: ${r.total} ${r.total === 1 ? 'move' : 'moves'} in dates and scope, ${r.unsourced} with no source${r.notRead.length ? ' (not read: ' + r.notRead.join(', ') + ')' : ''}`);
141
+ if (sub === 'count') say(String(r.total));
142
+ return 0;
143
+ }
144
+
145
+ module.exports = { movesOf, lastWeek, weekOfDay, forRepo, sourceOf, ownerOf, main, TAG };
146
+
147
+ if (require.main === module) process.exitCode = main(process.argv.slice(2));
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.702.0",
3
+ "version": "0.704.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.702.0",
9
+ "version": "0.704.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.702.0",
3
+ "version": "0.704.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",
@@ -344,7 +344,7 @@ function drawBar() {
344
344
  if (!n || !on()) { if (bar) { bar.remove(); bar = null; } return; }
345
345
  if (!bar) { bar = document.createElement('div'); bar.className = 'bk-bar'; bar.setAttribute('role', 'toolbar'); bar.setAttribute('aria-label', 'Ticked tasks'); document.body.appendChild(bar); bar.addEventListener('click', barPress); }
346
346
  bar.innerHTML = `<span class="c">${n} selected</span><button type="button" class="pm" data-bkb="give">${SPARK} Give to PMOS</button><button type="button" data-bkb="person">Give to a person</button>`
347
- + `<button type="button" data-bkb="ini">Move to initiative</button><button type="button" data-bkb="parent">Under a parent</button><button type="button" data-bkb="date">Set date</button><button type="button" data-bkb="shift">Move dates</button>`
347
+ + `<button type="button" data-bkb="ini">Move to initiative</button><button type="button" data-bkb="parent">Under a parent</button><button type="button" data-bkb="section">Stage</button><button type="button" data-bkb="date">Set date</button><button type="button" data-bkb="shift">Move dates</button>`
348
348
  + `<button type="button" data-bkb="done">Done</button><button type="button" data-bkb="archive">Archive</button>`
349
349
  + `<button type="button" class="x" data-bkb="clear" aria-label="Clear the ticks" title="Clear">${SV(I.x)}</button>`;
350
350
  }
@@ -366,6 +366,16 @@ async function barPress(e) {
366
366
  pickPop(b, 'Under a parent', [['', 'Top level (no parent)']].concat(L), async (v) => { const p = v ? DATA.tasks.find((t) => uidOf(t) === v) : null; await bulkMany(T, 'parent', p ? p.id : '', p ? p.title : 'the top level'); });
367
367
  return;
368
368
  }
369
+ if (k === 'section') {
370
+ // the bulk move to a stage (WorkBulkDS): the stages of the one initiative the picked tasks share; Jira tickets keep the stage Jira gives them
371
+ const inis = new Set(T.map((t) => t.ini || '')), ini = [...inis][0], t0 = T[0];
372
+ if (inis.size !== 1 || !ini) { AP().say('Pick tasks of one initiative to move them to a stage.'); return; }
373
+ let st = [];
374
+ try { const r = await (await fetch('/api/boards/items?ws=' + encodeURIComponent(t0.ws) + '&board=' + encodeURIComponent(t0.board), { credentials: 'same-origin' })).json(); st = (((r && r.initiatives) || []).find((x) => x.id === ini) || {}).stages || []; } catch { st = []; }
375
+ if (!st.length) { AP().say('This initiative has no stages to move tasks to.'); return; }
376
+ pickPop(b, 'Stage', [['', 'Not in a stage']].concat(st.map((x) => [x.key, x.name])), async (v) => { const x = st.find((y) => y.key === v); await bulkMany(T, 'section', v, x ? x.name : 'no stage'); });
377
+ return;
378
+ }
369
379
  if (k === 'shift') { pickPop(b, 'Move dates', [['-7', '1 week earlier'], ['-1', '1 day earlier'], ['1', '1 day later'], ['7', '1 week later']], async (v) => { const n = WS.shiftOf(v); if (n != null) await bulkMany(T, 'shift', n); }, { free: 'Days: +3, -2, 1w' }); return; }
370
380
  if (k === 'done') { await bulkMany(T, 'done', null); }
371
381
  }
@@ -712,6 +722,11 @@ export function sync(api) {
712
722
  const fb = document.getElementById('bdFilter');
713
723
  if (fb) fb.addEventListener('click', (e) => { if (!on() || !DATA) return; e.stopImmediatePropagation(); e.preventDefault(); if (pop && pop.classList.contains('bk-tune')) closePop(); else tune(fb); }, true);
714
724
  document.addEventListener('click', (e) => { if (pop && !pop.contains(e.target) && !e.target.closest('[data-bkb],#bdFilter,[data-bkmenu],[data-bkmode]')) closePop(); });
725
+ // Esc clears the picked rows in Backlog and This sprint (WorkBulkDS), as the bar's × does; an open pop list or a text field keeps its own Esc
726
+ document.addEventListener('keydown', (e) => {
727
+ if (e.key !== 'Escape' || e.defaultPrevented || !SEL.size || !on() || pop || (e.target && e.target.closest && e.target.closest('input, textarea, select, [role="dialog"]'))) return;
728
+ SEL.clear(); ANCHOR = ''; draw();
729
+ });
715
730
  }
716
731
  apply();
717
732
  if (on() && DATA && Date.now() - loadedAt > 3000) load();
@@ -212,10 +212,11 @@ const xOf = (W) => { const a = Date.parse(W.span.a), b = Date.parse(W.span.b); r
212
212
  function barHtml(x, W) {
213
213
  const X = xOf(W);
214
214
  if (x.kind === 'stage') return x.start || x.end ? CB.stageBar({ start: x.start, end: x.end, tone: x.tone, late: x.late, ms: x.ms, name: x.name, gaps: x.gaps, marks: x.open ? [] : x.marks }, X, { today: W.today }) : '';
215
- // a parent (WorkSubtasksDS): one outlined bar from its earliest subtask start to its latest end, filled as its subtasks finish
215
+ // a parent (WorkSubtasksDS): one outlined bar from its earliest subtask start to the end of its latest subtask's last day (as a task bar
216
+ // ends), filled as its subtasks finish
216
217
  if (x.kids) {
217
218
  if (!x.start && !x.end) return '';
218
- const l = Math.max(0, X(x.start || x.end)), r = Math.min(100, X(x.end || x.start) + 0.6), f = x.nLeaf ? Math.round((x.nDone / x.nLeaf) * 100) : 0;
219
+ const l = Math.max(0, X(x.start || x.end)), r = Math.min(100, X(new Date(Date.parse(String(x.end || x.start).slice(0, 10)) + 864e5).toISOString())), f = x.nLeaf ? Math.round((x.nDone / x.nLeaf) * 100) : 0;
219
220
  return `<i class="pw-pbar${x.done ? ' dn' : ''}" style="left:${l.toFixed(2)}%;width:${Math.max(0.8, r - l).toFixed(2)}%" title="${esc(x.title + ': ' + x.count)}"><b style="width:${f}%"></b></i>`;
220
221
  }
221
222
  return CB.taskBar(x, X, W.today);
@@ -438,6 +438,8 @@ function rankIn() {
438
438
  if (S.impact && S.impact.c && !S.impact.c.looked) extra.push({ key: 'impact', go: 'impact', title: 'Your impact: ' + S.impact.c.label + ' is ready to check', sub: 'A thank-you and what really moved, from your records.' });
439
439
  const lp = LPV.chipOf(); if (lp) extra.push({ key: 'loose', go: 'loose', title: lp.n + (lp.n === 1 ? ' loose row' : ' loose rows') + ' to place in an initiative', sub: 'PMOS proposes where each one belongs.' });
440
440
  for (const l of S.lab || []) extra.push({ key: 'lab:' + l.ws, go: 'lab', ws: l.ws, board: l.board, title: l.n + (l.n === 1 ? ' Lab finding' : ' Lab findings') + ' to keep or drop', sub: l.say || 'Keep one to start an initiative, or let it go.' });
441
+ // weekly-what-moved (A441): last week's date and scope moves of every product, one row until the PM opens the list (pm/moves-view.js)
442
+ if (S.movesRow) extra.push(S.movesRow);
441
443
  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 };
442
444
  }
443
445
  /** Each product's GET /api/your-move, read when Your day opens (never on Home's first draw: page speed). */
@@ -459,10 +461,15 @@ async function readMove() {
459
461
  // agent-run (AwA, R4): the runs that stopped, one amber line in Claude did
460
462
  next[ws] = { verdicts: r.verdicts || [], kr: r.kr || null, expired: r.expired || [], done, notices: A ? A.notices || [] : [], failed: A ? A.failed || [] : [] };
461
463
  });
464
+ // weekly-what-moved (A441): each product's last week of date and scope moves (GET /api/drift/moves), folded into one Your move row
465
+ const mv = await Promise.all(L.map((ws) => pmGet('/api/drift/moves' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)));
466
+ S.moves = mv.filter((r) => r && r.ok);
467
+ const prevMoves = JSON.stringify(S.movesRow || null);
468
+ try { const MV = await import('./moves-view.js'); S.movesRow = MV.rowOf(S.moves, { looked: MV.lookedWeek() }); } catch { S.movesRow = null; }
462
469
  const ob = await pmGet('/api/outbox').catch(() => null);
463
470
  const outbox = ob && ob.ok && Array.isArray(ob.entries) ? ob.entries.filter((e) => e && (e.state === 'queued' || e.state === 'blocked')) : [];
464
471
  const lab = labs.filter(Boolean);
465
- const same = JSON.stringify(next) === JSON.stringify(S.move || null) && JSON.stringify(outbox) === JSON.stringify(S.outbox || []) && JSON.stringify(lab) === JSON.stringify(S.lab || []);
472
+ 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);
466
473
  S.move = next; S.outbox = outbox; S.lab = lab;
467
474
  if (!same) { redrawLater(); drawList(); }
468
475
  // a demotion notice is said once: drawn now, then marked seen so the next read leaves it out
@@ -499,6 +506,7 @@ async function movePress(b) {
499
506
  if (r.kind === 'extra') {
500
507
  if (r.go === 'impact') { S.day = false; S.sel = 'impact'; if (isPhone()) S.phoneChat = true; openTarget(homeTarget()); drawList(); return; }
501
508
  if (r.go === 'loose') { VW.drill(); LPV.open(lpHost); return; }
509
+ if (r.go === 'moves') { VW.drill(); import('./moves-view.js').then((MV) => { MV.openMoves(S.moves || [], { toast }); S.movesRow = null; drawList(); }); return; }
502
510
  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; }
503
511
  return;
504
512
  }
@@ -0,0 +1,62 @@
1
+ /* pm/moves-view.js — the weekly what-moved list (initiative weekly-what-moved; bet A441). Pure apart from openMoves: Node imports it
2
+ * (drift.test.js, cases M8).
3
+ *
4
+ * rowOf(lists, { looked }) → the Your move row ({ key, go, title, sub }) or null: null in a quiet week (zero is silence) and once the
5
+ * PM opened this week's list. lists: each product's GET /api/drift/moves answer.
6
+ * listHtml(lists, { esc }) → the list, one section per product, the moves with no source first; each says its source, or
7
+ * "No source · ask <owner>"
8
+ * openMoves(lists, H) the list in the Viewer. H: { toast }
9
+ * lookedWeek() · markLooked(week) which week the PM opened (this browser only; a missing store reads as not looked)
10
+ * Nothing here writes a record or sends anything. */
11
+
12
+ const KEY = 'pmos.moves.looked';
13
+ const escDefault = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
14
+ const ICON = 'M3 12h4l3-8 4 16 3-8h4';
15
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
16
+ const ok = (l) => l && l.ok && Array.isArray(l.moves);
17
+
18
+ export function lookedWeek() { try { return localStorage.getItem(KEY) || ''; } catch { return ''; } }
19
+ export function markLooked(week) { try { if (week) localStorage.setItem(KEY, week); } catch { /* this browser keeps no store */ } }
20
+
21
+ /** The Your move row for last week's moves, or null. */
22
+ export function rowOf(lists, { looked = '' } = {}) {
23
+ const L = (lists || []).filter(ok);
24
+ const total = L.reduce((s, l) => s + (l.total || 0), 0);
25
+ if (!total) return null;
26
+ const week = (L.find((l) => l.week) || {}).week || '';
27
+ if (week && looked === week) return null;
28
+ const unsourced = L.reduce((s, l) => s + (l.unsourced || 0), 0);
29
+ return { key: 'moves:' + week, go: 'moves', week,
30
+ title: 'Last week: ' + plural(total, 'move', 'moves') + ' in dates and scope',
31
+ sub: unsourced ? unsourced + ' with no source. See who to ask.' : 'Each one has a source.' };
32
+ }
33
+
34
+ function moveHtml(m, esc) {
35
+ const what = m.n > 1 ? m.titles.join(', ') + (m.n > m.titles.length ? ', …' : '') : m.title;
36
+ const src = m.sourced ? esc(m.source) : `<strong>No source</strong> · ${m.toPm ? 'yours to check' : 'ask ' + esc(m.owner)}`;
37
+ return `<li class="mv-row${m.sourced ? '' : ' mv-flag'}"><span class="mv-say">${esc(m.say)}</span> · ${esc(what)}`
38
+ + `<br><span class="yd-exp">${esc(m.iniTitle)} · ${src}${m.by && m.by !== 'you' && m.sourced ? ' · by ' + esc(m.by) : ''}</span></li>`;
39
+ }
40
+
41
+ /** The list, one section per product. */
42
+ export function listHtml(lists, { esc = escDefault } = {}) {
43
+ const L = (lists || []).filter(ok).filter((l) => l.moves.length);
44
+ if (!L.length) return '<p class="yd-exp">Nothing moved in dates or scope last week.</p>';
45
+ const many = L.length > 1;
46
+ return L.map((l) => {
47
+ const rows = l.moves.slice().sort((a, b) => (a.sourced === b.sourced ? 0 : a.sourced ? 1 : -1));
48
+ const head = many ? `<h3>${esc(l.name || l.ws)}</h3>` : '';
49
+ const sum = `<p class="yd-exp">${esc(plural(l.total, 'move', 'moves'))}${l.unsourced ? ', ' + esc(String(l.unsourced)) + ' with no source' : ''}.</p>`;
50
+ return `<section class="mv-prod">${head}${sum}<ul class="mv-list">${rows.map((m) => moveHtml(m, esc)).join('')}</ul></section>`;
51
+ }).join('');
52
+ }
53
+
54
+ /** The list in the Viewer; opening it marks the week as looked. */
55
+ export function openMoves(lists, H = {}) {
56
+ const VW = window.czViewer;
57
+ const row = rowOf(lists);
58
+ if (row) markLooked(row.week);
59
+ if (!VW) { if (H.toast) H.toast('The list could not open here.'); return; }
60
+ VW.open({ id: 'moves:' + ((row && row.week) || ''), kind: 'What moved', title: 'What moved last week', icon: ICON, presses: [],
61
+ render: (b) => { b.innerHTML = listHtml(lists); } });
62
+ }