Fix preToolUse hook cwd to use ${PLUGIN_ROOT}#584
Open
solvaholic wants to merge 1 commit into
Open
Conversation
The three preToolUse guardrail hooks set cwd ".", which Copilot CLI
resolves against the project cwd rather than the plugin root. Once the
plugin is installed outside the repo checkout, the relative script paths
aren't found, the hook errors, and (since CLI 1.0.57 fail-closed) the
tool call is denied.
Anchor cwd to ${PLUGIN_ROOT} so the scripts resolve regardless of the
project cwd. Works on CLI 1.0.60+.
Fixes gm3dmo#583
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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 #583.
What
The three
preToolUseguardrail hooks incopilot-plugin/hooks.jsonset"cwd": ".", which Copilot CLI resolves against the project cwd rather than the plugin root. Once the plugin is installed outside the repo checkout (e.g. under$COPILOT_HOME/cache/marketplaces/...), the relative script paths (./hooks/guard-*.sh) are not found, the hook errors, and - since CLI 1.0.57 fail-closed - the tool call is denied withDenied by preToolUse hook from "the-power" (hook errored).Fix
Anchor each hook to
"cwd": "${PLUGIN_ROOT}"so the scripts resolve regardless of the project cwd.PLUGIN_ROOThas been injected since CLI 1.0.26, andcwdexpansion of plugin vars landed in 1.0.60, so this works on 1.0.60+.Verified workaround per github/copilot-cli#2540 (comment).
Notes
set -ein_common.sh).