feat: add memory-index export for LLM context retention#1064
Open
josery wants to merge 3 commits into
Open
Conversation
…xporter for LLM context retention This module exports a memory index optimized for LLM context retention, generating JSON, Markdown, and HTML files for easy access and understanding of project structure.
Add tests for memory_index exporter functionality.
Added support for 'memory-index' export format in graphify.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new
graphify export memory-indexcommand that generates LLM-optimized context files, enabling Claude and other AI assistants to resume work on large projects without re-reading the entire codebase.Impact: 97% token reduction (~55K → 2K tokens per session start)
Problem
Large projects create a friction point for LLM workflows:
Solution
The
memory-indexexporter generates three lightweight files optimized for LLM consumption:memory_index.json (1-2 KB)
MEMORY_REPORT.md (2-3 KB)
memory_index.html (50 KB)
Implementation Details
Files Changed
graphify/memory_index.py (NEW - 576 lines)
write_memory_index()main functionsanitize_label()on all HTML outputgraphify/main.py (MODIFIED - 4 surgical changes)
tests/test_memory_index.py (NEW - 16 tests)
Key Features
✅ Compact JSON (only key modules, not full graph)
✅ Markdown report with next steps prominently featured
✅ Interactive HTML with search (Ctrl+K) and sort by degree
✅ Token estimation (helps predict session cost)
✅ Cluster detection and navigation
✅ Zero new dependencies (uses stdlib + existing imports)
✅ Python 3.9+ compatible (no
|union syntax)✅ Secure by default (HTML-escaped labels)
✅ Full type hints throughout
✅ Error handling for missing/invalid inputs
Usage