@xi-ix/dsh-multi-sync 0.1.2 → 0.1.4
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.md +1 -1
- package/client.js +5 -1
- package/docs/DETAIL.md +2 -2
- package/index.js +51 -8
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ and writes it to one portable JSON document.
|
|
|
38
38
|
5. Restart DeepSeek Harness so the newly installed plugins load.
|
|
39
39
|
|
|
40
40
|
The first time, the follower has no copy of this plugin yet, so install it by hand
|
|
41
|
-
once: `dsh plugin --profile desktop add @xi-ix/dsh-multi-sync
|
|
41
|
+
once: `dsh plugin --profile desktop add @xi-ix/dsh-multi-sync`.
|
|
42
42
|
|
|
43
43
|
## What it deliberately does not do
|
|
44
44
|
|
package/client.js
CHANGED
|
@@ -57,6 +57,8 @@ window.__ModuleLoader__.load({
|
|
|
57
57
|
linked: '本地挂载',
|
|
58
58
|
added: '新增',
|
|
59
59
|
local: '本地',
|
|
60
|
+
'local-unpublished': '本地(该版本未发布)',
|
|
61
|
+
localOrigin: '本地挂载 · 已发布',
|
|
60
62
|
remote: '非 registry',
|
|
61
63
|
unknown: '未知',
|
|
62
64
|
alreadyTitle: '这些已经装过,不会重复处理',
|
|
@@ -112,6 +114,8 @@ window.__ModuleLoader__.load({
|
|
|
112
114
|
linked: 'local link',
|
|
113
115
|
added: 'new',
|
|
114
116
|
local: 'local',
|
|
117
|
+
'local-unpublished': 'local (version not published)',
|
|
118
|
+
localOrigin: 'local mount · published',
|
|
115
119
|
remote: 'non-registry',
|
|
116
120
|
unknown: 'unknown',
|
|
117
121
|
alreadyTitle: 'Already installed — left untouched',
|
|
@@ -471,7 +475,7 @@ window.__ModuleLoader__.load({
|
|
|
471
475
|
{ key: row.name },
|
|
472
476
|
h('td', null, row.name),
|
|
473
477
|
h('td', null, row.version || '—'),
|
|
474
|
-
h('td', null, row.bundle ? 'bundle' : 'dep'),
|
|
478
|
+
h('td', null, (row.bundle ? 'bundle' : 'dep') + (row.origin === 'local' ? ' · ' + L.localOrigin : '')),
|
|
475
479
|
),
|
|
476
480
|
),
|
|
477
481
|
list.skipped.map((row) =>
|
package/docs/DETAIL.md
CHANGED
|
@@ -52,10 +52,10 @@ one resolution, one lockfile write, and one bundle registration pass.
|
|
|
52
52
|
## First run on the new machine
|
|
53
53
|
|
|
54
54
|
This plugin cannot install itself before it exists on that machine, so install it
|
|
55
|
-
once by hand:
|
|
55
|
+
once by hand — without a version pin, so this line never goes stale:
|
|
56
56
|
|
|
57
57
|
```
|
|
58
|
-
dsh plugin --profile desktop add @xi-ix/dsh-multi-sync
|
|
58
|
+
dsh plugin --profile desktop add @xi-ix/dsh-multi-sync
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
Then restart, open Settings → Multi-sync, and choose **Follower**.
|
package/index.js
CHANGED
|
@@ -225,6 +225,25 @@ function compareVersions(a, b) {
|
|
|
225
225
|
|
|
226
226
|
// ---------------------------------------------------------------- operations
|
|
227
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Whether the registry already serves this exact version.
|
|
230
|
+
*
|
|
231
|
+
* A locally linked plugin that has been published is a normal downloadable entry
|
|
232
|
+
* for the other machine, so the scan asks instead of assuming that every `link:`
|
|
233
|
+
* or `file:` spec is unshareable. An unreachable registry answers "no", which
|
|
234
|
+
* degrades to the previous behaviour rather than failing the scan.
|
|
235
|
+
*/
|
|
236
|
+
async function publishedAt(packageName, version) {
|
|
237
|
+
const base = process.env.npm_config_registry || 'https://registry.npmjs.org/'
|
|
238
|
+
const url = `${base.replace(/\/+$/, '')}/${encodeURIComponent(packageName)}/${encodeURIComponent(version)}`
|
|
239
|
+
try {
|
|
240
|
+
const response = await fetch(url, { headers: { accept: 'application/json' }, signal: AbortSignal.timeout(6000) })
|
|
241
|
+
return response.ok
|
|
242
|
+
} catch {
|
|
243
|
+
return false
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
228
247
|
async function scan() {
|
|
229
248
|
const profile = resolveProfile()
|
|
230
249
|
const manifest = await readJson(join(profile.dir, 'package.json'))
|
|
@@ -236,7 +255,20 @@ async function scan() {
|
|
|
236
255
|
for (const [packageName, spec] of Object.entries(dependencies)) {
|
|
237
256
|
const kind = specKind(String(spec))
|
|
238
257
|
if (kind !== 'registry') {
|
|
239
|
-
|
|
258
|
+
// Local mount: it still travels if the same version is on the registry.
|
|
259
|
+
const facts = await installedFacts(profile.dir, packageName)
|
|
260
|
+
if (facts?.version && PACKAGE_NAME.test(packageName) && (await publishedAt(packageName, facts.version))) {
|
|
261
|
+
plugins.push({
|
|
262
|
+
name: packageName,
|
|
263
|
+
version: facts.version,
|
|
264
|
+
spec: String(spec),
|
|
265
|
+
bundle: facts.bundle ?? bundles.has(packageName),
|
|
266
|
+
present: true,
|
|
267
|
+
origin: 'local',
|
|
268
|
+
})
|
|
269
|
+
continue
|
|
270
|
+
}
|
|
271
|
+
skipped.push({ name: packageName, spec: String(spec), reason: facts?.version ? 'local-unpublished' : kind })
|
|
240
272
|
continue
|
|
241
273
|
}
|
|
242
274
|
if (!PACKAGE_NAME.test(packageName)) {
|
|
@@ -397,6 +429,19 @@ function cliAttempts(args) {
|
|
|
397
429
|
const nodeExecutable = process.env.DSH_NODE_EXECUTABLE
|
|
398
430
|
const installDir = process.env.DSH_INSTALL_DIR
|
|
399
431
|
const asNode = { env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' } }
|
|
432
|
+
const resources = resourcesRoot()
|
|
433
|
+
|
|
434
|
+
// The runtime shim is the installed carrier: only it is allowed to manage the
|
|
435
|
+
// desktop profile (`manageDesktopProfile`), so it is tried before the bare CLI.
|
|
436
|
+
if (resources) {
|
|
437
|
+
for (const relative of [join('runtime', 'cli', 'bin'), join('runtime', 'cli'), join('cli', 'bin'), 'bin']) {
|
|
438
|
+
for (const name of platform() === 'win32' ? ['dsh.cmd', 'dsh.exe'] : ['dsh', 'dsh.sh']) {
|
|
439
|
+
const shim = join(resources, relative, name)
|
|
440
|
+
if (!existsSync(shim)) continue
|
|
441
|
+
attempts.push({ command: shim, argv: args, options: { shell: platform() === 'win32' }, label: `${shim} ${args.join(' ')}` })
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}
|
|
400
445
|
|
|
401
446
|
if (nodeExecutable && installDir) {
|
|
402
447
|
attempts.push({
|
|
@@ -407,7 +452,6 @@ function cliAttempts(args) {
|
|
|
407
452
|
})
|
|
408
453
|
}
|
|
409
454
|
|
|
410
|
-
const resources = resourcesRoot()
|
|
411
455
|
if (resources) {
|
|
412
456
|
for (const relative of [
|
|
413
457
|
join('app.asar', 'dsh', 'node_modules', '@deepseek-ai', 'dsh', 'lib', 'bin.js'),
|
|
@@ -423,11 +467,6 @@ function cliAttempts(args) {
|
|
|
423
467
|
label: `${process.execPath} ${entry} ${args.join(' ')}`,
|
|
424
468
|
})
|
|
425
469
|
}
|
|
426
|
-
for (const relative of [join('runtime', 'cli', 'bin'), join('cli', 'bin')]) {
|
|
427
|
-
const shim = join(resources, relative, platform() === 'win32' ? 'dsh.cmd' : 'dsh')
|
|
428
|
-
if (!existsSync(shim)) continue
|
|
429
|
-
attempts.push({ command: shim, argv: args, options: {}, label: `${shim} ${args.join(' ')}` })
|
|
430
|
-
}
|
|
431
470
|
}
|
|
432
471
|
|
|
433
472
|
attempts.push({
|
|
@@ -446,8 +485,12 @@ async function runDsh(args) {
|
|
|
446
485
|
for (const attempt of cliAttempts(args)) {
|
|
447
486
|
tried.push(attempt.label)
|
|
448
487
|
last = await runOnce(attempt.command, attempt.argv, attempt.options)
|
|
488
|
+
if (last.ok) return { ...last, command: attempt.label, tried }
|
|
449
489
|
const missing = last.code === 'ENOENT' || /not found|不是内部或外部命令|cannot find/i.test(last.stderr)
|
|
450
|
-
|
|
490
|
+
// A bare CLI refuses the desktop profile by design; that is not the end of the
|
|
491
|
+
// search, because the runtime carrier on the next line is allowed to do it.
|
|
492
|
+
const wrongEntry = /managed exclusively|managed by the Electron application/i.test(last.stderr)
|
|
493
|
+
if (missing || wrongEntry) continue
|
|
451
494
|
return { ...last, command: attempt.label, tried }
|
|
452
495
|
}
|
|
453
496
|
return { ...(last ?? { ok: false, stdout: '', stderr: '' }), command: 'none', ok: false, tried }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xi-ix/dsh-multi-sync",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Copy one machine's installed DSH plugin list to another: scan the profile, export a pinned list, then install the selected entries on the other machine.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -50,3 +50,5 @@
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
|
|
54
|
+
|