claude-flow-novice 2.14.28 โ 2.14.30
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.
- package/.claude/cfn-agents-ignore/cfn-seo-team/AGENT_CREATION_REPORT.md +4 -14
- package/.claude/cfn-agents-ignore/cfn-seo-team/AGENT_CREATION_REPORT.md.backup +481 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/DELEGATION_MATRIX.md +3 -4
- package/.claude/cfn-agents-ignore/cfn-seo-team/DELEGATION_MATRIX.md.backup +371 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/INTEGRATION_REQUIREMENTS.md +20 -26
- package/.claude/cfn-agents-ignore/cfn-seo-team/INTEGRATION_REQUIREMENTS.md.backup +637 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/cfn-seo-coordinator.md +295 -50
- package/.claude/cfn-agents-ignore/cfn-seo-team/cfn-seo-coordinator.md.backup +398 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/competitive-seo-analyst.md +27 -25
- package/.claude/cfn-agents-ignore/cfn-seo-team/competitive-seo-analyst.md.backup +401 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/content-atomization-specialist.md +5 -106
- package/.claude/cfn-agents-ignore/cfn-seo-team/content-atomization-specialist.md.backup +552 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/content-seo-strategist.md +5 -25
- package/.claude/cfn-agents-ignore/cfn-seo-team/content-seo-strategist.md.backup +223 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/eeat-content-auditor.md +5 -27
- package/.claude/cfn-agents-ignore/cfn-seo-team/eeat-content-auditor.md.backup +367 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/geo-optimization-expert.md +5 -27
- package/.claude/cfn-agents-ignore/cfn-seo-team/geo-optimization-expert.md.backup +247 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/link-building-specialist.md +5 -27
- package/.claude/cfn-agents-ignore/cfn-seo-team/link-building-specialist.md.backup +269 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/local-seo-optimizer.md +5 -25
- package/.claude/cfn-agents-ignore/cfn-seo-team/local-seo-optimizer.md.backup +311 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/programmatic-seo-engineer.md +6 -26
- package/.claude/cfn-agents-ignore/cfn-seo-team/programmatic-seo-engineer.md.backup +222 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/schema-markup-engineer.md +5 -25
- package/.claude/cfn-agents-ignore/cfn-seo-team/schema-markup-engineer.md.backup +408 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/seo-analytics-specialist.md +6 -26
- package/.claude/cfn-agents-ignore/cfn-seo-team/seo-analytics-specialist.md.backup +354 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/seo-validators/accessibility-validator.md +4 -4
- package/.claude/cfn-agents-ignore/cfn-seo-team/seo-validators/accessibility-validator.md.backup +561 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/seo-validators/audience-validator.md +2 -2
- package/.claude/cfn-agents-ignore/cfn-seo-team/seo-validators/audience-validator.md.backup +480 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/seo-validators/branding-validator.md +1 -1
- package/.claude/cfn-agents-ignore/cfn-seo-team/seo-validators/branding-validator.md.backup +448 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/seo-validators/humanizer-validator.md +2 -2
- package/.claude/cfn-agents-ignore/cfn-seo-team/seo-validators/humanizer-validator.md.backup +329 -0
- package/.claude/cfn-agents-ignore/cfn-seo-team/technical-seo-specialist.md +361 -199
- package/.claude/cfn-agents-ignore/cfn-seo-team/technical-seo-specialist.md.backup +208 -0
- package/.claude/commands/CFN_LOOP_TASK_MODE.md +100 -11
- package/.claude/commands/cfn-mode.md +2 -2
- package/.claude/skills/cfn-agent-spawning/spawn-agent.sh +12 -0
- package/.claude/skills/cfn-agent-spawning/spawn-agent.sh.backup +273 -0
- package/.claude/skills/cfn-hybrid-routing/README.md +1 -1
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +95 -15
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup +76 -11
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup2 +959 -0
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.clean +949 -0
- package/.claude/skills/cfn-product-owner-decision/execute-decision.sh +82 -10
- package/claude-assets/agents/cfn-dev-team/CLAUDE.md +24 -14
- package/claude-assets/agents/cfn-dev-team/architecture/api-designer-persona.md +0 -7
- package/claude-assets/agents/cfn-dev-team/architecture/base-template-generator.md +12 -38
- package/claude-assets/agents/cfn-dev-team/architecture/goal-planner.md +0 -10
- package/claude-assets/agents/cfn-dev-team/architecture/planner.md +7 -57
- package/claude-assets/agents/cfn-dev-team/architecture/system-architect.md +8 -45
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-frontend-coordinator.md +365 -25
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +504 -448
- package/claude-assets/agents/cfn-dev-team/coordinators/consensus-builder.md +428 -167
- package/claude-assets/agents/cfn-dev-team/coordinators/multi-sprint-coordinator.md +472 -20
- package/claude-assets/agents/cfn-dev-team/dev-ops/devops-engineer.md +5 -5
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +5 -7
- package/claude-assets/agents/cfn-dev-team/dev-ops/kubernetes-specialist.md +0 -6
- package/claude-assets/agents/cfn-dev-team/dev-ops/monitoring-specialist.md +3 -3
- package/claude-assets/agents/cfn-dev-team/developers/api-gateway-specialist.md +13 -14
- package/claude-assets/agents/cfn-dev-team/developers/data/data-engineer.md +0 -6
- package/claude-assets/agents/cfn-dev-team/developers/database/database-architect.md +2 -2
- package/claude-assets/agents/cfn-dev-team/developers/frontend/mobile-dev.md +10 -56
- package/claude-assets/agents/cfn-dev-team/developers/frontend/typescript-specialist.md +7 -26
- package/claude-assets/agents/cfn-dev-team/developers/rust-developer.md +8 -48
- package/claude-assets/agents/cfn-dev-team/documentation/api-documentation.md +1 -1
- package/claude-assets/agents/cfn-dev-team/documentation/pseudocode.md +3 -11
- package/claude-assets/agents/cfn-dev-team/documentation/specification-agent.md +6 -16
- package/claude-assets/agents/cfn-dev-team/product-owners/cto-agent.md +7 -19
- package/claude-assets/agents/cfn-dev-team/product-owners/power-user-persona.md +9 -49
- package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +291 -86
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/code-quality-validator.md +9 -81
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/cyclomatic-complexity-reducer.md +4 -64
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/perf-analyzer.md +7 -87
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/performance-benchmarker.md +8 -12
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/security-specialist.md +11 -129
- package/claude-assets/agents/cfn-dev-team/reviewers/reviewer.md +231 -280
- package/claude-assets/agents/cfn-dev-team/testers/api-testing-specialist.md +0 -6
- package/claude-assets/agents/cfn-dev-team/testers/chaos-engineering-specialist.md +0 -6
- package/claude-assets/agents/cfn-dev-team/testers/e2e/playwright-tester.md +7 -32
- package/claude-assets/agents/cfn-dev-team/testers/interaction-tester.md +9 -47
- package/claude-assets/agents/cfn-dev-team/testers/load-testing-specialist.md +0 -6
- package/claude-assets/agents/cfn-dev-team/testers/playwright-tester.md +12 -28
- package/claude-assets/agents/cfn-dev-team/testers/tester.md +167 -236
- package/claude-assets/agents/cfn-dev-team/testers/unit/tdd-london-unit-swarm.md +7 -27
- package/claude-assets/agents/cfn-dev-team/testers/validation/validation-production-validator.md +7 -19
- package/claude-assets/agents/cfn-dev-team/testing/test-validation-agent.md +10 -47
- package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +40 -116
- package/claude-assets/agents/cfn-dev-team/utility/analyst.md +7 -47
- package/claude-assets/agents/cfn-dev-team/utility/code-booster.md +7 -40
- package/claude-assets/agents/cfn-dev-team/utility/context-curator.md +7 -47
- package/claude-assets/agents/cfn-dev-team/{coordinators โ utility}/epic-creator.md +29 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/AGENT_CREATION_REPORT.md +4 -14
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/AGENT_CREATION_REPORT.md.backup +481 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/DELEGATION_MATRIX.md +3 -4
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/DELEGATION_MATRIX.md.backup +371 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/INTEGRATION_REQUIREMENTS.md +20 -26
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/INTEGRATION_REQUIREMENTS.md.backup +637 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/cfn-seo-coordinator.md +295 -50
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/cfn-seo-coordinator.md.backup +398 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/competitive-seo-analyst.md +27 -25
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/competitive-seo-analyst.md.backup +401 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/content-atomization-specialist.md +5 -106
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/content-atomization-specialist.md.backup +552 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/content-seo-strategist.md +5 -25
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/content-seo-strategist.md.backup +223 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/eeat-content-auditor.md +5 -27
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/eeat-content-auditor.md.backup +367 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/geo-optimization-expert.md +5 -27
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/geo-optimization-expert.md.backup +247 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/link-building-specialist.md +5 -27
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/link-building-specialist.md.backup +269 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/local-seo-optimizer.md +5 -25
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/local-seo-optimizer.md.backup +311 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/programmatic-seo-engineer.md +6 -26
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/programmatic-seo-engineer.md.backup +222 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/schema-markup-engineer.md +5 -25
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/schema-markup-engineer.md.backup +408 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-analytics-specialist.md +6 -26
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-analytics-specialist.md.backup +354 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/accessibility-validator.md +4 -4
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/accessibility-validator.md.backup +561 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/audience-validator.md +2 -2
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/audience-validator.md.backup +480 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/branding-validator.md +1 -1
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/branding-validator.md.backup +448 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/humanizer-validator.md +2 -2
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/seo-validators/humanizer-validator.md.backup +329 -0
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/technical-seo-specialist.md +361 -199
- package/claude-assets/cfn-agents-ignore/cfn-seo-team/technical-seo-specialist.md.backup +208 -0
- package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +100 -11
- package/claude-assets/commands/cfn-mode.md +2 -2
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh +12 -0
- package/claude-assets/skills/cfn-agent-spawning/spawn-agent.sh.backup +273 -0
- package/claude-assets/skills/cfn-environment-sanitization/SKILL.md +200 -0
- package/claude-assets/skills/cfn-environment-sanitization/sanitize-environment.sh +244 -0
- package/claude-assets/skills/cfn-hybrid-routing/README.md +1 -1
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +95 -15
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.backup +76 -11
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.backup2 +959 -0
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.clean +949 -0
- package/claude-assets/skills/cfn-node-heap-sizer/task-mode-heap-limiter.sh +326 -0
- package/claude-assets/skills/cfn-process-instrumentation/SKILL.md +279 -0
- package/claude-assets/skills/cfn-process-instrumentation/instrument-process.sh +323 -0
- package/claude-assets/skills/cfn-product-owner-decision/execute-decision.sh +82 -10
- package/claude-assets/skills/cfn-task-audit/get-audit-data.sh +376 -0
- package/claude-assets/skills/cfn-task-audit/store-task-audit.sh +184 -0
- package/claude-assets/skills/cfn-task-mode-safety/cli-coordination.sh +519 -0
- package/claude-assets/skills/cfn-task-mode-safety/mode-detection.sh +326 -0
- package/claude-assets/skills/cfn-task-mode-sanitize/task-mode-env-sanitizer.sh +224 -0
- package/claude-assets/skills/cfn-telemetry/collect-metrics.sh +249 -0
- package/claude-assets/skills/cfn-telemetry/start-telemetry.sh +111 -0
- package/claude-assets/skills/cfn-validation-runner-instrumentation/wrapped-executor.sh +327 -0
- package/dist/agents/agent-loader.js +146 -165
- package/dist/agents/agent-loader.js.map +1 -1
- package/dist/cli/config-manager.js +109 -91
- package/dist/cli/config-manager.js.map +1 -1
- package/package.json +1 -1
- package/scripts/mode-detection.sh +321 -0
- package/scripts/spawn-worker.sh +8 -0
- 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
|