create-pmos 0.428.0 → 0.429.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.
Files changed (106) hide show
  1. package/package.json +13 -13
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/briefing-premium-board-test.js +2 -2
  7. package/workspace/briefing-premium-insights-test.js +81 -60
  8. package/workspace/briefing-premium-metrics-test.js +5 -3
  9. package/workspace/briefing-premium-sources-test.js +5 -5
  10. package/workspace/briefing-premium-test.js +5 -4
  11. package/workspace/changelog.json +12 -0
  12. package/workspace/ev-everywhere-test.js +2 -2
  13. package/workspace/guide/home.md +2 -0
  14. package/workspace/guide/index.md +1 -0
  15. package/workspace/guide/metric-drafts.md +48 -0
  16. package/workspace/intel-report-ui-test.js +189 -0
  17. package/workspace/lib/board-metrics-premium.js +1 -1
  18. package/workspace/lib/headless.js +15 -2
  19. package/workspace/lib/insights-premium.js +5 -1
  20. package/workspace/lib/insights-records.js +14 -5
  21. package/workspace/lib/intel-report.js +419 -0
  22. package/workspace/lib/metric-draft-runs.js +193 -0
  23. package/workspace/lib/metric-drafts.js +231 -0
  24. package/workspace/lib/metrics-cli.js +104 -0
  25. package/workspace/lib/pmos-verbs.js +3 -0
  26. package/workspace/lib/report-setups.js +29 -13
  27. package/workspace/lib/route-modules.js +1 -0
  28. package/workspace/lib/routes-insights-premium.js +2 -2
  29. package/workspace/lib/routes-insights-records.js +13 -5
  30. package/workspace/lib/routes-metric-drafts.js +141 -0
  31. package/workspace/lib/routes-phone-day.js +13 -2
  32. package/workspace/lib/routes-report-setups.js +92 -3
  33. package/workspace/lib/routes-viewer.js +5 -2
  34. package/workspace/metric-drafts-ui-test.js +209 -0
  35. package/workspace/package-lock.json +2 -2
  36. package/workspace/package.json +1 -1
  37. package/workspace/premium-phone-card-test.js +8 -5
  38. package/workspace/public/pm/bd-acts.js +3 -3
  39. package/workspace/public/pm/bd-pin-card.css +4 -4
  40. package/workspace/public/pm/bd-prog-panel.js +9 -4
  41. package/workspace/public/pm/cozy-aud.css +1 -1
  42. package/workspace/public/pm/cozy-board.css +256 -256
  43. package/workspace/public/pm/cozy-ev.css +45 -45
  44. package/workspace/public/pm/cozy-evmodel.js +1 -1
  45. package/workspace/public/pm/cozy-home-rows.css +23 -23
  46. package/workspace/public/pm/cozy-home.css +207 -207
  47. package/workspace/public/pm/cozy-insights.css +207 -108
  48. package/workspace/public/pm/cozy-live-pill.css +5 -5
  49. package/workspace/public/pm/cozy-mtg-present.css +23 -23
  50. package/workspace/public/pm/cozy-nav.js +1 -1
  51. package/workspace/public/pm/cozy-news.js +2 -2
  52. package/workspace/public/pm/cozy-panel.css +29 -29
  53. package/workspace/public/pm/cozy-pick.css +5 -5
  54. package/workspace/public/pm/cozy-rec-now.css +20 -20
  55. package/workspace/public/pm/cozy-rec-present.css +11 -11
  56. package/workspace/public/pm/cozy-rec-tab.css +13 -13
  57. package/workspace/public/pm/cozy-settings.js +1 -1
  58. package/workspace/public/pm/cozy-steps.css +9 -9
  59. package/workspace/public/pm/cozy-today.css +107 -71
  60. package/workspace/public/pm/cozy-viewer.css +7 -7
  61. package/workspace/public/pm/cozy-viewer.js +1 -1
  62. package/workspace/public/pm/cozy-vw-mtg.css +81 -81
  63. package/workspace/public/pm/cozy-vw-rp.css +53 -53
  64. package/workspace/public/pm/cozy-vw-shell.css +23 -23
  65. package/workspace/public/pm/cozy-vw.css +117 -117
  66. package/workspace/public/pm/cozy-xv.css +11 -11
  67. package/workspace/public/pm/cozy.css +18 -15
  68. package/workspace/public/pm/hi-pop.css +19 -19
  69. package/workspace/public/pm/home-app.js +28 -2
  70. package/workspace/public/pm/home-day.js +131 -26
  71. package/workspace/public/pm/home-ini.css +32 -32
  72. package/workspace/public/pm/home-line.css +7 -7
  73. package/workspace/public/pm/home-list.js +12 -1
  74. package/workspace/public/pm/home-phone-card.js +18 -15
  75. package/workspace/public/pm/ini-view.css +102 -102
  76. package/workspace/public/pm/ini-view.js +9 -3
  77. package/workspace/public/pm/loose-props.css +13 -13
  78. package/workspace/public/pm/metric-drafts.css +82 -0
  79. package/workspace/public/pm/metric-drafts.js +165 -0
  80. package/workspace/public/pm/ms-suggest.css +8 -8
  81. package/workspace/public/pm/ov-view.css +12 -12
  82. package/workspace/public/pm/premium-chart-tab.js +6 -6
  83. package/workspace/public/pm/premium-insights.js +298 -107
  84. package/workspace/public/pm/premium-report-intel.css +56 -0
  85. package/workspace/public/pm/premium-report-intel.js +232 -0
  86. package/workspace/public/pm/premium-shell.js +2 -2
  87. package/workspace/public/pm/premium-vw-file.js +2 -2
  88. package/workspace/public/pm/premium.css +127 -128
  89. package/workspace/public/pm/prog-order.css +6 -6
  90. package/workspace/public/pm/program-charter.css +23 -23
  91. package/workspace/public/pm/rp-parts.js +2 -2
  92. package/workspace/public/pm/sort-order.css +1 -1
  93. package/workspace/public/pm/split-merge.css +15 -15
  94. package/workspace/public/pm/task-card.css +21 -21
  95. package/workspace/public/pm/tk-tasks.css +37 -37
  96. package/workspace/public/pm/tk-view.css +6 -6
  97. package/workspace/public/pm/wf-page.css +28 -28
  98. package/workspace/public/premium-intelligence.html +82 -0
  99. package/workspace/server.js +38 -3
  100. package/workspace/skills/metric-draft.skill +47 -0
  101. package/workspace/test-lists/intel-report-ui.json +5 -0
  102. package/workspace/test-lists/intel-report.json +9 -0
  103. package/workspace/test-lists/metric-drafts-ui.json +5 -0
  104. package/workspace/test-lists/metric-drafts.json +9 -0
  105. package/workspace/test-run.js +3 -0
  106. package/workspace/public/premium-insights.html +0 -81
@@ -179,7 +179,7 @@ const sh = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
179
179
  {
180
180
  // re-pointed again for the Agreed design's Home: the source row is a Needs-you row of Home's list, and the digest is a row of New for you.
181
181
  // Re-pointed for Home A + C (HvAC, HvACDesk): a row is one line, its mark and its title; the subject moved to the row's tooltip and
182
- // accessible name, and the title is 14.5 px on a desktop, 15 px on a phone, weight 600
182
+ // accessible name, and the title is 14 px on a desktop, 16 px on a phone, weight 600 (the type scale, feedback batch 15 item 2)
183
183
  const ROWS = [['row', '.hm-rm'], ['number', '.hv-d'], ['title', '.hm-rt b']];
184
184
  const DIGS = [['event', ''], ['eventTime', '.ev-tx .ev-mut'], ['eventTitle', '.ev-tx b']];
185
185
  const SANS = 'var(--cz-sans)';
@@ -187,10 +187,10 @@ const sh = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
187
187
  const WANT = {
188
188
  row: { fontFamily: SANS, color: 'var(--cz-ink)', backgroundColor: 'transparent' },
189
189
  number: { backgroundColor: 'var(--cz-blue)', borderRadius: '50%', width: '8px', height: '8px' }, // the row's dot is blue: it waits on you (HvAC .d)
190
- title: { fontFamily: SANS, fontSize: '14.5px', fontWeight: '600', color: 'var(--cz-ink)' }, // HvACDesk .t; 15px on a phone (HvAC .t b)
190
+ title: { fontFamily: SANS, fontSize: '14px', fontWeight: '600', color: 'var(--cz-ink)' }, // HvACDesk .t; 16px on a phone (HvAC .t b)
191
191
  event: { fontFamily: SANS, color: 'var(--cz-ink)', backgroundColor: 'transparent' }, // a row of New for you's table (cozy-ev.css)
192
- eventTime: { fontSize: '12.5px', color: 'var(--cz-ink3)' },
193
- eventTitle: { fontFamily: SANS, fontSize: '13.5px', fontWeight: '700', color: 'var(--cz-ink)' },
192
+ eventTime: { fontSize: '12px', color: 'var(--cz-ink3)' },
193
+ eventTitle: { fontFamily: SANS, fontSize: '14px', fontWeight: '700', color: 'var(--cz-ink)' },
194
194
  };
195
195
  const grab = (pg, pairs, base, col) => pg.evaluate(([pairs, want, base, col]) => {
196
196
  const o = {};
@@ -221,7 +221,7 @@ const sh = (cwd, args) => spawnSync('git', args, { cwd, encoding: 'utf8' });
221
221
  await allNeeds(R.page);
222
222
  // on a phone "Not in an initiative" starts folded (HvAC): open it to reach the source row
223
223
  if (w === 390) { const lh = await R.page.$('#hmList .hv-lh[aria-expanded="false"]'); if (lh) await lh.click(); }
224
- WANT.title.fontSize = w === 390 ? '15px' : '14.5px';
224
+ WANT.title.fontSize = w === 390 ? '16px' : '14px';
225
225
  await sleep(500);
226
226
  const rowSel = '#hmList .hm-r[data-id^="n:src:"]';
227
227
  const diffs = diff(await grab(R.page, ROWS, rowSel, '.hm-pg'), ROWS, 4); // the row fills its group (the group's own inset aside)
@@ -85,7 +85,7 @@ const vw = () => { const v = document.querySelector('#czViewer:not([hidden])');
85
85
  ok('R1 /console.html and /classic.html go to Home: the console and the classic page are deleted', gone.every((r) => r.status === 302 && /\/premium\.html$/.test(r.headers.get('location') || '')), gone.map((r) => r.status).join());
86
86
  const old = await fetch(BASE + '/c3.html', { redirect: 'manual' }); ok('R1 /c3.html with no query goes to Home', old.status === 302 && /\/premium\.html$/.test(old.headers.get('location') || ''));
87
87
  const rail = await p.evaluate(() => ({ gone: !document.querySelector('nav.rail, .rail [data-go], #dlg'), places: [...document.querySelectorAll('#czMenu a')].map((a) => a.textContent.trim() + '>' + a.getAttribute('href')), cur: (document.querySelector('#czMenu [aria-current="page"]') || {}).textContent || '' }));
88
- ok('R1 no old rail and no old dialog; the place menu names Home, Board and Insights and Home is current', rail.gone && rail.places.join() === 'Home>/premium.html,Board>/premium-board.html,Insights>/premium-insights.html' && /Home/.test(rail.cur), JSON.stringify(rail));
88
+ ok('R1 no old rail and no old dialog; the place menu names Home, Board and Intelligence and Home is current', rail.gone && rail.places.join() === 'Home>/premium.html,Board>/premium-board.html,Intelligence>/premium-intelligence.html' && /Home/.test(rail.cur), JSON.stringify(rail));
89
89
  ok('R1 nothing on Home links to the console', await p.evaluate(() => !document.querySelector('a[href*="console"], a[href*="c3.html"], [data-href*="console"]')));
90
90
  // premium-uncovered-features (EvSettings): Settings is its own dialog, opened from the place menu
91
91
  await p.click('#czFab'); await p.click('[data-cz-settings]');
@@ -125,7 +125,7 @@ const vw = () => { const v = document.querySelector('#czViewer:not([hidden])');
125
125
  const selBg = await p.evaluate(() => getComputedStyle(document.querySelector('.hm-r.sel')).backgroundColor);
126
126
  ok('R12 the selected row is tinted (HvACDesk .sel)', selBg && !/rgba\(0, 0, 0, 0\)|transparent/.test(selBg), selBg);
127
127
  const hd = await p.evaluate(() => { const h = document.querySelector('#hmCh'); return h && !h.hidden ? { t: (h.querySelector('.hm-chb') || {}).textContent || '', mark: !!h.querySelector('.hv-mk .hv-d, .hv-mk .hv-ck'), y: Math.round(h.getBoundingClientRect().top), size: getComputedStyle(h.querySelector('.hm-chb')).fontSize } : null; });
128
- ok('R12 the chat\'s header line names the open row: its mark and its title, 17 px, at the top of the chat card (HvACDesk .ch)', !!hd && hd.t === r0.t && hd.mark && hd.y === 32 && hd.size === '17px', JSON.stringify(hd)); }
128
+ ok('R12 the chat\'s header line names the open row: its mark and its title, 16 px (the type scale, batch 15), at the top of the chat card (HvACDesk .ch)', !!hd && hd.t === r0.t && hd.mark && hd.y === 32 && hd.size === '16px', JSON.stringify(hd)); }
129
129
 
130
130
  /* R10 */
131
131
  ok('R10 a page where nothing was pressed to record sends no POST', A.posts.filter((x) => /briefing-premium\/(decide|put-off|return|start)/.test(x.path)).length === 0, JSON.stringify(A.posts.map((x) => x.path)));
@@ -228,9 +228,10 @@ const vw = () => { const v = document.querySelector('#czViewer:not([hidden])');
228
228
  // Home A + C (HvAC, XvAPhDay): the list folds "Not in an initiative" on a phone; every next step is in Your day, which "Good morning" opens
229
229
  await until(() => P.page.evaluate(() => { const l = document.querySelector('#hmList'); return l && getComputedStyle(l).display !== 'none' && !!document.querySelector('#hmList .hv-sub'); }));
230
230
  const top = await P.page.evaluate(() => (document.querySelector('#hmList .hv-sub') || {}).textContent || '');
231
- // Your day is an item in the Viewer, full screen on a phone (XvAPhDay): Your move lists the same rows
231
+ // Your day is an item in the Viewer, full screen on a phone (XvAPhDay): the same rows, split since batch 15 item 3 (design E) into the
232
+ // calls of Your move, Drafted for you and Can wait
232
233
  await P.page.click('#hmList [data-hm-day]');
233
- const rows = await until(() => P.page.evaluate((sel) => document.querySelectorAll('#czViewer:not([hidden]) .hd-move ' + sel.replace('#hmList ', '')).length, NEEDS));
234
+ const rows = await until(() => P.page.evaluate(() => document.querySelectorAll('#czViewer:not([hidden]) .yd [data-id^="n:"]').length));
234
235
  await P.page.evaluate(() => window.czViewer.close());
235
236
  const tn = /(\d+) (?:is|are) yours/.exec(top);
236
237
  ok(`R8 (${theme}) on a phone the list is the page; "N are yours" counts the next steps Your day lists`, rows >= MODEL.list.rows.length && !!tn && +tn[1] >= rows && await P.page.evaluate(() => document.body.classList.contains('hm-plist')), JSON.stringify({ top, rows }));
@@ -1,4 +1,16 @@
1
1
  [
2
+ {
3
+ "v": "0.429.0",
4
+ "at": "2026-10-27T18:29:21.690Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 1072,
9
+ "t": "Feedback batch 15",
10
+ "s": "Feedback batch 15"
11
+ }
12
+ ]
13
+ },
2
14
  {
3
15
  "v": "0.428.0",
4
16
  "at": "2026-10-27T09:47:36.220Z",
@@ -2,7 +2,7 @@
2
2
  'use strict';
3
3
  /* ev-everywhere-test.js — the Everywhere parts (initiative premium-uncovered-features, E1 to E4; canvas EvMenu, EvSearch, EvInbox, EvSources,
4
4
  * EvSettings, EvStates, EvDark, EvPhone). The real server with one scratch product repository that has a worktree with a draft.
5
- * U1 the place menu: Home, Board, Insights, then Search, New for you, Sources, Settings and Theme; More only on Home
5
+ * U1 the place menu: Home, Board, Intelligence, then Search, New for you, Sources, Settings and Theme; More only on Home
6
6
  * S1 Ctrl K opens Search over the page; typing finds a document on main and a draft on the worktree; the kind chips narrow; Escape closes
7
7
  * S2 the worktree chip lists the worktree and leaving it out drops its draft; S3 a result opens in the Viewer
8
8
  * N1 New for you opens in the Viewer, with the rows the old Around you held named under Where the rest went; nothing is posted on open
@@ -83,7 +83,7 @@ const put = (root, rel, text) => { fs.mkdirSync(path.dirname(path.join(root, rel
83
83
  const { ctx, pg, errors, posts } = await open();
84
84
  await menu(pg);
85
85
  const m = await pg.evaluate(() => ({ links: [...document.querySelectorAll('#czMenu a')].map((a) => a.textContent.trim()), items: [...document.querySelectorAll('#czMenu .ev-mi')].map((b) => b.textContent.replace(/\s+/g, ' ').trim()), more: !!document.querySelector('#czMenu [data-cz-more]'), theme: [...document.querySelectorAll('#czMenu [data-ev-theme]')].map((b) => b.textContent) }));
86
- ok('U1 the menu holds Home, Board, Insights, then Search, New for you, Sources and Settings, More (on Home) and Theme', m.links.join() === 'Home,Board,Insights' && /^Search/.test(m.items[0]) && /^New for you/.test(m.items[1]) && /^Sources/.test(m.items[2]) && /^Settings/.test(m.items[3]) && m.more && m.theme.join() === 'Light,Dark,Auto', JSON.stringify(m));
86
+ ok('U1 the menu holds Home, Board, Intelligence, then Search, New for you, Sources and Settings, More (on Home) and Theme', m.links.join() === 'Home,Board,Intelligence' && /^Search/.test(m.items[0]) && /^New for you/.test(m.items[1]) && /^Sources/.test(m.items[2]) && /^Settings/.test(m.items[3]) && m.more && m.theme.join() === 'Light,Dark,Auto', JSON.stringify(m));
87
87
  await snap(pg, 'menu-1440-light');
88
88
  await pg.keyboard.press('Escape');
89
89
  ok('U2 Escape closes the menu', await until(() => pg.isHidden('#czMenu')));
@@ -9,6 +9,8 @@ timestamp: 2026-10-27
9
9
 
10
10
  Home is the page at `/premium.html`. It follows the Agreed design and the "Uncovered features" canvas (initiative `premium-uncovered-features`). The left side is one list. The middle is the chat. The right side is the Viewer. A row opens its item in the Viewer. On a phone the list is the page, and a row opens its conversation with a back bar.
11
11
 
12
+ Home, the Board, Insights and the Viewer use one type scale: 11, 12, 14, 16, 20 and 28 px. A list row's name is 14 px on a desktop and 16 px on a phone, a group head is 16 px, the quiet meta line and a chip are 12 px, a badge is 11 px, a page title is 20 px and a large number is 28 px. The same kind of text has the same size on every page; weight and colour make the difference, not a half pixel.
13
+
12
14
  ## The list
13
15
 
14
16
  - The top line has **Good morning**, the product picker, the filter icon (on a desktop) and **New**. The line under it says how many items are yours, for example "4 are yours".
@@ -67,6 +67,7 @@ On a desktop the workspace is one frame. [Layout](layout.md) explains each part.
67
67
  - [Initiatives and the Roadmap: Now, Next and Later](initiatives-roadmap.md): what day one shows, how an agent proposes a move, and `pmos initiative` and `pmos measure` from a terminal.
68
68
  - [The Initiative Driver: drafts the agent files for you](initiative-driver.md): when the driver runs, the unblock sweep, the limits, Keep, Send back and Drop, the board modes, and `pmos driver`.
69
69
  - [Claude proposes: the one ✦ on each initiative](claude-proposes.md): what Claude finds when you add an initiative, new dates, done and tidy names for late tasks, ✓, ✕, Undo, and `pmos propose`.
70
+ - [Claude drafts metrics without being asked](metric-drafts.md): when Claude drafts the metrics of a product, a program or an initiative, keep, drop, Undo, and `pmos metrics draft`.
70
71
  - [Core documents: what each level keeps](core-documents.md): the core documents of the portfolio, a board and an initiative, their states, how PMOS drafts them, Issue it, and `pmos coredoc write`.
71
72
  - [The Horizon scan: the agent looks outside your initiatives](horizon-scan.md): how often it runs, the watch list you keep, what a scan does, where findings land, what it cannot do, and `pmos scan`.
72
73
  - [PM-only acts: what you and your agents can do](pm-only-acts.md): the acts that were yours alone, how the workspace checks that a press comes from your page, your terminal or an agent session, how an agent's act is logged under its name (D98), and what to do when a press is refused.
@@ -0,0 +1,48 @@
1
+ ---
2
+ type: Guide
3
+ title: "Claude drafts metrics without being asked"
4
+ description: "When Claude drafts the metrics of a product, a program or an initiative, what each draft says, how you keep or drop it, Undo, how to turn it off, and the pmos metrics draft commands."
5
+ timestamp: 2026-10-27
6
+ ---
7
+
8
+ # Claude drafts metrics without being asked
9
+
10
+ You do not fill in a form to get metrics. When something has no metrics yet, Claude drafts them by itself and shows the drafts on the page. Nothing becomes a metric until you press ✓.
11
+
12
+ ## When Claude drafts
13
+
14
+ - **A product with no North Star.** Claude drafts a North Star, up to 3 inputs and up to 2 guardrails.
15
+ - **A new quarter.** In the first 14 days of a quarter, Claude drafts next quarter's key results from how the last quarter ended.
16
+ - **A program charter with no goal.** Claude drafts the program goal with checkpoints at its milestones, one metric for each product that it rolls up from, and one guardrail.
17
+ - **An initiative that gets a PRD and has no success measure.** Claude drafts how it proves it worked (read 4 weeks after release), one early signal and one guardrail. An initiative that already had its PRD when the workspace first scanned is not drafted by itself. Press Draft again to draft it.
18
+
19
+ Claude drafts each one once. A run that failed tries again the next day. At most 2 runs go at once.
20
+
21
+ ## What a draft says
22
+
23
+ The page shows the run as five steps: read, shape, measure, target and ready. Each source shows one line while Claude reads it.
24
+
25
+ Each row has a name, a type, the number now, a target and why. Every number now comes from the last 8 weeks of real readings, with its source. When no event counts a metric, the row says so and shows the ticket Claude drafted for the event. Claude does not create the ticket.
26
+
27
+ ## Keep, drop and Undo
28
+
29
+ - ✓ keeps one row. It writes one KR metric record and, when the number now is known, its first reading.
30
+ - ✓ in the header keeps every open row.
31
+ - ✕ drops one row.
32
+ - Undo on a kept row retires its record. Undo on a dropped row brings it back.
33
+ - Draft again starts a new run. The rows you kept stay. The rows you did not keep are drafted again.
34
+ - ■ Stop ends a run. What it drafted so far stays on the page.
35
+
36
+ To turn the drafts off, start the workspace with `PMOS_METRIC_DRAFT=off`.
37
+
38
+ ## The commands
39
+
40
+ Claude's background run files its drafts with these commands. The server pins the product, program or initiative and the run, so the commands refuse outside that run. You keep and drop drafts on the page.
41
+
42
+ - `pmos metrics draft read "<source>" --found "<one line>" [--state done|now|wait]`: one source read.
43
+ - `pmos metrics draft step shape|measure|target|ready`: the run moves to the next step.
44
+ - `pmos metrics draft row --json <file|->`: one drafted row, or a list of rows.
45
+ - `pmos metrics draft end --head "<line>" --sub "<line>" --src "<sources>"`: the run is done, with what the page says on top.
46
+ - `pmos metrics draft status`: what is open, kept and dropped.
47
+
48
+ The run writes no record and sends nothing.
@@ -0,0 +1,189 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* intel-report-ui-test.js — a report made from Intelligence, on the page (batch 15 item 4; canvas RfA1Entry, RfA2Draft, RfA6Phone). Serves the real
4
+ * Intelligence page from the real server. GET /api/insights-premium answers the model lib/insights-premium.js builds from its fixture; the
5
+ * /api/report-setups routes are stubbed here, answering with lib/intel-report.js on that same model, so the panel shows what the server would.
6
+ * H the report icon sits between Filter and +, icon-only with a label; its menu: This whole view, A dashboard, One key result or outcome
7
+ * D the draft opens in the side panel: ✦ "I drafted the story", the chips (how often, who, format, ⓘ from history), The answer, The story with
8
+ * numbered finding titles and switches (Appendix off), the five checks; a switch redraws the checks; ✓ is off until someone reads it
9
+ * S ✓ sets it up (source intelligence, the scope, the storyline); the panel says Set up with Undo; Undo removes it and discards its draft
10
+ * G a key result's Viewer carries the report press
11
+ * P the ✦ strip proposes a report: See the draft, Not now, ✓ Set it up, icon-only; Not now files strip-dismiss and the item goes
12
+ * T the type scale only · M on a phone. PMOS_SHOTS=<dir> also saves the screenshots. */
13
+ const path = require('path');
14
+ const fs = require('fs');
15
+ const { spawn } = require('child_process');
16
+ const { findBrowser } = require('./lib/find-browser');
17
+ const T = require('./test-run').configure({ name: 'intel-report-ui' });
18
+ const IP = require('./lib/insights-premium.js');
19
+ const F = require('./fixtures/insights-premium-facts.js');
20
+ const IR = require('./lib/intel-report.js');
21
+
22
+ const BASE = T.BASE;
23
+ const SHOTS = process.env.PMOS_SHOTS || '';
24
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
25
+ 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); } };
26
+ const results = [];
27
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 700) : ''}`); };
28
+ let srv = null; let browser = null;
29
+ const finish = async (code) => {
30
+ if (browser) await browser.close().catch(() => {});
31
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
32
+ T.killTmux();
33
+ const bad = results.filter((x) => !x.cond).length;
34
+ console.log(`\n${results.length - bad}/${results.length} intel-report-ui assertions passed`);
35
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
36
+ };
37
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
38
+
39
+ const BUDGETS = [{ id: 'docs', covers: 'documentation upkeep', cap: 0.2 }];
40
+ const MODEL = IP.build(F.facts({ pinned: 'all', budgets: BUDGETS }));
41
+ /* a Library finding (the same numbers mailed every Monday): the defaults and the ✦ proposal come from it */
42
+ const FINDING = { id: 'rf-0123456789', name: 'Partner numbers to Lee', why: 'You mail Lee the partner numbers every Monday.', evidence: [{ kind: 'mail', text: 'Partner numbers, 6 Mondays' }, { kind: 'mail', text: 'Re: partner numbers' }],
43
+ proposal: { name: 'Partner numbers weekly', audience: 'Lee', output: 'pdf', schedule: { cadence: 'weekly', day: 'Mon', time: '09:00' } } };
44
+
45
+ (async () => {
46
+ const exe = process.env.PMOS_CHROME || findBrowser();
47
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
48
+ let chromium;
49
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
50
+ srv = spawn(process.execPath, [path.join(__dirname, 'server.js')], { cwd: __dirname, stdio: 'ignore', env: T.env({ PMOS_WS_PORT: String(T.PORT), PMOS_SELF_ROOT: path.resolve(__dirname, '..') }) });
51
+ await T.waitForServer(BASE);
52
+ browser = await chromium.launch({ executablePath: exe });
53
+ if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
54
+ const shot = async (p, name) => { if (SHOTS) { await sleep(450); await p.screenshot({ path: path.join(SHOTS, name + '.png') }); } };
55
+
56
+ const open = async ({ w = 1440, h = 900, dark = false } = {}) => {
57
+ const c = await browser.newContext({ viewport: { width: w, height: h }, colorScheme: dark ? 'dark' : 'light' });
58
+ const page = await c.newPage();
59
+ const errors = [], posts = [], gets = [];
60
+ const st = { dismissed: [], setups: [] };
61
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
62
+ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
63
+ await page.route('**/api/insights-premium*', (r) => json(r, { ok: true, state: 'ready', model: MODEL, as_of: 1 }));
64
+ await page.route('**/api/board-metrics-premium*', (r) => json(r, { ok: true, state: 'ready', model: { tiles: [] } }));
65
+ await page.route('**/api/briefing-premium/products', (r) => json(r, { ok: true, all: false, chosen: true, products: [{ ws: MODEL.board.ws, name: MODEL.board.name, home: false, primary: true, initials: null, on: true }] }));
66
+ await page.route('**/api/metric-drafts**', (r) => json(r, { ok: true, rows: [], run: { state: 'idle', step: 0, reads: [] } }));
67
+ await page.route('**/api/report-setups/**', (r) => {
68
+ const rq = r.request(), u = new URL(rq.url());
69
+ if (rq.method() === 'GET' && u.pathname === '/api/report-setups/storyline') {
70
+ const scope = u.searchParams.get('scope') || 'view'; gets.push({ scope, story: u.searchParams.get('story') });
71
+ let story = {}; if (u.searchParams.get('story')) { const c0 = IR.checkStoryline(JSON.parse(u.searchParams.get('story'))); if (!c0.ok) return json(r, { ok: false, error: c0.error }, 400); story = c0.storyline; }
72
+ const S = IR.storylineOf(MODEL, { scope, ask: story.ask, items: story.items }); if (story.answer) S.answer = story.answer;
73
+ const d = IR.defaultsOf([FINDING], scope, S.name);
74
+ const doc = IR.documentOf(MODEL, { id: 'preview', name: S.name, audience: d.audience, output: d.output, source: IR.sourceOf(scope), storyline: story }, { slot: MODEL.today });
75
+ return json(r, { ok: true, storyline: S, defaults: d, checks: IR.storyChecks(doc), proposals: IR.proposalsOf(MODEL, { findings: [FINDING], dismissed: st.dismissed, now: Date.parse(MODEL.today) }), as_of: MODEL.today });
76
+ }
77
+ const body = JSON.parse(rq.postData() || '{}'); posts.push({ path: u.pathname, body });
78
+ if (u.pathname.endsWith('/strip-dismiss')) { st.dismissed.push(body.id); return json(r, { ok: true }); }
79
+ if (u.pathname.endsWith('/setup')) { st.setups.push(body); return json(r, { ok: true, setup: { id: 'partner-weekly', name: body.name, source: 'intelligence:' + body.scope, scope: body.scope }, first_draft: { slot: '2026-11-02' }, drafted: { ok: true, slot: '2026-11-02', path: 'pmos/state/reports/partner-weekly/2026-11-02.md' } }); }
80
+ if (u.pathname.endsWith('/remove')) return json(r, { ok: true });
81
+ return json(r, { ok: true });
82
+ });
83
+ await page.route('**/api/report-setups?*', (r) => json(r, { setups: [], findings: [], asks: [], finder: {} }));
84
+ await page.route('**/api/report-documents/**', (r) => { posts.push({ path: new URL(r.request().url()).pathname, body: JSON.parse(r.request().postData() || '{}') }); return json(r, { ok: true }); });
85
+ await page.goto(BASE + '/premium-intelligence.html');
86
+ await until(() => page.evaluate(() => document.querySelectorAll('#goalTbl .ins-row').length > 0), 20000);
87
+ return { page, ctx: c, errors, posts, gets, st };
88
+ };
89
+ const vClose = async (pg) => { for (let k = 0; k < 4; k++) { const shown = await pg.evaluate(() => { const v = document.querySelector('#czViewer'); return !!v && !v.hidden; }); if (!shown) break; await pg.evaluate(() => window.czViewer && window.czViewer.close()); await sleep(250); } };
90
+ 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);
91
+ const SCALE = new Set(['11px', '12px', '14px', '16px', '20px', '28px']);
92
+ const panel = (p) => p.evaluate(() => {
93
+ const b = document.querySelector('#czViewer:not([hidden]) .ins-rpd') || document.querySelector('#side:not([hidden]) .ins-rpd'); if (!b) return null;
94
+ return { title: (document.querySelector('#czViewer .cz-vw-title') || {}).textContent || '', kind: (document.querySelector('#czViewer .cz-vw-kind') || {}).textContent || '', sum: (b.querySelector('.ins-rps b') || {}).textContent || '',
95
+ chips: [...b.querySelectorAll('.ins-rpchip')].map((c) => c.querySelector('select') ? c.querySelector('select').selectedOptions[0].textContent : c.querySelector('input') ? c.querySelector('input').value : c.textContent.trim()),
96
+ answer: (b.querySelector('.ins-rpa') || {}).value || '', story: [...b.querySelectorAll('.ins-rpst')].map((r) => ({ n: r.querySelector('.n').textContent, t: r.querySelector('b').textContent, on: r.querySelector('[role="switch"]').getAttribute('aria-checked') === 'true', live: !!r.querySelector('.ins-rplive') })),
97
+ checks: [...b.querySelectorAll('.ins-rpck .ck')].map((c) => ({ ok: !c.classList.contains('w'), t: c.textContent })), checkHead: (b.querySelectorAll('.ins-rpl')[2] || {}).textContent || '',
98
+ set: (() => { const x = b.querySelector('[data-rd="set"]'); return x ? { label: x.getAttribute('aria-label'), disabled: x.disabled, solid: x.classList.contains('solid'), text: x.textContent.trim() } : null; })(),
99
+ undo: !!b.querySelector('[data-rd="undo"]') };
100
+ });
101
+
102
+ /* ── H: the header icon and its menu ── */
103
+ const A = await open();
104
+ const p = A.page;
105
+ const hd = await p.evaluate(() => { const ids = [...document.querySelectorAll('#insBar .ins-tools button.cz-ib')].map((b) => b.id); const b = document.querySelector('#repB'); return { ids, label: b && b.getAttribute('aria-label'), text: b && b.textContent.trim(), svg: !!(b && b.querySelector('svg[aria-hidden="true"]')) }; });
106
+ ok('H the report icon sits between Filter and +, icon-only with a label', hd.ids.indexOf('repB') === hd.ids.indexOf('filtB') + 1 && hd.ids.indexOf('newB') === hd.ids.indexOf('repB') + 1 && hd.label === 'Make a report from this' && !hd.text && hd.svg, JSON.stringify(hd));
107
+ await p.click('#repB');
108
+ const mn = await p.evaluate(() => [...document.querySelectorAll('#repMenu [role="menuitem"]')].map((x) => x.querySelector('span').firstChild.textContent));
109
+ ok('H its menu: This whole view, A dashboard, One key result or outcome', mn.join() === 'This whole view,A dashboard,One key result or outcome', mn.join());
110
+ await shot(p, 'RfA1-menu');
111
+ await p.click('#repMenu [data-rs="one"]');
112
+ const one = await p.evaluate(() => [...document.querySelectorAll('#repMenu [data-rs^="goal:"]')].length);
113
+ ok('H One key result or outcome lists the goals', one >= 3, one);
114
+ await p.click('#repMenu [data-rs="back"]');
115
+ await p.keyboard.press('Escape');
116
+ ok('H Escape closes it', await p.evaluate(() => document.querySelector('#repMenu').hidden));
117
+
118
+ /* ── D: the draft ── */
119
+ await p.click('#repB'); await p.click('#repMenu [data-rs="view"]');
120
+ const d = await until(() => panel(p));
121
+ const S0 = IR.storylineOf(MODEL, { scope: 'view' });
122
+ ok('D the draft opens in the side panel: Report · Lee, named from history', !!d && d.kind === 'Report · Lee' && d.title === 'Partner numbers weekly', JSON.stringify(d && { kind: d.kind, title: d.title }));
123
+ ok('D ✦ I drafted the story from Intelligence', !!d && d.sum === 'I drafted the story from Intelligence');
124
+ ok('D the chips: how often, who reads it, format, and why from history', !!d && d.chips.join(' / ') === 'Weekly · Mon 09:00 / Lee / One page + appendix / from your 2 Monday emails', d && d.chips.join(' / '));
125
+ ok('D The answer is the drafted governing thought', !!d && d.answer === S0.answer, d && d.answer);
126
+ ok('D The story: numbered finding titles, each a switch; Appendix and the ask off; live only on the data items', !!d && d.story.length === S0.items.length && d.story.every((r, i) => r.n === String(i + 1))
127
+ && !d.story[0].on && !d.story[d.story.length - 1].on && d.story[1].on && d.story[1].live && !d.story[0].live, JSON.stringify(d && d.story));
128
+ ok('D the five checks, with how many pass', !!d && d.checks.length === 5 && /Checks before it goes out\s*\d of 5/.test(d.checkHead), JSON.stringify(d && d.checks));
129
+ ok('D ✓ Set it up is one solid icon, with a label', !!d && d.set && d.set.solid && d.set.label === 'Set it up' && !d.set.text && !d.set.disabled, JSON.stringify(d && d.set));
130
+ await shot(p, 'RfA2-draft');
131
+ // the ask switch opens its three fields; filling them redraws the checks (the ask has who and by when)
132
+ await p.click('.ins-rpd [data-rd="tog"][data-id="ask"]');
133
+ await p.fill('.ins-rpd [data-rf="askt"]', 'Move the partner launch to after 15 December');
134
+ await p.fill('.ins-rpd [data-rf="askb"]', '2026-11-06');
135
+ await until(() => A.gets.some((g) => g.story && /"ask"/.test(g.story) && /2026-11-06/.test(g.story)), 4000);
136
+ const d2 = await until(async () => { const x = await panel(p); return x && x.story[0].on && /Your decision: Move the partner launch/.test(x.story[0].t) ? x : null; }, 4000);
137
+ ok('D the ask switch turns on with the decision, who (the reader) and by when, and the checks are read again', !!d2 && d2.checks.find((c) => /ask/.test(c.t)) && d2.checks.find((c) => /ask/.test(c.t)).ok, JSON.stringify(d2 && d2.checks));
138
+ // who reads it: empty → ✓ is off
139
+ await p.fill('.ins-rpd [data-rf="aud"]', '');
140
+ ok('D with nobody to read it, ✓ is off', await p.evaluate(() => document.querySelector('.ins-rpd [data-rd="set"]').disabled));
141
+ await p.fill('.ins-rpd [data-rf="aud"]', 'Lee');
142
+ const ts = await sizes(p, '.ins-rpd');
143
+ ok('T the draft uses the type scale only', ts.length && ts.every((x) => SCALE.has(x)), ts.join());
144
+
145
+ /* ── S: ✓ sets it up; Undo takes it back ── */
146
+ await p.click('.ins-rpd [data-rd="set"]');
147
+ const sp = await until(() => A.posts.find((x) => x.path === '/api/report-setups/setup'), 4000);
148
+ ok('S ✓ posts the setup: source intelligence, the scope, who, how often, the format and the storyline', !!sp && sp.body.source === 'intelligence' && sp.body.scope === 'view' && sp.body.audience === 'Lee' && sp.body.schedule.day === 'Mon' && sp.body.output === 'pdf'
149
+ && sp.body.storyline.ask && sp.body.storyline.ask.by === '2026-11-06' && sp.body.storyline.items.length === S0.items.length && sp.body.finding === FINDING.id, JSON.stringify(sp && sp.body));
150
+ const d3 = await until(async () => { const x = await panel(p); return x && x.sum === 'Set up' ? x : null; }, 4000);
151
+ ok('S the panel says Set up, with Undo', !!d3 && d3.undo);
152
+ ok('S the toast says who gets it and when, with Undo', await until(() => p.evaluate(() => { const t = document.querySelector('#toast'); return t && /Set up\. Lee gets it weekly at mon 09:00 from your mail\./i.test(t.textContent) && /Undo/.test(t.textContent); }), 3000), await p.evaluate(() => (document.querySelector('#toast') || {}).textContent));
153
+ await shot(p, 'RfA2-set');
154
+ await p.click('.ins-rpd [data-rd="undo"]');
155
+ await until(() => A.posts.some((x) => x.path === '/api/report-documents/discard'), 4000);
156
+ ok('S Undo removes the setup and discards its first draft', A.posts.some((x) => x.path === '/api/report-setups/remove' && x.body.id === 'partner-weekly') && A.posts.some((x) => x.path === '/api/report-documents/discard' && x.body.path === 'pmos/state/reports/partner-weekly/2026-11-02.md'), JSON.stringify(A.posts.map((x) => x.path)));
157
+ ok('S after Undo the draft is back', !!(await until(async () => { const x = await panel(p); return x && x.sum === 'I drafted the story from Intelligence'; }, 3000)));
158
+ await vClose(p);
159
+
160
+ /* ── G: a key result's Viewer carries the press ── */
161
+ await p.click('#goalTbl .ins-row');
162
+ const gp = await until(() => p.evaluate(() => { const b = document.querySelector('#czViewer:not([hidden]) [data-cz-vw-p="report"]'); return b ? { label: b.getAttribute('aria-label'), text: b.textContent.trim() } : null; }), 4000);
163
+ ok('G a key result\'s Viewer has the report icon', !!gp && gp.label === 'Make a report from this' && !gp.text, JSON.stringify(gp));
164
+ if (gp) { await p.click('#czViewer [data-cz-vw-p="report"]'); await until(() => A.gets.some((g) => /^goal:/.test(g.scope)), 3000); ok('G it opens the draft for that one goal', A.gets.some((g) => /^goal:/.test(g.scope))); }
165
+ await vClose(p);
166
+
167
+ /* ── P: the ✦ strip proposes a report ── */
168
+ const pageTo = async () => { for (let i = 0; i < 6; i++) { const has = await p.evaluate(() => !!document.querySelector('#insAct [data-rp="see"]')); if (has) return true; const dots = await p.$$('#insPg button:not([hidden])'); if (!dots.length) return false; await dots[dots.length - 1].click(); await sleep(120); } return false; };
169
+ ok('P the strip holds a report Claude proposes', await until(pageTo, 4000));
170
+ const pr = await p.evaluate(() => ({ text: document.querySelector('#brief').textContent, acts: [...document.querySelectorAll('#insAct [data-rp]')].map((b) => ({ k: b.dataset.rp, label: b.getAttribute('aria-label'), text: b.textContent.trim(), solid: b.classList.contains('solid') })), ask: document.querySelector('#askWhy').hidden, askShown: getComputedStyle(document.querySelector('#askWhy')).display }));
171
+ ok('P it says the pattern in plain words', /^You send Lee these numbers every Monday\. Shall I make it a report that drafts itself\?$/.test(pr.text), pr.text);
172
+ ok('P See the draft, Not now and a solid ✓ Set it up, icon-only, and no Ask why', pr.acts.map((a) => a.label).join() === 'See the draft,Not now,Set it up for Lee' && pr.acts.every((a) => !a.text) && pr.acts[2].solid && pr.ask && pr.askShown === 'none', JSON.stringify(pr));
173
+ await shot(p, 'RfA1-strip');
174
+ await p.click('#insAct [data-rp="no"]');
175
+ await until(() => A.posts.some((x) => x.path === '/api/report-setups/strip-dismiss'), 3000);
176
+ ok('P Not now files strip-dismiss and the item goes', A.posts.some((x) => x.path === '/api/report-setups/strip-dismiss' && x.body.id === 'found:' + FINDING.id) && await until(() => p.evaluate((id) => !document.querySelector('#insAct [data-rpid="' + id + '"]'), 'found:' + FINDING.id), 2000), await p.evaluate(() => document.querySelector('#insHero').textContent));
177
+ ok('no page errors', !A.errors.length, A.errors.join(' | '));
178
+
179
+ /* ── M: on a phone ── */
180
+ const B = await open({ w: 390, h: 844 });
181
+ await B.page.click('#repB'); await B.page.click('#repMenu [data-rs="view"]');
182
+ const m = await until(() => panel(B.page));
183
+ ok('M on a phone the draft opens full screen with the same parts', !!m && m.story.length === S0.items.length && m.checks.length === 5);
184
+ const ov = await B.page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth + 1);
185
+ ok('M no sideways scroll', ov);
186
+ await shot(B.page, 'RfA6-phone');
187
+ ok('M no page errors', !B.errors.length, B.errors.join(' | '));
188
+ return finish();
189
+ })();
@@ -124,7 +124,7 @@ function build(f) {
124
124
  const look = tiles.filter((t) => t.look).length, withTg = tiles.filter((t) => t.tg != null).length;
125
125
  const lead = look ? look + ' of ' + tiles.length + ' need a look.' : '';
126
126
  const body = 'Each chart is one measure over the last ' + N + ' weeks. ' + (withTg
127
- ? 'The dashed line is the target set on Insights. Orange is off target or needs a look.' + (withTg < tiles.length ? ' ' + (tiles.length - withTg) + ' ' + plural(tiles.length - withTg, 'measure has', 'measures have') + ' no target.' : '')
127
+ ? 'The dashed line is the target set on Intelligence. Orange is off target or needs a look.' + (withTg < tiles.length ? ' ' + (tiles.length - withTg) + ' ' + plural(tiles.length - withTg, 'measure has', 'measures have') + ' no target.' : '')
128
128
  : 'No measure here has a target yet, so none is on or off target. Orange needs a look.')
129
129
  + ' Press a measure for its definition and values. A week with fewer than ' + MIN_RUNS + ' runs is left blank. Blocked and idle are kept from the first day this card was read.';
130
130
  return {
@@ -3,7 +3,7 @@
3
3
  * (initiative workspace-headless-jobs; PM decision 2026-10-11: keep Jev, no direct Claude API, background
4
4
  * jobs that need no human run headless).
5
5
  *
6
- * kindFor({ agent, origin, skill, env }) → 'notes' | 'skill' | 'ask' | 'drive' | 'scan-web' | 'scan-repo' | 'scan-research-web' | 'scan-research-repo' | 'report-setup' | 'report-find' | 'core-doc' | 'report-design' | 'report-structure-pull' | 'report-sample-fetch' | 'report-structure' | 'report-structure-dry' | 'ms-review' | 'propose' | null (null: open a pane, as before)
6
+ * kindFor({ agent, origin, skill, env }) → 'notes' | 'skill' | 'ask' | 'drive' | 'scan-web' | 'scan-repo' | 'scan-research-web' | 'scan-research-repo' | 'report-setup' | 'report-find' | 'core-doc' | 'report-design' | 'report-structure-pull' | 'report-sample-fetch' | 'report-structure' | 'report-structure-dry' | 'ms-review' | 'propose' | 'metric-draft' | null (null: open a pane, as before)
7
7
  * argsFor(kind, { modelArgs, addDirs, writePaths }) → the argv after `claude` (writePaths: the one render file a report-design job may write;
8
8
  * for the skill kind, the folders the run may write in, from skillWriteDirs)
9
9
  * skillWriteDirs(skill, { root, scratch }) → the absolute folders a background skill run may write in: its scratch folder and the state folders its skill writes
@@ -57,6 +57,10 @@
57
57
  * initiative it looks for it in the PM's sources; each morning it finds why tasks slipped. It reads the repository, the stored reads and, where the PM's
58
58
  * own settings allow it, the PM's sources through connectors; its only write is `pmos propose`, pinned by the server to that initiative and run. Only
59
59
  * the PM's ✓ writes a task, a document or a stage. It sends nothing and never runs in a pane.
60
+ * The `metric-draft` kind is Claude's metric drafts for one product, program or initiative (batch 15 item 1): origin
61
+ * `metric-draft:<ws>:<scope>:<id>:<run>`. It reads the repository, the stored reads and, where the PM's own settings allow it, the PM's sources through
62
+ * connectors; its only write is `pmos metrics draft`, pinned by the server to that scope and run. Only the PM's ✓ keep writes a record. It sends nothing
63
+ * and never runs in a pane.
60
64
  * The `report-structure` and `report-structure-dry` kinds are the report structure step (initiative report-structure): origins `report-structure:<id>` and
61
65
  * `report-structure-dry:<id>`. A turn proposes or refines the plan of a report (sources, charts, outline); a dry run tries a saved version on the last complete
62
66
  * period. Each reads the repository and, where the PM's own Claude Code settings allow it, reads through connectors (none is named in the list, as for
@@ -100,6 +104,9 @@ const MS_REVIEW_ORIGINS = Object.freeze(['ms-review:']);
100
104
  // feedback batch 12 items 2, 3 and 4: Claude looks for a new initiative in the PM's sources, and the morning task check (origin
101
105
  // `propose:<ws>:<initiative>:<run>`, lib/proposal-runs.js). Its only write is `pmos propose`, pinned by the server to that initiative and run.
102
106
  const PROPOSE_ORIGINS = Object.freeze(['propose:']);
107
+ // batch 15 item 1: Claude drafts the metrics of a product, a program or an initiative (origin `metric-draft:<ws>:<scope>:<id>:<run>`,
108
+ // lib/metric-draft-runs.js). Its only write is `pmos metrics draft`, pinned by the server to that scope and run.
109
+ const METRIC_DRAFT_ORIGINS = Object.freeze(['metric-draft:']);
103
110
  // report-design-studio: a studio turn, a cycle render or a re-render to match (origin `report-design:<cadence>`).
104
111
  const REPORT_DESIGN_ORIGINS = Object.freeze(['report-design:']);
105
112
  // report-design-studio: reading ONE linked Google or Confluence file through the PM's own connectors (origin `report-sample-fetch:<cadence>:<sampleId>`).
@@ -154,6 +161,11 @@ const TOOLS = Object.freeze({
154
161
  // that sends; it never writes a task, a document or a stage (only the PM's ✓ does).
155
162
  propose: Object.freeze(['Read', 'Glob', 'Grep', 'Bash(pmos propose *)', 'Bash(pmos initiative export *)', 'Bash(pmos initiative list *)', 'Bash(pmos task list *)',
156
163
  'Bash(pmos source show *)', 'Bash(pmos source status *)', 'Bash(git log *)', 'Bash(date *)']),
164
+ // The metric-draft run (lib/metric-draft-runs.js): read and search the repository and the stored reads, and the one verb that files a draft.
165
+ // The PM's analytics, Jira and documents are read through the PM's own connectors only where the PM's settings allow it. No Write, no Edit,
166
+ // no web fetch, nothing that sends; it never writes a record (only the PM's ✓ keep does).
167
+ 'metric-draft': Object.freeze(['Read', 'Glob', 'Grep', 'Bash(pmos metrics draft *)', 'Bash(pmos initiative export *)', 'Bash(pmos initiative list *)',
168
+ 'Bash(pmos source show *)', 'Bash(pmos source status *)', 'Bash(git log *)', 'Bash(date *)']),
157
169
  // The design run: read and search only. Its one write, the render file, is added per run by argsFor (writePaths). No Bash, no web, nothing that sends.
158
170
  'report-design': Object.freeze(['Read', 'Glob', 'Grep']),
159
171
  // The link fetch run: Read, and its one write (the text copy of the linked file) is added per run by argsFor. No Bash, no web, no connector tool named.
@@ -191,6 +203,7 @@ function kindFor({ agent, origin, skill, env } = {}) {
191
203
  if (CORE_DOC_ORIGINS.some((p) => o.startsWith(p))) return 'core-doc';
192
204
  if (MS_REVIEW_ORIGINS.some((p) => o.startsWith(p))) return 'ms-review';
193
205
  if (PROPOSE_ORIGINS.some((p) => o.startsWith(p))) return 'propose';
206
+ if (METRIC_DRAFT_ORIGINS.some((p) => o.startsWith(p))) return 'metric-draft';
194
207
  if (REPORT_DESIGN_ORIGINS.some((p) => o.startsWith(p))) return 'report-design';
195
208
  if (REPORT_SAMPLE_FETCH_ORIGINS.some((p) => o.startsWith(p))) return 'report-sample-fetch';
196
209
  // 'report-structure-dry:' is not a prefix of 'report-structure:' (the colon differs), so the two are told apart by their prefix alone
@@ -352,4 +365,4 @@ function logLines(r, exitCode) {
352
365
  return out;
353
366
  }
354
367
 
355
- module.exports = { HEADLESS_SKILLS, HEADLESS_ORIGINS, ASK_ORIGINS, DRIVE_ORIGINS, SCAN_WEB_ORIGINS, SCAN_REPO_ORIGINS, SCAN_RESEARCH_WEB_ORIGINS, SCAN_RESEARCH_REPO_ORIGINS, WEB_KINDS, REPORT_SETUP_ORIGINS, REPORT_FIND_ORIGINS, CORE_DOC_ORIGINS, REPORT_DESIGN_ORIGINS, REPORT_SAMPLE_FETCH_ORIGINS, REPORT_STRUCTURE_ORIGINS, REPORT_STRUCTURE_DRY_ORIGINS, TOOLS, SKILL_WRITE_DIRS, DEFAULT_TIMEOUT_MS, kindFor, argsFor, skillWriteDirs, timeoutMs, parseResult, streamLines, outcomeOf, signedOut, SIGNED_OUT_WHY, logLines, switchedOff };
368
+ module.exports = { HEADLESS_SKILLS, HEADLESS_ORIGINS, ASK_ORIGINS, DRIVE_ORIGINS, SCAN_WEB_ORIGINS, SCAN_REPO_ORIGINS, SCAN_RESEARCH_WEB_ORIGINS, SCAN_RESEARCH_REPO_ORIGINS, WEB_KINDS, REPORT_SETUP_ORIGINS, REPORT_FIND_ORIGINS, CORE_DOC_ORIGINS, REPORT_DESIGN_ORIGINS, REPORT_SAMPLE_FETCH_ORIGINS, REPORT_STRUCTURE_ORIGINS, REPORT_STRUCTURE_DRY_ORIGINS, METRIC_DRAFT_ORIGINS, TOOLS, SKILL_WRITE_DIRS, DEFAULT_TIMEOUT_MS, kindFor, argsFor, skillWriteDirs, timeoutMs, parseResult, streamLines, outcomeOf, signedOut, SIGNED_OUT_WHY, logLines, switchedOff };
@@ -299,6 +299,9 @@ function milestoneOf(r, i) {
299
299
  return i < 5 ? { name: LIFE_LABEL[5] } : i < 7 ? { name: LIFE_LABEL[7] } : null;
300
300
  }
301
301
  /** One goal per KR metric record, with or without a series. `today` is a day in ms (UTC midnight). */
302
+ /** A KR metric record's role on Intelligence (batch 15 item 1): the North Star, an input or a guardrail of it, a key result, or a program's or an
303
+ * initiative's own measure (lib/metric-drafts.js writes them on a ✓). A record with none is a key result. */
304
+ const ROLES = ['north-star', 'input', 'guardrail', 'kr', 'program-goal', 'rollup', 'success', 'signal'];
302
305
  function goalsOf(outcomes, charts, inits, today, meta) {
303
306
  return outcomes.map((o) => {
304
307
  const x = (meta && meta[o.id]) || {}; // the fields New goal keeps on the record (lib/insights-goals.js goalFields)
@@ -337,6 +340,7 @@ function goalsOf(outcomes, charts, inits, today, meta) {
337
340
  direction: x.direction || (dir > 0 ? 'up' : dir < 0 ? 'down' : ''),
338
341
  dirTxt: x.type === 'Stay within' ? (x.limit === 'floor' ? 'stay above' : 'stay below') : x.direction === 'exact' ? 'exactly the target' : dir > 0 ? 'up is better' : dir < 0 ? 'down is better' : '',
339
342
  period: x.period || null, checkpoints: Array.isArray(x.checkpoints) ? x.checkpoints : [], source: x.source || '', owner: x.owner || '', guardrail: x.guardrail || '',
343
+ role: ROLES.includes(x.role) ? x.role : null, program: typeof x.program === 'string' ? x.program : null, initiative: typeof x.initiative === 'string' ? x.initiative : null, // Intelligence: North Star, inputs, guardrails; a program's or an initiative's own measure
340
344
  steps: Array.isArray(x.steps) ? x.steps : null, items: Array.isArray(x.items) ? x.items.filter((s) => typeof s === 'string' && s.trim()).map((s) => clip(s.trim(), 60)) : null, limit: x.limit || null, alwaysOn: x.always_on === true, series: rs.map((r) => ({ at: String(r.at).slice(0, 10), v: r.v })), base, baseTxt: base !== null ? num(base, u) : '', from: fromAt ? shortDate(fromAt) : '',
341
345
  now, nowTxt: now !== null ? num(now, u) : '', target: tgt, targetTxt: tgt !== null ? num(tgt, u) : '', by: byAt ? shortDate(byAt) : '', byAt, fromAt,
342
346
  done, timeGone, tone: STATE_TONE[o.status] || 'q', state: o.status || 'unscored', chip: (CHIP[o.status] || ['No line scored'])[0], reason: o.reason || '',
@@ -397,7 +401,7 @@ function build(facts) {
397
401
  const board = f.board || {};
398
402
  const model = {
399
403
  header: { text: (f.pending ? 'Reading the records · ' : '') + 'Real data' + (missing.length ? ' · not read: ' + missing.join(', ') : ''), missing },
400
- board: { ws: board.ws || null, id: board.id || null, name: board.name || 'Insights', switcher: (f.boards || []).map((b) => Object.assign({ ws: b.ws, id: b.id, name: b.name }, fin(b.goals) ? { goals: b.goals } : {})) },
404
+ board: { ws: board.ws || null, id: board.id || null, name: board.name || 'Intelligence', switcher: (f.boards || []).map((b) => Object.assign({ ws: b.ws, id: b.id, name: b.name }, fin(b.goals) ? { goals: b.goals } : {})) },
401
405
  charts, mine, mineGone, mineSaved: mineAll, noSeries, dashboards, rows: charts,
402
406
  findings: findings.length ? findings : [{ kind: 'calm', key: null, text: charts.length ? (charts.some((c) => c.target !== null) ? 'Nothing stands out. No measure moved much, and none is far behind its line.' : 'Nothing stands out. No measure here has a target, so the series can only be described.') : '' }],
403
407
  calm: !findings.length && charts.length > 0,
@@ -5,7 +5,9 @@
5
5
  * FORMS · RANGES · VERDICTS · TARGET_KEYS
6
6
  * ledgerFile(root) · readLines(file)
7
7
  * checkChart(input) → { ok, value } | refusal one chart on one dashboard: { board, dash, goal, form, range, compare, target, forecast, note }
8
- * checkVerdict(input) → { ok, value } | refusal { board, ini, verdict: Keep | Iterate | Stop, learned, goal }
8
+ * checkVerdict(input) → { ok, value } | refusal { board, ini, verdict: Keep | Iterate | Stop, learned, goal, drafted } drafted: the PM kept
9
+ * Claude's drafted verdict with one ✓ on Intelligence ("Did it work?"), and `learned` is the drafted line
10
+ * checkUndo(input) → { ok, value } | refusal { board, ini } a verdict-undo line: the initiative's verdict is taken back (Undo after ✓ Keep)
9
11
  * checkTarget(input) → { ok, value } | refusal a Delivery trends target of the page's own tiles: { key: late | scope, target: number | null }
10
12
  * checkTile(input) → { ok, value } | refusal how any Delivery trends target is read (premium-uncovered-features, IsTarget): { key: one of
11
13
  * TILE_KEYS, dir: 'at least' | 'at most' | 'none', from: 'YYYY-MM-DD' | '', chip: bool }. The number stays where it was kept.
@@ -14,7 +16,7 @@
14
16
  * read(root) → fold(readLines(ledgerFile(root)))
15
17
  * append(root, ev, value, actor, { now }) → { ok, line } THE SINGLE WRITER. `v`, `ev`, `actor` and `at` are set here.
16
18
  *
17
- * THE LINES. { v: 1, ev: 'chart' | 'verdict' | 'target' | 'tile', ...value, actor, at }. The last line of each key wins: a chart per board, dashboard and goal;
19
+ * THE LINES. { v: 1, ev: 'chart' | 'verdict' | 'verdict-undo' | 'target' | 'tile', ...value, actor, at }. The last line of each key wins: a chart per board, dashboard and goal;
18
20
  * a verdict per board and initiative; a target per key; a tile setting per key. A torn line, or one without its key fields, is skipped.
19
21
  * A verdict is recorded here only: it does not move the initiative on the Board and does not change its record. */
20
22
  const fs = require('fs');
@@ -70,7 +72,13 @@ function checkVerdict(input) {
70
72
  if (!VERDICTS.includes(i.verdict)) return refuse(400, 'Pick Keep, Iterate or Stop.');
71
73
  const learned = tidy(i.learned, LEARN_MAX);
72
74
  if (!learned) return refuse(400, 'Say what you learned, in a line.');
73
- return { ok: true, value: { board, ini, verdict: i.verdict, learned, goal: id(i.goal) } };
75
+ return { ok: true, value: Object.assign({ board, ini, verdict: i.verdict, learned, goal: id(i.goal) }, i.drafted === true ? { drafted: true } : {}) };
76
+ }
77
+ function checkUndo(input) {
78
+ const i = isObj(input) ? input : {};
79
+ const board = id(i.board), ini = id(i.ini);
80
+ if (!board || !ini) return refuse(400, 'Name the board and the initiative.');
81
+ return { ok: true, value: { board, ini } };
74
82
  }
75
83
  function checkTarget(input) {
76
84
  const i = isObj(input) ? input : {};
@@ -93,6 +101,7 @@ function fold(lines) {
93
101
  for (const l of lines || []) {
94
102
  if (l.ev === 'chart') { const c = checkChart(l); if (!c.ok) continue; const v = c.value; ((charts[v.board] = charts[v.board] || {})[v.dash] = charts[v.board][v.dash] || {})[v.goal] = Object.assign({}, v, { at: l.at || null }); }
95
103
  else if (l.ev === 'verdict') { const c = checkVerdict(l); if (!c.ok) continue; const v = c.value; (verdicts[v.board] = verdicts[v.board] || {})[v.ini] = Object.assign({}, v, { at: l.at || null, by: l.actor && l.actor.by ? l.actor.by : null }); }
104
+ else if (l.ev === 'verdict-undo') { const c = checkUndo(l); if (!c.ok) continue; if (verdicts[c.value.board]) delete verdicts[c.value.board][c.value.ini]; }
96
105
  else if (l.ev === 'target') { const c = checkTarget(l); if (!c.ok) continue; if (c.value.target === null) delete targets[c.value.key]; else targets[c.value.key] = c.value.target; }
97
106
  else if (l.ev === 'tile') { const c = checkTile(l); if (!c.ok) continue; tiles[c.value.key] = { dir: c.value.dir, from: c.value.from, chip: c.value.chip, at: l.at ? String(l.at).slice(0, 10) : null }; }
98
107
  }
@@ -100,7 +109,7 @@ function fold(lines) {
100
109
  }
101
110
  const read = (root) => fold(readLines(ledgerFile(root)));
102
111
 
103
- const CHECKS = { chart: checkChart, verdict: checkVerdict, target: checkTarget, tile: checkTile };
112
+ const CHECKS = { chart: checkChart, verdict: checkVerdict, 'verdict-undo': checkUndo, target: checkTarget, tile: checkTile };
104
113
  function append(root, ev, input, actor, { now } = {}) {
105
114
  if (!CHECKS[ev]) return refuse(400, 'unknown record: ' + ev);
106
115
  const c = CHECKS[ev](input);
@@ -112,4 +121,4 @@ function append(root, ev, input, actor, { now } = {}) {
112
121
  return { ok: true, line };
113
122
  }
114
123
 
115
- module.exports = { LEDGER, FORMS, RANGES, VERDICTS, TARGET_KEYS, TILE_KEYS, TILE_DIRS, ledgerFile, readLines, checkChart, checkVerdict, checkTarget, checkTile, fold, read, append };
124
+ module.exports = { LEDGER, FORMS, RANGES, VERDICTS, TARGET_KEYS, TILE_KEYS, TILE_DIRS, ledgerFile, readLines, checkChart, checkVerdict, checkUndo, checkTarget, checkTile, fold, read, append };