mobbdev 1.2.0 → 1.2.1

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 (2) hide show
  1. package/dist/index.mjs +251 -158
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1371,7 +1371,7 @@ import Debug19 from "debug";
1371
1371
  import { hideBin } from "yargs/helpers";
1372
1372
 
1373
1373
  // src/args/yargs.ts
1374
- import chalk12 from "chalk";
1374
+ import chalk13 from "chalk";
1375
1375
  import yargs from "yargs/yargs";
1376
1376
 
1377
1377
  // src/args/commands/convert_to_sarif.ts
@@ -6572,7 +6572,7 @@ async function getAdoSdk(params) {
6572
6572
  const url = new URL(repoUrl);
6573
6573
  const origin2 = url.origin.toLowerCase().endsWith(".visualstudio.com") ? DEFUALT_ADO_ORIGIN : url.origin.toLowerCase();
6574
6574
  const params2 = `path=/&versionDescriptor[versionOptions]=0&versionDescriptor[versionType]=commit&versionDescriptor[version]=${branch}&resolveLfs=true&$format=zip&api-version=5.0&download=true`;
6575
- const path24 = [
6575
+ const path25 = [
6576
6576
  prefixPath,
6577
6577
  owner,
6578
6578
  projectName,
@@ -6583,7 +6583,7 @@ async function getAdoSdk(params) {
6583
6583
  "items",
6584
6584
  "items"
6585
6585
  ].filter(Boolean).join("/");
6586
- return new URL(`${path24}?${params2}`, origin2).toString();
6586
+ return new URL(`${path25}?${params2}`, origin2).toString();
6587
6587
  },
6588
6588
  async getAdoBranchList({ repoUrl }) {
6589
6589
  try {
@@ -8180,8 +8180,8 @@ function extractBlameRanges(data) {
8180
8180
  }
8181
8181
  function buildBlameFragment(ref) {
8182
8182
  const escapedRef = safeGraphQLString(ref, "ref");
8183
- return (path24, index) => {
8184
- const escapedPath = safeGraphQLString(path24, "path");
8183
+ return (path25, index) => {
8184
+ const escapedPath = safeGraphQLString(path25, "path");
8185
8185
  return `
8186
8186
  file${index}: object(expression: "${escapedRef}") {
8187
8187
  ... on Commit {
@@ -8229,8 +8229,8 @@ async function processBlameAttempt(params) {
8229
8229
  )
8230
8230
  );
8231
8231
  for (const batchResult of batchResults) {
8232
- for (const [path24, blameData] of batchResult) {
8233
- result.set(path24, blameData);
8232
+ for (const [path25, blameData] of batchResult) {
8233
+ result.set(path25, blameData);
8234
8234
  }
8235
8235
  }
8236
8236
  return result;
@@ -8550,14 +8550,14 @@ function getGithubSdk(params = {}) {
8550
8550
  };
8551
8551
  },
8552
8552
  async getGithubBlameRanges(params2) {
8553
- const { ref, gitHubUrl, path: path24 } = params2;
8553
+ const { ref, gitHubUrl, path: path25 } = params2;
8554
8554
  const { owner, repo } = parseGithubOwnerAndRepo(gitHubUrl);
8555
8555
  const res = await octokit.graphql(
8556
8556
  GET_BLAME_DOCUMENT,
8557
8557
  {
8558
8558
  owner,
8559
8559
  repo,
8560
- path: path24,
8560
+ path: path25,
8561
8561
  ref
8562
8562
  }
8563
8563
  );
@@ -9030,8 +9030,8 @@ function getGithubSdk(params = {}) {
9030
9030
  return executeBatchGraphQL(octokit, params2.owner, params2.repo, {
9031
9031
  items: params2.filePaths,
9032
9032
  aliasPrefix: "file",
9033
- buildFragment: (path24, index) => {
9034
- const escapedPath = safeGraphQLString(path24, "path");
9033
+ buildFragment: (path25, index) => {
9034
+ const escapedPath = safeGraphQLString(path25, "path");
9035
9035
  return `
9036
9036
  file${index}: object(expression: "${escapedRef}") {
9037
9037
  ... on Commit {
@@ -9346,11 +9346,11 @@ var GithubSCMLib = class _GithubSCMLib extends SCMLib {
9346
9346
  markdownComment: comment
9347
9347
  });
9348
9348
  }
9349
- async getRepoBlameRanges(ref, path24) {
9349
+ async getRepoBlameRanges(ref, path25) {
9350
9350
  this._validateUrl();
9351
9351
  return await this.githubSdk.getGithubBlameRanges({
9352
9352
  ref,
9353
- path: path24,
9353
+ path: path25,
9354
9354
  gitHubUrl: this.url
9355
9355
  });
9356
9356
  }
@@ -10282,13 +10282,13 @@ function parseGitlabOwnerAndRepo(gitlabUrl) {
10282
10282
  const { organization, repoName, projectPath } = parsingResult;
10283
10283
  return { owner: organization, repo: repoName, projectPath };
10284
10284
  }
10285
- async function getGitlabBlameRanges({ ref, gitlabUrl, path: path24 }, options) {
10285
+ async function getGitlabBlameRanges({ ref, gitlabUrl, path: path25 }, options) {
10286
10286
  const { projectPath } = parseGitlabOwnerAndRepo(gitlabUrl);
10287
10287
  const api2 = getGitBeaker({
10288
10288
  url: gitlabUrl,
10289
10289
  gitlabAuthToken: options?.gitlabAuthToken
10290
10290
  });
10291
- const resp = await api2.RepositoryFiles.allFileBlames(projectPath, path24, ref);
10291
+ const resp = await api2.RepositoryFiles.allFileBlames(projectPath, path25, ref);
10292
10292
  let lineNumber = 1;
10293
10293
  return resp.filter((range) => range.lines).map((range) => {
10294
10294
  const oldLineNumber = lineNumber;
@@ -10462,10 +10462,10 @@ var GitlabSCMLib = class extends SCMLib {
10462
10462
  markdownComment: comment
10463
10463
  });
10464
10464
  }
10465
- async getRepoBlameRanges(ref, path24) {
10465
+ async getRepoBlameRanges(ref, path25) {
10466
10466
  this._validateUrl();
10467
10467
  return await getGitlabBlameRanges(
10468
- { ref, path: path24, gitlabUrl: this.url },
10468
+ { ref, path: path25, gitlabUrl: this.url },
10469
10469
  {
10470
10470
  url: this.url,
10471
10471
  gitlabAuthToken: this.accessToken
@@ -11555,7 +11555,8 @@ var mobbCliCommand = {
11555
11555
  uploadAiBlame: "upload-ai-blame",
11556
11556
  claudeCodeInstallHook: "claude-code-install-hook",
11557
11557
  claudeCodeProcessHook: "claude-code-process-hook",
11558
- windsurfIntellijMonitor: "windsurf-intellij-monitor"
11558
+ windsurfIntellijInstallHook: "windsurf-intellij-install-hook",
11559
+ windsurfIntellijProcessHook: "windsurf-intellij-process-hook"
11559
11560
  };
11560
11561
  var ScanContext = {
11561
11562
  FULL_SCAN: "FULL_SCAN",
@@ -12885,7 +12886,7 @@ async function postIssueComment(params) {
12885
12886
  fpDescription
12886
12887
  } = params;
12887
12888
  const {
12888
- path: path24,
12889
+ path: path25,
12889
12890
  startLine,
12890
12891
  vulnerabilityReportIssue: {
12891
12892
  vulnerabilityReportIssueTags,
@@ -12900,7 +12901,7 @@ async function postIssueComment(params) {
12900
12901
  Refresh the page in order to see the changes.`,
12901
12902
  pull_number: pullRequest,
12902
12903
  commit_id: commitSha,
12903
- path: path24,
12904
+ path: path25,
12904
12905
  line: startLine
12905
12906
  });
12906
12907
  const commentId = commentRes.data.id;
@@ -12934,7 +12935,7 @@ async function postFixComment(params) {
12934
12935
  scanner
12935
12936
  } = params;
12936
12937
  const {
12937
- path: path24,
12938
+ path: path25,
12938
12939
  startLine,
12939
12940
  vulnerabilityReportIssue: { fixId, vulnerabilityReportIssueTags, category },
12940
12941
  vulnerabilityReportIssueId
@@ -12952,7 +12953,7 @@ async function postFixComment(params) {
12952
12953
  Refresh the page in order to see the changes.`,
12953
12954
  pull_number: pullRequest,
12954
12955
  commit_id: commitSha,
12955
- path: path24,
12956
+ path: path25,
12956
12957
  line: startLine
12957
12958
  });
12958
12959
  const commentId = commentRes.data.id;
@@ -13542,8 +13543,8 @@ if (typeof __filename !== "undefined") {
13542
13543
  }
13543
13544
  var costumeRequire = createRequire(moduleUrl);
13544
13545
  var getCheckmarxPath = () => {
13545
- const os13 = type();
13546
- const cxFileName = os13 === "Windows_NT" ? "cx.exe" : "cx";
13546
+ const os14 = type();
13547
+ const cxFileName = os14 === "Windows_NT" ? "cx.exe" : "cx";
13547
13548
  try {
13548
13549
  return costumeRequire.resolve(`.bin/${cxFileName}`);
13549
13550
  } catch (e) {
@@ -15698,8 +15699,8 @@ var WorkspaceService = class {
15698
15699
  * Sets a known workspace path that was discovered through successful validation
15699
15700
  * @param path The validated workspace path to store
15700
15701
  */
15701
- static setKnownWorkspacePath(path24) {
15702
- this.knownWorkspacePath = path24;
15702
+ static setKnownWorkspacePath(path25) {
15703
+ this.knownWorkspacePath = path25;
15703
15704
  }
15704
15705
  /**
15705
15706
  * Gets the known workspace path that was previously validated
@@ -16972,10 +16973,10 @@ var getHostInfo = (additionalMcpList) => {
16972
16973
  const ideConfigPaths = /* @__PURE__ */ new Set();
16973
16974
  for (const ide of IDEs) {
16974
16975
  const configPaths = getMCPConfigPaths(ide);
16975
- configPaths.forEach((path24) => ideConfigPaths.add(path24));
16976
+ configPaths.forEach((path25) => ideConfigPaths.add(path25));
16976
16977
  }
16977
16978
  const uniqueAdditionalPaths = additionalMcpList.filter(
16978
- (path24) => !ideConfigPaths.has(path24)
16979
+ (path25) => !ideConfigPaths.has(path25)
16979
16980
  );
16980
16981
  for (const ide of IDEs) {
16981
16982
  const cfg = readMCPConfig(ide);
@@ -20268,7 +20269,7 @@ init_configs();
20268
20269
  import fs19 from "fs/promises";
20269
20270
  import nodePath from "path";
20270
20271
  var getLocalFiles = async ({
20271
- path: path24,
20272
+ path: path25,
20272
20273
  maxFileSize = MCP_MAX_FILE_SIZE,
20273
20274
  maxFiles,
20274
20275
  isAllFilesScan,
@@ -20276,17 +20277,17 @@ var getLocalFiles = async ({
20276
20277
  scanRecentlyChangedFiles
20277
20278
  }) => {
20278
20279
  logDebug(`[${scanContext}] Starting getLocalFiles`, {
20279
- path: path24,
20280
+ path: path25,
20280
20281
  maxFileSize,
20281
20282
  maxFiles,
20282
20283
  isAllFilesScan,
20283
20284
  scanRecentlyChangedFiles
20284
20285
  });
20285
20286
  try {
20286
- const resolvedRepoPath = await fs19.realpath(path24);
20287
+ const resolvedRepoPath = await fs19.realpath(path25);
20287
20288
  logDebug(`[${scanContext}] Resolved repository path`, {
20288
20289
  resolvedRepoPath,
20289
- originalPath: path24
20290
+ originalPath: path25
20290
20291
  });
20291
20292
  const gitService = new GitService(resolvedRepoPath, log);
20292
20293
  const gitValidation = await gitService.validateRepository();
@@ -20299,7 +20300,7 @@ var getLocalFiles = async ({
20299
20300
  if (!gitValidation.isValid || isAllFilesScan) {
20300
20301
  try {
20301
20302
  files = await FileUtils.getLastChangedFiles({
20302
- dir: path24,
20303
+ dir: path25,
20303
20304
  maxFileSize,
20304
20305
  maxFiles,
20305
20306
  isAllFilesScan
@@ -20391,7 +20392,7 @@ var getLocalFiles = async ({
20391
20392
  logError(`${scanContext}Unexpected error in getLocalFiles`, {
20392
20393
  error: error instanceof Error ? error.message : String(error),
20393
20394
  stack: error instanceof Error ? error.stack : void 0,
20394
- path: path24
20395
+ path: path25
20395
20396
  });
20396
20397
  throw error;
20397
20398
  }
@@ -22539,14 +22540,14 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
22539
22540
  * since the last scan.
22540
22541
  */
22541
22542
  async scanForSecurityVulnerabilities({
22542
- path: path24,
22543
+ path: path25,
22543
22544
  isAllDetectionRulesScan,
22544
22545
  isAllFilesScan,
22545
22546
  scanContext
22546
22547
  }) {
22547
22548
  this.hasAuthenticationFailed = false;
22548
22549
  logDebug(`[${scanContext}] Scanning for new security vulnerabilities`, {
22549
- path: path24
22550
+ path: path25
22550
22551
  });
22551
22552
  if (!this.gqlClient) {
22552
22553
  logInfo(`[${scanContext}] No GQL client found, skipping scan`);
@@ -22562,11 +22563,11 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
22562
22563
  }
22563
22564
  logDebug(
22564
22565
  `[${scanContext}] Connected to the API, assembling list of files to scan`,
22565
- { path: path24 }
22566
+ { path: path25 }
22566
22567
  );
22567
22568
  const isBackgroundScan = scanContext === ScanContext.BACKGROUND_INITIAL || scanContext === ScanContext.BACKGROUND_PERIODIC;
22568
22569
  const files = await getLocalFiles({
22569
- path: path24,
22570
+ path: path25,
22570
22571
  isAllFilesScan,
22571
22572
  scanContext,
22572
22573
  scanRecentlyChangedFiles: !isBackgroundScan
@@ -22592,13 +22593,13 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
22592
22593
  });
22593
22594
  const { fixReportId, projectId } = await scanFiles({
22594
22595
  fileList: filesToScan.map((file) => file.relativePath),
22595
- repositoryPath: path24,
22596
+ repositoryPath: path25,
22596
22597
  gqlClient: this.gqlClient,
22597
22598
  isAllDetectionRulesScan,
22598
22599
  scanContext
22599
22600
  });
22600
22601
  logInfo(
22601
- `[${scanContext}] Security scan completed for ${path24} reportId: ${fixReportId} projectId: ${projectId}`
22602
+ `[${scanContext}] Security scan completed for ${path25} reportId: ${fixReportId} projectId: ${projectId}`
22602
22603
  );
22603
22604
  if (isAllFilesScan) {
22604
22605
  return;
@@ -22892,13 +22893,13 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
22892
22893
  });
22893
22894
  return scannedFiles.some((file) => file.relativePath === fixFile);
22894
22895
  }
22895
- async getFreshFixes({ path: path24 }) {
22896
+ async getFreshFixes({ path: path25 }) {
22896
22897
  const scanContext = ScanContext.USER_REQUEST;
22897
- logDebug(`[${scanContext}] Getting fresh fixes`, { path: path24 });
22898
- if (this.path !== path24) {
22899
- this.path = path24;
22898
+ logDebug(`[${scanContext}] Getting fresh fixes`, { path: path25 });
22899
+ if (this.path !== path25) {
22900
+ this.path = path25;
22900
22901
  this.reset();
22901
- logInfo(`[${scanContext}] Reset service state for new path`, { path: path24 });
22902
+ logInfo(`[${scanContext}] Reset service state for new path`, { path: path25 });
22902
22903
  }
22903
22904
  try {
22904
22905
  const loginContext = createMcpLoginContext("check_new_fixes");
@@ -22917,7 +22918,7 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
22917
22918
  }
22918
22919
  throw error;
22919
22920
  }
22920
- this.triggerScan({ path: path24, gqlClient: this.gqlClient });
22921
+ this.triggerScan({ path: path25, gqlClient: this.gqlClient });
22921
22922
  let isMvsAutoFixEnabled = null;
22922
22923
  try {
22923
22924
  isMvsAutoFixEnabled = await this.gqlClient.getMvsAutoFixSettings();
@@ -22951,33 +22952,33 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
22951
22952
  return noFreshFixesPrompt;
22952
22953
  }
22953
22954
  triggerScan({
22954
- path: path24,
22955
+ path: path25,
22955
22956
  gqlClient
22956
22957
  }) {
22957
- if (this.path !== path24) {
22958
- this.path = path24;
22958
+ if (this.path !== path25) {
22959
+ this.path = path25;
22959
22960
  this.reset();
22960
- logInfo(`Reset service state for new path in triggerScan`, { path: path24 });
22961
+ logInfo(`Reset service state for new path in triggerScan`, { path: path25 });
22961
22962
  }
22962
22963
  this.gqlClient = gqlClient;
22963
22964
  if (!this.intervalId) {
22964
- this.startPeriodicScanning(path24);
22965
- this.executeInitialScan(path24);
22966
- void this.executeInitialFullScan(path24);
22965
+ this.startPeriodicScanning(path25);
22966
+ this.executeInitialScan(path25);
22967
+ void this.executeInitialFullScan(path25);
22967
22968
  }
22968
22969
  }
22969
- startPeriodicScanning(path24) {
22970
+ startPeriodicScanning(path25) {
22970
22971
  const scanContext = ScanContext.BACKGROUND_PERIODIC;
22971
22972
  logDebug(
22972
22973
  `[${scanContext}] Starting periodic scan for new security vulnerabilities`,
22973
22974
  {
22974
- path: path24
22975
+ path: path25
22975
22976
  }
22976
22977
  );
22977
22978
  this.intervalId = setInterval(() => {
22978
- logDebug(`[${scanContext}] Triggering periodic security scan`, { path: path24 });
22979
+ logDebug(`[${scanContext}] Triggering periodic security scan`, { path: path25 });
22979
22980
  this.scanForSecurityVulnerabilities({
22980
- path: path24,
22981
+ path: path25,
22981
22982
  scanContext
22982
22983
  }).catch((error) => {
22983
22984
  logError(`[${scanContext}] Error during periodic security scan`, {
@@ -22986,45 +22987,45 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
22986
22987
  });
22987
22988
  }, MCP_PERIODIC_CHECK_INTERVAL);
22988
22989
  }
22989
- async executeInitialFullScan(path24) {
22990
+ async executeInitialFullScan(path25) {
22990
22991
  const scanContext = ScanContext.FULL_SCAN;
22991
- logDebug(`[${scanContext}] Triggering initial full security scan`, { path: path24 });
22992
+ logDebug(`[${scanContext}] Triggering initial full security scan`, { path: path25 });
22992
22993
  logDebug(`[${scanContext}] Full scan paths scanned`, {
22993
22994
  fullScanPathsScanned: this.fullScanPathsScanned
22994
22995
  });
22995
- if (this.fullScanPathsScanned.includes(path24)) {
22996
+ if (this.fullScanPathsScanned.includes(path25)) {
22996
22997
  logDebug(`[${scanContext}] Full scan already executed for this path`, {
22997
- path: path24
22998
+ path: path25
22998
22999
  });
22999
23000
  return;
23000
23001
  }
23001
23002
  configStore.set("fullScanPathsScanned", [
23002
23003
  ...this.fullScanPathsScanned,
23003
- path24
23004
+ path25
23004
23005
  ]);
23005
23006
  try {
23006
23007
  await this.scanForSecurityVulnerabilities({
23007
- path: path24,
23008
+ path: path25,
23008
23009
  isAllFilesScan: true,
23009
23010
  isAllDetectionRulesScan: true,
23010
23011
  scanContext: ScanContext.FULL_SCAN
23011
23012
  });
23012
- if (!this.fullScanPathsScanned.includes(path24)) {
23013
- this.fullScanPathsScanned.push(path24);
23013
+ if (!this.fullScanPathsScanned.includes(path25)) {
23014
+ this.fullScanPathsScanned.push(path25);
23014
23015
  configStore.set("fullScanPathsScanned", this.fullScanPathsScanned);
23015
23016
  }
23016
- logInfo(`[${scanContext}] Full scan completed`, { path: path24 });
23017
+ logInfo(`[${scanContext}] Full scan completed`, { path: path25 });
23017
23018
  } catch (error) {
23018
23019
  logError(`[${scanContext}] Error during initial full security scan`, {
23019
23020
  error
23020
23021
  });
23021
23022
  }
23022
23023
  }
23023
- executeInitialScan(path24) {
23024
+ executeInitialScan(path25) {
23024
23025
  const scanContext = ScanContext.BACKGROUND_INITIAL;
23025
- logDebug(`[${scanContext}] Triggering initial security scan`, { path: path24 });
23026
+ logDebug(`[${scanContext}] Triggering initial security scan`, { path: path25 });
23026
23027
  this.scanForSecurityVulnerabilities({
23027
- path: path24,
23028
+ path: path25,
23028
23029
  scanContext: ScanContext.BACKGROUND_INITIAL
23029
23030
  }).catch((error) => {
23030
23031
  logError(`[${scanContext}] Error during initial security scan`, { error });
@@ -23121,9 +23122,9 @@ Example payload:
23121
23122
  `Invalid path: potential security risk detected in path: ${pathValidationResult.error}`
23122
23123
  );
23123
23124
  }
23124
- const path24 = pathValidationResult.path;
23125
+ const path25 = pathValidationResult.path;
23125
23126
  const resultText = await this.newFixesService.getFreshFixes({
23126
- path: path24
23127
+ path: path25
23127
23128
  });
23128
23129
  logInfo("CheckForNewAvailableFixesTool execution completed", {
23129
23130
  resultText
@@ -23301,8 +23302,8 @@ Call this tool instead of ${MCP_TOOL_SCAN_AND_FIX_VULNERABILITIES} when you only
23301
23302
  `Invalid path: potential security risk detected in path: ${pathValidationResult.error}`
23302
23303
  );
23303
23304
  }
23304
- const path24 = pathValidationResult.path;
23305
- const gitService = new GitService(path24, log);
23305
+ const path25 = pathValidationResult.path;
23306
+ const gitService = new GitService(path25, log);
23306
23307
  const gitValidation = await gitService.validateRepository();
23307
23308
  if (!gitValidation.isValid) {
23308
23309
  throw new Error(`Invalid git repository: ${gitValidation.error}`);
@@ -23687,9 +23688,9 @@ Example payload:
23687
23688
  `Invalid path: potential security risk detected in path: ${pathValidationResult.error}`
23688
23689
  );
23689
23690
  }
23690
- const path24 = pathValidationResult.path;
23691
+ const path25 = pathValidationResult.path;
23691
23692
  const files = await getLocalFiles({
23692
- path: path24,
23693
+ path: path25,
23693
23694
  maxFileSize: MCP_MAX_FILE_SIZE,
23694
23695
  maxFiles: args.maxFiles,
23695
23696
  scanContext: ScanContext.USER_REQUEST,
@@ -23709,7 +23710,7 @@ Example payload:
23709
23710
  try {
23710
23711
  const fixResult = await this.vulnerabilityFixService.processVulnerabilities({
23711
23712
  fileList: files.map((file) => file.relativePath),
23712
- repositoryPath: path24,
23713
+ repositoryPath: path25,
23713
23714
  offset: args.offset,
23714
23715
  limit: args.limit,
23715
23716
  isRescan: args.rescan || !!args.maxFiles
@@ -23922,10 +23923,8 @@ async function addScmTokenHandler(args) {
23922
23923
  await addScmToken(args);
23923
23924
  }
23924
23925
 
23925
- // src/features/codeium_intellij/data_collector_monitor.ts
23926
- import { setTimeout as setTimeout4 } from "timers/promises";
23927
-
23928
23926
  // src/features/codeium_intellij/data_collector.ts
23927
+ import { z as z46 } from "zod";
23929
23928
  init_GitService();
23930
23929
 
23931
23930
  // src/features/codeium_intellij/codeium_language_server_grpc_client.ts
@@ -24065,9 +24064,45 @@ function findRunningCodeiumLanguageServers() {
24065
24064
  }
24066
24065
 
24067
24066
  // src/features/codeium_intellij/data_collector.ts
24068
- async function getLatestInferences(startFrom) {
24067
+ var HookDataSchema2 = z46.object({
24068
+ trajectory_id: z46.string()
24069
+ });
24070
+ async function processAndUploadHookData2() {
24071
+ const tracePayload = await getTraceDataForHook();
24072
+ if (!tracePayload) {
24073
+ console.warn("Warning: Failed to retrieve chat data.");
24074
+ return;
24075
+ }
24076
+ try {
24077
+ const uploadSuccess = await uploadAiBlameHandlerFromExtension({
24078
+ prompts: tracePayload.prompts,
24079
+ inference: tracePayload.inference,
24080
+ model: tracePayload.model,
24081
+ tool: tracePayload.tool,
24082
+ responseTime: tracePayload.responseTime,
24083
+ blameType: "CHAT" /* Chat */,
24084
+ sessionId: tracePayload.sessionId,
24085
+ repositoryUrl: tracePayload.repositoryUrl
24086
+ });
24087
+ if (uploadSuccess) {
24088
+ console.log("Uploaded trace data.");
24089
+ } else {
24090
+ console.warn("Failed to upload trace data.");
24091
+ }
24092
+ } catch (e) {
24093
+ console.warn("Failed to upload trace data:", e);
24094
+ }
24095
+ }
24096
+ function validateHookData2(data) {
24097
+ return HookDataSchema2.parse(data);
24098
+ }
24099
+ async function getTraceDataForHook() {
24100
+ const rawData = await readStdinData();
24101
+ const hookData = validateHookData2(rawData);
24102
+ return await getTraceDataForTrajectory(hookData.trajectory_id);
24103
+ }
24104
+ async function getTraceDataForTrajectory(trajectoryId) {
24069
24105
  const instances = findRunningCodeiumLanguageServers();
24070
- const results = [];
24071
24106
  for (const instance of instances) {
24072
24107
  const client = await getGrpcClient(instance.port, instance.csrf);
24073
24108
  if (!client) {
@@ -24077,20 +24112,13 @@ async function getLatestInferences(startFrom) {
24077
24112
  for (const [cascadeId, chatSummary] of Object.entries(
24078
24113
  chats.trajectorySummaries
24079
24114
  )) {
24080
- const chatLastModifiedSecStr = chatSummary.lastModifiedTime?.seconds;
24081
- if (!chatLastModifiedSecStr) {
24115
+ if (chatSummary.trajectoryId !== trajectoryId) {
24082
24116
  continue;
24083
24117
  }
24084
- const chatLastModifiedSec = Number(chatLastModifiedSecStr);
24085
- if (chatLastModifiedSec >= Math.floor(startFrom.getTime() / 1e3)) {
24086
- const traceData = await processChat(client, cascadeId);
24087
- if (traceData) {
24088
- results.push(traceData);
24089
- }
24090
- }
24118
+ return await processChat(client, cascadeId);
24091
24119
  }
24092
24120
  }
24093
- return results;
24121
+ return null;
24094
24122
  }
24095
24123
  async function processChat(client, cascadeId) {
24096
24124
  const chatDetails = await client.GetCascadeTrajectory({
@@ -24186,7 +24214,11 @@ function processChatStepPlannerResponse(step) {
24186
24214
  }
24187
24215
  function processChatStepCodeAction(step) {
24188
24216
  const inferences = [];
24217
+ const toolCallName = step.metadata?.toolCall?.name;
24189
24218
  const unifiedDiff = step.codeAction?.actionResult?.edit?.diff?.unifiedDiff;
24219
+ if (!toolCallName) {
24220
+ return { prompts: [], inferences };
24221
+ }
24190
24222
  if (!unifiedDiff) {
24191
24223
  return { prompts: [], inferences };
24192
24224
  }
@@ -24198,63 +24230,119 @@ function processChatStepCodeAction(step) {
24198
24230
  return { prompts: [], inferences };
24199
24231
  }
24200
24232
 
24201
- // src/features/codeium_intellij/data_collector_monitor.ts
24202
- var POLL_INTERVAL = 5 * 1e3;
24203
- async function startMonitoring() {
24204
- await getAuthenticatedGQLClient({ isSkipPrompts: true });
24205
- let lastUpdateTs = /* @__PURE__ */ new Date();
24206
- for (; ; ) {
24207
- let tracePayloads = [];
24208
- try {
24209
- const startFrom = lastUpdateTs;
24210
- lastUpdateTs = /* @__PURE__ */ new Date();
24211
- tracePayloads = await getLatestInferences(startFrom);
24212
- } catch (e) {
24213
- console.error("Failed to retrieve Windsurf IntelliJ inferences.", e);
24214
- }
24215
- for (const tracePayload of tracePayloads) {
24216
- await tryUpload(tracePayload);
24217
- }
24218
- await setTimeout4(POLL_INTERVAL);
24219
- }
24233
+ // src/features/codeium_intellij/install_hook.ts
24234
+ import fsPromises6 from "fs/promises";
24235
+ import os13 from "os";
24236
+ import path24 from "path";
24237
+ import chalk12 from "chalk";
24238
+ function getCodeiumHooksPath() {
24239
+ return path24.join(os13.homedir(), ".codeium", "hooks.json");
24220
24240
  }
24221
- async function tryUpload(tracePayload) {
24241
+ async function readCodeiumHooks() {
24242
+ const hooksPath = getCodeiumHooksPath();
24222
24243
  try {
24223
- const uploadSuccess = await uploadAiBlameHandlerFromExtension({
24224
- prompts: tracePayload.prompts,
24225
- inference: tracePayload.inference,
24226
- model: tracePayload.model,
24227
- tool: tracePayload.tool,
24228
- responseTime: tracePayload.responseTime,
24229
- blameType: "CHAT" /* Chat */,
24230
- sessionId: tracePayload.sessionId,
24231
- repositoryUrl: tracePayload.repositoryUrl
24232
- });
24233
- if (uploadSuccess) {
24234
- console.log("Uploaded trace data.");
24235
- } else {
24236
- console.warn("Failed to upload trace data.");
24244
+ const content = await fsPromises6.readFile(hooksPath, "utf-8");
24245
+ return JSON.parse(content);
24246
+ } catch {
24247
+ return {};
24248
+ }
24249
+ }
24250
+ async function writeCodeiumHooks(config2) {
24251
+ const hooksPath = getCodeiumHooksPath();
24252
+ const dir = path24.dirname(hooksPath);
24253
+ await fsPromises6.mkdir(dir, { recursive: true });
24254
+ await fsPromises6.writeFile(
24255
+ hooksPath,
24256
+ JSON.stringify(config2, null, 2),
24257
+ "utf-8"
24258
+ );
24259
+ }
24260
+ async function installWindsurfHooks(options = {}) {
24261
+ const hooksPath = getCodeiumHooksPath();
24262
+ console.log(chalk12.blue("Installing Mobb hooks in Windsurf IntelliJ..."));
24263
+ const config2 = await readCodeiumHooks();
24264
+ if (!config2.hooks) {
24265
+ config2.hooks = {};
24266
+ }
24267
+ if (!config2.hooks.post_write_code) {
24268
+ config2.hooks.post_write_code = [];
24269
+ }
24270
+ let command = "npx --yes mobbdev@latest windsurf-intellij-process-hook";
24271
+ if (options.saveEnv) {
24272
+ const envVars = [];
24273
+ if (process.env["WEB_APP_URL"]) {
24274
+ envVars.push(`WEB_APP_URL="${process.env["WEB_APP_URL"]}"`);
24275
+ }
24276
+ if (process.env["API_URL"]) {
24277
+ envVars.push(`API_URL="${process.env["API_URL"]}"`);
24278
+ }
24279
+ if (envVars.length > 0) {
24280
+ command = `${envVars.join(" ")} ${command}`;
24281
+ console.log(
24282
+ chalk12.blue(
24283
+ `Adding environment variables to hook command: ${envVars.join(", ")}`
24284
+ )
24285
+ );
24237
24286
  }
24238
- } catch (e) {
24239
- console.warn("Failed to upload trace data:", e);
24240
24287
  }
24288
+ const mobbHook = {
24289
+ command,
24290
+ show_output: true
24291
+ };
24292
+ const existingHookIndex = config2.hooks.post_write_code.findIndex(
24293
+ (hook) => hook.command?.includes("mobbdev@latest windsurf-intellij-process-hook")
24294
+ );
24295
+ if (existingHookIndex >= 0) {
24296
+ console.log(chalk12.yellow("Mobb hook already exists, updating..."));
24297
+ config2.hooks.post_write_code[existingHookIndex] = mobbHook;
24298
+ } else {
24299
+ console.log(chalk12.green("Adding new Mobb hook..."));
24300
+ config2.hooks.post_write_code.push(mobbHook);
24301
+ }
24302
+ await writeCodeiumHooks(config2);
24303
+ console.log(
24304
+ chalk12.green(
24305
+ `\u2705 Mobb hooks ${options.saveEnv ? "and environment variables " : ""}installed successfully in ${hooksPath}`
24306
+ )
24307
+ );
24241
24308
  }
24242
24309
 
24243
24310
  // src/args/commands/windsurf_intellij.ts
24244
- var windsurfIntellijMonitorBuilder = (yargs2) => {
24311
+ var windsurfIntellijInstallHookBuilder = (yargs2) => {
24312
+ return yargs2.option("save-env", {
24313
+ type: "boolean",
24314
+ description: "Save WEB_APP_URL, and API_URL environment variables to hooks config",
24315
+ default: false
24316
+ }).example(
24317
+ "$0 windsurf-intellij-install-hook",
24318
+ "Install Windsurf IntelliJ hooks for data collection"
24319
+ ).example(
24320
+ "$0 windsurf-intellij-install-hook --save-env",
24321
+ "Install hooks and save environment variables to config"
24322
+ ).strict();
24323
+ };
24324
+ var windsurfIntellijProcessHookBuilder = (yargs2) => {
24245
24325
  return yargs2.example(
24246
- "$0 windsurf-intellij-monitor",
24247
- "Start monitoring Windsurf IntelliJ for AI inference data"
24326
+ "$0 windsurf-intellij-process-hook",
24327
+ "Process Windsurf IntelliJ hook data and upload to backend"
24248
24328
  ).strict();
24249
24329
  };
24250
- var windsurfIntellijMonitorHandler = async () => {
24330
+ var windsurfIntellijInstallHookHandler = async (argv) => {
24251
24331
  try {
24252
- console.log("Starting Windsurf IntelliJ monitor...");
24253
- console.log("Polling for AI inference data from running IDE instances.");
24254
- console.log("Press Ctrl+C to stop.\n");
24255
- await startMonitoring();
24332
+ await getAuthenticatedGQLClient({ isSkipPrompts: false });
24333
+ await installWindsurfHooks({ saveEnv: argv["save-env"] });
24334
+ process.exit(0);
24256
24335
  } catch (error) {
24257
- console.error("Windsurf IntelliJ monitor failed:", error);
24336
+ console.error("Failed to install Windsurf IntelliJ hooks:", error);
24337
+ process.exit(1);
24338
+ }
24339
+ };
24340
+ var windsurfIntellijProcessHookHandler = async () => {
24341
+ try {
24342
+ await processAndUploadHookData2();
24343
+ process.exit(0);
24344
+ } catch (error) {
24345
+ console.error("Failed to process Windsurf IntelliJ hook data:", error);
24258
24346
  process.exit(1);
24259
24347
  }
24260
24348
  };
@@ -24263,78 +24351,83 @@ var windsurfIntellijMonitorHandler = async () => {
24263
24351
  var parseArgs = async (args) => {
24264
24352
  const yargsInstance = yargs(args);
24265
24353
  return yargsInstance.updateStrings({
24266
- "Commands:": chalk12.yellow.underline.bold("Commands:"),
24267
- "Options:": chalk12.yellow.underline.bold("Options:"),
24268
- "Examples:": chalk12.yellow.underline.bold("Examples:"),
24269
- "Show help": chalk12.bold("Show help")
24354
+ "Commands:": chalk13.yellow.underline.bold("Commands:"),
24355
+ "Options:": chalk13.yellow.underline.bold("Options:"),
24356
+ "Examples:": chalk13.yellow.underline.bold("Examples:"),
24357
+ "Show help": chalk13.bold("Show help")
24270
24358
  }).usage(
24271
- `${chalk12.bold(
24359
+ `${chalk13.bold(
24272
24360
  "\n Bugsy - Trusted, Automatic Vulnerability Fixer \u{1F575}\uFE0F\u200D\u2642\uFE0F\n\n"
24273
- )} ${chalk12.yellow.underline.bold("Usage:")}
24274
- $0 ${chalk12.green(
24361
+ )} ${chalk13.yellow.underline.bold("Usage:")}
24362
+ $0 ${chalk13.green(
24275
24363
  "<command>"
24276
- )} ${chalk12.dim("[options]")}
24364
+ )} ${chalk13.dim("[options]")}
24277
24365
  `
24278
24366
  ).version(false).command(
24279
24367
  mobbCliCommand.scan,
24280
- chalk12.bold(
24368
+ chalk13.bold(
24281
24369
  "Scan your code for vulnerabilities, get automated fixes right away."
24282
24370
  ),
24283
24371
  scanBuilder,
24284
24372
  scanHandler
24285
24373
  ).command(
24286
24374
  mobbCliCommand.analyze,
24287
- chalk12.bold(
24375
+ chalk13.bold(
24288
24376
  "Provide a code repository, get automated fixes right away. You can also provide a vulnerability report to analyze or have Mobb scan the code for you."
24289
24377
  ),
24290
24378
  analyzeBuilder,
24291
24379
  analyzeHandler
24292
24380
  ).command(
24293
24381
  mobbCliCommand.review,
24294
- chalk12.bold(
24382
+ chalk13.bold(
24295
24383
  "Mobb will review your github pull requests and provide comments with fixes "
24296
24384
  ),
24297
24385
  reviewBuilder,
24298
24386
  reviewHandler
24299
24387
  ).command(
24300
24388
  mobbCliCommand.addScmToken,
24301
- chalk12.bold(
24389
+ chalk13.bold(
24302
24390
  "Add your SCM (Github, Gitlab, Azure DevOps) token to Mobb to enable automated fixes."
24303
24391
  ),
24304
24392
  addScmTokenBuilder,
24305
24393
  addScmTokenHandler
24306
24394
  ).command(
24307
24395
  mobbCliCommand.convertToSarif,
24308
- chalk12.bold("Convert an existing SAST report to SARIF format."),
24396
+ chalk13.bold("Convert an existing SAST report to SARIF format."),
24309
24397
  convertToSarifBuilder,
24310
24398
  convertToSarifHandler
24311
24399
  ).command(
24312
24400
  mobbCliCommand.mcp,
24313
- chalk12.bold("Launch the MCP (Model Context Protocol) server."),
24401
+ chalk13.bold("Launch the MCP (Model Context Protocol) server."),
24314
24402
  mcpBuilder,
24315
24403
  mcpHandler
24316
24404
  ).command(
24317
24405
  mobbCliCommand.uploadAiBlame,
24318
- chalk12.bold(
24406
+ chalk13.bold(
24319
24407
  "Upload AI Blame inference artifacts (prompt + inference) and finalize them."
24320
24408
  ),
24321
24409
  uploadAiBlameBuilder,
24322
24410
  uploadAiBlameCommandHandler
24323
24411
  ).command(
24324
24412
  mobbCliCommand.claudeCodeInstallHook,
24325
- chalk12.bold("Install Claude Code hooks for data collection."),
24413
+ chalk13.bold("Install Claude Code hooks for data collection."),
24326
24414
  claudeCodeInstallHookBuilder,
24327
24415
  claudeCodeInstallHookHandler
24328
24416
  ).command(
24329
24417
  mobbCliCommand.claudeCodeProcessHook,
24330
- chalk12.bold("Process Claude Code hook data and upload to backend."),
24418
+ chalk13.bold("Process Claude Code hook data and upload to backend."),
24331
24419
  claudeCodeProcessHookBuilder,
24332
24420
  claudeCodeProcessHookHandler
24333
24421
  ).command(
24334
- mobbCliCommand.windsurfIntellijMonitor,
24335
- chalk12.bold("Monitor Windsurf IntelliJ for AI inference data."),
24336
- windsurfIntellijMonitorBuilder,
24337
- windsurfIntellijMonitorHandler
24422
+ mobbCliCommand.windsurfIntellijInstallHook,
24423
+ chalk13.bold("Install Windsurf IntelliJ hooks for data collection."),
24424
+ windsurfIntellijInstallHookBuilder,
24425
+ windsurfIntellijInstallHookHandler
24426
+ ).command(
24427
+ mobbCliCommand.windsurfIntellijProcessHook,
24428
+ chalk13.bold("Process Windsurf IntelliJ hook data and upload to backend."),
24429
+ windsurfIntellijProcessHookBuilder,
24430
+ windsurfIntellijProcessHookHandler
24338
24431
  ).example(
24339
24432
  "npx mobbdev@latest scan -r https://github.com/WebGoat/WebGoat",
24340
24433
  "Scan an existing repository"
@@ -24343,7 +24436,7 @@ var parseArgs = async (args) => {
24343
24436
  handler() {
24344
24437
  yargsInstance.showHelp();
24345
24438
  }
24346
- }).strictOptions().help("h").alias("h", "help").epilog(chalk12.bgBlue("Made with \u2764\uFE0F by Mobb")).showHelpOnFail(true).wrap(Math.min(120, yargsInstance.terminalWidth())).parse();
24439
+ }).strictOptions().help("h").alias("h", "help").epilog(chalk13.bgBlue("Made with \u2764\uFE0F by Mobb")).showHelpOnFail(true).wrap(Math.min(120, yargsInstance.terminalWidth())).parse();
24347
24440
  };
24348
24441
 
24349
24442
  // src/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobbdev",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
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",