@dongowu/git-ai-cli 1.0.19 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +171 -94
- package/README_EN.md +179 -84
- package/dist/cli.js +2 -135
- package/dist/cli.js.map +1 -1
- package/dist/cli_main.d.ts +2 -0
- package/dist/cli_main.d.ts.map +1 -0
- package/dist/cli_main.js +255 -0
- package/dist/cli_main.js.map +1 -0
- package/dist/commands/branch.d.ts +11 -0
- package/dist/commands/branch.d.ts.map +1 -0
- package/dist/commands/branch.js +279 -0
- package/dist/commands/branch.js.map +1 -0
- package/dist/commands/commit.d.ts.map +1 -1
- package/dist/commands/commit.js +52 -9
- package/dist/commands/commit.js.map +1 -1
- package/dist/commands/config_manage.d.ts +14 -0
- package/dist/commands/config_manage.d.ts.map +1 -0
- package/dist/commands/config_manage.js +394 -0
- package/dist/commands/config_manage.js.map +1 -0
- package/dist/commands/hook.d.ts.map +1 -1
- package/dist/commands/hook.js +124 -6
- package/dist/commands/hook.js.map +1 -1
- package/dist/commands/msg.d.ts +1 -0
- package/dist/commands/msg.d.ts.map +1 -1
- package/dist/commands/msg.js +40 -6
- package/dist/commands/msg.js.map +1 -1
- package/dist/commands/pr.d.ts +8 -0
- package/dist/commands/pr.d.ts.map +1 -0
- package/dist/commands/pr.js +96 -0
- package/dist/commands/pr.js.map +1 -0
- package/dist/commands/release.d.ts +8 -0
- package/dist/commands/release.d.ts.map +1 -0
- package/dist/commands/release.js +95 -0
- package/dist/commands/release.js.map +1 -0
- package/dist/commands/report.d.ts +7 -2
- package/dist/commands/report.d.ts.map +1 -1
- package/dist/commands/report.js +99 -15
- package/dist/commands/report.js.map +1 -1
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/agent_lite.d.ts +5 -0
- package/dist/utils/agent_lite.d.ts.map +1 -0
- package/dist/utils/agent_lite.js +263 -0
- package/dist/utils/agent_lite.js.map +1 -0
- package/dist/utils/ai.d.ts +22 -0
- package/dist/utils/ai.d.ts.map +1 -1
- package/dist/utils/ai.js +852 -37
- package/dist/utils/ai.js.map +1 -1
- package/dist/utils/config.d.ts +5 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +157 -5
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/git.d.ts +17 -0
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +275 -49
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/update.d.ts +3 -1
- package/dist/utils/update.d.ts.map +1 -1
- package/dist/utils/update.js +53 -2
- package/dist/utils/update.js.map +1 -1
- package/package.json +1 -1
- package/release_notes.md +3 -2
package/README.md
CHANGED
|
@@ -18,144 +18,223 @@
|
|
|
18
18
|
<p align="center">
|
|
19
19
|
<a href="./README_EN.md">English</a> •
|
|
20
20
|
<a href="#-快速开始">快速开始</a> •
|
|
21
|
-
<a href="
|
|
22
|
-
<a href="
|
|
23
|
-
<a href="
|
|
21
|
+
<a href="#-使用指南推荐流程">使用指南</a> •
|
|
22
|
+
<a href="#-配置">配置</a> •
|
|
23
|
+
<a href="#-命令速查">命令</a>
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
|
-
**git-ai-cli**
|
|
28
|
+
**git-ai-cli** 不只是 Commit Message 生成器,它是你的**全能 AI 开发助手**:理解 diff、识别分支意图、统一团队规范、自动生成周报/PR/Release Notes。
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
32
|
## 🚀 快速开始
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
# 1
|
|
35
|
+
# 1) 安装
|
|
36
36
|
npm install -g @dongowu/git-ai-cli
|
|
37
37
|
|
|
38
|
-
# 2
|
|
38
|
+
# 2) 初始化 (自动探测本地模型或配置 API)
|
|
39
39
|
git-ai init
|
|
40
40
|
|
|
41
|
-
# 3
|
|
41
|
+
# 3) 使用
|
|
42
42
|
git add .
|
|
43
43
|
git-ai
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
---
|
|
47
47
|
|
|
48
|
-
##
|
|
49
|
-
|
|
50
|
-
### 1. 🇨🇳 极致本土化 & 隐私优先
|
|
51
|
-
- **DeepSeek/Qwen 深度优化**:内置专家级提示词,针对中文代码语境优化,不只是翻译 Diff,而是理解“意图”。
|
|
52
|
-
- **Ollama 零配置**:自动探测本地运行的 Ollama 模型(如 `llama3`, `deepseek-coder`),无需手动输入模型名。数据完全不出网,绝对安全。
|
|
48
|
+
## ✅ 使用指南(推荐流程)
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
50
|
+
1) **安装与初始化**
|
|
51
|
+
```bash
|
|
52
|
+
npm install -g @dongowu/git-ai-cli
|
|
53
|
+
git-ai init
|
|
54
|
+
```
|
|
57
55
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
2) **团队配置(推荐)**:在项目根目录写 `.git-ai.json`
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"provider": "deepseek",
|
|
60
|
+
"baseUrl": "https://api.deepseek.com/v1",
|
|
61
|
+
"model": "deepseek-reasoner",
|
|
62
|
+
"agentModel": "deepseek-chat",
|
|
63
|
+
"locale": "en",
|
|
64
|
+
"enableFooter": false,
|
|
65
|
+
"rulesPreset": "conventional",
|
|
66
|
+
"fallbackModels": ["deepseek-chat", "qwen-turbo"],
|
|
67
|
+
"policy": { "strict": true },
|
|
68
|
+
"rules": {
|
|
69
|
+
"types": ["feat", "fix", "docs", "refactor", "perf", "test", "chore", "build", "ci"],
|
|
70
|
+
"maxSubjectLength": 50,
|
|
71
|
+
"requireScope": false,
|
|
72
|
+
"issuePattern": "[A-Z]+-\\d+",
|
|
73
|
+
"issuePlacement": "footer",
|
|
74
|
+
"issueFooterPrefix": "Refs",
|
|
75
|
+
"requireIssue": false
|
|
76
|
+
},
|
|
77
|
+
"branch": {
|
|
78
|
+
"types": ["feat", "fix", "docs"],
|
|
79
|
+
"pattern": "{type}/{issue?}{name}",
|
|
80
|
+
"issueSeparator": "-",
|
|
81
|
+
"nameMaxLength": 50
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
63
85
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
86
|
+
3) **日常提交**
|
|
87
|
+
```bash
|
|
88
|
+
git add .
|
|
89
|
+
git-ai
|
|
90
|
+
```
|
|
67
91
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
-
|
|
92
|
+
4) **Hook 无感集成(强烈推荐)**
|
|
93
|
+
```bash
|
|
94
|
+
git-ai hook install
|
|
95
|
+
# 失败阻断提交(可选)
|
|
96
|
+
GIT_AI_HOOK_STRICT=1 git commit
|
|
97
|
+
# 失败时关闭兜底(可选)
|
|
98
|
+
GIT_AI_HOOK_FALLBACK=0 git commit
|
|
99
|
+
```
|
|
71
100
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
-
|
|
101
|
+
5) **脚本 / CI**
|
|
102
|
+
```bash
|
|
103
|
+
git-ai msg --json
|
|
104
|
+
```
|
|
75
105
|
|
|
76
|
-
|
|
106
|
+
6) **创建分支(交互式)**
|
|
107
|
+
```bash
|
|
108
|
+
git-ai branch
|
|
109
|
+
```
|
|
77
110
|
|
|
78
|
-
|
|
111
|
+
7) **PR / Release / Report**
|
|
112
|
+
```bash
|
|
113
|
+
# PR 描述
|
|
114
|
+
git-ai pr --base main --head HEAD
|
|
79
115
|
|
|
80
|
-
|
|
81
|
-
|
|
116
|
+
# Release Notes
|
|
117
|
+
git-ai release --from v1.0.0 --to HEAD
|
|
82
118
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
"model": "deepseek-coder",
|
|
86
|
-
"temperature": 0.5,
|
|
87
|
-
"locale": "zh-CN",
|
|
88
|
-
"customPrompt": "Always start with an emoji."
|
|
89
|
-
}
|
|
119
|
+
# 周报
|
|
120
|
+
git-ai report --days 7
|
|
90
121
|
```
|
|
91
122
|
|
|
92
|
-
|
|
93
|
-
在项目根目录创建,用于排除不想发送给 AI 的文件(语法同 `.gitignore`):
|
|
123
|
+
---
|
|
94
124
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
125
|
+
## ✨ 核心特性
|
|
126
|
+
|
|
127
|
+
- **DeepSeek/Qwen 深度优化**:理解意图而不是简单翻译 diff
|
|
128
|
+
- **本地模型隐私优先**:Ollama / LM Studio 即插即用
|
|
129
|
+
- **上下文感知**:分支规则、提交风格学习、智能 scope
|
|
130
|
+
- **Agent 智能体**:大改动时自动做影响分析
|
|
131
|
+
- **团队规则**:规则模板 + 强校验(policy)
|
|
132
|
+
- **Hook 集成**:无感生成提交信息
|
|
133
|
+
- **AI 报告**:日报/周报/PR/Release Notes 一键生成
|
|
100
134
|
|
|
101
135
|
---
|
|
102
136
|
|
|
103
|
-
##
|
|
137
|
+
## ⚙️ 配置
|
|
138
|
+
|
|
139
|
+
### 项目级配置 `.git-ai.json`
|
|
140
|
+
- `provider / baseUrl / model / agentModel`
|
|
141
|
+
- `locale`: `zh` / `en`
|
|
142
|
+
- `outputFormat`: `text` / `json`
|
|
143
|
+
- `rulesPreset`: `conventional` / `angular` / `minimal`
|
|
144
|
+
- `fallbackModels`: 主模型失败时的回退模型列表
|
|
145
|
+
- `policy.strict`: 是否阻断不合规提交
|
|
146
|
+
- `rules`: 提交规范(类型、scope、长度、issue 等)
|
|
147
|
+
- `branch`: 分支规范(类型、pattern、长度等)
|
|
148
|
+
|
|
149
|
+
### 规则与策略
|
|
150
|
+
- `issuePattern`: 任务号正则(如 `PROJ-123` / `#123`)
|
|
151
|
+
- `issuePlacement`: `scope | subject | footer`
|
|
152
|
+
- `requireIssue`: 是否必须包含任务号
|
|
153
|
+
- `policy.strict`: 不合规则阻断提交
|
|
154
|
+
- `branch.pattern`: 分支模板(如 `{type}/{issue?}{name}`)
|
|
155
|
+
- `branch.types`: 分支类型列表
|
|
156
|
+
- `branch.issueSeparator`: issue 分隔符(默认 `-`)
|
|
157
|
+
- `branch.nameMaxLength`: 分支名长度上限
|
|
158
|
+
|
|
159
|
+
### CLI 设置(可脚本化)
|
|
160
|
+
```bash
|
|
161
|
+
# 查看当前生效配置
|
|
162
|
+
git-ai config get --json
|
|
104
163
|
|
|
105
|
-
|
|
164
|
+
# 设置规则模板 / 严格策略 / 回退模型
|
|
165
|
+
git-ai config set rulesPreset conventional
|
|
166
|
+
git-ai config set policy '{"strict":true}'
|
|
167
|
+
git-ai config set fallbackModels "deepseek-chat,qwen-turbo"
|
|
106
168
|
|
|
107
|
-
|
|
108
|
-
git
|
|
109
|
-
git-ai
|
|
110
|
-
```
|
|
169
|
+
# 设置规则(JSON 或 @文件)
|
|
170
|
+
git-ai config set rules '{"types":["feat","fix"]}'
|
|
171
|
+
git-ai config set rules @rules.json --local
|
|
111
172
|
|
|
112
|
-
|
|
173
|
+
# 设置分支规则
|
|
174
|
+
git-ai config set branch '{"types":["feat","fix"],"pattern":"{type}/{issue?}{name}"}'
|
|
175
|
+
```
|
|
113
176
|
|
|
114
|
-
|
|
177
|
+
---
|
|
115
178
|
|
|
116
|
-
|
|
117
|
-
# 在当前项目安装
|
|
118
|
-
git-ai hook install
|
|
179
|
+
## 🛠 命令速查
|
|
119
180
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
181
|
+
| 命令 | 说明 |
|
|
182
|
+
|------|------|
|
|
183
|
+
| `git-ai init` | 初始化配置 |
|
|
184
|
+
| `git-ai config get/set/describe` | 配置管理 |
|
|
185
|
+
| `git-ai` / `git-ai commit` | 交互式提交 |
|
|
186
|
+
| `git-ai -a` | Agent 模式 |
|
|
187
|
+
| `git-ai msg` | 仅输出消息(脚本/Hook) |
|
|
188
|
+
| `git-ai branch` | 交互式创建分支 |
|
|
189
|
+
| `git-ai hook install/remove` | Git Hook 管理 |
|
|
190
|
+
| `git-ai report` | 生成 AI 周报 |
|
|
191
|
+
| `git-ai pr` | 生成 PR 描述 |
|
|
192
|
+
| `git-ai release` | 生成 Release Notes |
|
|
123
193
|
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
git checkout -b feature/awesome-login
|
|
127
|
-
# ... 写代码 ...
|
|
128
|
-
git add .
|
|
129
|
-
git commit # ✨ AI 自动帮你写好了 "feat(login): implement awesome login logic"
|
|
130
|
-
```
|
|
194
|
+
---
|
|
131
195
|
|
|
132
|
-
|
|
196
|
+
## ⚡ 环境变量(常用)
|
|
197
|
+
|
|
198
|
+
- `GIT_AI_PROVIDER` / `GIT_AI_BASE_URL` / `GIT_AI_MODEL` / `GIT_AI_AGENT_MODEL`
|
|
199
|
+
- `GIT_AI_API_KEY`(也支持 `DEEPSEEK_API_KEY`, `OPENAI_API_KEY`)
|
|
200
|
+
- `GIT_AI_TIMEOUT_MS`
|
|
201
|
+
- `GIT_AI_MAX_DIFF_CHARS` / `GIT_AI_MAX_OUTPUT_TOKENS`
|
|
202
|
+
- `GIT_AI_RULES_PRESET`
|
|
203
|
+
- `GIT_AI_FALLBACK_MODELS`
|
|
204
|
+
- `GIT_AI_POLICY_STRICT`
|
|
205
|
+
- `GIT_AI_ISSUE_PATTERN` / `GIT_AI_ISSUE_PLACEMENT` / `GIT_AI_REQUIRE_ISSUE`
|
|
206
|
+
- `GIT_AI_OUTPUT_FORMAT=json`
|
|
207
|
+
- `GIT_AI_MSG_DELIM=<<<GIT_AI_END>>>`
|
|
208
|
+
- `GIT_AI_HOOK_STRICT=1` / `GIT_AI_HOOK_FALLBACK=0`
|
|
209
|
+
- `GIT_AI_BRANCH_PATTERN` / `GIT_AI_BRANCH_TYPES`
|
|
210
|
+
- `GIT_AI_BRANCH_ISSUE_SEPARATOR` / `GIT_AI_BRANCH_NAME_MAXLEN`
|
|
133
211
|
|
|
134
|
-
|
|
212
|
+
---
|
|
135
213
|
|
|
136
|
-
|
|
137
|
-
# 生成本周日报/周报
|
|
138
|
-
git-ai report
|
|
214
|
+
## 🧩 忽略文件 `.git-aiignore`
|
|
139
215
|
|
|
140
|
-
|
|
141
|
-
|
|
216
|
+
```text
|
|
217
|
+
package-lock.json
|
|
218
|
+
dist/
|
|
219
|
+
*.min.js
|
|
142
220
|
```
|
|
143
221
|
|
|
222
|
+
同时兼容 OpenCommit 的 `.opencommitignore`。
|
|
223
|
+
|
|
144
224
|
---
|
|
145
225
|
|
|
146
|
-
##
|
|
226
|
+
## ❓常见问题
|
|
227
|
+
|
|
228
|
+
**1) 401 / API Key 无效**
|
|
229
|
+
- 先看配置:`git-ai config get --json --local`
|
|
230
|
+
- 检查环境变量是否覆盖
|
|
231
|
+
|
|
232
|
+
**2) Diff 被截断**
|
|
233
|
+
- 用 `.git-aiignore` 忽略大文件
|
|
234
|
+
- 或设置 `GIT_AI_MAX_DIFF_CHARS`
|
|
147
235
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
| `git-ai init` | `config` | **初始化配置**(设置模型、Key、语言) |
|
|
151
|
-
| `git-ai` | | 交互式生成并提交 |
|
|
152
|
-
| `git-ai -a` | | **Agent 模式** (深度分析 & 影响检查) |
|
|
153
|
-
| `git-ai -y` | | 跳过确认直接提交 |
|
|
154
|
-
| `git-ai -n 3` | | 生成 3 条候选消息 |
|
|
155
|
-
| `git-ai hook install` | | **安装 Git Hook** (支持 `--global`) |
|
|
156
|
-
| `git-ai hook remove` | | 移除 Git Hook |
|
|
157
|
-
| `git-ai report` | | **生成 AI 周报** (支持 `--days`) |
|
|
158
|
-
| `git-ai msg` | | 仅输出消息(供脚本调用) |
|
|
236
|
+
**3) Agent 自动回退**
|
|
237
|
+
- 设置 `GIT_AI_DEBUG=1` 查看原因
|
|
159
238
|
|
|
160
239
|
---
|
|
161
240
|
|
|
@@ -163,17 +242,15 @@ git-ai report --days 30
|
|
|
163
242
|
|
|
164
243
|
| 类型 | 服务商 | 优势 | 配置方式 |
|
|
165
244
|
|------|--------|------|----------|
|
|
166
|
-
| **本地隐私** | **Ollama** |
|
|
245
|
+
| **本地隐私** | **Ollama** | 免费、离线、隐私 | `git-ai init` 自动探测 |
|
|
167
246
|
| | **LM Studio** | 兼容性好 | 手动输入 URL |
|
|
168
|
-
| **国内高速** | **DeepSeek** |
|
|
169
|
-
| | **通义千问** |
|
|
170
|
-
| | **智谱/Moonshot** |
|
|
247
|
+
| **国内高速** | **DeepSeek** | 性价比高 | API Key |
|
|
248
|
+
| | **通义千问** | 长文本能力强 | API Key |
|
|
249
|
+
| | **智谱/Moonshot** | 国内主流 | API Key |
|
|
171
250
|
| **国际通用** | **OpenAI** | GPT-4o 基准能力 | API Key |
|
|
172
251
|
|
|
173
252
|
---
|
|
174
253
|
|
|
175
|
-
|
|
176
|
-
|
|
177
254
|
## 📄 License
|
|
178
255
|
|
|
179
256
|
[MIT](LICENSE)
|
|
@@ -184,4 +261,4 @@ git-ai report --days 30
|
|
|
184
261
|
Made with ❤️ by git-ai team
|
|
185
262
|
<br>
|
|
186
263
|
<sub>🤖 Generated by git-ai 🚀</sub>
|
|
187
|
-
</p>
|
|
264
|
+
</p>
|
package/README_EN.md
CHANGED
|
@@ -18,141 +18,236 @@
|
|
|
18
18
|
<p align="center">
|
|
19
19
|
<a href="./README.md">中文文档</a> •
|
|
20
20
|
<a href="#-quick-start">Quick Start</a> •
|
|
21
|
-
<a href="#-
|
|
22
|
-
<a href="#-
|
|
23
|
-
<a href="#-
|
|
21
|
+
<a href="#-usage-guide-recommended">Usage</a> •
|
|
22
|
+
<a href="#-configuration">Configuration</a> •
|
|
23
|
+
<a href="#-command-reference">Commands</a>
|
|
24
24
|
</p>
|
|
25
25
|
|
|
26
26
|
---
|
|
27
27
|
|
|
28
|
-
**git-ai-cli** is more than
|
|
28
|
+
**git-ai-cli** is more than a commit message generator. It understands diffs, enforces team rules, and generates reports, PR descriptions, and release notes.
|
|
29
29
|
|
|
30
30
|
---
|
|
31
31
|
|
|
32
32
|
## 🚀 Quick Start
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
# 1
|
|
35
|
+
# 1) Install
|
|
36
36
|
npm install -g @dongowu/git-ai-cli
|
|
37
37
|
|
|
38
|
-
# 2
|
|
38
|
+
# 2) Initialize (auto-detect local models or configure API)
|
|
39
39
|
git-ai init
|
|
40
40
|
|
|
41
|
-
# 3
|
|
41
|
+
# 3) Use
|
|
42
42
|
git add .
|
|
43
43
|
git-ai
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
---
|
|
47
47
|
|
|
48
|
-
##
|
|
48
|
+
## ✅ Usage Guide (Recommended)
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
-
|
|
50
|
+
1) **Install & Init**
|
|
51
|
+
```bash
|
|
52
|
+
npm install -g @dongowu/git-ai-cli
|
|
53
|
+
git-ai init
|
|
54
|
+
```
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
2) **Team config (recommended)**: create `.git-ai.json` in project root
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"provider": "deepseek",
|
|
60
|
+
"baseUrl": "https://api.deepseek.com/v1",
|
|
61
|
+
"model": "deepseek-reasoner",
|
|
62
|
+
"agentModel": "deepseek-chat",
|
|
63
|
+
"locale": "en",
|
|
64
|
+
"enableFooter": false,
|
|
65
|
+
"rulesPreset": "conventional",
|
|
66
|
+
"fallbackModels": ["deepseek-chat", "qwen-turbo"],
|
|
67
|
+
"policy": { "strict": true },
|
|
68
|
+
"rules": {
|
|
69
|
+
"types": ["feat", "fix", "docs", "refactor", "perf", "test", "chore", "build", "ci"],
|
|
70
|
+
"maxSubjectLength": 50,
|
|
71
|
+
"requireScope": false,
|
|
72
|
+
"issuePattern": "[A-Z]+-\\d+",
|
|
73
|
+
"issuePlacement": "footer",
|
|
74
|
+
"issueFooterPrefix": "Refs",
|
|
75
|
+
"requireIssue": false
|
|
76
|
+
},
|
|
77
|
+
"branch": {
|
|
78
|
+
"types": ["feat", "fix", "docs"],
|
|
79
|
+
"pattern": "{type}/{issue?}{name}",
|
|
80
|
+
"issueSeparator": "-",
|
|
81
|
+
"nameMaxLength": 50
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
57
85
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
-
|
|
62
|
-
|
|
86
|
+
3) **Daily commit**
|
|
87
|
+
```bash
|
|
88
|
+
git add .
|
|
89
|
+
git-ai
|
|
90
|
+
```
|
|
63
91
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
92
|
+
4) **Hook (recommended)**
|
|
93
|
+
```bash
|
|
94
|
+
git-ai hook install
|
|
95
|
+
# Block commit on failure (optional)
|
|
96
|
+
GIT_AI_HOOK_STRICT=1 git commit
|
|
97
|
+
# Disable fallback message (optional)
|
|
98
|
+
GIT_AI_HOOK_FALLBACK=0 git commit
|
|
99
|
+
```
|
|
67
100
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
-
|
|
101
|
+
5) **Scripts / CI**
|
|
102
|
+
```bash
|
|
103
|
+
git-ai msg --json
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
6) **Create branch (interactive)**
|
|
107
|
+
```bash
|
|
108
|
+
git-ai branch
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
7) **PR / Release / Report**
|
|
112
|
+
```bash
|
|
113
|
+
# PR description
|
|
114
|
+
git-ai pr --base main --head HEAD
|
|
115
|
+
|
|
116
|
+
# Release notes
|
|
117
|
+
git-ai release --from v1.0.0 --to HEAD
|
|
71
118
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
119
|
+
# Weekly report
|
|
120
|
+
git-ai report --days 7
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## ✨ Features
|
|
126
|
+
|
|
127
|
+
- **DeepSeek/Qwen optimized**: intent-focused prompts
|
|
128
|
+
- **Local privacy**: Ollama / LM Studio support
|
|
129
|
+
- **Context aware**: branch rules, style learning, smart scope
|
|
130
|
+
- **Agent mode**: impact analysis for large diffs
|
|
131
|
+
- **Team rules**: presets + strict policy
|
|
132
|
+
- **Git hooks**: zero-friction commits
|
|
133
|
+
- **AI reports**: weekly report / PR / release notes
|
|
75
134
|
|
|
76
135
|
---
|
|
77
136
|
|
|
78
137
|
## ⚙️ Configuration
|
|
79
138
|
|
|
80
|
-
### Project-
|
|
81
|
-
|
|
139
|
+
### Project-level config `.git-ai.json`
|
|
140
|
+
- `provider / baseUrl / model / agentModel`
|
|
141
|
+
- `locale`: `zh` / `en`
|
|
142
|
+
- `outputFormat`: `text` / `json`
|
|
143
|
+
- `rulesPreset`: `conventional` / `angular` / `minimal`
|
|
144
|
+
- `fallbackModels`: fallback list when the primary model fails
|
|
145
|
+
- `policy.strict`: block commit when rules are violated
|
|
146
|
+
- `rules`: types/scopes/length/issue rules
|
|
147
|
+
- `branch`: branch naming rules (types/pattern/length)
|
|
148
|
+
|
|
149
|
+
### Rules & Policy
|
|
150
|
+
- `issuePattern`: regex for issue IDs
|
|
151
|
+
- `issuePlacement`: `scope | subject | footer`
|
|
152
|
+
- `requireIssue`: enforce issue id
|
|
153
|
+
- `policy.strict`: block commit when invalid
|
|
154
|
+
- `branch.pattern`: branch template (e.g., `{type}/{issue?}{name}`)
|
|
155
|
+
- `branch.types`: branch type list
|
|
156
|
+
- `branch.issueSeparator`: issue separator (default `-`)
|
|
157
|
+
- `branch.nameMaxLength`: max length for name
|
|
158
|
+
|
|
159
|
+
### CLI config
|
|
160
|
+
```bash
|
|
161
|
+
# Show effective config
|
|
162
|
+
git-ai config get --json
|
|
82
163
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"locale": "en",
|
|
88
|
-
"customPrompt": "Always start with an emoji."
|
|
89
|
-
}
|
|
90
|
-
```
|
|
164
|
+
# Preset / policy / fallback
|
|
165
|
+
git-ai config set rulesPreset conventional
|
|
166
|
+
git-ai config set policy '{"strict":true}'
|
|
167
|
+
git-ai config set fallbackModels "deepseek-chat,qwen-turbo"
|
|
91
168
|
|
|
92
|
-
|
|
93
|
-
|
|
169
|
+
# Rules (JSON or @file)
|
|
170
|
+
git-ai config set rules '{"types":["feat","fix"]}'
|
|
171
|
+
git-ai config set rules @rules.json --local
|
|
94
172
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
dist/
|
|
98
|
-
*.min.js
|
|
173
|
+
# Branch rules
|
|
174
|
+
git-ai config set branch '{"types":["feat","fix"],"pattern":"{type}/{issue?}{name}"}'
|
|
99
175
|
```
|
|
100
176
|
|
|
101
177
|
---
|
|
102
178
|
|
|
103
|
-
##
|
|
179
|
+
## 🛠 Command Reference
|
|
104
180
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
git
|
|
108
|
-
git-ai
|
|
109
|
-
|
|
181
|
+
| Command | Description |
|
|
182
|
+
|--------|-------------|
|
|
183
|
+
| `git-ai init` | Initialize config |
|
|
184
|
+
| `git-ai config get/set/describe` | Config management |
|
|
185
|
+
| `git-ai` / `git-ai commit` | Interactive commit |
|
|
186
|
+
| `git-ai -a` | Agent mode |
|
|
187
|
+
| `git-ai msg` | Message only (scripts/hooks) |
|
|
188
|
+
| `git-ai branch` | Create branch interactively |
|
|
189
|
+
| `git-ai hook install/remove` | Hook management |
|
|
190
|
+
| `git-ai report` | Weekly report |
|
|
191
|
+
| `git-ai pr` | PR description |
|
|
192
|
+
| `git-ai release` | Release notes |
|
|
110
193
|
|
|
111
|
-
|
|
112
|
-
The smoothest experience. Install once, use forever.
|
|
194
|
+
---
|
|
113
195
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
196
|
+
## ⚡ Environment Variables
|
|
197
|
+
|
|
198
|
+
- `GIT_AI_PROVIDER` / `GIT_AI_BASE_URL` / `GIT_AI_MODEL` / `GIT_AI_AGENT_MODEL`
|
|
199
|
+
- `GIT_AI_API_KEY` (also `DEEPSEEK_API_KEY`, `OPENAI_API_KEY`)
|
|
200
|
+
- `GIT_AI_TIMEOUT_MS`
|
|
201
|
+
- `GIT_AI_MAX_DIFF_CHARS` / `GIT_AI_MAX_OUTPUT_TOKENS`
|
|
202
|
+
- `GIT_AI_RULES_PRESET`
|
|
203
|
+
- `GIT_AI_FALLBACK_MODELS`
|
|
204
|
+
- `GIT_AI_POLICY_STRICT`
|
|
205
|
+
- `GIT_AI_ISSUE_PATTERN` / `GIT_AI_ISSUE_PLACEMENT` / `GIT_AI_REQUIRE_ISSUE`
|
|
206
|
+
- `GIT_AI_OUTPUT_FORMAT=json`
|
|
207
|
+
- `GIT_AI_MSG_DELIM=<<<GIT_AI_END>>>`
|
|
208
|
+
- `GIT_AI_HOOK_STRICT=1` / `GIT_AI_HOOK_FALLBACK=0`
|
|
209
|
+
- `GIT_AI_BRANCH_PATTERN` / `GIT_AI_BRANCH_TYPES`
|
|
210
|
+
- `GIT_AI_BRANCH_ISSUE_SEPARATOR` / `GIT_AI_BRANCH_NAME_MAXLEN`
|
|
117
211
|
|
|
118
|
-
|
|
119
|
-
git-ai hook install --global
|
|
120
|
-
```
|
|
212
|
+
---
|
|
121
213
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
214
|
+
## 🧩 Ignore File `.git-aiignore`
|
|
215
|
+
|
|
216
|
+
```text
|
|
217
|
+
package-lock.json
|
|
218
|
+
dist/
|
|
219
|
+
*.min.js
|
|
128
220
|
```
|
|
129
221
|
|
|
130
|
-
|
|
131
|
-
Hate writing weekly reports?
|
|
222
|
+
Also compatible with `.opencommitignore`.
|
|
132
223
|
|
|
133
|
-
|
|
134
|
-
# Generate report for this week
|
|
135
|
-
git-ai report
|
|
224
|
+
---
|
|
136
225
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
226
|
+
## ❓Troubleshooting
|
|
227
|
+
|
|
228
|
+
**1) 401 / Invalid API key**
|
|
229
|
+
- `git-ai config get --json --local`
|
|
230
|
+
- Check env overrides
|
|
231
|
+
|
|
232
|
+
**2) Diff truncated**
|
|
233
|
+
- Ignore large files via `.git-aiignore`
|
|
234
|
+
- Or set `GIT_AI_MAX_DIFF_CHARS`
|
|
235
|
+
|
|
236
|
+
**3) Agent falls back**
|
|
237
|
+
- Set `GIT_AI_DEBUG=1` to see reasons
|
|
140
238
|
|
|
141
239
|
---
|
|
142
240
|
|
|
143
|
-
##
|
|
241
|
+
## 🤖 Supported Models
|
|
144
242
|
|
|
145
|
-
|
|
|
146
|
-
|
|
147
|
-
|
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
| `git-ai hook install` | | **Install Git Hook** (supports `--global`) |
|
|
154
|
-
| `git-ai report` | | **Generate AI Report** (supports `--days`) |
|
|
155
|
-
| `git-ai msg` | | Generate message only (stdout for scripts) |
|
|
243
|
+
| Type | Provider | Notes | Setup |
|
|
244
|
+
|------|----------|------|-------|
|
|
245
|
+
| **Local** | **Ollama** | Offline & private | `git-ai init` auto-detect |
|
|
246
|
+
| | **LM Studio** | Good compatibility | Manual URL |
|
|
247
|
+
| **CN** | **DeepSeek** | High value | API Key |
|
|
248
|
+
| | **Qwen** | Long context | API Key |
|
|
249
|
+
| | **Zhipu/Moonshot** | Popular in CN | API Key |
|
|
250
|
+
| **Global** | **OpenAI** | Baseline GPT-4o | API Key |
|
|
156
251
|
|
|
157
252
|
---
|
|
158
253
|
|