@probelabs/probe 0.6.0-rc173 → 0.6.0-rc175
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/build/agent/ProbeAgent.d.ts +6 -0
- package/build/agent/ProbeAgent.js +69 -1
- package/build/agent/index.js +418 -281
- package/build/agent/probeTool.js +4 -13
- package/build/downloader.js +6 -2
- package/build/extract.js +13 -5
- package/build/extractor.js +6 -2
- package/build/query.js +9 -2
- package/build/search.js +10 -2
- package/build/tools/bash.js +5 -5
- package/build/tools/edit.js +7 -7
- package/build/tools/langchain.js +12 -3
- package/build/tools/vercel.js +25 -29
- package/build/utils/file-lister.js +9 -2
- package/build/utils/path-validation.js +58 -0
- package/build/utils/symlink-utils.js +63 -0
- package/cjs/agent/ProbeAgent.cjs +515 -376
- package/cjs/index.cjs +535 -387
- package/index.d.ts +12 -1
- package/package.json +2 -2
- package/src/agent/ProbeAgent.d.ts +6 -0
- package/src/agent/ProbeAgent.js +69 -1
- package/src/agent/probeTool.js +4 -13
- package/src/downloader.js +6 -2
- package/src/extract.js +13 -5
- package/src/extractor.js +6 -2
- package/src/query.js +9 -2
- package/src/search.js +10 -2
- package/src/tools/bash.js +5 -5
- package/src/tools/edit.js +7 -7
- package/src/tools/langchain.js +12 -3
- package/src/tools/vercel.js +25 -29
- package/src/utils/file-lister.js +9 -2
- package/src/utils/path-validation.js +58 -0
- package/src/utils/symlink-utils.js +63 -0
package/build/agent/index.js
CHANGED
|
@@ -2210,9 +2210,50 @@ var init_directory_resolver = __esm({
|
|
|
2210
2210
|
}
|
|
2211
2211
|
});
|
|
2212
2212
|
|
|
2213
|
+
// src/utils/symlink-utils.js
|
|
2214
|
+
import fs2 from "fs";
|
|
2215
|
+
import { promises as fsPromises } from "fs";
|
|
2216
|
+
async function getEntryType(entry, fullPath) {
|
|
2217
|
+
try {
|
|
2218
|
+
const stats = await fsPromises.stat(fullPath);
|
|
2219
|
+
return {
|
|
2220
|
+
isFile: stats.isFile(),
|
|
2221
|
+
isDirectory: stats.isDirectory(),
|
|
2222
|
+
size: stats.size
|
|
2223
|
+
};
|
|
2224
|
+
} catch {
|
|
2225
|
+
return {
|
|
2226
|
+
isFile: entry.isFile(),
|
|
2227
|
+
isDirectory: entry.isDirectory(),
|
|
2228
|
+
size: 0
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2231
|
+
}
|
|
2232
|
+
function getEntryTypeSync(entry, fullPath) {
|
|
2233
|
+
try {
|
|
2234
|
+
const stats = fs2.statSync(fullPath);
|
|
2235
|
+
return {
|
|
2236
|
+
isFile: stats.isFile(),
|
|
2237
|
+
isDirectory: stats.isDirectory(),
|
|
2238
|
+
size: stats.size
|
|
2239
|
+
};
|
|
2240
|
+
} catch {
|
|
2241
|
+
return {
|
|
2242
|
+
isFile: entry.isFile(),
|
|
2243
|
+
isDirectory: entry.isDirectory(),
|
|
2244
|
+
size: 0
|
|
2245
|
+
};
|
|
2246
|
+
}
|
|
2247
|
+
}
|
|
2248
|
+
var init_symlink_utils = __esm({
|
|
2249
|
+
"src/utils/symlink-utils.js"() {
|
|
2250
|
+
"use strict";
|
|
2251
|
+
}
|
|
2252
|
+
});
|
|
2253
|
+
|
|
2213
2254
|
// src/downloader.js
|
|
2214
2255
|
import axios from "axios";
|
|
2215
|
-
import
|
|
2256
|
+
import fs3 from "fs-extra";
|
|
2216
2257
|
import path2 from "path";
|
|
2217
2258
|
import { createHash } from "crypto";
|
|
2218
2259
|
import { promisify } from "util";
|
|
@@ -2249,7 +2290,7 @@ async function acquireFileLock(lockPath, version) {
|
|
|
2249
2290
|
timestamp: Date.now()
|
|
2250
2291
|
};
|
|
2251
2292
|
try {
|
|
2252
|
-
await
|
|
2293
|
+
await fs3.writeFile(lockPath, JSON.stringify(lockData), { flag: "wx" });
|
|
2253
2294
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2254
2295
|
console.log(`Acquired file lock: ${lockPath}`);
|
|
2255
2296
|
}
|
|
@@ -2257,13 +2298,13 @@ async function acquireFileLock(lockPath, version) {
|
|
|
2257
2298
|
} catch (error) {
|
|
2258
2299
|
if (error.code === "EEXIST") {
|
|
2259
2300
|
try {
|
|
2260
|
-
const existingLock = JSON.parse(await
|
|
2301
|
+
const existingLock = JSON.parse(await fs3.readFile(lockPath, "utf-8"));
|
|
2261
2302
|
const lockAge = Date.now() - existingLock.timestamp;
|
|
2262
2303
|
if (lockAge > LOCK_TIMEOUT_MS) {
|
|
2263
2304
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2264
2305
|
console.log(`Removing stale lock file (age: ${Math.round(lockAge / 1e3)}s, pid: ${existingLock.pid})`);
|
|
2265
2306
|
}
|
|
2266
|
-
await
|
|
2307
|
+
await fs3.remove(lockPath);
|
|
2267
2308
|
return false;
|
|
2268
2309
|
}
|
|
2269
2310
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
@@ -2275,7 +2316,7 @@ async function acquireFileLock(lockPath, version) {
|
|
|
2275
2316
|
console.log(`Lock file corrupted, removing: ${readError.message}`);
|
|
2276
2317
|
}
|
|
2277
2318
|
try {
|
|
2278
|
-
await
|
|
2319
|
+
await fs3.remove(lockPath);
|
|
2279
2320
|
} catch {
|
|
2280
2321
|
}
|
|
2281
2322
|
return false;
|
|
@@ -2297,7 +2338,7 @@ async function acquireFileLock(lockPath, version) {
|
|
|
2297
2338
|
}
|
|
2298
2339
|
async function releaseFileLock(lockPath) {
|
|
2299
2340
|
try {
|
|
2300
|
-
await
|
|
2341
|
+
await fs3.remove(lockPath);
|
|
2301
2342
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2302
2343
|
console.log(`Released file lock: ${lockPath}`);
|
|
2303
2344
|
}
|
|
@@ -2310,13 +2351,13 @@ async function releaseFileLock(lockPath) {
|
|
|
2310
2351
|
async function waitForFileLock(lockPath, binaryPath) {
|
|
2311
2352
|
const startTime = Date.now();
|
|
2312
2353
|
while (Date.now() - startTime < MAX_LOCK_WAIT_MS) {
|
|
2313
|
-
if (await
|
|
2354
|
+
if (await fs3.pathExists(binaryPath)) {
|
|
2314
2355
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2315
2356
|
console.log(`Binary now available at ${binaryPath}, download completed by another process`);
|
|
2316
2357
|
}
|
|
2317
2358
|
return true;
|
|
2318
2359
|
}
|
|
2319
|
-
const lockExists = await
|
|
2360
|
+
const lockExists = await fs3.pathExists(lockPath);
|
|
2320
2361
|
if (!lockExists) {
|
|
2321
2362
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2322
2363
|
console.log(`Lock file removed but binary not found - download may have failed`);
|
|
@@ -2324,7 +2365,7 @@ async function waitForFileLock(lockPath, binaryPath) {
|
|
|
2324
2365
|
return false;
|
|
2325
2366
|
}
|
|
2326
2367
|
try {
|
|
2327
|
-
const lockData = JSON.parse(await
|
|
2368
|
+
const lockData = JSON.parse(await fs3.readFile(lockPath, "utf-8"));
|
|
2328
2369
|
const lockAge = Date.now() - lockData.timestamp;
|
|
2329
2370
|
if (lockAge > LOCK_TIMEOUT_MS) {
|
|
2330
2371
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
@@ -2642,13 +2683,13 @@ function findBestAsset(assets, osInfo, archInfo) {
|
|
|
2642
2683
|
return bestAsset;
|
|
2643
2684
|
}
|
|
2644
2685
|
async function downloadAsset(asset, outputDir) {
|
|
2645
|
-
await
|
|
2686
|
+
await fs3.ensureDir(outputDir);
|
|
2646
2687
|
const assetPath = path2.join(outputDir, asset.name);
|
|
2647
2688
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2648
2689
|
console.log(`Downloading ${asset.name}...`);
|
|
2649
2690
|
}
|
|
2650
2691
|
const assetResponse = await axios.get(asset.url, { responseType: "arraybuffer" });
|
|
2651
|
-
await
|
|
2692
|
+
await fs3.writeFile(assetPath, Buffer.from(assetResponse.data));
|
|
2652
2693
|
const checksumUrl = asset.checksumUrl || `${asset.url}.sha256`;
|
|
2653
2694
|
const checksumFileName = asset.checksumName || `${asset.name}.sha256`;
|
|
2654
2695
|
let checksumPath = null;
|
|
@@ -2658,7 +2699,7 @@ async function downloadAsset(asset, outputDir) {
|
|
|
2658
2699
|
}
|
|
2659
2700
|
const checksumResponse = await axios.get(checksumUrl);
|
|
2660
2701
|
checksumPath = path2.join(outputDir, checksumFileName);
|
|
2661
|
-
await
|
|
2702
|
+
await fs3.writeFile(checksumPath, checksumResponse.data);
|
|
2662
2703
|
} catch (error) {
|
|
2663
2704
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2664
2705
|
console.log("No checksum file found, skipping verification");
|
|
@@ -2673,9 +2714,9 @@ async function verifyChecksum(assetPath, checksumPath) {
|
|
|
2673
2714
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2674
2715
|
console.log(`Verifying checksum...`);
|
|
2675
2716
|
}
|
|
2676
|
-
const checksumContent = await
|
|
2717
|
+
const checksumContent = await fs3.readFile(checksumPath, "utf-8");
|
|
2677
2718
|
const expectedChecksum = checksumContent.trim().split(" ")[0];
|
|
2678
|
-
const fileBuffer = await
|
|
2719
|
+
const fileBuffer = await fs3.readFile(assetPath);
|
|
2679
2720
|
const actualChecksum = createHash("sha256").update(fileBuffer).digest("hex");
|
|
2680
2721
|
if (expectedChecksum !== actualChecksum) {
|
|
2681
2722
|
console.error(`Checksum verification failed!`);
|
|
@@ -2698,7 +2739,7 @@ async function extractBinary(assetPath, outputDir) {
|
|
|
2698
2739
|
const binaryPath = path2.join(outputDir, binaryName);
|
|
2699
2740
|
try {
|
|
2700
2741
|
const extractDir = path2.join(outputDir, "temp_extract");
|
|
2701
|
-
await
|
|
2742
|
+
await fs3.ensureDir(extractDir);
|
|
2702
2743
|
if (assetName.endsWith(".tar.gz") || assetName.endsWith(".tgz")) {
|
|
2703
2744
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2704
2745
|
console.log(`Extracting tar.gz to ${extractDir}...`);
|
|
@@ -2716,11 +2757,11 @@ async function extractBinary(assetPath, outputDir) {
|
|
|
2716
2757
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2717
2758
|
console.log(`Copying binary directly to ${binaryPath}`);
|
|
2718
2759
|
}
|
|
2719
|
-
await
|
|
2760
|
+
await fs3.copyFile(assetPath, binaryPath);
|
|
2720
2761
|
if (!isWindows) {
|
|
2721
|
-
await
|
|
2762
|
+
await fs3.chmod(binaryPath, 493);
|
|
2722
2763
|
}
|
|
2723
|
-
await
|
|
2764
|
+
await fs3.remove(extractDir);
|
|
2724
2765
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2725
2766
|
console.log(`Binary installed to ${binaryPath}`);
|
|
2726
2767
|
}
|
|
@@ -2730,13 +2771,14 @@ async function extractBinary(assetPath, outputDir) {
|
|
|
2730
2771
|
console.log(`Searching for binary in extracted files...`);
|
|
2731
2772
|
}
|
|
2732
2773
|
const findBinary = async (dir) => {
|
|
2733
|
-
const entries = await
|
|
2774
|
+
const entries = await fs3.readdir(dir, { withFileTypes: true });
|
|
2734
2775
|
for (const entry of entries) {
|
|
2735
2776
|
const fullPath = path2.join(dir, entry.name);
|
|
2736
|
-
|
|
2777
|
+
const entryType = await getEntryType(entry, fullPath);
|
|
2778
|
+
if (entryType.isDirectory) {
|
|
2737
2779
|
const result = await findBinary(fullPath);
|
|
2738
2780
|
if (result) return result;
|
|
2739
|
-
} else if (
|
|
2781
|
+
} else if (entryType.isFile) {
|
|
2740
2782
|
if (entry.name === binaryName || entry.name === BINARY_NAME || isWindows && entry.name.endsWith(".exe")) {
|
|
2741
2783
|
return fullPath;
|
|
2742
2784
|
}
|
|
@@ -2746,7 +2788,7 @@ async function extractBinary(assetPath, outputDir) {
|
|
|
2746
2788
|
};
|
|
2747
2789
|
const binaryFilePath = await findBinary(extractDir);
|
|
2748
2790
|
if (!binaryFilePath) {
|
|
2749
|
-
const allFiles = await
|
|
2791
|
+
const allFiles = await fs3.readdir(extractDir, { recursive: true });
|
|
2750
2792
|
console.error(`Binary not found in extracted files. Found: ${allFiles.join(", ")}`);
|
|
2751
2793
|
throw new Error(`Binary not found in the archive.`);
|
|
2752
2794
|
}
|
|
@@ -2754,11 +2796,11 @@ async function extractBinary(assetPath, outputDir) {
|
|
|
2754
2796
|
console.log(`Found binary at ${binaryFilePath}`);
|
|
2755
2797
|
console.log(`Copying binary to ${binaryPath}`);
|
|
2756
2798
|
}
|
|
2757
|
-
await
|
|
2799
|
+
await fs3.copyFile(binaryFilePath, binaryPath);
|
|
2758
2800
|
if (!isWindows) {
|
|
2759
|
-
await
|
|
2801
|
+
await fs3.chmod(binaryPath, 493);
|
|
2760
2802
|
}
|
|
2761
|
-
await
|
|
2803
|
+
await fs3.remove(extractDir);
|
|
2762
2804
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2763
2805
|
console.log(`Binary successfully installed to ${binaryPath}`);
|
|
2764
2806
|
}
|
|
@@ -2771,8 +2813,8 @@ async function extractBinary(assetPath, outputDir) {
|
|
|
2771
2813
|
async function getVersionInfo(binDir) {
|
|
2772
2814
|
try {
|
|
2773
2815
|
const versionInfoPath = path2.join(binDir, "version-info.json");
|
|
2774
|
-
if (await
|
|
2775
|
-
const content = await
|
|
2816
|
+
if (await fs3.pathExists(versionInfoPath)) {
|
|
2817
|
+
const content = await fs3.readFile(versionInfoPath, "utf-8");
|
|
2776
2818
|
return JSON.parse(content);
|
|
2777
2819
|
}
|
|
2778
2820
|
return null;
|
|
@@ -2787,7 +2829,7 @@ async function saveVersionInfo(version, binDir) {
|
|
|
2787
2829
|
lastUpdated: (/* @__PURE__ */ new Date()).toISOString()
|
|
2788
2830
|
};
|
|
2789
2831
|
const versionInfoPath = path2.join(binDir, "version-info.json");
|
|
2790
|
-
await
|
|
2832
|
+
await fs3.writeFile(versionInfoPath, JSON.stringify(versionInfo, null, 2));
|
|
2791
2833
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2792
2834
|
console.log(`Version info saved: ${version} at ${versionInfoPath}`);
|
|
2793
2835
|
}
|
|
@@ -2802,11 +2844,11 @@ async function getPackageVersion() {
|
|
|
2802
2844
|
];
|
|
2803
2845
|
for (const packageJsonPath of possiblePaths) {
|
|
2804
2846
|
try {
|
|
2805
|
-
if (
|
|
2847
|
+
if (fs3.existsSync(packageJsonPath)) {
|
|
2806
2848
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2807
2849
|
console.log(`Found package.json at: ${packageJsonPath}`);
|
|
2808
2850
|
}
|
|
2809
|
-
const packageJson = JSON.parse(
|
|
2851
|
+
const packageJson = JSON.parse(fs3.readFileSync(packageJsonPath, "utf-8"));
|
|
2810
2852
|
if (packageJson.version) {
|
|
2811
2853
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
2812
2854
|
console.log(`Using version from package.json: ${packageJson.version}`);
|
|
@@ -2862,9 +2904,9 @@ async function doDownload(version) {
|
|
|
2862
2904
|
const extractedBinaryPath = await extractBinary(assetPath, localDir);
|
|
2863
2905
|
await saveVersionInfo(tagVersion, localDir);
|
|
2864
2906
|
try {
|
|
2865
|
-
await
|
|
2907
|
+
await fs3.remove(assetPath);
|
|
2866
2908
|
if (checksumPath) {
|
|
2867
|
-
await
|
|
2909
|
+
await fs3.remove(checksumPath);
|
|
2868
2910
|
}
|
|
2869
2911
|
} catch (err) {
|
|
2870
2912
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
@@ -2885,7 +2927,7 @@ async function downloadProbeBinary(version) {
|
|
|
2885
2927
|
const isWindows = os2.platform() === "win32";
|
|
2886
2928
|
const binaryName = isWindows ? `${BINARY_NAME}.exe` : `${BINARY_NAME}-binary`;
|
|
2887
2929
|
const binaryPath = path2.join(localDir, binaryName);
|
|
2888
|
-
if (await
|
|
2930
|
+
if (await fs3.pathExists(binaryPath)) {
|
|
2889
2931
|
const versionInfo = await getVersionInfo(localDir);
|
|
2890
2932
|
if (versionInfo && versionInfo.version === version) {
|
|
2891
2933
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
@@ -2940,6 +2982,7 @@ var init_downloader = __esm({
|
|
|
2940
2982
|
"use strict";
|
|
2941
2983
|
init_utils();
|
|
2942
2984
|
init_directory_resolver();
|
|
2985
|
+
init_symlink_utils();
|
|
2943
2986
|
exec = promisify(execCallback);
|
|
2944
2987
|
REPO_OWNER = "probelabs";
|
|
2945
2988
|
REPO_NAME = "probe";
|
|
@@ -2955,11 +2998,11 @@ var init_downloader = __esm({
|
|
|
2955
2998
|
|
|
2956
2999
|
// src/utils.js
|
|
2957
3000
|
import path3 from "path";
|
|
2958
|
-
import
|
|
3001
|
+
import fs4 from "fs-extra";
|
|
2959
3002
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
2960
3003
|
async function getBinaryPath(options = {}) {
|
|
2961
3004
|
const { forceDownload = false, version } = options;
|
|
2962
|
-
if (process.env.PROBE_PATH &&
|
|
3005
|
+
if (process.env.PROBE_PATH && fs4.existsSync(process.env.PROBE_PATH) && !forceDownload) {
|
|
2963
3006
|
probeBinaryPath = process.env.PROBE_PATH;
|
|
2964
3007
|
return probeBinaryPath;
|
|
2965
3008
|
}
|
|
@@ -2972,13 +3015,13 @@ async function getBinaryPath(options = {}) {
|
|
|
2972
3015
|
const binaryName = isWindows ? "probe.exe" : "probe-binary";
|
|
2973
3016
|
const localPackageBin = path3.resolve(__dirname3, "..", "bin");
|
|
2974
3017
|
const localBinaryPath = path3.join(localPackageBin, binaryName);
|
|
2975
|
-
if (
|
|
3018
|
+
if (fs4.existsSync(localBinaryPath) && !forceDownload) {
|
|
2976
3019
|
probeBinaryPath = localBinaryPath;
|
|
2977
3020
|
return probeBinaryPath;
|
|
2978
3021
|
}
|
|
2979
3022
|
const binDir = await getPackageBinDir();
|
|
2980
3023
|
const binaryPath = path3.join(binDir, binaryName);
|
|
2981
|
-
if (
|
|
3024
|
+
if (fs4.existsSync(binaryPath) && !forceDownload) {
|
|
2982
3025
|
probeBinaryPath = binaryPath;
|
|
2983
3026
|
return probeBinaryPath;
|
|
2984
3027
|
}
|
|
@@ -3025,6 +3068,31 @@ var init_utils = __esm({
|
|
|
3025
3068
|
}
|
|
3026
3069
|
});
|
|
3027
3070
|
|
|
3071
|
+
// src/utils/path-validation.js
|
|
3072
|
+
import path4 from "path";
|
|
3073
|
+
import { promises as fs5 } from "fs";
|
|
3074
|
+
async function validateCwdPath(inputPath, defaultPath = process.cwd()) {
|
|
3075
|
+
const targetPath = inputPath || defaultPath;
|
|
3076
|
+
const normalizedPath = path4.normalize(path4.resolve(targetPath));
|
|
3077
|
+
try {
|
|
3078
|
+
const stats = await fs5.stat(normalizedPath);
|
|
3079
|
+
if (!stats.isDirectory()) {
|
|
3080
|
+
throw new Error(`Path is not a directory: ${normalizedPath}`);
|
|
3081
|
+
}
|
|
3082
|
+
} catch (error) {
|
|
3083
|
+
if (error.code === "ENOENT") {
|
|
3084
|
+
throw new Error(`Path does not exist: ${normalizedPath}`);
|
|
3085
|
+
}
|
|
3086
|
+
throw error;
|
|
3087
|
+
}
|
|
3088
|
+
return normalizedPath;
|
|
3089
|
+
}
|
|
3090
|
+
var init_path_validation = __esm({
|
|
3091
|
+
"src/utils/path-validation.js"() {
|
|
3092
|
+
"use strict";
|
|
3093
|
+
}
|
|
3094
|
+
});
|
|
3095
|
+
|
|
3028
3096
|
// src/search.js
|
|
3029
3097
|
import { execFile } from "child_process";
|
|
3030
3098
|
import { promisify as promisify2 } from "util";
|
|
@@ -3066,9 +3134,11 @@ async function search(options) {
|
|
|
3066
3134
|
options.session = process.env.PROBE_SESSION_ID;
|
|
3067
3135
|
}
|
|
3068
3136
|
const queries = Array.isArray(options.query) ? options.query : [options.query];
|
|
3137
|
+
const cwd = await validateCwdPath(options.cwd);
|
|
3069
3138
|
if (process.env.DEBUG === "1") {
|
|
3070
3139
|
let logMessage = `
|
|
3071
3140
|
Search: query="${queries[0]}" path="${options.path}"`;
|
|
3141
|
+
if (options.cwd) logMessage += ` cwd="${options.cwd}"`;
|
|
3072
3142
|
if (options.maxResults) logMessage += ` maxResults=${options.maxResults}`;
|
|
3073
3143
|
logMessage += ` maxTokens=${options.maxTokens}`;
|
|
3074
3144
|
logMessage += ` timeout=${options.timeout}`;
|
|
@@ -3088,6 +3158,7 @@ Search: query="${queries[0]}" path="${options.path}"`;
|
|
|
3088
3158
|
}
|
|
3089
3159
|
try {
|
|
3090
3160
|
const { stdout, stderr } = await execFileAsync(binaryPath, args, {
|
|
3161
|
+
cwd,
|
|
3091
3162
|
timeout: options.timeout * 1e3,
|
|
3092
3163
|
// Convert seconds to milliseconds
|
|
3093
3164
|
maxBuffer: 50 * 1024 * 1024
|
|
@@ -3141,13 +3212,15 @@ Search results: ${resultCount} matches, ${tokenCount} tokens`;
|
|
|
3141
3212
|
if (error.code === "ETIMEDOUT" || error.killed) {
|
|
3142
3213
|
const timeoutMessage = `Search operation timed out after ${options.timeout} seconds.
|
|
3143
3214
|
Binary: ${binaryPath}
|
|
3144
|
-
Args: ${args.join(" ")}
|
|
3215
|
+
Args: ${args.join(" ")}
|
|
3216
|
+
Cwd: ${cwd}`;
|
|
3145
3217
|
console.error(timeoutMessage);
|
|
3146
3218
|
throw new Error(timeoutMessage);
|
|
3147
3219
|
}
|
|
3148
3220
|
const errorMessage = `Error executing search command: ${error.message}
|
|
3149
3221
|
Binary: ${binaryPath}
|
|
3150
|
-
Args: ${args.join(" ")}
|
|
3222
|
+
Args: ${args.join(" ")}
|
|
3223
|
+
Cwd: ${cwd}`;
|
|
3151
3224
|
throw new Error(errorMessage);
|
|
3152
3225
|
}
|
|
3153
3226
|
}
|
|
@@ -3156,6 +3229,7 @@ var init_search = __esm({
|
|
|
3156
3229
|
"src/search.js"() {
|
|
3157
3230
|
"use strict";
|
|
3158
3231
|
init_utils();
|
|
3232
|
+
init_path_validation();
|
|
3159
3233
|
execFileAsync = promisify2(execFile);
|
|
3160
3234
|
SEARCH_FLAG_MAP = {
|
|
3161
3235
|
filesOnly: "--files-only",
|
|
@@ -3195,8 +3269,10 @@ async function query(options) {
|
|
|
3195
3269
|
cliArgs.push("--format", "json");
|
|
3196
3270
|
}
|
|
3197
3271
|
cliArgs.push(escapeString(options.pattern), escapeString(options.path));
|
|
3272
|
+
const cwd = await validateCwdPath(options.cwd);
|
|
3198
3273
|
if (process.env.DEBUG === "1") {
|
|
3199
3274
|
let logMessage = `Query: pattern="${options.pattern}" path="${options.path}"`;
|
|
3275
|
+
if (options.cwd) logMessage += ` cwd="${options.cwd}"`;
|
|
3200
3276
|
if (options.language) logMessage += ` language=${options.language}`;
|
|
3201
3277
|
if (options.maxResults) logMessage += ` maxResults=${options.maxResults}`;
|
|
3202
3278
|
if (options.allowTests) logMessage += " allowTests=true";
|
|
@@ -3204,7 +3280,7 @@ async function query(options) {
|
|
|
3204
3280
|
}
|
|
3205
3281
|
const command = `${binaryPath} query ${cliArgs.join(" ")}`;
|
|
3206
3282
|
try {
|
|
3207
|
-
const { stdout, stderr } = await execAsync(command);
|
|
3283
|
+
const { stdout, stderr } = await execAsync(command, { cwd });
|
|
3208
3284
|
if (stderr) {
|
|
3209
3285
|
console.error(`stderr: ${stderr}`);
|
|
3210
3286
|
}
|
|
@@ -3229,7 +3305,8 @@ async function query(options) {
|
|
|
3229
3305
|
return stdout;
|
|
3230
3306
|
} catch (error) {
|
|
3231
3307
|
const errorMessage = `Error executing query command: ${error.message}
|
|
3232
|
-
Command: ${command}
|
|
3308
|
+
Command: ${command}
|
|
3309
|
+
Cwd: ${cwd}`;
|
|
3233
3310
|
throw new Error(errorMessage);
|
|
3234
3311
|
}
|
|
3235
3312
|
}
|
|
@@ -3238,6 +3315,7 @@ var init_query = __esm({
|
|
|
3238
3315
|
"src/query.js"() {
|
|
3239
3316
|
"use strict";
|
|
3240
3317
|
init_utils();
|
|
3318
|
+
init_path_validation();
|
|
3241
3319
|
execAsync = promisify3(exec2);
|
|
3242
3320
|
QUERY_FLAG_MAP = {
|
|
3243
3321
|
language: "--language",
|
|
@@ -3274,6 +3352,7 @@ async function extract(options) {
|
|
|
3274
3352
|
cliArgs.push(escapeString(file));
|
|
3275
3353
|
}
|
|
3276
3354
|
}
|
|
3355
|
+
const cwd = await validateCwdPath(options.cwd);
|
|
3277
3356
|
if (process.env.DEBUG === "1") {
|
|
3278
3357
|
let logMessage = `
|
|
3279
3358
|
Extract:`;
|
|
@@ -3282,6 +3361,7 @@ Extract:`;
|
|
|
3282
3361
|
}
|
|
3283
3362
|
if (options.inputFile) logMessage += ` inputFile="${options.inputFile}"`;
|
|
3284
3363
|
if (options.content) logMessage += ` content=(${typeof options.content === "string" ? options.content.length : options.content.byteLength} bytes)`;
|
|
3364
|
+
if (options.cwd) logMessage += ` cwd="${cwd}"`;
|
|
3285
3365
|
if (options.allowTests) logMessage += " allowTests=true";
|
|
3286
3366
|
if (options.contextLines) logMessage += ` contextLines=${options.contextLines}`;
|
|
3287
3367
|
if (options.format) logMessage += ` format=${options.format}`;
|
|
@@ -3289,25 +3369,27 @@ Extract:`;
|
|
|
3289
3369
|
console.error(logMessage);
|
|
3290
3370
|
}
|
|
3291
3371
|
if (hasContent) {
|
|
3292
|
-
return extractWithStdin(binaryPath, cliArgs, options.content, options);
|
|
3372
|
+
return extractWithStdin(binaryPath, cliArgs, options.content, options, cwd);
|
|
3293
3373
|
}
|
|
3294
3374
|
const command = `${binaryPath} extract ${cliArgs.join(" ")}`;
|
|
3295
3375
|
try {
|
|
3296
|
-
const { stdout, stderr } = await execAsync2(command);
|
|
3376
|
+
const { stdout, stderr } = await execAsync2(command, { cwd });
|
|
3297
3377
|
if (stderr) {
|
|
3298
3378
|
console.error(`stderr: ${stderr}`);
|
|
3299
3379
|
}
|
|
3300
3380
|
return processExtractOutput(stdout, options);
|
|
3301
3381
|
} catch (error) {
|
|
3302
3382
|
const errorMessage = `Error executing extract command: ${error.message}
|
|
3303
|
-
Command: ${command}
|
|
3383
|
+
Command: ${command}
|
|
3384
|
+
Cwd: ${cwd}`;
|
|
3304
3385
|
throw new Error(errorMessage);
|
|
3305
3386
|
}
|
|
3306
3387
|
}
|
|
3307
|
-
function extractWithStdin(binaryPath, cliArgs, content, options) {
|
|
3388
|
+
function extractWithStdin(binaryPath, cliArgs, content, options, cwd) {
|
|
3308
3389
|
return new Promise((resolve6, reject2) => {
|
|
3309
3390
|
const childProcess = spawn(binaryPath, ["extract", ...cliArgs], {
|
|
3310
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
3391
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
3392
|
+
cwd
|
|
3311
3393
|
});
|
|
3312
3394
|
let stdout = "";
|
|
3313
3395
|
let stderr = "";
|
|
@@ -3396,6 +3478,7 @@ var init_extract = __esm({
|
|
|
3396
3478
|
"src/extract.js"() {
|
|
3397
3479
|
"use strict";
|
|
3398
3480
|
init_utils();
|
|
3481
|
+
init_path_validation();
|
|
3399
3482
|
execAsync2 = promisify4(exec3);
|
|
3400
3483
|
EXTRACT_FLAG_MAP = {
|
|
3401
3484
|
allowTests: "--allow-tests",
|
|
@@ -3428,7 +3511,7 @@ async function delegate({
|
|
|
3428
3511
|
maxIterations = 30,
|
|
3429
3512
|
tracer = null,
|
|
3430
3513
|
parentSessionId = null,
|
|
3431
|
-
path:
|
|
3514
|
+
path: path9 = null,
|
|
3432
3515
|
provider = null,
|
|
3433
3516
|
model = null
|
|
3434
3517
|
}) {
|
|
@@ -3468,7 +3551,7 @@ async function delegate({
|
|
|
3468
3551
|
maxIterations: remainingIterations,
|
|
3469
3552
|
debug,
|
|
3470
3553
|
tracer,
|
|
3471
|
-
path:
|
|
3554
|
+
path: path9,
|
|
3472
3555
|
// Inherit from parent
|
|
3473
3556
|
provider,
|
|
3474
3557
|
// Inherit from parent
|
|
@@ -4086,8 +4169,8 @@ var init_parseUtil = __esm({
|
|
|
4086
4169
|
init_errors();
|
|
4087
4170
|
init_en();
|
|
4088
4171
|
makeIssue = (params) => {
|
|
4089
|
-
const { data, path:
|
|
4090
|
-
const fullPath = [...
|
|
4172
|
+
const { data, path: path9, errorMaps, issueData } = params;
|
|
4173
|
+
const fullPath = [...path9, ...issueData.path || []];
|
|
4091
4174
|
const fullIssue = {
|
|
4092
4175
|
...issueData,
|
|
4093
4176
|
path: fullPath
|
|
@@ -4395,11 +4478,11 @@ var init_types = __esm({
|
|
|
4395
4478
|
init_parseUtil();
|
|
4396
4479
|
init_util2();
|
|
4397
4480
|
ParseInputLazyPath = class {
|
|
4398
|
-
constructor(parent, value,
|
|
4481
|
+
constructor(parent, value, path9, key) {
|
|
4399
4482
|
this._cachedPath = [];
|
|
4400
4483
|
this.parent = parent;
|
|
4401
4484
|
this.data = value;
|
|
4402
|
-
this._path =
|
|
4485
|
+
this._path = path9;
|
|
4403
4486
|
this._key = key;
|
|
4404
4487
|
}
|
|
4405
4488
|
get path() {
|
|
@@ -8222,15 +8305,15 @@ var init_vercel = __esm({
|
|
|
8222
8305
|
name: "search",
|
|
8223
8306
|
description: searchDescription,
|
|
8224
8307
|
inputSchema: searchSchema,
|
|
8225
|
-
execute: async ({ query: searchQuery, path:
|
|
8308
|
+
execute: async ({ query: searchQuery, path: path9, allow_tests, exact, maxTokens: paramMaxTokens, language }) => {
|
|
8226
8309
|
try {
|
|
8227
8310
|
const effectiveMaxTokens = paramMaxTokens || maxTokens;
|
|
8228
|
-
let searchPath =
|
|
8229
|
-
if ((searchPath === "." || searchPath === "./") && options.
|
|
8311
|
+
let searchPath = path9 || options.cwd || ".";
|
|
8312
|
+
if ((searchPath === "." || searchPath === "./") && options.cwd) {
|
|
8230
8313
|
if (debug) {
|
|
8231
|
-
console.error(`Using
|
|
8314
|
+
console.error(`Using cwd "${options.cwd}" instead of "${searchPath}"`);
|
|
8232
8315
|
}
|
|
8233
|
-
searchPath = options.
|
|
8316
|
+
searchPath = options.cwd;
|
|
8234
8317
|
}
|
|
8235
8318
|
if (debug) {
|
|
8236
8319
|
console.error(`Executing search with query: "${searchQuery}", path: "${searchPath}", exact: ${exact ? "true" : "false"}, language: ${language || "all"}, session: ${sessionId || "none"}`);
|
|
@@ -8238,6 +8321,8 @@ var init_vercel = __esm({
|
|
|
8238
8321
|
const searchOptions = {
|
|
8239
8322
|
query: searchQuery,
|
|
8240
8323
|
path: searchPath,
|
|
8324
|
+
cwd: options.cwd,
|
|
8325
|
+
// Working directory for resolving relative paths
|
|
8241
8326
|
allowTests: allow_tests,
|
|
8242
8327
|
exact,
|
|
8243
8328
|
json: false,
|
|
@@ -8265,14 +8350,14 @@ var init_vercel = __esm({
|
|
|
8265
8350
|
name: "query",
|
|
8266
8351
|
description: queryDescription,
|
|
8267
8352
|
inputSchema: querySchema,
|
|
8268
|
-
execute: async ({ pattern, path:
|
|
8353
|
+
execute: async ({ pattern, path: path9, language, allow_tests }) => {
|
|
8269
8354
|
try {
|
|
8270
|
-
let queryPath =
|
|
8271
|
-
if ((queryPath === "." || queryPath === "./") && options.
|
|
8355
|
+
let queryPath = path9 || options.cwd || ".";
|
|
8356
|
+
if ((queryPath === "." || queryPath === "./") && options.cwd) {
|
|
8272
8357
|
if (debug) {
|
|
8273
|
-
console.error(`Using
|
|
8358
|
+
console.error(`Using cwd "${options.cwd}" instead of "${queryPath}"`);
|
|
8274
8359
|
}
|
|
8275
|
-
queryPath = options.
|
|
8360
|
+
queryPath = options.cwd;
|
|
8276
8361
|
}
|
|
8277
8362
|
if (debug) {
|
|
8278
8363
|
console.error(`Executing query with pattern: "${pattern}", path: "${queryPath}", language: ${language || "auto"}`);
|
|
@@ -8280,6 +8365,8 @@ var init_vercel = __esm({
|
|
|
8280
8365
|
const results = await query({
|
|
8281
8366
|
pattern,
|
|
8282
8367
|
path: queryPath,
|
|
8368
|
+
cwd: options.cwd,
|
|
8369
|
+
// Working directory for resolving relative paths
|
|
8283
8370
|
language,
|
|
8284
8371
|
allow_tests,
|
|
8285
8372
|
json: false
|
|
@@ -8300,22 +8387,16 @@ var init_vercel = __esm({
|
|
|
8300
8387
|
inputSchema: extractSchema,
|
|
8301
8388
|
execute: async ({ targets, input_content, line, end_line, allow_tests, context_lines, format }) => {
|
|
8302
8389
|
try {
|
|
8303
|
-
|
|
8304
|
-
if ((extractPath === "." || extractPath === "./") && options.defaultPath) {
|
|
8305
|
-
if (debug) {
|
|
8306
|
-
console.error(`Using default path "${options.defaultPath}" instead of "${extractPath}"`);
|
|
8307
|
-
}
|
|
8308
|
-
extractPath = options.defaultPath;
|
|
8309
|
-
}
|
|
8390
|
+
const effectiveCwd = options.cwd || ".";
|
|
8310
8391
|
if (debug) {
|
|
8311
8392
|
if (targets) {
|
|
8312
|
-
console.error(`Executing extract with targets: "${targets}",
|
|
8393
|
+
console.error(`Executing extract with targets: "${targets}", cwd: "${effectiveCwd}", context lines: ${context_lines || 10}`);
|
|
8313
8394
|
} else if (input_content) {
|
|
8314
|
-
console.error(`Executing extract with input content,
|
|
8395
|
+
console.error(`Executing extract with input content, cwd: "${effectiveCwd}", context lines: ${context_lines || 10}`);
|
|
8315
8396
|
}
|
|
8316
8397
|
}
|
|
8317
8398
|
let tempFilePath = null;
|
|
8318
|
-
let extractOptions = {
|
|
8399
|
+
let extractOptions = { cwd: effectiveCwd };
|
|
8319
8400
|
if (input_content) {
|
|
8320
8401
|
const { writeFileSync: writeFileSync2, unlinkSync } = await import("fs");
|
|
8321
8402
|
const { join: join3 } = await import("path");
|
|
@@ -8332,6 +8413,7 @@ var init_vercel = __esm({
|
|
|
8332
8413
|
}
|
|
8333
8414
|
extractOptions = {
|
|
8334
8415
|
inputFile: tempFilePath,
|
|
8416
|
+
cwd: effectiveCwd,
|
|
8335
8417
|
allowTests: allow_tests,
|
|
8336
8418
|
contextLines: context_lines,
|
|
8337
8419
|
format: effectiveFormat
|
|
@@ -8344,6 +8426,7 @@ var init_vercel = __esm({
|
|
|
8344
8426
|
}
|
|
8345
8427
|
extractOptions = {
|
|
8346
8428
|
files,
|
|
8429
|
+
cwd: effectiveCwd,
|
|
8347
8430
|
allowTests: allow_tests,
|
|
8348
8431
|
contextLines: context_lines,
|
|
8349
8432
|
format: effectiveFormat
|
|
@@ -8372,12 +8455,12 @@ var init_vercel = __esm({
|
|
|
8372
8455
|
});
|
|
8373
8456
|
};
|
|
8374
8457
|
delegateTool = (options = {}) => {
|
|
8375
|
-
const { debug = false, timeout = 300,
|
|
8458
|
+
const { debug = false, timeout = 300, cwd, allowedFolders } = options;
|
|
8376
8459
|
return tool({
|
|
8377
8460
|
name: "delegate",
|
|
8378
8461
|
description: delegateDescription,
|
|
8379
8462
|
inputSchema: delegateSchema,
|
|
8380
|
-
execute: async ({ task, currentIteration, maxIterations, parentSessionId, path:
|
|
8463
|
+
execute: async ({ task, currentIteration, maxIterations, parentSessionId, path: path9, provider, model, tracer }) => {
|
|
8381
8464
|
if (!task || typeof task !== "string") {
|
|
8382
8465
|
throw new Error("Task parameter is required and must be a non-empty string");
|
|
8383
8466
|
}
|
|
@@ -8393,7 +8476,7 @@ var init_vercel = __esm({
|
|
|
8393
8476
|
if (parentSessionId !== void 0 && parentSessionId !== null && typeof parentSessionId !== "string") {
|
|
8394
8477
|
throw new TypeError("parentSessionId must be a string, null, or undefined");
|
|
8395
8478
|
}
|
|
8396
|
-
if (
|
|
8479
|
+
if (path9 !== void 0 && path9 !== null && typeof path9 !== "string") {
|
|
8397
8480
|
throw new TypeError("path must be a string, null, or undefined");
|
|
8398
8481
|
}
|
|
8399
8482
|
if (provider !== void 0 && provider !== null && typeof provider !== "string") {
|
|
@@ -8402,13 +8485,13 @@ var init_vercel = __esm({
|
|
|
8402
8485
|
if (model !== void 0 && model !== null && typeof model !== "string") {
|
|
8403
8486
|
throw new TypeError("model must be a string, null, or undefined");
|
|
8404
8487
|
}
|
|
8405
|
-
const effectivePath =
|
|
8488
|
+
const effectivePath = path9 || cwd || allowedFolders && allowedFolders[0];
|
|
8406
8489
|
if (debug) {
|
|
8407
8490
|
console.error(`Executing delegate with task: "${task.substring(0, 100)}${task.length > 100 ? "..." : ""}"`);
|
|
8408
8491
|
if (parentSessionId) {
|
|
8409
8492
|
console.error(`Parent session: ${parentSessionId}`);
|
|
8410
8493
|
}
|
|
8411
|
-
if (effectivePath && effectivePath !==
|
|
8494
|
+
if (effectivePath && effectivePath !== path9) {
|
|
8412
8495
|
console.error(`Using inherited path: ${effectivePath}`);
|
|
8413
8496
|
}
|
|
8414
8497
|
}
|
|
@@ -9514,7 +9597,7 @@ var init_bash = __esm({
|
|
|
9514
9597
|
const {
|
|
9515
9598
|
bashConfig = {},
|
|
9516
9599
|
debug = false,
|
|
9517
|
-
|
|
9600
|
+
cwd,
|
|
9518
9601
|
allowedFolders = []
|
|
9519
9602
|
} = options;
|
|
9520
9603
|
const permissionChecker = new BashPermissionChecker({
|
|
@@ -9528,8 +9611,8 @@ var init_bash = __esm({
|
|
|
9528
9611
|
if (bashConfig.workingDirectory) {
|
|
9529
9612
|
return bashConfig.workingDirectory;
|
|
9530
9613
|
}
|
|
9531
|
-
if (
|
|
9532
|
-
return
|
|
9614
|
+
if (cwd) {
|
|
9615
|
+
return cwd;
|
|
9533
9616
|
}
|
|
9534
9617
|
if (allowedFolders && allowedFolders.length > 0) {
|
|
9535
9618
|
return allowedFolders[0];
|
|
@@ -9674,7 +9757,7 @@ Command failed with exit code ${result.exitCode}`;
|
|
|
9674
9757
|
|
|
9675
9758
|
// src/tools/edit.js
|
|
9676
9759
|
import { tool as tool3 } from "ai";
|
|
9677
|
-
import { promises as
|
|
9760
|
+
import { promises as fs6 } from "fs";
|
|
9678
9761
|
import { dirname, resolve as resolve3, isAbsolute, sep } from "path";
|
|
9679
9762
|
import { existsSync as existsSync2 } from "fs";
|
|
9680
9763
|
function isPathAllowed(filePath, allowedFolders) {
|
|
@@ -9693,7 +9776,7 @@ function parseFileToolOptions(options = {}) {
|
|
|
9693
9776
|
return {
|
|
9694
9777
|
debug: options.debug || false,
|
|
9695
9778
|
allowedFolders: options.allowedFolders || [],
|
|
9696
|
-
|
|
9779
|
+
cwd: options.cwd
|
|
9697
9780
|
};
|
|
9698
9781
|
}
|
|
9699
9782
|
var editTool, createTool, editDescription, createDescription, editToolDefinition, createToolDefinition;
|
|
@@ -9701,7 +9784,7 @@ var init_edit = __esm({
|
|
|
9701
9784
|
"src/tools/edit.js"() {
|
|
9702
9785
|
"use strict";
|
|
9703
9786
|
editTool = (options = {}) => {
|
|
9704
|
-
const { debug, allowedFolders,
|
|
9787
|
+
const { debug, allowedFolders, cwd } = parseFileToolOptions(options);
|
|
9705
9788
|
return tool3({
|
|
9706
9789
|
name: "edit",
|
|
9707
9790
|
description: `Edit files using exact string replacement (Claude Code style).
|
|
@@ -9752,7 +9835,7 @@ Important:
|
|
|
9752
9835
|
if (new_string === void 0 || new_string === null || typeof new_string !== "string") {
|
|
9753
9836
|
return `Error editing file: Invalid new_string - must be a string`;
|
|
9754
9837
|
}
|
|
9755
|
-
const resolvedPath = isAbsolute(file_path) ? file_path : resolve3(
|
|
9838
|
+
const resolvedPath = isAbsolute(file_path) ? file_path : resolve3(cwd || process.cwd(), file_path);
|
|
9756
9839
|
if (debug) {
|
|
9757
9840
|
console.error(`[Edit] Attempting to edit file: ${resolvedPath}`);
|
|
9758
9841
|
}
|
|
@@ -9762,7 +9845,7 @@ Important:
|
|
|
9762
9845
|
if (!existsSync2(resolvedPath)) {
|
|
9763
9846
|
return `Error editing file: File not found - ${file_path}`;
|
|
9764
9847
|
}
|
|
9765
|
-
const content = await
|
|
9848
|
+
const content = await fs6.readFile(resolvedPath, "utf-8");
|
|
9766
9849
|
if (!content.includes(old_string)) {
|
|
9767
9850
|
return `Error editing file: String not found - the specified old_string was not found in ${file_path}`;
|
|
9768
9851
|
}
|
|
@@ -9779,7 +9862,7 @@ Important:
|
|
|
9779
9862
|
if (newContent === content) {
|
|
9780
9863
|
return `Error editing file: No changes made - old_string and new_string might be the same`;
|
|
9781
9864
|
}
|
|
9782
|
-
await
|
|
9865
|
+
await fs6.writeFile(resolvedPath, newContent, "utf-8");
|
|
9783
9866
|
const replacedCount = replace_all ? occurrences : 1;
|
|
9784
9867
|
if (debug) {
|
|
9785
9868
|
console.error(`[Edit] Successfully edited ${resolvedPath}, replaced ${replacedCount} occurrence(s)`);
|
|
@@ -9793,7 +9876,7 @@ Important:
|
|
|
9793
9876
|
});
|
|
9794
9877
|
};
|
|
9795
9878
|
createTool = (options = {}) => {
|
|
9796
|
-
const { debug, allowedFolders,
|
|
9879
|
+
const { debug, allowedFolders, cwd } = parseFileToolOptions(options);
|
|
9797
9880
|
return tool3({
|
|
9798
9881
|
name: "create",
|
|
9799
9882
|
description: `Create new files with specified content.
|
|
@@ -9836,7 +9919,7 @@ Important:
|
|
|
9836
9919
|
if (content === void 0 || content === null || typeof content !== "string") {
|
|
9837
9920
|
return `Error creating file: Invalid content - must be a string`;
|
|
9838
9921
|
}
|
|
9839
|
-
const resolvedPath = isAbsolute(file_path) ? file_path : resolve3(
|
|
9922
|
+
const resolvedPath = isAbsolute(file_path) ? file_path : resolve3(cwd || process.cwd(), file_path);
|
|
9840
9923
|
if (debug) {
|
|
9841
9924
|
console.error(`[Create] Attempting to create file: ${resolvedPath}`);
|
|
9842
9925
|
}
|
|
@@ -9847,8 +9930,8 @@ Important:
|
|
|
9847
9930
|
return `Error creating file: File already exists - ${file_path}. Use overwrite: true to replace it.`;
|
|
9848
9931
|
}
|
|
9849
9932
|
const dir = dirname(resolvedPath);
|
|
9850
|
-
await
|
|
9851
|
-
await
|
|
9933
|
+
await fs6.mkdir(dir, { recursive: true });
|
|
9934
|
+
await fs6.writeFile(resolvedPath, content, "utf-8");
|
|
9852
9935
|
const action = existsSync2(resolvedPath) && overwrite ? "overwrote" : "created";
|
|
9853
9936
|
const bytes = Buffer.byteLength(content, "utf-8");
|
|
9854
9937
|
if (debug) {
|
|
@@ -10118,8 +10201,8 @@ var init_tools = __esm({
|
|
|
10118
10201
|
});
|
|
10119
10202
|
|
|
10120
10203
|
// src/utils/file-lister.js
|
|
10121
|
-
import
|
|
10122
|
-
import
|
|
10204
|
+
import fs7 from "fs";
|
|
10205
|
+
import path5 from "path";
|
|
10123
10206
|
import { promisify as promisify6 } from "util";
|
|
10124
10207
|
import { exec as exec4 } from "child_process";
|
|
10125
10208
|
async function listFilesByLevel(options) {
|
|
@@ -10128,10 +10211,10 @@ async function listFilesByLevel(options) {
|
|
|
10128
10211
|
maxFiles = 100,
|
|
10129
10212
|
respectGitignore = true
|
|
10130
10213
|
} = options;
|
|
10131
|
-
if (!
|
|
10214
|
+
if (!fs7.existsSync(directory)) {
|
|
10132
10215
|
throw new Error(`Directory does not exist: ${directory}`);
|
|
10133
10216
|
}
|
|
10134
|
-
const gitDirExists =
|
|
10217
|
+
const gitDirExists = fs7.existsSync(path5.join(directory, ".git"));
|
|
10135
10218
|
if (gitDirExists && respectGitignore) {
|
|
10136
10219
|
try {
|
|
10137
10220
|
return await listFilesUsingGit(directory, maxFiles);
|
|
@@ -10146,8 +10229,8 @@ async function listFilesUsingGit(directory, maxFiles) {
|
|
|
10146
10229
|
const { stdout } = await execAsync3("git ls-files", { cwd: directory });
|
|
10147
10230
|
const files = stdout.split("\n").filter(Boolean);
|
|
10148
10231
|
const sortedFiles = files.sort((a, b) => {
|
|
10149
|
-
const depthA = a.split(
|
|
10150
|
-
const depthB = b.split(
|
|
10232
|
+
const depthA = a.split(path5.sep).length;
|
|
10233
|
+
const depthB = b.split(path5.sep).length;
|
|
10151
10234
|
return depthA - depthB;
|
|
10152
10235
|
});
|
|
10153
10236
|
return sortedFiles.slice(0, maxFiles);
|
|
@@ -10162,19 +10245,25 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
|
|
|
10162
10245
|
while (queue.length > 0 && result.length < maxFiles) {
|
|
10163
10246
|
const { dir, level } = queue.shift();
|
|
10164
10247
|
try {
|
|
10165
|
-
const entries =
|
|
10166
|
-
const files = entries.filter((entry) =>
|
|
10248
|
+
const entries = fs7.readdirSync(dir, { withFileTypes: true });
|
|
10249
|
+
const files = entries.filter((entry) => {
|
|
10250
|
+
const fullPath = path5.join(dir, entry.name);
|
|
10251
|
+
return getEntryTypeSync(entry, fullPath).isFile;
|
|
10252
|
+
});
|
|
10167
10253
|
for (const file of files) {
|
|
10168
10254
|
if (result.length >= maxFiles) break;
|
|
10169
|
-
const filePath =
|
|
10170
|
-
const relativePath =
|
|
10255
|
+
const filePath = path5.join(dir, file.name);
|
|
10256
|
+
const relativePath = path5.relative(directory, filePath);
|
|
10171
10257
|
if (shouldIgnore(relativePath, ignorePatterns)) continue;
|
|
10172
10258
|
result.push(relativePath);
|
|
10173
10259
|
}
|
|
10174
|
-
const dirs = entries.filter((entry) =>
|
|
10260
|
+
const dirs = entries.filter((entry) => {
|
|
10261
|
+
const fullPath = path5.join(dir, entry.name);
|
|
10262
|
+
return getEntryTypeSync(entry, fullPath).isDirectory;
|
|
10263
|
+
});
|
|
10175
10264
|
for (const subdir of dirs) {
|
|
10176
|
-
const subdirPath =
|
|
10177
|
-
const relativeSubdirPath =
|
|
10265
|
+
const subdirPath = path5.join(dir, subdir.name);
|
|
10266
|
+
const relativeSubdirPath = path5.relative(directory, subdirPath);
|
|
10178
10267
|
if (shouldIgnore(relativeSubdirPath, ignorePatterns)) continue;
|
|
10179
10268
|
if (subdir.name === "node_modules" || subdir.name === ".git") continue;
|
|
10180
10269
|
queue.push({ dir: subdirPath, level: level + 1 });
|
|
@@ -10186,12 +10275,12 @@ async function listFilesByLevelManually(directory, maxFiles, respectGitignore) {
|
|
|
10186
10275
|
return result;
|
|
10187
10276
|
}
|
|
10188
10277
|
function loadGitignorePatterns(directory) {
|
|
10189
|
-
const gitignorePath =
|
|
10190
|
-
if (!
|
|
10278
|
+
const gitignorePath = path5.join(directory, ".gitignore");
|
|
10279
|
+
if (!fs7.existsSync(gitignorePath)) {
|
|
10191
10280
|
return [];
|
|
10192
10281
|
}
|
|
10193
10282
|
try {
|
|
10194
|
-
const content =
|
|
10283
|
+
const content = fs7.readFileSync(gitignorePath, "utf8");
|
|
10195
10284
|
return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
10196
10285
|
} catch (error) {
|
|
10197
10286
|
console.error(`Warning: Could not read .gitignore: ${error.message}`);
|
|
@@ -10213,6 +10302,7 @@ var execAsync3;
|
|
|
10213
10302
|
var init_file_lister = __esm({
|
|
10214
10303
|
"src/utils/file-lister.js"() {
|
|
10215
10304
|
"use strict";
|
|
10305
|
+
init_symlink_utils();
|
|
10216
10306
|
execAsync3 = promisify6(exec4);
|
|
10217
10307
|
}
|
|
10218
10308
|
});
|
|
@@ -11287,7 +11377,7 @@ var init_escape = __esm({
|
|
|
11287
11377
|
});
|
|
11288
11378
|
|
|
11289
11379
|
// node_modules/minimatch/dist/esm/index.js
|
|
11290
|
-
var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform,
|
|
11380
|
+
var import_brace_expansion, minimatch, starDotExtRE, starDotExtTest, starDotExtTestDot, starDotExtTestNocase, starDotExtTestNocaseDot, starDotStarRE, starDotStarTest, starDotStarTestDot, dotStarRE, dotStarTest, starRE, starTest, starTestDot, qmarksRE, qmarksTestNocase, qmarksTestNocaseDot, qmarksTestDot, qmarksTest, qmarksTestNoExt, qmarksTestNoExtDot, defaultPlatform, path6, sep2, GLOBSTAR, qmark2, star2, twoStarDot, twoStarNoDot, filter, ext, defaults, braceExpand, makeRe, match, globMagic, regExpEscape2, Minimatch;
|
|
11291
11381
|
var init_esm = __esm({
|
|
11292
11382
|
"node_modules/minimatch/dist/esm/index.js"() {
|
|
11293
11383
|
import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
|
@@ -11356,11 +11446,11 @@ var init_esm = __esm({
|
|
|
11356
11446
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
11357
11447
|
};
|
|
11358
11448
|
defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
11359
|
-
|
|
11449
|
+
path6 = {
|
|
11360
11450
|
win32: { sep: "\\" },
|
|
11361
11451
|
posix: { sep: "/" }
|
|
11362
11452
|
};
|
|
11363
|
-
sep2 = defaultPlatform === "win32" ?
|
|
11453
|
+
sep2 = defaultPlatform === "win32" ? path6.win32.sep : path6.posix.sep;
|
|
11364
11454
|
minimatch.sep = sep2;
|
|
11365
11455
|
GLOBSTAR = Symbol("globstar **");
|
|
11366
11456
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
@@ -14547,12 +14637,12 @@ var init_esm4 = __esm({
|
|
|
14547
14637
|
/**
|
|
14548
14638
|
* Get the Path object referenced by the string path, resolved from this Path
|
|
14549
14639
|
*/
|
|
14550
|
-
resolve(
|
|
14551
|
-
if (!
|
|
14640
|
+
resolve(path9) {
|
|
14641
|
+
if (!path9) {
|
|
14552
14642
|
return this;
|
|
14553
14643
|
}
|
|
14554
|
-
const rootPath = this.getRootString(
|
|
14555
|
-
const dir =
|
|
14644
|
+
const rootPath = this.getRootString(path9);
|
|
14645
|
+
const dir = path9.substring(rootPath.length);
|
|
14556
14646
|
const dirParts = dir.split(this.splitSep);
|
|
14557
14647
|
const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
|
|
14558
14648
|
return result;
|
|
@@ -15304,8 +15394,8 @@ var init_esm4 = __esm({
|
|
|
15304
15394
|
/**
|
|
15305
15395
|
* @internal
|
|
15306
15396
|
*/
|
|
15307
|
-
getRootString(
|
|
15308
|
-
return win32.parse(
|
|
15397
|
+
getRootString(path9) {
|
|
15398
|
+
return win32.parse(path9).root;
|
|
15309
15399
|
}
|
|
15310
15400
|
/**
|
|
15311
15401
|
* @internal
|
|
@@ -15351,8 +15441,8 @@ var init_esm4 = __esm({
|
|
|
15351
15441
|
/**
|
|
15352
15442
|
* @internal
|
|
15353
15443
|
*/
|
|
15354
|
-
getRootString(
|
|
15355
|
-
return
|
|
15444
|
+
getRootString(path9) {
|
|
15445
|
+
return path9.startsWith("/") ? "/" : "";
|
|
15356
15446
|
}
|
|
15357
15447
|
/**
|
|
15358
15448
|
* @internal
|
|
@@ -15401,8 +15491,8 @@ var init_esm4 = __esm({
|
|
|
15401
15491
|
*
|
|
15402
15492
|
* @internal
|
|
15403
15493
|
*/
|
|
15404
|
-
constructor(cwd = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs:
|
|
15405
|
-
this.#fs = fsFromOption(
|
|
15494
|
+
constructor(cwd = process.cwd(), pathImpl, sep4, { nocase, childrenCacheSize = 16 * 1024, fs: fs10 = defaultFS } = {}) {
|
|
15495
|
+
this.#fs = fsFromOption(fs10);
|
|
15406
15496
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
15407
15497
|
cwd = fileURLToPath4(cwd);
|
|
15408
15498
|
}
|
|
@@ -15441,11 +15531,11 @@ var init_esm4 = __esm({
|
|
|
15441
15531
|
/**
|
|
15442
15532
|
* Get the depth of a provided path, string, or the cwd
|
|
15443
15533
|
*/
|
|
15444
|
-
depth(
|
|
15445
|
-
if (typeof
|
|
15446
|
-
|
|
15534
|
+
depth(path9 = this.cwd) {
|
|
15535
|
+
if (typeof path9 === "string") {
|
|
15536
|
+
path9 = this.cwd.resolve(path9);
|
|
15447
15537
|
}
|
|
15448
|
-
return
|
|
15538
|
+
return path9.depth();
|
|
15449
15539
|
}
|
|
15450
15540
|
/**
|
|
15451
15541
|
* Return the cache of child entries. Exposed so subclasses can create
|
|
@@ -15932,9 +16022,9 @@ var init_esm4 = __esm({
|
|
|
15932
16022
|
process2();
|
|
15933
16023
|
return results;
|
|
15934
16024
|
}
|
|
15935
|
-
chdir(
|
|
16025
|
+
chdir(path9 = this.cwd) {
|
|
15936
16026
|
const oldCwd = this.cwd;
|
|
15937
|
-
this.cwd = typeof
|
|
16027
|
+
this.cwd = typeof path9 === "string" ? this.cwd.resolve(path9) : path9;
|
|
15938
16028
|
this.cwd[setAsCwd](oldCwd);
|
|
15939
16029
|
}
|
|
15940
16030
|
};
|
|
@@ -15960,8 +16050,8 @@ var init_esm4 = __esm({
|
|
|
15960
16050
|
/**
|
|
15961
16051
|
* @internal
|
|
15962
16052
|
*/
|
|
15963
|
-
newRoot(
|
|
15964
|
-
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
16053
|
+
newRoot(fs10) {
|
|
16054
|
+
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs10 });
|
|
15965
16055
|
}
|
|
15966
16056
|
/**
|
|
15967
16057
|
* Return true if the provided path string is an absolute path
|
|
@@ -15989,8 +16079,8 @@ var init_esm4 = __esm({
|
|
|
15989
16079
|
/**
|
|
15990
16080
|
* @internal
|
|
15991
16081
|
*/
|
|
15992
|
-
newRoot(
|
|
15993
|
-
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs:
|
|
16082
|
+
newRoot(fs10) {
|
|
16083
|
+
return new PathPosix(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), { fs: fs10 });
|
|
15994
16084
|
}
|
|
15995
16085
|
/**
|
|
15996
16086
|
* Return true if the provided path string is an absolute path
|
|
@@ -16309,8 +16399,8 @@ var init_processor = __esm({
|
|
|
16309
16399
|
}
|
|
16310
16400
|
// match, absolute, ifdir
|
|
16311
16401
|
entries() {
|
|
16312
|
-
return [...this.store.entries()].map(([
|
|
16313
|
-
|
|
16402
|
+
return [...this.store.entries()].map(([path9, n]) => [
|
|
16403
|
+
path9,
|
|
16314
16404
|
!!(n & 2),
|
|
16315
16405
|
!!(n & 1)
|
|
16316
16406
|
]);
|
|
@@ -16523,9 +16613,9 @@ var init_walker = __esm({
|
|
|
16523
16613
|
signal;
|
|
16524
16614
|
maxDepth;
|
|
16525
16615
|
includeChildMatches;
|
|
16526
|
-
constructor(patterns,
|
|
16616
|
+
constructor(patterns, path9, opts) {
|
|
16527
16617
|
this.patterns = patterns;
|
|
16528
|
-
this.path =
|
|
16618
|
+
this.path = path9;
|
|
16529
16619
|
this.opts = opts;
|
|
16530
16620
|
this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
|
|
16531
16621
|
this.includeChildMatches = opts.includeChildMatches !== false;
|
|
@@ -16544,11 +16634,11 @@ var init_walker = __esm({
|
|
|
16544
16634
|
});
|
|
16545
16635
|
}
|
|
16546
16636
|
}
|
|
16547
|
-
#ignored(
|
|
16548
|
-
return this.seen.has(
|
|
16637
|
+
#ignored(path9) {
|
|
16638
|
+
return this.seen.has(path9) || !!this.#ignore?.ignored?.(path9);
|
|
16549
16639
|
}
|
|
16550
|
-
#childrenIgnored(
|
|
16551
|
-
return !!this.#ignore?.childrenIgnored?.(
|
|
16640
|
+
#childrenIgnored(path9) {
|
|
16641
|
+
return !!this.#ignore?.childrenIgnored?.(path9);
|
|
16552
16642
|
}
|
|
16553
16643
|
// backpressure mechanism
|
|
16554
16644
|
pause() {
|
|
@@ -16763,8 +16853,8 @@ var init_walker = __esm({
|
|
|
16763
16853
|
};
|
|
16764
16854
|
GlobWalker = class extends GlobUtil {
|
|
16765
16855
|
matches = /* @__PURE__ */ new Set();
|
|
16766
|
-
constructor(patterns,
|
|
16767
|
-
super(patterns,
|
|
16856
|
+
constructor(patterns, path9, opts) {
|
|
16857
|
+
super(patterns, path9, opts);
|
|
16768
16858
|
}
|
|
16769
16859
|
matchEmit(e) {
|
|
16770
16860
|
this.matches.add(e);
|
|
@@ -16801,8 +16891,8 @@ var init_walker = __esm({
|
|
|
16801
16891
|
};
|
|
16802
16892
|
GlobStream = class extends GlobUtil {
|
|
16803
16893
|
results;
|
|
16804
|
-
constructor(patterns,
|
|
16805
|
-
super(patterns,
|
|
16894
|
+
constructor(patterns, path9, opts) {
|
|
16895
|
+
super(patterns, path9, opts);
|
|
16806
16896
|
this.results = new Minipass({
|
|
16807
16897
|
signal: this.signal,
|
|
16808
16898
|
objectMode: true
|
|
@@ -17130,9 +17220,9 @@ import { exec as exec5 } from "child_process";
|
|
|
17130
17220
|
import { promisify as promisify7 } from "util";
|
|
17131
17221
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
17132
17222
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
17133
|
-
import
|
|
17134
|
-
import { promises as
|
|
17135
|
-
import
|
|
17223
|
+
import fs8 from "fs";
|
|
17224
|
+
import { promises as fsPromises2 } from "fs";
|
|
17225
|
+
import path7 from "path";
|
|
17136
17226
|
function isSessionCancelled(sessionId) {
|
|
17137
17227
|
return activeToolExecutions.get(sessionId)?.cancelled || false;
|
|
17138
17228
|
}
|
|
@@ -17212,6 +17302,7 @@ var init_probeTool = __esm({
|
|
|
17212
17302
|
"use strict";
|
|
17213
17303
|
init_index();
|
|
17214
17304
|
init_esm5();
|
|
17305
|
+
init_symlink_utils();
|
|
17215
17306
|
toolCallEmitter = new EventEmitter2();
|
|
17216
17307
|
activeToolExecutions = /* @__PURE__ */ new Map();
|
|
17217
17308
|
wrapToolWithEmitter = (tool4, toolName, baseExecute) => {
|
|
@@ -17298,17 +17389,17 @@ var init_probeTool = __esm({
|
|
|
17298
17389
|
execute: async (params) => {
|
|
17299
17390
|
const { directory = ".", workingDirectory } = params;
|
|
17300
17391
|
const baseCwd = workingDirectory || process.cwd();
|
|
17301
|
-
const secureBaseDir =
|
|
17392
|
+
const secureBaseDir = path7.resolve(baseCwd);
|
|
17302
17393
|
const isDependencyPath = directory.startsWith("/dep/") || directory.startsWith("go:") || directory.startsWith("js:") || directory.startsWith("rust:");
|
|
17303
17394
|
let targetDir;
|
|
17304
|
-
if (
|
|
17305
|
-
targetDir =
|
|
17306
|
-
if (!isDependencyPath && !targetDir.startsWith(secureBaseDir +
|
|
17395
|
+
if (path7.isAbsolute(directory)) {
|
|
17396
|
+
targetDir = path7.resolve(directory);
|
|
17397
|
+
if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
|
|
17307
17398
|
throw new Error(`Path traversal attempt detected. Cannot access directory outside workspace: ${directory}`);
|
|
17308
17399
|
}
|
|
17309
17400
|
} else {
|
|
17310
|
-
targetDir =
|
|
17311
|
-
if (!isDependencyPath && !targetDir.startsWith(secureBaseDir +
|
|
17401
|
+
targetDir = path7.resolve(secureBaseDir, directory);
|
|
17402
|
+
if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
|
|
17312
17403
|
throw new Error(`Path traversal attempt detected. Access denied: ${directory}`);
|
|
17313
17404
|
}
|
|
17314
17405
|
}
|
|
@@ -17317,7 +17408,7 @@ var init_probeTool = __esm({
|
|
|
17317
17408
|
console.log(`[DEBUG] Listing files in directory: ${targetDir}`);
|
|
17318
17409
|
}
|
|
17319
17410
|
try {
|
|
17320
|
-
const files = await
|
|
17411
|
+
const files = await fsPromises2.readdir(targetDir, { withFileTypes: true });
|
|
17321
17412
|
const formatSize = (size) => {
|
|
17322
17413
|
if (size < 1024) return `${size}B`;
|
|
17323
17414
|
if (size < 1024 * 1024) return `${(size / 1024).toFixed(1)}K`;
|
|
@@ -17325,21 +17416,12 @@ var init_probeTool = __esm({
|
|
|
17325
17416
|
return `${(size / (1024 * 1024 * 1024)).toFixed(1)}G`;
|
|
17326
17417
|
};
|
|
17327
17418
|
const entries = await Promise.all(files.map(async (file) => {
|
|
17328
|
-
const
|
|
17329
|
-
const
|
|
17330
|
-
let size = 0;
|
|
17331
|
-
try {
|
|
17332
|
-
const stats = await fsPromises.stat(fullPath);
|
|
17333
|
-
size = stats.size;
|
|
17334
|
-
} catch (statError) {
|
|
17335
|
-
if (debug) {
|
|
17336
|
-
console.log(`[DEBUG] Could not stat file ${file.name}:`, statError.message);
|
|
17337
|
-
}
|
|
17338
|
-
}
|
|
17419
|
+
const fullPath = path7.join(targetDir, file.name);
|
|
17420
|
+
const entryType = await getEntryType(file, fullPath);
|
|
17339
17421
|
return {
|
|
17340
17422
|
name: file.name,
|
|
17341
|
-
isDirectory,
|
|
17342
|
-
size
|
|
17423
|
+
isDirectory: entryType.isDirectory,
|
|
17424
|
+
size: entryType.size
|
|
17343
17425
|
};
|
|
17344
17426
|
}));
|
|
17345
17427
|
entries.sort((a, b) => {
|
|
@@ -17371,17 +17453,17 @@ var init_probeTool = __esm({
|
|
|
17371
17453
|
throw new Error("Pattern is required for file search");
|
|
17372
17454
|
}
|
|
17373
17455
|
const baseCwd = workingDirectory || process.cwd();
|
|
17374
|
-
const secureBaseDir =
|
|
17456
|
+
const secureBaseDir = path7.resolve(baseCwd);
|
|
17375
17457
|
const isDependencyPath = directory.startsWith("/dep/") || directory.startsWith("go:") || directory.startsWith("js:") || directory.startsWith("rust:");
|
|
17376
17458
|
let targetDir;
|
|
17377
|
-
if (
|
|
17378
|
-
targetDir =
|
|
17379
|
-
if (!isDependencyPath && !targetDir.startsWith(secureBaseDir +
|
|
17459
|
+
if (path7.isAbsolute(directory)) {
|
|
17460
|
+
targetDir = path7.resolve(directory);
|
|
17461
|
+
if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
|
|
17380
17462
|
throw new Error(`Path traversal attempt detected. Cannot access directory outside workspace: ${directory}`);
|
|
17381
17463
|
}
|
|
17382
17464
|
} else {
|
|
17383
|
-
targetDir =
|
|
17384
|
-
if (!isDependencyPath && !targetDir.startsWith(secureBaseDir +
|
|
17465
|
+
targetDir = path7.resolve(secureBaseDir, directory);
|
|
17466
|
+
if (!isDependencyPath && !targetDir.startsWith(secureBaseDir + path7.sep) && targetDir !== secureBaseDir) {
|
|
17385
17467
|
throw new Error(`Path traversal attempt detected. Access denied: ${directory}`);
|
|
17386
17468
|
}
|
|
17387
17469
|
}
|
|
@@ -19508,11 +19590,11 @@ var init_toKey = __esm({
|
|
|
19508
19590
|
});
|
|
19509
19591
|
|
|
19510
19592
|
// node_modules/lodash-es/_baseGet.js
|
|
19511
|
-
function baseGet(object,
|
|
19512
|
-
|
|
19513
|
-
var index = 0, length =
|
|
19593
|
+
function baseGet(object, path9) {
|
|
19594
|
+
path9 = castPath_default(path9, object);
|
|
19595
|
+
var index = 0, length = path9.length;
|
|
19514
19596
|
while (object != null && index < length) {
|
|
19515
|
-
object = object[toKey_default(
|
|
19597
|
+
object = object[toKey_default(path9[index++])];
|
|
19516
19598
|
}
|
|
19517
19599
|
return index && index == length ? object : void 0;
|
|
19518
19600
|
}
|
|
@@ -19526,8 +19608,8 @@ var init_baseGet = __esm({
|
|
|
19526
19608
|
});
|
|
19527
19609
|
|
|
19528
19610
|
// node_modules/lodash-es/get.js
|
|
19529
|
-
function get(object,
|
|
19530
|
-
var result = object == null ? void 0 : baseGet_default(object,
|
|
19611
|
+
function get(object, path9, defaultValue) {
|
|
19612
|
+
var result = object == null ? void 0 : baseGet_default(object, path9);
|
|
19531
19613
|
return result === void 0 ? defaultValue : result;
|
|
19532
19614
|
}
|
|
19533
19615
|
var get_default;
|
|
@@ -20890,11 +20972,11 @@ var init_baseHasIn = __esm({
|
|
|
20890
20972
|
});
|
|
20891
20973
|
|
|
20892
20974
|
// node_modules/lodash-es/_hasPath.js
|
|
20893
|
-
function hasPath(object,
|
|
20894
|
-
|
|
20895
|
-
var index = -1, length =
|
|
20975
|
+
function hasPath(object, path9, hasFunc) {
|
|
20976
|
+
path9 = castPath_default(path9, object);
|
|
20977
|
+
var index = -1, length = path9.length, result = false;
|
|
20896
20978
|
while (++index < length) {
|
|
20897
|
-
var key = toKey_default(
|
|
20979
|
+
var key = toKey_default(path9[index]);
|
|
20898
20980
|
if (!(result = object != null && hasFunc(object, key))) {
|
|
20899
20981
|
break;
|
|
20900
20982
|
}
|
|
@@ -20920,8 +21002,8 @@ var init_hasPath = __esm({
|
|
|
20920
21002
|
});
|
|
20921
21003
|
|
|
20922
21004
|
// node_modules/lodash-es/hasIn.js
|
|
20923
|
-
function hasIn(object,
|
|
20924
|
-
return object != null && hasPath_default(object,
|
|
21005
|
+
function hasIn(object, path9) {
|
|
21006
|
+
return object != null && hasPath_default(object, path9, baseHasIn_default);
|
|
20925
21007
|
}
|
|
20926
21008
|
var hasIn_default;
|
|
20927
21009
|
var init_hasIn = __esm({
|
|
@@ -20933,13 +21015,13 @@ var init_hasIn = __esm({
|
|
|
20933
21015
|
});
|
|
20934
21016
|
|
|
20935
21017
|
// node_modules/lodash-es/_baseMatchesProperty.js
|
|
20936
|
-
function baseMatchesProperty(
|
|
20937
|
-
if (isKey_default(
|
|
20938
|
-
return matchesStrictComparable_default(toKey_default(
|
|
21018
|
+
function baseMatchesProperty(path9, srcValue) {
|
|
21019
|
+
if (isKey_default(path9) && isStrictComparable_default(srcValue)) {
|
|
21020
|
+
return matchesStrictComparable_default(toKey_default(path9), srcValue);
|
|
20939
21021
|
}
|
|
20940
21022
|
return function(object) {
|
|
20941
|
-
var objValue = get_default(object,
|
|
20942
|
-
return objValue === void 0 && objValue === srcValue ? hasIn_default(object,
|
|
21023
|
+
var objValue = get_default(object, path9);
|
|
21024
|
+
return objValue === void 0 && objValue === srcValue ? hasIn_default(object, path9) : baseIsEqual_default(srcValue, objValue, COMPARE_PARTIAL_FLAG6 | COMPARE_UNORDERED_FLAG4);
|
|
20943
21025
|
};
|
|
20944
21026
|
}
|
|
20945
21027
|
var COMPARE_PARTIAL_FLAG6, COMPARE_UNORDERED_FLAG4, baseMatchesProperty_default;
|
|
@@ -20972,9 +21054,9 @@ var init_baseProperty = __esm({
|
|
|
20972
21054
|
});
|
|
20973
21055
|
|
|
20974
21056
|
// node_modules/lodash-es/_basePropertyDeep.js
|
|
20975
|
-
function basePropertyDeep(
|
|
21057
|
+
function basePropertyDeep(path9) {
|
|
20976
21058
|
return function(object) {
|
|
20977
|
-
return baseGet_default(object,
|
|
21059
|
+
return baseGet_default(object, path9);
|
|
20978
21060
|
};
|
|
20979
21061
|
}
|
|
20980
21062
|
var basePropertyDeep_default;
|
|
@@ -20986,8 +21068,8 @@ var init_basePropertyDeep = __esm({
|
|
|
20986
21068
|
});
|
|
20987
21069
|
|
|
20988
21070
|
// node_modules/lodash-es/property.js
|
|
20989
|
-
function property(
|
|
20990
|
-
return isKey_default(
|
|
21071
|
+
function property(path9) {
|
|
21072
|
+
return isKey_default(path9) ? baseProperty_default(toKey_default(path9)) : basePropertyDeep_default(path9);
|
|
20991
21073
|
}
|
|
20992
21074
|
var property_default;
|
|
20993
21075
|
var init_property = __esm({
|
|
@@ -21606,8 +21688,8 @@ var init_baseHas = __esm({
|
|
|
21606
21688
|
});
|
|
21607
21689
|
|
|
21608
21690
|
// node_modules/lodash-es/has.js
|
|
21609
|
-
function has(object,
|
|
21610
|
-
return object != null && hasPath_default(object,
|
|
21691
|
+
function has(object, path9) {
|
|
21692
|
+
return object != null && hasPath_default(object, path9, baseHas_default);
|
|
21611
21693
|
}
|
|
21612
21694
|
var has_default;
|
|
21613
21695
|
var init_has = __esm({
|
|
@@ -21813,14 +21895,14 @@ var init_negate = __esm({
|
|
|
21813
21895
|
});
|
|
21814
21896
|
|
|
21815
21897
|
// node_modules/lodash-es/_baseSet.js
|
|
21816
|
-
function baseSet(object,
|
|
21898
|
+
function baseSet(object, path9, value, customizer) {
|
|
21817
21899
|
if (!isObject_default(object)) {
|
|
21818
21900
|
return object;
|
|
21819
21901
|
}
|
|
21820
|
-
|
|
21821
|
-
var index = -1, length =
|
|
21902
|
+
path9 = castPath_default(path9, object);
|
|
21903
|
+
var index = -1, length = path9.length, lastIndex = length - 1, nested = object;
|
|
21822
21904
|
while (nested != null && ++index < length) {
|
|
21823
|
-
var key = toKey_default(
|
|
21905
|
+
var key = toKey_default(path9[index]), newValue = value;
|
|
21824
21906
|
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
21825
21907
|
return object;
|
|
21826
21908
|
}
|
|
@@ -21828,7 +21910,7 @@ function baseSet(object, path8, value, customizer) {
|
|
|
21828
21910
|
var objValue = nested[key];
|
|
21829
21911
|
newValue = customizer ? customizer(objValue, key, nested) : void 0;
|
|
21830
21912
|
if (newValue === void 0) {
|
|
21831
|
-
newValue = isObject_default(objValue) ? objValue : isIndex_default(
|
|
21913
|
+
newValue = isObject_default(objValue) ? objValue : isIndex_default(path9[index + 1]) ? [] : {};
|
|
21832
21914
|
}
|
|
21833
21915
|
}
|
|
21834
21916
|
assignValue_default(nested, key, newValue);
|
|
@@ -21852,9 +21934,9 @@ var init_baseSet = __esm({
|
|
|
21852
21934
|
function basePickBy(object, paths, predicate) {
|
|
21853
21935
|
var index = -1, length = paths.length, result = {};
|
|
21854
21936
|
while (++index < length) {
|
|
21855
|
-
var
|
|
21856
|
-
if (predicate(value,
|
|
21857
|
-
baseSet_default(result, castPath_default(
|
|
21937
|
+
var path9 = paths[index], value = baseGet_default(object, path9);
|
|
21938
|
+
if (predicate(value, path9)) {
|
|
21939
|
+
baseSet_default(result, castPath_default(path9, object), value);
|
|
21858
21940
|
}
|
|
21859
21941
|
}
|
|
21860
21942
|
return result;
|
|
@@ -21878,8 +21960,8 @@ function pickBy(object, predicate) {
|
|
|
21878
21960
|
return [prop];
|
|
21879
21961
|
});
|
|
21880
21962
|
predicate = baseIteratee_default(predicate);
|
|
21881
|
-
return basePickBy_default(object, props, function(value,
|
|
21882
|
-
return predicate(value,
|
|
21963
|
+
return basePickBy_default(object, props, function(value, path9) {
|
|
21964
|
+
return predicate(value, path9[0]);
|
|
21883
21965
|
});
|
|
21884
21966
|
}
|
|
21885
21967
|
var pickBy_default;
|
|
@@ -24592,12 +24674,12 @@ function assignCategoriesMapProp(tokenTypes) {
|
|
|
24592
24674
|
singleAssignCategoriesToksMap([], currTokType);
|
|
24593
24675
|
});
|
|
24594
24676
|
}
|
|
24595
|
-
function singleAssignCategoriesToksMap(
|
|
24596
|
-
forEach_default(
|
|
24677
|
+
function singleAssignCategoriesToksMap(path9, nextNode) {
|
|
24678
|
+
forEach_default(path9, (pathNode) => {
|
|
24597
24679
|
nextNode.categoryMatchesMap[pathNode.tokenTypeIdx] = true;
|
|
24598
24680
|
});
|
|
24599
24681
|
forEach_default(nextNode.CATEGORIES, (nextCategory) => {
|
|
24600
|
-
const newPath =
|
|
24682
|
+
const newPath = path9.concat(nextNode);
|
|
24601
24683
|
if (!includes_default(newPath, nextCategory)) {
|
|
24602
24684
|
singleAssignCategoriesToksMap(newPath, nextCategory);
|
|
24603
24685
|
}
|
|
@@ -25767,10 +25849,10 @@ var init_interpreter = __esm({
|
|
|
25767
25849
|
init_rest();
|
|
25768
25850
|
init_api2();
|
|
25769
25851
|
AbstractNextPossibleTokensWalker = class extends RestWalker {
|
|
25770
|
-
constructor(topProd,
|
|
25852
|
+
constructor(topProd, path9) {
|
|
25771
25853
|
super();
|
|
25772
25854
|
this.topProd = topProd;
|
|
25773
|
-
this.path =
|
|
25855
|
+
this.path = path9;
|
|
25774
25856
|
this.possibleTokTypes = [];
|
|
25775
25857
|
this.nextProductionName = "";
|
|
25776
25858
|
this.nextProductionOccurrence = 0;
|
|
@@ -25814,9 +25896,9 @@ var init_interpreter = __esm({
|
|
|
25814
25896
|
}
|
|
25815
25897
|
};
|
|
25816
25898
|
NextAfterTokenWalker = class extends AbstractNextPossibleTokensWalker {
|
|
25817
|
-
constructor(topProd,
|
|
25818
|
-
super(topProd,
|
|
25819
|
-
this.path =
|
|
25899
|
+
constructor(topProd, path9) {
|
|
25900
|
+
super(topProd, path9);
|
|
25901
|
+
this.path = path9;
|
|
25820
25902
|
this.nextTerminalName = "";
|
|
25821
25903
|
this.nextTerminalOccurrence = 0;
|
|
25822
25904
|
this.nextTerminalName = this.path.lastTok.name;
|
|
@@ -26057,10 +26139,10 @@ function initializeArrayOfArrays(size) {
|
|
|
26057
26139
|
}
|
|
26058
26140
|
return result;
|
|
26059
26141
|
}
|
|
26060
|
-
function pathToHashKeys(
|
|
26142
|
+
function pathToHashKeys(path9) {
|
|
26061
26143
|
let keys2 = [""];
|
|
26062
|
-
for (let i = 0; i <
|
|
26063
|
-
const tokType =
|
|
26144
|
+
for (let i = 0; i < path9.length; i++) {
|
|
26145
|
+
const tokType = path9[i];
|
|
26064
26146
|
const longerKeys = [];
|
|
26065
26147
|
for (let j = 0; j < keys2.length; j++) {
|
|
26066
26148
|
const currShorterKey = keys2[j];
|
|
@@ -26363,7 +26445,7 @@ function validateRuleIsOverridden(ruleName, definedRulesNames, className) {
|
|
|
26363
26445
|
}
|
|
26364
26446
|
return errors;
|
|
26365
26447
|
}
|
|
26366
|
-
function validateNoLeftRecursion(topRule, currRule, errMsgProvider,
|
|
26448
|
+
function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path9 = []) {
|
|
26367
26449
|
const errors = [];
|
|
26368
26450
|
const nextNonTerminals = getFirstNoneTerminal(currRule.definition);
|
|
26369
26451
|
if (isEmpty_default(nextNonTerminals)) {
|
|
@@ -26375,15 +26457,15 @@ function validateNoLeftRecursion(topRule, currRule, errMsgProvider, path8 = [])
|
|
|
26375
26457
|
errors.push({
|
|
26376
26458
|
message: errMsgProvider.buildLeftRecursionError({
|
|
26377
26459
|
topLevelRule: topRule,
|
|
26378
|
-
leftRecursionPath:
|
|
26460
|
+
leftRecursionPath: path9
|
|
26379
26461
|
}),
|
|
26380
26462
|
type: ParserDefinitionErrorType.LEFT_RECURSION,
|
|
26381
26463
|
ruleName
|
|
26382
26464
|
});
|
|
26383
26465
|
}
|
|
26384
|
-
const validNextSteps = difference_default(nextNonTerminals,
|
|
26466
|
+
const validNextSteps = difference_default(nextNonTerminals, path9.concat([topRule]));
|
|
26385
26467
|
const errorsFromNextSteps = flatMap_default(validNextSteps, (currRefRule) => {
|
|
26386
|
-
const newPath = clone_default(
|
|
26468
|
+
const newPath = clone_default(path9);
|
|
26387
26469
|
newPath.push(currRefRule);
|
|
26388
26470
|
return validateNoLeftRecursion(topRule, currRefRule, errMsgProvider, newPath);
|
|
26389
26471
|
});
|
|
@@ -31858,7 +31940,7 @@ function validateFlowchart(text, options = {}) {
|
|
|
31858
31940
|
const byLine = /* @__PURE__ */ new Map();
|
|
31859
31941
|
const collect = (arr) => {
|
|
31860
31942
|
for (const e of arr || []) {
|
|
31861
|
-
if (e && (e.code === "FL-LABEL-PARENS-UNQUOTED" || e.code === "FL-LABEL-AT-IN-UNQUOTED")) {
|
|
31943
|
+
if (e && (e.code === "FL-LABEL-PARENS-UNQUOTED" || e.code === "FL-LABEL-AT-IN-UNQUOTED" || e.code === "FL-LABEL-QUOTE-IN-UNQUOTED")) {
|
|
31862
31944
|
const ln = e.line ?? 0;
|
|
31863
31945
|
const col = e.column ?? 1;
|
|
31864
31946
|
const list = byLine.get(ln) || [];
|
|
@@ -31939,6 +32021,8 @@ function validateFlowchart(text, options = {}) {
|
|
|
31939
32021
|
const covered = existing.some((r) => !(endCol < r.start || startCol > r.end));
|
|
31940
32022
|
const hasParens = seg.includes("(") || seg.includes(")");
|
|
31941
32023
|
const hasAt = seg.includes("@");
|
|
32024
|
+
const hasQuote = seg.includes('"');
|
|
32025
|
+
const isSingleQuoted = /^'[^]*'$/.test(trimmed);
|
|
31942
32026
|
if (!covered && !isQuoted && !isParenWrapped && hasParens) {
|
|
31943
32027
|
errs.push({ line: ln, column: startCol, severity: "error", code: "FL-LABEL-PARENS-UNQUOTED", message: "Parentheses inside an unquoted label are not supported by Mermaid.", hint: 'Wrap the label in quotes, e.g., A["Mark (X)"] \u2014 or replace ( and ) with HTML entities: ( and ).' });
|
|
31944
32028
|
existing.push({ start: startCol, end: endCol });
|
|
@@ -31949,6 +32033,11 @@ function validateFlowchart(text, options = {}) {
|
|
|
31949
32033
|
existing.push({ start: startCol, end: endCol });
|
|
31950
32034
|
byLine.set(ln, existing);
|
|
31951
32035
|
}
|
|
32036
|
+
if (!covered && !isQuoted && !isSlashPair && hasQuote && !isSingleQuoted) {
|
|
32037
|
+
errs.push({ line: ln, column: startCol, severity: "error", code: "FL-LABEL-QUOTE-IN-UNQUOTED", message: "Quotes are not allowed inside unquoted node labels. Use " for quotes or wrap the entire label in quotes.", hint: 'Example: C["HTML Output: data-trigger-visibility="true""]' });
|
|
32038
|
+
existing.push({ start: startCol, end: endCol });
|
|
32039
|
+
byLine.set(ln, existing);
|
|
32040
|
+
}
|
|
31952
32041
|
i = j;
|
|
31953
32042
|
continue;
|
|
31954
32043
|
} else {
|
|
@@ -38980,11 +39069,11 @@ var require_baseGet = __commonJS({
|
|
|
38980
39069
|
"node_modules/lodash/_baseGet.js"(exports2, module2) {
|
|
38981
39070
|
var castPath2 = require_castPath();
|
|
38982
39071
|
var toKey2 = require_toKey();
|
|
38983
|
-
function baseGet2(object,
|
|
38984
|
-
|
|
38985
|
-
var index = 0, length =
|
|
39072
|
+
function baseGet2(object, path9) {
|
|
39073
|
+
path9 = castPath2(path9, object);
|
|
39074
|
+
var index = 0, length = path9.length;
|
|
38986
39075
|
while (object != null && index < length) {
|
|
38987
|
-
object = object[toKey2(
|
|
39076
|
+
object = object[toKey2(path9[index++])];
|
|
38988
39077
|
}
|
|
38989
39078
|
return index && index == length ? object : void 0;
|
|
38990
39079
|
}
|
|
@@ -38996,8 +39085,8 @@ var require_baseGet = __commonJS({
|
|
|
38996
39085
|
var require_get = __commonJS({
|
|
38997
39086
|
"node_modules/lodash/get.js"(exports2, module2) {
|
|
38998
39087
|
var baseGet2 = require_baseGet();
|
|
38999
|
-
function get2(object,
|
|
39000
|
-
var result = object == null ? void 0 : baseGet2(object,
|
|
39088
|
+
function get2(object, path9, defaultValue) {
|
|
39089
|
+
var result = object == null ? void 0 : baseGet2(object, path9);
|
|
39001
39090
|
return result === void 0 ? defaultValue : result;
|
|
39002
39091
|
}
|
|
39003
39092
|
module2.exports = get2;
|
|
@@ -39023,11 +39112,11 @@ var require_hasPath = __commonJS({
|
|
|
39023
39112
|
var isIndex2 = require_isIndex();
|
|
39024
39113
|
var isLength2 = require_isLength();
|
|
39025
39114
|
var toKey2 = require_toKey();
|
|
39026
|
-
function hasPath2(object,
|
|
39027
|
-
|
|
39028
|
-
var index = -1, length =
|
|
39115
|
+
function hasPath2(object, path9, hasFunc) {
|
|
39116
|
+
path9 = castPath2(path9, object);
|
|
39117
|
+
var index = -1, length = path9.length, result = false;
|
|
39029
39118
|
while (++index < length) {
|
|
39030
|
-
var key = toKey2(
|
|
39119
|
+
var key = toKey2(path9[index]);
|
|
39031
39120
|
if (!(result = object != null && hasFunc(object, key))) {
|
|
39032
39121
|
break;
|
|
39033
39122
|
}
|
|
@@ -39048,8 +39137,8 @@ var require_hasIn = __commonJS({
|
|
|
39048
39137
|
"node_modules/lodash/hasIn.js"(exports2, module2) {
|
|
39049
39138
|
var baseHasIn2 = require_baseHasIn();
|
|
39050
39139
|
var hasPath2 = require_hasPath();
|
|
39051
|
-
function hasIn2(object,
|
|
39052
|
-
return object != null && hasPath2(object,
|
|
39140
|
+
function hasIn2(object, path9) {
|
|
39141
|
+
return object != null && hasPath2(object, path9, baseHasIn2);
|
|
39053
39142
|
}
|
|
39054
39143
|
module2.exports = hasIn2;
|
|
39055
39144
|
}
|
|
@@ -39067,13 +39156,13 @@ var require_baseMatchesProperty = __commonJS({
|
|
|
39067
39156
|
var toKey2 = require_toKey();
|
|
39068
39157
|
var COMPARE_PARTIAL_FLAG7 = 1;
|
|
39069
39158
|
var COMPARE_UNORDERED_FLAG5 = 2;
|
|
39070
|
-
function baseMatchesProperty2(
|
|
39071
|
-
if (isKey2(
|
|
39072
|
-
return matchesStrictComparable2(toKey2(
|
|
39159
|
+
function baseMatchesProperty2(path9, srcValue) {
|
|
39160
|
+
if (isKey2(path9) && isStrictComparable2(srcValue)) {
|
|
39161
|
+
return matchesStrictComparable2(toKey2(path9), srcValue);
|
|
39073
39162
|
}
|
|
39074
39163
|
return function(object) {
|
|
39075
|
-
var objValue = get2(object,
|
|
39076
|
-
return objValue === void 0 && objValue === srcValue ? hasIn2(object,
|
|
39164
|
+
var objValue = get2(object, path9);
|
|
39165
|
+
return objValue === void 0 && objValue === srcValue ? hasIn2(object, path9) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG7 | COMPARE_UNORDERED_FLAG5);
|
|
39077
39166
|
};
|
|
39078
39167
|
}
|
|
39079
39168
|
module2.exports = baseMatchesProperty2;
|
|
@@ -39096,9 +39185,9 @@ var require_baseProperty = __commonJS({
|
|
|
39096
39185
|
var require_basePropertyDeep = __commonJS({
|
|
39097
39186
|
"node_modules/lodash/_basePropertyDeep.js"(exports2, module2) {
|
|
39098
39187
|
var baseGet2 = require_baseGet();
|
|
39099
|
-
function basePropertyDeep2(
|
|
39188
|
+
function basePropertyDeep2(path9) {
|
|
39100
39189
|
return function(object) {
|
|
39101
|
-
return baseGet2(object,
|
|
39190
|
+
return baseGet2(object, path9);
|
|
39102
39191
|
};
|
|
39103
39192
|
}
|
|
39104
39193
|
module2.exports = basePropertyDeep2;
|
|
@@ -39112,8 +39201,8 @@ var require_property = __commonJS({
|
|
|
39112
39201
|
var basePropertyDeep2 = require_basePropertyDeep();
|
|
39113
39202
|
var isKey2 = require_isKey();
|
|
39114
39203
|
var toKey2 = require_toKey();
|
|
39115
|
-
function property2(
|
|
39116
|
-
return isKey2(
|
|
39204
|
+
function property2(path9) {
|
|
39205
|
+
return isKey2(path9) ? baseProperty2(toKey2(path9)) : basePropertyDeep2(path9);
|
|
39117
39206
|
}
|
|
39118
39207
|
module2.exports = property2;
|
|
39119
39208
|
}
|
|
@@ -39175,8 +39264,8 @@ var require_has = __commonJS({
|
|
|
39175
39264
|
"node_modules/lodash/has.js"(exports2, module2) {
|
|
39176
39265
|
var baseHas2 = require_baseHas();
|
|
39177
39266
|
var hasPath2 = require_hasPath();
|
|
39178
|
-
function has2(object,
|
|
39179
|
-
return object != null && hasPath2(object,
|
|
39267
|
+
function has2(object, path9) {
|
|
39268
|
+
return object != null && hasPath2(object, path9, baseHas2);
|
|
39180
39269
|
}
|
|
39181
39270
|
module2.exports = has2;
|
|
39182
39271
|
}
|
|
@@ -41450,14 +41539,14 @@ var require_baseSet = __commonJS({
|
|
|
41450
41539
|
var isIndex2 = require_isIndex();
|
|
41451
41540
|
var isObject2 = require_isObject();
|
|
41452
41541
|
var toKey2 = require_toKey();
|
|
41453
|
-
function baseSet2(object,
|
|
41542
|
+
function baseSet2(object, path9, value, customizer) {
|
|
41454
41543
|
if (!isObject2(object)) {
|
|
41455
41544
|
return object;
|
|
41456
41545
|
}
|
|
41457
|
-
|
|
41458
|
-
var index = -1, length =
|
|
41546
|
+
path9 = castPath2(path9, object);
|
|
41547
|
+
var index = -1, length = path9.length, lastIndex = length - 1, nested = object;
|
|
41459
41548
|
while (nested != null && ++index < length) {
|
|
41460
|
-
var key = toKey2(
|
|
41549
|
+
var key = toKey2(path9[index]), newValue = value;
|
|
41461
41550
|
if (key === "__proto__" || key === "constructor" || key === "prototype") {
|
|
41462
41551
|
return object;
|
|
41463
41552
|
}
|
|
@@ -41465,7 +41554,7 @@ var require_baseSet = __commonJS({
|
|
|
41465
41554
|
var objValue = nested[key];
|
|
41466
41555
|
newValue = customizer ? customizer(objValue, key, nested) : void 0;
|
|
41467
41556
|
if (newValue === void 0) {
|
|
41468
|
-
newValue = isObject2(objValue) ? objValue : isIndex2(
|
|
41557
|
+
newValue = isObject2(objValue) ? objValue : isIndex2(path9[index + 1]) ? [] : {};
|
|
41469
41558
|
}
|
|
41470
41559
|
}
|
|
41471
41560
|
assignValue2(nested, key, newValue);
|
|
@@ -41486,9 +41575,9 @@ var require_basePickBy = __commonJS({
|
|
|
41486
41575
|
function basePickBy2(object, paths, predicate) {
|
|
41487
41576
|
var index = -1, length = paths.length, result = {};
|
|
41488
41577
|
while (++index < length) {
|
|
41489
|
-
var
|
|
41490
|
-
if (predicate(value,
|
|
41491
|
-
baseSet2(result, castPath2(
|
|
41578
|
+
var path9 = paths[index], value = baseGet2(object, path9);
|
|
41579
|
+
if (predicate(value, path9)) {
|
|
41580
|
+
baseSet2(result, castPath2(path9, object), value);
|
|
41492
41581
|
}
|
|
41493
41582
|
}
|
|
41494
41583
|
return result;
|
|
@@ -41503,8 +41592,8 @@ var require_basePick = __commonJS({
|
|
|
41503
41592
|
var basePickBy2 = require_basePickBy();
|
|
41504
41593
|
var hasIn2 = require_hasIn();
|
|
41505
41594
|
function basePick(object, paths) {
|
|
41506
|
-
return basePickBy2(object, paths, function(value,
|
|
41507
|
-
return hasIn2(object,
|
|
41595
|
+
return basePickBy2(object, paths, function(value, path9) {
|
|
41596
|
+
return hasIn2(object, path9);
|
|
41508
41597
|
});
|
|
41509
41598
|
}
|
|
41510
41599
|
module2.exports = basePick;
|
|
@@ -42558,15 +42647,15 @@ var require_parent_dummy_chains = __commonJS({
|
|
|
42558
42647
|
var node = g.node(v);
|
|
42559
42648
|
var edgeObj = node.edgeObj;
|
|
42560
42649
|
var pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w);
|
|
42561
|
-
var
|
|
42650
|
+
var path9 = pathData.path;
|
|
42562
42651
|
var lca = pathData.lca;
|
|
42563
42652
|
var pathIdx = 0;
|
|
42564
|
-
var pathV =
|
|
42653
|
+
var pathV = path9[pathIdx];
|
|
42565
42654
|
var ascending = true;
|
|
42566
42655
|
while (v !== edgeObj.w) {
|
|
42567
42656
|
node = g.node(v);
|
|
42568
42657
|
if (ascending) {
|
|
42569
|
-
while ((pathV =
|
|
42658
|
+
while ((pathV = path9[pathIdx]) !== lca && g.node(pathV).maxRank < node.rank) {
|
|
42570
42659
|
pathIdx++;
|
|
42571
42660
|
}
|
|
42572
42661
|
if (pathV === lca) {
|
|
@@ -42574,10 +42663,10 @@ var require_parent_dummy_chains = __commonJS({
|
|
|
42574
42663
|
}
|
|
42575
42664
|
}
|
|
42576
42665
|
if (!ascending) {
|
|
42577
|
-
while (pathIdx <
|
|
42666
|
+
while (pathIdx < path9.length - 1 && g.node(pathV = path9[pathIdx + 1]).minRank <= node.rank) {
|
|
42578
42667
|
pathIdx++;
|
|
42579
42668
|
}
|
|
42580
|
-
pathV =
|
|
42669
|
+
pathV = path9[pathIdx];
|
|
42581
42670
|
}
|
|
42582
42671
|
g.setParent(v, pathV);
|
|
42583
42672
|
v = g.successors(v)[0];
|
|
@@ -44750,8 +44839,8 @@ var init_svg_generator = __esm({
|
|
|
44750
44839
|
elements.push(this.generateNodeWithPad(node, padX, padY));
|
|
44751
44840
|
}
|
|
44752
44841
|
for (const edge of layout.edges) {
|
|
44753
|
-
const { path:
|
|
44754
|
-
elements.push(
|
|
44842
|
+
const { path: path9, overlay } = this.generateEdge(edge, padX, padY, nodeMap);
|
|
44843
|
+
elements.push(path9);
|
|
44755
44844
|
if (overlay)
|
|
44756
44845
|
overlays.push(overlay);
|
|
44757
44846
|
}
|
|
@@ -51067,8 +51156,8 @@ var require_utils = __commonJS({
|
|
|
51067
51156
|
}
|
|
51068
51157
|
return ind;
|
|
51069
51158
|
}
|
|
51070
|
-
function removeDotSegments(
|
|
51071
|
-
let input =
|
|
51159
|
+
function removeDotSegments(path9) {
|
|
51160
|
+
let input = path9;
|
|
51072
51161
|
const output = [];
|
|
51073
51162
|
let nextSlash = -1;
|
|
51074
51163
|
let len = 0;
|
|
@@ -51267,8 +51356,8 @@ var require_schemes = __commonJS({
|
|
|
51267
51356
|
wsComponent.secure = void 0;
|
|
51268
51357
|
}
|
|
51269
51358
|
if (wsComponent.resourceName) {
|
|
51270
|
-
const [
|
|
51271
|
-
wsComponent.path =
|
|
51359
|
+
const [path9, query2] = wsComponent.resourceName.split("?");
|
|
51360
|
+
wsComponent.path = path9 && path9 !== "/" ? path9 : void 0;
|
|
51272
51361
|
wsComponent.query = query2;
|
|
51273
51362
|
wsComponent.resourceName = void 0;
|
|
51274
51363
|
}
|
|
@@ -54611,7 +54700,7 @@ function validateJsonResponse(response, options = {}) {
|
|
|
54611
54700
|
}
|
|
54612
54701
|
if (!valid) {
|
|
54613
54702
|
const formattedErrors = validate2.errors.map((err) => {
|
|
54614
|
-
const
|
|
54703
|
+
const path9 = err.instancePath ? err.instancePath.substring(1).replace(/\//g, ".") : "<root>";
|
|
54615
54704
|
let message = "";
|
|
54616
54705
|
let suggestion = "";
|
|
54617
54706
|
if (err.keyword === "additionalProperties") {
|
|
@@ -54649,7 +54738,7 @@ function validateJsonResponse(response, options = {}) {
|
|
|
54649
54738
|
message = err.message;
|
|
54650
54739
|
suggestion = "";
|
|
54651
54740
|
}
|
|
54652
|
-
const location =
|
|
54741
|
+
const location = path9 ? `at '${path9}'` : "at root";
|
|
54653
54742
|
return suggestion ? `${location}: ${message} \u2192 ${suggestion}` : `${location}: ${message}`;
|
|
54654
54743
|
});
|
|
54655
54744
|
const errorSummary = formattedErrors.join("\n ");
|
|
@@ -54972,7 +55061,7 @@ function extractMermaidFromJson(response) {
|
|
|
54972
55061
|
}
|
|
54973
55062
|
const diagrams = [];
|
|
54974
55063
|
const jsonPaths = [];
|
|
54975
|
-
function searchObject(obj,
|
|
55064
|
+
function searchObject(obj, path9 = []) {
|
|
54976
55065
|
if (typeof obj === "string") {
|
|
54977
55066
|
const mermaidPattern = /```mermaid([^\n`]*?)(?:\n|\\n)([\s\S]*?)```/gi;
|
|
54978
55067
|
let match2;
|
|
@@ -54986,14 +55075,14 @@ function extractMermaidFromJson(response) {
|
|
|
54986
55075
|
endIndex: match2.index + match2[0].length,
|
|
54987
55076
|
attributes,
|
|
54988
55077
|
isInJson: true,
|
|
54989
|
-
jsonPath:
|
|
55078
|
+
jsonPath: path9.join(".")
|
|
54990
55079
|
});
|
|
54991
|
-
jsonPaths.push(
|
|
55080
|
+
jsonPaths.push(path9.join("."));
|
|
54992
55081
|
}
|
|
54993
55082
|
} else if (Array.isArray(obj)) {
|
|
54994
|
-
obj.forEach((item, index) => searchObject(item, [...
|
|
55083
|
+
obj.forEach((item, index) => searchObject(item, [...path9, `[${index}]`]));
|
|
54995
55084
|
} else if (obj && typeof obj === "object") {
|
|
54996
|
-
Object.entries(obj).forEach(([key, value]) => searchObject(value, [...
|
|
55085
|
+
Object.entries(obj).forEach(([key, value]) => searchObject(value, [...path9, key]));
|
|
54997
55086
|
}
|
|
54998
55087
|
}
|
|
54999
55088
|
searchObject(parsedJson);
|
|
@@ -55250,7 +55339,7 @@ async function tryMaidAutoFix(diagramContent, options = {}) {
|
|
|
55250
55339
|
}
|
|
55251
55340
|
}
|
|
55252
55341
|
async function validateAndFixMermaidResponse(response, options = {}) {
|
|
55253
|
-
const { schema, debug, path:
|
|
55342
|
+
const { schema, debug, path: path9, provider, model, tracer } = options;
|
|
55254
55343
|
const startTime = Date.now();
|
|
55255
55344
|
if (debug) {
|
|
55256
55345
|
console.log(`[DEBUG] Mermaid validation: Starting maid-based validation for response (${response.length} chars)`);
|
|
@@ -55407,7 +55496,7 @@ ${maidResult.fixed}
|
|
|
55407
55496
|
}
|
|
55408
55497
|
const aiFixingStart = Date.now();
|
|
55409
55498
|
const mermaidFixer = new MermaidFixingAgent({
|
|
55410
|
-
path:
|
|
55499
|
+
path: path9,
|
|
55411
55500
|
provider,
|
|
55412
55501
|
model,
|
|
55413
55502
|
debug,
|
|
@@ -55649,8 +55738,8 @@ Schema Validation Errors:
|
|
|
55649
55738
|
${validationResult.errorSummary}`;
|
|
55650
55739
|
} else if (validationResult.schemaErrors && validationResult.schemaErrors.length > 0) {
|
|
55651
55740
|
const errors = validationResult.schemaErrors.map((err) => {
|
|
55652
|
-
const
|
|
55653
|
-
return ` ${
|
|
55741
|
+
const path9 = err.instancePath || "(root)";
|
|
55742
|
+
return ` ${path9}: ${err.message}`;
|
|
55654
55743
|
}).join("\n");
|
|
55655
55744
|
schemaErrorDetails = `
|
|
55656
55745
|
|
|
@@ -58258,8 +58347,8 @@ __export(enhanced_claude_code_exports, {
|
|
|
58258
58347
|
});
|
|
58259
58348
|
import { spawn as spawn3 } from "child_process";
|
|
58260
58349
|
import { randomBytes } from "crypto";
|
|
58261
|
-
import
|
|
58262
|
-
import
|
|
58350
|
+
import fs9 from "fs/promises";
|
|
58351
|
+
import path8 from "path";
|
|
58263
58352
|
import os3 from "os";
|
|
58264
58353
|
import { EventEmitter as EventEmitter4 } from "events";
|
|
58265
58354
|
async function createEnhancedClaudeCLIEngine(options = {}) {
|
|
@@ -58282,12 +58371,12 @@ async function createEnhancedClaudeCLIEngine(options = {}) {
|
|
|
58282
58371
|
console.log("[DEBUG] Built-in MCP server started");
|
|
58283
58372
|
console.log("[DEBUG] MCP URL:", `http://${host}:${port}/mcp`);
|
|
58284
58373
|
}
|
|
58285
|
-
mcpConfigPath =
|
|
58374
|
+
mcpConfigPath = path8.join(os3.tmpdir(), `probe-mcp-${session.id}.json`);
|
|
58286
58375
|
const mcpConfig = {
|
|
58287
58376
|
mcpServers: {
|
|
58288
58377
|
probe: {
|
|
58289
58378
|
command: "node",
|
|
58290
|
-
args: [
|
|
58379
|
+
args: [path8.join(process.cwd(), "mcp-probe-server.js")],
|
|
58291
58380
|
env: {
|
|
58292
58381
|
PROBE_WORKSPACE: process.cwd(),
|
|
58293
58382
|
DEBUG: debug ? "true" : "false"
|
|
@@ -58295,7 +58384,7 @@ async function createEnhancedClaudeCLIEngine(options = {}) {
|
|
|
58295
58384
|
}
|
|
58296
58385
|
}
|
|
58297
58386
|
};
|
|
58298
|
-
await
|
|
58387
|
+
await fs9.writeFile(mcpConfigPath, JSON.stringify(mcpConfig, null, 2));
|
|
58299
58388
|
}
|
|
58300
58389
|
if (debug) {
|
|
58301
58390
|
console.log("[DEBUG] Enhanced Claude Code Engine");
|
|
@@ -58489,7 +58578,7 @@ ${opts.schema}`;
|
|
|
58489
58578
|
}
|
|
58490
58579
|
}
|
|
58491
58580
|
if (mcpConfigPath) {
|
|
58492
|
-
await
|
|
58581
|
+
await fs9.unlink(mcpConfigPath).catch(() => {
|
|
58493
58582
|
});
|
|
58494
58583
|
if (debug) {
|
|
58495
58584
|
console.log("[DEBUG] MCP config file removed");
|
|
@@ -59064,6 +59153,7 @@ var init_ProbeAgent = __esm({
|
|
|
59064
59153
|
* @param {boolean} [options.allowEdit=false] - Allow the use of the 'implement' tool
|
|
59065
59154
|
* @param {boolean} [options.enableDelegate=false] - Enable the delegate tool for task distribution to subagents
|
|
59066
59155
|
* @param {string} [options.path] - Search directory path
|
|
59156
|
+
* @param {string} [options.cwd] - Working directory for resolving relative paths (independent of allowedFolders)
|
|
59067
59157
|
* @param {string} [options.provider] - Force specific AI provider
|
|
59068
59158
|
* @param {string} [options.model] - Override model name
|
|
59069
59159
|
* @param {boolean} [options.debug] - Enable debug mode
|
|
@@ -59092,6 +59182,7 @@ var init_ProbeAgent = __esm({
|
|
|
59092
59182
|
* @param {Array<Object>} [options.fallback.providers] - List of provider configurations for custom fallback
|
|
59093
59183
|
* @param {boolean} [options.fallback.stopOnSuccess=true] - Stop on first success
|
|
59094
59184
|
* @param {number} [options.fallback.maxTotalAttempts=10] - Maximum total attempts across all providers
|
|
59185
|
+
* @param {string} [options.completionPrompt] - Custom prompt to run after attempt_completion for validation/review (runs before mermaid/JSON validation)
|
|
59095
59186
|
*/
|
|
59096
59187
|
constructor(options = {}) {
|
|
59097
59188
|
this.sessionId = options.sessionId || randomUUID5();
|
|
@@ -59113,6 +59204,7 @@ var init_ProbeAgent = __esm({
|
|
|
59113
59204
|
this.maxIterations = options.maxIterations || null;
|
|
59114
59205
|
this.disableMermaidValidation = !!options.disableMermaidValidation;
|
|
59115
59206
|
this.disableJsonValidation = !!options.disableJsonValidation;
|
|
59207
|
+
this.completionPrompt = options.completionPrompt || null;
|
|
59116
59208
|
const effectiveAllowedTools = options.disableTools ? [] : options.allowedTools;
|
|
59117
59209
|
this.allowedTools = this._parseAllowedTools(effectiveAllowedTools);
|
|
59118
59210
|
this.storageAdapter = options.storageAdapter || new InMemoryStorageAdapter();
|
|
@@ -59131,6 +59223,7 @@ var init_ProbeAgent = __esm({
|
|
|
59131
59223
|
} else {
|
|
59132
59224
|
this.allowedFolders = [process.cwd()];
|
|
59133
59225
|
}
|
|
59226
|
+
this.cwd = options.cwd || null;
|
|
59134
59227
|
this.clientApiProvider = options.provider || null;
|
|
59135
59228
|
this.clientApiModel = options.model || null;
|
|
59136
59229
|
this.clientApiKey = null;
|
|
@@ -59309,7 +59402,8 @@ var init_ProbeAgent = __esm({
|
|
|
59309
59402
|
const configOptions = {
|
|
59310
59403
|
sessionId: this.sessionId,
|
|
59311
59404
|
debug: this.debug,
|
|
59312
|
-
|
|
59405
|
+
// Use explicit cwd if set, otherwise fall back to first allowed folder
|
|
59406
|
+
cwd: this.cwd || (this.allowedFolders.length > 0 ? this.allowedFolders[0] : process.cwd()),
|
|
59313
59407
|
allowedFolders: this.allowedFolders,
|
|
59314
59408
|
outline: this.outline,
|
|
59315
59409
|
allowEdit: this.allowEdit,
|
|
@@ -61160,6 +61254,46 @@ IMPORTANT: When using <attempt_complete>, this must be the ONLY content in your
|
|
|
61160
61254
|
} catch (error) {
|
|
61161
61255
|
console.error(`[ERROR] Failed to save messages to storage:`, error);
|
|
61162
61256
|
}
|
|
61257
|
+
if (completionAttempted && this.completionPrompt && !options._completionPromptProcessed) {
|
|
61258
|
+
if (this.debug) {
|
|
61259
|
+
console.log("[DEBUG] Running completion prompt for post-completion validation/review...");
|
|
61260
|
+
}
|
|
61261
|
+
try {
|
|
61262
|
+
if (this.tracer) {
|
|
61263
|
+
this.tracer.recordEvent("completion_prompt.started", {
|
|
61264
|
+
"completion_prompt.original_result_length": finalResult?.length || 0
|
|
61265
|
+
});
|
|
61266
|
+
}
|
|
61267
|
+
const completionPromptMessage = `${this.completionPrompt}
|
|
61268
|
+
|
|
61269
|
+
Here is the result to review:
|
|
61270
|
+
<result>
|
|
61271
|
+
${finalResult}
|
|
61272
|
+
</result>
|
|
61273
|
+
|
|
61274
|
+
After reviewing, provide your final answer using attempt_completion.`;
|
|
61275
|
+
const completionResult = await this.answer(completionPromptMessage, [], {
|
|
61276
|
+
...options,
|
|
61277
|
+
_completionPromptProcessed: true
|
|
61278
|
+
});
|
|
61279
|
+
finalResult = completionResult;
|
|
61280
|
+
if (this.debug) {
|
|
61281
|
+
console.log(`[DEBUG] Completion prompt finished. New result length: ${finalResult?.length || 0}`);
|
|
61282
|
+
}
|
|
61283
|
+
if (this.tracer) {
|
|
61284
|
+
this.tracer.recordEvent("completion_prompt.completed", {
|
|
61285
|
+
"completion_prompt.final_result_length": finalResult?.length || 0
|
|
61286
|
+
});
|
|
61287
|
+
}
|
|
61288
|
+
} catch (error) {
|
|
61289
|
+
console.error("[ERROR] Completion prompt failed:", error);
|
|
61290
|
+
if (this.tracer) {
|
|
61291
|
+
this.tracer.recordEvent("completion_prompt.error", {
|
|
61292
|
+
"completion_prompt.error": error.message
|
|
61293
|
+
});
|
|
61294
|
+
}
|
|
61295
|
+
}
|
|
61296
|
+
}
|
|
61163
61297
|
const reachedMaxIterations = currentIteration >= maxIterations && !completionAttempted;
|
|
61164
61298
|
if (options.schema && !options._schemaFormatted && !completionAttempted && !reachedMaxIterations) {
|
|
61165
61299
|
if (this.debug) {
|
|
@@ -61626,6 +61760,8 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
61626
61760
|
path: this.allowedFolders[0],
|
|
61627
61761
|
// Use first allowed folder as primary path
|
|
61628
61762
|
allowedFolders: [...this.allowedFolders],
|
|
61763
|
+
cwd: this.cwd,
|
|
61764
|
+
// Preserve explicit working directory
|
|
61629
61765
|
provider: this.clientApiProvider,
|
|
61630
61766
|
model: this.clientApiModel,
|
|
61631
61767
|
debug: this.debug,
|
|
@@ -61634,6 +61770,7 @@ Convert your previous response content into actual JSON data that follows this s
|
|
|
61634
61770
|
maxIterations: this.maxIterations,
|
|
61635
61771
|
disableMermaidValidation: this.disableMermaidValidation,
|
|
61636
61772
|
disableJsonValidation: this.disableJsonValidation,
|
|
61773
|
+
completionPrompt: this.completionPrompt,
|
|
61637
61774
|
allowedTools: allowedToolsArray,
|
|
61638
61775
|
enableMcp: !!this.mcpBridge,
|
|
61639
61776
|
mcpConfig: this.mcpConfig,
|