claude-flow-novice 2.14.32 → 2.14.34

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.
@@ -15,7 +15,7 @@ Switch Main Chat and Task() tool API provider between Z.ai (cost-optimized) and
15
15
  **Arguments:**
16
16
  - `status` - Show current routing configuration (default)
17
17
  - `zai` - Route Main Chat + Task tool to Z.ai for cost savings
18
- - `max` or `claude` - Route Main Chat + Task tool to Anthropic for quality
18
+ - `max` - Route Main Chat + Task tool to Anthropic for quality (also accepts `claude` or `anthropic` as aliases)
19
19
 
20
20
  **What This Does:**
21
21
 
@@ -25,15 +25,9 @@ set -euo pipefail
25
25
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
26
26
  PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
27
27
 
28
- # ⚠️ ANTI-023 MEMORY LEAK PROTECTION: Block Task Mode agents
29
- # Task Mode agents spawn via Task() tool and should NOT use orchestration scripts
30
- if [[ -z "${TASK_ID:-}" || -z "${LOOP3_AGENTS:-}" ]]; then
31
- echo "❌ TASK MODE DETECTED - Orchestration forbidden" >&2
32
- echo "🚨 ANTI-023: This script is for CLI-spawned coordinators only" >&2
33
- echo "💡 Task Mode coordination should be handled directly by Main Chat" >&2
34
- echo "🔧 Coordinator spawned via Task() tool - Main Chat should coordinate directly" >&2
35
- exit 1
36
- fi
28
+ # ⚠️ ANTI-023 MEMORY LEAK PROTECTION:
29
+ # Task Mode validation moved to after argument parsing at line 276
30
+ # This allows proper CLI argument processing before validation
37
31
 
38
32
  # ⚠️ ANTI-023 MEMORY LEAK PROTECTION: Environment Sanitization
39
33
  # Load and apply environment sanitization to prevent memory leaks
@@ -0,0 +1,107 @@
1
+ #!/bin/bash
2
+
3
+ ##############################################################################
4
+ # Pre-Edit Backup Script - Creates safe file backups before modifications
5
+ # Version: 1.0.0
6
+ ##############################################################################
7
+
8
+ set -euo pipefail
9
+
10
+ # Function to create backup of a file before editing
11
+ create_backup() {
12
+ local file_path="$1"
13
+ local agent_id="${2:-unknown}"
14
+ local project_root="${3:-$(pwd)}"
15
+
16
+ # Validate inputs
17
+ if [[ -z "$file_path" ]]; then
18
+ echo "Error: File path is required" >&2
19
+ exit 1
20
+ fi
21
+
22
+ # Check if file exists
23
+ if [[ ! -f "$file_path" ]]; then
24
+ echo "Warning: File does not exist: $file_path" >&2
25
+ # Create empty backup path for new files
26
+ echo "$project_root/.backups/$agent_id/new-file-$(date +%s)-$(echo "$file_path" | tr '/' '_' | tr ' ' '_')"
27
+ return 0
28
+ fi
29
+
30
+ # Create backup directory structure
31
+ local backup_dir="$project_root/.backups/$agent_id"
32
+ local timestamp=$(date +%s)
33
+ local file_hash=$(md5sum "$file_path" | cut -d' ' -f1)
34
+ local backup_name="${timestamp}_${file_hash}"
35
+
36
+ # Create full backup path
37
+ local full_backup_path="$backup_dir/$backup_name"
38
+
39
+ # Create backup directory
40
+ mkdir -p "$full_backup_path"
41
+
42
+ # Copy original file to backup location
43
+ cp "$file_path" "$full_backup_path/original"
44
+
45
+ # Store backup metadata
46
+ cat > "$full_backup_path/metadata.json" << EOF
47
+ {
48
+ "timestamp": "$timestamp",
49
+ "agent_id": "$agent_id",
50
+ "original_file": "$file_path",
51
+ "file_hash": "$file_hash",
52
+ "backup_path": "$full_backup_path",
53
+ "created_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
54
+ }
55
+ EOF
56
+
57
+ # Create revert script
58
+ cat > "$full_backup_path/revert.sh" << EOF
59
+ #!/bin/bash
60
+ # Revert script for $file_path
61
+ set -euo pipefail
62
+
63
+ echo "Reverting file: $file_path"
64
+ cp "$full_backup_path/original" "$file_path"
65
+ echo "✅ File reverted successfully"
66
+ EOF
67
+
68
+ chmod +x "$full_backup_path/revert.sh"
69
+
70
+ # Output backup path for caller
71
+ echo "$full_backup_path"
72
+
73
+ echo "✅ Backup created: $full_backup_path" >&2
74
+ }
75
+
76
+ # Main execution
77
+ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
78
+ # Script called directly
79
+ if [[ $# -lt 1 ]]; then
80
+ echo "Usage: $0 <file_path> [--agent-id <id>] [--project-root <path>]" >&2
81
+ exit 1
82
+ fi
83
+
84
+ file_path="$1"
85
+ agent_id="unknown"
86
+ project_root="$(pwd)"
87
+
88
+ # Parse optional arguments
89
+ while [[ $# -gt 0 ]]; do
90
+ case $1 in
91
+ --agent-id)
92
+ agent_id="$2"
93
+ shift 2
94
+ ;;
95
+ --project-root)
96
+ project_root="$2"
97
+ shift 2
98
+ ;;
99
+ *)
100
+ # Skip unknown arguments
101
+ shift
102
+ ;;
103
+ esac
104
+ done
105
+
106
+ create_backup "$file_path" "$agent_id" "$project_root"
107
+ fi
@@ -16,18 +16,16 @@ You coordinate CFN Loop v3 execution with Redis-based agent orchestration and CL
16
16
 
17
17
  Orchestrate CFN Loop v3 execution using Redis coordination for CLI agent spawning, context management, and consensus collection.
18
18
 
19
- ## Mode-Specific Execution
19
+ ## CLI Mode Execution (Coordinator is ALWAYS CLI Mode)
20
20
 
21
- **CLI Mode (Production):**
21
+ **IMPORTANT:** This coordinator agent is **ALWAYS CLI mode**. Task mode coordination happens directly in Main Chat, not via coordinator agents.
22
+
23
+ When spawned via CLI (`npx claude-flow-novice agent-spawn`), implement full Redis coordination:
22
24
  - Use Redis coordination for agent spawning
23
25
  - Store context in Redis for swarm recovery
24
26
  - Collect confidence scores via Redis signals
25
27
  - Use background execution with monitoring
26
-
27
- **Task Mode (Debugging):**
28
- - Direct Task() spawning (no Redis needed)
29
- - Main Chat handles coordination
30
- - Simple JSON response only
28
+ - **ALWAYS invoke the orchestrator** - never handle tasks directly
31
29
 
32
30
  ## Redis Coordination Protocols
33
31
 
@@ -494,11 +492,75 @@ Extract deliverables from task description:
494
492
  - Estimate iteration count
495
493
  - Provide reasoning for choices
496
494
 
495
+ ## Execution Steps (CLI Mode Only)
496
+
497
+ **CRITICAL:** This coordinator is ALWAYS CLI mode. There is no Task Mode execution path.
498
+
499
+ ### Step 1: Task Classification (REQUIRED)
500
+ ```bash
501
+ # Classify task type (use hardcoded defaults if script fails)
502
+ TASK_TYPE="infrastructure" # Default fallback
503
+ if [[ -f ".claude/skills/task-classifier/classify-task.sh" ]]; then
504
+ CLASSIFIED_TYPE=$(bash .claude/skills/task-classifier/classify-task.sh "$TASK_DESCRIPTION" 2>/dev/null || echo "")
505
+ [[ -n "$CLASSIFIED_TYPE" ]] && TASK_TYPE="$CLASSIFIED_TYPE"
506
+ fi
507
+ ```
508
+
509
+ ### Step 2: Agent Selection with Fallback (REQUIRED)
510
+ ```bash
511
+ # Select agents with hardcoded fallbacks (never fail)
512
+ LOOP3_AGENTS="terraform-engineer,devops-engineer" # Infrastructure default
513
+ LOOP2_AGENTS="security-auditor,compliance-checker,cost-optimizer" # Validation default
514
+ PRODUCT_OWNER="product-owner"
515
+
516
+ # Try dynamic selection but fall back to defaults
517
+ if [[ -f ".claude/skills/cfn-agent-selector/select-agents.sh" ]]; then
518
+ SELECTED_AGENTS=$(bash .claude/skills/cfn-agent-selector/select-agents.sh --task-type "$TASK_TYPE" --description "$TASK_DESCRIPTION" 2>/dev/null || echo "")
519
+ if [[ -n "$SELECTED_AGENTS" ]]; then
520
+ PARSED_AGENTS=$(echo "$SELECTED_AGENTS" | jq -r '.loop3 // empty | join(",")')
521
+ [[ -n "$PARSED_AGENTS" ]] && LOOP3_AGENTS="$PARSED_AGENTS"
522
+
523
+ PARSED_AGENTS=$(echo "$SELECTED_AGENTS" | jq -r '.loop2 // empty | join(",")')
524
+ [[ -n "$PARSED_AGENTS" ]] && LOOP2_AGENTS="$PARSED_AGENTS"
525
+ fi
526
+ fi
527
+ ```
528
+
529
+ ### Step 3: INVOKE ORCHESTRATOR (MANDATORY - NOT OPTIONAL)
530
+
531
+ **CRITICAL:** You MUST invoke orchestrator by iteration 3. DO NOT complete tasks directly.
532
+
533
+ ```bash
534
+ # ALWAYS invoke orchestrator - this is your ONLY responsibility
535
+ ./.claude/skills/cfn-loop-orchestration/orchestrate.sh \
536
+ --task-id "$TASK_ID" \
537
+ --mode "standard" \
538
+ --loop3-agents "$LOOP3_AGENTS" \
539
+ --loop2-agents "$LOOP2_AGENTS" \
540
+ --product-owner "$PRODUCT_OWNER" \
541
+ --max-iterations 10 \
542
+ --success-criteria '{"deliverables":[],"acceptanceCriteria":["Implementation complete"]}'
543
+
544
+ # The orchestrator handles ALL CFN Loop execution including:
545
+ # - Loop 3 agent spawning and iteration
546
+ # - Loop 2 validator spawning and consensus
547
+ # - Product Owner decision (PROCEED/ITERATE/ABORT)
548
+ # - Git commit and push (on PROCEED)
549
+ # - Sprint summary generation
550
+
551
+ # Your job is complete after invoking this command - DO NOT wait for results
552
+ ```
553
+
554
+ **EXECUTION GUARANTEE:**
555
+ - If steps 1-2 fail, use hardcoded defaults and proceed to step 3
556
+ - **Never exit without invoking orchestrator**
557
+ - **Orchestrator invocation MUST happen by iteration 3**
558
+ - This coordinator's ONLY job is to configure and invoke the orchestrator
559
+
497
560
  ## Success Metrics
498
561
 
499
562
  - Agent selections match domain expertise
500
563
  - Validation criteria cover all critical requirements
501
564
  - Deliverable list is comprehensive
502
565
  - Confidence score ≥ 0.85 in analysis quality
503
-
504
- Provide structured output with confidence score based on analysis completeness and agent selection appropriateness.
566
+ - **CRITICAL: Orchestrator invoked successfully**
@@ -15,7 +15,7 @@ Switch Main Chat and Task() tool API provider between Z.ai (cost-optimized) and
15
15
  **Arguments:**
16
16
  - `status` - Show current routing configuration (default)
17
17
  - `zai` - Route Main Chat + Task tool to Z.ai for cost savings
18
- - `max` or `claude` - Route Main Chat + Task tool to Anthropic for quality
18
+ - `max` - Route Main Chat + Task tool to Anthropic for quality (also accepts `claude` or `anthropic` as aliases)
19
19
 
20
20
  **What This Does:**
21
21
 
@@ -25,15 +25,9 @@ set -euo pipefail
25
25
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
26
26
  PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
27
27
 
28
- # ⚠️ ANTI-023 MEMORY LEAK PROTECTION: Block Task Mode agents
29
- # Task Mode agents spawn via Task() tool and should NOT use orchestration scripts
30
- if [[ -z "${TASK_ID:-}" || -z "${LOOP3_AGENTS:-}" ]]; then
31
- echo "❌ TASK MODE DETECTED - Orchestration forbidden" >&2
32
- echo "🚨 ANTI-023: This script is for CLI-spawned coordinators only" >&2
33
- echo "💡 Task Mode coordination should be handled directly by Main Chat" >&2
34
- echo "🔧 Coordinator spawned via Task() tool - Main Chat should coordinate directly" >&2
35
- exit 1
36
- fi
28
+ # ⚠️ ANTI-023 MEMORY LEAK PROTECTION:
29
+ # Task Mode validation moved to after argument parsing at line 276
30
+ # This allows proper CLI argument processing before validation
37
31
 
38
32
  # ⚠️ ANTI-023 MEMORY LEAK PROTECTION: Environment Sanitization
39
33
  # Load and apply environment sanitization to prevent memory leaks