()
| 295 | |
| 296 | |
| 297 | def main() -> int: |
| 298 | ap = argparse.ArgumentParser() |
| 299 | ap.add_argument("--agent", choices=("claude", "codex"), default="claude") |
| 300 | ap.add_argument("--scenario", required=True, help="scenario JSON (one line)") |
| 301 | ap.add_argument("--claude-json", help="path to claude -p json result") |
| 302 | ap.add_argument("--codex-jsonl", help="path to codex exec --json output") |
| 303 | ap.add_argument("--config-dir", help="isolated CLAUDE_CONFIG_DIR") |
| 304 | ap.add_argument("--cwd", required=True, help="cwd the scenario ran in") |
| 305 | ap.add_argument( |
| 306 | "--verify-status", |
| 307 | type=int, |
| 308 | choices=(0, 1), |
| 309 | default=None, |
| 310 | help="exit status from the scenario verify_cmd (0=pass, 1=fail)", |
| 311 | ) |
| 312 | ap.add_argument("--rep", type=int, default=1, help="corpus repetition index") |
| 313 | args = ap.parse_args() |
| 314 | |
| 315 | scenario = load_scenario(args.scenario) |
| 316 | sid = None |
| 317 | transcript = None |
| 318 | td_tools: list[str] = [] |
| 319 | native_tools: list[str] = [] |
| 320 | commands: list[str] = [] |
| 321 | |
| 322 | if args.agent == "claude": |
| 323 | if not args.claude_json or not args.config_dir: |
| 324 | ap.error("--agent claude requires --claude-json and --config-dir") |
| 325 | sid = session_id_from_claude_json(Path(args.claude_json)) |
| 326 | transcript = find_transcript(Path(args.config_dir), args.cwd, sid) |
| 327 | if transcript is not None: |
| 328 | td_tools, native_tools, commands = count_claude_tools(transcript) |
| 329 | else: |
| 330 | if not args.codex_jsonl: |
| 331 | ap.error("--agent codex requires --codex-jsonl") |
| 332 | transcript = Path(args.codex_jsonl) |
| 333 | td_tools, native_tools, commands = count_codex_tools(transcript) |
| 334 | |
| 335 | result = evaluate_scenario( |
| 336 | scenario, |
| 337 | sid, |
| 338 | transcript, |
| 339 | td_tools, |
| 340 | native_tools, |
| 341 | commands, |
| 342 | verify_status=args.verify_status, |
| 343 | rep=args.rep, |
| 344 | ) |
| 345 | print(json.dumps(result)) |
| 346 | return 0 |
| 347 | |
| 348 | |
| 349 | if __name__ == "__main__": |
no test coverage detected