A Rust command-line application that automatically generates intelligent commit messages using OpenRouter API based on your staged git changes.
- π€ AI-Generated Commit Messages: Uses OpenRouter API to generate contextual commit messages
- π Smart Change Detection: Analyzes staged changes or auto-stages all changes
- π One-Command Workflow: Generate and commit in a single command
- π‘οΈ Safety First: Dry-run mode to preview commit messages before committing
- π Conventional Commits: Follows conventional commit format standards
- βοΈ Configurable: Flexible command-line options
- Rust (1.70 or later)
- Git repository
- OpenRouter API key
# Clone the repository
git clone <repository-url>
cd distill
# Build the application
cargo build --release
# Install globally (optional)
cargo install --path .Set your OpenRouter API key:
export OPENROUTER_API_KEY="your-api-key-here"To make this permanent, add it to your shell profile (~/.bashrc, ~/.zshrc, etc.):
echo 'export OPENROUTER_API_KEY="your-api-key-here"' >> ~/.zshrc
source ~/.zshrcEnsure your git user information is configured:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"# Generate commit message and commit automatically
distill
# Preview commit message without committing (dry run)
distill --dry-run
# Don't auto-stage changes - only work with already staged changes
distill --no-auto-stage
# Verbose output for debugging
distill --verbose--no-auto-stage: Don't automatically stage changes if no changes are staged--dry-run: Generate commit message but don't commit--verbose, -v: Enable verbose logging output--help, -h: Show help information
# Make your changes
echo "console.log('Hello, World!');" > hello.js
# Generate AI commit message and commit
distill# Stage specific files
git add src/main.rs
# Generate commit message for staged changes only
distill --no-auto-stage# See what commit message would be generated
distill --dry-run
# If you like it, run again without --dry-run
distill- Change Detection: Checks for staged changes in your git repository
- Auto-Staging: If no changes are staged (and
--no-auto-stageisn't set), stages all changes - Diff Generation: Creates a diff of the staged changes
- AI Processing: Sends the diff to OpenRouter API for commit message generation
- Commit Creation: Creates a git commit with the AI-generated message
The application uses the OpenRouter API with the meta-llama/llama-3.1-8b-instruct:free model by default. The AI is prompted to generate commit messages following conventional commit standards.
Generated commit messages follow the conventional commit format:
feat: add new featurefix: resolve bug in authenticationdocs: update API documentationrefactor: restructure user service
The application provides clear error messages for common issues:
- Missing API Key: Clear instructions to set
OPENROUTER_API_KEY - Not in Git Repository: Ensures you're running from within a git repository
- No Changes: Handles cases where there are no changes to commit
- API Failures: Graceful handling of network or API issues
-
"OPENROUTER_API_KEY environment variable is not set"
- Solution: Set your API key as shown in the Configuration section
-
"Failed to open git repository"
- Solution: Ensure you're running the command from within a git repository
-
"No changes to commit"
- Solution: Make some changes to your files or check if you have uncommitted changes
-
API request failures
- Solution: Check your internet connection and API key validity
Use the --verbose flag to see detailed logs:
distill --verboseThis will show:
- Git operations
- API requests and responses
- Internal processing steps
src/
βββ main.rs # CLI interface and orchestration
βββ config.rs # Configuration and environment variables
βββ git.rs # Git operations (staging, diff, commit)
βββ openrouter.rs # OpenRouter API client
# Development build
cargo build
# Release build
cargo build --release
# Run tests
cargo test
# Run with logs
RUST_LOG=debug cargo run -- --verbose- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenRouter for providing the AI API
- The Rust community for excellent crates
- Git for being an amazing version control system