@kabmo-labs/kabmo 0.11.1 → 0.12.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 (324) hide show
  1. package/README.md +67 -421
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +426 -413
  4. package/dist/client/static/js/{index-amss8pge.js → index-0smc9gm2.js} +1123 -747
  5. package/dist/client/static/js/index-shexbk5f.css +1 -0
  6. package/marketplace/marketplace.json +13 -3
  7. package/marketplace/plugins/command-runner/package.json +4 -2
  8. package/marketplace/plugins/git-forge/README.md +219 -0
  9. package/marketplace/plugins/git-forge/icon.svg +20 -0
  10. package/marketplace/plugins/git-forge/package.json +56 -0
  11. package/marketplace/plugins/git-forge/src/app.tsx +82 -0
  12. package/marketplace/plugins/git-forge/src/command.test.ts +181 -0
  13. package/marketplace/plugins/git-forge/src/command.ts +119 -0
  14. package/marketplace/plugins/git-forge/src/header.tsx +87 -0
  15. package/marketplace/plugins/git-forge/src/panel/Badge.tsx +76 -0
  16. package/marketplace/plugins/git-forge/src/panel/Change.tsx +150 -0
  17. package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +51 -0
  18. package/marketplace/plugins/git-forge/src/panel/Credential.tsx +107 -0
  19. package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +70 -0
  20. package/marketplace/plugins/git-forge/src/panel/Header.tsx +255 -0
  21. package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +198 -0
  22. package/marketplace/plugins/git-forge/src/panel/List.tsx +89 -0
  23. package/marketplace/plugins/git-forge/src/panel/Row.tsx +68 -0
  24. package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +94 -0
  25. package/marketplace/plugins/git-forge/src/panel/Write.tsx +236 -0
  26. package/marketplace/plugins/git-forge/src/panel/format.ts +78 -0
  27. package/marketplace/plugins/git-forge/src/panel/index.test.tsx +344 -0
  28. package/marketplace/plugins/git-forge/src/panel/index.tsx +193 -0
  29. package/marketplace/plugins/git-forge/src/panel/use-forge.ts +250 -0
  30. package/marketplace/plugins/git-forge/src/panel/write.test.tsx +269 -0
  31. package/marketplace/plugins/git-forge/src/protocol.ts +308 -0
  32. package/marketplace/plugins/git-forge/src/server/adapters.test.ts +274 -0
  33. package/marketplace/plugins/git-forge/src/server/bitbucket.ts +307 -0
  34. package/marketplace/plugins/git-forge/src/server/capabilities.test.ts +116 -0
  35. package/marketplace/plugins/git-forge/src/server/capabilities.ts +105 -0
  36. package/marketplace/plugins/git-forge/src/server/ci.test.ts +88 -0
  37. package/marketplace/plugins/git-forge/src/server/ci.ts +118 -0
  38. package/marketplace/plugins/git-forge/src/server/context.ts +76 -0
  39. package/marketplace/plugins/git-forge/src/server/diff.test.ts +127 -0
  40. package/marketplace/plugins/git-forge/src/server/diff.ts +120 -0
  41. package/marketplace/plugins/git-forge/src/server/filters.test.ts +138 -0
  42. package/marketplace/plugins/git-forge/src/server/filters.ts +138 -0
  43. package/marketplace/plugins/git-forge/src/server/forges.test.ts +235 -0
  44. package/marketplace/plugins/git-forge/src/server/gitea.ts +296 -0
  45. package/marketplace/plugins/git-forge/src/server/github-extras.ts +92 -0
  46. package/marketplace/plugins/git-forge/src/server/github.ts +320 -0
  47. package/marketplace/plugins/git-forge/src/server/gitlab-detail.ts +207 -0
  48. package/marketplace/plugins/git-forge/src/server/gitlab.test.ts +195 -0
  49. package/marketplace/plugins/git-forge/src/server/gitlab.ts +176 -0
  50. package/marketplace/plugins/git-forge/src/server/http.test.ts +270 -0
  51. package/marketplace/plugins/git-forge/src/server/http.ts +329 -0
  52. package/marketplace/plugins/git-forge/src/server/map.ts +120 -0
  53. package/marketplace/plugins/git-forge/src/server/registry.ts +47 -0
  54. package/marketplace/plugins/git-forge/src/server/remote.test.ts +146 -0
  55. package/marketplace/plugins/git-forge/src/server/remote.ts +188 -0
  56. package/marketplace/plugins/git-forge/src/server/scope-probe.test.ts +98 -0
  57. package/marketplace/plugins/git-forge/src/server/scope-probe.ts +128 -0
  58. package/marketplace/plugins/git-forge/src/server/scope.ts +66 -0
  59. package/marketplace/plugins/git-forge/src/server/test-context.ts +67 -0
  60. package/marketplace/plugins/git-forge/src/server/test-host.ts +51 -0
  61. package/marketplace/plugins/git-forge/src/server/token.test.ts +107 -0
  62. package/marketplace/plugins/git-forge/src/server/token.ts +139 -0
  63. package/marketplace/plugins/git-forge/src/server/write-http.test.ts +127 -0
  64. package/marketplace/plugins/git-forge/src/server/write-http.ts +110 -0
  65. package/marketplace/plugins/git-forge/src/server/writes.test.ts +218 -0
  66. package/marketplace/plugins/git-forge/src/server/writes.ts +313 -0
  67. package/marketplace/plugins/git-forge/src/server.ts +284 -0
  68. package/marketplace/plugins/git-forge/tsconfig.json +16 -0
  69. package/marketplace/plugins/session-info/package.json +4 -2
  70. package/marketplace/plugins/stats/package.json +4 -2
  71. package/package.json +6 -1
  72. package/src/client/components/common/code-surface/blame-hover.ts +188 -0
  73. package/src/client/components/common/code-surface/blame-panel.test.ts +304 -0
  74. package/src/client/components/common/code-surface/blame-panel.ts +306 -0
  75. package/src/client/components/common/code-surface/blame.test.ts +303 -0
  76. package/src/client/components/common/code-surface/blame.ts +227 -0
  77. package/src/client/components/common/code-surface/conflict-markers.test.ts +135 -0
  78. package/src/client/components/common/code-surface/conflict-markers.ts +144 -0
  79. package/src/client/components/common/code-surface/documents.ts +48 -1
  80. package/src/client/components/common/code-surface/extensions.test.ts +4 -0
  81. package/src/client/components/common/code-surface/extensions.ts +44 -0
  82. package/src/client/components/common/code-surface/fold-stack.test.ts +4 -0
  83. package/src/client/components/common/code-surface/indent.test.ts +5 -0
  84. package/src/client/components/common/code-surface/index.tsx +16 -2
  85. package/src/client/components/common/code-surface/lint-parsers.test.ts +109 -0
  86. package/src/client/components/common/code-surface/lint-parsers.ts +134 -0
  87. package/src/client/components/common/code-surface/lint.test.ts +101 -0
  88. package/src/client/components/common/code-surface/lint.ts +85 -0
  89. package/src/client/components/common/code-surface/props.ts +17 -0
  90. package/src/client/components/common/code-surface/surface-failures.test.ts +132 -0
  91. package/src/client/components/common/code-surface/theme.ts +71 -0
  92. package/src/client/components/common/header-controls/index.test.tsx +1 -1
  93. package/src/client/components/common/header-controls/plugin-entry.test.tsx +1 -1
  94. package/src/client/components/common/header-controls/shell-chrome.test.tsx +1 -1
  95. package/src/client/components/common/provider-icon/Plate.tsx +88 -0
  96. package/src/client/components/common/provider-icon/index.tsx +55 -11
  97. package/src/client/components/layout/session-sidebar/SessionsView.tsx +5 -2
  98. package/src/client/components/mobile/SessionSidebar.tsx +2 -10
  99. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +6 -0
  100. package/src/client/components/mobile/mobile-right-sidebar/StatusBar.tsx +8 -0
  101. package/src/client/components/settings/categories/AppearanceSettings.tsx +3 -0
  102. package/src/client/components/settings/categories/ProviderSettings.tsx +43 -41
  103. package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +97 -0
  104. package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +106 -54
  105. package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +14 -1
  106. package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +39 -150
  107. package/src/client/components/settings/categories/panel-plugins/Meta.test.tsx +143 -0
  108. package/src/client/components/settings/categories/panel-plugins/Meta.tsx +157 -0
  109. package/src/client/components/settings/categories/panel-plugins/Placement.test.tsx +149 -0
  110. package/src/client/components/settings/categories/panel-plugins/Placement.tsx +99 -0
  111. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +270 -0
  112. package/src/client/components/settings/categories/panel-plugins/Section.tsx +11 -3
  113. package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +25 -0
  114. package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +135 -80
  115. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +51 -21
  116. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +175 -0
  117. package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +275 -0
  118. package/src/client/components/settings/categories/provider-settings/Header.tsx +40 -9
  119. package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +142 -160
  120. package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
  121. package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +84 -46
  122. package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +217 -102
  123. package/src/client/components/settings/categories/provider-settings/PresetPicker.tsx +5 -2
  124. package/src/client/components/settings/categories/provider-settings/SidebarList.plugin.test.ts +3 -3
  125. package/src/client/components/settings/categories/provider-settings/SidebarList.tsx +158 -102
  126. package/src/client/components/settings/categories/provider-settings/auth-section.test.tsx +135 -0
  127. package/src/client/components/settings/categories/provider-settings/groups.test.ts +98 -0
  128. package/src/client/components/settings/categories/provider-settings/groups.ts +108 -0
  129. package/src/client/components/settings/categories/provider-settings/layout.test.tsx +325 -0
  130. package/src/client/components/settings/categories/provider-settings/model-dialogs.test.tsx +135 -0
  131. package/src/client/components/settings/categories/provider-settings/preset-picker.test.tsx +73 -0
  132. package/src/client/components/settings/categories/usage-settings/ProviderCard.tsx +22 -2
  133. package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +2 -0
  134. package/src/client/components/settings/categories/usage-settings/SidebarList.tsx +16 -6
  135. package/src/client/components/settings/categories/usage-settings/providers.ts +3 -0
  136. package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +19 -0
  137. package/src/client/components/settings/categories/usage-settings/usage-icons.test.tsx +143 -0
  138. package/src/client/components/workspace/chat-timeline/MinimapShortcuts.test.ts +2 -1
  139. package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +23 -19
  140. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +23 -19
  141. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +20 -18
  142. package/src/client/components/workspace/chat-timeline/chat-input/compact.test.tsx +19 -6
  143. package/src/client/components/workspace/chat-timeline/index.tsx +7 -16
  144. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +100 -0
  145. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +3 -47
  146. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +8 -1
  147. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-test-util.ts +62 -0
  148. package/src/client/components/workspace/diff-panel/HunkStepper.tsx +62 -0
  149. package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +29 -0
  150. package/src/client/components/workspace/diff-panel/Toolbar.tsx +32 -1
  151. package/src/client/components/workspace/diff-panel/changes.ts +69 -0
  152. package/src/client/components/workspace/diff-panel/chunks.ts +85 -0
  153. package/src/client/components/workspace/diff-panel/index.tsx +21 -1
  154. package/src/client/components/workspace/diff-panel/merge.test.ts +145 -0
  155. package/src/client/components/workspace/diff-panel/merge.ts +63 -68
  156. package/src/client/components/workspace/editor/EditorDropOverlay.tsx +6 -1
  157. package/src/client/components/workspace/editor/FileDocument.tsx +51 -1
  158. package/src/client/components/workspace/editor/FilePane.tsx +25 -1
  159. package/src/client/components/workspace/editor/StatusBar.tsx +19 -0
  160. package/src/client/components/workspace/editor/Toolbar.tsx +29 -5
  161. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +86 -0
  162. package/src/client/components/workspace/editor/toolbar-clusters.tsx +48 -16
  163. package/src/client/components/workspace/editor/viewers/bytes.ts +16 -0
  164. package/src/client/components/workspace/git-panel/index.test.ts +46 -1
  165. package/src/client/components/workspace/git-panel/index.tsx +11 -38
  166. package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +66 -0
  167. package/src/client/components/workspace/model-dropdown/Item.tsx +71 -62
  168. package/src/client/components/workspace/model-dropdown/Section.tsx +31 -14
  169. package/src/client/components/workspace/model-dropdown/collapsed.ts +72 -0
  170. package/src/client/components/workspace/model-dropdown/index.tsx +42 -19
  171. package/src/client/components/workspace/model-dropdown/refresh.test.tsx +260 -0
  172. package/src/client/components/workspace/model-dropdown/trigger.test.ts +34 -0
  173. package/src/client/components/workspace/model-dropdown/use-catalog.ts +13 -2
  174. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +19 -3
  175. package/src/client/hooks/chat/omp/folder-auto-expand.ts +113 -0
  176. package/src/client/hooks/chat/omp/index.ts +20 -0
  177. package/src/client/hooks/chat/omp/pending-rows.ts +21 -0
  178. package/src/client/hooks/chat/omp/pending-sessions.test.ts +16 -1
  179. package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +102 -0
  180. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +21 -1
  181. package/src/client/hooks/chat/omp/stream.ts +8 -1
  182. package/src/client/hooks/chat/timeline/index.ts +1 -1
  183. package/src/client/hooks/chat/timeline/new-chat-open.ts +60 -0
  184. package/src/client/hooks/editor/blame-settings.ts +67 -0
  185. package/src/client/hooks/editor/blame.test.ts +272 -0
  186. package/src/client/hooks/editor/blame.ts +232 -0
  187. package/src/client/hooks/editor/file-editor-types.ts +23 -0
  188. package/src/client/hooks/editor/save-file.test.ts +20 -0
  189. package/src/client/hooks/editor/use-editor-drop.test-util.ts +198 -0
  190. package/src/client/hooks/editor/use-editor-drop.test.ts +70 -175
  191. package/src/client/hooks/editor/use-editor-drop.ts +19 -36
  192. package/src/client/hooks/editor/use-file-editor.ts +7 -1
  193. package/src/client/hooks/settings/providers/actions.ts +90 -194
  194. package/src/client/hooks/settings/providers/api.ts +7 -1
  195. package/src/client/hooks/settings/providers/index.ts +171 -59
  196. package/src/client/hooks/settings/providers/login.test.ts +79 -0
  197. package/src/client/hooks/settings/providers/login.ts +276 -0
  198. package/src/client/hooks/settings/providers/messages.ts +28 -0
  199. package/src/client/hooks/settings/providers/model-actions.ts +178 -0
  200. package/src/client/hooks/ui/editor-error-toast.ts +47 -0
  201. package/src/client/hooks/ui/open-file.ts +7 -0
  202. package/src/client/hooks/ui/toasts.ts +7 -0
  203. package/src/client/hooks/workspace/file-tabs.ts +4 -1
  204. package/src/client/hooks/workspace/folder-expansion.test.ts +62 -0
  205. package/src/client/hooks/workspace/folder-expansion.ts +33 -0
  206. package/src/client/hooks/workspace/git-action-outcome.ts +86 -0
  207. package/src/client/hooks/workspace/git-actions.ts +29 -2
  208. package/src/client/hooks/workspace/plugin-contributions.test.ts +117 -0
  209. package/src/client/hooks/workspace/plugin-contributions.ts +146 -0
  210. package/src/client/lib/editor-errors.test.ts +85 -0
  211. package/src/client/lib/editor-errors.ts +71 -0
  212. package/src/client/lib/fs/resolve-open.test.ts +125 -0
  213. package/src/client/lib/fs/resolve-open.ts +90 -0
  214. package/src/client/lib/git/action-message.test.ts +82 -0
  215. package/src/client/lib/git/action-message.ts +160 -0
  216. package/src/client/lib/launch/device-files.test.ts +160 -0
  217. package/src/client/lib/launch/device-files.ts +197 -0
  218. package/src/client/lib/native/open-paths.test.ts +140 -0
  219. package/src/client/lib/native/open-paths.ts +157 -0
  220. package/src/client/lib/plugins/bootstrap.test.ts +1 -1
  221. package/src/client/main.tsx +20 -0
  222. package/src/server/db.server.test.ts +39 -0
  223. package/src/server/db.server.ts +21 -2
  224. package/src/server/lib/db/schema.ts +2 -0
  225. package/src/server/lib/fs/external-roots.test.ts +100 -0
  226. package/src/server/lib/fs/external-roots.ts +101 -0
  227. package/src/server/lib/fs/git-actions-branch.ts +15 -2
  228. package/src/server/lib/fs/git-actions-shared.ts +24 -0
  229. package/src/server/lib/fs/git-actions-sync.test.ts +18 -7
  230. package/src/server/lib/fs/git-actions-worktree.ts +5 -1
  231. package/src/server/lib/fs/git-blame.test.ts +206 -0
  232. package/src/server/lib/fs/git-blame.ts +189 -0
  233. package/src/server/lib/fs/root.ts +14 -0
  234. package/src/server/lib/http/same-origin.ts +28 -7
  235. package/src/server/lib/models/catalog.server.ts +230 -0
  236. package/src/server/lib/models/catalog.test.ts +83 -0
  237. package/src/server/lib/models/credential-origin.server.ts +108 -0
  238. package/src/server/lib/models/credential-origin.test.ts +132 -0
  239. package/src/server/lib/models/provider-icon-fetch.ts +115 -0
  240. package/src/server/lib/models/provider-icon-parse.test.ts +134 -0
  241. package/src/server/lib/models/provider-icon-parse.ts +139 -0
  242. package/src/server/lib/models/provider-icon-store.server.ts +118 -0
  243. package/src/server/lib/models/provider-icon-store.test.ts +107 -0
  244. package/src/server/lib/models/provider-icon.server.ts +209 -0
  245. package/src/server/lib/models/provider-items.server.ts +211 -37
  246. package/src/server/lib/models/provider-items.test.ts +201 -0
  247. package/src/server/lib/models/provider-registry.server.test.ts +27 -9
  248. package/src/server/lib/models/provider-registry.server.ts +160 -67
  249. package/src/server/lib/models/registry.server.test.ts +3 -3
  250. package/src/server/lib/models/registry.server.ts +8 -0
  251. package/src/server/lib/omp/config/definitions.test.ts +5 -4
  252. package/src/server/lib/omp/config/models-config.ts +42 -0
  253. package/src/server/lib/omp/config/provider-entry.test.ts +205 -0
  254. package/src/server/lib/omp/config/provider-entry.ts +197 -0
  255. package/src/server/lib/omp/config/provider-seeds.ts +10 -0
  256. package/src/server/lib/omp/core/models-json.ts +69 -0
  257. package/src/server/lib/omp/session/messages.ts +17 -3
  258. package/src/server/lib/omp/session/sidebar-data.canonical.test.ts +13 -3
  259. package/src/server/lib/panels/bundled-catalog.server.ts +7 -0
  260. package/src/server/lib/panels/catalog-offers.server.ts +68 -0
  261. package/src/server/lib/panels/git-update.server.test.ts +14 -0
  262. package/src/server/lib/panels/git-update.server.ts +63 -1
  263. package/src/server/lib/panels/manifest.test.ts +65 -0
  264. package/src/server/lib/panels/manifest.ts +55 -1
  265. package/src/server/lib/panels/offers.server.test.ts +191 -0
  266. package/src/server/lib/panels/offers.server.ts +108 -0
  267. package/src/server/lib/panels/registry.server.test.ts +35 -1
  268. package/src/server/lib/panels/registry.server.ts +51 -142
  269. package/src/server/lib/panels/scan.server.ts +162 -0
  270. package/src/server/lib/route-adapter.ts +13 -2
  271. package/src/server/lib/tray/tray.test.ts +2 -1
  272. package/src/server/lib/usage/providers.server.ts +4 -1
  273. package/src/server/routes/chat/session.ts +7 -1
  274. package/src/server/routes/fs/git-blame-loader.test.ts +146 -0
  275. package/src/server/routes/fs/git.ts +17 -0
  276. package/src/server/routes/fs/grant.test.ts +135 -0
  277. package/src/server/routes/fs/grant.ts +79 -0
  278. package/src/server/routes/fs/index.ts +2 -0
  279. package/src/server/routes/fs/scope.ts +34 -17
  280. package/src/server/routes/omp/login.ts +41 -14
  281. package/src/server/routes/omp/routes.test.ts +23 -10
  282. package/src/server/routes/settings/index.ts +8 -0
  283. package/src/server/routes/settings/provider-entry.ts +108 -0
  284. package/src/server/routes/settings/provider-icon.ts +99 -0
  285. package/src/server/routes/settings/provider-model.ts +4 -1
  286. package/src/server/routes/settings/provider-refresh.ts +87 -0
  287. package/src/server/routes/settings/providers.ts +31 -2
  288. package/src/shared/lib/chat/omp/fold.test.ts +34 -0
  289. package/src/shared/lib/chat/omp/tool-frames.test.ts +20 -0
  290. package/src/shared/lib/chat/omp/tool-frames.ts +5 -1
  291. package/src/shared/lib/chat/omp/tool-results.ts +29 -3
  292. package/src/shared/lib/chat/tool/wait-facts.ts +4 -0
  293. package/src/shared/lib/fs/git-blame.test.ts +266 -0
  294. package/src/shared/lib/fs/git-blame.ts +246 -0
  295. package/src/shared/lib/git/url.ts +18 -0
  296. package/src/shared/lib/markdown/sanitize.test.ts +57 -0
  297. package/src/shared/lib/markdown/sanitize.ts +30 -7
  298. package/src/shared/lib/models/provider/connection.ts +135 -0
  299. package/src/shared/lib/models/provider/dialect.test.ts +4 -2
  300. package/src/shared/lib/models/provider/dialect.ts +76 -6
  301. package/src/shared/lib/models/provider/models.ts +2 -0
  302. package/src/shared/lib/models/provider/origin.ts +94 -0
  303. package/src/shared/lib/models/provider/provider-ui.test.ts +7 -0
  304. package/src/shared/lib/models/server-cache.ts +8 -3
  305. package/src/shared/lib/omp/session/messages-map-pending.test.ts +110 -0
  306. package/src/shared/lib/omp/session/messages-map.ts +34 -2
  307. package/src/shared/lib/omp/session/prewarm-misc.test.ts +7 -90
  308. package/src/shared/lib/omp/session/prewarm.test.ts +133 -0
  309. package/src/shared/lib/omp/session/prewarm.ts +23 -1
  310. package/src/shared/lib/omp/session/wait.test.ts +28 -0
  311. package/src/shared/lib/omp/session/wait.ts +38 -3
  312. package/src/shared/lib/panels/slot-labels.test.ts +61 -0
  313. package/src/shared/lib/panels/slot-labels.ts +133 -0
  314. package/src/shared/lib/workspace/panel-ids.ts +11 -0
  315. package/src/shared/types/fs.ts +6 -0
  316. package/src/shared/types/index.ts +1 -0
  317. package/src/shared/types/models.ts +12 -0
  318. package/src/shared/types/panels-registry.ts +277 -0
  319. package/src/shared/types/panels.ts +46 -213
  320. package/src/shared/types/settings/provider.ts +58 -0
  321. package/src/shared/types/settings/usage.ts +10 -0
  322. package/src/test-support/pristine-globals.ts +7 -0
  323. package/dist/client/static/js/index-bq6qeayr.css +0 -1
  324. package/src/client/components/settings/categories/provider-settings/ReconnectModal.tsx +0 -184
@@ -0,0 +1,308 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * What the two halves of this plugin say to each other.
8
+ *
9
+ * A forge is several vendors with one vocabulary, so the shapes here are OURS:
10
+ * the panel never sees a GitHub issue object or a GitLab merge-request object,
11
+ * and the adapters are the only place either spelling exists. That is what lets
12
+ * the sidebar say "Merge requests" on GitLab and "Pull requests" on GitHub from
13
+ * one component, and it is why a section is named for the JOB rather than for
14
+ * the vendor's word for it.
15
+ *
16
+ * Three properties are load-bearing:
17
+ *
18
+ * - **One read answers ALL THREE sections.** The sidebar is the selector, and a
19
+ * selector with no counts is a guess; asking three times per switch would make
20
+ * browsing cost three round trips per click. So `list` fetches all three and
21
+ * the panel switches locally.
22
+ * - **A section that fails does not take the others with it.** A releases
23
+ * endpoint that answers 404 (a GitLab project with no releases) must not blank
24
+ * the issue list, so a partial read carries `notes` rather than failing.
25
+ * - **Nothing here names a token.** The credential lives on the server; the panel
26
+ * only ever learns which SOURCE it came from.
27
+ */
28
+
29
+ /** The APIs this plugin speaks. */
30
+ export type ForgeProvider = 'github' | 'gitlab' | 'gitea' | 'bitbucket';
31
+
32
+ /** What the panel's sidebar lists. `pulls` is PRs on GitHub, MRs on GitLab. */
33
+ export type ForgeSection = 'issues' | 'pulls' | 'releases';
34
+
35
+ /** The state filter a read carries. Releases ignore it. */
36
+ export type ForgeState = 'open' | 'closed' | 'all';
37
+
38
+ /**
39
+ * A row's display state.
40
+ *
41
+ * `draft` is a PR/MR that is still open, and `prerelease` is a release that is
42
+ * published but flagged — both are shown as their own badge because collapsing
43
+ * them into `open`/`published` hides the one fact a reviewer checks first.
44
+ */
45
+ export type ForgeItemState = 'open' | 'closed' | 'merged' | 'draft' | 'published' | 'prerelease';
46
+
47
+ /**
48
+ * The filter a read carries beyond the state.
49
+ *
50
+ * `mine` is a boolean rather than a username because every host has its own way
51
+ * of saying "the authenticated user" and only one of them accepts a literal:
52
+ * GitHub's search takes `assignee:@me`, GitLab takes `scope=assigned_to_me`.
53
+ * Sending an id would mean resolving the viewer first, on every read.
54
+ */
55
+ export interface ForgeFilter {
56
+ state: ForgeState;
57
+ /** Only items assigned to the authenticated user. */
58
+ mine: boolean;
59
+ /** One label, matched exactly. Empty means none. */
60
+ label: string;
61
+ /** Free text, matched by the host's own search. */
62
+ query: string;
63
+ }
64
+
65
+ export interface ForgeLabel {
66
+ name: string;
67
+ /** Six hex digits without `#`, as GitHub reports it. Null when the host has none. */
68
+ color: string | null;
69
+ }
70
+
71
+ /**
72
+ * A pipeline's verdict, normalized across hosts.
73
+ *
74
+ * Detail-only, deliberately. No host puts a pipeline on a LIST response:
75
+ * measured on GitLab, `head_pipeline` is `failed` on the single merge request
76
+ * and `null` on every row of the collection, and GitHub's PR list carries no
77
+ * checks at all. A row badge would therefore cost one request per row — twenty
78
+ * extra reads for a page nobody has opened — so the badge lives where it is
79
+ * already free: the item's own page.
80
+ */
81
+ export type ForgeCiState = 'success' | 'failure' | 'pending' | 'neutral';
82
+
83
+ /** The CI verdict for an item, when the host reports one. */
84
+ export interface ForgeCi {
85
+ state: ForgeCiState;
86
+ /** What the host called it (`success`, `FAILURE`, `passed`), for the tooltip. */
87
+ label: string;
88
+ url: string | null;
89
+ }
90
+
91
+ /** One issue, pull request, merge request or release. */
92
+ export interface ForgeItem {
93
+ /** Stable within its section: the number as a string, or a release tag. */
94
+ id: string;
95
+ /** The issue/PR number, or null for a release. */
96
+ number: number | null;
97
+ title: string;
98
+ state: ForgeItemState;
99
+ author: string;
100
+ /** ISO timestamp the host reports as last activity. */
101
+ updatedAt: string;
102
+ /** The page on the host. */
103
+ url: string;
104
+ labels: ForgeLabel[];
105
+ comments: number;
106
+ /** A release's tag; null for the other sections. */
107
+ tag: string | null;
108
+ }
109
+
110
+ export interface ForgeSectionData {
111
+ items: ForgeItem[];
112
+ /** The host returned a full page, so there may be more than this. */
113
+ truncated: boolean;
114
+ /** How many the host says exist, when it says. */
115
+ total: number | null;
116
+ }
117
+
118
+ /** One read of all three sections. */
119
+ export interface ForgeList {
120
+ provider: ForgeProvider;
121
+ host: string;
122
+ /** `owner/name`, subgroups included. */
123
+ slug: string;
124
+ webUrl: string;
125
+ filter: ForgeFilter;
126
+ sections: Record<ForgeSection, ForgeSectionData>;
127
+ /** Non-fatal sentences: a section that failed, an anonymous read. */
128
+ notes: string[];
129
+ }
130
+
131
+ export interface ForgeComment {
132
+ id: string;
133
+ author: string;
134
+ body: string;
135
+ createdAt: string;
136
+ url: string | null;
137
+ /** The host's own audit note ("changed the description"), not a reply. */
138
+ system: boolean;
139
+ /** The author is a bot or an app. */
140
+ bot: boolean;
141
+ }
142
+
143
+ /** One file a change touches. */
144
+ export interface ForgeFile {
145
+ path: string;
146
+ status: string;
147
+ additions: number;
148
+ deletions: number;
149
+ /** The unified hunk text, when the host sends it. */
150
+ patch: string;
151
+ }
152
+
153
+ /** One commit in a change. */
154
+ export interface ForgeCommit {
155
+ sha: string;
156
+ message: string;
157
+ author: string;
158
+ at: string;
159
+ }
160
+
161
+ /** One labelled fact about an item, e.g. `base ← head` or `+12 −3`. */
162
+ export interface ForgeFact {
163
+ label: string;
164
+ value: string;
165
+ }
166
+
167
+ /**
168
+ * What the credential and the host together allow.
169
+ *
170
+ * Derived per detail read rather than stored: a read-only token and a public
171
+ * repository are the same thing from the panel's side, and a button that can
172
+ * only fail is worse than no button.
173
+ */
174
+ export interface ForgeCapabilities {
175
+ comment: boolean;
176
+ state: boolean;
177
+ review: boolean;
178
+ merge: boolean;
179
+ }
180
+
181
+ export interface ForgeDetail {
182
+ item: ForgeItem;
183
+ /** Markdown, exactly as the host stores it. */
184
+ body: string;
185
+ comments: ForgeComment[];
186
+ facts: ForgeFact[];
187
+ files: ForgeFile[];
188
+ commits: ForgeCommit[];
189
+ ci: ForgeCi | null;
190
+ capabilities: ForgeCapabilities;
191
+ notes: string[];
192
+ }
193
+
194
+ export interface ForgeListInput {
195
+ root: string;
196
+ repo: string;
197
+ filter: ForgeFilter;
198
+ }
199
+
200
+ export interface ForgeDetailInput {
201
+ root: string;
202
+ repo: string;
203
+ section: ForgeSection;
204
+ id: string;
205
+ }
206
+
207
+ /** One write the panel may ask for. */
208
+ export type ForgeWrite =
209
+ | { kind: 'comment'; body: string }
210
+ | { kind: 'state'; state: 'open' | 'closed' }
211
+ | { kind: 'review'; verdict: 'approve' | 'request_changes'; body: string }
212
+ | { kind: 'merge'; method: 'merge' | 'squash' | 'rebase' };
213
+
214
+ export interface ForgeWriteInput extends ForgeDetailInput {
215
+ write: ForgeWrite;
216
+ }
217
+
218
+ /** What a write answers: the item as it now stands, and any note worth reading. */
219
+ export interface ForgeWriteResult {
220
+ item: ForgeItem;
221
+ message: string;
222
+ }
223
+
224
+ /** The credential as the panel may see it: which source, and whether it can write. */
225
+ export interface ForgeCredential {
226
+ source: 'setting' | 'environment' | 'cli' | 'none';
227
+ /** A credential is present at all. */
228
+ present: boolean;
229
+ /** The host accepted it for a write-capable scope, when it was checked. */
230
+ writeScope: boolean | null;
231
+ }
232
+
233
+ /**
234
+ * How much is waiting on the reader, for the navbar readout.
235
+ *
236
+ * Two numbers and no list: a readout is one line in a header, and a payload it
237
+ * has to narrow is a payload the server could have narrowed. `null` means the
238
+ * count could not be read, which is different from zero and is drawn as `—`.
239
+ */
240
+ export interface ForgeCounts {
241
+ /** Open issues assigned to the authenticated user. */
242
+ issues: number | null;
243
+ /** Open pull / merge requests assigned to the authenticated user. */
244
+ pulls: number | null;
245
+ /** The host, for the readout's tooltip. */
246
+ host: string;
247
+ /** Why a count is null, when it is. */
248
+ note: string | null;
249
+ }
250
+
251
+ /** The method names, in one place so a typo is a compile error on both sides. */
252
+ export const RPC = {
253
+ list: 'list',
254
+ detail: 'detail',
255
+ write: 'write',
256
+ credential: 'credential',
257
+ counts: 'counts',
258
+ } as const;
259
+
260
+ export const SECTIONS: readonly ForgeSection[] = ['issues', 'pulls', 'releases'];
261
+
262
+ export function isSection(value: unknown): value is ForgeSection {
263
+ return value === 'issues' || value === 'pulls' || value === 'releases';
264
+ }
265
+
266
+ export function isState(value: unknown): value is ForgeState {
267
+ return value === 'open' || value === 'closed' || value === 'all';
268
+ }
269
+
270
+ /** An empty section, for a read that has not answered yet or failed. */
271
+ export function emptySection(): ForgeSectionData {
272
+ return { items: [], truncated: false, total: null };
273
+ }
274
+
275
+ /**
276
+ * No filter: open, everything, no label, no text.
277
+ *
278
+ * ONE frozen object rather than a factory, and that is load-bearing. The panel
279
+ * passes this to `useSessionState` as its FALLBACK, and that hook's setters are
280
+ * `useCallback`s over `[sessionId, key, fallback]` — so a fresh object per render
281
+ * gives the setter a new identity per render, which re-arms the effect that
282
+ * writes it, which renders again. Measured: the panel mounted and never painted,
283
+ * with the test run hitting its timeout instead of failing an assertion.
284
+ *
285
+ * Every writer replaces the object immutably (`{ ...filter, state }`), so sharing
286
+ * one instance cannot leak a mutation between readers.
287
+ */
288
+ export const DEFAULT_FILTER: ForgeFilter = Object.freeze({
289
+ state: 'open',
290
+ mine: false,
291
+ label: '',
292
+ query: '',
293
+ });
294
+
295
+ /** A fresh copy, for a caller that needs one (a test fixture, a merge base). */
296
+ export function defaultFilter(): ForgeFilter {
297
+ return { ...DEFAULT_FILTER };
298
+ }
299
+
300
+ /** Whether a filter is anything but the default, for a "clear" control. */
301
+ export function filterIsDefault(filter: ForgeFilter): boolean {
302
+ return filter.state === 'open' && !filter.mine && !filter.label.trim() && !filter.query.trim();
303
+ }
304
+
305
+ /** The capabilities a read-only view has: none of them. */
306
+ export function readOnly(): ForgeCapabilities {
307
+ return { comment: false, state: false, review: false, merge: false };
308
+ }
@@ -0,0 +1,274 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ /**
7
+ * GitHub's adapter, over recorded bodies.
8
+ *
9
+ * A live host cannot be part of a test: it needs a credential, a network and a
10
+ * repository that does not change. So the mapping is driven against the exact
11
+ * JSON the vendor documents, which is the only part of an adapter that can be
12
+ * wrong — the fetching is `http.ts`'s own subject.
13
+ *
14
+ * The cases below are the ones that silently mislead rather than fail:
15
+ *
16
+ * - **A pull request appears in the ISSUES response.** Filtering it out of a
17
+ * full page left ZERO issues on a real repository, which is why the issues
18
+ * section reads the search endpoint instead.
19
+ * - **`merged_at` and `draft` are states of their own.** Calling a merged PR
20
+ * "closed" hides what happened; calling a draft "open" hides what it is.
21
+ * - **A release is keyed by its tag**, and a prerelease says so.
22
+ */
23
+
24
+ import { describe, expect, test } from 'bun:test';
25
+
26
+ import { detailGithub, isBotUser, listGithub } from './github';
27
+ import { host } from './test-host';
28
+ import { hostContext, openFilter } from './test-context';
29
+
30
+ const github = (fetchImpl: typeof fetch, overrides: Parameters<typeof hostContext>[2] = {}) =>
31
+ hostContext('github', fetchImpl, overrides);
32
+
33
+ describe('listGithub', () => {
34
+ test('a pull request in the issues response is not an issue', async () => {
35
+ const { fetchImpl } = host({
36
+ '/search/issues': {
37
+ total_count: 1,
38
+ items: [
39
+ { number: 7, title: 'Real issue', state: 'open', user: { login: 'ana' }, updated_at: '2026-01-01' },
40
+ {
41
+ number: 8,
42
+ title: 'A PR',
43
+ state: 'open',
44
+ user: { login: 'bo' },
45
+ pull_request: { url: 'x' },
46
+ updated_at: '2026-01-02',
47
+ },
48
+ ],
49
+ },
50
+ '/repos/kabmo-labs/kabmo/pulls': [],
51
+ '/repos/kabmo-labs/kabmo/releases': [],
52
+ });
53
+
54
+ const list = await listGithub(github(fetchImpl));
55
+ expect(list.sections.issues.items.map((item) => item.number)).toEqual([7]);
56
+ });
57
+
58
+ test('a pull request reports merged and draft as their own states', async () => {
59
+ const { fetchImpl } = host({
60
+ '/search/issues': {
61
+ total_count: 3,
62
+ items: [
63
+ { number: 1, title: 'Merged', state: 'closed', pull_request: { merged_at: '2026-01-01' } },
64
+ { number: 2, title: 'Draft', state: 'open', draft: true },
65
+ { number: 3, title: 'Open', state: 'open' },
66
+ ],
67
+ },
68
+ '/repos/kabmo-labs/kabmo/releases': [],
69
+ });
70
+
71
+ const list = await listGithub(github(fetchImpl));
72
+ expect(list.sections.pulls.items.map((item) => item.state)).toEqual(['merged', 'draft', 'open']);
73
+ });
74
+
75
+ test('a release is keyed by its tag and a prerelease says so', async () => {
76
+ const { fetchImpl } = host({
77
+ '/search/issues': { total_count: 0, items: [] },
78
+ '/repos/kabmo-labs/kabmo/releases': [
79
+ { tag_name: 'v1.0.0', name: 'First', published_at: '2026-01-01T00:00:00Z', author: { login: 'a' } },
80
+ { tag_name: 'v2.0.0-rc', prerelease: true, published_at: '2026-02-01T00:00:00Z' },
81
+ ],
82
+ });
83
+
84
+ const list = await listGithub(github(fetchImpl));
85
+ expect(list.sections.releases.items.map((item) => item.id)).toEqual(['v1.0.0', 'v2.0.0-rc']);
86
+ expect(list.sections.releases.items.map((item) => item.state)).toEqual(['published', 'prerelease']);
87
+ });
88
+
89
+ test('one section failing leaves the others readable, and says so', async () => {
90
+ const { fetchImpl } = host({
91
+ '/search/issues': { total_count: 1, items: [{ number: 1, title: 'ok', state: 'open' }] },
92
+ '/repos/kabmo-labs/kabmo/releases': { status: 403 },
93
+ });
94
+
95
+ const list = await listGithub(github(fetchImpl));
96
+ expect(list.sections.issues.items).toHaveLength(1);
97
+ expect(list.sections.releases.items).toEqual([]);
98
+ expect(list.notes.join(' ')).toContain('releases');
99
+ });
100
+
101
+ test('an anonymous read says it is anonymous', async () => {
102
+ const { fetchImpl } = host({
103
+ '/search/issues': { total_count: 0, items: [] },
104
+ '/repos/kabmo-labs/kabmo/releases': [],
105
+ });
106
+
107
+ const list = await listGithub(github(fetchImpl, { token: null }));
108
+ expect(list.notes.join(' ')).toContain('anonymously');
109
+ });
110
+
111
+ test('a full page is reported as truncated, from the host total', async () => {
112
+ const rows = Array.from({ length: 2 }, (_, index) => ({ number: index + 1, title: 't', state: 'open' }));
113
+ const { fetchImpl } = host({
114
+ '/search/issues': { total_count: 90, items: rows },
115
+ '/repos/kabmo-labs/kabmo/releases': [],
116
+ });
117
+
118
+ const list = await listGithub(github(fetchImpl, { perPage: 2 }));
119
+ expect(list.sections.issues.truncated).toBe(true);
120
+ expect(list.sections.issues.total).toBe(90);
121
+ });
122
+
123
+ test('a label list keeps the host colour and drops a bad one', async () => {
124
+ const { fetchImpl } = host({
125
+ '/search/issues': {
126
+ total_count: 1,
127
+ items: [
128
+ {
129
+ number: 1,
130
+ title: 't',
131
+ state: 'open',
132
+ labels: [{ name: 'bug', color: 'd73a4a' }, { name: 'odd', color: 'not-a-colour' }],
133
+ },
134
+ ],
135
+ },
136
+ '/repos/kabmo-labs/kabmo/releases': [],
137
+ });
138
+
139
+ const list = await listGithub(github(fetchImpl));
140
+ expect(list.sections.issues.items[0].labels).toEqual([
141
+ { name: 'bug', color: 'd73a4a' },
142
+ { name: 'odd', color: null },
143
+ ]);
144
+ });
145
+
146
+ test('the filter reaches the query', async () => {
147
+ const { asked, fetchImpl } = host({
148
+ '/search/issues': { total_count: 0, items: [] },
149
+ '/repos/kabmo-labs/kabmo/releases': [],
150
+ });
151
+ await listGithub(
152
+ github(fetchImpl, { filter: { ...openFilter(), state: 'closed', mine: true, label: 'good first issue' } }),
153
+ );
154
+ const search = asked.find((url) => url.includes('/search/issues'));
155
+ expect(search).toContain('state%3Aclosed');
156
+ expect(search).toContain('assignee%3A%40me');
157
+ // The qualifier's own quotes and space survive the encoding, which is what
158
+ // makes a two-word label one value rather than two qualifiers.
159
+ expect(decodeURIComponent(search ?? '')).toContain('label:"good first issue"');
160
+ });
161
+ });
162
+
163
+ describe('detailGithub', () => {
164
+ test('a pull request detail carries branch, diff, file and CI facts', async () => {
165
+ const { fetchImpl } = host({
166
+ '/repos/kabmo-labs/kabmo/pulls/12': {
167
+ number: 12,
168
+ title: 'Add a thing',
169
+ state: 'open',
170
+ body: 'Why this exists.',
171
+ head: { ref: 'feat/thing', sha: 'abc123', html_url: 'https://github.com/c/abc123' },
172
+ base: { ref: 'main' },
173
+ additions: 12,
174
+ deletions: 3,
175
+ changed_files: 4,
176
+ mergeable: true,
177
+ },
178
+ '/repos/kabmo-labs/kabmo/issues/12/comments': [
179
+ { id: 1, user: { login: 'ana' }, body: 'Looks good', created_at: '2026-01-01', html_url: 'u' },
180
+ { id: 2, user: { login: 'dependabot[bot]', type: 'Bot' }, body: 'Bumped', created_at: '2026-01-02' },
181
+ ],
182
+ '/repos/kabmo-labs/kabmo/commits/abc123/check-runs': {
183
+ check_runs: [
184
+ { name: 'test', status: 'completed', conclusion: 'success' },
185
+ { name: 'lint', status: 'completed', conclusion: 'failure' },
186
+ ],
187
+ },
188
+ '/repos/kabmo-labs/kabmo/pulls/12/files': [
189
+ { filename: 'src/a.ts', status: 'modified', additions: 2, deletions: 1, patch: '@@ -1 +1 @@' },
190
+ ],
191
+ '/repos/kabmo-labs/kabmo/pulls/12/commits': [
192
+ { sha: 'abc123', commit: { message: 'Add a thing\n\nbody', author: { name: 'Ana', date: '2026-01-01' } } },
193
+ ],
194
+ });
195
+
196
+ const detail = await detailGithub(github(fetchImpl), 'pulls', '12');
197
+ if ('error' in detail) throw new Error(detail.error);
198
+
199
+ expect(detail.body).toBe('Why this exists.');
200
+ expect(detail.facts).toEqual([
201
+ { label: 'branch', value: 'main ← feat/thing' },
202
+ { label: 'diff', value: '+12 −3' },
203
+ { label: 'files', value: '4' },
204
+ { label: 'mergeable', value: 'yes' },
205
+ ]);
206
+ expect(detail.comments.map((comment) => comment.author)).toEqual(['ana', 'dependabot[bot]']);
207
+ expect(detail.comments.map((comment) => comment.bot)).toEqual([false, true]);
208
+ expect(detail.ci).toEqual({ state: 'failure', label: '2 checks', url: 'https://github.com/c/abc123' });
209
+ expect(detail.files.map((file) => file.path)).toEqual(['src/a.ts']);
210
+ expect(detail.commits.map((commit) => commit.message)).toEqual(['Add a thing']);
211
+ expect(detail.capabilities).toEqual({ comment: true, state: true, review: true, merge: true });
212
+ });
213
+
214
+ test('a commit status is read when there are no check runs', async () => {
215
+ const { fetchImpl } = host({
216
+ '/repos/kabmo-labs/kabmo/pulls/13': {
217
+ number: 13,
218
+ title: 't',
219
+ state: 'open',
220
+ head: { ref: 'f', sha: 'def456' },
221
+ base: { ref: 'main' },
222
+ },
223
+ '/repos/kabmo-labs/kabmo/issues/13/comments': [],
224
+ '/repos/kabmo-labs/kabmo/commits/def456/check-runs': { check_runs: [] },
225
+ '/repos/kabmo-labs/kabmo/commits/def456/status': { state: 'pending' },
226
+ '/repos/kabmo-labs/kabmo/pulls/13/files': [],
227
+ '/repos/kabmo-labs/kabmo/pulls/13/commits': [],
228
+ });
229
+
230
+ const detail = await detailGithub(github(fetchImpl), 'pulls', '13');
231
+ if ('error' in detail) throw new Error(detail.error);
232
+ expect(detail.ci?.state).toBe('pending');
233
+ });
234
+
235
+ test('an issue has no review, merge, CI or files', async () => {
236
+ const { fetchImpl } = host({
237
+ '/repos/kabmo-labs/kabmo/issues/9': { number: 9, title: 'An issue', state: 'open', body: 'text', comments: 0 },
238
+ '/repos/kabmo-labs/kabmo/issues/9/comments': [],
239
+ });
240
+
241
+ const detail = await detailGithub(github(fetchImpl), 'issues', '9');
242
+ if ('error' in detail) throw new Error(detail.error);
243
+ expect(detail.ci).toBeNull();
244
+ expect(detail.files).toEqual([]);
245
+ expect(detail.capabilities).toEqual({ comment: true, state: true, review: false, merge: false });
246
+ });
247
+
248
+ test('a release has no comment thread', async () => {
249
+ const { asked, fetchImpl } = host({
250
+ '/repos/kabmo-labs/kabmo/releases/tags/v1': { tag_name: 'v1', name: 'One', body: 'notes' },
251
+ });
252
+
253
+ const detail = await detailGithub(github(fetchImpl), 'releases', 'v1');
254
+ if ('error' in detail) throw new Error(detail.error);
255
+ expect(detail.comments).toEqual([]);
256
+ expect(detail.capabilities).toEqual({ comment: false, state: false, review: false, merge: false });
257
+ expect(asked.some((url) => url.includes('/comments'))).toBe(false);
258
+ });
259
+
260
+ test('a failed detail read is a sentence', async () => {
261
+ const { fetchImpl } = host({});
262
+ const detail = await detailGithub(github(fetchImpl), 'issues', '404');
263
+ expect('error' in detail).toBe(true);
264
+ });
265
+ });
266
+
267
+ describe('isBotUser', () => {
268
+ test('an App account and a [bot] login are both bots', () => {
269
+ expect(isBotUser({ login: 'dependabot[bot]', type: 'Bot' })).toBe(true);
270
+ expect(isBotUser({ login: 'renovate[bot]' })).toBe(true);
271
+ expect(isBotUser({ login: 'release-bot' })).toBe(true);
272
+ expect(isBotUser({ login: 'ana', type: 'User' })).toBe(false);
273
+ });
274
+ });