mem0-plugin/.opencode-plugin/opencode-skills/import/SKILL.md
Import memories from a mem0 export file into the current project.
If the user provided a filename as an argument to /mem0:import <filename>, use that file.
Otherwise, list .md files in the current directory whose names contain mem0-export:
ls -1 *.md 2>/dev/null | grep mem0-export || echo "No export files found"
If multiple files are found, ask the user which one to import. If none are found, print:
No mem0-export files found in the current directory.
Run /mem0:export first, or provide the filename: /mem0:import <path-to-file>
Read the export file directly. It is a JSON file containing a top-level memories array. Each element has:
id — original memory ID (for reference only; a new ID will be assigned on import)type — metadata typeconfidence — metadata confidence valuebranch — metadata branchfiles — list of associated filescategories — list of categoriescontent — the memory textParse the JSON in-memory (do not run any external script). If the file cannot be read or parsed, or if the memories array is missing or empty, print:
Failed to parse <filename> or file contains no valid memory blocks.
and stop.
Determine the active identity:
user_id from MEM0_USER_ID env var, else $USER, else "default"project_id (used as app_id) from MEM0_PROJECT_ID env var, or via the project resolverFor each record in the parsed JSON array, call add_memory (MCP tool) with:
text="<record.content>"user_id=<active_user_id>app_id=<active_project_id>metadata={
"type": "<record.type>" (if non-empty)"confidence": "<record.confidence>" (if non-empty)"branch": "<record.branch>" (if non-empty)"files": <record.files> (the list, if non-empty)"source": "import"}infer=FalseNotes:
id — the platform assigns a new ID.content is empty.Imported <N> memories into project <project_id>
Where <N> is the number of successfully imported memories.
If any failed:
Imported <N>/<total> memories into project <project_id> (<failed> failed)
--tools)When invoked with --tools (e.g., /mem0:import --tools), detect and import
from competing AI tool configuration files:
| Tool | File/directory |
|---|---|
| Cursor | .cursorrules |
| GitHub Copilot | .github/copilot-instructions.md |
| Cline | memory-bank/ (directory of .md files) |
| Continue | .continue/rules.md |
test -f .cursorrules && echo "cursor: .cursorrules"
test -f .github/copilot-instructions.md && echo "copilot: .github/copilot-instructions.md"
test -d memory-bank/ && echo "cline: memory-bank/"
test -f .continue/rules.md && echo "continue: .continue/rules.md"
List found files, ask which to import (numbers, comma-separated, or "all"). If none found:
No competing tool configuration files found.
Checked: .cursorrules, .github/copilot-instructions.md, memory-bank/, .continue/rules.md
For each selected tool, read the file(s) directly and split the content into logical chunks to import as individual memories. No external scripts are used — all parsing and importing is done via MCP tools.
Chunking rules per tool:
cursorrules / copilot / continue: Read the file as plain text. Split on blank
lines or section headers (#, ##). Each non-empty chunk becomes one memory.
Skip chunks shorter than 50 characters.
cline (memory-bank/): List all .md files in the directory. Read each file.
Split each file on blank lines or headers. Each non-empty chunk becomes one memory.
Skip chunks shorter than 50 characters.
For each chunk, call add_memory (MCP tool) with:
text="<chunk text>"user_id=<active_user_id>app_id=<active_project_id>metadata={"type": "task_learning", "source": "<tool>-import", "confidence": 0.8}infer=FalseWhere <tool> is cursorrules, copilot, cline, or continue.
Notes: chunks longer than 10,000 characters are truncated before import. Safe to re-run — deduplication handles repeated entries.
Imported <N> memories into <project_id> (cursor: <N>, copilot: <N>)
When invoked with a path to Claude Code's native MEMORY.md file (typically
~/.claude/projects/<proj-key>/memory/MEMORY.md), or when on_session_start.sh
detects native auto-memory and the user chooses to import:
- bullet prefix).#).add_memory (MCP tool) with:
text="<line>"user_id=<active_user_id>app_id=<active_project_id>metadata={"type": "task_learning", "source": "memory-md-import", "confidence": 0.8}infer=FalseImported <N> memories from MEMORY.md into project <project_id>To avoid duplicate memory systems, add to ~/.claude/settings.json:
"autoMemoryEnabled": false
This handles the cold-start gap when a user has been using Claude Code's native memory and switches to mem0.
add_memory calls fail consistently (e.g. auth error), report the issue and stop early.IMPORTANT: Do NOT use markdown in your output. OpenCode TUI renders text verbatim — markdown like bold, ## headers, and | table | syntax appears as raw characters. Use plain text with indentation for structure. Use dashes for lists. Use spaces to align columns instead of markdown tables.