gcop-rs 0.1.4

AI-powered Git commit message generator and code reviewer
Documentation
gcop-rs-0.1.4 has been yanked.

gcop-rs

License: MIT Crates.io Downloads CI

AI-powered Git commit message generator and code reviewer, written in Rust.

Note: This is a Rust rewrite of the original gcop project (Python). Since the original project is no longer actively maintained, this version was created to provide better performance, reliability, and maintainability.

中文文档 | Documentation

Features

  • 🤖 AI Commit Messages - Generate conventional commit messages using Claude, OpenAI, or Ollama
  • 🔍 Code Review - Get AI-powered code reviews with security and performance insights
  • 🎯 Git Aliases - Convenient shortcuts like git c, git r, git acp for streamlined workflow
  • 🚀 Easy Setup - Interactive init command for quick configuration
  • 🔧 Custom Providers - Support any OpenAI/Claude compatible API (DeepSeek, custom endpoints, etc.)
  • 📝 Custom Prompts - Customize generation and review prompts with template variables
  • ⚙️ Flexible Config - Configure via file or environment variables
  • 🎨 Beautiful CLI - Spinner animations, colored output, and interactive prompts
  • 🐛 Debug Mode - Verbose logging with full request/response inspection
  • 🔐 GPG Signing - Full support for GPG commit signing via native git

Quick Start

1. Installation

# Clone and build
git clone https://github.com/your-repo/gcop-rs.git
cd gcop-rs
cargo build --release

# Copy to PATH
sudo cp target/release/gcop-rs /usr/local/bin/gcop-rs

See docs/installation.md for more options.

2. Configure

Option 1: Quick setup (recommended)

gcop-rs init

This interactive wizard will:

  • Create config directory and file
  • Set secure file permissions (chmod 600)
  • Optionally install convenient git aliases

Option 2: Manual setup

Create ~/.config/gcop/config.toml:

[llm]
default_provider = "claude"

[llm.providers.claude]
api_key = "sk-ant-your-key-here"
model = "claude-sonnet-4-5-20250929"

Or use environment variables:

export ANTHROPIC_API_KEY="sk-ant-your-key"

See docs/configuration.md for all options.

3. Use

# Generate commit message
git add .
gcop-rs commit
# Or use the alias: git c

# Review uncommitted changes
gcop-rs review
# Or use the alias: git r

# Complete workflow
git acp  # Add all, commit with AI, and push

# Use different provider
gcop-rs --provider openai commit

Git Aliases

gcop-rs provides convenient git aliases for streamlined workflow.

Installation

# Install all aliases
gcop-rs alias

# Or during initial setup
gcop-rs init  # Will prompt to install aliases

Usage

After installation, you can use these shortcuts:

git c          # AI commit message and commit
git r          # AI review uncommitted changes
git ac         # Add all changes and commit with AI
git acp        # Add all, commit with AI, and push
git gconfig    # Edit gcop-rs configuration
git p          # Push to remote
git pf         # Force push (safer with --force-with-lease)
git undo       # Undo last commit (keep changes staged)

Management

# List all available aliases
gcop-rs alias --list

# Reinstall (overwrite conflicts)
gcop-rs alias --force

# Remove all gcop-rs aliases
gcop-rs alias --remove --force

See docs/aliases.md for detailed information on each alias.

Commands

gcop-rs init

Initialize gcop-rs configuration.

gcop-rs init

Interactive setup wizard that:

  • Creates config directory
  • Copies example configuration
  • Sets secure file permissions
  • Optionally installs git aliases

gcop-rs commit

Generate AI-powered commit message for staged changes.

gcop-rs commit              # Generate, review, and commit
gcop-rs commit --no-edit    # Skip editor
gcop-rs commit --yes        # Skip confirmation
gcop-rs -v commit           # Verbose mode

Interactive workflow:

After generating a commit message, you can choose:

  • Accept - Use the generated message
  • Edit - Open editor to manually modify (returns to menu after editing)
  • Retry - Regenerate without feedback
  • Retry with feedback - Provide custom instructions (e.g., "use Chinese", "be more concise"). Feedback accumulates across retries for refined results
  • Quit - Cancel commit

Example:

$ git add .
$ gcop-rs commit

 Generated commit message:
feat(auth): implement JWT token validation

Choose next action:
> Accept
  Edit
  Retry
  Retry with feedback
  Quit

gcop-rs review

Review code changes with AI.

gcop-rs review                   # Review uncommitted changes
gcop-rs review --commit <hash>   # Review a commit
gcop-rs review --range main..dev # Review commit range
gcop-rs review --file src/main.rs # Review a file

Output formats: --format text|json|markdown


gcop-rs config

Manage configuration.

# Edit config file in your default editor (with validation)
gcop-rs config edit

# Validate configuration and test provider connection
gcop-rs config validate

# Show current configuration
gcop-rs config show

config edit validates your config after saving (like visudo) and works even when config is corrupted.

Tip: Always use gcop-rs config edit instead of editing the config file directly to avoid syntax errors.


gcop-rs alias

Manage git aliases.

gcop-rs alias                       # Install all aliases
gcop-rs alias --list                # List available aliases
gcop-rs alias --force               # Overwrite conflicts
gcop-rs alias --remove --force      # Remove all aliases

Provides convenient shortcuts like git c, git r, git acp, etc.

See docs/aliases.md for details.

Configuration

Config file location: ~/.config/gcop/config.toml

Example configuration with Claude API:

[llm]
default_provider = "claude"

[llm.providers.claude]
api_key = "sk-ant-your-key"
model = "claude-sonnet-4-5-20250929"
temperature = 0.3

[commit]
show_diff_preview = true
allow_edit = true

[review]
min_severity = "info"

[ui]
colored = true

For complete configuration reference, see docs/configuration.md.

Advanced Features

Custom Providers

Add any OpenAI or Claude compatible API:

[llm.providers.deepseek]
api_style = "openai"
api_key = "sk-your-deepseek-key"
endpoint = "https://api.deepseek.com/v1/chat/completions"
model = "deepseek-chat"

See docs/providers.md for more examples.

Custom Prompts

Customize commit message or review prompts:

[commit]
custom_prompt = """
Generate a commit message in Chinese for:
{diff}

Files: {files_changed}
Stats: +{insertions} -{deletions}
"""

See docs/prompts.md for template variables and examples.

Debug Mode

Use --verbose to see detailed logs:

gcop-rs -v commit  # Shows API requests, responses, and prompts

Documentation

Requirements

  • Rust 1.70 or higher
  • Git
  • API key for at least one provider (Claude, OpenAI, or local Ollama)

License

MIT License - see LICENSE file for details.

Author

AptS:1547 (Yuhan Bian / 卞雨涵) apts-1547@esaps.net


Tip: Run gcop-rs --help to see all commands, or use git c after installing aliases for quick commits!