"""Write-through mirrors under ``get_project_meta_path`` (not committed to customer repos)."""
from __future__ import annotations
import os

# Same logical layout as historical repo path ``p2hs/instructions.md``.
_INSTRUCTIONS_REL = os.path.join("p2hs", "instructions.md")


def instructions_mirror_abs_path(meta_root: str) -> str:
    return os.path.join(meta_root, _INSTRUCTIONS_REL)


def write_instructions_mirror(meta_root: str, content: str) -> None:
    """Persist current instruction text for workers/tools that read the filesystem."""
    path = instructions_mirror_abs_path(meta_root)
    os.makedirs(os.path.dirname(path), exist_ok=True)
    with open(path, "w", encoding="utf-8") as fh:
        fh.write(content or "")
