feat: update-swarm CLI, scout schema, gated and watchlist reports

This commit is contained in:
ginnoir committed 2026-08-14 14:58:55 -05:00
1 parent 5445f82d91
commit a34686f7a5
5 files changed
+173

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env python3
import os, sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__))))
from update_swarm.cli import main
if __name__ == "__main__":
sys.exit(main())
+84
View File
@@ -0,0 +1,84 @@
from __future__ import annotations
import argparse, glob, os, sys
from update_swarm.jobs import build_jobs, init_run
from update_swarm.judge import judge_all
from update_swarm.reports import write_reports
from update_swarm.schema import read_json, write_json
SCOUT_KEYS = ["stem", "latest_english_version", "url", "host", "gate",
"language_matrix", "source_used", "hackdex", "upstream_status", "notes"]
def validate_scout(obj: dict) -> list[str]:
return [k for k in SCOUT_KEYS if k not in obj]
def deploy_argv(pokemon_repo: str, site_repo: str) -> list[list[str]]:
return [
["python", "scripts/build-vault-mocs.py"],
["python", "scripts/build-wiki-data.py"],
["powershell", "-File", "scripts/deploy-site.ps1"],
]
def _load_scouts(run_dir: str) -> dict:
out = {}
for path in glob.glob(os.path.join(run_dir, "scouts", "*.json")):
obj = read_json(path)
errs = validate_scout(obj)
if errs:
raise SystemExit(f"{path} missing keys: {errs}")
out[obj["stem"]] = obj
return out
def _load_census(run_dir: str) -> dict:
out = {}
for path in glob.glob(os.path.join(run_dir, "census", "*.json")):
obj = read_json(path)
out[obj["stem"]] = obj
return out
def main(argv=None) -> int:
p = argparse.ArgumentParser(prog="update-swarm")
p.add_argument("--run", required=False, help="path to .scrape/update-runs/YYYY-MM-DD")
sub = p.add_subparsers(dest="cmd", required=True)
sub.add_parser("init")
pj = sub.add_parser("jobs")
pj.add_argument("--vault", required=True)
sub.add_parser("validate-scouts")
sub.add_parser("judge")
sub.add_parser("reports")
args = p.parse_args(argv)
if args.cmd == "init":
if not args.run:
raise SystemExit("--run is required")
init_run(args.run)
return 0
if args.cmd == "jobs":
if not args.run:
raise SystemExit("--run is required")
jobs = build_jobs(args.vault)
write_json(os.path.join(args.run, "jobs.json"), {"run_date": os.path.basename(args.run), "jobs": jobs})
print(f"wrote {len(jobs)} jobs")
return 0
if args.cmd == "validate-scouts":
if not args.run:
raise SystemExit("--run is required")
_load_scouts(args.run)
print("scouts ok")
return 0
if args.cmd == "judge":
if not args.run:
raise SystemExit("--run is required")
jobs = read_json(os.path.join(args.run, "jobs.json"))["jobs"]
verdicts = judge_all(jobs, _load_census(args.run), _load_scouts(args.run))
write_json(os.path.join(args.run, "verdict.json"), {"verdicts": verdicts})
print(f"wrote {len(verdicts)} verdicts")
return 0
if args.cmd == "reports":
if not args.run:
raise SystemExit("--run is required")
verdicts = read_json(os.path.join(args.run, "verdict.json"))["verdicts"]
write_reports(args.run, verdicts)
return 0
return 1
if __name__ == "__main__":
sys.exit(main())
+14
View File
@@ -0,0 +1,14 @@
from __future__ import annotations
import os
def write_reports(run_dir: str, verdicts: list[dict]) -> None:
gated = [v for v in verdicts if v["bucket"] == "gated_queue"]
watch = [v for v in verdicts if v["bucket"] == "watchlist_report"]
def table(path, title, rows):
lines = [f"# {title}", "", "| Stem | Latest English | Reason |", "|---|---|---|"]
for v in rows:
lines.append(f"| {v['stem']} | {v.get('latest_english_version') or ''} | {v.get('reason') or ''} |")
lines.append("")
open(path, "w", encoding="utf-8").write("\n".join(lines))
table(os.path.join(run_dir, "gated.md"), "Gated queue", gated)
table(os.path.join(run_dir, "watchlist-report.md"), "Watchlist check-in", watch)
+24
View File
@@ -0,0 +1,24 @@
# Scout agent prompt
You are a version scout for one Pokémon ROM hack or fangame. Do not download binaries. Do not invent versions.
Installed version (may be wrong if `source` is `note`): {installed_version} ({installed_source})
Homepage: {homepage}
Source URL: {source}
Find the latest **English** playable build, even if Spanish/French/etc. is newer.
Source order: official site / GitHub releases / project page → HackDex → PokeCommunity → other.
If HackDex is Cloudflare-blocked, set hackdex to "blocked" and continue. Never guess.
Write scouts/{stem}.json with exactly these keys:
- stem (string)
- latest_english_version (string or null)
- url (direct download if ungated, else the page URL, or null)
- host (github|archive|mediafire|mega|itch|drive|discord|kofi|hackdex|pokecommunity|other or null)
- gate (ungated|gated|null)
- language_matrix (object, e.g. {"en": "2.13", "es": "2.18"}; empty object if unknown)
- source_used (website|hackdex|pokecommunity|other or null)
- hackdex (ok|blocked|skipped)
- upstream_status (Complete|Ongoing|Beta or null)
- notes (string)