deploy: fix TemplateResponse signature
This commit is contained in:
@@ -0,0 +1,217 @@
|
||||
# prompt.md — Brief projet context-hub
|
||||
# Ce fichier est le PRD complet. Antigravity le lit et construit l application.
|
||||
# Derniere mise a jour : 2026-06-24
|
||||
|
||||
---
|
||||
|
||||
## CONTEXTE
|
||||
|
||||
context-hub est la source de verite unique pour tous les agents AI du NAS Synology DS920+.
|
||||
Au lieu de dupliquer les regles dans chaque system prompt / AGENTS.md / CLAUDE.md,
|
||||
un seul service REST + MCP centralise tout. Chaque agent interroge ce service
|
||||
selon ses droits et obtient uniquement ce qu il est autorise a voir.
|
||||
|
||||
**Consumers :**
|
||||
- Nabil (interface web admin)
|
||||
- Claude (MCP via claude.ai)
|
||||
- hermes-tt / hermes-nyora / hermes-perso (MCP via agents Hermes)
|
||||
- Gemini / Antigravity (REST API + MCP)
|
||||
|
||||
---
|
||||
|
||||
## STACK TECHNIQUE
|
||||
|
||||
- Python 3.11+
|
||||
- FastAPI (API REST + MCP SSE)
|
||||
- SQLite (via aiosqlite)
|
||||
- Jinja2 (templates admin UI)
|
||||
- PyJWT (auth web Nabil)
|
||||
- uvicorn
|
||||
|
||||
Un seul container Docker. Pas de base externe. Pas de Redis.
|
||||
Toutes les variables depuis .env (deja present dans /mnt/docker/context-hub/).
|
||||
|
||||
---
|
||||
|
||||
## STRUCTURE FICHIERS
|
||||
|
||||
context-hub/
|
||||
├── app/
|
||||
│ ├── main.py FastAPI app + montage routes
|
||||
│ ├── auth.py JWT web (Nabil) + API key (agents)
|
||||
│ ├── models.py SQLite schema + CRUD (aiosqlite)
|
||||
│ ├── scopes.py Matrice acces par cle API
|
||||
│ ├── routes/
|
||||
│ │ ├── api.py GET /api/rules/{scope}, /api/ports, /api/search
|
||||
│ │ ├── admin.py POST admin (CRUD regles, cles, audit)
|
||||
│ │ └── mcp.py Endpoint MCP SSE /mcp
|
||||
│ └── seed.py Population initiale SQLite depuis les donnees ci-dessous
|
||||
├── templates/
|
||||
│ ├── base.html
|
||||
│ ├── login.html
|
||||
│ ├── dashboard.html Vue Nabil : tous les scopes, audit log, cles
|
||||
│ └── editor.html Editeur de regles par scope
|
||||
├── static/
|
||||
│ └── style.css
|
||||
├── docker-compose.yml
|
||||
├── Dockerfile
|
||||
├── requirements.txt
|
||||
├── .env (deja cree — NE PAS recreer)
|
||||
├── AGENTS.md (deja cree — NE PAS recreer)
|
||||
└── prompt.md (ce fichier)
|
||||
|
||||
|
||||
---
|
||||
|
||||
## MATRICE D ACCES
|
||||
|
||||
| Scope | CLAUDE | HERMES_TT | HERMES_NYORA | HERMES_PERSO | GEMINI | NABIL |
|
||||
|-------|--------|-----------|--------------|--------------|--------|-------|
|
||||
| infra | oui | oui | oui | oui | oui | oui |
|
||||
| llm | oui | oui | oui | oui | oui | oui |
|
||||
| nyora | oui | NON | oui | oui | oui | oui |
|
||||
| perso | oui | NON | NON | oui | NON | oui |
|
||||
| tt | oui | oui | NON | NON | NON | oui |
|
||||
|
||||
HTTP 403 sur toute tentative non autorisee. La cle determine le consumer.
|
||||
|
||||
|
||||
---
|
||||
|
||||
## ENDPOINTS API
|
||||
|
||||
GET /api/rules/{scope} Regles du scope (JSON). Auth: X-API-Key
|
||||
GET /api/ports Registre ports complet (JSON)
|
||||
GET /api/search?q=terme Recherche plein-texte (scopes autorises)
|
||||
POST /api/admin/rules/{scope} CRUD regle (NABIL uniquement, JWT)
|
||||
GET /api/audit?limit=50 Log acces agents (NABIL uniquement)
|
||||
GET /api/keys Gestion cles API (NABIL uniquement)
|
||||
POST /api/keys/rotate/{agent} Rotation cle (NABIL uniquement)
|
||||
GET /health Health check public
|
||||
POST /mcp MCP SSE endpoint
|
||||
|
||||
Auth web Nabil : POST /auth/login -> JWT cookie httponly (12h)
|
||||
Auth agents : Header X-API-Key
|
||||
|
||||
---
|
||||
|
||||
## OUTILS MCP
|
||||
|
||||
get_rules(scope) -> dict Regles scope si autorise
|
||||
get_ports() -> list Registre ports complet
|
||||
search_rules(query) -> list Recherche scopes autorises
|
||||
get_agent_config(name) -> dict Config compilee agent (infra+llm+scopes)
|
||||
check_port(port) -> dict Port libre ou occupe
|
||||
|
||||
---
|
||||
|
||||
## CONTENU SEED — scope infra
|
||||
|
||||
Initialiser SQLite avec :
|
||||
ssh: host=192.168.100.33, port=22222, user=Best0f
|
||||
docker: uid=1026, gid=100
|
||||
network: from_container=172.17.0.1, from_lan=192.168.100.33
|
||||
identities: bolbol=Gitea, Best0f=SSH, bestof=Portainer
|
||||
git_push_pattern: http://bolbol:PWD@172.17.0.1:3232/bolbol/REPO.git
|
||||
mcp_nas: heredoc->timeout, heredoc->printf/python, limit=350chars, session-poison-apres-3-erreurs
|
||||
|
||||
---
|
||||
|
||||
## CONTENU SEED — scope llm
|
||||
|
||||
bifrost_internal: http://bifrost:8080/v1
|
||||
bifrost_lan: http://192.168.100.33:3085/v1
|
||||
bifrost_auth: header x-bf-vk (JAMAIS Authorization Bearer)
|
||||
bifrost_proxy_max_tokens: 16384
|
||||
default_model: deepseek/deepseek-chat-v3-0324
|
||||
provider: opencode-go
|
||||
budget_usd_month: 10
|
||||
vision_model: openrouter/google/gemini-2.5-flash
|
||||
deepseek_limitation: text-only, 404 sur images
|
||||
openrouter: urgence uniquement
|
||||
|
||||
---
|
||||
|
||||
## CONTENU SEED — scope nyora
|
||||
|
||||
apps: family-help:3041, nyora-veille:3055, redaction-pro:3092
|
||||
dr_nexum: deadline=2026-11-15, target_subs=1000, target_revenue_eur=300
|
||||
footer: color=#d4a01a, line1=gradient-or, line2=NYORA, line3=Crafted with precision, line4=2026
|
||||
rules:
|
||||
- Ne jamais ecrire Tunisie Telecom ou Zone Sud dans apps Nyora
|
||||
- Login forms : placeholder=Identifiant uniquement
|
||||
- Footer Nyora obligatoire sur toutes les apps personnelles
|
||||
|
||||
---
|
||||
|
||||
## CONTENU SEED — scope perso
|
||||
|
||||
family:
|
||||
nedya: nee 1983, coeliaque
|
||||
yesmine: nee 2008, fibromyalgie et nevralgie, priorite accompagnement
|
||||
ahmed: ne 2010
|
||||
mondher: pharmacien, reponses niveau clinique
|
||||
yasmi: marque artisanale mode, jasmine, Sfax
|
||||
|
||||
---
|
||||
|
||||
## CONTENU SEED — scope tt (acces restreint)
|
||||
|
||||
baserow_token: deT2PW3ZFZ0h3euxhKDFnlZhKNrcckYV
|
||||
zone: Gabes, Gafsa, Kebili, Medenine, Sfax, Tataouine, Tozeur
|
||||
ci_cpt_zone_sud: 998, fb_zone_sud: 1006
|
||||
rla_contracts: table=856, count=55
|
||||
rules:
|
||||
- Ne jamais mentionner Baserow/Python/IA dans documents officiels
|
||||
- Documents = travail Direction Zone Sud Tunisie Telecom
|
||||
|
||||
---
|
||||
|
||||
## ADMIN UI — NABIL
|
||||
|
||||
Page dashboard : vue tous scopes, audit log dernieres 24h, statut cles
|
||||
Page editor : editer une regle par scope (formulaire JSON inline)
|
||||
Page audit : log complet avec filtre par agent et par scope
|
||||
Page keys : liste cles + date derniere utilisation + bouton rotation
|
||||
|
||||
Design : sobre, dark theme, same feel que redaction-pro.
|
||||
Pas de framework CSS externe. Tailwind CDN accepte.
|
||||
Titre page : context-hub | Nyora Infrastructure
|
||||
|
||||
---
|
||||
|
||||
## DOCKER-COMPOSE
|
||||
|
||||
Service unique context-hub.
|
||||
Reseau : n8n (pour acces interne bifrost, nyora-notes, baserow).
|
||||
Volume : ./data:/app/data (SQLite persiste).
|
||||
Port : 3093:8000.
|
||||
Env : env_file: .env
|
||||
Restart : unless-stopped.
|
||||
Healthcheck : GET /health.
|
||||
|
||||
---
|
||||
|
||||
## SECURITE
|
||||
|
||||
- .env dans .gitignore (deja configure)
|
||||
- JWT httponly, SameSite=strict
|
||||
- Rate limit sur /auth/login (5 tentatives/minute)
|
||||
- Logs audit : chaque requete API loguee (agent, scope, timestamp, ip)
|
||||
- Rotation cles : possible depuis UI sans redemarrage (cles en DB)
|
||||
- Scope tt : double verification (cle + scope explicite dans requete)
|
||||
|
||||
---
|
||||
|
||||
## ORDRE DE CONSTRUCTION RECOMMANDE
|
||||
|
||||
1. models.py + seed.py (schema SQLite + donnees initiales)
|
||||
2. auth.py (JWT + API key middleware)
|
||||
3. scopes.py (matrice + validation)
|
||||
4. routes/api.py (endpoints REST publics agents)
|
||||
5. routes/admin.py (CRUD + audit)
|
||||
6. routes/mcp.py (MCP SSE)
|
||||
7. templates/ (UI Nabil)
|
||||
8. Dockerfile + docker-compose.yml
|
||||
9. Test complet toutes les cles + scopes
|
||||
10. git commit + push bolbol/context-hub.git
|
||||
Reference in New Issue
Block a user