Skip to main content

基于AI的Git提交消息生成工具,提供智能分析和规范化的提交消息

Project description

Git AI Commit - 智能提交助手

🤖 基于AI的Git提交消息生成工具,让代码提交更智能、更规范

PyPI version Python 3.12+ License: MIT alt text

📖 项目介绍

Git AI Commit 是一个现代化的Git提交助手,结合了AI技术和直观的图形界面,帮助开发者:

  • 📊 智能分析:自动分析Git变更内容,生成结构化报告
  • 🤖 AI生成:使用GLM-4-Flash模型生成规范的提交消息
  • 🖥️ 图形界面:提供友好的GUI界面,操作简单直观
  • ⚙️ 灵活配置:支持自定义API配置和个性化设置

✨ 功能特性

核心功能

  • 🔍 Git变更分析:深度分析代码变更,识别修改、新增、删除的文件
  • 📝 智能提交消息:基于变更内容生成符合规范的提交消息
  • 🎯 一键提交:分析、生成、提交一站式完成
  • 💾 配置管理:持久化保存API配置和用户偏好

界面特性

  • 🎨 现代化UI:基于PySide6的原生界面,响应迅速
  • 📱 紧凑设计:优化的窗口布局,节省屏幕空间
  • 🔄 异步处理:多线程处理,避免界面卡顿
  • 💡 智能提示:实时状态反馈和操作指导

🚀 快速开始

🎯 一键启动 (最简单)

# 方式1:使用uv直接安装并运行 (推荐)
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install git-ai-commit-gui
git-ai-commit-gui

# 方式2:使用uv临时运行
uv run --from git-ai-commit-gui git-ai-commit-gui

系统要求

  • Python 3.12+
  • Git (已安装并配置)
  • 网络连接 (用于AI API调用)

安装方法

🚀 使用 uv (推荐)

方式1:全局安装 (推荐)

# 1. 安装 uv (如果尚未安装)
curl -LsSf https://astral.sh/uv/install.sh | sh

# 2. 安装工具
uv tool install git-ai-commit-gui

# 3. 直接使用
git-ai-commit-gui

方式2:临时运行

# 安装uv并临时运行
curl -LsSf https://astral.sh/uv/install.sh | sh
uv run --from git-ai-commit-gui git-ai-commit-gui

方式3:从源码运行

# 1. 克隆项目
git clone https://github.com/duolabmeng6/ai_git_commit_gui.git
cd ai_git_commit_gui

# 2. 安装依赖并运行
uv sync
uv run git-ai-commit-gui

📦 使用 pip

# 安装
pip install git-ai-commit-gui

# 运行
git-ai-commit-gui

🛠️ 开发者安装

# 1. 克隆项目
git clone https://github.com/duolabmeng6/ai_git_commit_gui.git
cd ai_git_commit_gui

# 2. 创建虚拟环境
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# 3. 安装依赖
pip install -e .

# 4. 启动应用
python gui_main.py

📋 使用指南

首次配置

  1. 启动应用

    # 如果已全局安装
    git-ai-commit-gui
    
    # 或者使用uv临时运行
    uv run --from git-ai-commit-gui git-ai-commit-gui
    
  2. 配置API设置

    • 切换到"设置"标签页
    • 输入API URL:https://api.kenhong.com/v1
    • 输入API密钥
    • 设置模型名称:glm-4-flash
    • 点击"保存设置"
  3. 选择Git仓库

    • 在"仓库路径"中输入或浏览选择Git仓库
    • 应用会自动验证仓库有效性

基本工作流程

  1. 查看变更:点击"查看变更信息"按钮,分析当前仓库的未提交变更
  2. AI分析:点击"AI总结变更"按钮,生成智能提交消息
  3. 执行提交:确认提交消息后,点击"Git Commit"完成提交

命令行使用

# 分析指定仓库的变更
uv run python git_diff_analyzer.py /path/to/repo 200

# 启动GUI并指定仓库路径
uv run git-ai-commit /path/to/repo

# 使用当前目录
uv run git-ai-commit ./

# 直接启动GUI(会使用当前目录)
uv run python gui_main.py

使用示例

场景1:分析当前项目变更

cd /your/project/directory
git-ai-commit-gui ./

场景2:快速查看变更内容

# 如果全局安装了
git-ai-commit-gui

# 或者使用uv临时运行
uv run --from git-ai-commit-gui git-ai-commit-gui

场景3:AI生成提交消息

  1. 在GUI中点击"查看变更信息"
  2. 查看分析结果
  3. 点击"AI总结变更"
  4. 确认生成的提交消息
  5. 点击"Git Commit"完成提交

⚙️ 配置说明

API配置

  • API URL:AI服务的API端点地址
  • API Key:访问AI服务的密钥
  • 模型名称:使用的AI模型,默认为 glm-4-flash

高级设置

配置文件位置:~/.git_ai_commit/config.json

{
  "api": {
    "url": "https://api.kenhong.com/v1",
    "api_key": "your-api-key",
    "model": "glm-4-flash"
  },
  "ui": {
    "window_width": 400,
    "window_height": 550,
    "last_repo_path": ""
  },
  "git": {
    "max_diff_lines": 200,
    "auto_stage": false
  }
}

🛠️ 开发指南

项目结构

git_ai_commit/
├── gui_main.py          # GUI主界面
├── git_diff_analyzer.py # Git变更分析器
├── ai_interface.py      # AI接口模块
├── config.py           # 配置管理
├── utils.py            # 工具函数
├── pyproject.toml      # 项目配置
└── README.md           # 项目文档

开发环境设置

# 使用 uv 创建开发环境
uv sync --dev

# 运行测试
uv run python -m pytest

# 代码格式化
uv run black .
uv run isort .

❓ 常见问题

Q: 如何获取API密钥?

A: 请联系API服务提供商获取有效的API密钥。确保密钥有足够的权限访问GLM-4-Flash模型。

Q: 应用启动失败怎么办?

A: 请检查:

  • Python版本是否为3.12+
  • 是否正确安装了依赖:uv sync
  • 是否在Git仓库目录中运行

Q: AI分析失败怎么办?

A: 请检查:

  • API密钥是否正确配置
  • 网络连接是否正常
  • API服务是否可用

Q: 支持哪些Git操作?

A: 目前支持:

  • 查看未提交的变更
  • 生成提交消息
  • 执行git add和git commit
  • 不支持push操作(需手动执行)

🔧 故障排除

依赖安装问题

# 清理并重新安装
rm -rf .venv
uv sync

# 或使用传统方式
pip install --upgrade pip
pip install -e .

GUI界面问题

  • 确保系统支持Qt6
  • 在Linux上可能需要安装额外的系统包:
    # Ubuntu/Debian
    sudo apt-get install python3-pyside6
    
    # CentOS/RHEL
    sudo yum install python3-pyside6
    

配置文件问题

如果配置出现问题,可以删除配置文件重新开始:

rm -rf ~/.git_ai_commit/config.json

📄 许可证

本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📞 联系方式

如有问题或建议,请通过以下方式联系:


⭐ 如果这个项目对你有帮助,请给它一个星标!

打赏

alt text

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

git_ai_commit_gui-0.1.1.tar.gz (521.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

git_ai_commit_gui-0.1.1-py3-none-any.whl (531.4 kB view details)

Uploaded Python 3

File details

Details for the file git_ai_commit_gui-0.1.1.tar.gz.

File metadata

  • Download URL: git_ai_commit_gui-0.1.1.tar.gz
  • Upload date:
  • Size: 521.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for git_ai_commit_gui-0.1.1.tar.gz
Algorithm Hash digest
SHA256 575f49806b7572fffd05d60f201c7874ff2eb53ccbb0ded8bb6ed4240c3660e9
MD5 5087d8e7df0be07cd18db31285389690
BLAKE2b-256 da313a6c26565f19e3ed2f8a88f02b749d8d11c9fa7ebf6e65a64ef93697fe83

See more details on using hashes here.

File details

Details for the file git_ai_commit_gui-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for git_ai_commit_gui-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1807ff2e5e502a967fad34c222047ad555fd6ca45eaf0339e25740c1b58a4a2e
MD5 e183e7afb9b278869240411f2c37e32a
BLAKE2b-256 e212c820c6e4e81973d3f0bb391098ce8b23736b067de567ced2ff1d1b3e434b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page