Skip to content

fix: Windows compatibility#15

Open
xobosox wants to merge 2 commits intoseverity1:mainfrom
xobosox:fix/windows-compatibility
Open

fix: Windows compatibility#15
xobosox wants to merge 2 commits intoseverity1:mainfrom
xobosox:fix/windows-compatibility

Conversation

@xobosox
Copy link

@xobosox xobosox commented Jan 14, 2026

  • Change hook command from python3 to py -3 (Python Launcher for Windows)
  • Add quotes around path for paths with spaces
  • Add -u flag for unbuffered output
  • Add timeout of 10 seconds
  • Add Windows stdin UTF-8 encoding handling
  • Add flush=True to output for proper buffering
  • Update README with Windows requirements and instructions

Windows doesn't have python3 command - it uses 'python' or 'py -3' (Python Launcher). The App Execution Alias for 'python' redirects to Microsoft Store, so 'py -3' is the most reliable cross-platform approach for Windows.

- Change hook command from python3 to py -3 (Python Launcher for Windows)
- Add quotes around path for paths with spaces
- Add -u flag for unbuffered output
- Add timeout of 10 seconds
- Add Windows stdin UTF-8 encoding handling
- Add flush=True to output for proper buffering
- Update README with Windows requirements and instructions

Windows doesn't have python3 command - it uses 'python' or 'py -3' (Python
Launcher). The App Execution Alias for 'python' redirects to Microsoft Store,
so 'py -3' is the most reliable cross-platform approach for Windows.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Owner

@severity1 severity1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the Windows compatibility work! The Python script changes (UTF-8 stdin handling, flush=True, better error handling) are great and backwards-compatible.

However, the hooks/hooks.json change from python3 to py -3 will break the plugin for Linux/macOS users since py (Python Launcher) is Windows-only.

Suggested approach: bash wrapper script

Instead of changing the Python interpreter directly, consider adding a cross-platform bash wrapper:

1. Create scripts/run-hook.sh:

#!/bin/bash
# Cross-platform wrapper to invoke Python with the correct interpreter
# - Linux/macOS: uses python3
# - Windows (Git Bash/MSYS/Cygwin): uses py -3

SCRIPT_DIR="$(dirname "$0")"
HOOK_SCRIPT="$SCRIPT_DIR/improve-prompt.py"

if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OS" == "Windows_NT" ]]; then
    py -3 -u "$HOOK_SCRIPT"
else
    python3 -u "$HOOK_SCRIPT"
fi

2. Update hooks/hooks.json:

{
  "type": "command",
  "command": "bash \"${CLAUDE_PLUGIN_ROOT}/scripts/run-hook.sh\"",
  "timeout": 10,
  "description": "Run the prompt improvement script"
}

This approach:

  • Works on Linux/macOS natively
  • Works on Windows with Git Bash (common for developers)
  • Keeps a single configuration file
  • Preserves your timeout and buffering improvements

The README updates documenting Windows requirements are helpful and can stay as-is.

Thanks for the excellent suggestion! Updated to use a bash wrapper script
that detects the OS and uses the appropriate Python command:
- Linux/macOS: python3
- Windows (Git Bash/MSYS/Cygwin): py -3

This preserves compatibility with all platforms while keeping the timeout
and buffering improvements.

Changes:
- Add scripts/run-hook.sh: cross-platform wrapper script
- Update hooks/hooks.json: use bash wrapper instead of direct py -3

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@xobosox
Copy link
Author

xobosox commented Jan 14, 2026

Thanks for the excellent suggestion! I've updated the code to use a bash wrapper script that detects the OS and uses the appropriate Python command (python3 on Linux/macOS, py -3 on Windows with Git Bash). This preserves cross-platform compatibility while keeping the timeout and buffering improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants