fix: start.sh auto-build brain-ui + /health tolerant sans Ollama + docs source unique brain-engine

- start.sh: detecte brain-ui/dist absent → build auto si Node dispo, warning sinon
- start.sh: lien docs pointe vers /ui/docs (page rendue) au lieu de /docs (JSON)
- server.py /health: tolere absence table embeddings (pas d'Ollama = indexed:0, pas crash)
- server.py /docs/view: redirect 302 → /ui/docs pour navigateurs
- public/docs/ supprime: source unique = docs/ servi par brain-engine API
This commit is contained in:
Tetardtek-Cortex
2026-03-21 17:16:19 +01:00
parent 02e19fcd7c
commit 5c060dcc1c
18 changed files with 34 additions and 21 deletions

View File

@@ -67,7 +67,7 @@ from pathlib import Path
import subprocess
import asyncio
from fastapi import FastAPI, Header, HTTPException, Query, Body, WebSocket, Request
from fastapi.responses import JSONResponse
from fastapi.responses import JSONResponse, RedirectResponse
from fastapi.websockets import WebSocketDisconnect
try:
@@ -268,7 +268,13 @@ def health():
import sqlite3
from search import DB_PATH
conn = sqlite3.connect(DB_PATH)
count = conn.execute("SELECT COUNT(*) FROM embeddings WHERE indexed=1").fetchone()[0]
# embeddings table is created by embed.py (requires Ollama) — optional
has_embeddings = conn.execute(
"SELECT name FROM sqlite_master WHERE type='table' AND name='embeddings'"
).fetchone()
count = 0
if has_embeddings:
count = conn.execute("SELECT COUNT(*) FROM embeddings WHERE indexed=1").fetchone()[0]
conn.close()
return {'status': 'ok', 'indexed': count, 'uptime': uptime}
except Exception as e:
@@ -360,6 +366,12 @@ def brain_compose_tiers():
# ── Docs live — sert docs/*.md depuis le filesystem ────────────────────────────
@app.get('/docs/view')
def docs_redirect():
"""Redirige /docs/view vers le dashboard docs (pour les navigateurs)."""
return RedirectResponse(url='/ui/docs', status_code=302)
@app.get('/docs')
def docs_list():
"""Liste les fichiers docs/*.md avec métadonnées (frontmatter group/label)."""

View File

@@ -61,7 +61,21 @@ else
echo " Le serveur démarre quand même (BSI, docs, endpoints basiques)."
fi
# 5. Vérifier si déjà en cours
# 5. Vérifier brain-ui (dashboard + docs)
UI_DIST="$BRAIN_ROOT/brain-ui/dist"
if [ ! -d "$UI_DIST" ]; then
echo ""
echo "⚠️ brain-ui pas buildé — le dashboard ne sera pas disponible."
if command -v node &>/dev/null && command -v npm &>/dev/null; then
echo "→ Build automatique de brain-ui..."
bash "$BRAIN_ROOT/brain-ui/build.sh"
else
echo " Node.js/npm requis pour le dashboard."
echo " Installe Node.js 18+ puis lance : bash brain-ui/build.sh"
fi
fi
# 6. Vérifier si déjà en cours (re-check après build éventuel)
PIDFILE="$BRAIN_ROOT/.brain-engine.pid"
if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
echo ""
@@ -71,13 +85,16 @@ if [ -f "$PIDFILE" ] && kill -0 "$(cat "$PIDFILE")" 2>/dev/null; then
exit 0
fi
# 6. Lancer le serveur
# 7. Lancer le serveur
PORT="${BRAIN_PORT:-7700}"
LOGFILE="$BRAIN_ROOT/brain-engine/brain-engine.log"
echo ""
echo "=== Lancement brain-engine sur port $PORT ==="
echo " Health : http://localhost:$PORT/health"
echo " Dashboard : http://localhost:$PORT/ui/"
if [ -d "$UI_DIST" ]; then
echo " Dashboard : http://localhost:$PORT/ui/"
fi
echo " Docs : http://localhost:$PORT/ui/docs"
echo " Agents : http://localhost:$PORT/agents"
echo ""

View File

@@ -1 +0,0 @@
../../../docs/README.md

View File

@@ -1 +0,0 @@
../../../docs/agents-brain.md

View File

@@ -1 +0,0 @@
../../../docs/agents-code.md

View File

@@ -1 +0,0 @@
../../../docs/agents-infra.md

View File

@@ -1 +0,0 @@
../../../docs/agents.md

View File

@@ -1 +0,0 @@
../../../docs/architecture.md

View File

@@ -1 +0,0 @@
../../../docs/brain-engine-guide.md

View File

@@ -1 +0,0 @@
../../../docs/getting-started.md

View File

@@ -1 +0,0 @@
../../../docs/satellites.md

View File

@@ -1 +0,0 @@
../../../docs/sessions.md

View File

@@ -1 +0,0 @@
../../../docs/vue-featured.md

View File

@@ -1 +0,0 @@
../../../docs/vue-free.md

View File

@@ -1 +0,0 @@
../../../docs/vue-full.md

View File

@@ -1 +0,0 @@
../../../docs/vue-pro.md

View File

@@ -1 +0,0 @@
../../../docs/vue-tiers.md

View File

@@ -1 +0,0 @@
../../../docs/workflows.md