π The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
Checkpoint: File edits
rUv66640919cd3a
diff --git a/v3/@claude-flow/cli/.claude/helpers/statusline.cjs b/v3/@claude-flow/cli/.claude/helpers/statusline.cjsindex 45bd2bb6c8..7466b3786e 100644--- a/v3/@claude-flow/cli/.claude/helpers/statusline.cjs+++ b/v3/@claude-flow/cli/.claude/helpers/statusline.cjs@@ -27,10 +27,6 @@ const CONFIG = {topology: 'hierarchical-mesh',};-// Cross-platform helpers-const isWindows = process.platform === 'win32';-const nullDevice = isWindows ? 'NUL' : '/dev/null';-// ANSI colorsconst c = {reset: '\x1b[0m',@@ -58,15 +54,8 @@ function getUserInfo() {let modelName = 'Unknown';try {- const gitUserCmd = isWindows- ? 'git config user.name 2>NUL || echo user'- : 'git config user.name 2>/dev/null || echo "user"';- const gitBranchCmd = isWindows- ? 'git branch --show-current 2>NUL || echo.'- : 'git branch --show-current 2>/dev/null || echo ""';- name = execSync(gitUserCmd, { encoding: 'utf-8' }).trim();- gitBranch = execSync(gitBranchCmd, { encoding: 'utf-8' }).trim();- if (gitBranch === '.') gitBranch = ''; // Windows echo. outputs a dot+ name = execSync('git config user.name 2>/dev/null || echo "user"', { encoding: 'utf-8' }).trim();+ gitBranch = execSync('git branch --show-current 2>/dev/null || echo ""', { encoding: 'utf-8' }).trim();} catch (e) {// Ignore errors}@@ -235,17 +224,11 @@ function getSwarmStatus() {let coordinationActive = false;try {- if (isWindows) {- // Windows: use tasklist and findstr- const ps = execSync('tasklist 2>NUL | findstr /I "agentic-flow" 2>NUL | find /C /V "" 2>NUL || echo 0', { encoding: 'utf-8' });- activeAgents = Math.max(0, parseInt(ps.trim()) || 0);- } else {- const ps = execSync('ps aux 2>/dev/null | grep -c agentic-flow || echo "0"', { encoding: 'utf-8' });- activeAgents = Math.max(0, parseInt(ps.trim()) - 1);- }+ const ps = execSync('ps aux 2>/dev/null | grep -c agentic-flow || echo "0"', { encoding: 'utf-8' });+ activeAgents = Math.max(0, parseInt(ps.trim()) - 1);coordinationActive = activeAgents > 0;} catch (e) {- // Ignore errors - default to 0 agents+ // Ignore errors}return {@@ -261,14 +244,8 @@ function getSystemMetrics() {let subAgents = 0;try {- if (isWindows) {- // Windows: use tasklist for memory info, fallback to process.memoryUsage- // tasklist memory column is complex to parse, use Node.js API instead- memoryMB = Math.floor(process.memoryUsage().heapUsed / 1024 / 1024);- } else {- const mem = execSync('ps aux | grep -E "(node|agentic|claude)" | grep -v grep | awk \'{sum += $6} END {print int(sum/1024)}\'', { encoding: 'utf-8' });- memoryMB = parseInt(mem.trim()) || 0;- }+ const mem = execSync('ps aux | grep -E "(node|agentic|claude)" | grep -v grep | awk \'{sum += \$6} END {print int(sum/1024)}\'', { encoding: 'utf-8' });+ memoryMB = parseInt(mem.trim()) || 0;} catch (e) {// FallbackmemoryMB = Math.floor(process.memoryUsage().heapUsed / 1024 / 1024);@@ -285,16 +262,10 @@ function getSystemMetrics() {// Count active sub-agents from process listtry {- if (isWindows) {- // Windows: use tasklist and findstr for agent counting- const agents = execSync('tasklist 2>NUL | findstr /I "claude-flow" 2>NUL | find /C /V "" 2>NUL || echo 0', { encoding: 'utf-8' });- subAgents = Math.max(0, parseInt(agents.trim()) || 0);- } else {- const agents = execSync('ps aux 2>/dev/null | grep -c "claude-flow.*agent" || echo "0"', { encoding: 'utf-8' });- subAgents = Math.max(0, parseInt(agents.trim()) - 1);- }+ const agents = execSync('ps aux 2>/dev/null | grep -c "claude-flow.*agent" || echo "0"', { encoding: 'utf-8' });+ subAgents = Math.max(0, parseInt(agents.trim()) - 1);} catch (e) {- // Ignore - default to 0+ // Ignore}return {diff --git a/v3/@claude-flow/cli/CLAUDE.md b/v3/@claude-flow/cli/CLAUDE.mdindex 03e552edcd..498ece87ac 100644--- a/v3/@claude-flow/cli/CLAUDE.md+++ b/v3/@claude-flow/cli/CLAUDE.md@@ -19,42 +19,71 @@### π€ INTELLIGENT 3-TIER MODEL ROUTING (ADR-026)-**Before spawning agents, check for model recommendations:**--```bash-# Get routing recommendation-npx @claude-flow/cli@latest hooks pre-task --description "[task]"-```--**The routing system has 3 tiers:**+**The routing system has 3 tiers for optimal cost/performance:**| Tier | Handler | Latency | Cost | Use Cases ||------|---------|---------|------|-----------|-| **1** | Agent Booster (WASM) | <1ms | $0 | Simple transforms (varβconst, add-types, remove-console) |-| **2** | Haiku/Sonnet | 500ms-2s | $0.0002-$0.003 | Bug fixes, refactoring, features |-| **3** | Opus | 2-5s | $0.015 | Architecture, security, distributed systems |+| **1** | Agent Booster | <1ms | $0 | Simple transforms (varβconst, add-types, remove-console) |+| **2** | Haiku | ~500ms | $0.0002 | Simple tasks, bug fixes, low complexity |+| **3** | Sonnet/Opus | 2-5s | $0.003-$0.015 | Architecture, security, complex reasoning |++**Before spawning agents, get routing recommendation:**+```bash+npx @claude-flow/cli@latest hooks pre-task --description "[task description]"+```**When you see these recommendations:**-1. `[AGENT_BOOSTER_AVAILABLE]` β Skip LLM, use Edit tool directly for simple transforms+1. `[AGENT_BOOSTER_AVAILABLE]` β Skip LLM entirely, use Edit tool directly+ - Intent types: `var-to-const`, `add-types`, `add-error-handling`, `async-await`, `add-logging`, `remove-console`+2. `[TASK_MODEL_RECOMMENDATION] Use model="X"` β Use that model in Task tool:- ```javascript- Task({- prompt: "...",- subagent_type: "coder",- model: "sonnet" // β USE RECOMMENDED MODEL- })- ```+```javascript+Task({+ prompt: "...",+ subagent_type: "coder",+ model: "haiku" // β USE THE RECOMMENDED MODEL (haiku/sonnet/opus)+})+```++**Benefits:** 75% cost reduction, 352x faster for Tier 1 tasks++---++### π‘οΈ Anti-Drift Config (PREFERRED)++**Use this to prevent agent drift:**+```bash+# Small teams (6-8 agents) - use hierarchical for tight control+npx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized++# Large teams (10-15 agents) - use hierarchical-mesh for V3 queen + peer communication+npx @claude-flow/cli@latest swarm init --topology hierarchical-mesh --max-agents 15 --strategy specialized+```++**Valid Topologies:**+- `hierarchical` - Queen controls workers directly (anti-drift for small teams)+- `hierarchical-mesh` - V3 queen + peer communication (recommended for 10+ agents)+- `mesh` - Fully connected peer network+- `ring` - Circular communication pattern+- `star` - Central coordinator with spokes+- `hybrid` - Dynamic topology switching-**Benefits:** 75% cost reduction, 2.5x quota extension for Claude Max users+**Anti-Drift Guidelines:**+- **hierarchical**: Coordinator catches divergence+- **max-agents 6-8**: Smaller team = less drift+- **specialized**: Clear roles, no overlap+- **consensus**: raft (leader maintains state)++---### π Auto-Start Swarm Protocol (Background Execution)When the user requests a complex task, **spawn agents in background and WAIT for completion:**```javascript-// STEP 1: Initialize swarm coordination-Bash("npx @claude-flow/cli@latest swarm init --topology hierarchical-mesh --max-agents 15")+// STEP 1: Initialize swarm coordination (anti-drift config)+Bash("npx @claude-flow/cli@latest swarm init --topology hierarchical --max-agents 8 --strategy specialized")// STEP 2: Spawn ALL agents IN BACKGROUND in a SINGLE message// Use run_in_background: true so agents work concurrently@@ -132,10 +161,10 @@ They're working in parallel. I'll synthesize their results when they complete.### Before Starting Any Task```bash# 1. Search memory for relevant patterns from past successes-Bash("npx @claude-flow/cli@latest memory search -q '[task keywords]' --namespace patterns")+Bash("npx @claude-flow/cli@latest memory search --query '[task keywords]' --namespace patterns")# 2. Check if similar task was done before-Bash("npx @claude-flow/cli@latest memory search -q '[task type]' --namespace tasks")+Bash("npx @claude-flow/cli@latest memory search --query '[task type]' --namespace tasks")# 3. Load learned optimizationsBash("npx @claude-flow/cli@latest hooks route --task '[task description]'")@@ -181,17 +210,18 @@ Bash("npx @claude-flow/cli@latest hooks worker dispatch --trigger optimize")- Finding a performance fix (store the optimization)- Discovering a security issue (store the vulnerability pattern)-### π Agent Routing by Task Type+### π Agent Routing (Anti-Drift)-| Task Type | Required Agents | Topology |-|-----------|-----------------|----------|-| Bug Fix | researcher, coder, tester | mesh |-| New Feature | coordinator, architect, coder, tester, reviewer | hierarchical |-| Refactoring | architect, coder, reviewer | mesh |-| Performance | researcher, performance-engineer, coder | hierarchical |-| Security Audit | security-architect, security-auditor, reviewer | hierarchical |-| Memory Optimization | memory-specialist, performance-engineer | mesh |-| Documentation | researcher, api-docs | mesh |+| Code | Task | Agents |+|------|------|--------|+| 1 | Bug Fix | coordinator, researcher, coder, tester |+| 3 | Feature | coordinator, architect, coder, tester, reviewer |+| 5 | Refactor | coordinator, architect, coder, reviewer |+| 7 | Performance | coordinator, perf-engineer, coder |+| 9 | Security | coordinator, security-architect, auditor |+| 11 | Docs | researcher, api-docs |++**Codes 1-9: hierarchical/specialized (anti-drift). Code 11: mesh/balanced**### π― Task Complexity Detection@@ -238,14 +268,15 @@ Bash("npx @claude-flow/cli@latest hooks worker dispatch --trigger optimize")- `/scripts` - Utility scripts- `/examples` - Example code-## Project Configuration+## Project Config (Anti-Drift Defaults)-This project is configured with Claude Flow V3:-- **Topology**: hierarchical-mesh-- **Max Agents**: 15-- **Memory Backend**: hybrid-- **HNSW Indexing**: Enabled (150x-12,500x faster)-- **Neural Learning**: Enabled (SONA)+- **Topology**: hierarchical (prevents drift)+- **Max Agents**: 8 (smaller = less drift)+- **Strategy**: specialized (clear roles)+- **Consensus**: raft+- **Memory**: hybrid+- **HNSW**: Enabled+- **Neural**: Enabled## π V3 CLI Commands (26 Commands, 140+ Subcommands)@@ -299,7 +330,7 @@ npx @claude-flow/cli@latest agent spawn -t coder --name my-codernpx @claude-flow/cli@latest swarm init --v3-mode# Search memory (HNSW-indexed)-npx @claude-flow/cli@latest memory search -q "authentication patterns"+npx @claude-flow/cli@latest memory search --query "authentication patterns"# System diagnosticsnpx @claude-flow/cli@latest doctor --fix@@ -319,6 +350,12 @@ npx @claude-flow/cli@latest performance benchmark --suite all### V3 Specialized Agents`security-architect`, `security-auditor`, `memory-specialist`, `performance-engineer`+### π @claude-flow/security+CVE remediation, input validation, path security:+- `InputValidator` - Zod validation+- `PathValidator` - Traversal prevention+- `SafeExecutor` - Injection protection+### Swarm Coordination`hierarchical-coordinator`, `mesh-coordinator`, `adaptive-coordinator`, `collective-intelligence-coordinator`, `swarm-memory-manager`@@ -446,10 +483,9 @@ npx @claude-flow/cli@latest migrate validateV3 includes the RuVector Intelligence System:- **SONA**: Self-Optimizing Neural Architecture (<0.05ms adaptation)- **MoE**: Mixture of Experts for specialized routing-- **HNSW**: 150x-12,500x faster pattern search (persistent to disk)+- **HNSW**: 150x-12,500x faster pattern search- **EWC++**: Elastic Weight Consolidation (prevents forgetting)- **Flash Attention**: 2.49x-7.47x speedup-- **Int8 Quantization**: 3.92x memory compressionThe 4-step intelligence pipeline:1. **RETRIEVE** - Fetch relevant patterns via HNSW@@ -457,57 +493,6 @@ The 4-step intelligence pipeline:3. **DISTILL** - Extract key learnings via LoRA4. **CONSOLIDATE** - Prevent catastrophic forgetting via EWC++-### Implemented Optimizations (alpha.76+)--| Feature | Benefit | Location |-|---------|---------|----------|-| **Persistent HNSW** | 0ms warm loads, instant startup | `.swarm/hnsw.index` |-| **Int8 Quantization** | 3.92x compression, 75% less memory | `quantizeInt8()` |-| **ReasoningBank** | Pattern storage & similarity search | `intelligence.ts` |-| **SONA Coordinator** | Trajectory recording & learning | `initializeIntelligence()` |--### Using the Intelligence API--```typescript-import {- initializeIntelligence,- recordStep,- recordTrajectory,- findSimilarPatterns,- getIntelligenceStats-} from '@claude-flow/cli/memory/intelligence';--// Initialize SONA + ReasoningBank-const init = await initializeIntelligence();--// Record steps during task execution-await recordStep({ type: 'observation', content: 'Found bug in auth module' });-await recordStep({ type: 'action', content: 'Fixed validation logic' });--// Record complete trajectory with verdict-await recordTrajectory(steps, 'success');--// Find similar patterns for new tasks-const patterns = await findSimilarPatterns('authentication bug');-```--### Using Int8 Quantization--```typescript-import { quantizeInt8, dequantizeInt8, getQuantizationStats } from '@claude-flow/cli/memory';--// Quantize embeddings for storage-const { quantized, scale, zeroPoint } = quantizeInt8(embedding);-// Result: Int8Array with 3.92x smaller footprint--// Dequantize when needed-const restored = dequantizeInt8(quantized, scale, zeroPoint);--// Check compression stats-const stats = getQuantizationStats(embedding);-// { originalBytes: 1536, quantizedBytes: 392, compressionRatio: 3.92 }-```-## π¦ Embeddings Package (v3.0.0-alpha.12)Features:@@ -535,15 +520,14 @@ Features:## V3 Performance Targets-| Metric | Target | Status |-|--------|--------|--------|-| HNSW Search | 150x-12,500x faster | **Implemented** (persistent) |-| Memory Reduction | 50-75% with quantization | **Implemented** (3.92x Int8) |-| SONA Integration | Pattern learning | **Implemented** (ReasoningBank) |-| Flash Attention | 2.49x-7.47x speedup | In progress |-| MCP Response | <100ms | Achieved |-| CLI Startup | <500ms | Achieved |-| SONA Adaptation | <0.05ms | In progress |+| Metric | Target |+|--------|--------|+| Flash Attention | 2.49x-7.47x speedup |+| HNSW Search | 150x-12,500x faster |+| Memory Reduction | 50-75% with quantization |+| MCP Response | <100ms |+| CLI Startup | <500ms |+| SONA Adaptation | <0.05ms |## π Performance Optimization Protocol@@ -645,12 +629,67 @@ npx @claude-flow/cli@latest doctor --fix- **Swarm init**: `npx @claude-flow/cli@latest swarm init --topology <type>`- **Swarm status**: `npx @claude-flow/cli@latest swarm status`- **Agent spawn**: `npx @claude-flow/cli@latest agent spawn -t <type> --name <name>`-- **Memory store**: `npx @claude-flow/cli@latest memory store --namespace <ns> --key <k> --value <v>`-- **Memory search**: `npx @claude-flow/cli@latest memory search -q "<query>"`+- **Memory store**: `npx @claude-flow/cli@latest memory store --key "mykey" --value "myvalue" --namespace patterns`+- **Memory search**: `npx @claude-flow/cli@latest memory search --query "search terms"`+- **Memory list**: `npx @claude-flow/cli@latest memory list --namespace patterns`+- **Memory retrieve**: `npx @claude-flow/cli@latest memory retrieve --key "mykey" --namespace patterns`- **Hooks**: `npx @claude-flow/cli@latest hooks <hook-name> [options]`+## π Memory Commands Reference (IMPORTANT)++### Store Data (ALL options shown)+```bash+# REQUIRED: --key and --value+# OPTIONAL: --namespace (default: "default"), --ttl, --tags+npx @claude-flow/cli@latest memory store --key "pattern-auth" --value "JWT with refresh tokens" --namespace patterns+npx @claude-flow/cli@latest memory store --key "bug-fix-123" --value "Fixed null check" --namespace solutions --tags "bugfix,auth"+```++### Search Data (semantic vector search)+```bash+# REQUIRED: --query (full flag, not -q)+# OPTIONAL: --namespace, --limit, --threshold+npx @claude-flow/cli@latest memory search --query "authentication patterns"+npx @claude-flow/cli@latest memory search --query "error handling" --namespace patterns --limit 5+```++### List Entries+```bash+# OPTIONAL: --namespace, --limit+npx @claude-flow/cli@latest memory list+npx @claude-flow/cli@latest memory list --namespace patterns --limit 10+```++### Retrieve Specific Entry+```bash+# REQUIRED: --key+# OPTIONAL: --namespace (default: "default")+npx @claude-flow/cli@latest memory retrieve --key "pattern-auth"+npx @claude-flow/cli@latest memory retrieve --key "pattern-auth" --namespace patterns+```++### Initialize Memory Database+```bash+npx @claude-flow/cli@latest memory init --force --verbose+```+**KEY**: CLI coordinates the strategy via Bash, Claude Code's Task tool executes with real agents.+## π Full Capabilities Reference++For a comprehensive overview of all Claude Flow V3 features, agents, commands, and integrations, see:++**`.claude-flow/CAPABILITIES.md`** - Complete reference generated during init++This includes:+- All 60+ agent types with routing recommendations+- All 26 CLI commands with 140+ subcommands+- All 27 hooks + 12 background workers+- RuVector intelligence system details+- Hive-Mind consensus mechanisms+- Integration ecosystem (agentic-flow, agentdb, ruv-swarm, flow-nexus, agentic-jujutsu)+- Performance targets and status+## Support- Documentation: https://github.com/ruvnet/claude-flowdiff --git a/v3/@claude-flow/cli/agents/architect.yaml b/v3/@claude-flow/cli/agents/architect.yamlindex 831192bda8..310b876fc0 100644--- a/v3/@claude-flow/cli/agents/architect.yaml+++ b/v3/@claude-flow/cli/agents/architect.yaml@@ -8,4 +8,4 @@ capabilities:optimizations:- context-caching- memory-persistence-createdAt: "2026-01-14T21:49:18.503Z"+createdAt: "2026-01-16T19:21:04.610Z"diff --git a/v3/@claude-flow/cli/agents/coder.yaml b/v3/@claude-flow/cli/agents/coder.yamlindex 45c7da21aa..838fa7c261 100644--- a/v3/@claude-flow/cli/agents/coder.yaml+++ b/v3/@claude-flow/cli/agents/coder.yaml@@ -8,4 +8,4 @@ capabilities:optimizations:- flash-attention- token-reduction-createdAt: "2026-01-14T21:49:18.502Z"+createdAt: "2026-01-16T19:21:04.610Z"diff --git a/v3/@claude-flow/cli/agents/reviewer.yaml b/v3/@claude-flow/cli/agents/reviewer.yamlindex 04cf54a344..1c7de26646 100644--- a/v3/@claude-flow/cli/agents/reviewer.yaml+++ b/v3/@claude-flow/cli/agents/reviewer.yaml@@ -7,4 +7,4 @@ capabilities:- best-practicesoptimizations:- incremental-analysis-createdAt: "2026-01-14T21:49:18.503Z"+createdAt: "2026-01-16T19:21:04.611Z"diff --git a/v3/@claude-flow/cli/agents/security-architect.yaml b/v3/@claude-flow/cli/agents/security-architect.yamlindex 678e35fce7..327e6cd45c 100644--- a/v3/@claude-flow/cli/agents/security-architect.yaml+++ b/v3/@claude-flow/cli/agents/security-architect.yaml@@ -7,4 +7,4 @@ capabilities:- security-reviewoptimizations:- pattern-matching-createdAt: "2026-01-14T21:49:18.503Z"+createdAt: "2026-01-16T19:21:04.611Z"diff --git a/v3/@claude-flow/cli/agents/tester.yaml b/v3/@claude-flow/cli/agents/tester.yamlindex ff227a9632..8c21bb2fcf 100644--- a/v3/@claude-flow/cli/agents/tester.yaml+++ b/v3/@claude-flow/cli/agents/tester.yaml@@ -7,4 +7,4 @@ capabilities:- coverageoptimizations:- parallel-execution-createdAt: "2026-01-14T21:49:18.503Z"+createdAt: "2026-01-16T19:21:04.611Z"diff --git a/v3/@claude-flow/cli/src/commands/index.ts b/v3/@claude-flow/cli/src/commands/index.tsindex 51a8e53de0..19f6ab5aff 100644--- a/v3/@claude-flow/cli/src/commands/index.ts+++ b/v3/@claude-flow/cli/src/commands/index.ts@@ -116,6 +116,7 @@ import { embeddingsCommand } from './embeddings.js';import { neuralCommand } from './neural.js';import { performanceCommand } from './performance.js';import { securityCommand } from './security.js';+import { hiveMindCommand } from './hive-mind.js';// Pre-populate cache with core commandsloadedCommands.set('init', initCommand);