mobbdev 1.1.10 → 1.1.11

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.
@@ -51,26 +51,18 @@ declare const PromptItemZ: z.ZodObject<{
51
51
  name: string;
52
52
  parameters: string;
53
53
  result: string;
54
- accepted?: boolean | undefined;
55
54
  rawArguments?: string | undefined;
55
+ accepted?: boolean | undefined;
56
56
  }, {
57
57
  name: string;
58
58
  parameters: string;
59
59
  result: string;
60
- accepted?: boolean | undefined;
61
60
  rawArguments?: string | undefined;
61
+ accepted?: boolean | undefined;
62
62
  }>>;
63
63
  }, "strip", z.ZodTypeAny, {
64
64
  type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
65
- tool?: {
66
- name: string;
67
- parameters: string;
68
- result: string;
69
- accepted?: boolean | undefined;
70
- rawArguments?: string | undefined;
71
- } | undefined;
72
65
  date?: Date | undefined;
73
- text?: string | undefined;
74
66
  attachedFiles?: {
75
67
  relativePath: string;
76
68
  startLine?: number | undefined;
@@ -79,17 +71,17 @@ declare const PromptItemZ: z.ZodObject<{
79
71
  inputCount: number;
80
72
  outputCount: number;
81
73
  } | undefined;
82
- }, {
83
- type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
74
+ text?: string | undefined;
84
75
  tool?: {
85
76
  name: string;
86
77
  parameters: string;
87
78
  result: string;
88
- accepted?: boolean | undefined;
89
79
  rawArguments?: string | undefined;
80
+ accepted?: boolean | undefined;
90
81
  } | undefined;
82
+ }, {
83
+ type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
91
84
  date?: Date | undefined;
92
- text?: string | undefined;
93
85
  attachedFiles?: {
94
86
  relativePath: string;
95
87
  startLine?: number | undefined;
@@ -98,6 +90,14 @@ declare const PromptItemZ: z.ZodObject<{
98
90
  inputCount: number;
99
91
  outputCount: number;
100
92
  } | undefined;
93
+ text?: string | undefined;
94
+ tool?: {
95
+ name: string;
96
+ parameters: string;
97
+ result: string;
98
+ rawArguments?: string | undefined;
99
+ accepted?: boolean | undefined;
100
+ } | undefined;
101
101
  }>;
102
102
  type PromptItem = z.infer<typeof PromptItemZ>;
103
103
  declare const PromptItemArrayZ: z.ZodArray<z.ZodObject<{
@@ -134,26 +134,18 @@ declare const PromptItemArrayZ: z.ZodArray<z.ZodObject<{
134
134
  name: string;
135
135
  parameters: string;
136
136
  result: string;
137
- accepted?: boolean | undefined;
138
137
  rawArguments?: string | undefined;
138
+ accepted?: boolean | undefined;
139
139
  }, {
140
140
  name: string;
141
141
  parameters: string;
142
142
  result: string;
143
- accepted?: boolean | undefined;
144
143
  rawArguments?: string | undefined;
144
+ accepted?: boolean | undefined;
145
145
  }>>;
146
146
  }, "strip", z.ZodTypeAny, {
147
147
  type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
148
- tool?: {
149
- name: string;
150
- parameters: string;
151
- result: string;
152
- accepted?: boolean | undefined;
153
- rawArguments?: string | undefined;
154
- } | undefined;
155
148
  date?: Date | undefined;
156
- text?: string | undefined;
157
149
  attachedFiles?: {
158
150
  relativePath: string;
159
151
  startLine?: number | undefined;
@@ -162,17 +154,17 @@ declare const PromptItemArrayZ: z.ZodArray<z.ZodObject<{
162
154
  inputCount: number;
163
155
  outputCount: number;
164
156
  } | undefined;
165
- }, {
166
- type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
157
+ text?: string | undefined;
167
158
  tool?: {
168
159
  name: string;
169
160
  parameters: string;
170
161
  result: string;
171
- accepted?: boolean | undefined;
172
162
  rawArguments?: string | undefined;
163
+ accepted?: boolean | undefined;
173
164
  } | undefined;
165
+ }, {
166
+ type: "USER_PROMPT" | "AI_RESPONSE" | "TOOL_EXECUTION" | "AI_THINKING";
174
167
  date?: Date | undefined;
175
- text?: string | undefined;
176
168
  attachedFiles?: {
177
169
  relativePath: string;
178
170
  startLine?: number | undefined;
@@ -181,6 +173,14 @@ declare const PromptItemArrayZ: z.ZodArray<z.ZodObject<{
181
173
  inputCount: number;
182
174
  outputCount: number;
183
175
  } | undefined;
176
+ text?: string | undefined;
177
+ tool?: {
178
+ name: string;
179
+ parameters: string;
180
+ result: string;
181
+ rawArguments?: string | undefined;
182
+ accepted?: boolean | undefined;
183
+ } | undefined;
184
184
  }>, "many">;
185
185
  type PromptItemArray = z.infer<typeof PromptItemArrayZ>;
186
186
  type UploadAiBlameOptions = {
@@ -5291,9 +5291,15 @@ var PromptItemZ = z26.object({
5291
5291
  });
5292
5292
  var PromptItemArrayZ = z26.array(PromptItemZ);
5293
5293
  function getSystemInfo() {
5294
+ let userName;
5295
+ try {
5296
+ userName = os2.userInfo().username;
5297
+ } catch {
5298
+ userName = void 0;
5299
+ }
5294
5300
  return {
5295
5301
  computerName: os2.hostname(),
5296
- userName: os2.userInfo().username
5302
+ userName
5297
5303
  };
5298
5304
  }
5299
5305
  function uploadAiBlameBuilder(args) {
package/dist/index.mjs CHANGED
@@ -6635,6 +6635,18 @@ var SCMLib = class {
6635
6635
  password: accessToken
6636
6636
  });
6637
6637
  }
6638
+ /**
6639
+ * Fetches commits for multiple PRs in a single batch request.
6640
+ * This is an optimization that not all SCM providers may support efficiently.
6641
+ * Default implementation throws - override in subclasses that support batching.
6642
+ *
6643
+ * @param repoUrl - Repository URL
6644
+ * @param prNumbers - Array of PR numbers to fetch commits for
6645
+ * @returns Map of PR number to array of commit SHAs
6646
+ */
6647
+ async getPrCommitsBatch(_repoUrl, _prNumbers) {
6648
+ throw new Error("getPrCommitsBatch not implemented for this SCM provider");
6649
+ }
6638
6650
  getAccessToken() {
6639
6651
  return this.accessToken || "";
6640
6652
  }
@@ -7493,13 +7505,6 @@ var GET_BLAME_DOCUMENT = `
7493
7505
  ranges {
7494
7506
  commit {
7495
7507
  oid
7496
- author {
7497
- user {
7498
- name
7499
- login
7500
- }
7501
- }
7502
- authoredDate
7503
7508
  }
7504
7509
  startingLine
7505
7510
  endingLine
@@ -7539,6 +7544,7 @@ var GITHUB_GRAPHQL_FRAGMENTS = {
7539
7544
  /**
7540
7545
  * Fragment for fetching blame data.
7541
7546
  * Use with object(expression: $ref) on Commit type.
7547
+ * Note: $path placeholder must be replaced with actual file path.
7542
7548
  */
7543
7549
  BLAME_RANGES: `
7544
7550
  blame(path: "$path") {
@@ -7547,13 +7553,6 @@ var GITHUB_GRAPHQL_FRAGMENTS = {
7547
7553
  endingLine
7548
7554
  commit {
7549
7555
  oid
7550
- author {
7551
- user {
7552
- name
7553
- login
7554
- email
7555
- }
7556
- }
7557
7556
  }
7558
7557
  }
7559
7558
  }
@@ -7717,19 +7716,27 @@ async function executeBatchGraphQL(octokit, owner, repo, config2) {
7717
7716
  }
7718
7717
  }
7719
7718
  `;
7720
- const response = await octokit.graphql(query, { owner, repo });
7719
+ let response;
7720
+ try {
7721
+ response = await octokit.graphql(query, { owner, repo });
7722
+ } catch (error) {
7723
+ const graphqlError = error;
7724
+ if (graphqlError.data?.repository) {
7725
+ response = graphqlError.data;
7726
+ } else {
7727
+ throw error;
7728
+ }
7729
+ }
7721
7730
  const result = /* @__PURE__ */ new Map();
7722
7731
  items.forEach((item, index) => {
7723
7732
  const data = response.repository[`${aliasPrefix}${index}`];
7724
- if (data) {
7725
- const extracted = extractResult(
7726
- data,
7727
- item,
7728
- index
7729
- );
7730
- if (extracted !== void 0) {
7731
- result.set(item, extracted);
7732
- }
7733
+ const extracted = extractResult(
7734
+ data || {},
7735
+ item,
7736
+ index
7737
+ );
7738
+ if (extracted !== void 0) {
7739
+ result.set(item, extracted);
7733
7740
  }
7734
7741
  });
7735
7742
  return result;
@@ -7875,9 +7882,15 @@ function getGithubSdk(params = {}) {
7875
7882
  }));
7876
7883
  } catch (e) {
7877
7884
  if (e instanceof RequestError && e.status === 401) {
7885
+ console.warn(
7886
+ "GitHub API returned 401 Unauthorized when listing repos - token may be expired or lack repo scope"
7887
+ );
7878
7888
  return [];
7879
7889
  }
7880
7890
  if (e instanceof RequestError && e.status === 404) {
7891
+ console.warn(
7892
+ "GitHub API returned 404 Not Found when listing repos - user may not exist"
7893
+ );
7881
7894
  return [];
7882
7895
  }
7883
7896
  throw e;
@@ -8023,13 +8036,42 @@ function getGithubSdk(params = {}) {
8023
8036
  (range) => ({
8024
8037
  startingLine: range.startingLine,
8025
8038
  endingLine: range.endingLine,
8026
- commitSha: range.commit.oid,
8027
- email: range.commit.author.user?.email || "",
8028
- name: range.commit.author.user?.name || "",
8029
- login: range.commit.author.user?.login || ""
8039
+ commitSha: range.commit.oid
8030
8040
  })
8031
8041
  );
8032
8042
  },
8043
+ /**
8044
+ * Fetches commits for multiple PRs in a single GraphQL request.
8045
+ * This is much more efficient than making N separate REST API calls.
8046
+ *
8047
+ * @param params.owner - Repository owner
8048
+ * @param params.repo - Repository name
8049
+ * @param params.prNumbers - Array of PR numbers to fetch commits for
8050
+ * @returns Map of PR number to array of commit SHAs
8051
+ */
8052
+ async getPrCommitsBatch(params2) {
8053
+ return executeBatchGraphQL(octokit, params2.owner, params2.repo, {
8054
+ items: params2.prNumbers,
8055
+ aliasPrefix: "prCommits",
8056
+ buildFragment: (prNumber, index) => `
8057
+ prCommits${index}: pullRequest(number: ${prNumber}) {
8058
+ commits(first: 100) {
8059
+ nodes {
8060
+ commit {
8061
+ oid
8062
+ }
8063
+ }
8064
+ }
8065
+ }`,
8066
+ extractResult: (data) => {
8067
+ const prData = data;
8068
+ if (prData?.commits?.nodes) {
8069
+ return prData.commits.nodes.map((node) => node.commit.oid);
8070
+ }
8071
+ return [];
8072
+ }
8073
+ });
8074
+ },
8033
8075
  // todo: refactor the name for this function
8034
8076
  async createPr(params2) {
8035
8077
  const { sourceRepoUrl, filesPaths, userRepoUrl, title, body } = params2;
@@ -8250,7 +8292,7 @@ function getGithubSdk(params = {}) {
8250
8292
  },
8251
8293
  /**
8252
8294
  * Batch fetch blame data for multiple files via GraphQL.
8253
- * Field selection matches GITHUB_GRAPHQL_FRAGMENTS.BLAME_RANGES pattern.
8295
+ * Uses GITHUB_GRAPHQL_FRAGMENTS.BLAME_RANGES for the field selection.
8254
8296
  */
8255
8297
  async getBlameBatch(params2) {
8256
8298
  return executeBatchGraphQL(octokit, params2.owner, params2.repo, {
@@ -8259,15 +8301,7 @@ function getGithubSdk(params = {}) {
8259
8301
  buildFragment: (path22, index) => `
8260
8302
  file${index}: object(expression: "${params2.ref}") {
8261
8303
  ... on Commit {
8262
- blame(path: "${path22}") {
8263
- ranges {
8264
- startingLine
8265
- endingLine
8266
- commit {
8267
- oid
8268
- }
8269
- }
8270
- }
8304
+ ${GITHUB_GRAPHQL_FRAGMENTS.BLAME_RANGES.replace("$path", path22)}
8271
8305
  }
8272
8306
  }`,
8273
8307
  extractResult: (data) => {
@@ -8276,11 +8310,7 @@ function getGithubSdk(params = {}) {
8276
8310
  return fileData.blame.ranges.map((range) => ({
8277
8311
  startingLine: range.startingLine,
8278
8312
  endingLine: range.endingLine,
8279
- commitSha: range.commit.oid,
8280
- // This is an urgent fix. We need to later remove these fields from the return type and propagate the change.
8281
- email: "",
8282
- name: "",
8283
- login: ""
8313
+ commitSha: range.commit.oid
8284
8314
  }));
8285
8315
  }
8286
8316
  return void 0;
@@ -8681,11 +8711,7 @@ var GithubSCMLib = class extends SCMLib {
8681
8711
  })
8682
8712
  )
8683
8713
  );
8684
- const diffLines = await this._attributeLinesViaBlame(
8685
- pr.head.ref,
8686
- filesRes.data,
8687
- commits
8688
- );
8714
+ const diffLines = filesRes ? await this._attributeLinesViaBlame(pr.head.ref, filesRes.data, commits) : [];
8689
8715
  return {
8690
8716
  diff: prDiff,
8691
8717
  createdAt: new Date(pr.created_at),
@@ -8743,6 +8769,19 @@ var GithubSCMLib = class extends SCMLib {
8743
8769
  });
8744
8770
  return submitRequests;
8745
8771
  }
8772
+ /**
8773
+ * Fetches commits for multiple PRs in a single GraphQL request.
8774
+ * Much more efficient than calling getSubmitRequestDiff for each PR.
8775
+ *
8776
+ * @param repoUrl - Repository URL
8777
+ * @param prNumbers - Array of PR numbers to fetch commits for
8778
+ * @returns Map of PR number to array of commit SHAs
8779
+ */
8780
+ async getPrCommitsBatch(repoUrl, prNumbers) {
8781
+ this._validateAccessToken();
8782
+ const { owner, repo } = parseGithubOwnerAndRepo(repoUrl);
8783
+ return this.githubSdk.getPrCommitsBatch({ owner, repo, prNumbers });
8784
+ }
8746
8785
  /**
8747
8786
  * Parse a Linear ticket from URL and name
8748
8787
  * Returns null if invalid or missing data
@@ -9211,10 +9250,7 @@ async function getGitlabBlameRanges({ ref, gitlabUrl, path: path22 }, options) {
9211
9250
  return {
9212
9251
  startingLine: oldLineNumber,
9213
9252
  endingLine: lineNumber - 1,
9214
- commitSha: range.commit.id,
9215
- login: range.commit.author_email,
9216
- email: range.commit.author_email,
9217
- name: range.commit.author_name
9253
+ commitSha: range.commit.id
9218
9254
  };
9219
9255
  });
9220
9256
  }
@@ -13426,9 +13462,15 @@ var PromptItemZ = z31.object({
13426
13462
  });
13427
13463
  var PromptItemArrayZ = z31.array(PromptItemZ);
13428
13464
  function getSystemInfo() {
13465
+ let userName;
13466
+ try {
13467
+ userName = os2.userInfo().username;
13468
+ } catch {
13469
+ userName = void 0;
13470
+ }
13429
13471
  return {
13430
13472
  computerName: os2.hostname(),
13431
- userName: os2.userInfo().username
13473
+ userName
13432
13474
  };
13433
13475
  }
13434
13476
  function uploadAiBlameBuilder(args) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.1.10",
3
+ "version": "1.1.11",
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",