Memory Tree Visualization¶
Arr matey! This be the guide fer visualizin' yer KΓΉzu memory graph in the terminal using Rich Tree.
Overview¶
The memory tree visualization displays yer graph database as a beautiful terminal tree structure, showin' sessions, agents, and memories with their types, scores, and relationships.
Usage¶
Basic Command¶
This displays the entire memory graph from the default KΓΉzu backend.
Filter by Session¶
Shows only memories from a specific session.
Filter by Memory Type¶
amplihack memory tree --type episodic
amplihack memory tree --type semantic
amplihack memory tree --type prospective
amplihack memory tree --type procedural
amplihack memory tree --type working
Shows only memories of a specific type.
Limit Depth¶
Limits the tree depth to 3 levels (default: unlimited).
Choose Backend¶
Selects the storage backend (default: kuzu).
Combine Filters¶
Combine multiple filters for precise queries.
Output Format¶
Tree Structure¶
The visualization shows a hierarchical tree:
π§ Memory Graph (Backend: kuzu)
βββ π
Sessions (2)
β βββ Session-2026-01-11 (5 memories)
β β βββ π Episodic: User discussed auth (β
β
β
β
β
β
β
β
ββ 8/10)
β β βββ π‘ Semantic: Pattern - JWT (confidence: 0.95)
β β βββ π Prospective: TODO - Review PR
β β βββ βοΈ Procedural: pytest β fix β commit (used: 3x)
β β βββ π§ Working: Current task - testing (expires: 1h)
β βββ Session-2026-01-10 (3 memories)
βββ π₯ Agents (3)
βββ architect (8 memories)
βββ builder (12 memories)
βββ security (5 memories)
Memory Type Emojis¶
Each memory type has a distinct emoji:
- π Episodic: What happened when (conversations, events)
- π‘ Semantic: Important learnings (patterns, facts, knowledge)
- π Prospective: Future intentions (TODOs, reminders)
- βοΈ Procedural: How to do something (workflows, processes)
- π§ Working: Active task details (current context, variables)
Importance Scores¶
Episodic and semantic memories show importance/confidence scores:
- Episodic:
β β β β β β β β ββ 8/10(importance 1-10) - Semantic:
confidence: 0.95(0.0-1.0)
Empty Graph¶
If the graph be empty, ye see a friendly message:
Color Coding¶
The tree uses colors fer visual clarity (if yer terminal supports it):
- Blue: Session names
- Green: Memory titles
- Yellow: Memory type indicators
- Red: High importance items
- Cyan: Agents
Performance¶
- Handles graphs with 1000+ memories without lag
- Queries are optimized using Cypher (KΓΉzu) or SQL (SQLite)
- Depth limiting reduces output fer large graphs
Architecture¶
Components¶
- cli_visualize.py: Core visualization module
visualize_memory_tree(): Main function- Uses Rich Tree library
-
Queries backend with MemoryQuery
-
CLI Integration:
amplihack memory treesubcommand - Argument parsing
- Backend selection
- Error handling
Backend Agnostic¶
The visualization works with any backend that implements:
list_sessions(): Get all sessionsretrieve_memories(query): Filter memoriesget_stats(): Get graph statistics
Currently supported:
- KuzuBackend: Native graph queries (Cypher)
- SQLiteBackend: Relational queries (SQL)
Examples¶
Development Workflow¶
# Check recent session memories
amplihack memory tree --session $(amplihack memory sessions --latest) --depth 2
# Review all TODOs
amplihack memory tree --type prospective
# See what the architect agent remembers
amplihack memory tree --filter agent=architect --depth 1
Memory Analysis¶
# Count memories by type (use stats command instead)
amplihack memory stats
# View full graph structure
amplihack memory tree
Implementation Notes¶
Philosophy Compliance¶
- Ruthless Simplicity: Uses Rich Tree, no complex graph algorithms
- Zero-BS: Everything works, no stubs or placeholders
- Self-Contained: All visualization logic in one module
- Working Code Only: Real queries, real data
Dependencies¶
- Rich library (already in amplihack dependencies)
- Existing KuzuBackend/SQLiteBackend
- Existing MemoryQuery for filtering
Testing¶
Covered by:
- Unit tests for tree building logic
- Integration tests with mock backend
- Manual testing with real KΓΉzu database
Troubleshooting¶
"Command not found"¶
Ensure amplihack be installed:
"No memories found"¶
The graph be empty. Add some memories:
- Run Claude Code with amplihack
- Have a conversation
- Check again:
amplihack memory tree
"Backend not available"¶
If KΓΉzu not installed:
Or use SQLite backend: