create-pmos 0.782.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.782.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": {
@@ -33,6 +33,58 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.784.0",
38
+ "at": "2026-11-24T16:59:38.052Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
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",
47
+ "try": {
48
+ "steps": [
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"
52
+ ],
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",
54
+ "open": "/premium-board.html"
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"
69
+ },
70
+ {
71
+ "n": 1780,
72
+ "t": "One-tap reason when work rolls to the next sprint",
73
+ "s": "One-tap reason when work rolls to the next sprint",
74
+ "k": "new",
75
+ "h": "One-tap reason when work rolls to the next sprint",
76
+ "try": {
77
+ "steps": [
78
+ "Open Work, then a product's Backlog, and press This sprint",
79
+ "Press the sprint name and pick the last closed sprint",
80
+ "Under Carried to, press one reason on a ticket, such as Blocked"
81
+ ],
82
+ "see": "The ticket shows Blocked with a clear button, and the Carried to block above counts it: 1 blocked, and one fewer not said yet.",
83
+ "open": "/premium-board.html"
84
+ }
85
+ }
86
+ ]
87
+ },
36
88
  {
37
89
  "v": "0.782.0",
38
90
  "at": "2026-11-24T16:18:37.421Z",
@@ -369,50 +421,6 @@
369
421
  }
370
422
  }
371
423
  ]
372
- },
373
- {
374
- "v": "0.764.0",
375
- "at": "2026-11-24T06:08:25.279Z",
376
- "f": 4,
377
- "prs": [
378
- {
379
- "n": 1720,
380
- "t": "A risky change on shared text only asks the owner",
381
- "s": "A risky change on shared text only asks the owner",
382
- "k": "new",
383
- "try": {
384
- "steps": [
385
- "Say in a Slack channel PMOS reads, and in a meeting note, that a task with no Jira ticket is done",
386
- "Wait for the next PMOS round",
387
- "Open Today and look at today's questions"
388
- ],
389
- "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.",
390
- "open": "/premium-home.html"
391
- }
392
- }
393
- ]
394
- },
395
- {
396
- "v": "0.763.0",
397
- "at": "2026-11-24T05:36:34.102Z",
398
- "f": 4,
399
- "prs": [
400
- {
401
- "n": 1719,
402
- "t": "Tracker sync on Today below 95%, take Jira's value with Undo",
403
- "s": "Tracker sync on Today below 95%, take Jira's value with Undo",
404
- "k": "new",
405
- "try": {
406
- "steps": [
407
- "Open Today on a product that differs from Jira on more than 5% of its tasks",
408
- "Press the down arrow on the ✦ row that names the product, then ✓ on one row or ✓ on the ✦ row",
409
- "Press Undo in the message that shows"
410
- ],
411
- "see": "The ✦ row says how many tasks differ from Jira; ✓ makes PMOS say what Jira says and the row leaves; Undo puts back what PMOS said before. A product at 95% or more shows no row.",
412
- "open": "/today.html"
413
- }
414
- }
415
- ]
416
424
  }
417
425
  ]
418
426
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@31150fd7c
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:18:33Z"}
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:18:33Z"}
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:18:33Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T16:59:34Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,56 @@
1
1
  [
2
+ {
3
+ "v": "0.784.0",
4
+ "at": "2026-11-24T16:59:38.052Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
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",
13
+ "try": {
14
+ "steps": [
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"
18
+ ],
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",
20
+ "open": "/premium-board.html"
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"
35
+ },
36
+ {
37
+ "n": 1780,
38
+ "t": "One-tap reason when work rolls to the next sprint",
39
+ "s": "One-tap reason when work rolls to the next sprint",
40
+ "k": "new",
41
+ "h": "One-tap reason when work rolls to the next sprint",
42
+ "try": {
43
+ "steps": [
44
+ "Open Work, then a product's Backlog, and press This sprint",
45
+ "Press the sprint name and pick the last closed sprint",
46
+ "Under Carried to, press one reason on a ticket, such as Blocked"
47
+ ],
48
+ "see": "The ticket shows Blocked with a clear button, and the Carried to block above counts it: 1 blocked, and one fewer not said yet.",
49
+ "open": "/premium-board.html"
50
+ }
51
+ }
52
+ ]
53
+ },
2
54
  {
3
55
  "v": "0.782.0",
4
56
  "at": "2026-11-24T16:18:37.421Z",
@@ -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.
@@ -874,6 +874,7 @@ The benchmark needs a signed-in agent CLI. It never pushes and never opens a pul
874
874
  - `pmos jira query --sprint "<name>"`
875
875
  - `pmos jira sync --sprint "<name>" --from <file|-> [--dry-run]`
876
876
  - `pmos jira summary [--from <file|->] [--dry-run]`
877
+ - `pmos jira why --sprint "<name>"`, `pmos jira why <KEY> <reason> --sprint "<name>"` or `pmos jira why <KEY> --clear --sprint "<name>"`: why a ticket rolled out of a closed sprint (blocked, bigger, pushed or waiting), the same as the one tap on Work › Backlog.
877
878
  - `pmos jira which <KEY>`
878
879
  - `pmos jira moves`
879
880
  - `pmos jira moved <move id> --status "<Jira status>"` or `--refused "<why>"`
@@ -271,6 +271,18 @@ pmos jira summary
271
271
  pmos jira summary --from <file|-> [--dry-run]
272
272
  ```
273
273
 
274
+ ## Why work rolled to the next sprint
275
+
276
+ Pick a closed sprint in the sprint picker on Work › Backlog. Under **Carried to …**, each ticket that rolled to the next sprint shows four reasons: **Blocked**, **Bigger than thought**, **Pushed down** and **Waiting on someone**. Press one. The ticket then shows that reason and a button to take it back. The **Carried to** block above counts the reasons, largest first, and the tickets with no reason yet, so the sprint review sees why the plan slipped.
277
+
278
+ The reasons stay in PMOS, in `<state>/tracker/jira/_rollover-reasons.jsonl`. Nothing is written to Jira. The chat writes the same reason:
279
+
280
+ ```
281
+ pmos jira why --sprint "<name>" the count per reason, and the tickets not said
282
+ pmos jira why <KEY> <reason> --sprint "<name>" reason: blocked, bigger, pushed or waiting
283
+ pmos jira why <KEY> --clear --sprint "<name>" take the reason back
284
+ ```
285
+
274
286
  ## Link an initiative to its Jira epics
275
287
 
276
288
  Your team may already plan in Jira, with an epic for each piece of work. Then link the initiative to its epics. You do not have to draft or push tickets.
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
- /* routes-card-catalog.js — the card catalog for the page (star-buttons-act-directly).
2
+ /* card-catalog-route.js — the card catalog for the page (star-buttons-act-directly).
3
3
  *
4
4
  * GET /api/card-catalog → { ok, catalog } the committed v2 catalog (lib/card-catalog.json), read only
5
5
  *
@@ -11,7 +11,7 @@
11
11
  * button runs no command ("opens the task popup")
12
12
  * commands() → [{ verb, sub, run, uses: [{ kind, label }] }], one per distinct "<verb> <sub>"
13
13
  *
14
- * The page reads the same file through GET /api/card-catalog (lib/routes-card-catalog.js) and runs a button with
14
+ * The page reads the same file through GET /api/card-catalog (lib/card-catalog-route.js) and runs a button with
15
15
  * public/pm/action-run.js. Pure apart from the one read. */
16
16
  const fs = require('fs');
17
17
  const path = require('path');
@@ -55,8 +55,9 @@ const jiraCriteria = require('./jira-criteria.js');
55
55
  const pmName = (env) => { const e = String(((env || process.env).PMOS_PM_NAME) || '').trim(); if (e) return e; try { return require('./routes-board-publish.js').sharedBy() || ''; } catch { return ''; } };
56
56
  const planItems = require('./plan-items.js');
57
57
  const guard = require('./pm-guard.js');
58
+ const RR = require('./rollover-reasons.js');
58
59
 
59
- const COMMANDS = { jira: ['draft', 'show', 'epic', 'approve', 'pending', 'record', 'query', 'sync', 'pin', 'summary', 'which', 'moves', 'moved', 'epic-asks', 'epic-done', 'guesses', 'answer', 'criteria', 'digest', 'criteria-propose', 'criteria-ask', 'criteria-asks', 'criteria-done', 'criteria-reach'] };
60
+ const COMMANDS = { jira: ['draft', 'show', 'epic', 'approve', 'pending', 'record', 'query', 'sync', 'pin', 'summary', 'which', 'moves', 'moved', 'epic-asks', 'epic-done', 'guesses', 'answer', 'criteria', 'digest', 'criteria-propose', 'criteria-ask', 'criteria-asks', 'criteria-done', 'criteria-reach', 'why'] };
60
61
  const USAGE = [
61
62
  'usage: pmos jira draft|show|epic|approve|pending|record|query|sync|summary|which — Jira tickets from the PRD, and their status',
62
63
  ' pmos jira draft <initiative> [--dry-run] draft one ticket per PRD item, in the ticket template',
@@ -82,6 +83,9 @@ const USAGE = [
82
83
  ' pmos jira sync --sprint "<name>" --from <file|-> keep that read as the sprint\'s snapshot',
83
84
  ' pmos jira summary the sprints that need a goal and summary written',
84
85
  ' pmos jira summary --from <file|-> [--dry-run] save each sprint\'s goal, summary and themes (a closed sprint is kept once written)',
86
+ ' pmos jira why --sprint "<name>" why the tickets rolled out of a closed sprint: the count per reason, and the ones not said',
87
+ ' pmos jira why <KEY> <reason> --sprint "<name>" save why a ticket rolled to the next sprint: blocked, bigger, pushed or waiting',
88
+ ' pmos jira why <KEY> --clear --sprint "<name>" take that reason back',
85
89
  ' pmos jira which <KEY> [<KEY> …] the initiative a Jira key belongs to',
86
90
  ' pmos jira moves the status moves asked in PMOS that wait for Jira',
87
91
  ' pmos jira moved <move id> --status "<status>" | --refused "<why>" what Jira did with one move',
@@ -96,7 +100,7 @@ const USAGE = [
96
100
  ' every command: [--json] [--root <dir>]',
97
101
  'This command never calls Jira. Your agent reads and writes Jira with your own connection.',
98
102
  ];
99
- const BOOL = new Set(['json', 'dry-run', 'help', 'sprints', 'keep-default', 'direct', 'draft', 'changed', 'off', 'all', 'health', 'count']);
103
+ const BOOL = new Set(['json', 'dry-run', 'help', 'sprints', 'keep-default', 'direct', 'draft', 'changed', 'off', 'all', 'health', 'count', 'clear']);
100
104
  const VALUE = new Set(['from', 'query', 'root', 'epic', 'updated', 'group', 'status', 'refused', 'sprint', 'text', 'since']);
101
105
  const FLAG_TEXT = { 'prd-changed': 'PRD changed', removed: 'Removed from PRD', blocked: 'Blocked', incomplete: 'Missing text', pushing: 'Selected, waiting for the push', edited: 'Edited, not in Jira yet' };
102
106
 
@@ -156,7 +160,30 @@ async function run(argv, { say = (s) => console.log(s), cwd = process.cwd(), isT
156
160
 
157
161
  try {
158
162
  if (flags.sprints && verb !== 'query' && verb !== 'sync') return fail('--sprints goes with query or sync', 2);
159
- if (flags.sprint != null && verb !== 'query' && verb !== 'sync') return fail('--sprint goes with query or sync', 2);
163
+ if (flags.sprint != null && verb !== 'query' && verb !== 'sync' && verb !== 'why') return fail('--sprint goes with query, sync or why', 2);
164
+ if (flags.clear && verb !== 'why') return fail('--clear goes with why', 2);
165
+ // why a ticket rolled to the next sprint (initiative rollover-reason): the same write as the one tap on Work › Backlog
166
+ if (verb === 'why') {
167
+ if (flags.sprint == null) return need('--sprint "<name>" [<KEY> <reason> | <KEY> --clear]');
168
+ const sprint = String(flags.sprint);
169
+ const SH = require('./sprint-history.js');
170
+ const s = SH.snapshotOf(SH.read(root), sprint);
171
+ if (!s || s.sprint.state !== 'closed') return fail(`PMOS kept no closed sprint named "${sprint}"`);
172
+ const carried = s.rows.filter((r) => r.carried);
173
+ if (!pos.length) {
174
+ const fold = RR.foldOf(RR.read(root)), w = RR.whyOf(carried, fold, sprint);
175
+ if (!w) return out({ ok: true, sprint, why: null, unsaid: [] }, [`${sprint} carried nothing to the next sprint`]);
176
+ const unsaid = carried.filter((r) => !fold.has(sprint + '|' + r.key)).map((r) => r.key);
177
+ const parts = RR.REASONS.filter((k) => w[k]).map((k) => `${w[k]} ${RR.LABELS[k].toLowerCase()}`);
178
+ return out({ ok: true, sprint, why: w, unsaid }, [`${sprint} · ${carried.length} carried${parts.length ? ' · ' + parts.join(' · ') : ''}${w.unsaid ? ` · ${w.unsaid} not said yet` : ''}`,
179
+ ...(unsaid.length ? [`not said: ${unsaid.join(' ')}`] : [])]);
180
+ }
181
+ const key = String(pos[0]).toUpperCase(), reason = flags.clear ? null : pos[1];
182
+ if (!flags.clear && !reason) return need('<KEY> <reason> --sprint "<name>" reason: ' + RR.REASONS.join(', '));
183
+ const r = RR.saveCarried(root, { sprint, key, reason, by: (isTTY ? 'pm' : 'agent') + ':cli' });
184
+ if (!r.ok) return fail(r.error);
185
+ return out({ ok: true, sprint, key, reason, was: r.was }, [reason ? `${key} · ${RR.LABELS[reason]} · rolled out of ${sprint}` : `${key} · reason taken back · ${sprint}`]);
186
+ }
160
187
  if (flags.since != null && verb !== 'digest') return fail('--since goes with digest', 2);
161
188
  if (flags.changed && verb !== 'query' && verb !== 'sync') return fail('--changed goes with query or sync', 2);
162
189
  if (flags.off && verb !== 'pin') return fail('--off goes with pin', 2);
@@ -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');
@@ -0,0 +1,127 @@
1
+ 'use strict';
2
+ /* rollover-reasons.js — why a ticket rolled to the next sprint, one tap per ticket (initiative rollover-reason, bet A481, job #1759).
3
+ *
4
+ * WHY. Work rolls from one sprint to the next all the time (634 unfinished open-sprint items carried over on the test bed), and PMOS showed
5
+ * only THAT it slips (the carried-over line on Work › Backlog), not why. When a sprint closes, each ticket it carried takes one reason with
6
+ * one tap, and the sprint's "Carried to" block counts them, so a sprint review reads "3 blocked · 2 bigger than thought" instead of "5 carried".
7
+ *
8
+ * THE FILE. <state>/tracker/jira/_rollover-reasons.jsonl, next to _sprint-history.jsonl. Append-only, one line per tap:
9
+ * { at, sprint, key, reason: blocked|bigger|pushed|waiting|null, by }
10
+ * The latest line per sprint and ticket wins; reason null clears it (Undo, or the PM changed their mind). Nothing is written to Jira.
11
+ *
12
+ * REASONS, LABELS
13
+ * record(root, { sprint, key, reason, by, at }) → { ok, was } | { ok: false, error }
14
+ * saveCarried(root, { sprint, key, reason, by }, sin?) → the same, only for a ticket a kept closed sprint carried (the page and the chat)
15
+ * read(root) → [line]
16
+ * foldOf(lines) → Map 'sprint|KEY' → { reason, at, by }
17
+ * whyOf(rows, fold, sprint) → { blocked, bigger, pushed, waiting, unsaid } | null (null when no row was carried)
18
+ * count(root) → whole percent of the carried tickets of kept closed sprints that have a reason (0 when none was carried)
19
+ *
20
+ * BOUNDARY. No network, no child process. Writes only its own file. Every write logs one line starting [rollover-reason]. */
21
+ const fs = require('fs');
22
+ const path = require('path');
23
+ const jiraTickets = require('./jira-tickets.js');
24
+
25
+ const FILE = '_rollover-reasons.jsonl';
26
+ const REASONS = ['blocked', 'bigger', 'pushed', 'waiting'];
27
+ const LABELS = { blocked: 'Blocked', bigger: 'Bigger than thought', pushed: 'Pushed down', waiting: 'Waiting on someone' };
28
+ const KEY_RE = /^[A-Z][A-Z0-9_]*-\d+$/;
29
+ const fileOf = (root) => path.join(jiraTickets.jiraDir(root), FILE);
30
+ const idOf = (sprint, key) => sprint + '|' + key;
31
+ const say = (s) => { try { console.log('[rollover-reason] ' + s); } catch { /* no console */ } };
32
+
33
+ function read(root) {
34
+ let raw = '';
35
+ try { raw = fs.readFileSync(fileOf(root), 'utf8'); } catch { return []; }
36
+ const out = [];
37
+ for (const l of raw.split('\n')) {
38
+ if (!l.trim()) continue;
39
+ try {
40
+ const o = JSON.parse(l);
41
+ if (o && typeof o.sprint === 'string' && o.sprint && KEY_RE.test(String(o.key || '')) && (o.reason === null || REASONS.includes(o.reason))) out.push(o);
42
+ } catch { /* a torn line has no effect */ }
43
+ }
44
+ return out;
45
+ }
46
+
47
+ /** The latest reason per sprint and ticket. A cleared one is left out. */
48
+ function foldOf(lines) {
49
+ const m = new Map();
50
+ for (const l of lines || []) {
51
+ const id = idOf(l.sprint, String(l.key).toUpperCase());
52
+ if (l.reason) m.set(id, { reason: l.reason, at: l.at || null, by: l.by || null }); else m.delete(id);
53
+ }
54
+ return m;
55
+ }
56
+
57
+ /** Check one tap: → { sprint, key, reason } | { error } */
58
+ function checkOf(inp) {
59
+ const sprint = typeof inp.sprint === 'string' ? inp.sprint.trim().slice(0, 120) : '';
60
+ const key = String(inp.key || '').trim().toUpperCase();
61
+ const reason = inp.reason == null || inp.reason === '' ? null : String(inp.reason);
62
+ if (!sprint) return { error: 'sprint names the closed sprint the ticket rolled out of' };
63
+ if (!KEY_RE.test(key)) return { error: 'key is a Jira key like ATL-12' };
64
+ if (reason !== null && !REASONS.includes(reason)) return { error: 'reason is one of ' + REASONS.join(', ') + ', or null to clear it' };
65
+ return { sprint, key, reason };
66
+ }
67
+
68
+ /** Save one tap. → { ok, was (the reason before, or null) } | { ok: false, error } */
69
+ function record(root, inp) {
70
+ const c = checkOf(inp || {});
71
+ if (c.error) return { ok: false, error: c.error };
72
+ const was = (foldOf(read(root)).get(idOf(c.sprint, c.key)) || {}).reason || null;
73
+ const line = { at: inp.at || new Date().toISOString(), sprint: c.sprint, key: c.key, reason: c.reason, by: String(inp.by || 'pm').slice(0, 120) };
74
+ const f = fileOf(root);
75
+ fs.mkdirSync(path.dirname(f), { recursive: true });
76
+ fs.appendFileSync(f, JSON.stringify(line) + '\n');
77
+ say(`${c.sprint} ${c.key} ${c.reason ? 'reason ' + c.reason : 'reason cleared'}${was && was !== c.reason ? ' (was ' + was + ')' : ''}`);
78
+ return { ok: true, was };
79
+ }
80
+
81
+ /** One tap from the page or the chat: only a ticket a kept closed sprint carried takes a reason. sin is what lib/sprint-history.js detailOf
82
+ * reads (the route passes the board's; the CLI passes { lines }). → { ok, was } | { ok: false, error } */
83
+ function saveCarried(root, inp, sin) {
84
+ const c = checkOf(inp || {});
85
+ if (c.error) return { ok: false, error: c.error };
86
+ const SH = require('./sprint-history.js');
87
+ const d = SH.detailOf(c.sprint, sin || { lines: SH.read(root) });
88
+ if (!d || d.state !== 'closed' || !d.rows) return { ok: false, error: `PMOS kept no closed sprint named "${c.sprint}"` };
89
+ if (!d.rows.some((r) => r.key === c.key && r.category !== 'done')) return { ok: false, error: `${c.key} did not roll out of ${c.sprint}` };
90
+ return record(root, { ...c, by: inp.by, at: inp.at });
91
+ }
92
+
93
+ /** The counts for one sprint's carried rows. Zero is silence for the caller: null when the sprint carried nothing. */
94
+ function whyOf(rows, fold, sprint) {
95
+ const carried = (rows || []).filter((r) => r && r.category !== 'done' && !r.removed);
96
+ if (!carried.length) return null;
97
+ const out = { blocked: 0, bigger: 0, pushed: 0, waiting: 0, unsaid: 0 };
98
+ for (const r of carried) {
99
+ const f = fold ? fold.get(idOf(sprint, String(r.key).toUpperCase())) : null;
100
+ if (f && REASONS.includes(f.reason)) out[f.reason]++; else out.unsaid++;
101
+ }
102
+ return out;
103
+ }
104
+
105
+ /** The health number: the share (whole percent) of the tickets carried out of kept closed sprints that have a reason. */
106
+ function count(root) {
107
+ const SH = require('./sprint-history.js');
108
+ const lines = SH.read(root), fold = foldOf(read(root));
109
+ let all = 0, said = 0;
110
+ for (const name of new Set(lines.map((l) => l.sprint.name))) {
111
+ const s = SH.snapshotOf(lines, name);
112
+ if (!s || s.sprint.state !== 'closed') continue;
113
+ const w = whyOf(s.rows, fold, name);
114
+ if (!w) continue;
115
+ all += w.blocked + w.bigger + w.pushed + w.waiting + w.unsaid;
116
+ said += w.blocked + w.bigger + w.pushed + w.waiting;
117
+ }
118
+ return all ? Math.round((said / all) * 100) : 0;
119
+ }
120
+
121
+ module.exports = { FILE, REASONS, LABELS, KEY_RE, fileOf, read, foldOf, checkOf, record, saveCarried, whyOf, count };
122
+
123
+ if (require.main === module) {
124
+ const [cmd, dir] = process.argv.slice(2);
125
+ if (cmd !== 'count') { console.error('usage: node workspace/lib/rollover-reasons.js count [<product checkout>] (percent of carried tickets with a reason)'); process.exit(2); }
126
+ console.log(String(count(path.resolve(dir || '.'))));
127
+ }
@@ -25,6 +25,8 @@
25
25
  * POST /api/backlog/place { ws, board, key, to } a No home Jira ticket into an initiative (a ticket-move line on the board
26
26
  * ledger, as a split or merge writes it; Jira is not written to, D88). to '' takes it back out.
27
27
  *
28
+ * POST /api/backlog/sprint-reason { ws, board, sprint, key, reason } why a ticket rolled out of a closed sprint: blocked, bigger, pushed,
29
+ * waiting, or null to clear it (initiative rollover-reason; lib/rollover-reasons.js)
28
30
  * Every POST is a page press (lib/pm-guard.js requirePagePress). The gives ledger is <runtime>/backlog/gives.jsonl, append-only, and this file
29
31
  * is its one writer. Nothing here sends anything: a message PMOS drafts goes out only after the PM's Approve, through the day run's own send.
30
32
  * A task PMOS finished by itself is closed (Done) on the next read, by the same function `pmos task state` runs, written as the agent. */
@@ -38,6 +40,7 @@ const assigned = require('./work-assigned.js');
38
40
  const WK = require('./work-kind.js');
39
41
  const SO = require('./sprint-overview.js');
40
42
  const SH = require('./sprint-history.js');
43
+ const RR = require('./rollover-reasons.js');
41
44
  const SN = require('./sprint-now.js');
42
45
  /** The PM's own name for Who (PMOS_PM_NAME, else git's user.name: the name Home greets them by); '' when neither is set. */
43
46
  const pmNameOf = () => { try { return require('./routes-board-publish.js').sharedBy() || ''; } catch { return ''; } };
@@ -166,7 +169,8 @@ function sprintInputs(w, board, pmNotes, tasks, jiraStatus) {
166
169
  for (const k of set) if (typeof k === 'string' && k) projects.add(k.toUpperCase());
167
170
  if (!projects.size) for (const t of tasks || []) if (t.key) projects.add(String(t.key).split('-')[0].toUpperCase());
168
171
  const notes = read(() => jiraStatus.readSprintNotes(w.root));
169
- return { lines: read(() => SH.read(w.root)) || [], notes: notes ? notes.notes : [], whole: read(() => jiraStatus.readSprints(w.root)), pmNotes: pmNotes || {}, projects: [...projects] };
172
+ return { lines: read(() => SH.read(w.root)) || [], notes: notes ? notes.notes : [], whole: read(() => jiraStatus.readSprints(w.root)), pmNotes: pmNotes || {}, projects: [...projects],
173
+ reasons: read(() => RR.foldOf(RR.read(w.root))) || new Map() };
170
174
  }
171
175
 
172
176
  /** A task PMOS finished by itself (or the PM approved) is closed in PMOS, once: the same write as `pmos task state --to Done`, as the agent. */
@@ -222,7 +226,7 @@ async function handle(req, res, url, ctx) {
222
226
  if (!d) return send(bad(404, 'PMOS knows no sprint of that name on this board'));
223
227
  return send({ status: 200, body: { ok: true, ws: L.ws, board: L.board, sprint: d } });
224
228
  }
225
- if (!['give', 'stop', 'decide', 'undo', 'decline', 'place', 'rank', 'sprint-draft', 'sprint-note'].includes(sub)) return send(bad(404, 'no such route'));
229
+ if (!['give', 'stop', 'decide', 'undo', 'decline', 'place', 'rank', 'sprint-draft', 'sprint-note', 'sprint-reason'].includes(sub)) return send(bad(404, 'no such route'));
226
230
  if (req.method !== 'POST') return send(bad(405, 'POST only'));
227
231
  const read = await ctx.readJson(req);
228
232
  if (!read.ok || !read.body || typeof read.body !== 'object') return send(bad(400, 'the body must be a JSON object'));
@@ -237,6 +241,14 @@ async function handle(req, res, url, ctx) {
237
241
  const gives = BL.foldGives(readGives(ctx));
238
242
  const giveOf = (id) => (gives.get(BL.keyOf(ws, board, id)) || { give: null, declined: null, n: 0 });
239
243
 
244
+ // why a ticket rolled to the next sprint (initiative rollover-reason): one tap on a ticket the closed sprint carried; reason null clears it
245
+ if (sub === 'sprint-reason') {
246
+ const r = RR.saveCarried(L._w.root, { sprint: body.sprint, key: body.key, reason: body.reason, by: g.actor.by }, L._sin);
247
+ if (!r.ok) return send(bad(400, r.error));
248
+ const c = RR.checkOf(body);
249
+ return send({ status: 200, body: { ok: true, key: c.key, sprint: c.sprint, reason: c.reason, was: r.was } });
250
+ }
251
+
240
252
  // the sprint overview (initiative sprint-overview): PMOS's written draft of one active sprint, and the PM's edits of it
241
253
  if (sub === 'sprint-draft' || sub === 'sprint-note') {
242
254
  const sprint = text(body.sprint).slice(0, 120);
@@ -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'));
@@ -81,9 +81,9 @@ function list(deps = {}) {
81
81
  }
82
82
 
83
83
  // The commands a card's buttons run live beside the chat's commands (star-buttons-act-directly): GET /api/card-catalog
84
- // (lib/routes-card-catalog.js) and the ✦ drafts' background job, POST/GET /api/star-drafts (lib/routes-star-drafts.js). They ride on this
84
+ // (lib/card-catalog-route.js) and the ✦ drafts' background job, POST/GET /api/star-drafts (lib/star-drafts-route.js). They ride on this
85
85
  // module's entry, so route-modules.js keeps its list.
86
- const BESIDE = [require('./routes-card-catalog.js'), require('./routes-star-drafts.js')];
86
+ const BESIDE = [require('./card-catalog-route.js'), require('./star-drafts-route.js')];
87
87
 
88
88
  module.exports = {
89
89
  prefixes: ['/api/slash-commands', '/api/card-catalog', '/api/star-drafts'],
@@ -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));
@@ -22,13 +22,15 @@
22
22
  * snapshotOf(lines, name) → the sprint as kept: its rows with their state at close and the counts (fold, pure)
23
23
  * closeOf(lines, name) → { done, total, carried, carriedTo, carriedIn, points } | null PMOS's own close numbers (never the agent's)
24
24
  * listOf({ lines, notes, whole, pmNotes, projects }) → the sprint picker (SpH1): every sprint PMOS knows of, newest first
25
- * detailOf(name, same inputs) → one sprint for the frozen view (SpH2) or the never-seen view (SpH3)
25
+ * detailOf(name, same inputs) → one sprint for the frozen view (SpH2) or the never-seen view (SpH3); with inputs.reasons (the fold of
26
+ * lib/rollover-reasons.js) each carried row has its reason and the sprint its `why` counts (initiative rollover-reason)
26
27
  * trendOf(list) → { line, bars } the carried-over work across the kept sprints; null when there is nothing to say
27
28
  *
28
29
  * BOUNDARY. No network, no child process. Reads Jira only through the files the read path saved; writes only the history file. */
29
30
  const fs = require('fs');
30
31
  const path = require('path');
31
32
  const jiraTickets = require('./jira-tickets.js');
33
+ const RR = require('./rollover-reasons.js');
32
34
 
33
35
  const FILE = '_sprint-history.jsonl';
34
36
  const fileOf = (root) => path.join(jiraTickets.jiraDir(root), FILE);
@@ -277,6 +279,10 @@ function detailOf(name, inp) {
277
279
  }
278
280
  for (const t of g.whole) { const r = rows.get(t.key); if (r && !r.url && t.url) r.url = t.url; }
279
281
  const R = [...rows.values()].sort((a, b) => a.key.localeCompare(b.key, undefined, { numeric: true }));
282
+ // why each carried ticket rolled on (initiative rollover-reason): one tap per ticket, kept in lib/rollover-reasons.js; done rows take none
283
+ const RF = inp.reasons instanceof Map ? inp.reasons : null;
284
+ for (const r of R) if (r.category !== 'done') r.reason = (RF && RF.get(name + '|' + String(r.key).toUpperCase()) || {}).reason || null;
285
+ const why = RR.whyOf(R, RF, name);
280
286
  const removed = g.snap ? g.snap.rows.filter((x) => x.removed) : [];
281
287
  // rows the snapshot cannot show (old data): the note counted more than PMOS kept, said once, on one quiet row
282
288
  const gotDone = R.filter((r) => r.category === 'done').length, gotCarried = R.filter((r) => r.category !== 'done').length;
@@ -288,7 +294,7 @@ function detailOf(name, inp) {
288
294
  const themes = n ? (n.themes || []).map((t) => ({ title: t.title, tickets: t.tickets || 0, done: t.done || 0, keys: Array.isArray(t.keys) ? t.keys.filter((x) => rows.has(x)) : [] })) : [];
289
295
  return { ...base, ...k, hit: n && n.hit ? n.hit : null, got: n && n.got ? n.got : null, themes,
290
296
  happened: n ? sentences(n.summary).slice(0, 5) : [], rows: R, removed: removed.map((r) => ({ key: r.key, title: r.title })), missing,
291
- addedLater: g.snap && g.snap.seenOpen ? g.snap.counts.added : null };
297
+ addedLater: g.snap && g.snap.seenOpen ? g.snap.counts.added : null, ...(why ? { why } : {}) };
292
298
  }
293
299
 
294
300
  module.exports = { FILE, fileOf, read, append, snapshotOf, closeOf, listOf, detailOf, trendOf, WHY };
@@ -1,5 +1,5 @@
1
1
  'use strict';
2
- /* routes-star-drafts.js — a ✦ "Draft …" answer as a PMOS background job (star-buttons-act-directly, done test A7; lib/star-draft.js).
2
+ /* star-drafts-route.js — a ✦ "Draft …" answer as a PMOS background job (star-buttons-act-directly, done test A7; lib/star-draft.js).
3
3
  *
4
4
  * POST /api/star-drafts { ws, ask, again? } → { ok, state: 'pending' | 'ready' | 'failed', key, text?, why? } starts the job, or
5
5
  * answers the kept draft at once
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.782.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.782.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.782.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",
@@ -225,6 +225,17 @@ textarea.bk-rvl-ed, .bk-rvl textarea.bd { resize: vertical; min-height: 180px; }
225
225
  .bk-past .bk-t { cursor: text; }
226
226
  .bk-past a.bk-t { cursor: pointer; }
227
227
  .bk-past .bk-more { box-sizing: border-box; width: 100%; }
228
+ /* why a carried ticket rolled on (initiative rollover-reason): one tap under its title */
229
+ .bk-past .bk-wy > .c-n { flex-wrap: wrap; row-gap: var(--space-4); padding: 6px 0; white-space: normal; }
230
+ .bk-past .bk-wy .bk-t { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
231
+ .bk-why { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-left: 24px; }
232
+ .bk-wb { all: unset; cursor: pointer; display: inline-flex; align-items: center; height: 24px; padding: 0 var(--space-8); border-radius: var(--radius-pill); font-size: var(--fs-meta); color: var(--cz-ink2); box-shadow: inset 0 0 0 1px var(--cz-hair); white-space: nowrap; }
233
+ .bk-wb.on { cursor: default; background: var(--cz-ink); color: var(--cz-card); box-shadow: none; }
234
+ .bk-why .bk-wx { width: 22px; height: 22px; }
235
+ .bk-wb:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
236
+ @media (hover: hover) { .bk-wb:not(.on):hover { background: var(--cz-well); } }
237
+ @media (pointer: coarse) { .bk-wb { height: 36px; } }
238
+ .sbo-b li.sbo-why span { color: var(--cz-ink2); font-size: var(--fs-meta); }
228
239
  .sbo-pk:focus-visible, .sbo-mi:focus-visible, .sbo-mo:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
229
240
  @media (hover: hover) { .sbo-mi:hover:not(.on) { background: var(--cz-well); } }
230
241
  @media (max-width: 1100px) { .sbo-pl { grid-template-columns: 1fr 1fr; } }
@@ -205,8 +205,10 @@ function pastHtml(o, H, x, deps) {
205
205
  + `<div class="sbo-ed"><button type="button" class="bk-ib ok" data-sppsave="${k}" aria-label="Save ${title}" title="Save">${SV(I.ok)}</button><button type="button" class="bk-ib" data-spcancel aria-label="Cancel" title="Cancel">${SV(I.x)}</button></div></div>`;
206
206
  return `<div class="sbo-b">${h}${L.length ? ulOf(L) : `<ul class="q"><li><span>${esc(empty)}</span></li></ul>`}</div>`;
207
207
  };
208
+ const whyLine = d ? SK.whyLineOf(d.why) : ''; // why they rolled on (initiative rollover-reason): the one-tap reasons, counted
208
209
  const carriedCol = x.carried ? `<div class="sbo-b"><h4>Carried to ${esc(to)}</h4><ul><li><span>${x.carried} open ${x.carried === 1 ? 'ticket' : 'tickets'}</span>`
209
- + (x.carriedTo && H.list.some((y) => y.name === x.carriedTo) ? `<button type="button" class="bk-lnk" data-spgo="${esc(x.carriedTo)}">open ${esc(to)}</button>` : '') + '</li></ul></div>' : '';
210
+ + (x.carriedTo && H.list.some((y) => y.name === x.carriedTo) ? `<button type="button" class="bk-lnk" data-spgo="${esc(x.carriedTo)}">open ${esc(to)}</button>` : '') + '</li>'
211
+ + (whyLine ? `<li class="sbo-why"><span>${esc(whyLine)}</span></li>` : '') + '</ul></div>' : '';
210
212
  const pl = `<div class="sbo-pl">${pblock('happened', 'What happened', happened, !note.happened, 'PMOS writes this when the sprint closes.')}${carriedCol}${pblock('lessons', 'Lessons', lessons, false, 'Add what the team learned. Kept with the snapshot.')}</div>`;
211
213
  return `<section class="sbo-band sbo-past" aria-label="${esc(SK.labelOf(x.name))}, snapshot"><div class="sbo-top">${sum}${th}</div>${pl}</section>`;
212
214
  }
@@ -222,21 +224,31 @@ export function pastListHtml() {
222
224
  const as = CURP.x.keptAt ? 'as read on ' + SK.dayOf(CURP.x.keptAt) : '';
223
225
  const cols = 'style="--bk-cols: 40px minmax(240px, 1fr) 104px minmax(80px, 160px) minmax(140px, 220px) 72px"';
224
226
  const head = '<div class="bk-r bk-h" role="row"><span class="c-ck"></span><span class="c-n">Task</span><span class="c-jira">Jira ticket</span><span class="c-epic">Epic</span><span class="c-state">State at close</span><span class="c-a"></span></div>';
225
- const row = (r) => `<div class="bk-r bk-i" role="row"><span class="c-ck"></span><span class="c-n bk-n"><i class="bk-ic" title="Task">${SV('M5 5h14v14H5z')}</i>`
226
- + (r.url ? `<a class="bk-t" href="${esc(r.url)}" target="_blank" rel="noopener" title="${esc(r.title)}">${esc(r.title)}</a>` : `<span class="bk-t" title="${esc(r.title)}">${esc(r.title)}</span>`) + '</span>'
227
- + `<span class="c-jira"><span class="bk-jk" title="Jira ticket ${esc(r.key)}">${SV(I.jira)}${esc(r.key)}</span></span>`
228
- + `<span class="c-epic">${r.epicName || r.epic ? `<span title="${esc(r.epicName || r.epic)}">${esc(r.epicName || r.epic)}</span>` : '<span class="q">No epic</span>'}</span>`
229
- + `<span class="c-state bk-s"><i class="bk-dot ${r.category === 'done' ? 'green' : r.category === 'doing' ? 'blue' : ''}"></i>${esc(r.status || (r.category === 'done' ? 'Done' : 'Open'))}</span><span class="c-a"></span></div>`;
230
227
  const body = G.map((g, i) => {
231
228
  const cut = g.k === 'done' && !PMORE && !th && g.rows.length > 6;
232
229
  const R = cut ? g.rows.slice(0, 6) : g.rows;
233
230
  return `<div class="bk-r bk-g open" role="row"><span class="bk-gt"><b>${esc(g.n)}</b><span class="k">${g.rows.length} kept</span></span>${i === 0 && as ? `<span class="bk-gs">${esc(as)}</span>` : ''}${th ? `<button type="button" class="bk-lnk" data-spall>Show all</button>` : ''}</div>`
234
- + R.map(row).join('') + (cut ? `<button type="button" class="bk-r bk-more" data-sppmore>${SV(I.chev)}${g.rows.length - 6} more done ${g.rows.length - 6 === 1 ? 'ticket' : 'tickets'}</button>` : '');
231
+ + R.map(pastRowHtml).join('') + (cut ? `<button type="button" class="bk-r bk-more" data-sppmore>${SV(I.chev)}${g.rows.length - 6} more done ${g.rows.length - 6 === 1 ? 'ticket' : 'tickets'}</button>` : '');
235
232
  }).join('') || '<p class="bk-none">PMOS kept no row of this sprint\'s tickets.</p>';
236
233
  const miss = SK.missingLineOf(d.missing);
237
234
  return `<div class="bk bk-past" role="table" aria-label="${esc(SK.labelOf(d.name))} at close" ${cols}>${head}${body}${miss && !th ? `<p class="sbo-miss" role="row">${esc(miss)}</p>` : ''}</div>`;
238
235
  }
239
236
 
237
+ /** One row of a past sprint's list: its state at close, and for a carried ticket why it rolled on (whyHtml). */
238
+ export const pastRowHtml = (r) => `<div class="bk-r bk-i${r.category !== 'done' ? ' bk-wy' : ''}" role="row"><span class="c-ck"></span><span class="c-n bk-n"><i class="bk-ic" title="Task">${SV('M5 5h14v14H5z')}</i>`
239
+ + (r.url ? `<a class="bk-t" href="${esc(r.url)}" target="_blank" rel="noopener" title="${esc(r.title)}">${esc(r.title)}</a>` : `<span class="bk-t" title="${esc(r.title)}">${esc(r.title)}</span>`)
240
+ + (r.category !== 'done' ? whyHtml(r) : '') + '</span>'
241
+ + `<span class="c-jira"><span class="bk-jk" title="Jira ticket ${esc(r.key)}">${SV(I.jira)}${esc(r.key)}</span></span>`
242
+ + `<span class="c-epic">${r.epicName || r.epic ? `<span title="${esc(r.epicName || r.epic)}">${esc(r.epicName || r.epic)}</span>` : '<span class="q">No epic</span>'}</span>`
243
+ + `<span class="c-state bk-s"><i class="bk-dot ${r.category === 'done' ? 'green' : r.category === 'doing' ? 'blue' : ''}"></i>${esc(r.status || (r.category === 'done' ? 'Done' : 'Open'))}</span><span class="c-a"></span></div>`;
244
+ /** Why a carried ticket rolled on (initiative rollover-reason): the four reasons as one-tap buttons, or the one said and a button to take it
245
+ * back. Nothing is written to Jira. */
246
+ function whyHtml(r) {
247
+ if (r.reason) return `<span class="bk-why"><span class="bk-wb on">${esc(SK.whyLabelOf(r.reason))}</span>`
248
+ + `<button type="button" class="bk-ib bk-wx" data-spwhyx="${esc(r.key)}" aria-label="${esc('Take back why ' + r.key + ' rolled on')}" title="Take back">${SV(I.x)}</button></span>`;
249
+ return `<span class="bk-why" role="group" aria-label="${esc('Why ' + r.key + ' rolled to the next sprint')}">`
250
+ + SK.WHY.map(([k, l]) => `<button type="button" class="bk-wb" data-spwhy="${k}" data-spkey="${esc(r.key)}">${esc(l)}</button>`).join('') + '</span>';
251
+ }
240
252
  /** The theme pressed, for the list below: { name, uids: Set, total } | null. */
241
253
  export function themeOf() {
242
254
  if (!THEME || !CUR || CURP) return null;
@@ -260,6 +272,7 @@ export async function press(e, deps) {
260
272
  deps.draw(); const k = document.querySelector('[data-spmenu]'); if (k) k.focus(); return true;
261
273
  }
262
274
  if (hit('data-sppmore')) { PMORE = true; deps.draw(); return true; }
275
+ if (CURP && CURP.d && ((b = hit('data-spwhy')) || (b = hit('data-spwhyx')))) return why(b, deps);
263
276
  if (hit('data-spcancel')) { EDIT = ''; deps.draw(); return true; }
264
277
  if (CURP && hit('data-spfill')) {
265
278
  const { H, x } = CURP, k = H.ws + '|' + H.board + '|' + x.name;
@@ -335,6 +348,26 @@ export async function press(e, deps) {
335
348
  if ((b = hit('data-spok'))) { const p = CUR.props.find((x) => x.id === b.dataset.spok); return p ? accept(p, b, deps) : true; }
336
349
  return false;
337
350
  }
351
+ /** One tap on why a carried ticket rolled on, or its take-back; both with Undo. The kept detail is updated in place, then read again. */
352
+ async function why(b, deps) {
353
+ const { H, x, d } = CURP, key = b.dataset.spkey || b.dataset.spwhyx, reason = b.dataset.spwhy || null;
354
+ const row = (d.rows || []).find((r) => r.key === key);
355
+ if (!row) return true;
356
+ const set = async (to) => {
357
+ const r = await deps.post('/api/backlog/sprint-reason', { ws: H.ws, board: H.board, sprint: x.name, key, reason: to });
358
+ if (!r || r.ok === false) { deps.say((r && r.error) || 'The reason was not saved.'); return null; }
359
+ const was = row.reason || null;
360
+ row.reason = to;
361
+ if (d.why) { if (was) d.why[was]--; else d.why.unsaid--; if (to) d.why[to]++; else d.why.unsaid++; }
362
+ deps.draw();
363
+ return r;
364
+ };
365
+ const r = await set(reason);
366
+ if (!r) return true;
367
+ const was = r.was || null;
368
+ deps.say(reason ? `${key}: ${SK.whyLabelOf(reason).toLowerCase()}.` : `${key}: reason taken back.`, () => set(was));
369
+ return true;
370
+ }
338
371
  /** No on a proposal: not now, with Undo. */
339
372
  async function dismiss(p, at, deps) {
340
373
  const r = await deps.post('/api/backlog/sprint-note', { ...at, ev: 'dismiss', id: p.id });
@@ -305,6 +305,16 @@ export function pastGroupsOf(d, keys) {
305
305
  if (open.length) G.push({ k: 'carried', n: 'Carried to ' + to, rows: open });
306
306
  return G;
307
307
  }
308
+ /** Why work rolled to the next sprint (initiative rollover-reason): the four one-tap reasons, in the order the row shows them. */
309
+ export const WHY = [['blocked', 'Blocked'], ['bigger', 'Bigger than thought'], ['pushed', 'Pushed down'], ['waiting', 'Waiting on someone']];
310
+ export const whyLabelOf = (k) => (WHY.find(([x]) => x === k) || [, ''])[1];
311
+ /** The carried block's count line: each reason with tickets, largest first, then the ones not said. Zero is silence: '' with nothing carried. */
312
+ export function whyLineOf(w) {
313
+ if (!w) return '';
314
+ const said = WHY.filter(([k]) => w[k] > 0).sort((a, b) => w[b[0]] - w[a[0]]).map(([k, l]) => `${w[k]} ${l.toLowerCase()}`);
315
+ if (w.unsaid > 0) said.push(`${w.unsaid} not said yet`);
316
+ return said.join(' · ');
317
+ }
308
318
  /** The one quiet row for rows the snapshot does not hold (old data): '' when none are missing. */
309
319
  export function missingLineOf(m) {
310
320
  if (!m || (!m.done && !m.carried)) return '';
@@ -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,9 @@
1
+ {
2
+ "_comment": "One-tap reason when work rolls to the next sprint (initiative rollover-reason, done test planning/done-tests/rollover-reason.md R1-R7). The store, the fold, the write the route and the chat share, the CLI and the rendered rows, in process. No connector, model or network.",
3
+ "modules": [
4
+ "rollover-reason.test.js"
5
+ ],
6
+ "seconds": {
7
+ "rollover-reason.test.js": 2
8
+ }
9
+ }
@@ -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
+ }