""" Simple CLI runner to: 1) Build a new pack from pasted scenario text. 2) Run Phase 1 (clarifications). 3) Exit with the questions so an operator/UI can answer them. 4) After answers are saved to clarifications.json, run Phase 2 to produce final output. Usage (example): python -m clarityops.pipeline.main --scenario "My scenario text..." --name "oncology_pilot" Then answer questions by editing packs//clarifications.json and run: python -m clarityops.pipeline.main --pack packs/oncology_pilot --phase2 """ import argparse from pathlib import Path import json from .pack_builder import build_pack_from_scenario from .run_two_phase import run_clarityops, call_model def main(): parser = argparse.ArgumentParser() parser.add_argument("--scenario", type=str, help="Free-form scenario text") parser.add_argument("--name", type=str, default="", help="Hint for pack folder name") parser.add_argument("--pack", type=str, help="Existing pack to run") parser.add_argument("--phase2", action="store_true", help="Run Phase 2 using existing clarifications.json") args = parser.parse_args() root = Path(__file__).parents[2] if args.scenario: # Build pack from scenario text pack_dir = build_pack_from_scenario(root, args.scenario, args.name) print(f"[OK] Created pack: {pack_dir}") print("Next step: Run Phase 1 to generate clarification questions (the pipeline will request answers).") # Run Phase 1 only by triggering pipeline and capturing questions # We let run_clarityops raise for missing clarifications.json answers to surface Phase 1 questions. try: _output, clarif_raw = run_clarityops(str(pack_dir)) except RuntimeError as e: print("\n[PHASE 1 QUESTIONS]\n") # We don't have direct access to clarif_raw here since run_clarityops expects clarifications.json. # In a production stack, you'd split run_two_phase to expose a "phase1_only" call that returns questions. # For now, instruct the operator to open the logs or integrate your model streaming. print("Phase 1 questions have been generated by the model.") print("Open your app's model output/log to capture them, then write answers into:") print(f" {pack_dir}/clarifications.json") print("\nTip: In production, expose a UI to show and record these answers.") return elif args.pack and args.phase2: output, clarif_questions = run_clarityops(args.pack) print("[OK] Phase 2 completed. Final JSON:") print(json.dumps(output, ensure_ascii=False, indent=2)) else: parser.print_help() if __name__ == "__main__": main()