dsh-config-sync-plugin 0.4.23 → 0.4.24

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
@@ -289,6 +289,14 @@ This release fixes five classes of issues found in the full-code audit:
289
289
 
290
290
  Also: `git add -A` now goes through cmd forwarding (no NativeCommandError under EAP=Stop); push failure classification adds non-fast-forward ("pull first" guidance); capture cwd normalization uses `Get-HostNodeRunner` (no more `& $null` crash) and `$PID` temp names; notices byKind counts `landing`; panel AutoCard uses callAuto; required-group item checkboxes are disabled in the scope card (they were dead switches).
291
291
 
292
+ ### Full cross-machine config sync: Windows-MCP state + MCP connectors + bridge path (0.4.24)
293
+
294
+ This release fixes three configs that were previously unsynced or wrong across machines:
295
+
296
+ - **Windows-MCP version state**: `~\.dsh\dsh-windows-mcp.versions.json` (active/previous/history/lastCheck) is a loose file at the `.dsh` root; `plugin-data` only scans first-level directories and the `settings` whitelist lacked it, so it was always lost cross-machine. Now included in the settings group.
297
+ - **MCP connector config**: the `mcp-connectors` group was an empty shell — panel declared it, capture only made an empty dir, apply had no code at all. Now real capture/restore of `~\.dsh\storages\mcp_connector.json` (includes OAuth/API Key credentials, auto-backup before overwrite).
298
+ - **Bridge exe path**: the windows-mcp-bridge command in `cordis.patch.yml` is a `C:\Users\xxx\.dsh\...` absolute path; only AppRoot was tokenized before, missing DSH_HOME, so the bridge pointed at the old machine after sync. DSH_HOME is now tokenized and expanded to the local path on the target machine.
299
+
292
300
  ### Fix over-strict pull preflight (0.4.18)
293
301
 
294
302
  This release fixes the 0.4.17 preflight false-failure that rolled back pulls on the target machine:
package/README.md CHANGED
@@ -309,6 +309,14 @@ pwsh -File runtime\sync.ps1 pull `
309
309
 
310
310
  附带:`git add -A` 改走 cmd 转发(EAP=Stop 下不再被 stderr advice 中断);push 失败分类补 non-fast-forward(双机竞态给出「先拉取」指引);capture 会话头归一执行器统一走 `Get-HostNodeRunner`(无独立 node 时不再 `& $null` 崩溃)并用 `$PID` 命名临时文件;notices byKind 补 `landing` 计数;面板 AutoCard 的 auto 请求统一走 callAuto;同步内容卡必需组单项勾选禁用(原本就是死开关)。
311
311
 
312
+ ### 跨机配置完全同步:Windows-MCP 版本状态 + MCP 连接器 + 桥行路径(0.4.24)
313
+
314
+ 本版补齐三类此前不同步或不正确的配置:
315
+
316
+ - **Windows-MCP 版本状态**:`~\.dsh\dsh-windows-mcp.versions.json`(active/previous/history/lastCheck)是 `.dsh` 根散落文件,此前 `plugin-data` 只扫一级目录、`settings` 白名单也没它,跨机一直丢。本版纳入 settings 组同步。
317
+ - **MCP 连接器配置**:此前 `mcp-connectors` 是空壳组——面板有声明、capture 只建空目录、apply 完全没有代码。本版补上 `~\.dsh\storages\mcp_connector.json` 的真实抓取与还原(含 OAuth/API Key 凭据,覆盖前自动备份)。
318
+ - **桥行 exe 路径**:`cordis.patch.yml` 里 windows-mcp-bridge 的 command 是 `C:\Users\xxx\.dsh\...` 绝对路径,此前只 token 化 AppRoot、漏了 DSH_HOME,换机后桥接指向旧机路径失效。本版把 DSH_HOME 也 token 化,跨机自动展开为本机路径。
319
+
312
320
  ### 修复拉取前置检查过严(0.4.18)
313
321
 
314
322
  本版修复 0.4.17 新增的拉取前置检查在目标机误报失败、导致拉取被回滚的问题:
package/index.js CHANGED
@@ -3374,6 +3374,9 @@ function collectScopeGroups(dshHome, appRoot) {
3374
3374
  { id: 'comfyui-workflows.json', src: join(dshHome, 'data', 'dsh-comfyui', 'workflows.json') },
3375
3375
  { id: 'dsh-pet-main-config.jsonc', src: join(dshHome, 'dsh-pet', 'main-config.jsonc') },
3376
3376
  { id: 'dsh-market-state.json', src: join(profileDir, '.dsh-market', 'state.json') },
3377
+ // 0.4.24:Windows-MCP 版本状态(active/previous/history/lastCheck)——之前是 .dsh 根散落文件、
3378
+ // plugin-data 只扫一级目录、settings 白名单也没有它,跨机一直丢。纳入 settings 组同步。
3379
+ { id: 'dsh-windows-mcp.versions.json', src: join(dshHome, 'dsh-windows-mcp.versions.json') },
3377
3380
  ].filter((x) => existsSync(x.src))
3378
3381
  groups.push({ id: 'settings', titleZh: '插件设置与工作流', titleEn: 'Plugin settings & workflows',
3379
3382
  descZh: '免付费模型设置、ComfyUI 工作流库、桌宠配置、插件市场状态', descEn: 'Free-model settings, ComfyUI workflows, desktop-pet config, market state',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-config-sync-plugin",
3
- "version": "0.4.23",
3
+ "version": "0.4.24",
4
4
  "type": "module",
5
5
  "description": "在 DSH 设置里查看 dsh-config 仓库与本机的同步状态,并生成退出后执行的 push/pull 脚本。同步动作本身不在应用内执行。面板与文案跟随客户端语言(中文/English)。",
6
6
  "main": "./index.js",
package/runtime/apply.ps1 CHANGED
@@ -85,6 +85,12 @@ function Expand-AppRoot([string]$text, [string]$rootFwd) {
85
85
  $wsFwd = $WorkspaceHome.Replace('\\', '/').TrimEnd('/')
86
86
  $text = $text.Replace($WorkspaceHomeToken, $wsFwd)
87
87
  }
88
+ # 0.4.24:windows-mcp-bridge command 里的 {{DSH_HOME}} → 本机 .dsh 路径。
89
+ # capture 侧 Set-AppRootToken 已把旧机 DSH_HOME token 化,这里必须展开,否则桥行留裸占位符。
90
+ if ($text.Contains($DshHomeToken)) {
91
+ $dshFwd = ([string]$DshHome).Replace('\\', '/').TrimEnd('/')
92
+ $text = $text.Replace($DshHomeToken, $dshFwd)
93
+ }
88
94
  # 再兜底老仓库里没迁移过的盘符绝对路径
89
95
  return (Convert-AppRootText $text $AppRoot $rootFwd)
90
96
  }
@@ -863,7 +869,9 @@ $settingsMap = @(
863
869
  @{ Repo = 'settings\task-board-ledger.json'; Src = (Join-Path $DshHome 'task-board\ledger-v2.json'); Label = '任务板台账' },
864
870
  @{ Repo = 'settings\task-board-scheduler.json'; Src = (Join-Path $DshHome 'task-board\scheduler-v2.json'); Label = '任务板调度' },
865
871
  @{ Repo = 'settings\dsh-workspaces.json'; Src = (Join-Path $DshHome 'storages\workspace.json'); Label = 'DSH 工作区登记' },
866
- @{ Repo = 'settings\workspace-archives.json'; Src = (Join-Path $DshHome 'dsh-session-manager\workspace-archives.v1.json'); Label = 'DSH 工作区隐藏状态' }
872
+ @{ Repo = 'settings\workspace-archives.json'; Src = (Join-Path $DshHome 'dsh-session-manager\workspace-archives.v1.json'); Label = 'DSH 工作区隐藏状态' },
873
+ # 0.4.24:Windows-MCP 版本状态,与 capture.ps1 的 settingsMap 同步
874
+ @{ Repo = 'settings\dsh-windows-mcp.versions.json'; Src = (Join-Path $DshHome 'dsh-windows-mcp.versions.json'); Label = 'Windows-MCP 版本状态' }
867
875
  )
868
876
 
869
877
  # ---------- 0.5 宿主版本契约(只提示、不阻断拉取;0.4.10 起) ----------
@@ -1213,6 +1221,37 @@ foreach ($m in $settingsMap) {
1213
1221
  }
1214
1222
  Ok "已还原插件设置 / 工作流 / 各插件配置"
1215
1223
  } else { Warn '跳过(未勾选同步):插件设置 / 工作流 / 各插件配置' }
1224
+
1225
+ # 5.5) MCP 连接器配置还原(0.4.24 补全:此前 apply 完全没有 mcp 相关代码)
1226
+ if (Test-SyncGroupEnabled $Scope 'mcp-connectors') {
1227
+ $mcpSrcRepo = Join-Path $RepoRoot 'mcp-connectors\mcp_connector.json'
1228
+ $mcpDstLocal = Join-Path $DshHome 'storages\mcp_connector.json'
1229
+ if (-not (Test-Path -LiteralPath $mcpSrcRepo)) {
1230
+ Warn '仓库里没有 mcp-connectors\mcp_connector.json,跳过 MCP 连接器还原'
1231
+ } else {
1232
+ # 覆盖前备份本机现状(含机主自己的授权,翻车可还原)
1233
+ if (Test-Path -LiteralPath $mcpDstLocal) {
1234
+ $mcpBakDir = Join-Path $BackupDir 'mcp-connectors'
1235
+ if (-not (Test-Path -LiteralPath $mcpBakDir)) { New-Item -ItemType Directory -Path $mcpBakDir -Force | Out-Null }
1236
+ Copy-Item -LiteralPath $mcpDstLocal -Destination (Join-Path $mcpBakDir 'mcp_connector.json') -Force
1237
+ }
1238
+ $mcpTxt = [IO.File]::ReadAllText($mcpSrcRepo)
1239
+ $mcpExpanded = Expand-TokenText $mcpTxt $roots
1240
+ $mcpMissing = @(Get-MissingTokens $mcpExpanded)
1241
+ if ($mcpMissing.Count -gt 0) {
1242
+ foreach ($k in $mcpMissing) {
1243
+ $pendingItems.Add([pscustomobject][ordered]@{ token = $k; file = 'mcp-connectors\mcp_connector.json'; label = 'MCP 连接器配置'; hint = (Get-TokenHint $k) }) | Out-Null
1244
+ }
1245
+ Warn ("跳过 MCP 连接器还原:需要先确认路径 " + ($mcpMissing -join '、'))
1246
+ } else {
1247
+ $mcpDir = Split-Path -Parent $mcpDstLocal
1248
+ if (-not (Test-Path -LiteralPath $mcpDir)) { New-Item -ItemType Directory -Path $mcpDir -Force | Out-Null }
1249
+ [IO.File]::WriteAllText($mcpDstLocal, $mcpExpanded, (New-Object Text.UTF8Encoding($false)))
1250
+ Ok '已还原 MCP 连接器配置(含 OAuth/API Key 凭据,敏感文件)'
1251
+ }
1252
+ }
1253
+ } else { Warn '跳过(未勾选同步):MCP 连接器配置' }
1254
+
1216
1255
  if ($pendingItems.Count -gt 0) {
1217
1256
  $pf = Write-PendingPaths $DshHome $pendingItems
1218
1257
  Warn ("有 {0} 项配置等待确认路径,本次未写入。已记到 {1},到面板「本机路径」选好目录,之后再拉取一次即可。" -f $pendingItems.Count, $pf)
@@ -606,7 +606,15 @@ function Sync-ConversationCapture {
606
606
  # 现在先按本机 -AppRoot 的实际路径做字面替换(任意目录名、任意盘符),再用「末级目录名」正则兜底。
607
607
 
608
608
  function Set-AppRootToken([string]$text) {
609
- return (Convert-AppRootText $text $AppRoot $AppRootToken)
609
+ $text = Convert-AppRootText $text $AppRoot $AppRootToken
610
+ # 0.4.24:profile\cordis.patch.yml 里 windows-mcp-bridge 的 command 是 DSH_HOME 下的绝对路径
611
+ # (C:\Users\xxx\.dsh\dsh-windows-mcp\toolchain\...\windows-mcp.exe)。只 token 化 AppRoot 会漏掉它,
612
+ # 换机后仍指向旧机 Administrator 路径、桥接 exe 失效。补一条 DSH_HOME → {{DSH_HOME}}。
613
+ if ($text -and $DshHome -and $DshHome.Length -ge 5) {
614
+ foreach ($v in (Get-PathVariants $DshHome)) { $text = $text.Replace($v, $DshHomeToken) }
615
+ $text = [regex]::Replace($text, '(\{\{DSH_HOME\}\})((?:\\\\|\\|/)[^"\s,;:}{\[\]]*)', { param($m) $m.Groups[1].Value + ($m.Groups[2].Value.Replace('\\', '/').Replace('\', '/')) })
616
+ }
617
+ return $text
610
618
  }
611
619
 
612
620
  Say "== DSH 配置同步 / capture =="
@@ -899,7 +907,10 @@ if (Test-SyncGroupEnabled $Scope 'settings') {
899
907
  @{ Repo = 'settings\task-board-ledger.json'; Src = (Join-Path $DshHome 'task-board\ledger-v2.json'); Label = '任务板台账' },
900
908
  @{ Repo = 'settings\task-board-scheduler.json'; Src = (Join-Path $DshHome 'task-board\scheduler-v2.json'); Label = '任务板调度' },
901
909
  @{ Repo = 'settings\dsh-workspaces.json'; Src = (Join-Path $DshHome 'storages\workspace.json'); Label = 'DSH 工作区登记' },
902
- @{ Repo = 'settings\workspace-archives.json'; Src = (Join-Path $DshHome 'dsh-session-manager\workspace-archives.v1.json'); Label = 'DSH 工作区隐藏状态' }
910
+ @{ Repo = 'settings\workspace-archives.json'; Src = (Join-Path $DshHome 'dsh-session-manager\workspace-archives.v1.json'); Label = 'DSH 工作区隐藏状态' },
911
+ # 0.4.24:Windows-MCP 版本状态(active/previous/history/lastCheck),此前是 .dsh 根散落文件、
912
+ # plugin-data 只扫一级目录、settings 白名单也没有它 → 跨机一直丢。纳入 settings 组。
913
+ @{ Repo = 'settings\dsh-windows-mcp.versions.json'; Src = (Join-Path $DshHome 'dsh-windows-mcp.versions.json'); Label = 'Windows-MCP 版本状态' }
903
914
  )
904
915
  foreach ($m in $settingsMap) {
905
916
  if (-not (Test-SyncItemEnabled $Scope 'settings' ($m.Repo -replace '^settings\\', ''))) {
@@ -936,6 +947,33 @@ if (Test-SyncGroupEnabled $Scope 'settings') {
936
947
 
937
948
  } else { Skip-SyncGroup $Scope $RepoRoot 'settings' }
938
949
 
950
+ # 5.5) MCP 连接器配置(0.4.24 补全:此前面板有组、这里只有建空目录,没有真正抓取)
951
+ # mcp_connector.json 含 OAuth token / API Key,属敏感文件:文本里 token 会被 ConvertTo-TokenText
952
+ # 归一本机路径(若字段里有),但凭据本身原样入库——这是用户要跨机复用授权的明确选择。
953
+ if (Test-SyncGroupEnabled $Scope 'mcp-connectors') {
954
+ $mcpSrc = Join-Path $DshHome 'storages\mcp_connector.json'
955
+ $mcpDst = Join-Path $RepoRoot 'mcp-connectors\mcp_connector.json'
956
+ if (Test-Path -LiteralPath $mcpSrc) {
957
+ $mcpRoots = Get-SyncRoots $DshHome $AppRoot $WorkspaceHome
958
+ $txt = [IO.File]::ReadAllText($mcpSrc)
959
+ $txt = ConvertTo-TokenText $txt $mcpRoots
960
+ $norm = $txt -replace "`r`n", "`n"
961
+ $existing = $null
962
+ if (Test-Path -LiteralPath $mcpDst) { $existing = [IO.File]::ReadAllText($mcpDst) -replace "`r`n", "`n" }
963
+ if ($null -ne $existing -and $existing -eq $norm) {
964
+ Say " = mcp-connectors\mcp_connector.json(无变化)"
965
+ } else {
966
+ $mcpDir = Split-Path -Parent $mcpDst
967
+ if (-not (Test-Path -LiteralPath $mcpDir)) { New-Item -ItemType Directory -Path $mcpDir -Force | Out-Null }
968
+ [IO.File]::WriteAllText($mcpDst, $norm, (New-Object Text.UTF8Encoding($false, $false)))
969
+ $changed.Add('mcp-connectors\mcp_connector.json') | Out-Null
970
+ Ok "更新 mcp-connectors\mcp_connector.json(含 OAuth/API Key 凭据,敏感文件)"
971
+ }
972
+ } else {
973
+ Warn "本机没有 storages\mcp_connector.json,跳过 MCP 连接器同步"
974
+ }
975
+ } else { Skip-SyncGroup $Scope $RepoRoot 'mcp-connectors' }
976
+
939
977
  # 6) 记忆插件数据目录 mnemon(与记忆插件配套,需要跨机一致)
940
978
  if (Test-SyncGroupEnabled $Scope 'mnemon') {
941
979
  $mnemonSrc = Join-Path $AppRoot 'mnemon'
@@ -2175,5 +2175,29 @@ console.log('== 0.4.23:跨机隐藏对齐(Mnemon/子代理会话同步保留
2175
2175
  && apS3.includes("$allSids += @($localTable[$id2]['sessionIds'])"), 'apply.ps1')
2176
2176
  }
2177
2177
 
2178
+ console.log('== 0.4.24:Windows-MCP 版本状态 + MCP 连接器真实同步 + 桥行 DSH_HOME token ==')
2179
+ {
2180
+ const capS4 = readFileSync(join(pluginRootSelf, 'runtime', 'capture.ps1'), 'utf8')
2181
+ const apS4 = readFileSync(join(pluginRootSelf, 'runtime', 'apply.ps1'), 'utf8')
2182
+ const idxS4 = readFileSync(join(pluginRootSelf, 'index.js'), 'utf8')
2183
+ // 1) Windows-MCP versions.json 入 settings 白名单(capture + apply + 面板)
2184
+ check('capture.ps1 settingsMap 含 dsh-windows-mcp.versions.json',
2185
+ capS4.includes("settings\\dsh-windows-mcp.versions.json"), 'capture.ps1')
2186
+ check('apply.ps1 settingsMap 含 dsh-windows-mcp.versions.json',
2187
+ apS4.includes("settings\\dsh-windows-mcp.versions.json"), 'apply.ps1')
2188
+ check('index.js settingsFiles 含 dsh-windows-mcp.versions.json',
2189
+ idxS4.includes("'dsh-windows-mcp.versions.json'"), 'index.js')
2190
+ // 2) MCP 连接器真实抓取/还原(此前是空壳:只有组声明 + 建空目录)
2191
+ check('capture.ps1 有 mcp-connectors 真实抓取(CopyTracked mcp_connector.json)',
2192
+ capS4.includes("mcp-connectors\\mcp_connector.json") && capS4.includes('Get-SyncRoots $DshHome $AppRoot $WorkspaceHome'), 'capture.ps1')
2193
+ check('apply.ps1 有 mcp-connectors 还原(写回 storages\\mcp_connector.json)',
2194
+ apS4.includes("mcp-connectors\\mcp_connector.json") && apS4.includes("storages\\mcp_connector.json"), 'apply.ps1')
2195
+ // 3) 桥行 DSH_HOME token 化(capture 替换 + apply 展开)
2196
+ check('capture.ps1 Set-AppRootToken 含 DSH_HOME token 化',
2197
+ capS4.includes('$DshHomeToken') && capS4.includes('Get-PathVariants $DshHome'), 'capture.ps1')
2198
+ check('apply.ps1 Expand-AppRoot 含 {{DSH_HOME}} 展开',
2199
+ apS4.includes('$text.Replace($DshHomeToken, $dshFwd)'), 'apply.ps1')
2200
+ }
2201
+
2178
2202
  process.exit(failures === 0 ? 0 : 1)
2179
2203