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.
- package/.eslintignore +5 -0
- package/.gitattributes +5 -0
- package/CHANGELOG.md +371 -6
- package/CLAUDE.md +6 -0
- package/CODE_OF_CONDUCT.md +18 -0
- package/CONTRIBUTING.md +30 -0
- package/Formula/ssh-manager.rb +60 -0
- package/README.md +484 -964
- package/ROADMAP-V4.md +451 -0
- package/brand/README.md +43 -0
- package/brand/icon.svg +32 -0
- package/brand/mark.svg +18 -0
- package/brand/wordmark.svg +30 -0
- package/cli/app.js +230 -0
- package/cli/control.js +116 -0
- package/cli/lib/colors.sh +15 -0
- package/cli/lib/menu.sh +145 -96
- package/cli/portability.js +186 -0
- package/cli/ssh-manager +197 -91
- package/cli/ssh-manager.js +14 -0
- package/cli/style.js +17 -0
- package/cli/vault.js +411 -0
- package/desktop/ControlPlaneApp.swift +219 -0
- package/desktop/build.sh +58 -0
- package/desktop/electron/after-pack.cjs +39 -0
- package/desktop/electron/electron-builder.yml +148 -0
- package/desktop/electron/finalize-artifacts.mjs +83 -0
- package/desktop/electron/main.js +815 -0
- package/desktop/electron/package-lock.json +3656 -0
- package/desktop/electron/package.json +30 -0
- package/desktop/electron/prepare-engine.mjs +84 -0
- package/desktop/electron/resources/entitlements.mac.plist +22 -0
- package/desktop/electron/resources/icon.png +0 -0
- package/desktop/electron/resources/trayTemplate.png +0 -0
- package/desktop/electron/resources/trayTemplate@2x.png +0 -0
- package/desktop/electron/smoke-test.mjs +184 -0
- package/dist/ui/app.css +1 -0
- package/dist/ui/app.js +501 -0
- package/dist/ui/assets/Forum-Regular.woff2 +0 -0
- package/dist/ui/assets/JetBrainsMono-Bold.woff2 +0 -0
- package/dist/ui/assets/JetBrainsMono-Regular.woff2 +0 -0
- package/dist/ui/assets/Karla-Variable.woff2 +0 -0
- package/dist/ui/index.html +16 -0
- package/docs/DISTRIBUTION.md +136 -0
- package/docs/FINAL-TEST-V4.md +209 -0
- package/docs/MIGRATION.md +334 -0
- package/docs/TESTING-V4.md +119 -0
- package/docs/superpowers/specs/2026-10-08-desktop-from-npm-and-cli-design.md +187 -0
- package/docs/videos/control-plane.mp4 +0 -0
- package/package.json +61 -30
- package/scripts/build-interface.mjs +73 -0
- package/scripts/capture-screenshots.mjs +191 -0
- package/scripts/demo-env.mjs +461 -0
- package/scripts/frame-screenshots.py +176 -0
- package/scripts/macbook-mockup.py +296 -0
- package/scripts/make-tray-icon.py +61 -0
- package/scripts/preview-candidate.mjs +291 -0
- package/scripts/publish-desktop.mjs +46 -0
- package/scripts/record-demo.mjs +229 -0
- package/scripts/release-version.mjs +32 -0
- package/scripts/render-cli-menu.py +157 -0
- package/scripts/requirements-dev.in +12 -0
- package/scripts/requirements-dev.txt +424 -0
- package/scripts/run-ui-regression.mjs +48 -0
- package/scripts/setup-hooks.sh +7 -13
- package/scripts/smoke-desktop.mjs +80 -0
- package/scripts/test-drag-and-drop.mjs +114 -0
- package/scripts/test-first-run.mjs +5 -0
- package/scripts/test-import-ui.mjs +5 -0
- package/scripts/test-preferences-persist.mjs +5 -0
- package/scripts/test-upgrade-from-published.mjs +226 -0
- package/scripts/verify-mac-build.sh +153 -0
- package/scripts/verify-windows-build.ps1 +15 -0
- package/server.json +3 -3
- package/skills/README.md +42 -0
- package/skills/ssh-incident/SKILL.md +55 -0
- package/skills/ssh-operations/SKILL.md +62 -0
- package/skills/ssh-restricted/SKILL.md +57 -0
- package/src/agent-clients.js +482 -0
- package/src/approval.js +291 -0
- package/src/audit.js +11 -1
- package/src/command-log.js +162 -0
- package/src/config-loader.js +119 -4
- package/src/config-paths.js +101 -0
- package/src/control-plane.js +2730 -0
- package/src/desktop-install.js +747 -0
- package/src/index.js +179 -213
- package/src/live-stream.js +261 -0
- package/src/saved-commands.js +150 -0
- package/src/secret-store.js +573 -0
- package/src/server-aliases.js +8 -7
- package/src/server-config-manager.js +33 -7
- package/src/server-export.js +106 -0
- package/src/server-groups.js +82 -21
- package/src/server-import.js +477 -0
- package/src/shell-quote.js +9 -2
- package/src/ssh-connection.js +155 -0
- package/src/ssh-manager.js +186 -13
- package/src/tunnel-manager.js +79 -0
- package/src/vault-recovery.js +206 -0
- package/src/xlsx.js +322 -0
- package/docs/images/social-preview.png +0 -0
- package/docs/images/social-preview@2x.png +0 -0
- package/docs/images/ssh-manager-cli-menu.png +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The only desktop upload step. Runs in a separate job after every OS passed.
|
|
3
|
+
import assert from 'node:assert/strict';
|
|
4
|
+
import fs from 'node:fs';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import crypto from 'node:crypto';
|
|
7
|
+
import { execFileSync } from 'node:child_process';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { releaseVersion } from './release-version.mjs';
|
|
10
|
+
|
|
11
|
+
export function verifyArtifacts(directory, version, expectedCommit = null) {
|
|
12
|
+
const files = [];
|
|
13
|
+
for (const platform of ['darwin', 'win32', 'linux']) {
|
|
14
|
+
const manifestPath = path.join(directory, `release-manifest-${platform}.json`);
|
|
15
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
16
|
+
assert.equal(manifest.version, version);
|
|
17
|
+
assert.equal(manifest.platform, platform);
|
|
18
|
+
if (expectedCommit) assert.equal(manifest.commit, expectedCommit, 'Git tag changed after the build');
|
|
19
|
+
for (const item of manifest.files) {
|
|
20
|
+
assert.equal(path.basename(item.name), item.name);
|
|
21
|
+
const file = path.join(directory, item.name);
|
|
22
|
+
// One read, and both checks on those bytes: sizing the path and then
|
|
23
|
+
// hashing a second read could vouch for two different files.
|
|
24
|
+
const bytes = fs.readFileSync(file);
|
|
25
|
+
assert.equal(bytes.length, item.size);
|
|
26
|
+
assert.equal(crypto.createHash('sha256').update(bytes).digest('hex'), item.sha256, `Artifact changed after validation: ${item.name}`);
|
|
27
|
+
files.push(file);
|
|
28
|
+
}
|
|
29
|
+
files.push(manifestPath);
|
|
30
|
+
}
|
|
31
|
+
assert.equal(new Set(files).size, files.length, 'Different platforms have colliding filenames');
|
|
32
|
+
return files;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
|
|
36
|
+
const version = JSON.parse(fs.readFileSync('package.json', 'utf8')).version;
|
|
37
|
+
const release = releaseVersion(version, process.env.RELEASE_TAG);
|
|
38
|
+
const commit = execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
|
|
39
|
+
const files = verifyArtifacts(process.argv[2], version, commit);
|
|
40
|
+
const gh = args => execFileSync('gh', args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'] });
|
|
41
|
+
const existing = JSON.parse(gh(['release', 'view', release.tag, '--json', 'isDraft,isPrerelease']));
|
|
42
|
+
assert.equal(existing.isDraft, true, 'Refuse to replace assets of an already public release; publish a new version');
|
|
43
|
+
assert.equal(existing.isPrerelease, release.prerelease, 'GitHub release channel differs from package version');
|
|
44
|
+
gh(['release', 'upload', release.tag, ...files, '--clobber']);
|
|
45
|
+
gh(['release', 'edit', release.tag, '--draft=false', `--prerelease=${release.prerelease}`, `--latest=${!release.prerelease}`]);
|
|
46
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Record the control plane doing its job, as a video.
|
|
4
|
+
*
|
|
5
|
+
* The screenshots show what the screens look like. They cannot show the thing
|
|
6
|
+
* the product is actually for: an agent asking to run `rm -rf` on production,
|
|
7
|
+
* and a person stopping it. That is a sequence, so it needs to move.
|
|
8
|
+
*
|
|
9
|
+
* Same rig as the screenshots — a real Chrome over the DevTools protocol,
|
|
10
|
+
* driven against scripts/demo-env.mjs — so the recording has the same property
|
|
11
|
+
* that matters: nothing in it is staged in a video editor. Every frame is the
|
|
12
|
+
* product responding to a click.
|
|
13
|
+
*
|
|
14
|
+
* Frames are pulled at a fixed cadence with Page.captureScreenshot rather than
|
|
15
|
+
* pushed by Page.startScreencast. The screencast only emits on visual change
|
|
16
|
+
* and proved wildly unreliable here — two identical runs produced 1111 frames
|
|
17
|
+
* and 22 — which is not something to discover after publishing a video. Pulling
|
|
18
|
+
* costs more per frame and yields a timeline we choose.
|
|
19
|
+
*
|
|
20
|
+
* Outputs:
|
|
21
|
+
* docs/videos/control-plane.mp4 full size, for linking
|
|
22
|
+
* docs/images/control-plane.gif downscaled and animated, for the README
|
|
23
|
+
*
|
|
24
|
+
* Usage:
|
|
25
|
+
* node scripts/demo-env.mjs --port 7315 &
|
|
26
|
+
* node scripts/record-demo.mjs <url-with-token>
|
|
27
|
+
*/
|
|
28
|
+
import fs from 'fs';
|
|
29
|
+
import os from 'os';
|
|
30
|
+
import path from 'path';
|
|
31
|
+
import { spawn, execFileSync } from 'child_process';
|
|
32
|
+
|
|
33
|
+
// Node has had a global WebSocket since 22; the shared eslint env predates it.
|
|
34
|
+
/* global WebSocket */
|
|
35
|
+
|
|
36
|
+
const CHROME = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome';
|
|
37
|
+
const ROOT = path.join(path.dirname(new URL(import.meta.url).pathname), '..');
|
|
38
|
+
const PORT = 9334;
|
|
39
|
+
// 16:10 — the aspect of every MacBook screen, so the recording drops into the
|
|
40
|
+
// mockup frame without letterboxing or a stretch.
|
|
41
|
+
const WIDTH = 1440;
|
|
42
|
+
const HEIGHT = 900;
|
|
43
|
+
/** Capture cadence. Ten a second is smooth enough for an interface and cheap. */
|
|
44
|
+
const FPS = 10;
|
|
45
|
+
const FRAME_MS = 1000 / FPS;
|
|
46
|
+
|
|
47
|
+
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The story, in order.
|
|
51
|
+
*
|
|
52
|
+
* `do` is evaluated in the page; `hold` is how long to sit on the result. The
|
|
53
|
+
* holds are long by software-demo standards on purpose — a reader needs time to
|
|
54
|
+
* read a command before watching somebody refuse it.
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* Click something by its accessible name first, then by its visible text.
|
|
58
|
+
*
|
|
59
|
+
* The rail is collapsed by default, so its items carry an aria-label and no
|
|
60
|
+
* text at all — matching on textContent found nothing and the recording died on
|
|
61
|
+
* the second scene.
|
|
62
|
+
*/
|
|
63
|
+
const click = text =>
|
|
64
|
+
`(() => { const b = document.querySelector('button[aria-label=${JSON.stringify(text)}]')`
|
|
65
|
+
+ ` || [...document.querySelectorAll('button')].find(b => b.textContent.includes(${JSON.stringify(text)}));`
|
|
66
|
+
+ ` if (!b) throw new Error('nothing to click: ' + ${JSON.stringify(text)}); b.click(); })()`;
|
|
67
|
+
|
|
68
|
+
const SCENES = [
|
|
69
|
+
{ name: 'the servers you gave it', act: null, hold: 2600 },
|
|
70
|
+
{ name: 'something is waiting', act: click('Waiting'), hold: 3800 },
|
|
71
|
+
{ name: 'refuse it', act: click('Refuse'), hold: 2600 },
|
|
72
|
+
{ name: 'watch one run', act: click('Live'), hold: 900 },
|
|
73
|
+
{ name: 'open the output', act: click('tail -f'), hold: 3600 },
|
|
74
|
+
{ name: 'both filesystems', act: click('Health'), hold: 200 },
|
|
75
|
+
{ name: 'probe on demand', act: click('Check every server'), hold: 7000 },
|
|
76
|
+
{ name: 'a shell on any machine', act: click('Terminal'), hold: 2400 },
|
|
77
|
+
{ name: 'back to the servers', act: click('Servers'), hold: 1800 },
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
/** A minimal CDP client: one socket, numbered commands, awaited replies. */
|
|
81
|
+
class Devtools {
|
|
82
|
+
constructor(ws) {
|
|
83
|
+
this.ws = ws;
|
|
84
|
+
this.next = 1;
|
|
85
|
+
this.pending = new Map();
|
|
86
|
+
this.listeners = new Map();
|
|
87
|
+
ws.addEventListener('message', event => {
|
|
88
|
+
const message = JSON.parse(event.data);
|
|
89
|
+
if (message.method) {
|
|
90
|
+
for (const fn of this.listeners.get(message.method) || []) fn(message.params);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const waiter = this.pending.get(message.id);
|
|
94
|
+
if (!waiter) return;
|
|
95
|
+
this.pending.delete(message.id);
|
|
96
|
+
message.error ? waiter.reject(new Error(message.error.message)) : waiter.resolve(message.result);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static async connect(target) {
|
|
101
|
+
const ws = new WebSocket(target);
|
|
102
|
+
await new Promise((resolve, reject) => {
|
|
103
|
+
ws.addEventListener('open', resolve, { once: true });
|
|
104
|
+
ws.addEventListener('error', () => reject(new Error('cannot reach Chrome')), { once: true });
|
|
105
|
+
});
|
|
106
|
+
return new Devtools(ws);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
on(method, fn) {
|
|
110
|
+
if (!this.listeners.has(method)) this.listeners.set(method, []);
|
|
111
|
+
this.listeners.get(method).push(fn);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
send(method, params = {}) {
|
|
115
|
+
const id = this.next++;
|
|
116
|
+
this.ws.send(JSON.stringify({ id, method, params }));
|
|
117
|
+
return new Promise((resolve, reject) => this.pending.set(id, { resolve, reject }));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function targetUrl() {
|
|
122
|
+
for (let attempt = 0; attempt < 60; attempt++) {
|
|
123
|
+
try {
|
|
124
|
+
const list = await fetch(`http://127.0.0.1:${PORT}/json/list`).then(r => r.json());
|
|
125
|
+
const page = list.find(t => t.type === 'page' && t.webSocketDebuggerUrl);
|
|
126
|
+
if (page) return page.webSocketDebuggerUrl;
|
|
127
|
+
} catch { /* not up yet */ }
|
|
128
|
+
await sleep(250);
|
|
129
|
+
}
|
|
130
|
+
throw new Error('Chrome never opened its debugging port');
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function main() {
|
|
134
|
+
const base = process.argv[2];
|
|
135
|
+
if (!base) {
|
|
136
|
+
console.error('usage: node scripts/record-demo.mjs <control-plane-url-with-token>');
|
|
137
|
+
process.exit(1);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const frames = fs.mkdtempSync(path.join(os.tmpdir(), 'demo-frames-'));
|
|
141
|
+
const profile = fs.mkdtempSync(path.join(os.tmpdir(), 'record-profile-'));
|
|
142
|
+
const chrome = spawn(CHROME, [
|
|
143
|
+
`--remote-debugging-port=${PORT}`,
|
|
144
|
+
`--user-data-dir=${profile}`,
|
|
145
|
+
'--no-first-run', '--no-default-browser-check',
|
|
146
|
+
'--disable-background-networking', '--disable-features=Translate',
|
|
147
|
+
`--window-size=${WIDTH},${HEIGHT}`,
|
|
148
|
+
'about:blank',
|
|
149
|
+
], { stdio: 'ignore' });
|
|
150
|
+
|
|
151
|
+
const cdp = await Devtools.connect(await targetUrl());
|
|
152
|
+
await cdp.send('Page.enable');
|
|
153
|
+
await cdp.send('Runtime.enable');
|
|
154
|
+
await cdp.send('Emulation.setDeviceMetricsOverride',
|
|
155
|
+
{ width: WIDTH, height: HEIGHT, deviceScaleFactor: 1, mobile: false });
|
|
156
|
+
|
|
157
|
+
// Deliberately *not* `?shell=macos`. That mode keeps the rail's top row empty
|
|
158
|
+
// for window buttons the desktop app draws over the content — right
|
|
159
|
+
// for a screenshot that gets a window frame composited around it, wrong here,
|
|
160
|
+
// where the video is shown edge to edge and the reserved strip reads as a
|
|
161
|
+
// layout bug with nothing in it.
|
|
162
|
+
await cdp.send('Page.navigate', { url: base });
|
|
163
|
+
await sleep(2500);
|
|
164
|
+
|
|
165
|
+
let shot = 0;
|
|
166
|
+
let recording = true;
|
|
167
|
+
// One capture in flight at a time: a slow frame delays the next tick rather
|
|
168
|
+
// than queueing a second request behind it.
|
|
169
|
+
const ticker = (async () => {
|
|
170
|
+
while (recording) {
|
|
171
|
+
const started = Date.now();
|
|
172
|
+
try {
|
|
173
|
+
const { data } = await cdp.send('Page.captureScreenshot',
|
|
174
|
+
{ format: 'jpeg', quality: 88, captureBeyondViewport: false });
|
|
175
|
+
fs.writeFileSync(path.join(frames, `f${String(shot++).padStart(5, '0')}.jpg`),
|
|
176
|
+
Buffer.from(data, 'base64'));
|
|
177
|
+
} catch { /* the page is navigating; the next tick will get it */ }
|
|
178
|
+
await sleep(Math.max(0, FRAME_MS - (Date.now() - started)));
|
|
179
|
+
}
|
|
180
|
+
})();
|
|
181
|
+
|
|
182
|
+
for (const scene of SCENES) {
|
|
183
|
+
if (scene.act) {
|
|
184
|
+
const { exceptionDetails } = await cdp.send('Runtime.evaluate', { expression: scene.act });
|
|
185
|
+
if (exceptionDetails) throw new Error(`${scene.name}: ${exceptionDetails.text}`);
|
|
186
|
+
}
|
|
187
|
+
process.stdout.write(` ${scene.name}\n`);
|
|
188
|
+
await sleep(scene.hold);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
recording = false;
|
|
192
|
+
await ticker;
|
|
193
|
+
chrome.kill();
|
|
194
|
+
|
|
195
|
+
if (shot < 2) throw new Error('no frames captured');
|
|
196
|
+
console.log(` ${shot} images — ${(shot / FPS).toFixed(1)} s`);
|
|
197
|
+
|
|
198
|
+
fs.mkdirSync(path.join(ROOT, 'docs', 'videos'), { recursive: true });
|
|
199
|
+
const mp4 = path.join(ROOT, 'docs', 'videos', 'control-plane.mp4');
|
|
200
|
+
const gif = path.join(ROOT, 'docs', 'images', 'control-plane.gif');
|
|
201
|
+
|
|
202
|
+
const pattern = path.join(frames, 'f%05d.jpg');
|
|
203
|
+
execFileSync('ffmpeg', ['-y', '-loglevel', 'error', '-framerate', String(FPS), '-i', pattern,
|
|
204
|
+
'-vf', 'scale=1440:-2:flags=lanczos,format=yuv420p',
|
|
205
|
+
'-c:v', 'libx264', '-crf', '20', '-preset', 'slow', '-movflags', '+faststart',
|
|
206
|
+
'-r', '24', mp4]);
|
|
207
|
+
|
|
208
|
+
// GIF, with a palette generated from this footage rather than the web-safe
|
|
209
|
+
// default — the interface is mostly close greys and one orange, which is
|
|
210
|
+
// exactly what a generic palette ruins. Homebrew's ffmpeg ships no WebP
|
|
211
|
+
// encoder, and an APNG of the same clip is 8 MB against 600 KB here.
|
|
212
|
+
execFileSync('ffmpeg', ['-y', '-loglevel', 'error', '-framerate', String(FPS), '-i', pattern,
|
|
213
|
+
'-vf', 'fps=12,scale=900:-2:flags=lanczos,split[a][b];' +
|
|
214
|
+
'[a]palettegen=max_colors=192[p];[b][p]paletteuse=dither=bayer:bayer_scale=3',
|
|
215
|
+
'-loop', '0', gif]);
|
|
216
|
+
|
|
217
|
+
for (const out of [mp4, gif]) {
|
|
218
|
+
console.log(` ${path.relative(ROOT, out).padEnd(34)} ${(fs.statSync(out).size / 1e6).toFixed(1)} Mo`);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
fs.rmSync(frames, { recursive: true, force: true });
|
|
222
|
+
await sleep(1200);
|
|
223
|
+
try { fs.rmSync(profile, { recursive: true, force: true }); } catch { /* temp dir */ }
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
main().catch(error => {
|
|
227
|
+
console.error(error.message);
|
|
228
|
+
process.exit(1);
|
|
229
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { execFileSync } from 'node:child_process';
|
|
7
|
+
|
|
8
|
+
export function releaseVersion(version, tag) {
|
|
9
|
+
assert.match(version, /^\d+\.\d+\.\d+(?:-([a-z][a-z0-9-]*)(?:\.[0-9A-Za-z-]+)*)?$/, 'Release version must be stable or a named prerelease');
|
|
10
|
+
if (tag !== undefined) assert.equal(tag, `v${version}`, 'Publication requires the exact version tag');
|
|
11
|
+
const prerelease = version.includes('-');
|
|
12
|
+
return { version, tag: `v${version}`, prerelease, npmTag: prerelease ? 'next' : 'latest', channel: prerelease ? version.slice(version.indexOf('-') + 1).split('.')[0] : 'latest' };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (process.argv[1] && fileURLToPath(import.meta.url) === path.resolve(process.argv[1])) {
|
|
16
|
+
const read = file => JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
17
|
+
const version = read('package.json').version;
|
|
18
|
+
const release = releaseVersion(version, process.env.RELEASE_REQUIRE_TAG === 'true' ? process.env.RELEASE_TAG : undefined);
|
|
19
|
+
const commit = execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();
|
|
20
|
+
if (process.env.RELEASE_REQUIRE_TAG === 'true') {
|
|
21
|
+
const taggedCommit = execFileSync('git', ['rev-parse', `refs/tags/${release.tag}^{commit}`], { encoding: 'utf8' }).trim();
|
|
22
|
+
assert.equal(taggedCommit, commit, 'Publication requires checkout of the exact Git tag');
|
|
23
|
+
}
|
|
24
|
+
for (const file of ['package-lock.json', 'desktop/electron/package.json', 'desktop/electron/package-lock.json', 'server.json']) {
|
|
25
|
+
assert.equal(read(file).version, version, `${file} version differs`);
|
|
26
|
+
}
|
|
27
|
+
assert.equal(read('server.json').packages[0].version, version);
|
|
28
|
+
if (process.env.GITHUB_OUTPUT) {
|
|
29
|
+
fs.appendFileSync(process.env.GITHUB_OUTPUT, Object.entries({ ...release, commit }).map(([key, value]) => `${key}=${value}\n`).join(''));
|
|
30
|
+
}
|
|
31
|
+
console.log(JSON.stringify(release));
|
|
32
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Draw the CLI's home screen for the README, from the CLI itself.
|
|
4
|
+
|
|
5
|
+
The picture this replaces was a screenshot taken by hand of the 3.1 menu, in
|
|
6
|
+
another terminal application, with somebody's avatar in the corner: it showed a
|
|
7
|
+
version nobody runs and leaked a little of the machine it was taken on. This
|
|
8
|
+
runs the real `ssh-manager` menu in a pseudo-terminal, against a stand-in home
|
|
9
|
+
holding three demo servers, reads the colours it prints, and draws the screen
|
|
10
|
+
in a plain terminal window. After any change to the menu, run it again.
|
|
11
|
+
|
|
12
|
+
What is real: every character and colour the menu prints. What is not: the
|
|
13
|
+
servers (three names on the loopback) and the home directory. The desktop app
|
|
14
|
+
part of the status line is read from this machine's /Applications.
|
|
15
|
+
|
|
16
|
+
Pillow is the only dependency (`uv run --with pillow python3 scripts/render-cli-menu.py`).
|
|
17
|
+
|
|
18
|
+
Usage: python3 scripts/render-cli-menu.py [out.png] (default: docs/images/ssh-manager-cli-menu.png)
|
|
19
|
+
"""
|
|
20
|
+
import os
|
|
21
|
+
import pathlib
|
|
22
|
+
import re
|
|
23
|
+
import subprocess
|
|
24
|
+
import sys
|
|
25
|
+
import tempfile
|
|
26
|
+
|
|
27
|
+
from PIL import Image, ImageDraw, ImageFilter, ImageFont
|
|
28
|
+
|
|
29
|
+
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
30
|
+
OUT = ROOT / 'docs' / 'images' / 'ssh-manager-cli-menu.png'
|
|
31
|
+
FONT = '/System/Library/Fonts/Menlo.ttc' # index 0 regular, 1 bold
|
|
32
|
+
|
|
33
|
+
SCALE = 2
|
|
34
|
+
COLS = 78
|
|
35
|
+
CELL_W, CELL_H = 8 * SCALE, 17 * SCALE # Menlo 13pt advance and line height
|
|
36
|
+
FONT_SIZE = 13 * SCALE
|
|
37
|
+
PAD_X, PAD_Y = 22 * SCALE, 18 * SCALE
|
|
38
|
+
BAR = 34 * SCALE
|
|
39
|
+
SHADOW = 40 * SCALE
|
|
40
|
+
RADIUS = 11 * SCALE
|
|
41
|
+
|
|
42
|
+
GROUND = (20, 20, 19) # #141413, the icon's black
|
|
43
|
+
BAR_TOP = (38, 37, 35)
|
|
44
|
+
TEXT = (230, 227, 221)
|
|
45
|
+
LIGHTS = [(255, 95, 87), (254, 188, 46), (40, 200, 64)]
|
|
46
|
+
|
|
47
|
+
# The handful of SGR colours the menu uses, mapped to what a dark terminal
|
|
48
|
+
# shows for them. 166 is the application's orange (#c04500 at 256 colours).
|
|
49
|
+
SGR_COLOURS = {
|
|
50
|
+
'30': (60, 60, 60), '31': (231, 96, 85), '32': (95, 191, 131), '33': (227, 169, 59),
|
|
51
|
+
'34': (127, 176, 234), '35': (200, 140, 220), '36': (90, 200, 210), '37': TEXT,
|
|
52
|
+
'90': (138, 134, 127), '38;5;166': (215, 95, 0),
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
DEMO_ENV = (
|
|
56
|
+
'SSH_SERVER_PRODUCTION_HOST=127.0.0.1\nSSH_SERVER_PRODUCTION_USER=deploy\n'
|
|
57
|
+
'SSH_SERVER_STAGING_HOST=127.0.0.1\nSSH_SERVER_STAGING_USER=deploy\n'
|
|
58
|
+
'SSH_SERVER_BACKUP_HOST=127.0.0.1\nSSH_SERVER_BACKUP_USER=root\n'
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def capture() -> str:
|
|
63
|
+
"""Run the menu in a pseudo-terminal, answer `q`, and return what it drew."""
|
|
64
|
+
with tempfile.TemporaryDirectory(prefix='cli-menu-') as home:
|
|
65
|
+
state = pathlib.Path(home, '.ssh-manager')
|
|
66
|
+
state.mkdir()
|
|
67
|
+
(state / '.env').write_text(DEMO_ENV)
|
|
68
|
+
env = {'PATH': os.environ['PATH'], 'HOME': home, 'TERM': 'xterm-256color',
|
|
69
|
+
'COLUMNS': str(COLS), 'LINES': '30'}
|
|
70
|
+
# `script` gives the menu a terminal, so it draws exactly what a person
|
|
71
|
+
# sees; piped, it would print its plain non-interactive output instead.
|
|
72
|
+
result = subprocess.run(['script', '-q', '/dev/null', 'bash', str(ROOT / 'cli' / 'ssh-manager')],
|
|
73
|
+
input='q\n', capture_output=True, text=True, env=env, timeout=60)
|
|
74
|
+
screen = result.stdout
|
|
75
|
+
# Keep what follows the last clear-screen: the home screen itself.
|
|
76
|
+
cleared = [m.end() for m in re.finditer(r'\x1b\[2J', screen)]
|
|
77
|
+
if not cleared:
|
|
78
|
+
sys.exit('the menu never drew its screen:\n' + screen[:500])
|
|
79
|
+
screen = screen[cleared[-1]:].replace('\r', '')
|
|
80
|
+
lines = screen.split('\n')
|
|
81
|
+
# Up to and including the prompt line; the echoed `q` and the farewell are not the screen.
|
|
82
|
+
end = next((i for i, line in enumerate(lines) if '›' in line), len(lines) - 1)
|
|
83
|
+
return '\n'.join(lines[:end + 1]).strip('\n')
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def spans(line: str):
|
|
87
|
+
"""Split a line into (text, colour, bold) runs, following its SGR codes."""
|
|
88
|
+
colour, bold, out = TEXT, False, []
|
|
89
|
+
for part in re.split(r'(\x1b\[[0-9;]*m)', line):
|
|
90
|
+
match = re.fullmatch(r'\x1b\[([0-9;]*)m', part)
|
|
91
|
+
if not match:
|
|
92
|
+
if part:
|
|
93
|
+
out.append((re.sub(r'\x1b\[[0-9;?]*[A-Za-z]', '', part), colour, bold))
|
|
94
|
+
continue
|
|
95
|
+
codes = match.group(1) or '0'
|
|
96
|
+
if codes.startswith('38;5;'):
|
|
97
|
+
colour = SGR_COLOURS.get(codes, TEXT)
|
|
98
|
+
continue
|
|
99
|
+
for code in codes.split(';'):
|
|
100
|
+
if code in ('0', ''):
|
|
101
|
+
colour, bold = TEXT, False
|
|
102
|
+
elif code == '1':
|
|
103
|
+
bold = True
|
|
104
|
+
elif code in SGR_COLOURS:
|
|
105
|
+
colour = SGR_COLOURS[code]
|
|
106
|
+
return out
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def render(screen: str, out: pathlib.Path) -> pathlib.Path:
|
|
110
|
+
lines = screen.split('\n')
|
|
111
|
+
regular = ImageFont.truetype(FONT, FONT_SIZE, index=0)
|
|
112
|
+
heavy = ImageFont.truetype(FONT, FONT_SIZE, index=1)
|
|
113
|
+
w = PAD_X * 2 + COLS * CELL_W
|
|
114
|
+
h = BAR + PAD_Y * 2 + len(lines) * CELL_H
|
|
115
|
+
|
|
116
|
+
window = Image.new('RGBA', (w, h), (*GROUND, 255))
|
|
117
|
+
d = ImageDraw.Draw(window)
|
|
118
|
+
d.rectangle([0, 0, w, BAR], fill=(*BAR_TOP, 255))
|
|
119
|
+
for i, colour in enumerate(LIGHTS):
|
|
120
|
+
x = 14 * SCALE + i * 20 * SCALE
|
|
121
|
+
y = (BAR - 12 * SCALE) // 2
|
|
122
|
+
d.ellipse([x, y, x + 12 * SCALE, y + 12 * SCALE], fill=(*colour, 255))
|
|
123
|
+
d.text((w // 2, BAR // 2), 'ssh-manager', font=regular, fill=(150, 146, 139), anchor='mm')
|
|
124
|
+
|
|
125
|
+
for row, line in enumerate(lines):
|
|
126
|
+
col = 0
|
|
127
|
+
for text, colour, bold in spans(line):
|
|
128
|
+
for char in text:
|
|
129
|
+
if char == '\t':
|
|
130
|
+
col += 8 - col % 8
|
|
131
|
+
continue
|
|
132
|
+
d.text((PAD_X + col * CELL_W, BAR + PAD_Y + row * CELL_H), char,
|
|
133
|
+
font=heavy if bold else regular, fill=colour)
|
|
134
|
+
col += 1
|
|
135
|
+
|
|
136
|
+
mask = Image.new('L', window.size, 0)
|
|
137
|
+
ImageDraw.Draw(mask).rounded_rectangle([0, 0, w - 1, h - 1], radius=RADIUS, fill=255)
|
|
138
|
+
window.putalpha(mask)
|
|
139
|
+
|
|
140
|
+
canvas = Image.new('RGBA', (w + SHADOW * 2, h + SHADOW * 2), (0, 0, 0, 0))
|
|
141
|
+
shadow = Image.new('RGBA', canvas.size, (0, 0, 0, 0))
|
|
142
|
+
ImageDraw.Draw(shadow).rounded_rectangle([SHADOW, SHADOW + 8 * SCALE, SHADOW + w, SHADOW + h + 8 * SCALE],
|
|
143
|
+
radius=RADIUS, fill=(0, 0, 0, 90))
|
|
144
|
+
canvas.alpha_composite(shadow.filter(ImageFilter.GaussianBlur(14 * SCALE)))
|
|
145
|
+
canvas.alpha_composite(window, (SHADOW, SHADOW))
|
|
146
|
+
canvas.save(out, optimize=True)
|
|
147
|
+
return out
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def main():
|
|
151
|
+
out = pathlib.Path(sys.argv[1]) if len(sys.argv) > 1 else OUT
|
|
152
|
+
made = render(capture(), out)
|
|
153
|
+
print(f' {made.relative_to(ROOT) if made.is_relative_to(ROOT) else made} {made.stat().st_size // 1024} Ko')
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
if __name__ == '__main__':
|
|
157
|
+
main()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Python tools for the pre-commit hooks (scripts/setup-hooks.sh). The hashed
|
|
2
|
+
# lock, requirements-dev.txt, is generated from this file; floors only, the lock
|
|
3
|
+
# holds the exact versions. Python 3.11 and later: 3.10 reaches end of life this month, and the
|
|
4
|
+
# fixed releases of black, filelock, requests and urllib3 do not support older ones.
|
|
5
|
+
# uv pip compile scripts/requirements-dev.in --generate-hashes --universal --python-version 3.11 -o scripts/requirements-dev.txt
|
|
6
|
+
# Check the result against OSV before committing: a lock of pinned versions is
|
|
7
|
+
# read by OpenSSF Scorecard, and an affected version there is a standing alert.
|
|
8
|
+
pre-commit>=4.0.1
|
|
9
|
+
black>=26.3.1
|
|
10
|
+
flake8>=7.1.1
|
|
11
|
+
isort>=5.13.2
|
|
12
|
+
detect-secrets>=1.5.0
|