smart-memory
Context-aware memory for AI agents with dual retrieval modes — fast vector search or curated Focus Agent synthesis. SQLite backend, zero configuration, local embeddings.
- License 许可
- MIT
- 最近更新
- 2026-08-23
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- smart-memory
- description
- Context-aware memory for AI agents with dual retrieval modes — fast vector search or curated Focus Agent synthesis. SQLite backend, zero configuration, local embeddings.
02 资源文件 23
- 参考文档_meta.json286 B
- 参考文档AGENTS.md2.3 KB
- 参考文档CHANGELOG.md1.7 KB
- 脚本install.sh2.3 KB
- 参考文档MEMORY_STRUCTURE.md2.3 KB
- 参考文档README.md7.3 KB
- 参考文档skills/vector-memory/README.md5.3 KB
- 参考文档skills/vector-memory/skill.json1.9 KB
- 脚本smart-memory/chunker.js3.9 KB
- 脚本smart-memory/db.js10.4 KB
- 脚本smart-memory/embed.js3.5 KB
- 脚本smart-memory/focus_agent.js9.8 KB
- 脚本smart-memory/hot_memory.js7.2 KB
- 脚本smart-memory/memory_bridge.js2.6 KB
- 脚本smart-memory/memory_mode.js4.0 KB
- 脚本smart-memory/memory.js8.0 KB
- 参考文档smart-memory/package.json483 B
- 参考文档smart-memory/references/integration.md3.0 KB
- 参考文档smart-memory/references/pgvector.md1.1 KB
- 脚本smart-memory/search.js5.5 KB
- 脚本smart-memory/session_memory.js10.1 KB
- 脚本smart-memory/smart_memory.js10.8 KB
- 脚本smart-memory/vector_memory_local.js9.8 KB
03 SKILL.md 正文
Smart Memory v2.1 - Focus Agent Edition
Drop-in replacement for OpenClaw's memory system with superior search quality and optional curated retrieval via Focus Agent.
Features
- Hybrid Search: Combines FTS5 keyword search (BM25) with semantic vector search
- Focus Agent: Multi-pass curation for complex queries (retrieve → rank → synthesize)
- Dual Modes: Fast (direct) or Focus (curated) — toggle anytime
- SQLite Backend: Single-file database, no external services
- 100% Local: Embeddings run locally with Transformers.js (no API keys)
- Auto-Optimization: Uses sqlite-vec when available for native vector ops
- Zero Configuration: Works immediately after install
Installation
npx clawhub install smart-memory
Or from ClawHub: https://clawhub.ai/BluePointDigital/smart-memory
Quick Start
1. Sync Memory
node smart-memory/smart_memory.js --sync
2. Search (Fast Mode - Default)
node smart-memory/smart_memory.js --search "James values principles"
3. Enable Focus Mode (Curated Retrieval)
node smart-memory/smart_memory.js --focus
node smart-memory/smart_memory.js --search "complex decision about project direction"
4. Disable Focus Mode
node smart-memory/smart_memory.js --unfocus
Search Modes
Fast Mode (Default)
Direct vector similarity search. Best for:
- Simple lookups
- Quick fact retrieval
- Routine queries
node smart-memory/smart_memory.js --search "git remote"
Focus Mode (Curated)
Multi-pass curation via Focus Agent. Best for:
- Complex decisions
- Multi-fact synthesis
- Planning and strategy
- Comparing options
node smart-memory/smart_memory.js --focus
node smart-memory/smart_memory.js --search "What did we decide about BluePointDigital architecture?"
How Focus Mode Works:
- Retrieve 20+ chunks (broad net)
- Rank by weighted relevance (vector + term matching + source boost)
- Synthesize into coherent narrative
- Deliver structured context with confidence scores
How It Works
Hybrid Search Algorithm
- FTS5 finds exact keyword matches (BM25 ranking)
- Vector search finds semantic matches (cosine similarity)
- Merged results using weighted scoring:
- 70% vector score + 30% keyword score
- Catches both "what you mean" and "exact tokens"
Focus Agent Curation
When enabled, searches go through additional processing:
Query: "What did we decide about BluePointDigital?"
┌─────────────────┐
│ Retrieve 20+ │ ← Vector similarity
│ chunks │
└────────┬────────┘
▼
┌─────────────────┐
│ Weighted │ ← Term matching
│ Ranking │ Source boosting
│ │ Recency boost
└────────┬────────┘
▼
┌─────────────────┐
│ Select Top 5 │ ← Threshold filtering
└────────┬────────┘
▼
┌─────────────────┐
│ Synthesize │ ← Group by source
│ Narrative │ Extract key facts
└────────┬────────┘
▼
Structured output with confidence
Tools
memory_search
memory_search({
query: "deployment configuration",
maxResults: 5
})
Returns (Fast Mode):
{
"query": "deployment configuration",
"mode": "fast",
"results": [
{
"path": "MEMORY.md",
"from": 42,
"lines": 8,
"score": 0.89,
"snippet": "..."
}
]
}
Returns (Focus Mode):
{
"query": "deployment configuration",
"mode": "focus",
"confidence": 0.87,
"sources": ["MEMORY.md", "memory/2026-02-05.md"],
"synthesis": "Relevant context for: \"deployment configuration\"\n\nFrom MEMORY.md:\n • Docker setup uses docker-compose...\n • Production deployment on AWS...\n\nFrom memory/2026-02-05.md:\n • Decided to use Railway instead...",
"facts": [
{
"content": "Docker setup uses docker-compose...",
"source": "MEMORY.md",
"lines": "42-50",
"confidence": 0.89
}
]
}
memory_get
memory_get({
path: "MEMORY.md",
from: 42,
lines: 10
})
memory_mode (Focus Toggle)
memory_mode('focus') // Enable curated retrieval
memory_mode('fast') // Disable curated retrieval
memory_mode() // Get current mode status
CLI Commands
# Sync memory files
node smart_memory.js --sync
# Search (uses current mode)
node smart_memory.js --search "query" [--max-results N]
# Search with mode override
node smart_memory.js --search "query" --focus
node smart_memory.js --search "query" --fast
# Toggle modes
node smart_memory.js --focus # Enable focus mode
node smart_memory.js --unfocus # Disable focus mode
node smart_memory.js --fast # Same as --unfocus
# Check status
node smart_memory.js --status # Database stats + current mode
node smart_memory.js --mode # Current mode details
# Focus agent only
node focus_agent.js --search "query"
node focus_agent.js --suggest "query" # Check if focus recommended
# Mode management
node memory_mode.js focus
node memory_mode.js unfocus
node memory_mode.js status
Performance
| Feature | Fallback | With sqlite-vec |
|---|---|---|
| Keyword search | FTS5 (native) | FTS5 (native) |
| Vector search | JS cosine | Native KNN |
| Focus curation | +50-100ms | +50-100ms |
| Speed | ~100 chunks/sec | ~10,000 chunks/sec |
| Memory | All in RAM | DB handles it |
When to Use Focus Mode
Use --focus or enable focus mode when:
- Query involves multiple related concepts
- You need synthesized context, not raw chunks
- Making decisions that require understanding relationships
- Summarizing project history
- Comparing options mentioned in different files
Don't use focus mode when:
- Quick fact lookup (phone number, command syntax)
- You need exact text matches
- Latency matters more than context quality
Installation: sqlite-vec (Optional)
For best performance, install sqlite-vec:
# macOS
brew install sqlite-vec
# Ubuntu/Debian
# Download from https://github.com/asg017/sqlite-vec/releases
# Place vec0.so in ~/.local/lib/ or /usr/local/lib/
Without it: Works fine, just slower on large databases.
File Structure
smart-memory/
├── smart_memory.js # Main CLI
├── focus_agent.js # Curated retrieval engine
├── memory_mode.js # Mode toggle commands
├── memory.js # OpenClaw wrapper
├── db.js # SQLite layer
├── search.js # Hybrid search
├── chunker.js # Token-based chunking
├── embed.js # Transformers.js embeddings
└── vector-memory.db # SQLite database (auto-created)
Environment Variables
MEMORY_DIR=/path/to/memory # Default: ./memory
MEMORY_FILE=/path/to/MEMORY.md # Default: ./MEMORY.md
MEMORY_DB_PATH=/path/to/db.sqlite # Default: ./vector-memory.db
Comparison: v1 vs v2 vs v2.1
| v1 (JSON) | v2 (SQLite) | v2.1 (Focus Agent) | |
|---|---|---|---|
| Search | Vector only | Hybrid (BM25 + Vector) | Hybrid + Focus Curation |
| Storage | JSON file | SQLite | SQLite |
| Scale | ~1000 chunks | Unlimited | Unlimited |
| Keyword match | Weak | Strong (FTS5) | Strong (FTS5) |
| Context curation | No | No | Yes (toggle) |
| Setup | Zero config | Zero config | Zero config |
License
MIT
04 同仓库更多 Skills
crowd-prompting
A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.
dilemm-ai
Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, or submitting paper reviews via API at http://150.158.152.82:8000.
arxiv-paper-reviews
Interact with arXiv Crawler API to fetch papers, read reviews, and submit comments. Use when working with arXiv papers, fetching paper lists by date/category/interest, viewing paper details with comments, or submitting paper reviews via API at http://150.158.152.82:8000.
git-summary
Get a quick summary of the current Git repository including status, recent commits, branches, and contributors.
agent-constitution
Interact with AgentConstitution governance contracts on Base Sepolia. Check compliance, read rules, log actions, query governance state.