fix(okf-hub): excluir variantes MEMORY-*.md no validador e classify
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Classifica layer raw|wiki nos .md do Cloud (estrutura cliente/pessoal/empresa)."""
|
||||
import sys, re, os
|
||||
from pathlib import Path
|
||||
ROOT = Path("/media/ealmeida/Dados/Cloud")
|
||||
DRY = "--dry-run" in sys.argv
|
||||
|
||||
EPHEMERAL = re.compile(r'(worklog|checkup|sess[aã]o|di[aá]rio|reuni[aã]o|/logs?/|fontes|pesquisa|deep-research|relat[oó]rio-di[aá]rio)', re.I)
|
||||
|
||||
def classify(rel: str) -> str:
|
||||
p = rel.lower()
|
||||
if EPHEMERAL.search(p): return "raw"
|
||||
# armazenamento de cliente/pessoal = raw (lê-se, não se cura como grafo)
|
||||
if p.startswith(("clientes_360/", "clientes/", "eal/", "tomplays/", "docsdrive/")): return "raw"
|
||||
# conhecimento de empresa/admin = wiki
|
||||
if p.startswith(("descomplicar/", "adm_descomplicar/", "adm_missão_pertinente/")): return "wiki"
|
||||
return "wiki" # defeito
|
||||
|
||||
add=upd=0
|
||||
for f in ROOT.rglob("*.md"):
|
||||
rel = str(f.relative_to(ROOT))
|
||||
if any(part.startswith(".") for part in f.parts) or "node_modules" in rel: continue
|
||||
if f.name in ("index.md","log.md"): continue
|
||||
try: txt = f.read_text(encoding="utf-8")
|
||||
except: continue
|
||||
if not txt.startswith("---"): continue
|
||||
end = txt.find("\n---", 3)
|
||||
if end < 0: continue
|
||||
fm = txt[3:end]
|
||||
if re.search(r'^layer:', fm, re.M): continue # já tem
|
||||
layer = classify(rel)
|
||||
new = txt[:end] + f"\nlayer: {layer}" + txt[end:]
|
||||
if not DRY: f.write_text(new, encoding="utf-8")
|
||||
add+=1
|
||||
print(f"{'[DRY] ' if DRY else ''}layer adicionado a {add} ficheiros")
|
||||
Reference in New Issue
Block a user