feat: brain-template v2.0 — BSI-v3 complet + tiers documentés
- README reécrit : tiers free/pro/full + modèle clé API + multi-instance - Sync agents/ (57 agents, kernel-isolation validated) - Sync scripts/ BSI-v3 (file-lock, preflight, human-gate, brain-status) - KERNEL.md v0.7.0 — zones + délégation + rendering + isolation - brain-compose.yml v0.7.0 — rendering mode + kerneluser - workflows/ — template + brain-engine exemple - locks/.gitkeep + claims/.gitkeep - helloWorld : RAG boot tier full only (bsi-rag retiré du template)
This commit is contained in:
78
scripts/install-brain-hooks.sh
Executable file
78
scripts/install-brain-hooks.sh
Executable file
@@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env bash
|
||||
# install-brain-hooks.sh — Installe les hooks git brain
|
||||
#
|
||||
# Usage :
|
||||
# scripts/install-brain-hooks.sh → installe dans .git/hooks/
|
||||
# scripts/install-brain-hooks.sh --check → vérifie si les hooks sont installés
|
||||
#
|
||||
# Hooks installés :
|
||||
# post-commit → déclenche brain-db-sync.sh si claims/ handoffs/ ou BRAIN-INDEX.md changent
|
||||
#
|
||||
# Idempotent — peut être relancé sans risque.
|
||||
# À relancer sur chaque clone frais (hooks non versionnés dans git).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
BRAIN_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
HOOKS_DIR="$BRAIN_ROOT/.git/hooks"
|
||||
CHECK_ONLY=false
|
||||
|
||||
[[ "${1:-}" == "--check" ]] && CHECK_ONLY=true
|
||||
|
||||
hook_installed() {
|
||||
[[ -f "$HOOKS_DIR/post-commit" ]] && grep -q "brain-db-sync" "$HOOKS_DIR/post-commit" 2>/dev/null
|
||||
}
|
||||
|
||||
if $CHECK_ONLY; then
|
||||
if hook_installed; then
|
||||
echo "✅ Hooks brain installés"
|
||||
exit 0
|
||||
else
|
||||
echo "⚠️ Hooks brain non installés — lancer: scripts/install-brain-hooks.sh"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$HOOKS_DIR"
|
||||
|
||||
# ── post-commit ────────────────────────────────────────────────────────────────
|
||||
|
||||
POST_COMMIT="$HOOKS_DIR/post-commit"
|
||||
|
||||
# Préserver un hook post-commit existant non-brain (append)
|
||||
if [[ -f "$POST_COMMIT" ]] && ! grep -q "brain-db-sync" "$POST_COMMIT"; then
|
||||
echo "" >> "$POST_COMMIT"
|
||||
echo "# ── brain-db-sync (ajouté par install-brain-hooks.sh) ──" >> "$POST_COMMIT"
|
||||
cat >> "$POST_COMMIT" <<'HOOK'
|
||||
# Déclenche brain-db-sync.sh si claims, handoffs ou BRAIN-INDEX ont changé
|
||||
_brain_changed=$(git diff HEAD~1 --name-only 2>/dev/null \
|
||||
| grep -qE '^(claims/|handoffs/|BRAIN-INDEX\.md)' && echo yes || echo no)
|
||||
if [[ "$_brain_changed" == "yes" ]]; then
|
||||
BRAIN_ROOT="$(git rev-parse --show-toplevel)"
|
||||
bash "$BRAIN_ROOT/scripts/brain-db-sync.sh" --quiet || true
|
||||
fi
|
||||
HOOK
|
||||
echo "✅ Hook post-commit existant complété"
|
||||
else
|
||||
# Créer from scratch
|
||||
cat > "$POST_COMMIT" <<'HOOK'
|
||||
#!/usr/bin/env bash
|
||||
# brain post-commit hook — installé par scripts/install-brain-hooks.sh
|
||||
|
||||
# Sync brain.db si claims, handoffs ou BRAIN-INDEX ont changé
|
||||
_brain_changed=$(git diff HEAD~1 --name-only 2>/dev/null \
|
||||
| grep -qE '^(claims/|handoffs/|BRAIN-INDEX\.md)' && echo yes || echo no)
|
||||
if [[ "$_brain_changed" == "yes" ]]; then
|
||||
BRAIN_ROOT="$(git rev-parse --show-toplevel)"
|
||||
bash "$BRAIN_ROOT/scripts/brain-db-sync.sh" --quiet || true
|
||||
fi
|
||||
HOOK
|
||||
chmod +x "$POST_COMMIT"
|
||||
echo "✅ Hook post-commit installé"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Hooks brain actifs :"
|
||||
echo " post-commit → brain-db-sync.sh (déclenché sur claims/ handoffs/ BRAIN-INDEX.md)"
|
||||
echo ""
|
||||
echo "Pour vérifier : scripts/install-brain-hooks.sh --check"
|
||||
Reference in New Issue
Block a user