dsh-config-manager 0.6.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 (112) 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 +14 -2
  5. package/lib/client.js +722 -647
  6. package/lib/core/backup.d.ts +9 -1
  7. package/lib/core/backup.js +21 -0
  8. package/lib/core/local-plugin-host.d.ts +9 -0
  9. package/lib/core/local-plugin-host.js +174 -1
  10. package/lib/core/messages-core.d.ts +3 -0
  11. package/lib/core/messages-core.js +6 -0
  12. package/lib/core/messages.d.ts +8 -0
  13. package/lib/core/messages.js +18 -0
  14. package/lib/core/model-tools.js +2 -0
  15. package/lib/core/phase4-crash-child.js +1 -1
  16. package/lib/core/plugin-cli.d.ts +11 -0
  17. package/lib/core/plugin-cli.js +30 -0
  18. package/lib/core/restore-wal.d.ts +2 -0
  19. package/lib/core/restore-wal.js +11 -6
  20. package/lib/core/restore.d.ts +15 -2
  21. package/lib/core/restore.js +65 -3
  22. package/lib/core/run-registry.d.ts +10 -0
  23. package/lib/core/run-registry.js +17 -0
  24. package/lib/core/snapshot-diff.js +2 -1
  25. package/lib/core/types.d.ts +32 -0
  26. package/lib/index.d.ts +8 -2
  27. package/lib/index.js +24 -21
  28. package/lib/routes/import.js +6 -1
  29. package/lib/routes/route-support.d.ts +7 -1
  30. package/lib/routes/route-support.js +36 -5
  31. package/lib/routes/sync.js +8 -2
  32. package/lib/sync/autosync-config.d.ts +9 -1
  33. package/lib/sync/autosync-config.js +10 -2
  34. package/lib/sync/autosync-scheduler.js +18 -6
  35. package/lib/sync/git/git-transport.d.ts +31 -1
  36. package/lib/sync/git/git-transport.js +119 -23
  37. package/lib/sync/merge-preview-view.d.ts +78 -0
  38. package/lib/sync/merge-preview-view.js +46 -0
  39. package/lib/sync/merge.d.ts +2 -1
  40. package/lib/sync/merge.js +9 -4
  41. package/lib/sync/plugin-removal-apply.d.ts +95 -0
  42. package/lib/sync/plugin-removal-apply.js +158 -0
  43. package/lib/sync/plugin-removals.d.ts +90 -0
  44. package/lib/sync/plugin-removals.js +167 -0
  45. package/lib/sync/sync-config.d.ts +34 -3
  46. package/lib/sync/sync-config.js +38 -5
  47. package/lib/sync/sync-engine.d.ts +34 -43
  48. package/lib/sync/sync-engine.js +50 -42
  49. package/lib/sync/sync-selection.d.ts +8 -0
  50. package/lib/sync/sync-selection.js +6 -0
  51. package/lib/sync/workspace-merge.d.ts +8 -1
  52. package/lib/ui/restore-plan-view.js +1 -0
  53. package/lib/ui/sync-settings-view.d.ts +14 -0
  54. package/lib/ui/sync-settings-view.js +5 -0
  55. package/package.json +1 -1
  56. package/src/adapters/test-helpers.ts +10 -0
  57. package/src/cli/actions.ts +1 -1
  58. package/src/client/common/info-hint-guard.test.ts +2 -1
  59. package/src/client/run-store.test.ts +8 -6
  60. package/src/client/run-store.ts +9 -5
  61. package/src/client/sync/ChannelConfigDialog.tsx +15 -1
  62. package/src/client/sync/SyncPanel.tsx +16 -0
  63. package/src/client/sync/SyncSectionPickerDialog.tsx +17 -1
  64. package/src/client/sync/sync-api.ts +2 -0
  65. package/src/client/sync/sync-locales.ts +10 -0
  66. package/src/client/sync/sync-view.ts +6 -0
  67. package/src/core/backup.ts +21 -1
  68. package/src/core/local-plugin-host.test.ts +31 -2
  69. package/src/core/local-plugin-host.ts +175 -2
  70. package/src/core/messages-core.ts +6 -0
  71. package/src/core/messages.ts +18 -0
  72. package/src/core/model-tools.ts +2 -0
  73. package/src/core/phase4-crash-child.ts +1 -1
  74. package/src/core/plugin-cli.ts +37 -0
  75. package/src/core/restore-plugin-install.test.ts +116 -0
  76. package/src/core/restore-wal.ts +12 -6
  77. package/src/core/restore.ts +79 -4
  78. package/src/core/run-registry-runs.test.ts +26 -1
  79. package/src/core/run-registry.ts +18 -0
  80. package/src/core/smoke.test.ts +5 -0
  81. package/src/core/snapshot-diff.test.ts +1 -1
  82. package/src/core/snapshot-diff.ts +2 -1
  83. package/src/core/types.ts +31 -0
  84. package/src/index.sync.test.ts +27 -0
  85. package/src/index.ts +30 -28
  86. package/src/routes/import.ts +6 -1
  87. package/src/routes/route-support.ts +34 -5
  88. package/src/routes/sync.ts +8 -2
  89. package/src/security/security.test.ts +1 -0
  90. package/src/sync/autosync-config.ts +10 -2
  91. package/src/sync/autosync-scheduler.test.ts +61 -1
  92. package/src/sync/autosync-scheduler.ts +17 -5
  93. package/src/sync/git/git-transport.test.ts +117 -0
  94. package/src/sync/git/git-transport.ts +131 -23
  95. package/src/sync/merge-preview-view.ts +97 -0
  96. package/src/sync/merge.test.ts +17 -15
  97. package/src/sync/merge.ts +10 -3
  98. package/src/sync/plugin-removal-apply.ts +198 -0
  99. package/src/sync/plugin-removals.test.ts +221 -0
  100. package/src/sync/plugin-removals.ts +208 -0
  101. package/src/sync/sync-config.test.ts +59 -1
  102. package/src/sync/sync-config.ts +51 -5
  103. package/src/sync/sync-engine.test.ts +251 -1
  104. package/src/sync/sync-engine.ts +84 -83
  105. package/src/sync/sync-selection.test.ts +29 -7
  106. package/src/sync/sync-selection.ts +13 -0
  107. package/src/sync/workspace-merge.ts +9 -0
  108. package/src/ui/restore-plan-view.test.ts +1 -1
  109. package/src/ui/restore-plan-view.ts +1 -0
  110. package/src/ui/snapshots-view.test.ts +1 -1
  111. package/src/ui/sync-settings-view.test.ts +21 -0
  112. package/src/ui/sync-settings-view.ts +19 -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
  /** 失败清单 */
@@ -3028,6 +3033,8 @@ interface SyncStatusResponse {
3028
3033
  configured: boolean;
3029
3034
  /** git 通道:已配置的仓库地址(不含 token,可回显;与当前通道无关,配置过即返回) */
3030
3035
  repoUrl?: string;
3036
+ /** git 通道:仓库内子目录前缀('' / 缺省 = 仓库根;issue 131,供表单回填) */
3037
+ subdir?: string;
3031
3038
  /** git 通道:DSH credentials 中是否已存在 token(describe 只报状态,值永不返回) */
3032
3039
  credentialConfigured: boolean;
3033
3040
  credentialWritable: boolean;
@@ -5846,6 +5853,9 @@ declare const zh$3: {
5846
5853
  readonly 'config.title': '仓库配置';
5847
5854
  readonly 'config.repoUrl': '仓库地址';
5848
5855
  readonly 'config.repoUrlHint': 'Git 私有仓库地址(https / ssh / 本地路径)。认证 token 请使用下方凭据字段,不要拼入地址。';
5856
+ readonly 'config.gitSubdir': '仓库内子目录';
5857
+ readonly 'config.gitSubdirHint': '留空 = 直接用仓库根目录(旧行为)。填了就把同步内容放进该子目录(如「DSH备份」或「tools/dsh」):多个工具共用一个私有仓库时各自独立。切换子目录不会搬动已有快照 —— 换前缀前先重建工作副本。';
5858
+ readonly 'config.gitSubdirPlaceholder': 'DSH备份(可选)';
5849
5859
  readonly 'config.token': '认证 token';
5850
5860
  readonly 'config.tokenHint': '将安全写入 DSH credentials(引用名 {ref}),不会写入同步文件或日志。留空表示沿用已保存的凭据。';
5851
5861
  readonly 'config.tokenSaved': '凭据已配置';
@@ -5992,6 +6002,8 @@ declare const zh$3: {
5992
6002
  readonly 'mode.hint': '同步范围 = 勾选的分区集合(默认已勾选推荐分区,可随时改)。';
5993
6003
  readonly 'mode.selectedCount': '已勾选 {n} / {total}';
5994
6004
  readonly 'mode.sectionsHint': '默认可同步的是可移植分区;平台相关分区(MCP 服务器)与设备相关分区(插件文件、凭据状态、历史会话)只有你在这里主动勾选才参与同步。';
6005
+ readonly 'mode.deletePlugins': '跟随远端删除插件';
6006
+ readonly 'mode.deletePluginsHint': '远端快照里已经没有、本机也没改过的插件会被卸载(判断依据是共同祖先里还有它 —— 那只可能是别处删掉了)。卸载只发生在插件分区真正被应用的那一轮;失败逐项提示、其余同步照常完成。desktop 保留档案与宿主自己不会被删。';
5995
6007
  readonly 'mode.atLeastOne': '请至少勾选一个同步分区';
5996
6008
  readonly 'mode.sectionPortable': '可移植';
5997
6009
  readonly 'mode.sectionRecommended': '推荐';