Fix workplan frontmatter join and prefix inference (STATE-WP-0067)

Repair glued --- delimiters, infer prefixes from frontmatter ids, and
support bare WP-* workplan schemes.
This commit is contained in:
2026-06-22 23:16:15 +02:00
parent fcb41e8c25
commit ae2302df64
2 changed files with 37 additions and 8 deletions

View File

@@ -14,7 +14,10 @@ ROOT = Path(__file__).resolve().parent.parent
TEMPLATE_DIR = ROOT / "scripts" / "project_rules"
API_BASE = "http://127.0.0.1:8000"
HOME_ROOT = Path("/home/worsch")
WP_FILE_RE = re.compile(r"^([A-Z][A-Z0-9-]*-WP)-\d+")
WP_FILE_RE = re.compile(r"^([A-Za-z][A-Za-z0-9-]*-WP)-\d+", re.IGNORECASE)
WP_BARE_RE = re.compile(r"^(WP)-\d+")
ID_PREFIX_RE = re.compile(r"^id:\s*([A-Z][A-Z0-9-]*-WP)-\d+", re.MULTILINE)
ID_BARE_RE = re.compile(r"^id:\s*(WP)-\d+", re.MULTILINE)
def fetch(path: str):
@@ -70,9 +73,14 @@ def infer_wp_prefix(repo_path: Path, repo_slug: str) -> str:
for workplan in workplans_dir.glob("*.md"):
if workplan.name.startswith("ADHOC"):
continue
match = WP_FILE_RE.match(workplan.name)
if match:
counts[match.group(1)] += 1
text = workplan.read_text(encoding="utf-8", errors="replace")
id_match = ID_PREFIX_RE.search(text) or ID_BARE_RE.search(text)
if id_match:
counts[id_match.group(1)] += 1
continue
file_match = WP_FILE_RE.match(workplan.name) or WP_BARE_RE.match(workplan.name)
if file_match:
counts[file_match.group(1).upper()] += 1
if not counts:
return default_wp_prefix(repo_slug)
top_prefix, top_count = counts.most_common(1)[0]