create-pmos 0.428.0 → 0.430.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 -25
- 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-board-test.js +4 -4
- package/workspace/briefing-premium-insights-test.js +82 -61
- package/workspace/briefing-premium-metrics-test.js +5 -3
- package/workspace/briefing-premium-sources-test.js +5 -5
- package/workspace/briefing-premium-test.js +5 -4
- package/workspace/changelog.json +24 -0
- package/workspace/ev-everywhere-test.js +2 -2
- package/workspace/guide/adler.md +45 -0
- package/workspace/guide/briefing-premium.md +2 -0
- package/workspace/guide/home.md +4 -2
- package/workspace/guide/index.md +2 -0
- package/workspace/guide/metric-drafts.md +49 -0
- package/workspace/guide/programs.md +2 -0
- package/workspace/intel-report-ui-test.js +189 -0
- package/workspace/intelligence-gaps-ui-test.js +168 -0
- package/workspace/lib/board-metrics-premium.js +1 -1
- package/workspace/lib/headless.js +15 -2
- package/workspace/lib/initiative-writer.js +16 -2
- package/workspace/lib/insight-moves.js +135 -0
- package/workspace/lib/insights-premium.js +9 -4
- package/workspace/lib/insights-records.js +14 -5
- package/workspace/lib/intel-report.js +432 -0
- package/workspace/lib/metric-draft-runs.js +193 -0
- package/workspace/lib/metric-drafts.js +261 -0
- package/workspace/lib/metrics-cli.js +104 -0
- package/workspace/lib/page-opens.js +74 -0
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/report-setups.js +29 -13
- package/workspace/lib/route-modules.js +3 -0
- package/workspace/lib/routes-insight-moves.js +119 -0
- package/workspace/lib/routes-insights-premium.js +12 -3
- package/workspace/lib/routes-insights-records.js +13 -5
- package/workspace/lib/routes-metric-drafts.js +150 -0
- package/workspace/lib/routes-page-opens.js +26 -0
- package/workspace/lib/routes-phone-day.js +13 -2
- package/workspace/lib/routes-report-setups.js +97 -3
- package/workspace/lib/routes-viewer.js +5 -2
- package/workspace/lib/settings-store.js +6 -0
- package/workspace/metric-drafts-ui-test.js +209 -0
- package/workspace/milestone-suggest-test.js +4 -4
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-phone-card-test.js +8 -5
- package/workspace/premium-viewer-flicker-test.js +1 -1
- package/workspace/public/pm/bd-acts.js +3 -3
- package/workspace/public/pm/bd-pin-card.css +4 -4
- package/workspace/public/pm/bd-prog-panel.js +12 -7
- package/workspace/public/pm/bd-prog.js +2 -2
- package/workspace/public/pm/cozy-adler.css +82 -0
- package/workspace/public/pm/cozy-adler.js +270 -0
- package/workspace/public/pm/cozy-aud.css +1 -1
- package/workspace/public/pm/cozy-board.css +256 -256
- package/workspace/public/pm/cozy-ev.css +48 -45
- package/workspace/public/pm/cozy-evmodel.js +1 -1
- package/workspace/public/pm/cozy-home-rows.css +23 -23
- package/workspace/public/pm/cozy-home.css +211 -207
- package/workspace/public/pm/cozy-insights.css +221 -108
- package/workspace/public/pm/cozy-live-pill.css +5 -5
- package/workspace/public/pm/cozy-mtg-present.css +23 -23
- package/workspace/public/pm/cozy-nav.js +3 -1
- package/workspace/public/pm/cozy-news.js +2 -2
- package/workspace/public/pm/cozy-panel.css +29 -29
- package/workspace/public/pm/cozy-pick.css +5 -5
- package/workspace/public/pm/cozy-rec-now.css +20 -20
- package/workspace/public/pm/cozy-rec-present.css +11 -11
- package/workspace/public/pm/cozy-rec-tab.css +13 -13
- package/workspace/public/pm/cozy-search.js +4 -2
- package/workspace/public/pm/cozy-settings.js +16 -3
- package/workspace/public/pm/cozy-steps.css +9 -9
- package/workspace/public/pm/cozy-today.css +122 -71
- package/workspace/public/pm/cozy-viewer.css +7 -7
- package/workspace/public/pm/cozy-viewer.js +1 -1
- package/workspace/public/pm/cozy-vw-mtg.css +81 -81
- package/workspace/public/pm/cozy-vw-rp.css +53 -53
- package/workspace/public/pm/cozy-vw-shell.css +23 -23
- package/workspace/public/pm/cozy-vw.css +117 -117
- package/workspace/public/pm/cozy-xv.css +11 -11
- package/workspace/public/pm/cozy.css +34 -15
- package/workspace/public/pm/hi-pop.css +19 -19
- package/workspace/public/pm/home-app.js +33 -9
- package/workspace/public/pm/home-chat.js +10 -2
- package/workspace/public/pm/home-day.js +155 -27
- package/workspace/public/pm/home-ini.css +32 -32
- package/workspace/public/pm/home-line.css +7 -7
- package/workspace/public/pm/home-list.js +12 -1
- package/workspace/public/pm/home-phone-card.js +18 -15
- package/workspace/public/pm/home-today.js +5 -3
- package/workspace/public/pm/ini-view-model.js +1 -1
- package/workspace/public/pm/ini-view.css +108 -102
- package/workspace/public/pm/ini-view.js +22 -3
- package/workspace/public/pm/loose-props.css +13 -13
- package/workspace/public/pm/metric-drafts.css +89 -0
- package/workspace/public/pm/metric-drafts.js +204 -0
- package/workspace/public/pm/ms-suggest.css +8 -8
- package/workspace/public/pm/ms-suggest.js +2 -1
- package/workspace/public/pm/ov-view.css +12 -12
- package/workspace/public/pm/premium-board.js +2 -2
- package/workspace/public/pm/premium-chart-tab.js +6 -6
- package/workspace/public/pm/premium-insights.js +364 -107
- package/workspace/public/pm/premium-report-intel.css +56 -0
- package/workspace/public/pm/premium-report-intel.js +232 -0
- package/workspace/public/pm/premium-shell.js +2 -2
- package/workspace/public/pm/premium-vw-cal.js +1 -1
- package/workspace/public/pm/premium-vw-file.js +2 -2
- package/workspace/public/pm/premium-welcome.js +3 -2
- package/workspace/public/pm/premium.css +130 -128
- package/workspace/public/pm/prog-order.css +6 -6
- package/workspace/public/pm/program-charter.css +23 -23
- package/workspace/public/pm/program-model.js +7 -0
- package/workspace/public/pm/rp-parts.js +2 -2
- package/workspace/public/pm/sort-order.css +1 -1
- package/workspace/public/pm/split-merge.css +15 -15
- package/workspace/public/pm/split-merge.js +2 -1
- package/workspace/public/pm/task-card.css +21 -21
- package/workspace/public/pm/tk-tasks.css +37 -37
- package/workspace/public/pm/tk-view.css +6 -6
- package/workspace/public/pm/wf-page.css +28 -28
- package/workspace/public/premium-intelligence.html +82 -0
- package/workspace/server.js +38 -3
- package/workspace/skills/metric-draft.skill +47 -0
- package/workspace/test-lists/intel-report-ui.json +5 -0
- package/workspace/test-lists/intel-report.json +9 -0
- package/workspace/test-lists/intelligence-gaps-ui.json +5 -0
- package/workspace/test-lists/intelligence-gaps.json +5 -0
- package/workspace/test-lists/metric-drafts-ui.json +5 -0
- package/workspace/test-lists/metric-drafts.json +9 -0
- package/workspace/test-run.js +3 -0
- package/workspace/public/premium-insights.html +0 -81
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* routes-page-opens.js — POST /api/page-opens { ws, page, view } → { ok, wrote } (feedback batch 16 item 1). Intelligence posts it once per page
|
|
3
|
+
* load, with the view on screen; lib/page-opens.js keeps one line per page, view and day in the runtime folder (local only, never the repository)
|
|
4
|
+
* and lib/intel-report.js proposalsOf reads it for "You open this every week". A call from an agent session is not an open by the PM: 403.
|
|
5
|
+
* The page's own Origin and launch nonce are checked as for any page write (pm-guard requirePagePress). */
|
|
6
|
+
const guard = require('./pm-guard.js');
|
|
7
|
+
const PO = require('./page-opens.js');
|
|
8
|
+
|
|
9
|
+
async function handle(req, res, url, ctx) {
|
|
10
|
+
const send = (status, body) => { ctx.json(res, body, status); return true; };
|
|
11
|
+
if (url.pathname !== '/api/page-opens') return false;
|
|
12
|
+
if (req.method !== 'POST') return send(405, { ok: false, error: 'POST only' });
|
|
13
|
+
if (req.headers && req.headers['x-pmos-session']) return send(403, { ok: false, error: 'An agent session does not open pages. Only the PM\'s own opens are recorded.' });
|
|
14
|
+
const read = await ctx.readJson(req);
|
|
15
|
+
if (!read.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
16
|
+
const body = read.body || {};
|
|
17
|
+
const g = guard.requirePagePress(req, body);
|
|
18
|
+
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
19
|
+
let w = null;
|
|
20
|
+
try { w = ctx.getWs(typeof body.ws === 'string' ? body.ws : null); } catch { w = null; }
|
|
21
|
+
if (!w || w.id !== body.ws) return send(404, { ok: false, error: 'no such workspace' });
|
|
22
|
+
const r = PO.record(ctx.runtimeDir || null, { ws: w.id, page: body.page, view: body.view }, new Date().toISOString());
|
|
23
|
+
return r.ok ? send(200, { ok: true, wrote: r.wrote }) : send(r.error.startsWith('This workspace') ? 409 : 400, { ok: false, error: r.error });
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = { prefixes: ['/api/page-opens'], handle };
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
* text, sub }: the confirmed decisions first, then the items done, then the drafts.
|
|
15
15
|
* tomorrow end of the day: the next working day (Monday to Friday) and its meetings, in the shape of GET /api/brief-page today[] rows
|
|
16
16
|
* (routes-brief-page.js todayAgenda), so the companion opens their briefs the same way.
|
|
17
|
+
* run today's morning prep run (Prepare my day), or null when there is none: { started_at, working, failed: [{ id, title, error }] }.
|
|
18
|
+
* working counts the tasks still waiting, working or sending; failed are the tasks the agent could not finish (at most 3).
|
|
19
|
+
* Your day (batch 15 item 3) says "My part's done" only when working is 0, and names each failed task as Claude's own miss.
|
|
17
20
|
* A private note is never read. A file that is missing or unreadable counts as empty. */
|
|
18
21
|
const fs = require('fs');
|
|
19
22
|
const path = require('path');
|
|
@@ -46,6 +49,14 @@ function finishedOf(run) {
|
|
|
46
49
|
.sort((a, b) => String(b.at || '').localeCompare(String(a.at || '')));
|
|
47
50
|
}
|
|
48
51
|
|
|
52
|
+
/** Today's run as Your day reads it: what is still under way and what failed. Null when there is no run. */
|
|
53
|
+
function runOf(run) {
|
|
54
|
+
if (!run || !Array.isArray(run.tasks)) return null;
|
|
55
|
+
const T = run.tasks.filter(Boolean);
|
|
56
|
+
return { started_at: run.started_at || null, working: T.filter((t) => ['waiting', 'working', 'sending'].includes(t.status)).length,
|
|
57
|
+
failed: T.filter((t) => t.status === 'failed').slice(0, 3).map((t) => ({ id: t.id, title: clip(t.title, 200), error: clip(t.error, 200) })) };
|
|
58
|
+
}
|
|
59
|
+
|
|
49
60
|
/** deps: { events, items, run, notes: [note with final_notes], adapter, points: (noteId) → { [pointId]: 'confirmed' | 'wrong' } }
|
|
50
61
|
* notes are today's non-private notes, read in full. A decision's point id is the Replay's (lib/meeting-replay.js): d1, d2, … in caughtOf order. */
|
|
51
62
|
function build(query, deps = {}) {
|
|
@@ -71,7 +82,7 @@ function build(query, deps = {}) {
|
|
|
71
82
|
...finished.map((t) => ({ kind: 'agent', text: clip(t.title, 200), sub: t.status === 'review' ? 'Drafted by the agent; it waits for you' : 'Finished by the agent' }))].slice(0, 5);
|
|
72
83
|
const tm = nextWorkday(now);
|
|
73
84
|
return { status: 200, body: {
|
|
74
|
-
ok: true, date: today, finished,
|
|
85
|
+
ok: true, date: today, finished, run: runOf(deps.run),
|
|
75
86
|
recap: { meetings: agenda.filter((m) => Date.parse(m.end || m.start) <= now.getTime()).length, decided: decisions.length, to_confirm: toConfirm, done: done.length, finished: finished.length, moved },
|
|
76
87
|
tomorrow: { date: localDate(tm), label: WD[tm.getDay()] + ' ' + tm.getDate() + ' ' + MO[tm.getMonth()], meetings: todayAgenda(events, items, tm, deps.adapter || {}) },
|
|
77
88
|
} };
|
|
@@ -93,7 +104,7 @@ function readRun(dir, date) {
|
|
|
93
104
|
|
|
94
105
|
module.exports = {
|
|
95
106
|
prefixes: ['/api/phone-day'],
|
|
96
|
-
build, finishedOf, nextWorkday,
|
|
107
|
+
build, finishedOf, nextWorkday, runOf,
|
|
97
108
|
handle: async (req, res, url, ctx) => {
|
|
98
109
|
if (url.pathname !== '/api/phone-day') return false;
|
|
99
110
|
if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
|
|
@@ -19,6 +19,12 @@
|
|
|
19
19
|
* POST /api/report-setups/remove { ws, id } → { ok } delete a TEMPLATE: its schedule stops; its drafts and issued reports stay (L2)
|
|
20
20
|
* POST /api/report-setups/from-dashboard { ws, key, name, output, schedule, audience } → { ok, setup }
|
|
21
21
|
* POST /api/report-setups/finder { ws, cadence?, sources? } → { ok, finder }
|
|
22
|
+
* GET /api/report-setups/storyline?ws&board&scope&story? → { ok, storyline, defaults, checks, proposals } a report from Intelligence (batch 15 item 4,
|
|
23
|
+
* lib/intel-report.js): the draft the side panel opens on, who reads it / how often / the format from history,
|
|
24
|
+
* the five checks on the draft as `story` (the PM's edits, JSON) leaves it, and the ✦ strip's proposals
|
|
25
|
+
* POST /api/report-setups/setup { ws, source: 'intelligence', scope, board?, name, audience, output, schedule, storyline } → as above: sets up a
|
|
26
|
+
* report from Intelligence and drafts issue 1 from the live model (source intelligence:<scope>)
|
|
27
|
+
* POST /api/report-setups/strip-dismiss { ws, id } → { ok } Not now on a report the ✦ strip proposed
|
|
22
28
|
* GET /api/report-documents?ws → { docs: [{ path, id, setup, name, slot, state: draft|issued, source, output, made_by: schedule|you|agent, v, copy }] }
|
|
23
29
|
* POST /api/report-documents/discard { ws, path } → { ok, doc } delete an UNISSUED draft; an issued report is 409 and untouched (L3)
|
|
24
30
|
* POST /api/report-documents/archive { ws, path, archived } → { ok, doc, archived } hide (or bring back) an ISSUED report; a draft is 409 (L4)
|
|
@@ -54,7 +60,8 @@ const headless = require('./headless.js');
|
|
|
54
60
|
|
|
55
61
|
const text = (v) => (typeof v === 'string' ? v : '');
|
|
56
62
|
const bad = (status, error) => ({ status, body: { ok: false, error } });
|
|
57
|
-
const POSTS = ['ask', 'change', 'cancel', 'setup', 'draft', 'dismiss', 'pause', 'resume', 'from-dashboard', 'finder', 'edit', 'remove', 'documents/discard', 'documents/archive'];
|
|
63
|
+
const POSTS = ['ask', 'change', 'cancel', 'setup', 'draft', 'dismiss', 'pause', 'resume', 'from-dashboard', 'finder', 'edit', 'remove', 'documents/discard', 'documents/archive', 'strip-dismiss'];
|
|
64
|
+
const IR = require('./intel-report.js');
|
|
58
65
|
const MADE_BY = ['schedule', 'you', 'agent'];
|
|
59
66
|
|
|
60
67
|
const runs = new Map(); // ask id → session id, for the report-setup runs this server started
|
|
@@ -144,6 +151,7 @@ function setupOut(s, now, docsOf, idx, root, draft) {
|
|
|
144
151
|
if (s.status === 'active') { try { const n = RS.nextDraftAt(s.schedule, s.last_run, now); next = n ? n.toISOString() : null; } catch { next = null; } }
|
|
145
152
|
return {
|
|
146
153
|
id: s.id, name: s.name, purpose: s.purpose, audience: s.audience, source: s.source, output: s.output, schedule: s.schedule, label: RS.scheduleLabel(s.schedule),
|
|
154
|
+
...(IR.isIntelligence(s.source) ? { scope: IR.scopeOf(s.source), storyline: s.storyline || {} } : {}),
|
|
147
155
|
next_draft: next, last_issued: issued, status: s.status, cycles: mine.length,
|
|
148
156
|
copy: copyOf(latest ? linkFor(idx, latest.path, s.output) : null, docSync.copyKindOf(s.output)),
|
|
149
157
|
structure: structureOf(root, s.id),
|
|
@@ -231,7 +239,7 @@ async function tick(ctx, now = new Date()) {
|
|
|
231
239
|
let st;
|
|
232
240
|
try { st = RS.stateOf(w.root); } catch { continue; }
|
|
233
241
|
for (const s of st.setups.values()) {
|
|
234
|
-
if (s.status !== 'active' || !String(s.source).startsWith('dashboard:')) continue;
|
|
242
|
+
if (s.status !== 'active' || !(String(s.source).startsWith('dashboard:') || IR.isIntelligence(s.source))) continue;
|
|
235
243
|
const sched = RS.scheduleOf(s);
|
|
236
244
|
if (!logic.isDue(sched, now)) continue;
|
|
237
245
|
const slotAt = logic.lastSlot(sched, now);
|
|
@@ -239,6 +247,11 @@ async function tick(ctx, now = new Date()) {
|
|
|
239
247
|
const slot = RS.localDay(slotAt);
|
|
240
248
|
if (s.drafted.some((d) => d.slot === slot)) continue;
|
|
241
249
|
let out;
|
|
250
|
+
if (IR.isIntelligence(s.source)) {
|
|
251
|
+
try { out = await draftIntelligence({ ...ctx, getWs: (id) => (id === w.id || id == null ? w : ctx.getWs(id)) }, w, s, slot, { now }); } catch (e) { out = { ok: false, error: String((e && e.message) || e) }; }
|
|
252
|
+
done.push({ id: s.id, slot, ...out });
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
242
255
|
try {
|
|
243
256
|
const c3 = require('./routes-c3-reports.js');
|
|
244
257
|
const deps = await c3.depsFor({ ...ctx, getWs: (id) => (id === w.id || id == null ? w : ctx.getWs(id)) }, w.id);
|
|
@@ -277,6 +290,11 @@ function exportAnswer(ctx, res, w, url) {
|
|
|
277
290
|
return { status: 200, file: out };
|
|
278
291
|
}
|
|
279
292
|
|
|
293
|
+
/** The view the PM opens every week on Intelligence (feedback batch 16 item 1; lib/page-opens.js, local only), or null. */
|
|
294
|
+
function weeklyOpen(ctx, ws) {
|
|
295
|
+
try { const PO = require('./page-opens.js'); return PO.weeklyOf(PO.readLines(ctx.runtimeDir || null), { ws, page: 'intelligence', now: Date.now() }); } catch { return null; }
|
|
296
|
+
}
|
|
297
|
+
|
|
280
298
|
async function handle(req, res, url, ctx) {
|
|
281
299
|
const p = url.pathname;
|
|
282
300
|
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
@@ -285,6 +303,25 @@ async function handle(req, res, url, ctx) {
|
|
|
285
303
|
const docPost = p === '/api/report-documents/discard' || p === '/api/report-documents/archive';
|
|
286
304
|
const sub = docPost ? p.replace(/^\/api\/report-/, '') : isDocs ? 'documents' : isExport ? 'export' : p.replace(/^\/api\/report-setups\/?/, '');
|
|
287
305
|
|
|
306
|
+
if (sub === 'storyline') {
|
|
307
|
+
if (req.method !== 'GET') return send(bad(405, 'GET only'));
|
|
308
|
+
const w = wsOf(ctx, url.searchParams.get('ws'));
|
|
309
|
+
if (!w) return send(bad(404, 'no such workspace'));
|
|
310
|
+
const scope = text(url.searchParams.get('scope')) || 'view';
|
|
311
|
+
if (!IR.SCOPE_RE.test(scope)) return send(bad(400, 'scope is view, dashboard:<id>, goal:<id> or outcome:<id>'));
|
|
312
|
+
const m = await intelModel(req, ctx, w.id, url.searchParams.get('board'));
|
|
313
|
+
if (!m) return send(bad(500, 'Intelligence could not be read, so there is no draft.'));
|
|
314
|
+
const st = RS.fold(RS.readLines(RS.ledgerFile(w.root)));
|
|
315
|
+
const findings = RS.openFindings(st);
|
|
316
|
+
// ?story= the PM's edits so far ({ answer, ask, items }): the draft is redrawn with them and the five checks run on that preview
|
|
317
|
+
let story = {};
|
|
318
|
+
if (url.searchParams.get('story')) { let raw = null; try { raw = JSON.parse(url.searchParams.get('story')); } catch { raw = null; } const c = IR.checkStoryline(raw); if (!c.ok) return send(bad(400, c.error)); story = c.storyline; }
|
|
319
|
+
const S = IR.storylineOf(m, { scope, ask: story.ask, items: story.items });
|
|
320
|
+
if (story.answer) S.answer = story.answer;
|
|
321
|
+
const defaults = IR.defaultsOf(findings, scope, S.name);
|
|
322
|
+
const preview = IR.documentOf(m, { id: 'preview', name: S.name, audience: defaults.audience, output: defaults.output, source: IR.sourceOf(scope), storyline: story }, { slot: m.today, issue: 1 });
|
|
323
|
+
return send({ status: 200, body: { ok: true, storyline: S, defaults, checks: IR.storyChecks(preview), proposals: IR.proposalsOf(m, { findings, dismissed: [...st.stripDismissed], weekly: weeklyOpen(ctx, w.id), covered: [...st.setups.values()].map((x) => IR.scopeOf(x.source)).filter(Boolean) }), as_of: m.today } });
|
|
324
|
+
}
|
|
288
325
|
if (!docPost && (isDocs || isExport || (sub === '' && req.method === 'GET'))) {
|
|
289
326
|
if (req.method !== 'GET') return send(bad(405, 'GET only'));
|
|
290
327
|
if ((isDocs && p !== '/api/report-documents') || (isExport && p !== '/api/report-export')) return send(bad(404, 'no such report route'));
|
|
@@ -346,6 +383,30 @@ async function handle(req, res, url, ctx) {
|
|
|
346
383
|
if (sid && typeof ctx.stopSession === 'function') { try { ctx.stopSession(sid); } catch { /* the run ends by itself */ } }
|
|
347
384
|
return send({ status: 200, body: { ok: true } });
|
|
348
385
|
}
|
|
386
|
+
if (sub === 'setup' && body.source === 'intelligence') {
|
|
387
|
+
const scope = text(body.scope) || 'view';
|
|
388
|
+
if (!IR.SCOPE_RE.test(scope)) return send(bad(400, 'scope is view, dashboard:<id>, goal:<id> or outcome:<id>'));
|
|
389
|
+
const m = await intelModel(req, ctx, w.id, text(body.board) || null);
|
|
390
|
+
if (!m) return send(bad(500, 'Intelligence could not be read, so nothing was set up.'));
|
|
391
|
+
const name = text(body.name).trim() || IR.scopeName(m, scope);
|
|
392
|
+
const audience = text(body.audience).trim();
|
|
393
|
+
if (!audience) return send(bad(400, 'say who reads it'));
|
|
394
|
+
const finding = text(body.finding) ? RS.lookupFinding(RS.fold(RS.readLines(file)), text(body.finding)) : null;
|
|
395
|
+
const proposal = { name, purpose: `${name} from Intelligence for ${audience}: the answer first, the scorecard, and what needs a decision.`, audience, source: IR.sourceOf(scope),
|
|
396
|
+
output: text(body.output) || 'pdf', schedule: body.schedule, sources: [`Intelligence · ${IR.scopeName(m, scope)}`], sections: RS.FRAME.slice(), learned_from: 'Set up from Intelligence.', fixes: [],
|
|
397
|
+
storyline: body.storyline || {}, ...(finding && finding.ok ? { from: { finding: finding.finding.id } } : {}) };
|
|
398
|
+
const r = RS.setUp(root, proposal, opts);
|
|
399
|
+
if (!r.ok) return fail(r);
|
|
400
|
+
let drafted = { error: 'no first draft day' };
|
|
401
|
+
if (r.first_draft) { try { drafted = await draftIntelligence(ctx, w, r.setup, r.first_draft.slot, { model: m, now: new Date() }); } catch (e) { drafted = { error: String((e && e.message) || e) }; } }
|
|
402
|
+
if (drafted.path && ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg();
|
|
403
|
+
return send({ status: 200, body: { ok: true, setup: setupOut(r.setup, new Date(), documentsOf(ctx, w), copyIndex(root), root), first_draft: r.first_draft, drafted } });
|
|
404
|
+
}
|
|
405
|
+
if (sub === 'strip-dismiss') {
|
|
406
|
+
const r = RS.stripDismiss(file, { id: text(body.id), by: g.actor });
|
|
407
|
+
if (!r.ok) return fail(r);
|
|
408
|
+
return send({ status: 200, body: { ok: true } });
|
|
409
|
+
}
|
|
349
410
|
if (sub === 'setup') {
|
|
350
411
|
const st = RS.fold(RS.readLines(file));
|
|
351
412
|
let from = null; let base = null;
|
|
@@ -371,6 +432,14 @@ async function handle(req, res, url, ctx) {
|
|
|
371
432
|
// Draft it now: the next cycle of a set-up report, written at the slot of its next scheduled draft. A page write, like Draft now on the report.
|
|
372
433
|
const s = RS.fold(RS.readLines(file)).setups.get(text(body.id));
|
|
373
434
|
if (!s || s.status === 'removed') return send(bad(404, 'no such report'));
|
|
435
|
+
if (IR.isIntelligence(s.source)) {
|
|
436
|
+
let next = null; try { next = RS.nextDraftAt(s.schedule, s.last_run, new Date()); } catch { next = null; }
|
|
437
|
+
if (!next) return send(bad(400, 'this report has no next draft day'));
|
|
438
|
+
const d = await draftIntelligence(ctx, w, s, RS.localDay(next), { now: new Date() });
|
|
439
|
+
if (!d.ok && !d.existing) return send(bad(d.status || 500, 'the draft was not written: ' + d.error));
|
|
440
|
+
if (ctx.invalidateNeedsAgg) ctx.invalidateNeedsAgg();
|
|
441
|
+
return send({ status: 200, body: { ok: true, drafted: { slot: d.slot, path: d.path, existing: !!d.existing }, id: s.id + '/' + d.slot } });
|
|
442
|
+
}
|
|
374
443
|
if (s.source !== 'work') return send(bad(400, 'a dashboard report is drafted from its dashboard on its day'));
|
|
375
444
|
let next = null; try { next = RS.nextDraftAt(s.schedule, s.last_run, new Date()); } catch { next = null; }
|
|
376
445
|
const day = next ? `${next.getFullYear()}-${String(next.getMonth() + 1).padStart(2, '0')}-${String(next.getDate()).padStart(2, '0')}` : null; // the local day, as setUp names a slot
|
|
@@ -435,6 +504,31 @@ async function handle(req, res, url, ctx) {
|
|
|
435
504
|
return send(bad(404, 'no such report route'));
|
|
436
505
|
}
|
|
437
506
|
|
|
507
|
+
/** The Intelligence model, through its page's own read (as lib/routes-insights-records.js does), so a report says what the page shows. null when it cannot be read. */
|
|
508
|
+
async function intelModel(req, ctx, ws, board) {
|
|
509
|
+
let out = null;
|
|
510
|
+
const c = Object.assign({}, ctx, { json: (res, obj) => { out = obj; } });
|
|
511
|
+
const u = new URL('http://local/api/insights-premium?' + new URLSearchParams(Object.entries({ ws, board }).filter(([, v]) => v)).toString());
|
|
512
|
+
try { await require('./routes-insights-premium.js').handle({ method: 'GET', headers: (req && req.headers) || {} }, {}, u, c); } catch { return null; }
|
|
513
|
+
return out && out.ok ? out.model : null;
|
|
514
|
+
}
|
|
515
|
+
/** Draft one issue of a report from Intelligence at `slot` (lib/intel-report.js documentOf). The issue number counts the documents before it; the issue
|
|
516
|
+
* before it (the latest issued one) gives Actions from issue N and Since issue N. A document already at the slot is the answer and is not overwritten.
|
|
517
|
+
* → { ok, slot, path } | { ok: false, existing?, error } */
|
|
518
|
+
async function draftIntelligence(ctx, w, s, slot, { model, now = new Date() } = {}) {
|
|
519
|
+
const rel = RD.draftPath(path.resolve(w.root), s.id, slot);
|
|
520
|
+
try { if (fs.statSync(path.join(path.resolve(w.root), rel)).isFile()) return { ok: false, existing: true, slot, path: rel, error: 'drafted already' }; } catch { /* not there yet */ }
|
|
521
|
+
const m = model || await intelModel(null, ctx, w.id, null);
|
|
522
|
+
if (!m) return { ok: false, error: 'Intelligence could not be read' };
|
|
523
|
+
const mine = (RN.reportsOf(w.root).reports || []).filter((x) => x.cadence === s.id && x.slot < slot).sort((a, b) => (a.slot < b.slot ? -1 : 1));
|
|
524
|
+
const before = mine.filter((x) => x.issued).pop() || null;
|
|
525
|
+
let prior = null;
|
|
526
|
+
if (before) { try { prior = fs.readFileSync(path.join(path.resolve(w.root), before.path), 'utf8'); } catch { prior = null; } }
|
|
527
|
+
const md = IR.documentOf(m, s, { slot, now, issue: mine.length + 1, prior });
|
|
528
|
+
const r = RS.writeDocument(w.root, s, slot, md, { now });
|
|
529
|
+
return r.ok ? { ok: true, slot, path: r.path } : { ok: false, status: r.status, error: r.error };
|
|
530
|
+
}
|
|
531
|
+
|
|
438
532
|
/** Draft a report's cycle now through the one writer (report-draft.js writeDraft). → { slot, path } | { error } */
|
|
439
533
|
function draftCycle(root, cadence, slot, actor) {
|
|
440
534
|
const d = RD.draftOf(root, { cadence, slot: slot || undefined });
|
|
@@ -450,4 +544,4 @@ function firstDraft(root, r, actor) {
|
|
|
450
544
|
return draftCycle(root, r.setup.id, r.first_draft && r.first_draft.slot, actor);
|
|
451
545
|
}
|
|
452
546
|
|
|
453
|
-
module.exports = { prefixes: ['/api/report-setups', '/api/report-documents', '/api/report-export'], handle, tick, ensureMigrated, documentsOf, listAnswer, copyOf };
|
|
547
|
+
module.exports = { prefixes: ['/api/report-setups', '/api/report-documents', '/api/report-export'], handle, tick, ensureMigrated, documentsOf, listAnswer, copyOf, draftIntelligence, intelModel };
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* POST /api/viewer-meeting/work-item { note, step: { text, owner?, due? } } → { ok, ticket, created }
|
|
12
12
|
* A next step becomes a ticket Drafted in PMOS on the note's initiative (lib/jira-tickets.js's draft file). It is not approved and not pushed:
|
|
13
13
|
* only the Commit gate pushes a ticket to Jira.
|
|
14
|
-
* GET /api/viewer-report/checks?ws=&path=&slot= → { ok, checks: [{ id, ok, text }] } the three checks before Issue (lib/viewer-report.js)
|
|
14
|
+
* GET /api/viewer-report/checks?ws=&path=&slot= → { ok, checks: [{ id, ok, text }] } the three checks before Issue (lib/viewer-report.js); five for a
|
|
15
|
+
* report made from Intelligence (lib/intel-report.js storyChecks)
|
|
15
16
|
* Every POST is a page press (lib/pm-guard.js requirePagePress). Handlers are pure over (q | body, ctx) so a test needs no server. */
|
|
16
17
|
const fs = require('fs');
|
|
17
18
|
const path = require('path');
|
|
@@ -84,7 +85,9 @@ function checks(q, ctx) {
|
|
|
84
85
|
let text = '';
|
|
85
86
|
try { text = fs.readFileSync(full, 'utf8'); } catch { return fail(404, 'the report file could not be read'); }
|
|
86
87
|
const slot = str(q.slot, 10) || ((/(\d{4}-\d{2}-\d{2})\.md$/.exec(rel) || [])[1] || '');
|
|
87
|
-
|
|
88
|
+
// A report made from Intelligence (batch 15 item 4) is checked as a story: the five checks before it goes out (lib/intel-report.js storyChecks).
|
|
89
|
+
const IR = require('./intel-report.js'), src = (/^---\r?\n[\s\S]*?^source:\s*(\S+)/m.exec(text) || [])[1];
|
|
90
|
+
return okBody({ checks: IR.isIntelligence(src) ? IR.storyChecks(text) : VR.issueChecks(text, { slot }) });
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
const respond = (ctx, res, r) => { ctx.json(res, r.body, r.status); return true; };
|
|
@@ -70,6 +70,12 @@ const DEFS = Object.freeze({
|
|
|
70
70
|
'upd.apply': one('updates', 'computer', ['ask', 'idle'], 'ask'),
|
|
71
71
|
'upd.kits': one('updates', 'computer', ['all', 'each'], 'all'),
|
|
72
72
|
'upd.channel': one('updates', 'computer', ['stable', 'early'], 'stable'),
|
|
73
|
+
// Settings > Adler (feedback batch 16 item 2, canvas AdM5): how much of Claude's face shows, whether he moves, whether he celebrates, and
|
|
74
|
+
// whether PMOS opens on him asleep after 22:00. pm/cozy-adler.js reads them.
|
|
75
|
+
'adler.amount': one('adler', 'computer', ['full', 'face', 'off'], 'full'),
|
|
76
|
+
'adler.motion': one('adler', 'computer', ['system', 'still'], 'system'),
|
|
77
|
+
'adler.celebrate': one('adler', 'computer', ['real', 'never'], 'real'),
|
|
78
|
+
'adler.quiet': one('adler', 'computer', ['22', 'never'], '22'),
|
|
73
79
|
});
|
|
74
80
|
|
|
75
81
|
/* The environment variables that win over a setting, here or in a setting's own store. `key` names the setting the page
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
/* metric-drafts-ui-test.js — the metrics Claude drafts, as the program panel and the initiative view show them (feedback batch 15 item 1;
|
|
4
|
+
* canvas Iq9Program, Iq9Initiative). Serves the real Board page from the real server; Project Ascent comes from fixtures/program-ascent.js, and
|
|
5
|
+
* GET /api/metric-drafts and its POSTs are stubbed here in the contract's shape (keep-all marks every open row kept, undo puts one back).
|
|
6
|
+
* P the program's proposed goal leads the panel: the goal line, checkpoint chips, Built from with the drafted ticket as a pill, one line of
|
|
7
|
+
* why; Discuss in Home, Edit and ✓ are icon-only with a label · K ✓ keeps all; the Goal row of chips with a dot (ok, off) and Undo ·
|
|
8
|
+
* U Undo makes it a proposal again · Z nothing drafted, nothing shown · I the initiative at Discover: the proposed success measure under
|
|
9
|
+
* the stage card, Proves it worked, Early signal and Guardrail as Now → Target; ✓ keeps all; the folded "Success measure · Set before the
|
|
10
|
+
* build · 3" with Undo · S the type scale only · H on a phone. PMOS_SHOTS=<dir> also saves the screenshots. */
|
|
11
|
+
const path = require('path');
|
|
12
|
+
const fs = require('fs');
|
|
13
|
+
const { spawn } = require('child_process');
|
|
14
|
+
const { findBrowser } = require('./lib/find-browser');
|
|
15
|
+
const T = require('./test-run').configure({ name: 'metric-drafts-ui' });
|
|
16
|
+
const BP = require('./lib/board-premium.js');
|
|
17
|
+
const F = require('./fixtures/board-premium-facts.js');
|
|
18
|
+
const A = require('./fixtures/program-ascent.js');
|
|
19
|
+
|
|
20
|
+
const BASE = T.BASE;
|
|
21
|
+
const SHOTS = process.env.PMOS_SHOTS || '';
|
|
22
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
23
|
+
const until = async (fn, ms = 10000, step = 100) => { const t0 = Date.now(); for (;;) { let v; try { v = await fn(); } catch { v = null; } if (v) return v; if (Date.now() - t0 > ms) return v; await sleep(step); } };
|
|
24
|
+
const results = [];
|
|
25
|
+
const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 700) : ''}`); };
|
|
26
|
+
let srv = null; let browser = null;
|
|
27
|
+
const finish = async (code) => {
|
|
28
|
+
if (browser) await browser.close().catch(() => {});
|
|
29
|
+
if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
|
|
30
|
+
T.killTmux();
|
|
31
|
+
const bad = results.filter((x) => !x.cond).length;
|
|
32
|
+
console.log(`\n${results.length - bad}/${results.length} metric-drafts-ui assertions passed`);
|
|
33
|
+
process.exit(code !== undefined ? code : (bad ? 1 : 0));
|
|
34
|
+
};
|
|
35
|
+
process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
|
|
36
|
+
|
|
37
|
+
/* the drafts, in the contract's row shape (metric-drafts-contract.md) */
|
|
38
|
+
const PROGRAM = () => ({
|
|
39
|
+
title: 'Project Ascent', src: 'from the charter and its 3 initiatives', sub: '',
|
|
40
|
+
rows: [
|
|
41
|
+
{ id: 'g', group: 'Program goal', name: 'Sign-ins on CIAM, all products', type: 'Percentage', now: 12, nowTxt: '12%', target: 100, targetTxt: '100%', by: '2028-06-30',
|
|
42
|
+
why: 'idpf is 80% of all sign-ins, so it carries the goal. I check it every morning once you keep it.', source: 'Amplitude', ticket: null,
|
|
43
|
+
checkpoints: [{ by: '2027-02-27', target: 40, label: 'Legacy IdP off' }, { by: '2027-03-20', target: 85, label: 'All microsites' }], state: 'open' },
|
|
44
|
+
{ id: 'r1', group: 'Rolls up from', name: 'idpf · sign-ins on CIAM', type: 'Percentage', now: 15, nowTxt: '15%', target: 100, targetTxt: '100%', by: '2027-02-27', why: '', source: 'Amplitude', ticket: null, state: 'open' },
|
|
45
|
+
{ id: 'r2', group: 'Rolls up from', name: 'Microsites · sign-ins on CIAM', type: 'Percentage', now: null, nowTxt: '', target: 100, targetTxt: '100%', by: '2027-03-20', why: 'No event counts it yet.', source: '', ticket: { key: 'MS-212', text: 'MS-212 drafted' }, state: 'open' },
|
|
46
|
+
{ id: 'gr', group: 'Guardrail', name: 'Sign-in success', type: 'Stay within', now: 99.6, nowTxt: '99.6%', target: 99, targetTxt: 'stays above 99%', by: null, why: '', source: 'Amplitude', ticket: null, state: 'open' },
|
|
47
|
+
],
|
|
48
|
+
});
|
|
49
|
+
const INITIATIVE = () => ({
|
|
50
|
+
title: 'Descope feature parity', src: 'from the PRD and the desktop launch', sub: 'Desktop fell 7 points after the same change. 10% of shoppers keep the old login, so the result is fair.',
|
|
51
|
+
rows: [
|
|
52
|
+
{ id: 'gd', group: 'Guardrail', name: 'Checkout conversion', type: 'Stay within', now: 3.1, nowTxt: '3.1%', target: 3.1, targetTxt: '≥ 3.1%', by: null, why: 'A faster login must not cost orders', source: 'Amplitude', ticket: null, state: 'open' },
|
|
53
|
+
{ id: 'pw', group: 'Proves it worked', name: 'Mobile checkout login drop-off', type: 'Percentage', now: 27, nowTxt: '27%', target: 19, targetTxt: '19%', by: '2027-01-15', why: 'Moves your key result “drop-off under 15%”', source: 'Amplitude', ticket: null, state: 'open' },
|
|
54
|
+
{ id: 'es', group: 'Early signal', name: 'Inline form completion', type: 'Percentage', now: null, nowTxt: '', target: 80, targetTxt: '80% week 1', by: null, why: '', source: '', ticket: { key: 'ESHOP-981', text: 'ESHOP-981 drafted' }, state: 'open' },
|
|
55
|
+
],
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
(async () => {
|
|
59
|
+
const exe = process.env.PMOS_CHROME || findBrowser();
|
|
60
|
+
if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
|
|
61
|
+
let chromium;
|
|
62
|
+
try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
|
|
63
|
+
srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT) }) });
|
|
64
|
+
await T.waitForServer(BASE);
|
|
65
|
+
browser = await chromium.launch({ executablePath: exe });
|
|
66
|
+
if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
|
|
67
|
+
const shot = async (p, name) => { if (SHOTS) { await sleep(450); await p.screenshot({ path: path.join(SHOTS, name + '.png') }); } };
|
|
68
|
+
|
|
69
|
+
const open = async ({ w = 1440, h = 900, drafts = { program: PROGRAM(), initiative: INITIATIVE() }, dark = false } = {}) => {
|
|
70
|
+
const c = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: dark ? 'dark' : 'light' });
|
|
71
|
+
const page = await c.newPage();
|
|
72
|
+
const errors = [], posts = [], gets = [];
|
|
73
|
+
page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
|
|
74
|
+
const json = (r, b) => r.fulfill({ contentType: 'application/json', body: JSON.stringify(b) }), wsOf = (r) => new URL(r.request().url()).searchParams.get('ws') || 'idpf';
|
|
75
|
+
await page.route('**/api/board-premium*', (r) => json(r, { ok: true, state: 'ready', model: BP.build(F.programFacts(wsOf(r))), as_of: Date.now() }));
|
|
76
|
+
await page.route('**/api/programs', (r) => json(r, { ok: true, programs: F.programs() }));
|
|
77
|
+
await page.route('**/api/boards/anchors*', (r) => json(r, { ok: true, anchors: A.ANCHORS[wsOf(r)] || [] }));
|
|
78
|
+
await page.route('**/api/insights-premium*', (r) => json(r, { ok: true, model: { goals: A.GOALS[wsOf(r)] || [] } }));
|
|
79
|
+
await page.route('**/api/boards/items*', (r) => json(r, { ok: true, items: A.ITEMS[wsOf(r)] || [] }));
|
|
80
|
+
await page.route('**/api/programs/*', (r) => json(r, { ok: true }));
|
|
81
|
+
await page.route('**/api/board-trail*', (r) => r.fulfill({ status: 500, contentType: 'application/json', body: '{"ok":false,"error":"not in this check"}' }));
|
|
82
|
+
// the metric drafts, per scope: the GET answers the rows as they stand; keep-all and undo change them as the server would
|
|
83
|
+
const S = { program: drafts.program, initiative: drafts.initiative };
|
|
84
|
+
await page.route('**/api/metric-drafts**', (r) => {
|
|
85
|
+
const rq = r.request(), u = new URL(rq.url());
|
|
86
|
+
if (rq.method() === 'GET') {
|
|
87
|
+
const scope = u.searchParams.get('scope'), id = u.searchParams.get('id'), d = S[scope];
|
|
88
|
+
gets.push({ scope, id, ws: u.searchParams.get('ws') });
|
|
89
|
+
const rows = d && d.rows ? d.rows : [];
|
|
90
|
+
return json(r, { ok: true, scope, id, title: (d && d.title) || '', when: '2026-10-27', run: { state: rows.length ? 'ready' : 'idle', step: rows.length ? 4 : 0, reads: [] }, rows, head: '', sub: (d && d.sub) || '', src: (d && d.src) || '' });
|
|
91
|
+
}
|
|
92
|
+
const body = JSON.parse(rq.postData() || '{}'), d = S[body.scope];
|
|
93
|
+
posts.push({ path: u.pathname, body });
|
|
94
|
+
if (u.pathname.endsWith('/keep-all')) { const n = d.rows.filter((x) => x.state === 'open').length; d.rows.forEach((x) => { if (x.state === 'open') { x.state = 'kept'; x.rid = 'rid-' + x.id; } }); return json(r, { ok: true, kept: n }); }
|
|
95
|
+
if (u.pathname.endsWith('/undo')) { const x = d.rows.find((y) => y.id === body.row); if (x) { x.state = 'open'; delete x.rid; } return json(r, { ok: true }); }
|
|
96
|
+
return json(r, { ok: true });
|
|
97
|
+
});
|
|
98
|
+
await page.goto(BASE + '/premium-board.html?ws=idpf&program=project-ascent');
|
|
99
|
+
await until(() => page.evaluate(() => { const v = document.querySelector('#czViewer'); return !!v && !v.hidden && !!v.querySelector('.pp-vw .czs-sum'); }));
|
|
100
|
+
return { page, ctx: c, errors, posts, gets, S };
|
|
101
|
+
};
|
|
102
|
+
const card = (p) => p.evaluate(() => {
|
|
103
|
+
const c = document.querySelector('#czViewer .pp-vw .md-card'); if (!c) return null;
|
|
104
|
+
return { first: c === c.parentElement.firstElementChild, hd: c.querySelector('.md-hd b').textContent, src: (c.querySelector('.md-src') || {}).textContent || '', gl: c.querySelector('.md-gl').textContent,
|
|
105
|
+
cps: [...c.querySelectorAll('.md-cp')].map((x) => x.textContent), built: [...c.querySelectorAll('.md-ru:not(.q)')].map((x) => [...x.children].map((y) => y.textContent).join(' | ')),
|
|
106
|
+
why: c.querySelector('.md-why').textContent,
|
|
107
|
+
presses: [...c.querySelectorAll('.md-ft .md-ib')].map((b) => ({ label: b.getAttribute('aria-label'), title: b.getAttribute('title'), text: b.textContent.trim(), svg: !!b.querySelector('svg[aria-hidden="true"]'), solid: b.classList.contains('solid'), href: b.getAttribute('href') || '' })) };
|
|
108
|
+
});
|
|
109
|
+
// every font size the parts draw: the type scale only (11, 12, 14, 16, 20, 28 px)
|
|
110
|
+
const sizes = (p, sel) => p.evaluate((s) => [...new Set([...document.querySelectorAll(s + ', ' + s + ' *')].filter((e) => e.childNodes.length && [...e.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim())).map((e) => getComputedStyle(e).fontSize))], sel);
|
|
111
|
+
const SCALE = new Set(['11px', '12px', '14px', '16px', '20px', '28px']);
|
|
112
|
+
|
|
113
|
+
/* ── P: the program's proposed goal ── */
|
|
114
|
+
const D = await open();
|
|
115
|
+
const p = D.page;
|
|
116
|
+
const c = await until(() => card(p));
|
|
117
|
+
ok('P the proposed goal leads the panel body, with where it came from', !!c && c.first && c.hd === 'Proposed goal' && c.src === 'from the charter and its 3 initiatives', JSON.stringify(c));
|
|
118
|
+
ok('P the goal line', !!c && c.gl === 'Sign-ins on CIAM, all products: 12% → 100% by Jun 2028', c && c.gl);
|
|
119
|
+
ok('P checkpoint chips at its milestones, and the guardrail', !!c && c.cps.join(' / ') === '40% at Legacy IdP off · Feb 27 / 85% at All microsites · Mar 20 / Guardrail: Sign-in success · stays above 99%', c && c.cps.join(' / '));
|
|
120
|
+
ok('P Built from: Now and Target, a drafted ticket as a pill', !!c && c.built.join(' / ') === 'idpf · sign-ins on CIAM | 15% | 100% by Feb 27 / Microsites · sign-ins on CIAM | — | Ticket MS-212 drafted'
|
|
121
|
+
&& await p.evaluate(() => !!document.querySelector('#czViewer .md-card .md-ru .md-pill')), c && c.built.join(' / '));
|
|
122
|
+
ok('P one line of why, in Claude\'s words', !!c && c.why === 'idpf is 80% of all sign-ins, so it carries the goal. I check it every morning once you keep it.', c && c.why);
|
|
123
|
+
ok('P Discuss in Home, Edit (in place, batch 16) and a solid ✓ Keep this goal: icon-only, each with a label and a title', !!c && c.presses.map((x) => x.label).join() === 'Discuss the proposed goal in Home,Edit the proposed goal,Keep this goal'
|
|
124
|
+
&& c.presses.every((x) => x.title && !x.text && x.svg) && c.presses[2].solid && /ask=program%3Aproject-ascent/.test(c.presses[0].href) && !c.presses[1].href, JSON.stringify(c && c.presses));
|
|
125
|
+
ok('P the read names the program and its product', D.gets.some((g) => g.scope === 'program' && g.id === 'project-ascent' && g.ws === 'idpf'), JSON.stringify(D.gets));
|
|
126
|
+
const ps = await sizes(p, '#czViewer .md-card');
|
|
127
|
+
ok('S the card uses the type scale only', ps.length && ps.every((x) => SCALE.has(x)), ps.join());
|
|
128
|
+
ok('P the rest of the panel is as before: the summary, the goals and the folding rows follow', await p.evaluate(() => { const b = document.querySelector('#czViewer .pp-vw'); return !!b.querySelector('.md-card + .czs-sum') && !!b.querySelector('.czs-sum ~ .pp-goal') && !!b.querySelector('[data-czs-fold="tree"]'); }));
|
|
129
|
+
await shot(p, 'Iq9Program-proposed-built');
|
|
130
|
+
|
|
131
|
+
/* ── K: ✓ keeps all ── */
|
|
132
|
+
await p.click('#czViewer .md-card [data-md="keep"]');
|
|
133
|
+
const kp = await until(() => D.posts.find((x) => x.path === '/api/metric-drafts/keep-all'));
|
|
134
|
+
ok('K ✓ keeps all in one press (POST /api/metric-drafts/keep-all)', !!kp && kp.body.scope === 'program' && kp.body.id === 'project-ascent' && kp.body.ws === 'idpf', JSON.stringify(kp));
|
|
135
|
+
const kept = await until(() => p.evaluate(() => { const g = document.querySelector('#czViewer .pp-vw .md-kept'); if (!g) return null;
|
|
136
|
+
return { first: g === g.parentElement.firstElementChild, per: g.querySelector('.pp-per').textContent, chips: [...g.querySelectorAll('.md-kr')].map((x) => (x.querySelector('.pp-gd.off') ? 'off:' : x.querySelector('.pp-gd') ? 'ok:' : '') + x.textContent),
|
|
137
|
+
undo: (g.querySelector('[data-md="undo"]') || {}).title || '', card: !!document.querySelector('#czViewer .md-card') }; }));
|
|
138
|
+
ok('K the Goal row of chips, each with a dot: ok with a reading, off while it waits on a ticket', !!kept && kept.first && kept.per === 'Goal' && !kept.card
|
|
139
|
+
&& kept.chips.join(' / ') === 'ok:Sign-ins on CIAM, all products12% of 100% · Jun 2028 / ok:idpf · sign-ins on CIAM15% of 100% · Feb 27 / off:Microsites · sign-ins on CIAMwaits on MS-212 / ok:Sign-in successstays above 99%', JSON.stringify(kept));
|
|
140
|
+
ok('K Undo is beside it, icon-only', !!kept && kept.undo === 'Undo');
|
|
141
|
+
ok('K the toast says what happens next, in first person', /I check the goal every morning/.test(await p.evaluate(() => (document.querySelector('#bdToast') || {}).textContent || '')));
|
|
142
|
+
await shot(p, 'Iq9Program-kept-built');
|
|
143
|
+
|
|
144
|
+
/* ── U: Undo ── */
|
|
145
|
+
await p.click('#czViewer .md-kept [data-md="undo"]');
|
|
146
|
+
await until(() => D.posts.filter((x) => x.path === '/api/metric-drafts/undo').length === 4, 5000);
|
|
147
|
+
ok('U Undo puts each kept row back (POST /api/metric-drafts/undo, one per row)', D.posts.filter((x) => x.path === '/api/metric-drafts/undo').map((x) => x.body.row).join() === 'g,r1,r2,gr');
|
|
148
|
+
ok('U the proposal shows again', !!(await until(() => card(p))));
|
|
149
|
+
|
|
150
|
+
/* ── I: the initiative at Discover ── */
|
|
151
|
+
await until(() => p.evaluate(() => { const b = document.querySelector('#czViewer [data-czs-fold="tree"]'); if (b && b.getAttribute('aria-expanded') !== 'true') b.click(); return !!document.querySelector('#czViewer button.pp-open[data-ini="descope-parity"]'); }));
|
|
152
|
+
await p.click('#czViewer button.pp-open[data-ini="descope-parity"]');
|
|
153
|
+
const ic = await until(() => p.evaluate(() => { const c = document.querySelector('#czViewer .iv .md-card'); if (!c) return null;
|
|
154
|
+
return { after: !!(c.previousElementSibling && c.previousElementSibling.classList.contains('iv-sc')), hd: c.querySelector('.md-hd b').textContent, src: c.querySelector('.md-src').textContent,
|
|
155
|
+
rows: [...c.querySelectorAll('.md-mr')].map((r) => [r.querySelector('.md-role').textContent, r.querySelector('.md-nm b').textContent, (r.querySelector('small') || {}).textContent || '', r.querySelector('.md-now').textContent, r.querySelector('.md-to').textContent].join(' | ')),
|
|
156
|
+
why: c.querySelector('.md-why').textContent, presses: [...c.querySelectorAll('.md-ft .md-ib')].map((b) => ({ label: b.getAttribute('aria-label'), title: b.getAttribute('title'), text: b.textContent.trim(), solid: b.classList.contains('solid'), href: b.getAttribute('href') || '' })) }; }));
|
|
157
|
+
ok('I the proposed success measure sits under the stage card, with where it came from', !!ic && ic.after && ic.hd === 'Proposed success measure' && ic.src === 'from the PRD and the desktop launch', JSON.stringify(ic));
|
|
158
|
+
ok('I three groups in order, each Now → Target', !!ic && ic.rows.join(' / ') === 'Proves it worked · 4 weeks after release | Mobile checkout login drop-off | Moves your key result “drop-off under 15%” | 27% | 19% / Early signal · shows in days | Inline form completion | Ticket ESHOP-981 drafted | — | 80% week 1 / Guardrail | Checkout conversion | A faster login must not cost orders | 3.1% | ≥ 3.1%', ic && ic.rows.join(' / '));
|
|
159
|
+
ok('I one line of why', !!ic && /^Desktop fell 7 points/.test(ic.why));
|
|
160
|
+
ok('I Edit (in place, batch 16) and a solid ✓ Keep this success measure: icon-only, each with a label and a title', !!ic && ic.presses.map((x) => x.label).join() === 'Edit the proposed success measure,Keep this success measure'
|
|
161
|
+
&& ic.presses.every((x) => x.title && !x.text) && ic.presses[1].solid && !ic.presses[0].href, JSON.stringify(ic && ic.presses));
|
|
162
|
+
const is = await sizes(p, '#czViewer .iv .md-card');
|
|
163
|
+
ok('S the initiative card uses the type scale only', is.length && is.every((x) => SCALE.has(x)), is.join());
|
|
164
|
+
await shot(p, 'Iq9Initiative-proposed-built');
|
|
165
|
+
await p.click('#czViewer .iv .md-card [data-md="keep"]');
|
|
166
|
+
const ki = await until(() => D.posts.find((x) => x.path === '/api/metric-drafts/keep-all' && x.body.scope === 'initiative'));
|
|
167
|
+
ok('I ✓ keeps all (POST /api/metric-drafts/keep-all, scope initiative)', !!ki && ki.body.id === 'descope-parity', JSON.stringify(ki));
|
|
168
|
+
const kf = await until(() => p.evaluate(() => { const k = document.querySelector('#czViewer .iv .md-kept-i'); if (!k) return null; const f = k.querySelector('[data-md="fold"]');
|
|
169
|
+
return { b: f.querySelector('b').textContent, pill: f.querySelector('.md-ok').textContent, n: f.querySelector('.n').textContent, open: f.getAttribute('aria-expanded'), undo: (k.querySelector('[data-md="undo"]') || {}).title || '', card: !!document.querySelector('#czViewer .iv .md-card') }; }));
|
|
170
|
+
ok('I kept: the folded "Success measure · Set before the build · 3", with Undo', !!kf && kf.b === 'Success measure' && kf.pill === 'Set before the build' && kf.n === '3' && kf.open === 'false' && kf.undo === 'Undo' && !kf.card, JSON.stringify(kf));
|
|
171
|
+
await p.click('#czViewer .iv .md-kept-i [data-md="fold"]');
|
|
172
|
+
const lst = await until(() => p.evaluate(() => { const L = [...document.querySelectorAll('#czViewer .iv .md-kept-i .md-lr')]; return L.length ? L.map((x) => x.textContent) : null; }));
|
|
173
|
+
ok('I the fold opens on its rows', !!lst && lst.join(' / ') === 'Mobile checkout login drop-off27% → 19%, 4 weeks after release / Inline form completionWaits on ESHOP-981 / Checkout conversionStays at ≥ 3.1%', JSON.stringify(lst));
|
|
174
|
+
await shot(p, 'Iq9Initiative-kept-built');
|
|
175
|
+
await p.click('#czViewer .iv .md-kept-i [data-md="undo"]');
|
|
176
|
+
await until(() => D.posts.filter((x) => x.path === '/api/metric-drafts/undo' && x.body.scope === 'initiative').length === 3, 5000);
|
|
177
|
+
ok('I Undo makes it a proposal again', !!(await until(() => p.evaluate(() => !!document.querySelector('#czViewer .iv .md-card')))));
|
|
178
|
+
ok('0 no page error (desk)', D.errors.length === 0, D.errors.join(' | '));
|
|
179
|
+
await D.ctx.close();
|
|
180
|
+
|
|
181
|
+
/* ── Z: nothing drafted, nothing shown ── */
|
|
182
|
+
const Z = await open({ drafts: { program: { rows: [] }, initiative: { rows: [] } } });
|
|
183
|
+
await until(() => Z.gets.some((g) => g.scope === 'program'), 4000);
|
|
184
|
+
await sleep(400); // the answer has arrived and drawn: nothing may appear
|
|
185
|
+
ok('Z nothing drafted: no proposal and no Goal row on the program panel', await Z.page.evaluate(() => !document.querySelector('#czViewer .md-card, #czViewer .md-kept')));
|
|
186
|
+
await Z.page.evaluate(() => { const b = document.querySelector('#czViewer [data-czs-fold="tree"]'); if (b && b.getAttribute('aria-expanded') !== 'true') b.click(); });
|
|
187
|
+
await until(() => Z.page.evaluate(() => !!document.querySelector('#czViewer button.pp-open[data-ini="descope-parity"]')));
|
|
188
|
+
await Z.page.click('#czViewer button.pp-open[data-ini="descope-parity"]');
|
|
189
|
+
await until(() => Z.page.evaluate(() => !!document.querySelector('#czViewer .iv')) && Z.gets.some((g) => g.scope === 'initiative'), 6000);
|
|
190
|
+
await sleep(400);
|
|
191
|
+
ok('Z nothing drafted: no success measure on the initiative', await Z.page.evaluate(() => !document.querySelector('#czViewer .md-card, #czViewer .md-kept-i')));
|
|
192
|
+
ok('0 no page error (nothing drafted)', Z.errors.length === 0, Z.errors.join(' | '));
|
|
193
|
+
await Z.ctx.close();
|
|
194
|
+
|
|
195
|
+
/* ── H: a phone, and dark ── */
|
|
196
|
+
const H = await open({ w: 390, h: 844 });
|
|
197
|
+
const hc = await until(() => card(H.page));
|
|
198
|
+
ok('H on a phone: the card fits the width, and its presses are 44 px', !!hc && await H.page.evaluate(() => { const c = document.querySelector('#czViewer .md-card'), r = c.getBoundingClientRect(), b = c.querySelector('[data-md="keep"]').getBoundingClientRect(); return r.right <= innerWidth && c.scrollWidth <= c.clientWidth + 1 && b.width >= 44; }));
|
|
199
|
+
await shot(H.page, 'Iq9Program-phone-built');
|
|
200
|
+
ok('0 no page error (phone)', H.errors.length === 0, H.errors.join(' | '));
|
|
201
|
+
await H.ctx.close();
|
|
202
|
+
if (SHOTS) {
|
|
203
|
+
const K = await open({ dark: true });
|
|
204
|
+
await until(() => card(K.page));
|
|
205
|
+
await shot(K.page, 'Iq9Program-dark-built');
|
|
206
|
+
await K.ctx.close();
|
|
207
|
+
}
|
|
208
|
+
return finish();
|
|
209
|
+
})();
|
|
@@ -142,7 +142,7 @@ const withReview = (open, o = {}) => F.programs().map((p) => ({ ...p, ...(o.empt
|
|
|
142
142
|
|
|
143
143
|
/* ── M: Home's Your move ── */
|
|
144
144
|
const M = await open({ home: true });
|
|
145
|
-
// the program's milestone changes lead its card on Home (batch 14 item 4
|
|
145
|
+
// the program's milestone changes lead its card on Home (batch 14 item 4)
|
|
146
146
|
await until(() => M.page.evaluate(() => !!document.querySelector('[data-hm-prog]')), 10000);
|
|
147
147
|
const hm = await until(() => M.page.evaluate(() => { const b = document.querySelector('[data-hm-sel="ms:project-ascent"]'); return b ? [...b.querySelectorAll('b, em')].map((x) => x.textContent.trim()).join(' · ') : null; }), 10000);
|
|
148
148
|
ok('M Home\'s program card has one line for its milestone changes, first', hm === '3 milestone changes · Pilot live to Dec 2', String(hm));
|
|
@@ -150,11 +150,11 @@ const withReview = (open, o = {}) => F.programs().map((p) => ({ ...p, ...(o.empt
|
|
|
150
150
|
await M.page.click('[data-hm-sel="ms:project-ascent"]');
|
|
151
151
|
ok('M a tap opens the program, where the changes lead Waits on you', !!(await until(() => M.page.evaluate(() => !!document.querySelector('#czViewer [data-czs-id="needs"] .msg-r')), 8000)));
|
|
152
152
|
}
|
|
153
|
-
// batch
|
|
153
|
+
// batch 16: on a desktop the greeting opens Your day in the Viewer, as on a phone; the calendar is under ⋯
|
|
154
154
|
if (await M.page.$('[data-hm-day]')) {
|
|
155
155
|
await M.page.click('[data-hm-day]');
|
|
156
|
-
const vw = await until(() => M.page.evaluate(() => { const v = document.querySelector('#czViewer'); const t = v && !v.hidden ? v.textContent.replace(/\s+/g, ' ') : ''; return /
|
|
157
|
-
ok('D on a desktop the greeting opens
|
|
156
|
+
const vw = await until(() => M.page.evaluate(() => { const v = document.querySelector('#czViewer'); const t = v && !v.hidden ? v.textContent.replace(/\s+/g, ' ') : ''; return /Your day/.test(t) ? t : null; }), 8000);
|
|
157
|
+
ok('D on a desktop the greeting opens Your day in the Viewer, as on a phone', !!vw, String(vw).slice(0, 200));
|
|
158
158
|
}
|
|
159
159
|
ok('0 no page error on Home', M.errors.length === 0, M.errors.join(' | '));
|
|
160
160
|
await M.ctx.close();
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.430.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.430.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -102,8 +102,9 @@ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'applicati
|
|
|
102
102
|
await p.__ctx.close();
|
|
103
103
|
|
|
104
104
|
p = await scene({ time: at(8, 0), today: [MT('mB', 'Quota review', 13, 0, 14, 0)], needs: [{ key: 'k1', kind: 'due-today', id: i1.id, headline: 'Send the partner onboarding list to Lina' }], name: 'morning' });
|
|
105
|
-
c = await wait(p, /
|
|
106
|
-
|
|
105
|
+
c = await wait(p, /Your morning/);
|
|
106
|
+
// Your day E (YdE1Ready): the day's meetings by time and title, then what of yours is due; no count of what waits
|
|
107
|
+
ok('M5 the morning: lists the meetings and what of yours is due, and counts nothing', c && c.kind === 'morning' && /13:00\s*Quota review/.test(c.text) && /Send the partner onboarding list to Lina/.test(c.text) && !/\d+ items? of yours|this morning/.test(c.text), c && c.text);
|
|
107
108
|
await p.__ctx.close();
|
|
108
109
|
|
|
109
110
|
p = await scene({ time: at(14, 30), today: [MT('mB', 'Quota review', 16, 0, 17, 0)], name: 'work' });
|
|
@@ -112,8 +113,9 @@ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'applicati
|
|
|
112
113
|
await p.__ctx.close();
|
|
113
114
|
|
|
114
115
|
p = await scene({ time: at(18, 0), today: [A], needs: [{ key: 'k1', kind: 'overdue', id: i1.id, headline: 'Send the partner onboarding list to Lina', days_late: 1 }], name: 'recap' });
|
|
115
|
-
c = await wait(p, /
|
|
116
|
-
|
|
116
|
+
c = await wait(p, /What today made possible/);
|
|
117
|
+
// Your day E (YdE3Evening): what moved, from phone-day; no counts and no "days late"
|
|
118
|
+
ok('M7 the evening: what today made possible, from phone-day, with no counts and no lateness', c && c.kind === 'recap' && /Sandbox dates agreed/.test(c.text) && /One thing tonight/.test(c.text) && !/\d+ items done|days? late/.test(c.text), c && c.text);
|
|
117
119
|
await p.__ctx.close();
|
|
118
120
|
|
|
119
121
|
p = await scene({ time: at(21, 0), today: [A], name: 'night' });
|
|
@@ -160,7 +162,8 @@ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'applicati
|
|
|
160
162
|
await p.__ctx.close();
|
|
161
163
|
p = await scene({ time: at(18, 0), today: [A], dayFail: true });
|
|
162
164
|
c = await wait(p, /Today could not be read/);
|
|
163
|
-
|
|
165
|
+
// zero is silence (batch 15 item 3): with nothing of the PM's open the recap says nothing about it, but a failed read is always named
|
|
166
|
+
ok('E2 a failed phone-day read is named in the recap, and claims nothing it could not read', c && /could not be read/.test(c.text) && !/What today made possible/.test(c.text), c && c.text);
|
|
164
167
|
await p.__ctx.close();
|
|
165
168
|
|
|
166
169
|
/* W: desktop width and the POST allow-list */
|
|
@@ -76,7 +76,7 @@ const SHOTS = process.env.PMOS_SHOTS || '';
|
|
|
76
76
|
await page.evaluate(() => {
|
|
77
77
|
window.__rise = 0; window.__loads = 0; window.__frame = document.querySelector('#czViewer .obody.vw iframe.vwframe');
|
|
78
78
|
window.__turns = [...document.querySelectorAll('#hmLog .hm-u, #hmLog .hm-a')];
|
|
79
|
-
document.querySelector('#hmLog').addEventListener('animationstart', () => { window.__rise++; }); // any entrance a turn plays again
|
|
79
|
+
document.querySelector('#hmLog').addEventListener('animationstart', (e) => { if (!e.target.closest('.ad-svg')) window.__rise++; }); // any entrance a turn plays again (Adler's own idle motion on the latest reply is not an entrance)
|
|
80
80
|
if (window.__frame) window.__frame.addEventListener('load', () => { window.__loads++; });
|
|
81
81
|
});
|
|
82
82
|
await sleep(7000); // three conversation reads and two list reads
|