create-pmos 0.312.0 → 0.314.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 +1 -1
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-insights-test.js +1 -1
- package/workspace/briefing-premium-metrics-test.js +41 -3
- package/workspace/briefing-premium-products-test.js +4 -0
- package/workspace/briefing-premium-sources-test.js +4 -0
- package/workspace/briefing-premium-test.js +44 -6
- package/workspace/guide/briefing-premium.md +5 -2
- package/workspace/lib/board-metric-records.js +101 -0
- package/workspace/lib/board-metrics-premium.js +56 -25
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-board-metric-targets.js +33 -0
- package/workspace/lib/routes-board-premium.js +4 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/premium-board.js +6 -45
- package/workspace/public/pm/premium-brief.js +44 -3
- package/workspace/public/pm/premium-insights.js +53 -1
- package/workspace/public/pm/premium-metric-tiles.js +68 -0
- package/workspace/public/pm/premium-work.js +8 -0
- package/workspace/public/pm/premium.js +48 -21
- package/workspace/public/premium-insights.html +8 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.314.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": {
|
package/payload/KIT-VERSION
CHANGED
|
@@ -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:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T13:37:58Z"}
|
|
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:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T13:37:58Z"}
|
|
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:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-19T13:37:58Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -129,7 +129,7 @@ const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'br
|
|
|
129
129
|
{ const R = await open(); await R.page.locator('#repDocs .dmo').first().click(); ok('I8 a report opens in the page\'s reader, not the console (premium-report-read R1)', await until(() => R.page.evaluate(() => document.querySelector('#dlg').classList.contains('rdrd') && document.querySelector('#dlg').classList.contains('on')), 5000) && /premium-insights\.html/.test(R.page.url()), R.page.url());
|
|
130
130
|
await R.page.click('#dClose'); await R.page.click('#repOpen'); ok('I8 the Reports tab link still opens the console to edit or issue', await until(() => /\/console\.html\?tab=rep/.test(R.page.url()), 5000), R.page.url()); await R.ctx.close(); }
|
|
131
131
|
/* I9 labels */
|
|
132
|
-
ok('I9 no demo label, and the foot says what is left out', !(await p.evaluate(() => /demo/i.test(document.querySelector('main.stage').textContent))) && /Left out:
|
|
132
|
+
ok('I9 no demo label, and the foot says what is left out', !(await p.evaluate(() => /demo/i.test(document.querySelector('main.stage').textContent))) && /Left out: any measure no record holds/.test(await txt('#foot')) && /Board measures card/.test(await txt('#foot')) && /Real data/.test(await txt('#snap')));
|
|
133
133
|
ok('I9 the page makes no write request on its own', A.posts.length === 0, A.posts.join());
|
|
134
134
|
/* I10 empty */
|
|
135
135
|
{
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
/* briefing-premium-metrics-test.js — the Metrics card of the premium Board (initiative briefing-premium-metrics; planning/prd/briefing-premium-metrics-prd.md M1 to M10).
|
|
4
4
|
* Serves the real page from the real server. The Board's answer and the card's answer are served from fixtures (the card's model is built by
|
|
5
5
|
* lib/board-metrics-premium.js from made-up runs, commits and initiatives); the last blocks ask the real route and compare the card with the mockup.
|
|
6
|
-
* C1 place and absence · C2 tiles · C3 reading a week · C4 dialog and agent · C5 pending and failure · C6 floors · C7 the real route · C8 fidelity */
|
|
6
|
+
* C1 place and absence · C2 tiles · C3 reading a week · C4 dialog and agent · C5 pending and failure · C6 floors · C7 the real route · C8 fidelity · C9 targets on the Board · C10 the Insights twin */
|
|
7
7
|
const fs = require('fs');
|
|
8
8
|
const path = require('path');
|
|
9
9
|
const { spawn } = require('child_process');
|
|
@@ -71,7 +71,7 @@ const ready = (model) => ({ status: 200, body: { ok: true, state: 'ready', model
|
|
|
71
71
|
/* C2 */
|
|
72
72
|
const tiles = await p.evaluate(() => [...document.querySelectorAll('#metBody .mt1')].map((t) => ({ l: t.querySelector('span').textContent, v: t.querySelector('.mval').textContent, c: t.querySelector('.mwk').textContent, chart: !!t.querySelector('svg'), cls: t.className, chg: (t.querySelector('.mchg') || {}).textContent || '' })));
|
|
73
73
|
ok('C2 the first tile is the latest week with its run count, and how it changed', tiles[0].l === 'Corrections per 100 runs' && tiles[0].v === '10.0' && /^week to .+, 10 runs$/.test(tiles[0].c) && tiles[0].chg === '▼ Down 15.0 vs last week' && tiles[0].chart && /\bok\b/.test(tiles[0].cls), JSON.stringify(tiles[0]));
|
|
74
|
-
ok('C2 merges, blocked and idle are counted; blocked and idle
|
|
74
|
+
ok('C2 merges, blocked and idle are counted; blocked and idle chart from today and say plainly that their history starts today', tiles[1].v === '3' && tiles[1].chart && tiles[2].v === '1' && tiles[2].c === 'of 3 open · history starts today' && tiles[2].chart && tiles[3].v === '1' && tiles[3].c === 'of 3 open · history starts today' && tiles[3].chart && /\bbad\b/.test(tiles[2].cls) && /\bwarn\b/.test(tiles[3].cls), JSON.stringify(tiles));
|
|
75
75
|
const per = await p.evaluate(() => [...document.querySelectorAll('#perTabs button')].map((b) => b.textContent + ':' + b.getAttribute('aria-pressed') + ':' + (b.getAttribute('aria-disabled') || '')).join('|'));
|
|
76
76
|
ok('C2 only Week is available; Day and Month are disabled', per === 'Day:false:true|Week:true:|Month:false:true', per);
|
|
77
77
|
ok('C2 no target, on-target chip, dashed line or demo label is drawn; the lead line says no measure has a target', await p.evaluate(() => !document.querySelector('#cMet .mchip.ok, #cMet .tg, #cMet .tgl') && !/on target|demo|dashed/i.test(document.querySelector('#metBody').textContent) && /No measure here has a target/.test(document.querySelector('#metHint').textContent)));
|
|
@@ -108,7 +108,7 @@ const ready = (model) => ({ status: 200, body: { ok: true, state: 'ready', model
|
|
|
108
108
|
ok('C4 a question posts the metric\'s key and the text', await until(() => A.posts.length > n0 && A.posts[A.posts.length - 1].path === '/api/briefing-premium/ask' && A.posts[A.posts.length - 1].body.key === 'board:metric-corrections' && A.posts[A.posts.length - 1].body.text === 'Why did it fall?'), JSON.stringify(A.posts.slice(-1)));
|
|
109
109
|
await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
|
|
110
110
|
await p.locator('#metBody .mt1').nth(2).click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(400);
|
|
111
|
-
ok('C4
|
|
111
|
+
ok('C4 Blocked opens its definition, and the weeks before its history started read Not kept yet', await p.evaluate(() => { const v = [...document.querySelectorAll('#oMain .vtb div b')].map((b) => b.textContent); return document.querySelector('#dTitle').textContent === 'Blocked' && /blocked step/.test(document.querySelector('#oMain .lede').textContent) && v.length === 8 && v.slice(0, 7).every((x) => x === 'Not kept yet') && v[7] === '1'; }));
|
|
112
112
|
await p.keyboard.press('Escape'); await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')));
|
|
113
113
|
await p.click('#perTabs [data-per="day"]', { force: true }); ok('C4 a disabled period says why and changes nothing', await until(() => p.evaluate(() => /by week only/.test(document.querySelector('#toast').textContent))) && await p.evaluate(() => document.querySelector('#perTabs [data-per="week"]').getAttribute('aria-pressed') === 'true'));
|
|
114
114
|
ok('0 no page error', A.errors.length === 0, A.errors.join(' | '));
|
|
@@ -148,6 +148,44 @@ const ready = (model) => ({ status: 200, body: { ok: true, state: 'ready', model
|
|
|
148
148
|
await ctx.close();
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
+
/* C9 a target set on Insights draws on the Board */
|
|
152
|
+
{
|
|
153
|
+
const R = await open({ answers: () => ready(metrics({ targets: { corrections: { target: 12 }, merges: { target: 5 } } })) }), q = R.page;
|
|
154
|
+
await until(() => q.evaluate(() => document.querySelectorAll('#metBody .mt1').length === 4));
|
|
155
|
+
const t = await q.evaluate(() => [...document.querySelectorAll('#metBody .mt1')].map((x) => ({ chip: (x.querySelector('.mchip') || {}).textContent || '', cls: (x.querySelector('.mchip') || {}).className || '', tg: !!x.querySelector('svg .tg'), tgl: !!x.querySelector('.tgl'), tgt: (x.querySelector('.mtg') || {}).textContent || '', off: x.classList.contains('off') })));
|
|
156
|
+
ok('C9 a measure on target carries the On target chip, its target and the dashed line, with no outline', t[0].chip === 'On target' && /\bok\b/.test(t[0].cls) && t[0].tg && t[0].tgl && t[0].tgt === 'target 12.0' && !t[0].off, JSON.stringify(t[0]));
|
|
157
|
+
ok('C9 a measure off target carries its gap, the dashed line and the orange outline', t[1].chip === '2 short' && /\bwarn\b/.test(t[1].cls) && t[1].tg && t[1].tgt === 'target 5' && t[1].off, JSON.stringify(t[1]));
|
|
158
|
+
ok('C9 a measure with no target draws no dashed line, and the lead line says the line is the target set on Insights', !t[2].tg && !t[3].tg && await q.evaluate(() => /The dashed line is the target set on Insights/.test(document.querySelector('#metHint').textContent)), JSON.stringify(t.slice(2)));
|
|
159
|
+
await q.locator('#metBody .mt1').first().click(); await until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(300);
|
|
160
|
+
ok('C9 the dialog names the target and the gap', await q.evaluate(() => { const g = [...document.querySelectorAll('#oMain .kv2 span')].map((s) => s.textContent).join('|'); return /Target\|12\.0/.test(g) && /Gap\|On target/.test(g); }));
|
|
161
|
+
ok('C9 no page error', R.errors.length === 0, R.errors.join(' | '));
|
|
162
|
+
await R.ctx.close();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* C10 the Insights page shows the same measures, and a target saved there is sent for the Board */
|
|
166
|
+
{
|
|
167
|
+
const IP = require('./lib/insights-premium.js'), IF = require('./fixtures/insights-premium-facts.js');
|
|
168
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), q = await ctx.newPage(), errs = [], saves = [], asked = [];
|
|
169
|
+
let tg = {};
|
|
170
|
+
q.on('pageerror', (e) => errs.push(String((e && e.message) || e)));
|
|
171
|
+
await q.route('**/api/insights-premium*', (r) => r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: IP.build(IF.facts()), as_of: 1 }) }));
|
|
172
|
+
await q.route('**/api/board-metrics-premium*', (r) => { asked.push(new URL(r.request().url()).searchParams.get('weeks')); return r.fulfill({ contentType: 'application/json', body: JSON.stringify(ready(metrics({ targets: tg })).body) }); });
|
|
173
|
+
await q.route('**/api/board-metric-targets/save', (r) => { const b = JSON.parse(r.request().postData() || '{}'); saves.push(b); tg = b.target == null ? {} : { [b.key]: { target: Number(b.target) } }; return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, targets: tg }) }); });
|
|
174
|
+
await q.route('**/api/briefing-premium/**', (r) => r.fulfill({ contentType: 'application/json', body: '{"ok":true,"turns":[],"working":false}' }));
|
|
175
|
+
await q.goto(BASE + '/premium-insights.html');
|
|
176
|
+
const up = await until(() => q.evaluate(() => !document.querySelector('#cBm').hidden && document.querySelectorAll('#bmBody .mt1').length === 4), 20000);
|
|
177
|
+
ok('C10 Insights draws the Board measures card with the same four tiles as the Board', up && await q.evaluate(() => [...document.querySelectorAll('#bmBody .mt1 .mval')].map((v) => v.textContent).join('|') === '10.0|3|1|1' && /counted from idpf/.test(document.querySelector('#bmCap').textContent)));
|
|
178
|
+
ok('C10 Blocked and Idle say plainly on their charts that history starts today', await q.evaluate(() => [...document.querySelectorAll('#bmBody .mt1')].slice(2).every((t) => !!t.querySelector('svg') && t.querySelector('.mwk').textContent === 'of 3 open · history starts today')));
|
|
179
|
+
await q.locator('#bmRange [data-w="26"]').click();
|
|
180
|
+
ok('C10 a longer range asks for 26 weeks', await until(() => asked.includes('26')) && await until(() => q.evaluate(() => document.querySelector('#bmRange [data-w="26"]').getAttribute('aria-pressed') === 'true')), JSON.stringify(asked));
|
|
181
|
+
await q.locator('#bmBody .mt1').nth(1).click(); await until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(300);
|
|
182
|
+
await q.fill('#bmT', '5'); await q.click('#bmGo');
|
|
183
|
+
ok('C10 Save target sends the measure and the number for this board', await until(() => saves.length === 1) && saves[0].ws === 'w1' && saves[0].key === 'merges' && saves[0].target === '5', JSON.stringify(saves));
|
|
184
|
+
ok('C10 the card redraws with the target: its gap chip, dashed line and outline', await until(() => q.evaluate(() => { const t = document.querySelectorAll('#bmBody .mt1')[1]; return t && (t.querySelector('.mchip') || {}).textContent === '2 short' && !!t.querySelector('svg .tg') && t.classList.contains('off'); })));
|
|
185
|
+
ok('C10 no page error', errs.length === 0, errs.join(' | '));
|
|
186
|
+
await ctx.close();
|
|
187
|
+
}
|
|
188
|
+
|
|
151
189
|
/* C8 fidelity against the mockup */
|
|
152
190
|
if (!fs.existsSync(MOCKUP)) ok('C8 the mockup is in the repository', false, MOCKUP);
|
|
153
191
|
else {
|
|
@@ -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
|
-
|
|
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:
|
|
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 =
|
|
175
|
-
ok('R2 the hero reads the
|
|
176
|
-
ok('R2 the
|
|
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.
|
|
@@ -241,7 +243,7 @@ Board is the third place on the rail, at `/premium-board.html`. It reads what th
|
|
|
241
243
|
- **By stage** has one column for each stage of the board's workflow with the board's own count and its first five initiatives.
|
|
242
244
|
- **List** and **Timeline** show ten tasks a page with Previous and Next; **By stage** shows six cards a column with Show more. **Timeline** draws a bar for each initiative that has both a start and an end date, with the days left or over, and counts the rest. With no dates on record it says so and draws nothing.
|
|
243
245
|
- **Sprint** appears when an agent session has read Jira for the board. Otherwise it says there is none. **Coming up** shows the next release, from the releases ledger.
|
|
244
|
-
- **Metrics** appears above the Initiatives card on the board of any workspace except the home one (PMOS itself), and counts from that workspace's own repository. It has four tiles. **Corrections per 100 runs** is the corrections logged on the week's runs in `planning/runs/agent-runs.jsonl`; a week with fewer than 10 runs is left blank. **Merged a week** counts the commits on the first-parent line of the trunk. **Blocked** and **Idle for a month** come from the workflow engine
|
|
246
|
+
- **Metrics** appears above the Initiatives card on the board of any workspace except the home one (PMOS itself), and counts from that workspace's own repository. It has four tiles. **Corrections per 100 runs** is the corrections logged on the week's runs in `planning/runs/agent-runs.jsonl`; a week with fewer than 10 runs is left blank. **Merged a week** counts the commits on the first-parent line of the trunk. **Blocked** and **Idle for a month** come from the workflow engine, which keeps no history. From the first day the card is read, PMOS keeps their counts once a day in the workspace's state folder (`board-metric-history.jsonl`), so their charts start on that day and their caption says **history starts today** (later, the date). Earlier weeks read **Not kept yet**. Move over a chart, or use the arrow keys, to read a week. A tile that cannot be counted says **Not read** and why; a repository with no run log says **No runs yet**. The line above the tiles starts with how many tiles need a look, and those tiles have a **Needs a look** chip and an orange outline. The line ends with **open Insights**, which opens the same board's Insights page. Press a tile for its definition and values, with the read-only agent beside it. A target is set on Insights, not here. A measure with a target shows it under the value, draws it as a dashed line, and carries **On target** or its gap (for example **2 short**); off target, it also has the orange outline. A measure without a target draws no line. Day and Month are off. It was tested only on made-up repositories, not on a real IDPF or microsite repository.
|
|
245
247
|
- **The crumb** at the top names the board. With more than one board a menu switches between them, and the sparkle opens the board in the dialog with the read-only agent.
|
|
246
248
|
- **Core documents** lists the board's documents with their state, cadence and writer, a summary (drafts to review, not started, up to date), a progress bar, a filter and a search. A document with a file opens in the dialog, read only, with its path and state; a draft there has **Issue it**, which marks it issued through the console's own route and sends nothing, and **Draft it again**, which starts a new draft that replaces this one (a board draft has no Edit tab). **Draft it** starts the existing read-only run that writes a draft and sends nothing; **Draft the N not started** does that for each document that can be drafted. **Set it up** and **Open** go to the console. **Add a document** opens a form (title, who writes it, where it lives) and saves a document the core set does not cover on the board's record, in `custom-docs.jsonl`. A document with no link reads "Not started". A document with a link to Confluence or Google Docs reads "Linked" and shows its address. PMOS does not read or sync the linked page, so a linked document is never counted as up to date. Issue and Drop are not on this page.
|
|
247
249
|
- **Opening an initiative.** A click on an initiative opens its page (see "Initiative page"). The **Page / Popup** switch in the header changes that: Popup opens the initiative's dialog instead, which shows its record as a grid and the path of its file, with the read-only agent beside it. The choice is kept in this browser. The dialog holds no press.
|
|
@@ -283,6 +285,7 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
|
|
|
283
285
|
- **Choose a deck or a document, and read the design brief.** On the Design tab, the **Format** chip offers **Deck** and **Document** for the next version. Versions you already made keep their form. Once a design is saved, a **Design brief** chip shows what PMOS reads each cycle: your description, your samples, the reference version, and what stays the same, what changes and what PMOS learned. The cycles drafted to match it are checked on the report itself.
|
|
284
286
|
- **Point, make the next version, compare.** On the Design tab, click any part of a slide to attach a request to that spot: a numbered pin appears, and you type the request under the preview (**Point and say**; the switch turns pointing off). **Make the next version** sends the typed line and every pinned request to PMOS, which makes the next version; the pins are cleared once it starts. **Compare two** shows the same slide of two versions side by side; pick the version on each side.
|
|
285
287
|
- **What stands out.** Up to three plain sentences taken from the series: behind its line for three readings in a row, behind and still moving away from the target, closing in, slipped, reached its target, or a large one-step move. There is no forecast and no cause.
|
|
288
|
+
- **Board measures.** The same four tiles as the Board's Metrics card, counted from the board's repository and drawn the same way. Choose **8 weeks**, **26 weeks** or **52 weeks**; the page keeps your choice. Press a measure to read its definition and values and to set its target: type a number and press **Save target**, or press **Clear target**. For Corrections, Blocked and Idle, lower is better, so the target is the most you accept; for Merged a week it is the least. The target goes to the workspace's state folder (`board-metric-targets.jsonl`) and the Board draws it too. An agent session cannot set one.
|
|
286
289
|
- **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
|
|
287
290
|
- **Ask PMOS to set up a report.** Type what the report is for and press **Ask**. A background run proposes a report and does nothing else. The request is listed as Working, then Ready to review. A ready request opens with its proposal: **Set it up**, **Change it** (say what to change; the run revises it), or **Cancel**.
|
|
288
291
|
- **Found in your work.** Up to three reports PMOS found in your calendar, mail or documents, each with why and what it saw. **Set it up** records the report and drafts its first cycle as a file. **Not a report** hides it and records it after 5 seconds, unless you press **Undo**. If the finding changed while the window was open, the window says what happened. It was already set up, it was marked not a report, or a new scan replaced it. The list is read again. Close the window and open the report from the list. If PMOS does not hear back, the window says nothing was recorded. Press the button to try again.
|
|
@@ -290,7 +293,7 @@ Insights is the fourth place on the rail, at `/premium-insights.html`. It reads
|
|
|
290
293
|
- **Documents.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens it on the page at the normal dialog size, with a status line (Draft or Issued, the saved design version, the file). The **slide deck / Document** menu picks the view: a deck is a title slide, then one slide for each section, with the arrow keys and a strip of slides; a document is a page. The **Read** menu holds **Present**, which shows the slide on the whole screen (the arrow keys move and Escape stops), and **Print or save as PDF**, which prints one slide to a page. **Download** gives PowerPoint, Word, Excel, CSV or the Markdown file; the files carry the words, not the look. **Open in the console** is where a document is edited or issued. Nothing is sent from this page.
|
|
291
294
|
- **Shape a report's look.** On a draft, **Add a sample** takes a PDF, PowerPoint, Word, PNG or JPG file to follow. Say how it should look in the conversation; PMOS draws the next design version (D1, D2, …) and says what it changed. Press a version to go back to it. **This is it** saves the version shown as the report's design, and PMOS draws the cycle to match. An issued cycle is frozen with its look.
|
|
292
295
|
|
|
293
|
-
Not built: a second measure next to a chart, bar highlights, speaker notes and notes on a slide, changing a set-up report's audience, format or schedule, tile sizes and free layout, the finder's settings,
|
|
296
|
+
Not built: a second measure next to a chart, bar highlights, speaker notes and notes on a slide, changing a set-up report's audience, format or schedule, tile sizes and free layout, the finder's settings, and any measure no record holds. The console's own dashboards are separate and unchanged. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
|
|
294
297
|
|
|
295
298
|
## Welcome
|
|
296
299
|
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* board-metric-records.js — the two records behind the Board's Metrics card and its Insights twin (initiative briefing-premium-metrics, option C).
|
|
3
|
+
* THE ONE WRITER and THE ONE FOLD of <state>/board-metric-targets.jsonl and <state>/board-metric-history.jsonl.
|
|
4
|
+
*
|
|
5
|
+
* KEYS the four measures: corrections · merges · blocked · idle
|
|
6
|
+
* targetsFile(root) · historyFile(root)
|
|
7
|
+
* checkTarget(input) → { ok: true, value: { key, target } } | { ok: false, status, error } PURE (target null clears it)
|
|
8
|
+
* foldTargets(lines) → { [key]: { target, at, actor } } PURE: the last line of each key; a clear drops it
|
|
9
|
+
* targets(root) → the fold of the file
|
|
10
|
+
* saveTarget(root, input, actor, { now }) → { ok: true, targets } | { ok: false, status, error }
|
|
11
|
+
* dayOf(now) → 'YYYY-MM-DD' (UTC) PURE
|
|
12
|
+
* history(root) → [{ day, blocked, idle, open }] in day order, one per day (the first line of a day wins)
|
|
13
|
+
* record(root, { now, blocked, idle, open }) → true when it appended today's line, false when today already has one
|
|
14
|
+
*
|
|
15
|
+
* TARGETS. Lines { v: 1, ev: set | clear, key, target, actor, at }. The PM sets one on the Insights page; the Board and Insights both read it. A target is a
|
|
16
|
+
* number the PM typed: nothing here proposes one.
|
|
17
|
+
* HISTORY. Blocked and Idle come from the workflow engine, which keeps no history. From the first day the card is read, one line per UTC day records the
|
|
18
|
+
* counts, so their charts start on that day and never before it. Lines { v: 1, day, blocked, idle, open, at }. Both files are append-only and never
|
|
19
|
+
* rewritten; a torn line is skipped. */
|
|
20
|
+
const fs = require('fs');
|
|
21
|
+
const path = require('path');
|
|
22
|
+
|
|
23
|
+
const KEYS = ['corrections', 'merges', 'blocked', 'idle'];
|
|
24
|
+
const TARGET_MAX = 1e6;
|
|
25
|
+
const isObj = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
26
|
+
const refuse = (status, error) => ({ ok: false, status, error });
|
|
27
|
+
|
|
28
|
+
function stateDir(root) {
|
|
29
|
+
const abs = path.resolve(String(root));
|
|
30
|
+
return path.join(abs, require('./report-draft.js').stateRel(abs));
|
|
31
|
+
}
|
|
32
|
+
const targetsFile = (root) => path.join(stateDir(root), 'board-metric-targets.jsonl');
|
|
33
|
+
const historyFile = (root) => path.join(stateDir(root), 'board-metric-history.jsonl');
|
|
34
|
+
|
|
35
|
+
function readLines(file) {
|
|
36
|
+
let text = '';
|
|
37
|
+
try { text = fs.readFileSync(file, 'utf8'); } catch { return []; }
|
|
38
|
+
const out = [];
|
|
39
|
+
for (const raw of text.split('\n')) {
|
|
40
|
+
if (!raw.trim()) continue;
|
|
41
|
+
try { const l = JSON.parse(raw); if (isObj(l)) out.push(l); } catch { /* a torn line is skipped */ }
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function checkTarget(input) {
|
|
47
|
+
const i = isObj(input) ? input : {};
|
|
48
|
+
if (!KEYS.includes(i.key)) return refuse(400, 'Name the measure: corrections, merges, blocked or idle.');
|
|
49
|
+
if (i.target === null || i.target === '') return { ok: true, value: { key: i.key, target: null } };
|
|
50
|
+
const t = typeof i.target === 'number' ? i.target : typeof i.target === 'string' && i.target.trim() !== '' ? Number(i.target) : NaN;
|
|
51
|
+
if (!Number.isFinite(t) || t < 0 || t > TARGET_MAX) return refuse(400, 'The target must be a number of 0 or more.');
|
|
52
|
+
return { ok: true, value: { key: i.key, target: Math.round(t * 100) / 100 } };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function foldTargets(lines) {
|
|
56
|
+
const out = {};
|
|
57
|
+
for (const l of lines || []) {
|
|
58
|
+
if (!KEYS.includes(l.key)) continue;
|
|
59
|
+
if (l.ev === 'clear') delete out[l.key];
|
|
60
|
+
else if (l.ev === 'set' && typeof l.target === 'number' && Number.isFinite(l.target)) out[l.key] = { target: l.target, at: l.at || null, actor: l.actor || null };
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
const targets = (root) => foldTargets(readLines(targetsFile(root)));
|
|
65
|
+
|
|
66
|
+
/** THE SINGLE WRITER of board-metric-targets.jsonl. */
|
|
67
|
+
function saveTarget(root, input, actor, { now } = {}) {
|
|
68
|
+
const c = checkTarget(input);
|
|
69
|
+
if (!c.ok) return c;
|
|
70
|
+
const t = now == null ? Date.now() : now, v = c.value;
|
|
71
|
+
const line = v.target === null ? { v: 1, ev: 'clear', key: v.key, actor: actor || null, at: new Date(t).toISOString() } : { v: 1, ev: 'set', key: v.key, target: v.target, actor: actor || null, at: new Date(t).toISOString() };
|
|
72
|
+
const file = targetsFile(root);
|
|
73
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
74
|
+
fs.appendFileSync(file, JSON.stringify(line) + '\n');
|
|
75
|
+
return { ok: true, targets: targets(root) };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const dayOf = (now) => new Date(now).toISOString().slice(0, 10);
|
|
79
|
+
const count = (v) => Number.isInteger(v) && v >= 0;
|
|
80
|
+
|
|
81
|
+
function history(root) {
|
|
82
|
+
const seen = new Set(), out = [];
|
|
83
|
+
for (const l of readLines(historyFile(root))) {
|
|
84
|
+
if (typeof l.day !== 'string' || !/^\d{4}-\d{2}-\d{2}$/.test(l.day) || seen.has(l.day) || !count(l.blocked) || !count(l.idle)) continue;
|
|
85
|
+
seen.add(l.day); out.push({ day: l.day, blocked: l.blocked, idle: l.idle, open: count(l.open) ? l.open : null });
|
|
86
|
+
}
|
|
87
|
+
return out.sort((a, z) => (a.day < z.day ? -1 : a.day > z.day ? 1 : 0));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** THE SINGLE WRITER of board-metric-history.jsonl: today's counts, once a day. */
|
|
91
|
+
function record(root, { now, blocked, idle, open }) {
|
|
92
|
+
if (!count(blocked) || !count(idle)) return false;
|
|
93
|
+
const t = now == null ? Date.now() : now, day = dayOf(t);
|
|
94
|
+
if (history(root).some((h) => h.day === day)) return false;
|
|
95
|
+
const file = historyFile(root);
|
|
96
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
97
|
+
fs.appendFileSync(file, JSON.stringify({ v: 1, day, blocked, idle, open: count(open) ? open : null, at: new Date(t).toISOString() }) + '\n');
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
module.exports = { KEYS, targetsFile, historyFile, checkTarget, foldTargets, targets, saveTarget, dayOf, history, record };
|
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* lib/board-metrics-premium.js — the Metrics card of a tenant's premium Board (initiative briefing-premium-metrics).
|
|
3
3
|
*
|
|
4
|
-
* build(facts) → model PURE. facts = { now, repo, runs[]|null, commits[]|null (ms), inits[]|null, initsPending, missing[]
|
|
5
|
-
*
|
|
4
|
+
* build(facts) → model PURE. facts = { now, repo, runs[]|null, commits[]|null (ms), inits[]|null, initsPending, missing[],
|
|
5
|
+
* weeks (8 | 26 | 52, default 8), targets { [key]: { target } }, history [{ day, blocked, idle }] }
|
|
6
|
+
* read({ root, engine, now, weeks }) → model the card of one workspace's repository: its run log, its trunk's history, its workflow state, the
|
|
7
|
+
* targets the PM set on Insights and the daily Blocked/Idle history (lib/board-metric-records.js). It
|
|
8
|
+
* appends today's Blocked/Idle line once the workflow state is known: that is the one write it makes.
|
|
6
9
|
* weeksTo(now, n) → [{ from, to, label }] PURE. The n weeks (Monday to Sunday, UTC) that end with the week of `now`.
|
|
7
10
|
*
|
|
8
11
|
* THE RULE THE FILE FOLLOWS: a number is made only from a record of the repository it names. A source that cannot be read is "Not read", a
|
|
9
|
-
* repository with no run log has "No runs yet", a week with too few runs is blank
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
+
* repository with no run log has "No runs yet", a week with too few runs is blank. A target exists only where the PM set one on Insights; a tile with one
|
|
13
|
+
* carries `tg`, its gap and an on/off-target chip, and a tile without one is never called on or off target. A tile that is off target, or needs a look
|
|
14
|
+
* (kind warn or bad) with no target, is marked `look`; the page draws that with the mockup's chip and orange outline. Blocked and Idle have history only
|
|
15
|
+
* from the first day the card was read: earlier weeks are blank, never zero. */
|
|
12
16
|
const fs = require('fs');
|
|
13
17
|
const path = require('path');
|
|
14
18
|
const { execFile } = require('child_process');
|
|
15
19
|
const BP = require('./briefing-premium.js');
|
|
20
|
+
const Rec = require('./board-metric-records.js');
|
|
16
21
|
|
|
17
|
-
const WEEKS = 8, MIN_RUNS = 10, DAY = 86400000, IDLE_DAYS = 30;
|
|
22
|
+
const WEEKS = 8, RANGES = [8, 26, 52], MIN_RUNS = 10, DAY = 86400000, IDLE_DAYS = 30;
|
|
18
23
|
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
19
24
|
const day = (t) => { const d = new Date(t); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()]; };
|
|
20
25
|
const plural = (n, one, many) => (n === 1 ? one : many);
|
|
@@ -41,9 +46,10 @@ function change(prev, cur, dec) {
|
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
function build(f) {
|
|
44
|
-
const now = f.now || Date.now(), W = weeksTo(now), missing = (f.missing || []).slice();
|
|
49
|
+
const now = f.now || Date.now(), N = RANGES.includes(f.weeks) ? f.weeks : WEEKS, W = weeksTo(now, N), missing = (f.missing || []).slice();
|
|
45
50
|
const repo = f.repo || '';
|
|
46
51
|
const tiles = [];
|
|
52
|
+
let counted = null; // today's Blocked/Idle counts, for the reader to keep
|
|
47
53
|
|
|
48
54
|
// corrections per 100 runs
|
|
49
55
|
if (f.runs === 'missing') tiles.push({ key: 'corrections', label: 'Corrections per 100 runs', absent: 'No runs yet', why: 'No agent run is logged in ' + repo + ' yet. Runs are read from planning/runs/agent-runs.jsonl.', def: DEFS.corrections });
|
|
@@ -54,7 +60,7 @@ function build(f) {
|
|
|
54
60
|
return { n: rs.length, v: rs.length >= MIN_RUNS ? Math.round(rs.reduce((a, r) => a + Number(r.human_corrections), 0) / rs.length * 1000) / 10 : null };
|
|
55
61
|
});
|
|
56
62
|
const ser = per.map((p) => p.v), li = ser.map((v, i) => (v != null ? i : -1)).filter((i) => i >= 0).pop();
|
|
57
|
-
if (li == null) tiles.push({ key: 'corrections', label: 'Corrections per 100 runs', absent: 'No weeks yet', why: 'No week of the last ' +
|
|
63
|
+
if (li == null) tiles.push({ key: 'corrections', label: 'Corrections per 100 runs', absent: 'No weeks yet', why: 'No week of the last ' + N + ' has ' + MIN_RUNS + ' runs with a logged correction count. ' + f.runs.length + ' ' + plural(f.runs.length, 'run is', 'runs are') + ' on record in all.', def: DEFS.corrections });
|
|
58
64
|
else {
|
|
59
65
|
const ch = li > 0 ? change(ser[li - 1], ser[li], 1) : null;
|
|
60
66
|
tiles.push({ key: 'corrections', label: 'Corrections per 100 runs', value: ser[li].toFixed(1), text: 'week to ' + W[li].label + ', ' + per[li].n + ' runs', kind: ch ? (ch.d === 0 ? '' : ch.good ? 'ok' : 'warn') : '', ser, wk: W.map((w) => w.label), nt: per.map((p) => (p.n ? p.n + ' ' + plural(p.n, 'run', 'runs') : '')), dec: 1, suf: '', change: ch, def: DEFS.corrections, lowBetter: true });
|
|
@@ -68,37 +74,57 @@ function build(f) {
|
|
|
68
74
|
tiles.push({ key: 'merges', label: 'Merged a week', value: String(ser[li]), text: 'to the trunk, week to ' + W[li].label, kind: '', ser, wk: W.map((w) => w.label), nt: ser.map(() => ''), dec: 0, suf: '', change: li > 0 ? (() => { const d = ser[li] - ser[li - 1]; return { d, good: d > 0, txt: (d === 0 ? 'No change' : (d > 0 ? 'Up ' : 'Down ') + Math.abs(d)) + ' vs last week' }; })() : null, def: DEFS.merges, lowBetter: false });
|
|
69
75
|
}
|
|
70
76
|
|
|
71
|
-
// blocked, idle
|
|
77
|
+
// blocked, idle: today's count, and earlier weeks from the daily history that starts on the first day the card was read
|
|
72
78
|
const waiting = (key, label, def) => ({ key, label, absent: f.initsPending ? 'Reading' : 'Not read', why: f.initsPending ? 'The workflow engine is deriving the initiatives of ' + repo + '. This tile fills in when it ends.' : 'The workflow engine could not be run in ' + repo + '.', def, pending: !!f.initsPending });
|
|
73
79
|
if (!f.inits) { tiles.push(waiting('blocked', 'Blocked', DEFS.blocked), waiting('idle', 'Idle for a month', DEFS.idle)); }
|
|
74
80
|
else {
|
|
75
81
|
const open = f.inits.filter((i) => !i.accepted && !i.stopped);
|
|
76
82
|
const blocked = open.filter((i) => (i.steps || []).some((s) => s.status === 'blocked')).length;
|
|
77
83
|
const idle = open.filter((i) => { const t = Date.parse(i.last_activity); return !Number.isFinite(t) || now - t > IDLE_DAYS * DAY; }).length;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
);
|
|
84
|
+
const hist = (f.history || []).filter((h) => Date.parse(h.day) < W[W.length - 1].from); // this week is today's live count
|
|
85
|
+
const first = (f.history || []).length ? Date.parse(f.history[0].day) : now;
|
|
86
|
+
const since = Rec.dayOf(Math.min(first, now)) === Rec.dayOf(now) ? 'history starts today' : 'history starts ' + day(Math.min(first, now));
|
|
87
|
+
const serOf = (k, live) => W.map((w, j) => { if (j === W.length - 1) return live; const inWk = hist.filter((h) => { const t = Date.parse(h.day); return t >= w.from && t < w.to; }); return inWk.length ? inWk[inWk.length - 1][k] : null; });
|
|
88
|
+
const hTile = (key, label, live, kind, def) => {
|
|
89
|
+
const ser = serOf(key, live), prev = ser.length > 1 ? ser[ser.length - 2] : null;
|
|
90
|
+
const ch = prev == null ? null : (() => { const d = live - prev; return { d, good: d < 0, txt: (d === 0 ? 'No change' : (d > 0 ? 'Up ' : 'Down ') + Math.abs(d)) + ' vs last week' }; })();
|
|
91
|
+
return { key, label, value: String(live), text: 'of ' + open.length + ' open · ' + since, kind, ser, wk: W.map((w) => w.label), nt: ser.map(() => ''), dec: 0, suf: '', change: ch, since, def, lowBetter: true };
|
|
92
|
+
};
|
|
93
|
+
tiles.push(hTile('blocked', 'Blocked', blocked, blocked ? 'bad' : '', DEFS.blocked), hTile('idle', 'Idle for a month', idle, idle ? 'warn' : '', DEFS.idle));
|
|
94
|
+
counted = { blocked, idle, open: open.length };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// targets the PM set on Insights: a chip, a gap and the dashed line, only where one exists
|
|
98
|
+
const T = f.targets || {};
|
|
99
|
+
for (const t of tiles) {
|
|
100
|
+
const tg = T[t.key] && Number.isFinite(T[t.key].target) ? T[t.key].target : null;
|
|
101
|
+
if (t.absent || tg == null) continue;
|
|
102
|
+
const v = Number(t.value), dec = t.dec || 0, ok = t.lowBetter ? v <= tg : v >= tg, gap = Math.abs(v - tg);
|
|
103
|
+
Object.assign(t, { tg, ok, gap: gap.toFixed(dec), chip: ok ? 'On target' : gap.toFixed(dec) + (t.lowBetter ? ' over' : ' short'), targetTxt: 'target ' + tg.toFixed(dec), kind: ok ? 'ok' : 'warn' });
|
|
82
104
|
}
|
|
83
105
|
|
|
84
106
|
// one row per tile for the read-only agent (key board:metric-<tile>), in the shape the Board's own rows have
|
|
85
107
|
const rows = tiles.map((t) => {
|
|
86
|
-
const say = t.absent ? t.label + ' is not shown: ' + t.why : t.label + ' is ' + t.value + ', ' + t.text + '.' + (t.change ? ' ' + t.change.txt + '.' : '');
|
|
87
|
-
const facts = [['Measure', t.label], ['Now', t.absent ? t.absent : t.value], ['Counted from', repo], ['Better when', t.lowBetter ? 'Lower' : t.lowBetter === false ? 'Higher' : '']]
|
|
108
|
+
const say = t.absent ? t.label + ' is not shown: ' + t.why : t.label + ' is ' + t.value + ', ' + t.text + '.' + (t.change ? ' ' + t.change.txt + '.' : '') + (t.tg != null ? ' The target is ' + t.tg + ': ' + (t.ok ? 'on target' : t.chip) + '.' : '');
|
|
109
|
+
const facts = [['Measure', t.label], ['Now', t.absent ? t.absent : t.value], ['Target', t.tg != null ? String(t.tg) : ''], ['Counted from', repo], ['Better when', t.lowBetter ? 'Lower' : t.lowBetter === false ? 'Higher' : '']]
|
|
88
110
|
.concat(t.ser ? t.ser.map((v, j) => [t.wk[j], v == null ? 'No runs' : String(v)]) : []).filter((x) => x[1] !== '');
|
|
89
111
|
t.rowKey = 'board:metric-' + t.key;
|
|
90
112
|
return { key: t.rowKey, id: null, title: t.label, sub: 'Metric · ' + repo, dialog: { say, facts, files: [] } };
|
|
91
113
|
});
|
|
92
|
-
tiles.forEach((t) => { t.look = t.kind === 'warn' || t.kind === 'bad'; });
|
|
93
|
-
const look = tiles.filter((t) => t.look).length;
|
|
114
|
+
tiles.forEach((t) => { t.look = t.tg != null ? !t.ok : t.kind === 'warn' || t.kind === 'bad'; });
|
|
115
|
+
const look = tiles.filter((t) => t.look).length, withTg = tiles.filter((t) => t.tg != null).length;
|
|
94
116
|
const lead = look ? look + ' of ' + tiles.length + ' need a look.' : '';
|
|
95
|
-
const body = 'Each chart is one measure over the last ' +
|
|
117
|
+
const body = 'Each chart is one measure over the last ' + N + ' weeks. ' + (withTg
|
|
118
|
+
? 'The dashed line is the target set on Insights. Orange is off target or needs a look.' + (withTg < tiles.length ? ' ' + (tiles.length - withTg) + ' ' + plural(tiles.length - withTg, 'measure has', 'measures have') + ' no target.' : '')
|
|
119
|
+
: 'No measure here has a target yet, so none is on or off target. Orange needs a look.')
|
|
120
|
+
+ ' Press a measure for its definition and values. A week with fewer than ' + MIN_RUNS + ' runs is left blank. Blocked and idle are kept from the first day this card was read.';
|
|
96
121
|
return {
|
|
97
122
|
state: 'ready', pending: !!f.initsPending, repo,
|
|
98
123
|
header: missing.length ? 'not read: ' + missing.join(', ') : 'counted from ' + repo,
|
|
99
124
|
look, lead, body,
|
|
100
|
-
|
|
101
|
-
|
|
125
|
+
weeks: N, counted,
|
|
126
|
+
hint: (lead ? lead + ' ' : '') + body + ' To set a target, or for longer ranges, open Insights.',
|
|
127
|
+
note: 'Counted from ' + repo + ': corrections from planning/runs/agent-runs.jsonl, merges from the history of its trunk, blocked and idle from its workflow state, in weeks to ' + W[W.length - 1].label + '. A week with fewer than ' + MIN_RUNS + ' runs is blank. Blocked and idle are kept once a day from the first day this card was read; earlier weeks are blank.',
|
|
102
128
|
tiles, rows,
|
|
103
129
|
};
|
|
104
130
|
}
|
|
@@ -107,8 +133,8 @@ function build(f) {
|
|
|
107
133
|
const git = (args) => new Promise((res) => execFile('git', args, { maxBuffer: 64 * 1024 * 1024, timeout: 60000 }, (e, out) => res(e ? null : String(out))));
|
|
108
134
|
const kept = new Map(); // root → { key, inits, inflight }
|
|
109
135
|
|
|
110
|
-
async function readCommits(root, now) {
|
|
111
|
-
const since = new Date(weeksTo(now)[0].from).toISOString();
|
|
136
|
+
async function readCommits(root, now, n = WEEKS) {
|
|
137
|
+
const since = new Date(weeksTo(now, n)[0].from).toISOString();
|
|
112
138
|
const ref = (await git(['-C', root, 'rev-parse', '--verify', '-q', 'origin/main'])) ? 'origin/main' : 'HEAD';
|
|
113
139
|
const out = await git(['-C', root, 'log', '--first-parent', '--since=' + since, '--format=%ct', ref]);
|
|
114
140
|
return out === null ? null : out.split('\n').filter(Boolean).map((x) => Number(x) * 1000);
|
|
@@ -121,7 +147,7 @@ function readRuns(root) {
|
|
|
121
147
|
}
|
|
122
148
|
|
|
123
149
|
/** The card of one repository. Runs and history are read at once; the workflow state is slow, so it is derived in the background and kept until the repository changes. */
|
|
124
|
-
async function read({ root, engine, now = Date.now() }) {
|
|
150
|
+
async function read({ root, engine, now = Date.now(), weeks = WEEKS }) {
|
|
125
151
|
const k = kept.get(root) || { key: null, inits: null, inflight: false }; kept.set(root, k);
|
|
126
152
|
const key = await BP.repoKey(root);
|
|
127
153
|
if (!k.inflight && engine && (!k.inits || k.key !== key)) {
|
|
@@ -129,10 +155,15 @@ async function read({ root, engine, now = Date.now() }) {
|
|
|
129
155
|
BP.readInitiatives({ root, engine }).then((inits) => { if (inits) { k.inits = inits; k.key = key; } }).catch(() => { }).finally(() => { k.inflight = false; });
|
|
130
156
|
}
|
|
131
157
|
const repo = path.basename(root);
|
|
132
|
-
const
|
|
158
|
+
const N = RANGES.includes(weeks) ? weeks : WEEKS;
|
|
159
|
+
let targets = {}, history = [];
|
|
160
|
+
try { targets = Rec.targets(root); } catch { /* no target file reads as none */ }
|
|
161
|
+
try { history = Rec.history(root); } catch { /* no history reads as none */ }
|
|
162
|
+
const model = build({ now, repo, weeks: N, runs: readRuns(root), commits: await readCommits(root, now, N), inits: k.inits, initsPending: !!engine && !k.inits && k.inflight, targets, history });
|
|
163
|
+
if (model.counted) { try { Rec.record(root, Object.assign({ now }, model.counted)); } catch { /* a read-only folder keeps no history */ } }
|
|
133
164
|
return model;
|
|
134
165
|
}
|
|
135
166
|
|
|
136
167
|
const forget = () => kept.clear();
|
|
137
168
|
|
|
138
|
-
module.exports = { build, read, weeksTo, forget, MIN_RUNS };
|
|
169
|
+
module.exports = { build, read, weeksTo, forget, MIN_RUNS, RANGES };
|
|
@@ -84,6 +84,7 @@ const MODULES = Object.freeze([
|
|
|
84
84
|
'routes-core-docs', // core-documents: the core documents of each level, Draft it (a core-doc run), Issue it and Drop (core-docs.jsonl)
|
|
85
85
|
'routes-custom-docs', // briefing-premium-adddoc: the documents the PM adds beyond the core set, Add a document (custom-docs.jsonl)
|
|
86
86
|
'routes-premium-dashboards', // briefing-premium-reports: the dashboards the PM makes on premium Insights (premium-dashboards.jsonl; page-press POST save)
|
|
87
|
+
'routes-board-metric-targets', // briefing-premium-metrics option C: the targets of the Board's four measures, set on premium Insights (board-metric-targets.jsonl; page-press POST save)
|
|
87
88
|
'routes-premium-charts', // premium-studio-chart: the charts the PM makes in the Insight Studio (premium-charts.jsonl; page-press POST save)
|
|
88
89
|
'routes-report-design', // report-design-studio: the design studio (describe, samples, turns, versions, This is it), cycle renders and decisions, speaker notes and pins
|
|
89
90
|
'routes-report-structure', // report-structure: the structure step (turns, versions, Use this structure, sources and their checks, dry run) and the chart store (GET /api/charts)
|