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, '
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>
| Ressource | Endpoints | Note Trilium |
|---|---|---|
| Projets | GET /api/projets, GET /api/projets/{nom}, POST, PATCH | Documentation > Projets |
| Backlog | GET /api/backlog/{projet}, POST /api/backlog, PATCH | Documentation > Backlog |
| Decisions | GET /api/decisions/{projet}, POST, PATCH | Documentation > Decisions |
| Historique | GET /api/historique/{projet}, POST, PATCH | Documentation > Historique |
| Conversations | GET /api/conversations/{projet}, POST, PATCH | Documentation > Conversations |
| Glossaire | GET /api/glossaire/{projet}, POST, PATCH | Documentation > Glossaire |
| Contexte Reprise | GET /api/contexte/{projet}, GET /api/contexte/{projet}/last | Documentation > Contexte Reprise |
| Code | Signification |
|---|---|
| 200 | OK |
| 201 | Cree avec succes |
| 401 | Cle API invalide |
| 404 | Ressource introuvable |
| 422 | Validation Pydantic echouee (parametre invalide) |
Liste tous les projets.
' 'curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/projets' '
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' '
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'
'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',
'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' '
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'
'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',
'Liste les decisions actives (statut=active).
' 'curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/decisions/SlidingAutomation' '
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'
'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',
'Liste les entrees encore valides (encoreValide=true).
' 'curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/historique/SlidingAutomation' '
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'
'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',
'Liste toutes les conversations du projet.
' 'curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/conversations/SlidingAutomation' '
Detail avec contenu HTML d une conversation specifique.
' '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'
'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',
'Liste les termes avec contenu (definition).
' 'curl -s -H "Authorization: CLE" https://api-trilium.bertha-cloud.fr/api/glossaire/SlidingAutomation' '
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'
'Modifie definition et/ou synonymes_eviter.
' ), ( 'API - Contexte Reprise', '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..."}
' '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,
'Ce skill permet a un LLM d appeler directement l API pour lire et ecrire dans Trilium.
' '| Parametre | Valeur |
|---|---|
| Base URL | https://api-trilium.bertha-cloud.fr |
| Auth header | Authorization: <API_KEY> |
| Cle Claude | Demander a Bastien ou lire dans .env |
| Cle Le Chat | Demander a Bastien ou lire dans .env |
| Doc Swagger | https://api-trilium.bertha-cloud.fr/api/docs |
| Action | Appel |
|---|---|
| Lire le contexte projet | GET /api/contexte/{projet}?llm_cible=NomLLM |
| Voir le backlog | GET /api/backlog/{projet} |
| Enregistrer une decision | POST /api/decisions |
| Enregistrer un historique | POST /api/historique |
| Creer une conversation | POST /api/conversations |
| Cloturer une session | PATCH /api/conversations/{id} |
| Marquer backlog item fait | PATCH /api/backlog/{id} |
| Champ | Valeurs acceptees |
|---|---|
| priorite | haute | moyenne | basse |
| statut backlog | a faire | en cours | bloque | fait | abandonne |
| statut decision | active | revisee | annulee |
| type historique | Fait etabli | Test effectue | Hypothese invalidee | Contrainte decouverte |
| llm conversation | Claude Sonnet | Claude Opus | Le Chat Large | Le Chat Medium |
| statut projet | actif | en-pause | archive |
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\'])"'
'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'
'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'
'curl -s -H "Authorization: CLE" \\\n'
'"https://api-trilium.bertha-cloud.fr/api/contexte/ContextContinuity/last"'
)
print('Skill API FastAPI cree:', nid)
print('DONE')