create-pmos 0.257.0 → 0.258.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 +228 -0
- package/workspace/fixtures/insights-premium-facts.js +30 -0
- package/workspace/guide/briefing-premium.md +12 -0
- package/workspace/lib/briefing-premium-agent.js +2 -2
- package/workspace/lib/insights-premium.js +133 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-briefing-premium.js +2 -1
- package/workspace/lib/routes-insights-premium.js +53 -0
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/premium-insights.css +143 -0
- package/workspace/public/pm/premium-insights.js +143 -0
- package/workspace/public/pm/premium-shell.js +2 -2
- package/workspace/public/premium-insights.html +61 -0
- package/workspace/server.js +2 -2
- package/workspace/test-files.json +2 -0
- package/workspace/test-lists/briefing-premium.json +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.258.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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T02:00:03Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T02:00:03Z"}
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-18T02:00:03Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* briefing-premium-insights-test.js — the premium Insights page (initiative briefing-premium-insights; planning/prd/briefing-premium-insights-prd.md I1 to I11).
|
|
4
|
+
* Serves the real page from the real server. Most checks answer GET /api/insights-premium with the model lib/insights-premium.js builds from a fixture
|
|
5
|
+
* (fixtures/insights-premium-facts.js); the last blocks read a scratch repository's KR metric records through the real route, and compare the page with the mockup.
|
|
6
|
+
* I1 place · I2 reading · I3 charts · I4 no series · I5 dashboards · I6 what stands out · I7 dialog · I8 reports · I9 labels · I10 empty · I11 floors and fidelity */
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const { spawn } = require('child_process');
|
|
11
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
12
|
+
const T = require('./test-run').configure({ name: 'briefing-premium-insights' });
|
|
13
|
+
const IP = require('./lib/insights-premium.js');
|
|
14
|
+
const F = require('./fixtures/insights-premium-facts.js');
|
|
15
|
+
|
|
16
|
+
const BASE = T.BASE;
|
|
17
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
18
|
+
const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { const v = await fn(); if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
19
|
+
const results = [];
|
|
20
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + extra : ''}`); };
|
|
21
|
+
let srv = null, srv2 = null, browser = null;
|
|
22
|
+
const finish = async (code) => {
|
|
23
|
+
if (browser) await browser.close().catch(() => {});
|
|
24
|
+
for (const s of [srv, srv2]) if (s) { try { s.kill('SIGKILL'); } catch { /* gone */ } }
|
|
25
|
+
T.killTmux();
|
|
26
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
27
|
+
console.log(`\n${results.length - bad}/${results.length} briefing-premium-insights assertions passed`);
|
|
28
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
29
|
+
};
|
|
30
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
31
|
+
|
|
32
|
+
const mk = (o) => IP.build(F.facts(o));
|
|
33
|
+
const MOCKUP = path.join(__dirname, '..', 'prototype', 'premium-ux-concept', 'briefing-artifact.html');
|
|
34
|
+
|
|
35
|
+
(async () => {
|
|
36
|
+
const exe = findBrowser();
|
|
37
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
38
|
+
let chromium;
|
|
39
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
40
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: path.resolve(__dirname, '..') }) });
|
|
41
|
+
await T.waitForServer(BASE);
|
|
42
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
43
|
+
|
|
44
|
+
const open = async ({ w = 1280, h = 900, theme = 'light', model = mk(), answers = null } = {}) => {
|
|
45
|
+
const ctx = await browser.newContext({ viewport: { width: w, height: h } });
|
|
46
|
+
const page = await ctx.newPage();
|
|
47
|
+
let current = model, calls = 0; const errors = [], posts = []; let thread = { ok: true, turns: [], working: false };
|
|
48
|
+
page.on('pageerror', (e) => errors.push(String((e && e.message) || e)));
|
|
49
|
+
page.on('request', (rq) => { if (rq.method() !== 'GET') posts.push(rq.method() + ' ' + new URL(rq.url()).pathname); });
|
|
50
|
+
await page.route('**/api/insights-premium*', (r) => { calls++; if (answers) { const a = answers(calls); return r.fulfill({ status: a.status, contentType: 'application/json', body: JSON.stringify(a.body) }); } return r.fulfill({ contentType: 'application/json', body: JSON.stringify({ ok: true, state: 'ready', model: current, as_of: 1 }) }); });
|
|
51
|
+
await page.route('**/api/briefing-premium/**', (r) => { const rq = r.request(); if (rq.method() === 'GET') return r.fulfill({ contentType: 'application/json', body: JSON.stringify(thread) }); return r.fulfill({ contentType: 'application/json', body: '{"ok":true}' }); });
|
|
52
|
+
await page.goto(BASE + '/premium-insights.html?theme=' + theme);
|
|
53
|
+
const up = await until(() => page.evaluate(() => document.querySelectorAll('#dashBody .mch').length > 0 || /could not be read/.test(document.querySelector('#snap').textContent) || document.querySelectorAll('#dashBody .nempty').length > 0), 20000);
|
|
54
|
+
return { ctx, page, errors, posts, up, calls: () => calls, setModel: (m) => { current = m; }, setThread: (t) => { thread = t; } };
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const A = await open();
|
|
58
|
+
ok('0 the page draws the charts', A.up);
|
|
59
|
+
if (!A.up) return finish(1);
|
|
60
|
+
const p = A.page, M = mk();
|
|
61
|
+
const txt = (s) => p.evaluate((q) => (document.querySelector(q) || {}).textContent || '', s);
|
|
62
|
+
|
|
63
|
+
/* I1 */
|
|
64
|
+
const rail = await p.evaluate(() => ({ names: [...document.querySelectorAll('.rail .pl')].map((b) => b.textContent.trim()), cur: document.querySelector('.rail [aria-current="page"]').textContent.trim(), pi: getComputedStyle(document.querySelector('.rail')).getPropertyValue('--pi').trim(), title: document.title, name: document.querySelector('#crBoard').textContent, sw: document.querySelector('#crSw').hidden }));
|
|
65
|
+
ok('I1 the rail names four places, Insights is current, the board is named and has no switcher for one board', rail.names.join() === 'Briefing,My work,Board,Insights' && rail.cur === 'Insights' && rail.pi === '3' && rail.name === 'pmos' && rail.sw, JSON.stringify(rail));
|
|
66
|
+
ok('I1 the page is served at /premium-insights and /premium-insights.html', (await fetch(BASE + '/premium-insights')).status === 200 && (await fetch(BASE + '/premium-insights.html')).status === 200);
|
|
67
|
+
for (const [go, re] of [['brief', /\/premium\.html$/], ['work', /\/premium-work\.html$/], ['init', /\/premium-board\.html$/]]) {
|
|
68
|
+
const r2 = await open(); await r2.page.locator(`.rail [data-go="${go}"]`).click();
|
|
69
|
+
ok(`I1 the ${go} button opens its premium page`, await until(() => re.test(r2.page.url()), 5000), r2.page.url());
|
|
70
|
+
await r2.ctx.close();
|
|
71
|
+
}
|
|
72
|
+
{ const r2 = await open(); const before = r2.page.url(); await r2.page.locator('.rail [data-go="rep"]').click(); await sleep(300); ok('I1 the Insights button opens nothing else: it is the page already', r2.page.url() === before); await r2.ctx.close(); }
|
|
73
|
+
|
|
74
|
+
/* I3 charts */
|
|
75
|
+
const ch = await p.evaluate(() => ({ n: document.querySelectorAll('#dashBody .mch').length, tiles: [...document.querySelectorAll('#dashBody .mch')].map((t) => ({ lab: t.querySelector('.mlab').firstChild.textContent, chip: t.querySelector('.mchip').textContent, val: t.querySelector('.mval').textContent, cap: t.querySelector('.mwk').textContent, tg: !!t.querySelector('.tg'), foot: t.querySelector('.mfoot').textContent, pts: t.querySelector('.ln2').getAttribute('d').split('L').length, off: t.classList.contains('off') })) }));
|
|
76
|
+
ok('I3 one chart for each KR metric with two or more readings, with its latest value, chip and target', ch.n === 3 && ch.tiles[0].lab === 'Partner activation' && ch.tiles[0].val === '28%' && ch.tiles[0].chip === 'Behind its line' && /target 50%/.test(ch.tiles[0].cap) && ch.tiles[0].tg && ch.tiles[1].chip === 'On its line' && !ch.tiles[1].off && ch.tiles[2].val === '9 days', JSON.stringify(ch.tiles[0]));
|
|
77
|
+
ok('I3 the line has exactly as many points as the record has readings (a gap is not filled)', ch.tiles[0].pts === 4 && ch.tiles[1].pts === 4);
|
|
78
|
+
ok('I3 the foot names the first and last date and says the dashed line is the target', /1 Jul/.test(ch.tiles[0].foot) && /15 Oct/.test(ch.tiles[0].foot) && /dashed line is the target/.test(ch.tiles[0].foot), ch.tiles[0].foot);
|
|
79
|
+
{
|
|
80
|
+
const gap = await p.evaluate(() => { const t = document.querySelector('#dashBody .mch'); const d = t.querySelector('.ln2').getAttribute('d').split('L').map((s) => parseFloat(s.replace('M', ''))); return d; });
|
|
81
|
+
ok('I3 the x position follows the date: the long wait between 1 Aug and 1 Oct is the widest step', (gap[2] - gap[1]) > 1.9 * (gap[1] - gap[0]) && (gap[3] - gap[2]) < (gap[1] - gap[0]) / 2, JSON.stringify(gap));
|
|
82
|
+
}
|
|
83
|
+
// hover and keys move the reading
|
|
84
|
+
{
|
|
85
|
+
const t = p.locator('#dashBody .mch').first(); await t.focus(); await p.keyboard.press('ArrowLeft');
|
|
86
|
+
const a = await p.evaluate(() => { const t = document.querySelector('#dashBody .mch'); return { v: t.querySelector('.mval').textContent, c: t.querySelector('.mwk').textContent, hv: t.classList.contains('hv') }; });
|
|
87
|
+
ok('I3 the left arrow reads the reading before the last, with its date', a.v === '30%' && /1 Oct/.test(a.c) && a.hv, JSON.stringify(a));
|
|
88
|
+
await p.keyboard.press('ArrowRight');
|
|
89
|
+
ok('I3 the right arrow returns to the latest reading', (await txt('#dashBody .mch .mval')) === '28%');
|
|
90
|
+
}
|
|
91
|
+
/* I4 no series */
|
|
92
|
+
const ns = await p.evaluate(() => [...document.querySelectorAll('#dashBody .ngl, #dashBody .dplist .nempty')].map((e) => e.textContent.replace(/\s+/g, ' ').trim()));
|
|
93
|
+
ok('I4 a measure with one reading or none is listed with the record\'s reason and not drawn', ns[0] === 'No series recorded · 2' && /Partner NPS.*Only one reading is recorded\. It is not drawn\./.test(ns[1]) && /Monthly churn.*No reading is recorded yet\./.test(ns[2]), JSON.stringify(ns));
|
|
94
|
+
/* I5 dashboards */
|
|
95
|
+
const tabs = await p.evaluate(() => [...document.querySelectorAll('#dashTabs button')].map((b) => b.textContent + ':' + b.getAttribute('aria-pressed')));
|
|
96
|
+
ok('I5 dashboards are the pillars the records name, all measures first', tabs.join() === 'All measures:true,Growth:false,Reliability:false', tabs.join());
|
|
97
|
+
await p.click('#dashTabs [data-d="p:Reliability"]');
|
|
98
|
+
ok('I5 choosing a pillar shows only its charts and one count', (await p.evaluate(() => document.querySelectorAll('#dashBody .mch').length)) === 1 && /1 of 1.*on their line/.test(await txt('#dashBody .mhint')) && (await p.evaluate(() => document.querySelector('#dashBody .mprog').getAttribute('aria-valuenow'))) === '1');
|
|
99
|
+
await p.click('#dashTabs [data-d="all"]');
|
|
100
|
+
const hint = await txt('#dashBody .mhint');
|
|
101
|
+
ok('I5 the card counts the measures behind their line from the records: 1 of 3 on their line', /1 of 3 on their line\. 2 are behind it\./.test(hint.replace(/\s+/g, ' ')), hint);
|
|
102
|
+
ok('I5 the dock counts the same two', (await txt('#dN')) === '2' && /measures off their line/.test(await txt('#dLab')) && /First Time to first call/.test(await txt('#dNext')));
|
|
103
|
+
/* I6 */
|
|
104
|
+
const fd = await p.evaluate(() => [...document.querySelectorAll('.nfd li')].map((li) => li.className + ': ' + li.textContent.replace(/\s+/g, ' ').trim()));
|
|
105
|
+
ok('I6 what stands out is up to three plain sentences with numbers from the series', fd.length >= 1 && fd.length <= 3 && /^stuck: Time to first call has been behind its line at three readings in a row/.test(fd[0]) && fd.some((x) => /from 30% to 28%/.test(x)), JSON.stringify(fd));
|
|
106
|
+
ok('I6 no sentence forecasts or gives a cause', !fd.some((x) => /forecast|will reach|because|caused|expected to/i.test(x)));
|
|
107
|
+
/* I7 dialog */
|
|
108
|
+
await p.locator('.nfd .nfr').first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
|
|
109
|
+
const dl = await p.evaluate(() => ({ title: document.querySelector('#dTitle').textContent, eye: document.querySelector('#dEye').textContent, kv: [...document.querySelectorAll('#oMain .kv2')].map((k) => k.textContent.replace(/\s+/g, ' ')).join(' | '), path: document.querySelector('#oMain .dpath').textContent, btn: document.querySelectorAll('#oMain button').length, hold: document.querySelector('#holdWhy').textContent, inert: ['.rail', 'main.stage', '#dock'].every((s) => document.querySelector(s).inert) }));
|
|
110
|
+
ok('I7 a finding opens the standard dialog: the record\'s numbers, its readings with dates, its path, no press', dl.title === 'Time to first call' && /real data/.test(dl.eye) && /Target3 days by 31 Dec/.test(dl.kv) && /15 Oct9 days/.test(dl.kv) && dl.path === 'planning/records/kr-metrics.jsonl' && dl.btn === 0 && /Nothing here changes a record/.test(dl.hold) && dl.inert, JSON.stringify(dl));
|
|
111
|
+
ok('I7 Escape closes it and focus returns', (await p.keyboard.press('Escape'), await until(() => p.evaluate(() => !document.querySelector('#dlg').classList.contains('on')))));
|
|
112
|
+
await p.locator('#dashBody [data-open]').filter({ hasText: 'Details' }).first().click(); await until(() => p.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(300);
|
|
113
|
+
ok('I7 the Details link of a chart opens that chart\'s dialog', (await txt('#dTitle')) === 'Partner activation');
|
|
114
|
+
await p.keyboard.press('Escape'); await sleep(300);
|
|
115
|
+
/* the agent is the read-only one: a question goes to the briefing route and nothing else posts */
|
|
116
|
+
{
|
|
117
|
+
const R = await open(); const posts = [];
|
|
118
|
+
await R.page.route('**/api/briefing-premium/ask', (r) => { posts.push(JSON.parse(r.request().postData() || '{}')); r.fulfill({ contentType: 'application/json', body: '{"ok":true,"id":"bq-1","state":"working"}' }); });
|
|
119
|
+
await R.page.locator('#dashBody [data-open]').filter({ hasText: 'Details' }).first().click(); await until(() => R.page.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(400);
|
|
120
|
+
await R.page.fill('#askIn', 'Why is this behind?'); await R.page.keyboard.press('Enter'); await sleep(500);
|
|
121
|
+
ok('I7 a question goes to the read-only agent with the chart\'s key, and the page posts nothing else', posts.length === 1 && posts[0].key === 'ins:krm-act' && R.posts.every((x) => /briefing-premium\/ask$/.test(x)), JSON.stringify([posts, R.posts]));
|
|
122
|
+
await R.ctx.close();
|
|
123
|
+
}
|
|
124
|
+
/* I8 reports */
|
|
125
|
+
const rp = await p.evaluate(() => ({ rows: [...document.querySelectorAll('#repBody .dmr')].map((r) => r.querySelector('.dmn b').textContent + ' / ' + r.querySelector('.s').textContent), note: document.querySelector('#repBody .mhint').textContent, cap: document.querySelector('#repCap').textContent }));
|
|
126
|
+
ok('I8 the Reports card lists the report files: cadence, slot, draft or issued', rp.rows.join() === 'biweekly · 14 Oct / Draft,monthly · 30 Sep / Issued 1 Oct' && /Nothing is sent from here/.test(rp.note) && rp.cap === '2', JSON.stringify(rp));
|
|
127
|
+
{ const R = await open(); await R.page.locator('#repBody .dmo').first().click(); ok('I8 a report opens the console\'s Reports tab to read it', await until(() => /\/c3\.html\?tab=rep/.test(R.page.url()), 5000), R.page.url()); await R.ctx.close(); }
|
|
128
|
+
/* I9 labels */
|
|
129
|
+
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: the Insight Studio/.test(await txt('#foot')) && /Real data/.test(await txt('#snap')));
|
|
130
|
+
ok('I9 the page makes no write request on its own', A.posts.length === 0, A.posts.join());
|
|
131
|
+
/* I10 empty */
|
|
132
|
+
{
|
|
133
|
+
const R = await open({ model: mk({ outcomes: [] }) });
|
|
134
|
+
ok('I10 with no KR metric the page says so in one sentence and the Reports card still lists its files', await R.page.evaluate(() => /No KR metric is recorded/.test(document.querySelector('#brief').textContent) && /No KR metric is recorded for this workspace/.test(document.querySelector('#dashBody').textContent) && document.querySelectorAll('#repBody .dmr').length === 2 && document.querySelectorAll('#dashBody .mch').length === 0));
|
|
135
|
+
await R.ctx.close();
|
|
136
|
+
const R2 = await open({ model: mk({ reportsOk: false, reports: [], missing: ['reports'] }) });
|
|
137
|
+
ok('I10 reports that could not be read are said to be unread, not empty', await R2.page.evaluate(() => /report files could not be read/.test(document.querySelector('#repBody').textContent) && /not read: reports/.test(document.querySelector('#snap').textContent)));
|
|
138
|
+
await R2.ctx.close();
|
|
139
|
+
}
|
|
140
|
+
/* I2 failed read */
|
|
141
|
+
{
|
|
142
|
+
const c2 = await browser.newContext({ viewport: { width: 1280, height: 900 } }), p2 = await c2.newPage();
|
|
143
|
+
await p2.route('**/api/insights-premium*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: JSON.stringify({ ok: false, state: 'error', error: 'the KR metric records could not be read: boom' }) }));
|
|
144
|
+
await p2.goto(BASE + '/premium-insights.html');
|
|
145
|
+
ok('I2 a failed read says why and draws nothing', await until(() => p2.evaluate(() => /The reason: the KR metric records could not be read: boom/.test(document.querySelector('#brief').textContent) && document.querySelectorAll('#dashBody .mch').length === 0), 4000));
|
|
146
|
+
await c2.close();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* I11 floors */
|
|
150
|
+
for (const theme of ['light', 'dark']) {
|
|
151
|
+
const R = await open({ w: 390, h: 844, theme }), q = R.page;
|
|
152
|
+
const m = await q.evaluate(() => { const small = [...document.querySelectorAll('#dashTabs button, #dashBody .lk, #dashBody .nfr, #repBody .dmo, #repBody .lk, #crSw')].filter((b) => !b.closest('[hidden]') && b.getBoundingClientRect().height > 0 && b.getBoundingClientRect().height < 44).map((b) => b.className + ':' + Math.round(b.getBoundingClientRect().height)); return { over: document.documentElement.scrollWidth > innerWidth + 1, small }; });
|
|
153
|
+
ok(`I11 at 390 px (${theme}) the page has no sideways scroll and every control is 44 px`, !m.over && m.small.length === 0, JSON.stringify(m));
|
|
154
|
+
await q.locator('#dashBody .nfr').first().click(); await until(() => q.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(900);
|
|
155
|
+
const g = await q.evaluate(() => { const r = document.querySelector('#dlg').getBoundingClientRect(); return { l: Math.round(r.left), w: Math.round(r.width), vw: innerWidth, tabs: getComputedStyle(document.querySelector('#dTabs')).display }; });
|
|
156
|
+
ok(`I11 at 390 px (${theme}) the dialog is full width and its tab strip is hidden`, g.l === 0 && g.w === g.vw && g.tabs === 'none', JSON.stringify(g));
|
|
157
|
+
await R.ctx.close();
|
|
158
|
+
}
|
|
159
|
+
{
|
|
160
|
+
const R = await open(); await R.page.locator('#dashBody .lk').first().focus(); await R.page.keyboard.press('Enter'); await until(() => R.page.evaluate(() => document.querySelector('#dlg').classList.contains('on'))); await sleep(500);
|
|
161
|
+
ok('I11 the page behind a dialog is inert, Escape closes it and focus returns to the link', await R.page.evaluate(() => ['.rail', 'main.stage', '#dock'].every((s) => document.querySelector(s).inert)) && (await R.page.keyboard.press('Escape'), await until(() => R.page.evaluate(() => !document.querySelector('#dlg').classList.contains('on') && document.activeElement.classList.contains('lk')))));
|
|
162
|
+
await R.ctx.close();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/* the real routes: this repository holds no KR metric record, and a scratch repository holds one with a gap */
|
|
166
|
+
{
|
|
167
|
+
const r = await fetch(BASE + '/api/insights-premium'); const j = await r.json();
|
|
168
|
+
ok('E1 the real route answers ready for this repository, with no demo data', r.status === 200 && j.ok && j.state === 'ready' && !/demo/i.test(JSON.stringify(j.model.header)), JSON.stringify(j).slice(0, 200));
|
|
169
|
+
ok('E2 this repository holds no KR metric record, so the model draws nothing and says so', j.model.charts.length === 0 && j.model.counts.total === 0 && /^No KR metric is recorded/.test(j.model.empty), JSON.stringify(j.model.counts));
|
|
170
|
+
const post = await fetch(BASE + '/api/insights-premium', { method: 'POST', headers: await T.pressHeaders(BASE), body: '{}' }).then((x) => x.status);
|
|
171
|
+
ok('E3 the model route is read-only', post === 405, String(post));
|
|
172
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), pg = await ctx.newPage(), errs = [];
|
|
173
|
+
pg.on('pageerror', (e) => errs.push(String(e)));
|
|
174
|
+
await pg.goto(BASE + '/premium-insights.html');
|
|
175
|
+
ok('E4 the real page says there is nothing to chart, and has no script error', await until(() => pg.evaluate(() => /No KR metric is recorded/.test(document.querySelector('#dashBody').textContent)), 20000) && errs.length === 0, errs.join(' | '));
|
|
176
|
+
await ctx.close();
|
|
177
|
+
}
|
|
178
|
+
{
|
|
179
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'ins-repo-'));
|
|
180
|
+
fs.mkdirSync(path.join(dir, 'planning', 'records'), { recursive: true });
|
|
181
|
+
const L = [{ id: '1', kind: 'add', rid: 'krm-a', fields: { metric: 'Partner activation', baseline: 20, target: 50, by: '2026-12-31', pillar: 'Growth', unit: '%' } },
|
|
182
|
+
{ id: '2', kind: 'reading', rid: 'krm-a', fields: { at: '2026-07-01', value: 20 } }, { id: '3', kind: 'reading', rid: 'krm-a', fields: { at: '2026-08-01', value: 24 } }, { id: '4', kind: 'reading', rid: 'krm-a', fields: { at: '2026-10-01', value: 30 } },
|
|
183
|
+
{ id: '5', kind: 'add', rid: 'krm-b', fields: { metric: 'Lonely', baseline: 1, target: 2, by: '2026-12-31' } }, { id: '6', kind: 'reading', rid: 'krm-b', fields: { at: '2026-10-01', value: 1 } }];
|
|
184
|
+
fs.writeFileSync(path.join(dir, 'planning', 'records', 'kr-metrics.jsonl'), L.map((x) => JSON.stringify(x)).join('\n') + '\n');
|
|
185
|
+
const port2 = T.port(), base2 = `http://${require('./test-run').HOST}:${port2}`;
|
|
186
|
+
srv2 = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(port2), PMOS_SELF_ROOT: dir, PMOS_STATE_DIR: fs.mkdtempSync(path.join(os.tmpdir(), 'ins-state-')) }) });
|
|
187
|
+
await T.waitForServer(base2);
|
|
188
|
+
const j = await (await fetch(base2 + '/api/insights-premium')).json(); const m = j.model;
|
|
189
|
+
ok('E5 a scratch repository\'s KR metric records reach the page model: one chart of three readings, one measure without a series', !!m && m.charts.length === 1 && m.charts[0].pts.length === 3 && m.charts[0].v === '30%' && m.noSeries.length === 1 && m.noSeries[0].why === 'Only one reading is recorded.', JSON.stringify(m && m.counts));
|
|
190
|
+
ok('E6 the real model keeps the gap: the 1 Aug to 1 Oct step is wider than 1 Jul to 1 Aug', !!m && m.charts[0].pts[2].fx - m.charts[0].pts[1].fx > 1.9 * (m.charts[0].pts[1].fx - m.charts[0].pts[0].fx));
|
|
191
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 900 } }), pg = await ctx.newPage(), errs = [];
|
|
192
|
+
pg.on('pageerror', (e) => errs.push(String(e)));
|
|
193
|
+
await pg.goto(base2 + '/premium-insights.html');
|
|
194
|
+
ok('E7 the real page draws that chart with the record\'s numbers and no script error', await until(() => pg.evaluate(() => { const t = document.querySelector('#dashBody .mch'); return !!t && t.querySelector('.mval').textContent === '30%' && /Partner activation/.test(t.textContent); }), 20000) && errs.length === 0, errs.join(' | '));
|
|
195
|
+
await ctx.close();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* I11 fidelity against the mockup */
|
|
199
|
+
if (!fs.existsSync(MOCKUP)) ok('I11 the mockup is in the repository', false, MOCKUP);
|
|
200
|
+
else {
|
|
201
|
+
const PAIRS = [['rail', '.rail', '.rail'], ['card', '.nlc .card', '.nlc .card'], ['heading', '#hNd', '#hDash'], ['band', '.nfd', '.nfd'], ['bandlabel', '.nfd .label', '.nfd .label'], ['finding', '.nfd .nfr', '.nfd .nfr'], ['findtext', '.nfd .nft', '.nfd .nft'], ['dot', '.nfd .nfdot', '.nfd .nfdot'],
|
|
202
|
+
['hint', '.mhint', '.mhint'], ['grid', '.ngrid', '.ngrid'], ['tile', '.ngrid .mt1', '.ngrid .mt1'], ['tlabel', '.ngrid .mlab', '.ngrid .mlab'], ['chip', '.ngrid .mchip', '.ngrid .mchip'], ['value', '.ngrid .mval', '.ngrid .mval'], ['caption', '.ngrid .mwk', '.ngrid .mwk'],
|
|
203
|
+
['foot', '.ngrid .mfoot', '.ngrid .mfoot'], ['link', '.ntf .lk', '.ntf .lk'], ['repcard', '.nlr .card', '.nlr .card'], ['dock', '.dock', '.dock']];
|
|
204
|
+
const SKIP_W = ['card', 'band', 'bandlabel', 'finding', 'findtext', 'hint', 'tile', 'tlabel', 'chip', 'value', 'caption', 'foot', 'link', 'heading', 'repcard', 'grid'];
|
|
205
|
+
const PROPS = ['fontSize', 'fontWeight', 'fontFamily', 'color', 'backgroundColor', 'borderRadius', 'paddingTop', 'paddingLeft', 'letterSpacing', 'lineHeight', 'boxShadow', 'backdropFilter', 'borderTopColor'];
|
|
206
|
+
const grab = (pg, which) => pg.evaluate(([pairs, props, idx]) => { const o = {}; for (const pr of pairs) { const n = pr[0], s0 = pr[idx]; const s = (n === 'rail' || n === 'dock') ? s0 : 'main.stage:not([hidden]) ' + s0; const e = document.querySelector(s); if (!e) { o[n] = null; continue; } const cs = getComputedStyle(e), r = e.getBoundingClientRect(), v = { left: Math.round(r.left), width: Math.round(r.width) }; props.forEach((k) => { v[k] = cs[k]; }); o[n] = v; } return o; }, [PAIRS, PROPS, which]);
|
|
207
|
+
for (const [w, h] of [[1280, 900], [390, 844]]) for (const th of ['light', 'dark']) {
|
|
208
|
+
const m = await (await browser.newContext({ viewport: { width: w, height: h } })).newPage();
|
|
209
|
+
await m.goto('file://' + MOCKUP);
|
|
210
|
+
await until(() => m.evaluate(() => document.querySelectorAll('#rank .rr').length > 0));
|
|
211
|
+
await m.evaluate((t) => { document.documentElement.dataset.theme = t; document.querySelector('.pl[data-p="ins"]').click(); }, th);
|
|
212
|
+
await until(() => m.evaluate(() => document.querySelectorAll('#nMain .mt1').length > 0)); await sleep(900);
|
|
213
|
+
const R = await open({ w, h, theme: th }); await sleep(500);
|
|
214
|
+
const a = await grab(m, 1), c = await grab(R.page, 2), diffs = [];
|
|
215
|
+
for (const [n] of PAIRS) {
|
|
216
|
+
if (!a[n] || !c[n]) { diffs.push(n + ' missing'); continue; }
|
|
217
|
+
for (const k of Object.keys(a[n])) {
|
|
218
|
+
const geom = k === 'left' || k === 'width';
|
|
219
|
+
if (geom && (SKIP_W.includes(n) && k === 'width' || ['findtext', 'tlabel', 'chip', 'value', 'caption', 'foot', 'link', 'dot', 'finding', 'hint', 'heading'].includes(n) && k === 'left')) continue;
|
|
220
|
+
if (geom ? Math.abs(a[n][k] - c[n][k]) > 2 : a[n][k] !== c[n][k]) diffs.push(`${n}.${k} ${a[n][k]} | ${c[n][k]}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
ok(`I11 styles and geometry match the mockup at ${w} px, ${th}`, diffs.length === 0, diffs.join(' ; '));
|
|
224
|
+
await m.context().close(); await R.ctx.close();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return finish();
|
|
228
|
+
})().catch((e) => { console.error(e); finish(1); });
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* fixtures/insights-premium-facts.js — the facts lib/insights-premium.js builds from, for a plausible workspace on 18 Oct 2026. Shapes follow the answers of
|
|
3
|
+
* lib/routes-c3-strategy.js (outcomes) and lib/routes-reports.js (reports). Five KR metrics: three with a series, one with a single reading, one with none.
|
|
4
|
+
* The Activation series has a month with no reading in it, so the page must draw a gap and not a zero. */
|
|
5
|
+
const NOW = new Date(2026, 9, 18, 9, 0).getTime();
|
|
6
|
+
const rd = (at, v) => ({ at, v });
|
|
7
|
+
const OUTCOMES = [
|
|
8
|
+
{ id: 'krm-act', name: 'Partner activation', pillar: 'Growth', unit: '%', start: 20, target: 50, by: '2026-12-31', now: 28, expected: 38, shortfall: 0.33, status: 'drift', pivot: false, reason: '',
|
|
9
|
+
readings: [rd('2026-07-01', 20), rd('2026-08-01', 24), rd('2026-10-01', 30), rd('2026-10-15', 28)] },
|
|
10
|
+
{ id: 'krm-up', name: 'Partner uptime', pillar: 'Reliability', unit: '%', start: 99, target: 99.9, by: '2026-12-31', now: 99.6, expected: 99.5, shortfall: -0.1, status: 'ok', pivot: false, reason: '',
|
|
11
|
+
readings: [rd('2026-09-01', 99.2), rd('2026-09-15', 99.4), rd('2026-10-01', 99.5), rd('2026-10-15', 99.6)] },
|
|
12
|
+
{ id: 'krm-ttfc', name: 'Time to first call', pillar: 'Growth', unit: 'days', start: 10, target: 3, by: '2026-12-31', now: 9, expected: 6, shortfall: 0.43, status: 'drift', pivot: true, reason: '',
|
|
13
|
+
readings: [rd('2026-09-01', 8), rd('2026-09-15', 8.5), rd('2026-10-01', 8.8), rd('2026-10-15', 9)] },
|
|
14
|
+
{ id: 'krm-nps', name: 'Partner NPS', pillar: 'Growth', unit: '', start: 10, target: 40, by: '2026-12-31', now: 12, expected: 30, shortfall: 0.6, status: 'off', pivot: false, reason: '',
|
|
15
|
+
readings: [rd('2026-10-01', 12)] },
|
|
16
|
+
{ id: 'krm-churn', name: 'Monthly churn', pillar: 'Reliability', unit: '%', start: 4, target: 2, by: '2026-12-31', now: null, expected: null, status: 'unscored', pivot: false, reason: 'No reading is recorded yet.',
|
|
17
|
+
readings: [] },
|
|
18
|
+
];
|
|
19
|
+
const REPORTS = [
|
|
20
|
+
{ cadence: 'biweekly', slot: '2026-10-14', path: 'planning/reports/biweekly/2026-10-14.md', status: 'draft', bytes: 900, edited: false, issued: null },
|
|
21
|
+
{ cadence: 'monthly', slot: '2026-09-30', path: 'planning/reports/monthly/2026-09-30.md', status: null, bytes: 1200, edited: false, issued: { at: '2026-10-01T09:00:00Z', by: 'wawan', via: 'ui', sha: 'a'.repeat(40) } },
|
|
22
|
+
];
|
|
23
|
+
function facts(o = {}) {
|
|
24
|
+
return {
|
|
25
|
+
now: NOW, pending: false, missing: [],
|
|
26
|
+
board: { ws: 'w1', id: 'w1', name: 'pmos' }, boards: [{ ws: 'w1', id: 'w1', name: 'pmos' }],
|
|
27
|
+
outcomes: OUTCOMES.map((x) => ({ ...x, readings: x.readings.map((r) => ({ ...r })) })), reports: REPORTS.map((r) => ({ ...r })), reportsOk: true, ...o,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
module.exports = { NOW, facts, OUTCOMES, REPORTS };
|
|
@@ -163,3 +163,15 @@ The initiative page is at `/premium-initiative.html?id=<initiative>`. A click on
|
|
|
163
163
|
- **The document sheet.** A document that has a file opens in a dialog with **Read** (the file's text, its front matter as a grid and an outline), **Edit** (the file as plain Markdown, a reason, and **Save**), **Proposals** (**Ask the agent**, the open proposals with **Accept** and **Reject**, and the closed ones), **Edit log** (the revisions and other entries of the document sheet) and **Health** (the document-health checks; a check with no input is not counted). The file changes only when you press Save or Accept, and every change is kept in the Edit log with its reason. Save and Reject need a reason. A proposal made on text that has since changed shows which sections are out of date and cannot take them. The agent beside the sheet still only reads. Bold and undo buttons, Issue and Drop are not built on this page.
|
|
164
164
|
|
|
165
165
|
Not drawn, because PMOS holds no record for them: the mockup's demo tasks, its Jira data, and the owner "Agents" on a requirement.
|
|
166
|
+
|
|
167
|
+
## Insights
|
|
168
|
+
|
|
169
|
+
Insights is the fourth place on the rail, at `/premium-insights.html`. It reads the KR metric records of the board's workspace and the report files the console's Reports tab lists. It presses nothing and writes nothing.
|
|
170
|
+
|
|
171
|
+
- **Charts.** One chart for each KR metric that holds at least two readings. The line runs through the readings at their dates, so a month with no reading is a gap and not a zero. The dashed line is the metric's target. The chip is the record's own line status: on its line, behind it, or well behind it. Pressing a chart, or its Details link, opens the metric's record in the dialog with the read-only agent beside it.
|
|
172
|
+
- **Dashboards.** The records hold no dashboard, so the groups are the pillars the metrics name, with all measures first. The switch shows only when there is more than one pillar.
|
|
173
|
+
- **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.
|
|
174
|
+
- **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
|
|
175
|
+
- **Reports.** The report files of the workspace, with cadence, slot and whether each is a draft or issued. Pressing one opens the console's Reports tab, where it is read, edited or issued. Nothing is sent from this page.
|
|
176
|
+
|
|
177
|
+
Not built: the Insight Studio (making your own chart, dashboard or report by conversation), run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), saved dashboards and their layout, and any measure no record holds. KR metric records belong to a workspace, so every board of a workspace shows the same charts.
|
|
@@ -16,7 +16,7 @@ const crypto = require('crypto');
|
|
|
16
16
|
const headless = require('./headless.js');
|
|
17
17
|
|
|
18
18
|
const THREADS = 'briefing-premium-threads.jsonl';
|
|
19
|
-
const KEY_RE = /^(decision|blocked|waited|src|ev|work|board|init|doc):[A-Za-z0-9][A-Za-z0-9._:-]{0,100}$/;
|
|
19
|
+
const KEY_RE = /^(decision|blocked|waited|src|ev|work|board|init|doc|ins):[A-Za-z0-9][A-Za-z0-9._:-]{0,100}$/;
|
|
20
20
|
const MAX_Q = 2000, MAX_A = 6000, MAX_QUESTIONS = 40, PROMPT_TURNS = 8;
|
|
21
21
|
const fail = (status, error) => ({ status, body: { ok: false, error } });
|
|
22
22
|
const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
@@ -49,7 +49,7 @@ function threadOf(runtimeDir, key, now = Date.now()) {
|
|
|
49
49
|
/** The row as the server's own model has it, plus the files an answer should start from. null when the key names no row on the page. */
|
|
50
50
|
function rowFor(model, key) {
|
|
51
51
|
if (!model || !KEY_RE.test(String(key || ''))) return null;
|
|
52
|
-
if (/^(work|board|init|doc):/.test(key)) { // a My work item, a Board initiative, an initiative page or one of its documents: the item's own record is the context
|
|
52
|
+
if (/^(work|board|init|doc|ins):/.test(key)) { // a My work item, a Board initiative, an Insights measure, an initiative page or one of its documents: the item's own record is the context
|
|
53
53
|
const w = (model.rows || []).find((r) => r.key === key); if (!w) return null;
|
|
54
54
|
const d = w.dialog || {};
|
|
55
55
|
return { title: clip(w.title, 160), subject: clip(w.sub, 240), say: clip(d.say, 600), facts: (d.facts || []).slice(0, 12).map(([a, b]) => clip(a, 40) + ': ' + clip(b, 240)), files: (d.files || []).filter((f) => SAFE_PATH.test(f) && !f.includes('..')).slice(0, 4) };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* lib/insights-premium.js — the premium Insights page's model, built from the KR metric records and the report files the console's Reports tab reads
|
|
3
|
+
* (initiative briefing-premium-insights).
|
|
4
|
+
*
|
|
5
|
+
* build(facts) → model PURE. facts = { now, board, boards, outcomes, reports, reportsOk, missing[] }
|
|
6
|
+
* peekModel() → the last model built, for the agent to find a chart in (null before the first)
|
|
7
|
+
*
|
|
8
|
+
* facts come from the routes of lib/routes-c3-strategy.js and lib/routes-reports.js:
|
|
9
|
+
* board { ws, id, name } the board the page shows (KR metric records belong to its workspace, PRD D2)
|
|
10
|
+
* outcomes GET /api/c3-strategy → .outcomes [{ id, name, pillar, unit, start (the baseline), target, by, now, expected, shortfall, status, pivot, reason, readings: [{ at, v }] }]
|
|
11
|
+
* reports GET /api/report → .reports [{ cadence, slot, path, status, issued: { at, by } | null, edited }]
|
|
12
|
+
*
|
|
13
|
+
* THE RULE THE FILE FOLLOWS (as the other premium models): a number, chip, line or date is made only from a field of a record. A measure with fewer than two
|
|
14
|
+
* readings gets no chart and says why. The time between two readings is drawn as the time it is, so a gap in a series shows as a gap and never as a zero. No
|
|
15
|
+
* forecast is drawn and no cause is given. Run-based series (corrections per 100 runs, merges a week) belong to the Board's Metrics card and are not built here (PRD decision 4). */
|
|
16
|
+
|
|
17
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
18
|
+
const isoDay = (v) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(v || '')); return m ? Date.UTC(+m[1], +m[2] - 1, +m[3]) : null; };
|
|
19
|
+
const shortDate = (v) => { const t = isoDay(v); if (t === null) return ''; const d = new Date(t); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()]; };
|
|
20
|
+
const clip = (s, n) => { s = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return s.length > n ? s.slice(0, n - 1).trimEnd() + '…' : s; };
|
|
21
|
+
const fin = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
22
|
+
const r2 = (v) => Math.round(v * 100) / 100;
|
|
23
|
+
const num = (v, unit) => { const u = String(unit || '').trim(), s = String(r2(v)); return u ? (/^[A-Za-z]/.test(u) ? s + ' ' + u : s + u) : s; };
|
|
24
|
+
const CHIP = { ok: ['On its line', 'ok'], drift: ['Behind its line', 'warn'], off: ['Well behind its line', 'bad'] };
|
|
25
|
+
const MAX_FINDINGS = 3;
|
|
26
|
+
const KR_FILE = 'planning/records/kr-metrics.jsonl';
|
|
27
|
+
|
|
28
|
+
let last = null;
|
|
29
|
+
const peekModel = () => last;
|
|
30
|
+
|
|
31
|
+
/** One KR metric outcome with two or more readings → a chart. null when it has no series. */
|
|
32
|
+
function chartOf(o) {
|
|
33
|
+
const rs = (o.readings || []).filter((x) => x && fin(x.v) && isoDay(x.at) !== null);
|
|
34
|
+
if (rs.length < 2) return null;
|
|
35
|
+
const u = o.unit || '', tgt = fin(o.target) ? o.target : null, base = fin(o.start) ? o.start : null;
|
|
36
|
+
const t0 = isoDay(rs[0].at), t1 = isoDay(rs[rs.length - 1].at), span = t1 - t0 || 1;
|
|
37
|
+
const ys = rs.map((x) => x.v).concat(tgt !== null ? [tgt] : []);
|
|
38
|
+
const lo = Math.min(...ys), hi = Math.max(...ys), range = hi - lo || 1;
|
|
39
|
+
const pts = rs.map((x) => ({ at: x.at, v: x.v, fx: (isoDay(x.at) - t0) / span, fy: (x.v - lo) / range, txt: num(x.v, u), d: shortDate(x.at) }));
|
|
40
|
+
const now = rs[rs.length - 1].v, prev = rs[rs.length - 2].v;
|
|
41
|
+
const dir = tgt !== null && base !== null && tgt !== base ? Math.sign(tgt - base) : tgt !== null ? Math.sign(tgt - now) : 0;
|
|
42
|
+
const step = now - prev, good = dir ? step * dir > 0 : null;
|
|
43
|
+
const chip = CHIP[o.status] || ['No line scored', 'mut'];
|
|
44
|
+
const rows = [
|
|
45
|
+
['Latest reading', num(now, u) + ' on ' + shortDate(rs[rs.length - 1].at)],
|
|
46
|
+
tgt !== null ? ['Target', num(tgt, u) + (o.by ? ' by ' + shortDate(o.by) : '')] : null,
|
|
47
|
+
base !== null ? ['Baseline', num(base, u)] : null,
|
|
48
|
+
fin(o.expected) ? ['On its line today', num(o.expected, u)] : null,
|
|
49
|
+
['Line status', chip[0] + (o.status === 'unscored' && o.reason ? ' — ' + o.reason : '')],
|
|
50
|
+
['Readings', rs.length + ' from ' + shortDate(rs[0].at) + ' to ' + shortDate(rs[rs.length - 1].at)],
|
|
51
|
+
o.pillar ? ['Pillar', o.pillar] : null,
|
|
52
|
+
].filter(Boolean);
|
|
53
|
+
const say = o.name + ' stands at ' + num(now, u) + (tgt !== null ? ' against a target of ' + num(tgt, u) : '') + '. ' + (CHIP[o.status] ? 'Against its own line the record says: ' + chip[0].toLowerCase() + '.' : 'The record cannot score it against a line.');
|
|
54
|
+
const rid = clip(o.id, 100);
|
|
55
|
+
return {
|
|
56
|
+
key: 'ins:' + rid, id: o.id, title: clip(o.name, 120), sub: [o.pillar, rs.length + ' readings'].filter(Boolean).join(' · '), pillar: o.pillar || '',
|
|
57
|
+
unit: u, v: num(now, u), at: shortDate(rs[rs.length - 1].at), target: tgt, targetTxt: tgt !== null ? 'target ' + num(tgt, u) : '', by: o.by ? shortDate(o.by) : '',
|
|
58
|
+
ty: tgt !== null ? (tgt - lo) / range : null, state: o.status || 'unscored', chip: chip[0], chipKind: chip[1], off: o.status === 'drift' || o.status === 'off', pivot: !!o.pivot,
|
|
59
|
+
step: r2(step), good, dir, first: rs[0].at, lastAt: rs[rs.length - 1].at, pts, range: [lo, hi],
|
|
60
|
+
ticks: [shortDate(rs[0].at), shortDate(rs[rs.length - 1].at)],
|
|
61
|
+
dialog: {
|
|
62
|
+
eye: 'Measure', logTitle: 'Read from the KR metric record', say, head: 'Where it stands', facts: rows, files: [KR_FILE],
|
|
63
|
+
log: ['Read the KR metric record ' + o.id, 'Took ' + rs.length + ' readings from the record', 'Took the line status from the record: ' + chip[0].toLowerCase()],
|
|
64
|
+
hold: 'Nothing here changes a record. A reading is added where the KR metric is kept, not on this page.',
|
|
65
|
+
pane: { label: 'KR metric record', file: KR_FILE, rows: rs.map((x) => [shortDate(x.at), num(x.v, u)]).reverse() },
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** Up to three plain sentences about what stands out, from the series alone. No forecast and no cause. */
|
|
71
|
+
function findingsOf(charts) {
|
|
72
|
+
const out = [];
|
|
73
|
+
for (const c of charts) {
|
|
74
|
+
const u = c.unit, f = [];
|
|
75
|
+
const move = (a, b) => 'from ' + num(a, u) + ' to ' + num(b, u);
|
|
76
|
+
const prev = c.pts[c.pts.length - 2].v, now = c.pts[c.pts.length - 1].v;
|
|
77
|
+
const spread = (c.range[1] - c.range[0]) || 1;
|
|
78
|
+
if (c.pivot) f.push({ kind: 'stuck', score: 100, text: c.title + ' has been behind its line at three readings in a row, and the gap is not closing.' });
|
|
79
|
+
else if (c.off && c.good === false && c.step !== 0) f.push({ kind: 'worse', score: 90, text: c.title + ' is behind its line, and its last reading moved away from the target (' + move(prev, now) + ').' });
|
|
80
|
+
else if (c.off && c.good) f.push({ kind: 'closing', score: 60, text: c.title + ' is behind its line, and its last reading moved toward the target (' + move(prev, now) + ').' });
|
|
81
|
+
else if (c.off) f.push({ kind: 'off', score: 55, text: c.title + ' is behind its line at ' + num(now, u) + '.' });
|
|
82
|
+
else if (c.state === 'ok' && c.good === false && c.step !== 0) f.push({ kind: 'slip', score: 50, text: c.title + ' is on its line, but its last reading moved away from the target (' + move(prev, now) + ').' });
|
|
83
|
+
if (c.target !== null && c.dir && (c.dir > 0 ? now >= c.target : now <= c.target)) f.push({ kind: 'reached', score: 58, text: c.title + ' has reached its target of ' + num(c.target, u) + '.' });
|
|
84
|
+
if (Math.abs(now - prev) / spread >= 0.4 && !(f[0] && f[0].score >= 90)) f.push({ kind: 'move', score: 70, text: c.title + ' moved ' + move(prev, now) + ' in one reading.' });
|
|
85
|
+
f.sort((a, b) => b.score - a.score);
|
|
86
|
+
if (f[0]) out.push(Object.assign(f[0], { key: c.key, chart: c.key }));
|
|
87
|
+
}
|
|
88
|
+
out.sort((a, b) => b.score - a.score);
|
|
89
|
+
return out.slice(0, MAX_FINDINGS);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function reportRows(reports) {
|
|
93
|
+
return (reports || []).slice().sort((a, b) => String(b.slot).localeCompare(String(a.slot)) || String(a.cadence).localeCompare(String(b.cadence))).slice(0, 12).map((r) => {
|
|
94
|
+
const issued = !!r.issued;
|
|
95
|
+
return {
|
|
96
|
+
key: 'rep:' + r.cadence + ':' + r.slot, cadence: r.cadence, slot: r.slot, date: shortDate(r.slot), state: issued ? 'issued' : r.status === 'draft' ? 'draft' : 'file',
|
|
97
|
+
stateLabel: issued ? 'Issued' + (r.issued.at ? ' ' + shortDate(r.issued.at) : '') : r.status === 'draft' ? 'Draft' : 'Report file', path: r.path || '',
|
|
98
|
+
};
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function build(facts) {
|
|
103
|
+
const f = facts || {};
|
|
104
|
+
const outcomes = f.outcomes || [], missing = (f.missing || []).slice();
|
|
105
|
+
const charts = outcomes.map(chartOf).filter(Boolean);
|
|
106
|
+
const noSeries = outcomes.filter((o) => !chartOf(o)).map((o) => ({
|
|
107
|
+
key: 'nos:' + o.id, title: clip(o.name, 120), pillar: o.pillar || '',
|
|
108
|
+
why: (o.readings || []).length === 1 ? 'Only one reading is recorded.' : (o.readings || []).length === 0 ? (o.reason && /reading/i.test(o.reason) ? o.reason : 'No reading is recorded yet.') : 'Its readings do not form a series.',
|
|
109
|
+
}));
|
|
110
|
+
const pillars = [...new Set(charts.map((c) => c.pillar).filter(Boolean))];
|
|
111
|
+
const offOf = (L) => L.filter((c) => c.off).length;
|
|
112
|
+
const dash = (id, name, L) => ({ id, name, keys: L.map((c) => c.key), total: L.length, off: offOf(L), chip: !L.length ? '' : offOf(L) ? offOf(L) + ' off its line' : 'On their lines' });
|
|
113
|
+
const dashboards = [dash('all', 'All measures', charts)].concat(pillars.length > 1 ? pillars.map((p) => dash('p:' + p, p, charts.filter((c) => c.pillar === p))) : []);
|
|
114
|
+
const findings = findingsOf(charts);
|
|
115
|
+
const rep = reportRows(f.reports);
|
|
116
|
+
const off = offOf(charts);
|
|
117
|
+
const board = f.board || {};
|
|
118
|
+
const model = {
|
|
119
|
+
header: { text: (f.pending ? 'Reading the records · ' : '') + 'Real data' + (missing.length ? ' · not read: ' + missing.join(', ') : '') },
|
|
120
|
+
board: { ws: board.ws || null, id: board.id || null, name: board.name || 'Insights', switcher: (f.boards || []).map((b) => ({ ws: b.ws, id: b.id, name: b.name })) },
|
|
121
|
+
charts, noSeries, dashboards, rows: charts,
|
|
122
|
+
findings: findings.length ? findings : [{ kind: 'calm', key: null, text: charts.length ? (charts.some((c) => c.target !== null) ? 'Nothing stands out. No measure moved much, and none is far behind its line.' : 'Nothing stands out. No measure here has a target, so the series can only be described.') : '' }],
|
|
123
|
+
calm: !findings.length && charts.length > 0,
|
|
124
|
+
reports: { rows: rep, ok: f.reportsOk !== false, counts: { draft: rep.filter((r) => r.state === 'draft').length, issued: rep.filter((r) => r.state === 'issued').length }, missing: f.reportsOk === false },
|
|
125
|
+
empty: !outcomes.length ? 'No KR metric is recorded for this workspace, so there is nothing to chart. Add one where the KR metrics are kept.' : !charts.length ? 'No KR metric holds two readings yet, so nothing is drawn.' : '',
|
|
126
|
+
dock: { needs: off, label: off === 1 ? 'measure off its line' : 'measures off their line', next: findings[0] && findings[0].chart ? (charts.find((c) => c.key === findings[0].chart) || {}).title || null : null },
|
|
127
|
+
counts: { charts: charts.length, noSeries: noSeries.length, off, total: outcomes.length },
|
|
128
|
+
};
|
|
129
|
+
last = model;
|
|
130
|
+
return model;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
module.exports = { build, peekModel, chartOf, findingsOf, shortDate, num };
|
|
@@ -52,6 +52,7 @@ const MODULES = Object.freeze([
|
|
|
52
52
|
'routes-briefing-premium', // briefing-premium: the premium Briefing's page model from repository state (read-only)
|
|
53
53
|
'routes-my-work-premium', // briefing-premium-work: the premium My work page's model from the Work page's own list (read-only)
|
|
54
54
|
'routes-board-premium', // briefing-premium-board: the premium Board page's model from the Initiatives page's own routes (read-only)
|
|
55
|
+
'routes-insights-premium', // briefing-premium-insights: the premium Insights page's model from the KR metric records and report files (read-only)
|
|
55
56
|
'routes-initiative-premium', // briefing-premium-initiative: the premium initiative page's model from the Initiatives sheet's own routes (read-only)
|
|
56
57
|
'routes-brief-page', // console3 Briefing as the brief: Today agenda, Needs you and Mentions (read-only; writes go through routes-pm-items)
|
|
57
58
|
'routes-mentions', // console3 Briefing Mentions: the PM's read marks (page press only)
|
|
@@ -16,6 +16,7 @@ const Ag = require('./briefing-premium-agent.js');
|
|
|
16
16
|
const WP = require('./my-work-premium.js');
|
|
17
17
|
const BoardP = require('./board-premium.js');
|
|
18
18
|
const InitP = require('./initiative-premium.js');
|
|
19
|
+
const InsP = require('./insights-premium.js');
|
|
19
20
|
const { repoScript } = require('./repo-script.js');
|
|
20
21
|
const { correctionEvent } = require(repoScript('card-state.js'));
|
|
21
22
|
const { appendOutbox } = require(repoScript('outbox.js'));
|
|
@@ -66,7 +67,7 @@ async function post(req, res, url, ctx) {
|
|
|
66
67
|
}
|
|
67
68
|
if (act === 'ask') {
|
|
68
69
|
let wsId; try { const w = merged && sk ? { id: sk.ws } : ctx.getWs && ctx.getWs(url.searchParams.get('ws') || null); wsId = w && w.id; } catch { wsId = undefined; }
|
|
69
|
-
const a = Ag.ask({ runtimeDir, key: b.key, text: b.text, model: /^work:/.test(String(b.key || '')) ? WP.peekModel() : /^board:/.test(String(b.key || '')) ? BoardP.peekModel() : /^(init|doc):/.test(String(b.key || '')) ? InitP.peekModel() : sk || /^src:/.test(String(b.key || '')) ? Prod.peekModel() : BP.peekModel(root), spawnSession: ctx.spawnSession, wsId });
|
|
70
|
+
const a = Ag.ask({ runtimeDir, key: b.key, text: b.text, model: /^work:/.test(String(b.key || '')) ? WP.peekModel() : /^board:/.test(String(b.key || '')) ? BoardP.peekModel() : /^ins:/.test(String(b.key || '')) ? InsP.peekModel() : /^(init|doc):/.test(String(b.key || '')) ? InitP.peekModel() : sk || /^src:/.test(String(b.key || '')) ? Prod.peekModel() : BP.peekModel(root), spawnSession: ctx.spawnSession, wsId });
|
|
70
71
|
ctx.json(res, a.body, a.status);
|
|
71
72
|
return true;
|
|
72
73
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-insights-premium.js — GET /api/insights-premium[?ws=<id>&board=<id>] (initiative briefing-premium-insights).
|
|
3
|
+
*
|
|
4
|
+
* 200 { ok, state: 'ready', model, as_of } | 500 { ok: false, state: 'error', error }
|
|
5
|
+
* model is lib/insights-premium.js build(), made from what the console's Reports tab reads: /api/boards (the board list), the KR metric records of the
|
|
6
|
+
* workspace with the line status the Calendar's Quarter pane computes from them (routes-c3-strategy.js outcomeOf; /api/c3-strategy itself drops the dated
|
|
7
|
+
* readings, so the records are read here), and /api/report (the report files). None starts a cold repository read, so this route does not answer 202. Read-only: it writes nothing and the page posts nothing. */
|
|
8
|
+
const Insights = require('./insights-premium.js');
|
|
9
|
+
const boards = require('./routes-boards.js');
|
|
10
|
+
const strategy = require('./routes-c3-strategy.js');
|
|
11
|
+
const { repoScript } = require('./repo-script.js');
|
|
12
|
+
const { recordsDirFor } = require('./records-dir.js');
|
|
13
|
+
const reports = require('./routes-reports.js');
|
|
14
|
+
|
|
15
|
+
/** GET `pathAndQuery` from a route module's own handler, as the Board page's route does, and return { status, body }. */
|
|
16
|
+
async function via(mod, pathAndQuery, req, ctx) {
|
|
17
|
+
let out = { status: 500, body: null };
|
|
18
|
+
const c = Object.assign({}, ctx, { json: (res, obj, code) => { out = { status: code || 200, body: obj }; } });
|
|
19
|
+
const u = new URL('http://local' + pathAndQuery);
|
|
20
|
+
const handled = await mod.handle({ method: 'GET', headers: (req && req.headers) || {} }, {}, u, c);
|
|
21
|
+
return handled === false ? { status: 404, body: null } : out;
|
|
22
|
+
}
|
|
23
|
+
const qs = (o) => '?' + Object.entries(o).filter(([, v]) => v != null && v !== '').map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
prefixes: ['/api/insights-premium'],
|
|
27
|
+
handle: async (req, res, url, ctx) => {
|
|
28
|
+
if (url.pathname !== '/api/insights-premium') return false;
|
|
29
|
+
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
30
|
+
const fail = (error) => { ctx.json(res, { ok: false, state: 'error', error: String(error).slice(0, 240) }, 500); return true; };
|
|
31
|
+
try {
|
|
32
|
+
const list = await via(boards, '/api/boards', req, ctx);
|
|
33
|
+
const all = list.body && list.body.ok !== false ? list.body.boards || [] : [];
|
|
34
|
+
const wantWs = url.searchParams.get('ws'), wantId = url.searchParams.get('board');
|
|
35
|
+
const pick = all.find((b) => (!wantWs || b.ws === wantWs) && (!wantId || b.id === wantId)) || all[0] || null;
|
|
36
|
+
const ws = pick ? pick.ws : wantWs;
|
|
37
|
+
const q = qs({ ws });
|
|
38
|
+
const rp = await via(reports, '/api/report' + q, req, ctx);
|
|
39
|
+
let outcomes;
|
|
40
|
+
try {
|
|
41
|
+
const today = new Date(), pad = (n) => String(n).padStart(2, '0'), day = today.getFullYear() + '-' + pad(today.getMonth() + 1) + '-' + pad(today.getDate());
|
|
42
|
+
outcomes = require(repoScript('records/index.js')).list(recordsDirFor(ctx, ws), 'kr-metrics').map((k) => strategy.outcomeOf(k, day));
|
|
43
|
+
} catch (e) { return fail('the KR metric records could not be read: ' + ((e && e.message) || e)); }
|
|
44
|
+
const reportsOk = !!(rp.body && rp.body.ok !== false);
|
|
45
|
+
const model = Insights.build({
|
|
46
|
+
now: Date.now(), board: pick ? { ws: pick.ws, id: pick.id, name: pick.name } : { ws, id: null, name: 'Insights' }, boards: all.map((x) => ({ ws: x.ws, id: x.id, name: x.name })),
|
|
47
|
+
outcomes, reports: reportsOk ? rp.body.reports || [] : [], reportsOk, missing: reportsOk ? [] : ['reports'],
|
|
48
|
+
});
|
|
49
|
+
ctx.json(res, { ok: true, state: 'ready', model, as_of: Date.now() });
|
|
50
|
+
return true;
|
|
51
|
+
} catch (e) { return fail((e && e.message) || e); }
|
|
52
|
+
},
|
|
53
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.258.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.258.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
.ch.stuck{padding-block:12px;box-shadow:0 10px 24px -16px rgba(20,24,60,.3),inset 0 -1px 0 var(--hair)}
|
|
2
|
+
.ch.stuck .ic{transform:scale(.8)}
|
|
3
|
+
.ch.stuck small{opacity:0}
|
|
4
|
+
.mprog{height:4px;border-radius:8px;background:color-mix(in oklab,var(--ink) 10%,transparent);margin:0 0 6px;overflow:hidden}
|
|
5
|
+
.mprog b{display:block;height:100%;width:0;border-radius:8px;background:var(--ok);transition:width .6s var(--spring,ease)}
|
|
6
|
+
@media (max-width:700px){
|
|
7
|
+
.mprog{margin-top:8px}
|
|
8
|
+
}
|
|
9
|
+
.cx{display:grid;gap:24px;align-content:start}
|
|
10
|
+
.cx .label,.p-work .label{display:block;margin-bottom:8px}
|
|
11
|
+
.lk{display:inline-flex;align-items:center;gap:6px;font-size:12.5px;font-weight:600;color:var(--ink-2);padding:6px 10px 6px 4px;border-radius:999px}
|
|
12
|
+
.lk:hover{color:var(--ink);background:var(--well)}
|
|
13
|
+
.lk svg{width:15px;height:15px;transform:rotate(90deg)}
|
|
14
|
+
.mt1{background:var(--well);border-radius:18px;padding:14px 16px 12px;display:grid;gap:2px;align-content:start;outline:0}
|
|
15
|
+
.mt1 span{font-size:12.5px;color:var(--ink-3)}
|
|
16
|
+
.mt1 b{font-size:28px;letter-spacing:-.03em;line-height:1.15}
|
|
17
|
+
.mt1 em{font-style:normal;font-size:12.5px;color:var(--ink-3)}
|
|
18
|
+
.mt1.warn em{color:var(--ember-ink)}
|
|
19
|
+
.mt1.bad em{color:var(--bad)}
|
|
20
|
+
.mt1.ok em{color:var(--ok)}
|
|
21
|
+
.mch{cursor:crosshair}
|
|
22
|
+
.mch:focus-visible{box-shadow:0 0 0 2px var(--b3)}
|
|
23
|
+
.mch svg{width:100%;height:auto;display:block;margin-top:8px;overflow:visible}
|
|
24
|
+
.mch .ar{fill:color-mix(in oklab,var(--ink) 8%,transparent);stroke:none}
|
|
25
|
+
.mch .ln2{fill:none;stroke:var(--ink);stroke-width:1.8;stroke-linejoin:round;stroke-linecap:round;vector-effect:non-scaling-stroke}
|
|
26
|
+
.mch .tg{stroke:var(--ink-3);stroke-dasharray:3 3;stroke-width:1;vector-effect:non-scaling-stroke}
|
|
27
|
+
.mch .cx{stroke:var(--ink-3);stroke-width:1;opacity:0;vector-effect:non-scaling-stroke;transition:opacity .2s}
|
|
28
|
+
.mch .dt{fill:var(--ink);transition:cx .15s,cy .15s}
|
|
29
|
+
.mch.ok .dt{fill:var(--ok)}
|
|
30
|
+
.mch.warn .dt{fill:var(--ember)}
|
|
31
|
+
.mch.bad .dt{fill:var(--bad)}
|
|
32
|
+
.mch .gp{stroke:var(--ink-3);opacity:.55;stroke-dasharray:2 4;fill:none;stroke-width:1.4}
|
|
33
|
+
.calm{display:flex;align-items:center;gap:16px;padding:22px 4px 8px}
|
|
34
|
+
.calm[hidden]{display:none}
|
|
35
|
+
.calm i{width:44px;height:44px;border-radius:50%;background:var(--solid);color:var(--on-solid);display:grid;place-items:center;flex:none}
|
|
36
|
+
.calm i svg{stroke-width:2.6}
|
|
37
|
+
.calm b{display:block;font-size:var(--t-title);letter-spacing:-.01em}
|
|
38
|
+
.calm small{display:block;color:var(--ink-2);font-size:var(--t-small);margin-top:2px}
|
|
39
|
+
.spk{width:120px;height:34px;flex:none;overflow:visible}
|
|
40
|
+
.spk path{fill:none;stroke:var(--ink);stroke-width:1.6;stroke-linecap:round;stroke-linejoin:round}
|
|
41
|
+
.spk line{stroke:var(--ink-3);stroke-dasharray:3 3;stroke-width:1}
|
|
42
|
+
.spk circle{fill:var(--ink)}
|
|
43
|
+
.spk.ok circle{fill:var(--ok)}
|
|
44
|
+
.spk.warn circle{fill:var(--ember)}
|
|
45
|
+
.spk.bad circle{fill:var(--bad)}
|
|
46
|
+
.mhint{margin:2px 0 14px;color:var(--ink-2);font-size:12.5px;line-height:1.55;max-width:78ch}
|
|
47
|
+
.mhint b{color:var(--ink)}
|
|
48
|
+
.mlab{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
|
|
49
|
+
.mchip{font-style:normal;font-size:12.5px;font-weight:650;padding:2px 9px;border-radius:999px;background:var(--well);color:var(--ink-2)}
|
|
50
|
+
.mchip.ok{background:color-mix(in oklab,var(--ok) 14%,transparent);color:var(--ok)}
|
|
51
|
+
.mchip.warn{background:color-mix(in oklab,var(--ember) 18%,transparent);color:var(--ember-ink)}
|
|
52
|
+
.mt1.off{box-shadow:inset 0 0 0 1.5px color-mix(in oklab,var(--ember) 55%,transparent)}
|
|
53
|
+
.mchg{font-size:12.5px;color:var(--ink-3);margin-top:2px}
|
|
54
|
+
.mchg.bad{color:var(--ember-ink)}
|
|
55
|
+
.mfoot{display:flex;justify-content:space-between;gap:8px;font:600 12.5px var(--mono);letter-spacing:.04em;text-transform:uppercase;color:var(--ink-3);margin-top:4px}
|
|
56
|
+
.mfoot i{font-style:normal}
|
|
57
|
+
.mfoot .tgl{text-transform:none;font-family:var(--sans);font-weight:550;letter-spacing:0;color:var(--ink-3)}
|
|
58
|
+
.mt1[data-op]{cursor:pointer;transition:transform .25s,box-shadow .25s}
|
|
59
|
+
.mt1[data-op]:hover{transform:translateY(-2px)}
|
|
60
|
+
#cIni .mprog{margin:0 0 10px}
|
|
61
|
+
.ndh{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;flex-wrap:wrap}
|
|
62
|
+
.ndh h2{margin:0;font-size:20px;font-weight:700;letter-spacing:-.01em}
|
|
63
|
+
.ndh p{margin:4px 0 0;color:var(--ink-2);font-size:12.5px}
|
|
64
|
+
.nact{display:flex;gap:8px;flex-wrap:wrap;align-items:center}
|
|
65
|
+
.nrow{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;margin:14px 0 4px}
|
|
66
|
+
.nrow .seg{margin:0}
|
|
67
|
+
.ngrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px;margin-top:6px}
|
|
68
|
+
.ntw{display:grid;gap:6px;align-content:start}
|
|
69
|
+
.ntw .mt1{margin:0}
|
|
70
|
+
.nbn{margin:0 0 -2px 4px;font-size:12.5px;font-weight:600;color:var(--ink-3)}
|
|
71
|
+
.ntf{display:flex;align-items:center;gap:6px;flex-wrap:wrap;min-height:30px;padding-left:2px}
|
|
72
|
+
.ntf .lk{font-size:12.5px}
|
|
73
|
+
.nempty{display:grid;gap:10px;justify-items:start;padding:22px;border-radius:18px;background:var(--well)}
|
|
74
|
+
.nempty p{margin:0;color:var(--ink-2)}
|
|
75
|
+
.ngrp{margin-top:18px}
|
|
76
|
+
.ngrp>.label{margin:0 0 6px 4px}
|
|
77
|
+
.ncr .spk{width:104px;height:auto;display:block}
|
|
78
|
+
.nsrc{display:inline-flex;align-items:center;gap:5px}
|
|
79
|
+
.nsch{margin:14px 0 0;color:var(--ink-3);font-size:12.5px}
|
|
80
|
+
.dplist{display:grid;gap:6px}
|
|
81
|
+
.dplist button{display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:left;padding:12px 14px;border-radius:14px;background:var(--well)}
|
|
82
|
+
.dplist button b{font-size:15px;font-weight:600}
|
|
83
|
+
.dplist button small{color:var(--ink-3);display:block;font-weight:400;font-size:12.5px}
|
|
84
|
+
.dplist button[aria-pressed="true"]{box-shadow:inset 0 0 0 1.5px var(--ink)}
|
|
85
|
+
.dplist button i{font-style:normal;font-size:12.5px;font-weight:650;color:var(--ink-2)}
|
|
86
|
+
@media (max-width:700px){
|
|
87
|
+
.ngrid{grid-template-columns:minmax(0,1fr)}
|
|
88
|
+
.ncr .spk{width:120px}
|
|
89
|
+
}
|
|
90
|
+
.ndh+.mprog{margin-top:14px}
|
|
91
|
+
.nfd{margin:16px 0 4px;padding:16px 18px;border-radius:18px;background:var(--well)}
|
|
92
|
+
.nfd .label{margin:0 0 8px}
|
|
93
|
+
.nfd ul{list-style:none;margin:0;padding:0;display:grid;gap:2px}
|
|
94
|
+
.nfd li{display:grid;grid-template-columns:14px minmax(0,1fr) auto;gap:10px;align-items:start;padding:8px 0}
|
|
95
|
+
.nfd li+li{border-top:1px solid var(--hair)}
|
|
96
|
+
.nfdot{width:9px;height:9px;border-radius:50%;margin-top:7px;background:var(--ink-3)}
|
|
97
|
+
.nfd li.worse .nfdot,.nfd li.stuck .nfdot,.nfd li.off .nfdot{background:var(--ember)}
|
|
98
|
+
.nfd li.closing .nfdot,.nfd li.reached .nfdot{background:var(--ok)}
|
|
99
|
+
.nft{font-size:15px;line-height:1.5;color:var(--ink)}
|
|
100
|
+
@media (max-width:700px){
|
|
101
|
+
.nfd li{grid-template-columns:14px minmax(0,1fr)}
|
|
102
|
+
}
|
|
103
|
+
.nl{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1fr);gap:18px;align-items:start}
|
|
104
|
+
.nlc,.nlr{min-width:0}
|
|
105
|
+
.nhb{display:flex;align-items:center;gap:8px;margin-left:12px;flex-wrap:nowrap}
|
|
106
|
+
.nhb .lk{font-size:12.5px;white-space:nowrap}
|
|
107
|
+
.nrep .nhb{margin-left:auto}
|
|
108
|
+
.ndt{margin:0;font-size:20px;font-weight:700;letter-spacing:-.01em;display:flex;align-items:center;gap:10px;flex-wrap:wrap}
|
|
109
|
+
.ngl{margin:24px 0 8px 4px}
|
|
110
|
+
.ndg{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
|
|
111
|
+
.ndc{display:grid;gap:8px;align-content:start;text-align:left;padding:16px 18px;border-radius:18px;background:var(--well);transition:background .25s,transform .3s var(--spring)}
|
|
112
|
+
.ndc:hover{background:color-mix(in oklab,var(--ink) 8%,var(--well));transform:translateY(-2px)}
|
|
113
|
+
.ndc b{font-size:15px;display:flex;align-items:center;gap:8px}
|
|
114
|
+
.ndm{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
|
|
115
|
+
.ndm small{color:var(--ink-3);font-size:12.5px}
|
|
116
|
+
.nrep .mhint{margin-bottom:10px}
|
|
117
|
+
@media (max-width:999px){
|
|
118
|
+
.nl{grid-template-columns:minmax(0,1fr)}
|
|
119
|
+
}
|
|
120
|
+
@media (max-width:700px){
|
|
121
|
+
.ndg{grid-template-columns:minmax(0,1fr)}
|
|
122
|
+
.nhb{flex:1 0 100%;margin-left:0;flex-wrap:wrap}
|
|
123
|
+
.nrep .nhb{margin-left:0}
|
|
124
|
+
}
|
|
125
|
+
.ndh{margin-top:16px}
|
|
126
|
+
.mnote{margin:6px 0 0 4px;font-size:12.5px;color:var(--ink-2)}
|
|
127
|
+
.ntf .lk,.nfa .lk,.nhb .lk,.stx .lk,.stlh .lk,.stdone{min-height:44px;padding:0 10px}
|
|
128
|
+
.nfd li{display:block;padding:0}
|
|
129
|
+
.nfd li+li{border-top:1px solid var(--hair)}
|
|
130
|
+
.nfr{display:grid;grid-template-columns:14px minmax(0,1fr) 18px;gap:10px;align-items:start;width:100%;text-align:left;padding:10px 6px;margin:0 -6px;border-radius:14px;min-height:44px;transition:background .2s}
|
|
131
|
+
button.nfr:hover,button.nfr:focus-visible{background:color-mix(in oklab,var(--ink) 6%,transparent)}
|
|
132
|
+
.ndc{gap:10px}
|
|
133
|
+
.ndc b{display:flex;align-items:center;gap:8px;font-size:15px}
|
|
134
|
+
.ndu{color:var(--ink-2);font-size:12.5px;line-height:1.4}
|
|
135
|
+
.ndsp{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
|
|
136
|
+
.nsp{display:grid;gap:4px;min-width:0}
|
|
137
|
+
.nsp svg{width:100%;height:30px;color:var(--ink-2)}
|
|
138
|
+
.nsp.warn svg{color:var(--ember)}
|
|
139
|
+
.nsp em{font-style:normal;font-size:12.5px;color:var(--ink-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
140
|
+
.ndm{display:flex;align-items:center;justify-content:space-between;gap:8px}
|
|
141
|
+
.ndm small{color:var(--ink-3)}
|
|
142
|
+
.ntf .lk,.nsch .lk{min-height:44px;display:inline-flex;align-items:center}
|
|
143
|
+
.ntf{min-height:44px}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/* pm/premium-insights.js — the premium Insights page (initiative briefing-premium-insights, slice 9). Reads GET /api/insights-premium and draws the model
|
|
2
|
+
* lib/insights-premium.js builds from the KR metric records and the report files the console's Reports tab reads: the Dashboards card (charts with a target
|
|
3
|
+
* line, what stands out), the Reports card, the dock and the standard dialog. Nothing here posts: no press changes a record, and nothing is sent. */
|
|
4
|
+
import { $, $$, esc, openDlg, toast, loadThread, onScroll, wireRail, logHtml, turnA, ptx, pillOf, crumbHtml, wireCrumb } from './premium-shell.js';
|
|
5
|
+
|
|
6
|
+
let M = null; // the model
|
|
7
|
+
let dash = 'all'; // the dashboard on screen
|
|
8
|
+
wireRail('rep');
|
|
9
|
+
const ICO = (p) => `<svg class="i" viewBox="0 0 24 24">${p}</svg>`;
|
|
10
|
+
const DOCI = '<path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 13h6M9 17h4"/>';
|
|
11
|
+
const CHV2 = '<svg class="i" viewBox="0 0 24 24"><path d="M9 6l6 6-6 6"/></svg>';
|
|
12
|
+
const byKey = (k) => (M && M.charts || []).find((c) => c.key === k) || null;
|
|
13
|
+
|
|
14
|
+
/* ── header ───────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
15
|
+
let crumbed = false;
|
|
16
|
+
function drawHead() {
|
|
17
|
+
if (!crumbed) {
|
|
18
|
+
crumbed = true;
|
|
19
|
+
const boards = M.board.switcher || [];
|
|
20
|
+
$('#crumbHost').innerHTML = crumbHtml({ board: M.board.name || 'Insights', boards, ask: 'Ask about these measures' });
|
|
21
|
+
wireCrumb({ boards, board: M.board.id, goBoard: (ws, id) => location.assign('/premium-insights.html?ws=' + encodeURIComponent(ws) + '&board=' + encodeURIComponent(id)), ask: () => { const c = M.charts[0]; if (c) openChart(c); else toast('No measure has a series to ask about.'); } });
|
|
22
|
+
}
|
|
23
|
+
$('#snap').textContent = M.header.text;
|
|
24
|
+
$('#snap').title = 'Every figure on this page comes from a KR metric record. A measure with fewer than two readings is listed, not drawn.';
|
|
25
|
+
$('#brief').textContent = M.empty || '';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/* ── charts ───────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
29
|
+
const W = 220, H = 60, P = 5;
|
|
30
|
+
const X = (fx) => P + fx * (W - 2 * P), Y = (fy) => P + (1 - fy) * (H - 2 * P);
|
|
31
|
+
function tileHtml(c) {
|
|
32
|
+
const d = c.pts.map((p, i) => (i ? 'L' : 'M') + X(p.fx).toFixed(1) + ',' + Y(p.fy).toFixed(1)).join('');
|
|
33
|
+
const last = c.pts[c.pts.length - 1];
|
|
34
|
+
const cls = c.chipKind === 'bad' ? 'warn' : c.chipKind;
|
|
35
|
+
const chg = c.step === 0 ? '' : `<span class="mchg ${c.good === null ? '' : c.good ? 'good' : 'bad'}">${c.step > 0 ? '▲ ' : '▼ '}${esc(Math.abs(c.step) + (c.unit && /^[%°]/.test(c.unit) ? c.unit : c.unit ? ' ' + c.unit : ''))} since the last reading</span>`;
|
|
36
|
+
return `<div class="mt1 mch ${c.chipKind}${c.off ? ' off' : ''}" data-key="${esc(c.key)}" tabindex="0" role="img" aria-label="${esc(c.title)}, ${c.pts.length} readings, now ${esc(c.v)}${c.targetTxt ? ', ' + esc(c.targetTxt) : ''}. Use the arrow keys to read each reading."><span class="mlab">${esc(c.title)}<i class="mchip ${cls}">${esc(c.chip)}</i></span><b class="mval">${esc(c.v)}</b><em class="mwk">${esc('on ' + c.at + (c.targetTxt ? ' · ' + c.targetTxt : ''))}</em>${chg}`
|
|
37
|
+
+ `<svg viewBox="0 0 ${W} ${H}"><path class="ar" d="${d}L${X(1)},${H}L${X(0)},${H}Z"/>${c.ty !== null ? `<line class="tg" x1="${P}" x2="${W - P}" y1="${Y(c.ty)}" y2="${Y(c.ty)}"/>` : ''}<path class="ln2" d="${d}"/><line class="cx" x1="0" x2="0" y1="0" y2="${H}"/><circle class="dt" cx="${X(last.fx)}" cy="${Y(last.fy)}" r="3.5"/></svg>`
|
|
38
|
+
+ `<span class="mfoot"><i>${esc(c.ticks[0])}</i>${c.target !== null ? '<i class="tgl">dashed line is the target</i>' : ''}<i>${esc(c.ticks[1])}</i></span></div>`;
|
|
39
|
+
}
|
|
40
|
+
/* Point at reading j: the cursor line, the dot, the value and the date move to it. Without j the tile returns to the latest reading. */
|
|
41
|
+
function chartAt(t, j) {
|
|
42
|
+
const c = byKey(t.dataset.key); if (!c) return;
|
|
43
|
+
const n = c.pts.length; j = j == null ? n - 1 : Math.max(0, Math.min(n - 1, j));
|
|
44
|
+
const p = c.pts[j], last = j === n - 1;
|
|
45
|
+
const cx = $('.cx', t), dt = $('.dt', t);
|
|
46
|
+
cx.setAttribute('x1', X(p.fx)); cx.setAttribute('x2', X(p.fx)); dt.setAttribute('cx', X(p.fx)); dt.setAttribute('cy', Y(p.fy));
|
|
47
|
+
t.classList.toggle('hv', !last); t.dataset.j = j;
|
|
48
|
+
const val = last ? c.v : p.txt, cap = last ? 'on ' + c.at + (c.targetTxt ? ' · ' + c.targetTxt : '') : 'on ' + p.d + (c.targetTxt ? ' · ' + c.targetTxt : '');
|
|
49
|
+
$('.mval', t).textContent = val; $('.mwk', t).textContent = cap;
|
|
50
|
+
t.setAttribute('aria-label', c.title + ', ' + (last ? 'now ' : '') + val + ', ' + cap + '. Use the arrow keys to read each reading.');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* ── the dashboards card ──────────────────────────────────────────────────────────────────────────────────────── */
|
|
54
|
+
const curDash = () => M.dashboards.find((d) => d.id === dash) || M.dashboards[0];
|
|
55
|
+
function findingsHtml() {
|
|
56
|
+
const F = M.findings.filter((f) => f.text);
|
|
57
|
+
if (!F.length) return '';
|
|
58
|
+
return `<div class="nfd" role="region" aria-label="What stands out"><p class="label">What stands out</p><ul>${F.map((f) => `<li class="${esc(f.kind)}">${f.chart
|
|
59
|
+
? `<button class="nfr" data-open="${esc(f.chart)}" aria-haspopup="dialog"><i class="nfdot" aria-hidden="true"></i><span class="nft">${esc(f.text)}</span>${CHV2}</button>`
|
|
60
|
+
: `<div class="nfr"><i class="nfdot" aria-hidden="true"></i><span class="nft">${esc(f.text)}</span></div>`}</li>`).join('')}</ul></div>`;
|
|
61
|
+
}
|
|
62
|
+
function drawDash() {
|
|
63
|
+
const D = curDash(), L = D.keys.map(byKey).filter(Boolean);
|
|
64
|
+
$('#dashCap').textContent = M.counts.total ? M.counts.charts + ' drawn · ' + M.counts.noSeries + ' without a series' : '';
|
|
65
|
+
const tabs = $('#dashTabs'); tabs.hidden = M.dashboards.length < 2;
|
|
66
|
+
if (!tabs.hidden) { tabs.innerHTML = '<i class="pill"></i>' + M.dashboards.map((d) => `<button data-d="${esc(d.id)}" aria-pressed="${d.id === D.id}">${esc(d.name)}</button>`).join(''); pillOf(tabs); }
|
|
67
|
+
if (!M.charts.length) {
|
|
68
|
+
$('#dashBody').innerHTML = `<div class="nempty" style="margin-top:14px"><p><b>${esc(M.counts.total ? 'No KR metric holds two readings yet.' : 'No KR metric is recorded for this workspace.')}</b> ${esc(M.counts.total ? 'A chart needs a series, so nothing is drawn.' : 'There is nothing to chart. Add one where the KR metrics are kept.')}</p></div>` + noSeriesHtml();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const off = D.off, tot = L.length;
|
|
72
|
+
$('#dashBody').innerHTML = `<div class="mprog" role="progressbar" aria-label="Measures on their line" aria-valuemin="0" aria-valuemax="${tot}" aria-valuenow="${tot - off}"><b style="width:${(tot - off) / tot * 100}%"></b></div>`
|
|
73
|
+
+ findingsHtml()
|
|
74
|
+
+ `<p class="mhint" style="margin-top:6px"><b>${tot - off} of ${tot}</b> on their line${off ? `. <b class="mflag">${off} ${off === 1 ? 'is' : 'are'} behind it.</b>` : '.'} Each chart is one KR metric, drawn at the dates of its readings. A gap between readings is left as a gap. The dashed line is the target.</p>`
|
|
75
|
+
+ `<div class="ngrid">${L.map((c) => `<div class="ntw">${tileHtml(c)}<div class="ntf"><button class="lk" data-open="${esc(c.key)}">Details</button></div></div>`).join('')}</div>` + noSeriesHtml();
|
|
76
|
+
}
|
|
77
|
+
function noSeriesHtml() {
|
|
78
|
+
const N = M.noSeries; if (!N.length) return '';
|
|
79
|
+
return `<p class="label ngl">No series recorded · ${N.length}</p><div class="dplist" role="list">${N.map((n) => `<div class="nempty" role="listitem" style="margin-bottom:6px"><p><b>${esc(n.title)}</b>${n.pillar ? ' · ' + esc(n.pillar) : ''}<br>${esc(n.why)} It is not drawn.</p></div>`).join('')}</div>`;
|
|
80
|
+
}
|
|
81
|
+
$('#dashTabs').addEventListener('click', (e) => { const b = e.target.closest('[data-d]'); if (!b) return; dash = b.dataset.d; drawDash(); });
|
|
82
|
+
$('#dashBody').addEventListener('click', (e) => { const o = e.target.closest('[data-open]'); if (o) openChart(byKey(o.dataset.open)); });
|
|
83
|
+
$('#dashBody').addEventListener('keydown', (e) => {
|
|
84
|
+
const t = e.target.closest && e.target.closest('.mch'); if (!t || !/^Arrow(Left|Right)$/.test(e.key)) return;
|
|
85
|
+
e.preventDefault(); const c = byKey(t.dataset.key), j = +(t.dataset.j == null ? c.pts.length - 1 : t.dataset.j); chartAt(t, j + (e.key === 'ArrowRight' ? 1 : -1));
|
|
86
|
+
});
|
|
87
|
+
$('#dashBody').addEventListener('pointermove', (e) => {
|
|
88
|
+
const t = e.target.closest && e.target.closest('.mch'); $$('#dashBody .mch.hv').forEach((x) => { if (x !== t) chartAt(x); });
|
|
89
|
+
if (!t) return; const c = byKey(t.dataset.key), r = $('svg', t).getBoundingClientRect(); if (!c || !r.width) return;
|
|
90
|
+
const fx = Math.max(0, Math.min(1, ((e.clientX - r.left) / r.width * W - P) / (W - 2 * P)));
|
|
91
|
+
let best = 0; c.pts.forEach((p, i) => { if (Math.abs(p.fx - fx) < Math.abs(c.pts[best].fx - fx)) best = i; }); chartAt(t, best);
|
|
92
|
+
});
|
|
93
|
+
$('#dashBody').addEventListener('pointerleave', () => $$('#dashBody .mch.hv').forEach((x) => chartAt(x)));
|
|
94
|
+
|
|
95
|
+
/* ── reports ──────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
96
|
+
function repRow(r) {
|
|
97
|
+
return `<div class="dmr ${esc(r.state)}" role="listitem"><button class="dmo" data-rep="1"><span class="dmi c-Board">${ICO(DOCI)}</span><span class="dmn"><b>${esc(r.cadence)} · ${esc(r.date || r.slot)}</b><small>${esc(r.path)}</small><span class="dmm"><span class="s ${esc(r.state === 'issued' ? 'issued' : 'draft')}">${esc(r.stateLabel)}</span></span></span></button></div>`;
|
|
98
|
+
}
|
|
99
|
+
function drawReps() {
|
|
100
|
+
const R = M.reports;
|
|
101
|
+
$('#repCap').textContent = R.rows.length ? String(R.rows.length) : '';
|
|
102
|
+
$('#repBody').innerHTML = `<p class="mhint">A report is a file in the repository. PMOS drafts it, you read it. <b>Nothing is sent from here.</b></p>`
|
|
103
|
+
+ (R.missing ? '<div class="nempty"><p><b>The report files could not be read</b>, so none is listed.</p></div>'
|
|
104
|
+
: R.rows.length ? `<p class="note" style="margin:6px 0 10px"><b>${R.counts.draft}</b> ${R.counts.draft === 1 ? 'draft' : 'drafts'} · <b>${R.counts.issued}</b> issued</p><div class="dmg ngrp" role="list">${R.rows.map(repRow).join('')}</div>`
|
|
105
|
+
: '<div class="nempty"><p><b>No report file is on record.</b> PMOS drafts one when you ask for it in the console.</p></div>')
|
|
106
|
+
+ `<p class="nsch"><button class="lk" id="repOpen">Open the Reports tab</button> to read, edit or issue one. Schedules are not shown here.</p>`;
|
|
107
|
+
}
|
|
108
|
+
$('#repBody').addEventListener('click', (e) => { if (e.target.closest('[data-rep]') || e.target.closest('#repOpen')) location.assign('/c3.html?tab=rep'); });
|
|
109
|
+
|
|
110
|
+
/* ── dock ─────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
111
|
+
function drawDock() { $('#dN').textContent = M.dock.needs; $('#dLab').textContent = M.dock.label; $('#dNext').innerHTML = M.dock.next ? `<i></i>First <b>${esc(M.dock.next)}</b>` : 'No measure is behind its line'; }
|
|
112
|
+
|
|
113
|
+
/* ── the dialog: the measure's record, no press, the read-only agent beside it ───────────────────────────────── */
|
|
114
|
+
function cardHtml(c) { return `<div class="acard" id="card"><p class="ct">What this page can do</p><p class="nodef" id="holdWhy">${esc(c.dialog.hold)}</p></div>`; }
|
|
115
|
+
function paneHtml(c) {
|
|
116
|
+
const p = c.dialog.pane;
|
|
117
|
+
return `<article class="paper doc"><p class="dpath">${esc(p.file)}</p><div class="kv2">${c.dialog.facts.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div><h3 class="h2">All ${c.pts.length} readings</h3><div class="kv2">${p.rows.map(([a, b]) => `<span>${esc(a)}</span><span>${esc(b)}</span>`).join('')}</div><p class="xn">Read from the KR metric record. The line status is the record's own: the straight line from its baseline to its target. Nothing here is a forecast.</p></article>`;
|
|
118
|
+
}
|
|
119
|
+
function openChart(c) {
|
|
120
|
+
if (!c) return;
|
|
121
|
+
const d = c.dialog;
|
|
122
|
+
openDlg({ eye: d.eye + ' · real data', title: c.title, sub: c.sub + ' · ' + c.chip, say: d.say, stream: turnA(logHtml(d)) + turnA(ptx(d.say)) + cardHtml(c), noteKey: c.key, pane: paneHtml(c), label: 'KR metric record' });
|
|
123
|
+
loadThread(c.key);
|
|
124
|
+
setTimeout(() => { const b = $('#dBody'); b.scrollTop = b.scrollHeight; }, 120);
|
|
125
|
+
}
|
|
126
|
+
$('#dBody').addEventListener('click', (e) => { const lt = e.target.closest('#logT'); if (lt) { const c = $('#alog').classList.toggle('col'); lt.setAttribute('aria-expanded', !c); } });
|
|
127
|
+
|
|
128
|
+
/* ── load ─────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
129
|
+
function draw() { drawHead(); if (!M.dashboards.some((d) => d.id === dash)) dash = 'all'; drawDash(); drawReps(); drawDock(); onScroll(); }
|
|
130
|
+
async function load() {
|
|
131
|
+
const p = new URLSearchParams(location.search), q = [p.get('ws') ? 'ws=' + encodeURIComponent(p.get('ws')) : '', p.get('board') ? 'board=' + encodeURIComponent(p.get('board')) : ''].filter(Boolean).join('&');
|
|
132
|
+
let r = null, status = 0;
|
|
133
|
+
try { const res = await fetch('/api/insights-premium' + (q ? '?' + q : ''), { credentials: 'same-origin' }); status = res.status; r = await res.json(); } catch { r = null; }
|
|
134
|
+
if (!r || !r.ok) {
|
|
135
|
+
$('#snap').textContent = 'The records could not be read';
|
|
136
|
+
$('#brief').textContent = 'The KR metric records could not be read, so this page shows nothing rather than guess.' + (r && r.error ? ' The reason: ' + r.error : status ? ' (the server answered ' + status + ')' : ' The server did not answer.');
|
|
137
|
+
setTimeout(load, 15000);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
M = r.model; draw();
|
|
141
|
+
}
|
|
142
|
+
$('#brief').textContent = 'Reading the records.';
|
|
143
|
+
load();
|
|
@@ -141,8 +141,8 @@ export function onScroll() {
|
|
|
141
141
|
}
|
|
142
142
|
addEventListener('scroll', onScroll, { passive: true }); addEventListener('resize', onScroll);
|
|
143
143
|
|
|
144
|
-
/* ── the rail: Briefing
|
|
145
|
-
const GO = { brief: '/premium.html', work: '/premium-work.html', init: '/premium-board.html', rep: '/
|
|
144
|
+
/* ── the rail: Briefing, My work, Board and Insights are premium pages ── */
|
|
145
|
+
const GO = { brief: '/premium.html', work: '/premium-work.html', init: '/premium-board.html', rep: '/premium-insights.html' };
|
|
146
146
|
export function wireRail(here) {
|
|
147
147
|
const rail = $('.rail');
|
|
148
148
|
rail.style.setProperty('--pi', String(['brief', 'work', 'init', 'rep'].indexOf(here)));
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="pmos-nonce" content="" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
|
7
|
+
<title>PMOS · Insights</title>
|
|
8
|
+
<!-- The premium Insights (initiative briefing-premium-insights, slice 9). The fourth place on the rail, in the Briefing's shell. It reads GET /api/insights-premium, built from the KR metric records and the report files the console's Reports tab reads. It presses nothing and writes nothing. -->
|
|
9
|
+
<link rel="preload" href="/vendor/geist-var.woff2" as="font" type="font/woff2" crossorigin />
|
|
10
|
+
<link rel="stylesheet" href="/pm/premium.css" />
|
|
11
|
+
<link rel="stylesheet" href="/pm/premium-insights.css" />
|
|
12
|
+
</head>
|
|
13
|
+
<body>
|
|
14
|
+
<div class="sky"><i class="a"></i><i class="b"></i><i class="c"></i></div>
|
|
15
|
+
<nav class="rail glass" aria-label="Places">
|
|
16
|
+
<i class="ind"></i>
|
|
17
|
+
<button class="pl" data-go="brief"><svg class="i" viewBox="0 0 24 24"><circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4"/></svg>Briefing</button>
|
|
18
|
+
<button class="pl" data-go="work"><svg class="i" viewBox="0 0 24 24"><rect x="4" y="4" width="16" height="16" rx="3"/><path d="m8.5 12 2.5 2.5 4.5-5"/></svg>My work</button>
|
|
19
|
+
<button class="pl" data-go="init"><svg class="i" viewBox="0 0 24 24"><path d="M12 3 3 8l9 5 9-5z"/><path d="m3 13 9 5 9-5"/></svg>Board</button>
|
|
20
|
+
<button class="pl" data-go="rep" aria-current="page"><svg class="i" viewBox="0 0 24 24"><path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/></svg>Insights</button>
|
|
21
|
+
</nav>
|
|
22
|
+
|
|
23
|
+
<div class="dock glass" id="dock" inert><span class="nm">Insights</span><span class="sep"></span><span class="cnt"><b id="dN">·</b><span id="dLab">need a look</span></span><span class="sep hide-s"></span><span class="pl2 hide-s" id="dNext"></span><span class="sp"></span><button class="round" id="theme2" aria-label="Switch light or dark" style="width:44px;height:44px"><svg class="i" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/></svg></button></div>
|
|
24
|
+
<div class="veil" id="veil"></div>
|
|
25
|
+
<div class="dlg" id="dlg" role="dialog" aria-modal="true" aria-labelledby="dTitle" tabindex="-1" data-mode="split" inert>
|
|
26
|
+
<div class="grab"></div>
|
|
27
|
+
<div class="dhead"><div class="dht"><p class="label" id="dEye"></p><h2 id="dTitle"></h2><p class="dsub" id="dSub"></p></div>
|
|
28
|
+
<div class="dtools"><button class="round dx2" id="dPane" aria-label="Hide the conversation" aria-pressed="true" title="Hide the conversation"><svg class="i" viewBox="0 0 24 24"><rect x="3" y="4" width="18" height="16" rx="3"/><path d="M9 4v16"/></svg></button><button class="round dx2" id="dExpand" aria-label="Full screen" aria-pressed="false" title="Full screen"><svg class="i" viewBox="0 0 24 24"><path id="dExpP" d="M14 4h6v6M10 20H4v-6M20 4l-7 7M4 20l7-7"/></svg></button><button class="round dx2" id="dClose" aria-label="Close"><svg class="i" viewBox="0 0 24 24"><path d="M6 6l12 12M18 6 6 18"/></svg></button></div></div>
|
|
29
|
+
<div class="dtabs" id="dTabs"><div class="seg" role="group" aria-label="Sections"><i class="pill"></i><button data-t="out" aria-pressed="true">Detail</button><button data-t="chat" aria-pressed="false">Conversation</button></div></div>
|
|
30
|
+
<div class="dgrid" id="dGrid" data-tab="out"><section class="pane p-work" id="dBody" aria-label="Conversation"></section>
|
|
31
|
+
<section class="pane p-out" id="dOut" aria-label="Detail"><div class="otop"><span class="ol" id="oLab">Detail</span></div><div class="obody" id="oMain"></div></section></div>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="toast glass" id="toast" role="status"></div>
|
|
34
|
+
<main class="stage" id="stage">
|
|
35
|
+
<header class="top rise" style="--d:0">
|
|
36
|
+
<h1 class="vh">Insights</h1><div id="crumbHost"></div>
|
|
37
|
+
<div class="tools tools-top"><span class="snap" id="snap">Reading the records</span>
|
|
38
|
+
<button class="glass round" id="theme" aria-label="Switch light or dark"><svg class="i" viewBox="0 0 24 24"><path d="M20 14.5A8 8 0 0 1 9.5 4 8 8 0 1 0 20 14.5z"/></svg></button></div>
|
|
39
|
+
</header>
|
|
40
|
+
<section class="hero hero-slim"><p class="brief rise" style="--d:2" id="brief" aria-live="polite"></p></section>
|
|
41
|
+
<div class="nl">
|
|
42
|
+
<div class="nlc">
|
|
43
|
+
<section class="card rise" style="--d:5" id="cDash" aria-labelledby="hDash">
|
|
44
|
+
<div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M4 20V10M10 20V4M16 20v-8M22 20H2"/></svg></span><h2 id="hDash">Dashboards</h2><small id="dashCap"></small></div>
|
|
45
|
+
<div class="seg" id="dashTabs" role="group" aria-label="Dashboard" hidden><i class="pill"></i></div>
|
|
46
|
+
<div id="dashBody"></div>
|
|
47
|
+
</section>
|
|
48
|
+
</div>
|
|
49
|
+
<aside class="nlr" aria-label="Reports">
|
|
50
|
+
<section class="card nrep rise" style="--d:6" id="cRep" aria-labelledby="hRep">
|
|
51
|
+
<div class="ch"><span class="ic"><svg class="i" viewBox="0 0 24 24"><path d="M6 3h9l4 4v14H6z"/><path d="M14 3v5h5M9 13h6M9 17h4"/></svg></span><h2 id="hRep">Reports</h2><small id="repCap"></small></div>
|
|
52
|
+
<div id="repBody"></div>
|
|
53
|
+
</section>
|
|
54
|
+
</aside>
|
|
55
|
+
</div>
|
|
56
|
+
<p class="foot" id="foot">Charts read the KR metric records of this workspace and never invent a number. Left out: the Insight Studio (making your own chart, dashboard or report by conversation), run-based charts such as corrections per 100 runs (they belong to the Board's Metrics card), and any measure no record holds. This page presses nothing and sends nothing.</p>
|
|
57
|
+
</main>
|
|
58
|
+
<noscript>This page needs JavaScript.</noscript>
|
|
59
|
+
<script type="module" src="/pm/premium-insights.js"></script>
|
|
60
|
+
</body>
|
|
61
|
+
</html>
|
package/workspace/server.js
CHANGED
|
@@ -6093,12 +6093,12 @@ async function handleRequest(req, res) {
|
|
|
6093
6093
|
|
|
6094
6094
|
// console3 (public/c3.html) is the default page: '/' and '/index.html' serve it, and '/c3.html' stays an alias so old links
|
|
6095
6095
|
// keep working. The older shell (public/index.html) moved to '/classic.html' (c3-default-page), reachable and easy to return to.
|
|
6096
|
-
if (p === '/' || p === '/index.html' || p === '/c3.html' || p === '/classic' || p === '/classic.html' || p === '/welcome' || p === '/welcome.html' || p === '/premium' || p === '/premium.html' || p === '/premium-work' || p === '/premium-work.html' || p === '/premium-board' || p === '/premium-board.html' || p === '/premium-initiative' || p === '/premium-initiative.html') {
|
|
6096
|
+
if (p === '/' || p === '/index.html' || p === '/c3.html' || p === '/classic' || p === '/classic.html' || p === '/welcome' || p === '/welcome.html' || p === '/premium' || p === '/premium.html' || p === '/premium-work' || p === '/premium-work.html' || p === '/premium-board' || p === '/premium-board.html' || p === '/premium-initiative' || p === '/premium-initiative.html' || p === '/premium-insights' || p === '/premium-insights.html') {
|
|
6097
6097
|
// pm-os-absorb Run 2 (R25, X11): the per-launch nonce goes into the base meta line, nowhere else. no-store, so a
|
|
6098
6098
|
// restarted server never answers a press from a page that holds the previous launch's value. The page code is
|
|
6099
6099
|
// referenced under this launch's build prefix.
|
|
6100
6100
|
const n = pmGuard.launchNonce();
|
|
6101
|
-
return fs.readFile(path.join(PUB, (p === '/classic' || p === '/classic.html') ? 'index.html' : (p === '/welcome' || p === '/welcome.html') ? 'welcome.html' : (p === '/premium' || p === '/premium.html') ? 'premium.html' : (p === '/premium-work' || p === '/premium-work.html') ? 'premium-work.html' : (p === '/premium-board' || p === '/premium-board.html') ? 'premium-board.html' : (p === '/premium-initiative' || p === '/premium-initiative.html') ? 'premium-initiative.html' : 'c3.html'), 'utf8', (err, html) => {
|
|
6101
|
+
return fs.readFile(path.join(PUB, (p === '/classic' || p === '/classic.html') ? 'index.html' : (p === '/welcome' || p === '/welcome.html') ? 'welcome.html' : (p === '/premium' || p === '/premium.html') ? 'premium.html' : (p === '/premium-work' || p === '/premium-work.html') ? 'premium-work.html' : (p === '/premium-board' || p === '/premium-board.html') ? 'premium-board.html' : (p === '/premium-initiative' || p === '/premium-initiative.html') ? 'premium-initiative.html' : (p === '/premium-insights' || p === '/premium-insights.html') ? 'premium-insights.html' : 'c3.html'), 'utf8', (err, html) => {
|
|
6102
6102
|
if (err) { res.writeHead(404); res.end('not found'); return; }
|
|
6103
6103
|
let out = withBuild(html);
|
|
6104
6104
|
if (n) out = out.replace('<meta name="' + pmGuard.NONCE_META + '" content="" />', '<meta name="' + pmGuard.NONCE_META + '" content="' + n + '" />');
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"briefing-premium-agent.test.js",
|
|
41
41
|
"briefing-premium-work.test.js",
|
|
42
42
|
"briefing-premium-board.test.js",
|
|
43
|
+
"briefing-premium-insights.test.js",
|
|
43
44
|
"briefing-premium-initiative.test.js",
|
|
44
45
|
"briefing-premium-doc-edit.test.js",
|
|
45
46
|
"briefing-premium-products.test.js",
|
|
@@ -203,6 +204,7 @@
|
|
|
203
204
|
"briefing-premium-agent.test.js": 1,
|
|
204
205
|
"briefing-premium-work.test.js": 1,
|
|
205
206
|
"briefing-premium-board.test.js": 1,
|
|
207
|
+
"briefing-premium-insights.test.js": 1,
|
|
206
208
|
"briefing-premium-initiative.test.js": 1,
|
|
207
209
|
"briefing-premium-doc-edit.test.js": 1,
|
|
208
210
|
"briefing-premium-products.test.js": 1,
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"briefing-premium-test.js",
|
|
5
5
|
"briefing-premium-work-test.js",
|
|
6
6
|
"briefing-premium-board-test.js",
|
|
7
|
+
"briefing-premium-insights-test.js",
|
|
7
8
|
"briefing-premium-initiative-test.js",
|
|
8
9
|
"briefing-premium-doc-edit-test.js",
|
|
9
10
|
"briefing-premium-products-test.js",
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
"briefing-premium-test.js": 60,
|
|
16
17
|
"briefing-premium-work-test.js": 80,
|
|
17
18
|
"briefing-premium-board-test.js": 120,
|
|
19
|
+
"briefing-premium-insights-test.js": 90,
|
|
18
20
|
"briefing-premium-initiative-test.js": 120,
|
|
19
21
|
"briefing-premium-doc-edit-test.js": 90,
|
|
20
22
|
"briefing-premium-products-test.js": 90,
|