@ranger1/dx 0.1.15 → 0.1.17

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.
@@ -0,0 +1,276 @@
1
+ ---
2
+ allowed-tools: [Bash, Read, Glob, TodoWrite, Edit, Grep]
3
+ description: 'Git 工作流:Issue/Commit/PR 自动化'
4
+ agent: quick
5
+ ---
6
+
7
+ ## 用法
8
+
9
+ ```bash
10
+ /git-commit-and-pr # 自动检测并执行所需阶段
11
+ /git-commit-and-pr --issue <ID> # 指定关联 Issue
12
+ /git-commit-and-pr --issue-only # 仅创建 Issue
13
+ /git-commit-and-pr --pr --base <BRANCH> # 仅创建 PR
14
+ ```
15
+
16
+ ---
17
+
18
+ ## 执行流程
19
+
20
+ ### Step 1: 状态检测
21
+
22
+ 并行执行:
23
+
24
+ ```bash
25
+ git status --short
26
+ git branch --show-current
27
+ git log -1 --format='%H %s' 2>/dev/null || echo "no-commits"
28
+ ```
29
+
30
+ 根据状态决定执行阶段:
31
+
32
+ - 无 Issue 或 `--issue-only` → 执行 Issue 创建
33
+ - 有未提交修改 → 执行 Commit 流程
34
+ - 工作树干净且在功能分支 → 执行 PR 创建
35
+
36
+ **禁止在 main/master 直接提交。**
37
+
38
+ ---
39
+
40
+ ### Step 2: Issue 创建(可选)
41
+
42
+ #### 2.1 信息收集与分析
43
+
44
+ **代码变更分析(并行执行):**
45
+
46
+ ```bash
47
+ git status --short
48
+ git diff --stat
49
+ ```
50
+
51
+ **重复检查(可选):**
52
+
53
+ ```bash
54
+ gh issue list --search "<关键词>" --limit 5
55
+ ```
56
+
57
+ **上下文提炼:**
58
+
59
+ - 从对话历史中提取问题描述和需求背景
60
+ - 识别受影响的模块(backend/front/admin/shared)
61
+ - 确认是否涉及数据库、API 或基础设施变更
62
+
63
+ #### 2.2 Issue 内容生成
64
+
65
+ **标题生成策略:**
66
+
67
+ - 格式:`[模块] 简洁描述` 或 `[类型] 功能/问题描述`
68
+ - 示例:
69
+ - `[Backend] 优化用户认证流程性能`
70
+ - `[Bug] 修复聊天消息丢失问题`
71
+ - `[规范] 统一错误码命名规范`
72
+ - 优先使用用户提供的 `--title` 参数
73
+
74
+ **标签选择(基于内容自动添加):**
75
+
76
+ - `bug` - Bug 修复
77
+ - `enhancement` - 功能增强
78
+ - `documentation` - 文档相关
79
+ - `performance` - 性能优化
80
+ - `refactor` - 代码重构
81
+ - `backend` / `frontend` - 模块标签
82
+ - `infrastructure` - 基础设施
83
+
84
+ **正文结构模板:**
85
+
86
+ ```markdown
87
+ ## 背景
88
+
89
+ [当前场景、讨论来源、为什么需要这个改动]
90
+
91
+ ## 现状/问题
92
+
93
+ [观察到的问题、现有实现的不足、需要改进的地方]
94
+
95
+ ## 期望行为
96
+
97
+ [目标状态、期望结果、验收标准]
98
+
99
+ ## 执行计划
100
+
101
+ - [ ] 步骤 1
102
+ - [ ] 步骤 2
103
+ - [ ] 步骤 3
104
+
105
+ ## 影响范围
106
+
107
+ [受影响的模块、可能的风险、需要通知的团队]
108
+
109
+ ## 相关资源
110
+
111
+ [相关 Issue、PR、文档链接]
112
+ ```
113
+
114
+ #### 2.3 执行 Issue 创建
115
+
116
+ 使用 heredoc 格式执行 gh CLI:
117
+
118
+ ```bash
119
+ gh issue create \
120
+ --title "[模块] 问题摘要" \
121
+ --label label1 --label label2 \
122
+ --body-file - <<'MSG'
123
+ ## 背景
124
+
125
+ [从对话历史提炼的背景信息]
126
+
127
+ ## 现状/问题
128
+
129
+ [代码变更分析结果和问题描述]
130
+
131
+ ## 期望行为
132
+
133
+ [目标状态和验收标准]
134
+
135
+ ## 执行计划
136
+
137
+ - [ ] 步骤 1
138
+ - [ ] 步骤 2
139
+
140
+ ## 影响范围
141
+
142
+ [受影响模块列表]
143
+ MSG
144
+ ```
145
+
146
+ **质量检查清单:**
147
+
148
+ - [ ] 标题简洁明确(≤ 80 字符)
149
+ - [ ] 背景信息完整
150
+ - [ ] 问题/需求描述清晰
151
+ - [ ] 执行步骤可操作
152
+ - [ ] 影响范围已标注
153
+ - [ ] 标签选择准确
154
+ - [ ] 无敏感信息(.env、密钥等)
155
+
156
+ #### 2.4 输出 Issue 信息
157
+
158
+ 成功创建后,解析 gh 输出获取 Issue 编号:
159
+
160
+ ```
161
+ ✅ Issue 创建成功
162
+
163
+ Issue: #<编号>
164
+ 标题: <标题>
165
+ 链接: <GitHub URL>
166
+ 标签: <标签列表>
167
+ ```
168
+
169
+ 存储 Issue ID 供后续 commit 和 PR 使用。
170
+
171
+ `--issue-only` 时在此终止。
172
+
173
+ ---
174
+
175
+ ### Step 3: Commit 流程
176
+
177
+ #### 3.1 暂存变更
178
+
179
+ ```bash
180
+ git add -A
181
+ git diff --cached --stat
182
+ ```
183
+
184
+ #### 3.2 生成提交
185
+
186
+ 分析 `git diff --cached` 内容,生成 commit message:
187
+
188
+ ```bash
189
+ git commit -F - <<'EOF'
190
+ <type>: <概要>
191
+
192
+ 变更说明:
193
+ - <变更项1>
194
+ - <变更项2>
195
+
196
+ Refs: #<issue-id>
197
+ EOF
198
+ ```
199
+
200
+ type 类型:feat/fix/refactor/docs/chore/test
201
+
202
+ #### 3.3 确认提交
203
+
204
+ ```bash
205
+ git status
206
+ git log -1 --oneline
207
+ ```
208
+
209
+ ---
210
+
211
+ ### Step 4: PR 创建
212
+
213
+ #### 4.1 推送分支
214
+
215
+ ```bash
216
+ git push -u origin HEAD
217
+ ```
218
+
219
+ #### 4.2 分析变更
220
+
221
+ ```bash
222
+ git log origin/master..HEAD --oneline
223
+ git diff origin/master...HEAD --stat
224
+ ```
225
+
226
+ #### 4.3 创建 PR
227
+
228
+ ```bash
229
+ gh pr create --title '<type>: <概要>' --body-file - <<'EOF'
230
+ ## 变更说明
231
+
232
+ - <变更项>
233
+
234
+ ## 测试
235
+
236
+ - [ ] 本地测试通过
237
+
238
+ Closes: #<issue-id>
239
+ EOF
240
+ ```
241
+
242
+ #### 4.4 提示评审
243
+
244
+ 创建 PR 成功后,提醒用户运行自动评审流程:
245
+
246
+ ```
247
+ 💡 提示:运行以下命令启动自动评审
248
+ /dx:pr-review-loop --pr <PR_NUMBER>
249
+ ```
250
+
251
+ ---
252
+
253
+ ## 输出格式
254
+
255
+ **成功:**
256
+
257
+ ```
258
+ ✅ 完成
259
+
260
+ Issue: #<编号> <标题>
261
+ Commit: <hash> <主题>
262
+ PR: #<编号> → <URL>
263
+
264
+ 💡 下一步:运行以下命令启动自动评审
265
+ /dx:pr-review-loop --pr <编号>
266
+ ```
267
+
268
+ **部分完成:**
269
+
270
+ ```
271
+ ⚠️ 停止于 [阶段]
272
+
273
+ 已完成:<列表>
274
+ 阻塞:<原因>
275
+ 继续:/dx:git-commit-and-pr --issue <编号>
276
+ ```