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.js
CHANGED
|
@@ -2330,7 +2330,7 @@ function analyzeQueryIntent(query) {
|
|
|
2330
2330
|
}
|
|
2331
2331
|
function isTestPath(filePath) {
|
|
2332
2332
|
const normalized = normalizePath(filePath);
|
|
2333
|
-
return /(?:^|\/)(?:test|tests|__tests__|spec|specs)(?:\/|$)/u.test(normalized) ||
|
|
2333
|
+
return /(?:^|\/)(?:test|tests|__tests__|spec|specs)(?:\/|$)/u.test(normalized) || /(?:\.(?:test|spec)|_(?:test|spec))\.[^/]+$/u.test(normalized) || /(?:^|\/)(?:test|spec)_[^/]+\.[^/]+$/u.test(normalized);
|
|
2334
2334
|
}
|
|
2335
2335
|
function isFixturePath(filePath) {
|
|
2336
2336
|
const normalized = normalizePath(filePath);
|
|
@@ -6430,85 +6430,6 @@ function createEmbeddingProvider(configuredProviderInfo) {
|
|
|
6430
6430
|
}
|
|
6431
6431
|
}
|
|
6432
6432
|
|
|
6433
|
-
// src/rerank/index.ts
|
|
6434
|
-
function createReranker(config) {
|
|
6435
|
-
if (!config.enabled) {
|
|
6436
|
-
return new NoOpReranker();
|
|
6437
|
-
}
|
|
6438
|
-
return new SiliconFlowReranker(config);
|
|
6439
|
-
}
|
|
6440
|
-
var NoOpReranker = class {
|
|
6441
|
-
isAvailable() {
|
|
6442
|
-
return false;
|
|
6443
|
-
}
|
|
6444
|
-
async rerank(_query, documents, _topN) {
|
|
6445
|
-
return {
|
|
6446
|
-
results: documents.map((_, index) => ({ index, relevanceScore: 0 }))
|
|
6447
|
-
};
|
|
6448
|
-
}
|
|
6449
|
-
};
|
|
6450
|
-
var SiliconFlowReranker = class {
|
|
6451
|
-
config;
|
|
6452
|
-
constructor(config) {
|
|
6453
|
-
this.config = config;
|
|
6454
|
-
}
|
|
6455
|
-
isAvailable() {
|
|
6456
|
-
return this.config.enabled && !!this.config.baseUrl && !!this.config.model;
|
|
6457
|
-
}
|
|
6458
|
-
async rerank(query, documents, topN) {
|
|
6459
|
-
if (documents.length === 0) {
|
|
6460
|
-
return { results: [] };
|
|
6461
|
-
}
|
|
6462
|
-
const headers = {
|
|
6463
|
-
"Content-Type": "application/json"
|
|
6464
|
-
};
|
|
6465
|
-
if (this.config.apiKey) {
|
|
6466
|
-
headers["Authorization"] = `Bearer ${this.config.apiKey}`;
|
|
6467
|
-
}
|
|
6468
|
-
const baseUrl = this.config.baseUrl;
|
|
6469
|
-
if (!baseUrl) {
|
|
6470
|
-
throw new Error("Reranker baseUrl is required. Configure reranker.baseUrl in your codebase-index.json.");
|
|
6471
|
-
}
|
|
6472
|
-
const timeoutMs = this.config.timeoutMs ?? 3e4;
|
|
6473
|
-
const controller = new AbortController();
|
|
6474
|
-
const timeout = setTimeout(() => controller.abort(), timeoutMs);
|
|
6475
|
-
try {
|
|
6476
|
-
const response = await fetch(`${baseUrl}/rerank`, {
|
|
6477
|
-
method: "POST",
|
|
6478
|
-
headers,
|
|
6479
|
-
body: JSON.stringify({
|
|
6480
|
-
model: this.config.model,
|
|
6481
|
-
query,
|
|
6482
|
-
documents,
|
|
6483
|
-
top_n: topN ?? this.config.topN ?? 20,
|
|
6484
|
-
return_documents: false
|
|
6485
|
-
}),
|
|
6486
|
-
signal: controller.signal
|
|
6487
|
-
});
|
|
6488
|
-
clearTimeout(timeout);
|
|
6489
|
-
if (!response.ok) {
|
|
6490
|
-
const errorText = await response.text();
|
|
6491
|
-
throw new Error(`Rerank API error: ${response.status} - ${errorText}`);
|
|
6492
|
-
}
|
|
6493
|
-
const data = await response.json();
|
|
6494
|
-
return {
|
|
6495
|
-
results: data.results.map((r) => ({
|
|
6496
|
-
index: r.index,
|
|
6497
|
-
relevanceScore: r.relevance_score,
|
|
6498
|
-
document: r.document?.text
|
|
6499
|
-
})),
|
|
6500
|
-
tokensUsed: data.meta?.tokens?.input_tokens
|
|
6501
|
-
};
|
|
6502
|
-
} catch (error) {
|
|
6503
|
-
clearTimeout(timeout);
|
|
6504
|
-
if (error instanceof Error && error.name === "AbortError") {
|
|
6505
|
-
throw new Error(`Rerank API request timed out after ${timeoutMs}ms`);
|
|
6506
|
-
}
|
|
6507
|
-
throw error;
|
|
6508
|
-
}
|
|
6509
|
-
}
|
|
6510
|
-
};
|
|
6511
|
-
|
|
6512
6433
|
// src/utils/logger.ts
|
|
6513
6434
|
var LOG_LEVEL_PRIORITY = {
|
|
6514
6435
|
error: 0,
|
|
@@ -8622,7 +8543,8 @@ function rankHybridResults(query, semanticResults, keywordResults, options) {
|
|
|
8622
8543
|
return cached;
|
|
8623
8544
|
}
|
|
8624
8545
|
}
|
|
8625
|
-
const
|
|
8546
|
+
const overfetchFactor = prioritizeSourcePaths ? 12 : 4;
|
|
8547
|
+
const overfetchLimit = Math.max(options.limit * overfetchFactor, options.limit);
|
|
8626
8548
|
const fused = options.fusionStrategy === "rrf" ? fuseResultsRrf(semanticResults, keywordResults, options.rrfK, overfetchLimit) : fuseResultsWeighted(semanticResults, keywordResults, options.hybridWeight, overfetchLimit);
|
|
8627
8549
|
const rerankPoolLimit = Math.max(overfetchLimit, options.rerankTopN * 3, options.limit * 6);
|
|
8628
8550
|
const rerankPool = fused.slice(0, rerankPoolLimit);
|
|
@@ -10133,7 +10055,6 @@ var Indexer = class _Indexer {
|
|
|
10133
10055
|
database = null;
|
|
10134
10056
|
provider = null;
|
|
10135
10057
|
configuredProviderInfo = null;
|
|
10136
|
-
reranker = null;
|
|
10137
10058
|
fileHashCache = /* @__PURE__ */ new Map();
|
|
10138
10059
|
fileHashCachePath = "";
|
|
10139
10060
|
failedBatchesPath = "";
|
|
@@ -10293,7 +10214,6 @@ var Indexer = class _Indexer {
|
|
|
10293
10214
|
this.database = null;
|
|
10294
10215
|
this.provider = null;
|
|
10295
10216
|
this.configuredProviderInfo = null;
|
|
10296
|
-
this.reranker = null;
|
|
10297
10217
|
this.indexCompatibility = null;
|
|
10298
10218
|
this.initializationMode = "none";
|
|
10299
10219
|
this.readIssues = [];
|
|
@@ -11590,15 +11510,6 @@ var Indexer = class _Indexer {
|
|
|
11590
11510
|
rerankerEnabled: this.config.reranker?.enabled ?? false
|
|
11591
11511
|
});
|
|
11592
11512
|
this.provider = createEmbeddingProvider(this.configuredProviderInfo);
|
|
11593
|
-
if (this.config.reranker?.enabled) {
|
|
11594
|
-
this.reranker = createReranker(this.config.reranker);
|
|
11595
|
-
if (this.reranker.isAvailable()) {
|
|
11596
|
-
this.logger.info("Reranker initialized", {
|
|
11597
|
-
model: this.config.reranker.model,
|
|
11598
|
-
baseUrl: this.config.reranker.baseUrl
|
|
11599
|
-
});
|
|
11600
|
-
}
|
|
11601
|
-
}
|
|
11602
11513
|
const dimensions = this.configuredProviderInfo.modelInfo.dimensions;
|
|
11603
11514
|
const storePath = path19.join(this.indexPath, "vectors");
|
|
11604
11515
|
const vectorMetadataPath = `${storePath}.meta.json`;
|
|
@@ -13003,6 +12914,7 @@ var Indexer = class _Indexer {
|
|
|
13003
12914
|
const filterByBranch = options?.filterByBranch ?? true;
|
|
13004
12915
|
const sourceIntent = options?.definitionIntent === true || classifyQueryIntentRaw(query) === "source";
|
|
13005
12916
|
const identifierHints = extractIdentifierHints(query);
|
|
12917
|
+
const candidateLimit = maxResults * (sourceIntent ? 12 : 4);
|
|
13006
12918
|
this.logger.search("debug", "Starting search", {
|
|
13007
12919
|
query,
|
|
13008
12920
|
maxResults,
|
|
@@ -13039,7 +12951,7 @@ var Indexer = class _Indexer {
|
|
|
13039
12951
|
const semanticCandidates = embedding ? this.searchSemanticCandidates(
|
|
13040
12952
|
store,
|
|
13041
12953
|
embedding,
|
|
13042
|
-
|
|
12954
|
+
candidateLimit,
|
|
13043
12955
|
branchChunkIds,
|
|
13044
12956
|
shouldPrefilterByBranch
|
|
13045
12957
|
) : [];
|
|
@@ -13047,7 +12959,7 @@ var Indexer = class _Indexer {
|
|
|
13047
12959
|
const keywordStartTime = performance2.now();
|
|
13048
12960
|
const keywordCandidates = await this.keywordSearch(
|
|
13049
12961
|
query,
|
|
13050
|
-
|
|
12962
|
+
candidateLimit,
|
|
13051
12963
|
store,
|
|
13052
12964
|
invertedIndex,
|
|
13053
12965
|
branchChunkIds,
|
|
@@ -14209,7 +14121,6 @@ var Indexer = class _Indexer {
|
|
|
14209
14121
|
this.store = null;
|
|
14210
14122
|
this.invertedIndex = null;
|
|
14211
14123
|
this.provider = null;
|
|
14212
|
-
this.reranker = null;
|
|
14213
14124
|
this.configuredProviderInfo = null;
|
|
14214
14125
|
this.indexCompatibility = null;
|
|
14215
14126
|
this.initializationMode = "none";
|