From 41c77d198ce76eb429e91884a72c41125c2f4f8f Mon Sep 17 00:00:00 2001 From: montjeffrey Date: Wed, 4 Nov 2026 10:02:50 -0500 Subject: [PATCH] fix(clv2): run the Python Install Manager launcher, not its WindowsApps alias With the Python Install Manager, python3/python in %LOCALAPPDATA%\Microsoft\WindowsApps are App Execution Aliases. Every start of one makes Windows run an App Installer update check (AppXDeploymentServer event 603), and observe.sh starts Python several times per tool call (anthropics/claude-code#98929). When the chosen python3/python resolves into WindowsApps and the Install Manager's global shortcut %LOCALAPPDATA%\Python\bin\.exe exists, observe.sh now runs that shortcut. It is exported as CLV2_PYTHON_CMD, so detect-project.sh uses it too. Nothing is executed to decide: no probe, no timeout, no cache. Microsoft Store Python (no shortcut), regular installs, Linux and macOS are unchanged, and an explicit CLV2_PYTHON_CMD still wins. Measured on Windows 11 with Python Install Manager and Python 3.14: 3 alias starts logged 3 event-603 entries; 3 shortcut starts logged 0. Average start: alias 200.6 ms, shortcut 56.1 ms, interpreter 53.3 ms. Co-Authored-By: Claude Opus 5.5 --- .../continuous-learning-v2/hooks/observe.sh | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/skills/continuous-learning-v2/hooks/observe.sh b/skills/continuous-learning-v2/hooks/observe.sh index aecb29a07..7b9984d10 100755 --- a/skills/continuous-learning-v2/hooks/observe.sh +++ b/skills/continuous-learning-v2/hooks/observe.sh @@ -66,6 +66,29 @@ _is_windows_app_installer_stub() { return 1 } +_python_install_manager_launcher() { + # With the Python Install Manager, python3/python in + # %LOCALAPPDATA%\Microsoft\WindowsApps + # are App Execution Aliases. Every start of one makes Windows run an App + # Installer update check (AppXDeploymentServer event 603), and this hook + # starts Python several times per tool call. The Install Manager's global + # shortcuts in %LOCALAPPDATA%\Python\bin start the same runtime without that + # check, so print the shortcut for $1 when it is an alias and one exists. + # Microsoft Store Python has no such shortcut and keeps its alias. + local _candidate="$1" _resolved _launcher + _resolved="$(command -v "$_candidate" 2>/dev/null || true)" + case "$_resolved" in + *[\\/][Mm][Ii][Cc][Rr][Oo][Ss][Oo][Ff][Tt][\\/][Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss][\\/]*) ;; + *) return 1 ;; + esac + [ -n "${LOCALAPPDATA:-}" ] || return 1 + # Git Bash accepts C:/... paths, so swapping separators avoids a cygpath start. + _launcher="${LOCALAPPDATA//\\//}" + _launcher="${_launcher%/}/Python/bin/${_candidate}.exe" + [ -f "$_launcher" ] && [ -x "$_launcher" ] || return 1 + printf '%s\n' "$_launcher" +} + resolve_python_cmd() { if [ -n "${CLV2_PYTHON_CMD:-}" ] && command -v "$CLV2_PYTHON_CMD" >/dev/null 2>&1; then printf '%s\n' "$CLV2_PYTHON_CMD" @@ -73,12 +96,12 @@ resolve_python_cmd() { fi if command -v python3 >/dev/null 2>&1 && ! _is_windows_app_installer_stub python3; then - printf '%s\n' python3 + _python_install_manager_launcher python3 || printf '%s\n' python3 return 0 fi if command -v python >/dev/null 2>&1 && ! _is_windows_app_installer_stub python; then - printf '%s\n' python + _python_install_manager_launcher python || printf '%s\n' python return 0 fi