#!/usr/bin/env python3 """ Example 3: Project Analysis & Quick Wins Shows how to analyze a React project and identify improvement opportunities. """ import asyncio import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).parent.parent)) async def main(): print("=" * 60) print("EXAMPLE 3: Project Analysis & Quick Wins") print("=" * 60) # Use current directory as example project project_path = "." # 1. Scan Project print("\n1. Scanning Project...") print("-" * 60) from tools.analyze.scanner import ProjectScanner scanner = ProjectScanner(project_path) analysis = await scanner.scan() print(f"✅ Project scanned successfully") print(f"\nProject Details:") print(f" Framework: {analysis.framework}") print(f" Styling: {analysis.styling_approach}") print(f" Package Manager: {analysis.package_manager}") print(f" Has TypeScript: {analysis.has_typescript}") print(f" Components Found: {len(analysis.components)}") # 2. Find Quick Wins print("\n2. Finding Quick Wins...") print("-" * 60) from tools.analyze.quick_wins import QuickWinFinder finder = QuickWinFinder(project_path) wins = await finder.find_all() print(f"✅ Found {len(wins.opportunities)} improvement opportunities\n") # Group by type by_type = {} for win in wins.opportunities: win_type = win.type.value if win_type not in by_type: by_type[win_type] = [] by_type[win_type].append(win) print("Breakdown by Type:") for win_type, items in sorted(by_type.items()): print(f" {win_type}: {len(items)} opportunities") # 3. Show Top Priorities (High Impact, Low Effort) print("\n3. Top Priorities (High ROI)") print("-" * 60) high_roi = [ w for w in wins.opportunities if w.impact.value == "high" and w.effort.value in ["low", "medium"] ] if high_roi: for i, win in enumerate(high_roi[:5], 1): print(f"\n{i}. {win.title}") print(f" Type: {win.type.value}") print(f" Impact: {win.impact.value} | Effort: {win.effort.value}") print(f" Description: {win.description}") if win.suggested_fix: print(f" Fix: {win.suggested_fix}") else: print(" No high-ROI opportunities found (project is well-optimized!)") # 4. Generate Report print("\n4. Generating Report...") print("-" * 60) report = await finder.generate_report() print(report[:500] + "..." if len(report) > 500 else report) print("\n" + "=" * 60) print("💡 Next Steps:") print(" 1. Review high-impact, low-effort wins") print(" 2. Create backlog tickets for improvements") print(" 3. Use MCP tools for automated fixes") print("=" * 60) if __name__ == "__main__": asyncio.run(main())