mirror of
https://github.com/Imbad0202/academic-research-skills.git
synced 2026-09-14 13:51:17 +08:00
4f8acbcaf2
The PreToolUse write-scope guard was wired as a bare `python3 ".../ars_write_scope_guard.py"`. On Windows `python3` is commonly a 0-byte Microsoft Store alias stub (exit 49, no output), so the hook failed before the guard's own fail-safes ran and spammed the hook log every call. A new cross-platform launcher `hooks/run_guard.sh` (POSIX sh; `hooks.json` invokes it via bash) finds a real interpreter — `py -3` / `python3` / `python`, each verified by a marker probe that must exit 0 AND print the marker (a stub is skipped) — then runs the guard as a supervised, time-bounded subprocess. Plan A graceful degradation: if no real interpreter is found or the guard subprocess misbehaves, the launcher emits a valid pass-through hook JSON and exits 0, never blocking and staying silent on stderr on the degraded paths. Hardened across a two-model dual-track review (codex + gemini, both POSIX-reproduced): the no-`timeout` watchdog fallback's stdin/stdout/timeout handling, a pid-reuse race (done-file handshake), a predictable-/tmp symlink fail-open (mktemp failure degrades to pass-through), and a gameable CI exec assertion (line-anchored). 76 tests (21 launcher + 55 guard); README documents the Git Bash prerequisite on Windows. Verified against the reporter's confirmed environment (py -3 real, python3 an exit-49 stub): the stub is skipped, the guard runs via py -3, and the decision is forwarded. Closes #454. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
26 lines
486 B
JSON
26 lines
486 B
JSON
{
|
|
"hooks": {
|
|
"SessionStart": [
|
|
{
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/announce-ars-loaded.sh\""
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"PreToolUse": [
|
|
{
|
|
"matcher": "Write|Edit|MultiEdit|Bash",
|
|
"hooks": [
|
|
{
|
|
"type": "command",
|
|
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/run_guard.sh\""
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
}
|