dsh-config-manager 0.7.0 → 0.8.1
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/lib/adapters/mcp.d.ts +6 -1
- package/lib/adapters/mcp.js +22 -4
- package/lib/adapters/test-helpers.d.ts +7 -0
- package/lib/adapters/test-helpers.js +11 -0
- package/lib/cli/actions.js +1 -1
- package/lib/client.d.ts +9 -2
- package/lib/client.js +683 -647
- package/lib/core/backup.d.ts +9 -1
- package/lib/core/backup.js +21 -0
- package/lib/core/messages-core.d.ts +3 -0
- package/lib/core/messages-core.js +6 -0
- package/lib/core/messages.d.ts +7 -0
- package/lib/core/messages.js +14 -0
- package/lib/core/model-tools.js +2 -0
- package/lib/core/patch-document.d.ts +65 -0
- package/lib/core/patch-document.js +161 -0
- package/lib/core/phase4-crash-child.js +1 -1
- package/lib/core/plugin-cli.d.ts +11 -0
- package/lib/core/plugin-cli.js +30 -0
- package/lib/core/restore-wal.d.ts +2 -0
- package/lib/core/restore-wal.js +11 -6
- package/lib/core/restore.d.ts +15 -2
- package/lib/core/restore.js +65 -3
- package/lib/core/snapshot-diff.js +2 -1
- package/lib/core/types.d.ts +32 -0
- package/lib/index.d.ts +8 -1
- package/lib/index.js +51 -68
- package/lib/routes/route-support.d.ts +5 -0
- package/lib/routes/route-support.js +28 -2
- package/lib/routes/sync.js +3 -0
- package/lib/sync/merge-preview-view.d.ts +78 -0
- package/lib/sync/merge-preview-view.js +46 -0
- package/lib/sync/merge.d.ts +2 -1
- package/lib/sync/merge.js +9 -4
- package/lib/sync/plugin-removal-apply.d.ts +95 -0
- package/lib/sync/plugin-removal-apply.js +158 -0
- package/lib/sync/plugin-removals.d.ts +90 -0
- package/lib/sync/plugin-removals.js +167 -0
- package/lib/sync/sync-engine.d.ts +34 -43
- package/lib/sync/sync-engine.js +50 -42
- package/lib/sync/sync-selection.d.ts +8 -0
- package/lib/sync/sync-selection.js +6 -0
- package/lib/sync/workspace-merge.d.ts +8 -1
- package/lib/ui/restore-plan-view.js +1 -0
- package/lib/ui/sync-settings-view.d.ts +10 -0
- package/lib/ui/sync-settings-view.js +2 -0
- package/package.json +1 -1
- package/src/adapters/mcp.test.ts +23 -3
- package/src/adapters/mcp.ts +24 -4
- package/src/adapters/test-helpers.ts +10 -0
- package/src/cli/actions.ts +1 -1
- package/src/client/common/info-hint-guard.test.ts +2 -1
- package/src/client/run-store.test.ts +7 -5
- package/src/client/run-store.ts +4 -5
- package/src/client/sync/SyncPanel.tsx +10 -0
- package/src/client/sync/SyncSectionPickerDialog.tsx +17 -1
- package/src/client/sync/sync-locales.ts +4 -0
- package/src/client/sync/sync-view.ts +6 -0
- package/src/core/backup.ts +21 -1
- package/src/core/messages-core.ts +6 -0
- package/src/core/messages.ts +14 -0
- package/src/core/model-tools.ts +2 -0
- package/src/core/patch-document.test.ts +107 -0
- package/src/core/patch-document.ts +194 -0
- package/src/core/phase4-crash-child.ts +1 -1
- package/src/core/plugin-cli.ts +37 -0
- package/src/core/restore-plugin-install.test.ts +116 -0
- package/src/core/restore-wal.ts +12 -6
- package/src/core/restore.ts +79 -4
- package/src/core/smoke.test.ts +5 -0
- package/src/core/snapshot-diff.test.ts +1 -1
- package/src/core/snapshot-diff.ts +2 -1
- package/src/core/types.ts +31 -0
- package/src/index.facade.test.ts +83 -1
- package/src/index.ts +57 -67
- package/src/routes/route-support.ts +27 -2
- package/src/routes/sync.ts +3 -0
- package/src/security/security.test.ts +1 -0
- package/src/sync/merge-preview-view.ts +97 -0
- package/src/sync/merge.test.ts +17 -15
- package/src/sync/merge.ts +10 -3
- package/src/sync/plugin-removal-apply.ts +198 -0
- package/src/sync/plugin-removals.test.ts +221 -0
- package/src/sync/plugin-removals.ts +208 -0
- package/src/sync/sync-engine.test.ts +251 -1
- package/src/sync/sync-engine.ts +84 -83
- package/src/sync/sync-selection.test.ts +29 -7
- package/src/sync/sync-selection.ts +13 -0
- package/src/sync/workspace-merge.ts +9 -0
- package/src/ui/restore-plan-view.test.ts +1 -1
- package/src/ui/restore-plan-view.ts +1 -0
- package/src/ui/snapshots-view.test.ts +1 -1
- package/src/ui/sync-settings-view.test.ts +20 -0
- package/src/ui/sync-settings-view.ts +12 -0
- package/src/utils/patch-yaml.test.ts +1 -1
|
@@ -60,6 +60,14 @@ export interface SyncSelection {
|
|
|
60
60
|
encrypt: boolean;
|
|
61
61
|
/** 手动推送默认导出真实凭据值(安全:必须同时 encrypt;自动同步恒 false) */
|
|
62
62
|
includeSecrets: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* 跟随远端删除插件(issue #132;缺省 **false** = 既有行为逐字不变)。
|
|
65
|
+
*
|
|
66
|
+
* 打开后:祖先快照里有、远端快照里没有、且本机未改过的插件,手动合并与自动同步都会执行
|
|
67
|
+
* `dsh plugin remove`(开关本身就是用户的显式授权,见 docs/known-issues/known-gaps.md G-20)。
|
|
68
|
+
* 关闭时一律不删(候选降级为 `switch-off`,报告里逐项写明原因)。
|
|
69
|
+
*/
|
|
70
|
+
deletePlugins: boolean;
|
|
63
71
|
}
|
|
64
72
|
|
|
65
73
|
/** 全通道选择视图(v2 文件直接读取;status 路由一次返回两个通道的选择)。 */
|
|
@@ -107,6 +115,7 @@ export function defaultSyncSelection(): SyncSelection {
|
|
|
107
115
|
sessionsInclude: [],
|
|
108
116
|
encrypt: false,
|
|
109
117
|
includeSecrets: false,
|
|
118
|
+
deletePlugins: false,
|
|
110
119
|
};
|
|
111
120
|
}
|
|
112
121
|
|
|
@@ -155,6 +164,8 @@ function parseChannelSelection(obj: Record<string, unknown>): SyncSelection {
|
|
|
155
164
|
sel.sessionsInclude = normalizeSessionsInclude(obj['sessionsInclude']);
|
|
156
165
|
if (typeof obj['encrypt'] === 'boolean') sel.encrypt = obj['encrypt'];
|
|
157
166
|
if (typeof obj['includeSecrets'] === 'boolean') sel.includeSecrets = obj['includeSecrets'];
|
|
167
|
+
// issue #132:缺字段 = 旧文件 = 关(绝不把「没这个字段」解释成「用户同意删插件」)
|
|
168
|
+
if (typeof obj['deletePlugins'] === 'boolean') sel.deletePlugins = obj['deletePlugins'];
|
|
158
169
|
// 安全兜底:持久化数据被篡改导致 includeSecrets 但未 encrypt → 强制关掉导出密钥
|
|
159
170
|
if (sel.includeSecrets && !sel.encrypt) sel.includeSecrets = false;
|
|
160
171
|
return sel;
|
|
@@ -246,6 +257,8 @@ export async function writeSyncSelection(dir: string, channel: SyncTransportType
|
|
|
246
257
|
sessionsInclude: channels[ch].sessionsInclude,
|
|
247
258
|
encrypt: channels[ch].encrypt,
|
|
248
259
|
includeSecrets: channels[ch].includeSecrets,
|
|
260
|
+
// issue #132:落盘白名单漏写 = 用户勾了开关、重启后静默变回关(P0-3 的同一类错)
|
|
261
|
+
deletePlugins: channels[ch].deletePlugins,
|
|
249
262
|
})),
|
|
250
263
|
};
|
|
251
264
|
const target = path.join(dir, SYNC_SELECTION_FILE);
|
|
@@ -32,11 +32,20 @@ export interface GranularMergeOutcome {
|
|
|
32
32
|
mergePoints: number;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* 钩子可读的合并上下文:目前只有 plugins 需要 —— 「跟随远端删除插件」是用户开关,
|
|
37
|
+
* 关着时钩子必须**不参与**(交给通用路径 = 与未引入 #132 前逐字一致),否则会静默丢掉本机条目。
|
|
38
|
+
*/
|
|
39
|
+
export interface GranularMergeHooks {
|
|
40
|
+
deletePlugins?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
35
43
|
/** 记录级合并钩子签名(`merge.ts` 按分区 id 调用;返回 undefined = 不参与,走通用路径)。 */
|
|
36
44
|
export type GranularMerger = (
|
|
37
45
|
local: SectionData,
|
|
38
46
|
remote: SectionData,
|
|
39
47
|
ancestor: SectionData | undefined,
|
|
48
|
+
hooks?: GranularMergeHooks,
|
|
40
49
|
) => GranularMergeOutcome | undefined;
|
|
41
50
|
|
|
42
51
|
function isWorkspaces(data: SectionData | undefined): data is WorkspacesSection {
|
|
@@ -14,7 +14,7 @@ function plan(): RestorePlan {
|
|
|
14
14
|
createdAt: '2026-09-21T00:00:00.000Z',
|
|
15
15
|
sourceZip: 'x.zip',
|
|
16
16
|
pluginBaselineConfirmed: true,
|
|
17
|
-
summary: { hostFileRestores: 1, hostFileRemoves: 1, pluginRemoves: 1, fileRestores: 1, fileRemoves: 0, credentialHints: 1, skips: 3 },
|
|
17
|
+
summary: { hostFileRestores: 1, hostFileRemoves: 1, pluginRemoves: 1, pluginInstalls: 0, fileRestores: 1, fileRemoves: 0, credentialHints: 1, skips: 3 },
|
|
18
18
|
actions: [
|
|
19
19
|
{ kind: 'hostFileRestore', description: '整文件还原 settings.yaml', target: 'settings.yaml', blobPath: 'blobs/a', detail: '会先备份' },
|
|
20
20
|
{ kind: 'fileRestore', description: '还原文件 skills/x.md', target: 'skills/x.md', blobPath: 'blobs/b' },
|
|
@@ -43,7 +43,7 @@ const planOf = (kinds: RestoreActionKind[]): RestorePlan => ({
|
|
|
43
43
|
sourceZip: 'dsh-config.zip',
|
|
44
44
|
actions: kinds.map((kind) => ({ kind, description: kind })),
|
|
45
45
|
summary: {
|
|
46
|
-
hostFileRestores: 0, hostFileRemoves: 0, pluginRemoves: 0,
|
|
46
|
+
hostFileRestores: 0, hostFileRemoves: 0, pluginRemoves: 0, pluginInstalls: 0,
|
|
47
47
|
fileRestores: 0, fileRemoves: 0, credentialHints: 0, skips: 0,
|
|
48
48
|
},
|
|
49
49
|
pluginBaselineConfirmed: false,
|
|
@@ -64,6 +64,7 @@ function settings(overrides: Partial<SyncChannelSettings> = {}): SyncChannelSett
|
|
|
64
64
|
sessionsInclude: [],
|
|
65
65
|
encrypt: false,
|
|
66
66
|
includeSecrets: false,
|
|
67
|
+
deletePlugins: false,
|
|
67
68
|
encryptPassword: '',
|
|
68
69
|
encryptPasswordConfirm: '',
|
|
69
70
|
encryptPasswordSaved: false,
|
|
@@ -265,6 +266,8 @@ test('sync-settings-view: 通道回填 —— 无持久化 → 缺省值;密
|
|
|
265
266
|
sessionsInclude: [],
|
|
266
267
|
encrypt: false,
|
|
267
268
|
includeSecrets: false,
|
|
269
|
+
// 宿主没给 selection → 破坏性开关缺省关(issue #132)
|
|
270
|
+
deletePlugins: false,
|
|
268
271
|
encryptPasswordSaved: false,
|
|
269
272
|
decryptPasswordSaved: false,
|
|
270
273
|
autosyncEnabled: false,
|
|
@@ -288,6 +291,17 @@ test('sync-settings-view: 通道回填 —— 持久化值优先;用户主动
|
|
|
288
291
|
assert.equal(backfill.decryptPasswordSaved, true)
|
|
289
292
|
assert.equal(backfill.autosyncEnabled, true)
|
|
290
293
|
assert.equal(backfill.autosyncInterval, '6h')
|
|
294
|
+
// issue #132:开关以宿主 selection 为权威;宿主没给(undefined)= 关
|
|
295
|
+
assert.equal(backfill.deletePlugins, false)
|
|
296
|
+
|
|
297
|
+
const switchedOn = channelBackfillFromStatus({
|
|
298
|
+
selection: { sessionsLimit: 12, deletePlugins: true },
|
|
299
|
+
autosync: { enabled: true, interval: '6h' },
|
|
300
|
+
credentials: { encryptPasswordConfigured: true, decryptPasswordConfigured: true },
|
|
301
|
+
persistedSections: [],
|
|
302
|
+
sessionsLimit: 12,
|
|
303
|
+
})
|
|
304
|
+
assert.equal(switchedOn.deletePlugins, true)
|
|
291
305
|
})
|
|
292
306
|
|
|
293
307
|
/* ------------------------------------ 分区选择请求体 + 配置保存状态机 */
|
|
@@ -302,6 +316,8 @@ test('sync-settings-view: 分区选择请求体 —— 未给出的字段沿用
|
|
|
302
316
|
sessionsInclude: [],
|
|
303
317
|
encrypt: true,
|
|
304
318
|
includeSecrets: true,
|
|
319
|
+
// issue #132:破坏性开关必须显式随请求体发出(缺省关)
|
|
320
|
+
deletePlugins: false,
|
|
305
321
|
})
|
|
306
322
|
|
|
307
323
|
const patched = buildSelectionRequest('git', current, { sections: ['settings'], encryptPassword: '', decryptPassword: 'D' })
|
|
@@ -312,6 +328,10 @@ test('sync-settings-view: 分区选择请求体 —— 未给出的字段沿用
|
|
|
312
328
|
const clearing = buildSelectionRequest('git', current, { clearEncryptPassword: true, encryptPassword: 'new' })
|
|
313
329
|
assert.equal(clearing.clearEncryptPassword, true)
|
|
314
330
|
assert.equal(clearing.encryptPassword, 'new', '删除与写入可同时出现(Host 侧删除优先)')
|
|
331
|
+
|
|
332
|
+
// issue #132:开关只由 patch 携带;未给时沿用当前通道值,不会被静默关掉
|
|
333
|
+
assert.equal(buildSelectionRequest('git', settings({ deletePlugins: true })).deletePlugins, true)
|
|
334
|
+
assert.equal(buildSelectionRequest('git', current, { deletePlugins: true }).deletePlugins, true)
|
|
315
335
|
})
|
|
316
336
|
|
|
317
337
|
test('sync-settings-view: 保存防重入状态机 —— 在途期间的改动结束后补发,flush 优先待发', () => {
|
|
@@ -84,6 +84,11 @@ export interface SyncChannelSettings {
|
|
|
84
84
|
sessionsInclude: readonly string[]
|
|
85
85
|
encrypt: boolean
|
|
86
86
|
includeSecrets: boolean
|
|
87
|
+
/**
|
|
88
|
+
* 跟随远端删除插件(issue #132,缺省 **false**):祖先有、远端没有、本机未改过的插件
|
|
89
|
+
* 会执行 `dsh plugin remove`。勾上 = 用户显式授权手动合并与自动同步都删。
|
|
90
|
+
*/
|
|
91
|
+
deletePlugins: boolean
|
|
87
92
|
encryptPassword: string
|
|
88
93
|
encryptPasswordConfirm: string
|
|
89
94
|
/** 本机凭据库里是否已有密码(只回布尔,值永不回浏览器) */
|
|
@@ -151,6 +156,7 @@ export interface SyncSelectionRequestBody {
|
|
|
151
156
|
sessionsInclude: string[]
|
|
152
157
|
encrypt: boolean
|
|
153
158
|
includeSecrets: boolean
|
|
159
|
+
deletePlugins: boolean
|
|
154
160
|
encryptPassword?: string
|
|
155
161
|
decryptPassword?: string
|
|
156
162
|
clearEncryptPassword?: boolean
|
|
@@ -164,6 +170,7 @@ export interface SyncSelectionPatch {
|
|
|
164
170
|
sessionsInclude?: string[]
|
|
165
171
|
encrypt?: boolean
|
|
166
172
|
includeSecrets?: boolean
|
|
173
|
+
deletePlugins?: boolean
|
|
167
174
|
encryptPassword?: string
|
|
168
175
|
decryptPassword?: string
|
|
169
176
|
clearEncryptPassword?: boolean
|
|
@@ -177,6 +184,7 @@ export interface SyncChannelSettingsPatch {
|
|
|
177
184
|
sessionsInclude?: string[]
|
|
178
185
|
encrypt?: boolean
|
|
179
186
|
includeSecrets?: boolean
|
|
187
|
+
deletePlugins?: boolean
|
|
180
188
|
encryptPassword?: string
|
|
181
189
|
encryptPasswordConfirm?: string
|
|
182
190
|
encryptPasswordSaved?: boolean
|
|
@@ -192,6 +200,7 @@ export interface SyncChannelBackfill {
|
|
|
192
200
|
sessionsInclude: string[]
|
|
193
201
|
encrypt: boolean
|
|
194
202
|
includeSecrets: boolean
|
|
203
|
+
deletePlugins: boolean
|
|
195
204
|
encryptPasswordSaved: boolean
|
|
196
205
|
decryptPasswordSaved: boolean
|
|
197
206
|
autosyncEnabled: boolean
|
|
@@ -204,6 +213,7 @@ export interface SyncSelectionLike {
|
|
|
204
213
|
sessionsInclude?: string[]
|
|
205
214
|
encrypt?: boolean
|
|
206
215
|
includeSecrets?: boolean
|
|
216
|
+
deletePlugins?: boolean
|
|
207
217
|
}
|
|
208
218
|
|
|
209
219
|
/** 按通道的自动同步状态(/sync/status 的 autosyncByChannel[ch])。 */
|
|
@@ -565,6 +575,7 @@ export function buildSelectionRequest(
|
|
|
565
575
|
sessionsInclude: [...(patch.sessionsInclude ?? current.sessionsInclude)],
|
|
566
576
|
encrypt: patch.encrypt ?? current.encrypt,
|
|
567
577
|
includeSecrets: patch.includeSecrets ?? current.includeSecrets,
|
|
578
|
+
deletePlugins: patch.deletePlugins ?? current.deletePlugins,
|
|
568
579
|
...(patch.encryptPassword !== undefined && patch.encryptPassword !== ''
|
|
569
580
|
? { encryptPassword: patch.encryptPassword }
|
|
570
581
|
: {}),
|
|
@@ -731,6 +742,7 @@ export function channelBackfillFromStatus(input: {
|
|
|
731
742
|
sessionsInclude: [...(selection?.sessionsInclude ?? [])],
|
|
732
743
|
encrypt: selection?.encrypt ?? false,
|
|
733
744
|
includeSecrets: selection?.includeSecrets ?? false,
|
|
745
|
+
deletePlugins: selection?.deletePlugins ?? false,
|
|
734
746
|
encryptPasswordSaved: credentials?.encryptPasswordConfigured ?? false,
|
|
735
747
|
decryptPasswordSaved: credentials?.decryptPasswordConfigured ?? false,
|
|
736
748
|
autosyncEnabled: autosync?.enabled ?? false,
|
|
@@ -102,7 +102,7 @@ test('接线守卫:patch 门面与 boot-safety 的 YAML 解析都必须走本
|
|
|
102
102
|
|
|
103
103
|
assert.ok(index.includes('doc = loadPatchDocument(text)'), 'readPatchLines 必须用方言载入');
|
|
104
104
|
assert.ok(index.includes('doc = loadPatchDocument(existing)'), 'applyPatchChanges 必须用方言载入既有文件');
|
|
105
|
-
assert.
|
|
105
|
+
assert.match(index, /\+ dumpPatchDocument\((out|plan\.items)\)/, '写回 patch 文件必须用方言(yaml.dump 会把 {__jsExpr} 写成普通 map)');
|
|
106
106
|
assert.match(
|
|
107
107
|
index,
|
|
108
108
|
/parseYaml:\s*\(text\)\s*=>\s*loadPatchDocument\(text\)/,
|