moflo 4.7.8 → 4.8.1

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 (77) hide show
  1. package/.claude/settings.local.json +4 -1
  2. package/.claude/workflow-state.json +3 -7
  3. package/README.md +3 -1
  4. package/bin/build-embeddings.mjs +59 -3
  5. package/bin/generate-code-map.mjs +3 -1
  6. package/bin/hooks.mjs +23 -20
  7. package/bin/index-guidance.mjs +3 -1
  8. package/bin/lib/moflo-resolve.mjs +14 -0
  9. package/bin/semantic-search.mjs +10 -5
  10. package/bin/session-start-launcher.mjs +116 -3
  11. package/package.json +6 -6
  12. package/src/@claude-flow/cli/dist/src/appliance/ruvllm-bridge.js +3 -7
  13. package/src/@claude-flow/cli/dist/src/commands/daemon.js +42 -95
  14. package/src/@claude-flow/cli/dist/src/commands/doctor.js +127 -6
  15. package/src/@claude-flow/cli/dist/src/commands/embeddings.js +4 -3
  16. package/src/@claude-flow/cli/dist/src/commands/hooks.js +3 -2
  17. package/src/@claude-flow/cli/dist/src/commands/mcp.js +38 -22
  18. package/src/@claude-flow/cli/dist/src/commands/memory.js +2 -1
  19. package/src/@claude-flow/cli/dist/src/commands/neural.js +10 -5
  20. package/src/@claude-flow/cli/dist/src/config/moflo-config.d.ts +5 -0
  21. package/src/@claude-flow/cli/dist/src/config/moflo-config.js +16 -0
  22. package/src/@claude-flow/cli/dist/src/index.js +12 -0
  23. package/src/@claude-flow/cli/dist/src/init/executor.js +74 -0
  24. package/src/@claude-flow/cli/dist/src/init/moflo-init.js +49 -0
  25. package/src/@claude-flow/cli/dist/src/mcp-tools/memory-tools.js +2 -2
  26. package/src/@claude-flow/cli/dist/src/mcp-tools/neural-tools.js +2 -1
  27. package/src/@claude-flow/cli/dist/src/memory/memory-bridge.js +5 -1
  28. package/src/@claude-flow/cli/dist/src/memory/memory-initializer.js +29 -24
  29. package/src/@claude-flow/cli/dist/src/ruvector/ast-analyzer.js +2 -1
  30. package/src/@claude-flow/cli/dist/src/ruvector/coverage-router.js +2 -1
  31. package/src/@claude-flow/cli/dist/src/ruvector/diff-classifier.js +2 -1
  32. package/src/@claude-flow/cli/dist/src/ruvector/enhanced-model-router.js +3 -3
  33. package/src/@claude-flow/cli/dist/src/ruvector/index.js +6 -13
  34. package/src/@claude-flow/cli/dist/src/ruvector/q-learning-router.js +4 -1
  35. package/src/@claude-flow/cli/dist/src/services/daemon-lock.d.ts +39 -0
  36. package/src/@claude-flow/cli/dist/src/services/daemon-lock.js +213 -0
  37. package/src/@claude-flow/cli/dist/src/services/learning-service.js +2 -1
  38. package/src/@claude-flow/cli/dist/src/services/moflo-require.d.ts +34 -0
  39. package/src/@claude-flow/cli/dist/src/services/moflo-require.js +67 -0
  40. package/src/@claude-flow/cli/dist/src/services/ruvector-training.js +8 -6
  41. package/src/@claude-flow/cli/package.json +6 -6
  42. package/.claude/helpers/README.md +0 -97
  43. package/.claude/helpers/adr-compliance.sh +0 -186
  44. package/.claude/helpers/aggressive-microcompact.mjs +0 -36
  45. package/.claude/helpers/auto-commit.sh +0 -178
  46. package/.claude/helpers/checkpoint-manager.sh +0 -251
  47. package/.claude/helpers/context-persistence-hook.mjs +0 -1979
  48. package/.claude/helpers/daemon-manager.sh +0 -252
  49. package/.claude/helpers/ddd-tracker.sh +0 -144
  50. package/.claude/helpers/github-safe.js +0 -106
  51. package/.claude/helpers/github-setup.sh +0 -28
  52. package/.claude/helpers/guidance-hook.sh +0 -13
  53. package/.claude/helpers/guidance-hooks.sh +0 -102
  54. package/.claude/helpers/health-monitor.sh +0 -108
  55. package/.claude/helpers/learning-hooks.sh +0 -329
  56. package/.claude/helpers/learning-optimizer.sh +0 -127
  57. package/.claude/helpers/learning-service.mjs +0 -1211
  58. package/.claude/helpers/memory.cjs +0 -84
  59. package/.claude/helpers/metrics-db.mjs +0 -492
  60. package/.claude/helpers/patch-aggressive-prune.mjs +0 -184
  61. package/.claude/helpers/pattern-consolidator.sh +0 -86
  62. package/.claude/helpers/perf-worker.sh +0 -160
  63. package/.claude/helpers/quick-start.sh +0 -19
  64. package/.claude/helpers/router.cjs +0 -62
  65. package/.claude/helpers/security-scanner.sh +0 -127
  66. package/.claude/helpers/session.cjs +0 -125
  67. package/.claude/helpers/setup-mcp.sh +0 -18
  68. package/.claude/helpers/standard-checkpoint-hooks.sh +0 -189
  69. package/.claude/helpers/swarm-comms.sh +0 -353
  70. package/.claude/helpers/swarm-hooks.sh +0 -761
  71. package/.claude/helpers/swarm-monitor.sh +0 -211
  72. package/.claude/helpers/sync-v3-metrics.sh +0 -245
  73. package/.claude/helpers/update-v3-progress.sh +0 -166
  74. package/.claude/helpers/v3-quick-status.sh +0 -58
  75. package/.claude/helpers/v3.sh +0 -111
  76. package/.claude/helpers/validate-v3-config.sh +0 -216
  77. package/.claude/helpers/worker-manager.sh +0 -170
@@ -1,184 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Patch: Aggressive Text Pruning for Claude Code
4
- *
5
- * Extends Claude Code's micro-compaction (Vd function) to also prune old
6
- * user/assistant TEXT content, not just tool results. This keeps context
7
- * lean and prevents full compaction from ever being needed.
8
- *
9
- * What it does:
10
- * After Vd() runs (pruning tool results), this patch adds a second pass
11
- * that truncates old conversation text. It keeps the last N turns intact
12
- * and replaces older text with brief summaries.
13
- *
14
- * How it works:
15
- * Patches cli.js to insert a textPrune() function call after Vd().
16
- * The function:
17
- * 1. Counts total text tokens in the message array
18
- * 2. If above threshold (configurable via CLAUDE_TEXT_PRUNE_THRESHOLD)
19
- * 3. Keeps the last CLAUDE_TEXT_PRUNE_KEEP turns intact
20
- * 4. Truncates older text blocks to first line + "[earlier context pruned]"
21
- * 5. Preserves tool_use/tool_result structure (never breaks the API contract)
22
- *
23
- * Safety:
24
- * - Only modifies text content blocks, never tool_use or tool_result
25
- * - Always keeps last N turns fully intact
26
- * - Preserves message structure (role, type, ids)
27
- * - Falls back gracefully if anything fails
28
- * - Can be reverted by running: node patch-aggressive-prune.mjs --revert
29
- *
30
- * Usage:
31
- * node patch-aggressive-prune.mjs # Apply patch
32
- * node patch-aggressive-prune.mjs --revert # Revert patch
33
- * node patch-aggressive-prune.mjs --check # Check if patched
34
- */
35
-
36
- import { readFileSync, writeFileSync, copyFileSync, existsSync } from 'fs';
37
- import { join, dirname } from 'path';
38
- import { fileURLToPath } from 'url';
39
-
40
- const __filename = fileURLToPath(import.meta.url);
41
- const __dirname = dirname(__filename);
42
- const PROJECT_ROOT = join(__dirname, '../..');
43
- const CLI_PATH = join(PROJECT_ROOT, 'node_modules/@anthropic-ai/claude-agent-sdk/cli.js');
44
- const BACKUP_PATH = CLI_PATH + '.backup';
45
-
46
- const PATCH_MARKER = '/*AGGRESSIVE_TEXT_PRUNE_PATCH*/';
47
-
48
- // The text pruning function to inject
49
- const TEXT_PRUNE_FUNCTION = `
50
- /*AGGRESSIVE_TEXT_PRUNE_PATCH*/
51
- function _aggressiveTextPrune(messages) {
52
- try {
53
- var KEEP = parseInt(process.env.CLAUDE_TEXT_PRUNE_KEEP || '10', 10);
54
- var THRESHOLD = parseInt(process.env.CLAUDE_TEXT_PRUNE_THRESHOLD || '60000', 10);
55
- var MAX_OLD_TEXT = parseInt(process.env.CLAUDE_TEXT_PRUNE_MAX_CHARS || '150', 10);
56
-
57
- // Count text tokens roughly (4 chars per token)
58
- var totalChars = 0;
59
- for (var i = 0; i < messages.length; i++) {
60
- var m = messages[i];
61
- if ((m.type === 'user' || m.type === 'assistant') && Array.isArray(m.message?.content)) {
62
- for (var j = 0; j < m.message.content.length; j++) {
63
- var c = m.message.content[j];
64
- if (c.type === 'text') totalChars += (c.text || '').length;
65
- }
66
- }
67
- }
68
-
69
- var totalTokensEst = Math.ceil(totalChars / 4);
70
- if (totalTokensEst < THRESHOLD) return messages;
71
-
72
- // Find turn boundaries (user message = new turn)
73
- var turnStarts = [];
74
- for (var i = 0; i < messages.length; i++) {
75
- if (messages[i].type === 'user') turnStarts.push(i);
76
- }
77
-
78
- // Keep last KEEP turns intact
79
- var cutoffIdx = turnStarts.length > KEEP ? turnStarts[turnStarts.length - KEEP] : 0;
80
- if (cutoffIdx === 0) return messages;
81
-
82
- var pruned = [];
83
- var prunedChars = 0;
84
- for (var i = 0; i < messages.length; i++) {
85
- var m = messages[i];
86
- if (i >= cutoffIdx) {
87
- pruned.push(m);
88
- continue;
89
- }
90
- if ((m.type === 'user' || m.type === 'assistant') && Array.isArray(m.message?.content)) {
91
- var newContent = [];
92
- for (var j = 0; j < m.message.content.length; j++) {
93
- var c = m.message.content[j];
94
- if (c.type === 'text' && c.text && c.text.length > MAX_OLD_TEXT) {
95
- var firstLine = c.text.split('\\n')[0].slice(0, MAX_OLD_TEXT);
96
- prunedChars += c.text.length - firstLine.length - 30;
97
- newContent.push({ ...c, text: firstLine + '\\n[earlier context pruned]' });
98
- } else {
99
- newContent.push(c);
100
- }
101
- }
102
- pruned.push({ ...m, message: { ...m.message, content: newContent } });
103
- } else {
104
- pruned.push(m);
105
- }
106
- }
107
-
108
- if (prunedChars > 1000) {
109
- process.stderr?.write?.('[TextPrune] Pruned ~' + Math.round(prunedChars/4) + ' tokens of old text (kept last ' + KEEP + ' turns)\\n');
110
- }
111
- return pruned;
112
- } catch(e) {
113
- return messages;
114
- }
115
- }
116
- /*END_AGGRESSIVE_TEXT_PRUNE_PATCH*/`;
117
-
118
- // The injection point: after Vd() call, before CT2() call
119
- const VD_CALL_PATTERN = 'z=await Vd(F,void 0,Y);if(F=z.messages,';
120
- const PATCHED_PATTERN = 'z=await Vd(F,void 0,Y);if(F=_aggressiveTextPrune(z.messages),';
121
-
122
- function check() {
123
- const src = readFileSync(CLI_PATH, 'utf8');
124
- const isPatched = src.includes(PATCH_MARKER);
125
- console.log(isPatched ? 'PATCHED' : 'NOT PATCHED');
126
- return isPatched;
127
- }
128
-
129
- function apply() {
130
- if (check()) {
131
- console.log('Already patched. Use --revert first to re-apply.');
132
- return;
133
- }
134
-
135
- const src = readFileSync(CLI_PATH, 'utf8');
136
-
137
- // Verify the injection point exists
138
- if (!src.includes(VD_CALL_PATTERN)) {
139
- console.error('ERROR: Could not find Vd() call pattern in cli.js.');
140
- console.error('Claude Code may have been updated. Pattern expected:');
141
- console.error(' ' + VD_CALL_PATTERN);
142
- process.exit(1);
143
- }
144
-
145
- // Backup
146
- if (!existsSync(BACKUP_PATH)) {
147
- copyFileSync(CLI_PATH, BACKUP_PATH);
148
- console.log('Backup saved to:', BACKUP_PATH);
149
- }
150
-
151
- // Inject the function at the top of the file (after the first line)
152
- let patched = src;
153
- const firstNewline = patched.indexOf('\n');
154
- patched = patched.slice(0, firstNewline + 1) + TEXT_PRUNE_FUNCTION + '\n' + patched.slice(firstNewline + 1);
155
-
156
- // Patch the Vd() call site to also run our text pruner
157
- patched = patched.replace(VD_CALL_PATTERN, PATCHED_PATTERN);
158
-
159
- writeFileSync(CLI_PATH, patched);
160
- console.log('PATCH APPLIED successfully.');
161
- console.log('');
162
- console.log('Configuration (via env vars in settings.json):');
163
- console.log(' CLAUDE_TEXT_PRUNE_KEEP=10 # Keep last N turns intact');
164
- console.log(' CLAUDE_TEXT_PRUNE_THRESHOLD=60000 # Start pruning above this token count');
165
- console.log(' CLAUDE_TEXT_PRUNE_MAX_CHARS=150 # Truncate old text to this many chars');
166
- console.log('');
167
- console.log('Restart Claude Code for the patch to take effect.');
168
- }
169
-
170
- function revert() {
171
- if (!existsSync(BACKUP_PATH)) {
172
- console.error('No backup found at:', BACKUP_PATH);
173
- console.error('Cannot revert. Reinstall with: npm install @anthropic-ai/claude-agent-sdk');
174
- process.exit(1);
175
- }
176
-
177
- copyFileSync(BACKUP_PATH, CLI_PATH);
178
- console.log('REVERTED to original cli.js from backup.');
179
- }
180
-
181
- const arg = process.argv[2];
182
- if (arg === '--revert') revert();
183
- else if (arg === '--check') check();
184
- else apply();
@@ -1,86 +0,0 @@
1
- #!/bin/bash
2
- # RuFlo V3 - Pattern Consolidator Worker
3
- # Deduplicates patterns, prunes old ones, improves quality scores
4
-
5
- set -euo pipefail
6
-
7
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
- PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
9
- PATTERNS_DB="$PROJECT_ROOT/.claude-flow/learning/patterns.db"
10
- METRICS_DIR="$PROJECT_ROOT/.claude-flow/metrics"
11
- LAST_RUN_FILE="$METRICS_DIR/.consolidator-last-run"
12
-
13
- mkdir -p "$METRICS_DIR"
14
-
15
- should_run() {
16
- if [ ! -f "$LAST_RUN_FILE" ]; then return 0; fi
17
- local last_run=$(cat "$LAST_RUN_FILE" 2>/dev/null || echo "0")
18
- local now=$(date +%s)
19
- [ $((now - last_run)) -ge 900 ] # 15 minutes
20
- }
21
-
22
- consolidate_patterns() {
23
- if [ ! -f "$PATTERNS_DB" ] || ! command -v sqlite3 &>/dev/null; then
24
- echo "[$(date +%H:%M:%S)] No patterns database found"
25
- return 0
26
- fi
27
-
28
- echo "[$(date +%H:%M:%S)] Consolidating patterns..."
29
-
30
- # Count before
31
- local before=$(sqlite3 "$PATTERNS_DB" "SELECT COUNT(*) FROM short_term_patterns" 2>/dev/null || echo "0")
32
-
33
- # Remove duplicates (keep highest quality)
34
- sqlite3 "$PATTERNS_DB" "
35
- DELETE FROM short_term_patterns
36
- WHERE rowid NOT IN (
37
- SELECT MIN(rowid) FROM short_term_patterns
38
- GROUP BY strategy, domain
39
- )
40
- " 2>/dev/null || true
41
-
42
- # Prune old low-quality patterns (older than 7 days, quality < 0.3)
43
- sqlite3 "$PATTERNS_DB" "
44
- DELETE FROM short_term_patterns
45
- WHERE quality < 0.3
46
- AND created_at < datetime('now', '-7 days')
47
- " 2>/dev/null || true
48
-
49
- # Promote high-quality patterns to long-term (quality > 0.8, used > 5 times)
50
- sqlite3 "$PATTERNS_DB" "
51
- INSERT OR IGNORE INTO long_term_patterns (strategy, domain, quality, source)
52
- SELECT strategy, domain, quality, 'consolidated'
53
- FROM short_term_patterns
54
- WHERE quality > 0.8
55
- " 2>/dev/null || true
56
-
57
- # Decay quality of unused patterns
58
- sqlite3 "$PATTERNS_DB" "
59
- UPDATE short_term_patterns
60
- SET quality = quality * 0.95
61
- WHERE updated_at < datetime('now', '-1 day')
62
- " 2>/dev/null || true
63
-
64
- # Count after
65
- local after=$(sqlite3 "$PATTERNS_DB" "SELECT COUNT(*) FROM short_term_patterns" 2>/dev/null || echo "0")
66
- local removed=$((before - after))
67
-
68
- echo "[$(date +%H:%M:%S)] ✓ Consolidated: $before → $after patterns (removed $removed)"
69
-
70
- date +%s > "$LAST_RUN_FILE"
71
- }
72
-
73
- case "${1:-check}" in
74
- "run"|"consolidate") consolidate_patterns ;;
75
- "check") should_run && consolidate_patterns || echo "[$(date +%H:%M:%S)] Skipping (throttled)" ;;
76
- "force") rm -f "$LAST_RUN_FILE"; consolidate_patterns ;;
77
- "status")
78
- if [ -f "$PATTERNS_DB" ] && command -v sqlite3 &>/dev/null; then
79
- local short=$(sqlite3 "$PATTERNS_DB" "SELECT COUNT(*) FROM short_term_patterns" 2>/dev/null || echo "0")
80
- local long=$(sqlite3 "$PATTERNS_DB" "SELECT COUNT(*) FROM long_term_patterns" 2>/dev/null || echo "0")
81
- local avg_q=$(sqlite3 "$PATTERNS_DB" "SELECT ROUND(AVG(quality), 2) FROM short_term_patterns" 2>/dev/null || echo "0")
82
- echo "Patterns: $short short-term, $long long-term, avg quality: $avg_q"
83
- fi
84
- ;;
85
- *) echo "Usage: $0 [run|check|force|status]" ;;
86
- esac
@@ -1,160 +0,0 @@
1
- #!/bin/bash
2
- # RuFlo V3 - Performance Benchmark Worker
3
- # Runs periodic benchmarks and updates metrics using agentic-flow agents
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
- PERF_FILE="$METRICS_DIR/performance.json"
11
- LAST_RUN_FILE="$METRICS_DIR/.perf-last-run"
12
-
13
- mkdir -p "$METRICS_DIR"
14
-
15
- # Check if we should run (throttle to once per 5 minutes)
16
- should_run() {
17
- if [ ! -f "$LAST_RUN_FILE" ]; then
18
- return 0
19
- fi
20
-
21
- local last_run=$(cat "$LAST_RUN_FILE" 2>/dev/null || echo "0")
22
- local now=$(date +%s)
23
- local diff=$((now - last_run))
24
-
25
- # Run every 5 minutes (300 seconds)
26
- [ "$diff" -ge 300 ]
27
- }
28
-
29
- # Simple search benchmark (measures grep/search speed)
30
- benchmark_search() {
31
- local start=$(date +%s%3N)
32
-
33
- # Search through v3 codebase
34
- find "$PROJECT_ROOT/v3" -name "*.ts" -type f 2>/dev/null | \
35
- xargs grep -l "function\|class\|interface" 2>/dev/null | \
36
- wc -l > /dev/null
37
-
38
- local end=$(date +%s%3N)
39
- local duration=$((end - start))
40
-
41
- # Baseline is ~100ms, calculate improvement
42
- local baseline=100
43
- if [ "$duration" -gt 0 ]; then
44
- local improvement=$(echo "scale=2; $baseline / $duration" | bc 2>/dev/null || echo "1.0")
45
- echo "${improvement}x"
46
- else
47
- echo "1.0x"
48
- fi
49
- }
50
-
51
- # Memory efficiency check
52
- benchmark_memory() {
53
- local node_mem=$(ps aux 2>/dev/null | grep -E "(node|agentic)" | grep -v grep | awk '{sum += $6} END {print int(sum/1024)}')
54
- local baseline_mem=4000 # 4GB baseline
55
-
56
- if [ -n "$node_mem" ] && [ "$node_mem" -gt 0 ]; then
57
- local reduction=$(echo "scale=0; 100 - ($node_mem * 100 / $baseline_mem)" | bc 2>/dev/null || echo "0")
58
- if [ "$reduction" -lt 0 ]; then reduction=0; fi
59
- echo "${reduction}%"
60
- else
61
- echo "0%"
62
- fi
63
- }
64
-
65
- # Startup time check
66
- benchmark_startup() {
67
- local start=$(date +%s%3N)
68
-
69
- # Quick check of agentic-flow responsiveness
70
- timeout 5 npx agentic-flow@alpha --version >/dev/null 2>&1 || true
71
-
72
- local end=$(date +%s%3N)
73
- local duration=$((end - start))
74
-
75
- echo "${duration}ms"
76
- }
77
-
78
- # Run benchmarks and update metrics
79
- run_benchmarks() {
80
- echo "[$(date +%H:%M:%S)] Running performance benchmarks..."
81
-
82
- local search_speed=$(benchmark_search)
83
- local memory_reduction=$(benchmark_memory)
84
- local startup_time=$(benchmark_startup)
85
-
86
- # Calculate overall speedup (simplified)
87
- local speedup_num=$(echo "$search_speed" | tr -d 'x')
88
- if [ -z "$speedup_num" ] || [ "$speedup_num" = "1.0" ]; then
89
- speedup_num="1.0"
90
- fi
91
-
92
- # Update performance.json
93
- if [ -f "$PERF_FILE" ] && command -v jq &>/dev/null; then
94
- jq --arg search "$search_speed" \
95
- --arg memory "$memory_reduction" \
96
- --arg startup "$startup_time" \
97
- --arg speedup "${speedup_num}x" \
98
- --arg updated "$(date -Iseconds)" \
99
- '.search.improvement = $search |
100
- .memory.reduction = $memory |
101
- .startupTime.current = $startup |
102
- .flashAttention.speedup = $speedup |
103
- ."last-updated" = $updated' \
104
- "$PERF_FILE" > "$PERF_FILE.tmp" && mv "$PERF_FILE.tmp" "$PERF_FILE"
105
-
106
- echo "[$(date +%H:%M:%S)] ✓ Metrics updated: search=$search_speed memory=$memory_reduction startup=$startup_time"
107
- else
108
- echo "[$(date +%H:%M:%S)] ⚠ Could not update metrics (missing jq or file)"
109
- fi
110
-
111
- # Record last run time
112
- date +%s > "$LAST_RUN_FILE"
113
- }
114
-
115
- # Spawn agentic-flow performance agent for deep analysis
116
- run_deep_benchmark() {
117
- echo "[$(date +%H:%M:%S)] Spawning performance-benchmarker agent..."
118
-
119
- npx agentic-flow@alpha --agent perf-analyzer --task "Analyze current system performance and update metrics" 2>/dev/null &
120
- local pid=$!
121
-
122
- # Don't wait, let it run in background
123
- echo "[$(date +%H:%M:%S)] Agent spawned (PID: $pid)"
124
- }
125
-
126
- # Main dispatcher
127
- case "${1:-check}" in
128
- "run"|"benchmark")
129
- run_benchmarks
130
- ;;
131
- "deep")
132
- run_deep_benchmark
133
- ;;
134
- "check")
135
- if should_run; then
136
- run_benchmarks
137
- else
138
- echo "[$(date +%H:%M:%S)] Skipping benchmark (throttled)"
139
- fi
140
- ;;
141
- "force")
142
- rm -f "$LAST_RUN_FILE"
143
- run_benchmarks
144
- ;;
145
- "status")
146
- if [ -f "$PERF_FILE" ]; then
147
- jq -r '"Search: \(.search.improvement // "1x") | Memory: \(.memory.reduction // "0%") | Startup: \(.startupTime.current // "N/A")"' "$PERF_FILE" 2>/dev/null
148
- else
149
- echo "No metrics available"
150
- fi
151
- ;;
152
- *)
153
- echo "Usage: perf-worker.sh [run|deep|check|force|status]"
154
- echo " run - Run quick benchmarks"
155
- echo " deep - Spawn agentic-flow agent for deep analysis"
156
- echo " check - Run if throttle allows (default)"
157
- echo " force - Force run ignoring throttle"
158
- echo " status - Show current metrics"
159
- ;;
160
- esac
@@ -1,19 +0,0 @@
1
- #!/bin/bash
2
- # Quick start guide for Claude Flow
3
-
4
- echo "🚀 Claude Flow Quick Start"
5
- echo "=========================="
6
- echo ""
7
- echo "1. Initialize a swarm:"
8
- echo " npx claude-flow swarm init --topology hierarchical"
9
- echo ""
10
- echo "2. Spawn agents:"
11
- echo " npx claude-flow agent spawn --type coder --name "API Developer""
12
- echo ""
13
- echo "3. Orchestrate tasks:"
14
- echo " npx claude-flow task orchestrate --task "Build REST API""
15
- echo ""
16
- echo "4. Monitor progress:"
17
- echo " npx claude-flow swarm monitor"
18
- echo ""
19
- echo "📚 For more examples, see .claude/commands/"
@@ -1,62 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * Claude Flow Agent Router
4
- * Routes tasks to optimal agents based on learned patterns
5
- */
6
-
7
- const AGENT_CAPABILITIES = {
8
- coder: ['code-generation', 'refactoring', 'debugging', 'implementation'],
9
- tester: ['unit-testing', 'integration-testing', 'coverage', 'test-generation'],
10
- reviewer: ['code-review', 'security-audit', 'quality-check', 'best-practices'],
11
- researcher: ['web-search', 'documentation', 'analysis', 'summarization'],
12
- architect: ['system-design', 'architecture', 'patterns', 'scalability'],
13
- 'backend-dev': ['api', 'database', 'server', 'authentication'],
14
- 'frontend-dev': ['ui', 'react', 'css', 'components'],
15
- devops: ['ci-cd', 'docker', 'deployment', 'infrastructure'],
16
- };
17
-
18
- const TASK_PATTERNS = {
19
- 'implement|create|build|add|write code': 'coder',
20
- 'test|spec|coverage|unit test|integration': 'tester',
21
- 'review|audit|check|validate|security': 'reviewer',
22
- 'research|find|search|documentation|explore': 'researcher',
23
- 'design|architect|structure|plan': 'architect',
24
- 'api|endpoint|server|backend|database': 'backend-dev',
25
- 'ui|frontend|component|react|css|style': 'frontend-dev',
26
- 'deploy|docker|ci|cd|pipeline|infrastructure': 'devops',
27
- };
28
-
29
- function routeTask(task) {
30
- const taskLower = task.toLowerCase();
31
-
32
- for (const [pattern, agent] of Object.entries(TASK_PATTERNS)) {
33
- const regex = new RegExp(pattern, 'i');
34
- if (regex.test(taskLower)) {
35
- return {
36
- agent,
37
- confidence: 0.8,
38
- reason: `Matched pattern: ${pattern}`,
39
- };
40
- }
41
- }
42
-
43
- return {
44
- agent: 'coder',
45
- confidence: 0.5,
46
- reason: 'Default routing - no specific pattern matched',
47
- };
48
- }
49
-
50
- module.exports = { routeTask, AGENT_CAPABILITIES, TASK_PATTERNS };
51
-
52
- // CLI - only run when executed directly
53
- if (require.main === module) {
54
- const task = process.argv.slice(2).join(' ');
55
- if (task) {
56
- const result = routeTask(task);
57
- console.log(JSON.stringify(result, null, 2));
58
- } else {
59
- console.log('Usage: router.js <task description>');
60
- console.log('\nAvailable agents:', Object.keys(AGENT_CAPABILITIES).join(', '));
61
- }
62
- }
@@ -1,127 +0,0 @@
1
- #!/bin/bash
2
- # RuFlo V3 - Security Scanner Worker
3
- # Scans for secrets, vulnerabilities, CVE updates
4
-
5
- set -euo pipefail
6
-
7
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
- PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
9
- SECURITY_DIR="$PROJECT_ROOT/.claude-flow/security"
10
- SCAN_FILE="$SECURITY_DIR/scan-results.json"
11
- LAST_RUN_FILE="$SECURITY_DIR/.scanner-last-run"
12
-
13
- mkdir -p "$SECURITY_DIR"
14
-
15
- should_run() {
16
- if [ ! -f "$LAST_RUN_FILE" ]; then return 0; fi
17
- local last_run=$(cat "$LAST_RUN_FILE" 2>/dev/null || echo "0")
18
- local now=$(date +%s)
19
- [ $((now - last_run)) -ge 1800 ] # 30 minutes
20
- }
21
-
22
- scan_secrets() {
23
- local secrets_found=0
24
- local patterns=(
25
- "password\s*=\s*['\"][^'\"]+['\"]"
26
- "api[_-]?key\s*=\s*['\"][^'\"]+['\"]"
27
- "secret\s*=\s*['\"][^'\"]+['\"]"
28
- "token\s*=\s*['\"][^'\"]+['\"]"
29
- "private[_-]?key"
30
- )
31
-
32
- for pattern in "${patterns[@]}"; do
33
- local count=$(grep -riE "$pattern" "$PROJECT_ROOT/src" "$PROJECT_ROOT/v3" 2>/dev/null | grep -v node_modules | grep -v ".git" | wc -l | tr -d '[:space:]')
34
- count=${count:-0}
35
- secrets_found=$((secrets_found + count))
36
- done
37
-
38
- echo "$secrets_found"
39
- }
40
-
41
- scan_vulnerabilities() {
42
- local vulns=0
43
-
44
- # Check for known vulnerable patterns
45
- # SQL injection patterns
46
- local sql_count=$(grep -rE "execute\s*\(" "$PROJECT_ROOT/src" "$PROJECT_ROOT/v3" 2>/dev/null | grep -v node_modules | grep -v ".test." | wc -l | tr -d '[:space:]')
47
- vulns=$((vulns + ${sql_count:-0}))
48
-
49
- # Command injection patterns
50
- local cmd_count=$(grep -rE "exec\s*\(|spawn\s*\(" "$PROJECT_ROOT/src" "$PROJECT_ROOT/v3" 2>/dev/null | grep -v node_modules | grep -v ".test." | wc -l | tr -d '[:space:]')
51
- vulns=$((vulns + ${cmd_count:-0}))
52
-
53
- # Unsafe eval
54
- local eval_count=$(grep -rE "\beval\s*\(" "$PROJECT_ROOT/src" "$PROJECT_ROOT/v3" 2>/dev/null | grep -v node_modules | wc -l | tr -d '[:space:]')
55
- vulns=$((vulns + ${eval_count:-0}))
56
-
57
- echo "$vulns"
58
- }
59
-
60
- check_npm_audit() {
61
- if [ -f "$PROJECT_ROOT/package-lock.json" ]; then
62
- # Skip npm audit for speed - it's slow
63
- echo "0"
64
- else
65
- echo "0"
66
- fi
67
- }
68
-
69
- run_scan() {
70
- echo "[$(date +%H:%M:%S)] Running security scan..."
71
-
72
- local secrets=$(scan_secrets)
73
- local vulns=$(scan_vulnerabilities)
74
- local npm_vulns=$(check_npm_audit)
75
-
76
- local total_issues=$((secrets + vulns + npm_vulns))
77
- local status="clean"
78
-
79
- if [ "$total_issues" -gt 10 ]; then
80
- status="critical"
81
- elif [ "$total_issues" -gt 0 ]; then
82
- status="warning"
83
- fi
84
-
85
- # Update audit status
86
- cat > "$SCAN_FILE" << EOF
87
- {
88
- "status": "$status",
89
- "timestamp": "$(date -Iseconds)",
90
- "findings": {
91
- "secrets": $secrets,
92
- "vulnerabilities": $vulns,
93
- "npm_audit": $npm_vulns,
94
- "total": $total_issues
95
- },
96
- "cves": {
97
- "tracked": ["CVE-1", "CVE-2", "CVE-3"],
98
- "remediated": 3
99
- }
100
- }
101
- EOF
102
-
103
- # Update main audit status file
104
- if [ "$status" = "clean" ]; then
105
- echo '{"status":"CLEAN","cvesFixed":3}' > "$SECURITY_DIR/audit-status.json"
106
- else
107
- echo "{\"status\":\"$status\",\"cvesFixed\":3,\"issues\":$total_issues}" > "$SECURITY_DIR/audit-status.json"
108
- fi
109
-
110
- echo "[$(date +%H:%M:%S)] ✓ Security: $status | Secrets: $secrets | Vulns: $vulns | NPM: $npm_vulns"
111
-
112
- date +%s > "$LAST_RUN_FILE"
113
- }
114
-
115
- case "${1:-check}" in
116
- "run"|"scan") run_scan ;;
117
- "check") should_run && run_scan || echo "[$(date +%H:%M:%S)] Skipping (throttled)" ;;
118
- "force") rm -f "$LAST_RUN_FILE"; run_scan ;;
119
- "status")
120
- if [ -f "$SCAN_FILE" ]; then
121
- jq -r '"Status: \(.status) | Secrets: \(.findings.secrets) | Vulns: \(.findings.vulnerabilities) | NPM: \(.findings.npm_audit)"' "$SCAN_FILE"
122
- else
123
- echo "No scan data available"
124
- fi
125
- ;;
126
- *) echo "Usage: $0 [run|check|force|status]" ;;
127
- esac