rust-ingest is a command-line tool that generates a comprehensive text digest of a code repository. It intelligently traverses a directory, bundling all relevant source code into a single text file. This is particularly useful for providing context to Large Language Models (LLMs) or for creating a complete snapshot of a project's source for archival or review.
The tool is smart about what it includes, automatically respecting .gitignore rules and skipping common binary files, build artifacts, and dependency directories.
- Intelligent Filtering: Automatically respects
.gitignore,.ignore, and other standard ignore files. - Default Ignores: Comes with a built-in list of common directories (
node_modules,target, etc.) and files (.DS_Store,package-lock.json) to exclude. - Customizable Patterns: Use glob patterns to precisely
--includeor--excludefiles and directories. - Content-Aware: Includes a file's path in the directory tree but can exclude its content from the digest (e.g., for images, archives, or large files).
- Size Limiting: Exclude content from files that exceed a configurable size limit with the
--max-sizeflag. - Fast: Built in Rust for high performance, even on large repositories.
You can install rust-ingest directly from source using Cargo.
-
Clone the repository:
git clone https://github.com/your-username/rust-ingest.git cd rust-ingest -
Install the binary:
cargo install --path .
This command compiles and installs the rust-ingest executable in your Cargo binary path (~/.cargo/bin), making it available from anywhere in your terminal.
Once installed, you can run the tool using the rust-ingest command.
To run on the current directory and create a digest.txt file:
rust-ingestTo analyze a different repository:
rust-ingest /path/to/another/repoSpecify a different output file:
rust-ingest . --output my-project-digest.txtInclude only specific file types (e.g., Rust and TOML files):
rust-ingest . --include "*.rs" --include "*.toml"Exclude a specific directory and all log files:
rust-ingest . --exclude "docs/" --exclude "*.log"Increase the file size limit for content inclusion to 200 KB:
rust-ingest . --max-size 200Here is the complete list of options available:
$ rust-ingest --help
Generate a directory content digest, intelligently excluding non-source files.
Usage: rust-ingest [OPTIONS] [PATH]
Arguments:
[PATH] The root directory to process [default: .]
Options:
-i, --include <INCLUDE> Glob patterns for files to include. If used, only matching files are included
-e, --exclude <EXCLUDE> Additional glob patterns for files or directories to exclude
--max-size <MAX_SIZE>
Maximum file size in KB for content inclusion [default: 100]
-o, --output <OUTPUT>
Output file name [default: digest.txt]
-h, --help
Print help
-V, --version
Print versionTo build and run this project from source for development purposes:
-
Clone the repository:
git clone https://github.com/your-username/rust-ingest.git cd rust-ingest -
Build and run with Cargo:
# This runs the tool on itself cargo run -- . --output self-digest.txt
This project is licensed under the MIT License.