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,194 @@
1
+ #!/bin/bash
2
+ # ============================================================================
3
+ # flow-spec Entry Gate
4
+ # ============================================================================
5
+ # [INPUT]: REQ_ID (参数或自动检测)
6
+ # [OUTPUT]: 验证结果 (exit code 0=pass, 1=fail)
7
+ # [POS]: flow-spec 的入口检查,验证前置条件
8
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
9
+ # ============================================================================
10
+
11
+ set -euo pipefail
12
+
13
+ # ============================================================================
14
+ # 参数解析
15
+ # ============================================================================
16
+
17
+ REQ_ID=""
18
+ SKIP_TECH=false
19
+ SKIP_UI=false
20
+ RETRY=false
21
+ FROM_STAGE=""
22
+
23
+ while [[ $# -gt 0 ]]; do
24
+ case $1 in
25
+ --skip-tech)
26
+ SKIP_TECH=true
27
+ shift
28
+ ;;
29
+ --skip-ui)
30
+ SKIP_UI=true
31
+ shift
32
+ ;;
33
+ --retry)
34
+ RETRY=true
35
+ shift
36
+ ;;
37
+ --from=*)
38
+ FROM_STAGE="${1#*=}"
39
+ shift
40
+ ;;
41
+ *)
42
+ if [[ -z "$REQ_ID" ]]; then
43
+ REQ_ID="$1"
44
+ fi
45
+ shift
46
+ ;;
47
+ esac
48
+ done
49
+
50
+ # ============================================================================
51
+ # REQ_ID 解析
52
+ # ============================================================================
53
+
54
+ if [[ -z "$REQ_ID" ]]; then
55
+ # 尝试从分支名推断
56
+ BRANCH=$(git branch --show-current 2>/dev/null || echo "")
57
+ if [[ "$BRANCH" =~ feature/(REQ-[0-9]+) ]]; then
58
+ REQ_ID="${BASH_REMATCH[1]}"
59
+ fi
60
+ fi
61
+
62
+ if [[ -z "$REQ_ID" ]]; then
63
+ # 尝试从 orchestration_status.json 获取
64
+ STATUS_FILE="devflow/requirements/*/orchestration_status.json"
65
+ for f in $STATUS_FILE; do
66
+ if [[ -f "$f" ]]; then
67
+ REQ_ID=$(jq -r '.req_id // empty' "$f" 2>/dev/null || echo "")
68
+ if [[ -n "$REQ_ID" ]]; then
69
+ break
70
+ fi
71
+ fi
72
+ done
73
+ fi
74
+
75
+ if [[ -z "$REQ_ID" ]]; then
76
+ echo "ERROR: REQ_ID not provided and cannot be auto-detected"
77
+ echo "Usage: entry-gate.sh REQ-XXX [--skip-tech] [--skip-ui]"
78
+ exit 1
79
+ fi
80
+
81
+ # ============================================================================
82
+ # 路径定义
83
+ # ============================================================================
84
+
85
+ REQ_DIR="devflow/requirements/${REQ_ID}"
86
+ BRAINSTORM_FILE="${REQ_DIR}/BRAINSTORM.md"
87
+ RESEARCH_FILE="${REQ_DIR}/research/research.md"
88
+ STATUS_FILE="${REQ_DIR}/orchestration_status.json"
89
+
90
+ # ============================================================================
91
+ # 检查 1: REQ_ID 格式
92
+ # ============================================================================
93
+
94
+ if [[ ! "$REQ_ID" =~ ^REQ-[0-9]+$ ]]; then
95
+ echo "ERROR: Invalid REQ_ID format: $REQ_ID"
96
+ echo "Expected: REQ-XXX (e.g., REQ-001, REQ-123)"
97
+ exit 1
98
+ fi
99
+
100
+ echo "✓ REQ_ID format valid: $REQ_ID"
101
+
102
+ # ============================================================================
103
+ # 检查 2: 目录存在
104
+ # ============================================================================
105
+
106
+ if [[ ! -d "$REQ_DIR" ]]; then
107
+ echo "ERROR: Requirement directory not found: $REQ_DIR"
108
+ echo "Run /flow-init first"
109
+ exit 1
110
+ fi
111
+
112
+ echo "✓ Requirement directory exists: $REQ_DIR"
113
+
114
+ # ============================================================================
115
+ # 检查 3: BRAINSTORM.md 存在
116
+ # ============================================================================
117
+
118
+ if [[ ! -f "$BRAINSTORM_FILE" ]]; then
119
+ echo "ERROR: BRAINSTORM.md not found: $BRAINSTORM_FILE"
120
+ echo "Run /flow-init first"
121
+ exit 1
122
+ fi
123
+
124
+ echo "✓ BRAINSTORM.md exists"
125
+
126
+ # ============================================================================
127
+ # 检查 4: Research 完成
128
+ # ============================================================================
129
+
130
+ if [[ ! -f "$RESEARCH_FILE" ]]; then
131
+ echo "ERROR: research.md not found: $RESEARCH_FILE"
132
+ echo "Run /flow-init with research first"
133
+ exit 1
134
+ fi
135
+
136
+ # 检查 research.md 无 TODO/PLACEHOLDER
137
+ if grep -qE '\{\{[A-Z_]+\}\}|TODO|TBD|PLACEHOLDER' "$RESEARCH_FILE"; then
138
+ echo "WARNING: research.md contains TODO/PLACEHOLDER markers"
139
+ echo "Consider completing research before proceeding"
140
+ fi
141
+
142
+ echo "✓ Research file exists"
143
+
144
+ # ============================================================================
145
+ # 检查 5: Status Check
146
+ # ============================================================================
147
+
148
+ if [[ -f "$STATUS_FILE" ]]; then
149
+ CURRENT_STATUS=$(jq -r '.status // "unknown"' "$STATUS_FILE")
150
+
151
+ VALID_STATUSES=("initialized" "spec_failed" "prd_complete" "tech_design_complete" "ui_complete")
152
+
153
+ if [[ "$RETRY" == "true" ]]; then
154
+ echo "✓ Retry mode: bypassing status check"
155
+ elif [[ ! " ${VALID_STATUSES[*]} " =~ " ${CURRENT_STATUS} " ]]; then
156
+ echo "ERROR: Invalid status for /flow-spec: $CURRENT_STATUS"
157
+ echo "Valid statuses: ${VALID_STATUSES[*]}"
158
+ exit 1
159
+ else
160
+ echo "✓ Status valid: $CURRENT_STATUS"
161
+ fi
162
+ else
163
+ echo "WARNING: orchestration_status.json not found, creating..."
164
+ fi
165
+
166
+ # ============================================================================
167
+ # 输出结果
168
+ # ============================================================================
169
+
170
+ echo ""
171
+ echo "============================================"
172
+ echo "Entry Gate PASSED"
173
+ echo "============================================"
174
+ echo "REQ_ID: $REQ_ID"
175
+ echo "REQ_DIR: $REQ_DIR"
176
+ echo "SKIP_TECH: $SKIP_TECH"
177
+ echo "SKIP_UI: $SKIP_UI"
178
+ echo "FROM_STAGE: ${FROM_STAGE:-prd}"
179
+ echo "============================================"
180
+
181
+ # 输出 JSON 供后续脚本使用
182
+ cat << EOF
183
+ {
184
+ "req_id": "$REQ_ID",
185
+ "req_dir": "$REQ_DIR",
186
+ "skip_tech": $SKIP_TECH,
187
+ "skip_ui": $SKIP_UI,
188
+ "from_stage": "${FROM_STAGE:-prd}",
189
+ "brainstorm_file": "$BRAINSTORM_FILE",
190
+ "research_file": "$RESEARCH_FILE"
191
+ }
192
+ EOF
193
+
194
+ exit 0
@@ -0,0 +1,244 @@
1
+ #!/bin/bash
2
+ # ============================================================================
3
+ # flow-spec Exit Gate
4
+ # ============================================================================
5
+ # [INPUT]: REQ_ID, 生成的文件列表
6
+ # [OUTPUT]: 验证结果 (exit code 0=pass, 1=fail)
7
+ # [POS]: flow-spec 的出口检查,验证所有输出文件
8
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
9
+ # ============================================================================
10
+
11
+ set -euo pipefail
12
+
13
+ # ============================================================================
14
+ # 参数解析
15
+ # ============================================================================
16
+
17
+ REQ_ID=""
18
+ SKIP_TECH=false
19
+ SKIP_UI=false
20
+
21
+ while [[ $# -gt 0 ]]; do
22
+ case $1 in
23
+ --skip-tech)
24
+ SKIP_TECH=true
25
+ shift
26
+ ;;
27
+ --skip-ui)
28
+ SKIP_UI=true
29
+ shift
30
+ ;;
31
+ *)
32
+ if [[ -z "$REQ_ID" ]]; then
33
+ REQ_ID="$1"
34
+ fi
35
+ shift
36
+ ;;
37
+ esac
38
+ done
39
+
40
+ if [[ -z "$REQ_ID" ]]; then
41
+ echo "ERROR: REQ_ID required"
42
+ exit 1
43
+ fi
44
+
45
+ # ============================================================================
46
+ # 路径定义
47
+ # ============================================================================
48
+
49
+ REQ_DIR="devflow/requirements/${REQ_ID}"
50
+ PRD_FILE="${REQ_DIR}/PRD.md"
51
+ TECH_FILE="${REQ_DIR}/TECH_DESIGN.md"
52
+ UI_FILE="${REQ_DIR}/UI_PROTOTYPE.html"
53
+ EPIC_FILE="${REQ_DIR}/EPIC.md"
54
+ TASKS_FILE="${REQ_DIR}/TASKS.md"
55
+ STATUS_FILE="${REQ_DIR}/orchestration_status.json"
56
+
57
+ ERRORS=()
58
+ WARNINGS=()
59
+
60
+ # ============================================================================
61
+ # 检查 1: PRD.md
62
+ # ============================================================================
63
+
64
+ echo "Checking PRD.md..."
65
+
66
+ if [[ ! -f "$PRD_FILE" ]]; then
67
+ ERRORS+=("PRD.md not found")
68
+ else
69
+ # 检查 placeholder
70
+ if grep -qE '\{\{[A-Z_]+\}\}' "$PRD_FILE"; then
71
+ ERRORS+=("PRD.md contains {{PLACEHOLDER}} markers")
72
+ fi
73
+ echo "✓ PRD.md exists and valid"
74
+ fi
75
+
76
+ # ============================================================================
77
+ # 检查 2: TECH_DESIGN.md (如果未跳过)
78
+ # ============================================================================
79
+
80
+ if [[ "$SKIP_TECH" == "false" ]]; then
81
+ echo "Checking TECH_DESIGN.md..."
82
+
83
+ if [[ ! -f "$TECH_FILE" ]]; then
84
+ ERRORS+=("TECH_DESIGN.md not found (use --skip-tech to skip)")
85
+ else
86
+ if grep -qE '\{\{[A-Z_]+\}\}' "$TECH_FILE"; then
87
+ ERRORS+=("TECH_DESIGN.md contains {{PLACEHOLDER}} markers")
88
+ fi
89
+
90
+ # 检查必需章节
91
+ if ! grep -q "## 1. System Architecture" "$TECH_FILE"; then
92
+ WARNINGS+=("TECH_DESIGN.md missing System Architecture section")
93
+ fi
94
+ if ! grep -q "## 4. API Design" "$TECH_FILE"; then
95
+ WARNINGS+=("TECH_DESIGN.md missing API Design section")
96
+ fi
97
+
98
+ echo "✓ TECH_DESIGN.md exists"
99
+ fi
100
+ else
101
+ echo "⊘ TECH_DESIGN.md skipped"
102
+ fi
103
+
104
+ # ============================================================================
105
+ # 检查 3: UI_PROTOTYPE.html (如果未跳过)
106
+ # ============================================================================
107
+
108
+ if [[ "$SKIP_UI" == "false" ]]; then
109
+ echo "Checking UI_PROTOTYPE.html..."
110
+
111
+ # 检查 PRD 是否有 UI 关键词
112
+ HAS_UI_KEYWORDS=false
113
+ if [[ -f "$PRD_FILE" ]]; then
114
+ if grep -qiE '用户界面|前端|页面|交互|UI|界面设计' "$PRD_FILE"; then
115
+ HAS_UI_KEYWORDS=true
116
+ fi
117
+ fi
118
+
119
+ if [[ "$HAS_UI_KEYWORDS" == "true" ]]; then
120
+ if [[ ! -f "$UI_FILE" ]]; then
121
+ WARNINGS+=("UI_PROTOTYPE.html not found but PRD contains UI keywords")
122
+ else
123
+ echo "✓ UI_PROTOTYPE.html exists"
124
+ fi
125
+ else
126
+ echo "⊘ UI_PROTOTYPE.html not required (no UI keywords in PRD)"
127
+ fi
128
+ else
129
+ echo "⊘ UI_PROTOTYPE.html skipped"
130
+ fi
131
+
132
+ # ============================================================================
133
+ # 检查 4: EPIC.md
134
+ # ============================================================================
135
+
136
+ echo "Checking EPIC.md..."
137
+
138
+ if [[ ! -f "$EPIC_FILE" ]]; then
139
+ ERRORS+=("EPIC.md not found")
140
+ else
141
+ if grep -qE '\{\{[A-Z_]+\}\}' "$EPIC_FILE"; then
142
+ ERRORS+=("EPIC.md contains {{PLACEHOLDER}} markers")
143
+ fi
144
+ echo "✓ EPIC.md exists and valid"
145
+ fi
146
+
147
+ # ============================================================================
148
+ # 检查 5: TASKS.md
149
+ # ============================================================================
150
+
151
+ echo "Checking TASKS.md..."
152
+
153
+ if [[ ! -f "$TASKS_FILE" ]]; then
154
+ ERRORS+=("TASKS.md not found")
155
+ else
156
+ if grep -qE '\{\{[A-Z_]+\}\}' "$TASKS_FILE"; then
157
+ ERRORS+=("TASKS.md contains {{PLACEHOLDER}} markers")
158
+ fi
159
+
160
+ # 检查 TDD 顺序: Phase 2 (Tests) 应该在 Phase 3 (Implementation) 之前
161
+ PHASE2_LINE=$(grep -n "Phase 2" "$TASKS_FILE" | head -1 | cut -d: -f1 || echo "0")
162
+ PHASE3_LINE=$(grep -n "Phase 3" "$TASKS_FILE" | head -1 | cut -d: -f1 || echo "0")
163
+
164
+ if [[ "$PHASE2_LINE" -gt 0 && "$PHASE3_LINE" -gt 0 ]]; then
165
+ if [[ "$PHASE2_LINE" -gt "$PHASE3_LINE" ]]; then
166
+ ERRORS+=("TASKS.md TDD order incorrect: Phase 2 (Tests) should come before Phase 3 (Implementation)")
167
+ else
168
+ echo "✓ TASKS.md TDD order correct"
169
+ fi
170
+ fi
171
+
172
+ echo "✓ TASKS.md exists"
173
+ fi
174
+
175
+ # ============================================================================
176
+ # 更新状态
177
+ # ============================================================================
178
+
179
+ if [[ ${#ERRORS[@]} -eq 0 ]]; then
180
+ echo "Updating orchestration_status.json..."
181
+
182
+ # 构建输出文件列表
183
+ OUTPUTS='["PRD.md", "EPIC.md", "TASKS.md"'
184
+ if [[ "$SKIP_TECH" == "false" && -f "$TECH_FILE" ]]; then
185
+ OUTPUTS+=', "TECH_DESIGN.md"'
186
+ fi
187
+ if [[ "$SKIP_UI" == "false" && -f "$UI_FILE" ]]; then
188
+ OUTPUTS+=', "UI_PROTOTYPE.html"'
189
+ fi
190
+ OUTPUTS+=']'
191
+
192
+ # 更新状态文件
193
+ if [[ -f "$STATUS_FILE" ]]; then
194
+ jq --arg status "spec_complete" \
195
+ --arg phase "spec" \
196
+ --argjson outputs "$OUTPUTS" \
197
+ '.status = $status | .phase = $phase | .outputs = $outputs | .updated_at = now | .spec_completed_at = now' \
198
+ "$STATUS_FILE" > "${STATUS_FILE}.tmp" && mv "${STATUS_FILE}.tmp" "$STATUS_FILE"
199
+ fi
200
+
201
+ echo "✓ Status updated to spec_complete"
202
+ fi
203
+
204
+ # ============================================================================
205
+ # 输出结果
206
+ # ============================================================================
207
+
208
+ echo ""
209
+ echo "============================================"
210
+
211
+ if [[ ${#ERRORS[@]} -gt 0 ]]; then
212
+ echo "Exit Gate FAILED"
213
+ echo "============================================"
214
+ echo ""
215
+ echo "ERRORS:"
216
+ for err in "${ERRORS[@]}"; do
217
+ echo " ✗ $err"
218
+ done
219
+ fi
220
+
221
+ if [[ ${#WARNINGS[@]} -gt 0 ]]; then
222
+ echo ""
223
+ echo "WARNINGS:"
224
+ for warn in "${WARNINGS[@]}"; do
225
+ echo " ⚠ $warn"
226
+ done
227
+ fi
228
+
229
+ if [[ ${#ERRORS[@]} -eq 0 ]]; then
230
+ echo "Exit Gate PASSED"
231
+ echo "============================================"
232
+ echo ""
233
+ echo "Generated files:"
234
+ echo " - PRD.md"
235
+ [[ "$SKIP_TECH" == "false" && -f "$TECH_FILE" ]] && echo " - TECH_DESIGN.md"
236
+ [[ "$SKIP_UI" == "false" && -f "$UI_FILE" ]] && echo " - UI_PROTOTYPE.html"
237
+ echo " - EPIC.md"
238
+ echo " - TASKS.md"
239
+ echo ""
240
+ echo "Next step: /flow-dev \"$REQ_ID\""
241
+ exit 0
242
+ else
243
+ exit 1
244
+ fi
@@ -0,0 +1,205 @@
1
+ #!/bin/bash
2
+ # ============================================================================
3
+ # flow-spec Parallel Orchestrator
4
+ # ============================================================================
5
+ # [INPUT]: REQ_ID, 模式标志
6
+ # [OUTPUT]: 并行执行状态
7
+ # [POS]: 协调 tech-architect 和 ui-designer 的并行执行
8
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
9
+ # ============================================================================
10
+
11
+ # 注意: 此脚本主要用于文档目的
12
+ # 实际的并行执行由 Claude 的 Task tool 处理
13
+ # 此脚本提供执行逻辑的参考实现
14
+
15
+ set -euo pipefail
16
+
17
+ # ============================================================================
18
+ # 参数解析
19
+ # ============================================================================
20
+
21
+ REQ_ID=""
22
+ SKIP_TECH=false
23
+ SKIP_UI=false
24
+
25
+ while [[ $# -gt 0 ]]; do
26
+ case $1 in
27
+ --skip-tech)
28
+ SKIP_TECH=true
29
+ shift
30
+ ;;
31
+ --skip-ui)
32
+ SKIP_UI=true
33
+ shift
34
+ ;;
35
+ *)
36
+ if [[ -z "$REQ_ID" ]]; then
37
+ REQ_ID="$1"
38
+ fi
39
+ shift
40
+ ;;
41
+ esac
42
+ done
43
+
44
+ if [[ -z "$REQ_ID" ]]; then
45
+ echo "ERROR: REQ_ID required"
46
+ exit 1
47
+ fi
48
+
49
+ # ============================================================================
50
+ # 路径定义
51
+ # ============================================================================
52
+
53
+ REQ_DIR="devflow/requirements/${REQ_ID}"
54
+ PRD_FILE="${REQ_DIR}/PRD.md"
55
+ EXECUTION_LOG="${REQ_DIR}/EXECUTION_LOG.md"
56
+
57
+ # ============================================================================
58
+ # 并行执行逻辑 (伪代码)
59
+ # ============================================================================
60
+
61
+ cat << 'EOF'
62
+ ============================================
63
+ Parallel Orchestration Logic
64
+ ============================================
65
+
66
+ This script documents the parallel execution strategy.
67
+ Actual execution is handled by Claude's Task tool.
68
+
69
+ Execution Flow:
70
+ ---------------
71
+
72
+ 1. PRD Generation (Sequential - Must complete first)
73
+ Agent: prd-writer
74
+ Output: PRD.md
75
+
76
+ 2. Parallel Execution (After PRD completes)
77
+
78
+ ┌─────────────────────────────────────────────────────┐
79
+ │ │
80
+ │ ┌─────────────────┐ ┌─────────────────┐ │
81
+ │ │ tech-architect │ │ ui-designer │ │
82
+ │ │ │ │ │ │
83
+ │ │ Condition: │ │ Condition: │ │
84
+ │ │ !--skip-tech │ │ !--skip-ui AND │ │
85
+ │ │ │ │ UI keywords in │ │
86
+ │ │ │ │ PRD │ │
87
+ │ │ │ │ │ │
88
+ │ │ Output: │ │ Output: │ │
89
+ │ │ - TECH_DESIGN │ │ - UI_PROTOTYPE │ │
90
+ │ │ - data-model │ │ - ui_design_ │ │
91
+ │ │ - contracts/ │ │ strategy.md │ │
92
+ │ └────────┬────────┘ └────────┬────────┘ │
93
+ │ │ │ │
94
+ │ └──────────┬───────────┘ │
95
+ │ │ │
96
+ │ ▼ │
97
+ │ Wait for both │
98
+ │ │
99
+ └─────────────────────────────────────────────────────┘
100
+
101
+ 3. Epic Generation (After parallel stage completes)
102
+ Agent: planner
103
+ Input: PRD.md + TECH_DESIGN.md (optional) + UI_PROTOTYPE.html (optional)
104
+ Output: EPIC.md + TASKS.md
105
+
106
+ Claude Task Tool Usage:
107
+ -----------------------
108
+
109
+ // Stage 2: Parallel execution
110
+ const tasks = [];
111
+
112
+ if (!skipTech) {
113
+ tasks.push(Task({
114
+ subagent_type: "tech-architect",
115
+ prompt: `Generate TECH_DESIGN.md for ${REQ_ID}`,
116
+ description: "Tech design generation"
117
+ }));
118
+ }
119
+
120
+ if (!skipUI && hasUIKeywords) {
121
+ tasks.push(Task({
122
+ subagent_type: "ui-designer",
123
+ prompt: `Generate UI_PROTOTYPE.html for ${REQ_ID}`,
124
+ description: "UI prototype generation"
125
+ }));
126
+ }
127
+
128
+ // Execute in parallel
129
+ await Promise.all(tasks);
130
+
131
+ Error Handling:
132
+ ---------------
133
+
134
+ - If tech-architect fails: Continue with UI, mark tech as skipped
135
+ - If ui-designer fails: Continue without UI, mark ui as skipped
136
+ - If both fail: Log error, status = spec_failed
137
+
138
+ Timing Expectations:
139
+ --------------------
140
+
141
+ | Stage | Duration | Notes |
142
+ |-------|----------|-------|
143
+ | PRD | 2-3 min | Sequential |
144
+ | Tech | 2-3 min | Parallel |
145
+ | UI | 2-3 min | Parallel |
146
+ | Epic | 2-3 min | Sequential |
147
+ | Total | 5-8 min | With parallelization |
148
+
149
+ Without parallelization: 8-12 min
150
+ Improvement: ~35% time reduction
151
+
152
+ ============================================
153
+ EOF
154
+
155
+ # ============================================================================
156
+ # 检测 UI 关键词
157
+ # ============================================================================
158
+
159
+ echo ""
160
+ echo "Checking PRD for UI keywords..."
161
+
162
+ if [[ -f "$PRD_FILE" ]]; then
163
+ if grep -qiE '用户界面|前端|页面|交互|UI|界面设计|Web页面' "$PRD_FILE"; then
164
+ echo "✓ UI keywords detected in PRD"
165
+ echo " ui-designer will be invoked (unless --skip-ui)"
166
+ else
167
+ echo "⊘ No UI keywords in PRD"
168
+ echo " ui-designer will be skipped"
169
+ fi
170
+ else
171
+ echo "✗ PRD.md not found"
172
+ fi
173
+
174
+ # ============================================================================
175
+ # 输出执行计划
176
+ # ============================================================================
177
+
178
+ echo ""
179
+ echo "============================================"
180
+ echo "Execution Plan for $REQ_ID"
181
+ echo "============================================"
182
+ echo ""
183
+ echo "Stage 1: PRD Generation"
184
+ echo " Agent: prd-writer"
185
+ echo " Status: Pending"
186
+ echo ""
187
+ echo "Stage 2: Parallel Execution"
188
+ if [[ "$SKIP_TECH" == "false" ]]; then
189
+ echo " [A] tech-architect: Enabled"
190
+ else
191
+ echo " [A] tech-architect: Skipped (--skip-tech)"
192
+ fi
193
+ if [[ "$SKIP_UI" == "false" ]]; then
194
+ echo " [B] ui-designer: Enabled (if UI keywords)"
195
+ else
196
+ echo " [B] ui-designer: Skipped (--skip-ui)"
197
+ fi
198
+ echo ""
199
+ echo "Stage 3: Epic Generation"
200
+ echo " Agent: planner"
201
+ echo " Status: Pending"
202
+ echo ""
203
+ echo "============================================"
204
+
205
+ exit 0