Files
TSYSGroupAIOS/hooks/exit-protocol.sh
T
mrcharles 374288a105 feat: bootstrap meta — cross-project best-practices template
Extract patterns from 18 projects across two machines (12 local infra +
6 remote personal/business via ssh survey). Ship a reusable Gitea template
with AGENTS.md, 5 Crush PreToolUse hooks, git pre-commit/pre-push, a
generalized rules engine, shared bash library, Makefile, lifecycle scripts,
and gardening loop. Includes the canonical BASELINE-PROMPT.md (13 sections)
and PATTERNS.md (standardization scorecard).

The repo self-applies: it passes its own shellcheck (zero info-level),
make fast, and all check-rules.sh checks.

💘 Generated with Crush

Assisted-by: Crush via Crush <crush@charm.land>
2026-08-07 11:17:53 -05:00

27 lines
1.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Hook: exit-protocol (PreToolUse, matcher: .*) — catch-all.
# Enforces the project's definition of "done": if WORKING.md has any unchecked
# task, inject context ordering the agent to finish them before responding.
# This prevents premature "Done" responses.
set -euo pipefail
# Required by the hook protocol: consume stdin.
cat >/dev/null
REPO_ROOT="${CRUSH_PROJECT_DIR:-$(pwd)}"
WORKING_FILE="$REPO_ROOT/WORKING.md"
if [ -f "$WORKING_FILE" ]; then
UNCHECKED="$(grep -cF -- '- [ ]' "$WORKING_FILE" || true)"
if [ "$UNCHECKED" -gt 0 ]; then
TASKS_JSON="$(grep -F -- '- [ ]' "$WORKING_FILE" \
| sed 's/\\/\\\\/g; s/"/\\"/g' \
| awk -v ORS='\\n' '{print}' | sed 's/\\n$//')"
printf '{"context": "STOP. WORKING.md has %s unfinished task(s). You cannot declare work done or respond to the user while these remain:\\n%s\\nFinish them now. Do not respond until all are checked. Then clear WORKING.md and commit."}\n' \
"$UNCHECKED" "$TASKS_JSON"
exit 0
fi
fi
echo '{}'