feat(statusline): estados activo (deterministas) + reposo (haiku)
Separa el ciclo de trabajo en dos grupos con la fuente adecuada para cada uno: - ACTIVO (mientras se trabaja): lo marca el hook PostToolUse de forma determinista, sin LLM, segun la herramienta usada — Read/Grep/Glob -> investigando; Edit/Write -> haciendo; Bash con tests -> testeando; Bash de lectura (ls/cat/git status...) -> investigando; mcp fn_search/show/... -> investigando. Refleja en tiempo real lo que hace el asistente. - REPOSO (al parar y ceder el control): lo resuelve el Stop hook con ask_llm (haiku) -> hecho / pendiente_revision / bloqueado / en_pausa. Al parar nunca queda en un estado activo. Cambios: - goal_phase_active.sh: nuevo hook PostToolUse (mapa herramienta -> fase activa). - goal_phase_worker.sh: ahora solo produce estados de reposo; se elimina el modo prompt. Mantiene el gate (resuelve reposo solo si hubo trabajo o se venia de activo) y el historial. - goal_tracker.sh: deja de lanzar clasificacion LLM en el prompt (redundante); vuelve a fijar objetivo desde el prompt + informar estado. - statusline.sh: nuevo estado en_pausa (en pausa); set de fases reordenado. - settings.json: registra el hook PostToolUse. Resultado: 1 sola llamada haiku por turno (Stop); el estado activo es gratis y refleja las acciones reales en vez de la intencion del prompt. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/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
|
||||
|
||||
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)
|
||||
PHASE=haciendo ;;
|
||||
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 ;;
|
||||
*)
|
||||
# Herramientas que no representan un cambio de actividad (TodoWrite,
|
||||
# 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
|
||||
Reference in New Issue
Block a user