opencode-rag-plugin 2.2.2 → 2.3.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/dist/api.js +2 -0
- package/dist/chunker/factory.js +48 -18
- package/dist/chunker/image.js +6 -0
- package/dist/cli/commands/clear.js +21 -1
- package/dist/cli/commands/query.js +6 -0
- package/dist/cli/commands/status.js +4 -0
- package/dist/core/bootstrap.d.ts +3 -1
- package/dist/core/bootstrap.js +5 -0
- package/dist/core/config.d.ts +69 -1
- package/dist/core/config.js +63 -1
- package/dist/core/interfaces.d.ts +34 -0
- package/dist/describer/describer.js +9 -1
- package/dist/embedder/factory.d.ts +5 -1
- package/dist/embedder/factory.js +76 -6
- package/dist/embedder/health.d.ts +1 -1
- package/dist/embedder/health.js +43 -0
- package/dist/eval/rerank-eval.d.ts +45 -0
- package/dist/eval/rerank-eval.js +581 -0
- package/dist/indexer/pipeline.d.ts +17 -0
- package/dist/indexer/pipeline.js +123 -3
- package/dist/indexer/stats.d.ts +7 -0
- package/dist/mcp/handlers.js +3 -0
- package/dist/opencode/create-read-tool.js +5 -2
- package/dist/plugin.js +67 -6
- package/dist/quirks/quirk-store.d.ts +1 -0
- package/dist/quirks/quirk-store.js +1 -1
- package/dist/quirks/tool-error-recall.d.ts +112 -0
- package/dist/quirks/tool-error-recall.js +144 -0
- package/dist/reranker/base.d.ts +47 -0
- package/dist/reranker/base.js +73 -0
- package/dist/reranker/factory.d.ts +16 -0
- package/dist/reranker/factory.js +47 -0
- package/dist/reranker/llama-server.d.ts +33 -0
- package/dist/reranker/llama-server.js +101 -0
- package/dist/retriever/keyword-index.d.ts +1 -0
- package/dist/retriever/keyword-index.js +1 -1
- package/dist/retriever/retriever.d.ts +24 -1
- package/dist/retriever/retriever.js +69 -5
- package/dist/types/opencode-plugin.d.ts +2 -2
- package/dist/v2/v2-adapter.d.ts +6 -1
- package/dist/v2/v2-adapter.js +52 -8
- package/dist/vectorstore/lancedb.d.ts +1 -1
- package/dist/vectorstore/lancedb.js +43 -7
- package/dist/web/api.js +5 -0
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ export interface HealthCheckResult {
|
|
|
10
10
|
/** Model identifier that was tested */
|
|
11
11
|
model: string;
|
|
12
12
|
/** Which capability was checked */
|
|
13
|
-
type: "embedding" | "description" | "image_description" | "image_description_on_demand";
|
|
13
|
+
type: "embedding" | "description" | "image_description" | "image_description_on_demand" | "rerank";
|
|
14
14
|
/** Whether the provider is reachable and the model is available */
|
|
15
15
|
status: "ok" | "missing" | "error";
|
|
16
16
|
/** Human-readable error message when status is not "ok" */
|
package/dist/embedder/health.js
CHANGED
|
@@ -20,8 +20,51 @@ export async function checkProviderHealth(config) {
|
|
|
20
20
|
checks.push(checkOnDemandImageDescriptionModel(onDemand));
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
if (config.reranking?.enabled) {
|
|
24
|
+
checks.push(checkRerankModel(config));
|
|
25
|
+
}
|
|
23
26
|
return Promise.all(checks);
|
|
24
27
|
}
|
|
28
|
+
/** Check the rerank endpoint (llama-server `/v1/rerank`) with a minimal two-document scoring call. */
|
|
29
|
+
async function checkRerankModel(config) {
|
|
30
|
+
const rr = config.reranking;
|
|
31
|
+
const provider = rr?.provider ?? "llama-server";
|
|
32
|
+
const model = rr?.model ?? "unknown";
|
|
33
|
+
if (!rr?.enabled || !rr.baseUrl || !rr.model) {
|
|
34
|
+
return { provider, model, type: "rerank", status: "error", error: "reranking.enabled is true but reranking.baseUrl/model is not configured" };
|
|
35
|
+
}
|
|
36
|
+
const headers = {};
|
|
37
|
+
if (rr.apiKey) {
|
|
38
|
+
headers.Authorization = `Bearer ${rr.apiKey}`;
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
const response = await postJson(`${rr.baseUrl.replace(/\/+$/, "")}/rerank`, { model: rr.model, query: "health check", documents: ["First health check document.", "Second health check document."] }, headers, Math.min(rr.timeoutMs ?? 1500, 15000), rr.proxy);
|
|
42
|
+
if (response.ok) {
|
|
43
|
+
return { provider, model, type: "rerank", status: "ok" };
|
|
44
|
+
}
|
|
45
|
+
const body = await response.text().catch(() => "");
|
|
46
|
+
if (response.status === 404) {
|
|
47
|
+
return {
|
|
48
|
+
provider,
|
|
49
|
+
model,
|
|
50
|
+
type: "rerank",
|
|
51
|
+
status: "error",
|
|
52
|
+
error: "HTTP 404 from the rerank endpoint — is llama-server started with --reranking (and does your proxy route /v1/rerank)?",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (isModelNotFoundError(body)) {
|
|
56
|
+
return { provider, model, type: "rerank", status: "missing" };
|
|
57
|
+
}
|
|
58
|
+
return { provider, model, type: "rerank", status: "error", error: `HTTP ${response.status}: ${body.slice(0, 200)}` };
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
const msg = err.message || String(err);
|
|
62
|
+
if (isConnectionError(msg)) {
|
|
63
|
+
return { provider, model, type: "rerank", status: "error", error: "Connection refused. Is the rerank server running?" };
|
|
64
|
+
}
|
|
65
|
+
return { provider, model, type: "rerank", status: "error", error: msg.slice(0, 200) };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
25
68
|
/** Dispatch the embedding-model check to the correct provider-specific handler. */
|
|
26
69
|
async function checkEmbeddingModel(config, timeoutMs) {
|
|
27
70
|
const { provider, baseUrl, model, apiKey, proxy } = config.embedding;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Rerank A/B evaluation harness: runs labeled ground-truth queries through
|
|
3
|
+
* the real retrieval pipeline (baseline vs. opt-in rerank stage) and reports
|
|
4
|
+
* Hit@k, Precision@5, Recall@k, MRR, nDCG@10, and warm latency (p50/p95).
|
|
5
|
+
*
|
|
6
|
+
* Usage: node --import tsx src/eval/rerank-eval.ts [options]
|
|
7
|
+
*
|
|
8
|
+
* Options:
|
|
9
|
+
* --arms=baseline,rerank20,rerank30,rerank-desc Arms to run (default: baseline,rerank20,rerank30)
|
|
10
|
+
* --topk=20 Override retrieval topK (default: config)
|
|
11
|
+
* --minScore=0.35 Override retrieval minScore (default: config)
|
|
12
|
+
* --category=nl Only run labels of one category (nl|gotcha|symbol|de)
|
|
13
|
+
* --limit=10 Only run the first N labels (after filtering)
|
|
14
|
+
* --warmup=2 Discarded warmup queries per arm before measuring (default 2;
|
|
15
|
+
* llama-swap cold starts measure 15-25s and would pollute p50/p95)
|
|
16
|
+
* --labels=path Label file (default: src/eval/rerank-labels.json)
|
|
17
|
+
* --report=path Report file (default: doc/rerank-eval-report.md)
|
|
18
|
+
* --rerank-base-url=URL Rerank endpoint (e.g. http://127.0.0.1:11437/v1). Passing any
|
|
19
|
+
* --rerank-* flag enables the rerank arms without touching the
|
|
20
|
+
* user's opencode-rag.json (synthesized enabled section).
|
|
21
|
+
* --rerank-model=NAME Reranker model name (e.g. Qwen3-Reranker-0.6B)
|
|
22
|
+
* --rerank-api-key=KEY Optional bearer token for the rerank endpoint
|
|
23
|
+
* --rerank-provider=ID Provider id (default: llama-server)
|
|
24
|
+
* --rerank-timeout=MS Override the rerank stage timeout for this run (default: provider
|
|
25
|
+
* config, 1500). Raise it when the server needs >1.5 s for large
|
|
26
|
+
* candidate pools — otherwise most queries degrade to fusion order.
|
|
27
|
+
* --embedding-model=ID Override embedding.model for this run (e.g. Qwen3-Embedding:8B).
|
|
28
|
+
* Useful when the shared config is broken or leased by another session.
|
|
29
|
+
* --embedding-base-url=… Override embedding.baseUrl for this run.
|
|
30
|
+
*
|
|
31
|
+
* Design notes:
|
|
32
|
+
* - Ground truth lives in `rerank-labels.json` as query -> file paths (+ optional
|
|
33
|
+
* symbol). Chunk IDs are deliberately NOT used: they do not survive re-indexing.
|
|
34
|
+
* - The reranker module is imported dynamically so this harness type-checks and runs
|
|
35
|
+
* while `src/reranker/**` is still under construction. Rerank arms are skipped with
|
|
36
|
+
* a diagnostic when the config has no enabled `reranking.*` section, the module is
|
|
37
|
+
* missing, or the provider cannot be created (e.g. llama-server without --reranking).
|
|
38
|
+
* - Latency is measured warm: each arm issues one discarded warmup query first, so
|
|
39
|
+
* embedding/rerank connection setup does not pollute p50/p95. Cold start is a
|
|
40
|
+
* separate, documented number — not part of this measurement.
|
|
41
|
+
* - `retrieve()` is called through a loose local signature on purpose: the rerank
|
|
42
|
+
* stage is being developed in parallel, and this harness must not depend on its
|
|
43
|
+
* exact RetrieveOptions type.
|
|
44
|
+
*/
|
|
45
|
+
export {};
|