Files
QuiCommit/readme_zh.md

6.2 KiB
Raw Blame History

QuiCommit

English | 简体中文

一款强大的AI驱动的Git助手用于生成规范化的提交信息、标签和变更日志并支持管理多个Git配置。

Rust LICENSE

主要功能

  • AI智能生成使用LLM APIOllama本地、OpenAI、Anthropic Claude、Kimi、DeepSeek、OpenRouter生成提交信息、标签和变更日志
  • 规范化提交支持Conventional Commits和commitlint格式规范
  • 多配置管理为不同场景管理多个Git身份支持SSH密钥和GPG签名配置
  • 智能标签管理基于语义版本自动检测升级AI生成标签信息
  • 变更日志生成自动生成Keep a Changelog格式的变更日志
  • 安全保护:加密存储敏感数据
  • 交互式界面美观的CLI界面支持预览和确认

安装

目前,整体工具还在开发,并不保证各项功能准确达到既定目标。但依然十分欢迎参与贡献、反馈问题和建议。

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

要求Rust 1.70+、Git 2.0+

快速开始

初始化配置

quicommit init

生成提交信息

# AI生成提交信息默认
quicommit commit

# 手动提交
quicommit commit --manual -t feat -m "添加新功能"

# 暂存所有文件并提交
quicommit commit -a

# 跳过确认直接提交
quicommit commit --yes

创建标签

# 自动检测版本升级
quicommit tag

# 指定版本升级类型
quicommit tag --bump minor

# 自定义标签名
quicommit tag -n v1.0.0

生成变更日志

# 生成未发布变更的变更日志
quicommit changelog

# 为特定版本生成
quicommit changelog -v 1.0.0

配置管理

# 添加新配置
quicommit profile add

# 查看配置列表
quicommit profile list

# 切换配置
quicommit profile switch

# 设置当前仓库的配置
quicommit profile set-repo personal

LLM配置

# 配置Ollama本地
quicommit config set-llm ollama
quicommit config set-ollama --url http://localhost:11434 --model llama2

# 配置OpenAI
quicommit config set-llm openai
quicommit config set-openai-key YOUR_API_KEY

# 配置Anthropic Claude
quicommit config set-llm anthropic
quicommit config set-anthropic-key YOUR_API_KEY

# 配置Kimi
quicommit config set-llm kimi
quicommit config set-kimi-key YOUR_API_KEY

# 配置DeepSeek
quicommit config set-llm deepseek
quicommit config set-deepseek-key YOUR_API_KEY

# 配置OpenRouter
quicommit config set-llm openrouter
quicommit config set-openrouter-key YOUR_API_KEY

# 测试LLM连接
quicommit config test-llm

命令参考

命令 别名 说明
quicommit init i 初始化配置
quicommit commit c 生成并执行提交
quicommit tag t 生成并创建标签
quicommit changelog cl 生成变更日志
quicommit profile p 管理Git配置
quicommit config cfg 管理应用配置

commit命令选项

选项 说明
-t, --commit-type 提交类型feat、fix等
-s, --scope 提交范围
-m, --message 提交描述
--body 提交正文
--breaking 标记为破坏性变更
--manual 手动输入跳过AI生成
-a, --all 暂存所有更改
-S, --sign GPG签名提交
--amend 修改上一次提交
--dry-run 试运行,不实际提交
-y, --yes 跳过确认提示

tag命令选项

选项 说明
-n, --name 标签名称
-b, --bump 版本升级类型major/minor/patch
-m, --message 标签信息
-g, --generate AI生成标签信息
-S, --sign GPG签名标签
--lightweight 创建轻量标签
--push 推送到远程
-y, --yes 跳过确认提示

配置文件

配置文件位置:

  • Linux/macOS: ~/.config/quicommit/config.toml
  • Windows: %APPDATA%\quicommit\config.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

环境变量

变量名 说明
QUICOMMIT_CONFIG 配置文件路径
EDITOR 默认编辑器
NO_COLOR 禁用彩色输出

故障排除

# 查看当前配置
quicommit config list

# 测试LLM连接
quicommit config test-llm

# 列出可用模型
quicommit config list-models

# 编辑配置文件
quicommit config edit

贡献

欢迎贡献代码!请遵循以下步骤:

提交Pull Request

  1. Fork本仓库
  2. 创建功能分支:git checkout -b feature/your-feature
  3. 提交变更:git commit -m 'feat: 添加新功能'
  4. 推送分支:git push origin feature/your-feature
  5. 提交Pull Request

开发环境

# 克隆仓库
git clone https://github.com/YOUR_USERNAME/quicommit.git
cd quicommit

# 安装依赖
cargo fetch

# 开发模式运行
cargo run -- commit --help

# 运行测试
cargo test

# 代码检查
cargo clippy
cargo fmt --check

代码规范

  • 遵循Rust官方代码风格运行 cargo fmt
  • 提交信息使用Conventional Commits格式
  • 新增功能应添加测试
  • 运行 cargo clippy 确保无警告

项目结构

src/
├── commands/    # CLI命令实现
├── config/      # 配置管理
├── generator/   # AI内容生成
├── git/         # Git操作封装
├── llm/         # LLM提供商实现
└── utils/       # 工具函数

许可证

MIT License