import os from pathlib import Path def pyra_home() -> Path: return Path.home() / ".pyra" def ensure_dir(path: Path, mode: int = 0o700) -> Path: path.mkdir(parents=True, exist_ok=True) safe_chmod(path, mode) return path def safe_chmod(path: Path, mode: int) -> None: if os.name != "nt": path.chmod(mode) def expand(p: str) -> Path: return Path(p).expanduser().resolve()