from __future__ import annotations from pathlib import Path import re from env.config import SUPPORTED_SUFFIXES # Match explicit report markers even when the model emits them inline. _EXPLICIT_MARKER_PATTERN = re.compile( r"(?i)(={2,}[ \t]*" r"(?:dominant emotions?|emotions?|" r"affected life areas?|life areas?|areas|" r"cognitive distortions?|distortions?|" r"balanced reframe|cognitive reframe|reframe|" r"tiny next steps?|small next steps?|next steps?|" r"reflection)" r"[ \t]*={2,})" ) # Match the section heading variants the local model commonly emits. _SECTION_MARKER_PATTERN = re.compile( r"(?im)^[ \t]*(?:[-*][ \t]*)?(?:#{1,6}[ \t]*)?" r"(?:\*\*)?(?:={2,}[ \t]*)?" r"(?P