mcp-ssh-manager 3.8.7 → 4.0.1

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 (104) hide show
  1. package/.eslintignore +5 -0
  2. package/.gitattributes +5 -0
  3. package/CHANGELOG.md +371 -6
  4. package/CLAUDE.md +6 -0
  5. package/CODE_OF_CONDUCT.md +18 -0
  6. package/CONTRIBUTING.md +30 -0
  7. package/Formula/ssh-manager.rb +60 -0
  8. package/README.md +484 -964
  9. package/ROADMAP-V4.md +451 -0
  10. package/brand/README.md +43 -0
  11. package/brand/icon.svg +32 -0
  12. package/brand/mark.svg +18 -0
  13. package/brand/wordmark.svg +30 -0
  14. package/cli/app.js +230 -0
  15. package/cli/control.js +116 -0
  16. package/cli/lib/colors.sh +15 -0
  17. package/cli/lib/menu.sh +145 -96
  18. package/cli/portability.js +186 -0
  19. package/cli/ssh-manager +197 -91
  20. package/cli/ssh-manager.js +14 -0
  21. package/cli/style.js +17 -0
  22. package/cli/vault.js +411 -0
  23. package/desktop/ControlPlaneApp.swift +219 -0
  24. package/desktop/build.sh +58 -0
  25. package/desktop/electron/after-pack.cjs +39 -0
  26. package/desktop/electron/electron-builder.yml +148 -0
  27. package/desktop/electron/finalize-artifacts.mjs +83 -0
  28. package/desktop/electron/main.js +815 -0
  29. package/desktop/electron/package-lock.json +3656 -0
  30. package/desktop/electron/package.json +30 -0
  31. package/desktop/electron/prepare-engine.mjs +84 -0
  32. package/desktop/electron/resources/entitlements.mac.plist +22 -0
  33. package/desktop/electron/resources/icon.png +0 -0
  34. package/desktop/electron/resources/trayTemplate.png +0 -0
  35. package/desktop/electron/resources/trayTemplate@2x.png +0 -0
  36. package/desktop/electron/smoke-test.mjs +184 -0
  37. package/dist/ui/app.css +1 -0
  38. package/dist/ui/app.js +501 -0
  39. package/dist/ui/assets/Forum-Regular.woff2 +0 -0
  40. package/dist/ui/assets/JetBrainsMono-Bold.woff2 +0 -0
  41. package/dist/ui/assets/JetBrainsMono-Regular.woff2 +0 -0
  42. package/dist/ui/assets/Karla-Variable.woff2 +0 -0
  43. package/dist/ui/index.html +16 -0
  44. package/docs/DISTRIBUTION.md +136 -0
  45. package/docs/FINAL-TEST-V4.md +209 -0
  46. package/docs/MIGRATION.md +334 -0
  47. package/docs/TESTING-V4.md +119 -0
  48. package/docs/superpowers/specs/2026-10-08-desktop-from-npm-and-cli-design.md +187 -0
  49. package/docs/videos/control-plane.mp4 +0 -0
  50. package/package.json +61 -30
  51. package/scripts/build-interface.mjs +73 -0
  52. package/scripts/capture-screenshots.mjs +191 -0
  53. package/scripts/demo-env.mjs +461 -0
  54. package/scripts/frame-screenshots.py +176 -0
  55. package/scripts/macbook-mockup.py +296 -0
  56. package/scripts/make-tray-icon.py +61 -0
  57. package/scripts/preview-candidate.mjs +291 -0
  58. package/scripts/publish-desktop.mjs +46 -0
  59. package/scripts/record-demo.mjs +229 -0
  60. package/scripts/release-version.mjs +32 -0
  61. package/scripts/render-cli-menu.py +157 -0
  62. package/scripts/requirements-dev.in +12 -0
  63. package/scripts/requirements-dev.txt +424 -0
  64. package/scripts/run-ui-regression.mjs +48 -0
  65. package/scripts/setup-hooks.sh +7 -13
  66. package/scripts/smoke-desktop.mjs +80 -0
  67. package/scripts/test-drag-and-drop.mjs +114 -0
  68. package/scripts/test-first-run.mjs +5 -0
  69. package/scripts/test-import-ui.mjs +5 -0
  70. package/scripts/test-preferences-persist.mjs +5 -0
  71. package/scripts/test-upgrade-from-published.mjs +226 -0
  72. package/scripts/verify-mac-build.sh +153 -0
  73. package/scripts/verify-windows-build.ps1 +15 -0
  74. package/server.json +3 -3
  75. package/skills/README.md +42 -0
  76. package/skills/ssh-incident/SKILL.md +55 -0
  77. package/skills/ssh-operations/SKILL.md +62 -0
  78. package/skills/ssh-restricted/SKILL.md +57 -0
  79. package/src/agent-clients.js +482 -0
  80. package/src/approval.js +291 -0
  81. package/src/audit.js +11 -1
  82. package/src/command-log.js +162 -0
  83. package/src/config-loader.js +119 -4
  84. package/src/config-paths.js +101 -0
  85. package/src/control-plane.js +2730 -0
  86. package/src/desktop-install.js +747 -0
  87. package/src/index.js +179 -213
  88. package/src/live-stream.js +261 -0
  89. package/src/saved-commands.js +150 -0
  90. package/src/secret-store.js +573 -0
  91. package/src/server-aliases.js +8 -7
  92. package/src/server-config-manager.js +33 -7
  93. package/src/server-export.js +106 -0
  94. package/src/server-groups.js +82 -21
  95. package/src/server-import.js +477 -0
  96. package/src/shell-quote.js +9 -2
  97. package/src/ssh-connection.js +155 -0
  98. package/src/ssh-manager.js +186 -13
  99. package/src/tunnel-manager.js +79 -0
  100. package/src/vault-recovery.js +206 -0
  101. package/src/xlsx.js +322 -0
  102. package/docs/images/social-preview.png +0 -0
  103. package/docs/images/social-preview@2x.png +0 -0
  104. package/docs/images/ssh-manager-cli-menu.png +0 -0
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Prove that dragging a file from one pane to the other actually moves it.
4
+ *
5
+ * Not part of `npm test`: it needs a demo control plane and a real Chrome.
6
+ *
7
+ * node scripts/demo-env.mjs --port 7315 &
8
+ * node scripts/test-drag-and-drop.mjs <url-with-token> /tmp/shots
9
+ *
10
+ * ## A real drag, not a fabricated one
11
+ *
12
+ * A hand-made DragEvent carries its own empty DataTransfer, so the payload the
13
+ * application writes on dragstart never reaches the drop — the handler fires and
14
+ * does nothing, which looks like a pass and is not one.
15
+ *
16
+ * Chrome can intercept its own native drag instead: setInterceptDrags(true)
17
+ * turns a genuine mouse drag into a `Input.dragIntercepted` event carrying the
18
+ * real drag data, which is then handed to dispatchDragEvent at the target.
19
+ * Everything the browser would have done, it does.
20
+ *
21
+ * The fabricated version was not merely imprecise, it reported success: the
22
+ * drop handler ran, found nothing in its DataTransfer, and did nothing, while
23
+ * the check looked at the wrong pane and saw the word it wanted. Two bugs
24
+ * agreeing is not a passing test.
25
+ *
26
+ * Ground truth is the filesystem — look for the file under the demo's scratch
27
+ * directory afterwards, not at the screen.
28
+ */
29
+ import { spawn } from 'child_process';
30
+ import fs from 'fs'; import os from 'os'; import path from 'path';
31
+ /* global WebSocket */
32
+ const CHROME='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
33
+ const PORT=9343; const OUT=process.argv[3]; const sleep=ms=>new Promise(r=>setTimeout(r,ms));
34
+ const profile=fs.mkdtempSync(path.join(os.tmpdir(),'rd-'));
35
+ const chrome=spawn(CHROME,[`--remote-debugging-port=${PORT}`,`--user-data-dir=${profile}`,
36
+ '--no-first-run','--no-default-browser-check','--window-size=1500,950','about:blank'],{ stdio:'ignore' });
37
+ let t; for(let i=0;i<60;i++){try{const l=await fetch(`http://127.0.0.1:${PORT}/json/list`).then(r=>r.json());
38
+ const p=l.find(x=>x.type==='page'&&x.webSocketDebuggerUrl); if(p){t=p.webSocketDebuggerUrl;break;}}catch{} await sleep(250);}
39
+ const ws=new WebSocket(t); await new Promise(r=>ws.addEventListener('open',r,{ once:true }));
40
+ let id=1; const pend=new Map(); const events=[];
41
+ ws.addEventListener('message',e=>{const m=JSON.parse(e.data);
42
+ if(m.method){events.push(m); return;}
43
+ const w=pend.get(m.id); if(w){pend.delete(m.id); w(m.result);}});
44
+ const send=(me,pa={})=>{const i=id++; ws.send(JSON.stringify({ id:i,method:me,params:pa })); return new Promise(r=>pend.set(i,r));};
45
+ const ev = async e => (await send('Runtime.evaluate',{ expression:e,returnByValue:true,awaitPromise:true })).result?.value;
46
+ const shot = async n => { const s=await send('Page.captureScreenshot',{ format:'png' });
47
+ fs.writeFileSync(`${OUT}/${n}.png`, Buffer.from(s.data,'base64')); };
48
+ const waitFor = async (method, ms=4000) => {
49
+ const until = Date.now()+ms;
50
+ while (Date.now() < until) {
51
+ const hit = events.find(e => e.method === method);
52
+ if (hit) { events.length = 0; return hit.params; }
53
+ await sleep(60);
54
+ }
55
+ return null;
56
+ };
57
+
58
+ await send('Page.enable'); await send('Runtime.enable'); await send('Input.enable').catch(()=>{});
59
+ await send('Emulation.setDeviceMetricsOverride',{ width:1500,height:950,deviceScaleFactor:1,mobile:false });
60
+ await send('Page.navigate',{ url:process.argv[2] }); await sleep(3000);
61
+ await ev('document.querySelectorAll(\'[aria-label="Browse files"]\')[1].click()'); await sleep(3800);
62
+
63
+ const centreOf = async name => ev(`
64
+ (() => { const e = [...document.querySelectorAll('*')]
65
+ .find(e => e.children.length === 0 && e.textContent.trim() === ${JSON.stringify(name)} && e.offsetParent);
66
+ if (!e) return null; const r = e.getBoundingClientRect();
67
+ return { x: Math.round(r.left + r.width/2), y: Math.round(r.top + r.height/2) }; })()`);
68
+
69
+ // Into Documents first: the previous run dragged the folder itself and the
70
+ // application correctly refused it. A file is the case worth proving.
71
+ const folder = await centreOf('Documents');
72
+ await send('Input.dispatchMouseEvent',{ type:'mousePressed',x:folder.x,y:folder.y,button:'left',clickCount:2 });
73
+ await send('Input.dispatchMouseEvent',{ type:'mouseReleased',x:folder.x,y:folder.y,button:'left',clickCount:2 });
74
+ await sleep(2200);
75
+ const from = await centreOf('runbook.md');
76
+ const to = await centreOf('backups');
77
+ console.log(` source (Documents, gauche): ${JSON.stringify(from)}`);
78
+ console.log(` cible (backups, droite) : ${JSON.stringify(to)}`);
79
+ if (!from || !to) { console.log(' ✗ points introuvables'); chrome.kill(); process.exit(1); }
80
+
81
+ await send('Input.setInterceptDrags', { enabled: true });
82
+
83
+ // A drag the browser itself recognises: press, then move far enough to pass the
84
+ // threshold that starts one.
85
+ await send('Input.dispatchMouseEvent',{ type:'mousePressed',x:from.x,y:from.y,button:'left',clickCount:1 });
86
+ await send('Input.dispatchMouseEvent',{ type:'mouseMoved',x:from.x+8,y:from.y+4,button:'left',buttons:1 });
87
+ await send('Input.dispatchMouseEvent',{ type:'mouseMoved',x:from.x+40,y:from.y+10,button:'left',buttons:1 });
88
+
89
+ const intercepted = await waitFor('Input.dragIntercepted', 4000);
90
+ if (!intercepted) {
91
+ console.log(' ✗ Chrome n a pas reconnu un glisser — la ligne n est peut-être pas draggable');
92
+ await send('Input.dispatchMouseEvent',{ type:'mouseReleased',x:from.x,y:from.y,button:'left' });
93
+ } else {
94
+ const data = intercepted.data;
95
+ console.log(` ✓ glisser natif reconnu — ${data.items.length} élément(s), types: ${data.items.map(i=>i.mimeType).join(', ')}`);
96
+ await send('Input.dispatchDragEvent',{ type:'dragEnter',x:to.x,y:to.y,data });
97
+ await send('Input.dispatchDragEvent',{ type:'dragOver',x:to.x,y:to.y,data });
98
+ await shot('drag-over');
99
+ await send('Input.dispatchDragEvent',{ type:'drop',x:to.x,y:to.y,data });
100
+ console.log(' ✓ dépôt envoyé sur le panneau distant');
101
+ }
102
+
103
+ await sleep(4000);
104
+ await shot('drag-done');
105
+ const landed = await ev(`
106
+ (() => { const panes=[...document.querySelectorAll('div.flex.h-full.flex-col')];
107
+ const right = panes[1] ? panes[1].innerText : '';
108
+ return { rightPane: right.split('\\n').filter(Boolean).slice(0,10),
109
+ transferBanner: /transfer|Uploading|Downloading|%/i.test(document.body.innerText) }; })()`);
110
+ console.log(' contenu du panneau droit :', JSON.stringify(landed.rightPane));
111
+ console.log(' ' + (landed.rightPane.includes('Documents')
112
+ ? '✓ Documents est arrive a droite'
113
+ : '✗ Documents n est pas arrive a droite'));
114
+ chrome.kill(); await sleep(600); try{fs.rmSync(profile,{ recursive:true,force:true });}catch{}
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ // Compatibility entry point. No URL/token or screenshot-directory arguments:
3
+ // isolated Playwright fixtures own the server and browser. Use --help for flags.
4
+ import { runUiRegression } from './run-ui-regression.mjs';
5
+ runUiRegression('welcome is accessible|welcome fits a narrow viewport');
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ // Compatibility entry point. Import assertions use temporary fixture config,
3
+ // never Transmit favourites or a caller's live vault. Use --help for the contract.
4
+ import { runUiRegression } from './run-ui-regression.mjs';
5
+ runUiRegression('import action in welcome|import is optional and keeps the original configuration');
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ // Compatibility entry point for persistence across a new control-plane port.
3
+ // Requires an already-built UI; use --help for Playwright flags and prerequisites.
4
+ import { runUiRegression } from './run-ui-regression.mjs';
5
+ runUiRegression('preferences survive a new control-plane port');
@@ -0,0 +1,226 @@
1
+ #!/usr/bin/env node
2
+ /** Registry 3.8.5 -> packed working tree -> registry rollback, with no opt-in UI.
3
+ * Run before a release: node scripts/test-upgrade-from-published.mjs [version]
4
+ * Installs three times and probes .env, TOML and process-environment setups.
5
+ * Every home/config is isolated; only hashes of credential fields cross probes.
6
+ */
7
+ import assert from 'node:assert/strict';
8
+ import crypto from 'node:crypto';
9
+ import fs from 'node:fs';
10
+ import os from 'node:os';
11
+ import path from 'node:path';
12
+ import { execFileSync, spawn } from 'node:child_process';
13
+ import { fileURLToPath, pathToFileURL } from 'node:url';
14
+ import { createRequire } from 'node:module';
15
+
16
+ const ROOT = path.dirname(path.dirname(fileURLToPath(import.meta.url)));
17
+ const PREVIOUS = process.argv[2] || '3.8.5';
18
+ assert.match(PREVIOUS, /^\d+\.\d+\.\d+(?:-[\w.-]+)?$/, 'previous version must be an exact version');
19
+ const FIELDS = ['name', 'host', 'user', 'password', 'keyPath', 'passphrase', 'port',
20
+ 'defaultDir', 'sudoPassword', 'description', 'group', 'platform', 'proxyJump',
21
+ 'proxyCommand', 'forwardAgent', 'mode', 'allowPatterns', 'denyPatterns', 'auditLog', 'source'];
22
+ let passed = 0;
23
+ const ok = label => console.log(`✓ ${++passed}. ${label}`);
24
+ const canonical = value => Array.isArray(value) ? value.map(canonical)
25
+ : value && typeof value === 'object' ? Object.fromEntries(Object.keys(value).sort().map(key => [key, canonical(value[key])])) : value;
26
+
27
+ // npm.cmd cannot be passed to execFile on Windows. Locate npm's JavaScript CLI
28
+ // and run it with this Node executable on every platform, without shell quoting.
29
+ function npmCLI() {
30
+ const candidates = [process.env.npm_execpath];
31
+ try { candidates.push(path.join(path.dirname(createRequire(import.meta.url).resolve('npm/package.json')), 'bin', 'npm-cli.js')); } catch { /* global install */ }
32
+ for (const dir of [path.dirname(process.execPath), ...(process.env.PATH || '').split(path.delimiter)]) {
33
+ candidates.push(path.join(dir, 'node_modules', 'npm', 'bin', 'npm-cli.js'));
34
+ try { candidates.push(fs.realpathSync(path.join(dir, 'npm'))); } catch { /* not on this PATH entry */ }
35
+ }
36
+ const cli = candidates.find(candidate => candidate && /npm-cli\.js$/.test(candidate) && fs.existsSync(candidate));
37
+ if (!cli) throw new Error('Cannot locate npm-cli.js; run this check through npm or install npm beside Node');
38
+ return cli;
39
+ }
40
+ const npmPath = npmCLI();
41
+ function npm(args, cwd) {
42
+ try {
43
+ return execFileSync(process.execPath, [npmPath, ...args], { cwd, encoding: 'utf8',
44
+ stdio: ['ignore', 'pipe', 'pipe'], timeout: 180000 });
45
+ } catch (error) {
46
+ // Do not dump npm configuration or child output, which may contain tokens.
47
+ throw new Error(`npm ${args[0]} failed (exit ${error.status ?? error.code}); check registry access and retry`);
48
+ }
49
+ }
50
+
51
+ function interrogate(scenario, entry) {
52
+ return new Promise((resolve, reject) => {
53
+ const child = spawn(process.execPath, ['--import', pathToFileURL(scenario.preload).href, entry], {
54
+ cwd: scenario.dir, env: scenario.env, stdio: ['pipe', 'pipe', 'pipe'],
55
+ });
56
+ let buffer = '';
57
+ let stderr = '';
58
+ let nextId = 1;
59
+ let finished = false;
60
+ const pending = new Map();
61
+ const timer = setTimeout(() => fail(new Error(`${scenario.name}: MCP probe timed out`)), 12000);
62
+ const exit = new Promise(done => child.once('exit', done));
63
+ function fail(error) {
64
+ if (finished) return;
65
+ finished = true; clearTimeout(timer); child.kill(); reject(error);
66
+ }
67
+ child.stderr.on('data', chunk => { stderr = (stderr + chunk).slice(-4096); });
68
+ child.on('error', fail);
69
+ child.on('exit', (code, signal) => {
70
+ const diagnostic = stderr.match(/\bERR_[A-Z0-9_]+\b/)?.[0];
71
+ // Expose the runtime error code, never raw logs or fixture credentials.
72
+ if (!finished) fail(new Error(`${scenario.name}: MCP exited before answering (exit ${code ?? signal}${diagnostic ? `, ${diagnostic}` : ''})`));
73
+ });
74
+ child.stdout.on('data', chunk => {
75
+ buffer += chunk;
76
+ while (buffer.includes('\n')) {
77
+ const end = buffer.indexOf('\n');
78
+ const line = buffer.slice(0, end); buffer = buffer.slice(end + 1);
79
+ if (!line.trim()) continue;
80
+ let message;
81
+ try { message = JSON.parse(line); } catch { fail(new Error(`${scenario.name}: non-JSON stdout broke MCP framing`)); return; }
82
+ if (message.method === 'elicitation/create') { fail(new Error(`${scenario.name}: unexpected interactive prompt`)); return; }
83
+ const waiter = pending.get(message.id);
84
+ if (waiter) { pending.delete(message.id); message.error ? waiter.reject(new Error(`${scenario.name}: MCP ${waiter.method} failed`)) : waiter.resolve(message.result); }
85
+ }
86
+ });
87
+ const request = (method, params) => new Promise((res, rej) => {
88
+ const id = nextId++;
89
+ pending.set(id, { resolve: res, reject: rej, method });
90
+ child.stdin.write(`${JSON.stringify({ jsonrpc: '2.0', id, method, params })}\n`);
91
+ });
92
+ (async () => {
93
+ await request('initialize', { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'upgrade-regression', version: '1' } });
94
+ child.stdin.write(`${JSON.stringify({ jsonrpc: '2.0', method: 'notifications/initialized', params: {} })}\n`);
95
+ const tools = await request('tools/list', {});
96
+ const listed = await request('tools/call', { name: 'ssh_list_servers', arguments: {} });
97
+ assert.equal(listed.isError, undefined, `${scenario.name}: listing failed`);
98
+ let servers;
99
+ try { servers = JSON.parse(listed.content[0].text); } catch { throw new Error(`${scenario.name}: server listing is not JSON`); }
100
+ assert.ok(Array.isArray(servers) && servers.length === 2, `${scenario.name}: expected exactly the two fixture servers`);
101
+ assert.equal(tools.tools.length, 37, `${scenario.name}: expected all 37 tools`);
102
+ const schemas = Object.fromEntries(tools.tools.map(tool => [tool.name, canonical(tool.inputSchema)]).sort(([a], [b]) => a.localeCompare(b)));
103
+ assert.equal(Object.keys(schemas).length, 37, `${scenario.name}: duplicate tool names`);
104
+ finished = true; clearTimeout(timer); child.stdin.end();
105
+ const kill = setTimeout(() => child.kill(), 1000);
106
+ await exit; clearTimeout(kill);
107
+ resolve({ listing: canonical(servers.sort((a, b) => a.name.localeCompare(b.name))), schemas });
108
+ })().catch(fail);
109
+ });
110
+ }
111
+
112
+ const work = fs.mkdtempSync(path.join(os.tmpdir(), 'upgrade-real-'));
113
+ const salt = crypto.randomBytes(32).toString('hex');
114
+ const hash = value => crypto.createHmac('sha256', salt).update(JSON.stringify(value)).digest('hex');
115
+ const snapshots = new Map();
116
+ function remember(file, content) { fs.mkdirSync(path.dirname(file), { recursive: true }); fs.writeFileSync(file, content); snapshots.set(file, fs.readFileSync(file)); }
117
+
118
+ function scenario(name) {
119
+ const dir = path.join(work, name); fs.mkdirSync(dir);
120
+ const envFile = path.join(dir, '.env');
121
+ const tomlFile = path.join(dir, '.codex', 'ssh-config.toml');
122
+ // Exercise URL escaping even on POSIX: bare --import paths break on both
123
+ // Windows drive letters and filename characters interpreted as URL fragments.
124
+ const preload = path.join(dir, 'isolation # fixture.mjs');
125
+ const fields = { name: 'prod', host: `${name}.fixture.invalid`, user: 'fixture-user', password: 'fixture-password',
126
+ keyPath: '~/.ssh/fixture-key', passphrase: 'fixture-passphrase', port: 2222, defaultDir: '~/fixture folder',
127
+ sudoPassword: 'fixture-sudo', description: `${name} fixture`, group: 'fixture-group', platform: 'windows',
128
+ proxyJump: 'bastion', proxyCommand: 'ssh -W %h:%p fixture-bastion', forwardAgent: true,
129
+ mode: 'restricted', allowPatterns: ['^printf', '^echo'], denyPatterns: ['forbidden'], auditLog: path.join(dir, 'audit.jsonl').replaceAll('\\', '/'), source: name === 'toml' ? 'toml' : 'env' };
130
+ const mapping = { host: 'HOST', user: 'USER', password: 'PASSWORD', keyPath: 'KEYPATH', passphrase: 'PASSPHRASE', port: 'PORT',
131
+ defaultDir: 'DEFAULT_DIR', sudoPassword: 'SUDO_PASSWORD', description: 'DESCRIPTION', group: 'GROUP', platform: 'PLATFORM',
132
+ proxyJump: 'PROXYJUMP', proxyCommand: 'PROXYCOMMAND', forwardAgent: 'FORWARD_AGENT', mode: 'MODE',
133
+ allowPatterns: 'ALLOW_PATTERNS', denyPatterns: 'DENY_PATTERNS', auditLog: 'AUDIT_LOG' };
134
+ const tomlMapping = { keyPath: 'key_path', defaultDir: 'default_dir', sudoPassword: 'sudo_password',
135
+ proxyJump: 'proxy_jump', proxyCommand: 'proxy_command', forwardAgent: 'forward_agent',
136
+ allowPatterns: 'allow_patterns', denyPatterns: 'deny_patterns', auditLog: 'audit_log' };
137
+ const variables = { SSH_SERVER_BASTION_HOST: 'bastion.fixture.invalid', SSH_SERVER_BASTION_USER: 'fixture' };
138
+ for (const [key, suffix] of Object.entries(mapping)) variables[`SSH_SERVER_PROD_${suffix}`] = Array.isArray(fields[key]) ? fields[key].join(';') : String(fields[key]);
139
+ const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('SSH_') && !key.startsWith('MCP_SSH_') && key !== 'PREFER_TOML_CONFIG' && key !== 'NODE_OPTIONS'));
140
+ Object.assign(env, { NODE_ENV: 'test', SSH_ENV_PATH: envFile, SSH_CONFIG_PATH: tomlFile, SSH_MANAGER_HOME: path.join(dir, 'managed'),
141
+ SSH_MANAGER_VAULT: path.join(dir, 'managed', 'vault.json'), SSH_MANAGER_KEY_SOURCE: 'file',
142
+ SSH_LOG_FILE: path.join(dir, 'probe.log'), SSH_HISTORY_FILE: path.join(dir, 'history.json'), SSH_LOG_LEVEL: 'ERROR' });
143
+ // Fail if either release attempts to start a local server/UI during a stdio
144
+ // probe. The OS-home stub isolates old readers that predate SSH_MANAGER_HOME.
145
+ fs.writeFileSync(preload, `import os from 'node:os'; import net from 'node:net'; import {syncBuiltinESMExports} from 'node:module'; os.homedir=()=>${JSON.stringify(dir)}; net.Server.prototype.listen=function(){throw new Error('Unexpected network listener in a headless probe');}; syncBuiltinESMExports();`);
146
+ if (name === 'toml') {
147
+ remember(envFile, '# TOML setup has no env server definitions\n');
148
+ remember(tomlFile, `[ssh_servers.bastion]\nhost = "bastion.fixture.invalid"\nuser = "fixture"\n\n[ssh_servers.prod]\n` + Object.keys(mapping).map(key => `${tomlMapping[key] || key} = ${JSON.stringify(fields[key])}`).join('\n') + '\n');
149
+ } else {
150
+ remember(envFile, name === 'environment' ? '# credentials supplied by the MCP client environment\n'
151
+ : Object.entries(variables).map(([key, value]) => `${key}=${JSON.stringify(value)}`).join('\n') + '\n');
152
+ if (name === 'environment') Object.assign(env, variables);
153
+ }
154
+ return { name, dir, envFile, tomlFile, preload, env, fields };
155
+ }
156
+
157
+ function loaderSnapshot(installed, item) {
158
+ const helper = path.join(item.dir, 'loader-probe.mjs');
159
+ fs.writeFileSync(helper, `import crypto from 'node:crypto';
160
+ import {ConfigLoader} from ${JSON.stringify(pathToFileURL(path.join(installed, 'src/config-loader.js')).href)};
161
+ const loaded=await new ConfigLoader().load(${JSON.stringify({ envPath: item.envFile, tomlPath: item.tomlFile })});
162
+ const fields=${JSON.stringify(FIELDS)};
163
+ const result=Object.fromEntries([...loaded].sort(([a],[b])=>a.localeCompare(b)).map(([name,config])=>[name,Object.fromEntries(fields.map(field=>[field,{present:Object.hasOwn(config,field),kind:typeof config[field],hash:crypto.createHmac('sha256',${JSON.stringify(salt)}).update(JSON.stringify(config[field]===undefined?{undefined:true}:config[field])).digest('hex')}]))]));
164
+ process.stdout.write(JSON.stringify(result));`);
165
+ let output;
166
+ try { output = execFileSync(process.execPath, ['--import', pathToFileURL(item.preload).href, helper], { cwd: item.dir, env: item.env, encoding: 'utf8', timeout: 15000, stdio: ['ignore', 'pipe', 'pipe'] }); }
167
+ catch (error) {
168
+ const diagnostic = String(error.stderr || '').match(/\bERR_[A-Z0-9_]+\b/)?.[0];
169
+ throw new Error(`${item.name}: isolated ConfigLoader probe failed (exit ${error.status ?? error.code}${diagnostic ? `, ${diagnostic}` : ''})`);
170
+ }
171
+ const snapshot = JSON.parse(output);
172
+ assert.deepEqual(Object.keys(snapshot).sort(), ['bastion', 'prod'], `${item.name}: missing loader fixture servers`);
173
+ for (const field of FIELDS) {
174
+ assert.equal(snapshot.prod[field]?.kind, typeof item.fields[field], `${item.name}: ${field} missing or mistyped`);
175
+ assert.equal(snapshot.prod[field]?.hash, hash(item.fields[field]), `${item.name}: ${field} changed from the configured fixture`);
176
+ }
177
+ return snapshot;
178
+ }
179
+
180
+ function untouched(scenarios) {
181
+ for (const [file, before] of snapshots) assert.ok(fs.readFileSync(file).equals(before), `${path.basename(file)} was modified`);
182
+ for (const item of scenarios) {
183
+ for (const name of ['managed', '.ssh-manager', 'vault.json', 'vault.key', '.server-groups.json', 'commands.json', 'commands.log.jsonl']) {
184
+ assert.equal(fs.existsSync(path.join(item.dir, name)), false, `${item.name}: unexpected opt-in state ${name}`);
185
+ }
186
+ }
187
+ }
188
+
189
+ async function main() {
190
+ try {
191
+ const scenarios = ['env', 'toml', 'environment'].map(scenario);
192
+ const install = path.join(work, 'installation'); fs.mkdirSync(install);
193
+ remember(path.join(install, 'package.json'), '{"name":"upgrade-regression","version":"1.0.0","private":true}\n');
194
+ // npm intentionally updates this manifest; the original user config files
195
+ // above are the byte-preservation contract, not npm's dependency bookkeeping.
196
+ snapshots.delete(path.join(install, 'package.json'));
197
+ const installed = path.join(install, 'node_modules', 'mcp-ssh-manager');
198
+ const packageVersion = () => JSON.parse(fs.readFileSync(path.join(installed, 'package.json'), 'utf8')).version;
199
+ const installPrevious = () => npm(['install', `mcp-ssh-manager@${PREVIOUS}`, '--no-audit', '--no-fund', '--silent', '--registry=https://registry.npmjs.org'], install);
200
+ installPrevious(); assert.equal(packageVersion(), PREVIOUS); ok(`registry ${PREVIOUS} installed`);
201
+ const before = {};
202
+ for (const item of scenarios) before[item.name] = { protocol: await interrogate(item, path.join(installed, 'src/index.js')), loader: loaderSnapshot(installed, item) };
203
+ untouched(scenarios); ok('previous release: .env, TOML and environment each preserve all 20 effective fields and expose 37 tools');
204
+ const pack = JSON.parse(npm(['pack', '--json', '--pack-destination', work], ROOT));
205
+ assert.equal(pack.length, 1, 'npm pack must produce one artifact');
206
+ npm(['install', path.join(work, pack[0].filename), '--no-audit', '--no-fund', '--silent'], install);
207
+ const current = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8')).version;
208
+ assert.equal(packageVersion(), current); ok(`installed packed ${current} over ${PREVIOUS}`);
209
+ for (const item of scenarios) {
210
+ const after = { protocol: await interrogate(item, path.join(installed, 'src/index.js')), loader: loaderSnapshot(installed, item) };
211
+ assert.deepEqual(after.loader, before[item.name].loader, `${item.name}: effective ConfigLoader field fingerprints differ`);
212
+ assert.deepEqual(after.protocol.listing, before[item.name].protocol.listing, `${item.name}: MCP listing changed`);
213
+ assert.deepEqual(after.protocol.schemas, before[item.name].protocol.schemas, `${item.name}: MCP tool names or input schemas changed`);
214
+ ok(`${item.name}: effective fields, MCP listing and all 37 tool input schemas unchanged`);
215
+ }
216
+ untouched(scenarios); ok('upgrade leaves original config bytes intact and starts no UI, listener, prompt or vault');
217
+ installPrevious(); assert.equal(packageVersion(), PREVIOUS);
218
+ for (const item of scenarios) {
219
+ const rollback = { protocol: await interrogate(item, path.join(installed, 'src/index.js')), loader: loaderSnapshot(installed, item) };
220
+ assert.deepEqual(rollback, before[item.name], `${item.name}: rollback differs from the previous release`);
221
+ }
222
+ untouched(scenarios); ok(`rollback to registry ${PREVIOUS} restores identical behavior for all three configurations`);
223
+ console.log(`\nUpgrade ${PREVIOUS} → ${current} → ${PREVIOUS}: ${passed} checks passed`);
224
+ } finally { fs.rmSync(work, { recursive: true, force: true }); }
225
+ }
226
+ main().catch(error => { console.error(`Upgrade check failed: ${error.message}`); process.exitCode = 1; });
@@ -0,0 +1,153 @@
1
+ #!/usr/bin/env bash
2
+ #
3
+ # Is this build actually shippable?
4
+ #
5
+ # Every failure this checks for has already happened here, and none of them were
6
+ # visible from the build log — which exited 0 each time:
7
+ #
8
+ # - the engine shipped with an empty node_modules, so every downloaded copy
9
+ # died on launch with "Cannot find package 'dotenv'"
10
+ # - the menu-bar glyph was left out of the asar, which would have thrown
11
+ # inside `new Tray` and taken the app down
12
+ # - the app is signed but not notarized, so anyone who *downloads* it is told
13
+ # macOS cannot check it — invisible on the machine that built it, because a
14
+ # locally produced file carries no quarantine attribute
15
+ #
16
+ # Run it on the artifact you are about to publish, not on the tree that made it.
17
+ #
18
+ # Usage: scripts/verify-mac-build.sh [path/to/SSH Manager.app]
19
+ set -uo pipefail
20
+
21
+ APP="${1:-desktop/electron/dist/mac-arm64/SSH Manager.app}"
22
+ FAIL=0
23
+ pass() { printf ' \033[32m✓\033[0m %s\n' "$1"; }
24
+ fail() { printf ' \033[31m✗\033[0m %s\n' "$1"; FAIL=1; }
25
+ warn() { printf ' \033[33m!\033[0m %s\n' "$1"; }
26
+
27
+ [ -d "$APP" ] || { echo "No app at: $APP"; exit 1; }
28
+ echo "Checking $APP"
29
+ echo
30
+
31
+ # --- it is what it says it is ------------------------------------------------
32
+ # Read once into a variable, then match against that. Piping into `grep -q`
33
+ # under `set -o pipefail` is a trap: grep exits at the first match, codesign
34
+ # dies of SIGPIPE writing the rest, and the pipeline reports 141 — but only
35
+ # sometimes, depending on whether codesign had already finished. It reported a
36
+ # correctly signed app as unsigned on roughly every other run.
37
+ SIG=$(codesign -dv --verbose=2 "$APP" 2>&1)
38
+
39
+ ID=$(sed -n 's/^Identifier=//p' <<<"$SIG")
40
+ [ "$ID" = "com.bvisible.ssh-manager" ] \
41
+ && pass "bundle identifier is $ID" \
42
+ || fail "bundle identifier is '$ID', expected com.bvisible.ssh-manager"
43
+
44
+ if codesign --verify --deep --strict "$APP" 2>/dev/null; then
45
+ pass "signature is valid, all the way down"
46
+ else
47
+ fail "signature does not verify — codesign --verify --deep --strict failed"
48
+ fi
49
+
50
+ case "$SIG" in
51
+ *"Authority=Developer ID Application"*)
52
+ pass "signed with a Developer ID Application certificate" ;;
53
+ *)
54
+ fail "not signed with a Developer ID — it will not open on another machine" ;;
55
+ esac
56
+
57
+ # --- it will open on somebody else's machine ---------------------------------
58
+ GK=$(spctl -a -vvv -t exec "$APP" 2>&1)
59
+ if grep -q 'accepted' <<<"$GK"; then
60
+ pass "Gatekeeper accepts it"
61
+ elif grep -q 'Unnotarized' <<<"$GK"; then
62
+ fail "NOT NOTARIZED — a downloader gets \"cannot check it for malicious software\". See docs/DISTRIBUTION.md"
63
+ else
64
+ fail "Gatekeeper rejects it: $(head -2 <<<"$GK" | tr '\n' ' ')"
65
+ fi
66
+
67
+ if xcrun stapler validate "$APP" >/dev/null 2>&1; then
68
+ pass "the notarization ticket is stapled to the app"
69
+ else
70
+ fail "no stapled ticket on the app"
71
+ fi
72
+
73
+ # And on the DMG, which is the file people actually download. electron-builder
74
+ # notarizes the .app *before* packaging it, so Apple has no ticket for the disk
75
+ # image and `stapler staple` on it fails with "could not find base64 encoded
76
+ # ticket". The DMG has to be submitted on its own — see docs/DISTRIBUTION.md.
77
+ APP_VERSION=$(/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' "$APP/Contents/Info.plist")
78
+ APP_ARCH=$(lipo -archs "$APP/Contents/MacOS/SSH Manager" 2>/dev/null)
79
+ [ "$APP_ARCH" != x86_64 ] || APP_ARCH=x64
80
+ DMG=$(find "$(dirname "$APP")/.." -maxdepth 1 -name "*-${APP_VERSION}-${APP_ARCH}.dmg" -type f -print -quit)
81
+ if [ -n "$DMG" ]; then
82
+ if xcrun stapler validate "$DMG" >/dev/null 2>&1; then
83
+ pass "and to the DMG, so it opens offline too"
84
+ else
85
+ fail "the matching DMG has no stapled ticket"
86
+ fi
87
+ # The disk image carries its own signature (dmg.sign), so every Apple tool
88
+ # agrees it is distributable, not only the double-click.
89
+ if codesign --verify --strict "$DMG" >/dev/null 2>&1 \
90
+ && spctl --assess --type open --context context:primary-signature "$DMG" >/dev/null 2>&1; then
91
+ pass "the DMG itself is signed and accepted"
92
+ else
93
+ fail "the matching DMG is not signed, or Gatekeeper refuses its signature"
94
+ fi
95
+ else
96
+ fail "no matching ${APP_ARCH} DMG for version ${APP_VERSION}"
97
+ fi
98
+
99
+ # --- it carries all of itself ------------------------------------------------
100
+ ENGINE="$APP/Contents/Resources/engine"
101
+ COUNT=$(ls "$ENGINE/node_modules" 2>/dev/null | wc -l | tr -d ' ')
102
+ [ "${COUNT:-0}" -ge 50 ] \
103
+ && pass "the engine has its dependencies ($COUNT packages)" \
104
+ || fail "the engine has $COUNT packages — it will die on 'Cannot find package'"
105
+
106
+ for module in dotenv ssh2 @modelcontextprotocol; do
107
+ [ -e "$ENGINE/node_modules/$module" ] \
108
+ && pass " $module is present" \
109
+ || fail " $module is MISSING"
110
+ done
111
+
112
+ [ -f "$ENGINE/dist/ui/index.html" ] \
113
+ && pass "the interface is bundled" \
114
+ || fail "no dist/ui — the window would load nothing"
115
+
116
+ # --- the local shell ---------------------------------------------------------
117
+ # node-pty runs spawn-helper for every pseudo-terminal it opens, and the npm
118
+ # tarball ships it as 644. Without the bit, the first local shell dies on
119
+ # `posix_spawnp failed` — in the packaged build only, because a developer's
120
+ # checkout usually has a chmod'd copy from somewhere.
121
+ HELPER=$(find "$APP/Contents/Resources" -name spawn-helper -type f 2>/dev/null | head -1)
122
+ if [ -z "$HELPER" ]; then
123
+ fail "no local shell in this build (node-pty is not packaged)"
124
+ elif [ -x "$HELPER" ]; then
125
+ pass "the local shell's spawn helper is executable"
126
+ else
127
+ fail "spawn-helper is not executable — every local shell would fail to start"
128
+ fi
129
+
130
+ # --- the pieces the app reads at runtime -------------------------------------
131
+ ASAR="$APP/Contents/Resources/app.asar"
132
+ # `asar` is a dependency of electron-builder, so it lives under the desktop
133
+ # shell and not at the repository root — `npx --no-install asar` from here
134
+ # finds nothing and this check quietly degraded to a warning, in CI included.
135
+ ASAR_BIN="$(dirname "$0")/../desktop/electron/node_modules/.bin/asar"
136
+ ASAR_LIST=$(
137
+ if [ -x "$ASAR_BIN" ]; then "$ASAR_BIN" list "$ASAR" 2>/dev/null
138
+ else npx --no-install asar list "$ASAR" 2>/dev/null
139
+ fi || true
140
+ )
141
+ case "$ASAR_LIST" in
142
+ *trayTemplate.png*) pass "the menu-bar icon is in the asar" ;;
143
+ '') fail "could not read the asar (is @electron/asar installed?)" ;;
144
+ *) fail "trayTemplate.png is not packaged — there would be no menu bar item" ;;
145
+ esac
146
+
147
+ echo
148
+ if [ "$FAIL" -eq 0 ]; then
149
+ printf '\033[32mReady to publish.\033[0m\n'
150
+ else
151
+ printf '\033[31mNot shippable yet — see the failures above.\033[0m\n'
152
+ exit 1
153
+ fi
@@ -0,0 +1,15 @@
1
+ param([string]$Directory = "desktop/electron/dist", [switch]$RequireSigned)
2
+ $ErrorActionPreference = "Stop"
3
+ $files = @(Get-ChildItem $Directory -Filter "*-setup.exe")
4
+ if ($files.Count -ne 1) { throw "Expected exactly one Windows installer" }
5
+ $files += @(Get-ChildItem $Directory -Recurse -Filter "SSH Manager.exe")
6
+ if ($files.Count -lt 3) { throw "Missing packaged x64/arm64 executables" }
7
+ foreach ($file in $files) {
8
+ $signature = Get-AuthenticodeSignature $file.FullName
9
+ if ($signature.Status -ne "Valid") {
10
+ if ($RequireSigned) { throw "Invalid Authenticode signature: $($file.Name) ($($signature.Status))" }
11
+ Write-Warning "DRY RUN / PRERELEASE ONLY: $($file.Name) is not validly signed ($($signature.Status))"
12
+ } else {
13
+ Write-Host "Valid Authenticode signature: $($file.Name), publisher $($signature.SignerCertificate.Subject)"
14
+ }
15
+ }
package/server.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
3
  "name": "io.github.bvisible/mcp-ssh-manager",
4
- "description": "SSH server management for agents, with per-server read-only and allowlist security modes",
4
+ "description": "SSH for AI agents: commands, files, backups and health, with approval, a vault and an audit trail",
5
5
  "repository": {
6
6
  "url": "https://github.com/bvisible/mcp-ssh-manager",
7
7
  "source": "github"
8
8
  },
9
- "version": "3.8.7",
9
+ "version": "4.0.1",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "mcp-ssh-manager",
14
- "version": "3.8.7",
14
+ "version": "4.0.1",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  },
@@ -0,0 +1,42 @@
1
+ # Skills
2
+
3
+ Packaged instructions so an agent uses these tools well — the things it cannot
4
+ infer from a tool description, because they are about judgement rather than
5
+ syntax.
6
+
7
+ | Skill | When it fires |
8
+ |---|---|
9
+ | `ssh-operations` | Any task that deploys, backs up, restarts, or runs commands on a server |
10
+ | `ssh-incident` | "The server is down", "the site is slow", "something broke" |
11
+ | `ssh-restricted` | A tool was refused: security modes and human approval |
12
+
13
+ They are deliberately short. A skill that reads like a manual gets skimmed; these
14
+ say the few things that actually change what an agent does — look before you
15
+ change, back up before you overwrite, read the log before restarting, and treat
16
+ a refusal as the system working rather than an obstacle.
17
+
18
+ ## Installing them
19
+
20
+ They ship with the npm package, so they are already on disk once it is installed.
21
+ Copy the ones you want into your agent's skills directory:
22
+
23
+ ```bash
24
+ # Claude Code, user-wide
25
+ cp -r "$(npm root -g)/mcp-ssh-manager/skills/"* ~/.claude/skills/
26
+
27
+ # or for one project
28
+ mkdir -p .claude/skills && cp -r "$(npm root -g)/mcp-ssh-manager/skills/"* .claude/skills/
29
+ ```
30
+
31
+ From a clone, `cp -r skills/* ~/.claude/skills/`.
32
+
33
+ ## Writing your own
34
+
35
+ Your servers have habits these cannot know: a deploy that must run from a
36
+ particular directory, a service that has to be drained before restarting, a
37
+ database that must never be dumped during business hours. Those belong in a skill
38
+ of your own, next to these.
39
+
40
+ The format is a directory with a `SKILL.md`, front matter carrying `name` and
41
+ `description`. The description is what decides whether the skill is loaded, so
42
+ write it as the situation, not as a summary of the contents.