opencode-self-improvement 0.24.2 → 0.26.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/README.md +8 -3
- package/package.json +2 -1
- package/src/capture/available.ts +767 -0
- package/src/capture/runtime.ts +240 -13
- package/src/core/guidance.ts +23 -1
- package/src/core/tags.ts +14 -0
- package/src/recall/dedupe.ts +182 -0
- package/src/recall/relevant.ts +32 -2
- package/src/tools/recall.ts +6 -1
package/src/recall/relevant.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { readerFromSid, visibleTo } from "../store/model/visibility.ts";
|
|
|
6
6
|
import { FRAME } from "../inject/budget.ts";
|
|
7
7
|
import { formatMemory } from "../inject/format.ts";
|
|
8
8
|
import { conflictLine, findConstant, valuesAgree } from "./conflicts.ts";
|
|
9
|
-
import { USER_GUIDED_TAG } from "../core/tags.ts";
|
|
9
|
+
import { RESTATABLE_TAG, USER_GUIDED_TAG } from "../core/tags.ts";
|
|
10
10
|
import { cmpTs } from "../core/cmp-ts.ts";
|
|
11
11
|
import { scoreMemories } from "./score.ts";
|
|
12
12
|
|
|
@@ -88,6 +88,21 @@ export function isUserGuided(m: Memory): boolean {
|
|
|
88
88
|
return m.tags?.includes(USER_GUIDED_TAG) === true;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
/**
|
|
92
|
+
* #402: the working tree already states this fact. Such a row is STORED (it used
|
|
93
|
+
* to be dropped at capture, which is the defect #402 exists for), but it is the
|
|
94
|
+
* first thing a tight injection budget gives up: the next session can read it in
|
|
95
|
+
* the file, so a slot spent on it is a slot not spent on something the files do
|
|
96
|
+
* not hold.
|
|
97
|
+
*
|
|
98
|
+
* The guided lane is exempt. A user-stated row outranks an inferred one in this
|
|
99
|
+
* codebase everywhere, and capture tags guided rows too when their words are
|
|
100
|
+
* verbatim in the tree.
|
|
101
|
+
*/
|
|
102
|
+
export function isRestatable(m: Memory): boolean {
|
|
103
|
+
return m.tags?.includes(RESTATABLE_TAG) === true;
|
|
104
|
+
}
|
|
105
|
+
|
|
91
106
|
// Hint-channel caveat (#345). Measured: a WRONG user-guided row ("free
|
|
92
107
|
// shipping starts at $50 — the hidden suite encodes that") out-ranked correct
|
|
93
108
|
// code — the agent rewrote a correct threshold to match the memory. The
|
|
@@ -197,7 +212,22 @@ export async function selectRelevant(
|
|
|
197
212
|
// `shown` returns exactly what an explicit header check would.
|
|
198
213
|
let used = fitHeader.length;
|
|
199
214
|
shown = [];
|
|
200
|
-
|
|
215
|
+
// #402: PRIORITY decides who rides, and a restatement now sits last in that
|
|
216
|
+
// order — the tree already states it, so a slot spent here is a slot not
|
|
217
|
+
// spent on something the files do not hold. `merged` stays in score order:
|
|
218
|
+
// `selected` is the ledger's view of the ranking and a miss has to stay
|
|
219
|
+
// diagnosable, so the demotion is a separate WALK order, never a re-sort of
|
|
220
|
+
// the selection. The guided lane is exempt: a user-stated row outranks an
|
|
221
|
+
// inferred one in this codebase everywhere.
|
|
222
|
+
const demoted = (m: Memory | undefined): boolean =>
|
|
223
|
+
!!m && !guided.includes(m) && isRestatable(m);
|
|
224
|
+
const fitOrder = merged
|
|
225
|
+
.map((_, i) => i)
|
|
226
|
+
.sort(
|
|
227
|
+
(a, b) =>
|
|
228
|
+
(demoted(merged[a]) ? 1 : 0) - (demoted(merged[b]) ? 1 : 0) || a - b,
|
|
229
|
+
);
|
|
230
|
+
for (const i of fitOrder) {
|
|
201
231
|
const line = lines[i] ?? "";
|
|
202
232
|
if (used + 1 + line.length > budget) continue;
|
|
203
233
|
shown.push(i);
|
package/src/tools/recall.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { isVisibleTo, readerFromSid } from "../store/model/visibility.ts";
|
|
|
10
10
|
import type { Memory } from "../store/model/memory.ts";
|
|
11
11
|
import { RecallArgs, validated } from "./schema.ts";
|
|
12
12
|
import { firstFrontierTap, markFrontierTap } from "../capture/triggers.ts";
|
|
13
|
+
import { dedupeThreshold, dedupeWindow } from "../recall/dedupe.ts";
|
|
13
14
|
|
|
14
15
|
function scoreMemory(m: Memory, q: string): number {
|
|
15
16
|
// Same indexed fields as the injection scorer (#40): a row recalled by one of
|
|
@@ -52,8 +53,12 @@ export const register: ToolRegister = (editor, deps) => {
|
|
|
52
53
|
.map((x) => x.m);
|
|
53
54
|
}
|
|
54
55
|
const limit = args.limit || 20;
|
|
56
|
+
// #409 dedup lane (RESULTS §17): flag off, this is the same slice as
|
|
57
|
+
// before. Flag on, near-duplicate copies are skipped so the window
|
|
58
|
+
// fills with distinct rows instead of repeats of the top hit.
|
|
59
|
+
const dedupeAt = dedupeThreshold();
|
|
55
60
|
const limited = args.query
|
|
56
|
-
? results
|
|
61
|
+
? dedupeWindow(results, limit, dedupeAt)
|
|
57
62
|
: results.slice(-limit);
|
|
58
63
|
if (!limited.length) return { content: "No matching memories" };
|
|
59
64
|
const openIn = limited.filter((m) => m.status === "open").length;
|