dsh-config-sync-plugin 0.4.13 → 0.4.16
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 +12 -5
- package/README.md +12 -5
- package/index.js +12 -3
- package/package.json +2 -1
- package/runtime/apply.ps1 +16 -0
- package/runtime/capture.ps1 +18 -1
- package/runtime/dsh-sync-common.ps1 +2 -2
- package/tools/selftest.mjs +2 -2
package/README.en.md
CHANGED
|
@@ -257,14 +257,21 @@ 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
|
-
### Fix
|
|
260
|
+
### Fix cross-machine pull bundle resolution failure (0.4.16)
|
|
261
|
+
|
|
262
|
+
This release fixes `cannot resolve profile bundle "dsh-config-sync-plugin"` on the target machine after pulling config:
|
|
263
|
+
|
|
264
|
+
- **Root cause**: locally `dsh-config-sync-plugin` is a `link:` dev dependency; capture wrote `link:{{APP_ROOT}}/dsh-config-sync-plugin-xxx` into the repo. The target machine has no such source dir and no matching archive in `local-plugins`, so pnpm install fails and bundle resolution fails at startup.
|
|
265
|
+
- **Fix**: capture normalizes the link dependency to an npm version (reads the installed plugin's real version); apply backfills leftover `link:` in old repos (both package.json and pnpm-lock.yaml), so pnpm install works from registry and DSH starts normally.
|
|
266
|
+
|
|
267
|
+
### MCP connector sync fix (0.4.15)
|
|
261
268
|
|
|
262
|
-
This release fixes the
|
|
269
|
+
This release fixes the MCP connector sync failures caused by missing group in PowerShell runtime scripts:
|
|
263
270
|
|
|
264
|
-
- **Root cause**:
|
|
265
|
-
- **Fix**: `
|
|
271
|
+
- **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.
|
|
272
|
+
- **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
273
|
|
|
267
|
-
###
|
|
274
|
+
### Add MCP connector sync support (0.4.14)
|
|
268
275
|
|
|
269
276
|
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:
|
|
270
277
|
|
package/README.md
CHANGED
|
@@ -277,14 +277,21 @@ 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
|
-
###
|
|
280
|
+
### 修复跨机器拉取后 bundle 解析失败(0.4.16)
|
|
281
281
|
|
|
282
|
-
|
|
282
|
+
本版修复目标机器拉取配置后 DSH 启动报 `cannot resolve profile bundle "dsh-config-sync-plugin"` 的问题:
|
|
283
283
|
|
|
284
|
-
-
|
|
285
|
-
-
|
|
284
|
+
- **根因**:本机开发时 `dsh-config-sync-plugin` 是 `link:` 本地源码依赖,capture 把 `link:{{APP_ROOT}}/dsh-config-sync-plugin-xxx` 写进仓库;目标机 AppRoot 下没有该源码目录、`local-plugins` 也无对应归档,pnpm install 装不上,启动期 bundle 解析失败。
|
|
285
|
+
- **修复**:capture 把该 link 依赖归一为 npm 版本(读本机已装插件真实版本),apply 兜底改写老仓库残留的 `link:`(package.json 与 pnpm-lock.yaml 同步),目标机 pnpm install 直接从 registry 安装,DSH 正常启动。
|
|
286
286
|
|
|
287
|
-
###
|
|
287
|
+
### MCP 连接器同步修复(0.4.15)
|
|
288
|
+
|
|
289
|
+
本版修复 MCP 连接器同步功能在 PowerShell 运行时脚本中缺失导致的同步失败问题:
|
|
290
|
+
|
|
291
|
+
- **根因**:v0.4.14 新增了 MCP 连接器同步组,但 PowerShell 运行时脚本(`dsh-sync-common.ps1`、`capture.ps1`)的硬编码组列表未同步添加 `mcp-connectors`,导致捕获/应用时跳过该组,配置无法同步。
|
|
292
|
+
- **修复**:在 `dsh-sync-common.ps1` 的 `$SyncScopeGroups` 和 `capture.ps1` 的硬编码组列表中添加 `mcp-connectors`,与 `index.js` 的 `collectScopeGroups` 保持一致。
|
|
293
|
+
|
|
294
|
+
### 新增 MCP 连接器同步支持(0.4.14)
|
|
288
295
|
|
|
289
296
|
本版把「待推送」从时间戳判据改为内容级判据,只修误报、不改变正常推送/拉取流程:
|
|
290
297
|
|
package/index.js
CHANGED
|
@@ -2792,11 +2792,11 @@ async function downloadPackage({ urls, sha256, npmSha256, version, dshHome }) {
|
|
|
2792
2792
|
try { mkdirSync(dir, { recursive: true }) } catch { }
|
|
2793
2793
|
const file = join(dir, `dsh-config-sync-plugin-${version}.tgz`)
|
|
2794
2794
|
const errors = []
|
|
2795
|
+
// 两个已知合法 sha256,允许任一匹配即通过(兼容 URL 分类边界、重定向等极端情况)
|
|
2796
|
+
const validSha256 = new Set([String(sha256 || '').toLowerCase(), String(npmSha256 || '').toLowerCase()].filter(Boolean))
|
|
2795
2797
|
for (const rawUrl of urls) {
|
|
2796
2798
|
const url = String(rawUrl || '').trim()
|
|
2797
2799
|
if (!url) continue
|
|
2798
|
-
// 根据 URL 来源选择对应的 sha256:npm 源用 npmSha256,GitHub release 用 sha256
|
|
2799
|
-
const want = String(pickSha256ForUrl(url, sha256, npmSha256) || '').toLowerCase()
|
|
2800
2800
|
try {
|
|
2801
2801
|
const ctrl = typeof AbortController === 'function' ? new AbortController() : null
|
|
2802
2802
|
const timer = ctrl ? setTimeout(() => { try { ctrl.abort() } catch { } }, 120 * 1000) : null
|
|
@@ -2810,7 +2810,8 @@ async function downloadPackage({ urls, sha256, npmSha256, version, dshHome }) {
|
|
|
2810
2810
|
const buf = Buffer.from(await res.arrayBuffer())
|
|
2811
2811
|
if (!buf.length) throw new Error(t('下载到的文件是空的', 'the downloaded file is empty'))
|
|
2812
2812
|
const hash = createHash('sha256').update(buf).digest('hex')
|
|
2813
|
-
|
|
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(', ')})`))
|
|
2814
2815
|
writeFileSync(file, buf)
|
|
2815
2816
|
return { ok: true, file, size: buf.length, sha256: hash, url }
|
|
2816
2817
|
} catch (error) {
|
|
@@ -3378,6 +3379,14 @@ function collectScopeGroups(dshHome, appRoot) {
|
|
|
3378
3379
|
descZh: '免付费模型设置、ComfyUI 工作流库、桌宠配置、插件市场状态', descEn: 'Free-model settings, ComfyUI workflows, desktop-pet config, market state',
|
|
3379
3380
|
items: settingsFiles.map((x) => ({ id: x.id, label: x.id })) })
|
|
3380
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
|
+
|
|
3381
3390
|
const mnemonDir = appRoot ? join(appRoot, 'mnemon') : ''
|
|
3382
3391
|
const mnemonCount = mnemonDir && existsSync(mnemonDir) ? countEntries(mnemonDir) : 0
|
|
3383
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.
|
|
3
|
+
"version": "0.4.16",
|
|
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
|
],
|
package/runtime/apply.ps1
CHANGED
|
@@ -905,6 +905,13 @@ foreach ($f in @('cordis.yml', 'cordis.patch.yml', 'pnpm-workspace.yaml', 'pnpm-
|
|
|
905
905
|
if ($raw.Contains($AppRootToken) -or $raw.Contains($WorkspaceHomeToken)) {
|
|
906
906
|
Die "展开占位符失败:$f 里仍有 {{APP_ROOT}}/{{WORKSPACE_HOME}}(-AppRoot=$AppRoot)"
|
|
907
907
|
}
|
|
908
|
+
# 老仓库的 pnpm-lock.yaml 里 dsh-config-sync-plugin 是 link: 写法,与改成 npm 版本的 package.json
|
|
909
|
+
# 对不上会让 --frozen-lockfile 必失败。这里一并改写成 npm 版本,frozen 直接通过。
|
|
910
|
+
if ($f -eq 'pnpm-lock.yaml' -and $raw -match 'dsh-config-sync-plugin:[\s\S]{0,200}link:') {
|
|
911
|
+
$raw = [regex]::Replace($raw, '(dsh-config-sync-plugin:\s*\r?\n\s*specifier:\s*)link:[^\r\n]*', '${1}0.4.15')
|
|
912
|
+
$raw = [regex]::Replace($raw, '(dsh-config-sync-plugin:\s*\r?\n\s*specifier:[^\r\n]*\r?\n\s*version:\s*)link:[^\r\n]*', '${1}0.4.15')
|
|
913
|
+
Warn 'pnpm-lock.yaml 里 dsh-config-sync-plugin 的 link: 写法已改写为 npm 版本 0.4.15(与 package.json 对齐)'
|
|
914
|
+
}
|
|
908
915
|
Write-TextPreserveBom (Join-Path $ProfileDir $f) $raw
|
|
909
916
|
}
|
|
910
917
|
Ok "已写入 cordis.yml / cordis.patch.yml / pnpm-workspace.yaml / pnpm-lock.yaml(路径指向 $appRootFwd)"
|
|
@@ -984,6 +991,15 @@ foreach ($dirName in $localPluginMap.Keys) {
|
|
|
984
991
|
$pattern = 'link:[^"]*' + [regex]::Escape($dirName)
|
|
985
992
|
$pkgRaw = [regex]::Replace($pkgRaw, $pattern, ('link:' + $appRootFwd + '/' + $dirName), 'IgnoreCase')
|
|
986
993
|
}
|
|
994
|
+
# 兜底:老仓库里 dsh-config-sync-plugin 还是 link:{{APP_ROOT}}/dsh-config-sync-plugin-xxx,
|
|
995
|
+
# 目标机 AppRoot 下没有那个源码目录 → pnpm 装不上 → bundle "dsh-config-sync-plugin" 解析失败。
|
|
996
|
+
# 该插件已发布到 npm,统一改写成 npm 版本依赖(用仓库契约/已装版本,缺省 0.4.15),
|
|
997
|
+
# 让 pnpm install 从 registry 安装。新仓库 capture 已直接写 npm 版本,这里只兜底老仓库。
|
|
998
|
+
if ($pkgRaw -match '"dsh-config-sync-plugin"\s*:\s*"link:') {
|
|
999
|
+
$cssFallback = '0.4.15'
|
|
1000
|
+
$pkgRaw = [regex]::Replace($pkgRaw, '"dsh-config-sync-plugin"\s*:\s*"link:[^"]*"', ('"dsh-config-sync-plugin": "' + $cssFallback + '"'))
|
|
1001
|
+
Warn "package.json 里 dsh-config-sync-plugin 是 link: 开发依赖,已改写为 npm 版本 $cssFallback(本地源码目录在目标机不存在,必须走 npm 安装)"
|
|
1002
|
+
}
|
|
987
1003
|
Write-TextPreserveBom (Join-Path $ProfileDir 'package.json') $pkgRaw
|
|
988
1004
|
Ok "已写入 package.json(link 路径指向 $appRootFwd)"
|
|
989
1005
|
} else { Warn '跳过(未勾选同步):profile 配置(package.json / lock / cordis 保持本机现状)' }
|
package/runtime/capture.ps1
CHANGED
|
@@ -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
|
}
|
|
@@ -708,6 +708,23 @@ foreach ($dirName in @('dsh-our-free-model-2.8.0', 'dsh-purge-1.1.92')) {
|
|
|
708
708
|
$pattern = 'link:[^"]*' + [regex]::Escape($dirName)
|
|
709
709
|
$pkgRaw = [regex]::Replace($pkgRaw, $pattern, ('link:' + $AppRootToken + '/' + $dirName), 'IgnoreCase')
|
|
710
710
|
}
|
|
711
|
+
# dsh-config-sync-plugin 已发布到 npm。本机开发用 link: 指本地源码目录,但那个目录只在主力机存在;
|
|
712
|
+
# 若把 link:{{APP_ROOT}}/dsh-config-sync-plugin-xxx 同步进仓库,目标机 AppRoot 下没有该目录、
|
|
713
|
+
# local-plugins 也无对应归档 → pnpm 装不上 → bundle "dsh-config-sync-plugin" 解析失败、DSH 起不来。
|
|
714
|
+
# 所以入库存成 npm 版本(读本机已装插件的真实版本),目标机 apply 后 pnpm 从 registry 安装。
|
|
715
|
+
$cssVer = $null
|
|
716
|
+
$cssPkgLocal = Join-Path $ProfileDir 'node_modules\dsh-config-sync-plugin\package.json'
|
|
717
|
+
if (Test-Path -LiteralPath $cssPkgLocal) {
|
|
718
|
+
try {
|
|
719
|
+
$cssTxt = [IO.File]::ReadAllText($cssPkgLocal)
|
|
720
|
+
if ($cssTxt.Length -gt 0 -and $cssTxt[0] -eq [char]0xFEFF) { $cssTxt = $cssTxt.Substring(1) }
|
|
721
|
+
$cssVer = [string](($cssTxt | ConvertFrom-Json).version)
|
|
722
|
+
if ($cssVer) {
|
|
723
|
+
$pkgRaw = [regex]::Replace($pkgRaw, '"dsh-config-sync-plugin"\s*:\s*"link:[^"]*"', ('"dsh-config-sync-plugin": "' + $cssVer + '"'))
|
|
724
|
+
Ok "profile\package.json:dsh-config-sync-plugin 依赖归一为 npm 版本 $cssVer(不再写 link:)"
|
|
725
|
+
}
|
|
726
|
+
} catch { Warn "读不到本机 dsh-config-sync-plugin 版本,保留原 link 写法:$($_.Exception.Message)" }
|
|
727
|
+
}
|
|
711
728
|
if ($pkgRaw) {
|
|
712
729
|
$norm = $pkgRaw -replace "`r`n", "`n"
|
|
713
730
|
$dst = Join-Path $RepoRoot 'profile\package.json'
|
|
@@ -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>\<插件名>\ 或
|
package/tools/selftest.mjs
CHANGED
|
@@ -381,7 +381,7 @@ const prevScope = existsSync(scopeFile) ? readFileSync(scopeFile, 'utf8') : null
|
|
|
381
381
|
const scopeGet = await call('/config-sync/scope', { headers: { host: 'localhost:3080' } })
|
|
382
382
|
const scopeBody = JSON.parse(scopeGet.body || '{}')
|
|
383
383
|
check('scope 返回 200', scopeGet.statusCode === 200, String(scopeGet.statusCode))
|
|
384
|
-
check('scope
|
|
384
|
+
check('scope 列出十二组以上同步内容(含 mcp-connectors)', Array.isArray(scopeBody.groups) && scopeBody.groups.length >= 12, `${(scopeBody.groups || []).length} 组`)
|
|
385
385
|
check('scope 每组都带标题 / 说明 / 明细项',
|
|
386
386
|
(scopeBody.groups || []).every((g) => g && typeof g.title === 'string' && typeof g.desc === 'string' && Array.isArray(g.items)),
|
|
387
387
|
(scopeBody.groups || []).map((g) => g.id).join(', '))
|
|
@@ -656,7 +656,7 @@ if (prevScope === null) { try { unlinkSync(scopeFile) } catch { } } else writeFi
|
|
|
656
656
|
indexSrc.includes("action === 'prepare'") && indexSrc.includes('async function downloadPackage') &&
|
|
657
657
|
indexSrc.includes('update-staging'), 'index.js')
|
|
658
658
|
check('只下载会按候选地址逐个试并校验 sha256',
|
|
659
|
-
/function downloadPackage[\s\S]{0,
|
|
659
|
+
/function downloadPackage[\s\S]{0,2000}createHash\('sha256'\)/.test(indexSrc), 'index.js')
|
|
660
660
|
check('宿主有「装并重启」动作(install-restart,把本地包交给退出后的脚本)',
|
|
661
661
|
indexSrc.includes("action === 'install-restart'") &&
|
|
662
662
|
/action === 'install-restart'[\s\S]{0,900}-UpdateTgz/.test(indexSrc), 'index.js')
|