From 0a4d60db4faf3628abc3e6be4fc3e1a0697c69de Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Thu, 22 Oct 2026 20:56:46 +0000 Subject: fix(hooks): add a powershell form of the SessionStart command for Copilot on Windows (#2189) GitHub Copilot on Windows (Copilot CLI and VS Code Copilot) runs a hook's command through PowerShell and ignores shell:"bash". PowerShell parses "/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 Co-authored-by: Serge ARADJ Claude-Session: https://claude.ai/code/session_01SHANcr4A71nzuU9et4Fnba --- docs/windows/polyglot-hooks.md | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'docs') diff --git a/docs/windows/polyglot-hooks.md b/docs/windows/polyglot-hooks.md index 3da01ae..d753d90 100644 --- a/docs/windows/polyglot-hooks.md +++ b/docs/windows/polyglot-hooks.md @@ -51,6 +51,7 @@ hooks/ { "type": "command", "command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start", + "powershell": "& \"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start", "shell": "bash", "async": false } @@ -63,6 +64,15 @@ hooks/ The path is quoted because `${CLAUDE_PLUGIN_ROOT}` may contain spaces. +### The `powershell` key + +GitHub Copilot (the CLI and VS Code) on Windows runs hook commands through +PowerShell regardless of the `shell` key (#2189), where a leading quoted path +parses as a string expression and the trailing bareword is an error +("Unexpected token 'session-start'"). Copilot uses the `powershell` key +instead of `command` when it is present, and it gives the same dispatch with +the `&` call operator. Claude Code ignores the key. + ## How `run-hook.cmd` Works at a High Level `run-hook.cmd` is a polyglot script: Windows treats the first block as batch -- cgit