English | 中文
Unified memory management for multiple AI agents.
Agents (Claude Code, Copilot, FingerSaver, etc.) read, write, search, and consolidate memories through CLI, JSON-RPC over stdin, or persistent Unix socket. A background daemon continuously classifies, links, and refines stored memories.
go build -o memory .
# or
go install github.com/cybernagle/memory-cli@latest# Initialize (creates ~/.memory/)
memory write "user prefers dark mode" --category preferences --tags ui
# Read back
memory read <id>
# Search
memory search "dark mode"
# List by category
memory list --category knowledge
# Ingest from existing sources
memory ingest --source claude
# Start daemon + socket server
memory serveMemories progress through phases across 15 categories:
inbox → processed → organized (Extract+Merge 加工链)
Memories are stored in SQLite (~/.memory/memories.db), not flat files. Each memory carries:
phase— inbox / processed / organizedcategory— knowledge / preferences / decisions / project / people / evidence / … (15 total)metadata(JSON) — version tracking (superseded_by), proposals status, evidence aggregates, provenance (tmux_session, prompt_id, …)source— provenance: who/what wrote it (e.g.claude,makro-brain,consolidate,evidence-task)tags,links(bidirectional[[wikilinks]])
Provenance columns (tmux_session, prompt_id, user+assistant turns) enable full traceability from any organized memory back to its source conversation.
See
docs/ARCHITECTURE.mdfor the full layered architecture — 5 layers (foundation → core → domain → orchestration → composition), data-flow diagrams, and the cross-layer rules every feature change should follow.
memory write <content> [--category <cat>] [--tags t1,t2] [--scope global] [--source <name>]
memory read <id>
memory delete <id>
memory list [--phase inbox|organized] [--category <cat>] [--scope ...] [--source ...]memory search <query> [--tags ...] [--category ...] [--from YYYY-MM-DD] [--to YYYY-MM-DD]Memories can reference each other with [[wikilink]] syntax. Wikilinks are resolved automatically during ingest, and the EntityExtractionTask (daemon) keeps the entity graph + backlinks up to date — no manual link commands needed.
The daemon runs an Extract+Merge pipeline (via factprocessor, the canonical implementation through the plugin contract) plus several background refinement tasks:
memory serve # start daemon: consolidate / enrich / profile / entity / evidence / reminderDaemon tasks (run on memory serve):
ConsolidateLLMTask— processed → organized (LLM merge)EnrichTagsTask— tag enrichmentProfileTask— user profile synthesis (→character)EntityExtractionTask— LLM entity discovery (fills the entity graph)EvidenceTask— proposal accept/reject aggregation (→evidence)ReminderTask— due reminders → macOS notifications
memory notifyChecks due reminders and pushes macOS notifications. Writes pending reminders to ~/.memory/pending.md for agents to consume on startup.
memory serve [--interval 60s]Starts background daemon (consolidate-llm / enrich / profile / entity-extract / evidence / reminder) plus Unix socket server at ~/.memory/memory.sock. This is the single entry point for all background processing.
memory ingest --source claude|car-agent|fingersaver|logseq|obsidian|allmemory export [--output file] [--category ...]
memory import [--input file]JSONL format, one memory per line.
Any agent that can run shell commands:
memory write "user prefers vim" --category preferences
memory search "editor preference"# List tools
memory mcpSpeak JSON-RPC 2.0 over stdio (initialize → tools/call). 8 tools: memory_ask, memory_search, memory_write, memory_read, memory_delete, memory_timeline, memory_list, memory_remind.
# Connect
socat - UNIX-CONNECT:~/.memory/memory.sock
# List tools
{"id":1,"method":"tools/list","params":{}}
# Search
{"id":2,"method":"tools/call","params":{"name":"memory_search","params":{"query":"dark mode"}}}
# Shorthand: use tool name directly as method
{"id":3,"method":"memory_list","params":{"category":"knowledge"}}Each request/response is a single JSON line.
~/.memory/config.yaml:
storage:
root: ~/.memory
short_term_ttl: 168h # Inbox TTL (7 days)
daemon:
interval: 60s
notification:
enabled: true
method: osascript
timezone: "Asia/Shanghai"memory-cli is a 5-layer system with strict bottom-up dependencies (the dependency graph is a clean DAG — no cycles):
⑤ cmd — composition root (cobra wiring, 18 subcommands)
④ daemon/api/mcp/transport — orchestration (scheduling + protocol adapters)
③ ingest/factprocessor/entity/plugin/query/dashboard/agent — domain (semantic processing)
② store — core storage (SQLite, 12 dependents) ★
① config/llm/notify/health — foundation (zero internal deps)
Full diagram + layer responsibilities + cross-layer rules: see docs/ARCHITECTURE.md.
go build -o memory .
go test ./...
go vet ./...
go fmt ./...MIT