-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (32 loc) · 1.15 KB
/
main.py
File metadata and controls
43 lines (32 loc) · 1.15 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
import os
from dotenv import load_dotenv
from github_utils import GitHubConnector
from agent import build_graph
load_dotenv()
def run_review_agent(repo_name, pr_number):
print(f"Starting Review Agent on {repo_name} PR #{pr_number}...")
gh = GitHubConnector(os.getenv("GITHUB_ACCESS_TOKEN"))
pr, files = gh.get_pr_files(repo_name, pr_number)
if not files:
print("No analysable files found (might be all binary or deleted).")
return
print(f"📂 Found {len(files)} files to analyze.")
app = build_graph()
initial_state = {
"repo_name": repo_name,
"pr_number": pr_number,
"files_to_analyze": files,
"final_issues": []
}
result = app.invoke(initial_state)
issues = result["final_issues"]
print(f"Analysis Complete. Found {len(issues)} issues.")
if issues:
gh.post_inline_comments(pr, issues)
else:
pr.create_issue_comment("AI Review: LGTM! No significant issues found.")
print("No issues found. Posted LGTM.")
if __name__ == "__main__":
REPO = "manthan-jsharma/AI-PR-AGENT"
PR_ID = 1
run_review_agent(REPO, PR_ID)