Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

Checkpoint: File edits

rUv52b08dbaf00c
diff --git a/.claude/agents/README.md b/.claude/agents/README.md
deleted file mode 100644
index ce84ea2f0d..0000000000
--- a/.claude/agents/README.md
+++ /dev/null
@@ -1,89 +0,0 @@
----
-name: Agents Directory
-type: documentation
-category: agents
-description: Sub-agent definitions organized by type and purpose with specific capabilities and tool restrictions
----
-
-# Claude Code Agents Directory Structure
-
-This directory contains sub-agent definitions organized by type and purpose. Each agent has specific capabilities, tool restrictions, and naming conventions that trigger automatic delegation.
-
-## Directory Structure
-
-```
-.claude/agents/
-β”œβ”€β”€ README.md # This file
-β”œβ”€β”€ _templates/ # Agent templates
-β”‚ β”œβ”€β”€ base-agent.yaml
-β”‚ └── agent-types.md
-β”œβ”€β”€ development/ # Development agents
-β”‚ β”œβ”€β”€ backend/
-β”‚ β”œβ”€β”€ frontend/
-β”‚ β”œβ”€β”€ fullstack/
-β”‚ └── api/
-β”œβ”€β”€ testing/ # Testing agents
-β”‚ β”œβ”€β”€ unit/
-β”‚ β”œβ”€β”€ integration/
-β”‚ β”œβ”€β”€ e2e/
-β”‚ └── performance/
-β”œβ”€β”€ architecture/ # Architecture agents
-β”‚ β”œβ”€β”€ system-design/
-β”‚ β”œβ”€β”€ database/
-β”‚ β”œβ”€β”€ cloud/
-β”‚ └── security/
-β”œβ”€β”€ devops/ # DevOps agents
-β”‚ β”œβ”€β”€ ci-cd/
-β”‚ β”œβ”€β”€ infrastructure/
-β”‚ β”œβ”€β”€ monitoring/
-β”‚ └── deployment/
-β”œβ”€β”€ documentation/ # Documentation agents
-β”‚ β”œβ”€β”€ api-docs/
-β”‚ β”œβ”€β”€ user-guides/
-β”‚ β”œβ”€β”€ technical/
-β”‚ └── readme/
-β”œβ”€β”€ analysis/ # Analysis agents
-β”‚ β”œβ”€β”€ code-review/
-β”‚ β”œβ”€β”€ performance/
-β”‚ β”œβ”€β”€ security/
-β”‚ └── refactoring/
-β”œβ”€β”€ data/ # Data agents
-β”‚ β”œβ”€β”€ etl/
-β”‚ β”œβ”€β”€ analytics/
-β”‚ β”œβ”€β”€ ml/
-β”‚ └── visualization/
-└── specialized/ # Specialized agents
- β”œβ”€β”€ mobile/
- β”œβ”€β”€ embedded/
- β”œβ”€β”€ blockchain/
- └── ai-ml/
-```
-
-## Naming Conventions
-
-Agent files follow this naming pattern:
-`[type]-[specialization]-[capability].agent.yaml`
-
-Examples:
-- `dev-backend-api.agent.yaml`
-- `test-unit-jest.agent.yaml`
-- `arch-cloud-aws.agent.yaml`
-- `docs-api-openapi.agent.yaml`
-
-## Automatic Delegation Triggers
-
-Claude Code automatically delegates to agents based on:
-1. **Keywords in user request**: "test", "deploy", "document", "review"
-2. **File patterns**: `*.test.js` β†’ testing agent, `*.tf` β†’ infrastructure agent
-3. **Task complexity**: Multi-step tasks spawn coordinator agents
-4. **Domain detection**: Database queries β†’ data agent, API endpoints β†’ backend agent
-
-## Tool Restrictions
-
-Each agent type has specific tool access:
-- **Development agents**: Full file system access, code execution
-- **Testing agents**: Test runners, coverage tools, limited write access
-- **Architecture agents**: Read-only access, diagram generation
-- **Documentation agents**: Markdown tools, read access, limited write to docs/
-- **DevOps agents**: Infrastructure tools, deployment scripts, environment access
-- **Analysis agents**: Read-only access, static analysis tools
\ No newline at end of file
diff --git a/.claude/agents/consensus/README.md b/.claude/agents/consensus/README.md
deleted file mode 100644
index 681ea438fa..0000000000
--- a/.claude/agents/consensus/README.md
+++ /dev/null
@@ -1,253 +0,0 @@
----
-name: Consensus Builder
-type: documentation
-category: consensus
-description: Specialized agents for distributed consensus mechanisms and fault-tolerant coordination protocols
----
-
-# Distributed Consensus Builder Agents
-
-## Overview
-
-This directory contains specialized agents for implementing advanced distributed consensus mechanisms and fault-tolerant coordination protocols. These agents work together to provide robust, scalable consensus capabilities for distributed swarm systems.
-
-## Agent Collection
-
-### Core Consensus Protocols
-
-#### 1. **Byzantine Consensus Coordinator** (`byzantine-coordinator.md`)
-- **Mission**: Implement Byzantine fault-tolerant consensus algorithms for secure decision-making
-- **Key Features**:
- - PBFT (Practical Byzantine Fault Tolerance) implementation
- - Malicious agent detection and isolation
- - Threshold signature schemes
- - Network partition recovery protocols
- - DoS protection and rate limiting
-
-#### 2. **Raft Consensus Manager** (`raft-manager.md`)
-- **Mission**: Implement Raft consensus algorithm with leader election and log replication
-- **Key Features**:
- - Leader election with randomized timeouts
- - Log replication and consistency guarantees
- - Follower synchronization and catch-up mechanisms
- - Snapshot creation and log compaction
- - Leadership transfer protocols
-
-#### 3. **Gossip Protocol Coordinator** (`gossip-coordinator.md`)
-- **Mission**: Implement epidemic information dissemination for scalable communication
-- **Key Features**:
- - Push/Pull/Hybrid gossip protocols
- - Anti-entropy state synchronization
- - Membership management and failure detection
- - Network topology discovery
- - Adaptive gossip parameter tuning
-
-### Security and Cryptography
-
-#### 4. **Security Manager** (`security-manager.md`)
-- **Mission**: Provide comprehensive security mechanisms for consensus protocols
-- **Key Features**:
- - Threshold cryptography and signature schemes
- - Zero-knowledge proof systems
- - Attack detection and mitigation (Byzantine, Sybil, Eclipse, DoS)
- - Secure key management and distribution
- - End-to-end encryption for consensus traffic
-
-### State Synchronization
-
-#### 5. **CRDT Synchronizer** (`crdt-synchronizer.md`)
-- **Mission**: Implement Conflict-free Replicated Data Types for eventual consistency
-- **Key Features**:
- - State-based and operation-based CRDTs
- - G-Counter, PN-Counter, OR-Set, LWW-Register implementations
- - RGA (Replicated Growable Array) for sequences
- - Delta-state CRDT optimization
- - Causal consistency tracking
-
-### Performance and Optimization
-
-#### 6. **Performance Benchmarker** (`performance-benchmarker.md`)
-- **Mission**: Comprehensive performance analysis and optimization for consensus protocols
-- **Key Features**:
- - Throughput and latency measurement
- - Resource utilization monitoring
- - Comparative protocol analysis
- - Adaptive performance tuning
- - Real-time optimization recommendations
-
-#### 7. **Quorum Manager** (`quorum-manager.md`)
-- **Mission**: Dynamic quorum adjustment based on network conditions and fault tolerance
-- **Key Features**:
- - Network-based quorum strategies
- - Performance-optimized quorum sizing
- - Fault tolerance analysis and optimization
- - Intelligent membership management
- - Predictive quorum adjustments
-
-## Architecture Integration
-
-### MCP Integration Points
-
-All consensus agents integrate with the MCP (Model Context Protocol) coordination system:
-
-```javascript
-// Memory coordination for persistent state
-await this.mcpTools.memory_usage({
- action: 'store',
- key: 'consensus_state',
- value: JSON.stringify(consensusData),
- namespace: 'distributed_consensus'
-});
-
-// Performance monitoring
-await this.mcpTools.metrics_collect({
- components: ['consensus_latency', 'throughput', 'fault_tolerance']
-});
-
-// Task orchestration
-await this.mcpTools.task_orchestrate({
- task: 'consensus_round',
- strategy: 'parallel',
- priority: 'high'
-});
-```
-
-### Swarm Coordination
-
-Agents coordinate with the broader swarm infrastructure:
-
-- **Node Discovery**: Integration with swarm node discovery mechanisms
-- **Health Monitoring**: Consensus participation in distributed health checks
-- **Load Balancing**: Dynamic load distribution across consensus participants
-- **Fault Recovery**: Coordinated recovery from node and network failures
-
-## Usage Patterns
-
-### Basic Consensus Setup
-
-```javascript
-// Initialize Byzantine consensus for high-security scenarios
-const byzantineConsensus = new ByzantineConsensusCoordinator('node-1', 7, 2);
-await byzantineConsensus.initializeNode();
-
-// Initialize Raft for leader-based coordination
-const raftConsensus = new RaftConsensusManager('node-1', ['node-1', 'node-2', 'node-3']);
-await raftConsensus.initialize();
-
-// Initialize Gossip for scalable information dissemination
-const gossipCoordinator = new GossipProtocolCoordinator('node-1', ['seed-1', 'seed-2']);
-await gossipCoordinator.initialize();
-```
-
-### Security-Enhanced Consensus
-
-```javascript
-// Add security layer to consensus protocols
-const securityManager = new SecurityManager();
-await securityManager.generateDistributedKeys(participants, threshold);
-
-const secureConsensus = new SecureConsensusWrapper(
- byzantineConsensus,
- securityManager
-);
-```
-
-### Performance Optimization
-
-```javascript
-// Benchmark and optimize consensus performance
-const benchmarker = new ConsensusPerformanceBenchmarker();
-const results = await benchmarker.runComprehensiveBenchmarks(
- ['byzantine', 'raft', 'gossip'],
- scenarios
-);
-
-// Apply adaptive optimizations
-const optimizer = new AdaptiveOptimizer();
-await optimizer.optimizeBasedOnResults(results);
-```
-
-### State Synchronization
-
-```javascript
-// Set up CRDT-based state synchronization
-const crdtSynchronizer = new CRDTSynchronizer('node-1', replicationGroup);
-const counter = crdtSynchronizer.registerCRDT('request_counter', 'G_COUNTER');
-const userSet = crdtSynchronizer.registerCRDT('active_users', 'OR_SET');
-
-await crdtSynchronizer.synchronize();
-```
-
-## Advanced Features
-
-### Fault Tolerance
-
-- **Byzantine Fault Tolerance**: Handles up to f < n/3 malicious nodes
-- **Crash Fault Tolerance**: Recovers from node failures and network partitions
-- **Network Partition Tolerance**: Maintains consistency during network splits
-- **Graceful Degradation**: Continues operation with reduced functionality
-
-### Scalability
-
-- **Horizontal Scaling**: Add/remove nodes dynamically
-- **Load Distribution**: Distribute consensus load across available resources
-- **Gossip-based Dissemination**: Logarithmic message complexity
-- **Delta Synchronization**: Efficient incremental state updates
-
-### Security
-
-- **Cryptographic Primitives**: Ed25519 signatures, threshold cryptography
-- **Attack Mitigation**: Protection against Byzantine, Sybil, Eclipse, and DoS attacks
-- **Zero-Knowledge Proofs**: Privacy-preserving consensus verification
-- **Secure Communication**: TLS 1.3 with forward secrecy
-
-### Performance
-
-- **Adaptive Optimization**: Real-time parameter tuning based on performance
-- **Resource Monitoring**: CPU, memory, network, and storage utilization
-- **Bottleneck Detection**: Automatic identification of performance constraints
-- **Predictive Scaling**: Anticipate resource needs before bottlenecks occur
-
-## Testing and Validation
-
-### Consensus Correctness
-- **Safety Properties**: Verify agreement and validity properties
-- **Liveness Properties**: Ensure progress under normal conditions
-- **Fault Injection**: Test behavior under various failure scenarios
-- **Formal Verification**: Mathematical proofs of correctness
-
-### Performance Testing
-- **Load Testing**: High-throughput consensus scenarios
-- **Latency Analysis**: End-to-end latency measurement and optimization
-- **Scalability Testing**: Performance with varying cluster sizes
-- **Resource Efficiency**: Optimize resource utilization
-
-### Security Validation
-- **Penetration Testing**: Simulated attacks on consensus protocols
-- **Cryptographic Verification**: Validate security of cryptographic schemes
-- **Threat Modeling**: Analyze potential attack vectors
-- **Compliance Testing**: Ensure adherence to security standards
-
-## Deployment Considerations
-
-### Network Requirements
-- **Bandwidth**: Sufficient bandwidth for consensus message traffic
-- **Latency**: Low-latency network connections between nodes
-- **Reliability**: Stable network connectivity for consensus participants
-- **Security**: Encrypted communication channels
-
-### Resource Requirements
-- **CPU**: Adequate processing power for cryptographic operations
-- **Memory**: Sufficient RAM for consensus state and message buffers
-- **Storage**: Persistent storage for consensus logs and state
-- **Redundancy**: Multiple nodes for fault tolerance
-
-### Monitoring and Observability
-- **Metrics Collection**: Real-time performance and health metrics
-- **Alerting**: Notifications for consensus failures or degraded performance
-- **Logging**: Comprehensive audit trails for consensus operations
-- **Dashboards**: Visual monitoring of consensus health and performance
-
-## Integration Examples
-
-See individual agent files for detailed implementation examples and integration patterns with specific consensus protocols and use cases.
\ No newline at end of file
diff --git a/.claude/agents/dual-mode/README.md b/.claude/agents/dual-mode/README.md
deleted file mode 100644
index 46dd0b133c..0000000000
--- a/.claude/agents/dual-mode/README.md
+++ /dev/null
@@ -1,94 +0,0 @@
-# Dual-Mode Agents (Claude Code + Codex)
-
-Optional agents for orchestrating hybrid workflows combining Claude Code (interactive) and Codex (headless) execution.
-
-## Available Agents
-
-| Agent | File | Platform | Purpose |
-|-------|------|----------|---------|
-| `dual-orchestrator` | dual-orchestrator.md | dual | Orchestrate hybrid Claude+Codex workflows |
-| `codex-coordinator` | codex-coordinator.md | dual | Coordinate multiple headless Codex workers |
-| `codex-worker` | codex-worker.md | codex | Headless background worker with self-learning |
-
-## Architecture
-
-```
-β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
-β”‚ CLAUDE CODE (Interactive) β”‚
-β”‚ β”œβ”€ Complex reasoning β”‚
-β”‚ β”œβ”€ Architecture decisions β”‚
-β”‚ └─ Real-time review β”‚
-β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
-β”‚ dual-orchestrator β”‚
-β”‚ β”œβ”€ Routes tasks to appropriate platform β”‚
-β”‚ └─ Coordinates hybrid workflows β”‚
-β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
-β”‚ codex-coordinator β”‚
-β”‚ β”œβ”€ Spawns headless workers β”‚
-β”‚ β”œβ”€ Tracks progress via memory β”‚
-β”‚ └─ Aggregates results β”‚
-β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
-β”‚ CODEX (Headless) β”‚
-β”‚ β”œβ”€ codex-worker instances β”‚
-β”‚ β”œβ”€ Run in parallel via `claude -p` β”‚
-β”‚ └─ Store results in shared memory β”‚
-β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
-```
-
-## Quick Start
-
-### 1. Hybrid Development Workflow
-```bash
-# Interactive design β†’ Parallel implementation β†’ Interactive review
-# Use dual-orchestrator agent
-```
-
-### 2. Spawn Parallel Workers
-```bash
-# Initialize coordination
-npx claude-flow@v3alpha swarm init --topology hierarchical --max-agents 4
-
-# Spawn workers
-claude -p "Implement auth service" --session-id auth-1 &
-claude -p "Write auth tests" --session-id auth-2 &
-wait
-
-# Collect results
-npx claude-flow@v3alpha memory list --namespace results
-```
-
-## When to Use Each Agent
-
-### dual-orchestrator
-- Starting a new feature that needs both design and implementation
-- Deciding whether a task needs interactive reasoning or can run headlessly
-- Coordinating end-to-end hybrid workflows
-
-### codex-coordinator
-- Spawning multiple parallel workers for batch execution
-- Managing worker lifecycle and result aggregation
-- When the task is already well-defined and can be parallelized
-
-### codex-worker
-- Individual headless execution units
-- Self-learning workers that check memory before/after tasks
-- Background implementation tasks
-
-## Related Skills
-
-See `.claude/skills/dual-mode/` for skill commands:
-- `/dual-spawn` - Spawn headless workers
-- `/dual-coordinate` - Full hybrid workflow
-- `/dual-collect` - Collect worker results
-
-## Platform Routing
-
-| Task Type | Platform | Agent |
-|-----------|----------|-------|
-| Design/Architecture | Claude Code | dual-orchestrator |
-| Debugging | Claude Code | - |
-| Implementation | Codex | codex-worker |
-| Testing | Codex | codex-worker |
-| Documentation | Codex | codex-worker |
-| Code Review | Claude Code | - |
-| Hybrid Feature | Both | dual-orchestrator |
diff --git a/.claude/agents/optimization/README.md b/.claude/agents/optimization/README.md
deleted file mode 100644
index e869a82937..0000000000
--- a/.claude/agents/optimization/README.md
+++ /dev/null
@@ -1,250 +0,0 @@
----
-name: Performance Optimization
-type: documentation
-category: optimization
-description: Comprehensive suite of performance optimization agents for swarm efficiency and scalability
----
-
-# Performance Optimization Agents
-
-This directory contains a comprehensive suite of performance optimization agents designed to maximize swarm efficiency, scalability, and reliability.
-
-## Agent Overview
-
-### 1. Load Balancing Coordinator (`load-balancer.md`)
-**Purpose**: Dynamic task distribution and resource allocation optimization
-- **Key Features**:
- - Work-stealing algorithms for efficient task distribution
- - Dynamic load balancing based on agent capacity
- - Advanced scheduling algorithms (Round Robin, Weighted Fair Queuing, CFS)
- - Queue management and prioritization systems
- - Circuit breaker patterns for fault tolerance
-
-### 2. Performance Monitor (`performance-monitor.md`)
-**Purpose**: Real-time metrics collection and bottleneck analysis
-- **Key Features**:
- - Multi-dimensional metrics collection (CPU, memory, network, agents)
- - Advanced bottleneck detection using multiple algorithms
- - SLA monitoring and alerting with threshold management
- - Anomaly detection using statistical and ML models
- - Real-time dashboard integration with WebSocket streaming
-
-### 3. Topology Optimizer (`topology-optimizer.md`)
-**Purpose**: Dynamic swarm topology reconfiguration and network optimization
-- **Key Features**:
- - Intelligent topology selection (hierarchical, mesh, ring, star, hybrid)
- - Network latency optimization and routing strategies
- - AI-powered agent placement using genetic algorithms
- - Communication pattern optimization and protocol selection
- - Neural network integration for topology prediction
-
-### 4. Resource Allocator (`resource-allocator.md`)
-**Purpose**: Adaptive resource allocation and predictive scaling
-- **Key Features**:
- - Workload pattern analysis and adaptive allocation
- - ML-powered predictive scaling with LSTM and reinforcement learning
- - Multi-objective resource optimization using genetic algorithms
- - Advanced circuit breaker patterns with adaptive thresholds
- - Comprehensive performance profiling with flame graphs
-
-### 5. Benchmark Suite (`benchmark-suite.md`)
-**Purpose**: Comprehensive performance benchmarking and validation
-- **Key Features**:
- - Automated performance testing (load, stress, volume, endurance)
- - Performance regression detection using multiple algorithms
- - SLA validation and quality assessment frameworks
- - Continuous integration with CI/CD pipelines
- - Error pattern analysis and trend detection
-
-## Architecture Overview
-
-```
-β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
-β”‚ MCP Integration Layer β”‚
-β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
-β”‚ Performance β”‚ Load β”‚ Topology β”‚ Resource β”‚
-β”‚ Monitor β”‚ Balancer β”‚ Optimizer β”‚ Allocatorβ”‚
-β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
-β”‚ Benchmark Suite & Validation β”‚
-β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
-β”‚ Swarm Infrastructure Integration β”‚
-β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
-```
-
-## Key Performance Features
-
-### Advanced Algorithms
-- **Genetic Algorithms**: For topology optimization and resource allocation
-- **Simulated Annealing**: For topology reconfiguration optimization
-- **Reinforcement Learning**: For adaptive scaling decisions
-- **Machine Learning**: For anomaly detection and predictive analytics
-- **Work-Stealing**: For efficient task distribution
-
-### Monitoring & Analytics
-- **Real-time Metrics**: CPU, memory, network, agent performance
-- **Bottleneck Detection**: Multi-algorithm approach for identifying performance issues
-- **Trend Analysis**: Historical performance pattern recognition
-- **Predictive Analytics**: ML-based forecasting for resource needs
-- **Cost Optimization**: Resource efficiency and cost analysis
-
-### Fault Tolerance
-- **Circuit Breaker Patterns**: Adaptive thresholds for system protection
-- **Bulkhead Isolation**: Resource pool separation for failure containment
-- **Graceful Degradation**: Fallback mechanisms for service continuity
-- **Recovery Strategies**: Automated system recovery and healing
-
-### Integration Capabilities
-- **MCP Tools**: Extensive use of claude-flow MCP performance tools
-- **Real-time Dashboards**: WebSocket-based live performance monitoring
-- **CI/CD Integration**: Automated performance validation in deployment pipelines
-- **Alert Systems**: Multi-channel notification for performance issues
-
-## Usage Examples
-
-### Basic Optimization Workflow
-```bash
-# 1. Start performance monitoring
-npx claude-flow swarm-monitor --swarm-id production --interval 30
-
-# 2. Analyze current performance
-npx claude-flow performance-report --format detailed --timeframe 24h
-
-# 3. Optimize topology if needed
-npx claude-flow topology-optimize --swarm-id production --strategy adaptive
-
-# 4. Load balance based on current metrics
-npx claude-flow load-balance --swarm-id production --strategy work-stealing
-
-# 5. Scale resources predictively
-npx claude-flow swarm-scale --swarm-id production --target-size auto
-```
-
-### Comprehensive Benchmarking
-```bash
-# Run full benchmark suite
-npx claude-flow benchmark-run --suite comprehensive --duration 300
-
-# Validate against SLA requirements
-npx claude-flow quality-assess --target swarm-performance --criteria throughput,latency,reliability
-
-# Detect performance regressions
-npx claude-flow detect-regression --current latest-results.json --historical baseline.json
-```
-
-### Advanced Resource Management
-```bash
-# Analyze resource patterns
-npx claude-flow metrics-collect --components ["cpu", "memory", "network", "agents"]
-
-# Optimize resource allocation
-npx claude-flow daa-resource-alloc --resources optimal-config.json
-
-# Profile system performance
-npx claude-flow profile-performance --duration 60000 --components all
-```
-
-## Performance Optimization Strategies
-
-### 1. Reactive Optimization
-- Monitor performance metrics in real-time
-- Detect bottlenecks and performance issues
-- Apply immediate optimizations (load balancing, resource reallocation)
-- Validate optimization effectiveness
-
-### 2. Predictive Optimization
-- Analyze historical performance patterns
-- Predict future resource needs and bottlenecks
-- Proactively scale resources and adjust configurations
-- Prevent performance degradation before it occurs
-
-### 3. Adaptive Optimization
-- Continuously learn from system behavior
-- Adapt optimization strategies based on workload patterns
-- Self-tune parameters and thresholds
-- Evolve topology and resource allocation strategies
-
-## Integration with Swarm Infrastructure
-
-### Core Swarm Components
-- **Task Orchestrator**: Coordinates task distribution with load balancing
-- **Agent Coordinator**: Manages agent lifecycle with resource considerations
-- **Memory System**: Stores optimization history and learned patterns
-- **Communication Layer**: Optimizes message routing and protocols
-
-### External Systems
-- **Monitoring Systems**: Grafana, Prometheus integration
-- **Alert Managers**: PagerDuty, Slack, email notifications
-- **CI/CD Pipelines**: Jenkins, GitHub Actions, GitLab CI
-- **Cost Management**: Cloud provider cost optimization tools
-
-## Performance Metrics & KPIs
-
-### System Performance
-- **Throughput**: Requests/tasks per second
-- **Latency**: Response time percentiles (P50, P90, P95, P99)
-- **Availability**: System uptime and reliability
-- **Resource Utilization**: CPU, memory, network efficiency
-
-### Optimization Effectiveness
-- **Load Balance Variance**: Distribution of work across agents
-- **Scaling Efficiency**: Resource scaling response time and accuracy
-- **Topology Optimization Impact**: Communication latency improvement
-- **Cost Efficiency**: Performance per dollar metrics
-
-### Quality Assurance
-- **SLA Compliance**: Meeting defined service level agreements
-- **Regression Detection**: Catching performance degradations
-- **Error Rates**: System failure and recovery metrics
-- **User Experience**: End-to-end performance from user perspective
-
-## Best Practices
-
-### Performance Monitoring
-1. Establish baseline performance metrics
-2. Set up automated alerting for critical thresholds
-3. Monitor trends, not just point-in-time metrics
-4. Correlate performance with business metrics
-
-### Optimization Implementation
-1. Test optimizations in staging environments first
-2. Implement gradual rollouts for major changes
-3. Maintain rollback capabilities for all optimizations
-4. Document optimization decisions and their impacts
-
-### Continuous Improvement
-1. Regular performance reviews and optimization cycles
-2. Automated regression testing in CI/CD pipelines
-3. Capacity planning based on growth projections
-4. Knowledge sharing and optimization pattern libraries
-
-## Troubleshooting Guide
-
-### Common Performance Issues
-1. **High CPU Usage**: Check for inefficient algorithms, infinite loops
-2. **Memory Leaks**: Monitor memory growth patterns, object retention
-3. **Network Bottlenecks**: Analyze communication patterns, optimize protocols
-4. **Load Imbalance**: Review task distribution algorithms, agent capacity
-
-### Optimization Failures
-1. **Topology Changes Not Effective**: Verify network constraints, communication patterns
-2. **Scaling Not Responsive**: Check predictive model accuracy, threshold tuning
-3. **Circuit Breakers Triggering**: Analyze failure patterns, adjust thresholds
-4. **Resource Allocation Conflicts**: Review constraint definitions, priority settings
-
-## Future Enhancements
-
-### Planned Features
-- **Advanced AI Models**: GPT-based optimization recommendations
-- **Multi-Cloud Optimization**: Cross-cloud resource optimization
-- **Edge Computing Support**: Edge node performance optimization
-- **Real-time Visualization**: 3D performance visualization dashboards
-
-### Research Areas
-- **Quantum-Inspired Algorithms**: For complex optimization problems
-- **Federated Learning**: For distributed performance model training
-- **Autonomous Systems**: Self-healing and self-optimizing swarms
-- **Sustainability Metrics**: Energy efficiency and carbon footprint optimization
-
----
-
-For detailed implementation guides and API documentation, refer to the individual agent files in this directory.
\ No newline at end of file
diff --git a/.claude/agents/swarm/README.md b/.claude/agents/swarm/README.md
deleted file mode 100644
index 34e8c28e94..0000000000
--- a/.claude/agents/swarm/README.md
+++ /dev/null
@@ -1,190 +0,0 @@
----
-name: Swarm Coordination
-type: documentation
-category: swarm
-description: Specialized swarm coordination agents for claude-code-flow hive-mind system with different topologies
----
-
-# Swarm Coordination Agents
-
-This directory contains specialized swarm coordination agents designed to work with the claude-code-flow hive-mind system. Each agent implements a different coordination topology and strategy.
-
-## Available Agents
-
-### 1. Hierarchical Coordinator (`hierarchical-coordinator.md`)
-**Architecture**: Queen-led hierarchy with specialized workers
-- **Use Cases**: Complex projects requiring central coordination
-- **Strengths**: Clear command structure, efficient resource allocation
-- **Best For**: Large-scale development, multi-team coordination
-
-### 2. Mesh Coordinator (`mesh-coordinator.md`)
-**Architecture**: Peer-to-peer distributed network
-- **Use Cases**: Fault-tolerant distributed processing
-- **Strengths**: High resilience, no single point of failure
-- **Best For**: Critical systems, high-availability requirements
-
-### 3. Adaptive Coordinator (`adaptive-coordinator.md`)
-**Architecture**: Dynamic topology switching with ML optimization
-- **Use Cases**: Variable workloads requiring optimization
-- **Strengths**: Self-optimizing, learns from experience
-- **Best For**: Production systems, long-running processes
-
-## Coordination Patterns
-
-### Topology Comparison
-
-| Feature | Hierarchical | Mesh | Adaptive |
-|---------|-------------|------|----------|
-| **Fault Tolerance** | Medium | High | High |
-| **Scalability** | High | Medium | High |
-| **Coordination Overhead** | Low | High | Variable |
-| **Learning Capability** | Low | Low | High |
-| **Setup Complexity** | Low | High | Medium |
-| **Best Use Case** | Structured projects | Critical systems | Variable workloads |
-
-### Performance Characteristics
-
-```
-Hierarchical: ⭐⭐⭐⭐⭐ Coordination Efficiency
- ⭐⭐⭐⭐ Fault Tolerance
- ⭐⭐⭐⭐⭐ Scalability
-
-Mesh: ⭐⭐⭐ Coordination Efficiency
- ⭐⭐⭐⭐⭐ Fault Tolerance
- ⭐⭐⭐ Scalability
-
-Adaptive: ⭐⭐⭐⭐⭐ Coordination Efficiency
- ⭐⭐⭐⭐⭐ Fault Tolerance
- ⭐⭐⭐⭐⭐ Scalability
-```
-
-## MCP Tool Integration
-
-All swarm coordinators leverage the following MCP tools:
-
-### Core Coordination Tools
-- `mcp__claude-flow__swarm_init` - Initialize swarm topology
-- `mcp__claude-flow__agent_spawn` - Create specialized worker agents
-- `mcp__claude-flow__task_orchestrate` - Coordinate complex workflows
-- `mcp__claude-flow__swarm_monitor` - Real-time performance monitoring
-
-### Advanced Features
-- `mcp__claude-flow__neural_patterns` - Pattern recognition and learning
-- `mcp__claude-flow__daa_consensus` - Distributed decision making
-- `mcp__claude-flow__topology_optimize` - Dynamic topology optimization
-- `mcp__claude-flow__performance_report` - Comprehensive analytics
-
-## Usage Examples
-
-### Hierarchical Coordination
-```bash
-# Initialize hierarchical swarm for development project
-claude-flow agent spawn hierarchical-coordinator "Build authentication microservice"
-
-# Agents will automatically:
-# 1. Decompose project into tasks
-# 2. Spawn specialized workers (research, code, test, docs)
-# 3. Coordinate execution with central oversight
-# 4. Generate comprehensive reports
-```
-
-### Mesh Coordination
-```bash
-# Initialize mesh network for distributed processing
-claude-flow agent spawn mesh-coordinator "Process user analytics data"
-
-# Network will automatically:
-# 1. Establish peer-to-peer connections
-# 2. Distribute work across available nodes
-# 3. Handle node failures gracefully
-# 4. Maintain consensus on results
-```
-
-### Adaptive Coordination
-```bash
-# Initialize adaptive swarm for production optimization
-claude-flow agent spawn adaptive-coordinator "Optimize system performance"
-
-# System will automatically:
-# 1. Analyze current workload patterns
-# 2. Select optimal topology (hierarchical/mesh/ring)
-# 3. Learn from performance outcomes
-# 4. Continuously adapt to changing conditions
-```
-
-## Architecture Decision Framework
-
-### When to Use Hierarchical
-- βœ… Well-defined project structure
-- βœ… Clear resource hierarchy
-- βœ… Need for centralized decision making
-- βœ… Large team coordination required
-- ❌ High fault tolerance critical
-- ❌ Network partitioning likely
-
-### When to Use Mesh
-- βœ… High availability requirements
-- βœ… Distributed processing needs
-- βœ… Network reliability concerns
-- βœ… Peer collaboration model
-- ❌ Simple coordination sufficient
-- ❌ Resource constraints exist
-
-### When to Use Adaptive
-- βœ… Variable workload patterns
-- βœ… Long-running production systems
-- βœ… Performance optimization critical
-- βœ… Machine learning acceptable
-- ❌ Predictable, stable workloads
-- ❌ Simple requirements
-
-## Performance Monitoring
-
-Each coordinator provides comprehensive metrics:
-
-### Key Performance Indicators
-- **Task Completion Rate**: Percentage of successful task completion
-- **Agent Utilization**: Efficiency of resource usage
-- **Coordination Overhead**: Communication and management costs
-- **Fault Recovery Time**: Speed of recovery from failures
-- **Learning Convergence**: Adaptation effectiveness (adaptive only)
-
-### Monitoring Dashboards
-Real-time visibility into:
-- Swarm topology and agent status
-- Task queues and execution pipelines
-- Performance metrics and trends
-- Error rates and failure patterns
-- Resource utilization and capacity
-
-## Best Practices
-
-### Design Principles
-1. **Start Simple**: Begin with hierarchical for well-understood problems
-2. **Scale Gradually**: Add complexity as requirements grow
-3. **Monitor Continuously**: Track performance and adapt strategies
-4. **Plan for Failure**: Design fault tolerance from the beginning
-
-### Operational Guidelines
-1. **Agent Sizing**: Right-size swarms for workload (5-15 agents typical)
-2. **Resource Planning**: Ensure adequate compute/memory for coordination overhead
-3. **Network Design**: Consider latency and bandwidth for distributed topologies
-4. **Security**: Implement proper authentication and authorization
-
-### Troubleshooting
-- **Poor Performance**: Check agent capability matching and load distribution
-- **Coordination Failures**: Verify network connectivity and consensus thresholds
-- **Resource Exhaustion**: Monitor and scale agent pools proactively
-- **Learning Issues**: Validate training data quality and model convergence
-
-## Integration with Claude-Flow
-
-These agents integrate seamlessly with the broader claude-flow ecosystem:
-
-- **Memory System**: All coordination state persisted in claude-flow memory bank
-- **Terminal Management**: Agents can spawn and manage multiple terminal sessions
-- **MCP Integration**: Full access to claude-flow's MCP tool ecosystem
-- **Event System**: Real-time coordination through claude-flow event bus
-- **Configuration**: Managed through claude-flow configuration system
-
-For implementation details, see individual agent files and the claude-flow documentation.
\ No newline at end of file
diff --git a/.claude/settings.json b/.claude/settings.json
index 88eabece19..402bf142d9 100644
--- a/.claude/settings.json
+++ b/.claude/settings.json
@@ -28,10 +28,6 @@
"CLAUDE_FLOW_AUTO_PUSH": "true",
"CLAUDE_FLOW_HOOKS_ENABLED": "true",
"CLAUDE_FLOW_TELEMETRY_ENABLED": "true",
- "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "30",
- "CLAUDE_TEXT_PRUNE_KEEP": "4",
- "CLAUDE_TEXT_PRUNE_THRESHOLD": "20000",
- "CLAUDE_TEXT_PRUNE_MAX_CHARS": "80",
"CLAUDE_FLOW_REMOTE_EXECUTION": "true",
"CLAUDE_FLOW_CHECKPOINTS_ENABLED": "true",
"CLAUDE_FLOW_V3_CLI_ENABLED": "true",
@@ -114,12 +110,12 @@
{
"type": "command",
"timeout": 5000,
- "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh pre-edit \"$TOOL_INPUT_file_path\" 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh pre-edit \"$TOOL_INPUT_file_path\" 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 4000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks pre-edit --file \"$TOOL_INPUT_file_path\" --intelligence true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks pre-edit --file \"$TOOL_INPUT_file_path\" --intelligence true 2>/dev/null || cd ."
}
]
},
@@ -129,12 +125,12 @@
{
"type": "command",
"timeout": 3000,
- "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh pre-command \"$TOOL_INPUT_command\" 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh pre-command \"$TOOL_INPUT_command\" 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks pre-command --command \"$TOOL_INPUT_command\" 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks pre-command --command \"$TOOL_INPUT_command\" 2>/dev/null || cd ."
}
]
},
@@ -144,22 +140,22 @@
{
"type": "command",
"timeout": 2000,
- "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh route \"$TOOL_INPUT_prompt\" 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh route \"$TOOL_INPUT_prompt\" 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "/workspaces/claude-flow/.claude/helpers/swarm-hooks.sh pre-task \"$TOOL_INPUT_prompt\" 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/swarm-hooks.sh pre-task \"$TOOL_INPUT_prompt\" 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "cat | jq -r '.tool_input.prompt // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-task --description '{}' --coordinate-swarm true 2>/dev/null || true"
+ "command": "cat | jq -r '.tool_input.prompt // empty' | tr '\\n' '\\0' | xargs -0 -I {} npx claude-flow@alpha hooks pre-task --description '{}' --coordinate-swarm true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 4000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks pre-task --task-id \"task-$(date +%s)\" --description \"$TOOL_INPUT_prompt\" --intelligence true --swarm-coordinate true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks pre-task --task-id \"task-$(date +%s)\" --description \"$TOOL_INPUT_prompt\" --intelligence true --swarm-coordinate true 2>/dev/null || cd ."
}
]
}
@@ -171,22 +167,22 @@
{
"type": "command",
"timeout": 5000,
- "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh post-edit \"$TOOL_INPUT_file_path\" 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh post-edit \"$TOOL_INPUT_file_path\" 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 4000,
- "command": "/workspaces/claude-flow/.claude/helpers/learning-hooks.sh store \"Edit: $TOOL_INPUT_file_path\" code 0.7 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/learning-hooks.sh store \"Edit: $TOOL_INPUT_file_path\" code 0.7 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 4000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-edit --file \"$TOOL_INPUT_file_path\" --success true --train-patterns true --memory-key \"edit/$TOOL_INPUT_file_path\" 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-edit --file \"$TOOL_INPUT_file_path\" --success true --train-patterns true --memory-key \"edit/$TOOL_INPUT_file_path\" 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 10000,
- "command": "/workspaces/claude-flow/.claude/helpers/auto-commit.sh batch 'Checkpoint: File edits' 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/auto-commit.sh batch 'Checkpoint: File edits' 2>/dev/null || cd ."
}
]
},
@@ -196,17 +192,17 @@
{
"type": "command",
"timeout": 3000,
- "command": "npx agentic-flow@alpha hooks post-command \"$TOOL_INPUT_command\" -c 0 2>/dev/null || true"
+ "command": "npx agentic-flow@alpha hooks post-command \"$TOOL_INPUT_command\" -c 0 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 2000,
- "command": "/workspaces/claude-flow/.claude/helpers/swarm-monitor.sh check 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/swarm-monitor.sh check 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-command --command \"$TOOL_INPUT_command\" --exit-code 0 --success true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-command --command \"$TOOL_INPUT_command\" --exit-code 0 --success true 2>/dev/null || cd ."
}
]
},
@@ -216,32 +212,32 @@
{
"type": "command",
"timeout": 2000,
- "command": "npx agentic-flow@alpha hooks metrics 2>/dev/null || true"
+ "command": "npx agentic-flow@alpha hooks metrics 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "/workspaces/claude-flow/.claude/helpers/swarm-monitor.sh check 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/swarm-monitor.sh check 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "/workspaces/claude-flow/.claude/helpers/swarm-hooks.sh post-task \"$TOOL_INPUT_prompt\" true 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/swarm-hooks.sh post-task \"$TOOL_INPUT_prompt\" true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 4000,
- "command": "/workspaces/claude-flow/.claude/helpers/checkpoint-manager.sh agent-checkpoint \"Task completed: $TOOL_INPUT_prompt\" 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/checkpoint-manager.sh agent-checkpoint \"Task completed: $TOOL_INPUT_prompt\" 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "cat | jq -r '{agent: .tool_input.subagent_type, description: .tool_input.description} | @json' | xargs -I {} npx claude-flow@alpha hooks post-task --agent-data '{}' --update-swarm-status true --train-patterns true 2>/dev/null || true"
+ "command": "cat | jq -r '{agent: .tool_input.subagent_type, description: .tool_input.description} | @json' | xargs -I {} npx claude-flow@alpha hooks post-task --agent-data '{}' --update-swarm-status true --train-patterns true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 4000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-task --task-id \"task-$(date +%s)\" --description \"$TOOL_INPUT_prompt\" --success true --train-patterns true --update-metrics true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-task --task-id \"task-$(date +%s)\" --description \"$TOOL_INPUT_prompt\" --success true --train-patterns true --update-metrics true 2>/dev/null || cd ."
}
]
}
@@ -253,12 +249,12 @@
{
"type": "command",
"timeout": 5000,
- "command": "npx agentic-flow@alpha hooks post-edit \"$TOOL_INPUT_file_path\" --fail 2>/dev/null || true"
+ "command": "npx agentic-flow@alpha hooks post-edit \"$TOOL_INPUT_file_path\" --fail 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 4000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-edit --file \"$TOOL_INPUT_file_path\" --success false --learn-from-failure true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-edit --file \"$TOOL_INPUT_file_path\" --success false --learn-from-failure true 2>/dev/null || cd ."
}
]
},
@@ -268,12 +264,12 @@
{
"type": "command",
"timeout": 3000,
- "command": "npx agentic-flow@alpha hooks post-command \"$TOOL_INPUT_command\" -c 1 2>/dev/null || true"
+ "command": "npx agentic-flow@alpha hooks post-command \"$TOOL_INPUT_command\" -c 1 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-command --command \"$TOOL_INPUT_command\" --exit-code 1 --success false --learn-from-failure true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-command --command \"$TOOL_INPUT_command\" --exit-code 1 --success false --learn-from-failure true 2>/dev/null || cd ."
}
]
},
@@ -283,7 +279,7 @@
{
"type": "command",
"timeout": 4000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-task --task-id \"task-$(date +%s)\" --description \"$TOOL_INPUT_prompt\" --success false --learn-from-failure true --retry-analysis true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks post-task --task-id \"task-$(date +%s)\" --description \"$TOOL_INPUT_prompt\" --success false --learn-from-failure true --retry-analysis true 2>/dev/null || cd ."
}
]
}
@@ -294,47 +290,37 @@
{
"type": "command",
"timeout": 3000,
- "command": "/workspaces/claude-flow/.claude/helpers/daemon-manager.sh start 3 5 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/daemon-manager.sh start 3 5 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 8000,
- "command": "/workspaces/claude-flow/.claude/helpers/learning-hooks.sh session-start 2>/dev/null || true"
- },
- {
- "type": "command",
- "timeout": 6000,
- "command": "node /workspaces/claude-flow/.claude/helpers/auto-memory-hook.mjs import 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/learning-hooks.sh session-start 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "/workspaces/claude-flow/.claude/helpers/swarm-hooks.sh agents 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/swarm-hooks.sh agents 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 5000,
- "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh session-context 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh session-context 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 5000,
- "command": "npx claude-flow@alpha hooks session-start --auto-configure true --restore-context true 2>/dev/null || true"
+ "command": "npx claude-flow@alpha hooks session-start --auto-configure true --restore-context true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 6000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks session-restore --restore-memory true --load-patterns true --intelligence true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks session-restore --restore-memory true --load-patterns true --intelligence true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 4000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks build-agents --topology hierarchical-mesh --max-agents 15 2>/dev/null || true"
- },
- {
- "type": "command",
- "timeout": 6000,
- "command": "node /workspaces/claude-flow/.claude/helpers/context-persistence-hook.mjs session-start 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks build-agents --topology hierarchical-mesh --max-agents 15 2>/dev/null || cd ."
}
]
}
@@ -342,45 +328,40 @@
"SessionEnd": [
{
"hooks": [
- {
- "type": "command",
- "timeout": 8000,
- "command": "node /workspaces/claude-flow/.claude/helpers/auto-memory-hook.mjs sync 2>/dev/null || true"
- },
{
"type": "command",
"timeout": 10000,
- "command": "/workspaces/claude-flow/.claude/helpers/learning-hooks.sh session-end 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/learning-hooks.sh session-end 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 8000,
- "command": "npx agentic-flow@alpha hooks metrics --json 2>/dev/null || true"
+ "command": "npx agentic-flow@alpha hooks metrics --json 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 6000,
- "command": "/workspaces/claude-flow/.claude/helpers/checkpoint-manager.sh session-end \"V3 development session completed\" 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/checkpoint-manager.sh session-end \"V3 development session completed\" 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 4000,
- "command": "/workspaces/claude-flow/.claude/helpers/update-v3-progress.sh status > /workspaces/claude-flow/.claude-flow/last-session-status.txt 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/update-v3-progress.sh status > /workspaces/claude-flow/.claude-flow/last-session-status.txt 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 2000,
- "command": "/workspaces/claude-flow/.claude/helpers/daemon-manager.sh stop 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/daemon-manager.sh stop 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 8000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks session-end --persist-memory true --export-patterns true --generate-summary true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks session-end --persist-memory true --export-patterns true --generate-summary true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 5000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks metrics --format json --output /workspaces/claude-flow/.claude-flow/v3-session-metrics.json 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks metrics --format json --output /workspaces/claude-flow/.claude-flow/v3-session-metrics.json 2>/dev/null || cd ."
}
]
}
@@ -391,27 +372,22 @@
{
"type": "command",
"timeout": 4000,
- "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh user-prompt \"$USER_PROMPT\" 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/guidance-hooks.sh user-prompt \"$USER_PROMPT\" 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 5000,
- "command": "npx claude-flow@alpha hooks route-task --auto-swarm true --detect-complexity true 2>/dev/null || true"
+ "command": "npx claude-flow@alpha hooks route-task --auto-swarm true --detect-complexity true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 5000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks route --task \"$USER_PROMPT\" --intelligence true --auto-swarm true --complexity-threshold 3 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks route --task \"$USER_PROMPT\" --intelligence true --auto-swarm true --complexity-threshold 3 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 6000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks worker detect --prompt \"$USER_PROMPT\" --auto-dispatch --min-confidence 0.6 2>/dev/null || true"
- },
- {
- "type": "command",
- "timeout": 5000,
- "command": "node /workspaces/claude-flow/.claude/helpers/context-persistence-hook.mjs user-prompt-submit 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks worker detect --prompt \"$USER_PROMPT\" --auto-dispatch --min-confidence 0.6 2>/dev/null || cd ."
}
]
}
@@ -423,27 +399,27 @@
{
"type": "command",
"timeout": 8000,
- "command": "/workspaces/claude-flow/.claude/helpers/learning-hooks.sh session-end 2>/dev/null || true"
+ "command": "/workspaces/claude-flow/.claude/helpers/learning-hooks.sh session-end 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 5000,
- "command": "npx agentic-flow@alpha hooks metrics --json 2>/dev/null || true"
+ "command": "npx agentic-flow@alpha hooks metrics --json 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 5000,
- "command": "npx claude-flow@alpha hooks session-end --generate-summary true --persist-state true --export-metrics true 2>/dev/null || true"
+ "command": "npx claude-flow@alpha hooks session-end --generate-summary true --persist-state true --export-metrics true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 6000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks session-end --persist-memory true --train-final-patterns true --export-learnings true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks session-end --persist-memory true --train-final-patterns true --export-learnings true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 4000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks transfer --export-patterns /workspaces/claude-flow/.claude-flow/v3-patterns.json 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks transfer --export-patterns /workspaces/claude-flow/.claude-flow/v3-patterns.json 2>/dev/null || cd ."
}
]
}
@@ -454,12 +430,12 @@
{
"type": "command",
"timeout": 5000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks teammate-idle --auto-assign true --check-task-list true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks teammate-idle --auto-assign true --check-task-list true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "npx claude-flow@alpha hooks teammate-idle --auto-assign true 2>/dev/null || true"
+ "command": "npx claude-flow@alpha hooks teammate-idle --auto-assign true 2>/dev/null || cd ."
}
]
}
@@ -470,12 +446,12 @@
{
"type": "command",
"timeout": 5000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks task-completed --task-id \"$TASK_ID\" --train-patterns true --notify-lead true --update-metrics true 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks task-completed --task-id \"$TASK_ID\" --train-patterns true --notify-lead true --update-metrics true 2>/dev/null || cd ."
},
{
"type": "command",
"timeout": 3000,
- "command": "npx claude-flow@alpha hooks task-completed --train-patterns true --store-results true 2>/dev/null || true"
+ "command": "npx claude-flow@alpha hooks task-completed --train-patterns true --store-results true 2>/dev/null || cd ."
}
]
}
@@ -486,17 +462,12 @@
"hooks": [
{
"type": "command",
- "command": "/bin/bash -c 'INPUT=$(cat); CUSTOM=$(echo \"$INPUT\" | jq -r \".custom_instructions // \\\"\\\"\"); echo \"\ud83d\udd04 PreCompact Guidance:\"; echo \"\ud83d\udccb IMPORTANT: Review CLAUDE.md in project root for:\"; echo \" \u2022 54 available agents and concurrent usage patterns\"; echo \" \u2022 Swarm coordination strategies (hierarchical, mesh, adaptive)\"; echo \" \u2022 SPARC methodology workflows with batchtools optimization\"; echo \" \u2022 Critical concurrent execution rules (GOLDEN RULE: 1 MESSAGE = ALL OPERATIONS)\"; if [ -n \"$CUSTOM\" ]; then echo \"\ud83c\udfaf Custom compact instructions: $CUSTOM\"; fi; echo \"\u2705 Ready for compact operation\"'"
- },
- {
- "type": "command",
- "timeout": 5000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks transfer --export-patterns /workspaces/claude-flow/.claude-flow/compact-patterns.json --preserve-critical true 2>/dev/null || true"
+ "command": "/bin/bash -c 'INPUT=$(cat); CUSTOM=$(echo \"$INPUT\" | jq -r \".custom_instructions // \\\"\\\"\"); echo \"πŸ”„ PreCompact Guidance:\"; echo \"πŸ“‹ IMPORTANT: Review CLAUDE.md in project root for:\"; echo \" β€’ 54 available agents and concurrent usage patterns\"; echo \" β€’ Swarm coordination strategies (hierarchical, mesh, adaptive)\"; echo \" β€’ SPARC methodology workflows with batchtools optimization\"; echo \" β€’ Critical concurrent execution rules (GOLDEN RULE: 1 MESSAGE = ALL OPERATIONS)\"; if [ -n \"$CUSTOM\" ]; then echo \"🎯 Custom compact instructions: $CUSTOM\"; fi; echo \"βœ… Ready for compact operation\"'"
},
{
"type": "command",
"timeout": 5000,
- "command": "node /workspaces/claude-flow/.claude/helpers/context-persistence-hook.mjs pre-compact 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks transfer --export-patterns /workspaces/claude-flow/.claude-flow/compact-patterns.json --preserve-critical true 2>/dev/null || cd ."
}
]
},
@@ -505,17 +476,12 @@
"hooks": [
{
"type": "command",
- "command": "/bin/bash -c 'echo \"\ud83d\udd04 Auto-Compact Guidance (Context Window Full):\"; echo \"\ud83d\udccb CRITICAL: Before compacting, ensure you understand:\"; echo \" \u2022 All 54 agents available in .claude/agents/ directory\"; echo \" \u2022 Concurrent execution patterns from CLAUDE.md\"; echo \" \u2022 Batchtools optimization for 300% performance gains\"; echo \" \u2022 Swarm coordination strategies for complex tasks\"; echo \"\u26a1 Apply GOLDEN RULE: Always batch operations in single messages\"; echo \"\u2705 Auto-compact proceeding with full agent context\"'"
+ "command": "/bin/bash -c 'echo \"πŸ”„ Auto-Compact Guidance (Context Window Full):\"; echo \"πŸ“‹ CRITICAL: Before compacting, ensure you understand:\"; echo \" β€’ All 54 agents available in .claude/agents/ directory\"; echo \" β€’ Concurrent execution patterns from CLAUDE.md\"; echo \" β€’ Batchtools optimization for 300% performance gains\"; echo \" β€’ Swarm coordination strategies for complex tasks\"; echo \"⚑ Apply GOLDEN RULE: Always batch operations in single messages\"; echo \"βœ… Auto-compact proceeding with full agent context\"'"
},
{
"type": "command",
"timeout": 6000,
- "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks intelligence --export-state /workspaces/claude-flow/.claude-flow/intelligence-state.json --preserve-patterns true 2>/dev/null || true"
- },
- {
- "type": "command",
- "timeout": 5000,
- "command": "node /workspaces/claude-flow/.claude/helpers/context-persistence-hook.mjs pre-compact 2>/dev/null || true"
+ "command": "node /workspaces/claude-flow/v3/@claude-flow/cli/bin/cli.js hooks intelligence --export-state /workspaces/claude-flow/.claude-flow/intelligence-state.json --preserve-patterns true 2>/dev/null || cd ."
}
]
}
@@ -606,7 +572,7 @@
},
"attribution": {
"commit": "Co-Authored-By: claude-flow <[email protected]>",
- "pr": "\ud83e\udd16 Generated with [claude-flow](https://github.com/ruvnet/claude-flow)"
+ "pr": "πŸ€– Generated with [claude-flow](https://github.com/ruvnet/claude-flow)"
},
"enabledMcpjsonServers": [
"claude-flow",
@@ -640,4 +606,4 @@
}
}
}
-}
+}
\ No newline at end of file
diff --git a/agents/architect.yaml b/agents/architect.yaml
index e693e1627b..4271188ae5 100644
--- a/agents/architect.yaml
+++ b/agents/architect.yaml
@@ -8,4 +8,4 @@ capabilities:
optimizations:
- context-caching
- memory-persistence
-createdAt: "2026-02-10T20:04:09.233Z"
+createdAt: "2026-02-11T20:42:24.607Z"
diff --git a/agents/coder.yaml b/agents/coder.yaml
index 2021919ef8..404ec5820d 100644
--- a/agents/coder.yaml
+++ b/agents/coder.yaml
@@ -8,4 +8,4 @@ capabilities:
optimizations:
- flash-attention
- token-reduction
-createdAt: "2026-02-10T20:04:09.233Z"
+createdAt: "2026-02-11T20:42:24.606Z"
diff --git a/agents/reviewer.yaml b/agents/reviewer.yaml
index e17cc9a71f..2189e4b181 100644
--- a/agents/reviewer.yaml
+++ b/agents/reviewer.yaml
@@ -7,4 +7,4 @@ capabilities:
- best-practices
optimizations:
- incremental-analysis
-createdAt: "2026-02-10T20:04:09.234Z"
+createdAt: "2026-02-11T20:42:24.607Z"
diff --git a/agents/security-architect.yaml b/agents/security-architect.yaml
index 63bdc49b9b..a585ea99c0 100644
--- a/agents/security-architect.yaml
+++ b/agents/security-architect.yaml
@@ -7,4 +7,4 @@ capabilities:
- security-review
optimizations:
- pattern-matching
-createdAt: "2026-02-10T20:04:09.233Z"
+createdAt: "2026-02-11T20:42:24.607Z"
diff --git a/agents/tester.yaml b/agents/tester.yaml
index 5200da8f77..3137a6a9c4 100644
--- a/agents/tester.yaml
+++ b/agents/tester.yaml
@@ -7,4 +7,4 @@ capabilities:
- coverage
optimizations:
- parallel-execution
-createdAt: "2026-02-10T20:04:09.233Z"
+createdAt: "2026-02-11T20:42:24.607Z"
diff --git a/package-lock.json b/package-lock.json
index a7f8635feb..ee8f6d3edb 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "claude-flow",
- "version": "3.1.0-alpha.28",
+ "version": "3.1.0-alpha.32",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "claude-flow",
- "version": "3.1.0-alpha.28",
+ "version": "3.1.0-alpha.32",
"license": "MIT",
"dependencies": {
"semver": "^7.6.0",
diff --git a/package.json b/package.json
index a06049e522..319d3a7b66 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "claude-flow",
- "version": "3.1.0-alpha.28",
+ "version": "3.1.0-alpha.32",
"description": "Enterprise AI agent orchestration for Claude Code - Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration",
"main": "dist/index.js",
"type": "module",
diff --git a/v3/@claude-flow/cli/README.md b/v3/@claude-flow/cli/README.md
index 14b4d73d76..8a9298cf89 100644
--- a/v3/@claude-flow/cli/README.md
+++ b/v3/@claude-flow/cli/README.md
@@ -2833,6 +2833,120 @@ Real-world scenarios and pre-built workflows for common tasks.
---
+## 🧠 Infinite Context & Memory Optimization
+
+Ruflo eliminates Claude Code's context window ceiling with a real-time memory management system that archives, optimizes, and restores conversation context automatically.
+
+<details>
+<summary>♾️ <strong>Context Autopilot</strong> β€” Never lose context to compaction again</summary>
+
+### The Problem
+
+Claude Code has a finite context window (~200K tokens). When full, it **compacts** β€” summarizing the conversation and discarding details like exact file paths, tool outputs, decision reasoning, and code snippets. This creates a "context cliff" where Claude loses the ability to reference earlier work.
+
+### The Solution: Context Autopilot (ADR-051)
+
+Ruflo intercepts the compaction lifecycle with three hooks that make context loss invisible:
+
+```
+Every Prompt Context Full After Compact
+ β”‚ β”‚ β”‚
+ β–Ό β–Ό β–Ό
+UserPromptSubmit PreCompact SessionStart
+ β”‚ β”‚ β”‚
+ Archive turns Archive + BLOCK Restore from archive
+ to SQLite auto-compaction via additionalContext
+ (incremental) (exit code 2) (importance-ranked)
+ β”‚ β”‚ β”‚
+ β–Ό β–Ό β–Ό
+ Track tokens Manual /compact Seamless continuation
+ Report % used still allowed with full history
+```
+
+### How Memory is Optimized
+
+| Layer | What It Does | When |
+|-------|-------------|------|
+| **Proactive Archiving** | Every user prompt archives new turns to SQLite with SHA-256 dedup | Every prompt |
+| **Token Tracking** | Reads actual API `usage` data (input + cache tokens) for accurate % | Every prompt |
+| **Compaction Blocking** | PreCompact hook returns exit code 2 to cancel auto-compaction | When context fills |
+| **Manual Compact** | `/compact` is allowed β€” archives first, resets autopilot, then compresses | On user request |
+| **Importance Ranking** | Entries scored by `recency Γ— frequency Γ— richness` for smart retrieval | On restore |
+| **Access Tracking** | Restored entries get access_count++ creating a relevance feedback loop | On restore |
+| **Auto-Pruning** | Never-accessed entries older than 30 days are automatically removed | On PreCompact |
+| **Content Compaction** | Old session entries trimmed to summaries, reducing archive storage | Manual or scheduled |
+| **RuVector Sync** | SQLite entries auto-replicated to PostgreSQL when configured | On PreCompact |
+
+### Optimization Thresholds
+
+| Zone | Threshold | Statusline | Action |
+|------|-----------|-----------|--------|
+| OK | <70% | `πŸ›‘οΈ 43% 86.7K ⊘` (green) | Normal operation, track growth trend |
+| Warning | 70-85% | `πŸ›‘οΈ 72% 144K ⊘` (yellow) | Flag approaching limit, archive aggressively |
+| Optimize | 85%+ | `πŸ›‘οΈ 88% 176K ⟳2` (red) | Prune stale entries, keep responses concise |
+
+### Real-Time Statusline
+
+The statusline shows live context metrics read from `autopilot-state.json`:
+
+```
+πŸ›‘οΈ 45% 89.2K ⊘ 🧠 86%
+β”‚ β”‚ β”‚ β”‚ β”‚ β”‚
+β”‚ β”‚ β”‚ β”‚ β”‚ └─ Intelligence score (learning.json + patterns + archive)
+β”‚ β”‚ β”‚ β”‚ └──── Intelligence indicator
+β”‚ β”‚ β”‚ └───────── No prune cycles (⊘) or prune count (⟳N)
+β”‚ β”‚ └─────────────── Token count (actual API usage)
+β”‚ └─────────────────── Context percentage used
+└──────────────────────── Autopilot active (shield icon)
+```
+
+### Storage Tiers
+
+| Tier | Backend | Storage | Features |
+|------|---------|---------|----------|
+| 1 | **SQLite** (default) | `.claude-flow/data/transcript-archive.db` | WAL mode, indexed queries, ACID, importance ranking |
+| 2 | **RuVector PostgreSQL** | Configurable remote | TB-scale, pgvector embeddings, GNN search |
+| 3 | **AgentDB + HNSW** | In-memory + persist | 150x-12,500x faster semantic search |
+| 4 | **JSON** (fallback) | `.claude-flow/data/transcript-archive.json` | Zero dependencies, always works |
+
+### Configuration
+
+```bash
+# Context Autopilot (all have sensible defaults)
+CLAUDE_FLOW_CONTEXT_AUTOPILOT=true # Enable/disable autopilot (default: true)
+CLAUDE_FLOW_CONTEXT_WINDOW=200000 # Context window size in tokens
+CLAUDE_FLOW_AUTOPILOT_WARN=0.70 # Warning threshold (70%)
+CLAUDE_FLOW_AUTOPILOT_PRUNE=0.85 # Optimization threshold (85%)
+CLAUDE_FLOW_COMPACT_RESTORE_BUDGET=4000 # Max chars restored after compaction
+CLAUDE_FLOW_RETENTION_DAYS=30 # Auto-prune never-accessed entries
+CLAUDE_FLOW_AUTO_OPTIMIZE=true # Importance ranking + pruning + sync
+```
+
+### Commands
+
+```bash
+# Check archive status and autopilot state
+node .claude/helpers/context-persistence-hook.mjs status
+
+# Manual compact (archives first, then allows Claude Code to compress)
+# Use /compact in Claude Code β€” autopilot allows manual, blocks auto
+
+# Query archive directly
+sqlite3 .claude-flow/data/transcript-archive.db \
+ "SELECT COUNT(*), SUM(LENGTH(content)) FROM transcript_entries;"
+```
+
+### Architecture Reference
+
+- **ADR-051**: Infinite Context via Compaction-to-Memory Bridge
+- **ADR-052**: Statusline Observability System
+- **Implementation**: `.claude/helpers/context-persistence-hook.mjs` (~1560 lines)
+- **Settings**: `.claude/settings.json` (PreCompact, SessionStart, UserPromptSubmit hooks)
+
+</details>
+
+---
+
## 🧠 Intelligence & Learning
Self-learning hooks, pattern recognition, and intelligent task routing.
diff --git a/v3/@claude-flow/cli/package.json b/v3/@claude-flow/cli/package.json
index 07c905038e..3806c0ca4f 100644
--- a/v3/@claude-flow/cli/package.json
+++ b/v3/@claude-flow/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@claude-flow/cli",
- "version": "3.1.0-alpha.28",
+ "version": "3.1.0-alpha.32",
"type": "module",
"description": "Claude Flow CLI - Enterprise AI agent orchestration with 60+ specialized agents, swarm coordination, MCP server, self-learning hooks, and vector memory for Claude Code",
"main": "dist/src/index.js",
diff --git a/v3/@claude-flow/cli/src/commands/init.ts b/v3/@claude-flow/cli/src/commands/init.ts
index 05d3bc6a4f..d8ebb10596 100644
--- a/v3/@claude-flow/cli/src/commands/init.ts
+++ b/v3/@claude-flow/cli/src/commands/init.ts
@@ -808,6 +808,7 @@ const hooksCommand: Command = {
userPromptSubmit: false,
sessionStart: false,
stop: false,
+ preCompact: false,
notification: false,
timeout: 5000,
continueOnError: true,
diff --git a/v3/@claude-flow/cli/src/init/executor.ts b/v3/@claude-flow/cli/src/init/executor.ts
index e607199fa2..f87b0dce0d 100644
--- a/v3/@claude-flow/cli/src/init/executor.ts
+++ b/v3/@claude-flow/cli/src/init/executor.ts
@@ -25,6 +25,7 @@ import {
generateMemoryHelper,
generateHookHandler,
generateIntelligenceStub,
+ generateAutoMemoryHook,
} from './helpers-generator.js';
import { generateClaudeMd } from './claudemd-generator.js';
@@ -455,6 +456,7 @@ export async function executeUpgrade(targetDir: string, upgradeSettings = false)
const generatedCritical: Record<string, string> = {
'hook-handler.cjs': generateHookHandler(),
'intelligence.cjs': generateIntelligenceStub(),
+ 'auto-memory-hook.mjs': generateAutoMemoryHook(),
};
for (const [helperName, content] of Object.entries(generatedCritical)) {
const targetPath = path.join(targetDir, '.claude', 'helpers', helperName);
@@ -1046,6 +1048,7 @@ async function writeHelpers(
'memory.js': generateMemoryHelper(),
'hook-handler.cjs': generateHookHandler(),
'intelligence.cjs': generateIntelligenceStub(),
+ 'auto-memory-hook.mjs': generateAutoMemoryHook(),
};
for (const [name, content] of Object.entries(helpers)) {
@@ -1125,7 +1128,6 @@ async function writeStatusline(
{ src: 'statusline.mjs', dest: 'statusline.mjs', dir: claudeDir },
];
- let copiedAdvanced = false;
if (sourceClaudeDir) {
for (const file of advancedStatuslineFiles) {
const sourcePath = path.join(sourceClaudeDir, file.src);
@@ -1139,7 +1141,6 @@ async function writeStatusline(
fs.chmodSync(destPath, '755');
}
result.created.files.push(`.claude/${file.dest}`);
- copiedAdvanced = true;
} else {
result.skipped.push(`.claude/${file.dest}`);
}
@@ -1147,26 +1148,16 @@ async function writeStatusline(
}
}
- // Fall back to generating simple statusline if advanced files not available
- if (!copiedAdvanced) {
- const statuslineScript = generateStatuslineScript(options);
- const statuslineHook = generateStatuslineHook(options);
+ // ALWAYS generate statusline.cjs β€” settings.json references this path
+ // regardless of whether advanced statusline files were also copied.
+ const statuslineScript = generateStatuslineScript(options);
+ const statuslinePath = path.join(helpersDir, 'statusline.cjs');
- const files: Record<string, string> = {
- 'statusline.cjs': statuslineScript, // .cjs for ES module project compatibility
- 'statusline-hook.sh': statuslineHook,
- };
-
- for (const [name, content] of Object.entries(files)) {
- const filePath = path.join(helpersDir, name);
-
- if (!fs.existsSync(filePath) || options.force) {
- fs.writeFileSync(filePath, content, 'utf-8');
- result.created.files.push(`.claude/helpers/${name}`);
- } else {
- result.skipped.push(`.claude/helpers/${name}`);
- }
- }
+ if (!fs.existsSync(statuslinePath) || options.force) {
+ fs.writeFileSync(statuslinePath, statuslineScript, 'utf-8');
+ result.created.files.push('.claude/helpers/statusline.cjs');
+ } else {
+ result.skipped.push('.claude/helpers/statusline.cjs');
}
}
@@ -1938,6 +1929,7 @@ function countEnabledHooks(options: InitOptions): number {
if (hooks.userPromptSubmit) count++;
if (hooks.sessionStart) count++;
if (hooks.stop) count++;
+ if (hooks.preCompact) count++;
if (hooks.notification) count++;
return count;
diff --git a/v3/@claude-flow/cli/src/init/helpers-generator.ts b/v3/@claude-flow/cli/src/init/helpers-generator.ts
index 5921ef379c..60ead2044d 100644
--- a/v3/@claude-flow/cli/src/init/helpers-generator.ts
+++ b/v3/@claude-flow/cli/src/init/helpers-generator.ts
@@ -747,6 +747,96 @@ export function generateIntelligenceStub(): string {
return lines.join('\n') + '\n';
}
+/**
+ * Generate a minimal auto-memory-hook.mjs fallback for fresh installs.
+ * This ESM script handles import/sync/status commands gracefully when
+ * @claude-flow/memory is not installed. Gets overwritten when source copy succeeds.
+ */
+export function generateAutoMemoryHook(): string {
+ return `#!/usr/bin/env node
+/**
+ * Auto Memory Bridge Hook (ADR-048/049) β€” Minimal Fallback
+ * Full version is copied from package source when available.
+ *
+ * Usage:
+ * node auto-memory-hook.mjs import # SessionStart
+ * node auto-memory-hook.mjs sync # SessionEnd / Stop
+ * node auto-memory-hook.mjs status # Show bridge status
+ */
+
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
+import { join, dirname } from 'path';
+import { fileURLToPath } from 'url';
+
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = dirname(__filename);
+const PROJECT_ROOT = join(__dirname, '../..');
+const DATA_DIR = join(PROJECT_ROOT, '.claude-flow', 'data');
+const STORE_PATH = join(DATA_DIR, 'auto-memory-store.json');
+
+const DIM = '\\x1b[2m';
+const RESET = '\\x1b[0m';
+const dim = (msg) => console.log(\` \${DIM}\${msg}\${RESET}\`);
+
+// Ensure data dir
+if (!existsSync(DATA_DIR)) mkdirSync(DATA_DIR, { recursive: true });
+
+async function doImport() {
+ // Try loading @claude-flow/memory for full functionality
+ let memPkg = null;
+ try { memPkg = await import('@claude-flow/memory'); } catch {}
+
+ if (!memPkg || !memPkg.AutoMemoryBridge) {
+ dim('Memory package not available β€” auto memory import skipped (non-critical)');
+ return;
+ }
+
+ // Full implementation deferred to copied version
+ dim('Auto memory import available β€” run init --upgrade for full support');
+}
+
+async function doSync() {
+ if (!existsSync(STORE_PATH)) {
+ dim('No entries to sync');
+ return;
+ }
+
+ let memPkg = null;
+ try { memPkg = await import('@claude-flow/memory'); } catch {}
+
+ if (!memPkg || !memPkg.AutoMemoryBridge) {
+ dim('Memory package not available β€” sync skipped (non-critical)');
+ return;
+ }
+
+ dim('Auto memory sync available β€” run init --upgrade for full support');
+}
+
+function doStatus() {
+ console.log('\\n=== Auto Memory Bridge Status ===\\n');
+ console.log(' Package: Fallback mode (run init --upgrade for full)');
+ console.log(\` Store: \${existsSync(STORE_PATH) ? 'Initialized' : 'Not initialized'}\`);
+ console.log('');
+}
+
+const command = process.argv[2] || 'status';
+
+try {
+ switch (command) {
+ case 'import': await doImport(); break;
+ case 'sync': await doSync(); break;
+ case 'status': doStatus(); break;
+ default:
+ console.log('Usage: auto-memory-hook.mjs <import|sync|status>');
+ process.exit(1);
+ }
+} catch (err) {
+ // Hooks must never crash Claude Code - fail silently
+ dim(\`Error (non-critical): \${err.message}\`);
+}
+`;
+}
+
/**
* Generate Windows PowerShell daemon manager
*/
diff --git a/v3/@claude-flow/cli/src/init/settings-generator.ts b/v3/@claude-flow/cli/src/init/settings-generator.ts
index 11d95a309e..322e69da68 100644
--- a/v3/@claude-flow/cli/src/init/settings-generator.ts
+++ b/v3/@claude-flow/cli/src/init/settings-generator.ts
@@ -178,6 +178,9 @@ function generateStatusLineConfig(options: InitOptions): object {
function generateHooksConfig(config: HooksConfig): object {
const hooks: Record<string, unknown[]> = {};
+ // All hook commands use `2>/dev/null || true` to prevent Node.js errors
+ // (e.g. MODULE_NOT_FOUND) from surfacing as hook failures in Claude Code.
+
// PreToolUse β€” validate commands before execution
if (config.preToolUse) {
hooks.PreToolUse = [
@@ -186,7 +189,7 @@ function generateHooksConfig(config: HooksConfig): object {
hooks: [
{
type: 'command',
- command: 'node .claude/helpers/hook-handler.cjs pre-bash',
+ command: 'node .claude/helpers/hook-handler.cjs pre-bash 2>/dev/null || true',
timeout: config.timeout,
},
],
@@ -202,7 +205,7 @@ function generateHooksConfig(config: HooksConfig): object {
hooks: [
{
type: 'command',
- command: 'node .claude/helpers/hook-handler.cjs post-edit',
+ command: 'node .claude/helpers/hook-handler.cjs post-edit 2>/dev/null || true',
timeout: 10000,
},
],
@@ -217,7 +220,7 @@ function generateHooksConfig(config: HooksConfig): object {
hooks: [
{
type: 'command',
- command: 'node .claude/helpers/hook-handler.cjs route',
+ command: 'node .claude/helpers/hook-handler.cjs route 2>/dev/null || true',
timeout: 10000,
},
],
@@ -229,19 +232,16 @@ function generateHooksConfig(config: HooksConfig): object {
if (config.sessionStart) {
hooks.SessionStart = [
{
- matcher: 'startup|resume',
hooks: [
{
type: 'command',
- command: 'node .claude/helpers/hook-handler.cjs session-restore',
+ command: 'node .claude/helpers/hook-handler.cjs session-restore 2>/dev/null || true',
timeout: 15000,
- continueOnError: true,
},
{
type: 'command',
- command: 'node .claude/helpers/auto-memory-hook.mjs import',
+ command: 'node .claude/helpers/auto-memory-hook.mjs import 2>/dev/null || true',
timeout: 8000,
- continueOnError: true,
},
],
},
@@ -255,9 +255,8 @@ function generateHooksConfig(config: HooksConfig): object {
hooks: [
{
type: 'command',
- command: 'node .claude/helpers/hook-handler.cjs session-end',
+ command: 'node .claude/helpers/hook-handler.cjs session-end 2>/dev/null || true',
timeout: 10000,
- continueOnError: true,
},
],
},
@@ -271,9 +270,42 @@ function generateHooksConfig(config: HooksConfig): object {
hooks: [
{
type: 'command',
- command: 'node .claude/helpers/auto-memory-hook.mjs sync',
+ command: 'node .claude/helpers/auto-memory-hook.mjs sync 2>/dev/null || true',
timeout: 10000,
- continueOnError: true,
+ },
+ ],
+ },
+ ];
+ }
+
+ // PreCompact β€” preserve context before compaction
+ if (config.preCompact) {
+ hooks.PreCompact = [
+ {
+ matcher: 'manual',
+ hooks: [
+ {
+ type: 'command',
+ command: `/bin/bash -c 'echo "PreCompact Guidance:"; echo "IMPORTANT: Review CLAUDE.md in project root for:"; echo " - Available agents and concurrent usage patterns"; echo " - Swarm coordination strategies (hierarchical, mesh, adaptive)"; echo " - Critical concurrent execution rules (1 MESSAGE = ALL OPERATIONS)"; echo "Ready for compact operation"'`,
+ },
+ {
+ type: 'command',
+ command: 'node .claude/helpers/hook-handler.cjs session-end 2>/dev/null || true',
+ timeout: 5000,
+ },
+ ],
+ },
+ {
+ matcher: 'auto',
+ hooks: [
+ {
+ type: 'command',
+ command: `/bin/bash -c 'echo "Auto-Compact Guidance (Context Window Full):"; echo "CRITICAL: Before compacting, ensure you understand:"; echo " - All agents available in .claude/agents/ directory"; echo " - Concurrent execution patterns from CLAUDE.md"; echo " - Swarm coordination strategies for complex tasks"; echo "Apply GOLDEN RULE: Always batch operations in single messages"; echo "Auto-compact proceeding with full agent context"'`,
+ },
+ {
+ type: 'command',
+ command: 'node .claude/helpers/hook-handler.cjs session-end 2>/dev/null || true',
+ timeout: 6000,
},
],
},
@@ -286,9 +318,8 @@ function generateHooksConfig(config: HooksConfig): object {
hooks: [
{
type: 'command',
- command: 'node .claude/helpers/hook-handler.cjs status',
+ command: 'node .claude/helpers/hook-handler.cjs status 2>/dev/null || true',
timeout: 3000,
- continueOnError: true,
},
],
},
diff --git a/v3/@claude-flow/cli/src/init/types.ts b/v3/@claude-flow/cli/src/init/types.ts
index 55801fbee4..74eb4036ce 100644
--- a/v3/@claude-flow/cli/src/init/types.ts
+++ b/v3/@claude-flow/cli/src/init/types.ts
@@ -46,6 +46,8 @@ export interface HooksConfig {
sessionStart: boolean;
/** Enable Stop hooks */
stop: boolean;
+ /** Enable PreCompact hooks (context preservation before compaction) */
+ preCompact: boolean;
/** Enable Notification hooks */
notification: boolean;
/** Hook timeout in milliseconds */
@@ -326,6 +328,7 @@ export const DEFAULT_INIT_OPTIONS: InitOptions = {
userPromptSubmit: true,
sessionStart: true,
stop: true,
+ preCompact: true,
notification: true,
timeout: 5000,
continueOnError: true,