dsh-config-sync-plugin 0.4.12 → 0.4.15

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 CHANGED
@@ -257,7 +257,14 @@ Two display fixes on top of 0.3.77:
257
257
 
258
258
  The "Plugin update" card now shows an **npm download URL** line with the actual fallback addresses (domestic mirror `registry.npmmirror.com` + official `registry.npmjs.org`). When the GitHub release download is unreachable (common in mainland China), the update package automatically falls back to npm. It is still verified against the authoritative sha256 in `version.json` — switching source never relaxes verification. The two sources back each other up: the mirror can briefly 404 during its first-sync window, and the official source takes over. The npm tarball is byte-identical to the GitHub release tgz (same sha256).
259
259
 
260
- ### Content-level pending detection: only prompt to push when content actually changed (0.4.12)
260
+ ### MCP connector sync fix (0.4.15)
261
+
262
+ This release fixes the MCP connector sync failures caused by missing group in PowerShell runtime scripts:
263
+
264
+ - **Root cause**: v0.4.14 added the MCP connector sync group, but PowerShell runtime scripts (`dsh-sync-common.ps1`, `capture.ps1`) had hardcoded group lists missing `mcp-connectors`, causing capture/apply to skip the group and fail to sync configs.
265
+ - **Fix**: Added `mcp-connectors` to `$SyncScopeGroups` in `dsh-sync-common.ps1` and the hardcoded group list in `capture.ps1`, aligning with `index.js`'s `collectScopeGroups`.
266
+
267
+ ### Add MCP connector sync support (0.4.14)
261
268
 
262
269
  This release changes the "pending push" rule from a timestamp check to a content-level check, fixing false positives without altering the normal push/pull flow:
263
270
 
package/README.md CHANGED
@@ -277,7 +277,14 @@ pwsh -File runtime\sync.ps1 pull `
277
277
 
278
278
  「插件更新」卡新增一行 **npm 下载路径**,直接显示实际兜底地址(国内镜像 `registry.npmmirror.com` + 官方 `registry.npmjs.org` 两个源)。GitHub release 整段不通时(国内常见),更新包会自动兜底从 npm 下载;仍按 `version.json` 里的权威 sha256 校验,换源不放宽校验。两个源互为备份:镜像首发同步窗口期会短暂 404,官方源随即兜上。实测 npm tarball 与 GitHub release tgz 是同一份产物、sha256 完全一致。
279
279
 
280
- ### 待推送判据改为内容级:实际内容变了才提示推送(0.4.12)
280
+ ### MCP 连接器同步修复(0.4.15)
281
+
282
+ 本版修复 MCP 连接器同步功能在 PowerShell 运行时脚本中缺失导致的同步失败问题:
283
+
284
+ - **根因**:v0.4.14 新增了 MCP 连接器同步组,但 PowerShell 运行时脚本(`dsh-sync-common.ps1`、`capture.ps1`)的硬编码组列表未同步添加 `mcp-connectors`,导致捕获/应用时跳过该组,配置无法同步。
285
+ - **修复**:在 `dsh-sync-common.ps1` 的 `$SyncScopeGroups` 和 `capture.ps1` 的硬编码组列表中添加 `mcp-connectors`,与 `index.js` 的 `collectScopeGroups` 保持一致。
286
+
287
+ ### 新增 MCP 连接器同步支持(0.4.14)
281
288
 
282
289
  本版把「待推送」从时间戳判据改为内容级判据,只修误报、不改变正常推送/拉取流程:
283
290
 
package/index.js CHANGED
@@ -2578,6 +2578,17 @@ function npmTgzUrls(version) {
2578
2578
  `https://registry.npmjs.org/dsh-config-sync-plugin/-/${f}`,
2579
2579
  ]
2580
2580
  }
2581
+
2582
+ /** 判断 URL 是否为 npm registry 源(需用 npmSha256 校验) */
2583
+ function isNpmRegistryUrl(url) {
2584
+ const u = String(url || '')
2585
+ return u.includes('registry.npmmirror.com') || u.includes('registry.npmjs.org')
2586
+ }
2587
+
2588
+ /** 根据 URL 选择对应的 sha256:npm 源用 npmSha256,GitHub release 用 sha256 */
2589
+ function pickSha256ForUrl(url, githubSha256, npmSha256) {
2590
+ return isNpmRegistryUrl(url) ? (npmSha256 || githubSha256) : githubSha256
2591
+ }
2581
2592
  // 兼容旧调用:返回首选 npm 兜底地址
2582
2593
  function npmTgzUrl(version) {
2583
2594
  const list = npmTgzUrls(version)
@@ -2775,13 +2786,14 @@ function updatePayload(state, settings = {}) {
2775
2786
  * 候选地址逐个试(raw 常常不通,反代在前面兜着),全失败时把每个源的原因汇总抛出。
2776
2787
  * 返回 { ok, file, size, sha256, url } 或 { ok:false, error }
2777
2788
  */
2778
- async function downloadPackage({ urls, sha256, version, dshHome }) {
2789
+ async function downloadPackage({ urls, sha256, npmSha256, version, dshHome }) {
2779
2790
  if (typeof fetch !== 'function') return { ok: false, error: t('当前运行环境没有 fetch,无法下载更新包', 'fetch is unavailable in this runtime — cannot download the update package') }
2780
2791
  const dir = join(dshHome, 'update-staging')
2781
2792
  try { mkdirSync(dir, { recursive: true }) } catch { }
2782
2793
  const file = join(dir, `dsh-config-sync-plugin-${version}.tgz`)
2783
- const want = String(sha256 || '').toLowerCase()
2784
2794
  const errors = []
2795
+ // 两个已知合法 sha256,允许任一匹配即通过(兼容 URL 分类边界、重定向等极端情况)
2796
+ const validSha256 = new Set([String(sha256 || '').toLowerCase(), String(npmSha256 || '').toLowerCase()].filter(Boolean))
2785
2797
  for (const rawUrl of urls) {
2786
2798
  const url = String(rawUrl || '').trim()
2787
2799
  if (!url) continue
@@ -2798,7 +2810,8 @@ async function downloadPackage({ urls, sha256, version, dshHome }) {
2798
2810
  const buf = Buffer.from(await res.arrayBuffer())
2799
2811
  if (!buf.length) throw new Error(t('下载到的文件是空的', 'the downloaded file is empty'))
2800
2812
  const hash = createHash('sha256').update(buf).digest('hex')
2801
- if (want && hash !== want) throw new Error(t(`sha256 不一致(拿到 ${hash})`, `sha256 mismatch (got ${hash})`))
2813
+ // 只要命中任一合法 sha256 即通过(兼容 URL 分类/重定向边界情况)
2814
+ if (validSha256.size && !validSha256.has(hash)) throw new Error(t(`sha256 不一致(拿到 ${hash},合法值:${[...validSha256].join('、')})`, `sha256 mismatch (got ${hash}, valid: ${[...validSha256].join(', ')})`))
2802
2815
  writeFileSync(file, buf)
2803
2816
  return { ok: true, file, size: buf.length, sha256: hash, url }
2804
2817
  } catch (error) {
@@ -2899,7 +2912,7 @@ async function handleUpdate(req, res, config) {
2899
2912
  }
2900
2913
  const urls = resolveTgzCandidates(remote, state.url)
2901
2914
  if (!urls.length) throw new Error(t('version.json 里没有给 tgz 下载地址', 'version.json gives no tgz download URL'))
2902
- const got = await downloadPackage({ urls, sha256: String(remote.sha256 || ''), version: String(remote.version), dshHome })
2915
+ const got = await downloadPackage({ urls, sha256: String(remote.sha256 || ''), npmSha256: String(remote.npmSha256 || ''), version: String(remote.version), dshHome })
2903
2916
  if (!got.ok) throw new Error(String(got.error || t('下载失败', 'download failed')))
2904
2917
  updateState.prepared = {
2905
2918
  version: String(remote.version),
@@ -3366,6 +3379,14 @@ function collectScopeGroups(dshHome, appRoot) {
3366
3379
  descZh: '免付费模型设置、ComfyUI 工作流库、桌宠配置、插件市场状态', descEn: 'Free-model settings, ComfyUI workflows, desktop-pet config, market state',
3367
3380
  items: settingsFiles.map((x) => ({ id: x.id, label: x.id })) })
3368
3381
 
3382
+ // MCP 连接器配置
3383
+ const mcpConnectorFile = join(dshHome, 'storages', 'mcp_connector.json')
3384
+ if (existsSync(mcpConnectorFile)) {
3385
+ groups.push({ id: 'mcp-connectors', titleZh: 'MCP 连接器', titleEn: 'MCP Connectors',
3386
+ descZh: '已连接的 MCP 连接器配置(含 OAuth 授权、API Key 等)', descEn: 'Connected MCP connector configurations (OAuth grants, API keys, etc.)',
3387
+ items: [{ id: 'mcp_connector.json', label: 'mcp_connector.json', excludable: false }] })
3388
+ }
3389
+
3369
3390
  const mnemonDir = appRoot ? join(appRoot, 'mnemon') : ''
3370
3391
  const mnemonCount = mnemonDir && existsSync(mnemonDir) ? countEntries(mnemonDir) : 0
3371
3392
  groups.push({ id: 'mnemon', titleZh: '记忆数据', titleEn: 'Memory data',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-config-sync-plugin",
3
- "version": "0.4.12",
3
+ "version": "0.4.15",
4
4
  "type": "module",
5
5
  "description": "在 DSH 设置里查看 dsh-config 仓库与本机的同步状态,并生成退出后执行的 push/pull 脚本。同步动作本身不在应用内执行。面板与文案跟随客户端语言(中文/English)。",
6
6
  "main": "./index.js",
@@ -16,6 +16,7 @@
16
16
  "README.md",
17
17
  "README.en.md",
18
18
  "LICENSE",
19
+ "package.json",
19
20
  "runtime",
20
21
  "tools"
21
22
  ],
@@ -601,7 +601,7 @@ $Scope = Get-SyncScope $DshHome
601
601
 
602
602
  $ProfileDir = Join-Path $DshHome ("profiles\" + $ProfileName)
603
603
  if (-not $WorkspaceOnly -and -not (Test-Path -LiteralPath $ProfileDir)) { Die "找不到 profile:$ProfileDir" }
604
- foreach ($d in @('profile', 'prompt', 'skills', 'presets', 'local-plugins', 'storages-record', 'settings', 'mnemon', 'plugin-data', 'extra', 'workspace', 'conversations')) {
604
+ foreach ($d in @('profile', 'prompt', 'skills', 'presets', 'local-plugins', 'storages-record', 'settings', 'mnemon', 'plugin-data', 'extra', 'workspace', 'conversations', 'mcp-connectors')) {
605
605
  $p = Join-Path $RepoRoot $d
606
606
  if (-not (Test-Path -LiteralPath $p)) { New-Item -ItemType Directory -Path $p -Force | Out-Null }
607
607
  }
@@ -251,7 +251,7 @@ function Get-AppRootPattern([string]$appRoot) {
251
251
  # 关键修正:排除反斜杠边界,避免吞掉 JSON 里的 \"
252
252
  # (?<![A-Za-z0-9_\]) 排除前置反斜杠;(?![\w-\]) 排除后置反斜杠
253
253
  # [^\s"',;()\[\]\\] 排除路径字符类里的反斜杠
254
- return ('(?i)(?<![A-Za-z0-9_\\])[A-Z]:[\\/]+(?:[^\s"''`,;()\[\]\\]*[\\/]+)?' + [regex]::Escape($leaf) + '(?![\w-\\])(?:[\\/]+)?')
254
+ return ('(?i)(?<![A-Za-z0-9_\\])[A-Z]:[\\/]+(?:[^\s"''`,;()\[\]\\]*[\\/]+)?' + [regex]::Escape($leaf) + '(?![\w-\\])(?:[\\/]+)?')
255
255
  }
256
256
 
257
257
  function Get-AppRootFwd([string]$appRoot) {
@@ -530,7 +530,7 @@ function Resolve-DshAppRoot([string]$explicit) {
530
530
  # 面板「同步内容」卡片的落点:每组一行、组内还能排除单项。文件不存在 = 全勾(老行为不变)。
531
531
  # 纪律:勾选只决定「要不要处理」——跳过就是既不抓也不还原;
532
532
  # 只有 deleteCloud 打开时才顺手删掉仓库里那份副本(默认关闭,删了就不可逆)。
533
- $SyncScopeGroups = @('profile', 'prompt', 'skills', 'presets', 'storages-record', 'settings', 'mnemon', 'local-plugins', 'plugin-data', 'extra', 'workspace', 'conversations')
533
+ $SyncScopeGroups = @('profile', 'prompt', 'skills', 'presets', 'storages-record', 'settings', 'mnemon', 'local-plugins', 'plugin-data', 'extra', 'workspace', 'conversations', 'mcp-connectors')
534
534
 
535
535
  # ---------- 插件数据 / 额外路径(0.3.51 起)----------
536
536
  # 背景:以前的同步范围是白名单(十组固定清单),新装的插件如果自己往 <DshHome>\<插件名>\ 或