dsh-config-sync-plugin 0.4.16 → 0.4.18
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 +24 -7
- package/README.md +17 -0
- package/client.js +1 -0
- package/index.js +4 -4
- package/package.json +1 -1
- package/runtime/apply.ps1 +120 -4
- package/runtime/dsh-sync-common.ps1 +1 -1
- package/runtime/sync.ps1 +78 -0
- package/tools/selftest.mjs +55 -2
package/README.en.md
CHANGED
|
@@ -257,13 +257,30 @@ 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
|
|
261
|
-
|
|
262
|
-
This release fixes
|
|
263
|
-
|
|
264
|
-
- **
|
|
265
|
-
- **
|
|
266
|
-
|
|
260
|
+
### Fix over-strict pull preflight (0.4.18)
|
|
261
|
+
|
|
262
|
+
This release fixes the 0.4.17 preflight false-failure that rolled back pulls on the target machine:
|
|
263
|
+
|
|
264
|
+
- **link archive false-missing**: preflight only looked for `.tgz` archives, but `dsh-our-free-model-2.8.0` / `dsh-purge-1.4.0` are `.zip` in the repo. Archives existed but were reported missing, blocking the pull. Now accepts both `.tgz` and `.zip`, matching apply's extraction.
|
|
265
|
+
- **workspaceHome false-fail**: on a fresh machine the workspace root does not exist yet — normal, apply creates it. Now auto-creates the directory and uses the default `~/Documents/deepseek-harness` when unset, instead of blocking.
|
|
266
|
+
- **Effect**: first pull on the second machine no longer fails preflight and rolls back; workspace and sessions land normally.
|
|
267
|
+
|
|
268
|
+
### Pull landing hardening: usable right after pull on a second machine (0.4.17)
|
|
269
|
+
|
|
270
|
+
Fixes "workspace and conversations both empty after pulling sync on another machine":
|
|
271
|
+
|
|
272
|
+
- **Root cause**: workspace/conversations groups could be unchecked; unconfirmed local roots, missing `link:` plugin directories or unresolved bundles made apply exit mid-way or DSH read an empty registry; an unresolved bundle also made the script exit non-zero and triggered post-exit rollback, wiping already-landed data.
|
|
273
|
+
- **Preflight**: before apply, pull checks the workspace/conversations groups, `-SkipWorkspace`, local appRoot/workspaceHome and `link:` plugin targets; missing prerequisites produce a clear diagnosis in sync-notices.json instead of a silent empty result.
|
|
274
|
+
- **No rollback**: unresolved bundles now record a notice and continue instead of Die, so landed workspace/session data is kept; `-ForceBundles` keeps the strict check.
|
|
275
|
+
- **Landing verification**: after apply, verify non-empty `workspaceIds`, a non-dangling default workspace, no duplicate paths, session directories restored, no leftover projcache tokens and complete `link:` plugins; result goes to `pull-landing-check.json`.
|
|
276
|
+
- **Required groups**: workspace files and conversations join profile as required sync groups and cannot be unchecked in the panel.
|
|
277
|
+
### Fix cross-machine pull bundle resolution failure (0.4.16)
|
|
278
|
+
|
|
279
|
+
This release fixes `cannot resolve profile bundle "dsh-config-sync-plugin"` on the target machine after pulling config:
|
|
280
|
+
|
|
281
|
+
- **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.
|
|
282
|
+
- **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.
|
|
283
|
+
|
|
267
284
|
### MCP connector sync fix (0.4.15)
|
|
268
285
|
|
|
269
286
|
This release fixes the MCP connector sync failures caused by missing group in PowerShell runtime scripts:
|
package/README.md
CHANGED
|
@@ -277,6 +277,23 @@ 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.18)
|
|
281
|
+
|
|
282
|
+
本版修复 0.4.17 新增的拉取前置检查在目标机误报失败、导致拉取被回滚的问题:
|
|
283
|
+
|
|
284
|
+
- **link 归档误报**:前置检查只找 `.tgz` 归档,但仓库里 `dsh-our-free-model-2.8.0` / `dsh-purge-1.4.0` 实际是 `.zip`。明明归档存在却报「缺失」,直接拦死拉取。本版改为同时认 `.tgz` 与 `.zip`,与 apply 的解压逻辑一致。
|
|
285
|
+
- **workspaceHome 误判**:全新机器首次拉取时工作区资料根还不存在是正常的(apply 落地时会自动建)。本版改为目录不存在就自动补建、路径未确认就用默认 `~/Documents/deepseek-harness`,不再因此拦死拉取。
|
|
286
|
+
- **效果**:目标机首次拉取不再因前置检查失败而回滚,工作区与会话能正常落地。
|
|
287
|
+
|
|
288
|
+
### 拉取落地加固:另一台机器拉取即可用(0.4.17)
|
|
289
|
+
|
|
290
|
+
本版修复「另一台机器拉取同步后,左侧工作区与会话同时为空」的问题:
|
|
291
|
+
|
|
292
|
+
- **根因**:工作区/会话组可被误取消勾选;本机根路径未确认、`link:` 插件本地目录缺失、bundle 未解析都可能让 apply 中途退出或让 DSH 读到空表;bundle 未解析时脚本非零退出还会触发 post-exit 回滚,把已经落地的工作区/会话一起擦掉。
|
|
293
|
+
- **前置检查**:拉取在进入 apply 前检查工作区/会话同步组、`-SkipWorkspace`、本机 appRoot/workspaceHome 与 `link:` 插件目标,缺项直接给出明确诊断(写入 sync-notices.json),不再「拉完是空的」。
|
|
294
|
+
- **不回滚**:bundle 未解析从「Die 停止」改为记 notice 并继续落地,避免把已同步的工作区/会话回滚掉;需要严格检查仍可用 `-ForceBundles`。
|
|
295
|
+
- **落地验证**:apply 结束后核对 `workspaceIds` 非空、默认工作区 ID 不悬空、无重复路径、会话目录已铺回、projcache 无占位符残留、`link:` 插件齐备,结果写 `pull-landing-check.json` 并在面板可查。
|
|
296
|
+
- **必需组**:工作区资料、会话记录与 profile 一起列为必需同步组,面板不可误取消,从源头堵住「勾选漏了导致空列表」。
|
|
280
297
|
### 修复跨机器拉取后 bundle 解析失败(0.4.16)
|
|
281
298
|
|
|
282
299
|
本版修复目标机器拉取配置后 DSH 启动报 `cannot resolve profile bundle "dsh-config-sync-plugin"` 的问题:
|
package/client.js
CHANGED
|
@@ -2143,6 +2143,7 @@ window.__ModuleLoader__.load({
|
|
|
2143
2143
|
history: M('历史里的超限文件', 'Oversized in history'),
|
|
2144
2144
|
failed: M('失败', 'Failed'),
|
|
2145
2145
|
skipped: M('跳过', 'Skipped'),
|
|
2146
|
+
landing: M('落地检查', 'Landing check'),
|
|
2146
2147
|
}[k] || k)
|
|
2147
2148
|
const rows = (notices.items || []).map((it, i) => h('div', {
|
|
2148
2149
|
key: `notice-${i}`,
|
package/index.js
CHANGED
|
@@ -1528,7 +1528,7 @@ function readAutoResult(dshHome) {
|
|
|
1528
1528
|
* 就回落到 ~/.dsh/sync-notices.json。两种情况都做裁剪,避免一个几万文件的仓库把 /status 撑爆。
|
|
1529
1529
|
*/
|
|
1530
1530
|
function readNoticeList(dshHome, fromResult) {
|
|
1531
|
-
const KINDS = ['plugin-missing', 'context-state', 'history', 'too-large', 'failed', 'skipped']
|
|
1531
|
+
const KINDS = ['plugin-missing', 'context-state', 'history', 'too-large', 'failed', 'skipped', 'landing']
|
|
1532
1532
|
let raw = fromResult
|
|
1533
1533
|
if (!raw || !Array.isArray(raw.items)) {
|
|
1534
1534
|
try {
|
|
@@ -3095,7 +3095,7 @@ function writeScope(dshHome, scope) {
|
|
|
3095
3095
|
// 必需组:不许取消勾选 —— 因为不勾就会报错,而不是"少同步一点"。
|
|
3096
3096
|
// profile 里的 package.json / cordis.patch.yml 是 apply 的前置条件(仓库里缺它们 apply.ps1 直接 Die)。
|
|
3097
3097
|
// host-contract.json 自 0.4.10 起只用于「本机/契约」信息条展示,版本不同不再阻断拉取。
|
|
3098
|
-
const SCOPE_REQUIRED_GROUPS = ['profile']
|
|
3098
|
+
const SCOPE_REQUIRED_GROUPS = ['profile', 'workspace', 'conversations']
|
|
3099
3099
|
function scopeGroupRequired(id) { return SCOPE_REQUIRED_GROUPS.includes(id) }
|
|
3100
3100
|
|
|
3101
3101
|
function scopeGroupEnabled(scope, id) {
|
|
@@ -3420,11 +3420,11 @@ function collectScopeGroups(dshHome, appRoot) {
|
|
|
3420
3420
|
|
|
3421
3421
|
const workspaces = listWorkspaceEntries(dshHome)
|
|
3422
3422
|
groups.push({ id: 'workspace', titleZh: '工作区资料', titleEn: 'Workspace files',
|
|
3423
|
-
descZh: '登记过的工作区里的资料(>100MB 与模型权重本来就不同步)', descEn: 'Files inside registered workspaces (big files and model weights are never synced)',
|
|
3423
|
+
descZh: '登记过的工作区里的资料(>100MB 与模型权重本来就不同步)', descEn: 'Files inside registered workspaces (big files and model weights are never synced)', required: true,
|
|
3424
3424
|
items: workspaces.map((w) => ({ id: w.id, label: w.title })) })
|
|
3425
3425
|
|
|
3426
3426
|
groups.push({ id: 'conversations', titleZh: '会话记录', titleEn: 'Conversations',
|
|
3427
|
-
descZh: '每个工作区的对话、附件与缓存(按工作区勾选)', descEn: 'Chats, attachments and caches per workspace',
|
|
3427
|
+
descZh: '每个工作区的对话、附件与缓存(按工作区勾选)', descEn: 'Chats, attachments and caches per workspace', required: true,
|
|
3428
3428
|
items: workspaces.map((w) => ({ id: w.id, label: w.title })) })
|
|
3429
3429
|
|
|
3430
3430
|
const scope = readScope(dshHome)
|
package/package.json
CHANGED
package/runtime/apply.ps1
CHANGED
|
@@ -1596,6 +1596,116 @@ if (Test-SyncGroupEnabled $Scope 'profile') {
|
|
|
1596
1596
|
if ($bm -eq 0) { Ok '插件备份无需清理' }
|
|
1597
1597
|
}
|
|
1598
1598
|
}
|
|
1599
|
+
function Test-PullLanding {
|
|
1600
|
+
# 0.4.17 落地后验证:「同步成功」和「DSH 真能读出来」之间还差最后一步。按 DSH 的登记表
|
|
1601
|
+
# 判据逐条核对,任何一条不过都写 pull-landing-check.json + notice,把"上层取不到数据"的
|
|
1602
|
+
# 原因摆到明面,而不是让用户对着空工作区/空会话列表瞎猜。本函数只提示、不回滚。
|
|
1603
|
+
$issues = @()
|
|
1604
|
+
$ids = @()
|
|
1605
|
+
$def = ''
|
|
1606
|
+
$localDirs = 0
|
|
1607
|
+
$reg = Join-Path $DshHome 'storages\workspace.json'
|
|
1608
|
+
$o = $null
|
|
1609
|
+
if (-not (Test-Path -LiteralPath $reg)) {
|
|
1610
|
+
$issues += 'workspace.json-missing'
|
|
1611
|
+
Add-SyncNotice -Kind 'landing' -Path 'storages/workspace.json' -Reason '本机工作区登记表不存在。'
|
|
1612
|
+
} else {
|
|
1613
|
+
try { $o = Get-Content -LiteralPath $reg -Raw -Encoding UTF8 | ConvertFrom-Json }
|
|
1614
|
+
catch {
|
|
1615
|
+
$issues += 'workspace.json-invalid'
|
|
1616
|
+
Add-SyncNotice -Kind 'landing' -Path 'storages/workspace.json' -Reason '工作区登记表不是合法 JSON。'
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
if ($o) {
|
|
1620
|
+
# 1) global.workspaceIds 非空
|
|
1621
|
+
if ($o.global -and $o.global.workspaceIds) { $ids = @($o.global.workspaceIds | Where-Object { $_ }) }
|
|
1622
|
+
if ($ids.Count -eq 0) {
|
|
1623
|
+
$issues += 'workspaceIds-empty'
|
|
1624
|
+
Add-SyncNotice -Kind 'landing' -Path 'global.workspaceIds' -Reason '工作区登记表 global.workspaceIds 为空,DSH 工作台会显示空列表。'
|
|
1625
|
+
}
|
|
1626
|
+
# 2) defaultWorkspaceId 不悬空(悬空会让 DSH 校验整张表失败)
|
|
1627
|
+
if ($o.global) { $def = [string]$o.global.defaultWorkspaceId }
|
|
1628
|
+
$hasDef = $false
|
|
1629
|
+
if ($def -and $o.tables -and $o.tables.workspaces) {
|
|
1630
|
+
$hasDef = ($null -ne $o.tables.workspaces.PSObject.Properties[$def])
|
|
1631
|
+
}
|
|
1632
|
+
if (-not $hasDef) {
|
|
1633
|
+
$issues += 'defaultWorkspaceId-dangling'
|
|
1634
|
+
Add-SyncNotice -Kind 'landing' -Path 'global.defaultWorkspaceId' -Reason '默认工作区 ID 悬空,DSH 校验整张登记表失败。'
|
|
1635
|
+
}
|
|
1636
|
+
# 3) 无 duplicate path:DSH 启动校验 duplicate paths,同路径两条会整表判坏 → 列表全空
|
|
1637
|
+
$seen = @{}
|
|
1638
|
+
$dup = @()
|
|
1639
|
+
if ($o.tables -and $o.tables.workspaces) {
|
|
1640
|
+
foreach ($p in $o.tables.workspaces.PSObject.Properties) {
|
|
1641
|
+
$np = ([string]$p.Value.path).Replace('/', '\').TrimEnd('\').ToLowerInvariant()
|
|
1642
|
+
if (-not $np) { continue }
|
|
1643
|
+
if ($seen.ContainsKey($np)) { $dup += $np } else { $seen[$np] = $true }
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
if ($dup.Count -gt 0) {
|
|
1647
|
+
$issues += 'duplicate-path'
|
|
1648
|
+
Add-SyncNotice -Kind 'landing' -Path 'tables.workspaces' -Reason ("登记表里有 " + $dup.Count + " 条重复路径,DSH 会整表判坏。")
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
# 4) 会话目录:仓库有、本机 0 个 → 上层读不出会话
|
|
1652
|
+
$repoSess = Join-Path $RepoRoot 'conversations\sessions'
|
|
1653
|
+
$localSess = Join-Path $DshHome 'sessions'
|
|
1654
|
+
$repoDirs = if (Test-Path -LiteralPath $repoSess) { @(Get-ChildItem -LiteralPath $repoSess -Directory -Force).Count } else { 0 }
|
|
1655
|
+
$localDirs = if (Test-Path -LiteralPath $localSess) { @(Get-ChildItem -LiteralPath $localSess -Directory -Force).Count } else { 0 }
|
|
1656
|
+
if ($repoDirs -gt 0 -and $localDirs -eq 0) {
|
|
1657
|
+
$issues += 'session-dirs-0'
|
|
1658
|
+
Add-SyncNotice -Kind 'landing' -Path 'sessions' -Reason ("仓库有 " + $repoDirs + " 个会话目录,本机 sessions 为 0 个。")
|
|
1659
|
+
}
|
|
1660
|
+
# 5) projcache 占位符残留:apply 故意不同步 projcache(让 DSH 从 session log 重建),
|
|
1661
|
+
# 但本机若留着带占位符的旧缓存,投影同样取不到数据 —— 只提示、不阻断。
|
|
1662
|
+
$pc = Join-Path $DshHome 'storages\session_projcache\sessions'
|
|
1663
|
+
if (Test-Path -LiteralPath $pc) {
|
|
1664
|
+
$bad = 0
|
|
1665
|
+
foreach ($f in @(Get-ChildItem -LiteralPath $pc -Recurse -File -Filter '*.json' -ErrorAction SilentlyContinue)) {
|
|
1666
|
+
$raw = Get-Content -LiteralPath $f.FullName -Raw
|
|
1667
|
+
if ($raw -match '\{\{(APP_ROOT|WORKSPACE_HOME|DSH_HOME)\}\}') { $bad++ }
|
|
1668
|
+
}
|
|
1669
|
+
if ($bad -gt 0) {
|
|
1670
|
+
$issues += 'projcache-token'
|
|
1671
|
+
Add-SyncNotice -Kind 'landing' -Path 'storages/session_projcache/sessions' -Reason ($bad + " 个会话投影缓存仍含占位符,DSH 启动时会重建。")
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
# 6) bundle / link:复用刚才自检段算出的 $unresolved
|
|
1675
|
+
foreach ($ub in @($unresolved)) {
|
|
1676
|
+
Add-SyncNotice -Kind 'landing' -Path $ub -Reason 'bundle 本机不可解析,工作区/会话已落地但相关功能不可用。'
|
|
1677
|
+
}
|
|
1678
|
+
# 7) 本机 profile 若仍用 link: 指向 AppRoot 下的本地源码目录,那目录必须存在
|
|
1679
|
+
$localProfilePkg = Join-Path $ProfileDir 'package.json'
|
|
1680
|
+
if (Test-Path -LiteralPath $localProfilePkg) {
|
|
1681
|
+
try {
|
|
1682
|
+
$lp = Get-Content -LiteralPath $localProfilePkg -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
1683
|
+
foreach ($d in @('dsh-purge-1.4.0', 'dsh-our-free-model-2.8.0')) {
|
|
1684
|
+
$dn = $d -replace '-\d+\.\d+\.\d+$', ''
|
|
1685
|
+
$dep = $lp.dependencies.$dn
|
|
1686
|
+
if ($dep -and ([string]$dep -like 'link:*') -and -not (Test-Path -LiteralPath (Join-Path $AppRoot $d))) {
|
|
1687
|
+
$issues += "link:$d"
|
|
1688
|
+
Add-SyncNotice -Kind 'landing' -Path $d -Reason ("本机 profile 用 link: 依赖 " + $dn + ",但 AppRoot 下缺少 " + $d + " 目录。")
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
} catch { }
|
|
1692
|
+
}
|
|
1693
|
+
$out = [ordered]@{
|
|
1694
|
+
at = (Get-Date).ToString('o')
|
|
1695
|
+
ok = ($issues.Count -eq 0)
|
|
1696
|
+
workspaceIds = $ids.Count
|
|
1697
|
+
defaultWorkspaceId = $def
|
|
1698
|
+
sessionDirs = $localDirs
|
|
1699
|
+
issues = @($issues)
|
|
1700
|
+
}
|
|
1701
|
+
try {
|
|
1702
|
+
[IO.File]::WriteAllText((Join-Path $DshHome 'pull-landing-check.json'), ($out | ConvertTo-Json -Depth 6), (New-Object Text.UTF8Encoding($false)))
|
|
1703
|
+
} catch { Warn ('写 pull-landing-check.json 失败:' + $_.Exception.Message) }
|
|
1704
|
+
if ($issues.Count -gt 0) { Warn ("落地后验证未通过:" + ($issues -join '、') + "(详见 " + $DshHome + "\pull-landing-check.json)") }
|
|
1705
|
+
else { Ok '落地后验证通过:工作区/会话/登记表齐备,DSH 可读取' }
|
|
1706
|
+
return $issues
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1599
1709
|
# ---------- 10. 自检 ----------
|
|
1600
1710
|
Say ""
|
|
1601
1711
|
Say "== 自检 =="
|
|
@@ -1641,12 +1751,18 @@ if ($unresolved.Count -eq 0) {
|
|
|
1641
1751
|
Add-SyncNotice -Kind 'plugin-missing' -Path $ub -Reason ('bundle 在本机解析不到:插件没装好(pnpm install 没成功,或仓库里没有这个插件的归档)。装好后重新拉取一次;若它是宿主绑定的实验性 bundle,删掉本机 profile\package.json 里那一行。')
|
|
1642
1752
|
}
|
|
1643
1753
|
if (-not $ForceBundles) {
|
|
1644
|
-
Die
|
|
1645
|
-
|
|
1646
|
-
|
|
1754
|
+
# 0.4.17:bundle 未全解析不再 Die —— 工作区/会话此刻已经落地,为缺一个 bundle 就让
|
|
1755
|
+
# 脚本非零退出,会让 post-exit.ps1 把已落地的数据整段回滚,用户看到的就是"拉完还是空的"。
|
|
1756
|
+
# 改为记 notice + 继续;-ForceBundles 保留为严格模式(当前语义)。
|
|
1757
|
+
Warn "bundle 未全解析,但工作区/会话已落地:不阻断(0.4.17);已记入 sync-notices.json,装好插件后重新拉取。"
|
|
1758
|
+
foreach ($ub in $unresolved) {
|
|
1759
|
+
Add-SyncNotice -Kind 'landing' -Path $ub -Reason 'bundle 在本机解析不到:工作区/会话已落地,装好后重新拉取即可。'
|
|
1760
|
+
}
|
|
1761
|
+
} else {
|
|
1762
|
+
Warn "已加 -ForceBundles(严格检查仍不阻断落地)"
|
|
1647
1763
|
}
|
|
1648
|
-
Warn "已加 -ForceBundles,跳过该检查(启动仍可能崩溃)"
|
|
1649
1764
|
}
|
|
1765
|
+
$null = Test-PullLanding
|
|
1650
1766
|
Ok "Skill 目录:$((Get-ChildItem -LiteralPath $skillsDst -Directory -Force -ErrorAction SilentlyContinue | Measure-Object).Count) 个"
|
|
1651
1767
|
Say ""
|
|
1652
1768
|
Say "下一步:完全启动 DSH(不是重启窗口,要确认进程全部退出后再开)。"
|
|
@@ -714,7 +714,7 @@ function Get-PluginDataFiles([string]$slotDir, $cfg, [string]$baseDir = '') {
|
|
|
714
714
|
# profile 里的 package.json / cordis.patch.yml 是 apply 的前置条件 —— 仓库缺它们,apply.ps1 直接 Die;
|
|
715
715
|
# 同一组的 host-contract.json 用于实验 bundle 门控;版本差异不再阻断,只提示,不会因此拒绝铺配置。
|
|
716
716
|
# 所以这里(以及面板)都把 profile 钉死为开启,手改 JSON 关掉也按开启处理。
|
|
717
|
-
$SyncRequiredGroups = @('profile')
|
|
717
|
+
$SyncRequiredGroups = @('profile', 'workspace', 'conversations')
|
|
718
718
|
|
|
719
719
|
function Test-SyncRequiredGroup([string]$Group) { return ($SyncRequiredGroups -contains $Group) }
|
|
720
720
|
|
package/runtime/sync.ps1
CHANGED
|
@@ -69,6 +69,83 @@ Say ""
|
|
|
69
69
|
Say "== DSH 配置同步 / $Action =="
|
|
70
70
|
Say "仓库:$RepoRoot"
|
|
71
71
|
|
|
72
|
+
function Test-PullPreflight {
|
|
73
|
+
# 0.4.17 拉取前置检查:把"拉完了却落不了地"的前置条件在进入 apply 之前查一遍。
|
|
74
|
+
# 不替用户装插件、不猜根路径,只把会造成空工作区/空会话的条件摆出来并写 notice,
|
|
75
|
+
# 避免"拉完但是空的"这种最难排查的状态。
|
|
76
|
+
$fail = @()
|
|
77
|
+
$scopeNow = Get-SyncScope $DshHome
|
|
78
|
+
# 1) 必需组:ps1 侧 Test-SyncGroupEnabled 已恒 true,这里显式再核对,兼顾老 scope 文件
|
|
79
|
+
foreach ($g in @('workspace', 'conversations')) {
|
|
80
|
+
if (-not (Test-SyncGroupEnabled $scopeNow $g)) {
|
|
81
|
+
Add-SyncNotice -Kind 'landing' -Path ("scope/" + $g) -Reason ("「" + $g + "」同步组未勾选,拉取无法落地工作区/会话。")
|
|
82
|
+
$fail += ($g + ' 未勾选')
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if ($SkipWorkspace) {
|
|
86
|
+
Add-SyncNotice -Kind 'landing' -Path 'switch/SkipWorkspace' -Reason '本次带了 -SkipWorkspace,会整段跳过工作区与会话。'
|
|
87
|
+
$fail += '-SkipWorkspace'
|
|
88
|
+
}
|
|
89
|
+
# 2) 根路径:
|
|
90
|
+
# appRoot —— DSH 安装目录,开头 Resolve-DshAppRoot 已确认,这里再挡一道(必须存在)。
|
|
91
|
+
# workspaceHome —— 工作区资料根,全新机器第一次拉取时还不存在是正常的:apply 铺资料时会
|
|
92
|
+
# 自动建目录。所以"目录不存在"不拦,只有"根本没确认出路径值"才给提示,
|
|
93
|
+
# 而且也不拦拉取(否则 B 机永远卡在第一次拉取,工作区一个都落不了地)。
|
|
94
|
+
$roots = Get-SyncRoots $DshHome $AppRoot $WorkspaceHome
|
|
95
|
+
$rvApp = [string]$roots.appRoot
|
|
96
|
+
if (-not $rvApp -or -not (Test-Path -LiteralPath $rvApp)) {
|
|
97
|
+
Add-SyncNotice -Kind 'landing' -Path 'roots/appRoot' -Reason ("本机 appRoot 未确认或目录不存在:" + $rvApp + "。")
|
|
98
|
+
$fail += 'appRoot 未确认'
|
|
99
|
+
}
|
|
100
|
+
$rvWs = [string]$roots.workspaceHome
|
|
101
|
+
if (-not $rvWs) {
|
|
102
|
+
# 没有工作区根值时给个可自动落地默认值,并写回 roots 供后续 capture 归一使用
|
|
103
|
+
$rvWs = Join-Path $env:USERPROFILE 'Documents\deepseek-harness'
|
|
104
|
+
$roots.workspaceHome = $rvWs
|
|
105
|
+
Save-SyncRoots $DshHome $roots
|
|
106
|
+
Warn ("workspaceHome 未确认,已用默认值:$rvWs(目录会在拉取落地时自动建)")
|
|
107
|
+
}
|
|
108
|
+
if (-not (Test-Path -LiteralPath $rvWs)) {
|
|
109
|
+
# 目录尚不存在:直接补建,不当成失败条件
|
|
110
|
+
try { New-Item -ItemType Directory -Path $rvWs -Force | Out-Null; Ok "已补建 workspaceHome 目录:$rvWs" }
|
|
111
|
+
catch { Warn "补建 workspaceHome 失败(不拦拉取):$rvWs — $($_.Exception.Message)" }
|
|
112
|
+
}
|
|
113
|
+
if (@($roots.confirmed).Count -eq 0) {
|
|
114
|
+
Add-SyncNotice -Kind 'landing' -Path 'config-sync-roots.json' -Reason 'confirmed 为空,请在面板确认本机路径。'
|
|
115
|
+
}
|
|
116
|
+
# 3) link 型插件:本地 AppRoot 下缺目录、仓库也无归档 → pnpm install 必失败 → bundle 解析不到
|
|
117
|
+
$pkg = Join-Path $RepoRoot 'profile\package.json'
|
|
118
|
+
if (Test-Path -LiteralPath $pkg) {
|
|
119
|
+
try {
|
|
120
|
+
$deps = (Get-Content -LiteralPath $pkg -Raw -Encoding utf8 | ConvertFrom-Json).dependencies
|
|
121
|
+
foreach ($nm in $deps.PSObject.Properties.Name) {
|
|
122
|
+
$v = [string]$deps.$nm
|
|
123
|
+
if ($v -like 'link:*' -and $nm -ne 'dsh-config-sync-plugin') {
|
|
124
|
+
$leaf = [IO.Path]::GetFileName(($v -replace '^link:', ''))
|
|
125
|
+
if ($leaf -and -not (Test-Path -LiteralPath (Join-Path ([string]$roots.appRoot) $leaf))) {
|
|
126
|
+
# apply.ps1 的 local-plugins 解压同时认 .tgz 与 .zip(见 apply.ps1:1371-1445),
|
|
127
|
+
# 前置检查必须一致:两种归档任一存在就算齐备。旧版只查 .tgz,把仓库里实际存在的
|
|
128
|
+
# dsh-our-free-model-2.8.0.zip / dsh-purge-1.4.0.zip 误报成缺失,直接拦死拉取。
|
|
129
|
+
$archTgz = Join-Path $RepoRoot ("local-plugins\" + $leaf + ".tgz")
|
|
130
|
+
$archZip = Join-Path $RepoRoot ("local-plugins\" + $leaf + ".zip")
|
|
131
|
+
$hasArch = (Test-Path -LiteralPath $archTgz) -or (Test-Path -LiteralPath $archZip)
|
|
132
|
+
if (-not $hasArch) {
|
|
133
|
+
Add-SyncNotice -Kind 'landing' -Path $nm -Reason ("link 目标 " + $leaf + " 不在 AppRoot 下、仓库也无 .tgz/.zip 归档,pnpm install 会失败。")
|
|
134
|
+
$fail += ("link:" + $leaf + " 缺失")
|
|
135
|
+
} else {
|
|
136
|
+
Ok ("link 目标 " + $leaf + " 本地目录缺失,但仓库有归档,apply 会解压部署")
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
} catch { }
|
|
142
|
+
}
|
|
143
|
+
if ($fail.Count -gt 0) {
|
|
144
|
+
Die ("拉取前置检查未通过:" + ($fail -join '、') + ";详见 " + $DshHome + "\sync-notices.json。修正后重新拉取。")
|
|
145
|
+
}
|
|
146
|
+
Ok '拉取前置检查通过:scope/root/link 齐备'
|
|
147
|
+
}
|
|
148
|
+
|
|
72
149
|
function Get-RepoState {
|
|
73
150
|
$branch = (& $git -C $RepoRoot rev-parse --abbrev-ref HEAD 2>$null)
|
|
74
151
|
$head = (& $git -C $RepoRoot log -1 --oneline 2>$null)
|
|
@@ -975,6 +1052,7 @@ if ($Action -eq 'push') {
|
|
|
975
1052
|
|
|
976
1053
|
# ---------- pull ----------
|
|
977
1054
|
Initialize-RepoIfNeeded
|
|
1055
|
+
Test-PullPreflight
|
|
978
1056
|
if ((Test-DshRunning) -and (-not $Force)) {
|
|
979
1057
|
Die "DeepSeek Harness 仍在运行。请完全退出(含托盘)后重跑,或加 -Force 强制继续。"
|
|
980
1058
|
}
|
package/tools/selftest.mjs
CHANGED
|
@@ -558,8 +558,8 @@ const profileGroup = (reqAfter.groups || []).find((g) => g.id === 'profile') ||
|
|
|
558
558
|
check('回读里 profile 仍是勾选、并标了 required',
|
|
559
559
|
profileGroup.enabled === true && profileGroup.required === true,
|
|
560
560
|
`enabled=${profileGroup.enabled} required=${profileGroup.required}`)
|
|
561
|
-
check('
|
|
562
|
-
(reqAfter.groups || []).
|
|
561
|
+
check('必需组含 profile/workspace/conversations 三项(拉取会落地工作区/会话)',
|
|
562
|
+
['profile', 'workspace', 'conversations'].every((id) => (reqAfter.groups || []).some((g) => g.id === id && g.required === true)))
|
|
563
563
|
if (prevScope === null) { try { unlinkSync(scopeFile) } catch { } } else writeFileSync(scopeFile, prevScope, 'utf8')
|
|
564
564
|
// D:\dsh-config,所以这里退一步做静态断言——宿主源码里确实有这道守卫,且提示指向面板。
|
|
565
565
|
{
|
|
@@ -2066,5 +2066,58 @@ console.log('== 0.4.10:拉取不再因本机/契约版本不一致而阻断 ==
|
|
|
2066
2066
|
!/版本不一致(本机 \$\{version\.local\}/.test(cliSrc)
|
|
2067
2067
|
&& cliSrc.includes("metric(M('本机 / 契约', 'App / contract'), versionText, 'ok')"), 'client.js 去告警')
|
|
2068
2068
|
}
|
|
2069
|
+
console.log('')
|
|
2070
|
+
console.log('== 0.4.17:拉取落地加固(前置检查 + 自愈 + 落地验证)==')
|
|
2071
|
+
{
|
|
2072
|
+
const syncS = readFileSync(join(pluginRootSelf, 'runtime', 'sync.ps1'), 'utf8')
|
|
2073
|
+
const comS = readFileSync(join(pluginRootSelf, 'runtime', 'dsh-sync-common.ps1'), 'utf8')
|
|
2074
|
+
const appS = readFileSync(join(pluginRootSelf, 'runtime', 'apply.ps1'), 'utf8')
|
|
2075
|
+
const idxS = readFileSync(join(pluginRootSelf, 'index.js'), 'utf8')
|
|
2076
|
+
const cliS = readFileSync(join(pluginRootSelf, 'client.js'), 'utf8')
|
|
2077
|
+
|
|
2078
|
+
// 必需组扩到三项(ps1 / 宿主 / 面板三处联动)
|
|
2079
|
+
check('必需组含 profile/workspace/conversations(ps1 侧)',
|
|
2080
|
+
/\$SyncRequiredGroups\s*=\s*@\('profile'\s*,\s*'workspace'\s*,\s*'conversations'\)/.test(comS), 'dsh-sync-common.ps1')
|
|
2081
|
+
check('必需组含三项(宿主侧 SCOPE_REQUIRED_GROUPS)',
|
|
2082
|
+
/const SCOPE_REQUIRED_GROUPS\s*=\s*\['profile'\s*,\s*'workspace'\s*,\s*'conversations'\]/.test(idxS), 'index.js')
|
|
2083
|
+
check('工作区/会话组在面板标 required(不可取消)',
|
|
2084
|
+
(idxS.match(/required: true/g) || []).length >= 3 && cliS.includes('g.required === true'), 'index.js/client.js')
|
|
2085
|
+
|
|
2086
|
+
// 前置检查:sync.ps1 在 Initialize-RepoIfNeeded 之后、apply 之前调用
|
|
2087
|
+
check('sync.ps1 pull 调 Test-PullPreflight(repo 初始化后、apply 前)',
|
|
2088
|
+
appS !== '' && syncS.includes('function Test-PullPreflight')
|
|
2089
|
+
&& syncS.lastIndexOf('Test-PullPreflight') > syncS.indexOf('Initialize-RepoIfNeeded')
|
|
2090
|
+
&& syncS.lastIndexOf('Test-PullPreflight') < syncS.lastIndexOf("& (Join-Path $PSScriptRoot 'apply.ps1')"), 'sync.ps1')
|
|
2091
|
+
check('前置检查覆盖 scope/root/link 三类',
|
|
2092
|
+
syncS.includes("Test-SyncGroupEnabled $scopeNow $g") && syncS.includes("@('workspace', 'conversations')")
|
|
2093
|
+
&& syncS.includes('Get-SyncRoots') && syncS.includes("link:*"), 'sync.ps1')
|
|
2094
|
+
// 0.4.18:link 归档必须同时认 .tgz/.zip;workspaceHome 目录不存在时补建而非拦死
|
|
2095
|
+
check('前置检查 link 归档同时认 .tgz/.zip(不误报仓库里存在的 .zip)',
|
|
2096
|
+
syncS.includes('$archTgz') && syncS.includes('$archZip') && syncS.includes('$hasArch'), 'sync.ps1')
|
|
2097
|
+
check('前置检查 workspaceHome 缺目录时自动补建而非失败',
|
|
2098
|
+
syncS.includes("已补建 workspaceHome") && syncS.includes("Documents\\deepseek-harness"), 'sync.ps1')
|
|
2099
|
+
|
|
2100
|
+
// bundle 不再 Die/回滚
|
|
2101
|
+
check('bundle 未解析不再 Die(记 notice + 继续落地)',
|
|
2102
|
+
appS.includes('bundle 未全解析,但工作区/会话已落地')
|
|
2103
|
+
&& !/bundle 清单[\s\S]{0,400}已停止,先别启动/.test(appS), 'apply.ps1')
|
|
2104
|
+
|
|
2105
|
+
// 落地验证函数存在且被调用,覆盖 DSH 登记表判据
|
|
2106
|
+
check('apply.ps1 有 Test-PullLanding 且被调用',
|
|
2107
|
+
appS.includes('function Test-PullLanding') && appS.includes('$null = Test-PullLanding'), 'apply.ps1')
|
|
2108
|
+
check('落地验证覆盖 workspaceIds/defaultWorkspaceId/duplicate/session 目录',
|
|
2109
|
+
appS.includes('workspaceIds-empty') && appS.includes('defaultWorkspaceId-dangling')
|
|
2110
|
+
&& appS.includes('duplicate-path') && appS.includes('session-dirs-0'), 'apply.ps1')
|
|
2111
|
+
check('落地验证覆盖 projcache/bundle/link 且写 pull-landing-check.json',
|
|
2112
|
+
appS.includes('projcache-token') && appS.includes('pull-landing-check.json')
|
|
2113
|
+
&& appS.includes('link:$d'), 'apply.ps1')
|
|
2114
|
+
|
|
2115
|
+
// notice 白名单与面板文案同步
|
|
2116
|
+
check('index.js notice KINDS 含 landing',
|
|
2117
|
+
/KINDS = \[[^\]]*'landing'/.test(idxS), 'index.js')
|
|
2118
|
+
check('client.js notice 文案含 landing 标签',
|
|
2119
|
+
cliS.includes("landing: M('落地检查', 'Landing check')"), 'client.js')
|
|
2120
|
+
}
|
|
2121
|
+
|
|
2069
2122
|
process.exit(failures === 0 ? 0 : 1)
|
|
2070
2123
|
|