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: Edit /workspaces/claude-code-flow/benchmark/examples/basic/simple_sparc.py

rUv3bedc1e020e7
diff --git a/benchmark/.claude/checkpoints/1754447876.json b/benchmark/.claude/checkpoints/1754447876.json
new file mode 100644
index 0000000000..2bb2d55407
--- /dev/null
+++ b/benchmark/.claude/checkpoints/1754447876.json
@@ -0,0 +1 @@
+{"branch": "checkpoint/pre-edit-20250806-023756", "file": "/workspaces/claude-code-flow/benchmark/src/swarm_benchmark/optimization/engine.py", "timestamp": "2025-08-06T02:37:56Z", "type": "pre-edit", "original_branch": "alpha-88"}
diff --git a/benchmark/.claude/checkpoints/1754447878.json b/benchmark/.claude/checkpoints/1754447878.json
new file mode 100644
index 0000000000..3e5c3eb5eb
--- /dev/null
+++ b/benchmark/.claude/checkpoints/1754447878.json
@@ -0,0 +1 @@
+{"tag": "checkpoint-20250806-023758", "file": "/workspaces/claude-code-flow/benchmark/src/swarm_benchmark/optimization/engine.py", "timestamp": "2025-08-06T02:37:58Z", "type": "post-edit", "branch": "alpha-88", "diff_summary": " .claude-flow/metrics/system-metrics.json | 84 +++ benchmark/.claude-flow/metrics/performance.json | 2 +- benchmark/.claude-flow/metrics/task-metrics.json | 6 +- benchmark/.claude/checkpoints/1754447873.json | 1 + benchmark/.claude/checkpoints/1754447875.json | 1 + .../src/swarm_benchmark/optimization/engine.py | 599 +++++++++++++++++++++ claude-flow-wiki | 0 7 files changed, 689 insertions(+), 4 deletions(-) "}
diff --git a/benchmark/examples/basic/simple_sparc.py b/benchmark/examples/basic/simple_sparc.py
new file mode 100644
index 0000000000..2345561a17
--- /dev/null
+++ b/benchmark/examples/basic/simple_sparc.py
@@ -0,0 +1,229 @@
+#!/usr/bin/env python3
+"""
+Simple SPARC benchmark example using Specification, Pseudocode, Architecture, Refinement, Completion.
+
+This example demonstrates:
+- SPARC methodology implementation
+- TDD (Test-Driven Development) integration
+- Progressive refinement tracking
+- Quality assurance metrics
+"""
+
+import subprocess
+import sys
+import json
+from pathlib import Path
+
+def run_sparc_benchmark():
+ """Run a simple SPARC methodology benchmark."""
+ print("⚑ Starting Simple SPARC Benchmark")
+ print("=" * 45)
+
+ # Example 1: CLI with SPARC mode
+ print("\nπŸ“‹ Method 1: CLI with SPARC TDD Mode")
+ cmd = [
+ "swarm-benchmark", "real", "sparc",
+ "Create a user authentication system",
+ "--mode", "tdd",
+ "--agents", "4",
+ "--refinement-cycles", "3"
+ ]
+
+ try:
+ result = subprocess.run(cmd, capture_output=True, text=True, cwd="/workspaces/claude-code-flow/benchmark")
+ if result.returncode == 0:
+ print(f"βœ… SPARC CLI execution successful")
+ print(f"⚑ SPARC output: {result.stdout[:200]}...")
+ else:
+ print(f"❌ CLI execution failed: {result.stderr}")
+ except Exception as e:
+ print(f"⚠️ CLI execution error: {e}")
+
+ # Example 2: Python API with SPARC workflow
+ print("\nπŸ“‹ Method 2: Python API with SPARC Workflow")
+ try:
+ from swarm_benchmark.modes import SparcMode
+
+ # Initialize SPARC coordinator
+ sparc_coordinator = SparcMode(
+ refinement_cycles=3,
+ enable_tdd=True,
+ quality_gates=True
+ )
+
+ # Configure SPARC task
+ sparc_config = {
+ "specification": "User authentication with JWT tokens",
+ "architecture_style": "microservices",
+ "testing_strategy": "unit_and_integration",
+ "completion_threshold": 0.95
+ }
+
+ # Execute SPARC workflow
+ result = sparc_coordinator.execute_sparc_cycle(**sparc_config)
+
+ print(f"βœ… SPARC workflow execution successful")
+ print(f"πŸ“ Architecture completeness: {result.get('architecture_score', 0):.2f}")
+ print(f"πŸ§ͺ Test coverage: {result.get('test_coverage', 0):.2f}")
+
+ except ImportError:
+ print("⚠️ SPARC components not available")
+ demonstrate_mock_sparc_workflow()
+ except Exception as e:
+ print(f"❌ SPARC workflow error: {e}")
+
+def demonstrate_mock_sparc_workflow():
+ """Demonstrate SPARC methodology steps."""
+ print("\n⚑ Mock SPARC Workflow Demo")
+ print("=" * 30)
+
+ # SPARC phases
+ sparc_phases = {
+ "Specification": {
+ "description": "Define clear requirements and constraints",
+ "deliverables": ["Requirements doc", "User stories", "Acceptance criteria"],
+ "completion": 0.85
+ },
+ "Pseudocode": {
+ "description": "High-level algorithm design",
+ "deliverables": ["Algorithm outline", "Data structures", "Flow diagrams"],
+ "completion": 0.78
+ },
+ "Architecture": {
+ "description": "System design and component architecture",
+ "deliverables": ["Architecture diagram", "Component interfaces", "Technology stack"],
+ "completion": 0.92
+ },
+ "Refinement": {
+ "description": "Iterative improvement and optimization",
+ "deliverables": ["Code refinements", "Performance improvements", "Security hardening"],
+ "completion": 0.88
+ },
+ "Completion": {
+ "description": "Final implementation and validation",
+ "deliverables": ["Production code", "Test suite", "Documentation"],
+ "completion": 0.91
+ }
+ }
+
+ print("SPARC Phase Progress:")
+ total_completion = 0
+ for phase, details in sparc_phases.items():
+ completion = details["completion"]
+ total_completion += completion
+ status = "βœ…" if completion > 0.8 else "🟑" if completion > 0.6 else "❌"
+ print(f" {status} {phase}: {completion:.1%}")
+ print(f" πŸ“‹ {details['description']}")
+ print(f" πŸ“¦ Deliverables: {len(details['deliverables'])} items")
+
+ overall_completion = total_completion / len(sparc_phases)
+ print(f"\n🎯 Overall SPARC Completion: {overall_completion:.1%}")
+
+ return {
+ "sparc_completion": overall_completion,
+ "phases_completed": sum(1 for p in sparc_phases.values() if p["completion"] > 0.8),
+ "total_phases": len(sparc_phases)
+ }
+
+def demonstrate_tdd_integration():
+ """Show TDD integration with SPARC."""
+ print("\nπŸ§ͺ TDD Integration with SPARC")
+ print("=" * 32)
+
+ tdd_cycle = {
+ "Red": {
+ "description": "Write failing tests first",
+ "sparc_phase": "Specification",
+ "deliverables": ["Test specifications", "Failure scenarios"]
+ },
+ "Green": {
+ "description": "Implement minimal code to pass tests",
+ "sparc_phase": "Pseudocode + Architecture",
+ "deliverables": ["Basic implementation", "Passing tests"]
+ },
+ "Refactor": {
+ "description": "Improve code quality while maintaining tests",
+ "sparc_phase": "Refinement",
+ "deliverables": ["Clean code", "Optimized performance"]
+ }
+ }
+
+ print("TDD Cycle Integration:")
+ for cycle, details in tdd_cycle.items():
+ print(f" πŸ”΄πŸŸ’πŸ”΅ {cycle}:")
+ print(f" πŸ“ {details['description']}")
+ print(f" ⚑ SPARC Phase: {details['sparc_phase']}")
+ print(f" πŸ“¦ Outputs: {', '.join(details['deliverables'])}")
+
+ # Example test metrics
+ test_metrics = {
+ "test_count": 24,
+ "test_coverage": 0.87,
+ "passing_tests": 22,
+ "failing_tests": 2,
+ "code_quality_score": 8.5,
+ "technical_debt_ratio": 0.15
+ }
+
+ print(f"\nπŸ“Š TDD Metrics:")
+ print(f" πŸ§ͺ Total Tests: {test_metrics['test_count']}")
+ print(f" πŸ“ˆ Coverage: {test_metrics['test_coverage']:.1%}")
+ print(f" βœ… Passing: {test_metrics['passing_tests']}")
+ print(f" ❌ Failing: {test_metrics['failing_tests']}")
+ print(f" 🎯 Quality Score: {test_metrics['code_quality_score']}/10")
+
+def collect_sparc_metrics():
+ """Collect and save SPARC-specific metrics."""
+ print("\nπŸ“Š SPARC Metrics Collection")
+ print("=" * 28)
+
+ # Sample SPARC metrics
+ sparc_metrics = {
+ "benchmark_id": "simple-sparc-demo",
+ "execution_time": 78.5,
+ "agents_count": 4,
+ "methodology": "SPARC",
+ "tdd_enabled": True,
+ "refinement_cycles": 3,
+ "specification_completeness": 0.85,
+ "pseudocode_clarity": 0.78,
+ "architecture_score": 0.92,
+ "refinement_iterations": 2,
+ "completion_quality": 0.91,
+ "test_coverage": 0.87,
+ "code_quality_score": 8.5,
+ "technical_debt_ratio": 0.15,
+ "time_per_phase": {
+ "specification": 12.3,
+ "pseudocode": 15.7,
+ "architecture": 18.9,
+ "refinement": 21.4,
+ "completion": 10.2
+ }
+ }
+
+ print("SPARC methodology metrics:")
+ print(json.dumps(sparc_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_sparc_metrics.json", "w") as f:
+ json.dump(sparc_metrics, f, indent=2)
+
+ print(f"πŸ“ SPARC metrics saved to: {output_dir / 'simple_sparc_metrics.json'}")
+
+if __name__ == "__main__":
+ run_sparc_benchmark()
+ sparc_result = demonstrate_mock_sparc_workflow()
+ demonstrate_tdd_integration()
+ collect_sparc_metrics()
+
+ print("\n⚑ Simple SPARC Benchmark Complete!")
+ print(f"🎯 SPARC completion rate: {sparc_result['sparc_completion']:.1%}")
+ print(f"βœ… Phases completed: {sparc_result['phases_completed']}/{sparc_result['total_phases']}")
+ print("\nNext steps:")
+ print("- Try advanced SPARC patterns in ../advanced/")
+ print("- Run real TDD benchmarks in ../real/")
+ print("- Compare with other development methodologies")
\ No newline at end of file