kaizen-agent 1.85.2 → 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 (545) 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/rea.ts +99 -11
  9. package/cli/settings.ts +16 -17
  10. package/cli/state.ts +15 -29
  11. package/cli/task-service.ts +114 -34
  12. package/cli/tasks.ts +8 -2
  13. package/cli/term-image.ts +18 -0
  14. package/cli/ui-audit.allow.json +0 -1
  15. package/cli/ui-audit.ts +12 -12
  16. package/cli/web.ts +197 -61
  17. package/package.json +21 -4
  18. package/skills/kaizen/spec.md +12 -4
  19. package/skills/optional/disk-cleanup/SKILL.md +60 -0
  20. package/skills/optional/disk-cleanup/skill.json +1 -0
  21. package/skills/optional/disk-cleanup/tui.py +90 -0
  22. package/tsconfig.json +16 -0
  23. package/web/README.md +105 -0
  24. package/web/{annotate.js → annotate/annotate.ts} +51 -50
  25. package/web/boot/boot.ts +7 -0
  26. package/web/components/annotate/annotate-bar.tsx +78 -0
  27. package/web/components/annotate/annotate-panel.tsx +20 -0
  28. package/web/components/annotate/annotate-settings.tsx +60 -0
  29. package/web/components/annotate/index.ts +1 -0
  30. package/web/components/annotate/notes-list.tsx +75 -0
  31. package/web/components/board/board-card.tsx +177 -0
  32. package/web/components/board/board-column.tsx +212 -0
  33. package/web/components/board/board-mode-switch.tsx +21 -0
  34. package/web/components/board/board-popups.tsx +45 -0
  35. package/web/components/board/card-footer.tsx +58 -0
  36. package/web/components/board/card-form.tsx +168 -0
  37. package/web/components/board/card-kids.tsx +53 -0
  38. package/web/components/board/clear-menu.tsx +36 -0
  39. package/web/components/board/filter-box.tsx +42 -0
  40. package/web/components/board/index.ts +6 -0
  41. package/web/components/board/run-form.tsx +129 -0
  42. package/web/components/board/severity-menu.tsx +44 -0
  43. package/web/components/board/status-strip.tsx +75 -0
  44. package/web/components/board/task-form.tsx +140 -0
  45. package/web/components/board/ws-card.tsx +38 -0
  46. package/web/components/context/context-panel.tsx +244 -0
  47. package/web/components/context/index.ts +1 -0
  48. package/web/components/decision/decision-bar.tsx +422 -0
  49. package/web/components/decision/index.ts +1 -0
  50. package/web/components/decision/inline-form.tsx +47 -0
  51. package/web/components/decision/plan-answers-form.tsx +78 -0
  52. package/web/components/decision/revise-form.tsx +65 -0
  53. package/web/components/decision/task-reply-form.tsx +48 -0
  54. package/web/components/footer/foot-bar.tsx +67 -0
  55. package/web/components/footer/index.ts +1 -0
  56. package/web/components/git/git-ask.tsx +88 -0
  57. package/web/components/git/git-commits.tsx +53 -0
  58. package/web/components/git/git-confirm.tsx +78 -0
  59. package/web/components/git/git-counts.tsx +10 -0
  60. package/web/components/git/git-files.tsx +113 -0
  61. package/web/components/git/git-head.tsx +70 -0
  62. package/web/components/git/git-icon.tsx +25 -0
  63. package/web/components/git/git-message.tsx +44 -0
  64. package/web/components/git/git-split.tsx +64 -0
  65. package/web/components/git/git-tab.tsx +55 -0
  66. package/web/components/git/index.ts +1 -0
  67. package/web/components/home/chat-list.tsx +57 -0
  68. package/web/components/home/home-composer.tsx +169 -0
  69. package/web/components/home/home-message.tsx +120 -0
  70. package/web/components/home/home-window.tsx +253 -0
  71. package/web/components/home/home-ws-add.tsx +47 -0
  72. package/web/components/home/index.ts +6 -0
  73. package/web/components/home/onboarding-dialog.tsx +371 -0
  74. package/web/components/icebox/board-chip.tsx +27 -0
  75. package/web/components/icebox/board-menu.tsx +41 -0
  76. package/web/components/icebox/bulk-bar.tsx +41 -0
  77. package/web/components/icebox/capture-box.tsx +155 -0
  78. package/web/components/icebox/choice-menu.tsx +39 -0
  79. package/web/components/icebox/collection-dialog.tsx +60 -0
  80. package/web/components/icebox/favicon.tsx +39 -0
  81. package/web/components/icebox/index.ts +10 -0
  82. package/web/components/icebox/kind-label.tsx +22 -0
  83. package/web/components/icebox/kind-menu.tsx +20 -0
  84. package/web/components/icebox/promote-form.tsx +93 -0
  85. package/web/components/icebox/reply-box.tsx +88 -0
  86. package/web/components/icebox/request-actions.tsx +141 -0
  87. package/web/components/icebox/request-badges.tsx +13 -0
  88. package/web/components/icebox/request-card.tsx +99 -0
  89. package/web/components/icebox/request-detail.tsx +43 -0
  90. package/web/components/icebox/request-images.tsx +33 -0
  91. package/web/components/icebox/request-phone-row.tsx +181 -0
  92. package/web/components/icebox/request-row.tsx +120 -0
  93. package/web/components/icebox/service-chip.tsx +58 -0
  94. package/web/components/icebox/snooze-menu.tsx +83 -0
  95. package/web/components/icebox/source-card.tsx +225 -0
  96. package/web/components/icebox/source-drawer.tsx +112 -0
  97. package/web/components/icebox/source-form.tsx +147 -0
  98. package/web/components/icebox/swipe-deck.tsx +242 -0
  99. package/web/components/layout/index.ts +1 -0
  100. package/web/components/layout/page-frame.tsx +44 -0
  101. package/web/components/markdown/index.ts +1 -0
  102. package/web/components/markdown/markdown.tsx +156 -0
  103. package/web/components/notebook/editor-pane.tsx +23 -0
  104. package/web/components/notebook/index.ts +5 -0
  105. package/web/components/notebook/note-body.tsx +172 -0
  106. package/web/components/notebook/note-tree.tsx +99 -0
  107. package/web/components/notebook/notes-head.tsx +37 -0
  108. package/web/components/notebook/notes-side.tsx +46 -0
  109. package/web/components/notes/index.ts +1 -0
  110. package/web/components/notes/note-composer.tsx +90 -0
  111. package/web/components/notes/notes-chat.tsx +58 -0
  112. package/web/components/panes/browser-pane.tsx +281 -0
  113. package/web/components/panes/index.ts +3 -0
  114. package/web/components/panes/preview-pane.tsx +91 -0
  115. package/web/components/panes/terminal-pane.tsx +52 -0
  116. package/web/components/phone/haptic.tsx +29 -0
  117. package/web/components/phone/index.ts +6 -0
  118. package/web/components/phone/phone-card.tsx +118 -0
  119. package/web/components/phone/phone-home.tsx +304 -0
  120. package/web/components/phone/phone-sheets.tsx +103 -0
  121. package/web/components/phone/qr-code.tsx +6 -0
  122. package/web/components/phone/usage-chips.tsx +85 -0
  123. package/web/components/phone/whatsapp-card.tsx +85 -0
  124. package/web/components/project/add-project-dialog.tsx +435 -0
  125. package/web/components/project/index.ts +3 -0
  126. package/web/components/project/project-bar.tsx +101 -0
  127. package/web/components/project/ws-menu.tsx +21 -0
  128. package/web/components/rail/agent-chips.tsx +110 -0
  129. package/web/components/rail/index.ts +4 -0
  130. package/web/components/rail/rail-filter.tsx +118 -0
  131. package/web/components/rail/rail-list.tsx +259 -0
  132. package/web/components/rail/source-marks.tsx +21 -0
  133. package/web/components/resources/index.ts +1 -0
  134. package/web/components/resources/resources-popup.tsx +490 -0
  135. package/web/components/run/doc-body.tsx +123 -0
  136. package/web/components/run/file-viewer.tsx +53 -0
  137. package/web/components/run/fix-form.tsx +88 -0
  138. package/web/components/run/index.ts +16 -0
  139. package/web/components/run/inline-md.tsx +30 -0
  140. package/web/components/run/key-hint.tsx +29 -0
  141. package/web/components/run/pane-gutter.tsx +52 -0
  142. package/web/components/run/pane-header.tsx +35 -0
  143. package/web/components/run/pane.tsx +140 -0
  144. package/web/components/run/panel-grip.tsx +49 -0
  145. package/web/components/run/panel-head.tsx +56 -0
  146. package/web/components/run/panel-tabs.tsx +35 -0
  147. package/web/components/run/phase-steps.tsx +37 -0
  148. package/web/components/run/project-notes.tsx +49 -0
  149. package/web/components/run/run-add-menu.tsx +80 -0
  150. package/web/components/run/run-bar.tsx +40 -0
  151. package/web/components/run/run-empty.tsx +10 -0
  152. package/web/components/run/run-footer.tsx +53 -0
  153. package/web/components/run/run-history.tsx +24 -0
  154. package/web/components/run/run-panes.tsx +78 -0
  155. package/web/components/run/run-picker.tsx +51 -0
  156. package/web/components/run/run-progress.tsx +30 -0
  157. package/web/components/run/run-tabs.tsx +147 -0
  158. package/web/components/run/run-wait.tsx +18 -0
  159. package/web/components/search/index.ts +1 -0
  160. package/web/components/search/search-palette.tsx +159 -0
  161. package/web/components/settings/account-rows.tsx +128 -0
  162. package/web/components/settings/agent-rows.tsx +249 -0
  163. package/web/components/settings/automation-rows.tsx +211 -0
  164. package/web/components/settings/browser-row.tsx +111 -0
  165. package/web/components/settings/cleanup-row.tsx +32 -0
  166. package/web/components/settings/commit-input.tsx +39 -0
  167. package/web/components/settings/index.ts +4 -0
  168. package/web/components/settings/integration-row.tsx +158 -0
  169. package/web/components/settings/mic-row.tsx +48 -0
  170. package/web/components/settings/orchestration-flow.tsx +87 -0
  171. package/web/components/settings/setting-row.tsx +131 -0
  172. package/web/components/settings/settings-item.tsx +78 -0
  173. package/web/components/settings/settings-loading.tsx +41 -0
  174. package/web/components/settings/settings-nav.tsx +119 -0
  175. package/web/components/settings/settings-scope.tsx +66 -0
  176. package/web/components/settings/settings-section.tsx +33 -0
  177. package/web/components/settings/skill-card.tsx +131 -0
  178. package/web/components/settings/stepper.tsx +74 -0
  179. package/web/components/settings/update-bar.tsx +167 -0
  180. package/web/components/shared/action-menu.tsx +76 -0
  181. package/web/components/shared/ask-host.tsx +18 -0
  182. package/web/components/shared/attach-button.tsx +23 -0
  183. package/web/components/shared/chip.tsx +19 -0
  184. package/web/components/shared/client-mark.tsx +15 -0
  185. package/web/components/shared/confirm-dialog.tsx +35 -0
  186. package/web/components/shared/empty-state.tsx +29 -0
  187. package/web/components/shared/field.tsx +77 -0
  188. package/web/components/shared/filter-popover.tsx +29 -0
  189. package/web/components/shared/form-frame.tsx +19 -0
  190. package/web/components/shared/icon-button.tsx +50 -0
  191. package/web/components/shared/index.ts +18 -0
  192. package/web/components/shared/mic-button.tsx +75 -0
  193. package/web/components/shared/pager.tsx +49 -0
  194. package/web/components/shared/picker.tsx +108 -0
  195. package/web/components/shared/project-mark.tsx +38 -0
  196. package/web/components/shared/segmented.tsx +43 -0
  197. package/web/components/shared/state-dot.tsx +4 -0
  198. package/web/components/shared/status-mark.tsx +26 -0
  199. package/web/components/shell/index.ts +3 -0
  200. package/web/components/shell/rail.tsx +259 -0
  201. package/web/components/shell/sprite.tsx +124 -0
  202. package/web/components/shell/wordmark.tsx +13 -0
  203. package/web/components/task/artifact-view.tsx +148 -0
  204. package/web/components/task/chat-bubble.tsx +43 -0
  205. package/web/components/task/filter-menu.tsx +38 -0
  206. package/web/components/task/index.ts +7 -0
  207. package/web/components/task/result-checks.tsx +34 -0
  208. package/web/components/task/result-view.tsx +103 -0
  209. package/web/components/task/status-badge.tsx +24 -0
  210. package/web/components/task/task-row.tsx +34 -0
  211. package/web/components/task/typing-dots.tsx +16 -0
  212. package/web/components/terminal/index.ts +3 -0
  213. package/web/components/terminal/terminal-bar.tsx +91 -0
  214. package/web/components/terminal/terminal-grid.tsx +149 -0
  215. package/web/components/terminal/terminal-modes.tsx +23 -0
  216. package/web/components/terminal/terminal-tile.tsx +139 -0
  217. package/web/dist/annotate.js +24 -0
  218. package/web/dist/board.css +718 -0
  219. package/web/dist/board.js +115 -0
  220. package/web/dist/boot.js +2 -0
  221. package/web/dist/notebook.css +319 -0
  222. package/web/dist/notebook.js +89 -0
  223. package/web/dist/popup.css +41 -0
  224. package/web/dist/popup.js +13 -0
  225. package/web/{term.js → dist/term.js} +48 -48
  226. package/web/dist/ui.css +3 -0
  227. package/web/dist/video.js +108 -0
  228. package/web/html/board.html +17 -0
  229. package/web/html/notes.html +14 -0
  230. package/web/html/popup.html +13 -0
  231. package/web/{video.html → html/video.html} +14 -15
  232. package/web/lib/annotate/index.ts +2 -0
  233. package/web/lib/annotate/notes.ts +105 -0
  234. package/web/lib/annotate/page.ts +121 -0
  235. package/web/lib/annotate/rules.ts +37 -0
  236. package/web/lib/annotate/session.ts +336 -0
  237. package/web/lib/board/board-actions.ts +119 -0
  238. package/web/lib/board/board-open.ts +12 -0
  239. package/web/lib/board/board-store.ts +159 -0
  240. package/web/lib/board/filter-box.ts +7 -0
  241. package/web/lib/board/index.ts +10 -0
  242. package/web/lib/board/nav.ts +29 -0
  243. package/web/lib/board/on-state.ts +90 -0
  244. package/web/lib/board/popups.ts +22 -0
  245. package/web/lib/board/snapshot.ts +105 -0
  246. package/web/lib/board/strip.ts +43 -0
  247. package/web/{board → lib/board}/ws-board.ts +1 -1
  248. package/web/lib/context/context-rules.ts +27 -0
  249. package/web/lib/context/context-store.ts +95 -0
  250. package/web/lib/context/feed.ts +28 -0
  251. package/web/lib/context/index.ts +3 -0
  252. package/web/lib/core/api.ts +86 -0
  253. package/web/lib/core/ask.ts +24 -0
  254. package/web/lib/core/board.ts +290 -0
  255. package/web/lib/core/brief.ts +31 -0
  256. package/web/lib/core/format.ts +8 -0
  257. package/web/lib/core/host.ts +107 -0
  258. package/web/lib/core/index.ts +16 -0
  259. package/web/{board → lib/core}/labels.ts +6 -5
  260. package/web/lib/core/layers.ts +7 -0
  261. package/web/lib/core/leave.ts +7 -0
  262. package/web/lib/core/motion.ts +10 -0
  263. package/web/{board/toast.ts → lib/core/notices.ts} +2 -20
  264. package/web/lib/core/notifier.ts +15 -0
  265. package/web/lib/core/store.ts +39 -0
  266. package/web/lib/core/term-handle.ts +8 -0
  267. package/web/lib/core/toast.ts +29 -0
  268. package/web/lib/core/utils.ts +15 -0
  269. package/web/lib/decision/index.ts +1 -0
  270. package/web/lib/decision/plan-questions.ts +39 -0
  271. package/web/lib/dictation/chunks.ts +93 -0
  272. package/web/lib/dictation/dictation-store.ts +22 -0
  273. package/web/lib/dictation/engine.ts +265 -0
  274. package/web/lib/dictation/index.ts +5 -0
  275. package/web/lib/dictation/mic.ts +42 -0
  276. package/web/lib/dictation/terminal-dictation.ts +50 -0
  277. package/web/lib/footer/footer-rules.ts +13 -0
  278. package/web/lib/footer/footer-store.ts +42 -0
  279. package/web/lib/footer/index.ts +2 -0
  280. package/web/lib/git/git-actions.ts +110 -0
  281. package/web/lib/git/git-panel.ts +43 -0
  282. package/web/lib/git/git-store.ts +47 -0
  283. package/web/lib/git/git.ts +170 -0
  284. package/web/lib/git/index.ts +4 -0
  285. package/web/lib/home/home-engine.ts +16 -0
  286. package/web/lib/home/home-events.ts +9 -0
  287. package/web/lib/home/home-store.ts +247 -0
  288. package/web/lib/home/home-window.ts +193 -0
  289. package/web/lib/home/home.ts +85 -0
  290. package/web/lib/home/index.ts +7 -0
  291. package/web/lib/home/onboarding.ts +199 -0
  292. package/web/lib/home/use-float-drag.ts +62 -0
  293. package/web/lib/icebox/icebox-actions.ts +518 -0
  294. package/web/lib/icebox/icebox-store.ts +112 -0
  295. package/web/lib/icebox/icebox-view.ts +48 -0
  296. package/web/lib/icebox/icebox.ts +273 -0
  297. package/web/lib/icebox/index.ts +8 -0
  298. package/web/lib/icebox/use-card-drag.ts +82 -0
  299. package/web/lib/icebox/use-ice-keys.ts +75 -0
  300. package/web/lib/icebox/use-icebox.ts +41 -0
  301. package/web/lib/icebox/use-row-swipe.ts +107 -0
  302. package/web/lib/markdown/index.ts +1 -0
  303. package/web/lib/markdown/markdown.ts +136 -0
  304. package/web/lib/notebook/autosave.ts +131 -0
  305. package/web/lib/notebook/deal.ts +58 -0
  306. package/web/lib/notebook/engine-complete.ts +128 -0
  307. package/web/lib/notebook/engine-preview.ts +287 -0
  308. package/web/lib/notebook/engine-types.ts +26 -0
  309. package/web/lib/notebook/engine-widgets.ts +218 -0
  310. package/web/lib/notebook/engine.ts +74 -0
  311. package/web/lib/notebook/index.ts +9 -0
  312. package/web/lib/notebook/kit-loader.ts +16 -0
  313. package/web/lib/notebook/kit.ts +12 -0
  314. package/web/{notes-lib.ts → lib/notebook/text.ts} +11 -10
  315. package/web/lib/notebook/vault-actions.ts +239 -0
  316. package/web/lib/notebook/vault-rules.ts +74 -0
  317. package/web/lib/notebook/vault-session.ts +73 -0
  318. package/web/lib/notebook/vault-store.ts +63 -0
  319. package/web/lib/notes/index.ts +4 -0
  320. package/web/lib/notes/md-html.ts +115 -0
  321. package/web/lib/notes/notes-actions.ts +32 -0
  322. package/web/lib/notes/notes-store.ts +22 -0
  323. package/web/lib/notes/notes.ts +58 -0
  324. package/web/{board → lib/notes}/rich.ts +1 -2
  325. package/web/lib/phone/index.ts +7 -0
  326. package/web/lib/phone/phone-actions.ts +77 -0
  327. package/web/lib/phone/phone-home.ts +102 -0
  328. package/web/lib/phone/phone-setup.ts +59 -0
  329. package/web/lib/phone/phone-sheet.ts +25 -0
  330. package/web/lib/phone/phone-store.ts +32 -0
  331. package/web/lib/phone/sheet-swipe.ts +55 -0
  332. package/web/lib/phone/use-phone-setup.ts +89 -0
  333. package/web/lib/project/add-project.ts +37 -0
  334. package/web/lib/project/branch.ts +14 -0
  335. package/web/lib/project/index.ts +5 -0
  336. package/web/lib/project/project-bar.ts +76 -0
  337. package/web/lib/project/project-pick.ts +36 -0
  338. package/web/lib/project/ws-menu.ts +8 -0
  339. package/web/lib/rail/agents.ts +63 -0
  340. package/web/lib/rail/card-links.ts +20 -0
  341. package/web/lib/rail/index.ts +7 -0
  342. package/web/lib/rail/rail-actions.ts +74 -0
  343. package/web/lib/rail/rail-boot.ts +99 -0
  344. package/web/lib/rail/rail-store.ts +85 -0
  345. package/web/lib/rail/rules.ts +241 -0
  346. package/web/lib/rail/source-marks.ts +17 -0
  347. package/web/lib/rail/use-rank-drag.ts +108 -0
  348. package/web/lib/resources/index.ts +3 -0
  349. package/web/lib/resources/resources-actions.ts +59 -0
  350. package/web/lib/resources/resources-store.ts +48 -0
  351. package/web/lib/resources/rules.ts +56 -0
  352. package/web/lib/router/index.ts +3 -0
  353. package/web/lib/router/route-rules.ts +96 -0
  354. package/web/lib/router/route-store.ts +115 -0
  355. package/web/lib/router/use-route-classes.ts +15 -0
  356. package/web/lib/run/browser.ts +53 -0
  357. package/web/lib/run/card-terminal.ts +32 -0
  358. package/web/lib/run/doc.ts +42 -0
  359. package/web/lib/run/grip.ts +8 -0
  360. package/web/lib/run/index.ts +19 -0
  361. package/web/lib/run/kept.ts +58 -0
  362. package/web/lib/run/layout-store.ts +156 -0
  363. package/web/lib/run/layout.ts +195 -0
  364. package/web/lib/run/panel-actions.ts +104 -0
  365. package/web/lib/run/panel-derive.ts +148 -0
  366. package/web/lib/run/panel-store.ts +125 -0
  367. package/web/lib/run/preview.ts +105 -0
  368. package/web/lib/run/run-actions.ts +118 -0
  369. package/web/lib/run/run-view-store.ts +134 -0
  370. package/web/lib/run/term-loader.ts +19 -0
  371. package/web/lib/run/use-panel-run.ts +125 -0
  372. package/web/lib/run/use-run-lifecycle.ts +70 -0
  373. package/web/lib/run/viewer.ts +12 -0
  374. package/web/lib/run/workspace.ts +281 -0
  375. package/web/lib/run/ws-actions.ts +293 -0
  376. package/web/lib/run/ws-derive.ts +50 -0
  377. package/web/lib/run/ws-draw.ts +102 -0
  378. package/web/lib/run/ws-store.ts +21 -0
  379. package/web/lib/run/ws-tabs.ts +125 -0
  380. package/web/lib/search/index.ts +3 -0
  381. package/web/lib/search/search-match.ts +48 -0
  382. package/web/lib/search/search-rows.ts +228 -0
  383. package/web/lib/search/search.ts +30 -0
  384. package/web/lib/search/use-search-rows.ts +22 -0
  385. package/web/lib/server/attention.ts +29 -0
  386. package/web/lib/server/index.ts +6 -0
  387. package/web/lib/server/poll-rules.ts +57 -0
  388. package/web/lib/server/poller.ts +210 -0
  389. package/web/lib/server/server-store.ts +39 -0
  390. package/web/lib/server/types.ts +31 -0
  391. package/web/lib/server/use-server.ts +19 -0
  392. package/web/lib/settings/agent-favicons.ts +14 -0
  393. package/web/lib/settings/index.ts +7 -0
  394. package/web/lib/settings/panel-settings.ts +29 -0
  395. package/web/lib/settings/settings-actions.ts +357 -0
  396. package/web/lib/settings/settings-store.ts +114 -0
  397. package/web/lib/settings/settings.ts +413 -0
  398. package/web/lib/settings/skill-icons.ts +24 -0
  399. package/web/lib/settings/update.ts +70 -0
  400. package/web/lib/shared/data-urls.ts +32 -0
  401. package/web/lib/shared/index.ts +4 -0
  402. package/web/lib/shared/use-draft.ts +38 -0
  403. package/web/lib/shared/use-narrow.ts +11 -0
  404. package/web/lib/shared/use-pager.ts +24 -0
  405. package/web/lib/shell/appearance.ts +97 -0
  406. package/web/lib/shell/help-store.ts +4 -0
  407. package/web/lib/shell/index.ts +4 -0
  408. package/web/lib/shell/shell-store.ts +23 -0
  409. package/web/lib/shell/stored-look.ts +47 -0
  410. package/web/lib/task/index.ts +7 -0
  411. package/web/lib/task/task-results.ts +92 -0
  412. package/web/lib/task/tasks.ts +132 -0
  413. package/web/lib/task/use-live-frame.ts +85 -0
  414. package/web/lib/task/use-saved-text.ts +25 -0
  415. package/web/lib/task/use-task.ts +161 -0
  416. package/web/lib/task/use-tasks.ts +50 -0
  417. package/web/{board → lib/task}/zoom.ts +25 -12
  418. package/web/lib/terminal/hidden-badge.ts +15 -0
  419. package/web/lib/terminal/index.ts +8 -0
  420. package/web/lib/terminal/layout.ts +138 -0
  421. package/web/{term-font.ts → lib/terminal/term-font.ts} +3 -2
  422. package/web/lib/terminal/terminal-store.ts +65 -0
  423. package/web/lib/terminal/terms-feed.ts +37 -0
  424. package/web/lib/terminal/use-arranged.ts +15 -0
  425. package/web/lib/terminal/use-terminal-keys.ts +37 -0
  426. package/web/lib/url/index.ts +1 -0
  427. package/web/lib/url/safe-url.ts +9 -0
  428. package/web/notebook/notebook.ts +27 -0
  429. package/web/notebook/notes-lib.ts +3 -0
  430. package/web/pages/board/App.tsx +76 -0
  431. package/web/pages/board/header.tsx +83 -0
  432. package/web/pages/board/help.tsx +59 -0
  433. package/web/pages/board/host-bridge.ts +94 -0
  434. package/web/pages/board/host.tsx +19 -0
  435. package/web/pages/board/keys.ts +112 -0
  436. package/web/pages/board/live.ts +39 -0
  437. package/web/pages/board/main.ts +32 -0
  438. package/web/pages/board/pages.tsx +86 -0
  439. package/web/pages/board/panel.tsx +157 -0
  440. package/web/pages/board/portal.tsx +39 -0
  441. package/web/pages/board/use-boot.ts +13 -0
  442. package/web/pages/board/views.ts +63 -0
  443. package/web/pages/board-page.tsx +62 -0
  444. package/web/pages/home-page.tsx +127 -0
  445. package/web/pages/icebox-page.tsx +440 -0
  446. package/web/pages/notebook/App.tsx +35 -0
  447. package/web/pages/notebook-page.tsx +50 -0
  448. package/web/pages/popup/App.tsx +207 -0
  449. package/web/pages/settings-page.tsx +111 -0
  450. package/web/pages/task-page.tsx +383 -0
  451. package/web/pages/tasks-page.tsx +151 -0
  452. package/web/pages/terminal-page.tsx +15 -0
  453. package/web/popup/popup.ts +7 -0
  454. package/web/term/term-paste.ts +10 -0
  455. package/web/{term.ts → term/term.ts} +101 -27
  456. package/web/ui/alert-dialog.tsx +39 -0
  457. package/web/ui/badge.tsx +20 -0
  458. package/web/ui/button.tsx +37 -0
  459. package/web/ui/checkbox.tsx +20 -0
  460. package/web/ui/command.tsx +41 -0
  461. package/web/ui/dialog.tsx +28 -0
  462. package/web/ui/dropdown-menu.tsx +54 -0
  463. package/web/ui/icon.tsx +17 -0
  464. package/web/ui/index.ts +21 -0
  465. package/web/ui/input.tsx +9 -0
  466. package/web/ui/label.tsx +7 -0
  467. package/web/ui/legacy/board.css +715 -0
  468. package/web/{notes.html → ui/legacy/notes.css} +23 -157
  469. package/web/ui/legacy/popup.css +40 -0
  470. package/web/ui/popover.tsx +28 -0
  471. package/web/ui/select.tsx +61 -0
  472. package/web/ui/sheet.tsx +43 -0
  473. package/web/ui/skeleton.tsx +6 -0
  474. package/web/ui/sonner.tsx +25 -0
  475. package/web/ui/spinner.tsx +12 -0
  476. package/web/ui/switch.tsx +18 -0
  477. package/web/ui/tabs.tsx +18 -0
  478. package/web/ui/textarea.tsx +14 -0
  479. package/web/ui/theme.css +125 -0
  480. package/web/ui/toggle.tsx +8 -0
  481. package/web/ui/tooltip.tsx +26 -0
  482. package/web/{video.ts → video/video.ts} +5 -5
  483. package/web/board/add-project.ts +0 -147
  484. package/web/board/agent-favicons.ts +0 -9
  485. package/web/board/agent-term.ts +0 -51
  486. package/web/board/annotate-lib.ts +0 -19
  487. package/web/board/annotate.ts +0 -221
  488. package/web/board/api.ts +0 -180
  489. package/web/board/approvals.ts +0 -109
  490. package/web/board/badge.ts +0 -115
  491. package/web/board/cards.ts +0 -1080
  492. package/web/board/chat.ts +0 -128
  493. package/web/board/context.ts +0 -248
  494. package/web/board/dictation.ts +0 -343
  495. package/web/board/dom.ts +0 -132
  496. package/web/board/drafts.ts +0 -21
  497. package/web/board/fixes.ts +0 -89
  498. package/web/board/git.ts +0 -416
  499. package/web/board/home-ws.ts +0 -266
  500. package/web/board/home.ts +0 -421
  501. package/web/board/icebox.ts +0 -1788
  502. package/web/board/keys.ts +0 -121
  503. package/web/board/live.ts +0 -87
  504. package/web/board/main.ts +0 -94
  505. package/web/board/markdown.ts +0 -210
  506. package/web/board/onboarding.ts +0 -227
  507. package/web/board/panel.ts +0 -437
  508. package/web/board/phone-setup.ts +0 -79
  509. package/web/board/phone.ts +0 -219
  510. package/web/board/projects.ts +0 -277
  511. package/web/board/resources.ts +0 -170
  512. package/web/board/run-pick.ts +0 -41
  513. package/web/board/run-view.ts +0 -1316
  514. package/web/board/search-match.ts +0 -20
  515. package/web/board/search.ts +0 -330
  516. package/web/board/settings-accounts.ts +0 -76
  517. package/web/board/settings-agents.ts +0 -102
  518. package/web/board/settings-automations.ts +0 -71
  519. package/web/board/settings-cleanup.ts +0 -42
  520. package/web/board/settings-orchestration.ts +0 -32
  521. package/web/board/settings-pages.ts +0 -62
  522. package/web/board/settings-skills.ts +0 -86
  523. package/web/board/settings-voice.ts +0 -28
  524. package/web/board/settings.ts +0 -490
  525. package/web/board/store.ts +0 -47
  526. package/web/board/task-page.ts +0 -615
  527. package/web/board/task-results.ts +0 -234
  528. package/web/board/tasks.ts +0 -242
  529. package/web/board/terms.ts +0 -390
  530. package/web/board/update.ts +0 -171
  531. package/web/board/viewer.ts +0 -47
  532. package/web/board/views.ts +0 -164
  533. package/web/board/whatsapp-setup.ts +0 -149
  534. package/web/board/workspace.ts +0 -650
  535. package/web/board/ws-board-ui.ts +0 -95
  536. package/web/board/ws-tabs.ts +0 -227
  537. package/web/board.html +0 -1563
  538. package/web/board.js +0 -500
  539. package/web/notebook.js +0 -514
  540. package/web/notebook.ts +0 -1254
  541. package/web/popup.html +0 -141
  542. package/web/video.js +0 -570
  543. /package/web/{term.css → dist/term.css} +0 -0
  544. /package/web/{board/term-sessions.ts → lib/terminal/sessions.ts} +0 -0
  545. /package/web/{board/terminal-viewport.ts → lib/terminal/viewport.ts} +0 -0
package/cli/web.ts CHANGED
@@ -7,13 +7,13 @@ import { join, dirname, resolve, sep, basename } from "node:path";
7
7
  import {
8
8
  home, type Item, type Card, knownProjects, remember, reorderProjects, canonPath, locate, label, tilde, searchRoots, findProjects,
9
9
  readInbox, writeInbox, replaceTask, moveTask, abandonRun, runToTask, launchRun, parseItem, agentChoices, onPath, projectOf, KNOWN_AGENTS, plainModel, short, setArchived, writeNotes,
10
- appendNote, saveAttachment, pidOnPort, readText, cmdExe, sysExe, powershellExe, runGit, readCommit, commitPush, commitStaged, stageFiles, suggestMessage, notice, notifier, LOGO,
10
+ appendNote, saveAttachment, pidOnPort, readText, cmdExe, sysExe, powershellExe, runGit, readCommit, commitPush, commitStaged, stageFiles, suggestMessage, notice, LOGO,
11
11
  reviewFindings, pickFindings, backlogItem, startedBacklog, closeBacklog, markBacklogDone, fixPrompt, approvalPrompt, canApproveAwaiting, gateOf, recordAcceptance, healRuns, finishRun, nativePath, closeSessions, sweepSessions, issueUrl,
12
- launchMode, pruneRuns, pruneSessions, readSessions, ownerOf, runIndex, resumePrompt, runAgent, firstSession, webHosts,
12
+ pruneRuns, pruneSessions, readSessions, ownerOf, runIndex, resumePrompt, runAgent, firstSession, webHosts,
13
13
  } from "./state.ts";
14
14
  import { ACCOUNT_EXTRA, ACCOUNT_VAR, accountDir, agyLogin, addAccount, loginStatus, readAccounts, renameAccount, removeAccount, resolveAccount, setDefaultAccount, type Login, type Tool } from "./accounts.ts";
15
15
  import { readReport, signalOf } from "./report.ts";
16
- import { MAX_IMAGE, saveImage } from "./term-image.ts";
16
+ import { MAX_FILE, MAX_IMAGE, saveFile, saveImage } from "./term-image.ts";
17
17
  import { shellHistory } from "./term-history.ts";
18
18
  import { bundledSkills, repairSkill, setSkill, skillsHeld, skillsOff, skillStatus } from "./skills.ts";
19
19
  import * as rea from "./rea.ts";
@@ -22,6 +22,7 @@ import { agentLine, failStart, handoffModel, markRunning, readWorkers, requested
22
22
  import { childDied, childQuiet, markWoken, move, requestOpen, readHandoff, refused, started, wakeAction, wakeLine, type Handoff } from "./handoff.ts";
23
23
  import { processTable, storage, systemMemory, treeRss, type Root } from "./resources.ts";
24
24
  import { attachPty, frames, writePty, submitPty, resizePty, exitPty, killPty, panePid, ptyState, ptyKeys, adoptLoginEnv, startPty, ptySupported, detachPty, ptyTail, ptyTmux, tmuxAlive, RESUMED } from "./pty.ts";
25
+ import { conflictPort, holders, inProjects, isKaizenProcess, listeners, stopPort } from "./ports.ts";
25
26
  import { snapshot, snapWorker } from "./state-snap.ts";
26
27
  import { claudeUsage, claudeUsageAt, codexUsage, codexUsageAt, phonePeers, type Usage } from "./usage.ts";
27
28
  import { readSources, addSource, removeSource, moveSource, setCategory, setWriteback, setPaused, readIcebox, applySort, promote, dismiss, restore, capture, editItem, setKind, setTags, setBoard, saveBoard, removeBoard, snooze, unsnooze, readBoards, kindOf, isSnoozed, markDone, markReplied, gatherSource, freshImages, gatherAll, gatherDirs, due, socialUrl, socialOf } from "./sources.ts";
@@ -46,24 +47,31 @@ import * as taskService from "./task-service.ts";
46
47
  import { artifactResponse as taskArtifactResponse } from "./task-results.ts";
47
48
  import { gitUrl, destDir, winBad, cloneInto, branchesOf, ignoreKaizen } from "./add-project.ts";
48
49
 
49
- const PAGE = join(dirname(import.meta.dir), "web", "board.html");
50
- // The board's script: web/board/*.ts, bundled into one file by `bun run build:web`.
51
- const BOARD_JS = join(dirname(import.meta.dir), "web", "board.js");
50
+ const PAGE = join(dirname(import.meta.dir), "web", "html", "board.html");
51
+ // The board's script: web/pages/board/main.ts with web/lib and web/components, bundled into one file by `bun run build:web`.
52
+ const BOARD_JS = join(dirname(import.meta.dir), "web", "dist", "board.js");
52
53
  const SOUNDS_DIR = join(dirname(import.meta.dir), "web", "sounds");
53
- // The notebook: its page, and the CodeMirror bundle `bun run build:web` commits beside it.
54
- const NOTES_PAGE = join(dirname(import.meta.dir), "web", "notes.html");
54
+ // The notebook: its page, and the CodeMirror bundle `bun run build:web` commits to web/dist.
55
+ const NOTES_PAGE = join(dirname(import.meta.dir), "web", "html", "notes.html");
55
56
  const ICO = join(dirname(import.meta.dir), "assets", "kaizen.ico");
56
- const NOTES_JS = join(dirname(import.meta.dir), "web", "notebook.js");
57
+ const UI_CSS = join(dirname(import.meta.dir), "web", "dist", "ui.css");
58
+ const NOTES_JS = join(dirname(import.meta.dir), "web", "dist", "notebook.js");
57
59
  // The in-card terminal (agent.launch: card): xterm.js, bundled the same way.
58
- const TERM_JS = join(dirname(import.meta.dir), "web", "term.js");
59
- const ANNOTATE_JS = join(dirname(import.meta.dir), "web", "annotate.js");
60
- const TERM_CSS = join(dirname(import.meta.dir), "web", "term.css");
60
+ const TERM_JS = join(dirname(import.meta.dir), "web", "dist", "term.js");
61
+ const ANNOTATE_JS = join(dirname(import.meta.dir), "web", "dist", "annotate.js");
62
+ const TERM_CSS = join(dirname(import.meta.dir), "web", "dist", "term.css");
61
63
  // The Video page (kaizen-video's library, editor and renders) and its bundle.
62
- const VIDEO_PAGE = join(dirname(import.meta.dir), "web", "video.html");
63
- const POPUP_PAGE = join(dirname(import.meta.dir), "web", "popup.html");
64
+ const VIDEO_PAGE = join(dirname(import.meta.dir), "web", "html", "video.html");
65
+ const POPUP_PAGE = join(dirname(import.meta.dir), "web", "html", "popup.html");
66
+ // Each page's one stylesheet (the kit's Tailwind and the page's own styles) and the chat popup's script.
67
+ const dist = (f: string) => join(dirname(import.meta.dir), "web", "dist", f);
68
+ const STYLES: Record<string, string> = { "/board.css": dist("board.css"), "/notebook.css": dist("notebook.css"), "/popup.css": dist("popup.css") };
69
+ const POPUP_JS = dist("popup.js");
70
+ // The blocking head script of the board and the Notebook: the stored theme is on <html> before the first paint.
71
+ const BOOT_JS = dist("boot.js");
64
72
  // The chat the popup was on when its Back button was pressed, until Home takes it.
65
73
  let popupChat: string | null = null;
66
- const VIDEO_JS = join(dirname(import.meta.dir), "web", "video.js");
74
+ const VIDEO_JS = join(dirname(import.meta.dir), "web", "dist", "video.js");
67
75
  const DEFAULT_PORT = 7420;
68
76
  // Gathered posts a reply is going out to right now: one send per item at a time.
69
77
  const replying = new Set<string>();
@@ -87,8 +95,15 @@ delete process.env.KAIZEN_DESKTOP_BUNDLED;
87
95
  // page newer than its server sends ops the server does not know ("unknown op").
88
96
  // So the pages are kept as they were at start, and read live (dev edits) only while
89
97
  // the installed version is still the one this board runs.
90
- const AT_START = new Map([PAGE, BOARD_JS, NOTES_PAGE, NOTES_JS, TERM_JS, TERM_CSS, VIDEO_PAGE, VIDEO_JS, ANNOTATE_JS].map((f) => [f, existsSync(f) ? readText(f) : null]));
91
- const served = (f: string) => installed() === VERSION && existsSync(f) ? readText(f) : AT_START.get(f) ?? null;
98
+ const AT_START = new Map([PAGE, BOARD_JS, NOTES_PAGE, NOTES_JS, TERM_JS, TERM_CSS, VIDEO_PAGE, VIDEO_JS, ANNOTATE_JS, UI_CSS, POPUP_PAGE, POPUP_JS, BOOT_JS, ...Object.values(STYLES)].map((f) => [f, existsSync(f) ? readText(f) : null]));
99
+ // `bun run dev` (cli/dev.ts) sets KAIZEN_DEV: every page file is read from disk on each request, and pages get a small
100
+ // script that reloads them when the dev script has rebuilt the bundles (GET /__dev/stream, POST /__dev/reload).
101
+ const DEV = process.env.KAIZEN_DEV === "1";
102
+ const DEV_TAG = `<script>new EventSource("/__dev/stream").onmessage=(e)=>{if(e.data==="reload")location.reload()}</script>`;
103
+ const served = (f: string) => {
104
+ const body = DEV ? (existsSync(f) ? readText(f) : null) : installed() === VERSION && existsSync(f) ? readText(f) : AT_START.get(f) ?? null;
105
+ return DEV && body !== null && f.endsWith(".html") ? body.replace("</head>", DEV_TAG + "</head>") : body;
106
+ };
92
107
 
93
108
  // A board answers at url and runs the installed version. A board from before the
94
109
  // version header sends none, so it counts as stale too.
@@ -282,17 +297,44 @@ export async function web(repoDir: string, opts: Opts = {}) {
282
297
  : [cur]
283
298
  ).filter((d, i, arr) => arr.indexOf(d) === i && existsSync(d));
284
299
 
300
+ // A run's decision sent to its agent: the agent already open in this run's card takes it
301
+ // there, as it takes a fix: no second tab of the same conversation. With none, the run's
302
+ // conversation continues in one new window, and then the idle one ends. A failed launch
303
+ // leaves it open, since the decision went nowhere.
304
+ const sendDecision = (dir: string, id: string, awaiting: string, why?: string, answers?: string[]) => {
305
+ const text = approvalPrompt(id, awaiting, why, answers);
306
+ const live = liveAgent(dir, id);
307
+ const before = Date.now();
308
+ const r = live ? { ok: true as const, pty: live.key, agent: live.cmd, reused: true } : launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard);
309
+ if (live) submitPty(live.key, text);
310
+ else if (r.ok) closeSessions(dir, id, { before });
311
+ // The plan's approval starts the build; fixing open findings is the review stage again.
312
+ if (r.ok) markStage(dir, id, awaiting === "approvals.plan" ? "impl" : awaiting === "findings" ? "review" : "", r.pty);
313
+ // Approving the review as-is is the user's acceptance, on record before the
314
+ // agent marks the run done; a revise is not.
315
+ if (r.ok && why === undefined && (awaiting === "approvals.review" || awaiting === "findings")) recordAcceptance(dir, id, "board");
316
+ return { r, live };
317
+ };
318
+ // A task whose run was just approved picks the approval up as its Looks good.
319
+ const syncTask = (dir: string, taskId: string) => {
320
+ try { const found = tasks.resolveTask(dir, taskId); if (found) taskService.reconcile(found.state, found.task, taskHooks); } catch { /* the next read reconciles */ }
321
+ };
285
322
  const taskHooks = {
323
+ approve: (dir: string, id: string, awaiting: string) => { const { r } = sendDecision(dir, id, awaiting); return r.ok ? null : (r.why || "The run's agent could not be reached"); },
286
324
  launch: (dir: string, id: string, text: string, task: tasks.Task, pick?: any) => {
287
325
  const live = liveAgent(dir, id);
288
326
  if (live) { submitPty(live.key, text); return { ok: true, pty: live.key }; }
289
- return launchRun({ severity: null, where: null, text, raw: text }, dir, id, { ...inCard(dir), ...(pick ? { agent: KNOWN_AGENTS.some((a) => a.cmd === pick.agent) ? pick.agent : undefined, account: typeof pick.account === "string" ? pick.account : undefined, explore: typeof pick.explore === "boolean" ? pick.explore : undefined, yolo: pick.yolo === true } : {}), task: { id: task.id, requirePlanConfirmation: !task.initialConfirmed } });
327
+ return launchRun({ severity: null, where: null, text, raw: text }, dir, id, { ...inCard, ...(pick ? { agent: KNOWN_AGENTS.some((a) => a.cmd === pick.agent) ? pick.agent : undefined, account: typeof pick.account === "string" ? pick.account : undefined, explore: typeof pick.explore === "boolean" ? pick.explore : undefined, yolo: pick.yolo === true } : {}), task: { id: task.id, requirePlanConfirmation: !task.initialConfirmed } });
290
328
  },
291
329
  alive: (key: string) => ptyState(key)?.alive === true,
292
330
  stop: (key: string) => killPty(key),
331
+ find: (dir: string, run: string) => liveAgent(dir, run)?.key,
293
332
  };
294
333
  const taskPump = setInterval(() => {
295
334
  for (const dir of states(true)) for (const task of tasks.listTasks(dir)) {
335
+ // A stopping task is asked to stop again until its terminal is gone, not only when someone opens it.
336
+ // A ready task also picks up its run's acceptance given in the agent terminal (kaizen done --user-approved).
337
+ if ((task.status === "stopping" || task.status === "ready") && !task.archived) { try { if (taskService.reconcile(dir, task, taskHooks).revision !== task.revision) changed(); } catch { /* next pass */ } if (task.status === "stopping") continue; }
296
338
  if (!task.safe || task.queuePaused || task.pendingDecision || !task.inputs.some(i => i.state === "queued")) continue;
297
339
  try { taskService.dispatchReady(dir, task.id, taskHooks); changed(); } catch { /* CAS conflict: next pass reads the new state */ }
298
340
  }
@@ -358,6 +400,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
358
400
  // Change notification: one SSE stream per open board, fed by fs.watch where it
359
401
  // works and a slow poll where it does not.
360
402
  const clients = new Set<ReadableStreamDefaultController>();
403
+ const devClients = new Set<ReadableStreamDefaultController>();
361
404
  // Shells the board started (POST /shell), by /pty key; dead ones drop on the next /shells.
362
405
  const shells = new Map<string, { key: string; dir: string; title: string; agent: string; run: string; ws?: string; pid?: number }>();
363
406
  const SHELL_CAP = 8;
@@ -395,8 +438,8 @@ export async function web(repoDir: string, opts: Opts = {}) {
395
438
  for (const c of clients) { try { c.enqueue("data: changed\n\n"); } catch { clients.delete(c); } }
396
439
  }, 200);
397
440
  };
398
- // agent.launch: card runs what this board launches inside the board, shown on the card.
399
- const inCard = (dir: string) => ({ card: launchMode(projectOf(dir)) === "card", onChange: changed });
441
+ // What this board launches runs inside the board, shown on the card.
442
+ const inCard = { card: true, onChange: changed };
400
443
 
401
444
  // The agent open in a run's card, the newest when there are several: what the user sees
402
445
  // working. Everything sent to a run goes here before any new agent is started.
@@ -431,7 +474,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
431
474
  const prev = readSessions(dir).filter((s) => ownerOf(dir, s, idx) === id && existsSync(tailOf(s.key))).pop();
432
475
  let seed: string | undefined;
433
476
  try { if (prev) seed = readText(tailOf(prev.key)) + RESUMED; } catch { /* shown without it */ }
434
- const r = launchRun({ severity: null, where: null, text, raw: text }, dir, id, { ...inCard(dir), seed });
477
+ const r = launchRun({ severity: null, where: null, text, raw: text }, dir, id, { ...inCard, seed });
435
478
  if (r.ok) closeSessions(dir, id, { before });
436
479
  if (r.ok && prev) rmSync(tailOf(prev.key), { force: true });
437
480
  changed();
@@ -798,9 +841,8 @@ export async function web(repoDir: string, opts: Opts = {}) {
798
841
 
799
842
  if (req.method === "GET" && path === "/") {
800
843
  const page = served(PAGE);
801
- if (page === null) return new Response("web/board.html missing", { status: 500 });
802
- // The page gets the notify rule from state.ts rather than keeping its own copy.
803
- return new Response(page.replace("/*notifier*/", () => notifier.toString()), {
844
+ if (page === null) return new Response("web/html/board.html missing", { status: 500 });
845
+ return new Response(page, {
804
846
  headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store", "x-kaizen-version": VERSION },
805
847
  });
806
848
  }
@@ -811,6 +853,19 @@ export async function web(repoDir: string, opts: Opts = {}) {
811
853
  return new Response(body, { headers: { "content-type": "application/javascript; charset=utf-8", "cache-control": "no-store" } });
812
854
  }
813
855
 
856
+ // The React pages' Tailwind (web/ui/theme.css compiled by bun run build:web).
857
+ if (req.method === "GET" && path === "/ui.css") {
858
+ const body = served(UI_CSS);
859
+ if (body === null) return new Response(`${path} missing; run bun run build:web`, { status: 500 });
860
+ return new Response(body, { headers: { "content-type": "text/css; charset=utf-8", "cache-control": "no-store" } });
861
+ }
862
+
863
+ if (req.method === "GET" && STYLES[path]) {
864
+ const body = served(STYLES[path]);
865
+ if (body === null) return new Response(`${path} missing; run bun run build:web`, { status: 500 });
866
+ return new Response(body, { headers: { "content-type": "text/css; charset=utf-8", "cache-control": "no-store" } });
867
+ }
868
+
814
869
  if (req.method === "GET" && path.startsWith("/sounds/")) {
815
870
  const name = /^\/sounds\/([A-Za-z]+)\.mp3$/.exec(path)?.[1];
816
871
  const file = name && join(SOUNDS_DIR, `${name}.mp3`);
@@ -825,11 +880,17 @@ export async function web(repoDir: string, opts: Opts = {}) {
825
880
  return new Response(body, { headers: { "content-type": type, "cache-control": "no-store" } });
826
881
  }
827
882
 
883
+ if (req.method === "GET" && path === "/boot.js") {
884
+ const body = served(BOOT_JS);
885
+ if (body === null) return new Response(`${path} missing; run bun run build:web`, { status: 500 });
886
+ return new Response(body, { headers: { "content-type": "application/javascript; charset=utf-8", "cache-control": "no-store" } });
887
+ }
888
+
828
889
  // `kaizen chat`: the small chat window over the desktop.
829
- if (req.method === "GET" && path === "/popup") {
830
- const body = served(POPUP_PAGE);
831
- if (body === null) return new Response("web/popup.html missing", { status: 500 });
832
- return new Response(body, { headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" } });
890
+ if (req.method === "GET" && (path === "/popup" || path === "/popup.js")) {
891
+ const body = served(path === "/popup" ? POPUP_PAGE : POPUP_JS);
892
+ if (body === null) return new Response(`${path} missing; run bun run build:web`, { status: 500 });
893
+ return new Response(body, { headers: { "content-type": path === "/popup" ? "text/html; charset=utf-8" : "application/javascript; charset=utf-8", "cache-control": "no-store" } });
833
894
  }
834
895
 
835
896
  // Handing the chat between Home and the popup (`kaizen chat`). /popup/open:
@@ -1009,6 +1070,16 @@ export async function web(repoDir: string, opts: Opts = {}) {
1009
1070
  const saved = saveImage(bytes);
1010
1071
  return saved ? json({ path: saved }) : bad("not an image", 415);
1011
1072
  }
1073
+ // The phone's Attach key: any file, saved on this computer under its own name, and its path typed into the terminal.
1074
+ if (req.method === "POST" && path === "/term-file") {
1075
+ if (!sameOrigin(req)) return bad("cross-origin request refused", 403);
1076
+ if (Number(req.headers.get("content-length") ?? 0) > MAX_FILE) return bad("file too large (25 MB at most)", 413);
1077
+ let name = "file";
1078
+ try { name = decodeURIComponent(req.headers.get("x-file-name") ?? "file"); } catch {}
1079
+ const bytes = new Uint8Array(await req.arrayBuffer());
1080
+ const saved = saveFile(bytes, name);
1081
+ return saved ? json({ path: saved }) : bad(bytes.length ? "file too large (25 MB at most)" : "empty file", bytes.length ? 413 : 400);
1082
+ }
1012
1083
  if (req.method === "POST" && path === "/shell") {
1013
1084
  const refused = strict(req);
1014
1085
  if (refused) return refused;
@@ -1278,6 +1349,35 @@ export async function web(repoDir: string, opts: Opts = {}) {
1278
1349
  // Never the board itself: `kaizen web` started inside the workspace listens there too.
1279
1350
  return json(devPorts(out, (pid) => { try { return readlinkSync(`/proc/${pid}/cwd`); } catch { return ""; } }, ws, [...KNOWN_AGENTS.map((a) => a.cmd), "cursor-agent"]).filter((p) => p !== port));
1280
1351
  }
1352
+ // A dev server (POST /shell with dev) whose terminal says its port is taken: that port and who holds it, for the Run app
1353
+ // button's "Stop it and run the app" question. Read from the terminal's own output, so nothing is guessed.
1354
+ if (req.method === "GET" && path === "/shell/conflict") {
1355
+ if (!local(req)) return bad("cross-origin request refused", 403);
1356
+ const key = url.searchParams.get("key") ?? "";
1357
+ // The shell may already have left /shells (dead ones drop there); its output is kept a little longer.
1358
+ const p = /^sh-[\w-]+$/.test(key) ? conflictPort(ptyTail(key) ?? "") : null;
1359
+ return json(p ? { port: p, holders: await holders(p), board: p === port } : { port: null });
1360
+ }
1361
+ // The ports this user's processes listen on, inside the board's projects (the Resources popup's Ports). Not the board's own,
1362
+ // not the agents (Claude Code listens on a local port of its own). Linux only; elsewhere the list is empty.
1363
+ if (req.method === "GET" && path === "/ports") {
1364
+ if (!local(req)) return bad("cross-origin request refused", 403);
1365
+ const dirs = states(true).filter((d) => d !== join(home, ".kaizen")).map((d) => dirname(d));
1366
+ const agents = [...KNOWN_AGENTS.map((a) => a.cmd), "cursor-agent"];
1367
+ const list = inProjects(await listeners(), dirs).filter((l) => l.pid !== process.pid && l.port !== port && !agents.includes(l.name) && !isKaizenProcess(l.cmd));
1368
+ return json(list.map((l) => ({ port: l.port, pid: l.pid, name: l.name, cmd: l.cmd, cwd: l.cwd, project: label(join(l.project, ".kaizen")) })));
1369
+ }
1370
+ // Stops what listens on a port (the question above, answered yes): a process of this user, never the board itself.
1371
+ if (req.method === "POST" && path === "/port/stop") {
1372
+ const refused = strict(req);
1373
+ if (refused) return refused;
1374
+ let body: any;
1375
+ try { body = await req.json(); } catch { return bad("json body expected"); }
1376
+ const n = Number(body?.port);
1377
+ if (n === port) return bad("that is the board itself");
1378
+ const r = await stopPort(n, [process.pid]);
1379
+ return r.ok ? json(r) : bad(r.error ?? "could not stop it");
1380
+ }
1281
1381
  // A phone on the tailnet cannot reach this computer's localhost. Serves that loopback port
1282
1382
  // to the tailnet (`tailscale serve --https=<port>`, never funnel) and answers the address
1283
1383
  // the phone opens instead. Loopback http only, one argv, never a shell string.
@@ -1346,7 +1446,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
1346
1446
  // Not the board itself: a proxy to it would forward /pty with an Origin rewritten to the board's own.
1347
1447
  if (u.port === (new URL(req.url).port || "80")) return bad("that is the board's own port", 400);
1348
1448
  try {
1349
- const px = openProxy(u);
1449
+ const px = openProxy(u, () => served(ANNOTATE_JS));
1350
1450
  return json({ ok: true, origin: px.origin, token: px.token, url: px.origin + u.pathname + u.search + u.hash });
1351
1451
  } catch (e) { return bad((e as Error).message, 500); }
1352
1452
  }
@@ -1509,7 +1609,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
1509
1609
  if (path === "/task-artifact") return taskArtifactResponse(found.state, found.task.id, url.searchParams.get("result") ?? "", url.searchParams.get("artifact") ?? "", req, url.searchParams.get("download") === "1");
1510
1610
  let task = taskService.reconcile(found.state, found.task, taskHooks);
1511
1611
  if (task.safe && !task.queuePaused && !task.pendingDecision && task.inputs.some(i => i.state === "queued")) task = taskService.dispatchReady(found.state, task.id, taskHooks);
1512
- return json({ task: taskService.taskView(found.state, task), results: taskService.resultViews(found.state, task.id), projects: taskProjects(), defaults: taskService.taskDefaults(found.state) });
1612
+ return json({ task: taskService.taskView(found.state, task, taskHooks), results: taskService.resultViews(found.state, task.id), projects: taskProjects(), defaults: taskService.taskDefaults(found.state) });
1513
1613
  } catch (e) { return bad((e as Error).message, e instanceof tasks.TaskError ? e.status : 400); }
1514
1614
  }
1515
1615
 
@@ -1545,6 +1645,17 @@ export async function web(repoDir: string, opts: Opts = {}) {
1545
1645
  // Off this thread: it also relays every terminal, and a rebuild here froze their typing.
1546
1646
  const { cards, extra, backlog } = await buildSnap(dirs, gitGen).catch(() => snapshot(dirs, gitGen));
1547
1647
  const pty = ptyOf(cards), beat = heartbeatMinutes();
1648
+ // A task's decisions shown on its run too: the open question, and Looks good when it may be given.
1649
+ const taskByRun = new Map<string, { id: string; dir: string; revision: number; result: string | null; question?: { id: string; text: string; options: string[] }; accept: boolean }>();
1650
+ for (const d of new Set(cards.filter((c) => c.kind === "run").map((c) => c.state))) {
1651
+ try {
1652
+ for (const t of tasks.listTasks(d)) {
1653
+ if (t.archived || !t.activeRun) continue;
1654
+ const q = t.pendingDecision?.kind === "question" && t.pendingDecision.run === t.activeRun ? t.pendingDecision : null;
1655
+ taskByRun.set(d + "\0" + t.activeRun, { id: t.id, dir: d, revision: t.revision, result: t.currentResult, ...(q ? { question: { id: q.id, text: q.text, options: q.options ?? [] } } : {}), accept: t.status !== "accepted" && taskService.allowedActions(d, t, taskHooks).accept });
1656
+ }
1657
+ } catch { /* a task file mid-write: the next refresh has it */ }
1658
+ }
1548
1659
  // The agents open now, for the sidebar cards: one list per tick, from the cards' sessions and the board's agent
1549
1660
  // shells. ws is as the card or shell has it; the page resolves it to a listed workspace. Ended agents are left out.
1550
1661
  const agents: any[] = [], seenKey = new Set<string>(), ptys = cards.map(pty);
@@ -1569,9 +1680,12 @@ export async function web(repoDir: string, opts: Opts = {}) {
1569
1680
  // Dirs with a card the picker leaves out (the global queue, a project outside the
1570
1681
  // Projects folder): the rail still needs their workspaces so a waiting run shows.
1571
1682
  rail: [...new Set(cards.map((c) => c.state))].filter((d) => !picker.includes(d)).map(entry),
1683
+ // Every known project, the Projects folder ignored: the Notes tab lists these (#86).
1684
+ known: states(true).map((d) => ({ dir: d, label: label(d) })),
1572
1685
  fresh: unset.map((d) => ({ dir: join(d, ".kaizen"), label: tilde(d) })),
1573
1686
  agents,
1574
1687
  cards: cards.map((c, i) => {
1688
+ const task = c.kind === "run" && c.id ? taskByRun.get(c.state + "\0" + c.id) : undefined;
1575
1689
  const rep = c.kind === "run" && c.id && c.status !== "done" && c.status !== "abandoned" ? readReport(c.state, c.id) : null;
1576
1690
  const signal = signalOf(c, rep, ptys[i] as any, Date.now(), beat);
1577
1691
  // Only a run that has workers.json carries `workers`: any other card is as it was.
@@ -1579,7 +1693,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
1579
1693
  // No terminal left to wake: the card says so, and approval works here as for any run.
1580
1694
  const hand = c.kind === "run" && c.id ? readHandoff(c.state, c.id) : null, parentPty = hand ? ptyState(hand.parent_terminal) : null;
1581
1695
  const unwoken = wakeAction(hand, parentPty ? { ...parentPty, typedAt: parentPty.typedAt ?? 0 } : null, Date.now()), orphan = unwoken === "gone" || unwoken === "held";
1582
- return { ...c, notice: notice(orphan ? { ...c, handoff: hand!.status } : c), ...extra[i], pty: ptys[i], signal, ...(ws ? { workers: ws.workers.map((x) => ({ id: x.id, title: x.title, status: workerStale(x, x.key ? ptyState(x.key) : null, Date.now(), beat) ? "stale" : x.status, bypass: x.bypass })), ...(ws.merge && ws.merge.status !== "merged" ? { workersMerge: ws.merge.status } : {}) } : {}), ...(rep?.phase ? { phase: rep.phase } : {}), ...(signal === "blocked" ? { blocked: rep!.blocked } : {}) };
1696
+ return { ...c, notice: notice(orphan ? { ...c, handoff: hand!.status } : c), ...extra[i], pty: ptys[i], signal, ...(ws ? { workers: ws.workers.map((x) => ({ id: x.id, title: x.title, status: workerStale(x, x.key ? ptyState(x.key) : null, Date.now(), beat) ? "stale" : x.status, bypass: x.bypass })), ...(ws.merge && ws.merge.status !== "merged" ? { workersMerge: ws.merge.status } : {}) } : {}), ...(rep?.phase ? { phase: rep.phase } : {}), ...(signal === "blocked" ? { blocked: rep!.blocked } : {}), ...(task ? { task } : {}) };
1583
1697
  }),
1584
1698
  backlog: backlog.map((b) => ({ ...b, starting: backlogLaunched.has(`${b.state}\0${b.source}#${b.n}`) || undefined })),
1585
1699
  now: Date.now(),
@@ -1830,7 +1944,16 @@ export async function web(repoDir: string, opts: Opts = {}) {
1830
1944
  rea.forgetDoctor(); rea.forgetLatest();
1831
1945
  return r.ok ? json(r) : bad(r.why);
1832
1946
  }
1833
- return bad("step: plan, apply or off");
1947
+ // Node.js for REA: runs only the command nodeFix builds here, after the page's confirm
1948
+ // and with the one-time token the Skills page got; never a command from the request.
1949
+ if (body?.step === "node") {
1950
+ const tokenOk = !!skillToken && body?.token === skillToken;
1951
+ skillToken = "";
1952
+ if (body?.confirm !== true || !tokenOk) return bad("confirm required");
1953
+ const r = await rea.installNode();
1954
+ return r.ok ? json({ ok: true }) : bad(r.why);
1955
+ }
1956
+ return bad("step: plan, apply, off or node");
1834
1957
  }
1835
1958
 
1836
1959
  // Per user, so no scope. A saved environment value is never in either answer.
@@ -2073,6 +2196,16 @@ export async function web(repoDir: string, opts: Opts = {}) {
2073
2196
  return new Response(null, { status: 302, headers: { location: u, "cache-control": "no-store", "referrer-policy": "no-referrer" } });
2074
2197
  }
2075
2198
 
2199
+ if (DEV && path === "/__dev/stream" && req.method === "GET") {
2200
+ let c: ReadableStreamDefaultController;
2201
+ return new Response(new ReadableStream({ start(x) { c = x; devClients.add(x); x.enqueue("data: hello\n\n"); }, cancel() { devClients.delete(c); } }),
2202
+ { headers: { "content-type": "text/event-stream", "cache-control": "no-store", "connection": "keep-alive" } });
2203
+ }
2204
+ if (DEV && path === "/__dev/reload" && req.method === "POST" && local(req)) {
2205
+ for (const c of devClients) { try { c.enqueue("data: reload\n\n"); } catch { devClients.delete(c); } }
2206
+ return json({ ok: true, clients: devClients.size });
2207
+ }
2208
+
2076
2209
  if (req.method === "GET" && path === "/events") {
2077
2210
  let ctrl: ReadableStreamDefaultController;
2078
2211
  const stream = new ReadableStream({
@@ -2126,7 +2259,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
2126
2259
  agents: KNOWN_AGENTS.filter((a) => agentUsable(a.cmd)).map((a) => a.cmd),
2127
2260
  // As POST /run starts a task, without one on the inbox.
2128
2261
  run: async (d: string, runner: "lite" | "full", agent: string, text: string) => {
2129
- const r = launchRun(parseItem(`${runner} ${text}`), d, undefined, { agent, ...inCard(d) });
2262
+ const r = launchRun(parseItem(`${runner} ${text}`), d, undefined, { agent, ...inCard });
2130
2263
  changed();
2131
2264
  return r.ok ? { agent: r.agent.cmd } : { error: r.why };
2132
2265
  },
@@ -2270,14 +2403,14 @@ export async function web(repoDir: string, opts: Opts = {}) {
2270
2403
  if (!destination || !states(true).includes(destination) || destination === join(home, ".kaizen")) return bad("Choose a named project", 400);
2271
2404
  const task = tasks.transferDraft(found.state, found.task.id, destination, dirname(destination));
2272
2405
  const result = taskService.taskAction(destination, { op: "start", id: task.id, revision: task.revision, operationId: String(body.operationId) + ":start" }, taskHooks);
2273
- changed(); return json({ ok: true, task: taskService.taskView(result.state, result.task) });
2406
+ changed(); return json({ ok: true, task: taskService.taskView(result.state, result.task, taskHooks) });
2274
2407
  }
2275
2408
  if (!["create", "adopt"].includes(body.op)) {
2276
2409
  const found = tasks.resolveTask(dir, String(body.id ?? ""));
2277
2410
  if (!found || !states(true).includes(found.state)) return bad("unknown task", 404);
2278
2411
  }
2279
2412
  const result = taskService.taskAction(dir, body, taskHooks);
2280
- changed(); return json({ ok: true, task: taskService.taskView(result.state, result.task) });
2413
+ changed(); return json({ ok: true, task: taskService.taskView(result.state, result.task, taskHooks) });
2281
2414
  } catch (e) { return bad((e as Error).message, e instanceof tasks.TaskError ? e.status : 400); }
2282
2415
  }
2283
2416
 
@@ -2484,7 +2617,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
2484
2617
  const p = parseItem(line.text);
2485
2618
  const it: Item = { ...p, text: kind ? `${kind} ${p.text}` : p.text };
2486
2619
  it.notes = [source !== "orphan" ? `Parent: ${source}` : "", `Backlog: ${source}#${n}`, p.text !== line.text ? `Backlog item: ${line.text}` : ""].filter(Boolean).join("\n");
2487
- const r = launchRun(it, dir, undefined, { agent, account: typeof body.account === "string" ? body.account : undefined, model: model || undefined, explore: typeof body.explore === "boolean" ? body.explore : undefined, yolo: body.yolo === true, ...inCard(dir) });
2620
+ const r = launchRun(it, dir, undefined, { agent, account: typeof body.account === "string" ? body.account : undefined, model: model || undefined, explore: typeof body.explore === "boolean" ? body.explore : undefined, yolo: body.yolo === true, ...inCard });
2488
2621
  if (r.ok) backlogLaunched.add(`${dir}\0${source}#${n}`);
2489
2622
  changed();
2490
2623
  return json(r.ok
@@ -2495,7 +2628,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
2495
2628
  // A `started` task may be run again: the terminal the first launch opened
2496
2629
  // can come up empty, and nothing else tells the board a run never began.
2497
2630
  it.notes = readInbox(dir).find((l) => (l.status === "open" || l.status === "started") && l.text === text)?.notes;
2498
- const r = launchRun(it, dir, undefined, { agent, account: typeof body.account === "string" ? body.account : undefined, model: model || undefined, explore: typeof body.explore === "boolean" ? body.explore : undefined, yolo: body.yolo === true, ...inCard(dir) });
2631
+ const r = launchRun(it, dir, undefined, { agent, account: typeof body.account === "string" ? body.account : undefined, model: model || undefined, explore: typeof body.explore === "boolean" ? body.explore : undefined, yolo: body.yolo === true, ...inCard });
2499
2632
  if (r.ok) replaceTask(dir, text, { status: "started", text });
2500
2633
  if (r.ok && r.pty) {
2501
2634
  for (const [k, v] of taskPty) if (!ptyState(v)) taskPty.delete(k); // sessions already dropped
@@ -2674,7 +2807,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
2674
2807
  // The run's conversation picks the fix up, and once that window is open the
2675
2808
  // waiting one ends. A failed launch leaves it: the decision has nowhere else.
2676
2809
  const before = Date.now();
2677
- const r = launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard(dir));
2810
+ const r = launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard);
2678
2811
  if (r.ok) (closeSessions(dir, id, { before }), markStage(dir, id, "review", r.pty));
2679
2812
  changed();
2680
2813
  return json(r.ok
@@ -2694,7 +2827,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
2694
2827
  const text = `run ${id}: the user chose Skip Explore for this run only. Stop exploration, preserve partial findings and unanswered questions in 00-explore.md, record that the user skipped it, run kaizen report unblock --run ${id}, set explore_status=skipped stage=plan awaiting=null with kaizen state, and prepare the plan. Do not change explore.enabled or skip the plan approval.`;
2695
2828
  const live = liveAgent(dir, id), before = Date.now();
2696
2829
  const r = live ? { ok: true as const, agent: live.agent, pty: live.key }
2697
- : launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard(dir));
2830
+ : launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard);
2698
2831
  if (live) submitPty(live.key, text);
2699
2832
  else if (r.ok) closeSessions(dir, id, { before });
2700
2833
  changed();
@@ -2717,31 +2850,37 @@ export async function web(repoDir: string, opts: Opts = {}) {
2717
2850
  const why = recordAcceptance(dir, id, "board");
2718
2851
  if (why) return bad(why, 409);
2719
2852
  finishRun(dir, id);
2853
+ if (run.task_id) syncTask(dir, String(run.task_id));
2720
2854
  changed();
2721
2855
  return json({ ok: true });
2722
2856
  }
2723
- if (run.task_id && run.awaiting === "approvals.plan") return bad("Confirm the current proposal on the task page so its version is checked.", 409);
2857
+ // A task's plan approval is the task's proposal confirmation: route it through the
2858
+ // task so the same version check and receipts apply. A revise is a change message.
2859
+ if (run.task_id && run.awaiting === "approvals.plan" && body.awaiting === "approvals.plan") {
2860
+ const found = tasks.resolveTask(dir, String(run.task_id));
2861
+ const d = found?.task.pendingDecision;
2862
+ if (!found || !d || d.kind !== "proposal" || d.run !== id) return bad("This task has no plan waiting. Refresh and try again.", 409);
2863
+ const why = body.why === undefined ? "" : String(body.why).trim();
2864
+ if (body.why !== undefined && !why) return bad("a revise needs a comment");
2865
+ const answers = Array.isArray(body.answers) ? body.answers.filter((a: unknown) => typeof a === "string" && a.trim()).slice(0, 20) : [];
2866
+ try {
2867
+ const op = why ? { op: "message", text: why } : { op: "confirm", decisionId: d.id };
2868
+ const done = taskService.taskAction(found.state, { ...op, id: found.task.id, revision: found.task.revision, operationId: `decide:${id}:${d.id}:${why ? "revise" : "confirm"}` }, taskHooks);
2869
+ // The plan's questions answered with the approval reach the agent as one message.
2870
+ if (!why && answers.length) taskService.taskAction(found.state, { op: "message", text: "Answers to the plan's questions:\n" + answers.join("\n"), id: found.task.id, revision: done.task.revision, operationId: `decide:${id}:${d.id}:answers` }, taskHooks);
2871
+ } catch (e) { return bad((e as Error).message, e instanceof tasks.TaskError ? e.status : 400); }
2872
+ changed();
2873
+ return json({ ok: true, task: true });
2874
+ }
2724
2875
  if (!canApproveAwaiting(run.awaiting) || run.awaiting !== body.awaiting) return bad("this run is not waiting on that approval", 409);
2725
2876
  if (run.awaiting === "findings" && body.why !== undefined) return bad("open findings can only be approved as-is or fixed individually", 409);
2726
2877
  if (body.why !== undefined && !String(body.why).trim()) return bad("a revise needs a comment");
2727
2878
  const answers = body.answers;
2728
2879
  if (answers !== undefined && (run.awaiting !== "approvals.plan" || body.why !== undefined || !Array.isArray(answers)
2729
2880
  || !answers.length || answers.length > 20 || answers.some((a: unknown) => typeof a !== "string" || !a.trim()))) return bad("bad answers");
2730
- const text = approvalPrompt(id, run.awaiting, body.why === undefined ? undefined : String(body.why), answers);
2731
- // The agent already open in this run's card takes the decision there, as it takes
2732
- // a fix: no second tab of the same conversation. With none, the run's conversation
2733
- // continues in one new window, and then the idle one ends. A failed launch leaves
2734
- // it open, since the decision went nowhere.
2735
- const live = liveAgent(dir, id);
2736
- const before = Date.now();
2737
- const r = live ? { ok: true as const, pty: live.key, agent: live.cmd, reused: true } : launchRun({ severity: null, where: null, text, raw: text }, dir, id, inCard(dir));
2738
- if (live) submitPty(live.key, text);
2739
- else if (r.ok) closeSessions(dir, id, { before });
2740
- // The plan's approval starts the build; fixing open findings is the review stage again.
2741
- if (r.ok) markStage(dir, id, run.awaiting === "approvals.plan" ? "impl" : run.awaiting === "findings" ? "review" : "", r.pty);
2742
- // Approving the review as-is is the user's acceptance, on record before the
2743
- // agent marks the run done; a revise is not.
2744
- if (r.ok && body.why === undefined && (run.awaiting === "approvals.review" || run.awaiting === "findings")) recordAcceptance(dir, id, "board");
2881
+ const { r, live } = sendDecision(dir, id, run.awaiting, body.why === undefined ? undefined : String(body.why), answers);
2882
+ // A task's run approved here is the task's Looks good too.
2883
+ if (r.ok && run.task_id) syncTask(dir, String(run.task_id));
2745
2884
  changed();
2746
2885
  return json(r.ok
2747
2886
  ? { ok: true, agent: r.agent, pty: r.pty, ...(live ? { reused: true } : {}) }
@@ -2761,6 +2900,7 @@ export async function web(repoDir: string, opts: Opts = {}) {
2761
2900
  const why = recordAcceptance(dir, id, "board");
2762
2901
  if (why) return bad(why, 409);
2763
2902
  finishRun(dir, id);
2903
+ if (st.task_id) syncTask(dir, String(st.task_id));
2764
2904
  changed();
2765
2905
  return json({ ok: true });
2766
2906
  }
@@ -2826,7 +2966,6 @@ export async function web(repoDir: string, opts: Opts = {}) {
2826
2966
  done.add(`${dir}\0${id}`);
2827
2967
  viaRun.add(key);
2828
2968
  if (saved.crash && resumed && Date.now() - resumed < CRASH_AGAIN_MS) { console.log(` not resuming ${id}: the board died again right after resuming it`); continue; }
2829
- if (launchMode(projectOf(dir)) !== "card") continue;
2830
2969
  const r = resumeRun(dir, id);
2831
2970
  if (saved.crash && "pty" in r && r.pty) autoResumed.set(r.pty, Date.now());
2832
2971
  console.log(` ${"error" in r || !r.ok ? "could not resume" : "resumed"} ${id}${"error" in r ? ` (${r.error})` : !r.ok ? ` (${r.why})` : ""}`);
@@ -2983,11 +3122,8 @@ export function shellHosts(root: number, id: string): boolean {
2983
3122
  }
2984
3123
 
2985
3124
  export async function openApp(url: string, profile?: string) {
2986
- // Kaizen Bot's window (a profile) is always an app; the board asks the setting.
2987
- if (!profile) {
2988
- const { listSettings } = await import("./settings.ts");
2989
- if (listSettings(join(import.meta.dir, "..")).rows.find((r) => r.key === "board.open")?.value !== "app") return openDefault(url);
2990
- }
3125
+ // Kaizen Bot's window (a profile) is an app window; the board opens in a browser tab.
3126
+ if (!profile) return openDefault(url);
2991
3127
  const args = [`--app=${url}`, ...(profile ? [`--user-data-dir=${profile}`] : [])];
2992
3128
  const chromes = process.platform === "darwin"
2993
3129
  ? ["Google Chrome", "Chromium", "Microsoft Edge", "Brave Browser"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kaizen-agent",
3
- "version": "1.85.2",
3
+ "version": "1.87.0",
4
4
  "description": "Staged workflow for AI agents — code, writing, research, operations: plan, human approval, build, independent review, bounded fix loop.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,6 +13,7 @@
13
13
  "agents",
14
14
  "commands",
15
15
  "web",
16
+ "tsconfig.json",
16
17
  "assets/kaizen-logo.png",
17
18
  "assets/kaizen.ico",
18
19
  "README.md",
@@ -24,9 +25,10 @@
24
25
  "install-links": "bun run cli/install.ts",
25
26
  "check": "bun run cli/install.ts --check",
26
27
  "build:web": "bun run cli/build-web.ts",
28
+ "dev": "bun cli/dev.ts",
27
29
  "audit:ui": "bun run cli/ui-audit.ts",
28
- "format": "prettier --write web/*.ts web/board bot/web/app",
29
- "format:check": "prettier --check web/*.ts web/board bot/web/app",
30
+ "format": "prettier --write web/notebook web/term web/video web/ui web/components web/pages web/lib bot/web/app",
31
+ "format:check": "prettier --check web/notebook web/term web/video web/ui web/components web/pages web/lib bot/web/app",
30
32
  "test": "bun test",
31
33
  "prepublishOnly": "bun test",
32
34
  "postpublish": "sh cli/release.sh",
@@ -57,12 +59,27 @@
57
59
  "@codemirror/state": "6.7.6",
58
60
  "@codemirror/view": "6.43.13",
59
61
  "@lezer/highlight": "1.2.5",
62
+ "@tailwindcss/cli": "4.3.5",
63
+ "@types/bun": "1.4.4",
64
+ "@types/react": "19.3.0",
65
+ "@types/react-dom": "19.3.0",
60
66
  "@xterm/addon-fit": "0.11.0",
61
67
  "@xterm/addon-search": "0.16.0",
62
68
  "@xterm/addon-unicode11": "0.9.0",
63
69
  "@xterm/addon-web-links": "0.12.0",
64
70
  "@xterm/addon-webgl": "0.19.0",
65
71
  "@xterm/xterm": "6.0.0",
66
- "prettier": "3.9.10"
72
+ "class-variance-authority": "0.7.1",
73
+ "clsx": "2.1.1",
74
+ "cmdk": "1.1.1",
75
+ "prettier": "3.9.10",
76
+ "radix-ui": "1.8.1",
77
+ "react": "19.3.1",
78
+ "react-dom": "19.3.1",
79
+ "sonner": "2.0.8",
80
+ "tailwind-merge": "3.7.0",
81
+ "tailwindcss": "4.3.5",
82
+ "tw-animate-css": "1.4.0",
83
+ "zustand": "5.1.0"
67
84
  }
68
85
  }
@@ -213,9 +213,12 @@ switch agents. Both full and lite runners honor the persisted task policy before
213
213
  reading global auto/approval defaults.
214
214
 
215
215
  Task intake/planning may ask questions and propose an outcome, but must not produce
216
- until the current proposal is explicitly confirmed. Use the sanctioned state command;
217
- it rejects build/review/done before that confirmation. Do not overwrite task_policy,
218
- task_id or task_confirmed by hand. The task page owns the versioned decision.
216
+ until the current plan is explicitly approved. Use the sanctioned state command;
217
+ it rejects build/review/done before that approval. Do not overwrite task_policy,
218
+ task_id or task_confirmed by hand. The user may decide in any of three places: the task
219
+ page, the run panel, or by typing to you. The board records the first two; record a
220
+ decision typed to you with the `approved` or `answered` event below. The final yes on
221
+ the result is `kaizen done <run> --user-approved`; it also accepts the task.
219
222
 
220
223
  Read context with `kaizen task show --task <uuid>`. Publish structured events with
221
224
  `kaizen task event --task <uuid> --run <run-id> --operation <stable-event-id> --json '<event>'`.
@@ -227,6 +230,10 @@ input ids; acknowledge the launch before doing anything else:
227
230
  - `{"type":"question","text":"...","options":["..."]}` requests material input.
228
231
  - `{"type":"proposal","text":"outcome, constraints and checks","details":"full plan"}`
229
232
  requests explicit confirmation of this run/iteration/result. Stop production here.
233
+ - `{"type":"approved"}` records that the user approved the current plan by typing to
234
+ you in the agent terminal. Send it only on a clear yes, then continue the build.
235
+ - `{"type":"answered","text":"..."}` records the user's answer to your open question (or
236
+ their plan changes) given in the agent terminal, so the task and run pages stop asking.
230
237
  - `{"type":"work","text":"..."}` reports genuine production after confirmation.
231
238
  - `{"type":"receipt","inputIds":["..."],"outcome":"applied"}` acknowledges only
232
239
  dispatched input ids. Use `failed` and `error` for requests not applied.
@@ -239,7 +246,8 @@ input ids; acknowledge the launch before doing anything else:
239
246
  publishes a typed version. Paths must be regular files inside the project/worktree.
240
247
  Do not snapshot source trees or databases. HTML/SVG files download only. Include
241
248
  specialized Video identity as `video:{name,letter,revision}` when relevant, without
242
- changing its recipes. A copy/disk failure retains earlier versions and needs recovery.
249
+ changing its recipes. A refused result does not pause the task; fix the cause and publish again.
250
+ Only a failed copy to disk pauses it, retains earlier versions and needs recovery.
243
251
 
244
252
  A question/status reply never authorizes production. Queued change requests are not
245
253
  already applied: keep their ids and report receipts. Stop requests cancellation and