Skip to main content

AI-powered commit message generator

Project description

Cmscribe

Python Version License

AI-powered commit message generator that leverages various AI providers to create meaningful commit messages from your code changes.

🌟 Features

  • Multiple AI Providers

    • OpenAI
    • Anthropic
    • Google
    • Azure OpenAI
    • Ollama
    • HuggingFace
  • Commit Message Formats

    • Conventional Commits
    • Semantic Versioning
    • Simple format
    • Angular format
  • Smart Configuration

    • Multiple provider configurations
    • Default provider setting
    • Environment variable support
    • Provider-specific defaults
    • Easy provider switching
  • Developer Experience

    • Auto-commit support
    • Response caching
    • Git hook integration
    • Cross-platform support

🚀 Installation

Using uv (Recommended)

# Install uv if you haven't already
curl -LsSf https://astral.sh/uv/install.sh | sh

# Create and activate virtual environment
uv venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install the package
uv pip install cmscribe

Using pip

pip install cmscribe

💻 Usage

Basic Usage

# Generate a commit message for staged changes
cmscribe gen

# Generate with a specific provider (overrides default)
cmscribe gen --provider openai

# Generate with a specific commit format
cmscribe gen --format conventional

# Generate and auto-commit
cmscribe gen --auto

Configuration Management

Quick Setup

# Create initial configuration with all providers
cmscribe config create

# Configure OpenAI
cmscribe config update --provider openai --api-key YOUR_API_KEY

# Configure Anthropic
cmscribe config update --provider anthropic --api-key YOUR_API_KEY

# Configure Google
cmscribe config update --provider gemini --api-key YOUR_API_KEY

# Set OpenAI as default provider
cmscribe config update --provider openai --set-default

Provider-Specific Configuration

Each provider has sensible defaults, but you can customize them:

# OpenAI with custom settings
cmscribe config update --provider openai \
    --api-key YOUR_API_KEY \
    --model gpt-4 \
    --max-tokens 100 \
    --temperature 0.8

# Ollama (local)
cmscribe config update --provider ollama \
    --model llama2 \
    --endpoint http://localhost:11434

# Ollama (remote)
cmscribe config update --provider ollama \
    --model llama2 \
    --endpoint http://your-server:11434

# Azure OpenAI
cmscribe config update --provider azure_openai \
    --api-key YOUR_API_KEY \
    --endpoint YOUR_ENDPOINT \
    --model gpt-4

Core Settings

Configure global settings that apply to all providers:

# Set default commit format
cmscribe config update --format conventional

# Enable auto-commit
cmscribe config update --auto-commit true

# Enable response caching
cmscribe config update --cache-responses true

Environment Variables

You can also use environment variables for sensitive information:

# OpenAI
export OPENAI_API_KEY="your-api-key"

# Anthropic
export ANTHROPIC_API_KEY="your-api-key"

# Google
export GOOGLE_API_KEY="your-api-key"

# Azure OpenAI
export AZURE_OPENAI_API_KEY="your-api-key"
export AZURE_OPENAI_ENDPOINT="your-endpoint"

View Configuration

View your current configuration:

cmscribe config show

🔧 Configuration File

The configuration file is located at:

  • Unix/macOS: ~/.config/cmscribe/config.ini
  • Windows: %APPDATA%\cmscribe\config.ini

Example Configuration

[Core]
provider = openai
commit_format = conventional
auto_commit = false
cache_responses = true

[openai]
model = gpt-3.5-turbo
endpoint = https://api.openai.com/v1
max_tokens = 50
temperature = 0.7
api_key = your-api-key

[anthropic]
model = claude-3-sonnet-20240229
endpoint = https://api.anthropic.com
max_tokens = 50
temperature = 0.7
api_key = your-api-key

[gemini]
model = gemini-pro
endpoint = https://generativelanguage.googleapis.com/v1
max_tokens = 50
temperature = 0.7
api_key = your-api-key

[ollama]
model = llama2
endpoint = http://localhost:11434
max_tokens = 50
temperature = 0.7
api_key = 

[huggingface]
model = mistralai/Mistral-7B-Instruct-v0.2
endpoint = https://api-inference.huggingface.co/models
max_tokens = 50
temperature = 0.7
api_key = your-api-key

🧪 Development

Running Tests

# Run all tests
uv run pytest

# Run with coverage
uv run pytest --cov=cmscribe

# Run specific test file
uv run pytest test/test_providers.py

Code Quality

# Run linter
uv run ruff check .

# Format code
uv run black .

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmscribe-0.1.0.tar.gz (67.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cmscribe-0.1.0-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file cmscribe-0.1.0.tar.gz.

File metadata

  • Download URL: cmscribe-0.1.0.tar.gz
  • Upload date:
  • Size: 67.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.4

File hashes

Hashes for cmscribe-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4188a9d6d260dc7e7b510ea1236cfdb5c0ab1e4d8d6970a8a040da499e514920
MD5 d3124051b6dcfeb9a40651dde2f43348
BLAKE2b-256 e33cb702db36e78a7e9e4bc3e440774c177afa93c1e0708406fc977e001b47dd

See more details on using hashes here.

File details

Details for the file cmscribe-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cmscribe-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 32.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.4

File hashes

Hashes for cmscribe-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1e8a414b1822f38e73f9f715ea2a5ff9250b6dcc184d64520ff8dd060269ab8
MD5 52d1d1eb6f791a595873a9a84ed2eabd
BLAKE2b-256 ec1da470eafc59b1f23207d8b49b35c9f9b6e81f3bd1b56c18b24f2204f47be5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page