OpenClaw-style persistent memory system for OpenCode with full automation and local vector search
- β OpenClaw-Style Memory System - Complete 9 core memory files (SOUL, AGENTS, USER, IDENTITY, TOOLS, MEMORY, HEARTBEAT, BOOT, BOOTSTRAP)
- β Fully Automated - Automatically saves important information without being asked
- β Local Vector Search - Semantic search using local embeddings (sqlite-vec)
- β Daily Memory Logs - Running context with automatic consolidation
- β Long-Term Memory - Persistent knowledge across sessions and projects
- β Hybrid Search - BM25 + vector search for optimal results
- 2 Automation Agents:
@memory-automation- Auto-saves important information@memory-consolidate- Auto-organizes daily logs
- 8 Memory Tools:
memory_write- Write entries to memorymemory_read- Read from memory filesmemory_search- Keyword search across memoryvector_memory_search- Semantic search with embeddingslist_daily- List available daily logsinit_daily- Initialize today's daily logrebuild_index- Rebuild vector indexindex_status- Check vector index status
- OpenCode v1.1.48 or later
- Node.js 20+ (for development)
# Install latest version from npm registry
npm install @csuwl/opencode-memory-plugin -g
# Or install a specific version
npm install -g @csuwl/opencode-memory-plugin@1.0.0
# That's it! The plugin will be automatically configured for you! π§ The npm installation automatically:
- β
Creates memory directory structure (
~/.opencode/memory/) - β Copies all 9 memory files
- β Configures OpenCode to load memory into every session
- β Sets up automation agents
- β Initializes today's daily log
No manual configuration needed!
# Clone repository
git clone https://github.com/csuwl/opencode-memory-plugin.git
cd opencode-memory-plugin
# Run initialization script
bash opencode-memory-plugin/scripts/init.sh
# That's it! Your OpenCode now has memory π§ The initialization script will:
- Create memory directory structure
- Copy all memory files to
~/.opencode/memory/ - Configure OpenCode to load memory into every session
- Set up automation agents
- Initialize today's daily log
The plugin automatically configures OpenCode to load memory files into every session:
Memory files injected:
SOUL.md- AI personality and boundariesAGENTS.md- Operating instructions and memory rulesUSER.md- User profile and preferencesIDENTITY.md- Assistant identityTOOLS.md- Tool usage conventionsMEMORY.md- Long-term memory- Plus today's daily log
# In OpenCode, try these commands:
# Write a memory entry
memory_write content="User prefers TypeScript for all new features" type="long-term" tags=["typescript","code-style"]
# Search for past information
memory_search query="async patterns"
# Semantic search
vector_memory_search query="how do I handle async errors"
# List recent daily logs
list_daily days=7
# Initialize today's log
init_daily
# Check vector index status
index_status
# Rebuild vector index
rebuild_index force=true# Auto-save important information
@memory-automation review conversation and save important information
# Organize daily logs
@memory-consolidate review and consolidate recent memoriesopencode-memory-plugin/
βββ memory/ # Core memory files (OpenClaw style)
β βββ SOUL.md # Personality, tone, boundaries
β βββ AGENTS.md # Operating instructions
β βββ USER.md # User profile
β βββ IDENTITY.md # Assistant identity
β βββ TOOLS.md # Tool conventions
β βββ MEMORY.md # Long-term memory
β βββ HEARTBEAT.md # Health checklist
β βββ BOOT.md # Startup checklist
β βββ BOOTSTRAP.md # One-time ritual
β βββ daily/ # Daily logs
βββ tools/ # Custom OpenCode tools
β βββ memory.ts # Basic memory tools
β βββ vector-memory.ts # Vector search tools
βββ agents/ # Custom OpenCode agents
β βββ memory-automation.md # Auto-save agent
β βββ memory-consolidate.md # Auto-consolidate agent
βββ scripts/ # Utility scripts
β βββ init.sh # Installation script
βββ package.json # NPM package configuration
- Create a new tool in
tools/directory - Export the tool using
tool()helper - Update
agents/to use the new tool
import { tool } from "@opencode-ai/plugin"
export default tool({
description: "Your tool description",
args: {
query: tool.schema.string().describe("Your parameter description"),
},
async execute(args, context) {
// Your tool logic here
return `Result: ${args.query}`
},
})- Create agent markdown file in
agents/ - Configure permissions and tools
- Add to
package.jsonor create a PR
Memory system configuration is stored in:
~/.opencode/memory/memory-config.json~/.opencode/memory/MEMORY.md- Long-term memory~/.opencode/memory/daily/YYYY-MM-DD.md- Daily logs~/.opencode/memory/archive/- Archived logs
OpenCode configuration is in:
~/.config/opencode/opencode.json- Memory tools and agents
- Check OpenCode config:
cat ~/.config/opencode/opencode.json - Verify file paths are correct
- Restart OpenCode if needed
- Check vector index:
index_status - Rebuild if needed:
rebuild_index force=true - Check
memory-config.jsonsettings
- Check directory:
ls ~/.opencode/memory/daily/ - Manually initialize:
init_daily - Check permissions
- OpenCode Docs - Official OpenCode documentation
- OpenClaw Docs - Reference for OpenClaw-style memory system
We welcome contributions! Here's how you can help:
- Report Issues - Open an issue on GitHub for bugs or feature requests
- Submit Pull Requests - Fork the repository and create a pull request
- Improve Documentation - Help improve README and examples
- Add Features - Add new tools or agents
- Share Ideas - Suggest improvements or new use cases
- Follow OpenCode plugin conventions
- Use TypeScript for tools
- Test changes thoroughly
- Update documentation with new features
- Respect the memory-first approach
MIT License - see LICENSE for details
- OpenClaw team for the memory system design
- OpenCode team for the plugin system
- All contributors and users
Made with β€οΈ for OpenCode community
Your OpenCode instance now has perfect memory - just like OpenClaw! π§