-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
75 lines (56 loc) · 2.08 KB
/
Copy pathmain.py
File metadata and controls
75 lines (56 loc) · 2.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
"""
main.py — Entry Point
Orchestrates the full pipeline:
Fetch repos → Pull code + README → Classify → Analyze → Report → Log
"""
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent / "src"))
from src.fetcher import fetch_trending_repos
from src.code_puller import pull_code_files
from src.analyzer import analyze_repo, classify_repo
from src.reporter import open_issues
from src.database import init_db, get_already_scanned, mark_repo_scanned, print_stats
def run_audit():
print("=" * 55)
print(" 🤖 CODE AUDITOR — Starting Run")
print("=" * 55)
init_db()
already_seen = get_already_scanned()
print(f"\n[Main] {len(already_seen)} repo(s) already scanned — will skip these.\n")
repos = fetch_trending_repos(already_seen)
if not repos:
print("[Main] No new repos to audit today. Done.")
print_stats()
return
for repo in repos:
full_name = repo["full_name"]
print(f"\n{'─' * 55}")
print(f" 📦 Auditing: {full_name} (★{repo['stars']:,})")
print(f"{'─' * 55}")
# Pull code files + README
files, readme, file_tree = pull_code_files(repo)
if not files:
print(f"[Main] No analyzable files found in {full_name}. Marking as scanned to skip in future.")
mark_repo_scanned(full_name, repo["stars"], [], None)
continue
# Classify repo using Gemini + README
print(f"\n[Main] Classifying repo type...")
repo_context = classify_repo(readme, file_tree)
# Analyze files with full pipeline
findings = analyze_repo(files, repo_context)
# Open one issue per finding (max 3)
issue_urls = open_issues(full_name, findings)
# Log to DB
mark_repo_scanned(
full_name,
repo["stars"],
findings,
issue_urls[0] if issue_urls else None,
)
print(f"\n{'=' * 55}")
print(" ✅ Audit Run Complete")
print(f"{'=' * 55}")
print_stats()
if __name__ == "__main__":
run_audit()