Files
cp1-agents/sub-agents/ALZ-F01: Discovery Workflow Agent/scripts/render_discovery_report.py
Jonathan Boniface 8bb62a4a42 ALZ-F01 Discovery sub-agent pattern: report phase and fetch in code
Orchestrator report phase (ADR 0013) and fetching in code (ADR 0014), with the report renderer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-05 22:13:25 +00:00

32 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Write the clean Discovery report for an approved run, from the report step's output.
Usage: render_discovery_report.py <step output.json> <report.md> [notice] also writes <report>.html; refuses to overwrite
"""
import importlib.util
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
spec = importlib.util.spec_from_file_location("report", ROOT / "cp1-alz-discovery-orchestrator-agent/app/report.py")
report = importlib.util.module_from_spec(spec)
spec.loader.exec_module(report)
def main() -> int:
source, target = Path(sys.argv[1]), Path(sys.argv[2])
page = target.with_suffix(".html")
if target.exists() or page.exists():
raise SystemExit(f"{target} or {page} exists; reports are never overwritten")
notice = sys.argv[3] if len(sys.argv) > 3 else None
data = json.loads(source.read_text())["report_data"]
target.write_text(report.render(data, notice))
page.write_text(report.render_html(data, notice))
print(f"wrote {target} and {page}")
return 0
if __name__ == "__main__":
sys.exit(main())