# What the harness hooks call under PowerShell: tools/trace_ingest.py, run by the venv's Python. # # ./tools/trace-hook --source claude-code --event prompt.submitted # # The hook commands name only that string, and its POSIX half is tools/trace-hook. PowerShell # on Windows resolves it to this file first. Without it, the string reaches the sh script # itself, which Windows has no program for: it opens the "choose an app" dialog on every hook # event. Copilot CLI takes that path through .claude/settings.json - it reads that file besides # its own .github/hooks/, and runs its single `command` under PowerShell on Windows. # # Same rules as the sh twin: the venv's Python stands in for the recorded one, no venv means # no trace, and the exit status is always 0 - a hook must never fail the call it observes. # There is no `#Requires -Version 7` for the same reason: VS Code starts hooks under Windows # PowerShell 5.1, so this file keeps to what both understand. $ErrorActionPreference = 'SilentlyContinue' $PSNativeCommandArgumentPassing = 'Standard' trap { exit 0 } $Dir = $PSScriptRoot foreach ($candidate in @((Join-Path $Dir '.venv/Scripts/python.exe'), (Join-Path $Dir '.venv/bin/python'))) { if (Test-Path -LiteralPath $candidate -PathType Leaf) { & $candidate (Join-Path $Dir 'trace_ingest.py') @args 2>$null break } } exit 0