Initial upload with CI/CD workflow
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-04 17:54:24 +00:00
parent 24a02f50af
commit 52fae68b23

197
app/README.md Normal file
View File

@@ -0,0 +1,197 @@
# Git Commit Message Generator CLI
A CLI tool that generates git commit messages and conventional changelogs from staged/unstaged diffs using local LLMs (Ollama, llama.cpp). Features privacy-first operation with no external API calls, supports conventional commits format, includes interactive mode for message refinement, auto-detects change types, and can generate CHANGELOG.md from git history.
## Features
- **Privacy-First**: All processing happens locally using Ollama - no external API calls
- **Conventional Commits**: Generates messages following the conventional commits format
- **Interactive Mode**: Refine and edit messages before committing
- **Auto-Detection**: Automatically detects change types (feat, fix, docs, etc.)
- **Scope Detection**: Identifies affected areas from file paths
- **Changelog Generation**: Creates CHANGELOG.md from git history
- **Flexible Configuration**: Supports environment variables and config files
## Installation
```bash
pip install git-commit-message-generator
```
Or from source:
```bash
pip install -e .
```
## Prerequisites
- Python 3.9+
- [Ollama](https://ollama.ai/) running locally
- A supported model (llama3, codellama, etc.)
Install Ollama and pull a model:
```bash
# Install Ollama from https://ollama.ai
ollama serve
ollama pull llama3
```
## Usage
### Generate Commit Message
Generate a commit message from staged changes:
```bash
git-commit-gen generate
```
Generate from unstaged changes:
```bash
git-commit-gen generate --unstaged
```
Use interactive mode for message refinement:
```bash
git-commit-gen generate --interactive
```
Specify a different model:
```bash
git-commit-gen generate --model codellama
```
Write message to file:
```bash
git-commit-gen generate -o commit-message.txt
```
### Generate Changelog
Generate a changelog from git history:
```bash
git-commit-gen changelog
```
Generate with a limit on commits:
```bash
git-commit-gen changelog --limit 100
```
Generate simple changelog (without LLM):
```bash
git-commit-gen changelog --simple
```
Write to file:
```bash
git-commit-gen changelog -o CHANGELOG.md
```
### Check Status
Check system status and configuration:
```bash
git-commit-gen status
```
### Configure Settings
Show current configuration:
```bash
git-commit-gen config --show
```
Set default model:
```bash
git-commit-gen config --model llama3
```
## Configuration
### Environment Variables
| Variable | Description | Default |
|----------|-------------|---------|
| `OLLAMA_HOST` | Ollama server URL | `http://localhost:11434` |
| `OLLAMA_MODEL` | Default model to use | `llama3` |
| `GIT_COMMIT_GENERATOR_CONFIG` | Path to config file | - |
### Config File
Create a `config.yaml` file:
```yaml
ollama_host: http://localhost:11434
ollama_model: llama3
```
## Prompt Templates
Customize generation prompts by creating files in the prompts directory:
- `prompts/commit_message.txt` - Template for commit message generation
- `prompts/changelog.txt` - Template for changelog generation
## Error Handling
| Error | Solution |
|-------|----------|
| Ollama connection failed | Check if Ollama is running, verify host URL |
| No staged changes | Stage with `git add` or use `--unstaged` |
| Invalid format | Regenerate or manually edit |
| Git repo not found | Run from within a git repository |
| Model not found | Pull with `ollama pull <model_name>` |
## Development
### Running Tests
```bash
pytest tests/ -v --cov=src --cov-report=term-missing
```
### Project Structure
```
git-commit-message-generator/
├── src/git_commit_generator/
│ ├── __init__.py
│ ├── __main__.py # Entry point
│ ├── cli.py # CLI interface
│ ├── config.py # Configuration management
│ ├── git_utils.py # Git operations
│ ├── ollama_client.py # Ollama integration
│ ├── message_generator.py # Commit message generation
│ ├── changelog_generator.py # Changelog generation
│ └── interactive.py # Interactive mode
├── prompts/
│ ├── commit_message.txt
│ └── changelog.txt
├── tests/
│ ├── test_cli.py
│ ├── test_git_utils.py
│ ├── test_message_generator.py
│ ├── test_changelog_generator.py
│ └── conftest.py
├── pyproject.toml
├── requirements.txt
└── README.md
```
## License
MIT