claude-flow-novice 2.15.2 → 2.15.3
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/hooks/cfn-BACKUP_USAGE.md +243 -243
- package/.claude/hooks/cfn-invoke-security-validation.sh +69 -69
- package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
- package/.claude/hooks/cfn-post-edit.config.json +44 -44
- package/.claude/skills/agent-lifecycle/SKILL.md +60 -0
- package/.claude/skills/agent-lifecycle/execute-lifecycle-hook.sh +573 -0
- package/.claude/skills/agent-lifecycle/simple-audit.sh +31 -0
- package/.claude/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
- package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
- package/.claude/skills/cfn-redis-coordination/get-context.sh +112 -112
- package/.claude/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
- package/.claude/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
- package/.claude/skills/cfn-transparency-middleware/test-integration.sh +161 -161
- package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
- package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
- package/.claude/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
- package/claude-assets/hooks/cfn-BACKUP_USAGE.md +243 -243
- package/claude-assets/hooks/cfn-invoke-security-validation.sh +69 -69
- package/claude-assets/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
- package/claude-assets/hooks/cfn-post-edit.config.json +44 -44
- package/claude-assets/hooks/cfn-post-execution/memory-cleanup.sh +19 -19
- package/claude-assets/hooks/cfn-pre-execution/memory-check.sh +19 -19
- package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +572 -572
- package/claude-assets/skills/agent-lifecycle/simple-audit.sh +30 -30
- package/claude-assets/skills/cfn-automatic-memory-persistence/persist-agent-output.sh +48 -48
- package/claude-assets/skills/cfn-automatic-memory-persistence/query-agent-history.sh +34 -34
- package/claude-assets/skills/cfn-deliverable-validation/confidence-calculator.sh +261 -261
- package/claude-assets/skills/cfn-expert-update/update-expert.sh +345 -345
- package/claude-assets/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
- package/claude-assets/skills/cfn-intervention-detector/detect-intervention.sh +110 -110
- package/claude-assets/skills/cfn-intervention-orchestrator/execute-intervention.sh +58 -58
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
- package/claude-assets/skills/cfn-loop2-output-processing/process-validator-output.sh +275 -275
- package/claude-assets/skills/cfn-memory-management/check-memory.sh +159 -159
- package/claude-assets/skills/cfn-memory-management/cleanup-memory.sh +196 -196
- package/claude-assets/skills/cfn-node-heap-sizer/task-mode-heap-limiter.sh +325 -325
- package/claude-assets/skills/cfn-playbook-auto-update/auto-update-playbook.sh +85 -85
- package/claude-assets/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
- package/claude-assets/skills/cfn-redis-coordination/get-context.sh +112 -112
- package/claude-assets/skills/cfn-scope-simplifier/simplify-scope.sh +67 -67
- package/claude-assets/skills/cfn-specialist-injection/recommend-specialist.sh +56 -56
- package/claude-assets/skills/cfn-standardized-error-handling/capture-agent-error.sh +86 -86
- package/claude-assets/skills/cfn-standardized-error-handling/test-error-handling.sh +165 -165
- package/claude-assets/skills/cfn-task-config-init/initialize-config.sh +264 -264
- package/claude-assets/skills/cfn-task-decomposition/task-decomposer.sh +278 -278
- package/claude-assets/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
- package/claude-assets/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
- package/claude-assets/skills/cfn-transparency-middleware/test-integration.sh +161 -161
- package/claude-assets/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
- package/claude-assets/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
- package/claude-assets/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
- package/claude-assets/skills/docker-build/SKILL.md +96 -203
- package/claude-assets/skills/docker-build/build.sh +73 -73
- package/claude-assets/skills/integration/agent-handoff.sh +494 -0
- package/claude-assets/skills/integration/file-operations.sh +414 -0
- package/claude-assets/skills/workflow-codification/APPROVAL_WORKFLOW.md +806 -0
- package/claude-assets/skills/workflow-codification/COST_TRACKING.md +637 -0
- package/claude-assets/skills/workflow-codification/EDGE_CASE_TRACKING.md +404 -0
- package/claude-assets/skills/workflow-codification/README_PHASE4.md +457 -0
- package/claude-assets/skills/workflow-codification/SKILL.md +110 -0
- package/claude-assets/skills/workflow-codification/analyze-patterns.sh +899 -0
- package/claude-assets/skills/workflow-codification/approval-workflow.sh +514 -0
- package/claude-assets/skills/workflow-codification/generate-skill-update.sh +525 -0
- package/claude-assets/skills/workflow-codification/review-skill.sh +643 -0
- package/claude-assets/skills/workflow-codification/templates/email-notification.txt +114 -0
- package/claude-assets/skills/workflow-codification/templates/slack-notification.md +85 -0
- package/claude-assets/skills/workflow-codification/test-integration.sh +281 -0
- package/claude-assets/skills/workflow-codification/track-cost-savings.sh +445 -0
- package/claude-assets/skills/workflow-codification/track-edge-case.sh +323 -0
- package/dist/cli/config-manager.js +91 -109
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/integration/DatabaseHandoff.js +507 -0
- package/dist/integration/DatabaseHandoff.js.map +1 -0
- package/dist/integration/StandardAdapter.js +291 -0
- package/dist/integration/StandardAdapter.js.map +1 -0
- package/dist/lib/agent-output-parser.js +518 -0
- package/dist/lib/agent-output-parser.js.map +1 -0
- package/dist/lib/agent-output-validator.js +950 -0
- package/dist/lib/agent-output-validator.js.map +1 -0
- package/dist/lib/artifact-registry.js +443 -0
- package/dist/lib/artifact-registry.js.map +1 -0
- package/dist/lib/config-validator.js +687 -0
- package/dist/lib/config-validator.js.map +1 -0
- package/dist/types/agent-output.js +44 -0
- package/dist/types/agent-output.js.map +1 -0
- package/dist/types/config.js +28 -0
- package/dist/types/config.js.map +1 -0
- package/package.json +2 -1
- package/scripts/artifact-cleanup.sh +392 -0
- package/scripts/deploy-production.sh +355 -355
- package/scripts/docker-playwright-fix.sh +311 -311
- package/scripts/docker-rebuild-all-agents.sh +127 -127
- package/scripts/memory-leak-prevention.sh +305 -305
- package/scripts/migrate-artifacts.sh +563 -0
- package/scripts/migrate-yaml-to-json.sh +465 -0
- package/scripts/run-marketing-tests.sh +42 -42
- package/scripts/update_paths.sh +46 -46
|
@@ -1,356 +1,356 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Production CFN Loop Deployment Script
|
|
4
|
-
# Deploys the complete production stack with validation
|
|
5
|
-
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
# Configuration
|
|
9
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
-
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
11
|
-
TIMESTAMP=$(date +%s)
|
|
12
|
-
LOG_FILE="$PROJECT_ROOT/logs/production-deploy-$TIMESTAMP.log"
|
|
13
|
-
|
|
14
|
-
# Colors for output
|
|
15
|
-
RED='\033[0;31m'
|
|
16
|
-
GREEN='\033[0;32m'
|
|
17
|
-
YELLOW='\033[1;33m'
|
|
18
|
-
BLUE='\033[0;34m'
|
|
19
|
-
NC='\033[0m' # No Color
|
|
20
|
-
|
|
21
|
-
# Environment variables
|
|
22
|
-
export BUILD_DATE="${BUILD_DATE:-$(date -u +'%Y-%m-%dT%H:%M:%SZ')}"
|
|
23
|
-
export VCS_REF="${VCS_REF:-$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')}"
|
|
24
|
-
export VERSION="${VERSION:-4.0.0}"
|
|
25
|
-
export CLAUDE_FLOW_VERSION="${CLAUDE_FLOW_VERSION:-4.0.0}"
|
|
26
|
-
export LOG_LEVEL="${LOG_LEVEL:-info}"
|
|
27
|
-
export MAX_AGENTS="${MAX_AGENTS:-10}"
|
|
28
|
-
export AGENT_TIMEOUT="${AGENT_TIMEOUT:-300000}"
|
|
29
|
-
export MEMORY_LIMIT="${MEMORY_LIMIT:-1g}"
|
|
30
|
-
export CPU_LIMIT="${CPU_LIMIT:-0.5}"
|
|
31
|
-
export AGENT_REPLICAS="${AGENT_REPLICAS:-3}"
|
|
32
|
-
export WORKER_POOL_SIZE="${WORKER_POOL_SIZE:-5}"
|
|
33
|
-
export GRAFANA_USER="${GRAFANA_USER:-admin}"
|
|
34
|
-
export GRAFANA_PASSWORD="${GRAFANA_PASSWORD:-admin123}"
|
|
35
|
-
|
|
36
|
-
# Logging function
|
|
37
|
-
log() {
|
|
38
|
-
echo -e "${BLUE}[$(date '+%Y-%m-%d %H:%M:%S')]${NC} $1" | tee -a "$LOG_FILE"
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
error() {
|
|
42
|
-
echo -e "${RED}[ERROR]${NC} $1" >&2 | tee -a "$LOG_FILE"
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
success() {
|
|
46
|
-
echo -e "${GREEN}[SUCCESS]${NC} $1" | tee -a "$LOG_FILE"
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
warning() {
|
|
50
|
-
echo -e "${YELLOW}[WARNING]${NC} $1" | tee -a "$LOG_FILE"
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
# Cleanup function
|
|
54
|
-
cleanup() {
|
|
55
|
-
log "Cleaning up on exit..."
|
|
56
|
-
# Add any cleanup tasks here
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
# Set up signal handlers
|
|
60
|
-
trap cleanup EXIT INT TERM
|
|
61
|
-
|
|
62
|
-
# Main deployment function
|
|
63
|
-
main() {
|
|
64
|
-
log "🚀 Starting Production CFN Loop Deployment"
|
|
65
|
-
log "📋 Deployment ID: $TIMESTAMP"
|
|
66
|
-
log "📁 Project root: $PROJECT_ROOT"
|
|
67
|
-
log "📄 Log file: $LOG_FILE"
|
|
68
|
-
|
|
69
|
-
# Change to project directory
|
|
70
|
-
cd "$PROJECT_ROOT"
|
|
71
|
-
|
|
72
|
-
# Phase 1: Pre-deployment checks
|
|
73
|
-
log "🔍 Running pre-deployment checks..."
|
|
74
|
-
run_pre_deployment_checks
|
|
75
|
-
|
|
76
|
-
# Phase 2: Build production images
|
|
77
|
-
log "🏗️ Building production Docker images..."
|
|
78
|
-
build_production_images
|
|
79
|
-
|
|
80
|
-
# Phase 3: Deploy infrastructure
|
|
81
|
-
log "🐳 Deploying production infrastructure..."
|
|
82
|
-
deploy_infrastructure
|
|
83
|
-
|
|
84
|
-
# Phase 4: Wait for services to be healthy
|
|
85
|
-
log "⏳ Waiting for services to be healthy..."
|
|
86
|
-
wait_for_healthy_services
|
|
87
|
-
|
|
88
|
-
# Phase 5: Run validation tests
|
|
89
|
-
log "🧪 Running deployment validation..."
|
|
90
|
-
run_validation_tests
|
|
91
|
-
|
|
92
|
-
# Phase 6: Display deployment summary
|
|
93
|
-
display_deployment_summary
|
|
94
|
-
|
|
95
|
-
success "🎉 Production deployment completed successfully!"
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
# Pre-deployment checks
|
|
99
|
-
run_pre_deployment_checks() {
|
|
100
|
-
log " Checking prerequisites..."
|
|
101
|
-
|
|
102
|
-
# Check Docker
|
|
103
|
-
if ! command -v docker &> /dev/null; then
|
|
104
|
-
error "Docker is not installed or not in PATH"
|
|
105
|
-
exit 1
|
|
106
|
-
fi
|
|
107
|
-
log " ✅ Docker available: $(docker --version)"
|
|
108
|
-
|
|
109
|
-
# Check Docker Compose
|
|
110
|
-
if ! command -v docker-compose &> /dev/null; then
|
|
111
|
-
error "Docker Compose is not installed or not in PATH"
|
|
112
|
-
exit 1
|
|
113
|
-
fi
|
|
114
|
-
log " ✅ Docker Compose available: $(docker-compose --version)"
|
|
115
|
-
|
|
116
|
-
# Check Node.js (for local tests)
|
|
117
|
-
if command -v node &> /dev/null; then
|
|
118
|
-
log " ✅ Node.js available: $(node --version)"
|
|
119
|
-
else
|
|
120
|
-
warning "Node.js not available - some tests may be skipped"
|
|
121
|
-
fi
|
|
122
|
-
|
|
123
|
-
# Check available disk space
|
|
124
|
-
local available_space
|
|
125
|
-
available_space=$(df -BG . | awk 'NR==2 {print $4}' | sed 's/G//')
|
|
126
|
-
if [[ $available_space -lt 5 ]]; then
|
|
127
|
-
warning "Low disk space: ${available_space}GB available (recommended: 5GB+)"
|
|
128
|
-
else
|
|
129
|
-
log " ✅ Disk space: ${available_space}GB available"
|
|
130
|
-
fi
|
|
131
|
-
|
|
132
|
-
# Check available memory
|
|
133
|
-
if command -v free &> /dev/null; then
|
|
134
|
-
local available_memory
|
|
135
|
-
available_memory=$(free -g | awk 'NR==2{print $7}')
|
|
136
|
-
if [[ $available_memory -lt 4 ]]; then
|
|
137
|
-
warning "Low memory: ${available_memory}GB available (recommended: 4GB+)"
|
|
138
|
-
else
|
|
139
|
-
log " ✅ Memory: ${available_memory}GB available"
|
|
140
|
-
fi
|
|
141
|
-
fi
|
|
142
|
-
|
|
143
|
-
# Create necessary directories
|
|
144
|
-
log " Creating directories..."
|
|
145
|
-
mkdir -p logs workspaces monitoring/grafana/{provisioning/{datasources,dashboards},dashboards} nginx
|
|
146
|
-
|
|
147
|
-
log " ✅ Pre-deployment checks completed"
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
# Build production images
|
|
151
|
-
build_production_images() {
|
|
152
|
-
log " Building production Docker image..."
|
|
153
|
-
|
|
154
|
-
# Build the production image
|
|
155
|
-
if docker build -f Dockerfile.production -t claude-flow-novice:production .; then
|
|
156
|
-
success " ✅ Production image built successfully"
|
|
157
|
-
else
|
|
158
|
-
error " ❌ Failed to build production image"
|
|
159
|
-
exit 1
|
|
160
|
-
fi
|
|
161
|
-
|
|
162
|
-
# Tag the image
|
|
163
|
-
docker tag claude-flow-novice:production claude-flow-novice:${VERSION}
|
|
164
|
-
log " ✅ Image tagged as claude-flow-novice:${VERSION}"
|
|
165
|
-
|
|
166
|
-
# Show image information
|
|
167
|
-
local image_size
|
|
168
|
-
image_size=$(docker images claude-flow-novice:production --format "{{.Size}}")
|
|
169
|
-
log " 📊 Image size: $image_size"
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
# Deploy infrastructure
|
|
173
|
-
deploy_infrastructure() {
|
|
174
|
-
log " Deploying production stack..."
|
|
175
|
-
|
|
176
|
-
# Create environment file
|
|
177
|
-
cat > .env.production << EOF
|
|
178
|
-
# Production CFN Loop Environment Configuration
|
|
179
|
-
BUILD_DATE=$BUILD_DATE
|
|
180
|
-
VCS_REF=$VCS_REF
|
|
181
|
-
VERSION=$VERSION
|
|
182
|
-
CLAUDE_FLOW_VERSION=$CLAUDE_FLOW_VERSION
|
|
183
|
-
LOG_LEVEL=$LOG_LEVEL
|
|
184
|
-
MAX_AGENTS=$MAX_AGENTS
|
|
185
|
-
AGENT_TIMEOUT=$AGENT_TIMEOUT
|
|
186
|
-
MEMORY_LIMIT=$MEMORY_LIMIT
|
|
187
|
-
CPU_LIMIT=$CPU_LIMIT
|
|
188
|
-
AGENT_REPLICAS=$AGENT_REPLICAS
|
|
189
|
-
WORKER_POOL_SIZE=$WORKER_POOL_SIZE
|
|
190
|
-
GRAFANA_USER=$GRAFANA_USER
|
|
191
|
-
GRAFANA_PASSWORD=$GRAFANA_PASSWORD
|
|
192
|
-
EOF
|
|
193
|
-
|
|
194
|
-
# Deploy the stack
|
|
195
|
-
if docker-compose -f docker-compose.production.yml --env-file .env.production up -d; then
|
|
196
|
-
success " ✅ Production stack deployed"
|
|
197
|
-
else
|
|
198
|
-
error " ❌ Failed to deploy production stack"
|
|
199
|
-
exit 1
|
|
200
|
-
fi
|
|
201
|
-
|
|
202
|
-
# Show deployed services
|
|
203
|
-
log " 📊 Deployed services:"
|
|
204
|
-
docker-compose -f docker-compose.production.yml ps
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
# Wait for services to be healthy
|
|
208
|
-
wait_for_healthy_services() {
|
|
209
|
-
log " Waiting for services to become healthy..."
|
|
210
|
-
local max_wait=300 # 5 minutes
|
|
211
|
-
local wait_interval=10
|
|
212
|
-
local waited=0
|
|
213
|
-
|
|
214
|
-
while [[ $waited -lt $max_wait ]]; do
|
|
215
|
-
local healthy_count=0
|
|
216
|
-
local total_count=0
|
|
217
|
-
|
|
218
|
-
# Check service health
|
|
219
|
-
while IFS= read -r line; do
|
|
220
|
-
if [[ $line == *"cfn-"* ]]; then
|
|
221
|
-
((total_count++))
|
|
222
|
-
if [[ $line == *"healthy"* ]] || [[ $line == *"Up"* ]]; then
|
|
223
|
-
((healthy_count++))
|
|
224
|
-
fi
|
|
225
|
-
fi
|
|
226
|
-
done < <(docker-compose -f docker-compose.production.yml ps --format "table {{.Name}}\t{{.Status}}" | tail -n +2)
|
|
227
|
-
|
|
228
|
-
log " Progress: $healthy_count/$total_count services healthy (${waited}s elapsed)"
|
|
229
|
-
|
|
230
|
-
if [[ $healthy_count -eq $total_count ]] && [[ $total_count -gt 0 ]]; then
|
|
231
|
-
success " ✅ All $total_count services are healthy"
|
|
232
|
-
return 0
|
|
233
|
-
fi
|
|
234
|
-
|
|
235
|
-
sleep $wait_interval
|
|
236
|
-
((waited += wait_interval))
|
|
237
|
-
done
|
|
238
|
-
|
|
239
|
-
warning " ⚠️ Some services may still be starting up"
|
|
240
|
-
log " 📊 Current status:"
|
|
241
|
-
docker-compose -f docker-compose.production.yml ps
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
# Run validation tests
|
|
245
|
-
run_validation_tests() {
|
|
246
|
-
log " Running deployment validation tests..."
|
|
247
|
-
|
|
248
|
-
# Test basic connectivity
|
|
249
|
-
log " Testing Redis connectivity..."
|
|
250
|
-
if docker exec cfn-redis-coordinator redis-cli ping | grep -q "PONG"; then
|
|
251
|
-
success " ✅ Redis connectivity verified"
|
|
252
|
-
else
|
|
253
|
-
error " ❌ Redis connectivity failed"
|
|
254
|
-
fi
|
|
255
|
-
|
|
256
|
-
# Test orchestrator
|
|
257
|
-
log " Testing orchestrator..."
|
|
258
|
-
if docker exec cfn-orchestrator node -e "console.log('Orchestrator ready')" &>/dev/null; then
|
|
259
|
-
success " ✅ Orchestrator responsive"
|
|
260
|
-
else
|
|
261
|
-
warning " ⚠️ Orchestrator may still be initializing"
|
|
262
|
-
fi
|
|
263
|
-
|
|
264
|
-
# Test monitoring endpoints
|
|
265
|
-
log " Testing monitoring endpoints..."
|
|
266
|
-
local prometheus_ok=false
|
|
267
|
-
local grafana_ok=false
|
|
268
|
-
|
|
269
|
-
if curl -s http://localhost:9090/-/healthy &>/dev/null; then
|
|
270
|
-
prometheus_ok=true
|
|
271
|
-
success " ✅ Prometheus endpoint accessible"
|
|
272
|
-
else
|
|
273
|
-
warning " ⚠️ Prometheus endpoint not accessible"
|
|
274
|
-
fi
|
|
275
|
-
|
|
276
|
-
if curl -s http://localhost:3001/api/health &>/dev/null; then
|
|
277
|
-
grafana_ok=true
|
|
278
|
-
success " ✅ Grafana endpoint accessible"
|
|
279
|
-
else
|
|
280
|
-
warning " ⚠️ Grafana endpoint not accessible"
|
|
281
|
-
fi
|
|
282
|
-
|
|
283
|
-
# Run comprehensive test if Node.js is available
|
|
284
|
-
if command -v node &> /dev/null; then
|
|
285
|
-
log " Running comprehensive production test..."
|
|
286
|
-
if node tests/docker/production-deployment-test.js &>/dev/null; then
|
|
287
|
-
success " ✅ Comprehensive test passed"
|
|
288
|
-
else
|
|
289
|
-
warning " ⚠️ Comprehensive test encountered issues"
|
|
290
|
-
fi
|
|
291
|
-
else
|
|
292
|
-
log " ⏭️ Skipping comprehensive test (Node.js not available)"
|
|
293
|
-
fi
|
|
294
|
-
|
|
295
|
-
# Store test results
|
|
296
|
-
cat > logs/deployment-validation-$TIMESTAMP.json << EOF
|
|
297
|
-
{
|
|
298
|
-
"timestamp": "$(date -Iseconds)",
|
|
299
|
-
"deployment_id": "$TIMESTAMP",
|
|
300
|
-
"redis_healthy": $(docker exec cfn-redis-coordinator redis-cli ping | grep -q "PONG" && echo true || echo false),
|
|
301
|
-
"prometheus_healthy": $prometheus_ok,
|
|
302
|
-
"grafana_healthy": $grafana_ok,
|
|
303
|
-
"services_total": $(docker-compose -f docker-compose.production.yml ps --format json | jq '. | length'),
|
|
304
|
-
"services_healthy": $(docker-compose -f docker-compose.production.yml ps --format json | jq '[.[] | select(.State == "running")] | length')
|
|
305
|
-
}
|
|
306
|
-
EOF
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
# Display deployment summary
|
|
310
|
-
display_deployment_summary() {
|
|
311
|
-
log "📊 Deployment Summary"
|
|
312
|
-
log "===================="
|
|
313
|
-
|
|
314
|
-
# Service status
|
|
315
|
-
log ""
|
|
316
|
-
log "🐳 Services Status:"
|
|
317
|
-
docker-compose -f docker-compose.production.yml ps
|
|
318
|
-
|
|
319
|
-
# Access URLs
|
|
320
|
-
log ""
|
|
321
|
-
log "🔗 Access URLs:"
|
|
322
|
-
log " • Prometheus: http://localhost:9090"
|
|
323
|
-
log " • Grafana: http://localhost:3001 (admin/admin123)"
|
|
324
|
-
log " • Redis: redis://localhost:6379"
|
|
325
|
-
log " • Orchestrator: http://localhost:3000"
|
|
326
|
-
|
|
327
|
-
# Resource usage
|
|
328
|
-
log ""
|
|
329
|
-
log "📈 Resource Usage:"
|
|
330
|
-
docker stats --no-stream --format "table {{.Container}}\t{{.MemUsage}}\t{{.CPUPerc}}" | grep cfn- || log " No container stats available yet"
|
|
331
|
-
|
|
332
|
-
# Useful commands
|
|
333
|
-
log ""
|
|
334
|
-
log "🛠️ Useful Commands:"
|
|
335
|
-
log " • View logs: docker-compose -f docker-compose.production.yml logs -f [service-name]"
|
|
336
|
-
log " • Stop stack: docker-compose -f docker-compose.production.yml down"
|
|
337
|
-
log " • Restart service: docker-compose -f docker-compose.production.yml restart [service-name]"
|
|
338
|
-
log " • Scale agents: docker-compose -f docker-compose.production.yml up -d --scale agent-pool=[N]"
|
|
339
|
-
|
|
340
|
-
# Next steps
|
|
341
|
-
log ""
|
|
342
|
-
log "📋 Next Steps:"
|
|
343
|
-
log " 1. Configure Grafana dashboards for monitoring"
|
|
344
|
-
log " 2. Set up alerting rules in Prometheus"
|
|
345
|
-
log " 3. Test CFN Loop execution with real tasks"
|
|
346
|
-
log " 4. Configure backup and disaster recovery"
|
|
347
|
-
log " 5. Set up log aggregation and analysis"
|
|
348
|
-
|
|
349
|
-
log ""
|
|
350
|
-
success "🎉 Production deployment is ready for use!"
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
# Script entry point
|
|
354
|
-
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
355
|
-
main "$@"
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Production CFN Loop Deployment Script
|
|
4
|
+
# Deploys the complete production stack with validation
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
# Configuration
|
|
9
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
11
|
+
TIMESTAMP=$(date +%s)
|
|
12
|
+
LOG_FILE="$PROJECT_ROOT/logs/production-deploy-$TIMESTAMP.log"
|
|
13
|
+
|
|
14
|
+
# Colors for output
|
|
15
|
+
RED='\033[0;31m'
|
|
16
|
+
GREEN='\033[0;32m'
|
|
17
|
+
YELLOW='\033[1;33m'
|
|
18
|
+
BLUE='\033[0;34m'
|
|
19
|
+
NC='\033[0m' # No Color
|
|
20
|
+
|
|
21
|
+
# Environment variables
|
|
22
|
+
export BUILD_DATE="${BUILD_DATE:-$(date -u +'%Y-%m-%dT%H:%M:%SZ')}"
|
|
23
|
+
export VCS_REF="${VCS_REF:-$(git rev-parse --short HEAD 2>/dev/null || echo 'unknown')}"
|
|
24
|
+
export VERSION="${VERSION:-4.0.0}"
|
|
25
|
+
export CLAUDE_FLOW_VERSION="${CLAUDE_FLOW_VERSION:-4.0.0}"
|
|
26
|
+
export LOG_LEVEL="${LOG_LEVEL:-info}"
|
|
27
|
+
export MAX_AGENTS="${MAX_AGENTS:-10}"
|
|
28
|
+
export AGENT_TIMEOUT="${AGENT_TIMEOUT:-300000}"
|
|
29
|
+
export MEMORY_LIMIT="${MEMORY_LIMIT:-1g}"
|
|
30
|
+
export CPU_LIMIT="${CPU_LIMIT:-0.5}"
|
|
31
|
+
export AGENT_REPLICAS="${AGENT_REPLICAS:-3}"
|
|
32
|
+
export WORKER_POOL_SIZE="${WORKER_POOL_SIZE:-5}"
|
|
33
|
+
export GRAFANA_USER="${GRAFANA_USER:-admin}"
|
|
34
|
+
export GRAFANA_PASSWORD="${GRAFANA_PASSWORD:-admin123}"
|
|
35
|
+
|
|
36
|
+
# Logging function
|
|
37
|
+
log() {
|
|
38
|
+
echo -e "${BLUE}[$(date '+%Y-%m-%d %H:%M:%S')]${NC} $1" | tee -a "$LOG_FILE"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
error() {
|
|
42
|
+
echo -e "${RED}[ERROR]${NC} $1" >&2 | tee -a "$LOG_FILE"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
success() {
|
|
46
|
+
echo -e "${GREEN}[SUCCESS]${NC} $1" | tee -a "$LOG_FILE"
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
warning() {
|
|
50
|
+
echo -e "${YELLOW}[WARNING]${NC} $1" | tee -a "$LOG_FILE"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
# Cleanup function
|
|
54
|
+
cleanup() {
|
|
55
|
+
log "Cleaning up on exit..."
|
|
56
|
+
# Add any cleanup tasks here
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# Set up signal handlers
|
|
60
|
+
trap cleanup EXIT INT TERM
|
|
61
|
+
|
|
62
|
+
# Main deployment function
|
|
63
|
+
main() {
|
|
64
|
+
log "🚀 Starting Production CFN Loop Deployment"
|
|
65
|
+
log "📋 Deployment ID: $TIMESTAMP"
|
|
66
|
+
log "📁 Project root: $PROJECT_ROOT"
|
|
67
|
+
log "📄 Log file: $LOG_FILE"
|
|
68
|
+
|
|
69
|
+
# Change to project directory
|
|
70
|
+
cd "$PROJECT_ROOT"
|
|
71
|
+
|
|
72
|
+
# Phase 1: Pre-deployment checks
|
|
73
|
+
log "🔍 Running pre-deployment checks..."
|
|
74
|
+
run_pre_deployment_checks
|
|
75
|
+
|
|
76
|
+
# Phase 2: Build production images
|
|
77
|
+
log "🏗️ Building production Docker images..."
|
|
78
|
+
build_production_images
|
|
79
|
+
|
|
80
|
+
# Phase 3: Deploy infrastructure
|
|
81
|
+
log "🐳 Deploying production infrastructure..."
|
|
82
|
+
deploy_infrastructure
|
|
83
|
+
|
|
84
|
+
# Phase 4: Wait for services to be healthy
|
|
85
|
+
log "⏳ Waiting for services to be healthy..."
|
|
86
|
+
wait_for_healthy_services
|
|
87
|
+
|
|
88
|
+
# Phase 5: Run validation tests
|
|
89
|
+
log "🧪 Running deployment validation..."
|
|
90
|
+
run_validation_tests
|
|
91
|
+
|
|
92
|
+
# Phase 6: Display deployment summary
|
|
93
|
+
display_deployment_summary
|
|
94
|
+
|
|
95
|
+
success "🎉 Production deployment completed successfully!"
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
# Pre-deployment checks
|
|
99
|
+
run_pre_deployment_checks() {
|
|
100
|
+
log " Checking prerequisites..."
|
|
101
|
+
|
|
102
|
+
# Check Docker
|
|
103
|
+
if ! command -v docker &> /dev/null; then
|
|
104
|
+
error "Docker is not installed or not in PATH"
|
|
105
|
+
exit 1
|
|
106
|
+
fi
|
|
107
|
+
log " ✅ Docker available: $(docker --version)"
|
|
108
|
+
|
|
109
|
+
# Check Docker Compose
|
|
110
|
+
if ! command -v docker-compose &> /dev/null; then
|
|
111
|
+
error "Docker Compose is not installed or not in PATH"
|
|
112
|
+
exit 1
|
|
113
|
+
fi
|
|
114
|
+
log " ✅ Docker Compose available: $(docker-compose --version)"
|
|
115
|
+
|
|
116
|
+
# Check Node.js (for local tests)
|
|
117
|
+
if command -v node &> /dev/null; then
|
|
118
|
+
log " ✅ Node.js available: $(node --version)"
|
|
119
|
+
else
|
|
120
|
+
warning "Node.js not available - some tests may be skipped"
|
|
121
|
+
fi
|
|
122
|
+
|
|
123
|
+
# Check available disk space
|
|
124
|
+
local available_space
|
|
125
|
+
available_space=$(df -BG . | awk 'NR==2 {print $4}' | sed 's/G//')
|
|
126
|
+
if [[ $available_space -lt 5 ]]; then
|
|
127
|
+
warning "Low disk space: ${available_space}GB available (recommended: 5GB+)"
|
|
128
|
+
else
|
|
129
|
+
log " ✅ Disk space: ${available_space}GB available"
|
|
130
|
+
fi
|
|
131
|
+
|
|
132
|
+
# Check available memory
|
|
133
|
+
if command -v free &> /dev/null; then
|
|
134
|
+
local available_memory
|
|
135
|
+
available_memory=$(free -g | awk 'NR==2{print $7}')
|
|
136
|
+
if [[ $available_memory -lt 4 ]]; then
|
|
137
|
+
warning "Low memory: ${available_memory}GB available (recommended: 4GB+)"
|
|
138
|
+
else
|
|
139
|
+
log " ✅ Memory: ${available_memory}GB available"
|
|
140
|
+
fi
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
# Create necessary directories
|
|
144
|
+
log " Creating directories..."
|
|
145
|
+
mkdir -p logs workspaces monitoring/grafana/{provisioning/{datasources,dashboards},dashboards} nginx
|
|
146
|
+
|
|
147
|
+
log " ✅ Pre-deployment checks completed"
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
# Build production images
|
|
151
|
+
build_production_images() {
|
|
152
|
+
log " Building production Docker image..."
|
|
153
|
+
|
|
154
|
+
# Build the production image
|
|
155
|
+
if docker build -f Dockerfile.production -t claude-flow-novice:production .; then
|
|
156
|
+
success " ✅ Production image built successfully"
|
|
157
|
+
else
|
|
158
|
+
error " ❌ Failed to build production image"
|
|
159
|
+
exit 1
|
|
160
|
+
fi
|
|
161
|
+
|
|
162
|
+
# Tag the image
|
|
163
|
+
docker tag claude-flow-novice:production claude-flow-novice:${VERSION}
|
|
164
|
+
log " ✅ Image tagged as claude-flow-novice:${VERSION}"
|
|
165
|
+
|
|
166
|
+
# Show image information
|
|
167
|
+
local image_size
|
|
168
|
+
image_size=$(docker images claude-flow-novice:production --format "{{.Size}}")
|
|
169
|
+
log " 📊 Image size: $image_size"
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
# Deploy infrastructure
|
|
173
|
+
deploy_infrastructure() {
|
|
174
|
+
log " Deploying production stack..."
|
|
175
|
+
|
|
176
|
+
# Create environment file
|
|
177
|
+
cat > .env.production << EOF
|
|
178
|
+
# Production CFN Loop Environment Configuration
|
|
179
|
+
BUILD_DATE=$BUILD_DATE
|
|
180
|
+
VCS_REF=$VCS_REF
|
|
181
|
+
VERSION=$VERSION
|
|
182
|
+
CLAUDE_FLOW_VERSION=$CLAUDE_FLOW_VERSION
|
|
183
|
+
LOG_LEVEL=$LOG_LEVEL
|
|
184
|
+
MAX_AGENTS=$MAX_AGENTS
|
|
185
|
+
AGENT_TIMEOUT=$AGENT_TIMEOUT
|
|
186
|
+
MEMORY_LIMIT=$MEMORY_LIMIT
|
|
187
|
+
CPU_LIMIT=$CPU_LIMIT
|
|
188
|
+
AGENT_REPLICAS=$AGENT_REPLICAS
|
|
189
|
+
WORKER_POOL_SIZE=$WORKER_POOL_SIZE
|
|
190
|
+
GRAFANA_USER=$GRAFANA_USER
|
|
191
|
+
GRAFANA_PASSWORD=$GRAFANA_PASSWORD
|
|
192
|
+
EOF
|
|
193
|
+
|
|
194
|
+
# Deploy the stack
|
|
195
|
+
if docker-compose -f docker-compose.production.yml --env-file .env.production up -d; then
|
|
196
|
+
success " ✅ Production stack deployed"
|
|
197
|
+
else
|
|
198
|
+
error " ❌ Failed to deploy production stack"
|
|
199
|
+
exit 1
|
|
200
|
+
fi
|
|
201
|
+
|
|
202
|
+
# Show deployed services
|
|
203
|
+
log " 📊 Deployed services:"
|
|
204
|
+
docker-compose -f docker-compose.production.yml ps
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
# Wait for services to be healthy
|
|
208
|
+
wait_for_healthy_services() {
|
|
209
|
+
log " Waiting for services to become healthy..."
|
|
210
|
+
local max_wait=300 # 5 minutes
|
|
211
|
+
local wait_interval=10
|
|
212
|
+
local waited=0
|
|
213
|
+
|
|
214
|
+
while [[ $waited -lt $max_wait ]]; do
|
|
215
|
+
local healthy_count=0
|
|
216
|
+
local total_count=0
|
|
217
|
+
|
|
218
|
+
# Check service health
|
|
219
|
+
while IFS= read -r line; do
|
|
220
|
+
if [[ $line == *"cfn-"* ]]; then
|
|
221
|
+
((total_count++))
|
|
222
|
+
if [[ $line == *"healthy"* ]] || [[ $line == *"Up"* ]]; then
|
|
223
|
+
((healthy_count++))
|
|
224
|
+
fi
|
|
225
|
+
fi
|
|
226
|
+
done < <(docker-compose -f docker-compose.production.yml ps --format "table {{.Name}}\t{{.Status}}" | tail -n +2)
|
|
227
|
+
|
|
228
|
+
log " Progress: $healthy_count/$total_count services healthy (${waited}s elapsed)"
|
|
229
|
+
|
|
230
|
+
if [[ $healthy_count -eq $total_count ]] && [[ $total_count -gt 0 ]]; then
|
|
231
|
+
success " ✅ All $total_count services are healthy"
|
|
232
|
+
return 0
|
|
233
|
+
fi
|
|
234
|
+
|
|
235
|
+
sleep $wait_interval
|
|
236
|
+
((waited += wait_interval))
|
|
237
|
+
done
|
|
238
|
+
|
|
239
|
+
warning " ⚠️ Some services may still be starting up"
|
|
240
|
+
log " 📊 Current status:"
|
|
241
|
+
docker-compose -f docker-compose.production.yml ps
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
# Run validation tests
|
|
245
|
+
run_validation_tests() {
|
|
246
|
+
log " Running deployment validation tests..."
|
|
247
|
+
|
|
248
|
+
# Test basic connectivity
|
|
249
|
+
log " Testing Redis connectivity..."
|
|
250
|
+
if docker exec cfn-redis-coordinator redis-cli ping | grep -q "PONG"; then
|
|
251
|
+
success " ✅ Redis connectivity verified"
|
|
252
|
+
else
|
|
253
|
+
error " ❌ Redis connectivity failed"
|
|
254
|
+
fi
|
|
255
|
+
|
|
256
|
+
# Test orchestrator
|
|
257
|
+
log " Testing orchestrator..."
|
|
258
|
+
if docker exec cfn-orchestrator node -e "console.log('Orchestrator ready')" &>/dev/null; then
|
|
259
|
+
success " ✅ Orchestrator responsive"
|
|
260
|
+
else
|
|
261
|
+
warning " ⚠️ Orchestrator may still be initializing"
|
|
262
|
+
fi
|
|
263
|
+
|
|
264
|
+
# Test monitoring endpoints
|
|
265
|
+
log " Testing monitoring endpoints..."
|
|
266
|
+
local prometheus_ok=false
|
|
267
|
+
local grafana_ok=false
|
|
268
|
+
|
|
269
|
+
if curl -s http://localhost:9090/-/healthy &>/dev/null; then
|
|
270
|
+
prometheus_ok=true
|
|
271
|
+
success " ✅ Prometheus endpoint accessible"
|
|
272
|
+
else
|
|
273
|
+
warning " ⚠️ Prometheus endpoint not accessible"
|
|
274
|
+
fi
|
|
275
|
+
|
|
276
|
+
if curl -s http://localhost:3001/api/health &>/dev/null; then
|
|
277
|
+
grafana_ok=true
|
|
278
|
+
success " ✅ Grafana endpoint accessible"
|
|
279
|
+
else
|
|
280
|
+
warning " ⚠️ Grafana endpoint not accessible"
|
|
281
|
+
fi
|
|
282
|
+
|
|
283
|
+
# Run comprehensive test if Node.js is available
|
|
284
|
+
if command -v node &> /dev/null; then
|
|
285
|
+
log " Running comprehensive production test..."
|
|
286
|
+
if node tests/docker/production-deployment-test.js &>/dev/null; then
|
|
287
|
+
success " ✅ Comprehensive test passed"
|
|
288
|
+
else
|
|
289
|
+
warning " ⚠️ Comprehensive test encountered issues"
|
|
290
|
+
fi
|
|
291
|
+
else
|
|
292
|
+
log " ⏭️ Skipping comprehensive test (Node.js not available)"
|
|
293
|
+
fi
|
|
294
|
+
|
|
295
|
+
# Store test results
|
|
296
|
+
cat > logs/deployment-validation-$TIMESTAMP.json << EOF
|
|
297
|
+
{
|
|
298
|
+
"timestamp": "$(date -Iseconds)",
|
|
299
|
+
"deployment_id": "$TIMESTAMP",
|
|
300
|
+
"redis_healthy": $(docker exec cfn-redis-coordinator redis-cli ping | grep -q "PONG" && echo true || echo false),
|
|
301
|
+
"prometheus_healthy": $prometheus_ok,
|
|
302
|
+
"grafana_healthy": $grafana_ok,
|
|
303
|
+
"services_total": $(docker-compose -f docker-compose.production.yml ps --format json | jq '. | length'),
|
|
304
|
+
"services_healthy": $(docker-compose -f docker-compose.production.yml ps --format json | jq '[.[] | select(.State == "running")] | length')
|
|
305
|
+
}
|
|
306
|
+
EOF
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
# Display deployment summary
|
|
310
|
+
display_deployment_summary() {
|
|
311
|
+
log "📊 Deployment Summary"
|
|
312
|
+
log "===================="
|
|
313
|
+
|
|
314
|
+
# Service status
|
|
315
|
+
log ""
|
|
316
|
+
log "🐳 Services Status:"
|
|
317
|
+
docker-compose -f docker-compose.production.yml ps
|
|
318
|
+
|
|
319
|
+
# Access URLs
|
|
320
|
+
log ""
|
|
321
|
+
log "🔗 Access URLs:"
|
|
322
|
+
log " • Prometheus: http://localhost:9090"
|
|
323
|
+
log " • Grafana: http://localhost:3001 (admin/admin123)"
|
|
324
|
+
log " • Redis: redis://localhost:6379"
|
|
325
|
+
log " • Orchestrator: http://localhost:3000"
|
|
326
|
+
|
|
327
|
+
# Resource usage
|
|
328
|
+
log ""
|
|
329
|
+
log "📈 Resource Usage:"
|
|
330
|
+
docker stats --no-stream --format "table {{.Container}}\t{{.MemUsage}}\t{{.CPUPerc}}" | grep cfn- || log " No container stats available yet"
|
|
331
|
+
|
|
332
|
+
# Useful commands
|
|
333
|
+
log ""
|
|
334
|
+
log "🛠️ Useful Commands:"
|
|
335
|
+
log " • View logs: docker-compose -f docker-compose.production.yml logs -f [service-name]"
|
|
336
|
+
log " • Stop stack: docker-compose -f docker-compose.production.yml down"
|
|
337
|
+
log " • Restart service: docker-compose -f docker-compose.production.yml restart [service-name]"
|
|
338
|
+
log " • Scale agents: docker-compose -f docker-compose.production.yml up -d --scale agent-pool=[N]"
|
|
339
|
+
|
|
340
|
+
# Next steps
|
|
341
|
+
log ""
|
|
342
|
+
log "📋 Next Steps:"
|
|
343
|
+
log " 1. Configure Grafana dashboards for monitoring"
|
|
344
|
+
log " 2. Set up alerting rules in Prometheus"
|
|
345
|
+
log " 3. Test CFN Loop execution with real tasks"
|
|
346
|
+
log " 4. Configure backup and disaster recovery"
|
|
347
|
+
log " 5. Set up log aggregation and analysis"
|
|
348
|
+
|
|
349
|
+
log ""
|
|
350
|
+
success "🎉 Production deployment is ready for use!"
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
# Script entry point
|
|
354
|
+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
355
|
+
main "$@"
|
|
356
356
|
fi
|