create-pmos 0.647.0 → 0.649.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.647.0",
3
+ "version": "0.649.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,32 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.649.0",
38
+ "at": "2026-11-20T06:16:36.793Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1431,
43
+ "t": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
44
+ "s": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.648.0",
51
+ "at": "2026-11-20T05:58:53.312Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1430,
56
+ "t": "Work's This sprint tab holds all work in the sprint's dates",
57
+ "s": "Work's This sprint tab holds all work in the sprint's dates",
58
+ "k": "new"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.647.0",
38
64
  "at": "2026-11-20T05:31:50.958Z",
@@ -290,32 +316,6 @@
290
316
  "k": "fix"
291
317
  }
292
318
  ]
293
- },
294
- {
295
- "v": "0.622.0",
296
- "at": "2026-11-19T05:05:08.698Z",
297
- "f": 4,
298
- "prs": [
299
- {
300
- "n": 1403,
301
- "t": "Work breakdown back to stages with their tasks; no-stage tasks in the Backlog",
302
- "s": "Work breakdown back to stages with their tasks; no-stage tasks in the Backlog",
303
- "k": "fix"
304
- }
305
- ]
306
- },
307
- {
308
- "v": "0.621.0",
309
- "at": "2026-11-19T04:46:30.709Z",
310
- "f": 4,
311
- "prs": [
312
- {
313
- "n": 1402,
314
- "t": "Backlog rows open the small task popup",
315
- "s": "Backlog rows open the small task popup",
316
- "k": "new"
317
- }
318
- ]
319
319
  }
320
320
  ]
321
321
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@c1158750
1
+ kernel-source: pmos@6a943aac
2
2
  assembled: 2026-11-20
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-20T05:31:47Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-20T06:16:33Z"}
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-20T05:31:47Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-20T06:16:33Z"}
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-20T05:31:47Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-20T06:16:33Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.649.0",
4
+ "at": "2026-11-20T06:16:36.793Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1431,
9
+ "t": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
10
+ "s": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.648.0",
17
+ "at": "2026-11-20T05:58:53.312Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1430,
22
+ "t": "Work's This sprint tab holds all work in the sprint's dates",
23
+ "s": "Work's This sprint tab holds all work in the sprint's dates",
24
+ "k": "new"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.647.0",
4
30
  "at": "2026-11-20T05:31:50.958Z",
@@ -94,6 +94,17 @@ On a computer, Work is built from the parts of the PMOS design system. The top l
94
94
  - **Initiatives.** A table with the columns you choose (the tune icon also sorts and filters). Press a column heading to sort by it. The timeline shows done in green, now in blue and planned in grey, with a red line for today. A milestone is a diamond on its initiative's row; a late one is red. Milestones less than 8 days apart are one numbered diamond: point at it to see them. Pick the scale with **Week**, **Month**, **Quarter**, **Year** or **Full**. Move the timeline with the arrows, with a sideways swipe on a trackpad, or by dragging it; the middle arrow goes back to today. A late date has a red badge, for example "8 days late". Closed initiatives fold into one line at the end.
95
95
  - **Next milestones.** The next five milestones of all initiatives on one line, on the same scale as the table, each with its date, its name and its initiative. Labels that are too close move down a row. A milestone after the end of the line is in the **+N** mark at the right: press it to move the line on. When the line has moved, a mark at the left moves it back. Press a diamond to open the milestone.
96
96
 
97
+ **Backlog** is the open work outside the sprint, in one rank across initiatives.
98
+
99
+ - **Where it stands.** A few lines: how many items wait, how many are ready to pull into the next sprint and from which initiatives, how many have not changed in 60 days, and how many have no initiative. An item is ready when it has an initiative and an owner, is not started, and PMOS is not working on it. Under it, PMOS suggests pulling the top ready items into the next sprint. ✓ gives the PMOS tasks the next sprint's dates (with Undo) and lists the Jira tickets for you to add in Jira, because PMOS does not change Jira. The pencil ticks the items on the **Ready** tab so you can change the pick first, and ✕ says not now.
100
+ - **Add to the backlog.** Type a line and press Enter. Name the initiative ("for Migration from Okta") or PMOS puts it in the closest one; when none is close, it asks.
101
+ - **Items.** A table grouped by initiative, each group with "n items · r ready". The tabs show **All**, **Ready**, **Needs detail** or **Untouched 60 days**. Drag a row by its grip to change the rank (with Undo); the number is its place in the one rank. **Last change** shows when the item last changed; an item untouched for 30 days or more has a badge, for example "79 days untouched". **Group** also groups the rows by what PMOS can do, with its ✓ buttons. Tick rows to change them together. The tune icon filters the rows.
102
+
103
+ **This sprint** shows all work in the sprint's dates, in Jira and outside it. It holds every ticket of the active Jira sprint, done ones too, and every PMOS task whose dates meet the sprint's dates. A task under way with no date is in it too. Early stages often have no tickets, so their work still shows here.
104
+
105
+ - **The sprint card.** The sprint's name, its end date and what it holds, for example "21 Jira tickets and 7 tasks outside Jira". Under it, "11 of 28 done" with a bar. Then four columns: **Sprint goal**, **In progress**, **To do** and **Done**, each with its count and its first tasks. PMOS drafts the goal from the sprint's work. Press the pencil to write your own; it can name work outside Jira, and PMOS does not write over it. When PMOS has a newer draft, ✓ uses it and ✕ keeps yours. Press the sprint's name to open a past sprint. The arrow icon reads Jira again; a red dot on it means the last read is old. Under the columns, PMOS shows one suggestion, for example to place tickets in an initiative, with **Why**, **PMOS will**, **What changes** and **Based on**. The pencil picks another initiative first, ✓ does it (with Undo) and ✕ says not now.
106
+ - **Tasks.** A table of the sprint's work, grouped by initiative. Each group says how much is done, for example "2 of 5 done". The tabs show **All**, **To do**, **In progress** or **Done**. **Group** groups the rows by initiative, by who has them, by state, by the themes PMOS found in the ticket titles, or not at all. **Source** shows the Jira ticket, or "Not in Jira". A due date that has passed on work that is not done has a red badge, for example "1 day late". A ticket that moved sprint twice says "Moved twice". Press a task to open it.
107
+
97
108
  ## The Viewer
98
109
 
99
110
  The Viewer shows one item: an initiative, a program, a task, a document, a meeting, a report, Your day or a page of this guide.
@@ -177,7 +177,7 @@ function foundOf(f) {
177
177
  }
178
178
  const KINDS = new Set(['board', 'workflow', 'move', 'assign', 'ask', 'ask-accept', 'ask-decline', 'ask-more', 'ini-workflow', 'task', 'task-update', 'task-remove', 'task-restore', 'ticket-note', 'ini-epics', 'ini-archive', 'ini-notdup', 'ini-wf', 'ini-end', 'stage-judge', 'ini-auto', 'task-section', 'task-milestone', 'task-pin', 'ticket-dates', 'task-order',
179
179
  // split or merge initiatives (feedback batch 11 item 14): a Jira ticket moved to another initiative, the split and merge records with their Undo, Claude's suggestion dismissed
180
- 'ticket-move', 'ini-split', 'ini-merge', 'ini-sm-undo', 'ini-suggest',
180
+ 'ticket-move', 'ini-split', 'ini-merge', 'ini-sm-undo', 'ini-suggest', 'backlog-rank',
181
181
  // Delete an initiative with its tasks, and its Undo (feedback batch 16 item 5d)
182
182
  'ini-delete', 'ini-restore']);
183
183
  // A task's state is its only stage (Wawan, 2026-10-25): the same five every workflow ends in. An old 'In review' reads as In progress (taskState).
@@ -227,6 +227,7 @@ function fold(events) {
227
227
  // split or merge (batch 11 item 14): Jira key → the initiative it moved to (a split or a merge; `to: null` sends it back to where Jira puts it),
228
228
  // op id → the ini-split / ini-merge line (its `undo` says how to put everything back), the ops undone, and the PM's ✕ on Claude's suggestion
229
229
  const ticketMoves = new Map();
230
+ const backlogRank = new Map(); // board → [task id], the Backlog's rank (backlog-rank lines)
230
231
  const smOps = new Map();
231
232
  const smUndone = new Set();
232
233
  const suggestNo = new Map(); // initiative id → { kind, fp, at } (the last ✕; a suggestion with another fingerprint shows again)
@@ -378,6 +379,10 @@ function fold(events) {
378
379
  const a = asks.get(e.ask);
379
380
  if (a.state !== 'open') continue;
380
381
  Object.assign(a, { state: 'declined', why: e.why || '', closedAt: e.at || null });
382
+ } else if (e.kind === 'backlog-rank' && b && Array.isArray(e.order)) {
383
+ // the Backlog's one rank across initiatives (D105; Work's Backlog, WorkBacklogDS): the board's open tasks, top first; [] clears it
384
+ const ids = [...new Set(e.order.filter((x) => typeof x === 'string' && x && x.length <= 120))];
385
+ if (ids.length) backlogRank.set(b, ids); else backlogRank.delete(b);
381
386
  } else if (e.kind === 'ticket-move' && typeof e.key === 'string' && JIRA_KEY_RE.test(e.key)) {
382
387
  if (typeof e.to === 'string' && e.to) ticketMoves.set(e.key.toUpperCase(), e.to); else ticketMoves.delete(e.key.toUpperCase());
383
388
  } else if ((e.kind === 'ini-split' || e.kind === 'ini-merge') && typeof e.op === 'string' && e.op && !smOps.has(e.op)) {
@@ -388,7 +393,7 @@ function fold(events) {
388
393
  suggestNo.set(e.id, { kind: e.of === 'merge' ? 'merge' : 'split', fp: e.fp, at: e.at || null });
389
394
  }
390
395
  }
391
- return { boards, moves, assigns, asks, stages, iniWorkflows, tasks, removed, sections, orders, milestones, pins, ticketNotes, ticketDates, epics, archives, deleted, notDup, iniWf, ends, judged, autoOver, ticketMoves, smOps, smUndone, suggestNo, events: list };
396
+ return { boards, moves, assigns, asks, stages, iniWorkflows, tasks, removed, sections, orders, milestones, pins, ticketNotes, ticketDates, epics, archives, deleted, notDup, iniWf, ends, judged, autoOver, ticketMoves, backlogRank, smOps, smUndone, suggestNo, events: list };
392
397
  }
393
398
 
394
399
  /** The stages an initiative runs on a board: its own workflow when one is recorded, else the board's. */
@@ -17,7 +17,11 @@
17
17
  * POST /api/backlog/decline { ws, board, task, undo? } ✕ on "PMOS can take these": not for PMOS (and its Undo)
18
18
  * GET /api/backlog/sprint?ws=&board=&sprint= → { ok, sprint } one sprint as PMOS kept it (initiative sprint-snapshots; SpH2, SpH3):
19
19
  * lib/sprint-history.js detailOf. GET /api/backlog also carries sprintList (the picker, SpH1) and
20
- * sprintTrend (the carried-over line and bars).
20
+ * sprintTrend (the carried-over line and bars), and sprintNow (This sprint: every task in the
21
+ * active sprint's dates, Jira and not, done ones too; lib/sprint-now.js).
22
+ * POST /api/backlog/rank { ws, board, order: [id] } the Backlog's one rank across initiatives (a backlog-rank line on the board
23
+ * ledger; D105). GET /api/backlog carries it as backlogRank, each task's inSprint and touched (its last
24
+ * change), and sprintNext (the earliest future sprint, as Jira holds it).
21
25
  * POST /api/backlog/place { ws, board, key, to } a No home Jira ticket into an initiative (a ticket-move line on the board
22
26
  * ledger, as a split or merge writes it; Jira is not written to, D88). to '' takes it back out.
23
27
  *
@@ -34,6 +38,7 @@ const assigned = require('./work-assigned.js');
34
38
  const WK = require('./work-kind.js');
35
39
  const SO = require('./sprint-overview.js');
36
40
  const SH = require('./sprint-history.js');
41
+ const SN = require('./sprint-now.js');
37
42
  /** 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. */
38
43
  const pmNameOf = () => { try { return require('./routes-board-publish.js').sharedBy() || ''; } catch { return ''; } };
39
44
 
@@ -96,6 +101,17 @@ function readingsOf(w, jiraStatus) {
96
101
  }
97
102
 
98
103
  /** One board's tasks, as GET /api/backlog answers them. → { ok, ... } | { pending } | { error, status } */
104
+ /** When a task was last touched: a PMOS task's last line on its ledger, a Jira ticket's last update as Jira gave it. → (task) → 'YYYY-MM-DD' | '' */
105
+ function touchedOf(folded, R) {
106
+ return (t) => {
107
+ if (t.src === 'jira') { const rd = R.get(String(t.key || t.id).toUpperCase()); return rd && rd.updated ? String(rd.updated).slice(0, 10) : ''; }
108
+ const f = folded && folded.get ? folded.get(t.id) : null;
109
+ if (!f) return '';
110
+ const ats = [f.at, ...(f.history || []).map((h) => h.at)].filter((x) => typeof x === 'string' && x).sort();
111
+ return ats.length ? ats[ats.length - 1].slice(0, 10) : '';
112
+ };
113
+ }
114
+
99
115
  function listOf(ctx, wsId, boardId, now) {
100
116
  const RB = require('./routes-boards.js');
101
117
  const jiraStatus = require('./jira-status.js');
@@ -129,7 +145,15 @@ function listOf(ctx, wsId, boardId, now) {
129
145
  const sin = sprintInputs(w, board, sprintNotes, tasks, jiraStatus);
130
146
  let sprintList = [], sprintTrend = null;
131
147
  try { sprintList = SH.listOf(sin); sprintTrend = SH.trendOf(sprintList); } catch { sprintList = []; sprintTrend = null; }
132
- return { ok: true, ws: w.id, board: board.id, product, mode, sprintNotes, sprintList, sprintTrend, _sin: sin, modeLabel: BL.MODE_LABEL[mode], kinds: BL.countKinds(inis.map((x) => x.kind)), factory, readAt, today,
148
+ // This sprint (WorkSprintDS): all work in the sprint's dates, Jira and not, done work too
149
+ let sprintNow = []; try { sprintNow = SN.sprintsNowOf({ R, tasks, items, inis, projects: sin.projects, today, me: actorLib.PM_SLUG, pmName: pmNameOf() }); } catch { sprintNow = []; }
150
+ // the Backlog (WorkBacklogDS): what waits outside the sprint, its one rank across initiatives, when each task was last touched, the next sprint
151
+ const inSprint = new Set(sprintNow.flatMap((sp) => sp.rows.map((r) => r.id)));
152
+ const touched = touchedOf(fr.folded.tasks, R);
153
+ for (const t of tasks) { t.inSprint = inSprint.has(t.id); const at = touched(t); if (at) t.touched = at; }
154
+ const backlogRank = (fr.folded.backlogRank && fr.folded.backlogRank.get(board.id)) || [];
155
+ let sprintNext = null; try { sprintNext = SN.nextSprintOf(R, sin.projects); } catch { sprintNext = null; }
156
+ return { ok: true, ws: w.id, board: board.id, product, mode, sprintNotes, sprintList, sprintTrend, sprintNow, sprintNext, backlogRank, _sin: sin, modeLabel: BL.MODE_LABEL[mode], kinds: BL.countKinds(inis.map((x) => x.kind)), factory, readAt, today,
133
157
  tasks, inis: inis.map((x) => ({ id: x.id, title: x.title, kind: x.kind })), _w: w, _RB: RB, _runTasks: runTasks };
134
158
  }
135
159
 
@@ -198,7 +222,7 @@ async function handle(req, res, url, ctx) {
198
222
  if (!d) return send(bad(404, 'PMOS knows no sprint of that name on this board'));
199
223
  return send({ status: 200, body: { ok: true, ws: L.ws, board: L.board, sprint: d } });
200
224
  }
201
- if (!['give', 'stop', 'decide', 'undo', 'decline', 'place', 'sprint-draft', 'sprint-note'].includes(sub)) return send(bad(404, 'no such route'));
225
+ if (!['give', 'stop', 'decide', 'undo', 'decline', 'place', 'rank', 'sprint-draft', 'sprint-note'].includes(sub)) return send(bad(404, 'no such route'));
202
226
  if (req.method !== 'POST') return send(bad(405, 'POST only'));
203
227
  const read = await ctx.readJson(req);
204
228
  if (!read.ok || !read.body || typeof read.body !== 'object') return send(bad(400, 'the body must be a JSON object'));
@@ -247,6 +271,16 @@ async function handle(req, res, url, ctx) {
247
271
  return send({ status: 200, body: { ok: true, key, to, from: was } });
248
272
  }
249
273
 
274
+ // the Backlog's one rank across initiatives (D105; WorkBacklogDS): a drag writes the board's whole order, top first; [] clears it
275
+ if (sub === 'rank') {
276
+ if (!Array.isArray(body.order) || body.order.length > 2000 || body.order.some((x) => typeof x !== 'string' || !x || x.length > 120)) return send(bad(400, 'order is a list of at most 2000 task ids, top first'));
277
+ const file = L._RB.ledgerFile(ctx, L._w);
278
+ if (!file) return send(bad(409, L._RB.NO_STATE));
279
+ const order = [...new Set(body.order)];
280
+ L._RB.append(file, g.actor, { kind: 'backlog-rank', board, order, why: order.length ? 'reranked in the Backlog' : 'rank taken out' });
281
+ return send({ status: 200, body: { ok: true, from: L.backlogRank || [] } });
282
+ }
283
+
250
284
  if (sub === 'give') {
251
285
  const ids = Array.isArray(body.tasks) ? body.tasks.map(text).filter(Boolean).slice(0, 50) : [text(body.task)].filter(Boolean);
252
286
  if (!ids.length) return send(bad(400, 'tasks is a list of task ids'));
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+ /* sprint-now.js — the sprint as Work › This sprint shows it (initiative work-ds-sprint; Exploring 3 page "work", board WorkSprintDS).
3
+ *
4
+ * The sprint holds ALL work in the sprint's dates, Jira and not (Wawan 2026-11-20: early stages have no tickets but still need reporting):
5
+ * · every Jira ticket of the board's projects in the active sprint, done ones too;
6
+ * · every PMOS task of the board whose dates meet the sprint's dates, or that is under way now when it has no date.
7
+ * Nothing is guessed: the sprint's dates are Jira's, a task's dates are its own. A sprint with no dates holds its tickets only.
8
+ *
9
+ * sprintsNowOf(input) → [{ name, label, start, end, rows, jira, other, done, total }] active sprints, the one with most work first.
10
+ * input: { R: Map key → Jira reading, tasks: the open rows of lib/backlog.js tasksOf, items: the board's items (every state), inis: [{ id,
11
+ * title }], projects: [Jira project key] (empty = every project), today: 'YYYY-MM-DD', me, pmName }
12
+ * row: { uid, id, src: jira|pmos, key, title, ini, iniTitle, who, state: To do|In progress|In review|Done, due, late (days), moved (other
13
+ * sprints the ticket was in), url, open (the row is in the Backlog's task list, so it opens as a task) }
14
+ * nextSprintOf(R, projects) → { name, label, start, end } | null the earliest future sprint (the Backlog pulls work into it)
15
+ */
16
+ const BL = require('./backlog.js');
17
+
18
+ const DAY = 864e5;
19
+ const dayNum = (d) => { const t = Date.parse(String(d || '').slice(0, 10) + 'T00:00:00Z'); return Number.isFinite(t) ? Math.round(t / DAY) : null; };
20
+ const str = (v, n) => String(v == null ? '' : v).slice(0, n);
21
+ const labelOf = (name) => { const m = /(sprint\s*\d+)\s*$/i.exec(String(name || '')); return m ? m[1].replace(/^s/, 'S') : String(name || ''); };
22
+ const stateOfJira = (rd) => (rd.category === 'done' ? 'Done' : rd.category === 'doing' ? (/review/i.test(rd.status || '') ? 'In review' : 'In progress') : 'To do');
23
+ const OPEN = new Set(['To do', 'In progress', 'In review']);
24
+
25
+ function sprintsNowOf(I) {
26
+ const R = I.R instanceof Map ? I.R : new Map();
27
+ const P = (I.projects || []).length ? new Set(I.projects.map((p) => String(p).toUpperCase())) : null;
28
+ const t0 = dayNum(I.today);
29
+ const iniBy = new Map((I.inis || []).map((x) => [x.id, x]));
30
+ const open = new Map((I.tasks || []).map((t) => [t.id, t]));
31
+ const me = String(I.me || '').toLowerCase();
32
+ const whoOf = (owner) => {
33
+ const o = str(owner, 80).replace(/^(?:person|tracker):/, '').trim();
34
+ if (!o) return '';
35
+ if (/^(pm|you|me)$/i.test(o) || /^pm:/i.test(o) || (me && o.toLowerCase() === me)) return I.pmName || 'You';
36
+ return BL.firstName(o);
37
+ };
38
+ const lateOf = (due, state) => { const d = dayNum(due); return d != null && t0 != null && d < t0 && OPEN.has(state) ? t0 - d : 0; };
39
+ const by = new Map();
40
+ for (const rd of R.values()) {
41
+ if (!rd || !rd.key || !rd.sprint || rd.sprint.state !== 'active' || !rd.sprint.name || /^epic$/i.test(rd.type || '')) continue;
42
+ const key = String(rd.key).toUpperCase();
43
+ if (P && !P.has(key.split('-')[0])) continue;
44
+ const name = String(rd.sprint.name);
45
+ if (!by.has(name)) by.set(name, { name, label: labelOf(name), start: null, end: null, rows: [] });
46
+ const sp = by.get(name);
47
+ if (!sp.start && rd.sprint.start) sp.start = String(rd.sprint.start).slice(0, 10);
48
+ if (!sp.end && rd.sprint.end) sp.end = String(rd.sprint.end).slice(0, 10);
49
+ const t = open.get(key);
50
+ const state = t ? t.state : stateOfJira(rd);
51
+ const ini = t ? t.ini : null;
52
+ const moved = Array.isArray(rd.sprints) ? rd.sprints.filter((s) => s && s.name && s.name !== name).length : 0;
53
+ const due = t ? t.due : null;
54
+ sp.rows.push({ uid: t ? t.ws + '|' + t.board + '|' + t.id : key, id: key, src: 'jira', key, title: str((t && t.title) || rd.summary || key, 300), ini, iniTitle: ini && iniBy.has(ini) ? str(iniBy.get(ini).title, 160) : '',
55
+ who: t ? t.who : whoOf(rd.assignee), state, due, late: lateOf(due, state), moved, url: (t && t.url) || rd.url || null, open: !!t });
56
+ }
57
+ for (const sp of by.values()) {
58
+ const s = dayNum(sp.start), e = dayNum(sp.end);
59
+ for (const w of I.items || []) {
60
+ if (!w || w.src !== 'pmos' || w.kind === 'Epic' || !w.uid) continue;
61
+ if (w.status === 'Archived' || w.status === "Won't do") continue;
62
+ const a = dayNum(w.start), b = dayNum(w.end);
63
+ const lo = a != null ? a : b, hi = b != null ? b : a;
64
+ const inDates = s != null && e != null && lo != null && lo <= e && hi >= s;
65
+ const now = lo == null && (w.status === 'In progress' || w.status === 'In review');
66
+ if (!inDates && !now) continue;
67
+ const id = String(w.uid), t = open.get(id);
68
+ const state = w.status === 'Done' ? 'Done' : OPEN.has(w.status) ? w.status : 'To do';
69
+ const ini = iniBy.has(w.ini) ? w.ini : null;
70
+ sp.rows.push({ uid: t ? t.ws + '|' + t.board + '|' + t.id : id, id, src: 'pmos', key: '', title: str(w.title, 300), ini, iniTitle: ini ? str(iniBy.get(ini).title, 160) : '',
71
+ who: t ? t.who : whoOf(w.owner), state, due: w.end || null, late: lateOf(w.end, state), moved: 0, url: null, open: !!t });
72
+ }
73
+ }
74
+ return [...by.values()].map((sp) => {
75
+ const jira = sp.rows.filter((r) => r.src === 'jira').length;
76
+ return { ...sp, jira, other: sp.rows.length - jira, done: sp.rows.filter((r) => r.state === 'Done').length, total: sp.rows.length };
77
+ }).sort((a, b) => b.total - a.total || a.name.localeCompare(b.name));
78
+ }
79
+
80
+ /** The board's next sprint, as Jira holds it: the earliest future sprint of the board's projects. → { name, label, start, end } | null */
81
+ function nextSprintOf(R, projects) {
82
+ const P = (projects || []).length ? new Set(projects.map((p) => String(p).toUpperCase())) : null;
83
+ const by = new Map();
84
+ for (const rd of (R instanceof Map ? R.values() : [])) {
85
+ if (!rd || !rd.key || !rd.sprint || rd.sprint.state !== 'future' || !rd.sprint.name) continue;
86
+ if (P && !P.has(String(rd.key).toUpperCase().split('-')[0])) continue;
87
+ const n = String(rd.sprint.name);
88
+ if (!by.has(n)) by.set(n, { name: n, label: labelOf(n), start: null, end: null });
89
+ const x = by.get(n);
90
+ if (!x.start && rd.sprint.start) x.start = String(rd.sprint.start).slice(0, 10);
91
+ if (!x.end && rd.sprint.end) x.end = String(rd.sprint.end).slice(0, 10);
92
+ }
93
+ return [...by.values()].sort((a, b) => (a.start || '9999').localeCompare(b.start || '9999') || a.name.localeCompare(b.name))[0] || null;
94
+ }
95
+
96
+ module.exports = { sprintsNowOf, nextSprintOf, labelOf };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.647.0",
3
+ "version": "0.649.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.647.0",
9
+ "version": "0.649.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.647.0",
3
+ "version": "0.649.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",
@@ -0,0 +1,176 @@
1
+ /* pm/bd-backlog-ds.js — the Backlog built from the design system's parts (initiative work-ds-backlog; Exploring 3 page "work", board
2
+ * WorkBacklogDS). Pure: HTML and numbers from data, no state, no fetch. pm/bd-backlog.js keeps the state and the presses.
3
+ *
4
+ * THE RULES, stated once (the guide says them too):
5
+ * · The Backlog is the open work outside the active sprint (GET /api/backlog marks each task inSprint; lib/sprint-now.js).
6
+ * · Ready = in an initiative, with an owner, not started, and PMOS is not working on it. Needs detail = the rest.
7
+ * · Untouched = no change for 60 days (a task's last ledger line; a Jira ticket's last update as Jira gave it). A row says how long from
8
+ * 30 days on.
9
+ * · The rank is one list across initiatives (D105): the board's backlog-rank line first, then the rest by initiative, due date and name.
10
+ * Groups follow their best-ranked row; "No initiative yet" goes last. A row's number is its place in that one list.
11
+ */
12
+ import { sugHtml } from './bd-stands.js';
13
+
14
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
15
+ const SV = (d, n = 16) => `<svg class="pm-ic" width="${n}" height="${n}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
16
+ const I = { star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', grip: 'M9 6h.01M15 6h.01M9 12h.01M15 12h.01M9 18h.01M15 18h.01', down: 'M7 10l5 5 5-5' };
17
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
18
+ const DAY = 864e5;
19
+ const dayNum = (d) => { const t = Date.parse(String(d || '').slice(0, 10) + 'T00:00:00Z'); return Number.isFinite(t) ? Math.round(t / DAY) : null; };
20
+ export const dayText = (d) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(d || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
21
+ const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
22
+ const NOINI = '~';
23
+ export const STALE = 60; // Untouched 60 days
24
+ const SAY_FROM = 30; // a row says how long it sat from 30 days on
25
+
26
+ /** In the Backlog: open, outside the active sprint, not finished by PMOS today. */
27
+ export const inBacklog = (t) => !!t && !t.inSprint && !(t.agent && t.agent.state === 'done' && t.agent.today !== false) && t.state !== 'Done';
28
+ const pmosHas = (t) => !!(t.agent && t.agent.state !== 'failed');
29
+ /** Ready for a sprint: in an initiative, with an owner, not started, and PMOS is not working on it. */
30
+ export const isReady = (t) => !!t.ini && !!t.who && t.whoKind !== 'none' && t.state === 'To do' && !pmosHas(t);
31
+ /** Days since the task was last touched, or null when PMOS does not know. */
32
+ export const idleOf = (t, today) => { const a = dayNum(t.touched), b = dayNum(today); return a == null || b == null ? null : Math.max(0, b - a); };
33
+ export const isStale = (t, today) => { const d = idleOf(t, today); return d != null && d >= STALE; };
34
+
35
+ export const TABS = [['all', 'All'], ['ready', 'Ready'], ['detail', 'Needs detail'], ['stale', 'Untouched 60 days']];
36
+ export const GROUPS = [['ini', 'Initiative'], ['pmos', 'What PMOS can do'], ['none', 'None']];
37
+ export function keepsTab(t, tab, today) {
38
+ if (tab === 'ready') return isReady(t);
39
+ if (tab === 'detail') return !isReady(t);
40
+ if (tab === 'stale') return isStale(t, today);
41
+ return true;
42
+ }
43
+ export function countsOf(B, today) { const c = { all: B.length, ready: 0, detail: 0, stale: 0 }; for (const t of B) { if (isReady(t)) c.ready++; else c.detail++; if (isStale(t, today)) c.stale++; } return c; }
44
+
45
+ /** The one rank across initiatives. B: the backlog's tasks; rank: [task id] (the board's backlog-rank line); inis: [{ id, title }] in the
46
+ * board's order. → the tasks in rank order, grouped: the groups follow their best-ranked row, "No initiative yet" last. */
47
+ export function ranked(B, rank, inis) {
48
+ const at = new Map((rank || []).map((id, i) => [id, i]));
49
+ const io = new Map((inis || []).map((x, i) => [x.id, i]));
50
+ const base = B.slice().sort((a, b) => {
51
+ const ra = at.has(a.id) ? at.get(a.id) : Infinity, rb = at.has(b.id) ? at.get(b.id) : Infinity;
52
+ if (ra !== rb) return ra - rb;
53
+ const ia = a.ini && io.has(a.ini) ? io.get(a.ini) : a.ini ? 9e8 : 9e9, ib = b.ini && io.has(b.ini) ? io.get(b.ini) : b.ini ? 9e8 : 9e9;
54
+ return ia - ib || (a.due || '9999').localeCompare(b.due || '9999') || String(a.title).localeCompare(String(b.title));
55
+ });
56
+ const groups = new Map();
57
+ for (const t of base) { const k = t.ini || NOINI; if (!groups.has(k)) groups.set(k, []); groups.get(k).push(t); }
58
+ const keys = [...groups.keys()].filter((k) => k !== NOINI).concat(groups.has(NOINI) ? [NOINI] : []);
59
+ return keys.flatMap((k) => groups.get(k));
60
+ }
61
+ /** The order a drag writes: the ranked list with `id` moved before `before` (or to the end of its group's list when before is ''). */
62
+ export function moved(order, id, before) {
63
+ const L = order.filter((x) => x !== id);
64
+ const i = before ? L.indexOf(before) : -1;
65
+ if (i < 0) L.push(id); else L.splice(i, 0, id);
66
+ return L;
67
+ }
68
+
69
+ /** Where it stands: what waits, what is ready for the next sprint, what is stale, what has no owner. Zero is silence. → [sentence] */
70
+ export function standsOf(B, o = {}) {
71
+ if (!B.length) return [];
72
+ const R = B.filter(isReady), stale = B.filter((t) => isStale(t, o.today)).length, noIni = B.filter((t) => !t.ini).length;
73
+ const out = [plural(B.length, 'item waits', 'items wait') + ' outside a sprint.'];
74
+ if (R.length) {
75
+ const nx = o.next;
76
+ const into = nx ? ` to pull into ${nx.label || nx.name}${nx.start ? ', which starts ' + dayText(nx.start) : ''}` : ' for the next sprint';
77
+ const by = new Map(); for (const t of R) by.set(t.iniTitle || t.ini, (by.get(t.iniTitle || t.ini) || 0) + 1);
78
+ const top = [...by].sort((a, b) => b[1] - a[1]);
79
+ const most = top.length > 1 && top[0][1] + (top[1] ? top[1][1] : 0) > R.length / 2 ? (top[1][1] > 1 ? `${top[0][0]} and ${top[1][0]}` : top[0][0]) : top.length === 1 && R.length > 1 ? top[0][0] : '';
80
+ out.push(`${R.length === B.length ? (R.length === 1 ? 'It is' : 'All are') : R.length + (R.length === 1 ? ' is' : ' are')} ready${into}${most ? `; most of them are ${most} work` : ''}.`);
81
+ }
82
+ const tail = [stale ? `${stale} ${stale === 1 ? 'has' : 'have'} not been touched in ${STALE} days` : '', noIni ? `${noIni} ${noIni === 1 ? 'has' : 'have'} no initiative, so nobody owns ${noIni === 1 ? 'it' : 'them'} yet` : ''].filter(Boolean);
83
+ if (tail.length) out.push(tail.join(', and ').replace(/^./, (c) => c.toUpperCase()) + '.');
84
+ return out;
85
+ }
86
+
87
+ /** The Suggestion: pull the top ready items into the next sprint. PMOS tasks get the sprint's dates; a Jira ticket is named for the PM to
88
+ * move in Jira (PMOS does not write to Jira). No next sprint with dates, or no task PMOS can date: no Suggestion. → { s, ids } | null */
89
+ export function pullOf(order, next, n = 4) {
90
+ if (!next || !next.start || !next.end) return null;
91
+ const top = order.filter(isReady).slice(0, n);
92
+ const mine = top.filter((t) => t.src === 'pmos'), jira = top.filter((t) => t.src === 'jira');
93
+ if (!mine.length) return null;
94
+ const name = next.label || next.name, when = `${dayText(next.start)} to ${dayText(next.end)}`;
95
+ const names = (L) => (L.length <= 3 ? L.map((t) => t.title).join(', ').replace(/, ([^,]*)$/, ' and $1') : L.length + ' tasks');
96
+ const s = {
97
+ title: `Pull the ${top.length === 1 ? 'top ready item' : top.length + ' top ready items'} into ${name}`,
98
+ why: `${name} starts ${dayText(next.start)}. ${top.length === 1 ? 'This item is' : 'These are'} ranked highest of the ready work: in an initiative, with an owner, not started.`,
99
+ will: [`Give ${names(mine)} the dates of ${name} (${when})`].concat(jira.length ? [`List ${jira.map((t) => t.key).join(', ')} for you to add to ${name} in Jira`] : []),
100
+ changes: `${name} holds ${mine.length === 1 ? 'it' : 'them'} when it starts.${jira.length ? ' PMOS does not change Jira.' : ''} Nothing is sent to anyone.`,
101
+ basis: `The rank in this backlog, ${name}'s dates in Jira`,
102
+ };
103
+ return { s, ids: mine.map((t) => t.id), keys: jira.map((t) => t.key) };
104
+ }
105
+
106
+ /** The Where it stands block. → '' when there is nothing to say. */
107
+ export function standsHtml(B, o = {}) {
108
+ const S = standsOf(B, o);
109
+ const p = o.pull ? sugHtml(o.pull.s, `data-ids="${esc(o.pull.ids.join(' '))}"`, 'data-bksug') : '';
110
+ if (!S.length && !p) return '';
111
+ return `<section class="pm-block wk-stands" aria-label="Where it stands"><h2 class="pm-h-sm pm-row">${SV(I.star).replace('pm-ic', 'pm-ic pm-star')}Where it stands</h2>`
112
+ + (S.length ? `<p class="wk-say">${esc(S.join(' '))}</p>` : '') + p + '</section>';
113
+ }
114
+
115
+ /** The capture: which initiative a line names. The words "in <x>" or "for <x>" first, then the initiative sharing most words with the line.
116
+ * → { title, ini } | { title, ini: null } when nothing fits (the page asks). */
117
+ const WORDS = (s) => String(s || '').toLowerCase().match(/[a-z0-9]{3,}/g) || [];
118
+ const SMALL = new Set(['the', 'and', 'for', 'with', 'into', 'from', 'this', 'that', 'add']);
119
+ export function captureOf(line, inis) {
120
+ const text = String(line || '').trim();
121
+ if (!text) return null;
122
+ const L = inis || [];
123
+ const m = /^(.*?)\s+(?:in|for|under|to)\s+(.+?)\s*$/i.exec(text);
124
+ if (m) {
125
+ const want = m[2].toLowerCase();
126
+ const hit = L.find((x) => x.title.toLowerCase() === want) || L.find((x) => x.title.toLowerCase().startsWith(want)) || L.find((x) => x.title.toLowerCase().includes(want));
127
+ if (hit) return { title: m[1].trim(), ini: hit.id };
128
+ }
129
+ const w = new Set(WORDS(text).filter((x) => !SMALL.has(x)));
130
+ const best = L.map((x) => ({ x, n: WORDS(x.title).filter((y) => w.has(y)).length })).filter((s) => s.n > 0).sort((a, b) => b.n - a.n);
131
+ if (best.length && (best.length === 1 || best[0].n > best[1].n)) return { title: text, ini: best[0].x.id, guessed: true };
132
+ return { title: text, ini: null };
133
+ }
134
+
135
+ /** The Backlog block. o: { tab, group, menu, today, rank (number by id), sel: Set of uids, picking, act(t) → the row's action html,
136
+ * stateOf(t) → { text, tone } for PMOS's own states, groupsPmos(rows) → [{ k, n, rows, yes }], mode (the kind-of-work line's html) } */
137
+ export function tableHtml(order, o = {}) {
138
+ const c = countsOf(order, o.today), tab = o.tab || 'all', group = o.group || 'ini';
139
+ const tabs = `<div class="pm-tabs" role="tablist" aria-label="Show">${TABS.filter(([k]) => k === 'all' || c[k] || k === tab).map(([k, n]) => `<button type="button" class="pm-tab" role="tab" aria-selected="${k === tab}" data-bktab="${k}">${n} <span class="pm-meta">${c[k]}</span></button>`).join('')}</div>`;
140
+ const gname = (GROUPS.find(([k]) => k === group) || GROUPS[0])[1];
141
+ const menu = `<span class="wk-mw"><button type="button" class="pm-tab wk-gb" data-bkgroup aria-haspopup="menu" aria-expanded="${!!o.menu}">Group: ${gname}${SV(I.down, 14)}</button>`
142
+ + (o.menu ? `<div class="pm-menu wk-gm" role="menu" aria-label="Group">${GROUPS.map(([k, n]) => `<button type="button" role="menuitemradio" aria-checked="${k === group}" data-bkgrp="${k}">${n}</button>`).join('')}</div>` : '') + '</span>';
143
+ const tune = `<button type="button" class="pm-btn" data-bktune aria-label="Filter" title="Filter">${SV('M4 7h9M17 7h3M4 17h3M11 17h9M15 5v4M9 15v4')}</button>`;
144
+ const cap = '<input class="pm-input wk-cap" type="text" data-bkcap placeholder="Add to the backlog; say the initiative, or PMOS picks one" aria-label="Add to the backlog">';
145
+ const R = order.filter((t) => keepsTab(t, tab, o.today));
146
+ let G;
147
+ if (group === 'pmos' && o.groupsPmos) G = o.groupsPmos(R);
148
+ else if (group === 'none') G = [{ k: '', n: '', rows: R }];
149
+ else {
150
+ const m = new Map();
151
+ for (const t of R) { const k = t.ini || NOINI; if (!m.has(k)) m.set(k, { k, n: t.ini ? t.iniTitle || t.ini : 'No initiative yet', rows: [] }); m.get(k).rows.push(t); }
152
+ G = [...m.values()];
153
+ const whole = new Map(); for (const t of order) { const k = t.ini || NOINI; const e = whole.get(k) || { n: 0, r: 0 }; e.n++; if (isReady(t)) e.r++; whole.set(k, e); }
154
+ for (const g of G) { const e = whole.get(g.k); g.sub = `${plural(e.n, 'item', 'items')} · ${e.r} ready`; }
155
+ }
156
+ const drag = group !== 'pmos';
157
+ const body = G.map((g) => (g.n ? `<tr class="wk-g"><td colspan="7"><div class="pm-group"><b>${esc(g.n)}</b>${g.sub ? ` <span class="pm-meta">${esc(g.sub)}</span>` : ''}${g.yes || ''}</div></td></tr>` : '')
158
+ + g.rows.map((t) => rowHtml(t, o, drag)).join('')).join('');
159
+ const table = R.length ? `<table class="pm-table wk-bkt${o.picking ? ' picking' : ''}"><thead><tr><th class="wk-rk">Rank</th><th>Item</th><th>Who</th><th>State</th><th>Source</th><th>Last change</th><th class="wk-ac" aria-label="Actions"></th></tr></thead><tbody>${body}</tbody></table>`
160
+ : `<p class="pm-meta">${order.length ? 'Nothing here.' : 'Nothing waits outside the sprint.'}</p>`;
161
+ const foot = R.length && drag ? '<p class="pm-meta">Drag a row to change its rank. The rank is one list across initiatives; groups only show where each item belongs.</p>' : '';
162
+ return `<section class="pm-block wk-blk wk-bk" aria-label="Backlog"><div class="head"><h2 class="pm-h">Backlog</h2><span class="sp"></span>${tabs}${menu}${tune}</div>${cap}${o.said || ''}${table}${foot}${o.mode || ''}</section>`;
163
+ }
164
+ function rowHtml(t, o, drag) {
165
+ const u = t.ws + '|' + t.board + '|' + t.id, ck = o.sel && o.sel.has(u);
166
+ const ready = isReady(t), idle = idleOf(t, o.today);
167
+ const who = pmosHas(t) ? '<span class="pm-star">✦</span> PMOS' : t.who ? esc(t.who) : '<span class="pm-meta">no one</span>';
168
+ const ps = o.stateOf ? o.stateOf(t) : null;
169
+ const state = ps ? `<span class="pm-badge${ps.tone === 'late' ? ' alert' : ' blue'}" title="${esc(ps.title || ps.text)}">${esc(ps.text)}</span>` : `<span class="pm-badge${ready ? ' blue' : ''}">${ready ? 'Ready' : 'Needs detail'}</span>`;
170
+ const src = t.key ? `<span class="pm-meta code">${esc(t.key)}</span>` : '<span class="pm-chip">Not in Jira</span>';
171
+ const n = o.rank ? o.rank.get(t.id) : null;
172
+ return `<tr class="wk-br${ck ? ' sel' : ''}" data-bk="${esc(u)}" data-bkid="${esc(t.id)}"${drag ? ' draggable="true"' : ''}>`
173
+ + `<td class="wk-rk"><span class="pm-row">${drag ? `<span class="wk-grip" aria-hidden="true">${SV(I.grip, 14)}</span>` : ''}<input type="checkbox" class="wk-ck" data-bkck="${esc(u)}" aria-label="Tick ${esc(t.title)}"${ck ? ' checked' : ''}><span class="pm-meta">${n != null ? n + 1 : ''}</span></span></td>`
174
+ + `<td><button type="button" class="wk-tt" data-bkopen="${esc(u)}" title="${esc(t.title)}">${esc(t.title)}</button>${idle != null && idle >= SAY_FROM ? ` <span class="pm-badge">${idle} days untouched</span>` : ''}${t.late ? ` <span class="pm-badge alert">${plural(t.late, 'day late', 'days late')}</span>` : ''}</td>`
175
+ + `<td>${who}</td><td>${state}</td><td>${src}</td><td><span class="pm-meta code">${t.touched ? dayText(t.touched) : ''}</span></td><td class="wk-ac">${o.act ? o.act(t) : ''}</td></tr>`;
176
+ }