# QuiCommit

English | [中文文档](README_zh.md)

A powerful AI-powered Git assistant for generating conventional commits, tags, and changelogs. Manage multiple Git profiles for different work contexts.

![Rust](https://img.shields.io/badge/rust-%23000000.svg?style=for-the-badge&logo=rust&logoColor=white)
![License](https://img.shields.io/badge/license-MIT-blue.svg)

## Features

- **AI-Powered Generation**: Generate commits, tags, and changelogs using LLM APIs (Ollama, OpenAI, Anthropic, Kimi, DeepSeek, OpenRouter) or local models
- **Conventional Commits**: Full support for Conventional Commits and commitlint formats
- **Profile Management**: Manage multiple Git identities with SSH keys and GPG signing support
- **Smart Tagging**: Semantic version bumping with AI-generated release notes
- **Changelog Generation**: Automatic changelog generation in Keep a Changelog format
- **Security**: Encrypt sensitive data
- **Interactive UI**: Beautiful CLI with previews and confirmations

## Installation

```bash
git clone https://github.com/yourusername/quicommit.git
cd quicommit
cargo build --release
cargo install --path .
```

Requirements: Rust 1.70+, Git 2.0+

## Quick Start

### Initialize

```bash
quicommit init
```

### Generate Commit

```bash
# AI-generated commit (default)
quicommit commit

# Manual commit
quicommit commit --manual -t feat -m "add new feature"

# Stage all and commit
quicommit commit -a

# Skip confirmation
quicommit commit --yes
```

### Create Tag

```bash
# Auto-detect version bump
quicommit tag

# Specify bump type
quicommit tag --bump minor

# Custom tag name
quicommit tag -n v1.0.0
```

### Generate Changelog

```bash
# Generate for unreleased changes
quicommit changelog

# Generate for specific version
quicommit changelog -v 1.0.0
```

### Manage Profiles

```bash
# Add new profile
quicommit profile add

# List profiles
quicommit profile list

# Switch profile
quicommit profile switch

# Set profile for current repo
quicommit profile set-repo personal
```

### Configure LLM

```bash
# Configure Ollama (local)
quicommit config set-llm ollama
quicommit config set-ollama --url http://localhost:11434 --model llama2

# Configure OpenAI
quicommit config set-llm openai
quicommit config set-openai-key YOUR_API_KEY

# Configure Anthropic Claude
quicommit config set-llm anthropic
quicommit config set-anthropic-key YOUR_API_KEY

# Configure Kimi (Moonshot AI)
quicommit config set-llm kimi
quicommit config set-kimi-key YOUR_API_KEY

# Configure DeepSeek
quicommit config set-llm deepseek
quicommit config set-deepseek-key YOUR_API_KEY

# Configure OpenRouter
quicommit config set-llm openrouter
quicommit config set-openrouter-key YOUR_API_KEY

# Test LLM connection
quicommit config test-llm
```

## Command Reference

| Command | Alias | Description |
|---------|-------|-------------|
| `quicommit init` | `i` | Initialize configuration |
| `quicommit commit` | `c` | Generate and create commit |
| `quicommit tag` | `t` | Generate and create tag |
| `quicommit changelog` | `cl` | Generate changelog |
| `quicommit profile` | `p` | Manage Git profiles |
| `quicommit config` | `cfg` | Manage settings |

### Commit Options

| Option | Description |
|--------|-------------|
| `-t, --commit-type` | Commit type (feat, fix, etc.) |
| `-s, --scope` | Commit scope |
| `-m, --message` | Commit description |
| `--body` | Commit body |
| `--breaking` | Mark as breaking change |
| `--manual` | Manual input, skip AI |
| `-a, --all` | Stage all changes |
| `-S, --sign` | GPG sign commit |
| `--amend` | Amend previous commit |
| `--dry-run` | Show without committing |
| `-y, --yes` | Skip confirmation |

### Tag Options

| Option | Description |
|--------|-------------|
| `-n, --name` | Tag name |
| `-b, --bump` | Version bump (major/minor/patch) |
| `-m, --message` | Tag message |
| `-g, --generate` | AI-generate message |
| `-S, --sign` | GPG sign tag |
| `--lightweight` | Create lightweight tag |
| `--push` | Push to remote |
| `-y, --yes` | Skip confirmation |

## Configuration File

Location:
- Linux/macOS: `~/.config/quicommit/config.toml`
- Windows: `%APPDATA%\quicommit\config.toml`

```toml
version = "1"
default_profile = "personal"

[profiles.personal]
name = "personal"
user_name = "John Doe"
user_email = "john@example.com"

[profiles.work]
name = "work"
user_name = "John Doe"
user_email = "john@company.com"
is_work = true
organization = "Acme Corp"

[llm]
provider = "ollama"
max_tokens = 500
temperature = 0.7
timeout = 30

[llm.ollama]
url = "http://localhost:11434"
model = "llama2"

[llm.openai]
model = "gpt-4"
base_url = "https://api.openai.com/v1"

[commit]
format = "conventional"
auto_generate = true
max_subject_length = 100

[tag]
version_prefix = "v"
auto_generate = true

[changelog]
path = "CHANGELOG.md"
auto_generate = true
group_by_type = true
```

## Environment Variables

| Variable | Description |
|----------|-------------|
| `QUICOMMIT_CONFIG` | Configuration file path |
| `EDITOR` | Default editor |
| `NO_COLOR` | Disable colored output |

## Troubleshooting

```bash
# View current configuration
quicommit config list

# Test LLM connection
quicommit config test-llm

# List available models
quicommit config list-models

# Edit configuration
quicommit config edit
```

## Contributing

Contributions are welcome! Please follow these steps:

### Submit a Pull Request

1. Fork the repository
2. Create a feature branch: `git checkout -b feature/your-feature`
3. Commit changes: `git commit -m 'feat: add new feature'`
4. Push branch: `git push origin feature/your-feature`
5. Open a Pull Request

### Development Setup

```bash
# Clone repository
git clone https://github.com/YOUR_USERNAME/quicommit.git
cd quicommit

# Fetch dependencies
cargo fetch

# Run in development mode
cargo run -- commit --help

# Run tests
cargo test

# Code quality checks
cargo clippy
cargo fmt --check
```

### Code Standards

- Follow Rust formatting (run `cargo fmt`)
- Use Conventional Commits for commit messages
- Add tests for new features
- Ensure `cargo clippy` passes with no warnings

### Project Structure

```
src/
├── commands/    # CLI command implementations
├── config/      # Configuration management
├── generator/   # AI content generation
├── git/         # Git operations
├── llm/         # LLM provider implementations
└── utils/       # Utility functions
```

## License

MIT License

## Acknowledgments

- [Conventional Commits](https://www.conventionalcommits.org/) specification
- [Keep a Changelog](https://keepachangelog.com/) format
- [Ollama](https://ollama.ai/) for local LLM support
