@probelabs/probe 0.6.0-rc141 → 0.6.0-rc143
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/index.js +260 -71
- package/build/downloader.js +343 -55
- package/build/mcp/index.js +10 -2
- package/build/mcp/index.ts +10 -2
- package/build/search.js +20 -29
- package/build/utils.js +9 -7
- package/cjs/agent/ProbeAgent.cjs +254 -65
- package/cjs/index.cjs +255 -66
- package/package.json +1 -1
- package/src/downloader.js +343 -55
- package/src/mcp/index.ts +10 -2
- package/src/search.js +20 -29
- package/src/utils.js +9 -7
package/cjs/agent/ProbeAgent.cjs
CHANGED
|
@@ -27268,6 +27268,145 @@ var init_directory_resolver = __esm({
|
|
|
27268
27268
|
});
|
|
27269
27269
|
|
|
27270
27270
|
// src/downloader.js
|
|
27271
|
+
async function acquireFileLock(lockPath, version) {
|
|
27272
|
+
const lockData = {
|
|
27273
|
+
version,
|
|
27274
|
+
pid: process.pid,
|
|
27275
|
+
timestamp: Date.now()
|
|
27276
|
+
};
|
|
27277
|
+
try {
|
|
27278
|
+
await import_fs_extra2.default.writeFile(lockPath, JSON.stringify(lockData), { flag: "wx" });
|
|
27279
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27280
|
+
console.log(`Acquired file lock: ${lockPath}`);
|
|
27281
|
+
}
|
|
27282
|
+
return true;
|
|
27283
|
+
} catch (error2) {
|
|
27284
|
+
if (error2.code === "EEXIST") {
|
|
27285
|
+
try {
|
|
27286
|
+
const existingLock = JSON.parse(await import_fs_extra2.default.readFile(lockPath, "utf-8"));
|
|
27287
|
+
const lockAge = Date.now() - existingLock.timestamp;
|
|
27288
|
+
if (lockAge > LOCK_TIMEOUT_MS) {
|
|
27289
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27290
|
+
console.log(`Removing stale lock file (age: ${Math.round(lockAge / 1e3)}s, pid: ${existingLock.pid})`);
|
|
27291
|
+
}
|
|
27292
|
+
await import_fs_extra2.default.remove(lockPath);
|
|
27293
|
+
return false;
|
|
27294
|
+
}
|
|
27295
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27296
|
+
console.log(`Download in progress by process ${existingLock.pid}, waiting...`);
|
|
27297
|
+
}
|
|
27298
|
+
return false;
|
|
27299
|
+
} catch (readError) {
|
|
27300
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27301
|
+
console.log(`Lock file corrupted, removing: ${readError.message}`);
|
|
27302
|
+
}
|
|
27303
|
+
try {
|
|
27304
|
+
await import_fs_extra2.default.remove(lockPath);
|
|
27305
|
+
} catch {
|
|
27306
|
+
}
|
|
27307
|
+
return false;
|
|
27308
|
+
}
|
|
27309
|
+
}
|
|
27310
|
+
if (error2.code === "EACCES" || error2.code === "EPERM" || error2.code === "EROFS") {
|
|
27311
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27312
|
+
console.log(`Cannot create lock file (${error2.code}): ${lockPath}`);
|
|
27313
|
+
console.log(`File-based locking unavailable, will proceed without cross-process coordination`);
|
|
27314
|
+
}
|
|
27315
|
+
return null;
|
|
27316
|
+
}
|
|
27317
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27318
|
+
console.log(`Unexpected error creating lock file: ${error2.message}`);
|
|
27319
|
+
console.log(`Proceeding without file-based lock`);
|
|
27320
|
+
}
|
|
27321
|
+
return null;
|
|
27322
|
+
}
|
|
27323
|
+
}
|
|
27324
|
+
async function releaseFileLock(lockPath) {
|
|
27325
|
+
try {
|
|
27326
|
+
await import_fs_extra2.default.remove(lockPath);
|
|
27327
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27328
|
+
console.log(`Released file lock: ${lockPath}`);
|
|
27329
|
+
}
|
|
27330
|
+
} catch (error2) {
|
|
27331
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27332
|
+
console.log(`Warning: Could not release lock file: ${error2.message}`);
|
|
27333
|
+
}
|
|
27334
|
+
}
|
|
27335
|
+
}
|
|
27336
|
+
async function waitForFileLock(lockPath, binaryPath) {
|
|
27337
|
+
const startTime = Date.now();
|
|
27338
|
+
while (Date.now() - startTime < MAX_LOCK_WAIT_MS) {
|
|
27339
|
+
if (await import_fs_extra2.default.pathExists(binaryPath)) {
|
|
27340
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27341
|
+
console.log(`Binary now available at ${binaryPath}, download completed by another process`);
|
|
27342
|
+
}
|
|
27343
|
+
return true;
|
|
27344
|
+
}
|
|
27345
|
+
const lockExists = await import_fs_extra2.default.pathExists(lockPath);
|
|
27346
|
+
if (!lockExists) {
|
|
27347
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27348
|
+
console.log(`Lock file removed but binary not found - download may have failed`);
|
|
27349
|
+
}
|
|
27350
|
+
return false;
|
|
27351
|
+
}
|
|
27352
|
+
try {
|
|
27353
|
+
const lockData = JSON.parse(await import_fs_extra2.default.readFile(lockPath, "utf-8"));
|
|
27354
|
+
const lockAge = Date.now() - lockData.timestamp;
|
|
27355
|
+
if (lockAge > LOCK_TIMEOUT_MS) {
|
|
27356
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27357
|
+
console.log(`Lock expired (age: ${Math.round(lockAge / 1e3)}s), will retry download`);
|
|
27358
|
+
}
|
|
27359
|
+
return false;
|
|
27360
|
+
}
|
|
27361
|
+
} catch {
|
|
27362
|
+
}
|
|
27363
|
+
await new Promise((resolve4) => setTimeout(resolve4, LOCK_POLL_INTERVAL_MS));
|
|
27364
|
+
}
|
|
27365
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27366
|
+
console.log(`Timeout waiting for file lock`);
|
|
27367
|
+
}
|
|
27368
|
+
return false;
|
|
27369
|
+
}
|
|
27370
|
+
async function withDownloadLock(version, downloadFn) {
|
|
27371
|
+
const lockKey = version || "latest";
|
|
27372
|
+
if (downloadLocks.has(lockKey)) {
|
|
27373
|
+
const lock = downloadLocks.get(lockKey);
|
|
27374
|
+
const lockAge = Date.now() - lock.timestamp;
|
|
27375
|
+
if (lockAge > LOCK_TIMEOUT_MS) {
|
|
27376
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27377
|
+
console.log(`In-memory lock for version ${lockKey} expired (age: ${Math.round(lockAge / 1e3)}s), removing stale lock`);
|
|
27378
|
+
}
|
|
27379
|
+
downloadLocks.delete(lockKey);
|
|
27380
|
+
} else {
|
|
27381
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27382
|
+
console.log(`Download already in progress in this process for version ${lockKey}, waiting...`);
|
|
27383
|
+
}
|
|
27384
|
+
try {
|
|
27385
|
+
return await lock.promise;
|
|
27386
|
+
} catch (error2) {
|
|
27387
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27388
|
+
console.log(`In-memory locked download failed, will retry: ${error2.message}`);
|
|
27389
|
+
}
|
|
27390
|
+
}
|
|
27391
|
+
}
|
|
27392
|
+
}
|
|
27393
|
+
const downloadPromise = Promise.race([
|
|
27394
|
+
downloadFn(),
|
|
27395
|
+
new Promise(
|
|
27396
|
+
(_2, reject2) => setTimeout(() => reject2(new Error(`Download timeout after ${LOCK_TIMEOUT_MS / 1e3}s`)), LOCK_TIMEOUT_MS)
|
|
27397
|
+
)
|
|
27398
|
+
]);
|
|
27399
|
+
downloadLocks.set(lockKey, {
|
|
27400
|
+
promise: downloadPromise,
|
|
27401
|
+
timestamp: Date.now()
|
|
27402
|
+
});
|
|
27403
|
+
try {
|
|
27404
|
+
const result = await downloadPromise;
|
|
27405
|
+
return result;
|
|
27406
|
+
} finally {
|
|
27407
|
+
downloadLocks.delete(lockKey);
|
|
27408
|
+
}
|
|
27409
|
+
}
|
|
27271
27410
|
function detectOsArch() {
|
|
27272
27411
|
const osType = import_os2.default.platform();
|
|
27273
27412
|
const archType = import_os2.default.arch();
|
|
@@ -27711,16 +27850,64 @@ async function getPackageVersion() {
|
|
|
27711
27850
|
return "0.0.0";
|
|
27712
27851
|
}
|
|
27713
27852
|
}
|
|
27853
|
+
async function doDownload(version) {
|
|
27854
|
+
const localDir = await getPackageBinDir();
|
|
27855
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27856
|
+
console.log(`Downloading probe binary (version: ${version || "latest"})...`);
|
|
27857
|
+
console.log(`Using binary directory: ${localDir}`);
|
|
27858
|
+
}
|
|
27859
|
+
const isWindows = import_os2.default.platform() === "win32";
|
|
27860
|
+
const binaryName = isWindows ? `${BINARY_NAME}.exe` : `${BINARY_NAME}-binary`;
|
|
27861
|
+
const binaryPath = import_path2.default.join(localDir, binaryName);
|
|
27862
|
+
const { os: osInfo, arch: archInfo } = detectOsArch();
|
|
27863
|
+
let versionToUse = version;
|
|
27864
|
+
let bestAsset;
|
|
27865
|
+
let tagVersion;
|
|
27866
|
+
if (!versionToUse || versionToUse === "0.0.0") {
|
|
27867
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27868
|
+
console.log("No specific version requested, will use the latest release");
|
|
27869
|
+
}
|
|
27870
|
+
const { tag: tag2, assets } = await getLatestRelease(void 0);
|
|
27871
|
+
tagVersion = tag2.startsWith("v") ? tag2.substring(1) : tag2;
|
|
27872
|
+
bestAsset = findBestAsset(assets, osInfo, archInfo);
|
|
27873
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27874
|
+
console.log(`Found release version: ${tagVersion}`);
|
|
27875
|
+
}
|
|
27876
|
+
} else {
|
|
27877
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27878
|
+
console.log(`Direct download for version: ${versionToUse}`);
|
|
27879
|
+
}
|
|
27880
|
+
tagVersion = versionToUse;
|
|
27881
|
+
bestAsset = constructAssetInfo(versionToUse, osInfo, archInfo);
|
|
27882
|
+
}
|
|
27883
|
+
const { assetPath, checksumPath } = await downloadAsset(bestAsset, localDir);
|
|
27884
|
+
const checksumValid = await verifyChecksum(assetPath, checksumPath);
|
|
27885
|
+
if (!checksumValid) {
|
|
27886
|
+
throw new Error("Checksum verification failed");
|
|
27887
|
+
}
|
|
27888
|
+
const extractedBinaryPath = await extractBinary(assetPath, localDir);
|
|
27889
|
+
await saveVersionInfo(tagVersion, localDir);
|
|
27890
|
+
try {
|
|
27891
|
+
await import_fs_extra2.default.remove(assetPath);
|
|
27892
|
+
if (checksumPath) {
|
|
27893
|
+
await import_fs_extra2.default.remove(checksumPath);
|
|
27894
|
+
}
|
|
27895
|
+
} catch (err) {
|
|
27896
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27897
|
+
console.log(`Warning: Could not clean up temporary files: ${err}`);
|
|
27898
|
+
}
|
|
27899
|
+
}
|
|
27900
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27901
|
+
console.log(`Binary successfully installed at ${extractedBinaryPath} (version: ${tagVersion})`);
|
|
27902
|
+
}
|
|
27903
|
+
return extractedBinaryPath;
|
|
27904
|
+
}
|
|
27714
27905
|
async function downloadProbeBinary(version) {
|
|
27715
27906
|
try {
|
|
27716
27907
|
const localDir = await getPackageBinDir();
|
|
27717
27908
|
if (!version || version === "0.0.0") {
|
|
27718
27909
|
version = await getPackageVersion();
|
|
27719
27910
|
}
|
|
27720
|
-
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27721
|
-
console.log(`Downloading probe binary (version: ${version || "latest"})...`);
|
|
27722
|
-
console.log(`Using binary directory: ${localDir}`);
|
|
27723
|
-
}
|
|
27724
27911
|
const isWindows = import_os2.default.platform() === "win32";
|
|
27725
27912
|
const binaryName = isWindows ? `${BINARY_NAME}.exe` : `${BINARY_NAME}-binary`;
|
|
27726
27913
|
const binaryPath = import_path2.default.join(localDir, binaryName);
|
|
@@ -27736,54 +27923,44 @@ async function downloadProbeBinary(version) {
|
|
|
27736
27923
|
console.log(`Existing binary version (${versionInfo?.version || "unknown"}) doesn't match requested version (${version}). Downloading new version...`);
|
|
27737
27924
|
}
|
|
27738
27925
|
}
|
|
27739
|
-
const
|
|
27740
|
-
|
|
27741
|
-
let
|
|
27742
|
-
|
|
27743
|
-
|
|
27744
|
-
|
|
27745
|
-
|
|
27746
|
-
|
|
27747
|
-
|
|
27748
|
-
|
|
27749
|
-
|
|
27750
|
-
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27751
|
-
console.log(`Found release version: ${tagVersion}`);
|
|
27926
|
+
const lockPath = import_path2.default.join(localDir, `.probe-download-${version}.lock`);
|
|
27927
|
+
const maxRetries = 3;
|
|
27928
|
+
for (let retry = 0; retry < maxRetries; retry++) {
|
|
27929
|
+
const lockAcquired = await acquireFileLock(lockPath, version);
|
|
27930
|
+
if (lockAcquired === true) {
|
|
27931
|
+
try {
|
|
27932
|
+
const result = await withDownloadLock(version, () => doDownload(version));
|
|
27933
|
+
return result;
|
|
27934
|
+
} finally {
|
|
27935
|
+
await releaseFileLock(lockPath);
|
|
27936
|
+
}
|
|
27752
27937
|
}
|
|
27753
|
-
|
|
27754
|
-
|
|
27755
|
-
|
|
27938
|
+
if (lockAcquired === null) {
|
|
27939
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27940
|
+
console.log(`File-based locking unavailable, downloading without cross-process coordination`);
|
|
27941
|
+
}
|
|
27942
|
+
return await withDownloadLock(version, () => doDownload(version));
|
|
27756
27943
|
}
|
|
27757
|
-
|
|
27758
|
-
|
|
27759
|
-
|
|
27760
|
-
const { assetPath, checksumPath } = await downloadAsset(bestAsset, localDir);
|
|
27761
|
-
const checksumValid = await verifyChecksum(assetPath, checksumPath);
|
|
27762
|
-
if (!checksumValid) {
|
|
27763
|
-
throw new Error("Checksum verification failed");
|
|
27764
|
-
}
|
|
27765
|
-
const extractedBinaryPath = await extractBinary(assetPath, localDir);
|
|
27766
|
-
await saveVersionInfo(tagVersion, localDir);
|
|
27767
|
-
try {
|
|
27768
|
-
await import_fs_extra2.default.remove(assetPath);
|
|
27769
|
-
if (checksumPath) {
|
|
27770
|
-
await import_fs_extra2.default.remove(checksumPath);
|
|
27944
|
+
const downloadCompleted = await waitForFileLock(lockPath, binaryPath);
|
|
27945
|
+
if (downloadCompleted) {
|
|
27946
|
+
return binaryPath;
|
|
27771
27947
|
}
|
|
27772
|
-
|
|
27773
|
-
|
|
27774
|
-
|
|
27948
|
+
if (retry < maxRetries - 1) {
|
|
27949
|
+
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27950
|
+
console.log(`Retrying download (attempt ${retry + 2}/${maxRetries})...`);
|
|
27951
|
+
}
|
|
27775
27952
|
}
|
|
27776
27953
|
}
|
|
27777
27954
|
if (process.env.DEBUG === "1" || process.env.VERBOSE === "1") {
|
|
27778
|
-
console.log(`
|
|
27955
|
+
console.log(`All lock attempts exhausted, attempting direct download`);
|
|
27779
27956
|
}
|
|
27780
|
-
return
|
|
27957
|
+
return await withDownloadLock(version, () => doDownload(version));
|
|
27781
27958
|
} catch (error2) {
|
|
27782
27959
|
console.error("Error downloading probe binary:", error2);
|
|
27783
27960
|
throw error2;
|
|
27784
27961
|
}
|
|
27785
27962
|
}
|
|
27786
|
-
var import_axios, import_fs_extra2, import_path2, import_crypto, import_util3, import_child_process, import_tar, import_os2, import_url2, exec, REPO_OWNER, REPO_NAME, BINARY_NAME, __filename2, __dirname2;
|
|
27963
|
+
var import_axios, import_fs_extra2, import_path2, import_crypto, import_util3, import_child_process, import_tar, import_os2, import_url2, exec, REPO_OWNER, REPO_NAME, BINARY_NAME, __filename2, __dirname2, downloadLocks, LOCK_TIMEOUT_MS, LOCK_POLL_INTERVAL_MS, MAX_LOCK_WAIT_MS;
|
|
27787
27964
|
var init_downloader = __esm({
|
|
27788
27965
|
"src/downloader.js"() {
|
|
27789
27966
|
"use strict";
|
|
@@ -27804,19 +27981,25 @@ var init_downloader = __esm({
|
|
|
27804
27981
|
BINARY_NAME = "probe";
|
|
27805
27982
|
__filename2 = (0, import_url2.fileURLToPath)("file:///");
|
|
27806
27983
|
__dirname2 = import_path2.default.dirname(__filename2);
|
|
27984
|
+
downloadLocks = /* @__PURE__ */ new Map();
|
|
27985
|
+
LOCK_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
27986
|
+
LOCK_POLL_INTERVAL_MS = 1e3;
|
|
27987
|
+
MAX_LOCK_WAIT_MS = 5 * 60 * 1e3;
|
|
27807
27988
|
}
|
|
27808
27989
|
});
|
|
27809
27990
|
|
|
27810
27991
|
// src/utils.js
|
|
27811
27992
|
async function getBinaryPath(options = {}) {
|
|
27812
27993
|
const { forceDownload = false, version } = options;
|
|
27813
|
-
if (probeBinaryPath && !forceDownload && import_fs_extra3.default.existsSync(probeBinaryPath)) {
|
|
27814
|
-
return probeBinaryPath;
|
|
27815
|
-
}
|
|
27816
27994
|
if (process.env.PROBE_PATH && import_fs_extra3.default.existsSync(process.env.PROBE_PATH) && !forceDownload) {
|
|
27817
27995
|
probeBinaryPath = process.env.PROBE_PATH;
|
|
27818
27996
|
return probeBinaryPath;
|
|
27819
27997
|
}
|
|
27998
|
+
if (version && !forceDownload) {
|
|
27999
|
+
console.log(`Specific version ${version} requested. Downloading...`);
|
|
28000
|
+
probeBinaryPath = await downloadProbeBinary(version);
|
|
28001
|
+
return probeBinaryPath;
|
|
28002
|
+
}
|
|
27820
28003
|
const binDir = await getPackageBinDir();
|
|
27821
28004
|
const isWindows = process.platform === "win32";
|
|
27822
28005
|
const binaryName = isWindows ? "probe.exe" : "probe-binary";
|
|
@@ -27922,17 +28105,20 @@ Search: query="${queries[0]}" path="${options.path}"`;
|
|
|
27922
28105
|
if (options.session) logMessage += ` session=${options.session}`;
|
|
27923
28106
|
console.error(logMessage);
|
|
27924
28107
|
}
|
|
27925
|
-
const
|
|
28108
|
+
const args = ["search", ...cliArgs];
|
|
27926
28109
|
if (queries.length > 0) {
|
|
27927
|
-
|
|
28110
|
+
args.push(queries[0]);
|
|
28111
|
+
}
|
|
28112
|
+
args.push(options.path);
|
|
28113
|
+
if (process.env.DEBUG === "1") {
|
|
28114
|
+
console.error(`Executing: ${binaryPath} ${args.join(" ")}`);
|
|
27928
28115
|
}
|
|
27929
|
-
positionalArgs.push(escapeString(options.path));
|
|
27930
|
-
const command = `${binaryPath} search ${cliArgs.join(" ")} ${positionalArgs.join(" ")}`;
|
|
27931
28116
|
try {
|
|
27932
|
-
const { stdout, stderr } = await
|
|
27933
|
-
|
|
27934
|
-
timeout: options.timeout * 1e3
|
|
28117
|
+
const { stdout, stderr } = await execFileAsync(binaryPath, args, {
|
|
28118
|
+
timeout: options.timeout * 1e3,
|
|
27935
28119
|
// Convert seconds to milliseconds
|
|
28120
|
+
maxBuffer: 50 * 1024 * 1024
|
|
28121
|
+
// 50MB buffer for large outputs
|
|
27936
28122
|
});
|
|
27937
28123
|
if (stderr && process.env.DEBUG) {
|
|
27938
28124
|
console.error(`stderr: ${stderr}`);
|
|
@@ -27981,23 +28167,25 @@ Search results: ${resultCount} matches, ${tokenCount} tokens`;
|
|
|
27981
28167
|
} catch (error2) {
|
|
27982
28168
|
if (error2.code === "ETIMEDOUT" || error2.killed) {
|
|
27983
28169
|
const timeoutMessage = `Search operation timed out after ${options.timeout} seconds.
|
|
27984
|
-
|
|
28170
|
+
Binary: ${binaryPath}
|
|
28171
|
+
Args: ${args.join(" ")}`;
|
|
27985
28172
|
console.error(timeoutMessage);
|
|
27986
28173
|
throw new Error(timeoutMessage);
|
|
27987
28174
|
}
|
|
27988
28175
|
const errorMessage = `Error executing search command: ${error2.message}
|
|
27989
|
-
|
|
28176
|
+
Binary: ${binaryPath}
|
|
28177
|
+
Args: ${args.join(" ")}`;
|
|
27990
28178
|
throw new Error(errorMessage);
|
|
27991
28179
|
}
|
|
27992
28180
|
}
|
|
27993
|
-
var import_child_process2, import_util4,
|
|
28181
|
+
var import_child_process2, import_util4, execFileAsync, SEARCH_FLAG_MAP;
|
|
27994
28182
|
var init_search = __esm({
|
|
27995
28183
|
"src/search.js"() {
|
|
27996
28184
|
"use strict";
|
|
27997
28185
|
import_child_process2 = require("child_process");
|
|
27998
28186
|
import_util4 = require("util");
|
|
27999
28187
|
init_utils2();
|
|
28000
|
-
|
|
28188
|
+
execFileAsync = (0, import_util4.promisify)(import_child_process2.execFile);
|
|
28001
28189
|
SEARCH_FLAG_MAP = {
|
|
28002
28190
|
filesOnly: "--files-only",
|
|
28003
28191
|
ignore: "--ignore",
|
|
@@ -28005,6 +28193,7 @@ var init_search = __esm({
|
|
|
28005
28193
|
reranker: "--reranker",
|
|
28006
28194
|
frequencySearch: "--frequency",
|
|
28007
28195
|
exact: "--exact",
|
|
28196
|
+
strictElasticSyntax: "--strict-elastic-syntax",
|
|
28008
28197
|
maxResults: "--max-results",
|
|
28009
28198
|
maxBytes: "--max-bytes",
|
|
28010
28199
|
maxTokens: "--max-tokens",
|
|
@@ -28042,7 +28231,7 @@ async function query(options) {
|
|
|
28042
28231
|
}
|
|
28043
28232
|
const command = `${binaryPath} query ${cliArgs.join(" ")}`;
|
|
28044
28233
|
try {
|
|
28045
|
-
const { stdout, stderr } = await
|
|
28234
|
+
const { stdout, stderr } = await execAsync(command);
|
|
28046
28235
|
if (stderr) {
|
|
28047
28236
|
console.error(`stderr: ${stderr}`);
|
|
28048
28237
|
}
|
|
@@ -28071,14 +28260,14 @@ Command: ${command}`;
|
|
|
28071
28260
|
throw new Error(errorMessage);
|
|
28072
28261
|
}
|
|
28073
28262
|
}
|
|
28074
|
-
var import_child_process3, import_util5,
|
|
28263
|
+
var import_child_process3, import_util5, execAsync, QUERY_FLAG_MAP;
|
|
28075
28264
|
var init_query = __esm({
|
|
28076
28265
|
"src/query.js"() {
|
|
28077
28266
|
"use strict";
|
|
28078
28267
|
import_child_process3 = require("child_process");
|
|
28079
28268
|
import_util5 = require("util");
|
|
28080
28269
|
init_utils2();
|
|
28081
|
-
|
|
28270
|
+
execAsync = (0, import_util5.promisify)(import_child_process3.exec);
|
|
28082
28271
|
QUERY_FLAG_MAP = {
|
|
28083
28272
|
language: "--language",
|
|
28084
28273
|
ignore: "--ignore",
|
|
@@ -28131,7 +28320,7 @@ Extract:`;
|
|
|
28131
28320
|
}
|
|
28132
28321
|
const command = `${binaryPath} extract ${cliArgs.join(" ")}`;
|
|
28133
28322
|
try {
|
|
28134
|
-
const { stdout, stderr } = await
|
|
28323
|
+
const { stdout, stderr } = await execAsync2(command);
|
|
28135
28324
|
if (stderr) {
|
|
28136
28325
|
console.error(`stderr: ${stderr}`);
|
|
28137
28326
|
}
|
|
@@ -28229,14 +28418,14 @@ Token Usage:
|
|
|
28229
28418
|
}
|
|
28230
28419
|
return output;
|
|
28231
28420
|
}
|
|
28232
|
-
var import_child_process4, import_util6,
|
|
28421
|
+
var import_child_process4, import_util6, execAsync2, EXTRACT_FLAG_MAP;
|
|
28233
28422
|
var init_extract = __esm({
|
|
28234
28423
|
"src/extract.js"() {
|
|
28235
28424
|
"use strict";
|
|
28236
28425
|
import_child_process4 = require("child_process");
|
|
28237
28426
|
import_util6 = require("util");
|
|
28238
28427
|
init_utils2();
|
|
28239
|
-
|
|
28428
|
+
execAsync2 = (0, import_util6.promisify)(import_child_process4.exec);
|
|
28240
28429
|
EXTRACT_FLAG_MAP = {
|
|
28241
28430
|
allowTests: "--allow-tests",
|
|
28242
28431
|
contextLines: "--context",
|
|
@@ -28247,14 +28436,14 @@ var init_extract = __esm({
|
|
|
28247
28436
|
});
|
|
28248
28437
|
|
|
28249
28438
|
// src/grep.js
|
|
28250
|
-
var import_child_process5, import_util7,
|
|
28439
|
+
var import_child_process5, import_util7, execFileAsync2;
|
|
28251
28440
|
var init_grep = __esm({
|
|
28252
28441
|
"src/grep.js"() {
|
|
28253
28442
|
"use strict";
|
|
28254
28443
|
import_child_process5 = require("child_process");
|
|
28255
28444
|
import_util7 = require("util");
|
|
28256
28445
|
init_utils2();
|
|
28257
|
-
|
|
28446
|
+
execFileAsync2 = (0, import_util7.promisify)(import_child_process5.execFile);
|
|
28258
28447
|
}
|
|
28259
28448
|
});
|
|
28260
28449
|
|
|
@@ -34540,7 +34729,7 @@ async function listFilesByLevel(options) {
|
|
|
34540
34729
|
return await listFilesByLevelManually(directory, maxFiles, respectGitignore);
|
|
34541
34730
|
}
|
|
34542
34731
|
async function listFilesUsingGit(directory, maxFiles) {
|
|
34543
|
-
const { stdout } = await
|
|
34732
|
+
const { stdout } = await execAsync3("git ls-files", { cwd: directory });
|
|
34544
34733
|
const files = stdout.split("\n").filter(Boolean);
|
|
34545
34734
|
const sortedFiles = files.sort((a3, b3) => {
|
|
34546
34735
|
const depthA = a3.split(import_path6.default.sep).length;
|
|
@@ -34606,7 +34795,7 @@ function shouldIgnore(filePath, ignorePatterns) {
|
|
|
34606
34795
|
}
|
|
34607
34796
|
return false;
|
|
34608
34797
|
}
|
|
34609
|
-
var import_fs2, import_path6, import_util11, import_child_process8,
|
|
34798
|
+
var import_fs2, import_path6, import_util11, import_child_process8, execAsync3;
|
|
34610
34799
|
var init_file_lister = __esm({
|
|
34611
34800
|
"src/utils/file-lister.js"() {
|
|
34612
34801
|
"use strict";
|
|
@@ -34614,7 +34803,7 @@ var init_file_lister = __esm({
|
|
|
34614
34803
|
import_path6 = __toESM(require("path"), 1);
|
|
34615
34804
|
import_util11 = require("util");
|
|
34616
34805
|
import_child_process8 = require("child_process");
|
|
34617
|
-
|
|
34806
|
+
execAsync3 = (0, import_util11.promisify)(import_child_process8.exec);
|
|
34618
34807
|
}
|
|
34619
34808
|
});
|
|
34620
34809
|
|