OpenCode plugin that gives coding agents persistent memory using OpenMemory (local-first, privacy-focused)
npm install @happycastle/opencode-openmemory

Local-first, privacy-focused persistent memory for OpenCode agents using OpenMemory.
A fork of opencode-supermemory, redesigned to work with OpenMemory - an open-source, self-hosted cognitive memory engine that keeps your data on your machine.
- Local-first: All memories stored on your machine via OpenMemory
- Privacy-focused: No data sent to external services
- Automatic context injection: User profile, project memory, and relevant memories injected into conversations
- Explicit & implicit memory capture: Save memories with "remember this" or let the agent extract knowledge automatically
- Scope separation: User-level (cross-project) vs project-level memories
- Context compaction: Smart summarization when context window fills up
```
┌───────────────────────────────────────────────────────────────┐
│ OpenCode (Plugin) │
│ - Injection Policy (format, token budget, priority) │
│ - Memory Capture Policy (explicit "remember", implicit) │
│ - Scope Router (user_id, project_id) │
└───────────────────┬───────────────────────────────────────────┘
│
v
┌───────────────────────────────────────────────────────────────┐
│ OpenMemory Server (REST API) │
│ - Store: raw notes / facts / events / snippets │
│ - Index: embeddings + metadata (scope/recency/type) │
│ - Retrieval: hybrid scoring (similarity + salience + decay) │
│ - Default: http://localhost:8080 │
└───────────────────────────────────────────────────────────────┘
`bash`
bunx @eddy.soungmin/opencode-openmemory@latest install
Or manually add to ~/.config/opencode/opencode.jsonc:
`jsonc`
{
"plugin": ["@happycastle/opencode-openmemory@latest"]
}
Option A: Docker (recommended)
`bash`
git clone https://github.com/CaviraOSS/OpenMemory.git
cd OpenMemory
cp .env.example .envEdit .env with your OPENAI_API_KEY (for embeddings)
docker compose up --build -d
Option B: Manual setup (for development)
`bash`
git clone https://github.com/CaviraOSS/OpenMemory.git
cd OpenMemory/backend
npm install
npm run dev # Starts on :8080 by default
For more details, see the OpenMemory documentation.
The plugin will automatically connect to OpenMemory REST API at http://localhost:8080.
Create ~/.config/opencode/openmemory.jsonc:
`jsonc`
{
// OpenMemory REST API URL
"apiUrl": "http://localhost:8080",
// Search settings
"similarityThreshold": 0.6,
"maxMemories": 5,
"maxProjectMemories": 10,
"maxProfileItems": 5,
"minSalience": 0.3,
// Context injection
"injectProfile": true,
// Scope prefix for organizing memories
"scopePrefix": "opencode",
// Default sector for storing memories
"defaultSector": "semantic"
}
On the first message of each session, the plugin automatically injects:
1. User Profile: Cross-project preferences and patterns
2. Project Knowledge: Project-specific memories from the current directory
3. Relevant Memories: Semantically similar memories to the current query
Use trigger phrases to save memories:
``
"Remember that we use Prettier with single quotes"
"Save this: always run tests before committing"
"Keep in mind that the auth service is in /src/lib/auth"
The openmemory tool is available with these modes:
| Mode | Description | Arguments |
|------|-------------|-----------|
| add | Store a new memory | content, type?, scope? |search
| | Search memories | query, scope?, limit? |profile
| | View user profile | query? |list
| | List recent memories | scope?, limit? |forget
| | Remove a memory | memoryId, scope? |help
| | Show usage guide | - |
Scopes:
- user: Cross-project preferences and knowledgeproject
- : Project-specific knowledge (default)
Memory Types:
- project-config: Tech stack, commands, toolingarchitecture
- : Codebase structure, components, data flowlearned-pattern
- : Conventions specific to this codebaseerror-solution
- : Known issues and their fixespreference
- : Coding style preferencesconversation
- : Session summaries
Run the /openmemory-init command to deeply research your codebase and populate memory:
``
/openmemory-init
When the context window fills up (80% by default), the plugin:
1. Injects project knowledge into the summary prompt
2. Triggers OpenCode's summarization
3. Saves the summary as a memory for future sessions
4. Automatically resumes the conversation
If you're using Oh My OpenCode, disable its built-in auto-compact hook to let this plugin handle context compaction:
Add to ~/.config/opencode/oh-my-opencode.json:
`json`
{
"disabled_hooks": ["anthropic-context-window-limit-recovery"]
}
`bashClone
git clone https://github.com/happycastle114/opencode-openmemory.git
cd opencode-openmemory
Comparison with opencode-supermemory
| Feature | opencode-supermemory | @eddy.soungmin/opencode-openmemory |
|---------|---------------------|-------------------------------------|
| Backend | Supermemory Cloud | OpenMemory (local) |
| Data Location | Cloud | Your machine |
| Privacy | Requires API key | Fully local |
| Cost | API usage fees | Free (self-hosted) |
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (
git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)- Based on opencode-supermemory by Supermemory
- Uses OpenMemory by CaviraOSS
- Developed by @happycastle114
- Oh My OpenCode - This plugin was developed using Oh My OpenCode's powerful agent orchestration capabilities