@gitkraken/core-gitlens 0.5.112 → 0.5.114

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 (255) hide show
  1. package/CHANGELOG.md +19 -3
  2. package/dist/git/cache.d.ts +4 -0
  3. package/dist/git/cache.d.ts.map +1 -1
  4. package/dist/git/cache.js +33 -0
  5. package/dist/git/cache.js.map +1 -1
  6. package/dist/git/context.d.ts +10 -0
  7. package/dist/git/context.d.ts.map +1 -1
  8. package/dist/git/context.js.map +1 -1
  9. package/dist/git/errors.d.ts +6 -3
  10. package/dist/git/errors.d.ts.map +1 -1
  11. package/dist/git/errors.js +9 -1
  12. package/dist/git/errors.js.map +1 -1
  13. package/dist/git/features.d.ts +1 -1
  14. package/dist/git/features.d.ts.map +1 -1
  15. package/dist/git/features.js +38 -0
  16. package/dist/git/features.js.map +1 -1
  17. package/dist/git/gitHealth.d.ts +153 -0
  18. package/dist/git/gitHealth.d.ts.map +1 -0
  19. package/dist/git/gitHealth.js +353 -0
  20. package/dist/git/gitHealth.js.map +1 -0
  21. package/dist/git/models/search.d.ts +6 -3
  22. package/dist/git/models/search.d.ts.map +1 -1
  23. package/dist/git/models/search.js +5 -1
  24. package/dist/git/models/search.js.map +1 -1
  25. package/dist/git/parsers/diffParser.d.ts +8 -2
  26. package/dist/git/parsers/diffParser.d.ts.map +1 -1
  27. package/dist/git/parsers/diffParser.js +27 -4
  28. package/dist/git/parsers/diffParser.js.map +1 -1
  29. package/dist/git/providers/config.d.ts +36 -3
  30. package/dist/git/providers/config.d.ts.map +1 -1
  31. package/dist/git/providers/graph.d.ts +9 -0
  32. package/dist/git/providers/graph.d.ts.map +1 -1
  33. package/dist/git/providers/maintenance.d.ts +222 -0
  34. package/dist/git/providers/maintenance.d.ts.map +1 -0
  35. package/dist/git/providers/maintenance.js +20 -0
  36. package/dist/git/providers/maintenance.js.map +1 -0
  37. package/dist/git/providers/operations.d.ts +10 -0
  38. package/dist/git/providers/operations.d.ts.map +1 -1
  39. package/dist/git/providers/pausedOperations.d.ts +3 -0
  40. package/dist/git/providers/pausedOperations.d.ts.map +1 -1
  41. package/dist/git/providers/provider.d.ts +2 -0
  42. package/dist/git/providers/provider.d.ts.map +1 -1
  43. package/dist/git/providers/tags.d.ts +3 -0
  44. package/dist/git/providers/tags.d.ts.map +1 -1
  45. package/dist/git/repositoryService.d.ts +1 -0
  46. package/dist/git/repositoryService.d.ts.map +1 -1
  47. package/dist/git/repositoryService.js.map +1 -1
  48. package/dist/git/run.types.d.ts +8 -0
  49. package/dist/git/run.types.d.ts.map +1 -1
  50. package/dist/git/service.js +3 -0
  51. package/dist/git/service.js.map +1 -1
  52. package/dist/git/utils/search.utils.d.ts.map +1 -1
  53. package/dist/git/utils/search.utils.js +112 -5
  54. package/dist/git/utils/search.utils.js.map +1 -1
  55. package/dist/git/watching/watchService.d.ts +3 -0
  56. package/dist/git/watching/watchService.d.ts.map +1 -1
  57. package/dist/git/watching/watchService.js +8 -0
  58. package/dist/git/watching/watchService.js.map +1 -1
  59. package/dist/git-cli/cliGitProvider.d.ts +11 -0
  60. package/dist/git-cli/cliGitProvider.d.ts.map +1 -1
  61. package/dist/git-cli/cliGitProvider.js +12 -0
  62. package/dist/git-cli/cliGitProvider.js.map +1 -1
  63. package/dist/git-cli/exec/git.d.ts +23 -1
  64. package/dist/git-cli/exec/git.d.ts.map +1 -1
  65. package/dist/git-cli/exec/git.js +83 -8
  66. package/dist/git-cli/exec/git.js.map +1 -1
  67. package/dist/git-cli/exec/gitQueue.d.ts +2 -0
  68. package/dist/git-cli/exec/gitQueue.d.ts.map +1 -1
  69. package/dist/git-cli/exec/gitQueue.js +19 -17
  70. package/dist/git-cli/exec/gitQueue.js.map +1 -1
  71. package/dist/git-cli/parsers/logParser.d.ts.map +1 -1
  72. package/dist/git-cli/parsers/logParser.js +4 -1
  73. package/dist/git-cli/parsers/logParser.js.map +1 -1
  74. package/dist/git-cli/providers/blame.d.ts.map +1 -1
  75. package/dist/git-cli/providers/blame.js +4 -7
  76. package/dist/git-cli/providers/blame.js.map +1 -1
  77. package/dist/git-cli/providers/branches.d.ts.map +1 -1
  78. package/dist/git-cli/providers/branches.js +13 -3
  79. package/dist/git-cli/providers/branches.js.map +1 -1
  80. package/dist/git-cli/providers/commits.d.ts.map +1 -1
  81. package/dist/git-cli/providers/commits.js +34 -3
  82. package/dist/git-cli/providers/commits.js.map +1 -1
  83. package/dist/git-cli/providers/config.d.ts +27 -0
  84. package/dist/git-cli/providers/config.d.ts.map +1 -1
  85. package/dist/git-cli/providers/config.js +31 -6
  86. package/dist/git-cli/providers/config.js.map +1 -1
  87. package/dist/git-cli/providers/graph.d.ts +8 -0
  88. package/dist/git-cli/providers/graph.d.ts.map +1 -1
  89. package/dist/git-cli/providers/graph.js +85 -6
  90. package/dist/git-cli/providers/graph.js.map +1 -1
  91. package/dist/git-cli/providers/maintenance.d.ts +306 -0
  92. package/dist/git-cli/providers/maintenance.d.ts.map +1 -0
  93. package/dist/git-cli/providers/maintenance.js +2129 -0
  94. package/dist/git-cli/providers/maintenance.js.map +1 -0
  95. package/dist/git-cli/providers/operations.d.ts +1 -0
  96. package/dist/git-cli/providers/operations.d.ts.map +1 -1
  97. package/dist/git-cli/providers/operations.js +8 -0
  98. package/dist/git-cli/providers/operations.js.map +1 -1
  99. package/dist/git-cli/providers/pausedOperations.d.ts +1 -0
  100. package/dist/git-cli/providers/pausedOperations.d.ts.map +1 -1
  101. package/dist/git-cli/providers/pausedOperations.js +1 -1
  102. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  103. package/dist/git-cli/providers/tags.d.ts +3 -0
  104. package/dist/git-cli/providers/tags.d.ts.map +1 -1
  105. package/dist/git-cli/providers/tags.js +23 -1
  106. package/dist/git-cli/providers/tags.js.map +1 -1
  107. package/dist/plus/agents/agentCapabilities.d.ts +77 -0
  108. package/dist/plus/agents/agentCapabilities.d.ts.map +1 -0
  109. package/dist/plus/agents/agentCapabilities.js +197 -0
  110. package/dist/plus/agents/agentCapabilities.js.map +1 -0
  111. package/dist/plus/agents/providers/claudeCodeTranscript.d.ts +77 -13
  112. package/dist/plus/agents/providers/claudeCodeTranscript.d.ts.map +1 -1
  113. package/dist/plus/agents/providers/claudeCodeTranscript.js +263 -55
  114. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  115. package/dist/plus/agents/providers/{claudeCodeProvider.d.ts → gkAgentProvider.d.ts} +52 -19
  116. package/dist/plus/agents/providers/gkAgentProvider.d.ts.map +1 -0
  117. package/dist/plus/agents/providers/{claudeCodeProvider.js → gkAgentProvider.js} +935 -262
  118. package/dist/plus/agents/providers/gkAgentProvider.js.map +1 -0
  119. package/dist/plus/agents/types.d.ts +113 -35
  120. package/dist/plus/agents/types.d.ts.map +1 -1
  121. package/dist/plus/agents/types.js +7 -4
  122. package/dist/plus/agents/types.js.map +1 -1
  123. package/dist/plus/ai/models/promptTemplates.d.ts +1 -1
  124. package/dist/plus/ai/models/promptTemplates.d.ts.map +1 -1
  125. package/dist/plus/ai/prompts.d.ts +4 -0
  126. package/dist/plus/ai/prompts.d.ts.map +1 -1
  127. package/dist/plus/ai/prompts.js +59 -4
  128. package/dist/plus/ai/prompts.js.map +1 -1
  129. package/dist/plus/git-github/api/github.d.ts +50 -1
  130. package/dist/plus/git-github/api/github.d.ts.map +1 -1
  131. package/dist/plus/git-github/api/github.js +333 -29
  132. package/dist/plus/git-github/api/github.js.map +1 -1
  133. package/dist/plus/git-github/api/issueSearchQuery.d.ts +13 -0
  134. package/dist/plus/git-github/api/issueSearchQuery.d.ts.map +1 -1
  135. package/dist/plus/git-github/api/issueSearchQuery.js +41 -0
  136. package/dist/plus/git-github/api/issueSearchQuery.js.map +1 -1
  137. package/dist/plus/git-github/providers/github/blame.d.ts.map +1 -1
  138. package/dist/plus/git-github/providers/github/blame.js +2 -1
  139. package/dist/plus/git-github/providers/github/blame.js.map +1 -1
  140. package/dist/plus/integrations/integrationService.d.ts +15 -0
  141. package/dist/plus/integrations/integrationService.d.ts.map +1 -1
  142. package/dist/plus/integrations/integrationService.js +4 -0
  143. package/dist/plus/integrations/integrationService.js.map +1 -1
  144. package/dist/plus/integrations/manager.d.ts +43 -0
  145. package/dist/plus/integrations/manager.d.ts.map +1 -1
  146. package/dist/plus/integrations/models/gitHostIntegration.d.ts +49 -17
  147. package/dist/plus/integrations/models/gitHostIntegration.d.ts.map +1 -1
  148. package/dist/plus/integrations/models/gitHostIntegration.js +40 -0
  149. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  150. package/dist/plus/integrations/models/integration.d.ts +1 -1
  151. package/dist/plus/integrations/models/integration.d.ts.map +1 -1
  152. package/dist/plus/integrations/models/integration.js.map +1 -1
  153. package/dist/plus/integrations/providers/github.d.ts +10 -0
  154. package/dist/plus/integrations/providers/github.d.ts.map +1 -1
  155. package/dist/plus/integrations/providers/github.js +8 -0
  156. package/dist/plus/integrations/providers/github.js.map +1 -1
  157. package/dist/plus/integrations/providers/models.d.ts +2 -1
  158. package/dist/plus/integrations/providers/models.d.ts.map +1 -1
  159. package/dist/plus/integrations/providers/models.js.map +1 -1
  160. package/dist/plus/integrations/reads/broaden.d.ts +47 -10
  161. package/dist/plus/integrations/reads/broaden.d.ts.map +1 -1
  162. package/dist/plus/integrations/reads/broaden.js +144 -33
  163. package/dist/plus/integrations/reads/broaden.js.map +1 -1
  164. package/dist/plus/integrations/reads/filters.d.ts +18 -0
  165. package/dist/plus/integrations/reads/filters.d.ts.map +1 -1
  166. package/dist/plus/integrations/reads/filters.js +37 -1
  167. package/dist/plus/integrations/reads/filters.js.map +1 -1
  168. package/dist/plus/integrations/reads/issueBatch.d.ts +51 -0
  169. package/dist/plus/integrations/reads/issueBatch.d.ts.map +1 -0
  170. package/dist/plus/integrations/reads/issueBatch.js +91 -0
  171. package/dist/plus/integrations/reads/issueBatch.js.map +1 -0
  172. package/dist/plus/integrations/reads/pullRequests.d.ts +6 -0
  173. package/dist/plus/integrations/reads/pullRequests.d.ts.map +1 -1
  174. package/dist/plus/integrations/reads/pullRequests.js +28 -40
  175. package/dist/plus/integrations/reads/pullRequests.js.map +1 -1
  176. package/dist/plus/integrations/reads/searchPullRequests.d.ts +2 -0
  177. package/dist/plus/integrations/reads/searchPullRequests.d.ts.map +1 -1
  178. package/dist/plus/integrations/reads/searchPullRequests.js +1 -0
  179. package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
  180. package/dist/plus/integrations/reads/sweeps.d.ts.map +1 -1
  181. package/dist/plus/integrations/reads/sweeps.js +5 -3
  182. package/dist/plus/integrations/reads/sweeps.js.map +1 -1
  183. package/dist/utils/promiseCache.d.ts +19 -0
  184. package/dist/utils/promiseCache.d.ts.map +1 -1
  185. package/dist/utils/promiseCache.js +30 -0
  186. package/dist/utils/promiseCache.js.map +1 -1
  187. package/dist/utils/resourceUsage.d.ts +5 -0
  188. package/dist/utils/resourceUsage.d.ts.map +1 -0
  189. package/dist/utils/resourceUsage.js +2 -0
  190. package/dist/utils/resourceUsage.js.map +1 -0
  191. package/dist/utils/string.d.ts +12 -0
  192. package/dist/utils/string.d.ts.map +1 -1
  193. package/dist/utils/string.js +36 -1
  194. package/dist/utils/string.js.map +1 -1
  195. package/docs/integrations.md +29 -25
  196. package/docs/kepler-read-api-parity.md +12 -4
  197. package/package.json +12 -4
  198. package/src/git/cache.ts +36 -0
  199. package/src/git/context.ts +11 -0
  200. package/src/git/errors.ts +13 -1
  201. package/src/git/features.ts +51 -0
  202. package/src/git/gitHealth.ts +522 -0
  203. package/src/git/models/search.ts +19 -4
  204. package/src/git/parsers/diffParser.ts +27 -4
  205. package/src/git/providers/config.ts +42 -1
  206. package/src/git/providers/graph.ts +12 -0
  207. package/src/git/providers/maintenance.ts +224 -0
  208. package/src/git/providers/operations.ts +10 -0
  209. package/src/git/providers/pausedOperations.ts +3 -0
  210. package/src/git/providers/provider.ts +2 -0
  211. package/src/git/providers/tags.ts +1 -0
  212. package/src/git/repositoryService.ts +1 -0
  213. package/src/git/run.types.ts +8 -0
  214. package/src/git/service.ts +3 -0
  215. package/src/git/utils/search.utils.ts +129 -5
  216. package/src/git/watching/watchService.ts +10 -0
  217. package/src/git-cli/cliGitProvider.ts +25 -0
  218. package/src/git-cli/exec/git.ts +120 -6
  219. package/src/git-cli/exec/gitQueue.ts +19 -17
  220. package/src/git-cli/parsers/logParser.ts +4 -1
  221. package/src/git-cli/providers/blame.ts +3 -8
  222. package/src/git-cli/providers/branches.ts +28 -8
  223. package/src/git-cli/providers/commits.ts +34 -2
  224. package/src/git-cli/providers/config.ts +38 -6
  225. package/src/git-cli/providers/graph.ts +107 -7
  226. package/src/git-cli/providers/maintenance.ts +2599 -0
  227. package/src/git-cli/providers/operations.ts +11 -0
  228. package/src/git-cli/providers/pausedOperations.ts +7 -2
  229. package/src/git-cli/providers/tags.ts +36 -1
  230. package/src/plus/agents/agentCapabilities.ts +286 -0
  231. package/src/plus/agents/providers/claudeCodeTranscript.ts +313 -58
  232. package/src/plus/agents/providers/{claudeCodeProvider.ts → gkAgentProvider.ts} +1123 -277
  233. package/src/plus/agents/types.ts +137 -40
  234. package/src/plus/ai/models/promptTemplates.ts +1 -1
  235. package/src/plus/ai/prompts.ts +62 -4
  236. package/src/plus/git-github/api/github.ts +381 -31
  237. package/src/plus/git-github/api/issueSearchQuery.ts +49 -1
  238. package/src/plus/git-github/providers/github/blame.ts +2 -1
  239. package/src/plus/integrations/integrationService.ts +19 -0
  240. package/src/plus/integrations/manager.ts +43 -0
  241. package/src/plus/integrations/models/gitHostIntegration.ts +77 -18
  242. package/src/plus/integrations/models/integration.ts +1 -0
  243. package/src/plus/integrations/providers/github.ts +20 -0
  244. package/src/plus/integrations/providers/models.ts +6 -0
  245. package/src/plus/integrations/reads/broaden.ts +282 -70
  246. package/src/plus/integrations/reads/filters.ts +39 -1
  247. package/src/plus/integrations/reads/issueBatch.ts +197 -0
  248. package/src/plus/integrations/reads/pullRequests.ts +51 -70
  249. package/src/plus/integrations/reads/searchPullRequests.ts +3 -0
  250. package/src/plus/integrations/reads/sweeps.ts +19 -12
  251. package/src/utils/promiseCache.ts +43 -0
  252. package/src/utils/resourceUsage.ts +5 -0
  253. package/src/utils/string.ts +38 -1
  254. package/dist/plus/agents/providers/claudeCodeProvider.d.ts.map +0 -1
  255. package/dist/plus/agents/providers/claudeCodeProvider.js.map +0 -1
@@ -87,6 +87,8 @@ import { countIssues, countPullRequests } from './reads/counts.js';
87
87
  import type { SupportedFilters } from './reads/filters.js';
88
88
  import { getSupportedFilters } from './reads/filters.js';
89
89
  import { listOrgs, listProjects, listRepos } from './reads/hierarchy.js';
90
+ import type { IssueBatchResult, IssueBatchTarget } from './reads/issueBatch.js';
91
+ import { getIssuesBatch } from './reads/issueBatch.js';
90
92
  import { listIssuesPage } from './reads/issues.js';
91
93
  import { listIssueTrackerIssuesPage } from './reads/issueTracker.js';
92
94
  import { listPullRequestsPage } from './reads/pullRequests.js';
@@ -1053,6 +1055,8 @@ export class IntegrationService implements Disposable, RepositoryResolutionConte
1053
1055
  * from the trusted authentication configuration, not repository or remote data.
1054
1056
  */
1055
1057
  domain?: string;
1058
+ /** See {@link IntegrationManager.listPullRequestsPage}. */
1059
+ summary?: boolean;
1056
1060
  }): Promise<ProviderPagedResult<PullRequestShape>> {
1057
1061
  return listPullRequestsPage(this, options);
1058
1062
  }
@@ -1069,6 +1073,8 @@ export class IntegrationService implements Disposable, RepositoryResolutionConte
1069
1073
  forceSync?: boolean;
1070
1074
  connectionId?: string;
1071
1075
  domain?: string;
1076
+ /** See {@link IntegrationManager.searchPullRequestsPage}. */
1077
+ summary?: boolean;
1072
1078
  }): Promise<ProviderPagedResult<PullRequestShape>> {
1073
1079
  return searchPullRequestsPage(this, options);
1074
1080
  }
@@ -1152,6 +1158,19 @@ export class IntegrationService implements Disposable, RepositoryResolutionConte
1152
1158
  return countIssues(this, options);
1153
1159
  }
1154
1160
 
1161
+ async getIssuesBatch(options: {
1162
+ providerId: IntegrationIds;
1163
+ targets: readonly IssueBatchTarget[];
1164
+ connectionId?: string;
1165
+ /**
1166
+ * Explicit self-managed host domain. Used only when the requested connection has no configured domain;
1167
+ * it must come from the trusted authentication configuration, not repository or remote data.
1168
+ */
1169
+ domain?: string;
1170
+ }): Promise<ProviderResult<IssueBatchResult>> {
1171
+ return getIssuesBatch(this, options);
1172
+ }
1173
+
1155
1174
  /**
1156
1175
  * How many pull requests match each scope, without fetching any — the PR twin of {@link countIssues}. See
1157
1176
  * {@link IntegrationManager.countPullRequests} for the cost model, the per-scope isolation rules, and why
@@ -16,6 +16,7 @@ import type {
16
16
  PullRequestCountScope,
17
17
  } from './reads/counts.js';
18
18
  import type { SupportedFilters } from './reads/filters.js';
19
+ import type { IssueBatchResult, IssueBatchTarget } from './reads/issueBatch.js';
19
20
  import type {
20
21
  ConnectionStateChangeEvent,
21
22
  ProviderBroadenResult,
@@ -364,6 +365,15 @@ export interface IntegrationManager {
364
365
  * it must come from the trusted authentication configuration, not repository or remote data.
365
366
  */
366
367
  domain?: string;
368
+ /**
369
+ * Requests the lightweight row shape: everything except the per-row build-status rollup
370
+ * (`statusCheckRollupState`) and `commitCount`, which share one provider selection and are therefore
371
+ * dropped together. Set it on list/aggregate surfaces that read neither.
372
+ *
373
+ * The account-wide branch already requests this shape. A provider without a lightweight projection
374
+ * ignores the option, so it is a hint rather than a guarantee about which fields are present.
375
+ */
376
+ summary?: boolean;
367
377
  }): Promise<ProviderPagedResult<PullRequestShape>>;
368
378
  /**
369
379
  * Pull requests matching structured criteria over a repository/organization or current-user relationship
@@ -407,6 +417,14 @@ export interface IntegrationManager {
407
417
  connectionId?: string;
408
418
  /** Self-managed host domain fallback; see {@link ProviderSweepTarget.domain}. */
409
419
  domain?: string;
420
+ /**
421
+ * Requests the lightweight row shape: identity, body, author, repository, branch refs and stack info,
422
+ * without review, check or diff statistics. It also raises the default page size.
423
+ *
424
+ * A provider without a lightweight projection ignores it and returns its usual shape, so this is a hint
425
+ * rather than a contract about which fields are present.
426
+ */
427
+ summary?: boolean;
410
428
  }): Promise<ProviderPagedResult<PullRequestShape>>;
411
429
  listIssuesPage(options: {
412
430
  providerId: IntegrationIds;
@@ -546,6 +564,31 @@ export interface IntegrationManager {
546
564
  /** Self-managed host domain fallback; see {@link ProviderSweepTarget.domain}. */
547
565
  domain?: string;
548
566
  }): Promise<ProviderResult<IssueCountResult>>;
567
+ /**
568
+ * Resolves several issues BY COORDINATE — `(owner, repo, number)` — in one request.
569
+ *
570
+ * The read for "which issue does this branch name reference", which is an IDENTITY question rather than a
571
+ * search. Emulating it by paging a scoped list and matching the identifier cannot prove absence without
572
+ * walking the whole scope, so a miss stays unproven, uncacheable, and repeats its whole budget on every pass.
573
+ * This answers it in one request per chunk, and a miss is final.
574
+ *
575
+ * Results are echoed under the caller's own `key`, so no positional matching is needed. Per-target isolation
576
+ * is the rule: a chunk that fails upstream warns and drops only its own targets (with `fetchFailed` set) while
577
+ * every other target still answers.
578
+ *
579
+ * `issue: undefined` means PROVEN ABSENT — the issue does not exist, or is not visible to this connection —
580
+ * and is safe to cache. A target whose chunk failed is NOT returned at all, so the two are distinguishable;
581
+ * caching a failure as an absence is exactly the bug this distinction prevents. GitHub/GHE only: a provider
582
+ * that cannot batch refuses outright rather than degrading into N requests behind the caller's back.
583
+ */
584
+ getIssuesBatch(options: {
585
+ providerId: IntegrationIds;
586
+ /** Each `key` must be unique — a duplicate refuses the whole call, since keys identify results. */
587
+ targets: readonly IssueBatchTarget[];
588
+ connectionId?: string;
589
+ /** Self-managed host domain fallback; see {@link ProviderSweepTarget.domain}. */
590
+ domain?: string;
591
+ }): Promise<ProviderResult<IssueBatchResult>>;
549
592
  /**
550
593
  * How many pull requests match each scope, fetching none of them — the PR twin of {@link countIssues}, behind a
551
594
  * "this will fetch ~N pull requests" preview and a live count next to an unapplied filter. Same cost model,
@@ -1,4 +1,4 @@
1
- import type { CollectionMetadata, CollectionScopeFailure } from '@gitkraken/provider-apis';
1
+ import type { CollectionMetadata, CollectionScopeFailure, GitHubPullRequestFieldMap } from '@gitkraken/provider-apis';
2
2
  import type { Account, UnidentifiedAuthor } from '../../../git/models/author.js';
3
3
  import type { DefaultBranch } from '../../../git/models/defaultBranch.js';
4
4
  import type { IssueSearchCriteria, IssueShape } from '../../../git/models/issue.js';
@@ -117,6 +117,18 @@ export type SearchMyPullRequestsOptions = {
117
117
  includeReviewRequested?: boolean;
118
118
  };
119
119
 
120
+ type MyPullRequestsForReposOptions = {
121
+ filters?: PullRequestFilter[];
122
+ cursor?: string;
123
+ customUrl?: string;
124
+ page?: number;
125
+ pageSize?: number;
126
+ /** PR states to include; when omitted the provider returns its default (open only). */
127
+ state?: PullRequestStateFilter | PullRequestStateFilter[];
128
+ /** Requests the lightweight row shape without per-row build status or commit count. */
129
+ summary?: boolean;
130
+ };
131
+
120
132
  /**
121
133
  * Rejects a read the provider can't serve as asked: logs the reason and returns it as the `{ error }` half of an
122
134
  * {@link IntegrationResult}, timed from `start`.
@@ -132,6 +144,15 @@ function unsupportedRead<T>(message: string, start: number, logContext?: string)
132
144
  return { error: new Error(message), duration: performance.now() - start };
133
145
  }
134
146
 
147
+ /**
148
+ * Both fields gate the same GitHub `commits` subtree, so either truthy key retains the build-status rollup.
149
+ * An absent map retains the full row; a summary read explicitly drops both optional fields.
150
+ */
151
+ const summaryPullRequestFields: Required<GitHubPullRequestFieldMap> = {
152
+ headCommit: false,
153
+ commitCount: false,
154
+ };
155
+
135
156
  export abstract class GitHostIntegration<
136
157
  ID extends IntegrationIds = IntegrationIds,
137
158
  T extends ResourceDescriptor = ResourceDescriptor,
@@ -1084,15 +1105,7 @@ export abstract class GitHostIntegration<
1084
1105
 
1085
1106
  async getMyPullRequestsForRepos(
1086
1107
  reposOrRepoIds: ProviderReposInput,
1087
- options?: {
1088
- filters?: PullRequestFilter[];
1089
- cursor?: string;
1090
- customUrl?: string;
1091
- page?: number;
1092
- pageSize?: number;
1093
- /** PR states to include; when omitted the provider returns its default (open only). */
1094
- state?: PullRequestStateFilter | PullRequestStateFilter[];
1095
- },
1108
+ options?: MyPullRequestsForReposOptions,
1096
1109
  connectionId?: string,
1097
1110
  ): Promise<ProviderApiPagedResult<ProviderPullRequest> | undefined> {
1098
1111
  return (await this.getMyPullRequestsForReposResult(reposOrRepoIds, options, connectionId))?.value;
@@ -1106,14 +1119,7 @@ export abstract class GitHostIntegration<
1106
1119
  */
1107
1120
  async getMyPullRequestsForReposResult(
1108
1121
  reposOrRepoIds: ProviderReposInput,
1109
- options?: {
1110
- filters?: PullRequestFilter[];
1111
- cursor?: string;
1112
- customUrl?: string;
1113
- page?: number;
1114
- pageSize?: number;
1115
- state?: PullRequestStateFilter | PullRequestStateFilter[];
1116
- },
1122
+ options?: MyPullRequestsForReposOptions,
1117
1123
  connectionId?: string,
1118
1124
  ): Promise<IntegrationResult<ProviderApiPagedResult<ProviderPullRequest> | undefined>> {
1119
1125
  const scope = getScopedLogger();
@@ -1364,6 +1370,7 @@ export abstract class GitHostIntegration<
1364
1370
  states: states,
1365
1371
  // Azure DevOps only populates clone URLs on request (extra call); no-op elsewhere.
1366
1372
  includeRemoteInfo: isAzureDevOpsProvider(providerId) ? true : undefined,
1373
+ fields: options?.summary ? summaryPullRequestFields : undefined,
1367
1374
  });
1368
1375
  return { value: result, duration: performance.now() - start };
1369
1376
  } catch (ex) {
@@ -1575,6 +1582,8 @@ export abstract class GitHostIntegration<
1575
1582
  criteria?: PullRequestSearchCriteria;
1576
1583
  cursor?: string;
1577
1584
  pageSize?: number;
1585
+ /** See {@link IntegrationManager.searchPullRequestsPage}. */
1586
+ summary?: boolean;
1578
1587
  },
1579
1588
  cancellation?: AbortSignal,
1580
1589
  connectionId?: string,
@@ -1603,6 +1612,8 @@ export abstract class GitHostIntegration<
1603
1612
  criteria?: PullRequestSearchCriteria;
1604
1613
  cursor?: string;
1605
1614
  pageSize?: number;
1615
+ /** See the caller's option of the same name on {@link searchPullRequestsPage}. */
1616
+ summary?: boolean;
1606
1617
  },
1607
1618
  cancellation?: AbortSignal,
1608
1619
  ): Promise<ProviderPullRequestSearchPage | undefined>;
@@ -1778,6 +1789,54 @@ export abstract class GitHostIntegration<
1778
1789
  cancellation?: AbortSignal,
1779
1790
  ): Promise<(number | undefined)[] | undefined>;
1780
1791
 
1792
+ /**
1793
+ * Result-returning wrapper for the BATCH issue read: resolves several `(owner, repo, number)` coordinates in
1794
+ * one request. Recovers thrown errors into `{ error }` like the reads around it.
1795
+ *
1796
+ * Distinct from every search on this class, and deliberately so. A search answers "what matches"; this answers
1797
+ * "does this exact issue exist", which is the question a caller correlating a branch name to an issue is
1798
+ * actually asking. It has no result ceiling, no ordering and no cursor, and — the property that matters most —
1799
+ * an absent slot is a PROVEN ABSENCE rather than "not found within a page budget", so a caller can cache a
1800
+ * miss instead of re-walking for it forever.
1801
+ *
1802
+ * Results come back POSITIONALLY — one per input coordinate, in order — for the same reason
1803
+ * {@link countIssuesResult} does: a caller's key must never reach the provider query. `undefined` in a slot
1804
+ * means the issue does not exist or is not visible to this token, never that the read failed.
1805
+ */
1806
+ async getIssuesBatchResult(
1807
+ coordinates: readonly { owner: string; repo: string; number: number }[],
1808
+ cancellation?: AbortSignal,
1809
+ connectionId?: string,
1810
+ ): Promise<IntegrationResult<(IssueShape | undefined)[] | undefined>> {
1811
+ const scope = getScopedLogger();
1812
+ // `connectionId` targets a specific account (multi-account); omitted reads the primary.
1813
+ const session = await this.resolveReadSession(connectionId, scope);
1814
+ if (session == null) return undefined;
1815
+
1816
+ const start = performance.now();
1817
+ try {
1818
+ const issues = await this.getProviderIssuesBatch?.(session, coordinates, cancellation);
1819
+ this.resetRequestExceptionCount('getIssuesBatch');
1820
+ return { value: issues, duration: performance.now() - start };
1821
+ } catch (ex) {
1822
+ this.handleProviderException('getIssuesBatch', ex, { scope: scope, connectionId: connectionId });
1823
+ return { error: toError(ex), duration: performance.now() - start };
1824
+ }
1825
+ }
1826
+
1827
+ /**
1828
+ * OPTIONAL: only a provider that can resolve SEVERAL issues by coordinate in one request implements this.
1829
+ * GitHub aliases its point read into one document; the SDK exposes only a singular `getIssue` for every other
1830
+ * provider, and there is no plural variant to build on. A provider that can't answer doesn't implement it and
1831
+ * the facade refuses the read, so a caller keeps its own per-issue path rather than being handed a batch that
1832
+ * silently degraded into N requests.
1833
+ */
1834
+ protected getProviderIssuesBatch?(
1835
+ session: ProviderAuthenticationSession,
1836
+ coordinates: readonly { owner: string; repo: string; number: number }[],
1837
+ cancellation?: AbortSignal,
1838
+ ): Promise<(IssueShape | undefined)[] | undefined>;
1839
+
1781
1840
  /** The PR twin of {@link countIssuesResult}: counts each scope's pull requests, transferring none. */
1782
1841
  async countPullRequestsResult(
1783
1842
  scopes: readonly { repos?: ProviderRepoInput[]; org?: string; criteria?: PullRequestSearchCriteria }[],
@@ -65,6 +65,7 @@ type SyncReqUsecase = Exclude<
65
65
  | 'getDefaultBranch'
66
66
  | 'getIssue'
67
67
  | 'getIssueOrPullRequest'
68
+ | 'getIssuesBatch'
68
69
  | 'getIssuesForProject'
69
70
  | 'getIssuesForRepos'
70
71
  | 'getMyPullRequestsForUser'
@@ -612,6 +612,7 @@ abstract class GitHubIntegrationBase<ID extends GitHubIntegrationIds> extends Gi
612
612
  criteria?: PullRequestSearchCriteria;
613
613
  cursor?: string;
614
614
  pageSize?: number;
615
+ summary?: boolean;
615
616
  },
616
617
  cancellation?: AbortSignal,
617
618
  ): Promise<ProviderPullRequestSearchPage | undefined> {
@@ -625,6 +626,7 @@ abstract class GitHubIntegrationBase<ID extends GitHubIntegrationIds> extends Gi
625
626
  baseUrl: this.apiBaseUrl,
626
627
  cursor: options.cursor,
627
628
  pageSize: options.pageSize,
629
+ summary: options.summary,
628
630
  },
629
631
  cancellation,
630
632
  );
@@ -687,6 +689,24 @@ abstract class GitHubIntegrationBase<ID extends GitHubIntegrationIds> extends Gi
687
689
  );
688
690
  }
689
691
 
692
+ /**
693
+ * Resolves several issues by `(owner, repo, number)` in ONE request, by aliasing the point read rather than a
694
+ * search — see {@link GitHubApi.getIssuesBatch} for why that distinction is the whole design.
695
+ */
696
+ protected override async getProviderIssuesBatch(
697
+ session: ProviderAuthenticationSession,
698
+ coordinates: readonly { owner: string; repo: string; number: number }[],
699
+ cancellation?: AbortSignal,
700
+ ): Promise<(IssueShape | undefined)[] | undefined> {
701
+ return (await this.authenticationService.apis.github)?.getIssuesBatch(
702
+ this,
703
+ toTokenWithInfo(this.id, session),
704
+ coordinates,
705
+ { baseUrl: this.apiBaseUrl, includeBody: true },
706
+ cancellation,
707
+ );
708
+ }
709
+
690
710
  /**
691
711
  * Counts several pull-request scopes in ONE request. Like {@link countProviderIssues}, GitHub's `search`
692
712
  * reports `issueCount` on a zero-node selection, so a count preview costs no pull-request transfer.
@@ -16,6 +16,7 @@ import type {
16
16
  GitBuildStatus,
17
17
  GitBuildStatusState as GitBuildStatusStateType,
18
18
  GitHub,
19
+ GitHubPullRequestFieldMap,
19
20
  GitIssueState as GitIssueStateType,
20
21
  GitLab,
21
22
  GitLabGroup,
@@ -329,6 +330,11 @@ export interface GetPullRequestsOptions {
329
330
  // Opt in to repository remote metadata (clone URLs) when the PR payload lacks it. Only Azure DevOps
330
331
  // acts on this today (extra API call); it is a no-op for the other providers.
331
332
  includeRemoteInfo?: boolean;
333
+ // Field selection for the row shape. GitHub-shaped because it is the only provider whose PR read gates
334
+ // anything on it; the others ignore it. Declared here rather than passed through a spread so a typo or a
335
+ // wrong-shaped map is a compile error instead of a silently ignored key. An ABSENT map means "select
336
+ // everything", so only summary reads pass one.
337
+ fields?: GitHubPullRequestFieldMap;
332
338
  }
333
339
 
334
340
  export interface GetPullRequestsForUserOptions {