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 = ( '

Skill - API Trilium ETAPI (TriliumNext 0.95+)

' '

Contexte

' '

TriliumNext 0.95 a restructure ses routes internes.
' 'POST /etapi/notes retourne Router not found.
' 'Solution validee : utiliser trilium-py 1.3.9.

' '

Installation

' '
pip install trilium-py python-dotenv
' '

Authentification

' '

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.

' '

Wrapper valide : trilium_api.py

' '

Chemin : ~/App/Context_continuity/trilium_api.py

' '' '' '' '' '' '' '' '' '' '' '' '' '' '
FonctionDescription
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
' '

Erreurs connues et fixes

' '' '' '' '' '' '' '' '
ErreurCauseFix
Router not found POST /etapi/notesTriliumNext 0.95 routing changeUtiliser trilium-py
missing argument isInheritablecreate_attribute() trilium-pyPasser isInheritable=False
Note content must be setcontent vide refusePasser content=" "
Recherche avec guillemets retourne []Parser 0.95Chercher sans guillemets
{status,code,message} sur createNote existe deja ou contenu videfind_note_by_title avant + content=" "
' '

Patterns valides

' '

Creer une note

' '
result = create_note(parent_id, "Titre", note_type="text")\nnote_id = get_note_id(result)
' '

Rechercher par label

' '
notes = search_by_label("type", "backlogItem")\nnotes = search_by_label("projet", "SlidingAutomation")
' '

Ajouter un attribut

' '
set_label(note_id, "statut", "actif")
' '

Workflow bascule LLM

' '
'
    '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'
    '
' '

IDs importants

' '

Stockes dans trilium_ids.json apres python trilium_init.py
' 'Cles : root, Projets, Conversations, Backlog, Decisions, Historique, Glossaire, ContextesReprise

' '

Recuperer ce skill en contexte LLM

' '
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)