Skip to content

fix(grok): prefix PowerShell call operator on Windows hook commands - #750

Open
Dannym-Packetloss wants to merge 1 commit into
HarnessMD:mainfrom
Dannym-Packetloss:fix/749-grok-hook-pwsh
Open

Dannym-Packetloss wants to merge 1 commit into
HarnessMD:mainfrom
Dannym-Packetloss:fix/749-grok-hook-pwsh

Conversation

@Dannym-Packetloss

@Dannym-Packetloss Dannym-Packetloss commented Oct 15, 2026 •

Copy link
Copy Markdown

Summary

Grok runs hook commands through PowerShell (pwsh) on Windows. installGrokHooks() wrote "<hive-node.cmd>" "<grok-hook.cjs>"; in PowerShell a line that starts with a quoted string is an expression, so the second string is a ParserError (Unexpected token) and every hook exits 1. Grok ignores the failure, so tools run but the hive never gets status, session capture or tracking. Because the file is rewritten on every Grok spawn, a manual fix does not survive.

This adds grokHookCommand(), which puts PowerShell's call operator in front on win32: & "<hive-node.cmd>" "<grok-hook.cjs>". macOS/Linux output is unchanged.

Fixes #749

Tests

  • New unit test for grokHookCommand() per platform.
  • New Windows test that installs the Grok hooks under a hive path with a space and runs the generated command in pwsh: the old shape fails with a ParserError (negative control), the new one exits 0.
  • npm run typecheck clean; test/hive-hook-node.test.cjs: 11 pass, 0 fail, 3 skipped (POSIX only). npm run test:focused adds 2 passing tests and no new failures.
  • Tested on Windows 11, pwsh 7.6.6, Grok 1.0.52.

Before

Before: the generated hook command fails in pwsh 7.6.6 with ParserError, exit code 1

The generated hook command, run by pwsh 7.6.6 as Grok runs it:

PS> "%APPDATA%\munder-difflin\shared\bin\<hash>\hive-node.cmd" "%APPDATA%\munder-difflin\shared\bin\<hash>\grok-hook.cjs"
ParserError:
Line |
   1 |  . e-node.cmd" "C:\Users\…\AppData\Roaming\munder-difflin\shared\bin .
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Unexpected token '"…\grok-hook.cjs"' in expression or statement.
exit code: 1

After

After: the same command with the & call operator exits 0 in pwsh 7.6.6

PS> & "%APPDATA%\munder-difflin\shared\bin\<hash>\hive-node.cmd" "%APPDATA%\munder-difflin\shared\bin\<hash>\grok-hook.cjs"
exit code: 0

With this command in ~/.grok/hooks/munder-hive.json, Grok's Hooks tab shows global/munder-hive passing (pre_tool_use, post_tool_use, user_prompt_submit: status=success) where it previously failed every event.

🤖 Generated with Claude Code

Grok runs hook commands through pwsh on Windows. A command that starts
with a quoted path is a string expression there, so every generated
hook exited 1 with a ParserError and never reached the hive.

Fixes HarnessMD#749

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

✅ Evidence received. Before and after are both attached. Thanks — this is what makes a PR reviewable in one pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grok hive hook fails on Windows: munder-hive.json command is not valid PowerShell

1 participant