File size: 1,654 Bytes
732b14f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
"""Find LLM prompt-like strings under app/ not referenced in PROMPTS_INVENTORY.md."""
from __future__ import annotations

import re
from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent
INV = (ROOT / "PROMPTS_INVENTORY.md").read_text(encoding="utf-8")

MARKERS = (
    "chat.completions",
    "SystemMessage",
    "HumanMessage",
    "ChatPromptTemplate",
    'role": "system"',
    "messages=[",
)


def main() -> None:
    missing: list[tuple[str, str]] = []
    for py in (ROOT / "app").rglob("*.py"):
        if "tests" in py.parts:
            continue
        text = py.read_text(encoding="utf-8", errors="ignore")
        if not any(m in text for m in MARKERS):
            continue
        for m in re.finditer(r'"""(.*?)"""', text, re.DOTALL):
            s = m.group(1).strip()
            if len(s) < 60:
                continue
            if not any(
                tok in s
                for tok in (
                    "You are",
                    "STRICT",
                    "RICS",
                    "Return ONLY",
                    "MANDATORY",
                    "Validate",
                    "Expand",
                    "merge",
                    "MRICS",
                    "JSON",
                )
            ):
                continue
            probe = s[:50].replace("\n", " ")
            if probe in INV or s[:80] in INV:
                continue
            missing.append((str(py.relative_to(ROOT)), probe))

    print(f"Potentially missing blocks: {len(missing)}")
    for path, probe in missing[:40]:
        print(f"  {path}: {probe}...")


if __name__ == "__main__":
    main()