fix: Windows compatibility for hook scripts (execFileSync + tmux)#215
Conversation
- post-edit-format.js: add `shell: process.platform === 'win32'` to
execFileSync options so npx.cmd is resolved via cmd.exe on Windows
- post-edit-typecheck.js: same fix for tsc invocation via npx
- hooks.json: skip tmux-dependent hooks on Windows where tmux is
unavailable (dev-server blocker and long-running command reminder)
On Windows, execFileSync('npx', ...) without shell:true fails with
ENOENT because Node.js cannot directly execute .cmd files. These
hooks silently fail on all Windows installations.
The tmux hooks unconditionally block dev server commands (exit 2) or
warn about tmux on Windows where tmux is not available.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds platform guards to hook configuration to avoid running certain hooks on Windows, enables shell execution on Windows for format/typecheck hook scripts, normalizes string quote styles, and broadens session-end transcript parsing to handle Claude Code JSONL formats and nested content. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 🧹 Recent nitpick comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
The session-end hook expected user messages at entry.content, but Claude Code's actual JSONL format nests them at entry.message.content. This caused all session files to be blank templates (0 user messages despite 136+ actual entries). - Check entry.message?.content in addition to entry.content - Extract tool_use blocks from assistant message.content arrays Verified with Claude Code v2.1.41 JSONL transcripts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
[openclaw-bot:pr-review] Automated Review - CI checks are passing! ✅ Hi @dungan24, thanks for this contribution! All CI checks have passed successfully. A maintainer will review this PR shortly. In the meantime, please ensure:
This is an automated review from OpenClaw. |
…ocks Tests the new transcript parsing from PR #215: - entry.message.content format (string and array content) - tool_use blocks nested in assistant message content arrays - Verifies file paths and tool names extracted from both formats
…faan-m#215) * fix: Windows compatibility for hook scripts - post-edit-format.js: add `shell: process.platform === 'win32'` to execFileSync options so npx.cmd is resolved via cmd.exe on Windows - post-edit-typecheck.js: same fix for tsc invocation via npx - hooks.json: skip tmux-dependent hooks on Windows where tmux is unavailable (dev-server blocker and long-running command reminder) On Windows, execFileSync('npx', ...) without shell:true fails with ENOENT because Node.js cannot directly execute .cmd files. These hooks silently fail on all Windows installations. The tmux hooks unconditionally block dev server commands (exit 2) or warn about tmux on Windows where tmux is not available. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: parse Claude Code JSONL transcript format correctly The session-end hook expected user messages at entry.content, but Claude Code's actual JSONL format nests them at entry.message.content. This caused all session files to be blank templates (0 user messages despite 136+ actual entries). - Check entry.message?.content in addition to entry.content - Extract tool_use blocks from assistant message.content arrays Verified with Claude Code v2.1.41 JSONL transcripts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: ddungan <sckim@mococo.co.kr> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
…ocks Tests the new transcript parsing from PR affaan-m#215: - entry.message.content format (string and array content) - tool_use blocks nested in assistant message content arrays - Verifies file paths and tool names extracted from both formats
Summary
shell: process.platform === 'win32'toexecFileSyncoptions sonpx.cmdis resolved viacmd.exeon WindowsProblem 1: execFileSync ENOENT on Windows
On Windows (Git Bash / nvm-windows),
execFileSync('npx', [...])withoutshell: truefails withENOENTbecause Node.js'sCreateProcessWcannot directly execute.cmdfiles — only actual.exebinaries. Since npm installsnpx.cmd(notnpx.exe), the Prettier auto-format and TypeScript type-check hooks silently fail on every Windows installation.Additionally, the tmux dev-server blocker hook unconditionally exits with code 2 on Windows (blocking
npm run devcommands), and the tmux reminder always fires sinceprocess.env.TMUXis never set.Reproduction
Problem 2: Session summary files always blank
extractSessionSummary()insession-end.jsexpected user messages atentry.content, but Claude Code's actual JSONL transcript format nests them atentry.message.content. This caused all session summary files to remain blank templates — 0 user messages extracted despite 136+ actual user entries in the transcript.Actual Claude Code v2.1.41 JSONL structure:
{"type":"user","message":{"role":"user","content":"user text here"},...} {"type":"assistant","message":{"content":[{"type":"tool_use","name":"Edit","input":{"file_path":"..."}},...]},...} {"type":"progress","data":{...},...}The parser expected:
entry.content(string) — actual location:entry.message.contententry.type === 'tool_use'at top level — actual location: nested inentry.message.content[]blocks withinassistantentriesFix
Minimal, targeted changes:
shell: process.platform === 'win32'— only enables shell on Windows, zero overhead on macOS/Linuxprocess.platform !== 'win32'guard on tmux hooks — skips tmux logic on Windowsentry.message?.contentin addition toentry.contentfor user messagestool_useblocks from assistantmessage.contentarraysTest plan
execFileSync('npx', [...], { shell: process.platform === 'win32' })resolvesnpx.cmdon Windowsfalse)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Chores
New Features