@kabmo-labs/kabmo 0.21.0 → 0.22.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 (295) hide show
  1. package/README.md +7 -2
  2. package/dist/client/index.html +9 -8
  3. package/dist/client/index.js +334 -334
  4. package/dist/client/static/js/{index-zg32n2sk.js → index-297dck9a.js} +784 -791
  5. package/dist/client/static/js/index-7ppta1pb.css +1 -0
  6. package/extensions/kabmo-modes/commands.ts +17 -3
  7. package/extensions/kabmo-modes/goal-start.ts +101 -0
  8. package/extensions/kabmo-modes/goal.test.ts +80 -5
  9. package/extensions/kabmo-modes/goal.ts +13 -38
  10. package/extensions/kabmo-modes/prompts.test.ts +12 -0
  11. package/extensions/kabmo-modes/prompts.ts +9 -2
  12. package/index.html +8 -7
  13. package/package.json +2 -2
  14. package/src/cli/lib/args.js +9 -0
  15. package/src/cli/lib/args.test.js +26 -0
  16. package/src/cli/lib/commands/doctor.js +153 -0
  17. package/src/cli/lib/commands/doctor.test.js +139 -0
  18. package/src/cli/lib/commands/serve.js +23 -10
  19. package/src/cli/lib/commands/status.js +22 -3
  20. package/src/cli/lib/omp-setup.js +131 -0
  21. package/src/cli/lib/omp-setup.test.js +115 -0
  22. package/src/cli/main.js +1 -1
  23. package/src/client/components/common/DemoDataBadge.tsx +52 -0
  24. package/src/client/components/common/FolderPicker.tsx +2 -2
  25. package/src/client/components/common/Modal.tsx +15 -1
  26. package/src/client/components/common/code-surface/blame-panel.ts +1 -1
  27. package/src/client/components/common/context-usage-button/index.test.tsx +1 -1
  28. package/src/client/components/common/context-usage-button/index.tsx +4 -4
  29. package/src/client/components/common/demo-data-badge.test.tsx +58 -0
  30. package/src/client/components/common/diagram-viewer/index.tsx +2 -2
  31. package/src/client/components/common/editor-view-buttons/index.tsx +2 -2
  32. package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
  33. package/src/client/components/common/header-controls/index.tsx +4 -1
  34. package/src/client/components/common/markdown-review/ReviewPopover.tsx +2 -2
  35. package/src/client/components/common/markdown-review/ReviewSummary.tsx +1 -1
  36. package/src/client/components/common/panel-mark/index.tsx +2 -1
  37. package/src/client/components/common/server-control/Panel.tsx +3 -3
  38. package/src/client/components/common/server-control/index.tsx +1 -1
  39. package/src/client/components/common/shell-update-button/Modal.tsx +1 -1
  40. package/src/client/components/common/todo-row/index.tsx +1 -1
  41. package/src/client/components/layout/ActivityBar.tsx +4 -0
  42. package/src/client/components/layout/ShellNotice.tsx +33 -0
  43. package/src/client/components/layout/desktop-layout/index.tsx +14 -16
  44. package/src/client/components/layout/desktop-layout/resizer/index.tsx +14 -1
  45. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +2 -1
  46. package/src/client/components/layout/session-sidebar/ClassicView.tsx +5 -1
  47. package/src/client/components/layout/session-sidebar/SessionList.tsx +1 -1
  48. package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +56 -0
  49. package/src/client/components/layout/session-sidebar/SessionsView.tsx +2 -0
  50. package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +1 -1
  51. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +12 -1
  52. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +2 -1
  53. package/src/client/components/layout/session-sidebar/modern/index.tsx +6 -2
  54. package/src/client/components/layout/session-sidebar/new-workspace-modal/CloneField.tsx +1 -1
  55. package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
  56. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +1 -1
  57. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +3 -3
  58. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +1 -1
  59. package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +150 -0
  60. package/src/client/components/layout/session-sidebar/variant-props.ts +6 -0
  61. package/src/client/components/mobile/LayoutWrapper.tsx +20 -30
  62. package/src/client/components/mobile/MainView.tsx +5 -2
  63. package/src/client/components/mobile/RightSidebar.tsx +1 -1
  64. package/src/client/components/mobile/SessionSidebar.tsx +3 -0
  65. package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
  66. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +7 -1
  67. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
  68. package/src/client/components/settings/Modal.tsx +15 -1
  69. package/src/client/components/settings/ProjectSelectorDropdown.tsx +1 -1
  70. package/src/client/components/settings/Sidebar.tsx +2 -2
  71. package/src/client/components/settings/categories/OmpSettings.tsx +1 -1
  72. package/src/client/components/settings/categories/TokenUsageSettings.tsx +1 -1
  73. package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +3 -3
  74. package/src/client/components/settings/categories/appearance-settings/EditorFontSection.tsx +1 -1
  75. package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +2 -2
  76. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +5 -5
  77. package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +1 -1
  78. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +1 -1
  79. package/src/client/components/settings/categories/appearance-settings/ThemeCard.tsx +1 -1
  80. package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +1 -1
  81. package/src/client/components/settings/categories/chat-settings/GoalSection.tsx +1 -1
  82. package/src/client/components/settings/categories/command-settings/DetailPane.tsx +2 -2
  83. package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +5 -5
  84. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +3 -3
  85. package/src/client/components/settings/categories/omp-settings/RoleRow.tsx +2 -2
  86. package/src/client/components/settings/categories/panel-plugins/LeftDockSettings.tsx +1 -1
  87. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
  88. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +4 -3
  89. package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +2 -2
  90. package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +1 -1
  91. package/src/client/components/settings/categories/project-settings/NameInput.tsx +1 -1
  92. package/src/client/components/settings/categories/project-settings/PathField.tsx +1 -1
  93. package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +3 -3
  94. package/src/client/components/settings/categories/provider-settings/AddProviderModal.tsx +1 -1
  95. package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +2 -2
  96. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +1 -1
  97. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +4 -4
  98. package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +2 -2
  99. package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +1 -1
  100. package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +1 -1
  101. package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +2 -2
  102. package/src/client/components/settings/categories/provider-settings/PriceFields.tsx +1 -1
  103. package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +4 -4
  104. package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +2 -2
  105. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
  106. package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +1 -1
  107. package/src/client/components/settings/categories/usage-settings/KenariCard.tsx +5 -5
  108. package/src/client/components/workspace/browser-panel/AddressBar.tsx +1 -1
  109. package/src/client/components/workspace/browser-panel/Screencast.tsx +6 -6
  110. package/src/client/components/workspace/browser-panel/TabStrip.tsx +1 -1
  111. package/src/client/components/workspace/browser-panel/index.tsx +1 -1
  112. package/src/client/components/workspace/browser-toolbar/index.tsx +5 -5
  113. package/src/client/components/workspace/chat-timeline/AttachmentChips.tsx +1 -1
  114. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.tsx +13 -26
  115. package/src/client/components/workspace/chat-timeline/GoalNotice.tsx +2 -2
  116. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +1 -1
  117. package/src/client/components/workspace/chat-timeline/MinimapShortcuts.tsx +1 -1
  118. package/src/client/components/workspace/chat-timeline/QueueList.tsx +1 -1
  119. package/src/client/components/workspace/chat-timeline/SubagentView.tsx +1 -1
  120. package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +5 -5
  121. package/src/client/components/workspace/chat-timeline/TaskResultContent.tsx +2 -2
  122. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +4 -4
  123. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +1 -1
  124. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
  125. package/src/client/components/workspace/chat-timeline/chat-input/ArmedGoalStrip.tsx +71 -0
  126. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +4 -3
  127. package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +1 -1
  128. package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.tsx +3 -3
  129. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.test.ts +176 -0
  130. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +70 -81
  131. package/src/client/components/workspace/chat-timeline/chat-input/GoalSurfaces.tsx +10 -1
  132. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +20 -0
  133. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +13 -7
  134. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
  135. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +65 -3
  136. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +69 -19
  137. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +2 -2
  138. package/src/client/components/workspace/chat-timeline/chat-input/composer-portal.test.tsx +174 -0
  139. package/src/client/components/workspace/chat-timeline/chat-input/goal-modal-parts.tsx +80 -0
  140. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +15 -3
  141. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +3 -1
  142. package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +1 -1
  143. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
  144. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
  145. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -1
  146. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OptionRow.tsx +1 -1
  147. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.tsx +1 -1
  148. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +2 -2
  149. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionCard.tsx +4 -4
  150. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -2
  151. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/Header.tsx +1 -1
  152. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/SelectBody.tsx +1 -1
  153. package/src/client/components/workspace/chat-timeline/tool-renderers/hashline-patch/index.tsx +4 -4
  154. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AstEdit.tsx +6 -6
  155. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +13 -13
  156. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Checkpoint.tsx +1 -1
  157. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ContextNotes.tsx +2 -2
  158. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Debug.tsx +3 -3
  159. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Edit.tsx +9 -9
  160. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Eval.tsx +10 -10
  161. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/FileMatches.tsx +1 -1
  162. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Goal.tsx +5 -5
  163. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/GoalRecord.tsx +5 -5
  164. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Lsp.tsx +6 -6
  165. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ManageSkill.tsx +5 -5
  166. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.tsx +2 -2
  167. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Memory.tsx +3 -3
  168. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -15
  169. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +2 -2
  170. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Resolve.tsx +4 -4
  171. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchFs.tsx +2 -2
  172. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchTool.tsx +1 -1
  173. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SecurityScan.tsx +4 -4
  174. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/TaskResult.tsx +7 -7
  175. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Think.tsx +2 -2
  176. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Todo.tsx +2 -2
  177. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +4 -2
  178. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +17 -17
  179. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.tsx +3 -3
  180. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +1 -1
  181. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/EnvelopeHeader.tsx +2 -2
  182. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ExcerptCode.tsx +3 -3
  183. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/FallbackOutput.tsx +3 -3
  184. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/JsonCodeBlock.tsx +3 -3
  185. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/OutputWindow.tsx +2 -2
  186. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +2 -2
  187. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolFactChips.tsx +2 -2
  188. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolPanelHeader.tsx +1 -1
  189. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +1 -1
  190. package/src/client/components/workspace/context-panel/RawJsonViewer.tsx +2 -2
  191. package/src/client/components/workspace/context-panel/StatsGrid.tsx +1 -1
  192. package/src/client/components/workspace/context-panel/index.tsx +1 -1
  193. package/src/client/components/workspace/diff-panel/ConflictBanner.tsx +1 -1
  194. package/src/client/components/workspace/editor/EmptyEditor.tsx +1 -1
  195. package/src/client/components/workspace/editor/FindWidget.tsx +1 -1
  196. package/src/client/components/workspace/editor/Tabs.tsx +1 -1
  197. package/src/client/components/workspace/editor/Toolbar.tsx +1 -1
  198. package/src/client/components/workspace/file-explorer/OutlineSection.tsx +2 -2
  199. package/src/client/components/workspace/file-explorer/RowLabel.tsx +1 -1
  200. package/src/client/components/workspace/file-explorer/index.tsx +1 -1
  201. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +2 -2
  202. package/src/client/components/workspace/git-panel/ChangesList.tsx +3 -3
  203. package/src/client/components/workspace/git-panel/ConflictItem.tsx +3 -3
  204. package/src/client/components/workspace/git-panel/FileItem.tsx +2 -2
  205. package/src/client/components/workspace/git-panel/StashSection.tsx +5 -5
  206. package/src/client/components/workspace/git-panel/TreeItem.tsx +2 -2
  207. package/src/client/components/workspace/git-panel/branch-modal/BranchRow.tsx +4 -4
  208. package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -2
  209. package/src/client/components/workspace/git-panel/index.tsx +1 -1
  210. package/src/client/components/workspace/model-dropdown/Item.tsx +3 -3
  211. package/src/client/components/workspace/model-dropdown/Section.tsx +1 -1
  212. package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
  213. package/src/client/components/workspace/plan-panel/index.tsx +2 -2
  214. package/src/client/components/workspace/repo-picker/Modal.tsx +1 -1
  215. package/src/client/components/workspace/repo-picker/Row.tsx +6 -6
  216. package/src/client/components/workspace/search-panel/Body.tsx +2 -2
  217. package/src/client/components/workspace/search-panel/Results.tsx +1 -1
  218. package/src/client/components/workspace/search-panel/index.tsx +1 -1
  219. package/src/client/components/workspace/terminal-panel/index.tsx +1 -1
  220. package/src/client/components/workspace/todo-panel/PhaseGroup.tsx +1 -1
  221. package/src/client/components/workspace/todo-panel/index.tsx +2 -2
  222. package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -5
  223. package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +13 -13
  224. package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +4 -4
  225. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +1 -1
  226. package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +7 -7
  227. package/src/client/components/workspace/user-browser-panel/Frame.tsx +1 -1
  228. package/src/client/components/workspace/wiki-panel/Nav.tsx +1 -1
  229. package/src/client/components/workspace/wiki-panel/index.tsx +2 -2
  230. package/src/client/glass.css +50 -0
  231. package/src/client/glass.test.ts +68 -24
  232. package/src/client/hooks/chat/composer/browser-context.test.ts +6 -6
  233. package/src/client/hooks/chat/composer/use-draft.test.ts +2 -2
  234. package/src/client/hooks/chat/omp/prompt-send.test.ts +36 -0
  235. package/src/client/hooks/chat/omp/prompt-send.ts +24 -18
  236. package/src/client/hooks/chat/omp/session-list.tsx +24 -70
  237. package/src/client/hooks/chat/omp/session-merges.ts +89 -0
  238. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +4 -1
  239. package/src/client/hooks/chat/timeline/armed-goal-send.test.ts +168 -0
  240. package/src/client/hooks/chat/timeline/armed-goal.test.ts +178 -0
  241. package/src/client/hooks/chat/timeline/goal-command.ts +57 -27
  242. package/src/client/hooks/chat/timeline/index.ts +7 -4
  243. package/src/client/hooks/chat/timeline/mode-post.ts +46 -0
  244. package/src/client/hooks/chat/timeline/modes-contract.ts +94 -0
  245. package/src/client/hooks/chat/timeline/modes.ts +60 -95
  246. package/src/client/hooks/chat/timeline/send-props.ts +97 -0
  247. package/src/client/hooks/chat/timeline/send-steer.test.ts +6 -0
  248. package/src/client/hooks/chat/timeline/send.test-util.ts +55 -8
  249. package/src/client/hooks/chat/timeline/send.test.ts +17 -1
  250. package/src/client/hooks/chat/timeline/send.ts +64 -72
  251. package/src/client/hooks/ui/dialog-behaviour.ts +143 -0
  252. package/src/client/hooks/ui/theme.ts +17 -0
  253. package/src/client/hooks/workspace/copy-tab-path.ts +23 -0
  254. package/src/client/hooks/workspace/mobile-back.ts +71 -0
  255. package/src/client/palette-class.test.ts +93 -0
  256. package/src/client/tailwind-contrast.test.ts +194 -0
  257. package/src/client/tailwind.css +327 -8
  258. package/src/server/lib/assets/theme-shell.server.ts +4 -10
  259. package/src/server/lib/omp/config/provider-seeds.test.ts +39 -1
  260. package/src/server/lib/omp/config/provider-seeds.ts +32 -3
  261. package/src/server/lib/omp/config/provider-vision-compat.test.ts +140 -0
  262. package/src/server/lib/omp/core/host-resolution.test.ts +1 -55
  263. package/src/server/lib/omp/core/install-hint.test.ts +48 -0
  264. package/src/server/lib/omp/core/install-hint.ts +64 -0
  265. package/src/server/lib/omp/core/startup.test.ts +125 -0
  266. package/src/server/lib/omp/core/startup.ts +5 -1
  267. package/src/server/lib/omp/mode/request.ts +14 -6
  268. package/src/server/plugins/ssr.ts +2 -1
  269. package/src/shared/lib/browser/annotate.test.ts +22 -22
  270. package/src/shared/lib/browser/annotate.ts +14 -14
  271. package/src/shared/lib/browser/page-context.ts +6 -6
  272. package/src/shared/lib/icons/icon-paint-authority.test.ts +86 -0
  273. package/src/shared/lib/icons/icon-paint-authority.ts +94 -0
  274. package/src/shared/lib/icons/icon-paint-css.test.ts +139 -25
  275. package/src/shared/lib/icons/icon-paint-css.ts +76 -50
  276. package/src/shared/lib/icons/icon-paint-panel.ts +15 -18
  277. package/src/shared/lib/icons/icon-paint-weight.ts +142 -0
  278. package/src/shared/lib/icons/icon-tone.ts +58 -13
  279. package/src/shared/lib/icons/tint-hues.generated.ts +51 -6
  280. package/src/shared/lib/icons/tint-tones.test.ts +257 -0
  281. package/src/shared/lib/icons/tint.test.ts +3 -211
  282. package/src/shared/lib/icons/tint.ts +23 -25
  283. package/src/shared/lib/omp/mode/actions.ts +40 -0
  284. package/src/shared/lib/omp/mode/types.ts +12 -0
  285. package/src/shared/lib/theme/css.ts +21 -0
  286. package/src/shared/lib/theme/first-frame.ts +38 -0
  287. package/src/shared/lib/theme/ink-scale.test.ts +151 -0
  288. package/src/shared/lib/theme/ink-scale.ts +103 -0
  289. package/src/shared/lib/theme/shell-palette.test.ts +22 -5
  290. package/src/shared/lib/theme/shell-palette.ts +9 -4
  291. package/src/shared/lib/theme/theme.test.ts +28 -3
  292. package/src/shared/lib/workspace/project-accent.test.ts +33 -1
  293. package/src/shared/lib/workspace/project-accent.ts +23 -0
  294. package/src/shared/types/omp/agent.ts +24 -9
  295. package/dist/client/static/js/index-0721wrkf.css +0 -1
@@ -19,17 +19,21 @@ import {
19
19
  continueGoalTurn,
20
20
  createGoalFromSelection,
21
21
  finishGoalTurn,
22
+ parseGoalArgs,
22
23
  resetGoalContinuationTurns,
23
24
  startGoalTurn,
25
+ startGuidedGoal,
24
26
  } from './goal';
25
27
  import type { GoalRecord } from './protocol';
26
- import type { ExtensionCtx, ModeApi, ModeSession } from './session';
28
+ import { bindApi, type ExtensionCtx, type ModeApi, type ModeSession } from './session';
27
29
 
28
30
  const MAX_TURNS_ENV = 'KABMO_GOAL_MAX_TURNS';
29
31
 
30
32
  interface Harness {
31
33
  api: ModeApi;
32
34
  ctx: ExtensionCtx;
35
+ /** Visible turns the session was asked to run (`session.prompt`). */
36
+ prompts: string[];
33
37
  sent: Array<{ customType: string; content: string; display?: boolean }>;
34
38
  /** Entries the loop appended (the persisted verdict). */
35
39
  entries: Array<{ customType: string; data: Record<string, unknown> }>;
@@ -44,6 +48,7 @@ interface Harness {
44
48
  }
45
49
 
46
50
  function harness(): Harness {
51
+ const prompts: string[] = [];
47
52
  const sent: Harness['sent'] = [];
48
53
  const entries: Harness['entries'] = [];
49
54
  const markers: Harness['markers'] = [];
@@ -61,6 +66,7 @@ function harness(): Harness {
61
66
  let enabled = true;
62
67
 
63
68
  const session: ModeSession = {
69
+ prompt: async (text: string) => { prompts.push(text); },
64
70
  getGoalModeState: () => ({ goal, enabled }),
65
71
  goalRuntime: {
66
72
  // omp's own shape: `createGoal` answers the new record, which is how the
@@ -86,6 +92,7 @@ function harness(): Harness {
86
92
  return {
87
93
  api,
88
94
  ctx: { cwd: '/tmp/goal-test', ui: { notify: () => {} } },
95
+ prompts,
89
96
  sent,
90
97
  entries,
91
98
  markers,
@@ -228,12 +235,80 @@ describe('finishGoalTurn', () => {
228
235
  });
229
236
 
230
237
  describe('startGoalTurn', () => {
231
- test('the objective is sent as a hidden turn, not as a visible message', () => {
238
+ test('the objective is the first USER turn of the session', async () => {
232
239
  const h = harness();
233
- startGoalTurn(h.api, 'ship it');
240
+ await startGoalTurn(h.session, 'ship it');
234
241
  // `createGoal` writes the record and opens nothing; this is the half that
235
- // makes the goal actually start, and `display: false` is what keeps the
236
- // objective out of the transcript as a second user bubble.
242
+ // makes the goal actually start. It goes through `session.prompt` — the same
243
+ // entry point omp's own `/goal <objective>` uses — so the transcript opens
244
+ // with the operator's objective instead of an answer to nobody. Measured
245
+ // with the hidden form: `custom x8, assistant x3, toolResult x2, user x0`.
246
+ expect(h.prompts).toEqual(['ship it']);
247
+ expect(h.sent).toEqual([]);
248
+ });
249
+
250
+ test('a session that cannot take a prompt still opens a turn', async () => {
251
+ const h = harness();
252
+ // The RPC-side fallback: a build whose session has no `prompt` gets the
253
+ // hidden custom message, which still triggers a turn — it just cannot show
254
+ // the objective. A goal that never runs would be worse than a silent one.
255
+ // The bind is module-level (`bindApi`, called once at extension load), so
256
+ // the harness installs its own api here to observe the fallback.
257
+ bindApi(h.api);
258
+ const withoutPrompt: ModeSession = { ...h.session, prompt: undefined };
259
+ await startGoalTurn(withoutPrompt, 'ship it');
237
260
  expect(h.sent).toEqual([{ customType: 'goal-start', content: 'ship it', display: false }]);
238
261
  });
239
262
  });
263
+
264
+ describe('parseGoalArgs startTurn', () => {
265
+ test('an absent flag means the goal opens its own turn', () => {
266
+ // omp's own `/goal <objective>` behaviour, and the TUI's: the command is the
267
+ // question, so the child opens the turn.
268
+ expect(parseGoalArgs(JSON.stringify({ objective: 'ship it' })).startTurn).toBeUndefined();
269
+ });
270
+
271
+ test('false is carried through, so the operator prompt becomes turn one', () => {
272
+ const parsed = parseGoalArgs(JSON.stringify({ objective: 'ship it', startTurn: false }));
273
+ expect(parsed.startTurn).toBe(false);
274
+ expect(parsed.objective).toBe('ship it');
275
+ });
276
+
277
+ test('any other value is ignored rather than read as false', () => {
278
+ // A truthy string must not silently suppress the opening turn: only the
279
+ // literal false is the armed path.
280
+ expect(parseGoalArgs(JSON.stringify({ objective: 'x', startTurn: 'no' })).startTurn).toBeUndefined();
281
+ expect(parseGoalArgs(JSON.stringify({ objective: 'x', startTurn: true })).startTurn).toBeUndefined();
282
+ });
283
+ });
284
+
285
+ describe('startGuidedGoal', () => {
286
+ test('the operator message is the visible content of turn one', async () => {
287
+ const h = harness();
288
+ await startGuidedGoal(h.session, 'speed up the test suite', '');
289
+
290
+ expect(h.prompts).toHaveLength(1);
291
+ const body = h.prompts[0];
292
+ // The interview template's own slot, fed with what the operator typed — so
293
+ // the transcript opens on their words, not on a question to nobody.
294
+ expect(body).toContain('<rough-goal>');
295
+ expect(body).toContain('speed up the test suite');
296
+ // Nothing hidden was sent: the visible prompt IS the turn.
297
+ expect(h.sent).toEqual([]);
298
+ });
299
+
300
+ test("the modal's rough idea rides along when the message does not carry it", async () => {
301
+ const h = harness();
302
+ await startGuidedGoal(h.session, 'speed up the test suite', 'the slow ones are the route specs');
303
+ expect(h.prompts[0]).toContain('speed up the test suite');
304
+ expect(h.prompts[0]).toContain('the slow ones are the route specs');
305
+ });
306
+
307
+ test('a session that cannot take a prompt falls back to the hidden kickoff', async () => {
308
+ const h = harness();
309
+ bindApi(h.api);
310
+ const withoutPrompt: ModeSession = { ...h.session, prompt: undefined };
311
+ await startGuidedGoal(withoutPrompt, 'speed up the tests', '');
312
+ expect(h.sent.map((entry) => entry.customType)).toEqual(['guided-goal-interview']);
313
+ });
314
+ });
@@ -27,6 +27,9 @@
27
27
 
28
28
  import { GOAL_CONTINUATION_PROMPT, GUIDED_GOAL_INTERVIEW_PROMPT, renderPrompt } from './prompts';
29
29
  import type { ExtensionCtx, ModeApi, ModeSession } from './session';
30
+ import { startGuidedGoal, startGoalTurn } from './goal-start';
31
+
32
+ export { startGuidedGoal, startGoalTurn };
30
33
  import {
31
34
  KABMO_GOAL_CONTINUATION_MARKER,
32
35
  KABMO_GOAL_EVALUATING_MARKER,
@@ -103,16 +106,18 @@ function ceilingFor(goalId: string): number {
103
106
  return goalCeilings.get(goalId) ?? fallback;
104
107
  }
105
108
 
106
- /** Custom-message types, matching the TUI's own naming so a transcript written
107
- * by either surface reads the same. */
109
+ /** The loop's own turn type. The two OPENING types live in `goal-start.ts`,
110
+ * which is what sends them; matching the TUI's naming keeps a transcript
111
+ * written by either surface readable by both. */
108
112
  const GOAL_CONTINUATION_TYPE = 'goal-continuation';
109
- const GUIDED_GOAL_TYPE = 'guided-goal-interview';
110
- /** The opening turn of a goal. Distinct from `goal-continuation` because the
111
- * transcript should read as one started objective, not as a continuation. */
112
- const GOAL_START_TYPE = 'goal-start';
113
113
 
114
114
  interface GoalArgs {
115
115
  objective?: string;
116
+ /** Whether creating the goal should also OPEN its first turn. Omitted means
117
+ * `true` (a goal created by itself, as omp's own `/goal <objective>` does).
118
+ * `false` is the armed path: Kabmo creates the record at the fence of the
119
+ * operator's prompt, and THAT prompt is the goal's first turn. */
120
+ startTurn?: boolean;
116
121
  tokenBudget?: number;
117
122
  guided?: string;
118
123
  /** Automatic-turn ceiling for THIS goal; overrides the install default. */
@@ -141,6 +146,7 @@ export function parseGoalArgs(rest: string): GoalArgs {
141
146
  payload = { objective: trimmed };
142
147
  }
143
148
  const objective = typeof payload.objective === 'string' ? payload.objective.trim() : undefined;
149
+ const startTurn = payload.startTurn === false ? false : undefined;
144
150
  const guided = typeof payload.guided === 'string' ? payload.guided : undefined;
145
151
  // The Kabmo's auditor reports its terminal verdict through `done`; the
146
152
  // reason travels so the strip can name it (and so a reload can too).
@@ -155,7 +161,7 @@ export function parseGoalArgs(rest: string): GoalArgs {
155
161
  const rawMaxTurns = payload.maxTurns;
156
162
  const maxTurns =
157
163
  typeof rawMaxTurns === 'number' && Number.isInteger(rawMaxTurns) && rawMaxTurns > 0 ? rawMaxTurns : undefined;
158
- return { objective, tokenBudget, guided, maxTurns, stopped };
164
+ return { objective, tokenBudget, guided, maxTurns, stopped, startTurn };
159
165
  }
160
166
 
161
167
  /** The record Kabmo mirrors. `enabled` is what decides whether the
@@ -195,37 +201,6 @@ export async function createGoalFromSelection(
195
201
  if (goalId && input.maxTurns !== undefined) goalCeilings.set(goalId, input.maxTurns);
196
202
  }
197
203
 
198
- /**
199
- * The turn that makes a freshly created goal actually start.
200
- *
201
- * `createGoal` only writes the record — it opens no turn, so a goal created
202
- * here sat live with an idle child until the operator happened to send
203
- * something else, which is not "keeps working across turns". omp's own
204
- * `/goal <objective>` path does both (`#zs`: `#Tn({objective})` then a prompt
205
- * with the objective as text), and this is that second half.
206
- *
207
- * Sent as a hidden custom message rather than through the RPC prompt path: the
208
- * Kabmo cannot reach the live session's prompt, and `display: false` is what
209
- * keeps the objective out of the transcript as a second user bubble.
210
- */
211
- export function startGoalTurn(api: ModeApi, objective: string): void {
212
- api.sendMessage?.({ customType: GOAL_START_TYPE, content: objective, display: false }, { triggerTurn: true });
213
- }
214
-
215
- /**
216
- * Start the guided-goal interview.
217
- *
218
- * A normal conversation with a hidden kickoff: the agent asks its questions as
219
- * ordinary assistant turns, the operator answers in the composer, and the model
220
- * closes by calling `goal({op:"create"})` itself — which flips goal mode on
221
- * through `goal_updated`. The `goal` tool must already be active, which is what
222
- * the caller's `ensureGoalTool` provides.
223
- */
224
- export function startGuidedGoal(api: ModeApi, rough: string): void {
225
- const content = renderPrompt(GUIDED_GOAL_INTERVIEW_PROMPT, { initial: rough || undefined });
226
- api.sendMessage?.({ customType: GUIDED_GOAL_TYPE, content, display: false }, { triggerTurn: true });
227
- }
228
-
229
204
  /**
230
205
  * The loop's per-session counters, kept where the other process-wide state is:
231
206
  * a `bun --hot` reload must not lose the turn count, and the ceiling is the only
@@ -67,4 +67,16 @@ describe('renderPrompt', () => {
67
67
  const rendered = renderPrompt('{{#if y}}YES {{z}}{{/if}}', { y: true });
68
68
  expect(rendered).toBe('YES {{z}}');
69
69
  });
70
+
71
+ test('an {{else}} branch replaces the block instead of surviving in it', () => {
72
+ // The guided interview template uses this shape. A renderer that ignored
73
+ // `{{else}}` left BOTH branches in the prompt — measured on a real session,
74
+ // where the kickoff carried the literal `{{else}}` and told the model to ask
75
+ // for an objective it had just been given.
76
+ const template = '{{#if initial}}HAVE {{initial}}{{else}}ASK{{/if}}';
77
+
78
+ expect(renderPrompt(template, { initial: 'speed up the tests' })).toBe('HAVE speed up the tests');
79
+ expect(renderPrompt(template, {})).toBe('ASK');
80
+ expect(renderPrompt(template, { initial: 'x' })).not.toContain('{{else}}');
81
+ });
70
82
  });
@@ -156,8 +156,15 @@ export function renderPrompt(
156
156
  template: string,
157
157
  values: Record<string, string | number | boolean | undefined>,
158
158
  ): string {
159
- let out = template.replace(/\{\{#if\s+(\w+)\}\}([\s\S]*?)\{\{\/if\}\}/g, (_match, key: string, body: string) =>
160
- values[key] ? body : '',
159
+ // `{{#if}}` blocks carry an optional `{{else}}`. omp's own templates use it
160
+ // (the interview's "No objective stated" branch), and a renderer that ignored
161
+ // it left BOTH branches in the prompt — measured on a real session, where the
162
+ // kickoff contained the literal `{{else}}` and told the model to ask a
163
+ // question it had already been given the answer to.
164
+ let out = template.replace(
165
+ /\{\{#if\s+(\w+)\}\}([\s\S]*?)(?:\{\{else\}\}([\s\S]*?))?\{\{\/if\}\}/g,
166
+ (_match, key: string, whenTrue: string, whenFalse: string | undefined) =>
167
+ (values[key] ? whenTrue : (whenFalse ?? '')),
161
168
  );
162
169
  out = out.replace(/\{\{(\w+)\}\}/g, (match, key: string) => {
163
170
  const value = values[key];
package/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <meta name="apple-mobile-web-app-title" content="Kabmo" />
13
13
  <meta
14
14
  name="description"
15
- content="A light e-ink paper developer dashboard for AI Oh-My-Pi agent sessions — a web console for CI/CD deployments."
15
+ content="Web console and diagnostic workbench for Oh-My-Pi agent sessions: watch, steer and audit autonomous coding runs from one paper-flat dashboard."
16
16
  />
17
17
  <title>Kabmo</title>
18
18
  <!-- Inline and in the head on purpose: this has to be registered BEFORE the
@@ -57,12 +57,13 @@
57
57
  <link rel="icon" type="image/svg+xml" href="./public/icon.svg" sizes="any" />
58
58
  <link rel="icon" type="image/png" href="./public/icon-192x192.png" sizes="192x192" />
59
59
  <link rel="apple-touch-icon" href="./public/apple-touch-icon.png" />
60
- <link rel="preconnect" href="https://fonts.googleapis.com" />
61
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
62
- <link
63
- rel="stylesheet"
64
- href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap"
65
- />
60
+ <!-- No webfont from a third party. This block used to load Inter from
61
+ `fonts.googleapis.com` — a render-blocking request in `<head>` for a
62
+ family no stylesheet in the app ever named, so the browser paid a
63
+ round-trip to a third party and drew nothing with it. The UI stack is
64
+ the system face (`tailwind.css` → `body`), and the mono face is bundled
65
+ by `scripts/build-client.ts`. A page that ships an external font must
66
+ name it somewhere; this one did not. -->
66
67
  <!--app-head-->
67
68
  </head>
68
69
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kabmo-labs/kabmo",
3
- "version": "0.21.0",
4
- "description": "Web console and diagnostic workbench for AI coding agents — Elysia + Preact on Bun.",
3
+ "version": "0.22.0",
4
+ "description": "Web console and diagnostic workbench for AI coding agents: Elysia + Preact on Bun.",
5
5
  "license": "MIT",
6
6
  "author": "Wijanarko Putra Rajeb <wijanarko.rajeb@gmail.com>",
7
7
  "type": "module",
@@ -5,6 +5,8 @@
5
5
  * to a stream. Callers decide how to react to `unknown` flags.
6
6
  */
7
7
 
8
+ import { ompInstallHintLines } from '@/server/lib/omp/core/install-hint';
9
+
8
10
  const BOOLEAN_LONG = new Set([
9
11
  'lan',
10
12
  'dev',
@@ -221,10 +223,17 @@ COMMANDS:
221
223
  stop Stop the instances the CLI started (--port/--all to stop any)
222
224
  restart Stop and start again (every CLI-started instance, or --port <port>)
223
225
  status Show running instances (every one, or --port <port>)
226
+ doctor Diagnose this install: omp binary, versions, update source
224
227
  logs Print or follow server logs (every instance, or --port <port>)
225
228
  plugin Build, type, scaffold or list panel plugins
226
229
  (build|types|new|list; see "${bin} plugin --help")
227
230
 
231
+ REQUIRED: oh-my-pi (\`omp\`)
232
+ Kabmo drives your existing omp binary; it never installs one for you.
233
+ \`serve\` refuses to start until \`omp\` resolves (MOCK=true is the only
234
+ exception). Check this install with: ${bin} doctor
235
+ ${ompInstallHintLines(' ').join('\n')}
236
+
228
237
  OPTIONS:
229
238
  -p, --port <port> Web server port (default: 3000); scopes status/stop/restart/logs
230
239
  --host <address> Bind address (default: 127.0.0.1)
@@ -56,6 +56,32 @@ describe('helpText', () => {
56
56
  // The environment names are not the command name and must not be rewritten.
57
57
  expect(helpText('kabmo')).toContain('KABMO_DATA_DIR');
58
58
  });
59
+
60
+ // `--help` is where a user looks before running anything, and it used to
61
+ // mention omp only as an environment variable — so "why will this not start"
62
+ // had no answer anywhere in the output.
63
+ test('states the omp prerequisite and both install commands', () => {
64
+ const text = helpText('kabmo');
65
+ expect(text).toContain('REQUIRED: oh-my-pi');
66
+ expect(text).toContain('bun install -g @oh-my-pi/pi-coding-agent');
67
+ expect(text).toContain('https://omp.sh/install');
68
+ expect(text).toContain('kabmo doctor');
69
+ });
70
+
71
+ // The block arrived as an array interpolated into a template literal, which
72
+ // joins with commas — `bun install -g …, or: curl …`. The lines are
73
+ // asserted individually here so a caller that forgets `.join('\n')` fails.
74
+ test('the install block renders as separate lines, not one comma-joined row', () => {
75
+ const text = helpText('kabmo');
76
+ const lines = text.split('\n');
77
+ expect(lines.filter((line) => line.includes('install omp:')).length).toBe(1);
78
+ expect(lines.filter((line) => line.includes('or: curl -fsSL')).length).toBe(1);
79
+ expect(text).not.toContain('pi-coding-agent,');
80
+ });
81
+
82
+ test('lists the doctor command', () => {
83
+ expect(helpText('kabmo')).toContain('doctor Diagnose this install');
84
+ });
59
85
  });
60
86
 
61
87
  describe('--ui-password-file', () => {
@@ -0,0 +1,153 @@
1
+ // `kabmo doctor` — diagnose this install without changing anything.
2
+ //
3
+ // Read-only by construction: it resolves paths, asks `omp --version`, reads one
4
+ // npm document and lists live instances. It never opens the database (opening
5
+ // CREATES the file), never spawns a server and never writes a login entry.
6
+ //
7
+ // The command exists because the failure it explains is otherwise invisible:
8
+ // Kabmo refuses to start without an `omp` binary, and before this the only
9
+ // diagnostics were a one-paragraph refusal and `status`, which says nothing
10
+ // about omp at all.
11
+
12
+ import { existsSync } from 'node:fs';
13
+ import { join } from 'node:path';
14
+
15
+ import { color, formatTable, isJson, log, printJson } from '@/cli/lib/output.js';
16
+ import { listLiveInstances, resolveBunBin } from '@/cli/lib/runtime.js';
17
+ import { resolveOmpBin } from '@/server/lib/omp/core/cli';
18
+ import { ompInstallCommands } from '@/server/lib/omp/core/install-hint';
19
+ import { getAgentDir, getConfigRoot } from '@/server/lib/omp/core/paths';
20
+ import { isMockMode } from '@/server/mock.server';
21
+ import { getDataDir } from '@/server/lib/lifecycle/paths';
22
+ import { checkOmpUpdate } from '@/server/lib/updates/omp';
23
+ import { resolveInstallContext, resolveKabmoVersion } from '@/server/lib/updates/install';
24
+
25
+ /** A path plus a dim note when it is not usable, so the report never implies a file exists. */
26
+ function presence(target) {
27
+ try {
28
+ return existsSync(target) ? target : `${target} ${color.dim('(missing)')}`;
29
+ } catch {
30
+ return `${target} ${color.dim('(unreadable)')}`;
31
+ }
32
+ }
33
+
34
+ function bunVersion(bin) {
35
+ if (!bin) return null;
36
+ try {
37
+ const proc = Bun.spawnSync({ cmd: [bin, '--version'], stdin: 'ignore', stdout: 'pipe', stderr: 'pipe', timeout: 15_000 });
38
+ return proc.exitCode === 0 ? proc.stdout.toString().trim() : null;
39
+ } catch {
40
+ return null;
41
+ }
42
+ }
43
+
44
+ /** `resolveBunBin` throws when nothing answers `bun --version`; doctor reports that. */
45
+ function resolveBunOrNull() {
46
+ try {
47
+ return resolveBunBin();
48
+ } catch {
49
+ return null;
50
+ }
51
+ }
52
+
53
+ function formatInstances(instances) {
54
+ if (instances.length === 0) return 'none running';
55
+ const ports = instances.map((entry) => entry.port).join(', ');
56
+ return `${instances.length} running (port ${ports})`;
57
+ }
58
+
59
+ /** Every fact the report prints, so `--json` and the human table cannot disagree. */
60
+ export async function collectReport({ pkgRoot = process.cwd(), instances = null } = {}) {
61
+ const bin = resolveOmpBin();
62
+ const omp = await checkOmpUpdate();
63
+ const kabmo = await resolveKabmoVersion(pkgRoot);
64
+ const install = resolveInstallContext(pkgRoot);
65
+ const bun = resolveBunOrNull();
66
+ const live = instances ?? await listLiveInstances().catch(() => []);
67
+ const dataDir = getDataDir();
68
+
69
+ return {
70
+ kabmo: {
71
+ version: kabmo.current,
72
+ latest: kabmo.latest,
73
+ updateAvailable: kabmo.updateAvailable,
74
+ package: install.pkgRoot,
75
+ installMethod: install.method,
76
+ reason: install.reason,
77
+ },
78
+ bun: { bin: bun, version: bunVersion(bun) },
79
+ omp: {
80
+ bin,
81
+ installed: omp.installed,
82
+ version: omp.current,
83
+ latest: omp.latest,
84
+ updateAvailable: omp.updateAvailable,
85
+ error: omp.error,
86
+ configDir: getConfigRoot(),
87
+ agentDir: getAgentDir(),
88
+ },
89
+ data: { dir: presence(dataDir), database: presence(join(dataDir, 'db.sqlite')) },
90
+ mock: isMockMode(),
91
+ instances: live.map((entry) => ({ port: entry.port, pid: entry.pid, mode: entry.mode ?? null })),
92
+ };
93
+ }
94
+
95
+ /**
96
+ * Exit code: 1 only when Kabmo genuinely cannot run — no resolvable binary, or
97
+ * a binary whose version cannot be read. A registry outage and a missing demo
98
+ * database are notes, not failures; treating them as failures would make
99
+ * `doctor` red on a healthy air-gapped install.
100
+ */
101
+ export function exitCodeFor(report) {
102
+ if (report.mock) return 0;
103
+ if (!report.omp.bin) return 1;
104
+ return report.omp.version ? 0 : 1;
105
+ }
106
+
107
+ function printHuman(report) {
108
+ const rows = [
109
+ ['kabmo', `${report.kabmo.version ?? 'unknown'}${report.kabmo.updateAvailable ? color.yellow(` (${report.kabmo.latest} available)`) : ''}`],
110
+ [' package', report.kabmo.package],
111
+ [' install', `${report.kabmo.installMethod} — ${report.kabmo.reason}`],
112
+ ['bun', `${report.bun.version ?? 'unknown'} (${report.bun.bin})`],
113
+ ['omp', report.omp.bin ?? color.red('not found')],
114
+ [' version', report.omp.version ?? color.red(report.omp.error ?? 'unknown')],
115
+ ];
116
+ if (report.omp.installed && report.omp.latest) {
117
+ rows.push([' latest', `${report.omp.latest}${report.omp.updateAvailable ? color.yellow(' (update available)') : ''}`]);
118
+ }
119
+ rows.push(
120
+ [' config', report.omp.configDir],
121
+ [' agent', report.omp.agentDir],
122
+ ['data', report.data.dir],
123
+ [' database', report.data.database],
124
+ ['mode', report.mock ? 'mock (demo presets)' : 'live (real omp data)'],
125
+ ['instances', formatInstances(report.instances)],
126
+ );
127
+ log(formatTable(rows));
128
+ }
129
+
130
+ function printRemedy() {
131
+ const { source, binary } = ompInstallCommands();
132
+ log('');
133
+ log('Kabmo needs your own `omp` binary — it does not install one for you.');
134
+ log(` bun: ${source}`);
135
+ log(` or: ${binary}`);
136
+ log('Then check again: kabmo doctor');
137
+ }
138
+
139
+ export async function run(options, ctx) {
140
+ const pkgRoot = ctx?.pkgRoot ?? process.cwd();
141
+ const report = await collectReport({ pkgRoot });
142
+
143
+ if (isJson()) {
144
+ printJson(report);
145
+ if (exitCodeFor(report) !== 0) process.exitCode = 1;
146
+ return;
147
+ }
148
+
149
+ printHuman(report);
150
+ if (!report.omp.bin) printRemedy();
151
+ if (report.omp.error && report.omp.bin) log(color.red(`omp: ${report.omp.error}`));
152
+ if (exitCodeFor(report) !== 0) process.exitCode = 1;
153
+ }
@@ -0,0 +1,139 @@
1
+ // `kabmo doctor`'s report, and the exit code that decides whether CI breaks.
2
+ //
3
+ // The interesting decisions are not the table: they are which facts are read
4
+ // from the running install rather than guessed, and what counts as a FAILURE.
5
+ // A registry outage or an unwritten database must not make `doctor` red, while
6
+ // a missing binary must — otherwise the one command whose job is to explain a
7
+ // refusal would itself be unreadable.
8
+ //
9
+ // The omp binary is a real script in a temp directory (that is what
10
+ // `resolveOmpBin` probes and `omp --version` parses), and the registry is a
11
+ // stubbed `fetch`, so nothing here touches the network or the developer's omp.
12
+
13
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
14
+ import { chmodSync, mkdtempSync, writeFileSync } from 'node:fs';
15
+ import { tmpdir } from 'node:os';
16
+ import { join } from 'node:path';
17
+
18
+ import { collectReport, exitCodeFor } from '@/cli/lib/commands/doctor.js';
19
+ import { invalidateOmpCliCache } from '@/server/lib/omp/core/cli';
20
+ import { testPosix } from '@/test-support/platform';
21
+
22
+ const originalFetch = Bun.fetch;
23
+ const realEnv = {
24
+ KABMO_OMP_BIN: Bun.env.KABMO_OMP_BIN,
25
+ MOCK: Bun.env.MOCK,
26
+ KABMO_DATA_DIR: Bun.env.KABMO_DATA_DIR,
27
+ PI_CONFIG_DIR: Bun.env.PI_CONFIG_DIR,
28
+ PI_CODING_AGENT_DIR: Bun.env.PI_CODING_AGENT_DIR,
29
+ };
30
+
31
+ /** A runnable `omp` that names itself the way the real one does. */
32
+ function fakeOmp(version = '18.16.0') {
33
+ const dir = mkdtempSync(join(tmpdir(), 'kabmo-doctor-'));
34
+ const path = join(dir, 'omp');
35
+ writeFileSync(path, `#!/bin/sh\necho "omp/${version}"\n`);
36
+ chmodSync(path, 0o755);
37
+ return path;
38
+ }
39
+
40
+ function stubRegistry(version = '18.16.0', status = 200) {
41
+ globalThis.fetch = async () => new Response(JSON.stringify({ version }), {
42
+ status,
43
+ headers: { 'content-type': 'application/json' },
44
+ });
45
+ }
46
+
47
+ beforeEach(() => {
48
+ Bun.env.KABMO_DATA_DIR = mkdtempSync(join(tmpdir(), 'kabmo-doctor-data-'));
49
+ Bun.env.MOCK = 'false';
50
+ invalidateOmpCliCache();
51
+ stubRegistry();
52
+ });
53
+
54
+ afterEach(() => {
55
+ globalThis.fetch = originalFetch;
56
+ for (const [key, value] of Object.entries(realEnv)) {
57
+ if (value === undefined) delete Bun.env[key];
58
+ else Bun.env[key] = value;
59
+ }
60
+ invalidateOmpCliCache();
61
+ });
62
+
63
+ describe('collectReport', () => {
64
+ // POSIX only, because the assertion is `omp --version` being RUN: `fakeOmp`
65
+ // writes a `#!/bin/sh` script, and Windows cannot start one — `CreateProcess`
66
+ // needs a real executable, so the version came back null on the Windows gate
67
+ // while every other case here passed (they only need the PATH to resolve).
68
+ testPosix('reports the resolved binary and the version it names itself', async () => {
69
+ Bun.env.KABMO_OMP_BIN = fakeOmp('18.20.1');
70
+ const report = await collectReport({ instances: [] });
71
+ expect(report.omp.installed).toBe(true);
72
+ expect(report.omp.bin).toBe(Bun.env.KABMO_OMP_BIN);
73
+ expect(report.omp.version).toBe('18.20.1');
74
+ expect(report.omp.error).toBeNull();
75
+ });
76
+
77
+ test('a missing binary is reported as absent, not as an empty version', async () => {
78
+ Bun.env.KABMO_OMP_BIN = join(mkdtempSync(join(tmpdir(), 'kabmo-doctor-miss-')), 'omp');
79
+ const report = await collectReport({ instances: [] });
80
+ expect(report.omp.bin).toBeNull();
81
+ expect(report.omp.installed).toBe(false);
82
+ expect(report.omp.error).toBe('omp binary not found');
83
+ });
84
+
85
+ test('the data directory is the one this process resolves, marked when absent', async () => {
86
+ Bun.env.KABMO_OMP_BIN = fakeOmp();
87
+ const report = await collectReport({ instances: [] });
88
+ expect(report.data.dir).toBe(Bun.env.KABMO_DATA_DIR);
89
+ // Nothing has opened the database, so it cannot exist yet — and doctor must
90
+ // not create it (opening a handle CREATES the file).
91
+ expect(report.data.database).toContain('(missing)');
92
+ });
93
+
94
+ test('the install method comes from the path this copy runs out of', async () => {
95
+ Bun.env.KABMO_OMP_BIN = fakeOmp();
96
+ const report = await collectReport({ pkgRoot: process.cwd(), instances: [] });
97
+ // This suite runs from the repository checkout.
98
+ expect(report.kabmo.installMethod).toBe('git');
99
+ expect(report.kabmo.package).toBe(process.cwd());
100
+ });
101
+
102
+ test('instances are reported, not probed', async () => {
103
+ Bun.env.KABMO_OMP_BIN = fakeOmp();
104
+ const report = await collectReport({ instances: [{ port: 3000, pid: 42, mode: 'prod' }] });
105
+ expect(report.instances).toEqual([{ port: 3000, pid: 42, mode: 'prod' }]);
106
+ });
107
+ });
108
+
109
+ describe('exitCodeFor', () => {
110
+ const base = {
111
+ mock: false,
112
+ omp: { bin: '/usr/local/bin/omp', version: '18.16.0' },
113
+ kabmo: { error: null },
114
+ };
115
+
116
+ test('a resolvable, readable binary is healthy', () => {
117
+ expect(exitCodeFor(base)).toBe(0);
118
+ });
119
+
120
+ test('a missing binary fails', () => {
121
+ expect(exitCodeFor({ ...base, omp: { bin: null, version: null } })).toBe(1);
122
+ });
123
+
124
+ test('a binary whose version cannot be read fails', () => {
125
+ expect(exitCodeFor({ ...base, omp: { bin: '/usr/local/bin/omp', version: null } })).toBe(1);
126
+ });
127
+
128
+ // MOCK mode exists precisely to run without omp, so the gate that refuses to
129
+ // start is disabled there and this must agree with it.
130
+ test('mock mode is healthy without a binary', () => {
131
+ expect(exitCodeFor({ ...base, mock: true, omp: { bin: null, version: null } })).toBe(0);
132
+ });
133
+
134
+ // A registry outage leaves `latest: null`; that is a note, not a failure —
135
+ // an air-gapped install is still a working install.
136
+ test('an unreadable registry is not a failure', () => {
137
+ expect(exitCodeFor({ ...base, kabmo: { error: 'No Kabmo release could be resolved' } })).toBe(0);
138
+ });
139
+ });