sync: global→pool, pool-guard raus, Session-Watcher-Setup, verbotenes Wort Ehrlich

This commit is contained in:
marcus.hinz
2026-07-04 19:09:13 +02:00
parent a7ff9378da
commit 79314d6140
43 changed files with 669 additions and 33 deletions
+15
View File
@@ -0,0 +1,15 @@
// ghostty-wincount <pid> Anzahl sichtbarer Normal-Fenster (Layer 0) des
// Prozesses, direkt vom Window-Server. Keine Apple-Events, kein TCC-Prompt.
import CoreGraphics
import Foundation
guard CommandLine.arguments.count == 2, let pid = Int32(CommandLine.arguments[1]) else {
FileHandle.standardError.write(Data("usage: ghostty-wincount <pid>\n".utf8))
exit(2)
}
let list = CGWindowListCopyWindowInfo([.optionOnScreenOnly], kCGNullWindowID) as? [[String: Any]] ?? []
let n = list.filter {
($0[kCGWindowOwnerPID as String] as? Int32) == pid &&
($0[kCGWindowLayer as String] as? Int) == 0
}.count
print(n)
+32
View File
@@ -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