claude-flow-novice 2.14.3 → 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 (162) 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/agents/agent-loader.js +165 -146
  6. package/dist/agents/agent-loader.js.map +1 -1
  7. package/dist/cli/agent-prompt-builder.js +25 -0
  8. package/dist/cli/agent-prompt-builder.js.map +1 -1
  9. package/dist/cli/config-manager.js +91 -109
  10. package/package.json +1 -1
  11. package/.claude/skills/cfn-redis-coordination/HEARTBEAT.md +0 -57
  12. package/.claude/skills/cfn-redis-coordination/HEARTBEAT_MONITORING.md +0 -267
  13. package/.claude/skills/cfn-redis-coordination/LOGGING.md +0 -260
  14. package/.claude/skills/cfn-redis-coordination/README.md +0 -65
  15. package/.claude/skills/cfn-redis-coordination/SECURITY_REVIEW.md +0 -25
  16. package/.claude/skills/cfn-redis-coordination/SHUTDOWN_HANDLING.md +0 -164
  17. package/.claude/skills/cfn-redis-coordination/SKILL.md +0 -720
  18. package/.claude/skills/cfn-redis-coordination/demos/test-dlq.sh +0 -129
  19. package/.claude/skills/cfn-redis-coordination/demos/test-iteration-feedback.sh +0 -320
  20. package/.claude/skills/cfn-redis-coordination/demos/test-orchestrator.sh +0 -249
  21. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake-phase4-unix.sh +0 -148
  22. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake-phase4.sh +0 -163
  23. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake.sh +0 -138
  24. package/.claude/skills/cfn-redis-coordination/demos/test-quick-fix.sh +0 -81
  25. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-absolute.sh +0 -45
  26. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-fallback.sh +0 -68
  27. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-percentage.sh +0 -56
  28. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-with-retry.sh +0 -81
  29. package/.claude/skills/cfn-redis-coordination/demos/test-quorum.sh +0 -57
  30. package/.claude/skills/cfn-redis-coordination/demos/test-shutdown-handling.sh +0 -187
  31. package/.claude/skills/cfn-redis-coordination/demos/test-shutdown.sh +0 -160
  32. package/.claude/skills/cfn-redis-coordination/demos/test-utils-unix.sh +0 -97
  33. package/.claude/skills/cfn-redis-coordination/demos/test-utils.sh +0 -97
  34. package/.claude/skills/cfn-redis-coordination/demos/test-waiting-mode.sh +0 -59
  35. package/.claude/skills/cfn-redis-coordination/examples/README.md +0 -73
  36. package/.claude/skills/cfn-redis-coordination/examples/grafana-dashboard.json +0 -352
  37. package/.claude/skills/cfn-redis-coordination/examples/hierarchical-pattern.sh +0 -127
  38. package/.claude/skills/cfn-redis-coordination/examples/mesh-pattern.sh +0 -171
  39. package/.claude/skills/cfn-redis-coordination/examples/timeout-handling.sh +0 -227
  40. package/.claude/skills/cfn-redis-coordination/examples/waiting-mode-pattern.sh +0 -239
  41. package/.claude/skills/cfn-redis-coordination/execute-product-owner-decision.sh +0 -258
  42. package/.claude/skills/cfn-redis-coordination/get-agent-timeout.sh +0 -177
  43. package/.claude/skills/cfn-redis-coordination/heartbeat-functions.sh +0 -137
  44. package/.claude/skills/cfn-redis-coordination/heartbeat-protocol.md +0 -106
  45. package/.claude/skills/cfn-redis-coordination/heartbeat.sh +0 -126
  46. package/.claude/skills/cfn-redis-coordination/init-swarm.sh +0 -148
  47. package/.claude/skills/cfn-redis-coordination/invoke-redis-pattern.sh +0 -220
  48. package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +0 -283
  49. package/.claude/skills/cfn-redis-coordination/list-active-swarms.sh +0 -147
  50. package/.claude/skills/cfn-redis-coordination/log-event.sh +0 -109
  51. package/.claude/skills/cfn-redis-coordination/metrics-export.sh +0 -674
  52. package/.claude/skills/cfn-redis-coordination/metrics-schema.json +0 -66
  53. package/.claude/skills/cfn-redis-coordination/metrics-storage.md +0 -31
  54. package/.claude/skills/cfn-redis-coordination/monitor-cfn-violations.sh +0 -391
  55. package/.claude/skills/cfn-redis-coordination/monitor-heartbeats.sh +0 -101
  56. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop-v3.sh +0 -141
  57. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh +0 -31
  58. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
  59. package/.claude/skills/cfn-redis-coordination/priority-wake-mechanism.md +0 -75
  60. package/.claude/skills/cfn-redis-coordination/priority_wake.py +0 -134
  61. package/.claude/skills/cfn-redis-coordination/query-dlq.sh +0 -162
  62. package/.claude/skills/cfn-redis-coordination/query-logs.sh +0 -103
  63. package/.claude/skills/cfn-redis-coordination/redis-pattern.sh +0 -619
  64. package/.claude/skills/cfn-redis-coordination/retrieve-context.sh +0 -58
  65. package/.claude/skills/cfn-redis-coordination/select-specialist-agent.sh +0 -371
  66. package/.claude/skills/cfn-redis-coordination/semantic-match-tfidf.py +0 -252
  67. package/.claude/skills/cfn-redis-coordination/send-heartbeat.sh +0 -165
  68. package/.claude/skills/cfn-redis-coordination/signal.sh +0 -38
  69. package/.claude/skills/cfn-redis-coordination/store-context.sh +0 -86
  70. package/.claude/skills/cfn-redis-coordination/store-epic-context.sh +0 -123
  71. package/.claude/skills/cfn-redis-coordination/test-context-injection.sh +0 -354
  72. package/.claude/skills/cfn-redis-coordination/test-timeout-enforcement.sh +0 -513
  73. package/.claude/skills/cfn-redis-coordination/tests/convert-line-endings.sh +0 -15
  74. package/.claude/skills/cfn-redis-coordination/tests/dlq-functionality-test.sh +0 -102
  75. package/.claude/skills/cfn-redis-coordination/tests/edge-cases-test.sh +0 -99
  76. package/.claude/skills/cfn-redis-coordination/tests/integration-test.sh +0 -170
  77. package/.claude/skills/cfn-redis-coordination/tests/retry-mechanism-test.sh +0 -82
  78. package/.claude/skills/cfn-redis-coordination/tests/run-test-suite.sh +0 -92
  79. package/.claude/skills/cfn-redis-coordination/tests/run-tests.sh +0 -4
  80. package/.claude/skills/cfn-redis-coordination/tests/test-heartbeat-monitoring.sh +0 -418
  81. package/.claude/skills/cfn-redis-coordination/tests/test-heartbeat-simple.sh +0 -124
  82. package/.claude/skills/cfn-redis-coordination/tests/test-primitives.sh +0 -166
  83. package/.claude/skills/cfn-redis-coordination/tests/test-utils.sh +0 -54
  84. package/.claude/skills/cfn-redis-coordination/tests/test_utils.sh +0 -49
  85. package/.claude/skills/cfn-redis-coordination/v2_modularization/core_orchestration.sh +0 -76
  86. package/.claude/skills/cfn-redis-coordination/validate-parameters.sh +0 -492
  87. package/claude-assets/skills/cfn-redis-coordination/HEARTBEAT.md +0 -57
  88. package/claude-assets/skills/cfn-redis-coordination/HEARTBEAT_MONITORING.md +0 -267
  89. package/claude-assets/skills/cfn-redis-coordination/LOGGING.md +0 -260
  90. package/claude-assets/skills/cfn-redis-coordination/README.md +0 -65
  91. package/claude-assets/skills/cfn-redis-coordination/SECURITY_REVIEW.md +0 -25
  92. package/claude-assets/skills/cfn-redis-coordination/SHUTDOWN_HANDLING.md +0 -164
  93. package/claude-assets/skills/cfn-redis-coordination/SKILL.md +0 -720
  94. package/claude-assets/skills/cfn-redis-coordination/demos/test-dlq.sh +0 -129
  95. package/claude-assets/skills/cfn-redis-coordination/demos/test-iteration-feedback.sh +0 -320
  96. package/claude-assets/skills/cfn-redis-coordination/demos/test-orchestrator.sh +0 -249
  97. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake-phase4-unix.sh +0 -148
  98. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake-phase4.sh +0 -163
  99. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake.sh +0 -138
  100. package/claude-assets/skills/cfn-redis-coordination/demos/test-quick-fix.sh +0 -81
  101. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-absolute.sh +0 -45
  102. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-fallback.sh +0 -68
  103. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-percentage.sh +0 -56
  104. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-with-retry.sh +0 -81
  105. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum.sh +0 -57
  106. package/claude-assets/skills/cfn-redis-coordination/demos/test-shutdown-handling.sh +0 -187
  107. package/claude-assets/skills/cfn-redis-coordination/demos/test-shutdown.sh +0 -160
  108. package/claude-assets/skills/cfn-redis-coordination/demos/test-utils-unix.sh +0 -97
  109. package/claude-assets/skills/cfn-redis-coordination/demos/test-utils.sh +0 -97
  110. package/claude-assets/skills/cfn-redis-coordination/demos/test-waiting-mode.sh +0 -59
  111. package/claude-assets/skills/cfn-redis-coordination/examples/README.md +0 -73
  112. package/claude-assets/skills/cfn-redis-coordination/examples/grafana-dashboard.json +0 -352
  113. package/claude-assets/skills/cfn-redis-coordination/examples/hierarchical-pattern.sh +0 -127
  114. package/claude-assets/skills/cfn-redis-coordination/examples/mesh-pattern.sh +0 -171
  115. package/claude-assets/skills/cfn-redis-coordination/examples/timeout-handling.sh +0 -227
  116. package/claude-assets/skills/cfn-redis-coordination/examples/waiting-mode-pattern.sh +0 -239
  117. package/claude-assets/skills/cfn-redis-coordination/execute-product-owner-decision.sh +0 -258
  118. package/claude-assets/skills/cfn-redis-coordination/get-agent-timeout.sh +0 -177
  119. package/claude-assets/skills/cfn-redis-coordination/heartbeat-functions.sh +0 -137
  120. package/claude-assets/skills/cfn-redis-coordination/heartbeat-protocol.md +0 -106
  121. package/claude-assets/skills/cfn-redis-coordination/heartbeat.sh +0 -126
  122. package/claude-assets/skills/cfn-redis-coordination/init-swarm.sh +0 -148
  123. package/claude-assets/skills/cfn-redis-coordination/invoke-redis-pattern.sh +0 -220
  124. package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +0 -283
  125. package/claude-assets/skills/cfn-redis-coordination/list-active-swarms.sh +0 -147
  126. package/claude-assets/skills/cfn-redis-coordination/log-event.sh +0 -109
  127. package/claude-assets/skills/cfn-redis-coordination/metrics-export.sh +0 -674
  128. package/claude-assets/skills/cfn-redis-coordination/metrics-schema.json +0 -66
  129. package/claude-assets/skills/cfn-redis-coordination/metrics-storage.md +0 -31
  130. package/claude-assets/skills/cfn-redis-coordination/monitor-cfn-violations.sh +0 -391
  131. package/claude-assets/skills/cfn-redis-coordination/monitor-heartbeats.sh +0 -101
  132. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop-v3.sh +0 -141
  133. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh +0 -31
  134. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
  135. package/claude-assets/skills/cfn-redis-coordination/priority-wake-mechanism.md +0 -75
  136. package/claude-assets/skills/cfn-redis-coordination/priority_wake.py +0 -134
  137. package/claude-assets/skills/cfn-redis-coordination/query-dlq.sh +0 -162
  138. package/claude-assets/skills/cfn-redis-coordination/query-logs.sh +0 -103
  139. package/claude-assets/skills/cfn-redis-coordination/redis-pattern.sh +0 -619
  140. package/claude-assets/skills/cfn-redis-coordination/retrieve-context.sh +0 -58
  141. package/claude-assets/skills/cfn-redis-coordination/select-specialist-agent.sh +0 -371
  142. package/claude-assets/skills/cfn-redis-coordination/semantic-match-tfidf.py +0 -252
  143. package/claude-assets/skills/cfn-redis-coordination/send-heartbeat.sh +0 -165
  144. package/claude-assets/skills/cfn-redis-coordination/signal.sh +0 -38
  145. package/claude-assets/skills/cfn-redis-coordination/store-context.sh +0 -86
  146. package/claude-assets/skills/cfn-redis-coordination/store-epic-context.sh +0 -123
  147. package/claude-assets/skills/cfn-redis-coordination/test-context-injection.sh +0 -354
  148. package/claude-assets/skills/cfn-redis-coordination/test-timeout-enforcement.sh +0 -513
  149. package/claude-assets/skills/cfn-redis-coordination/tests/convert-line-endings.sh +0 -15
  150. package/claude-assets/skills/cfn-redis-coordination/tests/dlq-functionality-test.sh +0 -102
  151. package/claude-assets/skills/cfn-redis-coordination/tests/edge-cases-test.sh +0 -99
  152. package/claude-assets/skills/cfn-redis-coordination/tests/integration-test.sh +0 -170
  153. package/claude-assets/skills/cfn-redis-coordination/tests/retry-mechanism-test.sh +0 -82
  154. package/claude-assets/skills/cfn-redis-coordination/tests/run-test-suite.sh +0 -92
  155. package/claude-assets/skills/cfn-redis-coordination/tests/run-tests.sh +0 -4
  156. package/claude-assets/skills/cfn-redis-coordination/tests/test-heartbeat-monitoring.sh +0 -418
  157. package/claude-assets/skills/cfn-redis-coordination/tests/test-heartbeat-simple.sh +0 -124
  158. package/claude-assets/skills/cfn-redis-coordination/tests/test-primitives.sh +0 -166
  159. package/claude-assets/skills/cfn-redis-coordination/tests/test-utils.sh +0 -54
  160. package/claude-assets/skills/cfn-redis-coordination/tests/test_utils.sh +0 -49
  161. package/claude-assets/skills/cfn-redis-coordination/v2_modularization/core_orchestration.sh +0 -76
  162. package/claude-assets/skills/cfn-redis-coordination/validate-parameters.sh +0 -492
@@ -1,276 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- ##############################################################################
4
- # Test Cancel Swarm - Validates graceful shutdown functionality
5
- #
6
- # Tests:
7
- # 1. Cancel active swarm (success path)
8
- # 2. Cancel with custom reason and initiator
9
- # 3. Cancel non-existent swarm (error handling)
10
- # 4. Verify shutdown signals delivered to all agents
11
- # 5. Verify swarm metadata updated correctly
12
- # 6. Test force flag (skip confirmation)
13
- ##############################################################################
14
-
15
- # Disable strict error handling for tests
16
- set -uo pipefail
17
-
18
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
19
- TEST_TASK_ID="test-cancel-$(date +%s)"
20
- FAILED_TESTS=0
21
- PASSED_TESTS=0
22
-
23
- # Colors for output
24
- RED='\033[0;31m'
25
- GREEN='\033[0;32m'
26
- YELLOW='\033[1;33m'
27
- NC='\033[0m' # No Color
28
-
29
- log_test() {
30
- echo ""
31
- echo "========================================="
32
- echo "TEST: $1"
33
- echo "========================================="
34
- }
35
-
36
- log_pass() {
37
- echo -e "${GREEN}✓ PASS:${NC} $1"
38
- ((PASSED_TESTS++))
39
- }
40
-
41
- log_fail() {
42
- echo -e "${RED}✗ FAIL:${NC} $1"
43
- ((FAILED_TESTS++))
44
- }
45
-
46
- log_info() {
47
- echo -e "${YELLOW}ℹ INFO:${NC} $1"
48
- }
49
-
50
- cleanup() {
51
- log_info "Cleaning up test data..."
52
-
53
- # Delete test keys matching patterns
54
- KEYS=$(redis-cli --scan --pattern "swarm:${TEST_TASK_ID}*" 2>/dev/null || true)
55
- if [ -n "$KEYS" ]; then
56
- echo "$KEYS" | while read -r KEY; do
57
- redis-cli del "$KEY" > /dev/null 2>&1 || true
58
- done
59
- fi
60
-
61
- KEYS=$(redis-cli --scan --pattern "swarm:test-cancel-*" 2>/dev/null || true)
62
- if [ -n "$KEYS" ]; then
63
- echo "$KEYS" | while read -r KEY; do
64
- redis-cli del "$KEY" > /dev/null 2>&1 || true
65
- done
66
- fi
67
- }
68
-
69
- # Cleanup on exit
70
- trap cleanup EXIT
71
-
72
- echo "========================================="
73
- echo "Cancel Swarm Test Suite"
74
- echo "========================================="
75
- echo "Test Task ID: $TEST_TASK_ID"
76
- echo ""
77
-
78
- # =============================================================================
79
- # Test 1: Cancel active swarm (success path)
80
- # =============================================================================
81
- log_test "Cancel Active Swarm"
82
-
83
- # Initialize test swarm
84
- SWARM_ID="${TEST_TASK_ID}-swarm1"
85
- AGENTS="coder-1,reviewer-1,tester-1"
86
-
87
- "$SCRIPT_DIR/init-swarm.sh" \
88
- --swarm-id "$SWARM_ID" \
89
- --task-id "$TEST_TASK_ID" \
90
- --agents "$AGENTS" > /dev/null
91
-
92
- log_info "Swarm initialized: $SWARM_ID"
93
-
94
- # Cancel swarm with force flag (skip confirmation)
95
- OUTPUT=$("$SCRIPT_DIR/cancel-swarm.sh" \
96
- --task-id "$TEST_TASK_ID" \
97
- --force 2>&1 || true)
98
-
99
- # Verify status updated
100
- STATUS=$(redis-cli hget "swarm:${SWARM_ID}:metadata" status)
101
- if [ "$STATUS" = "cancelled" ]; then
102
- log_pass "Swarm status updated to 'cancelled'"
103
- else
104
- log_fail "Expected status 'cancelled', got: $STATUS"
105
- fi
106
-
107
- # Verify agents_notified count
108
- NOTIFIED=$(redis-cli hget "swarm:${SWARM_ID}:metadata" agents_notified)
109
- if [ "$NOTIFIED" = "3" ]; then
110
- log_pass "All 3 agents notified"
111
- else
112
- log_fail "Expected 3 agents notified, got: $NOTIFIED"
113
- fi
114
-
115
- # Verify shutdown signal broadcasted
116
- SHUTDOWN_KEY="swarm:${TEST_TASK_ID}:shutdown"
117
- SHUTDOWN_MSG=$(redis-cli --raw lindex "$SHUTDOWN_KEY" 0 2>/dev/null || echo "{}")
118
-
119
- if [ -n "$SHUTDOWN_MSG" ] && [ "$SHUTDOWN_MSG" != "(nil)" ]; then
120
- log_pass "Shutdown signal broadcasted to $SHUTDOWN_KEY"
121
-
122
- # Verify message content
123
- REASON=$(echo "$SHUTDOWN_MSG" | jq -r '.reason // empty')
124
- INITIATOR=$(echo "$SHUTDOWN_MSG" | jq -r '.initiator // empty')
125
-
126
- if [ "$REASON" = "user_requested_cancellation" ]; then
127
- log_pass "Shutdown signal has correct reason"
128
- else
129
- log_fail "Expected reason 'user_requested_cancellation', got: $REASON"
130
- fi
131
-
132
- if [ "$INITIATOR" = "main-chat" ]; then
133
- log_pass "Shutdown signal has correct initiator"
134
- else
135
- log_fail "Expected initiator 'main-chat', got: $INITIATOR"
136
- fi
137
- else
138
- log_fail "No shutdown signal found"
139
- fi
140
-
141
- # =============================================================================
142
- # Test 2: Cancel with custom reason and initiator
143
- # =============================================================================
144
- log_test "Cancel with Custom Reason and Initiator"
145
-
146
- SWARM_ID2="${TEST_TASK_ID}-swarm2"
147
- "$SCRIPT_DIR/init-swarm.sh" \
148
- --swarm-id "$SWARM_ID2" \
149
- --task-id "${TEST_TASK_ID}-custom" \
150
- --agents "backend-dev-1" > /dev/null
151
-
152
- OUTPUT=$("$SCRIPT_DIR/cancel-swarm.sh" \
153
- --task-id "${TEST_TASK_ID}-custom" \
154
- --reason "integration_test_timeout" \
155
- --initiator "test-runner" \
156
- --force 2>&1 || true)
157
-
158
- CANCEL_REASON=$(redis-cli hget "swarm:${SWARM_ID2}:metadata" cancellation_reason)
159
- CANCEL_INIT=$(redis-cli hget "swarm:${SWARM_ID2}:metadata" cancellation_initiator)
160
-
161
- if [ "$CANCEL_REASON" = "integration_test_timeout" ]; then
162
- log_pass "Custom cancellation reason recorded"
163
- else
164
- log_fail "Expected reason 'integration_test_timeout', got: $CANCEL_REASON"
165
- fi
166
-
167
- if [ "$CANCEL_INIT" = "test-runner" ]; then
168
- log_pass "Custom initiator recorded"
169
- else
170
- log_fail "Expected initiator 'test-runner', got: $CANCEL_INIT"
171
- fi
172
-
173
- # =============================================================================
174
- # Test 3: Cancel non-existent swarm (error handling)
175
- # =============================================================================
176
- log_test "Cancel Non-Existent Swarm (Error Handling)"
177
-
178
- OUTPUT=$("$SCRIPT_DIR/cancel-swarm.sh" \
179
- --task-id "non-existent-task-id-12345" \
180
- --force 2>&1 || true)
181
-
182
- if echo "$OUTPUT" | grep -q "No swarm found"; then
183
- log_pass "Error message displayed for non-existent swarm"
184
- else
185
- log_fail "Expected error message, got: $OUTPUT"
186
- fi
187
-
188
- # =============================================================================
189
- # Test 4: Verify shutdown message format
190
- # =============================================================================
191
- log_test "Verify Shutdown Message Format"
192
-
193
- SWARM_ID3="${TEST_TASK_ID}-swarm3"
194
- "$SCRIPT_DIR/init-swarm.sh" \
195
- --swarm-id "$SWARM_ID3" \
196
- --task-id "${TEST_TASK_ID}-format" \
197
- --agents "security-1" > /dev/null
198
-
199
- "$SCRIPT_DIR/cancel-swarm.sh" \
200
- --task-id "${TEST_TASK_ID}-format" \
201
- --reason "test_message_format" \
202
- --initiator "validator" \
203
- --force > /dev/null 2>&1
204
-
205
- SHUTDOWN_KEY="swarm:${TEST_TASK_ID}-format:shutdown"
206
- MSG=$(redis-cli --raw lindex "$SHUTDOWN_KEY" 0 2>/dev/null || echo "{}")
207
-
208
- # Validate JSON structure
209
- REASON=$(echo "$MSG" | jq -r '.reason // empty')
210
- TIMESTAMP=$(echo "$MSG" | jq -r '.timestamp // empty')
211
- INITIATOR=$(echo "$MSG" | jq -r '.initiator // empty')
212
-
213
- if [ "$REASON" = "test_message_format" ] && \
214
- [ -n "$TIMESTAMP" ] && \
215
- [ "$INITIATOR" = "validator" ]; then
216
- log_pass "Shutdown message has correct format"
217
- else
218
- log_fail "Shutdown message format incorrect: $MSG"
219
- fi
220
-
221
- # =============================================================================
222
- # Test 5: Verify cancelled_at timestamp
223
- # =============================================================================
224
- log_test "Verify Cancelled Timestamp"
225
-
226
- CANCELLED_AT=$(redis-cli hget "swarm:${SWARM_ID3}:metadata" cancelled_at)
227
-
228
- if [[ "$CANCELLED_AT" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$ ]]; then
229
- log_pass "Cancelled timestamp in ISO 8601 format: $CANCELLED_AT"
230
- else
231
- log_fail "Invalid timestamp format: $CANCELLED_AT"
232
- fi
233
-
234
- # =============================================================================
235
- # Test 6: Empty agent list handling
236
- # =============================================================================
237
- log_test "Handle Swarm with Empty Agent List"
238
-
239
- SWARM_ID4="${TEST_TASK_ID}-swarm4"
240
- redis-cli hset "swarm:${SWARM_ID4}:metadata" \
241
- swarm_id "$SWARM_ID4" \
242
- task_id "${TEST_TASK_ID}-empty" \
243
- agents "" \
244
- status "in_progress" > /dev/null
245
-
246
- OUTPUT=$("$SCRIPT_DIR/cancel-swarm.sh" \
247
- --task-id "${TEST_TASK_ID}-empty" \
248
- --force 2>&1 || true)
249
-
250
- STATUS=$(redis-cli hget "swarm:${SWARM_ID4}:metadata" status)
251
- NOTIFIED=$(redis-cli hget "swarm:${SWARM_ID4}:metadata" agents_notified)
252
-
253
- if [ "$STATUS" = "cancelled" ] && [ "$NOTIFIED" = "0" ]; then
254
- log_pass "Empty agent list handled correctly"
255
- else
256
- log_fail "Empty agent list handling failed (status: $STATUS, notified: $NOTIFIED)"
257
- fi
258
-
259
- # =============================================================================
260
- # Summary
261
- # =============================================================================
262
- echo ""
263
- echo "========================================="
264
- echo "Test Summary"
265
- echo "========================================="
266
- echo -e "${GREEN}Passed:${NC} $PASSED_TESTS"
267
- echo -e "${RED}Failed:${NC} $FAILED_TESTS"
268
- echo "========================================="
269
-
270
- if [ $FAILED_TESTS -eq 0 ]; then
271
- echo -e "${GREEN}✓ All tests passed!${NC}"
272
- exit 0
273
- else
274
- echo -e "${RED}✗ Some tests failed${NC}"
275
- exit 1
276
- fi
@@ -1,12 +1,145 @@
1
+ "use strict";
1
2
  /**
2
3
  * Dynamic Agent Loader - Reads agent definitions from .claude/agents/ directory
3
4
  * Single source of truth for agent types in the system
4
- */ import { readFileSync, existsSync } from 'node:fs';
5
- import { glob } from 'glob';
6
- import { resolve, dirname } from 'node:path';
7
- import { parse as parseYaml } from 'yaml';
5
+ */ var __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
6
+ function adopt(value) {
7
+ return value instanceof P ? value : new P(function(resolve) {
8
+ resolve(value);
9
+ });
10
+ }
11
+ return new (P || (P = Promise))(function(resolve, reject) {
12
+ function fulfilled(value) {
13
+ try {
14
+ step(generator.next(value));
15
+ } catch (e) {
16
+ reject(e);
17
+ }
18
+ }
19
+ function rejected(value) {
20
+ try {
21
+ step(generator["throw"](value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ }
26
+ function step(result) {
27
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
28
+ }
29
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
30
+ });
31
+ };
32
+ var __generator = this && this.__generator || function(thisArg, body) {
33
+ var _ = {
34
+ label: 0,
35
+ sent: function() {
36
+ if (t[0] & 1) throw t[1];
37
+ return t[1];
38
+ },
39
+ trys: [],
40
+ ops: []
41
+ }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
42
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
43
+ return this;
44
+ }), g;
45
+ function verb(n) {
46
+ return function(v) {
47
+ return step([
48
+ n,
49
+ v
50
+ ]);
51
+ };
52
+ }
53
+ function step(op) {
54
+ if (f) throw new TypeError("Generator is already executing.");
55
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
56
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
57
+ if (y = 0, t) op = [
58
+ op[0] & 2,
59
+ t.value
60
+ ];
61
+ switch(op[0]){
62
+ case 0:
63
+ case 1:
64
+ t = op;
65
+ break;
66
+ case 4:
67
+ _.label++;
68
+ return {
69
+ value: op[1],
70
+ done: false
71
+ };
72
+ case 5:
73
+ _.label++;
74
+ y = op[1];
75
+ op = [
76
+ 0
77
+ ];
78
+ continue;
79
+ case 7:
80
+ op = _.ops.pop();
81
+ _.trys.pop();
82
+ continue;
83
+ default:
84
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
85
+ _ = 0;
86
+ continue;
87
+ }
88
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
89
+ _.label = op[1];
90
+ break;
91
+ }
92
+ if (op[0] === 6 && _.label < t[1]) {
93
+ _.label = t[1];
94
+ t = op;
95
+ break;
96
+ }
97
+ if (t && _.label < t[2]) {
98
+ _.label = t[2];
99
+ _.ops.push(op);
100
+ break;
101
+ }
102
+ if (t[2]) _.ops.pop();
103
+ _.trys.pop();
104
+ continue;
105
+ }
106
+ op = body.call(thisArg, _);
107
+ } catch (e) {
108
+ op = [
109
+ 6,
110
+ e
111
+ ];
112
+ y = 0;
113
+ } finally{
114
+ f = t = 0;
115
+ }
116
+ if (op[0] & 5) throw op[1];
117
+ return {
118
+ value: op[0] ? op[1] : void 0,
119
+ done: true
120
+ };
121
+ }
122
+ };
123
+ var __spreadArray = this && this.__spreadArray || function(to, from, pack) {
124
+ if (pack || arguments.length === 2) for(var i = 0, l = from.length, ar; i < l; i++){
125
+ if (ar || !(i in from)) {
126
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
127
+ ar[i] = from[i];
128
+ }
129
+ }
130
+ return to.concat(ar || Array.prototype.slice.call(from));
131
+ };
132
+ Object.defineProperty(exports, "__esModule", {
133
+ value: true
134
+ });
135
+ exports.refreshAgents = exports.getAgentsByCategory = exports.isValidAgentType = exports.searchAgents = exports.getAgentCategories = exports.getAllAgents = exports.getAgent = exports.getAvailableAgentTypes = exports.agentLoader = exports.AgentLoader = void 0;
136
+ exports.resolveLegacyAgentType = resolveLegacyAgentType;
137
+ var node_fs_1 = require("node:fs");
138
+ var glob_1 = require("glob");
139
+ var node_path_1 = require("node:path");
140
+ var yaml_1 = require("yaml");
8
141
  // Legacy agent type mapping for backward compatibility
9
- const LEGACY_AGENT_MAPPING = {
142
+ var LEGACY_AGENT_MAPPING = {
10
143
  analyst: 'code-analyzer',
11
144
  coordinator: 'hierarchical-coordinator',
12
145
  optimizer: 'perf-analyzer',
@@ -17,38 +150,40 @@ const LEGACY_AGENT_MAPPING = {
17
150
  };
18
151
  /**
19
152
  * Resolve legacy agent types to current equivalents
20
- */ export function resolveLegacyAgentType(legacyType) {
153
+ */ function resolveLegacyAgentType(legacyType) {
21
154
  return LEGACY_AGENT_MAPPING[legacyType] || legacyType;
22
155
  }
23
- export class AgentLoader {
24
- agentCache = new Map();
25
- categoriesCache = [];
26
- lastLoadTime = 0;
27
- CACHE_EXPIRY = 60_000;
28
- getAgentsDirectory() {
29
- let currentDir = process.cwd();
156
+ var AgentLoader = /** @class */ function() {
157
+ function AgentLoader() {
158
+ this.agentCache = new Map();
159
+ this.categoriesCache = [];
160
+ this.lastLoadTime = 0;
161
+ this.CACHE_EXPIRY = 60000; // 1 minute cache
162
+ }
163
+ AgentLoader.prototype.getAgentsDirectory = function() {
164
+ var currentDir = process.cwd();
30
165
  while(currentDir !== '/'){
31
- const claudeAgentsPath = resolve(currentDir, '.claude', 'agents');
32
- if (existsSync(claudeAgentsPath)) {
166
+ var claudeAgentsPath = (0, node_path_1.resolve)(currentDir, '.claude', 'agents');
167
+ if ((0, node_fs_1.existsSync)(claudeAgentsPath)) {
33
168
  return claudeAgentsPath;
34
169
  }
35
- currentDir = dirname(currentDir);
170
+ currentDir = (0, node_path_1.dirname)(currentDir);
36
171
  }
37
- return resolve(process.cwd(), '.claude', 'agents');
38
- }
39
- parseAgentFile(filePath) {
172
+ return (0, node_path_1.resolve)(process.cwd(), '.claude', 'agents');
173
+ };
174
+ AgentLoader.prototype.parseAgentFile = function(filePath) {
40
175
  try {
41
- const content = readFileSync(filePath, 'utf-8');
42
- const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
176
+ var content = (0, node_fs_1.readFileSync)(filePath, 'utf-8');
177
+ var frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
43
178
  if (!frontmatterMatch) {
44
- console.warn(`No frontmatter found in ${filePath}`);
179
+ console.warn("No frontmatter found in ".concat(filePath));
45
180
  return null;
46
181
  }
47
- const [, yamlContent, markdownContent] = frontmatterMatch;
48
- const frontmatter = parseYaml(yamlContent);
49
- const description = frontmatter.description;
182
+ var yamlContent = frontmatterMatch[1], markdownContent = frontmatterMatch[2];
183
+ var frontmatter = (0, yaml_1.parse)(yamlContent);
184
+ var description = frontmatter.description;
50
185
  if (!frontmatter.name || !description) {
51
- console.warn(`Missing required fields (name, description) in ${filePath}`);
186
+ console.warn("Missing required fields (name, description) in ".concat(filePath));
52
187
  return null;
53
188
  }
54
189
  return {
@@ -69,129 +204,13 @@ export class AgentLoader {
69
204
  content: markdownContent.trim()
70
205
  };
71
206
  } catch (error) {
72
- console.error(`Error parsing agent file ${filePath}:`, error);
207
+ console.error("Error parsing agent file ".concat(filePath, ":"), error);
73
208
  return null;
74
209
  }
75
- }
76
- parseTools(frontmatter) {
77
- const extractTools = (input)=>{
210
+ };
211
+ AgentLoader.prototype.parseTools = function(frontmatter) {
212
+ var extractTools = function(input) {
78
213
  if (Array.isArray(input)) return input.map(String);
79
- if (typeof input === 'string') {
80
- return input.split(/[,\s]+/).map((t)=>t.trim()).filter((t)=>t.length > 0);
81
- }
82
- return [];
83
- };
84
- // Safely handle tools and capabilities.tools
85
- const toolsFromFrontmatter = frontmatter.tools ? extractTools(frontmatter.tools) : [];
86
- const toolsFromCapabilities = frontmatter.capabilities && typeof frontmatter.capabilities === 'object' ? extractTools(Object(frontmatter.capabilities).tools) : [];
87
- return [
88
- ...toolsFromFrontmatter,
89
- ...toolsFromCapabilities
90
- ];
91
- }
92
- async loadAgents() {
93
- const agentsDir = this.getAgentsDirectory();
94
- if (!existsSync(agentsDir)) {
95
- console.warn(`Agents directory not found: ${agentsDir}`);
96
- return;
97
- }
98
- const agentFiles = await new Promise((resolve, reject)=>{
99
- glob('**/*.md', {
100
- cwd: agentsDir,
101
- ignore: [
102
- '**/README.md',
103
- '**/MIGRATION_SUMMARY.md'
104
- ],
105
- absolute: true
106
- }, (err, matches)=>{
107
- if (err) reject(err);
108
- else resolve(matches);
109
- });
110
- });
111
- this.agentCache.clear();
112
- this.categoriesCache = [];
113
- const categoryMap = new Map();
114
- for (const filePath of agentFiles){
115
- const agent = this.parseAgentFile(filePath);
116
- if (agent) {
117
- this.agentCache.set(agent.name, agent);
118
- const relativePath = filePath.replace(agentsDir, '');
119
- const pathParts = relativePath.split('/');
120
- const category = pathParts[1] || 'uncategorized';
121
- if (!categoryMap.has(category)) {
122
- categoryMap.set(category, []);
123
- }
124
- categoryMap.get(category).push(agent);
125
- }
126
- }
127
- this.categoriesCache = Array.from(categoryMap.entries()).map(([name, agents])=>({
128
- name,
129
- agents: agents.sort((a, b)=>a.name.localeCompare(b.name))
130
- }));
131
- this.lastLoadTime = Date.now();
132
- }
133
- // Rest of the methods remain similar to the original implementation
134
- needsRefresh() {
135
- return Date.now() - this.lastLoadTime > this.CACHE_EXPIRY;
136
- }
137
- async ensureLoaded() {
138
- if (this.agentCache.size === 0 || this.needsRefresh()) {
139
- await this.loadAgents();
140
- }
141
- }
142
- async getAvailableAgentTypes() {
143
- await this.ensureLoaded();
144
- const currentTypes = Array.from(this.agentCache.keys());
145
- const legacyTypes = Object.keys(LEGACY_AGENT_MAPPING);
146
- return Array.from(new Set([
147
- ...currentTypes,
148
- ...legacyTypes
149
- ])).sort();
150
- }
151
- async getAgent(name) {
152
- await this.ensureLoaded();
153
- return this.agentCache.get(name) || this.agentCache.get(resolveLegacyAgentType(name)) || null;
154
- }
155
- async getAllAgents() {
156
- await this.ensureLoaded();
157
- return Array.from(this.agentCache.values()).sort((a, b)=>a.name.localeCompare(b.name));
158
- }
159
- async getAgentCategories() {
160
- await this.ensureLoaded();
161
- return this.categoriesCache;
162
- }
163
- async searchAgents(query) {
164
- await this.ensureLoaded();
165
- const lowerQuery = query.toLowerCase();
166
- return Array.from(this.agentCache.values()).filter((agent)=>agent.name.toLowerCase().includes(lowerQuery) || agent.description.toLowerCase().includes(lowerQuery) || agent.capabilities?.some((cap)=>cap.toLowerCase().includes(lowerQuery)));
167
- }
168
- async isValidAgentType(name) {
169
- await this.ensureLoaded();
170
- return this.agentCache.has(name) || this.agentCache.has(resolveLegacyAgentType(name));
171
- }
172
- async getAgentsByCategory(category) {
173
- const categories = await this.getAgentCategories();
174
- const found = categories.find((cat)=>cat.name === category);
175
- return found?.agents || [];
176
- }
177
- async refresh() {
178
- this.lastLoadTime = 0;
179
- await this.loadAgents();
180
- }
181
- }
182
- // Singleton instance
183
- export const agentLoader = new AgentLoader();
184
- // Convenience exports for use in other modules
185
- export const getAvailableAgentTypes = ()=>agentLoader.getAvailableAgentTypes();
186
- export const getAgent = (name)=>agentLoader.getAgent(name);
187
- export const getAllAgents = ()=>agentLoader.getAllAgents();
188
- export const getAgentCategories = ()=>agentLoader.getAgentCategories();
189
- export const searchAgents = (query)=>agentLoader.searchAgents(query);
190
- export const isValidAgentType = (name)=>agentLoader.isValidAgentType(name);
191
- export const getAgentsByCategory = (category)=>agentLoader.getAgentsByCategory(category);
192
- export const refreshAgents = ()=>agentLoader.refresh();
193
-
194
- //# sourceMappingURL=agent-loader.js.map.isArray(input)) return input.map(String);
195
214
  if (typeof input === 'string') {
196
215
  return input.split(/[,\s]+/).map(function(t) {
197
216
  return t.trim();