mcp-ssh-manager 4.0.3 → 4.2.0

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.
Files changed (43) hide show
  1. package/CHANGELOG.md +199 -0
  2. package/CLAUDE.md +17 -5
  3. package/Formula/ssh-manager.rb +2 -2
  4. package/INSTALLATION.md +4 -0
  5. package/README.md +41 -5
  6. package/brand/README.md +1 -0
  7. package/cli/codex.js +67 -0
  8. package/cli/guard.js +69 -0
  9. package/cli/lib/config.sh +102 -37
  10. package/cli/ssh-manager +13 -0
  11. package/cli/ssh-manager.js +1 -1
  12. package/desktop/electron/electron-builder.yml +3 -0
  13. package/desktop/electron/locale.mjs +34 -0
  14. package/desktop/electron/main.js +52 -65
  15. package/desktop/electron/native-menu.mjs +44 -0
  16. package/desktop/electron/native.zh-CN.json +58 -0
  17. package/desktop/electron/package-lock.json +15 -40
  18. package/desktop/electron/package.json +4 -1
  19. package/desktop/electron/smoke-test.mjs +11 -1
  20. package/dist/ui/app.css +1 -1
  21. package/dist/ui/app.js +123 -115
  22. package/docs/MIGRATION.md +1 -1
  23. package/docs/SECURITY_MODES.md +15 -8
  24. package/docs/SEO.md +1 -1
  25. package/llms-install.md +97 -0
  26. package/package.json +17 -3
  27. package/scripts/check-action-pins.mjs +57 -0
  28. package/scripts/test-upgrade-from-published.mjs +24 -2
  29. package/server.json +2 -2
  30. package/src/audit.js +6 -15
  31. package/src/background-job.js +44 -0
  32. package/src/backup-manager.js +24 -29
  33. package/src/config-loader.js +10 -1
  34. package/src/database-manager.js +13 -31
  35. package/src/dump-guard.js +79 -0
  36. package/src/filtered-agent.js +53 -0
  37. package/src/health-monitor.js +8 -4
  38. package/src/index.js +216 -21
  39. package/src/logger.js +3 -1
  40. package/src/quiet-stderr.js +15 -0
  41. package/src/ssh-guard.js +344 -0
  42. package/src/ssh-manager.js +71 -2
  43. package/src/tunnel-manager.js +14 -4
package/cli/lib/config.sh CHANGED
@@ -120,6 +120,64 @@ load_servers() {
120
120
  printf '%s\n' "${servers[@]}" | sort -u
121
121
  }
122
122
 
123
+ # The settings of a server, as the engine reads them (src/config-loader.js; a test
124
+ # keeps the two lists in step). A server's lines are found by these names and never
125
+ # by the bare prefix: removing "prod" used to remove the lines of "prod_eu" too.
126
+ SERVER_ENV_FIELDS="HOST USER PASSWORD KEYPATH CERTPATH AGENT_PUBLIC_KEY_PATH PASSPHRASE PORT DEFAULT_DIR SUDO_PASSWORD DESCRIPTION GROUP PLATFORM PROXYJUMP PROXYCOMMAND FORWARD_AGENT ANNOUNCE_AGENT MODE ALLOW_PATTERNS DENY_PATTERNS AUDIT_LOG APPROVAL"
127
+
128
+ # Copy stdin to stdout without the lines of server $1 (upper case) whose setting is
129
+ # in $2 (space separated). With a file as $3, its lines take the place of the first
130
+ # line dropped, so a server keeps its place and every setting that is not rewritten.
131
+ # Compared as text, never as a pattern: a name cannot steer it.
132
+ rewrite_server_lines() {
133
+ awk -v name="$1" -v fields="$2" -v block="${3:-}" '
134
+ BEGIN {
135
+ n = split(fields, f, " "); for (i = 1; i <= n; i++) drop[f[i]] = 1
136
+ prefix = "SSH_SERVER_" name "_"; done = 0
137
+ }
138
+ {
139
+ if (index($0, prefix) == 1) {
140
+ eq = index($0, "=")
141
+ if (eq > 0) {
142
+ field = substr($0, length(prefix) + 1, eq - length(prefix) - 1)
143
+ if (field in drop) {
144
+ if (block != "" && !done) { while ((getline line < block) > 0) print line; close(block); done = 1 }
145
+ next
146
+ }
147
+ }
148
+ }
149
+ print
150
+ }
151
+ END { if (block != "" && !done) { print ""; while ((getline line < block) > 0) print line; close(block) } }'
152
+ }
153
+
154
+ # One KEY=value line, written so that the engine's dotenv reads the value back as it
155
+ # was. A plain value stays bare, as before; one that dotenv would misread (a "#"
156
+ # starts a comment anywhere in it, a leading quote or space is eaten) is quoted with
157
+ # the delimiter it does not contain: single quotes and backticks have no escapes.
158
+ # With a third argument the value is quoted even when plain (descriptions and
159
+ # patterns always were), with double quotes unless it holds one.
160
+ env_line() {
161
+ local key="$1" value="$2" quote="${3:-}"
162
+ case "$value" in
163
+ *$'\n'*|*$'\r'*) print_error "The value of $key cannot hold a line break" >&2; return 1 ;;
164
+ esac
165
+ if [ -n "$quote" ] && [[ "$value" != *\"* ]]; then
166
+ printf '%s="%s"\n' "$key" "$value"
167
+ elif [[ "$value" != *"#"* ]] && [[ "$value" != [\'\"\`\ ]* ]] && [[ "$value" != *" " ]]; then
168
+ printf '%s=%s\n' "$key" "$value"
169
+ elif [[ "$value" != *\'* ]]; then
170
+ printf "%s='%s'\n" "$key" "$value"
171
+ elif [[ "$value" != *\"* ]]; then
172
+ printf '%s="%s"\n' "$key" "$value"
173
+ elif [[ "$value" != *'`'* ]]; then
174
+ printf '%s=`%s`\n' "$key" "$value"
175
+ else
176
+ print_error "The value of $key holds all three quote characters (' \" \`) and has to be quoted: the .env format cannot carry it" >&2
177
+ return 1
178
+ fi
179
+ }
180
+
123
181
  # Get server configuration
124
182
  get_server_config() {
125
183
  local server="$1"
@@ -147,8 +205,9 @@ get_server_config() {
147
205
  return 1
148
206
  fi
149
207
 
150
- # Only remove surrounding quotes if they exist, preserve quotes within the value
151
- if [[ "$value" =~ ^\"(.*)\"$ ]]; then
208
+ # Only remove surrounding quotes if they exist (the three dotenv accepts),
209
+ # preserve quotes within the value
210
+ if [[ "$value" =~ ^\"(.*)\"$ ]] || [[ "$value" =~ ^\'(.*)\'$ ]] || [[ "$value" =~ ^\`(.*)\`$ ]]; then
152
211
  printf '%s' "${BASH_REMATCH[1]}"
153
212
  else
154
213
  printf '%s' "$value"
@@ -187,36 +246,39 @@ add_server_to_env() {
187
246
  # Backup .env file
188
247
  cp "$SSH_MANAGER_ENV" "$SSH_MANAGER_ENV.bak"
189
248
 
190
- # Add server configuration
191
- {
249
+ # Add server configuration. Built before anything is written, so a value that
250
+ # cannot be carried by the .env format (see env_line) leaves the file as it was.
251
+ local block
252
+ block="$(
192
253
  echo ""
193
254
  echo "# Server: $name"
194
- echo "SSH_SERVER_${name_upper}_HOST=$host"
195
- echo "SSH_SERVER_${name_upper}_USER=$user"
196
- echo "SSH_SERVER_${name_upper}_PORT=$port"
255
+ env_line "SSH_SERVER_${name_upper}_HOST" "$host" &&
256
+ env_line "SSH_SERVER_${name_upper}_USER" "$user" &&
257
+ env_line "SSH_SERVER_${name_upper}_PORT" "$port" || exit 1
197
258
 
198
259
  if [ "$auth_type" = "password" ]; then
199
- echo "SSH_SERVER_${name_upper}_PASSWORD=$auth_value"
260
+ env_line "SSH_SERVER_${name_upper}_PASSWORD" "$auth_value" || exit 1
200
261
  else
201
- echo "SSH_SERVER_${name_upper}_KEYPATH=$auth_value"
262
+ env_line "SSH_SERVER_${name_upper}_KEYPATH" "$auth_value" || exit 1
202
263
  fi
203
264
 
204
265
  if [ -n "$description" ]; then
205
- echo "SSH_SERVER_${name_upper}_DESCRIPTION=\"$description\""
266
+ env_line "SSH_SERVER_${name_upper}_DESCRIPTION" "$description" quote || exit 1
206
267
  fi
207
268
 
208
269
  # Security mode (v3.5.0+) — only emit non-empty / non-default values to
209
270
  # keep generated .env diff-free for users who skip these prompts.
210
271
  if [ -n "$mode" ] && [ "$mode" != "unrestricted" ]; then
211
- echo "SSH_SERVER_${name_upper}_MODE=$mode"
272
+ env_line "SSH_SERVER_${name_upper}_MODE" "$mode" || exit 1
212
273
  fi
213
274
  if [ -n "$allow_patterns" ]; then
214
- echo "SSH_SERVER_${name_upper}_ALLOW_PATTERNS=\"$allow_patterns\""
275
+ env_line "SSH_SERVER_${name_upper}_ALLOW_PATTERNS" "$allow_patterns" quote || exit 1
215
276
  fi
216
277
  if [ -n "$audit_log" ]; then
217
- echo "SSH_SERVER_${name_upper}_AUDIT_LOG=$audit_log"
278
+ env_line "SSH_SERVER_${name_upper}_AUDIT_LOG" "$audit_log" || exit 1
218
279
  fi
219
- } >> "$SSH_MANAGER_ENV"
280
+ )" || { rm -f "$SSH_MANAGER_ENV.bak"; return 1; }
281
+ printf '%s\n' "$block" >> "$SSH_MANAGER_ENV"
220
282
 
221
283
  print_success "Server '$name' added successfully"
222
284
  }
@@ -243,37 +305,39 @@ update_server_in_env() {
243
305
  # Backup .env file
244
306
  cp "$SSH_MANAGER_ENV" "$SSH_MANAGER_ENV.bak"
245
307
 
246
- # Remove old server configuration (all lines including comments and old auth methods)
247
- local temp=$(mktemp)
248
- # Remove server config lines and the comment line before them
249
- sed "/^# Server: $name$/d; /^SSH_SERVER_${name_upper}_/d" "$SSH_MANAGER_ENV" > "$temp"
250
-
251
- # Find position to insert (after other servers or at end)
252
- # Add updated server configuration
253
- {
254
- cat "$temp"
255
- echo ""
256
- echo "# Server: $name"
257
- echo "SSH_SERVER_${name_upper}_HOST=$host"
258
- echo "SSH_SERVER_${name_upper}_USER=$user"
259
- echo "SSH_SERVER_${name_upper}_PORT=$port"
308
+ # The settings this function writes replace, in place, the ones the server had;
309
+ # every other setting of the server (mode, allow and deny patterns, audit log,
310
+ # group, proxy jump, platform...) stays exactly as it was. It used to delete all
311
+ # of them and write seven back, so editing a read-only server made it unrestricted.
312
+ # A changed login method drops the old one (a password or a key path, not both).
313
+ local block temp
314
+ block=$(mktemp)
315
+ temp=$(mktemp)
316
+ (
317
+ env_line "SSH_SERVER_${name_upper}_HOST" "$host" &&
318
+ env_line "SSH_SERVER_${name_upper}_USER" "$user" &&
319
+ env_line "SSH_SERVER_${name_upper}_PORT" "$port" || exit 1
260
320
 
261
321
  if [ "$auth_type" = "password" ]; then
262
- echo "SSH_SERVER_${name_upper}_PASSWORD=$auth_value"
322
+ env_line "SSH_SERVER_${name_upper}_PASSWORD" "$auth_value" || exit 1
263
323
  else
264
- echo "SSH_SERVER_${name_upper}_KEYPATH=$auth_value"
324
+ env_line "SSH_SERVER_${name_upper}_KEYPATH" "$auth_value" || exit 1
265
325
  fi
266
326
 
267
327
  if [ -n "$description" ]; then
268
- echo "SSH_SERVER_${name_upper}_DESCRIPTION=\"$description\""
328
+ env_line "SSH_SERVER_${name_upper}_DESCRIPTION" "$description" quote || exit 1
269
329
  fi
270
330
 
271
331
  if [ -n "$default_dir" ]; then
272
- echo "SSH_SERVER_${name_upper}_DEFAULT_DIR=$default_dir"
332
+ env_line "SSH_SERVER_${name_upper}_DEFAULT_DIR" "$default_dir" || exit 1
273
333
  fi
274
- } > "$SSH_MANAGER_ENV"
334
+ ) > "$block" || { rm -f "$block" "$temp" "$SSH_MANAGER_ENV.bak"; return 1; }
275
335
 
276
- rm -f "$temp"
336
+ rewrite_server_lines "$name_upper" "HOST USER PORT PASSWORD KEYPATH DESCRIPTION DEFAULT_DIR" "$block" < "$SSH_MANAGER_ENV" > "$temp"
337
+ # Written through the file, not renamed over it: its mode stays what it was.
338
+ cat "$temp" > "$SSH_MANAGER_ENV"
339
+
340
+ rm -f "$temp" "$block"
277
341
  print_success "Server '$name' updated successfully"
278
342
  }
279
343
 
@@ -290,10 +354,11 @@ remove_server_from_env() {
290
354
  # Backup .env file
291
355
  cp "$SSH_MANAGER_ENV" "$SSH_MANAGER_ENV.bak"
292
356
 
293
- # Remove all lines for this server
357
+ # Remove all lines for this server, and only this server's (see SERVER_ENV_FIELDS)
294
358
  local temp=$(mktemp)
295
- grep -v "^SSH_SERVER_${name_upper}_" "$SSH_MANAGER_ENV" > "$temp"
296
- mv "$temp" "$SSH_MANAGER_ENV"
359
+ rewrite_server_lines "$name_upper" "$SERVER_ENV_FIELDS" < "$SSH_MANAGER_ENV" > "$temp"
360
+ cat "$temp" > "$SSH_MANAGER_ENV"
361
+ rm -f "$temp"
297
362
 
298
363
  print_success "Server '$name' removed successfully"
299
364
  }
package/cli/ssh-manager CHANGED
@@ -99,6 +99,9 @@ show_help() {
99
99
  vault status Where it and its key live
100
100
  vault add|remove <name> One server in or out
101
101
  vault backup|restore <file> A recovery file, under a passphrase
102
+ codex setup|status Point Codex at this engine
103
+ guard install|remove|status Keep agents off raw ssh in their shell
104
+ guard print What install would write, nothing changed
102
105
  import <file> A spreadsheet, CSV, ~/.ssh/config, FileZilla,
103
106
  PuTTY, Termius or MobaXterm export (detected)
104
107
  import --from <tool> ssh-config · filezilla · transmit
@@ -382,6 +385,16 @@ main() {
382
385
  # reads — one code path, so the two cannot disagree.
383
386
  node "$SCRIPT_DIR/portability.js" "$command" "$@"
384
387
  ;;
388
+ codex)
389
+ # Codex's ssh-manager entry, through the same code as the interface's
390
+ # AI tools panel. Node, so it writes the file the way the engine does.
391
+ node "$SCRIPT_DIR/codex.js" "$@"
392
+ ;;
393
+ guard)
394
+ # Opt-in Claude Code hook against raw ssh. Node, like vault: it edits
395
+ # a JSON file, and the same code is what runs as the hook.
396
+ node "$SCRIPT_DIR/guard.js" "$@"
397
+ ;;
385
398
  vault)
386
399
  # v4 encrypted credential store. Implemented in Node because it uses
387
400
  # the same SecretStore the MCP server reads from — one code path for
@@ -28,7 +28,7 @@ const isWindows = platform() === 'win32';
28
28
  const args = process.argv.slice(2);
29
29
 
30
30
  // These commands are native Node and also work on Windows without Git Bash.
31
- const nativeCommands = { control: 'control.js', vault: 'vault.js', import: 'portability.js', export: 'portability.js', app: 'app.js' };
31
+ const nativeCommands = { control: 'control.js', vault: 'vault.js', import: 'portability.js', export: 'portability.js', app: 'app.js', guard: 'guard.js', codex: 'codex.js' };
32
32
  if (Object.hasOwn(nativeCommands, args[0])) {
33
33
  const commandArgs = ['import', 'export'].includes(args[0]) ? args : args.slice(1);
34
34
  const result = spawnSync(process.execPath, [join(__dirname, nativeCommands[args[0]]), ...commandArgs], { stdio: 'inherit' });
@@ -11,6 +11,9 @@ directories:
11
11
  # bindings at runtime and those cannot be read from inside an archive.
12
12
  files:
13
13
  - main.js
14
+ - locale.mjs
15
+ - native-menu.mjs
16
+ - native.zh-CN.json
14
17
  - local-shell.mjs
15
18
  - smoke-test.mjs
16
19
  - package.json
@@ -0,0 +1,34 @@
1
+ import fs from 'node:fs';
2
+ import os from 'node:os';
3
+ import path from 'node:path';
4
+
5
+ // Strings of the application's own native surfaces (menus, tray, notifications)
6
+ // in Chinese. English is the key itself, so English needs no catalogue.
7
+ const messages = JSON.parse(fs.readFileSync(new URL('./native.zh-CN.json', import.meta.url), 'utf8'));
8
+
9
+ /** The language a system locale asks for: Chinese for any `zh` tag, English otherwise. */
10
+ export function languageForLocale(locale) {
11
+ return /^zh(?:[-_]|$)/i.test(String(locale ?? '')) ? 'zh-CN' : 'en';
12
+ }
13
+
14
+ /**
15
+ * Which language the native menus and notifications speak.
16
+ *
17
+ * The choice saved from the interface (Options -> Appearance) always wins. Until
18
+ * somebody has chosen, the system language decides. The system locale is a
19
+ * parameter, not a lookup, so this module stays importable from plain Node (the
20
+ * tests do) and never needs Electron: the application passes `app.getLocale()`.
21
+ */
22
+ export function nativeLanguage({ home = process.env.SSH_MANAGER_HOME || path.join(os.homedir(), '.ssh-manager'), systemLocale = '' } = {}) {
23
+ try {
24
+ const preferences = JSON.parse(fs.readFileSync(path.join(home, 'preferences.json'), 'utf8'));
25
+ const saved = preferences['ssh-manager.language'];
26
+ if (saved === 'en' || saved === 'zh-CN') return saved;
27
+ } catch { /* no preferences yet, or unreadable: fall through to the system */ }
28
+ return languageForLocale(systemLocale);
29
+ }
30
+
31
+ export function nativeText(message, values = {}, language = nativeLanguage()) {
32
+ const text = language === 'en' ? message : messages[message] || message;
33
+ return text.replace(/\{\{(\w+)\}\}/g, (match, key) => String(values[key] ?? match));
34
+ }
@@ -30,9 +30,20 @@ import { createRequire } from 'module';
30
30
  import electronUpdater from 'electron-updater';
31
31
  import { fileURLToPath, pathToFileURL } from 'url';
32
32
  import { localShellLaunch, localShellName } from './local-shell.mjs';
33
+ import { nativeLanguage, nativeText } from './locale.mjs';
34
+ import { applicationMenuTemplate } from './native-menu.mjs';
33
35
 
34
36
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
35
37
 
38
+ /**
39
+ * The language of the menus, tray and notifications: the one chosen in the
40
+ * interface, else the system's. Read each time, because it can change while the
41
+ * application runs. `app.getLocale()` is only meaningful once the app is ready,
42
+ * and every caller runs after that.
43
+ */
44
+ const nativeLang = () => nativeLanguage({ systemLocale: app.getLocale() });
45
+ const text = (message, values) => nativeText(message, values, nativeLang());
46
+
36
47
  /**
37
48
  * The engine lives two directories up in the repository, and inside
38
49
  * `app.asar.unpacked` in a packaged build. Resolved rather than assumed,
@@ -194,7 +205,7 @@ function updateSnapshot() {
194
205
  const appUpdates = {
195
206
  snapshot: updateSnapshot,
196
207
  check: async () => {
197
- if (!updaterActive) throw new Error('Updates are turned off in this build');
208
+ if (!updaterActive) throw new Error(text('Updates are turned off in this build'));
198
209
  await electronUpdater.autoUpdater.checkForUpdates();
199
210
  },
200
211
  download: async () => { await electronUpdater.autoUpdater.downloadUpdate(); },
@@ -310,46 +321,18 @@ function createWindow(url) {
310
321
  mainWindow.on('closed', () => { mainWindow = null; });
311
322
  }
312
323
 
324
+ /** The language the application menu was last built in. */
325
+ let menuLanguage = null;
326
+
313
327
  /** A menu with the shortcuts a terminal-adjacent app is expected to have. */
314
328
  function buildMenu(url) {
315
- const isMac = process.platform === 'darwin';
316
- Menu.setApplicationMenu(Menu.buildFromTemplate([
317
- ...(isMac ? [{ role: 'appMenu' }] : []),
318
- {
319
- label: 'File',
320
- submenu: [
321
- {
322
- label: 'Open in browser',
323
- accelerator: 'CmdOrCtrl+B',
324
- // The tokenised URL is genuinely useful outside the app — a second
325
- // screen, a different browser, devtools you are used to.
326
- click: () => void shell.openExternal(url),
327
- },
328
- { type: 'separator' },
329
- isMac ? { role: 'close' } : { role: 'quit' },
330
- ],
331
- },
332
- { role: 'editMenu' },
333
- {
334
- label: 'View',
335
- submenu: [
336
- { role: 'reload' },
337
- { role: 'forceReload' },
338
- { role: 'toggleDevTools' },
339
- { type: 'separator' },
340
- { role: 'resetZoom' },
341
- { role: 'zoomIn' },
342
- { role: 'zoomOut' },
343
- { type: 'separator' },
344
- { role: 'togglefullscreen' },
345
- ],
346
- },
347
- { role: 'windowMenu' },
348
- {
349
- role: 'help',
350
- submenu: [{ label: 'Check for Updates…', click: () => void appUpdates.check().catch(() => { /* shown in Options → Updates */ }) }],
351
- },
352
- ]));
329
+ menuLanguage = nativeLang();
330
+ Menu.setApplicationMenu(Menu.buildFromTemplate(applicationMenuTemplate({
331
+ isMac: process.platform === 'darwin',
332
+ language: menuLanguage,
333
+ onOpenBrowser: () => void shell.openExternal(url),
334
+ onCheckUpdates: () => void appUpdates.check().catch(() => { /* shown in Options → Updates */ }),
335
+ })));
353
336
  }
354
337
 
355
338
  /**
@@ -398,8 +381,8 @@ function announce(pending) {
398
381
 
399
382
  const notification = new Notification({
400
383
  title: request.destructive
401
- ? `${request.server}: destructive command waiting`
402
- : `${request.server}: waiting for your decision`,
384
+ ? text('{{v0}}: destructive command waiting', { v0: request.server })
385
+ : text('{{v0}}: waiting for your decision', { v0: request.server }),
403
386
  body: String(request.command || request.tool || '').slice(0, 220),
404
387
  // Destructive requests stay on screen. `rm -rf` on production and
405
388
  // `systemctl status` are not the same interruption, and a banner that
@@ -437,11 +420,15 @@ function refreshTray() {
437
420
  // An unreadable vault is the interface's problem to report, not the tray's.
438
421
  }
439
422
 
423
+ // The application menu follows the language chosen in the interface, which
424
+ // can change while the app runs. Rebuild it only when that happens.
425
+ if (menuLanguage !== nativeLang()) buildMenu(plane.url);
426
+
440
427
  // Rebuilding a menu the user may have open is disruptive, and this runs on a
441
428
  // timer, so only touch it when something actually moved.
442
429
  const signature = JSON.stringify([
443
430
  pending.map(r => r.id), shells.map(t => t.server),
444
- running.map(s => s.id), servers, update.status, update.percent,
431
+ running.map(s => s.id), servers, update.status, update.percent, nativeLang(),
445
432
  ]);
446
433
  if (signature === trayState) return;
447
434
  trayState = signature;
@@ -468,7 +455,7 @@ function refreshTray() {
468
455
  const template = [...updateMenuItems()];
469
456
 
470
457
  if (pending.length) {
471
- template.push({ label: `${pending.length} waiting for your decision`, enabled: false });
458
+ template.push({ label: text('{{v0}} waiting for your decision', { v0: pending.length }), enabled: false });
472
459
  for (const request of pending.slice(0, 6)) {
473
460
  template.push({
474
461
  label: ` ${request.server} · ${brief(request.command)}`,
@@ -477,14 +464,14 @@ function refreshTray() {
477
464
  }
478
465
  template.push({ type: 'separator' });
479
466
  } else {
480
- template.push({ label: 'Nothing is waiting', enabled: false });
467
+ template.push({ label: text('Nothing is waiting'), enabled: false });
481
468
  template.push({ type: 'separator' });
482
469
  }
483
470
 
484
471
  if (shells.length || running.length) {
485
- template.push({ label: 'Open right now', enabled: false });
472
+ template.push({ label: text('Open right now'), enabled: false });
486
473
  for (const shell of shells.slice(0, 5)) {
487
- template.push({ label: ` Shell on ${shell.server}`, click: focus });
474
+ template.push({ label: text(' Shell on {{v0}}', { v0: shell.server }), click: focus });
488
475
  }
489
476
  for (const stream of running.slice(0, 5)) {
490
477
  template.push({
@@ -497,22 +484,22 @@ function refreshTray() {
497
484
 
498
485
  if (servers.length) {
499
486
  template.push({
500
- label: `Servers (${servers.length})`,
487
+ label: text('Servers ({{v0}})', { v0: servers.length }),
501
488
  submenu: servers.slice(0, 12).map(name => ({ label: name, click: focus })),
502
489
  });
503
490
  template.push({ type: 'separator' });
504
491
  }
505
492
 
506
493
  template.push(
507
- { label: 'Show SSH Manager', click: focus },
508
- { label: 'Open in browser', click: () => plane && void shell.openExternal(plane.url) },
494
+ { label: text('Show SSH Manager'), click: focus },
495
+ { label: text('Open in browser'), click: () => plane && void shell.openExternal(plane.url) },
509
496
  { type: 'separator' },
510
- { label: 'Quit SSH Manager', click: () => app.quit() },
497
+ { label: text('Quit SSH Manager'), click: () => app.quit() },
511
498
  );
512
499
 
513
500
  tray.setContextMenu(Menu.buildFromTemplate(template));
514
501
  tray.setToolTip(pending.length
515
- ? `SSH Manager — ${pending.length} waiting for your decision`
502
+ ? text('SSH Manager — {{v0}} waiting for your decision', { v0: pending.length })
516
503
  : 'SSH Manager');
517
504
 
518
505
  // The count beside the icon, and on the dock. Only when it is not zero: a
@@ -596,8 +583,8 @@ function announceUpdate(version) {
596
583
  try { fs.writeFileSync(marker, `${version}\n`); } catch { /* it will say it again next time; harmless */ }
597
584
  if (!Notification.isSupported()) return;
598
585
  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.',
586
+ title: text('SSH Manager {{v0}} is available', { v0: version }),
587
+ body: text('Open Options → Updates to download it. Nothing is installed until you restart.'),
601
588
  silent: true,
602
589
  });
603
590
  notification.on('click', () => {
@@ -617,23 +604,23 @@ function updateMenuItems() {
617
604
  const { autoUpdater } = electronUpdater;
618
605
  switch (update.status) {
619
606
  case 'checking':
620
- return [{ label: 'Checking for updates…', enabled: false }, { type: 'separator' }];
607
+ return [{ label: text('Checking for updates…'), enabled: false }, { type: 'separator' }];
621
608
  case 'available':
622
609
  return [{
623
- label: `Update to ${update.version}`,
610
+ label: text('Update to {{v0}}', { v0: update.version }),
624
611
  click: () => autoUpdater.downloadUpdate().catch(() => { /* reported by the error handler */ }),
625
612
  }, { type: 'separator' }];
626
613
  case 'downloading':
627
- return [{ label: `Downloading update… ${update.percent}%`, enabled: false },
614
+ return [{ label: text('Downloading update… {{v0}}%', { v0: update.percent }), enabled: false },
628
615
  { type: 'separator' }];
629
616
  case 'ready':
630
617
  return [{
631
- label: `Restart to update to ${update.version}`,
618
+ label: text('Restart to update to {{v0}}', { v0: update.version }),
632
619
  click: () => autoUpdater.quitAndInstall(),
633
620
  }, { type: 'separator' }];
634
621
  default:
635
622
  return updaterActive
636
- ? [{ label: 'Check for Updates…', click: () => void appUpdates.check().catch(() => { /* shown in Options → Updates */ }) },
623
+ ? [{ label: text('Check for Updates…'), click: () => void appUpdates.check().catch(() => { /* shown in Options → Updates */ }) },
637
624
  { type: 'separator' }]
638
625
  : [];
639
626
  }
@@ -738,7 +725,7 @@ app.whenReady().then(async () => {
738
725
  const { url } = await startControlPlane();
739
726
  if (smokeTest) {
740
727
  const { runSmokeTest } = await import('./smoke-test.mjs');
741
- await runSmokeTest({ app, BrowserWindow, url, root: engineRoot(), localShellProvider });
728
+ await runSmokeTest({ app, BrowserWindow, Menu, url, root: engineRoot(), localShellProvider });
742
729
  app.quit();
743
730
  return;
744
731
  }
@@ -762,13 +749,13 @@ app.whenReady().then(async () => {
762
749
  // box confidently suggested another copy was running, which sent the reader
763
750
  // looking in the wrong place entirely.
764
751
  const guess = /Cannot find (package|module)/i.test(error.message)
765
- ? 'The application is missing part of itself. This is a packaging fault, '
766
- + 'not something you can fix here — please report it with this message.'
752
+ ? text('The application is missing part of itself. This is a packaging fault, '
753
+ + 'not something you can fix here — please report it with this message.')
767
754
  : error.code === 'EADDRINUSE' || /already running|EADDRINUSE/i.test(error.message)
768
- ? 'Another copy is already running, or a stale socket is in the way.'
769
- : 'The socket path may be too long for this system, or the port could '
770
- + 'not be opened.';
771
- dialog.showErrorBox('SSH Manager could not start', `${error.message}\n\n${guess}`);
755
+ ? text('Another copy is already running, or a stale socket is in the way.')
756
+ : text('The socket path may be too long for this system, or the port could '
757
+ + 'not be opened.');
758
+ dialog.showErrorBox(text('SSH Manager could not start'), `${error.message}\n\n${guess}`);
772
759
  app.quit();
773
760
  }
774
761
 
@@ -0,0 +1,44 @@
1
+ import { nativeLanguage, nativeText } from './locale.mjs';
2
+
3
+ // Electron's aggregate menu roles generate English child labels regardless of
4
+ // the in-app language. Keep individual roles for native shortcuts and behavior,
5
+ // and supply each visible label from the same saved preference as the UI.
6
+ export function applicationMenuTemplate({ isMac, onOpenBrowser, onCheckUpdates, language = nativeLanguage() }) {
7
+ const text = message => nativeText(message, {}, language);
8
+ const item = (role, label) => ({ role, label: text(label) });
9
+ const separator = () => ({ type: 'separator' });
10
+ return [
11
+ ...(isMac ? [{ label: 'SSH Manager', submenu: [
12
+ item('about', 'About SSH Manager'), separator(),
13
+ { role: 'services', label: text('Services'), submenu: [] }, separator(),
14
+ item('hide', 'Hide SSH Manager'), item('hideOthers', 'Hide Others'),
15
+ item('unhide', 'Show All'), separator(), item('quit', 'Quit SSH Manager'),
16
+ ] }] : []),
17
+ { label: text('File'), submenu: [
18
+ { label: text('Open in browser'), accelerator: 'CmdOrCtrl+B', click: onOpenBrowser },
19
+ separator(), isMac ? item('close', 'Close') : item('quit', 'Quit'),
20
+ ] },
21
+ { label: text('Edit'), submenu: [
22
+ item('undo', 'Undo'), item('redo', 'Redo'), separator(),
23
+ item('cut', 'Cut'), item('copy', 'Copy'), item('paste', 'Paste'),
24
+ item('pasteAndMatchStyle', 'Paste and Match Style'), item('delete', 'Delete'),
25
+ item('selectAll', 'Select All'),
26
+ ...(isMac ? [separator(), { label: text('Speech'), submenu: [
27
+ item('startSpeaking', 'Start Speaking'), item('stopSpeaking', 'Stop Speaking'),
28
+ ] }] : []),
29
+ ] },
30
+ { label: text('View'), submenu: [
31
+ item('reload', 'Reload'), item('forceReload', 'Force reload'),
32
+ item('toggleDevTools', 'Developer tools'), separator(),
33
+ item('resetZoom', 'Actual size'), item('zoomIn', 'Zoom in'), item('zoomOut', 'Zoom out'),
34
+ separator(), item('togglefullscreen', 'Toggle fullscreen'),
35
+ ] },
36
+ { label: text('Window'), submenu: [
37
+ item('minimize', 'Minimize'), item('zoom', 'Zoom'),
38
+ ...(isMac ? [separator(), item('front', 'Bring All to Front')] : [item('close', 'Close')]),
39
+ ] },
40
+ { role: 'help', label: text('Help'), submenu: [
41
+ { label: text('Check for Updates…'), click: onCheckUpdates },
42
+ ] },
43
+ ];
44
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "Copy": "复制",
3
+ "Checking for updates…": "正在检查更新…",
4
+ "Close": "关闭",
5
+ "Nothing is waiting": "暂无待审批请求",
6
+ "File": "文件",
7
+ "View": "视图",
8
+ "Edit": "编辑",
9
+ "Window": "窗口",
10
+ "Help": "帮助",
11
+ "Open in browser": "在浏览器中打开",
12
+ "Check for Updates…": "检查更新…",
13
+ "Show SSH Manager": "显示 SSH Manager",
14
+ "Quit SSH Manager": "退出 SSH Manager",
15
+ "Open right now": "当前已打开",
16
+ "Updates are turned off in this build": "此版本已关闭更新",
17
+ "{{v0}}: destructive command waiting": "{{v0}}:破坏性命令等待审批",
18
+ "{{v0}}: waiting for your decision": "{{v0}}:等待审批",
19
+ "{{v0}} waiting for your decision": "{{v0}} 项请求等待审批",
20
+ " Shell on {{v0}}": " {{v0}} 的终端",
21
+ "Servers ({{v0}})": "服务器({{v0}})",
22
+ "SSH Manager — {{v0}} waiting for your decision": "SSH Manager — {{v0}} 项请求等待审批",
23
+ "SSH Manager {{v0}} is available": "SSH Manager {{v0}} 可供更新",
24
+ "Open Options → Updates to download it. Nothing is installed until you restart.": "打开“设置 → 更新”下载。重启时才会安装。",
25
+ "Update to {{v0}}": "更新至 {{v0}}",
26
+ "Downloading update… {{v0}}%": "正在下载更新… {{v0}}%",
27
+ "Restart to update to {{v0}}": "重启并更新至 {{v0}}",
28
+ "Reload": "重新加载",
29
+ "Force reload": "强制重新加载",
30
+ "Developer tools": "开发者工具",
31
+ "Actual size": "实际大小",
32
+ "Zoom in": "放大",
33
+ "Zoom out": "缩小",
34
+ "Toggle fullscreen": "切换全屏",
35
+ "Quit": "退出",
36
+ "About SSH Manager": "关于 SSH Manager",
37
+ "Services": "服务",
38
+ "Hide SSH Manager": "隐藏 SSH Manager",
39
+ "Hide Others": "隐藏其他应用",
40
+ "Show All": "全部显示",
41
+ "Undo": "撤销",
42
+ "Redo": "重做",
43
+ "Cut": "剪切",
44
+ "Paste": "粘贴",
45
+ "Paste and Match Style": "粘贴并匹配样式",
46
+ "Delete": "删除",
47
+ "Select All": "全选",
48
+ "Speech": "语音",
49
+ "Start Speaking": "开始朗读",
50
+ "Stop Speaking": "停止朗读",
51
+ "Minimize": "最小化",
52
+ "Zoom": "缩放",
53
+ "Bring All to Front": "全部置于前台",
54
+ "SSH Manager could not start": "SSH Manager 无法启动",
55
+ "The application is missing part of itself. This is a packaging fault, not something you can fix here — please report it with this message.": "应用缺少部分组件。这是打包问题,无法在此修复,请附上此消息反馈。",
56
+ "Another copy is already running, or a stale socket is in the way.": "另一个实例已在运行,或有残留的套接字占用了路径。",
57
+ "The socket path may be too long for this system, or the port could not be opened.": "套接字路径在此系统上可能过长,或端口无法打开。"
58
+ }