|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +Quick demo of AI-powered task decomposition. |
| 4 | +
|
| 5 | +Shows how Claude intelligently breaks down exploration goals. |
| 6 | +
|
| 7 | +Usage: |
| 8 | + uv run python -m plugins.automation.workflows.examples.demo |
| 9 | +""" |
| 10 | + |
| 11 | +import asyncio |
| 12 | +import sys |
| 13 | +from pathlib import Path |
| 14 | + |
| 15 | +# Add project root to path |
| 16 | +project_root = Path(__file__).parent.parent.parent.parent.parent |
| 17 | +sys.path.insert(0, str(project_root)) |
| 18 | + |
| 19 | +from plugins.automation.workflows.steps.operations import AISplitOperation |
| 20 | + |
| 21 | + |
| 22 | +async def main(): |
| 23 | + print("\n" + "=" * 80) |
| 24 | + print("AI-POWERED TASK DECOMPOSITION DEMO") |
| 25 | + print("=" * 80 + "\n") |
| 26 | + |
| 27 | + # Configure the AI split operation |
| 28 | + config = { |
| 29 | + "model": "haiku", # Fast model for task decomposition |
| 30 | + "max_tasks": 6, # Allow up to 6 parallel tasks |
| 31 | + "min_tasks": 3, # Require at least 3 tasks |
| 32 | + } |
| 33 | + |
| 34 | + inputs = { |
| 35 | + "goal": "Understand how the MCP workflow system orchestrates AI agents", |
| 36 | + "codebase_path": ".", # Current directory (git root) |
| 37 | + "focus_areas": ["architecture", "execution flow", "error handling"], |
| 38 | + "constraints": "Focus on the core workflow engine and step execution" |
| 39 | + } |
| 40 | + |
| 41 | + print("🎯 Goal:") |
| 42 | + print(f" {inputs['goal']}\n") |
| 43 | + |
| 44 | + print("📍 Focus Areas:") |
| 45 | + for area in inputs['focus_areas']: |
| 46 | + print(f" • {area}") |
| 47 | + print() |
| 48 | + |
| 49 | + print("⏳ Asking Claude to decompose this into focused exploration tasks...\n") |
| 50 | + print("-" * 80 + "\n") |
| 51 | + |
| 52 | + # Create and execute operation |
| 53 | + operation = AISplitOperation(config, inputs) |
| 54 | + |
| 55 | + # Validate |
| 56 | + error = operation.validate() |
| 57 | + if error: |
| 58 | + print(f"❌ Validation error: {error}") |
| 59 | + return |
| 60 | + |
| 61 | + try: |
| 62 | + # Execute AI split |
| 63 | + result = await operation.execute() |
| 64 | + |
| 65 | + # Display results |
| 66 | + print("✅ AI Task Decomposition Complete!\n") |
| 67 | + print("=" * 80) |
| 68 | + print(f"AI REASONING:") |
| 69 | + print("=" * 80) |
| 70 | + print(result['reasoning']) |
| 71 | + print() |
| 72 | + |
| 73 | + print("=" * 80) |
| 74 | + print(f"GENERATED TASKS ({result['task_count']} tasks)") |
| 75 | + print("=" * 80 + "\n") |
| 76 | + |
| 77 | + for task in result['tasks']: |
| 78 | + print(f"📋 Task {task['index'] + 1}: {task['title']}") |
| 79 | + print(f" Type: {task['type']}") |
| 80 | + print(f" Priority: {task.get('priority', 'N/A')}") |
| 81 | + print(f" Complexity: {task.get('estimated_complexity', 'N/A')}") |
| 82 | + print(f" Query: {task['query']}") |
| 83 | + print() |
| 84 | + |
| 85 | + print("=" * 80) |
| 86 | + print("METADATA") |
| 87 | + print("=" * 80) |
| 88 | + print(f"Goal: {result['metadata']['goal']}") |
| 89 | + print(f"Codebase: {result['metadata'].get('codebase_path', 'N/A')}") |
| 90 | + print(f"Model: {result['metadata'].get('model', 'haiku')}") |
| 91 | + print(f"Max Tasks: {result['metadata'].get('max_tasks', 'N/A')}") |
| 92 | + print(f"Min Tasks: {result['metadata'].get('min_tasks', 'N/A')}") |
| 93 | + print() |
| 94 | + |
| 95 | + print("💡 Next Steps:") |
| 96 | + print(" • These tasks can now be executed in parallel by ExploreAgent") |
| 97 | + print(" • Each task will store findings in session files") |
| 98 | + print(" • A summarize operation will aggregate all results") |
| 99 | + print(" • See README.md for full workflow examples") |
| 100 | + print() |
| 101 | + |
| 102 | + except Exception as e: |
| 103 | + print(f"❌ Error during execution: {e}") |
| 104 | + import traceback |
| 105 | + traceback.print_exc() |
| 106 | + |
| 107 | + |
| 108 | +if __name__ == "__main__": |
| 109 | + asyncio.run(main()) |
0 commit comments