-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhook_bootstrap.sh
More file actions
27 lines (24 loc) · 1.06 KB
/
Copy pathhook_bootstrap.sh
File metadata and controls
27 lines (24 loc) · 1.06 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
#!/usr/bin/env bash
# Bootstrap for the copilot-custom-logging plugin hooks (macOS/Linux).
#
# 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.
export COPILOT_OTEL_INPUT="$(cat)"
DISPATCH="${COPILOT_OTEL_DISPATCH:-}"
if [ -z "$DISPATCH" ]; then
ROOT="${COPILOT_HOME:-$HOME/.copilot}/installed-plugins"
DISPATCH="$(find "$ROOT" -name otel_dispatch.py -path '*copilot-custom-logging*' 2>/dev/null | head -n1)"
fi
[ -f "$DISPATCH" ] || exit 0
if command -v python3 >/dev/null 2>&1; then PY=python3
elif command -v python >/dev/null 2>&1; then PY=python
else exit 0
fi
exec "$PY" "$DISPATCH"