[skip ci] chore(agents): centralisation via 4NK_template (hooks+doc)

This commit is contained in:
Debian 2025-08-28 12:05:27 +00:00
parent 81a6584010
commit b0670cbbc4
6 changed files with 102 additions and 0 deletions

View File

@ -0,0 +1,6 @@
# Intégration des agents 4NK_template
- Hooks centralisés: pre-commit / pre-push via ../4NK_template (Docker).
- Pré-requis: ~/.4nk_template/.env monté en RO dans le conteneur.
- Exécution: scripts/local/precommit.sh ou git push (déclenche pre-push).
- Rapports: tests/reports/agents/.

19
scripts/local/install_hooks.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"/..
HOOKS_DIR="$REPO_ROOT/.git/hooks"
mkdir -p "$HOOKS_DIR"
install_hook() {
local name="$1" src="$2"
cp -f "$src" "$HOOKS_DIR/$name"
chmod +x "$HOOKS_DIR/$name"
echo "Installed hook: $name"
}
# Hooks qui délèguent aux agents via l'image Docker du template sur le projet courant
install_hook pre-commit "$REPO_ROOT/scripts/local/precommit.sh"
install_hook pre-push "$REPO_ROOT/scripts/local/prepush.sh"
echo "Hooks installés (mode agents via 4NK_template)."

25
scripts/local/merge_branch.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -euo pipefail
TARGET_BRANCH="${1:-main}"
SOURCE_BRANCH="${2:-}"
if [[ -z "$SOURCE_BRANCH" ]]; then
SOURCE_BRANCH="$(git rev-parse --abbrev-ref HEAD)"
fi
if [[ "$SOURCE_BRANCH" == "$TARGET_BRANCH" ]]; then
echo "Déjà sur $TARGET_BRANCH"; exit 0
fi
# Valider localement avant merge
AUTO_FIX="${AUTO_FIX:-1}" SCOPE="${SCOPE:-all}" scripts/agents/run.sh || true
if [ -f scripts/security/audit.sh ]; then bash scripts/security/audit.sh || true; fi
git fetch origin --prune
git checkout "$TARGET_BRANCH"
git pull --ff-only origin "$TARGET_BRANCH" || true
git merge --no-ff "$SOURCE_BRANCH" -m "[skip ci] merge: $SOURCE_BRANCH -> $TARGET_BRANCH"
git push origin "$TARGET_BRANCH"
echo "Merge effectué: $SOURCE_BRANCH$TARGET_BRANCH"

11
scripts/local/precommit.sh Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -euo pipefail
# Exécuter les agents depuis l'image Docker de 4NK_template sur le projet courant
PROJECT_DIR="$(git rev-parse --show-toplevel)"
TEMPLATE_DIR="$(cd "${PROJECT_DIR}/../4NK_template" && pwd)"
mkdir -p "${PROJECT_DIR}/tests/reports/agents"
"${TEMPLATE_DIR}/scripts/local/run_agents_for_project.sh" "${PROJECT_DIR}" "tests/reports/agents"
echo "[pre-commit] OK (agents via 4NK_template)"

21
scripts/local/prepush.sh Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
# Exécuter les agents depuis l'image Docker de 4NK_template sur le projet courant
PROJECT_DIR="$(git rev-parse --show-toplevel)"
TEMPLATE_DIR="$(cd "${PROJECT_DIR}/../4NK_template" && pwd)"
mkdir -p "${PROJECT_DIR}/tests/reports/agents"
"${TEMPLATE_DIR}/scripts/local/run_agents_for_project.sh" "${PROJECT_DIR}" "tests/reports/agents"
# Audit sécurité (best effort) dans le contexte du projet
if [ -f "${PROJECT_DIR}/scripts/security/audit.sh" ]; then
(cd "${PROJECT_DIR}" && bash scripts/security/audit.sh) || true
fi
# Release guard (dry-run logique) dans le contexte du projet
if [ -f "${PROJECT_DIR}/scripts/release/guard.sh" ]; then
(cd "${PROJECT_DIR}" && bash scripts/release/guard.sh) || true
fi
echo "[pre-push] OK (agents via 4NK_template)"

20
scripts/local/release_local.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail
VERSION="${1:-}"
if [[ -z "$VERSION" ]]; then
echo "Usage: $0 vYYYY.MM.P" >&2
exit 2
fi
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR/.."
echo "$VERSION" > TEMPLATE_VERSION
git add TEMPLATE_VERSION CHANGELOG.md 2>/dev/null || true
git commit -m "[skip ci] chore(release): $VERSION" || true
git tag -a "$VERSION" -m "release: $VERSION (latest)"
git push || true
git push origin "$VERSION"
echo "Release locale préparée: $VERSION"