cc-devflow 2.4.2 → 2.4.5

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.
Files changed (28) hide show
  1. package/.claude/agents/bug-analyzer.md +0 -1
  2. package/.claude/agents/compatibility-checker.md +0 -1
  3. package/.claude/agents/impact-analyzer.md +0 -1
  4. package/.claude/commands/flow-fix.md +1 -1
  5. package/.claude/commands/flow-new.md +2 -3
  6. package/.claude/commands/git-commit.md +425 -0
  7. package/.claude/docs/guides/NEW_TROUBLESHOOTING.md +4 -4
  8. package/.claude/docs/templates/NEW_ORCHESTRATION_TEMPLATE.md +2 -3
  9. package/.claude/rules/devflow-conventions.md +3 -6
  10. package/.claude/scripts/generate-status-report.sh +7 -7
  11. package/.claude/scripts/recover-workflow.sh +18 -12
  12. package/.claude/skills/npm-release/SKILL.md +314 -0
  13. package/.claude/skills/writing-skills/SKILL.md +655 -0
  14. package/.claude/skills/writing-skills/anthropic-best-practices.md +1150 -0
  15. package/.claude/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  16. package/.claude/skills/writing-skills/graphviz-conventions.dot +172 -0
  17. package/.claude/skills/writing-skills/persuasion-principles.md +187 -0
  18. package/.claude/skills/writing-skills/render-graphs.js +168 -0
  19. package/.claude/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  20. package/.claude/tsc-cache/748c64fa-9e5f-4a1d-9db8-efb8415a6183/affected-repos.txt +1 -0
  21. package/.claude/tsc-cache/748c64fa-9e5f-4a1d-9db8-efb8415a6183/edited-files.log +1 -0
  22. package/.claude/tsc-cache/f903e5df-3c39-4958-b26b-724808f32956/affected-repos.txt +1 -0
  23. package/.claude/tsc-cache/f903e5df-3c39-4958-b26b-724808f32956/edited-files.log +2 -0
  24. package/CHANGELOG.md +72 -7
  25. package/README.md +12 -0
  26. package/README.zh-CN.md +12 -0
  27. package/bin/cc-devflow-cli.js +4 -4
  28. package/package.json +1 -1
@@ -25,7 +25,6 @@ You MUST follow these rules during BUG analysis:
25
25
  2. **Agent Coordination**:
26
26
  - Update status in orchestration_status.json when analysis begins and completes
27
27
  - Implement proper error handling for unclear BUG symptoms
28
- - Create analysis completion markers (.completed files)
29
28
  - Avoid file locks (read-only agent - only generate documents)
30
29
 
31
30
  3. **DateTime Handling**:
@@ -25,7 +25,6 @@ You MUST follow these rules during compatibility analysis:
25
25
 
26
26
  2. **Agent Coordination**:
27
27
  - Update orchestration_status.json when analysis begins/completes
28
- - Create completion markers (.completed files) after successful analysis
29
28
  - Coordinate with impact-analyzer for change assessment
30
29
  - Research-only agent: no file modifications, only document generation
31
30
 
@@ -24,7 +24,6 @@ You MUST follow these rules during impact analysis:
24
24
 
25
25
  2. **Agent Coordination**:
26
26
  - Update orchestration_status.json when analysis begins/completes
27
- - Create completion markers (.completed files) after analysis
28
27
  - Research-only agent: no code modifications, only analysis documents
29
28
  - Coordinate with compatibility-checker for version management
30
29
 
@@ -157,7 +157,7 @@ Step 4: 逆向追踪数据流
157
157
  3. 每个任务完成后:
158
158
  → 运行 quickstart 中相关测试命令
159
159
  → Git 提交 (一任务一提交)
160
- → 更新 tasks/TASK_*.completed
160
+ → 更新 TASKS.md (checkbox 标记)
161
161
 
162
162
  4. 3+ 次修复失败 → STOP
163
163
  → 停下来,质疑架构
@@ -239,7 +239,7 @@ $ARGUMENTS = "REQ_ID|TITLE|PLAN_URLS?"
239
239
  **输出**:
240
240
  - 实现代码
241
241
  - 测试代码
242
- - tasks/*.completed 标记
242
+ - TASKS.md 更新 (checkbox 标记)
243
243
  - Git commits (每个任务一个)
244
244
 
245
245
  ---
@@ -349,8 +349,7 @@ devflow/requirements/${REQ_ID}/
349
349
  ├── contracts/openapi.yaml
350
350
  ├── quickstart.md
351
351
  ├── EPIC.md
352
- ├── TASKS.md (bite-sized)
353
- ├── tasks/*.completed
352
+ ├── TASKS.md (bite-sized, checkbox 标记)
354
353
  ├── SPEC_REVIEW.md ⭐ v2.1.0 新增
355
354
  ├── CODE_QUALITY_REVIEW.md ⭐ v2.1.0 新增
356
355
  ├── TEST_PLAN.md + TEST_REPORT.md
@@ -0,0 +1,425 @@
1
+ ---
2
+ name: git-commit
3
+ description: Git Commit 工作流最佳实践 - Conventional Commits 规范、分支策略、PR 管理
4
+ version: 3.0.0
5
+ author: CC-DevFlow
6
+ updated_at: 2026-01-04
7
+ scripts:
8
+ review: .claude/scripts/git-commit-review.sh
9
+ pr_check: .claude/scripts/check-remote.sh
10
+ ---
11
+
12
+ > **哲学核心**:Commit 是代码历史的节点,每个节点都应该清晰、独立、可追溯。
13
+ > **Rebase 信仰**:优先使用 `git rebase` 保持线性历史,让提交历史像链表一样优雅。
14
+ > **协作原则**:本地项目直接合并,远程项目走 PR 流程,代码审查是质量保障的自然环节。
15
+
16
+ ---
17
+
18
+ ## 📋 Commit Message 规范
19
+
20
+ ### 格式标准(Conventional Commits)
21
+
22
+ ```
23
+ <type>(<scope>): <subject>
24
+
25
+ <body>
26
+
27
+ <footer>
28
+ ```
29
+
30
+ ### Type 类型
31
+
32
+ | Type | 说明 | 示例 |
33
+ |------|------|------|
34
+ | `feat` | 新功能 | `feat(user): 添加登录功能` |
35
+ | `fix` | 修复 Bug | `fix(auth): 修复 token 过期问题` |
36
+ | `docs` | 文档更新 | `docs(readme): 更新安装说明` |
37
+ | `style` | 代码格式 | `style(utils): 统一代码缩进` |
38
+ | `refactor` | 重构 | `refactor(api): 简化请求处理逻辑` |
39
+ | `perf` | 性能优化 | `perf(render): 优化列表渲染性能` |
40
+ | `test` | 测试 | `test(utils): 添加工具函数单元测试` |
41
+ | `chore` | 构建/工具 | `chore(deps): 更新依赖版本` |
42
+
43
+ ### 编写规则
44
+
45
+ - **Subject**:50 字以内,祈使句,首字母小写,结尾不加句号
46
+ - **Body**:72 字换行,说明为什么和如何,而非做了什么
47
+ - **Footer**:`BREAKING CHANGE: <描述>` 或 `Closes #123`
48
+
49
+ ### ✅ 好示例
50
+
51
+ ```
52
+ feat(user): 添加微信登录功能
53
+
54
+ 支持通过微信授权码快速登录,提升用户体验。
55
+ 登录成功后自动同步用户信息到本地存储。
56
+
57
+ Closes #123
58
+ ```
59
+
60
+ ---
61
+
62
+ ## 🔄 工作流程
63
+
64
+ ### 远程项目 PR 流程(团队协作)
65
+
66
+ ```bash
67
+ # 1. 创建功能分支
68
+ git checkout main
69
+ git pull --rebase
70
+ git checkout -b feature/my-feature
71
+
72
+ # 2. 开发并提交(多次小提交)
73
+ git add <file1>
74
+ git commit -m "feat(module): 实现核心功能"
75
+ git add <file2>
76
+ git commit -m "test(module): 添加单元测试"
77
+
78
+ # 3. 推送前 rebase 主分支(保持线性历史)
79
+ git checkout main
80
+ git pull --rebase
81
+ git checkout feature/my-feature
82
+ git rebase main
83
+
84
+ # 4. 推送到远程
85
+ git push -u origin feature/my-feature
86
+ # rebase 后需要 force push
87
+ git push --force-with-lease
88
+
89
+ # 5. 创建 Pull Request
90
+ gh pr create --title "feat: 添加新功能" --body "$(cat <<'EOF'
91
+ ## Summary
92
+ - 实现核心功能模块
93
+ - 添加完整测试覆盖
94
+
95
+ ## Test plan
96
+ - [x] 单元测试通过
97
+ - [x] 集成测试通过
98
+
99
+ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
100
+ EOF
101
+ )"
102
+
103
+ # 6. 合并 PR 后清理
104
+ git checkout main
105
+ git pull --rebase
106
+ git branch -d feature/my-feature
107
+ ```
108
+
109
+ ---
110
+
111
+ ### 本地项目直接合并(个人项目)
112
+
113
+ ```bash
114
+ # 1. 创建功能分支
115
+ git checkout main
116
+ git checkout -b feature/my-feature
117
+
118
+ # 2. 开发并提交
119
+ git add .
120
+ git commit -m "feat(module): 实现核心功能"
121
+
122
+ # 3. Rebase 主分支并快进合并
123
+ git checkout main
124
+ git pull --rebase # 如果有远程仓库
125
+ git checkout feature/my-feature
126
+ git rebase main
127
+ git checkout main
128
+ git merge --ff-only feature/my-feature
129
+
130
+ # 4. 清理分支
131
+ git branch -d feature/my-feature
132
+ ```
133
+
134
+ ---
135
+
136
+ ### 🚨 紧急修复流程(Hotfix)
137
+
138
+ ```bash
139
+ # 1. 从 main 创建热修复分支
140
+ git checkout main
141
+ git pull --rebase
142
+ git checkout -b hotfix/critical-issue
143
+
144
+ # 2. 修复并提交
145
+ git add .
146
+ git commit -m "fix(critical): 修复紧急问题"
147
+
148
+ # 3. 合并到 main 和 develop
149
+ git checkout main
150
+ git merge hotfix/critical-issue
151
+ git push
152
+
153
+ git checkout develop
154
+ git merge hotfix/critical-issue
155
+ git push
156
+
157
+ # 4. 清理分支
158
+ git branch -d hotfix/critical-issue
159
+ ```
160
+
161
+ ---
162
+
163
+ ## 📦 多文件拆分提交工作流(NEW)
164
+
165
+ > **原则**:涉及多文件时,必须按同类变更拆分提交,每个 commit 只包含一类变更。
166
+
167
+ ### 场景 1:功能 + 测试 + 文档
168
+
169
+ ```bash
170
+ # ❌ 错误:一次性提交所有文件
171
+ git add .
172
+ git commit -m "feat: 添加用户管理功能"
173
+
174
+ # ✅ 正确:按类型拆分提交
175
+ # 第一次提交:核心功能实现
176
+ git add src/services/user.ts src/routes/user.ts
177
+ git commit -m "feat(user): 实现用户管理核心功能"
178
+
179
+ # 第二次提交:测试文件
180
+ git add tests/user.test.ts
181
+ git commit -m "test(user): 添加用户管理单元测试"
182
+
183
+ # 第三次提交:文档更新
184
+ git add docs/api/user.md README.md
185
+ git commit -m "docs(user): 添加用户管理 API 文档"
186
+
187
+ # 第四次提交:配置变更
188
+ git add .env.example config/user.yml
189
+ git commit -m "chore(user): 添加用户管理配置文件"
190
+ ```
191
+
192
+ ### 场景 2:重构多个模块
193
+
194
+ ```bash
195
+ # ✅ 按模块拆分提交
196
+ # 第一次提交:auth 模块重构
197
+ git add src/services/auth.ts src/middlewares/auth.ts
198
+ git commit -m "refactor(auth): 简化认证逻辑"
199
+
200
+ # 第二次提交:user 模块重构
201
+ git add src/services/user.ts src/models/user.ts
202
+ git commit -m "refactor(user): 优化用户服务层"
203
+
204
+ # 第三次提交:api 模块重构
205
+ git add src/routes/api.ts src/controllers/api.ts
206
+ git commit -m "refactor(api): 统一 API 错误处理"
207
+ ```
208
+
209
+ ### 场景 3:跨层修改(数据库 + 服务 + API)
210
+
211
+ ```bash
212
+ # ✅ 按层次拆分提交
213
+ # 第一次提交:数据模型层
214
+ git add prisma/schema.prisma prisma/migrations/*
215
+ git commit -m "feat(db): 添加 order 表及关联字段"
216
+
217
+ # 第二次提交:服务层
218
+ git add src/services/order.ts src/lib/prisma/order.ts
219
+ git commit -m "feat(order): 实现订单服务逻辑"
220
+
221
+ # 第三次提交:API 路由层
222
+ git add src/routes/order.ts src/controllers/order.ts
223
+ git commit -m "feat(order): 添加订单 API 接口"
224
+
225
+ # 第四次提交:前端集成
226
+ git add miniprogram/pages/order/* miniprogram/utils/order-api.js
227
+ git commit -m "feat(order): 小程序订单页面集成"
228
+ ```
229
+
230
+ ### 场景 4:Bug 修复 + 防御性代码
231
+
232
+ ```bash
233
+ # ✅ 先修复 bug,再添加防御
234
+ # 第一次提交:核心 bug 修复
235
+ git add src/services/payment.ts
236
+ git commit -m "fix(payment): 修复支付回调处理逻辑"
237
+
238
+ # 第二次提交:添加测试
239
+ git add tests/payment.test.ts
240
+ git commit -m "test(payment): 添加支付回调场景测试"
241
+
242
+ # 第三次提交:防御性代码
243
+ git add src/middlewares/validator.ts
244
+ git commit -m "feat(payment): 添加支付参数校验中间件"
245
+ ```
246
+
247
+ ### 拆分提交的技巧
248
+
249
+ ```bash
250
+ # 技巧 1:交互式添加(部分文件添加)
251
+ git add -p <file> # 逐块选择要提交的代码
252
+
253
+ # 技巧 2:查看未提交变更
254
+ git status -s
255
+ git diff --stat
256
+
257
+ # 技巧 3:临时保存其他变更
258
+ git stash push -m "临时保存其他模块变更" -- <files>
259
+
260
+ # 技巧 4:整理已提交历史
261
+ git rebase -i HEAD~5 # 交互式整理最近 5 个 commit
262
+ ```
263
+
264
+ ### 拆分原则
265
+
266
+ | 维度 | 拆分规则 | 示例 |
267
+ |------|----------|------|
268
+ | **功能维度** | 实现 → 测试 → 文档 | `feat → test → docs` |
269
+ | **模块维度** | 按模块边界拆分 | `auth → user → order` |
270
+ | **层次维度** | 按架构分层拆分 | `model → service → route → UI` |
271
+ | **类型维度** | 按文件类型拆分 | `.ts → .test.ts → .md → .yml` |
272
+ | **影响范围** | 核心 → 边缘 | `核心逻辑 → 配置 → 文档` |
273
+
274
+ ---
275
+
276
+ ## 🔄 Rebase 最佳实践
277
+
278
+ ### 日常 Rebase
279
+
280
+ ```bash
281
+ # 功能分支定期 rebase 主分支
282
+ git checkout feature/my-feature
283
+ git fetch origin
284
+ git rebase origin/main
285
+
286
+ # 解决冲突后继续
287
+ git add .
288
+ git rebase --continue
289
+
290
+ # 中止 rebase
291
+ git rebase --abort
292
+ ```
293
+
294
+ ### 交互式 Rebase 整理历史
295
+
296
+ ```bash
297
+ # 整理最近 3 个 commit
298
+ git rebase -i HEAD~3
299
+
300
+ # 操作选项:
301
+ # pick: 保留 commit
302
+ # reword: 修改 message
303
+ # squash: 合并到上一个 commit(保留 message)
304
+ # fixup: 合并到上一个 commit(丢弃 message)
305
+ # drop: 删除 commit
306
+ ```
307
+
308
+ ### Rebase 黄金法则
309
+
310
+ ```yaml
311
+ 核心原则: "永远不要 rebase 公共分支的历史"
312
+
313
+ ✅ 安全场景:
314
+ - 个人功能分支 rebase 主分支
315
+ - 本地未推送的提交整理
316
+
317
+ ❌ 危险场景:
318
+ - 主分支(main/master/develop)
319
+ - 多人协作的长期分支
320
+ - 已推送到公共仓库的提交
321
+ ```
322
+
323
+ ### Force Push 安全使用
324
+
325
+ ```bash
326
+ # ❌ 危险:无脑覆盖
327
+ git push --force
328
+
329
+ # ✅ 安全:仅当远程无新提交时才覆盖
330
+ git push --force-with-lease
331
+ ```
332
+
333
+ ---
334
+
335
+ ## 📤 Pull Request 管理
336
+
337
+ ### 创建 PR
338
+
339
+ ```bash
340
+ # 使用 gh 命令创建 PR
341
+ gh pr create \
342
+ --title "feat(module): 添加新功能" \
343
+ --body "$(cat <<'EOF'
344
+ ## Summary
345
+ - 实现了 XXX 核心功能
346
+ - 添加了完整的测试覆盖
347
+
348
+ ## Test Plan
349
+ - [x] 单元测试通过
350
+ - [x] 集成测试通过
351
+
352
+ ## Related Issues
353
+ Closes #123
354
+
355
+ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
356
+ EOF
357
+ )"
358
+ ```
359
+
360
+ ### PR 合并策略
361
+
362
+ ```bash
363
+ # 1. Squash merge(推荐,合并为单个 commit)
364
+ gh pr merge 123 --squash --delete-branch
365
+
366
+ # 2. Rebase merge(线性历史)
367
+ gh pr merge 123 --rebase --delete-branch
368
+
369
+ # 3. Merge commit(保留完整历史)
370
+ gh pr merge 123 --merge
371
+ ```
372
+
373
+ ### PR 最佳实践
374
+
375
+ - ✅ 每个 PR ≤ 400 行代码变更
376
+ - ✅ 专注单一功能或修复
377
+ - ✅ 推送前 `git rebase main`
378
+ - ✅ 所有讨论解决后再合并
379
+
380
+ ---
381
+
382
+ ## 🛠️ 常用命令速查
383
+
384
+ ```bash
385
+ # 查看状态
386
+ git status -s
387
+ git diff --staged
388
+
389
+ # 提交
390
+ git add -p # 交互式添加
391
+ git commit -m "message" # 快速提交
392
+ git commit --amend # 修改最后一次提交
393
+
394
+ # 撤销
395
+ git restore <file> # 撤销工作区变更
396
+ git restore --staged <file> # 撤销暂存区变更
397
+ git reset --soft HEAD~1 # 撤销提交(保留变更)
398
+
399
+ # 分支
400
+ git switch -c <branch> # 创建并切换分支
401
+ git branch -d <branch> # 删除分支
402
+
403
+ # 暂存
404
+ git stash push -m "desc" -- <files>
405
+ git stash pop
406
+
407
+ # 历史
408
+ git log --oneline --graph
409
+ git show <commit-hash>
410
+ ```
411
+
412
+ ---
413
+
414
+ ## 🎯 核心原则
415
+
416
+ 1. **原子性提交**:每个 commit 只做一件事,功能完整、可独立测试
417
+ 2. **清晰的 Message**:遵循 Conventional Commits,让历史可读可追溯
418
+ 3. **频繁提交**:小步快跑,不积累大量变更
419
+ 4. **保持线性历史**:优先 rebase,让历史像链表一样优雅
420
+ 5. **同类变更分组**:多文件按类型/模块/层次拆分提交
421
+ 6. **安全的 Force Push**:仅在个人分支使用 `--force-with-lease`
422
+
423
+ ---
424
+
425
+ **记住**:好的 commit 历史是项目最好的文档。代码是写给人看的,只是顺便让机器运行。
@@ -87,11 +87,11 @@ git branch -D feature/REQ-123-*
87
87
 
88
88
  ### Partial Resume (从特定任务继续)
89
89
  ```bash
90
- # 检查最后完成的任务
91
- ls devflow/requirements/REQ-123/tasks/*.completed | tail -1
90
+ # 检查任务状态
91
+ bash .claude/scripts/check-task-status.sh --verbose
92
92
 
93
- # 从下一任务继续
94
- /flow-dev "REQ-123" --resume --from=TASK_008
93
+ # 从特定任务继续
94
+ /flow-dev "REQ-123" --task T008
95
95
  ```
96
96
 
97
97
  ### State File Rebuild
@@ -57,7 +57,7 @@ Phase 3: 实现代码
57
57
  Phase 4: 测试验证 → 测试必须通过
58
58
  Phase 5: Git 提交并标记完成
59
59
  ```
60
- - 输出: 实现代码 + 测试代码 + tasks/*.completed
60
+ - 输出: 实现代码 + 测试代码 + TASKS.md 更新 (checkbox 标记)
61
61
 
62
62
  ### [5/8] /flow-qa --full
63
63
  **Exit Gate 检查**:
@@ -115,8 +115,7 @@ devflow/requirements/${REQ_ID}/
115
115
  ├── contracts/openapi.yaml
116
116
  ├── quickstart.md
117
117
  ├── EPIC.md # [3/8]
118
- ├── TASKS.md
119
- ├── tasks/*.completed # [4/8]
118
+ ├── TASKS.md # [4/8] (checkbox 标记任务完成状态)
120
119
  ├── TEST_REPORT.md # [5/8]
121
120
  ├── SECURITY_REPORT.md
122
121
  └── RELEASE_PLAN.md # [6/8]
@@ -37,9 +37,7 @@ devflow/requirements/${reqId}/
37
37
  ├── UI_PROTOTYPE.html # UI原型 ⚡️ 条件生成 (仅UI需求)
38
38
  ├── EPIC.md # Epic 规划
39
39
  ├── TASKS.md # 任务分解 (单文件管理所有任务)
40
- ├── tasks/ # 任务执行标记
41
- │ ├── TASK_001.completed # 任务完成标记
42
- │ ├── TASK_002.completed
40
+ ├── tasks/ # 任务执行文档
43
41
  │ └── IMPLEMENTATION_PLAN.md # dev-implementer 输出
44
42
  ├── research/ # 研究资料
45
43
  │ ├── ${reqId}_plan_1.md
@@ -56,8 +54,7 @@ devflow/requirements/${reqId}/
56
54
  ### 文档命名约定
57
55
  - **PRD 文件**: `PRD.md`
58
56
  - **Epic 文件**: `EPIC.md`
59
- - **Tasks 文件**: `TASKS.md` (所有任务集中在一个文件)
60
- - **任务完成标记**: `tasks/TASK_{ID}.completed` (空文件)
57
+ - **Tasks 文件**: `TASKS.md` (所有任务集中在一个文件,通过 checkbox 标记完成状态)
61
58
  - **研究文件**: `${reqId}_plan_{序号}.md`
62
59
  - **测试报告**: `TEST_REPORT.md`
63
60
  - **执行日志**: `EXECUTION_LOG.md`
@@ -137,7 +134,7 @@ Co-authored-by: Claude <claude@anthropic.com>
137
134
 
138
135
  ### 状态同步约定
139
136
  - 每个阶段完成后更新 `orchestration_status.json`
140
- - 每个任务完成后创建 `tasks/TASK_{ID}.completed`
137
+ - 每个任务完成后更新 `TASKS.md` 中的 checkbox (`- [ ]` → `- [x]`)
141
138
  - 所有重要操作记录到 `EXECUTION_LOG.md`
142
139
 
143
140
  ---
@@ -197,14 +197,14 @@ collect_requirements() {
197
197
  local tasks_file="$req_dir/TASKS.md"
198
198
 
199
199
  if [[ -f "$tasks_file" ]]; then
200
- # 统计任务总数 ( ## TASK 开头的行)
201
- tasks_total=$(grep -c "^## TASK" "$tasks_file" 2>/dev/null || echo "0")
200
+ # 统计已完成任务 (- [x] 标记)
201
+ tasks_completed=$(grep -c "^\- \[x\]" "$tasks_file" 2>/dev/null || echo "0")
202
202
 
203
- # 统计已完成任务 (检查 .completed 标记文件)
204
- local tasks_dir="$req_dir/tasks"
205
- if [[ -d "$tasks_dir" ]]; then
206
- tasks_completed=$(find "$tasks_dir" -name "*.completed" -type f 2>/dev/null | wc -l | tr -d ' ')
207
- fi
203
+ # 统计待完成任务 (- [ ] 标记)
204
+ local tasks_pending=$(grep -c "^\- \[ \]" "$tasks_file" 2>/dev/null || echo "0")
205
+
206
+ # 计算任务总数
207
+ tasks_total=$((tasks_completed + tasks_pending))
208
208
  fi
209
209
 
210
210
  # 计算进度百分比
@@ -164,16 +164,19 @@ detect_workflow_status() {
164
164
 
165
165
  # 检查任务进度
166
166
  if [[ -f "$REQ_DIR/TASKS.md" ]]; then
167
- local tasks_total=$(grep -c "^## TASK" "$REQ_DIR/TASKS.md" 2>/dev/null || echo "0")
168
- local tasks_completed=0
169
- if [[ -d "$REQ_DIR/tasks" ]]; then
170
- tasks_completed=$(find "$REQ_DIR/tasks" -name "*.completed" -type f 2>/dev/null | wc -l | tr -d ' ')
171
- fi
167
+ # 统计已完成任务 (- [x] 标记)
168
+ local tasks_completed=$(grep -c "^\- \[x\]" "$REQ_DIR/TASKS.md" 2>/dev/null || echo "0")
169
+
170
+ # 统计待完成任务 (- [ ] 标记)
171
+ local tasks_pending=$(grep -c "^\- \[ \]" "$REQ_DIR/TASKS.md" 2>/dev/null || echo "0")
172
+
173
+ # 计算任务总数
174
+ local tasks_total=$((tasks_completed + tasks_pending))
172
175
 
173
176
  echo -e "${BOLD}任务进度:${NC}"
174
177
  echo -e " 总任务数: $tasks_total"
175
178
  echo -e " 已完成: $tasks_completed"
176
- echo -e " 未完成: $((tasks_total - tasks_completed))"
179
+ echo -e " 未完成: $tasks_pending"
177
180
  echo ""
178
181
  fi
179
182
 
@@ -235,13 +238,16 @@ analyze_recovery_strategy() {
235
238
  development|dev_complete)
236
239
  # 检查是否有未完成的任务
237
240
  if [[ -f "$REQ_DIR/TASKS.md" ]]; then
238
- local tasks_total=$(grep -c "^## TASK" "$REQ_DIR/TASKS.md" 2>/dev/null || echo "0")
239
- local tasks_completed=0
240
- if [[ -d "$REQ_DIR/tasks" ]]; then
241
- tasks_completed=$(find "$REQ_DIR/tasks" -name "*.completed" -type f 2>/dev/null | wc -l | tr -d ' ')
242
- fi
241
+ # 统计已完成任务 (- [x] 标记)
242
+ local tasks_completed=$(grep -c "^\- \[x\]" "$REQ_DIR/TASKS.md" 2>/dev/null || echo "0")
243
+
244
+ # 统计待完成任务 (- [ ] 标记)
245
+ local tasks_pending=$(grep -c "^\- \[ \]" "$REQ_DIR/TASKS.md" 2>/dev/null || echo "0")
246
+
247
+ # 计算任务总数
248
+ local tasks_total=$((tasks_completed + tasks_pending))
243
249
 
244
- if [[ $tasks_completed -lt $tasks_total ]]; then
250
+ if [[ $tasks_pending -gt 0 ]]; then
245
251
  echo -e "${CYAN}建议: 继续开发 (恢复未完成任务)${NC}"
246
252
  echo "dev"
247
253
  else