Skip to content

🤖 AI-powered git commit message generator supporting multiple LLM providers (Qwen, DeepSeek). Generate meaningful commit messages from your staged changes with a beautiful CLI interface.

Notifications You must be signed in to change notification settings

SimonGino/aicommit

Repository files navigation

AI Commit

English | 简体中文

一个基于AI的Git提交消息生成工具,自动生成符合Conventional Commits规范的提交消息。

功能特点

  • 自动生成标准化的Git提交消息
  • ���持 OpenAI 和 Azure OpenAI
  • 支持自定义 API URL 和模型
  • 遵循 Conventional Commits 规范
  • 支持多语言(英文、简体中文、繁体中文)
  • 美观的命令行界面
  • 交互式提交确认
  • 支持生成日报

提交消息格式

生成的提交消息严格遵循以下格式:

<类型>(<范围>): <主题>

<正文>

<脚注>

支持的提交类型:

  • feat: 新功能
  • fix: 修复缺陷
  • refactor: 代码重构
  • docs: 文档更新
  • style: 代码格式
  • test: 测试相关
  • chore: 其他更新

安装

快速安装(推荐)

Linux/macOS

curl -fsSL https://raw.githubusercontent.com/SimonGino/aicommit/main/scripts/install.sh | sudo bash

Windows (以管理员身份运行 PowerShell)

iwr -useb https://raw.githubusercontent.com/SimonGino/aicommit/main/scripts/install.ps1 | iex

手动安装

  1. 下载最新版本的发布包:

    • 访问 Releases 页面
    • 选择适合你系统的版本下载
  2. 解压并安装:

# Linux/macOS
tar xzf aicommit_*.tar.gz
sudo mv aicommit /usr/local/bin/
chmod +x /usr/local/bin/aicommit

# Windows
# 解压zip文件,并将aicommit.exe添加到系统PATH

配置

首次使用前需要配置API设置。支持 OpenAI 和 Azure OpenAI 两种提供商。

OpenAI 配置

# 配置 OpenAI API 密钥
aicommit config --api-key your-openai-api-key-here

# 配置自定义API基础URL(可选)
aicommit config --base-url https://your-custom-api-url.com/v1

# 配置自定义模型(可选,默认为gpt-4o)
aicommit config --model gpt-4-turbo

# 设置提供商为 OpenAI(默认)
aicommit config --provider openai

配置文件示例(~/.config/aicommit/config.json):

{
  "api_key": "sk-your-openai-api-key",
  "base_url": "https://api.openai.com/v1",
  "model": "gpt-4o",
  "language": "zh-CN",
  "provider": "openai"
}

Azure OpenAI 配置

# 设置提供商为 Azure OpenAI
aicommit config --provider azure

# 配置 Azure OpenAI API 密钥
aicommit config --api-key your-azure-api-key

# 配置 Azure OpenAI 完整 endpoint URL
aicommit config --base-url "https://your-resource-name.openai.azure.com/openai/deployments/your-deployment-name/chat/completions"

# 配置 API 版本(可选,默认为 2024-02-15-preview)
aicommit config --azure-api-version "2024-02-15-preview"

# 配置模型名称(使用你的部署名称)
aicommit config --model your-deployment-name

配置文件示例(~/.config/aicommit/config.json):

{
  "api_key": "your-azure-api-key",
  "base_url": "https://your-resource-name.openai.azure.com/openai/deployments/your-deployment-name/chat/completions",
  "model": "gpt-35-turbo",
  "language": "zh-CN",
  "provider": "azure",
  "azure_api_version": "2024-02-15-preview"
}

通用配置

设置输出语言(可选):

aicommit config --language zh-CN  # 简体中文(默认)
aicommit config --language en     # 英文
aicommit config --language zh-TW  # 繁体中文

使用方法

  1. 暂存要提交的更改:
git add .  # 或指定文件
  1. 生成提交消息:
aicommit

使用自定义提交消息:

aicommit -m "feat(auth): 添加用户认证功能"

临时指定输出语言:

aicommit -l en     # 使用英文生成提交消息
aicommit -l zh-CN  # 使用简体中文生成提交消息
aicommit -l zh-TW  # 使用繁体中文生成提交消息
aicommit -l zh     # 使用简体中文生成提交消息(简写)
  1. 使用 aicommit report 生成日报

    根据你的 Git 提交历史生成工作日报。

    # 生成本周日报 (默认作者为当前 Git 配置)
    aicommit report --this-week
    
    # 生成上周日报
    aicommit report --last-week
    
    # 生成指定日期范围的日报
    aicommit report --since 2023-10-01 --until 2023-10-31
    
    # 为指定作者生成本周日报
    aicommit report --this-week --author "user@example.com"

卸载

# Linux/macOS
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/SimonGino/aicommit/main/scripts/uninstall.sh)"

# Windows (以管理员身份运行 PowerShell)
iwr -useb https://raw.githubusercontent.com/SimonGino/aicommit/main/scripts/uninstall.ps1 | iex

开发

  1. 克隆仓库:
git clone https://github.com/SimonGino/aicommit.git
cd aicommit
  1. 安装依赖:
go mod download
  1. 运行测试:
go test ./...

贡献

欢迎提交Pull Request或Issue!

许可证

MIT

About

🤖 AI-powered git commit message generator supporting multiple LLM providers (Qwen, DeepSeek). Generate meaningful commit messages from your staged changes with a beautiful CLI interface.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published