chore: versioning initial du systeme Context Continuity
Code du systeme de memoire multi-LLM sur Trilium : - trilium_api.py : wrapper trilium-py (notes, labels, relations) - mcp_server.py : serveur MCP Starlette (19 tools, OAuth + Bearer) - api_context.py : API REST FastAPI - trilium_context.py : workflow CLI - watchdog.sh, start_*.sh : supervision et demarrage - skills, docs et ontologie associes Secrets (.env, oauth_state.json) exclus via .gitignore.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
"""Nettoyage one-shot des labels en doublon sur les notes du systeme."""
|
||||
from trilium_api import _ea, search_by_label, get_note
|
||||
|
||||
ea = _ea()
|
||||
LABELS_A_DEDOUBLONNER = ["statut", "priorite", "encoreValide", "type", "projet"]
|
||||
|
||||
# On parcourt tous les types de notes du systeme
|
||||
types_notes = ["backlogItem", "decision", "historiqueItem", "conversation",
|
||||
"termeGlossaire", "projet", "contexteReprise", "skill"]
|
||||
|
||||
notes_traitees = set()
|
||||
total_supprimes = 0
|
||||
|
||||
for tn in types_notes:
|
||||
for n in search_by_label("type", tn):
|
||||
nid = n["noteId"]
|
||||
if nid in notes_traitees:
|
||||
continue
|
||||
notes_traitees.add(nid)
|
||||
note = get_note(nid)
|
||||
attrs = [a for a in note.get("attributes", []) if a.get("type") == "label"]
|
||||
# Grouper par nom de label
|
||||
par_nom = {}
|
||||
for a in attrs:
|
||||
par_nom.setdefault(a.get("name"), []).append(a)
|
||||
for name, lst in par_nom.items():
|
||||
if len(lst) <= 1:
|
||||
continue
|
||||
if name not in LABELS_A_DEDOUBLONNER:
|
||||
continue
|
||||
# Valeur de reference = celle du dernier label (plus recent)
|
||||
valeur_finale = lst[-1].get("value", "")
|
||||
garde = lst[0]
|
||||
# Patcher le premier avec la valeur finale
|
||||
try:
|
||||
ea.patch_attribute(attributeId=garde.get("attributeId"), value=valeur_finale)
|
||||
except Exception as e:
|
||||
print(" patch echoue sur", nid, name, ":", e)
|
||||
# Supprimer tous les autres
|
||||
for doublon in lst[1:]:
|
||||
try:
|
||||
ea.delete_attribute(attributeId=doublon.get("attributeId"))
|
||||
total_supprimes += 1
|
||||
except Exception as e:
|
||||
print(" delete echoue :", e)
|
||||
print(f"{nid} : {name} dedoublonne ({len(lst)} -> 1, valeur={valeur_finale})")
|
||||
|
||||
print(f"\nTermine. {total_supprimes} labels en double supprimes.")
|
||||
Reference in New Issue
Block a user