Persistent memory for OpenCode — zero config, visible results.
Your AI coding assistant forgets everything between sessions. This plugin fixes that. It silently saves what matters and finds it when needed — no extra prompts, no manual effort.
Before every reply, the plugin searches your memory for relevant context. After every session, it quietly saves durable knowledge. You never have to say "remember this" — but when you do, it listens.
You: "What build tool does this project use?"
AI: [searches memory] → "Bun. You decided that on April 10."
- Answers informed by your past decisions, preferences, and project history
- No repeated explanations across sessions
- Privacy-first: secrets and private blocks are never stored
- Works entirely locally — no cloud, no API keys, no MCP server
Prerequisites: OpenCode and Python 3.10+ with pip.
pip install mempalace
mempalace init ~/.mempalace/palaceAdd to opencode.json:
{
"plugin": ["@rvboris/opencode-mempalace"]
}That's it. Memory search, autosave, and both tools are active immediately.
Hidden retrieval
Before each answer, the plugin injects a search instruction so the model checks your memory first. No tool call noise in the chat — the context just appears.
On session idle, compaction, or close, the plugin mines the conversation transcript for durable facts and saves them to the right memory area automatically.
Four modes, one interface:
| Mode | Purpose |
|---|---|
save |
Store a preference, fact, or decision |
search |
Find relevant memory by query |
kg_add |
Add a structured fact to the knowledge graph |
diary_write |
Save a short work note |
Examples:
mempalace_memory mode: save scope: user room: preferences content: Prefers concise responses.
mempalace_memory mode: search scope: project room: decisions query: build tool
mempalace_memory mode: kg_add subject: my-repo predicate: uses object: bun
Check whether the plugin is actually helping:
mempalace_status
Shows retrieval hit rate, last autosave outcome, memory previews, and cumulative counters. Use verbose: true for full detail.
A compact session stats line appears in the OpenCode prompt area:
MEM hits 3 · saved 2 · failed 0 · writes 1
Color-coded indicators for SKIPPED and FAILED states. Requires a tui.json entry (see below).
User memory — cross-project preferences and habits:
preferences— coding style, communication preferencesworkflow— working patterns, tool choicescommunication— language, response format
Project memory — repository-specific knowledge:
architecture— design decisions, patternsworkflow— build commands, CI configdecisions— ADRs, trade-offsbugs— known issues, workaroundssetup— environment setup, dependencies
<private>...</private>blocks are respected and never stored- Common secrets (API keys, tokens, passwords) are redacted before writes
- Fully private content is skipped entirely
Optional config file at ~/.config/opencode/mempalace.jsonc:
Environment variables:
| Variable | Purpose |
|---|---|
MEMPALACE_AUTOSAVE_ENABLED |
Toggle background autosave |
MEMPALACE_RETRIEVAL_ENABLED |
Toggle hidden retrieval |
MEMPALACE_KEYWORD_SAVE_ENABLED |
Toggle keyword-triggered saves |
MEMPALACE_PRIVACY_REDACTION_ENABLED |
Toggle secret redaction |
MEMPALACE_ADAPTER_PYTHON |
Path to Python binary |
MEMPALACE_ADAPTER_TIMEOUT_MS |
Adapter timeout (default 15000) |
To enable the prompt-area stats display, add a tui.json in your OpenCode config directory:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": [
"file:///path/to/mempalace-autosave/plugin/tui/index.tsx"
]
}Or when installed from npm, use the package entry:
{
"$schema": "https://opencode.ai/tui.json",
"plugin": ["@rvboris/opencode-mempalace/tui"]
}User message
→ system hook injects "search memory first" instruction
→ model calls mempalace_memory [search]
→ results inform the answer
Session ends / idles
→ event hook mines transcript
→ Python adapter saves durable facts via MemPalace
The plugin uses a local Python bridge (bridge/mempalace_adapter.py) to communicate with MemPalace. It does not require the MemPalace MCP server.
| Requirement | Version |
|---|---|
| OpenCode | latest |
| Python | 3.10+ |
| MemPalace | 3.3+ |
| OS | macOS, Linux, Windows |
- Changelog — release history
- Contributing — changelog rules
git clone https://github.com/rvboris/opencode-mempalace.git
cd opencode-mempalace/mempalace-autosave
npm install
npm run buildLoad from source in opencode.json:
{
"plugin": ["file:///ABSOLUTE/PATH/TO/mempalace-autosave/plugin/index.ts"]
}Debug: opencode --log-level DEBUG or check ~/.mempalace/opencode_autosave.log.
- OpenCode: https://opencode.ai
- MemPalace: https://github.com/milla-jovovich/mempalace
- npm: https://www.npmjs.com/package/@rvboris/opencode-mempalace
MIT
{ "autosaveEnabled": true, "retrievalEnabled": true, "keywordSaveEnabled": true, "maxInjectedItems": 6, "retrievalQueryLimit": 5, "privacyRedactionEnabled": true }