fix(agent-guard): make the fresh-clone hook guard cross-platform (Windows)#823
Open
milamberspace wants to merge 1 commit into
Open
fix(agent-guard): make the fresh-clone hook guard cross-platform (Windows)#823milamberspace wants to merge 1 commit into
milamberspace wants to merge 1 commit into
Conversation
…dows) Follow-up to apache#786: the POSIX `[ -f … ] && … || true` guard only works in a POSIX shell, so on Windows (PowerShell, no Git Bash) the committed hook breaks. Replace it with an inline `python3 -c` existence check that no-ops when agent-guard.py is absent and runs + propagates its exit code otherwise — cross-platform, no shell conditional, and reads CLAUDE_PROJECT_DIR from the environment in Python (no $VAR vs %VAR% expansion). Reported by an adopter (Apache JMeter) reviewing the same change downstream. Generated-by: Claude Opus 4.8
Contributor
Author
|
Heads-up for maintainers: this cross-platform fix may be superseded by #824. That issue proposes writing the agent-guard hook into the gitignored, per-machine Happy to close this in favour of #824, or keep it as the interim fix if you would rather ship the smaller change first — your call. |
Member
|
Oh... Windows support :) |
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.
Summary
Follow-up to #786 (merged): that PR guarded the committed agent-guard hook command with a POSIX shell conditional —
[ -f … ] && python3 … || true— so the hook no-ops on a fresh clone before/magpie-setuphas syncedagent-guard.pyin. But that form only works in a POSIX shell; on Windows (PowerShell, no Git Bash) the committed hook breaks.Replace it with an inline
python3 -cexistence check that is cross-platform and needs no shell conditional:CLAUDE_PROJECT_DIRfrom the environment in Python, so it doesn't depend on$VARvs%VAR%shell expansion.Updated in the two places that ship the snippet:
skills/setup/adopt.mdandtools/agent-guard/README.md.Found by an adopter (Apache JMeter) reviewing the same change downstream — the reviewer asked "Does this work with windows?" on the adoption PR.
Type of change
Test plan
Doc / template change. The guarded command is valid on both POSIX and Windows (pure
python3 -c, no shell conditional); it no-ops when the script is missing and runs + propagates the guard's exit code when present.