@kabmo-labs/kabmo 0.17.0 → 0.19.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 (438) hide show
  1. package/README.md +10 -7
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +523 -441
  4. package/dist/client/static/js/{index-rerjq5th.js → index-fcee4c13.js} +828 -818
  5. package/dist/client/static/js/index-sxdw908m.css +1 -0
  6. package/marketplace/plugins/command-runner/package.json +3 -2
  7. package/marketplace/plugins/git-forge/package.json +3 -2
  8. package/marketplace/plugins/session-info/package.json +3 -2
  9. package/marketplace/plugins/stats/package.json +3 -2
  10. package/package.json +3 -1
  11. package/src/client/components/auth/login-screen/index.tsx +2 -1
  12. package/src/client/components/common/ComposerPicker.tsx +1 -1
  13. package/src/client/components/common/FolderPicker.tsx +2 -2
  14. package/src/client/components/common/MarkdownRenderer.tsx +136 -89
  15. package/src/client/components/common/Modal.tsx +2 -2
  16. package/src/client/components/common/PWAInstallButton.tsx +2 -2
  17. package/src/client/components/common/ViewportSelector.tsx +1 -1
  18. package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
  19. package/src/client/components/common/anchored-menu/index.tsx +147 -0
  20. package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
  21. package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
  22. package/src/client/components/common/brand-wordmark/index.tsx +13 -2
  23. package/src/client/components/common/checkbox/style.test.ts +139 -0
  24. package/src/client/components/common/checkbox/style.ts +51 -0
  25. package/src/client/components/common/context-usage-button/index.tsx +2 -2
  26. package/src/client/components/common/file-icon/index.tsx +23 -9
  27. package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
  28. package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
  29. package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
  30. package/src/client/components/common/markdown-review/index.tsx +129 -0
  31. package/src/client/components/common/panel-mark/index.tsx +97 -0
  32. package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
  33. package/src/client/components/common/provider-icon/index.test.ts +14 -0
  34. package/src/client/components/common/provider-icon/index.tsx +4 -0
  35. package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
  36. package/src/client/components/common/provider-icon/resolve.ts +16 -3
  37. package/src/client/components/common/server-control/Panel.tsx +33 -23
  38. package/src/client/components/common/server-control/index.test.tsx +11 -5
  39. package/src/client/components/common/server-control/index.tsx +10 -8
  40. package/src/client/components/common/session-actions-menu/index.tsx +1 -1
  41. package/src/client/components/common/toolbar-row/index.tsx +1 -1
  42. package/src/client/components/layout/ActivityBar.tsx +22 -3
  43. package/src/client/components/layout/LeftDock.tsx +9 -2
  44. package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
  45. package/src/client/components/layout/WindowAura.tsx +27 -0
  46. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
  47. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
  48. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
  49. package/src/client/components/layout/desktop-layout/index.tsx +3 -1
  50. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +44 -23
  51. package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
  52. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
  53. package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
  54. package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
  55. package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
  56. package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
  57. package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
  58. package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
  59. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
  60. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
  61. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +40 -14
  62. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
  63. package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
  64. package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
  65. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
  66. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
  67. package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
  68. package/src/client/components/layout/update-popup/index.tsx +5 -1
  69. package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
  70. package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
  71. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
  72. package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
  73. package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
  74. package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
  75. package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
  76. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
  77. package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
  78. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
  79. package/src/client/components/mobile/panel-chips.tsx +10 -2
  80. package/src/client/components/settings/Modal.tsx +4 -4
  81. package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
  82. package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
  83. package/src/client/components/settings/apply-side-effects.test.ts +30 -0
  84. package/src/client/components/settings/apply-side-effects.ts +14 -0
  85. package/src/client/components/settings/categories/AgentSettings.tsx +23 -50
  86. package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
  87. package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
  88. package/src/client/components/settings/categories/McpSettings.tsx +4 -21
  89. package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
  90. package/src/client/components/settings/categories/SkillSettings.tsx +2 -2
  91. package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
  92. package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
  93. package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
  94. package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +9 -2
  95. package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
  96. package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
  97. package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
  98. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
  99. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
  100. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
  101. package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
  102. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
  103. package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
  104. package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
  105. package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +93 -77
  106. package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
  107. package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +28 -15
  108. package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
  109. package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
  110. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
  111. package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
  112. package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
  113. package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
  114. package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
  115. package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
  116. package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
  117. package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
  118. package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
  119. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
  120. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
  121. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
  122. package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
  123. package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
  124. package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
  125. package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
  126. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
  127. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
  128. package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
  129. package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
  130. package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +37 -8
  131. package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +34 -14
  132. package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +21 -0
  133. package/src/client/components/settings/categories/skill-settings/pane.test.tsx +15 -6
  134. package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
  135. package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
  136. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
  137. package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
  138. package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
  139. package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
  140. package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
  141. package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
  142. package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
  143. package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
  144. package/src/client/components/workspace/browser-panel/index.tsx +50 -4
  145. package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
  146. package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
  147. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
  148. package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
  149. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
  150. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
  151. package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
  152. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
  153. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
  154. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
  155. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
  156. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
  157. package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
  158. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
  159. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
  160. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
  161. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
  162. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
  163. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
  164. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
  165. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
  166. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
  167. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
  168. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
  169. package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
  170. package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
  171. package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
  172. package/src/client/components/workspace/diff-panel/changes.ts +28 -12
  173. package/src/client/components/workspace/diff-panel/index.tsx +2 -2
  174. package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
  175. package/src/client/components/workspace/diff-panel/merge.ts +21 -1
  176. package/src/client/components/workspace/editor/Body.tsx +7 -0
  177. package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
  178. package/src/client/components/workspace/editor/FilePane.tsx +12 -0
  179. package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
  180. package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
  181. package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
  182. package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
  183. package/src/client/components/workspace/editor/Tabs.tsx +1 -1
  184. package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
  185. package/src/client/components/workspace/editor/index.tsx +25 -22
  186. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
  187. package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
  188. package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
  189. package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
  190. package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
  191. package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
  192. package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
  193. package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
  194. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
  195. package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
  196. package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
  197. package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
  198. package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
  199. package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
  200. package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
  201. package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
  202. package/src/client/components/workspace/git-panel/index.tsx +7 -0
  203. package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
  204. package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
  205. package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
  206. package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
  207. package/src/client/components/workspace/search-panel/Body.tsx +1 -1
  208. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
  209. package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
  210. package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
  211. package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
  212. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
  213. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
  214. package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
  215. package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
  216. package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
  217. package/src/client/data/agent-data/builtin.ts +0 -10
  218. package/src/client/data/agent-data/orchestrator.ts +0 -45
  219. package/src/client/data/agent-data/specialist.ts +0 -100
  220. package/src/client/data/mock/token-usage.ts +170 -120
  221. package/src/client/data/settings/omp-schema.json +33 -1
  222. package/src/client/glass.css +785 -0
  223. package/src/client/glass.test.ts +346 -0
  224. package/src/client/hooks/browser/use-annotate.test.ts +143 -0
  225. package/src/client/hooks/browser/use-annotate.ts +98 -0
  226. package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
  227. package/src/client/hooks/browser/use-close-tab.ts +67 -0
  228. package/src/client/hooks/browser/use-screencast.ts +13 -1
  229. package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
  230. package/src/client/hooks/chat/composer/browser-context.ts +40 -16
  231. package/src/client/hooks/chat/composer/items.test.ts +1 -1
  232. package/src/client/hooks/chat/composer/review-context.ts +38 -0
  233. package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
  234. package/src/client/hooks/chat/composer/use-draft.ts +31 -2
  235. package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
  236. package/src/client/hooks/editor/use-document-annotations.ts +124 -0
  237. package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
  238. package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
  239. package/src/client/hooks/editor/use-preview-review.ts +148 -0
  240. package/src/client/hooks/settings/agents.ts +149 -0
  241. package/src/client/hooks/settings/crud-list.test.ts +28 -6
  242. package/src/client/hooks/settings/crud-list.ts +96 -57
  243. package/src/client/hooks/settings/omp-config.ts +164 -0
  244. package/src/client/hooks/settings/useTokenUsage.ts +125 -0
  245. package/src/client/hooks/settings/write-feedback.test.ts +104 -0
  246. package/src/client/hooks/settings/write-feedback.ts +63 -0
  247. package/src/client/hooks/ui/glass-support.ts +57 -0
  248. package/src/client/hooks/ui/icon-style.ts +59 -0
  249. package/src/client/hooks/ui/markdown-hydration.ts +125 -0
  250. package/src/client/hooks/ui/stuck-header.test.ts +188 -0
  251. package/src/client/hooks/ui/stuck-header.ts +91 -0
  252. package/src/client/hooks/ui/style-attributes.test.ts +120 -0
  253. package/src/client/hooks/ui/surface-style.ts +56 -0
  254. package/src/client/hooks/ui/updates/index.test.ts +100 -1
  255. package/src/client/hooks/ui/updates/index.ts +50 -0
  256. package/src/client/hooks/ui/updates/notes.test.ts +138 -0
  257. package/src/client/hooks/ui/updates/notes.ts +57 -0
  258. package/src/client/hooks/workspace/panel-hues.ts +23 -0
  259. package/src/client/lib/browser/element-at.test.ts +229 -0
  260. package/src/client/lib/browser/element-at.ts +139 -0
  261. package/src/client/lib/review/client.ts +73 -0
  262. package/src/client/lib/router/search-params.ts +42 -20
  263. package/src/client/main.tsx +10 -0
  264. package/src/client/tailwind.css +329 -11
  265. package/src/server/lib/assets/shell-attributes.server.ts +80 -0
  266. package/src/server/lib/assets/shell-attributes.test.ts +86 -0
  267. package/src/server/lib/btw/lifecycle.server.ts +2 -2
  268. package/src/server/lib/db/schema.ts +7 -0
  269. package/src/server/lib/db/seed-terminal.test.ts +4 -0
  270. package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
  271. package/src/server/lib/omp/config/agents.ts +231 -61
  272. package/src/server/lib/omp/config/definitions.test.ts +9 -105
  273. package/src/server/lib/omp/config/extensions.ts +16 -7
  274. package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
  275. package/src/server/lib/omp/rpc/constants.test.ts +11 -0
  276. package/src/server/lib/omp/rpc/constants.ts +15 -0
  277. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
  278. package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
  279. package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
  280. package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
  281. package/src/server/lib/omp/rpc/manager.ts +2 -2
  282. package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
  283. package/src/server/lib/omp/rpc/process.test.ts +106 -0
  284. package/src/server/lib/omp/rpc/process.ts +39 -18
  285. package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
  286. package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
  287. package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
  288. package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
  289. package/src/server/lib/omp/rpc/session-commands.ts +17 -3
  290. package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
  291. package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
  292. package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
  293. package/src/server/lib/omp/rpc/utility.ts +12 -0
  294. package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
  295. package/src/server/lib/panels/manifest.test.ts +20 -0
  296. package/src/server/lib/panels/manifest.ts +12 -0
  297. package/src/server/lib/panels/scan.server.ts +4 -0
  298. package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
  299. package/src/server/lib/queue/delivery-harness.ts +8 -4
  300. package/src/server/lib/queue/delivery.server.test.ts +29 -0
  301. package/src/server/lib/queue/delivery.server.ts +39 -0
  302. package/src/server/lib/queue/store.server.test.ts +22 -2
  303. package/src/server/lib/queue/store.server.ts +33 -11
  304. package/src/server/lib/review/schema.server.ts +45 -0
  305. package/src/server/lib/review/store.server.ts +138 -0
  306. package/src/server/lib/terminal/attach-replay.test.ts +132 -0
  307. package/src/server/lib/terminal/output.test.ts +166 -0
  308. package/src/server/lib/terminal/output.ts +104 -0
  309. package/src/server/lib/terminal/runtime.server.ts +5 -0
  310. package/src/server/lib/terminal/send-result.test.ts +33 -0
  311. package/src/server/lib/terminal/send-result.ts +32 -0
  312. package/src/server/lib/terminal/session.server.ts +45 -11
  313. package/src/server/lib/terminal/store-liveness.test.ts +4 -0
  314. package/src/server/lib/updates/active-notes.test.ts +149 -0
  315. package/src/server/lib/updates/active-notes.ts +75 -0
  316. package/src/server/lib/updates/changelog-file.ts +42 -11
  317. package/src/server/lib/updates/changelog.test.ts +15 -1
  318. package/src/server/lib/updates/omp.ts +42 -15
  319. package/src/server/lib/updates/release-url.ts +27 -1
  320. package/src/server/lib/usage/index-parse.test.ts +200 -0
  321. package/src/server/lib/usage/index-parse.ts +178 -0
  322. package/src/server/lib/usage/index-query.server.ts +248 -0
  323. package/src/server/lib/usage/index-scan.server.ts +343 -0
  324. package/src/server/lib/usage/index-schema.server.ts +82 -0
  325. package/src/server/lib/usage/index.test.ts +234 -0
  326. package/src/server/lib/usage/providers.server.ts +4 -53
  327. package/src/server/plugins/ssr.ts +22 -5
  328. package/src/server/routes/browser/index.ts +3 -0
  329. package/src/server/routes/browser/stream.ts +31 -2
  330. package/src/server/routes/browser/tabs.test.ts +94 -0
  331. package/src/server/routes/browser/tabs.ts +85 -0
  332. package/src/server/routes/index.ts +2 -0
  333. package/src/server/routes/review/bindings.ts +11 -0
  334. package/src/server/routes/review/index.ts +127 -0
  335. package/src/server/routes/review/routes.test.ts +191 -0
  336. package/src/server/routes/settings/agents.test.ts +180 -0
  337. package/src/server/routes/settings/agents.ts +95 -102
  338. package/src/server/routes/settings/mcp.test.ts +135 -0
  339. package/src/server/routes/settings/mcp.ts +14 -6
  340. package/src/server/routes/settings/settings-store-routes.test.ts +6 -113
  341. package/src/server/routes/telemetry/tokens.test.ts +145 -0
  342. package/src/server/routes/telemetry/tokens.ts +70 -149
  343. package/src/server/routes/terminal/ws.ts +6 -5
  344. package/src/server/routes/updates/index.ts +2 -0
  345. package/src/server/routes/updates/notes.ts +34 -0
  346. package/src/server/routes/updates/routes.test.ts +49 -0
  347. package/src/shared/lib/browser/annotate.test.ts +283 -0
  348. package/src/shared/lib/browser/annotate.ts +231 -0
  349. package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
  350. package/src/shared/lib/browser/frame-gate.test.ts +91 -0
  351. package/src/shared/lib/browser/frame-gate.ts +69 -0
  352. package/src/shared/lib/browser/frame-params.test.ts +43 -0
  353. package/src/shared/lib/browser/frame-params.ts +60 -0
  354. package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
  355. package/src/shared/lib/browser/frame-pipeline.ts +80 -0
  356. package/src/shared/lib/browser/page-context.ts +60 -4
  357. package/src/shared/lib/browser/snapshot.test.ts +115 -0
  358. package/src/shared/lib/browser/snapshot.ts +112 -0
  359. package/src/shared/lib/browser/tab-close.test.ts +74 -0
  360. package/src/shared/lib/browser/tab-close.ts +77 -0
  361. package/src/shared/lib/browser/viewer.ts +45 -26
  362. package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
  363. package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
  364. package/src/shared/lib/chat/tool/artifact.ts +55 -20
  365. package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
  366. package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
  367. package/src/shared/lib/chat/tool/minimized.ts +64 -0
  368. package/src/shared/lib/chat/tool/summary.test.ts +28 -8
  369. package/src/shared/lib/chat/tool/summary.ts +3 -32
  370. package/src/shared/lib/icons/file-brand-color.ts +38 -0
  371. package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
  372. package/src/shared/lib/icons/icon-paint-css.ts +284 -0
  373. package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
  374. package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
  375. package/src/shared/lib/icons/tint.test.ts +273 -0
  376. package/src/shared/lib/icons/tint.ts +219 -0
  377. package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
  378. package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
  379. package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
  380. package/src/shared/lib/markdown/blocks/scan.ts +100 -0
  381. package/src/shared/lib/markdown/blocks/types.ts +62 -0
  382. package/src/shared/lib/markdown/marked.ts +58 -147
  383. package/src/shared/lib/markdown/math-extensions.ts +168 -0
  384. package/src/shared/lib/markdown/review/prompt.ts +77 -0
  385. package/src/shared/lib/markdown/review/reconcile.ts +55 -0
  386. package/src/shared/lib/markdown/review/review.test.ts +96 -0
  387. package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
  388. package/src/shared/lib/markdown/xml-sections.ts +139 -0
  389. package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
  390. package/src/shared/lib/models/provider/brand-color.ts +103 -0
  391. package/src/shared/lib/models/provider/label.ts +57 -0
  392. package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
  393. package/src/shared/lib/omp/config/agent-file.ts +43 -0
  394. package/src/shared/lib/omp/config/row-value.test.ts +95 -0
  395. package/src/shared/lib/omp/config/row-value.ts +97 -0
  396. package/src/shared/lib/omp/config/schema.test.ts +31 -0
  397. package/src/shared/lib/omp/config/schema.ts +6 -0
  398. package/src/shared/lib/omp/rpc/frame.test.ts +113 -47
  399. package/src/shared/lib/omp/rpc/frame.ts +107 -43
  400. package/src/shared/lib/settings/defaults.ts +4 -0
  401. package/src/shared/lib/theme/catalog.test.ts +5 -4
  402. package/src/shared/lib/theme/catalog.ts +18 -3
  403. package/src/shared/lib/theme/glass-support.test.ts +38 -0
  404. package/src/shared/lib/theme/glass-support.ts +73 -0
  405. package/src/shared/lib/theme/icon-style.test.ts +74 -0
  406. package/src/shared/lib/theme/icon-style.ts +90 -0
  407. package/src/shared/lib/theme/legibility.ts +91 -0
  408. package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
  409. package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
  410. package/src/shared/lib/theme/surface-style.test.ts +68 -0
  411. package/src/shared/lib/theme/surface-style.ts +91 -0
  412. package/src/shared/lib/theme/theme.test.ts +11 -7
  413. package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
  414. package/src/shared/lib/ui/menu-anchor.ts +89 -0
  415. package/src/shared/lib/usage/breakdown.test.ts +197 -0
  416. package/src/shared/lib/usage/breakdown.ts +241 -0
  417. package/src/shared/lib/usage/range.test.ts +204 -0
  418. package/src/shared/lib/usage/range.ts +240 -0
  419. package/src/shared/lib/usage/view.test.ts +85 -0
  420. package/src/shared/lib/usage/view.ts +74 -0
  421. package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
  422. package/src/shared/lib/workspace/panel-hues.ts +57 -0
  423. package/src/shared/types/browser.ts +78 -0
  424. package/src/shared/types/index.ts +1 -0
  425. package/src/shared/types/panels-registry.ts +6 -0
  426. package/src/shared/types/panels.ts +14 -0
  427. package/src/shared/types/settings/agent.ts +28 -6
  428. package/src/shared/types/settings/state.ts +30 -3
  429. package/src/shared/types/settings/write.ts +6 -0
  430. package/src/shared/types/tokenUsage.ts +128 -21
  431. package/src/shared/types/updates.ts +20 -0
  432. package/src/test-support/fake-omp-frames.ts +163 -0
  433. package/dist/client/static/js/index-3ve31rzx.css +0 -1
  434. package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
  435. package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
  436. package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
  437. package/src/server/lib/omp/session/usage/shaping.ts +0 -130
  438. /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Reconciliation and the prompt: what a stored judgement becomes once the
8
+ * document has moved.
9
+ *
10
+ * The behaviours pinned here are the ones a user notices when they are wrong:
11
+ * a mark that follows its block, a mark that says it is outdated instead of
12
+ * disappearing, and composer text that names a block precisely enough for the
13
+ * agent to find it.
14
+ */
15
+
16
+ import { describe, expect, test } from 'bun:test';
17
+
18
+ import { reconcileAnnotations, tallyAnnotations } from '@/shared/lib/markdown/review/reconcile';
19
+ import { appendReviewBlock, formatReviewBlock } from '@/shared/lib/markdown/review/prompt';
20
+ import type { DocumentAnnotation, MdBlock } from '@/shared/lib/markdown/blocks/types';
21
+
22
+ const block = (key: string, quote = key): MdBlock => ({ key, type: 'paragraph', lineStart: 1, lineEnd: 1, quote });
23
+
24
+ const annotation = (overrides: Partial<DocumentAnnotation> & { id: string; blockKey: string }): DocumentAnnotation => ({
25
+ scope: 'root\u0000.',
26
+ path: 'NOTES.md',
27
+ lineStart: 1,
28
+ lineEnd: 1,
29
+ verdict: 'good',
30
+ note: '',
31
+ quote: 'x',
32
+ createdAt: 1,
33
+ updatedAt: 1,
34
+ ...overrides,
35
+ });
36
+
37
+ describe('reconcileAnnotations', () => {
38
+ test('a mark follows its block, and a mark whose block is gone is OUTDATED', () => {
39
+ const blocks = [block('a'), block('b')];
40
+ const result = reconcileAnnotations(blocks, [
41
+ annotation({ id: '1', blockKey: 'b' }),
42
+ annotation({ id: '2', blockKey: 'gone', updatedAt: 5 }),
43
+ ]);
44
+ expect([...result.attached.keys()]).toEqual(['b']);
45
+ expect(result.outdated.map((row) => row.id)).toEqual(['2']);
46
+ // The note is still there: it is the user's only copy.
47
+ expect(result.outdated[0].quote).toBe('x');
48
+ });
49
+
50
+ test('outdated marks are newest first, so the last edit is at the top', () => {
51
+ const result = reconcileAnnotations([], [
52
+ annotation({ id: 'old', blockKey: 'x', updatedAt: 1 }),
53
+ annotation({ id: 'new', blockKey: 'y', updatedAt: 9 }),
54
+ ]);
55
+ expect(result.outdated.map((row) => row.id)).toEqual(['new', 'old']);
56
+ });
57
+
58
+ test('the tally counts what is attached, not what is stored', () => {
59
+ const result = reconcileAnnotations([block('a'), block('b')], [
60
+ annotation({ id: '1', blockKey: 'a', verdict: 'good' }),
61
+ annotation({ id: '2', blockKey: 'b', verdict: 'needs-work' }),
62
+ annotation({ id: '3', blockKey: 'outdated', verdict: 'needs-work' }),
63
+ ]);
64
+ expect(tallyAnnotations(result.attached)).toEqual({ good: 1, needsWork: 1 });
65
+ });
66
+ });
67
+
68
+ describe('formatReviewBlock', () => {
69
+ test('names each block by range and quote, and says what the verdict means', () => {
70
+ const text = formatReviewBlock({
71
+ path: 'docs/NOTES.md',
72
+ annotations: [
73
+ annotation({ id: '1', blockKey: 'a', lineStart: 3, lineEnd: 5, verdict: 'needs-work', note: 'basi', quote: '## Notes' }),
74
+ annotation({ id: '2', blockKey: 'b', lineStart: 9, lineEnd: 9, verdict: 'good', quote: 'Run gates' }),
75
+ ],
76
+ });
77
+ expect(text).toContain('[Review dokumen] docs/NOTES.md');
78
+ expect(text).toContain('- L3-5 «## Notes» — needs work: basi');
79
+ expect(text).toContain('- L9 «Run gates» — good');
80
+ // The instruction is what turns a list of verdicts into a decision.
81
+ expect(text).toContain('jangan diubah');
82
+ });
83
+
84
+ test('an empty review produces no text at all', () => {
85
+ expect(formatReviewBlock({ path: 'a.md', annotations: [] })).toBe('');
86
+ });
87
+
88
+ test('a blank draft takes the block; an existing one is separated by a blank line', () => {
89
+ expect(appendReviewBlock('', 'BLOCK')).toBe('BLOCK');
90
+ expect(appendReviewBlock('draft', 'BLOCK')).toBe('draft\n\nBLOCK');
91
+ // One blank line either way: a single trailing newline still needs a separator.
92
+ expect(appendReviewBlock('draft\n', 'BLOCK')).toBe('draft\n\nBLOCK');
93
+ expect(appendReviewBlock('draft\n\n', 'BLOCK')).toBe('draft\n\nBLOCK');
94
+ expect(appendReviewBlock('draft', '')).toBe('draft');
95
+ });
96
+ });
@@ -0,0 +1,140 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * XML section wrappers in omp's `xd://` docs (`<instruction>`, `<examples>`,
8
+ * `<critical>`) became headings before the markdown parse. Without that, the
9
+ * prose path escaped the tags — the reader saw `<instruction>` as a literal
10
+ * line and every section ran together as one block.
11
+ *
12
+ * The gates are what the tests pin: a paired, whole-line wrapper is rewritten,
13
+ * and nothing else is (a code fence showing the tags as an example, an
14
+ * attribute-carrying wrapper, an unpaired tag, a tag inside a sentence).
15
+ */
16
+
17
+ import { describe, expect, test } from 'bun:test';
18
+ import { xmlSectionsToHeadings } from '@/shared/lib/markdown/xml-sections';
19
+
20
+ describe('xmlSectionsToHeadings', () => {
21
+ test('paired wrappers become headings and their closing lines disappear', () => {
22
+ const source = [
23
+ 'Intro line.',
24
+ '',
25
+ '<instruction>',
26
+ '- Static content? Use `read`.',
27
+ '</instruction>',
28
+ '',
29
+ '<critical>',
30
+ '- MUST open a tab before direct use.',
31
+ '</critical>',
32
+ ].join('\n');
33
+
34
+ expect(xmlSectionsToHeadings(source)).toBe([
35
+ 'Intro line.',
36
+ '',
37
+ '## Instruction',
38
+ '- Static content? Use `read`.',
39
+ '',
40
+ '',
41
+ '## Critical',
42
+ '- MUST open a tab before direct use.',
43
+ '',
44
+ ].join('\n'));
45
+ });
46
+
47
+ test('nesting steps the heading level down, capped at h6', () => {
48
+ const source = [
49
+ '<outer>',
50
+ '<inner>',
51
+ 'text',
52
+ '</inner>',
53
+ '</outer>',
54
+ '<a>',
55
+ '<b>',
56
+ '<c>',
57
+ '<d>',
58
+ '<e>',
59
+ 'deep',
60
+ '</e>',
61
+ '</d>',
62
+ '</c>',
63
+ '</b>',
64
+ '</a>',
65
+ ].join('\n');
66
+
67
+ expect(xmlSectionsToHeadings(source)).toBe([
68
+ '## Outer',
69
+ '### Inner',
70
+ 'text',
71
+ '',
72
+ '',
73
+ '## A',
74
+ '### B',
75
+ '#### C',
76
+ '##### D',
77
+ '###### E',
78
+ 'deep',
79
+ '',
80
+ '',
81
+ '',
82
+ '',
83
+ '',
84
+ ].join('\n'));
85
+ });
86
+
87
+ test('a crossed pair leaves the unmatched lines literal', () => {
88
+ // Valid = open + matching close, properly nested. `<a>` never gets its own
89
+ // close where the stack expects it, so only the well-formed `<b>` pair is
90
+ // a section.
91
+ const source = ['<a>', 'text', '<b>', 'inner', '</a>', '</b>'].join('\n');
92
+
93
+ expect(xmlSectionsToHeadings(source)).toBe(
94
+ ['<a>', 'text', '## B', 'inner', '</a>', ''].join('\n'),
95
+ );
96
+ });
97
+
98
+ test('a fenced block that shows the wrappers keeps them verbatim', () => {
99
+ const source = [
100
+ '<instruction>',
101
+ 'Outer section.',
102
+ '```xml',
103
+ '<instruction>',
104
+ 'literal',
105
+ '</instruction>',
106
+ '```',
107
+ '</instruction>',
108
+ ].join('\n');
109
+
110
+ expect(xmlSectionsToHeadings(source)).toBe([
111
+ '## Instruction',
112
+ 'Outer section.',
113
+ '```xml',
114
+ '<instruction>',
115
+ 'literal',
116
+ '</instruction>',
117
+ '```',
118
+ '',
119
+ ].join('\n'));
120
+ });
121
+
122
+ test('an unpaired or inline tag is left exactly as written', () => {
123
+ const source = [
124
+ '<summary>',
125
+ 'no closing partner',
126
+ 'use <slug> here',
127
+ '<system-reminder reason="a rule fired">',
128
+ 'wrapped with attributes',
129
+ '</system-reminder>',
130
+ 'closing without an opener: </notes>',
131
+ ].join('\n');
132
+
133
+ expect(xmlSectionsToHeadings(source)).toBe(source);
134
+ });
135
+
136
+ test('a source with no tags is returned untouched', () => {
137
+ const source = '# Title\n\n- a < b';
138
+ expect(xmlSectionsToHeadings(source)).toBe(source);
139
+ });
140
+ });
@@ -0,0 +1,139 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * XML section wrappers → markdown headings.
8
+ *
9
+ * omp's `xd://` device docs are markdown, but several sections are marked with
10
+ * an XML-ish wrapper instead of a heading: `<instruction>…</instruction>`,
11
+ * `<examples>…</examples>`, `<critical>…</critical>`. The markdown pipeline
12
+ * escapes source HTML (agent output renders markup as data), so the read panel
13
+ * showed `<instruction>` and `</instruction>` as literal lines and the sections
14
+ * ran together as ordinary prose — the wrap did no visual work at all.
15
+ *
16
+ * Converting them before the markdown parse is the only place both halves can
17
+ * be dropped: marked would otherwise treat a bare tag line as an HTML block,
18
+ * and DOMPurify's profile strips it only after the paragraph boundaries are
19
+ * already decided.
20
+ *
21
+ * Deliberately narrow, because the same text path renders real markdown files:
22
+ *
23
+ * - A wrapper must occupy a WHOLE line AND be valid: an opening line closed by
24
+ * the same name, properly nested. `<slug>` inside a sentence, a lone
25
+ * `<summary>`, a stray `</tag>`, and a tag carrying attributes
26
+ * (`<system-reminder reason="…">`, which the output envelope already reads)
27
+ * are left byte-for-byte as they were.
28
+ * - Nothing inside a fenced code block is touched: a doc that shows the tags
29
+ * as an example must keep showing them as text.
30
+ * - Nesting moves the heading level down one, capped at `h6`; the first level
31
+ * is `h2`, since the document's own `#` title is `h1`.
32
+ */
33
+
34
+ /** A wrapper line: `<name>` / `</name>`, nothing else on the line. */
35
+ const OPEN_RE = /^<([A-Za-z][\w-]*)>$/;
36
+ const CLOSE_RE = /^<\/([A-Za-z][\w-]*)>$/;
37
+
38
+ /** One wrapper line, and the pair it forms when a matching close arrives. */
39
+ interface Section {
40
+ name: string;
41
+ openIndex: number;
42
+ /** The wrapper this one sits inside — matched or not; the level check sorts
43
+ * that out once the whole source has been scanned. */
44
+ parent?: Section;
45
+ /** Line index of the closing wrapper, once the pair was matched. */
46
+ closeIndex?: number;
47
+ }
48
+
49
+ /** A fence opener or closer, indented no more than markdown allows. */
50
+ function fenceAt(line: string): { char: string; length: number } | undefined {
51
+ const body = line.trimStart();
52
+ if (line.length - body.length > 3) return undefined;
53
+ const match = /^(`{3,}|~{3,})/.exec(body);
54
+ return match ? { char: match[1][0], length: match[1].length } : undefined;
55
+ }
56
+
57
+ /** `security-scan` → `Security Scan`; an already-capitalized name is kept. */
58
+ function sectionLabel(name: string): string {
59
+ return name
60
+ .split(/[-_]+/)
61
+ .filter(Boolean)
62
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
63
+ .join(' ');
64
+ }
65
+
66
+ /**
67
+ * Rewrite standalone XML wrapper pairs into `##`-level headings, and drop the
68
+ * closing wrapper lines.
69
+ *
70
+ * A wrapper only counts when it is VALID: an opening line and a closing line
71
+ * with the same name, properly nested against every other wrapper around it. A
72
+ * stray `<tag>`, a stray `</tag>`, and a crossed pair (`<a><b></a></b>`) stay
73
+ * literal — they are text about markup, not a section of the document.
74
+ */
75
+ export function xmlSectionsToHeadings(source: string): string {
76
+ if (!source.includes('<')) return source;
77
+
78
+ const lines = source.split('\n');
79
+
80
+ // Which lines sit inside a fenced code block, so the scan below can skip
81
+ // them. A fence is closed by a run of the same character that is at least as
82
+ // long as the one that opened it.
83
+ const inFence: boolean[] = [];
84
+ let fence: { char: string; length: number } | undefined;
85
+ for (const line of lines) {
86
+ const candidate = fenceAt(line);
87
+ if (fence) {
88
+ inFence.push(true);
89
+ if (candidate && candidate.char === fence.char && candidate.length >= fence.length) fence = undefined;
90
+ continue;
91
+ }
92
+ if (candidate) fence = candidate;
93
+ inFence.push(candidate !== undefined);
94
+ }
95
+
96
+ const stack: Section[] = [];
97
+ /** The opening line index of every valid pair, and where its close sits. */
98
+ const headings = new Map<number, Section>();
99
+ const closes = new Set<number>();
100
+
101
+ for (let index = 0; index < lines.length; index += 1) {
102
+ if (inFence[index]) continue;
103
+ const text = lines[index].trim();
104
+
105
+ const closed = CLOSE_RE.exec(text);
106
+ if (closed) {
107
+ // Strict nesting: only the wrapper that is actually open can be closed.
108
+ const opener = stack[stack.length - 1];
109
+ if (!opener || opener.name !== closed[1]) continue;
110
+ stack.pop();
111
+ opener.closeIndex = index;
112
+ headings.set(opener.openIndex, opener);
113
+ closes.add(index);
114
+ continue;
115
+ }
116
+
117
+ const opened = OPEN_RE.exec(text);
118
+ if (opened) stack.push({ name: opened[1], openIndex: index, parent: stack[stack.length - 1] });
119
+ }
120
+
121
+ if (headings.size === 0) return source;
122
+
123
+ /** Heading level from the nesting of VALID ancestors only: an unmatched
124
+ * wrapper stays literal text and therefore contributes no level. */
125
+ const level = (section: Section): number => {
126
+ const parent = section.parent;
127
+ if (!parent || parent.closeIndex === undefined) return 2;
128
+ return Math.min(6, level(parent) + 1);
129
+ };
130
+
131
+ return lines
132
+ .map((line, index) => {
133
+ const section = headings.get(index);
134
+ if (section) return `${'#'.repeat(level(section))} ${sectionLabel(section.name)}`;
135
+ if (closes.has(index)) return '';
136
+ return line;
137
+ })
138
+ .join('\n');
139
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The brand-colour table's promises: nothing in it is illegible on any palette
8
+ * this build ships, and every row names a glyph that can actually be drawn.
9
+ *
10
+ * Contrast is recomputed from `THEMES`, not from one hardcoded surface — the
11
+ * worst light paper is `tokyonight-light`'s `#dee0ee` and the worst dark one
12
+ * `jetbrains-dark`'s `#2B2D30`, and neither is guessable from the shipped
13
+ * default palette.
14
+ */
15
+
16
+ import { describe, expect, test } from 'bun:test';
17
+ import { BRAND_COLORS, brandColorFor } from '@/shared/lib/models/provider/brand-color';
18
+ import { PROVIDER_GLYPHS } from '@/client/components/common/provider-icon/glyphs';
19
+ import { THEMES } from '@/shared/lib/theme/catalog';
20
+ import {
21
+ BRAND_CONTRAST_FLOOR,
22
+ contrastRatio,
23
+ isNearMonochrome,
24
+ legiblePair,
25
+ worstSurfaceContrast,
26
+ } from '@/shared/lib/theme/legibility';
27
+
28
+ const rows = Object.entries(BRAND_COLORS);
29
+ const HEX = /^#[0-9a-f]{6}$/i;
30
+
31
+ describe('the brand colours', () => {
32
+ test('there are rows to check', () => {
33
+ expect(rows.length).toBeGreaterThan(20);
34
+ });
35
+
36
+ test('every light value clears the floor on EVERY light palette', () => {
37
+ for (const [name, entry] of rows) {
38
+ expect(worstSurfaceContrast(entry.light, 'light'), `${name} light ${entry.light}`).toBeGreaterThanOrEqual(
39
+ BRAND_CONTRAST_FLOOR,
40
+ );
41
+ }
42
+ });
43
+
44
+ test('every dark value clears the floor on EVERY dark palette', () => {
45
+ for (const [name, entry] of rows) {
46
+ if (entry.dark === null) continue;
47
+ expect(worstSurfaceContrast(entry.dark, 'dark'), `${name} dark ${entry.dark}`).toBeGreaterThanOrEqual(
48
+ BRAND_CONTRAST_FLOOR,
49
+ );
50
+ }
51
+ });
52
+
53
+ test('the shipped values are the ones the shared rule derives', () => {
54
+ // One algorithm, not a hand-typed pair: a row that disagreed with
55
+ // `legiblePair` would be a second convention for the same job.
56
+ for (const [name, entry] of rows) {
57
+ expect(entry, name).toEqual({ base: entry.base, ...legiblePair(entry.base) });
58
+ }
59
+ });
60
+
61
+ test('a monochrome brand has no dark value, a chromatic one always does', () => {
62
+ for (const [name, entry] of rows) {
63
+ expect(entry.dark === null, `${name} (${entry.base})`).toBe(isNearMonochrome(entry.base));
64
+ }
65
+ });
66
+
67
+ test('every value is a 6-digit colour', () => {
68
+ for (const [name, entry] of rows) {
69
+ expect(entry.base, name).toMatch(HEX);
70
+ expect(entry.light, name).toMatch(HEX);
71
+ if (entry.dark !== null) expect(entry.dark, name).toMatch(HEX);
72
+ }
73
+ });
74
+
75
+ test('every row names a glyph this build can actually draw', () => {
76
+ for (const name of Object.keys(BRAND_COLORS)) {
77
+ expect(PROVIDER_GLYPHS[name], `${name} has no glyph`).toBeDefined();
78
+ }
79
+ });
80
+
81
+ test('a light value is the brand hex or a darker mix of it, never another hue', () => {
82
+ for (const [name, entry] of rows) {
83
+ if (entry.light === entry.base) continue;
84
+ // Mixed toward black: the light value is never brighter than the base.
85
+ expect(contrastRatio(entry.light, '#ffffff'), name).toBeGreaterThanOrEqual(
86
+ contrastRatio(entry.base, '#ffffff'),
87
+ );
88
+ }
89
+ });
90
+ });
91
+
92
+ describe('brandColorFor', () => {
93
+ test('answers the derived pair for each variant', () => {
94
+ // Pinned: these two numbers are what the shared rule produces for Claude,
95
+ // so a change in the mixer shows up here rather than in a screenshot.
96
+ expect(brandColorFor('claude', 'light')).toBe('#b8654a');
97
+ expect(brandColorFor('claude', 'dark')).toBe('#D97757');
98
+ });
99
+
100
+ test('a monochrome brand answers null on dark, which the caller paints in ink', () => {
101
+ expect(brandColorFor('openai', 'light')).toBeNull();
102
+ expect(brandColorFor('cursor', 'dark')).toBeNull();
103
+ });
104
+
105
+ test('a provider with no row keeps the ink in both modes', () => {
106
+ expect(brandColorFor('my-private-gateway', 'light')).toBeNull();
107
+ expect(brandColorFor(null, 'dark')).toBeNull();
108
+ });
109
+ });
110
+
111
+ describe('the palette the rule measures against', () => {
112
+ test('both variants are represented, so a worst case cannot be vacuous', () => {
113
+ expect(THEMES.some((theme) => theme.variant === 'light')).toBe(true);
114
+ expect(THEMES.some((theme) => theme.variant === 'dark')).toBe(true);
115
+ });
116
+ });
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The brand colour of every provider mark Kabmo can draw in colour.
8
+ *
9
+ * **The table holds the brand's OWN hex, and nothing else.** The two values that
10
+ * get painted are derived by {@link legiblePair}, against the palettes this
11
+ * build actually ships, so there is no hand-maintained pair to drift from the
12
+ * rule: measured, `claude`'s `#D97757` reads 2.38:1 on `tokyonight-light`'s
13
+ * paper (`#dee0ee`) and 4.42:1 on `jetbrains-dark`'s (`#2B2D30`), so one hex
14
+ * cannot be legible on both halves and a second value has to exist — but it is
15
+ * computed, not typed.
16
+ *
17
+ * **A near-monochrome brand has no dark value** (`dark: null`): `#000000` mixed
18
+ * toward white lands on grey, which is indistinguishable from the ink it was
19
+ * meant to replace while claiming to be a brand colour. Those brands are drawn
20
+ * in the theme's ink instead — the same answer the reference implementation
21
+ * gives with `filter: invert()`.
22
+ *
23
+ * **Sources.** `simple-icons`' hex for the brand that owns the glyph, matched
24
+ * through its alias list because the slug and Kabmo's glyph name differ
25
+ * (`mistralai`/`mistral`, `googlegemini`/`gemini`, `x`/`xai`). A glyph with no
26
+ * row — 38 of the 73 in `provider-icon/glyphs.ts` — publishes no colour, and
27
+ * keeps the palette ink in both modes. That is the honest half of the feature:
28
+ * `color` means "brand colour where one exists", never "every mark is
29
+ * chromatic".
30
+ *
31
+ * These are third-party trademarks, used here to identify the provider each one
32
+ * belongs to. They are not covered by this project's licence.
33
+ */
34
+
35
+ import { legiblePair } from '@/shared/lib/theme/legibility';
36
+
37
+ /** The brand's own hex, per glyph name in `provider-icon/glyphs.ts`. */
38
+ const BRAND_BASES: Readonly<Record<string, string>> = {
39
+ alibaba: '#FF6A00',
40
+ anthropic: '#191919',
41
+ apple: '#000000',
42
+ baidu: '#2932E1',
43
+ claude: '#D97757',
44
+ cline: '#18181B',
45
+ cloudflare: '#F38020',
46
+ cursor: '#000000',
47
+ deepseek: '#5786FE',
48
+ gemini: '#8E75B2',
49
+ geminicli: '#8E75B2',
50
+ githubcopilot: '#000000',
51
+ gitlab: '#FC6D26',
52
+ google: '#4285F4',
53
+ huggingface: '#FFD21E',
54
+ kagi: '#FFB319',
55
+ kimi: '#000000',
56
+ lmstudio: '#000000',
57
+ meta: '#0467DF',
58
+ metaai: '#9844FF',
59
+ minimax: '#E73562',
60
+ mistral: '#FA520F',
61
+ moonshot: '#000000',
62
+ nvidia: '#76B900',
63
+ ollama: '#000000',
64
+ opencode: '#000000',
65
+ openrouter: '#94A3B8',
66
+ perplexity: '#1FB8CD',
67
+ qwen: '#6950EF',
68
+ stencil: '#5530FF',
69
+ vercel: '#000000',
70
+ vertexai: '#4285F4',
71
+ vllm: '#30A2FF',
72
+ xai: '#000000',
73
+ xiaomi: '#FF6900',
74
+ };
75
+
76
+ export interface BrandColor {
77
+ /** The brand's own hex, as published. Provenance and documentation. */
78
+ base: string;
79
+ /** Legible on every light palette; `null` means "use the theme ink". */
80
+ light: string;
81
+ /** Legible on every dark palette; `null` means "use the theme ink". */
82
+ dark: string | null;
83
+ }
84
+
85
+ /** Every row, with its two painted values derived from `base`. */
86
+ export const BRAND_COLORS: Readonly<Record<string, BrandColor>> = Object.fromEntries(
87
+ Object.entries(BRAND_BASES).map(([name, base]) => [name, { base, ...legiblePair(base) }]),
88
+ );
89
+
90
+ /**
91
+ * The colour a mark is painted in for one variant, or `null` when it should
92
+ * keep the surrounding ink.
93
+ *
94
+ * `null` covers both "no brand colour published" and "the brand is black", so a
95
+ * caller never has to distinguish them: the answer to "what paints this mark"
96
+ * is either a hex or the ink.
97
+ */
98
+ export function brandColorFor(name: string | null | undefined, variant: 'light' | 'dark'): string | null {
99
+ if (!name) return null;
100
+ const entry = BRAND_COLORS[name];
101
+ if (!entry) return null;
102
+ return variant === 'dark' ? entry.dark : entry.light;
103
+ }
@@ -29,6 +29,63 @@ export function providerLabel(slug: string, names: Record<string, string> = {}):
29
29
  return known?.trim() ? known : titleCaseProviderSlug(slug);
30
30
  }
31
31
 
32
+ /**
33
+ * Slug aliases omp uses interchangeably, folded onto one identity.
34
+ *
35
+ * Both the quota surfaces (`usage/providers.server.ts`) and the token/cost
36
+ * rollup attribute rows by provider, and the two must agree or the same
37
+ * account is two rows on one panel and one on the other.
38
+ */
39
+ const SLUG_ALIASES: Record<string, string> = {
40
+ 'command-code': 'commandcode',
41
+ };
42
+
43
+ /** The canonical spelling of a provider slug: lowercased, alias folded. */
44
+ export function canonicalProviderSlug(slug: string): string {
45
+ const lower = slug.trim().toLowerCase();
46
+ return SLUG_ALIASES[lower] ?? lower;
47
+ }
48
+
49
+ /**
50
+ * Brand spellings a title-case pass cannot produce. Kept small on purpose: the
51
+ * slug is the identity, this is only how it is printed.
52
+ */
53
+ const BRAND_NAMES: Record<string, string> = {
54
+ openai: 'OpenAI',
55
+ kenari: 'Kenari.id',
56
+ deepseek: 'DeepSeek',
57
+ 'openai-codex': 'OpenAI Codex',
58
+ 'google-gemini-cli': 'Google Gemini CLI',
59
+ 'google-antigravity': 'Google Antigravity',
60
+ 'github-copilot': 'GitHub Copilot',
61
+ zai: 'Z.AI',
62
+ 'zai-coding-plan': 'Z.AI Coding Plan',
63
+ xai: 'xAI',
64
+ 'xai-oauth': 'xAI (OAuth)',
65
+ 'kimi-code': 'Kimi Code',
66
+ 'qwen-portal': 'Qwen Portal',
67
+ 'minimax-code': 'MiniMax Code',
68
+ 'minimax-code-cn': 'MiniMax Code (CN)',
69
+ 'alibaba-token-plan': 'Alibaba Token Plan',
70
+ 'alibaba-coding-plan': 'Alibaba Coding Plan',
71
+ 'zhipu-coding-plan': 'Zhipu Coding Plan',
72
+ 'gitlab-duo': 'GitLab Duo',
73
+ 'gitlab-duo-agent': 'GitLab Duo Agent',
74
+ 'charm-hyper': 'Charm Hyper',
75
+ 'cline-pass': 'Cline Pass',
76
+ 'opencode-go': 'OpenCode Go',
77
+ 'xiaomi-token-plan-sgp': 'Xiaomi Token Plan (SGP)',
78
+ 'xiaomi-token-plan-ams': 'Xiaomi Token Plan (AMS)',
79
+ 'xiaomi-token-plan-cn': 'Xiaomi Token Plan (CN)',
80
+ 'openai-codex-device': 'OpenAI Codex (Device)',
81
+ };
82
+
83
+ /** Human-readable provider name: brand spelling when known, title case otherwise. */
84
+ export function providerDisplayName(slug: string): string {
85
+ const canonical = canonicalProviderSlug(slug);
86
+ return BRAND_NAMES[canonical] ?? titleCaseProviderSlug(canonical);
87
+ }
88
+
32
89
  /** Build a slug → display-name map from `/api/models` `connectedProviders`. */
33
90
  export function providerNamesFromConnected(
34
91
  connectedProviders: readonly ProviderNameInfo[] | undefined,