Metadata-Version: 2.4
Name: commitcraft-cli
Version: 0.1.0
Summary: Smart conventional commit messages with a rule engine + minimal-context LLM
License: MIT
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: anthropic>=0.30.0
Requires-Dist: google-generativeai>=0.7.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: openai>=1.0.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: pyyaml>=6.0.0
Requires-Dist: rich>=13.0.0
Requires-Dist: typer>=0.12.0
Provides-Extra: dev
Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.4.0; extra == 'dev'
Description-Content-Type: text/markdown

# commitcraft

> Smart conventional commit messages — a rule engine decides when AI is even needed.

[![CI](https://github.com/mavsensei/commitcraft/actions/workflows/ci.yml/badge.svg)](https://github.com/mavesensei/commitcraft/actions)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

## What makes it different

Most "AI commit message" tools blindly send your entire diff to an LLM. commitcraft doesn't.

It first runs a **local rule engine** on your diff. README-only change? Lockfile bump? Single test file? Those get a conventional commit message generated instantly, locally, with zero AI cost. Only when changes are genuinely complex does it reach out to an LLM — and even then it sends a condensed summary, not the full diff.

**The story isn't "I used AI." It's "I built a system that decides when AI should be used."**

## Pipeline

```
git diff (staged)
    │
    ▼
Parser → extract changed files, line counts, file types
    │
    ▼
Filter → strip lockfiles, dist/, build/, *.min.js, etc.
    │
    ▼
Rule Engine → simple change? generate commit locally (zero cost)
    │              e.g. README-only → "docs: update README"
    │              lockfile-only → "chore: update lockfile"
    │
    ▼ (complex change only)
Classifier → complexity score 0-100 from:
             • file count and directory spread
             • function/class definition changes (regex)
             • test files alongside source files
             • total line count
    │
    ▼
Context Builder → condensed summary (not the full diff)
    │              ~100-500 tokens instead of thousands
    ▼
Your chosen Provider (Ollama / OpenAI / Gemini / Anthropic)
    │
    ▼
Conventional commit message
```

## Installation

```bash
pip install commitcraft
commitcraft init   # one-time setup: choose your provider
```

## Quickstart

```bash
# Make some changes, then:
commitcraft commit

# Generate a PR description for the current branch:
commitcraft pr

# Generate release notes between two tags:
commitcraft release-notes v1.0.0..v1.1.0

# Analyze your commit history:
commitcraft history
```

## Provider setup

On first run (`commitcraft init`), you choose your provider:

| Provider | Cost | Requires |
|---|---|---|
| **Ollama** | Free (local) | Ollama installed + a model pulled |
| **OpenAI** | Your API key | `openai_api_key` in config |
| **Anthropic Claude** | Your API key | `anthropic_api_key` in config |
| **Google Gemini** | Your API key | `gemini_api_key` in config |

Your API key is stored locally at `~/.commitcraft/config.yaml`. It never leaves your machine except to call your chosen provider directly.

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) and [docs/adding_a_provider.md](docs/adding_a_provider.md).

## License

MIT © mavesensei

