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
@@ -0,0 +1,265 @@
1
+ // Dictation: Whisper in the page. Audio never leaves the browser; the model is fetched once from huggingface.co and
2
+ // cached. The library and the models are pinned here and in chunks.ts. One session listens at a time; the button that
3
+ // started it shows its state through dictation-store.ts.
4
+ import { toast } from "@lib/core";
5
+ import { openMic, savedMic } from "./mic.ts";
6
+ import { ASR_MODELS, SAMPLE_RATE, insertAt, makeChunker, makeOrdered, modelFor } from "./chunks.ts";
7
+ import { idleMic, markMic } from "./dictation-store.ts";
8
+
9
+ const TFJS = "https://cdn.jsdelivr.net/npm/@huggingface/transformers@4.3.0";
10
+ // Inference lives in a module Worker so a slow chunk never freezes the board. A function, so a bundle that imports this
11
+ // file without mounting a microphone button (the Notebook's kit) drops the source text instead of carrying it.
12
+ const workerSrc = () => `import{pipeline}from"${TFJS}";let asr=null;
13
+ onmessage=async e=>{const m=e.data;try{
14
+ if(m.type==="load"){const prog=p=>{if(p.status==="progress")postMessage({type:"progress",file:p.file,pct:p.progress||0})};
15
+ // WebGPU first, with the encoder in fp16 only where the adapter has shader-f16; any GPU failure falls back to the CPU.
16
+ const gpu=m.webgpu?{device:"webgpu",dtype:{encoder_model:m.f16?"fp16":"fp32",decoder_model_merged:"q4"}}:null,cpu={device:"wasm",dtype:"q8"};
17
+ try{if(!gpu)throw 0;asr=await pipeline("automatic-speech-recognition",m.model,{...gpu,progress_callback:prog})}
18
+ catch(e){if(gpu)postMessage({type:"fallback",why:String(e&&e.message||e)});asr=await pipeline("automatic-speech-recognition",m.model,{...cpu,progress_callback:prog})}
19
+ postMessage({type:"ready"})}
20
+ if(m.type==="run"){const r=await asr(m.audio,{chunk_length_s:30,return_timestamps:false});postMessage({type:"text",sid:m.sid,seq:m.seq,text:(r.text||"").trim()})}
21
+ }catch(err){postMessage({type:"error",sid:m.sid,seq:m.seq,error:String(err&&err.message||err)})}}`;
22
+ // The worklet only forwards 128-frame blocks; chunking and silence detection stay on the main thread.
23
+ const WORKLET_SRC = `class T extends AudioWorkletProcessor{process(i){const c=i[0]&&i[0][0];if(c)this.port.postMessage(c.slice(0));return true}}registerProcessor("kz-tap",T)`;
24
+
25
+ export const hasMic = () =>
26
+ !!(
27
+ navigator.mediaDevices &&
28
+ navigator.mediaDevices.getUserMedia &&
29
+ window.AudioWorkletNode &&
30
+ window.WebAssembly &&
31
+ window.Worker
32
+ );
33
+
34
+ // What dictation types into: a textarea or input, or the stand-in for a terminal (terminal-dictation.ts). `classList`,
35
+ // `style` and `onStart` are there only when the field has them.
36
+ export type Field = {
37
+ value: string;
38
+ selectionStart: number | null;
39
+ selectionEnd: number | null;
40
+ isConnected: boolean;
41
+ classList?: DOMTokenList;
42
+ style?: CSSStyleDeclaration;
43
+ focus(): void;
44
+ dispatchEvent(e: Event): boolean;
45
+ onStart?(): void;
46
+ };
47
+ // One button's claim: its id (the key of its state), the element the level meter is set on, and the field to type into.
48
+ export type Owner = { id: string; el?: HTMLElement | null; target(): Field };
49
+
50
+ // `active` is the one session listening; `sessions` also holds stopped ones still waiting on a chunk.
51
+ type Session = { id: string; field: Field; onmsg(m: any): void; stop(): void };
52
+ let asrModel: string | null = null,
53
+ asrWorker: Worker | null = null,
54
+ asrReady: Promise<void> | null = null,
55
+ progressTo: string | null = null, // the button whose press is waiting on the model
56
+ active: Session | null = null,
57
+ starting = false;
58
+ const sessions = new Set<Session>();
59
+ const dropWorker = () => {
60
+ try {
61
+ asrWorker?.terminate();
62
+ } catch {}
63
+ asrWorker = null;
64
+ asrReady = null;
65
+ };
66
+
67
+ // One worker for the page; loading is awaited by whoever pressed first, later presses join. Loads the model named in
68
+ // settings; a model changed since the last load replaces the worker.
69
+ async function loadAsr(): Promise<void> {
70
+ let want: unknown = "small";
71
+ try {
72
+ const cfg = await fetch("/settings").then((r) => r.json());
73
+ want = (cfg.rows.find((r: any) => r.key === "dictation.model") || {}).value || want;
74
+ } catch {}
75
+ const model = modelFor(want);
76
+ if (asrReady && asrModel !== model) {
77
+ active?.stop(); // a session still listening would post to the worker being dropped
78
+ dropWorker();
79
+ sessions.clear();
80
+ active = null;
81
+ }
82
+ if (asrReady) return asrReady;
83
+ asrModel = model;
84
+ const ready = new Promise<void>(async (res, rej) => {
85
+ const w = (asrWorker = new Worker(URL.createObjectURL(new Blob([workerSrc()], { type: "text/javascript" })), {
86
+ type: "module",
87
+ }));
88
+ const files: Record<string, number> = {};
89
+ w.onmessage = (e) => {
90
+ const m = e.data;
91
+ if (m.type === "progress") {
92
+ files[m.file] = m.pct;
93
+ const v = Object.values(files);
94
+ if (progressTo) markMic(progressTo, { pct: Math.round(v.reduce((a, b) => a + b, 0) / v.length) });
95
+ } else if (m.type === "ready") res();
96
+ else if (m.type === "fallback") toast("GPU could not run the model, using the CPU: " + m.why);
97
+ else if (m.type === "error" && m.seq == null) rej(new Error(m.error));
98
+ for (const s of sessions) s.onmsg(m);
99
+ };
100
+ w.onerror = (e) => rej(new Error(e.message || "worker failed"));
101
+ // Ask the adapter what it can do: no adapter means the CPU path; no shader-f16 means an fp32 encoder.
102
+ let adapter: any = null;
103
+ try {
104
+ adapter = (navigator as any).gpu && (await (navigator as any).gpu.requestAdapter());
105
+ } catch {}
106
+ if (!adapter) toast("No WebGPU: dictation will run on the CPU and be slower");
107
+ w.postMessage({
108
+ type: "load",
109
+ model: ASR_MODELS[asrModel as string],
110
+ webgpu: !!adapter,
111
+ f16: !!(adapter && adapter.features.has("shader-f16")),
112
+ });
113
+ });
114
+ asrReady = ready;
115
+ ready.catch(() => {
116
+ if (asrReady === ready) dropWorker();
117
+ });
118
+ return ready;
119
+ }
120
+
121
+ // After a re-render only a listener whose field is gone is stopped; closing the panel stops any.
122
+ export function stopDictation(all?: boolean) {
123
+ if (active && (all || !active.field.isConnected)) active.stop();
124
+ }
125
+
126
+ // Whether the session `id` is the one listening.
127
+ export const listeningFor = (id: string) => active?.id === id;
128
+
129
+ // A press on a microphone button: stops what is listening (and stops there if that was this button), else loads the model,
130
+ // asks for the microphone and starts listening into the owner's target field. Text lands where the caret is when each chunk
131
+ // arrives (or after the last insertion when the field is not focused), so typing while the mic is on is kept.
132
+ export async function toggleMic(o: Owner) {
133
+ if (active) {
134
+ const mine = active.id === o.id;
135
+ active.stop();
136
+ if (mine) return;
137
+ }
138
+ // One press at a time: the model load and the permission prompt are both awaits a second press could slip through.
139
+ if (starting) return;
140
+ starting = true;
141
+ const fail = (why: string) => {
142
+ idleMic(o.id);
143
+ starting = false;
144
+ toast(why);
145
+ };
146
+ markMic(o.id, { loading: true, busy: true, pct: null });
147
+ progressTo = o.id;
148
+ try {
149
+ await loadAsr();
150
+ } catch (err: any) {
151
+ progressTo = null;
152
+ return fail("Dictation model could not load: " + err.message);
153
+ }
154
+ progressTo = null;
155
+ markMic(o.id, { loading: false, pct: null });
156
+ const gone = () => !!o.el && !o.el.isConnected;
157
+ if (gone()) {
158
+ idleMic(o.id);
159
+ starting = false;
160
+ return;
161
+ }
162
+ let stream: MediaStream;
163
+ try {
164
+ stream = await openMic((audio) => navigator.mediaDevices.getUserMedia({ audio }), savedMic(), toast);
165
+ } catch (err: any) {
166
+ return fail("Microphone not available: " + (err.name === "NotAllowedError" ? "permission denied" : err.message));
167
+ }
168
+ // The field went away while the permission prompt was up (its dialog closed): nothing to type into.
169
+ if (gone()) {
170
+ stream.getTracks().forEach((t) => t.stop());
171
+ idleMic(o.id);
172
+ starting = false;
173
+ return;
174
+ }
175
+ if (active) active.stop();
176
+ let ctx: AudioContext, src: MediaStreamAudioSourceNode, tap: AudioWorkletNode;
177
+ try {
178
+ ctx = new AudioContext({ sampleRate: SAMPLE_RATE });
179
+ await ctx.audioWorklet.addModule(URL.createObjectURL(new Blob([WORKLET_SRC], { type: "text/javascript" })));
180
+ src = ctx.createMediaStreamSource(stream);
181
+ tap = new AudioWorkletNode(ctx, "kz-tap");
182
+ } catch (err: any) {
183
+ stream.getTracks().forEach((t) => t.stop());
184
+ return fail("Microphone not available: " + err.message);
185
+ }
186
+ src.connect(tap);
187
+ const f = o.target(),
188
+ id = o.id,
189
+ sid = Math.random().toString(36).slice(2), // chunk seqs are per session, so a result is matched by session id too
190
+ chunker = makeChunker(),
191
+ order = makeOrdered();
192
+ f.onStart?.();
193
+ let at = f.selectionStart ?? f.value.length,
194
+ seq = 0,
195
+ stopping = false;
196
+ const write = (t: string) => {
197
+ if (!t || !f.isConnected) return;
198
+ if (typeof document !== "undefined" && document.activeElement === (f as unknown)) at = f.selectionStart ?? at;
199
+ const r = insertAt(f.value, at, t);
200
+ f.value = r.value;
201
+ at = r.at;
202
+ f.selectionStart = f.selectionEnd = at;
203
+ f.dispatchEvent(new Event("input", { bubbles: true }));
204
+ };
205
+ const flush = () => {
206
+ const a = chunker.take();
207
+ if (!a || !asrWorker) return;
208
+ order.reserve(seq);
209
+ asrWorker.postMessage({ type: "run", sid, seq, audio: a }, [a.buffer]);
210
+ seq++;
211
+ markMic(id, { busy: true });
212
+ };
213
+ const drain = () => {
214
+ if (!order.drain(write)) return;
215
+ markMic(id, { busy: false });
216
+ if (stopping) {
217
+ idleMic(id);
218
+ sessions.delete(sess);
219
+ }
220
+ };
221
+ tap.port.onmessage = (e) => {
222
+ const { level, ready } = chunker.push(e.data);
223
+ f.style?.setProperty("--lvl", level);
224
+ o.el?.style.setProperty("--lvl", level);
225
+ if (ready) flush();
226
+ };
227
+ const sess: Session = {
228
+ id,
229
+ field: f,
230
+ onmsg: (m) => {
231
+ if (m.sid !== sid) return;
232
+ if (m.type === "text") {
233
+ order.set(m.seq, m.text);
234
+ drain();
235
+ } else if (m.type === "error" && m.seq != null) {
236
+ order.set(m.seq, "");
237
+ toast("Dictation failed: " + m.error);
238
+ drain();
239
+ }
240
+ },
241
+ stop: () => {
242
+ if (stopping) return;
243
+ stopping = true;
244
+ markMic(id, { on: false });
245
+ f.classList?.remove("dictating");
246
+ f.style?.removeProperty("--lvl");
247
+ try {
248
+ tap.port.onmessage = null;
249
+ src.disconnect();
250
+ tap.disconnect();
251
+ stream.getTracks().forEach((t) => t.stop());
252
+ ctx.close();
253
+ } catch {}
254
+ active = null;
255
+ flush();
256
+ drain();
257
+ },
258
+ };
259
+ sessions.add(sess);
260
+ active = sess;
261
+ starting = false;
262
+ markMic(id, { on: true, busy: false });
263
+ f.classList?.add("dictating");
264
+ f.focus();
265
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./chunks.ts";
2
+ export * from "./dictation-store.ts";
3
+ export * from "./engine.ts";
4
+ export * from "./terminal-dictation.ts";
5
+ export * from "./mic.ts";
@@ -0,0 +1,42 @@
1
+ // The microphone dictation uses, per browser (Settings → Keyboard & Dictation picks it). No choice means the system default.
2
+ const KEY = "kz-mic";
3
+ export const savedMic = () => {
4
+ try {
5
+ return localStorage.getItem(KEY) || "";
6
+ } catch {
7
+ return "";
8
+ }
9
+ };
10
+ export const saveMic = (id: string) => {
11
+ try {
12
+ localStorage.setItem(KEY, id);
13
+ } catch {
14
+ /* this browser keeps nothing */
15
+ }
16
+ };
17
+ export const micAudio = (device = "") => ({
18
+ channelCount: 1,
19
+ noiseSuppression: true,
20
+ echoCancellation: true,
21
+ ...(device ? { deviceId: { exact: device } } : {}),
22
+ });
23
+
24
+ // An unplugged choice falls back to the default, and says so. Anything else is the caller's.
25
+ export async function openMic(get: (audio: object) => Promise<MediaStream>, device: string, warn: (m: string) => void) {
26
+ try {
27
+ return await get(micAudio(device));
28
+ } catch (err: any) {
29
+ if (!device || err?.name !== "OverconstrainedError") throw err;
30
+ warn("Chosen microphone not found. Using the default");
31
+ return get(micAudio());
32
+ }
33
+ }
34
+
35
+ // The inputs to pick from. Device names appear only once the browser has microphone permission.
36
+ export async function listMics(): Promise<{ id: string; label: string }[]> {
37
+ if (!navigator.mediaDevices?.enumerateDevices) return [];
38
+ const all = await navigator.mediaDevices.enumerateDevices().catch(() => []);
39
+ return all
40
+ .filter((d) => d.kind === "audioinput" && d.deviceId && d.deviceId !== "default")
41
+ .map((d, i) => ({ id: d.deviceId, label: d.label || `Microphone ${i + 1}` }));
42
+ }
@@ -0,0 +1,50 @@
1
+ // Ctrl+Alt+D in a focused terminal. xterm's hidden textarea takes pastes, not typed values, so a stand-in field hands each
2
+ // chunk to that one terminal as a paste; the session runs as for any field. It works only while the page has focus.
3
+ import { toast } from "@lib/core";
4
+ import { hasMic, listeningFor, stopDictation, toggleMic, type Field } from "./engine.ts";
5
+
6
+ const HOT = "terminal";
7
+ function termField(box: HTMLTextAreaElement): Field {
8
+ let first = true;
9
+ return {
10
+ value: "",
11
+ selectionStart: 0,
12
+ selectionEnd: 0,
13
+ get isConnected() {
14
+ return box.isConnected;
15
+ },
16
+ focus() {},
17
+ onStart() {
18
+ toast("Listening. Ctrl+Alt+D to stop");
19
+ },
20
+ dispatchEvent() {
21
+ const data = new DataTransfer();
22
+ data.setData("text/plain", (first ? "" : " ") + this.value);
23
+ first = false;
24
+ this.value = "";
25
+ box.dispatchEvent(new ClipboardEvent("paste", { clipboardData: data, bubbles: true, cancelable: true }));
26
+ return true;
27
+ },
28
+ };
29
+ }
30
+ let started = false;
31
+ export function startTerminalDictation() {
32
+ if (started) return;
33
+ started = true;
34
+ addEventListener(
35
+ "keydown",
36
+ (e) => {
37
+ if (!e.ctrlKey || !e.altKey || e.key.toLowerCase() !== "d") return;
38
+ e.preventDefault();
39
+ e.stopPropagation();
40
+ // Pressed again while it listens: stop. A session that ended another way (mic refused, terminal closed) leaves nothing to stop.
41
+ if (listeningFor(HOT)) return stopDictation(true);
42
+ const box = document.activeElement as HTMLTextAreaElement | null;
43
+ if (!box?.classList.contains("xterm-helper-textarea")) return toast("Click into a terminal first");
44
+ if (!hasMic()) return toast("Dictation isn't available in this browser");
45
+ const f = termField(box);
46
+ void toggleMic({ id: HOT, target: () => f });
47
+ },
48
+ true,
49
+ );
50
+ }
@@ -0,0 +1,13 @@
1
+ // The footer's words, with no DOM: what the phone chip says, and how the terminal count reads.
2
+ export type PhoneNet = { tailscale?: boolean; online?: boolean; phones?: number };
3
+ export type PhoneStatus = { text: string; on: boolean; tip: string };
4
+ export function phoneStatus(d: PhoneNet): PhoneStatus {
5
+ if (!d.tailscale) return { text: "Tailscale off", on: false, tip: "Tailscale is not running on this computer" };
6
+ if (d.online) return { text: "Phone connected", on: true, tip: "A phone is online on your tailnet" };
7
+ return {
8
+ text: "Phone offline",
9
+ on: false,
10
+ tip: d.phones ? "Your phone is not online on the tailnet" : "No phone on your tailnet",
11
+ };
12
+ }
13
+ export const terminalsTitle = (n: number) => `${n} live terminal${n === 1 ? "" : "s"}: show them all`;
@@ -0,0 +1,42 @@
1
+ // The board footer's data (Zustand): what Claude and Codex have used and whether a phone is on the tailnet. The footer
2
+ // (components/footer/foot-bar.tsx) draws it, with the live terminal count from the server store (lib/server).
3
+ import { create } from "zustand";
4
+ import type { Usage } from "@lib/phone";
5
+ import { phoneStatus, type PhoneStatus } from "./footer-rules.ts";
6
+
7
+ export const useFooter = create<{ usage: Usage[] | null; phone: PhoneStatus | null; refreshing: boolean }>()(() => ({
8
+ usage: null,
9
+ phone: null,
10
+ refreshing: false,
11
+ }));
12
+
13
+ // A refresh asked for (the button) spins its icon until the answer is in, and for at least SPIN_MS so a fast answer still shows.
14
+ const SPIN_MS = 700;
15
+ export async function loadUsage(refresh = false) {
16
+ const t = Date.now();
17
+ if (refresh) useFooter.setState({ refreshing: true });
18
+ try {
19
+ const r = await fetch("/usage" + (refresh ? "?refresh=1" : ""));
20
+ if (r.ok) useFooter.setState({ usage: await r.json() });
21
+ } catch {
22
+ /* the footer keeps what it had */
23
+ } finally {
24
+ if (refresh) {
25
+ await new Promise((done) => setTimeout(done, Math.max(0, SPIN_MS - (Date.now() - t))));
26
+ useFooter.setState({ refreshing: false });
27
+ }
28
+ }
29
+ }
30
+ export async function loadPhone() {
31
+ try {
32
+ useFooter.setState({ phone: phoneStatus(await (await fetch("/phone")).json()) });
33
+ } catch {}
34
+ }
35
+ // Read once, then usage every 5 minutes and the phone every minute. Returns the function that stops them.
36
+ export function startFooter() {
37
+ void loadUsage();
38
+ void loadPhone();
39
+ const a = setInterval(() => void loadUsage(), 5 * 60_000),
40
+ b = setInterval(() => void loadPhone(), 60_000);
41
+ return () => (clearInterval(a), clearInterval(b));
42
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./footer-rules.ts";
2
+ export * from "./footer-store.ts";
@@ -0,0 +1,110 @@
1
+ // Everything the Source control tab asks the server to do, one place: the same routes and payloads the old tab sent
2
+ // (/stage, /commit, /commit-message, /pr). A step that needs a second look opens its inline form or confirm first.
3
+ import { post, cardKey, host, toast } from "@lib/core";
4
+ import { DONE, type StepId } from "./git.ts";
5
+ import { getGit, gitUi, patchUi, resetUi, runOf, setGit, type GitAsk, type GitConfirm } from "./git-store.ts";
6
+
7
+ export type GitAct =
8
+ | StepId
9
+ | "go-pr"
10
+ | "go-draft"
11
+ | "go-merge"
12
+ | "go-remove"
13
+ | "stage"
14
+ | "unstage"
15
+ | "stageall"
16
+ | "unstageall"
17
+ | "discard"
18
+ | "discardall"
19
+ | "spark";
20
+ const ASKS = ["pr", "draft", "merge", "remove"];
21
+ export const ask = (a: GitAsk | undefined) => patchUi(cardKey(getGit().snap!.card), { ask: a });
22
+ export const fold = (k: string) => {
23
+ const key = cardKey(getGit().snap!.card);
24
+ patchUi(key, { shut: { ...gitUi(key).shut, [k]: !gitUi(key).shut[k] } });
25
+ };
26
+ // Resolves when the user answers the dialog the tab shows (components/git/git-confirm.tsx).
27
+ const confirm = (c: DistributiveOmit<GitConfirm, "ok" | "run">) =>
28
+ new Promise<boolean>((ok) => setGit((s) => ({ confirm: { ...c, run: runOf(s), ok } as GitConfirm })));
29
+ type DistributiveOmit<T, K extends keyof any> = T extends unknown ? Omit<T, K> : never;
30
+
31
+ // Draws the run again from the server, unless another card has opened in the panel meanwhile.
32
+ const refetch = async (key: string) => {
33
+ const s = getGit().snap;
34
+ if (s && cardKey(s.card) === key) await host.refetchRun(s.card);
35
+ };
36
+ const withBusy = async (id: string, fn: () => Promise<void>) => {
37
+ setGit((s) => ({ busy: id, busyRun: runOf(s) }));
38
+ try {
39
+ await fn();
40
+ } finally {
41
+ setGit({ busy: null, busyRun: null });
42
+ }
43
+ };
44
+
45
+ export async function gitAct(a: GitAct, path = "", untracked = false) {
46
+ const snap = getGit().snap!,
47
+ c = snap.card,
48
+ key = cardKey(c),
49
+ ui = gitUi(key),
50
+ g = snap.git;
51
+ if (ASKS.includes(a)) return ask(a as GitAsk);
52
+ if (a === "spark")
53
+ return withBusy("spark", async () => {
54
+ const r = await post("/commit-message", { dir: c.state, id: c.id });
55
+ if (r.ok) {
56
+ patchUi(key, { msg: r.message });
57
+ if (!r.ai) toast("Claude was not available: wrote a plain message");
58
+ }
59
+ });
60
+ if (/stage|discard/.test(a)) {
61
+ const op = a === "discardall" ? "discard" : a.replace("all", ""),
62
+ paths =
63
+ /all$/.test(a) && a !== "unstageall"
64
+ ? (g.rows ?? []).filter((r) => !r.staged).map((r) => r.path)
65
+ : a === "unstageall"
66
+ ? (g.staged ?? [])
67
+ : [path];
68
+ if (a === "discard" && !(await confirm({ kind: "discard", path, untracked, many: 0 }))) return;
69
+ if (
70
+ a === "discardall" &&
71
+ !(await confirm({ kind: "discard", path: paths.join("\n"), untracked: false, many: paths.length }))
72
+ )
73
+ return;
74
+ return withBusy(a + ":" + path, async () => {
75
+ await post("/stage", { dir: c.state, id: c.id, op, paths });
76
+ await refetch(key);
77
+ });
78
+ }
79
+ const msg = ui.msg ?? snap.msg;
80
+ if ((a === "commit" || a === "commitpush") && !msg.trim()) return toast("A commit message is required");
81
+ const base = { dir: c.state, id: c.id },
82
+ [route, payload] =
83
+ a === "commit"
84
+ ? ["/commit", { ...base, message: msg, files: g.staged ?? [], push: false }]
85
+ : a === "commitpush" || a === "push"
86
+ ? ["/commit", { ...base, message: a === "commitpush" ? msg : "", files: g.files }]
87
+ : a === "go-pr" || a === "go-draft"
88
+ ? [
89
+ "/pr",
90
+ {
91
+ ...base,
92
+ op: "create",
93
+ title: ui.title ?? snap.title,
94
+ body: ui.body ?? `Run ${c.id}.`,
95
+ draft: a === "go-draft",
96
+ },
97
+ ]
98
+ : ["/pr", { ...base, op: a === "go-merge" ? "merge" : "remove" }];
99
+ return withBusy(a, async () => {
100
+ let r = await post(route, payload);
101
+ // The preflight stopped it: show what it found; a go-ahead resends with its one-time token.
102
+ if (r.preflight && (await confirm({ kind: "preflight", pf: r.preflight })))
103
+ r = await post(route, { ...payload, override: r.token });
104
+ if (r.ok) {
105
+ toast(DONE(a, r as any));
106
+ resetUi(key);
107
+ }
108
+ await refetch(key);
109
+ });
110
+ }
@@ -0,0 +1,43 @@
1
+ import { commitMsg } from "@lib/markdown";
2
+ import { getPanel, setPanel } from "@lib/run";
3
+ import { setGit } from "./git-store.ts";
4
+
5
+ // The run's Source control tab is React (web/components/git/git-tab.tsx, rules in web/lib/git/git.ts, requests in
6
+ // web/lib/git/git-actions.ts). This module decides when the tab shows and hands it the run's git state on every redraw of
7
+ // the panel; what the user typed and which confirm is open live in the tab's own store.
8
+
9
+ // Commits only after the final approval, and only on a finished run. `d` is the run's /run reply.
10
+ export const gitShownIn = (c, d) => {
11
+ const g = d && d.git;
12
+ return !!(g && g.repo) && !c.archived && c.accept !== "needs" && (c.status === "done" || c.awaiting === "approvals.review");
13
+ };
14
+ // Something is left to do: the footer points at the tab.
15
+ export const gitPendingIn = (c, d) => {
16
+ if (!gitShownIn(c, d)) return false;
17
+ const g = d.git,
18
+ b = d.branch;
19
+ return (
20
+ g.files.length > 0 ||
21
+ (b
22
+ ? (b.upstream && g.ahead > 0) ||
23
+ (b.pr && b.pr.state === "OPEN") ||
24
+ (b.landed && !b.pr) ||
25
+ (b.pr && b.pr.state === "MERGED")
26
+ : g.ahead > 0)
27
+ );
28
+ };
29
+
30
+ // The panel body (pages/board/panel.tsx) shows this tab while its `body` is git; another tab replaces it.
31
+ export function gitTab(c) {
32
+ const impl = getPanel().runDoc.impl;
33
+ // The panel body shows the tab; the tab's own store holds what is typed in it.
34
+ setPanel({ body: "git" });
35
+ setGit({ snap: {
36
+ card: c,
37
+ git: getPanel().runDoc.git,
38
+ branch: getPanel().runDoc.branch,
39
+ msg: commitMsg(impl) || c.title || c.text || "",
40
+ title: (commitMsg(impl) || c.title || "").split("\n")[0],
41
+ } });
42
+ }
43
+ export const gitLeave = () => setGit({ snap: null });
@@ -0,0 +1,47 @@
1
+ // The Source control tab's React state (Zustand). The old panel code (lib/git/git-panel.ts via git.ts) publishes `snap`
2
+ // on every redraw of the tab. What the user typed and which inline confirm is open live here per run, so a redraw of
3
+ // the panel (which replaces the element the tab stands in) loses nothing.
4
+ import { create } from "zustand";
5
+ import { cardKey, type Card } from "@lib/core";
6
+ import type { BranchDoc, GitDoc } from "./git.ts";
7
+
8
+ export type GitAsk = "pr" | "draft" | "merge" | "remove";
9
+ export type GitUi = { msg?: string; title?: string; body?: string; ask?: GitAsk; shut: Record<string, boolean> };
10
+ export type GitSnap = {
11
+ card: Card;
12
+ git: GitDoc;
13
+ branch: BranchDoc | null;
14
+ msg: string; // the commit message the run's report suggests
15
+ title: string; // and the pull request title
16
+ };
17
+ // A question the tab put to the user and waits on: Discard or Cancel, or the preflight's go-ahead. `ok` answers it.
18
+ export type GitConfirm =
19
+ | { kind: "discard"; run: string | null; path: string; untracked: boolean; many: number; ok: (yes: boolean) => void }
20
+ | {
21
+ kind: "preflight";
22
+ run: string | null;
23
+ pf: { branch?: string; base: string; issues: { what: string; files?: string[] }[]; notes: string[] };
24
+ ok: (yes: boolean) => void;
25
+ };
26
+ export type GitState = {
27
+ snap: GitSnap | null;
28
+ ui: Record<string, GitUi>;
29
+ busy: string | null; // the step or file action running ("commit", "spark", "stage:src/a.ts")...
30
+ busyRun: string | null; // ...for this run (read it through `busyOf`: another run's panel is not busy)
31
+ confirm: GitConfirm | null;
32
+ };
33
+ export const useGit = create<GitState>()(() => ({ snap: null, ui: {}, busy: null, busyRun: null, confirm: null }));
34
+ export const runOf = (s: GitState) => (s.snap ? cardKey(s.snap.card) : null);
35
+ export const busyOf = (s: GitState) => (s.busy && s.busyRun === runOf(s) ? s.busy : null);
36
+ export const getGit = useGit.getState;
37
+ export const setGit = useGit.setState;
38
+ // One shared empty value: a selector that returned a new object each time would never settle.
39
+ const NONE: GitUi = { shut: {} };
40
+ export const gitUi = (k: string): GitUi => getGit().ui[k] ?? NONE;
41
+ export const patchUi = (k: string, p: Partial<GitUi>) =>
42
+ setGit((s) => ({ ui: { ...s.ui, [k]: { ...(s.ui[k] ?? NONE), ...p } } }));
43
+ export const resetUi = (k: string) =>
44
+ setGit((s) => {
45
+ const { [k]: _, ...ui } = s.ui;
46
+ return { ui };
47
+ });