create-pmos 0.664.0 → 0.666.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.664.0",
3
+ "version": "0.666.0",
4
4
  "description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
5
5
  "license": "MIT",
6
6
  "bin": {
@@ -34,10 +34,41 @@
34
34
  ],
35
35
  "pmosChanges": [
36
36
  {
37
- "v": "0.664.0",
38
- "at": "2026-11-22T04:17:27.653Z",
37
+ "v": "0.666.0",
38
+ "at": "2026-11-22T04:26:58.946Z",
39
39
  "f": 4,
40
40
  "prs": [
41
+ {
42
+ "n": 1448,
43
+ "t": "Check launch readiness before go-live",
44
+ "s": "Check launch readiness before go-live",
45
+ "k": "new"
46
+ },
47
+ {
48
+ "n": 1452,
49
+ "t": "A task opened from a place is the full popup from design system blocks",
50
+ "s": "A task opened from a place is the full popup from design system blocks",
51
+ "k": "new"
52
+ },
53
+ {
54
+ "n": 1453,
55
+ "t": "Read the tracker daily for all products, never forecast from a stale state",
56
+ "s": "Read the tracker daily for all products, never forecast from a stale state",
57
+ "k": "new"
58
+ }
59
+ ]
60
+ },
61
+ {
62
+ "v": "0.663.0",
63
+ "at": "2026-11-22T04:09:31.042Z",
64
+ "f": 4,
65
+ "prs": [
66
+ {
67
+ "n": 1449,
68
+ "t": "Rebuild the Intelligence page from Komorebi blocks",
69
+ "s": "Rebuild the Intelligence page from Komorebi blocks",
70
+ "k": "new"
71
+ },
41
72
  {
42
73
  "n": 1442,
43
74
  "t": "Routine is built from the design system's blocks",
@@ -49,12 +80,6 @@
49
80
  "t": "A design critic reads each design against every standing rule before the PM sees it",
50
81
  "s": "A design critic reads each design against every standing rule before the PM sees it",
51
82
  "k": "new"
52
- },
53
- {
54
- "n": 1448,
55
- "t": "Check launch readiness before go-live",
56
- "s": "Check launch readiness before go-live",
57
- "k": "new"
58
83
  }
59
84
  ]
60
85
  },
@@ -321,19 +346,6 @@
321
346
  "k": "fix"
322
347
  }
323
348
  ]
324
- },
325
- {
326
- "v": "0.633.0",
327
- "at": "2026-11-19T13:29:42.454Z",
328
- "f": 4,
329
- "prs": [
330
- {
331
- "n": 1415,
332
- "t": "Build the agreed phone design (Ph2 boards)",
333
- "s": "Build the agreed phone design (Ph2 boards)",
334
- "k": "new"
335
- }
336
- ]
337
349
  }
338
350
  ]
339
351
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@0cd92a74
1
+ kernel-source: pmos@26e63944
2
2
  assembled: 2026-11-22
3
3
  mode: vendor
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Eval calibration log"
4
4
  description: "Append-only record of every PM override of an evaluator verdict."
5
- generated: {by: process:create-pmos, at: "2026-11-22T04:17:24Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T04:26:55Z"}
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-22T04:17:24Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T04:26:55Z"}
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-22T04:17:24Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-22T04:26:55Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -63,7 +63,7 @@ const BMR = { ok: true, state: 'ready', model: { tiles: [
63
63
  await T.waitForServer(BASE);
64
64
  browser = classicBoard(await chromium.launch({ executablePath: exe }));
65
65
 
66
- const open = async ({ w = 1440, h = 900, theme = 'light', model = mk(), answers = null, bm = BMR, q = '', pick = null } = {}) => {
66
+ const open = async ({ w = 1440, h = 900, theme = 'light', model = mk(), answers = null, bm = BMR, q = '', pick = null, tab = 'goals' } = {}) => {
67
67
  const ctx = await browser.newContext({ viewport: { width: w, height: h } });
68
68
  const page = await ctx.newPage();
69
69
  let current = model, calls = 0; const errors = [], posts = [];
@@ -78,7 +78,7 @@ const BMR = { ok: true, state: 'ready', model: { tiles: [
78
78
  if (r.request().method() === 'POST') { pk.on = JSON.parse(r.request().postData() || '{}').on; pk.posts.push(pk.on); }
79
79
  r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, all: false, chosen: true, products: reg.map((x, i) => ({ ...x, home: false, primary: !i, initials: null, on: pk.on.includes(x.ws) })) }) });
80
80
  });
81
- await page.goto(BASE + '/premium-intelligence.html?theme=' + theme + '&tab=goals' + q); // key results live on Goals: ?tab=goals shows them here (intelligence-ds-page)
81
+ await page.goto(BASE + '/premium-intelligence.html?theme=' + theme + (tab ? '&tab=' + tab : '') + q); // key results live on Goals: ?tab=goals shows them here (intelligence-ds-page)
82
82
  const up = await until(() => page.evaluate(() => document.querySelectorAll('#goalTbl .ins-row').length > 0 || /could not be read/.test(document.querySelector('#brief').textContent) || !!document.querySelector('#goalTbl .ins-empty')), 20000);
83
83
  return { ctx, page, errors, posts, up, pk, calls: () => calls, setModel: (m) => { current = m; } };
84
84
  };
@@ -292,6 +292,34 @@ const BMR = { ok: true, state: 'ready', model: { tiles: [
292
292
  ok('I9 no demo label, and the page makes no write request on its own', !(await p.evaluate(() => /demo/i.test(document.querySelector('main.stage').textContent))) && A.posts.length === 0, A.posts.join());
293
293
  }
294
294
 
295
+ /* C4 + C6 (intelligence-ds-page): the default desk view, with no ?tab=goals. Key results step aside; Delivery trends is its own block with
296
+ * Choose tiles; a phone keeps its goal cards. */
297
+ { const D = await open({ tab: '' }); const dp = D.page;
298
+ await until(() => dp.evaluate(() => !!document.querySelector('#trendBox:not([hidden]) #bmBody [data-tile]')), 10000);
299
+ const dv = await dp.evaluate(() => { const tb = document.querySelector('#trendBox'), g = document.querySelector('#pGoals'); return { krs: document.body.classList.contains('ins-krs'), goals: getComputedStyle(g).display, block: tb.matches('section.pm-block') && !tb.hidden && tb.parentElement === g.parentElement, inGoals: !!g.querySelector('#trendBox'), h: (tb.querySelector('#hTr') || {}).textContent, tiles: tb.querySelectorAll('#bmBody [data-tile]').length, chooser: (tb.querySelector('#tileB') || { getAttribute: () => '' }).getAttribute('aria-label'), menu: !!document.querySelector('#tileMenu') }; });
300
+ ok('C6 on a desk the default view shows no key results: the table is in the page but hidden, and ?tab=goals is what shows it', !dv.krs && dv.goals === 'none', JSON.stringify(dv));
301
+ ok('C4 on the default view Delivery trends is a pm-block of its own (not inside key results), with its tiles and Choose tiles, its menu shut', dv.block && !dv.inGoals && dv.h === 'Delivery trends' && dv.tiles >= 3 && dv.chooser === 'Choose tiles' && !dv.menu, JSON.stringify(dv));
302
+ await dp.click('#tileB');
303
+ const mn = await until(() => dp.evaluate(() => { const m = document.querySelector('#tileMenu'); return m ? [...m.querySelectorAll('.pm-switch[role="switch"]')].map((s) => s.dataset.tileon + ':' + s.getAttribute('aria-checked')) : null; }), 3000);
304
+ ok('C4 Choose tiles opens a menu with one switch per tile, all on', !!mn && mn.length === dv.tiles && mn.every((x) => /:true$/.test(x)), JSON.stringify(mn));
305
+ const k0 = mn && mn[0].split(':')[0];
306
+ await dp.click(`#tileMenu [data-tileon="${k0}"]`);
307
+ const off = await until(() => dp.evaluate((k) => !document.querySelector(`#bmBody [data-tile="${k}"]`) && document.querySelector(`#tileMenu [data-tileon="${k}"]`).getAttribute('aria-checked') === 'false', k0), 3000);
308
+ ok('C4 a switch turned off takes its tile out of the block', !!off, k0);
309
+ await dp.click(`#tileMenu [data-tileon="${k0}"]`);
310
+ ok('C4 turned on again, the tile comes back', !!(await until(() => dp.evaluate((k) => !!document.querySelector(`#bmBody [data-tile="${k}"]`), k0), 3000)));
311
+ await dp.click('#tileB');
312
+ await dp.click('#trendBox [data-tile="merges"]');
313
+ ok('C4 on the default view a tile press opens the tile in the Viewer', !!(await until(() => dp.evaluate(() => { const v = document.querySelector('#czViewer'); return v && !v.hidden && !!v.querySelector('[data-tgset]'); }), 3000)));
314
+ await dp.click('#czViewer [data-tgset]');
315
+ ok('C4 and its Set target opens the target popover over the tiles', !!(await until(() => dp.evaluate(() => !!document.querySelector('#tgPop')), 3000)));
316
+ ok('C4 no page error on the default view', D.errors.length === 0, D.errors.join(' | '));
317
+ await D.ctx.close();
318
+ const P = await open({ tab: '', w: 390, h: 844 });
319
+ const ph = await P.page.evaluate(() => ({ goals: getComputedStyle(document.querySelector('#pGoals')).display, cards: [...document.querySelectorAll('#goalCards .ins-card')].filter((c) => c.getBoundingClientRect().height > 0).map((c) => c.dataset.goal).join() }));
320
+ ok('C6 a phone keeps its goal cards on the default view (the phone page does not change)', ph.goals !== 'none' && ph.cards === 'krm-act,krm-up,krm-ttfc,krm-nps', JSON.stringify(ph));
321
+ await P.ctx.close(); }
322
+
295
323
  /* D: New dashboard (AgInsNewDash), describe, the saved view, Edit chart (AgInsChart) and the pin */
296
324
  {
297
325
  const R = await open(), q = R.page, sent = [];
@@ -1,9 +1,40 @@
1
1
  [
2
2
  {
3
- "v": "0.664.0",
4
- "at": "2026-11-22T04:17:27.653Z",
3
+ "v": "0.666.0",
4
+ "at": "2026-11-22T04:26:58.946Z",
5
5
  "f": 4,
6
6
  "prs": [
7
+ {
8
+ "n": 1448,
9
+ "t": "Check launch readiness before go-live",
10
+ "s": "Check launch readiness before go-live",
11
+ "k": "new"
12
+ },
13
+ {
14
+ "n": 1452,
15
+ "t": "A task opened from a place is the full popup from design system blocks",
16
+ "s": "A task opened from a place is the full popup from design system blocks",
17
+ "k": "new"
18
+ },
19
+ {
20
+ "n": 1453,
21
+ "t": "Read the tracker daily for all products, never forecast from a stale state",
22
+ "s": "Read the tracker daily for all products, never forecast from a stale state",
23
+ "k": "new"
24
+ }
25
+ ]
26
+ },
27
+ {
28
+ "v": "0.663.0",
29
+ "at": "2026-11-22T04:09:31.042Z",
30
+ "f": 4,
31
+ "prs": [
32
+ {
33
+ "n": 1449,
34
+ "t": "Rebuild the Intelligence page from Komorebi blocks",
35
+ "s": "Rebuild the Intelligence page from Komorebi blocks",
36
+ "k": "new"
37
+ },
7
38
  {
8
39
  "n": 1442,
9
40
  "t": "Routine is built from the design system's blocks",
@@ -15,12 +46,6 @@
15
46
  "t": "A design critic reads each design against every standing rule before the PM sees it",
16
47
  "s": "A design critic reads each design against every standing rule before the PM sees it",
17
48
  "k": "new"
18
- },
19
- {
20
- "n": 1448,
21
- "t": "Check launch readiness before go-live",
22
- "s": "Check launch readiness before go-live",
23
- "k": "new"
24
49
  }
25
50
  ]
26
51
  },
@@ -116,6 +116,14 @@ The Viewer shows one item: an initiative, a program, a task, a document, a meeti
116
116
  - On a page drawn from the PMOS design system (Today, Home, an item on its own page), the parts inside the Viewer card follow the system too: a meeting, the calendar and a report use its corners, its buttons and its switches. A word button has a small corner, a switch looks like tabs, and a chip or a tag stays round.
117
117
  - One item shows in one Viewer only. If an item is already open, opening it again (a row, a ⌘-click, Open beside) shows it in the Viewer it is in. It never opens a second copy.
118
118
 
119
+ ### A task opened from a place
120
+
121
+ On a computer, a PMOS task you open from Events, Today, Goals or Search opens as one full popup, in the middle of the page. Home keeps its Viewer until Home is rebuilt, and a Jira ticket keeps the ticket Viewer.
122
+
123
+ - The top line has **Close**, the path (product › initiative › Jira key), the Jira chip, the chat button, ⋯ and ×. Press the initiative's name to open the initiative. One line under the name says Task or Milestone, who has it, when it is due and its stage.
124
+ - The left column has three blocks. **Where it stands** says who has it, its status, when it is due or how many days late it is, what waits on you and which initiative it moves. A task with no due date says so. **Linked** lists the initiative, the Jira ticket and each link in the notes; with nothing linked, the block does not show. **Activity** lists PMOS's kept changes, newest first: three, then **Earlier**. A change from the last 7 days has **Undo**.
125
+ - The right column is the task card: status, dates, owner, notes and every change you can make there, each with **Undo**.
126
+
119
127
  ## Work and its chat, in one popup
120
128
 
121
129
  On a computer, an initiative you open from Home, Board or Intelligence opens in one popup over the page. The work is on the left and the chat about the same work is on the right. A thin dimmed edge of the page shows around it. Escape, × or a press on the edge closes it.
@@ -94,6 +94,11 @@ const WEEKLY = { view: 'view', weeks: 3, day: 'Mon', opens: 4 };
94
94
  const s0 = await until(() => p.evaluate(() => { const m = document.querySelector('#insMv'); const b = document.querySelector('#insAct [data-mv="apply"]'); return m && !m.hidden && b ? { mv: m.textContent, label: b.getAttribute('aria-label'), text: b.textContent.trim(), solid: b.classList.contains('primary'), two: document.querySelector('#insHero').classList.contains('mv') } : null; }), 5000);
95
95
  ok('S the drafted move is the expanded Suggestion under the finding (its label, then PMOS will …), with a primary ✓ that is icon-only', !!s0 && s0.mv.startsWith(MOVE.label) && s0.mv.includes('PMOS will' + MOVE.text) && s0.label === MOVE.label && !s0.text && s0.solid && s0.two, JSON.stringify(s0));
96
96
  await shot(p, 'gap1-strip-move', '#insHero');
97
+ /* C2 (intelligence-ds-page): the expanded Suggestion's parts, in the board's order, and its three answers */
98
+ const sx = await p.evaluate(() => { const m = document.querySelector('#insMv'); return { cls: m.className, dt: [...m.querySelectorAll('dl > dt')].map((d) => d.textContent).join('|'), why: ((m.querySelector('dl > dt + dd') || {}).textContent || ''), src: (m.querySelector('dd.src') || {}).textContent || '', acts: [...m.querySelectorAll('#insAct > .pm-btn')].map((b) => b.getAttribute('aria-label') + ':' + (b.classList.contains('primary') ? 'p' : b.classList.contains('outline') ? 'o' : '-') + ':' + !!b.querySelector('svg') + ':' + !b.textContent.trim()).join('|'), chg: (m.querySelector('#insAct a.pm-btn') || {}).href || '' }; });
99
+ ok('C2 the move is a pm-sug x with Why, PMOS will, What changes and Based on, in that order', /\bpm-sug\b/.test(sx.cls) && /\bx\b/.test(sx.cls) && sx.dt === 'Why|PMOS will|What changes|Based on' && !!sx.why.trim() && !!sx.src.trim(), JSON.stringify(sx));
100
+ ok('C2 its answers are Change it first (pencil, opens a chat), Yes (primary ✓) and No (outline ✕), each icon-only', sx.acts === 'Change it first:-:true:true|' + MOVE.label + ':p:true:true|Not now:o:true:true' && /ask=insights/.test(sx.chg) && /Change%20this%20before|Change\+this\+before/.test(sx.chg), JSON.stringify(sx));
101
+ ok('C2 with a move, the reason is not said twice under the finding', (await p.evaluate(() => document.querySelector('#insWhy').textContent)) === '');
97
102
  await p.click('#insAct [data-mv="apply"]');
98
103
  await until(() => A.posts.some((x) => x.path === '/api/insight-moves/apply'), 3000);
99
104
  const ap = A.posts.find((x) => x.path === '/api/insight-moves/apply');
@@ -16,7 +16,7 @@
16
16
  * decorateInsights(model, F) puts g.forecast on each goal and b.burn on each budget of an Insights model; answers the items to record
17
17
  *
18
18
  * STATES. on-track (every line reaches the target), at-risk (some do), will-miss (none do), too-early (under 3 weeks or under 3 readings: no
19
- * number at all), held (the source was not read for more than 7 days: the range stands as it was read and is never carried forward). A delivery's
19
+ * number at all), held (the source was not read for more than 7 days, or Jira for more than a day: the range stands as it was read and is never carried forward). A delivery's
20
20
  * state comes from its range against the promise; with no promised date it has no state (null) and says why.
21
21
  *
22
22
  * THE LEDGER: <state>/forecast.jsonl, append-only, one line per event { at, by, kind, ... }:
@@ -38,6 +38,9 @@ const KINDS = new Set(['seen', 'turned', 'baseline', 'baseline-off']);
38
38
  const STATES = Object.freeze(['on-track', 'at-risk', 'will-miss', 'too-early', 'held']);
39
39
  const DAY = 864e5, WEEK = 7 * DAY;
40
40
  const MIN_WEEKS = 3, MIN_READINGS = 3, HELD_DAYS = 7, BURN_WEEKS = 8;
41
+ // tracker-daily (bet 1, proofs A77): Jira is read every day, so a delivery range never rests on a read older than yesterday's. It is held
42
+ // the day after a missed read, where a goal (read weekly or less) waits HELD_DAYS.
43
+ const READ_DAYS = 1;
41
44
  const DATE_RE = /^\d{4}-\d{2}-\d{2}$/;
42
45
  const fin = (v) => typeof v === 'number' && Number.isFinite(v);
43
46
  const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
@@ -87,7 +90,7 @@ function deliveryForecast(r, J, o = {}) {
87
90
  const likely = F.hi ? addDays(F.lo, Math.round((dayMs(F.hi) - dayMs(F.lo)) / DAY / 2)) : F.lo;
88
91
  const state = F.finished ? 'on-track' : promised ? DOT_STATE[F.dot] || null : null;
89
92
  const out = { ...base, state, likely, low: F.lo, high: F.hi, why: F.finished ? 'Every ticket is done.' : !promised ? 'No promised date to read the range against.' : F.why || 'The tickets left at the fastest and the slowest closing rate.' };
90
- if (!F.finished && asOf && dayMs(today) - dayMs(asOf) > HELD_DAYS * DAY) return Object.assign(out, { state: 'held', was: state, why: 'Jira not read since ' + asOf + ', so the range is held where it was.' });
93
+ if (!F.finished && asOf && dayMs(today) - dayMs(asOf) > READ_DAYS * DAY) return Object.assign(out, { state: 'held', was: state, why: 'Jira not read since ' + asOf + ', so the range is held where it was.' });
91
94
  if (state && state !== 'on-track' && o.driftFrom) out.driftFrom = o.driftFrom;
92
95
  return out;
93
96
  }
@@ -7,7 +7,9 @@
7
7
  * no plan item, no record, no ledger line (D88: the Breakdown is the handoff checklist, not a copy of Jira).
8
8
  *
9
9
  * queryFor(root, initiative) → { linked, mode, query } the JQL for the tickets this initiative pushed, or, when it
10
- * pushed none, for its Jira epics and their children (mode 'epic', jira-epic-items)
10
+ * pushed none, for its Jira epics and their children (mode 'epic', jira-epic-items). In every
11
+ * mode it adds the tickets the initiative's tasks name at the start of their titles; with
12
+ * nothing else it reads only those (mode 'tasks', tracker-daily: lib/task-jira.js)
11
13
  * linkedInitiatives(root) → [{ initiative, query }]
12
14
  * normalize(raw) → { issues, skipped } | { error }
13
15
  * sync(root, initiative, raw, opts) → the snapshot, written to <state>/tracker/jira/<initiative>.md
@@ -28,11 +30,15 @@
28
30
  * stale. Titles and statuses only: never a description or a comment. The one person a reading carries is the assignee's display name, with
29
31
  * the time of the last update (`assignee`, `updated`): Waiting on others names who a stale ticket waits on (home-your-move-waiting).
30
32
  *
33
+ * A task that names a key follows its reading: lib/task-jira.js trackerLines sets its state in memory when the read is newer (no
34
+ * plan item or ledger line is written, D88 still holds).
35
+ *
31
36
  * BOUNDARY (J15). No network module, no child process. The only write is the snapshot file.
32
37
  */
33
38
  const fs = require('fs');
34
39
  const path = require('path');
35
40
  const jiraTickets = require('./jira-tickets.js');
41
+ const taskJira = require('./task-jira.js');
36
42
 
37
43
  const KEY_RE = /^[A-Za-z][A-Za-z0-9_]*-\d+$/;
38
44
  const isStr = (v) => typeof v === 'string';
@@ -41,18 +47,29 @@ const clip = (s, n) => (s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s);
41
47
  const nowIso = (now) => new Date(now == null ? Date.now() : now).toISOString().replace(/\.\d{3}Z$/, 'Z');
42
48
 
43
49
  // ── the query ──────────────────────────────────────────────────────────────────────────────────────
44
- function queryFor(root, initiative) {
50
+ /** The Jira keys the initiative's own tasks name in their titles (lib/task-jira.js): imported tasks follow their tickets. */
51
+ function taskKeysOf(root, initiative, byIni) {
52
+ const m = byIni || taskJira.readKeys(root);
53
+ return m.get(initiative) || [];
54
+ }
55
+ function queryFor(root, initiative, byIni) {
45
56
  if (!jiraTickets.recordFm(root, initiative)) return { ok: false, error: `no initiative ${initiative} in this repository` };
46
- const keys = [...jiraTickets.pushedTickets(root, initiative).tickets.keys()];
47
- if (keys.length) return { ok: true, initiative, linked: true, mode: 'pushed', keys, query: `key in (${keys.join(', ')}) ORDER BY key` };
57
+ const pushed = [...jiraTickets.pushedTickets(root, initiative).tickets.keys()];
58
+ const tasks = taskKeysOf(root, initiative, byIni).filter((k) => !pushed.includes(k));
59
+ const keys = [...pushed, ...tasks];
60
+ if (pushed.length) return { ok: true, initiative, linked: true, mode: 'pushed', keys, ...(tasks.length ? { tasks } : {}), query: `key in (${keys.join(', ')}) ORDER BY key` };
48
61
  // EPIC MODE (jira-epic-items): no ticket pushed, but the initiative has Jira epics. Read each epic and its children.
49
62
  const epics = jiraTickets.epicKeysOf(root, initiative);
50
- if (epics.length) return { ok: true, initiative, linked: true, mode: 'epic', keys: epics, epics, query: `key in (${epics.join(', ')}) OR parent in (${epics.join(', ')}) ORDER BY key` };
63
+ const extra = tasks.filter((k) => !epics.includes(k));
64
+ if (epics.length) return { ok: true, initiative, linked: true, mode: 'epic', keys: [...epics, ...extra], epics, ...(extra.length ? { tasks: extra } : {}), query: `key in (${[...epics, ...extra].join(', ')}) OR parent in (${epics.join(', ')}) ORDER BY key` };
65
+ // TASK MODE (tracker-daily): no ticket pushed and no epic, but tasks that name Jira tickets. Read those tickets.
66
+ if (tasks.length) return { ok: true, initiative, linked: true, mode: 'tasks', keys: tasks, tasks, query: `key in (${tasks.join(', ')}) ORDER BY key` };
51
67
  return { ok: true, initiative, linked: false, keys: [], query: null };
52
68
  }
53
69
  function linkedInitiatives(root) {
54
- const ids = [...new Set([...jiraTickets.draftedInitiatives(root), ...jiraTickets.epicInitiatives(root)])].sort();
55
- return ids.map((id) => queryFor(root, id)).filter((q) => q.ok);
70
+ const byIni = taskJira.readKeys(root);
71
+ const ids = [...new Set([...jiraTickets.draftedInitiatives(root), ...jiraTickets.epicInitiatives(root), ...byIni.keys()])].sort();
72
+ return ids.map((id) => queryFor(root, id, byIni)).filter((q) => q.ok);
56
73
  }
57
74
 
58
75
  // ── reading a saved search result ──────────────────────────────────────────────────────────────────
@@ -307,16 +324,21 @@ function sync(root, initiative, raw, { query, dryRun = false, now } = {}) {
307
324
  if (n.error) return { ok: false, error: n.error };
308
325
  const pushed = jiraTickets.pushedTickets(root, initiative).tickets;
309
326
  const epics = pushed.size ? [] : jiraTickets.epicKeysOf(root, initiative);
310
- if (!pushed.size && !epics.length) return { ok: false, error: `${initiative} has no ticket in Jira yet — push its tickets first, or link its Jira epic` };
327
+ const tasks = new Set(taskKeysOf(root, initiative)); // tracker-daily: the tickets the initiative's tasks name
328
+ if (!pushed.size && !epics.length && !tasks.size) return { ok: false, error: `${initiative} has no ticket in Jira yet — push its tickets first, link its Jira epic, or name a ticket key at the start of a task` };
311
329
  const prev = readSnapshot(root, initiative);
312
330
  // Pushed mode keeps the pushed keys. Epic mode keeps the epics and the issues under them; an issue the search returned
313
331
  // with no parent field is kept, since the search was scoped to the epics; one under another parent is ignored.
314
- const keep = pushed.size ? (i) => pushed.has(i.key) : (i) => epics.includes(i.key) || !i.parent || epics.includes(i.parent);
332
+ // In every mode the tickets the tasks name are kept too.
333
+ const keep = pushed.size ? (i) => pushed.has(i.key) || tasks.has(i.key)
334
+ : epics.length ? (i) => tasks.has(i.key) || epics.includes(i.key) || !i.parent || epics.includes(i.parent)
335
+ : (i) => tasks.has(i.key);
315
336
  const got = new Map(n.issues.filter(keep).map((i) => [i.key, i]));
316
337
  const ignored = n.issues.length - got.size;
317
338
  const ids = new Map([...pushed].map(([k, v]) => [k, v.id]));
318
339
  const readings = []; const changes = []; const missing = [];
319
- const expected = pushed.size ? [...pushed.keys()] : [...new Set([...epics, ...got.keys(), ...(prev ? [...prev.tickets.keys()].filter((k) => { const r = prev.tickets.get(k); return epics.includes(k) || !r.parent || epics.includes(r.parent); }) : [])])];
340
+ const expected = pushed.size || !epics.length ? [...new Set([...pushed.keys(), ...tasks])]
341
+ : [...new Set([...epics, ...tasks, ...got.keys(), ...(prev ? [...prev.tickets.keys()].filter((k) => { const r = prev.tickets.get(k); return epics.includes(k) || !r.parent || epics.includes(r.parent); }) : [])])];
320
342
  for (const key of expected) {
321
343
  const r = got.get(key);
322
344
  const was = prev ? prev.tickets.get(key) : null;
@@ -18,6 +18,8 @@
18
18
  * With no links into go-live there is no critical path to name, and the Viewer says nothing about it.
19
19
  * colour done: done. Red: it ends later than its baseline, it is on the critical path and go-live misses the goal date. Amber: it ends
20
20
  * later than its baseline otherwise, or it has not started and its start has passed. Green: on its baseline. None: no dates.
21
+ * stale input `stale` (lib/task-jira.js staleOf): the tasks that name Jira tickets rest on a read older than a day. Then on track is
22
+ * unknown, says when Jira was last read, and no ✦ is made (tracker-daily, bet 1).
21
23
  * on track "On track for <goal date>?" Yes when the forecast go-live is on or before the goal date; No with the slip and the first
22
24
  * slipping task on the critical path (the cause); unknown with the reason when a date is missing.
23
25
  * proposal on a No: a ✦ that moves the go-live milestone to its forecast. It never changes the goal, the KR or the title: those are
@@ -179,6 +181,14 @@ function project(input) {
179
181
  words: 'No. Forecast ' + md(fgo) + ', ' + days(fgo - goalN) + ' late.', cause: cause ? { uid: cause.uid, title: cause.title, slip: cause.slip } : null,
180
182
  why: cause ? '"' + cause.title + '" ends ' + days(cause.slip) + ' after its baseline' + (cause.critical ? ' and sits on the critical path' + (after.length ? ', so ' + listOf(after.map((x) => '"' + x + '"')) + (after.length === 1 ? ' moves' : ' move') : '') : '') + '.' : 'Open work is past its due day.', src };
181
183
  }
184
+ // tracker-daily (bet 1): never forecast from a stale tracker state. When the tasks that name Jira tickets rest on a read older than a
185
+ // day (or one that did not return them), the answer waits for the next read and no ✦ moves a date.
186
+ const ST = I.stale && I.stale.stale ? I.stale : null;
187
+ if (ST && (ontrack.answer === 'yes' || ontrack.answer === 'no')) {
188
+ const n = (ST.keys || []).length;
189
+ ontrack = { answer: 'unknown', stale: true, staleSince: ST.since || null, forecast: ontrack.forecast,
190
+ words: (ST.since ? 'Jira not read since ' + md(dn(String(ST.since).slice(0, 10))) : 'Jira not read yet') + ', so PMOS does not forecast from it. ' + n + (n === 1 ? ' task waits' : ' tasks wait') + ' on the next read.', src };
191
+ }
182
192
  // the ✦: move the go-live milestone to its forecast. Never the goal, the KR or the title.
183
193
  let proposal = null;
184
194
  if (ontrack.answer === 'no' && goLive && goLive.ms) {
@@ -49,6 +49,7 @@ const LOST_MS = 6 * 3600 * 1000; // a run with no live session and no end afte
49
49
  const READ_MS = 30 * 60 * 1000; // batch 31 item 6: a read of a tool (how 'tool') is stopped after this long, with the reason, so the next slot can run
50
50
  const SLOW_MS = 15 * 60 * 1000; // a read still working after this long shows as slow on its row
51
51
  const ALL_MS = 3 * 3600 * 1000; // a Refresh all that has not ended after this long is over: a new press starts a new one
52
+ const DAILY_MS = 20 * 3600 * 1000; // tracker-daily: a product workspace the pinned Jira read does not cover is read again once its last read is this old
52
53
  const DERIVED = Object.freeze(['leads', 'brief']); // what Refresh all writes again after the sources, in this order
53
54
  const DERIVED_LIST = Object.freeze(['scan', 'coredocs', 'leads', 'brief']); // what Sources lists as derived content: built from stored reads, never a tool
54
55
  const AUTH_RETRY_MS = 2 * 60 * 1000;
@@ -129,11 +130,16 @@ function create(host) {
129
130
  * initiative has a Jira ticket. It failed every morning ("The shared refresh session did not save a new read of it", "No initiative
130
131
  * has a Jira ticket or linked epic yet") while the workspace that holds the tickets was never read.
131
132
  */
132
- function wsFor(id, first) {
133
+ function wsFor(id, first, { only = false } = {}) {
133
134
  let list = null;
134
135
  if (host.sourceWs) { try { const l = host.sourceWs(id); if (Array.isArray(l)) list = [...new Set(l.filter(Boolean))]; } catch (e) { warn('source workspaces', e); } }
135
136
  if (!list) return first ? [first] : [];
136
- return first && list.includes(first) ? [first] : list;
137
+ if (!first || !list.includes(first)) return list;
138
+ if (only) return [first];
139
+ // tracker-daily (bet 1, proofs A77, 2026-11-22): a pinned workspace kept the read to one product, so the other products' tickets were
140
+ // never read again after their import. The pinned one keeps its rhythm; every other one is read when its last read is a day old.
141
+ const t = now();
142
+ return [first, ...list.filter((w) => w !== first && !readSince(id, w, t - DAILY_MS))];
137
143
  }
138
144
  const NOTHING_TO_READ = 'No initiative in any workspace has a Jira ticket or a linked epic yet, so there is nothing to read.';
139
145
 
@@ -590,7 +596,7 @@ function create(host) {
590
596
  R.writeState(dir, state);
591
597
  return { ok: true, source: id, waiting: busy, inputs: startedInputs };
592
598
  }
593
- const wss = wsFor(id, ws || (set.sources[id] && set.sources[id].ws) || host.homeWs());
599
+ const wss = wsFor(id, ws || (set.sources[id] && set.sources[id].ws) || host.homeWs(), { only: !!ws }); // a press in a workspace reads that one
594
600
  if (!wss.length) return { ok: false, status: 409, error: NOTHING_TO_READ };
595
601
  let r = null;
596
602
  for (const w of wss) { const r1 = start(src, w, { trigger: 'pressed' }); if (!r || (!r.ok && r1.ok)) r = r1; }
@@ -99,6 +99,7 @@ const B = require(repoScript('boards.js'));
99
99
  const WF = require(repoScript('workflows.js'));
100
100
  const WS = require('./workflows-store.js');
101
101
  const TI = require('./task-items.js');
102
+ const TJ = require('./task-jira.js'); // tracker-daily: imported tasks follow their Jira tickets
102
103
  const SW = require('./status-when.js');
103
104
  const TS = require('./task-store.js');
104
105
  const holdSpans = require('./hold-spans.js');
@@ -142,7 +143,7 @@ function readLedger(ctx, w) {
142
143
  const store = TS.storeFor(w && w.root);
143
144
  const key = statKey(f) + '|' + (store ? statKey(store.file) : 'none');
144
145
  const hit = ledgerMemo.get(f);
145
- if (hit && hit.key === key) return hit.lines.slice();
146
+ if (hit && hit.key === key) return withTracker(w, f, key, hit.lines);
146
147
  const board = readBoardLines(f);
147
148
  let lines = board;
148
149
  if (store) {
@@ -158,7 +159,26 @@ function readLedger(ctx, w) {
158
159
  }
159
160
  if (ledgerMemo.size > 100) ledgerMemo.clear();
160
161
  ledgerMemo.set(f, { key: statKey(f) + '|' + (store ? statKey(store.file) : 'none'), lines });
161
- return lines.slice();
162
+ return withTracker(w, f, key, lines);
163
+ }
164
+ /* tracker-daily (bet 1, proofs A77): a task whose title names a Jira key takes the state of the last Jira read when that read is newer
165
+ * (lib/task-jira.js trackerLines). The lines are added in memory, after the ledger's own lines, and never written; they change again
166
+ * with each read. Kept per ledger and per set of Jira snapshots. */
167
+ const trackerMemo = new Map();
168
+ function jiraSig(w) {
169
+ try { const d = jiraTickets.jiraDir(w.root); return fs.readdirSync(d).filter((n) => n.endsWith('.md') && !n.endsWith('-tickets.md') && !n.startsWith('_')).sort().map((n) => n + ':' + fs.statSync(path.join(d, n)).mtimeMs).join(','); } catch { return 'none'; }
170
+ }
171
+ function withTracker(w, f, key, lines) {
172
+ if (!w || !w.root) return lines.slice();
173
+ const k = key + '|' + jiraSig(w);
174
+ const hit = trackerMemo.get(f);
175
+ if (hit && hit.key === k) return hit.lines.slice();
176
+ let extra = [];
177
+ try { extra = TJ.trackerLines(lines, (ini) => jiraStatus.readSnapshot(w.root, ini)); } catch { extra = []; }
178
+ const all = extra.length ? lines.concat(extra) : lines;
179
+ if (trackerMemo.size > 100) trackerMemo.clear();
180
+ trackerMemo.set(f, { key: k, lines: all });
181
+ return all.slice();
162
182
  }
163
183
  function append(file, actor, ev) {
164
184
  const line = { at: new Date().toISOString(), by: actor.by, ...ev };
@@ -797,6 +817,7 @@ function itemsOf(w, fr, board, rows) {
797
817
  }
798
818
  for (const t of fr.folded.tasks.values()) if (t.board === board.id && ids.has(t.initiative)) out.push(B.taskItem(t));
799
819
  out.push(...TI.rowsOf(w.root, ids, board.id)); // one kind of task: an initiative's breakdown items show as its tasks (lib/task-items.js)
820
+ trackerMarks(w, out);
800
821
  for (const x of out) if (x.src === 'jira') x.notes = (fr.folded.ticketNotes && fr.folded.ticketNotes.get(board.id + '\u0000' + x.key)) || ''; // the PM's notes (canvas XetX1Jira)
801
822
  // the PM's own days for a Jira ticket (batch 11 item 23): kept in PMOS, they win over Jira's, and the row says so
802
823
  const TD = fr.folded.ticketDates || new Map();
@@ -841,6 +862,20 @@ function itemsOf(w, fr, board, rows) {
841
862
  return B.rollupItems(out);
842
863
  }
843
864
 
865
+ /** tracker-daily: a PMOS task that names a Jira key carries `tracker` { key, status, readAt, stale }: Jira's status at the last read, and
866
+ * stale when that read is older than a day or did not return the ticket (lib/task-jira.js staleOf). Its state is already the read's
867
+ * (readLedger). A page or a forecast says "not read since" instead of trusting a stale state. */
868
+ function trackerMarks(w, items) {
869
+ const snaps = new Map(), now = Date.now();
870
+ for (const x of items) {
871
+ if (x.src !== 'pmos' || x.kind === 'Epic') continue;
872
+ const key = TJ.keyOf(x.title);
873
+ if (!key) continue;
874
+ if (!snaps.has(x.ini)) { let sn = null; try { sn = jiraStatus.readSnapshot(w.root, x.ini); } catch { sn = null; } snaps.set(x.ini, sn); }
875
+ const sn = snaps.get(x.ini), rd = sn && sn.tickets ? sn.tickets.get(key) : null;
876
+ x.tracker = { key, status: (rd && rd.status) || null, readAt: (sn && sn.fetchedAt) || null, stale: TJ.staleOf([key], sn, now).stale };
877
+ }
878
+ }
844
879
  /** The Jira items of an initiative PMOS pushed nothing for: its linked epics and the issues under them, from the last
845
880
  * read of the Jira status check (lib/jira-status.js, epic mode). An issue under no linked epic hangs under the first. */
846
881
  function epicItems(row, board, snap, seen, out) {
@@ -77,8 +77,14 @@ function control(ctx, q, o = {}) {
77
77
  try { const f = require('./routes-boards.js').ledgerFile(ctx, w); if (f) lines.push(...readJsonl(f).filter((e) => e && (e.kind === 'task' || e.kind === 'task-update'))); } catch { /* none */ }
78
78
  lines.sort((a, b) => String(a.at || '').localeCompare(String(b.at || '')));
79
79
  const baseline = KC.baselineOf(lines, new Set(tasks.map((x) => x.uid || x.key)), baselineAt);
80
+ // tracker-daily: whether the tasks that name Jira tickets rest on a stale read (lib/task-jira.js)
81
+ let stale = null;
82
+ try {
83
+ const TJ = require('./task-jira.js'), keys = tasks.filter((x) => x.status !== 'Done' && x.status !== "Won't do" && x.status !== 'Archived').map((x) => TJ.keyOf(x.title)).filter(Boolean);
84
+ if (keys.length) stale = TJ.staleOf(keys, require('./jira-status.js').readSnapshot(w.root, id), o.now || Date.now());
85
+ } catch { stale = null; }
80
86
  const m = KC.project({ today, title: fm.title || (row && row.title) || id, goal: goal ? { id: goal.id, title: goal.title, byAt: goal.byAt } : null, end: row && row.end,
81
- record: fm, tasks, links: snap.links || [], baseline, baselineAt, people });
87
+ record: fm, tasks, links: snap.links || [], baseline, baselineAt, people, stale });
82
88
  return okBody({ ...m, ...(line ? { line } : {}) });
83
89
  }
84
90
 
@@ -0,0 +1,138 @@
1
+ 'use strict';
2
+ /* task-jira.js — a PMOS task that names a Jira ticket follows the ticket's state (bet 1, "read the tracker daily and never forecast
3
+ * from stale states"; proofs A77-states and A77-five-products, 2026-11-22).
4
+ *
5
+ * WHY. Tasks imported from Jira carry the ticket key at the start of their title ("IDPF-2746 · Send verification email"). PMOS read
6
+ * Jira only for the tickets it pushed itself or the issues under a linked epic, so these tasks kept the state of the day they were
7
+ * imported. On 22 Nov PMOS showed as open 69 of 109 such Scarlet tasks, 5 of 16 on OOH Digital and 142 of 359 on idpf that Jira had
8
+ * closed, and forecast from them. CAS matched (0 of 13). Here such a task joins the Jira read, and the read sets its state.
9
+ *
10
+ * keyOf(title) → 'IDPF-2746' | null the Jira key a title starts with
11
+ * keyedTasks(lines) PURE → Map task id → { task, initiative, key, state, stateAt } from task ledger lines
12
+ * keysByInitiative(lines) PURE → Map initiative → [key] the keys a Jira read must cover (lib/jira-status.js queryFor)
13
+ * readKeys(root) → the same, from the repository's task ledger (lib/task-store.js)
14
+ * stateOf(reading) PURE → 'To do' | 'In progress' | 'Done' | "Won't do" a Jira reading as a task state
15
+ * trackerLines(lines, snapOf) PURE → [task-update line] the state changes the last Jira read makes (see THE RULE). They are
16
+ * added to the folded lines in memory (lib/routes-boards.js readLedger) and never written to a file
17
+ * staleOf(keys, snap, now) PURE → { stale, since, keys } whether the read these keys rest on is older than STALE_MS
18
+ *
19
+ * THE RULE. The read sets the state of a task nobody changed since it was made or imported. When someone changed the state in PMOS, the
20
+ * read wins only when it is newer and Jira moved the ticket after that change (its last update or its resolution day); a read with
21
+ * neither time may only close the task. So a task the PM reopened stays open until Jira moves. A reading the search did not return
22
+ * (marked stale) changes nothing.
23
+ * STALE. The Jira read is due every day: a read older than 26 hours (lib/freshness.js, jira stale_after_ms) is stale, and so is a task
24
+ * key no read has covered yet. A forecast never rests on a stale read (lib/forecast.js, lib/kind-control.js).
25
+ *
26
+ * BOUNDARY. No network, no write: the only input is the ledger lines and the stored Jira snapshots.
27
+ */
28
+ const H = 3600 * 1000;
29
+ const STALE_MS = 26 * H;
30
+ const BY = 'tracker:jira';
31
+ const LEAD_KEY = /^\s*\[?([A-Z][A-Z0-9_]{0,19}-\d{1,7})\]?(?![A-Za-z0-9-])/;
32
+ const CLOSED_NOT_DONE = /invalid|not an issue|won'?t|cancel|duplicate|reject|obsolete|not (?:needed|required|a bug)|declined|abandon/i;
33
+ const TASK_KINDS = new Set(['task', 'task-update', 'task-remove', 'task-restore']);
34
+
35
+ /** The Jira key a task title starts with, upper case; null when it names none. */
36
+ const NOT_TICKETS = /^(CVE|CWE|GHSA|RFC|ISO|SOC|PCI|COVID|ES|TLS|SHA|UTF|AES|RSA|HTTP)-/; // advisory, standard and version ids, not tickets
37
+ function keyOf(title) {
38
+ const m = LEAD_KEY.exec(String(title == null ? '' : title));
39
+ return m && !NOT_TICKETS.test(m[1]) ? m[1] : null;
40
+ }
41
+ const ms = (s) => { const t = Date.parse(String(s || '')); return Number.isFinite(t) ? t : 0; };
42
+
43
+ /** Every task of the ledger lines whose title names a Jira key, folded the way scripts/boards.js folds tasks (first `task` line wins,
44
+ * `task-update` changes it, `task-remove` takes it out and `task-restore` puts it back). */
45
+ function keyedTasks(lines) {
46
+ const all = new Map(); const removed = new Map();
47
+ for (const e of lines || []) {
48
+ if (!e || typeof e !== 'object' || !TASK_KINDS.has(e.kind) || typeof e.task !== 'string') continue;
49
+ if (e.kind === 'task') {
50
+ if (all.has(e.task) || typeof e.initiative !== 'string') continue;
51
+ // stateAt is the time someone CHANGED the state: the state a task was created (or imported) with is no decision
52
+ all.set(e.task, { task: e.task, initiative: e.initiative, title: String(e.title || ''), state: e.state || 'To do', stateAt: null });
53
+ } else if (e.kind === 'task-update') {
54
+ const t = all.get(e.task); if (!t) continue;
55
+ if (typeof e.initiative === 'string' && e.initiative) t.initiative = e.initiative;
56
+ if (typeof e.title === 'string' && e.title.trim()) t.title = e.title.trim();
57
+ if (typeof e.state === 'string' && e.state) { t.state = e.state === 'In review' ? 'In progress' : e.state; t.stateAt = e.at || t.stateAt; }
58
+ } else if (e.kind === 'task-remove') {
59
+ if (all.has(e.task)) { removed.set(e.task, all.get(e.task)); all.delete(e.task); }
60
+ } else if (e.kind === 'task-restore') {
61
+ if (removed.has(e.task) && !all.has(e.task)) { all.set(e.task, removed.get(e.task)); removed.delete(e.task); }
62
+ }
63
+ }
64
+ const out = new Map();
65
+ for (const t of all.values()) { const key = keyOf(t.title); if (key) out.set(t.task, { ...t, key }); }
66
+ return out;
67
+ }
68
+
69
+ /** The keys each initiative's tasks name, sorted. Archived tasks are left out: nobody plans them. */
70
+ function keysByInitiative(lines) {
71
+ const by = new Map();
72
+ for (const t of keyedTasks(lines).values()) {
73
+ if (t.state === 'Archived') continue;
74
+ if (!by.has(t.initiative)) by.set(t.initiative, new Set());
75
+ by.get(t.initiative).add(t.key);
76
+ }
77
+ return new Map([...by].map(([k, v]) => [k, [...v].sort()]));
78
+ }
79
+ /** keysByInitiative from the repository's own task ledger; an empty Map when it cannot be read. */
80
+ function readKeys(root) {
81
+ let raw = null;
82
+ try { raw = require('./task-store.js').readStore(root); } catch { raw = null; }
83
+ const lines = [];
84
+ for (const x of raw || []) { if (typeof x !== 'string') { lines.push(x); continue; } try { lines.push(JSON.parse(x)); } catch { /* a torn line */ } }
85
+ return keysByInitiative(lines);
86
+ }
87
+
88
+ /** A Jira reading as a task state. */
89
+ function stateOf(rd) {
90
+ if (!rd) return null;
91
+ const s = String(rd.status || ''), cat = String(rd.category || '').toLowerCase();
92
+ const done = cat === 'done' || /\b(done|closed|resolved|released|complete|shipped|deployed)\b/i.test(s) || CLOSED_NOT_DONE.test(s);
93
+ if (done) return CLOSED_NOT_DONE.test(s) ? "Won't do" : 'Done';
94
+ if (cat === 'doing' || cat === 'indeterminate' || /progress|doing|review|\bqa\b|test|block|started|verif|\buat\b/i.test(s)) return 'In progress';
95
+ return 'To do';
96
+ }
97
+
98
+ /**
99
+ * The task-update lines the last Jira read makes. snapOf(initiative) → { fetchedAt, tickets: Map } | null (lib/jira-status.js
100
+ * readSnapshot). Each line is { at: the read's time, by: 'tracker:jira', kind: 'task-update', task, state, why, tracker: true }.
101
+ */
102
+ function trackerLines(lines, snapOf) {
103
+ const out = []; const snaps = new Map();
104
+ const snap = (ini) => { if (!snaps.has(ini)) { let s = null; try { s = snapOf(ini) || null; } catch { s = null; } snaps.set(ini, s); } return snaps.get(ini); };
105
+ for (const t of keyedTasks(lines).values()) {
106
+ if (t.state === 'Archived') continue;
107
+ const s = snap(t.initiative);
108
+ if (!s || !s.fetchedAt || !s.tickets || !s.tickets.get) continue;
109
+ const rd = s.tickets.get(t.key);
110
+ if (!rd || rd.stale) continue;
111
+ const want = stateOf(rd);
112
+ if (!want || want === t.state) continue;
113
+ const readAt = ms(s.fetchedAt), changed = ms(t.stateAt);
114
+ if (!readAt || readAt <= changed) continue; // the PM (or an agent) changed the task after the read
115
+ if (changed) {
116
+ // someone changed the state in PMOS: Jira wins only when it moved after that (its last update or resolution), or, when the read
117
+ // carries neither time, only to close the task
118
+ const jiraAt = Math.max(ms(rd.updated), ms(rd.resolved));
119
+ const closes = want === 'Done' || want === "Won't do";
120
+ if (jiraAt ? jiraAt <= changed : !closes) continue;
121
+ }
122
+ out.push({ at: s.fetchedAt, by: BY, kind: 'task-update', task: t.task, state: want, tracker: true,
123
+ why: `Jira says ${String(rd.status || want).slice(0, 40)} (${t.key}, read ${String(s.fetchedAt).slice(0, 16).replace('T', ' ')} UTC)` });
124
+ }
125
+ return out.sort((a, b) => String(a.at).localeCompare(String(b.at)));
126
+ }
127
+
128
+ /** Whether the read `keys` rest on is stale: no read, a read older than STALE_MS, or keys the read did not return. */
129
+ function staleOf(keys, snap, now = Date.now()) {
130
+ const list = [...new Set((keys || []).filter(Boolean))];
131
+ if (!list.length) return { stale: false, since: null, keys: [] };
132
+ if (!snap || !snap.fetchedAt) return { stale: true, since: null, keys: list };
133
+ const old = now - ms(snap.fetchedAt) > STALE_MS;
134
+ const missing = list.filter((k) => { const r = snap.tickets && snap.tickets.get ? snap.tickets.get(k) : null; return !r || r.stale; });
135
+ return { stale: old || missing.length > 0, since: snap.fetchedAt, keys: old ? list : missing };
136
+ }
137
+
138
+ module.exports = { STALE_MS, BY, keyOf, keyedTasks, keysByInitiative, readKeys, stateOf, trackerLines, staleOf };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.664.0",
3
+ "version": "0.666.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.664.0",
9
+ "version": "0.666.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.664.0",
3
+ "version": "0.666.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",
@@ -45,10 +45,30 @@ button.ctp-cr:hover { text-decoration: underline; }
45
45
  .ctp-sep { color: var(--cz-ink2); }
46
46
  .ctp-th { display: flex; align-items: center; gap: var(--space-8); margin: 0 0 var(--space-12); }
47
47
  .ctp-full .ctp-t { font-size: var(--fs-panel); }
48
- .ctp-full .ctp-b, .ctp-full .ctp-hx { max-width: 720px; }
48
+ .ctp-full .ctp-hx { max-width: 720px; }
49
49
  .ctp-hx { margin: 0 0 var(--space-16); display: flex; flex-direction: column; gap: var(--space-12); }
50
50
  .ctp-hx .pwd-facts { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--space-4) var(--space-12); margin: 0; }
51
51
  .ctp-hx .pwd-facts dt { color: var(--cz-ink2); }
52
52
  .ctp-hx .pwd-facts dd { margin: 0; }
53
53
  .ctp-hx .grey { color: var(--cz-ink2); }
54
54
  .ctp-hx .warn { color: var(--cz-late); }
55
+
56
+ /* viewer-ds-task (board ViewerDS): the full popup is main + side, built from Komorebi blocks (pm/vw-ds.js); here only their places.
57
+ * With no popup behind (a task opened from Today, Events, Goals or Search) it is centred and near full (ctp-solo). */
58
+ .ctp.ctp-full.ctp-solo { left: var(--space-24); top: var(--space-24); right: var(--space-24); bottom: var(--space-24); margin: 0 auto; max-width: 1280px; }
59
+ .ctp-full .ctp-th { margin-bottom: var(--space-4); }
60
+ .ctp-meta { margin: 0 0 var(--space-16); }
61
+ .ctp-g { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: var(--space-16); align-items: start; }
62
+ .ctp-main { display: flex; flex-direction: column; gap: var(--space-16); min-width: 0; }
63
+ .ctp-main > div:empty { display: none; }
64
+ .ctp-main .ctp-hx { margin: 0; }
65
+ .ctp-say { margin: 0; }
66
+ .ctp-side { position: sticky; top: 0; min-width: 0; }
67
+ .ctp-ad { flex: none; width: 52px; }
68
+ .ctp-main .pm-li { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; text-decoration: none; cursor: pointer; }
69
+ .ctp-main .pm-li:hover { background: var(--well); }
70
+ .ctp-main div.pm-li { cursor: default; }
71
+ @media (max-width: 900px) {
72
+ .ctp-g { grid-template-columns: minmax(0, 1fr); }
73
+ .ctp-side { position: static; order: -1; }
74
+ }
@@ -18,6 +18,7 @@
18
18
  * Every write is the PM's press, on the board's own routes. The UI says PMOS, never Claude; icon-only buttons carry aria-label. */
19
19
  import { taskOf, mountCard, boardSaver, cardStyle, historyFor } from './task-card.js';
20
20
  import * as SWN from './cozy-status-when.js';
21
+ import * as VD from './vw-ds.js'; // viewer-ds-task (board ViewerDS): the full popup's Where it stands, Linked and Activity blocks
21
22
 
22
23
  const CSS = new URL('./cozy-task-pop.css', import.meta.url).href;
23
24
  if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
@@ -59,6 +60,7 @@ export function closeTask() {
59
60
  function place() {
60
61
  if (!S || !S.el.classList.contains('ctp-full')) return;
61
62
  const L = document.querySelector('.cz-pop .cz-pop-l'), r = L && L.getBoundingClientRect();
63
+ S.el.classList.toggle('ctp-solo', !r || !r.width); // no popup behind (a task opened from Today, Events, Goals or Search): centred, near full
62
64
  if (!r || !r.width) { S.el.removeAttribute('style'); return; }
63
65
  Object.assign(S.el.style, { left: r.left + 'px', top: r.top + 'px', width: r.width + 'px', height: r.height + 'px' });
64
66
  }
@@ -87,7 +89,9 @@ export async function openTask(uid, ctx = {}) {
87
89
  S = { el, scrim, ctx, uid, prevFocus: document.activeElement };
88
90
  // the full popup lies over the work side of the popup and follows its size (the chat opening beside it narrows it)
89
91
  if (ctx.full) {
90
- el.classList.add('ctp-full'); scrim.classList.add('ctp-full');
92
+ el.classList.add('ctp-full', 'pm-ds'); scrim.classList.add('ctp-full'); // pm-ds: the Komorebi parts inside (komorebi.css, loaded below)
93
+ const K = new URL('./komorebi.css', import.meta.url).href;
94
+ if (!document.querySelector(`link[href="${K}"]`) && !document.querySelector('link[href="/pm/komorebi.css"]')) { const l = document.createElement('link'); l.rel = 'stylesheet'; l.href = K; document.head.appendChild(l); }
91
95
  const L = document.querySelector('.cz-pop .cz-pop-l');
92
96
  if (L && typeof ResizeObserver !== 'undefined') { S.ro = new ResizeObserver(place); S.ro.observe(L); }
93
97
  window.addEventListener('resize', place); place();
@@ -122,14 +126,19 @@ async function show(uid) {
122
126
  const more = !t.jira ? ib('data-ctp-more aria-haspopup="menu"', 'More for this task', P.more) : '';
123
127
  S.el.setAttribute('aria-label', (t.milestone ? 'Milestone: ' : 'Task: ') + t.title);
124
128
  if (ctx.full) {
125
- // WorkStatesDS 4 and 6: ← and the path back to the initiative, then chat, ⋯ and ×; the kind and the title under it
129
+ // WorkStatesDS 4 and 6, ViewerDS: ← and the path back, the source chip, then chat, ⋯ and ×; the kind, the title and one meta line under it.
130
+ // The body is main + side (viewer-ds-task): Where it stands, Linked and Activity, beside the task card (fields and notes) in a block.
126
131
  const path = ctx.path || [], last = path.length - 1;
127
- const crumbs = path.map((p, k) => (k === last ? `<button type="button" class="ctp-cr" data-ctp-close>${esc(p)}</button>` : `<span class="ctp-cr">${esc(p)}</span>`)).join('<span class="ctp-sep" aria-hidden="true">›</span>');
132
+ // iniCrumb (a task opened from a place, not from its initiative's popup): the initiative's name opens it, and ← closes
133
+ const lastAttr = ctx.iniCrumb && t.ini ? `data-ctp-ini="${esc(t.ini)}"` : 'data-ctp-close';
134
+ const crumbs = path.map((p, k) => (k === last ? `<button type="button" class="ctp-cr" ${lastAttr}>${esc(p)}</button>` : `<span class="ctp-cr">${esc(p)}</span>`)).join('<span class="ctp-sep" aria-hidden="true">›</span>');
128
135
  const head = ctx.head ? ctx.head(t) : '';
129
- S.el.innerHTML = `<div class="ctp-h ctp-fh">${ib('data-ctp-close', 'Back to ' + (path[last] || 'the initiative'), P.back)}<nav class="ctp-path" aria-label="Where this is">${crumbs}</nav>`
136
+ const back = path.length && !ctx.iniCrumb ? 'Back to ' + path[last] : 'Close';
137
+ S.el.innerHTML = `<div class="ctp-h ctp-fh">${ib('data-ctp-close', back, P.back)}<nav class="ctp-path" aria-label="Where this is">${crumbs}${t.jira ? '<span class="pm-chip">Jira</span>' : ''}</nav>`
130
138
  + `<span class="ctp-tools">${step}${ctx.chat ? ib('data-ctp-chat', 'Ask PMOS about this', P.chat) : ''}${more}${ib('data-ctp-x', 'Close', P.x)}</span></div>`
131
- + `<div class="ctp-th">${kind}${title}</div>${head ? `<div class="ctp-hx">${head}</div>` : ''}`
132
- + '<div class="ctp-b"></div><div class="ctp-when" hidden></div>';
139
+ + `<div class="ctp-th">${kind}${title}</div><p class="pm-meta ctp-meta">${esc(VD.metaOf(t))}</p>`
140
+ + `<div class="ctp-g"><div class="ctp-main">${head ? `<div class="ctp-hx">${head}</div>` : ''}<div class="ctp-stands"></div><div class="ctp-linked"></div><div class="ctp-act"></div></div>`
141
+ + '<aside class="ctp-side"><section class="pm-block" aria-label="Fields and notes"><div class="ctp-b"></div><div class="ctp-when" hidden></div></section></aside></div>';
133
142
  } else {
134
143
  S.el.innerHTML = `<div class="ctp-h">${kind}${title}<span class="ctp-tools">${step}${more}${ib('data-ctp-close', 'Close', P.x)}</span></div>`
135
144
  + '<div class="ctp-b"></div><div class="ctp-when" hidden></div>';
@@ -143,18 +152,34 @@ async function show(uid) {
143
152
  return base(patch);
144
153
  };
145
154
  // the host's row changes at once (ctx.patch: the list behind shows the new status and dates before the board is read again)
146
- const changed = () => { raw.status = t.status; raw.end = t.due; raw.start = t.start; raw.owner = t.owner; raw.notes = t.notes; raw.milestone = t.milestone; if (ctx.patch) { try { ctx.patch(t.uid, { status: t.status, end: t.due || '', start: t.start || '', milestone: !!t.milestone, title: t.title }); } catch { /* the reload still draws it */ } } clearTimeout(changed.t); changed.t = setTimeout(() => { if (ctx.onChange) ctx.onChange(); }, 400); };
155
+ const changed = () => { raw.status = t.status; raw.end = t.due; raw.start = t.start; raw.owner = t.owner; raw.notes = t.notes; raw.milestone = t.milestone; if (ctx.patch) { try { ctx.patch(t.uid, { status: t.status, end: t.due || '', start: t.start || '', milestone: !!t.milestone, title: t.title }); } catch { /* the reload still draws it */ } } clearTimeout(changed.t); changed.t = setTimeout(() => { if (ctx.onChange) ctx.onChange(); }, 400); if (ctx.full) drawMain(); };
147
156
  const toast = (msg, undo) => (ctx.toast ? ctx.toast(msg, undo) : undefined);
157
+ S.hist = historyFor({ ws: ctx.ws, board: raw.board || ctx.board, t, post: (p, b) => ctx.pmPost(p, b) });
158
+ S.histL = null;
148
159
  S.card = mountCard(S.el.querySelector('.ctp-b'), t, {
149
160
  save, toast, changed, now: () => Date.now(),
150
161
  openIni: (id) => { closeTask(); if (ctx.openIni) ctx.openIni(id); },
151
162
  iniTitleOf: (id) => (ctx.iniTitle ? ctx.iniTitle(id) : id),
152
163
  owners: () => (ctx.owners ? ctx.owners() : []),
153
164
  inis: () => (ctx.inis ? ctx.inis() : []),
154
- history: historyFor({ ws: ctx.ws, board: raw.board || ctx.board, t, post: (p, b) => ctx.pmPost(p, b) }),
165
+ // the full popup says PMOS's changes once, in its Activity block; the small popup keeps the card's History fold
166
+ history: ctx.full ? null : S.hist,
155
167
  });
168
+ if (ctx.full) { drawMain(); loadActivity(); }
156
169
  const f = S.el.querySelector('.ctp-t') || S.el.querySelector('button'); if (f) f.focus();
157
170
  }
171
+ /* the full popup's main column (viewer-ds-task, pm/vw-ds.js): Where it stands and Linked from the task, Activity from PMOS's kept changes */
172
+ function drawMain() {
173
+ if (!S || !S.ctx.full || !S.t) return;
174
+ const put = (sel, html) => { const x = S.el.querySelector(sel); if (x) x.innerHTML = html; };
175
+ put('.ctp-stands', VD.standsHtml(S.t, { waits: S.ctx.waits ? S.ctx.waits(S.t) : '' }));
176
+ put('.ctp-linked', VD.linkedHtml(S.t));
177
+ put('.ctp-act', VD.activityHtml(S.histL || [], { open: !!S.aopen }));
178
+ }
179
+ function loadActivity() {
180
+ const s = S; if (!s || !s.hist) return;
181
+ Promise.resolve(s.hist.load()).catch(() => []).then((L) => { if (S !== s) return; s.histL = Array.isArray(L) ? L : []; drawMain(); });
182
+ }
158
183
 
159
184
  /* the card's status press waits for "When did this happen?": Today preselected, so a second press of the status or Enter keeps today */
160
185
  function holdStatus(e) {
@@ -180,8 +205,19 @@ function hideWhen() { if (!S) return; const w = S.el.querySelector('.ctp-when');
180
205
 
181
206
  async function press(e) {
182
207
  if (!S) return;
183
- const b = e.target.closest('button'); if (!b || b.disabled || !S.el.contains(b)) return;
208
+ const b = e.target.closest('button,a[data-ctp-ini]'); if (!b || b.disabled || !S.el.contains(b)) return;
184
209
  const d = b.dataset, ctx = S.ctx, t = S.t;
210
+ // the full popup's main column (viewer-ds-task): the initiative opens it; Undo a kept change; the Activity fold
211
+ if (d.ctpIni) { e.preventDefault(); const id = d.ctpIni; closeTask(); if (ctx.openIni) ctx.openIni(id); return; }
212
+ if (d.ctpHundo && S.hist) {
213
+ const s0 = S; b.disabled = true;
214
+ const r = await Promise.resolve(s0.hist.undo(d.ctpHundo)).catch(() => null);
215
+ if (!r || r.ok === false) { if (ctx.toast) ctx.toast((r && r.error) || 'The undo did not land.'); }
216
+ if (ctx.onChange) ctx.onChange();
217
+ if (S === s0) show(s0.uid); // the task as it is now, and its Activity again
218
+ return;
219
+ }
220
+ if ('ctpAfold' in d) { S.aopen = true; drawMain(); return; }
185
221
  if (b.closest('.ctp-hx')) { if (ctx.headPress) { const s0 = S; await ctx.headPress(b, { refresh: () => { if (S === s0) show(s0.uid); }, close: closeTask }); } return; }
186
222
  if ('ctpClose' in d) { closeTask(); return; }
187
223
  if ('ctpChat' in d) { if (ctx.chat) ctx.chat(); return; }
@@ -34,8 +34,38 @@ async function read(o) {
34
34
  return p;
35
35
  }
36
36
 
37
+ /* viewer-ds-task (board ViewerDS, brief: the Viewer's item as the full popup): a PMOS task opened from a place (Events, Today, Goals, Search)
38
+ * opens as the full task popup (pm/cozy-task-pop.js full mode: Where it stands, Linked and Activity beside the task card), centred when no
39
+ * popup is open. Home keeps its own Viewer trail until its own rebuild (it holds #hmChat); a Jira ticket keeps the ticket Viewer. */
40
+ const onHome = () => typeof document !== 'undefined' && !!document.getElementById('hmChat');
41
+ async function openFull(o) {
42
+ const uid = String(o.key || '').replace(/^task:/, '');
43
+ const [TP, SC] = await Promise.all([import('./cozy-task-pop.js'), import('./scope-chip.js').catch(() => null)]);
44
+ const s = await read({ id: o.ini, ws: o.ws || '', board: o.board || '' });
45
+ const m = s && s.state === 'ready' ? s.model : null;
46
+ const ws = o.ws || (m && m.board && m.board.ws) || '', board = o.board || (m && m.board && m.board.id) || '';
47
+ const row = m ? findTask(m, o.key) : null;
48
+ if (row && cardTask(m, row).jira) return false; // a Jira ticket: the ticket Viewer, as before
49
+ const product = SC && SC.productName ? SC.productName(ws, (m && m.board && m.board.name) || '') : '';
50
+ TP.openTask(uid, {
51
+ full: true, ws, board, ini: o.ini, pmPost: (p, b) => pmPost(p, b), toast: toastUndo,
52
+ path: [product, (m && m.title) || o.ini].filter(Boolean), iniCrumb: true,
53
+ iniTitle: (id) => (id === o.ini && m ? m.title : id),
54
+ row: () => (row ? { ...row, uid, board, ini: o.ini } : null),
55
+ rename: o.rename && typeof o.rename.save === 'function' ? (raw, title) => o.rename.save(title, {}) : null,
56
+ onChange: () => cache.clear(),
57
+ openIni: (id) => openWorkItem({ kind: 'initiative', id, title: id === o.ini && m ? m.title : '', ws: o.ws, board: o.board }),
58
+ chat: () => import('./page-chat.js').then((PC) => PC.openChat({ kind: 'task', id: uid, title: (row && row.title) || o.title || 'this task' }, { ws })),
59
+ });
60
+ return true;
61
+ }
62
+
37
63
  export function openWorkItem(o) {
38
64
  if (!o) return null;
65
+ if (o.kind === 'task' && /^task:/.test(o.key || '') && o.ini && !onHome() && o.full !== false) {
66
+ openFull(o).then((done) => { if (!done) openWorkItem({ ...o, full: false }); }).catch(() => openWorkItem({ ...o, full: false }));
67
+ return null;
68
+ }
39
69
  vwStyle('item');
40
70
  const ctx = { id: o.kind === 'task' ? o.ini : o.id, ws: o.ws || '', board: o.board || '' };
41
71
  if (!ctx.id) return null;
@@ -197,6 +197,11 @@ export function cardHtml(t, o = {}) {
197
197
  /** History (canvas TpA6): Claude's approved changes to the task, newest first (lib/proposals.js historyOf). Zero is silence. */
198
198
  const FIELD = { due: 'Due', status: 'Status', name: 'Name', notes: 'Notes', add: 'Added' };
199
199
  const valOf = (f, v) => (v == null || v === '' ? '—' : typeof v === 'object' ? [short(v.start), short(v.due)].filter(Boolean).join(' – ') || '—' : f === 'notes' ? 'edited' : String(v));
200
+ /** One history entry in words: { what, by, day } (the Activity block of the full task popup, pm/vw-ds.js, says it the same way). */
201
+ export function historyWords(x) {
202
+ const what = x.field === 'add' ? 'Added from ' + (x.source || 'your sources') : (FIELD[x.field] || x.field) + ': ' + valOf(x.field, x.from) + ' → ' + valOf(x.field, x.to);
203
+ return { what, by: ['PMOS, kept by you', x.why, x.field !== 'add' && x.source ? x.source : ''].filter(Boolean).join(' · '), day: short(String(x.at || '').slice(0, 10)) };
204
+ }
200
205
  export function historyHtml(hist, open, now = Date.now()) {
201
206
  const L = (hist || []).filter((x) => x && !x.undone);
202
207
  if (!L.length) return '';
@@ -0,0 +1,100 @@
1
+ /* pm/vw-ds.js — the blocks a task's full popup is built from (initiative viewer-ds-task; Exploring 3 page "pages", board ViewerDS; brief
2
+ * design-system/pages-rebuild/brief.md, Viewer: item as the full popup). Built only from PMOS Komorebi parts (workspace/design-system/ui).
3
+ * PURE: no DOM, no fetch; `now` comes in. pm/cozy-task-pop.js draws them in its full mode and wires the presses by their data- attributes.
4
+ *
5
+ * metaOf(t) → 'Task · Dina · due 24 Nov · Build' the one line under the title
6
+ * pathOf(t, o) → [crumb] product › initiative › task (the Jira key, or the task's name)
7
+ * standsOf(t, o) → [html] Where it stands, from the record only
8
+ * linkedOf(t) → [{ kind, title, sub, href?, act? }] the initiative, the Jira ticket, each link in the notes
9
+ * standsHtml · linkedHtml · activityHtml(hist, o) the three main-column blocks
10
+ *
11
+ * NOTHING HERE MAKES A FACT UP. A task with no due date says so; a task nobody has says so; zero is silence (no link, no Linked block). */
12
+ import { historyWords } from './task-card.js';
13
+
14
+ export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[c]);
15
+ const SV = (d, n = 16, cls = '') => `<svg class="pm-ic${cls ? ' ' + cls : ''}" width="${n}" height="${n}" viewBox="0 0 24 24" aria-hidden="true"><path d="${d}"/></svg>`;
16
+ export const I = {
17
+ star: 'M12 3l1.8 5.4L19 10.2l-5.2 1.8L12 17.4l-1.8-5.4L5 10.2l5.2-1.8z', 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',
18
+ ini: 'M8 6h12M8 12h12M8 18h12M4 6h.01M4 12h.01M4 18h.01', jira: 'M12 3l9 9-9 9-9-9z', undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', chev: 'M9 6l6 6-6 6',
19
+ };
20
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
21
+ const DAY = 864e5;
22
+ 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; };
23
+ const today = (now) => { const d = new Date(now); return Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()); };
24
+ export const dm = (v) => { const t = day(v); if (t == null) return ''; const d = new Date(t); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()]; };
25
+ const days = (n) => n + (n === 1 ? ' day' : ' days');
26
+ const done = (t) => /^(done|closed|resolved|won'?t do|archived)$/i.test(String(t.status || ''));
27
+ /** "pm:wawan" is the PM: "You". */
28
+ const who = (o) => (/^pm:/.test(String(o || '')) ? 'You' : String(o || '').trim());
29
+
30
+ export function metaOf(t) {
31
+ const d = t.due ? 'due ' + dm(t.due) : '', w = who(t.owner);
32
+ return [t.milestone ? 'Milestone' : 'Task', w, d, t.section || ''].filter(Boolean).join(' · ');
33
+ }
34
+ export function pathOf(t, o = {}) {
35
+ return [o.product || '', t.iniTitle || t.ini || '', t.jira ? t.jira.key : ''].filter(Boolean);
36
+ }
37
+
38
+ /* ── Where it stands ──────────────────────────────────────────────────────────────────────────────────────────── */
39
+ export function standsOf(t, o = {}) {
40
+ const now = o.now == null ? Date.now() : o.now, out = [], T = today(now), w = who(t.owner);
41
+ if (done(t)) out.push(`It is ${esc(String(t.status).toLowerCase())}.`);
42
+ else {
43
+ const d = day(t.due), st = String(t.status || 'To do');
44
+ const holder = w ? (w === 'You' ? 'You have it' : `${esc(w)} has it`) : 'Nobody has it yet';
45
+ out.push(`${holder}, and it is ${esc(st.toLowerCase())}.`);
46
+ if (d == null) out.push('It has no due date yet, so nothing shows when it will finish.');
47
+ else {
48
+ const n = Math.round((d - T) / DAY);
49
+ out.push(n < 0 ? `It was due ${esc(dm(t.due))} and is ${days(-n)} late.` : n === 0 ? 'It is due today.' : n === 1 ? `It is due tomorrow, ${esc(dm(t.due))}.` : `It is due ${esc(dm(t.due))}, in ${days(n)}.`);
50
+ }
51
+ if (o.waits) out.push(`It waits on you: ${esc(String(o.waits).replace(/\.$/, ''))}.`);
52
+ }
53
+ if (t.ini) out.push(`It ${t.milestone ? 'is a milestone of' : 'moves'} <a href="#" data-ctp-ini="${esc(t.ini)}">${esc(t.iniTitle || t.ini)}</a>${t.section ? `, in its ${esc(t.section)} stage` : ''}.`);
54
+ return out;
55
+ }
56
+ export function standsHtml(t, o = {}) {
57
+ const S = standsOf(t, o);
58
+ if (!S.length && !o.sug) return '';
59
+ return `<section class="pm-block" aria-label="Where it stands"><h3 class="pm-h-sm pm-row">${SV(I.star, 16, 'pm-star')}Where it stands</h3>`
60
+ + (S.length ? `<p class="ctp-say">${S.join(' ')}</p>` : '') + (o.sug || '') + '</section>';
61
+ }
62
+
63
+ /* ── Linked ───────────────────────────────────────────────────────────────────────────────────────────────────── */
64
+ const URL_RE = /\bhttps?:\/\/[^\s<>"')\]]+/g;
65
+ const shortUrl = (u) => { try { const x = new URL(u); const p = x.pathname.replace(/\/$/, ''); return x.host.replace(/^www\./, '') + (p.length > 32 ? p.slice(0, 31) + '…' : p); } catch { return u.slice(0, 48); } };
66
+ export function linkedOf(t) {
67
+ const out = [];
68
+ if (t.ini) out.push({ kind: 'ini', title: t.iniTitle || t.ini, sub: 'initiative', act: t.ini });
69
+ if (t.jira && t.jira.key) out.push({ kind: 'jira', title: t.jira.key, sub: 'Jira ticket' + (t.jira.readAt ? ' · read ' + dm(t.jira.readAt) : '') });
70
+ const seen = new Set();
71
+ for (const u of String(t.notes || '').match(URL_RE) || []) { if (seen.has(u) || seen.size >= 5) continue; seen.add(u); out.push({ kind: 'url', title: shortUrl(u), sub: 'link in the notes', href: u }); }
72
+ return out;
73
+ }
74
+ export function linkedHtml(t) {
75
+ const L = linkedOf(t);
76
+ if (!L.length) return '';
77
+ const icon = (k) => SV(k === 'ini' ? I.ini : k === 'jira' ? I.jira : I.link);
78
+ const row = (x) => {
79
+ const inner = `${icon(x.kind)}<span class="txt"><span class="t">${esc(x.title)}</span><span class="w">${esc(x.sub)}</span></span>`;
80
+ return x.href ? `<a class="pm-li" href="${esc(x.href)}" target="_blank" rel="noopener">${inner}</a>`
81
+ : x.act ? `<button type="button" class="pm-li" data-ctp-ini="${esc(x.act)}">${inner}</button>` : `<div class="pm-li">${inner}</div>`;
82
+ };
83
+ return `<section class="pm-block list" aria-label="Linked"><div class="head"><h3 class="pm-h-sm">Linked</h3><span class="pm-meta">${L.length}</span></div><div class="rows">${L.map(row).join('')}</div></section>`;
84
+ }
85
+
86
+ /* ── Activity: PMOS's kept changes, newest first ──────────────────────────────────────────────────────────────── */
87
+ /** hist: GET /api/proposals/history entries (task-card.js historyFor). o: { now, open: the fold is open, first: rows before the fold (3) }. */
88
+ export function activityHtml(hist, o = {}) {
89
+ const now = o.now == null ? Date.now() : o.now, first = o.first || 3;
90
+ const L = (hist || []).filter((x) => x && !x.undone);
91
+ if (!L.length) return '';
92
+ const row = (x) => {
93
+ const w = historyWords(x), recent = now - (Date.parse(x.at) || 0) < 7 * DAY;
94
+ return `<div class="pm-li"><span class="code pm-meta ctp-ad">${esc(w.day)}</span><span class="txt"><span class="t">${esc(w.what)}</span><span class="w">${esc(w.by)}</span></span>`
95
+ + (recent && x.batch ? `<button type="button" class="pm-btn" data-ctp-hundo="${esc(x.batch)}" aria-label="Undo this change" title="Undo">${SV(I.undo)}</button>` : '') + '</div>';
96
+ };
97
+ const shown = o.open ? L : L.slice(0, first), rest = L.length - shown.length;
98
+ return `<section class="pm-block list" aria-label="Activity"><div class="head"><h3 class="pm-h-sm">Activity</h3></div><div class="rows">${shown.map(row).join('')}</div>`
99
+ + (rest > 0 ? `<button type="button" class="pm-fold" data-ctp-afold aria-expanded="false">Earlier <span class="pm-meta">${rest}</span></button>` : '') + '</section>';
100
+ }
@@ -24,7 +24,7 @@ Rules that always hold:
24
24
  Procedure:
25
25
  0. Ask first, when the task names no initiative. Run `pmos refresh since jira`. If it says "read in full", go to step 1. If it says "ask first", note the number of minutes it prints. Run `pmos jira query` and `pmos jira query --sprints`, and run each search they print with ` AND updated >= -<minutes>m` added (put the search in brackets first), asking only for the key field and one result. If no search returns an issue, run `pmos refresh same jira`, finish with "Checked: no change in Jira in the last <minutes> minutes", and stop. If any search returns an issue, or a search fails, go to step 1 and read in full.
26
26
  0a. One sprint, when the task names it ("This check: sprint …"): the PM asked PMOS to read a closed sprint it never saw. Run `pmos jira query --sprint "<the sprint's name>"`, run that search with the fields of step 2, fetch every page, save the result in the scratch folder in the shape of step 3, run `pmos jira sync --sprint "<the sprint's name>" --from <the file>`, finish with "Checked: <the sprint's name>, <N> tickets kept", and stop. Do nothing else in that run.
27
- 1. If the task names one initiative ("This check: initiative …"), check that one only: run `pmos jira query <initiative>`. Otherwise run `pmos jira query`: each line is an initiative id, a tab and the Jira search (JQL) to run for it. An initiative PMOS pushed no ticket for, but which is linked to Jira epics, gets a search for those epics and the issues under them. If no initiative has a ticket or an epic in Jira, say so in one line and stop.
27
+ 1. If the task names one initiative ("This check: initiative …"), check that one only: run `pmos jira query <initiative>`. Otherwise run `pmos jira query`: each line is an initiative id, a tab and the Jira search (JQL) to run for it. An initiative PMOS pushed no ticket for, but which is linked to Jira epics, gets a search for those epics and the issues under them. An initiative whose tasks start with a Jira key (tasks imported from Jira, such as "IDPF-2746 · Send verification email") gets those tickets in its search too: PMOS sets each task's state from what you read. If no initiative has a ticket or an epic in Jira, say so in one line and stop.
28
28
  2. For each initiative, run its search with the Jira search tool and the fields in rule 3, at most 50 issues per page. The sprint is a custom field named "Sprint" whose id differs per site (often `customfield_10020`, on some sites `customfield_10004`). If the first page comes back with no Sprint field, ask once for every field of one issue (`*all`), find the field whose value is a list of sprints (each with a name and a state), and ask for that id from then on. Story points are also a custom field, named "Story Points" or "Story point estimate" (often `customfield_10016`); ask for it by name. Fetch every page.
29
29
  3. Save the result as JSON in the scratch folder, for example `<scratch>/jira-<initiative>.json`, as a list with one object per issue:
30
30
  `{"key", "summary", "status", "category", "type", "parent", "sprint", "subtasks", "points", "resolved", "flagged", "reason", "url"}`
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "A task opened from a place as the full popup from design system blocks (initiative viewer-ds-task, done test C1-C7): pm/vw-ds.js, pm/cozy-task-pop.js full mode, pm/premium-vw-item.js opener. Pure, node.",
3
+ "modules": [
4
+ "vw-ds.test.js"
5
+ ],
6
+ "seconds": {
7
+ "vw-ds.test.js": 2
8
+ }
9
+ }