mobbdev 1.2.50 → 1.2.51
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/dist/index.mjs +191 -139
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7043,7 +7043,7 @@ async function getAdoSdk(params) {
|
|
|
7043
7043
|
const url = new URL(repoUrl);
|
|
7044
7044
|
const origin2 = url.origin.toLowerCase().endsWith(".visualstudio.com") ? DEFUALT_ADO_ORIGIN : url.origin.toLowerCase();
|
|
7045
7045
|
const params2 = `path=/&versionDescriptor[versionOptions]=0&versionDescriptor[versionType]=commit&versionDescriptor[version]=${branch}&resolveLfs=true&$format=zip&api-version=5.0&download=true`;
|
|
7046
|
-
const
|
|
7046
|
+
const path27 = [
|
|
7047
7047
|
prefixPath,
|
|
7048
7048
|
owner,
|
|
7049
7049
|
projectName,
|
|
@@ -7054,7 +7054,7 @@ async function getAdoSdk(params) {
|
|
|
7054
7054
|
"items",
|
|
7055
7055
|
"items"
|
|
7056
7056
|
].filter(Boolean).join("/");
|
|
7057
|
-
return new URL(`${
|
|
7057
|
+
return new URL(`${path27}?${params2}`, origin2).toString();
|
|
7058
7058
|
},
|
|
7059
7059
|
async getAdoBranchList({ repoUrl }) {
|
|
7060
7060
|
try {
|
|
@@ -13867,7 +13867,7 @@ async function postIssueComment(params) {
|
|
|
13867
13867
|
fpDescription
|
|
13868
13868
|
} = params;
|
|
13869
13869
|
const {
|
|
13870
|
-
path:
|
|
13870
|
+
path: path27,
|
|
13871
13871
|
startLine,
|
|
13872
13872
|
vulnerabilityReportIssue: {
|
|
13873
13873
|
vulnerabilityReportIssueTags,
|
|
@@ -13882,7 +13882,7 @@ async function postIssueComment(params) {
|
|
|
13882
13882
|
Refresh the page in order to see the changes.`,
|
|
13883
13883
|
pull_number: pullRequest,
|
|
13884
13884
|
commit_id: commitSha,
|
|
13885
|
-
path:
|
|
13885
|
+
path: path27,
|
|
13886
13886
|
line: startLine
|
|
13887
13887
|
});
|
|
13888
13888
|
const commentId = commentRes.data.id;
|
|
@@ -13916,7 +13916,7 @@ async function postFixComment(params) {
|
|
|
13916
13916
|
scanner
|
|
13917
13917
|
} = params;
|
|
13918
13918
|
const {
|
|
13919
|
-
path:
|
|
13919
|
+
path: path27,
|
|
13920
13920
|
startLine,
|
|
13921
13921
|
vulnerabilityReportIssue: { fixId, vulnerabilityReportIssueTags, category },
|
|
13922
13922
|
vulnerabilityReportIssueId
|
|
@@ -13934,7 +13934,7 @@ async function postFixComment(params) {
|
|
|
13934
13934
|
Refresh the page in order to see the changes.`,
|
|
13935
13935
|
pull_number: pullRequest,
|
|
13936
13936
|
commit_id: commitSha,
|
|
13937
|
-
path:
|
|
13937
|
+
path: path27,
|
|
13938
13938
|
line: startLine
|
|
13939
13939
|
});
|
|
13940
13940
|
const commentId = commentRes.data.id;
|
|
@@ -15857,6 +15857,47 @@ init_client_generates();
|
|
|
15857
15857
|
init_GitService();
|
|
15858
15858
|
init_urlParser2();
|
|
15859
15859
|
|
|
15860
|
+
// src/utils/computeGitDiffAdditions.ts
|
|
15861
|
+
import { mkdtemp, rm, writeFile } from "fs/promises";
|
|
15862
|
+
import { tmpdir } from "os";
|
|
15863
|
+
import path13 from "path";
|
|
15864
|
+
import { simpleGit as simpleGit4 } from "simple-git";
|
|
15865
|
+
async function computeGitDiffAdditions(oldStr, newStr) {
|
|
15866
|
+
const tmpDir = await mkdtemp(path13.join(tmpdir(), "diff-"));
|
|
15867
|
+
const oldFile = path13.join(tmpDir, "old");
|
|
15868
|
+
const newFile = path13.join(tmpDir, "new");
|
|
15869
|
+
try {
|
|
15870
|
+
await writeFile(oldFile, oldStr);
|
|
15871
|
+
await writeFile(newFile, newStr);
|
|
15872
|
+
const git = simpleGit4();
|
|
15873
|
+
let result;
|
|
15874
|
+
try {
|
|
15875
|
+
result = await git.raw([
|
|
15876
|
+
"diff",
|
|
15877
|
+
"--no-index",
|
|
15878
|
+
"--unified=0",
|
|
15879
|
+
oldFile,
|
|
15880
|
+
newFile
|
|
15881
|
+
]);
|
|
15882
|
+
} catch (err) {
|
|
15883
|
+
if (err instanceof Error && "stdOut" in err) {
|
|
15884
|
+
result = err.stdOut;
|
|
15885
|
+
} else {
|
|
15886
|
+
throw err;
|
|
15887
|
+
}
|
|
15888
|
+
}
|
|
15889
|
+
const additions = [];
|
|
15890
|
+
for (const line of result.split("\n")) {
|
|
15891
|
+
if (line.startsWith("+") && !line.startsWith("+++")) {
|
|
15892
|
+
additions.push(line.slice(1));
|
|
15893
|
+
}
|
|
15894
|
+
}
|
|
15895
|
+
return additions.join("\n");
|
|
15896
|
+
} finally {
|
|
15897
|
+
await rm(tmpDir, { recursive: true, force: true });
|
|
15898
|
+
}
|
|
15899
|
+
}
|
|
15900
|
+
|
|
15860
15901
|
// src/features/claude_code/transcript_parser.ts
|
|
15861
15902
|
import fsPromises4 from "fs/promises";
|
|
15862
15903
|
function processTranscriptLine(entry) {
|
|
@@ -16041,29 +16082,40 @@ async function readStdinData() {
|
|
|
16041
16082
|
function validateHookData(data) {
|
|
16042
16083
|
return HookDataSchema.parse(data);
|
|
16043
16084
|
}
|
|
16044
|
-
function
|
|
16085
|
+
function extractStructuredPatchAdditions(hookData) {
|
|
16086
|
+
const editResponse = hookData.tool_response;
|
|
16087
|
+
const additions = [];
|
|
16088
|
+
for (const patch of editResponse.structuredPatch) {
|
|
16089
|
+
for (const line of patch.lines) {
|
|
16090
|
+
if (line.startsWith("+")) {
|
|
16091
|
+
additions.push(line.slice(1));
|
|
16092
|
+
}
|
|
16093
|
+
}
|
|
16094
|
+
}
|
|
16095
|
+
return additions.join("\n");
|
|
16096
|
+
}
|
|
16097
|
+
async function extractInference(hookData) {
|
|
16045
16098
|
if (hookData.tool_name === "Write") {
|
|
16046
16099
|
const writeInput = hookData.tool_input;
|
|
16047
16100
|
return writeInput.content || "";
|
|
16048
16101
|
}
|
|
16049
16102
|
if (hookData.tool_name === "Edit") {
|
|
16050
|
-
const
|
|
16051
|
-
|
|
16052
|
-
|
|
16053
|
-
|
|
16054
|
-
|
|
16055
|
-
|
|
16056
|
-
|
|
16057
|
-
|
|
16103
|
+
const editInput = hookData.tool_input;
|
|
16104
|
+
try {
|
|
16105
|
+
return await computeGitDiffAdditions(
|
|
16106
|
+
editInput.old_string,
|
|
16107
|
+
editInput.new_string
|
|
16108
|
+
);
|
|
16109
|
+
} catch {
|
|
16110
|
+
return extractStructuredPatchAdditions(hookData);
|
|
16058
16111
|
}
|
|
16059
|
-
return additions.join("\n");
|
|
16060
16112
|
}
|
|
16061
16113
|
return "";
|
|
16062
16114
|
}
|
|
16063
16115
|
async function collectHookData() {
|
|
16064
16116
|
const rawData = await readStdinData();
|
|
16065
16117
|
const hookData = validateHookData(rawData);
|
|
16066
|
-
const inference = extractInference(hookData);
|
|
16118
|
+
const inference = await extractInference(hookData);
|
|
16067
16119
|
let tracePayload;
|
|
16068
16120
|
try {
|
|
16069
16121
|
tracePayload = await parseTranscriptAndCreateTrace(
|
|
@@ -16148,9 +16200,9 @@ async function processAndUploadHookData() {
|
|
|
16148
16200
|
// src/features/claude_code/install_hook.ts
|
|
16149
16201
|
import fsPromises5 from "fs/promises";
|
|
16150
16202
|
import os4 from "os";
|
|
16151
|
-
import
|
|
16203
|
+
import path14 from "path";
|
|
16152
16204
|
import chalk11 from "chalk";
|
|
16153
|
-
var CLAUDE_SETTINGS_PATH =
|
|
16205
|
+
var CLAUDE_SETTINGS_PATH = path14.join(os4.homedir(), ".claude", "settings.json");
|
|
16154
16206
|
async function claudeSettingsExists() {
|
|
16155
16207
|
try {
|
|
16156
16208
|
await fsPromises5.access(CLAUDE_SETTINGS_PATH);
|
|
@@ -16335,8 +16387,8 @@ var WorkspaceService = class {
|
|
|
16335
16387
|
* Sets a known workspace path that was discovered through successful validation
|
|
16336
16388
|
* @param path The validated workspace path to store
|
|
16337
16389
|
*/
|
|
16338
|
-
static setKnownWorkspacePath(
|
|
16339
|
-
this.knownWorkspacePath =
|
|
16390
|
+
static setKnownWorkspacePath(path27) {
|
|
16391
|
+
this.knownWorkspacePath = path27;
|
|
16340
16392
|
}
|
|
16341
16393
|
/**
|
|
16342
16394
|
* Gets the known workspace path that was previously validated
|
|
@@ -17197,7 +17249,7 @@ async function createAuthenticatedMcpGQLClient({
|
|
|
17197
17249
|
import { execSync as execSync2 } from "child_process";
|
|
17198
17250
|
import fs13 from "fs";
|
|
17199
17251
|
import os5 from "os";
|
|
17200
|
-
import
|
|
17252
|
+
import path15 from "path";
|
|
17201
17253
|
var IDEs = ["cursor", "windsurf", "webstorm", "vscode", "claude"];
|
|
17202
17254
|
var runCommand = (cmd) => {
|
|
17203
17255
|
try {
|
|
@@ -17212,7 +17264,7 @@ var gitInfo = {
|
|
|
17212
17264
|
};
|
|
17213
17265
|
var getClaudeWorkspacePaths = () => {
|
|
17214
17266
|
const home = os5.homedir();
|
|
17215
|
-
const claudeIdePath =
|
|
17267
|
+
const claudeIdePath = path15.join(home, ".claude", "ide");
|
|
17216
17268
|
const workspacePaths = [];
|
|
17217
17269
|
if (!fs13.existsSync(claudeIdePath)) {
|
|
17218
17270
|
return workspacePaths;
|
|
@@ -17220,7 +17272,7 @@ var getClaudeWorkspacePaths = () => {
|
|
|
17220
17272
|
try {
|
|
17221
17273
|
const lockFiles = fs13.readdirSync(claudeIdePath).filter((file) => file.endsWith(".lock"));
|
|
17222
17274
|
for (const lockFile of lockFiles) {
|
|
17223
|
-
const lockFilePath =
|
|
17275
|
+
const lockFilePath = path15.join(claudeIdePath, lockFile);
|
|
17224
17276
|
try {
|
|
17225
17277
|
const lockContent = JSON.parse(fs13.readFileSync(lockFilePath, "utf8"));
|
|
17226
17278
|
if (lockContent.workspaceFolders && Array.isArray(lockContent.workspaceFolders)) {
|
|
@@ -17245,24 +17297,24 @@ var getMCPConfigPaths = (hostName) => {
|
|
|
17245
17297
|
switch (hostName.toLowerCase()) {
|
|
17246
17298
|
case "cursor":
|
|
17247
17299
|
return [
|
|
17248
|
-
|
|
17300
|
+
path15.join(currentDir, ".cursor", "mcp.json"),
|
|
17249
17301
|
// local first
|
|
17250
|
-
|
|
17302
|
+
path15.join(home, ".cursor", "mcp.json")
|
|
17251
17303
|
];
|
|
17252
17304
|
case "windsurf":
|
|
17253
17305
|
return [
|
|
17254
|
-
|
|
17306
|
+
path15.join(currentDir, ".codeium", "mcp_config.json"),
|
|
17255
17307
|
// local first
|
|
17256
|
-
|
|
17308
|
+
path15.join(home, ".codeium", "windsurf", "mcp_config.json")
|
|
17257
17309
|
];
|
|
17258
17310
|
case "webstorm":
|
|
17259
17311
|
return [];
|
|
17260
17312
|
case "visualstudiocode":
|
|
17261
17313
|
case "vscode":
|
|
17262
17314
|
return [
|
|
17263
|
-
|
|
17315
|
+
path15.join(currentDir, ".vscode", "mcp.json"),
|
|
17264
17316
|
// local first
|
|
17265
|
-
process.platform === "win32" ?
|
|
17317
|
+
process.platform === "win32" ? path15.join(home, "AppData", "Roaming", "Code", "User", "mcp.json") : path15.join(
|
|
17266
17318
|
home,
|
|
17267
17319
|
"Library",
|
|
17268
17320
|
"Application Support",
|
|
@@ -17273,13 +17325,13 @@ var getMCPConfigPaths = (hostName) => {
|
|
|
17273
17325
|
];
|
|
17274
17326
|
case "claude": {
|
|
17275
17327
|
const claudePaths = [
|
|
17276
|
-
|
|
17328
|
+
path15.join(currentDir, ".claude.json"),
|
|
17277
17329
|
// local first
|
|
17278
|
-
|
|
17330
|
+
path15.join(home, ".claude.json")
|
|
17279
17331
|
];
|
|
17280
17332
|
const workspacePaths = getClaudeWorkspacePaths();
|
|
17281
17333
|
for (const workspacePath of workspacePaths) {
|
|
17282
|
-
claudePaths.push(
|
|
17334
|
+
claudePaths.push(path15.join(workspacePath, ".mcp.json"));
|
|
17283
17335
|
}
|
|
17284
17336
|
return claudePaths;
|
|
17285
17337
|
}
|
|
@@ -17440,10 +17492,10 @@ var getHostInfo = (additionalMcpList) => {
|
|
|
17440
17492
|
const ideConfigPaths = /* @__PURE__ */ new Set();
|
|
17441
17493
|
for (const ide of IDEs) {
|
|
17442
17494
|
const configPaths = getMCPConfigPaths(ide);
|
|
17443
|
-
configPaths.forEach((
|
|
17495
|
+
configPaths.forEach((path27) => ideConfigPaths.add(path27));
|
|
17444
17496
|
}
|
|
17445
17497
|
const uniqueAdditionalPaths = additionalMcpList.filter(
|
|
17446
|
-
(
|
|
17498
|
+
(path27) => !ideConfigPaths.has(path27)
|
|
17447
17499
|
);
|
|
17448
17500
|
for (const ide of IDEs) {
|
|
17449
17501
|
const cfg = readMCPConfig(ide);
|
|
@@ -17565,7 +17617,7 @@ init_configs();
|
|
|
17565
17617
|
init_configs();
|
|
17566
17618
|
import fs14 from "fs";
|
|
17567
17619
|
import os6 from "os";
|
|
17568
|
-
import
|
|
17620
|
+
import path16 from "path";
|
|
17569
17621
|
var MAX_DEPTH = 2;
|
|
17570
17622
|
var patterns = ["mcp", "claude"];
|
|
17571
17623
|
var isFileMatch = (fileName) => {
|
|
@@ -17585,7 +17637,7 @@ var searchDir = async (dir, depth = 0) => {
|
|
|
17585
17637
|
if (depth > MAX_DEPTH) return results;
|
|
17586
17638
|
const entries = await fs14.promises.readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
17587
17639
|
for (const entry of entries) {
|
|
17588
|
-
const fullPath =
|
|
17640
|
+
const fullPath = path16.join(dir, entry.name);
|
|
17589
17641
|
if (entry.isFile() && isFileMatch(entry.name)) {
|
|
17590
17642
|
results.push(fullPath);
|
|
17591
17643
|
} else if (entry.isDirectory()) {
|
|
@@ -17602,14 +17654,14 @@ var findSystemMCPConfigs = async () => {
|
|
|
17602
17654
|
const home = os6.homedir();
|
|
17603
17655
|
const platform2 = os6.platform();
|
|
17604
17656
|
const knownDirs = platform2 === "win32" ? [
|
|
17605
|
-
|
|
17606
|
-
|
|
17607
|
-
|
|
17657
|
+
path16.join(home, ".cursor"),
|
|
17658
|
+
path16.join(home, "Documents"),
|
|
17659
|
+
path16.join(home, "Downloads")
|
|
17608
17660
|
] : [
|
|
17609
|
-
|
|
17610
|
-
process.env["XDG_CONFIG_HOME"] ||
|
|
17611
|
-
|
|
17612
|
-
|
|
17661
|
+
path16.join(home, ".cursor"),
|
|
17662
|
+
process.env["XDG_CONFIG_HOME"] || path16.join(home, ".config"),
|
|
17663
|
+
path16.join(home, "Documents"),
|
|
17664
|
+
path16.join(home, "Downloads")
|
|
17613
17665
|
];
|
|
17614
17666
|
const timeoutPromise = new Promise(
|
|
17615
17667
|
(resolve) => setTimeout(() => {
|
|
@@ -20025,13 +20077,13 @@ For a complete security audit workflow, use the \`full-security-audit\` prompt.
|
|
|
20025
20077
|
// src/mcp/services/McpDetectionService/CursorMcpDetectionService.ts
|
|
20026
20078
|
import * as fs17 from "fs";
|
|
20027
20079
|
import * as os9 from "os";
|
|
20028
|
-
import * as
|
|
20080
|
+
import * as path18 from "path";
|
|
20029
20081
|
|
|
20030
20082
|
// src/mcp/services/McpDetectionService/BaseMcpDetectionService.ts
|
|
20031
20083
|
init_configs();
|
|
20032
20084
|
import * as fs16 from "fs";
|
|
20033
20085
|
import fetch6 from "node-fetch";
|
|
20034
|
-
import * as
|
|
20086
|
+
import * as path17 from "path";
|
|
20035
20087
|
|
|
20036
20088
|
// src/mcp/services/McpDetectionService/McpDetectionServiceUtils.ts
|
|
20037
20089
|
import * as fs15 from "fs";
|
|
@@ -20040,14 +20092,14 @@ import * as os8 from "os";
|
|
|
20040
20092
|
// src/mcp/services/McpDetectionService/VscodeMcpDetectionService.ts
|
|
20041
20093
|
import * as fs18 from "fs";
|
|
20042
20094
|
import * as os10 from "os";
|
|
20043
|
-
import * as
|
|
20095
|
+
import * as path19 from "path";
|
|
20044
20096
|
|
|
20045
20097
|
// src/mcp/tools/checkForNewAvailableFixes/CheckForNewAvailableFixesTool.ts
|
|
20046
20098
|
import { z as z43 } from "zod";
|
|
20047
20099
|
|
|
20048
20100
|
// src/mcp/services/PathValidation.ts
|
|
20049
20101
|
import fs19 from "fs";
|
|
20050
|
-
import
|
|
20102
|
+
import path20 from "path";
|
|
20051
20103
|
async function validatePath(inputPath) {
|
|
20052
20104
|
logDebug("Validating MCP path", { inputPath });
|
|
20053
20105
|
if (/^\/[a-zA-Z]:\//.test(inputPath)) {
|
|
@@ -20079,7 +20131,7 @@ async function validatePath(inputPath) {
|
|
|
20079
20131
|
logError(error);
|
|
20080
20132
|
return { isValid: false, error, path: inputPath };
|
|
20081
20133
|
}
|
|
20082
|
-
const normalizedPath =
|
|
20134
|
+
const normalizedPath = path20.normalize(inputPath);
|
|
20083
20135
|
if (normalizedPath.includes("..")) {
|
|
20084
20136
|
const error = `Normalized path contains path traversal patterns: ${inputPath}`;
|
|
20085
20137
|
logError(error);
|
|
@@ -20731,7 +20783,7 @@ init_configs();
|
|
|
20731
20783
|
import fs20 from "fs/promises";
|
|
20732
20784
|
import nodePath from "path";
|
|
20733
20785
|
var getLocalFiles = async ({
|
|
20734
|
-
path:
|
|
20786
|
+
path: path27,
|
|
20735
20787
|
maxFileSize = MCP_MAX_FILE_SIZE,
|
|
20736
20788
|
maxFiles,
|
|
20737
20789
|
isAllFilesScan,
|
|
@@ -20739,17 +20791,17 @@ var getLocalFiles = async ({
|
|
|
20739
20791
|
scanRecentlyChangedFiles
|
|
20740
20792
|
}) => {
|
|
20741
20793
|
logDebug(`[${scanContext}] Starting getLocalFiles`, {
|
|
20742
|
-
path:
|
|
20794
|
+
path: path27,
|
|
20743
20795
|
maxFileSize,
|
|
20744
20796
|
maxFiles,
|
|
20745
20797
|
isAllFilesScan,
|
|
20746
20798
|
scanRecentlyChangedFiles
|
|
20747
20799
|
});
|
|
20748
20800
|
try {
|
|
20749
|
-
const resolvedRepoPath = await fs20.realpath(
|
|
20801
|
+
const resolvedRepoPath = await fs20.realpath(path27);
|
|
20750
20802
|
logDebug(`[${scanContext}] Resolved repository path`, {
|
|
20751
20803
|
resolvedRepoPath,
|
|
20752
|
-
originalPath:
|
|
20804
|
+
originalPath: path27
|
|
20753
20805
|
});
|
|
20754
20806
|
const gitService = new GitService(resolvedRepoPath, log);
|
|
20755
20807
|
const gitValidation = await gitService.validateRepository();
|
|
@@ -20762,7 +20814,7 @@ var getLocalFiles = async ({
|
|
|
20762
20814
|
if (!gitValidation.isValid || isAllFilesScan) {
|
|
20763
20815
|
try {
|
|
20764
20816
|
files = await FileUtils.getLastChangedFiles({
|
|
20765
|
-
dir:
|
|
20817
|
+
dir: path27,
|
|
20766
20818
|
maxFileSize,
|
|
20767
20819
|
maxFiles,
|
|
20768
20820
|
isAllFilesScan
|
|
@@ -20854,7 +20906,7 @@ var getLocalFiles = async ({
|
|
|
20854
20906
|
logError(`${scanContext}Unexpected error in getLocalFiles`, {
|
|
20855
20907
|
error: error instanceof Error ? error.message : String(error),
|
|
20856
20908
|
stack: error instanceof Error ? error.stack : void 0,
|
|
20857
|
-
path:
|
|
20909
|
+
path: path27
|
|
20858
20910
|
});
|
|
20859
20911
|
throw error;
|
|
20860
20912
|
}
|
|
@@ -20864,7 +20916,7 @@ var getLocalFiles = async ({
|
|
|
20864
20916
|
init_client_generates();
|
|
20865
20917
|
init_GitService();
|
|
20866
20918
|
import fs21 from "fs";
|
|
20867
|
-
import
|
|
20919
|
+
import path21 from "path";
|
|
20868
20920
|
import { z as z42 } from "zod";
|
|
20869
20921
|
function extractPathFromPatch(patch) {
|
|
20870
20922
|
const match = patch?.match(/diff --git a\/([^\s]+) b\//);
|
|
@@ -20950,7 +21002,7 @@ var LocalMobbFolderService = class {
|
|
|
20950
21002
|
"[LocalMobbFolderService] Non-git repository detected, skipping .gitignore operations"
|
|
20951
21003
|
);
|
|
20952
21004
|
}
|
|
20953
|
-
const mobbFolderPath =
|
|
21005
|
+
const mobbFolderPath = path21.join(
|
|
20954
21006
|
this.repoPath,
|
|
20955
21007
|
this.defaultMobbFolderName
|
|
20956
21008
|
);
|
|
@@ -21122,7 +21174,7 @@ var LocalMobbFolderService = class {
|
|
|
21122
21174
|
mobbFolderPath,
|
|
21123
21175
|
baseFileName
|
|
21124
21176
|
);
|
|
21125
|
-
const filePath =
|
|
21177
|
+
const filePath = path21.join(mobbFolderPath, uniqueFileName);
|
|
21126
21178
|
await fs21.promises.writeFile(filePath, patch, "utf8");
|
|
21127
21179
|
logInfo("[LocalMobbFolderService] Patch saved successfully", {
|
|
21128
21180
|
filePath,
|
|
@@ -21180,11 +21232,11 @@ var LocalMobbFolderService = class {
|
|
|
21180
21232
|
* @returns Unique filename that doesn't conflict with existing files
|
|
21181
21233
|
*/
|
|
21182
21234
|
getUniqueFileName(folderPath, baseFileName) {
|
|
21183
|
-
const baseName =
|
|
21184
|
-
const extension =
|
|
21235
|
+
const baseName = path21.parse(baseFileName).name;
|
|
21236
|
+
const extension = path21.parse(baseFileName).ext;
|
|
21185
21237
|
let uniqueFileName = baseFileName;
|
|
21186
21238
|
let index = 1;
|
|
21187
|
-
while (fs21.existsSync(
|
|
21239
|
+
while (fs21.existsSync(path21.join(folderPath, uniqueFileName))) {
|
|
21188
21240
|
uniqueFileName = `${baseName}-${index}${extension}`;
|
|
21189
21241
|
index++;
|
|
21190
21242
|
if (index > 1e3) {
|
|
@@ -21215,7 +21267,7 @@ var LocalMobbFolderService = class {
|
|
|
21215
21267
|
logDebug("[LocalMobbFolderService] Logging patch info", { fixId: fix.id });
|
|
21216
21268
|
try {
|
|
21217
21269
|
const mobbFolderPath = await this.getFolder();
|
|
21218
|
-
const patchInfoPath =
|
|
21270
|
+
const patchInfoPath = path21.join(mobbFolderPath, "patchInfo.md");
|
|
21219
21271
|
const markdownContent = this.generateFixMarkdown(fix, savedPatchFileName);
|
|
21220
21272
|
let existingContent = "";
|
|
21221
21273
|
if (fs21.existsSync(patchInfoPath)) {
|
|
@@ -21257,7 +21309,7 @@ var LocalMobbFolderService = class {
|
|
|
21257
21309
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
21258
21310
|
const patch = this.extractPatchFromFix(fix);
|
|
21259
21311
|
const relativePatchedFilePath = patch ? extractPathFromPatch(patch) : null;
|
|
21260
|
-
const patchedFilePath = relativePatchedFilePath ?
|
|
21312
|
+
const patchedFilePath = relativePatchedFilePath ? path21.resolve(this.repoPath, relativePatchedFilePath) : null;
|
|
21261
21313
|
const fixIdentifier = savedPatchFileName ? savedPatchFileName.replace(".patch", "") : fix.id;
|
|
21262
21314
|
let markdown = `# Fix ${fixIdentifier}
|
|
21263
21315
|
|
|
@@ -21601,14 +21653,14 @@ import {
|
|
|
21601
21653
|
} from "fs";
|
|
21602
21654
|
import fs22 from "fs/promises";
|
|
21603
21655
|
import parseDiff2 from "parse-diff";
|
|
21604
|
-
import
|
|
21656
|
+
import path22 from "path";
|
|
21605
21657
|
var PatchApplicationService = class {
|
|
21606
21658
|
/**
|
|
21607
21659
|
* Gets the appropriate comment syntax for a file based on its extension
|
|
21608
21660
|
*/
|
|
21609
21661
|
static getCommentSyntax(filePath) {
|
|
21610
|
-
const ext =
|
|
21611
|
-
const basename2 =
|
|
21662
|
+
const ext = path22.extname(filePath).toLowerCase();
|
|
21663
|
+
const basename2 = path22.basename(filePath);
|
|
21612
21664
|
const commentMap = {
|
|
21613
21665
|
// C-style languages (single line comments)
|
|
21614
21666
|
".js": "//",
|
|
@@ -21816,7 +21868,7 @@ var PatchApplicationService = class {
|
|
|
21816
21868
|
}
|
|
21817
21869
|
);
|
|
21818
21870
|
}
|
|
21819
|
-
const dirPath =
|
|
21871
|
+
const dirPath = path22.dirname(normalizedFilePath);
|
|
21820
21872
|
mkdirSync(dirPath, { recursive: true });
|
|
21821
21873
|
writeFileSync(normalizedFilePath, finalContent, "utf8");
|
|
21822
21874
|
return normalizedFilePath;
|
|
@@ -21825,9 +21877,9 @@ var PatchApplicationService = class {
|
|
|
21825
21877
|
repositoryPath,
|
|
21826
21878
|
targetPath
|
|
21827
21879
|
}) {
|
|
21828
|
-
const repoRoot =
|
|
21829
|
-
const normalizedPath =
|
|
21830
|
-
const repoRootWithSep = repoRoot.endsWith(
|
|
21880
|
+
const repoRoot = path22.resolve(repositoryPath);
|
|
21881
|
+
const normalizedPath = path22.resolve(repoRoot, targetPath);
|
|
21882
|
+
const repoRootWithSep = repoRoot.endsWith(path22.sep) ? repoRoot : `${repoRoot}${path22.sep}`;
|
|
21831
21883
|
if (normalizedPath !== repoRoot && !normalizedPath.startsWith(repoRootWithSep)) {
|
|
21832
21884
|
throw new Error(
|
|
21833
21885
|
`Security violation: target path ${targetPath} resolves outside repository`
|
|
@@ -21836,7 +21888,7 @@ var PatchApplicationService = class {
|
|
|
21836
21888
|
return {
|
|
21837
21889
|
repoRoot,
|
|
21838
21890
|
normalizedPath,
|
|
21839
|
-
relativePath:
|
|
21891
|
+
relativePath: path22.relative(repoRoot, normalizedPath)
|
|
21840
21892
|
};
|
|
21841
21893
|
}
|
|
21842
21894
|
/**
|
|
@@ -22118,7 +22170,7 @@ var PatchApplicationService = class {
|
|
|
22118
22170
|
continue;
|
|
22119
22171
|
}
|
|
22120
22172
|
try {
|
|
22121
|
-
const absolutePath =
|
|
22173
|
+
const absolutePath = path22.resolve(repositoryPath, targetFile);
|
|
22122
22174
|
if (existsSync6(absolutePath)) {
|
|
22123
22175
|
const stats = await fs22.stat(absolutePath);
|
|
22124
22176
|
const fileModTime = stats.mtime.getTime();
|
|
@@ -22344,7 +22396,7 @@ var PatchApplicationService = class {
|
|
|
22344
22396
|
fix,
|
|
22345
22397
|
scanContext
|
|
22346
22398
|
});
|
|
22347
|
-
appliedFiles.push(
|
|
22399
|
+
appliedFiles.push(path22.relative(repositoryPath, actualPath));
|
|
22348
22400
|
logDebug(`[${scanContext}] Created new file: ${relativePath}`);
|
|
22349
22401
|
}
|
|
22350
22402
|
/**
|
|
@@ -22393,7 +22445,7 @@ var PatchApplicationService = class {
|
|
|
22393
22445
|
fix,
|
|
22394
22446
|
scanContext
|
|
22395
22447
|
});
|
|
22396
|
-
appliedFiles.push(
|
|
22448
|
+
appliedFiles.push(path22.relative(repositoryPath, actualPath));
|
|
22397
22449
|
logDebug(`[${scanContext}] Modified file: ${relativePath}`);
|
|
22398
22450
|
}
|
|
22399
22451
|
}
|
|
@@ -22590,7 +22642,7 @@ init_configs();
|
|
|
22590
22642
|
// src/mcp/services/FileOperations.ts
|
|
22591
22643
|
init_FileUtils();
|
|
22592
22644
|
import fs23 from "fs";
|
|
22593
|
-
import
|
|
22645
|
+
import path23 from "path";
|
|
22594
22646
|
import AdmZip3 from "adm-zip";
|
|
22595
22647
|
var FileOperations = class {
|
|
22596
22648
|
/**
|
|
@@ -22610,10 +22662,10 @@ var FileOperations = class {
|
|
|
22610
22662
|
let packedFilesCount = 0;
|
|
22611
22663
|
const packedFiles = [];
|
|
22612
22664
|
const excludedFiles = [];
|
|
22613
|
-
const resolvedRepoPath =
|
|
22665
|
+
const resolvedRepoPath = path23.resolve(repositoryPath);
|
|
22614
22666
|
for (const filepath of fileList) {
|
|
22615
|
-
const absoluteFilepath =
|
|
22616
|
-
const resolvedFilePath =
|
|
22667
|
+
const absoluteFilepath = path23.join(repositoryPath, filepath);
|
|
22668
|
+
const resolvedFilePath = path23.resolve(absoluteFilepath);
|
|
22617
22669
|
if (!resolvedFilePath.startsWith(resolvedRepoPath)) {
|
|
22618
22670
|
const reason = "potential path traversal security risk";
|
|
22619
22671
|
logDebug(`[FileOperations] Skipping ${filepath} due to ${reason}`);
|
|
@@ -22660,11 +22712,11 @@ var FileOperations = class {
|
|
|
22660
22712
|
fileList,
|
|
22661
22713
|
repositoryPath
|
|
22662
22714
|
}) {
|
|
22663
|
-
const resolvedRepoPath =
|
|
22715
|
+
const resolvedRepoPath = path23.resolve(repositoryPath);
|
|
22664
22716
|
const validatedPaths = [];
|
|
22665
22717
|
for (const filepath of fileList) {
|
|
22666
|
-
const absoluteFilepath =
|
|
22667
|
-
const resolvedFilePath =
|
|
22718
|
+
const absoluteFilepath = path23.join(repositoryPath, filepath);
|
|
22719
|
+
const resolvedFilePath = path23.resolve(absoluteFilepath);
|
|
22668
22720
|
if (!resolvedFilePath.startsWith(resolvedRepoPath)) {
|
|
22669
22721
|
logDebug(
|
|
22670
22722
|
`[FileOperations] Rejecting ${filepath} - path traversal attempt detected`
|
|
@@ -22692,7 +22744,7 @@ var FileOperations = class {
|
|
|
22692
22744
|
for (const absolutePath of filePaths) {
|
|
22693
22745
|
try {
|
|
22694
22746
|
const content = await fs23.promises.readFile(absolutePath);
|
|
22695
|
-
const relativePath =
|
|
22747
|
+
const relativePath = path23.basename(absolutePath);
|
|
22696
22748
|
fileDataArray.push({
|
|
22697
22749
|
relativePath,
|
|
22698
22750
|
absolutePath,
|
|
@@ -23004,14 +23056,14 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
23004
23056
|
* since the last scan.
|
|
23005
23057
|
*/
|
|
23006
23058
|
async scanForSecurityVulnerabilities({
|
|
23007
|
-
path:
|
|
23059
|
+
path: path27,
|
|
23008
23060
|
isAllDetectionRulesScan,
|
|
23009
23061
|
isAllFilesScan,
|
|
23010
23062
|
scanContext
|
|
23011
23063
|
}) {
|
|
23012
23064
|
this.hasAuthenticationFailed = false;
|
|
23013
23065
|
logDebug(`[${scanContext}] Scanning for new security vulnerabilities`, {
|
|
23014
|
-
path:
|
|
23066
|
+
path: path27
|
|
23015
23067
|
});
|
|
23016
23068
|
if (!this.gqlClient) {
|
|
23017
23069
|
logInfo(`[${scanContext}] No GQL client found, skipping scan`);
|
|
@@ -23027,11 +23079,11 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
23027
23079
|
}
|
|
23028
23080
|
logDebug(
|
|
23029
23081
|
`[${scanContext}] Connected to the API, assembling list of files to scan`,
|
|
23030
|
-
{ path:
|
|
23082
|
+
{ path: path27 }
|
|
23031
23083
|
);
|
|
23032
23084
|
const isBackgroundScan = scanContext === ScanContext.BACKGROUND_INITIAL || scanContext === ScanContext.BACKGROUND_PERIODIC;
|
|
23033
23085
|
const files = await getLocalFiles({
|
|
23034
|
-
path:
|
|
23086
|
+
path: path27,
|
|
23035
23087
|
isAllFilesScan,
|
|
23036
23088
|
scanContext,
|
|
23037
23089
|
scanRecentlyChangedFiles: !isBackgroundScan
|
|
@@ -23057,13 +23109,13 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
23057
23109
|
});
|
|
23058
23110
|
const { fixReportId, projectId } = await scanFiles({
|
|
23059
23111
|
fileList: filesToScan.map((file) => file.relativePath),
|
|
23060
|
-
repositoryPath:
|
|
23112
|
+
repositoryPath: path27,
|
|
23061
23113
|
gqlClient: this.gqlClient,
|
|
23062
23114
|
isAllDetectionRulesScan,
|
|
23063
23115
|
scanContext
|
|
23064
23116
|
});
|
|
23065
23117
|
logInfo(
|
|
23066
|
-
`[${scanContext}] Security scan completed for ${
|
|
23118
|
+
`[${scanContext}] Security scan completed for ${path27} reportId: ${fixReportId} projectId: ${projectId}`
|
|
23067
23119
|
);
|
|
23068
23120
|
if (isAllFilesScan) {
|
|
23069
23121
|
return;
|
|
@@ -23357,13 +23409,13 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
23357
23409
|
});
|
|
23358
23410
|
return scannedFiles.some((file) => file.relativePath === fixFile);
|
|
23359
23411
|
}
|
|
23360
|
-
async getFreshFixes({ path:
|
|
23412
|
+
async getFreshFixes({ path: path27 }) {
|
|
23361
23413
|
const scanContext = ScanContext.USER_REQUEST;
|
|
23362
|
-
logDebug(`[${scanContext}] Getting fresh fixes`, { path:
|
|
23363
|
-
if (this.path !==
|
|
23364
|
-
this.path =
|
|
23414
|
+
logDebug(`[${scanContext}] Getting fresh fixes`, { path: path27 });
|
|
23415
|
+
if (this.path !== path27) {
|
|
23416
|
+
this.path = path27;
|
|
23365
23417
|
this.reset();
|
|
23366
|
-
logInfo(`[${scanContext}] Reset service state for new path`, { path:
|
|
23418
|
+
logInfo(`[${scanContext}] Reset service state for new path`, { path: path27 });
|
|
23367
23419
|
}
|
|
23368
23420
|
try {
|
|
23369
23421
|
const loginContext = createMcpLoginContext("check_new_fixes");
|
|
@@ -23382,7 +23434,7 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
23382
23434
|
}
|
|
23383
23435
|
throw error;
|
|
23384
23436
|
}
|
|
23385
|
-
this.triggerScan({ path:
|
|
23437
|
+
this.triggerScan({ path: path27, gqlClient: this.gqlClient });
|
|
23386
23438
|
let isMvsAutoFixEnabled = null;
|
|
23387
23439
|
try {
|
|
23388
23440
|
isMvsAutoFixEnabled = await this.gqlClient.getMvsAutoFixSettings();
|
|
@@ -23416,33 +23468,33 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
23416
23468
|
return noFreshFixesPrompt;
|
|
23417
23469
|
}
|
|
23418
23470
|
triggerScan({
|
|
23419
|
-
path:
|
|
23471
|
+
path: path27,
|
|
23420
23472
|
gqlClient
|
|
23421
23473
|
}) {
|
|
23422
|
-
if (this.path !==
|
|
23423
|
-
this.path =
|
|
23474
|
+
if (this.path !== path27) {
|
|
23475
|
+
this.path = path27;
|
|
23424
23476
|
this.reset();
|
|
23425
|
-
logInfo(`Reset service state for new path in triggerScan`, { path:
|
|
23477
|
+
logInfo(`Reset service state for new path in triggerScan`, { path: path27 });
|
|
23426
23478
|
}
|
|
23427
23479
|
this.gqlClient = gqlClient;
|
|
23428
23480
|
if (!this.intervalId) {
|
|
23429
|
-
this.startPeriodicScanning(
|
|
23430
|
-
this.executeInitialScan(
|
|
23431
|
-
void this.executeInitialFullScan(
|
|
23481
|
+
this.startPeriodicScanning(path27);
|
|
23482
|
+
this.executeInitialScan(path27);
|
|
23483
|
+
void this.executeInitialFullScan(path27);
|
|
23432
23484
|
}
|
|
23433
23485
|
}
|
|
23434
|
-
startPeriodicScanning(
|
|
23486
|
+
startPeriodicScanning(path27) {
|
|
23435
23487
|
const scanContext = ScanContext.BACKGROUND_PERIODIC;
|
|
23436
23488
|
logDebug(
|
|
23437
23489
|
`[${scanContext}] Starting periodic scan for new security vulnerabilities`,
|
|
23438
23490
|
{
|
|
23439
|
-
path:
|
|
23491
|
+
path: path27
|
|
23440
23492
|
}
|
|
23441
23493
|
);
|
|
23442
23494
|
this.intervalId = setInterval(() => {
|
|
23443
|
-
logDebug(`[${scanContext}] Triggering periodic security scan`, { path:
|
|
23495
|
+
logDebug(`[${scanContext}] Triggering periodic security scan`, { path: path27 });
|
|
23444
23496
|
this.scanForSecurityVulnerabilities({
|
|
23445
|
-
path:
|
|
23497
|
+
path: path27,
|
|
23446
23498
|
scanContext
|
|
23447
23499
|
}).catch((error) => {
|
|
23448
23500
|
logError(`[${scanContext}] Error during periodic security scan`, {
|
|
@@ -23451,45 +23503,45 @@ var _CheckForNewAvailableFixesService = class _CheckForNewAvailableFixesService
|
|
|
23451
23503
|
});
|
|
23452
23504
|
}, MCP_PERIODIC_CHECK_INTERVAL);
|
|
23453
23505
|
}
|
|
23454
|
-
async executeInitialFullScan(
|
|
23506
|
+
async executeInitialFullScan(path27) {
|
|
23455
23507
|
const scanContext = ScanContext.FULL_SCAN;
|
|
23456
|
-
logDebug(`[${scanContext}] Triggering initial full security scan`, { path:
|
|
23508
|
+
logDebug(`[${scanContext}] Triggering initial full security scan`, { path: path27 });
|
|
23457
23509
|
logDebug(`[${scanContext}] Full scan paths scanned`, {
|
|
23458
23510
|
fullScanPathsScanned: this.fullScanPathsScanned
|
|
23459
23511
|
});
|
|
23460
|
-
if (this.fullScanPathsScanned.includes(
|
|
23512
|
+
if (this.fullScanPathsScanned.includes(path27)) {
|
|
23461
23513
|
logDebug(`[${scanContext}] Full scan already executed for this path`, {
|
|
23462
|
-
path:
|
|
23514
|
+
path: path27
|
|
23463
23515
|
});
|
|
23464
23516
|
return;
|
|
23465
23517
|
}
|
|
23466
23518
|
configStore.set("fullScanPathsScanned", [
|
|
23467
23519
|
...this.fullScanPathsScanned,
|
|
23468
|
-
|
|
23520
|
+
path27
|
|
23469
23521
|
]);
|
|
23470
23522
|
try {
|
|
23471
23523
|
await this.scanForSecurityVulnerabilities({
|
|
23472
|
-
path:
|
|
23524
|
+
path: path27,
|
|
23473
23525
|
isAllFilesScan: true,
|
|
23474
23526
|
isAllDetectionRulesScan: true,
|
|
23475
23527
|
scanContext: ScanContext.FULL_SCAN
|
|
23476
23528
|
});
|
|
23477
|
-
if (!this.fullScanPathsScanned.includes(
|
|
23478
|
-
this.fullScanPathsScanned.push(
|
|
23529
|
+
if (!this.fullScanPathsScanned.includes(path27)) {
|
|
23530
|
+
this.fullScanPathsScanned.push(path27);
|
|
23479
23531
|
configStore.set("fullScanPathsScanned", this.fullScanPathsScanned);
|
|
23480
23532
|
}
|
|
23481
|
-
logInfo(`[${scanContext}] Full scan completed`, { path:
|
|
23533
|
+
logInfo(`[${scanContext}] Full scan completed`, { path: path27 });
|
|
23482
23534
|
} catch (error) {
|
|
23483
23535
|
logError(`[${scanContext}] Error during initial full security scan`, {
|
|
23484
23536
|
error
|
|
23485
23537
|
});
|
|
23486
23538
|
}
|
|
23487
23539
|
}
|
|
23488
|
-
executeInitialScan(
|
|
23540
|
+
executeInitialScan(path27) {
|
|
23489
23541
|
const scanContext = ScanContext.BACKGROUND_INITIAL;
|
|
23490
|
-
logDebug(`[${scanContext}] Triggering initial security scan`, { path:
|
|
23542
|
+
logDebug(`[${scanContext}] Triggering initial security scan`, { path: path27 });
|
|
23491
23543
|
this.scanForSecurityVulnerabilities({
|
|
23492
|
-
path:
|
|
23544
|
+
path: path27,
|
|
23493
23545
|
scanContext: ScanContext.BACKGROUND_INITIAL
|
|
23494
23546
|
}).catch((error) => {
|
|
23495
23547
|
logError(`[${scanContext}] Error during initial security scan`, { error });
|
|
@@ -23586,9 +23638,9 @@ Example payload:
|
|
|
23586
23638
|
`Invalid path: potential security risk detected in path: ${pathValidationResult.error}`
|
|
23587
23639
|
);
|
|
23588
23640
|
}
|
|
23589
|
-
const
|
|
23641
|
+
const path27 = pathValidationResult.path;
|
|
23590
23642
|
const resultText = await this.newFixesService.getFreshFixes({
|
|
23591
|
-
path:
|
|
23643
|
+
path: path27
|
|
23592
23644
|
});
|
|
23593
23645
|
logInfo("CheckForNewAvailableFixesTool execution completed", {
|
|
23594
23646
|
resultText
|
|
@@ -23766,8 +23818,8 @@ Call this tool instead of ${MCP_TOOL_SCAN_AND_FIX_VULNERABILITIES} when you only
|
|
|
23766
23818
|
`Invalid path: potential security risk detected in path: ${pathValidationResult.error}`
|
|
23767
23819
|
);
|
|
23768
23820
|
}
|
|
23769
|
-
const
|
|
23770
|
-
const gitService = new GitService(
|
|
23821
|
+
const path27 = pathValidationResult.path;
|
|
23822
|
+
const gitService = new GitService(path27, log);
|
|
23771
23823
|
const gitValidation = await gitService.validateRepository();
|
|
23772
23824
|
if (!gitValidation.isValid) {
|
|
23773
23825
|
throw new Error(`Invalid git repository: ${gitValidation.error}`);
|
|
@@ -24152,9 +24204,9 @@ Example payload:
|
|
|
24152
24204
|
`Invalid path: potential security risk detected in path: ${pathValidationResult.error}`
|
|
24153
24205
|
);
|
|
24154
24206
|
}
|
|
24155
|
-
const
|
|
24207
|
+
const path27 = pathValidationResult.path;
|
|
24156
24208
|
const files = await getLocalFiles({
|
|
24157
|
-
path:
|
|
24209
|
+
path: path27,
|
|
24158
24210
|
maxFileSize: MCP_MAX_FILE_SIZE,
|
|
24159
24211
|
maxFiles: args.maxFiles,
|
|
24160
24212
|
scanContext: ScanContext.USER_REQUEST,
|
|
@@ -24174,7 +24226,7 @@ Example payload:
|
|
|
24174
24226
|
try {
|
|
24175
24227
|
const fixResult = await this.vulnerabilityFixService.processVulnerabilities({
|
|
24176
24228
|
fileList: files.map((file) => file.relativePath),
|
|
24177
|
-
repositoryPath:
|
|
24229
|
+
repositoryPath: path27,
|
|
24178
24230
|
offset: args.offset,
|
|
24179
24231
|
limit: args.limit,
|
|
24180
24232
|
isRescan: args.rescan || !!args.maxFiles
|
|
@@ -24414,10 +24466,10 @@ init_client_generates();
|
|
|
24414
24466
|
init_urlParser2();
|
|
24415
24467
|
|
|
24416
24468
|
// src/features/codeium_intellij/codeium_language_server_grpc_client.ts
|
|
24417
|
-
import
|
|
24469
|
+
import path24 from "path";
|
|
24418
24470
|
import * as grpc from "@grpc/grpc-js";
|
|
24419
24471
|
import * as protoLoader from "@grpc/proto-loader";
|
|
24420
|
-
var PROTO_PATH =
|
|
24472
|
+
var PROTO_PATH = path24.join(
|
|
24421
24473
|
getModuleRootDir(),
|
|
24422
24474
|
"src/features/codeium_intellij/proto/exa/language_server_pb/language_server.proto"
|
|
24423
24475
|
);
|
|
@@ -24429,7 +24481,7 @@ function loadProto() {
|
|
|
24429
24481
|
defaults: true,
|
|
24430
24482
|
oneofs: true,
|
|
24431
24483
|
includeDirs: [
|
|
24432
|
-
|
|
24484
|
+
path24.join(getModuleRootDir(), "src/features/codeium_intellij/proto")
|
|
24433
24485
|
]
|
|
24434
24486
|
});
|
|
24435
24487
|
return grpc.loadPackageDefinition(
|
|
@@ -24485,28 +24537,28 @@ async function getGrpcClient(port, csrf3) {
|
|
|
24485
24537
|
// src/features/codeium_intellij/parse_intellij_logs.ts
|
|
24486
24538
|
import fs25 from "fs";
|
|
24487
24539
|
import os11 from "os";
|
|
24488
|
-
import
|
|
24540
|
+
import path25 from "path";
|
|
24489
24541
|
function getLogsDir() {
|
|
24490
24542
|
if (process.platform === "darwin") {
|
|
24491
|
-
return
|
|
24543
|
+
return path25.join(os11.homedir(), "Library/Logs/JetBrains");
|
|
24492
24544
|
} else if (process.platform === "win32") {
|
|
24493
|
-
return
|
|
24494
|
-
process.env["LOCALAPPDATA"] ||
|
|
24545
|
+
return path25.join(
|
|
24546
|
+
process.env["LOCALAPPDATA"] || path25.join(os11.homedir(), "AppData/Local"),
|
|
24495
24547
|
"JetBrains"
|
|
24496
24548
|
);
|
|
24497
24549
|
} else {
|
|
24498
|
-
return
|
|
24550
|
+
return path25.join(os11.homedir(), ".cache/JetBrains");
|
|
24499
24551
|
}
|
|
24500
24552
|
}
|
|
24501
24553
|
function parseIdeLogDir(ideLogDir) {
|
|
24502
24554
|
const logFiles = fs25.readdirSync(ideLogDir).filter((f) => /^idea(\.\d+)?\.log$/.test(f)).map((f) => ({
|
|
24503
24555
|
name: f,
|
|
24504
|
-
mtime: fs25.statSync(
|
|
24556
|
+
mtime: fs25.statSync(path25.join(ideLogDir, f)).mtimeMs
|
|
24505
24557
|
})).sort((a, b) => a.mtime - b.mtime).map((f) => f.name);
|
|
24506
24558
|
let latestCsrf = null;
|
|
24507
24559
|
let latestPort = null;
|
|
24508
24560
|
for (const logFile of logFiles) {
|
|
24509
|
-
const lines = fs25.readFileSync(
|
|
24561
|
+
const lines = fs25.readFileSync(path25.join(ideLogDir, logFile), "utf-8").split("\n");
|
|
24510
24562
|
for (const line of lines) {
|
|
24511
24563
|
if (!line.includes(
|
|
24512
24564
|
"com.codeium.intellij.language_server.LanguageServerProcessHandler"
|
|
@@ -24534,9 +24586,9 @@ function findRunningCodeiumLanguageServers() {
|
|
|
24534
24586
|
const logsDir = getLogsDir();
|
|
24535
24587
|
if (!fs25.existsSync(logsDir)) return results;
|
|
24536
24588
|
for (const ide of fs25.readdirSync(logsDir)) {
|
|
24537
|
-
let ideLogDir =
|
|
24589
|
+
let ideLogDir = path25.join(logsDir, ide);
|
|
24538
24590
|
if (process.platform !== "darwin") {
|
|
24539
|
-
ideLogDir =
|
|
24591
|
+
ideLogDir = path25.join(ideLogDir, "log");
|
|
24540
24592
|
}
|
|
24541
24593
|
if (!fs25.existsSync(ideLogDir) || !fs25.statSync(ideLogDir).isDirectory()) {
|
|
24542
24594
|
continue;
|
|
@@ -24719,10 +24771,10 @@ function processChatStepCodeAction(step) {
|
|
|
24719
24771
|
// src/features/codeium_intellij/install_hook.ts
|
|
24720
24772
|
import fsPromises6 from "fs/promises";
|
|
24721
24773
|
import os12 from "os";
|
|
24722
|
-
import
|
|
24774
|
+
import path26 from "path";
|
|
24723
24775
|
import chalk14 from "chalk";
|
|
24724
24776
|
function getCodeiumHooksPath() {
|
|
24725
|
-
return
|
|
24777
|
+
return path26.join(os12.homedir(), ".codeium", "hooks.json");
|
|
24726
24778
|
}
|
|
24727
24779
|
async function readCodeiumHooks() {
|
|
24728
24780
|
const hooksPath = getCodeiumHooksPath();
|
|
@@ -24735,7 +24787,7 @@ async function readCodeiumHooks() {
|
|
|
24735
24787
|
}
|
|
24736
24788
|
async function writeCodeiumHooks(config2) {
|
|
24737
24789
|
const hooksPath = getCodeiumHooksPath();
|
|
24738
|
-
const dir =
|
|
24790
|
+
const dir = path26.dirname(hooksPath);
|
|
24739
24791
|
await fsPromises6.mkdir(dir, { recursive: true });
|
|
24740
24792
|
await fsPromises6.writeFile(
|
|
24741
24793
|
hooksPath,
|