A powerful OpenCode plugin that provides persistent memory synced across machines via a private GitHub repo. Now with automatic memory extraction, encryption, and smart consolidation!
- Automatic Memory Extraction - Extracts key facts, decisions, and preferences from conversations
- Cross-Machine Sync - GitHub-based synchronization for multi-device workflows
- Structured Memory Types - Preferences, decisions, facts, errors, and people
- Smart Search - Index-based search with relevance scoring
- Full Encryption - AES-256-GCM encryption for all memories
- Memory Consolidation - Automatic deduplication and stale memory archiving
- New Tools -
memory_diff,memory_export,memory_import,memory_consolidate,memory_encrypt - Auto-Extraction - Hooks into OpenCode events to extract memories in real-time
- Index-Based Search - Fast JSON index for instant memory lookup
npm install opencode-sync-memory- Enable the plugin in your OpenCode config:
{
"plugins": ["opencode-sync-memory"]
}- Initialize memory store (first time):
/memory_save title="My first memory" content="This plugin is awesome!"
- Sync across machines:
/memory_sync
# Save a memory
/memory_save title="React Preference" content="I prefer React over Vue for frontend projects" category="preferences" tags="react,frontend" importance="high"
# Search memories
/memory_search query="react"
# Read a specific memory
/memory_read path="preferences/react-preference.md"
# List all memories
/memory_list category="technical"
# Update a memory
/memory_update path="preferences/react-preference.md" content="Updated preference" importance="low"
# Remove a memory (archived)
/memory_forget path="preferences/react-preference.md" reason="No longer relevant"
# View status
/memory_status
# View memory history
/memory_diff path="technical/architecture.md"
# Export a category
/memory_export category="technical" format="json"
# Import memories
/memory_import data="[{"title":"Imported Memory","content":"..."}]" format="json"
# Consolidate duplicates and archive stale entries
/memory_consolidate
# Enable encryption
/memory_encrypt key="your-secret-key"
The plugin automatically extracts memories from:
- Assistant messages - Preferences, decisions, and facts are extracted in real-time
- Compaction summaries - Architecture decisions and key facts are captured for free
- Tool executions - Working patterns and solutions are saved
- preferences - Coding style, tools, defaults
- technical - Architecture decisions, project facts
- errors - Error patterns and solutions
- people - Team info, responsibilities
- notes - Daily notes and session logs
Enable encryption to protect sensitive memories:
# Generate a key
/memory_encrypt
# Or use your own key
/memory_encrypt key="my-secret-key-123"Set the key on other machines:
export OPENCODE_MEMORY_ENCRYPTION_KEY="your-key-here"Run consolidation to merge duplicates and archive stale entries:
/memory_consolidate
This will:
- Find and merge duplicate memories
- Archive memories older than 30 days
- Clean up the memory store
Location: ~/.config/opencode/opencode-sync-memory.jsonc
Create .opencode-memory.json in your project root:
{
"categories": ["project-specific", "team-notes"],
"injection": {
"maxMemories": 10
}
}# Encryption key (optional)
OPENCODE_MEMORY_ENCRYPTION_KEY="your-key-here"┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ OpenCode Chat │────▶│ Memory Extractor │────▶│ Local Index │
│ (hooks) │ │ (regex + compaction)│ │ (JSON) │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
┌───────────────────────┘
▼
┌──────────────────┐
│ YAML Files │
│ (git-tracked) │
│ memories/*.md │
└──────────────────┘
│
▼
┌──────────────────┐
│ GitHub Repo │
│ (cross-machine) │
└──────────────────┘
~/.opencode-memory/
.git/ # GitHub sync (encrypted files)
memories/
preferences/ # User preferences
technical/ # Architecture decisions
errors/ # Error patterns & fixes
people/ # Team info
notes/ # Daily notes (auto-generated)
.archive/ # Archived memories
.index.json # Search index (local only)
# Clone the repo
git clone https://github.com/nutter77-fossmc/opencode-sync-memory.git
cd opencode-sync-memory
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Run tests in watch mode
npm run test:watch- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run
npm testto ensure everything works - Submit a pull request
MIT
- BREAKING: Fixed git template literal chains (requires Node.js 18+)
- Added automatic memory extraction from conversations
- Added AES-256-GCM encryption for all memories
- Added memory consolidation (deduplication + stale archiving)
- Added new tools:
memory_diff,memory_export,memory_import,memory_consolidate,memory_encrypt - Added index-based search for faster queries
- Added per-project configuration support
- Added GitHub Actions CI/CD
- Added comprehensive test suite
- Initial release with basic memory tools
- GitHub sync support
- Daily notes auto-capture
- Early prototype
{ // GitHub sync settings "remote": { "url": "git@github.com:user/opencode-memory.git", "branch": "main", "autoCreate": true }, // Memory categories "categories": ["preferences", "repos", "technical", "people", "workflows", "snippets", "notes"], // System prompt injection "injection": { "enabled": true, "maxMemories": 5, "maxLinesPerMemory": 3 }, // Daily notes "dailyNotes": { "enabled": true, "autoCreate": true }, // Session search "sessionSearch": { "enabled": true, "maxResults": 10 } }