build_patch_plan.py 1011 B

1234567891011121314151617181920212223242526272829
  1. import argparse
  2. import json
  3. import sys
  4. from pathlib import Path
  5. def main() -> int:
  6. parser = argparse.ArgumentParser(description="Normalize a lightweight DOCX edit request into a patch-plan shell.")
  7. parser.add_argument("instruction_json", help="Path to a JSON file containing an 'ops' array")
  8. args = parser.parse_args()
  9. instruction_path = Path(args.instruction_json).expanduser().resolve()
  10. payload = json.loads(instruction_path.read_text(encoding="utf-8"))
  11. result = {
  12. "source": str(instruction_path),
  13. "opCount": len(payload.get("ops", [])),
  14. "ops": payload.get("ops", []),
  15. "note": "This script validates and echoes a candidate patch plan shell. It does not mutate DOCX files.",
  16. }
  17. print(json.dumps(result, ensure_ascii=False, indent=2))
  18. return 0
  19. if __name__ == "__main__":
  20. try:
  21. raise SystemExit(main())
  22. except Exception as exc:
  23. print(f"build_patch_plan.py failed: {exc}", file=sys.stderr)
  24. raise SystemExit(1)