@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
@@ -0,0 +1,142 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `text-ink/60` is a WEIGHT, not a colour choice — and a weight means LESS
8
+ * COLOUR, not a darker colour.
9
+ *
10
+ * Split out of `icon-paint-css.ts` so both files stay readable, not because the
11
+ * rules are independent: they are the family that sheet concatenates, and they
12
+ * are stated AFTER `paintRules` because they transform what it resolves.
13
+ *
14
+ * The settings sidebar, the composer toolbar and a few hundred other call sites
15
+ * write `text-ink/40`-`/80` to mute an icon. That is "the ink, quieter": the
16
+ * caller chose a weight, not a colour. A utility class is (0,1,0) and the hue
17
+ * rules are `:where()` (0,0,0), so the mute won and every muted icon stayed ink
18
+ * in the colour mode ("icon di setting modal kenapa gk full color").
19
+ *
20
+ * ## The bug this replaces
21
+ *
22
+ * The first answer mixed the hue toward `var(--theme-ink)`. That does two things
23
+ * at once — it desaturates AND darkens — and darkening is the opposite of what a
24
+ * mute means. Measured on the settings sidebar (hue 250, `#736aec` on `paper`'s
25
+ * `#faf8f3`): the pure tone reads **3.96:1**, `text-ink/60` monochrome reads
26
+ * **4.74:1**, and the old rule painted **7.48:1** — a muted icon DARKER than the
27
+ * active one beside it, and darker than the monochrome ink it replaced. That is
28
+ * the "icon di modal setting masih kusam di light mode" report: not a shortage of
29
+ * chroma but a colour pushed to a weight it was never meant to have. Over all 36
30
+ * hues and all 32 light palettes the old rule moved mean contrast 4.37 → 9.46 as
31
+ * the weight got quieter, while monochrome moved 9.17 → 1.60.
32
+ *
33
+ * ## The rule now
34
+ *
35
+ * Multiply the CHROMA by the weight and leave LIGHTNESS alone: `60%` of a hue's
36
+ * chroma is the same hue, quieter, at the legibility the tone was solved for.
37
+ * Measured over the same matrix: contrast holds at **3.87 mean / 3.07 min** from
38
+ * `text-ink/90` down to `/25` (the tone's own 3.91), while chroma falls 0.146 →
39
+ * 0.040 — the icon recedes by losing colour rather than by going dark. Dark
40
+ * behaves the same way (3.83 mean, 3.02 min), because the transform never reads
41
+ * the variant.
42
+ *
43
+ * ## Two facts about the SELECTOR, both measured
44
+ *
45
+ * **1. `[class~=…]`, never `[class*=…]`.** A substring match also fires on the
46
+ * VARIANT token: `text-ink/50 group-hover:text-ink/80` matched both `/50` and
47
+ * `/80`, so the resting icon was painted at its HOVER weight — measured in the
48
+ * composer's target picker, `Folder` computed `oklch(… 0.151 320)` (the `/80`
49
+ * paint) while it was not hovered. `~=` compares one whitespace-separated word,
50
+ * and `group-hover:text-ink/80` is not the word `text-ink/80`, so the base
51
+ * weight is the only one that applies at rest.
52
+ *
53
+ * **2. The variants are stated explicitly.** With the base weights matching
54
+ * exactly, `hover:text-ink/70` and `group-hover:text-ink/80` would otherwise be
55
+ * ignored entirely (the paint rule sets `color` on the `svg` itself, so
56
+ * inheritance from the hovered parent cannot reach it). Each variant is
57
+ * re-stated against its own pseudo-class, which also gives it the higher
58
+ * specificity the tie needs.
59
+ *
60
+ * ## And it no longer eats a signal
61
+ *
62
+ * The rule is stated against `--icon-color`, not against a hue formula, so a
63
+ * signal glyph (`--icon-color: var(--theme-warning)`) keeps its token and is
64
+ * merely quieted — measured, `Bell` under `text-ink/60` used to paint
65
+ * `rgb(26,53,80)`, the warning orange replaced by the hashed hue path. Now it
66
+ * paints warning at 60% chroma (`oklch(0.553 0.104 38.4)`).
67
+ *
68
+ * `oklch(from …)` is relative colour syntax: it reads the source in OKLCH and
69
+ * rewrites one channel, which is the only CSS way to say "same colour, less of
70
+ * it". Supported in every engine this app targets (Chromium 119+, Safari 16.4+,
71
+ * WebKitGTK 2.42+); an engine that lacks it IGNORES the declaration and keeps
72
+ * the full-strength paint, so the failure is an unmuted icon, never a missing
73
+ * one.
74
+ */
75
+
76
+ /** The steps call sites actually use, plus the neighbours a new one may reach for. */
77
+ const WEIGHT_STEPS = [20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90];
78
+
79
+ /**
80
+ * How much chroma a weight KEEPS, as a multiplier on the source colour.
81
+ *
82
+ * A straight `c * step` is what made the lighter mutes read grey: measured over
83
+ * the shipped tones, `text-ink/40` (the single most common icon mute — 84 call
84
+ * sites) painted chroma **0.065**, under half the tone's 0.163, and 169 of 1139
85
+ * coloured glyphs landed below 0.08, i.e. indistinguishable from ink.
86
+ *
87
+ * The curve keeps a floor: `FLOOR + (1 - FLOOR) * step`. At `FLOOR = 0.45` the
88
+ * same `/40` paints 0.110 instead of 0.065 and `/20` paints 0.089 instead of
89
+ * 0.033, while the ORDER the ramp exists for survives — `/90` is still nearly
90
+ * twice the chroma of `/40`, so a quiet icon still reads as quieter. Contrast is
91
+ * untouched: only chroma moves, and the tone's lightness is what the floor is
92
+ * measured against.
93
+ */
94
+ const WEIGHT_CHROMA_FLOOR = 0.45;
95
+
96
+ /** The weight at `step/100`, or the untouched colour. */
97
+ function paintAt(step: number | null): string {
98
+ if (step === null) return 'var(--icon-color)';
99
+ const scale = (WEIGHT_CHROMA_FLOOR + (1 - WEIGHT_CHROMA_FLOOR) * (step / 100)).toFixed(3);
100
+ return `oklch(from var(--icon-color) l calc(c * ${scale}) h)`;
101
+ }
102
+
103
+ /** Every variant prefix that carries a `text-ink` weight somewhere in this app. */
104
+ const VARIANTS = ['hover', 'group-hover'] as const;
105
+
106
+ /**
107
+ * `selector` and the weight it paints. `prefix` is empty for the resting state.
108
+ *
109
+ * DOM order matters: `.group` is an ANCESTOR of the icon while
110
+ * `[data-icon-style]` sits on `<html>`, so the group has to come AFTER the mode
111
+ * gate. Stated the other way round (`group:hover [data-icon-style="color"] …`)
112
+ * the selector demands a descendant carrying the attribute and never matches —
113
+ * measured, `group-hover:text-ink/80` had no effect at all.
114
+ *
115
+ * The order this returns is the order the rules are emitted in, and it matters:
116
+ * a variant has strictly higher specificity than the base, so a hover weight
117
+ * always wins over the resting one, whatever order the two landed in the sheet.
118
+ */
119
+ function weightRule(variant: (typeof VARIANTS)[number] | null, step: number | null, dark: boolean): string {
120
+ const mode = dark ? '[data-icon-style="color"][data-theme-variant="dark"]' : '[data-icon-style="color"]';
121
+ const token = variant ? `${variant}:text-ink` : 'text-ink';
122
+ const suffix = step === null ? '' : `/${step}`;
123
+ // `.group:hover` for the shared-parent variant, `svg:hover` for the direct one.
124
+ const scope = variant === 'group-hover' ? '.group:hover ' : '';
125
+ const pseudo = variant === 'hover' ? ':hover' : '';
126
+ return `${mode} ${scope}svg.lucide:not(.project-accent-mark)[class~="${token}${suffix}"]${pseudo} { --icon-paint: ${paintAt(step)}; }`;
127
+ }
128
+
129
+ export function inkWeightRules(): string[] {
130
+ const rules: string[] = [];
131
+ for (const dark of [false, true]) {
132
+ // The un-suffixed `text-ink` is the full-strength ink, and its variants are
133
+ // "the caller wants full ink back" — the same paint, no step.
134
+ rules.push(weightRule(null, null, dark));
135
+ for (const variant of VARIANTS) rules.push(weightRule(variant, null, dark));
136
+ for (const step of WEIGHT_STEPS) rules.push(weightRule(null, step, dark));
137
+ for (const step of WEIGHT_STEPS) {
138
+ for (const variant of VARIANTS) rules.push(weightRule(variant, step, dark));
139
+ }
140
+ }
141
+ return rules;
142
+ }
@@ -75,12 +75,44 @@ export const ICON_TONE_CONTRAST = 3.15;
75
75
  * can show at that lightness. Measured, that reads as a neon sign beside a
76
76
  * toolbar glyph, not as a hue. 0.19 keeps every capped hue vivid and leaves the
77
77
  * ones that cannot reach it (yellow, teal) at their gamut maximum.
78
+ *
79
+ * Raising the cap is NOT the lever for a dull hue, which is why it stays: the
80
+ * rows that read greyest (teal/cyan, C 0.096-0.102) are at the sRGB gamut
81
+ * boundary for their lightness, so a bigger cap changes nothing there and only
82
+ * pushes magenta and red further toward neon — a wider spread, not a more even
83
+ * wheel. Consistency is bought by solving each variant and by the weight floor,
84
+ * not by more chroma at the top.
78
85
  */
79
86
  export const ICON_TONE_CHROMA_CAP = 0.19;
80
87
 
81
- /** Lightnesses the solver may use, lightest first — ties prefer the lighter. */
88
+ /**
89
+ * Lightnesses the LIGHT solver may use, lightest first — ties prefer the lighter.
90
+ *
91
+ * The ceiling is not taste: above 0.62 the darkest light papers in the catalog
92
+ * (`tokyonight-light` `#dee0ee`, `kanagawa-light` `#eae4bf`) drop the most
93
+ * chromatic hues under the floor.
94
+ */
82
95
  const LIGHTNESS_LADDER = [0.62, 0.6, 0.58, 0.56, 0.54, 0.52, 0.5, 0.48, 0.46, 0.44, 0.4];
83
96
 
97
+ /**
98
+ * Lightnesses the DARK solver may use, lightest first — ties prefer the lighter.
99
+ *
100
+ * Dark used to be ONE `hsl(H 65% 70%)` for every hue, and the measured cost is a
101
+ * lightness spread of **0.25** (L 0.65 at hue 240 against L 0.90 at hue 60): the
102
+ * same mode draws a blue icon markedly heavier than the yellow one beside it,
103
+ * which is the inconsistency the light side was solved out of.
104
+ *
105
+ * The band is a BAND, not a ladder from black to white, and that is the whole
106
+ * fix. Solved per hue with no bound, the solver still spreads 0.20 — it spends
107
+ * every point of lightness the dark palettes would allow chasing chroma. Pinned
108
+ * to 0.74-0.82 it cannot: measured over the 36 hues, the spread falls to
109
+ * **0.08** while the mean chroma RISES 0.126 → 0.170 and the muddiest row goes
110
+ * 0.082 → 0.134, every row still clearing 3.15:1 on all 31 dark papers.
111
+ */
112
+ const DARK_LIGHTNESS_LADDER = [
113
+ 0.82, 0.81, 0.8, 0.79, 0.78, 0.77, 0.76, 0.75, 0.74,
114
+ ];
115
+
84
116
  /** The wheel the generated hues land on: 36 steps of 10°. */
85
117
  export const ICON_TONE_WHEEL = Array.from({ length: 36 }, (_, index) => index * 10);
86
118
 
@@ -113,34 +145,47 @@ export function oklchOf(hex: string): { lightness: number; chroma: number; hue:
113
145
  };
114
146
  }
115
147
 
116
- /** The lowest contrast `hex` reaches on any light palette's surface. */
117
- function worstLightContrast(hex: string): number {
148
+ /** The lowest contrast `hex` reaches on any palette surface of `variant`. */
149
+ function worstVariantContrast(hex: string, variant: 'light' | 'dark'): number {
118
150
  let worst = Number.POSITIVE_INFINITY;
119
151
  for (const theme of THEMES) {
120
- if (theme.variant !== 'light') continue;
152
+ if (theme.variant !== variant) continue;
121
153
  worst = Math.min(worst, contrastRatio(hex, theme.paper));
122
154
  }
123
155
  return worst === Number.POSITIVE_INFINITY ? BRAND_CONTRAST_FLOOR : worst;
124
156
  }
125
157
 
126
158
  /**
127
- * The tone for ONE wheel hue, given the pair the mode used to paint with.
159
+ * The tone for ONE wheel hue in ONE variant.
160
+ *
161
+ * `saturation`/`lightness` are the pair the mode used to paint with, and they
162
+ * are only used to NAME the colour: `hsl(H 60% 30%)` (light) and `hsl(H 65% 70%)`
163
+ * (dark) are hue `H` as this app already means it, and the OKLCH hue angle of
164
+ * that paint is what every candidate keeps.
128
165
  *
129
- * `saturation`/`lightness` are the OLD constants, and they are only used to name
130
- * the colour: `hsl(H 60% 30%)` is hue `H` as this app already means it, and its
131
- * OKLCH hue angle is what gets kept.
166
+ * The rule is identical for both variants — keep the hue, take the most chroma
167
+ * sRGB can show at a legal lightness, prefer chroma then the lighter candidate —
168
+ * because the complaint and the fix are the same on either side: a single pair
169
+ * spends its whole budget on the worst hue and leaves the muddiest row at less
170
+ * than half the chroma of the vividest one.
132
171
  */
133
- export function solveIconTone(wheelHue: number, saturation = 60, lightness = 30): string {
172
+ export function solveIconTone(
173
+ wheelHue: number,
174
+ variant: 'light' | 'dark' = 'light',
175
+ saturation = variant === 'light' ? 60 : 65,
176
+ lightness = variant === 'light' ? 30 : 70,
177
+ ): string {
134
178
  const colorHue = oklchOf(hslToHex(wheelHue, saturation, lightness)).hue;
179
+ const ladder = variant === 'light' ? LIGHTNESS_LADDER : DARK_LIGHTNESS_LADDER;
135
180
  let best: { hex: string; chroma: number; lightness: number } | null = null;
136
181
  let darkest = '';
137
- for (const candidate of LIGHTNESS_LADDER) {
182
+ for (const candidate of ladder) {
138
183
  const chroma = Math.min(ICON_TONE_CHROMA_CAP, maxChromaInGamut(candidate, colorHue));
139
184
  const paint = oklchToRgb(candidate, Math.max(chroma, 0.02), colorHue);
140
185
  const hex = rgbaToHex(paint);
141
186
  darkest = hex;
142
187
  if (!paint.inGamut) continue;
143
- if (worstLightContrast(hex) < ICON_TONE_CONTRAST) continue;
188
+ if (worstVariantContrast(hex, variant) < ICON_TONE_CONTRAST) continue;
144
189
  const better = !best || chroma > best.chroma + 1e-6 || (Math.abs(chroma - best.chroma) <= 1e-6 && candidate > best.lightness);
145
190
  if (better) best = { hex, chroma, lightness: candidate };
146
191
  }
@@ -148,8 +193,8 @@ export function solveIconTone(wheelHue: number, saturation = 60, lightness = 30)
148
193
  }
149
194
 
150
195
  /** Every wheel hue's light tone: what the generator writes to disk. */
151
- export function solveIconTones(): Record<number, string> {
152
- return Object.fromEntries(ICON_TONE_WHEEL.map((hue) => [hue, solveIconTone(hue)]));
196
+ export function solveIconTones(variant: 'light' | 'dark' = 'light'): Record<number, string> {
197
+ return Object.fromEntries(ICON_TONE_WHEEL.map((hue) => [hue, solveIconTone(hue, variant)]));
153
198
  }
154
199
 
155
200
  /** `hsl(h <saturation>% <lightness>%)` as `#rrggbb` — the paint this module replaces. */
@@ -11,12 +11,17 @@
11
11
  * paint a palette token, because a trash can has to be the theme's error colour
12
12
  * and not whatever the hash said.
13
13
  *
14
- * `ICON_TONES` is the LIGHT paint for each wheel hue, solved by
15
- * `shared/lib/icons/icon-tone.ts` against every light palette this build ships.
16
- * It is a table rather than a call because the solve needs the palette catalog,
17
- * which the client would otherwise carry — and 11k contrast checks — only to
18
- * colour a toolbar glyph. Dark keeps its single `hsl()` pair: it already reads
19
- * bright, and one pair is enough when the budget is not spent.
14
+ * `ICON_TONES` and `ICON_TONES_DARK` are the paints for each wheel hue, solved
15
+ * by `shared/lib/icons/icon-tone.ts` against every palette of that variant this
16
+ * build ships. They are tables rather than calls because the solve needs the
17
+ * palette catalog, which the client would otherwise carry — and 11k contrast
18
+ * checks — only to colour a toolbar glyph.
19
+ *
20
+ * Both variants are solved, and that is the fix for the mode's other half: dark
21
+ * used to be one `hsl(H 65% 70%)` for every hue, which spread its lightness
22
+ * over 0.25 and left the muddiest row at a quarter of the vividest row's
23
+ * chroma. Solved per hue inside a pinned band, both variants now land in a
24
+ * narrow lightness spread, so a glyph is the same colour on either theme.
20
25
  *
21
26
  * Regenerate with `bun run icons:tints` after adding an icon OR a palette. The
22
27
  * suite fails when this table and the imports disagree (`icons:tints:check`),
@@ -275,3 +280,43 @@ export const ICON_TONES: Readonly<Record<number, string>> = {
275
280
  340: '#d63f70',
276
281
  350: '#da3f58',
277
282
  };
283
+
284
+ /** The dark paint for each wheel hue: the same hue, solved for ink surfaces. */
285
+ export const ICON_TONES_DARK: Readonly<Record<number, string>> = {
286
+ 0: '#ff7d7f',
287
+ 10: '#ff8069',
288
+ 20: '#ff843d',
289
+ 30: '#ff9e07',
290
+ 40: '#f7b900',
291
+ 50: '#e1c400',
292
+ 60: '#cfcc00',
293
+ 70: '#bed200',
294
+ 80: '#abd82f',
295
+ 90: '#99dc46',
296
+ 100: '#88df57',
297
+ 110: '#79e164',
298
+ 120: '#6ce36e',
299
+ 130: '#5be479',
300
+ 140: '#3ee687',
301
+ 150: '#00e79c',
302
+ 160: '#00e5b4',
303
+ 170: '#00e2cc',
304
+ 180: '#00e0e1',
305
+ 190: '#00dcf8',
306
+ 200: '#09c1ff',
307
+ 210: '#5cb1ff',
308
+ 220: '#7fa9ff',
309
+ 230: '#91a3ff',
310
+ 240: '#9d9fff',
311
+ 250: '#a99aff',
312
+ 260: '#b793ff',
313
+ 270: '#c68bff',
314
+ 280: '#d581fe',
315
+ 290: '#ea87fd',
316
+ 300: '#fc8dfc',
317
+ 310: '#fd84ea',
318
+ 320: '#fe7ad5',
319
+ 330: '#fe71bd',
320
+ 340: '#ff76a7',
321
+ 350: '#ff7a93',
322
+ };
@@ -0,0 +1,257 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The two solved tone tables, and the properties each one has to keep.
8
+ *
9
+ * Split out of `tint.test.ts` because it asserts a different thing: that file
10
+ * pins which hue a glyph GETS (the hash, the class, the signal table), while this
11
+ * one pins how a hue is PAINTED — per variant, contrast-safe on every palette of
12
+ * that variant, inside a narrow lightness band, and identical in hue across the
13
+ * two themes.
14
+ */
15
+
16
+ import { describe, expect, test } from 'bun:test';
17
+ import {
18
+ assignPanelHues,
19
+ DEFAULT_ICON_HUE,
20
+ ICON_HUE_PAINT,
21
+ ICON_HUE_ROWS,
22
+ ICON_TINTS,
23
+ iconHue,
24
+ hashHue,
25
+ iconHuePaint,
26
+ iconTone,
27
+ } from '@/shared/lib/icons/tint';
28
+ import { ICON_HUES, ICON_TONES, ICON_TONES_DARK } from '@/shared/lib/icons/tint-hues.generated';
29
+ import { oklchOf } from '@/shared/lib/icons/icon-tone';
30
+ import { THEMES } from '@/shared/lib/theme/catalog';
31
+ import { BRAND_CONTRAST_FLOOR, contrastRatio } from '@/shared/lib/theme/legibility';
32
+
33
+ /** `hsl(<hue> <sat>% <light>%)` as a hex, so contrast can be measured. */
34
+ function hslHex(hue: number, saturation: number, lightness: number): string {
35
+ const s = saturation / 100;
36
+ const l = lightness / 100;
37
+ const k = (n: number) => (n + hue / 30) % 12;
38
+ const a = s * Math.min(l, 1 - l);
39
+ const channel = (n: number) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
40
+ const toHex = (value: number) =>
41
+ Math.round(Math.min(1, Math.max(0, value)) * 255)
42
+ .toString(16)
43
+ .padStart(2, '0');
44
+ return `#${toHex(channel(0))}${toHex(channel(8))}${toHex(channel(4))}`;
45
+ }
46
+
47
+ describe('the generated hues', () => {
48
+ test('the table has one entry per imported, non-signal icon', () => {
49
+ expect(Object.keys(ICON_HUES).length).toBeGreaterThan(100);
50
+ for (const name of Object.keys(ICON_TINTS)) {
51
+ expect(ICON_HUES[name], `${name} is a signal and must not carry a hue`).toBeUndefined();
52
+ }
53
+ });
54
+
55
+ test('every hue is a step on the 36-hue wheel', () => {
56
+ for (const [name, hue] of Object.entries(ICON_HUES)) {
57
+ expect(hue % 10, name).toBe(0);
58
+ expect(hue, name).toBeGreaterThanOrEqual(0);
59
+ expect(hue, name).toBeLessThan(360);
60
+ }
61
+ });
62
+
63
+ test('neighbouring icons are not all the same colour', () => {
64
+ const hues = new Set(Object.values(ICON_HUES));
65
+ // The whole point of a per-icon hue: a dense list must not be one colour.
66
+ expect(hues.size).toBeGreaterThan(20);
67
+ });
68
+
69
+ test('the hue table matches the icons this repo imports', async () => {
70
+ // The generator is the source of truth; running its `--check` here is what
71
+ // makes a stale table a test failure instead of a review miss.
72
+ //
73
+ // `Bun.fileURLToPath`, not `URL.pathname`: on a Windows host the pathname
74
+ // is `/D:/a/kabmo/kabmo/`, which no process can open, so the spawn failed
75
+ // for a reason that had nothing to do with the table — measured on the
76
+ // Windows gate, where this case failed while every other row passed.
77
+ //
78
+ // The script is resolved THROUGH the URL rather than by string-joining onto
79
+ // the directory: `fileURLToPath` keeps a trailing separator (`…/kabmo/`),
80
+ // and a hand-written join would then carry one separator style into a path
81
+ // the other half spelled the other way.
82
+ const repoUrl = new URL('../../../..', import.meta.url);
83
+ const repoRoot = Bun.fileURLToPath(repoUrl);
84
+ const script = Bun.fileURLToPath(new URL('scripts/icon-tints.mjs', repoUrl));
85
+ const check = Bun.spawnSync(['bun', 'run', script, '--check'], {
86
+ cwd: repoRoot,
87
+ stdout: 'pipe',
88
+ stderr: 'pipe',
89
+ });
90
+ expect(check.exitCode, check.stderr.toString()).toBe(0);
91
+ });
92
+
93
+ test('every light tone clears the non-text floor on every light palette', () => {
94
+ // The tone is SOLVED per hue (see `icon-tone.ts`); this is the property that
95
+ // let the mode carry 39% more chroma without losing a single row, so it is
96
+ // pinned per palette rather than against one hex.
97
+ const papers = THEMES.filter((theme) => theme.variant === 'light').map((theme) => theme.paper);
98
+ for (const [hue, tone] of Object.entries(ICON_TONES)) {
99
+ expect(tone, hue).toMatch(/^#[0-9a-f]{6}$/);
100
+ const worst = Math.min(...papers.map((paper) => contrastRatio(tone, paper)));
101
+ expect(worst, `hue ${hue} (${tone})`).toBeGreaterThanOrEqual(BRAND_CONTRAST_FLOOR);
102
+ }
103
+ });
104
+
105
+ test('every dark tone clears the floor on every dark palette', () => {
106
+ // Dark used to be ONE `hsl(H 65% 70%)` for every hue and was deliberately
107
+ // left alone. Measured, that pair spreads its lightness over 0.25 (L 0.65 at
108
+ // hue 240 against 0.90 at hue 60) and leaves the muddiest row at a quarter
109
+ // of the vividest row's chroma — the same "kusam" the light side was
110
+ // reported for, one variant later. It is solved now, and this pins the
111
+ // property the solve must keep.
112
+ const papers = THEMES.filter((theme) => theme.variant === 'dark').map((theme) => theme.paper);
113
+ for (const [hue, tone] of Object.entries(ICON_TONES_DARK)) {
114
+ expect(tone, hue).toMatch(/^#[0-9a-f]{6}$/);
115
+ const worst = Math.min(...papers.map((paper) => contrastRatio(tone, paper)));
116
+ expect(worst, `hue ${hue} (${tone})`).toBeGreaterThanOrEqual(BRAND_CONTRAST_FLOOR);
117
+ }
118
+ });
119
+
120
+ test('each variant lands in a narrow lightness band and carries real chroma', () => {
121
+ // The whole point of solving per hue in BOTH variants: one pair per side made
122
+ // the wheel uneven — a blue icon visibly heavier than the yellow beside it.
123
+ // Measured after the solve, light spreads 0.04 and dark 0.08, and the
124
+ // muddiest dark row goes from chroma 0.082 to 0.133.
125
+ for (const [label, table, maxSpread, minChroma] of [
126
+ ['light', ICON_TONES, 0.06, 0.09],
127
+ ['dark', ICON_TONES_DARK, 0.1, 0.12],
128
+ ] as const) {
129
+ const tones = Object.values(table).map((tone) => oklchOf(tone));
130
+ const lightnesses = tones.map((tone) => tone.lightness);
131
+ const spread = Math.max(...lightnesses) - Math.min(...lightnesses);
132
+ expect(spread, `${label} lightness spread`).toBeLessThanOrEqual(maxSpread);
133
+ expect(Math.min(...tones.map((tone) => tone.chroma)), `${label} dullest row`).toBeGreaterThanOrEqual(minChroma);
134
+ }
135
+ });
136
+
137
+ test('a hue keeps its identity across variants', () => {
138
+ // A glyph must be "the same colour" on both themes, or switching the palette
139
+ // silently recolours every icon in the app.
140
+ for (const hue of Object.keys(ICON_TONES)) {
141
+ const light = oklchOf(ICON_TONES[Number(hue)]!).hue;
142
+ const dark = oklchOf(ICON_TONES_DARK[Number(hue)]!).hue;
143
+ const drift = Math.min(Math.abs(light - dark), 360 - Math.abs(light - dark));
144
+ expect(drift, `hue ${hue}`).toBeLessThan(12);
145
+ }
146
+ });
147
+
148
+ test('a light tone carries MORE chroma than the pair it replaced', () => {
149
+ // The report — "warna icon di mode full color ketika light mode kelihatan
150
+ // kusem" — is this measurement, and nothing else: the old pair maxed out at
151
+ // OKLCH chroma 0.075 on the muddiest hue because one saturation had to suit
152
+ // every hue on the wheel. Solving per hue is what buys the colour back, and
153
+ // this is the assertion that would fail if a future edit quietly put a
154
+ // uniform pair back.
155
+ const hues = Object.keys(ICON_TONES).map(Number);
156
+ const mean = (values: number[]) => values.reduce((a, b) => a + b, 0) / values.length;
157
+ const before = hues.map((hue) => oklchOf(hslHex(hue, ICON_HUE_PAINT.light.saturation, ICON_HUE_PAINT.light.lightness)).chroma);
158
+ const after = hues.map((hue) => oklchOf(ICON_TONES[hue]!).chroma);
159
+ expect(mean(after)).toBeGreaterThan(mean(before) * 1.3);
160
+ // Every single hue must improve — a table that traded one muddy row for
161
+ // another would still pass the mean.
162
+ for (const hue of hues) {
163
+ expect(oklchOf(ICON_TONES[hue]!).chroma, `hue ${hue}`).toBeGreaterThan(
164
+ oklchOf(hslHex(hue, ICON_HUE_PAINT.light.saturation, ICON_HUE_PAINT.light.lightness)).chroma,
165
+ );
166
+ }
167
+ });
168
+
169
+ test('a light tone keeps its hue, so a row does not change colour', () => {
170
+ // Solved in OKLCH, but the hue is the OKLCH angle of the OLD paint: a tone
171
+ // that drifted would recolour every icon in the app, which is not what
172
+ // "more colour" means.
173
+ for (const [hue, tone] of Object.entries(ICON_TONES)) {
174
+ const before = oklchOf(hslHex(Number(hue), ICON_HUE_PAINT.light.saturation, ICON_HUE_PAINT.light.lightness)).hue;
175
+ const after = oklchOf(tone).hue;
176
+ const circular = Math.min(Math.abs(before - after), 360 - Math.abs(before - after));
177
+ expect(circular, `hue ${hue} (${tone})`).toBeLessThan(12);
178
+ }
179
+ });
180
+
181
+ test('the light tone is a table lookup, not a solve, and it snaps to the wheel', () => {
182
+ expect(iconTone(120)).toBe(ICON_TONES[120]!);
183
+ // `hashHue` only produces wheel steps, but a stored or plugin name could
184
+ // still reach here with something else; the nearest step keeps it a colour.
185
+ expect(iconTone(124)).toBe(ICON_TONES[120]!);
186
+ expect(iconTone(356)).toBe(ICON_TONES[0]!);
187
+ expect(iconTone(-10)).toBe(ICON_TONES[350]!);
188
+ });
189
+
190
+ test('the paint rule and the concrete colour share one formula', () => {
191
+ // The stylesheet leaves the hue to `--icon-hue`; the settings preview needs a
192
+ // real colour. Both must come from the same numbers, or the preview lies.
193
+ // Each variant reads its OWN solved table, which is why neither is a bare
194
+ // `hsl()` any more.
195
+ expect(iconHuePaint('light')).toBe(
196
+ `var(--icon-tone, hsl(var(--icon-hue, ${DEFAULT_ICON_HUE}) ${ICON_HUE_PAINT.light.saturation}% ${ICON_HUE_PAINT.light.lightness}%))`,
197
+ );
198
+ expect(iconHuePaint('dark')).toBe(
199
+ `var(--icon-tone-dark, hsl(var(--icon-hue, ${DEFAULT_ICON_HUE}) ${ICON_HUE_PAINT.dark.saturation}% ${ICON_HUE_PAINT.dark.lightness}%))`,
200
+ );
201
+ expect(iconTone(120, 'light')).toBe(ICON_TONES[120]!);
202
+ expect(iconTone(120, 'dark')).toBe(ICON_TONES_DARK[120]!);
203
+ });
204
+
205
+ test('the table is exactly what the runtime hash produces', () => {
206
+ // One formula for both: a plugin's mark is coloured by `hashHue` at runtime,
207
+ // so if the generated rows drifted from it, an installed plugin would sit on
208
+ // a different wheel than the glyphs beside it.
209
+ for (const [name, hue] of Object.entries(ICON_HUES)) {
210
+ expect(hashHue(name), name).toBe(hue);
211
+ }
212
+ });
213
+
214
+ test('a plugin name gets a stable hue on the same wheel', () => {
215
+ expect(hashHue('Demo Plugin')).toBe(hashHue('Demo Plugin'));
216
+ expect(hashHue('Demo Plugin')).not.toBe(hashHue('Other Plugin'));
217
+ for (const name of ['Demo', 'Session Info', 'git-forge', 'Stats — CPU & RAM']) {
218
+ expect(hashHue(name) % 10, name).toBe(0);
219
+ expect(hashHue(name), name).toBeLessThan(360);
220
+ }
221
+ });
222
+
223
+ test('the rail gives every panel its OWN hue, even when two hashes collide', () => {
224
+ // Fourteen buttons on a 36-slot wheel collide about nine times in ten
225
+ // (birthday bound) — measured, three right-rail icons shared one blue.
226
+ const ids = [
227
+ 'context', 'files', 'search', 'git', 'wiki', 'terminal', 'user-browser',
228
+ 'browser', 'usage', 'todo', 'plan', 'plugin:command-runner',
229
+ 'plugin:git-forge', 'plugin:stats',
230
+ ];
231
+ const hues = assignPanelHues(ids);
232
+
233
+ expect(hues.size).toBe(ids.length);
234
+ expect(new Set(hues.values()).size).toBe(ids.length);
235
+ });
236
+
237
+ test('the assignment does not depend on the catalog order', () => {
238
+ // Reordering a rail must not recolour it: the ids are sorted before probing.
239
+ const ids = ['b', 'a', 'c', 'plugin:x'];
240
+ expect([...assignPanelHues(ids)]).toEqual([...assignPanelHues([...ids].reverse())]);
241
+ });
242
+
243
+ test('an unassigned panel falls back to the plain hash', () => {
244
+ expect(assignPanelHues(['only']).get('only')).toBe(hashHue('only'));
245
+ });
246
+
247
+ test('an icon outside the table keeps a neutral default', () => {
248
+ expect(iconHue('NotAnIcon')).toBe(DEFAULT_ICON_HUE);
249
+ expect(iconHue('Trash2')).toBe(DEFAULT_ICON_HUE);
250
+ });
251
+
252
+ test('the rows name classes, one per hue', () => {
253
+ const classes = ICON_HUE_ROWS.map((row) => row.className);
254
+ expect(new Set(classes).size).toBe(classes.length);
255
+ expect(classes.every((className) => className.startsWith('lucide-'))).toBe(true);
256
+ });
257
+ });