diff options
| author | Jesse Vincent <jesse@fsck.com> | 2026-10-22 20:56:46 +0000 |
|---|---|---|
| committer | Jesse Vincent <jesse@fsck.com> | 2026-10-22 20:56:46 +0000 |
| commit | 0a4d60db4faf3628abc3e6be4fc3e1a0697c69de (patch) | |
| tree | 953d85a7e412297303c495863346c10136bd2407 /tests/hooks/test-session-start.sh | |
| parent | 0f9581f6c1525b51dc1600b14d24f3db1f601446 (diff) | |
fix(hooks): add a powershell form of the SessionStart command for Copilot on Windows (#2189)fix/2189-copilot-powershell-hook
GitHub Copilot on Windows (Copilot CLI and VS Code Copilot) runs a hook's
command through PowerShell and ignores shell:"bash". PowerShell parses
"<root>/hooks/run-hook.cmd" session-start as a string expression followed
by a bareword, fails with "Unexpected token 'session-start'", and the
using-superpowers bootstrap never reaches the session.
Copilot prefers a hook's powershell key over command when it is present, so
add one that runs the same wrapper with the & call operator. Claude Code
ignores the key and keeps dispatching command through Git Bash.
Verified on Windows 11 in a VM: Copilot CLI 1.0.103 logged the ParserError
and sent no bootstrap before the change, and ran the hook and sent the
bootstrap after it. Claude Code 2.1.308 ran the hook and sent the bootstrap
both before and after.
The new test in test-run-hook-cmd-windows.sh runs the hooks.json powershell
value through powershell.exe against a plugin root with a space in its path.
Co-authored-by: Tugrul Guner <tugrulguner@users.noreply.github.com>
Co-authored-by: Serge ARADJ <orty@users.noreply.github.com>
Claude-Session: https://claude.ai/code/session_01SHANcr4A71nzuU9et4Fnba
Diffstat (limited to 'tests/hooks/test-session-start.sh')
| -rwxr-xr-x | tests/hooks/test-session-start.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/hooks/test-session-start.sh b/tests/hooks/test-session-start.sh index 6ddf011..2a27c78 100755 --- a/tests/hooks/test-session-start.sh +++ b/tests/hooks/test-session-start.sh @@ -147,6 +147,12 @@ echo "SessionStart hook output tests" # Windows dispatches via Git Bash (or fails with an actionable error) instead # of PowerShell/cmd.exe, whose parsers break on the quoted command string # (PowerShell ParserError; cmd.exe quote-stripping on paths with metacharacters). +# +# VS Code Copilot ignores shell:"bash" and runs the `command` string through +# PowerShell regardless (#2189). The optional `powershell` key supplies a +# PowerShell-native form of the same dispatch: the `&` call operator makes the +# quoted plugin-root path parse as a command invocation instead of a string +# expression followed by the bareword `session-start`. if node -e ' const hooks = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")); const entry = hooks.hooks.SessionStart[0].hooks[0]; @@ -158,6 +164,14 @@ if (!/run-hook\.cmd" session-start$/.test(entry.command)) { console.error(`unexpected SessionStart command shape: ${entry.command}`); process.exit(1); } +if (typeof entry.powershell !== "string") { + console.error(`SessionStart hook missing powershell key for VS Code Copilot (#2189)`); + process.exit(1); +} +if (!/^& "/.test(entry.powershell) || !/run-hook\.cmd" session-start$/.test(entry.powershell)) { + console.error(`unexpected SessionStart powershell shape: ${entry.powershell}`); + process.exit(1); +} ' "$REPO_ROOT/hooks/hooks.json"; then pass "hooks.json registers SessionStart with shell:bash dispatch" else |
