fix: use env var instead of tmux check for Stop hook scoping
The tmux display-message approach had edge cases: it could succeed outside tmux, fail on first iteration, or behave differently depending on tmux socket state. Replace with AGENT_LOOP_ACTIVE env var exported by loop.sh. CC sessions spawned by the loop inherit it; interactive CC sessions don't. Simple, no external dependencies, no race conditions.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
"name": "agent-loop",
|
||||
"source": "./",
|
||||
"description": "Autonomous generator-evaluator agent loop for long-running coding tasks. Plan interactively, then execute with full visibility.",
|
||||
"version": "0.10.0",
|
||||
"version": "0.10.1",
|
||||
"author": {
|
||||
"name": "Sheldon"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "agent-loop",
|
||||
"version": "0.10.0",
|
||||
"version": "0.10.1",
|
||||
"description": "Autonomous generator-evaluator agent loop for long-running coding tasks. Run /agent-loop:run to start.",
|
||||
"author": {
|
||||
"name": "Sheldon"
|
||||
|
||||
@@ -14,11 +14,10 @@
|
||||
|
||||
SETTINGS_FILE="${PROJECT_ROOT}/.claude/settings.local.json"
|
||||
|
||||
# The hook command checks we're inside the agent-loop tmux session before killing.
|
||||
# This prevents the hook from affecting other CC sessions open in the same project.
|
||||
# IMPORTANT: Must check $TMUX first — tmux display-message can succeed even outside
|
||||
# tmux by falling back to the most recently created session, which would be agent-loop.
|
||||
HOOK_COMMAND='[ -n "$TMUX" ] && tmux display-message -p "#{session_name}" 2>/dev/null | grep -q "^agent-loop$" && kill -INT $PPID || true'
|
||||
# The hook checks AGENT_LOOP_ACTIVE before killing. This env var is exported by
|
||||
# loop.sh and inherited by CC sessions it spawns. Interactive CC sessions in the
|
||||
# same project won't have it set, so the hook is a no-op for them.
|
||||
HOOK_COMMAND='[ "${AGENT_LOOP_ACTIVE:-}" = "1" ] && kill -INT $PPID || true'
|
||||
|
||||
install_hooks() {
|
||||
if [ ! -f "$SETTINGS_FILE" ]; then
|
||||
|
||||
Reference in New Issue
Block a user