-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathtools_run_weekly_summary.py
More file actions
71 lines (57 loc) · 2.24 KB
/
Copy pathtools_run_weekly_summary.py
File metadata and controls
71 lines (57 loc) · 2.24 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
"""Smoke runner: generate a real weekly summary from the live 188-repo DB.
Usage:
python tools_run_weekly_summary.py [--summary weekly|by_tag|top_n|health]
[--tag NAME] [--n N] [--sort KEY]
Reads from ~/.claude/data/ai-team-os/aiteam.db (live archive) and prints
the markdown to stdout. No DB writes, no report_save.
"""
from __future__ import annotations
import argparse
import asyncio
import sys
from pathlib import Path
# Force UTF-8 stdout on Windows so markdown emojis don't trip cp936/GBK.
try:
sys.stdout.reconfigure(encoding="utf-8") # type: ignore[attr-defined]
except Exception:
pass
from aiteam.services.ecosystem_summarizer import EcosystemSummarizer
from aiteam.storage.connection import close_db
from aiteam.storage.repository import StorageRepository
async def _run(args: argparse.Namespace) -> None:
db_path = Path.home() / ".claude" / "data" / "ai-team-os" / "aiteam.db"
db_url = f"sqlite+aiosqlite:///{db_path}"
repo = StorageRepository(db_url=db_url)
summarizer = EcosystemSummarizer(repo)
try:
if args.summary == "weekly":
md = await summarizer.weekly_summary(window_days=args.window)
elif args.summary == "by_tag":
md = await summarizer.by_tag_summary(
args.tag, include_archived=args.include_archived
)
elif args.summary == "top_n":
md = await summarizer.top_n_summary(
category=args.category, n=args.n, sort=args.sort
)
else:
md = await summarizer.health_summary()
finally:
await close_db()
print(md)
def _parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument(
"--summary",
choices=("weekly", "by_tag", "top_n", "health"),
default="weekly",
)
parser.add_argument("--tag", default="")
parser.add_argument("--include-archived", action="store_true")
parser.add_argument("--category", default="")
parser.add_argument("--n", type=int, default=10)
parser.add_argument("--sort", default="stars")
parser.add_argument("--window", type=int, default=7)
return parser.parse_args()
if __name__ == "__main__":
asyncio.run(_run(_parse_args()))