chore: merge origin/main into mintlify/af82bda4 and resolve conflicts
This commit is contained in:
@@ -5,10 +5,14 @@ description: "Add persistent memory to OpenCode with the Mem0 plugin featuring n
|
||||
|
||||
Add persistent memory to [**OpenCode**](https://opencode.ai) with the Mem0 plugin. Your agent forgets everything between sessions. Mem0 fixes that by storing decisions, preferences, and learnings so they carry over automatically.
|
||||
|
||||
<Info>Current package version: `0.3.0`.</Info>
|
||||
|
||||
Sidekick is available only in the [Claude Code plugin](/integrations/claude-code#sidekick-agent).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
1. A Mem0 API key (starts with `m0-`):
|
||||
- <a href="https://app.mem0.ai/dashboard/api-keys?utm_source=oss&utm_medium=integration-opencode" rel="nofollow">Get your API key</a> (free sign-up at <a href="https://app.mem0.ai?utm_source=oss&utm_medium=integration-opencode" rel="nofollow">app.mem0.ai</a>)
|
||||
- <a href="https://app.mem0.ai/dashboard/api-keys?utm_source=oss&utm_medium=integration-opencode">Get your API key</a> (free sign-up at <a href="https://app.mem0.ai?utm_source=oss&utm_medium=integration-opencode">app.mem0.ai</a>)
|
||||
|
||||
2. Add it to your shell profile so it persists across sessions:
|
||||
|
||||
@@ -33,7 +37,7 @@ opencode plugin @mem0/opencode-plugin
|
||||
**Or let your agent do it**: paste this into OpenCode:
|
||||
|
||||
```
|
||||
Install @mem0/opencode-plugin by following https://raw.githubusercontent.com/mem0ai/mem0/main/integrations/mem0-plugin/.opencode-plugin/README.md
|
||||
Install @mem0/opencode-plugin by following https://raw.githubusercontent.com/mem0ai/mem0/main/integrations/opencode-plugin/README.md
|
||||
```
|
||||
|
||||
This adds the plugin to your `~/.config/opencode/opencode.json`. Restart OpenCode. You get the native memory tools, lifecycle hooks, and all `/mem0-*` slash commands. The memory tools are registered by the plugin itself via the `mem0ai` SDK. No MCP server to configure.
|
||||
@@ -61,9 +65,9 @@ If you only need the memory tools without the plugin's hooks or skills, point Op
|
||||
|
||||
| Component | Plugin (A) | Standalone MCP (B) |
|
||||
|-----------|:----------:|:------------------:|
|
||||
| 9 memory tools | Native (SDK) | Remote MCP server |
|
||||
| 10 memory tools | Native (SDK) | 9 remote MCP tools |
|
||||
| Lifecycle Hooks | Yes | No |
|
||||
| 9 Skills | Yes | No |
|
||||
| 7 Skills | Yes | No |
|
||||
|
||||
## Available Memory Tools
|
||||
|
||||
@@ -78,6 +82,7 @@ If you only need the memory tools without the plugin's hooks or skills, point Op
|
||||
| `delete_all_memories` | Bulk delete all memories in scope |
|
||||
| `delete_entities` | Delete a user/agent/app/run entity and its memories |
|
||||
| `list_entities` | List users/agents/apps/runs stored in Mem0 |
|
||||
| `get_event_status` | Check the processing status of an asynchronous memory event |
|
||||
|
||||
## Memory scope
|
||||
|
||||
@@ -87,9 +92,9 @@ If you only need the memory tools without the plugin's hooks or skills, point Op
|
||||
|-------|-------|--------|
|
||||
| `project` *(default)* | this repo (`user_id` + `app_id`) | this repo |
|
||||
| `session` | this run only (`+ run_id`) | this run |
|
||||
| `global` | **all your projects in the workspace** (`app_id: "*"`) | user-wide |
|
||||
| `global` | **all your projects in the workspace** (filtered by your user ID) | user-wide |
|
||||
|
||||
Ask naturally, for example, *"search my memories across all my projects"*. The agent passes `scope: "global"`. For normal questions it stays scoped to the current project automatically.
|
||||
Select `/mem0-scope global` before requesting a cross-project tool operation. A tool cannot enable global scope by supplying an argument alone. Switch back with `/mem0-scope project` when finished.
|
||||
|
||||
To change the **default** scope (used when no scope is passed), run the `/mem0-scope` skill:
|
||||
|
||||
@@ -110,30 +115,14 @@ The plugin uses the [mem0ai](https://www.npmjs.com/package/mem0ai) TypeScript SD
|
||||
| OpenCode Event | Hook | What happens |
|
||||
|----------------|------|-------------|
|
||||
| `config` | **Config** | Registers the `/mem0-*` slash commands (`config.command`) and adds the plugin's own `opencode-skills/` dir to OpenCode's `skills.paths` for in-place skill discovery (no copying) |
|
||||
| `chat.message` | **Chat message** | Searches prior memories on session start, searches relevant memories before each prompt, auto-captures learnings periodically |
|
||||
| `chat.message` | **Chat message** | Searches prior memories on session start, searches relevant memories before each prompt, sends every third qualifying user prompt for extraction |
|
||||
| `tool.execute.before` | **Pre-tool** | Blocks MEMORY.md writes, steering them to the `add_memory` tool |
|
||||
| `tool.execute.after` | **Post-tool** | Scans Bash errors and pre-fetches related error memories |
|
||||
| `experimental.chat.messages.transform` | **Messages transform** | Injects memory context (session memories, search results, error lookups) into the prompt |
|
||||
| `experimental.session.compacting` | **Compaction** | Stores session state memory, then injects prior memories into compaction context so nothing is lost |
|
||||
| `experimental.session.compacting` | **Compaction** | Stores session state memory, then injects prior memories into compaction context |
|
||||
| `shell.env` | **Shell env** | Exports `MEM0_USER_ID`, `MEM0_APP_ID`, `MEM0_SESSION_ID`, and `MEM0_BRANCH` to all shell executions |
|
||||
|
||||
## Auto-dream (memory consolidation)
|
||||
|
||||
The plugin can automatically consolidate stored memories by merging duplicates, dropping stale/sensitive entries, and rewriting vague ones. This keeps your memory set clean over time. It runs at most once per session, and only when **all** gates pass:
|
||||
|
||||
- **Time**: at least `minHours` (default 24) since the last consolidation
|
||||
- **Sessions**: at least `minSessions` (default 5) sessions since then
|
||||
- **Memories**: at least `minMemories` (default 20) stored for the project
|
||||
|
||||
A filesystem lock (`~/.mem0/mem0-dream.lock`) keeps two sessions from consolidating at once. Tune the thresholds with a `dream` block in `~/.mem0/settings.json`, or disable entirely with `MEM0_DREAM=false`:
|
||||
|
||||
```json
|
||||
{
|
||||
"dream": { "enabled": true, "auto": true, "minHours": 24, "minSessions": 5, "minMemories": 20 }
|
||||
}
|
||||
```
|
||||
|
||||
If auto-dream hasn't run yet, it's almost always because a gate hasn't been met (most often too few memories). Run `/mem0-status` to see the exact gate progress (e.g. `sessions 2/5, memories 3/20`), `/mem0-dream` to consolidate **now** regardless of the gates, or lower the thresholds above.
|
||||
Automatic capture sends the selected user prompt with its full redacted text, without a per-message character cutoff. It does not capture every prompt or the full assistant transcript. These automatic writes use user and project scope, with the session ID in `metadata.session_id`; session-scoped tools use top-level `run_id`. A session-scoped search therefore does not include automatic writes that lack `run_id`.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@@ -141,7 +130,6 @@ If auto-dream hasn't run yet, it's almost always because a gate hasn't been met
|
||||
- **"Connection failed"**: Verify your key is set: `echo $MEM0_API_KEY`
|
||||
- **Plugin not loading**: Run `opencode plugin @mem0/opencode-plugin` again, then restart
|
||||
- **Hooks not firing**: Hooks require the plugin install (Option A). MCP-only installs don't include hooks.
|
||||
- **Auto-dream never runs**: It's gated (time + sessions + memories). Run `/mem0-status` to see which gate is blocking, or `/mem0-dream` to consolidate now.
|
||||
- **Wrong project name / memories not found**: The project id comes from your git remote; launch OpenCode from inside the repo (not your home directory). Check the resolved id with `/mem0-status`.
|
||||
|
||||
<CardGroup cols={2}>
|
||||
|
||||
Reference in New Issue
Block a user