dsh-config-sync-plugin 0.4.16 → 0.4.17

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,6 +257,15 @@ 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
+ ### Pull landing hardening: usable right after pull on a second machine (0.4.17)
261
+
262
+ Fixes "workspace and conversations both empty after pulling sync on another machine":
263
+
264
+ - **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.
265
+ - **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.
266
+ - **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.
267
+ - **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`.
268
+ - **Required groups**: workspace files and conversations join profile as required sync groups and cannot be unchecked in the panel.
260
269
  ### Fix cross-machine pull bundle resolution failure (0.4.16)
261
270
 
262
271
  This release fixes `cannot resolve profile bundle "dsh-config-sync-plugin"` on the target machine after pulling config:
package/README.md CHANGED
@@ -277,6 +277,15 @@ 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.17)
281
+
282
+ 本版修复「另一台机器拉取同步后,左侧工作区与会话同时为空」的问题:
283
+
284
+ - **根因**:工作区/会话组可被误取消勾选;本机根路径未确认、`link:` 插件本地目录缺失、bundle 未解析都可能让 apply 中途退出或让 DSH 读到空表;bundle 未解析时脚本非零退出还会触发 post-exit 回滚,把已经落地的工作区/会话一起擦掉。
285
+ - **前置检查**:拉取在进入 apply 前检查工作区/会话同步组、`-SkipWorkspace`、本机 appRoot/workspaceHome 与 `link:` 插件目标,缺项直接给出明确诊断(写入 sync-notices.json),不再「拉完是空的」。
286
+ - **不回滚**:bundle 未解析从「Die 停止」改为记 notice 并继续落地,避免把已同步的工作区/会话回滚掉;需要严格检查仍可用 `-ForceBundles`。
287
+ - **落地验证**:apply 结束后核对 `workspaceIds` 非空、默认工作区 ID 不悬空、无重复路径、会话目录已铺回、projcache 无占位符残留、`link:` 插件齐备,结果写 `pull-landing-check.json` 并在面板可查。
288
+ - **必需组**:工作区资料、会话记录与 profile 一起列为必需同步组,面板不可误取消,从源头堵住「勾选漏了导致空列表」。
280
289
  ### 修复跨机器拉取后 bundle 解析失败(0.4.16)
281
290
 
282
291
  本版修复目标机器拉取配置后 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-config-sync-plugin",
3
- "version": "0.4.16",
3
+ "version": "0.4.17",
4
4
  "type": "module",
5
5
  "description": "在 DSH 设置里查看 dsh-config 仓库与本机的同步状态,并生成退出后执行的 push/pull 脚本。同步动作本身不在应用内执行。面板与文案跟随客户端语言(中文/English)。",
6
6
  "main": "./index.js",
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 ("已停止,先别启动。处理:①若上面「缺少插件」不为空,说明 pnpm install 没成功;" +
1645
- "②若是宿主绑定的实验性 bundle,直接删掉本机 profile\package.json 里那一行;" +
1646
- "③确认无误后可加 -ForceBundles 跳过本检查(启动仍有崩溃风险)。")
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,61 @@ 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) 根路径:appRoot / workspaceHome 必须存在
90
+ $roots = Get-SyncRoots $DshHome $AppRoot $WorkspaceHome
91
+ foreach ($k in @('appRoot', 'workspaceHome')) {
92
+ $rv = [string]$roots.$k
93
+ if (-not $rv -or -not (Test-Path -LiteralPath $rv)) {
94
+ Add-SyncNotice -Kind 'landing' -Path ("roots/" + $k) -Reason ("本机根 " + $k + " 未确认或目录不存在:" + $rv + "。")
95
+ $fail += ($k + ' 未确认')
96
+ }
97
+ }
98
+ if (@($roots.confirmed).Count -eq 0) {
99
+ Add-SyncNotice -Kind 'landing' -Path 'config-sync-roots.json' -Reason 'confirmed 为空,请在面板确认本机路径。'
100
+ }
101
+ # 3) link 型插件:本地 AppRoot 下缺目录、仓库也无归档 → pnpm install 必失败 → bundle 解析不到
102
+ $pkg = Join-Path $RepoRoot 'profile\package.json'
103
+ if (Test-Path -LiteralPath $pkg) {
104
+ try {
105
+ $deps = (Get-Content -LiteralPath $pkg -Raw -Encoding utf8 | ConvertFrom-Json).dependencies
106
+ foreach ($nm in $deps.PSObject.Properties.Name) {
107
+ $v = [string]$deps.$nm
108
+ if ($v -like 'link:*' -and $nm -ne 'dsh-config-sync-plugin') {
109
+ $leaf = [IO.Path]::GetFileName(($v -replace '^link:', ''))
110
+ if ($leaf -and -not (Test-Path -LiteralPath (Join-Path ([string]$roots.appRoot) $leaf))) {
111
+ $arch = Join-Path $RepoRoot ("local-plugins\" + $leaf + ".tgz")
112
+ if (-not (Test-Path -LiteralPath $arch)) {
113
+ Add-SyncNotice -Kind 'landing' -Path $nm -Reason ("link 目标 " + $leaf + " 不在 AppRoot 下、仓库也无归档,pnpm install 会失败。")
114
+ $fail += ("link:" + $leaf + " 缺失")
115
+ }
116
+ }
117
+ }
118
+ }
119
+ } catch { }
120
+ }
121
+ if ($fail.Count -gt 0) {
122
+ Die ("拉取前置检查未通过:" + ($fail -join '、') + ";详见 " + $DshHome + "\sync-notices.json。修正后重新拉取。")
123
+ }
124
+ Ok '拉取前置检查通过:scope/root/link 齐备'
125
+ }
126
+
72
127
  function Get-RepoState {
73
128
  $branch = (& $git -C $RepoRoot rev-parse --abbrev-ref HEAD 2>$null)
74
129
  $head = (& $git -C $RepoRoot log -1 --oneline 2>$null)
@@ -975,6 +1030,7 @@ if ($Action -eq 'push') {
975
1030
 
976
1031
  # ---------- pull ----------
977
1032
  Initialize-RepoIfNeeded
1033
+ Test-PullPreflight
978
1034
  if ((Test-DshRunning) -and (-not $Force)) {
979
1035
  Die "DeepSeek Harness 仍在运行。请完全退出(含托盘)后重跑,或加 -Force 强制继续。"
980
1036
  }
@@ -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('其余组没有 required 标记(只有真正会报错的那组被钉死)',
562
- (reqAfter.groups || []).filter((g) => g.id !== 'profile').every((g) => g.required !== true))
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,53 @@ 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
+
2095
+ // bundle 不再 Die/回滚
2096
+ check('bundle 未解析不再 Die(记 notice + 继续落地)',
2097
+ appS.includes('bundle 未全解析,但工作区/会话已落地')
2098
+ && !/bundle 清单[\s\S]{0,400}已停止,先别启动/.test(appS), 'apply.ps1')
2099
+
2100
+ // 落地验证函数存在且被调用,覆盖 DSH 登记表判据
2101
+ check('apply.ps1 有 Test-PullLanding 且被调用',
2102
+ appS.includes('function Test-PullLanding') && appS.includes('$null = Test-PullLanding'), 'apply.ps1')
2103
+ check('落地验证覆盖 workspaceIds/defaultWorkspaceId/duplicate/session 目录',
2104
+ appS.includes('workspaceIds-empty') && appS.includes('defaultWorkspaceId-dangling')
2105
+ && appS.includes('duplicate-path') && appS.includes('session-dirs-0'), 'apply.ps1')
2106
+ check('落地验证覆盖 projcache/bundle/link 且写 pull-landing-check.json',
2107
+ appS.includes('projcache-token') && appS.includes('pull-landing-check.json')
2108
+ && appS.includes('link:$d'), 'apply.ps1')
2109
+
2110
+ // notice 白名单与面板文案同步
2111
+ check('index.js notice KINDS 含 landing',
2112
+ /KINDS = \[[^\]]*'landing'/.test(idxS), 'index.js')
2113
+ check('client.js notice 文案含 landing 标签',
2114
+ cliS.includes("landing: M('落地检查', 'Landing check')"), 'client.js')
2115
+ }
2116
+
2069
2117
  process.exit(failures === 0 ? 0 : 1)
2070
2118