61 lines
2.3 KiB
Python
61 lines
2.3 KiB
Python
import os
|
|
import re
|
|
|
|
lanes_dir = "/home/donghyeon/Documents/LLM Wiki/docs/superpowers/specs/2026-05-27-branch-notes-audit/lanes"
|
|
lane_files = sorted(os.listdir(lanes_dir))
|
|
|
|
total_files = 0
|
|
matrix_rows = []
|
|
all_findings = []
|
|
|
|
severity_counts = {"Critical": 0, "High": 0, "Medium": 0, "Low": 0}
|
|
|
|
for lf in lane_files:
|
|
if not lf.endswith(".md"):
|
|
continue
|
|
|
|
path = os.path.join(lanes_dir, lf)
|
|
with open(path, "r", encoding="utf-8") as f:
|
|
content = f.read()
|
|
|
|
print(f"Analyzing {lf}...")
|
|
|
|
# 1. Parse Lane Inventory Table
|
|
# Format: | Path | Status | Evidence Lines | Extracted Facts |
|
|
# (Sometimes headers vary, but they usually contain | Path | Status |)
|
|
inventory_matches = re.findall(r"\|\s*raw/branch-notes/([a-zA-Z0-9\-\._]+)\s*\|\s*([A-Z_]+)\s*\|\s*([^|]+)\s*\|\s*([^|\n]+)\s*\|", content)
|
|
for m in inventory_matches:
|
|
file_name, status, evidence, facts = m
|
|
matrix_rows.append({
|
|
"path": f"raw/branch-notes/{file_name.strip()}",
|
|
"status": status.strip(),
|
|
"evidence": evidence.strip(),
|
|
"facts": facts.strip()
|
|
})
|
|
|
|
# 2. Parse Findings
|
|
# Find headers like "Finding X.Y.Z" or "Finding L1-F01" or similar
|
|
findings_headers = re.findall(r"###+ (Finding [^\n]+)", content)
|
|
for fh in findings_headers:
|
|
all_findings.append({
|
|
"lane": lf,
|
|
"header": fh
|
|
})
|
|
|
|
# Let's count severity occurrences in findings
|
|
# Find "Severity: Critical", "심각도: Critical", etc.
|
|
crit_count = len(re.findall(r"(?:Severity|심각도)\s*:\s*Critical", content, re.IGNORECASE))
|
|
high_count = len(re.findall(r"(?:Severity|심각도)\s*:\s*High", content, re.IGNORECASE))
|
|
med_count = len(re.findall(r"(?:Severity|심각도)\s*:\s*Medium", content, re.IGNORECASE))
|
|
low_count = len(re.findall(r"(?:Severity|심각도)\s*:\s*Low", content, re.IGNORECASE))
|
|
|
|
severity_counts["Critical"] += crit_count
|
|
severity_counts["High"] += high_count
|
|
severity_counts["Medium"] += med_count
|
|
severity_counts["Low"] += low_count
|
|
|
|
print(f"\n--- Aggregated Results ---")
|
|
print(f"Total files in inventory: {len(matrix_rows)}")
|
|
print(f"Total findings headers found: {len(all_findings)}")
|
|
print(f"Severity counts: {severity_counts}")
|