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,353 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # Team Communication Protocol for flow-spec
4
+ # =============================================================================
5
+ # [INPUT]: 依赖 common.sh 的 Team 函数,team-config.json 的协商主题
6
+ # [OUTPUT]: 对外提供协商消息生成和决策记录功能
7
+ # [POS]: flow-spec/scripts/ 的 Team 通信协议,被 tech-architect 和 ui-designer 消费
8
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
9
+ # =============================================================================
10
+
11
+ set -euo pipefail
12
+
13
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
+ source "$SCRIPT_DIR/../../../../scripts/common.sh"
15
+
16
+ # =============================================================================
17
+ # Negotiate Message Generation
18
+ # =============================================================================
19
+
20
+ # Generate a negotiate message from template
21
+ # Args: $1 - topic_id, $2 - sender, $3 - content (JSON)
22
+ generate_negotiate_message() {
23
+ local topic_id="$1"
24
+ local sender="$2"
25
+ local content="$3"
26
+ local timestamp
27
+ timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
28
+
29
+ cat <<EOF
30
+ {
31
+ "type": "negotiate",
32
+ "topic_id": "$topic_id",
33
+ "sender": "$sender",
34
+ "timestamp": "$timestamp",
35
+ "content": $content
36
+ }
37
+ EOF
38
+ }
39
+
40
+ # Get negotiate topic template
41
+ # Args: $1 - topic_id
42
+ get_topic_template() {
43
+ local topic_id="$1"
44
+ local config_file="$SCRIPT_DIR/../team-config.json"
45
+
46
+ if [[ ! -f "$config_file" ]]; then
47
+ echo "Error: team-config.json not found" >&2
48
+ return 1
49
+ fi
50
+
51
+ # Extract template for topic
52
+ jq -r --arg tid "$topic_id" \
53
+ '.communication.negotiate_topics[] | select(.id == $tid) | .template // empty' \
54
+ "$config_file"
55
+ }
56
+
57
+ # Get topic participants
58
+ # Args: $1 - topic_id
59
+ get_topic_participants() {
60
+ local topic_id="$1"
61
+ local config_file="$SCRIPT_DIR/../team-config.json"
62
+
63
+ jq -r --arg tid "$topic_id" \
64
+ '.communication.negotiate_topics[] | select(.id == $tid) | .participants | join(",")' \
65
+ "$config_file"
66
+ }
67
+
68
+ # Get topic decision owner
69
+ # Args: $1 - topic_id
70
+ get_topic_decision_owner() {
71
+ local topic_id="$1"
72
+ local config_file="$SCRIPT_DIR/../team-config.json"
73
+
74
+ jq -r --arg tid "$topic_id" \
75
+ '.communication.negotiate_topics[] | select(.id == $tid) | .decision_owner' \
76
+ "$config_file"
77
+ }
78
+
79
+ # =============================================================================
80
+ # Decision Recording
81
+ # =============================================================================
82
+
83
+ # Initialize design decisions file
84
+ # Args: $1 - repo_root, $2 - req_id
85
+ init_design_decisions() {
86
+ local repo_root="$1"
87
+ local req_id="$2"
88
+ local decisions_dir="$repo_root/devflow/requirements/$req_id/research"
89
+ local decisions_file="$decisions_dir/design_decisions.md"
90
+ local timestamp
91
+ timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
92
+
93
+ mkdir -p "$decisions_dir"
94
+
95
+ if [[ ! -f "$decisions_file" ]]; then
96
+ cat > "$decisions_file" <<EOF
97
+ # Design Decisions for $req_id
98
+
99
+ > [INPUT]: 依赖 team-config.json 的 negotiate_topics 定义
100
+ > [OUTPUT]: 对外提供设计决策记录
101
+ > [POS]: research/ 的 Team 协商决策记录,被 planner 消费
102
+ > [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
103
+
104
+ ---
105
+ req_id: "$req_id"
106
+ created_at: "$timestamp"
107
+ updated_at: "$timestamp"
108
+ participants: ["tech-architect", "ui-designer", "planner"]
109
+ ---
110
+
111
+ ## Decision Log
112
+
113
+ <!-- Decisions will be appended below -->
114
+
115
+ ## Summary
116
+
117
+ | Topic | Decision | Owner | Status |
118
+ |-------|----------|-------|--------|
119
+ | api_format | - | tech-architect | pending |
120
+ | field_naming | - | tech-architect | pending |
121
+ | auth_strategy | - | tech-architect | pending |
122
+ | state_management | - | ui-designer | pending |
123
+ | component_granularity | - | ui-designer | pending |
124
+
125
+ ## Changelog
126
+
127
+ | Date | Topic | Change | By |
128
+ |------|-------|--------|-----|
129
+ | $timestamp | - | Initial creation | spec-lead |
130
+ EOF
131
+ echo "Created design_decisions.md at $decisions_file"
132
+ else
133
+ echo "design_decisions.md already exists at $decisions_file"
134
+ fi
135
+ }
136
+
137
+ # Record a design decision
138
+ # Args: $1 - repo_root, $2 - req_id, $3 - topic_id, $4 - decision_json
139
+ record_decision() {
140
+ local repo_root="$1"
141
+ local req_id="$2"
142
+ local topic_id="$3"
143
+ local decision_json="$4"
144
+ local decisions_file="$repo_root/devflow/requirements/$req_id/research/design_decisions.md"
145
+ local timestamp
146
+ timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
147
+
148
+ if [[ ! -f "$decisions_file" ]]; then
149
+ init_design_decisions "$repo_root" "$req_id"
150
+ fi
151
+
152
+ # Extract decision details from JSON
153
+ local decision
154
+ local rationale
155
+ local owner
156
+ local status
157
+ decision=$(echo "$decision_json" | jq -r '.decision // "TBD"')
158
+ rationale=$(echo "$decision_json" | jq -r '.rationale // "TBD"')
159
+ owner=$(get_topic_decision_owner "$topic_id")
160
+ status=$(echo "$decision_json" | jq -r '.status // "approved"')
161
+
162
+ # Get next decision number
163
+ local decision_num
164
+ decision_num=$(grep -c "^### DD-" "$decisions_file" 2>/dev/null || echo "0")
165
+ decision_num=$((decision_num + 1))
166
+ local decision_id
167
+ decision_id=$(printf "DD-%03d" "$decision_num")
168
+
169
+ # Get topic name from config
170
+ local topic_name
171
+ topic_name=$(jq -r --arg tid "$topic_id" \
172
+ '.communication.negotiate_topics[] | select(.id == $tid) | .name' \
173
+ "$SCRIPT_DIR/../team-config.json")
174
+
175
+ # Append decision to file
176
+ cat >> "$decisions_file" <<EOF
177
+
178
+ ### $decision_id: $topic_name
179
+
180
+ **Topic ID**: \`$topic_id\`
181
+ **Decision Owner**: $owner
182
+ **Participants**: $(get_topic_participants "$topic_id")
183
+ **Status**: $status
184
+
185
+ **Decision**:
186
+ $decision
187
+
188
+ **Rationale**:
189
+ $rationale
190
+
191
+ **Timestamp**: $timestamp
192
+
193
+ ---
194
+ EOF
195
+
196
+ # Update summary table
197
+ sed -i '' "s/| $topic_id | .* |/| $topic_id | $decision | $owner | $status |/" "$decisions_file" 2>/dev/null || true
198
+
199
+ # Update changelog
200
+ local changelog_entry="| $timestamp | $topic_id | Decision recorded | $owner |"
201
+ sed -i '' "/^## Changelog/,/^$/{ /^|.*|$/a\\
202
+ $changelog_entry
203
+ }" "$decisions_file" 2>/dev/null || true
204
+
205
+ echo "Recorded decision $decision_id for topic $topic_id"
206
+ }
207
+
208
+ # =============================================================================
209
+ # SendMessage Integration Examples
210
+ # =============================================================================
211
+
212
+ # Example: tech-architect initiates API format negotiation
213
+ example_api_format_negotiate() {
214
+ cat <<'EOF'
215
+ # tech-architect 发起 API 格式协商
216
+
217
+ ## SendMessage 调用示例
218
+
219
+ ```json
220
+ {
221
+ "type": "message",
222
+ "recipient": "ui-designer",
223
+ "content": "我建议 API 响应格式采用 RESTful JSON,分页使用 cursor-based pagination。响应结构如下:\n\n```json\n{\n \"data\": [...],\n \"meta\": {\n \"cursor\": \"xxx\",\n \"hasMore\": true\n }\n}\n```\n\n你的前端需求是否有特殊要求?",
224
+ "summary": "API format negotiation - RESTful JSON"
225
+ }
226
+ ```
227
+
228
+ ## ui-designer 响应示例
229
+
230
+ ```json
231
+ {
232
+ "type": "message",
233
+ "recipient": "tech-architect",
234
+ "content": "同意 RESTful JSON 方案。建议 meta 中增加 total 字段用于显示总数。另外,错误响应格式建议统一为:\n\n```json\n{\n \"error\": {\n \"code\": \"ERR_XXX\",\n \"message\": \"...\"\n }\n}\n```",
235
+ "summary": "API format agreement with suggestions"
236
+ }
237
+ ```
238
+ EOF
239
+ }
240
+
241
+ # Example: ui-designer initiates state management negotiation
242
+ example_state_management_negotiate() {
243
+ cat <<'EOF'
244
+ # ui-designer 发起状态管理协商
245
+
246
+ ## SendMessage 调用示例
247
+
248
+ ```json
249
+ {
250
+ "type": "message",
251
+ "recipient": "tech-architect",
252
+ "content": "前端状态管理建议采用 Zustand,全局状态包括:\n\n1. user: 用户信息\n2. auth: 认证状态\n3. ui: UI 状态 (sidebar, modal)\n\n这些状态需要与后端 API 同步,请确认数据结构是否匹配。",
253
+ "summary": "State management proposal - Zustand"
254
+ }
255
+ ```
256
+ EOF
257
+ }
258
+
259
+ # =============================================================================
260
+ # Main
261
+ # =============================================================================
262
+
263
+ main() {
264
+ local action="${1:-help}"
265
+ local repo_root="${2:-$(get_repo_root)}"
266
+ local req_id="${3:-$(get_current_req_id)}"
267
+
268
+ case "$action" in
269
+ init)
270
+ init_design_decisions "$repo_root" "$req_id"
271
+ ;;
272
+ record)
273
+ local topic_id="${4:-}"
274
+ local decision_json="${5:-'{}'}"
275
+ if [[ -z "$topic_id" ]]; then
276
+ echo "Usage: $0 record <repo_root> <req_id> <topic_id> <decision_json>" >&2
277
+ exit 1
278
+ fi
279
+ record_decision "$repo_root" "$req_id" "$topic_id" "$decision_json"
280
+ ;;
281
+ template)
282
+ local topic_id="${4:-}"
283
+ if [[ -z "$topic_id" ]]; then
284
+ echo "Usage: $0 template <repo_root> <req_id> <topic_id>" >&2
285
+ exit 1
286
+ fi
287
+ get_topic_template "$topic_id"
288
+ ;;
289
+ participants)
290
+ local topic_id="${4:-}"
291
+ if [[ -z "$topic_id" ]]; then
292
+ echo "Usage: $0 participants <repo_root> <req_id> <topic_id>" >&2
293
+ exit 1
294
+ fi
295
+ get_topic_participants "$topic_id"
296
+ ;;
297
+ owner)
298
+ local topic_id="${4:-}"
299
+ if [[ -z "$topic_id" ]]; then
300
+ echo "Usage: $0 owner <repo_root> <req_id> <topic_id>" >&2
301
+ exit 1
302
+ fi
303
+ get_topic_decision_owner "$topic_id"
304
+ ;;
305
+ example-api)
306
+ example_api_format_negotiate
307
+ ;;
308
+ example-state)
309
+ example_state_management_negotiate
310
+ ;;
311
+ help|*)
312
+ cat <<EOF
313
+ Team Communication Protocol for flow-spec
314
+
315
+ Usage: $0 <action> [args...]
316
+
317
+ Actions:
318
+ init <repo_root> <req_id>
319
+ Initialize design_decisions.md for a requirement
320
+
321
+ record <repo_root> <req_id> <topic_id> <decision_json>
322
+ Record a design decision
323
+
324
+ template <repo_root> <req_id> <topic_id>
325
+ Get negotiate message template for a topic
326
+
327
+ participants <repo_root> <req_id> <topic_id>
328
+ Get participants for a topic
329
+
330
+ owner <repo_root> <req_id> <topic_id>
331
+ Get decision owner for a topic
332
+
333
+ example-api
334
+ Show API format negotiation example
335
+
336
+ example-state
337
+ Show state management negotiation example
338
+
339
+ Topics:
340
+ api_format - API 响应格式
341
+ field_naming - 数据字段命名
342
+ auth_strategy - 认证策略
343
+ state_management - 状态管理方案
344
+ component_granularity - 组件粒度
345
+ EOF
346
+ ;;
347
+ esac
348
+ }
349
+
350
+ # Run if executed directly
351
+ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
352
+ main "$@"
353
+ fi
@@ -0,0 +1,195 @@
1
+ #!/usr/bin/env bash
2
+ # =============================================================================
3
+ # Team Mode Initialization for flow-spec
4
+ # =============================================================================
5
+ # [INPUT]: 依赖 common.sh 的 Team 函数
6
+ # [OUTPUT]: 初始化 Team 状态,创建 spec-design-team
7
+ # [POS]: flow-spec/scripts/ 的 Team 初始化器
8
+ # [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
9
+ # =============================================================================
10
+
11
+ set -euo pipefail
12
+
13
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
14
+ REPO_ROOT="$(cd "$SCRIPT_DIR/../../../../.." && pwd)"
15
+ source "$REPO_ROOT/.claude/scripts/common.sh"
16
+
17
+ # =============================================================================
18
+ # Mode Detection
19
+ # =============================================================================
20
+
21
+ # Detect whether to use Team or Subagent mode
22
+ # Args: $1 - skip_tech flag (true/false), $2 - skip_ui flag (true/false)
23
+ # Returns: "team" or "subagent"
24
+ detect_execution_mode() {
25
+ local skip_tech="${1:-false}"
26
+ local skip_ui="${2:-false}"
27
+
28
+ # Team mode requires both tech and ui (Full Mode)
29
+ # Subagent mode for simplified modes
30
+ if [[ "$skip_tech" == "true" ]] || [[ "$skip_ui" == "true" ]]; then
31
+ echo "subagent"
32
+ else
33
+ echo "team"
34
+ fi
35
+ }
36
+
37
+ # =============================================================================
38
+ # Team Initialization
39
+ # =============================================================================
40
+
41
+ # Initialize spec-design-team
42
+ # Args: $1 - repo root, $2 - requirement ID
43
+ init_spec_team() {
44
+ local repo_root="$1"
45
+ local req_id="$2"
46
+
47
+ echo "Initializing spec-design-team for $req_id..."
48
+
49
+ # Initialize Team state in orchestration_status.json
50
+ init_team_state "$repo_root" "$req_id" "parallel" "spec-lead"
51
+
52
+ # Add teammates
53
+ add_teammate "$repo_root" "$req_id" "prd-writer" "analyst"
54
+ add_teammate "$repo_root" "$req_id" "tech-architect" "architect"
55
+ add_teammate "$repo_root" "$req_id" "ui-designer" "designer"
56
+ add_teammate "$repo_root" "$req_id" "planner" "planner"
57
+
58
+ echo "Team initialized with 4 teammates"
59
+ }
60
+
61
+ # =============================================================================
62
+ # Team Configuration
63
+ # =============================================================================
64
+
65
+ # Get team configuration as JSON
66
+ get_team_config() {
67
+ cat <<'EOF'
68
+ {
69
+ "name": "spec-design-team",
70
+ "description": "并行规格设计团队",
71
+ "mode": "parallel",
72
+ "lead": "spec-lead",
73
+ "members": [
74
+ {
75
+ "id": "prd-writer",
76
+ "role": "analyst",
77
+ "agent_type": "prd-writer",
78
+ "description": "PRD 生成,需求分析"
79
+ },
80
+ {
81
+ "id": "tech-architect",
82
+ "role": "architect",
83
+ "agent_type": "tech-architect",
84
+ "description": "技术设计,架构方案"
85
+ },
86
+ {
87
+ "id": "ui-designer",
88
+ "role": "designer",
89
+ "agent_type": "ui-designer",
90
+ "description": "UI 原型,交互设计"
91
+ },
92
+ {
93
+ "id": "planner",
94
+ "role": "planner",
95
+ "agent_type": "planner",
96
+ "description": "Epic 规划,任务分解"
97
+ }
98
+ ],
99
+ "workflow": {
100
+ "stages": [
101
+ {
102
+ "name": "PRD Generation",
103
+ "agents": ["prd-writer"],
104
+ "parallel": false,
105
+ "outputs": ["PRD.md"]
106
+ },
107
+ {
108
+ "name": "Design Parallel",
109
+ "agents": ["tech-architect", "ui-designer"],
110
+ "parallel": true,
111
+ "outputs": ["TECH_DESIGN.md", "UI_PROTOTYPE.html"],
112
+ "wait_for": ["PRD Generation"],
113
+ "negotiate": {
114
+ "enabled": true,
115
+ "topics": ["api_format", "field_naming", "auth_strategy", "state_management"]
116
+ }
117
+ },
118
+ {
119
+ "name": "Epic Planning",
120
+ "agents": ["planner"],
121
+ "parallel": false,
122
+ "outputs": ["EPIC.md", "TASKS.md"],
123
+ "wait_for": ["Design Parallel"]
124
+ }
125
+ ]
126
+ },
127
+ "communication": {
128
+ "protocol": "direct_message",
129
+ "negotiate_topics": [
130
+ {
131
+ "id": "api_format",
132
+ "description": "API 响应格式 (REST/GraphQL, JSON structure)",
133
+ "participants": ["tech-architect", "ui-designer"]
134
+ },
135
+ {
136
+ "id": "field_naming",
137
+ "description": "数据字段命名规范",
138
+ "participants": ["tech-architect", "ui-designer", "planner"]
139
+ },
140
+ {
141
+ "id": "auth_strategy",
142
+ "description": "认证策略 (JWT, Session, OAuth)",
143
+ "participants": ["tech-architect", "ui-designer"]
144
+ },
145
+ {
146
+ "id": "state_management",
147
+ "description": "前端状态管理方案",
148
+ "participants": ["tech-architect", "ui-designer"]
149
+ },
150
+ {
151
+ "id": "component_granularity",
152
+ "description": "组件粒度和任务拆分",
153
+ "participants": ["ui-designer", "planner"]
154
+ }
155
+ ]
156
+ }
157
+ }
158
+ EOF
159
+ }
160
+
161
+ # =============================================================================
162
+ # Main
163
+ # =============================================================================
164
+
165
+ main() {
166
+ local action="${1:-detect}"
167
+
168
+ case "$action" in
169
+ detect)
170
+ local skip_tech="${2:-false}"
171
+ local skip_ui="${3:-false}"
172
+ detect_execution_mode "$skip_tech" "$skip_ui"
173
+ ;;
174
+ init)
175
+ local repo_root="${2:-$(get_repo_root)}"
176
+ local req_id="${3:-$(get_current_req_id)}"
177
+ init_spec_team "$repo_root" "$req_id"
178
+ ;;
179
+ config)
180
+ get_team_config
181
+ ;;
182
+ *)
183
+ echo "Usage: $0 {detect|init|config} [args...]" >&2
184
+ echo " detect [skip_tech] [skip_ui] - Detect execution mode" >&2
185
+ echo " init [repo_root] [req_id] - Initialize Team state" >&2
186
+ echo " config - Output Team config JSON" >&2
187
+ exit 1
188
+ ;;
189
+ esac
190
+ }
191
+
192
+ # Run if executed directly
193
+ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
194
+ main "$@"
195
+ fi