dsh-config-sync-plugin 0.3.68 → 0.3.70
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 +17 -180
- package/README.md +19 -171
- package/client.js +58 -31
- package/index.js +9 -9
- package/package.json +1 -1
- package/runtime/apply.ps1 +37 -6
- package/runtime/capture.ps1 +20 -1
- package/runtime/dsh-sync-common.ps1 +153 -1
- package/runtime/post-exit.ps1 +2 -0
- package/runtime/tools/bili-state.mjs +501 -0
- package/tools/bili-state.mjs +501 -0
- package/tools/selftest.mjs +67 -0
package/client.js
CHANGED
|
@@ -929,7 +929,7 @@ window.__ModuleLoader__.load({
|
|
|
929
929
|
}
|
|
930
930
|
// 「手动还原」指引里的目标位置:认不出类型时按内容猜不到,索性把三类常见落点都摆出来
|
|
931
931
|
const manualTargets = () => [
|
|
932
|
-
M('插件本体 → 插件安装目录(如 D:\\DeepSeekHarness\\dsh-config-sync-plugin
|
|
932
|
+
M('插件本体 → 插件安装目录(如 D:\\DeepSeekHarness\\dsh-config-sync-plugin-<ver>)', 'Plugin files → the plugin install folder (e.g. D:\\DeepSeekHarness\\dsh-config-sync-plugin-<ver>)'),
|
|
933
933
|
M('会话目录(--xxx--)→ ~\\.dsh\\sessions', 'Session folders (--xxx--) → ~\\.dsh\\sessions'),
|
|
934
934
|
M('配置五件套(package.json / pnpm-lock.yaml / cordis.yml…)→ ~\\.dsh\\profiles\\desktop', 'Config files (package.json / pnpm-lock.yaml / cordis.yml…) → ~\\.dsh\\profiles\\desktop'),
|
|
935
935
|
]
|
|
@@ -966,7 +966,7 @@ window.__ModuleLoader__.load({
|
|
|
966
966
|
)),
|
|
967
967
|
)))
|
|
968
968
|
: h('div', { style: S.hint }, backup.exists
|
|
969
|
-
? M('
|
|
969
|
+
? M('这个目录下还没有快照(每次拉取/落地前会自动打一份)', 'No snapshots in this backup folder yet (apply.ps1 makes one before every pull/apply)')
|
|
970
970
|
: M(`备份目录不存在:${backup.root || defaultRoot}`, `Backup folder does not exist: ${backup.root || defaultRoot}`))
|
|
971
971
|
|
|
972
972
|
/**
|
|
@@ -1460,7 +1460,7 @@ window.__ModuleLoader__.load({
|
|
|
1460
1460
|
const p = newPath.trim()
|
|
1461
1461
|
if (!p || !draft || !editing) return
|
|
1462
1462
|
if (!/^([A-Za-z]:[\\/]|\\\\)/.test(p)) {
|
|
1463
|
-
setErr(M('
|
|
1463
|
+
setErr(M('要填绝对路径,如 C:\\Users\\你\\某个目录(相对路径换机后对不上)', 'Use an absolute path such as C:\\Users\\you\\some-folder'))
|
|
1464
1464
|
return
|
|
1465
1465
|
}
|
|
1466
1466
|
const label = newLabel.trim() || p.replace(/[\\/]+$/, '').split(/[\\/]/).pop() || 'extra'
|
|
@@ -1499,7 +1499,7 @@ window.__ModuleLoader__.load({
|
|
|
1499
1499
|
),
|
|
1500
1500
|
h('div', { style: S.footnote },
|
|
1501
1501
|
editing
|
|
1502
|
-
? M('
|
|
1502
|
+
? M('点「保存」写进 config-sync-extra.json,「取消」丢弃改动', 'Click Save to write config-sync-extra.json; Cancel drops the change')
|
|
1503
1503
|
: M('只读:点右上「修改」才能改规则、加路径', 'Read-only: click Edit to change rules or add paths')),
|
|
1504
1504
|
msg ? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-success-primary, #1a7f37)' } }, msg) : null,
|
|
1505
1505
|
err ? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-error-primary)' } }, err) : null,
|
|
@@ -1851,7 +1851,7 @@ window.__ModuleLoader__.load({
|
|
|
1851
1851
|
h('div', { style: { ...S.footnote, flex: 1 } }, M('默认关闭;不开就是纯手动', 'Off by default — leaving them off keeps it manual')),
|
|
1852
1852
|
),
|
|
1853
1853
|
sw('autoPull', 'pull', M('启动时自动拉取', 'Pull on startup'),
|
|
1854
|
-
M('云端有新提交 → 弹确认 →
|
|
1854
|
+
M('云端有新提交 → 弹确认 → 退出后拉取,失败自动还原',
|
|
1855
1855
|
'New commits upstream → confirm → pull after exit; failures roll back to the previous config')),
|
|
1856
1856
|
sw('autoPush', 'push', M('退出时自动推送', 'Push on exit'),
|
|
1857
1857
|
M('有改动 / 新资料 / 未推送提交 → 每 2 分钟复查,退出后推送',
|
|
@@ -1869,7 +1869,7 @@ window.__ModuleLoader__.load({
|
|
|
1869
1869
|
: null,
|
|
1870
1870
|
!auto.script
|
|
1871
1871
|
? h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-warn-primary)' } },
|
|
1872
|
-
M('
|
|
1872
|
+
M('找不到 post-exit.ps1:自动同步排不了队,重装插件即可',
|
|
1873
1873
|
'post-exit.ps1 is missing from both the plugin and the repo, so auto sync cannot queue — reinstall the plugin (the current package ships runtime/)'))
|
|
1874
1874
|
: null,
|
|
1875
1875
|
h('div', { style: S.actions },
|
|
@@ -1926,6 +1926,8 @@ window.__ModuleLoader__.load({
|
|
|
1926
1926
|
function noticesBlock(notices) {
|
|
1927
1927
|
if (!notices || !notices.total) return null
|
|
1928
1928
|
const kindLabel = (k) => ({
|
|
1929
|
+
'plugin-missing': M('插件没装', 'Plugin missing'),
|
|
1930
|
+
'context-state': M('缺压缩状态', 'No compaction state'),
|
|
1929
1931
|
'too-large': M('超过单文件上限', 'Over size cap'),
|
|
1930
1932
|
history: M('历史里的超限文件', 'Oversized in history'),
|
|
1931
1933
|
failed: M('失败', 'Failed'),
|
|
@@ -1945,6 +1947,8 @@ window.__ModuleLoader__.load({
|
|
|
1945
1947
|
if (notices.byKind.history) parts.push(M(`${notices.byKind.history} 个在历史提交里`, `${notices.byKind.history} already in history`))
|
|
1946
1948
|
if (notices.byKind.failed) parts.push(M(`${notices.byKind.failed} 个失败`, `${notices.byKind.failed} failed`))
|
|
1947
1949
|
if (notices.byKind.skipped) parts.push(M(`${notices.byKind.skipped} 个被跳过`, `${notices.byKind.skipped} skipped`))
|
|
1950
|
+
if (notices.byKind['plugin-missing']) parts.push(M(`${notices.byKind['plugin-missing']} 个插件没装`, `${notices.byKind['plugin-missing']} plugin(s) missing`))
|
|
1951
|
+
if (notices.byKind['context-state']) parts.push(M(`${notices.byKind['context-state']} 个会话缺压缩状态`, `${notices.byKind['context-state']} session(s) without compaction state`))
|
|
1948
1952
|
}
|
|
1949
1953
|
return h('div', {
|
|
1950
1954
|
style: {
|
|
@@ -1953,11 +1957,34 @@ window.__ModuleLoader__.load({
|
|
|
1953
1957
|
background: 'color-mix(in srgb, var(--dsw-alias-state-warn-primary) 8%, transparent)',
|
|
1954
1958
|
},
|
|
1955
1959
|
},
|
|
1956
|
-
|
|
1957
|
-
|
|
1960
|
+
// 标题按「实际是哪类问题」说人话:插件没装/缺压缩状态不是「文件没同步」,
|
|
1961
|
+
// 混在一起会让人以为磁盘上少了东西。
|
|
1962
|
+
(() => {
|
|
1963
|
+
const fileish = (notices.byKind && (notices.byKind['too-large'] || notices.byKind.history || notices.byKind.failed || notices.byKind.skipped)) || 0
|
|
1964
|
+
const pluginN = (notices.byKind && notices.byKind['plugin-missing']) || 0
|
|
1965
|
+
const stateN = (notices.byKind && notices.byKind['context-state']) || 0
|
|
1966
|
+
const headline = fileish
|
|
1967
|
+
? M(`上次同步有 ${notices.total} 项没处理完${parts.length ? `(${parts.join('、')})` : ''}`,
|
|
1968
|
+
`Last sync left ${notices.total} item(s) unresolved${parts.length ? ` (${parts.join(', ')})` : ''}`)
|
|
1969
|
+
: (pluginN || stateN)
|
|
1970
|
+
? M(`上次同步后有 ${notices.total} 项需要处理${parts.length ? `(${parts.join('、')})` : ''}`,
|
|
1971
|
+
`After the last sync ${notices.total} item(s) need attention${parts.length ? ` (${parts.join(', ')})` : ''}`)
|
|
1972
|
+
: M(`上次同步有 ${notices.total} 项没处理完`, `Last sync left ${notices.total} item(s) unresolved`)
|
|
1973
|
+
return h('div', { style: { fontSize: '12px', fontWeight: 600, color: 'var(--dsw-alias-state-warn-primary)' } }, headline)
|
|
1974
|
+
})(),
|
|
1958
1975
|
h('div', { style: { ...S.footnote, marginTop: '3px' } },
|
|
1959
|
-
M('
|
|
1960
|
-
'
|
|
1976
|
+
M('文件类的仍在本机磁盘上,只是没进仓库;插件类要先装好再拉一次。',
|
|
1977
|
+
'File items are still on this machine, just not in the repo; the next sync re-checks them. Plugin items need an install here first, then pull again.')),
|
|
1978
|
+
(notices.byKind && notices.byKind['plugin-missing'])
|
|
1979
|
+
? h('div', { style: { ...S.footnote, marginTop: '3px', color: 'var(--dsw-alias-state-warn-primary)' } },
|
|
1980
|
+
M('插件没装:拉取不装依赖。先在 profile 目录执行 pnpm install(或去掉 -SkipInstall 重跑 apply.ps1),装好后再拉一次。',
|
|
1981
|
+
'Missing plugins: pulling only restores config, it does not install dependencies. Run pnpm install in the profile dir first (or re-run apply.ps1 without -SkipInstall), then pull again.'))
|
|
1982
|
+
: null,
|
|
1983
|
+
(notices.byKind && notices.byKind['context-state'])
|
|
1984
|
+
? h('div', { style: { ...S.footnote, marginTop: '3px', color: 'var(--dsw-alias-state-warn-primary)' } },
|
|
1985
|
+
M('会话缺压缩状态:这些会话在本机可能报上下文超长。在主力机重新推送一次(会带上压缩状态),或设 BILLION_CONTEXT_PLUGIN=0 让原生压缩兜底。',
|
|
1986
|
+
'Missing compaction state: billion-context blocks were not synced, so those sessions may hit a context-overflow error here. Push again from the main machine, or set BILLION_CONTEXT_PLUGIN=0 here to fall back to DSH native compaction.'))
|
|
1987
|
+
: null,
|
|
1961
1988
|
h('div', { style: { marginTop: '4px' } }, rows),
|
|
1962
1989
|
notices.truncated
|
|
1963
1990
|
? h('div', { style: { ...S.footnote, marginTop: '3px' } },
|
|
@@ -1966,7 +1993,7 @@ window.__ModuleLoader__.load({
|
|
|
1966
1993
|
: null,
|
|
1967
1994
|
notices.byKind && notices.byKind.history
|
|
1968
1995
|
? h('div', { style: { ...S.footnote, marginTop: '4px', color: 'var(--dsw-alias-state-warn-primary)' } },
|
|
1969
|
-
M('
|
|
1996
|
+
M('历史里的超限文件会让整次推送被拒收:换一份新仓库(本卡「初始化推送」),或用 git filter-repo 清史。',
|
|
1970
1997
|
'Oversized files already in history make the whole push get rejected: point at a fresh empty repo (Initialize push here), or rewrite history with git filter-repo.'))
|
|
1971
1998
|
: null,
|
|
1972
1999
|
)
|
|
@@ -2392,7 +2419,7 @@ window.__ModuleLoader__.load({
|
|
|
2392
2419
|
type: 'text',
|
|
2393
2420
|
style: S.input,
|
|
2394
2421
|
value: note,
|
|
2395
|
-
placeholder: M('
|
|
2422
|
+
placeholder: M('可选:这次改了什么(写进提交信息,时间自动附上)', 'Optional: what changed (written into the push commit message; the timestamp is added automatically)'),
|
|
2396
2423
|
spellCheck: false,
|
|
2397
2424
|
onChange: (e) => setNote(e.target.value),
|
|
2398
2425
|
}),
|
|
@@ -2403,23 +2430,23 @@ window.__ModuleLoader__.load({
|
|
|
2403
2430
|
`还原快照:${data.backup.latest}(${data.backup.count} 份中的最新)`,
|
|
2404
2431
|
`Restore snapshot: ${data.backup.latest} (newest of ${data.backup.count})`,
|
|
2405
2432
|
)
|
|
2406
|
-
: M('
|
|
2433
|
+
: M('还原快照:还没有备份快照(需先拉取,或指定 -FromCommit)', 'Restore snapshot: no backups yet (restore has nothing to fall back to — pull first, or pass -FromCommit)')),
|
|
2407
2434
|
data && data.repo && !data.repo.exists && !data.repo.empty
|
|
2408
2435
|
? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-error-primary)' } },
|
|
2409
|
-
M('
|
|
2436
|
+
M('仓库路径未配置:先在本机仓库卡里设好',
|
|
2410
2437
|
'Repo path is not set: configure it in the Local repo card, otherwise scripts cannot be generated.'))
|
|
2411
2438
|
: null,
|
|
2412
2439
|
data && data.repo && (data.repo.phase === 'empty' || data.repo.phase === 'missing')
|
|
2413
2440
|
? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-warn-primary)' } },
|
|
2414
2441
|
data.repo.mode === 'await-init'
|
|
2415
|
-
? M('
|
|
2442
|
+
? M('本机与云端都空:只生成「推送」(会初始化仓库),没有东西可拉',
|
|
2416
2443
|
'Both the local repo and the cloud are empty: only Push can be generated (push initializes the repo and writes the skeleton); there is nothing to pull.')
|
|
2417
|
-
: M('
|
|
2444
|
+
: M('本机仓库是空的:只生成「拉取」,拉完才能推送',
|
|
2418
2445
|
'The local repo has no content yet: only Pull (plus Restore) can be generated now. Pull brings the whole cloud repo into this path; push unlocks after that.'))
|
|
2419
2446
|
: null,
|
|
2420
2447
|
data && data.remote && !data.remote.configured
|
|
2421
2448
|
? h('div', { style: { ...S.footnote, color: 'var(--dsw-alias-state-error-primary)' } },
|
|
2422
|
-
M('
|
|
2449
|
+
M('远端地址未配置:只能生成还原',
|
|
2423
2450
|
'Cloud remote not set: push/pull unavailable (restore still works).'))
|
|
2424
2451
|
: null,
|
|
2425
2452
|
data && data.repo && data.repo.ahead > 0
|
|
@@ -2488,8 +2515,8 @@ window.__ModuleLoader__.load({
|
|
|
2488
2515
|
] : h('span', null, summary.text),
|
|
2489
2516
|
),
|
|
2490
2517
|
h('div', { style: S.pageLead },
|
|
2491
|
-
M('
|
|
2492
|
-
'Configs flow between this machine, the repo and the cloud.
|
|
2518
|
+
M('配置在本机、仓库、云端之间流转。改完立即生效;写回与还原在退出客户端后执行。',
|
|
2519
|
+
'Configs flow between this machine, the repo and the cloud. Edits apply at once; write-back and restore run after the client quits.')),
|
|
2493
2520
|
),
|
|
2494
2521
|
h('div', { style: S.headerActions },
|
|
2495
2522
|
// 「本机路径」区唯一的入口:平时普通按钮,只有根外路径/被覆盖这两类告警才变橙并带数字
|
|
@@ -2499,7 +2526,7 @@ window.__ModuleLoader__.load({
|
|
|
2499
2526
|
? { ...S.btn, color: 'var(--dsw-alias-state-warn-primary)', borderColor: 'var(--dsw-alias-state-warn-primary)' }
|
|
2500
2527
|
: S.btn,
|
|
2501
2528
|
title: (!showRoots && lpAlert > 0)
|
|
2502
|
-
? M('
|
|
2529
|
+
? M('本机路径有告警(根外路径 / 被覆盖的配置)', 'Local paths need attention (outside-root paths / overwritten configs)')
|
|
2503
2530
|
: M('查看本机路径与占位符的对照', 'Show local paths and their placeholders'),
|
|
2504
2531
|
onClick: () => setShowRoots((v) => !v),
|
|
2505
2532
|
},
|
|
@@ -2531,17 +2558,17 @@ window.__ModuleLoader__.load({
|
|
|
2531
2558
|
conflictCard
|
|
2532
2559
|
? Section(M('同步冲突', 'Sync conflicts'), M('这些文件挡住了拉取:逐项选完保存,再点「立即拉取」', 'These files block the pull: pick per file, save, then pull'), [conflictCard])
|
|
2533
2560
|
: null,
|
|
2534
|
-
Section(M('本机路径', 'Local paths'), M('
|
|
2535
|
-
Section(M('同步目标', 'Sync targets'), M('
|
|
2561
|
+
Section(M('本机路径', 'Local paths'), M('每台机器确认一次即可:仓库里用占位符,落地时按这里展开', 'Confirm once per machine: the repo stores placeholders, expanded with these paths'), [rootsCard]),
|
|
2562
|
+
Section(M('同步目标', 'Sync targets'), M('仓库与远端都是本机设置,改完即生效', 'Repo and remote are local settings, applied at once'), [repoCard, remoteCard].filter(Boolean)),
|
|
2536
2563
|
Section(M('自动化与插件更新', 'Automation & plugin update'), M('退出后自动做什么、插件自己怎么升级', 'What runs automatically after exit, and how the plugin upgrades'), [autoCard, updCard].filter(Boolean)),
|
|
2537
|
-
Section(M('退出后执行', 'After exit'), M('生成脚本 →
|
|
2564
|
+
Section(M('退出后执行', 'After exit'), M('生成脚本 → 退出客户端后跑一遍', 'Generate the script → it runs after the client quits'), [actionCard]),
|
|
2538
2565
|
// 「还原备份」跟在动作卡之后:先看怎么生成脚本,再挑具体退回到哪份快照
|
|
2539
2566
|
Section(M('还原备份', 'Restore backup'), M('点快照 → 确认差异 → 排队还原(退出客户端后执行)', 'Pick a snapshot → confirm the diff → queued restore (runs after the client quits)'), [restoreCard].filter(Boolean)),
|
|
2540
2567
|
// 「同步内容」放在整页最下面:它是"细项配置",看清前面的状态与动作后才会来调整
|
|
2541
2568
|
Section(M('同步内容', 'Sync content'), M('十二组内容,默认全勾;必需组锁定', 'Twelve groups, all checked; required groups are locked'), [scopeCard]),
|
|
2542
|
-
Section(M('插件数据与额外路径', 'Plugin data & extra paths'), M('
|
|
2569
|
+
Section(M('插件数据与额外路径', 'Plugin data & extra paths'), M('插件自己的配置与数据:默认自动收,可改排除名单与体积上限', 'A plugin\'s own config and data: collected automatically, with editable exclusions and a size cap'), [extraCard]),
|
|
2543
2570
|
// 反馈放在最后一区:查完状态、调完配置,才轮到「有问题要报」
|
|
2544
|
-
Section(M('问题反馈', 'Feedback'), M('提交即建 GitHub Issue
|
|
2571
|
+
Section(M('问题反馈', 'Feedback'), M('提交即建 GitHub Issue,跨机器共用;离线先排队', 'Each report becomes a GitHub Issue, shared across machines; offline reports queue locally'), [feedbackCard]),
|
|
2545
2572
|
),
|
|
2546
2573
|
)
|
|
2547
2574
|
}
|
|
@@ -2776,7 +2803,7 @@ window.__ModuleLoader__.load({
|
|
|
2776
2803
|
it.adopted
|
|
2777
2804
|
? h('span', { style: { ...S.chip, color: 'var(--dsw-alias-state-success-primary, #2e7d32)' } }, M('已采纳', 'Accepted'))
|
|
2778
2805
|
: h('button', { type: 'button', style: S.btn, disabled: busy, onClick: () => adoptAbsolute(it) }, M('采纳', 'Accept')))
|
|
2779
|
-
: h('div', { style: S.hint }, M('
|
|
2806
|
+
: h('div', { style: S.hint }, M('本机没有等价目录:可忽略,或自己改文件里的路径', 'No equivalent folder on this machine: skip it, or edit that path by hand')))
|
|
2780
2807
|
return h('div', { style: { ...S.panel, gap: '6px' } },
|
|
2781
2808
|
h('div', { style: { ...S.hint, color: 'var(--dsw-alias-state-warn-primary)' } },
|
|
2782
2809
|
M(`这份配置是 ${data.absolutePaths.machine || '另一台机器'} 推送的:其中有 ${data.absolutePaths.total} 处绝对路径不属于本机任何已确认根。箭头右边是按本机情况推出来的目录,点「采纳」就记进本机自选目录——下次推送起它们变成占位符,哪台机器拉取都换回自己的路径。`,
|
|
@@ -2790,7 +2817,7 @@ window.__ModuleLoader__.load({
|
|
|
2790
2817
|
: null,
|
|
2791
2818
|
dataItems.length
|
|
2792
2819
|
? h('div', { style: S.footnote },
|
|
2793
|
-
M('
|
|
2820
|
+
M('决定工作区与历史会话落在哪个目录。已是本机路径的会自动对齐;下面这些还指着对方机器,点「采纳」补成自选目录。',
|
|
2794
2821
|
'These decide which folder a workspace opens in and which folder a session returns to. The pull already aligns them with this machine\'s workspace locations; listed below are the records still pointing at the other machine - Accept adds them as custom roots too.'))
|
|
2795
2822
|
: null,
|
|
2796
2823
|
dataItems.map(rowOf),
|
|
@@ -2967,7 +2994,7 @@ window.__ModuleLoader__.load({
|
|
|
2967
2994
|
h('div', { style: { ...S.kvVal, display: 'flex', gap: '8px' } },
|
|
2968
2995
|
h('input', {
|
|
2969
2996
|
type: 'password', style: S.input, value: token, spellCheck: false, autoComplete: 'off',
|
|
2970
|
-
placeholder: M('粘贴 GitHub
|
|
2997
|
+
placeholder: M('粘贴 GitHub 令牌(一次即可;留空则读本机 git 凭据)', 'Paste a GitHub token (once); leave empty to reuse the local git credential'),
|
|
2971
2998
|
onChange: (e) => setToken(e.target.value),
|
|
2972
2999
|
}),
|
|
2973
3000
|
h('button', { type: 'button', style: S.btnPrimary, disabled: busy || !token.trim(), onClick: saveToken }, M('保存', 'Save')),
|
|
@@ -3045,7 +3072,7 @@ window.__ModuleLoader__.load({
|
|
|
3045
3072
|
)
|
|
3046
3073
|
: h('div', { style: S.footnote }, M('还没有反馈记录。', 'No feedback yet.')),
|
|
3047
3074
|
h('div', { style: S.footnote },
|
|
3048
|
-
M('
|
|
3075
|
+
M('读列表不用令牌;提交和关单要令牌,且只有仓库所有者能关单。没令牌时提交会打开浏览器里预填好的页面。',
|
|
3049
3076
|
'Reading needs no token (public repo, 60 anonymous requests/hour); submitting and closing do, and only the repo owner can close. Without a token, submitting opens a prefilled new-issue page in the browser.')),
|
|
3050
3077
|
)
|
|
3051
3078
|
}
|
|
@@ -3185,7 +3212,7 @@ window.__ModuleLoader__.load({
|
|
|
3185
3212
|
} catch { /* 插件路由还没起好就静默跳过,面板里仍会显示同一结果 */ }
|
|
3186
3213
|
}
|
|
3187
3214
|
|
|
3188
|
-
// ==================== 0.3.
|
|
3215
|
+
// ==================== 0.3.70:会话缓存守卫(客户端半身) ====================
|
|
3189
3216
|
// 宿主侧没法拦 agent-busy(它是 sessionController 内部抛的 RemoteError),
|
|
3190
3217
|
// 所以在这里包一层 sessions.create:撞上就上报、清缓存、去掉旧 sessionId 重试一次。
|
|
3191
3218
|
const BUSY_RE = /session\/agent-busy|is owned by subagent routing/i
|
|
@@ -3282,7 +3309,7 @@ window.__ModuleLoader__.load({
|
|
|
3282
3309
|
// 界面还没完全起来时 fetch 可能扑空,所以稍等一会儿再查;只查一次,不轮询。
|
|
3283
3310
|
try { setTimeout(announceLastResult, 1500) } catch { }
|
|
3284
3311
|
|
|
3285
|
-
// 0.3.
|
|
3312
|
+
// 0.3.70:给客户端的 sessions 服务套上 agent-busy 自愈钩子。
|
|
3286
3313
|
// 拿不到 sessions(老版本宿主 / 服务还没起来)就静默跳过,面板功能不受影响。
|
|
3287
3314
|
try {
|
|
3288
3315
|
if (typeof ctx.get === 'function') {
|
package/index.js
CHANGED
|
@@ -24,7 +24,7 @@ import { closeSync, existsSync, mkdirSync, mkdtempSync, openSync, readdirSync, r
|
|
|
24
24
|
import { homedir, hostname, tmpdir } from 'node:os'
|
|
25
25
|
import { basename, dirname, isAbsolute, join, relative } from 'node:path'
|
|
26
26
|
import { fileURLToPath } from 'node:url'
|
|
27
|
-
// 0.3.
|
|
27
|
+
// 0.3.70:会话投影缓存守卫(agent-busy 自动清缓存,让缓存按日志重建)
|
|
28
28
|
import { runGuard, clearSessionCaches, appendGuardLog } from './runtime/tools/session-cache-guard.mjs'
|
|
29
29
|
|
|
30
30
|
const pluginRequire = createRequire(import.meta.url)
|
|
@@ -39,7 +39,7 @@ const ROUTE_CONFLICT = '/config-sync/conflict'
|
|
|
39
39
|
// 0.3.30:跨机路径确认(每台机器把自己的根目录报给插件一次)与问题反馈(落仓库 feedback\ 再推 GitHub)
|
|
40
40
|
const ROUTE_ROOTS = '/config-sync/roots'
|
|
41
41
|
const ROUTE_FEEDBACK = '/config-sync/feedback'
|
|
42
|
-
// 0.3.
|
|
42
|
+
// 0.3.70:会话投影缓存守卫(GET 只读扫描 / POST scan|sweep|clear|busy)
|
|
43
43
|
const ROUTE_CACHE_GUARD = '/config-sync/cache-guard'
|
|
44
44
|
const SETTINGS_NAME = 'dsh-config-sync.json'
|
|
45
45
|
/** 本插件自己的安装目录(插件根,含 runtime\ 与 index.js)—— 插件备份还原时的目标。 */
|
|
@@ -237,7 +237,7 @@ function readSettings(dshHome) {
|
|
|
237
237
|
// 同步完成重启前把 DSH 的「默认工作区」校正到谁:
|
|
238
238
|
// 留空 = 自动找名字/路径是 default-workspace 的工作区;可填工作区路径或 ID;填 off 关闭。
|
|
239
239
|
defaultWorkspace: typeof raw.defaultWorkspace === 'string' ? raw.defaultWorkspace : '',
|
|
240
|
-
// 0.3.
|
|
240
|
+
// 0.3.70:会话投影缓存守卫,默认开。关掉后既不定时扫描,也不理会客户端的 agent-busy 上报。
|
|
241
241
|
cacheGuard: raw.cacheGuard !== false,
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -1180,7 +1180,7 @@ async function inspect(config) {
|
|
|
1180
1180
|
const pending = c.items.filter((it) => !it.choice).length
|
|
1181
1181
|
return { exists: true, total: c.items.length, pending, at: c.at || '', backupDir: c.backupDir || '' }
|
|
1182
1182
|
})(),
|
|
1183
|
-
// 0.3.
|
|
1183
|
+
// 0.3.70:会话投影缓存守卫状态(面板「会话缓存守卫」卡用)
|
|
1184
1184
|
cacheGuard: cacheGuardSnapshot(config),
|
|
1185
1185
|
}
|
|
1186
1186
|
}
|
|
@@ -1499,7 +1499,7 @@ function readAutoResult(dshHome) {
|
|
|
1499
1499
|
* 就回落到 ~/.dsh/sync-notices.json。两种情况都做裁剪,避免一个几万文件的仓库把 /status 撑爆。
|
|
1500
1500
|
*/
|
|
1501
1501
|
function readNoticeList(dshHome, fromResult) {
|
|
1502
|
-
const KINDS = ['history', 'too-large', 'failed', 'skipped']
|
|
1502
|
+
const KINDS = ['plugin-missing', 'context-state', 'history', 'too-large', 'failed', 'skipped']
|
|
1503
1503
|
let raw = fromResult
|
|
1504
1504
|
if (!raw || !Array.isArray(raw.items)) {
|
|
1505
1505
|
try {
|
|
@@ -1962,7 +1962,7 @@ async function handleSettings(req, res, config) {
|
|
|
1962
1962
|
const autoPull = has('autoPull') ? body.autoPull === true : before.autoPull
|
|
1963
1963
|
const autoPush = has('autoPush') ? body.autoPush === true : before.autoPush
|
|
1964
1964
|
const autoRestart = has('autoRestart') ? body.autoRestart !== false : before.autoRestart
|
|
1965
|
-
// 0.3.
|
|
1965
|
+
// 0.3.70:会话投影缓存守卫开关,字段没给就沿用原值
|
|
1966
1966
|
const cacheGuard = has('cacheGuard') ? body.cacheGuard !== false : before.cacheGuard
|
|
1967
1967
|
|
|
1968
1968
|
if (!has('repoPath') && !has('remoteUrl') && !has('sshKey') &&
|
|
@@ -4022,7 +4022,7 @@ function newIssueUrl(repo, title, text, config) {
|
|
|
4022
4022
|
return `https://github.com/${repo}/issues/new?${q}`
|
|
4023
4023
|
}
|
|
4024
4024
|
|
|
4025
|
-
// ============================ 0.3.
|
|
4025
|
+
// ============================ 0.3.70:会话投影缓存守卫 ============================
|
|
4026
4026
|
// 背景:UI 点「新建会话」时会挑一条 summary.blank===true 的会话复用,挑中了 origin=subagent
|
|
4027
4027
|
// 的子会话就会被宿主拒绝(session/agent-busy:is owned by subagent routing)。
|
|
4028
4028
|
// 起因是投影缓存停在 session/created 那一刻(blank=true、seq=-1),而会话日志早就推进过,
|
|
@@ -4430,7 +4430,7 @@ export function apply(ctx, config) {
|
|
|
4430
4430
|
path: ROUTE_FEEDBACK,
|
|
4431
4431
|
handler: withLang(handleFeedback),
|
|
4432
4432
|
}))
|
|
4433
|
-
// 0.3.
|
|
4433
|
+
// 0.3.70:会话投影缓存守卫(GET 只读扫描 / POST scan|sweep|clear|busy)
|
|
4434
4434
|
scoped.effect(() => scoped.webServer.register({
|
|
4435
4435
|
kind: 'exact',
|
|
4436
4436
|
path: ROUTE_CACHE_GUARD,
|
|
@@ -4443,7 +4443,7 @@ export function apply(ctx, config) {
|
|
|
4443
4443
|
// status 不用再为首屏那 2.5 秒的 ls-remote 埋单。
|
|
4444
4444
|
typeof setTimeout === 'function' ? setTimeout(() => { try { warmRemoteProbe(config) } catch { } }, 300) : null
|
|
4445
4445
|
installQuitWhenAllWindowsClosed(ctx)
|
|
4446
|
-
// 0.3.
|
|
4446
|
+
// 0.3.70:会话投影缓存守卫的定时扫描(默认开,设置里可关)
|
|
4447
4447
|
scheduleCacheGuard(config)
|
|
4448
4448
|
} catch (error) {
|
|
4449
4449
|
// 不抛:缺 webServer 的 profile 里这个插件静默不激活即可
|
package/package.json
CHANGED
package/runtime/apply.ps1
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<#
|
|
2
|
-
DSH 配置同步 —— 应用脚本(把本仓库的配置还原到当前电脑)
|
|
2
|
+
DSH 配置同步 —— 应用脚本(把本仓库的配置还原到当前电脑)
|
|
3
3
|
|
|
4
4
|
用法
|
|
5
5
|
pwsh -File apply.ps1 # 默认:铺配置 + 全量还原所有工作区
|
|
@@ -59,7 +59,7 @@ $ErrorActionPreference = 'Stop'
|
|
|
59
59
|
if (-not $RepoRoot) { $RepoRoot = $PSScriptRoot }
|
|
60
60
|
. (Join-Path $PSScriptRoot 'dsh-sync-common.ps1')
|
|
61
61
|
|
|
62
|
-
if (-not $NoResetNotices) { Reset-SyncNotices $DshHome 'pull' }
|
|
62
|
+
if (-not $NoResetNotices) { Reset-SyncNotices $DshHome 'pull' } else { Set-SyncNoticeContext $DshHome 'pull' }
|
|
63
63
|
|
|
64
64
|
# 客户端可能被卸载重装到别的盘:传进来的 -AppRoot 先校验,对不上就自动定位(注册表 → 常见位置)。
|
|
65
65
|
$resolvedRoot = Resolve-DshAppRoot $AppRoot
|
|
@@ -672,6 +672,16 @@ function Sync-ConversationApply {
|
|
|
672
672
|
Warn ('没找到可用于修正会话头部的执行器(Node / 客户端 Electron 都没找到,AppRoot={0}),本次未修正' -f $AppRoot)
|
|
673
673
|
}
|
|
674
674
|
}
|
|
675
|
+
# 5) billion-context 压缩状态:DSH 原生 compaction 被 bili 接管后,真正的压缩记录在 bili 自己的
|
|
676
|
+
# SQLite(…\billion-context\sessions\index.db)里,不在 .dsh 下。不带这份状态,长会话在本机
|
|
677
|
+
# 继续时会以未压缩的全量 surface 发给 provider,报 CONTEXT_WINDOW_EXCEEDED。
|
|
678
|
+
$biliRepo = Join-Path $convDir 'billion_context'
|
|
679
|
+
if (Test-Path -LiteralPath $biliRepo) {
|
|
680
|
+
$bs = Invoke-BiliStateSync -Mode 'import' -RepoDir $biliRepo -AppRoot $AppRoot -ScriptRoot $PSScriptRoot -RepoRoot $RepoRoot
|
|
681
|
+
Write-BiliStateSyncReport $bs $DshHome
|
|
682
|
+
} else {
|
|
683
|
+
Say ' 仓库里没有 billion-context 压缩状态(首次导出前为空,属正常)'
|
|
684
|
+
}
|
|
675
685
|
Ok ('会话数据全量还原:{0} 个目录映射,写入/更新 {1} 个文件、备份 {2} 个(四块数据字节保真,会话只增不删)' -f $dirMap.Count, $nAdd, $nBk)
|
|
676
686
|
}
|
|
677
687
|
|
|
@@ -888,9 +898,13 @@ if ($dropped.Count -gt 0) { Ok "已剔除 $($dropped.Count) 个实验性 bundle
|
|
|
888
898
|
$localPluginMap = [ordered]@{
|
|
889
899
|
'dsh-our-free-model-2.8.0' = 'dsh-our-free-model'
|
|
890
900
|
'dsh-purge-1.4.0' = 'dsh-purge'
|
|
901
|
+
'dsh-config-sync-plugin-0.3.69' = 'dsh-config-sync-plugin'
|
|
902
|
+
'dsh-config-sync-plugin-0.3.70' = 'dsh-config-sync-plugin'
|
|
903
|
+
'dsh-config-sync-plugin-0.3.68' = 'dsh-config-sync-plugin'
|
|
891
904
|
'dsh-config-sync-plugin-0.3.67' = 'dsh-config-sync-plugin'
|
|
892
|
-
|
|
893
|
-
|
|
905
|
+
'dsh-config-sync-plugin-0.3.66' = 'dsh-config-sync-plugin'
|
|
906
|
+
'dsh-config-sync-plugin-0.3.65' = 'dsh-config-sync-plugin'
|
|
907
|
+
'dsh-config-sync-plugin-0.3.64' = 'dsh-config-sync-plugin'
|
|
894
908
|
'dsh-config-sync-plugin-0.3.63' = 'dsh-config-sync-plugin'
|
|
895
909
|
'dsh-config-sync-plugin-0.3.62' = 'dsh-config-sync-plugin'
|
|
896
910
|
'dsh-config-sync-plugin-0.3.61' = 'dsh-config-sync-plugin'
|
|
@@ -1332,6 +1346,7 @@ if ($needExtract.Count -gt 0) {
|
|
|
1332
1346
|
Ok "已解压并部署:$final"
|
|
1333
1347
|
} else {
|
|
1334
1348
|
Warn "仓库里没有 $dirName 的归档,跳过(该插件会装不上)"
|
|
1349
|
+
Add-SyncNotice -Kind 'plugin-missing' -Path $dirName -Reason ('仓库的 local-plugins\ 里没有这个源码插件包的归档(.tgz/.zip),本机装不上。在主力机跑 capture.ps1 -PackLocalPlugins 打包并推送,然后在本机重新拉取一次。')
|
|
1335
1350
|
}
|
|
1336
1351
|
}
|
|
1337
1352
|
Remove-Item -LiteralPath $staging -Recurse -Force -ErrorAction SilentlyContinue
|
|
@@ -1479,8 +1494,21 @@ foreach ($name in $deps.PSObject.Properties.Name) {
|
|
|
1479
1494
|
$probe = Join-Path $ProfileDir ("node_modules\" + ($name -replace '/', '\'))
|
|
1480
1495
|
if (-not (Test-Path -LiteralPath $probe)) { $missing += $name }
|
|
1481
1496
|
}
|
|
1482
|
-
if ($missing.Count -eq 0) {
|
|
1483
|
-
|
|
1497
|
+
if ($missing.Count -eq 0) {
|
|
1498
|
+
Ok "全部 $(@($deps.PSObject.Properties).Count) 个插件依赖已就位"
|
|
1499
|
+
} else {
|
|
1500
|
+
Warn ("缺少 $($missing.Count) 个插件:" + ($missing -join ', '))
|
|
1501
|
+
# 拉取只还原配置文件,不会替本机安装依赖:仓库里没有这些插件的实体(它们该由 pnpm install 从
|
|
1502
|
+
# registry 装,或从 local-plugins 的归档解压)。把每一个都记进未同步清单,面板会常驻提示
|
|
1503
|
+
# 「装好插件后再拉取一次」,否则用户只看到插件页少几项、不知道下一步做什么。
|
|
1504
|
+
foreach ($nm in $missing) {
|
|
1505
|
+
$why = '插件未安装到本机:拉取不会替你装依赖。'
|
|
1506
|
+
if ($SkipInstall) { $why += '本次带了 -SkipInstall,pnpm install 被跳过;' }
|
|
1507
|
+
$why += '在 profile 目录执行一次 pnpm install(或去掉 -SkipInstall 重跑本脚本),装好后重新拉取一次。'
|
|
1508
|
+
Add-SyncNotice -Kind 'plugin-missing' -Path $nm -Reason $why
|
|
1509
|
+
}
|
|
1510
|
+
Warn '已把这些插件记进未同步清单(sync-notices.json),面板会一直提示到装好并重新拉取为止。'
|
|
1511
|
+
}
|
|
1484
1512
|
|
|
1485
1513
|
# bundle 可解析性检查:清单里写了、本机却没有 → 启动期 entry loading 必挂(整个应用起不来,不是功能不可用)
|
|
1486
1514
|
# 解析顺序与 DSH 一致:先 profile\node_modules(pnpm 装的),再 <AppRoot>\resources\app\dsh\node_modules(宿主自带)
|
|
@@ -1497,6 +1525,9 @@ if ($unresolved.Count -eq 0) {
|
|
|
1497
1525
|
} else {
|
|
1498
1526
|
Warn "以下 $($unresolved.Count) 个 bundle 在本机找不到,启动会在 entry loading 阶段失败:"
|
|
1499
1527
|
$unresolved | ForEach-Object { Warn " - $_" }
|
|
1528
|
+
foreach ($ub in $unresolved) {
|
|
1529
|
+
Add-SyncNotice -Kind 'plugin-missing' -Path $ub -Reason ('bundle 在本机解析不到:插件没装好(pnpm install 没成功,或仓库里没有这个插件的归档)。装好后重新拉取一次;若它是宿主绑定的实验性 bundle,删掉本机 profile\package.json 里那一行。')
|
|
1530
|
+
}
|
|
1500
1531
|
if (-not $ForceBundles) {
|
|
1501
1532
|
Die ("已停止,先别启动。处理:①若上面「缺少插件」不为空,说明 pnpm install 没成功;" +
|
|
1502
1533
|
"②若是宿主绑定的实验性 bundle,直接删掉本机 profile\package.json 里那一行;" +
|
package/runtime/capture.ps1
CHANGED
|
@@ -93,7 +93,7 @@ function Get-TreeCmpSummary {
|
|
|
93
93
|
return ('文件比较({0}):比对 {1} 个,深哈希 {2} 个' -f $deep, $script:CmpFileCount, $script:CmpHashCount)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
if (-not $NoResetNotices) { Reset-SyncNotices $DshHome 'capture' }
|
|
96
|
+
if (-not $NoResetNotices) { Reset-SyncNotices $DshHome 'capture' } else { Set-SyncNoticeContext $DshHome 'capture' }
|
|
97
97
|
|
|
98
98
|
# 客户端可能被卸载重装到别的盘:-AppRoot 先校验,对不上就自动定位(注册表 → 常见位置)。
|
|
99
99
|
$resolvedRoot = Resolve-DshAppRoot $AppRoot
|
|
@@ -437,6 +437,8 @@ function Sync-ConversationCapture {
|
|
|
437
437
|
@{ Src = (Join-Path $DshHome 'storages\vision_router_session_policy\policies'); Dst = 'vision_router_session_policy'; Remap = $false }
|
|
438
438
|
)
|
|
439
439
|
$nAdd = 0; $nDel = 0
|
|
440
|
+
# 本次真正写入过的会话 id(用来只导出这些会话的 billion-context 压缩状态)
|
|
441
|
+
$touchedSids = [System.Collections.Generic.List[string]]::new()
|
|
440
442
|
foreach ($b in $blocks) {
|
|
441
443
|
$dstRoot = Join-Path $convDir $b.Dst
|
|
442
444
|
if (-not (Test-Path -LiteralPath $b.Src)) { Warn ('本机没有会话数据块,跳过:{0}' -f $b.Src); continue }
|
|
@@ -472,6 +474,13 @@ function Sync-ConversationCapture {
|
|
|
472
474
|
if (-not (Test-Path -LiteralPath $dd)) { New-Item -ItemType Directory -Path $dd -Force | Out-Null }
|
|
473
475
|
$madeDirs[$dd] = $true
|
|
474
476
|
}
|
|
477
|
+
if ($b.Dst -eq 'sessions') {
|
|
478
|
+
$rp = @($rel -split '\\')
|
|
479
|
+
if ($rp.Count -ge 2) {
|
|
480
|
+
$sid = [string]$rp[1]
|
|
481
|
+
if ($sid -and -not $touchedSids.Contains($sid)) { $touchedSids.Add($sid) | Out-Null }
|
|
482
|
+
}
|
|
483
|
+
}
|
|
475
484
|
if (Test-SessionLogFile $rel) {
|
|
476
485
|
$guardJobs.Add([ordered]@{ Src = $si.FullName; Dst = $d; WriteTo = $d }) | Out-Null
|
|
477
486
|
$dstRels[$rel] = [IO.FileInfo]::new($d)
|
|
@@ -512,6 +521,16 @@ function Sync-ConversationCapture {
|
|
|
512
521
|
}
|
|
513
522
|
}
|
|
514
523
|
}
|
|
524
|
+
# 4) billion-context 压缩状态:DSH 原生 compaction 被 bili 接管后,真正的压缩记录在 bili 自己的
|
|
525
|
+
# SQLite 里(不在 .dsh 下)。只带会话日志、不带这份状态,另一台机器会把未压缩的全量 surface
|
|
526
|
+
# 发给 provider 并报 CONTEXT_WINDOW_EXCEEDED。这里按会话导出 blocks/refs/summary。
|
|
527
|
+
if ($touchedSids.Count -gt 0) {
|
|
528
|
+
$biliRepo = Join-Path $convDir 'billion_context'
|
|
529
|
+
$bs = Invoke-BiliStateSync -Mode 'export' -RepoDir $biliRepo -Sessions $touchedSids.ToArray() -AppRoot $AppRoot -ScriptRoot $PSScriptRoot -RepoRoot $RepoRoot
|
|
530
|
+
Write-BiliStateSyncReport $bs $DshHome
|
|
531
|
+
} else {
|
|
532
|
+
Say ' 本次没有会话变动,跳过 billion-context 压缩状态导出'
|
|
533
|
+
}
|
|
515
534
|
Ok ('会话数据全量同步:{0} 个目录映射,入库/更新 {1} 个文件、删除 {2} 个(四块数据全部字节保真)' -f $idxEntries.Count, $nAdd, $nDel)
|
|
516
535
|
Say (' ' + (Get-TreeCmpSummary))
|
|
517
536
|
|