AI-Powered Git Commit Message Generator
Project description
# Commit-Gen - AI-Powered Git Commit Message Generator
Generate intelligent commit messages using AI with support for multiple providers including OpenRouter, Ollama, Google Gemini, Mistral AI, and Z.AI.
๐ Quick Start
Installation
pip install commit-gen
First Time Setup
# Interactive setup wizard (recommended)
commit-gen --setup
# Or manual setup
commit-gen --set-provider openrouter
commit-gen --set-api-key YOUR_API_KEY
Basic Usage
# Interactive file selection and commit
commit-gen
# Commit specific files
commit-gen --files src/main.py tests/test_main.py
# Commit all files
commit-gen --all
# Commit and push
commit-gen --push
๐ API Key Setup
OpenRouter
Step 1: Create Account
- Visit OpenRouter
- Click "Sign Up" and create an account
- Verify your email address
Step 2: Get API Key
- Go to OpenRouter API Keys
- Click "Create Key"
- Give your key a name (e.g., "commit-gen")
- Copy the generated API key
Step 3: Configure
commit-gen --set-provider openrouter
commit-gen --set-api-key YOUR_OPENROUTER_API_KEY
๐ก Tips:
- OpenRouter provides access to multiple AI models
- Free tier available with limited usage
- Supports models like GPT-4, Claude, and others
Google Gemini
Step 1: Create Google Cloud Project
- Visit Google Cloud Console
- Create a new project or select existing one
- Enable the Gemini API
Step 2: Enable Gemini API
- Go to Google AI Studio
- Click "Get API key"
- Create a new API key
- Copy the generated key
Step 3: Configure
commit-gen --set-provider gemini
commit-gen --set-api-key YOUR_GEMINI_API_KEY
๐ก Tips:
- Free tier: 15 requests per minute
- Supports models: gemini-2.5-flash, gemini-2.5-pro
- Requires Google Cloud account
Mistral AI
Step 1: Create Account
- Visit Mistral AI
- Click "Sign Up" and create an account
- Verify your email address
Step 2: Get API Key
- Go to Mistral AI Console
- Click "Create new API key"
- Give your key a name (e.g., "commit-gen")
- Copy the generated API key
Step 3: Configure
commit-gen --set-provider mistral
commit-gen --set-api-key YOUR_MISTRAL_API_KEY
๐ก Tips:
- Free tier: 20 requests per minute
- Supports models: mistral-large-latest, mistral-medium-latest
- High-quality reasoning capabilities
Z.AI
Step 1: Create Account
- Visit the Z.AI Open Platform Quick Start: Z.AI Quick Start
- Register or log in
- Create an API key in the API Keys page
Step 2: Configure
commit-gen --set-provider zai
commit-gen --set-api-key YOUR_ZAI_API_KEY
# Optional: set model (default: glm-4.6)
commit-gen --set-model glm-4.6
Notes:
- Endpoint:
https://api.z.ai/api/paas/v4/chat/completions - OpenAI-compatible request/response (non-stream)
- See docs: Z.AI Quick Start
Ollama (Local - No API Key Required)
Step 1: Install Ollama
# macOS/Linux
curl -fsSL https://ollama.ai/install.sh | sh
# Windows
# Download from https://ollama.ai/download
Step 2: Start Ollama
ollama serve
Step 3: Pull Model
ollama pull qwen2.5-coder:7b
Step 4: Configure
commit-gen --set-provider ollama
# No API key needed for local Ollama
๐ก Tips:
- Runs locally on your machine
- No internet required after model download
- Free to use
- Supports many open-source models
Custom Provider
Step 1: Get API Key
- Obtain API key from your custom provider
- Note the base URL for the provider
Step 2: Configure
commit-gen --set-provider custom
commit-gen --set-api-key YOUR_CUSTOM_API_KEY
commit-gen --set-base-url https://your-provider.com/api/v1
โจ Key Features
- ๐ค AI-Powered: Generate commit messages using advanced AI models
- ๐ Interactive File Selection: Choose which files to commit with arrow key navigation
- ๐ง Multiple AI Providers: Support for OpenRouter, Ollama, Google Gemini, Mistral AI
- โ๏ธ Easy Configuration: Interactive setup wizard and simple CLI commands
- ๐ Smart Review: Edit and confirm commit messages before committing
- ๐ Auto Push: Optional automatic push to remote repository
๐ ๏ธ Supported AI Providers
| Provider | Type | Default Model | API Key Required | Free Tier |
|---|---|---|---|---|
| OpenRouter | Cloud | moonshotai/kimi-k2:free | โ | โ |
| Ollama | Local | qwen2.5-coder:7b | โ | โ |
| Google Gemini | Cloud | gemini-2.5-flash | โ | โ |
| Mistral AI | Cloud | mistral-large-2411 | โ | โ |
| Z.AI | Cloud | glm-4.6 | โ | Varies |
| Custom | Any | Configurable | โ | Varies |
๐ Usage Examples
Interactive File Selection
commit-gen
Shows an interactive interface where you can:
- Navigate files with โ/โ arrow keys
- Toggle selection with SPACE
- See file status (modified, added, untracked)
File Selection Interface
When you run commit-gen without arguments, you'll see an interactive interface with arrow key navigation:
๐ Files to commit:
============================================================
Use โ/โ to navigate, SPACE to toggle, ENTER to confirm
a=select all, n=select none, s=skip (stage all), q=quit
๐ CODE:
โ [ ] commit_gen/cli.py (modified, 18KB)
[x] demo_file2.py (added, 13B) โ
[ ] README.md (modified, 9KB)
[ ] arrow_config.json (untracked, 12B)
Selected: 1/4 files
Navigation Controls:
- โ/โ Arrow Keys: Navigate through files
- SPACE: Toggle file selection (check/uncheck)
- ENTER: Confirm selection and proceed
- a: Select all files
- n: Select none (use only already staged files)
- s: Skip selection (stage all files)
- q: Quit without committing
Visual Indicators:
- โ: Current cursor position
- [x]: Selected file
- [ ]: Unselected file
- โ : Already staged file
- Selected: X/Y files: Shows selection count
Features:
- Status indicators: Shows if files are modified, added, or untracked
- Size information: Displays file sizes
- Staged markers: Shows which files are already staged
- Real-time selection: See selection count update as you navigate
- Keyboard navigation: Intuitive arrow key and spacebar controls
Commit Confirmation
After selecting files, commit-gen will:
- Generate AI commit message
- Show commit message for review
- Allow editing (with external editor or simple input)
- Confirm before committing
Commit Review Interface:
๐ค Generating commit message...
๐ Edit commit message:
============================================================
Current commit message:
------------------------------
feat: add interactive file selection with arrow keys
- Implement arrow key navigation for file selection
- Add spacebar toggle for file selection
- Improve UX with visual indicators and real-time feedback
------------------------------
Options:
1. Edit message
2. Use as-is
3. Cancel
Commit Confirmation:
๐ Commit Review:
============================================================
Commit message:
------------------------------
feat: add interactive file selection with arrow keys
- Implement arrow key navigation for file selection
- Add spacebar toggle for file selection
- Improve UX with visual indicators and real-time feedback
------------------------------
Options:
1. โ
Yes, commit
2. ๐ Yes, commit and push
3. โ No, go back to editing
4. ๐ช Cancel
Confirmation Options:
- Yes, commit: Commit only
- Yes, commit and push: Commit and push to remote
- No, go back to editing: Return to edit commit message
- Cancel: Exit without committing
Editing Options:
- External Editor: Uses
$EDITOR(default: nano) - Simple Input: Fallback if editor not available
- Validation: Ensures commit message is not empty
Quick Commits
# Commit specific files
commit-gen --files src/main.py tests/test_main.py
# Commit all modified files
commit-gen --all
# Commit and push automatically
commit-gen --push
Provider Configuration
# Set provider
commit-gen --set-provider gemini
# Set API key
commit-gen --set-api-key YOUR_API_KEY
# Set custom model
commit-gen --set-model gemini-2.5-pro
# View current config
commit-gen --config
๐ง Configuration
Interactive Setup (Recommended)
commit-gen --setup
Guides you through:
- Provider selection
- API key configuration
- Model selection
- Connection testing
Manual Configuration
# Show available providers
commit-gen --providers
# Configure OpenRouter
commit-gen --set-provider openrouter
commit-gen --set-api-key YOUR_OPENROUTER_KEY
# Configure Ollama (local)
commit-gen --set-provider ollama
# No API key needed for Ollama
# Configure Google Gemini
commit-gen --set-provider gemini
commit-gen --set-api-key YOUR_GEMINI_KEY
# Configure Mistral AI
commit-gen --set-provider mistral
commit-gen --set-api-key YOUR_MISTRAL_KEY
# Configure Z.AI
commit-gen --set-provider zai
commit-gen --set-api-key YOUR_ZAI_KEY
# Optional: set model (default is glm-4.6)
commit-gen --set-model glm-4.6
๐ฏ Advanced Features
Custom Prompts
# Inline prompt
commit-gen --prompt "Generate a conventional commit message: {changes}"
# Load prompt from file
commit-gen --prompt-file my_prompt.txt
# Save current prompt to file
commit-gen --save-prompt-file my_prompt.txt
Example prompt file (my_prompt.txt):
You are an expert developer. Generate a clear, concise commit message based on the following changes:
{changes}
Requirements:
- Use conventional commit format (type: description)
- Keep it under 50 characters for the first line
- Add detailed description if needed
- Focus on what changed and why
- Use present tense ("add" not "added")
- Be specific but concise
Examples:
- feat: add user authentication system
- fix: resolve memory leak in data processing
- docs: update API documentation
- refactor: simplify database query logic
Changelog Generation
commit-gen --changelog
commit-gen --changelog --compare-branch develop
Debug Mode
commit-gen --debug
Troubleshooting
Issue: Command not found after installation
If commit-gen command is not found after installation:
-
Check if symlink exists:
ls -la /usr/local/bin/commit-gen
-
If symlink is broken, recreate it:
sudo ln -s /path/to/your/project/commit-gen.py /usr/local/bin/commit-gen
-
For pip installation, check PATH:
which commit-gen echo $PATH
Issue: Configuration files not cleaned up
If configuration files remain after uninstallation:
rm -rf ~/.config/git-commit-ai/
Issue: API Key Authentication Failed
Common Solutions:
-
Check API Key Format:
- Ensure no extra spaces or characters
- Copy the entire key from provider dashboard
-
Verify Provider Configuration:
commit-gen --config -
Test with Different Model:
commit-gen --set-model gpt-4o-mini # For OpenRouter commit-gen --set-model gemini-2.5-flash # For Gemini
-
Check API Key Permissions:
- Ensure key has proper permissions
- Check if key is active in provider dashboard
Issue: Rate Limiting
Solutions:
- OpenRouter: Upgrade to paid plan for higher limits
- Gemini: Wait for rate limit reset (usually 1 minute)
- Mistral: Check usage in Mistral console
- Ollama: No rate limits (local usage)
๐ Requirements
- Python: 3.8 or higher
- Git: Working git repository
- AI Provider: At least one AI provider configured
๐ Acknowledgments
- Powered by various AI providers
- Inspired by the need for better commit messages
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 commit_gen_cli-1.1.7.tar.gz.
File metadata
- Download URL: commit_gen_cli-1.1.7.tar.gz
- Upload date:
- Size: 38.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cf655300658b5cb3d59e52144d83d4a8110b2f0bb6f377cd01914ca53f30f8c
|
|
| MD5 |
bc57c2b4889e3bf5e4d9c8347eee5b1f
|
|
| BLAKE2b-256 |
ecaf20b61db6c2b3fd780ee1e81593f282141763ce16442217607ad3c73aaee8
|
File details
Details for the file commit_gen_cli-1.1.7-py3-none-any.whl.
File metadata
- Download URL: commit_gen_cli-1.1.7-py3-none-any.whl
- Upload date:
- Size: 31.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fffd2961fb08604fe8183235cf844a44608382a764ecae884aa141611826228
|
|
| MD5 |
76d9f0d3dc23eabad5e18cff48b5259f
|
|
| BLAKE2b-256 |
e4f3299f00d999389aead65e33302a7ee9057b7c53ac3e7cc6b06de2ae5eacce
|