🚨 Active Supply Chain Attack:node-ipc Package Compromised.Learn More
Socket
Book a DemoSign in
Socket

ai-git-msg

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ai-git-msg

AI-powered conventional commit message generator. Read diff → Generate → Confirm → Commit.

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

ai-commit

AI 驱动的 Git Commit Message 生成器 —— 读 diff → 生成 → 确认 → 提交,一条命令搞定。

English | 中文

特性

  • 零依赖 — 无 required dependencies,npx 秒级执行
  • 多 AI 模型 — OpenAI / DeepSeek / Claude / 通义千问 / Gemini / Ollama,自动识别
  • Conventional Commits — 支持 Angular / Conventional / Simple / Gitmoji 四种规范
  • 交互确认 — 生成后确认 / 编辑 / 重新生成 / 取消,完全可控
  • 中英文 — commit message 和 CLI 均支持中英文
  • 配置化.ai-commit.json 团队共享规范
  • 兼容 — 环境变量兼容 ai-review-pipeline,无需重复配置

快速开始

# 1. 配置 API Key(任选一种模型服务,写入 .env.local)

# OpenAI
echo 'OPENAI_API_KEY=sk-xxx' >> .env.local

# DeepSeek(国内推荐,便宜好用)
echo 'DEEPSEEK_API_KEY=sk-xxx' >> .env.local

# 本地 Ollama(无需 Key)
echo 'AI_REVIEW_PROVIDER=ollama' >> .env.local

# 2. Stage 你的改动
git add .

# 3. AI 生成 commit message
npx ai-git-msg

安装

# 方式一:项目级安装(推荐团队使用)
npm install -D ai-git-msg

# 方式二:全局安装
npm install -g ai-git-msg

# 方式三:不安装,npx 直接用
npx ai-git-msg

安装后可使用短名 aic 替代 ai-commit

使用流程

$ npx ai-commit

📝  正在分析 staged 变更...
📂  变更统计:  src/auth/login.ts | 32 +++++++++
🤖  正在调用 AI 生成 commit message...
🔗  Provider: deepseek
🧠  模型: deepseek-chat

┌─────────────────────────────────────────────┐
│  🤖 Generated commit message:               │
└─────────────────────────────────────────────┘

  feat(auth): 添加 Google OAuth 登录支持

  - 新增 GoogleOAuthButton 组件处理重定向
  - 实现 OAuth 回调路由完成 token 交换
  - 更新 auth store 持久化 OAuth token

Confirm? [Y]es / [n]o / [e]dit / [r]egenerate > y

🎉  ✅ 已提交: feat(auth): 添加 Google OAuth 登录支持

命令参数

参数说明
--style <type>规范风格:angular(默认) / conventional / simple / gitmoji
--lang <zh|en>commit message 语言(默认中文)
--one-line只生成标题行(不含 body)
--dry-run只展示,不执行提交
--scope <name>手动指定 scope
-y / --yes跳过确认,直接提交
--help / -h显示帮助
--version / -v显示版本

子命令

命令说明
ai-commit默认:生成 commit message
ai-commit init初始化 .ai-commit.json 配置文件

规范风格

Angular(默认)

feat(auth): 添加 Google OAuth 登录支持

- 新增 GoogleOAuthButton 组件
- 实现 OAuth 回调路由

Conventional

feat: 添加 Google OAuth 登录支持

Simple

添加 Google OAuth 登录支持

Gitmoji

✨ feat(auth): 添加 Google OAuth 登录支持

支持的 AI 模型

Provider默认模型环境变量
OpenAIgpt-4o-miniOPENAI_API_KEY
DeepSeekdeepseek-chatDEEPSEEK_API_KEY
Claudeclaude-sonnet-4-20250514ANTHROPIC_API_KEY
通义千问qwen-plusDASHSCOPE_API_KEY
Geminigemini-2.0-flashGEMINI_API_KEY
Ollamaqwen2.5-coder无需 Key
自定义AI_COMMIT_API_KEY + AI_COMMIT_BASE_URL

也可使用 AI_REVIEW_* 系列环境变量(与 ai-review-pipeline 兼容)。

配置文件

运行 ai-commit init 生成 .ai-commit.json

{
  "style": "angular",          // angular | conventional | simple | gitmoji
  "language": "zh",            // zh | en
  "maxDiffLines": 500,         // diff 超过此行数截断
  "scopeMap": {},              // 路径 → scope 映射(v1.1)
  "types": [                   // 允许的 commit type
    "feat", "fix", "refactor", "docs", "style", "test", "chore", "perf", "ci"
  ],
  "emoji": false,              // 是否默认启用 gitmoji
  "autoConfirm": false,        // 是否跳过确认
  "model": ""                  // 指定模型
}

环境变量

变量说明
OPENAI_API_KEYOpenAI API Key
DEEPSEEK_API_KEYDeepSeek API Key
ANTHROPIC_API_KEYAnthropic Claude API Key
DASHSCOPE_API_KEY阿里通义千问 API Key
GEMINI_API_KEYGoogle Gemini API Key
AI_COMMIT_API_KEY通用 Key(优先级最高)
AI_COMMIT_PROVIDER手动指定 Provider
AI_COMMIT_BASE_URL自定义 API 地址
AI_COMMIT_MODEL覆盖默认模型
HTTPS_PROXYHTTP 代理

兼容 AI_REVIEW_* 系列变量。支持 .env.local.env 文件自动加载。

常用命令速查

npx ai-commit                         # 默认:分析 staged,生成 commit message
npx ai-commit --style gitmoji         # gitmoji 风格
npx ai-commit --style simple          # 简单一行描述
npx ai-commit --lang en               # 英文 commit message
npx ai-commit --dry-run               # 只展示不提交
npx ai-commit -y                      # 跳过确认直接提交
npx ai-commit --scope auth            # 手动指定 scope
npx ai-commit init                    # 生成配置文件

工具链

代码编写
   │
   ├── ai-review-pipeline ── Review → Test → Report
   │
   ├── ai-commit ── Diff → AI Message → Confirm → Commit
   │
   └── ai-changelog (coming) ── Git Log → CHANGELOG

English

What is this?

An AI-powered Git commit message generator. Reads staged diff → AI generates Conventional Commit message → You confirm → Done. Supports OpenAI, DeepSeek, Claude, Qwen, Gemini, Ollama and any OpenAI-compatible API.

Quick Start

echo 'DEEPSEEK_API_KEY=sk-xxx' >> .env.local
git add .
npx ai-git-msg

Options

OptionDescription
--style <type>Style: angular(default) / conventional / simple / gitmoji
--lang <zh|en>Message language (default: zh)
--one-lineSubject line only
--dry-runPreview only, don't commit
--scope <name>Manually specify scope
-y / --yesSkip confirmation

Install

npm install -D ai-git-msg   # Project-level
npm install -g ai-git-msg   # Global
npx ai-git-msg              # No install needed

Use --lang en for English commit messages.

License

MIT

Keywords

ai

FAQs

Package last updated on 01 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts