A powerful CLI and TUI tool for bundling files and directories into AI/LLM-friendly formats. Perfect for sharing code snippets and project structures with AI assistants.
AIBundle is a multi-format specification designed for optimal code sharing with Large Language Models:
- Multiple Representations: Each bundle can be exported as:
- XML (hierarchical and structured)
- Markdown (human-readable and LLM-friendly)
- JSON (parseable and programmatic)
- LLM (enhanced AI-optimized format with dependency analysis)
- File Hierarchy: Preserves directory structure and relationships
- Content Preservation: Maintains original file content and formatting
- Binary Handling: Identifies and marks binary files
- Path Normalization: Uses forward slashes for cross-platform compatibility
- Line Numbers: Optional line numbering for precise code references
- Selection Limits: Smart handling of large directories with selection limits (default: 400 files)
- Async Operations: Non-blocking UI during large operations
- Command Line Mode: Full CLI support with config persistence
- Smart Dependency Analysis: Detects and visualizes file relationships (LLM format)
<file name="src/main.rs">
// File contents here
</file>
<folder name="src/lib">
<file name="src/lib/mod.rs">
// File contents here
</file>
</folder>
```src/main.rs
// File contents here
```
```src/lib/mod.rs
// File contents here
```
[
{"type":"file","path":"src/main.rs","binary":false,"content":"// File contents here"},
{"type":"directory","path":"src/lib","contents":[
{"type":"file","path":"src/lib/mod.rs","binary":false,"content":"// File contents here"}
]}
]
# PROJECT ANALYSIS FOR AI ASSISTANT
## π¦ GENERAL INFORMATION
- **Project path**: `/home/user/project`
- **Total files**: 12
- **Files included in this analysis**: 8
- **Main languages used**:
- Rust (5 files)
- Markdown (2 files)
- TOML (1 file)
## ποΈ PROJECT STRUCTURE
/home/user/project βββ src β βββ main.rs β βββ lib.rs β βββ utils β βββ helpers.rs βββ tests β βββ integration_test.rs βββ Cargo.toml
## π FILE RELATIONSHIPS
### Core Files (most referenced)
- **`src/lib.rs`** is imported by 3 files
### Dependencies by File
- **`src/main.rs`**:
- *Internal dependencies*: `src/lib.rs`, `src/utils/helpers.rs`
- *External dependencies*: `std::io`, `clap`
## π FILE CONTENTS
### src/main.rs
```rust
fn main() {
println!("Hello, world!");
}
## Features π
- π₯οΈ **Dual-Mode Operation**:
- Interactive TUI for visual file exploration
- Full-featured CLI for scripting and automation
- π Interactive file browser with folder expansion/collapse
- π Enhanced search functionality:
- Real-time filtering
- Glob pattern support
- Recursive or non-recursive search modes
- β¨ Rich file icons for over 200 file types
- π Export in multiple formats:
- XML (hierarchical and structured)
- Markdown (human-readable format)
- JSON (parseable format)
- LLM (AI-optimized with dependency analysis)
- π Smart code analysis (LLM format):
- Dependency detection between files
- Project structure visualization
- Focused project insights for AI
- π― Smart file filtering:
- `.gitignore` support
- Default ignore patterns (node_modules, target, etc.)
- Custom ignore patterns
- Binary file handling
- β¨οΈ Intuitive keyboard shortcuts
- π₯οΈ Cross-platform clipboard support:
- Windows (PowerShell)
- macOS (pbcopy/pbpaste)
- Linux - X11 (xclip)
- Linux - Wayland (wl-copy/wl-paste)
- WSL2 integration
- π Line number support for all formats
- π Format switching on the fly
- β‘ Performance optimizations:
- Asynchronous directory scanning
- Iterative vs. recursive loading options
- Early bailout for large selections
- π¨ Beautiful TUI with modal dialogs and help screens
- π Detailed copy statistics with file counts and sizes
- π Selection limits to prevent memory issues (configurable)
- βοΈ Persistent configuration:
- Save and load settings
- Per-user configuration files
- CLI and TUI configuration separation
## Installation π¦
Using Cargo:
```bash
cargo install aibundle
From source:
git clone https://github.com/yourusername/aibundle
cd aibundle
cargo build --release
Launch AIBundle's interactive terminal interface in any directory:
aibundle # Current directory
aibundle /path/to/project # Specific directory
Use AIBundle directly from the command line:
# Basic usage - copy all .rs files to clipboard in LLM format
aibundle --files "*.rs"
# Export to a file instead of clipboard
aibundle --files "*.{rs,toml}" --output-file project_bundle.md
# Print to console with line numbers
aibundle --files "src/*.rs" --output-console --line-numbers
# Specify format and other options
aibundle --files "*.py" --format markdown --recursive
# Save your preferences for future use
aibundle --format llm --gitignore true --recursive true --save-config
aibundle [OPTIONS] [SOURCE_DIR]
- File pattern matching and selection
- Multiple output formats (XML, Markdown, JSON, LLM)
- Content search capabilities
- Gitignore integration
- Clipboard, file, or console output
- Configurable ignore patterns
- Configuration saving
Option | Description | Example |
---|---|---|
--files , -f |
File pattern to match | --files "*.rs" |
--format , -m |
Output format (xml/markdown/json/llm) | --format markdown |
--output-file , -o |
Write to file instead of clipboard | --output-file bundle.md |
--output-console , -p |
Write to console instead of clipboard | --output-console |
--source-dir , -d |
Source directory (default: current) | --source-dir ./src |
--search , -s |
Search pattern to match file contents | --search "function" |
--recursive , -r |
Include subfolders recursively | --recursive |
--line-numbers , -n |
Show line numbers in output | --line-numbers |
--gitignore , -g |
Use .gitignore files for filtering (default: true) | --gitignore |
--ignore , -i |
Ignore patterns (comma-separated list) | --ignore node_modules,target |
--save-config , -S |
Save current settings to .aibundle.config | --save-config |
Pattern | Description | Example |
---|---|---|
* |
Match any characters | *.rs |
? |
Match single character | test?.rs |
** |
Match directories recursively | src/**/*.rs |
{} |
Group patterns | *.{rs,toml} |
- Space: Toggle selection of current item
-
- (asterisk): Toggle all visible items
- Press
/
to enter search mode - Case-insensitive by default
- Matches file names and paths
- Press 'f' to cycle through formats: XML, Markdown, JSON, LLM
- Press 'n' to toggle line numbers
- Press 'c' to copy selected files
- Press 'Tab' to expand/collapse folders
- Press 'Enter' to navigate into directories
- Press 'i' to toggle default ignores
- Press 'g' to toggle gitignore usage
- Press 'b' to toggle binary files inclusion
- Press 's' to save current configuration
- Press 'h' to show help
- Press 'q' to quit (copies selected items to clipboard)
- β³ Operation in progress
- β Operation complete
- β Operation failed
AIBundle saves configuration in ~/.aibundle.config.toml
:
[cli]
files = "*.rs"
format = "llm"
recursive = true
[tui]
format = "markdown"
line_numbers = true
selection_limit = 600
Navigation:
β/β
- Move selectionPgUp/PgDn
- Move by 10 itemsEnter
- Open directoryTab
- Expand/collapse folder
Selection:
Space
- Select/deselect item*
- Select/deselect all visible items
Actions:
c
- Copy selected items to clipboardf
- Toggle format (XML β Markdown β JSON β LLM)n
- Toggle line numbers/
- Search (ESC to cancel)
Filters:
i
- Toggle default ignoresg
- Toggle .gitignore supportb
- Toggle binary files
Other:
h
- Show helps
- Save configurationq
- Quit (copies if items selected)
- Use XML for AI platforms that expect structured input
- Use Markdown for documentation and readability
- Use JSON for programmatic processing
- Use LLM for optimized language model input
- Enable line numbers for code review contexts
- Save your preferred configuration with
--save-config
Core dependencies:
- crossterm - Terminal manipulation and events
- ratatui - Terminal user interface framework
- ignore - .gitignore support and file filtering
- clap - Command line argument parsing
- serde - Serialization/deserialization framework
- toml - TOML file parsing for configuration
- glob - Glob pattern matching
- regex - Regular expressions for dependency analysis
- itertools - Additional iterator adaptors
# Clean build
cargo clean
cargo build --release
# Run all checks
cargo fmt --all -- --check
cargo fmt
cargo clippy --all-targets --all-features
cargo test --all-features
cargo doc --no-deps
# If publishing to crates.io
cargo publish --dry-run
AIBundle v0.6.13 includes several performance optimizations:
- Asynchronous processing:
- Non-blocking item counting during selection
- Background processing of large operations
- Smart selection management:
- Early bailout for large directory selections
- Default selection limit of 400 files (configurable)
- Hierarchical selection cascading
- Improved file navigation:
- Iterative vs. recursive directory traversal options
- Smart caching of directory contents
- Efficient path normalization
- Search optimizations:
- Pattern-based (glob) or text-based search options
- Recursive or non-recursive search modes
- Real-time filtering with pattern matching
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- The Rust community for amazing crates
- ratatui for the excellent TUI framework
- All contributors who have helped shape this project
Made with β€οΈ by the AIBundle Team