create-pmos 0.312.0 → 0.313.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.312.0",
3
+ "version": "0.313.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": {
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@aa213c1
1
+ kernel-source: pmos@36b0e23
2
2
  assembled: 2026-10-19
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-10-19T13:02:02Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T13:24:33Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Health budgets"
4
4
  description: "Closed registry of health-budget anchors (D59), edited only by the PM."
5
- generated: {by: process:create-pmos, at: "2026-10-19T13:02:02Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T13:24:33Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -2,7 +2,7 @@
2
2
  type: Reference
3
3
  title: "Discoveries and friction log"
4
4
  description: "Append-only record of what runs discovered and where the process rubbed."
5
- generated: {by: process:create-pmos, at: "2026-10-19T13:02:02Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-19T13:24:33Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -70,6 +70,10 @@ const product = (name, cond) => {
70
70
  ok('P1 the two rows share an id and differ in workspace', m0 && new Set(m0.model.list.rows.map((r) => r.key)).size === 2 && m0.model.list.rows.every((r) => /^decision:KC9:/.test(r.key)));
71
71
 
72
72
  browser = await chromium.launch({ executablePath: exe });
73
+ { /* this suite checks the records-only rows: the console's Needs you read (premium-brief.js), which replaces them when it answers, is off */
74
+ const nc = browser.newContext.bind(browser);
75
+ browser.newContext = async (...args) => { const c = await nc(...args); await c.route('**/api/brief-page*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'off in this suite' }) })); return c; };
76
+ }
73
77
  const open = async ({ w = 1280, h = 900, theme = 'light', q = '' } = {}) => {
74
78
  const ctx = await browser.newContext({ viewport: { width: w, height: h } });
75
79
  await ctx.addInitScript((t) => { try { localStorage.setItem('pmos.premium.theme', t); } catch { /* none */ } }, theme);
@@ -77,6 +77,10 @@ const sh = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
77
77
  ok('S8 the header no longer says there is no brief', !/no morning brief/.test(m1.header.text), m1.header.text);
78
78
 
79
79
  browser = await chromium.launch({ executablePath: exe });
80
+ { /* this suite checks the records-only rows: the console's Needs you read (premium-brief.js), which replaces them when it answers, is off */
81
+ const nc = browser.newContext.bind(browser);
82
+ browser.newContext = async (...args) => { const c = await nc(...args); await c.route('**/api/brief-page*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'off in this suite' }) })); return c; };
83
+ }
80
84
  const open = async ({ w = 1280, h = 900, theme = 'light' } = {}) => {
81
85
  const ctx = await browser.newContext({ viewport: { width: w, height: h } });
82
86
  const page = await ctx.newPage(); const errors = [];
@@ -51,14 +51,22 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
51
51
  srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
52
52
  await T.waitForServer(BASE);
53
53
  browser = await chromium.launch({ executablePath: exe });
54
+ { /* every context starts with the console's Needs you read off (see open below); a page route set by `console` wins over it */
55
+ const nc = browser.newContext.bind(browser);
56
+ browser.newContext = async (...args) => { const c = await nc(...args); await c.route('**/api/brief-page*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: false, error: 'off in this suite' }) })); return c; };
57
+ }
54
58
 
55
- const open = async ({ w = 1280, h = 900, theme = 'light', model = MODEL, ctxOpts = {}, pre = null } = {}) => {
59
+ /* The console's Needs you reads (premium-brief.js): off by default, so the page keeps the model's records-only hero and rows, which most of
60
+ * this suite checks. `console` stubs them: { briefing, page, agent }; the C block checks that path. */
61
+ const open = async ({ w = 1280, h = 900, theme = 'light', model = MODEL, ctxOpts = {}, pre = null, console: cn = null } = {}) => {
56
62
  const ctx = await browser.newContext({ viewport: { width: w, height: h }, ...ctxOpts });
57
63
  const page = await ctx.newPage();
58
64
  const errors = [], reqs = [];
59
65
  page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
60
66
  page.on('request', (r) => { if (r.url().startsWith(BASE)) reqs.push(r.method() + ' ' + new URL(r.url()).pathname); });
61
67
  await page.route('**/api/briefing-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model, as_of: Date.now() }) }));
68
+ const json = (body) => (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(body) });
69
+ if (cn) { await page.route('**/api/brief-page*', json(cn.page)); await page.route('**/api/briefing', json(cn.briefing)); await page.route('**/api/needs?*', json({ needs: cn.agent || [] })); }
62
70
  if (pre) await page.addInitScript(pre);
63
71
  await page.goto(BASE + '/premium.html?theme=' + theme);
64
72
  const up = await until(() => page.evaluate(() => document.querySelectorAll('#rank .rr').length > 0 || !document.querySelector('#calm').hidden), 20000);
@@ -168,12 +176,11 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
168
176
  await p.keyboard.press('Escape'); await p.unroute('**/api/sessions'); await p.unroute('**/api/session/remove');
169
177
  for (let i = A.reqs.length - 1; i >= 0; i--) if (/^POST \/api\/(session\/remove|runs\/answer)$/.test(A.reqs[i])) A.reqs.splice(i, 1); }
170
178
 
171
- /* R2: the hero is the console's The brief (premium-brief.js) once its reads come back; the same composer gives the same words */
172
- await until(() => p.evaluate(() => /^The same paragraph as The brief/.test(document.querySelector('#brief').title || '')));
179
+ /* R2: with the console reads off, the hero is the model's records-only sentences */
173
180
  const hero = await p.evaluate(() => ({ text: document.querySelector('#brief').textContent, k: [...document.querySelectorAll('#brief .k')].map((x) => x.textContent) }));
174
- const want = await p.evaluate(() => import('/pm/premium-brief.js').then((m) => m.consoleBrief()).then((r) => (r ? r.parts.map((x) => x.t).join('') : null)));
175
- ok('R2 the hero reads the console brief, word for word', !!want && hero.text === want, hero.text + ' | ' + want);
176
- ok('R2 the hero is not the records-only sentences', hero.text !== MODEL.hero.map((s) => s.parts.map((x) => x.t).join('')).join(' '), hero.text);
181
+ const want = MODEL.hero.map((s) => s.parts.map((x) => x.t).join('')).join(' ');
182
+ ok('R2 the hero reads the model, word for word, while the console reads fail', hero.text === want, hero.text);
183
+ ok('R2 the numbers and the stuck items are marked', hero.k.some((t) => /three changes today/.test(t)) && hero.k.some((t) => /20 to 10 per 100 runs/.test(t)) && hero.k.length >= 5, JSON.stringify(hero.k));
177
184
  ok('R2 the date line is the model\'s', await p.evaluate((d) => document.querySelector('#date').textContent === d, MODEL.date));
178
185
 
179
186
  /* R3, R4 */
@@ -472,6 +479,37 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
472
479
  await E.ctx.close();
473
480
  }
474
481
 
482
+ /* C: the console's Needs you, read the way the console reads it, is the hero and the list (premium-brief.js) */
483
+ {
484
+ const CN = {
485
+ briefing: { cards: [], needs: [{ key: 'mw:J-7', itemId: 'J-7', origin: 'jira', kind: 'Decide', headline: 'Pick the launch market', time: null, dueText: null, src: 'J-7', why: 'Assigned to you as a decision.', facts: [{ text: 'J-7 · In progress', source: 'Jira' }], url: 'https://example.atlassian.net/browse/J-7', url_label: 'Open J-7 in Jira' }] },
486
+ page: { ok: true, today: [], mentions: null, needs: [{ key: 'item:w1', id: 'w1', kind: 'overdue', headline: 'Send Priya the date', days_late: 3, person: 'Priya' }] },
487
+ agent: [{ run_id: 'run-9', kind: 'driver-drafts', question: 'Agent has 2 drafts on Checkout', initiative_id: 'checkout', ws: 'w0' }],
488
+ };
489
+ const C = await open({ console: CN });
490
+ const cp = C.page;
491
+ await until(() => cp.evaluate(() => document.querySelectorAll('#rank .rr').length === 3 && /^The same paragraph as The brief/.test(document.querySelector('#brief').title || '')));
492
+ const want = await cp.evaluate(() => import('/pm/premium-brief.js').then((m) => m.consoleReads().then((r) => ({ brief: m.briefOf(r).parts.map((x) => x.t).join(''), titles: m.needsListOf(r).map((x) => x.title) }))));
493
+ const got = await cp.evaluate(() => ({ brief: document.querySelector('#brief').textContent, titles: [...document.querySelectorAll('#rank .rr .rt')].map((t) => t.childNodes[0].textContent), skip: document.querySelectorAll('#rank .rr .skip').length, cap: document.querySelector('#movesCap').textContent, dn: document.querySelector('#dN').textContent, bell: document.querySelector('#pvBdg').textContent, links: document.querySelectorAll('#rank .rr[data-link]').length }));
494
+ ok('C1 the hero is the console brief, word for word', got.brief === want.brief && /3 things need you/.test(got.brief), got.brief);
495
+ ok('C2 the list is the console\'s Needs you, in its order', got.titles.join('|') === want.titles.join('|') && got.titles.length === 3, JSON.stringify(got.titles));
496
+ ok('C3 a console row has no "If you skip" line and no meeting link: no record holds them', got.skip === 0 && got.links === 0, JSON.stringify(got));
497
+ ok('C4 the header, the dock and the bell count the same three rows', /3 rows left/.test(got.cap) && got.dn === '3' && got.bell === '3', JSON.stringify(got));
498
+ const dec = await cp.evaluate(() => [...document.querySelectorAll('#rank .rr')].findIndex((r) => /Pick the launch market/.test(r.textContent)));
499
+ await cp.locator('#rank .rr .rhd').nth(dec).click();
500
+ await until(() => cp.evaluate(() => document.querySelector('#dlg').classList.contains('on')));
501
+ const dd = await cp.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, body: document.querySelector('#dBody').textContent, ask: document.querySelector('#askF').hidden, link: (document.querySelector('#srcLink') || {}).href || '' }));
502
+ ok('C5 a decision opens the dialog with what its record says and its source link, and no agent box', dd.title === 'Pick the launch market' && /Read from the console Briefing/.test(dd.body) && dd.ask && /J-7/.test(dd.link), JSON.stringify(dd));
503
+ await cp.keyboard.press('Escape');
504
+ await cp.route('**/premium-work.html*', (r) => r.fulfill({ contentType: 'text/html', body: '<p>work</p>' }));
505
+ const own = await cp.evaluate(() => [...document.querySelectorAll('#rank .rr')].findIndex((r) => /Send Priya the date/.test(r.textContent)));
506
+ await cp.locator('#rank .rr .rhd').nth(own).click();
507
+ await until(() => cp.evaluate(() => /premium-work\.html/.test(location.pathname)));
508
+ ok('C6 your own item opens on My work, on that item', await cp.evaluate(() => location.pathname === '/premium-work.html' && new URLSearchParams(location.search).get('item') === 'w1'), await cp.evaluate(() => location.href));
509
+ ok('C7 no page error on the console path', C.errors.length === 0, C.errors.join(' | '));
510
+ await C.ctx.close();
511
+ }
512
+
475
513
  /* R8, R11 the dock folds in on scroll, and is not reachable before it shows */
476
514
  await p.evaluate(() => window.scrollTo(0, 0));
477
515
  await until(() => p.evaluate(() => !document.body.classList.contains('docked')));
@@ -88,6 +88,8 @@ A part with no record is left out. With nothing to say, the hero says so.
88
88
 
89
89
  ## What you need to do
90
90
 
91
+ The list is the console's **Needs you**: the same rows, in the same order, from the same reads. A decision opens here, with what its record says and a link to its source. Choose its option on the console Briefing. Your own item opens on My work, on that item. An agent row opens its initiative. These rows have no "If you skip" line and no link to a meeting, because no record holds them. The header, the dock and the bell count the same rows. If the console reads fail, the page shows the records-only rows below instead.
92
+
91
93
  Each row is a thing that waits for you. The order is fixed: blocked work first, then decisions only you can make, then what has waited longest. The first row is tagged "Do this first".
92
94
 
93
95
  A row has a verb-first title, the subject, what the repository says is next, and "If you skip", which says what stays blocked. Press a row to open it. Detail opens first, and the conversation sits beside it. On a phone, the Detail tab is first.
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.312.0",
3
+ "version": "0.313.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.312.0",
9
+ "version": "0.313.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.312.0",
3
+ "version": "0.313.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",
@@ -3,6 +3,7 @@
3
3
  * consoleBrief(now?) → Promise of { parts: [{ t, go? }], sources } | null reads what the console Briefing reads, composes with composeBrief
4
4
  * briefNeeds(b, page, agent) → { decisions, own, agentN } PURE. The rows the console's Needs you holds, in its ranked order (c3-brief-needs.js)
5
5
  * briefInputOf(...) → the composeBrief input PURE
6
+ * needsListOf(reads, ws) → the rows of "What you need to do", one per console Needs you row, in its order PURE
6
7
  * The same five reads, the same row rules and the same composer as the console: GET /api/briefing, GET /api/brief-page, GET /api/needs (agent drafts),
7
8
  * the calendar quarter, and the day part of the clock. A read that fails leaves its sentence out. null when the needs reads failed, so the page keeps
8
9
  * its own records-only hero rather than guess. No write, no model call. */
@@ -37,7 +38,39 @@ export function briefNeeds(b, page, agent) {
37
38
  const ordered = [...R.first, ...R.rest].filter((r) => !(R.byKey.get(r.key) || {}).members).map((r) => byKey.get(r.key)).filter(Boolean);
38
39
  const decisions = ordered.filter((x) => x.src === 'decision').map((x) => { const m = meta.get(String(x.raw.key)) || {}; return { key: String(x.raw.key), headline: x.raw.headline || '', time: m.time || null, decide: !!m.decide, overdue: !!m.overdue, days_late: m.days_late || 0 }; });
39
40
  const own = ordered.filter((x) => x.src === 'own').map((x) => ({ key: String(x.raw.key), headline: x.raw.headline || '', kind: x.raw.kind, days_late: x.raw.days_late || 0 }));
40
- return { decisions, own, agentN: ordered.filter((x) => x.src === 'agent').length };
41
+ return { decisions, own, agentN: ordered.filter((x) => x.src === 'agent').length, ordered };
42
+ }
43
+
44
+ const lateWord = (d) => (d === 1 ? '1 day late' : d + ' days late');
45
+ const factText = (f) => (f && typeof f === 'object' ? f.text : f);
46
+ /** One row of "What you need to do" from one row of the console's Needs you. A row says only what the console row's own data says:
47
+ * no "If you skip" line (no record holds one). go: where a press goes, the item's own page; null opens the Briefing's dialog. */
48
+ export function needsRowOf(x, ws) {
49
+ const r = x.raw, q = (k, v) => k + '=' + encodeURIComponent(v);
50
+ if (x.src === 'own') {
51
+ const when = r.kind === 'overdue' ? lateWord(Math.max(1, Number(r.days_late) || 1)) : r.kind === 'due-today' ? 'Due today' : r.offline ? 'Outside PMOS' : '';
52
+ return { key: 'own:' + r.key, src: 'own', title: r.headline || '', subject: ['Yours', when, r.person ? 'with ' + r.person : ''].filter(Boolean).join(' · '),
53
+ prepared: r.evidence && r.evidence.text ? 'Looks done: ' + r.evidence.text + '. Confirm it in My work.' : 'Open it in My work to mark it done, put it off or drop it.',
54
+ go: r.id ? '/premium-work.html?' + [q('item', r.id), ws ? q('ws', ws) : ''].filter(Boolean).join('&') : null };
55
+ }
56
+ if (x.src === 'agent') {
57
+ const blocked = r.kind === 'driver-blocked', ini = r.initiative_id || '';
58
+ return { key: 'agent:' + r.run_id, src: 'agent', title: r.question || '', subject: ['From the agent', blocked ? 'waiting on you' : 'drafts to review', ini].filter(Boolean).join(' · '),
59
+ prepared: blocked ? 'The agent will not go on until you decide.' : r.kind === 'core-doc-drafts' ? 'Review each draft, then issue it.' : 'Keep, send back or drop each draft.',
60
+ go: ini ? '/premium-initiative.html?' + [q('id', ini), r.ws ? q('ws', r.ws) : ''].filter(Boolean).join('&') : '/console.html' };
61
+ }
62
+ const v = r.view || null;
63
+ const facts = v ? v.facts : (r.facts || []).map(factText).filter(Boolean);
64
+ const say = (v ? v.why : r.why) || '';
65
+ return { key: 'dec:' + r.key, src: 'decision', title: r.headline || '', subject: [v ? v.tag : r.kind, r.dueText || (v && v.deadline && v.deadline.text) || r.time || '', r.src && r.src !== (v && v.tag) ? r.src : ''].filter(Boolean).join(' · '),
66
+ prepared: say || facts[0] || '', facts, options: v ? v.options.map((o) => o.label) : [], url: (v ? v.url : r.url) || null, urlLabel: (v ? v.urlLabel : r.url_label) || null, go: null };
67
+ }
68
+
69
+ /** "What you need to do" in the console's Needs you order. null when the needs reads failed. */
70
+ export function needsListOf({ b, page, agent }, ws) {
71
+ if (!page || page.ok === false) return null;
72
+ const { ordered } = briefNeeds(b, page, agent);
73
+ return ordered.map((x) => needsRowOf(x, ws));
41
74
  }
42
75
 
43
76
  export function briefInputOf({ b, page, agent, quarter, now }) {
@@ -48,9 +81,17 @@ export function briefInputOf({ b, page, agent, quarter, now }) {
48
81
  pulse: quarter && quarter.ok !== false ? pulseRows(quarter.gantt) : null };
49
82
  }
50
83
 
51
- export async function consoleBrief(now) {
84
+ /** The console Briefing's reads, once. */
85
+ export async function consoleReads() {
52
86
  const [b, page, agent, quarter] = await Promise.all([loadBriefing(true), loadBriefPage(), loadDriverNeeds().catch(() => []), readQuarter().catch(() => null)]);
87
+ return { b, page, agent, quarter };
88
+ }
89
+
90
+ export function briefOf(reads, now) {
91
+ const { page } = reads;
53
92
  if (!page || page.ok === false) return null; // the needs reads failed: keep the records-only hero rather than half a brief
54
- const r = composeBrief(briefInputOf({ b, page, agent, quarter, now }));
93
+ const r = composeBrief(briefInputOf({ ...reads, now }));
55
94
  return r.parts.length ? r : null;
56
95
  }
96
+
97
+ export async function consoleBrief(now) { return briefOf(await consoleReads(), now); }
@@ -637,6 +637,13 @@ $('#cap').addEventListener('submit', async (e) => {
637
637
  });
638
638
 
639
639
  /* ── load ────────────────────────────────────────────────────────────────────────────────────────────────── */
640
+ /* ?item=<id> (a row of the Briefing's "What you need to do"): open that item's dialog once, after the first read. */
641
+ let ASKED = new URLSearchParams(location.search).get('item');
642
+ function openAsked() {
643
+ if (!ASKED) return;
644
+ const r = rowOf('work:' + ASKED); ASKED = null;
645
+ if (r) openRow(r); else toast('That item is not on your list any more.');
646
+ }
640
647
  async function load() {
641
648
  let r = null, status = 0;
642
649
  try { const res = await fetch('/api/my-work-premium', { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
@@ -646,6 +653,7 @@ async function load() {
646
653
  return;
647
654
  }
648
655
  M = r.model; draw();
656
+ openAsked();
649
657
  if (!WK) readWk();
650
658
  const mine = dlgOpen() && ((dlgKind === 'item' && openR && S.key === openR.key) || (dlgKind === 'fjobs' && S.key === 'focus:today'));
651
659
  if (mine && dlgKind === 'item') refreshOpen(); else if (mine) drawFocusDlg();
@@ -7,7 +7,7 @@ import { startAgent } from './page-agent.js';
7
7
  import { mountMeeting } from './premium-meeting.js';
8
8
  import { mountFirst } from './premium-first.js';
9
9
  import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
10
- import { consoleBrief } from './premium-brief.js';
10
+ import { consoleReads, briefOf, needsListOf } from './premium-brief.js';
11
11
  import { momentOf, inText } from './c3-phone-model.js';
12
12
  import { $, $$, esc, store, THEME_KEY, RM, AI, S, theme, toast, kv, H, openDlg, closeDlg, setTab, setMode, CHECK, CHEV, ptx, turnA, turnU, H1, H2, P1, UL, logHtml, loadThread, onScroll, wireRail, pvFeed } from './premium-shell.js';
13
13
  const ICON = {
@@ -39,10 +39,17 @@ function baseline(keys) {
39
39
  /* The headline is the console's "The brief", from the same reads and the same composer (premium-brief.js). Until it comes back, or when its reads fail, the
40
40
  * records-only sentences above stay. Each draw asks again; a late answer to an older ask is dropped. */
41
41
  let briefAsk = 0, shownBrief = null; // once the console brief is shown, a re-read keeps it on screen until the next answer: the hero does not flip back
42
+ /* "What you need to do" is the console's Needs you, from the same reads (premium-brief.js needsListOf). null until they come back, and while the
43
+ * needs reads fail: the records-only rows of the model stay. */
44
+ let CL = null;
42
45
  function drawConsoleBrief() {
43
46
  const ask = ++briefAsk;
44
- consoleBrief().then((r) => {
45
- if (ask !== briefAsk || !r) return;
47
+ consoleReads().then((reads) => {
48
+ if (ask !== briefAsk) return;
49
+ const list = needsListOf(reads, new URLSearchParams(location.search).get('ws'));
50
+ if (list) { CL = list; drawRows(); drawDock(); pvFeed({ ok: true, model: { list: LIST() } }); }
51
+ const r = briefOf(reads);
52
+ if (!r) return;
46
53
  shownBrief = r.parts.map((p) => (p.go ? `<span class="k">${esc(p.t)}</span>` : esc(p.t))).join('');
47
54
  if ($('#brief').innerHTML !== shownBrief) { $('#brief').innerHTML = shownBrief; onScroll(); }
48
55
  $('#brief').title = 'The same paragraph as The brief on the console Briefing. Read from: ' + r.sources.join(', ') + '.';
@@ -58,21 +65,28 @@ function drawHero() {
58
65
 
59
66
  /* ── rows ───────────────────────────────────────────────────────────────────────────────────────────────── */
60
67
  const STAMP = (n) => String(n).padStart(2, '0');
68
+ const CL_ORDER = 'In the order of Needs you on the console: what cannot wait first, then by impact, urgency and effort.';
69
+ /** The list the page draws: the console's Needs you once it is read, else the model's records-only rows. */
70
+ function LIST() {
71
+ if (!CL) return M.list;
72
+ return { rows: CL.map((r, i) => ({ ...r, n: i + 1 })), count: CL.length, more: 0, putOff: [], order: CL_ORDER, pendingNote: '' };
73
+ }
61
74
  function drawRows() {
62
- const rows = M.list.rows, L = $('#rank');
63
- const keys = rows.map((r) => r.key), off = (M.list.putOff || []).map((x) => x.key); // a row put off is not done: it leaves both counts and is named below the list
64
- const base = (M.pending ? keys : baseline(keys)).filter((k) => !off.includes(k)), done = base.filter((k) => !keys.includes(k)).length, total = base.length;
75
+ const LS = LIST(), pend = M.pending && !CL;
76
+ const rows = LS.rows, L = $('#rank');
77
+ const keys = rows.map((r) => r.key), off = (LS.putOff || []).map((x) => x.key); // a row put off is not done: it leaves both counts and is named below the list
78
+ const base = (pend ? keys : baseline(keys)).filter((k) => !off.includes(k)), done = base.filter((k) => !keys.includes(k)).length, total = base.length;
65
79
  const order = rows.slice().sort((a, b) => (pinned.has(b.key) - pinned.has(a.key)) || (a.n - b.n));
66
- L.innerHTML = order.map((r, i) => `<div class="rr${i < 3 ? ' lead' : ''}${i === 0 ? ' first' : ''}" data-key="${esc(r.key)}"${linkOf(r) ? ` data-link="${esc(linkOf(r))}"` : ''}><button class="rhd" aria-haspopup="dialog"><span class="rn">${STAMP(i + 1)}</span><span><span class="rt">${esc(r.title)}${i === 0 ? '<em class="tgf">Do this first</em>' : ''}</span><span class="rs">${r.product ? `<b class="pn">${esc(r.product)}</b>` : ''}${esc(r.subject)}</span><span class="sug"><span>${esc(r.prepared)}</span></span><span class="skip">${esc(r.skip)}</span></span></button><button class="rpin" data-pin="${esc(r.key)}" aria-pressed="${pinned.has(r.key)}" aria-label="Pin ${esc(r.title)} to the top" title="Pin to the top"><svg class="i" viewBox="0 0 24 24"><path d="M9 4h6l-1 6 3 3H7l3-3zM12 13v7"/></svg></button></div>`).join('')
67
- + (M.list.more ? `<p class="note">${M.list.more} more ${M.list.more === 1 ? 'row is' : 'rows are'} not shown here.</p>` : '');
68
- const n = M.list.count;
69
- $('#movesCap').innerHTML = M.pending ? `${n} ${n === 1 ? 'row' : 'rows'} so far · still reading` : n ? `<b>${done} of ${total}</b> done · ${n} ${n === 1 ? 'row' : 'rows'} left` : 'All clear';
80
+ L.innerHTML = order.map((r, i) => `<div class="rr${i < 3 ? ' lead' : ''}${i === 0 ? ' first' : ''}" data-key="${esc(r.key)}"${linkOf(r) ? ` data-link="${esc(linkOf(r))}"` : ''}><button class="rhd" aria-haspopup="dialog"><span class="rn">${STAMP(i + 1)}</span><span><span class="rt">${esc(r.title)}${i === 0 ? '<em class="tgf">Do this first</em>' : ''}</span><span class="rs">${r.product ? `<b class="pn">${esc(r.product)}</b>` : ''}${esc(r.subject)}</span><span class="sug"><span>${esc(r.prepared)}</span></span>${r.skip ? `<span class="skip">${esc(r.skip)}</span>` : ''}</span></button><button class="rpin" data-pin="${esc(r.key)}" aria-pressed="${pinned.has(r.key)}" aria-label="Pin ${esc(r.title)} to the top" title="Pin to the top"><svg class="i" viewBox="0 0 24 24"><path d="M9 4h6l-1 6 3 3H7l3-3zM12 13v7"/></svg></button></div>`).join('')
81
+ + (LS.more ? `<p class="note">${LS.more} more ${LS.more === 1 ? 'row is' : 'rows are'} not shown here.</p>` : '');
82
+ const n = LS.count;
83
+ $('#movesCap').innerHTML = pend ? `${n} ${n === 1 ? 'row' : 'rows'} so far · still reading` : n ? `<b>${done} of ${total}</b> done · ${n} ${n === 1 ? 'row' : 'rows'} left` : 'All clear';
70
84
  $('#movesCap').title = 'Counts rows that cleared since this page first read today. A row clears when its record changes.';
71
- const p = $('#mprog'); p.hidden = !total || !!M.pending; p.setAttribute('aria-valuemax', total); p.setAttribute('aria-valuenow', done); $('b', p).style.width = (total ? done / total * 100 : 0) + '%';
72
- $('#calm').hidden = n > 0 || !!M.pending; $('#calmNext').textContent = '';
73
- $('#order').textContent = M.pending ? M.list.pendingNote : n ? M.list.order : '';
74
- $('#order').hidden = !n && !M.pending;
75
- const po = M.list.putOff || [];
85
+ const p = $('#mprog'); p.hidden = !total || pend; p.setAttribute('aria-valuemax', total); p.setAttribute('aria-valuenow', done); $('b', p).style.width = (total ? done / total * 100 : 0) + '%';
86
+ $('#calm').hidden = n > 0 || pend; $('#calmNext').textContent = '';
87
+ $('#order').textContent = pend ? LS.pendingNote : n ? LS.order : '';
88
+ $('#order').hidden = !n && !pend;
89
+ const po = LS.putOff || [];
76
90
  $('#putoff').textContent = po.length ? 'Put off by you: ' + po.map((x) => x.text).join('; ') + '. Not counted as done.' : '';
77
91
  $('#putoff').hidden = !po.length;
78
92
  }
@@ -80,13 +94,16 @@ $('#rank').addEventListener('click', (e) => {
80
94
  const pin = e.target.closest('.rpin');
81
95
  if (pin) { const k = pin.dataset.pin; pinned.has(k) ? pinned.delete(k) : pinned.add(k); drawRows(); toast(pinned.has(k) ? 'Pinned to the top for this session.' : 'Unpinned.'); return; }
82
96
  const h = e.target.closest('.rhd');
83
- if (h) openRow(M.list.rows.find((r) => r.key === h.closest('.rr').dataset.key));
97
+ if (!h) return;
98
+ const r = LIST().rows.find((x) => x.key === h.closest('.rr').dataset.key);
99
+ if (r && r.go) { location.assign(r.go); return; } // a console row opens its item on its own page: My work, the initiative, or the console
100
+ openRow(r);
84
101
  });
85
102
 
86
103
  /* ── today ──────────────────────────────────────────────────────────────────────────────────────────────── */
87
104
  const linkOf = (r) => ((r.from || []).find((x) => /^meeting:/.test(x)) || '').replace(/^meeting:/, '');
88
105
  function evHtml(e, i) {
89
- const lnk = e.kind === 'meeting' && (M.list.rows || []).some((r) => linkOf(r) === e.title) ? e.title : '';
106
+ const lnk = e.kind === 'meeting' && (LIST().rows || []).some((r) => linkOf(r) === e.title) ? e.title : '';
90
107
  return `<button class="ev src-${e.kind}"${lnk ? ` data-link="${esc(lnk)}"` : ''} data-i="${i}" style="animation:rise .6s var(--ease) both"><time>${esc(e.t)}</time><span class="gl-t"><svg class="i" viewBox="0 0 24 24">${ICON[e.kind]}</svg></span><span><b>${esc(e.title)}</b><span class="d">${esc(e.sub)}${e.product ? ' · ' + esc(e.product) : ''}</span></span></button>`;
91
108
  }
92
109
  const ALL = () => M.today.ahead.concat(M.today.earlier);
@@ -135,7 +152,10 @@ document.addEventListener('click', (e) => {
135
152
  });
136
153
 
137
154
  /* ── dock ───────────────────────────────────────────────────────────────────────────────────────────────── */
138
- function drawDock() { $('#dN').textContent = M.dock.needs == null ? '·' : M.dock.needs; $('#dLab').textContent = M.dock.needs == null ? 'still reading' : M.dock.needs === 0 ? 'need you' : M.dock.label; }
155
+ function drawDock() {
156
+ const n = CL ? CL.length : M.dock.needs;
157
+ $('#dN').textContent = n == null ? '·' : n; $('#dLab').textContent = n == null ? 'still reading' : n === 0 ? 'need you' : CL ? (n === 1 ? 'needs you' : 'need you') : M.dock.label;
158
+ }
139
159
 
140
160
  const SEL = {}; // the option chosen on each row, for this session
141
161
  const START = {}; // 'ask' while the PM is confirming a start, by row key
@@ -189,13 +209,20 @@ let openR = null;
189
209
  function plainDialog(r) {
190
210
  return { eye: 'Detail', logTitle: 'Read from the repository', log: ['Read the record'], say: [r.prepared, r.skip].filter(Boolean).join(' '), head: 'What is known', facts: [['Subject', r.subject], ['Next', r.prepared], ['If you skip', r.skip && r.skip.replace(/^If you skip: /, '')]].filter((x) => x[1]), opts: [], sel: null, nodef: '', pane: { label: 'Detail', file: '', h: r.title, intro: r.subject || '', rows: [], paras: [] } };
191
211
  }
212
+ /* A decision from the console's Needs you: what its record says, and its source. Choosing an option on an engine card is not recorded from here. */
213
+ function consoleDialog(r) {
214
+ const facts = [['Kind', r.subject]].concat((r.facts || []).map((f) => ['Fact', f]), r.options && r.options.length ? [['Options', r.options.join(' · ')]] : []);
215
+ return { eye: 'Needs you', logTitle: 'Read from the console Briefing', log: ['Read GET /api/briefing', 'Kept the row Needs you shows'], say: r.prepared || 'This is on the console\'s Needs you.', head: 'What is known', facts, opts: [], sel: null,
216
+ nodef: r.options && r.options.length ? 'Choosing an option is recorded on the console Briefing, not here.' : '', link: r.url || null, linkLabel: r.urlLabel || null, noAsk: true,
217
+ pane: { label: 'Detail', file: 'Needs you', h: r.title, intro: r.subject || '', rows: [], paras: (r.facts || []).slice(0, 6) } };
218
+ }
192
219
  function openRow(r) {
193
220
  if (!r) return;
194
- if (!r.dialog) r = { ...r, dialog: plainDialog(r) };
221
+ if (!r.dialog) r = { ...r, dialog: r.src ? consoleDialog(r) : plainDialog(r) };
195
222
  openR = r; const d = r.dialog;
196
223
  openDlg({ eye: d.eye + ' · real data', title: d.title || r.title, sub: d.sub || r.subject, say: d.say, stream: turnA(logHtml(d)) + turnA(ptx(d.say)) + cardHtml(r), noteKey: r.key, pane: paneHtml(r), label: d.pane.label });
197
224
  ctaState(r);
198
- loadThread(r.key);
225
+ if (r.dialog.noAsk) { $('#askF').hidden = true; $('#askNote').hidden = true; } else loadThread(r.key); // the read-only agent answers about the model's rows only
199
226
  setTimeout(() => { const b = $('#dBody'); b.scrollTop = b.scrollHeight; }, 120);
200
227
  }
201
228
  function showErr(msg) { const e = $('#cardErr'); if (!e) { toast(msg); return; } e.textContent = msg; e.hidden = false; }
@@ -899,7 +926,7 @@ async function load() {
899
926
  const ws = new URLSearchParams(location.search).get('ws');
900
927
  try { const res = await fetch('/api/briefing-premium' + (ws ? '?ws=' + encodeURIComponent(ws) : ''), { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
901
928
  clearInterval(readTimer);
902
- pvFeed(r);
929
+ pvFeed(CL && r && r.ok ? { ok: true, model: { list: LIST() } } : r); // the bell counts what the list shows: the console's Needs you once it is read
903
930
  if (r && r.state === 'reading') {
904
931
  // the first read has no end I can promise: say how long it has run, and ask again
905
932
  const t0 = Date.now() - (r.elapsed_ms || 0), tick = () => { $('#brief').textContent = 'Reading the products for the first time. ' + Math.round((Date.now() - t0) / 1000) + ' s so far. This page shows nothing until it has read, rather than guess.'; };