From 1028fb162ccc2f78a7bce1100dfc9df9339ef3c0 Mon Sep 17 00:00:00 2001 From: CypherPoet Date: Sat, 4 Apr 2026 03:07:02 -0500 Subject: [PATCH] fix: match heading depths 1-6 in session-handoff validator The heading-match regex `##?` only recognized `#` and `##`, causing `###` headings (used by the handoff template's own nested structure) to be flagged as missing. This expands the pattern to `#{1,6}` across required-section detection, recommended-section detection, and the next-section boundary used for content-length measurement. Fixes #21 --- skills/session-handoff/scripts/validate_handoff.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/skills/session-handoff/scripts/validate_handoff.py b/skills/session-handoff/scripts/validate_handoff.py index ad1e3c1..892e983 100755 --- a/skills/session-handoff/scripts/validate_handoff.py +++ b/skills/session-handoff/scripts/validate_handoff.py @@ -64,15 +64,15 @@ def check_required_sections(content: str) -> tuple[bool, list[str]]: """Check that required sections exist and have content.""" missing = [] for section in REQUIRED_SECTIONS: - # Look for section header - pattern = rf'(?:^|\n)##?\s*{re.escape(section)}' + # Look for section header at any heading depth (# through ######) + pattern = rf'(?:^|\n)#{{1,6}}\s*{re.escape(section)}' match = re.search(pattern, content, re.IGNORECASE) if not match: missing.append(f"{section} (missing)") else: # Check if section has meaningful content (not just placeholder) section_start = match.end() - next_section = re.search(r'\n##?\s+', content[section_start:]) + next_section = re.search(r'\n#{1,6}\s+', content[section_start:]) section_end = section_start + next_section.start() if next_section else len(content) section_content = content[section_start:section_end].strip() @@ -87,7 +87,7 @@ def check_recommended_sections(content: str) -> list[str]: """Check which recommended sections are missing.""" missing = [] for section in RECOMMENDED_SECTIONS: - pattern = rf'(?:^|\n)##?\s*{re.escape(section)}' + pattern = rf'(?:^|\n)#{{1,6}}\s*{re.escape(section)}' if not re.search(pattern, content, re.IGNORECASE): missing.append(section) return missing