mirror of
https://github.com/MaksTinyWorkshop/_Assistant_Lead_Tech
synced 2026-04-06 21:41:42 +02:00
feat: ajout script post-bmad-install pour automatiser la capitalisation Lead_tech
- post-bmad-install.sh : patch les customize.yaml des agents producteurs BMAD (dev, architect, sm, qa, quick-flow-solo-dev, tea) avec la memory de capitalisation - Idempotent : skip si déjà présent, compatible Mac (sed -i '') et Linux - Patch aussi CLAUDE.md projet si la section capitalisation est absente - Alias post-bmad-install ajouté dans aliases.sh Workflow : npx bmad-method install → post-bmad-install
This commit is contained in:
@@ -22,5 +22,8 @@ alias mkproj='~/AI_RULES/_Assistant_Lead_Tech/scripts/mkproj.sh 2>/dev/null || /
|
||||
# Sync mémoire agents
|
||||
alias sync-ai='~/AI_RULES/_Assistant_Lead_Tech/scripts/sync-ai-instructions.sh 2>/dev/null || /srv/projects/_Assistant_Lead_Tech/scripts/sync-ai-instructions.sh'
|
||||
|
||||
# Post-install BMAD : injecte la capitalisation Lead_tech dans les agents du projet courant
|
||||
alias post-bmad-install='"$LEADTECH/scripts/post-bmad-install.sh"'
|
||||
|
||||
# Aller dans projets
|
||||
alias projects='cd ~/Volumes/TeraSSD/Projets_Dev 2>/dev/null || cd /srv/projects'
|
||||
163
scripts/post-bmad-install.sh
Executable file
163
scripts/post-bmad-install.sh
Executable file
@@ -0,0 +1,163 @@
|
||||
#!/usr/bin/env bash
|
||||
# post-bmad-install.sh
|
||||
# À lancer après `npx bmad-method install` dans un projet BMAD.
|
||||
# Injecte la memory de capitalisation Lead_tech dans les agents producteurs.
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Résolution du chemin Lead_tech (même logique que aliases.sh)
|
||||
if [ -d "$HOME/AI_RULES/_Assistant_Lead_Tech" ]; then
|
||||
LEADTECH_PATH="$HOME/AI_RULES/_Assistant_Lead_Tech"
|
||||
elif [ -d "/srv/projects/_Assistant_Lead_Tech" ]; then
|
||||
LEADTECH_PATH="/srv/projects/_Assistant_Lead_Tech"
|
||||
else
|
||||
echo "Erreur : impossible de localiser le repo Lead_tech." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Projet courant
|
||||
PROJECT_ROOT="$(pwd)"
|
||||
PROJECT_NAME="$(basename "$PROJECT_ROOT")"
|
||||
AGENTS_DIR="$PROJECT_ROOT/_bmad/_config/agents"
|
||||
CLAUDE_MD="$PROJECT_ROOT/CLAUDE.md"
|
||||
|
||||
if [ ! -d "$AGENTS_DIR" ]; then
|
||||
echo "Erreur : dossier _bmad/_config/agents/ introuvable dans $PROJECT_ROOT"
|
||||
echo "Lance ce script depuis la racine d'un projet BMAD installé."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Agents producteurs à patcher
|
||||
# (ceux qui génèrent du code, des décisions ou de l'architecture)
|
||||
PRODUCER_AGENTS=(
|
||||
"bmm-dev"
|
||||
"bmm-architect"
|
||||
"bmm-sm"
|
||||
"bmm-qa"
|
||||
"bmm-quick-flow-solo-dev"
|
||||
"tea-tea"
|
||||
)
|
||||
|
||||
CAPITALIZE_MARKER="95_a_capitaliser.md"
|
||||
|
||||
patch_agent() {
|
||||
local agent="$1"
|
||||
local file="$AGENTS_DIR/${agent}.customize.yaml"
|
||||
|
||||
if [ ! -f "$file" ]; then
|
||||
return 0 # agent non installé dans ce projet, on skip
|
||||
fi
|
||||
|
||||
# Idempotent : ne pas injecter si déjà présent
|
||||
if grep -q "$CAPITALIZE_MARKER" "$file"; then
|
||||
echo " [skip] $agent — memory déjà présente"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Injection après la ligne "memories: []"
|
||||
# Si memories: [] → remplacer par le bloc memories avec la memory
|
||||
if grep -q "^memories: \[\]" "$file"; then
|
||||
# Construire la memory adaptée au rôle de l'agent
|
||||
local memory
|
||||
memory="$(build_memory "$agent")"
|
||||
|
||||
# Remplacer memories: [] par le bloc injecté
|
||||
# Compatible macOS (sed -i '') et Linux (sed -i)
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
sed -i '' "s|^memories: \[\]|memories:\n - \"${memory}\"|" "$file"
|
||||
else
|
||||
sed -i "s|^memories: \[\]|memories:\n - \"${memory}\"|" "$file"
|
||||
fi
|
||||
|
||||
echo " [ok] $agent — memory injectée"
|
||||
else
|
||||
echo " [warn] $agent — format memories: inattendu, patch manuel requis"
|
||||
fi
|
||||
}
|
||||
|
||||
build_memory() {
|
||||
local agent="$1"
|
||||
local base="When a reusable pattern, difficult bug fix, anti-pattern, or architecture decision emerges"
|
||||
|
||||
case "$agent" in
|
||||
bmm-dev|bmm-quick-flow-solo-dev)
|
||||
echo "${base} during implementation, write a proposal to ~/AI_RULES/_Assistant_Lead_Tech/95_a_capitaliser.md (NUC: /srv/projects/_Assistant_Lead_Tech/95_a_capitaliser.md). Format: DATE — ${PROJECT_NAME} / FILE_UPDATE_PROPOSAL / Fichier cible: <target file> / Pourquoi: <reason> / Proposition: <content>. Never write directly to Lead_tech validated files."
|
||||
;;
|
||||
bmm-architect)
|
||||
echo "${base}, write a proposal to ~/AI_RULES/_Assistant_Lead_Tech/95_a_capitaliser.md (NUC: /srv/projects/_Assistant_Lead_Tech/95_a_capitaliser.md). Format: DATE — ${PROJECT_NAME} / FILE_UPDATE_PROPOSAL / Fichier cible: <target file> / Pourquoi: <reason> / Proposition: <content>. Never write directly to Lead_tech validated files."
|
||||
;;
|
||||
bmm-sm)
|
||||
echo "When a process improvement, recurring friction, or architecture decision emerges during sprint work, write a proposal to ~/AI_RULES/_Assistant_Lead_Tech/95_a_capitaliser.md (NUC: /srv/projects/_Assistant_Lead_Tech/95_a_capitaliser.md). Format: DATE — ${PROJECT_NAME} / FILE_UPDATE_PROPOSAL / Fichier cible: <target file> / Pourquoi: <reason> / Proposition: <content>. Never write directly to Lead_tech validated files."
|
||||
;;
|
||||
bmm-qa|tea-tea)
|
||||
echo "When a reusable test pattern, tricky bug, or quality anti-pattern is identified, write a proposal to ~/AI_RULES/_Assistant_Lead_Tech/95_a_capitaliser.md (NUC: /srv/projects/_Assistant_Lead_Tech/95_a_capitaliser.md). Format: DATE — ${PROJECT_NAME} / FILE_UPDATE_PROPOSAL / Fichier cible: <target file> / Pourquoi: <reason> / Proposition: <content>. Never write directly to Lead_tech validated files."
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
patch_claude_md() {
|
||||
if [ ! -f "$CLAUDE_MD" ]; then
|
||||
echo " [skip] CLAUDE.md — fichier absent"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if grep -q "$CAPITALIZE_MARKER" "$CLAUDE_MD"; then
|
||||
echo " [skip] CLAUDE.md — section capitalisation déjà présente"
|
||||
return 0
|
||||
fi
|
||||
|
||||
cat >> "$CLAUDE_MD" <<EOF
|
||||
|
||||
---
|
||||
|
||||
# Capitalisation vers Lead_tech
|
||||
|
||||
Quand un apprentissage émerge (bug difficile, pattern réutilisable, anti-pattern, décision d'archi),
|
||||
l'écrire dans la zone tampon Lead_tech :
|
||||
|
||||
\`\`\`
|
||||
~/AI_RULES/_Assistant_Lead_Tech/95_a_capitaliser.md
|
||||
\`\`\`
|
||||
|
||||
Sur le NUC : \`/srv/projects/_Assistant_Lead_Tech/95_a_capitaliser.md\`
|
||||
|
||||
Format :
|
||||
|
||||
\`\`\`
|
||||
DATE — ${PROJECT_NAME}
|
||||
|
||||
FILE_UPDATE_PROPOSAL
|
||||
Fichier cible : <10_backend_patterns_valides.md | 10_frontend_patterns_valides.md | 10_backend_risques_et_vigilance.md | 10_frontend_risques_et_vigilance.md | 40_decisions_et_archi.md | 90_debug_et_postmortem.md>
|
||||
|
||||
Pourquoi :
|
||||
<raison en 1-2 phrases>
|
||||
|
||||
Proposition :
|
||||
<contenu suggéré>
|
||||
\`\`\`
|
||||
|
||||
Règle : écrire dans \`95_a_capitaliser.md\` uniquement. Jamais directement dans les fichiers Lead_tech validés.
|
||||
EOF
|
||||
|
||||
echo " [ok] CLAUDE.md — section capitalisation ajoutée"
|
||||
}
|
||||
|
||||
# --- Main ---
|
||||
echo ""
|
||||
echo "post-bmad-install — injection Lead_tech capitalisation"
|
||||
echo "Projet : $PROJECT_NAME ($PROJECT_ROOT)"
|
||||
echo "Agents : $AGENTS_DIR"
|
||||
echo ""
|
||||
|
||||
echo "Patch agents :"
|
||||
for agent in "${PRODUCER_AGENTS[@]}"; do
|
||||
patch_agent "$agent"
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "Patch CLAUDE.md :"
|
||||
patch_claude_md
|
||||
|
||||
echo ""
|
||||
echo "Terminé. Lance 'git diff' pour vérifier les changements."
|
||||
Reference in New Issue
Block a user