diff --git a/setup b/setup index c28b44a71..49f05ffc2 100755 --- a/setup +++ b/setup @@ -1293,7 +1293,14 @@ rm -f /tmp/gstack-latest-version # 10. Team mode: register/unregister SessionStart hook SETTINGS_HOOK="$SOURCE_GSTACK_DIR/bin/gstack-settings-hook" -HOOK_CMD="$SOURCE_GSTACK_DIR/bin/gstack-session-update" +# On Windows (Git Bash / MSYS2 / Cygwin), extensionless scripts can't be +# launched directly by the OS — the file-association dialog appears instead. +# Prefix with 'bash' so Claude Code's hook runner invokes Git Bash explicitly. +if [ "$IS_WINDOWS" -eq 1 ]; then + HOOK_CMD="bash $SOURCE_GSTACK_DIR/bin/gstack-session-update" +else + HOOK_CMD="$SOURCE_GSTACK_DIR/bin/gstack-session-update" +fi if [ "$TEAM_MODE" -eq 1 ]; then "$GSTACK_CONFIG" set auto_upgrade true 2>/dev/null || true diff --git a/test/setup-windows-fallback.test.ts b/test/setup-windows-fallback.test.ts index cc04fbbd7..142bb7912 100644 --- a/test/setup-windows-fallback.test.ts +++ b/test/setup-windows-fallback.test.ts @@ -55,6 +55,14 @@ describe('setup: _link_or_copy invariant (D7)', () => { const fnBody = SETUP_SRC.slice(fnStart, fnEnd); expect(fnBody).toContain('_print_windows_copy_note_once'); }); + + test('SessionStart HOOK_CMD is prefixed with bash on Windows (D7-session-hook)', () => { + const hookStart = SETUP_SRC.indexOf('# 10. Team mode: register/unregister SessionStart hook'); + const hookEnd = SETUP_SRC.indexOf('\nif [ "$TEAM_MODE" -eq 1 ]', hookStart); + const hookSection = SETUP_SRC.slice(hookStart, hookEnd); + expect(hookSection).toContain('IS_WINDOWS'); + expect(hookSection).toContain('bash $SOURCE_GSTACK_DIR/bin/gstack-session-update'); + }); }); // Behavior matrix uses Unix `ln -snf` semantics in the IS_WINDOWS=0 cells.