Files
torben 9d06050338
CI / verify (push) Successful in 2m26s
CI / pwsh (push) Successful in 1m53s
Release / release (push) Successful in 35s
fix: trace-hook.ps1 - Copilot hooks under PowerShell on Windows no longer open the choose-an-app dialog (#164)
Files changed:
- CHANGES.md
- EVALS.md
- VERSION
- tools/README.md
- tools/chemenu/tests/test_preflight.py
- tools/chemenu/tests/test_preflight_pwsh.py
- tools/trace-hook
- tools/trace-hook.ps1
2026-10-01 16:50:13 +02:00

28 lines
1.3 KiB
PowerShell

# 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