adfb45015e
Los dos estados activos que no tenian disparador ahora se asignan de forma determinista en el PostToolUse: - planificando: al usar TodoWrite / ExitPlanMode / EnterPlanMode. - puliendo: al editar (Edit/Write/MultiEdit/NotebookEdit) cuando la fase actual ya era testeando o puliendo, es decir retoques finales sobre algo ya probado. Una edicion normal (sin testeo previo) sigue siendo haciendo; volver a testear saca de puliendo. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
76 lines
2.7 KiB
Bash
Executable File
76 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# PostToolUse hook: marca el estado ACTIVO de la tarea segun la herramienta que
|
|
# el asistente acaba de usar. Determinista, sin LLM, en tiempo real. Solo actua
|
|
# si la terminal tiene un objetivo fijado.
|
|
#
|
|
# El estado de REPOSO (al parar: hecho/pendiente_revision/bloqueado/en_pausa) lo
|
|
# pone el Stop hook (goal_phase_eval.sh + goal_phase_worker.sh).
|
|
|
|
INPUT=$(cat)
|
|
SID=$(printf '%s' "$INPUT" | jq -r '.session_id // empty' 2>/dev/null)
|
|
[ -z "$SID" ] && exit 0
|
|
|
|
F="$HOME/.claude/goals/${SID}.json"
|
|
[ -f "$F" ] || exit 0
|
|
GOAL=$(jq -r '.goal // ""' "$F" 2>/dev/null)
|
|
[ -z "$GOAL" ] && exit 0
|
|
CUR=$(jq -r '.phase // ""' "$F" 2>/dev/null)
|
|
|
|
TOOL=$(printf '%s' "$INPUT" | jq -r '.tool_name // empty' 2>/dev/null)
|
|
[ -z "$TOOL" ] && exit 0
|
|
|
|
PHASE=""
|
|
case "$TOOL" in
|
|
Read|Grep|Glob|NotebookRead|WebFetch|WebSearch|ToolSearch)
|
|
PHASE=investigando ;;
|
|
Edit|Write|MultiEdit|NotebookEdit)
|
|
# Editar tras haber testeado = retoques finales -> puliendo. Si no, es
|
|
# implementacion normal -> haciendo.
|
|
case "$CUR" in
|
|
testeando|puliendo) PHASE=puliendo ;;
|
|
*) PHASE=haciendo ;;
|
|
esac
|
|
;;
|
|
Task|Agent|Workflow)
|
|
PHASE=haciendo ;;
|
|
Bash)
|
|
CMD=$(printf '%s' "$INPUT" | jq -r '.tool_input.command // ""' 2>/dev/null | tr '[:upper:]' '[:lower:]')
|
|
case "$CMD" in
|
|
*pytest*|*"go test"*|*ctest*|*jest*|*vitest*|*"npm test"*|*"npm run test"*|*"cargo test"*|*unittest*|*" test "*|*"./fn run"*test*)
|
|
PHASE=testeando ;;
|
|
ls|ls\ *|cat\ *|*grep*|find\ *|head\ *|tail\ *|stat\ *|tree*|rg\ *|fd\ *|*"git status"*|*"git log"*|*"git diff"*|*"git show"*|*"git branch"*)
|
|
PHASE=investigando ;;
|
|
*)
|
|
PHASE=haciendo ;;
|
|
esac
|
|
;;
|
|
mcp__registry__fn_search|mcp__registry__fn_show|mcp__registry__fn_code|mcp__registry__fn_uses|mcp__registry__fn_list_domains|mcp__registry__fn_doctor|mcp__registry__fn_proposal)
|
|
PHASE=investigando ;;
|
|
mcp__registry__fn_run)
|
|
PHASE=haciendo ;;
|
|
TodoWrite|ExitPlanMode|EnterPlanMode|Plan)
|
|
PHASE=planificando ;;
|
|
*)
|
|
# Herramientas que no representan un cambio de actividad (AskUserQuestion,
|
|
# etc.): no tocar la fase.
|
|
exit 0 ;;
|
|
esac
|
|
[ -z "$PHASE" ] && exit 0
|
|
|
|
# Escribir la fase + mantener historial (append solo si cambia respecto al
|
|
# ultimo; se conservan los ultimos 12 estados).
|
|
TMP="${F}.tmp.$$"
|
|
if jq --arg p "$PHASE" '
|
|
.phase = $p
|
|
| .history = (
|
|
( .history // [] ) as $h
|
|
| ( if ($h | length) > 0 and ($h[-1] == $p) then $h else ($h + [$p]) end )
|
|
| .[-12:]
|
|
)
|
|
' "$F" > "$TMP" 2>/dev/null; then
|
|
mv "$TMP" "$F"
|
|
else
|
|
rm -f "$TMP"
|
|
fi
|
|
exit 0
|