diff --git a/docs/AGENTS_INTEGRATION.md b/docs/AGENTS_INTEGRATION.md new file mode 100644 index 0000000..ac4b41d --- /dev/null +++ b/docs/AGENTS_INTEGRATION.md @@ -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/. diff --git a/scripts/local/install_hooks.sh b/scripts/local/install_hooks.sh new file mode 100755 index 0000000..bd0f600 --- /dev/null +++ b/scripts/local/install_hooks.sh @@ -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)." diff --git a/scripts/local/precommit.sh b/scripts/local/precommit.sh index e9a1387..b2b502c 100755 --- a/scripts/local/precommit.sh +++ b/scripts/local/precommit.sh @@ -1,18 +1,11 @@ #!/usr/bin/env bash set -euo pipefail -# Script de pré-commit pour 4NK_wallet -# Lance les agents de 4NK_template sur ce projet +# 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)" -PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" -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 "=== Pré-commit 4NK_wallet via 4NK_template ===" - -# Créer le dossier de sortie -mkdir -p "$PROJECT_DIR/tests/reports/agents" - -# Lancer les agents de 4NK_template sur ce projet -"$TEMPLATE_DIR/scripts/local/run_agents_for_project.sh" "$PROJECT_DIR" "tests/reports/agents" - -echo "=== Pré-commit terminé ===" +echo "[pre-commit] OK (agents via 4NK_template)" diff --git a/scripts/local/prepush.sh b/scripts/local/prepush.sh index 2d3d93a..7cb8c7d 100755 --- a/scripts/local/prepush.sh +++ b/scripts/local/prepush.sh @@ -1,20 +1,21 @@ #!/usr/bin/env bash set -euo pipefail -ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" -cd "$ROOT_DIR/.." +# 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)" -# Agents complets -AUTO_FIX="${AUTO_FIX:-1}" SCOPE="${SCOPE:-all}" scripts/agents/run.sh +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) -if [ -f scripts/security/audit.sh ]; then - bash scripts/security/audit.sh || true +# 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) -if [ -f scripts/release/guard.sh ]; then - bash scripts/release/guard.sh || true +# 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" +echo "[pre-push] OK (agents via 4NK_template)" diff --git a/scripts/local/release_local.sh b/scripts/local/release_local.sh new file mode 100755 index 0000000..e3f48ed --- /dev/null +++ b/scripts/local/release_local.sh @@ -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"