Metadata-Version: 2.5
Name: commitwise-cli
Version: 0.1.0
Summary: AI-powered git commit message generator using Groq LLM
Project-URL: Homepage, https://github.com/Md-Shamir-raza/commitwise
Project-URL: Repository, https://github.com/Md-Shamir-raza/commitwise
Project-URL: Issues, https://github.com/Md-Shamir-raza/commitwise/issues
Author: Md Shamir Raza
License-Expression: MIT
License-File: LICENSE
Keywords: ai,cli,commit,conventional-commits,developer-tools,git,groq,llm
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Version Control :: Git
Requires-Python: >=3.10
Requires-Dist: click>=8.0
Requires-Dist: groq>=0.4.0
Requires-Dist: python-dotenv>=1.0
Requires-Dist: rich>=13.0
Description-Content-Type: text/markdown

<div align="center">

# 🧠 CommitWise-CLI

**AI-powered git commit message generator**

[![PyPI version](https://img.shields.io/pypi/v/commitwise-cli?color=blue&logo=pypi&logoColor=white)](https://pypi.org/project/commitwise-cli/)
[![Python](https://img.shields.io/pypi/pyversions/commitwise-cli?logo=python&logoColor=white)](https://pypi.org/project/commitwise-cli/)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)

Stop writing generic commit messages. Let AI analyze your staged changes and suggest meaningful, [Conventional Commits](https://www.conventionalcommits.org/) compliant messages.

</div>

---

## ✨ Features

- 🔍 **Smart Analysis** — Reads your `git diff --cached` and understands what changed
- 🤖 **LLM-Powered** — Uses Groq's blazing-fast Llama 3 70B for high-quality suggestions
- 📝 **Conventional Commits** — Auto-prefixes with `feat:`, `fix:`, `refactor:`, etc.
- 🎨 **Beautiful CLI** — Rich terminal output with colors and formatting
- ⚡ **One Command** — Run `commitwise`, pick a message, done
- 🔒 **Privacy-First** — Only staged diffs are sent; nothing leaves your machine otherwise

## 📦 Installation

```bash
pip install commitwise-cli
```

Or install from source:

```bash
git clone https://github.com/Md-Shamir-raza/commitwise.git
cd commitwise
pip install -e .
```

## 🔑 Setup

You need a free [Groq API key](https://console.groq.com/keys).

**Option 1: Environment variable**

```bash
export GROQ_API_KEY=your_api_key_here
```

**Option 2: `.env` file**

Create a `.env` file in your project root:

```env
GROQ_API_KEY=your_api_key_here
```

## 🚀 Usage

```bash
# Stage your changes
git add .

# Generate AI commit messages
commitwise
```

### What happens:

1. CommitWise reads your staged changes via `git diff --cached`
2. Sends the diff to Groq (Llama 3 70B) for analysis
3. Displays **3 commit message suggestions** in Conventional Commits format
4. You pick one (1/2/3) or type your own custom message
5. The commit is automatically applied

## 🎬 Demo

<div align="center">

![CommitWise Demo](assets/demo.png)

</div>

## 📖 Example

```
🧠 CommitWise  v0.1.0

⠋ Analyzing changes…

╭─ ✦ Suggested Commit Messages ────────────────────────╮
│                                                       │
│  1. feat: add user authentication middleware          │
│  2. feat: implement JWT token validation for routes   │
│  3. chore: add auth dependencies to requirements      │
│                                                       │
╰───────────────────────────────────────────────────────╯

Enter 1, 2, or 3 to pick a suggestion, or type your own message.

❯ 1

✓ Committed: feat: add user authentication middleware
```

## ⚙️ How It Works

```
┌─────────────┐     ┌──────────────┐     ┌───────────┐     ┌────────────┐
│  git add .   │ ──▶ │  commitwise  │ ──▶ │  Groq API │ ──▶ │ git commit │
│  (you stage) │     │  (reads diff)│     │ (Llama 3) │     │  (applied) │
└─────────────┘     └──────────────┘     └───────────┘     └────────────┘
```

## 🛡️ Edge Cases Handled

| Scenario | Behavior |
|---|---|
| No staged changes | Prints warning and exits gracefully |
| Diff too large (>8000 tokens) | Truncates with a notice |
| API key missing | Clear error with setup instructions |
| LLM returns invalid JSON | Retries once, then falls back to raw output |
| Git not installed | Prints error and exits |

## 🏗️ Project Structure

```
commitwise/
├── commitwise/
│   ├── __init__.py          # Package metadata
│   ├── cli.py               # Click CLI entry point
│   ├── git_utils.py         # Git subprocess wrappers
│   ├── llm.py               # Groq API integration
│   └── prompt_templates.py  # LLM prompt definitions
├── .env.example             # API key template
├── pyproject.toml           # PyPI packaging config
├── README.md
└── LICENSE
```

## 🤝 Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

```bash
# Clone the repo
git clone https://github.com/Md-Shamir-raza/commitwise.git
cd commitwise

# Install in development mode
pip install -e .

# Run locally
commitwise
```

## 📄 License

This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.

---

<div align="center">

Made with ❤️ by [Md Shamir Raza](https://github.com/Md-Shamir-raza)

</div>
