create-pmos 0.648.0 → 0.650.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.648.0",
3
+ "version": "0.650.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.650.0",
38
+ "at": "2026-11-20T06:52:20.858Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1432,
43
+ "t": "The initiative popup is built from design system blocks",
44
+ "s": "The initiative popup is built from design system blocks",
45
+ "k": "new"
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "v": "0.649.0",
51
+ "at": "2026-11-20T06:16:36.793Z",
52
+ "f": 4,
53
+ "prs": [
54
+ {
55
+ "n": 1431,
56
+ "t": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
57
+ "s": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
58
+ "k": "new"
59
+ }
60
+ ]
61
+ },
36
62
  {
37
63
  "v": "0.648.0",
38
64
  "at": "2026-11-20T05:58:53.312Z",
@@ -290,32 +316,6 @@
290
316
  "k": "new"
291
317
  }
292
318
  ]
293
- },
294
- {
295
- "v": "0.623.0",
296
- "at": "2026-11-19T05:21:06.341Z",
297
- "f": 4,
298
- "prs": [
299
- {
300
- "n": 1405,
301
- "t": "Work's bars stop at the timeline's edge at every span",
302
- "s": "Work's bars stop at the timeline's edge at every span",
303
- "k": "fix"
304
- }
305
- ]
306
- },
307
- {
308
- "v": "0.622.0",
309
- "at": "2026-11-19T05:05:08.698Z",
310
- "f": 4,
311
- "prs": [
312
- {
313
- "n": 1403,
314
- "t": "Work breakdown back to stages with their tasks; no-stage tasks in the Backlog",
315
- "s": "Work breakdown back to stages with their tasks; no-stage tasks in the Backlog",
316
- "k": "fix"
317
- }
318
- ]
319
319
  }
320
320
  ]
321
321
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@9750136d
1
+ kernel-source: pmos@efc39439
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:58:50Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-20T06:52:18Z"}
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:58:50Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-20T06:52:18Z"}
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:58:50Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-20T06:52:18Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,30 @@
1
1
  [
2
+ {
3
+ "v": "0.650.0",
4
+ "at": "2026-11-20T06:52:20.858Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1432,
9
+ "t": "The initiative popup is built from design system blocks",
10
+ "s": "The initiative popup is built from design system blocks",
11
+ "k": "new"
12
+ }
13
+ ]
14
+ },
15
+ {
16
+ "v": "0.649.0",
17
+ "at": "2026-11-20T06:16:36.793Z",
18
+ "f": 4,
19
+ "prs": [
20
+ {
21
+ "n": 1431,
22
+ "t": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
23
+ "s": "Work's Backlog tab ranks the work outside the sprint and is built from design system blocks",
24
+ "k": "new"
25
+ }
26
+ ]
27
+ },
2
28
  {
3
29
  "v": "0.648.0",
4
30
  "at": "2026-11-20T05:58:53.312Z",
@@ -94,6 +94,12 @@ 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
+
97
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.
98
104
 
99
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.
@@ -129,7 +135,20 @@ A phone keeps its own layout. A shared read-only Board has no popup.
129
135
 
130
136
  ### What the popup shows for an initiative
131
137
 
132
- The work side has three parts, top to bottom. They use the full width of the popup: in a wide popup the timeline gets the extra width. A done task shows in grey text, never struck through.
138
+ On a computer the popup is built from the parts of the PMOS design system. The top line shows **Work ›**, the initiative's name, the **Initiative** chip and one line under it: the stage, the goal it is anchored to, when it opened and its owner. Press **Work** or ← to go back to the page.
139
+
140
+ The left column has three blocks:
141
+
142
+ - **Where it stands.** What is happening, in a few sentences. Then **Next**: the next three dates, a milestone as a diamond and the outcome check as a circle; press a milestone to open it. Then one suggestion from PMOS with **Why**, **PMOS will** and **Based on**. The pencil opens it so you can change it first, ✓ does it and ✕ drops it. Other suggestions are one link under it.
143
+ - **Stages.** Each stage of the workflow, with its dates under its name or "no dates yet", on a month scale with a red line for today. A stage has a bar only when it has real dates. A milestone is a diamond on its stage's row.
144
+ - **Work breakdown.** **List** or **Gantt**; PMOS keeps your choice on this computer. **List** has one box on top: type a task and press Enter. Say its stage ("… in Plan"), or it goes to the stage in progress; start with ◇ to add a milestone. Each stage with tasks is one group that says how much is done, for example "1 of 3 done". A done task stays in its stage, in grey with a check. Stages with no tasks fold into one line at the end. Press the box before a task to change its status, its name to rename it, and the rest of the row to open it; ↗ and ⋯ show when you point at the row. **Gantt** is the table described below, with its bars.
145
+
146
+ The right column has two blocks:
147
+
148
+ - **The case.** **Problem**, **Goal** and **Done when** from the initiative's records, then its facts (status, dates, the next milestone, goal, product, program, workflow and what is open). Press a line to change it. A line not written offers a PMOS draft (✦) or ✕. When no line is written yet, one suggestion offers to draft them all from what is linked: ✓ sends the request to the chat, ✕ says not this, and the pencil lets you write it yourself.
149
+ - **Artefacts.** The brief, the prototype and the documents, each with its kind and date. A document the gate needs that nobody wrote is grey and says which gate. + adds a file, a link or a new document.
150
+
151
+ On a phone, in a shared read-only copy and in a breakdown given the whole popup, the work side keeps the three parts below. They use the full width of the popup: in a wide popup the timeline gets the extra width. A done task shows in grey text, never struck through.
133
152
 
134
153
  - **Overview.** Three short lines from the initiative's own records: **Problem**, **Goal** (with the goal it serves, by name) and **Done when**. A line with no record says **Not written yet.** and offers a draft with ✓ and ✕. Press a line to change it; it saves when you leave the field, with **Undo**. Then one line on where it stands, **PMOS suggests** (at most three, each with ✓ and ✕), and **Details ›** for the facts: Stage, Status, Start, Target end, Next milestone, Goal, Product, Program, Workflow and Open. A fact with no value is not shown. Goal, Product, Program and Next milestone are in the link colour and open their thing; the others are plain text. An initiative that is closed or done but has open tasks shows one suggestion: **Close them** or **Reopen**.
135
154
  - **Work breakdown.** Each stage is a row that folds and says how much is done, for example "3 of 9 done". Only the stage in progress opens by itself. In a long stage you see the late tasks, the tasks in progress and the next five, then **N more tasks**. Done tasks fold to one line, and the stages after the next one fold to one row. A task in no stage is not in the breakdown: it is in Work › Backlog, and one quiet line under the breakdown says how many, for example **2 tasks with no stage are in the Backlog ›**. A task with no date shows no date and is never late. The timeline is on the right, with **Today** on it. Drag the grip between the columns and the timeline to make the timeline wider or narrower; a double press puts it back. Choose its span (Quarter to Full) beside the tune icon, which shows or hides columns. The four-corners icon gives the breakdown the whole popup. Type in the last row of a stage to add a task; the **Task** choice beside it makes the next one a milestone.
@@ -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. */
@@ -19,6 +19,9 @@
19
19
  * lib/sprint-history.js detailOf. GET /api/backlog also carries sprintList (the picker, SpH1) and
20
20
  * sprintTrend (the carried-over line and bars), and sprintNow (This sprint: every task in the
21
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).
22
25
  * POST /api/backlog/place { ws, board, key, to } a No home Jira ticket into an initiative (a ticket-move line on the board
23
26
  * ledger, as a split or merge writes it; Jira is not written to, D88). to '' takes it back out.
24
27
  *
@@ -98,6 +101,17 @@ function readingsOf(w, jiraStatus) {
98
101
  }
99
102
 
100
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
+
101
115
  function listOf(ctx, wsId, boardId, now) {
102
116
  const RB = require('./routes-boards.js');
103
117
  const jiraStatus = require('./jira-status.js');
@@ -133,7 +147,13 @@ function listOf(ctx, wsId, boardId, now) {
133
147
  try { sprintList = SH.listOf(sin); sprintTrend = SH.trendOf(sprintList); } catch { sprintList = []; sprintTrend = null; }
134
148
  // This sprint (WorkSprintDS): all work in the sprint's dates, Jira and not, done work too
135
149
  let sprintNow = []; try { sprintNow = SN.sprintsNowOf({ R, tasks, items, inis, projects: sin.projects, today, me: actorLib.PM_SLUG, pmName: pmNameOf() }); } catch { sprintNow = []; }
136
- return { ok: true, ws: w.id, board: board.id, product, mode, sprintNotes, sprintList, sprintTrend, sprintNow, _sin: sin, modeLabel: BL.MODE_LABEL[mode], kinds: BL.countKinds(inis.map((x) => x.kind)), factory, readAt, today,
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,
137
157
  tasks, inis: inis.map((x) => ({ id: x.id, title: x.title, kind: x.kind })), _w: w, _RB: RB, _runTasks: runTasks };
138
158
  }
139
159
 
@@ -202,7 +222,7 @@ async function handle(req, res, url, ctx) {
202
222
  if (!d) return send(bad(404, 'PMOS knows no sprint of that name on this board'));
203
223
  return send({ status: 200, body: { ok: true, ws: L.ws, board: L.board, sprint: d } });
204
224
  }
205
- 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'));
206
226
  if (req.method !== 'POST') return send(bad(405, 'POST only'));
207
227
  const read = await ctx.readJson(req);
208
228
  if (!read.ok || !read.body || typeof read.body !== 'object') return send(bad(400, 'the body must be a JSON object'));
@@ -251,6 +271,16 @@ async function handle(req, res, url, ctx) {
251
271
  return send({ status: 200, body: { ok: true, key, to, from: was } });
252
272
  }
253
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
+
254
284
  if (sub === 'give') {
255
285
  const ids = Array.isArray(body.tasks) ? body.tasks.map(text).filter(Boolean).slice(0, 50) : [text(body.task)].filter(Boolean);
256
286
  if (!ids.length) return send(bad(400, 'tasks is a list of task ids'));
@@ -11,6 +11,7 @@
11
11
  * title }], projects: [Jira project key] (empty = every project), today: 'YYYY-MM-DD', me, pmName }
12
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
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)
14
15
  */
15
16
  const BL = require('./backlog.js');
16
17
 
@@ -76,4 +77,20 @@ function sprintsNowOf(I) {
76
77
  }).sort((a, b) => b.total - a.total || a.name.localeCompare(b.name));
77
78
  }
78
79
 
79
- module.exports = { sprintsNowOf, labelOf };
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.648.0",
3
+ "version": "0.650.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.648.0",
9
+ "version": "0.650.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.648.0",
3
+ "version": "0.650.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
+ }
@@ -15,14 +15,15 @@
15
15
  * with Undo where the route has one. The words say PMOS, never the model's name. pm/premium-board.js calls sync() after each read of the board. */
16
16
  import * as BM from './bk-model.js';
17
17
  import { productName } from './scope-chip.js'; // the product's display name ("IDPF"), never its folder id
18
- import * as SP from './bd-sprint.js'; // the sprint overview while "This sprint" is on (initiative sprint-overview)
18
+ import * as SP from './bd-sprint.js';
19
+ import * as BD from './bd-backlog-ds.js'; // the Backlog from the system's parts (WorkBacklogDS) // the sprint overview while "This sprint" is on (initiative sprint-overview)
19
20
 
20
21
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
21
22
  const SV = (d, n) => `<svg viewBox="0 0 24 24"${n ? ` width="${n}" height="${n}"` : ''} aria-hidden="true"><path d="${d}"/></svg>`;
22
23
  const I = {
23
24
  chev: 'M9 6l6 6-6 6', down: 'M7 10l5 5 5-5', ok: 'M5 12.5l4.5 4.5L19 7', x: 'M6 6l12 12M18 6L6 18', more: 'M5 12h.01M12 12h.01M19 12h.01',
24
25
  undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', jira: 'M12 3l9 9-9 9-9-9z', task: 'M6 6h12v12H6z', ms: 'M12 4l8 8-8 8-8-8z', back: 'M15 6l-6 6 6 6',
25
- ext: 'M14 4h6v6M20 4l-9 9M10 6H5v13h13v-5', ret: 'M20 5v7a4 4 0 0 1-4 4H5M9 12l-4 4 4 4',
26
+ ext: 'M14 4h6v6M20 4l-9 9M10 6H5v13h13v-5', eye: 'M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12zM12 9a3 3 0 1 0 0 6 3 3 0 0 0 0-6z', ret: 'M20 5v7a4 4 0 0 1-4 4H5M9 12l-4 4 4 4',
26
27
  };
27
28
  const SPARK = '✦';
28
29
  const KEY = 'pmos.backlog.view';
@@ -41,10 +42,14 @@ let SEL = new Set(); // ticked rows: ws|board|id
41
42
  let host = null, sw = null;
42
43
  let iniApplied = false; // ?ini= is read once
43
44
  let SAID = null; // the one line after a Yes: { text, undo }
45
+ // the Backlog tab (WorkBacklogDS): its tab, its group, the Group menu, the pulls the PM said no to (kept in this browser)
46
+ let BMENU = false;
47
+ const PULLNO = 'pmos.backlog.pullno';
44
48
 
45
49
  const box = () => { try { return typeof localStorage !== 'undefined' ? localStorage : null; } catch { return null; } };
46
50
  const get = (k, d) => { try { const s = box(); const v = s ? JSON.parse(s.getItem(k) || 'null') : null; return v == null ? d : v; } catch { return d; } };
47
51
  const put = (k, v) => { try { const s = box(); if (s) s.setItem(k, JSON.stringify(v)); } catch { /* a private window keeps it for this page */ } };
52
+ const BV = (() => { const v = get('pmos.work.backlog', {}) || {}; return { tab: BD.TABS.some(([k]) => k === v.tab) ? v.tab : 'all', group: BD.GROUPS.some(([k]) => k === v.group) ? v.group : 'ini' }; })();
48
53
  const scopeKey = () => (A ? A.scope().map((s) => s.ws + '|' + (s.board || '')).sort().join(',') : '');
49
54
  const uidOf = (t) => t.ws + '|' + t.board + '|' + t.id;
50
55
 
@@ -87,6 +92,7 @@ export async function load() {
87
92
  // the oldest Jira read of the pick (the sprint band says when Jira was last read) and the PM's edits of each sprint's overview
88
93
  const reads = ok.map((r) => r.readAt).filter(Boolean).sort();
89
94
  DATA = { readAt: reads[0] || null, hist: ok.map((r) => ({ ws: r.ws, board: r.board, list: r.sprintList || [], trend: r.sprintTrend || null })),
95
+ rank: ok.flatMap((r) => r.backlogRank || []), next: (ok.find((r) => r.sprintNext) || {}).sprintNext || null, today: (ok[0] || {}).today || '',
90
96
  now: ok.flatMap((r) => (r.sprintNow || []).map((n) => ({ ...n, ws: r.ws, board: r.board, rows: (n.rows || []).map((x) => ({ ...x, ws: r.ws, board: r.board })) }))), notes: Object.fromEntries(ok.map((r) => [r.ws + '|' + r.board, r.sprintNotes || {}])), tasks: ok.flatMap((r) => r.tasks || []), modes: ok.map((r) => ({ product: productName(r.ws, r.product), mode: r.mode, label: r.modeLabel, kinds: r.kinds || null })), inis: ok.flatMap((r) => (r.inis || []).map((x) => ({ ...x, ws: r.ws, board: r.board, product: productName(r.ws, r.product) }))),
91
97
  err: ok.length ? (ok.length < S.length ? 'One product could not be read; its tasks are not here.' : '') : 'The tasks could not be read. Try again in a moment.', many: S.length > 1 };
92
98
  // ?ini=<initiative id> (the initiative popup's "Open in Backlog"): the Initiative facet starts on that initiative, once
@@ -133,6 +139,7 @@ function draw() {
133
139
  const said = SAID ? `<p class="bk-said" role="status">${esc(SAID.text)}${SAID.undo ? ' <button type="button" class="bk-lnk" data-bksaid>Undo</button>' : ''}</p>` : '';
134
140
  const sh = BM.showingLine(T, { chips: CHIPS, pick: PICK, partB: partB() });
135
141
  const showing = sh ? `<p class="bk-show">${esc(sh.text)}${sh.hidden ? ` · ${sh.hidden} hidden` : ''} · <button type="button" class="bk-lnk" data-bkall>Show all</button></p>` : '';
142
+ if (tabOf() === 'bk') { drawBk(); return; }
136
143
  // This sprint (WorkSprintDS): the Summary card and the Tasks Table, both pm/bd-sprint.js; a past sprint keeps its frozen view and list
137
144
  if (tabOf() === 'sp') {
138
145
  const card = SP.bandHtml({ tasks: T.filter(BM.isOpen), all: T, inis: DATA.inis, readAt: DATA.readAt, notes: DATA.notes, hist: DATA.hist, now: DATA.now }, spDeps());
@@ -157,6 +164,98 @@ function draw() {
157
164
  + (past != null ? past : `<div class="bk" role="table" aria-label="Backlog" style="--bk-cols: ${colsCss(cols)}">${head}${body}</div>`);
158
165
  drawBar();
159
166
  }
167
+ /* ── the Backlog tab (WorkBacklogDS): Where it stands with one Suggestion, then the Backlog block ───────────────────────── */
168
+ let ORDER = []; // the backlog in rank order, as drawn last
169
+ const backlogOf = () => DATA.tasks.filter(BD.inBacklog).filter((t) => BM.keeps(t, new Set(), PICK, partB()));
170
+ function pullFor(order) {
171
+ const p = BD.pullOf(order, DATA.next);
172
+ if (!p) return null;
173
+ const no = get(PULLNO, []) || [];
174
+ return no.includes(pullSig(p)) ? null : p;
175
+ }
176
+ const pullSig = (p) => (DATA.next ? DATA.next.name : '') + ':' + p.ids.concat(p.keys).join(',');
177
+ function drawBk() {
178
+ const B = backlogOf(), order = BD.ranked(B, DATA.rank, DATA.inis);
179
+ ORDER = order;
180
+ const rank = new Map(order.map((t, i) => [t.id, i]));
181
+ const sh = BM.showingLine(DATA.tasks, { chips: new Set(), pick: PICK, partB: partB() });
182
+ const showing = sh ? `<p class="pm-meta">${esc(sh.text)}${sh.hidden ? ` · ${sh.hidden} hidden` : ''} · <button type="button" class="wk-sa" data-bkall>Show all</button></p>` : '';
183
+ const said = SAID ? `<p class="pm-meta" role="status">${esc(SAID.text)}${SAID.undo ? ' <button type="button" class="wk-sa" data-bksaid>Undo</button>' : ''}</p>` : '';
184
+ const ml = BM.modeLine(DATA.modes);
185
+ const mode = ml ? `<p class="pm-meta">${esc(ml.lead)}<b>${esc(ml.label)}</b>${esc(ml.tail)}: ${esc(ml.what)} <button type="button" class="wk-sa" data-bkmode aria-haspopup="dialog">Change</button></p>` : '';
186
+ const pmosGroups = (R) => BM.groupsOf(R, { partB: partB(), sort: SORT }).map((g) => {
187
+ const can = yesRows(g, g.rows);
188
+ return { k: g.k, n: g.n, sub: g.sub, rows: g.rows, yes: can.length ? ` <button type="button" class="pm-btn" data-bkyes="${g.k}" aria-label="${esc(g.k === 'take' ? 'Give all ' + can.length + ' to PMOS' : 'Place all ' + can.length)}" title="${esc(g.k === 'take' ? 'Give all ' + can.length + ' to PMOS' : 'Place all ' + can.length)}">${SV(I.ok, 16)}</button>` : '' };
189
+ });
190
+ host.innerHTML = (DATA.err ? `<p class="bk-err">${esc(DATA.err)}</p>` : '')
191
+ + BD.standsHtml(B, { today: DATA.today, next: DATA.next, pull: pullFor(order) })
192
+ + BD.tableHtml(order, { tab: BV.tab, group: BV.group, menu: BMENU, today: DATA.today, rank, sel: SEL, picking: host.classList.contains('picking'),
193
+ act: (t) => actHtml(t, BM.groupOf(t, partB())), stateOf: (t) => { if (!t.agent) return null; const x = BM.stateOf(t); return { text: x.text, tone: x.tone, title: x.text + (x.note ? ' · ' + x.note : '') }; },
194
+ groupsPmos: pmosGroups, said: showing + said, mode });
195
+ drawBar();
196
+ }
197
+ const saveBv = () => put('pmos.work.backlog', BV);
198
+ /** A press only the Backlog tab has. → true when it was one. */
199
+ async function bkPress(e) {
200
+ const t0 = e.target, hit = (a) => t0.closest('[' + a + ']');
201
+ let b;
202
+ if ((b = hit('data-bktab'))) { BV.tab = b.dataset.bktab; saveBv(); draw(); const n = host.querySelector(`[data-bktab="${BV.tab}"]`); if (n) n.focus(); return true; }
203
+ if (hit('data-bkgroup')) { BMENU = !BMENU; draw(); const n = host.querySelector('[data-bkgrp][aria-checked="true"]'); if (BMENU && n) n.focus(); return true; }
204
+ if ((b = hit('data-bkgrp'))) { BV.group = b.dataset.bkgrp; BMENU = false; saveBv(); draw(); const n = host.querySelector('[data-bkgroup]'); if (n) n.focus(); return true; }
205
+ if (BMENU) { BMENU = false; draw(); }
206
+ if ((b = hit('data-bktune'))) { if (pop && pop.classList.contains('bk-tune')) closePop(); else tune(b); return true; }
207
+ if ((b = hit('data-bksug'))) {
208
+ const p = pullFor(ORDER); if (!p) return true;
209
+ const k = b.dataset.bksug, T = p.ids.map((id) => DATA.tasks.find((t) => t.id === id)).filter(Boolean);
210
+ if (k === 'no') { const no = get(PULLNO, []) || []; no.push(pullSig(p)); put(PULLNO, no.slice(-50)); AP().say('PMOS will not suggest this again.', () => { put(PULLNO, (get(PULLNO, []) || []).filter((x) => x !== pullSig(p))); draw(); }); draw(); return true; }
211
+ if (k === 'edit') { BV.tab = 'ready'; saveBv(); for (const t of T) SEL.add(uidOf(t)); draw(); AP().say(`Ticked ${T.length === 1 ? 'the item' : 'the ' + T.length + ' items'}. Change the ticks, then Set date.`); return true; }
212
+ await editMany(T, { start: DATA.next.start, due: DATA.next.end }, 'Into ' + (DATA.next.label || DATA.next.name) + (p.keys.length ? '. Add ' + p.keys.join(', ') + ' in Jira' : ''));
213
+ return true;
214
+ }
215
+ return false;
216
+ }
217
+ /** The capture: one line into the backlog, in the initiative it names, else the closest by its words, else PMOS asks. */
218
+ async function capture(inp) {
219
+ const line = inp.value.trim(); if (!line) return;
220
+ const L = DATA.inis || [], c = BD.captureOf(line, L);
221
+ const add = async (ini) => {
222
+ const x = L.find((y) => y.id === ini); if (!x) return;
223
+ const r = await post('/api/boards/tasks/add', { ws: x.ws, board: x.board, title: c.title.slice(0, 200), initiative: ini });
224
+ if (!r || r.ok === false || !r.item) { AP().say((r && r.error) || 'The task was not added.'); return; }
225
+ inp.value = '';
226
+ AP().say(`Added to ${x.title}: ${c.title}.`, async () => { await post('/api/boards/tasks/delete', { ws: x.ws, board: x.board, task: r.item.uid }); AP().say('Taken out.'); load(); AP().reload(); });
227
+ load(); AP().reload();
228
+ };
229
+ if (c.ini) { await add(c.ini); return; }
230
+ pickPop(inp, 'Which initiative?', L.map((x) => [x.id, x.title]), add);
231
+ }
232
+ /** A drag in the Backlog block: the row moves before the row it is dropped on, in the one rank; the board's order is written with Undo. */
233
+ let DRAG = '';
234
+ function dragWire() {
235
+ host.addEventListener('dragstart', (e) => { const r = e.target.closest && e.target.closest('tr.wk-br[draggable]'); if (!r) return; DRAG = r.dataset.bkid; r.classList.add('drag'); try { e.dataTransfer.effectAllowed = 'move'; e.dataTransfer.setData('text/plain', DRAG); } catch { /* old browser */ } });
236
+ host.addEventListener('dragend', () => { DRAG = ''; for (const n of host.querySelectorAll('.drag, .drop')) n.classList.remove('drag', 'drop'); });
237
+ host.addEventListener('dragover', (e) => { if (!DRAG) return; const r = e.target.closest('tr.wk-br'); if (!r) return; e.preventDefault(); for (const n of host.querySelectorAll('.drop')) if (n !== r) n.classList.remove('drop'); r.classList.add('drop'); });
238
+ host.addEventListener('drop', async (e) => {
239
+ const r = e.target.closest('tr.wk-br'); if (!DRAG || !r) return;
240
+ e.preventDefault();
241
+ const id = DRAG, before = r.dataset.bkid; DRAG = '';
242
+ if (id === before) { draw(); return; }
243
+ await rerank(BD.moved(ORDER.map((t) => t.id), id, before), ORDER.find((t) => t.id === id));
244
+ });
245
+ }
246
+ async function rerank(ids, t) {
247
+ if (!t) return;
248
+ const by = byBoard(ORDER), back = [];
249
+ for (const [, ts] of by) {
250
+ const mine = new Set(ts.map((x) => x.id));
251
+ const r = await post('/api/backlog/rank', { ws: ts[0].ws, board: ts[0].board, order: ids.filter((x) => mine.has(x)) });
252
+ if (!r || r.ok === false) { AP().say((r && r.error) || 'The rank was not changed.'); break; }
253
+ back.push({ ws: ts[0].ws, board: ts[0].board, from: r.from || [] });
254
+ }
255
+ if (back.length) AP().say('Reranked: ' + t.title + '.', async () => { for (const x of back) await post('/api/backlog/rank', { ws: x.ws, board: x.board, order: x.from }); AP().say('Put back.'); load(); });
256
+ DATA.rank = ids; draw(); load();
257
+ }
258
+
160
259
  /* ── the columns: Task first and the actions last, always; the ones between are a list, so the initiative popup can leave Initiative out ── */
161
260
  export const COLS = ['jira', 'epic', 'ini', 'who', 'state'];
162
261
  const COL = { jira: ['Jira ticket', '104px'], epic: ['Epic', 'minmax(80px, 130px)'], ini: ['Initiative', 'minmax(110px, 160px)'], who: ['Who', '76px'], due: ['Due', 'minmax(80px, 150px)'], state: ['State', 'minmax(200px, 290px)'] };
@@ -192,6 +291,16 @@ function whoHtml(t) {
192
291
  if (t.agent && t.agent.state !== 'failed') return `<span class="bk-pm">${SPARK} PMOS</span>`;
193
292
  return t.who ? esc(t.who) : '<span class="q">None</span>';
194
293
  }
294
+ /** The row's action, by its group: Review, ⋯ (PMOS is working), ✓ ✕ (PMOS can take it, or PMOS proposes a home), Undo (done today). */
295
+ function actHtml(t, gk) {
296
+ const u = uidOf(t);
297
+ let act = '';
298
+ if (gk === 'review') act = `<button type="button" class="bk-ib" data-bkrev="${esc(u)}" aria-label="Review what PMOS made: ${esc(t.title)}" title="Review">${SV(I.eye)}</button>`;
299
+ else if (gk === 'working') act = `<button type="button" class="bk-ib" data-bkmenu="${esc(u)}" aria-label="More for ${esc(t.title)}" title="More">${SV(I.more)}</button>`;
300
+ else if (gk === 'take' || (gk === 'nohome' && t.propose)) act = `<span class="bk-two"><button type="button" class="bk-ib" data-bkok="${esc(u)}" aria-label="${gk === 'take' ? 'Give to PMOS' : 'Put it in ' + esc(t.propose.title)}" title="${gk === 'take' ? 'Give to PMOS' : 'Put it there'}">${SV(I.ok)}</button><button type="button" class="bk-ib" data-bkno="${esc(u)}" aria-label="${gk === 'take' ? 'Not for PMOS' : 'Not there'}" title="${gk === 'take' ? 'Not for PMOS' : 'Not there'}">${SV(I.x)}</button></span>`;
301
+ else if (gk === 'done') act = `<button type="button" class="bk-ib" data-bkundo="${esc(u)}" aria-label="Undo: open ${esc(t.title)} again" title="Undo">${SV(I.undo)}</button>`;
302
+ return act;
303
+ }
195
304
  function rowHtml(t, gk, cols = COLS) {
196
305
  const u = uidOf(t), ck = SEL.has(u), s = BM.stateOf(t, gk, { noLate: cols.includes('due') });
197
306
  const icon = t.milestone ? `<i class="bk-ic ms" title="Milestone">${SV(I.ms)}</i>` : `<i class="bk-ic" title="Task">${SV(I.task)}</i>`;
@@ -199,11 +308,7 @@ function rowHtml(t, gk, cols = COLS) {
199
308
  const epic = t.src === 'jira' ? (t.epic ? `<span title="${esc(t.epic.name ? t.epic.name + ' (' + t.epic.key + ')' : t.epic.key)}">${esc(t.epic.name || t.epic.key)}</span>` : '<span class="q">No epic</span>') : '';
200
309
  const ini = t.ini ? `<span title="${esc(t.iniTitle)}">${esc(t.iniTitle)}</span>`
201
310
  : t.propose ? `<span class="bk-pm" title="${esc('PMOS proposes it: ' + t.propose.why)}">${SPARK} ${esc(t.propose.title)}</span>` : ''; // No home says it once, in its head
202
- let act = '';
203
- if (gk === 'review') act = `<button type="button" class="bk-rvb" data-bkrev="${esc(u)}">Review</button>`;
204
- else if (gk === 'working') act = `<button type="button" class="bk-ib" data-bkmenu="${esc(u)}" aria-label="More for ${esc(t.title)}" title="More">${SV(I.more)}</button>`;
205
- else if (gk === 'take' || (gk === 'nohome' && t.propose)) act = `<span class="bk-two"><button type="button" class="bk-ib" data-bkok="${esc(u)}" aria-label="${gk === 'take' ? 'Give to PMOS' : 'Put it in ' + esc(t.propose.title)}" title="${gk === 'take' ? 'Give to PMOS' : 'Put it there'}">${SV(I.ok)}</button><button type="button" class="bk-ib" data-bkno="${esc(u)}" aria-label="${gk === 'take' ? 'Not for PMOS' : 'Not there'}" title="${gk === 'take' ? 'Not for PMOS' : 'Not there'}">${SV(I.x)}</button></span>`;
206
- else if (gk === 'done') act = `<button type="button" class="bk-ib" data-bkundo="${esc(u)}" aria-label="Undo: open ${esc(t.title)} again" title="Undo">${SV(I.undo)}</button>`;
311
+ const act = actHtml(t, gk);
207
312
  const cell = {
208
313
  due: `<span class="c-due${t.late ? ' lt' : ''}">${t.due ? esc(dueText(t.due) + (t.late ? ' · ' + t.late + (t.late === 1 ? ' day late' : ' days late') : '')) : '<span class="q">No date</span>'}</span>`,
209
314
  jira: `<span class="c-jira">${jira}</span>`, epic: `<span class="c-epic">${epic}</span>`, ini: `<span class="c-ini">${ini}</span>`, who: `<span class="c-who">${whoHtml(t)}</span>`,
@@ -431,6 +536,7 @@ const taskOf = (u) => (SC ? SC.tasks() : DATA ? DATA.tasks : []).find((t) => uid
431
536
  async function press(e, emb) {
432
537
  const t0 = e.target;
433
538
  if (!emb && t0.closest('.sbo-band, .bk-past, [data-spall], .wk-sp, .wk-spt') && await SP.press(e, spDeps())) return;
539
+ if (!emb && tabOf() === 'bk' && await bkPress(e)) return;
434
540
  const chip = t0.closest('[data-bkchip]');
435
541
  if (chip) { const k = chip.dataset.bkchip; if (k === 'all') CHIPS.clear(); else if (CHIPS.has(k)) CHIPS.delete(k); else CHIPS.add(k); draw(); const n = host.querySelector(`[data-bkchip="${k}"]`); if (n) n.focus(); return; }
436
542
  if (t0.closest('[data-bkall]')) { CHIPS.clear(); PICK = {}; SP.clearTheme(); draw(); return; }
@@ -556,6 +662,8 @@ export function sync(api) {
556
662
  ib.insertAdjacentElement('afterend', host);
557
663
  host.addEventListener('click', (e) => { press(e); });
558
664
  host.addEventListener('change', (e) => { if (e.target.closest('[data-bkck]')) press(e); });
665
+ host.addEventListener('keydown', (e) => { const c = e.target.closest('[data-bkcap]'); if (c && e.key === 'Enter') { e.preventDefault(); capture(c); } });
666
+ dragWire();
559
667
  // a phone shows no tick boxes until a long press on a row (design check 1 h): the press ticks that row and shows the boxes
560
668
  let lp = null;
561
669
  const lpEnd = () => { if (lp) { clearTimeout(lp); lp = null; } };
@@ -320,6 +320,12 @@ export const vidOf = (r) => (r.id ? String(r.id) : 'bd:' + r.key);
320
320
  /** A published copy (pm/readonly.js) opens a row of Work in the one popup, read only (shared-copy brief Part A 4); the four views a phone and
321
321
  * the narrow form keep open their side viewer, as before. */
322
322
  const roPop = () => (window.PMOS_READONLY && document.body.classList.contains('wk-on') ? { ro: true, force: true } : {});
323
+ const MON3 = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
324
+ /** The popup head's meta line (WorkPopupDS): "Triage · anchored to KR 2.3 · opened 11 Oct · owner Dara". A part the record does not hold is left out. */
325
+ export function metaOf(r) {
326
+ const d = /^(\d{4})-(\d{2})-(\d{2})/.exec(String((r && r.start) || ''));
327
+ return [r && r.stage, r && r.kr ? 'anchored to ' + r.kr : '', d ? 'opened ' + +d[3] + ' ' + MON3[+d[2] - 1] : '', r && r.owner ? 'owner ' + r.owner : ''].filter(Boolean).join(' · ');
328
+ }
323
329
  export function openIni(r, from, o = {}) {
324
330
  if (!O || !r || !r.track) return;
325
331
  adding = o.addTo != null ? r.key : null; addTo = o.addTo || ''; addDates = o.addDates || null;
@@ -330,7 +336,7 @@ export function openIni(r, from, o = {}) {
330
336
  // the same tile as Home's initiative page; no "Open in full": the header's expand already opens it wide (batch 14 item 5)
331
337
  // on a desk it opens in the one popup with Ask PMOS about it beside it (slice 2 of the six-place navigation); a phone keeps its sheet
332
338
  const B = (O.M() || {}).board || {};
333
- VW.open({ kind: 'Initiative', title: r.title, icon: 'goal', wrap: true, id: vidOf(r), pop: { id: r.id || '', kind: 'initiative', title: r.title, ws: r.ws || B.ws || undefined, ...roPop() },
339
+ VW.open({ kind: 'Initiative', title: r.title, icon: 'goal', wrap: true, id: vidOf(r), from: 'Work', kindChip: 'Initiative', sub: metaOf(r), pop: { id: r.id || '', kind: 'initiative', title: r.title, ws: r.ws || B.ws || undefined, ...roPop() },
334
340
  discuss: r.id ? true : () => location.assign(O.askHref(r, '')), more: () => { const x = O.rowOf(r.key) || r, b = VW.bodyOf(vidOf(x)); return (PW.on(b) ? PW.moreItems(null, popExtra(x)) : []).concat(iniMore(x)); }, rename: O.rename ? O.rename(r) : null,
335
341
  // the kind of work (batch 29 item 11, KdV1-3): its glyph stands before Discuss; a tap opens the three kinds. A published copy
336
342
  // (pm/readonly.js) cannot change it, so it has no press: the Board's icon still names the kind
@@ -0,0 +1,80 @@
1
+ /* pm/bd-pop-ds.css — the initiative popup on a computer, built from PMOS Komorebi parts (initiative work-ds-popup; Exploring 3 page "work",
2
+ * boards WorkPopupDS, WorkGanttDS, WorkCaseEmptyDS). It only places the parts pm/bd-pop-ds.js draws (pm-block, pm-sug x, pm-tabs, pm-gt,
3
+ * pm-dia, pm-now, pm-group, pm-li, pm-fold, pm-input); the look is the system's. */
4
+
5
+ /* ── two columns: the work on the left, the case and its artefacts on the right ── */
6
+ .pw.pwd { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); gap: var(--space-16); align-items: start; padding-bottom: var(--space-24); }
7
+ .pwd-main, .pwd-side { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; }
8
+ .pwd-blk { gap: var(--space-12); }
9
+ .pwd-bh { justify-content: space-between; gap: var(--space-8); }
10
+ .pwd-bh .pm-h-sm { margin: 0; }
11
+ @container (max-width: 860px) { .pw.pwd { grid-template-columns: minmax(0, 1fr); } }
12
+ @media (max-width: 1100px) { .pw.pwd { grid-template-columns: minmax(0, 1fr); } }
13
+
14
+ /* ── Where it stands ── */
15
+ .pwd-say { margin: 0; font-size: var(--fs-body); line-height: 24px; }
16
+ .pwd-next { flex-wrap: wrap; gap: var(--space-8) var(--space-16); margin: 0; font-size: var(--fs-row); }
17
+ .pwd-nx { display: inline-flex; align-items: center; gap: var(--space-4); border: 0; background: none; padding: 0; font: inherit; color: var(--ink); cursor: pointer; }
18
+ span.pwd-nx { cursor: default; }
19
+ .pwd-nx:focus-visible { outline: none; box-shadow: var(--glow); border-radius: var(--radius-sm); }
20
+ .pwd-mk { display: inline-block; width: 10px; height: 10px; box-sizing: border-box; border: 2px solid var(--ink); flex: none; }
21
+ .pwd-mk.dia { transform: rotate(45deg); border-radius: 2px; }
22
+ .pwd-mk.ring { border-radius: 50%; }
23
+ .pwd-moresug { margin: 0; }
24
+
25
+ /* ── Stages: the name and its dates on the left, the track on the right ── */
26
+ .pwd-st { display: flex; flex-direction: column; }
27
+ .pwd-sr { display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center; min-height: 52px; }
28
+ .pwd-sr.pwd-sh { min-height: 24px; }
29
+ .pwd-sn { display: flex; flex-direction: column; font-size: var(--fs-row); line-height: 20px; }
30
+ .pwd-sn b { font-weight: var(--fw-strong); }
31
+ .pwd-sr.now .pwd-sn b { color: var(--blue); }
32
+ .pwd-tk { position: relative; height: 100%; min-height: 24px; }
33
+ .pwd-sh .pwd-tk { height: 24px; }
34
+ .pwd-mo { position: absolute; top: 2px; transform: translateX(-50%); font-size: var(--fs-meta); color: var(--muted); white-space: nowrap; }
35
+ .pwd-mo.td { color: var(--alert); font-weight: var(--fw-strong); }
36
+ .pwd-sr .pm-gt { height: 52px; }
37
+ .pwd-sr .pm-gt > .b { top: 21px; }
38
+ .pwd-sr .pm-now > span { display: none; }
39
+
40
+ /* ── the Work breakdown: List ── */
41
+ .pwd-cap { width: 100%; box-sizing: border-box; }
42
+ .pwd-list { display: flex; flex-direction: column; margin: 0 calc(-1 * var(--space-16)); }
43
+ .pwd-list .pm-group { margin-top: var(--space-4); }
44
+ .pwd-li { cursor: pointer; }
45
+ .pwd-li .pwd-tt { border: 0; background: none; padding: 0; font: inherit; font-weight: var(--fw-strong); color: inherit; text-align: left; cursor: text; max-width: 100%; }
46
+ .pwd-li .w.late { color: var(--alert); }
47
+ .pwd-li.dn { color: var(--muted); }
48
+ .pwd-li.dn .t { font-weight: var(--fw-regular); }
49
+ .pwd-ck { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; border-radius: var(--radius-sm); background: none; padding: 0; color: var(--muted); }
50
+ button.pwd-ck { cursor: pointer; }
51
+ button.pwd-ck:hover { color: var(--ink); background: var(--well); }
52
+ .pwd-ck.dn { color: var(--leaf); }
53
+ .pwd-fold { cursor: default; }
54
+ .pwd-none { margin: var(--space-8) var(--space-16); }
55
+ .pwd-loose { margin: 0; }
56
+
57
+ /* ── the Work breakdown: Gantt (the breakdown table inside the block) ── */
58
+ .pwd-wbs.pw-sec { margin: 0; }
59
+ .pwd-wbs .pw-sech { margin-bottom: 0; }
60
+ .pwd-wbs .pw-sech .pwd-bh { flex: 1; }
61
+
62
+ /* ── The case ── */
63
+ .pwd-cl { display: flex; flex-direction: column; gap: var(--space-4); }
64
+ .pwd-cl p { margin: 0; font-size: var(--fs-body); line-height: 24px; }
65
+ .pwd-cv { cursor: text; border-radius: var(--radius-sm); }
66
+ .pwd-cv:hover { background: var(--well); }
67
+ .pwd-cv:focus-visible { outline: none; box-shadow: var(--glow); }
68
+ .pwd-cv.grey, .pwd-case .grey { color: var(--muted); }
69
+ .pwd-off { display: inline-flex; gap: var(--space-4); margin-left: var(--space-4); vertical-align: middle; }
70
+ .pwd-facts { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--space-4) var(--space-12); margin: 0; font-size: var(--fs-row); }
71
+ .pwd-facts dt { color: var(--muted); }
72
+ .pwd-facts dd { margin: 0; min-width: 0; }
73
+ .pwd-case .warn { color: var(--alert); }
74
+
75
+ /* ── Artefacts ── */
76
+ .pwd-art { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; margin: 0 calc(-1 * var(--space-8)); width: calc(100% + 2 * var(--space-8)); }
77
+ div.pwd-art { cursor: default; }
78
+ .pwd-art.miss .t { color: var(--muted); }
79
+ .pwd-art .w.warn { color: var(--alert); }
80
+ .pwd-ai { flex: none; color: var(--muted); display: inline-flex; }
@@ -0,0 +1,201 @@
1
+ /* pm/bd-pop-ds.js — the initiative popup on a computer, built from the design system's blocks (initiative work-ds-popup; Exploring 3 page
2
+ * "work", boards WorkPopupDS, WorkGanttDS, WorkCaseEmptyDS; brief /mnt/project-files/design-system/work-rebuild/brief.md). Pure: strings
3
+ * only, no DOM and no reads. pm/cozy-pop-work.js draws it from pm/pop-work-model.js and wires its presses: every press here carries the
4
+ * popup's own data-pw-* attribute, so the handlers stay the ones the popup already has.
5
+ *
6
+ * nextOf(r, W, n) → [{ kind: 'ms' | 'check', date, text, name, uid }] the next n dates: open milestones, then the outcome check
7
+ * standsHtml(W, r, o) → the Where it stands block: the summary, the Next line, one expanded Suggestion. Nothing to say: ''
8
+ * stagesHtml(st, W) → the Stages block: each stage, its dates or "no dates yet", a month scale, the today line; a bar only for real dates
9
+ * listHtml(rows, W, o) → the Work breakdown's List: one capture Input, one group per stage with tasks, empty stages folded into one line
10
+ * wbsHead(view) → the Work breakdown's head: its name and the List / Gantt tabs
11
+ * caseHtml(W, o) → The case: its lines (each editable), the facts; no line written: one Suggestion to draft them all
12
+ * artsHtml(arts) → Artefacts: a List with Add in the head
13
+ * stageKeyOf(text, st) → { key, name, title } the stage a captured line names ("… in Plan"), else the stage in progress
14
+ *
15
+ * The UI says PMOS, never Claude. Buttons are icons with aria-label. */
16
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
17
+ const SV = (d, w = 16) => `<svg class="pm-ic" aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
18
+ export const I = {
19
+ star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', pen: 'M4 20h4L19 9l-4-4L4 16z', ok: 'M5 12.5l4.5 4.5L19 7.5', x: 'M6 6l12 12M18 6L6 18',
20
+ plus: 'M12 5v14M5 12h14', more: 'M5 12h.01M12 12h.01M19 12h.01', open: 'M14 5h5v5M19 5l-8 8M18 14v5H5V6h5', box: 'M6 5h12a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z',
21
+ dia: 'M12 4l8 8-8 8-8-8z', doc: 'M7 3h7l4 4v14H7zM14 3v4h4M9.5 12h6M9.5 16h6', deck: 'M4 5h16v11H4zM12 16v4M8 20h8', link: 'M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1',
22
+ proto: 'M4 5h16v12H4zM9 21h6M12 17v4', right: 'M10 7l5 5-5 5',
23
+ };
24
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
25
+ const DAY = 864e5;
26
+ const day = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
27
+ const plural = (n, a, b) => n + ' ' + (n === 1 ? a : b);
28
+ /** "4 Nov"; a year that is not today's: "13 Jan 2027". */
29
+ export function dayText(v, today) {
30
+ const d = day(v); if (d == null) return '';
31
+ const x = new Date(d), ty = new Date(day(today) || Date.now()).getUTCFullYear();
32
+ return x.getUTCDate() + ' ' + MON[x.getUTCMonth()] + (x.getUTCFullYear() !== ty ? ' ' + x.getUTCFullYear() : '');
33
+ }
34
+ /** A stage's dates: "4 – 25 Nov", "4 Nov – 9 Jan", "from 4 Nov", "ends 20 Feb", "no dates yet". */
35
+ export function spanText(a, b, today) {
36
+ if (a && b && a.slice(0, 10) === b.slice(0, 10)) return dayText(a, today);
37
+ if (a && b) {
38
+ const x = new Date(day(a)), y = new Date(day(b));
39
+ return x.getUTCMonth() === y.getUTCMonth() && x.getUTCFullYear() === y.getUTCFullYear() ? x.getUTCDate() + ' – ' + dayText(b, today) : dayText(a, today) + ' – ' + dayText(b, today);
40
+ }
41
+ if (a) return 'from ' + dayText(a, today);
42
+ if (b) return 'ends ' + dayText(b, today);
43
+ return 'no dates yet';
44
+ }
45
+ const inDays = (iso, today) => { const n = Math.round((day(iso) - day(today)) / DAY); return n === 0 ? 'today' : n === 1 ? 'tomorrow' : n > 1 ? 'in ' + n + ' days' : ''; };
46
+ const pct = (v, S) => { const a = day(S.a), b = day(S.b); return ((day(v) - a) / Math.max(DAY, b - a)) * 100; };
47
+
48
+ /* ── Where it stands ── */
49
+ /** The next dates of this initiative from today on: its open milestones, and the outcome check when the record holds one. */
50
+ export function nextOf(r, W, n = 3) {
51
+ const t = W.today, out = [];
52
+ for (const m of (r && r.milestones) || []) if (m && !m.done && m.date && m.date >= t) out.push({ kind: 'ms', date: m.date, name: m.name, uid: m.id || '' });
53
+ const ck = r && r.outcome && /^\d{4}-\d{2}-\d{2}/.test(String(r.outcome.next || '')) ? String(r.outcome.next).slice(0, 10) : '';
54
+ if (ck && ck >= t) out.push({ kind: 'check', date: ck, name: 'Check the outcome', uid: '' });
55
+ return out.sort((a, b) => a.date.localeCompare(b.date)).slice(0, n).map((x) => ({ ...x, text: dayText(x.date, t) }));
56
+ }
57
+ const sugWill = (s) => {
58
+ if (s.choices) return [];
59
+ const it = (s.items || []).filter((x) => x && (x.title || x.task));
60
+ if (s.group === 'dates' && it.length) return it.slice(0, 4).map((x) => 'Move ' + (x.title || x.task) + (x.to ? ' to ' + dayText(x.to) : ''));
61
+ if (it.length) return it.slice(0, 4).map((x) => String(x.title || x.task));
62
+ return s.ask || s.move || s.moveAll ? [s.say] : [];
63
+ };
64
+ /** One proposal as the expanded Suggestion. Pencil opens it (its page: change it first, ask about it), ✓ does it, ✕ says no. */
65
+ export function sugHtml(s) {
66
+ if (!s || !s.say) return '';
67
+ const row = (k, v, cls = '') => (v ? `<dt>${k}</dt><dd${cls ? ` class="${cls}"` : ''}>${v}</dd>` : '');
68
+ const will = sugWill(s), src = (s.sources || []).map((x) => x && x.label).filter(Boolean).join(', ');
69
+ const ans = s.choices
70
+ ? s.choices.map((c, i) => `<button type="button" class="pm-btn outline" data-pw-choice="${esc(s.id + '|' + i)}">${esc(c.label)}</button>`).join('') + `<button type="button" class="pm-btn outline" data-pw-drop="${esc(s.id)}" aria-label="Not now" title="Not now">${SV(I.x)}</button>`
71
+ : `<button type="button" class="pm-btn" data-pw-sug="${esc(s.id)}" aria-label="Change it first" title="Change it first">${SV(I.pen)}</button>`
72
+ + `<button type="button" class="pm-btn primary" data-pw-keep="${esc(s.id)}" aria-label="Yes, do it" title="Yes, do it">${SV(I.ok)}</button>`
73
+ + `<button type="button" class="pm-btn outline" data-pw-drop="${esc(s.id)}" aria-label="No" title="No">${SV(I.x)}</button>`;
74
+ return `<div class="pm-sug x" role="group" aria-label="PMOS suggests"><div class="ttl">${SV(I.star)}<b class="say">${esc(s.say)}</b></div>`
75
+ + `<dl>${row('Why', esc(s.why))}${row('PMOS will', will.length && !(will.length === 1 && will[0] === s.say) ? `<ul>${will.map((w) => `<li>${esc(w)}</li>`).join('')}</ul>` : '')}${row('Based on', esc(src), 'src')}</dl>`
76
+ + `<div class="ans">${ans}</div></div>`;
77
+ }
78
+ export function standsHtml(W, r, o = {}) {
79
+ const say = (W.summary && W.summary.text) || '';
80
+ const nx = nextOf(r, W);
81
+ const next = nx.length ? `<p class="pm-row pwd-next"><span class="pm-meta">Next</span>${nx.map((x) => {
82
+ const mk = x.kind === 'ms' ? '<i class="pwd-mk dia" aria-hidden="true"></i>' : '<i class="pwd-mk ring" aria-hidden="true"></i>';
83
+ const soon = inDays(x.date, W.today), when = soon && /^(today|tomorrow|in [1-7] days)$/.test(soon) ? ` <span class="pm-badge">${esc(soon)}</span>` : '';
84
+ const lbl = `${mk}<span class="pm-meta code">${esc(x.text)}</span> <span>${esc(x.name)}</span>${when}`;
85
+ return x.uid ? `<button type="button" class="pwd-nx" data-pw-open="${esc(x.uid)}" aria-label="${esc('Open ' + x.name + ', ' + x.text)}">${lbl}</button>` : `<span class="pwd-nx">${lbl}</span>`;
86
+ }).join('')}</p>` : '';
87
+ const s = (W.suggests || [])[0], more = Math.max(0, (W.suggests || []).length - 1) + (W.more || 0);
88
+ const sug = o.ro ? '' : sugHtml(s) + (more ? `<p class="pwd-moresug"><button type="button" class="pw-lk" data-pw-props>${esc(plural(more, 'more suggestion', 'more suggestions'))}</button></p>` : '');
89
+ if (!say && !next && !sug) return '';
90
+ return `<section class="pm-block pwd-blk pwd-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>`
91
+ + (say ? `<p class="pwd-say">${esc(say)}</p>` : '') + next + sug + '</section>';
92
+ }
93
+
94
+ /* ── Stages ── */
95
+ /** st: the stage rows of the breakdown with every stage drawn ({ key, name, start, end, now, done, marks }). */
96
+ export function stagesHtml(st, W) {
97
+ const S = W.span, list = (st || []).filter((x) => x && x.kind === 'stage' && x.key !== '');
98
+ if (!list.length) return '';
99
+ const a = day(S.a), b = day(S.b), months = [];
100
+ for (let d = new Date(a); d.getTime() < b; ) {
101
+ d = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth() + 1, 1));
102
+ if (d.getTime() >= b) break;
103
+ months.push({ x: pct(new Date(d).toISOString().slice(0, 10), S), label: MON[d.getUTCMonth()] + (d.getUTCMonth() === 0 ? ' ' + d.getUTCFullYear() : '') });
104
+ }
105
+ const step = months.length > 14 ? 3 : 1;
106
+ const tx = W.today >= S.a && W.today <= S.b ? pct(W.today, S) : null;
107
+ const now = tx != null ? `<i class="pm-now" style="left:${tx.toFixed(2)}%"></i>` : '';
108
+ const scale = `<div class="pwd-sr pwd-sh" aria-hidden="true"><span></span><div class="pwd-tk">${months.filter((m, i) => i % step === 0 && m.x > 2 && m.x < 97 && !(tx != null && Math.abs(m.x - tx) < 6)).map((m) => `<span class="pwd-mo" style="left:${m.x.toFixed(2)}%">${esc(m.label)}</span>`).join('')}${tx != null ? `<span class="pwd-mo td" style="left:${tx.toFixed(2)}%">${esc(dayText(W.today, W.today))}</span>` : ''}</div></div>`;
109
+ const rows = list.map((x) => {
110
+ const bar = x.start && x.end ? (() => { const l = Math.max(0, pct(x.start, S)), r = Math.min(100, pct(x.end, S)); return r > l ? `<i class="b${x.done ? ' dn' : x.now ? ' nw' : ''}" style="left:${l.toFixed(2)}%;width:${Math.max(0.8, r - l).toFixed(2)}%"></i>` : ''; })() : '';
111
+ const marks = (x.marks || []).filter((m) => m.end >= S.a && m.end <= S.b).map((m) => `<button type="button" class="pm-dia${m.done ? ' dn' : m.late ? ' late' : ''}" style="left:${pct(m.end, S).toFixed(2)}%" data-pw-open="${esc(m.uid)}" aria-label="${esc(m.title + ', ' + dayText(m.end, W.today))}" title="${esc(m.title + ' · ' + dayText(m.end, W.today))}"></button>`).join('');
112
+ return `<div class="pwd-sr${x.now ? ' now' : ''}" role="row"><span class="pwd-sn"><b>${esc(x.name)}</b><span class="pm-meta">${esc(spanText(x.start, x.end, W.today))}</span></span><div class="pm-gt pwd-tk">${bar}${marks}${now}</div></div>`;
113
+ }).join('');
114
+ return `<section class="pm-block pwd-blk pwd-stages" aria-label="Stages"><h2 class="pm-h-sm">Stages</h2><div class="pwd-st" role="table" aria-label="Stages">${scale}${rows}</div></section>`;
115
+ }
116
+
117
+ /* ── the Work breakdown ── */
118
+ export function wbsHead(view) {
119
+ const t = (k, l) => `<button type="button" class="pm-tab" role="tab" aria-selected="${view === k}" data-pwv="${k}">${l}</button>`;
120
+ return `<div class="pm-row pwd-bh"><h2 class="pm-h-sm">Work breakdown</h2><div class="pm-tabs" role="tablist" aria-label="View of the work breakdown">${t('list', 'List')}${t('gantt', 'Gantt')}</div></div>`;
121
+ }
122
+ /** The stage a captured line names: "Write the runbook in Plan" → Plan; else the stage in progress, else the first stage. */
123
+ export function stageKeyOf(text, st) {
124
+ const L = (st || []).filter((x) => x && x.kind === 'stage' && x.key !== '');
125
+ const s = String(text || '').trim();
126
+ for (const x of L) {
127
+ const re = new RegExp('\\s+(?:in|for|under|to)\\s+(?:the\\s+)?' + x.name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') + '(?:\\s+stage)?\\s*$', 'i');
128
+ if (re.test(s)) return { key: x.key, name: x.name, title: s.replace(re, '').trim() };
129
+ }
130
+ const cur = L.find((x) => x.now) || L.find((x) => !x.done) || L[0];
131
+ return cur ? { key: cur.key, name: cur.name, title: s, guessed: true } : null;
132
+ }
133
+ /** rows: the breakdown with every stage open, its done tasks shown and no fold (pop-work-model.js breakdownOf). o: { ro, looseN, ms } */
134
+ export function listHtml(rows, W, o = {}) {
135
+ const groups = [], empty = [];
136
+ let g = null;
137
+ for (const x of rows || []) {
138
+ if (x.kind === 'stage') { g = x.key === '' ? null : { s: x, tasks: [] }; if (g) groups.push(g); continue; }
139
+ if (g && x.kind === 'task') g.tasks.push(x);
140
+ }
141
+ const li = (x) => {
142
+ const sub = [x.date, x.who && x.who !== 'You' ? x.who : ''].filter(Boolean).join(' · ');
143
+ const box = x.done ? `<span class="pwd-ck dn" aria-label="Done" role="img">${SV(I.ok, 14)}</span>`
144
+ : o.ro || x.jira ? `<span class="pwd-ck" aria-hidden="true">${SV(x.ms ? I.dia : I.box, 14)}</span>`
145
+ : `<button type="button" class="pwd-ck" data-pw-status="${esc(x.uid)}" aria-haspopup="menu" aria-label="${esc('Status: ' + x.status + '. Change it')}" title="${esc(x.status)}">${SV(x.ms ? I.dia : I.box, 14)}</button>`;
146
+ const title = x.jira || o.ro || x.done ? `<span class="t">${esc(x.title)}</span>` : `<button type="button" class="t pwd-tt" data-pw-name="${esc(x.uid)}" aria-label="${esc('Rename ' + x.title)}">${esc(x.title)}</button>`;
147
+ const acts = o.ro ? '' : `<span class="acts"><button type="button" class="pm-btn" data-pw-open="${esc(x.uid)}" aria-label="Open the task" title="Open the task">${SV(I.open)}</button><button type="button" class="pm-btn" data-pw-row-more="${esc(x.uid)}" aria-haspopup="menu" aria-label="${esc('More for ' + x.title)}" title="More">${SV(I.more)}</button></span>`;
148
+ return `<div class="pm-li pwd-li${x.done ? ' dn' : ''}${x.lit ? ' now' : ''}" data-pwli="${esc(x.uid)}" data-pw-row="${esc(x.uid)}">${box}<span class="txt">${title}${sub ? `<span class="w${x.late ? ' late' : ''}">${esc(sub)}</span>` : ''}</span>${acts}</div>`;
149
+ };
150
+ const body = groups.map((G) => {
151
+ if (!G.tasks.length) { empty.push(G.s.name); return ''; }
152
+ const open = G.tasks.filter((x) => !x.done), dn = G.tasks.filter((x) => x.done);
153
+ return `<div class="pm-group${G.s.now ? ' now' : ''}"><b>${esc(G.s.name)}</b> <span class="pm-meta">${esc(dn.length + ' of ' + G.tasks.length + ' done')}</span></div>` + open.concat(dn).map(li).join('');
154
+ }).join('');
155
+ const fold = empty.length ? `<div class="pm-fold pwd-fold">${esc(empty.length === 1 ? empty[0] + ' has no tasks yet' : empty.slice(0, -1).join(', ') + ' and ' + empty[empty.length - 1] + ' have no tasks yet')}</div>` : '';
156
+ const cap = o.ro ? '' : `<input class="pm-input pwd-cap" data-pw-cap placeholder="Add a task; say its stage, or PMOS picks one" aria-label="Add a task. Say its stage, or PMOS picks one" maxlength="200" autocomplete="off">`;
157
+ const loose = o.looseN && !o.ro ? `<p class="pwd-loose"><button type="button" class="pw-lk" data-pw-backlog>${esc(o.looseN === 1 ? '1 task with no stage is in the Backlog' : o.looseN + ' tasks with no stage are in the Backlog')}${SV(I.right, 13)}</button></p>` : '';
158
+ return cap + `<div class="pwd-list" role="list" aria-label="Work breakdown">${body || (fold ? '' : '<p class="pm-meta pwd-none">No task yet.</p>')}${fold}</div>` + loose;
159
+ }
160
+
161
+ /* ── the side column ── */
162
+ /** The case: the lines PMOS read from the records, each a press that edits it in place; a line not written offers a PMOS draft. No line
163
+ * written: one Suggestion drafts them all (✓ sends the asks to Ask PMOS), ✕ says not now, the pencil starts the first line yourself. */
164
+ export function caseHtml(W, o = {}) {
165
+ const ov = W.overview || { lines: [] }, dr = o.dropped || new Set(), oid = o.oid || '';
166
+ const L = ov.lines || [], none = L.length && L.every((x) => !x.text);
167
+ const sid = (x) => 'ov:' + oid + ':' + x.id;
168
+ const ask = L.filter((x) => !x.text && x.ask && !dr.has(sid(x)));
169
+ let top = '';
170
+ if (none && !o.ro && ask.length) {
171
+ top = `<div class="pm-sug x" role="group" aria-label="PMOS suggests"><div class="ttl">${SV(I.star)}<b class="say">Let PMOS draft the case from what is linked</b></div>`
172
+ + `<dl><dt>Why</dt><dd>No line of the case is written yet.</dd><dt>PMOS will</dt><dd><ul>${ask.map((x) => `<li>${esc('Draft the ' + x.k.toLowerCase() + ' from the linked tickets, documents and meetings')}</li>`).join('')}</ul></dd><dt>What changes</dt><dd>You read the draft before it is saved.</dd></dl>`
173
+ + `<div class="ans"><button type="button" class="pm-btn" data-pw-line="${esc(L[0].id)}" aria-label="Write it yourself" title="Write it yourself">${SV(I.pen)}</button>`
174
+ + `<button type="button" class="pm-btn primary" data-pw-lkeep="${esc(ask.map((x) => x.id).join(','))}" aria-label="Use a PMOS draft" title="Use a PMOS draft">${SV(I.ok)}</button>`
175
+ + `<button type="button" class="pm-btn outline" data-pw-ldrop="${esc(ask.map(sid).join(','))}" aria-label="Not this" title="Not this">${SV(I.x)}</button></div></div>`;
176
+ }
177
+ const lines = L.filter((x) => !(none && top) || x.text).map((x) => {
178
+ const ed = !o.ro && x.edit;
179
+ const words = x.text ? esc(x.text) : 'Not written yet.';
180
+ const tx = ed ? `<span class="pwd-cv${x.text ? '' : ' grey'}" data-pw-line="${esc(x.id)}" tabindex="0" role="button" aria-label="${esc((x.text ? 'Change the ' : 'Write the ') + x.k.toLowerCase())}">${words}</span>` : `<span class="${x.text ? '' : 'grey'}">${words}</span>`;
181
+ const src = !o.ro && x.text && x.src ? (x.path ? ` <button type="button" class="pw-osrc" data-pw-src="${esc(x.path)}">from ${esc(x.src)}</button>` : ` <span class="pm-meta">from ${esc(x.src)}</span>`) : '';
182
+ const off = !o.ro && !x.text && x.ask && !dr.has(sid(x)) ? `<span class="pm-row pwd-off"><button type="button" class="pm-btn" data-pw-lkeep="${esc(x.id)}" aria-label="Yes, PMOS drafts it" title="Yes, PMOS drafts it">${SV(I.star, 14)}</button><button type="button" class="pm-btn" data-pw-ldrop="${esc(sid(x))}" aria-label="No" title="No">${SV(I.x, 14)}</button></span>` : '';
183
+ return `<div class="pwd-cl"><span class="pm-meta">${esc(x.k)}</span><p>${tx}${x.serves ? ' <span class="pm-meta">' + esc(x.serves) + '</span>' : ''}${src}${off}</p></div>`;
184
+ }).join('');
185
+ const F = (W.facts || []).filter((f) => f && f.k !== 'Stage' && !/^no signal$/i.test(String(f.v || '').trim()));
186
+ const facts = F.length ? `<dl class="pwd-facts">${F.map((f) => `<dt>${esc(f.k)}</dt><dd>${f.act && !f.read && !o.ro ? `<button type="button" class="pw-lk" data-pw-fact="${esc(f.act)}">${esc(f.v)}</button>` : `<span class="${f.grey ? 'grey' : ''}${f.warn && !f.note ? ' warn' : ''}">${esc(f.v)}</span>`}${f.note ? ` <span class="pm-meta${f.warn ? ' warn' : ''}">${esc(f.note)}</span>` : ''}</dd>`).join('')}</dl>` : '';
187
+ return `<section class="pm-block pwd-blk pwd-case" aria-label="The case"><h2 class="pm-h-sm">The case</h2>${top}${lines}${ov.status && !W.summary ? `<p>${esc(ov.status)}</p>` : ''}${facts}</section>`;
188
+ }
189
+ const iconOf = (a) => (a.link || /^link/i.test(a.kind || '') ? I.link : /slide|deck/i.test(a.kind || '') ? I.deck : /proto|design/i.test((a.kindName || '') + ' ' + (a.kind || '') + ' ' + (a.akind || '')) ? I.proto : I.doc);
190
+ /** arts: the model's artefacts, in its order (each row's press is its index, as the popup's handler reads it). o: { ro, merge (the ✦ line) } */
191
+ export function artsHtml(arts, o = {}) {
192
+ const R = (arts || []).map((a, i) => ({ a, i })).filter((x) => !(o.ro && x.a.missing));
193
+ if (o.ro && !R.length) return '';
194
+ const rows = R.map(({ a, i }) => {
195
+ const meta = a.missing ? String(a.missing) : [a.kindName || a.kind, a.came, a.when].filter(Boolean).join(' · ');
196
+ const inner = `<span class="pwd-ai">${SV(iconOf(a))}</span><span class="txt"><span class="t">${esc(a.title)}</span>${meta ? `<span class="w${a.missing ? ' warn' : ''}">${esc(meta)}</span>` : ''}</span>`;
197
+ return a.missing || o.ro ? `<div class="pm-li pwd-art${a.missing ? ' miss' : ''}">${inner}</div>` : `<button type="button" class="pm-li pwd-art" data-pw-art="${i}">${inner}</button>`;
198
+ }).join('');
199
+ const add = o.ro ? '' : `<button type="button" class="pm-btn" data-pw-addart aria-label="Add an artefact: a file, a link, or a new document" title="Add an artefact">${SV(I.plus)}</button>`;
200
+ return `<section class="pm-block pwd-blk pwd-arts" aria-label="Artefacts"><div class="pm-row pwd-bh"><h2 class="pm-h-sm">Artefacts</h2>${add}</div>${o.merge || ''}${rows || '<p class="pm-meta">Nothing yet.</p>'}</section>`;
201
+ }
@@ -136,6 +136,28 @@ body.bd-page.sp-on [id="bkBody"] { display: flex; flex-direction: column; gap: v
136
136
  .wk-spx .wk-due { gap: var(--space-8); flex-wrap: nowrap; }
137
137
  .wk-spx tr.wk-g td { padding: 0; }
138
138
 
139
+ /* ── Backlog (WorkBacklogDS): Where it stands, the capture, the ranked Table ── */
140
+ body.bd-page.bk-on [id="bdFilter"] { display: none; }
141
+ body.bd-page.bk-on [id="bkBody"] { display: flex; flex-direction: column; gap: var(--space-16); max-width: none; }
142
+ .wk-bk .wk-cap { margin: var(--space-4) 0; }
143
+ .wk-bkt td { white-space: nowrap; }
144
+ .wk-bkt td:nth-child(2) { white-space: normal; }
145
+ .wk-bkt th.wk-rk, .wk-bkt td.wk-rk { width: 64px; }
146
+ .wk-bkt td.wk-rk > .pm-row { gap: var(--space-4); flex-wrap: nowrap; }
147
+ .wk-bkt .wk-grip { color: var(--muted); cursor: grab; display: inline-flex; }
148
+ .wk-bkt .wk-ck { display: none; margin: 0; }
149
+ .wk-bkt tr:hover .wk-ck, .wk-bkt tr.sel .wk-ck, .wk-bkt.picking .wk-ck, .wk-bkt .wk-ck:focus-visible { display: inline-block; }
150
+ .wk-bkt tr:hover .wk-ck + .pm-meta, .wk-bkt tr.sel .wk-ck + .pm-meta, .wk-bkt.picking .wk-ck + .pm-meta { display: none; }
151
+ .wk-bkt .wk-tt { all: unset; cursor: pointer; font-weight: var(--fw-strong); }
152
+ .wk-bkt .wk-tt:hover { text-decoration: underline; }
153
+ .wk-bkt .wk-tt:focus-visible { box-shadow: var(--glow); border-radius: var(--radius-sm); }
154
+ .wk-bkt th.wk-ac, .wk-bkt td.wk-ac { width: 1%; text-align: right; }
155
+ .wk-bkt tr.drag td { opacity: .5; }
156
+ .wk-bkt tr.drop td { box-shadow: inset 0 2px 0 var(--blue); }
157
+ .wk-bkt tr.wk-g td { padding: 0; }
158
+ .wk-bkt .pm-group .pm-btn { margin-left: auto; }
159
+ .wk-bk > .pm-meta .wk-sa, .wk-bk .wk-sa { all: unset; cursor: pointer; color: var(--blue); }
160
+
139
161
  @media (max-width: 760px) {
140
162
  .wk-spcols { grid-template-columns: 1fr 1fr; }
141
163
  body.bd-page.wk-on .bd-hd, body.bd-page.bk-on .bd-hd { display: flex; }
@@ -26,12 +26,16 @@ import * as ED from './ini-edit.js';
26
26
  import * as SW from './cozy-status-when.js'; // When did this happen? after a status pick (round 3 point 18)
27
27
  import * as DP from './cozy-day-pick.js'; // the app's own day field, "15 Oct 2026"
28
28
  const { localToday } = DP;
29
- import * as AK from './artefact-kind.js'; // the Kind of a file and one row per kind (round 3 point 16), shared with the Library // the rename and its Undo, the same write as the old List (batch 18 item 16)
29
+ import * as AK from './artefact-kind.js';
30
+ import * as PD from './bd-pop-ds.js'; // the popup on a computer, built from the design system's blocks (initiative work-ds-popup) // the Kind of a file and one row per kind (round 3 point 16), shared with the Library // the rename and its Undo, the same write as the old List (batch 18 item 16)
30
31
 
31
- const CSS = new URL('./cozy-pop-work.css', import.meta.url).href;
32
+ const CSS = new URL('./cozy-pop-work.css', import.meta.url).href, DSCSS = new URL('./bd-pop-ds.css', import.meta.url).href;
32
33
  if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
33
34
  const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = CSS; document.head.appendChild(l);
34
35
  }
36
+ if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${DSCSS}"]`)) {
37
+ const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = DSCSS; document.head.appendChild(l);
38
+ }
35
39
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
36
40
  const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
37
41
  const P = {
@@ -291,9 +295,30 @@ export function html(r, v, o = {}) {
291
295
  const { W, S } = model(r, v, o), C = cols(), mode = store.get(SPAN, 'full');
292
296
  if (phone() && !RO) return phoneHtml(W, S, keyOf(v, o), v);
293
297
  if (S.big) return `<div class="pw" data-pw-big-on>${breakdownHtml(W, C, mode, true, S)}</div>`;
298
+ if (!RO && !phone()) return dsHtml(r, v, o, W, S, C, mode);
294
299
  return `<div class="pw">${overviewHtml(W, S, keyOf(v, o))}${breakdownHtml(W, C, mode, false, S)}${artefactsHtml(W.artefacts, C, true, { scope: keyOf(v, o), recPath: v.prd && (v.prd.path || v.prd) })}</div>`;
295
300
  }
296
301
 
302
+ /* ── a computer (initiative work-ds-popup; boards WorkPopupDS, WorkGanttDS, WorkCaseEmptyDS): the main column (Where it stands, Stages, the
303
+ * Work breakdown as List or Gantt) and the side column (The case, Artefacts), from the system's blocks (pm/bd-pop-ds.js). The Gantt view is the
304
+ * breakdown table with its bars and tools; List and Gantt are one remembered choice ('pw-view'). */
305
+ const VIEW = 'pw-view';
306
+ const allOpen = (v) => { const k = new Set(((v.tasks || {}).sections || []).filter((s) => s.kind === 'stage').map((s) => s.key)); return k; };
307
+ function stagesOf(r, v, o) {
308
+ const k = allOpen(v);
309
+ return M.breakdownOf(r, v, { ...o, open: k, shut: new Set(), doneOpen: k, moreOpen: k, farOpen: true }).rows;
310
+ }
311
+ function dsHtml(r, v, o, W, S, C, mode) {
312
+ const id = keyOf(v, o), view = store.get(VIEW, 'list') === 'gantt' ? 'gantt' : 'list';
313
+ const st = stagesOf(r, v, { ...o, today: W.today, focus: S.focus });
314
+ const wbs = view === 'gantt'
315
+ ? breakdownHtml(W, C, mode, false, S).replace('<h3>Work breakdown</h3>', PD.wbsHead('gantt')).replace('class="pw-sec"', 'class="pw-sec pm-block pwd-blk pwd-wbs"')
316
+ : `<section class="pm-block pwd-blk pwd-wbs" aria-label="Work breakdown">${PD.wbsHead('list')}${PD.listHtml(st, W, { looseN: W.looseN })}</section>`;
317
+ const mg = mergeOf(W.artefacts), merge = mg ? `<div class="pw-sugs pw-amg" role="list" aria-label="PMOS suggests">${sugLine({ id: mg.id, say: mg.say, merge: mg })}</div>` : '';
318
+ return `<div class="pw pwd">${'<div class="pwd-main">'}${PD.standsHtml(W, r)}${PD.stagesHtml(st, W)}${wbs}</div>`
319
+ + `<aside class="pwd-side">${PD.caseHtml(W, { oid: id, dropped: dropped() })}${PD.artsHtml(W.artefacts, { merge })}</aside></div>`;
320
+ }
321
+
297
322
  /* ── a phone (board Ph2_init; build brief nav-structure/phone/build-brief-v2.md item 8): the popup's content in a phone layout. No cards and
298
323
  * no table: the stage and its days over, the gate line, ✦ Overview with the lines that are written and one proposal for the ones that are not,
299
324
  * the status line and PMOS's proposals, the Work breakdown as rows with a status dot (grey done, blue in progress, an empty ring to do), the
@@ -450,10 +475,14 @@ export function wire(body, h0, x0) {
450
475
  body.addEventListener('scroll', () => { if (!body.querySelector(':scope > .pw, .pw:not(.pw-sp)')) return; const c = cur(); if (c) c.S.top = body.scrollTop; }, { passive: true });
451
476
  body.addEventListener('click', async (e) => {
452
477
  if (!live(e)) return;
453
- const b = e.target.closest('button, [data-pw-line]'); if (!b || b.disabled || !body.contains(b)) return;
478
+ const b = e.target.closest('button, [data-pw-line]');
479
+ // a List row (work-ds-popup): a press on the rest of the row opens the task
480
+ if (!b) { const li = e.target.closest('[data-pwli]'); if (li && !e.target.closest('input, textarea')) { const c0 = cur(); if (c0) openSmall(li.dataset.pwli, c0, body.__pwh, body.__pwx, body); } return; }
481
+ if (b.disabled || !body.contains(b)) return;
454
482
  const c = cur(); if (!c) return;
455
483
  const h = body.__pwh, x = body.__pwx;
456
484
  const d = b.dataset, S = c.S, W = c.W;
485
+ if (d.pwv) { store.set(VIEW, d.pwv); redraw(); return; }
457
486
  if ('pwDetails' in d) { S.details = !S.details; redraw(); return; }
458
487
  if (d.pwFold != null) { const k = d.pwFold, open = b.getAttribute('aria-expanded') === 'true'; S.open.delete(k); S.shut.delete(k); (open ? S.shut : S.open).add(k); if (k === '') looseKeep(c.id, !open); redraw(); return; }
459
488
  if ('pwFar' in d) { S.farOpen = true; redraw(); return; }
@@ -494,6 +523,15 @@ export function wire(body, h0, x0) {
494
523
  if (!live(e)) return;
495
524
  const t = e.target, h = body.__pwh;
496
525
  if (t.matches && t.matches('[data-pw-line]') && (e.key === 'Enter' || e.key === ' ')) { e.preventDefault(); t.click(); return; }
526
+ // the List's one capture Input (work-ds-popup): the task goes to the stage it names ("… in Plan"), else the stage in progress
527
+ if (t.matches && t.matches('[data-pw-cap]') && e.key === 'Enter') {
528
+ e.preventDefault(); const v0 = t.value.trim(), c = cur(); if (!v0 || !h.addTask || !c) return;
529
+ const ms = /^◇\s*/.test(v0), k = PD.stageKeyOf(v0.replace(/^◇\s*/, ''), stagesOf(c.r, c.v, { ...(body.__pwx.o() || {}), today: c.W.today }));
530
+ if (!k || !k.title) return;
531
+ await h.addTask(k.title, t, { section: k.key, name: k.name, ...(ms ? { milestone: true } : {}) });
532
+ setTimeout(() => { const f = body.querySelector('[data-pw-cap]'); if (f) { f.value = ''; f.focus(); } }, 0);
533
+ return;
534
+ }
497
535
  if (t.matches && t.matches('[data-pw-add]') && e.key === 'Enter') {
498
536
  e.preventDefault(); const v0 = t.value.trim(); if (!v0 || !h.addTask) return;
499
537
  const sec = t.dataset.pwAdd, c = cur();
@@ -291,7 +291,7 @@ export function goalName(list, anchor) {
291
291
  function taskRow(x, t) {
292
292
  const dl = x.end ? dateLate(x.end, t, !x.closed) : { text: x.start ? 'from ' + dayText(x.start, t) : '', late: false };
293
293
  const st = taskStatus(x);
294
- return { kind: 'task', uid: x.uid, title: x.title, status: st, date: dl.text, late: dl.late, start: x.start || '', end: x.end || '', since: x.since || '', done: !!x.closed, ms: !!x.ms, jira: !!x.jkey, canCheck: !!x.canCheck,
294
+ return { kind: 'task', uid: x.uid, title: x.title, who: x.owner || '', status: st, date: dl.text, late: dl.late, start: x.start || '', end: x.end || '', since: x.since || '', done: !!x.closed, ms: !!x.ms, jira: !!x.jkey, canCheck: !!x.canCheck,
295
295
  prog: /progress|review/i.test(st), wont: !!x.wont || st === "Won't do" };
296
296
  }
297
297
  /** o.focus: the task a Today row opened (round 3 item 11b): its stage, its done fold and the far stages open, and its row lit. */