From 21c25446ee3c871723db8872f83389f574345b91 Mon Sep 17 00:00:00 2001 From: NagyVikt Date: Sun, 17 May 2026 03:32:32 +0200 Subject: [PATCH] fix(hooks): restore scripts/agent-stalled-report.sh referenced by SessionStart The .claude/settings.json SessionStart hook calls scripts/agent-stalled-report.sh, but the file was never committed to this repo (only omx-merge-gate.sh got synced from recodee in #149). Every Claude Code session start failed with: bash: /.../scripts/agent-stalled-report.sh: No such file or directory Restore the canonical wrapper from recodee. When agent-autofinish-watch.sh is absent the script soft-exits 0, so the hook is silent until the watcher lands. --- scripts/agent-stalled-report.sh | 40 +++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 scripts/agent-stalled-report.sh diff --git a/scripts/agent-stalled-report.sh b/scripts/agent-stalled-report.sh new file mode 100755 index 0000000..b494cc8 --- /dev/null +++ b/scripts/agent-stalled-report.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Quiet wrapper around scripts/agent-autofinish-watch.sh that surfaces stalled +# agent/* worktrees. Prints nothing when everything's clean; prints a one-line +# summary per stalled worktree + a finish hint when there's work to recover. +# +# Designed to be wired as a SessionStart hook so Claude Code (and the user) +# learn about half-finished codex/claude agent runs at the top of each session. +# +# Exit codes: +# 0 — no stalled worktrees (or watcher missing — soft fail) +# 0 — even when stalled worktrees ARE detected (this is informational, not a hard error) + +set -euo pipefail + +repo_root="$(git rev-parse --show-toplevel 2>/dev/null || pwd)" +watcher="${repo_root}/scripts/agent-autofinish-watch.sh" + +if [[ ! -x "$watcher" ]]; then + exit 0 +fi + +raw_output="$(bash "$watcher" --once --dry-run 2>&1 || true)" + +# Filter to per-worktree status lines only ("[agent-autofinish-watch] agent/: ..."). +stalled_lines="$(printf '%s\n' "$raw_output" | grep -E '^\[agent-autofinish-watch\] agent/' || true)" + +if [[ -z "$stalled_lines" ]]; then + exit 0 +fi + +stalled_count="$(printf '%s\n' "$stalled_lines" | wc -l | tr -d ' ')" + +printf '⚠ Stalled agent worktrees detected (%s):\n' "$stalled_count" +printf '%s\n' "$stalled_lines" | sed 's/^\[agent-autofinish-watch\] / • /' +printf '\nResolve options:\n' +printf ' • Inspect: bash scripts/agent-autofinish-watch.sh --once --dry-run\n' +printf ' • Auto-finish: bash scripts/agent-autofinish-watch.sh --once --auto-merge\n' +printf ' • Run daemon: bash scripts/agent-autofinish-watch.sh --daemon --auto-merge\n' + +exit 0