@xi-ix/dsh-multi-sync 0.1.1 → 0.1.3

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 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@<version>`.
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
@@ -44,6 +44,7 @@ window.__ModuleLoader__.load({
44
44
  noRows: '清单里没有可安装的 npm 插件。',
45
45
  nothingSelected: '没有选中任何插件(「已装」的行不会重复安装)。',
46
46
  cliMissing: '找不到 dsh 命令行。试过:',
47
+ manualHint: '可以在终端里手动执行:',
47
48
  from: '清单来源',
48
49
  generatedAt: '生成时间',
49
50
  mismatch: '清单来自另一台机器,DSH 版本不同,安装前请留意。',
@@ -98,6 +99,7 @@ window.__ModuleLoader__.load({
98
99
  noRows: 'The list has no installable npm plugin.',
99
100
  nothingSelected: 'Nothing is selected ("installed" rows are not reinstalled).',
100
101
  cliMissing: 'Cannot find the dsh CLI. Tried:',
102
+ manualHint: 'You can run this in a terminal instead:',
101
103
  from: 'List from',
102
104
  generatedAt: 'Generated',
103
105
  mismatch: 'This list came from a machine running a different DSH version — check before installing.',
@@ -324,7 +326,8 @@ window.__ModuleLoader__.load({
324
326
  } else {
325
327
  const detail = body.result.stderr || body.result.message || 'install failed'
326
328
  const tried = Array.isArray(body.result.tried) && body.result.tried.length > 0 ? `\n\n${L.cliMissing}\n${body.result.tried.join('\n')}` : ''
327
- setMessage({ kind: 'err', text: detail + tried })
329
+ const manual = body.result.manual ? `\n\n${L.manualHint}\n${body.result.manual}` : ''
330
+ setMessage({ kind: 'err', text: detail + tried + manual })
328
331
  }
329
332
  } catch (error) {
330
333
  setMessage({ kind: 'err', text: String(error.message || error) })
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@0.1.0
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
@@ -18,7 +18,7 @@ import { existsSync, readdirSync } from 'node:fs'
18
18
  import { readFile, writeFile } from 'node:fs/promises'
19
19
  import { execFile } from 'node:child_process'
20
20
  import { homedir, platform } from 'node:os'
21
- import { basename, join } from 'node:path'
21
+ import { basename, dirname, join } from 'node:path'
22
22
 
23
23
  export const name = '@xi-ix/dsh-multi-sync'
24
24
  export const inject = ['webServer']
@@ -370,11 +370,46 @@ function runOnce(command, argv, options) {
370
370
  * whatever `dsh` the PATH offers. Each candidate is tried until one is not simply
371
371
  * missing, so a machine without the CLI reports every location it looked at.
372
372
  */
373
+ /**
374
+ * The app's `Resources` directory.
375
+ *
376
+ * `process.resourcesPath` exists only in an Electron process; the host this plugin
377
+ * runs in may be a plain Node child of the desktop shell. Deriving it from the
378
+ * executable covers that: macOS keeps it at `Contents/Resources` beside
379
+ * `Contents/MacOS`, Windows at `resources` beside the executable.
380
+ */
381
+ function resourcesRoot() {
382
+ if (process.resourcesPath) return process.resourcesPath
383
+ const executable = process.execPath
384
+ if (typeof executable !== 'string' || executable === '') return undefined
385
+ const candidates =
386
+ platform() === 'darwin'
387
+ ? [join(dirname(executable), '..', 'Resources')]
388
+ : [join(dirname(executable), 'resources'), join(dirname(executable), '..', 'resources')]
389
+ for (const candidate of candidates) {
390
+ if (existsSync(candidate)) return candidate
391
+ }
392
+ return undefined
393
+ }
394
+
373
395
  function cliAttempts(args) {
374
396
  const attempts = []
375
397
  const nodeExecutable = process.env.DSH_NODE_EXECUTABLE
376
398
  const installDir = process.env.DSH_INSTALL_DIR
377
399
  const asNode = { env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' } }
400
+ const resources = resourcesRoot()
401
+
402
+ // The runtime shim is the installed carrier: only it is allowed to manage the
403
+ // desktop profile (`manageDesktopProfile`), so it is tried before the bare CLI.
404
+ if (resources) {
405
+ for (const relative of [join('runtime', 'cli', 'bin'), join('runtime', 'cli'), join('cli', 'bin'), 'bin']) {
406
+ for (const name of platform() === 'win32' ? ['dsh.cmd', 'dsh.exe'] : ['dsh', 'dsh.sh']) {
407
+ const shim = join(resources, relative, name)
408
+ if (!existsSync(shim)) continue
409
+ attempts.push({ command: shim, argv: args, options: { shell: platform() === 'win32' }, label: `${shim} ${args.join(' ')}` })
410
+ }
411
+ }
412
+ }
378
413
 
379
414
  if (nodeExecutable && installDir) {
380
415
  attempts.push({
@@ -385,11 +420,11 @@ function cliAttempts(args) {
385
420
  })
386
421
  }
387
422
 
388
- const resources = process.resourcesPath
389
423
  if (resources) {
390
424
  for (const relative of [
391
425
  join('app.asar', 'dsh', 'node_modules', '@deepseek-ai', 'dsh', 'lib', 'bin.js'),
392
426
  join('app', 'dsh', 'node_modules', '@deepseek-ai', 'dsh', 'lib', 'bin.js'),
427
+ join('app.asar.unpacked', 'dsh', 'node_modules', '@deepseek-ai', 'dsh', 'lib', 'bin.js'),
393
428
  ]) {
394
429
  const entry = join(resources, relative)
395
430
  if (!existsSync(entry)) continue
@@ -400,15 +435,6 @@ function cliAttempts(args) {
400
435
  label: `${process.execPath} ${entry} ${args.join(' ')}`,
401
436
  })
402
437
  }
403
- const shim = join(resources, 'runtime', 'cli', 'bin', platform() === 'win32' ? 'dsh.cmd' : 'dsh')
404
- if (existsSync(shim)) {
405
- attempts.push({
406
- command: shim,
407
- argv: args,
408
- options: { shell: platform() === 'win32' },
409
- label: `${shim} ${args.join(' ')}`,
410
- })
411
- }
412
438
  }
413
439
 
414
440
  attempts.push({
@@ -427,8 +453,12 @@ async function runDsh(args) {
427
453
  for (const attempt of cliAttempts(args)) {
428
454
  tried.push(attempt.label)
429
455
  last = await runOnce(attempt.command, attempt.argv, attempt.options)
456
+ if (last.ok) return { ...last, command: attempt.label, tried }
430
457
  const missing = last.code === 'ENOENT' || /not found|不是内部或外部命令|cannot find/i.test(last.stderr)
431
- if (missing) continue
458
+ // A bare CLI refuses the desktop profile by design; that is not the end of the
459
+ // search, because the runtime carrier on the next line is allowed to do it.
460
+ const wrongEntry = /managed exclusively|managed by the Electron application/i.test(last.stderr)
461
+ if (missing || wrongEntry) continue
432
462
  return { ...last, command: attempt.label, tried }
433
463
  }
434
464
  return { ...(last ?? { ok: false, stdout: '', stderr: '' }), command: 'none', ok: false, tried }
@@ -451,6 +481,7 @@ async function applyList(items) {
451
481
  specs,
452
482
  command: run.command,
453
483
  tried: run.tried ?? [],
484
+ manual: `dsh plugin --profile ${profile.name} add ${specs.join(' ')}`,
454
485
  exitCode: typeof run.code === 'number' ? run.code : null,
455
486
  stdout: tail(run.stdout),
456
487
  stderr: tail(run.stderr),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xi-ix/dsh-multi-sync",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
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",
@@ -49,3 +49,5 @@
49
49
  }
50
50
  }
51
51
  }
52
+
53
+