A six-layer persistent memory system for CodeBuddy — keeps your AI assistant aware of who you are, what you're working on, and what you've decided, across all sessions.
Language: 中文文档
CodeBuddy sessions are stateless — each conversation starts fresh. Without a memory system, your AI assistant forgets:
- What projects you're working on
- Technical decisions you've made
- Your preferences and coding style
- Progress across multiple sessions
This project solves that with a six-layer persistent memory architecture that automatically records, consolidates, and surfaces the right context at the right time.
L1 SOUL.md AI behavior principles (e.g. "be proactive, not passive")
L2 USER.md Your profile — skills, goals, preferences
L3 CODEBUDDY.md Global config — environment, projects, imports
L4 MEMORY.md Permanent memory — auto-consolidated nightly
L5 daily-memories/ Temporary memory — per-day work logs
L6 update_memory Fragment memory — CodeBuddy's built-in persistence
Every night at 23:00, the system runs a 6-stage pipeline:
daily-memories/*.md
→ 1. Extract info (decisions, preferences, todos, progress)
→ 2. Deduplicate (Jaccard similarity ≥ 0.8)
→ 3. Filter trivia (tests, typos, formatting)
→ 4. Score by priority (keywords: architecture, design, security)
→ 5. Categorize by project
→ 6. Write MEMORY.md (capped at 200 lines)
- Python 3.9 or later (standard library only — zero external dependencies)
- macOS (for launchd scheduling)
- CodeBuddy IDE or CLI
# Clone the repository
git clone https://github.com/Kylinx-code/memory-system.git
cd memory-system
# Verify your environment
python3 scripts/memory_consolidator.py status# Install launchd jobs (daily consolidation + weekly review)
bash scripts/schedule_setup.sh install
# Verify they're running
bash scripts/schedule_setup.sh statusThe system runs automatically in the background:
- Daily at 23:00 — consolidates temporary memories into MEMORY.md
- Weekly Sunday 22:00 — reviews, archives, and cleans up
Quick execution via run.sh (recommended):
# Manual daily consolidation (same as 23:00 auto-task)
bash scripts/run.sh consolidate
# Manual weekly review (same as Sunday 22:00 auto-task)
bash scripts/run.sh review
# Check system status
bash scripts/run.sh statusDirect Python invocation:
python3 scripts/memory_consolidator.py status
python3 scripts/memory_consolidator.py consolidate
python3 scripts/memory_consolidator.py archive
python3 scripts/memory_consolidator.py review.
├── scripts/
│ ├── memory_consolidator.py # Core engine (500+ lines, pure stdlib)
│ ├── run.sh # Convenient manual execution entry point
│ └── schedule_setup.sh # launchd deployment for macOS
├── docs/
│ └── memory-system-guide.md # Full user guide (Chinese)
├── .gitignore
├── LICENSE # MIT
├── CHANGELOG.md
├── CODEBUDDY.md # Project guide for CodeBuddy IDE
├── README.md # You are here
└── README.zh-CN.md # Chinese version
| Decision | Rationale |
|---|---|
| Zero external dependencies | Maximize portability across environments |
| Python stdlib only | No pip install needed; works out of the box |
| Jaccard 0.8 threshold | Balances dedup precision vs recall for Chinese text |
| 200-line MEMORY.md cap | Respects CodeBuddy's autoMemory context window |
| 7-day daily-memory retention | Keeps transient data manageable; archive for history |
- Cross-platform scheduler support (Linux systemd, Windows Task Scheduler)
- Memory search with semantic relevance ranking
- CI pipeline for automated testing
- Plugin architecture for custom extractors
Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change.
MIT © 2026 段晓航 (Kylinx-code)
Built for CodeBuddy, inspired by the six-layer memory architecture from the CSDN community.