import json, os from trilium_api import create_note, get_note_id, set_label, find_note_by_title, update_note_content with open(os.path.expanduser('~/App/Context_continuity/trilium_ids.json')) as f: ids = json.load(f) # Créer le dossier Skills skills_id = find_note_by_title('Skills', ids['root']) if not skills_id: res = create_note(ids['root'], 'Skills', note_type='book') skills_id = get_note_id(res) set_label(skills_id, 'type', 'container') print('Dossier Skills cree:', skills_id) else: print('Dossier Skills existant:', skills_id) # Créer la note skill res = create_note(skills_id, 'Skill - API Trilium ETAPI') nid = get_note_id(res) set_label(nid, 'type', 'skill') set_label(nid, 'domaine', 'trilium') set_label(nid, 'version', '0.95') content = ( '
TriliumNext 0.95 a restructure ses routes internes.
'
'POST /etapi/notes retourne Router not found.
'
'Solution validee : utiliser trilium-py 1.3.9.
pip install trilium-py python-dotenv' '
Token dans .env :
' 'TRILIUM_URL=http://localhost:4292\nTRILIUM_TOKEN=token_genere_dans_Options_ETAPI' '
Header : Authorization: token (sans Bearer)
'
'Bearer accepte depuis 0.93 mais non requis.
Chemin : ~/App/Context_continuity/trilium_api.py
| Fonction | Description |
|---|---|
check_api() | Leve SystemExit si Trilium inaccessible |
create_note(parent_id, title, content=" ", note_type="text") | content=" " obligatoire — pas vide |
get_note_id(result) | Extrait noteId du resultat create_note |
get_note(note_id) | Recupere une note par ID |
get_note_content(note_id) | Recupere le contenu HTML |
update_note_content(note_id, content) | Met a jour le contenu |
search_notes(query, limit=50) | Recherche SANS guillemets autour du terme |
search_by_label(label, value="") | Syntaxe : #label=value |
find_note_by_title(title, parent_id="") | Retourne noteId ou None |
set_label(note_id, name, value="") | isInheritable=False requis en interne |
get_label_value(note_id, name) | Retourne valeur label ou None |
| Erreur | Cause | Fix |
|---|---|---|
| Router not found POST /etapi/notes | TriliumNext 0.95 routing change | Utiliser trilium-py |
| missing argument isInheritable | create_attribute() trilium-py | Passer isInheritable=False |
| Note content must be set | content vide refuse | Passer content=" " |
| Recherche avec guillemets retourne [] | Parser 0.95 | Chercher sans guillemets |
| {status,code,message} sur create | Note existe deja ou contenu vide | find_note_by_title avant + content=" " |
result = create_note(parent_id, "Titre", note_type="text")\nnote_id = get_note_id(result)' '
notes = search_by_label("type", "backlogItem")\nnotes = search_by_label("projet", "SlidingAutomation")'
'set_label(note_id, "statut", "actif")' '
'
'python trilium_context.py new-conversation --projet SlidingAutomation --llm "Claude Sonnet" --titre "Ma session"\n'
'# Travailler... puis quand limite approche :\n'
'python trilium_context.py close-session --note-id ID --summary "..."\n'
'python trilium_context.py generate-context --projet SlidingAutomation --llm-cible "Le Chat Large" --note-id ID --version 2\n'
'# Copier le briefing imprime dans la nouvelle session LLM'
''
'Stockes dans trilium_ids.json apres python trilium_init.py
'
'Cles : root, Projets, Conversations, Backlog, Decisions, Historique, Glossaire, ContextesReprise
python3 -c "\nfrom trilium_api import find_note_by_title, get_note_content\nnid = find_note_by_title(\'Skill - API Trilium ETAPI\')\nprint(get_note_content(nid))\n"' ) update_note_content(nid, content) print('Skill cree et rempli:', nid)