create-pmos 0.421.0 → 0.423.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 (112) hide show
  1. package/package.json +25 -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/scripts/anchor-resolve.js +93 -15
  6. package/payload/state/discoveries.md +1 -1
  7. package/workspace/board-programs-test.js +87 -3
  8. package/workspace/briefing-premium-adddoc-test.js +1 -1
  9. package/workspace/briefing-premium-board-test.js +13 -11
  10. package/workspace/briefing-premium-initiative-test.js +30 -38
  11. package/workspace/changelog.json +24 -0
  12. package/workspace/fixtures/report-api/draft.json +2 -1
  13. package/workspace/guide/briefing-premium.md +2 -1
  14. package/workspace/guide/home.md +14 -4
  15. package/workspace/guide/programs.md +5 -3
  16. package/workspace/guide/workflows.md +5 -1
  17. package/workspace/home-other-product-test.js +55 -0
  18. package/workspace/ini-workflow-test.js +4 -4
  19. package/workspace/lib/board-premium.js +21 -6
  20. package/workspace/lib/custom-docs.js +65 -3
  21. package/workspace/lib/doc-live-root.js +37 -0
  22. package/workspace/lib/engine/anchor-resolve.js +93 -15
  23. package/workspace/lib/engine/boards.js +30 -2
  24. package/workspace/lib/engine/intake.js +1 -1
  25. package/workspace/lib/hold-spans.js +24 -10
  26. package/workspace/lib/initiative-writer.js +63 -1
  27. package/workspace/lib/kg.js +1 -1
  28. package/workspace/lib/plan-items.js +36 -5
  29. package/workspace/lib/programs.js +11 -3
  30. package/workspace/lib/report-draft.js +3 -0
  31. package/workspace/lib/route-modules.js +2 -0
  32. package/workspace/lib/routes-board-premium.js +28 -0
  33. package/workspace/lib/routes-boards.js +92 -13
  34. package/workspace/lib/routes-doc-sheet.js +29 -1
  35. package/workspace/lib/routes-initiatives.js +12 -0
  36. package/workspace/lib/routes-programs.js +44 -5
  37. package/workspace/lib/routes-task-links.js +329 -0
  38. package/workspace/lib/routes-task-plans.js +333 -0
  39. package/workspace/lib/split-merge-suggest.js +162 -0
  40. package/workspace/lib/split-merge.js +379 -0
  41. package/workspace/lib/task-cli.js +73 -13
  42. package/workspace/lib/task-items.js +15 -3
  43. package/workspace/lib/task-links.js +422 -0
  44. package/workspace/lib/task-plans.js +232 -0
  45. package/workspace/lib/vendor/scripts/anchor-resolve.js +93 -15
  46. package/workspace/lib/vendor/scripts/intake.js +1 -1
  47. package/workspace/package-lock.json +2 -2
  48. package/workspace/package.json +1 -1
  49. package/workspace/premium-board-actions-test.js +2 -2
  50. package/workspace/premium-core-doc-issue-test.js +2 -2
  51. package/workspace/premium-vw-backlog-test.js +3 -3
  52. package/workspace/premium-vw-doc-test.js +26 -3
  53. package/workspace/premium-vw-item-test.js +3 -3
  54. package/workspace/premium-vw-jira-test.js +6 -6
  55. package/workspace/product-lane-test.js +165 -0
  56. package/workspace/program-leave-test.js +203 -0
  57. package/workspace/program-panel-test.js +1 -1
  58. package/workspace/public/pm/bd-acts.js +5 -2
  59. package/workspace/public/pm/bd-ini-panel.js +32 -9
  60. package/workspace/public/pm/bd-prog-panel.js +22 -7
  61. package/workspace/public/pm/bd-prog.js +6 -1
  62. package/workspace/public/pm/bd-span.js +234 -30
  63. package/workspace/public/pm/bd-views.js +3 -2
  64. package/workspace/public/pm/cozy-board.css +90 -0
  65. package/workspace/public/pm/cozy-home.css +3 -0
  66. package/workspace/public/pm/doc-follow.js +36 -0
  67. package/workspace/public/pm/home-app.js +62 -14
  68. package/workspace/public/pm/home-ini-model.js +0 -34
  69. package/workspace/public/pm/home-ini.js +81 -204
  70. package/workspace/public/pm/home-list.js +2 -2
  71. package/workspace/public/pm/home-today.js +3 -1
  72. package/workspace/public/pm/ini-groups.js +228 -0
  73. package/workspace/public/pm/ini-links.js +561 -0
  74. package/workspace/public/pm/ini-tasks.js +131 -30
  75. package/workspace/public/pm/ini-versions.js +348 -0
  76. package/workspace/public/pm/ini-view-model.js +113 -43
  77. package/workspace/public/pm/ini-view.css +341 -18
  78. package/workspace/public/pm/ini-view.js +153 -38
  79. package/workspace/public/pm/premium-board.js +160 -21
  80. package/workspace/public/pm/premium-report-read.js +20 -1
  81. package/workspace/public/pm/premium-shell.js +29 -4
  82. package/workspace/public/pm/premium-vw-doc.js +46 -11
  83. package/workspace/public/pm/prog-move.js +69 -0
  84. package/workspace/public/pm/split-merge.css +77 -0
  85. package/workspace/public/pm/split-merge.js +265 -0
  86. package/workspace/public/pm/stage-line.js +414 -0
  87. package/workspace/public/pm/task-card.css +3 -0
  88. package/workspace/public/pm/task-card.js +15 -6
  89. package/workspace/public/pm/wf-page.css +2 -0
  90. package/workspace/public/pm/wf-page.js +2 -0
  91. package/workspace/public/pm/wf-stage.js +2 -1
  92. package/workspace/server.js +15 -1
  93. package/workspace/split-merge-ui-test.js +175 -0
  94. package/workspace/stage-card-test.js +12 -11
  95. package/workspace/task-card-test.js +3 -2
  96. package/workspace/task-delete-test.js +126 -0
  97. package/workspace/task-links-test.js +227 -0
  98. package/workspace/task-milestones-test.js +176 -0
  99. package/workspace/task-plans-test.js +181 -0
  100. package/workspace/task-views-test.js +3 -3
  101. package/workspace/test-lists/bd-ini-panel.json +8 -2
  102. package/workspace/test-lists/product-lane.json +6 -0
  103. package/workspace/test-lists/program-leave.json +6 -0
  104. package/workspace/test-lists/split-merge.json +15 -0
  105. package/workspace/test-lists/task-delete.json +5 -0
  106. package/workspace/test-lists/task-links.json +6 -0
  107. package/workspace/test-lists/task-milestones.json +6 -0
  108. package/workspace/test-lists/task-plans.json +6 -0
  109. package/workspace/test-lists/viewer-live-file.json +9 -0
  110. package/workspace/timeline-holds-test.js +61 -4
  111. package/workspace/tk-tasks-test.js +173 -57
  112. package/workspace/workflows-setup-test.js +4 -3
@@ -74,6 +74,14 @@ body.bd-page main.bd-main { position: relative; max-width: none; margin: 16px; p
74
74
  .bd-page .crmenu > button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border-radius: 12px; font: 600 13.5px var(--cz-sans); color: var(--cz-ink); white-space: nowrap; }
75
75
  .bd-page .crmenu > button:hover, .bd-page .crmenu > button:focus-visible { background: var(--cz-well); }
76
76
  .bd-page .crmenu > button .bd-wtag { margin-left: auto; }
77
+ /* the product menu ticks several (batch 11 item 7): a blue tick when on, a grey dash on All products when only some are */
78
+ .bd-page .crmenu > button .crtk { margin-left: auto; width: 18px; height: 18px; flex: none; display: inline-flex; }
79
+ .bd-page .crmenu > button .crtk svg { width: 18px; height: 18px; fill: none; stroke: var(--cz-blue); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
80
+ .bd-page .crmenu > button .crtk.part svg { stroke: var(--cz-ink3); }
81
+ .bd-page .crmenu > button[aria-checked="false"] { color: var(--cz-ink2); }
82
+ .bd-page .crmenu .crsep { height: 1px; margin: 4px 8px; background: var(--cz-hair); }
83
+ .bd-pickw .crumb #crBoard { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
84
+ .bd-pickw .crumb #crBoard b { font-weight: 700; color: var(--cz-ink3); }
77
85
  .bd-page .crmenu em { margin-left: auto; font-style: normal; font-size: 12px; font-weight: 600; color: var(--cz-ink3); }
78
86
  .bd-page .tbrow { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 6px 0 12px; font: 600 13.5px var(--cz-sans); color: var(--cz-ink2); }
79
87
  .bd-page .tbrow[hidden] { display: none; }
@@ -504,6 +512,7 @@ button.tg-n:hover b { color: var(--cz-blueink); }
504
512
  .bd-show-s { display: inline-flex; }
505
513
  .bd-ib { width: 44px; height: 44px; }
506
514
  .bd-pickw .crumb, .bd-pickw .crumb #crBoard { height: 34px; }
515
+ .bd-pickw .crumb #crBoard { max-width: 150px; }
507
516
  .bd-tabs, .bd-sp, .bd-vr { display: none !important; }
508
517
  .bd-chiprow { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; gap: 6px; mask-image: linear-gradient(90deg, black 85%, transparent); -webkit-mask-image: linear-gradient(90deg, black 85%, transparent); }
509
518
  .bd-chiprow::-webkit-scrollbar { display: none; }
@@ -690,6 +699,7 @@ button.bd-lr:hover { background: var(--bd-row); }
690
699
  .bd-mi .k { margin-left: auto; font-size: 12px; color: var(--cz-ink3); font-weight: 600; white-space: nowrap; }
691
700
  .bd-mi .tx { display: flex; flex-direction: column; min-width: 0; flex: 1; padding: 6px 0; }
692
701
  .bd-mi .tx > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
702
+ .bd-mi .tx small { font-size: 12px; font-weight: 600; color: var(--cz-ink3); }
693
703
  .bd-mi mark { background: var(--cz-bluebg); color: var(--cz-blueink); border-radius: 3px; }
694
704
  .bd-mlbl { margin: 0; font-size: 12px; font-weight: 800; color: var(--cz-ink3); padding: 8px 12px 4px; }
695
705
  .bd-mnote { padding: 4px 12px 8px; }
@@ -1260,3 +1270,83 @@ body.bd-spick .bd-hd .bd-tools { margin-left: auto; }
1260
1270
  .bd-hold .bd-ib { width: 36px; height: 36px; background: var(--cz-well); }
1261
1271
  .bd-pp.bd-hold { padding: 14px 16px; gap: 8px; width: 300px; }
1262
1272
  .bd-pp.bd-hold.sheet { width: auto; }
1273
+
1274
+ /* A milestone task's ◇ on the initiative's row (feedback batch 11 item 3; canvas XmlA1Board, XmlA4Hover, XmlA5Phone, XmlA7Spans): hollow while
1275
+ * open, filled grey when done (a card ring keeps it apart from the bar), an orange outline when late. The short date sits under it. A 24 px hit
1276
+ * area carries the tooltip. A counted ◇ lists its milestones under it. Not draggable. */
1277
+ .tg-tm, .tg-tmc { position: absolute; top: 50%; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; transform: rotate(45deg); border-radius: 2px; background: var(--cz-card); border: 2px solid var(--bd-done); box-sizing: border-box; z-index: 3; }
1278
+ .tg-tm::before, .tg-tmc::before { content: ''; position: absolute; inset: -8px; }
1279
+ .tg-tm.dn, .tg-end.dn { background: var(--bd-done); box-shadow: 0 0 0 2px var(--cz-card); }
1280
+ .tg-tm.late, .tg-tmc.late { border-color: var(--cz-dot-late); }
1281
+ .tg-tmc { all: unset; box-sizing: border-box; position: absolute; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; transform: rotate(45deg); border-radius: 4px; background: var(--cz-card); border: 2px solid var(--bd-done); z-index: 3; cursor: pointer; display: flex; align-items: center; justify-content: center; }
1282
+ .tg-tmc.dn { background: var(--bd-done); }
1283
+ .tg-tmc b { transform: rotate(-45deg); font-size: 10px; font-weight: 800; color: var(--cz-ink2); }
1284
+ .tg-tmc.dn b { color: var(--cz-card); }
1285
+ .tg-tmc.late b { color: var(--cz-late); }
1286
+ .tg-tmc:focus-visible, .tg-tmc[aria-expanded="true"] { outline: 2px solid var(--cz-blue); outline-offset: 3px; }
1287
+ .tg-tml { position: absolute; top: calc(50% + 9px); transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--cz-ink3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; z-index: 3; pointer-events: none; }
1288
+ .tg-tml.late { color: var(--cz-late); font-weight: 800; }
1289
+ .tg-msp { position: fixed; z-index: 60; min-width: 240px; max-width: min(360px, calc(100vw - 16px)); padding: 6px; background: var(--cz-card); border-radius: 16px; box-shadow: 0 12px 32px rgba(0,0,0,.16), 0 0 0 1px var(--cz-hair); }
1290
+ .tg-msp .o { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 10px; font-size: 14px; font-weight: 700; color: var(--cz-ink); cursor: pointer; }
1291
+ .tg-msp .o:hover, .tg-msp .o:focus-visible { background: var(--cz-well2); }
1292
+ .tg-msp .o > span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
1293
+ .tg-msp .k { font-size: 13px; font-weight: 700; color: var(--cz-ink2); }
1294
+ .tg-msp .k.late { color: var(--cz-late); }
1295
+ .tg-tm-i { flex: none; width: 10px; height: 10px; transform: rotate(45deg); border-radius: 2px; border: 2px solid var(--bd-done); box-sizing: border-box; }
1296
+ .tg-tm-i.dn { background: var(--bd-done); }
1297
+ .tg-tm-i.late { border-color: var(--cz-dot-late); }
1298
+ .tg-msp.sh { left: 0; right: 0; bottom: 0; top: auto; max-width: none; border-radius: 24px 24px 0 0; padding: 10px 12px calc(16px + env(safe-area-inset-bottom)); }
1299
+ .tg-msp.sh .gr { display: block; width: 36px; height: 4px; margin: 0 auto 10px; border-radius: 2px; background: var(--cz-hair); }
1300
+ .tg-msp.sh .h { display: block; padding: 4px 12px 8px; font-size: 16px; font-weight: 800; color: var(--cz-ink); }
1301
+ .tgq-r .tg-tm, .tgq-r .tg-tmc { top: 50%; }
1302
+ /* the product lane (batch 11 item 17; PlmA1Board, PlmA2Folded, PlmA3Phone): a product's head row carries every milestone of its initiatives,
1303
+ * the rows' ◇ rolled up, over a thin grey line from the first start to the last end. The name cell keeps the fold button; the lane is the track. */
1304
+ .tg-lane, .tg-s .tg-lane > .tg-n { background: var(--bd-row); }
1305
+ .tg-q .tg-body > .tg-lane { min-height: 56px; }
1306
+ .tg-lnn { flex-direction: row; align-items: center; }
1307
+ .tg-lnn .bd-prdb { min-width: 0; overflow: hidden; }
1308
+ .tg-lane .tg-span { background: var(--bd-plan); }
1309
+ .tgq-n.tg-lnn { display: flex; width: var(--vw, 100%); padding: 4px 10px 2px; cursor: default; }
1310
+ .tg-lnp .o small { display: block; font-size: 12px; font-weight: 500; color: var(--cz-ink3); overflow: hidden; text-overflow: ellipsis; }
1311
+ .tg-msp.sh { max-height: 70vh; overflow-y: auto; }
1312
+ /* planned versus actual (batch 11 item 8; canvas PvaAC4Board): the saved plan's thin line with end caps under the bar, the slip after the end
1313
+ * date (+14d orange, −15d grey), an initiative with drafts only drawn dashed, the legend's Plan and Draft keys. Milestone date labels drop
1314
+ * under the plan line (+13 px). Dashed blue stays the Jira forecast; dotted stays a hold. */
1315
+ .tg-pl { position: absolute; top: calc(50% + 10px); height: 1.6px; background: var(--cz-ink2); z-index: 1; }
1316
+ .tg-pl::before, .tg-pl::after { content: ""; position: absolute; top: -3px; width: 1.6px; height: 7.6px; background: var(--cz-ink2); }
1317
+ .tg-pl::before { left: 0; } .tg-pl::after { right: 0; }
1318
+ .tg-p:has(.tg-pl) .tg-tml { top: calc(50% + 22px); }
1319
+ .tg-slip { font-weight: 800; color: var(--cz-ink3); }
1320
+ .tg-slip.late { color: var(--cz-late); }
1321
+ .tg-bar.tg-dr { background: transparent; border: 1.5px dashed color-mix(in srgb, var(--cz-ink3) 75%, var(--cz-card)); box-sizing: border-box; }
1322
+ .tg-lgd .k.pln { width: 16px; height: 1.6px; border-radius: 0; background: var(--cz-ink2); position: relative; vertical-align: 3px; }
1323
+ .tg-lgd .k.pln::before, .tg-lgd .k.pln::after { content: ""; position: absolute; top: -3px; width: 1.6px; height: 7.6px; background: var(--cz-ink2); }
1324
+ .tg-lgd .k.pln::before { left: 0; } .tg-lgd .k.pln::after { right: 0; }
1325
+ .tg-lgd .k.drf { border: 1.5px dashed var(--cz-ink3); box-sizing: border-box; }
1326
+ /* No activity (feedback batch 11 item 13; canvas XgapA1Board, XgapAHard, XgapA3Phone, XgapAGrill): a gap of 2 weeks or more with no dated work is a
1327
+ 2 px hairline in the To do grey at the bar's middle, one press (a 24 px area) with its words. A skipped stage between two dated ones is one » on
1328
+ the hairline, or on the bar at the joint. Kept apart from a hold (dotted + ⏸), a draft (dashed box) and the plan line (dark, end caps). */
1329
+ .tg-ng { all: unset; box-sizing: border-box; position: absolute; top: 50%; height: 24px; margin-top: -12px; z-index: 2; cursor: pointer; }
1330
+ span.tg-ng { cursor: default; }
1331
+ .tg-ng::before { content: ""; position: absolute; left: 0; right: 0; top: 11px; height: 2px; background: var(--bd-plan); }
1332
+ .tg-ng:hover::before, .tg-ng[aria-expanded="true"]::before { background: var(--bd-done); }
1333
+ .tg-ng:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 0; border-radius: 6px; }
1334
+ .tg-sk { position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: var(--cz-card); color: var(--cz-ink3); z-index: 3; }
1335
+ .tg-sk.on { width: 14px; height: 14px; margin: -7px 0 0 -7px; background: none; color: var(--cz-ink2); }
1336
+ .tg-sk svg, .tg-lgd .k.sk svg, .tg-sk-i svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
1337
+ .tg-lgd .k.ng { width: 18px; height: 2px; border-radius: 0; background: var(--bd-plan); vertical-align: 3px; }
1338
+ .tg-lgd .k.sk { width: 12px; height: 12px; background: none; vertical-align: -2px; color: var(--cz-ink3); }
1339
+ /* the gap's card: its words, and + New task with its dates while part of it is ahead (XgapAHard 2) */
1340
+ .tg-gpc { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 10px 10px 14px; }
1341
+ .tg-gpc .w { flex: 1; min-width: 0; }
1342
+ .tg-gpc p { margin: 0; font-size: 13px; font-weight: 800; color: var(--cz-ink); }
1343
+ .tg-gpc p.s { margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--cz-ink2); }
1344
+ .tg-gpc .gp-add { all: unset; box-sizing: border-box; flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--cz-ink); color: var(--cz-card); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
1345
+ .tg-gpc .gp-add svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
1346
+ .tg-gpc .gp-add:focus-visible { outline: 2px solid var(--cz-blue); outline-offset: 2px; }
1347
+ /* the phone's row sheet: a gap and a skipped stage are lines in date order with the milestones; words only */
1348
+ .tg-msp .o.i { cursor: default; font-weight: 600; color: var(--cz-ink2); }
1349
+ .tg-msp .o.i:hover { background: none; }
1350
+ .tg-msp .o.i small { display: block; font-size: 12px; font-weight: 500; color: var(--cz-ink3); white-space: normal; }
1351
+ .tg-ng-i { flex: none; width: 12px; height: 2px; background: var(--bd-done); }
1352
+ .tg-sk-i { flex: none; width: 12px; display: inline-flex; color: var(--cz-ink3); }
@@ -738,3 +738,6 @@ form.hm-box textarea { min-height: 48px; border: 0; background: none; resize: no
738
738
  .hm-recp.paused .pill { background: var(--cz-well); color: var(--cz-ink3); }
739
739
  .hm-recp.paused i { background: var(--cz-dot-q); }
740
740
  }
741
+ /* a milestone task's small grey ◇ after its name (feedback batch 11 item 3) */
742
+ .hm-rt.ms { flex-direction: row; align-items: center; gap: 6px; }
743
+ .hv-ms { flex: none; display: inline-flex; color: var(--cz-ink3); }
@@ -0,0 +1,36 @@
1
+ /* pm/doc-follow.js — a read-only view of a document that follows the file (PM, 2026-10-26: "When chat make update on the file that being shown on the
2
+ * current viewer, I should not need to refresh page. I should not need to manually commit as well").
3
+ *
4
+ * followDoc({ ws, ini, path, alive, onText }) -> Promise that settles when alive() turns false
5
+ * ws the workspace the view opened the document in
6
+ * ini the initiative it belongs to, or '': its chat writes in the initiative's own worktree, and that copy is the one read
7
+ * alive() true while the view still shows this document
8
+ * onText(text|null) the text, at once and again after each change; null when it could not be read
9
+ * Every few seconds GET /api/doc-sheet/stamp names the workspace that holds the live copy and the text's hash; a new hash reads GET /api/doc there.
10
+ * A file the stamp cannot check (not Markdown, or an older server) is read once. */
11
+ const CHECK_MS = 2500;
12
+ const qs = (o) => Object.entries(o).filter(([, v]) => v).map(([k, v]) => k + '=' + encodeURIComponent(v)).join('&');
13
+ async function json(url) { try { const r = await fetch(url, { credentials: 'same-origin' }); return await r.json(); } catch { return null; } }
14
+ async function text(url) { try { const r = await fetch(url, { credentials: 'same-origin' }); return r.ok ? await r.text() : null; } catch { return null; } }
15
+
16
+ export async function followDoc({ ws = '', ini = '', path, alive = () => true, onText = () => {} } = {}) {
17
+ let seen = null, first = true;
18
+ while (alive()) {
19
+ if (first || (typeof document === 'undefined' || !document.hidden)) {
20
+ const s = await json('/api/doc-sheet/stamp?' + qs({ ws, ini, path }));
21
+ if (!alive()) return;
22
+ if (!s || s.ok !== true) { // not a file the stamp checks: read it once, as before
23
+ if (first) onText(await text('/api/doc?' + qs({ ws, path })));
24
+ return;
25
+ }
26
+ const key = (s.ws || '') + '|' + s.hash;
27
+ if (key !== seen) {
28
+ const t = await text('/api/doc?' + qs({ ws: s.ws || ws, path }));
29
+ if (!alive()) return;
30
+ if (t != null || first) { seen = t != null ? key : seen; onText(t); }
31
+ }
32
+ first = false;
33
+ }
34
+ await new Promise((ok) => setTimeout(ok, CHECK_MS));
35
+ }
36
+ }
@@ -26,6 +26,7 @@ import * as SC from './home-stage-card.js'; // the initiative's stage card D
26
26
  import * as WFM from './ini-wf-model.js'; // D99: the workflow an initiative runs (kind line, usual days)
27
27
  import { wfIcon, wfOf } from './wf-model.js';
28
28
  import { iniView } from './ini-view-model.js'; // the one initiative view (batch 6 item 1): the same model the Board's panel draws
29
+ import { rowFor } from './ini-versions.js'; // planned versus actual (batch 11 item 8): Live or the draft the PM shows, with the plan line
29
30
  import { programOf } from './program-model.js';
30
31
  import { startAgent } from './page-agent.js';
31
32
  import { mdHtml } from './chat-md.js';
@@ -35,10 +36,12 @@ import * as L from './home-list.js';
35
36
  import * as TD from './home-today.js';
36
37
  import * as YD from './home-day.js'; // Your day in the Viewer (XvAPhDay)
37
38
  import { canDictate, dictate } from './home-dictate.js';
38
- import { mountIni, iniList, iniOverview, iniPage } from './home-ini.js'; // the initiative's page, its stage move, Tasks and Core documents (premium-uncovered-features, HbC)
39
+ import { mountIni, iniList, iniOverview, iniPage, iniAddTask } from './home-ini.js'; // the initiative's page, its stage move, Tasks and Core documents (premium-uncovered-features, HbC)
39
40
  import * as MEN from './home-mentions.js'; // @Mentions, the permanent row at the top of Home and its Viewer (Viewer kit, XvANew)
40
41
  import { mountRecRow, clockOf as recClock } from './home-rec-row.js';
41
42
  import { mountSesName } from './home-ses-name.js'; // session names A: tap the session's name to rename it (canvas XmsNames)
43
+ import * as SM from './split-merge.js'; // split one initiative in two, or merge two: Claude suggests, the PM approves (batch 11 item 14)
44
+ import * as PM from './prog-move.js'; // move an initiative out of its program, or to another (canvas LpA1More, LpA2Other, LpA4Phone)
42
45
  import * as PO from './prog-order.js'; // a program's order on Home: the grip, hold-then-drag on a phone, ✦ Claude's order from the dates (canvas RoAPhone)
43
46
  import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
44
47
 
@@ -87,6 +90,7 @@ const S = {
87
90
  sel: null, // the selected row's id
88
91
  allNeeds: false, kids: new Set(), shut: new Set(JSON.parse(store.get('pmos.home.shut') || '[]')), folded: store.get('pmos.home.fold') === '1',
89
92
  IM: null, IMid: null, // the selected initiative's model (GET /api/initiative-premium)
93
+ iniWs: {}, // another product's initiative found by a read (loadIni), by id: the workspace it was found in
90
94
  doneOpen: false, stepsMore: false, sheet: false, rec: {}, pin: new Set(JSON.parse(store.get('pmos.home.pin') || '[]')),
91
95
  cardFold: store.get('pmos.home.cardfold') === '1', // the card's checklist folded to one line (AgInitSpec), kept in this browser
92
96
  // the one list (premium-uncovered-features): the filter, the picked product, which groups and initiatives are open, kept in this browser
@@ -120,7 +124,9 @@ const taskRenameOf = (t) => taskRename({ pmPost, ws: t.ws || boardWs(), board: t
120
124
  toastUndo('Renamed', async () => { const u = await o.undo(); if (u.ok) { renamedHere('task', t.uid, u.title); t.title = u.title; { const c = VW.current(); if (c && String(c.id).endsWith(t.uid)) VW.retitle(c.id, u.title); } load(); } return u; });
121
125
  load();
122
126
  } });
123
- const iniRenameOf = (id, prefix) => initiativeRename({ pmPost, ws: WS || undefined, id, epics: ((H.boardRows(S.D).find((r) => r.id === id) || {}).epics) || [],
127
+ // another product's initiative renames in ITS workspace, not Home's (batch 11 item 9: "no initiative psle-microsite-revamp")
128
+ const iniWsOf = (id) => { const o = otherIni(id); return (o && o.ws) || WS || undefined; };
129
+ const iniRenameOf = (id, prefix) => initiativeRename({ pmPost, ws: iniWsOf(id), id, epics: ((iniRowOf(id) || {}).epics) || [],
124
130
  onSaved: (o) => {
125
131
  renamedHere('ini', id, o.title);
126
132
  if (o.jira) { S.phoneChat = isPhone(); openTarget(iniTarget(id)); setTimeout(() => { const ta = $('#hmIn'); if (ta) { ta.value = o.jira; ta.dispatchEvent(new Event('input', { bubbles: true })); ta.focus(); } }, 0); }
@@ -188,7 +194,15 @@ async function loadIni() {
188
194
  if (!id || id === 'product') { S.IM = null; S.IMid = id; S.D.files = []; return; }
189
195
  // an initiative of another product is read from its own board, not this one (it is not on this board, so the read said it could not be read)
190
196
  const oi = otherIni(id), b = oi ? { ws: oi.ws, id: oi.board } : (S.D.board && S.D.board.board) || {};
191
- const r = await getRetry('/api/initiative-premium?id=' + encodeURIComponent(id) + (b.ws ? '&ws=' + encodeURIComponent(b.ws) : wsQ('&')) + (b.id ? '&board=' + encodeURIComponent(b.id) : boardQ('&')), 16);
197
+ // another product's board unknown: its own workspace's default board, never this board's id
198
+ let r = await getRetry('/api/initiative-premium?id=' + encodeURIComponent(id) + (b.ws ? '&ws=' + encodeURIComponent(b.ws) : wsQ('&')) + (b.id ? '&board=' + encodeURIComponent(b.id) : oi ? '' : boardQ('&')), 16);
199
+ // not on this board and on no list Home read (batch 11 item 10): try each other product Home reads, and remember where it was found
200
+ if (!(r && r.ok && r.model) && !oi) {
201
+ for (const o of S.D.others || []) {
202
+ const t = await getRetry('/api/initiative-premium?id=' + encodeURIComponent(id) + '&ws=' + encodeURIComponent(o.ws), 4);
203
+ if (t && t.ok && t.model) { S.iniWs[id] = o.ws; r = t; break; }
204
+ }
205
+ }
192
206
  S.IM = r && r.ok && r.model ? r.model : null; S.IMid = id;
193
207
  if (S.IM) { import('./premium-vw-jira.js').catch(() => {}); import('./premium-vw-item.js').catch(() => {}); } // the Overview's ticket, sprint and record views, ready before a press
194
208
  S.D.files = S.IM ? (S.IM.docs.rows || []).filter((d) => d.path).map((d) => ({ name: d.title, path: d.path, meta: [d.state, d.when].filter(Boolean).join(' · ') })) : [];
@@ -228,7 +242,7 @@ function rowHtml(r, o = {}) {
228
242
  const kids = r.kids && S.kids.has(r.id) ? `<div class="hm-kids" role="group" aria-label="In ${esc(r.name)}">${r.kids.map((k) => rowHtml(k, { kid: true })).join('') || '<p class="hm-none">Nothing here now.</p>'}</div>` : '';
229
243
  return `<div class="hm-r${sel ? ' sel' : ''}${o.kid ? ' kid' : ''} st-${esc(r.state)}" data-id="${esc(r.id)}">`
230
244
  + `<button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"${sel ? ' aria-current="true"' : ''}><i class="hm-dot ${dotCls(r.state)}" aria-hidden="true"></i>${tileHtml(r)}`
231
- + `<span class="hm-rt"><b>${esc(r.name)}</b><em>${esc(r.hint || '')}</em></span></button>${chip}${end}</div>${kids}`;
245
+ + `<span class="hm-rt"><b>${r.kind === 'ini' ? SM.nameHtml(r.board, r.name) : esc(r.name)}</b><em>${esc(r.hint || '')}</em></span></button>${chip}${end}</div>${kids}`;
232
246
  }
233
247
  /* ── the one list (premium-uncovered-features: HmMyWork, HmProducts, HmDay, HmMic, HmReview, HmPhone) ── */
234
248
  const NOW = () => S.D.now || Date.now();
@@ -299,7 +313,7 @@ function iniViewOf(id) {
299
313
  const B = S.D.board || {}, t = S.D.trail && S.D.trail.items && S.D.trail.items[id];
300
314
  const need = H.needsOf(S.D).find((r) => r.ini === id);
301
315
  const p = programOf(S.D.programs || [], row.ws || (B.board || {}).ws || '', id);
302
- return iniView({ ...row, trail: t || row.trail || null }, { steps: B.steps || STEPS, today: B.today, usual: WFM.usualOf(S.D.trail, row),
316
+ return iniView(rowFor({ ...row, trail: t || row.trail || null }), { steps: B.steps || STEPS, today: B.today, usual: WFM.usualOf(S.D.trail, row),
303
317
  ask: need ? { title: need.name } : null, program: p ? { id: p.id, title: p.title } : null });
304
318
  }
305
319
  /** An initiative no board Home reads holds (its own read only, GET /api/initiative-premium): the row the one view needs, from that read. */
@@ -309,7 +323,9 @@ function imRowOf(id) {
309
323
  return { id, key: 'board:' + id, title: M.title || id, lane: M.lane || null, track: { k, key: k >= 0 ? STEPS[k].key : null, label: stage },
310
324
  tasks: ((M.tasks && M.tasks.rows) || []).filter((x) => x.pmos && x.uid).map((x) => ({ uid: x.uid, title: x.title, status: x.state || 'To do', start: x.start || '', end: x.end || '', owner: x.owner || '' })) };
311
325
  }
312
- function iniRowOf(id) { return H.boardRows(S.D).find((r) => r.id === id) || (otherIni(id) || {}).row || null; }
326
+ // an archived one opens too, from its link: a merged initiative's page says where its work went (batch 11 item 14, XsmA7Closed)
327
+ const goneRowOf = (id) => ((((S.D.board || {}).initiatives || {}).gone || {}).archived || []).find((r) => r.id === id) || null;
328
+ function iniRowOf(id) { return H.boardRows(S.D).find((r) => r.id === id) || (otherIni(id) || {}).row || goneRowOf(id); }
313
329
  /** An initiative of another product Home reads (D.others): its row, and the workspace and board it is read from. Null for the board's own. */
314
330
  function otherIni(id) {
315
331
  if (!id || id === 'product' || H.boardRows(S.D).some((r) => r.id === id)) return null;
@@ -318,7 +334,13 @@ function otherIni(id) {
318
334
  const row = rows.find((r) => r.id === id);
319
335
  if (row) return { ws: o.ws, board: (o.model.board || {}).id || null, row };
320
336
  }
321
- return null;
337
+ // one the board lists do not hold (batch 11 item 10): `pmos initiative new` puts it in Later, and a product's model lists only Now and the
338
+ // late and at-risk rows. Its next step names its workspace, or a read found it there (loadIni)
339
+ const own = boardWs(), need = H.needsOf(S.D).find((x) => x.ini === id && x.row && x.row.ws && x.row.ws !== own);
340
+ const ws = (need && need.row.ws) || S.iniWs[id];
341
+ if (!ws || ws === own) return null;
342
+ const o = (S.D.others || []).find((x) => x && x.ws === ws);
343
+ return { ws, board: (o && o.model && o.model.board && o.model.board.id) || null, row: need && need.row.subject ? { id, title: String(need.row.subject).split(' · ')[0], made: true } : null };
322
344
  }
323
345
  function headOf(id) {
324
346
  const row = iniRowOf(id) || {};
@@ -558,7 +580,8 @@ async function workItem(text, t) {
558
580
  const r = await pmPost('/api/home-desk/work-item', { ws: b.ws || WS || undefined, initiative: ini, text, key: (t && (t.key || t.sid)) || '' });
559
581
  toast(r && r.ok ? 'Drafted ' + (r.id || 'a work-item') + ' in ' + iniTitle(ini) + '. Nothing reaches Jira until your Commit.' : (r && r.error) || 'The work-item was not drafted.');
560
582
  }
561
- const iniTitle = (id) => (id === 'product' ? H.productName(S.D) + ' · product' : (iniRowOf(id) || {}).title || (S.IM && S.IM.title) || id);
583
+ // a row made from a next step (otherIni) carries its clipped subject: the initiative's own title wins once it is read
584
+ const iniTitle = (id) => { if (id === 'product') return H.productName(S.D) + ' · product'; const r = iniRowOf(id) || {}, m = S.IM && S.IMid === id ? S.IM.title : null; return (r.made && m) || r.title || (S.IM && S.IM.title) || id; };
562
585
  const scopeOf = (ini) => (ini ? { text: iniTitle(ini), icon: I.flag } : { text: 'All work', icon: I.home, loose: false });
563
586
  const rich = () => !!S.ini;
564
587
  function iniTarget(id) {
@@ -684,11 +707,36 @@ function overviewAsk(id) {
684
707
  }
685
708
  /** Turn into a program (P7), from the page's ⋯: a charter named after the initiative, which joins it; then the program opens here. */
686
709
  async function turnProgram(id) {
687
- const res = await pmPost('/api/programs/turn', { ws: boardWs() || null, initiative: id, title: iniTitle(id) }).catch(() => null);
710
+ // the initiative's own workspace, never the board's: its member line must sit beside it, or Home keeps it under its product (batch 11 item 18)
711
+ const res = await pmPost('/api/programs/turn', { ws: (otherIni(id) || {}).ws || boardWs() || null, initiative: id, title: iniTitle(id) }).catch(() => null);
688
712
  if (!res || !res.ok || !res.program) { toast((res && res.error) || 'The program was not made. Try again.'); return; }
689
713
  toast('Now a program · ' + iniTitle(id) + '.');
690
714
  await load(); goProgram(res.program.id);
691
715
  }
716
+ /** The page's ⋯ items for an initiative in a program (pm/prog-move.js): Move out of it, Move to another program. openList is home-ini.js's menu. */
717
+ function moveItems(id, openList) {
718
+ const row = iniRowOf(id) || {}, o = otherIni(id), B = S.D.board || {};
719
+ const other = o ? ((S.D.others || []).find((x) => x && x.ws === o.ws) || {}).model || {} : null;
720
+ const product = other ? (o.row && o.row.product) || (other.board || {}).product || (other.board || {}).name || '' : H.productName(S.D);
721
+ return PM.moveItems({ programs: () => S.D.programs || [], ws: row.ws || (o && o.ws) || (B.board || {}).ws || '', id, product, pmPost, phone: isPhone, openList,
722
+ say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)),
723
+ stateOf: (p) => (((S.M && S.M.groups) || []).find((g) => g.kind === 'program' && g.program.id === p.id) || {}).st || null,
724
+ reload: async () => { await load(); if (S.ini === id && VW.isOpen()) iniPage(); } });
725
+ }
726
+ /** Split or merge (pm/split-merge.js; canvas XsmA1Menu, XsmA1Suggest): the context of one initiative on Home. Only this board's rows: a
727
+ * merge stays on one board. After the write Home reads again and opens the one the PM lands on. openList is home-ini.js's menu. */
728
+ function smCtx(id, openList) {
729
+ const row = iniRowOf(id) || { id }, B = S.D.board || {}, ws = row.ws || (B.board || {}).ws || '';
730
+ return { row, rows: () => H.boardRows(S.D), ws, board: row.boardId || (B.board || {}).id || '', product: H.productName(S.D), program: programOf(S.D.programs || [], ws, id), pmPost,
731
+ say: (m, undo) => (undo ? toastUndo(m, undo) : toast(m)), openList: openList || (() => {}),
732
+ reload: async () => { await load(); if (S.ini && VW.isOpen()) iniPage(); },
733
+ openIni: async (to) => { for (let i = 0; i < 8 && !iniRowOf(to); i++) { await new Promise((ok) => setTimeout(ok, 900)); await load(); } if (iniRowOf(to)) goIni(to); } };
734
+ }
735
+ function smItems(id, openList) {
736
+ const B = S.D.board || {};
737
+ if ((B.board || {}).self || otherIni(id)) return [];
738
+ return SM.menuItems(smCtx(id, openList));
739
+ }
692
740
  /** A program's conversation (?ask=program:<id>, a program task's row): Claude with the program as its scope. task names the open row. */
693
741
  function programTarget(id, task) {
694
742
  const pr = (S.D.programs || []).find((p) => p && p.id === id) || { id, title: (P.get('label') || '').slice(0, 80) || id };
@@ -853,14 +901,13 @@ function openReviewVw() {
853
901
  },
854
902
  }));
855
903
  }
856
- /* New → A task: the PM names the initiative first. An initiative's task is added in its Tasks view (home-ini.js, the box there);
904
+ /* New → A task: the PM names the initiative first. An initiative's task is added in its page's Tasks field, the cursor in it (XtaA4NewTask);
857
905
  * "Not in an initiative" opens the capture box in the list, on the PM's own list (POST /api/pm-items/add). The box is not on Home otherwise. */
858
906
  async function addTaskIn(id) {
859
907
  if (!id) { S.cap = true; drawList(); const i = $('#hmCap'); if (i) i.focus(); return; }
860
908
  await goIni(id);
861
909
  if (S.ini !== id) return;
862
- iniOverview('tasks');
863
- setTimeout(() => { const n = document.querySelector('#czViewer #ovTask'); if (n) n.focus(); }, 0);
910
+ iniAddTask();
864
911
  }
865
912
  async function capture(text) {
866
913
  const line = String(text || '').trim(); if (!line) return false;
@@ -1093,7 +1140,8 @@ async function openFile(f) {
1093
1140
  if (typeof V.openDoc === 'function') { try { return V.openDoc(f.path, { ws: deskWs() }); } catch { /* the plain view below */ } }
1094
1141
  // a Markdown document opens as its page (premium-vw-doc.js): read, edit, its edit log, health, relations and copies, in the Viewer
1095
1142
  const fws = () => (S.ini && S.IM && S.IM.board && S.IM.board.ws) || deskWs(); // an initiative's document lives in its board's workspace
1096
- if (/\.md$/i.test(f.path)) { try { const M = await import('./premium-vw-doc.js'); if (M.openDocPage({ path: f.path, title: f.name || f.path.split('/').pop() }, { ws: () => fws() })) return; } catch { /* the plain view below */ } }
1143
+ const ini = S.ini || ''; // its chat edits the document in the initiative's own worktree: the page reads it there (premium-vw-doc.js)
1144
+ if (/\.md$/i.test(f.path)) { try { const M = await import('./premium-vw-doc.js'); if (M.openDocPage({ path: f.path, title: f.name || f.path.split('/').pop() }, { ws: () => fws(), ini })) return; } catch { /* the plain view below */ } }
1097
1145
  const body = VW.open({ id: 'file:' + f.path, kind: 'File · ' + f.path, title: f.name || f.path, icon: 'doc', html: '<p class="hx-n hv">Reading the file.</p>' });
1098
1146
  let txt = null;
1099
1147
  try { const r = await fetch('/api/doc?path=' + encodeURIComponent(f.path) + (deskWs() ? '&ws=' + encodeURIComponent(deskWs()) : ''), { credentials: 'same-origin' }); txt = r.ok ? await r.text() : null; } catch { txt = null; }
@@ -1482,7 +1530,7 @@ function cta() {
1482
1530
  mountIni({ S, VW, pmGet, pmPost, toast, rowOf: (id) => iniRowOf(id), renameIni: (id, pre) => iniRenameOf(id, pre), renameTask: (t) => taskRenameOf(t), load: () => load(), loadIni: () => loadIni(), openFile: (f) => openFile(f), iniTitle: (id) => iniTitle(id), drawList: () => drawList(), wait: MORE.WAIT,
1483
1531
  // the initiative's page (HbCDesk): its card, its header and its ⋯
1484
1532
  openBoardTask: (t) => openBoardTask(t),
1485
- cardHtml: (id, o) => cardHtml(id, o), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), talk: () => talk(), view: (id) => iniViewOf(id), head: (id) => (S.H = headOf(id)), goProgram: (id) => goProgram(id),
1533
+ cardHtml: (id, o) => cardHtml(id, o), kindOf: (id) => kindOf(id), cta: () => cta(), overviewAsk: (id) => overviewAsk(id), newIn: (id) => newIn(id), addPerson: () => addPerson(), turnProgram: (id) => turnProgram(id), moveItems: (id, openList) => moveItems(id, openList), smItems: (id, openList) => smItems(id, openList), smPress: (id, act) => SM.press(smCtx(id), act), goIni: (id) => goIni(id), talk: () => talk(), view: (id) => iniViewOf(id), head: (id) => (S.H = headOf(id)), goProgram: (id) => goProgram(id),
1486
1534
  foldCard: () => { S.cardFold = !S.cardFold; store.set('pmos.home.cardfold', S.cardFold ? '1' : null); } });
1487
1535
  /* The program panel in Home's Viewer (HbCProg): Home's board model and programs; an initiative of it opens here, with ← back to the program.
1488
1536
  * Read on the first program press, never at start: the panel's modules load premium-shell.js, whose start reads ?session= for the old dialog. */
@@ -3,8 +3,6 @@
3
3
  *
4
4
  * moveModel(h, M, L, now) the stage move: the exit items of the stage, the next and previous stage, whether it can move by itself
5
5
  * taskRows(M, L, now) the initiative's tasks with the stage each belongs to, its owner and its date
6
- * taskGroups(rows, L, by) the Tasks card's groups: by stage, by the PM's own groups, by owner, by status, or none
7
- * listTasks(rows) the list column's Tasks group: the open tasks, soonest first, and the "All tasks" line
8
6
  * docRows(M) the core documents with their kind, phase and whether they need a look
9
7
  * docGroups(rows, stage, o) the Documents card's groups: by stage (now, earlier, Later), by kind, or none; o.filter narrows them
10
8
  * docChips(rows) the filter chips: All, Needs a look, then one per kind that is there
@@ -15,7 +13,6 @@ import { STEPS, stageKey } from './premium-initiative-head.js';
15
13
 
16
14
  const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
17
15
  const DOW = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
18
- const plural = (n, one, many) => n + ' ' + (n === 1 ? one : many);
19
16
  const dayOf = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? new Date(+m[1], +m[2] - 1, +m[3]) : null; };
20
17
  const midnight = (ms) => { const d = new Date(ms); return new Date(d.getFullYear(), d.getMonth(), d.getDate()); };
21
18
 
@@ -101,37 +98,6 @@ export function taskRows(M, L, now = Date.now(), o = {}) {
101
98
  owner: t.owner || '', av: initials(t.owner), due: due.text, late: due.late, start: t.start || '', end: t.end || '', group: (lay.of || {})[t.key] || '', src: t.src || '', blocked: !!t.blocked, canCheck: !!(t.pmos && t.uid) };
102
99
  });
103
100
  }
104
- // a task hangs under no workflow stage (Wawan, 2026-10-25), so there is no "by stage"; a layout that saved 'stage' reads as Your groups
105
- export const BY_LABEL = { epic: 'Epic', mine: 'Your groups', owner: 'Owner', status: 'Status', none: 'No groups' }; // epic: tk-model.js ticketGroups
106
- const STATUS = TASK_STATES;
107
- const shut = (r) => (r.closed != null ? r.closed : r.done);
108
- const order = (rows) => rows.filter((r) => !shut(r)).concat(rows.filter((r) => shut(r)));
109
- export function taskGroups(rows, L, by) {
110
- const lay = L || { names: [] }, b = BY_LABEL[by] ? by : 'mine';
111
- const g = (key, title, list, o = {}) => ({ key, title, rows: order(list), open: list.filter((r) => !shut(r)).length, ...o });
112
- if (b === 'none') return [g('all', null, rows)];
113
- if (b === 'mine') {
114
- const out = (lay.names || []).map((n) => g('g:' + n, n, rows.filter((r) => r.group === n), { mine: true }));
115
- const rest = rows.filter((r) => !r.group || !(lay.names || []).includes(r.group));
116
- if (rest.length || !out.length) out.push(g('g:', out.length ? 'Not in a group' : 'Not in a group yet', rest, { loose: true }));
117
- return out;
118
- }
119
- if (b === 'owner') {
120
- const names = [...new Set(rows.map((r) => r.owner || ''))].sort((x, y) => (!x) - (!y) || x.localeCompare(y));
121
- return names.map((n) => g('o:' + n, n || 'No owner', rows.filter((r) => (r.owner || '') === n)));
122
- }
123
- if (b === 'status') {
124
- const keys = STATUS.concat([...new Set(rows.map((r) => r.state || 'No status').filter((s) => !STATUS.includes(s)))]);
125
- return keys.map((s) => g('s:' + s, s, rows.filter((r) => (r.state || 'No status') === s))).filter((x) => x.rows.length);
126
- }
127
- return [g('all', null, rows)];
128
- }
129
- export function listTasks(rows) {
130
- const open = rows.filter((r) => !shut(r) && !r.req);
131
- const top = open.slice().sort((a, b) => (a.end || '9999').localeCompare(b.end || '9999')).slice(0, 3);
132
- const jira = rows.filter((r) => r.jira).length, reqs = rows.filter((r) => r.req).length;
133
- return { top, open: open.length, all: rows.length, sub: [plural(rows.length, 'task', 'tasks'), jira ? jira + ' from Jira' : '', reqs ? plural(reqs, 'PRD requirement', 'PRD requirements') : ''].filter(Boolean).join(' · ') };
134
- }
135
101
 
136
102
  /* ── documents ── */
137
103
  const KIND = { record: 'Record', problem: 'Spec', research: 'Research', rice: 'Plan doc', prd: 'PRD', rubric: 'Rubric', design: 'Design', stories: 'Spec', risks: 'Plan doc', launch: 'Plan doc', review: 'Review', update: 'Report', explainer: 'Notes', outcome: 'Report', brd: 'BRD' };