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,764 +0,0 @@
1
- /* pm/c3-demo-boards.js — DEMO ONLY (/c3.html?demo=1): the Initiatives boards fixture (PRD c3-initiative-boards, S3, widened by
2
- * console3-initiatives-parity). It answers every /api/boards GET and POST with the response shapes of routes-boards.js, from 5 boards
3
- * and about 310 initiatives:
4
- * IDPF (Build and deliver on, Jira IDPF) · Payments (on, Jira PAY) · Growth (on, Jira GRO) · Office move (off, Project) ·
5
- * Hiring Q4 (off, Simple).
6
- * Each initiative runs its own workflow: most run their board's, some picked another template (IDPF-21 Research only, GRO-02 Content
7
- * and launch, and a share of the generated rows Quick fix or Research only). The work items are Jira items (on the Build and deliver
8
- * boards; the demo gives them dates and owners, which the real mirror does not have) and PMOS epics and tasks.
9
- * The rows are generated the way the restructure mockup's 10-data.js does it (the same seed, word lists and weights). Filtering,
10
- * sorting, paging and facets are done here the way the server does them. A write changes the in-memory state only (a move, a
11
- * workflow, board settings, a new board, an ask, a task): nothing reaches the server, and a reload starts again.
12
- *
13
- * Wiring: c3-demo.js imports installBoards and calls it in installDemo(), after its own wrapper, so this wrapper sits outermost and
14
- * answers the POSTs before c3-demo.js's catch-all "{ ok: true }". Real mode never loads this file.
15
- * Pure parts (exported for a Node test): createStore(), handle(store, method, path, params, body). */
16
- import { WS_ID, TODAY } from './c3-demo-data.js';
17
-
18
- const DAY = 86400000;
19
- const CATS = ['Discover', 'Plan', 'Do', 'Learn'];
20
- const st = (name, cat, hint) => ({ name, cat, hint: hint || '' });
21
- /** The workflow templates an initiative can run (scripts/boards.js INI_TEMPLATES). */
22
- export const INI_TEMPLATES = {
23
- product: { name: 'Product', kind: 'product', use: 'Product work that ships: discovery through to evaluating what shipped.', stages: [st('Discover', 'Discover', 'Discovery and ideation'), st('Plan', 'Plan', 'Strategize, then prioritize, then plan'), st('Build & Deliver', 'Do', 'Tickets, risks, release'), st('Monitor & Evaluate', 'Learn', 'Metrics, outcome check, learnings')] },
24
- fix: { name: 'Quick fix', kind: 'product', use: 'A small, known change: plan it, build it, ship it, check it.', stages: [st('Plan', 'Plan'), st('Build & Deliver', 'Do'), st('Evaluate', 'Learn')] },
25
- research: { name: 'Research only', kind: 'product', use: 'Learn before committing. Nothing gets built in this initiative.', stages: [st('Discover', 'Discover'), st('Plan', 'Plan'), st('Evaluate', 'Learn')] },
26
- content: { name: 'Content and launch', kind: 'project', use: 'Pages, campaigns and launches that a team or an agency produces.', stages: [st('Discover', 'Discover'), st('Plan', 'Plan'), st('Produce', 'Do'), st('Launch', 'Do'), st('Evaluate', 'Learn')] },
27
- project: { name: 'Project', kind: 'project', use: 'Someone who only manages a project: plan it, run it, close it.', stages: [st('Plan', 'Plan', 'Scope, milestones, owners'), st('Execute', 'Do', 'Progress, risks, blockers'), st('Close', 'Learn', 'Outcome and retro')] },
28
- simple: { name: 'Simple', kind: 'simple', use: 'A plain to-do flow for small or personal work.', stages: [st('To do', 'Plan'), st('Doing', 'Do'), st('Done', 'Learn')] },
29
- };
30
- const tplStages = (t) => INI_TEMPLATES[t].stages.map((s) => ({ ...s }));
31
- const isBuildStage = (s) => /^(build|deliver)/i.test(String((s && s.name) || s || ''));
32
- const templateBuilds = (k) => !!INI_TEMPLATES[k] && INI_TEMPLATES[k].stages.some(isBuildStage);
33
- const T = (id, label) => ({ id, label });
34
- /** The stage tools per template kind and category (scripts/boards.js TOOLS). */
35
- const TOOLS = {
36
- product: { Discover: [T('ideas', 'Ideas'), T('hypotheses', 'Hypotheses'), T('notes', 'Notes')], Plan: [T('prd', 'PRD'), T('rubric', 'Done-criteria'), T('breakdown', 'Breakdown'), T('placement', 'Roadmap place')], Do: [T('breakdown', 'Breakdown'), T('tickets', 'Tickets'), T('releases', 'Releases')], Learn: [T('measurements', 'Measurements'), T('evaluation', 'Evaluation'), T('history', 'History')] },
37
- project: { Discover: [T('notes', 'Notes')], Plan: [T('brief', 'Brief'), T('breakdown', 'Breakdown'), T('timeline', 'Timeline')], Do: [T('breakdown', 'Breakdown'), T('tickets', 'Tickets'), T('timeline', 'Timeline')], Learn: [T('notes', 'Notes'), T('history', 'History')] },
38
- simple: { Discover: [T('notes', 'Notes')], Plan: [T('notes', 'Notes')], Do: [T('breakdown', 'Breakdown')], Learn: [T('history', 'History')] },
39
- };
40
- const TASK_STATES = ['To do', 'In progress', 'In review', 'Done'];
41
- const PROG = { 'To do': 0, 'In progress': 0.45, 'In review': 0.8, Done: 1 };
42
- const KR = { '1.1': 'API p95 latency under 300 ms', '1.2': 'No Sev1 incidents', '1.3': 'Partner uptime 99.9%', '2.1': 'Activation to 45%', '2.2': 'First API call within one day', '2.3': 'WAU partners +20%', '3.1': 'Payments revenue +18%', '3.2': 'Net revenue retention 115%', '4.1': 'PCI scope reduced', '4.2': 'Chargebacks under 0.4%', '4.3': 'Payouts within 24 hours' };
43
- const TITLE_WORDS = {
44
- idpf: ['Audit log', 'SSO', 'Webhooks', 'Sandbox', 'Docs search', 'Key rotation', 'Org roles', 'Status page', 'SDK', 'Quota alerts', 'Data export', 'CLI', 'API versioning', 'Usage dashboard'],
45
- pay: ['Invoices', 'Refunds', 'Payouts', 'Fraud rules', 'Retry policy', 'Rate cards', 'Chargeback flow', 'Settlement reports', '3DS', 'Wallets'],
46
- growth: ['Onboarding emails', 'Referral', 'Trial limits', 'Pricing page', 'Activation checklist', 'In-app tips', 'Win-back emails', 'Mobile app'],
47
- office: ['Desk plan', 'Network', 'Furniture', 'Movers', 'Signage', 'Parking', 'Security badges', 'Meeting rooms', 'Pantry'],
48
- hiring: ['Recruiter', 'Interview loop', 'Offer process', 'Referral bonus', 'New-hire onboarding', 'Job posts', 'Sourcing'],
49
- };
50
- const hash = (s) => [...String(s)].reduce((a, c) => (a * 31 + c.charCodeAt(0)) % 1000003, 7);
51
- const base = (() => { const [y, m, d] = TODAY.split('-').map(Number); return new Date(y, m - 1, d).getTime(); })();
52
- const iso = (t) => { const d = new Date(t); return d.getFullYear() + '-' + String(d.getMonth() + 1).padStart(2, '0') + '-' + String(d.getDate()).padStart(2, '0'); };
53
- const D = (n) => iso(base + n * DAY);
54
- const at = (n, h) => D(n) + 'T' + String(h || 9).padStart(2, '0') + ':00:00';
55
- const shiftDay = (day, n) => { const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(day || '')); if (!m) return null; return iso(new Date(Number(m[1]), Number(m[2]) - 1, Number(m[3])).getTime() + n * DAY); };
56
- const sameFlow = (a, b) => a.length === b.length && a.every((s, k) => s.name === b[k].name && s.cat === b[k].cat);
57
-
58
- /** A fresh, deterministic store: boards, initiatives, asks, releases, work items and the ledger of events. */
59
- export function createStore() {
60
- const B = (id, name, full, template, owner, health, prefix, jira, offer, defTpl) => ({ ws: WS_ID, id, name, full, domain: id, template, workflow: tplStages(template), self: false,
61
- build: !!jira, jira, tracker: jira ? 'Jira · ' + jira : null, sprints: !!jira, offer, defTpl, owner, health, prefix });
62
- const BUILD_OFFER = ['product', 'fix', 'research', 'content'];
63
- const boards = [
64
- B('idpf', 'IDPF', 'Identity & Developer Platform', 'product', 'You', 'warn', 'IDPF', 'IDPF', BUILD_OFFER, 'product'),
65
- B('pay', 'Payments', 'Payments platform', 'product', 'Eko Prasetyo', 'ok', 'PAY', 'PAY', BUILD_OFFER, 'product'),
66
- B('growth', 'Growth', 'Activation and retention', 'product', 'You', 'ok', 'GRO', 'GRO', BUILD_OFFER, 'product'),
67
- B('office', 'Office move', 'Jakarta office move 2027', 'project', 'Gita Rahma', 'bad', 'OFF', null, ['content', 'project', 'research', 'simple'], 'project'),
68
- B('hiring', 'Hiring Q4', 'Q4 hiring plan', 'simple', 'You', 'ok', 'HIR', null, ['simple', 'project'], 'simple'),
69
- ];
70
- const I = (id, board, title, stage, owner, anchor, horizon, status, s, e, progress, lane, spec, template) => ({ id, board, title, stage, owner, anchor, horizon, status, start: D(s), end: D(e), progress, lane, spec: !!spec, warnings: [], featured: true, template: template || null, workflow: template ? tplStages(template) : null });
71
- const rows = [
72
- I('IDPF-12', 'idpf', 'Self-serve onboarding v2', 'Build & Deliver', 'You', 'KR 2.1 Activation to 45%', 'now', 'at risk', -40, 18, 0.62, 'feature', true),
73
- I('IDPF-07', 'idpf', 'Partner API rate limits', 'Plan', 'You', 'KR 1.3 Partner uptime 99.9%', 'now', 'on track', -12, 45, 0.25, 'feature', false),
74
- I('IDPF-21', 'idpf', 'Usage-based billing', 'Discover', 'You', 'KR 3.2 Net revenue retention 115%', 'next', 'on track', -5, 90, 0.1, 'discovery', false, 'research'),
75
- I('PAY-03', 'pay', 'Card tokenisation', 'Build & Deliver', 'Eko Prasetyo', 'KR 4.1 PCI scope reduced', 'now', 'on track', -70, 3, 0.9, 'feature', true),
76
- I('GRO-02', 'growth', 'Weekly partner digest', 'Discover', 'You', 'KR 2.3 WAU partners +20%', 'next', 'on track', 2, 60, 0, 'discovery', false, 'content'),
77
- I('OFF-01', 'office', 'Fit-out contractor selection', 'Execute', 'Gita Rahma', 'Project milestone: lease signed', 'now', 'late', -30, -2, 0.7, 'chore', false),
78
- I('HIR-04', 'hiring', 'Senior backend engineer', 'Doing', 'You', 'Hiring plan Q4', 'now', 'on track', -20, 30, 0.4, 'chore', false),
79
- ];
80
- rows.find((r) => r.id === 'IDPF-12').warnings = ['Skipped Plan'];
81
- /* the mockup's generator (10-data.js): the same seed, weights and draws, so the boards hold the same mix */
82
- const owners = ['You', 'Ana Putri', 'Eko Prasetyo', 'Budi Santoso', 'Chen Wei', 'Gita Rahma', ''];
83
- const horizons = ['now', 'next', 'later', 'later', 'next'];
84
- const statuses = ['on track', 'on track', 'on track', 'at risk', 'late', 'done'];
85
- const weights = ['idpf', 'idpf', 'idpf', 'idpf', 'pay', 'pay', 'pay', 'growth', 'growth', 'office', 'hiring'];
86
- const counters = { idpf: 30, pay: 10, growth: 5, office: 2, hiring: 5 };
87
- const suffix = ['v2', 'cleanup', 'pilot', 'for enterprise', 'migration', 'phase 2', 'redesign', 'MVP', 'hardening', 'GA'];
88
- const pools = { idpf: ['1.1', '1.2', '1.3', '2.1', '2.2', '3.2'], pay: ['3.1', '3.2', '4.1', '4.2', '4.3', '1.2'], growth: ['2.1', '2.2', '2.3', '3.2'] };
89
- const lanes = ['feature', 'feature', 'feature', 'discovery', 'chore', 'incident'];
90
- let seed = 7; const r = () => (seed = (seed * 16807) % 2147483647) / 2147483647;
91
- for (let i = 0; i < 305; i++) {
92
- const pick = weights[Math.floor(r() * weights.length)];
93
- const b = boards.find((x) => x.id === pick);
94
- let st0 = b.workflow[Math.floor(r() * b.workflow.length)].name;
95
- const s = Math.floor(r() * 200) - 120; const len = 20 + Math.floor(r() * 90);
96
- const status = st0 === b.workflow[b.workflow.length - 1].name && r() > 0.5 ? 'done' : statuses[Math.floor(r() * statuses.length)];
97
- const id = b.prefix + '-' + (++counters[b.id]);
98
- r(); const sx = suffix[Math.floor(r() * suffix.length)];
99
- const owner = owners[Math.floor(r() * owners.length)]; r(); r();
100
- const horizon = horizons[Math.floor(r() * horizons.length)];
101
- const progress = status === 'done' ? 1 : Math.round(r() * 100) / 100;
102
- const x = hash(id);
103
- const words = TITLE_WORDS[b.id];
104
- const title = words[x % words.length] + ' ' + (['office', 'hiring'].includes(b.id) ? ['phase 1', 'phase 2', 'vendor', 'plan', 'review'][x % 5] : sx);
105
- let anchor = pools[b.id] ? (() => { const k = pools[b.id][x % pools[b.id].length]; return 'KR ' + k + ' ' + KR[k]; })() : b.id === 'office' ? 'Project milestone: ' + ['Lease signed', 'Fit-out complete', 'Move weekend'][x % 3] : 'Hiring plan Q4';
106
- if (x % 29 === 0) anchor = '';
107
- const lane = ['office', 'hiring'].includes(b.id) ? 'chore' : lanes[x % lanes.length];
108
- let start = s; let end = s + len;
109
- let stat = status;
110
- if (horizon !== 'now' && stat !== 'done' && stat !== 'on track') stat = x % 3 ? 'on track' : 'at risk';
111
- /* dates that agree with the horizon (the mockup's shapeInitiatives): Now spans today, Next starts soon, Later starts later */
112
- if (stat !== 'done' && stat !== 'late') {
113
- if (horizon === 'now' && (end < 0 || start > 10)) { start = -(x % Math.max(1, len - 10)); end = start + len; }
114
- else if (horizon === 'next' && (start < 5 || start > 80)) { start = 5 + (x % 60); end = start + len; }
115
- else if (horizon === 'later' && start < 50) { start = 50 + (x % 90); end = start + len; }
116
- }
117
- if (stat === 'late' && end > 0) { end = -1 - (x % 9); start = end - len; }
118
- if (stat === 'done' && end > 0) { end = -(x % 40) - 1; start = end - len; }
119
- /* a share of the product-board rows picked another workflow (the mockup's perInitiativeWorkflows) */
120
- let template = null;
121
- if (b.build && x % 9 === 0) template = 'fix'; else if (b.build && x % 13 === 0) template = 'research';
122
- if (template === 'fix') { if (st0 === 'Discover') st0 = 'Plan'; if (st0 === 'Monitor & Evaluate') st0 = 'Evaluate'; }
123
- if (template === 'research') { if (st0 === 'Build & Deliver') st0 = 'Plan'; if (st0 === 'Monitor & Evaluate') st0 = 'Evaluate'; }
124
- rows.push({ id, board: b.id, title, stage: st0, owner, anchor, horizon, status: stat, start: D(start), end: D(end), progress, lane, spec: lane === 'feature' && x % 3 !== 0, warnings: [], featured: false, template, workflow: template ? tplStages(template) : null });
125
- }
126
- const asks = [
127
- { id: 'ask-1', board: 'idpf', line: 'SSO for enterprise trials', source: 'Lina Kusuma (Sales), Slack #sales-asks', at: at(-1, 16), state: 'open', draft: { lane: 'feature', confidence: 0.72, anchor_suggestion: 'KR 2.1 Activation to 45%', prior_rejections: [{ id: 'IDPF-5', title: 'SSO in trial', why: 'security review cost' }] } },
128
- { id: 'ask-2', board: 'pay', line: 'Bulk CSV export of invoices', source: 'Sari Wijaya (Support), Jira Service Desk', at: at(-2, 9), state: 'open', draft: { lane: 'feature', confidence: 0.81, anchor_suggestion: 'KR 3.1 Payments revenue +18%', prior_rejections: [] } },
129
- { id: 'ask-3', board: 'idpf', line: 'Webhook retries for Partner X', source: 'Raj Mehta (Partner), email', at: at(-4, 11), state: 'open', needMore: true, moreNote: 'Which webhooks fail, and how often?', draft: { lane: 'incident', confidence: 0.55, anchor_suggestion: 'KR 1.3 Partner uptime 99.9%', prior_rejections: [] } },
130
- { id: 'ask-4', board: 'office', line: 'Parking for 40 cars at the new office', source: 'Gita Rahma (Ops), meeting note', at: at(-4, 15), state: 'open', draft: { lane: 'chore', confidence: 0.64, anchor_suggestion: 'Project milestone: Move weekend', prior_rejections: [] } },
131
- ];
132
- const releases = [
133
- { id: 'rel-pay-14', board: 'pay', name: 'Tokenisation 1.4', date: D(7), status: 'Ready', scope: ['PAY-03'] },
134
- { id: 'rel-idpf-31', board: 'idpf', name: 'IDPF 3.1 · Onboarding beta', date: D(22), status: 'At risk', scope: ['IDPF-12'] },
135
- { id: 'rel-idpf-32', board: 'idpf', name: 'IDPF 3.2 · Rate limits', date: D(56), status: 'Planned', scope: ['IDPF-07'] },
136
- { id: 'rel-idpf-30', board: 'idpf', name: 'IDPF 3.0 · Partner keys', date: D(-21), status: 'Released', scope: ['IDPF-07', 'IDPF-12'] },
137
- ];
138
- const events = [
139
- { at: at(-5, 10), by: 'You', kind: 'move', board: 'idpf', id: 'IDPF-07', from: 'Discover', to: 'Plan', why: '', warnings: [] },
140
- { at: at(-4, 9), by: 'You', kind: 'workflow', board: 'idpf', id: 'IDPF-21', template: 'research', stages: INI_TEMPLATES.research.stages.map((s) => s.name) },
141
- { at: at(-3, 14), by: 'You', kind: 'move', board: 'idpf', id: 'IDPF-12', from: 'Discover', to: 'Build & Deliver', why: 'Beta needs a build now', warnings: ['Skipped Plan'] },
142
- { at: at(-2, 11), by: 'Eko Prasetyo', kind: 'move', board: 'pay', id: 'PAY-03', from: 'Plan', to: 'Build & Deliver', why: '', warnings: [] },
143
- { at: at(-1, 15), by: 'Gita Rahma', kind: 'move', board: 'office', id: 'OFF-01', from: 'Plan', to: 'Execute', why: '', warnings: [] },
144
- { at: at(-1, 17), by: 'You', kind: 'move', board: 'hiring', id: 'HIR-04', from: 'To do', to: 'Doing', why: 'Two candidates at final round', warnings: [] },
145
- ];
146
- /* Jira items mirrored from the board's Jira project (Build and deliver boards). The real mirror has no dates or people; the demo
147
- * gives them both so the Timeline has something to draw. s and e are day offsets from today. */
148
- const J = (key, kind, ini, epic, title, status, owner, s, e) => ({ key, kind, ini, epic, title, status, owner, start: s == null ? null : D(s), end: e == null ? null : D(e) });
149
- const jira = [
150
- J('IDPF-1160', 'Epic', 'IDPF-12', null, 'Guided setup flow', 'In progress', 'Budi Santoso'),
151
- J('IDPF-1170', 'Story', 'IDPF-12', 'IDPF-1160', 'Setup step 1: workspace name', 'Done', 'Budi Santoso', -38, -26),
152
- J('IDPF-1175', 'Story', 'IDPF-12', 'IDPF-1160', 'Setup step 2: first API key', 'Done', 'Budi Santoso', -24, -10),
153
- J('IDPF-1161', 'Epic', 'IDPF-12', null, 'Provisioning and beta', 'In progress', 'Ana Putri'),
154
- J('IDPF-1182', 'Story', 'IDPF-12', 'IDPF-1161', 'Workspace provisioning API', 'In progress', 'Ana Putri', -12, 4),
155
- J('IDPF-1186', 'Bug', 'IDPF-12', 'IDPF-1161', 'Provisioning retries on timeout', 'In review', 'Ana Putri', -6, 3),
156
- J('IDPF-1190', 'Task', 'IDPF-12', 'IDPF-1161', 'QA test plan for beta', 'Blocked', 'Ana Putri', -5, 2),
157
- J('IDPF-1201', 'Story', 'IDPF-12', 'IDPF-1161', 'Beta invite emails', 'To do', 'Chen Wei', 5, 12),
158
- J('IDPF-1209', 'Epic', 'IDPF-07', null, 'Partner rate limiting', 'To do', 'Ana Putri'),
159
- J('IDPF-1210', 'Task', 'IDPF-07', 'IDPF-1209', 'Spike: token bucket per partner', 'Done', 'Ana Putri', -14, -5),
160
- J('IDPF-1214', 'Story', 'IDPF-07', 'IDPF-1209', '429 response with a Retry-After header', 'To do', 'Ana Putri', 14, 30),
161
- J('IDPF-1215', 'Story', 'IDPF-07', 'IDPF-1209', 'Rate-limit dashboard for partners', 'To do', 'Budi Santoso', 20, 40),
162
- J('PAY-400', 'Epic', 'PAY-03', null, 'Network tokens', 'In progress', 'Eko Prasetyo'),
163
- J('PAY-401', 'Story', 'PAY-03', 'PAY-400', 'Network token provisioning', 'Done', 'Eko Prasetyo', -60, -30),
164
- J('PAY-405', 'Story', 'PAY-03', 'PAY-400', 'Migrate stored cards', 'Done', 'Eko Prasetyo', -35, -8),
165
- J('PAY-410', 'Task', 'PAY-03', 'PAY-400', 'Release notes 1.4', 'To do', 'You', 0, 3),
166
- J('PAY-412', 'Bug', 'PAY-03', 'PAY-400', 'Remove card digits from a log line', 'In progress', 'Eko Prasetyo', -2, 2),
167
- ];
168
- /* PMOS epics and tasks (the team's tasks; home: Initiative · Breakdown). A task's epic may be a Jira epic or a PMOS epic. */
169
- const K = (id, board, ini, title, owner, state, s, e, epic, kind) => ({ id, board, initiative: ini, title, owner, state: state || 'To do', start: D(s), due: D(e), epic: epic || null, kind: kind || 'Task', history: [] });
170
- const tasks = [
171
- K('t-idpf-1', 'idpf', 'IDPF-12', 'Agree the beta invite list with Sales', 'You', 'In progress', -4, 3, 'IDPF-1161'),
172
- K('t-idpf-2', 'idpf', 'IDPF-12', 'Brief Support on the new setup flow', 'Sari Wijaya', 'To do', 6, 12),
173
- K('t-idpf-3', 'idpf', 'IDPF-21', 'Write the interview guide for billing calls', 'You', 'In progress', -3, 4),
174
- K('t-idpf-4', 'idpf', 'IDPF-21', 'Book five interviews with large API users', 'You', 'To do', 2, 14),
175
- K('t-gro-1', 'growth', 'GRO-02', 'Pull partner admin login data', 'Chen Wei', 'To do', 3, 10),
176
- K('t-gro-2', 'growth', 'GRO-02', 'Draft the first digest email', 'You', 'To do', 9, 16),
177
- K('e-off-1', 'office', 'OFF-01', 'Bids and selection', 'Gita Rahma', 'To do', -30, -2, null, 'Epic'),
178
- K('e-off-2', 'office', 'OFF-01', 'Contract', 'Tom Hartono', 'To do', -4, 10, null, 'Epic'),
179
- K('t-off-1', 'office', 'OFF-01', 'Compare the three fit-out bids', 'Gita Rahma', 'Done', -25, -10, 'e-off-1'),
180
- K('t-off-2', 'office', 'OFF-01', 'Site visits with two contractors', 'Gita Rahma', 'Done', -12, -4, 'e-off-1'),
181
- K('t-off-3', 'office', 'OFF-01', 'Legal review of the contract', 'Tom Hartono', 'In progress', -3, 4, 'e-off-2'),
182
- K('t-off-4', 'office', 'OFF-01', 'Sign the contract', 'Gita Rahma', 'To do', 4, 8, 'e-off-2'),
183
- K('t-hir-1', 'hiring', 'HIR-04', 'Schedule the two final rounds', 'You', 'In progress', -4, 2),
184
- K('t-hir-2', 'hiring', 'HIR-04', 'Reference checks for the finalists', 'Ana Putri', 'To do', 3, 10),
185
- K('t-hir-3', 'hiring', 'HIR-04', 'Write the offer letter', 'You', 'To do', 9, 13),
186
- ];
187
- /* stage records (the stage-records routes' shapes: /api/stage-tools/records, rice, burndown), keyed initiative -> tool -> { data, at, by } */
188
- const R = (data, n) => ({ data, at: at(n, 10), by: 'You' });
189
- const records = {
190
- 'IDPF-12': { problem: R({ text: 'New workspaces wait two days for a sales-assisted setup, and 38% of trials never make a first API call.' }, -30), rice: R({ reach: 1400, impact: 2, confidence: 80, effort: 4 }, -20),
191
- launch: R({ items: [{ id: 'l1', text: 'Beta invite list agreed with Sales', done: true }, { id: 'l2', text: 'Support briefed on the new setup flow', done: false }, { id: 'l3', text: 'Rollback plan for provisioning', done: false }, { id: 'l4', text: 'Status page entry drafted', done: false }] }, -2),
192
- kill: R({ items: [{ id: 'k1', text: 'Activation below 35% four weeks after beta', status: 'watching' }] }, -10) },
193
- 'IDPF-07': { rice: R({ reach: 600, impact: 3, confidence: 70, effort: 3 }, -6) },
194
- 'IDPF-21': { problem: R({ text: 'Large API users pay a flat fee and small ones overpay, so neither group expands. We do not yet know how they forecast spend.' }, -4) },
195
- 'PAY-03': { rice: R({ reach: 900, impact: 2, confidence: 90, effort: 6 }, -50), launch: R({ items: [{ id: 'l1', text: 'PCI assessor sign-off', done: true }, { id: 'l2', text: 'Release notes 1.4', done: false }, { id: 'l3', text: 'Card digits removed from logs', done: false }] }, -1) },
196
- 'GRO-02': { problem: R({ text: 'Partner admins only log in when something breaks, so they miss new features and usage trends.' }, -1) },
197
- 'OFF-01': { launch: R({ items: [{ id: 'l1', text: 'Three bids compared', done: true }, { id: 'l2', text: 'Legal review of the contract', done: false }, { id: 'l3', text: 'Contract signed', done: false }] }, -3), learnings: R({ items: [{ id: 'n1', text: 'Ask for fixed-price bids first: two of three changed their price after the site visit.', date: D(-6) }] }, -6) },
198
- };
199
- /* c3-initiative-lifecycle: a likely duplicate, one on hold, one cancelled, two archived (one merged into IDPF-07) */
200
- const L = (id, title, stage, owner, anchor, horizon, status, s, e, progress, extra) => Object.assign(I(id, 'idpf', title, stage, owner, anchor, horizon, status, s, e, progress, 'feature', false), { featured: false }, extra || {});
201
- rows.push(
202
- L('IDPF-151', 'Guided self-serve setup for new workspaces', 'Discover', 'Lina Kusuma', 'KR 2.1 Activation to 45%', 'next', 'on track', -3, 60, 0.05, { dupOf: 'IDPF-12' }),
203
- L('IDPF-152', 'SAML SSO for enterprise trials', 'Plan', 'You', 'KR 3.2 Net revenue retention 115%', 'now', 'on hold', -30, 40, 0.3, { was: 'on track', stopped: { reason: 'Waiting for the Q1 budget decision', at: at(-11, 10), back: D(19) } }),
204
- L('IDPF-153', 'Sunset the v1 SDK', 'Build & Deliver', 'You', 'KR 1.3 Partner uptime 99.9%', 'now', 'cancelled', -50, 10, 0.4, { was: 'at risk', stopped: { reason: 'Not worth it now: three partners still on v1', at: at(-6, 10), back: null } }),
205
- L('IDPF-154', 'Refresh the marketing site footer', 'Discover', '', 'KR 2.3 WAU partners +20%', 'later', 'on track', -60, -20, 0, { archived: { at: at(-2, 10), by: 'You', reason: 'Not related to this board', into: null, moved: { epics: [], tasks: [] } } }),
206
- L('IDPF-155', 'Throttle bursty partner API calls', 'Discover', 'You', 'KR 1.3 Partner uptime 99.9%', 'now', 'on track', -20, 30, 0.05, { archived: { at: at(-4, 10), by: 'You', reason: 'Merged into Partner API rate limits', into: 'IDPF-07', moved: { epics: [], tasks: [] } } }),
207
- );
208
- tasks.push({ id: 'task-demo-l1', board: 'idpf', initiative: 'IDPF-151', title: 'Sketch the setup checklist', owner: 'Lina Kusuma', state: 'To do', start: D(1), due: D(8), epic: null, kind: 'Task', history: [] });
209
- return { boards, rows, asks, releases, events, jira, tasks, records, seq: 0, notDup: [] };
210
- }
211
-
212
- /* ── reads ── */
213
- const boardOf = (S, id) => S.boards.find((x) => x.id === id);
214
- const wfOf = (S, r) => r.workflow || boardOf(S, r.board).workflow;
215
- const catIn = (wf, stage) => ((wf.find((s) => s.name === stage) || {}).cat) || 'Plan';
216
- const catOfRow = (S, r) => catIn(wfOf(S, r), r.stage);
217
- const tplEdited = (b) => !INI_TEMPLATES[b.template] || !sameFlow(tplStages(b.template), b.workflow);
218
- const ACTIVE = ['on track', 'at risk', 'late'];
219
- const isOpen = (r) => ACTIVE.includes(r.status) && !r.archived; // on hold, done, cancelled and archived are not open
220
- const live = (r) => !r.archived;
221
- const mergedFrom = (S, id) => S.rows.filter((x) => x.archived && x.archived.into === id).map((x) => x.id);
222
- const nextRelease = (S, bid) => S.releases.filter((x) => x.board === bid && x.date >= TODAY).sort((a, c) => (a.date < c.date ? -1 : 1))[0] || null;
223
- const openAsks = (S, bid) => S.asks.filter((a) => a.board === bid && a.state === 'open').length;
224
- function rowOut(S, r) {
225
- const wf = wfOf(S, r);
226
- return { id: r.id, title: r.title, lane: r.lane, stage: r.stage, cat: catIn(wf, r.stage), owner: r.owner || null, anchor: r.anchor, horizon: r.horizon, status: r.status, start: r.start, end: r.end, progress: r.progress,
227
- warnings: r.warnings.slice(), template: r.template || null, workflow: wf.map((s) => ({ name: s.name, cat: s.cat })), epics: (r.epics || []).slice(), epicsFrom: r.epics ? 'pmos' : null,
228
- lifecycle: r.stopped ? (r.status === 'on hold' ? 'on-hold' : 'cancelled') : null, stopped: r.stopped ? { ...r.stopped } : null,
229
- archived: r.archived ? { ...r.archived, intoTitle: r.archived.into ? (S.rows.find((x) => x.id === r.archived.into) || {}).title || r.archived.into : undefined } : null,
230
- mergedFrom: mergedFrom(S, r.id), dupOf: r.dupOf && !r.archived && ACTIVE.includes(r.status) && !(S.notDup || []).includes(r.id + '|' + r.dupOf) ? r.dupOf : null };
231
- }
232
- function boardOut(S, b) {
233
- const list = S.rows.filter((r) => r.board === b.id && live(r));
234
- const byCat = Object.fromEntries(CATS.map((c) => [c, 0]));
235
- for (const r of list) byCat[catOfRow(S, r)]++;
236
- const rel = nextRelease(S, b.id);
237
- return { ws: b.ws, id: b.id, name: b.name, full: b.full, domain: b.domain, template: b.template, templateEdited: tplEdited(b), workflow: b.workflow.map((s) => ({ ...s })), self: b.self, tracker: b.tracker, sprints: b.sprints,
238
- build: b.build, buildDeliver: b.build, jira: b.jira, jiraProjects: b.build && b.jira ? (b.jiraProjects || [b.jira]).slice() : [], offer: b.offer.slice(), defTpl: b.defTpl, owner: b.owner, health: b.health,
239
- counts: { total: list.length, open: list.filter(isOpen).length, byCat, risk: list.filter((r) => r.status === 'at risk').length, late: list.filter((r) => r.status === 'late').length },
240
- asks: openAsks(S, b.id), nextRelease: rel ? { id: rel.id, name: rel.name, at: rel.date, date: rel.date, status: rel.status } : null };
241
- }
242
- const H = { now: 0, next: 1, later: 2 };
243
- const SS = { late: 0, 'at risk': 1, 'on track': 2, 'on hold': 3, done: 4, cancelled: 5 };
244
- /** The saved view and the search, as the server applies them (the base the facets count). */
245
- function viewRows(S, b, p) {
246
- const q = String(p.q || '').trim().toLowerCase();
247
- const archive = p.archived === '1';
248
- const view = archive ? 'all' : (p.view || 'now');
249
- const given = !!p.status; // a status filter overrides the view's own status rule
250
- const act = (r) => given || isOpen(r);
251
- return S.rows.filter((r) => {
252
- if (r.board !== b.id || !!r.archived !== archive) return false;
253
- if (view === 'now' && (!['now', 'next'].includes(r.horizon) || !act(r))) return false;
254
- if (view === 'mine' && (r.owner !== 'You' || !act(r))) return false;
255
- if (view === 'risk' && !given && !['at risk', 'late'].includes(r.status)) return false;
256
- if (view === 'noowner' && (r.owner || !act(r))) return false;
257
- if (q && !(r.id + ' ' + r.title + ' ' + r.anchor + ' ' + r.owner).toLowerCase().includes(q)) return false;
258
- return true;
259
- });
260
- }
261
- /** Then each named filter (a value or a comma list; 'none' for an empty owner or anchor), as scripts/boards.js filterRows does. */
262
- const asksCancelled = (p) => p.archived === '1' || String(p.status || '').split(',').map((x) => x.trim()).includes('cancelled');
263
- function filterRows(S, b, p) {
264
- return viewRows(S, b, p).filter((r) => asksCancelled(p) || r.status !== 'cancelled').filter((r) => {
265
- const has = (want, v) => !want || String(want).split(',').map((x) => x.trim().toLowerCase()).includes(String(v || 'none').toLowerCase());
266
- return has(p.stage, r.stage) && has(p.cat, catOfRow(S, r)) && has(p.status, r.status) && has(p.owner, r.owner) && has(p.horizon, r.horizon) && has(p.anchor, r.anchor);
267
- });
268
- }
269
- function sortRows(S, list, sort) {
270
- const desc = String(sort || '').startsWith('-'); const key = String(sort || 'horizon').replace(/^-/, '');
271
- const num = (id) => Number(String(id).split('-').pop()) || 0;
272
- const stageAt = (r) => { const wf = wfOf(S, r); return wf.findIndex((s) => s.name === r.stage) / Math.max(1, wf.length - 1); };
273
- const val = { id: (r) => num(r.id), title: (r) => r.title.toLowerCase(), stage: stageAt, status: (r) => SS[r.status] ?? 9, progress: (r) => r.progress,
274
- owner: (r) => (r.owner ? r.owner.toLowerCase() : '~'), horizon: (r) => (H[r.horizon] ?? 9) * 1e9 + Number(r.end.replace(/-/g, '')), rank: (r) => (H[r.horizon] ?? 9) * 1e9 + Number(r.end.replace(/-/g, '')), end: (r) => r.end, start: (r) => r.start }[key] || ((r) => num(r.id));
275
- return list.slice().sort((a, c) => { const x = val(a); const y = val(c); return ((x < y ? -1 : x > y ? 1 : 0) * (desc ? -1 : 1)) || (c.featured - a.featured) || (num(a.id) - num(c.id)); });
276
- }
277
- const tally = (list, f) => { const o = {}; for (const r of list) { const k = f(r); o[k] = (o[k] || 0) + 1; } return o; };
278
-
279
- /* ── work items: Jira items (Build and deliver boards) and PMOS tasks, epics rolled up ── */
280
- const itemStatus = (s) => (/review/i.test(s) ? 'In review' : /progress|block/i.test(s) ? 'In progress' : /done|closed/i.test(s) ? 'Done' : 'To do');
281
- const taskItem = (t) => ({ uid: t.id, key: '', kind: t.kind === 'Epic' ? 'Epic' : 'Task', src: 'pmos', title: t.title, status: t.state, blocked: false, owner: t.owner || null, ini: t.initiative, epic: t.epic || null, start: t.start || null, end: t.due || null, ref: t.id, board: t.board });
282
- function rollup(items) {
283
- for (const w of items) w.progress = PROG[w.status] || 0;
284
- for (const e of items.filter((w) => w.kind === 'Epic')) {
285
- const kids = items.filter((w) => w.epic && w.epic === e.uid);
286
- if (!kids.length) continue;
287
- e.progress = Math.round((kids.reduce((n, w) => n + w.progress, 0) / kids.length) * 100) / 100;
288
- e.status = kids.every((w) => w.status === 'Done') ? 'Done' : kids.some((w) => w.status !== 'To do') ? 'In progress' : 'To do';
289
- e.blocked = kids.some((w) => w.blocked);
290
- const ds = kids.map((w) => w.start).filter(Boolean).sort(); const de = kids.map((w) => w.end).filter(Boolean).sort();
291
- if (!e.start && ds.length) e.start = ds[0];
292
- if (!e.end && de.length) e.end = de[de.length - 1];
293
- }
294
- return items;
295
- }
296
- function itemsOf(S, b) {
297
- const ids = new Set(S.rows.filter((r) => r.board === b.id).map((r) => r.id));
298
- const out = [];
299
- if (b.build) for (const j of S.jira) if (ids.has(j.ini)) out.push({ uid: j.key, key: j.key, kind: j.kind, src: 'jira', title: j.title, status: itemStatus(j.status), blocked: /block/i.test(j.status), owner: j.owner, ini: j.ini, epic: j.epic, start: j.start, end: j.end, ref: null, board: b.id });
300
- for (const t of S.tasks) if (t.board === b.id && ids.has(t.initiative)) out.push(taskItem(t));
301
- return rollup(out);
302
- }
303
-
304
- /* ── the order rules: warnings, never a block (scripts/boards.js moveWarnings, on the initiative's own workflow) ── */
305
- function orderWarnings(wf, r, from, to) {
306
- const out = []; const fi = wf.findIndex((s) => s.name === from); const ti = wf.findIndex((s) => s.name === to);
307
- if (fi >= 0 && ti > fi + 1) for (const s of wf.slice(fi + 1, ti)) out.push('Skipped ' + s.name);
308
- if (catIn(wf, to) === 'Do' && r.lane === 'feature' && !r.spec) out.push('No spec yet');
309
- if (!r.anchor) out.push('No anchor');
310
- return out;
311
- }
312
- /** A workflow edit (names, categories, was): { ok, workflow, renamed } or { ok: false, error }. */
313
- function checkStages(stagesIn) {
314
- const stages = Array.isArray(stagesIn) ? stagesIn.map((s) => ({ name: String((s && s.name) || '').trim(), cat: s && s.cat, hint: (s && s.hint) || '', was: (s && s.was) || null })) : [];
315
- if (!stages.length) return { ok: false, error: 'A workflow needs at least one stage.' };
316
- if (stages.some((s) => !s.name)) return { ok: false, error: 'Every stage needs a name.' };
317
- if (new Set(stages.map((s) => s.name.toLowerCase())).size !== stages.length) return { ok: false, error: 'Two stages have the same name.' };
318
- if (stages.some((s) => !CATS.includes(s.cat))) return { ok: false, error: 'Each stage needs a category: Discover, Plan, Do or Learn.' };
319
- return { ok: true, stages };
320
- }
321
-
322
- const fail = (status, error) => ({ status, body: { ok: false, error } });
323
- const okb = (body) => ({ status: 200, body: { ok: true, ...body } });
324
-
325
- /** One request. Returns { status, body } or undefined when the path is not a boards route. */
326
- export function handle(S, method, path, p, body) {
327
- if (path.startsWith('/api/stage-tools')) return handleTools(S, method, path, p, body || {});
328
- if (!path.startsWith('/api/boards') && path !== '/api/lifecycle') return handleMore(S, method, path, p);
329
- const findBoard = (ws, id) => { const b = S.boards.find((x) => x.id === id); return b && (!ws || ws === b.ws) ? b : null; };
330
- if (method === 'GET') {
331
- if (path === '/api/boards') return okb({ today: TODAY, boards: S.boards.map((b) => boardOut(S, b)) });
332
- const b = findBoard(p.ws, p.board);
333
- if (!b && path !== '/api/boards/asks') return fail(404, 'No board "' + (p.board || '') + '" in this workspace.');
334
- if (path === '/api/boards/board') {
335
- const list = S.rows.filter((r) => r.board === b.id && live(r));
336
- const byStage = {};
337
- for (const r of list) byStage[r.stage] = (byStage[r.stage] || 0) + 1;
338
- const rel = nextRelease(S, b.id);
339
- const recent = S.events.filter((e) => e.board === b.id && e.kind === 'move').slice(-10).reverse().map((e) => ({ ...e, title: (S.rows.find((r) => r.id === e.id) || {}).title || '' }));
340
- const bo = boardOut(S, b);
341
- return okb({ board: bo, counts: { total: list.length, open: bo.counts.open, byStage, byStatus: tally(list, (r) => r.status), byCat: bo.counts.byCat }, asks: openAsks(S, b.id), nextRelease: bo.nextRelease, recent, release: rel });
342
- }
343
- if (path === '/api/boards/backlog') {
344
- const list = sortRows(S, filterRows(S, b, p), p.sort);
345
- const base0 = viewRows(S, b, p);
346
- const offset = Math.max(0, Number(p.offset) || 0); const limit = Math.min(100, Math.max(1, Number(p.limit) || 25));
347
- return okb({ view: p.archived === '1' ? 'all' : p.view || 'now', total: list.length, offset, limit, rows: list.slice(offset, offset + limit).map((r) => rowOut(S, r)),
348
- cancelledHidden: asksCancelled(p) ? 0 : S.rows.filter((r) => r.board === b.id && live(r) && r.status === 'cancelled').length,
349
- archived: p.archived === '1' ? list.length : S.rows.filter((r) => r.board === b.id && r.archived).length,
350
- facets: { stage: tally(base0, (r) => r.stage), status: tally(base0, (r) => r.status), owner: tally(base0, (r) => r.owner || 'none'), horizon: tally(base0, (r) => r.horizon),
351
- anchor: tally(base0, (r) => r.anchor || 'none'), cat: tally(base0, (r) => catOfRow(S, r)) } });
352
- }
353
- if (path === '/api/boards/initiative') {
354
- const r = S.rows.find((x) => x.id === p.id && x.board === b.id);
355
- if (!r) return fail(404, 'No initiative "' + (p.id || '') + '" on ' + b.name + '.');
356
- const row = rowOut(S, r);
357
- const kind = r.template ? INI_TEMPLATES[r.template].kind : (TOOLS[b.template] ? b.template : 'product');
358
- const byCat = TOOLS[kind] || TOOLS.product;
359
- const history = S.events.filter((e) => e.id === r.id).slice().reverse();
360
- return okb({ row, board: boardOut(S, b), history, tools: byCat[row.cat] || [], toolsByCat: byCat });
361
- }
362
- if (path === '/api/boards/asks') {
363
- const state = p.state || 'open';
364
- return okb({ asks: S.asks.filter((a) => (!b || a.board === b.id) && (state === 'all' || a.state === state)).map((a) => ({ ...a })) });
365
- }
366
- if (path === '/api/boards/anchors') {
367
- const krs = Object.keys(KR).map((k) => ({ value: 'KR ' + k + ' ' + KR[k], kind: 'kr', group: 'Objective ' + k.split('.')[0], label: 'KR ' + k + ' ' + KR[k] }));
368
- const health = [['tech', 'refactors, debt, tooling'], ['security', 'hardening, rotations, audits'], ['ops', 'pipelines, deploys, monitoring']]
369
- .map(([id, covers]) => ({ value: 'health:' + id, kind: 'health', group: 'Health budgets', label: 'health:' + id + ' (' + covers + ')' }));
370
- return okb({ board: b.id, anchors: [...krs, ...health], error: null });
371
- }
372
- if (path === '/api/boards/items') {
373
- const list = S.rows.filter((r) => r.board === b.id && live(r));
374
- return okb({ board: b.id, build: b.build, jira: b.jira, items: itemsOf(S, b),
375
- initiatives: list.map((r) => { const o = rowOut(S, r); return { id: o.id, title: o.title, stage: o.stage, cat: o.cat, status: o.status, owner: o.owner, horizon: o.horizon, start: o.start, end: o.end, progress: o.progress, template: o.template, featured: r.featured }; }) });
376
- }
377
- if (path === '/api/boards/sprints') {
378
- if (!b.tracker || !b.sprints) return okb({ source: 'none', readAt: null, sprints: [] });
379
- const key = b.prefix;
380
- const own = S.rows.filter((r) => r.board === b.id && catOfRow(S, r) === 'Do' && isOpen(r)).slice(0, 6);
381
- const ST = [['To Do', 'todo'], ['In Progress', 'doing'], ['In Review', 'doing'], ['Done', 'done']];
382
- const mirrored = S.jira.filter((j) => j.kind !== 'Epic' && own.concat(S.rows.filter((r) => r.featured)).some((r) => r.id === j.ini) && S.rows.find((r) => r.id === j.ini).board === b.id);
383
- const fromJira = mirrored.map((j) => ({ key: j.key, summary: j.title, status: j.status, category: /done/i.test(j.status) ? 'done' : /to do/i.test(j.status) ? 'todo' : 'doing', initiative: j.ini }));
384
- const issues = fromJira.concat(Array.from({ length: Math.max(0, 12 - fromJira.length) }, (_, k) => { const s = ST[hash(key + k) % 4]; const ini = own[k % Math.max(1, own.length)]; return { key: key + '-' + (1370 + k), summary: (ini ? ini.title : 'Sprint work') + ': part ' + (k + 1), status: s[0], category: s[1], initiative: ini ? ini.id : null }; }));
385
- const counts = { todo: issues.filter((i) => i.category === 'todo').length, doing: issues.filter((i) => i.category === 'doing').length, done: issues.filter((i) => i.category === 'done').length };
386
- const num = key === 'IDPF' ? 42 : 19;
387
- const extra = (k, state, name, cat, n) => { const is = Array.from({ length: n }, (_, i) => ({ key: key + '-' + (1100 + k * 20 + i), summary: (own[i % Math.max(1, own.length)] || { title: 'Sprint work' }).title + ': part ' + (i + 1), status: cat === 'done' ? 'Done' : 'To Do', category: cat, initiative: (own[i % Math.max(1, own.length)] || {}).id || null })); return { name, state, issues: is, counts: { todo: cat === 'todo' ? n : 0, doing: 0, done: cat === 'done' ? n : 0 } }; };
388
- // The goal and summary the Jira status check writes (sprint-goal-summary). The goal is always written from the tickets;
389
- // Jira's goal, when it has one, is a reference. The closed sprint was summarised once.
390
- const ini0 = own[0] ? own[0].id : null;
391
- const themes = [{ title: own[0] ? own[0].title : 'Sprint work', line: 'Most items are in progress or in review.', tickets: issues.filter((i) => i.initiative === ini0).length || 1, done: issues.filter((i) => i.initiative === ini0 && i.category === 'done').length, blocked: 1, people: 'Ana, Budi', initiative: ini0 },
392
- { title: 'Fixes and upkeep', line: 'Small fixes outside any initiative.', tickets: 2, done: 1, blocked: 0, people: 'Chen', initiative: null }];
393
- const act = { name: key + ' Sprint ' + num, state: 'active', issues, counts, goal: { from: 'tickets', text: 'Get the first initiative ready for internal users and clear the blocked work.', jira: 'Q4 delivery' },
394
- summary: 'Most of the sprint is on the first initiative. One item is blocked. Two small fixes sit outside any initiative.', themes, writtenAt: TODAY + 'T06:30:00Z', summarisedTickets: issues.length, closed: null, frozen: false,
395
- brief: { health: 'warn', verdict: 'At risk. Halfway through, 21 of 48 points are done. The team finishes about 27 points a sprint, so about 12 points will carry over unless scope is cut now. The blocked QA plan is the exposed part.',
396
- issues: [{ sev: 'bad', title: 'QA test plan for the beta is blocked', keys: key + '-1373', initiative: ini0, why: 'Flagged in Jira for 4 days: no QA tester is free this sprint. The beta cannot start without it.', by: 'Decide today',
397
- plan: ['Ask the QA lead whether another team can lend a tester for 3 days this week.', 'If yes, the tester writes the plan by Thursday and the beta keeps its date.', 'If no, move the beta by two weeks and tell the pilot customers this week.'], doneWhen: 'The ticket leaves Blocked with a named tester and a date.' },
398
- { sev: 'warn', title: 'Code expiry has sat in review for 3 days', keys: key + '-1371', initiative: ini0, why: 'Review is the slowest step this sprint.', by: 'Raise at stand-up', plan: ['Ask at stand-up for a second reviewer this week.'], doneWhen: 'The ticket is merged.' }],
399
- done: [{ title: 'Rate limiting approach chosen', keys: key + '-1370', initiative: ini0, line: 'Unblocks the build next sprint.', waiting: false }, { title: 'Footer shows the right year', keys: key + '-1379', initiative: null, line: 'Waiting for the next release to reach Prod.', waiting: true }],
400
- asks: ['Decide how the beta gets QA: borrow a tester, or move the beta date.', 'Cut about 12 points now, starting with the lowest-value tickets.'] },
401
- points: { committed: 48, done: 21, unestimated: 2 }, flow: [{ status: 'To Do', category: 'todo', n: counts.todo }, { status: 'In Progress', category: 'doing', n: counts.doing }, { status: 'Done', category: 'done', n: counts.done }].filter((f) => f.n),
402
- pace: { day: 7, days: 14, daysLeft: 8, avg: 27, hitRate: 0.77, forecast: 36 } };
403
- const fut = { ...extra(1, 'future', key + ' Sprint ' + (num + 1), 'todo', 3), goal: { from: 'tickets', text: 'Finish the first initiative and start the beta.', jira: null }, summary: 'Planned so far: three follow-up items.', themes: [], writtenAt: TODAY + 'T06:30:00Z', closed: null, frozen: false };
404
- const old = { ...extra(0, 'closed', key + ' Sprint ' + (num - 1), 'done', 5), goal: { from: 'tickets', text: 'Start the first initiative.', jira: null }, summary: 'Goal met. Five items shipped; two moved to the next sprint.', themes: [{ title: 'Sprint work', line: '', tickets: 5, done: 5, blocked: 0, people: '', initiative: ini0 }],
405
- writtenAt: '2026-09-29T06:30:00Z', closed: { done: 5, total: 7, carried: 2, carriedTo: key + ' Sprint ' + num, points: '21 of 26' }, frozen: true, hit: 'met', got: 'The code entry screen waited 5 days on design.' };
406
- const velocity = [{ name: key + ' Sprint ' + (num - 4), committed: 33, done: 24 }, { name: key + ' Sprint ' + (num - 3), committed: 36, done: 28 }, { name: key + ' Sprint ' + (num - 2), committed: 34, done: 26 }, { name: key + ' Sprint ' + (num - 1), committed: 38, done: 30 }];
407
- return okb({ source: 'jira', readAt: TODAY + 'T08:10:00', sprints: [act, fut, old], velocity });
408
- }
409
- return fail(404, 'No route ' + path);
410
- }
411
- /* POST */
412
- const ws = body.ws;
413
- if (path === '/api/lifecycle') {
414
- // D70 in the demo: on-hold, cancelled or active (the server writes one lifecycle.jsonl line; here the row changes in memory)
415
- const r = S.rows.find((x) => x.id === body.initiative_id);
416
- if (!r) return fail(404, "no initiative '" + (body.initiative_id || '') + "' in demo");
417
- if (!['on-hold', 'cancelled', 'closed', 'active'].includes(body.state)) return fail(400, 'state must be one of closed, on-hold, cancelled, active');
418
- if (body.back != null && (body.state !== 'on-hold' || !/^\d{4}-\d{2}-\d{2}$/.test(String(body.back)))) return fail(400, 'back is a day (YYYY-MM-DD) and only goes with on-hold');
419
- if (!r.stopped) r.was = r.status;
420
- if (body.state === 'active') { r.status = r.was || 'on track'; r.stopped = null; }
421
- else { r.status = body.state === 'on-hold' ? 'on hold' : body.state === 'closed' ? 'done' : 'cancelled'; r.stopped = { reason: String(body.reason || ''), at: at(0, 8), back: body.back || null }; }
422
- S.events.push({ at: at(0, 8), by: 'You', kind: 'lifecycle', id: r.id, state: body.state, reason: body.reason || '' });
423
- return okb({ recorded: { initiative_id: r.id, state: body.state } });
424
- }
425
- if (path === '/api/boards/archive' || path === '/api/boards/merge' || path === '/api/boards/notdup') {
426
- const bb = findBoard(ws, body.board);
427
- if (!bb) return fail(404, 'No board "' + (body.board || '') + '" in this workspace.');
428
- const on = (id) => S.rows.find((x) => x.id === id && x.board === bb.id);
429
- const r = on(body.id);
430
- if (!r) return fail(404, 'no initiative ' + (body.id || '') + ' on this board');
431
- if (path === '/api/boards/notdup') { S.notDup.push(r.id + '|' + body.of); return okb({}); }
432
- if (path === '/api/boards/archive') {
433
- if (typeof body.archived !== 'boolean') return fail(400, 'archived is true (archive) or false (restore)');
434
- if (body.archived && r.archived) return fail(409, r.id + ' is archived already');
435
- if (!body.archived && !r.archived) return fail(409, r.id + ' is not archived');
436
- if (!body.archived && r.archived.into) {
437
- const t = on(r.archived.into); const mv = r.archived.moved || { epics: [], tasks: [] };
438
- if (t && mv.epics.length) { t.epics = (t.epics || []).filter((k) => !mv.epics.includes(k)); r.epics = [...new Set([...(r.epics || []), ...mv.epics])]; }
439
- for (const tk of S.tasks) if (mv.tasks.includes(tk.id) && tk.initiative === r.archived.into) tk.initiative = r.id;
440
- }
441
- r.archived = body.archived ? { at: at(0, 8), by: 'You', reason: String(body.reason || ''), into: null, moved: { epics: [], tasks: [] } } : null;
442
- S.events.push({ at: at(0, 8), by: 'You', kind: body.archived ? 'archive' : 'restore', board: bb.id, id: r.id });
443
- return okb({ row: rowOut(S, r) });
444
- }
445
- const t = on(body.into);
446
- if (body.id === body.into) return fail(400, 'an initiative cannot be merged into itself');
447
- if (!t) return fail(404, 'no initiative ' + (body.into || '') + ' on this board (an initiative merges into one on the same board)');
448
- if (r.archived) return fail(409, r.id + ' is archived already');
449
- const epics = (body.epics || []).filter((k) => (r.epics || []).includes(k)); const tks = (body.tasks || []).filter((id) => S.tasks.some((x) => x.id === id && x.initiative === r.id));
450
- if (epics.length) { t.epics = [...new Set([...(t.epics || []), ...epics])]; r.epics = (r.epics || []).filter((k) => !epics.includes(k)); }
451
- for (const tk of S.tasks) if (tks.includes(tk.id)) tk.initiative = t.id;
452
- r.archived = { at: at(0, 8), by: 'You', reason: 'Merged into ' + t.title, into: t.id, moved: { epics, tasks: tks } };
453
- S.events.push({ at: at(0, 8), by: 'You', kind: 'merge', board: bb.id, id: r.id, into: t.id });
454
- return okb({ row: rowOut(S, r), into: rowOut(S, t) });
455
- }
456
- if (path === '/api/boards/create') {
457
- const name = String(body.name || '').trim();
458
- if (!name) return fail(400, 'A board needs a name.');
459
- if (!['product', 'project', 'simple'].includes(body.template)) return fail(400, 'Pick a template: product, project or simple.');
460
- if (S.boards.some((x) => x.name.toLowerCase() === name.toLowerCase())) return fail(409, 'A board named "' + name + '" exists already in this workspace.');
461
- let id = (body.domain || name).toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '') || 'board';
462
- while (S.boards.some((x) => x.id === id)) id += '-2';
463
- const bd = body.buildDeliver != null ? body.buildDeliver : body.build;
464
- const build = typeof bd === 'boolean' ? bd : true;
465
- const allowed = Object.keys(INI_TEMPLATES).filter((k) => build || !templateBuilds(k));
466
- const jira = build && body.jira ? String(body.jira).trim().toUpperCase() : null;
467
- if (jira && !/^[A-Z][A-Z0-9_]{0,19}$/.test(jira)) return fail(400, 'jira is a Jira project key: a letter, then letters, digits or _ (at most 20)');
468
- const defTpl = allowed.includes(body.defTpl) ? body.defTpl : allowed.includes(body.template) ? body.template : allowed[0];
469
- const b = { ws: ws || WS_ID, id, name, full: name, domain: body.domain || id, template: body.template, workflow: tplStages(body.template), self: false, build, jira, tracker: jira ? 'Jira · ' + jira : null, sprints: !!jira,
470
- offer: allowed, defTpl, owner: 'You', health: 'ok', prefix: name.replace(/[^A-Za-z]/g, '').slice(0, 3).toUpperCase() || 'NEW' };
471
- S.boards.push(b);
472
- S.events.push({ at: at(0, 8), by: 'You', kind: 'board', board: id, name, template: body.template });
473
- return okb({ board: boardOut(S, b) });
474
- }
475
- const b = findBoard(ws, body.board);
476
- if (path === '/api/boards/assign') {
477
- const r = S.rows.find((x) => x.id === body.id); const to = findBoard(ws, body.to);
478
- if (!r || !to) return fail(404, !r ? 'No initiative "' + body.id + '".' : 'No board "' + body.to + '".');
479
- r.board = to.id; r.template = null; r.workflow = null; if (!to.workflow.some((s) => s.name === r.stage)) r.stage = to.workflow[0].name;
480
- S.events.push({ at: at(0, 8), by: 'You', kind: 'assign', board: to.id, id: r.id, to: to.id });
481
- return okb({});
482
- }
483
- if (!b) return fail(404, 'No board "' + (body.board || '') + '" in this workspace.');
484
- if (path === '/api/boards/settings') {
485
- if (b.self) return fail(409, 'The PMOS board follows the ladder its records derive.');
486
- const v = {};
487
- const bd = body.buildDeliver != null ? body.buildDeliver : body.build;
488
- if (bd != null) { if (typeof bd !== 'boolean') return fail(400, 'buildDeliver is true or false'); v.build = bd; }
489
- if (body.jira != null && body.jira !== '') {
490
- const keys = [].concat(body.jira).join(',').split(/[,\s]+/).filter(Boolean);
491
- if (!keys.length || keys.some((j) => !/^[A-Za-z][A-Za-z0-9_]{0,19}$/.test(j))) return fail(400, 'jira is one or more Jira project keys (at most 10), each a letter, then letters, digits or _ (at most 20)');
492
- v.jiraProjects = [...new Set(keys.map((j) => j.toUpperCase()))]; v.jira = v.jiraProjects[0];
493
- }
494
- const build = 'build' in v ? v.build : b.build;
495
- if (body.offer != null) {
496
- if (!Array.isArray(body.offer) || !body.offer.length || body.offer.some((k) => !INI_TEMPLATES[k])) return fail(400, 'offer is a list of templates: ' + Object.keys(INI_TEMPLATES).join(', '));
497
- const blocked = body.offer.filter((k) => !build && templateBuilds(k));
498
- if (blocked.length) return fail(400, blocked.join(', ') + ' need Build and deliver on');
499
- v.offer = [...new Set(body.offer)];
500
- }
501
- if (body.defTpl != null) {
502
- const offer = v.offer || b.offer.filter((k) => build || !templateBuilds(k));
503
- if (!offer.includes(body.defTpl)) return fail(400, 'defTpl must be a template the board offers (' + offer.join(', ') + ')');
504
- v.defTpl = body.defTpl;
505
- }
506
- if (!Object.keys(v).length) return fail(400, 'say what changes: buildDeliver, jira, offer or defTpl');
507
- Object.assign(b, v);
508
- if (!b.build) { b.offer = b.offer.filter((k) => !templateBuilds(k)); if (!b.offer.length) b.offer = ['simple']; if (!b.offer.includes(b.defTpl)) b.defTpl = b.offer[0]; }
509
- if (b.build && !b.jira) b.jira = b.prefix;
510
- if (!b.jiraProjects || !b.jiraProjects.includes(b.jira)) b.jiraProjects = b.jira ? [b.jira] : [];
511
- b.tracker = b.build && b.jira ? 'Jira · ' + b.jiraProjects.join(', ') : null; b.sprints = !!(b.build && b.jira);
512
- S.events.push({ at: at(0, 8), by: 'You', kind: 'board', op: 'settings', board: b.id, ...v });
513
- return okb({ board: boardOut(S, b) });
514
- }
515
- if (path === '/api/boards/workflow') {
516
- if (b.self) return fail(409, 'The PMOS board follows the ladder its records derive. Its stages cannot be edited.');
517
- const ck = checkStages(body.stages); if (!ck.ok) return fail(400, ck.error);
518
- const stages = ck.stages;
519
- if (!b.build && stages.some(isBuildStage)) return fail(400, 'Build and Deliver stages need a board with Build and deliver on; ' + b.name + ' has it off');
520
- const kept = new Map(stages.filter((s) => s.was && b.workflow.some((o) => o.name === s.was)).map((s) => [s.was, s.name]));
521
- const removed = b.workflow.filter((o) => !kept.has(o.name)).map((o) => o.name);
522
- const mr = body.moveRemoved || {};
523
- const own = (r) => r.board === b.id && !r.workflow;
524
- for (const name of removed) {
525
- const n = S.rows.filter((r) => own(r) && r.stage === name).length;
526
- if (n && !stages.some((s) => s.name === mr[name])) return fail(400, name + ' holds ' + n + ' initiatives. Say which stage they move to.');
527
- }
528
- let moved = 0;
529
- for (const r of S.rows) {
530
- if (!own(r)) continue;
531
- if (kept.has(r.stage)) { r.stage = kept.get(r.stage); continue; }
532
- if (removed.includes(r.stage)) { const to = mr[r.stage]; S.events.push({ at: at(0, 8), by: 'You', kind: 'move', board: b.id, id: r.id, from: r.stage, to, why: r.stage + ' was removed from the workflow', warnings: [] }); r.stage = to; moved++; }
533
- }
534
- b.workflow = stages.map((s) => ({ name: s.name, cat: s.cat, hint: s.hint }));
535
- if (['product', 'project', 'simple'].includes(body.template)) b.template = body.template;
536
- S.events.push({ at: at(0, 8), by: 'You', kind: 'board-workflow', board: b.id, stages: b.workflow, moved: mr });
537
- return okb({ board: boardOut(S, b), moved });
538
- }
539
- if (path === '/api/boards/ini-epics') {
540
- if (!b.build) return fail(409, b.name + ' has Build and deliver off, so it mirrors no Jira');
541
- const r = S.rows.find((x) => x.id === body.id && x.board === b.id);
542
- if (!r) return fail(404, 'no initiative ' + (body.id || '') + ' on this board');
543
- const keys = Array.isArray(body.epics) ? body.epics : [];
544
- if (keys.length > 20 || keys.some((k) => !/^[A-Za-z][A-Za-z0-9_]*-\d+$/.test(String(k)))) return fail(400, 'epics is a list of Jira keys (at most 20), each like IDPF-2685');
545
- const epics = [...new Set(keys.map((k) => String(k).toUpperCase()))];
546
- const projects = b.jiraProjects && b.jiraProjects.length ? b.jiraProjects : b.jira ? [b.jira] : [];
547
- const off = projects.length ? epics.filter((k) => !projects.includes(k.split('-')[0])) : [];
548
- if (off.length) return fail(400, off.join(', ') + (off.length === 1 ? ' is' : ' are') + ' not in a Jira project of ' + b.name + ' (' + projects.join(', ') + ')');
549
- r.epics = epics;
550
- S.events.push({ at: at(0, 8), by: 'You', kind: 'ini-epics', board: b.id, id: r.id, epics });
551
- return okb({ row: rowOut(S, r) });
552
- }
553
- if (path === '/api/boards/ini-workflow') {
554
- if (b.self) return fail(409, 'The PMOS board follows the ladder its records derive.');
555
- const r = S.rows.find((x) => x.id === body.id && x.board === b.id);
556
- if (!r) return fail(404, 'no initiative ' + (body.id || '') + ' on this board');
557
- if (body.template != null && body.template !== '' && !b.offer.includes(body.template)) return fail(400, b.name + ' does not offer the template "' + body.template + '" (it offers ' + b.offer.join(', ') + ')');
558
- const ck = checkStages(body.stages); if (!ck.ok) return fail(400, ck.error);
559
- if (!b.build && ck.stages.some(isBuildStage)) return fail(400, 'Build and Deliver stages need a board with Build and deliver on; ' + b.name + ' has it off');
560
- const now = wfOf(S, r);
561
- const renamed = Object.fromEntries(ck.stages.filter((s) => s.was && now.some((o) => o.name === s.was) && s.was !== s.name).map((s) => [s.was, s.name]));
562
- const keptCur = ck.stages.find((s) => s.was === r.stage) || (ck.stages.some((s) => s.name === r.stage && !s.was) ? null : null);
563
- let moved = null; const from = r.stage;
564
- if (keptCur) r.stage = keptCur.name;
565
- else if (ck.stages.some((s) => s.name === r.stage)) { /* the same name again */ }
566
- else {
567
- if (!ck.stages.some((s) => s.name === body.moveTo)) return fail(400, 'the initiative is in "' + r.stage + '", which the new workflow removes: say which stage it moves to (moveTo)');
568
- moved = { from, to: body.moveTo }; r.stage = body.moveTo;
569
- }
570
- r.workflow = ck.stages.map((s) => ({ name: s.name, cat: s.cat, hint: s.hint }));
571
- r.template = body.template || null;
572
- S.events.push({ at: at(0, 8), by: 'You', kind: 'workflow', board: b.id, id: r.id, template: r.template, stages: r.workflow.map((s) => s.name), renamed });
573
- if (moved) S.events.push({ at: at(0, 8), by: 'You', kind: 'move', board: b.id, id: r.id, from: moved.from, to: moved.to, why: moved.from + ' was removed from its workflow', warnings: [] });
574
- r.warnings = orderWarnings(r.workflow, r, null, r.stage).filter((w) => !/^Skipped/.test(w));
575
- return okb({ row: rowOut(S, r), moved });
576
- }
577
- if (path === '/api/boards/move') {
578
- if (b.self) return fail(409, 'The PMOS board derives each stage from the records. A move is not recorded here.');
579
- const r = S.rows.find((x) => x.id === body.id && x.board === b.id);
580
- if (!r) return fail(404, 'No initiative "' + (body.id || '') + '" on ' + b.name + '.');
581
- const wf = wfOf(S, r);
582
- if (!wf.some((s) => s.name === body.to)) return fail(400, 'No stage "' + (body.to || '') + '" in the workflow of ' + r.id + '.');
583
- const from = r.stage; const warnings = from === body.to ? [] : orderWarnings(wf, r, from, body.to);
584
- r.stage = body.to; r.warnings = warnings;
585
- S.events.push({ at: at(0, 8), by: 'You', kind: 'move', board: b.id, id: r.id, from, to: body.to, why: body.why || '', warnings });
586
- return okb({ row: rowOut(S, r), warnings });
587
- }
588
- if (path === '/api/boards/asks/add') {
589
- const line = String(body.line || '').trim(); if (!line) return fail(400, 'Write the ask in one line.');
590
- const words = line.toLowerCase().split(/\s+/).filter((w) => w.length > 3);
591
- const similar = S.rows.find((r) => r.board === b.id && words.some((w) => r.title.toLowerCase().includes(w)));
592
- const draft = { title: line, lane: /bug|error|fail|broken|retr/i.test(line) ? 'incident' : 'feature', confidence: 0.5, anchor_suggestion: null, prior_rejections: [], refused: false, refused_reason: null, stage: 'discover',
593
- ...(similar ? { similar: { id: similar.id, title: similar.title, stage: similar.stage } } : {}) };
594
- const ask = { id: 'ask-demo' + (++S.seq), board: b.id, line, source: body.source || 'Typed by you', at: at(0, 8), state: 'open', draft };
595
- S.asks.push(ask);
596
- return okb({ ask: { ...ask }, draft });
597
- }
598
- if (path === '/api/boards/asks/more') {
599
- const a = S.asks.find((x) => x.id === body.ask && x.board === b.id && x.state === 'open');
600
- if (!a) return fail(404, 'No open ask "' + (body.ask || '') + '" on ' + b.name + '.');
601
- a.needMore = true; a.moreNote = String(body.note || '').trim();
602
- S.events.push({ at: at(0, 8), by: 'You', kind: 'ask-more', board: b.id, ask: a.id, note: a.moreNote });
603
- return okb({});
604
- }
605
- if (path === '/api/boards/asks/accept') {
606
- const a = S.asks.find((x) => x.id === body.ask && x.board === b.id && x.state === 'open');
607
- if (!a) return fail(404, 'No open ask "' + (body.ask || '') + '" on ' + b.name + '.');
608
- if (!String(body.anchor || '').trim()) return fail(400, 'An initiative needs an anchor: a key result or a health budget.');
609
- const max = S.rows.filter((r) => r.board === b.id).reduce((m, r) => Math.max(m, Number(r.id.split('-').pop()) || 0), 0);
610
- const tpl = b.defTpl;
611
- const own = sameFlow(tplStages(tpl), b.workflow) ? null : tplStages(tpl);
612
- const stage = (own || b.workflow)[0].name;
613
- const r = { id: b.prefix + '-' + (max + 1), board: b.id, title: String(body.title || a.line).trim(), stage, owner: 'You', anchor: String(body.anchor).trim(), horizon: 'next', status: 'on track', start: TODAY, end: D(60), progress: 0,
614
- lane: body.lane || 'feature', spec: false, warnings: [], featured: false, template: own ? tpl : null, workflow: own };
615
- S.rows.push(r); a.state = 'accepted'; a.initiative = r.id;
616
- S.events.push({ at: at(0, 8), by: 'You', kind: 'ask-accept', board: b.id, ask: a.id, id: r.id, stage, to: stage });
617
- return okb({ initiative: rowOut(S, r), stage });
618
- }
619
- if (path === '/api/boards/asks/decline') {
620
- const a = S.asks.find((x) => x.id === body.ask && x.board === b.id && x.state === 'open');
621
- if (!a) return fail(404, 'No open ask "' + (body.ask || '') + '" on ' + b.name + '.');
622
- if (!String(body.why || '').trim()) return fail(400, 'Say why you decline it.');
623
- a.state = 'declined'; a.why = String(body.why).trim();
624
- S.events.push({ at: at(0, 8), by: 'You', kind: 'ask-decline', board: b.id, ask: a.id, why: a.why });
625
- return okb({});
626
- }
627
- if (path === '/api/boards/tasks/add') {
628
- const title = String(body.title || '').trim();
629
- if (!title) return fail(400, 'title is one line of 1 to 200 characters');
630
- const r = S.rows.find((x) => x.id === body.initiative && x.board === b.id);
631
- if (!r) return fail(404, 'no initiative ' + (body.initiative || '') + ' on this board');
632
- const start = body.start || shiftDay(TODAY, 1); const due = body.due || shiftDay(start, 7);
633
- const t = { id: 'task-demo' + (++S.seq), board: b.id, initiative: r.id, title, owner: body.owner || 'You', state: 'To do', start, due, epic: body.epic || null, kind: body.type === 'Epic' ? 'Epic' : 'Task', history: [] };
634
- S.tasks.push(t);
635
- return okb({ item: rollup([taskItem(t)])[0] });
636
- }
637
- if (path === '/api/boards/tasks/state' || path === '/api/boards/tasks/reschedule') {
638
- const t = S.tasks.find((x) => x.id === body.task && x.board === b.id);
639
- if (!t) return fail(404, 'no PMOS task ' + (body.task || '') + ' on this board');
640
- if (path.endsWith('/state')) {
641
- if (!TASK_STATES.includes(body.state)) return fail(400, 'state is one of ' + TASK_STATES.join(', '));
642
- t.history.push({ at: at(0, 8), from: t.state, to: body.state }); t.state = body.state;
643
- } else {
644
- const n = Number(body.days);
645
- if (!Number.isInteger(n) || n === 0 || Math.abs(n) > 730) return fail(400, 'days is a whole number of days, not 0, at most 730 either way');
646
- t.history.push({ at: at(0, 8), start: t.start, due: t.due }); t.start = shiftDay(t.start, n); t.due = shiftDay(t.due, n);
647
- }
648
- return okb({ item: rollup([taskItem(t)])[0] });
649
- }
650
- return fail(404, 'No route ' + path);
651
- }
652
-
653
- /* ── views of other routes, for the Releases, Docs and initiative tabs (c3-ib-releases.js, c3-ib-docs.js, c3-ii-tabs.js) ──
654
- * These answer only a request that carries `board=` (the tabs add it; the old page never does), so the old demo fixtures keep answering
655
- * everything else: GET /api/releases, /api/docs/library, /api/my-work, /api/c3-init/breakdown, /api/doc and /api/doc-sheet/revisions, /proposals and /log.
656
- * The rows are made from the boards' featured initiatives. IDPF-07 gets no documents on purpose, so the empty state can be seen. */
657
- function handleMore(S, method, path, p) {
658
- if (method !== 'GET') return undefined;
659
- const feat = (bid) => S.rows.filter((r) => r.featured && (!bid || r.board === bid) && !['IDPF-07'].includes(r.id));
660
- if (path === '/api/doc' || path === '/api/doc-sheet/revisions') {
661
- if (!/^planning\/ib\//.test(p.path || '')) return undefined;
662
- const id = (p.path.match(/ib\/([a-z]+-\d+)/i) || [])[1] || '';
663
- const text = '## Summary\nA short demo document for ' + id.toUpperCase() + '.\n\n## Details\nThe detail lives in the source tool.\n';
664
- if (path === '/api/doc') return { status: 200, text };
665
- return okb({ path: p.path, revisions: [{ rev: 1, by: 'human:wawan', at: at(-3, 9) + '.000Z', why: 'First version', before_hash: '', after_hash: '' }] });
666
- }
667
- /* the document sheet's Proposals and Edit log tabs: none yet, one first version */
668
- if ((path === '/api/doc-sheet/proposals' || path === '/api/doc-sheet/log') && /^planning\/ib\//.test(p.path || '')) {
669
- if (path === '/api/doc-sheet/proposals') return okb({ path: p.path, proposals: [] });
670
- return okb({ path: p.path, revisions: [{ rev: 1, by: 'human:wawan', at: at(-3, 9) + '.000Z', why: 'First version', via: 'sheet', text_by: 'person', before_hash: '', after_hash: '' }], events: [] });
671
- }
672
- if (!p.board) return undefined;
673
- if (path === '/api/releases') {
674
- return okb({ board: { name: 'Demo board' }, releases: S.releases.filter((x) => x.board === p.board).map((x) => ({ id: x.id, name: x.name, type: 'both', initiative_ids: x.scope.slice(), deploy_at: x.date + 'T11:00:00', release_at: x.date + 'T12:00:00', accepted_at: x.status === 'Released' ? x.date + 'T12:30:00' : null, gapFlags: [], tags: { detected: [], reason: null }, summary: [], status: x.status, board: x.board })) });
675
- }
676
- if (path === '/api/docs/library') {
677
- const files = []; const edges = []; // the research informs the PRD; the rubric comes from the PRD (the document sheet's Relations graph)
678
- for (const r of feat(p.board)) {
679
- const h = hash(r.id); const slug = r.id.toLowerCase(); const at0 = files.length;
680
- if (r.spec) files.push({ path: 'planning/ib/' + slug + '-prd.md', title: r.title + ' PRD', category: 'spec', date: D(-(h % 20) - 1), initiative: r.id });
681
- files.push({ path: 'planning/ib/' + slug + '-research.md', title: r.title + ' research', category: 'res', date: D(-(h % 50) - 5), initiative: r.id });
682
- if (catOfRow(S, r) === 'Do') files.push({ path: 'planning/ib/' + slug + '-rubric.md', title: r.title + ' rubric', category: 'eval', date: D(-(h % 9) - 1), initiative: r.id });
683
- if (r.spec) { edges.push([at0 + 1, at0, 0]); if (files.length === at0 + 3) edges.push([at0, at0 + 2, 1]); }
684
- }
685
- return okb({ key: 'demo', files, edges, kinds: ['informs', 'rubric from'], categories: [{ key: 'spec', name: 'Specs' }, { key: 'eval', name: 'Evals' }, { key: 'res', name: 'Research & plans' }], initiatives: {} });
686
- }
687
- return undefined;
688
- }
689
-
690
- /* ── the stage records (route contract of the stage-records change; demo answers only) ── */
691
- const RICE_IMPACT = [0.25, 0.5, 1, 2, 3];
692
- const riceScore = (d) => Math.round((d.reach * d.impact * (d.confidence / 100)) / Math.max(0.25, d.effort) * 10) / 10;
693
- function checkRecord(tool, d) {
694
- if (!d || typeof d !== 'object') return 'data is an object';
695
- if (tool === 'problem') return typeof d.text === 'string' && d.text.length <= 4000 ? '' : 'text is at most 4000 characters';
696
- if (tool === 'rice') return [d.reach, d.confidence, d.effort].every((n) => typeof n === 'number' && Number.isFinite(n)) && RICE_IMPACT.includes(d.impact) && d.effort > 0 && d.confidence >= 0 && d.confidence <= 100 ? '' : 'reach, impact (0.25, 0.5, 1, 2 or 3), confidence 0 to 100 and effort > 0';
697
- const max = { launch: 40, kill: 20, learnings: 60 }[tool];
698
- if (!max) return 'tool is problem, rice, launch, kill or learnings';
699
- return Array.isArray(d.items) && d.items.length <= max && d.items.every((x) => x && typeof x.text === 'string') ? '' : 'items is a list of at most ' + max;
700
- }
701
- function handleTools(S, method, path, p, body) {
702
- const known = (id) => S.rows.some((r) => r.id === id);
703
- if (path === '/api/stage-tools/records') {
704
- if (method === 'POST') {
705
- if (!known(body.id)) return fail(404, 'No initiative "' + (body.id || '') + '".');
706
- const e = checkRecord(body.tool, body.data);
707
- if (e) return fail(400, e);
708
- const rec = { data: JSON.parse(JSON.stringify(body.data)), at: new Date().toISOString(), by: 'You' };
709
- (S.records[body.id] = S.records[body.id] || {})[body.tool] = rec;
710
- return okb({ record: rec });
711
- }
712
- const own = S.records[p.id] || {};
713
- const out = {};
714
- for (const k of ['problem', 'rice', 'launch', 'kill', 'learnings']) {
715
- const r = own[k];
716
- out[k] = r ? { ...r, data: k === 'rice' ? { ...r.data, score: riceScore(r.data) } : r.data } : null;
717
- }
718
- return okb({ ws: p.ws || WS_ID, id: p.id, records: out });
719
- }
720
- if (path === '/api/stage-tools/rice' && method === 'GET') {
721
- const ids = p.ids ? String(p.ids).split(',') : Object.keys(S.records);
722
- const rows = ids.filter((id) => S.records[id] && S.records[id].rice).map((id) => ({ id, ...S.records[id].rice.data, score: riceScore(S.records[id].rice.data), at: S.records[id].rice.at }))
723
- .sort((a, c) => c.score - a.score).map((r, k) => ({ ...r, rank: k + 1 }));
724
- return okb({ rows });
725
- }
726
- if (path === '/api/stage-tools/burndown' && method === 'GET') {
727
- const ids = String(p.ids || '').split(',').filter(Boolean);
728
- const b = p.board ? S.boards.find((x) => x.id === p.board) : S.boards.find((x) => ids.some((id) => S.rows.some((r) => r.id === id && r.board === x.id)));
729
- if (!b) return okb({ available: false, reason: 'No Jira sprint covers these initiatives.' });
730
- if (!b.build) return okb({ available: false, reason: 'Jira not enabled on this board' });
731
- const committed = b.id === 'idpf' ? 34 : b.id === 'pay' ? 21 : 18; const len = 14; const passed = 7;
732
- const drop = [0, 2, 3, 3, 6, 8, 11, 13];
733
- const series = Array.from({ length: len + 1 }, (_, k) => ({ date: D(k - passed), remaining: k <= passed ? committed - drop[k] : null, ideal: Math.round((committed * (1 - k / len)) * 10) / 10 }));
734
- const left = committed - drop[passed];
735
- return okb({ available: true, sprint: { name: b.prefix + ' Sprint ' + (b.id === 'idpf' ? 42 : 19), state: 'active', start: D(-passed), end: D(len - passed) }, committed, done: committed - left, left, daysLeft: len - passed,
736
- needPerDay: Math.round((left / (len - passed)) * 10) / 10, series, tickets: 12, unpointed: 1, readAt: TODAY + 'T08:10:00' });
737
- }
738
- return fail(404, 'No route ' + path);
739
- }
740
-
741
- let installed = false;
742
- /** Wrap window.fetch once: a /api/boards request is answered from the store; anything else goes on unchanged. */
743
- export function installBoards() {
744
- if (installed || typeof window === 'undefined') return;
745
- installed = true;
746
- const S = createStore();
747
- window.__c3boards = S; // the browser suites read the store to check what a write changed
748
- const prev = window.fetch;
749
- window.fetch = (input, init) => {
750
- try {
751
- const raw = typeof input === 'string' ? input : input instanceof URL ? input.href : input && input.url;
752
- const method = String((init && init.method) || (input && input.method) || 'GET').toUpperCase();
753
- const u = new URL(raw, location.origin);
754
- if (u.origin === location.origin && (u.pathname.startsWith('/api/boards') || u.pathname === '/api/lifecycle' || u.pathname.startsWith('/api/stage-tools') || u.searchParams.has('board') || u.pathname.startsWith('/api/doc'))) {
755
- let b = {};
756
- if (method !== 'GET') { try { b = init && init.body ? JSON.parse(init.body) : {}; } catch { b = {}; } }
757
- const out = handle(S, method, u.pathname, Object.fromEntries(u.searchParams), b);
758
- if (out && out.text != null) return Promise.resolve(new Response(out.text, { status: out.status, headers: { 'content-type': 'text/markdown; charset=utf-8' } }));
759
- if (out) return Promise.resolve(new Response(JSON.stringify(out.body), { status: out.status, headers: { 'content-type': 'application/json' } }));
760
- }
761
- } catch { /* an unreadable request goes on as it is */ }
762
- return prev(input, init);
763
- };
764
- }