@gitkraken/core-gitlens 0.55.0 → 0.56.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 (58) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/git/cache.js +3 -0
  3. package/dist/git/cache.js.map +1 -1
  4. package/dist/git-cli/providers/config.js +2 -2
  5. package/dist/git-cli/providers/pausedOperations.d.ts +2 -0
  6. package/dist/git-cli/providers/pausedOperations.js +106 -42
  7. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  8. package/dist/git-cli/providers/staging.js +1 -1
  9. package/dist/ipc/discovery.js +1 -1
  10. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  11. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  12. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  13. package/dist/plus/integrations/index.d.ts +2 -1
  14. package/dist/plus/integrations/index.js.map +1 -1
  15. package/dist/plus/integrations/integrationService.d.ts +9 -0
  16. package/dist/plus/integrations/integrationService.js +75 -3
  17. package/dist/plus/integrations/integrationService.js.map +1 -1
  18. package/dist/plus/integrations/manager.d.ts +10 -0
  19. package/dist/plus/integrations/models/bitbucketPullRequestWrites.d.ts +217 -0
  20. package/dist/plus/integrations/models/bitbucketPullRequestWrites.js +0 -0
  21. package/dist/plus/integrations/models/integration.d.ts +2 -1
  22. package/dist/plus/integrations/models/integration.js +6 -0
  23. package/dist/plus/integrations/models/integration.js.map +1 -1
  24. package/dist/plus/integrations/providers/azure/azure.js +1 -1
  25. package/dist/plus/integrations/providers/azure/writeIdentity.d.ts +0 -3
  26. package/dist/plus/integrations/providers/azure/writeIdentity.js +4 -12
  27. package/dist/plus/integrations/providers/azure/writeIdentity.js.map +1 -1
  28. package/dist/plus/integrations/providers/azureDevOps.d.ts +0 -2
  29. package/dist/plus/integrations/providers/azureDevOps.js +1 -7
  30. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  31. package/dist/plus/integrations/providers/azurePullRequestWrites.js +24 -26
  32. package/dist/plus/integrations/providers/azurePullRequestWrites.js.map +1 -1
  33. package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js +4 -3
  34. package/dist/plus/integrations/providers/azureWorkItemWriteErrors.js.map +1 -1
  35. package/dist/plus/integrations/providers/azureWorkItemWrites.js +22 -21
  36. package/dist/plus/integrations/providers/azureWorkItemWrites.js.map +1 -1
  37. package/dist/plus/integrations/providers/bitbucket.d.ts +4 -0
  38. package/dist/plus/integrations/providers/bitbucket.js +8 -0
  39. package/dist/plus/integrations/providers/bitbucket.js.map +1 -1
  40. package/dist/plus/integrations/providers/bitbucketPullRequestWriteErrors.d.ts +13 -0
  41. package/dist/plus/integrations/providers/bitbucketPullRequestWriteErrors.js +88 -0
  42. package/dist/plus/integrations/providers/bitbucketPullRequestWriteErrors.js.map +1 -0
  43. package/dist/plus/integrations/providers/bitbucketPullRequestWriteLedger.d.ts +14 -0
  44. package/dist/plus/integrations/providers/bitbucketPullRequestWriteLedger.js +36 -0
  45. package/dist/plus/integrations/providers/bitbucketPullRequestWriteLedger.js.map +1 -0
  46. package/dist/plus/integrations/providers/bitbucketPullRequestWrites.d.ts +47 -0
  47. package/dist/plus/integrations/providers/bitbucketPullRequestWrites.js +795 -0
  48. package/dist/plus/integrations/providers/bitbucketPullRequestWrites.js.map +1 -0
  49. package/dist/plus/integrations/providers/github.js +1 -1
  50. package/dist/plus/integrations/providers/providersApi.d.ts +4 -0
  51. package/dist/plus/integrations/providers/providersApi.js +5 -0
  52. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  53. package/dist/plus/integrations/providers/utils/writeInputs.d.ts +7 -0
  54. package/dist/plus/integrations/providers/utils/writeInputs.js +17 -0
  55. package/dist/plus/integrations/providers/utils/writeInputs.js.map +1 -0
  56. package/dist/utils/env/node/exec.js +2 -2
  57. package/docs/integrations.md +155 -0
  58. package/package.json +1 -1
@@ -0,0 +1,7 @@
1
+ //#region ../plus/integrations/src/providers/utils/writeInputs.d.ts
2
+ export declare function isWriteIdentifier(value: unknown): value is string;
3
+ export declare function isPositiveInt32(value: unknown): value is number;
4
+ export declare function sameIdentifier(actual: unknown, expected: string): boolean;
5
+ export declare function isCommitSha(sha: unknown): sha is string;
6
+ //#endregion
7
+ //# sourceMappingURL=writeInputs.d.ts.map
@@ -0,0 +1,17 @@
1
+ //#region ../plus/integrations/src/providers/utils/writeInputs.ts
2
+ function isWriteIdentifier(value) {
3
+ return typeof value === "string" && value.length > 0 && value.trim() === value && ![...value].some((character) => character < " " || character === "");
4
+ }
5
+ function isPositiveInt32(value) {
6
+ return typeof value === "number" && Number.isInteger(value) && value > 0 && value <= 2147483647;
7
+ }
8
+ function sameIdentifier(actual, expected) {
9
+ return typeof actual === "string" && actual.toLowerCase() === expected.toLowerCase();
10
+ }
11
+ function isCommitSha(sha) {
12
+ return typeof sha === "string" && /^(?!0{40}$)[\da-f]{40}$/i.test(sha);
13
+ }
14
+ //#endregion
15
+ export { isCommitSha, isPositiveInt32, isWriteIdentifier, sameIdentifier };
16
+
17
+ //# sourceMappingURL=writeInputs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writeInputs.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/utils/writeInputs.ts"],"sourcesContent":["export function isWriteIdentifier(value: unknown): value is string {\n\treturn (\n\t\ttypeof value === 'string' &&\n\t\tvalue.length > 0 &&\n\t\tvalue.trim() === value &&\n\t\t![...value].some(character => character < ' ' || character === '\\x7f')\n\t);\n}\n\nexport function isPositiveInt32(value: unknown): value is number {\n\treturn typeof value === 'number' && Number.isInteger(value) && value > 0 && value <= 2147483647;\n}\n\nexport function sameIdentifier(actual: unknown, expected: string): boolean {\n\treturn typeof actual === 'string' && actual.toLowerCase() === expected.toLowerCase();\n}\n\nexport function isCommitSha(sha: unknown): sha is string {\n\treturn typeof sha === 'string' && /^(?!0{40}$)[\\da-f]{40}$/i.test(sha);\n}\n"],"mappings":";AAAA,SAAgB,kBAAkB,OAAiC;CAClE,OACC,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,KAAK,MAAM,SACjB,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAK,cAAa,YAAY,OAAO,cAAc,GAAM;AAEvE;AAEA,SAAgB,gBAAgB,OAAiC;CAChE,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,KAAK,QAAQ,KAAK,SAAS;AACtF;AAEA,SAAgB,eAAe,QAAiB,UAA2B;CAC1E,OAAO,OAAO,WAAW,YAAY,OAAO,YAAY,MAAM,SAAS,YAAY;AACpF;AAEA,SAAgB,YAAY,KAA6B;CACxD,OAAO,OAAO,QAAQ,YAAY,2BAA2B,KAAK,GAAG;AACtE"}
@@ -1,10 +1,10 @@
1
1
  import { getScopedLogger, maybeStartScopedLogger } from "../../logger.scoped.js";
2
2
  import { isWindows } from "./platform.js";
3
3
  import { join } from "path";
4
- import { execFile, spawn } from "child_process";
5
- import { access, constants } from "fs";
6
4
  import { stat } from "fs/promises";
7
5
  import * as process from "process";
6
+ import { execFile, spawn } from "child_process";
7
+ import { access, constants } from "fs";
8
8
  //#region ../utils/src/env/node/exec.ts
9
9
  var RunError = class extends Error {
10
10
  cmd;
@@ -1239,6 +1239,161 @@ reports an older `lastMergeTargetCommit`), policies are never bypassed, queued c
1239
1239
  results remain `outcome-unknown` without retries. Azure does not offer an atomic target-tip or PR-revision
1240
1240
  guard. Consumers must reconcile pending or uncertain results with reads before proposing another write.
1241
1241
 
1242
+ ### Bitbucket Cloud pull request writes
1243
+
1244
+ The following `IntegrationManager` methods and their types are exported from
1245
+ `@gitkraken/core-gitlens/plus/integrations/index.js`.
1246
+
1247
+ | Method | Input | Success |
1248
+ | ----------------------------------------- | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
1249
+ | `getBitbucketPullRequestCreateCapability` | `connectionId`, `workspace` and `repository` (slug or `{UUID}`), optional `expectedAccountId`. | Live account UUID, canonical workspace and repository, and the repository main branch. |
1250
+ | `resolveBitbucketPullRequestWriteTarget` | The same scope plus the pull request `number`. | Live account UUID, pull request snapshot and action capabilities, including merge types. |
1251
+ | `writeBitbucketPullRequest` | `connectionId`, `expectedAccountId`, `workspaceId`, `repositoryId` (UUIDs) and one of the actions below. | A typed write status and pull request receipt. |
1252
+ | `getBitbucketPullRequestMergeStatus` | The write address plus `number`, the pending `mergeTaskId` and the approved branches and source SHA. | `merged`, `pending` or `failed` with a reason, and the pull request snapshot. |
1253
+ | `releaseBitbucketPullRequestWrite` | The write address plus the held write's `attemptId` and its `sourceBranch` or `number` (and `mergeTaskId`). | Whether Core released the attempt, what its reread observed and the PR it found; `conflict` with that PR while another PR from a create's branch is open. |
1254
+
1255
+ - `create` takes `sourceBranch` and `targetBranch` in the selected repository, `title` and optional `description`.
1256
+ - `edit` takes `number` and at least one of `title` or `description`. Pass an empty description to clear it.
1257
+ - `decline` takes `number`.
1258
+ - `merge` takes `number`, `strategy`, `expectedSourceBranch`, `expectedSourceSha`, `expectedTargetBranch` and
1259
+ `expectedTargetSha`. Strategy values are Bitbucket's own: `merge_commit`, `squash`, `fast_forward`,
1260
+ `squash_fast_forward`, `rebase_fast_forward` and `rebase_merge`.
1261
+
1262
+ Branches are plain branch names, as Bitbucket addresses them, not `refs/heads/` refs. SHAs are full 40-character
1263
+ commit IDs; a resolved target carries them as `sourceSha` and `targetSha` from the live branch tips. Keep the
1264
+ returned `accountId` (the Bitbucket user UUID, braces included) as `expectedAccountId` and the canonical workspace
1265
+ and repository UUIDs and PR number across confirmation. Core checks the selected connection's live user and the
1266
+ repository before every action, and checks that the same credential is still current immediately before dispatch.
1267
+ Writes require the `pullrequest:write` OAuth scope, which GitKraken's Bitbucket connection grants. Bitbucket
1268
+ evaluates repository write access and branch restrictions at dispatch, so a capability is not a grant.
1269
+
1270
+ Bitbucket Cloud cannot reopen a declined pull request, through its API or its UI, so `capabilities.reopen` is always
1271
+ `false` and there is no reopen action. Only open pull requests can be edited or declined. Creating from a fork is
1272
+ not part of this contract; a pull request whose source lives in another repository can be edited and declined, but
1273
+ reports merge as `unsupported`. Draft pull requests report merge as `policy-blocked`.
1274
+
1275
+ Bitbucket can answer a create for a source branch that already has an open pull request by updating that pull
1276
+ request, and offers neither an idempotency key nor a compare-and-swap. Each integration manager keeps its own record
1277
+ of the creates and merges made through `writeBitbucketPullRequest` whose outcome it could not confirm
1278
+ (`outcome-unknown`, or `pending` for a merge), and runs one create or merge at a time per destination: repository
1279
+ and source branch for a create, repository and PR number for a merge. Edits, declines, GitLens' legacy merge and
1280
+ other managers are not covered. While such a write is unsettled, the manager sends no other create or merge to that
1281
+ destination: a create reports `conflict` while any open pull request from the branch exists, and `outcome-unknown`
1282
+ otherwise; a merge reports `outcome-unknown` while the PR is open; and `resolveBitbucketPullRequestWriteTarget`
1283
+ reports merge as `unavailable` with `outcome-unknown`. The write that records an entry, a `pending` merge or an
1284
+ `outcome-unknown` create or merge, carries it as `unsettled`, and so does every `outcome-unknown` the entry causes
1285
+ later: its opaque `attemptId`, the `accountId` that dispatched it, `dispatchedAt`, and its branches and receipt's
1286
+ `pullRequestNumber` for a create, or its `number` and `mergeTaskId` for a merge. `unsettled` is a frozen, `readonly`
1287
+ copy, so changing it cannot change what Core holds or how it settles or releases the attempt.
1288
+
1289
+ An entry clears only when the attempt's own receipt or task decides it, when its destination can no longer take
1290
+ the write (a pull request that is no longer open, since Bitbucket Cloud never reopens one), or when a person
1291
+ releases it. For a create, the deciding evidence is the pull request its
1292
+ readable receipt named, found open from the same branch of the repository or no longer open; a create whose receipt
1293
+ named no pull request never clears on its own, whatever pull requests from its branch show. Any open pull request
1294
+ from the branch that is not the named one refuses the create with `conflict` and keeps the entry. For a merge, it is
1295
+ a PR that is no longer open or, when the `202` named a task, that task's own terminal result; a merge recorded
1296
+ without a task clears only when the PR is no longer open. Any failure once Core called `fetch` for a create or merge
1297
+ records an entry and reports `outcome-unknown`, whatever the transport reports, a name resolution or connection
1298
+ error included, and so does a response whose body cannot be read. Waiting has no deadline of its own: a write for a
1299
+ destination waits for the one before it to settle. `getBitbucketPullRequestMergeStatus` does not wait for an
1300
+ in-flight merge.
1301
+
1302
+ A write that never reached Bitbucket leaves no such evidence, and neither does a create whose receipt named no pull
1303
+ request or a merge Bitbucket accepted (`202`) whose task has expired, since Bitbucket then answers `PENDING` for it.
1304
+ `releaseBitbucketPullRequestWrite` clears such an attempt, and is only for a host to call after a person checked in
1305
+ Bitbucket that the attempt did not arrive or is no longer running: a request still in flight or held by a proxy, or
1306
+ a merge Bitbucket is still running, can land after the release and duplicate the write. Under the destination's
1307
+ lock, it checks the attempt first, without reading Bitbucket and without releasing or settling anything. A merge
1308
+ whose held `mergeTaskId` differs from the release's answers `invalid-input`, whatever the PR's state; then, when
1309
+ this manager holds an attempt for the destination under another `attemptId`, the release answers `conflict`. Both
1310
+ carry that attempt as `unsettled` only when the caller's verified account is the one that dispatched it; another
1311
+ account gets the same refusal without `unsettled` or any detail of the attempt, since it may lack the pull request
1312
+ read access `resolveBitbucketPullRequestWriteTarget` requires before it shows one. A host that never received an
1313
+ `attemptId`, because the write threw or its receipt was unreadable, releases through the account that dispatched the
1314
+ write with its own record's id, shows the `unsettled` attempt the `conflict` returns, and releases again with that
1315
+ `attemptId`. Otherwise it rereads, whether or not this manager still holds the attempt. The release's own
1316
+ `mergeTaskId` is read only when the manager holds none, for example after a restart.
1317
+
1318
+ A create whose receipt's pull request is open from its branch settles and answers `pull-request-open`. Any other open
1319
+ pull request from the branch refuses the release with `conflict` and keeps the attempt, since the attempt could still
1320
+ land once that pull request closes; the failure carries that pull request as `pullRequest` when the reread can show
1321
+ it, so the host can show it. Once it closes, a person can release the attempt on a reread that finds nothing open.
1322
+
1323
+ A merge whose PR is queued refuses with `conflict`. With a task id, only a valid, bare `PENDING` of that task, one
1324
+ whose `queued_pullrequest` is missing or `null`, lets the release go on; without one, the PR reread alone decides. A
1325
+ task queued for this pull request, `SUCCESS`, a ref change (`409`) or leaving the merge queue refuses with
1326
+ `conflict`, the last three also settling the attempt; an empty or malformed body, an unknown status, a queue entry for
1327
+ another pull request and any other task error refuse with `outcome-unknown`, and a task read that fails (`404`, a rate
1328
+ limit, a server or network error) answers that typed failure; all of them keep the attempt. A task id that does not
1329
+ belong to this pull request answers `invalid-input`.
1330
+
1331
+ Otherwise it answers `released`, `true` only when this manager held that `attemptId`, and `observed`:
1332
+ `no-open-pull-request` or `pull-request-open` (its receipt's pull request) for a create, `pull-request-open` for a
1333
+ merge, or `pull-request-closed` when the reread found the attempt's pull request closed, which settles it. With
1334
+ `pull-request-open` and `pull-request-closed` it also carries `pullRequest`, the canonical pull request the reread
1335
+ found, as in a write result. A `pullRequest` in a release result, failure included, is the one the reread found only
1336
+ when its number is the attempt's (a merge) or it comes from the create's source branch in the repository and targets
1337
+ its held target branch; it is absent otherwise, when several pull requests from the branch are open and none is the
1338
+ receipt's, when one has no valid id, or when the read made only to show it fails or finds it no longer open, and
1339
+ never present with `no-open-pull-request`. An `ok` release means this manager holds no attempt for that destination
1340
+ any more; with `released: false` it held none for it, so the host can clear its own record of it, for example one
1341
+ kept across a restart. The connection and repository are checked as for a write. A person may release another
1342
+ account's attempt with its `attemptId`. A release that names another `attemptId` or `mergeTaskId` tells another
1343
+ account only that an attempt is held, never its details, though `resolveBitbucketPullRequestWriteTarget` shows the
1344
+ attempt to any account that can read the pull request. The `attemptId` correlates a release with an attempt; it does
1345
+ not authorize one. Core does not check who may release, so the host must enforce a person's confirmation of the
1346
+ exact attempt, and of the account releasing it, at its own trust boundary, especially when agents, delegated users
1347
+ or MCP tools can reach the call. An approval given for one attempt never carries over to another, and reading the
1348
+ attempt through a resolve, a write result or a pull request read is not permission to release it. The host should
1349
+ record who released it, with which account, and what the reread observed.
1350
+
1351
+ Core checks for an open pull request from the source branch before dispatch and refuses the create with `conflict`.
1352
+ It only reports `created` for a `201` receipt authored by the selected account whose `created_on` is no earlier than
1353
+ the server time Bitbucket sent on that preflight (its `Date` header, rounded down to the second), and that names the
1354
+ requested branches, title and description, when one was sent; any other receipt, including one without that header,
1355
+ reports `outcome-unknown`. A browser host only sees `Date` if Bitbucket exposes it to CORS, so creates there may
1356
+ report `outcome-unknown`. The preflight runs under the destination's lock and saw no open pull request from the
1357
+ branch, so an upsert of one older than the preflight's second is ruled out. What the rounding leaves is a pull
1358
+ request another client opened from the branch in that same second without it yet appearing to the preflight, and only
1359
+ if Bitbucket answers that upsert with `201`; the same holds for one opened between the preflight and the create.
1360
+ Bitbucket offers no way to tell either apart. A create without a description does not compare it, because Bitbucket
1361
+ may fill in the repository's default description. Title and description comparisons ignore surrounding whitespace and
1362
+ line-ending differences.
1363
+
1364
+ Merge capabilities come from the target branch's `merge_strategies` and Bitbucket's
1365
+ [mergeability checks](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/#api-repositories-workspace-repo-slug-pullrequests-pull-request-id-mergeability-checks-get).
1366
+ A blocking check makes merge unavailable: the PR state or a Git conflict reports `conflict`, missing merge permission
1367
+ reports `forbidden`, and standard or custom merge checks report `policy-blocked`. When the target branch requires
1368
+ its merge queue, strategies narrow to the ones the queue accepts. Immediately before dispatch Core reads the
1369
+ mergeability checks, then rereads the PR and both branch tips, rechecks the approved branches, SHAs, strategy and
1370
+ blocking checks, and posts the merge with the approved strategy. Bitbucket's merge API has no compare-and-swap on the PR or branch tips, so the
1371
+ source or target can still move after those reads; Bitbucket's own `409` for a ref that changed during the merge
1372
+ reports `conflict`. A merged receipt whose source commit is not the approved `expectedSourceSha` reports
1373
+ `outcome-unknown`, never `merged`. Core follows Bitbucket's own `blocking` verdict for each check, so a check
1374
+ Bitbucket reports as `UNKNOWN` or `PENDING` without blocking leaves merge available; Bitbucket evaluates it again at
1375
+ dispatch.
1376
+
1377
+ `merged` confirms Bitbucket reported the PR merged. `pending` acknowledges a merge Bitbucket queued or that outlasted
1378
+ its synchronous timeout (`202`). When the `202` names this pull request's task-status link, `pending` carries its
1379
+ `mergeTaskId`; a missing or foreign link leaves it out. Reconcile with `getBitbucketPullRequestMergeStatus`, which
1380
+ checks the same connection, account and repository as a write and takes the approved `expectedSourceBranch`,
1381
+ `expectedTargetBranch` and `expectedSourceSha`. Its result comes from the task: `merged` only for a `SUCCESS` whose
1382
+ merged pull request has the approved branches and source commit; `pending` only for a `PENDING` whose own
1383
+ `queued_pullrequest` is this pull request; `failed` with `conflict` for a `409` or a task error reporting conflicts in
1384
+ the pull request, and with `policy-blocked` when the pull request left the merge queue without merging. Core settles
1385
+ a `merged` or `failed` task before reading the pull request again, and a `merged` result carries the task's own merged
1386
+ pull request. A failed result carries the pull request as read afterwards, which may show another merge, and omits it
1387
+ when that read fails. Bitbucket answers an unknown or expired
1388
+ task as `PENDING`, so a bare `PENDING`, an unrecognized task error or a `SUCCESS` that does not match reports
1389
+ `outcome-unknown`, and Core keeps refusing another merge until the pull request is no longer open or the task settles.
1390
+ `forbidden` includes
1391
+ missing privileges and scopes; `rate-limit` includes Bitbucket's throttling `403` and a `403` with `Retry-After` and no
1392
+ error message. Typed reasons follow the HTTP status even when Bitbucket's error body cannot be decoded. `outcome-unknown` means Core dispatched a write and could not confirm the result, including
1393
+ Bitbucket's `555` timeout. For pending or uncertain writes, reconcile with a read before attempting another write.
1394
+ Core sends each mutation once. See the
1395
+ [pull requests API](https://developer.atlassian.com/cloud/bitbucket/rest/api-group-pullrequests/).
1396
+
1242
1397
  ### GitHub and GitHub Enterprise Server pull request writes
1243
1398
 
1244
1399
  Use `providerId: 'github'` and the `connectionId` that read the repository or pull request. Pass the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gitkraken/core-gitlens",
3
3
  "description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
4
- "version": "0.55.0",
4
+ "version": "0.56.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
7
7
  "name": "GitKraken",