fix: cross-platform Node wrapper for ssh-manager CLI (#22)#23
Open
fix: cross-platform Node wrapper for ssh-manager CLI (#22)#23
Conversation
The ssh-manager bin entry used to point directly at a Bash script, which npm cannot wrap on native Windows shells — the generated .ps1/.cmd shim tries to invoke /bin/bash.exe, and even when a bash is available, Windows paths are not translated into POSIX form so the script cannot be found. Replace the bin entry with a small Node wrapper that: - On Unix, simply forwards argv to the existing Bash script via `bash`. - On Windows, probes for Git Bash (Program Files / LocalAppData), then WSL, then `bash` on PATH. Windows paths are converted to MSYS (/c/...) or WSL (/mnt/c/...) form as appropriate before invocation. - Prints an actionable message pointing at Git for Windows or WSL when no compatible Bash interpreter can be located. The underlying Bash CLI is untouched, so there is no regression for existing Unix users. Closes #22.
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #22 — on native Windows shells (PowerShell, cmd) the
ssh-managerCLI failed immediately after a global install because npm cannot wrap a Bash-shebang script properly: the generated.ps1/.cmdshim tried to run/bin/bash.exe, and even when a bash was on PATH, Windows paths (C:\...) were not translated into POSIX form so the script could not be located.This PR replaces the
ssh-managerbin entry with a small cross-platform Node wrapper that delegates to the existing Bash CLI. No Bash code was touched — the 2500-line CLI keeps running unchanged on Unix.What the wrapper does
cli/ssh-managerviabash(zero behavior change).%ProgramFiles%\Git\bin\bash.exe,%ProgramFiles(x86)%,%LOCALAPPDATA%\Programs\Git\bin\bash.exe, and two hard-coded defaults. Paths are converted to MSYS form (C:\foo→/c/foo) before invocation.wsl.exe --status; script path is converted to/mnt/c/...and launched viawsl.exe bash ....bashon PATH — last resort (custom MSYS2 installs, etc.).wsl --install, and exits 1.The MCP server itself (
mcp-ssh-manager→src/index.js) is untouched and continues to work on Windows with zero dependencies on Bash.Files changed
cli/ssh-manager.js(new) — Node wrapper, ESM, no external deps.package.json—bin.ssh-managernow points atcli/ssh-manager.jsinstead ofcli/ssh-manager.How to test
Unix (should behave exactly as before)
Windows (PowerShell / cmd)
Expected:
wsl.exe bash.Test plan
node --check cli/ssh-manager.jspasses./scripts/validate.shpassesnode cli/ssh-manager.js --versionon macOS forwards correctly to the Bash scriptnode cli/ssh-manager.js --helpon macOS forwards correctly (colors, subcommand list preserved)The last three items require a Windows machine — @Eleef opened the original issue and offered to help test, so I'd like to ask them to confirm on their setup before we merge.
Closes #22