"""Apply Phase 5 mechanical rename to the 3 current docs."""
from __future__ import annotations

import sys
from pathlib import Path

FILES = [
 "docs/guide_ai_client.md",
 "docs/guide_app_controller.md",
 "conductor/code_styleguides/error_handling.md",
]


def main() -> int:
 total = 0
 for rel in FILES:
  p = Path(rel)
  with p.open("r", encoding="utf-8", newline="") as f:
   content = f.read()
  before = content.count("send_result")
  new_content = content.replace("send_result", "send")
  with p.open("w", encoding="utf-8", newline="") as f:
   f.write(new_content)
  remaining = new_content.count("send_result")
  print(f"{rel}: {before} -> {before - remaining} (remaining={remaining})")
  total += before - remaining
 print(f"Total: {total} renamed")
 return 0


if __name__ == "__main__":
 raise SystemExit(main())
