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
package/lib/adapters/mcp.d.ts
CHANGED
|
@@ -41,7 +41,12 @@ export declare function extractMcpServers(lines: {
|
|
|
41
41
|
* 为非空字符串),否则两边会漂。返回 undefined = 该行只剩 MCP 条目,整行丢弃。
|
|
42
42
|
*/
|
|
43
43
|
export declare function stripMcpEntries(raw: unknown): unknown | undefined;
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* 由导出条目构造写回 patch 行 raw(单行形态,与 dsh-mcp-client 组合 config 语义一致)。
|
|
46
|
+
*
|
|
47
|
+
* `config.transport` 必须显式写:读侧靠它判定 server 类型,只在「没有 transport 的旧行」
|
|
48
|
+
* 上才回落 url 猜测(issue #133:此前写回丢了这个字段,stdio/http 只能靠 url 有没有值猜)。
|
|
49
|
+
*/
|
|
45
50
|
export declare function buildMcpPatchLine(lineId: string, server: McpServerEntry): Record<string, unknown>;
|
|
46
51
|
/**
|
|
47
52
|
* 单元 id:两条数据源各自独立前缀。
|
package/lib/adapters/mcp.js
CHANGED
|
@@ -33,7 +33,8 @@ export function extractMcpServers(lines) {
|
|
|
33
33
|
const serverName = c['serverName'];
|
|
34
34
|
if (typeof serverName !== 'string' || serverName === '')
|
|
35
35
|
continue;
|
|
36
|
-
|
|
36
|
+
// transport 优先(写回时一定有);老行没有该字段才回落「有 url = 远程」的猜测
|
|
37
|
+
const type = mcpTransportOf(c) ?? (typeof c['url'] === 'string' && c['url'] !== '' ? 'streamable-http' : 'stdio');
|
|
37
38
|
servers.push({
|
|
38
39
|
serverName,
|
|
39
40
|
type,
|
|
@@ -77,6 +78,11 @@ export function stripMcpEntries(raw) {
|
|
|
77
78
|
return raw;
|
|
78
79
|
return isMcpEntry(single[0]) ? undefined : raw;
|
|
79
80
|
}
|
|
81
|
+
/** `config.transport` 的合法取值;读不出来(缺字段/写错)返回 undefined,由调用方回落 url 判定。 */
|
|
82
|
+
function mcpTransportOf(c) {
|
|
83
|
+
const transport = c['transport'];
|
|
84
|
+
return transport === 'stdio' || transport === 'streamable-http' ? transport : undefined;
|
|
85
|
+
}
|
|
80
86
|
/** 单个 patch entry 是否是 MCP 服务器行(与 extractMcpServers 的判定同口径) */
|
|
81
87
|
function isMcpEntry(entry) {
|
|
82
88
|
if (entry === null || typeof entry !== 'object')
|
|
@@ -102,9 +108,21 @@ function entriesOf(raw) {
|
|
|
102
108
|
}
|
|
103
109
|
return [];
|
|
104
110
|
}
|
|
105
|
-
/**
|
|
111
|
+
/**
|
|
112
|
+
* MCP server 行的包名(bundle id,**必须带 scope**)。
|
|
113
|
+
*
|
|
114
|
+
* 宿主按 bundle id 解析 patch 行的 `name`;裸名 `dsh-mcp-client` 是否被归一化未经验证,
|
|
115
|
+
* 而用户机上的真实行都是 `@deepseek-ai/dsh-mcp-client`(issue #133 报告的原始行)。
|
|
116
|
+
*/
|
|
117
|
+
const MCP_BUNDLE_NAME = '@deepseek-ai/dsh-mcp-client';
|
|
118
|
+
/**
|
|
119
|
+
* 由导出条目构造写回 patch 行 raw(单行形态,与 dsh-mcp-client 组合 config 语义一致)。
|
|
120
|
+
*
|
|
121
|
+
* `config.transport` 必须显式写:读侧靠它判定 server 类型,只在「没有 transport 的旧行」
|
|
122
|
+
* 上才回落 url 猜测(issue #133:此前写回丢了这个字段,stdio/http 只能靠 url 有没有值猜)。
|
|
123
|
+
*/
|
|
106
124
|
export function buildMcpPatchLine(lineId, server) {
|
|
107
|
-
const config = { serverName: server.serverName };
|
|
125
|
+
const config = { serverName: server.serverName, transport: server.type };
|
|
108
126
|
if (server.type === 'streamable-http') {
|
|
109
127
|
config['url'] = server.url;
|
|
110
128
|
if (server.headers !== undefined)
|
|
@@ -119,7 +137,7 @@ export function buildMcpPatchLine(lineId, server) {
|
|
|
119
137
|
if (server.cwd !== undefined)
|
|
120
138
|
config['cwd'] = server.cwd;
|
|
121
139
|
}
|
|
122
|
-
return { id: lineId, name:
|
|
140
|
+
return { id: lineId, name: MCP_BUNDLE_NAME, config };
|
|
123
141
|
}
|
|
124
142
|
/** 连接器计划项的 id 前缀(导入时按前缀分派到 applyConnectorItem) */
|
|
125
143
|
const MCP_CONNECTOR_ITEM_PREFIX = 'mcp-connector:';
|
|
@@ -98,6 +98,13 @@ export declare class MemPlugins implements PluginsFacade {
|
|
|
98
98
|
install(pkg: string, spec?: string): Promise<{
|
|
99
99
|
needsRestart: boolean;
|
|
100
100
|
}>;
|
|
101
|
+
/** 测试钩子:卸载失败(模拟 desktop 保留档案被 CLI 拒绝) */
|
|
102
|
+
failUninstall: boolean;
|
|
103
|
+
/** 最近一次 uninstall 收到的包名(验证只删该删的那个) */
|
|
104
|
+
lastUninstalled: string | undefined;
|
|
105
|
+
uninstall(pkg: string): Promise<{
|
|
106
|
+
needsRestart: boolean;
|
|
107
|
+
}>;
|
|
101
108
|
}
|
|
102
109
|
export declare class MemWorkspace implements WorkspaceFacade {
|
|
103
110
|
records: Map<string, WorkspaceRecord>;
|
|
@@ -166,6 +166,17 @@ export class MemPlugins {
|
|
|
166
166
|
this.installed.set(pkg, { name: pkg, version: '1.0.0', enabled: true, spec });
|
|
167
167
|
return { needsRestart: true };
|
|
168
168
|
}
|
|
169
|
+
/** 测试钩子:卸载失败(模拟 desktop 保留档案被 CLI 拒绝) */
|
|
170
|
+
failUninstall = false;
|
|
171
|
+
/** 最近一次 uninstall 收到的包名(验证只删该删的那个) */
|
|
172
|
+
lastUninstalled;
|
|
173
|
+
async uninstall(pkg) {
|
|
174
|
+
if (this.failUninstall)
|
|
175
|
+
throw new Error(`profile "desktop" is managed exclusively by the Electron application`);
|
|
176
|
+
this.lastUninstalled = pkg;
|
|
177
|
+
this.installed.delete(pkg);
|
|
178
|
+
return { needsRestart: true };
|
|
179
|
+
}
|
|
169
180
|
}
|
|
170
181
|
export class MemWorkspace {
|
|
171
182
|
records = new Map();
|
package/lib/cli/actions.js
CHANGED
|
@@ -857,7 +857,7 @@ export async function unlockEncryptedBackup(exportsDir, fileName, password) {
|
|
|
857
857
|
}
|
|
858
858
|
/** 危险动作判定:会改动磁盘的分区(skip / credentialHint 不算)。 */
|
|
859
859
|
function isDangerousRestoreKind(kind) {
|
|
860
|
-
return kind === 'hostFileRestore' || kind === 'hostFileRemove' || kind === 'fileRestore' || kind === 'fileRemove' || kind === 'pluginRemove';
|
|
860
|
+
return kind === 'hostFileRestore' || kind === 'hostFileRemove' || kind === 'fileRestore' || kind === 'fileRemove' || kind === 'pluginRemove' || kind === 'pluginInstall';
|
|
861
861
|
}
|
|
862
862
|
/** 本机 DSH 包名(T8-F3;与 core/restore.ts 的 `DSH_PACKAGE_NAME` 同值 —— 两处读的是同一个文件)。 */
|
|
863
863
|
const DSH_PACKAGE_NAME = '@deepseek-ai/dsh';
|
package/lib/client.d.ts
CHANGED
|
@@ -608,7 +608,7 @@ interface ExportReport {
|
|
|
608
608
|
};
|
|
609
609
|
warnings: string[];
|
|
610
610
|
}
|
|
611
|
-
type RestoreActionKind = 'hostFileRestore' | 'hostFileRemove' | 'pluginRemove' | 'fileRestore' | 'fileRemove' | 'credentialHint' | 'skip';
|
|
611
|
+
type RestoreActionKind = 'hostFileRestore' | 'hostFileRemove' | 'pluginRemove' | 'pluginInstall' | 'fileRestore' | 'fileRemove' | 'credentialHint' | 'skip';
|
|
612
612
|
interface RestoreAction {
|
|
613
613
|
kind: RestoreActionKind;
|
|
614
614
|
/** 人类可读描述 */
|
|
@@ -617,8 +617,10 @@ interface RestoreAction {
|
|
|
617
617
|
target?: string;
|
|
618
618
|
/** hostFileRestore/fileRestore:快照内 blob 相对路径(相对 snapshotDir) */
|
|
619
619
|
blobPath?: string;
|
|
620
|
-
/** pluginRemove:插件包名 */
|
|
620
|
+
/** pluginRemove / pluginInstall:插件包名 */
|
|
621
621
|
pluginName?: string;
|
|
622
|
+
/** pluginInstall:重装目标(name@version;版本未知时就是裸包名) */
|
|
623
|
+
pluginTarget?: string;
|
|
622
624
|
/** credentialHint:人工提示文本 */
|
|
623
625
|
manualHint?: string;
|
|
624
626
|
/** 附加说明(旧快照缺基线 / 离线无法恢复等) */
|
|
@@ -635,6 +637,7 @@ interface RestorePlan {
|
|
|
635
637
|
hostFileRestores: number;
|
|
636
638
|
hostFileRemoves: number;
|
|
637
639
|
pluginRemoves: number;
|
|
640
|
+
pluginInstalls: number;
|
|
638
641
|
fileRestores: number;
|
|
639
642
|
fileRemoves: number;
|
|
640
643
|
credentialHints: number;
|
|
@@ -660,6 +663,8 @@ interface RestoreReport {
|
|
|
660
663
|
restored: string[];
|
|
661
664
|
/** 已卸载的插件名 */
|
|
662
665
|
removedPlugins: string[];
|
|
666
|
+
/** 已按 undo 记录装回的插件目标(name@version;issue #132) */
|
|
667
|
+
installedPlugins: string[];
|
|
663
668
|
/** 需人工处理的提示(凭据补录等) */
|
|
664
669
|
manualHints: string[];
|
|
665
670
|
/** 失败清单 */
|
|
@@ -5997,6 +6002,8 @@ declare const zh$3: {
|
|
|
5997
6002
|
readonly 'mode.hint': '同步范围 = 勾选的分区集合(默认已勾选推荐分区,可随时改)。';
|
|
5998
6003
|
readonly 'mode.selectedCount': '已勾选 {n} / {total}';
|
|
5999
6004
|
readonly 'mode.sectionsHint': '默认可同步的是可移植分区;平台相关分区(MCP 服务器)与设备相关分区(插件文件、凭据状态、历史会话)只有你在这里主动勾选才参与同步。';
|
|
6005
|
+
readonly 'mode.deletePlugins': '跟随远端删除插件';
|
|
6006
|
+
readonly 'mode.deletePluginsHint': '远端快照里已经没有、本机也没改过的插件会被卸载(判断依据是共同祖先里还有它 —— 那只可能是别处删掉了)。卸载只发生在插件分区真正被应用的那一轮;失败逐项提示、其余同步照常完成。desktop 保留档案与宿主自己不会被删。';
|
|
6000
6007
|
readonly 'mode.atLeastOne': '请至少勾选一个同步分区';
|
|
6001
6008
|
readonly 'mode.sectionPortable': '可移植';
|
|
6002
6009
|
readonly 'mode.sectionRecommended': '推荐';
|