-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhook_bootstrap.ps1
More file actions
28 lines (25 loc) · 1.3 KB
/
Copy pathhook_bootstrap.ps1
File metadata and controls
28 lines (25 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# Bootstrap for the copilot-custom-logging plugin hooks (Windows).
#
# Copilot runs hook commands with the user's working directory, not the
# plugin directory, so a plain relative path to the dispatcher won't resolve.
# This bootstrap reads the event payload, locates otel_dispatch.py inside the
# installed plugin directory, and runs it. hooks.json embeds a copy of this
# script (it is the tiny entry point); all real logic lives in
# otel_dispatch.py.
#
# It always exits 0 (fail-open): a PreToolUse command hook is fail-closed on a
# non-zero exit, so telemetry problems must never block the user's tools.
$env:COPILOT_OTEL_INPUT = [Console]::In.ReadToEnd()
$dispatch = $env:COPILOT_OTEL_DISPATCH
if (-not $dispatch) {
$root = if ($env:COPILOT_HOME) { $env:COPILOT_HOME } else { Join-Path $HOME '.copilot' }
$dispatch = Get-ChildItem -Path (Join-Path $root 'installed-plugins') -Recurse -Filter otel_dispatch.py -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -like '*copilot-custom-logging*' } |
Select-Object -First 1 -ExpandProperty FullName
}
if (-not $dispatch -or -not (Test-Path $dispatch)) { exit 0 }
$py = Get-Command python -ErrorAction SilentlyContinue
if (-not $py) { $py = Get-Command python3 -ErrorAction SilentlyContinue }
if (-not $py) { exit 0 }
& $py.Source $dispatch
exit 0