claude-flow-novice 2.14.18 → 2.14.19

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 (35) hide show
  1. package/.claude/commands/CFN_EXPERT_UPDATE.md +142 -0
  2. package/.claude/commands/cfn-docker/CFN_DOCKER_CLI.md +527 -0
  3. package/.claude/commands/cfn-docker/CFN_DOCKER_LOOP.md +377 -0
  4. package/.claude/commands/cfn-docker/CFN_DOCKER_TASK.md +490 -0
  5. package/.claude/commands/cfn-loop-cli.md +220 -46
  6. package/.claude/commands/deprecated/README.md +55 -0
  7. package/claude-assets/agents/docker-coordinators/cfn-docker-v3-coordinator.md +199 -0
  8. package/claude-assets/commands/CFN_EXPERT_UPDATE.md +142 -0
  9. package/claude-assets/commands/cfn-docker/CFN_DOCKER_CLI.md +527 -0
  10. package/claude-assets/commands/cfn-docker/CFN_DOCKER_LOOP.md +377 -0
  11. package/claude-assets/commands/cfn-docker/CFN_DOCKER_TASK.md +490 -0
  12. package/claude-assets/commands/cfn-loop-cli.md +220 -46
  13. package/claude-assets/commands/deprecated/README.md +55 -0
  14. package/claude-assets/skills/cfn-docker-agent-spawning/SKILL.md +394 -0
  15. package/claude-assets/skills/cfn-docker-agent-spawning/spawn-agent.sh +461 -0
  16. package/claude-assets/skills/cfn-docker-loop-orchestration/SKILL.md +449 -0
  17. package/claude-assets/skills/cfn-docker-loop-orchestration/orchestrate.sh +787 -0
  18. package/claude-assets/skills/cfn-docker-redis-coordination/SKILL.md +435 -0
  19. package/claude-assets/skills/cfn-docker-redis-coordination/coordinate.sh +635 -0
  20. package/claude-assets/skills/cfn-docker-skill-mcp-selection/SKILL.md +289 -0
  21. package/claude-assets/skills/cfn-docker-skill-mcp-selection/skill-mcp-selector.js +472 -0
  22. package/claude-assets/skills/cfn-expert-update/update-expert.sh +346 -0
  23. package/dist/agents/agent-loader.js +165 -146
  24. package/dist/agents/agent-loader.js.map +1 -1
  25. package/package.json +1 -1
  26. /package/.claude/commands/{cfn-loop-epic.md → deprecated/cfn-loop-epic.md} +0 -0
  27. /package/.claude/commands/{cfn-loop-single.md → deprecated/cfn-loop-single.md} +0 -0
  28. /package/.claude/commands/{cfn-loop-sprints.md → deprecated/cfn-loop-sprints.md} +0 -0
  29. /package/.claude/commands/{cfn-loop.md → deprecated/cfn-loop.md} +0 -0
  30. /package/.claude/commands/{cfn/run-tests.md → run-tests.md} +0 -0
  31. /package/claude-assets/commands/{cfn-loop-epic.md → deprecated/cfn-loop-epic.md} +0 -0
  32. /package/claude-assets/commands/{cfn-loop-single.md → deprecated/cfn-loop-single.md} +0 -0
  33. /package/claude-assets/commands/{cfn-loop-sprints.md → deprecated/cfn-loop-sprints.md} +0 -0
  34. /package/claude-assets/commands/{cfn-loop.md → deprecated/cfn-loop.md} +0 -0
  35. /package/claude-assets/commands/{cfn/run-tests.md → run-tests.md} +0 -0
@@ -0,0 +1,461 @@
1
+ #!/bin/bash
2
+
3
+ # CFN Docker Agent Spawning Implementation
4
+ # Usage: ./spawn-agent.sh [AGENT_TYPE] [TASK_ID] [AGENT_ID] [OPTIONS]
5
+
6
+ set -euo pipefail
7
+
8
+ # Default configuration
9
+ DEFAULT_MEMORY_LIMIT="1g"
10
+ DEFAULT_CPU_LIMIT="1.0"
11
+ DEFAULT_NETWORK="mcp-network"
12
+ DEFAULT_IMAGE="claude-flow-novice:agent"
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'
20
+
21
+ log() {
22
+ echo -e "${BLUE}[$(date '+%H:%M:%S')]${NC} $*"
23
+ }
24
+
25
+ log_success() {
26
+ echo -e "${GREEN}[SUCCESS]${NC} $*"
27
+ }
28
+
29
+ log_error() {
30
+ echo -e "${RED}[ERROR]${NC} $*"
31
+ }
32
+
33
+ log_warning() {
34
+ echo -e "${YELLOW}[WARNING]${NC} $*"
35
+ }
36
+
37
+ # Function to display usage
38
+ usage() {
39
+ cat << EOF
40
+ CFN Docker Agent Spawning
41
+
42
+ Usage: $0 [AGENT_TYPE] [TASK_ID] [AGENT_ID] [OPTIONS]
43
+
44
+ Arguments:
45
+ AGENT_TYPE Type of agent to spawn (e.g., react-frontend-engineer, backend-developer)
46
+ TASK_ID CFN Loop task identifier
47
+ AGENT_ID Unique agent identifier (auto-generated if not provided)
48
+
49
+ Options:
50
+ --memory-limit LIMIT Memory limit for container (default: 1g)
51
+ --cpu-limit LIMIT CPU limit for container (default: 1.0)
52
+ --network NAME Docker network (default: mcp-network)
53
+ --image NAME Docker image (default: claude-flow-novice:agent)
54
+ --mcp-servers LIST Comma-separated list of MCP servers
55
+ --context FILE Task context file path
56
+ --environment LIST Additional environment variables (key=value,key2=value2)
57
+ --volume LIST Additional volume mounts (src:dst,src2:dst2)
58
+ --dry-run Show configuration without creating container
59
+ --detach Run container in detached mode (default)
60
+ --interactive Run container in interactive mode
61
+ --verbose Enable verbose logging
62
+ --help Show this help message
63
+
64
+ Examples:
65
+ $0 react-frontend-engineer task-123 agent-001
66
+ $0 backend-developer task-456 --memory-limit 2g --mcp-servers redis,postgres
67
+ $0 security-specialist task-789 --interactive --verbose
68
+
69
+ EOF
70
+ }
71
+
72
+ # Parse command line arguments
73
+ AGENT_TYPE=""
74
+ TASK_ID=""
75
+ AGENT_ID=""
76
+ MEMORY_LIMIT="$DEFAULT_MEMORY_LIMIT"
77
+ CPU_LIMIT="$DEFAULT_CPU_LIMIT"
78
+ NETWORK="$DEFAULT_NETWORK"
79
+ IMAGE="$DEFAULT_IMAGE"
80
+ MCP_SERVERS=""
81
+ CONTEXT_FILE=""
82
+ ENVIRONMENT=""
83
+ VOLUMES=""
84
+ DRY_RUN=false
85
+ DETACH=true
86
+ INTERACTIVE=false
87
+ VERBOSE=false
88
+
89
+ while [[ $# -gt 0 ]]; do
90
+ case $1 in
91
+ --memory-limit)
92
+ MEMORY_LIMIT="$2"
93
+ shift 2
94
+ ;;
95
+ --cpu-limit)
96
+ CPU_LIMIT="$2"
97
+ shift 2
98
+ ;;
99
+ --network)
100
+ NETWORK="$2"
101
+ shift 2
102
+ ;;
103
+ --image)
104
+ IMAGE="$2"
105
+ shift 2
106
+ ;;
107
+ --mcp-servers)
108
+ MCP_SERVERS="$2"
109
+ shift 2
110
+ ;;
111
+ --context)
112
+ CONTEXT_FILE="$2"
113
+ shift 2
114
+ ;;
115
+ --environment)
116
+ ENVIRONMENT="$2"
117
+ shift 2
118
+ ;;
119
+ --volume)
120
+ VOLUMES="$2"
121
+ shift 2
122
+ ;;
123
+ --dry-run)
124
+ DRY_RUN=true
125
+ shift
126
+ ;;
127
+ --detach)
128
+ DETACH=true
129
+ shift
130
+ ;;
131
+ --interactive)
132
+ INTERACTIVE=true
133
+ DETACH=false
134
+ shift
135
+ ;;
136
+ --verbose)
137
+ VERBOSE=true
138
+ shift
139
+ ;;
140
+ --help)
141
+ usage
142
+ exit 0
143
+ ;;
144
+ -*)
145
+ log_error "Unknown option: $1"
146
+ usage
147
+ exit 1
148
+ ;;
149
+ *)
150
+ if [[ -z "$AGENT_TYPE" ]]; then
151
+ AGENT_TYPE="$1"
152
+ elif [[ -z "$TASK_ID" ]]; then
153
+ TASK_ID="$1"
154
+ elif [[ -z "$AGENT_ID" ]]; then
155
+ AGENT_ID="$1"
156
+ else
157
+ log_error "Too many arguments"
158
+ usage
159
+ exit 1
160
+ fi
161
+ shift
162
+ ;;
163
+ esac
164
+ done
165
+
166
+ # Validate required arguments
167
+ if [[ -z "$AGENT_TYPE" || -z "$TASK_ID" ]]; then
168
+ log_error "AGENT_TYPE and TASK_ID are required"
169
+ usage
170
+ exit 1
171
+ fi
172
+
173
+ # Generate agent ID if not provided
174
+ if [[ -z "$AGENT_ID" ]]; then
175
+ AGENT_ID="${AGENT_TYPE}-$(date +%s)-$(openssl rand -hex 4)"
176
+ fi
177
+
178
+ # Configuration validation
179
+ if [[ "$VERBOSE" == true ]]; then
180
+ log "Configuration:"
181
+ log " Agent Type: $AGENT_TYPE"
182
+ log " Task ID: $TASK_ID"
183
+ log " Agent ID: $AGENT_ID"
184
+ log " Memory Limit: $MEMORY_LIMIT"
185
+ log " CPU Limit: $CPU_LIMIT"
186
+ log " Network: $NETWORK"
187
+ log " Image: $IMAGE"
188
+ log " MCP Servers: ${MCP_SERVERS:-'auto-select'}"
189
+ log " Context File: ${CONTEXT_FILE:-'none'}"
190
+ fi
191
+
192
+ # Validate Docker is available
193
+ if ! command -v docker &> /dev/null; then
194
+ log_error "Docker is not installed or not in PATH"
195
+ exit 1
196
+ fi
197
+
198
+ # Check if Docker daemon is running
199
+ if ! docker info &> /dev/null; then
200
+ log_error "Docker daemon is not running"
201
+ exit 1
202
+ fi
203
+
204
+ # Validate Docker image exists
205
+ if ! docker image inspect "$IMAGE" &> /dev/null; then
206
+ log_error "Docker image '$IMAGE' not found"
207
+ log_error "Please build or pull the image first"
208
+ exit 1
209
+ fi
210
+
211
+ # Get project root directory
212
+ PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." && pwd)"
213
+ cd "$PROJECT_ROOT"
214
+
215
+ # Create workspace directory
216
+ WORKSPACE_DIR="/tmp/agent-workspace-${AGENT_ID}"
217
+ mkdir -p "$WORKSPACE_DIR"
218
+
219
+ # Function to get MCP configuration for agent type
220
+ get_mcp_config() {
221
+ local agent_type="$1"
222
+
223
+ # Use skill-based MCP selection if available
224
+ if [[ -f ".claude/skills/cfn-docker-skill-mcp-selection/skill-mcp-selector.js" ]]; then
225
+ node .claude/skills/cfn-docker-skill-mcp-selection/skill-mcp-selector.js select \
226
+ --agent-type "$agent_type" 2>/dev/null || echo '{}'
227
+ else
228
+ # Fallback to basic configuration
229
+ echo '{"selectedMCPServers":[],"totalMemoryRequired":0,"totalCPURequired":0}'
230
+ fi
231
+ }
232
+
233
+ # Get MCP servers for agent
234
+ if [[ -z "$MCP_SERVERS" ]]; then
235
+ log "Auto-selecting MCP servers for agent type: $AGENT_TYPE"
236
+ MCP_CONFIG=$(get_mcp_config "$AGENT_TYPE")
237
+ MCP_SERVERS=$(echo "$MCP_CONFIG" | jq -r '.selectedMCPServers[]' | tr '\n' ',' | sed 's/,$//')
238
+
239
+ if [[ "$VERBOSE" == true ]]; then
240
+ log "Auto-selected MCP servers: ${MCP_SERVERS:-'none'}"
241
+ fi
242
+ fi
243
+
244
+ # Function to generate MCP tokens
245
+ generate_mcp_tokens() {
246
+ local agent_type="$1"
247
+ local mcp_servers="$2"
248
+ local agent_id="$3"
249
+
250
+ if [[ -z "$mcp_servers" ]]; then
251
+ echo "{}"
252
+ return
253
+ fi
254
+
255
+ # Use token manager if available
256
+ if [[ -f "src/cli/agent-token-manager.js" ]]; then
257
+ node src/cli/agent-token-manager.js register "$agent_type" \
258
+ --mcp-servers "$mcp_servers" --agent-id "$agent_id" 2>/dev/null || echo "{}"
259
+ else
260
+ # Fallback: generate simple token structure
261
+ local token=$(openssl rand -hex 32)
262
+ echo "{\"${mcp_servers}\":\"${token}\"}"
263
+ fi
264
+ }
265
+
266
+ # Generate MCP tokens if MCP servers specified
267
+ MCP_TOKENS=""
268
+ if [[ -n "$MCP_SERVERS" ]]; then
269
+ log "Generating MCP tokens for: $MCP_SERVERS"
270
+ MCP_TOKENS=$(generate_mcp_tokens "$AGENT_TYPE" "$MCP_SERVERS" "$AGENT_ID")
271
+
272
+ # Write tokens to file
273
+ TOKENS_FILE="${WORKSPACE_DIR}/mcp-tokens.json"
274
+ echo "$MCP_TOKENS" > "$TOKENS_FILE"
275
+
276
+ if [[ "$VERBOSE" == true ]]; then
277
+ log "MCP tokens written to: $TOKENS_FILE"
278
+ fi
279
+ fi
280
+
281
+ # Build Docker command
282
+ DOCKER_CMD="docker run"
283
+
284
+ # Add container options
285
+ if [[ "$DETACH" == true ]]; then
286
+ DOCKER_CMD="$DOCKER_CMD --detach"
287
+ fi
288
+
289
+ if [[ "$INTERACTIVE" == true ]]; then
290
+ DOCKER_CMD="$DOCKER_CMD --interactive --tty"
291
+ fi
292
+
293
+ # Container identification
294
+ DOCKER_CMD="$DOCKER_CMD --name agent-${AGENT_ID}"
295
+ DOCKER_CMD="$DOCKER_CMD --hostname agent-${AGENT_ID}"
296
+
297
+ # Resource limits
298
+ DOCKER_CMD="$DOCKER_CMD --memory ${MEMORY_LIMIT}"
299
+ DOCKER_CMD="$DOCKER_CMD --cpus ${CPU_LIMIT}"
300
+
301
+ # Networking
302
+ if docker network inspect "$NETWORK" &> /dev/null; then
303
+ DOCKER_CMD="$DOCKER_CMD --network ${NETWORK}"
304
+ else
305
+ log_warning "Docker network '$NETWORK' not found, container will use default network"
306
+ fi
307
+
308
+ # Volume mounts
309
+ DOCKER_CMD="$DOCKER_CMD --volume ${PROJECT_ROOT}/.claude:/app/.claude:ro"
310
+ DOCKER_CMD="$DOCKER_CMD --volume ${PROJECT_ROOT}/src:/app/src:ro"
311
+ DOCKER_CMD="$DOCKER_CMD --volume ${WORKSPACE_DIR}:/app/workspace"
312
+
313
+ # Add custom volumes
314
+ if [[ -n "$VOLUMES" ]]; then
315
+ IFS=',' read -ra VOLUME_ARRAY <<< "$VOLUMES"
316
+ for volume in "${VOLUME_ARRAY[@]}"; do
317
+ DOCKER_CMD="$DOCKER_CMD --volume $volume"
318
+ done
319
+ fi
320
+
321
+ # Environment variables
322
+ DOCKER_CMD="$DOCKER_CMD --env AGENT_ID=${AGENT_ID}"
323
+ DOCKER_CMD="$DOCKER_CMD --env AGENT_TYPE=${AGENT_TYPE}"
324
+ DOCKER_CMD="$DOCKER_CMD --env TASK_ID=${TASK_ID}"
325
+ DOCKER_CMD="$DOCKER_CMD --env PROJECT_ROOT=/app"
326
+
327
+ # Add Redis URL if Redis is available
328
+ if command -v redis-cli &> /dev/null && redis-cli ping &> /dev/null; then
329
+ DOCKER_CMD="$DOCKER_CMD --env REDIS_URL=redis://redis:6379"
330
+ fi
331
+
332
+ # Add MCP tokens file path if tokens generated
333
+ if [[ -n "$TOKENS_FILE" ]]; then
334
+ DOCKER_CMD="$DOCKER_CMD --env MCP_TOKENS_FILE=/app/workspace/mcp-tokens.json"
335
+ fi
336
+
337
+ # Add custom environment variables
338
+ if [[ -n "$ENVIRONMENT" ]]; then
339
+ IFS=',' read -ra ENV_ARRAY <<< "$ENVIRONMENT"
340
+ for env_var in "${ENV_ARRAY[@]}"; do
341
+ DOCKER_CMD="$DOCKER_CMD --env $env_var"
342
+ done
343
+ fi
344
+
345
+ # Add restart policy
346
+ DOCKER_CMD="$DOCKER_CMD --restart unless-stopped"
347
+
348
+ # Remove container on exit for interactive mode
349
+ if [[ "$INTERACTIVE" == true ]]; then
350
+ DOCKER_CMD="$DOCKER_CMD --rm"
351
+ fi
352
+
353
+ # Add image and command
354
+ DOCKER_CMD="$DOCKER_CMD $IMAGE"
355
+ DOCKER_CMD="$DOCKER_CMD npx claude-flow-novice agent-spawn --type ${AGENT_TYPE} --task-id ${TASK_ID} --agent-id ${AGENT_ID}"
356
+
357
+ # Add context file if specified
358
+ if [[ -n "$CONTEXT_FILE" ]]; then
359
+ if [[ -f "$CONTEXT_FILE" ]]; then
360
+ DOCKER_CMD="$DOCKER_CMD --context $(cat "$CONTEXT_FILE")"
361
+ else
362
+ log_error "Context file not found: $CONTEXT_FILE"
363
+ exit 1
364
+ fi
365
+ fi
366
+
367
+ # Display configuration
368
+ log "Container Configuration:"
369
+ log " Agent ID: $AGENT_ID"
370
+ log " Agent Type: $AGENT_TYPE"
371
+ log " Task ID: $TASK_ID"
372
+ log " Memory Limit: $MEMORY_LIMIT"
373
+ log " CPU Limit: $CPU_LIMIT"
374
+ log " Network: $NETWORK"
375
+ log " Workspace: $WORKSPACE_DIR"
376
+ log " MCP Servers: ${MCP_SERVERS:-'none'}"
377
+
378
+ if [[ "$VERBOSE" == true ]]; then
379
+ log " Docker Command: $DOCKER_CMD"
380
+ fi
381
+
382
+ # Execute or show command
383
+ if [[ "$DRY_RUN" == true ]]; then
384
+ log "DRY RUN - Container not created"
385
+ log "Command: $DOCKER_CMD"
386
+ exit 0
387
+ fi
388
+
389
+ # Create container
390
+ log "Creating container: agent-${AGENT_ID}"
391
+ if ! CONTAINER_ID=$(eval "$DOCKER_CMD"); then
392
+ log_error "Failed to create container"
393
+ exit 1
394
+ fi
395
+
396
+ log_success "Container created successfully: $CONTAINER_ID"
397
+
398
+ # Wait for container to start (if detached)
399
+ if [[ "$DETACH" == true ]]; then
400
+ log "Waiting for container to start..."
401
+ sleep 3
402
+
403
+ # Check container status
404
+ if ! docker container inspect "$CONTAINER_ID" &> /dev/null; then
405
+ log_error "Container failed to start or was removed"
406
+ exit 1
407
+ fi
408
+
409
+ CONTAINER_STATUS=$(docker container inspect "$CONTAINER_ID" --format '{{.State.Status}}')
410
+ log "Container status: $CONTAINER_STATUS"
411
+
412
+ if [[ "$CONTAINER_STATUS" == "running" ]]; then
413
+ log_success "Agent container is running"
414
+
415
+ # Show initial logs if verbose
416
+ if [[ "$VERBOSE" == true ]]; then
417
+ log "Initial container logs:"
418
+ docker logs "$CONTAINER_ID" --tail 10
419
+ fi
420
+ else
421
+ log_error "Container is not running (status: $CONTAINER_STATUS)"
422
+ docker logs "$CONTAINER_ID"
423
+ exit 1
424
+ fi
425
+ fi
426
+
427
+ # Output container information
428
+ cat << EOF
429
+
430
+ Agent Container Information:
431
+ ============================
432
+ Container ID: $CONTAINER_ID
433
+ Agent ID: $AGENT_ID
434
+ Agent Type: $AGENT_TYPE
435
+ Task ID: $TASK_ID
436
+ Network: $NETWORK
437
+ Memory Limit: $MEMORY_LIMIT
438
+ CPU Limit: $CPU_LIMIT
439
+ Workspace: $WORKSPACE_DIR
440
+ MCP Servers: ${MCP_SERVERS:-'none'}
441
+
442
+ Useful Commands:
443
+ ---------------
444
+ # View container logs:
445
+ docker logs -f $CONTAINER_ID
446
+
447
+ # Execute commands in container:
448
+ docker exec -it $CONTAINER_ID bash
449
+
450
+ # Stop container:
451
+ docker stop $CONTAINER_ID
452
+
453
+ # Remove container:
454
+ docker rm $CONTAINER_ID
455
+
456
+ # View resource usage:
457
+ docker stats $CONTAINER_ID
458
+
459
+ EOF
460
+
461
+ log_success "Agent spawning completed successfully"