opencode-rag-plugin 2.8.0 → 2.9.1

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.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * @fileoverview High-level public API for OpenCodeRAG: search, indexWorkspace, getContext,
3
3
  * scanWorkspace, and related types.
4
4
  */
5
+ import type { MinScoreMode } from "./retriever/retriever.js";
5
6
  import { type IndexRunStats } from "./indexer.js";
6
7
  import { type WorkspaceFile } from "./content/reader.js";
7
8
  import { type SearchResult } from "./core/interfaces.js";
@@ -15,6 +16,13 @@ export interface SearchOptions {
15
16
  topK?: number;
16
17
  /** Minimum relevance score threshold (0-1). */
17
18
  minScore?: number;
19
+ /**
20
+ * How the `minScore` gate reads the score: `"fused"` (default, today's
21
+ * behaviour) or `"normalized"` (scale-free — the score is divided by the
22
+ * maximum that result could reach, so the threshold keeps its meaning at
23
+ * every keyword weight).
24
+ */
25
+ minScoreMode?: MinScoreMode;
18
26
  /** Weight for hybrid keyword search (0-1). */
19
27
  keywordWeight?: number;
20
28
  /** Filter results to files matching these path patterns. */
package/dist/api.js CHANGED
@@ -48,6 +48,7 @@ export async function search(query, options = {}) {
48
48
  const rawResults = await retrieve(query, ctx.embedder, ctx.store, {
49
49
  topK,
50
50
  minScore: options.minScore ?? ctx.config.retrieval.minScore,
51
+ minScoreMode: options.minScoreMode ?? ctx.config.retrieval.minScoreMode,
51
52
  keywordIndex: ctx.keywordIndex,
52
53
  keywordWeight: options.keywordWeight ?? ctx.config.retrieval.hybridSearch?.keywordWeight ?? 0.4,
53
54
  symbolKeywordWeight: ctx.config.retrieval.hybridSearch?.symbolKeywordWeight,
@@ -240,6 +240,7 @@ export function registerEvalGateCommand(program) {
240
240
  const retrieveOptions = {
241
241
  topK,
242
242
  minScore: ctx.config.retrieval.minScore,
243
+ minScoreMode: ctx.config.retrieval.minScoreMode,
243
244
  keywordIndex: ctx.keywordIndex,
244
245
  keywordWeight: hybrid?.keywordWeight,
245
246
  symbolKeywordWeight: hybrid?.symbolKeywordWeight,
@@ -51,6 +51,7 @@ export function registerQueryCommand(program) {
51
51
  const rawResults = await retrieve(query, embedder, store, {
52
52
  topK,
53
53
  minScore,
54
+ minScoreMode: config.retrieval.minScoreMode,
54
55
  keywordIndex,
55
56
  keywordWeight: hybridCfg?.keywordWeight,
56
57
  hybridEnabled: hybridCfg?.enabled,
@@ -318,6 +318,22 @@ export interface MemoryConfig {
318
318
  toolErrorProactiveInject: boolean;
319
319
  /** Max tool gotchas injected into the system prompt per request (default 5). */
320
320
  toolErrorProactiveMaxItems: number;
321
+ /**
322
+ * Intercept failures the host does NOT report as tool errors (default true).
323
+ * A command that exits non-zero, a script that raises, a file that cannot be
324
+ * read, a failed model call — the host reports all of them as SUCCESS, so
325
+ * without this the quirk path never saw them. Detection is
326
+ * high-precision on purpose: a false positive costs a recall, a possible
327
+ * quirk write, and an injected block in the next model request.
328
+ */
329
+ interceptAllErrors: boolean;
330
+ /**
331
+ * Allow a failure detected this way to CREATE a quirk (default true). The
332
+ * exact duplicate check (same tool + same cause class) keeps it bounded to
333
+ * one quirk per failure kind, so a command that fails differently each time
334
+ * still yields a single entry.
335
+ */
336
+ autoCreateOnInterceptedError: boolean;
321
337
  /** Decay settings for aging quirks. */
322
338
  decay: {
323
339
  /** Whether confidence decays over time. */
@@ -535,6 +551,18 @@ export interface RagConfig {
535
551
  topK: number;
536
552
  /** Minimum relevance score threshold (0-1). */
537
553
  minScore: number;
554
+ /**
555
+ * How `minScore` reads the score (default `"fused"`).
556
+ *
557
+ * The fused hybrid score's scale depends on `hybridSearch.keywordWeight`:
558
+ * a vector-only hit can never exceed `1 - kw`, so at `kw = 0.4` a fixed
559
+ * `minScore` of 0.65 silently demands a DUAL hit (13.5 of 20 results
560
+ * survive vs 17.7 at `kw = 0`). `"normalized"` divides the score by the
561
+ * maximum that result could reach, so the threshold keeps its meaning at
562
+ * every keyword weight. `"fused"` keeps today's behaviour — the default
563
+ * does not change silently; a default flip needs a bigger golden set.
564
+ */
565
+ minScoreMode?: "fused" | "normalized";
538
566
  /** Hybrid search (vector + keyword) configuration. */
539
567
  hybridSearch?: {
540
568
  /** Whether hybrid search is enabled. */
@@ -130,6 +130,7 @@ export const DEFAULT_CONFIG = {
130
130
  retrieval: {
131
131
  topK: 20,
132
132
  minScore: 0.35,
133
+ minScoreMode: "fused",
133
134
  hybridSearch: {
134
135
  enabled: true,
135
136
  keywordWeight: 0.4,
@@ -329,6 +330,8 @@ export const DEFAULT_CONFIG = {
329
330
  toolErrorCreateLatencyBudgetMs: 2000,
330
331
  toolErrorInjectCreated: false,
331
332
  toolErrorProactiveInject: true,
333
+ interceptAllErrors: true,
334
+ autoCreateOnInterceptedError: true,
332
335
  toolErrorProactiveMaxItems: 5,
333
336
  decay: {
334
337
  enabled: false,
@@ -492,6 +495,9 @@ export function validateConfig(config) {
492
495
  if (config.memory?.toolErrorProactiveMaxItems != null && config.memory.toolErrorProactiveMaxItems < 0) {
493
496
  warnings.push("memory.toolErrorProactiveMaxItems must be >= 0");
494
497
  }
498
+ if (config.retrieval?.minScoreMode != null && !["fused", "normalized"].includes(config.retrieval.minScoreMode)) {
499
+ warnings.push(`retrieval.minScoreMode "${config.retrieval.minScoreMode}" — expected "fused" or "normalized"`);
500
+ }
495
501
  if (config.memory?.decay && config.memory.decay.halfLifeDays <= 0) {
496
502
  warnings.push("memory.decay.halfLifeDays must be > 0");
497
503
  }
@@ -150,6 +150,12 @@ export interface SearchExplanation {
150
150
  vectorRank?: number;
151
151
  /** Rank (0-indexed) in the keyword index results. */
152
152
  keywordRank?: number;
153
+ /**
154
+ * The highest score a result with these legs could reach (rank 0 in
155
+ * each). Set only in `minScoreMode: "normalized"`, where the reported
156
+ * score is the fused score divided by this value.
157
+ */
158
+ maxReachableScore?: number;
153
159
  /** Cross-encoder relevance from the optional rerank stage. Higher means more
154
160
  * relevant. NOT a calibrated probability (provider-dependent, llama-server
155
161
  * semantics) and NOT comparable to the RRF-normalized fused components.
@@ -91,6 +91,7 @@ export async function handleSearchSemantic(params, embedder, store, cfg, keyword
91
91
  const retrieveOpts = {
92
92
  topK,
93
93
  minScore: cfg.retrieval.minScore,
94
+ minScoreMode: cfg.retrieval.minScoreMode,
94
95
  keywordIndex,
95
96
  keywordWeight: cfg.retrieval.hybridSearch?.keywordWeight,
96
97
  hybridEnabled: cfg.retrieval.hybridSearch?.enabled,