dsh-go-plugin-sync 0.4.2 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.4 — 2026-12-04
4
+
5
+ ### 改进
6
+ - dsh-go 面板:「显示全部 / 只看待处理」从主按钮排移到列表下方、复制同步码上方,避免和主操作挤在一行
7
+ - dsh-go 面板补上「配置 Git 仓库」「配置 SSH」两个入口,各带一张表单(仓库地址/分支/目录;主机/端口/用户/私钥/远端 HOME),保存到同一份 plugin-sync-config.json;留空字段保持原值
8
+ - 文案统一(两端):「应用所选 / 执行选中」改为「下载并安装」,「重置清单 / 清空列表」改为「重置插件列表」,「重试失败」改为「重试失败项」,使用引导的步骤说明同步更新
9
+
10
+ ## 0.4.3 — 2026-12-04
11
+
12
+ ### 改进
13
+ - dsh-go 面板按钮精简:「全选/取消全选」合并成一个切换;去掉「导出清单」「工作区导入」;「清空清单」改名「重置清单」;「重试失败」只在有失败项时出现并带数量;「使用引导」保留
14
+ - 「使用引导」改成纯文字说明,不再带操作按钮;安装失败日志补充 target(装的是哪个目录或哪个包)
15
+ - 安装失败会自动补一行「原因:」白话结论(超时、断网、权限、缺文件、包不存在、依赖冲突、该端不支持),电脑端和 dsh-go 面板都能看到;日志尾部展示行数增加(dsh-go 8 行、电脑端 12 行);修复「没有可安装来源」时原因写在失败标记之后导致读不到的顺序问题
16
+ - 失败归因更准:404 与版本不兼容不再误判成缺文件;pnpm 原文只在 packageResult.output 里时也能归因;结果行优先显示「target + 原因」,超长时保留尾部
17
+ - 取消任务改为按轮次隔离(run token):取消后旧循环不能再写日志/状态,也不会把剩余项装进新任务;取消结果行显示「任务被用户取消」而不是 stop 时间戳
18
+ - pnpm 原文与安装器 logPath 会写进任务日志(原因行之前),日志尾部能看到原始错误
19
+ - dsh-go 面板只列清单里的待处理插件:新增「待处理插件(N)」标题,去掉本机插件列表,清单外(仅本机有)的插件也不再显示;复制同步码在没选插件时默认带上全部本机插件
20
+ - dsh-go 面板的清单列表按电脑端风格精简:每行只显示名称和一句短状态,不再重复版本号与动作后缀;状态文案改为「可安装」「本地已有」「本地已有,版本不同」「仅dshgo」「仅电脑/网页」「缺文件」等;未选中项不再显示圆圈,选中后才出现 ✓
21
+ - 本地插件列表同样只保留名称 + 版本,可安装项排在前面
22
+
3
23
  ## 0.4.2 — 2026-12-04
4
24
 
5
25
  ### 修复
package/lib/client.js CHANGED
@@ -185,12 +185,12 @@ window.__ModuleLoader__.load({
185
185
  }).catch((error) => { setBusy(false); note(String(error && error.message || error), 'bad') })
186
186
  }
187
187
  const clearList = () => {
188
- if (!window.confirm(T('清空待处理插件列表?导入新的同步码后会恢复。', 'Clear the pending list? Import a new sync code to restore it.'))) return
188
+ if (!window.confirm(T('重置插件列表?导入新的同步码后会恢复。', 'Reset the plugin list? Import a new sync code to restore it.'))) return
189
189
  setBusy(true)
190
190
  api('action', { action: 'clear' }).then((result) => {
191
191
  setBusy(false)
192
192
  if (result.error) { note(result.error, 'bad'); return }
193
- note(T('列表已清空', 'List cleared'), 'good')
193
+ note(T('已重置插件列表', 'Plugin list reset'), 'good')
194
194
  load()
195
195
  }).catch((error) => { setBusy(false); note(String(error && error.message || error), 'bad') })
196
196
  }
@@ -295,7 +295,7 @@ window.__ModuleLoader__.load({
295
295
  h('button', { type: 'button', style: BUTTON, disabled: busy, onClick: load }, T('刷新', 'Refresh')))),
296
296
 
297
297
  cleared && h('div', { style: { fontSize: '12px', opacity: 0.6 } },
298
- T('待处理列表已清空,重新导入同步码后会恢复。', 'The pending list was cleared. Import a new sync code to restore it.')),
298
+ T('插件列表已重置,重新导入同步码后会恢复。', 'The plugin list was reset. Import a new sync code to restore it.')),
299
299
 
300
300
  pendingRows.length > 0 && h('div', { style: { display: 'flex', flexDirection: 'column', gap: '4px' } },
301
301
  h('div', { style: { fontWeight: 600 } }, T('待处理插件', 'Pending plugins')),
@@ -303,8 +303,8 @@ window.__ModuleLoader__.load({
303
303
  h('div', { style: { display: 'flex', gap: '8px', marginTop: '4px', flexWrap: 'wrap' } },
304
304
  h('button', { type: 'button', style: BUTTON, onClick: () => all(true) }, T('全选', 'Select all')),
305
305
  h('button', { type: 'button', style: BUTTON, onClick: () => all(false) }, T('取消全选', 'Deselect all')),
306
- h('button', { type: 'button', style: PRIMARY, disabled: busy || running, onClick: applySelected }, T('执行选中', 'Run selected')),
307
- h('button', { type: 'button', style: BUTTON, disabled: busy || running, onClick: clearList }, T('清空列表', 'Clear list')))),
306
+ h('button', { type: 'button', style: PRIMARY, disabled: busy || running, onClick: applySelected }, T('下载并安装', 'Download & install')),
307
+ h('button', { type: 'button', style: BUTTON, disabled: busy || running, onClick: clearList }, T('重置插件列表', 'Reset plugin list')))),
308
308
 
309
309
  installedRows.length > 0 && h('details', { style: { fontSize: '13px' } },
310
310
  h('summary', { style: { cursor: 'pointer', opacity: 0.7 } },
package/lib/index.js CHANGED
@@ -758,11 +758,18 @@ function readTaskResults() {
758
758
  continue
759
759
  }
760
760
  if (current && current.action === action && current.name === name) {
761
+ const targetLine = current.lines.find((line) => line.startsWith('target '))
762
+ const hintLine = current.lines.find((line) => line.startsWith('原因:'))
763
+ const others = current.lines.filter((line) => line.trim() !== '' && !line.startsWith('target ') && !line.startsWith('原因:') && !line.startsWith('stop '))
764
+ const parts = [targetLine, hintLine]
765
+ if (!hintLine && others.length > 0) parts.push(others[others.length - 1])
761
766
  results.push({
762
767
  action,
763
768
  name,
764
769
  ok: phase === 'ok',
765
- message: phase === 'fail' ? current.lines.slice(-2).join(' ').slice(0, 140) : '',
770
+ message: phase === 'fail'
771
+ ? (parts.filter(Boolean).join(' ').slice(-200) || current.lines.slice(-3).join(' ').slice(-200))
772
+ : '',
766
773
  })
767
774
  current = undefined
768
775
  }
@@ -798,6 +805,10 @@ function taskRunning() {
798
805
  return Boolean(status?.running && Date.now() - status.startedAt < 15 * 60 * 1000)
799
806
  }
800
807
 
808
+ /** Per-run token: cancelling marks the current run so it can never write into the next task. */
809
+ let installRun = 0
810
+ let cancelledRun = -1
811
+
801
812
  /** Kill the running task (its status line carries the pid) and mark it cancelled. */
802
813
  function stopTask() {
803
814
  const status = readTaskStatus()
@@ -812,16 +823,18 @@ function stopTask() {
812
823
  }
813
824
  } catch {}
814
825
  }
826
+ cancelledRun = installRun
815
827
  const current = readTaskCurrent()
816
828
  try {
817
- let note = `@@ stop ${Math.floor(Date.now() / 1000)}\n`
829
+ let note = '任务被用户取消\n'
830
+ note += `stop ${Math.floor(Date.now() / 1000)}\n`
818
831
  if (current) note += `@@ ${current.action} ${current.name} fail\n`
819
- note += '任务被用户取消\n'
820
832
  appendFileSync(taskLogPath(), note)
821
833
  } catch {}
822
834
  const failed = readTaskResults().filter((result) => !result.ok).length
835
+ const stoppedFailed = status.kind === 'install' ? Math.max(1, failed) : failed
823
836
  try {
824
- writeFileSync(taskStatusPath(), `done ${Math.floor(Date.now() / 1000)} ${Math.max(1, failed)} ${status.kind || 'apply'}\n`)
837
+ writeFileSync(taskStatusPath(), `done ${Math.floor(Date.now() / 1000)} ${stoppedFailed} ${status.kind || 'apply'}\n`)
825
838
  } catch {}
826
839
  return { ok: true, pid }
827
840
  }
@@ -973,6 +986,22 @@ function installTimedOut(result) {
973
986
  return kind.toLowerCase().includes('timeout')
974
987
  }
975
988
 
989
+ /** Turn noisy pnpm / installer output into one plain-language cause (empty when nothing matches). */
990
+ function explainFailure(text) {
991
+ const raw = String(text || '')
992
+ if (!raw) return ''
993
+ if (/ENOTFOUND|EAI_AGAIN|getaddrinfo/i.test(raw)) return '域名解析失败,检查网络或 registry 地址'
994
+ if (/ERR_PNPM_FETCH_404|E404|404 Not Found|does not exist on the registry/i.test(raw)) return '包或版本在 registry 上不存在(404)'
995
+ if (/ECONNRESET|ECONNREFUSED|socket hang up|ERR_SOCKET|network error/i.test(raw)) return '网络连接被重置或拒绝,多为 registry 不可达'
996
+ if (/ETIMEDOUT|ESOCKETTIMEDOUT|timed out|timeout|600000ms/i.test(raw)) return '安装超时(安装器长时间没有输出,原因为网络或 registry 卡住)'
997
+ if (/EPERM|EACCES|permission denied/i.test(raw)) return '权限不足,无法写入安装目录'
998
+ if (/ENOENT|no such file/i.test(raw)) return '缺文件:同步码里的文件或包内容不完整'
999
+ if (/ERESOLVE|peer dep/i.test(raw)) return '依赖冲突(peer dependency 不匹配)'
1000
+ if (/incompatible|版本不兼容|requires .* but (?:got|found)/i.test(raw)) return '版本不兼容(插件与当前 DSH 版本不匹配)'
1001
+ if (/unsupported|not supported|does not support/i.test(raw)) return '当前端的安装器不支持这种来源'
1002
+ return ''
1003
+ }
1004
+
976
1005
  /** The desktop host runs `@deepseek-ai/dsh-desktop-host/lib/index.js`; its CLI is the sibling file. */
977
1006
  function dshCliEntry() {
978
1007
  const host = typeof process.argv[2] === 'string' ? process.argv[2] : ''
@@ -1017,25 +1046,32 @@ function startInstallTask(ctx, jobs) {
1017
1046
  try { writeFileSync(taskTotalPath(), '0\n') } catch {}
1018
1047
  writeFileSync(taskLogPath(), '')
1019
1048
  writeFileSync(taskStatusPath(), `running ${Math.floor(Date.now() / 1000)} apply\n`)
1049
+ const runId = ++installRun
1020
1050
  const installs = jobs.filter((job) => job.action === 'install')
1021
- const say = (line) => { try { writeFileSync(taskLogPath(), `${line}\n`, { flag: 'a' }) } catch {} }
1051
+ const say = (line) => {
1052
+ if (cancelledRun === runId) return
1053
+ try { writeFileSync(taskLogPath(), `${line}\n`, { flag: 'a' }) } catch {}
1054
+ }
1055
+ try { say(`host dshGo=${ctx.get?.('dshGo') === true} platform=${process.platform} profile=${profileName()}`) } catch {}
1022
1056
  ;(async () => {
1023
1057
  let failed = 0
1024
1058
  for (const job of installs) {
1059
+ if (cancelledRun === runId) break
1025
1060
  const name = markerName(job.name)
1026
1061
  const target = job.localDir || job.registrySpec
1027
1062
  say(`@@ install ${name} start`)
1028
1063
  if (!target) {
1029
1064
  failed += 1
1030
- say(`@@ install ${name} fail`)
1065
+ say('原因:这个插件既没有本地文件也没有 registry 地址,无法安装')
1031
1066
  say('no install source')
1067
+ say(`@@ install ${name} fail`)
1032
1068
  continue
1033
1069
  }
1034
1070
  try {
1035
1071
  const result = await manager.installBundle(target, { enabled: true })
1036
1072
  const failure = installFailure(result)
1037
1073
  if (failure && installTimedOut(result)) {
1038
- say(`@@ install ${name} timeout, retry via dsh cli`)
1074
+ say(`install ${name} timeout, retry via dsh cli`)
1039
1075
  const retry = await runCliInstall(target)
1040
1076
  if (retry.ok) {
1041
1077
  say(`@@ install ${name} ok`)
@@ -1044,13 +1080,23 @@ function startInstallTask(ctx, jobs) {
1044
1080
  say('重启 DSH 后生效')
1045
1081
  } else {
1046
1082
  failed += 1
1047
- say(`@@ install ${name} cli failed`)
1083
+ say(`install ${name} cli failed`)
1048
1084
  say(retry.output.slice(-1500))
1085
+ const hint = explainFailure(retry.output)
1086
+ if (hint) say(`原因:${hint}`)
1049
1087
  say(`@@ install ${name} fail`)
1050
1088
  }
1051
1089
  } else if (failure) {
1052
1090
  failed += 1
1053
- say(failure.slice(0, 2000))
1091
+ say(`target ${target}`)
1092
+ const rawFailure = [failure, result?.packageResult?.output, result?.error?.packageResult?.output]
1093
+ .filter((part) => typeof part === 'string' && part !== '')
1094
+ .join('\n') || failure
1095
+ say(rawFailure.length <= 2000 ? rawFailure : `${rawFailure.slice(0, 1200)}\n…\n${rawFailure.slice(-800)}`)
1096
+ const hint = explainFailure(rawFailure)
1097
+ if (hint) say(`原因:${hint}`)
1098
+ const logPath = result?.packageResult?.logPath || result?.error?.packageResult?.logPath
1099
+ if (logPath) say(`log ${logPath}`)
1054
1100
  say(`@@ install ${name} fail`)
1055
1101
  } else {
1056
1102
  say(`@@ install ${name} ok`)
@@ -1059,11 +1105,16 @@ function startInstallTask(ctx, jobs) {
1059
1105
  }
1060
1106
  } catch (error) {
1061
1107
  failed += 1
1062
- say(String(error && (error.stack || error.message) || error).slice(0, 2000))
1108
+ const text = String(error && (error.stack || error.message) || error).slice(0, 2000)
1109
+ say(text)
1110
+ const hint = explainFailure(text)
1111
+ if (hint) say(`原因:${hint}`)
1063
1112
  say(`@@ install ${name} fail`)
1064
1113
  }
1065
1114
  }
1066
- try { writeFileSync(taskStatusPath(), `done ${Math.floor(Date.now() / 1000)} ${failed} apply\n`) } catch {}
1115
+ if (cancelledRun !== runId) {
1116
+ try { writeFileSync(taskStatusPath(), `done ${Math.floor(Date.now() / 1000)} ${failed} apply\n`) } catch {}
1117
+ }
1067
1118
  })()
1068
1119
  return { ok: true }
1069
1120
  }
@@ -1375,15 +1426,15 @@ function enableText(caps) {
1375
1426
 
1376
1427
  function statusLine(row, en) {
1377
1428
  let text = {
1378
- same: en ? 'same' : '一致',
1379
- conflict: en ? 'local wins' : '本机优先',
1380
- install: en ? 'not installed' : '未安装',
1381
- installable: en ? 'ready' : '可安装',
1382
- missing: en ? 'no files' : '缺文件',
1383
- extra: en ? 'not listed' : '清单外',
1429
+ same: en ? 'already here' : '本地已有',
1430
+ conflict: en ? 'already here, different version' : '本地已有,版本不同',
1431
+ install: en ? 'already here, not enabled' : '本地已有,未启用',
1432
+ installable: en ? 'installable' : '可安装',
1433
+ missing: en ? 'missing files' : '缺文件',
1434
+ extra: en ? 'local only' : '仅本机有',
1384
1435
  push: en ? 'pushable' : '可推送',
1385
- 'native-only': en ? 'phone-only' : '手机专用',
1386
- 'web-only': en ? 'web-only' : '电脑/网页专用',
1436
+ 'native-only': en ? 'dsh-go only' : '仅dshgo',
1437
+ 'web-only': en ? 'desktop/web only' : '仅电脑/网页',
1387
1438
  }[row.status] || row.status
1388
1439
  if (row.status !== 'web-only' && row.status !== 'native-only') {
1389
1440
  if (row.action === 'install' && row.registrySpec) text = en ? 'via npm' : 'npm 安装'
@@ -1397,6 +1448,23 @@ function statusLine(row, en) {
1397
1448
  return `${version} · ${text}`
1398
1449
  }
1399
1450
 
1451
+ const STATUS_BRIEF = {
1452
+ same: ['本地已有', 'already here'],
1453
+ conflict: ['本地已有,版本不同', 'already here, different version'],
1454
+ install: ['本地已有,未启用', 'already here, not enabled'],
1455
+ installable: ['可安装', 'installable'],
1456
+ missing: ['缺文件', 'missing files'],
1457
+ extra: ['仅本机有', 'local only'],
1458
+ push: ['可推送', 'pushable'],
1459
+ 'native-only': ['仅dshgo', 'dsh-go only'],
1460
+ 'web-only': ['仅电脑/网页', 'desktop/web only'],
1461
+ }
1462
+
1463
+ function statusBrief(row, en) {
1464
+ const pair = STATUS_BRIEF[row.status]
1465
+ return pair ? pair[en ? 1 : 0] : row.status
1466
+ }
1467
+
1400
1468
  function statusTone(status) {
1401
1469
  if (status === 'conflict' || status === 'extra') return 'warn'
1402
1470
  if (status === 'installable' || status === 'install' || status === 'push') return 'info'
@@ -1405,7 +1473,7 @@ function statusTone(status) {
1405
1473
  }
1406
1474
 
1407
1475
  const TASK_LABELS = {
1408
- apply: ['应用所选', 'apply selected'],
1476
+ apply: ['下载并安装', 'download & install'],
1409
1477
  'relay-push': ['推送中转', 'push to relay'],
1410
1478
  'relay-pull': ['拉取中转', 'pull from relay'],
1411
1479
  'ssh-test': ['测试 SSH', 'test SSH'],
@@ -1460,6 +1528,11 @@ function buildView(scope, caps, ctx) {
1460
1528
  [en ? 'SSH' : 'SSH', cfg.ssh.host ? `${cfg.ssh.user ? `${cfg.ssh.user}@` : ''}${cfg.ssh.host}:${cfg.ssh.port}` : (en ? 'not configured' : '未配置')],
1461
1529
  ] })
1462
1530
 
1531
+ children.push({ type: 'actions', items: [
1532
+ { label: en ? 'Configure Git relay' : '配置 Git 仓库', action: 'open-relay-config' },
1533
+ { label: en ? 'Configure SSH' : '配置 SSH', action: 'open-ssh-config' },
1534
+ ] })
1535
+
1463
1536
  const task = readTaskStatus()
1464
1537
  if (task?.running) {
1465
1538
  const stale = Date.now() - task.startedAt > 15 * 60 * 1000
@@ -1510,20 +1583,8 @@ function buildView(scope, caps, ctx) {
1510
1583
 
1511
1584
  if (!state.manifest) {
1512
1585
  children.push({ type: 'callout', tone: 'info', text: en
1513
- ? 'Select plugins below, then Copy code; or import a manifest / pull the relay first.'
1514
- : '先在下面选中要同步的插件,再点复制同步码;也可以先导入清单或拉取中转。' })
1515
- if (local.length > 0) {
1516
- const shown = local.slice(0, 40)
1517
- children.push({ type: 'list', items: shown.map((plugin) => ({
1518
- title: plugin.name,
1519
- subtitle: `${plugin.version} · ${en ? 'tap to select' : '点选'}`,
1520
- trailing: state.selected.has(plugin.name) ? '✓' : '○',
1521
- action: { id: 'toggle', args: { name: plugin.name } },
1522
- })) })
1523
- if (local.length > shown.length) {
1524
- children.push({ type: 'text', text: en ? `…and ${local.length - shown.length} more` : `…还有 ${local.length - shown.length} 项` })
1525
- }
1526
- }
1586
+ ? 'Import a sync code or pull the relay/manifest first. This panel only lists plugins that still need action; Copy code uses all local plugins when nothing is selected.'
1587
+ : '先导入同步码或拉取中转。这里只列需要处理的插件;复制同步码在没选任何插件时会带上全部本机插件。' })
1527
1588
  } else {
1528
1589
  const when = state.manifest.exportedAt ? state.manifest.exportedAt.slice(0, 16).replace('T', ' ') : ''
1529
1590
  const source = state.sourceName || state.manifest.host?.profile || ''
@@ -1531,23 +1592,26 @@ function buildView(scope, caps, ctx) {
1531
1592
  ? `Manifest: ${source || 'imported'}${when ? ` · ${when}` : ''}`
1532
1593
  : `清单来源:${source || '已导入'}${when ? ` · ${when}` : ''}` })
1533
1594
 
1534
- const pending = rows.filter((row) => row.status !== 'same')
1595
+ const pending = rows.filter((row) => row.status !== 'same' && row.status !== 'extra')
1535
1596
  const installed = rows.filter((row) => row.status === 'same')
1536
- const visible = (state.showAll ? rows : pending).slice()
1597
+ const listable = rows.filter((row) => row.status !== 'extra')
1598
+ const visible = (state.showAll ? listable : pending).slice()
1537
1599
  .sort((a, b) => Number(Boolean(b.action)) - Number(Boolean(a.action)))
1538
- if (rows.length === 0) {
1600
+ if (listable.length === 0) {
1539
1601
  children.push({ type: 'callout', tone: 'good', text: en ? 'The two hosts match.' : '两边完全一致。' })
1540
1602
  } else {
1541
1603
  if (pending.length === 0) {
1542
1604
  children.push({ type: 'callout', tone: 'good', text: en ? 'Nothing pending; everything is in sync.' : '没有待处理项,已全部一致。' })
1605
+ } else {
1606
+ children.push({ type: 'text', text: en ? `Pending plugins (${pending.length})` : `待处理插件(${pending.length})` })
1543
1607
  }
1544
1608
  const shown = visible.slice(0, 40)
1545
1609
  if (shown.length > 0) {
1546
1610
  children.push({ type: 'list', items: shown.map((row) => {
1547
1611
  const item = {
1548
1612
  title: row.name,
1549
- subtitle: statusLine(row, en),
1550
- trailing: state.selected.has(row.name) ? '✓' : '○',
1613
+ subtitle: statusBrief(row, en),
1614
+ trailing: state.selected.has(row.name) ? '✓' : undefined,
1551
1615
  action: { id: 'toggle', args: { name: row.name } },
1552
1616
  }
1553
1617
  const tone = statusTone(row.status)
@@ -1567,29 +1631,37 @@ function buildView(scope, caps, ctx) {
1567
1631
 
1568
1632
  }
1569
1633
 
1634
+ const selectableNames = state.manifest
1635
+ ? rows.filter((row) => row.status !== 'extra').map((row) => row.name)
1636
+ : local.map((plugin) => plugin.name)
1637
+ const allSelected = selectableNames.length > 0 && selectableNames.every((name) => state.selected.has(name))
1638
+
1639
+ if (state.manifest) {
1640
+ children.push({ type: 'actions', items: [
1641
+ { label: state.showAll ? (en ? 'Pending only' : '只看待处理') : (en ? 'Show all' : '显示全部'), action: 'toggle-show-all' },
1642
+ ] })
1643
+ }
1644
+
1570
1645
  const primary = [
1571
1646
  ...(task?.running ? [{ label: en ? 'Stop task' : '取消任务', action: 'stop-task' }] : []),
1572
1647
  { label: en ? 'Copy code' : '复制同步码', action: 'copy-code' },
1573
- { label: en ? 'Select all' : '全选', action: 'select-all' },
1574
- { label: en ? 'Clear' : '清空', action: 'clear' },
1575
- { label: state.showAll ? (en ? 'Pending only' : '只看待处理') : (en ? 'Show all' : '显示全部'), action: 'toggle-show-all' },
1648
+ { label: allSelected ? (en ? 'Select none' : '取消全选') : (en ? 'Select all' : '全选'), action: allSelected ? 'clear' : 'select-all' },
1576
1649
  { label: en ? 'Refresh' : '刷新', action: 'refresh' },
1577
1650
  ]
1578
1651
  children.push({ type: 'actions', items: primary })
1579
1652
 
1580
- children.push({ type: 'actions', items: [
1581
- { label: en ? 'Retry failed' : '重试失败', action: 'retry-failed' },
1582
- { label: en ? 'Export' : '导出清单', action: 'export' },
1583
- { label: en ? 'Read workspace' : '工作区导入', action: 'import-workspace' },
1584
- { label: en ? 'Clear list' : '清空清单', action: 'clear-all' },
1585
- { label: en ? 'Guide' : '使用引导', action: 'guide' },
1586
- ] })
1653
+ const failedCount = results.filter((result) => !result.ok).length
1654
+ const secondary = []
1655
+ if (failedCount > 0) secondary.push({ label: en ? `Retry failed (${failedCount})` : `重试失败项(${failedCount})`, action: 'retry-failed' })
1656
+ secondary.push({ label: en ? 'Reset plugin list' : '重置插件列表', action: 'clear-all' })
1657
+ secondary.push({ label: en ? 'Guide' : '使用引导', action: 'guide' })
1658
+ children.push({ type: 'actions', items: secondary })
1587
1659
 
1588
1660
  if (state.manifest && state.selected.size > 0) {
1589
- children.push({ type: 'confirm', id: 'apply', confirmLabel: en ? 'Apply' : '应用所选', cancelLabel: en ? 'Cancel' : '取消' })
1661
+ children.push({ type: 'confirm', id: 'apply', confirmLabel: en ? 'Download & install' : '下载并安装', cancelLabel: en ? 'Cancel' : '取消' })
1590
1662
  }
1591
1663
 
1592
- const log = readLogTail()
1664
+ const log = readLogTail(8)
1593
1665
  if (log.length > 0) {
1594
1666
  children.push({ type: 'keyValue', items: log.map((line, index) => [en ? `log ${index + 1}` : `日志 ${index + 1}`, line]) })
1595
1667
  }
@@ -1623,11 +1695,11 @@ function buildGuide(scope, caps, ctx) {
1623
1695
  { label: en ? 'Paste and import on B' : '在 B 粘贴并导入', status: 'current', detail: en
1624
1696
  ? 'Panel → code field → Import code'
1625
1697
  : '面板「同步码」输入框 → 导入同步码' },
1626
- { label: en ? 'Select and apply on B' : '在 B 选中并应用', status: 'todo', detail: en
1627
- ? 'All selected by default; deselect what you do not want'
1628
- : '默认全选,可取消不要的项' },
1698
+ { label: en ? 'Select and download' : '在 B 选中并下载安装', status: 'todo', detail: en
1699
+ ? 'Only double-end plugins missing here are preselected; adjust as needed'
1700
+ : '默认只勾选双端兼容且本机没有的插件,可再调整' },
1629
1701
  { label: en ? 'Retry failures' : '失败项点重试', status: 'todo', detail: en
1630
- ? 'Retry failed in the panel'
1702
+ ? 'Retry failed items in the panel'
1631
1703
  : '面板「重试失败项」' },
1632
1704
  { label: en ? 'Restart the engine' : '重启一次引擎', status: 'todo' },
1633
1705
  ] },
@@ -1648,19 +1720,8 @@ function buildGuide(scope, caps, ctx) {
1648
1720
  ['ssh.host', cfg.ssh.host || '—'],
1649
1721
  ] },
1650
1722
  { type: 'text', text: en
1651
- ? 'Advanced: large plugins or two-way file sync use the Git relay / SSH below.'
1652
- : '高级:大插件或双向文件同步用下面的 Git 中转 / SSH。' },
1653
- { type: 'actions', items: [
1654
- { label: en ? 'Copy code' : '复制同步码', action: 'copy-code' },
1655
- { label: en ? 'Config template' : '生成配置模板', action: 'copy-config' },
1656
- { label: en ? 'Back' : '返回同步', action: 'back' },
1657
- ] },
1658
- { type: 'actions', items: [
1659
- { label: en ? 'Push relay' : '推送中转', action: 'relay-push' },
1660
- { label: en ? 'Pull relay' : '拉取中转', action: 'relay-pull' },
1661
- { label: en ? 'Scan SSH' : '拉远端清单', action: 'ssh-scan' },
1662
- { label: en ? 'Test SSH' : '测试 SSH', action: 'ssh-test' },
1663
- ] },
1723
+ ? 'Advanced: large plugins or two-way file sync use the Git relay / SSH from the Sync panel.'
1724
+ : '高级:大插件或双向文件同步,在「插件同步」面板里用 Git 中转 / SSH。' },
1664
1725
  ],
1665
1726
  }
1666
1727
  }
@@ -1735,7 +1796,7 @@ function webSnapshot(ctx) {
1735
1796
  cleared,
1736
1797
  task: readTaskStatus(),
1737
1798
  results: readTaskResults(),
1738
- log: readLogTail(3),
1799
+ log: readLogTail(12),
1739
1800
  config: cfg,
1740
1801
  configPath: configPathFor(ctx, scope),
1741
1802
  }
@@ -1751,6 +1812,12 @@ function configPathFor(ctx, scope) {
1751
1812
  return join(storeDir(), CONFIG_FILE)
1752
1813
  }
1753
1814
 
1815
+ function writeConfig(ctx, scope, cfg) {
1816
+ const target = configPathFor(ctx, scope)
1817
+ mkdirSync(dirname(target), { recursive: true })
1818
+ writeFileSync(target, JSON.stringify(normalizeConfig(cfg), null, 2) + '\n')
1819
+ }
1820
+
1754
1821
  // ---------------------------------------------------------------- plugin
1755
1822
 
1756
1823
  export function apply(ctx) {
@@ -1958,6 +2025,14 @@ export function apply(ctx) {
1958
2025
  return { refresh: true }
1959
2026
  },
1960
2027
 
2028
+ 'open-relay-config'() {
2029
+ return { open: 'panel:relay-config' }
2030
+ },
2031
+
2032
+ 'open-ssh-config'() {
2033
+ return { open: 'panel:ssh-config' }
2034
+ },
2035
+
1961
2036
  'clear-all'(scope) {
1962
2037
  const state = stateFor(scope)
1963
2038
  state.manifest = null
@@ -1966,7 +2041,7 @@ export function apply(ctx) {
1966
2041
  state.importedAt = null
1967
2042
  state.selected.clear()
1968
2043
  try { unlinkSync(importFile()) } catch {}
1969
- return [{ toast: '已清空清单,可重新导入同步码或拉取中转' }, { refresh: true }]
2044
+ return [{ toast: '已重置插件列表,可重新导入同步码或拉取中转' }, { refresh: true }]
1970
2045
  },
1971
2046
 
1972
2047
  guide() {
@@ -2019,6 +2094,123 @@ export function apply(ctx) {
2019
2094
  },
2020
2095
  })
2021
2096
 
2097
+ ctx.dshGo.panel('relay-config', {
2098
+ view(scope, caps) {
2099
+ const en = enableText(caps)
2100
+ const cfg = loadConfig(ctx, scope)
2101
+ const components = Array.isArray(caps?.components) ? caps.components : []
2102
+ const canForm = components.includes('form') && components.includes('textField')
2103
+ const children = [{
2104
+ type: 'text',
2105
+ text: en
2106
+ ? (cfg.relay.repo ? `Current: ${cfg.relay.repo} · ${cfg.relay.branch} · ${cfg.relay.dir}` : 'No Git relay configured yet.')
2107
+ : (cfg.relay.repo ? `当前:${cfg.relay.repo} · 分支 ${cfg.relay.branch} · 目录 ${cfg.relay.dir}` : '还没有配置 Git 中转仓。'),
2108
+ }]
2109
+ if (canForm) {
2110
+ children.push({ type: 'form', submit: 'save-relay', submitLabel: en ? 'Save' : '保存', children: [
2111
+ { type: 'textField', label: en ? 'Repository URL' : '仓库地址', bind: 'data.relay.repo', placeholder: 'https://gitee.com/you/dsh-plugins.git' },
2112
+ { type: 'textField', label: en ? 'Branch' : '分支', bind: 'data.relay.branch', placeholder: cfg.relay.branch },
2113
+ { type: 'textField', label: en ? 'Directory' : '目录', bind: 'data.relay.dir', placeholder: cfg.relay.dir },
2114
+ ] })
2115
+ } else {
2116
+ children.push({ type: 'callout', tone: 'info', text: en
2117
+ ? 'This app version has no panel input; configure it on the desktop settings page.'
2118
+ : '当前 App 版本不支持面板输入,请用电脑端设置页配置。' })
2119
+ }
2120
+ children.push({ type: 'callout', tone: 'info', text: en
2121
+ ? 'Git uses system credentials. Fields left empty keep their current value.'
2122
+ : 'Git 用系统凭据;留空的字段保持原值。' })
2123
+ const view = { type: 'stack', title: en ? 'Configure Git relay' : '配置 Git 仓库', children }
2124
+ if (canForm) view.v = 2
2125
+ return view
2126
+ },
2127
+ data(scope, emit) {
2128
+ emit({ relay: { repo: '', branch: '', dir: '' } })
2129
+ return () => {}
2130
+ },
2131
+ actions: {
2132
+ 'save-relay'(scope, event) {
2133
+ const values = event?.value?.values && typeof event.value.values === 'object' ? event.value.values : {}
2134
+ const pick = (key) => (typeof values[key] === 'string' ? values[key].trim() : '')
2135
+ const cfg = loadConfig(ctx, scope)
2136
+ const next = {
2137
+ relay: {
2138
+ repo: pick('data.relay.repo') || cfg.relay.repo,
2139
+ branch: pick('data.relay.branch') || cfg.relay.branch,
2140
+ dir: pick('data.relay.dir') || cfg.relay.dir,
2141
+ },
2142
+ ssh: cfg.ssh,
2143
+ }
2144
+ try { writeConfig(ctx, scope, next) } catch { return { toast: '保存失败,检查工作区权限' } }
2145
+ return [{ toast: '已保存 Git 仓库配置' }, { open: 'panel:sync' }]
2146
+ },
2147
+ back() {
2148
+ return { open: 'panel:sync' }
2149
+ },
2150
+ },
2151
+ })
2152
+
2153
+ ctx.dshGo.panel('ssh-config', {
2154
+ view(scope, caps) {
2155
+ const en = enableText(caps)
2156
+ const cfg = loadConfig(ctx, scope)
2157
+ const components = Array.isArray(caps?.components) ? caps.components : []
2158
+ const canForm = components.includes('form') && components.includes('textField')
2159
+ const children = [{
2160
+ type: 'text',
2161
+ text: en
2162
+ ? (cfg.ssh.host ? `Current: ${cfg.ssh.user ? `${cfg.ssh.user}@` : ''}${cfg.ssh.host}:${cfg.ssh.port}` : 'No SSH host configured yet.')
2163
+ : (cfg.ssh.host ? `当前:${cfg.ssh.user ? `${cfg.ssh.user}@` : ''}${cfg.ssh.host}:${cfg.ssh.port}` : '还没有配置 SSH 主机。'),
2164
+ }]
2165
+ if (canForm) {
2166
+ children.push({ type: 'form', submit: 'save-ssh', submitLabel: en ? 'Save' : '保存', children: [
2167
+ { type: 'textField', label: en ? 'Host' : '主机', bind: 'data.ssh.host', placeholder: '192.168.1.10' },
2168
+ { type: 'textField', label: en ? 'Port' : '端口', bind: 'data.ssh.port', placeholder: String(cfg.ssh.port) },
2169
+ { type: 'textField', label: en ? 'User' : '用户', bind: 'data.ssh.user', placeholder: 'root' },
2170
+ { type: 'textField', label: en ? 'Identity file' : '私钥路径', bind: 'data.ssh.identity', placeholder: '~/.ssh/id_ed25519' },
2171
+ { type: 'textField', label: en ? 'Remote home' : '远端 HOME', bind: 'data.ssh.remoteHome', placeholder: cfg.ssh.remoteHome },
2172
+ ] })
2173
+ } else {
2174
+ children.push({ type: 'callout', tone: 'info', text: en
2175
+ ? 'This app version has no panel input; configure it on the desktop settings page.'
2176
+ : '当前 App 版本不支持面板输入,请用电脑端设置页配置。' })
2177
+ }
2178
+ children.push({ type: 'callout', tone: 'info', text: en
2179
+ ? 'SSH uses a key or agent. Fields left empty keep their current value.'
2180
+ : 'SSH 用密钥或 agent;留空的字段保持原值。' })
2181
+ const view = { type: 'stack', title: en ? 'Configure SSH' : '配置 SSH', children }
2182
+ if (canForm) view.v = 2
2183
+ return view
2184
+ },
2185
+ data(scope, emit) {
2186
+ emit({ ssh: { host: '', port: '', user: '', identity: '', remoteHome: '' } })
2187
+ return () => {}
2188
+ },
2189
+ actions: {
2190
+ 'save-ssh'(scope, event) {
2191
+ const values = event?.value?.values && typeof event.value.values === 'object' ? event.value.values : {}
2192
+ const pick = (key) => (typeof values[key] === 'string' ? values[key].trim() : '')
2193
+ const cfg = loadConfig(ctx, scope)
2194
+ const port = Number(pick('data.ssh.port'))
2195
+ const next = {
2196
+ relay: cfg.relay,
2197
+ ssh: {
2198
+ host: pick('data.ssh.host') || cfg.ssh.host,
2199
+ port: Number.isInteger(port) && port > 0 && port < 65536 ? port : cfg.ssh.port,
2200
+ user: pick('data.ssh.user') || cfg.ssh.user,
2201
+ identity: pick('data.ssh.identity') || cfg.ssh.identity,
2202
+ remoteHome: pick('data.ssh.remoteHome') || cfg.ssh.remoteHome,
2203
+ },
2204
+ }
2205
+ try { writeConfig(ctx, scope, next) } catch { return { toast: '保存失败,检查工作区权限' } }
2206
+ return [{ toast: '已保存 SSH 配置' }, { open: 'panel:sync' }]
2207
+ },
2208
+ back() {
2209
+ return { open: 'panel:sync' }
2210
+ },
2211
+ },
2212
+ })
2213
+
2022
2214
  ctx.dshGo.strip('pending', (scope, emit, caps) => {
2023
2215
  const en = String(caps?.locale || '').toLowerCase().startsWith('en')
2024
2216
  const tick = () => {
package/package.json CHANGED
@@ -1,102 +1,102 @@
1
- {
2
- "name": "dsh-go-plugin-sync",
3
- "version": "0.4.2",
4
- "type": "module",
5
- "main": "lib/index.js",
6
- "dsh": {
7
- "bundle": {
8
- "patch": "./cordis.patch.yml"
9
- },
10
- "client": {
11
- "platform": "web",
12
- "immediately": true,
13
- "inject": [
14
- "@deepseek-ai/dsh-client-ui-settings"
15
- ]
16
- }
17
- },
18
- "engines": {
19
- "dsh": ">=0.2.1-rc.2 <0.3.0-0"
20
- },
21
- "dshGo": {
22
- "v": 1,
23
- "title": {
24
- "zh": "插件同步",
25
- "en": "Plugin sync"
26
- },
27
- "icon": "refresh",
28
- "contributes": {
29
- "composer.actions": [
30
- {
31
- "id": "open-sync",
32
- "label": {
33
- "zh": "插件同步",
34
- "en": "Sync"
35
- },
36
- "icon": "refresh",
37
- "effect": {
38
- "type": "open",
39
- "page": "panel:sync"
40
- }
41
- }
42
- ],
43
- "composer.strip": [
44
- {
45
- "id": "pending",
46
- "icon": "refresh",
47
- "panel": "sync"
48
- }
49
- ],
50
- "panels": [
51
- {
52
- "id": "sync",
53
- "title": {
54
- "zh": "插件同步",
55
- "en": "Plugin sync"
56
- },
57
- "icon": "refresh",
58
- "placement": [
59
- "session.tab",
60
- "features"
61
- ],
62
- "presentation": "page"
63
- },
64
- {
65
- "id": "guide",
66
- "title": {
67
- "zh": "同步引导",
68
- "en": "Sync guide"
69
- },
70
- "icon": "book",
71
- "placement": [
72
- "features"
73
- ],
74
- "presentation": "page"
75
- }
76
- ]
77
- }
78
- },
79
- "repository": {
80
- "type": "git",
81
- "url": "https://gitee.com/o12354654/dshgochajiantongbucha.git"
82
- },
83
- "description": "dsh-go 插件同步:用同步码在手机与电脑之间安装 dsh-go / Cordis 插件;支持 Git 中转与 SSH。",
84
- "keywords": [
85
- "dsh",
86
- "dsh-plugin",
87
- "dsh-go",
88
- "plugin-sync"
89
- ],
90
- "homepage": "https://gitee.com/o12354654/dshgochajiantongbucha",
91
- "files": [
92
- "lib",
93
- "cordis.patch.yml",
94
- "README.md",
95
- "CHANGELOG.md"
96
- ],
97
- "exports": {
98
- ".": "./lib/index.js",
99
- "./client": "./lib/client.js",
100
- "./package.json": "./package.json"
101
- }
102
- }
1
+ {
2
+ "name": "dsh-go-plugin-sync",
3
+ "version": "0.4.4",
4
+ "type": "module",
5
+ "main": "lib/index.js",
6
+ "dsh": {
7
+ "bundle": {
8
+ "patch": "./cordis.patch.yml"
9
+ },
10
+ "client": {
11
+ "platform": "web",
12
+ "immediately": true,
13
+ "inject": [
14
+ "@deepseek-ai/dsh-client-ui-settings"
15
+ ]
16
+ }
17
+ },
18
+ "engines": {
19
+ "dsh": ">=0.2.1-rc.2 <0.3.0-0"
20
+ },
21
+ "dshGo": {
22
+ "v": 1,
23
+ "title": {
24
+ "zh": "插件同步",
25
+ "en": "Plugin sync"
26
+ },
27
+ "icon": "refresh",
28
+ "contributes": {
29
+ "composer.actions": [
30
+ {
31
+ "id": "open-sync",
32
+ "label": {
33
+ "zh": "插件同步",
34
+ "en": "Sync"
35
+ },
36
+ "icon": "refresh",
37
+ "effect": {
38
+ "type": "open",
39
+ "page": "panel:sync"
40
+ }
41
+ }
42
+ ],
43
+ "composer.strip": [
44
+ {
45
+ "id": "pending",
46
+ "icon": "refresh",
47
+ "panel": "sync"
48
+ }
49
+ ],
50
+ "panels": [
51
+ {
52
+ "id": "sync",
53
+ "title": {
54
+ "zh": "插件同步",
55
+ "en": "Plugin sync"
56
+ },
57
+ "icon": "refresh",
58
+ "placement": [
59
+ "session.tab",
60
+ "features"
61
+ ],
62
+ "presentation": "page"
63
+ },
64
+ {
65
+ "id": "guide",
66
+ "title": {
67
+ "zh": "同步引导",
68
+ "en": "Sync guide"
69
+ },
70
+ "icon": "book",
71
+ "placement": [
72
+ "features"
73
+ ],
74
+ "presentation": "page"
75
+ }
76
+ ]
77
+ }
78
+ },
79
+ "repository": {
80
+ "type": "git",
81
+ "url": "https://gitee.com/o12354654/dshgochajiantongbucha.git"
82
+ },
83
+ "description": "dsh-go 插件同步:用同步码在手机与电脑之间安装 dsh-go / Cordis 插件;支持 Git 中转与 SSH。",
84
+ "keywords": [
85
+ "dsh",
86
+ "dsh-plugin",
87
+ "dsh-go",
88
+ "plugin-sync"
89
+ ],
90
+ "homepage": "https://gitee.com/o12354654/dshgochajiantongbucha",
91
+ "files": [
92
+ "lib",
93
+ "cordis.patch.yml",
94
+ "README.md",
95
+ "CHANGELOG.md"
96
+ ],
97
+ "exports": {
98
+ ".": "./lib/index.js",
99
+ "./client": "./lib/client.js",
100
+ "./package.json": "./package.json"
101
+ }
102
+ }