opencode-self-improvement 0.30.4 → 0.31.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.
@@ -0,0 +1,22 @@
1
+ # Troubleshooting, full list
2
+
3
+ The README keeps the problems people actually run into. This file holds the
4
+ rarer ones, and repeats the common ones so one search finds the whole list.
5
+
6
+ ## Rarer problems
7
+
8
+ | Problem | Fix |
9
+ | --- | --- |
10
+ | STORE shows `N malformed` | A daily file has a `ts=` that is not a valid ISO instant (typically a hand-edit). Every reader skips those rows; fix the `ts=` or restore the file with `memory_undo`. |
11
+ | Stray `*.logfmt.lock` or `*.tmp` in the store | Write bookkeeping left by an older release; safe to delete while nothing is writing. Current releases leave `.store-lock.<file>.sqlite` beside each store file and `.store-batch.<name>.sqlite`: coordination state, holding no rows, one file per lock, safe to delete while nothing is writing. |
12
+ | `/repo-init` missing from the command list | The self-install couldn't write to `~/.config/opencode/commands/`. Create it and restart, or ask the model to "init memory for this repo" — the same tool. |
13
+ | `memory_init` rejects a call naming `mode` | The code-graph integration was removed (#231) and the tool schema refuses unknown arguments — drop `mode` from the call. Stamps written by older versions (their text carries `graph=`/`mode=`) still read fine; no re-init is forced. |
14
+ | `Error: Plugin is not configured` right after `plugin add` | An opencode bug ([#54654](https://github.com/anomalyco/opencode/issues/54654)), not a config problem: the first `plugin list/check/update` against a cold background service reads the plugin inventory before activation finishes. The plugin is installed and loading — just run the command again. |
15
+ | Reset all memories | Stop any running opencode session first, then delete `~/.config/opencode/memory/`. On Windows the delete fails with `EBUSY` while a session is live: the store lock is an open SQLite connection, and Windows will not delete a directory that contains one. |
16
+
17
+ ## Common problems
18
+
19
+ Kept in [README → Troubleshooting](../README.md#troubleshooting): tools not
20
+ available, a blocked `memory_remember`, an argument-schema rejection,
21
+ `memory store is busy`, a store on a network share, a stale plugin after an
22
+ update, and auto-capture doing nothing.
@@ -0,0 +1,50 @@
1
+ # The use ledger
2
+
3
+ A due-date card for every row: who looked at it, when, and how it reached them.
4
+ It answers one question you cannot answer any other way — is this memory
5
+ earning its place, or has nothing touched it in six months?
6
+
7
+ The ledger is `<memory-root>/hits.logfmt`: append-only, rotated at 2 MB, never
8
+ ingested as a memory, and reported in `memory_status` and the `/memory` panel.
9
+
10
+ ## What counts as use
11
+
12
+ Credit comes from three distinct sources, because "the model asked" and "the
13
+ harness offered" are different facts:
14
+
15
+ 1. the row rode the injected block;
16
+ 2. `memory_recall` returned it;
17
+ 3. a grep/read pull appended it.
18
+
19
+ Credit requires ≥2 shared terms with the query and is throttled to one line per
20
+ memory per session per source per hour, so one busy session cannot inflate a
21
+ row's standing.
22
+
23
+ **No prompt content is stored.** The ledger keeps a scan-truncated string from
24
+ the *memory* side, never your message.
25
+
26
+ ## What use is allowed to do
27
+
28
+ Reinforcement is a tie-break only (`useBoost ≤ 1.0`): a recently used row wins a
29
+ tie and can never outrank a real score gap. In consolidation, the most recently
30
+ used member of a cluster is never the merge loser.
31
+
32
+ `never retrieved` is stated, not acted on. Pruning is your decision, and retired
33
+ rows cannot inherit reinforcement: ledger rows are verified against the store on
34
+ read.
35
+
36
+ ## Whose numbers these are
37
+
38
+ Aggregate STORE counts are machine-wide by decision (#213 B): they count every
39
+ repository's rows in the shared store on this machine, never just the reading
40
+ session's repository. The numbers describe the store, not your slice of it.
41
+
42
+ Privacy applies to the content surfaces instead. `memory_evidence` and the
43
+ recent-blocked-writes list in `memory_status` and `/memory` follow each reader's
44
+ repository visibility (#306).
45
+
46
+ ## Capture lag
47
+
48
+ Capture lag is how stale the newest message was when auto-capture fired. The
49
+ line prints only when at least one `capture_lag` sample exists, which needs
50
+ auto-capture to have fired.
@@ -0,0 +1,21 @@
1
+ # Write gates and promotion evidence
2
+
3
+ A memory is a claim about your code, so it is checked the way a pull request
4
+ is: does the reference resolve, is something already on file stale, is it a
5
+ duplicate, and does it land or come back with a reason. The four gates and the
6
+ undo contract stay in the README. This file is what the audit trail keeps, and
7
+ what an update carries with it.
8
+
9
+ ## What promotion evidence samples
10
+
11
+ Promotion evidence keeps a bounded sample of call IDs: the ten most recent code-engagement calls, plus the latest gate check, the latest recorded gate FAIL/fix/PASS recovery, and the latest recorded tool FAIL/PASS retry (at most 16 distinct IDs). `evidence_refs_count` is the total number of recorded session calls before sampling, including non-code tools; the sampled IDs are audit pointers, not a complete history. Grounding and memory attribution still use the full in-memory ledger. Existing evidence day-files are left unchanged: this upgrade does not backfill, compact, or delete historical audit records.
12
+
13
+ ## What an update carries forward
14
+
15
+ `memory_update` picks its row by `query`: the row's id, a clock fragment such as `00:11:22.123`, or a unique substring of its text. Omit it and the newest entry of that scope and type is the target. A query that matches nothing, or that matches several rows, writes nothing and says so — an ambiguous selector is never resolved by picking one.
16
+
17
+ A prose edit carries the previous row's ordinary tags, issue link, retrieval keywords, open/settled standing and repository forward to the new row, so updating a `global` row from one machine keeps it global for every other. Capture-only guidance provenance is stripped by the replacement: an ordinary edit cannot re-mint a `user-guided` tag or a contradiction verdict.
18
+
19
+ Naming a row that an earlier update already superseded reports the duplicate when the live successor already holds exactly that content. When only the metadata you named differs, the update runs against the successor instead of dead-ending.
20
+
21
+ If a failure happens after the new row is already durable, the reply says `PARTIAL`. The message names what failed, the replacement stands on disk, and `memory_undo` (merge or force) brings the old row back.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-self-improvement",
3
- "version": "0.30.4",
3
+ "version": "0.31.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": {
@@ -36,6 +36,7 @@
36
36
  "src",
37
37
  "command",
38
38
  "vendor",
39
+ "docs",
39
40
  "README.md",
40
41
  "LICENSE"
41
42
  ],
@@ -1,5 +1,5 @@
1
1
  // candidates — split from src/capture.ts. Declaration bodies are unchanged.
2
- // Opt-in auto-capture parsing, prompt, and lag helpers. Host access and model
2
+ // Auto-capture parsing, prompt, and lag helpers. Host access and model
3
3
  // calls live in src/index.ts. Every candidate that leaves this module flows
4
4
  // through runWriteGate in index.ts: capture NEVER writes memories directly,
5
5
  // so dupes/stale/canonical rules keep the moat (same as model-authored writes).
@@ -1,5 +1,5 @@
1
1
  // prompt — split from src/capture.ts. Declaration bodies are unchanged.
2
- // Opt-in auto-capture parsing, prompt, and lag helpers. Host access and model
2
+ // Auto-capture parsing, prompt, and lag helpers. Host access and model
3
3
  // calls live in src/index.ts. Every candidate that leaves this module flows
4
4
  // through runWriteGate in index.ts: capture NEVER writes memories directly,
5
5
  // so dupes/stale/canonical rules keep the moat (same as model-authored writes).
@@ -190,28 +190,29 @@ export function configureAutoCapture(
190
190
  ) {
191
191
  let onCompactCapture: ((sid: string, messages: unknown) => void) | undefined;
192
192
  let captureCleanup: Cleanup | undefined;
193
- if (ctx.options?.autoCapture === true) {
194
- const captureModelOpt = ctx.options.captureModel;
195
- // an OMITTED captureModel no longer disables the subscription. It
193
+ const options = ctx.options ?? {};
194
+ if (options.autoCapture !== false) {
195
+ const captureModelOpt = options.captureModel;
196
+ // an OMITTED captureModel does not disable the subscription. It
196
197
  // resolves per capture — the per-session ref last seen on session.context,
197
198
  // else the host default — and only when both are missing does the pass
198
- // skip. autoCapture:true is already the explicit opt-in; a second required
199
- // config string was a syntax tax whose failure mode was a console.warn
200
- // nobody reads. An explicit but INVALID captureModel keeps today's
201
- // fail-closed setup behaviour: silently substituting another model than
202
- // the one the user typed is worse than the tax it replaces.
199
+ // skip. autoCapture is on by default, so the switch itself is the consent;
200
+ // requiring a second config string would be a syntax tax whose failure mode
201
+ // is a console.warn nobody reads. An explicit but INVALID captureModel
202
+ // keeps the fail-closed setup behaviour: silently substituting another
203
+ // model than the one the user typed is worse than the tax it replaces.
203
204
  const omitted = captureModelOpt === undefined;
204
- const captureMax = Number(ctx.options.captureMax) || 3;
205
+ const captureMax = Number(options.captureMax) || 3;
205
206
  // Deterministic guided-candidate pre-pass (POC): default OFF, the bench
206
207
  // picks the default-on arm (FINDINGS 2026-11-08 §4.4).
207
- const guidedRules = ctx.options?.captureGuidedRules === true;
208
- const captureOnCompact = ctx.options?.captureOnCompact !== false;
208
+ const guidedRules = options.captureGuidedRules === true;
209
+ const captureOnCompact = options.captureOnCompact !== false;
209
210
  // two cost levers, both OFF by default until the benchmark says which
210
211
  // way to set them. `captureOnSignal` skips a capture whose turn produced
211
212
  // nothing durable; `captureDelta` mines only the turns since the last
212
213
  // capture instead of re-reading the whole session every time.
213
- const captureOnSignal = ctx.options?.captureOnSignal === true;
214
- const captureDelta = ctx.options?.captureDelta === true;
214
+ const captureOnSignal = options.captureOnSignal === true;
215
+ const captureDelta = options.captureDelta === true;
215
216
  const modelRef = omitted ? null : parseModelRef(captureModelOpt);
216
217
  if (!omitted && !modelRef) {
217
218
  // Invalid explicit model: skip registering the whole subscription
@@ -1180,10 +1181,11 @@ export function configureAutoCapture(
1180
1181
  };
1181
1182
  }
1182
1183
  }
1183
- } else if (ctx.options?.captureOnCompact === true) {
1184
- // autoCapture is the master switch (zero-token default preserved).
1184
+ } else if (options.captureOnCompact === true) {
1185
+ // autoCapture is the master switch, so an explicit false wins over a
1186
+ // compaction trigger that was never turned off.
1185
1187
  console.warn(
1186
- "[opencode-self-improvement] captureOnCompact is on but autoCapture is off; compaction capture stays disabled (autoCapture is the master switch).",
1188
+ "[opencode-self-improvement] captureOnCompact is on but autoCapture is false; compaction capture stays disabled (autoCapture is the master switch).",
1187
1189
  );
1188
1190
  }
1189
1191
  return { onCompactCapture, cleanup: captureCleanup };
package/src/index.ts CHANGED
@@ -227,9 +227,10 @@ const impl = {
227
227
  );
228
228
  // ---- hooks (all fail-closed) -------------------------------------------
229
229
  // Seam set by the auto-capture wiring below ONLY when the compaction
230
- // trigger is live (autoCapture on, captureOnCompact not false, valid
231
- // captureModel). The compaction hook calls it fire-and-forget; undefined
232
- // means "off". Declared here because the hook registers before capture.
230
+ // trigger is live (autoCapture not false, captureOnCompact not false, and a
231
+ // model that resolves — the option, the session, or the host default). The
232
+ // compaction hook calls it fire-and-forget; undefined means "off".
233
+ // Declared here because the hook registers before capture.
233
234
  let onCompactCapture:
234
235
  | ((sid: string, messages: unknown) => void)
235
236
  | undefined;
@@ -246,13 +247,13 @@ const impl = {
246
247
  flushStatus,
247
248
  getCompactCapture: () => onCompactCapture,
248
249
  });
249
- // ---- opt-in auto-capture (idle + compaction triggers) ------------------
250
- // Default OFF: capture never reads sessions and never calls a model. (The
251
- // measured-cache listener above does subscribe to the event stream by
252
- // default, but it is zero-model: pure bookkeeping of message usage.) When
253
- // enabled (options.autoCapture === true AND a valid captureModel), each
254
- // supported turn-end event — and, unless captureOnCompact === false, each
255
- // compaction hook call too — runs ONE cheap ctx.generate.text call whose
250
+ // ---- auto-capture (turn-end + compaction triggers) ---------------------
251
+ // Armed unless the config sets `autoCapture: false`. (The measured-cache
252
+ // listener above also subscribes to the event stream, and it is
253
+ // zero-model: pure bookkeeping of message usage.) While armed — the switch
254
+ // not false, and a parseable `captureModel` whenever one is given — each
255
+ // supported turn-end event, and unless `captureOnCompact` is false each
256
+ // compaction hook call too, runs ONE cheap ctx.generate.text call whose
256
257
  // reply is parsed into candidates that go through the SAME runWriteGate as
257
258
  // model-authored writes — capture can never bypass the moat, and it only
258
259
  // ever writes through the gate. A per-session, per-trigger cooldown bounds
@@ -293,7 +294,9 @@ const impl = {
293
294
  } catch {
294
295
  // a heartbeat with an unknown version still beats no heartbeat
295
296
  }
296
- const wantCapture = ctx.options?.autoCapture === true;
297
+ // Auto-capture is armed unless the config opts it out: an absent key
298
+ // means on, so the switch is read as a negative opt-out.
299
+ const wantCapture = ctx.options?.autoCapture !== false;
297
300
  // an omitted captureModel is a valid arm — the capture inherits
298
301
  // the session's model (session.context) or the host default. Only an
299
302
  // explicit but malformed string is invalid_model.
@@ -158,18 +158,18 @@ export function attributionLines(p: StatusPayload): string[] {
158
158
  export function captureLines(c: CaptureHealth): string[] {
159
159
  switch (c.state) {
160
160
  case "off":
161
- return [" auto-capture: off (default)"];
161
+ return [" auto-capture: off (autoCapture: false)"];
162
162
  case "invalid_model":
163
163
  return [
164
- " auto-capture: invalid_model — autoCapture is on but captureModel is malformed; nothing fires",
164
+ ' auto-capture: invalid_model — captureModel is malformed, so auto-capture is disabled; expected "provider/id"',
165
165
  ];
166
166
  case "no_capabilities":
167
167
  return [
168
- " auto-capture: no_capabilities — autoCapture is on but the host lacks event.subscribe/generate.text/session.context",
168
+ " auto-capture: no_capabilities — the host lacks event.subscribe/generate.text/session.context, so auto-capture is disabled",
169
169
  ];
170
170
  case "switch_mismatch":
171
171
  return [
172
- " auto-capture: switch_mismatch — captureOnCompact is on but autoCapture is off; nothing fires",
172
+ " auto-capture: switch_mismatch — captureOnCompact is on but autoCapture is false; nothing fires",
173
173
  ];
174
174
  case "on": {
175
175
  // Inert means NO execution evidence at all: no candidate line and no