9ed1983b85
Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
12 KiB
12 KiB
Changelog
All notable changes to the @mem0/opencode-plugin will be documented in this file.
0.2.0 — Native SDK tools, MCP-free, leaner skill set
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.
0.1.3 — File-context injection, session summaries & activity timeline, anonymous telemetry
Added
- File-context injection (
tool.execute.before/ Read): Before the agent reads a file, the plugin searches mem0 for memories referencing that file path and injects prior work as system context. Gates on file size (>= 1,500 bytes). Gives the agent "I've worked on this file before" awareness automatically. - Stop hook session summary (
experimental.session.compacting): Enhanced session compaction to store a structuredsession_summarymemory withinfer=True, letting the mem0 backend AI extract key facts (request, decisions, learnings, next steps). Previously only stored a raw stats string. - SessionStart activity timeline: The initial memory loading now formats recent memories with type icons (⚖️ decision, 🔴 bug_fix, 🔵 task_learning, etc.) and relative age indicators (2h ago, 1d ago) instead of bare text. Provides a visual "Recent Activity" timeline on first message.
- PostHog telemetry (
telemetry.ts): Anonymous, fire-and-forget usage events. Opt out withMEM0_TELEMETRY=false. Only fires when an API key is present; never sends memory content, prompts, or the API key — only an anonymizedsha256(apiKey)[:32]identity plus event type, platform, and plugin version. Emits the same schema as the Mem0 editor plugin (plugin.*events,source: "plugin",platform: "opencode") so OpenCode appears as aplatformin the shared plugin dashboard. Events:plugin.session_start(with memory count) andplugin.tool_use(add/search/update/delete).
Changed
experimental.session.compactinghandler: Now storesmetadata.type=session_summarywithmetadata.source=opencode-stopinstead ofmetadata.type=session_statewithmetadata.source=pre-compaction. Includes a structured prompt that instructs mem0's AI to extract request, decisions, learnings, and next steps.- Initial context formatting: Memories shown on first message now include type icons and age labels for quick scanning.
0.1.2 — Automatic coding categories & global search
Added
- Auto-configured coding categories: The plugin now automatically sets up 17 coding categories (e.g.
architecture_decisions,api_design,security,debugging_notes) on the Mem0 project at startup. Runs in the background on every session start viaautoSetupCategories(), is fully idempotent, and never blocks initialization. Uses SHA-256 fingerprints of the category list and API key — stored in~/.mem0/categories_setup.json— to skip redundant API calls on subsequent sessions. - Global search mode (
global_searchsetting): Newglobal_searchtoggle in~/.mem0/settings.json(default:false). When enabled, allsearch_memoriesandget_memoriescalls use{"OR": [{"user_id": "*"}]}instead of the per-user per-projectANDfilter — returning all memories across all users and allapp_idscopes. Writes (add_memory) still tag with the currentuser_idandapp_id. Applies to all plugin search paths: initial load, per-message recall, resume detection, error-pattern lookup, and compaction context. /mem0:switch-project --global/--no-global: Enables or disables global search via the switch-project skill. Persists to~/.mem0/settings.json. No manual config editing needed.MEM0_GLOBAL_SEARCHenvironment variable: Exported to child shells via theshell.envhook ("true"or"false").
Changed
- Search filters are now dynamic: All search paths throughout the plugin construct filters based on the
global_searchsetting instead of always usingAND [user_id, app_id]. - Resume-context searches broadened: Resume and error-pattern searches no longer include
metadata.typesub-filters (session_state,decision,anti_pattern,bug_fix), broadening recall. - System context message updated: Informs the model when global search is active (
"Global search is ON — searches return all memories across all users and projects. Writes still use user_id=..., app_id=..."). /mem0:onboardStep 5 is no longer interactive: Removed the manual category installation prompt. Categories now configure automatically in the background; the onboarding step only verifies status and stores a fallbackproject_profilememory if the background run hasn't finished yet./mem0:switch-projectskill expanded: Description and execution updated to document the--globaland--no-globalflags alongside the existing project-name argument.
0.1.1
- CI/CD publish flow test (
#5288). - Fixed tsconfig, added
publishConfigand bun lockfile (#5273). - Renamed package to
@mem0/opencode-plugin(#5272). - Added plugin array to bundled
opencode.json(#5271).
0.1.0 — Initial release
- OpenCode plugin (
@mem0/opencode-pluginon npm): Pure TypeScript plugin using themem0aiTS SDK — no Python, no shell scripts. Hooks into all 6 OpenCode events (chat.message,tool.execute.before,tool.execute.after,experimental.chat.system.transform,experimental.session.compacting,shell.env). Features: session start memory loading, per-prompt semantic search, error pattern detection with memory lookup, resume/remember intent detection, auto-capture every 3rd message, periodic save nudges, full metadata defaults injection (confidence, source, type, session_id, files, branch), identity injection for search/get/delete filters, type-filtered error pre-fetch (anti_pattern + bug_fix), pre-compaction memory capture, MEMORY.md write blocking, and secret redaction. - 16 OpenCode-native skills bundled in
opencode-skills/:context-loader,dream,export,forget,health,import,list-projects,mem0(SDK reference),memory-reviewer,onboard,peek,pin,remember,stats,switch-project,tour. All skills are pure MCP-tool-based — no Python scripts, no shell scripts, no Claude Code dependencies. - Auto-install skills and commands (
installSkills()): On plugin load, copies all 16 skills to.opencode/skills/and creates command wrapper files in.opencode/commands/so they appear in the OpenCode/palette. - CLI installer (
cli.ts):bunx @mem0/opencode-plugin installauto-configures plugin and MCP server in~/.config/opencode/opencode.json.