Skip to content

Latest commit

ย 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒณ pi-memory-tree

โ€” Hierarchical Agent Memory

pi-memory-tree logo

A filesystem-native, infinitely scalable hierarchical memory system for AI coding agents.

Unlike flat two-file systems (Hermes), vector databases (Mem0), or virtual memory management (Letta), pi-memory-tree organizes agent memory as a knowledge tree โ€” keywords index โ†’ detail files โ†’ sub-branches, growing naturally as knowledge accumulates.

  Layer F (always loaded) โ€” What to focus on
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚     WATCH.md          โ”‚ โ† Current focus topics
  โ”‚  "Daemon โ†’ ๅพ…ๅฏๅŠจ"    โ”‚    drives smart loading
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚
             โ–ผ
  Level 0 (always loaded) โ€” Where to find it
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
  โ”‚     MEMORY.md         โ”‚ โ† Keywords โ†’ file mapping
  โ”‚  "Daemon โ†’ MEMORY2"   โ”‚
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
             โ”‚
    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
    โ–ผ        โ–ผ            โ–ผ
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚MEMORY1 โ”‚โ”‚MEMORY2 โ”‚โ”‚MEMORY3 โ”‚  Level 1 (on-demand)
 โ”‚_sem.md โ”‚โ”‚_epi.md โ”‚โ”‚_pro.md โ”‚
 โ”‚็Žฏๅขƒ้…็ฝฎ โ”‚โ”‚ Daemon  โ”‚โ”‚ ๅทฅๅ…ท้›†  โ”‚
 โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ””โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜
     โ”‚                   โ”‚
     โ–ผ                   โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”             โ–ผ          โ–ผ
 โ”‚MEMORY1โ”‚          โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
 โ”‚-1_sem โ”‚          โ”‚MEMORY3 โ”‚ โ”‚MEMORY3 โ”‚  Level 2+
 โ”‚ๅผ€ๅ‘ๅทฅๅ…ทโ”‚          โ”‚-1_pro  โ”‚ โ”‚-2_pro  โ”‚
 โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜          โ”‚ search โ”‚ โ”‚pattern โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Features

Feature Description
๐Ÿ—๏ธ Hierarchical Tree Keywords index (Level 0) โ†’ detail files (Level 1) โ†’ sub-branches (Level 2+)
โ™พ๏ธ Infinite Scale No capacity limit โ€” new files grow like tree branches
โšก Lazy Loading Only the index is loaded at session start; details loaded on demand
๐Ÿ‘๏ธ Focus Layer WATCH.md โ€” a compact ~500 char board of current priorities, driving smart Level 1 preloading
๐Ÿ”— Cross-Branch Links Each file tracks related files via ๐Ÿ”— ๅ…ณ่”ๆž (association links)
๐Ÿท๏ธ Memory Types Semantic (facts), Episodic (timeline), Procedural (steps), Mixed
โฑ๏ธ Version Tracking Timestamps on every entry; history preserved on updates
๐Ÿ”Œ Zero Dependencies Pure Bash + Markdown โ€” no databases, no npm packages
๐Ÿ” Full-Text Search session_search.sh searches summaries; raw_search.sh searches raw transcripts
๐Ÿ”„ Memory Cascade Auto: memory tree โ†’ session summaries โ†’ raw logs (no data loss)
๐Ÿ”„ Self-Improvement pattern.sh captures recurring patterns as reusable knowledge
๐Ÿค– Auto-Consolidation Daemon scheduler checks memory health daily
๐Ÿ›ก๏ธ Security Filtering Automatic blocking of API keys, passwords, and secrets

๐Ÿ”ฌ Comparison with Other Memory Systems

Capability pi-memory-tree Hermes Mem0 Letta/MemGPT Zep
Hierarchical tree โœ… โŒ โŒ โŒ โŒ
Infinite capacity โœ… โŒ โœ… โœ… โœ…
Zero dependencies โœ… โŒ โŒ โŒ โŒ
Human-readable โœ… โœ… โŒ โŒ โŒ
Cross-session persistence โœ… โœ… โœ… โœ… โœ…
Full-text search โœ… โœ… โœ… โœ… โœ…
Memory types โœ… โŒ โŒ โŒ โŒ
Association links โœ… โŒ โŒ โŒ โœ…
Version tracking โœ… โŒ โŒ โŒ โœ…
Pattern recognition โœ… โœ… โŒ โŒ โŒ
Self-nudge / proactive โœ… โœ… โŒ โŒ โŒ

๐Ÿš€ Quick Start

As a pi skill (recommended)

# Clone directly into pi's skill directory
git clone https://github.com/ArtiNexus/pi-memory-tree.git ~/.pi/agent/skills/pi-memory-tree
bash ~/.pi/agent/skills/pi-memory-tree/install.sh

Pi will auto-discover the skill. Next session, the agent knows how to use it.

As a standalone project

git clone https://github.com/ArtiNexus/pi-memory-tree.git
cd pi-memory-tree
bash install.sh

After install

Start your next session โ€” the agent will automatically:

  • Load the focus board (WATCH.md) + index (MEMORY.md)
  • Remember past conversations via 3-level cascade
  • Save every Q&A as searchable session log
  • Record important facts to the right branch file

๐Ÿ“ฆ What's Included

pi-memory-tree/
โ”œโ”€โ”€ AGENTS.md           โ† Protocol: auto-load memory at session start
โ”œโ”€โ”€ install.sh          โ† One-command setup
โ”‚
โ”œโ”€โ”€ src/                โ† Shell scripts (copy to ~/.pi/skills/pi-memory/scripts/)
โ”‚   โ”œโ”€โ”€ memory.sh           Core: add/replace/remove/list/search
โ”‚   โ”œโ”€โ”€ session.sh          Session logging
โ”‚   โ”œโ”€โ”€ session_search.sh   Full-text cross-session search
โ”‚   โ”œโ”€โ”€ pattern.sh          Pattern recognition / self-improvement
โ”‚   โ””โ”€โ”€ consolidate_memory.sh  Daemon-driven health check
โ”‚
โ”œโ”€โ”€ template/
โ”‚   โ””โ”€โ”€ MEMORY_TEMPLATE.md  โ† Format spec for all branch files
โ”‚
โ”œโ”€โ”€ examples/            โ† Example memory tree (rename/adapt)
โ”‚   โ”œโ”€โ”€ MEMORY.md            Level 0 index
โ”‚   โ”œโ”€โ”€ MEMORY1_sem.md       Semantic: environment config
โ”‚   โ”œโ”€โ”€ MEMORY2_epi.md       Episodic: project timeline
โ”‚   โ”œโ”€โ”€ MEMORY3_pro.md       Procedural: tool manuals
โ”‚   โ””โ”€โ”€ ...
โ”‚
โ””โ”€โ”€ docs/
    โ”œโ”€โ”€ ARCHITECTURE.md      โ† Full design doc
    โ”œโ”€โ”€ COMPARISON.md        โ† Cross-system analysis
    โ””โ”€โ”€ QUICKSTART.md        โ† Detailed setup guide

๐Ÿง  How It Works

Every session, the agent loads the three-layer core:

  1. WATCH.md (Layer F) โ€” current focus board, drives smart Level 1 preloading
  2. MEMORY.md (Level 0) โ€” compact keyword โ†’ file index
  3. USER.md โ€” user profile and preferences

When a topic comes up, the agent follows the index to the relevant Level 1 file and loads only that file โ€” keeping context efficient. It also preloads Level 1 files linked from WATCH.md priorities.

Memory Cascade: When asked "remember X?", the agent automatically cascades:

  1. Memory tree (already-loaded context + Level 1 files)
  2. Session summaries (session_search.sh)
  3. Raw transcripts (raw_search.sh) โ€” no data loss guarantee

When new knowledge is learned:

  • P0 (critical) โ†’ saved immediately to the appropriate branch
  • P1 (important) โ†’ saved during or after the session
  • Daily log โ†’ every Q&A pair is timestamped in session files

๐Ÿ“œ License

MIT โ€” free to use, modify, share, and commercialize.


Built for Pi coding agent. Inspired by Hermes Agent (Nous Research), Mem0, Letta/MemGPT, and Zep. Distilled from cross-system analysis.

About

๐ŸŒณ Filesystem-native hierarchical memory tree for AI coding agents. Three-layer architecture: Focus board (WATCH.md) โ†’ Keyword index (MEMORY.md) โ†’ Detail branches (Level 1+N). Infinite capacity, zero dependencies, auto-cascade recall.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages