mobbdev 1.2.22 → 1.2.24

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.
@@ -881,6 +881,7 @@ var init_client_generates = __esm({
881
881
  ... on ProcessAIBlameRequestedResult {
882
882
  status
883
883
  requestIds
884
+ commitBlameRequestIds
884
885
  }
885
886
  }
886
887
  }
@@ -2571,11 +2572,20 @@ var init_urlParser = __esm({
2571
2572
  }
2572
2573
  });
2573
2574
 
2575
+ // src/features/analysis/scm/shared/src/urlParser/repoSlug.ts
2576
+ var init_repoSlug = __esm({
2577
+ "src/features/analysis/scm/shared/src/urlParser/repoSlug.ts"() {
2578
+ "use strict";
2579
+ init_urlParser();
2580
+ }
2581
+ });
2582
+
2574
2583
  // src/features/analysis/scm/shared/src/urlParser/index.ts
2575
2584
  var init_urlParser2 = __esm({
2576
2585
  "src/features/analysis/scm/shared/src/urlParser/index.ts"() {
2577
2586
  "use strict";
2578
2587
  init_types2();
2588
+ init_repoSlug();
2579
2589
  init_urlParser();
2580
2590
  }
2581
2591
  });
@@ -4210,7 +4220,9 @@ function subscribeStream(query, variables, handlers, wsClientOptions) {
4210
4220
  finalizeError(error);
4211
4221
  },
4212
4222
  complete: () => {
4213
- return;
4223
+ finalizeError(
4224
+ new Error("Subscription completed by server before resolving")
4225
+ );
4214
4226
  }
4215
4227
  }
4216
4228
  );
@@ -6146,9 +6158,6 @@ var GetReferenceResultZ = z14.object({
6146
6158
  type: z14.nativeEnum(ReferenceType)
6147
6159
  });
6148
6160
 
6149
- // src/features/analysis/scm/utils/diffUtils.ts
6150
- import parseDiff from "parse-diff";
6151
-
6152
6161
  // src/features/analysis/scm/ado/constants.ts
6153
6162
  init_types2();
6154
6163
  var DEFUALT_ADO_ORIGIN = scmCloudUrl.Ado;
@@ -6249,8 +6258,6 @@ var REPORT_DEFAULT_FILE_NAME = "report.json";
6249
6258
  init_env();
6250
6259
 
6251
6260
  // src/features/analysis/scm/github/GithubSCMLib.ts
6252
- init_env();
6253
- import pLimit from "p-limit";
6254
6261
  import { z as z22 } from "zod";
6255
6262
  init_client_generates();
6256
6263
 
@@ -6274,7 +6281,7 @@ import {
6274
6281
  Gitlab
6275
6282
  } from "@gitbeaker/rest";
6276
6283
  import Debug4 from "debug";
6277
- import pLimit2 from "p-limit";
6284
+ import pLimit from "p-limit";
6278
6285
  import {
6279
6286
  Agent,
6280
6287
  fetch as undiciFetch,
package/dist/index.mjs CHANGED
@@ -881,6 +881,7 @@ var init_client_generates = __esm({
881
881
  ... on ProcessAIBlameRequestedResult {
882
882
  status
883
883
  requestIds
884
+ commitBlameRequestIds
884
885
  }
885
886
  }
886
887
  }
@@ -2620,11 +2621,20 @@ var init_urlParser = __esm({
2620
2621
  }
2621
2622
  });
2622
2623
 
2624
+ // src/features/analysis/scm/shared/src/urlParser/repoSlug.ts
2625
+ var init_repoSlug = __esm({
2626
+ "src/features/analysis/scm/shared/src/urlParser/repoSlug.ts"() {
2627
+ "use strict";
2628
+ init_urlParser();
2629
+ }
2630
+ });
2631
+
2623
2632
  // src/features/analysis/scm/shared/src/urlParser/index.ts
2624
2633
  var init_urlParser2 = __esm({
2625
2634
  "src/features/analysis/scm/shared/src/urlParser/index.ts"() {
2626
2635
  "use strict";
2627
2636
  init_types2();
2637
+ init_repoSlug();
2628
2638
  init_urlParser();
2629
2639
  }
2630
2640
  });
@@ -6109,34 +6119,6 @@ var GetReferenceResultZ = z13.object({
6109
6119
  type: z13.nativeEnum(ReferenceType)
6110
6120
  });
6111
6121
 
6112
- // src/features/analysis/scm/utils/diffUtils.ts
6113
- import parseDiff from "parse-diff";
6114
- function parseAddedLinesByFile(diff) {
6115
- const result = /* @__PURE__ */ new Map();
6116
- const parsedDiff = parseDiff(diff);
6117
- for (const file of parsedDiff) {
6118
- if (!file.to || file.to === "/dev/null") {
6119
- continue;
6120
- }
6121
- const filePath = file.to;
6122
- const addedLines = [];
6123
- if (file.chunks) {
6124
- for (const chunk of file.chunks) {
6125
- for (const change of chunk.changes) {
6126
- if (change.type === "add") {
6127
- const addChange = change;
6128
- addedLines.push(addChange.ln);
6129
- }
6130
- }
6131
- }
6132
- }
6133
- if (addedLines.length > 0) {
6134
- result.set(filePath, addedLines);
6135
- }
6136
- }
6137
- return result;
6138
- }
6139
-
6140
6122
  // src/features/analysis/scm/utils/scm.ts
6141
6123
  var safeBody = (body, maxBodyLength) => {
6142
6124
  const truncationNotice = "\n\n... Message was cut here because it is too long";
@@ -7101,28 +7083,16 @@ var SCMLib = class {
7101
7083
  *
7102
7084
  * @param repoUrl - Repository URL
7103
7085
  * @param prNumbers - Array of PR numbers to fetch commits for
7104
- * @returns Map of PR number to array of commit SHAs
7086
+ * @returns Map of PR number to array of commit SHAs in chronological order
7087
+ * (oldest first, HEAD commit last)
7105
7088
  */
7106
7089
  async getPrCommitsBatch(_repoUrl, _prNumbers) {
7107
7090
  throw new Error("getPrCommitsBatch not implemented for this SCM provider");
7108
7091
  }
7109
- /**
7110
- * Fetches additions and deletions counts for multiple PRs in batch.
7111
- * More efficient than fetching individual PR details.
7112
- *
7113
- * @param repoUrl - Repository URL
7114
- * @param prNumbers - Array of PR numbers to fetch metrics for
7115
- * @returns Map of PR number to additions/deletions count
7116
- */
7117
- async getPrAdditionsDeletionsBatch(_repoUrl, _prNumbers) {
7118
- throw new Error(
7119
- "getPrAdditionsDeletionsBatch not implemented for this SCM provider"
7120
- );
7121
- }
7122
7092
  /**
7123
7093
  * Batch fetch PR data (additions/deletions + comments) for multiple PRs.
7124
7094
  * Only implemented for GitHub (via GraphQL). Other providers should override if supported.
7125
- * This is more efficient than calling getPrAdditionsDeletionsBatch separately.
7095
+ * This is more efficient than calling separate batch methods.
7126
7096
  *
7127
7097
  * @param _repoUrl - Repository URL
7128
7098
  * @param _prNumbers - Array of PR numbers to fetch data for
@@ -7364,11 +7334,8 @@ var AdoSCMLib = class extends SCMLib {
7364
7334
  markdownComment: comment
7365
7335
  });
7366
7336
  }
7367
- async getCommitDiff(_commitSha) {
7368
- throw new Error("getCommitDiff not implemented for ADO");
7369
- }
7370
- async getSubmitRequestDiff(_submitRequestId) {
7371
- throw new Error("getSubmitRequestDiff not implemented for ADO");
7337
+ async getSubmitRequestMetadata(_submitRequestId) {
7338
+ throw new Error("getSubmitRequestMetadata not implemented for ADO");
7372
7339
  }
7373
7340
  async searchSubmitRequests(_params) {
7374
7341
  throw new Error("searchSubmitRequests not implemented for ADO");
@@ -7946,11 +7913,8 @@ var BitbucketSCMLib = class extends SCMLib {
7946
7913
  markdownComment: comment
7947
7914
  });
7948
7915
  }
7949
- async getCommitDiff(_commitSha) {
7950
- throw new Error("getCommitDiff not implemented for Bitbucket");
7951
- }
7952
- async getSubmitRequestDiff(_submitRequestId) {
7953
- throw new Error("getSubmitRequestDiff not implemented for Bitbucket");
7916
+ async getSubmitRequestMetadata(_submitRequestId) {
7917
+ throw new Error("getSubmitRequestMetadata not implemented for Bitbucket");
7954
7918
  }
7955
7919
  async searchSubmitRequests(_params) {
7956
7920
  throw new Error("searchSubmitRequests not implemented for Bitbucket");
@@ -7980,8 +7944,6 @@ var REPORT_DEFAULT_FILE_NAME = "report.json";
7980
7944
  init_env();
7981
7945
 
7982
7946
  // src/features/analysis/scm/github/GithubSCMLib.ts
7983
- init_env();
7984
- import pLimit from "p-limit";
7985
7947
  import { z as z21 } from "zod";
7986
7948
  init_client_generates();
7987
7949
 
@@ -8054,18 +8016,6 @@ var GET_PR_METRICS_QUERY = `
8054
8016
  mergedAt
8055
8017
  additions
8056
8018
  deletions
8057
- commits(first: 100) {
8058
- totalCount
8059
- nodes {
8060
- commit {
8061
- oid
8062
- committedDate
8063
- author {
8064
- date
8065
- }
8066
- }
8067
- }
8068
- }
8069
8019
  comments(first: 100) {
8070
8020
  totalCount
8071
8021
  nodes {
@@ -8506,33 +8456,6 @@ function getGithubSdk(params = {}) {
8506
8456
  commit_sha: commitSha
8507
8457
  });
8508
8458
  },
8509
- async getCommitWithDiff({
8510
- commitSha,
8511
- owner,
8512
- repo
8513
- }) {
8514
- const [commitData, diffData] = await Promise.all([
8515
- // Get commit metadata
8516
- octokit.rest.repos.getCommit({
8517
- repo,
8518
- owner,
8519
- ref: commitSha
8520
- }),
8521
- // Get commit diff
8522
- octokit.request("GET /repos/{owner}/{repo}/commits/{ref}", {
8523
- owner,
8524
- repo,
8525
- ref: commitSha,
8526
- headers: {
8527
- Accept: "application/vnd.github.v3.diff"
8528
- }
8529
- })
8530
- ]);
8531
- return {
8532
- commit: commitData.data,
8533
- diff: diffData.data
8534
- };
8535
- },
8536
8459
  async getTagDate({
8537
8460
  tag,
8538
8461
  owner,
@@ -8716,14 +8639,6 @@ function getGithubSdk(params = {}) {
8716
8639
  async getUserInfo() {
8717
8640
  return octokit.request(GET_USER);
8718
8641
  },
8719
- async getPrCommits(params2) {
8720
- const data = await octokit.paginate(octokit.rest.pulls.listCommits, {
8721
- owner: params2.owner,
8722
- repo: params2.repo,
8723
- pull_number: params2.pull_number
8724
- });
8725
- return { data };
8726
- },
8727
8642
  async getUserRepos() {
8728
8643
  return octokit.rest.repos.listForAuthenticatedUser({
8729
8644
  visibility: "all",
@@ -8767,30 +8682,6 @@ function getGithubSdk(params = {}) {
8767
8682
  });
8768
8683
  return { data };
8769
8684
  },
8770
- /**
8771
- * Batch fetch additions/deletions for multiple PRs via GraphQL.
8772
- * Uses GITHUB_GRAPHQL_FRAGMENTS.PR_CHANGES for the field selection.
8773
- */
8774
- async getPrAdditionsDeletionsBatch(params2) {
8775
- return executeBatchGraphQL(octokit, params2.owner, params2.repo, {
8776
- items: params2.prNumbers,
8777
- aliasPrefix: "pr",
8778
- buildFragment: (prNumber, index) => `
8779
- pr${index}: pullRequest(number: ${prNumber}) {
8780
- ${GITHUB_GRAPHQL_FRAGMENTS.PR_CHANGES}
8781
- }`,
8782
- extractResult: (data) => {
8783
- const prData = data;
8784
- if (prData.additions !== void 0 && prData.deletions !== void 0) {
8785
- return {
8786
- additions: prData.additions,
8787
- deletions: prData.deletions
8788
- };
8789
- }
8790
- return void 0;
8791
- }
8792
- });
8793
- },
8794
8685
  /**
8795
8686
  * Batch fetch comments for multiple PRs via GraphQL.
8796
8687
  * Uses GITHUB_GRAPHQL_FRAGMENTS.PR_COMMENTS for the field selection.
@@ -8818,7 +8709,7 @@ function getGithubSdk(params = {}) {
8818
8709
  /**
8819
8710
  * Batch fetch PR data (additions/deletions + comments) for multiple PRs via GraphQL.
8820
8711
  * Combines PR_CHANGES and PR_COMMENTS fragments into a single API call for efficiency.
8821
- * This is more efficient than calling getPrAdditionsDeletionsBatch and getPrCommentsBatch separately.
8712
+ * This is more efficient than calling separate batch methods.
8822
8713
  */
8823
8714
  async getPrDataBatch(params2) {
8824
8715
  return executeBatchGraphQL(octokit, params2.owner, params2.repo, {
@@ -9209,82 +9100,21 @@ var GithubSCMLib = class _GithubSCMLib extends SCMLib {
9209
9100
  comment_id: commentId
9210
9101
  });
9211
9102
  }
9212
- async getCommitDiff(commitSha, options) {
9103
+ async getSubmitRequestMetadata(submitRequestId) {
9213
9104
  this._validateAccessTokenAndUrl();
9214
9105
  const { owner, repo } = parseGithubOwnerAndRepo(this.url);
9215
- const { commit, diff } = await this.githubSdk.getCommitWithDiff({
9106
+ const prNumber = Number(submitRequestId);
9107
+ const prRes = await this.githubSdk.getPr({
9216
9108
  owner,
9217
9109
  repo,
9218
- commitSha
9110
+ pull_number: prNumber
9219
9111
  });
9220
- const commitTimestamp = commit.commit.committer?.date ? new Date(commit.commit.committer.date) : new Date(commit.commit.author?.date || Date.now());
9221
- let repositoryCreatedAt = options?.repositoryCreatedAt;
9222
- if (repositoryCreatedAt === void 0) {
9223
- try {
9224
- const repoData = await this.githubSdk.getRepository({ owner, repo });
9225
- repositoryCreatedAt = repoData.data.created_at ? new Date(repoData.data.created_at) : void 0;
9226
- } catch (error) {
9227
- console.error("Failed to fetch repository creation date", {
9228
- error,
9229
- owner,
9230
- repo
9231
- });
9232
- repositoryCreatedAt = void 0;
9233
- }
9234
- }
9235
- return {
9236
- diff,
9237
- commitTimestamp,
9238
- commitSha: commit.sha,
9239
- authorName: commit.commit.author?.name,
9240
- authorEmail: commit.commit.author?.email,
9241
- message: commit.commit.message,
9242
- repositoryCreatedAt
9243
- };
9244
- }
9245
- async getSubmitRequestDiff(submitRequestId) {
9246
- this._validateAccessTokenAndUrl();
9247
- const { owner, repo } = parseGithubOwnerAndRepo(this.url);
9248
- const prNumber = Number(submitRequestId);
9249
- const [prRes, commitsRes, repoData, prDiff] = await Promise.all([
9250
- this.githubSdk.getPr({ owner, repo, pull_number: prNumber }),
9251
- this.githubSdk.getPrCommits({ owner, repo, pull_number: prNumber }),
9252
- this.githubSdk.getRepository({ owner, repo }),
9253
- this.getPrDiff({ pull_number: prNumber })
9254
- ]);
9255
9112
  const pr = prRes.data;
9256
- const repositoryCreatedAt = repoData.data.created_at ? new Date(repoData.data.created_at) : void 0;
9257
- const limit = pLimit(GITHUB_API_CONCURRENCY);
9258
- const commits = await Promise.all(
9259
- commitsRes.data.map(
9260
- (commit) => limit(
9261
- () => this.getCommitDiff(commit.sha, {
9262
- repositoryCreatedAt
9263
- })
9264
- )
9265
- )
9266
- );
9267
- const addedLinesByFile = parseAddedLinesByFile(prDiff);
9268
- const diffLines = [];
9269
- for (const [file, lines] of addedLinesByFile) {
9270
- for (const line of lines) {
9271
- diffLines.push({ file, line });
9272
- }
9273
- }
9274
9113
  return {
9275
- diff: prDiff,
9276
- createdAt: new Date(pr.created_at),
9277
- updatedAt: new Date(pr.updated_at),
9278
- submitRequestId,
9279
- submitRequestNumber: prNumber,
9280
- sourceBranch: pr.head.ref,
9281
- targetBranch: pr.base.ref,
9282
- authorName: pr.user?.name || pr.user?.login,
9283
- authorEmail: pr.user?.email || void 0,
9284
9114
  title: pr.title,
9285
- description: pr.body || void 0,
9286
- commits,
9287
- diffLines
9115
+ targetBranch: pr.base.ref,
9116
+ sourceBranch: pr.head.ref,
9117
+ headCommitSha: pr.head.sha
9288
9118
  };
9289
9119
  }
9290
9120
  /**
@@ -9342,7 +9172,7 @@ var GithubSCMLib = class _GithubSCMLib extends SCMLib {
9342
9172
  }
9343
9173
  /**
9344
9174
  * Fetches commits for multiple PRs in a single GraphQL request.
9345
- * Much more efficient than calling getSubmitRequestDiff for each PR.
9175
+ * Much more efficient than fetching commits for each PR individually.
9346
9176
  *
9347
9177
  * @param repoUrl - Repository URL
9348
9178
  * @param prNumbers - Array of PR numbers to fetch commits for
@@ -9353,23 +9183,6 @@ var GithubSCMLib = class _GithubSCMLib extends SCMLib {
9353
9183
  const { owner, repo } = parseGithubOwnerAndRepo(repoUrl);
9354
9184
  return this.githubSdk.getPrCommitsBatch({ owner, repo, prNumbers });
9355
9185
  }
9356
- /**
9357
- * Fetches additions and deletions counts for multiple PRs in a single GraphQL request.
9358
- * Used to enrich search results with changed lines data.
9359
- *
9360
- * @param repoUrl - Repository URL
9361
- * @param prNumbers - Array of PR numbers to fetch metrics for
9362
- * @returns Map of PR number to additions/deletions count
9363
- */
9364
- async getPrAdditionsDeletionsBatch(repoUrl, prNumbers) {
9365
- this._validateAccessToken();
9366
- const { owner, repo } = parseGithubOwnerAndRepo(repoUrl);
9367
- return this.githubSdk.getPrAdditionsDeletionsBatch({
9368
- owner,
9369
- repo,
9370
- prNumbers
9371
- });
9372
- }
9373
9186
  /**
9374
9187
  * Batch fetch PR data (additions/deletions + comments) for multiple PRs.
9375
9188
  * Combines both metrics into a single GraphQL call for efficiency.
@@ -9469,19 +9282,6 @@ var GithubSCMLib = class _GithubSCMLib extends SCMLib {
9469
9282
  throw new Error(`Pull request #${prNumber} not found`);
9470
9283
  }
9471
9284
  const prStatus = determinePrStatus(pr.state, pr.isDraft);
9472
- const firstCommit = pr.commits.nodes[0];
9473
- const firstCommitDate = firstCommit ? new Date(
9474
- firstCommit.commit.author?.date || firstCommit.commit.committedDate || pr.createdAt
9475
- ) : null;
9476
- let commitShas = pr.commits.nodes.map((node) => node.commit.oid);
9477
- if (pr.commits.totalCount > 100) {
9478
- const commitsRes = await this.githubSdk.getPrCommits({
9479
- owner,
9480
- repo,
9481
- pull_number: prNumber
9482
- });
9483
- commitShas = commitsRes.data.map((c) => c.sha);
9484
- }
9485
9285
  let commentIds = pr.comments.nodes.map((node) => node.id);
9486
9286
  if (pr.comments.totalCount > 100) {
9487
9287
  const commentsRes = await this.githubSdk.getGeneralPrComments({
@@ -9496,10 +9296,7 @@ var GithubSCMLib = class _GithubSCMLib extends SCMLib {
9496
9296
  repositoryUrl: this.url,
9497
9297
  prCreatedAt: new Date(pr.createdAt),
9498
9298
  prMergedAt: pr.mergedAt ? new Date(pr.mergedAt) : null,
9499
- firstCommitDate,
9500
9299
  linesAdded: pr.additions,
9501
- commitsCount: pr.commits.totalCount,
9502
- commitShas,
9503
9300
  prStatus,
9504
9301
  commentIds
9505
9302
  };
@@ -9537,7 +9334,7 @@ import {
9537
9334
  Gitlab
9538
9335
  } from "@gitbeaker/rest";
9539
9336
  import Debug3 from "debug";
9540
- import pLimit2 from "p-limit";
9337
+ import pLimit from "p-limit";
9541
9338
  import {
9542
9339
  Agent,
9543
9340
  fetch as undiciFetch,
@@ -9619,14 +9416,6 @@ function removeTrailingSlash2(str) {
9619
9416
  return str.trim().replace(/\/+$/, "");
9620
9417
  }
9621
9418
  var MAX_GITLAB_PR_BODY_LENGTH = 1048576;
9622
- function buildUnifiedDiff(diffs) {
9623
- return diffs.filter((d) => d.diff).map((d) => {
9624
- const oldPath = d.old_path || d.new_path || "";
9625
- const newPath = d.new_path || d.old_path || "";
9626
- return `diff --git a/${oldPath} b/${newPath}
9627
- ${d.diff}`;
9628
- }).join("\n");
9629
- }
9630
9419
  function getRandomGitlabCloudAnonToken() {
9631
9420
  if (!GITLAB_API_TOKEN || typeof GITLAB_API_TOKEN !== "string") {
9632
9421
  return void 0;
@@ -9928,7 +9717,7 @@ async function getGitlabMrCommitsBatch({
9928
9717
  url: repoUrl,
9929
9718
  gitlabAuthToken: accessToken
9930
9719
  });
9931
- const limit = pLimit2(GITLAB_API_CONCURRENCY);
9720
+ const limit = pLimit(GITLAB_API_CONCURRENCY);
9932
9721
  const results = await Promise.all(
9933
9722
  mrNumbers.map(
9934
9723
  (mrNumber) => limit(async () => {
@@ -9937,7 +9726,7 @@ async function getGitlabMrCommitsBatch({
9937
9726
  projectPath,
9938
9727
  mrNumber
9939
9728
  );
9940
- return [mrNumber, commits.map((c) => c.id)];
9729
+ return [mrNumber, commits.map((c) => c.id).reverse()];
9941
9730
  } catch (error) {
9942
9731
  contextLogger.warn(
9943
9732
  "[getGitlabMrCommitsBatch] Failed to fetch commits for MR",
@@ -9967,28 +9756,12 @@ async function getGitlabMrDataBatch({
9967
9756
  url: repoUrl,
9968
9757
  gitlabAuthToken: accessToken
9969
9758
  });
9970
- const limit = pLimit2(GITLAB_API_CONCURRENCY);
9759
+ const limit = pLimit(GITLAB_API_CONCURRENCY);
9971
9760
  const results = await Promise.all(
9972
9761
  mrNumbers.map(
9973
9762
  (mrNumber) => limit(async () => {
9974
9763
  try {
9975
- const [diffs, notes] = await Promise.all([
9976
- api2.MergeRequests.allDiffs(projectPath, mrNumber),
9977
- api2.MergeRequestNotes.all(projectPath, mrNumber)
9978
- ]);
9979
- let additions = 0;
9980
- let deletions = 0;
9981
- for (const diff of diffs) {
9982
- if (diff.diff) {
9983
- for (const line of diff.diff.split("\n")) {
9984
- if (line.startsWith("+") && !line.startsWith("+++")) {
9985
- additions++;
9986
- } else if (line.startsWith("-") && !line.startsWith("---")) {
9987
- deletions++;
9988
- }
9989
- }
9990
- }
9991
- }
9764
+ const notes = await api2.MergeRequestNotes.all(projectPath, mrNumber);
9992
9765
  const comments = notes.map((note) => ({
9993
9766
  author: note.author ? {
9994
9767
  login: note.author.username,
@@ -9998,7 +9771,7 @@ async function getGitlabMrDataBatch({
9998
9771
  }));
9999
9772
  return [
10000
9773
  mrNumber,
10001
- { changedLines: { additions, deletions }, comments }
9774
+ { changedLines: { additions: 0, deletions: 0 }, comments }
10002
9775
  ];
10003
9776
  } catch (error) {
10004
9777
  contextLogger.warn(
@@ -10022,39 +9795,6 @@ async function getGitlabMrDataBatch({
10022
9795
  );
10023
9796
  return new Map(results);
10024
9797
  }
10025
- async function getGitlabMergeRequestLinesAdded({
10026
- url,
10027
- prNumber,
10028
- accessToken
10029
- }) {
10030
- try {
10031
- const { projectPath } = parseGitlabOwnerAndRepo(url);
10032
- const api2 = getGitBeaker({
10033
- url,
10034
- gitlabAuthToken: accessToken
10035
- });
10036
- const diffs = await api2.MergeRequests.allDiffs(projectPath, prNumber);
10037
- let linesAdded = 0;
10038
- for (const diff of diffs) {
10039
- if (diff.diff) {
10040
- const addedLines = diff.diff.split("\n").filter(
10041
- (line) => line.startsWith("+") && !line.startsWith("+++")
10042
- ).length;
10043
- linesAdded += addedLines;
10044
- }
10045
- }
10046
- return linesAdded;
10047
- } catch (error) {
10048
- contextLogger.warn(
10049
- "[getGitlabMergeRequestLinesAdded] Failed to fetch diffs for MR",
10050
- {
10051
- prNumber,
10052
- error
10053
- }
10054
- );
10055
- return 0;
10056
- }
10057
- }
10058
9798
  async function getGitlabMergeRequestMetrics({
10059
9799
  url,
10060
9800
  prNumber,
@@ -10065,26 +9805,17 @@ async function getGitlabMergeRequestMetrics({
10065
9805
  url,
10066
9806
  gitlabAuthToken: accessToken
10067
9807
  });
10068
- const [mr, commits, linesAdded, notes] = await Promise.all([
9808
+ const [mr, notes] = await Promise.all([
10069
9809
  api2.MergeRequests.show(projectPath, prNumber),
10070
- api2.MergeRequests.allCommits(projectPath, prNumber),
10071
- getGitlabMergeRequestLinesAdded({ url, prNumber, accessToken }),
10072
9810
  api2.MergeRequestNotes.all(projectPath, prNumber)
10073
9811
  ]);
10074
- const sortedCommits = [...commits].sort(
10075
- (a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime()
10076
- );
10077
- const firstCommitDate = sortedCommits[0]?.created_at ?? null;
10078
9812
  const commentIds = notes.filter((note) => !note.system).map((note) => String(note.id));
10079
9813
  return {
10080
9814
  state: mr.state,
10081
9815
  isDraft: mr.draft ?? false,
10082
9816
  createdAt: mr.created_at,
10083
9817
  mergedAt: mr.merged_at ?? null,
10084
- linesAdded,
10085
- commitsCount: commits.length,
10086
- commitShas: commits.map((c) => c.id),
10087
- firstCommitDate,
9818
+ linesAdded: 0,
10088
9819
  commentIds
10089
9820
  };
10090
9821
  }
@@ -10220,29 +9951,6 @@ async function getGitlabRecentCommits({
10220
9951
  }
10221
9952
  return allCommits;
10222
9953
  }
10223
- async function getGitlabCommitDiff({
10224
- repoUrl,
10225
- accessToken,
10226
- commitSha
10227
- }) {
10228
- const { projectPath } = parseGitlabOwnerAndRepo(repoUrl);
10229
- const api2 = getGitBeaker({ url: repoUrl, gitlabAuthToken: accessToken });
10230
- const [commit, diffs] = await Promise.all([
10231
- api2.Commits.show(projectPath, commitSha),
10232
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10233
- api2.Commits.showDiff(projectPath, commitSha, { unidiff: true })
10234
- ]);
10235
- const diffString = buildUnifiedDiff(diffs);
10236
- const commitTimestamp = commit.committed_date ? new Date(commit.committed_date) : /* @__PURE__ */ new Date();
10237
- return {
10238
- diff: diffString,
10239
- commitTimestamp,
10240
- commitSha: commit.id,
10241
- authorName: commit.author_name,
10242
- authorEmail: commit.author_email,
10243
- message: commit.message
10244
- };
10245
- }
10246
9954
  async function getGitlabRateLimitStatus({
10247
9955
  repoUrl,
10248
9956
  accessToken
@@ -10324,88 +10032,6 @@ async function brokerRequestHandler(endpoint, options) {
10324
10032
  };
10325
10033
  throw new Error(`gitbeaker: ${response.statusText}`);
10326
10034
  }
10327
- async function getGitlabMergeRequestDiff({
10328
- repoUrl,
10329
- accessToken,
10330
- mrNumber
10331
- }) {
10332
- debug4("[getGitlabMergeRequestDiff] Starting for MR #%d", mrNumber);
10333
- const { projectPath } = parseGitlabOwnerAndRepo(repoUrl);
10334
- const api2 = getGitBeaker({ url: repoUrl, gitlabAuthToken: accessToken });
10335
- debug4(
10336
- "[getGitlabMergeRequestDiff] Fetching MR details, diffs, and commits..."
10337
- );
10338
- const startMrFetch = Date.now();
10339
- const [mr, mrDiffs, mrCommitsRaw] = await Promise.all([
10340
- api2.MergeRequests.show(projectPath, mrNumber),
10341
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10342
- api2.MergeRequests.allDiffs(projectPath, mrNumber, { unidiff: true }),
10343
- api2.MergeRequests.allCommits(projectPath, mrNumber)
10344
- ]);
10345
- debug4(
10346
- "[getGitlabMergeRequestDiff] MR fetch took %dms. Diffs: %d, Commits: %d",
10347
- Date.now() - startMrFetch,
10348
- mrDiffs.length,
10349
- mrCommitsRaw.length
10350
- );
10351
- const diffString = buildUnifiedDiff(mrDiffs);
10352
- debug4(
10353
- "[getGitlabMergeRequestDiff] Fetching commit diffs for %d commits...",
10354
- mrCommitsRaw.length
10355
- );
10356
- const startCommitFetch = Date.now();
10357
- const commitDiffLimit = pLimit2(GITLAB_API_CONCURRENCY);
10358
- const commits = await Promise.all(
10359
- mrCommitsRaw.map(
10360
- (commit) => commitDiffLimit(async () => {
10361
- const commitDiff = await getGitlabCommitDiff({
10362
- repoUrl,
10363
- accessToken,
10364
- commitSha: commit.id
10365
- });
10366
- return {
10367
- diff: commitDiff.diff,
10368
- commitTimestamp: commitDiff.commitTimestamp,
10369
- commitSha: commitDiff.commitSha,
10370
- authorName: commitDiff.authorName,
10371
- authorEmail: commitDiff.authorEmail,
10372
- message: commitDiff.message
10373
- };
10374
- })
10375
- )
10376
- );
10377
- commits.sort(
10378
- (a, b) => new Date(a.commitTimestamp).getTime() - new Date(b.commitTimestamp).getTime()
10379
- );
10380
- debug4(
10381
- "[getGitlabMergeRequestDiff] Commit diffs fetch took %dms",
10382
- Date.now() - startCommitFetch
10383
- );
10384
- const addedLinesByFile = parseAddedLinesByFile(diffString);
10385
- const diffLines = [];
10386
- for (const [file, lines] of addedLinesByFile) {
10387
- for (const line of lines) {
10388
- diffLines.push({ file, line });
10389
- }
10390
- }
10391
- return {
10392
- diff: diffString,
10393
- createdAt: new Date(mr.created_at),
10394
- updatedAt: new Date(mr.updated_at),
10395
- submitRequestId: String(mrNumber),
10396
- submitRequestNumber: mrNumber,
10397
- sourceBranch: mr.source_branch,
10398
- targetBranch: mr.target_branch,
10399
- authorName: mr.author?.name || mr.author?.username,
10400
- authorEmail: void 0,
10401
- // GitLab MR API doesn't expose author email directly
10402
- title: mr.title,
10403
- description: mr.description || void 0,
10404
- commits,
10405
- headCommitSha: mr.sha,
10406
- diffLines
10407
- };
10408
- }
10409
10035
 
10410
10036
  // src/features/analysis/scm/gitlab/GitlabSCMLib.ts
10411
10037
  init_client_generates();
@@ -10570,33 +10196,23 @@ var GitlabSCMLib = class extends SCMLib {
10570
10196
  this._validateAccessTokenAndUrl();
10571
10197
  return `${this.url}/-/commits/${branchName}`;
10572
10198
  }
10573
- async getCommitDiff(commitSha) {
10574
- this._validateAccessTokenAndUrl();
10575
- const result = await getGitlabCommitDiff({
10576
- repoUrl: this.url,
10577
- accessToken: this.accessToken,
10578
- commitSha
10579
- });
10580
- return {
10581
- diff: result.diff,
10582
- commitTimestamp: result.commitTimestamp,
10583
- commitSha: result.commitSha,
10584
- authorName: result.authorName,
10585
- authorEmail: result.authorEmail,
10586
- message: result.message
10587
- };
10588
- }
10589
- async getSubmitRequestDiff(submitRequestId) {
10199
+ async getSubmitRequestMetadata(submitRequestId) {
10590
10200
  this._validateAccessTokenAndUrl();
10591
10201
  const mrNumber = parseInt(submitRequestId, 10);
10592
10202
  if (isNaN(mrNumber) || mrNumber <= 0) {
10593
10203
  throw new Error(`Invalid merge request ID: ${submitRequestId}`);
10594
10204
  }
10595
- return getGitlabMergeRequestDiff({
10596
- repoUrl: this.url,
10597
- accessToken: this.accessToken,
10598
- mrNumber
10205
+ const mr = await getGitlabMergeRequest({
10206
+ url: this.url,
10207
+ prNumber: mrNumber,
10208
+ accessToken: this.accessToken
10599
10209
  });
10210
+ return {
10211
+ title: mr.title,
10212
+ targetBranch: mr.target_branch,
10213
+ sourceBranch: mr.source_branch,
10214
+ headCommitSha: mr.sha
10215
+ };
10600
10216
  }
10601
10217
  async searchSubmitRequests(params) {
10602
10218
  this._validateAccessTokenAndUrl();
@@ -10704,10 +10320,7 @@ var GitlabSCMLib = class extends SCMLib {
10704
10320
  repositoryUrl: this.url,
10705
10321
  prCreatedAt: new Date(metrics.createdAt),
10706
10322
  prMergedAt: metrics.mergedAt ? new Date(metrics.mergedAt) : null,
10707
- firstCommitDate: metrics.firstCommitDate ? new Date(metrics.firstCommitDate) : null,
10708
10323
  linesAdded: metrics.linesAdded,
10709
- commitsCount: metrics.commitsCount,
10710
- commitShas: metrics.commitShas,
10711
10324
  prStatus,
10712
10325
  commentIds: metrics.commentIds
10713
10326
  };
@@ -10837,34 +10450,8 @@ var StubSCMLib = class extends SCMLib {
10837
10450
  async addCommentToSubmitRequest(_submitRequestId, _comment) {
10838
10451
  console.warn("addCommentToSubmitRequest() no-op");
10839
10452
  }
10840
- async getCommitDiff(_commitSha) {
10841
- console.warn("getCommitDiff() returning stub diff");
10842
- return {
10843
- diff: "",
10844
- commitTimestamp: /* @__PURE__ */ new Date(),
10845
- commitSha: _commitSha,
10846
- authorName: void 0,
10847
- authorEmail: void 0,
10848
- message: void 0
10849
- };
10850
- }
10851
- async getSubmitRequestDiff(_submitRequestId) {
10852
- console.warn("getSubmitRequestDiff() returning stub diff");
10853
- return {
10854
- diff: "",
10855
- createdAt: /* @__PURE__ */ new Date(),
10856
- updatedAt: /* @__PURE__ */ new Date(),
10857
- submitRequestId: _submitRequestId,
10858
- submitRequestNumber: parseInt(_submitRequestId) || 0,
10859
- sourceBranch: "",
10860
- targetBranch: "",
10861
- authorName: void 0,
10862
- authorEmail: void 0,
10863
- title: void 0,
10864
- description: void 0,
10865
- commits: [],
10866
- diffLines: []
10867
- };
10453
+ async getSubmitRequestMetadata(_submitRequestId) {
10454
+ throw new Error("getSubmitRequestMetadata() not implemented");
10868
10455
  }
10869
10456
  async getPullRequestMetrics(_prNumber) {
10870
10457
  console.warn("getPullRequestMetrics() returning empty object");
@@ -12001,7 +11588,9 @@ function subscribeStream(query, variables, handlers, wsClientOptions) {
12001
11588
  finalizeError(error);
12002
11589
  },
12003
11590
  complete: () => {
12004
- return;
11591
+ finalizeError(
11592
+ new Error("Subscription completed by server before resolving")
11593
+ );
12005
11594
  }
12006
11595
  }
12007
11596
  );
@@ -12903,7 +12492,7 @@ import Debug10 from "debug";
12903
12492
 
12904
12493
  // src/features/analysis/add_fix_comments_for_pr/utils/utils.ts
12905
12494
  import Debug9 from "debug";
12906
- import parseDiff2 from "parse-diff";
12495
+ import parseDiff from "parse-diff";
12907
12496
  import { z as z27 } from "zod";
12908
12497
 
12909
12498
  // src/features/analysis/utils/by_key.ts
@@ -13276,7 +12865,7 @@ Refresh the page in order to see the changes.`,
13276
12865
  }
13277
12866
  async function getRelevantVulenrabilitiesFromDiff(params) {
13278
12867
  const { gqlClient, diff, vulnerabilityReportId } = params;
13279
- const parsedDiff = parseDiff2(diff);
12868
+ const parsedDiff = parseDiff(diff);
13280
12869
  const fileHunks = parsedDiff.map((file) => {
13281
12870
  const fileNumbers = file.chunks.flatMap((chunk) => chunk.changes).filter((change) => change.type === "add").map((_change) => {
13282
12871
  const change = _change;
@@ -21710,7 +21299,7 @@ import {
21710
21299
  writeFileSync
21711
21300
  } from "fs";
21712
21301
  import fs22 from "fs/promises";
21713
- import parseDiff3 from "parse-diff";
21302
+ import parseDiff2 from "parse-diff";
21714
21303
  import path21 from "path";
21715
21304
  var PatchApplicationService = class {
21716
21305
  /**
@@ -22394,7 +21983,7 @@ var PatchApplicationService = class {
22394
21983
  fixId,
22395
21984
  scanContext
22396
21985
  }) {
22397
- const parsedPatch = parseDiff3(patch);
21986
+ const parsedPatch = parseDiff2(patch);
22398
21987
  if (!parsedPatch || parsedPatch.length === 0) {
22399
21988
  throw new Error("Failed to parse patch - no changes found");
22400
21989
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.2.22",
3
+ "version": "1.2.24",
4
4
  "description": "Automated secure code remediation tool",
5
5
  "repository": "git+https://github.com/mobb-dev/bugsy.git",
6
6
  "main": "dist/index.mjs",