claude-flow-novice 2.14.13 → 2.14.15

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 (74) hide show
  1. package/.claude/commands/CFN_LOOP_TASK_MODE.md +7 -51
  2. package/.claude/commands/cfn-loop-cli.md +50 -125
  3. package/.claude/skills/cfn-agent-selector/SKILL.md +2 -2
  4. package/.claude/skills/cfn-agent-selector/select-agents.sh +0 -45
  5. package/.claude/skills/cfn-loop-orchestration/helpers/context-injection.sh +6 -69
  6. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +0 -17
  7. package/README.md +2 -2
  8. package/claude-assets/agents/cfn-dev-team/CLAUDE.md +3 -3
  9. package/claude-assets/agents/cfn-dev-team/README.md +1 -1
  10. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +2 -2
  11. package/claude-assets/agents/cfn-dev-team/developers/README.md +3 -3
  12. package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md +1 -1
  13. package/claude-assets/agents/cfn-dev-team/test-agent.md +2 -2
  14. package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +7 -51
  15. package/claude-assets/commands/cfn-loop-cli.md +50 -125
  16. package/claude-assets/skills/cfn-agent-selector/SKILL.md +2 -2
  17. package/claude-assets/skills/cfn-agent-selector/select-agents.sh +0 -45
  18. package/claude-assets/skills/cfn-loop-orchestration/helpers/context-injection.sh +6 -69
  19. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +0 -17
  20. package/claude-assets/skills/cfn-multi-coordinator-planning/README.md +256 -0
  21. package/claude-assets/skills/cfn-multi-coordinator-planning/SKILL.md +62 -0
  22. package/claude-assets/skills/cfn-multi-coordinator-planning/map-dependencies-conflicts.sh +376 -0
  23. package/claude-assets/skills/cfn-multi-coordinator-planning/plan-coordinator-resources.sh +258 -0
  24. package/claude-assets/skills/cfn-multi-coordinator-planning/plan-multi-coordinator-work.sh +267 -0
  25. package/claude-assets/skills/cfn-multi-coordinator-planning/plan-risk-rollout.sh +350 -0
  26. package/claude-assets/skills/cfn-multi-coordinator-planning/test-multi-coordinator-planning.sh +338 -0
  27. package/claude-assets/skills/cfn-multi-coordinator-planning/validate-task-planning.sh +189 -0
  28. package/dist/agents/agent-loader.js +165 -146
  29. package/dist/agents/agent-loader.js.map +1 -1
  30. package/package.json +1 -1
  31. package/.claude/skills/cfn-agent-selector/SKILL.md.backup_before_replace +0 -91
  32. package/.claude/skills/cfn-loop-orchestration/helpers/validate-task-context.sh +0 -241
  33. package/.claude/skills/pre-edit-backup/backup.sh +0 -130
  34. package/.claude/skills/pre-edit-backup/cleanup.sh +0 -155
  35. package/.claude/skills/pre-edit-backup/restore.sh +0 -128
  36. package/.claude/skills/pre-edit-backup/revert-file.sh +0 -168
  37. package/claude-assets/agents/cfn-dev-team/CLAUDE.md.backup_before_replace +0 -1086
  38. package/claude-assets/agents/cfn-dev-team/README.md.backup_before_replace +0 -116
  39. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md.backup_before_replace +0 -451
  40. package/claude-assets/agents/cfn-dev-team/developers/README.md.backup_before_replace +0 -69
  41. package/claude-assets/agents/cfn-dev-team/documentation/agent-type-guidelines.md.backup_before_replace +0 -465
  42. package/claude-assets/agents/cfn-dev-team/test-agent.md.backup_before_replace +0 -141
  43. package/claude-assets/skills/CFN-LOOP-VALIDATION.md +0 -202
  44. package/claude-assets/skills/REDIS-COORDINATION.md +0 -187
  45. package/claude-assets/skills/SKILL.md +0 -229
  46. package/claude-assets/skills/agent-discovery/agents-registry.json +0 -484
  47. package/claude-assets/skills/agent-name-validation/README.md +0 -28
  48. package/claude-assets/skills/agent-name-validation/SKILL.md +0 -168
  49. package/claude-assets/skills/agent-name-validation/validate-agent-names.sh +0 -47
  50. package/claude-assets/skills/cfn-agent-selector/SKILL.md.backup_before_replace +0 -91
  51. package/claude-assets/skills/cfn-loop-orchestration/helpers/validate-task-context.sh +0 -241
  52. package/claude-assets/skills/consensus-calculator.js +0 -45
  53. package/claude-assets/skills/evidence-chain.sql +0 -66
  54. package/claude-assets/skills/hook-pipeline/bash-dependency-checker.sh +0 -89
  55. package/claude-assets/skills/hook-pipeline/bash-pipe-safety.sh +0 -69
  56. package/claude-assets/skills/hook-pipeline/enforce-lf.sh +0 -36
  57. package/claude-assets/skills/hook-pipeline/js-promise-safety.sh +0 -110
  58. package/claude-assets/skills/hook-pipeline/python-async-safety.py +0 -124
  59. package/claude-assets/skills/hook-pipeline/python-import-checker.py +0 -114
  60. package/claude-assets/skills/hook-pipeline/python-subprocess-safety.py +0 -77
  61. package/claude-assets/skills/hook-pipeline/rust-command-safety.sh +0 -38
  62. package/claude-assets/skills/hook-pipeline/rust-dependency-checker.sh +0 -50
  63. package/claude-assets/skills/hook-pipeline/rust-future-safety.sh +0 -50
  64. package/claude-assets/skills/pre-edit-backup/backup.sh +0 -130
  65. package/claude-assets/skills/pre-edit-backup/cleanup.sh +0 -155
  66. package/claude-assets/skills/pre-edit-backup/restore.sh +0 -128
  67. package/claude-assets/skills/pre-edit-backup/revert-file.sh +0 -168
  68. package/claude-assets/skills/run-all-skill-tests.sh +0 -124
  69. package/claude-assets/skills/seo-orchestration/SKILL.md +0 -292
  70. package/claude-assets/skills/seo-orchestration/orchestrate-seo.sh +0 -566
  71. package/claude-assets/skills/seo-orchestration/orchestrate-seo.sh.backup +0 -755
  72. package/claude-assets/skills/seo-orchestration/validate-consensus.sh +0 -270
  73. package/claude-assets/skills/team-provider-routing/execute-agent.sh +0 -76
  74. package/claude-assets/skills/test-execution-coordinator-pattern.md +0 -228
@@ -0,0 +1,258 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ source "$SCRIPT_DIR/../cfn-redis-coordination/redis-utils.sh"
7
+
8
+ # Configuration
9
+ DEFAULT_MEMORY_PER_COORDINATOR=2048 # MB
10
+ DEFAULT_CPU_PER_COORDINATOR=2
11
+ DEFAULT_REDIS_DB_START=1
12
+ DEFAULT_REDIS_DB_END=15
13
+ CLEANUP_OVERHEAD=0.15 # 15%
14
+ MONITORING_OVERHEAD=0.05 # 5%
15
+
16
+ # Colors
17
+ RED='\033[0;31m'
18
+ GREEN='\033[0;32m'
19
+ YELLOW='\033[1;33m'
20
+ BLUE='\033[0;34m'
21
+ NC='\033[0m'
22
+
23
+ log() {
24
+ echo -e "${GREEN}[$(date '+%Y-%m-%d %H:%M:%S')] $1${NC}"
25
+ }
26
+
27
+ warn() {
28
+ echo -e "${YELLOW}[$(date '+%Y-%m-%d %H:%M:%S')] WARNING: $1${NC}"
29
+ }
30
+
31
+ error() {
32
+ echo -e "${RED}[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1${NC}"
33
+ exit 1
34
+ }
35
+
36
+ info() {
37
+ echo -e "${BLUE}[$(date '+%Y-%m-%d %H:%M:%S')] INFO: $1${NC}"
38
+ }
39
+
40
+ get_system_resources() {
41
+ local memory_kb cpu_cores
42
+ memory_kb=$(grep MemTotal /proc/meminfo | awk '{print $2}')
43
+ cpu_cores=$(nproc)
44
+
45
+ local memory_mb=$((memory_kb / 1024))
46
+
47
+ echo "{\"memory_mb\": $memory_mb, \"cpu_cores\": $cpu_cores}"
48
+ }
49
+
50
+ calculate_max_coordinators() {
51
+ local system_resources="$1"
52
+ local memory_mb cpu_cores
53
+
54
+ memory_mb=$(echo "$system_resources" | jq -r '.memory_mb')
55
+ cpu_cores=$(echo "$system_resources" | jq -r '.cpu_cores')
56
+
57
+ # Calculate with overhead
58
+ local effective_memory=$((memory_mb - (memory_mb * CLEANUP_OVERHEAD + memory_mb * MONITORING_OVERHEAD)))
59
+ local effective_cpu=$((cpu_cores - (cpu_cores * CLEANUP_OVERHEAD + cpu_cores * MONITORING_OVERHEAD)))
60
+
61
+ local max_by_memory=$((effective_memory / DEFAULT_MEMORY_PER_COORDINATOR))
62
+ local max_by_cpu=$((effective_cpu / DEFAULT_CPU_PER_COORDINATOR))
63
+
64
+ # Return the smaller of the two limits
65
+ if [[ $max_by_memory -lt $max_by_cpu ]]; then
66
+ echo $max_by_memory
67
+ else
68
+ echo $max_by_cpu
69
+ fi
70
+ }
71
+
72
+ reserve_redis_namespace() {
73
+ local zone_name="$1"
74
+ local task_id="$2"
75
+ local redis_db="$3"
76
+
77
+ local namespace_pattern="swarm:zone-${zone_name}:${task_id}"
78
+
79
+ # Test Redis connectivity
80
+ if ! redis-cli ping >/dev/null 2>&1; then
81
+ error "Redis connection failed"
82
+ fi
83
+
84
+ # Reserve namespace with SETNX and TTL
85
+ local reservation_key="${namespace_pattern}:reservation"
86
+ local reservation_result
87
+ reservation_result=$(redis-cli setnx "$reservation_key" "$(date '+%s')" 2>/dev/null || echo "0")
88
+
89
+ if [[ "$reservation_result" != "1" ]]; then
90
+ error "Namespace already reserved: $namespace_pattern"
91
+ fi
92
+
93
+ # Set TTL for reservation (1 hour)
94
+ redis-cli expire "$reservation_key" 3600 >/dev/null
95
+
96
+ log "✓ Redis namespace reserved: $namespace_pattern (DB: $redis_db)"
97
+ echo "$namespace_pattern"
98
+ }
99
+
100
+ allocate_redis_databases() {
101
+ local zone_count="$1"
102
+ local start_db="$2"
103
+ local end_db="$3"
104
+
105
+ local available_dbs=$((end_db - start_db + 1))
106
+
107
+ if [[ $zone_count -gt $available_dbs ]]; then
108
+ error "Too many zones: $zone_count (available DBs: $available_dbs)"
109
+ fi
110
+
111
+ local db_allocation=()
112
+ for ((i=0; i<zone_count; i++)); do
113
+ db_allocation+=($((start_db + i)))
114
+ done
115
+
116
+ printf '%s\n' "${db_allocation[@]}"
117
+ }
118
+
119
+ generate_task_id() {
120
+ local zone_name="$1"
121
+ local timestamp
122
+ timestamp=$(date '+%s')
123
+
124
+ echo "zone-${zone_name}-${timestamp}"
125
+ }
126
+
127
+ plan_zone_resources() {
128
+ local zone_name="$1"
129
+ local redis_db="$2"
130
+ local task_data="$3"
131
+
132
+ local task_id
133
+ task_id=$(generate_task_id "$zone_name")
134
+
135
+ # Reserve Redis namespace
136
+ local namespace_pattern
137
+ namespace_pattern=$(reserve_redis_namespace "$zone_name" "$task_id" "$redis_db")
138
+
139
+ # Generate resource plan
140
+ local resource_plan="{
141
+ \"zone_name\": \"$zone_name\",
142
+ \"task_id\": \"$task_id\",
143
+ \"namespace_pattern\": \"$namespace_pattern\",
144
+ \"redis_db\": $redis_db,
145
+ \"memory_mb\": $DEFAULT_MEMORY_PER_COORDINATOR,
146
+ \"cpu_cores\": $DEFAULT_CPU_PER_COORDINATOR,
147
+ \"working_directory\": \"/tmp/zone-${zone_name}-${task_id}\",
148
+ \"monitoring_port\": $((8080 + redis_db)),
149
+ \"timestamp\": $(date '+%s')
150
+ }"
151
+
152
+ log "✓ Resource plan generated for zone: $zone_name"
153
+ echo "$resource_plan"
154
+ }
155
+
156
+ validate_resource_availability() {
157
+ local zone_count="$1"
158
+ local system_resources="$2"
159
+
160
+ local max_coordinators
161
+ max_coordinators=$(calculate_max_coordinators "$system_resources")
162
+
163
+ if [[ $zone_count -gt $max_coordinators ]]; then
164
+ error "Insufficient resources for $zone_count coordinators (maximum: $max_coordinators)"
165
+ fi
166
+
167
+ log "✓ Resource availability validated: $zone_count zones (capacity: $max_coordinators)"
168
+ }
169
+
170
+ main() {
171
+ local config_file="$1"
172
+
173
+ if [[ -z "$config_file" ]]; then
174
+ error "Usage: $0 <zone-config-file>"
175
+ fi
176
+
177
+ if [[ ! -f "$config_file" ]]; then
178
+ error "Configuration file not found: $config_file"
179
+ fi
180
+
181
+ log "Starting coordinator resource planning for: $config_file"
182
+
183
+ # Read configuration
184
+ local zone_config
185
+ if ! zone_config=$(jq . "$config_file" 2>/dev/null); then
186
+ error "Invalid JSON in configuration file: $config_file"
187
+ fi
188
+
189
+ local zone_count
190
+ zone_count=$(echo "$zone_config" | jq '.zones | length')
191
+
192
+ if [[ $zone_count -eq 0 ]]; then
193
+ error "No zones found in configuration"
194
+ fi
195
+
196
+ info "Planning resources for $zone_count zones"
197
+
198
+ # Get system resources
199
+ local system_resources
200
+ system_resources=$(get_system_resources)
201
+
202
+ # Validate resource availability
203
+ validate_resource_availability "$zone_count" "$system_resources"
204
+
205
+ # Allocate Redis databases
206
+ local redis_dbs
207
+ mapfile -t redis_dbs < <(allocate_redis_databases "$zone_count" "$DEFAULT_REDIS_DB_START" "$DEFAULT_REDIS_DB_END")
208
+
209
+ # Generate resource plan for each zone
210
+ local resource_plans="[]"
211
+ local i=0
212
+
213
+ while IFS= read -r zone_name; do
214
+ local zone_data
215
+ zone_data=$(echo "$zone_config" | jq -r ".zones[$i]")
216
+
217
+ local resource_plan
218
+ resource_plan=$(plan_zone_resources "$zone_name" "${redis_dbs[$i]}" "$zone_data")
219
+
220
+ resource_plans=$(echo "$resource_plans" | jq ". + [$resource_plan]")
221
+
222
+ ((i++))
223
+ done < <(echo "$zone_config" | jq -r '.zones[].name')
224
+
225
+ # Generate complete resource allocation plan
226
+ local allocation_plan="{
227
+ \"timestamp\": $(date '+%s'),
228
+ \"zone_count\": $zone_count,
229
+ \"system_resources\": $system_resources,
230
+ \"max_coordinators\": $(calculate_max_coordinators "$system_resources"),
231
+ \"resource_plans\": $resource_plans,
232
+ \"redis_allocation\": {
233
+ \"databases_used\": $(printf '%s,' "${redis_dbs[@]}" | sed 's/,$//'),
234
+ \"total_allocated\": $zone_count
235
+ }
236
+ }"
237
+
238
+ # Save allocation plan
239
+ local output_file="/tmp/coordinator-resource-plan-$(date '+%s').json"
240
+ echo "$allocation_plan" > "$output_file"
241
+
242
+ log "✅ Coordinator resource planning completed"
243
+ log "Resource allocation plan saved to: $output_file"
244
+
245
+ # Display summary
246
+ echo
247
+ info "=== Resource Allocation Summary ==="
248
+ echo "Zones to execute: $zone_count"
249
+ echo "System memory: $(echo "$system_resources" | jq -r '.memory_mb') MB"
250
+ echo "System CPUs: $(echo "$system_resources" | jq -r '.cpu_cores')"
251
+ echo "Memory per coordinator: ${DEFAULT_MEMORY_PER_COORDINATOR} MB"
252
+ echo "CPUs per coordinator: ${DEFAULT_CPU_PER_COORDINATOR}"
253
+ echo "Redis databases allocated: ${redis_dbs[*]}"
254
+ echo
255
+ }
256
+
257
+ # Execute main function with all arguments
258
+ main "$@"
@@ -0,0 +1,267 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+
7
+ # Colors
8
+ RED='\033[0;31m'
9
+ GREEN='\033[0;32m'
10
+ YELLOW='\033[1;33m'
11
+ BLUE='\033[0;34m'
12
+ NC='\033[0m'
13
+
14
+ log() {
15
+ echo -e "${GREEN}[$(date '+%Y-%m-%d %H:%M:%S')] $1${NC}"
16
+ }
17
+
18
+ warn() {
19
+ echo -e "${YELLOW}[$(date '+%Y-%m-%d %H:%M:%S')] WARNING: $1${NC}"
20
+ }
21
+
22
+ error() {
23
+ echo -e "${RED}[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1${NC}"
24
+ exit 1
25
+ }
26
+
27
+ info() {
28
+ echo -e "${BLUE}[$(date '+%Y-%m-%d %H:%M:%S')] INFO: $1${NC}"
29
+ }
30
+
31
+ display_usage() {
32
+ echo "Multi-Coordinator Planning Tool"
33
+ echo
34
+ echo "Usage: $0 <zone-config-file> [options]"
35
+ echo
36
+ echo "Options:"
37
+ echo " --max-zones-per-phase N Maximum zones per rollout phase (default: 2)"
38
+ echo " --skip-validation Skip task validation (not recommended)"
39
+ echo " --dry-run Generate plan without execution"
40
+ echo " --output-dir DIR Output directory for plans (default: /tmp)"
41
+ echo " --help Display this help message"
42
+ echo
43
+ echo "Example:"
44
+ echo " $0 zone-config.json --max-zones-per-phase 3"
45
+ echo
46
+ }
47
+
48
+ validate_prerequisites() {
49
+ # Check for required tools
50
+ local required_tools=("jq" "redis-cli" "bc")
51
+
52
+ for tool in "${required_tools[@]}"; do
53
+ if ! command -v "$tool" >/dev/null 2>&1; then
54
+ error "Required tool not found: $tool"
55
+ fi
56
+ done
57
+
58
+ # Check Redis connectivity
59
+ if ! redis-cli ping >/dev/null 2>&1; then
60
+ error "Redis connection failed - required for namespace planning"
61
+ fi
62
+
63
+ log "✓ Prerequisites validation passed"
64
+ }
65
+
66
+ execute_planning_phase() {
67
+ local phase_name="$1"
68
+ local config_file="$2"
69
+ local output_dir="$3"
70
+ shift 3
71
+ local additional_args=("$@")
72
+
73
+ log "Executing planning phase: $phase_name"
74
+
75
+ case "$phase_name" in
76
+ "validation")
77
+ if [[ "${additional_args[*]}" != *"--skip-validation"* ]]; then
78
+ "$SCRIPT_DIR/validate-task-planning.sh" "$config_file"
79
+ fi
80
+ ;;
81
+ "resources")
82
+ "$SCRIPT_DIR/plan-coordinator-resources.sh" "$config_file"
83
+ ;;
84
+ "dependencies")
85
+ "$SCRIPT_DIR/map-dependencies-conflicts.sh" "$config_file"
86
+ ;;
87
+ "rollout")
88
+ "$SCRIPT_DIR/plan-risk-rollout.sh" "$config_file" "${additional_args[@]}"
89
+ ;;
90
+ *)
91
+ error "Unknown planning phase: $phase_name"
92
+ ;;
93
+ esac
94
+ }
95
+
96
+ generate_execution_summary() {
97
+ local validation_file="$1"
98
+ local resource_file="$2"
99
+ local dependency_file="$3"
100
+ local rollout_file="$4"
101
+ local summary_file="$5"
102
+
103
+ local summary="{
104
+ \"timestamp\": $(date '+%s'),
105
+ \"planning_status\": \"completed\",
106
+ \"phases_executed\": [
107
+ \"task_validation\",
108
+ \"resource_allocation\",
109
+ \"dependency_analysis\",
110
+ \"rollout_planning\"
111
+ ],
112
+ \"output_files\": {
113
+ \"validation\": \"$validation_file\",
114
+ \"resources\": \"$resource_file\",
115
+ \"dependencies\": \"$dependency_file\",
116
+ \"rollout\": \"$rollout_file\"
117
+ },
118
+ \"ready_for_execution\": true,
119
+ \"next_steps\": [
120
+ \"Review generated plans\",
121
+ \"Execute rollout in phases\",
122
+ \"Monitor coordinator health\",
123
+ \"Apply rollback triggers if needed\"
124
+ ]
125
+ }"
126
+
127
+ echo "$summary" > "$summary_file"
128
+ }
129
+
130
+ display_final_summary() {
131
+ local summary_file="$1"
132
+ local summary_data
133
+ summary_data=$(jq . "$summary_file")
134
+
135
+ echo
136
+ info "=== Multi-Coordinator Planning Summary ==="
137
+ echo "Planning completed at: $(date -d @$(echo "$summary_data" | jq -r '.timestamp') '+%Y-%m-%d %H:%M:%S')"
138
+ echo "Status: $(echo "$summary_data" | jq -r '.planning_status')"
139
+ echo "Ready for execution: $(echo "$summary_data" | jq -r '.ready_for_execution')"
140
+ echo
141
+
142
+ echo "Generated Plans:"
143
+ echo "$summary_data" | jq -r '.output_files | to_entries[] | " - \(.key): \(.value)"'
144
+ echo
145
+
146
+ echo "Next Steps:"
147
+ echo "$summary_data" | jq -r '.next_steps[] | " - \(.)"'
148
+ echo
149
+
150
+ echo "Execution Command:"
151
+ local rollout_file
152
+ rollout_file=$(echo "$summary_data" | jq -r '.output_files.rollout')
153
+ echo " ./execute-coordinator-rollout.sh $rollout_file"
154
+ echo
155
+ }
156
+
157
+ main() {
158
+ # Parse command line arguments
159
+ local config_file=""
160
+ local max_zones_per_phase=2
161
+ local skip_validation=false
162
+ local dry_run=false
163
+ local output_dir="/tmp"
164
+
165
+ while [[ $# -gt 0 ]]; do
166
+ case $1 in
167
+ --max-zones-per-phase)
168
+ max_zones_per_phase="$2"
169
+ shift 2
170
+ ;;
171
+ --skip-validation)
172
+ skip_validation=true
173
+ shift
174
+ ;;
175
+ --dry-run)
176
+ dry_run=true
177
+ shift
178
+ ;;
179
+ --output-dir)
180
+ output_dir="$2"
181
+ shift 2
182
+ ;;
183
+ --help)
184
+ display_usage
185
+ exit 0
186
+ ;;
187
+ -*)
188
+ error "Unknown option: $1"
189
+ ;;
190
+ *)
191
+ if [[ -z "$config_file" ]]; then
192
+ config_file="$1"
193
+ else
194
+ error "Multiple configuration files specified"
195
+ fi
196
+ shift
197
+ ;;
198
+ esac
199
+ done
200
+
201
+ # Validate arguments
202
+ if [[ -z "$config_file" ]]; then
203
+ error "Configuration file required"
204
+ fi
205
+
206
+ if [[ ! -f "$config_file" ]]; then
207
+ error "Configuration file not found: $config_file"
208
+ fi
209
+
210
+ # Create output directory
211
+ mkdir -p "$output_dir"
212
+
213
+ log "Starting multi-coordinator planning for: $config_file"
214
+
215
+ # Validate prerequisites
216
+ validate_prerequisites
217
+
218
+ # Prepare additional arguments
219
+ local additional_args=()
220
+ if [[ "$skip_validation" == true ]]; then
221
+ additional_args+=("--skip-validation")
222
+ fi
223
+
224
+ # Execute planning phases
225
+ local timestamp
226
+ timestamp=$(date '+%s')
227
+
228
+ local validation_output="/tmp/validated-task-$(basename "$config_file")"
229
+ local resource_output="/tmp/coordinator-resource-plan-$timestamp.json"
230
+ local dependency_output="/tmp/dependency-conflict-analysis-$timestamp.json"
231
+ local rollout_output="/tmp/rollout-plan-$timestamp.json"
232
+
233
+ # Phase 1: Task Validation
234
+ execute_planning_phase "validation" "$config_file" "$output_dir" "${additional_args[@]}"
235
+
236
+ # Phase 2: Resource Allocation
237
+ execute_planning_phase "resources" "$config_file" "$output_dir"
238
+
239
+ # Phase 3: Dependency Analysis
240
+ execute_planning_phase "dependencies" "$config_file" "$output_dir"
241
+
242
+ # Phase 4: Rollout Planning
243
+ execute_planning_phase "rollout" "$config_file" "$output_dir" "--max-zones-per-phase" "$max_zones_per_phase"
244
+
245
+ # Move files to output directory if specified
246
+ if [[ "$output_dir" != "/tmp" ]]; then
247
+ mv "$resource_output" "$output_dir/"
248
+ mv "$dependency_output" "$output_dir/"
249
+ mv "$rollout_output" "$output_dir/"
250
+ resource_output="$output_dir/$(basename "$resource_output")"
251
+ dependency_output="$output_dir/$(basename "$dependency_output")"
252
+ rollout_output="$output_dir/$(basename "$rollout_output")"
253
+ fi
254
+
255
+ # Generate execution summary
256
+ local summary_file="$output_dir/multi-coordinator-planning-summary-$timestamp.json"
257
+ generate_execution_summary "$validation_output" "$resource_output" "$dependency_output" "$rollout_output" "$summary_file"
258
+
259
+ log "✅ Multi-coordinator planning completed successfully"
260
+
261
+ if [[ "$dry_run" == false ]]; then
262
+ display_final_summary "$summary_file"
263
+ fi
264
+ }
265
+
266
+ # Execute main function with all arguments
267
+ main "$@"