opencode-codebase-index 0.22.5 → 0.23.0
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/dist/cli.cjs +949 -479
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +950 -480
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +854 -395
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +855 -396
- package/dist/index.js.map +1 -1
- package/dist/pi-extension.cjs +6 -95
- package/dist/pi-extension.cjs.map +1 -1
- package/dist/pi-extension.js +6 -95
- package/dist/pi-extension.js.map +1 -1
- package/native/codebase-index-native.darwin-arm64.node +0 -0
- package/native/codebase-index-native.darwin-x64.node +0 -0
- package/native/codebase-index-native.linux-arm64-gnu.node +0 -0
- package/native/codebase-index-native.linux-x64-gnu.node +0 -0
- package/native/codebase-index-native.win32-x64-msvc.node +0 -0
- package/package.json +3 -1
package/dist/pi-extension.cjs
CHANGED
|
@@ -2342,7 +2342,7 @@ function analyzeQueryIntent(query) {
|
|
|
2342
2342
|
}
|
|
2343
2343
|
function isTestPath(filePath) {
|
|
2344
2344
|
const normalized = normalizePath(filePath);
|
|
2345
|
-
return /(?:^|\/)(?:test|tests|__tests__|spec|specs)(?:\/|$)/u.test(normalized) ||
|
|
2345
|
+
return /(?:^|\/)(?:test|tests|__tests__|spec|specs)(?:\/|$)/u.test(normalized) || /(?:\.(?:test|spec)|_(?:test|spec))\.[^/]+$/u.test(normalized) || /(?:^|\/)(?:test|spec)_[^/]+\.[^/]+$/u.test(normalized);
|
|
2346
2346
|
}
|
|
2347
2347
|
function isFixturePath(filePath) {
|
|
2348
2348
|
const normalized = normalizePath(filePath);
|
|
@@ -6432,85 +6432,6 @@ function createEmbeddingProvider(configuredProviderInfo) {
|
|
|
6432
6432
|
}
|
|
6433
6433
|
}
|
|
6434
6434
|
|
|
6435
|
-
// src/rerank/index.ts
|
|
6436
|
-
function createReranker(config) {
|
|
6437
|
-
if (!config.enabled) {
|
|
6438
|
-
return new NoOpReranker();
|
|
6439
|
-
}
|
|
6440
|
-
return new SiliconFlowReranker(config);
|
|
6441
|
-
}
|
|
6442
|
-
var NoOpReranker = class {
|
|
6443
|
-
isAvailable() {
|
|
6444
|
-
return false;
|
|
6445
|
-
}
|
|
6446
|
-
async rerank(_query, documents, _topN) {
|
|
6447
|
-
return {
|
|
6448
|
-
results: documents.map((_, index) => ({ index, relevanceScore: 0 }))
|
|
6449
|
-
};
|
|
6450
|
-
}
|
|
6451
|
-
};
|
|
6452
|
-
var SiliconFlowReranker = class {
|
|
6453
|
-
config;
|
|
6454
|
-
constructor(config) {
|
|
6455
|
-
this.config = config;
|
|
6456
|
-
}
|
|
6457
|
-
isAvailable() {
|
|
6458
|
-
return this.config.enabled && !!this.config.baseUrl && !!this.config.model;
|
|
6459
|
-
}
|
|
6460
|
-
async rerank(query, documents, topN) {
|
|
6461
|
-
if (documents.length === 0) {
|
|
6462
|
-
return { results: [] };
|
|
6463
|
-
}
|
|
6464
|
-
const headers = {
|
|
6465
|
-
"Content-Type": "application/json"
|
|
6466
|
-
};
|
|
6467
|
-
if (this.config.apiKey) {
|
|
6468
|
-
headers["Authorization"] = `Bearer ${this.config.apiKey}`;
|
|
6469
|
-
}
|
|
6470
|
-
const baseUrl = this.config.baseUrl;
|
|
6471
|
-
if (!baseUrl) {
|
|
6472
|
-
throw new Error("Reranker baseUrl is required. Configure reranker.baseUrl in your codebase-index.json.");
|
|
6473
|
-
}
|
|
6474
|
-
const timeoutMs = this.config.timeoutMs ?? 3e4;
|
|
6475
|
-
const controller = new AbortController();
|
|
6476
|
-
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
6477
|
-
try {
|
|
6478
|
-
const response = await fetch(`${baseUrl}/rerank`, {
|
|
6479
|
-
method: "POST",
|
|
6480
|
-
headers,
|
|
6481
|
-
body: JSON.stringify({
|
|
6482
|
-
model: this.config.model,
|
|
6483
|
-
query,
|
|
6484
|
-
documents,
|
|
6485
|
-
top_n: topN ?? this.config.topN ?? 20,
|
|
6486
|
-
return_documents: false
|
|
6487
|
-
}),
|
|
6488
|
-
signal: controller.signal
|
|
6489
|
-
});
|
|
6490
|
-
clearTimeout(timeout);
|
|
6491
|
-
if (!response.ok) {
|
|
6492
|
-
const errorText = await response.text();
|
|
6493
|
-
throw new Error(`Rerank API error: ${response.status} - ${errorText}`);
|
|
6494
|
-
}
|
|
6495
|
-
const data = await response.json();
|
|
6496
|
-
return {
|
|
6497
|
-
results: data.results.map((r) => ({
|
|
6498
|
-
index: r.index,
|
|
6499
|
-
relevanceScore: r.relevance_score,
|
|
6500
|
-
document: r.document?.text
|
|
6501
|
-
})),
|
|
6502
|
-
tokensUsed: data.meta?.tokens?.input_tokens
|
|
6503
|
-
};
|
|
6504
|
-
} catch (error) {
|
|
6505
|
-
clearTimeout(timeout);
|
|
6506
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
6507
|
-
throw new Error(`Rerank API request timed out after ${timeoutMs}ms`);
|
|
6508
|
-
}
|
|
6509
|
-
throw error;
|
|
6510
|
-
}
|
|
6511
|
-
}
|
|
6512
|
-
};
|
|
6513
|
-
|
|
6514
6435
|
// src/utils/logger.ts
|
|
6515
6436
|
var LOG_LEVEL_PRIORITY = {
|
|
6516
6437
|
error: 0,
|
|
@@ -8625,7 +8546,8 @@ function rankHybridResults(query, semanticResults, keywordResults, options) {
|
|
|
8625
8546
|
return cached;
|
|
8626
8547
|
}
|
|
8627
8548
|
}
|
|
8628
|
-
const
|
|
8549
|
+
const overfetchFactor = prioritizeSourcePaths ? 12 : 4;
|
|
8550
|
+
const overfetchLimit = Math.max(options.limit * overfetchFactor, options.limit);
|
|
8629
8551
|
const fused = options.fusionStrategy === "rrf" ? fuseResultsRrf(semanticResults, keywordResults, options.rrfK, overfetchLimit) : fuseResultsWeighted(semanticResults, keywordResults, options.hybridWeight, overfetchLimit);
|
|
8630
8552
|
const rerankPoolLimit = Math.max(overfetchLimit, options.rerankTopN * 3, options.limit * 6);
|
|
8631
8553
|
const rerankPool = fused.slice(0, rerankPoolLimit);
|
|
@@ -10136,7 +10058,6 @@ var Indexer = class _Indexer {
|
|
|
10136
10058
|
database = null;
|
|
10137
10059
|
provider = null;
|
|
10138
10060
|
configuredProviderInfo = null;
|
|
10139
|
-
reranker = null;
|
|
10140
10061
|
fileHashCache = /* @__PURE__ */ new Map();
|
|
10141
10062
|
fileHashCachePath = "";
|
|
10142
10063
|
failedBatchesPath = "";
|
|
@@ -10296,7 +10217,6 @@ var Indexer = class _Indexer {
|
|
|
10296
10217
|
this.database = null;
|
|
10297
10218
|
this.provider = null;
|
|
10298
10219
|
this.configuredProviderInfo = null;
|
|
10299
|
-
this.reranker = null;
|
|
10300
10220
|
this.indexCompatibility = null;
|
|
10301
10221
|
this.initializationMode = "none";
|
|
10302
10222
|
this.readIssues = [];
|
|
@@ -11593,15 +11513,6 @@ var Indexer = class _Indexer {
|
|
|
11593
11513
|
rerankerEnabled: this.config.reranker?.enabled ?? false
|
|
11594
11514
|
});
|
|
11595
11515
|
this.provider = createEmbeddingProvider(this.configuredProviderInfo);
|
|
11596
|
-
if (this.config.reranker?.enabled) {
|
|
11597
|
-
this.reranker = createReranker(this.config.reranker);
|
|
11598
|
-
if (this.reranker.isAvailable()) {
|
|
11599
|
-
this.logger.info("Reranker initialized", {
|
|
11600
|
-
model: this.config.reranker.model,
|
|
11601
|
-
baseUrl: this.config.reranker.baseUrl
|
|
11602
|
-
});
|
|
11603
|
-
}
|
|
11604
|
-
}
|
|
11605
11516
|
const dimensions = this.configuredProviderInfo.modelInfo.dimensions;
|
|
11606
11517
|
const storePath = path19.join(this.indexPath, "vectors");
|
|
11607
11518
|
const vectorMetadataPath = `${storePath}.meta.json`;
|
|
@@ -13006,6 +12917,7 @@ var Indexer = class _Indexer {
|
|
|
13006
12917
|
const filterByBranch = options?.filterByBranch ?? true;
|
|
13007
12918
|
const sourceIntent = options?.definitionIntent === true || classifyQueryIntentRaw(query) === "source";
|
|
13008
12919
|
const identifierHints = extractIdentifierHints(query);
|
|
12920
|
+
const candidateLimit = maxResults * (sourceIntent ? 12 : 4);
|
|
13009
12921
|
this.logger.search("debug", "Starting search", {
|
|
13010
12922
|
query,
|
|
13011
12923
|
maxResults,
|
|
@@ -13042,7 +12954,7 @@ var Indexer = class _Indexer {
|
|
|
13042
12954
|
const semanticCandidates = embedding ? this.searchSemanticCandidates(
|
|
13043
12955
|
store,
|
|
13044
12956
|
embedding,
|
|
13045
|
-
|
|
12957
|
+
candidateLimit,
|
|
13046
12958
|
branchChunkIds,
|
|
13047
12959
|
shouldPrefilterByBranch
|
|
13048
12960
|
) : [];
|
|
@@ -13050,7 +12962,7 @@ var Indexer = class _Indexer {
|
|
|
13050
12962
|
const keywordStartTime = import_perf_hooks.performance.now();
|
|
13051
12963
|
const keywordCandidates = await this.keywordSearch(
|
|
13052
12964
|
query,
|
|
13053
|
-
|
|
12965
|
+
candidateLimit,
|
|
13054
12966
|
store,
|
|
13055
12967
|
invertedIndex,
|
|
13056
12968
|
branchChunkIds,
|
|
@@ -14212,7 +14124,6 @@ var Indexer = class _Indexer {
|
|
|
14212
14124
|
this.store = null;
|
|
14213
14125
|
this.invertedIndex = null;
|
|
14214
14126
|
this.provider = null;
|
|
14215
|
-
this.reranker = null;
|
|
14216
14127
|
this.configuredProviderInfo = null;
|
|
14217
14128
|
this.indexCompatibility = null;
|
|
14218
14129
|
this.initializationMode = "none";
|