opencode-self-improvement 0.9.1 → 0.9.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/inject.ts +10 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-self-improvement",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "Durable memory for opencode: remember facts, decisions, and commands across sessions, plus a one-command per-repo setup (/repo-init).",
5
5
  "main": "index.ts",
6
6
  "exports": {
package/src/inject.ts CHANGED
@@ -104,15 +104,22 @@ const LONG_QUERY_TOKENS = 3;
104
104
  // piles of common ones — the same idf form the bench's BM25 row uses).
105
105
  // Exported for bench/recall-quality.ts — the benchmark measures the shipped
106
106
  // matcher.
107
+ //
108
+ // Superseded rows are dropped HERE, not only by the callers. Every model-facing
109
+ // sink already passes isActive() rows, but a scorer that can be handed a raw
110
+ // loadAll() result must not be the one place a retired memory leaks back into
111
+ // an injected block (#43 item 1: forbidden hits). The drop also keeps a
112
+ // retired row from diluting the document frequencies the ranking depends on.
107
113
  export function scoreMemories(term: string, mems: Memory[], limit: number): Memory[] {
114
+ const live = mems.filter((m) => !m.superseded_by);
108
115
  const query = new Set(words(term).filter((t) => !QUERY_STOPWORDS.has(t)));
109
116
  if (!query.size) return [];
110
117
  const needShared = query.size >= LONG_QUERY_TOKENS ? 2 : 1;
111
- const hays = mems.map((m) => new Set(words(`${m.scope} ${m.type} ${m.content}`)));
118
+ const hays = live.map((m) => new Set(words(`${m.scope} ${m.type} ${m.content}`)));
112
119
  const df = new Map<string, number>();
113
120
  for (const h of hays) for (const t of h) df.set(t, (df.get(t) ?? 0) + 1);
114
- const n = mems.length || 1;
115
- return mems
121
+ const n = live.length || 1;
122
+ return live
116
123
  .map((m, i) => {
117
124
  let shared = 0;
118
125
  let score = 0;