Interactive code summarizer using AI and TUI
Project description
CodeSum: Intelligent Code Context for LLMs
Generate optimized code summaries that reduce token usage by 10-20x and deliver 4x faster results when working with AI coding assistants.
CodeSum is a terminal-based tool that transforms your codebase into perfectly formatted context for Large Language Models. Through an interactive file selector, intelligent compression, and persistent configurations, CodeSum makes it effortless to provide your AI assistant with exactly the right code context—without the overhead.
Why CodeSum?
Working with AI coding assistants typically involves one of two approaches:
- Agentic tools that crawl your entire codebase, consuming massive token counts and taking significant time
- Manual context where you copy-paste files, often missing critical dependencies or including irrelevant code
CodeSum solves both problems:
- 10-20x fewer tokens: Selective file inclusion and optional AI compression dramatically reduce context size
- 75% faster: Pre-generated summaries eliminate the need for agents to explore your codebase
- Better results: Focused, relevant context produces more accurate responses
- Reusable configurations: Save and recall file selections for different workflows
- Zero learning curve: Simple TUI with intuitive keyboard shortcuts and mouse support
Version 0.3.0 Highlights
This release introduces major workflow improvements and a completely redesigned user experience:
Per-File Compression
- Mark individual files for AI-powered compression with the
Skey - Mix full-content and compressed files in a single summary
- Compressed files show with a distinct marker (★) and don't count toward token totals
Selection Configuration Management
- Save named configurations of file selections and compression settings
- Full CRUD operations (Create, Read, Update, Delete) through an intuitive popup (press
M) - Instantly switch between different workflow contexts
Enhanced Terminal Experience
- Complete mouse support: click to select, scroll to navigate
- Improved keyboard navigation with left/right arrows for folder jumping
- Graceful Ctrl+C handling that preserves state
- Comprehensive help system (press
Hor?) - Beautiful exit screen with ASCII logo and summary statistics
Streamlined Workflow
- No more API key prompts on startup—only when you use AI features
- Automatic clipboard copy with clear visual confirmation
- All selected files displayed in exit summary (no truncation)
- Lazy OpenAI client initialization for faster startup
Installation
Requires Python 3.8 or higher.
pip install codesum
Quick Start
-
Navigate to your project root:
cd /path/to/your/project
-
Run CodeSum:
codesum
-
Select files in the interactive TUI:
- Space: Toggle file selection ([X] marker)
- S: Mark file for compressed summary (★ marker)
- M: Manage saved configurations
- H: Show help with all keyboard shortcuts
- Enter: Generate summary and copy to clipboard
-
Paste the clipboard content into your AI assistant
Key Features
Interactive TUI
- Smart file selection with folder expansion/collapse
- Mouse support for clicking and scrolling
- Keyboard shortcuts for efficient navigation
- Token counting displays exact context size
- Responsive layout adapts to terminal width
Intelligent Summaries
- Full-content summaries: Complete code with project structure
- AI compression: Selective compression for large files (requires OpenAI API key)
- Mixed mode: Combine full and compressed content in one summary
- Content hashing: Cached summaries avoid redundant API calls
Persistent State
- Selection memory: Remembers your file selections per project
- Named configurations: Save and recall different file selection sets
- Folder collapse state: Preserves your UI preferences
- Custom ignore patterns: Project-specific ignore rules
Smart Filtering
- Respects .gitignore: Automatically excludes ignored files
- Default ignore list: Skips common directories (node_modules, venv, .git, etc.)
- Custom ignore file: Add project-specific patterns in
.summary_files/codesum_ignore.txt
Configuration Management
Set up your OpenAI API key (optional, only needed for AI compression):
codesum --configure
Configuration is stored in your user config directory:
- Linux:
~/.config/codesum/settings.env - macOS:
~/Library/Application Support/codesum/settings.env - Windows:
%APPDATA%\codesum\codesum\settings.env
TUI Keyboard Shortcuts
Navigation
- ↑/↓: Move selection up/down
- ←/→: Jump to previous/next folder
- PgUp/PgDn: Page up/down
- Mouse scroll: Scroll through files
Selection
- Space: Toggle file selection ([X] marker)
- S: Toggle compressed summary (★ marker)
- F: Toggle all files in current folder
- A: Select/deselect all files
- E: Expand all folders recursively
- C: Collapse all child folders recursively
Management
- M: Open configuration management popup
- S: Save current selection
- L: Load configuration
- R: Rename configuration
- D: Delete configuration
- H or ?: Show help
- Enter: Confirm and generate summary
- Q or Esc: Quit without saving
Output Files
CodeSum creates a .summary_files/ directory containing:
code_summary.md: The generated summary (automatically copied to clipboard)previous_selection.json: Your last file selectionselection_configs.json: Saved configuration presetscollapsed_folders.json: UI state for folder collapse[filename]_metadata.json: Cached AI summaries with content hashes
Development Installation
To install from source:
git clone https://github.com/sam1am/codesum.git
cd codesum
python3 -m venv venv
source venv/bin/activate # On Windows: .\venv\Scripts\activate
pip install -e .
Dependencies
openai- OpenAI API clienttiktoken- Token countingpathspec- gitignore parsingpython-dotenv- Configuration managementpyperclip- Clipboard operationsplatformdirs- Cross-platform config pathswindows-curses- Windows terminal support (Windows only)importlib-resources- Resource loading (Python < 3.9 only)
Use Cases
Debugging Complex Issues
Select relevant modules and their tests, generate a summary, and provide focused context to your AI assistant. Results are more accurate because the model sees only what matters.
Feature Implementation
Save a configuration with your feature's core files. Load it whenever working on that feature. No need to re-select files or provide redundant context.
Code Reviews
Mark large files for compression while keeping critical files at full detail. Get concise summaries perfect for review discussions.
Documentation
Use AI compression on implementation files while keeping API interfaces at full detail. Generate accurate documentation without token bloat.
Performance Comparison
Traditional Agentic Approach:
- Agent crawls codebase: 150,000+ tokens
- Time to understand context: 2-3 minutes
- Cost per interaction: High
CodeSum Approach:
- Selective file inclusion: 15,000 tokens (10x reduction)
- Instant context availability: Pre-generated
- Cost per interaction: 10x lower
- Result quality: Superior due to focused context
Video Tutorial
Note: Video shows earlier version. Current version (0.3.0) includes additional features like per-file compression, mouse support, and configuration management.
License
MIT License - see LICENSE file for details
Contributing
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
Acknowledgements
Built with Python, OpenAI API, and the excellent libraries that make terminal UIs possible. Thanks to the open-source community for their continued support and contributions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file codesum-0.3.1.tar.gz.
File metadata
- Download URL: codesum-0.3.1.tar.gz
- Upload date:
- Size: 44.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
197f29ca019c96b760713c25792a8eacd2f75a478a984d4f6c168429f03954ec
|
|
| MD5 |
8975bcb1a4d4490bfa74f0473c617050
|
|
| BLAKE2b-256 |
f37f6d67aeb486122a7093f46d3a549e0605f2cec124e8daa72efab8d8bcd010
|
File details
Details for the file codesum-0.3.1-py3-none-any.whl.
File metadata
- Download URL: codesum-0.3.1-py3-none-any.whl
- Upload date:
- Size: 45.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48072c8424a9db5101830f637e7351a697280617d4a740e6e7a7277edf6e1ff0
|
|
| MD5 |
298f00f3bbf5fe56b774226579bd225f
|
|
| BLAKE2b-256 |
9ebb819def16c8addd0331e0eec3b8a1c2e583f393ead6831cc5d7a46939eddb
|