claude-flow-novice 2.14.27 โ†’ 2.14.29

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 (73) hide show
  1. package/.claude/commands/CFN_LOOP_TASK_MODE.md +119 -0
  2. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +22 -0
  3. package/.claude/skills/cfn-agent-spawning/spawn-agent.sh.backup +273 -0
  4. package/.claude/skills/cfn-hybrid-routing/README.md +1 -1
  5. package/.claude/skills/cfn-loop-orchestration/helpers/consensus.sh +10 -0
  6. package/.claude/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +10 -0
  7. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +105 -15
  8. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup +76 -11
  9. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup2 +959 -0
  10. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.clean +949 -0
  11. package/.claude/skills/cfn-product-owner-decision/execute-decision.sh +82 -10
  12. package/.claude/skills/cfn-redis-coordination/report-completion.sh +10 -0
  13. package/claude-assets/agents/cfn-dev-team/architecture/base-template-generator.md +7 -33
  14. package/claude-assets/agents/cfn-dev-team/architecture/planner.md +7 -47
  15. package/claude-assets/agents/cfn-dev-team/architecture/system-architect.md +7 -33
  16. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +88 -23
  17. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +59 -23
  18. package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +43 -39
  19. package/claude-assets/agents/cfn-dev-team/coordinators/epic-creator.md +69 -0
  20. package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +65 -1
  21. package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +7 -47
  22. package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +7 -26
  23. package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +7 -47
  24. package/claude-assets/agents/cfn-dev-team/product-owners/cto-agent.md +7 -19
  25. package/claude-assets/agents/cfn-dev-team/product-owners/power-user-persona.md +9 -49
  26. package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +407 -22
  27. package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +7 -66
  28. package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +7 -76
  29. package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +8 -2
  30. package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +7 -66
  31. package/claude-assets/agents/cfn-dev-team/reviewers/reviewer.md +7 -78
  32. package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +7 -18
  33. package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +7 -18
  34. package/claude-assets/agents/cfn-dev-team/testers/tester.md +7 -77
  35. package/claude-assets/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +7 -18
  36. package/claude-assets/agents/cfn-dev-team/testers/validation/validation-production-validator.md +7 -19
  37. package/claude-assets/agents/cfn-dev-team/testing/test-validation-agent.md +7 -44
  38. package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +35 -111
  39. package/claude-assets/agents/cfn-dev-team/utility/analyst.md +7 -47
  40. package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +7 -40
  41. package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +7 -47
  42. package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +119 -0
  43. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +22 -0
  44. package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh.backup +273 -0
  45. package/claude-assets/skills/cfn-environment-sanitization/SKILL.md +200 -0
  46. package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +244 -0
  47. package/claude-assets/skills/cfn-hybrid-routing/README.md +1 -1
  48. package/claude-assets/skills/cfn-loop-orchestration/helpers/consensus.sh +10 -0
  49. package/claude-assets/skills/cfn-loop-orchestration/helpers/spawn-agents.sh +10 -0
  50. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +105 -15
  51. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.backup +76 -11
  52. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.backup2 +959 -0
  53. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.clean +949 -0
  54. package/claude-assets/skills/cfn-node-heap-sizer/task-mode-heap-limiter.sh +326 -0
  55. package/claude-assets/skills/cfn-process-instrumentation/SKILL.md +279 -0
  56. package/claude-assets/skills/cfn-process-instrumentation/instrument-process.sh +323 -0
  57. package/claude-assets/skills/cfn-product-owner-decision/execute-decision.sh +82 -10
  58. package/claude-assets/skills/cfn-redis-coordination/report-completion.sh +10 -0
  59. package/claude-assets/skills/cfn-task-audit/get-audit-data.sh +376 -0
  60. package/claude-assets/skills/cfn-task-audit/store-task-audit.sh +184 -0
  61. package/claude-assets/skills/cfn-task-mode-safety/cli-coordination.sh +519 -0
  62. package/claude-assets/skills/cfn-task-mode-safety/mode-detection.sh +326 -0
  63. package/claude-assets/skills/cfn-task-mode-sanitize/task-mode-env-sanitizer.sh +224 -0
  64. package/claude-assets/skills/cfn-telemetry/collect-metrics.sh +249 -0
  65. package/claude-assets/skills/cfn-telemetry/start-telemetry.sh +111 -0
  66. package/claude-assets/skills/cfn-validation-runner-instrumentation/wrapped-executor.sh +327 -0
  67. package/dist/agents/agent-loader.js +467 -133
  68. package/dist/agents/agent-loader.js.map +1 -1
  69. package/dist/cli/config-manager.js.map +1 -1
  70. package/package.json +1 -1
  71. package/scripts/mode-detection.sh +321 -0
  72. package/scripts/spawn-worker.sh +8 -0
  73. package/scripts/track-zai-costs-simple.sh +8 -0
@@ -0,0 +1,519 @@
1
+ #!/bin/bash
2
+ # CFN CLI Mode Coordination - Safe Redis Operations for CLI Mode Only
3
+ # Part of ANTI-023 Memory Leak Protection System
4
+
5
+ set -euo pipefail
6
+
7
+ # Source mode detection
8
+ MODE_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
+ source "${MODE_SCRIPT_DIR}/mode-detection.sh"
10
+
11
+ # CLI Mode Redis Coordination Script
12
+
13
+ # Default Redis configuration
14
+ REDIS_HOST="${REDIS_HOST:-localhost}"
15
+ REDIS_PORT="${REDIS_PORT:-6379}"
16
+ REDIS_TIMEOUT="${REDIS_TIMEOUT:-30}"
17
+
18
+ # Safe Redis Connection Check
19
+ redis_check_connection() {
20
+ if ! redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" ping > /dev/null 2>&1; then
21
+ echo "โŒ Redis connection failed: $REDIS_HOST:$REDIS_PORT" >&2
22
+ return 1
23
+ fi
24
+ echo "โœ… Redis connection: $REDIS_HOST:$REDIS_PORT" >&2
25
+ return 0
26
+ }
27
+
28
+ # LPUSH wrapper with timeout and error handling
29
+ redis_lpush_safe() {
30
+ local key="$1"
31
+ local value="$2"
32
+ local timeout="${3:-$REDIS_TIMEOUT}"
33
+
34
+ if ! redis_check_connection; then
35
+ echo "โŒ Cannot LPUSH - Redis connection failed" >&2
36
+ return 1
37
+ fi
38
+
39
+ # Use timeout to prevent hanging
40
+ if timeout "$timeout" redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" LPUSH "$key" "$value" > /dev/null; then
41
+ echo "โœ… LPUSH successful: $key <- $value" >&2
42
+ return 0
43
+ else
44
+ echo "โŒ LPUSH failed: $key <- $value (timeout: $timeout)" >&2
45
+ return 1
46
+ fi
47
+ }
48
+
49
+ # BLPOP wrapper with timeout and error handling
50
+ redis_blpop_safe() {
51
+ local key="$1"
52
+ local timeout="${2:-$REDIS_TIMEOUT}"
53
+ local output_file="${3:-/tmp/blpop_output}"
54
+
55
+ if ! redis_check_connection; then
56
+ echo "โŒ Cannot BLPOP - Redis connection failed" >&2
57
+ return 1
58
+ fi
59
+
60
+ # Execute BLPOP with timeout and capture output
61
+ if timeout "$timeout" redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" BLPOP "$key" "$timeout" > "$output_file"; then
62
+ local result=$(cat "$output_file")
63
+ echo "โœ… BLPOP successful: $key" >&2
64
+ echo "$result"
65
+ return 0
66
+ else
67
+ echo "โŒ BLPOP failed: $key (timeout: $timeout)" >&2
68
+ return 1
69
+ fi
70
+ }
71
+
72
+ # HSET wrapper with error handling
73
+ redis_hset_safe() {
74
+ local key="$1"
75
+ shift
76
+ local data=("$@")
77
+
78
+ if ! redis_check_connection; then
79
+ echo "โŒ Cannot HSET - Redis connection failed" >&2
80
+ return 1
81
+ fi
82
+
83
+ # Build HSET command
84
+ local hset_cmd="redis-cli -h \"$REDIS_HOST\" -p \"$REDIS_PORT\" HSET \"$key\""
85
+ local first=true
86
+
87
+ for item in "${data[@]}"; do
88
+ if [[ "$first" == true ]]; then
89
+ first=false
90
+ else
91
+ hset_cmd+=" "
92
+ fi
93
+ hset_cmd+="\"$item\""
94
+ done
95
+
96
+ if eval "$hset_cmd" > /dev/null; then
97
+ echo "โœ… HSET successful: $key" >&2
98
+ return 0
99
+ else
100
+ echo "โŒ HSET failed: $key" >&2
101
+ return 1
102
+ fi
103
+ }
104
+
105
+ # GET wrapper with error handling
106
+ redis_get_safe() {
107
+ local key="$1"
108
+ local output_file="${2:-/tmp/redis_get_output}"
109
+
110
+ if ! redis_check_connection; then
111
+ echo "โŒ Cannot GET - Redis connection failed" >&2
112
+ return 1
113
+ fi
114
+
115
+ if redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" GET "$key" > "$output_file"; then
116
+ local result=$(cat "$output_file")
117
+ echo "โœ… GET successful: $key" >&2
118
+ echo "$result"
119
+ return 0
120
+ else
121
+ echo "โŒ GET failed: $key" >&2
122
+ return 1
123
+ fi
124
+ }
125
+
126
+ # EXPIRE wrapper with error handling
127
+ redis_expire_safe() {
128
+ local key="$1"
129
+ local seconds="$2"
130
+
131
+ if ! redis_check_connection; then
132
+ echo "โŒ Cannot EXPIRE - Redis connection failed" >&2
133
+ return 1
134
+ fi
135
+
136
+ if redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" EXPIRE "$key" "$seconds" > /dev/null; then
137
+ echo "โœ… EXPIRE successful: $key -> $seconds seconds" >&2
138
+ return 0
139
+ else
140
+ echo "โŒ EXPIRE failed: $key -> $seconds seconds" >&2
141
+ return 1
142
+ fi
143
+ }
144
+
145
+ # HEXPIRE wrapper (Redis 6.2+) with error handling
146
+ redis_hexpire_safe() {
147
+ local key="$1"
148
+ local seconds="$2"
149
+
150
+ if ! redis_check_connection; then
151
+ echo "โŒ Cannot HEXPIRE - Redis connection failed" >&2
152
+ return 1
153
+ fi
154
+
155
+ if redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" EXPIRE "$key" "$seconds" > /dev/null; then
156
+ echo "โœ… HEXPIRE successful: $key -> $seconds seconds" >&2
157
+ return 0
158
+ else
159
+ echo "โŒ HEXPIRE failed: $key -> $seconds seconds" >&2
160
+ return 1
161
+ fi
162
+ }
163
+
164
+ # DEL wrapper with error handling
165
+ redis_del_safe() {
166
+ local key="$1"
167
+
168
+ if ! redis_check_connection; then
169
+ echo "โŒ Cannot DEL - Redis connection failed" >&2
170
+ return 1
171
+ fi
172
+
173
+ if redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" DEL "$key" > /dev/null; then
174
+ echo "โœ… DEL successful: $key" >&2
175
+ return 0
176
+ else
177
+ echo "โŒ DEL failed: $key" >&2
178
+ return 1
179
+ fi
180
+ }
181
+
182
+ # Coordination Functions
183
+
184
+ # Signal agent completion
185
+ cfn_signal_agent_complete() {
186
+ local task_id="$1"
187
+ local agent_id="$2"
188
+
189
+ if ! is_cli_mode; then
190
+ echo "โŒ Agent completion signaling requires CLI mode" >&2
191
+ return 1
192
+ fi
193
+
194
+ local key="swarm:${task_id}:${agent_id}:done"
195
+ redis_lpush_safe "$key" "complete"
196
+ }
197
+
198
+ # Store agent confidence score
199
+ cfn_store_agent_confidence() {
200
+ local task_id="$1"
201
+ local agent_id="$2"
202
+ local confidence="$3"
203
+
204
+ if ! is_cli_mode; then
205
+ echo "โŒ Confidence storage requires CLI mode" >&2
206
+ return 1
207
+ fi
208
+
209
+ if ! awk -v conf="$confidence" 'BEGIN { if (conf < 0 || conf > 1) exit 1 }'; then
210
+ echo "โŒ Invalid confidence value: $confidence (must be 0.0-1.0)" >&2
211
+ return 1
212
+ fi
213
+
214
+ local key="swarm:${task_id}:${agent_id}:confidence"
215
+ redis_lpush_safe "$key" "$confidence"
216
+ redis_expire_safe "$key" 3600
217
+ }
218
+
219
+ # Store agent result
220
+ cfn_store_agent_result() {
221
+ local task_id="$1"
222
+ local agent_id="$2"
223
+ local confidence="$3"
224
+ local iteration="${4:-1}"
225
+
226
+ if ! is_cli_mode; then
227
+ echo "โŒ Result storage requires CLI mode" >&2
228
+ return 1
229
+ fi
230
+
231
+ if ! awk -v conf="$confidence" 'BEGIN { if (conf < 0 || conf > 1) exit 1 }'; then
232
+ echo "โŒ Invalid confidence value: $confidence (must be 0.0-1.0)" >&2
233
+ return 1
234
+ fi
235
+
236
+ local key="swarm:${task_id}:${agent_id}:result"
237
+ local timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)
238
+
239
+ redis_hset_safe "$key" \
240
+ "confidence" "$confidence" \
241
+ "iteration" "$iteration" \
242
+ "timestamp" "$timestamp" \
243
+ "agent_id" "$agent_id" \
244
+ "task_id" "$task_id"
245
+
246
+ redis_expire_safe "$key" 3600
247
+ }
248
+
249
+ # Wait for agent completion
250
+ cfn_wait_for_agent_completion() {
251
+ local task_id="$1"
252
+ local agent_id="$2"
253
+ local timeout="${3:-300}" # 5 minutes default
254
+
255
+ if ! is_cli_mode; then
256
+ echo "โŒ Agent completion waiting requires CLI mode" >&2
257
+ return 1
258
+ fi
259
+
260
+ local key="swarm:${task_id}:${agent_id}:done"
261
+ local output_file="/tmp/agent_completion_${task_id}_${agent_id}"
262
+
263
+ echo "โณ Waiting for agent $agent_id completion (timeout: ${timeout}s)..." >&2
264
+
265
+ if redis_blpop_safe "$key" "$timeout" "$output_file"; then
266
+ local result=$(cat "$output_file")
267
+ echo "โœ… Agent $agent_id completed: $result" >&2
268
+ return 0
269
+ else
270
+ echo "โŒ Agent $agent_id completion timeout" >&2
271
+ return 1
272
+ fi
273
+ }
274
+
275
+ # Collect confidence scores
276
+ cfn_collect_confidence_scores() {
277
+ local task_id="$1"
278
+ local agent_ids="$2"
279
+ local threshold="${3:-0.75}"
280
+ local min_quorum="${4:-1}"
281
+
282
+ if ! is_cli_mode; then
283
+ echo "โŒ Confidence score collection requires CLI mode" >&2
284
+ return 1
285
+ fi
286
+
287
+ local confidence_scores=()
288
+ local valid_scores=0
289
+ local total_scores=0
290
+
291
+ # Convert comma-separated agent IDs to array
292
+ IFS=',' read -ra AGENT_ARRAY <<< "$agent_ids"
293
+
294
+ for agent_id in "${AGENT_ARRAY[@]}"; do
295
+ agent_id=$(echo "$agent_id" | xargs) # Trim whitespace
296
+ local key="swarm:${task_id}:${agent_id}:confidence"
297
+
298
+ # Try to get confidence score
299
+ local confidence_output=$(redis_get_safe "$key" /tmp/confidence_${agent_id} 2>/dev/null || echo "null")
300
+
301
+ if [[ "$confidence_output" != "null" ]]; then
302
+ local confidence=$(echo "$confidence_output" | grep -o '[0-9]*\.[0-9]*' | head -1 || echo "0.0")
303
+ confidence_scores+=("$agent_id:$confidence")
304
+ valid_scores=$((valid_scores + 1))
305
+ else
306
+ confidence_scores+=("$agent_id:0.0")
307
+ fi
308
+
309
+ total_scores=$((total_scores + 1))
310
+ done
311
+
312
+ # Calculate average confidence
313
+ local total_confidence=0
314
+ local count=0
315
+
316
+ for score in "${confidence_scores[@]}"; do
317
+ local confidence=$(echo "$score" | cut -d':' -f2)
318
+ total_confidence=$(awk "BEGIN {print $total_confidence + $confidence}")
319
+ count=$((count + 1))
320
+ done
321
+
322
+ local average_confidence=0.0
323
+ if [[ $count -gt 0 ]]; then
324
+ average_confidence=$(awk "BEGIN {print $total_confidence / $count}")
325
+ fi
326
+
327
+ # Check gate criteria
328
+ local passes_gate=true
329
+ if (( valid_scores < min_quorum )); then
330
+ passes_gate=false
331
+ echo "โŒ Gate failed: Only $valid_scores scores found, need $min_quorum" >&2
332
+ elif (( $(awk "BEGIN {print ($average_confidence < $threshold)}") )); then
333
+ passes_gate=false
334
+ echo "โŒ Gate failed: Average confidence $average_confidence < $threshold" >&2
335
+ else
336
+ echo "โœ… Gate passed: Average confidence $average_confidence >= $threshold" >&2
337
+ fi
338
+
339
+ # Output results
340
+ local output="{"
341
+ output+='"average_confidence": '"$average_confidence"','
342
+ output+='"valid_scores": '"$valid_scores"','
343
+ output+='"total_scores": '"$total_scores"','
344
+ output+='"threshold": '"$threshold"','
345
+ output+='"passes_gate': $passes_gate','
346
+ output+='"agent_scores": ['
347
+ local first=true
348
+ for score in "${confidence_scores[@]}"; do
349
+ if [[ "$first" == true ]]; then
350
+ first=false
351
+ else
352
+ output+=","
353
+ fi
354
+ output+="$score"
355
+ done
356
+ output+="]}"
357
+
358
+ echo "$output"
359
+ }
360
+
361
+ # Cleanup old task data
362
+ cfn_cleanup_task_data() {
363
+ local task_id="$1"
364
+ local max_age="${2:-86400}" # 24 hours default
365
+
366
+ if ! is_cli_mode; then
367
+ echo "โŒ Task cleanup requires CLI mode" >&2
368
+ return 1
369
+ fi
370
+
371
+ echo "๐Ÿงน Cleaning up task data: $task_id (max age: ${max_age}s)" >&2
372
+
373
+ # Find and delete old task keys
374
+ local keys_to_delete=()
375
+ local key_patterns=(
376
+ "swarm:${task_id}:*"
377
+ "cfn_loop:${task_id}:*"
378
+ "task:${task_id}:*"
379
+ )
380
+
381
+ for pattern in "${key_patterns[@]}"; do
382
+ local keys=$(redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" KEYS "$pattern" 2>/dev/null || echo "")
383
+ if [[ -n "$keys" ]]; then
384
+ while read -r key; do
385
+ if [[ -n "$key" ]]; then
386
+ keys_to_delete+=("$key")
387
+ fi
388
+ done <<< "$keys"
389
+ fi
390
+ done
391
+
392
+ # Delete keys in batches
393
+ if [[ ${#keys_to_delete[@]} -gt 0 ]]; then
394
+ local batch_size=100
395
+ for ((i=0; i<${#keys_to_delete[@]}; i+=batch_size)); do
396
+ local batch=("${keys_to_delete[@]:$i:$batch_size}")
397
+ local batch_keys=$(printf '"%s" ' "${batch[@]}")
398
+ if redis-cli -h "$REDIS_HOST" -p "$REDIS_PORT" DEL $batch_keys > /dev/null; then
399
+ echo "โœ… Deleted batch: ${#batch[@]} keys" >&2
400
+ else
401
+ echo "โŒ Failed to delete batch: ${#batch[@]} keys" >&2
402
+ fi
403
+ done
404
+ fi
405
+
406
+ echo "โœ… Task cleanup completed for: $task_id" >&2
407
+ }
408
+
409
+ # Show Usage
410
+ show_usage() {
411
+ cat <<'EOF'
412
+ CFN CLI Mode Coordination - Safe Redis Operations
413
+
414
+ USAGE:
415
+ source "$(dirname "${BASH_SOURCE[0]}")/cli-coordination.sh"
416
+
417
+ # Configuration
418
+ export REDIS_HOST=localhost
419
+ export REDIS_PORT=6379
420
+ export REDIS_TIMEOUT=30
421
+
422
+ # Basic Operations
423
+ redis_check_connection # Check Redis connection
424
+ redis_lpush_safe <key> <value> [timeout] # Safe LPUSH with timeout
425
+ redis_blpop_safe <key> [timeout] [output] # Safe BLPOP with timeout
426
+ redis_hset_safe <key> <field> <value> ... # Safe HSET
427
+ redis_get_safe <key> [output] # Safe GET
428
+ redis_expire_safe <key> <seconds> # Safe EXPIRE
429
+ redis_del_safe <key> # Safe DEL
430
+
431
+ # Coordination Functions
432
+ cfn_signal_agent_complete <task_id> <agent_id>
433
+ cfn_store_agent_confidence <task_id> <agent_id> <confidence>
434
+ cfn_store_agent_result <task_id> <agent_id> <confidence> [iteration]
435
+ cfn_wait_for_agent_completion <task_id> <agent_id> [timeout]
436
+ cfn_collect_confidence_scores <task_id> <agent_ids> [threshold] [min_quorum]
437
+ cfn_cleanup_task_data <task_id> [max_age]
438
+
439
+ EXAMPLES:
440
+ # Signal agent completion
441
+ cfn_signal_agent_complete "task-123" "agent-001"
442
+
443
+ # Store confidence score
444
+ cfn_store_agent_confidence "task-123" "agent-001" 0.85
445
+
446
+ # Wait for agent completion
447
+ cfn_wait_for_agent_completion "task-123" "agent-001" 300
448
+
449
+ # Collect confidence scores
450
+ cfn_collect_confidence_scores "task-123" "agent-001,agent-002" 0.75 1
451
+
452
+ # Cleanup old task data
453
+ cfn_cleanup_task_data "task-123" 86400
454
+
455
+ EOF
456
+ }
457
+
458
+ # Main execution block
459
+ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
460
+ if [[ "$1" == "--help" || "$1" == "-h" ]]; then
461
+ show_usage
462
+ exit 0
463
+ fi
464
+
465
+ # Execute single operation if provided
466
+ if [[ $# -gt 0 ]]; then
467
+ case "$1" in
468
+ "check-connection")
469
+ redis_check_connection
470
+ ;;
471
+ "lpush")
472
+ redis_lpush_safe "$2" "$3" "${4:-$REDIS_TIMEOUT}"
473
+ ;;
474
+ "blpop")
475
+ redis_blpop_safe "$2" "${3:-$REDIS_TIMEOUT}" "${4:-/tmp/blpop_output}"
476
+ ;;
477
+ "hset")
478
+ shift
479
+ redis_hset_safe "$@"
480
+ ;;
481
+ "get")
482
+ redis_get_safe "$2" "${3:-/tmp/redis_get_output}"
483
+ ;;
484
+ "expire")
485
+ redis_expire_safe "$2" "$3"
486
+ ;;
487
+ "del")
488
+ redis_del_safe "$2"
489
+ ;;
490
+ "signal")
491
+ cfn_signal_agent_complete "$2" "$3"
492
+ ;;
493
+ "confidence")
494
+ cfn_store_agent_confidence "$2" "$3" "$4"
495
+ ;;
496
+ "wait")
497
+ cfn_wait_for_agent_completion "$2" "$3" "${4:-300}"
498
+ ;;
499
+ "collect")
500
+ cfn_collect_confidence_scores "$2" "$3" "${4:-0.75}" "${5:-1}"
501
+ ;;
502
+ "cleanup")
503
+ cfn_cleanup_task_data "$2" "${3:-86400}"
504
+ ;;
505
+ *)
506
+ echo "Unknown operation: $1" >&2
507
+ echo "Use --help for usage information" >&2
508
+ exit 1
509
+ ;;
510
+ esac
511
+ else
512
+ echo "CFN CLI Mode Coordination System" >&2
513
+ echo "Mode: $(detect_execution_mode)" >&2
514
+ echo "Task Mode: $(is_task_mode && echo "YES" || echo "NO")" >&2
515
+ echo "CLI Mode: $(is_cli_mode && echo "YES" || echo "NO")" >&2
516
+ echo "Redis: $REDIS_HOST:$REDIS_PORT" >&2
517
+ echo "Timeout: ${REDIS_TIMEOUT}s" >&2
518
+ fi
519
+ fi