opencode-self-improvement 0.28.1 → 0.29.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 +1 -0
- package/package.json +1 -1
- package/src/capture/prompt.ts +1 -1
- package/src/gate/gate.ts +55 -0
- package/src/tools/schema.ts +5 -1
package/README.md
CHANGED
|
@@ -88,6 +88,7 @@ Zero configuration is the default. To tune, use the object form of the plugin en
|
|
|
88
88
|
| `OPENCODE_MEMORY_INJECT_BUDGET` | Fallback for `injectBudget`. |
|
|
89
89
|
| `OPENCODE_MEMORY_FRONTIER_BUDGET` | Fallback for `frontierBudget`. |
|
|
90
90
|
| `OPENCODE_MEMORY_DEDUP` | Near-duplicate suppression inside a `memory_recall` window. Set to a content-token Jaccard threshold, for example `0.8`: a row that is a near-copy (same scope, Jaccard at or above the threshold) of a row already returned is skipped — the newest copy of a clash survives — so the window fills with distinct facts instead of repeats of the top hit. Rows that disagree on a negation word, or carry too little comparable content, are never suppressed. Unset or `0` returns the plain top-`limit` slice, byte-identical to previous behavior; below `0.5` the value is treated as a misconfiguration and the pass stays off; see [#409](https://github.com/abogartz/opencode-self-improvement/issues/409). |
|
|
91
|
+
| `OPENCODE_MEMORY_SYMPTOM` | Enforces the capture convention (#419): `learning` and `blocker` rows must open their content with the observable trigger a future session will hit, as `"When <symptom>: <fact>"`. A diary-shaped lesson ("In this session we fixed...") shares no words with the query the future session types — measured: surfaced 0/8 as diary, ranks 1-7 symptom-first — so the write gate blocks it with a rephrase hint instead of storing something that can never be recalled. ON by default; set `off` (or `0`/`false`) for automation holding a pre-convention backlog. A rewrite that keeps the supersede target's content byte-identical (a metadata-only `memory_update`, retag repair) is exempt — the rule shapes new lesson prose, not legacy-row maintenance. Other types (`context`, `decision`, `pattern`, `preference`) are unaffected. `scripts/symptom-fixer.ts` repairs old rows offline, grounding each symptom in the store's own query ledger. |
|
|
91
92
|
| `OPENCODE_MEMORY_QUERY_GATE` | When `1`, `true`, `yes` or `on`, a `memory_recall` match must share **two** whole words of the query once the query has three content words — the rule the injected relevance block already applies. Every other value, including `no`, keeps the matcher's permissive one-word admission. |
|
|
92
93
|
| `OPENCODE_COMMANDS_DIR` | Where the plugin mirrors its slash commands (default `~/.config/opencode/commands`). |
|
|
93
94
|
| `OPENCODE_VIEWER_HOST` | Interface the editor binds to (default `127.0.0.1`). A non-loopback bind serves the store over plain HTTP with no authentication — only do it on a network you control. See [Surfaces](#surfaces). |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-self-improvement",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
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/capture/prompt.ts
CHANGED
|
@@ -83,7 +83,7 @@ export function buildCapturePrompt(
|
|
|
83
83
|
// ranked 1-7 for the terse symptom queries agents actually issue when it
|
|
84
84
|
// opened with the observable trigger. The kw rule below is the bridge;
|
|
85
85
|
// this rule makes the content itself searchable and self-explanatory.
|
|
86
|
-
'- For `learning` and `blocker` rows, START the content with the observable trigger a future session will hit — the failing command, the error text, the wrong number — then the fact, as "When <symptom>: <fact>". A lesson written as a session diary ("In this session we fixed...") shares no words with the query a future session will type, and will never be recalled.',
|
|
86
|
+
'- For `learning` and `blocker` rows, START the content with the observable trigger a future session will hit — the failing command, the error text, the wrong number — then the fact, as "When <symptom>: <fact>". A lesson written as a session diary ("In this session we fixed...") shares no words with the query a future session will type, and will never be recalled. The write gate rejects `learning`/`blocker` rows that do not open this way.',
|
|
87
87
|
"- kw: 3-5 search keywords for how a DIFFERENT session would ask for this — synonyms and alternate names, other verb forms, the literal command or file name, and the words of the symptom itself (the failing command name, a distinctive error substring, the wrong figure's subject). They are indexed for retrieval and never shown to a model. Omit (or []) when the content already uses those words.",
|
|
88
88
|
"- guided: true ONLY when the user STATED this fact in their own words — a value, rate, number, rule or correction that appears in a user: line or the REQUESTS block. Omit guided for anything the agent discovered by itself.",
|
|
89
89
|
'- When guided AND the value names a declared code symbol, also output "ref": that symbol exactly as declared (e.g. "TAX_RATE"), "claim": the user\'s value alone (e.g. "0.0825", at most 32 characters), and "klass": "spec" when the user is the authority on the value (a rate, a requirement) or "behavior" when the row describes how working code behaves. Omit all three when no single declared constant is involved.',
|
package/src/gate/gate.ts
CHANGED
|
@@ -298,6 +298,25 @@ function deltaTokens(
|
|
|
298
298
|
return [...set];
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
+
/**
|
|
302
|
+
* The #419 symptom-clause rule (learning/blocker content must open with
|
|
303
|
+
* "When <symptom>:") is ON unless OPENCODE_MEMORY_SYMPTOM is off/0/false.
|
|
304
|
+
* Read per call so tests and automation can flip it without a restart.
|
|
305
|
+
*/
|
|
306
|
+
export function symptomRuleEnabled(
|
|
307
|
+
env: Record<string, string | undefined> = process.env,
|
|
308
|
+
): boolean {
|
|
309
|
+
const raw = env.OPENCODE_MEMORY_SYMPTOM;
|
|
310
|
+
return (
|
|
311
|
+
raw === undefined ||
|
|
312
|
+
!(
|
|
313
|
+
raw === "0" ||
|
|
314
|
+
raw.toLowerCase() === "off" ||
|
|
315
|
+
raw.toLowerCase() === "false"
|
|
316
|
+
)
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
|
|
301
320
|
export async function runWriteGate(
|
|
302
321
|
candidate: WriteCandidate,
|
|
303
322
|
ctx: GateContext,
|
|
@@ -429,6 +448,42 @@ export async function runWriteGate(
|
|
|
429
448
|
};
|
|
430
449
|
}
|
|
431
450
|
|
|
451
|
+
// The #419 capture convention, enforced: a `learning`/`blocker` row must
|
|
452
|
+
// open with the observable trigger a future session will hit. The measured
|
|
453
|
+
// gap is the whole argument — the same lesson surfaced 0/8 written as a
|
|
454
|
+
// session diary and ranked 1-7 written symptom-first, because the future
|
|
455
|
+
// searcher is typing the symptom, not the lesson. OPENCODE_MEMORY_SYMPTOM=off
|
|
456
|
+
// is the escape hatch for automation holding a pre-0.28 backlog; the
|
|
457
|
+
// backlog itself is repairable (scripts/symptom-fixer.ts), silence is not.
|
|
458
|
+
if (
|
|
459
|
+
(candidate.type === "learning" || candidate.type === "blocker") &&
|
|
460
|
+
symptomRuleEnabled() &&
|
|
461
|
+
!/^when\b[^\n]{0,160}:/i.test(candidate.content.replace(/^[\s\uFEFF]+/, ""))
|
|
462
|
+
) {
|
|
463
|
+
// New-vs-legacy distinction (#423 review): a rewrite that carries the
|
|
464
|
+
// supersede target's content byte-identical is a metadata repair, not a
|
|
465
|
+
// new lesson. retagQuarantinedRows and metadata-only memory_update on a
|
|
466
|
+
// legacy row re-submit unchanged prose — blocking them would stall
|
|
467
|
+
// quarantine repair forever and make legacy rows uneditable. New prose
|
|
468
|
+
// against a supersedesTs is still a new lesson and still blocked.
|
|
469
|
+
const repair =
|
|
470
|
+
ctx.supersedesTs !== undefined &&
|
|
471
|
+
(await loadScope(candidate.scope, reader)).some(
|
|
472
|
+
(m) =>
|
|
473
|
+
m.ts === ctx.supersedesTs &&
|
|
474
|
+
m.content === redactSecrets(candidate.content),
|
|
475
|
+
);
|
|
476
|
+
if (!repair) {
|
|
477
|
+
await recBlocked(4, "symptom_missing", [`type=${candidate.type}`], chain);
|
|
478
|
+
return {
|
|
479
|
+
action: "blocked",
|
|
480
|
+
reason: "symptom_missing",
|
|
481
|
+
chain,
|
|
482
|
+
hint: 'learning/blocker rows must open with the observable trigger: "When <symptom>: <fact>" (#419). Name the failing command, the error text, or the wrong number — the trigger clause must stay under 160 characters — or write the row as context/decision if it is not trigger-keyed.',
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
|
|
432
487
|
// This is the common boundary for manual, imported and auto-captured writes.
|
|
433
488
|
// Scrub content before hashing, analysis and persistence. Metadata is
|
|
434
489
|
// rejected above rather than silently changing where a row can be found.
|
package/src/tools/schema.ts
CHANGED
|
@@ -49,7 +49,11 @@ const keywordList = z
|
|
|
49
49
|
// ---- tool argument schemas (JSON Schema generated from these) ------------
|
|
50
50
|
|
|
51
51
|
export const RememberArgs = z.object({
|
|
52
|
-
type: z
|
|
52
|
+
type: z
|
|
53
|
+
.enum(TYPES)
|
|
54
|
+
.describe(
|
|
55
|
+
'Type of memory. A `learning` or `blocker` row must open its content with the observable trigger: "When <symptom>: <fact>" (#419).',
|
|
56
|
+
),
|
|
53
57
|
scope: memoryField.describe("Scope/area (e.g., auth, api, ctl)"),
|
|
54
58
|
content: z.string().describe("The memory content"),
|
|
55
59
|
issue: memoryField.describe("Related issue").optional(),
|