claude-pangu 2.2.21 → 2.3.0
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/.claude-plugin/plugin.json +1 -1
- package/README.md +2 -0
- package/agents/huoshen.md +220 -424
- package/agents/librarian.md +113 -276
- package/agents/lilou.md +56 -293
- package/agents/liubowen.md +103 -324
- package/agents/metis.md +178 -152
- package/agents/oracle.md +102 -260
- package/agents/wukong.md +101 -164
- package/agents/yugong.md +384 -231
- package/agents/zhuge.md +276 -200
- package/commands/handoff.md +178 -0
- package/commands/init-deep.md +160 -112
- package/commands/refactor.md +196 -194
- package/commands/start-work.md +88 -73
- package/commands/stop-continuation.md +57 -0
- package/hooks/agent-collaboration.sh +14 -1
- package/hooks/agent-handoff-prompt.sh +15 -4
- package/hooks/agent-ready-notification.sh +13 -2
- package/hooks/agent-usage-reminder.sh +12 -2
- package/hooks/anthropic-context-window-limit-recovery.sh +14 -2
- package/hooks/ast-grep.sh +14 -1
- package/hooks/atlas.sh +13 -4
- package/hooks/auto-update-checker.sh +20 -1
- package/hooks/background-compaction.sh +15 -2
- package/hooks/background-notification.sh +1 -1
- package/hooks/category-skill-reminder.sh +92 -0
- package/hooks/code-quality-checker.sh +14 -1
- package/hooks/comment-checker.sh +119 -0
- package/hooks/compaction-context-injector.sh +218 -0
- package/hooks/context-compression.sh +14 -1
- package/hooks/context-smart-alert.sh +15 -3
- package/hooks/context-window-monitor.sh +15 -3
- package/hooks/delegate-task-retry.sh +4 -4
- package/hooks/directory-agents-injector.sh +14 -1
- package/hooks/directory-readme-injector.sh +16 -2
- package/hooks/edit-error-recovery.sh +17 -3
- package/hooks/empty-message-sanitizer.sh +150 -0
- package/hooks/empty-task-response-detector.sh +14 -3
- package/hooks/error-friendly-display.sh +17 -7
- package/hooks/error-recovery.sh +14 -1
- package/hooks/first-use-onboarding.sh +1 -4
- package/hooks/hook-performance-monitor.sh +1 -1
- package/hooks/hooks.json +84 -1
- package/hooks/interactive-bash-session.sh +12 -2
- package/hooks/json-error-recovery.sh +176 -0
- package/hooks/lsp-tools.sh +14 -1
- package/hooks/non-interactive-env.sh +186 -0
- package/hooks/output-truncator.sh +14 -1
- package/hooks/preemptive-compaction.sh +14 -1
- package/hooks/rules-injector.sh +14 -1
- package/hooks/session-notification.sh +17 -3
- package/hooks/session-recovery.sh +12 -2
- package/hooks/stop-continuation-guard.sh +37 -0
- package/hooks/task-checkpointing.sh +14 -1
- package/hooks/think-mode.sh +14 -1
- package/hooks/thinking-block-validator.sh +14 -3
- package/hooks/tmux-agent-visualizer.sh +17 -2
- package/hooks/todo-continuation-enforcer.sh +105 -0
- package/hooks/write-existing-file-guard.sh +100 -0
- package/package.json +1 -1
- package/skills/agent-browser/SKILL.md +385 -146
- package/skills/dev-browser/SKILL.md +136 -0
- package/skills/frontend-ui-ux/SKILL.md +95 -3
- package/skills/git-master/SKILL.md +561 -386
|
@@ -12,434 +12,737 @@ triggers:
|
|
|
12
12
|
# Git Master 技能
|
|
13
13
|
|
|
14
14
|
智能 Git 操作技能,提供安全、规范的版本控制操作指引。
|
|
15
|
+
实现 6 阶段提交工作流、3 模式检测、强制性输出校验。
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Git Master 包含三个专业化角色,根据任务自动切换:
|
|
17
|
+
---
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
## 模式检测(第一步 - 必须执行)
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
> **⚠️ CRITICAL**: 收到任何 Git 相关请求时,必须**首先**判定操作模式。
|
|
22
|
+
> 不可跳过此步骤直接执行任何 Git 命令。
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
| 用户请求模式 | 检测关键词 | 激活模式 |
|
|
25
|
+
|-------------|-----------|---------|
|
|
26
|
+
| "提交" "commit" "暂存" "stage" | commit, add, stage, push, 提交, 暂存 | **COMMIT** → 进入 Phase 0-6 |
|
|
27
|
+
| "变基" "rebase" "squash" "整理历史" | rebase, squash, fixup, amend, 变基, 合并提交 | **REBASE** → 进入 R1-R4 |
|
|
28
|
+
| "谁改的" "blame" "查找" "什么时候引入" | blame, bisect, log -S, 谁, 何时, 查找, 历史 | **HISTORY_SEARCH** → 进入 H1-H3 |
|
|
25
29
|
|
|
26
30
|
```
|
|
27
|
-
|
|
28
|
-
│
|
|
29
|
-
|
|
30
|
-
│
|
|
31
|
-
│
|
|
32
|
-
│
|
|
33
|
-
|
|
31
|
+
┌─────────────────────────────────────────────┐
|
|
32
|
+
│ MODE DETECTION (MANDATORY FIRST STEP) │
|
|
33
|
+
├─────────────────────────────────────────────┤
|
|
34
|
+
│ │
|
|
35
|
+
│ 用户请求 ──→ 关键词匹配 │
|
|
36
|
+
│ ├─ commit/push/stage │
|
|
37
|
+
│ │ → COMMIT MODE (Phase 0-6) │
|
|
38
|
+
│ ├─ rebase/squash/fixup │
|
|
39
|
+
│ │ → REBASE MODE (R1-R4) │
|
|
40
|
+
│ └─ blame/bisect/log -S │
|
|
41
|
+
│ → HISTORY SEARCH (H1-H3) │
|
|
42
|
+
│ │
|
|
43
|
+
│ ⚠️ 无法判定 → 询问用户明确意图 │
|
|
44
|
+
└─────────────────────────────────────────────┘
|
|
34
45
|
```
|
|
35
46
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 核心原则:默认多提交
|
|
50
|
+
|
|
51
|
+
> **🔴 HARD RULE — 不可违反**
|
|
40
52
|
|
|
41
|
-
|
|
53
|
+
| 变更文件数 | 最少提交数 | 强制性 |
|
|
54
|
+
|-----------|-----------|--------|
|
|
55
|
+
| 1-2 文件 | 1 个提交 | 可选 |
|
|
56
|
+
| 3-4 文件 | 2+ 个提交 | **MANDATORY** |
|
|
57
|
+
| 5-9 文件 | 3+ 个提交 | **MANDATORY** |
|
|
58
|
+
| 10+ 文件 | 5+ 个提交 | **MANDATORY** |
|
|
42
59
|
|
|
43
|
-
|
|
60
|
+
**最小提交数公式**: `min_commits = ceil(file_count / 3)`
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
- 交互式 rebase 操作
|
|
47
|
-
- 冲突解决策略
|
|
48
|
-
- 分支合并整理
|
|
49
|
-
- Squash 和 fixup 操作
|
|
62
|
+
### 拆分判定标准
|
|
50
63
|
|
|
51
|
-
|
|
64
|
+
| 拆分条件 | 说明 | 优先级 |
|
|
65
|
+
|---------|------|--------|
|
|
66
|
+
| 不同目录 | `src/` vs `tests/` vs `docs/` | **最高** |
|
|
67
|
+
| 不同组件类型 | 配置 vs 类型 vs 实现 vs 测试 | 高 |
|
|
68
|
+
| 不同关注点 | 基础设施 vs 业务逻辑 | 高 |
|
|
69
|
+
| 不同依赖层 | 被依赖方先提交 | 中 |
|
|
70
|
+
| 实现+测试配对 | 同一功能的实现和测试可合并 | 低 |
|
|
52
71
|
|
|
53
|
-
|
|
72
|
+
### 提交前强制自检
|
|
54
73
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
74
|
+
> **⚠️ HARD STOP**: 执行 `git commit` 前,必须完成以下检查。
|
|
75
|
+
> 任何一项不通过,**禁止**继续提交。
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
┌─────────────────────────────────────────────┐
|
|
79
|
+
│ PRE-COMMIT SELF-CHECK (MANDATORY) │
|
|
80
|
+
├─────────────────────────────────────────────┤
|
|
81
|
+
│ □ 文件数 ≤ 2? 或已按规则拆分? │
|
|
82
|
+
│ □ 每个提交只做一件事? │
|
|
83
|
+
│ □ 提交消息匹配检测到的仓库风格? │
|
|
84
|
+
│ □ 无敏感文件(.env, credentials 等)? │
|
|
85
|
+
│ □ 提交间有清晰的依赖关系? │
|
|
86
|
+
│ □ 3+ 文件的提交有书面理由? │
|
|
87
|
+
│ │
|
|
88
|
+
│ ✗ 任一未通过 → 回到 Phase 3 重新规划 │
|
|
89
|
+
└─────────────────────────────────────────────┘
|
|
90
|
+
```
|
|
60
91
|
|
|
61
92
|
---
|
|
62
93
|
|
|
63
|
-
##
|
|
94
|
+
## COMMIT MODE: Phase 0-6 工作流
|
|
64
95
|
|
|
65
|
-
|
|
96
|
+
### Phase 0: 并行上下文收集
|
|
66
97
|
|
|
67
|
-
|
|
98
|
+
> **所有命令必须并行执行**,减少等待时间。
|
|
68
99
|
|
|
69
100
|
```bash
|
|
70
|
-
#
|
|
101
|
+
# 并行执行以下 4 组命令:
|
|
102
|
+
|
|
103
|
+
# [1] 工作区状态
|
|
104
|
+
git status
|
|
105
|
+
|
|
106
|
+
# [2] 变更详情(暂存 + 未暂存)
|
|
107
|
+
git diff
|
|
108
|
+
git diff --staged
|
|
109
|
+
|
|
110
|
+
# [3] 仓库提交风格(最近 30 条)
|
|
71
111
|
git log --oneline -30
|
|
112
|
+
|
|
113
|
+
# [4] 分支上下文
|
|
114
|
+
git branch -vv
|
|
115
|
+
git log --oneline main..HEAD 2>/dev/null || git log --oneline master..HEAD 2>/dev/null
|
|
72
116
|
```
|
|
73
117
|
|
|
74
|
-
|
|
118
|
+
收集结果后立即进入 Phase 1。
|
|
75
119
|
|
|
76
|
-
|
|
77
|
-
|------|------|------|
|
|
78
|
-
| **语言** | 英文 / 中文 / 混合 | `feat: add login` vs `feat: 添加登录` |
|
|
79
|
-
| **风格** | Conventional / Plain / Short | `feat(auth): add OAuth` vs `Add OAuth login` |
|
|
80
|
-
| **大小写** | lowercase / Capitalize / UPPERCASE | `add feature` vs `Add feature` |
|
|
81
|
-
| **长度** | 详细 / 简洁 | 50+ chars vs <30 chars |
|
|
120
|
+
---
|
|
82
121
|
|
|
83
|
-
###
|
|
122
|
+
### Phase 1: 风格检测(BLOCKING OUTPUT)
|
|
84
123
|
|
|
85
|
-
|
|
86
|
-
|
|
124
|
+
> **⚠️ CRITICAL**: 此阶段产生的输出**必须打印**后才能进入下一阶段。
|
|
125
|
+
> 不可在内部静默处理。
|
|
126
|
+
|
|
127
|
+
#### 1.1 语言检测
|
|
128
|
+
|
|
129
|
+
分析 `git log --oneline -30` 的输出,判定主要语言:
|
|
130
|
+
|
|
131
|
+
| 检测模式 | 判定语言 |
|
|
132
|
+
|---------|---------|
|
|
133
|
+
| 多数消息含中文字符 | **中文 (Chinese)** |
|
|
134
|
+
| 多数消息含韩文字符 | **韩文 (Korean)** |
|
|
135
|
+
| 多数消息为 ASCII | **英文 (English)** |
|
|
136
|
+
| 混合出现 | **混合 (Mixed)** → 优先匹配占比最高的语言 |
|
|
137
|
+
|
|
138
|
+
#### 1.2 风格分类
|
|
87
139
|
|
|
88
|
-
|
|
140
|
+
| 风格类型 | 特征 | 示例 |
|
|
141
|
+
|---------|------|------|
|
|
142
|
+
| **SEMANTIC** | `type(scope):` 格式,Conventional Commits | `feat(auth): add OAuth2 login` |
|
|
143
|
+
| **PLAIN** | 动词开头,首字母大写,无前缀 | `Add user authentication` |
|
|
144
|
+
| **SENTENCE** | 完整句子描述 | `Added the authentication module` |
|
|
145
|
+
| **SHORT** | 极简描述,< 20 字符 | `fix typo` |
|
|
146
|
+
|
|
147
|
+
#### 1.3 MANDATORY 输出块
|
|
148
|
+
|
|
149
|
+
> **🔴 BLOCKING**: 必须输出以下格式后才能继续。跳过此输出 = 违反协议。
|
|
150
|
+
|
|
151
|
+
```markdown
|
|
152
|
+
## 📊 风格检测报告
|
|
89
153
|
|
|
90
154
|
| 维度 | 检测结果 | 置信度 |
|
|
91
155
|
|------|----------|--------|
|
|
92
|
-
| 语言 |
|
|
93
|
-
| 格式 |
|
|
94
|
-
| 大小写 | lowercase |
|
|
95
|
-
| 平均长度 |
|
|
156
|
+
| 语言 | {English/Chinese/Korean/Mixed} | {N}% |
|
|
157
|
+
| 格式 | {SEMANTIC/PLAIN/SENTENCE/SHORT} | {N}% |
|
|
158
|
+
| 大小写 | {lowercase/Capitalize} | {N}% |
|
|
159
|
+
| 平均长度 | {N} 字符 | - |
|
|
96
160
|
|
|
97
|
-
|
|
161
|
+
**采用风格**: `{检测到的风格模板}`
|
|
162
|
+
**示例**: `{基于检测风格的示例消息}`
|
|
98
163
|
```
|
|
99
164
|
|
|
100
|
-
|
|
165
|
+
---
|
|
101
166
|
|
|
102
|
-
###
|
|
167
|
+
### Phase 2: 分支上下文分析
|
|
103
168
|
|
|
104
|
-
|
|
105
|
-
|----------|------|
|
|
106
|
-
| 更新 git config | 可能影响全局设置 |
|
|
107
|
-
| 运行破坏性/不可逆命令 | 除非用户明确请求 |
|
|
108
|
-
| 跳过 hooks | `--no-verify`, `--no-gpg-sign` 等 |
|
|
109
|
-
| 强制推送到 main/master | 如果用户请求,发出警告 |
|
|
110
|
-
| 未经请求就提交 | 用户必须明确要求 |
|
|
111
|
-
|
|
112
|
-
### 危险命令白名单(需用户明确请求):
|
|
169
|
+
#### 2.1 分支状态判定
|
|
113
170
|
|
|
114
171
|
```bash
|
|
115
|
-
|
|
116
|
-
git
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
git
|
|
172
|
+
# 检查当前分支
|
|
173
|
+
git branch --show-current
|
|
174
|
+
|
|
175
|
+
# 检查与远程的关系
|
|
176
|
+
git status -sb
|
|
177
|
+
|
|
178
|
+
# 检查是否有未推送的提交
|
|
179
|
+
git log @{u}..HEAD --oneline 2>/dev/null
|
|
120
180
|
```
|
|
121
181
|
|
|
122
|
-
|
|
182
|
+
#### 2.2 历史重写安全评估
|
|
123
183
|
|
|
124
|
-
|
|
184
|
+
| 条件 | 判定 | 操作 |
|
|
185
|
+
|------|------|------|
|
|
186
|
+
| 当前在 main/master | **禁止重写** | 仅允许新提交 |
|
|
187
|
+
| 分支已推送到远程且有协作者 | **风险高** | 警告用户,需明确确认 |
|
|
188
|
+
| 本地分支,未推送 | **安全** | 可自由 rebase/amend |
|
|
189
|
+
| 分支已推送但仅自己使用 | **需确认** | 可 force push,但需用户确认 |
|
|
125
190
|
|
|
126
|
-
|
|
127
|
-
2. HEAD commit 是由你在本次对话中创建的(验证:`git log -1 --format='%an %ae'`)
|
|
128
|
-
3. Commit 还没有推送到远程(验证:`git status` 显示 "Your branch is ahead")
|
|
191
|
+
#### 2.3 策略决定
|
|
129
192
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
193
|
+
```
|
|
194
|
+
分支状态 ──→ 本地未推送?
|
|
195
|
+
├─ 是 → 可使用 fixup + autosquash
|
|
196
|
+
└─ 否 → 已推送?
|
|
197
|
+
├─ 是 → 仅新提交(除非用户要求 force push)
|
|
198
|
+
└─ 检查远程 → 决定策略
|
|
199
|
+
```
|
|
133
200
|
|
|
134
201
|
---
|
|
135
202
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
### 步骤 1: 了解状态
|
|
203
|
+
### Phase 3: 原子单元规划(BLOCKING OUTPUT)
|
|
139
204
|
|
|
140
|
-
|
|
205
|
+
> **⚠️ CRITICAL**: 此阶段产生的提交计划**必须打印**并等待确认后才能执行。
|
|
141
206
|
|
|
142
|
-
|
|
143
|
-
# 查看所有未跟踪文件
|
|
144
|
-
git status
|
|
207
|
+
#### 3.1 计算最小提交数
|
|
145
208
|
|
|
146
|
-
|
|
147
|
-
|
|
209
|
+
```
|
|
210
|
+
file_count = len(changed_files)
|
|
211
|
+
min_commits = max(1, ceil(file_count / 3))
|
|
148
212
|
|
|
149
|
-
#
|
|
150
|
-
|
|
213
|
+
# 硬性下限校验
|
|
214
|
+
if file_count >= 3 and planned_commits < 2: REJECT
|
|
215
|
+
if file_count >= 5 and planned_commits < 3: REJECT
|
|
216
|
+
if file_count >= 10 and planned_commits < 5: REJECT
|
|
151
217
|
```
|
|
152
218
|
|
|
153
|
-
|
|
219
|
+
#### 3.2 拆分策略
|
|
154
220
|
|
|
155
|
-
|
|
221
|
+
按以下优先级拆分:
|
|
156
222
|
|
|
157
|
-
1.
|
|
158
|
-
2.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
- `fix` = bug 修复
|
|
162
|
-
- `refactor` = 代码重组
|
|
163
|
-
3. **不要提交可能包含敏感信息的文件**(`.env`, `credentials.json` 等)
|
|
164
|
-
4. **起草简洁的提交消息**(1-2 句),聚焦"为什么"而非"做什么"
|
|
223
|
+
1. **目录/模块优先**: 不同目录的文件分到不同提交
|
|
224
|
+
2. **关注点分离**: 配置 → 类型/接口 → 实现 → 测试 → 文档
|
|
225
|
+
3. **依赖排序**: 被依赖的代码先提交
|
|
226
|
+
4. **实现+测试配对**: 同一功能的实现文件和测试文件**可以**放同一提交
|
|
165
227
|
|
|
166
|
-
|
|
228
|
+
#### 3.3 3+ 文件提交的强制理由
|
|
167
229
|
|
|
168
|
-
|
|
169
|
-
# 添加相关的未跟踪文件到暂存区
|
|
170
|
-
git add <files>
|
|
230
|
+
> **🔴 MANDATORY**: 任何包含 3 个及以上文件的单次提交,**必须**附带书面理由。
|
|
171
231
|
|
|
172
|
-
|
|
173
|
-
|
|
232
|
+
合理理由示例:
|
|
233
|
+
- "这三个文件属于同一组件的不同层(model/service/controller),拆分会破坏编译"
|
|
234
|
+
- "重命名操作跨越多个文件,必须原子性完成"
|
|
235
|
+
- "配置文件和配套的类型声明必须同步更新"
|
|
174
236
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
```
|
|
237
|
+
不可接受的理由:
|
|
238
|
+
- "方便" "文件太少不值得拆" "一起提交更快"
|
|
178
239
|
|
|
179
|
-
|
|
240
|
+
#### 3.4 MANDATORY 输出块
|
|
180
241
|
|
|
181
|
-
|
|
182
|
-
1. 修复问题
|
|
183
|
-
2. 创建**新**提交(不要 amend)
|
|
242
|
+
> **🔴 BLOCKING**: 必须输出以下提交计划后才能进入 Phase 4。
|
|
184
243
|
|
|
185
|
-
|
|
244
|
+
```markdown
|
|
245
|
+
## 📋 提交计划
|
|
186
246
|
|
|
187
|
-
|
|
247
|
+
**变更文件数**: {N} 个
|
|
248
|
+
**计划提交数**: {M} 个 (最小要求: {min_commits})
|
|
188
249
|
|
|
189
|
-
###
|
|
250
|
+
### Commit 1: `{type}({scope}): {description}`
|
|
251
|
+
- `path/to/file1.ts` — {变更说明}
|
|
252
|
+
- `path/to/file2.ts` — {变更说明}
|
|
190
253
|
|
|
191
|
-
|
|
192
|
-
|
|
254
|
+
### Commit 2: `{type}({scope}): {description}`
|
|
255
|
+
- `path/to/file3.ts` — {变更说明}
|
|
193
256
|
|
|
194
|
-
|
|
257
|
+
{3+ 文件理由(如适用): ...}
|
|
195
258
|
|
|
196
|
-
|
|
259
|
+
### 依赖关系
|
|
260
|
+
Commit 1 → Commit 2 → Commit 3
|
|
261
|
+
(每个提交可独立编译通过)
|
|
197
262
|
```
|
|
198
263
|
|
|
199
|
-
|
|
264
|
+
---
|
|
200
265
|
|
|
201
|
-
|
|
266
|
+
### Phase 4: 提交策略决定
|
|
267
|
+
|
|
268
|
+
#### 4.1 Fixup vs 新提交
|
|
269
|
+
|
|
270
|
+
| 条件 | 策略 | 命令 |
|
|
202
271
|
|------|------|------|
|
|
203
|
-
|
|
|
204
|
-
|
|
|
205
|
-
|
|
|
206
|
-
|
|
|
207
|
-
| `refactor` | 重构 | `refactor(utils): simplify parser` |
|
|
208
|
-
| `perf` | 性能优化 | `perf(query): add database index` |
|
|
209
|
-
| `test` | 测试相关 | `test(auth): add login tests` |
|
|
210
|
-
| `build` | 构建系统 | `build: upgrade webpack to v5` |
|
|
211
|
-
| `ci` | CI 配置 | `ci: add GitHub Actions` |
|
|
212
|
-
| `chore` | 杂项 | `chore: update dependencies` |
|
|
213
|
-
| `revert` | 回退 | `revert: revert commit abc123` |
|
|
272
|
+
| 修复前序提交的 bug | fixup | `git commit --fixup=<hash>` |
|
|
273
|
+
| 补充前序提交遗漏的文件 | fixup | `git commit --fixup=<hash>` |
|
|
274
|
+
| 独立的新变更 | 新提交 | `git commit -m "..."` |
|
|
275
|
+
| 用户明确要求 amend | amend | `git commit --amend` (需满足 amend 规则) |
|
|
214
276
|
|
|
215
|
-
|
|
277
|
+
#### 4.2 历史重建决定
|
|
216
278
|
|
|
217
|
-
**简单提交**:
|
|
218
279
|
```
|
|
219
|
-
|
|
280
|
+
使用了 fixup?
|
|
281
|
+
├─ 是 → Phase 6 中执行 autosquash rebase
|
|
282
|
+
└─ 否 → 直接进入 Phase 5
|
|
220
283
|
|
|
221
|
-
|
|
222
|
-
|
|
284
|
+
分支已推送?
|
|
285
|
+
├─ 是 → 需要 force push(需用户确认)
|
|
286
|
+
└─ 否 → 安全执行
|
|
223
287
|
```
|
|
224
288
|
|
|
225
|
-
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
### Phase 5: 提交执行
|
|
292
|
+
|
|
293
|
+
#### 5.1 TodoWrite 注册
|
|
294
|
+
|
|
295
|
+
> 使用 TodoWrite 注册每个提交为独立任务,确保进度可追踪。
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
TODO 1: [pending] Commit 1 - {description}
|
|
299
|
+
TODO 2: [pending] Commit 2 - {description}
|
|
300
|
+
TODO 3: [pending] Commit 3 - {description}
|
|
226
301
|
```
|
|
227
|
-
feat(api)!: change response format
|
|
228
302
|
|
|
229
|
-
|
|
230
|
-
|
|
303
|
+
#### 5.2 执行每个提交
|
|
304
|
+
|
|
305
|
+
对计划中的每个提交,按顺序执行:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
# 1. 暂存文件
|
|
309
|
+
git add <file1> <file2>
|
|
310
|
+
|
|
311
|
+
# 2. 执行提交(消息匹配 Phase 1 检测到的风格)
|
|
312
|
+
git commit -m "<message>"
|
|
313
|
+
|
|
314
|
+
# 3. 验证
|
|
315
|
+
git status
|
|
316
|
+
git log --oneline -1
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
#### 5.3 提交消息生成规则
|
|
320
|
+
|
|
321
|
+
- **必须**匹配 Phase 1 检测到的风格
|
|
322
|
+
- **SEMANTIC 风格**: `<type>(<scope>): <lowercase description>`
|
|
323
|
+
- **PLAIN 风格**: `<Verb> <description>`
|
|
324
|
+
- **SENTENCE 风格**: `<Past tense sentence>`
|
|
325
|
+
- **SHORT 风格**: `<brief phrase>`
|
|
326
|
+
- **中文仓库**: 描述部分使用中文
|
|
327
|
+
|
|
328
|
+
#### 5.4 Hook 失败处理
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
提交被 pre-commit hook 拒绝?
|
|
332
|
+
├─ 查看 hook 输出,了解失败原因
|
|
333
|
+
├─ 修复问题(lint、格式、测试等)
|
|
334
|
+
├─ 重新暂存修改后的文件
|
|
335
|
+
├─ 创建新提交(⚠️ 绝对不要 amend 失败的提交)
|
|
336
|
+
└─ 更新 TODO 状态
|
|
231
337
|
```
|
|
232
338
|
|
|
233
339
|
---
|
|
234
340
|
|
|
235
|
-
|
|
341
|
+
### Phase 6: 验证与清理
|
|
236
342
|
|
|
237
|
-
|
|
343
|
+
#### 6.1 提交后验证
|
|
238
344
|
|
|
239
|
-
|
|
345
|
+
```bash
|
|
346
|
+
# 检查所有提交是否成功
|
|
347
|
+
git log --oneline -N # N = 计划提交数
|
|
240
348
|
|
|
349
|
+
# 确认工作区干净
|
|
350
|
+
git status
|
|
351
|
+
|
|
352
|
+
# 确认无遗漏文件
|
|
353
|
+
git diff
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
#### 6.2 Force Push 决定
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
使用了 fixup/autosquash?
|
|
360
|
+
├─ 是 → git rebase -i --autosquash <base>
|
|
361
|
+
│ ├─ 分支未推送? → 安全执行
|
|
362
|
+
│ └─ 分支已推送? → 需用户明确确认 force push
|
|
363
|
+
└─ 否 → 无需额外操作
|
|
241
364
|
```
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
│ - 每个提交可独立编译通过 │
|
|
257
|
-
│ - 每个提交有清晰的目的 │
|
|
258
|
-
└─────────────────────────────────────────────────────────────┘
|
|
365
|
+
|
|
366
|
+
#### 6.3 最终报告
|
|
367
|
+
|
|
368
|
+
```markdown
|
|
369
|
+
## ✅ 提交完成报告
|
|
370
|
+
|
|
371
|
+
| 提交 | 类型 | 消息 | 文件数 |
|
|
372
|
+
|------|------|------|--------|
|
|
373
|
+
| {hash1} | feat | {msg1} | {N} |
|
|
374
|
+
| {hash2} | test | {msg2} | {N} |
|
|
375
|
+
|
|
376
|
+
**总计**: {M} 个提交,{N} 个文件
|
|
377
|
+
**分支**: {branch_name}
|
|
378
|
+
**状态**: {已推送/待推送/待 force push}
|
|
259
379
|
```
|
|
260
380
|
|
|
261
|
-
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## REBASE MODE: R1-R4
|
|
262
384
|
|
|
263
|
-
|
|
385
|
+
### R1: 上下文分析与安全评估
|
|
264
386
|
|
|
387
|
+
```bash
|
|
388
|
+
# 并行执行
|
|
389
|
+
git log --oneline -20
|
|
390
|
+
git branch -vv
|
|
391
|
+
git status
|
|
392
|
+
git log @{u}..HEAD --oneline 2>/dev/null
|
|
265
393
|
```
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
394
|
+
|
|
395
|
+
**安全检查清单**:
|
|
396
|
+
|
|
397
|
+
| 检查项 | 安全 | 危险 |
|
|
398
|
+
|--------|------|------|
|
|
399
|
+
| 当前分支 | feature/* | main/master |
|
|
400
|
+
| 远程状态 | 未推送 | 已推送(需 force push) |
|
|
401
|
+
| 协作者 | 仅自己 | 多人协作 |
|
|
402
|
+
| 工作区 | 干净 | 有未提交更改 |
|
|
403
|
+
|
|
404
|
+
> **🔴 HARD STOP**: 如果在 main/master 分支上,**禁止**执行 rebase。
|
|
405
|
+
> 必须先切换到 feature 分支。
|
|
406
|
+
|
|
407
|
+
### R2: 执行 Rebase
|
|
408
|
+
|
|
409
|
+
#### 交互式 Rebase
|
|
410
|
+
|
|
411
|
+
```bash
|
|
412
|
+
# 编辑最近 N 个提交
|
|
413
|
+
git rebase -i HEAD~N
|
|
414
|
+
|
|
415
|
+
# 从某个提交开始
|
|
416
|
+
git rebase -i <commit>^
|
|
277
417
|
```
|
|
278
418
|
|
|
279
|
-
|
|
419
|
+
#### Rebase 操作符
|
|
420
|
+
|
|
421
|
+
| 操作 | 缩写 | 说明 |
|
|
422
|
+
|------|------|------|
|
|
423
|
+
| pick | p | 保留提交 |
|
|
424
|
+
| reword | r | 修改提交消息 |
|
|
425
|
+
| edit | e | 停下来修改内容 |
|
|
426
|
+
| squash | s | 合并到前一个提交(保留消息) |
|
|
427
|
+
| fixup | f | 合并到前一个提交(丢弃消息) |
|
|
428
|
+
| drop | d | 删除提交 |
|
|
429
|
+
|
|
430
|
+
#### Autosquash 工作流
|
|
280
431
|
|
|
281
432
|
```bash
|
|
282
|
-
#
|
|
283
|
-
git
|
|
284
|
-
|
|
433
|
+
# 先创建 fixup 提交
|
|
434
|
+
git commit --fixup=<target_hash>
|
|
435
|
+
|
|
436
|
+
# 然后自动整理
|
|
437
|
+
git rebase -i --autosquash <base_commit>
|
|
438
|
+
```
|
|
285
439
|
|
|
286
|
-
|
|
287
|
-
git add src/types/user.ts src/utils/validation.ts
|
|
288
|
-
git commit -m "feat(types): add user types and validation utils"
|
|
440
|
+
#### Onto Rebase(变更基底)
|
|
289
441
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
git
|
|
442
|
+
```bash
|
|
443
|
+
# 将分支移到新基底
|
|
444
|
+
git rebase --onto <new_base> <old_base> <branch>
|
|
445
|
+
```
|
|
293
446
|
|
|
294
|
-
|
|
295
|
-
git add src/controllers/auth.ts src/routes/auth.ts
|
|
296
|
-
git commit -m "feat(api): add auth controller and routes"
|
|
447
|
+
### R3: 冲突解决与验证
|
|
297
448
|
|
|
298
|
-
# Commit 5: 测试和文档
|
|
299
|
-
git add tests/auth.test.ts README.md
|
|
300
|
-
git commit -m "test(auth): add auth service tests and docs"
|
|
301
449
|
```
|
|
450
|
+
冲突发生时:
|
|
451
|
+
1. git status — 查看冲突文件
|
|
452
|
+
2. 打开文件,找到 <<<< ==== >>>> 标记
|
|
453
|
+
3. 选择保留内容,删除冲突标记
|
|
454
|
+
4. git add <resolved_files> — 标记已解决
|
|
455
|
+
5. git rebase --continue — 继续 rebase
|
|
456
|
+
6. 重复直到所有冲突解决
|
|
302
457
|
|
|
303
|
-
|
|
458
|
+
放弃 rebase:
|
|
459
|
+
git rebase --abort
|
|
460
|
+
```
|
|
304
461
|
|
|
462
|
+
**验证**:
|
|
463
|
+
|
|
464
|
+
```bash
|
|
465
|
+
# Rebase 完成后
|
|
466
|
+
git log --oneline -10
|
|
467
|
+
git diff <base_branch>..HEAD --stat
|
|
305
468
|
```
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
469
|
+
|
|
470
|
+
### R4: 报告
|
|
471
|
+
|
|
472
|
+
```markdown
|
|
473
|
+
## 📋 Rebase 报告
|
|
474
|
+
|
|
475
|
+
**操作**: {interactive/autosquash/onto}
|
|
476
|
+
**分支**: {branch_name}
|
|
477
|
+
**结果**:
|
|
478
|
+
- 提交数: {before} → {after}
|
|
479
|
+
- 冲突: {N} 个(已全部解决)
|
|
480
|
+
- 状态: {需要 force push / 已完成}
|
|
481
|
+
|
|
482
|
+
**变更提交**:
|
|
483
|
+
| 序号 | Hash | 消息 |
|
|
484
|
+
|------|------|------|
|
|
485
|
+
| 1 | {hash} | {message} |
|
|
315
486
|
```
|
|
316
487
|
|
|
317
488
|
---
|
|
318
489
|
|
|
319
|
-
##
|
|
490
|
+
## HISTORY SEARCH MODE: H1-H3
|
|
491
|
+
|
|
492
|
+
### H1: 确定搜索类型
|
|
320
493
|
|
|
321
|
-
|
|
494
|
+
| 用户意图 | 搜索类型 | 使用命令 |
|
|
495
|
+
|---------|---------|---------|
|
|
496
|
+
| "谁修改了这行代码" | **blame** | `git blame` |
|
|
497
|
+
| "这个函数什么时候添加的" | **pickaxe** | `git log -S` |
|
|
498
|
+
| "匹配某个模式的提交" | **regex** | `git log -G` |
|
|
499
|
+
| "这个 bug 哪个提交引入的" | **bisect** | `git bisect` |
|
|
500
|
+
| "这个文件的修改历史" | **file_log** | `git log --follow` |
|
|
501
|
+
|
|
502
|
+
### H2: 执行搜索
|
|
503
|
+
|
|
504
|
+
#### Blame(追溯)
|
|
322
505
|
|
|
323
506
|
```bash
|
|
324
|
-
#
|
|
507
|
+
# 查看文件每行的最后修改者
|
|
325
508
|
git blame <file>
|
|
326
509
|
|
|
327
|
-
#
|
|
510
|
+
# 指定行范围
|
|
328
511
|
git blame -L 10,20 <file>
|
|
329
512
|
|
|
330
|
-
#
|
|
513
|
+
# 忽略空白变更
|
|
331
514
|
git blame -w <file>
|
|
332
515
|
|
|
333
516
|
# 显示邮箱
|
|
334
517
|
git blame -e <file>
|
|
518
|
+
|
|
519
|
+
# 追溯到更早版本(忽略最近一次变更)
|
|
520
|
+
git blame <commit>^ -- <file>
|
|
335
521
|
```
|
|
336
522
|
|
|
337
|
-
|
|
523
|
+
#### Pickaxe(代码搜索)
|
|
338
524
|
|
|
339
525
|
```bash
|
|
340
526
|
# 搜索添加/删除特定字符串的提交
|
|
341
527
|
git log -S "functionName" --oneline
|
|
342
528
|
|
|
343
|
-
#
|
|
529
|
+
# 显示差异
|
|
530
|
+
git log -S "functionName" -p
|
|
531
|
+
|
|
532
|
+
# 限定文件范围
|
|
533
|
+
git log -S "functionName" -- "src/**/*.ts"
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
#### Regex(正则搜索)
|
|
537
|
+
|
|
538
|
+
```bash
|
|
539
|
+
# 搜索匹配正则表达式的提交
|
|
344
540
|
git log -G "pattern.*regex" --oneline
|
|
345
541
|
|
|
346
542
|
# 显示差异
|
|
347
|
-
git log -
|
|
543
|
+
git log -G "pattern.*regex" -p
|
|
348
544
|
```
|
|
349
545
|
|
|
350
|
-
|
|
546
|
+
#### Bisect(二分查找)
|
|
351
547
|
|
|
352
548
|
```bash
|
|
353
549
|
# 开始二分
|
|
354
550
|
git bisect start
|
|
355
551
|
|
|
356
|
-
#
|
|
552
|
+
# 标记当前为坏版本
|
|
357
553
|
git bisect bad
|
|
358
554
|
|
|
359
555
|
# 标记已知好的版本
|
|
360
556
|
git bisect good <commit>
|
|
361
557
|
|
|
362
|
-
# Git
|
|
363
|
-
git bisect good # 或
|
|
364
|
-
git bisect bad
|
|
558
|
+
# Git 自动切换到中间版本,测试后标记:
|
|
559
|
+
git bisect good # 或 git bisect bad
|
|
365
560
|
|
|
366
561
|
# 找到后重置
|
|
367
562
|
git bisect reset
|
|
368
563
|
```
|
|
369
564
|
|
|
370
|
-
|
|
565
|
+
#### File Log(文件历史)
|
|
566
|
+
|
|
567
|
+
```bash
|
|
568
|
+
# 查看文件完整修改历史
|
|
569
|
+
git log --follow --oneline -- <file>
|
|
570
|
+
|
|
571
|
+
# 显示差异
|
|
572
|
+
git log --follow -p -- <file>
|
|
573
|
+
|
|
574
|
+
# 仅显示统计
|
|
575
|
+
git log --follow --stat -- <file>
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
### H3: 结果呈现
|
|
579
|
+
|
|
580
|
+
> 搜索结果必须以结构化格式呈现,附带可操作的上下文。
|
|
371
581
|
|
|
372
582
|
```markdown
|
|
373
|
-
##
|
|
583
|
+
## 🔍 历史搜索报告
|
|
584
|
+
|
|
585
|
+
### 搜索目标
|
|
586
|
+
{要查找的代码/功能/问题}
|
|
374
587
|
|
|
375
|
-
###
|
|
376
|
-
|
|
588
|
+
### 搜索方法
|
|
589
|
+
{blame/pickaxe/regex/bisect/file_log}
|
|
377
590
|
|
|
378
591
|
### 发现
|
|
379
592
|
|
|
380
|
-
| 提交 | 日期 | 作者 |
|
|
381
|
-
|
|
382
|
-
|
|
|
383
|
-
|
|
|
384
|
-
| ghi789 | 2024-03-10 | Alice | Bug 修复 |
|
|
593
|
+
| 提交 | 日期 | 作者 | 变更说明 |
|
|
594
|
+
|------|------|------|---------|
|
|
595
|
+
| {hash1} | {date1} | {author1} | {description1} |
|
|
596
|
+
| {hash2} | {date2} | {author2} | {description2} |
|
|
385
597
|
|
|
386
598
|
### 关键变更点
|
|
387
|
-
|
|
599
|
+
{重要的变更说明和上下文}
|
|
388
600
|
|
|
389
|
-
###
|
|
390
|
-
|
|
601
|
+
### 可操作建议
|
|
602
|
+
- {基于发现的建议 1}
|
|
603
|
+
- {基于发现的建议 2}
|
|
391
604
|
```
|
|
392
605
|
|
|
393
606
|
---
|
|
394
607
|
|
|
395
|
-
##
|
|
608
|
+
## 快速参考
|
|
396
609
|
|
|
397
|
-
###
|
|
610
|
+
### 风格检测速查
|
|
398
611
|
|
|
399
|
-
```
|
|
400
|
-
|
|
401
|
-
|
|
612
|
+
```
|
|
613
|
+
SEMANTIC: feat(scope): description ← 有 type( 前缀
|
|
614
|
+
PLAIN: Add user authentication ← 首字母大写动词开头
|
|
615
|
+
SENTENCE: Added the auth module ← 过去式完整句子
|
|
616
|
+
SHORT: fix typo ← < 20 字符
|
|
617
|
+
```
|
|
402
618
|
|
|
403
|
-
|
|
404
|
-
|
|
619
|
+
### 决策树
|
|
620
|
+
|
|
621
|
+
```
|
|
622
|
+
收到 Git 请求
|
|
623
|
+
├─ 提交类? → COMMIT MODE
|
|
624
|
+
│ ├─ Phase 0: 并行收集上下文
|
|
625
|
+
│ ├─ Phase 1: 风格检测 [BLOCKING OUTPUT]
|
|
626
|
+
│ ├─ Phase 2: 分支上下文
|
|
627
|
+
│ ├─ Phase 3: 原子规划 [BLOCKING OUTPUT]
|
|
628
|
+
│ ├─ Phase 4: 策略决定
|
|
629
|
+
│ ├─ Phase 5: 逐个执行
|
|
630
|
+
│ └─ Phase 6: 验证报告
|
|
631
|
+
├─ Rebase 类? → REBASE MODE
|
|
632
|
+
│ ├─ R1: 安全评估
|
|
633
|
+
│ ├─ R2: 执行操作
|
|
634
|
+
│ ├─ R3: 冲突解决
|
|
635
|
+
│ └─ R4: 报告
|
|
636
|
+
└─ 历史查询类? → HISTORY SEARCH
|
|
637
|
+
├─ H1: 确定搜索类型
|
|
638
|
+
├─ H2: 执行搜索
|
|
639
|
+
└─ H3: 结果呈现
|
|
405
640
|
```
|
|
406
641
|
|
|
407
|
-
###
|
|
642
|
+
### 反模式清单
|
|
408
643
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
|
412
|
-
|
|
413
|
-
|
|
|
414
|
-
|
|
|
415
|
-
|
|
|
416
|
-
|
|
|
644
|
+
> **🚫 以下行为绝对禁止**:
|
|
645
|
+
|
|
646
|
+
| 反模式 | 正确做法 |
|
|
647
|
+
|--------|---------|
|
|
648
|
+
| 跳过风格检测直接提交 | 必须先完成 Phase 1 |
|
|
649
|
+
| 10 个文件一次提交 | 按规则拆分为 5+ 个提交 |
|
|
650
|
+
| 不打印 BLOCKING OUTPUT | Phase 1 和 Phase 3 的输出不可省略 |
|
|
651
|
+
| 对失败的提交执行 amend | 修复后创建新提交 |
|
|
652
|
+
| 在 main 上执行 rebase | 切换到 feature 分支 |
|
|
653
|
+
| 不检查分支安全就 force push | 先完成 R1 安全评估 |
|
|
654
|
+
| 3+ 文件提交无理由 | 必须附带书面理由 |
|
|
655
|
+
| 内部消化风格检测结果 | 必须输出格式化报告 |
|
|
656
|
+
|
|
657
|
+
---
|
|
658
|
+
|
|
659
|
+
## 安全协议(不可违反)
|
|
660
|
+
|
|
661
|
+
### 永远不要:
|
|
662
|
+
|
|
663
|
+
| 禁止操作 | 原因 |
|
|
664
|
+
|----------|------|
|
|
665
|
+
| 更新 git config | 可能影响全局设置 |
|
|
666
|
+
| 运行破坏性/不可逆命令 | 除非用户明确请求 |
|
|
667
|
+
| 跳过 hooks | `--no-verify`, `--no-gpg-sign` 等 |
|
|
668
|
+
| 强制推送到 main/master | 如果用户请求,发出警告 |
|
|
669
|
+
| 未经请求就提交 | 用户必须明确要求 |
|
|
417
670
|
|
|
418
|
-
###
|
|
671
|
+
### 危险命令白名单(需用户明确请求):
|
|
419
672
|
|
|
420
673
|
```bash
|
|
421
|
-
|
|
422
|
-
git
|
|
674
|
+
git push --force # 强制推送
|
|
675
|
+
git push -f # 强制推送
|
|
676
|
+
git reset --hard # 硬重置
|
|
677
|
+
git clean -fd # 删除未跟踪文件
|
|
678
|
+
git checkout -- . # 丢弃所有更改
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
### Git Commit --amend 规则
|
|
682
|
+
|
|
683
|
+
**仅在以下所有条件都满足时才能使用 --amend**:
|
|
684
|
+
|
|
685
|
+
1. 用户明确请求 amend,**或者** commit 成功但 pre-commit hook 自动修改了需要包含的文件
|
|
686
|
+
2. HEAD commit 是由你在本次对话中创建的(验证:`git log -1 --format='%an %ae'`)
|
|
687
|
+
3. Commit 还没有推送到远程(验证:`git status` 显示 "Your branch is ahead")
|
|
688
|
+
|
|
689
|
+
**关键**:
|
|
690
|
+
- 如果 commit **失败**或被 hook **拒绝**,**永远不要** amend - 修复问题并创建**新** commit
|
|
691
|
+
- 如果你已经推送到远程,**永远不要** amend(除非用户明确请求,因为需要 force push)
|
|
692
|
+
|
|
693
|
+
---
|
|
694
|
+
|
|
695
|
+
## Conventional Commits 格式
|
|
423
696
|
|
|
424
|
-
|
|
425
|
-
# pick abc123 First commit
|
|
426
|
-
# squash def456 Second commit
|
|
427
|
-
# squash ghi789 Third commit
|
|
697
|
+
### 基本格式
|
|
428
698
|
|
|
429
|
-
# 然后编辑合并后的提交消息
|
|
430
699
|
```
|
|
700
|
+
<type>(<scope>): <description>
|
|
431
701
|
|
|
432
|
-
|
|
702
|
+
[optional body]
|
|
433
703
|
|
|
704
|
+
[optional footer(s)]
|
|
434
705
|
```
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
706
|
+
|
|
707
|
+
### 类型
|
|
708
|
+
|
|
709
|
+
| 类型 | 描述 | 示例 |
|
|
710
|
+
|------|------|------|
|
|
711
|
+
| `feat` | 新功能 | `feat(auth): add OAuth2 login` |
|
|
712
|
+
| `fix` | Bug 修复 | `fix(api): handle null response` |
|
|
713
|
+
| `docs` | 文档更新 | `docs(readme): update installation` |
|
|
714
|
+
| `style` | 代码格式 | `style: format with prettier` |
|
|
715
|
+
| `refactor` | 重构 | `refactor(utils): simplify parser` |
|
|
716
|
+
| `perf` | 性能优化 | `perf(query): add database index` |
|
|
717
|
+
| `test` | 测试相关 | `test(auth): add login tests` |
|
|
718
|
+
| `build` | 构建系统 | `build: upgrade webpack to v5` |
|
|
719
|
+
| `ci` | CI 配置 | `ci: add GitHub Actions` |
|
|
720
|
+
| `chore` | 杂项 | `chore: update dependencies` |
|
|
721
|
+
| `revert` | 回退 | `revert: revert commit abc123` |
|
|
722
|
+
|
|
723
|
+
### 示例
|
|
724
|
+
|
|
725
|
+
**简单提交**:
|
|
442
726
|
```
|
|
727
|
+
feat(user): add email verification
|
|
728
|
+
|
|
729
|
+
Implement email verification flow with token generation
|
|
730
|
+
and expiration handling.
|
|
731
|
+
```
|
|
732
|
+
|
|
733
|
+
**带 Breaking Change**:
|
|
734
|
+
```
|
|
735
|
+
feat(api)!: change response format
|
|
736
|
+
|
|
737
|
+
BREAKING CHANGE: Response now wraps data in { data, meta } structure.
|
|
738
|
+
Migration guide available in docs/migration.md
|
|
739
|
+
```
|
|
740
|
+
|
|
741
|
+
### 语义化版本关联
|
|
742
|
+
|
|
743
|
+
- **`fix:`** → PATCH 版本 (1.0.0 → 1.0.1)
|
|
744
|
+
- **`feat:`** → MINOR 版本 (1.0.0 → 1.1.0)
|
|
745
|
+
- **BREAKING CHANGE** → MAJOR 版本 (1.0.0 → 2.0.0)
|
|
443
746
|
|
|
444
747
|
---
|
|
445
748
|
|
|
@@ -482,11 +785,11 @@ git status
|
|
|
482
785
|
git diff
|
|
483
786
|
|
|
484
787
|
# 检查当前分支是否跟踪远程分支且是最新的
|
|
485
|
-
git status
|
|
788
|
+
git status -sb
|
|
486
789
|
|
|
487
790
|
# 理解从 base 分支分叉以来的完整提交历史
|
|
488
|
-
git log main..HEAD
|
|
489
|
-
git diff main...HEAD
|
|
791
|
+
git log main..HEAD --oneline
|
|
792
|
+
git diff main...HEAD --stat
|
|
490
793
|
```
|
|
491
794
|
|
|
492
795
|
### 步骤 2: 分析所有更改
|
|
@@ -518,39 +821,6 @@ EOF
|
|
|
518
821
|
)"
|
|
519
822
|
```
|
|
520
823
|
|
|
521
|
-
### PR 模板
|
|
522
|
-
|
|
523
|
-
```markdown
|
|
524
|
-
## Summary
|
|
525
|
-
<1-3 个要点描述这个 PR 做了什么>
|
|
526
|
-
|
|
527
|
-
## Changes
|
|
528
|
-
- 变更 1
|
|
529
|
-
- 变更 2
|
|
530
|
-
- ...
|
|
531
|
-
|
|
532
|
-
## Testing
|
|
533
|
-
- 如何测试这些变更
|
|
534
|
-
- 需要注意的测试场景
|
|
535
|
-
|
|
536
|
-
## Related Issues
|
|
537
|
-
Fixes #123
|
|
538
|
-
```
|
|
539
|
-
|
|
540
|
-
---
|
|
541
|
-
|
|
542
|
-
## 分支管理
|
|
543
|
-
|
|
544
|
-
### 创建分支
|
|
545
|
-
|
|
546
|
-
```bash
|
|
547
|
-
# 从当前位置创建
|
|
548
|
-
git checkout -b feature/xxx
|
|
549
|
-
|
|
550
|
-
# 从特定分支创建
|
|
551
|
-
git checkout -b feature/xxx origin/main
|
|
552
|
-
```
|
|
553
|
-
|
|
554
824
|
### 分支命名约定
|
|
555
825
|
|
|
556
826
|
| 前缀 | 用途 | 示例 |
|
|
@@ -562,77 +832,6 @@ git checkout -b feature/xxx origin/main
|
|
|
562
832
|
| `docs/` | 文档 | `docs/api-reference` |
|
|
563
833
|
| `test/` | 测试 | `test/e2e-coverage` |
|
|
564
834
|
|
|
565
|
-
### 保护分支
|
|
566
|
-
|
|
567
|
-
以下分支受保护,操作前需额外确认:
|
|
568
|
-
- `main`
|
|
569
|
-
- `master`
|
|
570
|
-
- `develop`
|
|
571
|
-
- `production`
|
|
572
|
-
|
|
573
|
-
---
|
|
574
|
-
|
|
575
|
-
## 常见操作速查
|
|
576
|
-
|
|
577
|
-
### 查看状态
|
|
578
|
-
|
|
579
|
-
```bash
|
|
580
|
-
git status # 工作区状态
|
|
581
|
-
git diff # 未暂存的更改
|
|
582
|
-
git diff --staged # 已暂存的更改
|
|
583
|
-
git log --oneline -10 # 最近 10 个提交
|
|
584
|
-
git log --graph --oneline # 图形化历史
|
|
585
|
-
```
|
|
586
|
-
|
|
587
|
-
### 暂存更改
|
|
588
|
-
|
|
589
|
-
```bash
|
|
590
|
-
git add <file> # 暂存特定文件
|
|
591
|
-
git add . # 暂存所有更改
|
|
592
|
-
git add -p # 交互式暂存
|
|
593
|
-
git reset HEAD <file> # 取消暂存
|
|
594
|
-
```
|
|
595
|
-
|
|
596
|
-
### 撤销更改
|
|
597
|
-
|
|
598
|
-
```bash
|
|
599
|
-
git checkout -- <file> # 丢弃工作区更改(需用户确认)
|
|
600
|
-
git reset HEAD~1 # 撤销最近一次提交(保留更改)
|
|
601
|
-
git reset --soft HEAD~1 # 软重置
|
|
602
|
-
```
|
|
603
|
-
|
|
604
|
-
### 远程操作
|
|
605
|
-
|
|
606
|
-
```bash
|
|
607
|
-
git fetch # 获取远程更新
|
|
608
|
-
git pull # 拉取并合并
|
|
609
|
-
git push # 推送到远程(需用户确认)
|
|
610
|
-
git push -u origin <branch> # 推送并设置上游
|
|
611
|
-
```
|
|
612
|
-
|
|
613
|
-
---
|
|
614
|
-
|
|
615
|
-
## 与其他 Agent 协作
|
|
616
|
-
|
|
617
|
-
### 代码审查后提交
|
|
618
|
-
|
|
619
|
-
当魏征(代码审查)完成审查后:
|
|
620
|
-
|
|
621
|
-
```markdown
|
|
622
|
-
# 魏征审查通过后
|
|
623
|
-
@git-master 请提交这些更改,消息为:
|
|
624
|
-
"fix(auth): address code review feedback"
|
|
625
|
-
```
|
|
626
|
-
|
|
627
|
-
### 功能完成后创建 PR
|
|
628
|
-
|
|
629
|
-
当鲁班(实现)完成功能后:
|
|
630
|
-
|
|
631
|
-
```markdown
|
|
632
|
-
# 鲁班实现完成后
|
|
633
|
-
@git-master 请创建 PR 将这个功能合并到 main
|
|
634
|
-
```
|
|
635
|
-
|
|
636
835
|
---
|
|
637
836
|
|
|
638
837
|
## 配置选项
|
|
@@ -665,28 +864,4 @@ git push -u origin <branch> # 推送并设置上游
|
|
|
665
864
|
|
|
666
865
|
---
|
|
667
866
|
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
### 提交被 hook 拒绝
|
|
671
|
-
|
|
672
|
-
1. 查看 hook 输出,了解失败原因
|
|
673
|
-
2. 修复问题(lint、格式、测试等)
|
|
674
|
-
3. 重新添加修改后的文件
|
|
675
|
-
4. 创建新提交(不要 amend)
|
|
676
|
-
|
|
677
|
-
### 合并冲突
|
|
678
|
-
|
|
679
|
-
1. 使用 `git status` 查看冲突文件
|
|
680
|
-
2. 手动解决冲突
|
|
681
|
-
3. `git add <resolved-files>`
|
|
682
|
-
4. 继续合并或 rebase
|
|
683
|
-
|
|
684
|
-
### 推送被拒绝
|
|
685
|
-
|
|
686
|
-
1. 先 `git pull` 获取最新更改
|
|
687
|
-
2. 解决任何冲突
|
|
688
|
-
3. 重新推送
|
|
689
|
-
|
|
690
|
-
---
|
|
691
|
-
|
|
692
|
-
*Git Master 技能 - 安全、规范、智能的 Git 操作指引*
|
|
867
|
+
*Git Master 技能 v2.0 — 6 阶段提交工作流 · 3 模式检测 · 强制性输出校验*
|