@claude-flow/cli 3.0.0-alpha.36 → 3.0.0-alpha.38

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 (36) hide show
  1. package/.claude/helpers/README.md +97 -0
  2. package/.claude/helpers/adr-compliance.sh +186 -0
  3. package/.claude/helpers/auto-commit.sh +178 -0
  4. package/.claude/helpers/checkpoint-manager.sh +251 -0
  5. package/.claude/helpers/daemon-manager.sh +252 -0
  6. package/.claude/helpers/ddd-tracker.sh +144 -0
  7. package/.claude/helpers/github-safe.js +106 -0
  8. package/.claude/helpers/github-setup.sh +28 -0
  9. package/.claude/helpers/guidance-hook.sh +13 -0
  10. package/.claude/helpers/guidance-hooks.sh +102 -0
  11. package/.claude/helpers/health-monitor.sh +108 -0
  12. package/.claude/helpers/learning-hooks.sh +329 -0
  13. package/.claude/helpers/learning-optimizer.sh +127 -0
  14. package/.claude/helpers/learning-service.mjs +1144 -0
  15. package/.claude/helpers/metrics-db.mjs +488 -0
  16. package/.claude/helpers/pattern-consolidator.sh +86 -0
  17. package/.claude/helpers/perf-worker.sh +160 -0
  18. package/.claude/helpers/quick-start.sh +19 -0
  19. package/.claude/helpers/security-scanner.sh +127 -0
  20. package/.claude/helpers/setup-mcp.sh +18 -0
  21. package/.claude/helpers/standard-checkpoint-hooks.sh +189 -0
  22. package/.claude/helpers/swarm-comms.sh +353 -0
  23. package/.claude/helpers/swarm-hooks.sh +761 -0
  24. package/.claude/helpers/swarm-monitor.sh +211 -0
  25. package/.claude/helpers/sync-v3-metrics.sh +245 -0
  26. package/.claude/helpers/update-v3-progress.sh +166 -0
  27. package/.claude/helpers/v3-quick-status.sh +58 -0
  28. package/.claude/helpers/v3.sh +111 -0
  29. package/.claude/helpers/validate-v3-config.sh +216 -0
  30. package/.claude/helpers/worker-manager.sh +170 -0
  31. package/dist/src/init/mcp-generator.js +2 -2
  32. package/dist/src/init/mcp-generator.js.map +1 -1
  33. package/dist/src/init/types.js +2 -2
  34. package/dist/src/init/types.js.map +1 -1
  35. package/dist/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +1 -1
@@ -0,0 +1,97 @@
1
+ # Claude Flow V3 Helpers
2
+
3
+ This directory contains helper scripts and utilities for V3 development.
4
+
5
+ ## 🚀 Quick Start
6
+
7
+ ```bash
8
+ # Initialize V3 development environment
9
+ .claude/helpers/v3.sh init
10
+
11
+ # Quick status check
12
+ .claude/helpers/v3.sh status
13
+
14
+ # Update progress metrics
15
+ .claude/helpers/v3.sh update domain 3
16
+ .claude/helpers/v3.sh update agent 8
17
+ .claude/helpers/v3.sh update security 2
18
+ ```
19
+
20
+ ## Available Helpers
21
+
22
+ ### 🎛️ V3 Master Tool
23
+ - **`v3.sh`** - Main command-line interface for all V3 operations
24
+ ```bash
25
+ .claude/helpers/v3.sh help # Show all commands
26
+ .claude/helpers/v3.sh status # Quick development status
27
+ .claude/helpers/v3.sh update domain 3 # Update specific metrics
28
+ .claude/helpers/v3.sh validate # Validate configuration
29
+ .claude/helpers/v3.sh full-status # Complete status overview
30
+ ```
31
+
32
+ ### 📊 V3 Progress Management
33
+ - **`update-v3-progress.sh`** - Update V3 development metrics
34
+ ```bash
35
+ # Usage examples:
36
+ .claude/helpers/update-v3-progress.sh domain 3 # Mark 3 domains complete
37
+ .claude/helpers/update-v3-progress.sh agent 8 # 8 agents active
38
+ .claude/helpers/update-v3-progress.sh security 2 # 2 CVEs fixed
39
+ .claude/helpers/update-v3-progress.sh performance 2.5x # Performance boost
40
+ .claude/helpers/update-v3-progress.sh status # Show current status
41
+ ```
42
+
43
+ ### 🔍 Configuration Validation
44
+ - **`validate-v3-config.sh`** - Comprehensive environment validation
45
+ - Checks all required directories and files
46
+ - Validates JSON configuration files
47
+ - Verifies Node.js and development tools
48
+ - Confirms Git repository status
49
+ - Validates file permissions
50
+
51
+ ### ⚡ Quick Status
52
+ - **`v3-quick-status.sh`** - Compact development progress overview
53
+ - Shows domain, agent, and DDD progress
54
+ - Displays security and performance metrics
55
+ - Color-coded status indicators
56
+ - Current Git branch information
57
+
58
+ ## Helper Script Standards
59
+
60
+ ### File Naming
61
+ - Use kebab-case: `update-v3-progress.sh`
62
+ - Include version prefix: `v3-*` for V3-specific helpers
63
+ - Use descriptive names that indicate purpose
64
+
65
+ ### Script Requirements
66
+ - Must be executable (`chmod +x`)
67
+ - Include proper error handling (`set -e`)
68
+ - Provide usage help when called without arguments
69
+ - Use consistent exit codes (0 = success, non-zero = error)
70
+
71
+ ### Configuration Integration
72
+ Helpers are configured in `.claude/settings.json`:
73
+ ```json
74
+ {
75
+ "helpers": {
76
+ "directory": ".claude/helpers",
77
+ "enabled": true,
78
+ "v3ProgressUpdater": ".claude/helpers/update-v3-progress.sh"
79
+ }
80
+ }
81
+ ```
82
+
83
+ ## Development Guidelines
84
+
85
+ 1. **Security First**: All helpers must validate inputs
86
+ 2. **Idempotent**: Scripts should be safe to run multiple times
87
+ 3. **Fast Execution**: Keep helper execution under 1 second when possible
88
+ 4. **Clear Output**: Provide clear success/error messages
89
+ 5. **JSON Safe**: When updating JSON files, use `jq` for safety
90
+
91
+ ## Adding New Helpers
92
+
93
+ 1. Create script in `.claude/helpers/`
94
+ 2. Make executable: `chmod +x script-name.sh`
95
+ 3. Add to settings.json helpers section
96
+ 4. Test thoroughly before committing
97
+ 5. Update this README with usage documentation
@@ -0,0 +1,186 @@
1
+ #!/bin/bash
2
+ # Claude Flow V3 - ADR Compliance Checker Worker
3
+ # Checks compliance with Architecture Decision Records
4
+
5
+ set -euo pipefail
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
9
+ METRICS_DIR="$PROJECT_ROOT/.claude-flow/metrics"
10
+ ADR_FILE="$METRICS_DIR/adr-compliance.json"
11
+ LAST_RUN_FILE="$METRICS_DIR/.adr-last-run"
12
+
13
+ mkdir -p "$METRICS_DIR"
14
+
15
+ # V3 ADRs to check
16
+ declare -A ADRS=(
17
+ ["ADR-001"]="agentic-flow as core foundation"
18
+ ["ADR-002"]="Domain-Driven Design structure"
19
+ ["ADR-003"]="Single coordination engine"
20
+ ["ADR-004"]="Plugin-based architecture"
21
+ ["ADR-005"]="MCP-first API design"
22
+ ["ADR-006"]="Unified memory service"
23
+ ["ADR-007"]="Event sourcing for state"
24
+ ["ADR-008"]="Vitest over Jest"
25
+ ["ADR-009"]="Hybrid memory backend"
26
+ ["ADR-010"]="Remove Deno support"
27
+ )
28
+
29
+ should_run() {
30
+ if [ ! -f "$LAST_RUN_FILE" ]; then return 0; fi
31
+ local last_run=$(cat "$LAST_RUN_FILE" 2>/dev/null || echo "0")
32
+ local now=$(date +%s)
33
+ [ $((now - last_run)) -ge 900 ] # 15 minutes
34
+ }
35
+
36
+ check_adr_001() {
37
+ # ADR-001: agentic-flow as core foundation
38
+ local score=0
39
+
40
+ # Check package.json for agentic-flow dependency
41
+ grep -q "agentic-flow" "$PROJECT_ROOT/package.json" 2>/dev/null && score=$((score + 50))
42
+
43
+ # Check for imports from agentic-flow
44
+ local imports=$(grep -r "from.*agentic-flow\|require.*agentic-flow" "$PROJECT_ROOT/v3" "$PROJECT_ROOT/src" 2>/dev/null | grep -v node_modules | wc -l)
45
+ [ "$imports" -gt 5 ] && score=$((score + 50))
46
+
47
+ echo "$score"
48
+ }
49
+
50
+ check_adr_002() {
51
+ # ADR-002: Domain-Driven Design structure
52
+ local score=0
53
+
54
+ # Check for domain directories
55
+ [ -d "$PROJECT_ROOT/v3" ] || [ -d "$PROJECT_ROOT/src/domains" ] && score=$((score + 30))
56
+
57
+ # Check for bounded contexts
58
+ local contexts=$(find "$PROJECT_ROOT/v3" "$PROJECT_ROOT/src" -type d -name "domain" 2>/dev/null | wc -l)
59
+ [ "$contexts" -gt 0 ] && score=$((score + 35))
60
+
61
+ # Check for anti-corruption layers
62
+ local acl=$(grep -r "AntiCorruption\|Adapter\|Port" "$PROJECT_ROOT/v3" "$PROJECT_ROOT/src" 2>/dev/null | grep -v node_modules | wc -l)
63
+ [ "$acl" -gt 0 ] && score=$((score + 35))
64
+
65
+ echo "$score"
66
+ }
67
+
68
+ check_adr_003() {
69
+ # ADR-003: Single coordination engine
70
+ local score=0
71
+
72
+ # Check for unified SwarmCoordinator
73
+ grep -rq "SwarmCoordinator\|UnifiedCoordinator" "$PROJECT_ROOT/v3" "$PROJECT_ROOT/src" 2>/dev/null && score=$((score + 50))
74
+
75
+ # Check for no duplicate coordinators
76
+ local coordinators=$(grep -r "class.*Coordinator" "$PROJECT_ROOT/v3" "$PROJECT_ROOT/src" 2>/dev/null | grep -v node_modules | grep -v ".test." | wc -l)
77
+ [ "$coordinators" -le 3 ] && score=$((score + 50))
78
+
79
+ echo "$score"
80
+ }
81
+
82
+ check_adr_005() {
83
+ # ADR-005: MCP-first API design
84
+ local score=0
85
+
86
+ # Check for MCP server implementation
87
+ [ -d "$PROJECT_ROOT/v3/@claude-flow/mcp" ] && score=$((score + 40))
88
+
89
+ # Check for MCP tools
90
+ local tools=$(grep -r "tool.*name\|registerTool" "$PROJECT_ROOT/v3" 2>/dev/null | wc -l)
91
+ [ "$tools" -gt 5 ] && score=$((score + 30))
92
+
93
+ # Check for MCP schemas
94
+ grep -rq "schema\|jsonSchema" "$PROJECT_ROOT/v3/@claude-flow/mcp" 2>/dev/null && score=$((score + 30))
95
+
96
+ echo "$score"
97
+ }
98
+
99
+ check_adr_008() {
100
+ # ADR-008: Vitest over Jest
101
+ local score=0
102
+
103
+ # Check for vitest in package.json
104
+ grep -q "vitest" "$PROJECT_ROOT/package.json" 2>/dev/null && score=$((score + 50))
105
+
106
+ # Check for no jest references
107
+ local jest_refs=$(grep -r "from.*jest\|jest\." "$PROJECT_ROOT/v3" "$PROJECT_ROOT/src" 2>/dev/null | grep -v node_modules | grep -v "vitest" | wc -l)
108
+ [ "$jest_refs" -eq 0 ] && score=$((score + 50))
109
+
110
+ echo "$score"
111
+ }
112
+
113
+ check_compliance() {
114
+ echo "[$(date +%H:%M:%S)] Checking ADR compliance..."
115
+
116
+ local total_score=0
117
+ local compliant_count=0
118
+ local results=""
119
+
120
+ # Check each ADR
121
+ local adr_001=$(check_adr_001)
122
+ local adr_002=$(check_adr_002)
123
+ local adr_003=$(check_adr_003)
124
+ local adr_005=$(check_adr_005)
125
+ local adr_008=$(check_adr_008)
126
+
127
+ # Simple checks for others (assume partial compliance)
128
+ local adr_004=50 # Plugin architecture
129
+ local adr_006=50 # Unified memory
130
+ local adr_007=50 # Event sourcing
131
+ local adr_009=75 # Hybrid memory
132
+ local adr_010=100 # No Deno (easy to verify)
133
+
134
+ # Calculate totals
135
+ for score in $adr_001 $adr_002 $adr_003 $adr_004 $adr_005 $adr_006 $adr_007 $adr_008 $adr_009 $adr_010; do
136
+ total_score=$((total_score + score))
137
+ [ "$score" -ge 50 ] && compliant_count=$((compliant_count + 1))
138
+ done
139
+
140
+ local avg_score=$((total_score / 10))
141
+
142
+ # Write ADR compliance metrics
143
+ cat > "$ADR_FILE" << EOF
144
+ {
145
+ "timestamp": "$(date -Iseconds)",
146
+ "overallCompliance": $avg_score,
147
+ "compliantCount": $compliant_count,
148
+ "totalADRs": 10,
149
+ "adrs": {
150
+ "ADR-001": {"score": $adr_001, "title": "agentic-flow as core foundation"},
151
+ "ADR-002": {"score": $adr_002, "title": "Domain-Driven Design structure"},
152
+ "ADR-003": {"score": $adr_003, "title": "Single coordination engine"},
153
+ "ADR-004": {"score": $adr_004, "title": "Plugin-based architecture"},
154
+ "ADR-005": {"score": $adr_005, "title": "MCP-first API design"},
155
+ "ADR-006": {"score": $adr_006, "title": "Unified memory service"},
156
+ "ADR-007": {"score": $adr_007, "title": "Event sourcing for state"},
157
+ "ADR-008": {"score": $adr_008, "title": "Vitest over Jest"},
158
+ "ADR-009": {"score": $adr_009, "title": "Hybrid memory backend"},
159
+ "ADR-010": {"score": $adr_010, "title": "Remove Deno support"}
160
+ }
161
+ }
162
+ EOF
163
+
164
+ echo "[$(date +%H:%M:%S)] ✓ ADR Compliance: ${avg_score}% | Compliant: $compliant_count/10"
165
+
166
+ date +%s > "$LAST_RUN_FILE"
167
+ }
168
+
169
+ case "${1:-check}" in
170
+ "run") check_compliance ;;
171
+ "check") should_run && check_compliance || echo "[$(date +%H:%M:%S)] Skipping (throttled)" ;;
172
+ "force") rm -f "$LAST_RUN_FILE"; check_compliance ;;
173
+ "status")
174
+ if [ -f "$ADR_FILE" ]; then
175
+ jq -r '"Compliance: \(.overallCompliance)% | Compliant: \(.compliantCount)/\(.totalADRs)"' "$ADR_FILE"
176
+ else
177
+ echo "No ADR data available"
178
+ fi
179
+ ;;
180
+ "details")
181
+ if [ -f "$ADR_FILE" ]; then
182
+ jq -r '.adrs | to_entries[] | "\(.key): \(.value.score)% - \(.value.title)"' "$ADR_FILE"
183
+ fi
184
+ ;;
185
+ *) echo "Usage: $0 [run|check|force|status|details]" ;;
186
+ esac
@@ -0,0 +1,178 @@
1
+ #!/bin/bash
2
+ # Auto-commit helper for Claude Code hooks
3
+ # Handles git add, commit, and push in a robust way
4
+
5
+ set -e
6
+
7
+ # Colors
8
+ GREEN='\033[0;32m'
9
+ YELLOW='\033[1;33m'
10
+ RED='\033[0;31m'
11
+ NC='\033[0m'
12
+
13
+ # Configuration
14
+ MIN_CHANGES=${MIN_CHANGES:-1}
15
+ COMMIT_PREFIX=${COMMIT_PREFIX:-"checkpoint"}
16
+ AUTO_PUSH=${AUTO_PUSH:-true}
17
+
18
+ log() {
19
+ echo -e "${GREEN}[auto-commit]${NC} $1"
20
+ }
21
+
22
+ warn() {
23
+ echo -e "${YELLOW}[auto-commit]${NC} $1"
24
+ }
25
+
26
+ error() {
27
+ echo -e "${RED}[auto-commit]${NC} $1"
28
+ }
29
+
30
+ # Check if there are changes to commit
31
+ has_changes() {
32
+ ! git diff --quiet HEAD 2>/dev/null || ! git diff --cached --quiet 2>/dev/null || [ -n "$(git ls-files --others --exclude-standard)" ]
33
+ }
34
+
35
+ # Count changes
36
+ count_changes() {
37
+ local staged=$(git diff --cached --numstat | wc -l)
38
+ local unstaged=$(git diff --numstat | wc -l)
39
+ local untracked=$(git ls-files --others --exclude-standard | wc -l)
40
+ echo $((staged + unstaged + untracked))
41
+ }
42
+
43
+ # Main auto-commit function
44
+ auto_commit() {
45
+ local message="$1"
46
+ local file="$2" # Optional specific file
47
+
48
+ # Check if in a git repo
49
+ if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
50
+ error "Not in a git repository"
51
+ return 1
52
+ fi
53
+
54
+ # Check for changes
55
+ if ! has_changes; then
56
+ log "No changes to commit"
57
+ return 0
58
+ fi
59
+
60
+ local change_count=$(count_changes)
61
+ if [ "$change_count" -lt "$MIN_CHANGES" ]; then
62
+ log "Only $change_count change(s), skipping (min: $MIN_CHANGES)"
63
+ return 0
64
+ fi
65
+
66
+ # Stage changes
67
+ if [ -n "$file" ] && [ -f "$file" ]; then
68
+ git add "$file"
69
+ log "Staged: $file"
70
+ else
71
+ git add -A
72
+ log "Staged all changes ($change_count files)"
73
+ fi
74
+
75
+ # Create commit message
76
+ local branch=$(git branch --show-current)
77
+ local timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)
78
+
79
+ if [ -z "$message" ]; then
80
+ message="$COMMIT_PREFIX: Auto-commit from Claude Code"
81
+ fi
82
+
83
+ # Commit
84
+ if git commit -m "$message
85
+
86
+ Automatic checkpoint created by Claude Code
87
+ - Branch: $branch
88
+ - Timestamp: $timestamp
89
+ - Changes: $change_count file(s)
90
+
91
+ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
92
+
93
+ Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>" --quiet 2>/dev/null; then
94
+ log "Created commit: $message"
95
+
96
+ # Push if enabled
97
+ if [ "$AUTO_PUSH" = "true" ]; then
98
+ if git push origin "$branch" --quiet 2>/dev/null; then
99
+ log "Pushed to origin/$branch"
100
+ else
101
+ warn "Push failed (will retry later)"
102
+ fi
103
+ fi
104
+
105
+ return 0
106
+ else
107
+ warn "Commit failed (possibly nothing to commit)"
108
+ return 1
109
+ fi
110
+ }
111
+
112
+ # Batch commit (commits all changes together)
113
+ batch_commit() {
114
+ local message="${1:-Batch checkpoint}"
115
+ auto_commit "$message"
116
+ }
117
+
118
+ # Single file commit
119
+ file_commit() {
120
+ local file="$1"
121
+ local message="${2:-Checkpoint: $file}"
122
+
123
+ if [ -z "$file" ]; then
124
+ error "No file specified"
125
+ return 1
126
+ fi
127
+
128
+ if [ ! -f "$file" ]; then
129
+ error "File not found: $file"
130
+ return 1
131
+ fi
132
+
133
+ auto_commit "$message" "$file"
134
+ }
135
+
136
+ # Push only (no commit)
137
+ push_only() {
138
+ local branch=$(git branch --show-current)
139
+
140
+ if git push origin "$branch" 2>/dev/null; then
141
+ log "Pushed to origin/$branch"
142
+ else
143
+ warn "Push failed"
144
+ return 1
145
+ fi
146
+ }
147
+
148
+ # Entry point
149
+ case "${1:-batch}" in
150
+ batch)
151
+ batch_commit "$2"
152
+ ;;
153
+ file)
154
+ file_commit "$2" "$3"
155
+ ;;
156
+ push)
157
+ push_only
158
+ ;;
159
+ check)
160
+ if has_changes; then
161
+ echo "Changes detected: $(count_changes) files"
162
+ exit 0
163
+ else
164
+ echo "No changes"
165
+ exit 1
166
+ fi
167
+ ;;
168
+ *)
169
+ echo "Usage: $0 {batch|file|push|check} [args]"
170
+ echo ""
171
+ echo "Commands:"
172
+ echo " batch [message] Commit all changes with optional message"
173
+ echo " file <path> [msg] Commit specific file"
174
+ echo " push Push without committing"
175
+ echo " check Check if there are uncommitted changes"
176
+ exit 1
177
+ ;;
178
+ esac