diff --git a/okf-hub/okf-classify-cloud.py b/okf-hub/okf-classify-cloud.py new file mode 100644 index 0000000..6f27dfe --- /dev/null +++ b/okf-hub/okf-classify-cloud.py @@ -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") diff --git a/okf-hub/okf-classify-layer.sh b/okf-hub/okf-classify-layer.sh index d3e16ce..d07fdb9 100755 --- a/okf-hub/okf-classify-layer.sh +++ b/okf-hub/okf-classify-layer.sh @@ -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 diff --git a/okf-hub/okf-normalize.py b/okf-hub/okf-normalize.py index a7d8850..41411c6 100644 --- a/okf-hub/okf-normalize.py +++ b/okf-hub/okf-normalize.py @@ -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()) diff --git a/okf-hub/okf-validate.sh b/okf-hub/okf-validate.sh index 81ace68..7fca67d 100755 --- a/okf-hub/okf-validate.sh +++ b/okf-hub/okf-validate.sh @@ -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