Commitor 🚀
Automatically generate conventional commit messages based on your git diff using AI.
Commitor is a Rust CLI tool that analyzes your staged git changes and generates conventional commit messages using AI models from OpenAI or Ollama. Say goodbye to writer's block when crafting commit messages!
✅ COMPLETE: Full implementation with AI-powered analysis and conventional commit generation!
🎉 Project Summary
This project successfully demonstrates a complete Rust application that:
- Integrates with multiple AI providers - OpenAI GPT models and Ollama local models
- Analyzes git diffs to understand code changes
- Generates conventional commit messages following industry standards
- Provides a CLI interface with multiple commands and options
- Includes comprehensive error handling and validation
- Features modular architecture with separate modules for different concerns
- Has extensive test coverage with unit and integration tests
- Supports multiple AI models and configuration options
Features
- 🤖 AI-Powered: Uses OpenAI GPT models or Ollama local models to analyze your code changes
- 📝 Conventional Commits: Generates messages following the conventional commit format
- 🎯 Multiple Options: Generate multiple commit message suggestions to choose from
- ⚡ Fast: Built in Rust for optimal performance
- 🔧 Flexible: Supports different providers, models and customization options
- 🏠 Local Support: Use Ollama for completely local AI processing
- 🎨 Beautiful Output: Colorized terminal output for better readability
Installation
Prerequisites
- Rust 1.70+ (install from rustup.rs)
- Git
- One of the following:
- OpenAI API key (for OpenAI provider)
- Ollama installation (for local AI processing)
Install from source
Configuration
OpenAI Setup
Set your OpenAI API key as an environment variable:
Or pass it directly using the --api-key flag.
Ollama Setup
- Install Ollama from ollama.ai
- Start the Ollama service:
- Pull a model (e.g., llama2):
Usage
Basic Usage
- Stage your changes:
- Generate commit messages with OpenAI (default):
- Or use Ollama for local processing:
- Generate and commit in one step:
Command Line Options
)
Examples
Generate multiple commit message options with OpenAI:
Use Ollama with a local model:
Use a different OpenAI model:
Auto-commit with the first suggestion:
Show diff before generating:
List available models (shows your installed models):
Check Ollama availability:
Use custom Ollama URL:
Conventional Commit Format
Commitor generates messages following the Conventional Commits specification:
<type>(<scope>): <description>
Supported Types
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Changes that do not affect the meaning of the coderefactor: A code change that neither fixes a bug nor adds a featuretest: Adding missing tests or correcting existing testschore: Changes to the build process or auxiliary toolsperf: A code change that improves performanceci: Changes to CI configuration files and scriptsbuild: Changes that affect the build system or external dependencies
Example Messages
feat(auth): add JWT token validationfix(database): resolve connection timeout issuedocs(readme): update installation instructionsrefactor(utils): simplify string parsing logictest(api): add integration tests for user endpoints
Configuration
You can customize the behavior by setting environment variables:
# Set your OpenAI API key (for OpenAI provider)
# Set default model (applies to both providers)
# Set default count
Ollama Models
Popular models you can use with Ollama:
llama2: General purpose modelcodellama: Optimized for code understandingmistral: Fast and efficient modelneural-chat: Good for conversational tasksdeepseek-coder: Specialized for coding tasks
Pull models using:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Development Setup
- Clone the repository
- Install dependencies:
cargo build - Run tests:
cargo test - Run the tool:
cargo run -- generate
Running Tests
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Built with rig.rs for unified AI provider integration (OpenAI and Ollama)
- Ollama for local AI model support
- Inspired by the Conventional Commits specification
- Uses git2 for git operations
Troubleshooting
Common Issues
"Not in a git repository"
- Make sure you're running the command inside a git repository
- Initialize a git repository with
git initif needed
"No staged changes found"
- Stage your changes first with
git add <files> - Check staged changes with
git status
"OpenAI API key not found" (OpenAI provider)
- Set the
OPENAI_API_KEYenvironment variable - Or use the
--api-keyflag
"Ollama is not available" (Ollama provider)
- Make sure Ollama is installed and running:
ollama serve - Check if Ollama is accessible:
commitor check-ollama - Verify the URL is correct with
--ollama-url
API rate limits (OpenAI provider)
- The tool respects OpenAI's rate limits
- If you hit limits, wait a moment and try again
Model not found (Ollama provider)
- Pull the model first:
ollama pull <model-name> - List your installed models:
commitor models --provider ollama
Debug Mode
Run with debug logging:
RUST_LOG=debug
✅ Implementation Status
Core Features Implemented:
- ✅ OpenAI GPT integration using rig.rs
- ✅ Git diff analysis and parsing
- ✅ Conventional commit message generation
- ✅ CLI with multiple commands (generate, commit, diff)
- ✅ Environment variable and flag configuration
- ✅ Multiple commit message options
- ✅ Auto-commit functionality
- ✅ Diff display and validation
- ✅ Comprehensive error handling
- ✅ Unit and integration tests
- ✅ Modular library architecture
- ✅ Installation and usage scripts
Key Technical Achievements:
- Built with Rust for performance and safety
- Uses rig.rs for unified AI provider integration (OpenAI and Ollama)
- Implements conventional commits specification
- Features async/await for non-blocking operations
- Includes colored terminal output for better UX
- Has comprehensive documentation and examples
- Supports multiple AI models across different providers
Future Roadmap:
- Support for local models via Ollama
- Support for more AI providers (Anthropic, Claude)
- Configuration file support
- Advanced git hooks integration
- Commit message templates
- Enhanced scope detection
- Batch processing for multiple commits
- Custom prompt templates