#!/usr/bin/env python3 from intake_common import * import argparse import subprocess def draft_for(p, job_path=None): title = f"[ProjectIntakeTower] {p['name']}: bounded read-only handoff" lines = [ f"# {title}", "", "## Project", "", f"- Path: `{p['path']}`", f"- Status: `{p.get('triage_status')}`", f"- Score: `{p.get('score')}`", f"- Risk: `{p.get('risk_level')}`", f"- Technologies: {', '.join(p.get('technologies', []))}", f"- Git dirty tracked files: {p.get('git_status',{}).get('dirty_tracked_count',0)}", "", "## Evidence", "", f"- Project card: `inventory/project_cards/{p['project_id']}.md`", f"- Evidence file: `{p.get('evidence_file')}`", f"- TODO/FIXME/WIP hints: {p.get('todo_fixme_count',0)}", f"- Plan hits: {p.get('plan_hit_count',0)}", "", "## Proposed next action", "", "Run the bounded review-only job and produce `result.json` plus `handoff.md`. Do not modify the source project from this intake issue.", "", "## Bounded job", "", f"- `{job_path or 'jobs/pending/pit-...json'}`", "", "## Acceptance criteria", "", "- One concrete next action is selected.", "- Any human gate is explicit.", "- Verifier command/result is documented.", "- No secrets or source-project modifications.", "", ] return "\n".join(lines) def main(): ap = argparse.ArgumentParser() ap.add_argument("--create", action="store_true", help="Create GitHub issues using gh; requires --repo and --yes") ap.add_argument("--repo", default="", help="GitHub repo OWNER/REPO") ap.add_argument("--yes", action="store_true", help="Confirm issue creation") args = ap.parse_args() ensure_dirs() clear_generated_files(GH_DRAFTS, "*.md") projects = sorted(load_jsonl(INV / "projects.jsonl"), key=project_sort_key) selected = projects[:25] created = 0 for p in selected: job_id = f"pit-{p['project_id']}-review" rel = f"jobs/pending/{job_id}.json" path = GH_DRAFTS / f"{p['project_id']}.md" body = draft_for(p, rel) path.write_text(body, encoding="utf-8") if args.create: if not args.repo or not args.yes: raise SystemExit("--create requires --repo OWNER/REPO --yes") title = body.splitlines()[0].lstrip("# ") subprocess.run(["gh", "issue", "create", "--repo", args.repo, "--title", title, "--body-file", str(path), "--label", "project-intake"], check=True) created += 1 print(json.dumps({"status": "succeeded", "issue_drafts": len(selected), "issues_created": created}, indent=2)) if __name__ == "__main__": main()