dsh-config-sync-plugin 0.4.10 → 0.4.11
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 -0
- package/README.md +12 -0
- package/client.js +48 -42
- package/index.js +47 -29
- package/package.json +1 -1
- package/runtime/apply.ps1 +3 -1
- package/runtime/capture.ps1 +1 -1
- package/runtime/dsh-sync-common.ps1 +1 -1
- package/runtime/restore.ps1 +11 -13
- package/runtime/sync.ps1 +3 -1
- package/tools/clientcheck.mjs +3 -2
- package/tools/pack-plugin.ps1 +11 -3
- package/tools/selftest.mjs +14 -9
- package/README.en.md.bak-0410 +0 -830
- package/README.md.bak-0410 +0 -822
- package/runtime/apply.ps1.bak-0410 +0 -1646
- package/runtime/sync.ps1.bak-0410 +0 -1117
- package/tools/selftest.mjs.bak-0410 +0 -2045
package/README.en.md
CHANGED
|
@@ -257,6 +257,18 @@ 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
|
+
### Code cleanup and consistency fixes: equivalent refactor, no feature change (0.4.11)
|
|
261
|
+
|
|
262
|
+
This release is an equivalent refactor. The normal sync path is identical to 0.4.10 and no user-visible feature changes:
|
|
263
|
+
|
|
264
|
+
- **Gate criteria consolidated**: `pushAllowed` / `pullAllowed` are now unified into `canPush()` / `canPull()`, word-for-word equivalent to the original criteria; the fast criteria on the close path are unchanged and introduce no new allow conditions.
|
|
265
|
+
- **One fewer remote request**: the periodic re-check already ran `git fetch` and has the drift, so it reuses it via `driftOverride` instead of fetching again.
|
|
266
|
+
- **Idempotent force-kill**: multiple force-kill triggers within 1.5 seconds execute only once, so the close hook / periodic pre-queue / frontend beacon do not kill the same process family repeatedly.
|
|
267
|
+
- **Single source of truth**: the plugin root and version are consolidated to a single `PLUGIN_DIR` / `PLUGIN_VERSION` definition; dead code (`lsRemoteHeads`, unused imports, unused state) was removed.
|
|
268
|
+
- **Consistency fixes**: `market-index.json` `publishTimestamp` normalized to milliseconds; leading-zero versions gain an `npmVersion` field; packaging excludes `_stage-*` / `_refactor-*` / `*.bak*` temp artifacts; the restore flow's AppRoot detection and experimental-bundle (`app.asar`) recognition are aligned with the main path; the language header is computed at request time (POST follows a language switch too); `callUpdate` now checks failures.
|
|
269
|
+
|
|
270
|
+
Self-test: the four `node --check` targets, `selftest.mjs` and `clientcheck.mjs` match the 0.4.10 baseline item by item (the 8 prepare failures in this environment are pre-existing baseline failures with no `origin` configured, not introduced by this release).
|
|
271
|
+
|
|
260
272
|
### Pending push but nothing happens on × close: backend periodic pre-queue (0.4.05)
|
|
261
273
|
|
|
262
274
|
End-to-end diagnosis (manual POST to `/config-sync/auto-exit`) proved the backend check and route are fine — it instantly returns `queued:true`, queues the watcher, force-exits DSH and completes the push. Root cause is the frontend: `pagehide → navigator.sendBeacon('/config-sync/auto-exit')` never reaches the backend when DSH really exits (no beacon arrival in launch.log during × close), yet 0.3.96+ relied solely on it — code-level selftests passed but real UI never verified it.
|
package/README.md
CHANGED
|
@@ -277,6 +277,18 @@ 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.11)
|
|
281
|
+
|
|
282
|
+
本版是一次等价重构,正常同步路径与 0.4.10 完全一致,不改变任何用户可见功能:
|
|
283
|
+
|
|
284
|
+
- **门禁判据收敛**:`pushAllowed` / `pullAllowed` 抽成 `canPush()` / `canPull()` 统一函数,判据与原来逐字等价;退出关闭路径的 fast 判据保持原样,不引入新的放行条件。
|
|
285
|
+
- **少一次远端请求**:定时复查已经 `git fetch` 得到 drift,直接复用并传给 `checkAndQueueAutoSync`(`driftOverride`),不再重复 fetch。
|
|
286
|
+
- **强杀幂等**:1.5 秒内多次触发强杀只执行一次,避免窗口关闭钩子 / 定时预排 / 前端信标三路重复杀同一进程族。
|
|
287
|
+
- **单一定义**:插件根目录与版本收敛到 `PLUGIN_DIR` / `PLUGIN_VERSION` 单一来源;删除从未调用的 `lsRemoteHeads`、死导入与未使用的 state 等死代码。
|
|
288
|
+
- **一致性修复**:`market-index.json` 的 `publishTimestamp` 统一为毫秒;前导零版本补 `npmVersion` 字段;打包排除 `_stage-*` / `_refactor-*` / `*.bak*` 等临时产物;还原流程的 AppRoot 探测与实验 bundle(`app.asar`)识别对齐主链路;语言头改为请求时计算(切换语言后 POST 也跟随);`callUpdate` 补失败判断。
|
|
289
|
+
|
|
290
|
+
自测:`node --check` 四项、`selftest.mjs`、`clientcheck.mjs` 与 0.4.10 基线逐项一致(本环境 8 项 prepare 失败为无 origin 的既有基线失败,非本版引入)。
|
|
291
|
+
|
|
280
292
|
### 点 × 立即执行待推送/待拉取:后端窗口监视(0.4.06)
|
|
281
293
|
|
|
282
294
|
0.4.05 把「点 × 后没执行」的根因定位到前端信标送不到后端,用 2 分钟定时复查预排 watcher 绕开。但预排有窗口期:用户在两次复查之间点 ×,那一刻既没有预排 watcher、信标又送不到,退出后就什么都不执行。
|
package/client.js
CHANGED
|
@@ -231,6 +231,10 @@ window.__ModuleLoader__.load({
|
|
|
231
231
|
)
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
+
// 状态口径统一:后端 0.4.10 起用 uncommitted,旧快照/旧版本可能只有 dirty;
|
|
235
|
+
// 这里统一取值函数,local.pending / repo.pending 仍是“待推送”语义,保持原样。
|
|
236
|
+
const uncommittedOf = (repo) => (repo?.uncommitted ?? repo?.dirty ?? 0)
|
|
237
|
+
|
|
234
238
|
/**
|
|
235
239
|
* 左侧徽标:只说**本机自身**的状态(配置是否齐、依赖是否缺、有没有未提交/未推送的改动)。
|
|
236
240
|
* 「云端比本机领先多少」一律交给右侧云端徽标(cloudLine),否则标题行会同时出现
|
|
@@ -259,7 +263,7 @@ window.__ModuleLoader__.load({
|
|
|
259
263
|
}
|
|
260
264
|
// 0.4.10 起:本机/契约版本不一致不再算告警——拉取不再因版本不一致被阻断,只保留左上角信息条展示。
|
|
261
265
|
if (repo.behind === null) return { kind: 'idle', text: M('读不到本机 git 状态(git 不可用或没 upstream)', 'Cannot read local git state (git missing or no upstream)') }
|
|
262
|
-
if (repo
|
|
266
|
+
if (uncommittedOf(repo) > 0) return { kind: 'warn', text: M(`本机有 ${uncommittedOf(repo)} 处未提交改动,建议推送`, `${uncommittedOf(repo)} uncommitted change(s) — consider pushing`) }
|
|
263
267
|
if (repo.ahead > 0) return { kind: 'warn', text: M(`本机有 ${repo.ahead} 个提交还没推送`, `${repo.ahead} local commit(s) not pushed yet`) }
|
|
264
268
|
// git 干净不代表没东西要推:新会话/新资料还躺在 ~\.dsh 里,没 capture 之前仓库是完全干净的
|
|
265
269
|
const local = data.local || {}
|
|
@@ -329,14 +333,15 @@ window.__ModuleLoader__.load({
|
|
|
329
333
|
}
|
|
330
334
|
|
|
331
335
|
/** 每个 POST 都带 accept-language:宿主的建议句/错误信息按它出中文或英文。 */
|
|
332
|
-
|
|
336
|
+
// 函数化:每次请求现读语言,避免面板加载后才切换语言时 POST 仍带旧 accept-language。
|
|
337
|
+
const jsonHeaders = () => ({ 'content-type': 'application/json', ...langHeaders() })
|
|
333
338
|
|
|
334
339
|
async function callPrepare(action, message, backupDir) {
|
|
335
340
|
const res = await fetch('/config-sync/prepare', {
|
|
336
341
|
method: 'POST',
|
|
337
342
|
cache: 'no-store',
|
|
338
343
|
credentials: 'same-origin',
|
|
339
|
-
headers: jsonHeaders,
|
|
344
|
+
headers: jsonHeaders(),
|
|
340
345
|
body: JSON.stringify({ action, message: message || '', backupDir: backupDir || '' }),
|
|
341
346
|
})
|
|
342
347
|
const text = await res.text()
|
|
@@ -351,7 +356,7 @@ window.__ModuleLoader__.load({
|
|
|
351
356
|
method: 'POST',
|
|
352
357
|
cache: 'no-store',
|
|
353
358
|
credentials: 'same-origin',
|
|
354
|
-
headers: jsonHeaders,
|
|
359
|
+
headers: jsonHeaders(),
|
|
355
360
|
body: JSON.stringify(payload),
|
|
356
361
|
})
|
|
357
362
|
const text = await res.text()
|
|
@@ -367,7 +372,7 @@ window.__ModuleLoader__.load({
|
|
|
367
372
|
method: 'POST',
|
|
368
373
|
cache: 'no-store',
|
|
369
374
|
credentials: 'same-origin',
|
|
370
|
-
headers: jsonHeaders,
|
|
375
|
+
headers: jsonHeaders(),
|
|
371
376
|
body: JSON.stringify(payload),
|
|
372
377
|
})
|
|
373
378
|
const text = await res.text()
|
|
@@ -387,7 +392,7 @@ window.__ModuleLoader__.load({
|
|
|
387
392
|
method: 'POST',
|
|
388
393
|
cache: 'no-store',
|
|
389
394
|
credentials: 'same-origin',
|
|
390
|
-
headers: jsonHeaders,
|
|
395
|
+
headers: jsonHeaders(),
|
|
391
396
|
body: JSON.stringify(payload),
|
|
392
397
|
}
|
|
393
398
|
: { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
|
|
@@ -408,7 +413,7 @@ window.__ModuleLoader__.load({
|
|
|
408
413
|
method: 'POST',
|
|
409
414
|
cache: 'no-store',
|
|
410
415
|
credentials: 'same-origin',
|
|
411
|
-
headers: jsonHeaders,
|
|
416
|
+
headers: jsonHeaders(),
|
|
412
417
|
body: JSON.stringify(payload),
|
|
413
418
|
}
|
|
414
419
|
: { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
|
|
@@ -429,7 +434,7 @@ window.__ModuleLoader__.load({
|
|
|
429
434
|
method: 'POST',
|
|
430
435
|
cache: 'no-store',
|
|
431
436
|
credentials: 'same-origin',
|
|
432
|
-
headers: jsonHeaders,
|
|
437
|
+
headers: jsonHeaders(),
|
|
433
438
|
body: JSON.stringify(payload),
|
|
434
439
|
}
|
|
435
440
|
: { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
|
|
@@ -447,14 +452,14 @@ window.__ModuleLoader__.load({
|
|
|
447
452
|
method: 'POST',
|
|
448
453
|
cache: 'no-store',
|
|
449
454
|
credentials: 'same-origin',
|
|
450
|
-
headers: jsonHeaders,
|
|
455
|
+
headers: jsonHeaders(),
|
|
451
456
|
body: JSON.stringify(payload),
|
|
452
457
|
}
|
|
453
458
|
: { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
|
|
454
459
|
const text = await res.text()
|
|
455
460
|
let body
|
|
456
461
|
try { body = text ? JSON.parse(text) : null } catch { throw badJson(res) }
|
|
457
|
-
if (!res.ok || !body) throw new Error((body && body.error) || `${res.status}`)
|
|
462
|
+
if (!res.ok || !body || body.ok !== true) throw new Error((body && body.error) || `${res.status}`)
|
|
458
463
|
return body
|
|
459
464
|
}
|
|
460
465
|
|
|
@@ -465,7 +470,7 @@ window.__ModuleLoader__.load({
|
|
|
465
470
|
method: 'POST',
|
|
466
471
|
cache: 'no-store',
|
|
467
472
|
credentials: 'same-origin',
|
|
468
|
-
headers: jsonHeaders,
|
|
473
|
+
headers: jsonHeaders(),
|
|
469
474
|
body: JSON.stringify(payload),
|
|
470
475
|
}
|
|
471
476
|
: { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
|
|
@@ -484,7 +489,7 @@ window.__ModuleLoader__.load({
|
|
|
484
489
|
method,
|
|
485
490
|
cache: 'no-store',
|
|
486
491
|
credentials: 'same-origin',
|
|
487
|
-
headers: payload ? jsonHeaders : langHeaders(),
|
|
492
|
+
headers: payload ? jsonHeaders() : langHeaders(),
|
|
488
493
|
body: payload ? JSON.stringify(payload) : undefined,
|
|
489
494
|
})
|
|
490
495
|
const text = await res.text()
|
|
@@ -506,7 +511,7 @@ window.__ModuleLoader__.load({
|
|
|
506
511
|
method: 'POST',
|
|
507
512
|
cache: 'no-store',
|
|
508
513
|
credentials: 'same-origin',
|
|
509
|
-
headers: jsonHeaders,
|
|
514
|
+
headers: jsonHeaders(),
|
|
510
515
|
body: JSON.stringify(payload),
|
|
511
516
|
}
|
|
512
517
|
: { cache: 'no-store', credentials: 'same-origin', headers: langHeaders() })
|
|
@@ -688,8 +693,8 @@ window.__ModuleLoader__.load({
|
|
|
688
693
|
k: M('远端', 'Remote'),
|
|
689
694
|
v: repo.exists
|
|
690
695
|
? M(
|
|
691
|
-
`落后 ${repo.behind ?? '?'} · 领先 ${repo.ahead ?? '?'} · 未提交 ${repo
|
|
692
|
-
`behind ${repo.behind ?? '?'} · ahead ${repo.ahead ?? '?'} · uncommitted ${repo
|
|
696
|
+
`落后 ${repo.behind ?? '?'} · 领先 ${repo.ahead ?? '?'} · 未提交 ${uncommittedOf(repo)}` + (repo.pending ? `(本机待同步 ${repo.pending})` : ''),
|
|
697
|
+
`behind ${repo.behind ?? '?'} · ahead ${repo.ahead ?? '?'} · uncommitted ${uncommittedOf(repo)}` + (repo.pending ? ` (${repo.pending} pending on this machine)` : ''),
|
|
693
698
|
)
|
|
694
699
|
: (repo.empty ? M('(拉取之后才有得比)', '(available after the first pull)') : M('(不可用)', '(unavailable)')),
|
|
695
700
|
}),
|
|
@@ -845,7 +850,6 @@ window.__ModuleLoader__.load({
|
|
|
845
850
|
const [busy, setBusy] = react.useState(false)
|
|
846
851
|
const [err, setErr] = react.useState('')
|
|
847
852
|
const [msg, setMsg] = react.useState('')
|
|
848
|
-
const [made, setMade] = react.useState(null)
|
|
849
853
|
const [confirm, setConfirm] = react.useState(null) // { snap, preview }:确认环节
|
|
850
854
|
const [queued, setQueued] = react.useState(null) // restore-now 的排队结果
|
|
851
855
|
const [manual, setManual] = react.useState(null) // 认不出类型时的「手动还原」指引
|
|
@@ -1164,17 +1168,6 @@ window.__ModuleLoader__.load({
|
|
|
1164
1168
|
manualBlock,
|
|
1165
1169
|
queuedBlock,
|
|
1166
1170
|
lastRestoreBlock,
|
|
1167
|
-
made
|
|
1168
|
-
? h('div', { style: { display: 'flex', flexDirection: 'column', gap: '4px' } },
|
|
1169
|
-
h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-success-primary)' } },
|
|
1170
|
-
M(`已生成:${made.path}`, `Generated: ${made.path}`)),
|
|
1171
|
-
h('div', { style: S.code }, made.command || ''),
|
|
1172
|
-
h('div', { style: S.footnote }, M(
|
|
1173
|
-
'完全退出 DSH 后双击这份 .cmd:先打印计划,输 y 才真正写(写前自动备份当前状态)。',
|
|
1174
|
-
'Quit DSH, then double-click the .cmd: it prints the plan and only writes after y (backing up the current state first).',
|
|
1175
|
-
)),
|
|
1176
|
-
)
|
|
1177
|
-
: null,
|
|
1178
1171
|
err ? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-error-primary)' } }, M(`操作失败:${err}`, `Failed: ${err}`)) : null,
|
|
1179
1172
|
msg ? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-success-primary)' } }, msg) : null,
|
|
1180
1173
|
h('div', { style: S.footnote }, M(
|
|
@@ -2007,7 +2000,7 @@ window.__ModuleLoader__.load({
|
|
|
2007
2000
|
try {
|
|
2008
2001
|
const res = await fetch('/config-sync/auto', {
|
|
2009
2002
|
method: 'POST', cache: 'no-store', credentials: 'same-origin',
|
|
2010
|
-
headers: jsonHeaders,
|
|
2003
|
+
headers: jsonHeaders(),
|
|
2011
2004
|
body: JSON.stringify({ action, ...(extra || {}) }),
|
|
2012
2005
|
})
|
|
2013
2006
|
const text = await res.text()
|
|
@@ -2093,6 +2086,8 @@ window.__ModuleLoader__.load({
|
|
|
2093
2086
|
type: 'button',
|
|
2094
2087
|
style: canPullNow ? S.btnPrimary : { ...S.btnPrimary, opacity: 0.5, cursor: 'not-allowed' },
|
|
2095
2088
|
disabled: Boolean(busy) || !canPullNow,
|
|
2089
|
+
// 文案分叉是刻意的,与设置页摘要行不同:本卡的推送按钮在 initMode 下会切成「初始化推送」,
|
|
2090
|
+
// 所以这里指引写「先初始化推送」与按钮实际标签一致;摘要行按钮固定「立即推送」,两处场景不同,保留各自口径。
|
|
2096
2091
|
title: canPullNow ? '' : M('云端还是空的:没有内容可拉,先「初始化推送」', 'The cloud is still empty — nothing to pull, initialize push first'),
|
|
2097
2092
|
onClick: () => act('pull-now'),
|
|
2098
2093
|
}, M('立即拉取(会关闭 DSH)', 'Pull now (closes DSH)')),
|
|
@@ -2241,7 +2236,6 @@ window.__ModuleLoader__.load({
|
|
|
2241
2236
|
// 定时器放 ref 里:数据每刷新一次 effect 就会重跑,若在 effect 里 return 清理函数,
|
|
2242
2237
|
// 会把还没到点的"5 秒后消失"定时器一起清掉,提示就一直挂在屏幕上。
|
|
2243
2238
|
const toastTimer = react.useRef(null)
|
|
2244
|
-
const headerRef = react.useRef(null)
|
|
2245
2239
|
const summary = summarize(data)
|
|
2246
2240
|
// 门禁分三条:有路径就能生成还原脚本;拉取允许「真仓库 or 空目录」;推送只允许真仓库。
|
|
2247
2241
|
// 空目录 = 新机器还没拉过,面板只放行「拉取」,推送按钮直接禁掉(后端也会再拦一次)。
|
|
@@ -2305,6 +2299,9 @@ window.__ModuleLoader__.load({
|
|
|
2305
2299
|
if (failure) {
|
|
2306
2300
|
showToast(M(`重新检测失败:${failure}`, `Re-check failed: ${failure}`))
|
|
2307
2301
|
} else {
|
|
2302
|
+
// 时间格式三处不统一是刻意保留:toast 只需当前「时分秒」即时反馈,短格式更轻;
|
|
2303
|
+
// 概览指标用固定 M/D HH:mm 省版面,待办卡用 toLocaleString 出完整日期。三者可见格式不同,
|
|
2304
|
+
// 统一会改变用户看到的文案,按功能不变优先保持原样。
|
|
2308
2305
|
const t = new Date().toLocaleTimeString()
|
|
2309
2306
|
showToast(M(`已重新检测,数据已是最新(${t})`, `Re-checked, data is up to date (${t})`))
|
|
2310
2307
|
}
|
|
@@ -2348,7 +2345,9 @@ window.__ModuleLoader__.load({
|
|
|
2348
2345
|
}
|
|
2349
2346
|
}
|
|
2350
2347
|
|
|
2351
|
-
// 老路径遗留(install-live
|
|
2348
|
+
// 老路径遗留(install-live 装好了但没重启):只重启,不装东西。
|
|
2349
|
+
// 这里保留 restartDsh:restartRequired 场景下包已经覆盖进插件目录,只缺一次重启;
|
|
2350
|
+
// 主路径 restartAndInstall 走 install-restart,会先检查 prepared 包并再次安装,和这个场景不等价。
|
|
2352
2351
|
const restartDsh = async () => {
|
|
2353
2352
|
setUpdBusy(true)
|
|
2354
2353
|
try {
|
|
@@ -2460,9 +2459,12 @@ window.__ModuleLoader__.load({
|
|
|
2460
2459
|
return { kind: 'idle', text: M('云端检查中…', 'Checking the cloud…') }
|
|
2461
2460
|
})()
|
|
2462
2461
|
|
|
2462
|
+
// cloudLine 实际可能返回 ok / error / pull / init / idle;原先 init 落到默认「检查中」,
|
|
2463
|
+
// error 也只写「不一致」,这里按 chipLabel 的同款口径补全每一种 kind 的短标签。
|
|
2463
2464
|
const cloudLabel = cloudLine.kind === 'ok' ? M('一致', 'In sync')
|
|
2464
|
-
: (cloudLine.kind === 'error' ? M('
|
|
2465
|
-
: (cloudLine.kind === 'pull' ? M('待拉取', 'To pull')
|
|
2465
|
+
: (cloudLine.kind === 'error' ? M('检查失败', 'Check failed')
|
|
2466
|
+
: (cloudLine.kind === 'pull' ? M('待拉取', 'To pull')
|
|
2467
|
+
: (cloudLine.kind === 'init' ? M('待初始化', 'To initialize') : M('检查中', 'Checking'))))
|
|
2466
2468
|
|
|
2467
2469
|
// 插件更新卡:老版本机器进来第一眼就能看到"有新版本 x.y.z"和更新按钮;
|
|
2468
2470
|
// 更新相关的配置(清单地址、只读令牌)也收在这张卡里,别散到「云端仓库」去。
|
|
@@ -2809,7 +2811,7 @@ window.__ModuleLoader__.load({
|
|
|
2809
2811
|
// 页头在滚动区之外:内容滚不到它上面,区标签跳转后的标题也只出现在它下面
|
|
2810
2812
|
h('div', { style: S.pageHeaderWrap },
|
|
2811
2813
|
h('div', { style: S.pageHeaderInner },
|
|
2812
|
-
h('div', {
|
|
2814
|
+
h('div', { style: S.pageHeader },
|
|
2813
2815
|
h('div', { style: S.pageHeaderMain },
|
|
2814
2816
|
h('div', { style: S.pageTitleRow },
|
|
2815
2817
|
h('div', { style: S.pageTitle }, M('配置同步', 'Config Sync')),
|
|
@@ -2865,12 +2867,13 @@ window.__ModuleLoader__.load({
|
|
|
2865
2867
|
...(conflictCard ? [['conflict', M('同步冲突', 'Sync conflicts')]] : []),
|
|
2866
2868
|
...(showRoots ? [['roots', M('本机路径', 'Local paths')]] : []),
|
|
2867
2869
|
['targets', M('同步目标', 'Targets')],
|
|
2868
|
-
|
|
2869
|
-
['
|
|
2870
|
-
['
|
|
2871
|
-
['
|
|
2872
|
-
['
|
|
2873
|
-
['
|
|
2870
|
+
// 导航文案与 Section 标题口径对齐:key 仍是滚动锚点,只改显示标签,不改功能分组。
|
|
2871
|
+
['automation', M('自动化与插件更新', 'Automation & plugin update')],
|
|
2872
|
+
['actions', M('退出后执行', 'After exit')],
|
|
2873
|
+
['restore', M('还原备份', 'Restore backup')],
|
|
2874
|
+
['scope', M('同步内容', 'Sync content')],
|
|
2875
|
+
['extra', M('插件数据与额外路径', 'Plugin data & extra paths')],
|
|
2876
|
+
['workspace', M('工作区显示', 'Workspace visibility')],
|
|
2874
2877
|
['feedback', M('问题反馈', 'Feedback')],
|
|
2875
2878
|
].map((pair) => {
|
|
2876
2879
|
const sid = pair[0], label = pair[1]
|
|
@@ -3527,8 +3530,8 @@ window.__ModuleLoader__.load({
|
|
|
3527
3530
|
v: data.repo.behind === null
|
|
3528
3531
|
? M('读不到', 'Unavailable')
|
|
3529
3532
|
: M(
|
|
3530
|
-
`落后 ${data.repo.behind} · 领先 ${data.repo.ahead} · 未提交 ${data.repo
|
|
3531
|
-
`behind ${data.repo.behind} · ahead ${data.repo.ahead} · uncommitted ${data.repo
|
|
3533
|
+
`落后 ${data.repo.behind} · 领先 ${data.repo.ahead} · 未提交 ${uncommittedOf(data.repo)}` + (data.repo.pending ? `(本机待同步 ${data.repo.pending})` : ''),
|
|
3534
|
+
`behind ${data.repo.behind} · ahead ${data.repo.ahead} · uncommitted ${uncommittedOf(data.repo)}` + (data.repo.pending ? ` (${data.repo.pending} pending on this machine)` : ''),
|
|
3532
3535
|
),
|
|
3533
3536
|
}) : null,
|
|
3534
3537
|
data ? h(Kv, {
|
|
@@ -3546,6 +3549,9 @@ window.__ModuleLoader__.load({
|
|
|
3546
3549
|
type: 'button',
|
|
3547
3550
|
style: canPull ? S.btnPrimary : { ...S.btnPrimary, opacity: 0.5, cursor: 'not-allowed' },
|
|
3548
3551
|
disabled: Boolean(actBusy) || !canPull,
|
|
3552
|
+
// 文案分叉是刻意的,与「自动同步」卡不同:本摘要行的推送按钮固定显示「立即推送」,
|
|
3553
|
+
// 两边都空时那次推送即初始化推送;自动同步卡在 initMode 会把按钮切成「初始化推送」。
|
|
3554
|
+
// 两处场景不同,各自指引与旁边按钮标签一致,保留原口径。
|
|
3549
3555
|
title: canPull ? '' : M('云端还是空的:没有内容可拉,先「立即推送」', 'The cloud is still empty — nothing to pull, push first'),
|
|
3550
3556
|
onClick: () => actNow('pull-now'),
|
|
3551
3557
|
}, actBusy === 'pull-now' ? M('排队中…', 'Queueing…') : M('立即拉取(会关闭 DSH)', 'Pull now (closes DSH)')),
|
|
@@ -3639,7 +3645,7 @@ window.__ModuleLoader__.load({
|
|
|
3639
3645
|
method: 'POST',
|
|
3640
3646
|
cache: 'no-store',
|
|
3641
3647
|
credentials: 'same-origin',
|
|
3642
|
-
headers: jsonHeaders,
|
|
3648
|
+
headers: jsonHeaders(),
|
|
3643
3649
|
body: JSON.stringify({ action: 'busy', sessionId: sessionId || '' }),
|
|
3644
3650
|
})
|
|
3645
3651
|
if (!res.ok) return false
|
package/index.js
CHANGED
|
@@ -27,7 +27,7 @@ import { fileURLToPath } from 'node:url'
|
|
|
27
27
|
// 0.3.76:会话投影缓存守卫(agent-busy 自动清缓存,让缓存按日志重建)
|
|
28
28
|
import { runGuard, clearSessionCaches, appendGuardLog } from './runtime/tools/session-cache-guard.mjs'
|
|
29
29
|
// 0.3.76:工作区显示状态(三态 + 会话独立隐藏),自包含读写 DSH 两个权威文件
|
|
30
|
-
import { readView
|
|
30
|
+
import { readView } from './runtime/tools/workspace-view.mjs'
|
|
31
31
|
// 0.3.82:实时通道。拿不到 workspaceRegistry 时,这两个函数内部自动退回上面的文件写法。
|
|
32
32
|
import { setWorkspaceStateLive, setSessionStateLive } from './runtime/tools/workspace-view.mjs'
|
|
33
33
|
|
|
@@ -75,6 +75,8 @@ function t(zh, en) {
|
|
|
75
75
|
// ---- 插件自身的版本与更新源 ----
|
|
76
76
|
// 插件目录就是 index.js 所在目录(apply 会把它部署成 <AppRoot>\dsh-config-sync-plugin-<ver>\)。
|
|
77
77
|
const PLUGIN_DIR = dirname(fileURLToPath(import.meta.url))
|
|
78
|
+
// pluginRoot()/pluginVersion() 是历史调用点保留的同义包装,统一回到这一份定义,避免三处口径漂移。
|
|
79
|
+
function pluginRoot() { return PLUGIN_DIR }
|
|
78
80
|
const PLUGIN_VERSION = (() => {
|
|
79
81
|
try {
|
|
80
82
|
const pkg = JSON.parse(readFileSync(join(PLUGIN_DIR, 'package.json'), 'utf8'))
|
|
@@ -452,12 +454,8 @@ function runGit(args, env, timeout = 20000) {
|
|
|
452
454
|
})
|
|
453
455
|
}
|
|
454
456
|
|
|
455
|
-
function lsRemoteHeads(url, settings) {
|
|
456
|
-
return probeRemote(url, settings).then((p) => (p ? p.heads : null))
|
|
457
|
-
}
|
|
458
|
-
|
|
459
457
|
/** 临时 bare 仓库里数一次远端某个分支的文件数;失败返回 null。 */
|
|
460
|
-
async function remoteFileCount(url, settings
|
|
458
|
+
async function remoteFileCount(url, settings) {
|
|
461
459
|
const env = gitProbeEnv(settings)
|
|
462
460
|
let dir = ''
|
|
463
461
|
try {
|
|
@@ -492,7 +490,7 @@ async function probeRemote(url, settings) {
|
|
|
492
490
|
let value = null
|
|
493
491
|
if (heads === null) value = { heads: null, files: null }
|
|
494
492
|
else if (heads === 0) value = { heads: 0, files: 0 }
|
|
495
|
-
else value = { heads, files: await remoteFileCount(url, settings
|
|
493
|
+
else value = { heads, files: await remoteFileCount(url, settings) }
|
|
496
494
|
remoteProbeCache.set(url, { at: Date.now(), value })
|
|
497
495
|
return value
|
|
498
496
|
}
|
|
@@ -935,6 +933,19 @@ function repoPhase(dir) {
|
|
|
935
933
|
return others.length === 0 ? 'empty' : 'unusable'
|
|
936
934
|
}
|
|
937
935
|
|
|
936
|
+
/**
|
|
937
|
+
* 仓库三态 → 推送/拉取门禁的唯一判据来源(面板 inspect 与后端自动同步共用口径)。
|
|
938
|
+
* phase: ok=真仓库 / empty=空目录 / missing=未建 / unusable=填错路径。
|
|
939
|
+
* remoteFiles: 云端分支树文件数,0=空、null=判不了。
|
|
940
|
+
* 注:判据与 0.4.10 原实现逐字一致,抽取只为消除三处重复,不改变任何放行行为。
|
|
941
|
+
*/
|
|
942
|
+
function canPush(phase, remoteFiles) {
|
|
943
|
+
return phase === 'ok' || (phase === 'empty' && remoteFiles === 0)
|
|
944
|
+
}
|
|
945
|
+
function canPull(phase, remoteFiles) {
|
|
946
|
+
return phase === 'ok' || ((phase === 'empty' || phase === 'missing') && remoteFiles !== 0)
|
|
947
|
+
}
|
|
948
|
+
|
|
938
949
|
/**
|
|
939
950
|
* 体检。全部只读,不写任何文件(除了 prepare 那次由用户显式触发的 cmd 生成)。
|
|
940
951
|
*/
|
|
@@ -1112,9 +1123,9 @@ async function inspect(config) {
|
|
|
1112
1123
|
? 'ok'
|
|
1113
1124
|
: (remoteFiles === 0 ? 'await-init' : 'await-pull'),
|
|
1114
1125
|
// 推送:真仓库,或「空目录 + 云端确实没文件」的首次推送(判不了时不放行,宁可按老规矩只拉)
|
|
1115
|
-
pushAllowed:
|
|
1126
|
+
pushAllowed: canPush(phase, remoteFiles),
|
|
1116
1127
|
// 拉取:真仓库,或空目录/没建目录且云端确实有文件(sync.ps1 的 Initialize-RepoIfNeeded 会自动 init + fetch + checkout)
|
|
1117
|
-
pullAllowed:
|
|
1128
|
+
pullAllowed: canPull(phase, remoteFiles),
|
|
1118
1129
|
// 路径是怎么来的:settings=本机设置(面板可改)、config=插件配置、env=环境变量、auto=自动探测、none=没配
|
|
1119
1130
|
source: resolved.source,
|
|
1120
1131
|
configured: Boolean(settings.repoPath || config?.repoPath),
|
|
@@ -1288,10 +1299,6 @@ function pickPs1(repo, name) {
|
|
|
1288
1299
|
))
|
|
1289
1300
|
}
|
|
1290
1301
|
|
|
1291
|
-
function pluginRoot() {
|
|
1292
|
-
try { return dirname(fileURLToPath(import.meta.url)) } catch { return '' }
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
1302
|
function buildCmd(config, action, repo, appRoot, dshHome, state = {}) {
|
|
1296
1303
|
const isRestore = action === 'restore' || action === 'restore-backup'
|
|
1297
1304
|
const restorePs1 = isRestore ? pickPs1(repo, 'restore.ps1') : ''
|
|
@@ -1749,13 +1756,14 @@ function electronApp() {
|
|
|
1749
1756
|
}
|
|
1750
1757
|
|
|
1751
1758
|
/**
|
|
1752
|
-
*
|
|
1753
|
-
*
|
|
1754
|
-
* 旧实现是 `taskkill /PID <主进程>`(不带 /F):对 Electron 主进程无效 ——
|
|
1755
|
-
* 主进程没有自己的顶层窗口,实测直接报 "This process can only be terminated forcefully",
|
|
1756
|
-
* 于是「确认后自动退出 DSH」根本不生效,守护进程只能干等到 30 分钟超时。
|
|
1759
|
+
* 请求客户端退出(手动「立即推送/拉取/还原」排队后走这条)。
|
|
1757
1760
|
*
|
|
1758
|
-
*
|
|
1761
|
+
* 实现顺序(注释与实现保持一致,勿再写成「优先 app.quit」):
|
|
1762
|
+
* 1) 先按映像名发一次礼貌关闭 taskkill /IM(不带 /F),让 Electron 走正常关闭流程;
|
|
1763
|
+
* 2) 3.5 秒后 /F 强杀残留进程族(插件跑在子进程里,只杀 process.pid 杀不干净);
|
|
1764
|
+
* 3) 拿到 electron 句柄时另发一次 app.quit()(走 before-quit 落盘)。
|
|
1765
|
+
* 返回 true 表示「已发起退出请求」,不代表进程已确认退出(spawn 结果无法同步取得)。
|
|
1766
|
+
* 退出后自动同步那条链路用 forceCloseDshDetached(独立进程延迟强杀),不要混用。
|
|
1759
1767
|
*/
|
|
1760
1768
|
function closeDsh() {
|
|
1761
1769
|
const exe = join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'taskkill.exe')
|
|
@@ -1788,8 +1796,17 @@ function closeDsh() {
|
|
|
1788
1796
|
* 用 cmd /c + ping 做秒级延时(timeout.exe 在无控制台的非交互进程里会报错),
|
|
1789
1797
|
* 先给点 × 触发的正常关闭流程一点时间落盘,再 /F 兜底残留进程。
|
|
1790
1798
|
*/
|
|
1799
|
+
let _forceCloseLastAt = 0
|
|
1791
1800
|
function forceCloseDshDetached(config) {
|
|
1792
1801
|
const dshHome = config?.dshHome || process.env.DSH_HOME || join(homedir(), '.dsh')
|
|
1802
|
+
// 幂等:同一次退出事件里「窗口关闭 / 信标 / 定时预排」三处入口可能接连触发,
|
|
1803
|
+
// 1.5s 内只发一次独立强杀,避免重复 spawn。每次都是杀同一进程族,最终状态一致。
|
|
1804
|
+
const _now = Date.now()
|
|
1805
|
+
if (_now - _forceCloseLastAt < 1500) {
|
|
1806
|
+
logLaunch(dshHome, 'auto-exit:1.5s 内已发起过强杀,本次幂等跳过(同一进程族)')
|
|
1807
|
+
return true
|
|
1808
|
+
}
|
|
1809
|
+
_forceCloseLastAt = _now
|
|
1793
1810
|
const sys = process.env.SystemRoot || 'C:\\Windows'
|
|
1794
1811
|
const cmd = join(sys, 'System32', 'cmd.exe')
|
|
1795
1812
|
const taskkill = join(sys, 'System32', 'taskkill.exe')
|
|
@@ -3664,13 +3681,15 @@ async function handleAuto(req, res, config) {
|
|
|
3664
3681
|
/** 核心判断逻辑:给定配置与仓库,判断是否需要自动拉取/推送,需要则排队 watcher(可选关闭 DSH)。
|
|
3665
3682
|
* 供 scheduleAutoStart(定时)、triggerAutoSyncOnClose(关闭钩子)、handleSettings(开关即时触发)复用。 */
|
|
3666
3683
|
async function checkAndQueueAutoSync(dshHome, config, settings, repo, appRoot, options = {}) {
|
|
3667
|
-
const { skipConfirm = false, isManualTrigger = false, shouldCloseDsh = true, isPeriodic = false } = options
|
|
3684
|
+
const { skipConfirm = false, isManualTrigger = false, shouldCloseDsh = true, isPeriodic = false, driftOverride = null } = options
|
|
3668
3685
|
// 已经排队等退出了就别重复拉起 watcher;但 watcher 已死(超时退出)时允许重排
|
|
3669
3686
|
if (autoState.pending && isProcessAlive(autoState.pending.watcherPid)) return { queued: false, reason: 'already_pending' }
|
|
3670
3687
|
if (!repo || !isDir(join(repo, '.git'))) {
|
|
3671
3688
|
return { queued: false, reason: 'no_repo' }
|
|
3672
3689
|
}
|
|
3673
|
-
|
|
3690
|
+
// 定时复查已在同一次 run 里 checkDrift 过(结果写进 autoState.drift),经 driftOverride 复用,
|
|
3691
|
+
// 避免几毫秒内对同一仓库重复 git fetch。未传时行为与原来完全一致(自行 fetch)。
|
|
3692
|
+
const drift = driftOverride || await checkDrift(repo)
|
|
3674
3693
|
if (!drift) {
|
|
3675
3694
|
return { queued: false, reason: 'drift_failed' }
|
|
3676
3695
|
}
|
|
@@ -3720,6 +3739,7 @@ async function checkAndQueueAutoSync(dshHome, config, settings, repo, appRoot, o
|
|
|
3720
3739
|
const restart = settings.autoRestart !== false
|
|
3721
3740
|
const started = await spawnWatcher({ mode: 'push', repo, appRoot, dshHome, restart })
|
|
3722
3741
|
if (started.ok) {
|
|
3742
|
+
// reason=旧版兜底文案,reasonZh/reasonEn=双语文案(前端按语言优先读双语、reason 兜底),三者是不同键,勿合并
|
|
3723
3743
|
autoState.pending = { mode: 'push', at: Date.now(), reason: reasonZh, reasonZh, reasonEn, restart, watcherPid: started.pid, closeRequested: false }
|
|
3724
3744
|
if (shouldCloseDsh) closeDsh()
|
|
3725
3745
|
return { queued: true, mode: 'push', reason: reasonZh }
|
|
@@ -3763,7 +3783,8 @@ function scheduleAutoStart(config) {
|
|
|
3763
3783
|
// (shouldCloseDsh:false)。用户点 × 关闭 DSH 后,预排的 watcher 自动进入 run 执行。
|
|
3764
3784
|
// 前端信标仍保留作双保险:它若送达、发现已排队会直接复用,不会重复。
|
|
3765
3785
|
const appRoot = resolveAppRoot(config?.appRoot) || ''
|
|
3766
|
-
|
|
3786
|
+
// 复用本次复查刚 fetch 的 drift,避免 checkAndQueueAutoSync 内二次 fetch(同一仓库、同一时刻)
|
|
3787
|
+
await checkAndQueueAutoSync(dshHome, config, settings, repo, appRoot, { shouldCloseDsh: false, isPeriodic: true, driftOverride: drift })
|
|
3767
3788
|
} catch (error) {
|
|
3768
3789
|
autoState.checking = false
|
|
3769
3790
|
autoState.lastCheckAt = Date.now()
|
|
@@ -3807,6 +3828,8 @@ async function triggerAutoSyncOnClose(config, options = {}) {
|
|
|
3807
3828
|
const phase = repoPhase(repo)
|
|
3808
3829
|
|
|
3809
3830
|
// 本机仓库还没内容:autoPull 可以直接排队(sync.ps1 首次 clone),autoPush 不行(要先确认云端为空)
|
|
3831
|
+
// 注:关闭走的 fast 路径不探测 remoteFiles,这里沿用原 phase === 'empty' 判据;
|
|
3832
|
+
// inspect() 面板门禁已收敛到 canPull()(见文件上方),口径一致但此路径不额外 fetch,行为保持不变。
|
|
3810
3833
|
if (phase !== 'ok') {
|
|
3811
3834
|
if (settings.autoPull && phase === 'empty') {
|
|
3812
3835
|
const restart = settings.autoRestart !== false
|
|
@@ -4329,13 +4352,8 @@ async function handleRoots(req, res, config) {
|
|
|
4329
4352
|
const GH_DEFAULT_REPO = 'QcWyGm/dsh-config-sync-plugin'
|
|
4330
4353
|
const GH_FEEDBACK_LABEL = 'feedback'
|
|
4331
4354
|
|
|
4332
|
-
/**
|
|
4333
|
-
function pluginVersion() {
|
|
4334
|
-
try {
|
|
4335
|
-
const pkg = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'package.json'), 'utf8'))
|
|
4336
|
-
return String(pkg.version || '')
|
|
4337
|
-
} catch { return '' }
|
|
4338
|
-
}
|
|
4355
|
+
/** 当前插件版本(同义包装,统一回到 PLUGIN_VERSION 这一份定义)。 */
|
|
4356
|
+
function pluginVersion() { return PLUGIN_VERSION }
|
|
4339
4357
|
|
|
4340
4358
|
function ghPathOf(dshHome) { return join(dshHome, 'config-sync-gh.json') }
|
|
4341
4359
|
function outboxPathOf(dshHome) { return join(dshHome, 'config-sync-feedback-outbox.json') }
|
package/package.json
CHANGED
package/runtime/apply.ps1
CHANGED
|
@@ -48,6 +48,7 @@ param(
|
|
|
48
48
|
[switch]$SkipWorkspace,
|
|
49
49
|
[switch]$PruneWorkspace,
|
|
50
50
|
[switch]$ReplaceWorkspaceRegistry,
|
|
51
|
+
# 已废弃:0.4.10 起默认放行版本差异,此开关不参与判据,仅为兼容旧调用保留
|
|
51
52
|
[switch]$AllowVersionDrift,
|
|
52
53
|
[switch]$ForceBundles,
|
|
53
54
|
[string]$WorkspaceHome = $(Join-Path $env:USERPROFILE 'Documents\deepseek-harness'),
|
|
@@ -404,6 +405,7 @@ function Sync-WorkspaceApply {
|
|
|
404
405
|
# sessions\ 一级目录名 = Get-SessionDirName(工作区绝对路径)。编码不可逆,所以 capture
|
|
405
406
|
# 在 conversations\session-index.json 里记了「目录名 ↔ 工作区 ID」;apply 按本机
|
|
406
407
|
# -AppRoot / -WorkspaceHome 展开后的路径重新编码目录名,B 机才能认出这些会话。
|
|
408
|
+
# 与另一文件同名函数保持一致,修改需同步
|
|
407
409
|
function Get-SessionDirName([string]$path) {
|
|
408
410
|
$sb = New-Object System.Text.StringBuilder
|
|
409
411
|
[void]$sb.Append('--')
|
|
@@ -920,7 +922,7 @@ foreach ($b in $bundlesInRepo) {
|
|
|
920
922
|
if ($b -notlike '@deepseek-ai/dsh-experimental-*') { continue }
|
|
921
923
|
$why = $null
|
|
922
924
|
if ($versionDrift) {
|
|
923
|
-
$why = "本机 app 版本不同($hostAppVersion ≠ $contractVersion
|
|
925
|
+
$why = "本机 app 版本不同($hostAppVersion ≠ $contractVersion);仅剔除实验 bundle,不影响主流程"
|
|
924
926
|
} else {
|
|
925
927
|
# 宿主自带 bundle 的落点因构建而异:解包版在 resources\app\dsh\node_modules,
|
|
926
928
|
# 打包版整包塞在 app.asar 里(磁盘上没有目录)——所以交给 Test-HostBundle 统一判断,别只查路径。
|
package/runtime/capture.ps1
CHANGED
|
@@ -310,6 +310,7 @@ function Sync-WorkspaceCapture {
|
|
|
310
310
|
# 绝不做文本替换(zstd 流无法替换;projcache 按 sessionId 索引,cwd 只是历史记录,B 机可读)。
|
|
311
311
|
# sessions\ 一级目录名 = Get-SessionDirName(工作区绝对路径);该编码不可逆,所以 capture 用
|
|
312
312
|
# 「已知工作区路径 → 编码 → 匹配目录名」建 dir ↔ workspaceId 映射,apply 再按本机路径重编码目录名。
|
|
313
|
+
# 与另一文件同名函数保持一致,修改需同步
|
|
313
314
|
function Get-SessionDirName([string]$path) {
|
|
314
315
|
$sb = New-Object System.Text.StringBuilder
|
|
315
316
|
[void]$sb.Append('--')
|
|
@@ -588,7 +589,6 @@ function Sync-ConversationCapture {
|
|
|
588
589
|
# 关键修复(2026-11-10):旧版正则把目录名写死成 DeepSeekHarness,客户端装在 D:\DSH 时归一化整体失效,
|
|
589
590
|
# 本机绝对路径会被原样写进仓库 → 另一台 apply 后 lock 与 package.json 错位 → 安装半装 → 启动崩。
|
|
590
591
|
# 现在先按本机 -AppRoot 的实际路径做字面替换(任意目录名、任意盘符),再用「末级目录名」正则兜底。
|
|
591
|
-
$AppRootPattern = Get-AppRootPattern $AppRoot
|
|
592
592
|
|
|
593
593
|
function Set-AppRootToken([string]$text) {
|
|
594
594
|
return (Convert-AppRootText $text $AppRoot $AppRootToken)
|
|
@@ -712,7 +712,7 @@ function Get-PluginDataFiles([string]$slotDir, $cfg, [string]$baseDir = '') {
|
|
|
712
712
|
|
|
713
713
|
# 必需组:不许取消勾选。理由都是"不勾就报错"这一个事实:
|
|
714
714
|
# profile 里的 package.json / cordis.patch.yml 是 apply 的前置条件 —— 仓库缺它们,apply.ps1 直接 Die;
|
|
715
|
-
# 同一组的 host-contract.json
|
|
715
|
+
# 同一组的 host-contract.json 用于实验 bundle 门控;版本差异不再阻断,只提示,不会因此拒绝铺配置。
|
|
716
716
|
# 所以这里(以及面板)都把 profile 钉死为开启,手改 JSON 关掉也按开启处理。
|
|
717
717
|
$SyncRequiredGroups = @('profile')
|
|
718
718
|
|
package/runtime/restore.ps1
CHANGED
|
@@ -46,35 +46,33 @@ $ProfileDir = Join-Path $DshHome ('profiles\' + $ProfileName)
|
|
|
46
46
|
$ProfileFiles = @('package.json', 'pnpm-lock.yaml', 'pnpm-workspace.yaml', 'cordis.yml', 'cordis.patch.yml')
|
|
47
47
|
$HomeFiles = @('AGENTS.md', 'prompt-inject.md')
|
|
48
48
|
|
|
49
|
-
#
|
|
49
|
+
# 客户端根:优先复用主链路 Resolve-DshAppRoot(显式参数 → $env:DSH_APP_ROOT → 注册表 → 多盘候选);
|
|
50
|
+
# 实在找不到时保留 restore 原有的 D:\DeepSeekHarness 默认路径兜底,避免旧行为报错。
|
|
50
51
|
function Resolve-AppRoot([string]$explicit) {
|
|
51
|
-
$
|
|
52
|
-
if ($
|
|
53
|
-
$cands += @('D:\DeepSeekHarness', 'D:\DSH', 'G:\DSH', 'G:\DeepSeekHarness', 'C:\DeepSeekHarness')
|
|
54
|
-
foreach ($c in $cands) {
|
|
55
|
-
if (Test-Path -LiteralPath (Join-Path $c 'resources\app\package.json')) { return $c }
|
|
56
|
-
}
|
|
52
|
+
$resolved = Resolve-DshAppRoot $explicit
|
|
53
|
+
if ($resolved) { return $resolved }
|
|
57
54
|
if ($explicit) { return $explicit }
|
|
58
55
|
return 'D:\DeepSeekHarness'
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
# git 位置探测统一在 dsh-sync-common.ps1 里(Get-GitExe),restore 允许找不到(只影响 pnpm 安装步骤)
|
|
62
59
|
|
|
63
|
-
# 按 profile\package.json 的 bundles 逐项查能否解析(profile\node_modules
|
|
60
|
+
# 按 profile\package.json 的 bundles 逐项查能否解析(profile\node_modules 优先,再宿主磁盘/asar)
|
|
61
|
+
# 宿主侧统一交给 Test-HostBundle:它同时查 resources\app\dsh\node_modules 与 resources\app.asar,
|
|
62
|
+
# 打包版宿主不再因为 asar 里的 bundle 被误报为缺失。
|
|
64
63
|
function Get-UnresolvedBundles {
|
|
65
64
|
$missing = New-Object System.Collections.ArrayList
|
|
66
65
|
$pkgPath = Join-Path $ProfileDir 'package.json'
|
|
67
66
|
if (-not (Test-Path -LiteralPath $pkgPath)) { return $missing }
|
|
68
67
|
try { $pkg = Get-Content -LiteralPath $pkgPath -Raw -Encoding utf8 | ConvertFrom-Json } catch { return $missing }
|
|
69
68
|
$bundles = @($pkg.dsh.profile.bundles)
|
|
70
|
-
$
|
|
69
|
+
$profileModules = Join-Path $ProfileDir 'node_modules'
|
|
71
70
|
foreach ($b in $bundles) {
|
|
72
71
|
if ([string]::IsNullOrWhiteSpace($b)) { continue }
|
|
73
72
|
$rel = [string]($b -replace '/', '\')
|
|
74
73
|
$found = $false
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
74
|
+
if (Test-Path -LiteralPath (Join-Path $profileModules (Join-Path $rel 'package.json'))) { $found = $true }
|
|
75
|
+
if (-not $found -and (Test-HostBundle $AppRoot $b)) { $found = $true }
|
|
78
76
|
if (-not $found) { [void]$missing.Add($b) }
|
|
79
77
|
}
|
|
80
78
|
return $missing
|
|
@@ -501,7 +499,7 @@ if (Test-Path -LiteralPath $contractPath) {
|
|
|
501
499
|
}
|
|
502
500
|
Say " 本机 app 版本:$localVer;仓库契约:$contractVer"
|
|
503
501
|
if ($localVer -and $contractVer -and $localVer -ne $contractVer) {
|
|
504
|
-
Warn "两端版本不一致:本机 $localVer,仓库契约 $contractVer
|
|
502
|
+
Warn "两端版本不一致:本机 $localVer,仓库契约 $contractVer。0.4.10 起 pull 会放行版本差异,仅实验 bundle 按契约剔除;如需完全一致请升级本机。"
|
|
505
503
|
}
|
|
506
504
|
|
|
507
505
|
$missing = @(Get-UnresolvedBundles)
|