dsh-remote 1.2.1 → 1.3.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/README.en.md +4 -2
- package/README.md +4 -2
- package/lib/binding.js +86 -26
- package/lib/client.js +422 -154
- package/lib/deck-bridge.js +17 -0
- package/lib/errors.js +5 -2
- package/lib/forwards.js +18 -6
- package/lib/main.js +45 -12
- package/lib/mirror-paths.js +17 -0
- package/lib/pool.js +46 -4
- package/lib/registry.js +6 -1
- package/lib/routes-forwards.js +81 -10
- package/lib/update.js +209 -25
- package/package.json +4 -3
package/lib/update.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// files with the newer npm tarball. This module owns the version check and the
|
|
6
6
|
// tarball apply:
|
|
7
7
|
//
|
|
8
|
-
// •
|
|
8
|
+
// • fetchLatestVersion() — query npm latest, falling back to an official stable GitHub release;
|
|
9
9
|
// • applyUpdate() — download the tarball, extract package/{lib,package.json,
|
|
10
10
|
// cordis.patch.yml} with a minimal tar reader, verify the version, then
|
|
11
11
|
// replace the installed files atomically (temp file + rename, never a
|
|
@@ -22,10 +22,127 @@
|
|
|
22
22
|
// Every failure aborts without touching the installed files (a bad download or
|
|
23
23
|
// a version mismatch must never break the running plugin).
|
|
24
24
|
|
|
25
|
+
import { createHash } from 'node:crypto'
|
|
25
26
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
|
26
27
|
import { createRequire } from 'node:module'
|
|
27
28
|
import path from 'node:path'
|
|
28
29
|
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
30
|
+
import http from 'node:http'
|
|
31
|
+
import https from 'node:https'
|
|
32
|
+
import tls from 'node:tls'
|
|
33
|
+
import { gunzipSync, inflateSync, brotliDecompressSync } from 'node:zlib'
|
|
34
|
+
// Update-only proxy support uses builtins so partial-install self-healing
|
|
35
|
+
// never needs to import an unavailable package or missing sibling module.
|
|
36
|
+
const CAP = 32 * 1024 * 1024
|
|
37
|
+
|
|
38
|
+
export function updateProxyFor(url, env = process.env) {
|
|
39
|
+
const target = new URL(url)
|
|
40
|
+
const bypass = env.no_proxy ?? env.NO_PROXY ?? ''
|
|
41
|
+
const host = target.hostname.toLowerCase()
|
|
42
|
+
for (const item of bypass.split(',').map(s => s.trim().toLowerCase()).filter(Boolean)) {
|
|
43
|
+
if (item === '*') return ''
|
|
44
|
+
const match = /^(.*?)(?::(\d+))?$/.exec(item)
|
|
45
|
+
if (match[2] && match[2] !== (target.port || '443')) continue
|
|
46
|
+
const domain = match[1].replace(/^\*?\./, '')
|
|
47
|
+
if (host === domain || host.endsWith('.' + domain)) return ''
|
|
48
|
+
}
|
|
49
|
+
return env.https_proxy || env.HTTPS_PROXY || env.http_proxy || env.HTTP_PROXY || ''
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export async function requestThroughProxy(url, options, proxyUrl) {
|
|
53
|
+
const target = new URL(url), proxy = new URL(proxyUrl)
|
|
54
|
+
if (target.protocol !== 'https:' || !['http:', 'https:'].includes(proxy.protocol)) throw new Error('Update HTTPS proxy must use http:// or https://')
|
|
55
|
+
if (options.signal?.aborted) throw new DOMException('Update request aborted', 'AbortError')
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
let socket, secure, request, agent, done = false
|
|
58
|
+
const cleanup = () => { options.signal?.removeEventListener('abort', abort); agent?.destroy(); request?.destroy(); secure?.destroy(); socket?.destroy(); tunnel.destroy() }
|
|
59
|
+
const fail = error => { if (done) return; done = true; cleanup(); reject(error) }
|
|
60
|
+
const abort = () => fail(new DOMException('Update request aborted', 'AbortError'))
|
|
61
|
+
const headers = { host: target.host }
|
|
62
|
+
if (proxy.username || proxy.password) headers['proxy-authorization'] = 'Basic ' + Buffer.from(decodeURIComponent(proxy.username) + ':' + decodeURIComponent(proxy.password)).toString('base64')
|
|
63
|
+
const transport = proxy.protocol === 'https:' ? https : http
|
|
64
|
+
const tunnel = transport.request({ hostname: proxy.hostname, port: proxy.port || (proxy.protocol === 'https:' ? 443 : 80), method: 'CONNECT', path: target.host.includes(':') ? target.host : target.host + ':443', headers })
|
|
65
|
+
tunnel.on('error', fail)
|
|
66
|
+
tunnel.on('connect', (response, connected, head) => {
|
|
67
|
+
socket = connected
|
|
68
|
+
if (response.statusCode !== 200) { fail(Object.assign(new Error('HTTPS proxy CONNECT returned HTTP ' + response.statusCode), { code: 'PROXY_HTTP_' + response.statusCode })); return }
|
|
69
|
+
if (head.length) socket.unshift(head)
|
|
70
|
+
secure = tls.connect({ socket, servername: target.hostname, ...(options.ca ? { ca: options.ca } : {}) })
|
|
71
|
+
secure.on('error', fail)
|
|
72
|
+
secure.once('secureConnect', () => {
|
|
73
|
+
agent = new https.Agent({ keepAlive: false }); agent.createConnection = () => secure
|
|
74
|
+
request = https.request(target, { method: options.method || 'GET', headers: options.headers, agent }, response => {
|
|
75
|
+
const chunks = []; let size = 0
|
|
76
|
+
response.on('error', fail)
|
|
77
|
+
response.on('aborted', () => fail(new Error('Update response interrupted')))
|
|
78
|
+
response.on('data', chunk => { size += chunk.length; if (size > CAP) fail(new Error('Update response exceeds size limit')); else chunks.push(chunk) })
|
|
79
|
+
response.on('end', () => {
|
|
80
|
+
if (done) return
|
|
81
|
+
try {
|
|
82
|
+
let bytes = Buffer.concat(chunks)
|
|
83
|
+
const encoding = response.headers['content-encoding']
|
|
84
|
+
if (encoding === 'gzip') bytes = gunzipSync(bytes, { maxOutputLength: CAP })
|
|
85
|
+
else if (encoding === 'deflate') bytes = inflateSync(bytes, { maxOutputLength: CAP })
|
|
86
|
+
else if (encoding === 'br') bytes = brotliDecompressSync(bytes, { maxOutputLength: CAP })
|
|
87
|
+
done = true; cleanup()
|
|
88
|
+
resolve({ ok: response.statusCode >= 200 && response.statusCode < 300, status: response.statusCode, headers: new Headers(response.headers), json: async () => JSON.parse(bytes.toString('utf8')), arrayBuffer: async () => bytes })
|
|
89
|
+
} catch (error) { fail(error) }
|
|
90
|
+
})
|
|
91
|
+
})
|
|
92
|
+
request.on('error', fail); request.end()
|
|
93
|
+
})
|
|
94
|
+
})
|
|
95
|
+
options.signal?.addEventListener('abort', abort, { once: true })
|
|
96
|
+
if (options.signal?.aborted) abort(); else tunnel.end()
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export async function fetchUpdate(url, options = {}, hops = 0) {
|
|
101
|
+
const proxy = updateProxyFor(url)
|
|
102
|
+
// Unit tests retain their injected global fetch and never contact production.
|
|
103
|
+
if (!proxy || process.env.NODE_TEST_CONTEXT) return fetch(url, options)
|
|
104
|
+
const response = await requestThroughProxy(url, options, proxy)
|
|
105
|
+
if ([301, 302, 303, 307, 308].includes(response.status) && response.headers.get('location')) {
|
|
106
|
+
if (hops >= 5) throw new Error('Too many update redirects')
|
|
107
|
+
const next = new URL(response.headers.get('location'), url)
|
|
108
|
+
if (next.protocol !== 'https:') throw new Error('Update redirect must retain HTTPS')
|
|
109
|
+
const headers = new Headers(options.headers)
|
|
110
|
+
if (next.origin !== new URL(url).origin) { headers.delete('authorization'); headers.delete('cookie') }
|
|
111
|
+
return fetchUpdate(next.href, { ...options, headers: Object.fromEntries(headers) }, hops + 1)
|
|
112
|
+
}
|
|
113
|
+
return response
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Official release fallback only. Never install an unchecked mirror response.
|
|
117
|
+
const REPO = 'https://api.github.com/repos/flymysql/dsh-remote/releases/'
|
|
118
|
+
export const stableVersion = value => typeof value === 'string' && /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(value)
|
|
119
|
+
export async function fetchRelease(version, fetchImpl = fetchUpdate, timeoutMs = 8000) {
|
|
120
|
+
if (version !== undefined && !stableVersion(version)) throw new Error('Invalid stable release version')
|
|
121
|
+
const controller = new AbortController(), timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
122
|
+
timer.unref?.()
|
|
123
|
+
try {
|
|
124
|
+
const response = await fetchImpl(REPO + (version ? 'tags/v' + version : 'latest'), { signal: controller.signal, headers: { accept: 'application/vnd.github+json', 'user-agent': 'dsh-remote-updater' } })
|
|
125
|
+
if (!response.ok) throw new Error('GitHub Release HTTP ' + response.status)
|
|
126
|
+
const release = await response.json()
|
|
127
|
+
const found = String(release?.tag_name || '').replace(/^v/, '')
|
|
128
|
+
if (!stableVersion(found) || version && found !== version || release.draft !== false || release.prerelease !== false) throw new Error('GitHub Release is not the requested stable release')
|
|
129
|
+
const filename = 'dsh-remote-' + found + '.tgz'
|
|
130
|
+
const asset = release.assets?.find(a => a.name === filename && a.state === 'uploaded')
|
|
131
|
+
if (!asset || !/^sha256:[a-f0-9]{64}$/i.test(asset.digest || '') || !Number.isFinite(asset.size) || asset.size <= 0 || asset.size > 32 * 1024 * 1024) throw new Error('GitHub Release has no verified installation archive')
|
|
132
|
+
return { version: found, source: 'github', url: 'https://github.com/flymysql/dsh-remote/releases/download/v' + found + '/' + filename, integrity: 'sha256-' + Buffer.from(asset.digest.slice(7), 'hex').toString('base64') }
|
|
133
|
+
} finally { clearTimeout(timer) }
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function downloadReleaseBytes(url, fetchImpl = fetchUpdate, timeoutMs = 60000) {
|
|
137
|
+
const controller = new AbortController(), timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
138
|
+
try {
|
|
139
|
+
const response = await fetchImpl(url, { signal: controller.signal })
|
|
140
|
+
if (!response.ok) throw new Error('download failed (HTTP ' + response.status + ')')
|
|
141
|
+
const bytes = Buffer.from(await response.arrayBuffer())
|
|
142
|
+
if (bytes.length > 32 * 1024 * 1024) throw new Error('Update archive exceeds size limit')
|
|
143
|
+
return bytes
|
|
144
|
+
} finally { clearTimeout(timer) }
|
|
145
|
+
}
|
|
29
146
|
|
|
30
147
|
const NPM_PACKAGE = 'dsh-remote'
|
|
31
148
|
const REGISTRY_URL = 'https://registry.npmjs.org/' + NPM_PACKAGE + '/latest'
|
|
@@ -108,7 +225,7 @@ export function gtVersion(a, b) {
|
|
|
108
225
|
* 三者的处置完全不同,必须让用户看到真实原因。
|
|
109
226
|
* @param timeoutMs - 超时(看门狗只负责中止,不影响进程存活)。
|
|
110
227
|
*/
|
|
111
|
-
|
|
228
|
+
async function fetchNpmLatestVersion(timeoutMs = 8000, fetchImpl = fetchUpdate) {
|
|
112
229
|
try {
|
|
113
230
|
const controller = new AbortController()
|
|
114
231
|
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
@@ -117,29 +234,86 @@ export async function fetchLatestVersion(timeoutMs = 8000) {
|
|
|
117
234
|
if (typeof timer.unref === 'function') timer.unref()
|
|
118
235
|
let res
|
|
119
236
|
try {
|
|
120
|
-
res = await
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (!version) return { error: 'npm registry 响应里没有可用的版本号', reason: 'malformed' }
|
|
133
|
-
return { version }
|
|
237
|
+
res = await fetchImpl(REGISTRY_URL, { signal: controller.signal, headers: { accept: 'application/json' } })
|
|
238
|
+
if (res.status === 429) {
|
|
239
|
+
return { error: 'npm registry 限流(HTTP 429)——请求过于频繁,稍后会自动恢复', reason: 'rate-limited', status: 429 }
|
|
240
|
+
}
|
|
241
|
+
if (!res.ok) {
|
|
242
|
+
return { error: `npm registry 返回 HTTP ${res.status}`, reason: 'http', status: res.status }
|
|
243
|
+
}
|
|
244
|
+
const data = await res.json().catch(error => { if (error?.name === 'AbortError') throw error; return null })
|
|
245
|
+
const version = stableVersion(data?.version) ? data.version : null
|
|
246
|
+
if (!version) return { error: 'npm registry 响应里没有可用的版本号', reason: 'malformed' }
|
|
247
|
+
return { version }
|
|
248
|
+
} finally { clearTimeout(timer) }
|
|
134
249
|
} catch (err) {
|
|
135
250
|
const aborted = err?.name === 'AbortError'
|
|
136
251
|
return {
|
|
137
252
|
error: aborted ? `连接 npm registry 超时(${timeoutMs}ms)` : '无法连接 npm registry',
|
|
138
253
|
reason: aborted ? 'timeout' : 'network',
|
|
254
|
+
...((err?.cause?.code || err?.code) ? { networkCode: String(err.cause?.code || err.code) } : {}),
|
|
139
255
|
}
|
|
140
256
|
}
|
|
141
257
|
}
|
|
142
258
|
|
|
259
|
+
/** npm preferred; a registry outage does not disable official GitHub releases. */
|
|
260
|
+
export async function fetchLatestVersion(timeoutMs = 8000, { fetchImpl = fetchUpdate } = {}) {
|
|
261
|
+
const primary = await fetchNpmLatestVersion(timeoutMs, fetchImpl)
|
|
262
|
+
if (!primary.error) return primary
|
|
263
|
+
try {
|
|
264
|
+
const release = await fetchRelease(undefined, fetchImpl, timeoutMs)
|
|
265
|
+
return { version: release.version, source: release.source }
|
|
266
|
+
} catch (error) {
|
|
267
|
+
return { ...primary, error: primary.error + (primary.networkCode ? '(' + primary.networkCode + ')' : '') + ';GitHub 备用来源也不可用', fallbackError: String(error.message || error) }
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Fetch the npm metadata for one exact published version and return its
|
|
273
|
+
* `dist.integrity` (issue #169) — the SRI string the registry itself computed
|
|
274
|
+
* over the tarball bytes. This is the root of trust `applyUpdate` verifies
|
|
275
|
+
* the downloaded bytes against: TLS protects the transport, not the content.
|
|
276
|
+
*
|
|
277
|
+
* @param {string} version - exact published version.
|
|
278
|
+
* @param {Function} [fetchImpl] - fetch stand-in (tests inject here).
|
|
279
|
+
* @param {number} [timeoutMs] - watchdog budget; the caller does not await the timer.
|
|
280
|
+
* @returns {Promise<string>} the SRI string ("sha512-…").
|
|
281
|
+
*/
|
|
282
|
+
export async function fetchDistIntegrity(version, fetchImpl = fetchUpdate, timeoutMs = 15000) {
|
|
283
|
+
const controller = new AbortController()
|
|
284
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs)
|
|
285
|
+
if (typeof timer.unref === 'function') timer.unref()
|
|
286
|
+
try {
|
|
287
|
+
const res = await fetchImpl(`https://registry.npmjs.org/${NPM_PACKAGE}/${encodeURIComponent(version)}`, {
|
|
288
|
+
signal: controller.signal,
|
|
289
|
+
headers: { accept: 'application/vnd.npm.install-v1+json' },
|
|
290
|
+
})
|
|
291
|
+
if (!res.ok) throw new Error(`registry metadata returned HTTP ${res.status}`)
|
|
292
|
+
const data = await res.json().catch(error => { if (error?.name === 'AbortError') throw error; return null })
|
|
293
|
+
const integrity = data?.dist?.integrity
|
|
294
|
+
if (typeof integrity !== 'string' || !/^(sha512|sha256)-[A-Za-z0-9+/=]+$/.test(integrity)) {
|
|
295
|
+
throw new Error('registry metadata carries no usable dist.integrity')
|
|
296
|
+
}
|
|
297
|
+
return integrity
|
|
298
|
+
} finally { clearTimeout(timer) }
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Verify downloaded bytes against an npm `dist.integrity` SRI string.
|
|
303
|
+
* Throws (never returns false) so a mismatch aborts the update before the
|
|
304
|
+
* tar is even gunzipped.
|
|
305
|
+
* @param {Buffer} buf - the downloaded tarball bytes.
|
|
306
|
+
* @param {string} integrity - SRI string from the registry metadata.
|
|
307
|
+
*/
|
|
308
|
+
export function assertIntegrity(buf, integrity) {
|
|
309
|
+
const [alg, expected] = String(integrity || '').split('-')
|
|
310
|
+
if ((alg !== 'sha512' && alg !== 'sha256') || !expected) {
|
|
311
|
+
throw new Error(`unsupported dist.integrity: ${integrity}`)
|
|
312
|
+
}
|
|
313
|
+
const actual = createHash(alg).update(buf).digest('base64')
|
|
314
|
+
if (actual !== expected) throw new Error(`tarball integrity mismatch: expected ${alg}-${expected}, got ${alg}-${actual}`)
|
|
315
|
+
}
|
|
316
|
+
|
|
143
317
|
/** Minimal POSIX ustar reader (regular files only) — npm tarballs are gzipped tar. */
|
|
144
318
|
function parseTar(buf) {
|
|
145
319
|
const files = []
|
|
@@ -176,7 +350,7 @@ export async function applyUpdate(targetVersion, options = {}) {
|
|
|
176
350
|
}
|
|
177
351
|
const tarballUrl = `https://registry.npmjs.org/${NPM_PACKAGE}/-/${NPM_PACKAGE}-${targetVersion}.tgz`
|
|
178
352
|
const dir = path.resolve(options.dir || selfDir())
|
|
179
|
-
const doFetch = options.fetchImpl ||
|
|
353
|
+
const doFetch = options.fetchImpl || fetchUpdate
|
|
180
354
|
const writeAtomic = options.writeFileAtomic || writeFileAtomic
|
|
181
355
|
const restoreFile = options.restoreFile || copyFileSync
|
|
182
356
|
const tmpRoot = path.join(dir, `.dsh-remote-update-${Date.now()}`)
|
|
@@ -188,16 +362,26 @@ export async function applyUpdate(targetVersion, options = {}) {
|
|
|
188
362
|
// Offline repair must not contact the registry at all.
|
|
189
363
|
buf = readFileSync(options.tarballPath)
|
|
190
364
|
} else {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
let res
|
|
365
|
+
if (!stableVersion(targetVersion)) throw new Error('Invalid stable update version')
|
|
366
|
+
let integrity, registryFailure
|
|
194
367
|
try {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
368
|
+
integrity = options.integrity ?? await fetchDistIntegrity(targetVersion, doFetch)
|
|
369
|
+
buf = await downloadReleaseBytes(tarballUrl, doFetch)
|
|
370
|
+
} catch (error) { registryFailure = error }
|
|
371
|
+
if (registryFailure) {
|
|
372
|
+
// A malformed integrity response is not a connectivity failure: do not
|
|
373
|
+
// turn a failed trust check into a less strict installation path.
|
|
374
|
+
if (/no usable dist\.integrity|unsupported dist\.integrity/i.test(registryFailure.message)) throw registryFailure
|
|
375
|
+
try {
|
|
376
|
+
const release = await fetchRelease(targetVersion, doFetch)
|
|
377
|
+
integrity = release.integrity
|
|
378
|
+
buf = await downloadReleaseBytes(release.url, doFetch)
|
|
379
|
+
} catch (fallback) {
|
|
380
|
+
throw new Error(String(registryFailure.message) + '; GitHub fallback failed: ' + String(fallback.message))
|
|
381
|
+
}
|
|
198
382
|
}
|
|
199
|
-
|
|
200
|
-
buf
|
|
383
|
+
// Hash mismatches never trigger source switching and never touch files.
|
|
384
|
+
assertIntegrity(buf, integrity)
|
|
201
385
|
}
|
|
202
386
|
// npm tarballs are gzipped tar; extract the package/ directory.
|
|
203
387
|
const { gunzipSync } = await import('node:zlib')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "SSH remote workspaces for DeepSeek Harness: parallel projects across hosts, remote file browsing and editing, recursive search, terminals, Git diffs, and workspace-bound Agent tools to edit, build and test remotely. Optional IDE layout.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "flymysql <flyphp@outlook.com>",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
".": "./lib/boot.js",
|
|
33
33
|
"./client": "./lib/client.js",
|
|
34
34
|
"./package.json": "./package.json",
|
|
35
|
-
"./cordis.patch.yml": "./cordis.patch.yml"
|
|
35
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
36
|
+
"./deck-bridge": "./lib/deck-bridge.js"
|
|
36
37
|
},
|
|
37
38
|
"files": [
|
|
38
39
|
"lib",
|
|
@@ -102,6 +103,6 @@
|
|
|
102
103
|
"test:coverage": "node scripts/coverage-union.mjs",
|
|
103
104
|
"test:coverage:gate": "node scripts/coverage-union.mjs --gate 70 --file-gate 60"
|
|
104
105
|
},
|
|
105
|
-
"readme": "[English](https://github.com/flymysql/dsh-remote/blob/main/README.en.md) · **中文**\n\n# dsh-remote\n\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://github.com/flymysql/dsh-remote/blob/main/LICENSE)\n[](https://github.com/topics/dsh-plugin)\n\n由 [@flymysql](https://github.com/flymysql) 维护 · [主页](https://flymysql.github.io/dsh-remote/) · [用量统计](https://flymysql.github.io/dsh-remote/stats/) · [博客](https://gitpull.cn) · [讨论区](https://github.com/flymysql/dsh-remote/discussions) · [Issue](https://github.com/flymysql/dsh-remote/issues) · [English](https://github.com/flymysql/dsh-remote/blob/main/README.en.md)\n\n\n\n在 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 中,把 SSH 主机变成日常开发工作区:管理多主机项目,浏览和编辑远程文件、递归搜索文件与内容、使用终端、查看 Git 差异、建立本地/反向端口隧道;让 Agent 在所属远程工作区中读写文件、执行命令、构建和测试。多个工作区可独立并行。\n\n可按习惯使用普通布局,或切换 **IDE 三栏布局**,并排查看远程文件、编辑器与原生 Agent 会话;切换时保留任务和未保存编辑。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-ide.png\" alt=\"DSH 远程工作区 IDE 模式:远程文件树、代码编辑器和原生 Agent 会话三栏\" width=\"1200\"/>\n\n## 安装\n\n```bash\ndsh plugin --profile web add dsh-remote\n```\n\n安装或升级后,重启 DSH Web 并刷新页面。自动更新状态在设置 → 远程工作区 → 插件偏好中查看。\n\n## 3 步开始\n\n1. **配置主机**:设置 → 远程工作区,编辑 SSH
|
|
106
|
+
"readme": "[English](https://github.com/flymysql/dsh-remote/blob/main/README.en.md) · **中文**\n\n# dsh-remote\n\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://www.npmjs.com/package/dsh-remote)\n[](https://github.com/flymysql/dsh-remote/blob/main/LICENSE)\n[](https://github.com/topics/dsh-plugin)\n\n由 [@flymysql](https://github.com/flymysql) 维护 · [主页](https://flymysql.github.io/dsh-remote/) · [用量统计](https://flymysql.github.io/dsh-remote/stats/) · [博客](https://gitpull.cn) · [讨论区](https://github.com/flymysql/dsh-remote/discussions) · [Issue](https://github.com/flymysql/dsh-remote/issues) · [English](https://github.com/flymysql/dsh-remote/blob/main/README.en.md)\n\n\n\n在 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 中,把 SSH 主机变成日常开发工作区:管理多主机项目,浏览和编辑远程文件、递归搜索文件与内容、使用终端、查看 Git 差异、建立本地/反向端口隧道;让 Agent 在所属远程工作区中读写文件、执行命令、构建和测试。多个工作区可独立并行。\n\n可按习惯使用普通布局,或切换 **IDE 三栏布局**,并排查看远程文件、编辑器与原生 Agent 会话;切换时保留任务和未保存编辑。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-ide.png\" alt=\"DSH 远程工作区 IDE 模式:远程文件树、代码编辑器和原生 Agent 会话三栏\" width=\"1200\"/>\n\n## 安装\n\n```bash\ndsh plugin --profile web add dsh-remote\n```\n\n安装或升级后,重启 DSH Web 并刷新页面。自动更新状态在设置 → 远程工作区 → 插件偏好中查看。\n\n[1.3.1 更新说明](https://github.com/flymysql/dsh-remote/blob/main/docs/release/1.3.1.md):SSH 连接恢复、代理网络更新与官方 GitHub 下载回退。\n\n## 3 步开始\n\n1. **配置主机**:设置 → 远程工作区,编辑 SSH 配置或保存主机凭据;直接写在 `~/.ssh/config` 里的 Host 会出现在主机列表中,点该行的「…」菜单 →「编辑」即可保存成机器并填写登录密码(保存前后入口都是同一个「…」菜单)。打开设置会自动检查连通性,无需手动“连接”。\n2. **创建工作区**:添加工作区 → 远程,选择主机与目录。每个工作区独立绑定主机,设置页不选目录或“当前远程机”。\n3. **开始开发**:打开工作区文件或切换 IDE 模式,文件打开即可编辑并显示语法高亮,在远端搜索、运行命令并与 Agent 协作。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workspace-picker-browse.png\" alt=\"选择远程目录:固定路径与确认栏,目录列表占据弹窗主要区域\" width=\"720\"/>\n\n## 本地工作区也能用\n\n打开普通本地项目后,点击 **IDE 模式** 或 **工作区文件**,即可使用同一套文件树、高亮编辑、递归搜索、Git 差异与本地终端。无需配置 SSH;Agent 继续使用宿主原生文件和命令工具,多个本地、远程项目可并行工作。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-local.png\" alt=\"本地工作区:文件搜索、高亮编辑和原生 Agent 会话,Agent 已实际完成本地构建\" width=\"1200\"/>\n\n## 日常开发\n\n### 搜索远端文件与内容\n\n文件、目录和内容递归搜索,无需先展开目录或同步镜像。默认界面只显示搜索范围与进度摘要;按需展开搜索选项、扫描详情,支持大小写、忽略项、停止与重试。点击结果进入目录或文件对应行。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-search-results.png\" alt=\"简洁远程搜索:名称搜索结果包含嵌套目录与文件\" width=\"675\"/>\n\n### 查看远端 Git 改动\n\n分别查看工作区和已暂存 diff,筛选文件,点击改动行定位源码。面板只读,不提交或修改暂存区。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-git.png\" alt=\"远端 Git 工作区与已暂存改动、文件列表和源码 diff\" width=\"675\"/>\n\n### 在远端运行终端\n\n终端进入当前会话的远程目录;像素鱼欢迎图后接真实 SSH shell。已保存凭据可自动应答,支持多终端并行。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-terminal.png\" alt=\"DSH 远程终端:像素鱼欢迎图与实际 SSH 命令输出\" width=\"1000\"/>\n\n### 端口转发(SSH 隧道)\n\n谁要发起访问,就在谁那边开监听口:监听口开在本机是本地转发(`ssh -L`),开在远端是远程转发(`ssh -R`)。可同时运行多条;添加转发时可以选择「主机」,每条转发只属于一台机器——给还没连接的主机也能先存下转发,连上后再启动。每条转发都可以点「编辑」调整方向、端口、目标或所属主机,运行中的会先停止、保存后按新配置重新启动。每行能直接勾选「自动重连」——只恢复上次运行中的转发,且按机器隔离,反向转发首次勾选会提示远端监听风险。\n\n从旧版本升级:旧版没有 `lastActive` 的「自动重连」配置会暂停,行上显示「需重新确认」;重新勾选后才会参与自动恢复(反向转发需重新确认远端监听)。\n\n<img src=\"docs/shots/port-forwards.png\" alt=\"端口转发面板:本地/反向方向、自动重连勾选框与添加转发表单\" width=\"900\"/>\n\n### 与 Agent 一起修改和构建\n\n工具卡展示已应用改动、实际退出码和构建输出,编译诊断可跳转源码。编辑器保存会检测远端冲突、保留 CRLF,并保护保存期间继续输入的内容。\n\n<img src=\"https://raw.githubusercontent.com/flymysql/dsh-remote/main/docs/shots/workbench-applied-diff.png\" alt=\"Agent 远程编辑成功后的已应用 diff、路径与增删行数\" width=\"485\"/>\n\n## 兼容与边界\n\n- 主要面向 **DSH Web 0.2.x**;0.2.2 需要 **Node.js ≥24.9**。旧版宿主回退、Desktop/TUI 与 Agent diff 差异见[兼容说明](https://github.com/flymysql/dsh-remote/blob/main/docs/reference.zh.md#dsh-版本兼容性)。\n- 文件栏直接访问远端;镜像按需同步。草稿在当前页面内存,崩溃或强制退出仍可能丢失。\n- 不提供远端语言服务、扩展宿主或调试器。Agent 使用配置的 SSH 身份执行命令,请只配置可信主机。\n\n## 文档与社区\n\n[完整工具与配置参考](https://github.com/flymysql/dsh-remote/blob/main/docs/reference.zh.md) · [排障](https://github.com/flymysql/dsh-remote/blob/main/docs/troubleshooting.md) · [自更新修复](https://github.com/flymysql/dsh-remote/blob/main/docs/self-heal.md) · [升级指南](https://github.com/flymysql/dsh-remote/blob/main/docs/migration-1.0.md) · [更新记录](https://github.com/flymysql/dsh-remote/blob/main/CHANGELOG.md)\n\n[主页](https://flymysql.github.io/dsh-remote/) · [讨论区](https://github.com/flymysql/dsh-remote/discussions) · [反馈问题](https://github.com/flymysql/dsh-remote/issues) · [贡献指南](https://github.com/flymysql/dsh-remote/blob/main/CONTRIBUTING.md) · [贡献者与致谢](#贡献者与致谢)\n\n由 [@flymysql](https://github.com/flymysql) 与社区共同维护 · [MIT](https://github.com/flymysql/dsh-remote/blob/main/LICENSE)\n\n### 贡献者与致谢\n\n感谢每一位让这个项目更好的朋友(头像可点进主页;按提交数排序,机器人不计):\n\n<p align=\"left\">\n <a href=\"https://github.com/flymysql\"><img src=\"https://avatars.githubusercontent.com/u/37113068?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@flymysql\" title=\"@flymysql\" /></a>\n <a href=\"https://github.com/baiseraku\"><img src=\"https://avatars.githubusercontent.com/u/139727690?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@baiseraku\" title=\"@baiseraku\" /></a>\n <a href=\"https://github.com/glzhangzhi\"><img src=\"https://avatars.githubusercontent.com/u/36995275?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@glzhangzhi\" title=\"@glzhangzhi\" /></a>\n <a href=\"https://github.com/hjwsm1989\"><img src=\"https://avatars.githubusercontent.com/u/1067541?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@hjwsm1989\" title=\"@hjwsm1989\" /></a>\n <a href=\"https://github.com/j10ha0\"><img src=\"https://avatars.githubusercontent.com/u/72346906?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@j10ha0\" title=\"@j10ha0\" /></a>\n <a href=\"https://github.com/FoolishWiser\"><img src=\"https://avatars.githubusercontent.com/u/104308087?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@FoolishWiser\" title=\"@FoolishWiser\" /></a>\n <a href=\"https://github.com/kakaa-nju\"><img src=\"https://avatars.githubusercontent.com/u/79886619?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@kakaa-nju\" title=\"@kakaa-nju\" /></a>\n <a href=\"https://github.com/4FMTWRV\"><img src=\"https://avatars.githubusercontent.com/u/190457700?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@4FMTWRV\" title=\"@4FMTWRV\" /></a>\n <a href=\"https://github.com/dahaipeng\"><img src=\"https://avatars.githubusercontent.com/u/25660610?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@dahaipeng\" title=\"@dahaipeng\" /></a>\n <a href=\"https://github.com/davidlin2k\"><img src=\"https://avatars.githubusercontent.com/u/17074619?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@davidlin2k\" title=\"@davidlin2k\" /></a>\n <a href=\"https://github.com/FlintyLemming\"><img src=\"https://avatars.githubusercontent.com/u/19165511?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@FlintyLemming\" title=\"@FlintyLemming\" /></a>\n <a href=\"https://github.com/GDWhisper\"><img src=\"https://avatars.githubusercontent.com/u/129148123?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@GDWhisper\" title=\"@GDWhisper\" /></a>\n <a href=\"https://github.com/YiHui-Liu\"><img src=\"https://avatars.githubusercontent.com/u/30190271?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@YiHui-Liu\" title=\"@YiHui-Liu\" /></a>\n <a href=\"https://github.com/Minggle\"><img src=\"https://avatars.githubusercontent.com/u/35053182?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@Minggle\" title=\"@Minggle\" /></a>\n <a href=\"https://github.com/nekomona\"><img src=\"https://avatars.githubusercontent.com/u/25474483?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@nekomona\" title=\"@nekomona\" /></a>\n <a href=\"https://github.com/shis23\"><img src=\"https://avatars.githubusercontent.com/u/189869650?s=80&v=4\" width=\"40\" height=\"40\" alt=\"@shis23\" title=\"@shis23\" /></a>\n</p>\n\n<details>\n<summary>贡献记录与早期贡献者</summary>\n\n近期的亮点贡献(欢迎随时加入这个名单):\n\n| 贡献者 | 做了什么 |\n| --- | --- |\n| [@baiseraku](https://github.com/baiseraku) | 整个 dsh-tui 适配层([#92](https://github.com/flymysql/dsh-remote/pull/92))+ 底栏机器名修正([#98](https://github.com/flymysql/dsh-remote/pull/98)) |\n| [@hjwsm1989](https://github.com/hjwsm1989) | 远程 .md 渲染连环两道:memo 守卫([#102](https://github.com/flymysql/dsh-remote/pull/102))+ labels 契约([#107](https://github.com/flymysql/dsh-remote/pull/107)) |\n| [@shis23](https://github.com/shis23) | rw_sync 路径映射纠偏 + SFTP 超时韧性([#105](https://github.com/flymysql/dsh-remote/pull/105)) |\n| [@davidlin2k](https://github.com/davidlin2k) | 无凭据机器走用户自有 ssh([#100](https://github.com/flymysql/dsh-remote/pull/100)) |\n| [@GDWhisper](https://github.com/GDWhisper) | 目录补全逐字符重连修复([#42](https://github.com/flymysql/dsh-remote/pull/42),issue #41) |\n| [@glzhangzhi](https://github.com/glzhangzhi) | 多远端会话的连接池隔离(issue #25 的主体修复) |\n\n早期已合并 PR 的贡献者(考古名单):\n\n\n\n[@dahaipeng](https://github.com/dahaipeng) (#31) ·\n[@YiHui-Liu](https://github.com/YiHui-Liu) (#28) ·\n[@nekomona](https://github.com/nekomona) (#24) ·\n[@zhz1667](https://github.com/zhz1667) (#43) ·\n[FoolishWiser](https://github.com/FoolishWiser) (#17) ·\n[@jace1cch](https://github.com/jace1cch) (#16) ·\n[@Minggle](https://github.com/Minggle) (#10) ·\n[4FMTWRV](https://github.com/4FMTWRV) (#6) ·\n[glzhangzhi](https://github.com/glzhangzhi)(per-session SSH 连接池修复)\n\n> 名单随版本更新;头像墙之外的每一份 issue 报告、复现步骤、根因线索同样珍贵——\n> 本仓库近半修复的起点都是一条写清楚的 issue。\n\n</details>\n",
|
|
106
107
|
"readmeFilename": "README.md"
|
|
107
108
|
}
|