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) root_id = ids['root'] # ── Dossier Documentation ────────────────────────────────────────────────── doc_id = find_note_by_title('Documentation', root_id) if not doc_id: res = create_note(root_id, 'Documentation', note_type='book') doc_id = get_note_id(res) set_label(doc_id, 'type', 'container') print('Dossier Documentation cree:', doc_id) else: print('Dossier Documentation existant:', doc_id) # ── Note index Documentation ─────────────────────────────────────────────── res = create_note(doc_id, 'API Context Continuity - Vue densemble') nid = get_note_id(res) set_label(nid, 'type', 'documentation') set_label(nid, 'projet', 'ContextContinuity') update_note_content(nid, '

API Context Continuity

' '

Base URL externe : https://api-trilium.bertha-cloud.fr
' 'Base URL locale : http://localhost:8765
' 'Doc Swagger : https://api-trilium.bertha-cloud.fr/api/docs
' 'Auth : Header Authorization: <API_KEY>

' '

Ressources disponibles

' '' '' '' '' '' '' '' '' '' '
RessourceEndpointsNote Trilium
ProjetsGET /api/projets, GET /api/projets/{nom}, POST, PATCHDocumentation > Projets
BacklogGET /api/backlog/{projet}, POST /api/backlog, PATCHDocumentation > Backlog
DecisionsGET /api/decisions/{projet}, POST, PATCHDocumentation > Decisions
HistoriqueGET /api/historique/{projet}, POST, PATCHDocumentation > Historique
ConversationsGET /api/conversations/{projet}, POST, PATCHDocumentation > Conversations
GlossaireGET /api/glossaire/{projet}, POST, PATCHDocumentation > Glossaire
Contexte RepriseGET /api/contexte/{projet}, GET /api/contexte/{projet}/lastDocumentation > Contexte Reprise
' '

Codes de retour

' '' '' '' '' '' '' '' '
CodeSignification
200OK
201Cree avec succes
401Cle API invalide
404Ressource introuvable
422Validation Pydantic echouee (parametre invalide)
' ) print('Index documentation cree:', nid) # ── Notes par ressource ──────────────────────────────────────────────────── ressources = [ ( 'API - Projets', '

API - Projets

' '

GET /api/projets

' '

Liste tous les projets.

' '
curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/projets
' '

GET /api/projets/{nom}

' '

Detail d un projet par son nom (valeur du label #projet).

' '
curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/projets/SlidingAutomation
' '

POST /api/projets

' '

Cree un nouveau projet.

' '
curl -s -X POST -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"nom":"MonProjet","objectif":"Description","stack":"Python","llm_repartition":"Claude → archi"}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/projets
' '

PATCH /api/projets/{note_id}

' '

Modifie le statut ou l objectif. Champs optionnels : statut (actif|en-pause|archive), objectif, stack.

' '
curl -s -X PATCH -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"statut":"en-pause"}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/projets/NOTE_ID
' ), ( 'API - Backlog', '

API - Backlog

' '

GET /api/backlog/{projet}

' '

Liste les items actifs (hors fait et abandonne), tries par priorite.

' '
curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/backlog/SlidingAutomation
' '

POST /api/backlog

' '

Cree un item. Champs : projet (requis), titre (requis), priorite (haute|moyenne|basse, defaut: moyenne).

' '
curl -s -X POST -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"projet":"SlidingAutomation","titre":"Ma tache","priorite":"haute"}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/backlog
' '

PATCH /api/backlog/{note_id}

' '

Modifie statut ou priorite. statut valide : a faire|en cours|bloque|fait|abandonne.

' '
curl -s -X PATCH -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"statut":"fait"}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/backlog/NOTE_ID
' ), ( 'API - Decisions', '

API - Decisions

' '

GET /api/decisions/{projet}

' '

Liste les decisions actives (statut=active).

' '
curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/decisions/SlidingAutomation
' '

POST /api/decisions

' '

Cree une decision. Champs : projet, enonce (requis), justification, llm.

' '
curl -s -X POST -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"projet":"SlidingAutomation","enonce":"On utilise X","justification":"Parce que Y"}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/decisions
' '

PATCH /api/decisions/{note_id}

' '

Modifie statut (active|revisee|annulee) ou justification.

' '
curl -s -X PATCH -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"statut":"annulee"}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/decisions/NOTE_ID
' ), ( 'API - Historique', '

API - Historique

' '

GET /api/historique/{projet}

' '

Liste les entrees encore valides (encoreValide=true).

' '
curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/historique/SlidingAutomation
' '

POST /api/historique

' '

Cree une entree. type valide : Fait etabli|Test effectue|Hypothese invalidee|Contrainte decouverte.

' '
curl -s -X POST -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"projet":"SlidingAutomation","enonce":"Test X","type":"Test effectue","detail":"Resultat Y"}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/historique
' '

PATCH /api/historique/{note_id}

' '

Invalider une entree obsolete : encore_valide: false.

' '
curl -s -X PATCH -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"encore_valide":false}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/historique/NOTE_ID
' ), ( 'API - Conversations', '

API - Conversations

' '

GET /api/conversations/{projet}

' '

Liste toutes les conversations du projet.

' '
curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/conversations/SlidingAutomation
' '

GET /api/conversations/{projet}/{note_id}

' '

Detail avec contenu HTML d une conversation specifique.

' '

POST /api/conversations

' '

Cree une conversation. llm valide : Claude Sonnet|Claude Opus|Le Chat Large|Le Chat Medium.

' '
curl -s -X POST -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"projet":"SlidingAutomation","titre":"Ma session","llm":"Claude Sonnet"}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/conversations
' '

PATCH /api/conversations/{note_id}

' '

Cloture une session : synthese_cloture (max 500 chars) et/ou statut (en-cours|clos).

' '
curl -s -X PATCH -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"synthese_cloture":"Session terminee. Reste X."}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/conversations/NOTE_ID
' ), ( 'API - Glossaire', '

API - Glossaire

' '

GET /api/glossaire/{projet}

' '

Liste les termes avec contenu (definition).

' '
curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/glossaire/SlidingAutomation
' '

POST /api/glossaire

' '

Cree un terme. Champs : projet, terme, definition (requis), synonymes_eviter.

' '
curl -s -X POST -H "Authorization: CLE" -H "Content-Type: application/json" \\\n'
        '-d \'{"projet":"SlidingAutomation","terme":"Pipeline","definition":"Chaine complete de traitement"}\' \\\n'
        'https://api-trilium.bertha-cloud.fr/api/glossaire
' '

PATCH /api/glossaire/{note_id}

' '

Modifie definition et/ou synonymes_eviter.

' ), ( 'API - Contexte Reprise', '

API - Contexte Reprise

' '

GET /api/contexte/{projet}?llm_cible=NomLLM

' '

Genere et retourne le briefing de reprise en temps reel depuis Trilium.

' '
curl -s -H "Authorization: CLE" \\\n'
        '"https://api-trilium.bertha-cloud.fr/api/contexte/SlidingAutomation?llm_cible=Le+Chat+Large"
' '

Retourne : {"projet":"...","tokens":N,"briefing":"# REPRISE DE CONTEXTE..."}

' '

GET /api/contexte/{projet}/last

' '

Retourne le dernier contexte de reprise sauvegarde dans Trilium.

' '
curl -s -H "Authorization: CLE" \\\n'
        'https://api-trilium.bertha-cloud.fr/api/contexte/SlidingAutomation/last
' ), ] for titre, contenu in ressources: res = create_note(doc_id, titre) nid = get_note_id(res) set_label(nid, 'type', 'documentation') set_label(nid, 'projet', 'ContextContinuity') update_note_content(nid, contenu) print('Doc cree:', titre) # ── Skill API FastAPI pour LLMs ──────────────────────────────────────────── skills_id = find_note_by_title('Skills', root_id) res = create_note(skills_id, 'Skill - API FastAPI Context Continuity') nid = get_note_id(res) set_label(nid, 'type', 'skill') set_label(nid, 'domaine', 'api') set_label(nid, 'version', '1.0') update_note_content(nid, '

Skill - API FastAPI Context Continuity

' '

Ce skill permet a un LLM d appeler directement l API pour lire et ecrire dans Trilium.

' '

Configuration

' '' '' '' '' '' '' '' '
ParametreValeur
Base URLhttps://api-trilium.bertha-cloud.fr
Auth headerAuthorization: <API_KEY>
Cle ClaudeDemander a Bastien ou lire dans .env
Cle Le ChatDemander a Bastien ou lire dans .env
Doc Swaggerhttps://api-trilium.bertha-cloud.fr/api/docs
' '

Endpoints essentiels pour un LLM

' '' '' '' '' '' '' '' '' '' '
ActionAppel
Lire le contexte projetGET /api/contexte/{projet}?llm_cible=NomLLM
Voir le backlogGET /api/backlog/{projet}
Enregistrer une decisionPOST /api/decisions
Enregistrer un historiquePOST /api/historique
Creer une conversationPOST /api/conversations
Cloturer une sessionPATCH /api/conversations/{id}
Marquer backlog item faitPATCH /api/backlog/{id}
' '

Valeurs valides par champ

' '' '' '' '' '' '' '' '' '
ChampValeurs acceptees
prioritehaute | moyenne | basse
statut backloga faire | en cours | bloque | fait | abandonne
statut decisionactive | revisee | annulee
type historiqueFait etabli | Test effectue | Hypothese invalidee | Contrainte decouverte
llm conversationClaude Sonnet | Claude Opus | Le Chat Large | Le Chat Medium
statut projetactif | en-pause | archive
' '

Exemples curl complets

' '

Lire le contexte de reprise

' '
curl -s -H "Authorization: CLE" \\\n'
    '"https://api-trilium.bertha-cloud.fr/api/contexte/SlidingAutomation?llm_cible=Le+Chat+Large" \\\n'
    '| python3 -c "import sys,json; print(json.load(sys.stdin)[\'briefing\'])"
' '

Enregistrer une decision

' '
curl -s -X POST \\\n'
    '-H "Authorization: CLE" \\\n'
    '-H "Content-Type: application/json" \\\n'
    '-d \'{"projet":"SlidingAutomation","enonce":"Decision prise","justification":"Raison"}\' \\\n'
    'https://api-trilium.bertha-cloud.fr/api/decisions
' '

Marquer un item backlog comme fait

' '
curl -s -X PATCH \\\n'
    '-H "Authorization: CLE" \\\n'
    '-H "Content-Type: application/json" \\\n'
    '-d \'{"statut":"fait"}\' \\\n'
    'https://api-trilium.bertha-cloud.fr/api/backlog/NOTE_ID
' '

Recuperer ce skill

' '
curl -s -H "Authorization: CLE" \\\n'
    '"https://api-trilium.bertha-cloud.fr/api/contexte/ContextContinuity/last"
' ) print('Skill API FastAPI cree:', nid) print('DONE')