mcp-ssh-manager 4.0.0 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitattributes CHANGED
@@ -1,5 +1,5 @@
1
- # The committed browser build must reproduce on Windows as well as Unix.
2
- # Mixed CRLF input and LF Vite injections otherwise change index.html.
1
+ # The interface sources are checked out with LF on Windows too: the build must
2
+ # reproduce byte for byte on every system (mixed CRLF input and LF injections
3
+ # from Vite would otherwise change index.html).
3
4
  ui/** text=auto eol=lf
4
- dist/ui/** text=auto eol=lf
5
5
  *.woff2 -text
package/CHANGELOG.md CHANGED
@@ -5,6 +5,115 @@ All notable changes to MCP SSH Manager will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ## [4.0.2] - 2026-11-01
11
+
12
+ **Commands reach a Mac, and the desktop terminal behaves like your own.**
13
+ A patch release: no setting, file or default changes for anyone upgrading
14
+ (the release pipeline upgrades 3.8.5, 3.8.6, 3.8.7, 4.0.0 and 4.0.1 from the
15
+ registry to this version and back). The desktop app updates itself from 4.0.x.
16
+
17
+ The Windows installer is **not Authenticode-signed** in this release either,
18
+ for the same reason as 4.0.0 (the public certificate waits on the company's
19
+ registration): Windows shows *"Windows protected your PC"*, *More info → Run
20
+ anyway*, and `ssh-manager app` checks the installer against the SHA-256 in
21
+ `release-manifest-win32.json`. macOS builds are signed and notarized.
22
+
23
+ ### Fixed
24
+
25
+ - **Commands sent to a macOS server no longer fail before they start** (#115,
26
+ thanks to Henrik Tilly, @htilly). Every bounded command (`ssh_execute` and the
27
+ tools built on it) was wrapped in `timeout`, which a stock Mac does not have:
28
+ it failed with exit 127, `timeout: command not found`, whatever the command
29
+ was. The wrapper now finds `timeout` or Homebrew's `gtimeout` on the server
30
+ and, with neither, runs the command without it (the client-side limit still
31
+ applies). It works under any login shell, csh and tcsh included; Linux
32
+ servers still use their own `timeout`, with the same exit codes.
33
+ - **The desktop app's terminal starts a login shell.** Opened from the Dock or
34
+ Finder, the app only has macOS's bare `PATH`, and the terminal read none of the
35
+ profile files (`~/.zprofile`, `~/.bash_profile`) where Homebrew and most
36
+ installers add theirs: `brew`, `node` or any tool installed outside `/usr/bin`
37
+ answered "command not found" there while working in Terminal.app or Warp. The
38
+ shell is now started with `-l` on macOS and Linux.
39
+ - **The terminal keeps your keystrokes in order.** Each key went to the shell
40
+ on its own request, several at once, and the control plane wrote them as
41
+ they arrived: typed fast, or on a busy machine, `mo --help` could reach the
42
+ shell as `mo- elh-p`, a different command from the one on screen. Keystrokes
43
+ now leave one request at a time, in order, in every terminal (local and
44
+ remote, in the app and in `ssh-manager control`).
45
+
46
+ ### Changed
47
+
48
+ - **The desktop app's terminal on Windows is PowerShell.** It opened `cmd.exe`
49
+ (what `COMSPEC` names on every Windows machine), the old Command Prompt.
50
+ It now starts Windows PowerShell (`powershell.exe`, present on Windows 10 and
51
+ 11), the shell Windows Terminal opens by default. `cmd.exe` is still one
52
+ `cmd` away inside it.
53
+ - **Dependencies.** MCP SDK 1.32.2; dotenv 18, loaded quietly so it adds no line
54
+ to the log; `@hono/node-server` 2.1.5 (GHSA-rmxm-3fg6-px4f, in a part of the
55
+ SDK this stdio server never loads); CI actions and development tools.
56
+
57
+ ## [4.0.1] - 2026-10-26
58
+
59
+ **The application tells you about updates, and nothing changes in the engine.**
60
+ Everything below is in the interface, the packaging and the metadata: the MCP
61
+ engine behaves exactly as in 4.0.0 (the release pipeline upgrades 3.8.5, 3.8.6,
62
+ 3.8.7 and 4.0.0 from the registry to this version and back). The desktop app
63
+ updates itself from 4.0.0 and from the 4.0.0 betas.
64
+
65
+ The Windows installer is **not Authenticode-signed** in this release either,
66
+ for the same reason as 4.0.0 (the public certificate waits on the company's
67
+ registration): Windows shows *"Windows protected your PC"*, *More info → Run
68
+ anyway*, and `ssh-manager app` checks the installer against the SHA-256 in
69
+ `release-manifest-win32.json`. macOS builds are signed and notarized.
70
+
71
+ ### The application shows its updates
72
+
73
+ - **Options → Updates** (desktop application only): the version running and its
74
+ channel (a preview build is offered newer previews and the stable release), the
75
+ version on offer, *Check now*, *Download*, download progress, *Restart to
76
+ update*, the time of the last check, a link to the release notes, and the reason
77
+ when a check fails. If commands are waiting for your decision when you restart,
78
+ it says they will be refused.
79
+ - **The sidebar says so too**: an *Update available* (or *Restart to update*)
80
+ mark above Options, and a dot on the Options icon when the rail is collapsed.
81
+ A native notification is posted once per version, not at every launch.
82
+ - *Help → Check for Updates…*, and the menu-bar entry, are kept; the window and
83
+ the menu show the same state.
84
+ - A browser tab (`ssh-manager control`) and the npm engine see none of it: the
85
+ endpoints do not exist there, and nothing about updates is drawn.
86
+
87
+ ### Fixes
88
+
89
+ - **Servers**: the grid/list switch sits beside the search field instead of
90
+ wrapping onto a line of its own below the group filters, which left a band of
91
+ empty space when there were many groups.
92
+ - The primary button's hover state no longer drops white-on-orange text below
93
+ the 4.5:1 AA contrast (it now moves toward the page's text colour).
94
+
95
+ ### Easier to find
96
+
97
+ - The npm description and keywords, the MCP registry description and the GitHub
98
+ About box say what V4 is now (SSH for AI agents, with approval, a vault and an
99
+ audit trail) instead of the v3 pitch; the repository topics lose the ones that
100
+ had nothing to do with this project.
101
+ - The README opens by saying it is an MCP server for SSH and ends with the
102
+ questions people ask (is it safe, which clients, do I need Node, how is it
103
+ different).
104
+ - A code of conduct, issue forms and a pull request template (the project
105
+ already pointed to a code of conduct that did not exist).
106
+
107
+ ### The interface is built when the package is made, not committed
108
+
109
+ `dist/ui` (the bundled control plane interface) is no longer in git. `prepack`
110
+ builds it into the npm package and the desktop app builds it when it is
111
+ assembled, so what users install is the same: the package and the app carry the
112
+ built interface and nothing compiles on their machine. In a source checkout, run
113
+ `npm run build:ui` once before `ssh-manager control`. CI builds it on three
114
+ systems and fails if anything generated is tracked; `release.yml` refuses a
115
+ tarball that does not carry it.
116
+
8
117
  ## [4.0.0] - 2026-10-25
9
118
 
10
119
  **V4 is stable, on npm and as a desktop application** — [release](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.0).
package/CLAUDE.md CHANGED
@@ -73,6 +73,8 @@ npm ci # Install the exact tree from pack
73
73
  npm start # Start MCP server (requires stdin)
74
74
  npm test # Run the full test suite
75
75
  npm run typecheck # Type-check JSDoc with tsc (no build, nothing emitted)
76
+ npm run build:ui # Build the interface (ui/) into dist/ui: generated, git-ignored, run by `prepack`;
77
+ # needed before `ssh-manager control` from a checkout and before the browser tests
76
78
  npm run test:all # Tests + typecheck + validation
77
79
  ./scripts/validate.sh # Run all validation checks
78
80
  node --check src/index.js # Check JavaScript syntax
@@ -81,6 +83,8 @@ python -m py_compile tools/*.py # Check Python syntax
81
83
 
82
84
  **Typecheck**: `tsconfig.json` runs TypeScript in `checkJs`/`noEmit` mode over the plain JS —
83
85
  this project ships JavaScript straight from `src/` with no build step, and that must stay true.
86
+ The interface is the one generated thing: `dist/ui` is built from `ui/` when the package is packed and when the desktop
87
+ app is assembled, never committed (`scripts/build-interface.mjs`; CI fails if `dist/` is tracked).
84
88
  The baseline is 0 errors and CI enforces it, so add JSDoc annotations (or a narrow
85
89
  `/** @type {...} */` cast) rather than leaving new errors. `typescript` is pinned to `^6`
86
90
  because knip 5 declares `peer typescript ">=5.0.4 <7"` — bumping one requires bumping the other.
@@ -0,0 +1,18 @@
1
+ # Code of Conduct
2
+
3
+ This project is for people who run commands on real servers and want to do it
4
+ safely. Taking part in it, in issues, discussions and pull requests, means:
5
+
6
+ - **Be kind and assume good faith.** Disagree with the code, the design or the
7
+ decision, never with the person.
8
+ - **Stay on topic and be concrete.** A reproducible report and a clear request
9
+ help everyone; so does saying what you tried.
10
+ - **No harassment, discrimination, personal attacks or unwelcome advances**, and
11
+ no publishing other people's private information.
12
+ - **Keep secrets out of public places.** Never paste passwords, keys or tokens,
13
+ and do not post the details of a vulnerability in a public issue: use the
14
+ private channel described in [SECURITY.md](SECURITY.md).
15
+
16
+ The maintainer may edit or remove comments, lock threads and block people who do
17
+ not follow this. To report a problem with someone's behaviour, write to the
18
+ contacts listed in [SECURITY.md](SECURITY.md); reports are treated privately.
package/CONTRIBUTING.md CHANGED
@@ -70,6 +70,10 @@ Enhancement suggestions are tracked as GitHub issues. When creating an enhanceme
70
70
 
71
71
  4. Make your changes and test them
72
72
 
73
+ The interface (`ui/`) is built, not committed: `npm run build:ui` builds it
74
+ into the git-ignored `dist/ui`, which `ssh-manager control` serves from a
75
+ checkout. Changing `ui/` needs no build artifact in your pull request.
76
+
73
77
  5. Commit your changes:
74
78
  ```bash
75
79
  git add .
@@ -116,6 +120,32 @@ Before submitting a pull request:
116
120
  CI installs with `npm ci` on Node 18, 20 and 22, and the `lint` job runs
117
121
  ESLint and the JSDoc typecheck as blocking gates.
118
122
 
123
+ ### Tests come with the change
124
+
125
+ New functionality and every bug fix arrive with automated tests, in the same
126
+ pull request: a test that fails without the change and passes with it. This is
127
+ the project's policy for any major new functionality, and reviewers ask for the
128
+ test before the code. Where the test is:
129
+
130
+ - `tests/test-*.js` for the engine (run by `npm test`; each file is also a
131
+ script of its own, `npm run test:<name>`),
132
+ - `ui/tests/*.spec.ts` for the interface (Playwright, `npm --prefix ui run
133
+ test:e2e`),
134
+ - `tests/test-shell-quote-properties.js` shows the property-based style
135
+ (`fast-check`) used where a bug class matters more than one example: anything
136
+ that builds a command for a remote shell must go through `shellQuote()` and be
137
+ covered by it.
138
+
139
+ Security fixes also add the exact input that broke the code as a regression
140
+ test (see `tests/test-backup-monitor-injection.js` for the pattern).
141
+
142
+ ### Static analysis and warnings
143
+
144
+ ESLint, the JSDoc typecheck (`npm run typecheck`, zero errors) and CodeQL run on
145
+ every push and pull request, and OpenSSF Scorecard runs on `main`. Findings are
146
+ fixed rather than ignored; an alert that is a false positive is dismissed on
147
+ GitHub with a written reason.
148
+
119
149
  ## Documentation
120
150
 
121
151
  - Update README.md if you change functionality
@@ -13,8 +13,8 @@
13
13
  class SshManager < Formula
14
14
  desc "SSH server management for AI agents, with approval and audit"
15
15
  homepage "https://github.com/bvisible/mcp-ssh-manager"
16
- url "https://registry.npmjs.org/mcp-ssh-manager/-/mcp-ssh-manager-3.8.5.tgz"
17
- sha256 "494293e55b071a1d908b8af037a3a77094d6bb20dbe3ad25c2671ace8234b038"
16
+ url "https://registry.npmjs.org/mcp-ssh-manager/-/mcp-ssh-manager-4.0.1.tgz"
17
+ sha256 "c931cb956869345975c59f953329be71eb75c893b8810dbe6121f26ccedc1880"
18
18
  license "MIT"
19
19
 
20
20
  depends_on "node"
package/README.md CHANGED
@@ -12,19 +12,21 @@
12
12
  <h1 align="center">You give your agents a shell,<br>and you see what they do with it.</h1>
13
13
 
14
14
  <p align="center">
15
- Let <b>Claude Code</b> and <b>OpenAI Codex</b> work on your real servers — run commands, move files,<br>
16
- query databases, take backups, check health — and watch over their shoulder while they do it.
15
+ <b>An MCP server for SSH.</b> Let <b>Claude Code</b>, <b>Claude Desktop</b> and <b>OpenAI Codex</b> (or any MCP client)<br>
16
+ work on your real servers — run commands, move files, query databases, take backups, check health —<br>
17
+ and watch over their shoulder while they do it.
17
18
  </p>
18
19
 
19
20
  <div align="center">
20
21
 
21
22
  [![npm version](https://img.shields.io/npm/v/mcp-ssh-manager.svg?style=flat-square&logo=npm&color=c04500)](https://www.npmjs.com/package/mcp-ssh-manager)
22
23
  [![npm downloads](https://img.shields.io/npm/dm/mcp-ssh-manager.svg?style=flat-square&logo=npm&color=c04500)](https://www.npmjs.com/package/mcp-ssh-manager)
23
- [![Version](https://img.shields.io/badge/release-4.0.0-c04500?style=flat-square)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.0)
24
+ [![Version](https://img.shields.io/badge/release-4.0.2-c04500?style=flat-square)](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.2)
24
25
  [![Claude Code](https://img.shields.io/badge/Claude_Code-Compatible-5A67D8?style=flat-square&logo=anthropic)](https://claude.ai/code)
25
26
  [![OpenAI Codex](https://img.shields.io/badge/OpenAI_Codex-Compatible-00A67E?style=flat-square&logo=openai)](https://openai.com/codex)
26
27
  [![MCP](https://img.shields.io/badge/MCP-Server-orange?style=flat-square)](https://modelcontextprotocol.io)
27
28
  [![OpenSSF Scorecard](https://img.shields.io/ossf-scorecard/github.com/bvisible/mcp-ssh-manager?style=flat-square&label=OpenSSF)](https://scorecard.dev/viewer/?uri=github.com/bvisible/mcp-ssh-manager)
29
+ [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/15950/badge)](https://www.bestpractices.dev/projects/15950)
28
30
  [![License](https://img.shields.io/badge/License-MIT-blue?style=flat-square)](LICENSE)
29
31
 
30
32
  </div>
@@ -52,17 +54,17 @@ An MCP SSH server is the most dangerous tool you can hand an agent: a shell on m
52
54
 
53
55
  ## Choose your workspace
54
56
 
55
- **Desktop application (`4.0.0`):** one installation with its own runtime,
57
+ **Desktop application (`4.0.2`):** one installation with its own runtime,
56
58
  terminal, file browser and server settings. No separate Node.js or npm
57
- installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.0):
59
+ installation. [Download it](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.2):
58
60
 
59
61
  | Platform | File | Signature |
60
62
  |---|---|---|
61
63
  | macOS, Apple silicon / Intel | `…-arm64.dmg` / `…-x64.dmg` | **Signed and notarized by Apple** — opens normally |
62
- | Windows x64 / arm64 | `…-setup.exe` | **Not code-signed in 4.0.0.** Windows shows *"Windows protected your PC"*: *More info → Run anyway*. Check the file against the SHA-256 in `release-manifest-win32.json` on the release (`ssh-manager app` does it for you). Signing comes in a later release. |
64
+ | Windows x64 / arm64 | `…-setup.exe` | **Not code-signed in 4.0.x.** Windows shows *"Windows protected your PC"*: *More info → Run anyway*. Check the file against the SHA-256 in `release-manifest-win32.json` on the release (`ssh-manager app` does it for you). Signing comes in a later release. |
63
65
  | Linux x64 | `.deb`, `.AppImage` | Unsigned, as Linux packages usually are |
64
66
 
65
- **Already using npm / the CLI?** `npm update -g mcp-ssh-manager` brings 4.0.0,
67
+ **Already using npm / the CLI?** `npm update -g mcp-ssh-manager` brings 4.0.2,
66
68
  and the V4 engine runs without an interface, from your existing `.env`, TOML or
67
69
  process variables — no automatic import, no forced wizard, no approval prompt
68
70
  unless you enable one per server. The one behaviour that tightens is **SSH
@@ -88,7 +90,10 @@ variables, and takes effect when the tool next starts; switching back is the
88
90
  same click.
89
91
 
90
92
  **Updates.** The application checks for a new version at launch and every six
91
- hours, downloads it when you click *Update* and installs it when it quits. The
93
+ hours and says so where you will see it: a mark on the sidebar, *Options →
94
+ Updates* (the running version, the one on offer, a *Check now* button, release
95
+ notes) and, once per version, a notification. Downloading is a click, and
96
+ installing is a second one (*Restart to update*) or happens when you quit. The
92
97
  npm engine updates with npm, on its own schedule. A change to the interface
93
98
  reaches npm users with the next npm release and application users with the next
94
99
  application release.
@@ -140,6 +145,10 @@ cd cli && ./install.sh
140
145
  claude mcp add ssh-manager node /absolute/path/to/mcp-ssh-manager/src/index.js
141
146
  ```
142
147
 
148
+ The MCP engine needs no build. To use the interface (`ssh-manager control`) from a
149
+ checkout, build it once: `npm run build:ui` (the published package and the desktop
150
+ app already carry it).
151
+
143
152
  **Scopes** — `--scope project` writes an `.mcp.json` your team can commit; `--scope user` enables it everywhere for you.
144
153
 
145
154
  **Prerequisites** — Node 18+, on Linux, macOS or Windows. `rsync` for `ssh_sync`, `sshpass` only if you sync with password auth (`brew install hudochenkov/sshpass/sshpass`, or `apt-get install sshpass`).
@@ -317,6 +326,35 @@ AES-256-GCM, master key in your OS keychain (a `0600` file where there is none
317
326
 
318
327
  ---
319
328
 
329
+ ## Questions people ask
330
+
331
+ **Can I let an AI agent SSH into my servers safely?**
332
+ Yes, if you decide how far it can go. Per server you can make it read-only, allow only commands that match a pattern, or hold every request (or only the destructive ones) until you approve it in the control plane; credentials can live in an encrypted vault instead of a clear-text `.env`; and every command and decision is logged. See [Safe by default](#safe-by-default).
333
+
334
+ **How do I use Claude Code or Codex with SSH?**
335
+ `npm install -g mcp-ssh-manager`, add a server with `ssh-manager server add`, then `claude mcp add ssh-manager mcp-ssh-manager`. Codex is [set up here](#up-and-running-with-npm). Then ask in plain words: *"why is production slow?"*, *"tail the nginx error log on staging"*.
336
+
337
+ **Does it work with Cursor, Windsurf, Cline or another MCP client?**
338
+ It is a standard stdio MCP server, so any MCP client can run it. Claude Code, Claude Desktop and Codex are the clients documented and tested here. For another one, add what it expects, for example:
339
+
340
+ ```json
341
+ { "mcpServers": { "ssh-manager": { "command": "npx", "args": ["-y", "mcp-ssh-manager"] } } }
342
+ ```
343
+
344
+ **Do I need Node.js?**
345
+ With npm, yes (Node 18 or later). The desktop application carries its own runtime and engine: install it and connect your AI tools from *Options → AI tools*, with no Node and no npm.
346
+
347
+ **How is this different from other SSH MCP servers?**
348
+ Most hand the agent a shell. This one lets you choose per server how far it goes, can hold requests until you approve them, keeps an audit trail, and has a desktop app and a browser interface to see it all. It also runs without any of that, as a plain engine configured from a `.env` or a TOML file, if that is what you want.
349
+
350
+ **Where are my passwords and keys kept?**
351
+ Key files stay where they are. Saved passwords and passphrases can go into the encrypted vault (AES-256-GCM, with the key in your operating system's keychain) rather than a `.env`.
352
+
353
+ **Is it free?**
354
+ Yes, it is MIT-licensed. The source is here, the package is on [npm](https://www.npmjs.com/package/mcp-ssh-manager) and the desktop apps are on the [releases page](https://github.com/bvisible/mcp-ssh-manager/releases).
355
+
356
+ ---
357
+
320
358
  ## Reference
321
359
 
322
360
  <details>
@@ -647,6 +685,10 @@ The hero animation ships twice, light and dark, swapped by `<picture>` on `prefe
647
685
 
648
686
  ## What's new
649
687
 
688
+ **[4.0.2](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.2) — commands reach a Mac, and the desktop terminal is your own.** Commands sent to a macOS server no longer fail with `timeout: command not found` before they start (thanks to Henrik Tilly, [#115](https://github.com/bvisible/mcp-ssh-manager/pull/115)); the desktop terminal starts a login shell, so what Homebrew installed is found as in Terminal or Warp, and PowerShell on Windows; keystrokes reach the shell in the order they were typed; dependencies refreshed. Nothing to change on upgrade.
689
+
690
+ **[4.0.1](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.1) — the application tells you about updates.** *Options → Updates*, a mark on the sidebar and a notification once per version, so a new release no longer goes unnoticed in a menu you never open; a tidier Servers toolbar; the interface is built when the package is made rather than committed (what you install is byte for byte the same); and the npm, registry and GitHub descriptions say what V4 is. No change to the engine's behaviour.
691
+
650
692
  **[4.0.0](https://github.com/bvisible/mcp-ssh-manager/releases/tag/v4.0.0) — the control plane.** See what an agent is running on your servers, with its output, and stop it before it runs. A desktop application for macOS, Windows and Linux, installed from the engine with `ssh-manager app`; an encrypted vault for credentials; human approval per server; a shell on your own machine alongside the remote ones. Everything new is opt-in — an npm install upgraded from 3.8.x keeps behaving as 3.8.x, which [a test installs from the registry and proves](docs/TESTING-V4.md). The Windows application is not code-signed in this release. [What changes and how to go back](docs/MIGRATION.md).
651
693
 
652
694
  **v3.8.7 — a security release; upgrade.** Two advisories fixed: a partial server name or an alias escaped `readonly` and `restricted` mode ([GHSA-mq9f-5385-rjf4](https://github.com/bvisible/mcp-ssh-manager/security/advisories/GHSA-mq9f-5385-rjf4)), and `ssh_backup_restore`'s `backupId` ran commands on the server ([GHSA-2wjh-xm9c-7qf9](https://github.com/bvisible/mcp-ssh-manager/security/advisories/GHSA-2wjh-xm9c-7qf9)). See the [CHANGELOG](CHANGELOG.md#387---2026-10-25).
package/brand/README.md CHANGED
@@ -5,6 +5,7 @@
5
5
  | `wordmark.svg` | The logo: **ssh** solid, **manager** outlined. Supplied, not derived. |
6
6
  | `icon.svg` | The app icon — the mark on its tile. Everything else is generated from this. |
7
7
  | `mark.svg` | The mark alone, no tile, `currentColor` for the white parts. |
8
+ | `social-preview.html` | The GitHub social preview (1280×640), rendered to `docs/images/social-preview.png` and `@2x` by `npm run brand:social`. The window in it is the README's own capture of the real application (`docs/images/v4-waiting-app.png`, made by the screenshot rig), so the image follows the interface when the rig is re-run. |
8
9
 
9
10
  ## The icon
10
11
 
@@ -11,6 +11,7 @@ directories:
11
11
  # bindings at runtime and those cannot be read from inside an archive.
12
12
  files:
13
13
  - main.js
14
+ - local-shell.mjs
14
15
  - smoke-test.mjs
15
16
  - package.json
16
17
  # The menu-bar glyph is loaded at runtime from __dirname/resources, so it has
@@ -0,0 +1,41 @@
1
+ import path from 'node:path';
2
+
3
+ /**
4
+ * What the desktop application starts for "a terminal on this machine": the
5
+ * file, its arguments and its environment. Kept apart from main.js so a plain
6
+ * Node test can run it (main.js needs Electron).
7
+ *
8
+ * It is the user's own shell, started as a *login* shell on macOS and Linux.
9
+ * An application opened from the Dock or Finder gets launchd's bare PATH
10
+ * (/usr/bin:/bin:/usr/sbin:/sbin), and the directories Homebrew and most
11
+ * installers add live in ~/.zprofile or ~/.bash_profile, which only a login
12
+ * shell reads. Without `-l`, `brew`, `node` or any tool installed outside
13
+ * /usr/bin was "command not found" here and fine in Terminal.app or Warp,
14
+ * which both start login shells.
15
+ *
16
+ * On Windows it is PowerShell, the shell Windows Terminal opens by default and
17
+ * the one people use there today. COMSPEC is not consulted: it names cmd.exe on
18
+ * every Windows machine, so it says nothing about what the user chose. Windows
19
+ * PowerShell (powershell.exe) ships with Windows 10 and 11, unlike PowerShell 7.
20
+ * It has no `-l`; it reads its own profile.
21
+ *
22
+ * @param {{ platform?: string, env?: Record<string, string|undefined> }} [options]
23
+ * @returns {{ file: string, args: string[], env: Record<string, string|undefined> }}
24
+ */
25
+ export function localShellLaunch({ platform = process.platform, env = process.env } = {}) {
26
+ const file = platform === 'win32'
27
+ ? 'powershell.exe'
28
+ : env.SHELL || (platform === 'darwin' ? '/bin/zsh' : '/bin/bash');
29
+
30
+ const childEnv = { ...env, TERM: 'xterm-256color' };
31
+ // Electron sets this when it runs as a plain Node process; inherited by a
32
+ // shell it makes every `electron` the user runs behave as node instead.
33
+ delete childEnv.ELECTRON_RUN_AS_NODE;
34
+
35
+ return { file, args: platform === 'win32' ? [] : ['-l'], env: childEnv };
36
+ }
37
+
38
+ /** The name the interface shows for the shell (`zsh`, `cmd.exe`). */
39
+ export function localShellName(file, platform = process.platform) {
40
+ return (platform === 'win32' ? path.win32 : path.posix).basename(file);
41
+ }
@@ -29,6 +29,7 @@ import { createRequire } from 'module';
29
29
  // electron-updater is CommonJS: named imports do not resolve through the bridge.
30
30
  import electronUpdater from 'electron-updater';
31
31
  import { fileURLToPath, pathToFileURL } from 'url';
32
+ import { localShellLaunch, localShellName } from './local-shell.mjs';
32
33
 
33
34
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
34
35
 
@@ -108,17 +109,12 @@ function localShellProvider() {
108
109
 
109
110
  return async ({ cols, rows, cwd }) => {
110
111
  // The user's own login shell, because that is what "a terminal on this
111
- // machine" means to them — their aliases, their prompt, their PATH.
112
- const shellPath = process.platform === 'win32'
113
- ? process.env.COMSPEC || 'powershell.exe'
114
- : process.env.SHELL || (process.platform === 'darwin' ? '/bin/zsh' : '/bin/bash');
112
+ // machine" means to them — their aliases, their prompt, their PATH. A
113
+ // login shell: opened from the Dock this process has launchd's bare PATH,
114
+ // and only a login shell reads the profile that adds Homebrew's.
115
+ const { file, args, env } = localShellLaunch();
115
116
 
116
- const env = { ...process.env, TERM: 'xterm-256color' };
117
- // Electron sets this when it runs as a plain Node process; inherited by a
118
- // shell it makes every `electron` the user runs behave as node instead.
119
- delete env.ELECTRON_RUN_AS_NODE;
120
-
121
- const term = pty.spawn(shellPath, [], {
117
+ const term = pty.spawn(file, args, {
122
118
  name: 'xterm-256color',
123
119
  cols,
124
120
  rows,
@@ -127,7 +123,7 @@ function localShellProvider() {
127
123
  });
128
124
 
129
125
  return {
130
- shell: path.basename(shellPath),
126
+ shell: localShellName(file),
131
127
  onData: handler => term.onData(handler),
132
128
  onExit: handler => term.onExit(() => handler()),
133
129
  // node-pty writes strings. What arrives is the UTF-8 of exactly what the
@@ -168,8 +164,46 @@ let tray = null;
168
164
  let trayState = '';
169
165
  /** Requests already announced, so a queue that stays full is not announced twice. */
170
166
  const announced = new Set();
171
- /** What the updater is doing, for the menu bar to show. */
172
- let update = { status: 'idle', version: null, percent: 0 };
167
+ /**
168
+ * What the updater is doing. Shown in the menu bar, and handed to the control
169
+ * plane so the window can show it too (Options → Updates, the sidebar), because
170
+ * an update that is only visible in a menu most people never open is not an
171
+ * update anyone ever installs.
172
+ * @type {{status: 'idle'|'checking'|'available'|'downloading'|'ready'|'error', version: string|null, percent: number, checkedAt: string|null, error: string|null}}
173
+ */
174
+ let update = { status: 'idle', version: null, percent: 0, checkedAt: null, error: null };
175
+ /** Whether the updater was started: a packaged build, and not a candidate preview. */
176
+ let updaterActive = false;
177
+ /** Who is told when `update` changes: the control plane, which tells the window. */
178
+ const updateListeners = new Set();
179
+
180
+ function updateSnapshot() {
181
+ return {
182
+ currentVersion: app.getVersion(),
183
+ status: update.status,
184
+ ...(update.version ? { version: update.version } : {}),
185
+ ...(update.status === 'downloading' || update.status === 'ready' ? { percent: update.percent } : {}),
186
+ ...(update.checkedAt ? { checkedAt: update.checkedAt } : {}),
187
+ ...(update.error ? { error: update.error } : {}),
188
+ // A preview build is offered newer previews as well as the stable release.
189
+ channel: app.getVersion().includes('-') ? 'preview' : 'stable',
190
+ };
191
+ }
192
+
193
+ /** What the control plane offers the window: see AppUpdates in control-plane.js. */
194
+ const appUpdates = {
195
+ snapshot: updateSnapshot,
196
+ check: async () => {
197
+ if (!updaterActive) throw new Error('Updates are turned off in this build');
198
+ await electronUpdater.autoUpdater.checkForUpdates();
199
+ },
200
+ download: async () => { await electronUpdater.autoUpdater.downloadUpdate(); },
201
+ install: () => electronUpdater.autoUpdater.quitAndInstall(),
202
+ subscribe: listener => {
203
+ updateListeners.add(listener);
204
+ return () => updateListeners.delete(listener);
205
+ },
206
+ };
173
207
 
174
208
  async function startControlPlane() {
175
209
  const root = engineRoot();
@@ -183,6 +217,9 @@ async function startControlPlane() {
183
217
  // tree; the control plane resolves it relative to its own file, so nothing
184
218
  // extra is needed here.
185
219
  agents: ownInstallation(),
220
+ // Only a packaged build has a feed and a version to compare; a checkout run
221
+ // from source has nothing to update.
222
+ appUpdates: app.isPackaged ? appUpdates : null,
186
223
  });
187
224
  plane.setLocalShellProvider(localShellProvider());
188
225
  return plane.start();
@@ -308,6 +345,10 @@ function buildMenu(url) {
308
345
  ],
309
346
  },
310
347
  { role: 'windowMenu' },
348
+ {
349
+ role: 'help',
350
+ submenu: [{ label: 'Check for Updates…', click: () => void appUpdates.check().catch(() => { /* shown in Options → Updates */ }) }],
351
+ },
311
352
  ]));
312
353
  }
313
354
 
@@ -490,9 +531,10 @@ function refreshTray() {
490
531
  * release happened, or restarting under them while a transfer is running, are
491
532
  * both worse than being a version behind for an afternoon.
492
533
  *
493
- * So: it checks, and it says so in the menu bar. Downloading is a click.
494
- * Installing happens when the application is closed anyway — never in the
495
- * middle of something.
534
+ * So: it checks, and says so — in the window (Options → Updates, and a mark on
535
+ * the sidebar), in the menu bar, and once per version in a notification.
536
+ * Downloading is a click. Installing happens when the application is closed
537
+ * anyway, or when you choose to restart — never in the middle of something.
496
538
  */
497
539
  function setupUpdater() {
498
540
  // A candidate preview must keep the artifact the operator chose to test.
@@ -503,21 +545,32 @@ function setupUpdater() {
503
545
  autoUpdater.autoDownload = false;
504
546
  autoUpdater.autoInstallOnAppQuit = true;
505
547
  autoUpdater.logger = null;
548
+ updaterActive = true;
506
549
 
507
550
  const move = (status, extra = {}) => {
508
551
  update = { ...update, status, ...extra };
509
552
  trayState = ''; // force the menu to rebuild
510
553
  refreshTray();
554
+ const snapshot = updateSnapshot();
555
+ for (const listener of updateListeners) listener(snapshot);
511
556
  };
557
+ const now = () => new Date().toISOString();
512
558
 
513
- autoUpdater.on('update-available', info => move('available', { version: info.version }));
514
- autoUpdater.on('update-not-available', () => move('idle'));
559
+ autoUpdater.on('checking-for-update', () => move('checking', { error: null }));
560
+ autoUpdater.on('update-available', info => {
561
+ move('available', { version: info.version, percent: 0, checkedAt: now(), error: null });
562
+ announceUpdate(info.version);
563
+ });
564
+ autoUpdater.on('update-not-available', () => move('idle', { version: null, checkedAt: now(), error: null }));
515
565
  autoUpdater.on('download-progress', p => move('downloading', { percent: Math.round(p.percent) }));
516
- autoUpdater.on('update-downloaded', info => move('ready', { version: info.version }));
517
- autoUpdater.on('error', () => {
518
- // A failed check is not worth telling anybody about: the network is down,
519
- // or GitHub is. It will try again.
520
- move('idle');
566
+ autoUpdater.on('update-downloaded', info => move('ready', { version: info.version, percent: 100 }));
567
+ autoUpdater.on('error', error => {
568
+ // A failed background check is not worth an alert: the network is down, or
569
+ // GitHub is, and it will try again. The reason is kept for Options → Updates,
570
+ // where someone who asked to check can read it. A failed download goes back
571
+ // to "available", so it can be tried again.
572
+ const message = String(error?.message || error).split('\n')[0].slice(0, 200);
573
+ move(update.status === 'downloading' || update.status === 'ready' ? 'available' : 'idle', { checkedAt: now(), error: message });
521
574
  });
522
575
 
523
576
  const check = () => autoUpdater.checkForUpdates().catch(() => { /* see above */ });
@@ -526,10 +579,45 @@ function setupUpdater() {
526
579
  timer.unref();
527
580
  }
528
581
 
582
+ /**
583
+ * Say, once per version, that an update is on offer.
584
+ *
585
+ * The version is remembered on disk: a notification at every launch for an
586
+ * update somebody has already decided to leave for later is nagging, and
587
+ * the sidebar and the menu bar keep showing it anyway.
588
+ *
589
+ * @param {string} version
590
+ */
591
+ function announceUpdate(version) {
592
+ const marker = path.join(app.getPath('userData'), 'last-update-notice');
593
+ try {
594
+ if (fs.readFileSync(marker, 'utf8').trim() === version) return;
595
+ } catch { /* nothing recorded yet */ }
596
+ try { fs.writeFileSync(marker, `${version}\n`); } catch { /* it will say it again next time; harmless */ }
597
+ if (!Notification.isSupported()) return;
598
+ const notification = new Notification({
599
+ title: `SSH Manager ${version} is available`,
600
+ body: 'Open Options → Updates to download it. Nothing is installed until you restart.',
601
+ silent: true,
602
+ });
603
+ notification.on('click', () => {
604
+ if (mainWindow) {
605
+ if (mainWindow.isMinimized()) mainWindow.restore();
606
+ mainWindow.show();
607
+ mainWindow.focus();
608
+ } else if (plane) {
609
+ createWindow(plane.url);
610
+ }
611
+ });
612
+ notification.show();
613
+ }
614
+
529
615
  /** The menu-bar entry for whatever the updater is up to, or nothing. */
530
616
  function updateMenuItems() {
531
617
  const { autoUpdater } = electronUpdater;
532
618
  switch (update.status) {
619
+ case 'checking':
620
+ return [{ label: 'Checking for updates…', enabled: false }, { type: 'separator' }];
533
621
  case 'available':
534
622
  return [{
535
623
  label: `Update to ${update.version}`,
@@ -544,7 +632,10 @@ function updateMenuItems() {
544
632
  click: () => autoUpdater.quitAndInstall(),
545
633
  }, { type: 'separator' }];
546
634
  default:
547
- return [];
635
+ return updaterActive
636
+ ? [{ label: 'Check for Updates…', click: () => void appUpdates.check().catch(() => { /* shown in Options → Updates */ }) },
637
+ { type: 'separator' }]
638
+ : [];
548
639
  }
549
640
  }
550
641
 
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "ssh-manager-desktop",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "ssh-manager-desktop",
9
- "version": "4.0.0",
9
+ "version": "4.0.2",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "electron-updater": "^6.8.9",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ssh-manager-desktop",
3
3
  "productName": "SSH Manager",
4
- "version": "4.0.0",
4
+ "version": "4.0.2",
5
5
  "private": true,
6
6
  "description": "The SSH Manager control plane as a desktop application",
7
7
  "main": "main.js",