raggrep 0.10.2 → 0.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/indexer/index.d.ts +25 -0
- package/dist/cli/main.js +690 -88
- package/dist/cli/main.js.map +6 -5
- package/dist/index.js +688 -82
- package/dist/index.js.map +5 -4
- package/package.json +2 -1
package/dist/cli/main.js
CHANGED
|
@@ -327,6 +327,511 @@ function createSilentLogger() {
|
|
|
327
327
|
|
|
328
328
|
// src/infrastructure/logger/index.ts
|
|
329
329
|
var init_logger = () => {};
|
|
330
|
+
|
|
331
|
+
// node_modules/fdir/dist/index.mjs
|
|
332
|
+
import { createRequire as createRequire2 } from "module";
|
|
333
|
+
import { basename, dirname, normalize, relative, resolve, sep } from "path";
|
|
334
|
+
import * as nativeFs from "fs";
|
|
335
|
+
function cleanPath(path2) {
|
|
336
|
+
let normalized = normalize(path2);
|
|
337
|
+
if (normalized.length > 1 && normalized[normalized.length - 1] === sep)
|
|
338
|
+
normalized = normalized.substring(0, normalized.length - 1);
|
|
339
|
+
return normalized;
|
|
340
|
+
}
|
|
341
|
+
function convertSlashes(path2, separator) {
|
|
342
|
+
return path2.replace(SLASHES_REGEX, separator);
|
|
343
|
+
}
|
|
344
|
+
function isRootDirectory(path2) {
|
|
345
|
+
return path2 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path2);
|
|
346
|
+
}
|
|
347
|
+
function normalizePath(path2, options) {
|
|
348
|
+
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
349
|
+
const pathNeedsCleaning = process.platform === "win32" && path2.includes("/") || path2.startsWith(".");
|
|
350
|
+
if (resolvePaths)
|
|
351
|
+
path2 = resolve(path2);
|
|
352
|
+
if (normalizePath$1 || pathNeedsCleaning)
|
|
353
|
+
path2 = cleanPath(path2);
|
|
354
|
+
if (path2 === ".")
|
|
355
|
+
return "";
|
|
356
|
+
const needsSeperator = path2[path2.length - 1] !== pathSeparator;
|
|
357
|
+
return convertSlashes(needsSeperator ? path2 + pathSeparator : path2, pathSeparator);
|
|
358
|
+
}
|
|
359
|
+
function joinPathWithBasePath(filename, directoryPath) {
|
|
360
|
+
return directoryPath + filename;
|
|
361
|
+
}
|
|
362
|
+
function joinPathWithRelativePath(root, options) {
|
|
363
|
+
return function(filename, directoryPath) {
|
|
364
|
+
const sameRoot = directoryPath.startsWith(root);
|
|
365
|
+
if (sameRoot)
|
|
366
|
+
return directoryPath.slice(root.length) + filename;
|
|
367
|
+
else
|
|
368
|
+
return convertSlashes(relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
function joinPath(filename) {
|
|
372
|
+
return filename;
|
|
373
|
+
}
|
|
374
|
+
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
375
|
+
return directoryPath + filename + separator;
|
|
376
|
+
}
|
|
377
|
+
function build$7(root, options) {
|
|
378
|
+
const { relativePaths, includeBasePath } = options;
|
|
379
|
+
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
|
|
380
|
+
}
|
|
381
|
+
function pushDirectoryWithRelativePath(root) {
|
|
382
|
+
return function(directoryPath, paths) {
|
|
383
|
+
paths.push(directoryPath.substring(root.length) || ".");
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
function pushDirectoryFilterWithRelativePath(root) {
|
|
387
|
+
return function(directoryPath, paths, filters) {
|
|
388
|
+
const relativePath = directoryPath.substring(root.length) || ".";
|
|
389
|
+
if (filters.every((filter) => filter(relativePath, true)))
|
|
390
|
+
paths.push(relativePath);
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
function build$6(root, options) {
|
|
394
|
+
const { includeDirs, filters, relativePaths } = options;
|
|
395
|
+
if (!includeDirs)
|
|
396
|
+
return empty$2;
|
|
397
|
+
if (relativePaths)
|
|
398
|
+
return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
399
|
+
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
|
|
400
|
+
}
|
|
401
|
+
function build$5(options) {
|
|
402
|
+
const { excludeFiles, filters, onlyCounts } = options;
|
|
403
|
+
if (excludeFiles)
|
|
404
|
+
return empty$1;
|
|
405
|
+
if (filters && filters.length)
|
|
406
|
+
return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
407
|
+
else if (onlyCounts)
|
|
408
|
+
return pushFileCount;
|
|
409
|
+
else
|
|
410
|
+
return pushFile;
|
|
411
|
+
}
|
|
412
|
+
function build$4(options) {
|
|
413
|
+
return options.group ? getArrayGroup : getArray;
|
|
414
|
+
}
|
|
415
|
+
function build$3(options) {
|
|
416
|
+
return options.group ? groupFiles : empty;
|
|
417
|
+
}
|
|
418
|
+
function build$2(options, isSynchronous) {
|
|
419
|
+
if (!options.resolveSymlinks || options.excludeSymlinks)
|
|
420
|
+
return null;
|
|
421
|
+
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
422
|
+
}
|
|
423
|
+
function isRecursive(path2, resolved, state) {
|
|
424
|
+
if (state.options.useRealPaths)
|
|
425
|
+
return isRecursiveUsingRealPaths(resolved, state);
|
|
426
|
+
let parent = dirname(path2);
|
|
427
|
+
let depth = 1;
|
|
428
|
+
while (parent !== state.root && depth < 2) {
|
|
429
|
+
const resolvedPath = state.symlinks.get(parent);
|
|
430
|
+
const isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));
|
|
431
|
+
if (isSameRoot)
|
|
432
|
+
depth++;
|
|
433
|
+
else
|
|
434
|
+
parent = dirname(parent);
|
|
435
|
+
}
|
|
436
|
+
state.symlinks.set(path2, resolved);
|
|
437
|
+
return depth > 1;
|
|
438
|
+
}
|
|
439
|
+
function isRecursiveUsingRealPaths(resolved, state) {
|
|
440
|
+
return state.visited.includes(resolved + state.options.pathSeparator);
|
|
441
|
+
}
|
|
442
|
+
function report(error, callback$1, output, suppressErrors) {
|
|
443
|
+
if (error && !suppressErrors)
|
|
444
|
+
callback$1(error, output);
|
|
445
|
+
else
|
|
446
|
+
callback$1(null, output);
|
|
447
|
+
}
|
|
448
|
+
function build$1(options, isSynchronous) {
|
|
449
|
+
const { onlyCounts, group, maxFiles } = options;
|
|
450
|
+
if (onlyCounts)
|
|
451
|
+
return isSynchronous ? onlyCountsSync : onlyCountsAsync;
|
|
452
|
+
else if (group)
|
|
453
|
+
return isSynchronous ? groupsSync : groupsAsync;
|
|
454
|
+
else if (maxFiles)
|
|
455
|
+
return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
456
|
+
else
|
|
457
|
+
return isSynchronous ? defaultSync : defaultAsync;
|
|
458
|
+
}
|
|
459
|
+
function build(isSynchronous) {
|
|
460
|
+
return isSynchronous ? walkSync : walkAsync;
|
|
461
|
+
}
|
|
462
|
+
function promise(root, options) {
|
|
463
|
+
return new Promise((resolve$1, reject) => {
|
|
464
|
+
callback(root, options, (err2, output) => {
|
|
465
|
+
if (err2)
|
|
466
|
+
return reject(err2);
|
|
467
|
+
resolve$1(output);
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
function callback(root, options, callback$1) {
|
|
472
|
+
let walker = new Walker(root, options, callback$1);
|
|
473
|
+
walker.start();
|
|
474
|
+
}
|
|
475
|
+
function sync(root, options) {
|
|
476
|
+
const walker = new Walker(root, options);
|
|
477
|
+
return walker.start();
|
|
478
|
+
}
|
|
479
|
+
var __require2, SLASHES_REGEX, WINDOWS_ROOT_DIR_REGEX, pushDirectory = (directoryPath, paths) => {
|
|
480
|
+
paths.push(directoryPath || ".");
|
|
481
|
+
}, pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
482
|
+
const path2 = directoryPath || ".";
|
|
483
|
+
if (filters.every((filter) => filter(path2, true)))
|
|
484
|
+
paths.push(path2);
|
|
485
|
+
}, empty$2 = () => {}, pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
486
|
+
if (filters.every((filter) => filter(filename, false)))
|
|
487
|
+
counts.files++;
|
|
488
|
+
}, pushFileFilter = (filename, paths, _counts, filters) => {
|
|
489
|
+
if (filters.every((filter) => filter(filename, false)))
|
|
490
|
+
paths.push(filename);
|
|
491
|
+
}, pushFileCount = (_filename, _paths, counts, _filters) => {
|
|
492
|
+
counts.files++;
|
|
493
|
+
}, pushFile = (filename, paths) => {
|
|
494
|
+
paths.push(filename);
|
|
495
|
+
}, empty$1 = () => {}, getArray = (paths) => {
|
|
496
|
+
return paths;
|
|
497
|
+
}, getArrayGroup = () => {
|
|
498
|
+
return [""].slice(0, 0);
|
|
499
|
+
}, groupFiles = (groups, directory, files) => {
|
|
500
|
+
groups.push({
|
|
501
|
+
directory,
|
|
502
|
+
files,
|
|
503
|
+
dir: directory
|
|
504
|
+
});
|
|
505
|
+
}, empty = () => {}, resolveSymlinksAsync = function(path2, state, callback$1) {
|
|
506
|
+
const { queue, fs: fs2, options: { suppressErrors } } = state;
|
|
507
|
+
queue.enqueue();
|
|
508
|
+
fs2.realpath(path2, (error, resolvedPath) => {
|
|
509
|
+
if (error)
|
|
510
|
+
return queue.dequeue(suppressErrors ? null : error, state);
|
|
511
|
+
fs2.stat(resolvedPath, (error$1, stat) => {
|
|
512
|
+
if (error$1)
|
|
513
|
+
return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
514
|
+
if (stat.isDirectory() && isRecursive(path2, resolvedPath, state))
|
|
515
|
+
return queue.dequeue(null, state);
|
|
516
|
+
callback$1(stat, resolvedPath);
|
|
517
|
+
queue.dequeue(null, state);
|
|
518
|
+
});
|
|
519
|
+
});
|
|
520
|
+
}, resolveSymlinks = function(path2, state, callback$1) {
|
|
521
|
+
const { queue, fs: fs2, options: { suppressErrors } } = state;
|
|
522
|
+
queue.enqueue();
|
|
523
|
+
try {
|
|
524
|
+
const resolvedPath = fs2.realpathSync(path2);
|
|
525
|
+
const stat = fs2.statSync(resolvedPath);
|
|
526
|
+
if (stat.isDirectory() && isRecursive(path2, resolvedPath, state))
|
|
527
|
+
return;
|
|
528
|
+
callback$1(stat, resolvedPath);
|
|
529
|
+
} catch (e) {
|
|
530
|
+
if (!suppressErrors)
|
|
531
|
+
throw e;
|
|
532
|
+
}
|
|
533
|
+
}, onlyCountsSync = (state) => {
|
|
534
|
+
return state.counts;
|
|
535
|
+
}, groupsSync = (state) => {
|
|
536
|
+
return state.groups;
|
|
537
|
+
}, defaultSync = (state) => {
|
|
538
|
+
return state.paths;
|
|
539
|
+
}, limitFilesSync = (state) => {
|
|
540
|
+
return state.paths.slice(0, state.options.maxFiles);
|
|
541
|
+
}, onlyCountsAsync = (state, error, callback$1) => {
|
|
542
|
+
report(error, callback$1, state.counts, state.options.suppressErrors);
|
|
543
|
+
return null;
|
|
544
|
+
}, defaultAsync = (state, error, callback$1) => {
|
|
545
|
+
report(error, callback$1, state.paths, state.options.suppressErrors);
|
|
546
|
+
return null;
|
|
547
|
+
}, limitFilesAsync = (state, error, callback$1) => {
|
|
548
|
+
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
549
|
+
return null;
|
|
550
|
+
}, groupsAsync = (state, error, callback$1) => {
|
|
551
|
+
report(error, callback$1, state.groups, state.options.suppressErrors);
|
|
552
|
+
return null;
|
|
553
|
+
}, readdirOpts, walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
554
|
+
state.queue.enqueue();
|
|
555
|
+
if (currentDepth < 0)
|
|
556
|
+
return state.queue.dequeue(null, state);
|
|
557
|
+
const { fs: fs2 } = state;
|
|
558
|
+
state.visited.push(crawlPath);
|
|
559
|
+
state.counts.directories++;
|
|
560
|
+
fs2.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
561
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
562
|
+
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
563
|
+
});
|
|
564
|
+
}, walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
565
|
+
const { fs: fs2 } = state;
|
|
566
|
+
if (currentDepth < 0)
|
|
567
|
+
return;
|
|
568
|
+
state.visited.push(crawlPath);
|
|
569
|
+
state.counts.directories++;
|
|
570
|
+
let entries = [];
|
|
571
|
+
try {
|
|
572
|
+
entries = fs2.readdirSync(crawlPath || ".", readdirOpts);
|
|
573
|
+
} catch (e) {
|
|
574
|
+
if (!state.options.suppressErrors)
|
|
575
|
+
throw e;
|
|
576
|
+
}
|
|
577
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
578
|
+
}, Queue = class {
|
|
579
|
+
count = 0;
|
|
580
|
+
constructor(onQueueEmpty) {
|
|
581
|
+
this.onQueueEmpty = onQueueEmpty;
|
|
582
|
+
}
|
|
583
|
+
enqueue() {
|
|
584
|
+
this.count++;
|
|
585
|
+
return this.count;
|
|
586
|
+
}
|
|
587
|
+
dequeue(error, output) {
|
|
588
|
+
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
|
589
|
+
this.onQueueEmpty(error, output);
|
|
590
|
+
if (error) {
|
|
591
|
+
output.controller.abort();
|
|
592
|
+
this.onQueueEmpty = undefined;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}, Counter = class {
|
|
597
|
+
_files = 0;
|
|
598
|
+
_directories = 0;
|
|
599
|
+
set files(num) {
|
|
600
|
+
this._files = num;
|
|
601
|
+
}
|
|
602
|
+
get files() {
|
|
603
|
+
return this._files;
|
|
604
|
+
}
|
|
605
|
+
set directories(num) {
|
|
606
|
+
this._directories = num;
|
|
607
|
+
}
|
|
608
|
+
get directories() {
|
|
609
|
+
return this._directories;
|
|
610
|
+
}
|
|
611
|
+
get dirs() {
|
|
612
|
+
return this._directories;
|
|
613
|
+
}
|
|
614
|
+
}, Aborter = class {
|
|
615
|
+
aborted = false;
|
|
616
|
+
abort() {
|
|
617
|
+
this.aborted = true;
|
|
618
|
+
}
|
|
619
|
+
}, Walker = class {
|
|
620
|
+
root;
|
|
621
|
+
isSynchronous;
|
|
622
|
+
state;
|
|
623
|
+
joinPath;
|
|
624
|
+
pushDirectory;
|
|
625
|
+
pushFile;
|
|
626
|
+
getArray;
|
|
627
|
+
groupFiles;
|
|
628
|
+
resolveSymlink;
|
|
629
|
+
walkDirectory;
|
|
630
|
+
callbackInvoker;
|
|
631
|
+
constructor(root, options, callback$1) {
|
|
632
|
+
this.isSynchronous = !callback$1;
|
|
633
|
+
this.callbackInvoker = build$1(options, this.isSynchronous);
|
|
634
|
+
this.root = normalizePath(root, options);
|
|
635
|
+
this.state = {
|
|
636
|
+
root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
|
|
637
|
+
paths: [""].slice(0, 0),
|
|
638
|
+
groups: [],
|
|
639
|
+
counts: new Counter,
|
|
640
|
+
options,
|
|
641
|
+
queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
|
|
642
|
+
symlinks: /* @__PURE__ */ new Map,
|
|
643
|
+
visited: [""].slice(0, 0),
|
|
644
|
+
controller: new Aborter,
|
|
645
|
+
fs: options.fs || nativeFs
|
|
646
|
+
};
|
|
647
|
+
this.joinPath = build$7(this.root, options);
|
|
648
|
+
this.pushDirectory = build$6(this.root, options);
|
|
649
|
+
this.pushFile = build$5(options);
|
|
650
|
+
this.getArray = build$4(options);
|
|
651
|
+
this.groupFiles = build$3(options);
|
|
652
|
+
this.resolveSymlink = build$2(options, this.isSynchronous);
|
|
653
|
+
this.walkDirectory = build(this.isSynchronous);
|
|
654
|
+
}
|
|
655
|
+
start() {
|
|
656
|
+
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
657
|
+
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
658
|
+
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
659
|
+
}
|
|
660
|
+
walk = (entries, directoryPath, depth) => {
|
|
661
|
+
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
|
|
662
|
+
if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles)
|
|
663
|
+
return;
|
|
664
|
+
const files = this.getArray(this.state.paths);
|
|
665
|
+
for (let i2 = 0;i2 < entries.length; ++i2) {
|
|
666
|
+
const entry = entries[i2];
|
|
667
|
+
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
|
|
668
|
+
const filename = this.joinPath(entry.name, directoryPath);
|
|
669
|
+
this.pushFile(filename, files, this.state.counts, filters);
|
|
670
|
+
} else if (entry.isDirectory()) {
|
|
671
|
+
let path2 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
672
|
+
if (exclude && exclude(entry.name, path2))
|
|
673
|
+
continue;
|
|
674
|
+
this.pushDirectory(path2, paths, filters);
|
|
675
|
+
this.walkDirectory(this.state, path2, path2, depth - 1, this.walk);
|
|
676
|
+
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
677
|
+
let path2 = joinPathWithBasePath(entry.name, directoryPath);
|
|
678
|
+
this.resolveSymlink(path2, this.state, (stat, resolvedPath) => {
|
|
679
|
+
if (stat.isDirectory()) {
|
|
680
|
+
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
681
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path2 + pathSeparator))
|
|
682
|
+
return;
|
|
683
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path2 + pathSeparator, depth - 1, this.walk);
|
|
684
|
+
} else {
|
|
685
|
+
resolvedPath = useRealPaths ? resolvedPath : path2;
|
|
686
|
+
const filename = basename(resolvedPath);
|
|
687
|
+
const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options);
|
|
688
|
+
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
689
|
+
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
690
|
+
}
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
this.groupFiles(this.state.groups, directoryPath, files);
|
|
695
|
+
};
|
|
696
|
+
}, APIBuilder = class {
|
|
697
|
+
constructor(root, options) {
|
|
698
|
+
this.root = root;
|
|
699
|
+
this.options = options;
|
|
700
|
+
}
|
|
701
|
+
withPromise() {
|
|
702
|
+
return promise(this.root, this.options);
|
|
703
|
+
}
|
|
704
|
+
withCallback(cb) {
|
|
705
|
+
callback(this.root, this.options, cb);
|
|
706
|
+
}
|
|
707
|
+
sync() {
|
|
708
|
+
return sync(this.root, this.options);
|
|
709
|
+
}
|
|
710
|
+
}, pm = null, Builder = class {
|
|
711
|
+
globCache = {};
|
|
712
|
+
options = {
|
|
713
|
+
maxDepth: Infinity,
|
|
714
|
+
suppressErrors: true,
|
|
715
|
+
pathSeparator: sep,
|
|
716
|
+
filters: []
|
|
717
|
+
};
|
|
718
|
+
globFunction;
|
|
719
|
+
constructor(options) {
|
|
720
|
+
this.options = {
|
|
721
|
+
...this.options,
|
|
722
|
+
...options
|
|
723
|
+
};
|
|
724
|
+
this.globFunction = this.options.globFunction;
|
|
725
|
+
}
|
|
726
|
+
group() {
|
|
727
|
+
this.options.group = true;
|
|
728
|
+
return this;
|
|
729
|
+
}
|
|
730
|
+
withPathSeparator(separator) {
|
|
731
|
+
this.options.pathSeparator = separator;
|
|
732
|
+
return this;
|
|
733
|
+
}
|
|
734
|
+
withBasePath() {
|
|
735
|
+
this.options.includeBasePath = true;
|
|
736
|
+
return this;
|
|
737
|
+
}
|
|
738
|
+
withRelativePaths() {
|
|
739
|
+
this.options.relativePaths = true;
|
|
740
|
+
return this;
|
|
741
|
+
}
|
|
742
|
+
withDirs() {
|
|
743
|
+
this.options.includeDirs = true;
|
|
744
|
+
return this;
|
|
745
|
+
}
|
|
746
|
+
withMaxDepth(depth) {
|
|
747
|
+
this.options.maxDepth = depth;
|
|
748
|
+
return this;
|
|
749
|
+
}
|
|
750
|
+
withMaxFiles(limit) {
|
|
751
|
+
this.options.maxFiles = limit;
|
|
752
|
+
return this;
|
|
753
|
+
}
|
|
754
|
+
withFullPaths() {
|
|
755
|
+
this.options.resolvePaths = true;
|
|
756
|
+
this.options.includeBasePath = true;
|
|
757
|
+
return this;
|
|
758
|
+
}
|
|
759
|
+
withErrors() {
|
|
760
|
+
this.options.suppressErrors = false;
|
|
761
|
+
return this;
|
|
762
|
+
}
|
|
763
|
+
withSymlinks({ resolvePaths = true } = {}) {
|
|
764
|
+
this.options.resolveSymlinks = true;
|
|
765
|
+
this.options.useRealPaths = resolvePaths;
|
|
766
|
+
return this.withFullPaths();
|
|
767
|
+
}
|
|
768
|
+
withAbortSignal(signal) {
|
|
769
|
+
this.options.signal = signal;
|
|
770
|
+
return this;
|
|
771
|
+
}
|
|
772
|
+
normalize() {
|
|
773
|
+
this.options.normalizePath = true;
|
|
774
|
+
return this;
|
|
775
|
+
}
|
|
776
|
+
filter(predicate) {
|
|
777
|
+
this.options.filters.push(predicate);
|
|
778
|
+
return this;
|
|
779
|
+
}
|
|
780
|
+
onlyDirs() {
|
|
781
|
+
this.options.excludeFiles = true;
|
|
782
|
+
this.options.includeDirs = true;
|
|
783
|
+
return this;
|
|
784
|
+
}
|
|
785
|
+
exclude(predicate) {
|
|
786
|
+
this.options.exclude = predicate;
|
|
787
|
+
return this;
|
|
788
|
+
}
|
|
789
|
+
onlyCounts() {
|
|
790
|
+
this.options.onlyCounts = true;
|
|
791
|
+
return this;
|
|
792
|
+
}
|
|
793
|
+
crawl(root) {
|
|
794
|
+
return new APIBuilder(root || ".", this.options);
|
|
795
|
+
}
|
|
796
|
+
withGlobFunction(fn) {
|
|
797
|
+
this.globFunction = fn;
|
|
798
|
+
return this;
|
|
799
|
+
}
|
|
800
|
+
crawlWithOptions(root, options) {
|
|
801
|
+
this.options = {
|
|
802
|
+
...this.options,
|
|
803
|
+
...options
|
|
804
|
+
};
|
|
805
|
+
return new APIBuilder(root || ".", this.options);
|
|
806
|
+
}
|
|
807
|
+
glob(...patterns) {
|
|
808
|
+
if (this.globFunction)
|
|
809
|
+
return this.globWithOptions(patterns);
|
|
810
|
+
return this.globWithOptions(patterns, ...[{ dot: true }]);
|
|
811
|
+
}
|
|
812
|
+
globWithOptions(patterns, ...options) {
|
|
813
|
+
const globFn = this.globFunction || pm;
|
|
814
|
+
if (!globFn)
|
|
815
|
+
throw new Error("Please specify a glob function to use glob matching.");
|
|
816
|
+
var isMatch = this.globCache[patterns.join("\x00")];
|
|
817
|
+
if (!isMatch) {
|
|
818
|
+
isMatch = globFn(patterns, ...options);
|
|
819
|
+
this.globCache[patterns.join("\x00")] = isMatch;
|
|
820
|
+
}
|
|
821
|
+
this.options.filters.push((path2) => isMatch(path2));
|
|
822
|
+
return this;
|
|
823
|
+
}
|
|
824
|
+
};
|
|
825
|
+
var init_dist = __esm(() => {
|
|
826
|
+
__require2 = /* @__PURE__ */ createRequire2(import.meta.url);
|
|
827
|
+
SLASHES_REGEX = /[\\/]/g;
|
|
828
|
+
WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
829
|
+
readdirOpts = { withFileTypes: true };
|
|
830
|
+
try {
|
|
831
|
+
__require2.resolve("picomatch");
|
|
832
|
+
pm = __require2("picomatch");
|
|
833
|
+
} catch {}
|
|
834
|
+
});
|
|
330
835
|
// src/domain/entities/searchResult.ts
|
|
331
836
|
var DEFAULT_SEARCH_OPTIONS;
|
|
332
837
|
var init_searchResult = __esm(() => {
|
|
@@ -5200,8 +5705,8 @@ async function Module2(moduleArg = {}) {
|
|
|
5200
5705
|
var ENVIRONMENT_IS_WORKER = typeof WorkerGlobalScope != "undefined";
|
|
5201
5706
|
var ENVIRONMENT_IS_NODE = typeof process == "object" && process.versions?.node && process.type != "renderer";
|
|
5202
5707
|
if (ENVIRONMENT_IS_NODE) {
|
|
5203
|
-
const { createRequire:
|
|
5204
|
-
var require =
|
|
5708
|
+
const { createRequire: createRequire3 } = await import("module");
|
|
5709
|
+
var require = createRequire3(import.meta.url);
|
|
5205
5710
|
}
|
|
5206
5711
|
Module.currentQueryProgressCallback = null;
|
|
5207
5712
|
Module.currentProgressCallback = null;
|
|
@@ -5261,13 +5766,13 @@ async function Module2(moduleArg = {}) {
|
|
|
5261
5766
|
}
|
|
5262
5767
|
readAsync = /* @__PURE__ */ __name(async (url) => {
|
|
5263
5768
|
if (isFileURI(url)) {
|
|
5264
|
-
return new Promise((
|
|
5769
|
+
return new Promise((resolve3, reject) => {
|
|
5265
5770
|
var xhr = new XMLHttpRequest;
|
|
5266
5771
|
xhr.open("GET", url, true);
|
|
5267
5772
|
xhr.responseType = "arraybuffer";
|
|
5268
5773
|
xhr.onload = () => {
|
|
5269
5774
|
if (xhr.status == 200 || xhr.status == 0 && xhr.response) {
|
|
5270
|
-
|
|
5775
|
+
resolve3(xhr.response);
|
|
5271
5776
|
return;
|
|
5272
5777
|
}
|
|
5273
5778
|
reject(xhr.status);
|
|
@@ -5457,9 +5962,9 @@ async function Module2(moduleArg = {}) {
|
|
|
5457
5962
|
__name(receiveInstantiationResult, "receiveInstantiationResult");
|
|
5458
5963
|
var info2 = getWasmImports();
|
|
5459
5964
|
if (Module["instantiateWasm"]) {
|
|
5460
|
-
return new Promise((
|
|
5965
|
+
return new Promise((resolve3, reject) => {
|
|
5461
5966
|
Module["instantiateWasm"](info2, (mod, inst) => {
|
|
5462
|
-
|
|
5967
|
+
resolve3(receiveInstance(mod, inst));
|
|
5463
5968
|
});
|
|
5464
5969
|
});
|
|
5465
5970
|
}
|
|
@@ -6172,9 +6677,9 @@ async function Module2(moduleArg = {}) {
|
|
|
6172
6677
|
Module["monitorRunDependencies"]?.(runDependencies);
|
|
6173
6678
|
if (runDependencies == 0) {
|
|
6174
6679
|
if (dependenciesFulfilled) {
|
|
6175
|
-
var
|
|
6680
|
+
var callback2 = dependenciesFulfilled;
|
|
6176
6681
|
dependenciesFulfilled = null;
|
|
6177
|
-
|
|
6682
|
+
callback2();
|
|
6178
6683
|
}
|
|
6179
6684
|
}
|
|
6180
6685
|
}, "removeRunDependency");
|
|
@@ -6746,8 +7251,8 @@ async function Module2(moduleArg = {}) {
|
|
|
6746
7251
|
if (runtimeInitialized) {
|
|
6747
7252
|
moduleRtn = Module;
|
|
6748
7253
|
} else {
|
|
6749
|
-
moduleRtn = new Promise((
|
|
6750
|
-
readyPromiseResolve =
|
|
7254
|
+
moduleRtn = new Promise((resolve3, reject) => {
|
|
7255
|
+
readyPromiseResolve = resolve3;
|
|
6751
7256
|
readyPromiseReject = reject;
|
|
6752
7257
|
});
|
|
6753
7258
|
}
|
|
@@ -7863,11 +8368,11 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
7863
8368
|
C._ts_parser_set_language(this[0], address);
|
|
7864
8369
|
return this;
|
|
7865
8370
|
}
|
|
7866
|
-
parse(
|
|
7867
|
-
if (typeof
|
|
7868
|
-
C.currentParseCallback = (index) =>
|
|
7869
|
-
} else if (typeof
|
|
7870
|
-
C.currentParseCallback =
|
|
8371
|
+
parse(callback2, oldTree, options) {
|
|
8372
|
+
if (typeof callback2 === "string") {
|
|
8373
|
+
C.currentParseCallback = (index) => callback2.slice(index);
|
|
8374
|
+
} else if (typeof callback2 === "function") {
|
|
8375
|
+
C.currentParseCallback = callback2;
|
|
7871
8376
|
} else {
|
|
7872
8377
|
throw new Error("Argument must be a string or a function");
|
|
7873
8378
|
}
|
|
@@ -7928,13 +8433,13 @@ ${JSON.stringify(symbolNames, null, 2)}`);
|
|
|
7928
8433
|
}
|
|
7929
8434
|
return result;
|
|
7930
8435
|
}
|
|
7931
|
-
setLogger(
|
|
7932
|
-
if (!
|
|
8436
|
+
setLogger(callback2) {
|
|
8437
|
+
if (!callback2) {
|
|
7933
8438
|
this.logCallback = null;
|
|
7934
|
-
} else if (typeof
|
|
8439
|
+
} else if (typeof callback2 !== "function") {
|
|
7935
8440
|
throw new Error("Logger callback must be a function");
|
|
7936
8441
|
} else {
|
|
7937
|
-
this.logCallback =
|
|
8442
|
+
this.logCallback = callback2;
|
|
7938
8443
|
}
|
|
7939
8444
|
return this;
|
|
7940
8445
|
}
|
|
@@ -11344,9 +11849,9 @@ async function watchDirectory(rootDir, options = {}) {
|
|
|
11344
11849
|
onError(err2);
|
|
11345
11850
|
}
|
|
11346
11851
|
});
|
|
11347
|
-
await new Promise((
|
|
11852
|
+
await new Promise((resolve4) => {
|
|
11348
11853
|
watcher.on("ready", () => {
|
|
11349
|
-
|
|
11854
|
+
resolve4();
|
|
11350
11855
|
});
|
|
11351
11856
|
});
|
|
11352
11857
|
return {
|
|
@@ -11381,7 +11886,6 @@ __export(exports_indexer, {
|
|
|
11381
11886
|
clearFreshnessCache: () => clearFreshnessCache,
|
|
11382
11887
|
cleanupIndex: () => cleanupIndex
|
|
11383
11888
|
});
|
|
11384
|
-
import { glob } from "glob";
|
|
11385
11889
|
import * as fs8 from "fs/promises";
|
|
11386
11890
|
import * as path22 from "path";
|
|
11387
11891
|
import * as os3 from "os";
|
|
@@ -11545,6 +12049,15 @@ async function resetIndex(rootDir) {
|
|
|
11545
12049
|
async function ensureIndexFresh(rootDir, options = {}) {
|
|
11546
12050
|
const verbose = options.verbose ?? false;
|
|
11547
12051
|
const quiet = options.quiet ?? false;
|
|
12052
|
+
const showTiming = options.timing ?? false;
|
|
12053
|
+
const startTime = Date.now();
|
|
12054
|
+
let fileDiscoveryMs = 0;
|
|
12055
|
+
let statCheckMs = 0;
|
|
12056
|
+
let indexingMs = 0;
|
|
12057
|
+
let cleanupMs = 0;
|
|
12058
|
+
let filesDiscovered = 0;
|
|
12059
|
+
let filesStatChecked = 0;
|
|
12060
|
+
let filesIndexed = 0;
|
|
11548
12061
|
const logger = options.logger ? options.logger : quiet ? createSilentLogger() : createLogger({ verbose });
|
|
11549
12062
|
rootDir = path22.resolve(rootDir);
|
|
11550
12063
|
const status = await getIndexStatus(rootDir);
|
|
@@ -11576,16 +12089,35 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
11576
12089
|
const now = Date.now();
|
|
11577
12090
|
if (freshnessCache && freshnessCache.rootDir === rootDir && now - freshnessCache.timestamp < FRESHNESS_CACHE_TTL_MS && freshnessCache.manifestMtime === currentManifestMtime) {
|
|
11578
12091
|
logger.debug("Using cached freshness check result");
|
|
11579
|
-
|
|
12092
|
+
const cachedResult = { ...freshnessCache.result };
|
|
12093
|
+
if (showTiming) {
|
|
12094
|
+
cachedResult.timing = {
|
|
12095
|
+
totalMs: Date.now() - startTime,
|
|
12096
|
+
fileDiscoveryMs: 0,
|
|
12097
|
+
statCheckMs: 0,
|
|
12098
|
+
indexingMs: 0,
|
|
12099
|
+
cleanupMs: 0,
|
|
12100
|
+
filesDiscovered: 0,
|
|
12101
|
+
filesStatChecked: 0,
|
|
12102
|
+
filesIndexed: 0,
|
|
12103
|
+
fromCache: true
|
|
12104
|
+
};
|
|
12105
|
+
}
|
|
12106
|
+
return cachedResult;
|
|
11580
12107
|
}
|
|
11581
12108
|
await registerBuiltInModules();
|
|
11582
12109
|
const enabledModules = registry.getEnabled(config);
|
|
11583
12110
|
if (enabledModules.length === 0) {
|
|
11584
12111
|
return { indexed: 0, removed: 0, unchanged: 0 };
|
|
11585
12112
|
}
|
|
12113
|
+
const fileDiscoveryStart = Date.now();
|
|
11586
12114
|
const introspection = new IntrospectionIndex(rootDir);
|
|
11587
|
-
await
|
|
11588
|
-
|
|
12115
|
+
const [, currentFiles] = await Promise.all([
|
|
12116
|
+
introspection.initialize(),
|
|
12117
|
+
findFiles(rootDir, config)
|
|
12118
|
+
]);
|
|
12119
|
+
fileDiscoveryMs = Date.now() - fileDiscoveryStart;
|
|
12120
|
+
filesDiscovered = currentFiles.length;
|
|
11589
12121
|
const currentFileSet = new Set(currentFiles.map((f) => path22.relative(rootDir, f)));
|
|
11590
12122
|
let totalIndexed = 0;
|
|
11591
12123
|
let totalRemoved = 0;
|
|
@@ -11614,20 +12146,21 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
11614
12146
|
filesToRemove.push(filepath);
|
|
11615
12147
|
}
|
|
11616
12148
|
}
|
|
12149
|
+
const cleanupStart = Date.now();
|
|
11617
12150
|
const removedFilepaths = [];
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
totalRemoved
|
|
12151
|
+
if (filesToRemove.length > 0) {
|
|
12152
|
+
await Promise.all(filesToRemove.map(async (filepath) => {
|
|
12153
|
+
logger.debug(` Removing stale: ${filepath}`);
|
|
12154
|
+
const indexFilePath = path22.join(indexPath, filepath.replace(/\.[^.]+$/, ".json"));
|
|
12155
|
+
const symbolicFilePath = path22.join(indexPath, "symbolic", filepath.replace(/\.[^.]+$/, ".json"));
|
|
12156
|
+
await Promise.all([
|
|
12157
|
+
fs8.unlink(indexFilePath).catch(() => {}),
|
|
12158
|
+
fs8.unlink(symbolicFilePath).catch(() => {})
|
|
12159
|
+
]);
|
|
12160
|
+
delete manifest.files[filepath];
|
|
12161
|
+
removedFilepaths.push(filepath);
|
|
12162
|
+
}));
|
|
12163
|
+
totalRemoved += removedFilepaths.length;
|
|
11631
12164
|
}
|
|
11632
12165
|
if (removedFilepaths.length > 0) {
|
|
11633
12166
|
try {
|
|
@@ -11641,6 +12174,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
11641
12174
|
await literalIndex.save();
|
|
11642
12175
|
} catch {}
|
|
11643
12176
|
}
|
|
12177
|
+
cleanupMs += Date.now() - cleanupStart;
|
|
11644
12178
|
const ctx = {
|
|
11645
12179
|
rootDir,
|
|
11646
12180
|
config,
|
|
@@ -11655,21 +12189,51 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
11655
12189
|
},
|
|
11656
12190
|
getIntrospection: (filepath) => introspection.getFile(filepath)
|
|
11657
12191
|
};
|
|
11658
|
-
const
|
|
11659
|
-
let completedCount = 0;
|
|
11660
|
-
const processIncrementalFile = async (filepath) => {
|
|
12192
|
+
const statCheck = async (filepath) => {
|
|
11661
12193
|
const relativePath = path22.relative(rootDir, filepath);
|
|
11662
12194
|
try {
|
|
11663
12195
|
const stats = await fs8.stat(filepath);
|
|
11664
12196
|
const lastModified = stats.mtime.toISOString();
|
|
11665
12197
|
const existingEntry = manifest.files[relativePath];
|
|
11666
|
-
if (existingEntry
|
|
11667
|
-
|
|
11668
|
-
return { relativePath, status: "unchanged" };
|
|
12198
|
+
if (!existingEntry) {
|
|
12199
|
+
return { filepath, relativePath, lastModified, needsCheck: true, isNew: true };
|
|
11669
12200
|
}
|
|
12201
|
+
if (existingEntry.lastModified === lastModified) {
|
|
12202
|
+
return { filepath, relativePath, lastModified, needsCheck: false, isNew: false };
|
|
12203
|
+
}
|
|
12204
|
+
return { filepath, relativePath, lastModified, needsCheck: true, isNew: false };
|
|
12205
|
+
} catch {
|
|
12206
|
+
return null;
|
|
12207
|
+
}
|
|
12208
|
+
};
|
|
12209
|
+
const statCheckStart = Date.now();
|
|
12210
|
+
const statResults = await parallelMap(currentFiles, statCheck, STAT_CONCURRENCY);
|
|
12211
|
+
statCheckMs += Date.now() - statCheckStart;
|
|
12212
|
+
filesStatChecked += currentFiles.length;
|
|
12213
|
+
const filesToProcess = [];
|
|
12214
|
+
let unchangedCount = 0;
|
|
12215
|
+
for (const result2 of statResults) {
|
|
12216
|
+
if (!result2.success || !result2.value)
|
|
12217
|
+
continue;
|
|
12218
|
+
if (result2.value.needsCheck) {
|
|
12219
|
+
filesToProcess.push(result2.value);
|
|
12220
|
+
} else {
|
|
12221
|
+
unchangedCount++;
|
|
12222
|
+
}
|
|
12223
|
+
}
|
|
12224
|
+
if (filesToProcess.length === 0) {
|
|
12225
|
+
totalUnchanged += unchangedCount;
|
|
12226
|
+
continue;
|
|
12227
|
+
}
|
|
12228
|
+
let completedCount = 0;
|
|
12229
|
+
const totalToProcess = filesToProcess.length;
|
|
12230
|
+
const processChangedFile = async (statResult) => {
|
|
12231
|
+
const { filepath, relativePath, lastModified, isNew } = statResult;
|
|
12232
|
+
try {
|
|
11670
12233
|
const content = await fs8.readFile(filepath, "utf-8");
|
|
11671
12234
|
const contentHash = computeContentHash(content);
|
|
11672
|
-
|
|
12235
|
+
const existingEntry = manifest.files[relativePath];
|
|
12236
|
+
if (!isNew && existingEntry?.contentHash && existingEntry.contentHash === contentHash) {
|
|
11673
12237
|
completedCount++;
|
|
11674
12238
|
return {
|
|
11675
12239
|
relativePath,
|
|
@@ -11679,7 +12243,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
11679
12243
|
};
|
|
11680
12244
|
}
|
|
11681
12245
|
completedCount++;
|
|
11682
|
-
logger.progress(` [${completedCount}/${
|
|
12246
|
+
logger.progress(` [${completedCount}/${totalToProcess}] Indexing: ${relativePath}`);
|
|
11683
12247
|
introspection.addFile(relativePath, content);
|
|
11684
12248
|
const fileIndex = await module2.indexFile(relativePath, content, ctx);
|
|
11685
12249
|
if (!fileIndex) {
|
|
@@ -11698,8 +12262,12 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
11698
12262
|
return { relativePath, status: "error", error };
|
|
11699
12263
|
}
|
|
11700
12264
|
};
|
|
12265
|
+
const indexingStart = Date.now();
|
|
11701
12266
|
const concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
|
|
11702
|
-
const results = await parallelMap(
|
|
12267
|
+
const results = await parallelMap(filesToProcess, processChangedFile, concurrency);
|
|
12268
|
+
indexingMs += Date.now() - indexingStart;
|
|
12269
|
+
filesIndexed += filesToProcess.length;
|
|
12270
|
+
totalUnchanged += unchangedCount;
|
|
11703
12271
|
logger.clearProgress();
|
|
11704
12272
|
let mtimeUpdates = 0;
|
|
11705
12273
|
for (const item of results) {
|
|
@@ -11760,6 +12328,19 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
11760
12328
|
removed: totalRemoved,
|
|
11761
12329
|
unchanged: totalUnchanged
|
|
11762
12330
|
};
|
|
12331
|
+
if (showTiming) {
|
|
12332
|
+
result.timing = {
|
|
12333
|
+
totalMs: Date.now() - startTime,
|
|
12334
|
+
fileDiscoveryMs,
|
|
12335
|
+
statCheckMs,
|
|
12336
|
+
indexingMs,
|
|
12337
|
+
cleanupMs,
|
|
12338
|
+
filesDiscovered,
|
|
12339
|
+
filesStatChecked,
|
|
12340
|
+
filesIndexed,
|
|
12341
|
+
fromCache: false
|
|
12342
|
+
};
|
|
12343
|
+
}
|
|
11763
12344
|
let finalManifestMtime = currentManifestMtime;
|
|
11764
12345
|
try {
|
|
11765
12346
|
const manifestStats = await fs8.stat(globalManifestPath);
|
|
@@ -11767,7 +12348,7 @@ async function ensureIndexFresh(rootDir, options = {}) {
|
|
|
11767
12348
|
} catch {}
|
|
11768
12349
|
freshnessCache = {
|
|
11769
12350
|
rootDir,
|
|
11770
|
-
result,
|
|
12351
|
+
result: { indexed: totalIndexed, removed: totalRemoved, unchanged: totalUnchanged },
|
|
11771
12352
|
timestamp: Date.now(),
|
|
11772
12353
|
manifestMtime: finalManifestMtime
|
|
11773
12354
|
};
|
|
@@ -11907,18 +12488,14 @@ async function indexWithModule(rootDir, files, module2, config, verbose, introsp
|
|
|
11907
12488
|
return result;
|
|
11908
12489
|
}
|
|
11909
12490
|
async function findFiles(rootDir, config) {
|
|
11910
|
-
const
|
|
11911
|
-
const
|
|
11912
|
-
const
|
|
11913
|
-
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
|
|
11918
|
-
});
|
|
11919
|
-
files.push(...matches);
|
|
11920
|
-
}
|
|
11921
|
-
return [...new Set(files)];
|
|
12491
|
+
const validExtensions = new Set(config.extensions);
|
|
12492
|
+
const ignoreDirs = new Set(config.ignorePaths);
|
|
12493
|
+
const crawler = new Builder().withFullPaths().exclude((dirName) => ignoreDirs.has(dirName)).filter((filePath) => {
|
|
12494
|
+
const ext = path22.extname(filePath);
|
|
12495
|
+
return validExtensions.has(ext);
|
|
12496
|
+
}).crawl(rootDir);
|
|
12497
|
+
const files = await crawler.withPromise();
|
|
12498
|
+
return files;
|
|
11922
12499
|
}
|
|
11923
12500
|
async function loadModuleManifest(rootDir, moduleId, config) {
|
|
11924
12501
|
const manifestPath = getModuleManifestPath(rootDir, moduleId, config);
|
|
@@ -12087,14 +12664,16 @@ async function getIndexStatus(rootDir) {
|
|
|
12087
12664
|
}
|
|
12088
12665
|
return status;
|
|
12089
12666
|
}
|
|
12090
|
-
var FRESHNESS_CACHE_TTL_MS = 5000, freshnessCache = null, INDEX_SCHEMA_VERSION = "2.0.0", DEFAULT_CONCURRENCY;
|
|
12667
|
+
var FRESHNESS_CACHE_TTL_MS = 5000, freshnessCache = null, INDEX_SCHEMA_VERSION = "2.0.0", DEFAULT_CONCURRENCY, STAT_CONCURRENCY;
|
|
12091
12668
|
var init_indexer = __esm(() => {
|
|
12669
|
+
init_dist();
|
|
12092
12670
|
init_config2();
|
|
12093
12671
|
init_registry();
|
|
12094
12672
|
init_introspection2();
|
|
12095
12673
|
init_logger();
|
|
12096
12674
|
init_watcher();
|
|
12097
12675
|
DEFAULT_CONCURRENCY = getOptimalConcurrency();
|
|
12676
|
+
STAT_CONCURRENCY = Math.max(32, getOptimalConcurrency() * 4);
|
|
12098
12677
|
});
|
|
12099
12678
|
|
|
12100
12679
|
// node_modules/balanced-match/index.js
|
|
@@ -12317,9 +12896,9 @@ var init_assert_valid_pattern = __esm(() => {
|
|
|
12317
12896
|
});
|
|
12318
12897
|
|
|
12319
12898
|
// node_modules/minimatch/dist/esm/brace-expressions.js
|
|
12320
|
-
var posixClasses, braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&"), regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), rangesToString = (ranges) => ranges.join(""), parseClass = (
|
|
12899
|
+
var posixClasses, braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&"), regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), rangesToString = (ranges) => ranges.join(""), parseClass = (glob, position) => {
|
|
12321
12900
|
const pos = position;
|
|
12322
|
-
if (
|
|
12901
|
+
if (glob.charAt(pos) !== "[") {
|
|
12323
12902
|
throw new Error("not in a brace expression");
|
|
12324
12903
|
}
|
|
12325
12904
|
const ranges = [];
|
|
@@ -12332,8 +12911,8 @@ var posixClasses, braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&"), regexpEsc
|
|
|
12332
12911
|
let endPos = pos;
|
|
12333
12912
|
let rangeStart = "";
|
|
12334
12913
|
WHILE:
|
|
12335
|
-
while (i2 <
|
|
12336
|
-
const c =
|
|
12914
|
+
while (i2 < glob.length) {
|
|
12915
|
+
const c = glob.charAt(i2);
|
|
12337
12916
|
if ((c === "!" || c === "^") && i2 === pos + 1) {
|
|
12338
12917
|
negate = true;
|
|
12339
12918
|
i2++;
|
|
@@ -12353,9 +12932,9 @@ var posixClasses, braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&"), regexpEsc
|
|
|
12353
12932
|
}
|
|
12354
12933
|
if (c === "[" && !escaping) {
|
|
12355
12934
|
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
|
|
12356
|
-
if (
|
|
12935
|
+
if (glob.startsWith(cls, i2)) {
|
|
12357
12936
|
if (rangeStart) {
|
|
12358
|
-
return ["$.", false,
|
|
12937
|
+
return ["$.", false, glob.length - pos, true];
|
|
12359
12938
|
}
|
|
12360
12939
|
i2 += cls.length;
|
|
12361
12940
|
if (neg)
|
|
@@ -12378,12 +12957,12 @@ var posixClasses, braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&"), regexpEsc
|
|
|
12378
12957
|
i2++;
|
|
12379
12958
|
continue;
|
|
12380
12959
|
}
|
|
12381
|
-
if (
|
|
12960
|
+
if (glob.startsWith("-]", i2 + 1)) {
|
|
12382
12961
|
ranges.push(braceEscape(c + "-"));
|
|
12383
12962
|
i2 += 2;
|
|
12384
12963
|
continue;
|
|
12385
12964
|
}
|
|
12386
|
-
if (
|
|
12965
|
+
if (glob.startsWith("-", i2 + 1)) {
|
|
12387
12966
|
rangeStart = c;
|
|
12388
12967
|
i2 += 2;
|
|
12389
12968
|
continue;
|
|
@@ -12395,7 +12974,7 @@ var posixClasses, braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&"), regexpEsc
|
|
|
12395
12974
|
return ["", false, 0, false];
|
|
12396
12975
|
}
|
|
12397
12976
|
if (!ranges.length && !negs.length) {
|
|
12398
|
-
return ["$.", false,
|
|
12977
|
+
return ["$.", false, glob.length - pos, true];
|
|
12399
12978
|
}
|
|
12400
12979
|
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
12401
12980
|
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
@@ -12676,16 +13255,16 @@ class AST {
|
|
|
12676
13255
|
toMMPattern() {
|
|
12677
13256
|
if (this !== this.#root)
|
|
12678
13257
|
return this.#root.toMMPattern();
|
|
12679
|
-
const
|
|
13258
|
+
const glob = this.toString();
|
|
12680
13259
|
const [re, body2, hasMagic, uflag] = this.toRegExpSource();
|
|
12681
|
-
const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly &&
|
|
13260
|
+
const anyMagic = hasMagic || this.#hasMagic || this.#options.nocase && !this.#options.nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
|
|
12682
13261
|
if (!anyMagic) {
|
|
12683
13262
|
return body2;
|
|
12684
13263
|
}
|
|
12685
13264
|
const flags2 = (this.#options.nocase ? "i" : "") + (uflag ? "u" : "");
|
|
12686
13265
|
return Object.assign(new RegExp(`^${re}$`, flags2), {
|
|
12687
13266
|
_src: re,
|
|
12688
|
-
_glob:
|
|
13267
|
+
_glob: glob
|
|
12689
13268
|
});
|
|
12690
13269
|
}
|
|
12691
13270
|
get options() {
|
|
@@ -12768,19 +13347,19 @@ class AST {
|
|
|
12768
13347
|
return re;
|
|
12769
13348
|
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
12770
13349
|
}
|
|
12771
|
-
static #parseGlob(
|
|
13350
|
+
static #parseGlob(glob, hasMagic, noEmpty = false) {
|
|
12772
13351
|
let escaping = false;
|
|
12773
13352
|
let re = "";
|
|
12774
13353
|
let uflag = false;
|
|
12775
|
-
for (let i2 = 0;i2 <
|
|
12776
|
-
const c =
|
|
13354
|
+
for (let i2 = 0;i2 < glob.length; i2++) {
|
|
13355
|
+
const c = glob.charAt(i2);
|
|
12777
13356
|
if (escaping) {
|
|
12778
13357
|
escaping = false;
|
|
12779
13358
|
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
12780
13359
|
continue;
|
|
12781
13360
|
}
|
|
12782
13361
|
if (c === "\\") {
|
|
12783
|
-
if (i2 ===
|
|
13362
|
+
if (i2 === glob.length - 1) {
|
|
12784
13363
|
re += "\\\\";
|
|
12785
13364
|
} else {
|
|
12786
13365
|
escaping = true;
|
|
@@ -12788,7 +13367,7 @@ class AST {
|
|
|
12788
13367
|
continue;
|
|
12789
13368
|
}
|
|
12790
13369
|
if (c === "[") {
|
|
12791
|
-
const [src, needUflag, consumed, magic] = parseClass(
|
|
13370
|
+
const [src, needUflag, consumed, magic] = parseClass(glob, i2);
|
|
12792
13371
|
if (consumed) {
|
|
12793
13372
|
re += src;
|
|
12794
13373
|
uflag = uflag || needUflag;
|
|
@@ -12798,7 +13377,7 @@ class AST {
|
|
|
12798
13377
|
}
|
|
12799
13378
|
}
|
|
12800
13379
|
if (c === "*") {
|
|
12801
|
-
if (noEmpty &&
|
|
13380
|
+
if (noEmpty && glob === "*")
|
|
12802
13381
|
re += starNoEmpty;
|
|
12803
13382
|
else
|
|
12804
13383
|
re += star;
|
|
@@ -12812,7 +13391,7 @@ class AST {
|
|
|
12812
13391
|
}
|
|
12813
13392
|
re += regExpEscape(c);
|
|
12814
13393
|
}
|
|
12815
|
-
return [re, unescape(
|
|
13394
|
+
return [re, unescape(glob), !!hasMagic, uflag];
|
|
12816
13395
|
}
|
|
12817
13396
|
}
|
|
12818
13397
|
var types, isExtglobType = (c) => types.has(c), startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))", startNoDot = "(?!\\.)", addPatternStart, justDots, reSpecials, regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), qmark = "[^/]", star, starNoEmpty;
|
|
@@ -13413,7 +13992,7 @@ var import_brace_expansion, minimatch = (p, pattern, options = {}) => {
|
|
|
13413
13992
|
}, qmarksTestNoExtDot = ([$0]) => {
|
|
13414
13993
|
const len = $0.length;
|
|
13415
13994
|
return (f) => f.length === len && f !== "." && f !== "..";
|
|
13416
|
-
}, defaultPlatform, path23,
|
|
13995
|
+
}, defaultPlatform, path23, sep2, GLOBSTAR, qmark2 = "[^/]", star2, twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?", twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?", filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options), ext = (a, b = {}) => Object.assign({}, a, b), defaults = (def) => {
|
|
13417
13996
|
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
13418
13997
|
return minimatch;
|
|
13419
13998
|
}
|
|
@@ -13475,8 +14054,8 @@ var init_esm = __esm(() => {
|
|
|
13475
14054
|
win32: { sep: "\\" },
|
|
13476
14055
|
posix: { sep: "/" }
|
|
13477
14056
|
};
|
|
13478
|
-
|
|
13479
|
-
minimatch.sep =
|
|
14057
|
+
sep2 = defaultPlatform === "win32" ? path23.win32.sep : path23.posix.sep;
|
|
14058
|
+
minimatch.sep = sep2;
|
|
13480
14059
|
GLOBSTAR = Symbol("globstar **");
|
|
13481
14060
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
13482
14061
|
star2 = qmark2 + "*?";
|
|
@@ -13579,8 +14158,8 @@ function createSearchContext(rootDir, moduleId, config) {
|
|
|
13579
14158
|
const files = [];
|
|
13580
14159
|
await traverseDirectory(indexPath, files, indexPath);
|
|
13581
14160
|
return files.filter((f) => f.endsWith(".json") && !f.endsWith("manifest.json")).map((f) => {
|
|
13582
|
-
const
|
|
13583
|
-
return
|
|
14161
|
+
const relative5 = path24.relative(indexPath, f);
|
|
14162
|
+
return relative5.replace(/\.json$/, "");
|
|
13584
14163
|
});
|
|
13585
14164
|
}
|
|
13586
14165
|
};
|
|
@@ -13668,7 +14247,7 @@ init_logger();
|
|
|
13668
14247
|
// package.json
|
|
13669
14248
|
var package_default = {
|
|
13670
14249
|
name: "raggrep",
|
|
13671
|
-
version: "0.10.
|
|
14250
|
+
version: "0.10.5",
|
|
13672
14251
|
description: "Local filesystem-based RAG system for codebases - semantic search using local embeddings",
|
|
13673
14252
|
type: "module",
|
|
13674
14253
|
main: "./dist/index.js",
|
|
@@ -13725,6 +14304,7 @@ var package_default = {
|
|
|
13725
14304
|
dependencies: {
|
|
13726
14305
|
"@xenova/transformers": "^2.17.0",
|
|
13727
14306
|
chokidar: "^5.0.0",
|
|
14307
|
+
fdir: "^6.5.0",
|
|
13728
14308
|
glob: "^10.0.0",
|
|
13729
14309
|
typescript: "^5.0.0",
|
|
13730
14310
|
"web-tree-sitter": "^0.26.3"
|
|
@@ -13765,6 +14345,7 @@ function parseFlags(args3) {
|
|
|
13765
14345
|
help: false,
|
|
13766
14346
|
verbose: false,
|
|
13767
14347
|
watch: false,
|
|
14348
|
+
timing: false,
|
|
13768
14349
|
remaining: []
|
|
13769
14350
|
};
|
|
13770
14351
|
for (let i2 = 0;i2 < args3.length; i2++) {
|
|
@@ -13775,6 +14356,8 @@ function parseFlags(args3) {
|
|
|
13775
14356
|
flags2.verbose = true;
|
|
13776
14357
|
} else if (arg === "--watch" || arg === "-w") {
|
|
13777
14358
|
flags2.watch = true;
|
|
14359
|
+
} else if (arg === "--timing" || arg === "-T") {
|
|
14360
|
+
flags2.timing = true;
|
|
13778
14361
|
} else if (arg === "--model" || arg === "-m") {
|
|
13779
14362
|
const modelName = args3[++i2];
|
|
13780
14363
|
if (modelName && modelName in EMBEDDING_MODELS) {
|
|
@@ -13933,6 +14516,7 @@ Options:
|
|
|
13933
14516
|
-s, --min-score <n> Minimum similarity score 0-1 (default: 0.15)
|
|
13934
14517
|
-t, --type <ext> Filter by file extension (e.g., ts, tsx, js)
|
|
13935
14518
|
-f, --filter <path> Filter by path or glob pattern (can be used multiple times)
|
|
14519
|
+
-T, --timing Show timing breakdown for performance profiling
|
|
13936
14520
|
-h, --help Show this help message
|
|
13937
14521
|
|
|
13938
14522
|
Note:
|
|
@@ -13986,7 +14570,8 @@ Examples:
|
|
|
13986
14570
|
const freshStats = await ensureIndexFresh2(process.cwd(), {
|
|
13987
14571
|
model: flags2.model,
|
|
13988
14572
|
quiet: true,
|
|
13989
|
-
logger: silentLogger
|
|
14573
|
+
logger: silentLogger,
|
|
14574
|
+
timing: flags2.timing
|
|
13990
14575
|
});
|
|
13991
14576
|
console.log("RAGgrep Search");
|
|
13992
14577
|
console.log(`==============
|
|
@@ -14003,6 +14588,23 @@ Examples:
|
|
|
14003
14588
|
`);
|
|
14004
14589
|
} else {
|
|
14005
14590
|
console.log(`Using cached index (no changes detected).
|
|
14591
|
+
`);
|
|
14592
|
+
}
|
|
14593
|
+
if (flags2.timing && freshStats.timing) {
|
|
14594
|
+
const t = freshStats.timing;
|
|
14595
|
+
console.log("┌─ Timing ─────────────────────────────────────┐");
|
|
14596
|
+
if (t.fromCache) {
|
|
14597
|
+
console.log(`│ Cache hit (TTL-based) │`);
|
|
14598
|
+
console.log(`│ Total: ${t.totalMs.toFixed(0).padStart(6)}ms │`);
|
|
14599
|
+
} else {
|
|
14600
|
+
console.log(`│ File discovery: ${t.fileDiscoveryMs.toFixed(0).padStart(6)}ms (${t.filesDiscovered} files)`.padEnd(47) + "│");
|
|
14601
|
+
console.log(`│ Stat checks: ${t.statCheckMs.toFixed(0).padStart(6)}ms (${t.filesStatChecked} files)`.padEnd(47) + "│");
|
|
14602
|
+
console.log(`│ Indexing: ${t.indexingMs.toFixed(0).padStart(6)}ms (${t.filesIndexed} files)`.padEnd(47) + "│");
|
|
14603
|
+
console.log(`│ Cleanup: ${t.cleanupMs.toFixed(0).padStart(6)}ms`.padEnd(47) + "│");
|
|
14604
|
+
console.log(`│ ─────────────────────────────────────────── │`);
|
|
14605
|
+
console.log(`│ Total: ${t.totalMs.toFixed(0).padStart(6)}ms`.padEnd(47) + "│");
|
|
14606
|
+
}
|
|
14607
|
+
console.log(`└──────────────────────────────────────────────┘
|
|
14006
14608
|
`);
|
|
14007
14609
|
}
|
|
14008
14610
|
const filePatterns = flags2.fileType ? [`*.${flags2.fileType}`] : undefined;
|
|
@@ -14262,4 +14864,4 @@ Run 'raggrep <command> --help' for more information.
|
|
|
14262
14864
|
}
|
|
14263
14865
|
main();
|
|
14264
14866
|
|
|
14265
|
-
//# debugId=
|
|
14867
|
+
//# debugId=D79BF0530F7DE02664756E2164756E21
|