-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (40 loc) · 1.51 KB
/
Copy pathmain.py
File metadata and controls
46 lines (40 loc) · 1.51 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
import argparse
from agent.prudence import Prudence
from configuration.config import Configuration
from integration.github import GitHubProvider
def main():
parser = argparse.ArgumentParser(description="Prudence: AI Code Reviewer")
parser.add_argument("pr_number", type=int, help="The pull request number to analyze.")
parser.add_argument("--dry-run", action="store_true", help="Print the comments without publishing them to GitHub.")
args = parser.parse_args()
if args.dry_run:
print("\n[DRY RUN] mode activated")
config = Configuration()
GitHubProvider.initialize(
token=config.github_token,
app_id=config.github_app_id,
private_key=config.github_private_key,
installation_id=config.github_installation_id
)
agent = Prudence(config)
reviews = agent.analyze_pr(args.pr_number)
for review in reviews:
print(f"Review for file: {review.file}")
if review.comments:
for comment in review.comments:
print(f" - Line {comment.line}: {comment.body}")
else:
print(" No comments.")
if args.dry_run:
print("\n[DRY RUN] Skipping publishing comments to GitHub PR.")
else:
# Publish comments to GitHub
print("\nPublishing comments to GitHub PR...")
GitHubProvider.comment_pr_file(
repo_name=config.repo_name,
pr_number=args.pr_number,
comments=reviews
)
print("Done!")
if __name__ == "__main__":
main()