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
This commit is contained in:
1 parent
d6e973c3ce
commit
9d06050338
8 files changed
+119
-6
No files matched your search
@@ -0,0 +1,27 @@
|
||||
# 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
|
||||
Reference in new issue
Block a user