#!/bin/bash # subagentStop: log completion, add followup for fix-lint when completed HOOKS_DIR="$(cd "$(dirname "$0")" && pwd)" # shellcheck source=lib.sh . "${HOOKS_DIR}/lib.sh" input=$(cat) subagent_type=$(echo "$input" | jq -r '.subagent_type // "?"') status=$(echo "$input" | jq -r '.status // "?"') duration=$(echo "$input" | jq -r '.duration // 0') result_preview=$(echo "$input" | jq -r '.result // ""' | head -c 200) log_event "subagentStop" "type=$subagent_type status=$status duration=${duration}ms" log_json_truncated "subagentStop_result" "$result_preview" 300 result_lower=$(echo "$input" | jq -r '.result // ""' | tr '[:upper:]' '[:lower:]') # For fix-lint or lint-related subagents: suggest next step when completed if [ "$status" = "completed" ]; then if echo "$result_lower" | grep -qE "lint|fix-lint|corriger.*erreur"; then echo '{"followup_message":"Lint fix terminé. Vérifier : npm run lint dans lecoffre-back-main, lecoffre-front-main, lecoffre-ressources-dev."}' exit 0 fi fi # For deploy subagent: on error, request bug correction if [ "$status" = "error" ]; then if echo "$result_lower" | grep -qE "deploy|déploiement|build-and-deploy|deploy-app"; then echo '{"followup_message":"Le déploiement a échoué. Analyser l'\''erreur, identifier la root cause, corriger le bug puis retenter le déploiement."}' exit 0 fi fi echo '{}' exit 0