create-pmos 0.783.0 → 0.784.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.783.0",
3
+ "version": "0.784.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,24 +34,38 @@
34
34
  ],
35
35
  "pmosChanges": [
36
36
  {
37
- "v": "0.783.0",
38
- "at": "2026-11-24T16:37:58.744Z",
37
+ "v": "0.784.0",
38
+ "at": "2026-11-24T16:59:38.052Z",
39
39
  "f": 4,
40
40
  "prs": [
41
41
  {
42
- "n": 1778,
43
- "t": "Name the catalog and draft routes outside routes-*, so d86-seams check 7 passes",
44
- "s": "Name the catalog and draft routes outside routes-*, so d86-seams check 7 passes",
45
- "k": "fix",
42
+ "n": 1777,
43
+ "t": "PMOS proposes the scope cuts that save a date",
44
+ "s": "PMOS proposes the scope cuts that save a date",
45
+ "k": "new",
46
+ "h": "PMOS proposes the scope cuts that save a date",
46
47
  "try": {
47
48
  "steps": [
48
- "On Work, open an initiative whose Overview says Goal: Not written yet, and press ✓ on its ✦",
49
- "Wait for the line to say PMOS is drafting it, then read the goal it saved",
50
- "Press Undo on the toast"
49
+ "Open Work and open an initiative whose end date is still ahead but whose tasks run past it",
50
+ "Press its ✦ and find Cut to keep the date",
51
+ "Keep it, then press Undo"
51
52
  ],
52
- "see": "The goal line fills in by itself with no chat opening, and Undo puts it back to Not written yet",
53
+ "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",
53
54
  "open": "/premium-board.html"
54
55
  }
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ "v": "0.783.0",
61
+ "at": "2026-11-24T16:37:58.744Z",
62
+ "f": 4,
63
+ "prs": [
64
+ {
65
+ "n": 1778,
66
+ "t": "Name the catalog and draft routes outside routes-*, so d86-seams check 7 passes",
67
+ "s": "Name the catalog and draft routes outside routes-*, so d86-seams check 7 passes",
68
+ "k": "fix"
55
69
  },
56
70
  {
57
71
  "n": 1780,
@@ -407,28 +421,6 @@
407
421
  }
408
422
  }
409
423
  ]
410
- },
411
- {
412
- "v": "0.764.0",
413
- "at": "2026-11-24T06:08:25.279Z",
414
- "f": 4,
415
- "prs": [
416
- {
417
- "n": 1720,
418
- "t": "A risky change on shared text only asks the owner",
419
- "s": "A risky change on shared text only asks the owner",
420
- "k": "new",
421
- "try": {
422
- "steps": [
423
- "Say in a Slack channel PMOS reads, and in a meeting note, that a task with no Jira ticket is done",
424
- "Wait for the next PMOS round",
425
- "Open Today and look at today's questions"
426
- ],
427
- "see": "PMOS does not close the task by itself. Today's questions ask the owner whether it is done and say that only shared text (Slack and a meeting note) says so.",
428
- "open": "/premium-home.html"
429
- }
430
- }
431
- ]
432
424
  }
433
425
  ]
434
426
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@edfc951ef
1
+ kernel-source: pmos@b8a2cc4d0
2
2
  assembled: 2026-11-24
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-24T16:37:55Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T16:59:34Z"}
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-24T16:37:55Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T16:59:34Z"}
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-24T16:37:55Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T16:59:34Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,23 +1,37 @@
1
1
  [
2
2
  {
3
- "v": "0.783.0",
4
- "at": "2026-11-24T16:37:58.744Z",
3
+ "v": "0.784.0",
4
+ "at": "2026-11-24T16:59:38.052Z",
5
5
  "f": 4,
6
6
  "prs": [
7
7
  {
8
- "n": 1778,
9
- "t": "Name the catalog and draft routes outside routes-*, so d86-seams check 7 passes",
10
- "s": "Name the catalog and draft routes outside routes-*, so d86-seams check 7 passes",
11
- "k": "fix",
8
+ "n": 1777,
9
+ "t": "PMOS proposes the scope cuts that save a date",
10
+ "s": "PMOS proposes the scope cuts that save a date",
11
+ "k": "new",
12
+ "h": "PMOS proposes the scope cuts that save a date",
12
13
  "try": {
13
14
  "steps": [
14
- "On Work, open an initiative whose Overview says Goal: Not written yet, and press ✓ on its ✦",
15
- "Wait for the line to say PMOS is drafting it, then read the goal it saved",
16
- "Press Undo on the toast"
15
+ "Open Work and open an initiative whose end date is still ahead but whose tasks run past it",
16
+ "Press its ✦ and find Cut to keep the date",
17
+ "Keep it, then press Undo"
17
18
  ],
18
- "see": "The goal line fills in by itself with no chat opening, and Undo puts it back to Not written yet",
19
+ "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",
19
20
  "open": "/premium-board.html"
20
21
  }
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ "v": "0.783.0",
27
+ "at": "2026-11-24T16:37:58.744Z",
28
+ "f": 4,
29
+ "prs": [
30
+ {
31
+ "n": 1778,
32
+ "t": "Name the catalog and draft routes outside routes-*, so d86-seams check 7 passes",
33
+ "s": "Name the catalog and draft routes outside routes-*, so d86-seams check 7 passes",
34
+ "k": "fix"
21
35
  },
22
36
  {
23
37
  "n": 1780,
@@ -19,6 +19,7 @@ Press the ✦ to open "PMOS proposes N" in the Viewer. On a desk the chat stays
19
19
  - **Check these.** A maybe match, with its reason, and an item that is already in another initiative. A duplicate is linked, never copied. These need their own ✓.
20
20
  - **Not placed.** What PMOS could not fit. It is kept under Linked.
21
21
  - **Dates.** Each morning, and whenever a date passes, PMOS proposes new dates for tasks that are late or at risk (due within 3 days and not started), one proposal per stage. Each line names the task and its two days: "Move <task> from 24 Nov to 27 Nov". The reason is one line with its source. When PMOS finds no reason, it says "No reason found" and offers to ask the owner. When a new date reaches a task that waits on it, the proposal shows the link: keep it (the waiting task moves too) or ignore it (it stays and the two overlap). PMOS marks the one it recommends with a small ✦.
22
+ - **Cut to keep the date.** When an initiative's open tasks will finish after its date, and that date is still ahead, PMOS proposes "Cut 3 tasks to keep 12 Dec". It lists the tasks that finish after the date, and any task that waits on one of them. Each line shows when the task would end, where it moves to, and what the cut costs: "the PRD names it" (listed last) or a Jira ticket (PMOS drafts a comment and does not change the ticket). A ◇ milestone is never cut. Keep moves each task to the first working day after the date, with the same length, and adds a note that says why. Undo puts the dates and the notes back. This proposal is never in Keep all, and PMOS never applies it by itself. Remove a task you want to keep with its ✕. The date is the initiative's committed end, or else the latest due date of its tasks. Count the cuts you kept with `node lib/scope-cuts.js count`.
22
23
  - **Status.** "Looks done" when the evidence says the work happened, such as an email that was sent.
23
24
  - **Names.** Tidy names: the WBS number kept, verb first, about 7 words, no "+" and no brackets. The detail that is cut goes to the task's notes.
24
25
  - **Links.** The links between tasks that PMOS proposes.
@@ -13,6 +13,8 @@
13
13
  * section 'check' (Check these: a maybe, with its reason; a duplicate already in another initiative, LINKED, never copied: they
14
14
  * need their own ✓ and never ride on Keep all) and section 'unplaced' (Not placed: kept under Linked)
15
15
  * dates one proposal per stage: its late and at-risk tasks to new dates and its plan with them, plus what a moved task's links reach
16
+ * scope the scope cuts that save the date (lib/scope-cuts.js, idea A43): computed fresh like dates, never filed; type cut; section
17
+ * 'check' and class C (its own ✓). ✓ moves each cut task to after the committed end with a note (op dates + notes, scope: true)
16
18
  * status "looks done": the evidence says the work happened
17
19
  * names tidy names, before → after; the detail cut moves to the task's notes
18
20
  * outcome the expected outcome and its check date (D57; lib/outcomes.js, filed by lib/outcome-props.js): type new (no outcome yet) or date
@@ -516,11 +518,12 @@ function datesOf(ini, T, o = {}) {
516
518
  }
517
519
 
518
520
  /* ── what r.props carries ── */
519
- const ORDER = { build: -3, harness: -2.5, description: -2, outcome: -1, live: -0.7, prototyped: -0.6, improved: -0.5, scanned: -0.4, found: 0, dates: 1, status: 2, names: 3, links: 4, grill: 5 };
521
+ const ORDER = { build: -3, harness: -2.5, description: -2, outcome: -1, live: -0.7, prototyped: -0.6, improved: -0.5, scanned: -0.4, found: 0, dates: 1, scope: 1.5, status: 2, names: 3, links: 4, grill: 5 };
520
522
  const GRILL_SHOWN = 3;
521
523
  /**
522
524
  * One initiative's proposals, as the ✦ and the Viewer draw them, or null when there is nothing to show.
523
- * o: { T (Map uid → task), today (iso), stages: [{ key, name }], links: approved task links, settle, linkProps: [task-links proposal], grillAll (no fold) }
525
+ * o: { T (Map uid → task), today (iso), stages: [{ key, name }], links: approved task links, settle, linkProps: [task-links proposal], grillAll (no fold),
526
+ * limit (day number: the committed end, for the scope cuts), named(title) (the PRD names it) }
524
527
  * → { n, sure, look: { run, why, at, ended, stopped, sources: [{ source, name, state, n, what }] } | null, groups: [{ group, props: [p] }], t }
525
528
  */
526
529
  function viewOf(F, ini, o = {}) {
@@ -547,6 +550,14 @@ function viewOf(F, ini, o = {}) {
547
550
  const grillHidden = o.grillAll ? [] : grill.slice(GRILL_SHOWN).map((p) => ({ id: p.id, group: 'grill', type: p.type, title: p.title, why: p.why, at: p.at, sig: p.sig, sources: p.sources, data: p.data, items: [] }));
548
551
  if (!o.grillAll) for (const p of grill.slice(GRILL_SHOWN)) props.splice(props.indexOf(p), 1);
549
552
  if (today != null) for (const p of datesOf(ini, T, { today, filed: [...F.props.values()].filter((x) => x.group === 'dates' && x.ini === ini), stages: o.stages, links: o.links, settle: o.settle, drops: F.drops })) if (!kept.has(p.id + ':' + p.sig)) props.push(p);
553
+ // the scope cuts that save the date (lib/scope-cuts.js, idea A43): computed fresh like the dates ✦, never filed; its own ✓ (class C)
554
+ if (today != null && o.limit != null) {
555
+ for (const p of require('./scope-cuts.js').cutsOf(ini, T, { today: o.today, limit: o.limit, links: o.links, named: o.named })) {
556
+ if (kept.has(p.id + ':' + p.sig) || F.drops.has(p.sig)) continue;
557
+ p.items = p.items.filter((x) => !F.drops.has(itemSig(p, x)));
558
+ if (p.items.length) props.push(p);
559
+ }
560
+ }
550
561
  // one-change-record-no-source-no-auto: a link cites where it was read (the PRD line, a Jira dependency); a link guessed from the plan's
551
562
  // order or from two dates that meet cites nothing, so lib/source-guard.js holds it for the PM instead of adding it by itself
552
563
  const SG = require('./source-guard.js');
@@ -62,7 +62,19 @@ function view(ctx, p, ini, f, o = {}) {
62
62
  let linkProps = [];
63
63
  try { const lv = TL.viewOf(LF, ini, { T: f.T, today: todayIso(), limit: f.limit, src: TLR.sourcesOf(p.w.root, ini, f.items) }); linkProps = lv ? lv.proposals : []; } catch { linkProps = []; }
64
64
  const T = new Map(); for (const x of f.items) { if (!x || !(x.uid || x.key)) continue; const t = PR.taskOf(x); T.set(t.uid, t); }
65
- return PR.viewOf(F, ini, { T, today: todayIso(), stages: stagesOf(ctx, p, ini), links, settle: TL.settle, linkProps, grillAll: !!o.grillAll });
65
+ // the scope cuts (lib/scope-cuts.js): the committed end, and the PRD's words to say which cut costs more
66
+ const prd = (() => { try { return TLR.prdText(p.w.root, ini) || ''; } catch { return ''; } })();
67
+ const named = (title) => { const t = String(title || '').replace(/^\d+(\.\d+)*\s+/, '').trim(); return t.length >= 6 && prd.toLowerCase().includes(t.toLowerCase()); };
68
+ return PR.viewOf(F, ini, { T, today: todayIso(), stages: stagesOf(ctx, p, ini), links, settle: TL.settle, linkProps, grillAll: !!o.grillAll, limit: limitOf(f, T, ini), named });
69
+ }
70
+ /** The date the scope cuts keep: the initiative's committed end (its plan items), else the plan end its tasks make, as the Board's row
71
+ * shows it (routes-boards boardRow: the latest due date of its tasks). → day number | null */
72
+ function limitOf(f, T, ini) {
73
+ const base = f.limit ? f.limit(ini) : null;
74
+ if (base != null) return base;
75
+ let end = null;
76
+ for (const t of T.values()) if (t.ini === ini && t.kind !== 'Epic' && t.e != null && (end == null || t.e > end)) end = t.e;
77
+ return end;
66
78
  }
67
79
  function viewFor(ctx, w, boardId, ini) {
68
80
  const fr = RB.frameFor(ctx, w), board = fr.boards.find((b) => b.id === boardId);
@@ -97,7 +109,8 @@ function keepCore(ctx, p, g, f, ini, want, choices = {}, extra = {}) {
97
109
  if ((x.group === 'prototyped' || x.group === 'improved') && !w.length && x.failed) { failed.push({ id: x.id, why: x.failed }); continue; } // a round still being made stays open
98
110
  wrote.push(...w);
99
111
  if (x.group === 'dates' && x.plan && w.some((y) => y.op === 'dates')) plans++;
100
- keptIds.push(x.group === 'dates' ? x.id + ':' + x.sig : x.id);
112
+ keptIds.push(x.group === 'dates' || x.group === 'scope' ? x.id + ':' + x.sig : x.id); // computed fresh: kept while its signature holds
113
+ if (x.group === 'scope' && w.length) console.error(`${require('./scope-cuts.js').TAG} kept ${ini}: ${w.filter((y) => y.op === 'dates').length} moved to after ${(x.data && x.data.date) || ''}`);
101
114
  }
102
115
  for (const a of outbox) { const id = toOutbox(ctx, a); if (id) wrote.push({ op: 'outbox', task: a.task, entry: id, why: a.text }); }
103
116
  const batch = PR.newBatch();
@@ -463,6 +476,19 @@ function applyOne(ctx, p, g, f, ini, x, choices, outbox) {
463
476
  const mine = own && x.data && x.data.next && own !== x.data.next ? { edited: { from: String(x.data.next).slice(0, 200), to: own } } : {};
464
477
  if (W.ok(r)) add({ op: 'add', task: r.body.item && (r.body.item.uid || r.body.item.id), title: next, to: { start: '', due: '' }, ...mine });
465
478
  }
479
+ } else if (x.group === 'scope') {
480
+ // the scope cuts that save the date (lib/scope-cuts.js): each task moves to after the date, with a note saying why; Undo puts both back
481
+ const SC = require('./scope-cuts.js'), note = SC.noteOf(x), date = (x.data && x.data.date) || '';
482
+ for (const it of items) {
483
+ const t = f.T.get(it.task), xi = f.byUid.get(it.task) || {};
484
+ if (!t || t.closed) continue;
485
+ if (t.jira) { outbox.push({ task: it.task, text: 'Could ' + it.task + ' move to after ' + PR.md(PR.dn(date)) + '? ' + why }); continue; }
486
+ const r = W.dates(ctx, p, g, it.task, xi, it.to);
487
+ if (!W.ok(r)) continue;
488
+ add({ op: 'dates', task: it.task, title: t.title, from: { start: xi.start || '', due: xi.end || '' }, to: { start: it.to.start || xi.start || '', due: it.to.due || '' }, scope: true, cut: date });
489
+ const was = xi.notes || '';
490
+ if (!was.includes(note)) { const r2 = RB.taskEdit(ctx, { ws: p.w.id, board: p.board.id, task: it.task, notes: (was ? was + '\n' : '') + note }, g); if (W.ok(r2)) add({ op: 'notes', task: it.task, from: was, to: (was ? was + '\n' : '') + note, scope: true }); }
491
+ }
466
492
  } else if (x.group === 'status') {
467
493
  for (const it of items) {
468
494
  const t = f.T.get(it.task); if (!t || t.closed) continue;
@@ -515,7 +541,9 @@ function saidOf(wrote, plans, left) {
515
541
  const found = [n('stage') ? 'the stage' : '', n('doc') ? plural(n('doc'), 'document', 'documents') : '', n('add') ? plural(n('add'), 'task', 'tasks') : '', n('linked') ? plural(n('linked'), 'link', 'links') : ''].filter(Boolean);
516
542
  const bits = [];
517
543
  if (found.length) bits.push('Kept ' + (found.length > 1 ? found.slice(0, -1).join(', ') + ' and ' + found[found.length - 1] : found[0]));
518
- const moved = new Set(wrote.filter((w) => w.op === 'dates').map((w) => w.task)).size;
544
+ const cuts = wrote.filter((w) => w.op === 'dates' && w.scope), cutN = new Set(cuts.map((w) => w.task)).size;
545
+ if (cutN) bits.push((bits.length ? 'moved ' : 'Moved ') + plural(cutN, 'task', 'tasks') + ' to after ' + PR.md(PR.dn(cuts[0].cut)));
546
+ const moved = new Set(wrote.filter((w) => w.op === 'dates' && !w.scope).map((w) => w.task)).size;
519
547
  if (moved) bits.push((bits.length ? 'moved ' : 'Moved ') + plural(moved, 'task', 'tasks') + (plans ? ' and ' + plural(plans, 'plan', 'plans') : ''));
520
548
  if (n('state')) bits.push((bits.length ? 'ticked ' : 'Ticked ') + n('state') + ' done');
521
549
  if (n('rename')) bits.push((bits.length ? 'renamed ' : 'Renamed ') + n('rename'));
@@ -311,7 +311,7 @@ const WRITES = {
311
311
 
312
312
  module.exports = {
313
313
  prefixes: ['/api/task-links'],
314
- sweepFor, sourcesOf, frame, acceptFor, LOOP,
314
+ sweepFor, sourcesOf, prdText, frame, acceptFor, LOOP,
315
315
  handle: async (req, res, url, ctx) => {
316
316
  const p0 = url.pathname;
317
317
  if (req.method === 'GET') {
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* scope-cuts.js — the scope cuts that save a date (initiative scope-cuts-save-date; idea A43, factory job #1761).
4
+ *
5
+ * The dates ✦ (lib/proposals.js datesOf) answers a late task by giving its date up. A PM has a second answer: keep the date and move scope
6
+ * out of it. This file finds that answer for one initiative. PURE: it reads the tasks it is given and writes nothing; lib/proposals.js
7
+ * viewOf draws the result under the initiative's one ✦ and lib/routes-proposals.js applies it on the PM's ✓ (with Undo).
8
+ *
9
+ * THE RULE.
10
+ * · The date is the initiative's committed end (the row's `end`). No end, or an end already past: nothing (a past date cannot be saved by
11
+ * a cut; the dates ✦ proposes new dates for it).
12
+ * · Each open task's finish is forecast: its due date, or, for a late task, the time it had counted from today, the way the dates ✦
13
+ * counts it (so the two ✦ never disagree on a finish).
14
+ * · A task that finishes after the date is cut. A task that waits on a cut task (an approved task link: `to` waits on `from`) is cut too.
15
+ * · A ◇ milestone is a promise: it is never cut. When one finishes after the date, cuts alone cannot save it, and the proposal says so.
16
+ * · Closed tasks and Epic rows are never items.
17
+ * · Each item says what the cut costs: the PRD names it (listed last: the dearest cut), or a Jira ticket (a drafted comment, never a write).
18
+ * · A cut task moves to after the date: it starts the next working day after it and keeps its length.
19
+ *
20
+ * cutsOf(ini, T, o) PURE → [proposal] (zero or one): { id, sig, ini, group: 'scope', type: 'cut', section: 'check', title, why,
21
+ * sources, items: [{ id, task, title, from, to, finish, cost?, waits?, jira?, owner? }], data: { date, finish, keep, late,
22
+ * promise? } }
23
+ * o: { today (iso), limit (iso or day number: the committed end), links: [{ from, to }], named(title) → true when the PRD names it }
24
+ * noteOf(p) the note line a kept cut adds to its task
25
+ * countOf(lines) PURE → { kept, undone, still } scope cuts in a proposals ledger
26
+ * main(argv) `node lib/scope-cuts.js count [<root>]`: the health number (last line: cuts kept and not undone)
27
+ */
28
+ const path = require('path');
29
+
30
+ const TAG = '[scope-cut]';
31
+ const GROUP = 'scope';
32
+ const PR = () => require('./proposals.js'); // lazy: proposals.js requires this file
33
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
34
+ const WBS_RE = /^\d+(\.\d+)*\s+/;
35
+
36
+ /** Working days from day a (exclusive) to day b (inclusive); 0 when b is not after a. */
37
+ function workdaysBetween(a, b) {
38
+ let n = 0;
39
+ for (let d = a + 1; d <= b; d++) { const w = new Date(d * 864e5).getUTCDay(); if (w !== 0 && w !== 6) n++; }
40
+ return n;
41
+ }
42
+
43
+ /** A task's forecast finish (day number), or null when it has no date. Late tasks get the time they had, from today (as datesOf). */
44
+ function finishOf(t, today) {
45
+ const P = PR();
46
+ if (t.e == null) return null;
47
+ if (t.e >= today) return t.e;
48
+ const len = t.s != null && t.e != null ? Math.max(1, t.e - t.s) : 5;
49
+ if (t.hasStart) return P.workday(P.workday(today + 1) + len);
50
+ return P.workday(today + Math.max(P.RISK_DAYS, len));
51
+ }
52
+
53
+ function cutsOf(ini, T, o = {}) {
54
+ const P = PR();
55
+ const today = P.dn(o.today), L = typeof o.limit === 'number' ? o.limit : P.dn(o.limit);
56
+ if (today == null || L == null || L < today) return [];
57
+ const open = [...(T || new Map()).values()].filter((t) => t && t.ini === ini && !t.closed && t.kind !== 'Epic');
58
+ if (!open.length) return [];
59
+ const fin = new Map();
60
+ for (const t of open) { const f = finishOf(t, today); if (f != null) fin.set(t.uid, f); }
61
+ const promises = open.filter((t) => t.ms && fin.has(t.uid) && fin.get(t.uid) > L);
62
+ const cut = new Map(); // uid → waits (the cut task's title it waits on, or '')
63
+ for (const t of open) if (!t.ms && fin.has(t.uid) && fin.get(t.uid) > L) cut.set(t.uid, '');
64
+ if (!cut.size) return [];
65
+ // a task that waits on a cut task cannot land without it: it goes too (a milestone never does; it is a promise)
66
+ const links = (o.links || []).filter((l) => l && l.from && l.to);
67
+ for (let grew = true; grew;) {
68
+ grew = false;
69
+ for (const l of links) {
70
+ if (!cut.has(l.from) || cut.has(l.to)) continue;
71
+ const b = T.get(l.to); if (!b || b.closed || b.ini !== ini || b.ms) continue;
72
+ cut.set(l.to, (T.get(l.from).title || l.from).replace(WBS_RE, '')); grew = true;
73
+ }
74
+ }
75
+ const named = typeof o.named === 'function' ? o.named : () => false;
76
+ const items = [];
77
+ for (const [uid, waits] of cut) {
78
+ const t = T.get(uid), f = fin.get(uid);
79
+ const len = t.s != null && t.e != null ? Math.max(0, t.e - t.s) : 0;
80
+ const s1 = P.workday(L + 1), e1 = P.workday(s1 + len);
81
+ const cost = t.jira ? 'jira' : named(t.title) ? 'prd' : '';
82
+ items.push({ id: uid, task: uid, title: t.title, from: { start: t.hasStart ? P.isoN(t.s) : '', due: P.isoN(t.e) }, to: { start: t.hasStart ? P.isoN(s1) : '', due: P.isoN(e1) },
83
+ finish: f != null ? P.isoN(f) : '', ...(cost ? { cost } : {}), ...(waits ? { waits } : {}), ...(t.jira ? { jira: true } : {}), ...(t.owner ? { owner: t.owner } : {}) });
84
+ }
85
+ // the cheapest cuts first: a task nobody's PRD names, then a Jira ticket (a comment, not a write), then what the PRD names
86
+ const rank = (x) => (x.cost === 'prd' ? 2 : x.cost === 'jira' ? 1 : 0);
87
+ items.sort((a, b) => rank(a) - rank(b) || String(b.finish).localeCompare(String(a.finish)) || String(a.title).localeCompare(String(b.title)));
88
+ const lastF = Math.max(...[...fin.values()]);
89
+ const kept = open.filter((t) => !cut.has(t.uid) && fin.has(t.uid)).map((t) => fin.get(t.uid));
90
+ const keep = kept.length ? Math.max(...kept) : null;
91
+ const late = workdaysBetween(L, lastF);
92
+ const date = P.md(L);
93
+ const named1 = items.filter((x) => x.cost === 'prd').length;
94
+ const why = 'At today\'s pace the last task ends ' + P.md(lastF) + ', ' + plural(late, 'working day', 'working days') + ' after ' + date + '. '
95
+ + (promises.length ? 'The ◇ ' + promises[0].title.replace(WBS_RE, '') + ' also ends after it and is a promise, so cuts alone cannot save ' + date + '.'
96
+ : (items.length === 1 ? 'Moving it' : 'Moving these') + ' to after ' + date + ' keeps the date' + (keep != null ? ': the rest ends by ' + P.md(keep) + '.' : '.'))
97
+ + (named1 ? ' The PRD names ' + (named1 === 1 ? (items.length === 1 ? 'it' : 'one of them') : named1 + ' of them') + ': cut ' + (named1 === 1 ? 'it' : 'those') + ' last.' : '');
98
+ const id = P.idOf(ini, GROUP, 'cut', '');
99
+ const p = { id, ini, group: GROUP, type: 'cut', section: 'check',
100
+ title: 'Cut ' + plural(items.length, 'task', 'tasks') + ' to keep ' + date,
101
+ why, sources: [{ label: 'the plan', ref: plural(items.length, 'task', 'tasks') + ' due after ' + P.isoN(L) }], items,
102
+ data: { date: P.isoN(L), finish: P.isoN(lastF), keep: keep != null ? P.isoN(keep) : '', late, ...(promises.length ? { promise: promises[0].title } : {}) } };
103
+ // a new date or a moved task is a new signature: a ✕ holds while the tasks and the date it rests on hold
104
+ p.sig = 'd:' + P.hash([id, P.isoN(L), ...items.map((x) => x.task + '@' + x.finish)].join('|'));
105
+ return [p];
106
+ }
107
+
108
+ /** The note line a kept cut adds to its task. */
109
+ function noteOf(p) { return 'Cut to keep ' + PR().md(PR().dn(p.data && p.data.date)) + ' (PMOS ✦): ' + String(p.why || '').slice(0, 300); }
110
+
111
+ /** PURE. Scope cuts in a proposals ledger (oldest first): kept, undone, and kept and not undone. */
112
+ function countOf(lines) {
113
+ const undone = new Set();
114
+ for (const l of lines || []) if (l && l.kind === 'undo' && l.batch) undone.add(l.batch);
115
+ let kept = 0, back = 0;
116
+ for (const l of lines || []) {
117
+ if (!l || l.kind !== 'keep' || !Array.isArray(l.wrote) || !l.wrote.some((w) => w && w.scope === true)) continue;
118
+ kept++; if (undone.has(l.batch)) back++;
119
+ }
120
+ return { kept, undone: back, still: kept - back };
121
+ }
122
+
123
+ function main(argv, { say = (s) => console.log(s), cwd = process.cwd() } = {}) {
124
+ const pos = argv.filter((a) => !a.startsWith('--'));
125
+ const [sub = 'count', rootArg] = pos;
126
+ if (sub !== 'count') { say('usage: node lib/scope-cuts.js count [<root>] — scope cuts kept, undone and still kept (the last line)'); return 2; }
127
+ const root = path.resolve(cwd, rootArg || '.');
128
+ let dir;
129
+ try { dir = require('./driver.js').stateDirOf(root); } catch (e) { say(`${TAG} could not find the state folder of ${root}: ${(e && e.message) || e}`); return 1; }
130
+ const c = countOf(PR().readLines(PR().ledgerFile(dir)));
131
+ say(`${TAG} ${plural(c.kept, 'scope cut', 'scope cuts')} kept, ${c.undone} undone`);
132
+ say(String(c.still));
133
+ return 0;
134
+ }
135
+
136
+ module.exports = { GROUP, TAG, cutsOf, finishOf, noteOf, countOf, workdaysBetween, main };
137
+
138
+ 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.783.0",
3
+ "version": "0.784.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.783.0",
9
+ "version": "0.784.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.783.0",
3
+ "version": "0.784.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",
@@ -32,7 +32,7 @@ const I = {
32
32
  check: 'M5 12l5 5 9-10', x: 'M6 6l12 12M18 6L6 18', down: 'M6 9l6 6 6-6', up: 'M6 15l6-6 6 6', stop: 'M7 7h10v10H7z',
33
33
  doc: 'M7 3h7l5 5v13H7zM14 3v5h5', tasks: 'M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01', stage: 'M5 21V4M5 4h12l-2 4 2 4H5',
34
34
  link: 'M10 14a4 4 0 0 0 5.66 0l3-3a4 4 0 0 0-5.66-5.66l-1 1M14 10a4 4 0 0 0-5.66 0l-3 3a4 4 0 0 0 5.66 5.66l1-1',
35
- cal: 'M4 5h16v15H4zM8 3v4M16 3v4M4 10h16', done: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M8 12l3 3 5-6', name: 'M4 20h4L19 9l-4-4L4 16zM13 7l4 4',
35
+ cal: 'M4 5h16v15H4zM8 3v4M16 3v4M4 10h16', cut: 'M9 6a3 3 0 1 1-6 0 3 3 0 0 1 6 0M9 18a3 3 0 1 1-6 0 3 3 0 0 1 6 0M20 4 8.12 15.88M14.47 14.48 20 20M8.12 8.12 12 12', done: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M8 12l3 3 5-6', name: 'M4 20h4L19 9l-4-4L4 16zM13 7l4 4',
36
36
  goal: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M12 7a5 5 0 1 0 0 10 5 5 0 0 0 0-10M12 11a1 1 0 1 0 0 2 1 1 0 0 0 0-2',
37
37
  ask: 'M4 5h16v11H9l-5 4z', maybe: 'M12 3a9 9 0 1 0 0 18 9 9 0 0 0 0-18M9.5 9.5a2.5 2.5 0 1 1 3.5 2.3c-.6.3-1 .9-1 1.6M12 17h.01', keep: 'M5 12l5 5 9-10', ignore: 'M5 12h14',
38
38
  };
@@ -42,7 +42,7 @@ const md = (iso) => { const m = DAY.exec(String(iso || '')); return m ? MON[+m[2
42
42
  const span = (a, b) => (a && b && a !== b ? md(a) + ' – ' + md(b) : md(a || b));
43
43
  const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
44
44
  const clip = (s, n) => { s = String(s || ''); return s.length > n ? s.slice(0, n - 1) + '…' : s; };
45
- const GROUP = { live: 'PMOS will show it', build: 'Pull request', harness: 'Change the factory harness', description: 'Description', outcome: 'Expected outcome', prototyped: 'PMOS prototyped it', improved: 'PMOS improved it', scanned: 'PMOS scanned for it', found: 'Found elsewhere', dates: 'Dates', status: 'Looks done', names: 'Names', links: 'Links', grill: 'PMOS grilled it' };
45
+ const GROUP = { live: 'PMOS will show it', build: 'Pull request', harness: 'Change the factory harness', description: 'Description', outcome: 'Expected outcome', prototyped: 'PMOS prototyped it', improved: 'PMOS improved it', scanned: 'PMOS scanned for it', found: 'Found elsewhere', dates: 'Dates', scope: 'Cut to keep the date', status: 'Looks done', names: 'Names', links: 'Links', grill: 'PMOS grilled it' };
46
46
 
47
47
  /* ── the chip and the live look ── */
48
48
  export function chipOf(p) {
@@ -111,7 +111,7 @@ const titleOf = (p) => {
111
111
  return '';
112
112
  };
113
113
  const iconOf = (p) => (p.group === 'description' ? I.doc : p.group === 'outcome' ? I.goal : p.group === 'found' ? (p.type === 'stage' ? I.stage : p.type === 'docs' ? I.doc : p.type === 'tasks' ? I.tasks : p.type === 'link' ? I.link : I.maybe)
114
- : p.group === 'dates' ? I.cal : p.group === 'status' ? I.done : p.group === 'names' ? I.name : I.link);
114
+ : p.group === 'dates' ? I.cal : p.group === 'scope' ? I.cut : p.group === 'status' ? I.done : p.group === 'names' ? I.name : I.link);
115
115
  const ib = (attr, label, icon, cls = '') => `<button type="button" class="pp-ib${cls ? ' ' + cls : ''}" ${attr} aria-label="${esc(label)}" title="${esc(label)}">${SVG(icon, 16, 2.2)}</button>`;
116
116
  function itemHtml(p, x) {
117
117
  let t = '', m = '';
@@ -121,6 +121,7 @@ function itemHtml(p, x) {
121
121
  else if (p.type === 'tasks') { t = (x.wbs && !String(x.title || '').startsWith(x.wbs) ? x.wbs + ' ' : '') + (x.title || x.jira || ''); m = [x.jira ? 'Jira epic ' + x.jira : '', x.stage, span(x.start, x.due), x.owner].filter(Boolean).join(' · '); }
122
122
  else { t = x.title; m = x.other ? 'In ' + x.other.title : x.why || ''; }
123
123
  } else if (p.group === 'dates') { t = x.title || x.task; m = (x.from && x.from.due ? md(x.from.due) + ' → ' : '') + span(x.to && x.to.start, x.to && x.to.due) + (x.jira ? ' · Jira: a drafted comment' : '') + (x.ms ? ' · ◇ a promise' : ''); }
124
+ else if (p.group === 'scope') { t = x.title || x.task; m = [x.finish ? 'Ends ' + md(x.finish) : '', x.waits ? 'waits on ' + x.waits : '', 'moves to ' + span(x.to && x.to.start, x.to && x.to.due), x.cost === 'prd' ? 'the PRD names it' : '', x.jira ? 'Jira: a drafted comment' : ''].filter(Boolean).join(' · '); }
124
125
  else if (p.group === 'status') { t = x.title || taskTitle(p.ini, x.task); m = x.jira ? 'Jira: a drafted comment' : ''; }
125
126
  else if (p.group === 'outcome') { t = x.title; m = x.due ? 'Check on ' + md(x.due) : ''; }
126
127
  else if (p.group === 'description') { t = (p.data && p.data.text) || x.title; m = p.type === 'enrich' && p.data && p.data.from ? 'Now: ' + clip(p.data.from, 120) : ''; }
@@ -0,0 +1,5 @@
1
+ {
2
+ "_comment": "The scope cuts that save a date (initiative scope-cuts-save-date, done test S1-S8; idea A43): the engine pure, the ✦ group, class C, the health count, then ✓ and Undo on a scratch server. No connector, model or network.",
3
+ "modules": ["scope-cuts.test.js"],
4
+ "seconds": { "scope-cuts.test.js": 10 }
5
+ }