ai-commit-pro
v0.4.0
Published
AI-powered Git workflow assistant — commit, PR, changelog, release
Maintainers
Readme
🦾 AI Commit Pro
不只是"又一个 AI commit 工具"——而是 Git 工作流的 AI 增强层。覆盖从 commit 到 release 的完整文档链。
✨ 功能
- 🤖 AI Commit — 从 staged diff 生成 Conventional Commit message
- 📋 AI PR — 从分支 diff 生成 PR 标题 + 正文
- 📝 AI Changelog — 从 commit 历史生成结构化 CHANGELOG.md
- 🚀 AI Release — 生成 GitHub Release Notes
- 🇨🇳 国内模型优先 — DeepSeek / 通义千问 / 智谱 GLM / Kimi / 硅基流动
- 🎨 模板可定制 — Handlebars 模板,团队可统一 prompt 风格
- 🔍 Provider 自动检测 — 配置好 API Key,自动识别用哪个平台
- 💰 成本透明 — 每次调用显示 token 消耗和费用
📸 演示
$ git add src/
$ ai-commit --lang zh
✔ Found staged changes on branch feat/dark-mode (42 lines)
✔ Generated in 1.4s
────────────────────────────────────────────────────────────
feat(theme): 新增深色模式,支持系统偏好自动检测
- 新增 ThemeProvider,支持 light/dark/system 三种模式
- 用 CSS 变量替换硬编码颜色,实现主题切换
- 用户偏好持久化到 localStorage
────────────────────────────────────────────────────────────
Tokens: 1333 in + 21 out | Cost: $0.0002
Commit with this message? [Y/n/e] y
✔ Committed to feat/dark-mode 🎉🚀 快速开始
# 安装
npm install -g ai-commit-pro
# 配置 API Key(推荐 DeepSeek,极低成本)
export DEEPSEEK_API_KEY=sk-xxx
# 暂存修改
git add .
# 生成 commit
ai-commit💡 不需要指定 provider —— ai-commit 自动检测你配了哪个 API Key。
📖 使用
Commit(ai-commit)
ai-commit # 从 staged diff 生成 commit message
ai-commit --dry-run # 预览,不执行提交
ai-commit --yes # 跳过确认,直接提交
ai-commit --lang zh # 中文 commit message
ai-commit --provider deepseek # 指定 Provider
ai-commit --model deepseek-v4-flash # 指定模型PR(ai-commit pr)
ai-commit pr # 生成 PR 描述(对比 main)
ai-commit pr --target develop # 指定目标分支
ai-commit pr --dry-run # 仅预览Changelog(ai-commit changelog)
ai-commit changelog # 从最近 50 条 commit 生成
ai-commit changelog --from v1.0.0 --to HEAD # 指定范围
ai-commit changelog --output CHANGELOG.md # 写入文件Release(ai-commit release)
ai-commit release --from v1.0.0 --release-version v1.1.0 # 生成 Release NotesProviders(ai-commit providers)
ai-commit providers # 列出所有支持的模型平台🔧 配置
方式 1:环境变量
macOS / Linux:
export DEEPSEEK_API_KEY=sk-xxx # DeepSeek(推荐)
export DASHSCOPE_API_KEY=sk-xxx # 通义千问
export ZHIPU_API_KEY=xxx # 智谱 GLM
export MOONSHOT_API_KEY=sk-xxx # Kimi
export SILICONFLOW_API_KEY=sk-xxx # 硅基流动
Windows PowerShell:
$env:DEEPSEEK_API_KEY = "sk-xxx" # DeepSeek(推荐)
$env:DASHSCOPE_API_KEY = "sk-xxx" # 通义千问
$env:ZHIPU_API_KEY = "xxx" # 智谱 GLM
$env:MOONSHOT_API_KEY = "sk-xxx" # Kimi
$env:SILICONFLOW_API_KEY = "sk-xxx" # 硅基流动
> 💡 不需要配 `AI_COMMIT_PROVIDER`,配好 Key 后自动检测。
### 方式 2:配置文件
在项目根目录创建 `.ai-commit.yml`:
```yaml
provider: deepseek
apiKey: sk-xxx
model: deepseek-v4-flash
lang: zh支持格式:.ai-commit.yml、.ai-commit.json、.ai-commitrc、ai-commit.config.js
方式 3:自定义 Prompt 模板
mkdir -p .ai-commit/templates
cp node_modules/ai-commit-pro/dist/templates/commit.hbs .ai-commit/templates/
# 编辑后立即生效📦 支持的模型
🇨🇳 国内
| Provider | 模型 | 价格 | 注册 | |----------|------|------|------| | DeepSeek ⭐ | deepseek-v4-flash | ¥1/M 入 · ¥2/M 出 | platform.deepseek.com | | 通义千问 | qwen-plus | ¥0.8/M 入 · ¥2/M 出 | dashscope.console.aliyun.com | | 智谱 GLM | glm-4-flash | ¥0 入 · ¥0 出 | open.bigmodel.cn | | Kimi | kimi-k2.5 | ¥1.4/M 入 · ¥14/M 出 | platform.moonshot.cn | | 硅基流动 | Qwen3-235B-A22B | ¥2/M 入 · ¥6/M 出 | cloud.siliconflow.cn |
💡 注意:DeepSeek 的
deepseek-chat已于 2026-07-24 废弃,默认模型已切换为deepseek-v4-flash。
💡 推荐组合:日常用 DeepSeek(极低成本 + 效果好),偶尔切通义千问或智谱 GLM 作为补充。
🗺️ 路线图
已完成
- [x]
ai-commit— 提交信息生成 - [x]
ai-commit pr— PR 描述生成 - [x]
ai-commit changelog— 变更日志生成 - [x]
ai-commit release— 发布说明生成 - [x]
ai-commit providers— 列出模型平台 - [x] 🇨🇳 国内模型支持(DeepSeek, 通义千问, GLM, Kimi, 硅基流动)
- [x] 🇨🇳 中文 commit message 输出
- [x] 编辑器模式 — 提交前按
e打开编辑器手动修改 message - [x] 自定义 Prompt 模板(Handlebars)
高优先级
- [ ]
--all参数实现 —-a选项声明了但未生效,需自动执行git add -A - [ ] scope 自动检测 — 根据变更文件路径推断 scope(如
src/auth/→feat(auth):) - [ ] Claude 原生支持 — 已安装
@anthropic-ai/sdk,接入 Claude API(commit message 质量很高) - [ ] commit body 生成 —
--verbose模式生成带 bullet points 的详细 body
中优先级
- [ ] prepare-commit-msg hook — 支持配成 Git hook,
git commit时自动调 AI 生成 message - [ ] 自定义 Provider —
.ai-commit.yml中配置任意 OpenAI 兼容端点(Ollama、公司代理等) - [ ] 重试/换模型 — 不满意时按
r重新生成,支持切换 provider 再试 - [ ] 多模型对比 —
ai-commit --compare同时调多个 provider,展示结果让用户选 - [ ] pr --publish — PR 命令加
--publish直接调gh pr create创建 PR - [ ] changelog 缓存 — 同一段 commit range 缓存结果,避免重复调 API
低优先级
- [ ] 交互式向导 —
--wizard逐步询问改动类型、影响范围、是否有 breaking change - [ ] commit 后行为链 —
--push自动推送,--prcommit 后自动打开 PR - [ ] emoji 支持 —
--emoji使用 gitmoji 风格(✨ feat:,🐛 fix:等) - [ ] 更多语言 — 支持日语、韩语、葡萄牙语等 commit message
- [ ] pre-commit 检查 —
--lint验证生成的 message 是否符合 Conventional Commits 规范
🤝 贡献
📄 开源协议
MIT © anrune
