mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
🏁 Session end checkpoint: session-20250806-113646
This commit is contained in:
1 parent
e3b5e5eada
commit
d24781ea43
12 files changed
+1104
-619
No files matched your search
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"startTime": 1754446452382,
|
||||
"startTime": 1754480199183,
|
||||
"totalTasks": 1,
|
||||
"successfulTasks": 1,
|
||||
"failedTasks": 0,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
[
|
||||
{
|
||||
"id": "cmd-sparc-1754446452479",
|
||||
"type": "sparc",
|
||||
"id": "cmd-hooks-1754480199282",
|
||||
"type": "hooks",
|
||||
"success": true,
|
||||
"duration": 2.4250229999999817,
|
||||
"timestamp": 1754446452481,
|
||||
"duration": 10.741776000000016,
|
||||
"timestamp": 1754480199293,
|
||||
"metadata": {}
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1 @@
|
||||
{"branch": "checkpoint/pre-edit-20250806-113044", "file": "/workspaces/claude-code-flow/benchmark/src/swarm_benchmark/cli/main.py", "timestamp": "2025-08-06T11:30:44Z", "type": "pre-edit", "original_branch": "alpha-88"}
|
||||
@@ -0,0 +1 @@
|
||||
{"tag": "checkpoint-20250806-113046", "file": "/workspaces/claude-code-flow/benchmark/src/swarm_benchmark/cli/main.py", "timestamp": "2025-08-06T11:30:46Z", "type": "post-edit", "branch": "alpha-88", "diff_summary": " .claude-flow/metrics/performance.json | 2 +- .claude-flow/metrics/task-metrics.json | 8 ++++---- .claude/checkpoints/1754479841.json | 1 + .claude/checkpoints/1754479843.json | 1 + .../cli/__pycache__/main.cpython-312.pyc | Bin 22009 -> 28507 bytes benchmark/src/swarm_benchmark/cli/main.py | 4 ++-- .../claude_flow_real_executor.cpython-312.pyc | Bin 24769 -> 24769 bytes benchmark/test_hive_mind.py | 0 claude-flow-wiki | 0 9 files changed, 9 insertions(+), 7 deletions(-) "}
|
||||
File diff suppressed because it is too large.
Load diff
Regular → Executable
+17
-169
@@ -1,186 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
#\!/usr/bin/env python3
|
||||
"""
|
||||
Simple hive-mind benchmark example using collective intelligence.
|
||||
|
||||
This example demonstrates:
|
||||
- Hive-mind initialization
|
||||
- Collective decision making
|
||||
- Neural pattern coordination
|
||||
- Performance tracking
|
||||
Simple hive-mind benchmark example using real claude-flow execution.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
def run_hive_mind_benchmark():
|
||||
"""Run a simple hive-mind benchmark."""
|
||||
print("🧠 Starting Simple Hive-Mind Benchmark")
|
||||
print("=" * 50)
|
||||
|
||||
# Example 1: CLI approach
|
||||
print("\n📋 Method 1: CLI with Hive-Mind Strategy")
|
||||
cmd = [
|
||||
"swarm-benchmark", "real", "hive-mind",
|
||||
"Analyze code patterns and suggest optimizations",
|
||||
"--agents", "5",
|
||||
"--thinking-pattern", "collective",
|
||||
"--coordination", "mesh"
|
||||
"Design a simple REST API",
|
||||
"--max-workers", "3",
|
||||
"--timeout", "2"
|
||||
]
|
||||
|
||||
try:
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, cwd="/workspaces/claude-code-flow/benchmark")
|
||||
if result.returncode == 0:
|
||||
print(f"✅ Hive-mind CLI execution successful")
|
||||
print(f"🧠 Collective output: {result.stdout[:200]}...")
|
||||
else:
|
||||
print(f"❌ CLI execution failed: {result.stderr}")
|
||||
except Exception as e:
|
||||
print(f"⚠️ CLI execution error: {e}")
|
||||
print("Running hive-mind benchmark...")
|
||||
print(f"Command: {' '.join(cmd)}")
|
||||
|
||||
# Example 2: Python API with collective intelligence
|
||||
print("\n📋 Method 2: Python API with Collective Intelligence")
|
||||
try:
|
||||
from swarm_benchmark.collective import HiveMindCoordinator
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
|
||||
if result.returncode == 0:
|
||||
print("✅ Benchmark completed\!")
|
||||
print(result.stdout)
|
||||
else:
|
||||
print(f"❌ Failed: {result.stderr}")
|
||||
|
||||
# Initialize hive-mind coordinator
|
||||
coordinator = HiveMindCoordinator(
|
||||
agents=5,
|
||||
coordination_pattern="mesh",
|
||||
thinking_mode="collective"
|
||||
)
|
||||
|
||||
# Configure collective task
|
||||
task_config = {
|
||||
"objective": "Code analysis and optimization suggestions",
|
||||
"domain": "software_engineering",
|
||||
"collective_threshold": 0.8, # 80% agreement required
|
||||
"iteration_limit": 3
|
||||
}
|
||||
|
||||
# Execute with collective intelligence
|
||||
result = coordinator.execute_collective_task(**task_config)
|
||||
|
||||
print(f"✅ Collective intelligence execution successful")
|
||||
print(f"🎯 Consensus reached: {result.get('consensus_achieved', False)}")
|
||||
print(f"🧠 Collective confidence: {result.get('confidence_score', 0):.2f}")
|
||||
|
||||
except ImportError:
|
||||
print("⚠️ Hive-mind components not available")
|
||||
demonstrate_mock_collective_behavior()
|
||||
except Exception as e:
|
||||
print(f"❌ Collective intelligence error: {e}")
|
||||
|
||||
def demonstrate_mock_collective_behavior():
|
||||
"""Demonstrate collective behavior patterns."""
|
||||
print("\n🧠 Mock Collective Intelligence Demo")
|
||||
print("=" * 40)
|
||||
|
||||
# Simulate collective decision making
|
||||
agents_opinions = [
|
||||
{"agent_id": "alpha", "confidence": 0.85, "decision": "optimize_loops"},
|
||||
{"agent_id": "beta", "confidence": 0.92, "decision": "optimize_loops"},
|
||||
{"agent_id": "gamma", "confidence": 0.78, "decision": "refactor_functions"},
|
||||
{"agent_id": "delta", "confidence": 0.88, "decision": "optimize_loops"},
|
||||
{"agent_id": "epsilon", "confidence": 0.76, "decision": "optimize_loops"}
|
||||
]
|
||||
|
||||
# Calculate collective decision
|
||||
decisions = {}
|
||||
for opinion in agents_opinions:
|
||||
decision = opinion["decision"]
|
||||
confidence = opinion["confidence"]
|
||||
if decision not in decisions:
|
||||
decisions[decision] = {"votes": 0, "total_confidence": 0}
|
||||
decisions[decision]["votes"] += 1
|
||||
decisions[decision]["total_confidence"] += confidence
|
||||
|
||||
# Find consensus
|
||||
best_decision = max(decisions.items(), key=lambda x: x[1]["votes"])
|
||||
consensus_strength = best_decision[1]["total_confidence"] / best_decision[1]["votes"]
|
||||
|
||||
print(f"🎯 Collective Decision: {best_decision[0]}")
|
||||
print(f"📊 Consensus Strength: {consensus_strength:.2f}")
|
||||
print(f"🗳️ Votes: {best_decision[1]['votes']}/5")
|
||||
|
||||
return {
|
||||
"collective_decision": best_decision[0],
|
||||
"consensus_strength": consensus_strength,
|
||||
"participation_rate": 1.0
|
||||
}
|
||||
|
||||
def demonstrate_neural_patterns():
|
||||
"""Show neural coordination patterns."""
|
||||
print("\n🔗 Neural Coordination Patterns")
|
||||
print("=" * 35)
|
||||
|
||||
patterns = {
|
||||
"convergent": "Focused problem solving, single optimal solution",
|
||||
"divergent": "Creative exploration, multiple solution paths",
|
||||
"lateral": "Cross-domain thinking, unexpected connections",
|
||||
"systems": "Holistic analysis, system-wide optimization",
|
||||
"collective": "Group consensus, distributed decision making"
|
||||
}
|
||||
|
||||
print("Available thinking patterns:")
|
||||
for pattern, description in patterns.items():
|
||||
print(f" 🧠 {pattern}: {description}")
|
||||
|
||||
# Example coordination topology
|
||||
print("\nCoordination Topologies:")
|
||||
topologies = {
|
||||
"mesh": "Full connectivity, maximum information sharing",
|
||||
"hierarchical": "Tree structure, efficient coordination",
|
||||
"ring": "Sequential processing, ordered execution",
|
||||
"star": "Central coordinator, hub-and-spoke model"
|
||||
}
|
||||
|
||||
for topology, description in topologies.items():
|
||||
print(f" 🔗 {topology}: {description}")
|
||||
|
||||
def collect_hive_mind_metrics():
|
||||
"""Collect and save hive-mind specific metrics."""
|
||||
print("\n📊 Hive-Mind Metrics Collection")
|
||||
print("=" * 35)
|
||||
|
||||
# Sample hive-mind metrics
|
||||
hive_metrics = {
|
||||
"benchmark_id": "simple-hive-mind-demo",
|
||||
"execution_time": 62.8,
|
||||
"agents_count": 5,
|
||||
"coordination_topology": "mesh",
|
||||
"thinking_pattern": "collective",
|
||||
"consensus_achieved": True,
|
||||
"consensus_strength": 0.87,
|
||||
"iteration_count": 2,
|
||||
"collective_confidence": 0.89,
|
||||
"neural_coordination_efficiency": 92.3,
|
||||
"information_sharing_rate": 0.95,
|
||||
"decision_coherence": 0.91
|
||||
}
|
||||
|
||||
print("Hive-mind specific metrics:")
|
||||
print(json.dumps(hive_metrics, indent=2))
|
||||
|
||||
# Save metrics
|
||||
output_dir = Path("/workspaces/claude-code-flow/benchmark/examples/output")
|
||||
output_dir.mkdir(exist_ok=True)
|
||||
|
||||
with open(output_dir / "simple_hive_mind_metrics.json", "w") as f:
|
||||
json.dump(hive_metrics, f, indent=2)
|
||||
|
||||
print(f"📁 Hive-mind metrics saved to: {output_dir / 'simple_hive_mind_metrics.json'}")
|
||||
return result.returncode == 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_hive_mind_benchmark()
|
||||
demonstrate_neural_patterns()
|
||||
mock_result = demonstrate_mock_collective_behavior()
|
||||
collect_hive_mind_metrics()
|
||||
|
||||
print("\n🧠 Simple Hive-Mind Benchmark Complete!")
|
||||
print(f"🎯 Final collective decision confidence: {mock_result['consensus_strength']:.2f}")
|
||||
print("\nNext steps:")
|
||||
print("- Explore advanced collective intelligence in ../advanced/")
|
||||
print("- Run real hive-mind benchmarks in ../real/")
|
||||
print("- Compare with other coordination patterns")
|
||||
success = run_hive_mind_benchmark()
|
||||
sys.exit(0 if success else 1)
|
||||
@@ -1,53 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Quick test of swarm-benchmark real execution.
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import json
|
||||
import sys
|
||||
|
||||
def test_real_swarm():
|
||||
"""Test real swarm execution with simple task."""
|
||||
print("🧪 Testing swarm-benchmark real execution...")
|
||||
|
||||
# Test with a simple echo command
|
||||
cmd = [
|
||||
"swarm-benchmark", "real", "swarm",
|
||||
"echo hello world",
|
||||
"--max-agents", "1",
|
||||
"--timeout", "10"
|
||||
]
|
||||
|
||||
print(f"Command: {' '.join(cmd)}")
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=15
|
||||
)
|
||||
|
||||
print(f"Return code: {result.returncode}")
|
||||
|
||||
if result.stdout:
|
||||
print("Output:")
|
||||
print(result.stdout[:500])
|
||||
|
||||
if result.stderr:
|
||||
print("Errors:")
|
||||
print(result.stderr[:500])
|
||||
|
||||
return result.returncode == 0
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
print("⏱️ Command timed out (expected for long tasks)")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"❌ Error: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_real_swarm()
|
||||
sys.exit(0 if success else 1)
|
||||
Binary file not shown.
BIN
Binary file not shown.
@@ -1,27 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test hive-mind command directly."""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
# Test command
|
||||
cmd = [
|
||||
"swarm-benchmark",
|
||||
"real",
|
||||
"hive-mind",
|
||||
"Design hello world",
|
||||
"--max-workers", "2",
|
||||
"--timeout", "1"
|
||||
]
|
||||
|
||||
print(f"Running: {' '.join(cmd)}")
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
|
||||
print("STDOUT:")
|
||||
print(result.stdout[:1000] if result.stdout else "(empty)")
|
||||
|
||||
print("\nSTDERR:")
|
||||
print(result.stderr[:1000] if result.stderr else "(empty)")
|
||||
|
||||
print(f"\nReturn code: {result.returncode}")
|
||||
sys.exit(result.returncode)
|
||||
@@ -1,143 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Test real command execution functionality."""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def test_real_command_structure():
|
||||
"""Test that real command structure is working."""
|
||||
print("🔧 Testing real command structure...")
|
||||
|
||||
# Test real command group help
|
||||
result = subprocess.run([
|
||||
"swarm-benchmark", "real", "--help"
|
||||
], capture_output=True, text=True)
|
||||
|
||||
if result.returncode != 0:
|
||||
print(f"❌ Real command group failed: {result.stderr}")
|
||||
return False
|
||||
|
||||
if "Real claude-flow command execution" not in result.stdout:
|
||||
print("❌ Real command group help text missing")
|
||||
return False
|
||||
|
||||
# Test real swarm subcommand help
|
||||
result = subprocess.run([
|
||||
"swarm-benchmark", "real", "swarm", "--help"
|
||||
], capture_output=True, text=True)
|
||||
|
||||
if result.returncode != 0:
|
||||
print(f"❌ Real swarm command failed: {result.stderr}")
|
||||
return False
|
||||
|
||||
if "OBJECTIVE:" not in result.stdout:
|
||||
print("❌ Real swarm command help text missing")
|
||||
return False
|
||||
|
||||
print("✅ Real command structure working correctly")
|
||||
return True
|
||||
|
||||
|
||||
def test_global_options():
|
||||
"""Test that global options are working."""
|
||||
print("🌐 Testing global options...")
|
||||
|
||||
# Test with global options
|
||||
result = subprocess.run([
|
||||
"swarm-benchmark",
|
||||
"--verbose",
|
||||
"--real",
|
||||
"--claude-flow-path", "/custom/path",
|
||||
"--timeout", "10",
|
||||
"--no-stream",
|
||||
"list",
|
||||
"--limit", "1"
|
||||
], capture_output=True, text=True)
|
||||
|
||||
if result.returncode != 0:
|
||||
print(f"❌ Global options test failed: {result.stderr}")
|
||||
return False
|
||||
|
||||
print("✅ Global options working correctly")
|
||||
return True
|
||||
|
||||
|
||||
def test_real_execution_dry_run():
|
||||
"""Test real execution in dry-run mode."""
|
||||
print("🧪 Testing real execution (mock mode)...")
|
||||
|
||||
try:
|
||||
# Import and test the CLI directly to avoid actual execution
|
||||
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
||||
from swarm_benchmark.cli.main import cli
|
||||
from click.testing import CliRunner
|
||||
from unittest.mock import patch
|
||||
|
||||
runner = CliRunner()
|
||||
|
||||
# Mock the real benchmark engine to avoid actual execution
|
||||
with patch('swarm_benchmark.cli.main._run_real_benchmark') as mock_run:
|
||||
mock_run.return_value = {
|
||||
'summary': 'Mock real execution completed',
|
||||
'status': 'success'
|
||||
}
|
||||
|
||||
result = runner.invoke(cli, [
|
||||
'real', 'swarm', 'Simple test task',
|
||||
'--strategy', 'auto',
|
||||
'--max-agents', '1',
|
||||
'--timeout', '1'
|
||||
])
|
||||
|
||||
if result.exit_code != 0:
|
||||
print(f"❌ Real execution test failed: {result.output}")
|
||||
return False
|
||||
|
||||
if 'Real benchmark completed successfully' not in result.output:
|
||||
print(f"❌ Expected success message not found: {result.output}")
|
||||
return False
|
||||
|
||||
print("✅ Real execution dry-run working correctly")
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Real execution test failed with exception: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def main():
|
||||
"""Main test function."""
|
||||
print("🚀 Testing Real Command Execution")
|
||||
print("=" * 50)
|
||||
|
||||
success = True
|
||||
|
||||
# Test 1: Command structure
|
||||
if not test_real_command_structure():
|
||||
success = False
|
||||
|
||||
# Test 2: Global options
|
||||
if not test_global_options():
|
||||
success = False
|
||||
|
||||
# Test 3: Real execution dry-run
|
||||
if not test_real_execution_dry_run():
|
||||
success = False
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
|
||||
if success:
|
||||
print("🎉 ALL REAL EXECUTION TESTS PASSED!")
|
||||
return 0
|
||||
else:
|
||||
print("❌ SOME REAL EXECUTION TESTS FAILED!")
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = main()
|
||||
sys.exit(exit_code)
|
||||
@@ -1,222 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validate CLI is working correctly."""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import json
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def run_command(cmd, timeout=10):
|
||||
"""Run a command and return result."""
|
||||
try:
|
||||
print(f" Running: {' '.join(cmd)}")
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=timeout,
|
||||
cwd=Path(__file__).parent
|
||||
)
|
||||
return result
|
||||
except subprocess.TimeoutExpired:
|
||||
print(f" ⏰ Command timed out after {timeout}s")
|
||||
return None
|
||||
except FileNotFoundError:
|
||||
print(f" ❌ Command not found: {cmd[0]}")
|
||||
return None
|
||||
|
||||
|
||||
def validate_cli():
|
||||
"""Validate CLI is working correctly."""
|
||||
print("🔍 Validating CLI functionality...")
|
||||
print("=" * 50)
|
||||
|
||||
failed_tests = []
|
||||
|
||||
# Test cases: [command, expected_in_output, should_succeed]
|
||||
test_cases = [
|
||||
# Basic help and version
|
||||
(["swarm-benchmark", "--version"], "", True),
|
||||
(["swarm-benchmark", "--help"], "Claude Flow Advanced Swarm Benchmarking Tool", True),
|
||||
|
||||
# Global options in help
|
||||
(["swarm-benchmark", "--help"], "--real / --mock", True),
|
||||
(["swarm-benchmark", "--help"], "--claude-flow-path", True),
|
||||
(["swarm-benchmark", "--help"], "--timeout", True),
|
||||
(["swarm-benchmark", "--help"], "--stream / --no-stream", True),
|
||||
|
||||
# Command help tests
|
||||
(["swarm-benchmark", "run", "--help"], "Run a swarm benchmark", True),
|
||||
(["swarm-benchmark", "list", "--help"], "List recent benchmark runs", True),
|
||||
(["swarm-benchmark", "show", "--help"], "Show details for a specific benchmark", True),
|
||||
(["swarm-benchmark", "clean", "--help"], "Clean up benchmark results", True),
|
||||
(["swarm-benchmark", "serve", "--help"], "Start the benchmark web interface", True),
|
||||
|
||||
# Real command group
|
||||
(["swarm-benchmark", "real", "--help"], "Real claude-flow command execution", True),
|
||||
(["swarm-benchmark", "real", "swarm", "--help"], "Run real claude-flow swarm benchmarks", True),
|
||||
|
||||
# Strategy and mode options
|
||||
(["swarm-benchmark", "run", "--help"], "--strategy", True),
|
||||
(["swarm-benchmark", "run", "--help"], "--mode", True),
|
||||
(["swarm-benchmark", "real", "swarm", "--help"], "--strategy", True),
|
||||
(["swarm-benchmark", "real", "swarm", "--help"], "--mode", True),
|
||||
|
||||
# Invalid commands should fail gracefully
|
||||
(["swarm-benchmark", "nonexistent"], "No such command", False),
|
||||
]
|
||||
|
||||
print(f"📋 Running {len(test_cases)} validation tests...\n")
|
||||
|
||||
for i, (cmd, expected_output, should_succeed) in enumerate(test_cases, 1):
|
||||
print(f"Test {i:2}/{len(test_cases)}: {' '.join(cmd[:3])}{'...' if len(cmd) > 3 else ''}")
|
||||
|
||||
result = run_command(cmd)
|
||||
|
||||
if result is None:
|
||||
failed_tests.append(f"Test {i}: Command failed to run")
|
||||
continue
|
||||
|
||||
# Check if command succeeded as expected
|
||||
if should_succeed and result.returncode != 0:
|
||||
failed_tests.append(f"Test {i}: Expected success but got exit code {result.returncode}")
|
||||
print(f" ❌ Expected success but failed with code {result.returncode}")
|
||||
if result.stderr:
|
||||
print(f" Error: {result.stderr.strip()}")
|
||||
continue
|
||||
|
||||
if not should_succeed and result.returncode == 0:
|
||||
failed_tests.append(f"Test {i}: Expected failure but command succeeded")
|
||||
print(f" ❌ Expected failure but command succeeded")
|
||||
continue
|
||||
|
||||
# Check expected output if provided
|
||||
if expected_output:
|
||||
output = result.stdout + result.stderr
|
||||
if expected_output not in output:
|
||||
failed_tests.append(f"Test {i}: Expected '{expected_output}' not found in output")
|
||||
print(f" ❌ Expected '{expected_output}' not found")
|
||||
continue
|
||||
|
||||
print(f" ✅ Passed")
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
|
||||
if failed_tests:
|
||||
print(f"❌ {len(failed_tests)} test(s) failed:")
|
||||
for failure in failed_tests:
|
||||
print(f" • {failure}")
|
||||
return False
|
||||
else:
|
||||
print(f"🎉 All {len(test_cases)} tests passed!")
|
||||
return True
|
||||
|
||||
|
||||
def validate_installation():
|
||||
"""Validate that the CLI tool is properly installed."""
|
||||
print("📦 Validating installation...")
|
||||
print("=" * 50)
|
||||
|
||||
# Check if swarm-benchmark command is available
|
||||
result = run_command(["which", "swarm-benchmark"])
|
||||
if result and result.returncode == 0:
|
||||
cli_path = result.stdout.strip()
|
||||
print(f"✅ CLI found at: {cli_path}")
|
||||
else:
|
||||
print("⚠️ CLI not found in PATH, trying direct execution...")
|
||||
|
||||
# Try running from local setup
|
||||
project_root = Path(__file__).parent
|
||||
setup_py = project_root / "setup.py"
|
||||
|
||||
if setup_py.exists():
|
||||
print("📦 Installing in development mode...")
|
||||
install_result = run_command([
|
||||
sys.executable, "-m", "pip", "install", "-e", "."
|
||||
], timeout=60)
|
||||
|
||||
if install_result and install_result.returncode == 0:
|
||||
print("✅ Development installation successful")
|
||||
else:
|
||||
print("❌ Development installation failed")
|
||||
return False
|
||||
else:
|
||||
print("❌ No setup.py found for installation")
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def run_integration_test():
|
||||
"""Run a simple integration test."""
|
||||
print("\n🔧 Running integration test...")
|
||||
print("=" * 50)
|
||||
|
||||
# Try to run a simple benchmark command (should not crash)
|
||||
test_cmd = [
|
||||
"swarm-benchmark",
|
||||
"--verbose",
|
||||
"--mock",
|
||||
"list",
|
||||
"--format", "json",
|
||||
"--limit", "1"
|
||||
]
|
||||
|
||||
result = run_command(test_cmd, timeout=30)
|
||||
|
||||
if result is None:
|
||||
print("❌ Integration test failed - command timeout")
|
||||
return False
|
||||
|
||||
if result.returncode != 0:
|
||||
print(f"❌ Integration test failed with exit code {result.returncode}")
|
||||
if result.stderr:
|
||||
print(f"Error output: {result.stderr}")
|
||||
return False
|
||||
|
||||
print("✅ Integration test passed")
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
"""Main validation function."""
|
||||
print("🚀 Claude Flow Swarm Benchmark CLI Validation")
|
||||
print("=" * 50)
|
||||
print(f"Python: {sys.version}")
|
||||
print(f"Working directory: {Path.cwd()}")
|
||||
print()
|
||||
|
||||
success = True
|
||||
|
||||
# Step 1: Validate installation
|
||||
if not validate_installation():
|
||||
print("\n❌ Installation validation failed")
|
||||
success = False
|
||||
|
||||
# Step 2: Validate CLI commands
|
||||
if not validate_cli():
|
||||
print("\n❌ CLI validation failed")
|
||||
success = False
|
||||
|
||||
# Step 3: Run integration test
|
||||
if not run_integration_test():
|
||||
print("\n❌ Integration test failed")
|
||||
success = False
|
||||
|
||||
print("\n" + "=" * 50)
|
||||
|
||||
if success:
|
||||
print("🎉 ALL VALIDATIONS PASSED!")
|
||||
print("The CLI is working correctly and ready for use.")
|
||||
return 0
|
||||
else:
|
||||
print("❌ SOME VALIDATIONS FAILED!")
|
||||
print("Please check the errors above and fix the issues.")
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit_code = main()
|
||||
sys.exit(exit_code)
|
||||
Reference in new issue
Block a user