-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
103 lines (83 loc) · 3.08 KB
/
main.py
File metadata and controls
103 lines (83 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env python3
"""
MicroReview Main Entry Point
This is the main entry point for PR review processing in MicroReview.
It orchestrates the execution of micro-agents on PR diffs and synthesizes
the results into a single review comment.
Following the README requirements:
- DSPy configuration for LLM providers
- Micro-agent orchestration
- Single synthesized PR comment
Usage:
python main.py --pr-diff <diff_file> --config <config_file>
"""
import argparse
import sys
from pathlib import Path
from typing import Dict, Any
from core.orchestrator import AgentOrchestrator
from core.synthesizer import ResultSynthesizer
from core.dspy_config import setup_dspy_for_microreview
from config.loader import ConfigLoader
def main():
"""Main entry point for MicroReview PR processing."""
parser = argparse.ArgumentParser(description="MicroReview PR Analysis")
parser.add_argument(
"--pr-diff",
type=str,
help="Path to PR diff file or diff content"
)
parser.add_argument(
"--config",
type=str,
default=".microreview.yml",
help="Path to MicroReview configuration file"
)
parser.add_argument(
"--repo-path",
type=str,
default=".",
help="Path to the repository being analyzed"
)
args = parser.parse_args()
try:
# Step 1: Configure DSPy as shown in README
print("🔧 Configuring DSPy for LLM providers...")
dspy_configured = setup_dspy_for_microreview()
if dspy_configured:
print("✅ DSPy configured successfully - using LLM-based analysis")
else:
print("⚠️ DSPy not configured - using fallback pattern-based analysis")
# Step 2: Load configuration
config_loader = ConfigLoader()
config = config_loader.load_config(args.config)
# Step 3: Initialize orchestrator
orchestrator = AgentOrchestrator(config)
# Step 4: Read PR diff
if args.pr_diff:
if Path(args.pr_diff).exists():
with open(args.pr_diff, 'r') as f:
pr_diff = f.read()
else:
pr_diff = args.pr_diff
else:
print("Error: --pr-diff is required", file=sys.stderr)
return 1
# Step 5: Run analysis (following README architecture)
print("🔍 Running MicroReview micro-agent analysis...")
findings = orchestrator.run_analysis(pr_diff, args.repo_path)
# Step 6: Synthesize results into single PR comment
print("📝 Synthesizing findings into PR review comment...")
synthesizer = ResultSynthesizer(config)
review_comment = synthesizer.synthesize_findings(findings)
# Step 7: Output results
print("\n" + "="*50)
print("🤖 MicroReview Analysis Complete")
print("="*50)
print(review_comment)
return 0
except Exception as e:
print(f"❌ Error: {e}", file=sys.stderr)
return 1
if __name__ == "__main__":
sys.exit(main())