create-pmos 0.482.0 → 0.484.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 +27 -27
- 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/changelog.json +26 -0
- package/workspace/guide/briefing-premium.md +6 -2
- package/workspace/guide/home.md +1 -1
- package/workspace/home-rows-test.js +3 -1
- package/workspace/lib/goal-chat.js +29 -5
- package/workspace/lib/report-chat.js +3 -2
- package/workspace/lib/report-templates.js +172 -0
- package/workspace/lib/route-modules.js +1 -0
- package/workspace/lib/routes-report-flow.js +184 -0
- package/workspace/lib/routes-reports.js +4 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-chat-report-tab-test.js +40 -33
- package/workspace/premium-html-viewer-test.js +6 -0
- package/workspace/public/pm/cozy-vw-rp.css +48 -0
- package/workspace/public/pm/home-app.js +6 -2
- package/workspace/public/pm/home-chat.js +3 -3
- package/workspace/public/pm/home-list.js +10 -3
- package/workspace/public/pm/home-today.js +2 -2
- package/workspace/public/pm/premium-report-read.js +40 -6
- package/workspace/public/pm/premium-report-tab.js +163 -74
- package/workspace/public/pm/premium-vw-doc.css +6 -1
- package/workspace/public/pm/premium-vw-file.js +7 -2
- package/workspace/public/pm/premium-vw-pdf.js +42 -0
- package/workspace/public/pm/report-chat.js +5 -3
- package/workspace/public/pm/report-flow.js +163 -0
- package/workspace/public/vendor/pdf.min.js +28 -0
- package/workspace/public/vendor/pdf.worker.min.js +28 -0
- package/workspace/ready-dash-ui-test.js +2 -1
- package/workspace/server.js +3 -0
- package/workspace/test-lists/report-flow.json +11 -0
- package/workspace/third-party/README.md +9 -4
- package/workspace/third-party/pdfjs-dist-5.4.296.LICENSE +177 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/* pm/report-flow.js — the report building flow's parts, drawn as html (batch 22 item 14, "A+ on Home", canvas RfH1–RfH7). Pure: no DOM and no
|
|
2
|
+
* fetch, so node tests it (report-flow.test.mjs). premium-report-tab.js draws the questions and the template; premium-report-read.js draws the review.
|
|
3
|
+
*
|
|
4
|
+
* picksOf(proposal) → the answers a new report starts with: Claude's picks (format, who reads it, when it goes out)
|
|
5
|
+
* picksOfSettings(settings) → the same, from a template version (lib/report-templates.js settings)
|
|
6
|
+
* settingsOfPicks(q) → { output, audience, schedule } as the routes take them
|
|
7
|
+
* changedOf(q, base) → ['output' | 'audience' | 'schedule'] what differs from the current template
|
|
8
|
+
* diffOf(q, base) → ['Format: Slides → Document', …] the same, in words
|
|
9
|
+
* questionsHtml(q, o) the questions (RfH4, RfH7): Format, Readers, Goes out, Look, Sources, then Draft it.
|
|
10
|
+
* o.template draws them as the template (RfH3): "changed" marks, the history, Keep the current template and
|
|
11
|
+
* Make a different template
|
|
12
|
+
* historyHtml(versions) Template history: T<n>, what it is, when, the cycles issued with it, Go back to T<n>
|
|
13
|
+
* waitHtml(F) the report's current state while no cycle is written yet: drafting, ended, or no draft (RfH1)
|
|
14
|
+
* reviewHtml(rv, o) Claude's review of a draft in the proposal pattern (RfH2): one line, a ✦ row per fix with Not now and Do it,
|
|
15
|
+
* Do all, and "N other checks found nothing"
|
|
16
|
+
* Every press is an attribute (data-rt for the tab, data-r for the reader), so the caller wires it. Nothing here sends anything outward.
|
|
17
|
+
* Not drawn, as the agreed note says they are not proven: stakeholder groups (Readers is the words Claude picked), example issue dates, a look read
|
|
18
|
+
* from an attached PDF, and a review score. */
|
|
19
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
20
|
+
const SV = (d, n = 16) => `<svg viewBox="0 0 24 24" width="${n}" height="${n}" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
21
|
+
export const ICON = { go: 'M5 12h14M13 6l6 6-6 6', x: 'M6 6l12 12M18 6L6 18', check: 'M5 12.5l4.5 4.5L19 7.5', back: 'M9 14 4 9l5-5M4 9h11a5 5 0 0 1 0 10h-3',
|
|
22
|
+
tune: 'M4 7h10M18 7h2M4 17h2M10 17h10M14 5v4M8 15v4' };
|
|
23
|
+
export const FORMAT_NAMES = { 'google-slides': ['Slides', 'Read aloud or presented.'], 'google-doc': ['Document', 'Read alone, with tables and footnotes.'],
|
|
24
|
+
pdf: ['PDF', 'A fixed page to read or print.'], 'google-sheets': ['Sheets', 'The numbers as a table.'], confluence: ['Confluence page', 'A page in your wiki.'] };
|
|
25
|
+
export const CADENCES = [['weekly', 'Every week'], ['bi-weekly', 'Every two weeks'], ['monthly', 'Every month'], ['daily', 'Every day']];
|
|
26
|
+
const DAYS = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'];
|
|
27
|
+
const TIMES = ['07:00', '08:00', '09:00', '10:00', '12:00', '14:00', '16:00', '17:00'];
|
|
28
|
+
|
|
29
|
+
/** The answers a new report starts with: Claude's picks. */
|
|
30
|
+
export function picksOf(p = {}) {
|
|
31
|
+
const s = p.schedule && typeof p.schedule === 'object' && p.schedule.cadence ? p.schedule : null;
|
|
32
|
+
return { output: p.output || 'google-slides', audience: p.audience || '', repeat: !!s, cadence: s ? s.cadence : 'weekly', day: (s && s.day) || 'Mon', dayOfMonth: (s && s.dayOfMonth) || 1, time: (s && s.time) || '09:00',
|
|
33
|
+
pick: { output: p.output || 'google-slides', audience: p.audience || '' } };
|
|
34
|
+
}
|
|
35
|
+
export function picksOfSettings(st = {}) {
|
|
36
|
+
const q = picksOf({ output: st.output, audience: st.audience, schedule: st.schedule === 'off' ? null : st.schedule });
|
|
37
|
+
q.pick = null;
|
|
38
|
+
return q;
|
|
39
|
+
}
|
|
40
|
+
/** The answers as the routes take them. Once is schedule 'off'. */
|
|
41
|
+
export function settingsOfPicks(q) {
|
|
42
|
+
const schedule = !q.repeat ? 'off' : { cadence: q.cadence, ...(q.cadence === 'weekly' || q.cadence === 'bi-weekly' ? { day: q.day || 'Mon' } : {}), ...(q.cadence === 'monthly' ? { dayOfMonth: +q.dayOfMonth || 1 } : {}), time: q.time || '09:00' };
|
|
43
|
+
return { output: q.output, audience: String(q.audience || '').replace(/\s+/g, ' ').trim(), schedule };
|
|
44
|
+
}
|
|
45
|
+
const schedKey = (s) => JSON.stringify(!s || s === 'off' ? 'off' : [s.cadence, s.day || null, s.dayOfMonth || null, s.time || '09:00']);
|
|
46
|
+
/** What differs from the current template's settings. */
|
|
47
|
+
export function changedOf(q, base) {
|
|
48
|
+
if (!base) return [];
|
|
49
|
+
const now = settingsOfPicks(q), out = [];
|
|
50
|
+
if (now.output !== base.output) out.push('output');
|
|
51
|
+
if (now.audience !== (base.audience || '')) out.push('audience');
|
|
52
|
+
if (schedKey(now.schedule) !== schedKey(base.schedule)) out.push('schedule');
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
/** What changed, in words: ["Format: Slides → Document", …]. base is a template version's settings. */
|
|
56
|
+
export function diffOf(q, base) {
|
|
57
|
+
if (!base) return [];
|
|
58
|
+
const now = settingsOfPicks(q), was = picksOfSettings(base), out = [], fmt = (k) => (FORMAT_NAMES[k] || [k || 'none'])[0];
|
|
59
|
+
for (const c of changedOf(q, base)) {
|
|
60
|
+
if (c === 'output') out.push('Format: ' + fmt(base.output) + ' → ' + fmt(now.output));
|
|
61
|
+
if (c === 'audience') out.push('Readers: ' + (base.audience || 'none') + ' → ' + (now.audience || 'none'));
|
|
62
|
+
if (c === 'schedule') out.push('Goes out: ' + goesWords(was) + ' → ' + goesWords(q));
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
/** When it goes out, in words. */
|
|
67
|
+
export function goesWords(q) {
|
|
68
|
+
if (!q.repeat) return 'Once';
|
|
69
|
+
const c = (CADENCES.find((x) => x[0] === q.cadence) || CADENCES[0])[1];
|
|
70
|
+
return c + (q.cadence === 'weekly' || q.cadence === 'bi-weekly' ? ', ' + (q.day || 'Mon') : q.cadence === 'monthly' ? ', day ' + (q.dayOfMonth || 1) : '') + ' ' + (q.time || '09:00');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const tag = (t, k) => `<span class="rf-tag"${k ? ` data-k="${k}"` : ''}>${esc(t)}</span>`;
|
|
74
|
+
function formatHtml(q, ch, a) {
|
|
75
|
+
const keys = ['google-slides', 'google-doc'].concat(q.output && !['google-slides', 'google-doc'].includes(q.output) ? [q.output] : []);
|
|
76
|
+
const rows = keys.map((k) => {
|
|
77
|
+
const [name, what] = FORMAT_NAMES[k] || [k, ''];
|
|
78
|
+
const on = q.output === k;
|
|
79
|
+
return `<button type="button" class="rf-opt vz-hv" role="radio" aria-checked="${on}" ${a}="fmt|${esc(k)}"><span class="vz-ring"></span><span class="rf-ot"><b>${esc(name)}</b>`
|
|
80
|
+
+ `${on && q.pick && q.pick.output === k ? tag('my pick') : ''}${on && ch.includes('output') ? tag('changed', 'ch') : ''}<span>${esc(what)}</span></span></button>`;
|
|
81
|
+
}).join('');
|
|
82
|
+
return `<fieldset class="rf-q"><legend>Format</legend><div role="radiogroup" aria-label="Format">${rows}</div><p class="vz-note">PDF, PowerPoint, Word and Excel are all in Download, whichever you pick.</p></fieldset>`;
|
|
83
|
+
}
|
|
84
|
+
function readersHtml(q, ch, a, o) {
|
|
85
|
+
return `<fieldset class="rf-q"><legend>Readers${ch.includes('audience') ? ' ' + tag('changed', 'ch') : ''}</legend><label class="rf-in"><span class="rf-sr">Who the report is written for</span>`
|
|
86
|
+
+ `<input type="text" maxlength="120" value="${esc(q.audience)}" ${a}="aud" placeholder="Who reads it"></label>`
|
|
87
|
+
+ `<p class="vz-note">Who the report is written for. Nothing is sent to them: after you issue it, you share it yourself.${o.template ? ' Changing readers makes a different template.' : ''}</p></fieldset>`;
|
|
88
|
+
}
|
|
89
|
+
function goesHtml(q, ch, a) {
|
|
90
|
+
const opt = (v, label) => `<button type="button" class="rf-seg vz-hv" role="radio" aria-checked="${q.repeat === v}" ${a}="rep|${v ? 1 : 0}">${esc(label)}</button>`;
|
|
91
|
+
const sel = (key, list, cur, label) => `<label class="rf-sel"><span class="rf-sr">${esc(label)}</span><select ${a}="${key}">${list.map(([v, t]) => `<option value="${esc(v)}"${String(v) === String(cur) ? ' selected' : ''}>${esc(t)}</option>`).join('')}</select></label>`;
|
|
92
|
+
const more = q.repeat ? `<div class="rf-row">${sel('cad', CADENCES, q.cadence, 'How often')}`
|
|
93
|
+
+ (q.cadence === 'weekly' || q.cadence === 'bi-weekly' ? sel('day', DAYS.map((d) => [d, d]), q.day, 'Day') : '')
|
|
94
|
+
+ (q.cadence === 'monthly' ? sel('dom', Array.from({ length: 28 }, (_, i) => [i + 1, 'Day ' + (i + 1)]), q.dayOfMonth, 'Day of the month') : '')
|
|
95
|
+
+ sel('time', TIMES.concat(TIMES.includes(q.time) ? [] : [q.time]).sort().map((t) => [t, t]), q.time, 'Time') + '</div>' : '';
|
|
96
|
+
return `<fieldset class="rf-q"><legend>Goes out${ch.includes('schedule') ? ' ' + tag('changed', 'ch') : ''}</legend><div class="rf-row" role="radiogroup" aria-label="Goes out">${opt(false, 'Once')}${opt(true, 'Repeats')}</div>${more}`
|
|
97
|
+
+ `<p class="vz-note">${q.repeat ? 'Claude drafts each cycle on its day. ' : ''}You approve each issue; nothing goes out by itself.</p></fieldset>`;
|
|
98
|
+
}
|
|
99
|
+
function lookHtml(o) {
|
|
100
|
+
const words = o.look ? `<p class="vz-note">Your words: “${esc(o.look)}”. Claude makes this look after the first draft; until then it uses the standard look.</p>` : '';
|
|
101
|
+
return `<fieldset class="rf-q"><legend>Look</legend><p class="rf-fix"><b>Standard PMOS look</b><span>Nunito, navy title slides, 16:9</span></p>${words}</fieldset>`;
|
|
102
|
+
}
|
|
103
|
+
function sourcesHtml(o) {
|
|
104
|
+
const L = (o.sources || []).filter(Boolean);
|
|
105
|
+
if (!L.length) return '';
|
|
106
|
+
return `<fieldset class="rf-q"><legend>Sources</legend><ul class="rf-src">${L.map((x) => `<li>${esc(x)}</li>`).join('')}</ul><p class="vz-note">Claude reads these for the draft. Each slide names what it read, and what it could not reach.</p></fieldset>`;
|
|
107
|
+
}
|
|
108
|
+
/** Template history (RfH3): newest first; each one that is not the current one has Go back. */
|
|
109
|
+
export function historyHtml(versions = [], a = 'data-rt', o = {}) {
|
|
110
|
+
if (!versions.length) return '';
|
|
111
|
+
const day = (iso) => { const d = new Date(iso || ''); return Number.isFinite(d.getTime()) ? d.toLocaleDateString('en-GB', { day: 'numeric', month: 'short' }) : ''; };
|
|
112
|
+
const pend = o.pending ? `<li class="rf-hv" data-k="new"><b>T${(versions[0] ? versions[0].n : 0) + 1}</b><span>${esc(o.pending)}<em>Unsaved · waits for Make a different template</em></span></li>` : '';
|
|
113
|
+
const rows = versions.map((v) => `<li class="rf-hv"${v.current ? ' aria-current="true"' : ''}><b>T${v.n}</b><span>${esc(v.why || v.words || '')}<em>${esc([day(v.at), v.current ? 'current' : '', v.cycles ? v.cycles + (v.cycles === 1 ? ' cycle issued' : ' cycles issued') : ''].filter(Boolean).join(' · '))}</em></span>`
|
|
114
|
+
+ (v.current ? '' : `<button type="button" class="rf-ib vz-hv" ${a}="restore|${v.n}" aria-label="Go back to T${v.n}" title="Go back to T${v.n}"${o.busy ? ' disabled' : ''}>${SV(ICON.back)}</button>`) + '</li>').join('');
|
|
115
|
+
return `<section class="rf-hist"><h3>Template history</h3><ol>${pend}${rows}</ol><p class="vz-note">Going back makes that version the current one. Nothing is deleted.</p></section>`;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The questions. q = picksOf(…) as the PM changed it. o = { template?: { base, versions, diff }, look, sources, busy, msg }.
|
|
119
|
+
* A new report ends with "Nothing goes out" and Draft it; a template ends with its history and Keep the current template | Make a different template.
|
|
120
|
+
*/
|
|
121
|
+
export function questionsHtml(q, o = {}, a = 'data-rt') {
|
|
122
|
+
const T = o.template, ch = T ? changedOf(q, T.base) : [];
|
|
123
|
+
const st = T ? (ch.length ? 'Template · changed, not saved yet' : 'Template · T' + (T.current || 1)) : 'Waits on your answers';
|
|
124
|
+
const head = `<p class="rf-st"><i class="rf-dot" data-k="you" aria-hidden="true"></i>${esc(st)}</p>`;
|
|
125
|
+
const body = formatHtml(q, ch, a) + readersHtml(q, ch, a, o) + goesHtml(q, ch, a) + lookHtml(o) + (T ? '' : sourcesHtml(o));
|
|
126
|
+
const msg = o.msg ? `<p class="vz-msg" role="status">${esc(o.msg)}</p>` : '';
|
|
127
|
+
if (!T) {
|
|
128
|
+
return `<div class="rf-qs">${head}${body}${msg}<div class="rf-foot"><span class="vz-note">Nothing goes out</span><button type="button" class="rf-ib pri vz-hv" ${a}="draftit" aria-label="Draft it" title="Draft it"${o.busy || !q.audience.trim() ? ' disabled' : ''}>${SV(ICON.go, 18)}</button></div></div>`;
|
|
129
|
+
}
|
|
130
|
+
const words = ch.length ? T.diff : [];
|
|
131
|
+
const note = words.length ? `<p class="rf-chg">${tag('changed', 'ch')} ${esc(words.join('; '))}. This makes a different template. The current one keeps its draft and its cycles.</p>` : '';
|
|
132
|
+
return `<div class="rf-qs">${head}${body}${note}${historyHtml(T.versions, a, { pending: words.length ? words.join('; ') : '', busy: o.busy })}${msg}`
|
|
133
|
+
+ `<div class="rf-foot"><button type="button" class="rf-ib vz-hv" ${a}="keep" aria-label="Keep the current template" title="Keep the current template">${SV(ICON.back)}</button>`
|
|
134
|
+
+ `<button type="button" class="rf-ib pri vz-hv" ${a}="maketpl" aria-label="Make a different template" title="Make a different template"${o.busy || !words.length || !q.audience.trim() ? ' disabled' : ''}>${SV(ICON.check, 18)}</button></div></div>`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** The current state while no cycle is written yet (RfH1): drafting in the report's own session, a session that ended, or no draft. */
|
|
138
|
+
export function waitHtml(F = {}, face = '') {
|
|
139
|
+
const d = F.drafting;
|
|
140
|
+
if (d && d.state === 'held') return `<div class="rf-wait">${face}<p><b>The draft waits for a check of ${esc((d.sources || []).join(', '))}.</b><span>It starts by itself when the check passes.</span></p></div>`;
|
|
141
|
+
if (d && d.state === 'ended') return `<div class="rf-wait" data-k="bad">${face}<p><b>The drafting session ended before a draft was written.</b><span>${esc(d.reason || '')}</span></p><button type="button" class="rf-ib pri vz-hv" data-rt="redraft" aria-label="Draft it again" title="Draft it again">${SV(ICON.go)}</button></div>`;
|
|
142
|
+
if ((d && d.state === 'drafting') || (F.session && F.session.alive)) return `<div class="rf-wait" role="status">${face}<p><b>The report's own session is drafting it.</b><span>It opens here when it lands. Keep talking to Claude in the chat.</span></p></div>`;
|
|
143
|
+
return `<div class="rf-wait">${face}<p><b>No draft yet.</b><span>Draft it now, or it drafts on its day.</span></p><button type="button" class="rf-ib pri vz-hv" data-rt="redraft" aria-label="Draft it now" title="Draft it now">${SV(ICON.go)}</button></div>`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Claude's review of a draft (RfH2), in the proposal pattern. rv = { fix: [{ id, title, why }], passed: [label] } from GET /api/report-flow/review.
|
|
148
|
+
* o = { hidden: Set of fix ids (Not now), face (the M face html), busy, passed: ids already passed to the session }.
|
|
149
|
+
*/
|
|
150
|
+
export function reviewHtml(rv, o = {}, a = 'data-r') {
|
|
151
|
+
if (!rv) return '';
|
|
152
|
+
const hid = o.hidden || new Set(), sent = o.sent || new Set();
|
|
153
|
+
const L = (rv.fix || []).filter((f) => !hid.has(f.id));
|
|
154
|
+
const n = L.filter((f) => !sent.has(f.id)).length;
|
|
155
|
+
const line = n ? `I read it as your readers would. ${n === 1 ? 'One thing' : n + ' things'} to fix.` : (rv.fix || []).length ? 'Your changes are with the report\'s session.' : 'I read it as your readers would. Nothing to fix.';
|
|
156
|
+
const all = n > 1 ? `<button type="button" class="rf-ib pri vz-hv" ${a}="rv-all" aria-label="Do all ${n}" title="Do all ${n}"${o.busy ? ' disabled' : ''}>${SV(ICON.go)}</button>` : '';
|
|
157
|
+
const rows = L.map((f) => `<div class="rf-fx"><span class="rf-star" aria-hidden="true">✦</span><span class="rf-fxt"><b>${esc(f.title)}</b><span>${esc(f.why || '')}</span></span>`
|
|
158
|
+
+ (sent.has(f.id) ? '<span class="rf-tag">passed to the report\'s session</span>'
|
|
159
|
+
: `<button type="button" class="rf-ib vz-hv" ${a}="rv-no|${esc(f.id)}" aria-label="Not now" title="Not now">${SV(ICON.x)}</button><button type="button" class="rf-ib pri vz-hv" ${a}="rv-do|${esc(f.id)}" aria-label="Do it" title="Do it"${o.busy ? ' disabled' : ''}>${SV(ICON.go)}</button>`) + '</div>').join('');
|
|
160
|
+
const P = rv.passed || [];
|
|
161
|
+
const pass = P.length ? `<p class="rf-pass"><b>${P.length} other ${P.length === 1 ? 'check' : 'checks'} found nothing</b><span>${esc(P.join(' · '))}</span></p>` : '';
|
|
162
|
+
return `<section class="rf-rv" aria-label="Claude's review"><div class="rf-rvh">${o.face || ''}<b>${esc(line)}</b>${all}</div>${rows}${pass}</section>`;
|
|
163
|
+
}
|