Summary
OpenClaw (229K+ GitHub stars) is a self-hosted personal AI assistant running on Mac Mini / Linux. Its memory system stores embeddings in full-precision vectors that grow linearly and never shrink. On a 256GB Mac Mini, heavy users can accumulate 500MB–6GB+ of embedding indexes over time.
LEANN's graph-pruned recomputation architecture (97% storage compression) is a natural fit as an OpenClaw memory search backend. OpenClaw's async message processing model ("sleep time compute") makes LEANN's recomputation latency invisible to end users.
What needs to be done
1. leann search --json flag
The search CLI command currently outputs human-readable text only. OpenClaw agents need structured output to parse results programmatically.
- Add
--json argument to the search subparser
- When set, serialize
SearchResult objects (id, score, text, metadata) as JSON to stdout
- Keep the existing text output as default
2. leann watch --sync flag
The watch command currently detects file changes (added/removed/modified) via FileSynchronizer but only prints a report. It does not update the index.
- Add
--sync argument to the watch subparser
- When set, after detecting changes, call
update_index() for added/modified files and handle removals
- This enables automatic re-indexing when OpenClaw memory files change
3. OpenClaw Skill (SKILL.md)
Create a skill directory at packages/leann-openclaw/ containing:
SKILL.md — YAML frontmatter + instructions telling the OpenClaw agent how to use leann build and leann search --json for memory search
README.md — Setup guide for OpenClaw users (install leann-core, build index on ~/.openclaw/workspace/memory/, configure the skill)
4. MCP server: structured output (optional follow-up)
The existing leann_mcp server returns plain text from CLI subprocess calls. Consider adding a JSON mode or calling the Python API directly for structured results. This would benefit both OpenClaw MCP integration and Claude Code usage.
Context
Summary
OpenClaw (229K+ GitHub stars) is a self-hosted personal AI assistant running on Mac Mini / Linux. Its memory system stores embeddings in full-precision vectors that grow linearly and never shrink. On a 256GB Mac Mini, heavy users can accumulate 500MB–6GB+ of embedding indexes over time.
LEANN's graph-pruned recomputation architecture (97% storage compression) is a natural fit as an OpenClaw memory search backend. OpenClaw's async message processing model ("sleep time compute") makes LEANN's recomputation latency invisible to end users.
What needs to be done
1.
leann search --jsonflagThe
searchCLI command currently outputs human-readable text only. OpenClaw agents need structured output to parse results programmatically.--jsonargument to thesearchsubparserSearchResultobjects (id, score, text, metadata) as JSON to stdout2.
leann watch --syncflagThe
watchcommand currently detects file changes (added/removed/modified) viaFileSynchronizerbut only prints a report. It does not update the index.--syncargument to thewatchsubparserupdate_index()for added/modified files and handle removals3. OpenClaw Skill (
SKILL.md)Create a skill directory at
packages/leann-openclaw/containing:SKILL.md— YAML frontmatter + instructions telling the OpenClaw agent how to useleann buildandleann search --jsonfor memory searchREADME.md— Setup guide for OpenClaw users (install leann-core, build index on~/.openclaw/workspace/memory/, configure the skill)4. MCP server: structured output (optional follow-up)
The existing
leann_mcpserver returns plain text from CLI subprocess calls. Consider adding a JSON mode or calling the Python API directly for structured results. This would benefit both OpenClaw MCP integration and Claude Code usage.Context
docs/openclaw-integration-plan.md