@gitkraken/core-gitlens 0.35.0 → 0.37.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 (59) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/dist/git/models/branch.d.ts +9 -0
  3. package/dist/git/models/branch.js.map +1 -1
  4. package/dist/git/providers/branches.d.ts +11 -1
  5. package/dist/git/providers/revision.d.ts +6 -0
  6. package/dist/git/utils/branch.utils.d.ts +14 -0
  7. package/dist/git/utils/branch.utils.js +37 -1
  8. package/dist/git/utils/branch.utils.js.map +1 -1
  9. package/dist/git/utils/branchLanded.utils.d.ts +43 -0
  10. package/dist/git/utils/branchLanded.utils.js +56 -0
  11. package/dist/git/utils/branchLanded.utils.js.map +1 -0
  12. package/dist/git-cli/exec/git.js +2 -2
  13. package/dist/git-cli/exec/git.js.map +1 -1
  14. package/dist/git-cli/providers/branches.d.ts +6 -1
  15. package/dist/git-cli/providers/branches.js +58 -0
  16. package/dist/git-cli/providers/branches.js.map +1 -1
  17. package/dist/git-cli/providers/revision.d.ts +1 -0
  18. package/dist/git-cli/providers/revision.js +9 -0
  19. package/dist/git-cli/providers/revision.js.map +1 -1
  20. package/dist/plus/ai/models/model.js +58 -4
  21. package/dist/plus/ai/models/model.js.map +1 -1
  22. package/dist/plus/ai/providers/anthropicProvider.js +58 -223
  23. package/dist/plus/ai/providers/anthropicProvider.js.map +1 -1
  24. package/dist/plus/ai/providers/deepSeekProvider.js +32 -18
  25. package/dist/plus/ai/providers/deepSeekProvider.js.map +1 -1
  26. package/dist/plus/ai/providers/geminiProvider.js +25 -189
  27. package/dist/plus/ai/providers/geminiProvider.js.map +1 -1
  28. package/dist/plus/ai/providers/mistralProvider.js +31 -73
  29. package/dist/plus/ai/providers/mistralProvider.js.map +1 -1
  30. package/dist/plus/ai/providers/xaiProvider.js +9 -11
  31. package/dist/plus/ai/providers/xaiProvider.js.map +1 -1
  32. package/dist/plus/git-github/api/github.d.ts +14 -3
  33. package/dist/plus/git-github/api/github.js +47 -14
  34. package/dist/plus/git-github/api/github.js.map +1 -1
  35. package/dist/plus/integrations/integrationService.d.ts +5 -1
  36. package/dist/plus/integrations/integrationService.js +4 -2
  37. package/dist/plus/integrations/integrationService.js.map +1 -1
  38. package/dist/plus/integrations/manager.d.ts +24 -5
  39. package/dist/plus/integrations/models/integration.d.ts +12 -0
  40. package/dist/plus/integrations/models/integration.js +15 -1
  41. package/dist/plus/integrations/models/integration.js.map +1 -1
  42. package/dist/plus/integrations/models/issuesIntegration.d.ts +2 -1
  43. package/dist/plus/integrations/models/issuesIntegration.js +6 -3
  44. package/dist/plus/integrations/models/issuesIntegration.js.map +1 -1
  45. package/dist/plus/integrations/providers/azureDevOps.d.ts +21 -6
  46. package/dist/plus/integrations/providers/azureDevOps.js +24 -12
  47. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  48. package/dist/plus/integrations/providers/azureDevOpsServer.d.ts +49 -3
  49. package/dist/plus/integrations/providers/azureDevOpsServer.js +151 -23
  50. package/dist/plus/integrations/providers/azureDevOpsServer.js.map +1 -1
  51. package/dist/plus/integrations/providers/linear.d.ts +3 -2
  52. package/dist/plus/integrations/providers/linear.js +7 -5
  53. package/dist/plus/integrations/providers/linear.js.map +1 -1
  54. package/dist/plus/integrations/reads/autolinks.js.map +1 -1
  55. package/dist/plus/integrations/reads/searchPullRequests.d.ts +2 -0
  56. package/dist/plus/integrations/reads/searchPullRequests.js +18 -9
  57. package/dist/plus/integrations/reads/searchPullRequests.js.map +1 -1
  58. package/docs/integrations.md +27 -6
  59. package/package.json +1 -1
@@ -15,8 +15,8 @@ import { base64 } from "../../../utils/base64.js";
15
15
  import { getGitHubNoReplyAddressParts } from "../../../git/remotes/github.js";
16
16
  import { defaultIssueSort } from "../../../git/models/issue.js";
17
17
  import "../../../git/models/pullRequest.js";
18
- import { effectiveIssueSort, getIssueComparator } from "../../../git/utils/issue.utils.js";
19
18
  import { getPullRequestComparator } from "../../../git/utils/pullRequest.utils.js";
19
+ import { effectiveIssueSort, getIssueComparator } from "../../../git/utils/issue.utils.js";
20
20
  import { fromGitHubIssue, fromGitHubIssueOrPullRequestState, fromGitHubMergeQueueEntry, fromGitHubPullRequest, fromGitHubPullRequestLite } from "../models.js";
21
21
  import { githubSearchResultLimit } from "./config.js";
22
22
  import { gitHubIssueSearchRelationships, toGitHubIssueSearchQualifiers, toGitHubIssueSearchScopeQualifiers, toGitHubIssueSearchSlideQualifier, toGitHubIssueSortQualifier } from "./issueSearchQuery.js";
@@ -44,6 +44,8 @@ const requestRetryMaxDelay = 2e3;
44
44
  const accountResolveBatchSize = 25;
45
45
  const defaultPullRequestSearchPageSize = 30;
46
46
  const maxPullRequestSearchPageSize = 100;
47
+ const fullPullRequestSearchPageBudget = 20;
48
+ const summaryPullRequestSearchPageBudget = maxPullRequestSearchPageSize;
47
49
  const maxMyPullRequestSearchPages = 4;
48
50
  function isRetryableTransientError(ex) {
49
51
  if (!(ex instanceof RequestError)) return false;
@@ -55,6 +57,10 @@ function isRetryableTransientError(ex) {
55
57
  default: return false;
56
58
  }
57
59
  }
60
+ /** A gateway that gave up waiting for GitHub to build the response, which an identical request mostly repeats. */
61
+ function isGatewayTimeoutError(ex) {
62
+ return ex instanceof RequestError && (ex.status === 502 || ex.status === 504);
63
+ }
58
64
  /**
59
65
  * When a rate-limited request may be retried, as a UTC epoch in seconds, or `undefined` when the response says
60
66
  * nothing useful. Header precedence follows GitHub's own guidance
@@ -1899,12 +1905,14 @@ var GitHubApi = class {
1899
1905
  this._enterpriseVersions.set(accessToken, version);
1900
1906
  return version ?? void 0;
1901
1907
  }
1902
- async requestWithRetries(execute, retryable, signal, scope) {
1908
+ async requestWithRetries(execute, retryable, signal, scope, noGatewayRetry) {
1903
1909
  let attempt = 0;
1904
1910
  while (true) try {
1905
1911
  return await execute();
1906
1912
  } catch (ex) {
1907
- if (!retryable || attempt >= maxRequestRetries || signal?.aborted || !isRetryableTransientError(ex)) throw ex;
1913
+ if (signal?.aborted && isRetryableTransientError(ex)) throw new CancellationError(ex);
1914
+ if (!retryable || attempt >= maxRequestRetries || !isRetryableTransientError(ex)) throw ex;
1915
+ if (noGatewayRetry && isGatewayTimeoutError(ex)) throw ex;
1908
1916
  attempt++;
1909
1917
  const delay = getRequestRetryDelay(attempt);
1910
1918
  scope?.warn(`Transient request failure (status ${ex.status}); retrying ${attempt}/${maxRequestRetries} in ${delay}ms`);
@@ -1931,13 +1939,13 @@ var GitHubApi = class {
1931
1939
  });
1932
1940
  }
1933
1941
  _pendingGraphQL = /* @__PURE__ */ new Map();
1934
- async graphql(provider, token, query, variables, scope, cancellation, allowPartialNotFound) {
1942
+ async graphql(provider, token, query, variables, scope, cancellation, allowPartialNotFound, gatewayFailures) {
1935
1943
  const { accessToken, ...tokenInfo } = token;
1936
1944
  const dedupable = cancellation == null && variables?.request == null;
1937
1945
  let dedupeKey;
1938
1946
  if (dedupable) {
1939
1947
  try {
1940
- dedupeKey = `${token.microHash}|${provider?.id ?? ""}|${allowPartialNotFound ?? ""}|${query}|${JSON.stringify(variables ?? null)}`;
1948
+ dedupeKey = `${token.microHash}|${provider?.id ?? ""}|${allowPartialNotFound ?? ""}|${gatewayFailures ?? ""}|${query}|${JSON.stringify(variables ?? null)}`;
1941
1949
  } catch {
1942
1950
  dedupeKey = void 0;
1943
1951
  }
@@ -1959,7 +1967,7 @@ var GitHubApi = class {
1959
1967
  };
1960
1968
  }
1961
1969
  const retryable = graphqlReadQueryRegex.test(query);
1962
- const data = await this.requestWithRetries(() => this.config.wrapForForcedInsecureSSL(provider?.getIgnoreSSLErrors() ?? false, () => this.getDefaults(accessToken, graphql)(query, variables)), retryable, cancellation, scope);
1970
+ const data = await this.requestWithRetries(() => this.config.wrapForForcedInsecureSSL(provider?.getIgnoreSSLErrors() ?? false, () => this.getDefaults(accessToken, graphql)(query, variables)), retryable, cancellation, scope, gatewayFailures != null);
1963
1971
  return allowPartialNotFound === "aliased" ? {
1964
1972
  data,
1965
1973
  errors: []
@@ -1986,7 +1994,7 @@ var GitHubApi = class {
1986
1994
  case "FORBIDDEN": throw new AuthenticationError(tokenInfo, 3, ex);
1987
1995
  }
1988
1996
  if (_logger.isDebugging) this.config.onDebugError?.(`GitHub request failed: ${ex.errors?.[0]?.message ?? ex.message}`);
1989
- } else if (ex instanceof RequestError || ex.name === "AbortError") this.handleRequestError(provider, token, ex, scope, allowPartialNotFound === "aliased");
1997
+ } else if (gatewayFailures === "caller" && isGatewayTimeoutError(ex)) {} else if (ex instanceof RequestError || ex.name === "AbortError") this.handleRequestError(provider, token, ex, scope, allowPartialNotFound === "aliased");
1990
1998
  else if (_logger.isDebugging) this.config.onDebugError?.(`GitHub request failed: ${ex.message}`);
1991
1999
  throw ex;
1992
2000
  }
@@ -3043,6 +3051,15 @@ var GitHubApi = class {
3043
3051
  * union of facets and no per-facet server order describes it. The sort is part of the cursor fingerprint, so
3044
3052
  * changing it invalidates a threaded cursor exactly as changing the text or the scope does. User text is
3045
3053
  * sanitized before it reaches the provider query. See {@link toGitHubPullRequestSearchFacets}.
3054
+ *
3055
+ * A page selects at most {@link fullPullRequestSearchPageBudget} pull requests across its facets with the full
3056
+ * fragment, and {@link summaryPullRequestSearchPageBudget} with the lite one, whatever `pageSize` asks for: past
3057
+ * that GitHub's gateway times out building the page (502/504 after ~11s). When it times out anyway, the page is
3058
+ * requested once more at half its size (unchanged when it is already one row per facet) rather than twice more
3059
+ * unchanged, and a second gateway failure fails the read. A page that recovers is smaller but no facet skips or
3060
+ * repeats a row, since each resumes from the cursor of the last row it served; the halved size is kept in the
3061
+ * cursor for the rest of the walk, so later pages don't time out again first. Other transient failures (503, a
3062
+ * network failure) are retried unchanged on each of those two requests, as on any read.
3046
3063
  */
3047
3064
  async searchPullRequestsPage(provider, token, options, cancellation) {
3048
3065
  const scope = getScopedLogger();
@@ -3063,6 +3080,7 @@ var GitHubApi = class {
3063
3080
  let cursor;
3064
3081
  if (options?.cursor != null) try {
3065
3082
  const parsed = JSON.parse(options.cursor);
3083
+ const parsedBudget = cursorNumber(parsed, "budget");
3066
3084
  const parsedFacets = parsed.facets;
3067
3085
  if (parsedFacets != null && typeof parsedFacets === "object" && !Array.isArray(parsedFacets)) {
3068
3086
  const parsedAliases = Object.keys(parsedFacets).sort();
@@ -3073,7 +3091,8 @@ var GitHubApi = class {
3073
3091
  page: typeof parsed.page === "number" && Number.isFinite(parsed.page) ? Math.max(1, Math.trunc(parsed.page)) : 1,
3074
3092
  facets: parsedFacets,
3075
3093
  truncated: parsed.truncated === true,
3076
- totalCount: typeof parsed.totalCount === "number" && Number.isFinite(parsed.totalCount) ? Math.max(0, Math.trunc(parsed.totalCount)) : void 0
3094
+ totalCount: typeof parsed.totalCount === "number" && Number.isFinite(parsed.totalCount) ? Math.max(0, Math.trunc(parsed.totalCount)) : void 0,
3095
+ budget: parsedBudget != null && parsedBudget >= 1 ? Math.trunc(parsedBudget) : void 0
3077
3096
  };
3078
3097
  }
3079
3098
  } catch {}
@@ -3087,8 +3106,9 @@ var GitHubApi = class {
3087
3106
  truncated: cursor?.truncated === true,
3088
3107
  totalCount: cursor?.totalCount
3089
3108
  };
3090
- const defaultSize = options?.summary === true ? Math.max(1, Math.floor(maxPullRequestSearchPageSize / activeFacets.length)) : defaultPullRequestSearchPageSize;
3091
- const pageSize = Math.min(maxPullRequestSearchPageSize, Math.max(1, Math.trunc(options?.pageSize ?? defaultSize)));
3109
+ const budget = Math.min(options?.summary === true ? summaryPullRequestSearchPageBudget : fullPullRequestSearchPageBudget, cursor?.budget ?? Number.POSITIVE_INFINITY);
3110
+ const facetBudget = Math.max(1, Math.floor(budget / activeFacets.length));
3111
+ const requestedPageSize = Math.min(facetBudget, Math.max(1, Math.trunc(options?.pageSize ?? facetBudget)));
3092
3112
  const includeVar = (alias) => `include${alias.charAt(0).toUpperCase()}${alias.slice(1)}`;
3093
3113
  const stackFragment = gqlPullRequestStackFragmentFor(options);
3094
3114
  const mergeQueueFragment = gqlPullRequestMergeQueueFragmentFor(options, this.config);
@@ -3097,7 +3117,8 @@ var GitHubApi = class {
3097
3117
  `$${f.alias}Cursor: String`,
3098
3118
  `$${includeVar(f.alias)}: Boolean!`
3099
3119
  ]);
3100
- const fields = facets.map((f) => `${f.alias}: search(first: ${pageSize}, after: $${f.alias}Cursor, query: $${f.alias}Search, type: ISSUE)
3120
+ const toQuery = (size) => {
3121
+ const fields = facets.map((f) => `${f.alias}: search(first: ${size}, after: $${f.alias}Cursor, query: $${f.alias}Search, type: ISSUE)
3101
3122
  @include(if: $${includeVar(f.alias)}) {
3102
3123
  issueCount
3103
3124
  pageInfo {
@@ -3112,12 +3133,13 @@ var GitHubApi = class {
3112
3133
  }
3113
3134
  }
3114
3135
  }`);
3115
- const query = `query searchPullRequestsPage(
3136
+ return `query searchPullRequestsPage(
3116
3137
  ${params.join("\n ")}
3117
3138
  $avatarSize: Int
3118
3139
  ) {
3119
3140
  ${fields.join("\n ")}
3120
3141
  }`;
3142
+ };
3121
3143
  const variables = {
3122
3144
  baseUrl: options?.baseUrl,
3123
3145
  avatarSize: options?.avatarSize
@@ -3127,8 +3149,18 @@ var GitHubApi = class {
3127
3149
  variables[`${facet.alias}Cursor`] = cursor?.facets[facet.alias] ?? void 0;
3128
3150
  variables[includeVar(facet.alias)] = isActive(facet.alias);
3129
3151
  }
3152
+ const read = (size, gatewayFailures) => this.graphql(provider, token, toQuery(size), variables, scope, cancellation, void 0, gatewayFailures);
3130
3153
  try {
3131
- const rsp = await this.graphql(provider, token, query, variables, scope, cancellation);
3154
+ let pageSize = requestedPageSize;
3155
+ let rsp;
3156
+ try {
3157
+ rsp = await read(pageSize, "caller");
3158
+ } catch (ex) {
3159
+ if (!isGatewayTimeoutError(ex)) throw ex;
3160
+ pageSize = Math.max(1, Math.floor(pageSize / 2));
3161
+ scope?.warn(`Gateway failure (status ${ex.status}) building the page; retrying at ${pageSize} per facet`);
3162
+ rsp = await read(pageSize, "final");
3163
+ }
3132
3164
  if (rsp == null) return {
3133
3165
  values: [],
3134
3166
  hasMore: false,
@@ -3171,7 +3203,8 @@ var GitHubApi = class {
3171
3203
  page: page + 1,
3172
3204
  facets: nextFacets,
3173
3205
  truncated: truncated || void 0,
3174
- totalCount
3206
+ totalCount,
3207
+ budget: pageSize < requestedPageSize ? pageSize * activeFacets.length : cursor?.budget
3175
3208
  };
3176
3209
  return {
3177
3210
  values,