"""App version — single source of truth for /api/meta and the SPA footer.

Every code change bumps VERSION and adds a newest-first CHANGELOG.md
entry (coding.md "Versioning = deploy confirmation").
"""

from pathlib import Path

VERSION = "0.21.0"

_CHANGELOG = Path(__file__).resolve().parents[1] / "CHANGELOG.md"


def changelog_head() -> str | None:
    """First '## ' heading of the newest-first CHANGELOG.md, or None."""
    try:
        text = _CHANGELOG.read_text(encoding="utf-8")
    except OSError:
        return None
    for line in text.splitlines():
        if line.startswith("## "):
            return line[3:].strip()
    return None
