fix(okf-hub): excluir variantes MEMORY-*.md no validador e classify

This commit is contained in:
2026-06-28 21:22:53 +01:00
parent 8d4988ad3f
commit b78cc9c465
4 changed files with 38 additions and 1 deletions
+35
View File
@@ -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")
+1
View File
@@ -27,6 +27,7 @@ is_excluded() {
local base
base="$(basename "$rel")"
[[ "$base" == "MEMORY.md" ]] && return 0
[[ "$base" == MEMORY-*.md ]] && return 0
[[ "$base" == "index.md" ]] && return 0
[[ "$base" == "log.md" ]] && return 0
[[ "$base" == "CLAUDE.md" ]] && return 0
+1 -1
View File
@@ -280,7 +280,7 @@ def main():
print(f"{'[DRY-RUN] ' if dry_run else ''}A normalizar OKF em {hub}")
stats, report = scan_hub(hub, dry_run)
report_path = hub / "04-Stack/02.04-Sistemas/MemoriaCentral/scripts/okf-normalize-report.md"
report_path = Path(__file__).parent / "okf-normalize-report.md"
report_path.write_text(report, encoding="utf-8")
print(report_path.read_text(encoding="utf-8").split("## Resultado")[1].strip())
+1
View File
@@ -72,6 +72,7 @@ is_excluded() {
# Check filename patterns
local base
base="$(basename "$rel")"
[[ "$base" == MEMORY-*.md ]] && return 0 # variantes MEMORY legacy
for pat in "${EXCLUDE_FILES[@]}"; do
if [[ "$base" == "$pat" ]]; then
return 0