Cursor hooks silently do nothing on Windows: hook stdin starts with a mangled UTF-8 BOM
Bug Description
On Windows, the Cursor hooks installed by @vectorize-io/hindsight-coding-agents install cursor-cli run and exit with code 0, but do nothing: no bank is created, nothing is retained, and ~/.hindsight/coding-agents-logs/ is never created.
Cursor runs each hook command wrapped in a PowerShell pipeline (Get-Content '<tmp>.json' -Raw | & { $input | <command> }, visible in the Cursor Hooks output channel). The JSON arriving on stdin starts with a mangled UTF-8 BOM. Captured with a debug hook that dumped stdin:
"stdinBytes": 796,
"stdinStart": "{\"conversation_id\":\"...\",\"generation_id\":\"...\",..."
Because the input starts with  instead of {, JSON parsing fails and the hook exits 0 without logging anything.
Suggested fixes:
- Strip a leading BOM (
\uFEFFand its mojibake form), or anything before the first{, beforeJSON.parsein the hook entry points. - Log input parse failures to
plugin.log/diag.jsonlinstead of exiting silently. Since Cursor shows exit code 0 and the plugin logs nothing, this was very hard to diagnose.
Workaround that fixes it for us: a wrapper that strips everything before the first { and passes the rest to the real hook:
const { spawn } = require('child_process');
const hook = process.argv[2];
let input = '';
process.stdin.setEncoding('utf8');
process.stdin.on('data', d => input += d);
process.stdin.on('end', () => {
const start = input.indexOf('{');
const clean = start >= 0 ? input.slice(start) : input;
const child = spawn(process.execPath, [hook], { stdio: ['pipe', 'inherit', 'inherit'] });
child.stdin.end(clean);
child.on('exit', code => process.exit(code ?? 0));
});
used in hooks.json as node "<home>\.hindsight\hindsight-hook.js" "<home>\.hindsight\coding-agents\dist\cursor-stop-hook.js". Note that re-running install overwrites this.
Related, smaller issue: plugin.log shows [auto-update] version check failed: spawn npm ENOENT. On Windows npm is npm.cmd, which child_process.spawn('npm', ...) can't find without shell: true (and newer Node versions refuse to spawn .cmd files without shell: true since the April 2024 security change). Happy to open this as a separate issue if you prefer.
Steps to Reproduce
- On Windows 11, install Node (here v26.3.1 via Scoop) and Cursor 3.23.23.
- Run
npx @vectorize-io/hindsight-coding-agents@latest install cursor-cli --server cloud --api-token <token>. - Fully restart Cursor, open a git repo on a Windows drive, and have a short agent chat.
- Check View > Output > Hooks: all three Hindsight hooks ran with exit code 0.
- Check
~/.hindsight/coding-agents-logs/and the Hindsight Cloud bank list. - For comparison, pipe the same JSON payload manually into
cursor-stop-hook.jsfrom a terminal: this works.
Expected Behavior
Session start creates/recalls from the bank coding-agent::<repo>, and the stop hook retains the conversation, with session_start and retain_ok entries in diag.jsonl. Any input parsing failure should be logged.
Actual Behavior
Hooks exit 0 with no output. No bank is created, nothing is retained, and the log folder ~/.hindsight/coding-agents-logs/ is never created. Running the identical hook command manually with clean JSON works immediately (bank created, retain_ok with 74 turns), which confirms config, token and server are fine and points to the stdin content Cursor passes.
Version
@vectorize-io/hindsight-coding-agents 0.8.0 (Cursor 3.23.23, Node v26.3.1, Windows 11, Windows PowerShell)
LLM Provider
None
I hit the same thing and have a fix on a branch, since PRs here are limited to collaborators: https://github.com/WynandVStaden/hindsight/tree/fix/coding-agents-hook-stdin-bom
It reproduces on Windows 11 with PowerShell 5.1: the hook's stdin starts with one or two UTF-8 BOMs, JSON.parse throws and the hook returns silently. The branch reads the event through a small helper that drops a leading BOM before parsing, used by the prompt, retain and session-start hooks, with tests. Happy for anyone to cherry-pick it.