sync: global→pool, pool-guard raus, Session-Watcher-Setup, verbotenes Wort Ehrlich
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# pool-guard — SessionStart-Hook: prüft direkt nach dem claude-Start, ob die
|
||||
# Session über claude-sync (Pool-Mechanismus) läuft. claude-sync schreibt die
|
||||
# Sentinel-Datei in den Projekt-Root und hält sie offen; ein RAW-Start hat
|
||||
# keine lebende Sentinel dahinter und wird beendet.
|
||||
set -uo pipefail
|
||||
|
||||
sentinel="$CLAUDE_PROJECT_DIR/.ai-control-running"
|
||||
|
||||
fail() {
|
||||
# claude im Elternbaum finden und beenden, dann Banner aufs Terminal.
|
||||
p=$PPID
|
||||
while [ -n "$p" ] && [ "$p" -gt 1 ]; do
|
||||
case "$(ps -o comm= -p "$p")" in
|
||||
*claude*) kill "$p"; break ;;
|
||||
esac
|
||||
p=$(ps -o ppid= -p "$p" | tr -d ' ')
|
||||
done
|
||||
sleep 0.3
|
||||
{
|
||||
printf '\n\033[1;5;97;41m POOL-GUARD: %s \033[0m\n\n' "$1"
|
||||
printf '\033[1;31mDiese Session lief außerhalb des Pool-Mechanismus und wurde beendet.\nStart nur über die Ghostty-App bzw. claude-sync.\033[0m\n'
|
||||
} >/dev/tty
|
||||
exit 2
|
||||
}
|
||||
|
||||
[ -f "$sentinel" ] || fail "keine Sentinel-Datei ($sentinel)"
|
||||
pool=$(sed -n 's/^pool=//p' "$sentinel")
|
||||
pid=$(sed -n 's/^pid=//p' "$sentinel")
|
||||
[ "$pool" = "${CLAUDE_CONFIG_DIR:-}" ] || fail "Pool-Mismatch: Sentinel=$pool, Session=${CLAUDE_CONFIG_DIR:-<leer>}"
|
||||
kill -0 "$pid" 2>/dev/null || fail "claude-sync (PID $pid) lebt nicht mehr"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user