import pathlib import re import subprocess import sys import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from loop_claude.project.records import HUMAN_RULE_DIR from repo_checks import ROOT # The review standards this repo ships. A project's config may name another folder as `standards`. STANDARDS = "skills/larv-review/standards" # The folders whose files a citation may name by path. The judge reads both. RULE_DIRS = (HUMAN_RULE_DIR, STANDARDS) RULE_PATH = rf"(?:{'|'.join(map(re.escape, RULE_DIRS))})/[\w-]+\.md" NAMES = r'("[^"]+"(?:,? (?:and )?"[^"]+")*)' CITATION = re.compile(rf'`?(?:~/\.claude/)?(CLAUDE\.md|{RULE_PATH})`? → {NAMES}') # A citation of a file in whichever folder the project's config names as `standards`, checked against the folder this repo ships. STANDARD_CITATION = re.compile(rf"the review standards' `([\w-]+\.md)` → {NAMES}") HEADING = re.compile(r"^#+ (.+?)(?: \(.*\))?$", re.MULTILINE) LEAD = re.compile(r"^(?:- )?\*\*(.+?)(?:\*\*|[:.](?=\*\*| )| —)", re.MULTILINE) DECISION_CITATION = re.compile(r"`?docs/decisions\.md`? → `([^`]+)`") DECISION_TITLE = re.compile(r"^## (.+)$", re.MULTILINE) LISTED_TITLE = re.compile(r"^- (.+)$", re.MULTILINE) NAME = re.compile(r'"([^"]+)"') RULE_FILE = re.compile(rf"(?