dsh-config-manager 0.7.0 → 0.8.0

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.
Files changed (85) hide show
  1. package/lib/adapters/test-helpers.d.ts +7 -0
  2. package/lib/adapters/test-helpers.js +11 -0
  3. package/lib/cli/actions.js +1 -1
  4. package/lib/client.d.ts +9 -2
  5. package/lib/client.js +685 -649
  6. package/lib/core/backup.d.ts +9 -1
  7. package/lib/core/backup.js +21 -0
  8. package/lib/core/messages-core.d.ts +3 -0
  9. package/lib/core/messages-core.js +6 -0
  10. package/lib/core/messages.d.ts +5 -0
  11. package/lib/core/messages.js +10 -0
  12. package/lib/core/model-tools.js +2 -0
  13. package/lib/core/phase4-crash-child.js +1 -1
  14. package/lib/core/plugin-cli.d.ts +11 -0
  15. package/lib/core/plugin-cli.js +30 -0
  16. package/lib/core/restore-wal.d.ts +2 -0
  17. package/lib/core/restore-wal.js +11 -6
  18. package/lib/core/restore.d.ts +15 -2
  19. package/lib/core/restore.js +65 -3
  20. package/lib/core/snapshot-diff.js +2 -1
  21. package/lib/core/types.d.ts +32 -0
  22. package/lib/index.d.ts +6 -1
  23. package/lib/index.js +17 -16
  24. package/lib/routes/route-support.d.ts +5 -0
  25. package/lib/routes/route-support.js +28 -2
  26. package/lib/routes/sync.js +3 -0
  27. package/lib/sync/merge-preview-view.d.ts +78 -0
  28. package/lib/sync/merge-preview-view.js +46 -0
  29. package/lib/sync/merge.d.ts +2 -1
  30. package/lib/sync/merge.js +9 -4
  31. package/lib/sync/plugin-removal-apply.d.ts +95 -0
  32. package/lib/sync/plugin-removal-apply.js +158 -0
  33. package/lib/sync/plugin-removals.d.ts +90 -0
  34. package/lib/sync/plugin-removals.js +167 -0
  35. package/lib/sync/sync-engine.d.ts +34 -43
  36. package/lib/sync/sync-engine.js +50 -42
  37. package/lib/sync/sync-selection.d.ts +8 -0
  38. package/lib/sync/sync-selection.js +6 -0
  39. package/lib/sync/workspace-merge.d.ts +8 -1
  40. package/lib/ui/restore-plan-view.js +1 -0
  41. package/lib/ui/sync-settings-view.d.ts +10 -0
  42. package/lib/ui/sync-settings-view.js +2 -0
  43. package/package.json +1 -1
  44. package/src/adapters/test-helpers.ts +10 -0
  45. package/src/cli/actions.ts +1 -1
  46. package/src/client/common/info-hint-guard.test.ts +2 -1
  47. package/src/client/run-store.test.ts +7 -5
  48. package/src/client/run-store.ts +4 -5
  49. package/src/client/sync/SyncPanel.tsx +10 -0
  50. package/src/client/sync/SyncSectionPickerDialog.tsx +17 -1
  51. package/src/client/sync/sync-locales.ts +4 -0
  52. package/src/client/sync/sync-view.ts +6 -0
  53. package/src/core/backup.ts +21 -1
  54. package/src/core/messages-core.ts +6 -0
  55. package/src/core/messages.ts +10 -0
  56. package/src/core/model-tools.ts +2 -0
  57. package/src/core/phase4-crash-child.ts +1 -1
  58. package/src/core/plugin-cli.ts +37 -0
  59. package/src/core/restore-plugin-install.test.ts +116 -0
  60. package/src/core/restore-wal.ts +12 -6
  61. package/src/core/restore.ts +79 -4
  62. package/src/core/smoke.test.ts +5 -0
  63. package/src/core/snapshot-diff.test.ts +1 -1
  64. package/src/core/snapshot-diff.ts +2 -1
  65. package/src/core/types.ts +31 -0
  66. package/src/index.ts +21 -21
  67. package/src/routes/route-support.ts +27 -2
  68. package/src/routes/sync.ts +3 -0
  69. package/src/security/security.test.ts +1 -0
  70. package/src/sync/merge-preview-view.ts +97 -0
  71. package/src/sync/merge.test.ts +17 -15
  72. package/src/sync/merge.ts +10 -3
  73. package/src/sync/plugin-removal-apply.ts +198 -0
  74. package/src/sync/plugin-removals.test.ts +221 -0
  75. package/src/sync/plugin-removals.ts +208 -0
  76. package/src/sync/sync-engine.test.ts +251 -1
  77. package/src/sync/sync-engine.ts +84 -83
  78. package/src/sync/sync-selection.test.ts +29 -7
  79. package/src/sync/sync-selection.ts +13 -0
  80. package/src/sync/workspace-merge.ts +9 -0
  81. package/src/ui/restore-plan-view.test.ts +1 -1
  82. package/src/ui/restore-plan-view.ts +1 -0
  83. package/src/ui/snapshots-view.test.ts +1 -1
  84. package/src/ui/sync-settings-view.test.ts +20 -0
  85. package/src/ui/sync-settings-view.ts +12 -0
@@ -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();
@@ -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': '推荐';