cc-devflow 2.4.6 → 4.1.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.
Files changed (191) hide show
  1. package/.claude/CLAUDE.md +1065 -48
  2. package/.claude/agents/dev-implementer.md +195 -0
  3. package/.claude/commands/{flow-archive.md → flow/archive.md} +46 -11
  4. package/.claude/commands/flow/context.md +150 -0
  5. package/.claude/commands/flow/delta.md +245 -0
  6. package/.claude/commands/{flow-dev.md → flow/dev.md} +112 -11
  7. package/.claude/commands/flow/init.md +45 -0
  8. package/.claude/commands/flow/quality.md +159 -0
  9. package/.claude/commands/flow/spec.md +186 -0
  10. package/.claude/commands/flow/workspace.md +146 -0
  11. package/.claude/commands/{cancel-ralph.md → util/cancel-ralph.md} +1 -0
  12. package/.claude/config/quality-gates.yml +305 -0
  13. package/.claude/docs/guides/TEAM_MODE_GUIDE.md +313 -0
  14. package/.claude/docs/templates/DELTA_SPEC_TEMPLATE.md +91 -0
  15. package/.claude/docs/templates/DESIGN_DECISIONS_TEMPLATE.md +151 -0
  16. package/.claude/docs/templates/JOURNAL_TEMPLATE.md +75 -0
  17. package/.claude/docs/templates/_shared/CLAUDE.md +36 -0
  18. package/.claude/docs/templates/_shared/CONSTITUTION_CHECK.md +125 -0
  19. package/.claude/docs/templates/_shared/VALIDATION_CHECKLIST.md +187 -0
  20. package/.claude/docs/templates/_shared/YAML_FRONTMATTER.md +164 -0
  21. package/.claude/docs/templates/context/dev.jsonl.template +6 -0
  22. package/.claude/docs/templates/context/epic.jsonl.template +5 -0
  23. package/.claude/docs/templates/context/prd.jsonl.template +4 -0
  24. package/.claude/docs/templates/context/research.jsonl.template +4 -0
  25. package/.claude/docs/templates/context/review.jsonl.template +5 -0
  26. package/.claude/docs/templates/context/tech.jsonl.template +5 -0
  27. package/.claude/hooks/CLAUDE.md +342 -0
  28. package/.claude/hooks/inject-agent-context.ts +480 -0
  29. package/.claude/hooks/inject-skill-context.ts +359 -0
  30. package/.claude/hooks/ralph-loop.ts +931 -0
  31. package/.claude/hooks/task-completed-hook.ts +593 -0
  32. package/.claude/hooks/teammate-idle-hook.ts +690 -0
  33. package/.claude/hooks/types/team-types.d.ts +238 -0
  34. package/.claude/rules/devflow-conventions.md +82 -9
  35. package/.claude/scripts/archive-requirement.sh +44 -1
  36. package/.claude/scripts/common.sh +670 -3
  37. package/.claude/scripts/delta-parser.ts +527 -0
  38. package/.claude/scripts/detect-file-conflicts.sh +151 -0
  39. package/.claude/scripts/flow-context-add.sh +134 -0
  40. package/.claude/scripts/flow-context-init.sh +133 -0
  41. package/.claude/scripts/flow-context-validate.sh +144 -0
  42. package/.claude/scripts/flow-delta-apply.sh +297 -0
  43. package/.claude/scripts/flow-delta-archive.sh +71 -0
  44. package/.claude/scripts/flow-delta-create.sh +202 -0
  45. package/.claude/scripts/flow-delta-list.sh +142 -0
  46. package/.claude/scripts/flow-delta-status.sh +235 -0
  47. package/.claude/scripts/flow-quality-full.sh +184 -0
  48. package/.claude/scripts/flow-quality-quick.sh +64 -0
  49. package/.claude/scripts/flow-workspace-init.sh +117 -0
  50. package/.claude/scripts/flow-workspace-record.sh +164 -0
  51. package/.claude/scripts/flow-workspace-start.sh +88 -0
  52. package/.claude/scripts/get-workflow-status.sh +415 -0
  53. package/.claude/scripts/parse-task-dependencies.js +334 -0
  54. package/.claude/scripts/record-quality-error.sh +165 -0
  55. package/.claude/scripts/run-quality-gates.sh +242 -0
  56. package/.claude/scripts/team-dev-init.sh +319 -0
  57. package/.claude/scripts/team-state-recovery.sh +229 -0
  58. package/.claude/scripts/workflow-status.ts +433 -0
  59. package/.claude/settings.json +19 -0
  60. package/.claude/skills/cc-devflow-orchestrator/SKILL.md +85 -200
  61. package/.claude/skills/domain/using-git-worktrees/SKILL.md +252 -0
  62. package/.claude/skills/domain/using-git-worktrees/assets/SHELL_ALIASES.md +133 -0
  63. package/.claude/skills/domain/using-git-worktrees/context.jsonl +4 -0
  64. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-cleanup.sh +218 -0
  65. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-create.sh +232 -0
  66. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-list.sh +130 -0
  67. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-status.sh +140 -0
  68. package/.claude/skills/domain/using-git-worktrees/scripts/worktree-switch.sh +70 -0
  69. package/.claude/skills/skill-rules.json +72 -1
  70. package/.claude/skills/utility/journey-checker/SKILL.md +199 -0
  71. package/.claude/skills/utility/journey-checker/pressure-scenarios.md +164 -0
  72. package/.claude/skills/utility/skill-creator/LICENSE.txt +202 -0
  73. package/.claude/skills/utility/skill-creator/SKILL.md +356 -0
  74. package/.claude/skills/utility/skill-creator/references/output-patterns.md +82 -0
  75. package/.claude/skills/utility/skill-creator/references/workflows.md +28 -0
  76. package/.claude/skills/utility/skill-creator/scripts/init_skill.py +303 -0
  77. package/.claude/skills/utility/skill-creator/scripts/package_skill.py +110 -0
  78. package/.claude/skills/utility/skill-creator/scripts/quick_validate.py +95 -0
  79. package/.claude/skills/workflow/flow-dev/CLAUDE.md +78 -0
  80. package/.claude/skills/workflow/flow-dev/SKILL.md +96 -0
  81. package/.claude/skills/workflow/flow-dev/assets/IMPLEMENTATION_PLAN_TEMPLATE.md +71 -0
  82. package/.claude/skills/workflow/flow-dev/context.jsonl +8 -0
  83. package/.claude/skills/workflow/flow-dev/dev-implementer.jsonl +8 -0
  84. package/.claude/skills/workflow/flow-dev/scripts/entry-gate.sh +116 -0
  85. package/.claude/skills/workflow/flow-dev/scripts/exit-gate.sh +101 -0
  86. package/.claude/skills/workflow/flow-dev/scripts/task-orchestrator.sh +106 -0
  87. package/.claude/skills/workflow/flow-fix/SKILL.md +105 -0
  88. package/.claude/skills/workflow/flow-fix/context.jsonl +6 -0
  89. package/.claude/skills/workflow/flow-fix/references/bug-analyzer.md +381 -0
  90. package/.claude/skills/workflow/flow-init/SKILL.md +211 -0
  91. package/.claude/skills/workflow/flow-init/assets/BRAINSTORM_TEMPLATE.md +148 -0
  92. package/.claude/skills/workflow/flow-init/assets/INIT_FLOW_TEMPLATE.md +198 -0
  93. package/.claude/skills/workflow/flow-init/assets/RESEARCH_TEMPLATE.md +276 -0
  94. package/.claude/skills/workflow/flow-init/context.jsonl +5 -0
  95. package/.claude/skills/workflow/flow-init/references/flow-researcher.md +132 -0
  96. package/.claude/skills/workflow/flow-init/scripts/check-prerequisites.sh +232 -0
  97. package/.claude/skills/workflow/flow-init/scripts/consolidate-research.sh +182 -0
  98. package/.claude/skills/workflow/flow-init/scripts/create-requirement.sh +515 -0
  99. package/.claude/skills/workflow/flow-init/scripts/generate-research-tasks.sh +157 -0
  100. package/.claude/skills/workflow/flow-init/scripts/populate-research-tasks.sh +284 -0
  101. package/.claude/skills/workflow/flow-init/scripts/validate-research.sh +332 -0
  102. package/.claude/skills/workflow/flow-quality/SKILL.md +94 -0
  103. package/.claude/skills/workflow/flow-quality/context.jsonl +6 -0
  104. package/.claude/skills/workflow/flow-quality/references/code-quality-reviewer.md +205 -0
  105. package/.claude/skills/workflow/flow-quality/references/qa-tester.md +313 -0
  106. package/.claude/skills/workflow/flow-quality/references/security-reviewer.md +314 -0
  107. package/.claude/skills/workflow/flow-quality/references/spec-reviewer.md +221 -0
  108. package/.claude/skills/workflow/flow-release/SKILL.md +126 -0
  109. package/.claude/skills/workflow/flow-release/context.jsonl +7 -0
  110. package/.claude/skills/workflow/flow-release/references/release-manager.md +295 -0
  111. package/.claude/skills/workflow/flow-spec/CLAUDE.md +103 -0
  112. package/.claude/skills/workflow/flow-spec/SKILL.md +545 -0
  113. package/.claude/skills/workflow/flow-spec/context.jsonl +7 -0
  114. package/.claude/skills/workflow/flow-spec/scripts/entry-gate.sh +194 -0
  115. package/.claude/skills/workflow/flow-spec/scripts/exit-gate.sh +244 -0
  116. package/.claude/skills/workflow/flow-spec/scripts/parallel-orchestrator.sh +205 -0
  117. package/.claude/skills/workflow/flow-spec/scripts/team-communication.sh +353 -0
  118. package/.claude/skills/workflow/flow-spec/scripts/team-init.sh +195 -0
  119. package/.claude/skills/workflow/flow-spec/scripts/test-team-mode.sh +496 -0
  120. package/.claude/skills/workflow/flow-spec/team-config.json +165 -0
  121. package/.claude/skills/workflow.yaml +417 -0
  122. package/CHANGELOG.md +254 -0
  123. package/README.md +193 -33
  124. package/README.zh-CN.md +206 -46
  125. package/lib/compiler/CLAUDE.md +77 -46
  126. package/lib/compiler/__tests__/multi-module-emitters.test.js +508 -0
  127. package/lib/compiler/context-expander.js +179 -0
  128. package/lib/compiler/emitters/antigravity-emitter.js +195 -5
  129. package/lib/compiler/emitters/base-emitter.js +217 -2
  130. package/lib/compiler/emitters/codex-emitter.js +200 -4
  131. package/lib/compiler/emitters/cursor-emitter.js +307 -3
  132. package/lib/compiler/emitters/qwen-emitter.js +196 -4
  133. package/lib/compiler/index.js +197 -2
  134. package/lib/compiler/platforms.js +270 -21
  135. package/package.json +1 -1
  136. package/.claude/commands/flow-epic.md +0 -183
  137. package/.claude/commands/flow-init.md +0 -370
  138. package/.claude/commands/flow-prd.md +0 -144
  139. package/.claude/commands/flow-qa.md +0 -93
  140. package/.claude/commands/flow-review.md +0 -257
  141. package/.claude/commands/flow-tech.md +0 -142
  142. package/.claude/commands/flow-ui.md +0 -189
  143. package/.claude/skills/file-header-guardian/SKILL.md +0 -56
  144. package/.claude/skills/skill-developer/ADVANCED.md +0 -197
  145. package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +0 -306
  146. package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +0 -152
  147. package/.claude/skills/skill-developer/SKILL.md +0 -426
  148. package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +0 -315
  149. package/.claude/skills/skill-developer/TRIGGER_TYPES.md +0 -305
  150. package/.claude/skills/skill-developer/TROUBLESHOOTING.md +0 -514
  151. package/.claude/skills/writing-skills/SKILL.md +0 -655
  152. package/.claude/skills/writing-skills/anthropic-best-practices.md +0 -1150
  153. package/.claude/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
  154. package/.claude/skills/writing-skills/graphviz-conventions.dot +0 -172
  155. package/.claude/skills/writing-skills/persuasion-principles.md +0 -187
  156. package/.claude/skills/writing-skills/render-graphs.js +0 -168
  157. package/.claude/skills/writing-skills/testing-skills-with-subagents.md +0 -384
  158. package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/affected-repos.txt +0 -1
  159. package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/affected-repos.txt +0 -1
  160. /package/.claude/commands/{core-architecture.md → core/architecture.md} +0 -0
  161. /package/.claude/commands/{core-guidelines.md → core/guidelines.md} +0 -0
  162. /package/.claude/commands/{core-roadmap.md → core/roadmap.md} +0 -0
  163. /package/.claude/commands/{core-style.md → core/style.md} +0 -0
  164. /package/.claude/commands/{flow-checklist.md → flow/checklist.md} +0 -0
  165. /package/.claude/commands/{flow-clarify.md → flow/clarify.md} +0 -0
  166. /package/.claude/commands/{flow-constitution.md → flow/constitution.md} +0 -0
  167. /package/.claude/commands/{flow-fix.md → flow/fix.md} +0 -0
  168. /package/.claude/commands/{flow-ideate.md → flow/ideate.md} +0 -0
  169. /package/.claude/commands/{flow-new.md → flow/new.md} +0 -0
  170. /package/.claude/commands/{flow-release.md → flow/release.md} +0 -0
  171. /package/.claude/commands/{flow-restart.md → flow/restart.md} +0 -0
  172. /package/.claude/commands/{flow-status.md → flow/status.md} +0 -0
  173. /package/.claude/commands/{flow-update.md → flow/update.md} +0 -0
  174. /package/.claude/commands/{flow-upgrade.md → flow/upgrade.md} +0 -0
  175. /package/.claude/commands/{flow-verify.md → flow/verify.md} +0 -0
  176. /package/.claude/commands/{code-review-high.md → util/code-review.md} +0 -0
  177. /package/.claude/commands/{git-commit.md → util/git-commit.md} +0 -0
  178. /package/.claude/commands/{problem-analyzer.md → util/problem-analyzer.md} +0 -0
  179. /package/.claude/skills/{flow-attention-refresh → domain/attention-refresh}/SKILL.md +0 -0
  180. /package/.claude/skills/{flow-brainstorming → domain/brainstorming}/SKILL.md +0 -0
  181. /package/.claude/skills/{flow-debugging → domain/debugging}/SKILL.md +0 -0
  182. /package/.claude/skills/{flow-finishing-branch → domain/finishing-branch}/SKILL.md +0 -0
  183. /package/.claude/skills/{flow-receiving-review → domain/receiving-review}/SKILL.md +0 -0
  184. /package/.claude/skills/{flow-tdd → domain/tdd}/SKILL.md +0 -0
  185. /package/.claude/skills/{verification-before-completion → domain/verification}/SKILL.md +0 -0
  186. /package/.claude/skills/{constitution-guardian → guardrail/constitution-guardian}/SKILL.md +0 -0
  187. /package/.claude/skills/{devflow-tdd-enforcer → guardrail/tdd-enforcer}/SKILL.md +0 -0
  188. /package/.claude/skills/{devflow-constitution-quick-ref → utility/constitution-quick-ref}/SKILL.md +0 -0
  189. /package/.claude/skills/{devflow-file-standards → utility/file-standards}/SKILL.md +0 -0
  190. /package/.claude/skills/{fractal-docs-generator → utility/fractal-docs}/SKILL.md +0 -0
  191. /package/.claude/skills/{npm-release → utility/npm-release}/SKILL.md +0 -0
@@ -0,0 +1,415 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # get-workflow-status.sh - 工作流状态检测脚本
4
+ # =============================================================================
5
+ # 读取 workflow.yaml,检查工件文件存在性,输出当前状态和可执行的下一步
6
+ #
7
+ # 用法:
8
+ # ./get-workflow-status.sh REQ-001 # 检查指定需求的状态
9
+ # ./get-workflow-status.sh REQ-001 --json # JSON 格式输出
10
+ # ./get-workflow-status.sh REQ-001 --next # 仅输出下一步可执行的工件
11
+ # ./get-workflow-status.sh --project # 检查项目级工件状态
12
+ #
13
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
14
+ # =============================================================================
15
+
16
+ set -euo pipefail
17
+
18
+ # -----------------------------------------------------------------------------
19
+ # 配置
20
+ # -----------------------------------------------------------------------------
21
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
22
+ PROJECT_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
23
+ WORKFLOW_YAML="${PROJECT_ROOT}/.claude/skills/workflow.yaml"
24
+
25
+ # 颜色定义
26
+ RED='\033[0;31m'
27
+ GREEN='\033[0;32m'
28
+ YELLOW='\033[0;33m'
29
+ BLUE='\033[0;34m'
30
+ CYAN='\033[0;36m'
31
+ NC='\033[0m' # No Color
32
+
33
+ # -----------------------------------------------------------------------------
34
+ # 辅助函数
35
+ # -----------------------------------------------------------------------------
36
+ log_info() { echo -e "${BLUE}[INFO]${NC} $*"; }
37
+ log_success() { echo -e "${GREEN}[DONE]${NC} $*"; }
38
+ log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
39
+ log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
40
+
41
+ # 检查依赖
42
+ check_dependencies() {
43
+ local missing=()
44
+ for cmd in yq; do
45
+ if ! command -v "$cmd" &>/dev/null; then
46
+ missing+=("$cmd")
47
+ fi
48
+ done
49
+ if [[ ${#missing[@]} -gt 0 ]]; then
50
+ log_error "缺少依赖: ${missing[*]}"
51
+ log_info "安装方法: brew install ${missing[*]}"
52
+ exit 1
53
+ fi
54
+ }
55
+
56
+ # 替换路径中的占位符
57
+ resolve_path() {
58
+ local path="$1"
59
+ local req_id="${2:-}"
60
+ local bug_id="${3:-}"
61
+
62
+ path="${path//\{REQ\}/$req_id}"
63
+ path="${path//\{BUG\}/$bug_id}"
64
+ echo "$path"
65
+ }
66
+
67
+ # 检查文件/目录是否存在(支持 glob)
68
+ check_exists() {
69
+ local pattern="$1"
70
+ local is_glob="${2:-false}"
71
+ local full_path="${PROJECT_ROOT}/${pattern}"
72
+
73
+ if [[ "$is_glob" == "true" ]]; then
74
+ # glob 模式:检查是否有匹配的文件
75
+ local matches
76
+ matches=$(find "${full_path%/*}" -name "${full_path##*/}" 2>/dev/null | head -1)
77
+ [[ -n "$matches" ]]
78
+ else
79
+ # 精确路径:检查文件或目录存在
80
+ [[ -e "$full_path" ]]
81
+ fi
82
+ }
83
+
84
+ # 检查工件是否完成
85
+ is_artifact_complete() {
86
+ local generates="$1"
87
+ local req_id="$2"
88
+ local is_glob="${3:-false}"
89
+
90
+ local resolved_path
91
+ resolved_path=$(resolve_path "$generates" "$req_id")
92
+
93
+ check_exists "$resolved_path" "$is_glob"
94
+ }
95
+
96
+ # 检查依赖是否满足
97
+ are_dependencies_met() {
98
+ local artifact_id="$1"
99
+ local req_id="$2"
100
+
101
+ # 获取依赖列表
102
+ local requires
103
+ requires=$(yq ".artifacts[] | select(.id == \"$artifact_id\") | .requires[]?" "$WORKFLOW_YAML" 2>/dev/null)
104
+
105
+ if [[ -z "$requires" ]]; then
106
+ return 0 # 无依赖,满足
107
+ fi
108
+
109
+ # 检查每个依赖
110
+ while IFS= read -r dep_id; do
111
+ [[ -z "$dep_id" ]] && continue
112
+
113
+ local dep_generates dep_glob
114
+ dep_generates=$(yq ".artifacts[] | select(.id == \"$dep_id\") | .generates" "$WORKFLOW_YAML")
115
+ dep_glob=$(yq ".artifacts[] | select(.id == \"$dep_id\") | .glob // false" "$WORKFLOW_YAML")
116
+
117
+ if ! is_artifact_complete "$dep_generates" "$req_id" "$dep_glob"; then
118
+ return 1 # 依赖未完成
119
+ fi
120
+ done <<< "$requires"
121
+
122
+ return 0 # 所有依赖满足
123
+ }
124
+
125
+ # 获取工件状态
126
+ get_artifact_status() {
127
+ local artifact_id="$1"
128
+ local req_id="$2"
129
+
130
+ local generates is_glob is_optional
131
+ generates=$(yq ".artifacts[] | select(.id == \"$artifact_id\") | .generates" "$WORKFLOW_YAML")
132
+ is_glob=$(yq ".artifacts[] | select(.id == \"$artifact_id\") | .glob // false" "$WORKFLOW_YAML")
133
+ is_optional=$(yq ".artifacts[] | select(.id == \"$artifact_id\") | .optional // false" "$WORKFLOW_YAML")
134
+
135
+ if is_artifact_complete "$generates" "$req_id" "$is_glob"; then
136
+ echo "complete"
137
+ elif are_dependencies_met "$artifact_id" "$req_id"; then
138
+ echo "ready"
139
+ else
140
+ echo "blocked"
141
+ fi
142
+ }
143
+
144
+ # -----------------------------------------------------------------------------
145
+ # 主要功能
146
+ # -----------------------------------------------------------------------------
147
+
148
+ # 获取需求级工件状态
149
+ get_requirement_status() {
150
+ local req_id="$1"
151
+ local output_format="${2:-text}"
152
+
153
+ log_info "检查需求 $req_id 的工作流状态..."
154
+
155
+ # 获取所有需求级工件(包含 {REQ} 占位符的)
156
+ local artifacts
157
+ artifacts=$(yq '.artifacts[] | select(.generates | contains("{REQ}")) | .id' "$WORKFLOW_YAML")
158
+
159
+ local complete=()
160
+ local ready=()
161
+ local blocked=()
162
+ local optional_pending=()
163
+
164
+ while IFS= read -r artifact_id; do
165
+ [[ -z "$artifact_id" ]] && continue
166
+
167
+ local status is_optional
168
+ status=$(get_artifact_status "$artifact_id" "$req_id")
169
+ is_optional=$(yq ".artifacts[] | select(.id == \"$artifact_id\") | .optional // false" "$WORKFLOW_YAML")
170
+
171
+ case "$status" in
172
+ complete)
173
+ complete+=("$artifact_id")
174
+ ;;
175
+ ready)
176
+ if [[ "$is_optional" == "true" ]]; then
177
+ optional_pending+=("$artifact_id")
178
+ else
179
+ ready+=("$artifact_id")
180
+ fi
181
+ ;;
182
+ blocked)
183
+ blocked+=("$artifact_id")
184
+ ;;
185
+ esac
186
+ done <<< "$artifacts"
187
+
188
+ # 输出结果
189
+ if [[ "$output_format" == "json" ]]; then
190
+ cat <<EOF
191
+ {
192
+ "req_id": "$req_id",
193
+ "complete": [$(printf '"%s",' "${complete[@]}" | sed 's/,$//')]
194
+ "ready": [$(printf '"%s",' "${ready[@]}" | sed 's/,$//')]
195
+ "optional_pending": [$(printf '"%s",' "${optional_pending[@]}" | sed 's/,$//')]
196
+ "blocked": [$(printf '"%s",' "${blocked[@]}" | sed 's/,$//')]
197
+ "progress": "${#complete[@]}/$((${#complete[@]} + ${#ready[@]} + ${#blocked[@]}))"
198
+ }
199
+ EOF
200
+ else
201
+ echo ""
202
+ echo -e "${CYAN}=== 需求 $req_id 工作流状态 ===${NC}"
203
+ echo ""
204
+
205
+ if [[ ${#complete[@]} -gt 0 ]]; then
206
+ echo -e "${GREEN}已完成 (${#complete[@]}):${NC}"
207
+ for a in "${complete[@]}"; do
208
+ local generates
209
+ generates=$(yq ".artifacts[] | select(.id == \"$a\") | .generates" "$WORKFLOW_YAML")
210
+ generates=$(resolve_path "$generates" "$req_id")
211
+ echo -e " ${GREEN}✓${NC} $a → $generates"
212
+ done
213
+ echo ""
214
+ fi
215
+
216
+ if [[ ${#ready[@]} -gt 0 ]]; then
217
+ echo -e "${YELLOW}可执行 (${#ready[@]}):${NC}"
218
+ for a in "${ready[@]}"; do
219
+ local skill
220
+ skill=$(yq ".artifacts[] | select(.id == \"$a\") | .skill" "$WORKFLOW_YAML")
221
+ echo -e " ${YELLOW}→${NC} $a (skill: $skill)"
222
+ done
223
+ echo ""
224
+ fi
225
+
226
+ if [[ ${#optional_pending[@]} -gt 0 ]]; then
227
+ echo -e "${BLUE}可选工件 (${#optional_pending[@]}):${NC}"
228
+ for a in "${optional_pending[@]}"; do
229
+ local skill
230
+ skill=$(yq ".artifacts[] | select(.id == \"$a\") | .skill" "$WORKFLOW_YAML")
231
+ echo -e " ${BLUE}○${NC} $a (skill: $skill)"
232
+ done
233
+ echo ""
234
+ fi
235
+
236
+ if [[ ${#blocked[@]} -gt 0 ]]; then
237
+ echo -e "${RED}阻塞中 (${#blocked[@]}):${NC}"
238
+ for a in "${blocked[@]}"; do
239
+ local requires
240
+ requires=$(yq ".artifacts[] | select(.id == \"$a\") | .requires[]?" "$WORKFLOW_YAML" | tr '\n' ', ' | sed 's/,$//')
241
+ echo -e " ${RED}✗${NC} $a (等待: $requires)"
242
+ done
243
+ echo ""
244
+ fi
245
+
246
+ # 进度条
247
+ local total=$((${#complete[@]} + ${#ready[@]} + ${#blocked[@]}))
248
+ local percent=0
249
+ [[ $total -gt 0 ]] && percent=$((${#complete[@]} * 100 / total))
250
+ echo -e "进度: ${GREEN}${#complete[@]}${NC}/$total ($percent%)"
251
+
252
+ # 下一步建议
253
+ if [[ ${#ready[@]} -gt 0 ]]; then
254
+ local next_artifact="${ready[0]}"
255
+ local next_skill
256
+ next_skill=$(yq ".artifacts[] | select(.id == \"$next_artifact\") | .skill" "$WORKFLOW_YAML")
257
+ echo ""
258
+ echo -e "${CYAN}建议下一步:${NC} /$next_skill \"$req_id\""
259
+ fi
260
+ fi
261
+ }
262
+
263
+ # 获取项目级工件状态
264
+ get_project_status() {
265
+ local output_format="${1:-text}"
266
+
267
+ log_info "检查项目级工件状态..."
268
+
269
+ # 获取所有项目级工件(不包含 {REQ} 占位符的)
270
+ local artifacts
271
+ artifacts=$(yq '.artifacts[] | select(.generates | contains("{REQ}") | not) | select(.generates | contains("{BUG}") | not) | .id' "$WORKFLOW_YAML")
272
+
273
+ local complete=()
274
+ local missing=()
275
+
276
+ while IFS= read -r artifact_id; do
277
+ [[ -z "$artifact_id" ]] && continue
278
+
279
+ local generates
280
+ generates=$(yq ".artifacts[] | select(.id == \"$artifact_id\") | .generates" "$WORKFLOW_YAML")
281
+
282
+ if check_exists "$generates" "false"; then
283
+ complete+=("$artifact_id")
284
+ else
285
+ missing+=("$artifact_id")
286
+ fi
287
+ done <<< "$artifacts"
288
+
289
+ # 输出结果
290
+ if [[ "$output_format" == "json" ]]; then
291
+ cat <<EOF
292
+ {
293
+ "type": "project",
294
+ "complete": [$(printf '"%s",' "${complete[@]}" | sed 's/,$//')]
295
+ "missing": [$(printf '"%s",' "${missing[@]}" | sed 's/,$//')]
296
+ }
297
+ EOF
298
+ else
299
+ echo ""
300
+ echo -e "${CYAN}=== 项目级工件状态 ===${NC}"
301
+ echo ""
302
+
303
+ if [[ ${#complete[@]} -gt 0 ]]; then
304
+ echo -e "${GREEN}已完成 (${#complete[@]}):${NC}"
305
+ for a in "${complete[@]}"; do
306
+ local generates
307
+ generates=$(yq ".artifacts[] | select(.id == \"$a\") | .generates" "$WORKFLOW_YAML")
308
+ echo -e " ${GREEN}✓${NC} $a → $generates"
309
+ done
310
+ echo ""
311
+ fi
312
+
313
+ if [[ ${#missing[@]} -gt 0 ]]; then
314
+ echo -e "${YELLOW}缺失 (${#missing[@]}):${NC}"
315
+ for a in "${missing[@]}"; do
316
+ local skill generates
317
+ skill=$(yq ".artifacts[] | select(.id == \"$a\") | .skill" "$WORKFLOW_YAML")
318
+ generates=$(yq ".artifacts[] | select(.id == \"$a\") | .generates" "$WORKFLOW_YAML")
319
+ echo -e " ${YELLOW}○${NC} $a → $generates (skill: $skill)"
320
+ done
321
+ fi
322
+ fi
323
+ }
324
+
325
+ # 仅输出下一步可执行的工件
326
+ get_next_actions() {
327
+ local req_id="$1"
328
+
329
+ local artifacts
330
+ artifacts=$(yq '.artifacts[] | select(.generates | contains("{REQ}")) | .id' "$WORKFLOW_YAML")
331
+
332
+ while IFS= read -r artifact_id; do
333
+ [[ -z "$artifact_id" ]] && continue
334
+
335
+ local status is_optional
336
+ status=$(get_artifact_status "$artifact_id" "$req_id")
337
+ is_optional=$(yq ".artifacts[] | select(.id == \"$artifact_id\") | .optional // false" "$WORKFLOW_YAML")
338
+
339
+ if [[ "$status" == "ready" && "$is_optional" != "true" ]]; then
340
+ local skill
341
+ skill=$(yq ".artifacts[] | select(.id == \"$artifact_id\") | .skill" "$WORKFLOW_YAML")
342
+ echo "$artifact_id:$skill"
343
+ fi
344
+ done <<< "$artifacts"
345
+ }
346
+
347
+ # -----------------------------------------------------------------------------
348
+ # 主入口
349
+ # -----------------------------------------------------------------------------
350
+ main() {
351
+ check_dependencies
352
+
353
+ local req_id=""
354
+ local output_format="text"
355
+ local mode="requirement"
356
+
357
+ # 解析参数
358
+ while [[ $# -gt 0 ]]; do
359
+ case "$1" in
360
+ --json)
361
+ output_format="json"
362
+ shift
363
+ ;;
364
+ --next)
365
+ mode="next"
366
+ shift
367
+ ;;
368
+ --project)
369
+ mode="project"
370
+ shift
371
+ ;;
372
+ -h|--help)
373
+ echo "用法: $0 [REQ-ID] [选项]"
374
+ echo ""
375
+ echo "选项:"
376
+ echo " --json JSON 格式输出"
377
+ echo " --next 仅输出下一步可执行的工件"
378
+ echo " --project 检查项目级工件状态"
379
+ echo " -h, --help 显示帮助"
380
+ exit 0
381
+ ;;
382
+ REQ-*)
383
+ req_id="$1"
384
+ shift
385
+ ;;
386
+ *)
387
+ log_error "未知参数: $1"
388
+ exit 1
389
+ ;;
390
+ esac
391
+ done
392
+
393
+ # 执行
394
+ case "$mode" in
395
+ project)
396
+ get_project_status "$output_format"
397
+ ;;
398
+ next)
399
+ if [[ -z "$req_id" ]]; then
400
+ log_error "需要指定 REQ-ID"
401
+ exit 1
402
+ fi
403
+ get_next_actions "$req_id"
404
+ ;;
405
+ requirement)
406
+ if [[ -z "$req_id" ]]; then
407
+ log_error "需要指定 REQ-ID 或使用 --project"
408
+ exit 1
409
+ fi
410
+ get_requirement_status "$req_id" "$output_format"
411
+ ;;
412
+ esac
413
+ }
414
+
415
+ main "$@"