-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
189 lines (148 loc) · 5.26 KB
/
run.py
File metadata and controls
189 lines (148 loc) · 5.26 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
"""
AI Agent Trend Report v2 — Main Orchestrator
Pipeline:
1. Collect trending repos from GitHub Topics (stars>1000, active in 7d)
2. Compute velocity-based trend scores
3. Qualitative analysis (optional)
4. Generate trend report
5. Project-specific recommendations (optional)
Usage:
python run.py # Full pipeline
python run.py --skip-analysis # Skip qualitative analysis
python run.py --no-recommend # Skip recommendations
python run.py --project /path/to/proj # Recommendations for specific project
python run.py --report-only # Regenerate from existing data
python run.py --no-push # Skip git push
"""
import argparse
import io
import os
import subprocess
import sys
from datetime import datetime
from pathlib import Path
from dotenv import load_dotenv
# Fix Windows console encoding
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding="utf-8", errors="replace")
BASE_DIR = Path(__file__).resolve().parent
load_dotenv(BASE_DIR / ".env")
def run_step(name: str, func, *args):
"""Run a pipeline step with status logging."""
print(f"\n{'='*50}")
print(f" Step: {name}")
print(f"{'='*50}")
try:
result = func(*args)
print(f" ✓ {name} complete")
return result
except Exception as e:
print(f" ✗ {name} failed: {e}")
raise
def step_collect():
"""Step 1: Collect repos from GitHub Topics."""
from src.collect import collect_all
return collect_all()
def step_metrics(date: str):
"""Step 2: Compute quantitative metrics."""
from src.metrics import run_metrics
return run_metrics(date)
def step_analyze(date: str):
"""Step 3: Run Claude Code analysis."""
from src.analyze import run_analysis
return run_analysis(date)
def step_report(date: str):
"""Step 4: Generate markdown reports."""
from src.report import generate_reports
return generate_reports(date)
def step_trending(date: str):
"""Step 2b: Compute multi-signal trend scores."""
from src.scoring import run_scoring
return run_scoring(date)
def step_gaps(date: str):
"""Step 5: Scan GitHub Issues for tool demand."""
from src.gaps import run_gaps
return run_gaps(date)
def step_opportunities(date: str):
"""Step 6: Generate opportunity report."""
from src.opportunities import run_opportunities
return run_opportunities(date)
def step_recommend(date: str, project_path: str):
"""Step 7: Generate project recommendations."""
from src.recommend import run_recommendations
return run_recommendations(date, project_path)
def step_publish(date: str):
"""Step 6: Git commit & push."""
script = BASE_DIR / "src" / "publish.sh"
result = subprocess.run(
["bash", str(script), date],
cwd=str(BASE_DIR),
capture_output=False,
)
if result.returncode != 0:
print(" Warning: Git publish may have failed")
def main():
parser = argparse.ArgumentParser(description="AI Agent Trend Report Generator")
parser.add_argument(
"--date",
default=datetime.now().strftime("%Y-%m-%d"),
help="Date for the report (YYYY-MM-DD). Default: today",
)
parser.add_argument(
"--skip-analysis",
action="store_true",
help="Skip Claude Code analysis step",
)
parser.add_argument(
"--report-only",
action="store_true",
help="Only generate report from existing data",
)
parser.add_argument(
"--no-push",
action="store_true",
help="Skip git commit & push step",
)
parser.add_argument(
"--project",
default=".",
help="Path to your project for recommendations",
)
parser.add_argument(
"--no-recommend",
action="store_true",
help="Skip project recommendation step",
)
args = parser.parse_args()
print(f"AI Agent Trend Report — {args.date}")
print(f"Base directory: {BASE_DIR}")
if args.report_only:
run_step("Generate Reports", step_report, args.date)
else:
# Full pipeline
raw_data = run_step("Collect Repositories", step_collect)
date = raw_data["date"]
run_step("Compute Trend Scores", step_trending, date)
run_step("Compute Metrics", step_metrics, date)
if not args.skip_analysis:
run_step("Claude Code Analysis", step_analyze, date)
else:
print("\n Skipping Claude Code analysis (--skip-analysis)")
run_step("Generate Reports", step_report, date)
run_step("Scan Tool Gaps", step_gaps, date)
run_step("Generate Opportunities", step_opportunities, date)
if not args.no_recommend:
run_step("Project Recommendations", step_recommend, date, args.project)
else:
print("\n Skipping recommendations (--no-recommend)")
# Git commit & push
if not args.no_push:
run_step("Git Publish", step_publish, args.date)
else:
print("\n Skipping git publish (--no-push)")
print(f"\n{'='*50}")
print(f" Pipeline complete!")
print(f" Report: reports/{args.date}.md")
print(f"{'='*50}")
if __name__ == "__main__":
main()