create-pmos 0.398.0 → 0.400.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 (515) hide show
  1. package/package.json +30 -25
  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-adddoc-test.js +19 -15
  7. package/workspace/briefing-premium-board-test.js +82 -50
  8. package/workspace/briefing-premium-calendar-2-test.js +36 -36
  9. package/workspace/briefing-premium-calendar-3-test.js +39 -39
  10. package/workspace/briefing-premium-calendar-test.js +23 -24
  11. package/workspace/briefing-premium-doc-edit-test.js +8 -10
  12. package/workspace/briefing-premium-initiative-test.js +38 -16
  13. package/workspace/briefing-premium-insights-test.js +114 -37
  14. package/workspace/briefing-premium-metrics-test.js +6 -4
  15. package/workspace/briefing-premium-products-test.js +10 -7
  16. package/workspace/briefing-premium-sources-test.js +25 -22
  17. package/workspace/briefing-premium-test.js +48 -43
  18. package/workspace/briefing-premium-work-test.js +16 -11
  19. package/workspace/c3-capture-test.js +0 -17
  20. package/workspace/changelog.json +29 -0
  21. package/workspace/ev-everywhere-test.js +210 -0
  22. package/workspace/fixtures/premium-viewer-fixtures.js +11 -6
  23. package/workspace/guide/briefing-premium.md +2 -2
  24. package/workspace/guide/home.md +58 -19
  25. package/workspace/guide/index.md +1 -1
  26. package/workspace/guide/layout.md +2 -2
  27. package/workspace/guide/notes.md +2 -2
  28. package/workspace/guide/phone-companion.md +1 -1
  29. package/workspace/lib/board-grill.js +63 -0
  30. package/workspace/lib/board-premium.js +36 -5
  31. package/workspace/lib/initiative-layout.js +77 -0
  32. package/workspace/lib/insights-premium.js +3 -2
  33. package/workspace/lib/insights-records.js +21 -7
  34. package/workspace/lib/meeting-points.js +52 -0
  35. package/workspace/lib/news-for-you.js +88 -0
  36. package/workspace/lib/notes-series.js +29 -6
  37. package/workspace/lib/report-confirm.js +48 -0
  38. package/workspace/lib/route-modules.js +9 -9
  39. package/workspace/lib/routes-board-docs.js +46 -0
  40. package/workspace/lib/routes-board-grill.js +90 -0
  41. package/workspace/lib/routes-home-review.js +108 -0
  42. package/workspace/lib/routes-initiative-layout.js +57 -0
  43. package/workspace/lib/routes-insights-premium.js +4 -1
  44. package/workspace/lib/routes-insights-records.js +8 -4
  45. package/workspace/lib/routes-meeting-points.js +37 -0
  46. package/workspace/lib/routes-news.js +57 -0
  47. package/workspace/lib/routes-notes.js +2 -1
  48. package/workspace/lib/routes-phone-day.js +18 -9
  49. package/workspace/lib/routes-report-confirm.js +31 -0
  50. package/workspace/lib/routes-search.js +38 -0
  51. package/workspace/lib/routes-slash.js +95 -0
  52. package/workspace/lib/search-index.js +176 -0
  53. package/workspace/package-lock.json +2 -2
  54. package/workspace/package.json +1 -2
  55. package/workspace/premium-board-actions-test.js +86 -50
  56. package/workspace/premium-briefing-depth-test.js +55 -54
  57. package/workspace/premium-chat-chart-tab-test.js +4 -2
  58. package/workspace/premium-chat-goal-view-test.js +1 -1
  59. package/workspace/premium-chat-report-tab-test.js +16 -2
  60. package/workspace/premium-chat-term-test.js +0 -10
  61. package/workspace/premium-core-doc-issue-test.js +15 -13
  62. package/workspace/premium-menu-rows-test.js +1 -1
  63. package/workspace/premium-phone-card-test.js +7 -5
  64. package/workspace/premium-report-read-test.js +55 -18
  65. package/workspace/premium-vw-backlog-test.js +2 -2
  66. package/workspace/premium-vw-cal-test.js +50 -35
  67. package/workspace/premium-vw-doc-test.js +10 -11
  68. package/workspace/premium-vw-item-test.js +1 -1
  69. package/workspace/premium-vw-jira-test.js +2 -2
  70. package/workspace/premium-vw-meet-test.js +37 -40
  71. package/workspace/premium-vw-notes-test.js +21 -19
  72. package/workspace/premium-vw-rec-test.js +11 -12
  73. package/workspace/premium-welcome-test.js +3 -3
  74. package/workspace/premium-work-depth-test.js +5 -6
  75. package/workspace/public/capture.html +23 -0
  76. package/workspace/public/pm/bd-acts.js +303 -225
  77. package/workspace/public/pm/bd-asks.js +261 -0
  78. package/workspace/public/pm/bd-pop.js +59 -0
  79. package/workspace/public/pm/bd-span.js +49 -13
  80. package/workspace/public/pm/bd-views.js +169 -0
  81. package/workspace/public/pm/c3-base.js +47 -0
  82. package/workspace/public/pm/c3-capture.js +1 -1
  83. package/workspace/public/pm/c3-ini-ui.js +1 -1
  84. package/workspace/public/pm/c3-sheet.js +1 -1
  85. package/workspace/public/pm/c3-toast.js +1 -1
  86. package/workspace/public/pm/console3.css +3 -0
  87. package/workspace/public/pm/cozy-board.css +301 -0
  88. package/workspace/public/pm/cozy-ev.css +228 -0
  89. package/workspace/public/pm/cozy-evmodel.js +106 -0
  90. package/workspace/public/pm/cozy-evui.js +47 -0
  91. package/workspace/public/pm/cozy-home.css +20 -5
  92. package/workspace/public/pm/cozy-insights.css +148 -10
  93. package/workspace/public/pm/cozy-nav.js +103 -39
  94. package/workspace/public/pm/cozy-news.js +140 -0
  95. package/workspace/public/pm/cozy-search.js +203 -0
  96. package/workspace/public/pm/cozy-settings.js +198 -0
  97. package/workspace/public/pm/cozy-sources.js +89 -0
  98. package/workspace/public/pm/cozy-today.css +220 -0
  99. package/workspace/public/pm/cozy-viewer.js +5 -2
  100. package/workspace/public/pm/cozy-vw-mtg.css +350 -0
  101. package/workspace/public/pm/cozy-vw-rp.css +152 -0
  102. package/workspace/public/pm/cozy.css +9 -0
  103. package/workspace/public/pm/goal-chat.js +5 -1
  104. package/workspace/public/pm/home-adddoc.js +5 -5
  105. package/workspace/public/pm/home-app.js +365 -70
  106. package/workspace/public/pm/home-around.js +24 -126
  107. package/workspace/public/pm/home-chat.js +77 -18
  108. package/workspace/public/pm/home-data.js +9 -7
  109. package/workspace/public/pm/home-dictate.js +57 -0
  110. package/workspace/public/pm/home-draft.js +6 -6
  111. package/workspace/public/pm/home-ini-model.js +190 -0
  112. package/workspace/public/pm/home-ini.css +171 -0
  113. package/workspace/public/pm/home-ini.js +466 -0
  114. package/workspace/public/pm/home-list.js +289 -0
  115. package/workspace/public/pm/home-more.js +18 -135
  116. package/workspace/public/pm/home-phone-card.js +13 -8
  117. package/workspace/public/pm/home-review.js +103 -0
  118. package/workspace/public/pm/home-task.js +67 -0
  119. package/workspace/public/pm/home-today.js +148 -0
  120. package/workspace/public/pm/home-work.js +63 -28
  121. package/workspace/public/pm/note-dock.js +1 -2
  122. package/workspace/public/pm/notes-links.js +1 -2
  123. package/workspace/public/pm/notes-task.js +3 -4
  124. package/workspace/public/pm/premium-board.js +164 -40
  125. package/workspace/public/pm/premium-chart-tab.js +4 -5
  126. package/workspace/public/pm/premium-first.js +5 -7
  127. package/workspace/public/pm/premium-initiative-head.js +3 -3
  128. package/workspace/public/pm/premium-insights.js +499 -202
  129. package/workspace/public/pm/premium-mtg-present.js +138 -0
  130. package/workspace/public/pm/premium-mtg-replay.js +142 -0
  131. package/workspace/public/pm/premium-report-read.js +216 -52
  132. package/workspace/public/pm/premium-report-tab.js +44 -19
  133. package/workspace/public/pm/premium-shell.js +7 -7
  134. package/workspace/public/pm/premium-vw-cal.js +150 -60
  135. package/workspace/public/pm/premium-vw-doc.css +20 -2
  136. package/workspace/public/pm/premium-vw-doc.js +22 -7
  137. package/workspace/public/pm/premium-vw-mtg.js +488 -261
  138. package/workspace/public/pm/premium-vw-notes.js +61 -0
  139. package/workspace/public/pm/rp-parts.js +269 -0
  140. package/workspace/public/pm/view-notes.js +2 -2
  141. package/workspace/public/premium-board.html +4 -3
  142. package/workspace/public/premium-insights.html +10 -10
  143. package/workspace/public/premium.html +3 -1
  144. package/workspace/r/m1.png +0 -0
  145. package/workspace/r/m2.png +0 -0
  146. package/workspace/r/m3.png +0 -0
  147. package/workspace/r/nl.png +0 -0
  148. package/workspace/replaced-tests.json +435 -0
  149. package/workspace/run-tests.js +323 -28
  150. package/workspace/server.js +15 -10
  151. package/workspace/test-files.json +3 -140
  152. package/workspace/test-lists/base.json +1 -2
  153. package/workspace/test-lists/c3-desktop-light-load.json +1 -2
  154. package/workspace/test-lists/c3-initiative-boards.json +1 -2
  155. package/workspace/test-lists/c3-meeting-focus.json +2 -12
  156. package/workspace/test-lists/c3-work-agent.json +1 -2
  157. package/workspace/test-lists/calendar-tidy-up.json +1 -2
  158. package/workspace/test-lists/console3-reports.json +1 -2
  159. package/workspace/test-lists/docs-three-way-sync.json +1 -2
  160. package/workspace/test-lists/extension-capture.json +5 -0
  161. package/workspace/test-lists/initiative-layout.json +9 -0
  162. package/workspace/test-lists/jira-wbs.json +1 -2
  163. package/workspace/test-lists/legacy-cleanup-a.json +9 -0
  164. package/workspace/test-lists/meeting-material.json +1 -2
  165. package/workspace/test-lists/meeting-notes.json +2 -36
  166. package/workspace/test-lists/meeting-replay.json +1 -2
  167. package/workspace/test-lists/mm-capture.json +2 -12
  168. package/workspace/test-lists/my-work.json +2 -10
  169. package/workspace/test-lists/onboarding-firstrun.json +2 -12
  170. package/workspace/test-lists/people-directory.json +1 -2
  171. package/workspace/test-lists/premium-uncovered-meetings.json +9 -0
  172. package/workspace/test-lists/premium-uncovered-reports.json +9 -0
  173. package/workspace/test-lists/run2-a.json +1 -2
  174. package/workspace/test-lists/run2-d.json +2 -19
  175. package/workspace/test-lists/run3-b.json +1 -2
  176. package/workspace/test-lists/run3-c.json +2 -12
  177. package/workspace/test-lists/run4-b.json +1 -2
  178. package/workspace/test-lists/run4-d.json +1 -5
  179. package/workspace/test-lists/run5-c.json +1 -11
  180. package/workspace/test-lists/run6.json +1 -5
  181. package/workspace/test-lists/uf-everywhere.json +15 -0
  182. package/workspace/test-lists/uf-home.json +9 -0
  183. package/workspace/test-lists/uncovered-board.json +9 -0
  184. package/workspace/test-lists/workspace-launch-flags.json +2 -12
  185. package/workspace/test-lists/workspace-profile-detection.json +2 -10
  186. package/workspace/test-timings.json +242 -123
  187. package/workspace/c3-briefing-test.js +0 -136
  188. package/workspace/c3-core-docs-test.js +0 -170
  189. package/workspace/c3-driver-fixture.js +0 -64
  190. package/workspace/c3-driver-test.js +0 -169
  191. package/workspace/c3-foundation-test.js +0 -163
  192. package/workspace/c3-ib-items-test.js +0 -114
  193. package/workspace/c3-ib-more-test.js +0 -146
  194. package/workspace/c3-ib-triage-backlog-test.js +0 -128
  195. package/workspace/c3-ini-harness.js +0 -66
  196. package/workspace/c3-ini-life-test.js +0 -167
  197. package/workspace/c3-initiatives-test.js +0 -186
  198. package/workspace/c3-light-load-test.js +0 -112
  199. package/workspace/c3-one-home-test.js +0 -149
  200. package/workspace/c3-phone-test.js +0 -289
  201. package/workspace/c3-quiet-test.js +0 -157
  202. package/workspace/c3-report-design-real-test.js +0 -264
  203. package/workspace/c3-report-design-test.js +0 -442
  204. package/workspace/c3-report-setup-test.js +0 -192
  205. package/workspace/c3-report-structure-real-test.js +0 -248
  206. package/workspace/c3-report-structure-test.js +0 -397
  207. package/workspace/c3-reports-test.js +0 -288
  208. package/workspace/c3-scan-test.js +0 -517
  209. package/workspace/c3-sessions-panel-test.js +0 -365
  210. package/workspace/c3-settings-test.js +0 -204
  211. package/workspace/c3-updates-test.js +0 -131
  212. package/workspace/c3-work-test.js +0 -260
  213. package/workspace/cut-stub.js +0 -40
  214. package/workspace/first-paint-audit.js +0 -160
  215. package/workspace/lib/c3-full-console.js +0 -15
  216. package/workspace/lib/engine/derived/trust.js +0 -3
  217. package/workspace/lib/engine/plan-forecast.js +0 -342
  218. package/workspace/lib/engine/report-families.js +0 -175
  219. package/workspace/lib/engine/truth-table.js +0 -57
  220. package/workspace/lib/routes-c3-init.js +0 -54
  221. package/workspace/lib/routes-c3-life.js +0 -120
  222. package/workspace/lib/routes-c3-timeline.js +0 -192
  223. package/workspace/lib/routes-forecast.js +0 -86
  224. package/workspace/lib/routes-releases.js +0 -130
  225. package/workspace/lib/routes-report-facts.js +0 -85
  226. package/workspace/lib/routes-report-families.js +0 -33
  227. package/workspace/lib/routes-signals.js +0 -51
  228. package/workspace/lib/routes-timeline.js +0 -197
  229. package/workspace/public/c3.html +0 -35
  230. package/workspace/public/index.html +0 -156
  231. package/workspace/public/pm/app.js +0 -831
  232. package/workspace/public/pm/bd-board.js +0 -159
  233. package/workspace/public/pm/bd-drag.js +0 -59
  234. package/workspace/public/pm/bd-model.js +0 -152
  235. package/workspace/public/pm/bd-timeline.js +0 -233
  236. package/workspace/public/pm/bd-tree.js +0 -244
  237. package/workspace/public/pm/board-copy.js +0 -59
  238. package/workspace/public/pm/board-read.js +0 -38
  239. package/workspace/public/pm/branches-sheet.js +0 -56
  240. package/workspace/public/pm/breakdown-api.js +0 -58
  241. package/workspace/public/pm/breakdown-copy.js +0 -138
  242. package/workspace/public/pm/briefing-deck.js +0 -441
  243. package/workspace/public/pm/briefing-model.js +0 -251
  244. package/workspace/public/pm/c3-ambient.js +0 -100
  245. package/workspace/public/pm/c3-audience-link.js +0 -21
  246. package/workspace/public/pm/c3-audience.js +0 -46
  247. package/workspace/public/pm/c3-boot.js +0 -13
  248. package/workspace/public/pm/c3-breakdown.js +0 -240
  249. package/workspace/public/pm/c3-brief-data.js +0 -11
  250. package/workspace/public/pm/c3-brief-mentions.js +0 -137
  251. package/workspace/public/pm/c3-brief-needs.js +0 -288
  252. package/workspace/public/pm/c3-brief-pulse.js +0 -112
  253. package/workspace/public/pm/c3-brief-summary.js +0 -139
  254. package/workspace/public/pm/c3-brief-today.js +0 -79
  255. package/workspace/public/pm/c3-brief.js +0 -279
  256. package/workspace/public/pm/c3-cal-strategy.js +0 -529
  257. package/workspace/public/pm/c3-calendar.js +0 -965
  258. package/workspace/public/pm/c3-calpop.js +0 -111
  259. package/workspace/public/pm/c3-case.js +0 -196
  260. package/workspace/public/pm/c3-core-docs.css +0 -18
  261. package/workspace/public/pm/c3-core-docs.js +0 -236
  262. package/workspace/public/pm/c3-daypart.js +0 -176
  263. package/workspace/public/pm/c3-demo-boards.js +0 -764
  264. package/workspace/public/pm/c3-demo-brief-ix.js +0 -350
  265. package/workspace/public/pm/c3-demo-brief-page.js +0 -70
  266. package/workspace/public/pm/c3-demo-cal-ix.js +0 -74
  267. package/workspace/public/pm/c3-demo-cal2.js +0 -66
  268. package/workspace/public/pm/c3-demo-cal3.js +0 -173
  269. package/workspace/public/pm/c3-demo-cal4.js +0 -169
  270. package/workspace/public/pm/c3-demo-cal5.js +0 -52
  271. package/workspace/public/pm/c3-demo-coredocs.js +0 -221
  272. package/workspace/public/pm/c3-demo-data.js +0 -552
  273. package/workspace/public/pm/c3-demo-focus.js +0 -181
  274. package/workspace/public/pm/c3-demo-init.js +0 -430
  275. package/workspace/public/pm/c3-demo-life.js +0 -77
  276. package/workspace/public/pm/c3-demo-material.js +0 -58
  277. package/workspace/public/pm/c3-demo-misc2.js +0 -34
  278. package/workspace/public/pm/c3-demo-phone.js +0 -48
  279. package/workspace/public/pm/c3-demo-plan2.js +0 -30
  280. package/workspace/public/pm/c3-demo-rd.js +0 -432
  281. package/workspace/public/pm/c3-demo-rep-ix.js +0 -126
  282. package/workspace/public/pm/c3-demo-rep2.js +0 -130
  283. package/workspace/public/pm/c3-demo-rep3.js +0 -138
  284. package/workspace/public/pm/c3-demo-rs.js +0 -287
  285. package/workspace/public/pm/c3-demo-term.js +0 -153
  286. package/workspace/public/pm/c3-demo-time.js +0 -49
  287. package/workspace/public/pm/c3-demo-work-ix.js +0 -32
  288. package/workspace/public/pm/c3-demo.js +0 -131
  289. package/workspace/public/pm/c3-design-studio.js +0 -369
  290. package/workspace/public/pm/c3-doc-formats.js +0 -153
  291. package/workspace/public/pm/c3-doc-sheet.js +0 -1230
  292. package/workspace/public/pm/c3-dock.js +0 -206
  293. package/workspace/public/pm/c3-docs.js +0 -291
  294. package/workspace/public/pm/c3-driver-work.js +0 -110
  295. package/workspace/public/pm/c3-driver.css +0 -18
  296. package/workspace/public/pm/c3-driver.js +0 -298
  297. package/workspace/public/pm/c3-focus.css +0 -304
  298. package/workspace/public/pm/c3-focus.js +0 -983
  299. package/workspace/public/pm/c3-ib-docs.js +0 -92
  300. package/workspace/public/pm/c3-ib-initiatives.js +0 -201
  301. package/workspace/public/pm/c3-ib-items.js +0 -210
  302. package/workspace/public/pm/c3-ib-releases.js +0 -48
  303. package/workspace/public/pm/c3-ib-sprints.js +0 -201
  304. package/workspace/public/pm/c3-ib-triage.js +0 -177
  305. package/workspace/public/pm/c3-ii-tabs.js +0 -252
  306. package/workspace/public/pm/c3-ini-life.css +0 -34
  307. package/workspace/public/pm/c3-ini-life.js +0 -379
  308. package/workspace/public/pm/c3-ini-records.js +0 -197
  309. package/workspace/public/pm/c3-ini-timeline.js +0 -278
  310. package/workspace/public/pm/c3-ini-work.js +0 -139
  311. package/workspace/public/pm/c3-init-extras.js +0 -170
  312. package/workspace/public/pm/c3-initiatives.js +0 -852
  313. package/workspace/public/pm/c3-lifecycle-panels.js +0 -479
  314. package/workspace/public/pm/c3-look.js +0 -27
  315. package/workspace/public/pm/c3-material.css +0 -22
  316. package/workspace/public/pm/c3-material.js +0 -321
  317. package/workspace/public/pm/c3-md.js +0 -3
  318. package/workspace/public/pm/c3-misc-panels.js +0 -89
  319. package/workspace/public/pm/c3-new-session.js +0 -110
  320. package/workspace/public/pm/c3-notes.js +0 -751
  321. package/workspace/public/pm/c3-phone-boot.js +0 -47
  322. package/workspace/public/pm/c3-phone-detail.js +0 -97
  323. package/workspace/public/pm/c3-phone-model.js +0 -3
  324. package/workspace/public/pm/c3-phone.css +0 -66
  325. package/workspace/public/pm/c3-phone.js +0 -444
  326. package/workspace/public/pm/c3-plan-panels.js +0 -163
  327. package/workspace/public/pm/c3-plan.js +0 -193
  328. package/workspace/public/pm/c3-quiet.css +0 -113
  329. package/workspace/public/pm/c3-quiet.js +0 -177
  330. package/workspace/public/pm/c3-replay.css +0 -133
  331. package/workspace/public/pm/c3-replay.js +0 -429
  332. package/workspace/public/pm/c3-report-deck.css +0 -163
  333. package/workspace/public/pm/c3-report-deck.js +0 -598
  334. package/workspace/public/pm/c3-report-frame.css +0 -20
  335. package/workspace/public/pm/c3-report-print.css +0 -20
  336. package/workspace/public/pm/c3-report-setup.css +0 -67
  337. package/workspace/public/pm/c3-report-setup.js +0 -298
  338. package/workspace/public/pm/c3-report-store.js +0 -244
  339. package/workspace/public/pm/c3-report-structure.css +0 -44
  340. package/workspace/public/pm/c3-report-structure.js +0 -473
  341. package/workspace/public/pm/c3-reports.css +0 -68
  342. package/workspace/public/pm/c3-reports.js +0 -377
  343. package/workspace/public/pm/c3-roadmap.js +0 -249
  344. package/workspace/public/pm/c3-scan-api.js +0 -167
  345. package/workspace/public/pm/c3-scan-next.js +0 -248
  346. package/workspace/public/pm/c3-scan-setup.js +0 -313
  347. package/workspace/public/pm/c3-scan-words.js +0 -41
  348. package/workspace/public/pm/c3-scan.css +0 -74
  349. package/workspace/public/pm/c3-scan.js +0 -93
  350. package/workspace/public/pm/c3-session-chat.js +0 -103
  351. package/workspace/public/pm/c3-session-conv.js +0 -165
  352. package/workspace/public/pm/c3-session-term.js +0 -216
  353. package/workspace/public/pm/c3-settings.css +0 -85
  354. package/workspace/public/pm/c3-settings.js +0 -1045
  355. package/workspace/public/pm/c3-shell.js +0 -628
  356. package/workspace/public/pm/c3-signals.js +0 -196
  357. package/workspace/public/pm/c3-strategy-panels.js +0 -45
  358. package/workspace/public/pm/c3-swipe.js +0 -230
  359. package/workspace/public/pm/c3-terminal-data.js +0 -48
  360. package/workspace/public/pm/c3-terminal-edge.js +0 -91
  361. package/workspace/public/pm/c3-terminal-icons.js +0 -40
  362. package/workspace/public/pm/c3-terminal-results.js +0 -141
  363. package/workspace/public/pm/c3-terminal.js +0 -52
  364. package/workspace/public/pm/c3-tickets.js +0 -163
  365. package/workspace/public/pm/c3-timeline.js +0 -201
  366. package/workspace/public/pm/calendar-views.js +0 -1049
  367. package/workspace/public/pm/console3-lift.md +0 -220
  368. package/workspace/public/pm/cozy-home.js +0 -172
  369. package/workspace/public/pm/cozy-initiative.css +0 -138
  370. package/workspace/public/pm/cycle-review.js +0 -125
  371. package/workspace/public/pm/data.js +0 -1577
  372. package/workspace/public/pm/dest-board.js +0 -444
  373. package/workspace/public/pm/dest-docs.js +0 -530
  374. package/workspace/public/pm/dest-initiatives.js +0 -162
  375. package/workspace/public/pm/dest-mywork.js +0 -307
  376. package/workspace/public/pm/dest-notes.js +0 -537
  377. package/workspace/public/pm/dest-people.js +0 -449
  378. package/workspace/public/pm/dest-reports.js +0 -383
  379. package/workspace/public/pm/dest-settings.js +0 -601
  380. package/workspace/public/pm/dest-today.js +0 -267
  381. package/workspace/public/pm/display-word.js +0 -56
  382. package/workspace/public/pm/doc-editor.js +0 -473
  383. package/workspace/public/pm/doc-graph.js +0 -272
  384. package/workspace/public/pm/doc-health-panel.js +0 -110
  385. package/workspace/public/pm/doc-rail.js +0 -167
  386. package/workspace/public/pm/doc-remote.js +0 -180
  387. package/workspace/public/pm/dock-sessions.js +0 -472
  388. package/workspace/public/pm/dock.js +0 -216
  389. package/workspace/public/pm/fixture.js +0 -821
  390. package/workspace/public/pm/flag-picker.js +0 -104
  391. package/workspace/public/pm/frame-copy.js +0 -278
  392. package/workspace/public/pm/freshness-line.js +0 -149
  393. package/workspace/public/pm/handoff-box.js +0 -82
  394. package/workspace/public/pm/initiative-list.js +0 -235
  395. package/workspace/public/pm/initiative-sheet.js +0 -331
  396. package/workspace/public/pm/initiatives-api.js +0 -95
  397. package/workspace/public/pm/initiatives-copy.js +0 -287
  398. package/workspace/public/pm/initiatives-timeline-copy.js +0 -59
  399. package/workspace/public/pm/initiatives-timeline.js +0 -410
  400. package/workspace/public/pm/initiatives-ui.js +0 -291
  401. package/workspace/public/pm/item-sheet.js +0 -268
  402. package/workspace/public/pm/keep-card.js +0 -204
  403. package/workspace/public/pm/lifecycle-lens-model.js +0 -246
  404. package/workspace/public/pm/lifecycle-lens.js +0 -276
  405. package/workspace/public/pm/lifecycle.js +0 -111
  406. package/workspace/public/pm/mobile.css +0 -366
  407. package/workspace/public/pm/mobile.js +0 -581
  408. package/workspace/public/pm/modes-live.js +0 -453
  409. package/workspace/public/pm/modes.js +0 -147
  410. package/workspace/public/pm/my-work-card.js +0 -51
  411. package/workspace/public/pm/my-work-data.js +0 -36
  412. package/workspace/public/pm/new-initiative-sheet.js +0 -169
  413. package/workspace/public/pm/next-step-ui.js +0 -190
  414. package/workspace/public/pm/outbox-panel.js +0 -125
  415. package/workspace/public/pm/palette-copy.js +0 -55
  416. package/workspace/public/pm/palette.js +0 -343
  417. package/workspace/public/pm/panel-breakdown.js +0 -702
  418. package/workspace/public/pm/panel-cockpit.js +0 -425
  419. package/workspace/public/pm/panel-detail.js +0 -1513
  420. package/workspace/public/pm/panel-initiatives.js +0 -929
  421. package/workspace/public/pm/panel-newsess.js +0 -709
  422. package/workspace/public/pm/panel-repos.js +0 -741
  423. package/workspace/public/pm/panel-tabs.js +0 -1506
  424. package/workspace/public/pm/panel-trees.js +0 -204
  425. package/workspace/public/pm/people-link.js +0 -106
  426. package/workspace/public/pm/phone-deck.js +0 -167
  427. package/workspace/public/pm/pm-work-view.js +0 -1533
  428. package/workspace/public/pm/portfolio-report.js +0 -61
  429. package/workspace/public/pm/premium-acts.js +0 -280
  430. package/workspace/public/pm/premium-brief.js +0 -111
  431. package/workspace/public/pm/premium-chat.js +0 -22
  432. package/workspace/public/pm/premium-doc-sheet.js +0 -312
  433. package/workspace/public/pm/premium-initiative.js +0 -324
  434. package/workspace/public/pm/premium-insights.css +0 -228
  435. package/workspace/public/pm/premium-metric-tiles.js +0 -68
  436. package/workspace/public/pm/premium-report-brief.js +0 -132
  437. package/workspace/public/pm/premium-vw-rec.js +0 -67
  438. package/workspace/public/pm/premium-wide.css +0 -30
  439. package/workspace/public/pm/print.css +0 -44
  440. package/workspace/public/pm/provider-cards.js +0 -136
  441. package/workspace/public/pm/registry.js +0 -203
  442. package/workspace/public/pm/release-card.js +0 -110
  443. package/workspace/public/pm/releases-view.js +0 -248
  444. package/workspace/public/pm/report-families-view.js +0 -505
  445. package/workspace/public/pm/report-slides.js +0 -438
  446. package/workspace/public/pm/report-tab.js +0 -33
  447. package/workspace/public/pm/report-view.js +0 -337
  448. package/workspace/public/pm/reports-copy.js +0 -134
  449. package/workspace/public/pm/roadmap.js +0 -294
  450. package/workspace/public/pm/run-card.js +0 -260
  451. package/workspace/public/pm/sessions-panel.js +0 -219
  452. package/workspace/public/pm/sheet-jira.js +0 -353
  453. package/workspace/public/pm/shell-bell.js +0 -163
  454. package/workspace/public/pm/shell-model.js +0 -83
  455. package/workspace/public/pm/shell-phone.js +0 -124
  456. package/workspace/public/pm/shell-readaloud.js +0 -53
  457. package/workspace/public/pm/shell-recording.js +0 -274
  458. package/workspace/public/pm/shell-ticker.js +0 -90
  459. package/workspace/public/pm/sig-watch.js +0 -41
  460. package/workspace/public/pm/slide-confirm.js +0 -163
  461. package/workspace/public/pm/slides-copy.js +0 -52
  462. package/workspace/public/pm/status-banner.js +0 -95
  463. package/workspace/public/pm/tab-doc.js +0 -859
  464. package/workspace/public/pm/tab-gone.js +0 -21
  465. package/workspace/public/pm/tab-term.js +0 -1210
  466. package/workspace/public/pm/tab-web.js +0 -90
  467. package/workspace/public/pm/timeline-copy.js +0 -48
  468. package/workspace/public/pm/timeline-forecast-view.js +0 -164
  469. package/workspace/public/pm/today-agenda.js +0 -331
  470. package/workspace/public/pm/today-cards.js +0 -244
  471. package/workspace/public/pm/today-copy.js +0 -506
  472. package/workspace/public/pm/today-day.js +0 -1371
  473. package/workspace/public/pm/today-goals.js +0 -297
  474. package/workspace/public/pm/today-jobs.js +0 -84
  475. package/workspace/public/pm/today-mentions.js +0 -50
  476. package/workspace/public/pm/topbar.js +0 -202
  477. package/workspace/public/pm/triage-card.js +0 -60
  478. package/workspace/public/pm/undo-hold.js +0 -103
  479. package/workspace/public/pm/view-addrepo.js +0 -208
  480. package/workspace/public/pm/view-files.js +0 -197
  481. package/workspace/public/pm/view-livenotes.js +0 -399
  482. package/workspace/public/pm/view-today.js +0 -13
  483. package/workspace/public/pm/view-validate.js +0 -171
  484. package/workspace/public/pm/welcome.js +0 -391
  485. package/workspace/public/pm/work-place.js +0 -68
  486. package/workspace/public/pm/xlsx-read.js +0 -117
  487. package/workspace/public/welcome.html +0 -22
  488. package/workspace/test-lists/browser-suites-green.json +0 -5
  489. package/workspace/test-lists/c3-core-docs.json +0 -9
  490. package/workspace/test-lists/c3-doc-sheet-rich.json +0 -6
  491. package/workspace/test-lists/c3-doc-sheet-size.json +0 -6
  492. package/workspace/test-lists/c3-doc-sheet-v2.json +0 -6
  493. package/workspace/test-lists/c3-ib-items.json +0 -9
  494. package/workspace/test-lists/c3-ib-more.json +0 -9
  495. package/workspace/test-lists/c3-ib-triage-backlog.json +0 -9
  496. package/workspace/test-lists/c3-ini-life.json +0 -9
  497. package/workspace/test-lists/c3-meeting-board.json +0 -5
  498. package/workspace/test-lists/c3-meeting-card.json +0 -5
  499. package/workspace/test-lists/c3-notes-place.json +0 -5
  500. package/workspace/test-lists/c3-notes-series.json +0 -5
  501. package/workspace/test-lists/calendar-time-page.json +0 -5
  502. package/workspace/test-lists/calpop.json +0 -4
  503. package/workspace/test-lists/console3-briefing.json +0 -9
  504. package/workspace/test-lists/console3-foundation.json +0 -9
  505. package/workspace/test-lists/console3-work-page.json +0 -9
  506. package/workspace/test-lists/premium-brief-parity.json +0 -9
  507. package/workspace/test-lists/report-design-studio-ui.json +0 -5
  508. package/workspace/test-lists/report-structure-ui.json +0 -11
  509. package/workspace/test-lists/report-workspace-ui.json +0 -5
  510. package/workspace/test-lists/run3-a.json +0 -5
  511. package/workspace/test-lists/run3-d.json +0 -6
  512. package/workspace/test-lists/run4-c.json +0 -13
  513. package/workspace/test-lists/today-goals-jobs-ui.json +0 -5
  514. package/workspace/test-lists/today-mentions-cards.json +0 -5
  515. package/workspace/test-lists/workspace-tabs-declutter.json +0 -13
@@ -1,1577 +0,0 @@
1
- /* pm/data.js — the real-state adapter for the four-panel workspace.
2
- *
3
- * Every panel module renders from `state`. This module is the ONLY thing that puts real repository
4
- * state into it. It reads exclusively from this server's own origin over relative URLs — there is
5
- * no other host, no client library, no dependency — and in FIXTURE mode it does not read at all.
6
- *
7
- * ── The failure it exists to prevent ────────────────────────────────────────────────────────
8
- * The PRD names it "the beautiful shell": seed data rendering in both modes, so the comparator's
9
- * diff is clean and nothing is connected. Two rules keep that impossible here:
10
- * 1. `FIXTURE` short-circuits every function below before any fetch. Fixture mode makes NO
11
- * network calls, so a fixture render is provably not a real read wearing a costume.
12
- * 2. Nothing in this file falls back to `fixture.js` seed data. The only thing imported from it
13
- * is `C` — the semantic colour tokens — because a second copy of `var(--warning)` in this file
14
- * is exactly the kind of duplicate that drifts.
15
- *
16
- * ── The honesty contract ────────────────────────────────────────────────────────────────────
17
- * The server's own contract is `{ok:true,empty:true}` (a successful read of nothing → CALM) ·
18
- * `{ok:true,…}` (data) · `{ok:false,error}` (a failed read → RED). This module preserves the
19
- * distinction rather than collapsing it:
20
- * · a failed read of an initiative becomes `{readError}` on the record, which panel 3 renders as
21
- * its red block carrying the server's own message. It never becomes an empty tree.
22
- * · a failed read of the board leaves the board absent, which panel 2 renders as its own empty
23
- * state — and the failure is reported on the record of whatever the PM then selects.
24
- * · a field with no source is `null`. Not zero, not an empty string standing in for a value, and
25
- * never a plausible-looking guess. `— not tracked` is the surface's job, not this file's.
26
- *
27
- * ── What is derived here, and by what rule ──────────────────────────────────────────────────
28
- * PMOS has no task entity. The phases below are folded from the workflow ladder; the tasks they once carried (derived
29
- * from the rungs) are cut with the Task tab (R29), and the work an initiative holds is the Breakdown's:
30
- * · the phase SET comes from the initiative's lane;
31
- * · each phase folds a fixed set of the workflow engine's twelve rungs, so every rung's evidence
32
- * lands in exactly one phase and none is dropped;
33
- * · a phase's status comes from its rungs — `done` where they passed, `blocked` where one is
34
- * blocking, `current` where one is current, else `pending`. A phase whose rungs carry no
35
- * evidence at all reads `pending`, NEVER `done`.
36
- * Nothing is invented per initiative: every phase's text is the engine's own text for the rung it
37
- * belongs to.
38
- *
39
- * ── The one thing this file refuses to do ───────────────────────────────────────────────────
40
- * Linking an artifact records a DECLARATION (`{artifact_path, kind, target}` appended to
41
- * `artifact-links.jsonl`) and choosing a sync direction records another (`artifact-sync.jsonl`).
42
- * Neither makes an outbound request, because PMOS holds no credential: the request is made by an
43
- * agent session holding the PM's own MCP, and what comes back here is a report (D53).
44
- *
45
- * `state.connectors` used to be published as a literal `[]` on every load. That was written when it
46
- * was true of every machine, and it stayed after the server learned to DERIVE the answer from the
47
- * PM's agent profiles — so a careful derivation shipped into a client that had already decided. The
48
- * panel branches on it (`hasConnector`, `resolverFor`), so the visible cost was a control that never
49
- * rendered and a machine with a Jira MCP that reported having none. It is now published from the
50
- * payload, and the constant is gone rather than corrected: a constant cannot be wrong, which is
51
- * exactly why it could not be trusted.
52
- */
53
-
54
- import { state, setState, subscribe, FIXTURE } from './state.js';
55
- import { C } from './fixture.js';
56
- import { pressFetch } from './http.js';
57
-
58
- /* ── transport ──────────────────────────────────────────────────────────────────────────────
59
- * Relative URLs only. The server's origin/host allowlist 403s a page served from anywhere else,
60
- * so a relative path is both the simplest form and the only one that can work.
61
- */
62
-
63
- const q = (params) => Object.entries(params)
64
- .filter(([, v]) => v !== null && v !== undefined && v !== '')
65
- .map(([k, v]) => encodeURIComponent(k) + '=' + encodeURIComponent(v)).join('&');
66
-
67
- /** GET JSON. Resolves to `{ok:false,error}` on any transport failure — never throws at the caller. */
68
- async function getJson(path, params) {
69
- const url = params ? path + '?' + q(params) : path;
70
- let res;
71
- try { res = await fetch(url); }
72
- catch (e) { return { ok: false, error: 'could not reach the workspace server — ' + msg(e) }; }
73
- let body;
74
- try { body = await res.json(); }
75
- catch { return { ok: false, error: url + ' returned a body that is not JSON (HTTP ' + res.status + ')' }; }
76
- // The console family returns HTTP 200 even for {ok:false} — the body carries the reason. A
77
- // non-2xx with a JSON body is still that body's failure to report.
78
- if (!res.ok && body && body.ok !== false) return { ok: false, error: 'HTTP ' + res.status + ' from ' + url };
79
- return body;
80
- }
81
-
82
- async function postJson(path, body) {
83
- let res;
84
- try {
85
- res = await pressFetch(path, {
86
- method: 'POST', body: JSON.stringify(body), // pm/http.js: carries the per-launch nonce, and renews a stale one
87
- });
88
- } catch (e) { return { ok: false, error: 'could not reach the workspace server — ' + msg(e) }; }
89
- try { return await res.json(); }
90
- catch { return { ok: false, error: path + ' returned a body that is not JSON (HTTP ' + res.status + ')' }; }
91
- }
92
-
93
- const msg = (e) => (e && e.message ? e.message : String(e));
94
-
95
- /* ── the lane → phase model (PRD, "Tasks") ──────────────────────────────────────────────────
96
- * PHASES is the phase SET per lane, verbatim from the PRD. RUNGS maps each phase to the engine
97
- * rungs it folds. Every lane's mapping covers all twelve rungs exactly once — that is the property
98
- * that makes the fold lossless: no rung's evidence is dropped, and none is counted twice.
99
- */
100
-
101
- const PHASES = {
102
- feature: ['intake', 'spec', 'contract', 'build', 'eval', 'accepted'],
103
- discovery: ['intake', 'explore', 'synthesize', 'decide'],
104
- chore: ['intake', 'fix', 'verify'],
105
- incident: ['intake', 'contain', 'record', 'verify'],
106
- content: ['intake', 'draft', 'review', 'publish'],
107
- prototype: ['intake', 'specimens', 'grill', 'dispose'],
108
- };
109
-
110
- const RUNGS = {
111
- feature: {
112
- intake: ['route', 'anchor', 'prototype', 'understand', 'priors'],
113
- spec: ['spec'], contract: ['contract'], build: ['build', 'quality'],
114
- eval: ['review', 'explain'], accepted: ['accept', 'outcome'],
115
- },
116
- discovery: {
117
- intake: ['route', 'anchor', 'prototype', 'understand', 'priors', 'spec', 'contract'],
118
- explore: ['build', 'quality'], synthesize: ['review'], decide: ['explain', 'accept', 'outcome'],
119
- },
120
- chore: {
121
- intake: ['route', 'anchor', 'prototype', 'understand', 'priors', 'spec', 'contract'],
122
- fix: ['build', 'quality'], verify: ['review', 'explain', 'accept', 'outcome'],
123
- },
124
- incident: {
125
- intake: ['route', 'anchor', 'prototype', 'understand', 'priors'],
126
- contain: ['build', 'quality'], record: ['spec', 'contract', 'review'], verify: ['explain', 'accept', 'outcome'],
127
- },
128
- content: {
129
- intake: ['route', 'anchor', 'prototype', 'understand', 'priors'],
130
- draft: ['spec', 'contract', 'build', 'quality'], review: ['review'], publish: ['explain', 'accept', 'outcome'],
131
- },
132
- prototype: {
133
- intake: ['route', 'anchor', 'prototype', 'understand', 'priors', 'spec', 'contract'],
134
- specimens: ['build', 'quality'], grill: ['review', 'explain'], dispose: ['accept', 'outcome'],
135
- },
136
- };
137
-
138
- /* D68/D77 — the pm-artifacts profile's ladder: every document lane walks brief → draft → review →
139
- * approved (→ handed off). Keyed `pm:<lane>` because `discovery` and `chore` exist in BOTH profiles
140
- * with different ladders; the profile comes from the engine's own ladder row, never guessed.
141
- *
142
- * The lane NAMES and whether a lane hands off are not written here. They come from the server's
143
- * lane definitions (scripts/lane-defs.js, D77) through `setLaneDefs`, so a lane added to the
144
- * definitions has phases with no edit in this file. Before the first payload arrives, and for a
145
- * lane the server did not name, the phases are `pm:prd`'s — the profile's strictest. */
146
- let laneDefsFromServer = null;
147
- function buildPmLane(l, withHandoff) {
148
- PHASES['pm:' + l] = ['intake', 'brief', 'draft', 'review', 'approved'].concat(withHandoff ? ['handed off'] : []);
149
- RUNGS['pm:' + l] = Object.assign({ intake: ['route', 'anchor'], brief: ['brief'], draft: ['draft'], review: ['review'], approved: ['approved'] },
150
- withHandoff ? { 'handed off': ['handoff'] } : {});
151
- }
152
- buildPmLane('prd', true);
153
- /** Register the lane definitions the server sent with an initiative payload. */
154
- function setLaneDefs(defs) {
155
- if (!defs || typeof defs !== 'object') return;
156
- laneDefsFromServer = defs;
157
- for (const [l, d] of Object.entries(defs)) {
158
- if (Array.isArray(d.rungs)) buildPmLane(l, d.rungs.includes('handoff'));
159
- }
160
- }
161
- const laneOf = (lane, profile) => (profile === 'pm-artifacts'
162
- ? 'pm:' + (PHASES['pm:' + lane] ? lane : 'prd')
163
- : (PHASES[lane] ? lane : 'feature'));
164
-
165
- /**
166
- * The status a phase inherits from the rungs it folds.
167
- *
168
- * `na` and `unknown` are DECIDED BY NOBODY and are excluded from the roll-up rather than counted
169
- * as failures. `quality` is permanently `unknown` by the engine's own design — it never claims a
170
- * test result it did not run — so counting it as not-done would mean the build phase could never
171
- * read done on any initiative, forever. The engine's own `stage` derivation ignores it for exactly
172
- * this reason.
173
- *
174
- * A phase whose rungs carry NO evidence is `pending`, checked before anything else: a rung the
175
- * engine found nothing for must never roll up to `done`.
176
- */
177
- function phaseRungStatus(rungs) {
178
- if (!rungs.length) return 'pending';
179
- if (rungs.every((r) => !r.evidence)) return 'pending';
180
- if (rungs.some((r) => r.status === 'blocked')) return 'blocked';
181
- if (rungs.some((r) => r.status === 'current')) return 'current';
182
- // An outcome still waiting on its horizon is time, not unfinished work: it does not hold the phase open.
183
- const decided = rungs.filter((r) => r.status !== 'na' && r.status !== 'unknown' && !(r.key === 'outcome' && r.status === 'pending'));
184
- if (decided.length && decided.every((r) => r.status === 'done')) return 'done';
185
- return 'pending';
186
- }
187
-
188
- /** The rung that explains the phase: the blocker, else the current one, else the last with evidence. */
189
- function decidingRung(rungs) {
190
- return rungs.find((r) => r.status === 'blocked')
191
- || rungs.find((r) => r.status === 'current')
192
- || [...rungs].reverse().find((r) => r.evidence)
193
- || rungs[rungs.length - 1] || null;
194
- }
195
-
196
- /** The first repo-relative path inside an engine message, or null. Used for a step's `cmd`. */
197
- function pathIn(text) {
198
- const m = String(text || '').match(/\b(?:planning|prototype|workspace|okf|skills|build-skills)\/[\w./-]+\.\w+/);
199
- return m ? m[0] : null;
200
- }
201
-
202
- /** The `steps[]` panel 3 reads: one entry per lane phase, carrying the folded rungs' evidence. */
203
- function phaseSteps(lane, ladderSteps, profile) {
204
- const L = laneOf(lane, profile);
205
- const by = {};
206
- for (const s of ladderSteps || []) by[s.key] = s;
207
- return PHASES[L].map((phase) => {
208
- const rungs = (RUNGS[L][phase] || []).map((k) => by[k]).filter(Boolean);
209
- const lead = decidingRung(rungs) || {};
210
- return {
211
- k: phase,
212
- s: phaseRungStatus(rungs),
213
- t: lead.evidence || '',
214
- action: lead.next || null,
215
- cmd: pathIn(lead.next) || pathIn(lead.evidence) || null,
216
- };
217
- });
218
- }
219
-
220
- /* ── record derivation ──────────────────────────────────────────────────────────────────────── */
221
-
222
- /**
223
- * overhaul-r2 B3/B4 — where the initiative belongs: Domain › Objective › KR › Project, from the
224
- * resolver's SEPARATE fields (never parsed out of `reason`). A missing level is stated, not blank:
225
- * a domain anchor has no OKR and says so; a health anchor is upkeep. `line` is the KR's own
226
- * baseline → target text when the OKR document writes one — the measure the KR moves.
227
- */
228
- function crumbFor(anchor, fm) {
229
- if (!anchor) return null;
230
- const parts = [];
231
- const dom = (fm && fm.domain) || (anchor.kind === 'domain' ? 'domain:' + anchor.domain : null);
232
- if (dom) parts.push({ k: 'domain', v: String(dom).replace(/^domain:/, '') });
233
- if (anchor.kind === 'domain') parts.push({ k: 'objective', v: '(no OKR)', gap: true });
234
- else if (anchor.kind === 'health') parts.push({ k: 'budget', v: 'health:' + anchor.budget + ' — upkeep, not a bet' });
235
- else if (anchor.kind === 'okr') {
236
- parts.push({ k: 'objective', v: anchor.objective_name || anchor.objective || '(unresolved)', gap: !anchor.objective_name });
237
- if (anchor.kr) parts.push({ k: 'KR', v: anchor.kr_name || anchor.kr, gap: !anchor.kr_name });
238
- else parts.push({ k: 'KR', v: '(objective-level — no KR written)', gap: true });
239
- } else parts.push({ k: 'anchor', v: '(none — rejected under D59)', gap: true });
240
- if (fm && fm.project) parts.push({ k: 'project', v: String(fm.project) });
241
- return { parts, goal: anchor.kind === 'domain' ? anchor.domain_goal || null : null, line: anchor.kr_line || null };
242
- }
243
-
244
- /** The `pills` row: lane, then the resolved anchor or an honest rejection, then a declared flow. */
245
- function pillsFor({ lane, anchor, flow }) {
246
- const out = [];
247
- if (lane) out.push({ t: lane, c: C.pur });
248
- if (anchor && anchor.canonical) out.push({ t: anchor.canonical, c: C.mut });
249
- else if (anchor && anchor.status === 'unknown') out.push({ t: 'anchor unread', c: C.wrn });
250
- else out.push({ t: 'unanchored', c: C.wrn });
251
- // The `flow` pill ships only when the record declares one. No record in this repository does, and
252
- // inventing `adlc-feature` to fill the slot would be stating a workflow that was never chosen.
253
- if (flow) out.push({ t: 'flow ' + flow, c: C.inf });
254
- return out;
255
- }
256
-
257
- /**
258
- * The footer tuple `[stage, note, colour]` and the dot beside every row in panel 2. `stage` is the
259
- * engine's, never a `status:` string — there is no stage field to read (D64/the record README) and
260
- * a status nobody maintains is a board that lies.
261
- */
262
- function l2For(row) {
263
- if (!row) return ['—', 'ladder not derived yet', C.mut];
264
- const blockers = (row.blockers || []).length;
265
- if (row.accepted) return [row.stage || 'accepted', 'accepted', C.suc];
266
- if (blockers) return [row.stage || '—', '✗ ' + blockers + ' blocked', C.des];
267
- if (row.next) return [row.stage || '—', '→ ' + row.next.step + ' owed', C.wrn];
268
- return [row.stage || '—', 'no next step recorded', C.mut];
269
- }
270
-
271
- /** The `answer` banner — the engine's own `next`, with a tone derived from the blockers. */
272
- function answerFor(row) {
273
- if (!row) return null;
274
- if (!row.next) {
275
- return row.accepted
276
- ? { tone: 'ok', text: 'accepted — the ladder is complete.' }
277
- : { tone: 'info', text: 'the engine reports no next step for this initiative.' };
278
- }
279
- return {
280
- tone: (row.blockers || []).length ? 'bad' : 'warn',
281
- text: row.next.action || row.next.why || '',
282
- };
283
- }
284
-
285
- /**
286
- * The status-from-artifacts lines, derived by the engine (scripts/status-facts.js) and only worded
287
- * here. Each is a flag beside the ladder with its basis. None is a step: nothing here changes a
288
- * phase, a dot or a count, and a check that could not run says so instead of staying silent.
289
- */
290
- function factsFor(row) {
291
- if (!row) return [];
292
- const out = [];
293
- const sa = row.since_approval;
294
- if (sa) {
295
- if (sa.status === 'unknown') out.push({ tone: 'info', label: 'Since approval', text: 'Cannot tell. ' + (sa.reason || '') });
296
- else {
297
- for (const a of sa.approvals || []) {
298
- const what = a.kind === 'contract' ? 'the contract was approved' : 'you accepted it';
299
- if (a.status === 'unknown') out.push({ tone: 'info', label: 'Since approval', text: 'Cannot tell for ' + what + '. ' + (a.reason || '') });
300
- else if (!(a.changed || []).length) out.push({ tone: 'ok', label: 'Since approval', text: (row.profile === 'pm-artifacts' ? 'No brief or deliverable' : 'No spec file') + ' changed after ' + what + '.' });
301
- else {
302
- const files = [...new Set(a.changed.map((x) => x.file.split('/').pop()))].join(', ');
303
- const last = a.changed[a.changed.length - 1];
304
- out.push({ tone: 'warn', label: 'Since approval', text: files + ' changed after ' + what + ' (' + a.changed_total + ' commit' + (a.changed_total === 1 ? '' : 's') + ', latest ' + last.sha + (last.date ? ' on ' + last.date : '') + ').' });
305
- }
306
- }
307
- }
308
- }
309
- const cv = row.coverage;
310
- if (cv) {
311
- if (cv.status === 'unknown') out.push({ tone: 'info', label: 'Coverage', text: 'Cannot tell. ' + (cv.reason || '') });
312
- else if (!cv.uncited.length && !cv.orphan_citations.length) out.push({ tone: 'ok', label: 'Coverage', text: 'The rubric cites all ' + cv.requirements + ' requirement ids.' });
313
- else {
314
- const bits = [];
315
- if (cv.uncited.length) bits.push(cv.uncited.join(', ') + ' not cited in the rubric');
316
- if (cv.orphan_citations.length) bits.push(cv.orphan_citations.join(', ') + ' cited but not in the PRD');
317
- out.push({ tone: 'warn', label: 'Coverage', text: bits.join('; ') + '. A citation is not a grade.' });
318
- }
319
- }
320
- if (row.record_says) out.push({ tone: 'warn', label: 'Record says', text: 'The status line ' + row.record_says.reason + '. The ladder is not changed.' });
321
- return out;
322
- }
323
-
324
- /**
325
- * D83 — what Jev suggests about the documents tied to this initiative. A suggestion, in words, with the model that
326
- * gave it. It is never a step: it is listed after the facts and nothing reads it to colour a phase.
327
- */
328
- function suggestionLines(sg) {
329
- if (!sg) return [];
330
- if (sg.ok === false) return [{ tone: 'info', label: 'Documents suggest', text: 'Cannot tell. ' + (sg.reason || '') }];
331
- return (sg.items || []).map((x) => ({ tone: 'info', label: 'Documents suggest', text: (x.sentence || (x.doc + ': ' + x.kind)) + ' A suggestion, not a check' + (x.model ? ' (' + x.model + ')' : '') + '.' }));
332
- }
333
-
334
- /**
335
- * Why "What the documents say" has no line yet, in words, so an empty section is never mistaken for a missing one. Each
336
- * check names what it waits for. Null when there is no ladder (the panel says that elsewhere) or when a line exists.
337
- */
338
- function factsWhy(row, lines) {
339
- if (!row || (lines && lines.length)) return null;
340
- const why = [];
341
- if (row.profile === 'pm-artifacts') {
342
- why.push('Since approval starts when you accept this work: after that, a commit to its brief or deliverable shows here.');
343
- } else {
344
- why.push('Since approval starts when a contract is approved or the work is accepted.');
345
- if (row.lane !== 'feature') why.push('Coverage is for feature-lane initiatives, and this one is ' + (row.lane || 'not in a lane') + '.');
346
- else why.push('Coverage needs both a PRD and a rubric named in the record.');
347
- why.push('Record says checks a status line that starts with a stage word (intake, spec, contract, build, eval or accepted).');
348
- }
349
- why.push('Jev suggestions appear only when "read documents for status" is on in Validate.');
350
- return 'Nothing to compare yet. ' + why.join(' ');
351
- }
352
-
353
- /** The Review-Gate line, read off the `review` rung — no verdict is not a pass. */
354
- function evalFor(ladderSteps) {
355
- const r = (ladderSteps || []).find((s) => s.key === 'review');
356
- if (!r || r.status !== 'done' || !r.evidence) return null;
357
- return { pass: /^PASS/i.test(r.evidence), text: r.evidence };
358
- }
359
-
360
- /** A live session, in the shape panel 2 and panel 4 read. `shown` is the server's own derived state. */
361
- function sessionRow(s) {
362
- // `s.label` is the SERVER's rendering of the presented state — one join (lib/session-state's
363
- // `label`), one clock, one sentence. This used to be re-derived here from `shown` + `quietMs`,
364
- // which is how the sidebar and the pane could describe one session with two different words. The
365
- // local derivation survives only as a fallback for a server that predates the field.
366
- const label = s.label || (s.shown === 'quiet' && Number.isFinite(s.quietMs)
367
- ? 'quiet ' + Math.max(1, Math.round(s.quietMs / 60000)) + 'm'
368
- : (s.shown === 'needs' ? 'needs you' : s.shown));
369
- return { name: s.name, st: s.shown, label, profile: s.profile_id || null, id: s.id };
370
- }
371
-
372
- /**
373
- * External references. Two sources, both declarations and neither a reading: the record's own
374
- * `handoff_*` frontmatter (parsed by lib/handoff.js, whose `connected` is the literal false on
375
- * every path it has), and the rows the PM added by hand into `initiative-links.jsonl`.
376
- */
377
- function linksFor(payload) {
378
- const out = [];
379
- const h = payload.links && payload.links.links;
380
- for (const l of h || []) {
381
- out.push({ kind: l.kind, label: l.declared, path: l.href || l.declared, st: l.state_text || l.state });
382
- }
383
- for (const r of (payload.declarations && payload.declarations.links) || []) {
384
- // The row's OWN provenance, carried rather than replaced. `declared · not connected` was a
385
- // literal written before the store had a state vocabulary, and it outlived it: a reference a
386
- // session had genuinely resolved rendered the same seven words as one the PM had typed a second
387
- // earlier. The panel derives its state text from these fields (`linkStateText`), so carrying
388
- // them is the whole fix — there is no second opinion to keep in step.
389
- out.push({
390
- kind: r.kind, label: r.label, path: r.target,
391
- state: r.state, origin: r.origin, profile: r.profile || null,
392
- reason: r.reason || null, resolved_at: r.resolved_at || null,
393
- });
394
- }
395
- return out;
396
- }
397
-
398
- /** Artifacts, with any declared external destination and the latest sync for it attached. */
399
- function artsFor(payload) {
400
- const dest = new Map();
401
- for (const r of (payload.declarations && payload.declarations.artifacts) || []) {
402
- // The server has already collapsed the store to one row per pair and dropped what the PM
403
- // retracted, so what arrives here is the statement of now.
404
- dest.set(r.artifact_path, { kind: r.kind, target: r.target, state: r.state, origin: r.origin });
405
- }
406
- const sync = new Map();
407
- for (const r of (payload.declarations && payload.declarations.sync) || []) {
408
- sync.set(r.artifact_path + '|' + r.kind, r);
409
- }
410
- return (payload.artifacts || []).map((a) => {
411
- // A row in the store, else the destination the FILE declares about itself (server.js
412
- // `frontmatterDest`, gated by `withFrontmatterDest` — the server has already decided which of
413
- // the two the panel is allowed to see, including for an artifact whose link the PM retracted).
414
- // This used to return `{role, path}` here and drop `a.dest` on the floor, even though
415
- // `artifactRow` reads it as its fallback: the reader existed and the producer did not.
416
- const d = dest.get(a.path) || a.dest || null;
417
- if (!d) return { role: a.role, path: a.path };
418
- return { role: a.role, path: a.path, dest: d, sync: sync.get(a.path + '|' + d.kind) || null };
419
- });
420
- }
421
-
422
- /** The rung that blocks the initiative, as the card draws it: the engine's label, evidence and next step. Null when none blocks. */
423
- function blockerOf(row) {
424
- const s = row && Array.isArray(row.steps) ? row.steps.find((x) => x && x.blocking === true && x.status === 'blocked') : null;
425
- return s ? { key: s.key, label: s.label || s.key, evidence: s.evidence || '', next: s.next || '' } : null;
426
- }
427
-
428
- /** The full record panel 3 renders, from one `/api/initiative` payload. */
429
- function recordFrom(payload) {
430
- if (!payload || payload.ok === false) {
431
- const error = (payload && payload.error) || 'the initiative could not be read';
432
- return { readError: error, l2: ['read failed', error.slice(0, 60), C.des] };
433
- }
434
- const fm = payload.frontmatter || {};
435
- if (payload.lanes && payload.lanes.defs) setLaneDefs(payload.lanes.defs);
436
- const row = (payload.ladder && payload.ladder.ok && payload.ladder.row) || null;
437
- const scope = (payload.ladder && payload.ladder.scope) || null;
438
- const lane = fm.lane || (row && row.lane) || null;
439
- const steps = row ? phaseSteps(lane, row.steps, row.profile) : [];
440
- const laneDef = (payload.lanes && payload.lanes.defs && lane && payload.lanes.defs[lane]) || null;
441
- const rec = {
442
- tag: fm.title || (row && row.title) || '',
443
- // the lane this record declares, and the lanes this repository allows — what the header's lane picker offers
444
- lane: lane || null,
445
- lanes: payload.lanes && Array.isArray(payload.lanes.lanes) ? payload.lanes.lanes : null,
446
- laneDefs: (payload.lanes && payload.lanes.defs) || null,
447
- laneDef,
448
- stage: row ? row.stage : null,
449
- flow: fm.flow || null,
450
- pills: pillsFor({ lane, anchor: payload.anchor, flow: fm.flow || null }),
451
- crumb: crumbFor(payload.anchor, fm),
452
- // What the ladder was DERIVED ON, which is exactly what the footer sentence claims.
453
- branch: scope ? scope.branch : null,
454
- answer: answerFor(row),
455
- steps,
456
- sessions: (payload.sessions || []).map(sessionRow),
457
- links: linksFor(payload),
458
- arts: artsFor(payload),
459
- // R4/R5/R6 — what remains to acceptance, the conversations that belong to it, and the files git says
460
- // were changed for it. Each arrives already derived by the server; this layer only carries them.
461
- // workspace-cockpit-nav R2: the first rung the ladder says is blocking, or null. Nothing is invented — the words are the engine's.
462
- blocker: blockerOf(row),
463
- nextSteps: payload.next_steps || null,
464
- lcHistory: payload.lifecycle_history || [],
465
- convs: Array.isArray(payload.conversations) ? payload.conversations : [],
466
- gitFiles: payload.files || null,
467
- eval: evalFor(row && row.steps),
468
- facts: factsFor(row).concat(suggestionLines(payload.suggestions)),
469
- factsWhy: factsWhy(row, factsFor(row).concat(suggestionLines(payload.suggestions))),
470
- l2: l2For(row),
471
- };
472
- if (!row) {
473
- rec.noLadder = payload.absent
474
- ? 'No initiative record on this board — the artifacts below are what the library can see; no loop position is claimed.'
475
- : 'No loop position could be derived for this initiative.';
476
- if (!rec.answer) {
477
- rec.answer = { tone: 'warn', text: 'File an initiative record — artifacts exist, but no loop position is claimed.' };
478
- }
479
- rec.pills = payload.absent ? [{ t: 'no record', c: C.wrn }] : rec.pills;
480
- rec.l2 = payload.absent ? ['—', 'no record', C.wrn] : rec.l2;
481
- }
482
- if (!rec.sessions.length) {
483
- rec.noSess = (payload.session_trees || []).length
484
- ? 'No sessions on this initiative — normal, not an error.'
485
- : 'No working tree is on initiative/' + payload.id + ' — a normal state.';
486
- }
487
- return rec;
488
- }
489
-
490
- /* ── the board (panel 2), from the spine + the library ──────────────────────────────────────── */
491
-
492
- /** A LIGHT record: everything the board can show without deriving a ladder per initiative. */
493
- function lightRecord(rec, artifacts) {
494
- return {
495
- tag: rec.title || '',
496
- stage: null,
497
- flow: null,
498
- pills: pillsFor({ lane: rec.lane, anchor: rec.anchorHint || null, flow: null }),
499
- branch: null,
500
- answer: null,
501
- steps: [],
502
- sessions: [],
503
- links: [],
504
- arts: (artifacts || []).map((a) => ({ role: a.role, path: a.path })),
505
- eval: null,
506
- // Not "todo" and not "done": the ladder for this initiative has not been derived. Deriving all
507
- // of them costs one `git log` per record — ~30 s on this repository — and a board that froze
508
- // the PM's terminals to colour its dots would be a worse answer than a grey one.
509
- l2: ['—', 'ladder not derived yet — open it to derive', C.mut],
510
- lite: true,
511
- };
512
- }
513
-
514
- /**
515
- * Fold `/api/console?name=spine` into the board's groups.
516
- *
517
- * A group is one Objective+KR pair, which is the prototype's own model (one group, one optional KR
518
- * sub-row). Its `gid` therefore carries BOTH ids: the collapse key in panel 2 is `product|gid`, so
519
- * three groups all calling themselves `O1` would fold and unfold as one.
520
- */
521
- function groupsFromSpine(spine) {
522
- const groups = [];
523
- for (const o of spine.objectives || []) {
524
- const total = (o.krs || []).reduce((n, k) => n + k.initiatives.length, 0) + ((o.direct || []).length);
525
- for (const kr of o.krs || []) {
526
- if (!kr.initiatives.length) continue;
527
- groups.push({
528
- gid: o.id + '/' + kr.id, idc: C.fg, gname: o.name, gct: String(total),
529
- hasKr: true, krid: kr.id, krname: kr.name,
530
- krct: String(kr.initiatives.length),
531
- slugs: kr.initiatives.map((i) => i.id),
532
- });
533
- }
534
- if ((o.direct || []).length) {
535
- groups.push({
536
- gid: o.id, idc: C.fg, gname: o.name, gct: String(total), hasKr: false,
537
- slugs: o.direct.map((i) => i.id),
538
- });
539
- }
540
- }
541
- for (const b of spine.budgets || []) {
542
- groups.push({
543
- gid: b.id, idc: C.inf, gname: 'health budget — upkeep, not a bet',
544
- gct: String(b.initiatives.length), hasKr: false, slugs: b.initiatives.map((i) => i.id),
545
- });
546
- }
547
- // D67: a domain group — work that serves the domain's standing goal with no OKR, said plainly
548
- for (const d of spine.domains || []) {
549
- groups.push({
550
- gid: d.id, idc: C.fg, gname: 'domain — no OKR' + (d.goal ? ' · ' + d.goal : ''),
551
- gct: String(d.initiatives.length), hasKr: false, slugs: d.initiatives.map((i) => i.id),
552
- });
553
- }
554
- // D59: rejected work is FILED, never hidden. It is the last group and it says what it is.
555
- groups.push({
556
- gid: 'unanchored', dyn: true, idc: C.wrn,
557
- gname: 'no resolvable anchor — rejected work under D59',
558
- gct: String((spine.unanchored || []).length), hasKr: false,
559
- slugs: (spine.unanchored || []).map((i) => i.id),
560
- });
561
- return groups;
562
- }
563
-
564
- /* ── the workspace registry ─────────────────────────────────────────────────────────────────── */
565
-
566
- const products = new Map(); // product name → {name, ws, root, count, board, records}
567
- let productOrder = [];
568
-
569
- /* workspace id → the working-tree top it sits in (null for a folder with no git).
570
- *
571
- * This exists so panel 4 can answer "who else is already in the tree I am about to start a session
572
- * in?" BEFORE it starts one. The session rows carry `tree` too, but only for trees that already
573
- * have a session — which is one session too late for a chooser that runs on the FIRST click. The
574
- * server derives this (`git rev-parse --show-toplevel`, via `repoIdentity`) and publishes it on
575
- * /api/workspaces; it is read here and never re-derived. */
576
- const wsTree = new Map();
577
-
578
- /** The working tree a workspace id sits in, or null — for a folder with no git, or an unknown id. */
579
- export function treeOfWorkspace(id) {
580
- return (id && wsTree.get(id)) || null;
581
- }
582
-
583
- /** The branch that tree is on, or null. Shown beside the tree so a chooser names what is shared. */
584
- const wsBranch = new Map();
585
- export function branchOfWorkspace(id) {
586
- return (id && wsBranch.get(id)) || null;
587
- }
588
-
589
- /**
590
- * The same map as a plain object, for `setState`.
591
- *
592
- * `branchOfWorkspace` answers "what branch is THIS workspace on?", which is all the + session
593
- * chooser ever needed. The initiative board asks the other direction — "which initiatives does this
594
- * machine have a checkout for, and which of my live sessions is on one?" — and a lookup by id
595
- * cannot be enumerated.
596
- *
597
- * It is PUBLISHED rather than exported as a getter for the reason `productWs` is: a panel that has
598
- * to import the data layer to render a row cannot render that row until the import resolves, and
599
- * panel 2 is the board. Published, the fact arrives in the same patch as everything else the panel
600
- * reads, and the panel needs no adapter at all.
601
- *
602
- * `wsBranch` stays the single source — this is a projection of it taken at publish time, not a
603
- * second copy anything writes to. Nulls are kept out: a folder with no git has no branch, and a map
604
- * carrying holes would make every reader re-check the same thing.
605
- */
606
- function branchMap() {
607
- const out = {};
608
- for (const [id, b] of wsBranch) if (typeof b === 'string' && b) out[id] = b;
609
- return out;
610
- }
611
-
612
- /** Group registered working trees into products: several worktrees of one repo share a `repo_key`. */
613
- function foldWorkspaces(rows) {
614
- const byRepo = new Map();
615
- for (const w of rows || []) {
616
- // Recorded per REGISTERED id, before the fold — folding is by repository, and the whole point
617
- // of the tree key is that two registered ids can share one tree while a repo's two worktrees do
618
- // not. Reading it off the folded row would lose exactly that distinction.
619
- if (w && w.id) { wsTree.set(w.id, w.tree || null); wsBranch.set(w.id, w.branch || null); }
620
- const key = w.repo_key || w.root;
621
- if (!byRepo.has(key)) {
622
- byRepo.set(key, {
623
- name: w.label || w.repo_name || w.name, ws: w.id, root: w.root, trees: [],
624
- // The server derived this from the tree's `origin` remote (git-info.originUrl). It is read
625
- // here and never re-derived: a second opinion about what a repository IS would be a second
626
- // thing to keep true, and this one is the one that did the read.
627
- kind: w.kind === 'github' ? 'github' : 'local', remote: w.remote || null,
628
- laneSets: w.lane_sets || null,
629
- });
630
- }
631
- const p = byRepo.get(key);
632
- p.trees.push(w);
633
- // The main worktree is the product's identity; prefer its id for reads scoped to `ws` — and its
634
- // remote, since a linked worktree of the same repo answers with the same origin anyway.
635
- if (w.root === key) {
636
- p.ws = w.id;
637
- // the PM's own name for the repository (overhaul-r1 R3.1) lives on the main tree's row
638
- if (w.label) p.name = w.label;
639
- p.initials = w.initials || null;
640
- p.profile = w.profile === 'pm-artifacts' ? 'pm-artifacts' : 'product-code';
641
- p.kind = w.kind === 'github' ? 'github' : 'local';
642
- p.remote = w.remote || null;
643
- }
644
- }
645
- // Two distinct repositories can share a basename. Disambiguating with the parent directory keeps
646
- // both rows on the board rather than silently merging one into the other.
647
- const seen = new Map();
648
- const out = [];
649
- for (const p of byRepo.values()) {
650
- let name = p.name;
651
- if (seen.has(name)) {
652
- const parent = String(p.root).split('/').slice(-2, -1)[0] || '';
653
- name = parent ? parent + '/' + name : name + ' (' + p.ws + ')';
654
- }
655
- seen.set(p.name, true);
656
- out.push({ ...p, name });
657
- }
658
- return out;
659
- }
660
-
661
- /** Load one product's board: the spine (structure) joined with the library (artifacts). */
662
- async function loadBoard(prod) {
663
- const [spine, lib, surf] = await Promise.all([
664
- getJson('/api/console', { name: 'spine', ws: prod.ws }),
665
- getJson('/api/library', { ws: prod.ws }),
666
- // The DERIVED status of every initiative (server.js deriveState + the lifecycle ledger) — what "group by
667
- // status" reads. A failed read is kept as a reason, never as an empty map: an empty map would file every
668
- // initiative under Unknown without saying why.
669
- getJson('/api/surface', { name: 'initiatives', ws: prod.ws }),
670
- ]);
671
- {
672
- const items = (surf && surf.ok !== false && ((surf.surface && surf.surface.initiatives) || surf.initiatives)) || null;
673
- prod.statuses = {};
674
- if (items) {
675
- for (const i of items) if (i && i.id) prod.statuses[i.id] = { status: i.status, statusText: i.statusText || '', lifecycle: i.lifecycle || null };
676
- prod.statusError = null;
677
- } else {
678
- prod.statusError = (surf && surf.error) || 'the derived status of the initiatives could not be read';
679
- }
680
- }
681
- if (spine.ok === false) {
682
- prod.error = spine.error || 'the initiative spine could not be read';
683
- prod.board = [];
684
- prod.records = {};
685
- prod.count = null;
686
- return prod;
687
- }
688
- const artsById = new Map();
689
- for (const i of (lib && lib.initiatives) || []) artsById.set(i.id, i.artifacts || []);
690
-
691
- const groups = groupsFromSpine(spine);
692
- const records = {};
693
- const note = (rec, anchorHint) => {
694
- records[rec.id] = lightRecord({ ...rec, anchorHint }, artsById.get(rec.id));
695
- };
696
- for (const o of spine.objectives || []) {
697
- for (const kr of o.krs || []) for (const r of kr.initiatives) note(r, { canonical: o.key + '/' + kr.key });
698
- for (const r of o.direct || []) note(r, { canonical: o.key });
699
- }
700
- for (const b of spine.budgets || []) for (const r of b.initiatives) note(r, { canonical: b.id });
701
- for (const d of spine.domains || []) for (const r of d.initiatives) note(r, { canonical: d.id });
702
- for (const r of spine.unanchored || []) note(r, null);
703
-
704
- // The library can see initiatives the SPINE has no record for: artifacts that group into a unit
705
- // with no `planning/initiatives/<id>.md` behind them. They get their own group rather than being
706
- // folded into `unanchored`, because the two are different facts and the panel says different
707
- // things about them — "this record declares no resolvable anchor" (rejected under D59) is not
708
- // "there is no record at all" (real files, no loop position claimed). Dropping them was never an
709
- // option: they are documents that exist.
710
- // Counted BEFORE the orphans are merged in — see `prod.count` below.
711
- const spineCount = Object.keys(records).length;
712
- const known = new Set(Object.keys(records));
713
- const orphans = [...artsById.keys()].filter((id) => !known.has(id)).sort();
714
- if (orphans.length) {
715
- groups.push({
716
- gid: 'no record', dyn: true, idc: C.wrn,
717
- gname: 'artifacts with no initiative record — no loop position is claimed',
718
- gct: String(orphans.length), hasKr: false, slugs: orphans,
719
- });
720
- for (const id of orphans) {
721
- records[id] = {
722
- ...lightRecord({ id, title: '', lane: null }, artsById.get(id)),
723
- pills: [{ t: 'no record', c: C.wrn }],
724
- l2: ['—', 'no record', C.wrn],
725
- };
726
- }
727
- }
728
-
729
- prod.error = null;
730
- prod.board = groups;
731
- prod.records = records;
732
- // THE COUNT ON PANEL 1 IS THE SPINE'S, NOT THE RECORD MAP'S. `records` deliberately holds two
733
- // different populations — the initiatives the spine placed, and the orphan groups above, which
734
- // the very next panel labels "artifacts with no initiative record — no loop position is claimed".
735
- // Sizing the row off the merged map made panel 1 read `176 initiatives` on a repository holding
736
- // 138 placed records and 38 orphans: two numbers on one screen disagreeing, with the headline one
737
- // inflated by 27% with items the app itself refuses to call initiatives. Panel 2 still shows the
738
- // orphans, under their own honest heading; the row counts what it says it counts.
739
- prod.count = spineCount;
740
- prod.unrecorded = orphans.length;
741
- return prod;
742
- }
743
-
744
- /** Publish every loaded product's board and records into state, in one patch. */
745
- function publishBoards() {
746
- const board = {};
747
- /* Product NAME → workspace id, for every registered repository — not only the selected one.
748
- * panel 4 keeps every open terminal live, including those belonging to a repository the PM is not
749
- * currently looking at, and a parked tab's session must be resolved inside ITS OWN repository.
750
- * Scoping it by the selected workspace is how a tab in one repo attached to a shell in another
751
- * (tab-term.js `wsForTab`). */
752
- const productWs = {};
753
- const statuses = {}; const statusErrors = {};
754
- let records = {};
755
- for (const name of productOrder) {
756
- const p = products.get(name);
757
- if (!p) continue;
758
- if (p.ws) productWs[name] = p.ws;
759
- if (!p.board) continue;
760
- board[name] = p.board;
761
- statuses[name] = p.statuses || {}; if (p.statusError) statusErrors[name] = p.statusError;
762
- records = { ...records, ...p.records };
763
- }
764
- // `wsBranches` rides the same patch as `productWs` and for the same reason: it is a fact about
765
- // every registered working tree, read once from /api/workspaces, that a panel needs in order to
766
- // draw a row. panel 2 joins it against `state.sessions` to say which initiative each live agent is
767
- // on — the same `initiative/<id>` join lib/four-panel.js makes per initiative on the server.
768
- setState({ board, statuses, statusErrors, productWs, wsBranches: branchMap(), records: { ...records, ...(hydrated) } });
769
- }
770
-
771
- /* Hydrated (fully derived) records live apart from the light ones so that a board reload cannot
772
- * silently downgrade the initiative the PM is looking at back to its light form. */
773
- const hydrated = Object.create(null);
774
-
775
- /* ── hydration: one initiative, fully derived ───────────────────────────────────────────────── */
776
-
777
- const inFlight = new Set();
778
-
779
- /* THE READ CLOCK, and why it lives here rather than in the renderer.
780
- *
781
- * Panel 3's footer says "derived on <branch> · as of <time>". That line's whole job is provenance:
782
- * WHEN was what you are looking at read. It was first shipped as the design's literal `12:41:03` —
783
- * a time at which nothing ever happened — and then fixed by calling the clock inside `footer()`,
784
- * which measured the RENDER instead. The panel re-renders on any state change (a session poll, a
785
- * theme toggle, a tab opening), while `hydrate` runs once per slug per page life — so the line
786
- * advanced, untouched data underneath it, and read `as of 17:11:57` over a payload fetched twenty
787
- * seconds earlier. A true measurement of the wrong event is still a false claim.
788
- *
789
- * So the stamp is taken HERE, at the instant the payload lands, and carried on the record. The
790
- * renderer prints what it is given and owns no clock. */
791
- function readStamp() {
792
- const d = new Date();
793
- const p = (n) => String(n).padStart(2, '0');
794
- return `${p(d.getHours())}:${p(d.getMinutes())}:${p(d.getSeconds())}`;
795
- }
796
-
797
- /** Change an existing initiative's lane (the ladder re-derives from it), then re-read the record and its board. */
798
- export async function setInitiativeLane(slug, lane) {
799
- if (FIXTURE) return { ok: false, error: 'fixture mode has no records to edit' };
800
- const prod = products.get(currentProductName());
801
- const out = await postJson('/api/initiative/lane', { ws: prod ? prod.ws : null, id: slug, lane });
802
- if (out && out.ok && out.changed !== false) {
803
- delete hydrated[slug];
804
- await hydrate(slug);
805
- if (prod) { try { await loadBoard(prod); publishBoards(); } catch { /* the record read above already shows the new ladder */ } }
806
- }
807
- return out || { ok: false, error: 'the workspace server did not answer' };
808
- }
809
-
810
- async function hydrate(slug) {
811
- if (FIXTURE || !slug || inFlight.has(slug)) return null;
812
- const prod = products.get(currentProductName());
813
- const ws = prod ? prod.ws : null;
814
- inFlight.add(slug);
815
- try {
816
- const payload = await getJson('/api/initiative', { id: slug, ws });
817
- // Stamped after the await, on the line that follows the read — a failed read is still a read,
818
- // and its footer ("read failed · as of …") is entitled to say when it was attempted.
819
- const asOf = readStamp();
820
- hydrated[slug] = { ...recordFrom(payload), asOf };
821
- setState((s) => ({
822
- records: { ...s.records, [slug]: hydrated[slug] },
823
- // The server's `{configured:[{kind, profile, server, declared}], declaredBy, note}`, straight
824
- // through. Published on every hydration rather than once at boot, because a profile added
825
- // while the workspace is open should reach the panel on the next selection rather than on the
826
- // next restart — and because the payload is the only place this fact is ever produced.
827
- connectors: payload && payload.connectors ? payload.connectors : s.connectors,
828
- }));
829
- return payload;
830
- } finally { inFlight.delete(slug); }
831
- }
832
-
833
- function currentProductName() {
834
- if (state.product && products.has(state.product)) return state.product;
835
- return productOrder[0] || null;
836
- }
837
-
838
- /* ── sessions ───────────────────────────────────────────────────────────────────────────────
839
- * Polled rather than pushed. The WebSocket that carries `sessions` frames belongs to panel 4's
840
- * terminal module, which owns the attach/input protocol; opening a SECOND socket here to read a
841
- * list would put two connections on the same server for one fact. A 4 s poll of a local endpoint
842
- * is cheaper than the duplicate protocol and cannot disagree with itself.
843
- */
844
-
845
- let pollTimer = null;
846
- let sessionDigest = null;
847
-
848
- /* pm-os-absorb Run 1 — the plan-items signatures. An open Breakdown watches its workspace; the poll then asks for that
849
- * workspace's `evidence` signature too, and `pmos:ledgers` tells every listener which workspaces' signatures moved. */
850
- const ledgerWatch = new Map(); // ws id -> how many open Breakdowns watch it
851
- let lastLedgers = null; // null until the first poll: its signatures are the baseline, not a change
852
- export function watchLedgers(wsId) {
853
- if (!wsId) return () => {};
854
- ledgerWatch.set(wsId, (ledgerWatch.get(wsId) || 0) + 1);
855
- let done = false;
856
- return () => {
857
- if (done) return;
858
- done = true;
859
- const n = (ledgerWatch.get(wsId) || 1) - 1;
860
- if (n > 0) ledgerWatch.set(wsId, n); else ledgerWatch.delete(wsId);
861
- };
862
- }
863
-
864
- /**
865
- * WHAT THE SURFACE ACTUALLY RENDERS from a session row, as one string.
866
- *
867
- * Every `setState` repaints all four panels, and panel 2 rebuilds a board that is 138 initiatives
868
- * deep on this repository. Publishing the poll unconditionally therefore tore down and rebuilt the
869
- * whole window every four seconds, forever, whether or not anything had changed — which is a
870
- * hundreds-of-milliseconds stall on the main thread, on a cadence, next to a terminal the PM is
871
- * typing into. That is the jitter: input queued behind a repaint nobody asked for.
872
- *
873
- * The rows themselves change constantly (`lastOutputAt` moves with every byte an agent writes), so
874
- * comparing the payload is useless. What is compared is the PROJECTION the panels read — id, name,
875
- * workspace, derived state, the quiet reading ROUNDED THE WAY THE LABEL ROUNDS IT (minutes), and
876
- * the fields the sidebar prints. A working agent produces an identical projection minute after
877
- * minute, so the window stays still while it works, and repaints the moment something it shows
878
- * actually moves.
879
- */
880
- function sessionProjection(rows) {
881
- return (rows || []).map((s) => [
882
- s.id, s.ws, s.name, s.agent, s.state, s.shown, s.note || '', s.cwd || '',
883
- s.profile_id || '', s.profile_line || '', s.model_line || '',
884
- // the label's own resolution, not the millisecond behind it
885
- s.shown === 'quiet' && Number.isFinite(s.quietMs) ? Math.max(1, Math.round(s.quietMs / 60000)) : '',
886
- // Joined on U+0000, fields and rows both. A separator that cannot occur in any of these
887
- // values is what stops two different lists folding into one identical string and
888
- // suppressing a repaint that was real.
889
- ].join('\u0000')).join('\u0000\u0000');
890
- }
891
-
892
- async function pollSessions() {
893
- if (FIXTURE) return;
894
- const watched = [...ledgerWatch.keys()].slice(0, 4);
895
- const out = await getJson('/api/sessions' + (watched.length ? '?ledgers=' + watched.map(encodeURIComponent).join(',') : ''));
896
- if (out && Array.isArray(out.sessions)) {
897
- const digest = sessionProjection(out.sessions);
898
- const count = liveCount(out.sessions);
899
- // A poll that found nothing new is not a render. `runningCount` is compared too: it folds in
900
- // `extraSess`, so a session started in this window still publishes on the very next poll.
901
- if (digest !== sessionDigest || count !== state.runningCount) {
902
- sessionDigest = digest;
903
- setState({ sessions: out.sessions, runningCount: count });
904
- }
905
- }
906
- if (out && out.ledgers && typeof out.ledgers === 'object' && typeof window !== 'undefined') {
907
- const prev = lastLedgers;
908
- const changed = Object.keys(out.ledgers).filter((ws) => prev && JSON.stringify(out.ledgers[ws]) !== JSON.stringify(prev[ws]));
909
- lastLedgers = out.ledgers;
910
- if (changed.length) window.dispatchEvent(new CustomEvent('pmos:ledgers', { detail: { changed, ledgers: out.ledgers } }));
911
- }
912
- schedulePoll();
913
- }
914
-
915
- function liveCount(rows) {
916
- let n = 0;
917
- for (const s of rows || []) if (s && (s.shown === 'working' || s.shown === 'needs')) n++;
918
- for (const k in state.extraSess || {}) {
919
- for (const s of state.extraSess[k] || []) {
920
- // Started in this window and not yet visible in the server's list — counted once, by name.
921
- if (s && (s.st === 'working' || s.st === 'needs') && !(rows || []).some((r) => r && r.name === s.name)) n++;
922
- }
923
- }
924
- return n;
925
- }
926
-
927
- function schedulePoll() {
928
- if (pollTimer) clearTimeout(pollTimer);
929
- pollTimer = setTimeout(() => {
930
- if (typeof document !== 'undefined' && document.hidden) { schedulePoll(); return; }
931
- pollSessions();
932
- }, 4000);
933
- }
934
-
935
- /* ══════════════════════════════════════════════════════════════════════════════════════════════
936
- * The exported surface. Every one of these is called by a panel module BY NAME — the signatures
937
- * are the panels', not this file's, and none of them may change without changing the caller.
938
- * ════════════════════════════════════════════════════════════════════════════════════════════ */
939
-
940
- /**
941
- * panel-repos.js — `loadRepos()`. The repository list, with a real initiative count per row.
942
- * Each product's board is loaded here rather than lazily, because the count on the row IS the
943
- * board's size: a row that said "— initiatives" until it was clicked would be a row that has not
944
- * read anything.
945
- *
946
- * `kind` is the SERVER's answer, not a guess made here: /api/workspaces reports `remote` (the tree's
947
- * `origin` URL, or null) and the `github`/`local` label derived from it, so a row says `github` only
948
- * where a GitHub remote was actually read. It used to be hardcoded `local` on every row, which was
949
- * honest but blind; inferring it from the presence of a `.git` folder — the other tempting fix —
950
- * would put a provenance label on a row that no read supports.
951
- */
952
- export async function loadRepos() {
953
- if (FIXTURE) return [];
954
- const out = await getJson('/api/workspaces');
955
- // The server's one answer to "is the runtime state settled?", published straight onto state so
956
- // panel 1 can say so. Under an unmigrated conflict the lists below are short by everything the
957
- // per-user state directory does not hold, and a list that is short without saying so is the
958
- // silent failure this key exists to end. `{ok:true}` publishes too — the banner reads `ok`.
959
- const health = out && out.state_health ? out.state_health : null;
960
- const rows = foldWorkspaces(out && out.workspaces);
961
- productOrder = rows.map((r) => r.name);
962
- for (const r of rows) products.set(r.name, Object.assign(products.get(r.name) || {}, r));
963
- // The session poll does not read a board, so it does not wait for one. Behind the board loads it first answered only
964
- // after the (now larger) initiatives surface had been fetched, and a live agent's marker was missing until then.
965
- pollSessions();
966
- await Promise.all(rows.map((r) => loadBoard(products.get(r.name))));
967
- publishBoards();
968
- const first = currentProductName();
969
- const p = first ? products.get(first) : null;
970
- // The selection is set explicitly rather than left to panel 2's fallback. The fallback picks the
971
- // same row, but it picks it WITHOUT setting `sel` — so the row is not highlighted, and the
972
- // hydration watcher below (which fires on a change to `sel`) never sees the initiative that is
973
- // actually on screen. A restored selection from the PM's last session always wins.
974
- const sel = state.sel || (p ? firstSlugOf(p.name) : null);
975
- setState({
976
- stateHealth: health,
977
- wsId: p ? p.ws : null,
978
- // NOT initialised to a value here. What is resolvable is the server's derivation from the PM's
979
- // agent profiles, it arrives with the first `/api/initiative` payload, and seeding a `[]` in the
980
- // meantime is not a placeholder — it is an answer, and the panel would render it as one.
981
- product: state.product && products.has(state.product) ? state.product : first,
982
- sel,
983
- });
984
- if (sel) hydrate(sel);
985
- return productOrder.map((name) => {
986
- const prod = products.get(name);
987
- return {
988
- name,
989
- kind: prod && prod.kind === 'github' ? 'github' : 'local',
990
- count: prod && prod.count !== null ? prod.count : null,
991
- // The board's OTHER population, published beside the count rather than folded into it — see
992
- // `prod.unrecorded` in loadBoard and the sub-line in panel-repos.js#toTuple. A row that
993
- // reports only the spine's number is accurate about itself and silent about the rest of the
994
- // panel; the two together are what make panel 1 and panel 2 unable to disagree.
995
- unrecorded: prod && typeof prod.unrecorded === 'number' ? prod.unrecorded : 0,
996
- };
997
- });
998
- }
999
-
1000
- /**
1001
- * panel-repos.js — `productTrees(name)`, synchronous. The LINES OF WORK of one repository
1002
- * (overhaul-r1 R2.1): every registered tree sharing its `repo_key`, main tree first. `initiative`
1003
- * is read from an `initiative/<id>` branch and says so (`by: 'branch'`) — it is a reading of the
1004
- * branch name, not a recorded attribution, and the row must not present it as one.
1005
- */
1006
- export function productTrees(name) {
1007
- const p = products.get(name);
1008
- if (!p || !Array.isArray(p.trees)) return [];
1009
- const key = p.root;
1010
- return p.trees.map((t) => {
1011
- const m = /^initiative\/(.+)$/.exec(t.branch || '');
1012
- return { ws: t.id, dir: t.tree || t.root, branch: t.branch || null, main: t.root === key, sessions: t.sessions || 0,
1013
- initiative: m ? m[1] : null, by: m ? 'branch' : null };
1014
- }).sort((a, b) => (b.main - a.main));
1015
- }
1016
-
1017
- /** The branch of a registered tree, or null — for tab labels and the status bar (R2.2/R2.3). */
1018
- export function branchOfWs(ws) {
1019
- return ws ? (wsBranch.get(ws) || null) : null;
1020
- }
1021
-
1022
- /** True when `ws` is a linked worktree rather than its repository's main tree. */
1023
- export function isLinkedTree(ws) {
1024
- if (!ws) return false;
1025
- for (const p of products.values()) {
1026
- if (!Array.isArray(p.trees)) continue;
1027
- const t = p.trees.find((x) => x.id === ws);
1028
- if (t) return t.root !== p.root;
1029
- }
1030
- return false;
1031
- }
1032
-
1033
- /**
1034
- * panel-repos.js — `removeRepository(name)`. Forgets the repository AND its worktree rows; never
1035
- * deletes a folder (R3.2). Resolves `{ok}` or `{ok:false, reason, error}` with the server's own
1036
- * words, which the row shows as-is (R3.3).
1037
- */
1038
- export async function removeRepository(name) {
1039
- if (FIXTURE) return { ok: false, error: 'fixture mode — nothing is registered' };
1040
- const p = products.get(name);
1041
- if (!p) return { ok: false, reason: 'unknown', error: 'unknown repository' };
1042
- const res = await postJson('/api/workspaces/forget', { id: p.ws, repository: true });
1043
- if (res && res.ok) {
1044
- products.delete(name);
1045
- productOrder = productOrder.filter((n) => n !== name);
1046
- publishBoards();
1047
- if (state.product === name) setState({ product: productOrder[0] || null, sel: null, wsId: null });
1048
- }
1049
- return res || { ok: false, error: 'the workspace server did not answer' };
1050
- }
1051
-
1052
- /** The PM's own abbreviation for the rail, or null (the rail derives one from the name). */
1053
- export function repoInitials(name) { const p = products.get(name); return (p && p.initials) || null; }
1054
-
1055
- /** panel-repos.js — the repository's profile (D68): 'pm-artifacts' (documents) or 'product-code'. */
1056
- /** The workflow audit for one repository (D77): the sweep, read-only. Resolves to the report or `{ok:false,error}`. */
1057
- export async function loadAudit(name) {
1058
- const p = products.get(name);
1059
- if (!p) return { ok: false, error: 'that repository is not registered' };
1060
- return getJson('/api/audit', { ws: p.ws });
1061
- }
1062
- /** The lane names a profile offers, as the server's engine reports them; null when it did not say. */
1063
- export function repoLanes(name, profile) { const p = products.get(name); return (p && p.laneSets && p.laneSets[profile]) || null; }
1064
- export function repoProfile(name) { const p = products.get(name); return (p && p.profile) || 'product-code'; }
1065
-
1066
- /** panel-repos.js — write or remove `.pmos-profile`. Refusals come back as { ok:false, error }. */
1067
- export async function setRepoProfile(name, profile) {
1068
- if (FIXTURE) return { ok: false, error: 'fixture mode — nothing is registered' };
1069
- const p = products.get(name);
1070
- if (!p) return { ok: false, reason: 'unknown', error: 'unknown repository' };
1071
- const out = await postJson('/api/workspaces/profile', { id: p.ws, profile });
1072
- if (out && out.ok) {
1073
- p.profile = profile;
1074
- // the lane picker and the ladder read the profile: drop every cached record and re-read the open one
1075
- for (const k of Object.keys(hydrated)) delete hydrated[k];
1076
- try { await loadBoard(p); publishBoards(); } catch { /* the chip already shows the new profile */ }
1077
- if (state.sel) await hydrate(state.sel);
1078
- }
1079
- return out || { ok: false, error: 'the workspace server did not answer' };
1080
- }
1081
-
1082
- /** panel-repos.js — `renameRepository(name, label)`. A display name only (R3.1). */
1083
- export async function renameRepository(name, label, initials) {
1084
- if (FIXTURE) return { ok: false, error: 'fixture mode — nothing is registered' };
1085
- const p = products.get(name);
1086
- if (!p) return { ok: false, reason: 'unknown', error: 'unknown repository' };
1087
- return (await postJson('/api/workspaces/rename', { id: p.ws, name: label, ...(initials !== undefined ? { initials } : {}) })) || { ok: false, error: 'the workspace server did not answer' };
1088
- }
1089
-
1090
- /**
1091
- * panel-repos.js — `firstSlugOf(id)`, synchronous. The initiative selected when a repository is
1092
- * picked. A repository whose board is loaded and genuinely empty returns null, and panel 3 says so.
1093
- */
1094
- export function firstSlugOf(id) {
1095
- const p = products.get(id);
1096
- if (!p || !p.board) return null;
1097
- for (const g of p.board) if (g.slugs && g.slugs.length) return g.slugs[0];
1098
- return null;
1099
- }
1100
-
1101
- /**
1102
- * panel-repos.js — `loadInitiatives(id)`. The board for one repository, loaded if it is not
1103
- * already. Returns `{groups}` because that is the shape the caller's `firstSlugIn` reads.
1104
- */
1105
- export async function loadInitiatives(id) {
1106
- if (FIXTURE) return { groups: [] };
1107
- let p = products.get(id);
1108
- if (!p) {
1109
- await loadRepos();
1110
- p = products.get(id);
1111
- if (!p) return { ok: false, error: 'no repository named ' + id + ' is registered', groups: [] };
1112
- }
1113
- if (!p.board) await loadBoard(p);
1114
- publishBoards();
1115
- if (p.error) return { ok: false, error: p.error, groups: [] };
1116
- return { ok: true, groups: p.board, records: p.records };
1117
- }
1118
-
1119
- /**
1120
- * panel-repos.js — `addRepo({source, kind})`. Registering a local folder is a one-call write.
1121
- *
1122
- * A GitHub repository goes through the server's repo INGEST instead: the server clones it off the
1123
- * request path (the one sanctioned egress in this process, git's and not the browser's), scans it
1124
- * and proposes anchors that a human confirms one at a time. This function starts that and reports
1125
- * where it got to; it does NOT add a board row, because a row for a repository whose anchors have
1126
- * not been confirmed would be a board claiming work PMOS has not accepted.
1127
- */
1128
- export async function addRepo({ source, kind }) {
1129
- if (FIXTURE) return { log: [] };
1130
- if (kind === 'local') {
1131
- const res = await postJson('/api/workspaces', { root: source, focus: false });
1132
- if (!res || res.ok === false) {
1133
- return { log: [{ t: 'refused — ' + ((res && res.error) || 'the folder could not be registered'), c: 'var(--destructive)' }] };
1134
- }
1135
- const w = res.workspace || {};
1136
- const rows = foldWorkspaces([{ ...w, repo_key: w.root, repo_name: w.name }]);
1137
- const p = rows[0];
1138
- products.set(p.name, Object.assign(products.get(p.name) || {}, p));
1139
- if (!productOrder.includes(p.name)) productOrder.push(p.name);
1140
- await loadBoard(products.get(p.name));
1141
- publishBoards();
1142
- const prod = products.get(p.name);
1143
- return {
1144
- repo: { name: p.name, kind: 'local', count: prod.count, unrecorded: prod.unrecorded || 0 },
1145
- log: [
1146
- { t: 'registered ' + w.root, c: 'var(--muted-foreground)' },
1147
- prod.error
1148
- ? { t: 'the initiative spine could not be read — ' + prod.error, c: 'var(--destructive)' }
1149
- // The log says WHERE the records were read from, because "0 initiative record(s)" against
1150
- // a repo that has them is the defect this initiative exists to close — a line naming
1151
- // `planning/` on a kit repo that keeps them in `pmos/state/` would have described a
1152
- // directory the server never opened.
1153
- : { t: 'read ' + (prod.count === 1 ? '1 initiative record' : (prod.count || 0) + ' initiative records')
1154
- + (prod.unrecorded ? ' · ' + prod.unrecorded + ' artifact group(s) with no record' : ''), c: 'var(--muted-foreground)' },
1155
- { t: 'done — ' + p.name + ' added', c: 'var(--success)' },
1156
- ],
1157
- };
1158
- }
1159
- const res = await postJson('/api/ingest', { source: 'github', ref: source });
1160
- if (!res || res.ok === false) {
1161
- return { log: [{ t: 'refused — ' + ((res && res.error) || 'the ingest could not be started'), c: 'var(--destructive)' }] };
1162
- }
1163
- return {
1164
- log: [
1165
- { t: 'ingest ' + res.id + ' started — clone and scan run off the request path', c: 'var(--muted-foreground)' },
1166
- { t: 'anchors are PROPOSED by the scan and confirmed one at a time — nothing is on the board yet', c: 'var(--warning)' },
1167
- ],
1168
- };
1169
- }
1170
-
1171
- /**
1172
- * panel-repos.js — `chooseFolder(start)`. The machine's OWN folder dialog, opened by the server.
1173
- *
1174
- * A browser cannot hand back an absolute path — its directory picker yields a name and a handle,
1175
- * never a path — so the add-a-product form could only ever offer a text field, and the PM had to
1176
- * know and type the path of the repo they were looking at. The server runs on the PM's machine and
1177
- * binds 127.0.0.1 (D62), so it opens the native chooser and returns the chosen path; this function
1178
- * only asks. Registration still goes through `addRepo()` → POST /api/workspaces, so nothing here
1179
- * bypasses a guard: the dialog produces a string, and the PM confirms it like any other.
1180
- *
1181
- * `{cancelled:true}` and `{unsupported:true}` are ANSWERS, not failures — a headless Linux box has
1182
- * no chooser at all, which is what `listFolder()` below stands in for.
1183
- */
1184
- export async function chooseFolder(start) {
1185
- if (FIXTURE) return { ok: false, unsupported: true };
1186
- return postJson('/api/pick-folder', { start: start || '' });
1187
- }
1188
-
1189
- /**
1190
- * panel-repos.js — `listFolder(dir)`. The in-app folder browser's data source, for when there is
1191
- * no native chooser (and for anyone who prefers it). The server returns directory NAMES only —
1192
- * never a file, never a byte of content — and flags which ones are git repositories.
1193
- */
1194
- export async function listFolder(dir) {
1195
- if (FIXTURE) return { ok: false, error: 'fixture mode has no filesystem' };
1196
- return getJson('/api/fs/list', dir ? { path: dir } : null);
1197
- }
1198
-
1199
- /* ── what the session pre-flight asks the server ───────────────────────────────────────────────
1200
- * Four read-only endpoints that have been served all along with no client reading them. They are
1201
- * the questions the retired composer asked before a session started, and losing the client half is
1202
- * what left `+ session` spawning on defaults nobody chose.
1203
- *
1204
- * Every one declines in FIXTURE mode, and that is load-bearing rather than tidy: the fixture render
1205
- * must make no network call at all — it is what lets no-network.test.js and the design comparator
1206
- * trust a fixture run. The form degrades to "no repository was read" and the fixture's own profile
1207
- * list, which is a true statement about fixture mode rather than a blank.
1208
- */
1209
-
1210
- /**
1211
- * Every branch of a workspace's repository, plus which one is current and which are already
1212
- * checked out in another working tree. Returns the server's `gitInfo.branchInfo` verbatim, so a
1213
- * non-repo answers `{ok:false, code, error}` and NEVER a fabricated branch — the difference
1214
- * between "this folder has no git" and "git failed" is the picker's to show, so it must survive
1215
- * the trip.
1216
- */
1217
- export async function loadBranches(ws) {
1218
- if (FIXTURE) return { ok: false, error: 'fixture mode reads no repository' };
1219
- if (!ws) return { ok: false, error: 'no repository selected' };
1220
- return getJson('/api/git/branches', { ws });
1221
- }
1222
-
1223
- /**
1224
- * The Claude profile descriptors, as `{ok, absent, dir, profiles, broken, prefs, error}`.
1225
- *
1226
- * All six fields matter to the caller and none may be flattened here: `absent` ("the directory does
1227
- * not exist") is a different sentence from a successful read that found none; `broken` names a
1228
- * descriptor that must be shown and NOT offered, while every good one beside it is still offered;
1229
- * and `prefs` is what preselects a chip, replacing a hardcoded 'claude-work' that named a file this
1230
- * client had never opened.
1231
- *
1232
- * `env` values are absent by construction on the server side (profileWire) — D08's discipline
1233
- * covers anything the browser receives, and an overlay is where a credential lives.
1234
- */
1235
- export async function loadProfiles() {
1236
- if (FIXTURE) return { ok: false, error: 'fixture mode reads no profiles' };
1237
- return getJson('/api/profiles');
1238
- }
1239
-
1240
- /** Every flag `claude --help` lists, each marked `offered` or not with the reason. A static file on the server. */
1241
- export async function loadClaudeFlags() {
1242
- if (FIXTURE) return { ok: false, error: 'fixture mode reads no flag list', flags: [] };
1243
- return getJson('/api/claude-flags');
1244
- }
1245
-
1246
- /** Remember the profile this agent should preselect next time. The server refuses a preference for
1247
- * a descriptor it cannot read, so a stored id always resolves to a chip that is on screen. */
1248
- export async function preferProfile(agent, profile) {
1249
- if (FIXTURE) return { ok: false, error: 'fixture mode remembers nothing' };
1250
- return postJson('/api/profiles/prefer', { agent, profile });
1251
- }
1252
-
1253
- /** Re-read the registered trees only — no boards. A worktree created or removed anywhere (a spawn, the
1254
- * branch form, a terminal) reaches panel 1 through this, instead of waiting for a reload. */
1255
- export async function refreshTrees() {
1256
- if (FIXTURE) return;
1257
- const out = await getJson('/api/workspaces');
1258
- if (!out || !Array.isArray(out.workspaces)) return;
1259
- const rows = foldWorkspaces(out.workspaces);
1260
- for (const r of rows) products.set(r.name, Object.assign(products.get(r.name) || {}, r));
1261
- publishBoards();
1262
- }
1263
-
1264
- /** Create a branch with no session. `worktree` false = a checkout in the shared tree (the server
1265
- * refuses it while sessions run there). */
1266
- export async function createBranch({ ws, name, from, worktree }) {
1267
- if (FIXTURE) return { ok: false, error: 'fixture mode creates no branch' };
1268
- return postJson('/api/git/branch', { ws, name, from: from || null, worktree: worktree !== false });
1269
- }
1270
-
1271
- /** End a session and remove it, with an answer. */
1272
- export async function removeSessionById(id) {
1273
- if (FIXTURE) return { ok: false, error: 'fixture mode has no sessions' };
1274
- return postJson('/api/session/remove', { id });
1275
- }
1276
-
1277
- /** Remove a linked worktree folder. The server refuses a busy or unsaved one and says why. */
1278
- export async function removeWorktree(ws, dir) {
1279
- if (FIXTURE) return { ok: false, error: 'fixture mode has no worktrees' };
1280
- return postJson('/api/git/worktrees/remove', { ws, dir });
1281
- }
1282
-
1283
- /** Every working tree of this workspace's repo. The pre-flight reads it for ONE purpose: a branch
1284
- * checked out elsewhere is a branch git will refuse, and the PM should read that in the picker
1285
- * rather than as an error after the click. */
1286
- export async function loadWorktrees(ws) {
1287
- if (FIXTURE) return { ok: false, error: 'fixture mode reads no repository' };
1288
- if (!ws) return { ok: false, error: 'no repository selected' };
1289
- return getJson('/api/git/worktrees', { ws });
1290
- }
1291
-
1292
- /**
1293
- * panel-tabs.js — `startSession(slug, sess)`. Deliberately NOT a spawn.
1294
- *
1295
- * panel 4's terminal module owns session creation: it holds the WebSocket, and it spawns a PTY for
1296
- * exactly the sessions that were started in this window. Spawning one here as well would start two
1297
- * agents for one click and give the PM a tab attached to whichever won. What this hook does is
1298
- * refresh the session list soon enough that the new PTY appears in `state.sessions` — the join the
1299
- * board and the status bar read.
1300
- */
1301
- export function startSession(slug, sess) {
1302
- if (FIXTURE) return;
1303
- void slug; void sess;
1304
- setTimeout(pollSessions, 800);
1305
- }
1306
-
1307
- /**
1308
- * Bind a RUNNING session to an initiative — the PM's own word about work already in flight
1309
- * (workspace-session-attribution R3).
1310
- *
1311
- * Every session that existed before the recorded field shipped has no attribution, and so does every
1312
- * session started outside PMOS. Without this the field would be a promise about future sessions and
1313
- * no help at all with the ones on screen.
1314
- *
1315
- * What comes back is the server's answer, not an assumption: `previous` names the initiative this
1316
- * replaced, so a re-bind the PM did not mean to make is visible rather than silent. Pass
1317
- * `initiative: null` to clear a binding — the honest way back from a wrong one.
1318
- *
1319
- * The poll is scheduled rather than the state patched locally: `/api/sessions` is the one reader of
1320
- * this fact, and writing a second opinion into `state.sessions` here is how the board and the server
1321
- * would come to disagree about what a session is for.
1322
- */
1323
- export async function bindSessionInitiative(id, initiative) {
1324
- if (FIXTURE) return { ok: false, error: 'fixture mode has no server' };
1325
- const out = await postJson('/api/session/initiative', { id, initiative: initiative || null });
1326
- if (out && out.ok) setTimeout(pollSessions, 200);
1327
- return out || { ok: false, error: 'the workspace server did not answer' };
1328
- }
1329
-
1330
- /** 0.55.1 — the dock's ⋯ sheet: rename a session and set its type of work (`workType` null clears it). Labels only. */
1331
- export async function setSessionMeta(id, patch) {
1332
- if (FIXTURE) return { ok: false, error: 'fixture mode has no server' };
1333
- const out = await postJson('/api/session/meta', { id, ...(patch || {}) });
1334
- if (out && out.ok) setTimeout(pollSessions, 200);
1335
- return out || { ok: false, error: 'the workspace server did not answer' };
1336
- }
1337
-
1338
- /* ── the scratchpad ─────────────────────────────────────────────────────────────────────────────
1339
- * The pad is PER SESSION, and the server has always stored it that way: `/api/scratchpad` is keyed
1340
- * by the server-issued session id (workspace-scoped, one file per session, deleted with it). What
1341
- * was lost in the four-panel port was the CLIENT half — the pad became one in-memory string for the
1342
- * whole page, so every tab in every repository showed, and overwrote, the same text.
1343
- *
1344
- * These two functions are the whole restoration. The key is `sess:<id>` or `ws:<id>`; the panel
1345
- * derives it, this file only speaks the two shapes the endpoint accepts.
1346
- */
1347
-
1348
- function padParams(key) {
1349
- const k = String(key || '');
1350
- if (k.startsWith('sess:')) return { session: k.slice(5) };
1351
- if (k.startsWith('ws:')) return { ws: k.slice(3) };
1352
- return null;
1353
- }
1354
-
1355
- /** panel-tabs.js — the stored text for one pad, or '' when there is none (and on any failure). */
1356
- export async function loadScratchpad(key) {
1357
- if (FIXTURE) return '';
1358
- const params = padParams(key);
1359
- if (!params) return '';
1360
- const out = await getJson('/api/scratchpad', params);
1361
- return out && out.ok !== false && typeof out.text === 'string' ? out.text : '';
1362
- }
1363
-
1364
- /**
1365
- * panel-tabs.js — write one pad. A failure is reported to the console and NOT surfaced as a lost
1366
- * buffer: the text stays in `state.scratchPads`, so the PM keeps what they typed for this page even
1367
- * when the disk write refused.
1368
- */
1369
- export async function saveScratchpad(key, text) {
1370
- if (FIXTURE) return { ok: true };
1371
- const params = padParams(key);
1372
- if (!params) return { ok: false, error: 'no session or workspace to file this pad under' };
1373
- const out = await postJson('/api/scratchpad', { ...params, text });
1374
- if (out && out.ok === false) console.warn('[pm] the scratchpad was NOT saved: ' + out.error);
1375
- return out;
1376
- }
1377
-
1378
- /** tab-doc.js — `readDoc(path)`. The raw document body, or a rejected promise carrying the reason. */
1379
- export async function readDoc(path, ws, ref) {
1380
- if (FIXTURE) return '';
1381
- const p = products.get(currentProductName());
1382
- // `ws` is the tree a search hit came from (overhaul-r1 R1.3) — a branch-only file must be read
1383
- // from its own worktree, not from the product's main tree.
1384
- const url = '/api/doc?' + q({ ws: ws || state.wsId || (p ? p.ws : ''), path, ...(ref ? { ref } : {}) });
1385
- const res = await fetch(url);
1386
- if (!res.ok) {
1387
- // The server states why a read was refused (binary, too large, not text, outside the workspace); show that reason.
1388
- const why = res.status === 404 ? (await res.text().catch(() => '')) : '';
1389
- throw new Error(res.status === 404 ? (why || 'not a readable text document in this workspace') : 'HTTP ' + res.status);
1390
- }
1391
- return res.text();
1392
- }
1393
-
1394
- /**
1395
- * panel-initiatives.js — `searchFiles(q, limit)`. Every file under THIS workspace's root whose path
1396
- * or contents match, from the one endpoint that walks the folder. Bounded on the server, and the
1397
- * bound comes back in the payload (`truncated`, `scanned`) rather than being silently applied — a
1398
- * capped list rendered as a complete one is the defect the search box already had.
1399
- *
1400
- * FIXTURE mode resolves to an empty, untruncated result WITHOUT fetching: rule 1 of this file is
1401
- * that a fixture render is provably not a real read wearing a costume, and `no-network.test.js`
1402
- * checks that claim at source level.
1403
- */
1404
- export async function searchFiles(query, limit, all) {
1405
- const q = String(query == null ? '' : query).trim();
1406
- if (FIXTURE || !q) return { ok: true, q, hits: [], truncated: false, scanned: 0 };
1407
- const p = products.get(currentProductName());
1408
- // overhaul-r4 B1 — `all`: every registered repository, each hit tagged with its repository
1409
- if (all) return getJson('/api/search/files', { scope: 'all', q, limit });
1410
- return getJson('/api/search/files', { ws: state.wsId || (p ? p.ws : ''), q, limit });
1411
- }
1412
-
1413
- /**
1414
- * tab-doc.js — `saveDoc({ws, path, base, text})`. Refuse-on-stale: the server compares `base`
1415
- * against the file on disk and REFUSES rather than overwriting a file that changed underneath.
1416
- * The refusal is returned as `{ok:false,error}` and the caller keeps the buffer.
1417
- */
1418
- export async function saveDoc({ ws, path, base, text }) {
1419
- if (FIXTURE) return { ok: true };
1420
- const p = products.get(currentProductName());
1421
- return postJson('/api/doc/save', { ws: ws || state.wsId || (p ? p.ws : ''), path, base, text });
1422
- }
1423
-
1424
- /**
1425
- * panel-detail.js — `recordArtifactLink({artifact_path, slug, kind, target})`.
1426
- * Appends ONE declaration to `artifact-links.jsonl`. It contacts nothing: PMOS holds no credential,
1427
- * so this records what the PM says the mapping is and says nothing about the destination.
1428
- */
1429
- export async function recordArtifactLink({ artifact_path, slug, kind, target, origin, state: st }) {
1430
- if (FIXTURE) return { ok: true };
1431
- const p = products.get(currentProductName());
1432
- const out = await postJson('/api/initiative/link', {
1433
- store: 'artifact', ws: state.wsId || (p ? p.ws : ''),
1434
- initiative_id: slug, artifact_path,
1435
- // The surface labels a Google destination `google doc`; the store's vocabulary is `google`.
1436
- kind: String(kind || '').startsWith('google') ? 'google' : kind,
1437
- target,
1438
- // Passed through rather than defaulted here. The server owns the rules about which origin may
1439
- // claim which state — including that a retraction is the PM's alone — and a client that filled
1440
- // these in itself would be a second opinion about provenance, which is the one thing this store
1441
- // must have exactly one of.
1442
- origin, state: st,
1443
- });
1444
- if (out && out.ok === false) console.warn('[pm] the artifact link was NOT recorded: ' + out.error);
1445
- return out;
1446
- }
1447
-
1448
- /**
1449
- * panel-detail.js — `recordSync({artifact_path, slug, kind, target, direction, profile})`.
1450
- *
1451
- * Records the direction the PM chose and returns the TASK a session will run to carry it out. It
1452
- * syncs nothing: the row lands as `proposed`, which is the only state PMOS can produce on its own,
1453
- * and it stays that way until a session that actually performed the write reports back and names
1454
- * itself. Nothing here contacts Confluence, Jira or Google, and nothing here can.
1455
- */
1456
- export async function recordSync({ artifact_path, slug, kind, target, direction, profile }) {
1457
- if (FIXTURE) return { ok: false, error: 'fixture mode records no sync' };
1458
- const p = products.get(currentProductName());
1459
- const out = await postJson('/api/initiative/sync', {
1460
- ws: state.wsId || (p ? p.ws : ''),
1461
- initiative_id: slug, artifact_path,
1462
- kind: String(kind || '').startsWith('google') ? 'google' : kind,
1463
- target, direction, profile: profile || null,
1464
- });
1465
- if (out && out.ok === false) console.warn('[pm] the sync direction was NOT recorded: ' + out.error);
1466
- return out;
1467
- }
1468
-
1469
- /**
1470
- * panel-detail.js — `lookupTask({kind, subject, hint, profile})`.
1471
- *
1472
- * Asks the server to compose the task a SESSION will run to resolve a reference. It returns text.
1473
- * Nothing here contacts Jira, Confluence or Google, and nothing here can: the workspace holds no
1474
- * credential (D53 — the agent layer acts with the PM's own MCP, PMOS records the result).
1475
- */
1476
- export async function lookupTask({ kind, subject, hint, profile }) {
1477
- if (FIXTURE) return { ok: false, error: 'fixture mode composes no task' };
1478
- return postJson('/api/initiative/lookup-task', { kind, subject, hint, profile });
1479
- }
1480
-
1481
- /** panel-detail.js — `recordInitiativeLink({slug, kind, label, path, origin, state})` → `initiative-links.jsonl`. */
1482
- export async function recordInitiativeLink({ slug, kind, label, path, origin, state: st }) {
1483
- if (FIXTURE) return { ok: true };
1484
- const p = products.get(currentProductName());
1485
- const out = await postJson('/api/initiative/link', {
1486
- store: 'initiative', ws: state.wsId || (p ? p.ws : ''),
1487
- initiative_id: slug, kind, label, target: path, origin, state: st,
1488
- });
1489
- if (out && out.ok === false) console.warn('[pm] the reference link was NOT recorded: ' + out.error);
1490
- return out;
1491
- }
1492
-
1493
- /**
1494
- * app.js — `runningCount(state)`. The status bar's number: live PTYs the server reports as working
1495
- * or needing the PM, plus any started in this window the server has not listed yet.
1496
- */
1497
- export function runningCount(s) {
1498
- // DECLINE in fixture mode rather than answering 0. Returning a number here is an answer, and
1499
- // app.js quite correctly takes the first answer it gets — so `0` shadowed the fixture's own
1500
- // count and the status bar read "0 sessions running" against a seed board with three. It cost a
1501
- // parity failure on a bar that is otherwise pixel-identical. Null means "not mine to answer".
1502
- if (FIXTURE) return null;
1503
- return liveCount((s && s.sessions) || state.sessions || []);
1504
- }
1505
-
1506
- /* ── keeping the selection hydrated ──────────────────────────────────────────────────────────
1507
- * The PM selects an initiative in panel 2 and panel 3 must show its ladder. Rather than making
1508
- * every panel call this module, the selection is watched here: one subscription, one fetch per
1509
- * newly selected initiative, and a repaint when it lands.
1510
- */
1511
- if (!FIXTURE) {
1512
- let lastSel = null, lastProduct = null;
1513
- subscribe(() => {
1514
- if (state.product !== lastProduct) {
1515
- lastProduct = state.product;
1516
- const p = products.get(state.product);
1517
- if (p && p.ws && state.wsId !== p.ws) setState({ wsId: p.ws });
1518
- if (p && !p.board) loadInitiatives(state.product);
1519
- }
1520
- const sel = state.sel;
1521
- if (sel && sel !== lastSel) {
1522
- lastSel = sel;
1523
- if (!hydrated[sel]) hydrate(sel);
1524
- }
1525
- });
1526
- }
1527
-
1528
- /* ── D70 — stopped initiatives and press-only sync ───────────────────────────────────────────
1529
- * Each of these is reached only by a PM press. None runs on load, on a timer or as a side effect. */
1530
- export function wsOf(name) { const p = products.get(name); return p ? p.ws : null; }
1531
-
1532
- /* ── next-step actions: prepare, go, review (the routes are in server.js; every one is reached by a PM press) ── */
1533
- export async function nextStepPost(kind, body) {
1534
- if (FIXTURE) return { ok: false, error: 'fixture mode starts nothing' };
1535
- return (await postJson('/api/next-step/' + kind, { ws: wsOf(currentProductName()), ...body })) || { ok: false, error: 'the workspace server did not answer' };
1536
- }
1537
- export async function nextStepSummary(session) { return FIXTURE ? { ok: false, error: 'fixture mode' } : getJson('/api/next-step/summary', { session }); }
1538
- export async function nextStepProfiles() { return FIXTURE ? { ok: false, profiles: [] } : getJson('/api/profiles'); }
1539
- /** Re-read one initiative (its next steps, runs and verdicts) after something changed. */
1540
- export async function refreshInitiative(slug) { if (FIXTURE || !slug) return; delete hydrated[slug]; await hydrate(slug); }
1541
-
1542
- /** The lifecycle of every initiative in a repository, from the same surface the board uses. */
1543
- export async function lifecycleMap(name) {
1544
- const ws = wsOf(name);
1545
- if (FIXTURE || !ws) return {};
1546
- const res = await getJson('/api/surface', { name: 'initiatives', ws });
1547
- const out = {};
1548
- const items = (res && res.surface && res.surface.initiatives) || (res && res.initiatives) || [];
1549
- for (const i of items) if (i && i.lifecycle) out[i.id] = i.lifecycle;
1550
- return out;
1551
- }
1552
-
1553
- export async function setLifecycle(name, initiativeId, newState, reason) {
1554
- if (FIXTURE) return { ok: false, error: 'fixture mode — nothing is recorded' };
1555
- const ws = wsOf(name);
1556
- if (!ws) return { ok: false, error: 'unknown repository' };
1557
- const res = await postJson('/api/lifecycle', { ws, initiative_id: initiativeId, state: newState, reason });
1558
- if (res && res.ok) { const p = products.get(name); if (p) { p.board = null; await loadBoard(p); publishBoards(); } }
1559
- return res || { ok: false, error: 'the workspace server did not answer' };
1560
- }
1561
-
1562
- export async function syncStatusOf(name) {
1563
- const ws = wsOf(name);
1564
- if (FIXTURE || !ws) return null;
1565
- return getJson('/api/sync/status', { ws });
1566
- }
1567
-
1568
- // prefer: 'mine' | 'theirs' — the PM's answer after Sync stopped on a conflict (D70 as amended 2026-10-07).
1569
- export async function syncRepository(name, { prefer } = {}) {
1570
- if (FIXTURE) return { ok: false, message: 'fixture mode — nothing to sync' };
1571
- const ws = wsOf(name);
1572
- if (!ws) return { ok: false, message: 'unknown repository' };
1573
- const res = await postJson('/api/sync', prefer ? { ws, prefer } : { ws });
1574
- const p = products.get(name);
1575
- if (res && res.ok && p) { p.board = null; await loadBoard(p); publishBoards(); }
1576
- return res || { ok: false, message: 'the workspace server did not answer' };
1577
- }