dsh-config-sync-plugin 0.4.22 → 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/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.22",
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
  }
@@ -404,6 +410,23 @@ function Sync-WorkspaceApply {
404
410
  if ($defaultSids.Count -gt 0 -and $dwId -and $localTable.Contains($dwId)) {
405
411
  $localTable[$dwId]['sessionIds'] = @(@($localTable[$dwId]['sessionIds']) + $defaultSids | Where-Object { $_ -ne '' } | Sort-Object -Unique)
406
412
  }
413
+ # 跨机隐藏对齐(0.4.23):Mnemon 后台会话(id 前缀 mnemon-*)与子代理会话(纯 uuid id,无 session- 前缀)
414
+ # 会被登记进各机 workspace.json 并随同步带到对端。DSH UI 对 origin=subagent / blank 会话有视图级折叠,
415
+ # 但同步来的会话不在折叠边界时(如 mnemon-task-v1-* 带 turn/start、同步日志里的首条用户消息让 blank=false),
416
+ # 对端工作台就会列出「MnemonSkills 会话」和「未命名会话」。这两类会话都应同步保留(会话体不删),
417
+ # 但确定性不显示:把它们的 id 并进 global.archivedSessionIds(DSH 原生隐藏通道,列表/搜索/打开全链路拦截)。
418
+ # 判定只看 id 形态、不解会话头:A 机 401 个磁盘会话样本中主会话恒为 session- 前缀,
419
+ # mnemon-* 与纯 uuid(不带 session- 前缀)即两类后台会话,无例外。
420
+ $allSids = @()
421
+ foreach ($e2 in $plan) { $allSids += @($e2.SessionIds) }
422
+ foreach ($k2 in @($sidByWsDir.Keys)) { $allSids += @($sidByWsDir[$k2]) }
423
+ $allSids += $defaultSids
424
+ foreach ($id2 in @($localTable.Keys)) { $allSids += @($localTable[$id2]['sessionIds']) }
425
+ $autoHide = @($allSids | ForEach-Object { [string]$_ } | Where-Object { $_ -ne '' -and $_ -notlike 'session-*' })
426
+ if ($autoHide.Count -gt 0) {
427
+ $gArchAll += $autoHide
428
+ Ok ('跨机隐藏对齐:{0} 个 Mnemon/子代理会话已标记隐藏(同步保留、工作台不显示)' -f @($autoHide | Sort-Object -Unique).Count)
429
+ }
407
430
  $localGlobal['initialized'] = $true
408
431
  $localGlobal['workspaceIds'] = $ids
409
432
  $localGlobal['archivedSessionIds'] = @($gArchAll | Sort-Object -Unique)
@@ -846,7 +869,9 @@ $settingsMap = @(
846
869
  @{ Repo = 'settings\task-board-ledger.json'; Src = (Join-Path $DshHome 'task-board\ledger-v2.json'); Label = '任务板台账' },
847
870
  @{ Repo = 'settings\task-board-scheduler.json'; Src = (Join-Path $DshHome 'task-board\scheduler-v2.json'); Label = '任务板调度' },
848
871
  @{ Repo = 'settings\dsh-workspaces.json'; Src = (Join-Path $DshHome 'storages\workspace.json'); Label = 'DSH 工作区登记' },
849
- @{ 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 版本状态' }
850
875
  )
851
876
 
852
877
  # ---------- 0.5 宿主版本契约(只提示、不阻断拉取;0.4.10 起) ----------
@@ -1196,6 +1221,37 @@ foreach ($m in $settingsMap) {
1196
1221
  }
1197
1222
  Ok "已还原插件设置 / 工作流 / 各插件配置"
1198
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
+
1199
1255
  if ($pendingItems.Count -gt 0) {
1200
1256
  $pf = Write-PendingPaths $DshHome $pendingItems
1201
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'
@@ -2161,5 +2161,43 @@ console.log('== 0.4.21:更新安装兼容 pnpm 重打包结构(顶层 包名
2161
2161
  apS2.includes('pnpm publish 重打包') && apS2.includes("Join-Path $_.FullName 'package.json'"), 'apply.ps1')
2162
2162
  }
2163
2163
 
2164
+ console.log('== 0.4.23:跨机隐藏对齐(Mnemon/子代理会话同步保留但不显示)==')
2165
+ {
2166
+ const apS3 = readFileSync(join(pluginRootSelf, 'runtime', 'apply.ps1'), 'utf8')
2167
+ // apply.ps1 落盘前把非 session- 前缀的登记会话 id 并进 $gArchAll(global.archivedSessionIds)
2168
+ check('apply.ps1 跨机隐藏对齐块存在(0.4.23 注释)', apS3.includes('跨机隐藏对齐(0.4.23)'), 'apply.ps1')
2169
+ check('apply.ps1 autoHide 判定:非 session- 前缀即 Mnemon/子代理', apS3.includes("-notlike 'session-*'"), 'apply.ps1')
2170
+ check('apply.ps1 autoHide 并进 $gArchAll(global 隐藏通道)', apS3.includes('$gArchAll += $autoHide'), 'apply.ps1')
2171
+ check('apply.ps1 收集源覆盖 plan/sidByWsDir/defaultSids/localTable',
2172
+ apS3.includes('$allSids += @($e2.SessionIds)')
2173
+ && apS3.includes('$allSids += @($sidByWsDir[$k2])')
2174
+ && apS3.includes('$allSids += $defaultSids')
2175
+ && apS3.includes("$allSids += @($localTable[$id2]['sessionIds'])"), 'apply.ps1')
2176
+ }
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
+
2164
2202
  process.exit(failures === 0 ? 0 : 1)
2165
2203