File size: 1,415 Bytes
6a82282
2588589
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Riprap agent CLI β€” address β†’ cited briefing via the Burr FSM.

Usage:
    python agent.py "180 Beach 35 St, Queens"
    python agent.py "280 Broome St, Manhattan"  --json
"""
from __future__ import annotations

import argparse
import json
import sys
import warnings

warnings.filterwarnings("ignore")

from app.fsm import run  # noqa: E402


def main() -> int:
    ap = argparse.ArgumentParser()
    ap.add_argument("query", help="NYC address or natural-language location")
    ap.add_argument("--json", action="store_true", help="emit full JSON state")
    args = ap.parse_args()

    print(f"\n  query: {args.query}", file=sys.stderr)
    print("  running FSM... (Granite 4.1 + open data, all local)\n", file=sys.stderr)

    result = run(args.query)

    if args.json:
        print(json.dumps(result, indent=2, default=str))
        return 0

    print("─── trace " + "─" * 56)
    for step in result["trace"]:
        ok = "βœ“" if step["ok"] else "βœ—"
        line = f"  {ok} {step['step']:22s} {step.get('elapsed_s', 0):>5.2f}s"
        if step.get("result"):
            line += "  " + json.dumps(step["result"], default=str)
        elif step.get("err"):
            line += "  ERR: " + step["err"]
        print(line)

    print("\n─── cited report " + "─" * 49)
    print()
    print(result["paragraph"])
    print()
    return 0


if __name__ == "__main__":
    sys.exit(main())