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.
- package/.claude/CLAUDE.md +1065 -48
- package/.claude/agents/dev-implementer.md +195 -0
- package/.claude/commands/{flow-archive.md → flow/archive.md} +46 -11
- package/.claude/commands/flow/context.md +150 -0
- package/.claude/commands/flow/delta.md +245 -0
- package/.claude/commands/{flow-dev.md → flow/dev.md} +112 -11
- package/.claude/commands/flow/init.md +45 -0
- package/.claude/commands/flow/quality.md +159 -0
- package/.claude/commands/flow/spec.md +186 -0
- package/.claude/commands/flow/workspace.md +146 -0
- package/.claude/commands/{cancel-ralph.md → util/cancel-ralph.md} +1 -0
- package/.claude/config/quality-gates.yml +305 -0
- package/.claude/docs/guides/TEAM_MODE_GUIDE.md +313 -0
- package/.claude/docs/templates/DELTA_SPEC_TEMPLATE.md +91 -0
- package/.claude/docs/templates/DESIGN_DECISIONS_TEMPLATE.md +151 -0
- package/.claude/docs/templates/JOURNAL_TEMPLATE.md +75 -0
- package/.claude/docs/templates/_shared/CLAUDE.md +36 -0
- package/.claude/docs/templates/_shared/CONSTITUTION_CHECK.md +125 -0
- package/.claude/docs/templates/_shared/VALIDATION_CHECKLIST.md +187 -0
- package/.claude/docs/templates/_shared/YAML_FRONTMATTER.md +164 -0
- package/.claude/docs/templates/context/dev.jsonl.template +6 -0
- package/.claude/docs/templates/context/epic.jsonl.template +5 -0
- package/.claude/docs/templates/context/prd.jsonl.template +4 -0
- package/.claude/docs/templates/context/research.jsonl.template +4 -0
- package/.claude/docs/templates/context/review.jsonl.template +5 -0
- package/.claude/docs/templates/context/tech.jsonl.template +5 -0
- package/.claude/hooks/CLAUDE.md +342 -0
- package/.claude/hooks/inject-agent-context.ts +480 -0
- package/.claude/hooks/inject-skill-context.ts +359 -0
- package/.claude/hooks/ralph-loop.ts +931 -0
- package/.claude/hooks/task-completed-hook.ts +593 -0
- package/.claude/hooks/teammate-idle-hook.ts +690 -0
- package/.claude/hooks/types/team-types.d.ts +238 -0
- package/.claude/rules/devflow-conventions.md +82 -9
- package/.claude/scripts/archive-requirement.sh +44 -1
- package/.claude/scripts/common.sh +670 -3
- package/.claude/scripts/delta-parser.ts +527 -0
- package/.claude/scripts/detect-file-conflicts.sh +151 -0
- package/.claude/scripts/flow-context-add.sh +134 -0
- package/.claude/scripts/flow-context-init.sh +133 -0
- package/.claude/scripts/flow-context-validate.sh +144 -0
- package/.claude/scripts/flow-delta-apply.sh +297 -0
- package/.claude/scripts/flow-delta-archive.sh +71 -0
- package/.claude/scripts/flow-delta-create.sh +202 -0
- package/.claude/scripts/flow-delta-list.sh +142 -0
- package/.claude/scripts/flow-delta-status.sh +235 -0
- package/.claude/scripts/flow-quality-full.sh +184 -0
- package/.claude/scripts/flow-quality-quick.sh +64 -0
- package/.claude/scripts/flow-workspace-init.sh +117 -0
- package/.claude/scripts/flow-workspace-record.sh +164 -0
- package/.claude/scripts/flow-workspace-start.sh +88 -0
- package/.claude/scripts/get-workflow-status.sh +415 -0
- package/.claude/scripts/parse-task-dependencies.js +334 -0
- package/.claude/scripts/record-quality-error.sh +165 -0
- package/.claude/scripts/run-quality-gates.sh +242 -0
- package/.claude/scripts/team-dev-init.sh +319 -0
- package/.claude/scripts/team-state-recovery.sh +229 -0
- package/.claude/scripts/workflow-status.ts +433 -0
- package/.claude/settings.json +19 -0
- package/.claude/skills/cc-devflow-orchestrator/SKILL.md +85 -200
- package/.claude/skills/domain/using-git-worktrees/SKILL.md +252 -0
- package/.claude/skills/domain/using-git-worktrees/assets/SHELL_ALIASES.md +133 -0
- package/.claude/skills/domain/using-git-worktrees/context.jsonl +4 -0
- package/.claude/skills/domain/using-git-worktrees/scripts/worktree-cleanup.sh +218 -0
- package/.claude/skills/domain/using-git-worktrees/scripts/worktree-create.sh +232 -0
- package/.claude/skills/domain/using-git-worktrees/scripts/worktree-list.sh +130 -0
- package/.claude/skills/domain/using-git-worktrees/scripts/worktree-status.sh +140 -0
- package/.claude/skills/domain/using-git-worktrees/scripts/worktree-switch.sh +70 -0
- package/.claude/skills/skill-rules.json +72 -1
- package/.claude/skills/utility/journey-checker/SKILL.md +199 -0
- package/.claude/skills/utility/journey-checker/pressure-scenarios.md +164 -0
- package/.claude/skills/utility/skill-creator/LICENSE.txt +202 -0
- package/.claude/skills/utility/skill-creator/SKILL.md +356 -0
- package/.claude/skills/utility/skill-creator/references/output-patterns.md +82 -0
- package/.claude/skills/utility/skill-creator/references/workflows.md +28 -0
- package/.claude/skills/utility/skill-creator/scripts/init_skill.py +303 -0
- package/.claude/skills/utility/skill-creator/scripts/package_skill.py +110 -0
- package/.claude/skills/utility/skill-creator/scripts/quick_validate.py +95 -0
- package/.claude/skills/workflow/flow-dev/CLAUDE.md +78 -0
- package/.claude/skills/workflow/flow-dev/SKILL.md +96 -0
- package/.claude/skills/workflow/flow-dev/assets/IMPLEMENTATION_PLAN_TEMPLATE.md +71 -0
- package/.claude/skills/workflow/flow-dev/context.jsonl +8 -0
- package/.claude/skills/workflow/flow-dev/dev-implementer.jsonl +8 -0
- package/.claude/skills/workflow/flow-dev/scripts/entry-gate.sh +116 -0
- package/.claude/skills/workflow/flow-dev/scripts/exit-gate.sh +101 -0
- package/.claude/skills/workflow/flow-dev/scripts/task-orchestrator.sh +106 -0
- package/.claude/skills/workflow/flow-fix/SKILL.md +105 -0
- package/.claude/skills/workflow/flow-fix/context.jsonl +6 -0
- package/.claude/skills/workflow/flow-fix/references/bug-analyzer.md +381 -0
- package/.claude/skills/workflow/flow-init/SKILL.md +211 -0
- package/.claude/skills/workflow/flow-init/assets/BRAINSTORM_TEMPLATE.md +148 -0
- package/.claude/skills/workflow/flow-init/assets/INIT_FLOW_TEMPLATE.md +198 -0
- package/.claude/skills/workflow/flow-init/assets/RESEARCH_TEMPLATE.md +276 -0
- package/.claude/skills/workflow/flow-init/context.jsonl +5 -0
- package/.claude/skills/workflow/flow-init/references/flow-researcher.md +132 -0
- package/.claude/skills/workflow/flow-init/scripts/check-prerequisites.sh +232 -0
- package/.claude/skills/workflow/flow-init/scripts/consolidate-research.sh +182 -0
- package/.claude/skills/workflow/flow-init/scripts/create-requirement.sh +515 -0
- package/.claude/skills/workflow/flow-init/scripts/generate-research-tasks.sh +157 -0
- package/.claude/skills/workflow/flow-init/scripts/populate-research-tasks.sh +284 -0
- package/.claude/skills/workflow/flow-init/scripts/validate-research.sh +332 -0
- package/.claude/skills/workflow/flow-quality/SKILL.md +94 -0
- package/.claude/skills/workflow/flow-quality/context.jsonl +6 -0
- package/.claude/skills/workflow/flow-quality/references/code-quality-reviewer.md +205 -0
- package/.claude/skills/workflow/flow-quality/references/qa-tester.md +313 -0
- package/.claude/skills/workflow/flow-quality/references/security-reviewer.md +314 -0
- package/.claude/skills/workflow/flow-quality/references/spec-reviewer.md +221 -0
- package/.claude/skills/workflow/flow-release/SKILL.md +126 -0
- package/.claude/skills/workflow/flow-release/context.jsonl +7 -0
- package/.claude/skills/workflow/flow-release/references/release-manager.md +295 -0
- package/.claude/skills/workflow/flow-spec/CLAUDE.md +103 -0
- package/.claude/skills/workflow/flow-spec/SKILL.md +545 -0
- package/.claude/skills/workflow/flow-spec/context.jsonl +7 -0
- package/.claude/skills/workflow/flow-spec/scripts/entry-gate.sh +194 -0
- package/.claude/skills/workflow/flow-spec/scripts/exit-gate.sh +244 -0
- package/.claude/skills/workflow/flow-spec/scripts/parallel-orchestrator.sh +205 -0
- package/.claude/skills/workflow/flow-spec/scripts/team-communication.sh +353 -0
- package/.claude/skills/workflow/flow-spec/scripts/team-init.sh +195 -0
- package/.claude/skills/workflow/flow-spec/scripts/test-team-mode.sh +496 -0
- package/.claude/skills/workflow/flow-spec/team-config.json +165 -0
- package/.claude/skills/workflow.yaml +417 -0
- package/CHANGELOG.md +254 -0
- package/README.md +193 -33
- package/README.zh-CN.md +206 -46
- package/lib/compiler/CLAUDE.md +77 -46
- package/lib/compiler/__tests__/multi-module-emitters.test.js +508 -0
- package/lib/compiler/context-expander.js +179 -0
- package/lib/compiler/emitters/antigravity-emitter.js +195 -5
- package/lib/compiler/emitters/base-emitter.js +217 -2
- package/lib/compiler/emitters/codex-emitter.js +200 -4
- package/lib/compiler/emitters/cursor-emitter.js +307 -3
- package/lib/compiler/emitters/qwen-emitter.js +196 -4
- package/lib/compiler/index.js +197 -2
- package/lib/compiler/platforms.js +270 -21
- package/package.json +1 -1
- package/.claude/commands/flow-epic.md +0 -183
- package/.claude/commands/flow-init.md +0 -370
- package/.claude/commands/flow-prd.md +0 -144
- package/.claude/commands/flow-qa.md +0 -93
- package/.claude/commands/flow-review.md +0 -257
- package/.claude/commands/flow-tech.md +0 -142
- package/.claude/commands/flow-ui.md +0 -189
- package/.claude/skills/file-header-guardian/SKILL.md +0 -56
- package/.claude/skills/skill-developer/ADVANCED.md +0 -197
- package/.claude/skills/skill-developer/HOOK_MECHANISMS.md +0 -306
- package/.claude/skills/skill-developer/PATTERNS_LIBRARY.md +0 -152
- package/.claude/skills/skill-developer/SKILL.md +0 -426
- package/.claude/skills/skill-developer/SKILL_RULES_REFERENCE.md +0 -315
- package/.claude/skills/skill-developer/TRIGGER_TYPES.md +0 -305
- package/.claude/skills/skill-developer/TROUBLESHOOTING.md +0 -514
- package/.claude/skills/writing-skills/SKILL.md +0 -655
- package/.claude/skills/writing-skills/anthropic-best-practices.md +0 -1150
- package/.claude/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -189
- package/.claude/skills/writing-skills/graphviz-conventions.dot +0 -172
- package/.claude/skills/writing-skills/persuasion-principles.md +0 -187
- package/.claude/skills/writing-skills/render-graphs.js +0 -168
- package/.claude/skills/writing-skills/testing-skills-with-subagents.md +0 -384
- package/.claude/tsc-cache/795ba6e3-b98a-423b-bab2-51aa62812569/affected-repos.txt +0 -1
- package/.claude/tsc-cache/ae335694-be5a-4ba4-a1a0-b676c09a7906/affected-repos.txt +0 -1
- /package/.claude/commands/{core-architecture.md → core/architecture.md} +0 -0
- /package/.claude/commands/{core-guidelines.md → core/guidelines.md} +0 -0
- /package/.claude/commands/{core-roadmap.md → core/roadmap.md} +0 -0
- /package/.claude/commands/{core-style.md → core/style.md} +0 -0
- /package/.claude/commands/{flow-checklist.md → flow/checklist.md} +0 -0
- /package/.claude/commands/{flow-clarify.md → flow/clarify.md} +0 -0
- /package/.claude/commands/{flow-constitution.md → flow/constitution.md} +0 -0
- /package/.claude/commands/{flow-fix.md → flow/fix.md} +0 -0
- /package/.claude/commands/{flow-ideate.md → flow/ideate.md} +0 -0
- /package/.claude/commands/{flow-new.md → flow/new.md} +0 -0
- /package/.claude/commands/{flow-release.md → flow/release.md} +0 -0
- /package/.claude/commands/{flow-restart.md → flow/restart.md} +0 -0
- /package/.claude/commands/{flow-status.md → flow/status.md} +0 -0
- /package/.claude/commands/{flow-update.md → flow/update.md} +0 -0
- /package/.claude/commands/{flow-upgrade.md → flow/upgrade.md} +0 -0
- /package/.claude/commands/{flow-verify.md → flow/verify.md} +0 -0
- /package/.claude/commands/{code-review-high.md → util/code-review.md} +0 -0
- /package/.claude/commands/{git-commit.md → util/git-commit.md} +0 -0
- /package/.claude/commands/{problem-analyzer.md → util/problem-analyzer.md} +0 -0
- /package/.claude/skills/{flow-attention-refresh → domain/attention-refresh}/SKILL.md +0 -0
- /package/.claude/skills/{flow-brainstorming → domain/brainstorming}/SKILL.md +0 -0
- /package/.claude/skills/{flow-debugging → domain/debugging}/SKILL.md +0 -0
- /package/.claude/skills/{flow-finishing-branch → domain/finishing-branch}/SKILL.md +0 -0
- /package/.claude/skills/{flow-receiving-review → domain/receiving-review}/SKILL.md +0 -0
- /package/.claude/skills/{flow-tdd → domain/tdd}/SKILL.md +0 -0
- /package/.claude/skills/{verification-before-completion → domain/verification}/SKILL.md +0 -0
- /package/.claude/skills/{constitution-guardian → guardrail/constitution-guardian}/SKILL.md +0 -0
- /package/.claude/skills/{devflow-tdd-enforcer → guardrail/tdd-enforcer}/SKILL.md +0 -0
- /package/.claude/skills/{devflow-constitution-quick-ref → utility/constitution-quick-ref}/SKILL.md +0 -0
- /package/.claude/skills/{devflow-file-standards → utility/file-standards}/SKILL.md +0 -0
- /package/.claude/skills/{fractal-docs-generator → utility/fractal-docs}/SKILL.md +0 -0
- /package/.claude/skills/{npm-release → utility/npm-release}/SKILL.md +0 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# [INPUT]: 依赖 .claude/config/quality-gates.yml
|
|
3
|
+
# [OUTPUT]: 执行验证命令,返回结果
|
|
4
|
+
# [POS]: scripts 的质量闸执行脚本,被 ralph-stop-hook.sh 调用
|
|
5
|
+
# [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
|
|
6
|
+
|
|
7
|
+
set -e
|
|
8
|
+
|
|
9
|
+
# ============================================================================
|
|
10
|
+
# Configuration
|
|
11
|
+
# ============================================================================
|
|
12
|
+
|
|
13
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
14
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
15
|
+
CONFIG_FILE="$PROJECT_ROOT/.claude/config/quality-gates.yml"
|
|
16
|
+
|
|
17
|
+
# ============================================================================
|
|
18
|
+
# Usage
|
|
19
|
+
# ============================================================================
|
|
20
|
+
|
|
21
|
+
usage() {
|
|
22
|
+
cat << EOF
|
|
23
|
+
Usage: run-quality-gates.sh <phase> [--json] [--verbose]
|
|
24
|
+
|
|
25
|
+
Execute quality gate verification commands for a phase.
|
|
26
|
+
|
|
27
|
+
Arguments:
|
|
28
|
+
phase Phase name (flow-dev, flow-review, flow-quality, flow-qa, flow-release)
|
|
29
|
+
|
|
30
|
+
Options:
|
|
31
|
+
--json Output results as JSON
|
|
32
|
+
--verbose Show command output
|
|
33
|
+
--quick Use quick mode for flow-quality (default)
|
|
34
|
+
--full Use full mode for flow-quality
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
run-quality-gates.sh flow-dev
|
|
38
|
+
run-quality-gates.sh flow-quality --full
|
|
39
|
+
run-quality-gates.sh flow-dev --json
|
|
40
|
+
EOF
|
|
41
|
+
exit 1
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# ============================================================================
|
|
45
|
+
# Parse Arguments
|
|
46
|
+
# ============================================================================
|
|
47
|
+
|
|
48
|
+
PHASE=""
|
|
49
|
+
JSON_OUTPUT=false
|
|
50
|
+
VERBOSE=false
|
|
51
|
+
MODE="quick"
|
|
52
|
+
|
|
53
|
+
while [[ $# -gt 0 ]]; do
|
|
54
|
+
case $1 in
|
|
55
|
+
--json)
|
|
56
|
+
JSON_OUTPUT=true
|
|
57
|
+
shift
|
|
58
|
+
;;
|
|
59
|
+
--verbose)
|
|
60
|
+
VERBOSE=true
|
|
61
|
+
shift
|
|
62
|
+
;;
|
|
63
|
+
--quick)
|
|
64
|
+
MODE="quick"
|
|
65
|
+
shift
|
|
66
|
+
;;
|
|
67
|
+
--full)
|
|
68
|
+
MODE="full"
|
|
69
|
+
shift
|
|
70
|
+
;;
|
|
71
|
+
--help|-h)
|
|
72
|
+
usage
|
|
73
|
+
;;
|
|
74
|
+
*)
|
|
75
|
+
if [[ -z "$PHASE" ]]; then
|
|
76
|
+
PHASE="$1"
|
|
77
|
+
fi
|
|
78
|
+
shift
|
|
79
|
+
;;
|
|
80
|
+
esac
|
|
81
|
+
done
|
|
82
|
+
|
|
83
|
+
if [[ -z "$PHASE" ]]; then
|
|
84
|
+
echo "Error: phase is required"
|
|
85
|
+
usage
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
# ============================================================================
|
|
89
|
+
# Check Config File
|
|
90
|
+
# ============================================================================
|
|
91
|
+
|
|
92
|
+
if [[ ! -f "$CONFIG_FILE" ]]; then
|
|
93
|
+
if $JSON_OUTPUT; then
|
|
94
|
+
echo '{"success": true, "message": "No quality-gates.yml found, skipping verification"}'
|
|
95
|
+
else
|
|
96
|
+
echo "ℹ️ No quality-gates.yml found, skipping verification"
|
|
97
|
+
fi
|
|
98
|
+
exit 0
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
# ============================================================================
|
|
102
|
+
# Parse YAML (Simple Parser)
|
|
103
|
+
# ============================================================================
|
|
104
|
+
|
|
105
|
+
# Extract verify commands for the phase
|
|
106
|
+
# For flow-quality, use the mode (quick/full)
|
|
107
|
+
if [[ "$PHASE" == "flow-quality" ]]; then
|
|
108
|
+
YAML_PATH="${PHASE}.${MODE}.verify"
|
|
109
|
+
else
|
|
110
|
+
YAML_PATH="${PHASE}.verify"
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
# Simple YAML extraction using grep and sed
|
|
114
|
+
# This is a basic parser - for complex YAML, consider using yq
|
|
115
|
+
extract_commands() {
|
|
116
|
+
local in_section=false
|
|
117
|
+
local in_verify=false
|
|
118
|
+
local indent_level=0
|
|
119
|
+
|
|
120
|
+
while IFS= read -r line; do
|
|
121
|
+
# Check for phase section
|
|
122
|
+
if [[ "$line" =~ ^${PHASE}: ]]; then
|
|
123
|
+
in_section=true
|
|
124
|
+
continue
|
|
125
|
+
fi
|
|
126
|
+
|
|
127
|
+
# Check for mode section (for flow-quality)
|
|
128
|
+
if $in_section && [[ "$PHASE" == "flow-quality" ]] && [[ "$line" =~ ^[[:space:]]+${MODE}: ]]; then
|
|
129
|
+
in_section=true
|
|
130
|
+
continue
|
|
131
|
+
fi
|
|
132
|
+
|
|
133
|
+
# Check for verify section
|
|
134
|
+
if $in_section && [[ "$line" =~ ^[[:space:]]+verify: ]]; then
|
|
135
|
+
in_verify=true
|
|
136
|
+
continue
|
|
137
|
+
fi
|
|
138
|
+
|
|
139
|
+
# Extract command entries
|
|
140
|
+
if $in_verify; then
|
|
141
|
+
# Check if we've left the verify section (less indentation)
|
|
142
|
+
if [[ "$line" =~ ^[[:space:]]*[a-z_]+: ]] && [[ ! "$line" =~ ^[[:space:]]{4,}- ]]; then
|
|
143
|
+
in_verify=false
|
|
144
|
+
in_section=false
|
|
145
|
+
continue
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
# Extract command value
|
|
149
|
+
if [[ "$line" =~ command:[[:space:]]*\"(.+)\" ]]; then
|
|
150
|
+
echo "${BASH_REMATCH[1]}"
|
|
151
|
+
elif [[ "$line" =~ command:[[:space:]]*(.+) ]]; then
|
|
152
|
+
echo "${BASH_REMATCH[1]}"
|
|
153
|
+
fi
|
|
154
|
+
fi
|
|
155
|
+
done < "$CONFIG_FILE"
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
# ============================================================================
|
|
159
|
+
# Execute Commands
|
|
160
|
+
# ============================================================================
|
|
161
|
+
|
|
162
|
+
COMMANDS=$(extract_commands)
|
|
163
|
+
|
|
164
|
+
if [[ -z "$COMMANDS" ]]; then
|
|
165
|
+
if $JSON_OUTPUT; then
|
|
166
|
+
echo '{"success": true, "message": "No verify commands configured for phase", "phase": "'"$PHASE"'"}'
|
|
167
|
+
else
|
|
168
|
+
echo "ℹ️ No verify commands configured for $PHASE"
|
|
169
|
+
fi
|
|
170
|
+
exit 0
|
|
171
|
+
fi
|
|
172
|
+
|
|
173
|
+
TOTAL=0
|
|
174
|
+
PASSED=0
|
|
175
|
+
FAILED=0
|
|
176
|
+
RESULTS=()
|
|
177
|
+
|
|
178
|
+
while IFS= read -r cmd; do
|
|
179
|
+
[[ -z "$cmd" ]] && continue
|
|
180
|
+
|
|
181
|
+
((TOTAL++))
|
|
182
|
+
|
|
183
|
+
if $VERBOSE; then
|
|
184
|
+
echo "Running: $cmd"
|
|
185
|
+
fi
|
|
186
|
+
|
|
187
|
+
# Execute command
|
|
188
|
+
if eval "$cmd" > /dev/null 2>&1; then
|
|
189
|
+
((PASSED++))
|
|
190
|
+
RESULTS+=("{\"command\": \"$cmd\", \"status\": \"pass\"}")
|
|
191
|
+
if ! $JSON_OUTPUT; then
|
|
192
|
+
echo " ✓ $cmd"
|
|
193
|
+
fi
|
|
194
|
+
else
|
|
195
|
+
((FAILED++))
|
|
196
|
+
RESULTS+=("{\"command\": \"$cmd\", \"status\": \"fail\"}")
|
|
197
|
+
if ! $JSON_OUTPUT; then
|
|
198
|
+
echo " ✗ $cmd"
|
|
199
|
+
fi
|
|
200
|
+
fi
|
|
201
|
+
done <<< "$COMMANDS"
|
|
202
|
+
|
|
203
|
+
# ============================================================================
|
|
204
|
+
# Output Results
|
|
205
|
+
# ============================================================================
|
|
206
|
+
|
|
207
|
+
if $JSON_OUTPUT; then
|
|
208
|
+
# Build JSON array of results
|
|
209
|
+
RESULTS_JSON=$(printf '%s\n' "${RESULTS[@]}" | jq -s '.')
|
|
210
|
+
|
|
211
|
+
jq -n \
|
|
212
|
+
--arg phase "$PHASE" \
|
|
213
|
+
--arg mode "$MODE" \
|
|
214
|
+
--argjson total "$TOTAL" \
|
|
215
|
+
--argjson passed "$PASSED" \
|
|
216
|
+
--argjson failed "$FAILED" \
|
|
217
|
+
--argjson results "$RESULTS_JSON" \
|
|
218
|
+
'{
|
|
219
|
+
"phase": $phase,
|
|
220
|
+
"mode": $mode,
|
|
221
|
+
"total": $total,
|
|
222
|
+
"passed": $passed,
|
|
223
|
+
"failed": $failed,
|
|
224
|
+
"success": ($failed == 0),
|
|
225
|
+
"results": $results
|
|
226
|
+
}'
|
|
227
|
+
else
|
|
228
|
+
echo ""
|
|
229
|
+
echo "Quality Gate Results for $PHASE:"
|
|
230
|
+
echo " Total: $TOTAL"
|
|
231
|
+
echo " Passed: $PASSED"
|
|
232
|
+
echo " Failed: $FAILED"
|
|
233
|
+
|
|
234
|
+
if [[ $FAILED -gt 0 ]]; then
|
|
235
|
+
echo ""
|
|
236
|
+
echo "❌ Quality gate FAILED"
|
|
237
|
+
exit 1
|
|
238
|
+
else
|
|
239
|
+
echo ""
|
|
240
|
+
echo "✅ Quality gate PASSED"
|
|
241
|
+
fi
|
|
242
|
+
fi
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# =============================================================================
|
|
3
|
+
# Team Mode Initialization for flow-dev
|
|
4
|
+
# =============================================================================
|
|
5
|
+
# [INPUT]: 依赖 common.sh 的 Team 函数, parse-task-dependencies.js
|
|
6
|
+
# [OUTPUT]: 初始化 dev-team 状态,分析任务并行性
|
|
7
|
+
# [POS]: flow-dev 的 Team 初始化器,被 /flow:dev --team 调用
|
|
8
|
+
# [PROTOCOL]: 变更时更新此头部,然后检查 CLAUDE.md
|
|
9
|
+
# =============================================================================
|
|
10
|
+
|
|
11
|
+
set -euo pipefail
|
|
12
|
+
|
|
13
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
14
|
+
source "$SCRIPT_DIR/common.sh"
|
|
15
|
+
|
|
16
|
+
# =============================================================================
|
|
17
|
+
# Constants
|
|
18
|
+
# =============================================================================
|
|
19
|
+
|
|
20
|
+
DEFAULT_AGENTS=3
|
|
21
|
+
MAX_AGENTS=5
|
|
22
|
+
MIN_AGENTS=2
|
|
23
|
+
|
|
24
|
+
# =============================================================================
|
|
25
|
+
# Team Initialization
|
|
26
|
+
# =============================================================================
|
|
27
|
+
|
|
28
|
+
# Initialize dev-team for parallel task execution
|
|
29
|
+
# Args: $1 - repo root, $2 - requirement ID, $3 - number of agents
|
|
30
|
+
init_dev_team() {
|
|
31
|
+
local repo_root="$1"
|
|
32
|
+
local req_id="$2"
|
|
33
|
+
local num_agents="${3:-$DEFAULT_AGENTS}"
|
|
34
|
+
|
|
35
|
+
# Validate agent count
|
|
36
|
+
if [[ "$num_agents" -lt "$MIN_AGENTS" ]]; then
|
|
37
|
+
num_agents=$MIN_AGENTS
|
|
38
|
+
elif [[ "$num_agents" -gt "$MAX_AGENTS" ]]; then
|
|
39
|
+
num_agents=$MAX_AGENTS
|
|
40
|
+
fi
|
|
41
|
+
|
|
42
|
+
echo "Initializing dev-team for $req_id with $num_agents agents..."
|
|
43
|
+
|
|
44
|
+
# Initialize Team state in orchestration_status.json
|
|
45
|
+
init_team_state "$repo_root" "$req_id" "parallel" "dev-lead"
|
|
46
|
+
|
|
47
|
+
# Add developer teammates
|
|
48
|
+
for i in $(seq 1 "$num_agents"); do
|
|
49
|
+
add_teammate "$repo_root" "$req_id" "dev-$i" "developer"
|
|
50
|
+
done
|
|
51
|
+
|
|
52
|
+
echo "Team initialized with $num_agents developer agents"
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
# =============================================================================
|
|
56
|
+
# Task Analysis
|
|
57
|
+
# =============================================================================
|
|
58
|
+
|
|
59
|
+
# Analyze TASKS.md and return parallel execution plan
|
|
60
|
+
# Args: $1 - repo root, $2 - requirement ID
|
|
61
|
+
analyze_tasks() {
|
|
62
|
+
local repo_root="$1"
|
|
63
|
+
local req_id="$2"
|
|
64
|
+
local tasks_file="$repo_root/devflow/requirements/$req_id/TASKS.md"
|
|
65
|
+
|
|
66
|
+
if [[ ! -f "$tasks_file" ]]; then
|
|
67
|
+
echo '{"error": "TASKS.md not found", "tasks": [], "parallelGroups": []}' >&2
|
|
68
|
+
return 1
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# Use parse-task-dependencies.js to analyze tasks
|
|
72
|
+
node "$SCRIPT_DIR/parse-task-dependencies.js" parse "$tasks_file"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# Get next available tasks for parallel execution
|
|
76
|
+
# Args: $1 - repo root, $2 - requirement ID
|
|
77
|
+
get_next_tasks() {
|
|
78
|
+
local repo_root="$1"
|
|
79
|
+
local req_id="$2"
|
|
80
|
+
local tasks_file="$repo_root/devflow/requirements/$req_id/TASKS.md"
|
|
81
|
+
|
|
82
|
+
if [[ ! -f "$tasks_file" ]]; then
|
|
83
|
+
echo '[]'
|
|
84
|
+
return 0
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
node "$SCRIPT_DIR/parse-task-dependencies.js" next "$tasks_file"
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
# Get parallel groups for current phase
|
|
91
|
+
# Args: $1 - repo root, $2 - requirement ID
|
|
92
|
+
get_parallel_groups() {
|
|
93
|
+
local repo_root="$1"
|
|
94
|
+
local req_id="$2"
|
|
95
|
+
local tasks_file="$repo_root/devflow/requirements/$req_id/TASKS.md"
|
|
96
|
+
|
|
97
|
+
if [[ ! -f "$tasks_file" ]]; then
|
|
98
|
+
echo '[]'
|
|
99
|
+
return 0
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
node "$SCRIPT_DIR/parse-task-dependencies.js" groups "$tasks_file"
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# =============================================================================
|
|
106
|
+
# Conflict Detection
|
|
107
|
+
# =============================================================================
|
|
108
|
+
|
|
109
|
+
# Check for file conflicts in parallel tasks
|
|
110
|
+
# Args: $1 - repo root, $2 - requirement ID
|
|
111
|
+
check_conflicts() {
|
|
112
|
+
local repo_root="$1"
|
|
113
|
+
local req_id="$2"
|
|
114
|
+
|
|
115
|
+
local tasks
|
|
116
|
+
tasks=$(get_next_tasks "$repo_root" "$req_id")
|
|
117
|
+
|
|
118
|
+
# Format for conflict detection script
|
|
119
|
+
echo "{\"tasks\": $tasks}" | "$SCRIPT_DIR/detect-file-conflicts.sh"
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
# =============================================================================
|
|
123
|
+
# Task Assignment
|
|
124
|
+
# =============================================================================
|
|
125
|
+
|
|
126
|
+
# Assign tasks to teammates based on parallel groups and conflicts
|
|
127
|
+
# Args: $1 - repo root, $2 - requirement ID, $3 - number of agents
|
|
128
|
+
assign_tasks() {
|
|
129
|
+
local repo_root="$1"
|
|
130
|
+
local req_id="$2"
|
|
131
|
+
local num_agents="${3:-$DEFAULT_AGENTS}"
|
|
132
|
+
|
|
133
|
+
local next_tasks
|
|
134
|
+
next_tasks=$(get_next_tasks "$repo_root" "$req_id")
|
|
135
|
+
|
|
136
|
+
local task_count
|
|
137
|
+
task_count=$(echo "$next_tasks" | jq 'length')
|
|
138
|
+
|
|
139
|
+
if [[ "$task_count" -eq 0 ]]; then
|
|
140
|
+
echo '{"assignments": [], "message": "No pending tasks"}'
|
|
141
|
+
return 0
|
|
142
|
+
fi
|
|
143
|
+
|
|
144
|
+
# Check for conflicts
|
|
145
|
+
local conflicts
|
|
146
|
+
conflicts=$(echo "{\"tasks\": $next_tasks}" | "$SCRIPT_DIR/detect-file-conflicts.sh")
|
|
147
|
+
|
|
148
|
+
local has_conflicts
|
|
149
|
+
has_conflicts=$(echo "$conflicts" | jq '.hasConflicts')
|
|
150
|
+
|
|
151
|
+
# Build assignment plan
|
|
152
|
+
local assignments='[]'
|
|
153
|
+
|
|
154
|
+
if [[ "$has_conflicts" == "true" ]]; then
|
|
155
|
+
# Handle conflicts: assign conflicting tasks to same agent
|
|
156
|
+
local conflict_groups
|
|
157
|
+
conflict_groups=$(echo "$conflicts" | jq '.conflicts')
|
|
158
|
+
|
|
159
|
+
# Assign conflict groups to agents
|
|
160
|
+
local agent_idx=1
|
|
161
|
+
assignments=$(echo "$conflict_groups" | jq --argjson numAgents "$num_agents" '
|
|
162
|
+
to_entries | map({
|
|
163
|
+
agent: "dev-\((.key % $numAgents) + 1)",
|
|
164
|
+
tasks: .value.tasks,
|
|
165
|
+
reason: "File conflict - must run sequentially"
|
|
166
|
+
})
|
|
167
|
+
')
|
|
168
|
+
|
|
169
|
+
# Assign safe tasks to remaining agents
|
|
170
|
+
local safe_tasks
|
|
171
|
+
safe_tasks=$(echo "$conflicts" | jq '.safeGroups[0].tasks // []')
|
|
172
|
+
|
|
173
|
+
if [[ $(echo "$safe_tasks" | jq 'length') -gt 0 ]]; then
|
|
174
|
+
local safe_assignments
|
|
175
|
+
safe_assignments=$(echo "$safe_tasks" | jq --argjson numAgents "$num_agents" '
|
|
176
|
+
to_entries | map({
|
|
177
|
+
agent: "dev-\((.key % $numAgents) + 1)",
|
|
178
|
+
tasks: [.value],
|
|
179
|
+
reason: "No conflicts"
|
|
180
|
+
})
|
|
181
|
+
')
|
|
182
|
+
assignments=$(echo "$assignments $safe_assignments" | jq -s 'add')
|
|
183
|
+
fi
|
|
184
|
+
else
|
|
185
|
+
# No conflicts: distribute tasks evenly
|
|
186
|
+
assignments=$(echo "$next_tasks" | jq --argjson numAgents "$num_agents" '
|
|
187
|
+
to_entries | map({
|
|
188
|
+
agent: "dev-\((.key % $numAgents) + 1)",
|
|
189
|
+
tasks: [.value.id],
|
|
190
|
+
reason: "Round-robin assignment"
|
|
191
|
+
})
|
|
192
|
+
')
|
|
193
|
+
fi
|
|
194
|
+
|
|
195
|
+
# Group by agent
|
|
196
|
+
local grouped
|
|
197
|
+
grouped=$(echo "$assignments" | jq '
|
|
198
|
+
group_by(.agent) | map({
|
|
199
|
+
agent: .[0].agent,
|
|
200
|
+
tasks: [.[].tasks[]] | unique,
|
|
201
|
+
reasons: [.[].reason] | unique
|
|
202
|
+
})
|
|
203
|
+
')
|
|
204
|
+
|
|
205
|
+
echo "{\"assignments\": $grouped, \"hasConflicts\": $has_conflicts}"
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
# =============================================================================
|
|
209
|
+
# Team Configuration
|
|
210
|
+
# =============================================================================
|
|
211
|
+
|
|
212
|
+
# Get dev-team configuration as JSON
|
|
213
|
+
get_team_config() {
|
|
214
|
+
local num_agents="${1:-$DEFAULT_AGENTS}"
|
|
215
|
+
|
|
216
|
+
local members='[]'
|
|
217
|
+
for i in $(seq 1 "$num_agents"); do
|
|
218
|
+
members=$(echo "$members" | jq --arg id "dev-$i" --arg idx "$i" '
|
|
219
|
+
. + [{
|
|
220
|
+
id: $id,
|
|
221
|
+
role: "developer",
|
|
222
|
+
agent_type: "dev-implementer",
|
|
223
|
+
description: "Developer agent \($idx)"
|
|
224
|
+
}]
|
|
225
|
+
')
|
|
226
|
+
done
|
|
227
|
+
|
|
228
|
+
jq -n --argjson members "$members" --argjson numAgents "$num_agents" '{
|
|
229
|
+
name: "dev-team",
|
|
230
|
+
version: "1.0.0",
|
|
231
|
+
description: "并行开发团队 - 多 Agent 并行执行任务",
|
|
232
|
+
mode: "parallel",
|
|
233
|
+
lead: "dev-lead",
|
|
234
|
+
members: $members,
|
|
235
|
+
workflow: {
|
|
236
|
+
strategy: "phase_based",
|
|
237
|
+
conflict_resolution: "same_agent",
|
|
238
|
+
max_parallel: $numAgents
|
|
239
|
+
},
|
|
240
|
+
quality_gates: {
|
|
241
|
+
entry: {
|
|
242
|
+
required_files: ["TASKS.md", "TECH_DESIGN.md", "quickstart.md"],
|
|
243
|
+
status_check: ["epic_complete", "development_in_progress"]
|
|
244
|
+
},
|
|
245
|
+
exit: {
|
|
246
|
+
all_tasks_complete: true,
|
|
247
|
+
tests_pass: true,
|
|
248
|
+
status_update: "development_complete"
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}'
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
# =============================================================================
|
|
255
|
+
# Main
|
|
256
|
+
# =============================================================================
|
|
257
|
+
|
|
258
|
+
main() {
|
|
259
|
+
local action="${1:-help}"
|
|
260
|
+
|
|
261
|
+
case "$action" in
|
|
262
|
+
init)
|
|
263
|
+
local repo_root="${2:-$(get_repo_root)}"
|
|
264
|
+
local req_id="${3:-$(get_current_req_id)}"
|
|
265
|
+
local num_agents="${4:-$DEFAULT_AGENTS}"
|
|
266
|
+
init_dev_team "$repo_root" "$req_id" "$num_agents"
|
|
267
|
+
;;
|
|
268
|
+
analyze)
|
|
269
|
+
local repo_root="${2:-$(get_repo_root)}"
|
|
270
|
+
local req_id="${3:-$(get_current_req_id)}"
|
|
271
|
+
analyze_tasks "$repo_root" "$req_id"
|
|
272
|
+
;;
|
|
273
|
+
next)
|
|
274
|
+
local repo_root="${2:-$(get_repo_root)}"
|
|
275
|
+
local req_id="${3:-$(get_current_req_id)}"
|
|
276
|
+
get_next_tasks "$repo_root" "$req_id"
|
|
277
|
+
;;
|
|
278
|
+
groups)
|
|
279
|
+
local repo_root="${2:-$(get_repo_root)}"
|
|
280
|
+
local req_id="${3:-$(get_current_req_id)}"
|
|
281
|
+
get_parallel_groups "$repo_root" "$req_id"
|
|
282
|
+
;;
|
|
283
|
+
conflicts)
|
|
284
|
+
local repo_root="${2:-$(get_repo_root)}"
|
|
285
|
+
local req_id="${3:-$(get_current_req_id)}"
|
|
286
|
+
check_conflicts "$repo_root" "$req_id"
|
|
287
|
+
;;
|
|
288
|
+
assign)
|
|
289
|
+
local repo_root="${2:-$(get_repo_root)}"
|
|
290
|
+
local req_id="${3:-$(get_current_req_id)}"
|
|
291
|
+
local num_agents="${4:-$DEFAULT_AGENTS}"
|
|
292
|
+
assign_tasks "$repo_root" "$req_id" "$num_agents"
|
|
293
|
+
;;
|
|
294
|
+
config)
|
|
295
|
+
local num_agents="${2:-$DEFAULT_AGENTS}"
|
|
296
|
+
get_team_config "$num_agents"
|
|
297
|
+
;;
|
|
298
|
+
help|*)
|
|
299
|
+
echo "Usage: $0 <action> [args...]"
|
|
300
|
+
echo ""
|
|
301
|
+
echo "Actions:"
|
|
302
|
+
echo " init [repo_root] [req_id] [num_agents] - Initialize dev-team"
|
|
303
|
+
echo " analyze [repo_root] [req_id] - Analyze TASKS.md"
|
|
304
|
+
echo " next [repo_root] [req_id] - Get next available tasks"
|
|
305
|
+
echo " groups [repo_root] [req_id] - Get parallel groups"
|
|
306
|
+
echo " conflicts [repo_root] [req_id] - Check file conflicts"
|
|
307
|
+
echo " assign [repo_root] [req_id] [num_agents] - Assign tasks to agents"
|
|
308
|
+
echo " config [num_agents] - Output team config JSON"
|
|
309
|
+
echo ""
|
|
310
|
+
echo "Defaults:"
|
|
311
|
+
echo " num_agents: $DEFAULT_AGENTS (min: $MIN_AGENTS, max: $MAX_AGENTS)"
|
|
312
|
+
;;
|
|
313
|
+
esac
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
# Run if executed directly
|
|
317
|
+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
318
|
+
main "$@"
|
|
319
|
+
fi
|