raggrep 0.5.0 → 0.5.2
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/README.md +56 -11
- package/dist/app/indexer/index.d.ts +3 -1
- package/dist/cli/main.js +85 -11
- package/dist/cli/main.js.map +11 -11
- package/dist/domain/entities/searchResult.d.ts +5 -0
- package/dist/index.js +67 -9
- package/dist/index.js.map +10 -10
- package/dist/modules/core/index.d.ts +4 -0
- package/dist/modules/data/json/index.d.ts +2 -0
- package/dist/modules/docs/markdown/index.d.ts +2 -0
- package/dist/modules/language/typescript/index.d.ts +2 -0
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
|
@@ -74,6 +74,11 @@ export interface SearchOptions {
|
|
|
74
74
|
minScore?: number;
|
|
75
75
|
/** Filter to specific file patterns (e.g., ['*.ts', '*.tsx']) */
|
|
76
76
|
filePatterns?: string[];
|
|
77
|
+
/**
|
|
78
|
+
* Filter to files within specified paths (e.g., ['src/auth', 'src/utils']).
|
|
79
|
+
* Results will only include files that start with one of the specified paths.
|
|
80
|
+
*/
|
|
81
|
+
pathFilter?: string[];
|
|
77
82
|
/**
|
|
78
83
|
* Ensure the index is fresh before searching (default: true).
|
|
79
84
|
*
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ var init_searchResult = __esm(() => {
|
|
|
33
33
|
topK: 10,
|
|
34
34
|
minScore: 0.15,
|
|
35
35
|
filePatterns: [],
|
|
36
|
+
pathFilter: [],
|
|
36
37
|
ensureFresh: true
|
|
37
38
|
};
|
|
38
39
|
});
|
|
@@ -1795,6 +1796,9 @@ class CoreModule {
|
|
|
1795
1796
|
name = "Core Search";
|
|
1796
1797
|
description = "Language-agnostic text search with symbol extraction";
|
|
1797
1798
|
version = "1.0.0";
|
|
1799
|
+
supportsFile(_filepath) {
|
|
1800
|
+
return true;
|
|
1801
|
+
}
|
|
1798
1802
|
symbolIndex = new Map;
|
|
1799
1803
|
bm25Index = null;
|
|
1800
1804
|
rootDir = "";
|
|
@@ -2885,6 +2889,7 @@ var init_storage = __esm(() => {
|
|
|
2885
2889
|
// src/modules/language/typescript/index.ts
|
|
2886
2890
|
var exports_typescript = {};
|
|
2887
2891
|
__export(exports_typescript, {
|
|
2892
|
+
supportsFile: () => supportsFile,
|
|
2888
2893
|
isTypeScriptFile: () => isTypeScriptFile,
|
|
2889
2894
|
TypeScriptModule: () => TypeScriptModule,
|
|
2890
2895
|
TYPESCRIPT_EXTENSIONS: () => TYPESCRIPT_EXTENSIONS,
|
|
@@ -2923,6 +2928,9 @@ class TypeScriptModule {
|
|
|
2923
2928
|
name = "TypeScript Search";
|
|
2924
2929
|
description = "TypeScript-aware code search with AST parsing and semantic embeddings";
|
|
2925
2930
|
version = "1.0.0";
|
|
2931
|
+
supportsFile(filepath) {
|
|
2932
|
+
return isTypeScriptFile(filepath);
|
|
2933
|
+
}
|
|
2926
2934
|
embeddingConfig = null;
|
|
2927
2935
|
symbolicIndex = null;
|
|
2928
2936
|
pendingSummaries = new Map;
|
|
@@ -3146,7 +3154,7 @@ class TypeScriptModule {
|
|
|
3146
3154
|
return references;
|
|
3147
3155
|
}
|
|
3148
3156
|
}
|
|
3149
|
-
var DEFAULT_MIN_SCORE2 = 0.15, DEFAULT_TOP_K2 = 10, SEMANTIC_WEIGHT = 0.7, BM25_WEIGHT = 0.3, TYPESCRIPT_EXTENSIONS;
|
|
3157
|
+
var DEFAULT_MIN_SCORE2 = 0.15, DEFAULT_TOP_K2 = 10, SEMANTIC_WEIGHT = 0.7, BM25_WEIGHT = 0.3, TYPESCRIPT_EXTENSIONS, supportsFile;
|
|
3150
3158
|
var init_typescript = __esm(() => {
|
|
3151
3159
|
init_embeddings();
|
|
3152
3160
|
init_services();
|
|
@@ -3163,11 +3171,13 @@ var init_typescript = __esm(() => {
|
|
|
3163
3171
|
".mts",
|
|
3164
3172
|
".cts"
|
|
3165
3173
|
];
|
|
3174
|
+
supportsFile = isTypeScriptFile;
|
|
3166
3175
|
});
|
|
3167
3176
|
|
|
3168
3177
|
// src/modules/data/json/index.ts
|
|
3169
3178
|
var exports_json = {};
|
|
3170
3179
|
__export(exports_json, {
|
|
3180
|
+
supportsFile: () => supportsFile2,
|
|
3171
3181
|
isJsonFile: () => isJsonFile,
|
|
3172
3182
|
JsonModule: () => JsonModule,
|
|
3173
3183
|
JSON_EXTENSIONS: () => JSON_EXTENSIONS,
|
|
@@ -3224,6 +3234,9 @@ class JsonModule {
|
|
|
3224
3234
|
name = "JSON Search";
|
|
3225
3235
|
description = "JSON file search with structure-aware indexing";
|
|
3226
3236
|
version = "1.0.0";
|
|
3237
|
+
supportsFile(filepath) {
|
|
3238
|
+
return isJsonFile(filepath);
|
|
3239
|
+
}
|
|
3227
3240
|
embeddingConfig = null;
|
|
3228
3241
|
symbolicIndex = null;
|
|
3229
3242
|
pendingSummaries = new Map;
|
|
@@ -3385,18 +3398,20 @@ class JsonModule {
|
|
|
3385
3398
|
return results.slice(0, topK);
|
|
3386
3399
|
}
|
|
3387
3400
|
}
|
|
3388
|
-
var DEFAULT_MIN_SCORE3 = 0.15, DEFAULT_TOP_K3 = 10, SEMANTIC_WEIGHT2 = 0.7, BM25_WEIGHT2 = 0.3, JSON_EXTENSIONS;
|
|
3401
|
+
var DEFAULT_MIN_SCORE3 = 0.15, DEFAULT_TOP_K3 = 10, SEMANTIC_WEIGHT2 = 0.7, BM25_WEIGHT2 = 0.3, JSON_EXTENSIONS, supportsFile2;
|
|
3389
3402
|
var init_json = __esm(() => {
|
|
3390
3403
|
init_embeddings();
|
|
3391
3404
|
init_services();
|
|
3392
3405
|
init_config2();
|
|
3393
3406
|
init_storage();
|
|
3394
3407
|
JSON_EXTENSIONS = [".json"];
|
|
3408
|
+
supportsFile2 = isJsonFile;
|
|
3395
3409
|
});
|
|
3396
3410
|
|
|
3397
3411
|
// src/modules/docs/markdown/index.ts
|
|
3398
3412
|
var exports_markdown = {};
|
|
3399
3413
|
__export(exports_markdown, {
|
|
3414
|
+
supportsFile: () => supportsFile3,
|
|
3400
3415
|
isMarkdownFile: () => isMarkdownFile,
|
|
3401
3416
|
MarkdownModule: () => MarkdownModule,
|
|
3402
3417
|
MARKDOWN_EXTENSIONS: () => MARKDOWN_EXTENSIONS,
|
|
@@ -3502,6 +3517,9 @@ class MarkdownModule {
|
|
|
3502
3517
|
name = "Markdown Search";
|
|
3503
3518
|
description = "Markdown documentation search with section-aware indexing";
|
|
3504
3519
|
version = "1.0.0";
|
|
3520
|
+
supportsFile(filepath) {
|
|
3521
|
+
return isMarkdownFile(filepath);
|
|
3522
|
+
}
|
|
3505
3523
|
embeddingConfig = null;
|
|
3506
3524
|
symbolicIndex = null;
|
|
3507
3525
|
pendingSummaries = new Map;
|
|
@@ -3671,13 +3689,14 @@ ${section.content}` : section.content,
|
|
|
3671
3689
|
return results.slice(0, topK);
|
|
3672
3690
|
}
|
|
3673
3691
|
}
|
|
3674
|
-
var DEFAULT_MIN_SCORE4 = 0.15, DEFAULT_TOP_K4 = 10, SEMANTIC_WEIGHT3 = 0.7, BM25_WEIGHT3 = 0.3, MARKDOWN_EXTENSIONS;
|
|
3692
|
+
var DEFAULT_MIN_SCORE4 = 0.15, DEFAULT_TOP_K4 = 10, SEMANTIC_WEIGHT3 = 0.7, BM25_WEIGHT3 = 0.3, MARKDOWN_EXTENSIONS, supportsFile3;
|
|
3675
3693
|
var init_markdown = __esm(() => {
|
|
3676
3694
|
init_embeddings();
|
|
3677
3695
|
init_services();
|
|
3678
3696
|
init_config2();
|
|
3679
3697
|
init_storage();
|
|
3680
3698
|
MARKDOWN_EXTENSIONS = [".md", ".txt"];
|
|
3699
|
+
supportsFile3 = isMarkdownFile;
|
|
3681
3700
|
});
|
|
3682
3701
|
|
|
3683
3702
|
// src/app/indexer/index.ts
|
|
@@ -3685,6 +3704,7 @@ init_config2();
|
|
|
3685
3704
|
import { glob } from "glob";
|
|
3686
3705
|
import * as fs6 from "fs/promises";
|
|
3687
3706
|
import * as path14 from "path";
|
|
3707
|
+
import * as os3 from "os";
|
|
3688
3708
|
|
|
3689
3709
|
// src/modules/registry.ts
|
|
3690
3710
|
class ModuleRegistryImpl {
|
|
@@ -4081,7 +4101,24 @@ async function parallelMap(items, processor, concurrency) {
|
|
|
4081
4101
|
return results;
|
|
4082
4102
|
}
|
|
4083
4103
|
var INDEX_SCHEMA_VERSION = "1.0.0";
|
|
4084
|
-
|
|
4104
|
+
function formatDuration(ms) {
|
|
4105
|
+
if (ms < 1000) {
|
|
4106
|
+
return `${ms}ms`;
|
|
4107
|
+
}
|
|
4108
|
+
const seconds = ms / 1000;
|
|
4109
|
+
if (seconds < 60) {
|
|
4110
|
+
return `${seconds.toFixed(1)}s`;
|
|
4111
|
+
}
|
|
4112
|
+
const minutes = Math.floor(seconds / 60);
|
|
4113
|
+
const remainingSeconds = seconds % 60;
|
|
4114
|
+
return `${minutes}m ${remainingSeconds.toFixed(1)}s`;
|
|
4115
|
+
}
|
|
4116
|
+
function getOptimalConcurrency() {
|
|
4117
|
+
const cpuCount = os3.cpus().length;
|
|
4118
|
+
const optimal = Math.max(2, Math.min(16, Math.floor(cpuCount * 0.75)));
|
|
4119
|
+
return optimal;
|
|
4120
|
+
}
|
|
4121
|
+
var DEFAULT_CONCURRENCY = getOptimalConcurrency();
|
|
4085
4122
|
async function indexDirectory(rootDir, options = {}) {
|
|
4086
4123
|
const verbose = options.verbose ?? false;
|
|
4087
4124
|
const quiet = options.quiet ?? false;
|
|
@@ -4108,8 +4145,10 @@ async function indexDirectory(rootDir, options = {}) {
|
|
|
4108
4145
|
logger.info(`Enabled modules: ${enabledModules.map((m) => m.id).join(", ")}`);
|
|
4109
4146
|
const files = await findFiles(rootDir, config);
|
|
4110
4147
|
logger.info(`Found ${files.length} files to index`);
|
|
4148
|
+
const overallStart = Date.now();
|
|
4111
4149
|
const results = [];
|
|
4112
4150
|
for (const module of enabledModules) {
|
|
4151
|
+
const moduleStart = Date.now();
|
|
4113
4152
|
logger.info(`
|
|
4114
4153
|
[${module.name}] Starting indexing...`);
|
|
4115
4154
|
const moduleConfig = getModuleConfig(config, module.id);
|
|
@@ -4127,7 +4166,9 @@ async function indexDirectory(rootDir, options = {}) {
|
|
|
4127
4166
|
};
|
|
4128
4167
|
await module.initialize(configWithOverrides);
|
|
4129
4168
|
}
|
|
4130
|
-
const
|
|
4169
|
+
const moduleFiles = module.supportsFile ? files.filter((f) => module.supportsFile(f)) : files;
|
|
4170
|
+
logger.info(` Processing ${moduleFiles.length} files...`);
|
|
4171
|
+
const result = await indexWithModule(rootDir, moduleFiles, module, config, verbose, introspection, logger, concurrency);
|
|
4131
4172
|
results.push(result);
|
|
4132
4173
|
if (module.finalize) {
|
|
4133
4174
|
logger.info(`[${module.name}] Building secondary indexes...`);
|
|
@@ -4146,9 +4187,18 @@ async function indexDirectory(rootDir, options = {}) {
|
|
|
4146
4187
|
};
|
|
4147
4188
|
await module.finalize(ctx);
|
|
4148
4189
|
}
|
|
4149
|
-
|
|
4190
|
+
const moduleDuration = Date.now() - moduleStart;
|
|
4191
|
+
result.durationMs = moduleDuration;
|
|
4192
|
+
logger.info(`[${module.name}] Complete: ${result.indexed} indexed, ${result.skipped} skipped, ${result.errors} errors (${formatDuration(moduleDuration)})`);
|
|
4150
4193
|
}
|
|
4151
4194
|
await introspection.save(config);
|
|
4195
|
+
const overallDuration = Date.now() - overallStart;
|
|
4196
|
+
logger.info(`
|
|
4197
|
+
Indexing complete in ${formatDuration(overallDuration)}`);
|
|
4198
|
+
const totalIndexed = results.reduce((sum, r) => sum + r.indexed, 0);
|
|
4199
|
+
const totalSkipped = results.reduce((sum, r) => sum + r.skipped, 0);
|
|
4200
|
+
const totalErrors = results.reduce((sum, r) => sum + r.errors, 0);
|
|
4201
|
+
logger.info(`Total: ${totalIndexed} indexed, ${totalSkipped} skipped, ${totalErrors} errors`);
|
|
4152
4202
|
await updateGlobalManifest(rootDir, enabledModules, config);
|
|
4153
4203
|
return results;
|
|
4154
4204
|
}
|
|
@@ -4657,9 +4707,17 @@ async function search(rootDir, query, options = {}) {
|
|
|
4657
4707
|
const moduleResults = await module.search(query, ctx, options);
|
|
4658
4708
|
allResults.push(...moduleResults);
|
|
4659
4709
|
}
|
|
4660
|
-
|
|
4710
|
+
let filteredResults = allResults;
|
|
4711
|
+
if (options.pathFilter && options.pathFilter.length > 0) {
|
|
4712
|
+
const normalizedFilters = options.pathFilter.map((p) => p.replace(/\\/g, "/").replace(/^\//, "").replace(/\/$/, ""));
|
|
4713
|
+
filteredResults = allResults.filter((result) => {
|
|
4714
|
+
const normalizedPath = result.filepath.replace(/\\/g, "/");
|
|
4715
|
+
return normalizedFilters.some((filter) => normalizedPath.startsWith(filter + "/") || normalizedPath === filter || normalizedPath.startsWith("./" + filter + "/") || normalizedPath === "./" + filter);
|
|
4716
|
+
});
|
|
4717
|
+
}
|
|
4718
|
+
filteredResults.sort((a, b) => b.score - a.score);
|
|
4661
4719
|
const topK = options.topK ?? 10;
|
|
4662
|
-
return
|
|
4720
|
+
return filteredResults.slice(0, topK);
|
|
4663
4721
|
}
|
|
4664
4722
|
function createSearchContext(rootDir, moduleId, config) {
|
|
4665
4723
|
const indexPath = getModuleIndexPath(rootDir, moduleId, config);
|
|
@@ -4792,4 +4850,4 @@ export {
|
|
|
4792
4850
|
ConsoleLogger
|
|
4793
4851
|
};
|
|
4794
4852
|
|
|
4795
|
-
//# debugId=
|
|
4853
|
+
//# debugId=CD5077D1A96FC88964756E2164756E21
|