mobbdev 1.1.45 → 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.
- package/LICENSE +1 -1
- package/dist/index.mjs +530 -94
- package/package.json +5 -2
- package/src/features/codeium_intellij/proto/buf/validate/validate.proto +504 -0
- package/src/features/codeium_intellij/proto/exa/auto_cascade_common_pb/auto_cascade_common.proto +81 -0
- package/src/features/codeium_intellij/proto/exa/bug_checker_pb/bug_checker.proto +24 -0
- package/src/features/codeium_intellij/proto/exa/cascade_plugins_pb/cascade_plugins.proto +108 -0
- package/src/features/codeium_intellij/proto/exa/chat_client_server_pb/chat_client_server.proto +56 -0
- package/src/features/codeium_intellij/proto/exa/chat_pb/chat.proto +457 -0
- package/src/features/codeium_intellij/proto/exa/code_edit/code_edit_pb/code_edit.proto +191 -0
- package/src/features/codeium_intellij/proto/exa/codeium_common_pb/codeium_common.proto +3783 -0
- package/src/features/codeium_intellij/proto/exa/context_module_pb/context_module.proto +172 -0
- package/src/features/codeium_intellij/proto/exa/cortex_pb/cortex.proto +3604 -0
- package/src/features/codeium_intellij/proto/exa/diff_action_pb/diff_action.proto +73 -0
- package/src/features/codeium_intellij/proto/exa/extension_server_pb/extension_server.proto +565 -0
- package/src/features/codeium_intellij/proto/exa/index_pb/index.proto +474 -0
- package/src/features/codeium_intellij/proto/exa/knowledge_base_pb/knowledge_base.proto +149 -0
- package/src/features/codeium_intellij/proto/exa/language_server_pb/language_server.proto +2504 -0
- package/src/features/codeium_intellij/proto/exa/opensearch_clients_pb/opensearch_clients.proto +505 -0
- package/src/features/codeium_intellij/proto/exa/product_analytics_pb/product_analytics.proto +31 -0
- package/src/features/codeium_intellij/proto/exa/reactive_component_pb/reactive_component.proto +104 -0
- package/src/features/codeium_intellij/proto/exa/seat_management_pb/seat_management.proto +2349 -0
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
|
|
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
|
|
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(`${
|
|
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 (
|
|
8184
|
-
const escapedPath = safeGraphQLString(
|
|
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 [
|
|
8233
|
-
result.set(
|
|
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:
|
|
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:
|
|
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: (
|
|
9034
|
-
const escapedPath = safeGraphQLString(
|
|
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,
|
|
9349
|
+
async getRepoBlameRanges(ref, path25) {
|
|
9350
9350
|
this._validateUrl();
|
|
9351
9351
|
return await this.githubSdk.getGithubBlameRanges({
|
|
9352
9352
|
ref,
|
|
9353
|
-
path:
|
|
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:
|
|
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,
|
|
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,
|
|
10465
|
+
async getRepoBlameRanges(ref, path25) {
|
|
10466
10466
|
this._validateUrl();
|
|
10467
10467
|
return await getGitlabBlameRanges(
|
|
10468
|
-
{ ref, path:
|
|
10468
|
+
{ ref, path: path25, gitlabUrl: this.url },
|
|
10469
10469
|
{
|
|
10470
10470
|
url: this.url,
|
|
10471
10471
|
gitlabAuthToken: this.accessToken
|
|
@@ -11554,7 +11554,9 @@ var mobbCliCommand = {
|
|
|
11554
11554
|
mcp: "mcp",
|
|
11555
11555
|
uploadAiBlame: "upload-ai-blame",
|
|
11556
11556
|
claudeCodeInstallHook: "claude-code-install-hook",
|
|
11557
|
-
claudeCodeProcessHook: "claude-code-process-hook"
|
|
11557
|
+
claudeCodeProcessHook: "claude-code-process-hook",
|
|
11558
|
+
windsurfIntellijInstallHook: "windsurf-intellij-install-hook",
|
|
11559
|
+
windsurfIntellijProcessHook: "windsurf-intellij-process-hook"
|
|
11558
11560
|
};
|
|
11559
11561
|
var ScanContext = {
|
|
11560
11562
|
FULL_SCAN: "FULL_SCAN",
|
|
@@ -12884,7 +12886,7 @@ async function postIssueComment(params) {
|
|
|
12884
12886
|
fpDescription
|
|
12885
12887
|
} = params;
|
|
12886
12888
|
const {
|
|
12887
|
-
path:
|
|
12889
|
+
path: path25,
|
|
12888
12890
|
startLine,
|
|
12889
12891
|
vulnerabilityReportIssue: {
|
|
12890
12892
|
vulnerabilityReportIssueTags,
|
|
@@ -12899,7 +12901,7 @@ async function postIssueComment(params) {
|
|
|
12899
12901
|
Refresh the page in order to see the changes.`,
|
|
12900
12902
|
pull_number: pullRequest,
|
|
12901
12903
|
commit_id: commitSha,
|
|
12902
|
-
path:
|
|
12904
|
+
path: path25,
|
|
12903
12905
|
line: startLine
|
|
12904
12906
|
});
|
|
12905
12907
|
const commentId = commentRes.data.id;
|
|
@@ -12933,7 +12935,7 @@ async function postFixComment(params) {
|
|
|
12933
12935
|
scanner
|
|
12934
12936
|
} = params;
|
|
12935
12937
|
const {
|
|
12936
|
-
path:
|
|
12938
|
+
path: path25,
|
|
12937
12939
|
startLine,
|
|
12938
12940
|
vulnerabilityReportIssue: { fixId, vulnerabilityReportIssueTags, category },
|
|
12939
12941
|
vulnerabilityReportIssueId
|
|
@@ -12951,7 +12953,7 @@ async function postFixComment(params) {
|
|
|
12951
12953
|
Refresh the page in order to see the changes.`,
|
|
12952
12954
|
pull_number: pullRequest,
|
|
12953
12955
|
commit_id: commitSha,
|
|
12954
|
-
path:
|
|
12956
|
+
path: path25,
|
|
12955
12957
|
line: startLine
|
|
12956
12958
|
});
|
|
12957
12959
|
const commentId = commentRes.data.id;
|
|
@@ -13541,8 +13543,8 @@ if (typeof __filename !== "undefined") {
|
|
|
13541
13543
|
}
|
|
13542
13544
|
var costumeRequire = createRequire(moduleUrl);
|
|
13543
13545
|
var getCheckmarxPath = () => {
|
|
13544
|
-
const
|
|
13545
|
-
const cxFileName =
|
|
13546
|
+
const os14 = type();
|
|
13547
|
+
const cxFileName = os14 === "Windows_NT" ? "cx.exe" : "cx";
|
|
13546
13548
|
try {
|
|
13547
13549
|
return costumeRequire.resolve(`.bin/${cxFileName}`);
|
|
13548
13550
|
} catch (e) {
|
|
@@ -15697,8 +15699,8 @@ var WorkspaceService = class {
|
|
|
15697
15699
|
* Sets a known workspace path that was discovered through successful validation
|
|
15698
15700
|
* @param path The validated workspace path to store
|
|
15699
15701
|
*/
|
|
15700
|
-
static setKnownWorkspacePath(
|
|
15701
|
-
this.knownWorkspacePath =
|
|
15702
|
+
static setKnownWorkspacePath(path25) {
|
|
15703
|
+
this.knownWorkspacePath = path25;
|
|
15702
15704
|
}
|
|
15703
15705
|
/**
|
|
15704
15706
|
* Gets the known workspace path that was previously validated
|
|
@@ -16971,10 +16973,10 @@ var getHostInfo = (additionalMcpList) => {
|
|
|
16971
16973
|
const ideConfigPaths = /* @__PURE__ */ new Set();
|
|
16972
16974
|
for (const ide of IDEs) {
|
|
16973
16975
|
const configPaths = getMCPConfigPaths(ide);
|
|
16974
|
-
configPaths.forEach((
|
|
16976
|
+
configPaths.forEach((path25) => ideConfigPaths.add(path25));
|
|
16975
16977
|
}
|
|
16976
16978
|
const uniqueAdditionalPaths = additionalMcpList.filter(
|
|
16977
|
-
(
|
|
16979
|
+
(path25) => !ideConfigPaths.has(path25)
|
|
16978
16980
|
);
|
|
16979
16981
|
for (const ide of IDEs) {
|
|
16980
16982
|
const cfg = readMCPConfig(ide);
|
|
@@ -20267,7 +20269,7 @@ init_configs();
|
|
|
20267
20269
|
import fs19 from "fs/promises";
|
|
20268
20270
|
import nodePath from "path";
|
|
20269
20271
|
var getLocalFiles = async ({
|
|
20270
|
-
path:
|
|
20272
|
+
path: path25,
|
|
20271
20273
|
maxFileSize = MCP_MAX_FILE_SIZE,
|
|
20272
20274
|
maxFiles,
|
|
20273
20275
|
isAllFilesScan,
|
|
@@ -20275,17 +20277,17 @@ var getLocalFiles = async ({
|
|
|
20275
20277
|
scanRecentlyChangedFiles
|
|
20276
20278
|
}) => {
|
|
20277
20279
|
logDebug(`[${scanContext}] Starting getLocalFiles`, {
|
|
20278
|
-
path:
|
|
20280
|
+
path: path25,
|
|
20279
20281
|
maxFileSize,
|
|
20280
20282
|
maxFiles,
|
|
20281
20283
|
isAllFilesScan,
|
|
20282
20284
|
scanRecentlyChangedFiles
|
|
20283
20285
|
});
|
|
20284
20286
|
try {
|
|
20285
|
-
const resolvedRepoPath = await fs19.realpath(
|
|
20287
|
+
const resolvedRepoPath = await fs19.realpath(path25);
|
|
20286
20288
|
logDebug(`[${scanContext}] Resolved repository path`, {
|
|
20287
20289
|
resolvedRepoPath,
|
|
20288
|
-
originalPath:
|
|
20290
|
+
originalPath: path25
|
|
20289
20291
|
});
|
|
20290
20292
|
const gitService = new GitService(resolvedRepoPath, log);
|
|
20291
20293
|
const gitValidation = await gitService.validateRepository();
|
|
@@ -20298,7 +20300,7 @@ var getLocalFiles = async ({
|
|
|
20298
20300
|
if (!gitValidation.isValid || isAllFilesScan) {
|
|
20299
20301
|
try {
|
|
20300
20302
|
files = await FileUtils.getLastChangedFiles({
|
|
20301
|
-
dir:
|
|
20303
|
+
dir: path25,
|
|
20302
20304
|
maxFileSize,
|
|
20303
20305
|
maxFiles,
|
|
20304
20306
|
isAllFilesScan
|
|
@@ -20390,7 +20392,7 @@ var getLocalFiles = async ({
|
|
|
20390
20392
|
logError(`${scanContext}Unexpected error in getLocalFiles`, {
|
|
20391
20393
|
error: error instanceof Error ? error.message : String(error),
|
|
20392
20394
|
stack: error instanceof Error ? error.stack : void 0,
|
|
20393
|
-
path:
|
|
20395
|
+
path: path25
|
|
20394
20396
|
});
|
|
20395
20397
|
throw error;
|
|
20396
20398
|
}
|
|
@@ -22538,14 +22540,14 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
22538
22540
|
* since the last scan.
|
|
22539
22541
|
*/
|
|
22540
22542
|
async scanForSecurityVulnerabilities({
|
|
22541
|
-
path:
|
|
22543
|
+
path: path25,
|
|
22542
22544
|
isAllDetectionRulesScan,
|
|
22543
22545
|
isAllFilesScan,
|
|
22544
22546
|
scanContext
|
|
22545
22547
|
}) {
|
|
22546
22548
|
this.hasAuthenticationFailed = false;
|
|
22547
22549
|
logDebug(`[${scanContext}] Scanning for new security vulnerabilities`, {
|
|
22548
|
-
path:
|
|
22550
|
+
path: path25
|
|
22549
22551
|
});
|
|
22550
22552
|
if (!this.gqlClient) {
|
|
22551
22553
|
logInfo(`[${scanContext}] No GQL client found, skipping scan`);
|
|
@@ -22561,11 +22563,11 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
22561
22563
|
}
|
|
22562
22564
|
logDebug(
|
|
22563
22565
|
`[${scanContext}] Connected to the API, assembling list of files to scan`,
|
|
22564
|
-
{ path:
|
|
22566
|
+
{ path: path25 }
|
|
22565
22567
|
);
|
|
22566
22568
|
const isBackgroundScan = scanContext === ScanContext.BACKGROUND_INITIAL || scanContext === ScanContext.BACKGROUND_PERIODIC;
|
|
22567
22569
|
const files = await getLocalFiles({
|
|
22568
|
-
path:
|
|
22570
|
+
path: path25,
|
|
22569
22571
|
isAllFilesScan,
|
|
22570
22572
|
scanContext,
|
|
22571
22573
|
scanRecentlyChangedFiles: !isBackgroundScan
|
|
@@ -22591,13 +22593,13 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
22591
22593
|
});
|
|
22592
22594
|
const { fixReportId, projectId } = await scanFiles({
|
|
22593
22595
|
fileList: filesToScan.map((file) => file.relativePath),
|
|
22594
|
-
repositoryPath:
|
|
22596
|
+
repositoryPath: path25,
|
|
22595
22597
|
gqlClient: this.gqlClient,
|
|
22596
22598
|
isAllDetectionRulesScan,
|
|
22597
22599
|
scanContext
|
|
22598
22600
|
});
|
|
22599
22601
|
logInfo(
|
|
22600
|
-
`[${scanContext}] Security scan completed for ${
|
|
22602
|
+
`[${scanContext}] Security scan completed for ${path25} reportId: ${fixReportId} projectId: ${projectId}`
|
|
22601
22603
|
);
|
|
22602
22604
|
if (isAllFilesScan) {
|
|
22603
22605
|
return;
|
|
@@ -22891,13 +22893,13 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
22891
22893
|
});
|
|
22892
22894
|
return scannedFiles.some((file) => file.relativePath === fixFile);
|
|
22893
22895
|
}
|
|
22894
|
-
async getFreshFixes({ path:
|
|
22896
|
+
async getFreshFixes({ path: path25 }) {
|
|
22895
22897
|
const scanContext = ScanContext.USER_REQUEST;
|
|
22896
|
-
logDebug(`[${scanContext}] Getting fresh fixes`, { path:
|
|
22897
|
-
if (this.path !==
|
|
22898
|
-
this.path =
|
|
22898
|
+
logDebug(`[${scanContext}] Getting fresh fixes`, { path: path25 });
|
|
22899
|
+
if (this.path !== path25) {
|
|
22900
|
+
this.path = path25;
|
|
22899
22901
|
this.reset();
|
|
22900
|
-
logInfo(`[${scanContext}] Reset service state for new path`, { path:
|
|
22902
|
+
logInfo(`[${scanContext}] Reset service state for new path`, { path: path25 });
|
|
22901
22903
|
}
|
|
22902
22904
|
try {
|
|
22903
22905
|
const loginContext = createMcpLoginContext("check_new_fixes");
|
|
@@ -22916,7 +22918,7 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
22916
22918
|
}
|
|
22917
22919
|
throw error;
|
|
22918
22920
|
}
|
|
22919
|
-
this.triggerScan({ path:
|
|
22921
|
+
this.triggerScan({ path: path25, gqlClient: this.gqlClient });
|
|
22920
22922
|
let isMvsAutoFixEnabled = null;
|
|
22921
22923
|
try {
|
|
22922
22924
|
isMvsAutoFixEnabled = await this.gqlClient.getMvsAutoFixSettings();
|
|
@@ -22950,33 +22952,33 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
22950
22952
|
return noFreshFixesPrompt;
|
|
22951
22953
|
}
|
|
22952
22954
|
triggerScan({
|
|
22953
|
-
path:
|
|
22955
|
+
path: path25,
|
|
22954
22956
|
gqlClient
|
|
22955
22957
|
}) {
|
|
22956
|
-
if (this.path !==
|
|
22957
|
-
this.path =
|
|
22958
|
+
if (this.path !== path25) {
|
|
22959
|
+
this.path = path25;
|
|
22958
22960
|
this.reset();
|
|
22959
|
-
logInfo(`Reset service state for new path in triggerScan`, { path:
|
|
22961
|
+
logInfo(`Reset service state for new path in triggerScan`, { path: path25 });
|
|
22960
22962
|
}
|
|
22961
22963
|
this.gqlClient = gqlClient;
|
|
22962
22964
|
if (!this.intervalId) {
|
|
22963
|
-
this.startPeriodicScanning(
|
|
22964
|
-
this.executeInitialScan(
|
|
22965
|
-
void this.executeInitialFullScan(
|
|
22965
|
+
this.startPeriodicScanning(path25);
|
|
22966
|
+
this.executeInitialScan(path25);
|
|
22967
|
+
void this.executeInitialFullScan(path25);
|
|
22966
22968
|
}
|
|
22967
22969
|
}
|
|
22968
|
-
startPeriodicScanning(
|
|
22970
|
+
startPeriodicScanning(path25) {
|
|
22969
22971
|
const scanContext = ScanContext.BACKGROUND_PERIODIC;
|
|
22970
22972
|
logDebug(
|
|
22971
22973
|
`[${scanContext}] Starting periodic scan for new security vulnerabilities`,
|
|
22972
22974
|
{
|
|
22973
|
-
path:
|
|
22975
|
+
path: path25
|
|
22974
22976
|
}
|
|
22975
22977
|
);
|
|
22976
22978
|
this.intervalId = setInterval(() => {
|
|
22977
|
-
logDebug(`[${scanContext}] Triggering periodic security scan`, { path:
|
|
22979
|
+
logDebug(`[${scanContext}] Triggering periodic security scan`, { path: path25 });
|
|
22978
22980
|
this.scanForSecurityVulnerabilities({
|
|
22979
|
-
path:
|
|
22981
|
+
path: path25,
|
|
22980
22982
|
scanContext
|
|
22981
22983
|
}).catch((error) => {
|
|
22982
22984
|
logError(`[${scanContext}] Error during periodic security scan`, {
|
|
@@ -22985,45 +22987,45 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
22985
22987
|
});
|
|
22986
22988
|
}, MCP_PERIODIC_CHECK_INTERVAL);
|
|
22987
22989
|
}
|
|
22988
|
-
async executeInitialFullScan(
|
|
22990
|
+
async executeInitialFullScan(path25) {
|
|
22989
22991
|
const scanContext = ScanContext.FULL_SCAN;
|
|
22990
|
-
logDebug(`[${scanContext}] Triggering initial full security scan`, { path:
|
|
22992
|
+
logDebug(`[${scanContext}] Triggering initial full security scan`, { path: path25 });
|
|
22991
22993
|
logDebug(`[${scanContext}] Full scan paths scanned`, {
|
|
22992
22994
|
fullScanPathsScanned: this.fullScanPathsScanned
|
|
22993
22995
|
});
|
|
22994
|
-
if (this.fullScanPathsScanned.includes(
|
|
22996
|
+
if (this.fullScanPathsScanned.includes(path25)) {
|
|
22995
22997
|
logDebug(`[${scanContext}] Full scan already executed for this path`, {
|
|
22996
|
-
path:
|
|
22998
|
+
path: path25
|
|
22997
22999
|
});
|
|
22998
23000
|
return;
|
|
22999
23001
|
}
|
|
23000
23002
|
configStore.set("fullScanPathsScanned", [
|
|
23001
23003
|
...this.fullScanPathsScanned,
|
|
23002
|
-
|
|
23004
|
+
path25
|
|
23003
23005
|
]);
|
|
23004
23006
|
try {
|
|
23005
23007
|
await this.scanForSecurityVulnerabilities({
|
|
23006
|
-
path:
|
|
23008
|
+
path: path25,
|
|
23007
23009
|
isAllFilesScan: true,
|
|
23008
23010
|
isAllDetectionRulesScan: true,
|
|
23009
23011
|
scanContext: ScanContext.FULL_SCAN
|
|
23010
23012
|
});
|
|
23011
|
-
if (!this.fullScanPathsScanned.includes(
|
|
23012
|
-
this.fullScanPathsScanned.push(
|
|
23013
|
+
if (!this.fullScanPathsScanned.includes(path25)) {
|
|
23014
|
+
this.fullScanPathsScanned.push(path25);
|
|
23013
23015
|
configStore.set("fullScanPathsScanned", this.fullScanPathsScanned);
|
|
23014
23016
|
}
|
|
23015
|
-
logInfo(`[${scanContext}] Full scan completed`, { path:
|
|
23017
|
+
logInfo(`[${scanContext}] Full scan completed`, { path: path25 });
|
|
23016
23018
|
} catch (error) {
|
|
23017
23019
|
logError(`[${scanContext}] Error during initial full security scan`, {
|
|
23018
23020
|
error
|
|
23019
23021
|
});
|
|
23020
23022
|
}
|
|
23021
23023
|
}
|
|
23022
|
-
executeInitialScan(
|
|
23024
|
+
executeInitialScan(path25) {
|
|
23023
23025
|
const scanContext = ScanContext.BACKGROUND_INITIAL;
|
|
23024
|
-
logDebug(`[${scanContext}] Triggering initial security scan`, { path:
|
|
23026
|
+
logDebug(`[${scanContext}] Triggering initial security scan`, { path: path25 });
|
|
23025
23027
|
this.scanForSecurityVulnerabilities({
|
|
23026
|
-
path:
|
|
23028
|
+
path: path25,
|
|
23027
23029
|
scanContext: ScanContext.BACKGROUND_INITIAL
|
|
23028
23030
|
}).catch((error) => {
|
|
23029
23031
|
logError(`[${scanContext}] Error during initial security scan`, { error });
|
|
@@ -23120,9 +23122,9 @@ Example payload:
|
|
|
23120
23122
|
`Invalid path: potential security risk detected in path: ${pathValidationResult.error}`
|
|
23121
23123
|
);
|
|
23122
23124
|
}
|
|
23123
|
-
const
|
|
23125
|
+
const path25 = pathValidationResult.path;
|
|
23124
23126
|
const resultText = await this.newFixesService.getFreshFixes({
|
|
23125
|
-
path:
|
|
23127
|
+
path: path25
|
|
23126
23128
|
});
|
|
23127
23129
|
logInfo("CheckForNewAvailableFixesTool execution completed", {
|
|
23128
23130
|
resultText
|
|
@@ -23300,8 +23302,8 @@ Call this tool instead of ${MCP_TOOL_SCAN_AND_FIX_VULNERABILITIES} when you only
|
|
|
23300
23302
|
`Invalid path: potential security risk detected in path: ${pathValidationResult.error}`
|
|
23301
23303
|
);
|
|
23302
23304
|
}
|
|
23303
|
-
const
|
|
23304
|
-
const gitService = new GitService(
|
|
23305
|
+
const path25 = pathValidationResult.path;
|
|
23306
|
+
const gitService = new GitService(path25, log);
|
|
23305
23307
|
const gitValidation = await gitService.validateRepository();
|
|
23306
23308
|
if (!gitValidation.isValid) {
|
|
23307
23309
|
throw new Error(`Invalid git repository: ${gitValidation.error}`);
|
|
@@ -23686,9 +23688,9 @@ Example payload:
|
|
|
23686
23688
|
`Invalid path: potential security risk detected in path: ${pathValidationResult.error}`
|
|
23687
23689
|
);
|
|
23688
23690
|
}
|
|
23689
|
-
const
|
|
23691
|
+
const path25 = pathValidationResult.path;
|
|
23690
23692
|
const files = await getLocalFiles({
|
|
23691
|
-
path:
|
|
23693
|
+
path: path25,
|
|
23692
23694
|
maxFileSize: MCP_MAX_FILE_SIZE,
|
|
23693
23695
|
maxFiles: args.maxFiles,
|
|
23694
23696
|
scanContext: ScanContext.USER_REQUEST,
|
|
@@ -23708,7 +23710,7 @@ Example payload:
|
|
|
23708
23710
|
try {
|
|
23709
23711
|
const fixResult = await this.vulnerabilityFixService.processVulnerabilities({
|
|
23710
23712
|
fileList: files.map((file) => file.relativePath),
|
|
23711
|
-
repositoryPath:
|
|
23713
|
+
repositoryPath: path25,
|
|
23712
23714
|
offset: args.offset,
|
|
23713
23715
|
limit: args.limit,
|
|
23714
23716
|
isRescan: args.rescan || !!args.maxFiles
|
|
@@ -23921,77 +23923,511 @@ async function addScmTokenHandler(args) {
|
|
|
23921
23923
|
await addScmToken(args);
|
|
23922
23924
|
}
|
|
23923
23925
|
|
|
23926
|
+
// src/features/codeium_intellij/data_collector.ts
|
|
23927
|
+
import { z as z46 } from "zod";
|
|
23928
|
+
init_GitService();
|
|
23929
|
+
|
|
23930
|
+
// src/features/codeium_intellij/codeium_language_server_grpc_client.ts
|
|
23931
|
+
import path22 from "path";
|
|
23932
|
+
import * as grpc from "@grpc/grpc-js";
|
|
23933
|
+
import * as protoLoader from "@grpc/proto-loader";
|
|
23934
|
+
var PROTO_PATH = path22.join(
|
|
23935
|
+
getModuleRootDir(),
|
|
23936
|
+
"src/features/codeium_intellij/proto/exa/language_server_pb/language_server.proto"
|
|
23937
|
+
);
|
|
23938
|
+
function loadProto() {
|
|
23939
|
+
const packageDefinition = protoLoader.loadSync(PROTO_PATH, {
|
|
23940
|
+
keepCase: false,
|
|
23941
|
+
longs: String,
|
|
23942
|
+
enums: String,
|
|
23943
|
+
defaults: true,
|
|
23944
|
+
oneofs: true,
|
|
23945
|
+
includeDirs: [
|
|
23946
|
+
path22.join(getModuleRootDir(), "src/features/codeium_intellij/proto")
|
|
23947
|
+
]
|
|
23948
|
+
});
|
|
23949
|
+
return grpc.loadPackageDefinition(
|
|
23950
|
+
packageDefinition
|
|
23951
|
+
);
|
|
23952
|
+
}
|
|
23953
|
+
var PROTO = loadProto();
|
|
23954
|
+
function createCsrfInterceptor(csrfToken) {
|
|
23955
|
+
return (options, nextCall) => {
|
|
23956
|
+
return new grpc.InterceptingCall(nextCall(options), {
|
|
23957
|
+
start(metadata, listener, next) {
|
|
23958
|
+
metadata.set("x-codeium-csrf-token", csrfToken);
|
|
23959
|
+
next(metadata, listener);
|
|
23960
|
+
}
|
|
23961
|
+
});
|
|
23962
|
+
};
|
|
23963
|
+
}
|
|
23964
|
+
function promisifyClient(client) {
|
|
23965
|
+
return new Proxy(client, {
|
|
23966
|
+
get(target, prop) {
|
|
23967
|
+
const method = target[prop];
|
|
23968
|
+
if (typeof method === "function") {
|
|
23969
|
+
return (request) => new Promise((resolve, reject) => {
|
|
23970
|
+
const grpcMethod = method;
|
|
23971
|
+
grpcMethod.call(target, request, (err, res) => {
|
|
23972
|
+
if (err) reject(err);
|
|
23973
|
+
else if (res) resolve(res);
|
|
23974
|
+
else reject(new Error("No response"));
|
|
23975
|
+
});
|
|
23976
|
+
});
|
|
23977
|
+
}
|
|
23978
|
+
return method;
|
|
23979
|
+
}
|
|
23980
|
+
});
|
|
23981
|
+
}
|
|
23982
|
+
async function getGrpcClient(port, csrf3) {
|
|
23983
|
+
const client = promisifyClient(
|
|
23984
|
+
new PROTO.exa.language_server_pb.LanguageServerService(
|
|
23985
|
+
`localhost:${port}`,
|
|
23986
|
+
grpc.credentials.createInsecure(),
|
|
23987
|
+
{ interceptors: [createCsrfInterceptor(csrf3)] }
|
|
23988
|
+
)
|
|
23989
|
+
);
|
|
23990
|
+
try {
|
|
23991
|
+
await client.GetAllCascadeTrajectories({});
|
|
23992
|
+
} catch (e) {
|
|
23993
|
+
console.log(e);
|
|
23994
|
+
return null;
|
|
23995
|
+
}
|
|
23996
|
+
return client;
|
|
23997
|
+
}
|
|
23998
|
+
|
|
23999
|
+
// src/features/codeium_intellij/parse_intellij_logs.ts
|
|
24000
|
+
import fs24 from "fs";
|
|
24001
|
+
import os12 from "os";
|
|
24002
|
+
import path23 from "path";
|
|
24003
|
+
function getLogsDir() {
|
|
24004
|
+
if (process.platform === "darwin") {
|
|
24005
|
+
return path23.join(os12.homedir(), "Library/Logs/JetBrains");
|
|
24006
|
+
} else if (process.platform === "win32") {
|
|
24007
|
+
return path23.join(
|
|
24008
|
+
process.env["LOCALAPPDATA"] || path23.join(os12.homedir(), "AppData/Local"),
|
|
24009
|
+
"JetBrains"
|
|
24010
|
+
);
|
|
24011
|
+
} else {
|
|
24012
|
+
return path23.join(os12.homedir(), ".cache/JetBrains");
|
|
24013
|
+
}
|
|
24014
|
+
}
|
|
24015
|
+
function parseIdeLogDir(ideLogDir) {
|
|
24016
|
+
const logFiles = fs24.readdirSync(ideLogDir).filter((f) => /^idea(\.\d+)?\.log$/.test(f)).map((f) => ({
|
|
24017
|
+
name: f,
|
|
24018
|
+
mtime: fs24.statSync(path23.join(ideLogDir, f)).mtimeMs
|
|
24019
|
+
})).sort((a, b) => a.mtime - b.mtime).map((f) => f.name);
|
|
24020
|
+
let latestCsrf = null;
|
|
24021
|
+
let latestPort = null;
|
|
24022
|
+
for (const logFile of logFiles) {
|
|
24023
|
+
const lines = fs24.readFileSync(path23.join(ideLogDir, logFile), "utf-8").split("\n");
|
|
24024
|
+
for (const line of lines) {
|
|
24025
|
+
if (!line.includes(
|
|
24026
|
+
"com.codeium.intellij.language_server.LanguageServerProcessHandler"
|
|
24027
|
+
)) {
|
|
24028
|
+
continue;
|
|
24029
|
+
}
|
|
24030
|
+
const csrfMatch = line.match(/--csrf_token\s+([a-f0-9-]{36})/);
|
|
24031
|
+
if (csrfMatch?.[1]) {
|
|
24032
|
+
latestCsrf = csrfMatch[1];
|
|
24033
|
+
latestPort = null;
|
|
24034
|
+
}
|
|
24035
|
+
const portMatch = line.match(/listening on random port at (\d+)/);
|
|
24036
|
+
if (portMatch?.[1]) {
|
|
24037
|
+
latestPort = parseInt(portMatch[1]);
|
|
24038
|
+
}
|
|
24039
|
+
}
|
|
24040
|
+
}
|
|
24041
|
+
if (latestCsrf && latestPort) {
|
|
24042
|
+
return { csrf: latestCsrf, port: latestPort };
|
|
24043
|
+
}
|
|
24044
|
+
return null;
|
|
24045
|
+
}
|
|
24046
|
+
function findRunningCodeiumLanguageServers() {
|
|
24047
|
+
const results = [];
|
|
24048
|
+
const logsDir = getLogsDir();
|
|
24049
|
+
if (!fs24.existsSync(logsDir)) return results;
|
|
24050
|
+
for (const ide of fs24.readdirSync(logsDir)) {
|
|
24051
|
+
let ideLogDir = path23.join(logsDir, ide);
|
|
24052
|
+
if (process.platform !== "darwin") {
|
|
24053
|
+
ideLogDir = path23.join(ideLogDir, "log");
|
|
24054
|
+
}
|
|
24055
|
+
if (!fs24.existsSync(ideLogDir) || !fs24.statSync(ideLogDir).isDirectory()) {
|
|
24056
|
+
continue;
|
|
24057
|
+
}
|
|
24058
|
+
const result = parseIdeLogDir(ideLogDir);
|
|
24059
|
+
if (result) {
|
|
24060
|
+
results.push({ ide, ...result });
|
|
24061
|
+
}
|
|
24062
|
+
}
|
|
24063
|
+
return results;
|
|
24064
|
+
}
|
|
24065
|
+
|
|
24066
|
+
// src/features/codeium_intellij/data_collector.ts
|
|
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) {
|
|
24105
|
+
const instances = findRunningCodeiumLanguageServers();
|
|
24106
|
+
for (const instance of instances) {
|
|
24107
|
+
const client = await getGrpcClient(instance.port, instance.csrf);
|
|
24108
|
+
if (!client) {
|
|
24109
|
+
continue;
|
|
24110
|
+
}
|
|
24111
|
+
const chats = await client.GetAllCascadeTrajectories({});
|
|
24112
|
+
for (const [cascadeId, chatSummary] of Object.entries(
|
|
24113
|
+
chats.trajectorySummaries
|
|
24114
|
+
)) {
|
|
24115
|
+
if (chatSummary.trajectoryId !== trajectoryId) {
|
|
24116
|
+
continue;
|
|
24117
|
+
}
|
|
24118
|
+
return await processChat(client, cascadeId);
|
|
24119
|
+
}
|
|
24120
|
+
}
|
|
24121
|
+
return null;
|
|
24122
|
+
}
|
|
24123
|
+
async function processChat(client, cascadeId) {
|
|
24124
|
+
const chatDetails = await client.GetCascadeTrajectory({
|
|
24125
|
+
cascadeId
|
|
24126
|
+
});
|
|
24127
|
+
const allPrompts = [];
|
|
24128
|
+
const allInferences = [];
|
|
24129
|
+
const steps = chatDetails.trajectory?.steps || [];
|
|
24130
|
+
for (const step of steps) {
|
|
24131
|
+
const result = processChatStep(step);
|
|
24132
|
+
allPrompts.push(...result.prompts);
|
|
24133
|
+
allInferences.push(...result.inferences);
|
|
24134
|
+
}
|
|
24135
|
+
if (allInferences.length === 0) {
|
|
24136
|
+
return null;
|
|
24137
|
+
}
|
|
24138
|
+
const generatorMetadata = chatDetails.trajectory?.generatorMetadata || [];
|
|
24139
|
+
const model = generatorMetadata.find((m) => m.chatModel?.modelUid)?.chatModel?.modelUid || "unknown";
|
|
24140
|
+
const lastStep = steps[steps.length - 1];
|
|
24141
|
+
const completedAt = lastStep?.metadata?.completedAt;
|
|
24142
|
+
const responseTime = completedAt?.seconds ? new Date(Number(completedAt.seconds) * 1e3).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
|
|
24143
|
+
const repoOrigin = chatDetails.trajectory?.metadata?.workspaces?.[0]?.repository?.gitOriginUrl;
|
|
24144
|
+
let repositoryUrl;
|
|
24145
|
+
if (repoOrigin) {
|
|
24146
|
+
const normalizedUrl = normalizeGitUrl(repoOrigin);
|
|
24147
|
+
if (isGitHubUrl(normalizedUrl)) {
|
|
24148
|
+
repositoryUrl = normalizedUrl;
|
|
24149
|
+
}
|
|
24150
|
+
}
|
|
24151
|
+
return {
|
|
24152
|
+
prompts: allPrompts,
|
|
24153
|
+
inference: allInferences.join("\n"),
|
|
24154
|
+
model,
|
|
24155
|
+
tool: "Windsurf Intellij",
|
|
24156
|
+
responseTime,
|
|
24157
|
+
sessionId: cascadeId,
|
|
24158
|
+
repositoryUrl
|
|
24159
|
+
};
|
|
24160
|
+
}
|
|
24161
|
+
function processChatStep(step) {
|
|
24162
|
+
switch (step.type) {
|
|
24163
|
+
case "CORTEX_STEP_TYPE_USER_INPUT":
|
|
24164
|
+
return processChatStepUserInput(step);
|
|
24165
|
+
case "CORTEX_STEP_TYPE_PLANNER_RESPONSE":
|
|
24166
|
+
return processChatStepPlannerResponse(step);
|
|
24167
|
+
case "CORTEX_STEP_TYPE_CODE_ACTION":
|
|
24168
|
+
return processChatStepCodeAction(step);
|
|
24169
|
+
default:
|
|
24170
|
+
return { prompts: [], inferences: [] };
|
|
24171
|
+
}
|
|
24172
|
+
}
|
|
24173
|
+
function processChatStepUserInput(step) {
|
|
24174
|
+
const query = step.userInput?.query || step.userInput?.userResponse || "";
|
|
24175
|
+
if (!query) {
|
|
24176
|
+
return { prompts: [], inferences: [] };
|
|
24177
|
+
}
|
|
24178
|
+
return {
|
|
24179
|
+
prompts: [
|
|
24180
|
+
{
|
|
24181
|
+
type: "USER_PROMPT",
|
|
24182
|
+
text: query,
|
|
24183
|
+
date: /* @__PURE__ */ new Date()
|
|
24184
|
+
}
|
|
24185
|
+
],
|
|
24186
|
+
inferences: []
|
|
24187
|
+
};
|
|
24188
|
+
}
|
|
24189
|
+
function processChatStepPlannerResponse(step) {
|
|
24190
|
+
const prompts = [];
|
|
24191
|
+
const date = /* @__PURE__ */ new Date();
|
|
24192
|
+
const text = step.plannerResponse?.response || step.plannerResponse?.modifiedResponse || "";
|
|
24193
|
+
if (text) {
|
|
24194
|
+
prompts.push({
|
|
24195
|
+
type: "AI_RESPONSE",
|
|
24196
|
+
text,
|
|
24197
|
+
date
|
|
24198
|
+
});
|
|
24199
|
+
}
|
|
24200
|
+
for (const toolCall of step.plannerResponse?.toolCalls || []) {
|
|
24201
|
+
prompts.push({
|
|
24202
|
+
type: "TOOL_EXECUTION",
|
|
24203
|
+
date,
|
|
24204
|
+
tool: {
|
|
24205
|
+
name: toolCall.name,
|
|
24206
|
+
parameters: toolCall.argumentsJson,
|
|
24207
|
+
result: "",
|
|
24208
|
+
rawArguments: toolCall.argumentsJson,
|
|
24209
|
+
accepted: true
|
|
24210
|
+
}
|
|
24211
|
+
});
|
|
24212
|
+
}
|
|
24213
|
+
return { prompts, inferences: [] };
|
|
24214
|
+
}
|
|
24215
|
+
function processChatStepCodeAction(step) {
|
|
24216
|
+
const inferences = [];
|
|
24217
|
+
const toolCallName = step.metadata?.toolCall?.name;
|
|
24218
|
+
const unifiedDiff = step.codeAction?.actionResult?.edit?.diff?.unifiedDiff;
|
|
24219
|
+
if (!toolCallName) {
|
|
24220
|
+
return { prompts: [], inferences };
|
|
24221
|
+
}
|
|
24222
|
+
if (!unifiedDiff) {
|
|
24223
|
+
return { prompts: [], inferences };
|
|
24224
|
+
}
|
|
24225
|
+
for (const line of unifiedDiff.lines) {
|
|
24226
|
+
if (line.type === "UNIFIED_DIFF_LINE_TYPE_INSERT") {
|
|
24227
|
+
inferences.push(line.text);
|
|
24228
|
+
}
|
|
24229
|
+
}
|
|
24230
|
+
return { prompts: [], inferences };
|
|
24231
|
+
}
|
|
24232
|
+
|
|
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");
|
|
24240
|
+
}
|
|
24241
|
+
async function readCodeiumHooks() {
|
|
24242
|
+
const hooksPath = getCodeiumHooksPath();
|
|
24243
|
+
try {
|
|
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
|
+
);
|
|
24286
|
+
}
|
|
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
|
+
);
|
|
24308
|
+
}
|
|
24309
|
+
|
|
24310
|
+
// src/args/commands/windsurf_intellij.ts
|
|
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) => {
|
|
24325
|
+
return yargs2.example(
|
|
24326
|
+
"$0 windsurf-intellij-process-hook",
|
|
24327
|
+
"Process Windsurf IntelliJ hook data and upload to backend"
|
|
24328
|
+
).strict();
|
|
24329
|
+
};
|
|
24330
|
+
var windsurfIntellijInstallHookHandler = async (argv) => {
|
|
24331
|
+
try {
|
|
24332
|
+
await getAuthenticatedGQLClient({ isSkipPrompts: false });
|
|
24333
|
+
await installWindsurfHooks({ saveEnv: argv["save-env"] });
|
|
24334
|
+
process.exit(0);
|
|
24335
|
+
} catch (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);
|
|
24346
|
+
process.exit(1);
|
|
24347
|
+
}
|
|
24348
|
+
};
|
|
24349
|
+
|
|
23924
24350
|
// src/args/yargs.ts
|
|
23925
24351
|
var parseArgs = async (args) => {
|
|
23926
24352
|
const yargsInstance = yargs(args);
|
|
23927
24353
|
return yargsInstance.updateStrings({
|
|
23928
|
-
"Commands:":
|
|
23929
|
-
"Options:":
|
|
23930
|
-
"Examples:":
|
|
23931
|
-
"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")
|
|
23932
24358
|
}).usage(
|
|
23933
|
-
`${
|
|
24359
|
+
`${chalk13.bold(
|
|
23934
24360
|
"\n Bugsy - Trusted, Automatic Vulnerability Fixer \u{1F575}\uFE0F\u200D\u2642\uFE0F\n\n"
|
|
23935
|
-
)} ${
|
|
23936
|
-
$0 ${
|
|
24361
|
+
)} ${chalk13.yellow.underline.bold("Usage:")}
|
|
24362
|
+
$0 ${chalk13.green(
|
|
23937
24363
|
"<command>"
|
|
23938
|
-
)} ${
|
|
24364
|
+
)} ${chalk13.dim("[options]")}
|
|
23939
24365
|
`
|
|
23940
24366
|
).version(false).command(
|
|
23941
24367
|
mobbCliCommand.scan,
|
|
23942
|
-
|
|
24368
|
+
chalk13.bold(
|
|
23943
24369
|
"Scan your code for vulnerabilities, get automated fixes right away."
|
|
23944
24370
|
),
|
|
23945
24371
|
scanBuilder,
|
|
23946
24372
|
scanHandler
|
|
23947
24373
|
).command(
|
|
23948
24374
|
mobbCliCommand.analyze,
|
|
23949
|
-
|
|
24375
|
+
chalk13.bold(
|
|
23950
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."
|
|
23951
24377
|
),
|
|
23952
24378
|
analyzeBuilder,
|
|
23953
24379
|
analyzeHandler
|
|
23954
24380
|
).command(
|
|
23955
24381
|
mobbCliCommand.review,
|
|
23956
|
-
|
|
24382
|
+
chalk13.bold(
|
|
23957
24383
|
"Mobb will review your github pull requests and provide comments with fixes "
|
|
23958
24384
|
),
|
|
23959
24385
|
reviewBuilder,
|
|
23960
24386
|
reviewHandler
|
|
23961
24387
|
).command(
|
|
23962
24388
|
mobbCliCommand.addScmToken,
|
|
23963
|
-
|
|
24389
|
+
chalk13.bold(
|
|
23964
24390
|
"Add your SCM (Github, Gitlab, Azure DevOps) token to Mobb to enable automated fixes."
|
|
23965
24391
|
),
|
|
23966
24392
|
addScmTokenBuilder,
|
|
23967
24393
|
addScmTokenHandler
|
|
23968
24394
|
).command(
|
|
23969
24395
|
mobbCliCommand.convertToSarif,
|
|
23970
|
-
|
|
24396
|
+
chalk13.bold("Convert an existing SAST report to SARIF format."),
|
|
23971
24397
|
convertToSarifBuilder,
|
|
23972
24398
|
convertToSarifHandler
|
|
23973
24399
|
).command(
|
|
23974
24400
|
mobbCliCommand.mcp,
|
|
23975
|
-
|
|
24401
|
+
chalk13.bold("Launch the MCP (Model Context Protocol) server."),
|
|
23976
24402
|
mcpBuilder,
|
|
23977
24403
|
mcpHandler
|
|
23978
24404
|
).command(
|
|
23979
24405
|
mobbCliCommand.uploadAiBlame,
|
|
23980
|
-
|
|
24406
|
+
chalk13.bold(
|
|
23981
24407
|
"Upload AI Blame inference artifacts (prompt + inference) and finalize them."
|
|
23982
24408
|
),
|
|
23983
24409
|
uploadAiBlameBuilder,
|
|
23984
24410
|
uploadAiBlameCommandHandler
|
|
23985
24411
|
).command(
|
|
23986
24412
|
mobbCliCommand.claudeCodeInstallHook,
|
|
23987
|
-
|
|
24413
|
+
chalk13.bold("Install Claude Code hooks for data collection."),
|
|
23988
24414
|
claudeCodeInstallHookBuilder,
|
|
23989
24415
|
claudeCodeInstallHookHandler
|
|
23990
24416
|
).command(
|
|
23991
24417
|
mobbCliCommand.claudeCodeProcessHook,
|
|
23992
|
-
|
|
24418
|
+
chalk13.bold("Process Claude Code hook data and upload to backend."),
|
|
23993
24419
|
claudeCodeProcessHookBuilder,
|
|
23994
24420
|
claudeCodeProcessHookHandler
|
|
24421
|
+
).command(
|
|
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
|
|
23995
24431
|
).example(
|
|
23996
24432
|
"npx mobbdev@latest scan -r https://github.com/WebGoat/WebGoat",
|
|
23997
24433
|
"Scan an existing repository"
|
|
@@ -24000,7 +24436,7 @@ var parseArgs = async (args) => {
|
|
|
24000
24436
|
handler() {
|
|
24001
24437
|
yargsInstance.showHelp();
|
|
24002
24438
|
}
|
|
24003
|
-
}).strictOptions().help("h").alias("h", "help").epilog(
|
|
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();
|
|
24004
24440
|
};
|
|
24005
24441
|
|
|
24006
24442
|
// src/index.ts
|