@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.
- package/README.md +67 -421
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +426 -413
- package/dist/client/static/js/{index-amss8pge.js → index-0smc9gm2.js} +1123 -747
- package/dist/client/static/js/index-shexbk5f.css +1 -0
- package/marketplace/marketplace.json +13 -3
- package/marketplace/plugins/command-runner/package.json +4 -2
- package/marketplace/plugins/git-forge/README.md +219 -0
- package/marketplace/plugins/git-forge/icon.svg +20 -0
- package/marketplace/plugins/git-forge/package.json +56 -0
- package/marketplace/plugins/git-forge/src/app.tsx +82 -0
- package/marketplace/plugins/git-forge/src/command.test.ts +181 -0
- package/marketplace/plugins/git-forge/src/command.ts +119 -0
- package/marketplace/plugins/git-forge/src/header.tsx +87 -0
- package/marketplace/plugins/git-forge/src/panel/Badge.tsx +76 -0
- package/marketplace/plugins/git-forge/src/panel/Change.tsx +150 -0
- package/marketplace/plugins/git-forge/src/panel/CiBadge.tsx +51 -0
- package/marketplace/plugins/git-forge/src/panel/Credential.tsx +107 -0
- package/marketplace/plugins/git-forge/src/panel/Glyph.tsx +70 -0
- package/marketplace/plugins/git-forge/src/panel/Header.tsx +255 -0
- package/marketplace/plugins/git-forge/src/panel/ItemView.tsx +198 -0
- package/marketplace/plugins/git-forge/src/panel/List.tsx +89 -0
- package/marketplace/plugins/git-forge/src/panel/Row.tsx +68 -0
- package/marketplace/plugins/git-forge/src/panel/Sidebar.tsx +94 -0
- package/marketplace/plugins/git-forge/src/panel/Write.tsx +236 -0
- package/marketplace/plugins/git-forge/src/panel/format.ts +78 -0
- package/marketplace/plugins/git-forge/src/panel/index.test.tsx +344 -0
- package/marketplace/plugins/git-forge/src/panel/index.tsx +193 -0
- package/marketplace/plugins/git-forge/src/panel/use-forge.ts +250 -0
- package/marketplace/plugins/git-forge/src/panel/write.test.tsx +269 -0
- package/marketplace/plugins/git-forge/src/protocol.ts +308 -0
- package/marketplace/plugins/git-forge/src/server/adapters.test.ts +274 -0
- package/marketplace/plugins/git-forge/src/server/bitbucket.ts +307 -0
- package/marketplace/plugins/git-forge/src/server/capabilities.test.ts +116 -0
- package/marketplace/plugins/git-forge/src/server/capabilities.ts +105 -0
- package/marketplace/plugins/git-forge/src/server/ci.test.ts +88 -0
- package/marketplace/plugins/git-forge/src/server/ci.ts +118 -0
- package/marketplace/plugins/git-forge/src/server/context.ts +76 -0
- package/marketplace/plugins/git-forge/src/server/diff.test.ts +127 -0
- package/marketplace/plugins/git-forge/src/server/diff.ts +120 -0
- package/marketplace/plugins/git-forge/src/server/filters.test.ts +138 -0
- package/marketplace/plugins/git-forge/src/server/filters.ts +138 -0
- package/marketplace/plugins/git-forge/src/server/forges.test.ts +235 -0
- package/marketplace/plugins/git-forge/src/server/gitea.ts +296 -0
- package/marketplace/plugins/git-forge/src/server/github-extras.ts +92 -0
- package/marketplace/plugins/git-forge/src/server/github.ts +320 -0
- package/marketplace/plugins/git-forge/src/server/gitlab-detail.ts +207 -0
- package/marketplace/plugins/git-forge/src/server/gitlab.test.ts +195 -0
- package/marketplace/plugins/git-forge/src/server/gitlab.ts +176 -0
- package/marketplace/plugins/git-forge/src/server/http.test.ts +270 -0
- package/marketplace/plugins/git-forge/src/server/http.ts +329 -0
- package/marketplace/plugins/git-forge/src/server/map.ts +120 -0
- package/marketplace/plugins/git-forge/src/server/registry.ts +47 -0
- package/marketplace/plugins/git-forge/src/server/remote.test.ts +146 -0
- package/marketplace/plugins/git-forge/src/server/remote.ts +188 -0
- package/marketplace/plugins/git-forge/src/server/scope-probe.test.ts +98 -0
- package/marketplace/plugins/git-forge/src/server/scope-probe.ts +128 -0
- package/marketplace/plugins/git-forge/src/server/scope.ts +66 -0
- package/marketplace/plugins/git-forge/src/server/test-context.ts +67 -0
- package/marketplace/plugins/git-forge/src/server/test-host.ts +51 -0
- package/marketplace/plugins/git-forge/src/server/token.test.ts +107 -0
- package/marketplace/plugins/git-forge/src/server/token.ts +139 -0
- package/marketplace/plugins/git-forge/src/server/write-http.test.ts +127 -0
- package/marketplace/plugins/git-forge/src/server/write-http.ts +110 -0
- package/marketplace/plugins/git-forge/src/server/writes.test.ts +218 -0
- package/marketplace/plugins/git-forge/src/server/writes.ts +313 -0
- package/marketplace/plugins/git-forge/src/server.ts +284 -0
- package/marketplace/plugins/git-forge/tsconfig.json +16 -0
- package/marketplace/plugins/session-info/package.json +4 -2
- package/marketplace/plugins/stats/package.json +4 -2
- package/package.json +6 -1
- package/src/client/components/common/code-surface/blame-hover.ts +188 -0
- package/src/client/components/common/code-surface/blame-panel.test.ts +304 -0
- package/src/client/components/common/code-surface/blame-panel.ts +306 -0
- package/src/client/components/common/code-surface/blame.test.ts +303 -0
- package/src/client/components/common/code-surface/blame.ts +227 -0
- package/src/client/components/common/code-surface/conflict-markers.test.ts +135 -0
- package/src/client/components/common/code-surface/conflict-markers.ts +144 -0
- package/src/client/components/common/code-surface/documents.ts +48 -1
- package/src/client/components/common/code-surface/extensions.test.ts +4 -0
- package/src/client/components/common/code-surface/extensions.ts +44 -0
- package/src/client/components/common/code-surface/fold-stack.test.ts +4 -0
- package/src/client/components/common/code-surface/indent.test.ts +5 -0
- package/src/client/components/common/code-surface/index.tsx +16 -2
- package/src/client/components/common/code-surface/lint-parsers.test.ts +109 -0
- package/src/client/components/common/code-surface/lint-parsers.ts +134 -0
- package/src/client/components/common/code-surface/lint.test.ts +101 -0
- package/src/client/components/common/code-surface/lint.ts +85 -0
- package/src/client/components/common/code-surface/props.ts +17 -0
- package/src/client/components/common/code-surface/surface-failures.test.ts +132 -0
- package/src/client/components/common/code-surface/theme.ts +71 -0
- package/src/client/components/common/header-controls/index.test.tsx +1 -1
- package/src/client/components/common/header-controls/plugin-entry.test.tsx +1 -1
- package/src/client/components/common/header-controls/shell-chrome.test.tsx +1 -1
- package/src/client/components/common/provider-icon/Plate.tsx +88 -0
- package/src/client/components/common/provider-icon/index.tsx +55 -11
- package/src/client/components/layout/session-sidebar/SessionsView.tsx +5 -2
- package/src/client/components/mobile/SessionSidebar.tsx +2 -10
- package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +6 -0
- package/src/client/components/mobile/mobile-right-sidebar/StatusBar.tsx +8 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +3 -0
- package/src/client/components/settings/categories/ProviderSettings.tsx +43 -41
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +97 -0
- package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +106 -54
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +14 -1
- package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +39 -150
- package/src/client/components/settings/categories/panel-plugins/Meta.test.tsx +143 -0
- package/src/client/components/settings/categories/panel-plugins/Meta.tsx +157 -0
- package/src/client/components/settings/categories/panel-plugins/Placement.test.tsx +149 -0
- package/src/client/components/settings/categories/panel-plugins/Placement.tsx +99 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +270 -0
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +11 -3
- package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +25 -0
- package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +135 -80
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +51 -21
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +175 -0
- package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +275 -0
- package/src/client/components/settings/categories/provider-settings/Header.tsx +40 -9
- package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +142 -160
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +84 -46
- package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +217 -102
- package/src/client/components/settings/categories/provider-settings/PresetPicker.tsx +5 -2
- package/src/client/components/settings/categories/provider-settings/SidebarList.plugin.test.ts +3 -3
- package/src/client/components/settings/categories/provider-settings/SidebarList.tsx +158 -102
- package/src/client/components/settings/categories/provider-settings/auth-section.test.tsx +135 -0
- package/src/client/components/settings/categories/provider-settings/groups.test.ts +98 -0
- package/src/client/components/settings/categories/provider-settings/groups.ts +108 -0
- package/src/client/components/settings/categories/provider-settings/layout.test.tsx +325 -0
- package/src/client/components/settings/categories/provider-settings/model-dialogs.test.tsx +135 -0
- package/src/client/components/settings/categories/provider-settings/preset-picker.test.tsx +73 -0
- package/src/client/components/settings/categories/usage-settings/ProviderCard.tsx +22 -2
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +2 -0
- package/src/client/components/settings/categories/usage-settings/SidebarList.tsx +16 -6
- package/src/client/components/settings/categories/usage-settings/providers.ts +3 -0
- package/src/client/components/settings/categories/usage-settings/usage-and-picker.test.ts +19 -0
- package/src/client/components/settings/categories/usage-settings/usage-icons.test.tsx +143 -0
- package/src/client/components/workspace/chat-timeline/MinimapShortcuts.test.ts +2 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +23 -19
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +23 -19
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +20 -18
- package/src/client/components/workspace/chat-timeline/chat-input/compact.test.tsx +19 -6
- package/src/client/components/workspace/chat-timeline/index.tsx +7 -16
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +100 -0
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.test.ts +3 -47
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +8 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-test-util.ts +62 -0
- package/src/client/components/workspace/diff-panel/HunkStepper.tsx +62 -0
- package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +29 -0
- package/src/client/components/workspace/diff-panel/Toolbar.tsx +32 -1
- package/src/client/components/workspace/diff-panel/changes.ts +69 -0
- package/src/client/components/workspace/diff-panel/chunks.ts +85 -0
- package/src/client/components/workspace/diff-panel/index.tsx +21 -1
- package/src/client/components/workspace/diff-panel/merge.test.ts +145 -0
- package/src/client/components/workspace/diff-panel/merge.ts +63 -68
- package/src/client/components/workspace/editor/EditorDropOverlay.tsx +6 -1
- package/src/client/components/workspace/editor/FileDocument.tsx +51 -1
- package/src/client/components/workspace/editor/FilePane.tsx +25 -1
- package/src/client/components/workspace/editor/StatusBar.tsx +19 -0
- package/src/client/components/workspace/editor/Toolbar.tsx +29 -5
- package/src/client/components/workspace/editor/toolbar-clusters.test.ts +86 -0
- package/src/client/components/workspace/editor/toolbar-clusters.tsx +48 -16
- package/src/client/components/workspace/editor/viewers/bytes.ts +16 -0
- package/src/client/components/workspace/git-panel/index.test.ts +46 -1
- package/src/client/components/workspace/git-panel/index.tsx +11 -38
- package/src/client/components/workspace/model-dropdown/Item.plugin.test.ts +66 -0
- package/src/client/components/workspace/model-dropdown/Item.tsx +71 -62
- package/src/client/components/workspace/model-dropdown/Section.tsx +31 -14
- package/src/client/components/workspace/model-dropdown/collapsed.ts +72 -0
- package/src/client/components/workspace/model-dropdown/index.tsx +42 -19
- package/src/client/components/workspace/model-dropdown/refresh.test.tsx +260 -0
- package/src/client/components/workspace/model-dropdown/trigger.test.ts +34 -0
- package/src/client/components/workspace/model-dropdown/use-catalog.ts +13 -2
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +19 -3
- package/src/client/hooks/chat/omp/folder-auto-expand.ts +113 -0
- package/src/client/hooks/chat/omp/index.ts +20 -0
- package/src/client/hooks/chat/omp/pending-rows.ts +21 -0
- package/src/client/hooks/chat/omp/pending-sessions.test.ts +16 -1
- package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +102 -0
- package/src/client/hooks/chat/omp/session-sidebar-controller.ts +21 -1
- package/src/client/hooks/chat/omp/stream.ts +8 -1
- package/src/client/hooks/chat/timeline/index.ts +1 -1
- package/src/client/hooks/chat/timeline/new-chat-open.ts +60 -0
- package/src/client/hooks/editor/blame-settings.ts +67 -0
- package/src/client/hooks/editor/blame.test.ts +272 -0
- package/src/client/hooks/editor/blame.ts +232 -0
- package/src/client/hooks/editor/file-editor-types.ts +23 -0
- package/src/client/hooks/editor/save-file.test.ts +20 -0
- package/src/client/hooks/editor/use-editor-drop.test-util.ts +198 -0
- package/src/client/hooks/editor/use-editor-drop.test.ts +70 -175
- package/src/client/hooks/editor/use-editor-drop.ts +19 -36
- package/src/client/hooks/editor/use-file-editor.ts +7 -1
- package/src/client/hooks/settings/providers/actions.ts +90 -194
- package/src/client/hooks/settings/providers/api.ts +7 -1
- package/src/client/hooks/settings/providers/index.ts +171 -59
- package/src/client/hooks/settings/providers/login.test.ts +79 -0
- package/src/client/hooks/settings/providers/login.ts +276 -0
- package/src/client/hooks/settings/providers/messages.ts +28 -0
- package/src/client/hooks/settings/providers/model-actions.ts +178 -0
- package/src/client/hooks/ui/editor-error-toast.ts +47 -0
- package/src/client/hooks/ui/open-file.ts +7 -0
- package/src/client/hooks/ui/toasts.ts +7 -0
- package/src/client/hooks/workspace/file-tabs.ts +4 -1
- package/src/client/hooks/workspace/folder-expansion.test.ts +62 -0
- package/src/client/hooks/workspace/folder-expansion.ts +33 -0
- package/src/client/hooks/workspace/git-action-outcome.ts +86 -0
- package/src/client/hooks/workspace/git-actions.ts +29 -2
- package/src/client/hooks/workspace/plugin-contributions.test.ts +117 -0
- package/src/client/hooks/workspace/plugin-contributions.ts +146 -0
- package/src/client/lib/editor-errors.test.ts +85 -0
- package/src/client/lib/editor-errors.ts +71 -0
- package/src/client/lib/fs/resolve-open.test.ts +125 -0
- package/src/client/lib/fs/resolve-open.ts +90 -0
- package/src/client/lib/git/action-message.test.ts +82 -0
- package/src/client/lib/git/action-message.ts +160 -0
- package/src/client/lib/launch/device-files.test.ts +160 -0
- package/src/client/lib/launch/device-files.ts +197 -0
- package/src/client/lib/native/open-paths.test.ts +140 -0
- package/src/client/lib/native/open-paths.ts +157 -0
- package/src/client/lib/plugins/bootstrap.test.ts +1 -1
- package/src/client/main.tsx +20 -0
- package/src/server/db.server.test.ts +39 -0
- package/src/server/db.server.ts +21 -2
- package/src/server/lib/db/schema.ts +2 -0
- package/src/server/lib/fs/external-roots.test.ts +100 -0
- package/src/server/lib/fs/external-roots.ts +101 -0
- package/src/server/lib/fs/git-actions-branch.ts +15 -2
- package/src/server/lib/fs/git-actions-shared.ts +24 -0
- package/src/server/lib/fs/git-actions-sync.test.ts +18 -7
- package/src/server/lib/fs/git-actions-worktree.ts +5 -1
- package/src/server/lib/fs/git-blame.test.ts +206 -0
- package/src/server/lib/fs/git-blame.ts +189 -0
- package/src/server/lib/fs/root.ts +14 -0
- package/src/server/lib/http/same-origin.ts +28 -7
- package/src/server/lib/models/catalog.server.ts +230 -0
- package/src/server/lib/models/catalog.test.ts +83 -0
- package/src/server/lib/models/credential-origin.server.ts +108 -0
- package/src/server/lib/models/credential-origin.test.ts +132 -0
- package/src/server/lib/models/provider-icon-fetch.ts +115 -0
- package/src/server/lib/models/provider-icon-parse.test.ts +134 -0
- package/src/server/lib/models/provider-icon-parse.ts +139 -0
- package/src/server/lib/models/provider-icon-store.server.ts +118 -0
- package/src/server/lib/models/provider-icon-store.test.ts +107 -0
- package/src/server/lib/models/provider-icon.server.ts +209 -0
- package/src/server/lib/models/provider-items.server.ts +211 -37
- package/src/server/lib/models/provider-items.test.ts +201 -0
- package/src/server/lib/models/provider-registry.server.test.ts +27 -9
- package/src/server/lib/models/provider-registry.server.ts +160 -67
- package/src/server/lib/models/registry.server.test.ts +3 -3
- package/src/server/lib/models/registry.server.ts +8 -0
- package/src/server/lib/omp/config/definitions.test.ts +5 -4
- package/src/server/lib/omp/config/models-config.ts +42 -0
- package/src/server/lib/omp/config/provider-entry.test.ts +205 -0
- package/src/server/lib/omp/config/provider-entry.ts +197 -0
- package/src/server/lib/omp/config/provider-seeds.ts +10 -0
- package/src/server/lib/omp/core/models-json.ts +69 -0
- package/src/server/lib/omp/session/messages.ts +17 -3
- package/src/server/lib/omp/session/sidebar-data.canonical.test.ts +13 -3
- package/src/server/lib/panels/bundled-catalog.server.ts +7 -0
- package/src/server/lib/panels/catalog-offers.server.ts +68 -0
- package/src/server/lib/panels/git-update.server.test.ts +14 -0
- package/src/server/lib/panels/git-update.server.ts +63 -1
- package/src/server/lib/panels/manifest.test.ts +65 -0
- package/src/server/lib/panels/manifest.ts +55 -1
- package/src/server/lib/panels/offers.server.test.ts +191 -0
- package/src/server/lib/panels/offers.server.ts +108 -0
- package/src/server/lib/panels/registry.server.test.ts +35 -1
- package/src/server/lib/panels/registry.server.ts +51 -142
- package/src/server/lib/panels/scan.server.ts +162 -0
- package/src/server/lib/route-adapter.ts +13 -2
- package/src/server/lib/tray/tray.test.ts +2 -1
- package/src/server/lib/usage/providers.server.ts +4 -1
- package/src/server/routes/chat/session.ts +7 -1
- package/src/server/routes/fs/git-blame-loader.test.ts +146 -0
- package/src/server/routes/fs/git.ts +17 -0
- package/src/server/routes/fs/grant.test.ts +135 -0
- package/src/server/routes/fs/grant.ts +79 -0
- package/src/server/routes/fs/index.ts +2 -0
- package/src/server/routes/fs/scope.ts +34 -17
- package/src/server/routes/omp/login.ts +41 -14
- package/src/server/routes/omp/routes.test.ts +23 -10
- package/src/server/routes/settings/index.ts +8 -0
- package/src/server/routes/settings/provider-entry.ts +108 -0
- package/src/server/routes/settings/provider-icon.ts +99 -0
- package/src/server/routes/settings/provider-model.ts +4 -1
- package/src/server/routes/settings/provider-refresh.ts +87 -0
- package/src/server/routes/settings/providers.ts +31 -2
- package/src/shared/lib/chat/omp/fold.test.ts +34 -0
- package/src/shared/lib/chat/omp/tool-frames.test.ts +20 -0
- package/src/shared/lib/chat/omp/tool-frames.ts +5 -1
- package/src/shared/lib/chat/omp/tool-results.ts +29 -3
- package/src/shared/lib/chat/tool/wait-facts.ts +4 -0
- package/src/shared/lib/fs/git-blame.test.ts +266 -0
- package/src/shared/lib/fs/git-blame.ts +246 -0
- package/src/shared/lib/git/url.ts +18 -0
- package/src/shared/lib/markdown/sanitize.test.ts +57 -0
- package/src/shared/lib/markdown/sanitize.ts +30 -7
- package/src/shared/lib/models/provider/connection.ts +135 -0
- package/src/shared/lib/models/provider/dialect.test.ts +4 -2
- package/src/shared/lib/models/provider/dialect.ts +76 -6
- package/src/shared/lib/models/provider/models.ts +2 -0
- package/src/shared/lib/models/provider/origin.ts +94 -0
- package/src/shared/lib/models/provider/provider-ui.test.ts +7 -0
- package/src/shared/lib/models/server-cache.ts +8 -3
- package/src/shared/lib/omp/session/messages-map-pending.test.ts +110 -0
- package/src/shared/lib/omp/session/messages-map.ts +34 -2
- package/src/shared/lib/omp/session/prewarm-misc.test.ts +7 -90
- package/src/shared/lib/omp/session/prewarm.test.ts +133 -0
- package/src/shared/lib/omp/session/prewarm.ts +23 -1
- package/src/shared/lib/omp/session/wait.test.ts +28 -0
- package/src/shared/lib/omp/session/wait.ts +38 -3
- package/src/shared/lib/panels/slot-labels.test.ts +61 -0
- package/src/shared/lib/panels/slot-labels.ts +133 -0
- package/src/shared/lib/workspace/panel-ids.ts +11 -0
- package/src/shared/types/fs.ts +6 -0
- package/src/shared/types/index.ts +1 -0
- package/src/shared/types/models.ts +12 -0
- package/src/shared/types/panels-registry.ts +277 -0
- package/src/shared/types/panels.ts +46 -213
- package/src/shared/types/settings/provider.ts +58 -0
- package/src/shared/types/settings/usage.ts +10 -0
- package/src/test-support/pristine-globals.ts +7 -0
- package/dist/client/static/js/index-bq6qeayr.css +0 -1
- 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
|
+
});
|