claude-flow-novice 2.14.14 → 2.14.16

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.
@@ -1,189 +1,189 @@
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
- MIN_DELIVERABLES=3
10
- MIN_AGENT_TYPES=2
11
- MIN_CONTEXT_SCORE=0.8
12
- TIMEOUT_SECONDS=30
13
-
14
- # Colors
15
- RED='\033[0;31m'
16
- GREEN='\033[0;32m'
17
- YELLOW='\033[1;33m'
18
- NC='\033[0m'
19
-
20
- log() {
21
- echo -e "${GREEN}[$(date '+%Y-%m-%d %H:%M:%S')] $1${NC}"
22
- }
23
-
24
- warn() {
25
- echo -e "${YELLOW}[$(date '+%Y-%m-%d %H:%M:%S')] WARNING: $1${NC}"
26
- }
27
-
28
- error() {
29
- echo -e "${RED}[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1${NC}"
30
- exit 1
31
- }
32
-
33
- validate_deliverables() {
34
- local task_data="$1"
35
- local deliverables
36
- deliverables=$(echo "$task_data" | jq -r '.deliverables[]? // empty' 2>/dev/null || echo "")
37
-
38
- if [[ -z "$deliverables" ]]; then
39
- error "No deliverables found in task configuration"
40
- fi
41
-
42
- local deliverable_count
43
- deliverable_count=$(echo "$deliverables" | wc -l)
44
-
45
- if [[ $deliverable_count -lt $MIN_DELIVERABLES ]]; then
46
- error "Insufficient deliverables: $deliverable_count (minimum: $MIN_DELIVERABLES)"
47
- fi
48
-
49
- # Check for generic/deliverable anti-patterns
50
- while IFS= read -r deliverable; do
51
- if [[ "$deliverable" =~ ^(implementation|code|development|fix)$ ]]; then
52
- error "Generic deliverable detected: '$deliverable'. Be specific about file names and locations."
53
- fi
54
- done <<< "$deliverables"
55
-
56
- log "✓ Deliverables validation passed: $deliverable_count specific deliverables"
57
- }
58
-
59
- validate_agent_types() {
60
- local task_data="$1"
61
- local agent_types
62
- agent_types=$(echo "$task_data" | jq -r '.agent_types[]? // empty' 2>/dev/null || echo "")
63
-
64
- if [[ -z "$agent_types" ]]; then
65
- error "No agent types specified in task configuration"
66
- fi
67
-
68
- local agent_count
69
- agent_count=$(echo "$agent_types" | wc -l)
70
-
71
- if [[ $agent_count -lt $MIN_AGENT_TYPES ]]; then
72
- error "Insufficient agent types: $agent_count (minimum: $MIN_AGENT_TYPES for software tasks)"
73
- fi
74
-
75
- # Check for single-agent anti-patterns
76
- if [[ $agent_count -eq 1 ]]; then
77
- warn "Single agent type detected: ${agent_types}. Consider adding reviewer/tester agents."
78
- fi
79
-
80
- log "✓ Agent types validation passed: $agent_count agent types"
81
- }
82
-
83
- validate_context_completeness() {
84
- local task_data="$1"
85
- local score=0.0
86
-
87
- # Check for deliverables (0.3 points)
88
- if echo "$task_data" | jq -e '.deliverables and (.deliverables | length) > 0' >/dev/null 2>&1; then
89
- score=$(echo "$score + 0.3" | bc -l)
90
- fi
91
-
92
- # Check for acceptance criteria (0.3 points)
93
- if echo "$task_data" | jq -e '.acceptance_criteria and (.acceptance_criteria | length) > 0' >/dev/null 2>&1; then
94
- score=$(echo "$score + 0.3" | bc -l)
95
- fi
96
-
97
- # Check for in_scope/out_of_scope (0.2 points)
98
- if echo "$task_data" | jq -e '.in_scope and (.in_scope | length) > 0' >/dev/null 2>&1; then
99
- score=$(echo "$score + 0.1" | bc -l)
100
- fi
101
-
102
- if echo "$task_data" | jq -e '.out_of_scope and (.out_of_scope | length) > 0' >/dev/null 2>&1; then
103
- score=$(echo "$score + 0.1" | bc -l)
104
- fi
105
-
106
- # Check for directory specification (0.2 points)
107
- if echo "$task_data" | jq -e '.directory and (.directory | length) > 0' >/dev/null 2>&1; then
108
- score=$(echo "$score + 0.2" | bc -l)
109
- fi
110
-
111
- if (( $(echo "$score < $MIN_CONTEXT_SCORE" | bc -l) )); then
112
- error "Context completeness score: $score (minimum: $MIN_CONTEXT_SCORE)"
113
- fi
114
-
115
- log "✓ Context completeness validation passed: score $score"
116
- }
117
-
118
- validate_task_specificity() {
119
- local task_data="$1"
120
- local task_description
121
- task_description=$(echo "$task_data" | jq -r '.task_description // ""' 2>/dev/null || echo "")
122
-
123
- # Check for generic task descriptions
124
- local generic_patterns=("CFN Loop implementation" "implement feature" "fix bug" "create code")
125
- for pattern in "${generic_patterns[@]}"; do
126
- if [[ "$task_description" =~ $pattern ]]; then
127
- error "Generic task description detected: '$task_description'. Provide specific implementation details."
128
- fi
129
- done
130
-
131
- if [[ ${#task_description} -lt 20 ]]; then
132
- error "Task description too short: ${#task_description} characters (minimum: 20)"
133
- fi
134
-
135
- log "✓ Task specificity validation passed"
136
- }
137
-
138
- validate_namespace_requirements() {
139
- local task_data="$1"
140
- local zone_name
141
- zone_name=$(echo "$task_data" | jq -r '.zone_name // empty' 2>/dev/null || echo "")
142
-
143
- if [[ -z "$zone_name" ]]; then
144
- error "Zone name not specified in task configuration"
145
- fi
146
-
147
- # Validate zone name format
148
- if [[ ! "$zone_name" =~ ^[a-z0-9-]+$ ]]; then
149
- error "Invalid zone name format: '$zone_name'. Use lowercase letters, numbers, and hyphens only."
150
- fi
151
-
152
- log "✓ Namespace requirements validation passed: zone '$zone_name'"
153
- }
154
-
155
- main() {
156
- local config_file="$1"
157
-
158
- if [[ -z "$config_file" ]]; then
159
- error "Usage: $0 <task-config-file>"
160
- fi
161
-
162
- if [[ ! -f "$config_file" ]]; then
163
- error "Configuration file not found: $config_file"
164
- fi
165
-
166
- log "Starting task planning validation for: $config_file"
167
-
168
- # Read and validate JSON
169
- local task_data
170
- if ! task_data=$(jq . "$config_file" 2>/dev/null); then
171
- error "Invalid JSON in configuration file: $config_file"
172
- fi
173
-
174
- # Run all validations
175
- validate_deliverables "$task_data"
176
- validate_agent_types "$task_data"
177
- validate_context_completeness "$task_data"
178
- validate_task_specificity "$task_data"
179
- validate_namespace_requirements "$task_data"
180
-
181
- log "✅ Task planning validation completed successfully"
182
-
183
- # Output validated task data for next stage
184
- echo "$task_data" > "/tmp/validated-task-$(basename "$config_file")"
185
- log "Validated task data saved to: /tmp/validated-task-$(basename "$config_file")"
186
- }
187
-
188
- # Execute main function with all arguments
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
+ MIN_DELIVERABLES=3
10
+ MIN_AGENT_TYPES=2
11
+ MIN_CONTEXT_SCORE=0.8
12
+ TIMEOUT_SECONDS=30
13
+
14
+ # Colors
15
+ RED='\033[0;31m'
16
+ GREEN='\033[0;32m'
17
+ YELLOW='\033[1;33m'
18
+ NC='\033[0m'
19
+
20
+ log() {
21
+ echo -e "${GREEN}[$(date '+%Y-%m-%d %H:%M:%S')] $1${NC}"
22
+ }
23
+
24
+ warn() {
25
+ echo -e "${YELLOW}[$(date '+%Y-%m-%d %H:%M:%S')] WARNING: $1${NC}"
26
+ }
27
+
28
+ error() {
29
+ echo -e "${RED}[$(date '+%Y-%m-%d %H:%M:%S')] ERROR: $1${NC}"
30
+ exit 1
31
+ }
32
+
33
+ validate_deliverables() {
34
+ local task_data="$1"
35
+ local deliverables
36
+ deliverables=$(echo "$task_data" | jq -r '.deliverables[]? // empty' 2>/dev/null || echo "")
37
+
38
+ if [[ -z "$deliverables" ]]; then
39
+ error "No deliverables found in task configuration"
40
+ fi
41
+
42
+ local deliverable_count
43
+ deliverable_count=$(echo "$deliverables" | wc -l)
44
+
45
+ if [[ $deliverable_count -lt $MIN_DELIVERABLES ]]; then
46
+ error "Insufficient deliverables: $deliverable_count (minimum: $MIN_DELIVERABLES)"
47
+ fi
48
+
49
+ # Check for generic/deliverable anti-patterns
50
+ while IFS= read -r deliverable; do
51
+ if [[ "$deliverable" =~ ^(implementation|code|development|fix)$ ]]; then
52
+ error "Generic deliverable detected: '$deliverable'. Be specific about file names and locations."
53
+ fi
54
+ done <<< "$deliverables"
55
+
56
+ log "✓ Deliverables validation passed: $deliverable_count specific deliverables"
57
+ }
58
+
59
+ validate_agent_types() {
60
+ local task_data="$1"
61
+ local agent_types
62
+ agent_types=$(echo "$task_data" | jq -r '.agent_types[]? // empty' 2>/dev/null || echo "")
63
+
64
+ if [[ -z "$agent_types" ]]; then
65
+ error "No agent types specified in task configuration"
66
+ fi
67
+
68
+ local agent_count
69
+ agent_count=$(echo "$agent_types" | wc -l)
70
+
71
+ if [[ $agent_count -lt $MIN_AGENT_TYPES ]]; then
72
+ error "Insufficient agent types: $agent_count (minimum: $MIN_AGENT_TYPES for software tasks)"
73
+ fi
74
+
75
+ # Check for single-agent anti-patterns
76
+ if [[ $agent_count -eq 1 ]]; then
77
+ warn "Single agent type detected: ${agent_types}. Consider adding reviewer/tester agents."
78
+ fi
79
+
80
+ log "✓ Agent types validation passed: $agent_count agent types"
81
+ }
82
+
83
+ validate_context_completeness() {
84
+ local task_data="$1"
85
+ local score=0.0
86
+
87
+ # Check for deliverables (0.3 points)
88
+ if echo "$task_data" | jq -e '.deliverables and (.deliverables | length) > 0' >/dev/null 2>&1; then
89
+ score=$(echo "$score + 0.3" | bc -l)
90
+ fi
91
+
92
+ # Check for acceptance criteria (0.3 points)
93
+ if echo "$task_data" | jq -e '.acceptance_criteria and (.acceptance_criteria | length) > 0' >/dev/null 2>&1; then
94
+ score=$(echo "$score + 0.3" | bc -l)
95
+ fi
96
+
97
+ # Check for in_scope/out_of_scope (0.2 points)
98
+ if echo "$task_data" | jq -e '.in_scope and (.in_scope | length) > 0' >/dev/null 2>&1; then
99
+ score=$(echo "$score + 0.1" | bc -l)
100
+ fi
101
+
102
+ if echo "$task_data" | jq -e '.out_of_scope and (.out_of_scope | length) > 0' >/dev/null 2>&1; then
103
+ score=$(echo "$score + 0.1" | bc -l)
104
+ fi
105
+
106
+ # Check for directory specification (0.2 points)
107
+ if echo "$task_data" | jq -e '.directory and (.directory | length) > 0' >/dev/null 2>&1; then
108
+ score=$(echo "$score + 0.2" | bc -l)
109
+ fi
110
+
111
+ if (( $(echo "$score < $MIN_CONTEXT_SCORE" | bc -l) )); then
112
+ error "Context completeness score: $score (minimum: $MIN_CONTEXT_SCORE)"
113
+ fi
114
+
115
+ log "✓ Context completeness validation passed: score $score"
116
+ }
117
+
118
+ validate_task_specificity() {
119
+ local task_data="$1"
120
+ local task_description
121
+ task_description=$(echo "$task_data" | jq -r '.task_description // ""' 2>/dev/null || echo "")
122
+
123
+ # Check for generic task descriptions
124
+ local generic_patterns=("CFN Loop implementation" "implement feature" "fix bug" "create code")
125
+ for pattern in "${generic_patterns[@]}"; do
126
+ if [[ "$task_description" =~ $pattern ]]; then
127
+ error "Generic task description detected: '$task_description'. Provide specific implementation details."
128
+ fi
129
+ done
130
+
131
+ if [[ ${#task_description} -lt 20 ]]; then
132
+ error "Task description too short: ${#task_description} characters (minimum: 20)"
133
+ fi
134
+
135
+ log "✓ Task specificity validation passed"
136
+ }
137
+
138
+ validate_namespace_requirements() {
139
+ local task_data="$1"
140
+ local zone_name
141
+ zone_name=$(echo "$task_data" | jq -r '.zone_name // empty' 2>/dev/null || echo "")
142
+
143
+ if [[ -z "$zone_name" ]]; then
144
+ error "Zone name not specified in task configuration"
145
+ fi
146
+
147
+ # Validate zone name format
148
+ if [[ ! "$zone_name" =~ ^[a-z0-9-]+$ ]]; then
149
+ error "Invalid zone name format: '$zone_name'. Use lowercase letters, numbers, and hyphens only."
150
+ fi
151
+
152
+ log "✓ Namespace requirements validation passed: zone '$zone_name'"
153
+ }
154
+
155
+ main() {
156
+ local config_file="$1"
157
+
158
+ if [[ -z "$config_file" ]]; then
159
+ error "Usage: $0 <task-config-file>"
160
+ fi
161
+
162
+ if [[ ! -f "$config_file" ]]; then
163
+ error "Configuration file not found: $config_file"
164
+ fi
165
+
166
+ log "Starting task planning validation for: $config_file"
167
+
168
+ # Read and validate JSON
169
+ local task_data
170
+ if ! task_data=$(jq . "$config_file" 2>/dev/null); then
171
+ error "Invalid JSON in configuration file: $config_file"
172
+ fi
173
+
174
+ # Run all validations
175
+ validate_deliverables "$task_data"
176
+ validate_agent_types "$task_data"
177
+ validate_context_completeness "$task_data"
178
+ validate_task_specificity "$task_data"
179
+ validate_namespace_requirements "$task_data"
180
+
181
+ log "✅ Task planning validation completed successfully"
182
+
183
+ # Output validated task data for next stage
184
+ echo "$task_data" > "/tmp/validated-task-$(basename "$config_file")"
185
+ log "Validated task data saved to: /tmp/validated-task-$(basename "$config_file")"
186
+ }
187
+
188
+ # Execute main function with all arguments
189
189
  main "$@"