claude-flow-novice 2.14.2 → 2.14.4

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 (161) hide show
  1. package/.claude/commands/CFN_LOOP_TASK_MODE.md +4 -47
  2. package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -276
  3. package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +4 -47
  4. package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -276
  5. package/dist/cli/agent-prompt-builder.js +25 -0
  6. package/dist/cli/agent-prompt-builder.js.map +1 -1
  7. package/dist/cli/config-manager.js +91 -109
  8. package/package.json +1 -1
  9. package/scripts/init-project.js +1 -1
  10. package/.claude/skills/cfn-redis-coordination/HEARTBEAT.md +0 -57
  11. package/.claude/skills/cfn-redis-coordination/HEARTBEAT_MONITORING.md +0 -267
  12. package/.claude/skills/cfn-redis-coordination/LOGGING.md +0 -260
  13. package/.claude/skills/cfn-redis-coordination/README.md +0 -65
  14. package/.claude/skills/cfn-redis-coordination/SECURITY_REVIEW.md +0 -25
  15. package/.claude/skills/cfn-redis-coordination/SHUTDOWN_HANDLING.md +0 -164
  16. package/.claude/skills/cfn-redis-coordination/SKILL.md +0 -720
  17. package/.claude/skills/cfn-redis-coordination/demos/test-dlq.sh +0 -129
  18. package/.claude/skills/cfn-redis-coordination/demos/test-iteration-feedback.sh +0 -320
  19. package/.claude/skills/cfn-redis-coordination/demos/test-orchestrator.sh +0 -249
  20. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake-phase4-unix.sh +0 -148
  21. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake-phase4.sh +0 -163
  22. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake.sh +0 -138
  23. package/.claude/skills/cfn-redis-coordination/demos/test-quick-fix.sh +0 -81
  24. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-absolute.sh +0 -45
  25. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-fallback.sh +0 -68
  26. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-percentage.sh +0 -56
  27. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-with-retry.sh +0 -81
  28. package/.claude/skills/cfn-redis-coordination/demos/test-quorum.sh +0 -57
  29. package/.claude/skills/cfn-redis-coordination/demos/test-shutdown-handling.sh +0 -187
  30. package/.claude/skills/cfn-redis-coordination/demos/test-shutdown.sh +0 -160
  31. package/.claude/skills/cfn-redis-coordination/demos/test-utils-unix.sh +0 -97
  32. package/.claude/skills/cfn-redis-coordination/demos/test-utils.sh +0 -97
  33. package/.claude/skills/cfn-redis-coordination/demos/test-waiting-mode.sh +0 -59
  34. package/.claude/skills/cfn-redis-coordination/examples/README.md +0 -73
  35. package/.claude/skills/cfn-redis-coordination/examples/grafana-dashboard.json +0 -352
  36. package/.claude/skills/cfn-redis-coordination/examples/hierarchical-pattern.sh +0 -127
  37. package/.claude/skills/cfn-redis-coordination/examples/mesh-pattern.sh +0 -171
  38. package/.claude/skills/cfn-redis-coordination/examples/timeout-handling.sh +0 -227
  39. package/.claude/skills/cfn-redis-coordination/examples/waiting-mode-pattern.sh +0 -239
  40. package/.claude/skills/cfn-redis-coordination/execute-product-owner-decision.sh +0 -258
  41. package/.claude/skills/cfn-redis-coordination/get-agent-timeout.sh +0 -177
  42. package/.claude/skills/cfn-redis-coordination/heartbeat-functions.sh +0 -137
  43. package/.claude/skills/cfn-redis-coordination/heartbeat-protocol.md +0 -106
  44. package/.claude/skills/cfn-redis-coordination/heartbeat.sh +0 -126
  45. package/.claude/skills/cfn-redis-coordination/init-swarm.sh +0 -148
  46. package/.claude/skills/cfn-redis-coordination/invoke-redis-pattern.sh +0 -220
  47. package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +0 -283
  48. package/.claude/skills/cfn-redis-coordination/list-active-swarms.sh +0 -147
  49. package/.claude/skills/cfn-redis-coordination/log-event.sh +0 -109
  50. package/.claude/skills/cfn-redis-coordination/metrics-export.sh +0 -674
  51. package/.claude/skills/cfn-redis-coordination/metrics-schema.json +0 -66
  52. package/.claude/skills/cfn-redis-coordination/metrics-storage.md +0 -31
  53. package/.claude/skills/cfn-redis-coordination/monitor-cfn-violations.sh +0 -391
  54. package/.claude/skills/cfn-redis-coordination/monitor-heartbeats.sh +0 -101
  55. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop-v3.sh +0 -141
  56. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh +0 -31
  57. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
  58. package/.claude/skills/cfn-redis-coordination/priority-wake-mechanism.md +0 -75
  59. package/.claude/skills/cfn-redis-coordination/priority_wake.py +0 -134
  60. package/.claude/skills/cfn-redis-coordination/query-dlq.sh +0 -162
  61. package/.claude/skills/cfn-redis-coordination/query-logs.sh +0 -103
  62. package/.claude/skills/cfn-redis-coordination/redis-pattern.sh +0 -619
  63. package/.claude/skills/cfn-redis-coordination/retrieve-context.sh +0 -58
  64. package/.claude/skills/cfn-redis-coordination/select-specialist-agent.sh +0 -371
  65. package/.claude/skills/cfn-redis-coordination/semantic-match-tfidf.py +0 -252
  66. package/.claude/skills/cfn-redis-coordination/send-heartbeat.sh +0 -165
  67. package/.claude/skills/cfn-redis-coordination/signal.sh +0 -38
  68. package/.claude/skills/cfn-redis-coordination/store-context.sh +0 -86
  69. package/.claude/skills/cfn-redis-coordination/store-epic-context.sh +0 -123
  70. package/.claude/skills/cfn-redis-coordination/test-context-injection.sh +0 -354
  71. package/.claude/skills/cfn-redis-coordination/test-timeout-enforcement.sh +0 -513
  72. package/.claude/skills/cfn-redis-coordination/tests/convert-line-endings.sh +0 -15
  73. package/.claude/skills/cfn-redis-coordination/tests/dlq-functionality-test.sh +0 -102
  74. package/.claude/skills/cfn-redis-coordination/tests/edge-cases-test.sh +0 -99
  75. package/.claude/skills/cfn-redis-coordination/tests/integration-test.sh +0 -170
  76. package/.claude/skills/cfn-redis-coordination/tests/retry-mechanism-test.sh +0 -82
  77. package/.claude/skills/cfn-redis-coordination/tests/run-test-suite.sh +0 -92
  78. package/.claude/skills/cfn-redis-coordination/tests/run-tests.sh +0 -4
  79. package/.claude/skills/cfn-redis-coordination/tests/test-heartbeat-monitoring.sh +0 -418
  80. package/.claude/skills/cfn-redis-coordination/tests/test-heartbeat-simple.sh +0 -124
  81. package/.claude/skills/cfn-redis-coordination/tests/test-primitives.sh +0 -166
  82. package/.claude/skills/cfn-redis-coordination/tests/test-utils.sh +0 -54
  83. package/.claude/skills/cfn-redis-coordination/tests/test_utils.sh +0 -49
  84. package/.claude/skills/cfn-redis-coordination/v2_modularization/core_orchestration.sh +0 -76
  85. package/.claude/skills/cfn-redis-coordination/validate-parameters.sh +0 -492
  86. package/claude-assets/skills/cfn-redis-coordination/HEARTBEAT.md +0 -57
  87. package/claude-assets/skills/cfn-redis-coordination/HEARTBEAT_MONITORING.md +0 -267
  88. package/claude-assets/skills/cfn-redis-coordination/LOGGING.md +0 -260
  89. package/claude-assets/skills/cfn-redis-coordination/README.md +0 -65
  90. package/claude-assets/skills/cfn-redis-coordination/SECURITY_REVIEW.md +0 -25
  91. package/claude-assets/skills/cfn-redis-coordination/SHUTDOWN_HANDLING.md +0 -164
  92. package/claude-assets/skills/cfn-redis-coordination/SKILL.md +0 -720
  93. package/claude-assets/skills/cfn-redis-coordination/demos/test-dlq.sh +0 -129
  94. package/claude-assets/skills/cfn-redis-coordination/demos/test-iteration-feedback.sh +0 -320
  95. package/claude-assets/skills/cfn-redis-coordination/demos/test-orchestrator.sh +0 -249
  96. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake-phase4-unix.sh +0 -148
  97. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake-phase4.sh +0 -163
  98. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake.sh +0 -138
  99. package/claude-assets/skills/cfn-redis-coordination/demos/test-quick-fix.sh +0 -81
  100. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-absolute.sh +0 -45
  101. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-fallback.sh +0 -68
  102. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-percentage.sh +0 -56
  103. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-with-retry.sh +0 -81
  104. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum.sh +0 -57
  105. package/claude-assets/skills/cfn-redis-coordination/demos/test-shutdown-handling.sh +0 -187
  106. package/claude-assets/skills/cfn-redis-coordination/demos/test-shutdown.sh +0 -160
  107. package/claude-assets/skills/cfn-redis-coordination/demos/test-utils-unix.sh +0 -97
  108. package/claude-assets/skills/cfn-redis-coordination/demos/test-utils.sh +0 -97
  109. package/claude-assets/skills/cfn-redis-coordination/demos/test-waiting-mode.sh +0 -59
  110. package/claude-assets/skills/cfn-redis-coordination/examples/README.md +0 -73
  111. package/claude-assets/skills/cfn-redis-coordination/examples/grafana-dashboard.json +0 -352
  112. package/claude-assets/skills/cfn-redis-coordination/examples/hierarchical-pattern.sh +0 -127
  113. package/claude-assets/skills/cfn-redis-coordination/examples/mesh-pattern.sh +0 -171
  114. package/claude-assets/skills/cfn-redis-coordination/examples/timeout-handling.sh +0 -227
  115. package/claude-assets/skills/cfn-redis-coordination/examples/waiting-mode-pattern.sh +0 -239
  116. package/claude-assets/skills/cfn-redis-coordination/execute-product-owner-decision.sh +0 -258
  117. package/claude-assets/skills/cfn-redis-coordination/get-agent-timeout.sh +0 -177
  118. package/claude-assets/skills/cfn-redis-coordination/heartbeat-functions.sh +0 -137
  119. package/claude-assets/skills/cfn-redis-coordination/heartbeat-protocol.md +0 -106
  120. package/claude-assets/skills/cfn-redis-coordination/heartbeat.sh +0 -126
  121. package/claude-assets/skills/cfn-redis-coordination/init-swarm.sh +0 -148
  122. package/claude-assets/skills/cfn-redis-coordination/invoke-redis-pattern.sh +0 -220
  123. package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +0 -283
  124. package/claude-assets/skills/cfn-redis-coordination/list-active-swarms.sh +0 -147
  125. package/claude-assets/skills/cfn-redis-coordination/log-event.sh +0 -109
  126. package/claude-assets/skills/cfn-redis-coordination/metrics-export.sh +0 -674
  127. package/claude-assets/skills/cfn-redis-coordination/metrics-schema.json +0 -66
  128. package/claude-assets/skills/cfn-redis-coordination/metrics-storage.md +0 -31
  129. package/claude-assets/skills/cfn-redis-coordination/monitor-cfn-violations.sh +0 -391
  130. package/claude-assets/skills/cfn-redis-coordination/monitor-heartbeats.sh +0 -101
  131. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop-v3.sh +0 -141
  132. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh +0 -31
  133. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
  134. package/claude-assets/skills/cfn-redis-coordination/priority-wake-mechanism.md +0 -75
  135. package/claude-assets/skills/cfn-redis-coordination/priority_wake.py +0 -134
  136. package/claude-assets/skills/cfn-redis-coordination/query-dlq.sh +0 -162
  137. package/claude-assets/skills/cfn-redis-coordination/query-logs.sh +0 -103
  138. package/claude-assets/skills/cfn-redis-coordination/redis-pattern.sh +0 -619
  139. package/claude-assets/skills/cfn-redis-coordination/retrieve-context.sh +0 -58
  140. package/claude-assets/skills/cfn-redis-coordination/select-specialist-agent.sh +0 -371
  141. package/claude-assets/skills/cfn-redis-coordination/semantic-match-tfidf.py +0 -252
  142. package/claude-assets/skills/cfn-redis-coordination/send-heartbeat.sh +0 -165
  143. package/claude-assets/skills/cfn-redis-coordination/signal.sh +0 -38
  144. package/claude-assets/skills/cfn-redis-coordination/store-context.sh +0 -86
  145. package/claude-assets/skills/cfn-redis-coordination/store-epic-context.sh +0 -123
  146. package/claude-assets/skills/cfn-redis-coordination/test-context-injection.sh +0 -354
  147. package/claude-assets/skills/cfn-redis-coordination/test-timeout-enforcement.sh +0 -513
  148. package/claude-assets/skills/cfn-redis-coordination/tests/convert-line-endings.sh +0 -15
  149. package/claude-assets/skills/cfn-redis-coordination/tests/dlq-functionality-test.sh +0 -102
  150. package/claude-assets/skills/cfn-redis-coordination/tests/edge-cases-test.sh +0 -99
  151. package/claude-assets/skills/cfn-redis-coordination/tests/integration-test.sh +0 -170
  152. package/claude-assets/skills/cfn-redis-coordination/tests/retry-mechanism-test.sh +0 -82
  153. package/claude-assets/skills/cfn-redis-coordination/tests/run-test-suite.sh +0 -92
  154. package/claude-assets/skills/cfn-redis-coordination/tests/run-tests.sh +0 -4
  155. package/claude-assets/skills/cfn-redis-coordination/tests/test-heartbeat-monitoring.sh +0 -418
  156. package/claude-assets/skills/cfn-redis-coordination/tests/test-heartbeat-simple.sh +0 -124
  157. package/claude-assets/skills/cfn-redis-coordination/tests/test-primitives.sh +0 -166
  158. package/claude-assets/skills/cfn-redis-coordination/tests/test-utils.sh +0 -54
  159. package/claude-assets/skills/cfn-redis-coordination/tests/test_utils.sh +0 -49
  160. package/claude-assets/skills/cfn-redis-coordination/v2_modularization/core_orchestration.sh +0 -76
  161. package/claude-assets/skills/cfn-redis-coordination/validate-parameters.sh +0 -492
@@ -1,54 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Color codes for output
4
- RED='\033[0;31m'
5
- GREEN='\033[0;32m'
6
- NC='\033[0m' # No Color
7
-
8
- # Assert that two values are equal
9
- assert_equals() {
10
- local actual="$1"
11
- local expected="$2"
12
- local message="${3:-Assertion failed}"
13
-
14
- if [[ "$actual" == "$expected" ]]; then
15
- echo -e "${GREEN}PASS${NC}: $message"
16
- else
17
- echo -e "${RED}FAIL${NC}: $message"
18
- echo " Expected: $expected"
19
- echo " Actual: $actual"
20
- exit 1
21
- fi
22
- }
23
-
24
- # Assert that a string contains another string
25
- assert_contains() {
26
- local haystack="$1"
27
- local needle="$2"
28
- local message="${3:-Assertion failed}"
29
-
30
- if [[ "$haystack" == *"$needle"* ]]; then
31
- echo -e "${GREEN}PASS${NC}: $message"
32
- else
33
- echo -e "${RED}FAIL${NC}: $message"
34
- echo " Expected to contain: $needle"
35
- echo " Actual: $haystack"
36
- exit 1
37
- fi
38
- }
39
-
40
- # Error handling wrapper
41
- safe_execute() {
42
- local cmd="$1"
43
- local error_msg="${2:-Command execution failed}"
44
-
45
- set +e
46
- $cmd
47
- local exit_code=$?
48
- set -e
49
-
50
- if [[ $exit_code -ne 0 ]]; then
51
- echo -e "${RED}ERROR${NC}: $error_msg (Exit code: $exit_code)"
52
- exit 1
53
- fi
54
- }
@@ -1,49 +0,0 @@
1
- #!/bin/bash
2
-
3
- # Test Utilities for Bash Testing
4
-
5
- # Color codes
6
- GREEN='\033[0;32m'
7
- RED='\033[0;31m'
8
- NC='\033[0m' # No Color
9
-
10
- # Assert functions
11
- assert_equals() {
12
- local actual="$1"
13
- local expected="$2"
14
- local message="${3:-Assertion failed}"
15
-
16
- if [[ "$actual" != "$expected" ]]; then
17
- echo -e "${RED}❌ $message${NC}"
18
- echo " Expected: $expected"
19
- echo " Actual: $actual"
20
- exit 1
21
- fi
22
- echo -e "${GREEN}✅ $message passed${NC}"
23
- }
24
-
25
- assert_not_empty() {
26
- local value="$1"
27
- local message="${2:-Value should not be empty}"
28
-
29
- if [[ -z "$value" ]]; then
30
- echo -e "${RED}❌ $message${NC}"
31
- exit 1
32
- fi
33
- echo -e "${GREEN}✅ $message passed${NC}"
34
- }
35
-
36
- assert_json_equals() {
37
- local json1="$1"
38
- local json2="$2"
39
- local message="${3:-JSON comparison failed}"
40
-
41
- # Requires jq for deep JSON comparison
42
- if ! echo "$json1" | jq -n "inputs == $json2"; then
43
- echo -e "${RED}❌ $message${NC}"
44
- echo " JSON 1: $json1"
45
- echo " JSON 2: $json2"
46
- exit 1
47
- fi
48
- echo -e "${GREEN}✅ $message passed${NC}"
49
- }
@@ -1,76 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Core Orchestration Module for CFN Loop V2 Modularization
3
-
4
- # Source required modules
5
- source ./config_loader.sh
6
- source ./context_manager.sh
7
- source ./loop3_module.sh
8
- source ./loop2_module.sh
9
- source ./product_owner_module.sh
10
- source ./metrics_logger.sh
11
-
12
- # Main orchestration function
13
- orchestrate_cfn_loop() {
14
- local task_id="$1"
15
- local mode="${2:-standard}"
16
-
17
- # Load configuration
18
- load_environment_config "$task_id"
19
- validate_configuration
20
-
21
- # Load epic context
22
- local context
23
- context=$(load_epic_context "$task_id")
24
-
25
- # Execute Loop 3
26
- local loop3_result
27
- loop3_result=$(execute_loop_3_agents "$context")
28
-
29
- if [[ $loop3_result -ne 0 ]]; then
30
- log_iteration_metrics "loop3_failed"
31
- return 3
32
- fi
33
-
34
- # Execute Loop 2 Validation
35
- local consensus_result
36
- consensus_result=$(execute_loop_2_validation "$loop3_result")
37
-
38
- if [[ $consensus_result -ne 0 ]]; then
39
- log_iteration_metrics "loop2_validation_failed"
40
- return 4
41
- fi
42
-
43
- # Product Owner Decision
44
- local final_decision
45
- final_decision=$(evaluate_deliverables "$consensus_result")
46
-
47
- case "$final_decision" in
48
- "proceed")
49
- log_iteration_metrics "successful_completion"
50
- export_iteration_report
51
- return 0
52
- ;;
53
- "iterate")
54
- log_iteration_metrics "iteration_required"
55
- return 2
56
- ;;
57
- "abort")
58
- log_iteration_metrics "aborted"
59
- return 1
60
- ;;
61
- esac
62
- }
63
-
64
- # Entry point
65
- main() {
66
- local task_id="$1"
67
- local mode="${2:-standard}"
68
-
69
- orchestrate_cfn_loop "$task_id" "$mode"
70
- exit $?
71
- }
72
-
73
- # Only run main if script is executed directly
74
- if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
75
- main "$@"
76
- fi
@@ -1,492 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- ##############################################################################
4
- # Parameter Validation Helper for CFN Loop Orchestration
5
- # Validates and standardizes orchestrator parameters
6
- #
7
- # Usage:
8
- # ./validate-parameters.sh [options]
9
- # Returns: 0 if valid, 1 if invalid
10
- #
11
- # Options:
12
- # --task-id <id> Required: Unique task identifier
13
- # --mode <mode> Required: mvp|standard|enterprise
14
- # --loop3-agents <list> Required: Comma-separated agent IDs
15
- # --loop2-agents <list> Required: Comma-separated agent IDs
16
- # --product-owner <id> Required: Product owner agent ID
17
- # --max-iterations <n> Optional: Maximum iterations (1-20)
18
- # --min-quorum-loop3 <n> Optional: Minimum Loop 3 quorum
19
- # --min-quorum-loop2 <n> Optional: Minimum Loop 2 quorum
20
- # --epic-context <json> Optional: Epic context JSON
21
- # --phase-context <json> Optional: Phase context JSON
22
- # --success-criteria <json> Optional: Success criteria JSON
23
- # --expected-files <list> Optional: Comma-separated expected files
24
- # --phase-id <id> Optional: Phase identifier
25
- # --verbose Enable verbose output
26
- ##############################################################################
27
-
28
- set -euo pipefail
29
-
30
- # Variables
31
- TASK_ID=""
32
- MODE=""
33
- LOOP3_AGENTS=""
34
- LOOP2_AGENTS=""
35
- PRODUCT_OWNER=""
36
- MAX_ITERATIONS=""
37
- MIN_QUORUM_LOOP3=""
38
- MIN_QUORUM_LOOP2=""
39
- EPIC_CONTEXT=""
40
- PHASE_CONTEXT=""
41
- SUCCESS_CRITERIA=""
42
- EXPECTED_FILES=""
43
- PHASE_ID=""
44
- VERBOSE=0
45
-
46
- # Validation result tracking
47
- VALIDATION_ERRORS=()
48
- VALIDATION_WARNINGS=()
49
-
50
- # Colors for output
51
- RED='\033[0;31m'
52
- GREEN='\033[0;32m'
53
- YELLOW='\033[1;33m'
54
- NC='\033[0m' # No Color
55
-
56
- ##############################################################################
57
- # Utility Functions
58
- ##############################################################################
59
-
60
- log_error() {
61
- VALIDATION_ERRORS+=("$1")
62
- if [[ $VERBOSE -eq 1 ]]; then
63
- echo -e "${RED}ERROR: $1${NC}" >&2
64
- fi
65
- }
66
-
67
- log_warning() {
68
- VALIDATION_WARNINGS+=("$1")
69
- if [[ $VERBOSE -eq 1 ]]; then
70
- echo -e "${YELLOW}WARNING: $1${NC}" >&2
71
- fi
72
- }
73
-
74
- log_info() {
75
- if [[ $VERBOSE -eq 1 ]]; then
76
- echo -e "${GREEN}INFO: $1${NC}" >&2
77
- fi
78
- }
79
-
80
- # Validate JSON structure
81
- validate_json() {
82
- local json_string="$1"
83
- local field_name="$2"
84
-
85
- if [[ -z "$json_string" ]]; then
86
- return 0 # Empty JSON is valid (optional field)
87
- fi
88
-
89
- # Try to parse with jq
90
- if ! echo "$json_string" | jq . >/dev/null 2>&1; then
91
- log_error "$field_name: Invalid JSON format"
92
- return 1
93
- fi
94
-
95
- log_info "$field_name: Valid JSON structure"
96
- return 0
97
- }
98
-
99
- # Validate task ID format
100
- validate_task_id() {
101
- local task_id="$1"
102
-
103
- if [[ -z "$task_id" ]]; then
104
- log_error "task-id: Required parameter missing"
105
- return 1
106
- fi
107
-
108
- # Check length (reasonable limits)
109
- if [[ ${#task_id} -lt 3 ]]; then
110
- log_error "task-id: Too short (minimum 3 characters)"
111
- return 1
112
- fi
113
-
114
- if [[ ${#task_id} -gt 100 ]]; then
115
- log_error "task-id: Too long (maximum 100 characters)"
116
- return 1
117
- fi
118
-
119
- # Check for valid characters (alphanumeric, hyphens, underscores)
120
- if [[ ! "$task_id" =~ ^[a-zA-Z0-9_-]+$ ]]; then
121
- log_error "task-id: Invalid characters (only letters, numbers, hyphens, underscores allowed)"
122
- return 1
123
- fi
124
-
125
- log_info "task-id: Valid format"
126
- return 0
127
- }
128
-
129
- # Validate mode
130
- validate_mode() {
131
- local mode="$1"
132
-
133
- if [[ -z "$mode" ]]; then
134
- log_error "mode: Required parameter missing"
135
- return 1
136
- fi
137
-
138
- case "$mode" in
139
- mvp|standard|enterprise)
140
- log_info "mode: Valid mode ($mode)"
141
- return 0
142
- ;;
143
- *)
144
- log_error "mode: Invalid mode (must be mvp, standard, or enterprise)"
145
- return 1
146
- ;;
147
- esac
148
- }
149
-
150
- # Validate agent list
151
- validate_agent_list() {
152
- local agent_list="$1"
153
- local field_name="$2"
154
-
155
- if [[ -z "$agent_list" ]]; then
156
- log_error "$field_name: Required parameter missing"
157
- return 1
158
- fi
159
-
160
- # Split by comma and validate each agent ID
161
- IFS=',' read -ra AGENTS <<< "$agent_list"
162
- for agent in "${AGENTS[@]}"; do
163
- agent=$(echo "$agent" | xargs) # Trim whitespace
164
- if [[ -z "$agent" ]]; then
165
- log_error "$field_name: Empty agent ID in list"
166
- return 1
167
- fi
168
-
169
- if [[ ! "$agent" =~ ^[a-zA-Z0-9_-]+$ ]]; then
170
- log_error "$field_name: Invalid agent ID format: $agent"
171
- return 1
172
- fi
173
- done
174
-
175
- log_info "$field_name: Valid agent list (${#AGENTS[@]} agents)"
176
- return 0
177
- }
178
-
179
- # Validate numeric parameters
180
- validate_numeric() {
181
- local value="$1"
182
- local field_name="$2"
183
- local min_val="${3:-1}"
184
- local max_val="${4:-100}"
185
-
186
- if [[ -z "$value" ]]; then
187
- return 0 # Optional parameter
188
- fi
189
-
190
- # Check if it's a valid number
191
- if ! [[ "$value" =~ ^[0-9]+$ ]]; then
192
- log_error "$field_name: Must be a positive integer"
193
- return 1
194
- fi
195
-
196
- # Check range
197
- if [[ $value -lt $min_val || $value -gt $max_val ]]; then
198
- log_error "$field_name: Must be between $min_val and $max_val"
199
- return 1
200
- fi
201
-
202
- log_info "$field_name: Valid numeric value ($value)"
203
- return 0
204
- }
205
-
206
- # Validate quorum parameter (supports multiple formats)
207
- validate_quorum() {
208
- local quorum="$1"
209
- local field_name="$2"
210
-
211
- if [[ -z "$quorum" ]]; then
212
- return 0 # Optional parameter
213
- fi
214
-
215
- # Check percentage format (e.g., "75%")
216
- if [[ "$quorum" =~ ^[0-9]+%$ ]]; then
217
- local percent="${quorum%\%}"
218
- if [[ $percent -lt 1 || $percent -gt 100 ]]; then
219
- log_error "$field_name: Percentage must be between 1% and 100%"
220
- return 1
221
- fi
222
- log_info "$field_name: Valid percentage format ($quorum)"
223
- return 0
224
- fi
225
-
226
- # Check decimal format (e.g., "0.75")
227
- if [[ "$quorum" =~ ^0\.[0-9]+$ ]]; then
228
- local decimal=$(echo "$quorum" | bc -l)
229
- if (( $(echo "$decimal < 0.01 || $decimal > 1.0" | bc -l) )); then
230
- log_error "$field_name: Decimal must be between 0.01 and 1.0"
231
- return 1
232
- fi
233
- log_info "$field_name: Valid decimal format ($quorum)"
234
- return 0
235
- fi
236
-
237
- # Check absolute number format (e.g., "3")
238
- if [[ "$quorum" =~ ^[0-9]+$ ]]; then
239
- if [[ $quorum -lt 1 || $quorum -gt 20 ]]; then
240
- log_error "$field_name: Absolute number must be between 1 and 20"
241
- return 1
242
- fi
243
- log_info "$field_name: Valid absolute format ($quorum)"
244
- return 0
245
- fi
246
-
247
- log_error "$field_name: Invalid format (must be number, percentage, or decimal)"
248
- return 1
249
- }
250
-
251
- # Validate file list
252
- validate_file_list() {
253
- local file_list="$1"
254
- local field_name="$2"
255
-
256
- if [[ -z "$file_list" ]]; then
257
- return 0 # Optional parameter
258
- fi
259
-
260
- # Split by comma and validate each file path
261
- IFS=',' read -ra FILES <<< "$file_list"
262
- for file in "${FILES[@]}"; do
263
- file=$(echo "$file" | xargs) # Trim whitespace
264
- if [[ -z "$file" ]]; then
265
- log_error "$field_name: Empty file path in list"
266
- return 1
267
- fi
268
-
269
- # Basic path validation (no absolute paths, no directory traversal)
270
- if [[ "$file" =~ ^/ ]] || [[ "$file" =~ \.\. ]]; then
271
- log_warning "$field_name: Potentially unsafe path: $file"
272
- fi
273
- done
274
-
275
- log_info "$field_name: Valid file list (${#FILES[@]} files)"
276
- return 0
277
- }
278
-
279
- ##############################################################################
280
- # Main Validation Functions
281
- ##############################################################################
282
-
283
- validate_required_parameters() {
284
- local errors=0
285
-
286
- validate_task_id "$TASK_ID" || ((errors++))
287
- validate_mode "$MODE" || ((errors++))
288
- validate_agent_list "$LOOP3_AGENTS" "loop3-agents" || ((errors++))
289
- validate_agent_list "$LOOP2_AGENTS" "loop2-agents" || ((errors++))
290
- validate_agent_list "$PRODUCT_OWNER" "product-owner" || ((errors++))
291
-
292
- return $errors
293
- }
294
-
295
- validate_optional_parameters() {
296
- local errors=0
297
-
298
- validate_numeric "$MAX_ITERATIONS" "max-iterations" 1 20 || ((errors++))
299
- validate_quorum "$MIN_QUORUM_LOOP3" "min-quorum-loop3" || ((errors++))
300
- validate_quorum "$MIN_QUORUM_LOOP2" "min-quorum-loop2" || ((errors++))
301
- validate_json "$EPIC_CONTEXT" "epic-context" || ((errors++))
302
- validate_json "$PHASE_CONTEXT" "phase-context" || ((errors++))
303
- validate_json "$SUCCESS_CRITERIA" "success-criteria" || ((errors++))
304
- validate_file_list "$EXPECTED_FILES" "expected-files" || ((errors++))
305
-
306
- # Validate phase ID (similar to task ID)
307
- if [[ -n "$PHASE_ID" ]]; then
308
- if [[ ! "$PHASE_ID" =~ ^[a-zA-Z0-9_-]+$ ]]; then
309
- log_error "phase-id: Invalid format (only letters, numbers, hyphens, underscores allowed)"
310
- ((errors++))
311
- else
312
- log_info "phase-id: Valid format"
313
- fi
314
- fi
315
-
316
- return $errors
317
- }
318
-
319
- print_validation_summary() {
320
- local total_errors=${#VALIDATION_ERRORS[@]}
321
- local total_warnings=${#VALIDATION_WARNINGS[@]}
322
-
323
- echo ""
324
- echo "=== Parameter Validation Summary ==="
325
-
326
- if [[ $total_errors -eq 0 ]]; then
327
- echo -e "${GREEN}✅ All parameters are valid${NC}"
328
- else
329
- echo -e "${RED}❌ Validation failed with $total_errors error(s)${NC}"
330
- if [[ $VERBOSE -eq 0 ]]; then
331
- echo "Run with --verbose for detailed error messages"
332
- fi
333
- fi
334
-
335
- if [[ $total_warnings -gt 0 ]]; then
336
- echo -e "${YELLOW}⚠️ $total_warnings warning(s) found${NC}"
337
- if [[ $VERBOSE -eq 0 ]]; then
338
- echo "Run with --verbose for detailed warning messages"
339
- fi
340
- fi
341
-
342
- echo ""
343
-
344
- # Show errors in non-verbose mode
345
- if [[ $VERBOSE -eq 0 && $total_errors -gt 0 ]]; then
346
- echo "Errors:"
347
- for error in "${VALIDATION_ERRORS[@]}"; do
348
- echo " - $error"
349
- done
350
- echo ""
351
- fi
352
-
353
- # Show warnings in non-verbose mode
354
- if [[ $VERBOSE -eq 0 && $total_warnings -gt 0 ]]; then
355
- echo "Warnings:"
356
- for warning in "${VALIDATION_WARNINGS[@]}"; do
357
- echo " - $warning"
358
- done
359
- echo ""
360
- fi
361
- }
362
-
363
- ##############################################################################
364
- # Parse Arguments
365
- ##############################################################################
366
-
367
- while [[ $# -gt 0 ]]; do
368
- case $1 in
369
- --task-id)
370
- TASK_ID="$2"
371
- shift 2
372
- ;;
373
- --mode)
374
- MODE="$2"
375
- shift 2
376
- ;;
377
- --loop3-agents)
378
- LOOP3_AGENTS="$2"
379
- shift 2
380
- ;;
381
- --loop2-agents)
382
- LOOP2_AGENTS="$2"
383
- shift 2
384
- ;;
385
- --product-owner)
386
- PRODUCT_OWNER="$2"
387
- shift 2
388
- ;;
389
- --max-iterations)
390
- MAX_ITERATIONS="$2"
391
- shift 2
392
- ;;
393
- --min-quorum-loop3)
394
- MIN_QUORUM_LOOP3="$2"
395
- shift 2
396
- ;;
397
- --min-quorum-loop2)
398
- MIN_QUORUM_LOOP2="$2"
399
- shift 2
400
- ;;
401
- --epic-context)
402
- EPIC_CONTEXT="$2"
403
- shift 2
404
- ;;
405
- --phase-context)
406
- PHASE_CONTEXT="$2"
407
- shift 2
408
- ;;
409
- --success-criteria)
410
- SUCCESS_CRITERIA="$2"
411
- shift 2
412
- ;;
413
- --expected-files)
414
- EXPECTED_FILES="$2"
415
- shift 2
416
- ;;
417
- --phase-id)
418
- PHASE_ID="$2"
419
- shift 2
420
- ;;
421
- --verbose)
422
- VERBOSE=1
423
- shift
424
- ;;
425
- --help|-h)
426
- echo "Usage: $0 [options]"
427
- echo "Validates CFN Loop orchestrator parameters"
428
- echo ""
429
- echo "Required options:"
430
- echo " --task-id <id> Unique task identifier"
431
- echo " --mode <mode> Execution mode (mvp|standard|enterprise)"
432
- echo " --loop3-agents <list> Comma-separated Loop 3 agent IDs"
433
- echo " --loop2-agents <list> Comma-separated Loop 2 agent IDs"
434
- echo " --product-owner <id> Product owner agent ID"
435
- echo ""
436
- echo "Optional options:"
437
- echo " --max-iterations <n> Maximum iterations (1-20)"
438
- echo " --min-quorum-loop3 <n> Loop 3 quorum (number|percentage|decimal)"
439
- echo " --min-quorum-loop2 <n> Loop 2 quorum (number|percentage|decimal)"
440
- echo " --epic-context <json> Epic context JSON"
441
- echo " --phase-context <json> Phase context JSON"
442
- echo " --success-criteria <json> Success criteria JSON"
443
- echo " --expected-files <list> Comma-separated expected files"
444
- echo " --phase-id <id> Phase identifier"
445
- echo " --verbose Enable verbose output"
446
- echo " --help Show this help message"
447
- echo ""
448
- echo "Exit codes:"
449
- echo " 0 All parameters are valid"
450
- echo " 1 Validation errors found"
451
- exit 0
452
- ;;
453
- *)
454
- echo "Unknown option: $1" >&2
455
- echo "Use --help for usage information" >&2
456
- exit 1
457
- ;;
458
- esac
459
- done
460
-
461
- ##############################################################################
462
- # Main Execution
463
- ##############################################################################
464
-
465
- # If no parameters provided, show usage
466
- if [[ $# -eq 0 && $VERBOSE -eq 0 ]]; then
467
- echo "No parameters provided for validation" >&2
468
- echo "Use --help for usage information" >&2
469
- exit 1
470
- fi
471
-
472
- log_info "Starting parameter validation..."
473
-
474
- # Validate required parameters
475
- validate_required_parameters
476
- required_errors=$?
477
-
478
- # Validate optional parameters
479
- validate_optional_parameters
480
- optional_errors=$?
481
-
482
- total_errors=$((required_errors + optional_errors))
483
-
484
- # Print summary
485
- print_validation_summary
486
-
487
- # Exit with appropriate code
488
- if [[ $total_errors -eq 0 ]]; then
489
- exit 0
490
- else
491
- exit 1
492
- fi