A local-first personal finance app
[AI] Remove agentic stop-hook from all platforms (#8684)
Matiss Janis Aboltinsa0d10a5b46f0
diff --git a/.claude/settings.json b/.claude/settings.jsonindex 6d42c6885b..4002f065c1 100644--- a/.claude/settings.json+++ b/.claude/settings.json@@ -52,17 +52,6 @@}]}- ],- "Stop": [- {- "hooks": [- {- "type": "command",- "command": "\"$CLAUDE_PROJECT_DIR/scripts/agent-hooks/check-on-stop.sh\"",- "timeout": 600- }- ]- }]}}diff --git a/.codex/config.toml b/.codex/config.tomlindex 468cb499ac..5caff52a5d 100644--- a/.codex/config.toml+++ b/.codex/config.toml@@ -12,8 +12,8 @@# raw string in tool_input.command (no tool_input.file_path / .content), so the# file-content hooks below (strict-ignore, format, one-component) only fire for# the Write/Edit tools and no-op for apply_patch. They never false-block. The-# Bash/git guard and the Stop check work regardless. The file hooks are fully-# effective under Claude Code and Cursor.+# Bash/git guard works regardless. The file hooks are fully effective under+# Claude Code and Cursor.## For hooks to run (any surface, including the ChatGPT desktop app):# 1. Lifecycle hooks must be enabled — done by the [features] flag below.@@ -78,11 +78,3 @@ matcher = "^mcp__github__create_pull_request$"type = "command"command = '"$(git rev-parse --show-toplevel)/scripts/agent-hooks/pr-template-blank.sh"'statusMessage = "Checking PR template is left blank"--# When the turn ends, typecheck + test the workspaces this branch touched.-[[hooks.Stop]]-[[hooks.Stop.hooks]]-type = "command"-command = '"$(git rev-parse --show-toplevel)/scripts/agent-hooks/check-on-stop.sh"'-timeout = 600-statusMessage = "Typecheck + test touched workspaces"diff --git a/scripts/agent-hooks/check-on-stop.sh b/scripts/agent-hooks/check-on-stop.shdeleted file mode 100755index 0b37ec8bce..0000000000--- a/scripts/agent-hooks/check-on-stop.sh+++ /dev/null@@ -1,102 +0,0 @@-#!/usr/bin/env bash-# Agent hook (Stop), shared across Claude and Codex.-#-# When the agent finishes its turn, run typecheck + test for each workspace this-# branch has touched (scoped — far cheaper than the whole-monorepo check).-# Failures are surfaced back to the agent via exit code 2 so it can fix them.-# Adapted from a suggestion by @StephenBrown2 on PR #8089.-set -uo pipefail--. "$(dirname "$0")/common.sh"-require_jq--# Read the hook payload (Claude provides stop_hook_active to prevent loops).-payload=$(cat 2>/dev/null || true)-if printf '%s' "$payload" | jq -e '.stop_hook_active == true' >/dev/null 2>&1; then- exit 0-fi--# Resolve the repo root regardless of which agent invoked us.-ROOT=$(resolve_repo_root)-cd "$ROOT" 2>/dev/null || exit 0--# Skip if dependencies aren't installed.-[ -f "$ROOT/node_modules/.yarn-state.yml" ] || exit 0--# Collect changed files, NUL-delimited so paths with spaces survive: this-# branch's commits vs master, plus tracked + untracked working-tree changes.-base=$(git merge-base HEAD origin/master 2>/dev/null || true)-files=()-while IFS= read -r -d '' f; do- [ -n "$f" ] && files+=("$f")-done < <(- {- [ -n "$base" ] && git diff -z --name-only "$base"...HEAD- git diff -z --name-only HEAD- git ls-files -z --others --exclude-standard- } 2>/dev/null-)-[ "${#files[@]}" -gt 0 ] || exit 0--# Map changed source files to the workspace dir that owns them (deduped).-# Stock macOS ships bash 3.2, which has no associative arrays (`declare -A`) and-# evaluates `arr[$d]` subscripts as arithmetic (slashes/hyphens in a path then-# blow up under `set -u`). So dedupe via a space-padded string match instead —-# `ws_dirs` stays a plain indexed array, which bash 3.2 handles fine.-seen=" "-ws_dirs=()-for f in "${files[@]}"; do- case "$f" in- *.js | *.mjs | *.jsx | *.ts | *.tsx) ;;- *) continue ;;- esac- d=$(dirname "$f")- while [ "$d" != "." ] && [ "$d" != "/" ]; do- if [ -f "$ROOT/$d/package.json" ]; then- case "$seen" in- *" $d "*) ;;- *)- seen="$seen$d "- ws_dirs+=("$d")- ;;- esac- break- fi- d=$(dirname "$d")- done-done-[ "${#ws_dirs[@]}" -gt 0 ] || exit 0--fail=0-report=""-for d in "${ws_dirs[@]}"; do- # One jq read per package.json: name + which scripts exist. Every field is a- # non-empty token (the name falls back to "-", the flags to yes/no) so that- # `read` can't collapse an empty middle field — tab is IFS-whitespace, so a- # package with test-but-no-typecheck would otherwise shift the columns.- IFS=$'\t' read -r name tc te < <(- jq -r '[.name // "-",- (if .scripts.typecheck then "yes" else "no" end),- (if .scripts.test then "yes" else "no" end)] | @tsv' "$ROOT/$d/package.json"- )- [ "$name" != "-" ] || continue-- if [ "$tc" = "yes" ]; then- if ! out=$(yarn workspace "$name" run typecheck 2>&1); then- report="$report"$'\n'"[typecheck failed: $name]"$'\n'"$(printf '%s' "$out" | tail -25)"- fail=1- fi- fi- if [ "$te" = "yes" ]; then- if ! out=$(yarn workspace "$name" run test 2>&1); then- report="$report"$'\n'"[tests failed: $name]"$'\n'"$(printf '%s' "$out" | tail -25)"- fail=1- fi- fi-done--if [ "$fail" -eq 1 ]; then- printf 'Stop check found failures in touched workspaces:%s\n' "$report" >&2- exit 2-fi-exit 0diff --git a/upcoming-release-notes/remove-agentic-stop-hook.md b/upcoming-release-notes/remove-agentic-stop-hook.mdnew file mode 100644index 0000000000..631dcc34d7--- /dev/null+++ b/upcoming-release-notes/remove-agentic-stop-hook.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Remove the agentic stop-hook (turn-end typecheck + test) from all agent platforms