fix: make the hook cross-platform by removing the bash wrapper#33
Merged
fahadsiddiqui merged 1 commit intoJul 21, 2026
Merged
Conversation
jesse-quinn
force-pushed
the
fix/windows-node-only-hook
branch
from
July 19, 2026 03:16
6a26135 to
d6a1035
Compare
The UserPromptSubmit hook invoked scripts/prompt-guard-wrapper.sh, a
bash-only script that logged to /tmp with Unix paths, so the plugin
broke on native Windows (no WSL/git-bash).
Move the wrapper's sole responsibility - opt-in debug logging - into
scripts/prompt-guard.js and invoke node directly from hooks.json:
- hooks.json now runs "node ${CLAUDE_PLUGIN_ROOT}/scripts/prompt-guard.js"
(10s timeout unchanged).
- prompt-guard.js writes execution metadata (timestamp, plugin root,
cwd, node version, exit path/code) to a debug log under the platform
cache dir - XDG_CACHE_HOME or ~/.cache on POSIX, %LOCALAPPDATA% on
Windows via a small os.platform() helper - only when
PRIVACY_GUARD_DEBUG=1. Matched secret/PII values are never logged.
- Behavior parity preserved: block-decision JSON to stdout, exit 0 on
both allow and block. Internal errors are routed to the debug log
(when enabled) and stderr stays quiet, matching the wrapper which
discarded stderr when debug was off.
- Delete scripts/prompt-guard-wrapper.sh; update the README debug docs
with the Windows path.
Fixes datumbrain#18
fahadsiddiqui
force-pushed
the
fix/windows-node-only-hook
branch
from
July 21, 2026 19:54
d6a1035 to
f13da47
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #18
Problem
hooks/hooks.jsoninvokedscripts/prompt-guard-wrapper.sh, a bash-onlyscript that logged to
/tmpwith Unix paths. On native Windows (noWSL/git-bash) the hook fails, which depending on how the exit code is
interpreted either breaks prompting or silently disables protection.
Fix
Eliminate the bash layer entirely and invoke Node directly.
hooks/hooks.jsonnow runsnode ${CLAUDE_PLUGIN_ROOT}/scripts/prompt-guard.js(same
${CLAUDE_PLUGIN_ROOT}interpolation the plugin already used; 10stimeout unchanged).
scripts/prompt-guard.jsabsorbs the wrapper's only real job -opt-in debug logging. When
PRIVACY_GUARD_DEBUG=1, it writes executionmetadata (timestamp,
CLAUDE_PLUGIN_ROOT, cwd, Node version, exitpath/code) to
debug.logunder the platform cache dir, resolvedcross-platform by a small
os.platform()helper:XDG_CACHE_HOMEor~/.cache(unchanged from before)%LOCALAPPDATA%Matched secret/PII values are never written to the log.
scripts/prompt-guard-wrapper.sh.Behavior parity
allow and block (a non-zero exit would make the hook protocol treat the
block as a non-blocking error and let the prompt through).
stderr would now reach Claude Code, so internal errors are routed to the
debug log (when enabled) and stderr stays quiet otherwise. Error paths
still exit non-zero, matching the wrapper's pass-through of a failing exit
code (a non-blocking error - the prompt is not silently altered).
dist/noteThese changes touch only
scripts/andhooks/(andREADME.md) - nosrc/changes - sodist/does not change.git status dist/is clean,satisfying the CONTRIBUTING requirement that
dist/matchsrc/.Manual verification (macOS, Node v26.5.0)
Secret prompt - prints block JSON, exits 0:
Benign prompt - no output, exits 0:
PRIVACY_GUARD_DEBUG=1- creates the log with metadata only (no secret):Grep of the log for the secret value (
sk-proj,abc123,7890) - no match.npm install && npm run build && npm test: all 159 tests pass;dist/unchanged.