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.
Files changed (134) hide show
  1. package/package.json +25 -25
  2. package/payload/KIT-VERSION +2 -2
  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/payload/state/log.md +1 -1
  7. package/workspace/briefing-premium-board-test.js +4 -4
  8. package/workspace/briefing-premium-insights-test.js +82 -61
  9. package/workspace/briefing-premium-metrics-test.js +5 -3
  10. package/workspace/briefing-premium-sources-test.js +5 -5
  11. package/workspace/briefing-premium-test.js +5 -4
  12. package/workspace/changelog.json +24 -0
  13. package/workspace/ev-everywhere-test.js +2 -2
  14. package/workspace/guide/adler.md +45 -0
  15. package/workspace/guide/briefing-premium.md +2 -0
  16. package/workspace/guide/home.md +4 -2
  17. package/workspace/guide/index.md +2 -0
  18. package/workspace/guide/metric-drafts.md +49 -0
  19. package/workspace/guide/programs.md +2 -0
  20. package/workspace/intel-report-ui-test.js +189 -0
  21. package/workspace/intelligence-gaps-ui-test.js +168 -0
  22. package/workspace/lib/board-metrics-premium.js +1 -1
  23. package/workspace/lib/headless.js +15 -2
  24. package/workspace/lib/initiative-writer.js +16 -2
  25. package/workspace/lib/insight-moves.js +135 -0
  26. package/workspace/lib/insights-premium.js +9 -4
  27. package/workspace/lib/insights-records.js +14 -5
  28. package/workspace/lib/intel-report.js +432 -0
  29. package/workspace/lib/metric-draft-runs.js +193 -0
  30. package/workspace/lib/metric-drafts.js +261 -0
  31. package/workspace/lib/metrics-cli.js +104 -0
  32. package/workspace/lib/page-opens.js +74 -0
  33. package/workspace/lib/pmos-verbs.js +3 -0
  34. package/workspace/lib/report-setups.js +29 -13
  35. package/workspace/lib/route-modules.js +3 -0
  36. package/workspace/lib/routes-insight-moves.js +119 -0
  37. package/workspace/lib/routes-insights-premium.js +12 -3
  38. package/workspace/lib/routes-insights-records.js +13 -5
  39. package/workspace/lib/routes-metric-drafts.js +150 -0
  40. package/workspace/lib/routes-page-opens.js +26 -0
  41. package/workspace/lib/routes-phone-day.js +13 -2
  42. package/workspace/lib/routes-report-setups.js +97 -3
  43. package/workspace/lib/routes-viewer.js +5 -2
  44. package/workspace/lib/settings-store.js +6 -0
  45. package/workspace/metric-drafts-ui-test.js +209 -0
  46. package/workspace/milestone-suggest-test.js +4 -4
  47. package/workspace/package-lock.json +2 -2
  48. package/workspace/package.json +1 -1
  49. package/workspace/premium-phone-card-test.js +8 -5
  50. package/workspace/premium-viewer-flicker-test.js +1 -1
  51. package/workspace/public/pm/bd-acts.js +3 -3
  52. package/workspace/public/pm/bd-pin-card.css +4 -4
  53. package/workspace/public/pm/bd-prog-panel.js +12 -7
  54. package/workspace/public/pm/bd-prog.js +2 -2
  55. package/workspace/public/pm/cozy-adler.css +82 -0
  56. package/workspace/public/pm/cozy-adler.js +270 -0
  57. package/workspace/public/pm/cozy-aud.css +1 -1
  58. package/workspace/public/pm/cozy-board.css +256 -256
  59. package/workspace/public/pm/cozy-ev.css +48 -45
  60. package/workspace/public/pm/cozy-evmodel.js +1 -1
  61. package/workspace/public/pm/cozy-home-rows.css +23 -23
  62. package/workspace/public/pm/cozy-home.css +211 -207
  63. package/workspace/public/pm/cozy-insights.css +221 -108
  64. package/workspace/public/pm/cozy-live-pill.css +5 -5
  65. package/workspace/public/pm/cozy-mtg-present.css +23 -23
  66. package/workspace/public/pm/cozy-nav.js +3 -1
  67. package/workspace/public/pm/cozy-news.js +2 -2
  68. package/workspace/public/pm/cozy-panel.css +29 -29
  69. package/workspace/public/pm/cozy-pick.css +5 -5
  70. package/workspace/public/pm/cozy-rec-now.css +20 -20
  71. package/workspace/public/pm/cozy-rec-present.css +11 -11
  72. package/workspace/public/pm/cozy-rec-tab.css +13 -13
  73. package/workspace/public/pm/cozy-search.js +4 -2
  74. package/workspace/public/pm/cozy-settings.js +16 -3
  75. package/workspace/public/pm/cozy-steps.css +9 -9
  76. package/workspace/public/pm/cozy-today.css +122 -71
  77. package/workspace/public/pm/cozy-viewer.css +7 -7
  78. package/workspace/public/pm/cozy-viewer.js +1 -1
  79. package/workspace/public/pm/cozy-vw-mtg.css +81 -81
  80. package/workspace/public/pm/cozy-vw-rp.css +53 -53
  81. package/workspace/public/pm/cozy-vw-shell.css +23 -23
  82. package/workspace/public/pm/cozy-vw.css +117 -117
  83. package/workspace/public/pm/cozy-xv.css +11 -11
  84. package/workspace/public/pm/cozy.css +34 -15
  85. package/workspace/public/pm/hi-pop.css +19 -19
  86. package/workspace/public/pm/home-app.js +33 -9
  87. package/workspace/public/pm/home-chat.js +10 -2
  88. package/workspace/public/pm/home-day.js +155 -27
  89. package/workspace/public/pm/home-ini.css +32 -32
  90. package/workspace/public/pm/home-line.css +7 -7
  91. package/workspace/public/pm/home-list.js +12 -1
  92. package/workspace/public/pm/home-phone-card.js +18 -15
  93. package/workspace/public/pm/home-today.js +5 -3
  94. package/workspace/public/pm/ini-view-model.js +1 -1
  95. package/workspace/public/pm/ini-view.css +108 -102
  96. package/workspace/public/pm/ini-view.js +22 -3
  97. package/workspace/public/pm/loose-props.css +13 -13
  98. package/workspace/public/pm/metric-drafts.css +89 -0
  99. package/workspace/public/pm/metric-drafts.js +204 -0
  100. package/workspace/public/pm/ms-suggest.css +8 -8
  101. package/workspace/public/pm/ms-suggest.js +2 -1
  102. package/workspace/public/pm/ov-view.css +12 -12
  103. package/workspace/public/pm/premium-board.js +2 -2
  104. package/workspace/public/pm/premium-chart-tab.js +6 -6
  105. package/workspace/public/pm/premium-insights.js +364 -107
  106. package/workspace/public/pm/premium-report-intel.css +56 -0
  107. package/workspace/public/pm/premium-report-intel.js +232 -0
  108. package/workspace/public/pm/premium-shell.js +2 -2
  109. package/workspace/public/pm/premium-vw-cal.js +1 -1
  110. package/workspace/public/pm/premium-vw-file.js +2 -2
  111. package/workspace/public/pm/premium-welcome.js +3 -2
  112. package/workspace/public/pm/premium.css +130 -128
  113. package/workspace/public/pm/prog-order.css +6 -6
  114. package/workspace/public/pm/program-charter.css +23 -23
  115. package/workspace/public/pm/program-model.js +7 -0
  116. package/workspace/public/pm/rp-parts.js +2 -2
  117. package/workspace/public/pm/sort-order.css +1 -1
  118. package/workspace/public/pm/split-merge.css +15 -15
  119. package/workspace/public/pm/split-merge.js +2 -1
  120. package/workspace/public/pm/task-card.css +21 -21
  121. package/workspace/public/pm/tk-tasks.css +37 -37
  122. package/workspace/public/pm/tk-view.css +6 -6
  123. package/workspace/public/pm/wf-page.css +28 -28
  124. package/workspace/public/premium-intelligence.html +82 -0
  125. package/workspace/server.js +38 -3
  126. package/workspace/skills/metric-draft.skill +47 -0
  127. package/workspace/test-lists/intel-report-ui.json +5 -0
  128. package/workspace/test-lists/intel-report.json +9 -0
  129. package/workspace/test-lists/intelligence-gaps-ui.json +5 -0
  130. package/workspace/test-lists/intelligence-gaps.json +5 -0
  131. package/workspace/test-lists/metric-drafts-ui.json +5 -0
  132. package/workspace/test-lists/metric-drafts.json +9 -0
  133. package/workspace/test-run.js +3 -0
  134. package/workspace/public/premium-insights.html +0 -81
@@ -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')));
@@ -0,0 +1,45 @@
1
+ ---
2
+ type: Guide
3
+ title: "Adler, Claude's face"
4
+ description: "Who Adler is, where he shows in PMOS, what each of his six moods means, and how to choose how much of him you see in Settings."
5
+ timestamp: 2026-10-27
6
+ ---
7
+
8
+ # Adler, Claude's face
9
+
10
+ Adler is a Shiba in a green hoodie with a sprout on his head. He is Claude's face in PMOS. When Claude says something, Adler's face shows the mood of what Claude says, so you can read the mood before you read the words.
11
+
12
+ ## His six moods
13
+
14
+ Each mood comes from real state. When nothing happens, Adler is calm or he rests.
15
+
16
+ | Mood | What it means |
17
+ | --- | --- |
18
+ | Handled | Claude's part is done. This is the usual mood. |
19
+ | Celebrating | Something real happened, for example a full day of decisions done. He celebrates at most once a week. |
20
+ | Thinking (glasses) | Claude is working for you now. |
21
+ | Needs you (holds a card) | One call is yours. |
22
+ | Honest (drooping sprout) | Something is not right. Claude says it plainly. |
23
+ | Resting | There is nothing to report, or it is after hours. |
24
+
25
+ ## Where he shows
26
+
27
+ - **Every toast.** A small face before the words: calm when the change worked, honest when it did not.
28
+ - **Chat.** Claude's avatar on the latest reply only, in that reply's mood. An empty chat shows Adler resting.
29
+ - **Home.** His face next to the greeting. While Home reads your work he wears his glasses, and when Home cannot read the repository he says so with the honest face.
30
+ - **Your day (phone).** His face on the opening card. On the first open before noon, a small morning scene. When nothing else needs you, Adler with his tea. On a day you earned it, Adler celebrating. After 22:00, Adler asleep: press **Open anyway** to see your day. If something is wrong, PMOS does not hide it behind the night scene.
31
+ - **Claude's suggestions.** Adler holds the card when Claude suggests a split or a merge, milestones, a goal or a success measure.
32
+ - **Intelligence.** His face in Claude's line at the top only. Charts, numbers and key results never show him.
33
+ - **Search.** Adler with a magnifier when nothing matches.
34
+ - **Welcome.** Adler says hello once on the first step, and wears his glasses while PMOS reads your folder.
35
+
36
+ Adler never sits in a list row, a bar, a chart or a report. Rows keep their own signals: a dot is a session and a box is a task.
37
+
38
+ ## Choose how much of Adler you see
39
+
40
+ Open **Settings › Adler**. Each choice saves on this computer when you press it.
41
+
42
+ - **How much Adler:** **Full** shows his face, his figure and his scenes. **Face only** keeps his face where Claude speaks and drops the figures and scenes. **Off** shows a plain mood dot.
43
+ - **Motion:** **Follow my computer** lets him breathe and blink slowly. **Still** stops all motion. When your computer asks for reduced motion, he is always still.
44
+ - **Celebrations:** **Real wins only** (at most once a week) or **Never**.
45
+ - **Quiet after:** **22:00** opens Your day on Adler asleep after 22:00. **Never** turns this off.
@@ -368,6 +368,8 @@ Insights is the fifth place on the rail, at `/premium-insights.html`. Its produc
368
368
  - **Dashboards and reports.** One list holds the dashboards (All measures, your saved ones, then the pillars the metrics name) and then the reports (your set-up reports, then the report files). One chip in the card's head (**All** with its count) opens **All**, **Dashboards** and **Reports**, and shows only when the list holds both kinds; it shows six rows to a page, with page numbers. A dashboard row shows its top finding and a pin. A report has one row, whatever number of cycles it has: the row quotes the opening sentence of its latest cycle and counts its cycles (for example **1 draft**, **3 issued**). Archived cycles are hidden here: a report whose cycles are all archived has no row (a set-up report keeps its set-up row). An archived cycle is still listed under **Archived** in the report's cycle chip. A set-up report with no file says no draft is written yet. **New** offers **Dashboard** or **Report**. Your requests and what PMOS found in your work stay at the top of the list. A saved dashboard draws its charts in the order you saved them. A chart whose record is gone, or that has fewer than two readings, is listed in its place with the reason and is not drawn.
369
369
  - **Make or change a dashboard, a chart or a report in a chat.** There is no Insight Studio. **+**, then **Dashboard** or **Report**, and **New chart** in the dashboard's **⋯**, open the Chat page with a first line in the message box ("Make a dashboard of ") for you to finish and send. **Edit** on a saved dashboard or one of your charts, and **Shape it in a chat** on a report drawn from your work, open the Chat page with it in its tab beside the conversation. See [Reports from a chat](#reports-from-a-chat).
370
370
  - **The findings.** Each finding is one sentence with its reason, taken from the series: will miss its target at this pace, on course, behind its line for three readings in a row, behind and still moving away from the target, closing in, slipped, reached its target, or a large one-step move. No cause is given.
371
+ - **A drafted fix.** When a finding says a goal is behind, the ✦ strip can show one fix that Claude drafted, under the finding. Press **✓** to make it, and **Undo** in the message, or **Undo** beside **Done**, to take it back. The fix is one of three. **Ask for a new date**: an initiative that moves the goal is past its end date and has an owner and a Jira epic, so a comment to the owner goes to the outbox. Nothing is sent until you send it from the outbox. **Anchor an initiative**: nothing active moves the goal, and exactly one active initiative has no anchor that resolves and shares a word with the goal, so its `parent_kr` is set to the goal. **Move the target date**: the goal will miss its target at this pace, so its date moves to the day the line through its readings gets there. A finding with no fix has no ✓. Each ✓ and Undo is one line in the workspace's state folder (`insight-moves.jsonl`).
372
+ - **A weekly report from what you open.** Intelligence notes the view you open, once a day for each view, in the workspace's runtime folder on this computer (`page-opens.jsonl`). It is not in the repository and is not sent. When you open the same view in each of the last three weeks, the ✦ strip asks if it should make that view a report that drafts itself before the day you open it most. **See the draft**, **Not now** and **✓ Set it up** work as for the other reports the strip proposes. A view that a report covers already is not proposed.
371
373
  - **Board measures.** The same four tiles as the Board's Metrics card, counted from the board's repository and drawn the same way. Choose **8 weeks**, **26 weeks** or **52 weeks**; the page keeps your choice. Press a measure to read its definition and values and to set its target: type a number and press **Save target**, or press **Clear target**. For Corrections, Blocked and Idle, lower is better, so the target is the most you accept; for Merged a week it is the least. The target goes to the workspace's state folder (`board-metric-targets.jsonl`) and the Board draws it too. An agent session cannot set one.
372
374
  - **No series recorded.** A KR metric with one reading or none is listed with the reason and is not drawn.
373
375
  - **Ask PMOS to set up a report.** The card has one rounded input, under the list. Type what the report is for and press the round send button inside it. The **+** at its left offers Dashboard or Report. The line under the input says it only proposes; its **ⓘ** shows the longer note. A background run proposes a report and does nothing else. The request is listed as Working, then Ready to review. A ready request opens with its proposal: **Set it up**, **Change it** (say what to change; the run revises it), or **Cancel**.
@@ -9,11 +9,13 @@ 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".
15
- - On a computer, press **Good morning** to open the calendar in the Viewer. The list already shows each item that waits on you, under its initiative. A program's milestone changes that wait on you are the first line of the program's card.
16
- - On a phone, press **Good morning** to open **Your day**. Your day shows the date, the meetings of the day, **Your move** (the items that wait on you, with their count) and **This week** (the Weekly review).
17
+ - Press **Good morning** to open **Your day** in the Viewer. This is the same on a computer and on a phone. To open the calendar, press **⋯** in Your day. A program's milestone changes that wait on you are the first line of the program's card.
18
+ - Your day shows the date, the meetings of the day, **Your move** (the items that wait on you, with their count) and **This week** (the Weekly review).
17
19
  - A **program** comes first, above the products. Its header shows the program icon, its name, the next milestone (◆ and the date) and how many of its initiatives are ready for that milestone. Inside it, the program's own tasks come first, then its initiatives under a small heading for each product. Each initiative shows once. Press the program's name to open the program in the Viewer. The chat then talks about the program. Press the chevron to close or open the group.
18
20
  - The **product picker** is the chip on the top line. It shows the tiles of the ticked products, overlapped, with **+N** after 3, or **All** when every product is ticked. It shows even with one product. Hold the pointer on it to read the names. Press it to open the list: **All products**, then each product with its tile, its name and one line (for example "3 initiatives · 1 of 2 goals"), then **Add a product**. Press a product to tick or untick it; the list stays open, and the last ticked product stays ticked. The pick applies when the list closes (Escape, a press outside, or the chip again). On a phone the list is a sheet at the bottom. The pick is one saved setting (`ws.briefing.include`) that Home, the Board and Insights share, so a product that you untick on one page goes from all three. With **All** ticked, a product that you add later is ticked too. The **Product** row in Settings opens the same list.
19
21
  - A program with no open initiative yet still shows, with "No initiatives yet" or "No open initiatives". A program shows only when it holds work of a ticked product. Home reads again when you come back to its tab, so a program made on the Board shows at once.
@@ -67,6 +67,8 @@ 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`.
71
+ - [Adler, Claude's face](adler.md): who Adler is, where he shows, what his six moods mean, and Settings › Adler.
70
72
  - [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
73
  - [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
74
  - [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,49 @@
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, edit 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
+ - ✎ edits an open row in place: its name, its target and where it is measured. ✓ saves the edit and × cancels it. Press ✓ keep after that to track it as you wrote it. To change anything else, such as the why, press the chat icon and ask Claude in Home. On the program panel and the initiative view, ✎ opens all the rows of the proposal.
33
+ - Undo on a kept row retires its record. Undo on a dropped row brings it back.
34
+ - Draft again starts a new run. The rows you kept stay. The rows you did not keep are drafted again.
35
+ - ■ Stop ends a run. What it drafted so far stays on the page.
36
+
37
+ To turn the drafts off, start the workspace with `PMOS_METRIC_DRAFT=off`.
38
+
39
+ ## The commands
40
+
41
+ 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.
42
+
43
+ - `pmos metrics draft read "<source>" --found "<one line>" [--state done|now|wait]`: one source read.
44
+ - `pmos metrics draft step shape|measure|target|ready`: the run moves to the next step.
45
+ - `pmos metrics draft row --json <file|->`: one drafted row, or a list of rows.
46
+ - `pmos metrics draft end --head "<line>" --sub "<line>" --src "<sources>"`: the run is done, with what the page says on top.
47
+ - `pmos metrics draft status`: what is open, kept and dropped.
48
+
49
+ The run writes no record and sends nothing.
@@ -11,6 +11,8 @@ A **program** groups initiatives across products, for example a migration that t
11
11
 
12
12
  Programs do not change how Insights, the weekly update or sprints count initiatives. An initiative counts once, in its own product.
13
13
 
14
+ A cancelled or archived initiative leaves its program's views: the band, the program panel and the timeline show only live initiatives. It stays in **Cancelled and archived** on its product's Board.
15
+
14
16
  ## The Board
15
17
 
16
18
  - The product picker is the same chip and list as on Home (see [Home](home.md)). It shows the tiles of the ticked products, or **All**. When the list closes, the Board shows the ticked products, merged as on All products. The pick is the saved setting that Home and Insights share, so a reload keeps it, and a product that you untick here goes from Home too.
@@ -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
+ })();
@@ -0,0 +1,168 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ /* intelligence-gaps-ui-test.js — the three 0.429.0 Intelligence gaps on the page (feedback batch 16 item 1). Serves the real Intelligence page
4
+ * from the real server; GET /api/insights-premium answers the model lib/insights-premium.js builds from its fixture, with one drafted move on the
5
+ * strip's finding, and the write routes are stubbed here so each press can be read back.
6
+ * S the ✦ strip says the drafted move under the finding with a solid ✓, icon-only; ✓ posts the move's sig only; the toast says what changed with
7
+ * Undo; read again, the move is Done with Undo, and Undo posts /undo
8
+ * E a drafted metric's ✎ turns its row into fields (name, target, source) with ask-in-Home, × and ✓; ✓ posts /api/metric-drafts/edit with what
9
+ * was typed; Escape puts the row back
10
+ * C the program card (pm/metric-drafts.js): ✎ opens the fields in place, ✓ posts one edit per changed row
11
+ * O the page notes the open once (POST /api/page-opens, page intelligence, view view); the ✦ strip proposes the weekly report when the record
12
+ * says so, in plain words
13
+ * T the type scale only · M on a phone. PMOS_SHOTS=<dir> also saves the screenshots. */
14
+ const path = require('path');
15
+ const fs = require('fs');
16
+ const { spawn } = require('child_process');
17
+ const { findBrowser } = require('./lib/find-browser');
18
+ const T = require('./test-run').configure({ name: 'intelligence-gaps-ui' });
19
+ const IP = require('./lib/insights-premium.js');
20
+ const F = require('./fixtures/insights-premium-facts.js');
21
+ const IR = require('./lib/intel-report.js');
22
+
23
+ const BASE = T.BASE;
24
+ const SHOTS = process.env.PMOS_SHOTS || '';
25
+ const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
26
+ 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); } };
27
+ const results = [];
28
+ const ok = (name, cond, extra = '') => { results.push({ name, cond: !!cond }); console.log(`${cond ? '✓' : '✗'} ${name}${!cond && extra !== '' ? ' — ' + String(extra).slice(0, 700) : ''}`); };
29
+ let srv = null; let browser = null;
30
+ const finish = async (code) => {
31
+ if (browser) await browser.close().catch(() => {});
32
+ if (srv) { try { srv.kill('SIGKILL'); } catch { /* gone */ } }
33
+ T.killTmux();
34
+ const bad = results.filter((x) => !x.cond).length;
35
+ console.log(`\n${results.length - bad}/${results.length} intelligence-gaps-ui assertions passed`);
36
+ process.exit(code !== undefined ? code : (bad ? 1 : 0));
37
+ };
38
+ process.on('unhandledRejection', (e) => { console.error(e); finish(1); });
39
+
40
+ const MODEL = IP.build(F.facts({ pinned: 'all' }));
41
+ const MOVE = { kind: 'date', goal: 'krm-ttfc', from: '2026-12-31', to: '2027-02-14', sig: 'mv-0123456789ab', text: 'Move the target date of Time to first call from 31 December 2026 to 14 February 2027, when it gets there at this pace.',
42
+ label: 'Move the target date to 14 February 2027', said: 'The target date is 14 February 2027 now.' };
43
+ MODEL.insight.move = MOVE;
44
+ const DRAFTS = { ok: true, scope: 'product', id: MODEL.board.ws, title: 'pmos', run: { state: 'ready', step: 4, reads: [] }, head: 'I drafted 2 metrics for pmos.', sub: '', src: 'Product brief · Amplitude',
45
+ rows: [{ id: 'md-ns', group: 'North Star', name: 'Weekly signed-in shoppers', type: 'Count', now: 38800, nowTxt: '38.8k', target: 45000, targetTxt: '45k by Dec 31', by: '2026-12-31', why: 'Trend since Aug +7%.', source: 'Amplitude', ticket: null, state: 'open' },
46
+ { id: 'md-g', group: 'Guardrails', name: 'Login time, slowest 5%', type: 'Stay within', now: 0.9, nowTxt: '0.9 s', target: 1.2, targetTxt: 'Stays under 1.2 s', by: null, why: 'One more request per checkout.', source: 'Datadog', ticket: null, state: 'open' }] };
47
+ const WEEKLY = { view: 'view', weeks: 3, day: 'Mon', opens: 4 };
48
+
49
+ (async () => {
50
+ const exe = process.env.PMOS_CHROME || findBrowser();
51
+ if (!exe) { console.log('✗ no Chrome/Chromium on this machine — the suite cannot run'); return finish(1); }
52
+ let chromium;
53
+ try { ({ chromium } = require('playwright-core')); } catch { console.log('✗ playwright-core is not installed'); return finish(1); }
54
+ 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, '..') }) });
55
+ await T.waitForServer(BASE);
56
+ browser = await chromium.launch({ executablePath: exe });
57
+ if (SHOTS) fs.mkdirSync(SHOTS, { recursive: true });
58
+ const shot = async (p, name, el) => { if (SHOTS) { await sleep(450); if (el) await (await p.$(el)).screenshot({ path: path.join(SHOTS, name + '.png') }); else await p.screenshot({ path: path.join(SHOTS, name + '.png') }); } };
59
+
60
+ const open = async ({ w = 1440, h = 900 } = {}) => {
61
+ const c = await browser.newContext({ viewport: { width: w, height: h } });
62
+ const page = await c.newPage();
63
+ const errors = [], posts = [];
64
+ const st = { done: false };
65
+ page.on('pageerror', (e) => errors.push(String((e && e.stack) || e)));
66
+ const json = (r, b, status = 200) => r.fulfill({ status, contentType: 'application/json', body: JSON.stringify(b) });
67
+ const body = (r) => JSON.parse(r.request().postData() || '{}');
68
+ await page.route('**/api/insights-premium*', (r) => { const m = JSON.parse(JSON.stringify(MODEL)); if (st.done) m.insight.move.done = { at: '2026-10-27T10:00:00Z' }; return json(r, { ok: true, state: 'ready', model: m, as_of: 1 }); });
69
+ await page.route('**/api/board-metrics-premium*', (r) => json(r, { ok: true, state: 'ready', model: { tiles: [] } }));
70
+ 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 }] }));
71
+ await page.route('**/api/metric-drafts**', (r) => {
72
+ const u = new URL(r.request().url());
73
+ if (r.request().method() === 'GET') return json(r, u.searchParams.get('scope') === 'product' ? DRAFTS : { ...DRAFTS, scope: u.searchParams.get('scope'), rows: [{ ...DRAFTS.rows[0], group: 'Program goal' }, { ...DRAFTS.rows[1], group: 'Guardrail' }] });
74
+ posts.push({ path: u.pathname, body: body(r) }); return json(r, { ok: true, changed: true });
75
+ });
76
+ await page.route('**/api/insight-moves/**', (r) => { const u = new URL(r.request().url()); posts.push({ path: u.pathname, body: body(r) }); st.done = u.pathname.endsWith('/apply'); return json(r, u.pathname.endsWith('/apply') ? { ok: true, sig: MOVE.sig, kind: 'date', said: MOVE.said } : { ok: true, sig: MOVE.sig }); });
77
+ await page.route('**/api/page-opens', (r) => { posts.push({ path: '/api/page-opens', body: body(r) }); return json(r, { ok: true, wrote: true }); });
78
+ await page.route('**/api/report-setups/**', (r) => {
79
+ const u = new URL(r.request().url());
80
+ if (u.pathname === '/api/report-setups/storyline') return json(r, { ok: true, storyline: IR.storylineOf(MODEL, { scope: 'view' }), defaults: IR.defaultsOf([], 'view', 'pmos'), checks: [], proposals: IR.proposalsOf(MODEL, { weekly: WEEKLY, now: Date.parse(MODEL.today) }), as_of: MODEL.today });
81
+ posts.push({ path: u.pathname, body: body(r) }); return json(r, { ok: true });
82
+ });
83
+ await page.route('**/api/report-setups?*', (r) => json(r, { setups: [], findings: [], asks: [], finder: {} }));
84
+ await page.goto(BASE + '/premium-intelligence.html');
85
+ await until(() => page.evaluate(() => document.querySelectorAll('#goalTbl .ins-row').length > 0), 20000);
86
+ return { page, ctx: c, errors, posts, st };
87
+ };
88
+
89
+ /* ── S: the strip's drafted move ── */
90
+ const A = await open();
91
+ const p = A.page;
92
+ const s0 = await until(() => p.evaluate(() => { const m = document.querySelector('#insMv'); const b = document.querySelector('#insAct [data-mv="apply"]'); return m && !m.hidden && b ? { mv: m.textContent, label: b.getAttribute('aria-label'), text: b.textContent.trim(), solid: b.classList.contains('solid'), two: document.querySelector('#insHero').classList.contains('mv') } : null; }), 5000);
93
+ ok('S the drafted move is said under the finding, with a solid ✓ that is icon-only', !!s0 && s0.mv === MOVE.text && s0.label === MOVE.label && !s0.text && s0.solid && s0.two, JSON.stringify(s0));
94
+ await shot(p, 'gap1-strip-move', '#insHero');
95
+ await p.click('#insAct [data-mv="apply"]');
96
+ await until(() => A.posts.some((x) => x.path === '/api/insight-moves/apply'), 3000);
97
+ const ap = A.posts.find((x) => x.path === '/api/insight-moves/apply');
98
+ ok('S ✓ posts the move\'s sig only, with the product', !!ap && ap.body.sig === MOVE.sig && ap.body.ws === MODEL.board.ws && Object.keys(ap.body).sort().join() === 'board,sig,ws', JSON.stringify(ap));
99
+ ok('S the toast says what changed, with Undo', await until(() => p.evaluate((said) => { const t = document.querySelector('#toast'); return t && t.textContent.includes(said) && /Undo/.test(t.textContent); }, MOVE.said), 3000));
100
+ const s1 = await until(() => p.evaluate(() => { const u = document.querySelector('#insAct [data-mv="undo"]'); return u ? { pill: (document.querySelector('#insAct .cz-pill') || {}).textContent, dn: document.querySelector('#insMv').classList.contains('dn'), apply: !!document.querySelector('#insAct [data-mv="apply"]') } : null; }), 4000);
101
+ ok('S read again, the move is Done with Undo and no ✓', !!s1 && s1.pill === 'Done' && s1.dn && !s1.apply, JSON.stringify(s1));
102
+ await shot(p, 'gap1-strip-done', '#insHero');
103
+ await p.click('#insAct [data-mv="undo"]');
104
+ ok('S Undo posts the sig to /undo', !!(await until(() => A.posts.find((x) => x.path === '/api/insight-moves/undo' && x.body.sig === MOVE.sig), 3000)));
105
+
106
+ /* ── O: the page open, and the weekly proposal ── */
107
+ const po = A.posts.filter((x) => x.path === '/api/page-opens');
108
+ ok('O the page notes the open once: page intelligence, view view', po.length === 1 && po[0].body.page === 'intelligence' && po[0].body.view === 'view' && po[0].body.ws === MODEL.board.ws, JSON.stringify(po));
109
+ const pageTo = async () => { for (let i = 0; i < 6; i++) { const has = await p.evaluate(() => /every week/.test(document.querySelector('#brief').textContent)); 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; };
110
+ ok('O the ✦ strip proposes the weekly report from the record', await until(pageTo, 4000));
111
+ const wk = await p.evaluate(() => ({ t: document.querySelector('#brief').textContent, why: document.querySelector('#insWhy').textContent, acts: [...document.querySelectorAll('#insAct [data-rp]')].map((b) => b.getAttribute('aria-label')) }));
112
+ ok('O in plain words, with the weeks it rests on, and the proposal\'s own presses', wk.t === 'You open this view every week. Shall I make it a report that drafts itself before Monday?' && /each of the last 3 weeks, most on Mondays/.test(wk.why) && wk.acts.join() === 'See the draft,Not now,Set it up', JSON.stringify(wk));
113
+ await shot(p, 'gap3-strip-weekly', '#insHero');
114
+
115
+ /* ── E: a drafted metric edited in place ── */
116
+ await until(() => p.evaluate(() => !!document.querySelector('#draftBox [data-dr="edit"]')), 4000);
117
+ await p.click('#draftBox [data-dr="edit"][data-row="md-ns"]');
118
+ const e0 = await p.evaluate(() => { const r = document.querySelector('[data-dred="md-ns"]'); return r ? { f: [...r.querySelectorAll('[data-drf]')].map((x) => x.dataset.drf + '=' + x.value), acts: [...r.querySelectorAll('.ins-act a, .ins-act button')].map((b) => b.getAttribute('aria-label') + (b.textContent.trim() ? '!' : '')), focus: document.activeElement && document.activeElement.dataset.drf } : null; });
119
+ ok('E ✎ turns the row into fields: name, target, source; ask in Home, ×, ✓, all icon-only; the name has the focus', !!e0 && e0.f.join('|') === 'name=Weekly signed-in shoppers|target=45000|source=Amplitude'
120
+ && e0.acts.join() === 'Ask Claude in Home to change something else,Cancel the edit,Save Weekly signed-in shoppers' && e0.focus === 'name', JSON.stringify(e0));
121
+ await shot(p, 'gap2-draft-edit', '#draftBox');
122
+ await p.keyboard.press('Escape');
123
+ ok('E Escape puts the row back', await until(() => p.evaluate(() => !document.querySelector('[data-dred]') && !!document.querySelector('#draftBox [data-dr="edit"][data-row="md-ns"]')), 2000));
124
+ await p.click('#draftBox [data-dr="edit"][data-row="md-ns"]');
125
+ await p.fill('[data-dred="md-ns"] [data-drf="name"]', 'Weekly shoppers');
126
+ await p.fill('[data-dred="md-ns"] [data-drf="target"]', '48000');
127
+ await p.click('[data-dred="md-ns"] [data-dr="save"]');
128
+ const ed = await until(() => A.posts.find((x) => x.path === '/api/metric-drafts/edit'), 3000);
129
+ ok('E ✓ posts the edit with what was typed', !!ed && ed.body.row === 'md-ns' && ed.body.name === 'Weekly shoppers' && ed.body.target === '48000' && ed.body.source === 'Amplitude' && ed.body.scope === 'product', JSON.stringify(ed));
130
+
131
+ /* ── C: the program card (pm/metric-drafts.js) edits in place too ── */
132
+ const c0 = await p.evaluate(async (ws) => {
133
+ const MDm = await import('/pm/metric-drafts.js');
134
+ const host = document.createElement('div'); host.id = 'mdHost'; document.body.appendChild(host);
135
+ const prog = { id: 'prog-1', title: 'Checkout', home: ws };
136
+ const draw = () => { host.innerHTML = MDm.progHtml(prog, ws); };
137
+ MDm.want(ws, 'program', 'prog-1', draw);
138
+ host.addEventListener('click', (e) => { const b = e.target.closest('[data-md]'); if (b) MDm.press(b, { redraw: draw, toast: (m) => { host.dataset.toast = m; } }); });
139
+ for (let i = 0; i < 40 && !host.querySelector('[data-md="edit"]'); i++) await new Promise((r) => setTimeout(r, 100));
140
+ const pen = host.querySelector('[data-md="edit"]'); if (!pen) return { error: 'no ✎', html: host.innerHTML.slice(0, 300) };
141
+ const was = pen.tagName;
142
+ pen.click();
143
+ const f = [...host.querySelectorAll('[data-md-f]')].map((x) => x.dataset.mdRow + ':' + x.dataset.mdF);
144
+ return { was, f, acts: [...host.querySelectorAll('.md-ft .md-ib')].map((b) => b.getAttribute('aria-label')) };
145
+ }, MODEL.board.ws);
146
+ ok('C the program card\'s ✎ is a press now, and opens each draft\'s fields in place with ask, ×, ✓', !!c0 && c0.was === 'BUTTON' && c0.f.join() === 'md-ns:name,md-ns:target,md-ns:source,md-g:name,md-g:target,md-g:source'
147
+ && c0.acts.join() === 'Ask Claude in Home to change something else,Cancel the edit,Save the edit', JSON.stringify(c0));
148
+ await p.fill('#mdHost [data-md-row="md-g"][data-md-f="target"]', '1.5');
149
+ await p.click('#mdHost [data-md="save"]');
150
+ const ce = await until(() => A.posts.filter((x) => x.path === '/api/metric-drafts/edit' && x.body.scope === 'program'), 3000);
151
+ ok('C ✓ posts one edit, for the row that changed', !!ce && ce.length === 1 && ce[0].body.row === 'md-g' && ce[0].body.target === '1.5' && ce[0].body.id === 'prog-1', JSON.stringify(ce));
152
+ await p.evaluate(() => document.querySelector('#mdHost').remove());
153
+
154
+ /* ── T: the type scale ── */
155
+ const SCALE = new Set(['11px', '12px', '14px', '16px', '20px', '28px']);
156
+ const sizes = await p.evaluate(() => [...new Set([...document.querySelectorAll('#insHero, #insHero *, #draftBox, #draftBox *')].filter((e) => e.childNodes.length && [...e.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim())).map((e) => getComputedStyle(e).fontSize))]);
157
+ ok('T the strip and the drafts use the type scale only', sizes.every((s) => SCALE.has(s)), sizes.join());
158
+ ok('no page errors', !A.errors.length, A.errors.join(' | '));
159
+
160
+ /* ── M: on a phone ── */
161
+ const B = await open({ w: 390, h: 844 });
162
+ const m = await until(() => B.page.evaluate(() => { const m0 = document.querySelector('#insMv'); return m0 && !m0.hidden && !!document.querySelector('#insAct [data-mv="apply"]'); }), 5000);
163
+ ok("M on a phone the move and its ✓ show, the move in full", !!m && await B.page.evaluate(() => { const r = document.querySelector("#insMv").getBoundingClientRect(), t = document.querySelector("#insText").getBoundingClientRect(); return r.height > 0 && r.bottom <= t.bottom + 1; }));
164
+ ok('M no sideways scroll', await B.page.evaluate(() => document.documentElement.scrollWidth <= window.innerWidth + 1));
165
+ await shot(B.page, 'gap1-phone');
166
+ ok('M no page errors', !B.errors.length, B.errors.join(' | '));
167
+ return finish();
168
+ })();
@@ -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 {