An OpenCode server plugin that integrates MemPalace without vendoring the MemPalace application code.
The plugin:
- requires an existing
mempalaceinstallation and logs startup diagnostics if it is missing - registers a local
mempalaceMCP server - injects MemPalace slash commands into OpenCode
- injects a bundled
mempalaceskill into OpenCode - automatically mines OpenCode session transcripts into MemPalace conversation memory
- can inject
mempalace wake-upmemory into the system prompt and compaction context
Add the plugin to your OpenCode config:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@devtheops/opencode-plugin-mempalace"]
}You can configure automatic conversation mining with a per-session message threshold:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [["@devtheops/opencode-plugin-mempalace", { "threshold": 30 }]]
}Full plugin options:
{
"$schema": "https://opencode.ai/config.json",
"plugin": [["@devtheops/opencode-plugin-mempalace", {
"threshold": 15,
"autoMine": true,
"injectWakeUp": true,
"injectOnCompaction": true,
"maxWakeUpChars": 4000,
"flushOnIdle": true,
"flushOnExit": true
}]]
}threshold rules:
- default:
15 0: disable threshold-triggered mining and only flush on idle, delete, and compaction- invalid or negative values fall back to
15
Other options:
autoMine: enable or disable automatic conversation mining entirelyinjectWakeUp: injectmempalace wake-upoutput into the system promptinjectOnCompaction: injectmempalace wake-upoutput into compaction contextmaxWakeUpChars: truncate injected wake-up memory to this many charactersflushOnIdle: flush dirty sessions when OpenCode marks them idle or deletedflushOnExit: register graceful process-exit hooks
For local development you can point OpenCode directly at this checkout:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["/path/to/opencode-mempalace/src/index.ts"]
}- OpenCode
- Python 3.9+
- MemPalace installed already, either as
mempalaceonPATHor as a Python module importable bypython3orpython
The plugin injects these commands:
/mempalace-help/mempalace-init/mempalace-mine/mempalace-mine-session/mempalace-search/mempalace-status
It also injects:
- a
mempalaceskill - a local
mempalaceMCP server that runspython3 -m mempalace.mcp_server - a
mempalace_mine_sessionplugin tool for manually exporting and mining the current OpenCode session
If a mempalace MCP server is already configured, the plugin leaves it alone.
When OpenCode loads the plugin, it checks for the mempalace CLI first, then falls back to verifying whether the mempalace package is importable through python3 or python.
If MemPalace is missing, the plugin does not install it automatically. Instead it logs explicit warnings so MCP startup failures are easier to diagnose.
The plugin also exports OpenCode session transcripts through the OpenCode client API and mines them with:
mempalace mine <transcript-file> --mode convosThreshold-based mining is configurable through the plugin threshold option.
flushOnExit currently registers graceful signal handlers only. It does not yet perform a true synchronous transcript flush during process teardown.
bun install
bun run typecheck
bun testSee CONTRIBUTING.md for development and release workflow details.