opencode-self-improvement 0.30.5 → 0.31.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.
Files changed (56) hide show
  1. package/README.md +71 -244
  2. package/docs/auto-capture-evidence.md +8 -1
  3. package/docs/contradiction-authority.md +40 -4
  4. package/docs/development.md +23 -3
  5. package/docs/export-import.md +61 -0
  6. package/docs/flags.md +10 -2
  7. package/docs/import-quarantine.md +18 -2
  8. package/docs/injection-cost.md +10 -5
  9. package/docs/install.md +45 -0
  10. package/docs/options.md +41 -0
  11. package/docs/pre-release-ritual.md +4 -0
  12. package/docs/recall-quality.md +56 -0
  13. package/docs/repo-scoping.md +29 -5
  14. package/docs/secret-redaction.md +51 -0
  15. package/docs/store-concurrency.md +14 -1
  16. package/docs/surfaces.md +39 -0
  17. package/docs/troubleshooting.md +29 -0
  18. package/docs/use-ledger.md +61 -0
  19. package/docs/write-gates.md +17 -2
  20. package/docs/write-latency.md +25 -0
  21. package/package.json +1 -1
  22. package/src/capture/candidates.ts +1 -1
  23. package/src/capture/prompt.ts +1 -1
  24. package/src/capture/runtime.ts +19 -17
  25. package/src/capture/triggers.ts +1 -1
  26. package/src/consolidate/propose.ts +1 -1
  27. package/src/core/config/paths.ts +1 -1
  28. package/src/events.ts +2 -2
  29. package/src/gate/gate.ts +1 -1
  30. package/src/identity/session-context.ts +1 -1
  31. package/src/index.ts +18 -18
  32. package/src/init/run.ts +1 -1
  33. package/src/init/stamp.ts +1 -1
  34. package/src/inject/digest.ts +1 -1
  35. package/src/inject/epochs.ts +2 -2
  36. package/src/recall/gate.ts +30 -4
  37. package/src/status/report.ts +4 -4
  38. package/src/status/store-summary.ts +1 -1
  39. package/src/store/files/load.ts +1 -1
  40. package/src/store/lock.ts +1 -1
  41. package/src/store/prune.ts +1 -1
  42. package/src/store/tombstones/rejection.ts +1 -1
  43. package/src/store/tombstones/tombstone.ts +1 -1
  44. package/src/store/undo.ts +1 -1
  45. package/src/tools/consolidate.ts +2 -2
  46. package/src/tools/decay.ts +1 -1
  47. package/src/tools/deps.ts +1 -1
  48. package/src/tools/evidence.ts +1 -1
  49. package/src/tools/merge-review.ts +1 -1
  50. package/src/tools/recall.ts +15 -6
  51. package/src/tools/status-tool.ts +1 -1
  52. package/src/tools/update.ts +1 -1
  53. package/src/viewer/mutate.ts +1 -1
  54. /package/src/{command → init}/ensure.ts +0 -0
  55. /package/src/{hits → telemetry}/ledger.ts +0 -0
  56. /package/src/{evidence → telemetry}/record.ts +0 -0
@@ -1,8 +1,44 @@
1
1
  # Contradiction authority: the code check and its limits
2
2
 
3
- The scan behind a CONFLICT verdict, what it refuses to decide, and what is
4
- accepted as residual risk. The verdict table stays in the README.
3
+ You say the retry limit has to be `5`; the code says `3`. Before the plugin
4
+ takes sides it has to be sure it is reading a real declaration, so the check is
5
+ deliberately narrow — and what it refuses to decide is the more useful half of
6
+ this document.
5
7
 
6
- The code check accepts a unique top-level `const` with a literal value. Comments, string examples, local declarations and computed expressions cannot establish an authority verdict. The scan is limited to 300 source files, 256 KiB per file and depth 3, preferring `src/`; it does not follow source links or resolve imports. Ambiguous declarations, unreadable/invalid source, exhausted budgets or an undecidable claim keep the plain guidance and staleness caveat. The JavaScript/TypeScript parser loads only when a row needs a code check; explicit opt-out never loads it. Use attribution keeps the stored row's identity and prose while coverage counts only references present in the delivered text.
8
+ ## Who is the authority
7
9
 
8
- Accepted residual: a user-stated **wrong spec** still classifies as `spec`. Its verdict follows that stated requirement even if it breaks the current tests. The plugin does not infer hidden-suite authority or silently override the user's requirement. Asking an oracle or inventing an extra authority class is outside this contract. Capture classification can be wrong; a code comparison verifies a value mismatch, not the user's intent. Per the [maintainer's rollout decision](https://github.com/abogartz/opencode-self-improvement/pull/363#pullrequestreview-5819556342), the default is ON for full benchmarking after merge and can be revisited. The seat-model and merged-main confidence runs in #350–#352 remain outstanding; enabling the feature is not a claim that those benchmarks passed.
10
+ Capture records the kind of statement, and the verdict follows the class:
11
+
12
+ | Captured statement | Class | Verdict on a detected conflict |
13
+ | --- | --- | --- |
14
+ | User states the required value for a declared constant | `spec` | The user is the authority; change the constant to the stated requirement. |
15
+ | User describes how working code behaves | `behavior` | Code is the authority; keep the constant and raise the mismatch with the user. |
16
+ | Authority is unclear | Omit `klass` | Keep plain guidance and its staleness caveat; emit no CONFLICT verdict. |
17
+
18
+ ## What the check will read
19
+
20
+ One thing: a unique top-level `const` with a literal value. Comments, string
21
+ examples, local declarations and computed expressions cannot establish an
22
+ authority verdict. The scan is bounded to 300 source files, 256 KiB per file
23
+ and depth 3, preferring `src/`, and it does not follow source links or resolve
24
+ imports.
25
+
26
+ Anything it cannot settle — an ambiguous declaration, unreadable or invalid
27
+ source, an exhausted budget, a claim outside its reach — keeps the plain
28
+ guidance and its staleness caveat and emits no verdict. The JavaScript/TypeScript
29
+ parser loads only when a row needs a code check; an explicit opt-out never
30
+ loads it. Use attribution keeps the stored row's identity and prose while
31
+ coverage counts only references present in the delivered text.
32
+
33
+ ## The residual, accepted
34
+
35
+ A user-stated **wrong spec** still classifies as `spec`, and its verdict
36
+ follows that stated requirement even if it breaks the current tests. The plugin
37
+ does not infer a hidden test suite's authority and does not silently override
38
+ the user's requirement. Asking an oracle or inventing an extra authority class
39
+ is outside this contract.
40
+
41
+ Classification can also simply be wrong: a code comparison verifies a value
42
+ mismatch, not the user's intent.
43
+
44
+ Per the [maintainer's rollout decision](https://github.com/abogartz/opencode-self-improvement/pull/363#pullrequestreview-5819556342), the default is ON for full benchmarking after merge and can be revisited. The seat-model and merged-main confidence runs in #350–#352 remain outstanding; enabling the feature is not a claim that those benchmarks passed.
@@ -1,8 +1,28 @@
1
1
  # Development internals
2
2
 
3
- What the smoke suite really boots, and how the published npm surface is
4
- decided. The commands and the BDD-first rule stay in the README.
3
+ What the local commands really run, what the smoke suite boots, and how the
4
+ published npm surface is decided. The commands themselves and the BDD-first
5
+ rule stay in the README.
6
+
7
+ ## Local command to CI job
8
+
9
+ | Local command | Where it runs in CI | Gates a merge |
10
+ | --- | --- | --- |
11
+ | `bun run typecheck` | inside the job named `lint` | yes, under that name |
12
+ | `bun run lint` | `lint` | yes |
13
+ | `bun run test` | `test`, re-run in `test-windows` | `test` yes; `test-windows` reports only |
14
+ | `bun run test:e2e` | `smoke` | yes |
15
+
16
+ `tsc --noEmit` has no check of its own in CI — it runs inside `lint`, so a green `lint` silently implies a green typecheck.
17
+
18
+ `bun run lint` checks lint rules and TypeScript/TSX formatting, and CI calls the same command. Lint warnings stay advisory; formatting differences fail the check. Markdown commands, prose, JSON data and historical benchmark records are outside the formatter's scope.
19
+
20
+ The test scripts run files across at most four worker processes with Bun's file isolation. To reproduce an order-dependent failure the way it would appear in one shared process, run `bun test ./test/` or `bun test ./e2e/ --timeout 240000` directly.
21
+
22
+ ## What the smoke suite boots
5
23
 
6
24
  `e2e/` boots the **real opencode CLI** against each candidate in a fully isolated instance (fresh config, fresh db, fresh memory store, empty `HOME`) driven by a scripted OpenAI-compatible fake model — no API keys. It covers loading from the source tree and from the packed npm artifact installed runtime-deps-only, plus BDD flows for remember, recall, exact and near duplicates, ungrounded claims, and forget. Needs `opencode` on `PATH` locally, or set `OPENCODE_BIN`. A `test-windows` leg also runs the suite on Windows; it reports without gating merges.
7
25
 
8
- **The published surface is defined in `package.json`.** `exports` is the only import surface other code can reach (`.` → `index.ts`, `./tui` → `src/tui/panel.tsx`); `files` is the packaging list. `files` covers `src/`, so anything reachable from an `exports` target ships, but a new top-level file or directory — or anything the plugin reads at runtime outside those paths — must be added to `files` or it works from the checkout and vanishes from the npm artifact. The packed-artifact load in `e2e/` turns that miss red.
26
+ ## The published surface is `package.json`
27
+
28
+ `exports` is the only import surface other code can reach (`.` → `index.ts`, `./tui` → `src/tui/panel.tsx`); `files` is the packaging list. `files` covers `src/`, so anything reachable from an `exports` target ships, but a new top-level file or directory — or anything the plugin reads at runtime outside those paths — must be added to `files` or it works from the checkout and vanishes from the npm artifact. The packed-artifact load in `e2e/` turns that miss red.
@@ -0,0 +1,61 @@
1
+ # Export, import, and moving a store between machines
2
+
3
+ `memory_export` writes the store as JSONL and `memory_import` reads such a file
4
+ back. The contract worth memorizing: **you get what you can read, and an import
5
+ is not trusted input.**
6
+
7
+ ## What each tool exports
8
+
9
+ `memory_export` writes the store **as its caller can read it**: from a plugin
10
+ session that means your repository plus global rows. Full-store breadth belongs
11
+ to a session-less caller outside the plugin — the library route; the viewer has
12
+ no export route. `memory_import` reads such a file back, and every imported row
13
+ re-enters through the same four gates as `memory_remember` (tagged `import`,
14
+ original tags preserved).
15
+
16
+ ## The move
17
+
18
+ ```
19
+ Export my memories # -> <memory-root>/exports/<timestamp>-<unique>.jsonl
20
+ # …copy that file to the other machine's <memory-root>/…
21
+ Import <memory-root>/memories.jsonl # memory_import
22
+ ```
23
+
24
+ Both tools are model-facing, so a path is not a privilege: `file` must stay
25
+ inside the store — exports under `<memory-root>/exports`, imports anywhere under
26
+ `<memory-root>` — and a symbolic link cannot carry a request out of it. Pass
27
+ `scope` to export one scope. An operator running a one-off migration can restore
28
+ the old anywhere-on-disk behaviour with `OPENCODE_MEMORY_ALLOW_OUTSIDE_PATHS=1`,
29
+ which is read from the plugin process's own environment so a model cannot grant
30
+ it to itself.
31
+
32
+ ## The reply is a tally, not a yes/no
33
+
34
+ | Outcome | Meaning |
35
+ | --- | --- |
36
+ | `promoted` | passed the gates and was stored |
37
+ | `collapsed` | near-duplicate of an existing memory; nothing written |
38
+ | `blocked` | rejected by a gate; reason in `memory_evidence` |
39
+ | `skipped` | malformed line; never reached the gates |
40
+ | `downgraded` | imported as settled because its `status:"open"` could not be vouched for |
41
+
42
+ ## What the format is, and what confinement costs
43
+
44
+ The line format, what an import will believe about `status:"open"`, and the two
45
+ confinement limits no path check closes (a hard link inside `exports/`, and the
46
+ looser check on intermediate components):
47
+ [docs/import-quarantine.md](import-quarantine.md).
48
+
49
+ ## Quarantine
50
+
51
+ Import and auto-capture also scan incoming prose for instruction-override,
52
+ role-header and download/execute patterns. A promoted match is tagged `quarantine`
53
+ and withheld from recall, prompt and frontier injection, compaction anchors,
54
+ contextual pull, consolidation and decay. Think of it as a spam folder, not a
55
+ virus scanner: legitimate documentation can match, and several forms evade it.
56
+ Review the queue in the viewer's **quarantined** filter.
57
+
58
+ What the screen covers, what it misses, how an existing store is re-tagged, what
59
+ releasing quarantine does and what it leaves alone, and why direct
60
+ `memory_remember` and viewer edits are not scanned:
61
+ [docs/import-quarantine.md](import-quarantine.md).
package/docs/flags.md CHANGED
@@ -2,7 +2,15 @@
2
2
 
3
3
  The three flags that encode a measured finding rather than a preference:
4
4
  what each one enforces, the evidence behind it, and what an invalid value
5
- does. The README's table gives the default and the effect.
5
+ does. The README names the three and points here; this file is the whole
6
+ behaviour.
7
+
8
+ `OPENCODE_MEMORY_SYMPTOM` is the clearest case. A lesson saved as "in this
9
+ session we fixed the flaky test" shares no words with the query a future
10
+ session types, so it gets filed and never found: measured, 0 of 8 diary-shaped
11
+ rows surfaced, against ranks 1–7 when the same lesson opens with the symptom.
12
+ The flag therefore refuses the diary form at the write gate instead of storing
13
+ something unrecoverable.
6
14
 
7
15
  ## Flag behaviour
8
16
 
@@ -10,4 +18,4 @@ does. The README's table gives the default and the effect.
10
18
  | --- | --- |
11
19
  | `OPENCODE_MEMORY_DEDUP` | Near-duplicate suppression inside a `memory_recall` window. **ON by default at `0.8`** (content-token Jaccard): 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. Set `0` for the plain top-`limit` slice, byte-identical to the old behavior; an explicit value below `0.5` or above `1`, or one that is not a number, is a misconfiguration and turns the pass off; see [#409](https://github.com/abogartz/opencode-self-improvement/issues/409). |
12
20
  | `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. |
13
- | `OPENCODE_MEMORY_QUERY_GATE` | **ON by default**: 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, so both paths agree on when nothing is a good enough answer. Set `off` (also `0`, `no`, `n`, `false`, or any zero) to restore the matcher's permissive one-word admission. |
21
+ | `OPENCODE_MEMORY_QUERY_GATE` | **ON by default**: a `memory_recall` match must share **two** whole words of the query once the query has three content words — except when a complete query term matches an authored keyword unique among the visible candidates after scope and type filters. Automatic injection keeps its two-concept requirement. Set `off` (also `0`, `no`, `n`, `false`, or any zero) to restore the matcher's permissive one-word admission. |
@@ -1,8 +1,12 @@
1
1
  # Import, quarantine and the viewer's edit path
2
2
 
3
+ A quarantined row is a spam-folder row, not a deleted one: it stays in the
4
+ store where you can read it, and is withheld from everything the model reads.
5
+
3
6
  What the prose screen catches and misses, how an existing store gets
4
7
  re-tagged, what releasing quarantine does, and which writes it does not
5
- cover. The README keeps the export/import contract and the tally.
8
+ cover. The export contract and the import tally are in
9
+ [docs/export-import.md](export-import.md).
6
10
 
7
11
  Import and auto-capture also scan incoming prose for a small set of instruction-override, role-header, and download/execute patterns. Matching rows still face every write gate; a promoted match is tagged `quarantine` and withheld from recall, prompt/frontier injection, compaction anchors, contextual pull, scope/type listings, consolidation proposals, and decay. Decay previews do not quote these rows, and applied decay leaves them in the human review queue. The import reply counts quarantined promotions, gate evidence records pattern identifiers without copying the matched prose, and `/memory-report` lists review IDs for the caller's repository.
8
12
 
@@ -18,4 +22,16 @@ The viewer is a trusted admin editor: its edits and deleted-entry restores do no
18
22
 
19
23
  Existing stores are not rescanned. A byte-identical import that collapses into an existing row does not retroactively tag that row. Export preserves quarantined rows and their tags to avoid data loss; an exported released row can be quarantined again when re-import promotes it on another machine.
20
24
 
21
- An open row is exempt from reference grounding, so that status is honored only for files carrying an export header. Even with a header: an open row claiming `repo:"global"` is downgraded, and imported `repo` / `repoPath` stamps are kept only when they match the importing session's current repo — foreign stamps are dropped and the row is stamped for the importing repo. Re-running the same import in the same repo is a no-op.
25
+ ## The file format, and what an import will believe
26
+
27
+ A header line (`{_export, version, exportedAt, count}`) followed by one JSON object per line (`{ts,type,scope,content,status,tags,issue}`), active rows only.
28
+
29
+ An open row is exempt from reference grounding, so that status is honored only for files carrying an export header — a hand-written file without one imports such rows as settled. Even with a header: an open row claiming `repo:"global"` is downgraded, and imported `repo` / `repoPath` stamps are kept only when they match the importing session's current repo — foreign stamps are dropped and the row is stamped for the importing repo. Re-running the same import in the same repo is a no-op.
30
+
31
+ ## Keeping a path inside the store
32
+
33
+ Both tools are model-facing, so a path is treated as untrusted input rather than as permission. An export cannot write to `~/.gitconfig` or anywhere else outside the store, and an import cannot read outside it. Symbolic links are resolved before the check — including an `exports/` directory that is itself a link — so a link cannot carry a request out of the store. Exports are written `0600` and opened `O_NOFOLLOW` (both POSIX; on Windows the check before the write is the only guard).
34
+
35
+ The default name is `<memory-root>/exports/<timestamp>-<unique>.jsonl`, created exclusively, so two exports in the same second never replace each other's artifact.
36
+
37
+ Two limits no path check can close. A hard link planted inside `exports/` shares an inode with its target, so writing through it writes the target. And the check covers the final component more tightly than the intermediate path components, leaving a narrow window there. Both are stated rather than fixed because closing them means giving up the feature.
@@ -1,13 +1,18 @@
1
1
  # Injection epochs and their measured cost
2
2
 
3
+ Prompt caching turns a boring question into an expensive one: how often do the
4
+ bytes in front of the model actually change? The plugin's answer is to freeze
5
+ the memory section and re-render only when the frozen bytes would genuinely
6
+ differ — the same reason you cache an HTTP response by its body rather than by
7
+ how many times the database was touched.
8
+
9
+ Every figure here is bytes on a synthetic workload: not tokens, not a bill.
3
10
  The epoch mechanism, the deterministic byte workload behind the injection
4
- claim, and a provider audit reported by its author. Every figure here keeps
5
- the label it carried in the README: bytes are bytes, not tokens and not a
6
- bill.
11
+ claim, and a provider audit reported by its author.
7
12
 
8
13
  - **Section-frozen injection.** The whole memory section — standing digest, open-thread frontier, relevance block — is computed once per epoch and delivered byte-identically until something the model actually needs changes. The epoch's authority is the **rendered bytes**, not the store fingerprint: a promoted row that changes nothing visible costs no cache bust.
9
14
  - **A session never pays for bytes it is not riding.** A memory *you* saved in this session is a fact you already produced — it is in your own transcript — so it never busts your cache. The test is not "did the store change" but "would the frozen bytes still have been produced from the same inputs, minus the rows this session authored since": a correction, blocklisting, redaction or supersession of a row you are riding, and anything another session, the viewer or an import wrote, all still land on your next request.
10
- - **Two-concept threshold.** A free-text prompt must share at least two distinct concepts with a memory for it to be injected; keyword-length queries (one or two words) need only one. Silence on single-word coincidences is deliberate; `memory_recall` still reaches them on the pull path.
15
+ - **Two-concept threshold.** A free-text prompt must share at least two distinct concepts with a memory for it to be injected; keyword-length queries (one or two words) need only one. Silence on single-word coincidences is deliberate; an explicit `memory_recall` search can admit a complete authored keyword unique among its visible candidates.
11
16
  - **Identifiers split.** `getUserAccount`, `get_user_account`, `get-user-account` and `get.user.account` are one concept to the matcher rather than four, and a memory citing `src/recall/score.ts` answers a session that typed the path ([#409](https://github.com/abogartz/opencode-self-improvement/issues/409)). Measured on the published eval: aggregate recall unchanged, wrong-memory-first at the top falls 6% → 5%. Replayed over 1,091 logged recall queries through this scorer against the live store: 92.3% of top-5 sets are identical and 97.5% keep their top row.
12
17
  - **User-stated guidance rides ahead of relevance.** A row auto-capture tagged `user-guided` — something you said outright, like "the correct sales tax rate is 8.25%" — rides the block ahead of the lexical picks: newest-first, at most three, and `injectBudget` still bounds the whole block (`test/hint-channel.test.ts`). The channel exists because ranking cannot bridge vocabulary: a prompt about "the injected bug" shares no word with a row stating a tax rate, and the shipped matcher scored it zero ([#334](https://github.com/abogartz/opencode-self-improvement/issues/334)). `memory_recall` and the contextual pull stay query-driven — the channel changes only what rides the prompt. Because always-riding priority is a poisoning amplifier, the tag is minted by auto-capture alone: `memory_remember`, `memory_update` replacements and JSONL imports strip it, along with the contradiction fields ([#342](https://github.com/abogartz/opencode-self-improvement/issues/342), `test/guidance-provenance.test.ts`).
13
18
  - **The block re-scores at every user turn.** An epoch is not frozen at the first request: a later prompt re-scores, and the epoch MOVES only when the rendered bytes move — a prompt change that selects the same rows in the same order costs no cache bust ([#340](https://github.com/abogartz/opencode-self-improvement/issues/340), `test/epoch.test.ts`). Order is part of those bytes on this build: the lexical picks render in score order, so a prompt that keeps the same rows and re-ranks them moves the bytes and pays the bust. Canonical render order, which removes that churn, is still open ([#388](https://github.com/abogartz/opencode-self-improvement/issues/388), [#396](https://github.com/abogartz/opencode-self-improvement/pull/396)).
@@ -15,7 +20,7 @@ bill.
15
20
  - **Nothing volatile on the cached prefix.** The standing digest carries no row count and no latest timestamp. Both used to ride the very front of the system prompt, so every saved memory rewrote the prefix and made the next request re-bill the whole conversation; the exact numbers now live where they are free — the footer badge, `/memory`, `memory_status`, the viewer.
16
21
  - **Evidence is never injected**, and the standing system digest is two lines.
17
22
  - **Measured, not claimed.** The plugin reads each turn's `tokens.cache` accounting and displays the actual hit rate next to the badge. The same receipts now carry what the session generated — `output` and `reasoning`, shown split, because on a reasoning-heavy seat the completion side is where the cost actually goes. A host that reports neither shows nothing, never a zero.
18
- - **Auto-capture bills separately, and it is an estimate.** Capture is its own model call made after the turn, so it appears in no session's usage: read from session numbers, the plugin's own cost is exactly zero. The host exposes no receipt for it — `ctx.generate` has one member, `text`, resolving to `{ text }` with no `usage` — so `memory_status` reports chars/4 with `receipt=none` and the words "estimate, no provider receipt" on the line. Quote that number as an estimate or not at all. A pass disposed during teardown is not billed: its store is already gone, so the count undercounts by one call there.
23
+ - **Auto-capture bills separately, and it is an estimate.** Capture is its own model call made after the turn, so it appears in no session's usage: read from session numbers, the plugin's own cost is exactly zero. That reading is the misleading one — auto-capture is on by default, so the call happens on installs that never set an option. The host exposes no receipt for it — `ctx.generate` has one member, `text`, resolving to `{ text }` with no `usage` — so `memory_status` reports chars/4 with `receipt=none` and the words "estimate, no provider receipt" on the line. Quote that number as an estimate or not at all. A pass disposed during teardown is not billed: its store is already gone, so the count undercounts by one call there.
19
24
 
20
25
  **Bench** — deterministic workload (50 memories, 20 prompts, 3 mid-session store writes made *by the measured session*) through the plugin's real injection code. Every column is measured on the full memory section — the bytes a request actually sends — because prompt caching is a property of those bytes:
21
26
 
@@ -0,0 +1,45 @@
1
+ # Install variants and the version floor
2
+
3
+ The README keeps the three-step path: add the entry, restart, run `/repo-init`.
4
+ This file holds the other ways to install, how updates are resolved, and what to
5
+ point at when you are working on the plugin itself.
6
+
7
+ ## Plugin commands
8
+
9
+ ```sh
10
+ opencode plugin add opencode-self-improvement
11
+ opencode plugin update opencode-self-improvement
12
+ ```
13
+
14
+ Needs Bun 1.3.0 or newer in the opencode build (the tested floor); older Bun
15
+ reports a startup warning.
16
+
17
+ ## How an unpinned entry resolves
18
+
19
+ An unpinned entry resolves `@latest` exactly once and is never re-resolved
20
+ afterwards, so updates are deliberate: run `opencode plugin update` when you want
21
+ one. To pin, append `@<version>` — see [npm](https://www.npmjs.com/package/opencode-self-improvement)
22
+ for what is current.
23
+
24
+ ## Running from a checkout
25
+
26
+ To work on the plugin instead, clone it and point the entry at the checkout:
27
+
28
+ ```sh
29
+ git clone https://github.com/abogartz/opencode-self-improvement.git
30
+ cd opencode-self-improvement && bun install
31
+ ```
32
+
33
+ ```json
34
+ { "plugins": ["/full/path/to/opencode-self-improvement/index.ts"] }
35
+ ```
36
+
37
+ Then `git pull` and restart opencode to update.
38
+
39
+ ## Restart rules by host
40
+
41
+ A config edit needs a restart to take effect. On the desktop app, relaunching the
42
+ app is not enough: the background service stays alive with the options it already
43
+ parsed, so use `opencode service restart`. That is also why `memory_evidence` can
44
+ report a `capture=` value your config no longer contains. See
45
+ [docs/troubleshooting.md](troubleshooting.md).
@@ -0,0 +1,41 @@
1
+ # Options and environment variables
2
+
3
+ Every knob, in one place. The README keeps the ones you are likely to set; this
4
+ file is the complete reference, including what an invalid value does.
5
+
6
+ ## Plugin options
7
+
8
+ Set them in the object form of the plugin entry in `opencode.json(c)`:
9
+
10
+ ```json
11
+ {
12
+ "plugins": [{ "package": "opencode-self-improvement", "options": { "injectBudget": 1200, "frontierBudget": 3600 } }]
13
+ }
14
+ ```
15
+
16
+ | Option | Default | What it does |
17
+ | --- | --- | --- |
18
+ | `injectBudget` | `1200` | Character cap on the injected relevance block and each contextual pull; trimmed at whole-memory boundaries. Env fallback: `OPENCODE_MEMORY_INJECT_BUDGET`. |
19
+ | `frontierBudget` | `3 × injectBudget` | Character cap on the session-start open-threads block. A thread longer than the budget is not injected and is reported as omitted. Env fallback: `OPENCODE_MEMORY_FRONTIER_BUDGET`. |
20
+ | `contradictionSurface` | `true` | Experimental: compare guided constant claims with bounded source reads and render a class-specific CONFLICT verdict. Set `false` to skip code checks and retain plain guidance. See [docs/contradiction-authority.md](contradiction-authority.md). |
21
+ | `notifyBlocked` | `true` | Terminal (TUI) only: toast when a write gate blocks a write. Blocks are always in `memory_evidence` either way. |
22
+ | `autoCapture` | `true` | Master switch for auto-capture. On, so a plain install mines turn ends and compactions. Set `false` for no capture model call at all. |
23
+ | `captureModel` | inherits | `"provider/id"` model used for auto-capture. Unset means the model the session is using, else the host default. An explicit value that is not `provider/id` disables capture with a startup warning rather than substituting a model. |
24
+ | `captureMax` | `3` | Maximum candidates proposed per capture pass. |
25
+ | `captureOnCompact` | `true` | When auto-capture is armed, also mine the transcript at compaction, before the summarizer replaces it. Its 5-minute cooldown is separate from the turn-end one, so the two triggers' hit-rates stay measurable. Setting it while `autoCapture` is `false` does nothing and reports `switch_mismatch` on the `plugin_load` line. |
26
+ | `captureGuidedRules` | `false` | POC: deterministic guided-candidate pre-pass. The user's own lines decide which stated values or rules are guided (numbers, rates, currency, explicit rule assertions) and attach the verbatim quote; the capture model may phrase such a row but cannot clear the flag or the quote, and a guided quote the user never wrote is refused at the write boundary instead of silently stripped. Fires alongside the model pass only — no extra model calls. |
27
+
28
+ ## Environment variables
29
+
30
+ | Variable | Purpose |
31
+ | --- | --- |
32
+ | `OPENCODE_MEMORY_DIR` | Store location (default `~/.config/opencode/memory`). |
33
+ | `OPENCODE_MEMORY_ALLOW_OUTSIDE_PATHS` | Operator-only. When truthy, `memory_export`/`memory_import` accept paths anywhere on disk instead of confining themselves to the store. Off by default. It is read from the plugin process's own environment, so a model cannot grant it to itself through a tool argument. See [docs/import-quarantine.md](import-quarantine.md). |
34
+ | `OPENCODE_MEMORY_INJECT_BUDGET` | Fallback for `injectBudget`. |
35
+ | `OPENCODE_MEMORY_FRONTIER_BUDGET` | Fallback for `frontierBudget`. |
36
+ | `OPENCODE_COMMANDS_DIR` | Where the plugin mirrors its slash commands (default `~/.config/opencode/commands`). |
37
+ | `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. |
38
+ | `OPENCODE_VIEWER_PORT` | Admin editor port (default `8787`). |
39
+ | `OPENCODE_VIEWER_ALLOWED_HOSTS` | Comma-separated hosts beyond loopback. |
40
+
41
+ `OPENCODE_MEMORY_DEDUP`, `OPENCODE_MEMORY_SYMPTOM` and `OPENCODE_MEMORY_QUERY_GATE` are documented separately in [docs/flags.md](flags.md): they switch behaviour that a measurement decided, so the evidence behind each one matters more than the default.
@@ -1,5 +1,9 @@
1
1
  # Pre-release ritual: mutation sweep and artifact policy
2
2
 
3
+ A fire drill for the test suite: break one claimed invariant on purpose and
4
+ see whether anything notices. A mutant that no test kills is not a scandal —
5
+ it is a list of what the suite has been claiming without pinning.
6
+
3
7
  What `scripts/test-sweep.ts` measures, when a person runs it, and which
4
8
  benchmark artifacts stay out of git.
5
9
 
@@ -0,0 +1,56 @@
1
+ # Recall quality: what the keyword matcher gives up
2
+
3
+ A keyword matcher finds a memory when the words overlap. That is its whole
4
+ trick, and its whole weakness: "how we deploy" and "ship to staging" are the
5
+ same fact with no word in common. This file is what that costs, measured, and
6
+ what you can do about it at write time.
7
+
8
+ The headline table stays in the README. Full methodology and all store sizes:
9
+ `bench/recall-results.md`, reproduced with `bun run bench:recall`.
10
+
11
+ ## Write-time keywords are the answer to paraphrase
12
+
13
+ `memory_remember` asks each row for 3–5 `kw` aliases: other names for the same
14
+ thing, other verb forms, the literal command. Keywords are indexed and never
15
+ rendered into the prompt, so they cost nothing to store and nothing to inject.
16
+
17
+ **Bench** — the same matcher over the same store, with the only changed
18
+ variable being the index:
19
+
20
+ - strict (zero shared words) R@1 0% → 26%
21
+ - near (one overlap) R@1 28% → 67%
22
+
23
+ A permutation control — every row given someone else's aliases — scores
24
+ 29%/35%, so the gain is meaning rather than extra tokens. Auto-capture asks for
25
+ the same list, so these numbers are measured through the tool path rather than
26
+ through capture. The limit is narrowed, not removed.
27
+
28
+ ## Abstaining is a feature
29
+
30
+ Free-text prompts that share one concept with a memory abstain rather than
31
+ force a guess. Wrong top-memory fell to 6%. The cost is silence in cases where
32
+ a lucky guess would have been right; `memory_recall` still covers them when you
33
+ ask on purpose.
34
+
35
+ ### Explicit exact-keyword lookup
36
+
37
+ See the [transport lookup benchmark](https://github.com/abogartz/opencode-self-improvement/blob/64c494a26866851077ed2d59504c62a4f7809b56/bench/transport-lookup-results.md) for explicit recall and automatic injection on the same queries.
38
+
39
+ ## Why the default window is 5 rows
40
+
41
+ A live audit joined 1,090 recall events to their session transcripts. A
42
+ returned row at rank 1 shows up in a later tool call at 3.4x the rate of a
43
+ random store row, ranks 2–3 at 2.4x, and ranks 11–20 at 1.16x — noise against a
44
+ 0.129 null. The old default returned 17.7 rows per call, so most of the window
45
+ was context nobody read.
46
+
47
+ At limit 5, recall@1 and recall@3 are unchanged, precision rises 4.1% → 13.1%,
48
+ and 74% of the returned characters disappear. Every gold row the cut dropped sat
49
+ at ranks 6–20. Pass `limit` for a wider sweep ([#409](https://github.com/abogartz/opencode-self-improvement/issues/409)).
50
+
51
+ ## Caveats on the eval
52
+
53
+ The dataset is synthetic — 52 memories and 105 queries about a fictional
54
+ project — its class mix is deliberately adversarial, and scoring is
55
+ single-gold. Read the numbers as a comparison between matchers on one fixed
56
+ set, not as a prediction about your repository.
@@ -1,11 +1,35 @@
1
1
  # Repo scoping: identity, visibility and write refusal
2
2
 
3
- How a row's repository is derived and matched, which surfaces see what, and
4
- why an unresolved session has no write target. The README states the rule;
5
- this is the boundary detail.
3
+ Every row carries a label saying which repository wrote it. The label is
4
+ checked on the way in as well as the way out, and the two directions are not
5
+ symmetric: reading one extra project's memories is a nuisance, while writing
6
+ your private note into the wrong project is damage. So reads are permissive and
7
+ writes are strict.
8
+
9
+ The README states the rule; this is the boundary detail.
10
+
11
+ ## Identity
6
12
 
7
13
  Legacy whole-path-lowercased hashes accompanied by `repoPath` are matched to that directory (including real aliases), so a distinct case-sensitive sibling cannot inherit its memories or evidence. Remote-derived identities still share across clones. Stamps without `repoPath` retain key-only matching; their historical identity source cannot be recovered from the key alone.
8
14
 
9
- Injection, recall, the frontier block, compaction, `memory_forget` and decay only see the current repo plus global rows, resolved from the calling session's identity at flow entry. A session that reaches a plugin instance is bound to that instance's own workspace on first contact — in a process hosting several workspaces, one session never borrows the repository some other workspace's setup left behind. A session whose repository cannot be resolved at all sees global rows only; "unknown" is never "everything". Writes follow that rule in the stricter direction: a named session with no resolved repository has **no write target**, so `memory_remember`, `memory_update`, `memory_import` and auto-capture refuse it (evidence `write_refused`) and store nothing — the alternatives were stamping your private content into whichever workspace's `setup()` ran last, or publishing it to every project as an unstamped row. A caller that names no session at all (the viewer process, a restore, a script) keeps the process scope, and an explicit `global: true` is a deliberate owner. Evidence lines carry the same stamp, so `memory_evidence` answers from the caller's repo plus global lines; a line a named session wrote while its repository was unresolvable is private to that session, and only an explicitly global (or predating-stamps) line reads as global. Preferences that should follow you everywhere go in with `memory_remember global: true`. Rows written before scoping existed are global, and the viewer (an admin surface over every repo) edits and restores a row with its own repo stamp — the viewer's missing session scope never decides a row's visibility. `memory_merge_review` applies the same rule to its inputs: a session may merge exactly the rows it may read — global rows plus its own repo's, from either seat — and a row id it merely knows is not authority to retire another repo's memory. Upgrading changes nothing.
15
+ ## Who sees what
16
+
17
+ Injection, recall, the frontier block, compaction, `memory_forget` and decay only see the current repo plus global rows, resolved from the calling session's identity at flow entry. A session that reaches a plugin instance is bound to that instance's own workspace on first contact — in a process hosting several workspaces, one session never borrows the repository some other workspace's setup left behind. A session whose repository cannot be resolved at all sees global rows only; "unknown" is never "everything".
18
+
19
+ ## Why an unresolved session cannot write
20
+
21
+ Writes follow that rule in the stricter direction. A named session with no resolved repository has **no write target**, so `memory_remember`, `memory_update`, `memory_import` and auto-capture refuse it (evidence `write_refused`) and store nothing. The alternatives were stamping your private content into whichever workspace's `setup()` ran last, or publishing it to every project as an unstamped row.
22
+
23
+ A caller that names no session at all (the viewer process, a restore, a script) keeps the process scope, and an explicit `global: true` is a deliberate owner. Preferences that should follow you everywhere go in with `memory_remember global: true`. Rows written before scoping existed are global. Upgrading changes nothing.
24
+
25
+ `memory_merge_review` applies the same rule to its inputs: a session may merge exactly the rows it may read — global rows plus its own repo's, from either seat — and a row id it merely knows is not authority to retire another repo's memory.
26
+
27
+ ## Evidence attribution
28
+
29
+ Evidence lines carry the same stamp, so `memory_evidence` answers from the caller's repo plus global lines; a line a named session wrote while its repository was unresolvable is private to that session, and only an explicitly global (or predating-stamps) line reads as global.
30
+
31
+ Gate-authored evidence and its init/capture lifecycle records capture attribution at operation entry: if a session moves repositories while the operation runs, its audit lines remain in the starting repository's partition and can be read with `memory_evidence` from a session bound there. Init start/complete/skip, capture outcomes/refusals, and capture lag share that captured owner. A captured named session with no resolved repository keeps a session-private `sid` label even on lifecycle records that suppress call metadata; otherwise an unstamped line would appear global.
32
+
33
+ ## The viewer
10
34
 
11
- Gate-authored evidence and its init/capture lifecycle records capture attribution at operation entry: if a session moves repositories while the operation runs, its audit lines remain in the starting repository's partition and can be read with `memory_evidence` from a session bound there. Init start/complete/skip, capture outcomes/refusals, and capture lag share that captured owner. A captured named session with no resolved repository keeps a session-private `sid` label even on lifecycle records that suppress call metadata; otherwise an unstamped line would appear global. Viewer audit attribution and cancellation of in-flight capture are separate boundaries.
35
+ The viewer is an admin surface over every repo: it edits and restores a row with its own repo stamp, and the viewer's missing session scope never decides a row's visibility. Viewer audit attribution and cancellation of in-flight capture are separate boundaries.
@@ -0,0 +1,51 @@
1
+ # Secret redaction: what it covers and what it cannot
2
+
3
+ One best-effort credential rule set (`src/secrets.ts`) replaces recognized values
4
+ with `[redacted]`. Think of it as a metal detector at every door, not a safe: it
5
+ stops the recognized shapes, and it will never promise it saw everything.
6
+
7
+ It runs at every boundary a credential could persist, not one:
8
+
9
+ - over the auto-capture prompt before it leaves the plugin — the complete
10
+ transcript is redacted *before* the character budget crops it, so a credential
11
+ cut in half still matches its pattern;
12
+ - at the write gate, before content is hashed or analysed;
13
+ - again in the final write choke point used by gated writes and by the viewer's
14
+ edit and restore paths;
15
+ - at the durable audit boundaries — every evidence line, every supersede field
16
+ written into a retired row, and every deletion-audit reason.
17
+
18
+ So a recognized credential cannot persist in a new `evidence/` line, in a
19
+ deletion-audit `reason`, or in a supersede field written into a retired row,
20
+ whichever path carried it. It is not scrubbed from everything those paths touch —
21
+ see the limits below.
22
+
23
+ ## Covered patterns
24
+
25
+ OpenAI `sk-`, GitHub `ghp_` / `gho_` / `github_pat_`, Slack `xoxb-` / `xoxp-`,
26
+ AWS `AKIA`, Google `AIza`, bearer tokens containing digits, PEM private-key
27
+ blocks, and high-entropy values assigned to names ending in `_KEY`, `_TOKEN`,
28
+ `_SECRET` or `_PASSWORD` (plus `password`).
29
+
30
+ ## Limits worth knowing
31
+
32
+ - It can miss hex-only secrets, low-diversity passwords, and credentials written
33
+ in prose without an assignment.
34
+ - Credential-shaped `scope`, `tags` or `issue` metadata is rejected rather than
35
+ silently rewritten.
36
+ - `memory_remember` still replies `Remembered` when content was redacted, so the
37
+ stored text can differ from what was sent.
38
+ - Redaction is forward-only: existing stores are not scrubbed. `memory_export`
39
+ scrubs credentials out of `content`, `issue`, `scope`, `tags` and `kw` as it
40
+ serialises, so the file that leaves the machine carries `[redacted]` where a
41
+ stored row still holds a token; the store itself is untouched, and origin
42
+ stamps (`repo`, `repoPath`) are written as stored. The scrubber is a
43
+ best-effort sweep over known token families and high-entropy credential-shaped
44
+ values — an exotic credential can survive it, so an export is still a file you
45
+ hand out deliberately.
46
+ - Deleting a row copies it, it does not scrub it. `deletions.logfmt` keeps the
47
+ deleted row's `content`, `tags`, `kw` and `issue` exactly as the row held them
48
+ — a restore-entry built from that line has to re-stamp and re-attach precisely
49
+ what was there — and redacts only the `reason`. So deleting a row that predates
50
+ redaction writes its credential into the audit. Snapshots carry whatever a
51
+ stored row holds, for the same reason. That retention is deliberate (#292).
@@ -1,5 +1,10 @@
1
1
  # Store concurrency, publication and permissions
2
2
 
3
+ Replacing a store file while other sessions are reading it is the whole
4
+ problem. The answer is a book swap, not a page rewrite: the writer builds the
5
+ complete new file, then swaps it in under a lock. A reader therefore sees the
6
+ old file or the new one, never a half-written record.
7
+
3
8
  How a store file is replaced, what the lock covers, and what the plugin
4
9
  does and does not do about permissions. The README states the user-visible
5
10
  rules and links here.
@@ -10,4 +15,12 @@ The lock covers one **file**, not the store directory. Two sessions writing diff
10
15
 
11
16
  Two unsupported placements. The write-ahead log needs mmap'd shared memory, which SQLite does not provide on network filesystems, so a memory root on SMB, NFS or a OneDrive-mounted folder is **not supported**: writes there can report a disk I/O error rather than serialise. Configure `OPENCODE_MEMORY_DIR` on local disk. And during the update that introduced this lock, a session still running the previous release honours `<date>.logfmt.lock` while an updated session honours the SQLite lock, so those two do not exclude each other until every running session has restarted.
12
17
 
13
- On POSIX systems, new store directories use owner-only `0700` permissions and new files use `0600` (subject to a more restrictive umask). This includes temporary replacements, snapshots, locks (the lock database beside each store file), status files, and append-only logs. Accessing an existing store attempts to remove group/other permissions from its root; existing directories and appended/status files are tightened when written, without adding owner permissions. Old descendants are not recursively migrated: a successfully tightened root prevents other users from traversing to them. If directory chmod reports `EPERM`, `EROFS`, `EOPNOTSUPP`, or `ENOSYS` (for example an immutable or foreign-owned root, or a mount without chmod support), reads remain available with the existing permissions: owner-only traversal is not guaranteed. Correct ownership, mount support, or permissions outside the plugin when that privacy guarantee is required. File permission enforcement on writes remains unchanged. Existing ancestors outside the store are left unchanged. A store root that is itself a symlink is refused; configure its real directory instead. These modes do not revoke already-open handles or protect copies/hard links outside the private root. On Windows, privacy depends on the directory's ACL; the plugin does not change Windows ACLs.
18
+ On POSIX systems, new store directories use owner-only `0700` permissions and new files use `0600` (subject to a more restrictive umask) — including temporary replacements, snapshots, locks, status files and append-only logs. Accessing an existing store removes group/other permissions from its root, and tightens directories and files as they are written. Old descendants are not migrated recursively: a tightened root already stops other users from reaching them.
19
+
20
+ Three limits on that guarantee, stated plainly because they are privacy limits.
21
+
22
+ 1. If chmod reports `EPERM`, `EROFS`, `EOPNOTSUPP` or `ENOSYS` — an immutable root, a foreign-owned root, or a mount without chmod support — reads stay available under the existing permissions, so owner-only traversal is **not** guaranteed. Fix ownership, mount support or permissions outside the plugin when that guarantee is required.
23
+ 2. The modes do not revoke handles that are already open, and they do not protect copies or hard links made outside the private root.
24
+ 3. On Windows the plugin changes no ACLs; privacy there depends entirely on the directory's existing ACL.
25
+
26
+ A store root that is itself a symlink is refused; configure its real directory instead. Ancestors outside the store are left as they are.
@@ -0,0 +1,39 @@
1
+ # Surfaces
2
+
3
+ Four ways to see the same data. All of them read `memory_status`; none of them
4
+ makes a model call.
5
+
6
+ ## Terminal (opencode CLI)
7
+
8
+ The plugin ships a TUI half (`@opencode/plugin/tui`) that loads automatically.
9
+
10
+ - **Footer badge** — illustrative `● mem 1157/1200c · cache 96%`: the injected
11
+ block against its budget, plus the measured session prompt-cache hit rate. The
12
+ dot is green (stable and warm), yellow (recent recompute, or 50–90% reads) or
13
+ red (last turn served almost nothing from cache); `—` until the first assistant
14
+ turn, and `—` throughout on a provider that reports no cache usage.
15
+ - **`/memory`** — session panel: **CONTEXT** (what is riding the prompt now and
16
+ how much of the budget it uses), **CACHE** (busts this session and the measured
17
+ cache-served share of prompt tokens), **INJECTED BLOCK** (the verbatim block, or
18
+ an explicit abstention), **RECENT BLOCKED WRITES** (with gate reasons), **STORE**
19
+ (active / superseded / open / scopes, plus `malformed` when a row's `ts` is not
20
+ a valid ISO instant — those rows are skipped by every reader). Keys: `r`
21
+ refresh, `f` fullscreen.
22
+ - **Block toast** when a write is refused (`notifyBlocked: false` to silence).
23
+
24
+ ## Desktop / web / IDE
25
+
26
+ The terminal slots do not exist there, so use the self-installed
27
+ **`/memory-report`** chat command: the same sections rendered in the conversation.
28
+
29
+ ## Browser editor
30
+
31
+ `bun memory-view`, then http://127.0.0.1:8787. Bound to loopback; requests are
32
+ checked against `Host` and `Origin`, so other hosts must be listed explicitly in
33
+ `OPENCODE_VIEWER_ALLOWED_HOSTS`. Listing a non-loopback host serves the store over
34
+ plain HTTP with no authentication — only do it on a network you control.
35
+ `OPENCODE_VIEWER_HOST` changes the bind interface.
36
+
37
+ The viewer is a trusted admin seat. Its edits and deleted-entry restores skip the
38
+ model-facing grounding and deduplication gates but honor the same value
39
+ rejections: [docs/import-quarantine.md](import-quarantine.md).
@@ -0,0 +1,29 @@
1
+ # Troubleshooting, full list
2
+
3
+ The whole list: the problems people actually run into, and the rarer ones. The
4
+ README points here rather than repeating the table.
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
+ The seven cases a session actually hits.
20
+
21
+ | Problem | Fix |
22
+ | --- | --- |
23
+ | `memory_*` tools not available | The plugin didn't load. Restart opencode and check the `plugins` entry in your config. |
24
+ | `memory_remember` says blocked | A gate rejected the write: a stale code reference, a cited path that doesn't exist in the repo, overlap with a superseded memory, or an ambiguous claim. The reason is in `memory_evidence`; rephrase against current code and retry. |
25
+ | `invalid arguments to memory_*` | The call didn't match the tool's input schema; nothing was done and the message names the offending fields. Gate blocks look different (`blocked at GATE (…)`). |
26
+ | `memory store is busy` | A store write exhausted its 5s lock-wait budget, so the mutation is refused rather than run unlocked. Retry after contention clears. An operation spanning several files or steps may have completed earlier steps; refusal is not a rollback of those steps. If the reply reports `PARTIAL`, inspect the named rows and `memory_evidence` / `memory_undo` before retrying. A process that is killed releases the lock when it dies — there is no stale window to wait out. |
27
+ | Writes report a disk I/O error and the store is on a share | The lock's write-ahead log needs mmap'd shared memory, which SQLite does not support on network filesystems. SMB, NFS and OneDrive-mounted roots are unsupported — move `OPENCODE_MEMORY_DIR` to local disk. |
28
+ | Stale plugin after an update | `opencode plugin update opencode-self-improvement` (or bump the pinned `@version` in the `plugins` entry) and restart opencode. On desktop use `opencode service restart`: relaunching the app leaves the background service — and the plugin version and options it already parsed — alive. |
29
+ | Auto-capture does nothing | `memory_evidence` says which case you are in from the `plugin_load` line: `capture=on` (the default), `capture=off` (you set `autoCapture: false`), `invalid_model`, `no_capabilities` or `switch_mismatch`. `capture=on` with no `auto_capture_*` line after a session means the pass did not complete, and is not your configuration — see [Auto-capture](../README.md#auto-capture). On desktop, changing any of these options needs `opencode service restart`. The same `plugin_load` line carries `subscribed=[…]`, listing the event types that subscription really reacts to. |