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
package/src/xlsx.js ADDED
@@ -0,0 +1,322 @@
1
+ /**
2
+ * Reading and writing one-sheet spreadsheets, without a dependency.
3
+ *
4
+ * ## Why not a library
5
+ *
6
+ * People asked to fill in a spreadsheet, which is a reasonable thing to want and
7
+ * the reason CSV keeps losing: a CSV opened in Excel mangles a leading zero in a
8
+ * port, guesses at the separator by locale, and offers no column headers you can
9
+ * rely on. A real `.xlsx` avoids all three.
10
+ *
11
+ * The obvious way to read one is SheetJS, which is seven megabytes. This package
12
+ * is 730 KB and installs on machines whose whole job is to sit behind SSH; a
13
+ * tenfold increase for one import path is not a trade worth making.
14
+ *
15
+ * An `.xlsx` is a ZIP of XML files. Node ships `zlib`, which is the hard half.
16
+ * The rest is a few hundred lines of container format, written here, tested
17
+ * against files Excel and LibreOffice actually produce.
18
+ *
19
+ * ## What this handles, and what it does not
20
+ *
21
+ * One sheet, a header row, and cells that are text or numbers — which is exactly
22
+ * what a server list is. Not: formulas, dates, styles, merged cells, multiple
23
+ * sheets. A file using any of those still reads; the extra is ignored.
24
+ */
25
+ import zlib from 'zlib';
26
+
27
+ /* ------------------------------------------------------------------ the ZIP */
28
+
29
+ const CRC_TABLE = (() => {
30
+ const table = new Int32Array(256);
31
+ for (let n = 0; n < 256; n++) {
32
+ let c = n;
33
+ for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
34
+ table[n] = c;
35
+ }
36
+ return table;
37
+ })();
38
+
39
+ /** @param {Buffer} buf @returns {number} CRC-32, as the ZIP format wants it */
40
+ function crc32(buf) {
41
+ let c = -1;
42
+ for (let i = 0; i < buf.length; i++) c = CRC_TABLE[(c ^ buf[i]) & 0xff] ^ (c >>> 8);
43
+ return (c ^ -1) >>> 0;
44
+ }
45
+
46
+ /**
47
+ * Build a ZIP archive from named buffers.
48
+ *
49
+ * Everything is deflated and stored without directory entries — a `.xlsx` is
50
+ * read by name, so the tree structure is implied by the paths.
51
+ *
52
+ * @param {{name: string, data: Buffer}[]} entries
53
+ * @returns {Buffer}
54
+ */
55
+ function zip(entries) {
56
+ const locals = [];
57
+ const central = [];
58
+ let offset = 0;
59
+
60
+ for (const entry of entries) {
61
+ const name = Buffer.from(entry.name, 'utf8');
62
+ const deflated = zlib.deflateRawSync(entry.data, { level: 9 });
63
+ const sum = crc32(entry.data);
64
+
65
+ const local = Buffer.alloc(30 + name.length);
66
+ local.writeUInt32LE(0x04034b50, 0);
67
+ local.writeUInt16LE(20, 4); // version needed
68
+ local.writeUInt16LE(0, 6); // flags
69
+ local.writeUInt16LE(8, 8); // deflate
70
+ local.writeUInt16LE(0, 10); // time — fixed, so output is reproducible
71
+ local.writeUInt16LE(0x21, 12); // date — 1980-01-01
72
+ local.writeUInt32LE(sum, 14);
73
+ local.writeUInt32LE(deflated.length, 18);
74
+ local.writeUInt32LE(entry.data.length, 22);
75
+ local.writeUInt16LE(name.length, 26);
76
+ local.writeUInt16LE(0, 28);
77
+ name.copy(local, 30);
78
+ locals.push(local, deflated);
79
+
80
+ const dir = Buffer.alloc(46 + name.length);
81
+ dir.writeUInt32LE(0x02014b50, 0);
82
+ dir.writeUInt16LE(20, 4);
83
+ dir.writeUInt16LE(20, 6);
84
+ dir.writeUInt16LE(0, 8);
85
+ dir.writeUInt16LE(8, 10);
86
+ dir.writeUInt16LE(0, 12);
87
+ dir.writeUInt16LE(0x21, 14);
88
+ dir.writeUInt32LE(sum, 16);
89
+ dir.writeUInt32LE(deflated.length, 20);
90
+ dir.writeUInt32LE(entry.data.length, 24);
91
+ dir.writeUInt16LE(name.length, 28);
92
+ dir.writeUInt32LE(0, 42); // external attributes
93
+ dir.writeUInt32LE(offset, 42);
94
+ name.copy(dir, 46);
95
+ central.push(dir);
96
+
97
+ offset += local.length + deflated.length;
98
+ }
99
+
100
+ const directory = Buffer.concat(central);
101
+ const end = Buffer.alloc(22);
102
+ end.writeUInt32LE(0x06054b50, 0);
103
+ end.writeUInt16LE(entries.length, 8);
104
+ end.writeUInt16LE(entries.length, 10);
105
+ end.writeUInt32LE(directory.length, 12);
106
+ end.writeUInt32LE(offset, 16);
107
+
108
+ return Buffer.concat([...locals, directory, end]);
109
+ }
110
+
111
+ /**
112
+ * Read a ZIP archive into a map of name → contents.
113
+ *
114
+ * Walks the central directory rather than scanning for local headers: the
115
+ * directory is authoritative, and a file whose entries were rewritten in place
116
+ * (which Excel does) can carry stale local headers.
117
+ *
118
+ * @param {Buffer} buf
119
+ * @returns {Map<string, Buffer>}
120
+ */
121
+ function unzip(buf) {
122
+ // The end-of-central-directory record is last, but a trailing comment can push
123
+ // it back up to 64 KB from the end, so scan backwards for its signature.
124
+ let end = -1;
125
+ for (let i = buf.length - 22; i >= 0 && i > buf.length - 65558; i--) {
126
+ if (buf.readUInt32LE(i) === 0x06054b50) { end = i; break; }
127
+ }
128
+ if (end < 0) throw new Error('Not a zip file (no end-of-central-directory record)');
129
+
130
+ const count = buf.readUInt16LE(end + 10);
131
+ let at = buf.readUInt32LE(end + 16);
132
+ /** @type {Map<string, Buffer>} */
133
+ const files = new Map();
134
+
135
+ for (let i = 0; i < count; i++) {
136
+ if (buf.readUInt32LE(at) !== 0x02014b50) break;
137
+ const method = buf.readUInt16LE(at + 10);
138
+ const compressed = buf.readUInt32LE(at + 20);
139
+ const nameLength = buf.readUInt16LE(at + 28);
140
+ const extraLength = buf.readUInt16LE(at + 30);
141
+ const commentLength = buf.readUInt16LE(at + 32);
142
+ const localAt = buf.readUInt32LE(at + 42);
143
+ const name = buf.toString('utf8', at + 46, at + 46 + nameLength);
144
+
145
+ // The local header's own name and extra lengths are what locate the data;
146
+ // they are allowed to differ from the central directory's.
147
+ const localNameLength = buf.readUInt16LE(localAt + 26);
148
+ const localExtraLength = buf.readUInt16LE(localAt + 28);
149
+ const dataAt = localAt + 30 + localNameLength + localExtraLength;
150
+ const raw = buf.subarray(dataAt, dataAt + compressed);
151
+
152
+ if (!name.endsWith('/')) {
153
+ files.set(name, method === 0 ? Buffer.from(raw) : zlib.inflateRawSync(raw));
154
+ }
155
+ at += 46 + nameLength + extraLength + commentLength;
156
+ }
157
+ return files;
158
+ }
159
+
160
+ /* ------------------------------------------------------------------ the XML */
161
+
162
+ const ESCAPES = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', '\'': '&apos;' };
163
+ const escape = value => String(value).replace(/[&<>"']/g, c => ESCAPES[c]);
164
+
165
+ const UNESCAPES = { amp: '&', lt: '<', gt: '>', quot: '"', apos: '\'' };
166
+ const unescape = text => text.replace(/&(amp|lt|gt|quot|apos|#\d+|#x[0-9a-fA-F]+);/g,
167
+ (_, entity) => {
168
+ if (entity[0] !== '#') return UNESCAPES[entity];
169
+ return String.fromCodePoint(entity[1] === 'x'
170
+ ? parseInt(entity.slice(2), 16)
171
+ : parseInt(entity.slice(1), 10));
172
+ });
173
+
174
+ /** A1 → column 0, B1 → 1, AA1 → 26. Cells can be sparse, so this is how gaps are found. */
175
+ function columnOf(reference) {
176
+ let n = 0;
177
+ for (const ch of reference) {
178
+ const code = ch.charCodeAt(0);
179
+ if (code < 65 || code > 90) break;
180
+ n = n * 26 + (code - 64);
181
+ }
182
+ return n - 1;
183
+ }
184
+
185
+ /* --------------------------------------------------------------------- read */
186
+
187
+ /**
188
+ * Read the first worksheet as rows of strings.
189
+ *
190
+ * @param {Buffer} buf - The .xlsx file
191
+ * @returns {string[][]} Rows, each padded to the widest row seen
192
+ */
193
+ export function readSheet(buf) {
194
+ const files = unzip(buf);
195
+
196
+ // Excel puts every string in one table and refers to it by index; LibreOffice
197
+ // sometimes writes them inline. Both shapes appear in the wild.
198
+ /** @type {string[]} */
199
+ const shared = [];
200
+ const sharedXml = files.get('xl/sharedStrings.xml');
201
+ if (sharedXml) {
202
+ for (const item of sharedXml.toString('utf8').split(/<si[\s>]/).slice(1)) {
203
+ // A string can be split across runs; concatenate every <t> in the item.
204
+ const parts = [...item.matchAll(/<t[^>]*>([\s\S]*?)<\/t>/g)].map(m => unescape(m[1]));
205
+ shared.push(parts.join(''));
206
+ }
207
+ }
208
+
209
+ const sheetName = [...files.keys()].find(name => /^xl\/worksheets\/sheet\d+\.xml$/.test(name));
210
+ if (!sheetName) throw new Error('No worksheet in this file');
211
+ const sheet = files.get(sheetName).toString('utf8');
212
+
213
+ /** @type {string[][]} */
214
+ const rows = [];
215
+ let width = 0;
216
+
217
+ for (const rowXml of sheet.split(/<row[\s>]/).slice(1)) {
218
+ /** @type {string[]} */
219
+ const row = [];
220
+ for (const cell of rowXml.matchAll(/<c\s([^>]*?)\/?>([\s\S]*?)(?:<\/c>|$)/g)) {
221
+ const attributes = cell[1];
222
+ const body = cell[2];
223
+ const reference = /r="([A-Z]+\d+)"/.exec(attributes)?.[1];
224
+ const index = reference ? columnOf(reference) : row.length;
225
+ const type = /t="([^"]+)"/.exec(attributes)?.[1];
226
+
227
+ let value = '';
228
+ if (type === 's') {
229
+ const at = Number(/<v>(\d+)<\/v>/.exec(body)?.[1]);
230
+ value = shared[at] ?? '';
231
+ } else if (type === 'inlineStr') {
232
+ value = [...body.matchAll(/<t[^>]*>([\s\S]*?)<\/t>/g)].map(m => unescape(m[1])).join('');
233
+ } else {
234
+ value = unescape(/<v>([\s\S]*?)<\/v>/.exec(body)?.[1] ?? '');
235
+ }
236
+
237
+ while (row.length < index) row.push('');
238
+ row[index] = value.trim();
239
+ }
240
+ width = Math.max(width, row.length);
241
+ rows.push(row);
242
+ }
243
+
244
+ for (const row of rows) while (row.length < width) row.push('');
245
+ return rows;
246
+ }
247
+
248
+ /* -------------------------------------------------------------------- write */
249
+
250
+ /**
251
+ * Write one sheet as a .xlsx.
252
+ *
253
+ * Everything is an inline string, which sidesteps the shared-string table
254
+ * entirely. The file is a little larger and a great deal easier to be sure
255
+ * about; a server list is tens of rows, not tens of thousands.
256
+ *
257
+ * @param {string[][]} rows - First row is treated as the header
258
+ * @param {{sheetName?: string, widths?: number[]}} [options]
259
+ * @returns {Buffer}
260
+ */
261
+ export function writeSheet(rows, options = {}) {
262
+ const sheetName = options.sheetName || 'Servers';
263
+ const columns = (options.widths || []).map(
264
+ (width, i) => `<col min="${i + 1}" max="${i + 1}" width="${width}" customWidth="1"/>`).join('');
265
+
266
+ const body = rows.map((row, r) => {
267
+ const cells = row.map((value, c) => {
268
+ const reference = `${String.fromCharCode(65 + (c % 26))}${r + 1}`;
269
+ if (value === '' || value === null || value === undefined) return '';
270
+ // The header row is bold, via the one style defined below.
271
+ const style = r === 0 ? ' s="1"' : '';
272
+ return `<c r="${reference}"${style} t="inlineStr"><is><t xml:space="preserve">${escape(value)}</t></is></c>`;
273
+ }).join('');
274
+ return `<row r="${r + 1}">${cells}</row>`;
275
+ }).join('');
276
+
277
+ const files = [
278
+ ['[Content_Types].xml',
279
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
280
+ + '<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">'
281
+ + '<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>'
282
+ + '<Default Extension="xml" ContentType="application/xml"/>'
283
+ + '<Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/>'
284
+ + '<Override PartName="/xl/worksheets/sheet1.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>'
285
+ + '<Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'
286
+ + '</Types>'],
287
+ ['_rels/.rels',
288
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
289
+ + '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'
290
+ + '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/>'
291
+ + '</Relationships>'],
292
+ ['xl/workbook.xml',
293
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
294
+ + '<workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"'
295
+ + ' xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">'
296
+ + `<sheets><sheet name="${escape(sheetName)}" sheetId="1" r:id="rId1"/></sheets></workbook>`],
297
+ ['xl/_rels/workbook.xml.rels',
298
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
299
+ + '<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">'
300
+ + '<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/>'
301
+ + '<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'
302
+ + '</Relationships>'],
303
+ // Two fonts and two formats: the second of each is the bold header.
304
+ ['xl/styles.xml',
305
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
306
+ + '<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">'
307
+ + '<fonts count="2"><font><sz val="11"/><name val="Calibri"/></font>'
308
+ + '<font><b/><sz val="11"/><name val="Calibri"/></font></fonts>'
309
+ + '<fills count="1"><fill><patternFill patternType="none"/></fill></fills>'
310
+ + '<borders count="1"><border/></borders>'
311
+ + '<cellStyleXfs count="1"><xf/></cellStyleXfs>'
312
+ + '<cellXfs count="2"><xf xfId="0"/><xf xfId="0" fontId="1" applyFont="1"/></cellXfs>'
313
+ + '</styleSheet>'],
314
+ ['xl/worksheets/sheet1.xml',
315
+ '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
316
+ + '<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">'
317
+ + (columns ? `<cols>${columns}</cols>` : '')
318
+ + `<sheetData>${body}</sheetData></worksheet>`],
319
+ ];
320
+
321
+ return zip(files.map(([name, xml]) => ({ name, data: Buffer.from(xml, 'utf8') })));
322
+ }
Binary file
Binary file