Mem0 OpenCode Plugin (v0.2.0)
Changed (breaking)
- Memory tools are now native OpenCode tools registered via the
@opencode-ai/plugintool()helper and backed by themem0aiSDK directly. The plugin no longer registers or depends on the remote MCP server (mcp.mem0.ai); the bundledopencode.jsonand the regex-based MCP call interception have been removed. Tools:add_memory,search_memories,get_memories,get_memory,update_memory,delete_memory,delete_all_memories,delete_entities,list_entities, plus aget_event_statushelper for async-write status. - Skills load via the
confighook (skills.paths) instead of being copied into the project's.opencode/directory on startup. TheinstallSkills()filesystem copy and thecli.tsinstaller (mem0-opencodebin) have been removed — install withopencode plugin @mem0/opencode-plugin. - Trimmed to 9 focused skills (
context-loader,dream,forget,status,search,scope,pin,remember,tour). Removedimport,export,memory-reviewer,mem0(SDK reference),list-projects,stats, andonboard. The old statefulswitch-projectskill is superseded by the project/session/global scope model and the new/mem0-scopeskill.
Added
- Expanded telemetry to the full shared
plugin.*schema. In addition toplugin.session_startandplugin.tool_use, the plugin now emitsplugin.user_prompt,plugin.bash_error,plugin.pre_compact, andplugin.session_stop.tool_usenow fires from inside each native tool. Every event also carriesproject_hash(anonymizedsha256(app_id)) andos_version, matching the editor plugin'stelemetry.py. - Auto-dream — gated automatic memory consolidation (ported from the pi-agent plugin). When the time (
minHours, default 24), session-count (minSessions, default 5), and memory-count (minMemories, default 20) gates all pass, the plugin injects a consolidation protocol so the agent merges duplicates, drops stale/sensitive entries, and rewrites vague ones before answering. A filesystem lock (~/.mem0/mem0-dream.lock) prevents concurrent sessions from dreaming at once, and completion resets the gates. Tune via thedreamblock in~/.mem0/settings.json; disable withMEM0_DREAM=false. Emitsplugin.dream_triggered/plugin.dream_completed. - Memory
scope— per-call parameter and a persistent default.search_memories,get_memories,add_memory, anddelete_all_memoriesaccept an optionalscope:"project"(this repo, default),"session"(this run, addsrun_id), or"global"(across all the user's projects —app_id: "*"for reads, user-wide for writes). The new/mem0-scopeskill views and changes the default scope (used when no scope is passed), persisted to~/.mem0/settings.json(default_scope) and read fresh on each memory operation so changes apply immediately — no restart.add_memory/search_memories/get_memorieshonor the default (an explicitscope,filters, oragent_idstill wins; aprojectdefault preserves prior behavior, includingglobal_search).
Changed
/mem0-statusnow reports the active default scope and auto-dream readiness. It readsdefault_scopefrom~/.mem0/settings.json(falling back toproject) and shows the auto-dream gate progress (sessions / memories / time vs. thresholds) so it's clear why a consolidation hasn't run yet.
Fixed
- Skills load in place via
skills.paths— no copying. Theconfighook adds the plugin's ownopencode-skills/directory to OpenCode'sskills.paths, so OpenCode discovers the skills directly from the linked/installed plugin package (recursive**/SKILL.mdscan). TheinstallSkills()step that copied skills into~/.config/opencode/skills/(and the legacy~/.opencode/skills/) and its version-marker gating are removed — the plugin no longer writes into those directories or creates~/.opencode. Theconfighook still registers the/mem0-*slash commands viaconfig.command: OpenCode's TUI slash menu is built fromconfig.command, and skills onskills.pathsare available to the agent's skill tool but do not appear as slash commands on their own. Skill dir names aremem0-<skill>(matching^[a-z0-9]+(-[a-z0-9]+)*$); commands are/mem0-<skill>. - Robust project-id (
app_id) detection. Parsed from the git remote'sowner/repo— handling https, scp-style ssh, and custom ssh host aliases likegit@github.com-work:owner/repo.git— falling back to the git repo's root directory name (not the cwd, which may be a sub-directory or your home dir), then the cwd. Fixes the project showing as your username/home when OpenCode was launched outside the repo root. - Auto-dream visibility + robustness. When auto-dream doesn't fire, the plugin logs the blocking gate (e.g.
auto-dream waiting — memories: 3 < 20), and/mem0-statussurfaces the same gate progress. The session-start memory count is parsed defensively (handles both paginated{count}and bare-array SDK responses) so the memory gate evaluates correctly. - Error-pattern lookup in
tool.execute.afterno longer issues two identicalmem0.search()calls; it now performs a singletopK: 6search. - Corrected the documented system-prompt hook name from
experimental.chat.system.transformto the actualexperimental.chat.messages.transform.
Safety
delete_all_memoriesdeliberately ignores the default scope. Deleting user-wide always requires an explicitscope="global", so raising the default toglobalcan never turn a routine cleanup into a cross-project wipe.