kaizen-agent 1.86.0 → 1.87.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 (541) hide show
  1. package/README.md +1 -1
  2. package/cli/annotate-proxy.ts +6 -3
  3. package/cli/build-web.ts +46 -16
  4. package/cli/dev.ts +67 -0
  5. package/cli/docs.ts +1 -1
  6. package/cli/notes.ts +9 -3
  7. package/cli/ports.ts +121 -0
  8. package/cli/settings.ts +16 -17
  9. package/cli/state.ts +15 -29
  10. package/cli/task-service.ts +44 -14
  11. package/cli/tasks.ts +1 -1
  12. package/cli/term-image.ts +18 -0
  13. package/cli/ui-audit.allow.json +0 -1
  14. package/cli/ui-audit.ts +12 -12
  15. package/cli/web.ts +182 -58
  16. package/package.json +21 -4
  17. package/skills/kaizen/spec.md +10 -3
  18. package/tsconfig.json +16 -0
  19. package/web/README.md +105 -0
  20. package/web/{annotate.js → annotate/annotate.ts} +51 -50
  21. package/web/boot/boot.ts +7 -0
  22. package/web/components/annotate/annotate-bar.tsx +78 -0
  23. package/web/components/annotate/annotate-panel.tsx +20 -0
  24. package/web/components/annotate/annotate-settings.tsx +60 -0
  25. package/web/components/annotate/index.ts +1 -0
  26. package/web/components/annotate/notes-list.tsx +75 -0
  27. package/web/components/board/board-card.tsx +177 -0
  28. package/web/components/board/board-column.tsx +212 -0
  29. package/web/components/board/board-mode-switch.tsx +21 -0
  30. package/web/components/board/board-popups.tsx +45 -0
  31. package/web/components/board/card-footer.tsx +58 -0
  32. package/web/components/board/card-form.tsx +168 -0
  33. package/web/components/board/card-kids.tsx +53 -0
  34. package/web/components/board/clear-menu.tsx +36 -0
  35. package/web/components/board/filter-box.tsx +42 -0
  36. package/web/components/board/index.ts +6 -0
  37. package/web/components/board/run-form.tsx +129 -0
  38. package/web/components/board/severity-menu.tsx +44 -0
  39. package/web/components/board/status-strip.tsx +75 -0
  40. package/web/components/board/task-form.tsx +140 -0
  41. package/web/components/board/ws-card.tsx +38 -0
  42. package/web/components/context/context-panel.tsx +244 -0
  43. package/web/components/context/index.ts +1 -0
  44. package/web/components/decision/decision-bar.tsx +422 -0
  45. package/web/components/decision/index.ts +1 -0
  46. package/web/components/decision/inline-form.tsx +47 -0
  47. package/web/components/decision/plan-answers-form.tsx +78 -0
  48. package/web/components/decision/revise-form.tsx +65 -0
  49. package/web/components/decision/task-reply-form.tsx +48 -0
  50. package/web/components/footer/foot-bar.tsx +67 -0
  51. package/web/components/footer/index.ts +1 -0
  52. package/web/components/git/git-ask.tsx +88 -0
  53. package/web/components/git/git-commits.tsx +53 -0
  54. package/web/components/git/git-confirm.tsx +78 -0
  55. package/web/components/git/git-counts.tsx +10 -0
  56. package/web/components/git/git-files.tsx +113 -0
  57. package/web/components/git/git-head.tsx +70 -0
  58. package/web/components/git/git-icon.tsx +25 -0
  59. package/web/components/git/git-message.tsx +44 -0
  60. package/web/components/git/git-split.tsx +64 -0
  61. package/web/components/git/git-tab.tsx +55 -0
  62. package/web/components/git/index.ts +1 -0
  63. package/web/components/home/chat-list.tsx +57 -0
  64. package/web/components/home/home-composer.tsx +169 -0
  65. package/web/components/home/home-message.tsx +120 -0
  66. package/web/components/home/home-window.tsx +253 -0
  67. package/web/components/home/home-ws-add.tsx +47 -0
  68. package/web/components/home/index.ts +6 -0
  69. package/web/components/home/onboarding-dialog.tsx +371 -0
  70. package/web/components/icebox/board-chip.tsx +27 -0
  71. package/web/components/icebox/board-menu.tsx +41 -0
  72. package/web/components/icebox/bulk-bar.tsx +41 -0
  73. package/web/components/icebox/capture-box.tsx +155 -0
  74. package/web/components/icebox/choice-menu.tsx +39 -0
  75. package/web/components/icebox/collection-dialog.tsx +60 -0
  76. package/web/components/icebox/favicon.tsx +39 -0
  77. package/web/components/icebox/index.ts +10 -0
  78. package/web/components/icebox/kind-label.tsx +22 -0
  79. package/web/components/icebox/kind-menu.tsx +20 -0
  80. package/web/components/icebox/promote-form.tsx +93 -0
  81. package/web/components/icebox/reply-box.tsx +88 -0
  82. package/web/components/icebox/request-actions.tsx +141 -0
  83. package/web/components/icebox/request-badges.tsx +13 -0
  84. package/web/components/icebox/request-card.tsx +99 -0
  85. package/web/components/icebox/request-detail.tsx +43 -0
  86. package/web/components/icebox/request-images.tsx +33 -0
  87. package/web/components/icebox/request-phone-row.tsx +181 -0
  88. package/web/components/icebox/request-row.tsx +120 -0
  89. package/web/components/icebox/service-chip.tsx +58 -0
  90. package/web/components/icebox/snooze-menu.tsx +83 -0
  91. package/web/components/icebox/source-card.tsx +225 -0
  92. package/web/components/icebox/source-drawer.tsx +112 -0
  93. package/web/components/icebox/source-form.tsx +147 -0
  94. package/web/components/icebox/swipe-deck.tsx +242 -0
  95. package/web/components/layout/index.ts +1 -0
  96. package/web/components/layout/page-frame.tsx +44 -0
  97. package/web/components/markdown/index.ts +1 -0
  98. package/web/components/markdown/markdown.tsx +156 -0
  99. package/web/components/notebook/editor-pane.tsx +23 -0
  100. package/web/components/notebook/index.ts +5 -0
  101. package/web/components/notebook/note-body.tsx +172 -0
  102. package/web/components/notebook/note-tree.tsx +99 -0
  103. package/web/components/notebook/notes-head.tsx +37 -0
  104. package/web/components/notebook/notes-side.tsx +46 -0
  105. package/web/components/notes/index.ts +1 -0
  106. package/web/components/notes/note-composer.tsx +90 -0
  107. package/web/components/notes/notes-chat.tsx +58 -0
  108. package/web/components/panes/browser-pane.tsx +281 -0
  109. package/web/components/panes/index.ts +3 -0
  110. package/web/components/panes/preview-pane.tsx +91 -0
  111. package/web/components/panes/terminal-pane.tsx +52 -0
  112. package/web/components/phone/haptic.tsx +29 -0
  113. package/web/components/phone/index.ts +6 -0
  114. package/web/components/phone/phone-card.tsx +118 -0
  115. package/web/components/phone/phone-home.tsx +304 -0
  116. package/web/components/phone/phone-sheets.tsx +103 -0
  117. package/web/components/phone/qr-code.tsx +6 -0
  118. package/web/components/phone/usage-chips.tsx +85 -0
  119. package/web/components/phone/whatsapp-card.tsx +85 -0
  120. package/web/components/project/add-project-dialog.tsx +435 -0
  121. package/web/components/project/index.ts +3 -0
  122. package/web/components/project/project-bar.tsx +101 -0
  123. package/web/components/project/ws-menu.tsx +21 -0
  124. package/web/components/rail/agent-chips.tsx +110 -0
  125. package/web/components/rail/index.ts +4 -0
  126. package/web/components/rail/rail-filter.tsx +118 -0
  127. package/web/components/rail/rail-list.tsx +259 -0
  128. package/web/components/rail/source-marks.tsx +21 -0
  129. package/web/components/resources/index.ts +1 -0
  130. package/web/components/resources/resources-popup.tsx +490 -0
  131. package/web/components/run/doc-body.tsx +123 -0
  132. package/web/components/run/file-viewer.tsx +53 -0
  133. package/web/components/run/fix-form.tsx +88 -0
  134. package/web/components/run/index.ts +16 -0
  135. package/web/components/run/inline-md.tsx +30 -0
  136. package/web/components/run/key-hint.tsx +29 -0
  137. package/web/components/run/pane-gutter.tsx +52 -0
  138. package/web/components/run/pane-header.tsx +35 -0
  139. package/web/components/run/pane.tsx +140 -0
  140. package/web/components/run/panel-grip.tsx +49 -0
  141. package/web/components/run/panel-head.tsx +56 -0
  142. package/web/components/run/panel-tabs.tsx +35 -0
  143. package/web/components/run/phase-steps.tsx +37 -0
  144. package/web/components/run/project-notes.tsx +49 -0
  145. package/web/components/run/run-add-menu.tsx +80 -0
  146. package/web/components/run/run-bar.tsx +40 -0
  147. package/web/components/run/run-empty.tsx +10 -0
  148. package/web/components/run/run-footer.tsx +53 -0
  149. package/web/components/run/run-history.tsx +24 -0
  150. package/web/components/run/run-panes.tsx +78 -0
  151. package/web/components/run/run-picker.tsx +51 -0
  152. package/web/components/run/run-progress.tsx +30 -0
  153. package/web/components/run/run-tabs.tsx +147 -0
  154. package/web/components/run/run-wait.tsx +18 -0
  155. package/web/components/search/index.ts +1 -0
  156. package/web/components/search/search-palette.tsx +159 -0
  157. package/web/components/settings/account-rows.tsx +128 -0
  158. package/web/components/settings/agent-rows.tsx +249 -0
  159. package/web/components/settings/automation-rows.tsx +211 -0
  160. package/web/components/settings/browser-row.tsx +111 -0
  161. package/web/components/settings/cleanup-row.tsx +32 -0
  162. package/web/components/settings/commit-input.tsx +39 -0
  163. package/web/components/settings/index.ts +4 -0
  164. package/web/components/settings/integration-row.tsx +158 -0
  165. package/web/components/settings/mic-row.tsx +48 -0
  166. package/web/components/settings/orchestration-flow.tsx +87 -0
  167. package/web/components/settings/setting-row.tsx +131 -0
  168. package/web/components/settings/settings-item.tsx +78 -0
  169. package/web/components/settings/settings-loading.tsx +41 -0
  170. package/web/components/settings/settings-nav.tsx +119 -0
  171. package/web/components/settings/settings-scope.tsx +66 -0
  172. package/web/components/settings/settings-section.tsx +33 -0
  173. package/web/components/settings/skill-card.tsx +131 -0
  174. package/web/components/settings/stepper.tsx +74 -0
  175. package/web/components/settings/update-bar.tsx +167 -0
  176. package/web/components/shared/action-menu.tsx +76 -0
  177. package/web/components/shared/ask-host.tsx +18 -0
  178. package/web/components/shared/attach-button.tsx +23 -0
  179. package/web/components/shared/chip.tsx +19 -0
  180. package/web/components/shared/client-mark.tsx +15 -0
  181. package/web/components/shared/confirm-dialog.tsx +35 -0
  182. package/web/components/shared/empty-state.tsx +29 -0
  183. package/web/components/shared/field.tsx +77 -0
  184. package/web/components/shared/filter-popover.tsx +29 -0
  185. package/web/components/shared/form-frame.tsx +19 -0
  186. package/web/components/shared/icon-button.tsx +50 -0
  187. package/web/components/shared/index.ts +18 -0
  188. package/web/components/shared/mic-button.tsx +75 -0
  189. package/web/components/shared/pager.tsx +49 -0
  190. package/web/components/shared/picker.tsx +108 -0
  191. package/web/components/shared/project-mark.tsx +38 -0
  192. package/web/components/shared/segmented.tsx +43 -0
  193. package/web/components/shared/state-dot.tsx +4 -0
  194. package/web/components/shared/status-mark.tsx +26 -0
  195. package/web/components/shell/index.ts +3 -0
  196. package/web/components/shell/rail.tsx +259 -0
  197. package/web/components/shell/sprite.tsx +124 -0
  198. package/web/components/shell/wordmark.tsx +13 -0
  199. package/web/components/task/artifact-view.tsx +148 -0
  200. package/web/components/task/chat-bubble.tsx +43 -0
  201. package/web/components/task/filter-menu.tsx +38 -0
  202. package/web/components/task/index.ts +7 -0
  203. package/web/components/task/result-checks.tsx +34 -0
  204. package/web/components/task/result-view.tsx +103 -0
  205. package/web/components/task/status-badge.tsx +24 -0
  206. package/web/components/task/task-row.tsx +34 -0
  207. package/web/components/task/typing-dots.tsx +16 -0
  208. package/web/components/terminal/index.ts +3 -0
  209. package/web/components/terminal/terminal-bar.tsx +91 -0
  210. package/web/components/terminal/terminal-grid.tsx +149 -0
  211. package/web/components/terminal/terminal-modes.tsx +23 -0
  212. package/web/components/terminal/terminal-tile.tsx +139 -0
  213. package/web/dist/annotate.js +24 -0
  214. package/web/dist/board.css +718 -0
  215. package/web/dist/board.js +115 -0
  216. package/web/dist/boot.js +2 -0
  217. package/web/dist/notebook.css +319 -0
  218. package/web/dist/notebook.js +89 -0
  219. package/web/dist/popup.css +41 -0
  220. package/web/dist/popup.js +13 -0
  221. package/web/{term.js → dist/term.js} +48 -48
  222. package/web/dist/ui.css +3 -0
  223. package/web/dist/video.js +108 -0
  224. package/web/html/board.html +17 -0
  225. package/web/html/notes.html +14 -0
  226. package/web/html/popup.html +13 -0
  227. package/web/{video.html → html/video.html} +14 -15
  228. package/web/lib/annotate/index.ts +2 -0
  229. package/web/lib/annotate/notes.ts +105 -0
  230. package/web/lib/annotate/page.ts +121 -0
  231. package/web/lib/annotate/rules.ts +37 -0
  232. package/web/lib/annotate/session.ts +336 -0
  233. package/web/lib/board/board-actions.ts +119 -0
  234. package/web/lib/board/board-open.ts +12 -0
  235. package/web/lib/board/board-store.ts +159 -0
  236. package/web/lib/board/filter-box.ts +7 -0
  237. package/web/lib/board/index.ts +10 -0
  238. package/web/lib/board/nav.ts +29 -0
  239. package/web/lib/board/on-state.ts +90 -0
  240. package/web/lib/board/popups.ts +22 -0
  241. package/web/lib/board/snapshot.ts +105 -0
  242. package/web/lib/board/strip.ts +43 -0
  243. package/web/{board → lib/board}/ws-board.ts +1 -1
  244. package/web/lib/context/context-rules.ts +27 -0
  245. package/web/lib/context/context-store.ts +95 -0
  246. package/web/lib/context/feed.ts +28 -0
  247. package/web/lib/context/index.ts +3 -0
  248. package/web/lib/core/api.ts +86 -0
  249. package/web/lib/core/ask.ts +24 -0
  250. package/web/lib/core/board.ts +290 -0
  251. package/web/lib/core/brief.ts +31 -0
  252. package/web/lib/core/format.ts +8 -0
  253. package/web/lib/core/host.ts +107 -0
  254. package/web/lib/core/index.ts +16 -0
  255. package/web/{board → lib/core}/labels.ts +6 -5
  256. package/web/lib/core/layers.ts +7 -0
  257. package/web/lib/core/leave.ts +7 -0
  258. package/web/lib/core/motion.ts +10 -0
  259. package/web/{board/toast.ts → lib/core/notices.ts} +2 -20
  260. package/web/lib/core/notifier.ts +15 -0
  261. package/web/lib/core/store.ts +39 -0
  262. package/web/lib/core/term-handle.ts +8 -0
  263. package/web/lib/core/toast.ts +29 -0
  264. package/web/lib/core/utils.ts +15 -0
  265. package/web/lib/decision/index.ts +1 -0
  266. package/web/lib/decision/plan-questions.ts +39 -0
  267. package/web/lib/dictation/chunks.ts +93 -0
  268. package/web/lib/dictation/dictation-store.ts +22 -0
  269. package/web/lib/dictation/engine.ts +265 -0
  270. package/web/lib/dictation/index.ts +5 -0
  271. package/web/lib/dictation/mic.ts +42 -0
  272. package/web/lib/dictation/terminal-dictation.ts +50 -0
  273. package/web/lib/footer/footer-rules.ts +13 -0
  274. package/web/lib/footer/footer-store.ts +42 -0
  275. package/web/lib/footer/index.ts +2 -0
  276. package/web/lib/git/git-actions.ts +110 -0
  277. package/web/lib/git/git-panel.ts +43 -0
  278. package/web/lib/git/git-store.ts +47 -0
  279. package/web/lib/git/git.ts +170 -0
  280. package/web/lib/git/index.ts +4 -0
  281. package/web/lib/home/home-engine.ts +16 -0
  282. package/web/lib/home/home-events.ts +9 -0
  283. package/web/lib/home/home-store.ts +247 -0
  284. package/web/lib/home/home-window.ts +193 -0
  285. package/web/lib/home/home.ts +85 -0
  286. package/web/lib/home/index.ts +7 -0
  287. package/web/lib/home/onboarding.ts +199 -0
  288. package/web/lib/home/use-float-drag.ts +62 -0
  289. package/web/lib/icebox/icebox-actions.ts +518 -0
  290. package/web/lib/icebox/icebox-store.ts +112 -0
  291. package/web/lib/icebox/icebox-view.ts +48 -0
  292. package/web/lib/icebox/icebox.ts +273 -0
  293. package/web/lib/icebox/index.ts +8 -0
  294. package/web/lib/icebox/use-card-drag.ts +82 -0
  295. package/web/lib/icebox/use-ice-keys.ts +75 -0
  296. package/web/lib/icebox/use-icebox.ts +41 -0
  297. package/web/lib/icebox/use-row-swipe.ts +107 -0
  298. package/web/lib/markdown/index.ts +1 -0
  299. package/web/lib/markdown/markdown.ts +136 -0
  300. package/web/lib/notebook/autosave.ts +131 -0
  301. package/web/lib/notebook/deal.ts +58 -0
  302. package/web/lib/notebook/engine-complete.ts +128 -0
  303. package/web/lib/notebook/engine-preview.ts +287 -0
  304. package/web/lib/notebook/engine-types.ts +26 -0
  305. package/web/lib/notebook/engine-widgets.ts +218 -0
  306. package/web/lib/notebook/engine.ts +74 -0
  307. package/web/lib/notebook/index.ts +9 -0
  308. package/web/lib/notebook/kit-loader.ts +16 -0
  309. package/web/lib/notebook/kit.ts +12 -0
  310. package/web/{notes-lib.ts → lib/notebook/text.ts} +11 -10
  311. package/web/lib/notebook/vault-actions.ts +239 -0
  312. package/web/lib/notebook/vault-rules.ts +74 -0
  313. package/web/lib/notebook/vault-session.ts +73 -0
  314. package/web/lib/notebook/vault-store.ts +63 -0
  315. package/web/lib/notes/index.ts +4 -0
  316. package/web/lib/notes/md-html.ts +115 -0
  317. package/web/lib/notes/notes-actions.ts +32 -0
  318. package/web/lib/notes/notes-store.ts +22 -0
  319. package/web/lib/notes/notes.ts +58 -0
  320. package/web/{board → lib/notes}/rich.ts +1 -2
  321. package/web/lib/phone/index.ts +7 -0
  322. package/web/lib/phone/phone-actions.ts +77 -0
  323. package/web/lib/phone/phone-home.ts +102 -0
  324. package/web/lib/phone/phone-setup.ts +59 -0
  325. package/web/lib/phone/phone-sheet.ts +25 -0
  326. package/web/lib/phone/phone-store.ts +32 -0
  327. package/web/lib/phone/sheet-swipe.ts +55 -0
  328. package/web/lib/phone/use-phone-setup.ts +89 -0
  329. package/web/lib/project/add-project.ts +37 -0
  330. package/web/lib/project/branch.ts +14 -0
  331. package/web/lib/project/index.ts +5 -0
  332. package/web/lib/project/project-bar.ts +76 -0
  333. package/web/lib/project/project-pick.ts +36 -0
  334. package/web/lib/project/ws-menu.ts +8 -0
  335. package/web/lib/rail/agents.ts +63 -0
  336. package/web/lib/rail/card-links.ts +20 -0
  337. package/web/lib/rail/index.ts +7 -0
  338. package/web/lib/rail/rail-actions.ts +74 -0
  339. package/web/lib/rail/rail-boot.ts +99 -0
  340. package/web/lib/rail/rail-store.ts +85 -0
  341. package/web/lib/rail/rules.ts +241 -0
  342. package/web/lib/rail/source-marks.ts +17 -0
  343. package/web/lib/rail/use-rank-drag.ts +108 -0
  344. package/web/lib/resources/index.ts +3 -0
  345. package/web/lib/resources/resources-actions.ts +59 -0
  346. package/web/lib/resources/resources-store.ts +48 -0
  347. package/web/lib/resources/rules.ts +56 -0
  348. package/web/lib/router/index.ts +3 -0
  349. package/web/lib/router/route-rules.ts +96 -0
  350. package/web/lib/router/route-store.ts +115 -0
  351. package/web/lib/router/use-route-classes.ts +15 -0
  352. package/web/lib/run/browser.ts +53 -0
  353. package/web/lib/run/card-terminal.ts +32 -0
  354. package/web/lib/run/doc.ts +42 -0
  355. package/web/lib/run/grip.ts +8 -0
  356. package/web/lib/run/index.ts +19 -0
  357. package/web/lib/run/kept.ts +58 -0
  358. package/web/lib/run/layout-store.ts +156 -0
  359. package/web/lib/run/layout.ts +195 -0
  360. package/web/lib/run/panel-actions.ts +104 -0
  361. package/web/lib/run/panel-derive.ts +148 -0
  362. package/web/lib/run/panel-store.ts +125 -0
  363. package/web/lib/run/preview.ts +105 -0
  364. package/web/lib/run/run-actions.ts +118 -0
  365. package/web/lib/run/run-view-store.ts +134 -0
  366. package/web/lib/run/term-loader.ts +19 -0
  367. package/web/lib/run/use-panel-run.ts +125 -0
  368. package/web/lib/run/use-run-lifecycle.ts +70 -0
  369. package/web/lib/run/viewer.ts +12 -0
  370. package/web/lib/run/workspace.ts +281 -0
  371. package/web/lib/run/ws-actions.ts +293 -0
  372. package/web/lib/run/ws-derive.ts +50 -0
  373. package/web/lib/run/ws-draw.ts +102 -0
  374. package/web/lib/run/ws-store.ts +21 -0
  375. package/web/lib/run/ws-tabs.ts +125 -0
  376. package/web/lib/search/index.ts +3 -0
  377. package/web/lib/search/search-match.ts +48 -0
  378. package/web/lib/search/search-rows.ts +228 -0
  379. package/web/lib/search/search.ts +30 -0
  380. package/web/lib/search/use-search-rows.ts +22 -0
  381. package/web/lib/server/attention.ts +29 -0
  382. package/web/lib/server/index.ts +6 -0
  383. package/web/lib/server/poll-rules.ts +57 -0
  384. package/web/lib/server/poller.ts +210 -0
  385. package/web/lib/server/server-store.ts +39 -0
  386. package/web/lib/server/types.ts +31 -0
  387. package/web/lib/server/use-server.ts +19 -0
  388. package/web/lib/settings/agent-favicons.ts +14 -0
  389. package/web/lib/settings/index.ts +7 -0
  390. package/web/lib/settings/panel-settings.ts +29 -0
  391. package/web/lib/settings/settings-actions.ts +357 -0
  392. package/web/lib/settings/settings-store.ts +114 -0
  393. package/web/lib/settings/settings.ts +413 -0
  394. package/web/lib/settings/skill-icons.ts +24 -0
  395. package/web/lib/settings/update.ts +70 -0
  396. package/web/lib/shared/data-urls.ts +32 -0
  397. package/web/lib/shared/index.ts +4 -0
  398. package/web/lib/shared/use-draft.ts +38 -0
  399. package/web/lib/shared/use-narrow.ts +11 -0
  400. package/web/lib/shared/use-pager.ts +24 -0
  401. package/web/lib/shell/appearance.ts +97 -0
  402. package/web/lib/shell/help-store.ts +4 -0
  403. package/web/lib/shell/index.ts +4 -0
  404. package/web/lib/shell/shell-store.ts +23 -0
  405. package/web/lib/shell/stored-look.ts +47 -0
  406. package/web/lib/task/index.ts +7 -0
  407. package/web/lib/task/task-results.ts +92 -0
  408. package/web/lib/task/tasks.ts +132 -0
  409. package/web/lib/task/use-live-frame.ts +85 -0
  410. package/web/lib/task/use-saved-text.ts +25 -0
  411. package/web/lib/task/use-task.ts +161 -0
  412. package/web/lib/task/use-tasks.ts +50 -0
  413. package/web/{board → lib/task}/zoom.ts +25 -12
  414. package/web/lib/terminal/hidden-badge.ts +15 -0
  415. package/web/lib/terminal/index.ts +8 -0
  416. package/web/lib/terminal/layout.ts +138 -0
  417. package/web/{term-font.ts → lib/terminal/term-font.ts} +3 -2
  418. package/web/lib/terminal/terminal-store.ts +65 -0
  419. package/web/lib/terminal/terms-feed.ts +37 -0
  420. package/web/lib/terminal/use-arranged.ts +15 -0
  421. package/web/lib/terminal/use-terminal-keys.ts +37 -0
  422. package/web/lib/url/index.ts +1 -0
  423. package/web/lib/url/safe-url.ts +9 -0
  424. package/web/notebook/notebook.ts +27 -0
  425. package/web/notebook/notes-lib.ts +3 -0
  426. package/web/pages/board/App.tsx +76 -0
  427. package/web/pages/board/header.tsx +83 -0
  428. package/web/pages/board/help.tsx +59 -0
  429. package/web/pages/board/host-bridge.ts +94 -0
  430. package/web/pages/board/host.tsx +19 -0
  431. package/web/pages/board/keys.ts +112 -0
  432. package/web/pages/board/live.ts +39 -0
  433. package/web/pages/board/main.ts +32 -0
  434. package/web/pages/board/pages.tsx +86 -0
  435. package/web/pages/board/panel.tsx +157 -0
  436. package/web/pages/board/portal.tsx +39 -0
  437. package/web/pages/board/use-boot.ts +13 -0
  438. package/web/pages/board/views.ts +63 -0
  439. package/web/pages/board-page.tsx +62 -0
  440. package/web/pages/home-page.tsx +127 -0
  441. package/web/pages/icebox-page.tsx +440 -0
  442. package/web/pages/notebook/App.tsx +35 -0
  443. package/web/pages/notebook-page.tsx +50 -0
  444. package/web/pages/popup/App.tsx +207 -0
  445. package/web/pages/settings-page.tsx +111 -0
  446. package/web/pages/task-page.tsx +383 -0
  447. package/web/pages/tasks-page.tsx +151 -0
  448. package/web/pages/terminal-page.tsx +15 -0
  449. package/web/popup/popup.ts +7 -0
  450. package/web/{term.ts → term/term.ts} +48 -20
  451. package/web/ui/alert-dialog.tsx +39 -0
  452. package/web/ui/badge.tsx +20 -0
  453. package/web/ui/button.tsx +37 -0
  454. package/web/ui/checkbox.tsx +20 -0
  455. package/web/ui/command.tsx +41 -0
  456. package/web/ui/dialog.tsx +28 -0
  457. package/web/ui/dropdown-menu.tsx +54 -0
  458. package/web/ui/icon.tsx +17 -0
  459. package/web/ui/index.ts +21 -0
  460. package/web/ui/input.tsx +9 -0
  461. package/web/ui/label.tsx +7 -0
  462. package/web/ui/legacy/board.css +715 -0
  463. package/web/{notes.html → ui/legacy/notes.css} +23 -157
  464. package/web/ui/legacy/popup.css +40 -0
  465. package/web/ui/popover.tsx +28 -0
  466. package/web/ui/select.tsx +61 -0
  467. package/web/ui/sheet.tsx +43 -0
  468. package/web/ui/skeleton.tsx +6 -0
  469. package/web/ui/sonner.tsx +25 -0
  470. package/web/ui/spinner.tsx +12 -0
  471. package/web/ui/switch.tsx +18 -0
  472. package/web/ui/tabs.tsx +18 -0
  473. package/web/ui/textarea.tsx +14 -0
  474. package/web/ui/theme.css +125 -0
  475. package/web/ui/toggle.tsx +8 -0
  476. package/web/ui/tooltip.tsx +26 -0
  477. package/web/{video.ts → video/video.ts} +5 -5
  478. package/web/board/add-project.ts +0 -147
  479. package/web/board/agent-favicons.ts +0 -9
  480. package/web/board/agent-term.ts +0 -51
  481. package/web/board/annotate-lib.ts +0 -19
  482. package/web/board/annotate.ts +0 -221
  483. package/web/board/api.ts +0 -180
  484. package/web/board/approvals.ts +0 -109
  485. package/web/board/badge.ts +0 -115
  486. package/web/board/cards.ts +0 -1080
  487. package/web/board/chat.ts +0 -128
  488. package/web/board/context.ts +0 -248
  489. package/web/board/dictation.ts +0 -343
  490. package/web/board/dom.ts +0 -132
  491. package/web/board/drafts.ts +0 -21
  492. package/web/board/fixes.ts +0 -89
  493. package/web/board/git.ts +0 -416
  494. package/web/board/home-ws.ts +0 -266
  495. package/web/board/home.ts +0 -421
  496. package/web/board/icebox.ts +0 -1788
  497. package/web/board/keys.ts +0 -121
  498. package/web/board/live.ts +0 -87
  499. package/web/board/main.ts +0 -94
  500. package/web/board/markdown.ts +0 -210
  501. package/web/board/onboarding.ts +0 -227
  502. package/web/board/panel.ts +0 -437
  503. package/web/board/phone-setup.ts +0 -79
  504. package/web/board/phone.ts +0 -219
  505. package/web/board/projects.ts +0 -277
  506. package/web/board/resources.ts +0 -170
  507. package/web/board/run-pick.ts +0 -41
  508. package/web/board/run-view.ts +0 -1316
  509. package/web/board/search-match.ts +0 -20
  510. package/web/board/search.ts +0 -330
  511. package/web/board/settings-accounts.ts +0 -76
  512. package/web/board/settings-agents.ts +0 -102
  513. package/web/board/settings-automations.ts +0 -71
  514. package/web/board/settings-cleanup.ts +0 -42
  515. package/web/board/settings-orchestration.ts +0 -32
  516. package/web/board/settings-pages.ts +0 -62
  517. package/web/board/settings-skills.ts +0 -103
  518. package/web/board/settings-voice.ts +0 -28
  519. package/web/board/settings.ts +0 -490
  520. package/web/board/store.ts +0 -47
  521. package/web/board/task-page.ts +0 -628
  522. package/web/board/task-results.ts +0 -234
  523. package/web/board/tasks.ts +0 -242
  524. package/web/board/terms.ts +0 -390
  525. package/web/board/update.ts +0 -171
  526. package/web/board/viewer.ts +0 -47
  527. package/web/board/views.ts +0 -164
  528. package/web/board/whatsapp-setup.ts +0 -149
  529. package/web/board/workspace.ts +0 -650
  530. package/web/board/ws-board-ui.ts +0 -95
  531. package/web/board/ws-tabs.ts +0 -227
  532. package/web/board.html +0 -1563
  533. package/web/board.js +0 -505
  534. package/web/notebook.js +0 -519
  535. package/web/notebook.ts +0 -1254
  536. package/web/popup.html +0 -141
  537. package/web/video.js +0 -575
  538. /package/web/{term.css → dist/term.css} +0 -0
  539. /package/web/{board/term-sessions.ts → lib/terminal/sessions.ts} +0 -0
  540. /package/web/{board/terminal-viewport.ts → lib/terminal/viewport.ts} +0 -0
  541. /package/web/{term-paste.ts → term/term-paste.ts} +0 -0
@@ -0,0 +1,36 @@
1
+ import { post, toast } from "@lib/core";
2
+ import { load, setServer } from "@lib/server";
3
+ import { openAdd } from "./add-project.ts";
4
+
5
+ // The picked project outlives a reload. Saved only where the user changes it, so a
6
+ // second tab refreshing cannot undo it; a view the URL asked for is a one-off. Read once, as the page opened: a deep link
7
+ // that later rewrites the address to ?all=1 (a note's ?run=) does not make the person's own pick a one-off.
8
+ export const urlAll = typeof location !== "undefined" && new URLSearchParams(location.search).has("all");
9
+ export function keep(d) {
10
+ if (urlAll) return;
11
+ try {
12
+ d ? localStorage.setItem("kz-proj", d) : localStorage.removeItem("kz-proj");
13
+ } catch (e) {}
14
+ }
15
+ export async function pick(v) {
16
+ if (v === "__find") {
17
+ toast("Searching…");
18
+ const j = await post("/find", {});
19
+ if (j.ok) toast(j.added ? `Found ${j.added} new project${j.added === 1 ? "" : "s"}` : "No new projects found");
20
+ } else if (v === "__new" || v === "__clone") {
21
+ // The same sheet as the side menu's +; it adds the project and reloads onto it.
22
+ openAdd({ start: v === "__new" ? "create" : "clone" });
23
+ return;
24
+ } else if (v === "all") {
25
+ setServer({ all: true });
26
+ keep();
27
+ } else {
28
+ const j = await post("/cd", { dir: v });
29
+ if (j.ok) {
30
+ setServer({ all: false });
31
+ setServer({ dir: v });
32
+ keep(v);
33
+ }
34
+ }
35
+ await load();
36
+ }
@@ -0,0 +1,8 @@
1
+ // The right-click menu on a worktree row in the side menu: the old code (board/workspace.ts) knows what a row can do and
2
+ // hands over the rows and where the pointer was; components/project/ws-menu.tsx draws the menu.
3
+ import { create } from "zustand";
4
+
5
+ export type WsMenuItem = { label: string; run: () => void };
6
+ export const useWsMenu = create<{ at: { x: number; y: number; items: WsMenuItem[] } | null }>()(() => ({ at: null }));
7
+ export const openWsMenu = (x: number, y: number, items: WsMenuItem[]) => useWsMenu.setState({ at: { x, y, items } });
8
+ export const closeWsMenu = () => useWsMenu.setState({ at: null });
@@ -0,0 +1,63 @@
1
+ // The agents of the side menu's workspace rows, without the DOM (tested in ws-tabs.test.ts and rail-rules.test.ts): which
2
+ // status each open agent terminal shows (held at "working" for a moment after the output stops), and which agents a
3
+ // workspace row lists. Pure, so the board's old modules can import it into the notebook bundle without React.
4
+ import type { Agent } from "@lib/server";
5
+ export type { Agent };
6
+ export type Status = "conflict" | "failed" | "asking" | "working" | "done";
7
+ // Output flickers: entering "working" is immediate, leaving it for "done" waits this long after the last busy tick.
8
+ export const SETTLE_MS = 3000;
9
+ const seenBusy = new Map<string, number>(); // pty key + start time -> when it was last seen busy
10
+ const id = (a: Agent) => a.key + "@" + (a.born ?? 0); // a restarted pty under the same key is a new agent
11
+ const ORDER: Record<Status, number> = { conflict: 0, failed: 0, asking: 0, working: 1, done: 2 };
12
+ export const WORD: Record<Status, string> = {
13
+ conflict: "Conflict",
14
+ failed: "Land failed",
15
+ asking: "Asking",
16
+ working: "Working",
17
+ done: "Done",
18
+ };
19
+ export const DOT: Record<Status, string> = {
20
+ conflict: "fail",
21
+ failed: "fail",
22
+ asking: "wait",
23
+ working: "build",
24
+ done: "done",
25
+ }; // the .si icons
26
+ // asking comes first and is immediate both ways (the server already waits for the screen to settle).
27
+ export function agentStatus(a: Agent, now: number, seen = seenBusy): Status {
28
+ if (a.land) return a.land === "conflict" ? "conflict" : "failed";
29
+ if (a.asking) return "asking";
30
+ if (a.busy) return (seen.set(id(a), now), "working");
31
+ return now - (seen.get(id(a)) ?? -Infinity) < SETTLE_MS ? "working" : "done";
32
+ }
33
+ // Milliseconds until an agent now held at "working" may turn "done" (to redraw then); Infinity when none is.
34
+ export const settleIn = (as: Agent[], now: number, seen = seenBusy) =>
35
+ Math.min(
36
+ Infinity,
37
+ ...as
38
+ .filter((a) => !a.asking && !a.busy && seen.has(id(a)))
39
+ .map((a) => SETTLE_MS - (now - seen.get(id(a))!))
40
+ .filter((x) => x > 0),
41
+ );
42
+ // Forgets agents that are gone, so the memory stays as small as the open agents.
43
+ export const forgetAgents = (as: Agent[], seen = seenBusy) => {
44
+ const live = new Set(as.map(id));
45
+ for (const k of seen.keys()) if (!live.has(k)) seen.delete(k);
46
+ };
47
+ export type ARow = { a: Agent; st: Status };
48
+ // The agents of one workspace (the card's `ws` resolved as the rows resolve it), asking first, then working, then done.
49
+ export const wsAgents = (as: Agent[], dir: string, ws: string, wsOf, now: number, seen = seenBusy): ARow[] =>
50
+ as
51
+ .filter((a) => a.dir === dir && wsOf({ state: a.dir, ws: a.ws }) === ws)
52
+ .map((a) => ({ a, st: agentStatus(a, now, seen) }))
53
+ .sort((x, y) => ORDER[x.st] - ORDER[y.st]);
54
+ // An expanded card's row text: the agent's latest output line, else the status and the agent.
55
+ export const lineOf = ({ a, st }: ARow) => (a.land ? "" : a.last) || `${WORD[st]} - ${a.name}`;
56
+ // Expanded cards, remembered per workspace (localStorage kz-wsopen): the map of dir\0ws to true.
57
+ export const openKey = (dir: string, ws: string) => dir + "\0" + ws;
58
+ export function toggleOpen(m: Record<string, true>, dir: string, ws: string) {
59
+ const k = openKey(dir, ws);
60
+ if (m[k]) delete m[k];
61
+ else m[k] = true;
62
+ return m;
63
+ }
@@ -0,0 +1,20 @@
1
+ // What the board does with a card or a workspace address: its state mark as the side menu would draw it, the address of a
2
+ // workspace, the Home workspace's folder, and the projects a workspace can be made in.
3
+ import { railDataNow } from "@lib/server";
4
+ import { attentionFor } from "./rail-store.ts";
5
+ import { projName, stateOf, wsOfCard as ruleWsOfCard } from "./rules.ts";
6
+
7
+ // A card's state icon (.si) and the word under its title, with the attention the Tasks read says it has.
8
+ export const cardState = (c: any) => stateOf(c, attentionFor(c));
9
+ // The floating Home workspace's folder (~/.kaizen/home): never a project's `.kaizen` state dir, and it has no workspace view.
10
+ export const isHomeDir = (d: unknown) => typeof d === "string" && /[\\/]\.kaizen[\\/]home$/.test(d);
11
+ // A Home terminal's address opens the board with its panel (lib/home/home-events.ts), from any page.
12
+ export const wsHref = (dir: string, ws: string) =>
13
+ isHomeDir(dir) ? "/?view=board&homews=1" : `/?view=ws&dir=${encodeURIComponent(dir)}&ws=${encodeURIComponent(ws)}`;
14
+ // Projects that are git repositories (the main checkout has a branch): where a workspace can be made.
15
+ export const gitProjects = () =>
16
+ railDataNow()
17
+ .projects.filter((p) => p.workspaces?.some((w) => w.branch))
18
+ .map((p) => ({ dir: p.dir as string, name: projName(p.dir, railDataNow().projects) }));
19
+ // A card's workspace row, by the projects the last refresh listed (lib/rail/rules.ts takes them as an argument).
20
+ export const wsOfCardNow = (c: any, projects = railDataNow().projects) => ruleWsOfCard(c, projects);
@@ -0,0 +1,7 @@
1
+ export * from "./agents.ts";
2
+ export * from "./card-links.ts";
3
+ export * from "./rail-actions.ts";
4
+ export * from "./rail-store.ts";
5
+ export * from "./rules.ts";
6
+ export * from "./use-rank-drag.ts";
7
+ export * from "./source-marks.ts";
@@ -0,0 +1,74 @@
1
+ // What the side menu's rows do: ask the page to open something, and the worktree menu's requests. Open-in-place goes
2
+ // through host.open (the board answers it); when nobody does, the address changes.
3
+ import { ask, host, toast } from "@lib/core";
4
+ import { openAdd, type WsMenuItem } from "@lib/project";
5
+ import { getServer } from "@lib/server";
6
+ import { togglePin, useRail } from "./rail-store.ts";
7
+ import { wsLabel } from "./rules.ts";
8
+
9
+ // The two buttons the menu only draws: + (add a project) and Search. lib/rail/rail-boot.ts and lib/search/search-rows.ts answer.
10
+ export const railActions = { add: () => {}, search: () => {} };
11
+
12
+ // True when the page opened it in place (host.open: the board does, the Notebook page does not).
13
+ export const openTask = (id: string, dir: string) => host.open.task({ id, dir });
14
+ export const openWs = (dir: string, ws: string) => host.open.ws({ dir, ws });
15
+ // An agent's mark: the board opens that terminal tab in its workspace; the notebook page opens the workspace.
16
+ export const openTerm = (dir: string, ws: string, key: string) => {
17
+ if (!host.open.term({ dir, ws, key })) host.navigate(host.wsHref(dir, ws));
18
+ };
19
+ export const addWorkspace = (dir: string) => openAdd({ dir, start: "ws" });
20
+
21
+ async function wsOp(dir: string, ws: string, op: "update" | "delete") {
22
+ toast(op === "update" ? "Updating…" : "Deleting…");
23
+ const r = await fetch("/workspace", {
24
+ method: "POST",
25
+ headers: { "content-type": "application/json" },
26
+ body: JSON.stringify({ dir, ws, op }),
27
+ }).catch(() => null);
28
+ const j = await r?.json().catch(() => ({}));
29
+ toast(r?.ok ? (op === "update" ? j.out || "Updated" : "Deleted") : j?.error || j?.why || "Failed");
30
+ }
31
+ const copy = (text: string) =>
32
+ navigator.clipboard.writeText(text).then(
33
+ () => toast("Copied"),
34
+ () => toast("Could not copy"),
35
+ );
36
+ // The right-click menu on a worktree row: update, copy path, copy name, pin, delete (the main checkout has neither Update nor Delete).
37
+ export function wsMenuItems(dir: string, ws: string): WsMenuItem[] {
38
+ const w = getServer()
39
+ .every?.projects.find((p) => p.dir === dir)
40
+ ?.workspaces?.find((x) => x.path === ws);
41
+ if (!w) return [];
42
+ const name = wsLabel(w),
43
+ pinned = useRail.getState().pins.includes(dir + "\0" + ws);
44
+ return [
45
+ ...(w.main ? [] : [{ label: "Update", run: () => void wsOp(dir, ws, "update") }]),
46
+ { label: "Copy path", run: () => void copy(ws) },
47
+ { label: "Copy worktree name", run: () => void copy(name) },
48
+ { label: pinned ? "Unpin" : "Pin", run: () => togglePin(dir, ws) },
49
+ ...(w.main
50
+ ? []
51
+ : [
52
+ {
53
+ label: "Delete",
54
+ run: async () => {
55
+ const yes = await ask({
56
+ title: `Delete worktree "${name}"?`,
57
+ description: `Removes the folder. Refused while it has uncommitted changes. The branch stays.\n\n${ws}`,
58
+ confirmLabel: "Delete",
59
+ danger: true,
60
+ });
61
+ if (yes) void wsOp(dir, ws, "delete");
62
+ },
63
+ },
64
+ ]),
65
+ ];
66
+ }
67
+ export const saveOrder = (dirs: string[]) => {
68
+ const fail = () => toast("Could not save the project order");
69
+ void fetch("/projects/order", {
70
+ method: "POST",
71
+ headers: { "content-type": "application/json" },
72
+ body: JSON.stringify({ dirs }),
73
+ }).then((r) => !r.ok && fail(), fail);
74
+ };
@@ -0,0 +1,99 @@
1
+ // The side menu's start-up on every page (board, notebook, video): the live reads that feed its counts and marks (lib/server),
2
+ // the add-project sheet, the Search link and the animation phase of its state icons. The list itself is React (components/rail, data in the
3
+ // server store). Stands alone, so the notebook and video bundles can carry it without the board.
4
+ import { openAdd, type AddOpts } from "@lib/project/add-project.ts";
5
+ import { startRailFeed } from "@lib/server";
6
+ import { gitProjects, wsHref } from "./card-links.ts";
7
+ import { leave } from "@lib/core";
8
+ import { initSearch } from "@lib/search/search-rows.ts";
9
+ import { kitHere, loadKit } from "@lib/notebook/kit-loader.ts";
10
+ import { railActions } from "./rail-actions.ts";
11
+
12
+ // The Projects list, the sheet and the right-click menu are React. The board's App draws them; the Notebook page does the
13
+ // same in its own bundle (notebook/kit.ts, registered as window.kzKit) and opens them in place. On Video, which has no kit,
14
+ // the + button sends the person to the board with the sheet asked for (?add=), as Search does, and Video lists no projects.
15
+ // Set by the board's own start: the Notebook and Video are not the board.
16
+ let onBoard = false;
17
+ // The kit for this page, with what only this page knows handed over: where a new workspace opens, the Projects list, and
18
+ // a way to leave that writes the open note first. The toast and question of the old code then show through the kit too.
19
+ export async function kitFor() {
20
+ const k = await loadKit();
21
+ k.setHost({
22
+ gitProjects,
23
+ wsHref,
24
+ navigate: leave,
25
+ // The Notebook keeps its own project choice: pick it for the board too, then reload onto it.
26
+ pickProject: async (dir: string) => {
27
+ await fetch("/cd", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify({ dir }) }).catch(() => null);
28
+ try {
29
+ localStorage.setItem("kz-proj", dir);
30
+ } catch {}
31
+ leave("/notebook?dir=" + encodeURIComponent(dir));
32
+ },
33
+ });
34
+ return k;
35
+ }
36
+ function addProject(o: AddOpts) {
37
+ if (onBoard) return openAdd(o);
38
+ const q = new URLSearchParams({ view: "board", add: o.start ?? "1" });
39
+ if (o.dir) q.set("adddir", o.dir);
40
+ kitFor().then((k) => k.openAdd(o), () => leave("/?" + q));
41
+ }
42
+ // Arriving from the notebook or Video with the sheet asked for.
43
+ function openAsked() {
44
+ const q = new URLSearchParams(location.search),
45
+ add = q.get("add");
46
+ if (!add || !onBoard) return;
47
+ const dir = q.get("adddir");
48
+ q.delete("add");
49
+ q.delete("adddir");
50
+ history.replaceState(null, "", location.pathname + (q.toString() ? "?" + q : "") + location.hash);
51
+ return setTimeout(() => openAdd({ dir, ...(add === "ws" || add === "folder" || add === "clone" || add === "create" ? { start: add } : {}) }), 400);
52
+ }
53
+ // Rows are redrawn on every refresh, which restarts a CSS animation from 0deg: the state
54
+ // icons jumped back mid-turn. Pinning each to the page clock's origin keeps them in phase
55
+ // (the si-* animations have no delay for this to cancel).
56
+ const syncSpin = () =>
57
+ document.getAnimations().forEach((a: any) => {
58
+ if (a.animationName?.startsWith("si-") && a.startTime !== 0) a.startTime = 0;
59
+ });
60
+ export function initRail(o: { board?: boolean; video?: { add: HTMLElement | null; search: HTMLElement | null } } = {}) {
61
+ onBoard = !!o.board;
62
+ const offSearch = initSearch(onBoard);
63
+ let queued = false;
64
+ const hasSi = (n: any) => n.nodeType === 1 && (n.classList.contains("si") || n.querySelector(".si"));
65
+ const spin = new MutationObserver((rs) => {
66
+ if (queued || !rs.some((r) => [...r.addedNodes].some(hasSi))) return;
67
+ queued = true;
68
+ requestAnimationFrame(() => {
69
+ queued = false;
70
+ syncSpin();
71
+ });
72
+ });
73
+ spin.observe(document.body, { childList: true, subtree: true });
74
+ const offFeed = startRailFeed(onBoard);
75
+ // The Notebook's popups (the add-project sheet, the worktree menu) take what only this page knows through the kit.
76
+ if (!onBoard && kitHere()) void kitFor().catch(() => {});
77
+ // The sheet: add a folder, clone, create, or start a workspace; the current project is preselected.
78
+ const asked = openAsked();
79
+ // Video's menu is static HTML, not the React Rail: its two buttons are handed over by the page.
80
+ if (o.video) {
81
+ if (o.video.add) o.video.add.onclick = railActions.add;
82
+ if (o.video.search) o.video.search.onclick = (e) => (e.preventDefault(), railActions.search());
83
+ }
84
+ return () => (spin.disconnect(), offFeed(), offSearch(), clearTimeout(asked));
85
+ }
86
+ // The + button: add a folder, clone, create, or start a workspace.
87
+ railActions.add = () => {
88
+ const p = new URLSearchParams(location.search);
89
+ addProject({ dir: ["run", "ws"].includes(p.get("view") ?? "") ? p.get("dir") : pickedDir() });
90
+ };
91
+ // The one project the Projects filter is narrowed to (it keeps its choice in this browser; lib/rail/rail-store.ts).
92
+ function pickedDir() {
93
+ try {
94
+ const d = JSON.parse(localStorage.getItem("kz-rail-filter2") || "{}").dirs;
95
+ return Array.isArray(d) && d.length === 1 ? (d[0] as string) : null;
96
+ } catch {
97
+ return null;
98
+ }
99
+ }
@@ -0,0 +1,85 @@
1
+ // The side menu's state: what this browser keeps (the filter, folded projects, pinned worktrees, expanded agent lists). The
2
+ // cards, projects, agents and tasks it lists come from the server store (lib/server). Drawn by components/rail.
3
+ import { create } from "zustand";
4
+ import { getServer, onServer, setServer } from "@lib/server";
5
+ import { forgetAgents } from "./agents.ts";
6
+ import { taskForCard } from "./rules.ts";
7
+ import { ALLF, pinKey, type RailFilt } from "./rules.ts";
8
+
9
+ const read = <T>(k: string, d: T): T => {
10
+ try {
11
+ return JSON.parse(localStorage.getItem(k) || "null") ?? d;
12
+ } catch {
13
+ return d;
14
+ }
15
+ };
16
+ const keep = (k: string, v: unknown) => {
17
+ try {
18
+ localStorage.setItem(k, JSON.stringify(v));
19
+ } catch {}
20
+ };
21
+ // The held "working" status forgets an agent the server no longer lists.
22
+ onServer(
23
+ (s) => s.every,
24
+ (e) => e && forgetAgents(e.agents),
25
+ );
26
+ // The task that carries a card, by what the server last said needs attention.
27
+ export const attentionFor = (c: any) => taskForCard(c, getServer().tasks);
28
+ const K = { filt: "kz-rail-filter2", folded: "kz-rail-folded", pins: "kz-ws-pins", open: "kz-wsopen" };
29
+
30
+ type Rail = {
31
+ filt: RailFilt;
32
+ folded: string[];
33
+ pins: string[];
34
+ open: Record<string, true>;
35
+ q: string; // the filter popup's search
36
+ tick: number; // bumped when a held "working" agent may turn done
37
+ };
38
+ export const useRail = create<Rail>()(() => ({
39
+ filt: { ...ALLF, ...read<Partial<RailFilt>>(K.filt, {}) },
40
+ folded: read<string[]>(K.folded, []),
41
+ pins: read<string[]>(K.pins, []),
42
+ open: read<Record<string, true>>(K.open, {}),
43
+ q: "",
44
+ tick: 0,
45
+ }));
46
+
47
+ export const bumpRail = () => useRail.setState((s) => ({ tick: s.tick + 1 }));
48
+ export const setRailQuery = (q: string) => useRail.setState({ q });
49
+ export function setRailFilter(f: Partial<RailFilt>) {
50
+ const filt = { ...useRail.getState().filt, ...f };
51
+ keep(K.filt, filt);
52
+ useRail.setState({ filt });
53
+ }
54
+ export function foldProjects(dirs: string[], shut: boolean) {
55
+ const s = new Set(useRail.getState().folded);
56
+ for (const d of dirs) shut ? s.add(d) : s.delete(d);
57
+ const folded = [...s];
58
+ keep(K.folded, folded);
59
+ useRail.setState({ folded });
60
+ }
61
+ export const foldProject = (dir: string) => foldProjects([dir], !useRail.getState().folded.includes(dir));
62
+ export function togglePin(dir: string, ws: string) {
63
+ const k = pinKey(dir, ws),
64
+ pins = useRail.getState().pins;
65
+ const next = pins.includes(k) ? pins.filter((x) => x !== k) : [...pins, k];
66
+ keep(K.pins, next);
67
+ useRail.setState({ pins: next });
68
+ }
69
+ export function toggleAgents(dir: string, ws: string) {
70
+ const k = pinKey(dir, ws),
71
+ open = { ...useRail.getState().open };
72
+ if (open[k]) delete open[k];
73
+ else open[k] = true;
74
+ keep(K.open, open);
75
+ useRail.setState({ open });
76
+ }
77
+ // A drag dropped a project: the list shows the new order at once (the server saves it for every device).
78
+ export function orderProjects(dirs: string[]) {
79
+ const rank = new Map(dirs.map((x, i) => [x, i]));
80
+ const e = getServer().every;
81
+ if (e)
82
+ setServer({
83
+ every: { ...e, projects: [...e.projects].sort((a, b) => (rank.get(a.dir) ?? 1e9) - (rank.get(b.dir) ?? 1e9)) },
84
+ });
85
+ }
@@ -0,0 +1,241 @@
1
+ // The side menu's Projects list without the DOM: which projects and workspaces it lists for the cards, filter, pins and
2
+ // agents it is given, what each row shows, and the rules for the project drag. Pure, so a test stands alone and the
3
+ // board's old modules can import it into the notebook bundle without React (tested in rail-rules.test.ts).
4
+ import { wsAgents, type ARow, type Agent } from "./agents.ts";
5
+ import type { RailTask } from "@lib/server";
6
+
7
+ const DAY = 864e5;
8
+ export type { RailTask } from "@lib/server";
9
+ // What the old code hands the list on every refresh (/state?all=1 and /tasks?all=1).
10
+ export type { RailData } from "@lib/server";
11
+ // The Projects filter: projects ticked (none = all) and which kinds of card show. Running: tasks and agents that started
12
+ // and are not done. Done: the finished ones. Saved tasks that never started show in neither.
13
+ export type RailFilt = { dirs: string[]; running: boolean; done: boolean };
14
+ export const ALLF: RailFilt = { dirs: [], running: true, done: false };
15
+
16
+ // A done, approved run whose commit or push is still to do (the card's git mark).
17
+ export const gitDue = (c) =>
18
+ c.kind === "run" && c.status === "done" && c.accept !== "needs" && !c.archived && c.git === "pending";
19
+ export const dueWord = (c) => (c.gitDue === "push" ? "push" : "commit");
20
+ export const taskForCard = (c: any, tasks: RailTask[] | null) =>
21
+ tasks?.find(
22
+ (t) =>
23
+ t.dir === c.state &&
24
+ (t.id === c.taskId ||
25
+ (c.kind === "run" &&
26
+ [
27
+ t.activeRun,
28
+ ...(t.runs ?? t.runIds ?? []).map((r) => (typeof r === "string" ? r : r.id)),
29
+ ...(t.legacy?.kind === "run" ? [t.legacy.id] : []),
30
+ ].includes(c.id))),
31
+ );
32
+ export const RANK = { wait: 0, plan: 1, build: 2, review: 3, stalled: 4, idle: 5, done: 6, aband: 7 };
33
+ // A card's state icon (.si) and the word under its title.
34
+ export function stateOf(c, task?: RailTask | null) {
35
+ // Only a task that is really working spins; a saved goal is idle, a finished run keeps its own state.
36
+ // An abandoned run waits on nobody, and a done one only on its own approval or commit (below), so
37
+ // a linked task's "needs you" never paints a finished run orange.
38
+ if (task && !(c.kind === "run" && (c.status === "done" || c.status === "abandoned")))
39
+ return task.attention.category === "needs-you"
40
+ ? "wait"
41
+ : task.attention.category === "completed"
42
+ ? "done"
43
+ : ["interrupted", "failed"].includes(task.status ?? "")
44
+ ? "stalled"
45
+ : task.status === "draft"
46
+ ? "idle"
47
+ : "build";
48
+ // A task whose agent is working is a run being born: show it as planning.
49
+ if (c.kind === "idea") return !c.pty?.alive ? "idle" : c.pty.asking ? "wait" : c.pty.busy ? "plan" : "idle";
50
+ if (c.status === "waiting" || (c.pty?.alive && c.pty.asking)) return "wait";
51
+ if (c.status === "done") return c.accept === "needs" || gitDue(c) ? "wait" : "done";
52
+ if (c.status === "abandoned") return "aband";
53
+ if (c.status === "stalled") return "stalled";
54
+ return c.column >= 3 ? "review" : c.column === 2 ? "build" : "plan";
55
+ }
56
+ // Shown in the list: runs not archived, a finished one only for a day. Tasks not started yet
57
+ // live on the Tasks page; one whose agent is starting (it has a terminal) shows here.
58
+ export const listed = (c, now: number) =>
59
+ !c.archived &&
60
+ (c.kind === "idea" ? !!c.pty : !["done", "abandoned"].includes(c.status) || now - (c.moved ?? 0) < DAY);
61
+ // A card's title: its first line.
62
+ export const titleOf = (c) => (c.title || c.text || "").split("\n")[0];
63
+ // A card's address: its run workspace (?view=run&dir=&id=, or &idea= for a task).
64
+ export const cardHref = (c) =>
65
+ `/?view=run&dir=${encodeURIComponent(c.state)}&` +
66
+ (c.kind === "run" ? "id=" + encodeURIComponent(c.id) : "idea=" + encodeURIComponent(c.text));
67
+ export const projName = (dir: string, projects?: any[]) => {
68
+ const l = projects?.find((p) => p.dir === dir)?.label || dir.replace(/[\\/]\.kaizen$/, "");
69
+ return l.split(/[\\/]/).pop() || l;
70
+ };
71
+ export const wsLabel = (w) => w.branch || (w.main ? "workspace" : w.path.split(/[\\/]/).pop());
72
+ export const folderOf = (w) => w.path.split(/[\\/]/).pop() || w.path;
73
+ // A card's workspace row: its own (a run's worktree) when the project lists it, else the main checkout's, so a run whose
74
+ // worktree is gone, a task or an old run never vanishes.
75
+ export function wsOfCard(c, projects?: any[]) {
76
+ const ws = projects?.find((p) => p.dir === c.state)?.workspaces ?? [];
77
+ return ws.find((w) => w.path === c.ws)?.path ?? ws.find((w) => w.main)?.path ?? c.ws ?? "";
78
+ }
79
+
80
+ export type RailRow = {
81
+ w: any;
82
+ path: string;
83
+ label: string;
84
+ folder: string;
85
+ pinned: boolean;
86
+ st: string; // the dot: the most urgent run there, or an agent asking (amber) or working (spinner)
87
+ agents: ARow[];
88
+ open: boolean;
89
+ tasks: RailTask[];
90
+ };
91
+ export type RailGroup = {
92
+ dir: string;
93
+ name: string;
94
+ git: boolean;
95
+ mainWs: string;
96
+ shut: boolean;
97
+ empty: boolean;
98
+ rows: RailRow[];
99
+ };
100
+ export const pinKey = (dir: string, ws: string) => dir + "\0" + ws;
101
+
102
+ // The groups the list draws, in the registry's order (which the user ranks by dragging a project's bar).
103
+ export function railGroups(
104
+ d: RailData,
105
+ o: { filt: RailFilt; pins: string[]; folded: string[]; open: Record<string, true>; now: number },
106
+ ): RailGroup[] {
107
+ const { filt, now } = o,
108
+ pins = new Set(o.pins),
109
+ folded = new Set(o.folded),
110
+ tasks = d.tasks,
111
+ wsOf = (c) => wsOfCard(c, d.projects);
112
+ const projects = d.projects.filter((p) => p.workspaces?.length);
113
+ // Cards by project and workspace: each lands on a row, the main checkout when its own is not listed.
114
+ const by = new Map<string, any[]>();
115
+ const shownAgents = (rs: ARow[]) => rs.filter((r) => (r.st === "done" ? filt.done : filt.running));
116
+ const shown = (c) => {
117
+ const st = stateOf(c, taskForCard(c, tasks));
118
+ return (
119
+ (filt.running && ["wait", "plan", "build", "review", "stalled"].includes(st)) ||
120
+ (filt.done && (st === "done" || st === "aband"))
121
+ );
122
+ };
123
+ const st = (c) => stateOf(c, taskForCard(c, tasks));
124
+ for (const c of d.cards.filter((c) => listed(c, now) && shown(c))) {
125
+ const k = c.state + "\0" + wsOf(c);
126
+ if (!by.has(k)) by.set(k, []);
127
+ by.get(k)!.push(c);
128
+ }
129
+ return (
130
+ projects
131
+ .filter((p) => !filt.dirs.length || filt.dirs.includes(p.dir))
132
+ .map((p) => {
133
+ const dir = p.dir as string;
134
+ const rows = p.workspaces
135
+ .map((w) => {
136
+ const cs = by.get(dir + "\0" + w.path) ?? [];
137
+ const allCs = d.cards.filter((c) => c.state === dir && wsOf(c) === w.path && listed(c, now));
138
+ const onlyDone = allCs.length > 0 && allCs.every((c) => ["done", "abandoned"].includes(st(c)));
139
+ const ags = shownAgents(wsAgents(d.agents, dir, w.path, wsOf, now));
140
+ // An empty workspace or one with a run going is active; one holding only finished runs is done.
141
+ const keep = cs.length > 0 || ags.length > 0 || (filt.running && (w.main || !onlyDone));
142
+ return { w, cs, ags, keep };
143
+ })
144
+ .filter((r) => r.keep)
145
+ // Pinned worktrees first (a stable sort keeps the rest in git's order).
146
+ .sort((a, b) => +pins.has(pinKey(dir, b.w.path)) - +pins.has(pinKey(dir, a.w.path)));
147
+ return {
148
+ dir,
149
+ name: projName(dir, d.projects),
150
+ git: p.workspaces.some((w) => w.branch),
151
+ mainWs: p.workspaces?.find((w) => w.main)?.path ?? p.workspaces?.[0]?.path ?? dir,
152
+ // A project with nothing to list stays as a collapsed header.
153
+ shut: folded.has(dir) || !rows.length,
154
+ empty: !rows.length,
155
+ rows: rows.map(({ w, cs, ags }): RailRow => {
156
+ const st0 = cs.length ? st([...cs].sort((a, b) => RANK[st(a)] - RANK[st(b)])[0]) : "";
157
+ return {
158
+ w,
159
+ path: w.path,
160
+ label: wsLabel(w),
161
+ folder: folderOf(w),
162
+ pinned: pins.has(pinKey(dir, w.path)),
163
+ st:
164
+ st0 === "wait" || ags[0]?.st === "asking"
165
+ ? "wait"
166
+ : ags.some((r) => r.st === "working")
167
+ ? "build"
168
+ : st0 || (ags.length ? "done" : ""),
169
+ agents: ags,
170
+ open: !!o.open[pinKey(dir, w.path)],
171
+ tasks: taskLinks(tasks, dir, w, cs, filt),
172
+ };
173
+ }),
174
+ };
175
+ })
176
+ // Running only keeps every project listed, so an idle one reads "Nothing running" rather than vanishing.
177
+ .filter((g) => g.rows.length || filt.running)
178
+ );
179
+ }
180
+ // The Tasks that hang under a workspace row: not finished, not drafts, owned by a run listed there (or, on the main row,
181
+ // started with no run yet).
182
+ function taskLinks(tasks: RailTask[] | null, dir: string, w: any, cards: any[], filt: RailFilt): RailTask[] {
183
+ return (tasks ?? [])
184
+ .filter(
185
+ (t) =>
186
+ t.dir === dir &&
187
+ !t.legacy &&
188
+ t.attention.category !== "completed" &&
189
+ filt.running &&
190
+ t.status !== "draft" &&
191
+ (cards.some((c) => taskForCard(c, tasks)?.id === t.id) || (w.main && !(t.runs ?? t.runIds ?? []).length)),
192
+ )
193
+ .sort((a, b) => (a.created ?? 0) - (b.created ?? 0));
194
+ }
195
+ export const taskDot = (t: RailTask) =>
196
+ t.attention.category === "needs-you"
197
+ ? "wait"
198
+ : t.attention.category === "completed"
199
+ ? "done"
200
+ : ["interrupted", "failed"].includes(t.status ?? "")
201
+ ? "stalled"
202
+ : t.status === "draft"
203
+ ? "idle"
204
+ : "build";
205
+
206
+ // The filter button is lit when it narrows the list: a project ticked that exists, or a kind turned off or on.
207
+ export const filterOn = (filt: RailFilt, dirs: string[]) =>
208
+ filt.dirs.some((d) => dirs.includes(d)) || !filt.running || filt.done;
209
+ export const matchProjects = (dirs: string[], nameOf: (d: string) => string, q: string) =>
210
+ dirs.filter((d) => nameOf(d).toLowerCase().includes(q.toLowerCase()));
211
+ // The status chips of a workspace row's agents, most urgent first.
212
+ export const chipGroups = (rows: ARow[]) =>
213
+ (["conflict", "failed", "asking", "working", "done"] as const)
214
+ .map((st) => ({ st, rs: rows.filter((r) => r.st === st) }))
215
+ .filter((g) => g.rs.length);
216
+
217
+ // The workspace the address names (the row to light): ?ws=, else the workspace of the run ?id= names.
218
+ export function currentWs(search: string, cards: any[], projects?: any[]): { dir: string | null; ws: string | null } {
219
+ const cur = new URLSearchParams(search);
220
+ const c =
221
+ cur.get("id") && cards.find((x) => x.kind === "run" && x.state === cur.get("dir") && x.id === cur.get("id"));
222
+ return { dir: cur.get("dir"), ws: cur.get("ws") ?? (c ? wsOfCard(c, projects) : null) };
223
+ }
224
+
225
+ // The list with the item at `from` moved into slot `to` (0 = top, list.length = the end), counted
226
+ // before the move: the sidebar's project drag lands it where its drop line was drawn.
227
+ export const moveTo = <T>(list: T[], from: number, to: number): T[] => {
228
+ const out = list.filter((_, i) => i !== from);
229
+ out.splice(to > from ? to - 1 : to, 0, list[from]);
230
+ return out;
231
+ };
232
+ // The slot a dragged project lands in: before the first project whose bar's middle is below the pointer, else the end.
233
+ export const landingSlot = (boxes: { top: number; height: number }[], y: number) => {
234
+ const i = boxes.findIndex((r) => y < r.top + r.height / 2);
235
+ return i < 0 ? boxes.length : i;
236
+ };
237
+ // The new order after dropping `dir` into slot `to`, or null when it would not move.
238
+ export function rankedOrder(dirs: string[], dir: string, to: number): string[] | null {
239
+ const from = dirs.indexOf(dir);
240
+ return from >= 0 && to !== from && to !== from + 1 ? moveTo(dirs, from, to) : null;
241
+ }
@@ -0,0 +1,17 @@
1
+ // The marks of the first three request sources, in the side menu's Icebox item: a social platform's sprite, a sheet's
2
+ // grid, else the site's favicon. Drawn by components/rail/source-marks.tsx.
3
+ export type SourceMark = { kind: "social" | "sheet" | "icon"; id: string };
4
+ export const sourceMark = (s: { social?: string; url: string }): SourceMark | null => {
5
+ if (s.social) return { kind: "social", id: `#i-b-${s.social}` };
6
+ if (/docs\.google\.com\/spreadsheets|\.(csv|tsv)$/.test(s.url)) return { kind: "sheet", id: "#i-sheet" };
7
+ try {
8
+ return { kind: "icon", id: `${new URL(s.url).origin}/favicon.ico` };
9
+ } catch {
10
+ return null;
11
+ }
12
+ };
13
+ export const marksOf = (sources: { social?: string; url: string }[] | undefined): SourceMark[] =>
14
+ (sources ?? [])
15
+ .slice(0, 3)
16
+ .map(sourceMark)
17
+ .filter((m): m is SourceMark => !!m);