create-pmos 0.388.0 → 0.390.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 +25 -30
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/briefing-premium-insights-test.js +22 -27
- package/workspace/changelog.json +24 -0
- package/workspace/guide/briefing-premium.md +38 -19
- package/workspace/lib/briefing-premium-agent.js +3 -0
- package/workspace/lib/insights-premium.js +10 -8
- package/workspace/lib/report-chat.js +37 -0
- package/workspace/lib/routes-insights-premium.js +3 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-chart-tab-test.js +150 -0
- package/workspace/premium-chat-report-tab-test.js +127 -0
- package/workspace/premium-report-read-test.js +99 -59
- package/workspace/premium-vw-slides-test.js +17 -19
- package/workspace/public/pm/goal-chat.js +2 -1
- package/workspace/public/pm/premium-chart-draw.js +58 -0
- package/workspace/public/pm/premium-chart-tab.js +157 -0
- package/workspace/public/pm/premium-chat.js +8 -2
- package/workspace/public/pm/premium-insights.js +39 -85
- package/workspace/public/pm/premium-report-brief.js +132 -0
- package/workspace/public/pm/premium-report-read.js +276 -103
- package/workspace/public/pm/premium-report-tab.js +235 -0
- package/workspace/public/pm/premium-shell.js +35 -3
- package/workspace/public/pm/premium-vw-doc.js +9 -1
- package/workspace/public/pm/premium-vw-report.css +60 -0
- package/workspace/public/pm/premium-vw-slides.js +14 -5
- package/workspace/public/pm/premium.css +71 -122
- package/workspace/public/pm/report-chat.js +89 -0
- package/workspace/test-lists/premium-chat-chart-tab.json +12 -0
- package/workspace/test-lists/premium-chat-report-tab.json +12 -0
- package/workspace/premium-studio-chart-test.js +0 -193
- package/workspace/premium-studio-report-test.js +0 -277
- package/workspace/premium-studio-test.js +0 -185
- package/workspace/public/pm/premium-studio-design.js +0 -298
- package/workspace/public/pm/premium-studio-report.js +0 -291
- package/workspace/public/pm/premium-studio.js +0 -453
- package/workspace/test-lists/premium-studio-chart.json +0 -13
- package/workspace/test-lists/premium-studio-report.json +0 -9
- package/workspace/test-lists/premium-studio.json +0 -9
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/* pm/premium-report-brief.js — the Brief of a report: how it is made, in its own viewer tab beside the report (initiative premium-reports-from-chat;
|
|
2
|
+
* PM 2026-10-22: "the Report Design Brief alongside the design, so I know what the report is, how it is structured, how the data is gathered, how
|
|
3
|
+
* it is calculated … not part of the report … so I can validate and make corrections", then "Report brief can be open on Viewer tab").
|
|
4
|
+
*
|
|
5
|
+
* openBrief(ctx) open (or show) the Brief tab of the open report
|
|
6
|
+
* refreshBrief(ctx) draw it again if it is open (after a correction)
|
|
7
|
+
* briefParts(x) the sections as [{ id, t, html }] and the open questions, from the stored records (pure; x = { structure, design, ctx })
|
|
8
|
+
* ctx = { ws, id, name, issued, setup, design, schedWords, format, correct(title), goBack(n) }
|
|
9
|
+
*
|
|
10
|
+
* READS: GET /api/report-structure (the structure plan, its sources, charts and outline, and their checks) and the design the reader holds
|
|
11
|
+
* (GET /api/report-design). Nothing new is stored: the Brief is what PMOS already keeps, said in words. Where a record is silent, the Brief says
|
|
12
|
+
* "not said" and lists it under Please confirm; it never fills a gap with a guess.
|
|
13
|
+
* WRITES: only on a press: Use it on a new structure version (POST /api/report-structure/accept). Correct puts `Correct "<section>": ` in the
|
|
14
|
+
* chat box; the reader sends it as a structure turn. Go back to it (an earlier look) is the reader's revert. */
|
|
15
|
+
import { esc, toast } from './premium-shell.js';
|
|
16
|
+
import { pmGet, pmPost } from './http.js';
|
|
17
|
+
import { vwOpen, vwState } from './premium-viewer.js';
|
|
18
|
+
|
|
19
|
+
const tabId = (ctx) => 'brief:' + ctx.id;
|
|
20
|
+
const day = (s) => { const d = new Date(String(s || '')); return isNaN(d) ? '' : d.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' }); };
|
|
21
|
+
const NS = '<span class="tag as">not said</span>';
|
|
22
|
+
const say = (v) => v ? esc(v) : NS;
|
|
23
|
+
const STATE = { reached: ['reached', 'ok'], 'needs-you': ['needs you', 'no'], 'not-connected': ['not connected', 'no'], later: ['later', ''], off: ['off', ''] };
|
|
24
|
+
const KIND = { deck: 'Slide deck in PMOS', page: 'A page in PMOS', doc: 'A page in PMOS' };
|
|
25
|
+
|
|
26
|
+
/** The Brief's sections from the records. Each open question also counts toward "N to confirm". */
|
|
27
|
+
export function briefParts({ structure, design, ctx }) {
|
|
28
|
+
const S = structure || null, plan = S && S.plan, D = design || null, su = ctx.setup || null, open = [];
|
|
29
|
+
const sec = [];
|
|
30
|
+
const pu = (plan && plan.purpose) || {};
|
|
31
|
+
const ver = S && S.current != null ? 'S' + S.current + (S.saved === S.current ? '' : S.saved ? ' (S' + S.saved + ' is saved)' : ', not saved yet') : '';
|
|
32
|
+
if (!plan) open.push(su ? 'No structure is saved for this report yet. Say in the chat who reads it and what it answers.' : 'This report has no template, so PMOS keeps no structure or design for it. Say in a chat how often it is drafted, and PMOS sets one up.');
|
|
33
|
+
else {
|
|
34
|
+
if (!pu.readers) open.push('Who reads it?');
|
|
35
|
+
if (!pu.decision) open.push('What decision does it help make?');
|
|
36
|
+
if (!pu.scope) open.push('What is in it, and what is left out?');
|
|
37
|
+
if (!(pu.questions || []).length) open.push('Which questions should it answer?');
|
|
38
|
+
}
|
|
39
|
+
const made = !su ? 'By hand: a file with no template' : su.source === 'work' ? 'The schedule, from the saved structure' + (D && D.saved ? ' and design' : '') : su.source ? 'The schedule, from ' + su.source : 'The schedule';
|
|
40
|
+
sec.push({ id: 'glance', t: 'At a glance', html: `<dl class="rbkv"><dt>What it is</dt><dd>${say((su && su.purpose) || pu.decision)}</dd><dt>For</dt><dd>${say(pu.readers || (su && su.audience))}</dd><dt>Decision</dt><dd>${say(pu.decision)}</dd>`
|
|
41
|
+
+ `<dt>Schedule</dt><dd>${su ? esc(ctx.schedWords) : 'None: it has no template'}</dd><dt>Format</dt><dd>${esc(KIND[ctx.format] || KIND.deck)}</dd><dt>Made by</dt><dd>${esc(made)}</dd>${ver ? `<dt>Structure</dt><dd>${esc(ver)}</dd>` : ''}</dl>` });
|
|
42
|
+
if (!plan) return { sections: sec.concat(lookSections(D, ctx, open)).concat(openSection(open)), open };
|
|
43
|
+
sec.push({ id: 'questions', t: 'Questions it answers', html: (pu.questions || []).length ? '<ol>' + pu.questions.map((x) => `<li>${esc(x)}</li>`).join('') + '</ol>' : `<p>${NS}</p>` });
|
|
44
|
+
sec.push({ id: 'scope', t: 'In and out of scope', html: `<p>${say(pu.scope)}</p>${pu.cadence ? `<p><b>Covers:</b> ${esc(pu.cadence)}</p>` : ''}` });
|
|
45
|
+
const chartName = (id) => { const c = (plan.charts || []).find((x) => x.id === id); return c ? c.name : id; };
|
|
46
|
+
sec.push({ id: 'structure', t: 'How it is structured', html: '<ol>' + (plan.outline || []).map((o) => `<li><b>${esc(o.title)}</b>${o.notes ? ': ' + esc(o.notes) : ''}${(o.charts || []).length ? ' <span class="rbsub">Shows ' + esc(o.charts.map(chartName).join(', ')) + '.</span>' : ''}${o.fixed ? ' <span class="rbsub">In every report.</span>' : ''}</li>`).join('') + '</ol>' });
|
|
47
|
+
sec.push({ id: 'data', t: 'Where the data comes from', html: (plan.sources || []).length ? '<ul>' + plan.sources.map((s) => {
|
|
48
|
+
const st = STATE[s.state] || [s.state || '', ''];
|
|
49
|
+
if (!s.use) open.push('What is ' + s.name + ' used for?');
|
|
50
|
+
if (s.state === 'needs-you') open.push(s.name + ' could not be reached. Check its sign-in, or say what to use instead.');
|
|
51
|
+
if (s.state === 'not-connected') open.push(s.name + ' is not connected. Connect it, or say what to use instead.');
|
|
52
|
+
return `<li><b>${esc(s.name)}</b>${s.via ? ', through ' + esc(s.via) : ''}${s.ref ? ', <code>' + esc(s.ref) + '</code>' : ''}. ${s.use ? esc(s.use) : 'Use ' + NS}${st[0] ? ` <span class="tag ${st[1]}">${esc(st[0])}</span>` : ''}</li>`;
|
|
53
|
+
}).join('') + '</ul>' : `<p>No source is named. ${NS}</p>` });
|
|
54
|
+
const srcName = (id) => ((plan.sources || []).find((x) => x.id === id) || { name: id }).name;
|
|
55
|
+
sec.push({ id: 'calc', t: 'How each number is worked out', html: (plan.charts || []).length ? plan.charts.map((c) => {
|
|
56
|
+
if (!c.how) open.push('How is "' + c.name + '" worked out?');
|
|
57
|
+
return `<div class="rbcalc"><b>${esc(c.name)}</b>${c.question ? `<p>Answers: ${esc(c.question)}</p>` : ''}<p><b>From</b> ${esc(srcName(c.source))}${c.from ? ': ' + esc(c.from) : ''}</p><p><b>Worked out</b> ${say(c.how)}</p>${c.compare ? `<p><b>Compared with</b> ${esc(c.compare)}</p>` : ''}${c.flag ? `<p><b>Flagged when</b> ${esc(c.flag)}</p>` : ''}</div>`;
|
|
58
|
+
}).join('') : `<p>No number is worked out: the report is words only.</p>` });
|
|
59
|
+
const checks = Object.entries(S.checks || {}).map(([sid, c]) => `<li>${esc(srcName(sid))}: ${c.ok ? 'checked, it works <span class="tag ok">passed</span>' : esc(c.why || c.error || c.note || 'the last check did not pass') + ' <span class="tag no">needs you</span>'}${c.at ? ' (' + esc(day(c.at)) + ')' : ''}</li>`);
|
|
60
|
+
const errs = (S.errors || []).slice(-2).map((e) => `<li>The last structure run failed: ${esc(e.text)}</li>`);
|
|
61
|
+
sec.push({ id: 'checks', t: 'Checks and caveats', html: checks.length || errs.length ? '<ul>' + checks.concat(errs).join('') + '</ul>' : '<p>No source check has run. A source that PMOS reads itself needs none.</p>' });
|
|
62
|
+
if (S.current != null && S.saved !== S.current) open.push('The brief has a new version (S' + S.current + ') that is not saved. Press Use it at the top to keep it.');
|
|
63
|
+
return { sections: sec.concat(lookSections(D, ctx, open), historySection(S, D), openSection(open)), open };
|
|
64
|
+
}
|
|
65
|
+
function lookSections(D, ctx, open) {
|
|
66
|
+
if (!D) return ctx.issued ? [{ id: 'design', t: 'Why it looks like this', html: '<p>This cycle is issued, so its look is frozen as it was.</p>' }] : [];
|
|
67
|
+
const r = D.rules || { same: [], changes: [], learned: [] }, saved = D.saved ? D.saved.version : null;
|
|
68
|
+
if (!D.description && !(D.samples || []).length && !saved) open.push('How should it look? Say it in the chat, or attach a sample.');
|
|
69
|
+
const L = (h, xs) => (xs || []).length ? `<li><b>${h}</b> ${xs.map(esc).join('; ')}.</li>` : '';
|
|
70
|
+
const smp = (D.samples || []).map((s) => `<li>Follows <i>${esc(s.name)}</i>${s.took ? ': ' + esc(typeof s.took === 'string' ? s.took : s.took.took || '') : ''}.</li>`).join('');
|
|
71
|
+
const earlier = (D.versions || []).filter((v) => v.n !== saved).slice().reverse().slice(0, 5)
|
|
72
|
+
.map((v) => `<li>${esc(day(v.made_at))}: ${esc(v.turn || 'a version without a request')}${ctx.issued ? '' : ` <button type="button" class="rbfix" data-rb="back|${v.n}">Go back to it</button>`}</li>`).join('');
|
|
73
|
+
return [{ id: 'design', t: 'Why it looks like this', html: `<ul>${D.description ? `<li>${esc(D.description)}</li>` : ''}${smp}${L('Stays the same each cycle:', r.same)}${L('Changes each cycle:', r.changes)}${L('Learned from you:', r.learned)}</ul>`
|
|
74
|
+
+ (saved ? '' : '<p>No look is saved yet: each cycle uses the standard PMOS look.</p>') + (earlier ? `<p><b>Earlier looks</b></p><ul>${earlier}</ul>` : '') }];
|
|
75
|
+
}
|
|
76
|
+
function historySection(S, D) {
|
|
77
|
+
const E = [];
|
|
78
|
+
for (const v of (S && S.versions) || []) E.push({ at: v.at, t: 'Structure: ' + (v.turn || 'S' + v.n) });
|
|
79
|
+
for (const v of (D && D.versions) || []) E.push({ at: v.made_at, t: 'Look: ' + (v.turn || 'D' + v.n) });
|
|
80
|
+
E.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
81
|
+
return { id: 'history', t: 'What changed', html: E.length ? '<ul>' + E.slice(0, 8).map((e) => `<li>${esc(day(e.at))}: ${esc(e.t)}</li>`).join('') + '</ul>' : '<p>Nothing has changed since it was set up.</p>' };
|
|
82
|
+
}
|
|
83
|
+
const openSection = (open) => ({ id: 'open', t: 'Please confirm', html: open.length ? '<ol>' + open.map((x) => `<li>${esc(x)}</li>`).join('') + '</ol>' : '<p>Nothing open.</p>' });
|
|
84
|
+
|
|
85
|
+
const B = new Map(); // tab id → { ctx, structure, err }
|
|
86
|
+
function html(id) {
|
|
87
|
+
const b = B.get(id), ctx = b.ctx;
|
|
88
|
+
if (b.loading) return '<div class="rbrief"><p class="note">Reading how this report is made.</p></div>';
|
|
89
|
+
const { sections, open } = briefParts({ structure: b.structure, design: ctx.design, ctx });
|
|
90
|
+
const S = b.structure, use = S && S.plan && S.current != null && S.saved !== S.current && !ctx.issued;
|
|
91
|
+
return `<div class="rbrief"><div class="rbhd"><span><b>How this report is made</b><small>Not part of the report${b.err ? ' · ' + esc(b.err) : ''}</small></span>${open.length ? `<span class="rbto">${open.length} to confirm</span>` : ''}${use ? `<button type="button" class="dmcta dark" data-rb="use|${S.current}">Use it</button>` : ''}</div>`
|
|
92
|
+
+ `<nav class="rbtoc" aria-label="Brief sections">${sections.map((x) => `<button type="button" data-rb="go|${x.id}">${esc(x.t)}</button>`).join('')}</nav>`
|
|
93
|
+
+ sections.map((x) => `<section class="rbs" id="rb-${x.id}"><h4>${esc(x.t)}${x.id === 'glance' || x.id === 'history' ? '' : `<button type="button" class="rbfix" data-rb="fix|${esc(x.t)}" aria-label="Correct ${esc(x.t)}">Correct</button>`}</h4>${x.html}</section>`).join('') + '</div>';
|
|
94
|
+
}
|
|
95
|
+
async function load(id) {
|
|
96
|
+
const b = B.get(id), ctx = b.ctx;
|
|
97
|
+
const j = await Promise.resolve(pmGet('/api/report-structure?ws=' + encodeURIComponent(ctx.ws) + '&id=' + encodeURIComponent(ctx.id))).catch(() => null);
|
|
98
|
+
b.structure = j && j.ok ? j.structure : null;
|
|
99
|
+
b.err = j && !j.ok && j.status !== 404 && j.error ? 'the structure could not be read: ' + j.error : '';
|
|
100
|
+
b.loading = false;
|
|
101
|
+
}
|
|
102
|
+
function show(id) {
|
|
103
|
+
vwOpen({ id, title: 'Brief', icon: 'doc', html: html(id), wire: (el) => { el.onclick = (e) => press(id, e); } });
|
|
104
|
+
}
|
|
105
|
+
async function press(id, e) {
|
|
106
|
+
const t = e.target.closest('[data-rb]'); if (!t || t.disabled) return;
|
|
107
|
+
const [k, v] = t.dataset.rb.split('|'), b = B.get(id);
|
|
108
|
+
if (k === 'go') { const s = document.getElementById('rb-' + v); if (s) s.scrollIntoView({ behavior: 'smooth', block: 'start' }); return; }
|
|
109
|
+
if (k === 'fix') { b.ctx.correct(v); return; }
|
|
110
|
+
if (k === 'back') { t.disabled = true; await b.ctx.goBack(+v); return; }
|
|
111
|
+
if (k === 'use') {
|
|
112
|
+
t.disabled = true;
|
|
113
|
+
const r = await pmPost('/api/report-structure/accept', { ws: b.ctx.ws, id: b.ctx.id, n: +v }).catch(() => null);
|
|
114
|
+
if (!r || r.ok !== true) { t.disabled = false; toast((r && r.error) || 'The brief was not saved.'); return; }
|
|
115
|
+
toast('Saved. The next cycle is drafted from this brief.');
|
|
116
|
+
b.structure = r.structure || b.structure; show(id);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export async function openBrief(ctx) {
|
|
120
|
+
const id = tabId(ctx);
|
|
121
|
+
B.set(id, { ctx, structure: null, err: '', loading: true });
|
|
122
|
+
show(id);
|
|
123
|
+
await load(id);
|
|
124
|
+
if (B.get(id) && B.get(id).ctx === ctx) show(id);
|
|
125
|
+
}
|
|
126
|
+
export async function refreshBrief(ctx) {
|
|
127
|
+
const id = tabId(ctx);
|
|
128
|
+
if (!vwState().ids.includes(id)) return;
|
|
129
|
+
B.set(id, { ...(B.get(id) || {}), ctx, loading: false });
|
|
130
|
+
await load(id);
|
|
131
|
+
show(id);
|
|
132
|
+
}
|