dsh-config-manager 0.8.1 → 0.9.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 (368) hide show
  1. package/lib/adapters/mcp.js +42 -13
  2. package/lib/adapters/messages.d.ts +1 -0
  3. package/lib/adapters/messages.js +2 -0
  4. package/lib/adapters/patch-key-guard.d.ts +23 -0
  5. package/lib/adapters/patch-key-guard.js +13 -0
  6. package/lib/adapters/plugin-data.d.ts +19 -5
  7. package/lib/adapters/plugin-data.js +76 -22
  8. package/lib/adapters/plugins.d.ts +14 -1
  9. package/lib/adapters/plugins.js +147 -4
  10. package/lib/cli/actions.d.ts +7 -105
  11. package/lib/cli/actions.js +16 -172
  12. package/lib/cli/control-state.d.ts +54 -0
  13. package/lib/cli/control-state.js +107 -0
  14. package/lib/cli/index.js +14 -0
  15. package/lib/cli/write-gates.d.ts +61 -0
  16. package/lib/cli/write-gates.js +110 -0
  17. package/lib/client.d.ts +122 -50
  18. package/lib/client.js +12676 -12091
  19. package/lib/core/backup.d.ts +0 -4
  20. package/lib/core/backup.js +21 -4
  21. package/lib/core/boot-rescue.d.ts +1 -1
  22. package/lib/core/boot-rescue.js +12 -1
  23. package/lib/core/boot-safety.js +37 -2
  24. package/lib/core/conflict-decisions.js +2 -1
  25. package/lib/core/exporter.js +22 -1
  26. package/lib/core/journal.d.ts +54 -4
  27. package/lib/core/journal.js +158 -35
  28. package/lib/core/local-plugin-host.d.ts +29 -0
  29. package/lib/core/local-plugin-host.js +55 -48
  30. package/lib/core/messages.d.ts +7 -0
  31. package/lib/core/messages.js +14 -0
  32. package/lib/core/migration-history.js +16 -9
  33. package/lib/core/model-tools.d.ts +2 -2
  34. package/lib/core/model-tools.js +14 -2
  35. package/lib/core/patch-secret-guard.d.ts +49 -0
  36. package/lib/core/patch-secret-guard.js +164 -0
  37. package/lib/core/reconcile.d.ts +8 -0
  38. package/lib/core/reconcile.js +18 -3
  39. package/lib/core/reinstall.d.ts +2 -0
  40. package/lib/core/reinstall.js +6 -2
  41. package/lib/core/restore.js +31 -6
  42. package/lib/core/section-sanitize.d.ts +32 -0
  43. package/lib/core/section-sanitize.js +13 -0
  44. package/lib/core/snapshot-diff.d.ts +30 -0
  45. package/lib/core/snapshot-diff.js +56 -20
  46. package/lib/core/startup-barrier.js +8 -2
  47. package/lib/core/types.d.ts +22 -0
  48. package/lib/core/update-check.js +51 -2
  49. package/lib/foreign/kernel.js +9 -2
  50. package/lib/foreign/read-claude-plugins.js +29 -11
  51. package/lib/foreign/read-dsh.js +31 -2
  52. package/lib/foreign/read-trae.d.ts +11 -0
  53. package/lib/foreign/read-trae.js +124 -4
  54. package/lib/foreign/session-ir.js +50 -9
  55. package/lib/foreign/session-read.d.ts +8 -0
  56. package/lib/foreign/session-read.js +26 -0
  57. package/lib/foreign/session-source.d.ts +12 -4
  58. package/lib/foreign/session-source.js +5 -3
  59. package/lib/foreign/trae-sqlcipher.d.ts +127 -0
  60. package/lib/foreign/trae-sqlcipher.js +519 -0
  61. package/lib/foreign/trae.js +3 -1
  62. package/lib/foreign/truth-table.js +3 -2
  63. package/lib/foreign/types.d.ts +9 -1
  64. package/lib/index.d.ts +1 -1
  65. package/lib/index.js +1 -1
  66. package/lib/profiles/dsh-profile-io.d.ts +20 -0
  67. package/lib/profiles/dsh-profile-io.js +27 -0
  68. package/lib/profiles/dsh-profile-manager.d.ts +27 -0
  69. package/lib/profiles/dsh-profile-manager.js +45 -4
  70. package/lib/profiles/dsh-profile-runtime.d.ts +5 -1
  71. package/lib/profiles/dsh-profile-runtime.js +16 -3
  72. package/lib/profiles/process-control.d.ts +18 -1
  73. package/lib/profiles/process-control.js +25 -1
  74. package/lib/routes/profiles.js +2 -1
  75. package/lib/routes/sync.js +13 -1
  76. package/lib/schema/types.d.ts +11 -0
  77. package/lib/security/redaction.js +22 -6
  78. package/lib/sync/autosync-repeat.d.ts +27 -0
  79. package/lib/sync/autosync-repeat.js +23 -0
  80. package/lib/sync/autosync-scheduler.d.ts +34 -1
  81. package/lib/sync/autosync-scheduler.js +151 -43
  82. package/lib/sync/baseline-heal.js +7 -0
  83. package/lib/sync/baseline-record.d.ts +67 -0
  84. package/lib/sync/baseline-record.js +74 -0
  85. package/lib/sync/blob-store.js +13 -0
  86. package/lib/sync/content-diff.d.ts +39 -0
  87. package/lib/sync/content-diff.js +46 -0
  88. package/lib/sync/git/git-transport.d.ts +32 -1
  89. package/lib/sync/git/git-transport.js +146 -26
  90. package/lib/sync/github-auth.d.ts +17 -1
  91. package/lib/sync/github-auth.js +37 -1
  92. package/lib/sync/merge-apply-plan.d.ts +38 -0
  93. package/lib/sync/merge-apply-plan.js +76 -0
  94. package/lib/sync/messages.d.ts +1 -0
  95. package/lib/sync/messages.js +2 -0
  96. package/lib/sync/pending-merge.d.ts +34 -0
  97. package/lib/sync/pending-merge.js +53 -0
  98. package/lib/sync/s3/s3-transport.d.ts +14 -2
  99. package/lib/sync/s3/s3-transport.js +72 -48
  100. package/lib/sync/sync-engine.d.ts +23 -40
  101. package/lib/sync/sync-engine.js +115 -132
  102. package/lib/sync/sync-history.d.ts +7 -0
  103. package/lib/sync/sync-state.d.ts +28 -0
  104. package/lib/sync/sync-state.js +20 -0
  105. package/lib/sync/transport.d.ts +12 -3
  106. package/lib/sync/transport.js +13 -4
  107. package/lib/sync/webdav/webdav-transport.d.ts +19 -2
  108. package/lib/sync/webdav/webdav-transport.js +81 -40
  109. package/lib/ui/commands.js +5 -11
  110. package/lib/ui/dsh-profiles-view.d.ts +8 -3
  111. package/lib/ui/dsh-profiles-view.js +9 -5
  112. package/lib/ui/foreign-view.d.ts +19 -0
  113. package/lib/ui/foreign-view.js +24 -0
  114. package/lib/ui/i18n.d.ts +7 -1
  115. package/lib/ui/i18n.js +17 -2
  116. package/lib/ui/menu-placement.js +1 -1
  117. package/lib/ui/migration-consult-view.d.ts +11 -0
  118. package/lib/ui/migration-consult-view.js +15 -0
  119. package/lib/ui/overview-view.d.ts +7 -0
  120. package/lib/ui/overview-view.js +3 -0
  121. package/lib/ui/report.d.ts +9 -0
  122. package/lib/ui/report.js +17 -4
  123. package/lib/ui/selection-model.d.ts +8 -0
  124. package/lib/ui/selection-model.js +16 -0
  125. package/lib/utils/patch-yaml.d.ts +39 -1
  126. package/lib/utils/patch-yaml.js +82 -2
  127. package/lib/utils/paths.d.ts +13 -0
  128. package/lib/utils/paths.js +35 -0
  129. package/lib/utils/workdir-lock.js +18 -3
  130. package/package.json +2 -1
  131. package/src/adapters/mcp.test.ts +29 -0
  132. package/src/adapters/mcp.ts +43 -12
  133. package/src/adapters/messages.ts +2 -0
  134. package/src/adapters/patch-key-guard.ts +29 -0
  135. package/src/adapters/plugin-data.test.ts +126 -0
  136. package/src/adapters/plugin-data.ts +97 -26
  137. package/src/adapters/plugins.test.ts +288 -0
  138. package/src/adapters/plugins.ts +141 -4
  139. package/src/cli/actions.test.ts +74 -1
  140. package/src/cli/actions.ts +27 -246
  141. package/src/cli/control-state.ts +143 -0
  142. package/src/cli/index.ts +18 -0
  143. package/src/cli/web/web.test.ts +27 -0
  144. package/src/cli/write-gates.ts +149 -0
  145. package/src/client/about/AboutPanel.tsx +7 -6
  146. package/src/client/about/release-notes-view.test.ts +17 -0
  147. package/src/client/about/release-notes-view.ts +49 -24
  148. package/src/client/chat/ChatEntryView.tsx +2 -2
  149. package/src/client/chat/rollback-entry-view.ts +6 -1
  150. package/src/client/common/CommandPalette.tsx +6 -3
  151. package/src/client/common/ConfirmDialog.tsx +29 -12
  152. package/src/client/common/ContentPicker.tsx +13 -12
  153. package/src/client/common/Modal.tsx +12 -5
  154. package/src/client/common/MoreMenu.tsx +4 -1
  155. package/src/client/common/RunsCenter.tsx +103 -32
  156. package/src/client/common/Select.tsx +2 -2
  157. package/src/client/common/floating-bounds.ts +1 -1
  158. package/src/client/common/floating-units.test.ts +1 -2
  159. package/src/client/common/plan-text-redaction.test.ts +188 -3
  160. package/src/client/common/runs-center-guard.test.ts +60 -0
  161. package/src/client/common/runs-center-view.test.ts +128 -0
  162. package/src/client/common/runs-center-view.ts +96 -0
  163. package/src/client/common/section-title-action.test.ts +66 -0
  164. package/src/client/common/ui.tsx +93 -30
  165. package/src/client/config-manager.module.css +1507 -272
  166. package/src/client/consult/ConsultCard.tsx +7 -6
  167. package/src/client/environment/EnvironmentPanel.tsx +20 -21
  168. package/src/client/environment/maintenance/DiskUsageCard.tsx +65 -91
  169. package/src/client/environment/profiles-incomplete-ui.test.ts +8 -8
  170. package/src/client/export/ExportView.tsx +7 -16
  171. package/src/client/history/HistoryPanel.tsx +88 -28
  172. package/src/client/history/history-locales.ts +3 -3
  173. package/src/client/home/BackupScheduleCard.tsx +35 -30
  174. package/src/client/home/HomePanel.tsx +45 -10
  175. package/src/client/import/ConflictList.tsx +13 -13
  176. package/src/client/import/ForeignImportView.tsx +32 -13
  177. package/src/client/import/ImportWizardView.tsx +2 -3
  178. package/src/client/import/PathMappingForm.tsx +4 -4
  179. package/src/client/import/PathPickerDialog.tsx +2 -1
  180. package/src/client/import/foreign-import-view-guard.test.ts +1 -1
  181. package/src/client/import/import-wizard-steps.tsx +51 -39
  182. package/src/client/import/use-import-wizard-controller.test.ts +129 -0
  183. package/src/client/import/use-import-wizard-controller.ts +116 -22
  184. package/src/client/library/ArtifactRow.tsx +2 -2
  185. package/src/client/library/BackupInspectView.tsx +19 -15
  186. package/src/client/library/LibraryActions.tsx +56 -16
  187. package/src/client/library/LibraryPanel.tsx +7 -7
  188. package/src/client/library/RestorePlanView.tsx +13 -8
  189. package/src/client/locales/about.ts +0 -2
  190. package/src/client/locales/backup.ts +10 -12
  191. package/src/client/locales/common.ts +2 -0
  192. package/src/client/locales/export.ts +5 -12
  193. package/src/client/locales/foreign.ts +11 -2
  194. package/src/client/locales/import.ts +3 -2
  195. package/src/client/locales/overview.ts +4 -0
  196. package/src/client/locales/profiles.ts +32 -4
  197. package/src/client/locales/restore.ts +0 -2
  198. package/src/client/locales/sessions.ts +0 -2
  199. package/src/client/locales/shell.ts +2 -2
  200. package/src/client/market/MarketPanel.tsx +38 -20
  201. package/src/client/market/MyConfigsList.tsx +34 -32
  202. package/src/client/market/MyConfigsLoginCard.tsx +12 -15
  203. package/src/client/market/MyConfigsView.tsx +5 -5
  204. package/src/client/market/MyConfigsWizard.tsx +7 -12
  205. package/src/client/market/market-locales.ts +0 -6
  206. package/src/client/market/my-configs-split.test.ts +2 -1
  207. package/src/client/nav-menu-clip-guard.test.ts +52 -0
  208. package/src/client/recovery/IncompleteCopiesSection.tsx +1 -3
  209. package/src/client/recovery/RecoveryPanel.tsx +31 -16
  210. package/src/client/recovery/RollbackCard.tsx +58 -16
  211. package/src/client/recovery/RollbackFileChanges.tsx +40 -27
  212. package/src/client/recovery/SessionHealthCard.tsx +2 -2
  213. package/src/client/recovery/SessionHealthDialog.tsx +5 -7
  214. package/src/client/recovery/SessionLayoutSection.tsx +3 -5
  215. package/src/client/recovery/recovery-locales.ts +12 -8
  216. package/src/client/run-store.test.ts +30 -0
  217. package/src/client/run-store.ts +21 -1
  218. package/src/client/sync/AddChannelCard.tsx +65 -0
  219. package/src/client/sync/AutosyncCard.tsx +182 -108
  220. package/src/client/sync/ChannelClearConfirmDialog.tsx +5 -1
  221. package/src/client/sync/ChannelConfigDialog.tsx +27 -48
  222. package/src/client/sync/MergePreviewView.tsx +3 -5
  223. package/src/client/sync/PushReportSections.tsx +35 -0
  224. package/src/client/sync/SyncChannelEntryCard.tsx +33 -24
  225. package/src/client/sync/SyncConfirmView.tsx +3 -3
  226. package/src/client/sync/SyncLogList.tsx +16 -5
  227. package/src/client/sync/SyncPanel.tsx +153 -159
  228. package/src/client/sync/SyncProbeRow.tsx +5 -7
  229. package/src/client/sync/SyncRepositoryPicker.tsx +17 -4
  230. package/src/client/sync/SyncSecuritySection.tsx +157 -0
  231. package/src/client/sync/SyncSettingsDialog.tsx +304 -0
  232. package/src/client/sync/SyncSettingsView.test.ts +26 -8
  233. package/src/client/sync/WorkDirCard.tsx +2 -4
  234. package/src/client/sync/config-clear-guard.test.ts +94 -0
  235. package/src/client/sync/config-clear-guard.ts +98 -0
  236. package/src/client/sync/config-dirty.test.ts +91 -0
  237. package/src/client/sync/config-dirty.ts +88 -0
  238. package/src/client/sync/history-model.test.ts +2 -0
  239. package/src/client/sync/history-model.ts +3 -0
  240. package/src/client/sync/merge-request.ts +20 -0
  241. package/src/client/sync/sync-api.ts +12 -0
  242. package/src/client/sync/sync-locales.ts +87 -47
  243. package/src/client/sync/sync-panel-clear.test.ts +44 -0
  244. package/src/client/sync/sync-view.test.ts +20 -0
  245. package/src/client/sync/sync-view.ts +42 -4
  246. package/src/core/backup.test.ts +61 -1
  247. package/src/core/backup.ts +21 -4
  248. package/src/core/boot-rescue.test.ts +35 -0
  249. package/src/core/boot-rescue.ts +13 -2
  250. package/src/core/boot-safety.test.ts +25 -0
  251. package/src/core/boot-safety.ts +37 -2
  252. package/src/core/conflict-decisions.ts +2 -1
  253. package/src/core/exporter.ts +21 -1
  254. package/src/core/journal.test.ts +183 -0
  255. package/src/core/journal.ts +163 -25
  256. package/src/core/local-plugin-host.test.ts +68 -2
  257. package/src/core/local-plugin-host.ts +31 -4
  258. package/src/core/messages.ts +14 -0
  259. package/src/core/migration-history.test.ts +27 -0
  260. package/src/core/migration-history.ts +12 -4
  261. package/src/core/model-tools.test.ts +67 -0
  262. package/src/core/model-tools.ts +16 -4
  263. package/src/core/patch-secret-guard.test.ts +110 -0
  264. package/src/core/patch-secret-guard.ts +176 -0
  265. package/src/core/reconcile.ts +32 -4
  266. package/src/core/reinstall.ts +8 -2
  267. package/src/core/restore.ts +32 -7
  268. package/src/core/section-sanitize.ts +37 -0
  269. package/src/core/snapshot-diff.test.ts +73 -1
  270. package/src/core/snapshot-diff.ts +66 -21
  271. package/src/core/startup-barrier.test.ts +64 -0
  272. package/src/core/startup-barrier.ts +8 -2
  273. package/src/core/types.ts +27 -1
  274. package/src/core/update-check.test.ts +40 -0
  275. package/src/core/update-check.ts +53 -2
  276. package/src/foreign/claude-code.test.ts +5 -0
  277. package/src/foreign/claude-plugins.test.ts +57 -0
  278. package/src/foreign/claude-sessions-bytes.test.ts +7 -1
  279. package/src/foreign/dsh.test.ts +23 -0
  280. package/src/foreign/file-budget.test.ts +7 -1
  281. package/src/foreign/kernel.ts +9 -2
  282. package/src/foreign/read-claude-plugins.ts +32 -11
  283. package/src/foreign/read-dsh.ts +33 -2
  284. package/src/foreign/read-trae.ts +117 -5
  285. package/src/foreign/session-ir.test.ts +67 -0
  286. package/src/foreign/session-ir.ts +54 -14
  287. package/src/foreign/session-read.ts +23 -0
  288. package/src/foreign/session-source.ts +15 -5
  289. package/src/foreign/trae-sqlcipher.test.ts +360 -0
  290. package/src/foreign/trae-sqlcipher.ts +564 -0
  291. package/src/foreign/trae.test.ts +188 -0
  292. package/src/foreign/trae.ts +3 -1
  293. package/src/foreign/truth-table.ts +4 -2
  294. package/src/foreign/types.ts +10 -1
  295. package/src/index.ts +1 -1
  296. package/src/profiles/dsh-profile-copy-rollback.test.ts +58 -4
  297. package/src/profiles/dsh-profile-io.ts +29 -0
  298. package/src/profiles/dsh-profile-manager.test.ts +30 -0
  299. package/src/profiles/dsh-profile-manager.ts +53 -5
  300. package/src/profiles/dsh-profile-runtime.test.ts +29 -7
  301. package/src/profiles/dsh-profile-runtime.ts +17 -3
  302. package/src/profiles/process-control.test.ts +97 -0
  303. package/src/profiles/process-control.ts +28 -1
  304. package/src/routes/profiles.ts +2 -1
  305. package/src/routes/sync.ts +13 -1
  306. package/src/schema/types.ts +16 -1
  307. package/src/security/redaction.test.ts +31 -0
  308. package/src/security/redaction.ts +23 -6
  309. package/src/sync/autosync-repeat.test.ts +58 -0
  310. package/src/sync/autosync-repeat.ts +55 -0
  311. package/src/sync/autosync-scheduler.test.ts +417 -0
  312. package/src/sync/autosync-scheduler.ts +154 -41
  313. package/src/sync/baseline-heal.ts +6 -0
  314. package/src/sync/baseline-record.ts +135 -0
  315. package/src/sync/blob-store.test.ts +16 -0
  316. package/src/sync/blob-store.ts +13 -0
  317. package/src/sync/content-diff.test.ts +95 -0
  318. package/src/sync/content-diff.ts +79 -0
  319. package/src/sync/git/git-transport.test.ts +151 -4
  320. package/src/sync/git/git-transport.ts +143 -27
  321. package/src/sync/github-auth.test.ts +26 -1
  322. package/src/sync/github-auth.ts +37 -1
  323. package/src/sync/merge-apply-plan.ts +117 -0
  324. package/src/sync/messages.ts +2 -0
  325. package/src/sync/pending-merge.ts +77 -0
  326. package/src/sync/s3/s3-delete-and-blob-index.test.ts +249 -0
  327. package/src/sync/s3/s3-transport.ts +76 -42
  328. package/src/sync/sync-config.test.ts +39 -12
  329. package/src/sync/sync-device-identity.test.ts +3 -0
  330. package/src/sync/sync-engine.test.ts +465 -12
  331. package/src/sync/sync-engine.ts +130 -135
  332. package/src/sync/sync-history.ts +7 -0
  333. package/src/sync/sync-state.ts +48 -0
  334. package/src/sync/transport.test.ts +13 -1
  335. package/src/sync/transport.ts +12 -4
  336. package/src/sync/webdav/webdav-delete-and-blob-index.test.ts +249 -0
  337. package/src/sync/webdav/webdav-transport.ts +86 -34
  338. package/src/ui/commands.test.ts +11 -0
  339. package/src/ui/commands.ts +5 -14
  340. package/src/ui/dsh-profiles-view.test.ts +16 -0
  341. package/src/ui/dsh-profiles-view.ts +11 -5
  342. package/src/ui/foreign-view.test.ts +36 -0
  343. package/src/ui/foreign-view.ts +46 -0
  344. package/src/ui/i18n.ts +17 -2
  345. package/src/ui/menu-placement.ts +1 -1
  346. package/src/ui/migration-consult-view.test.ts +20 -1
  347. package/src/ui/migration-consult-view.ts +17 -0
  348. package/src/ui/overview-view.ts +10 -0
  349. package/src/ui/report.test.ts +25 -1
  350. package/src/ui/report.ts +15 -4
  351. package/src/ui/selection-model.test.ts +15 -1
  352. package/src/ui/selection-model.ts +18 -0
  353. package/src/utils/js-yaml4.d.ts +35 -0
  354. package/src/utils/patch-yaml.test.ts +207 -1
  355. package/src/utils/patch-yaml.ts +98 -2
  356. package/src/utils/paths.test.ts +14 -1
  357. package/src/utils/paths.ts +35 -0
  358. package/src/utils/workdir-lock.test.ts +69 -0
  359. package/src/utils/workdir-lock.ts +17 -3
  360. package/lib/ui/path-mapping.d.ts +0 -38
  361. package/lib/ui/path-mapping.js +0 -75
  362. package/src/client/common/InfoHint.tsx +0 -289
  363. package/src/client/common/info-hint-guard.test.ts +0 -1119
  364. package/src/client/sync/DecryptPasswordCard.tsx +0 -48
  365. package/src/client/sync/SecurityOptionsCard.tsx +0 -97
  366. package/src/client/sync/SyncSectionPickerDialog.tsx +0 -213
  367. package/src/ui/path-mapping.test.ts +0 -67
  368. package/src/ui/path-mapping.ts +0 -103
@@ -34,7 +34,7 @@ import { GC_SKIP_REFERENCE_MISSING, GC_SKIP_REFERENCE_UNREADABLE, GC_SKIP_SNAPSH
34
34
  import '../messages.js';
35
35
  import { deserializeSnapshot, serializeSnapshot } from '../snapshot-json.js';
36
36
  import { BLOB_SECTIONS, gcBlobs, isBlobRefsSection, isFilesSectionLike, referencedBlobHashes, refsToSection, sectionToBlobRefs } from '../blob-store.js';
37
- import { classifyHttpStatus, classifyNetworkErrorText, computeSnapshotMeta, DEFAULT_SYNC_TIMEOUT_MS, isEncryptedSections, sectionsEqual, SyncTransportError, withSyncRetry, } from '../transport.js';
37
+ import { classifyHttpStatus, classifyNetworkErrorText, computeSnapshotMeta, DEFAULT_SYNC_TIMEOUT_MS, isEncryptedSections, isPreconditionFailedStatus, sectionsEqual, SyncTransportError, withSyncRetry, } from '../transport.js';
38
38
  import { parseJsonSafe } from '../../utils/json.js';
39
39
  /** 快照 id 安全字符集:字母数字开头,仅 . _ -;防路径穿越与 URL 注入 */
40
40
  const SAFE_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
@@ -337,12 +337,15 @@ export class WebDavTransport {
337
337
  const merged = idxBefore.filter((m) => m.id !== snapshot.id);
338
338
  merged.push(meta);
339
339
  merged.sort((a, b) => (a.createdAt < b.createdAt ? -1 : a.createdAt > b.createdAt ? 1 : 0));
340
+ const idxHeaders = conditionalHeaders(idxEtag, indexMissing);
340
341
  const putIdx = await this.send('PUT', idxUrl, pwd, {
341
342
  body: JSON.stringify(merged),
342
- headers: conditionalHeaders(idxEtag, indexMissing),
343
+ headers: idxHeaders,
343
344
  });
344
- if (putIdx.status === 412)
345
+ // 条件写失败判定与 s3 通道共用 transport.ts 的唯一实现(412 恒算;409 仅在真的带了条件头时算)
346
+ if (isPreconditionFailedStatus(putIdx.status, { guarded: Object.keys(idxHeaders).length > 0 })) {
345
347
  throw this.concurrentWrite(idxUrl, putIdx.status);
348
+ }
346
349
  if (!putIdx.ok) {
347
350
  throw new WebDavTransportError(await this.failText('PUT', idxUrl, putIdx, pwd), classifyHttpStatus(putIdx.status));
348
351
  }
@@ -385,31 +388,47 @@ export class WebDavTransport {
385
388
  // gcBlobStore 以空引用集回收,删掉仍被现存快照文件引用的会话 blob(不可恢复)。
386
389
  // 与 F1 同口径:宁可显式失败,也不制造不可恢复的远端状态。list() 仍保留「404 = 空集合」语义。
387
390
  const { entries: idx, missing: indexMissing, etag: idxEtag } = await this.readIndexDetailed(pwd);
388
- // delete 快照文件:404 = 不存在,视为成功
389
391
  const url = this.snapshotUrl(id);
390
- const res = await this.send('DELETE', url, pwd);
391
- if (!res.ok && res.status !== 404) {
392
- throw new WebDavTransportError(await this.failText('DELETE', url, res, pwd), classifyHttpStatus(res.status));
393
- }
394
- // audit-sync sync-N1(P0):索引真缺失(404)= **缺信息**而不是「集合为空」。此时「哪些 blob
395
- // 无人引用」无从证明 —— 一律**不写回 index.json、不触发 blob GC**,其余快照与其引用的 blob
396
- // 原样保留(宁可留垃圾,不可删在用的)。目标快照文件已按用户意图删除(404 视为成功)。
397
- if (indexMissing)
392
+ if (indexMissing) {
393
+ // audit-sync sync-N1(P0):索引真缺失(404)= **缺信息**而不是「集合为空」。此时「哪些 blob
394
+ // 无人引用」无从证明 —— 一律**不写回 index.json、不触发 blob GC**,其余快照与其引用的 blob
395
+ // 原样保留(宁可留垃圾,不可删在用的)。目标快照文件按用户意图删除(404 视为成功)。
396
+ const res = await this.send('DELETE', url, pwd);
397
+ if (!res.ok && res.status !== 404) {
398
+ throw new WebDavTransportError(await this.failText('DELETE', url, res, pwd), classifyHttpStatus(res.status));
399
+ }
398
400
  return;
399
- // 若 index 中无该 id,则无需写回
401
+ }
400
402
  const remaining = idx.filter((m) => m.id !== id);
401
- if (remaining.length === idx.length && res.status === 404) {
402
- return; // 文件与 index 都不存在 → 静默成功,无写回
403
+ const entryPresent = remaining.length !== idx.length;
404
+ // audit-sync sync-P6-1(P3):**先写索引、后删对象**。
405
+ // 反序(旧实现先 DELETE 快照文件)的伤害:索引 PUT 回 412(别的设备刚改过索引)时本次删除已
406
+ // 抛错中止,但对象已经没了 ⇒ 索引里留下指向不存在对象的条目;list() 不校验存在性,别的设备
407
+ // pull 到该 id 就是 notfound 硬失败,只能靠用户再删一次自愈。
408
+ // 调整顺序后的**最坏情况**:索引写成功而对象 DELETE 失败 ⇒ 远端留一个索引里不存在、list()
409
+ // 看不到、pull 不会命中的孤儿文件(只占空间);重跑 delete 会把对象补删(404 视为成功)。
410
+ // 「多一个看不见的孤儿文件」远轻于「索引指向已删对象」,因此顺序必须是索引在前。
411
+ if (entryPresent) {
412
+ const idxHeaders = conditionalHeaders(idxEtag, false);
413
+ const putIdx = await this.send('PUT', idxUrl, pwd, {
414
+ body: JSON.stringify(remaining),
415
+ headers: idxHeaders,
416
+ });
417
+ // 判定与 s3 通道共用同一实现(412 恒算;409 仅在真的带了条件头时算)
418
+ if (isPreconditionFailedStatus(putIdx.status, { guarded: Object.keys(idxHeaders).length > 0 })) {
419
+ throw this.concurrentWrite(idxUrl, putIdx.status);
420
+ }
421
+ if (!putIdx.ok) {
422
+ throw new WebDavTransportError(await this.failText('PUT', idxUrl, putIdx, pwd), classifyHttpStatus(putIdx.status));
423
+ }
403
424
  }
404
- const putIdx = await this.send('PUT', idxUrl, pwd, {
405
- body: JSON.stringify(remaining),
406
- headers: conditionalHeaders(idxEtag, false),
407
- });
408
- if (putIdx.status === 412)
409
- throw this.concurrentWrite(idxUrl, putIdx.status);
410
- if (!putIdx.ok) {
411
- throw new WebDavTransportError(await this.failText('PUT', idxUrl, putIdx, pwd), classifyHttpStatus(putIdx.status));
425
+ // 索引已摘除(或本来就无该 id)后才动对象:404 = 不存在,视为成功
426
+ const res = await this.send('DELETE', url, pwd);
427
+ if (!res.ok && res.status !== 404) {
428
+ throw new WebDavTransportError(await this.failText('DELETE', url, res, pwd), classifyHttpStatus(res.status));
412
429
  }
430
+ if (!entryPresent && !res.ok)
431
+ return; // 索引无该 id 且对象本就不存在 → 静默成功,无 GC 可做
413
432
  // P1-4:快照被裁掉后回收无人引用的 blob(best-effort,失败不影响删除结果)
414
433
  await this.gcBlobStore(pwd, remaining).catch(() => undefined);
415
434
  }
@@ -437,7 +456,10 @@ export class WebDavTransport {
437
456
  throw new WebDavTransportError(await this.failText('MKCOL', url, res, pwd), classifyHttpStatus(res.status));
438
457
  }
439
458
  }
440
- /** 把本次新写入的 blob 合并进远端索引(写失败 → 抛错,调用方看到的是上传失败而非静默漏记)。 */
459
+ /**
460
+ * 把本次新写入的 blob 合并进远端索引(写失败 → 抛错,调用方看到的是上传失败而非静默漏记)。
461
+ * audit-sync sync-P6-4(P3):这里的读失败必须上抛 —— 整体 PUT 会覆盖远端已登记条目。
462
+ */
441
463
  async appendBlobIndex(fresh, pwd) {
442
464
  const index = await this.readBlobIndex(pwd);
443
465
  for (const [hash, at] of fresh)
@@ -480,28 +502,47 @@ export class WebDavTransport {
480
502
  return true; // 体读不出来 ⇒ 判不了 ⇒ 按有内容
481
503
  }
482
504
  }
483
- /** 读取 blob 索引(哈希 → 写入时间 ms);缺失/损坏 → 空(GC 只会「少删」,不会误删)。 */
505
+ /** 读取 blob 索引(哈希 → 写入时间 ms);只读失败即抛,绝不回落成空索引,见 readBlobIndexDetailed。 */
484
506
  async readBlobIndex(pwd) {
507
+ return (await this.readBlobIndexDetailed(pwd)).index;
508
+ }
509
+ /**
510
+ * audit-sync sync-P6-4(P3):读 blob 索引的**带缺失标志**版本 —— 「读失败」与「确实没有索引」必须分开。
511
+ *
512
+ * 旧实现把 5xx / 坏 JSON / 非法结构一律当成空索引返回,紧接着 appendBlobIndex 读→合并→**整体 PUT**,
513
+ * 于是「一次读抖动」= 远端索引被覆盖成本次新增的那几条,已登记条目全丢(GC 从此看不见这些 blob,
514
+ * 等于远端漏账;再叠加 delete 的 GC 就可能删掉它们)。语义因此必须三态:
515
+ * - 404 / 405 / 501 → missing = true:**缺资源**。405/501 是部分 WebDAV 服务端表达「没有这个资源」
516
+ * 的方言(与 remoteHasPriorContent 同口径),此时确实没有索引可丢,按空处理是安全的;
517
+ * - 其它非 2xx(5xx / 403 / …)→ 抛错(可重试):读不出来就**不许**整体覆盖,让上传显式失败;
518
+ * - 200 但坏 JSON / 非对象 → 抛 protocol(不可重试):索引损坏是远端状态问题,覆盖写会抹掉残存记录。
519
+ *
520
+ * 最坏情况(可重试失败):本可跳过的 blob 被重传一遍,或本次 blob 漏登记(只占空间,不误删)。
521
+ */
522
+ async readBlobIndexDetailed(pwd) {
485
523
  const url = this.blobsIndexUrl();
486
524
  const res = await this.send('GET', url, pwd);
487
- if (res.status === 404)
488
- return {};
489
- if (!res.ok)
490
- return {};
525
+ if (res.status === 404 || res.status === 405 || res.status === 501)
526
+ return { index: {}, missing: true };
527
+ if (!res.ok) {
528
+ throw new WebDavTransportError(await this.failText('GET', url, res, pwd), classifyHttpStatus(res.status));
529
+ }
530
+ let parsed;
491
531
  try {
492
- const parsed = parseJsonSafe(await res.text());
493
- if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
494
- return {};
495
- const out = {};
496
- for (const [hash, at] of Object.entries(parsed)) {
497
- if (BLOB_HASH_RE.test(hash) && typeof at === 'number' && Number.isFinite(at))
498
- out[hash] = at;
499
- }
500
- return out;
532
+ parsed = parseJsonSafe(await res.text());
501
533
  }
502
- catch {
503
- return {};
534
+ catch (err) {
535
+ throw new WebDavTransportError(this.o.msg('sync.webdav.indexInvalid', { url, err: this.mask(String(err?.message ?? ''), pwd) }), { kind: 'protocol', retryable: false });
536
+ }
537
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
538
+ throw new WebDavTransportError(this.o.msg('sync.webdav.indexInvalid', { url, err: 'not an object' }), { kind: 'protocol', retryable: false });
539
+ }
540
+ const out = {};
541
+ for (const [hash, at] of Object.entries(parsed)) {
542
+ if (BLOB_HASH_RE.test(hash) && typeof at === 'number' && Number.isFinite(at))
543
+ out[hash] = at;
504
544
  }
545
+ return { index: out, missing: false };
505
546
  }
506
547
  async writeBlobIndex(pwd, index) {
507
548
  const url = this.blobsIndexUrl();
@@ -11,16 +11,10 @@
11
11
  * - 命令 id 用英文(`go.overview` / `export.open`),顺带充当英文别名:
12
12
  * 中文用户敲「导出」命中标题,英文用户敲 "export" 命中 id。
13
13
  */
14
- /**
15
- * 通道搜索词 = **受守卫的客户端镜像**。
16
- *
17
- * 为什么必须写成这个形状:t32 源码守卫(`src/sync/sync-config.test.ts`)把「两个通道名的
18
- * 字面量相邻出现」视为第二处通道枚举声明(历史上一模一样的两份数组漏改过一份,导致某通道
19
- * 永不排期),只有带 `satisfies` 穷尽标记的客户端镜像才放行。**连注释里都不许把这两个名字
20
- * 写成相邻的带引号字面量** —— 守卫扫的是文本,不区分代码与注释。
21
- * 写成搜索关键词也一样要守这条规矩 —— 守卫认的是形状,不是用途。
22
- */
23
- const SYNC_CHANNEL_TERMS = ['git', 'webdav'];
14
+ // 通道搜索词只认**唯一事实源** `SYNC_CHANNELS`(`src/utils/shared-constants.ts`,零依赖,
15
+ // client 侧已有多处运行时 import 先例)。这里绝不再抄一份清单:手写镜像漏过 s3/gist,
16
+ // 结果搜这两个通道名时「同步」一条命令都不出现(审计 P10-1)。通道增删时这里自动跟随。
17
+ import { SYNC_CHANNELS } from '../utils/shared-constants.js';
24
18
  /** 命令面板的分组渲染顺序。 */
25
19
  export const COMMAND_GROUP_ORDER = ['navigate', 'library', 'action', 'view', 'rescue'];
26
20
  /** 默认最多返回多少条(面板限高,再多也看不见)。 */
@@ -41,7 +35,7 @@ export const COMMANDS = [
41
35
  // —— 前往:四个一级页面(v3 §3.1;市场不再是页面)——
42
36
  { id: 'go.home', group: 'navigate', titleKey: 'nav.home', keywords: ['home', 'overview', '首页', '总览'] },
43
37
  { id: 'go.library', group: 'navigate', titleKey: 'library.title', keywords: ['library', 'artifact', '产物', '快照'] },
44
- { id: 'go.sync', group: 'navigate', titleKey: 'nav.sync', keywords: ['sync', ...SYNC_CHANNEL_TERMS, '同步'] },
38
+ { id: 'go.sync', group: 'navigate', titleKey: 'nav.sync', keywords: ['sync', ...SYNC_CHANNELS, '同步'] },
45
39
  {
46
40
  // 环境 = 档案 + 维护与诊断。文案用导航条上的名字(environment.title),
47
41
  // 不用旧的 nav.profiles('档案')—— 面板里找不到「档案」这个页面。
@@ -73,10 +73,14 @@ export declare function profileInstallCommand(name: string): string;
73
73
  */
74
74
  export declare function suggestCopyName(name: string, existingNames: readonly string[], maxLength?: number): string;
75
75
  /**
76
- * 复制告警码 → i18n key。目前只有 `depsNotInstalled` 一类(副本没带 node_modules 却声明了依赖),
77
- * 返回类型写成字面量联合:新增告警码时这里会编译报错,逼着补文案而不是静默吞掉。
76
+ * 复制告警码 → i18n key。目前只有 `depsNotInstalled` 一类(副本没带 node_modules 却声明了依赖)。
77
+ *
78
+ * 为什么是 `Record<告警码, 文案键>` 而不是 if + 兜底:原先 if 与兜底 return 同一字面量,
79
+ * 任何新告警码都会被静默显示成「缺 node_modules」的文案,注释里承诺的「新增码编译报错」
80
+ * 并不存在(审计 P10-4)。Record 的键即告警码全集 —— 码增删而映射不跟上就是编译错误。
78
81
  */
79
- export declare function copyWarningKey(warning: DshProfileCopyWarning): 'profiles.duplicate.warn.depsNotInstalled';
82
+ declare const COPY_WARNING_KEY: Record<DshProfileCopyWarning, 'profiles.duplicate.warn.depsNotInstalled'>;
83
+ export declare function copyWarningKey(warning: DshProfileCopyWarning): (typeof COPY_WARNING_KEY)[DshProfileCopyWarning];
80
84
  /** 终端启动命令(非 web 形态没有浏览器界面,只能在终端用它拉起)。 */
81
85
  export declare function restartCommand(name: string): string;
82
86
  /**
@@ -173,3 +177,4 @@ export declare function issueLabelKey(issue: DshProfileIssue): 'profiles.issue.m
173
177
  export declare function formatProfileTime(ms: number | null): string;
174
178
  /** 字节数 → 人类可读(B / KB / MB,保留一位小数)。 */
175
179
  export declare function formatBytes(bytes: number): string;
180
+ export {};
@@ -112,13 +112,17 @@ export function suggestCopyName(name, existingNames, maxLength = 64) {
112
112
  }
113
113
  }
114
114
  /**
115
- * 复制告警码 → i18n key。目前只有 `depsNotInstalled` 一类(副本没带 node_modules 却声明了依赖),
116
- * 返回类型写成字面量联合:新增告警码时这里会编译报错,逼着补文案而不是静默吞掉。
115
+ * 复制告警码 → i18n key。目前只有 `depsNotInstalled` 一类(副本没带 node_modules 却声明了依赖)。
116
+ *
117
+ * 为什么是 `Record<告警码, 文案键>` 而不是 if + 兜底:原先 if 与兜底 return 同一字面量,
118
+ * 任何新告警码都会被静默显示成「缺 node_modules」的文案,注释里承诺的「新增码编译报错」
119
+ * 并不存在(审计 P10-4)。Record 的键即告警码全集 —— 码增删而映射不跟上就是编译错误。
117
120
  */
121
+ const COPY_WARNING_KEY = {
122
+ depsNotInstalled: 'profiles.duplicate.warn.depsNotInstalled',
123
+ };
118
124
  export function copyWarningKey(warning) {
119
- if (warning === 'depsNotInstalled')
120
- return 'profiles.duplicate.warn.depsNotInstalled';
121
- return 'profiles.duplicate.warn.depsNotInstalled';
125
+ return COPY_WARNING_KEY[warning];
122
126
  }
123
127
  /** 终端启动命令(非 web 形态没有浏览器界面,只能在终端用它拉起)。 */
124
128
  export function restartCommand(name) {
@@ -164,3 +164,22 @@ export declare const FOREIGN_LOSSY_KINDS: readonly ForeignLossyKind[];
164
164
  * · **`prompts` 分区** → `systemPrompt` 由字符串写成 `{ persona }` 对象(bundle-format §7.3)。
165
165
  */
166
166
  export declare function foreignLossyRows(sections: readonly string[] | null, t: UiT): readonly ForeignLossyRow[];
167
+ /**
168
+ * 导入失败 → 可见载荷(码 + 后端原话 + 一句人话)。
169
+ *
170
+ * 为什么要有它:宿主把「为什么没东西可导」放在 **400 的 body**(`code` + `skipped`),
171
+ * 而客户端过去只显示 `err.message` —— 于是 `sessions-not-migrated`、
172
+ * `trae-db-key-invalid` 这些**字典里早就有中英文案**的码,用户根本看不到。
173
+ * 现在按同一本字典把码翻成文案(skip 码走冻结映射,`nothing-to-import` 走单独一条键),
174
+ * 翻不出才回落后端 message —— 绝不吞掉原因,也绝不编解释。
175
+ */
176
+ export interface ForeignImportFailure {
177
+ /** 稳定机器码(后端 400 带的 code;没有则为 null) */
178
+ code: string | null;
179
+ /** 后端原始 message(渲染处再过 redact) */
180
+ message: string;
181
+ /** 展示文案(字典优先;没有就用 message) */
182
+ text: string;
183
+ }
184
+ /** 失败载荷的构造(未知码 → 原样返回 message,绝不猜语义) */
185
+ export declare function foreignImportFailure(err: unknown, t: UiT): ForeignImportFailure;
@@ -51,6 +51,11 @@ export const FOREIGN_SKIP_KEY = {
51
51
  'session-id-mismatch': 'foreign.skip.session-id-mismatch',
52
52
  'mcp-server-id-conflict': 'foreign.skip.mcp-server-id-conflict',
53
53
  'project-scan-truncated': 'foreign.skip.project-scan-truncated',
54
+ // 2026-11-12(#134):Trae 2.3.x 加密会话库的四条可判定失败 —— 同样是全量 Record 保底
55
+ 'trae-db-key-invalid': 'foreign.skip.trae-db-key-invalid',
56
+ 'trae-db-too-large': 'foreign.skip.trae-db-too-large',
57
+ 'trae-db-decrypt-failed': 'foreign.skip.trae-db-decrypt-failed',
58
+ 'trae-db-schema-mismatch': 'foreign.skip.trae-db-schema-mismatch',
54
59
  };
55
60
  /**
56
61
  * 机器码 → 字典键。**未知码(未来版本 / 第三方宿主)回退键名本身**,
@@ -256,4 +261,23 @@ export function foreignLossyRows(sections, t) {
256
261
  applicable: applicable[kind],
257
262
  }));
258
263
  }
264
+ /**
265
+ * 非 skip 词表、但同样会作为 400 码出现的导入失败(与 `src/routes/foreign.ts` 同源):
266
+ * `nothing-to-import` 是路由层的码,不在 `ForeignSkipCode` union 里,故单独映射。
267
+ */
268
+ const IMPORT_FAILURE_KEYS = {
269
+ 'nothing-to-import': 'foreign.importNothing',
270
+ };
271
+ /** 失败载荷的构造(未知码 → 原样返回 message,绝不猜语义) */
272
+ export function foreignImportFailure(err, t) {
273
+ const source = typeof err === 'object' && err !== null ? err : null;
274
+ const rawCode = source?.code;
275
+ const code = typeof rawCode === 'string' && rawCode !== '' ? rawCode : null;
276
+ const rawMessage = source?.message;
277
+ const message = typeof rawMessage === 'string' && rawMessage !== '' ? rawMessage : String(err);
278
+ if (code === null)
279
+ return { code, message, text: message };
280
+ const mapped = IMPORT_FAILURE_KEYS[code] ?? (isKnownSkipCode(code) ? FOREIGN_SKIP_KEY[code] : undefined);
281
+ return { code, message, text: mapped === undefined ? message : t(mapped) };
282
+ }
259
283
  //# sourceMappingURL=foreign-view.js.map
package/lib/ui/i18n.d.ts CHANGED
@@ -137,7 +137,6 @@ export declare const uiZh: {
137
137
  readonly 'snapshots.failed': '失败';
138
138
  readonly 'snapshots.skipped': '跳过';
139
139
  readonly 'snapshots.noActions': '该快照无可恢复动作(或全部跳过)。';
140
- readonly 'snapshots.selectHint': '选择一个快照预览其恢复计划(只读预览,不会改动任何设置):';
141
140
  readonly 'snapshots.reportTitle': '恢复报告';
142
141
  readonly 'sync.privateRepoHint': '安全要求:同步仓库必须为私有仓库(public 仓库会公开你的配置内容)。认证 token 仅用于仓库访问,绝不写入同步文件、提交内容或日志。';
143
142
  readonly 'sync.kind.create': '新增';
@@ -166,6 +165,7 @@ export declare const uiZh: {
166
165
  readonly 'sync.neverSyncedShort': '从未同步';
167
166
  readonly 'sync.pushFailed': '推送失败';
168
167
  readonly 'sync.pushOk': '推送成功(快照 {id})';
168
+ readonly 'sync.pushSkipped': '内容未变化,已跳过(沿用远端快照 {id})';
169
169
  readonly 'sync.conflictUnresolved': '冲突项 {id} 必须先选择解决方式(保留当前 / 使用导入)';
170
170
  readonly 'sync.pushPreviewHeadline': '将推送 {total} 个分区({changed} 个有变化)';
171
171
  readonly 'sync.pushPreviewEncrypted': '加密快照:载荷将整体加密,各分区相对基线的变化不可比对。';
@@ -247,6 +247,7 @@ export declare const uiZh: {
247
247
  readonly 'consult.loading': '正在生成咨询报告…';
248
248
  readonly 'diskUsage.title': '磁盘占用';
249
249
  readonly 'diskUsage.files': '{count} 个文件';
250
+ readonly 'diskUsage.total': '合计 {size} · {files}';
250
251
  readonly 'diskUsage.refresh': '重新体检';
251
252
  readonly 'diskUsage.loading': '正在统计磁盘占用…';
252
253
  readonly 'diskUsage.unreadable': '未统计';
@@ -427,6 +428,11 @@ export declare const uiZh: {
427
428
  readonly 'foreign.skip.legacy-rules-file': '旧式规则文件:DSH 无对等结构,只报告';
428
429
  readonly 'foreign.skip.instructions-merged': '多份指令源被合并为一个全局指令文件';
429
430
  readonly 'foreign.skip.instructions-override-selected': '命中更高优先级的指令文件(override),按它导入';
431
+ readonly 'foreign.importNothing': '没有可导入的内容:该来源在本机没有可转换的配置或会话';
432
+ readonly 'foreign.skip.trae-db-key-invalid': 'Trae 加密会话库的密钥对不上(换版或密钥被覆盖):页面头校验不通过,本次未读出任何会话';
433
+ readonly 'foreign.skip.trae-db-too-large': 'Trae 加密会话库超出本来源的体积上限:未解密,未读出任何会话(全局 1 GiB 上限未改动)';
434
+ readonly 'foreign.skip.trae-db-decrypt-failed': 'Trae 加密会话库无法解密:文件被截断、不是 SQLCipher 形态或读取失败,本次未读出任何会话';
435
+ readonly 'foreign.skip.trae-db-schema-mismatch': 'Trae 加密会话库解密成功但表结构不符(缺 chat_session / history_v2 或必需列):不猜字段,本次未读出任何会话';
430
436
  readonly 'foreign.skip.unsupported-permissions': '权限规则(allow/ask/deny)未迁移:DSH 没有权限规则文件的对等结构,这些规则不在本包内,导入后不会生效';
431
437
  readonly 'foreign.skip.unsupported-settings-keys': 'settings.json 里其余未迁移的顶层键:只记录键名与条数,键值一律不读取,也不会写进本包';
432
438
  readonly 'foreign.skip.unsupported-agents': '.claude/agents/*.md 子代理定义未迁移:DSH 的子代理是运行时 provider 注册制,没有文件级对等结构';
package/lib/ui/i18n.js CHANGED
@@ -146,7 +146,6 @@ export const uiZh = {
146
146
  'snapshots.failed': '失败',
147
147
  'snapshots.skipped': '跳过',
148
148
  'snapshots.noActions': '该快照无可恢复动作(或全部跳过)。',
149
- 'snapshots.selectHint': '选择一个快照预览其恢复计划(只读预览,不会改动任何设置):',
150
149
  'snapshots.reportTitle': '恢复报告',
151
150
  // 同步区块(sync-view)
152
151
  'sync.privateRepoHint': '安全要求:同步仓库必须为私有仓库(public 仓库会公开你的配置内容)。认证 token 仅用于仓库访问,绝不写入同步文件、提交内容或日志。',
@@ -176,6 +175,7 @@ export const uiZh = {
176
175
  'sync.neverSyncedShort': '从未同步',
177
176
  'sync.pushFailed': '推送失败',
178
177
  'sync.pushOk': '推送成功(快照 {id})',
178
+ 'sync.pushSkipped': '内容未变化,已跳过(沿用远端快照 {id})',
179
179
  'sync.conflictUnresolved': '冲突项 {id} 必须先选择解决方式(保留当前 / 使用导入)',
180
180
  'sync.pushPreviewHeadline': '将推送 {total} 个分区({changed} 个有变化)',
181
181
  'sync.pushPreviewEncrypted': '加密快照:载荷将整体加密,各分区相对基线的变化不可比对。',
@@ -265,6 +265,7 @@ export const uiZh = {
265
265
  'consult.loading': '正在生成咨询报告…',
266
266
  'diskUsage.title': '磁盘占用',
267
267
  'diskUsage.files': '{count} 个文件',
268
+ 'diskUsage.total': '合计 {size} · {files}',
268
269
  'diskUsage.refresh': '重新体检',
269
270
  'diskUsage.loading': '正在统计磁盘占用…',
270
271
  'diskUsage.unreadable': '未统计',
@@ -452,6 +453,13 @@ export const uiZh = {
452
453
  'foreign.skip.legacy-rules-file': '旧式规则文件:DSH 无对等结构,只报告',
453
454
  'foreign.skip.instructions-merged': '多份指令源被合并为一个全局指令文件',
454
455
  'foreign.skip.instructions-override-selected': '命中更高优先级的指令文件(override),按它导入',
456
+ // ---------- 2026-11-12(#134):Trae 2.3.x 的加密会话库(SQLCipher)四条可判定失败 ----------
457
+ // 纪律同上:每条都要能被代码逐条证明 —— 只说「什么没搬 / 为什么 / 怎么办」,不承诺修好。
458
+ 'foreign.importNothing': '没有可导入的内容:该来源在本机没有可转换的配置或会话',
459
+ 'foreign.skip.trae-db-key-invalid': 'Trae 加密会话库的密钥对不上(换版或密钥被覆盖):页面头校验不通过,本次未读出任何会话',
460
+ 'foreign.skip.trae-db-too-large': 'Trae 加密会话库超出本来源的体积上限:未解密,未读出任何会话(全局 1 GiB 上限未改动)',
461
+ 'foreign.skip.trae-db-decrypt-failed': 'Trae 加密会话库无法解密:文件被截断、不是 SQLCipher 形态或读取失败,本次未读出任何会话',
462
+ 'foreign.skip.trae-db-schema-mismatch': 'Trae 加密会话库解密成功但表结构不符(缺 chat_session / history_v2 或必需列):不猜字段,本次未读出任何会话',
455
463
  // ---------- 2026-10-18:Claude Code 项目级配置 / 插件 / 权限 / 设置键的如实诊断(8 个新码)----------
456
464
  // 纪律:每条都要能被代码逐条证明 —— 只说「什么没搬、为什么、本项是否可补」,
457
465
  // 绝不写「已支持 / 完全兼容」这类无法被代码证明的话。
@@ -637,7 +645,6 @@ export const uiEn = {
637
645
  'snapshots.failed': 'Failed',
638
646
  'snapshots.skipped': 'Skipped',
639
647
  'snapshots.noActions': 'No restorable actions for this snapshot (or all skipped).',
640
- 'snapshots.selectHint': 'Select a snapshot to preview its restore plan (read-only preview, changes nothing):',
641
648
  'snapshots.reportTitle': 'Restore Report',
642
649
  'sync.privateRepoHint': 'Security requirement: the sync repository MUST be private (a public repo would expose your configuration). The auth token is only used for repository access and is never written into sync files, commit content, or logs.',
643
650
  'sync.kind.create': 'Create',
@@ -666,6 +673,7 @@ export const uiEn = {
666
673
  'sync.neverSyncedShort': 'Never synced',
667
674
  'sync.pushFailed': 'Push failed',
668
675
  'sync.pushOk': 'Push succeeded (snapshot {id})',
676
+ 'sync.pushSkipped': 'No content changes — skipped (reusing remote snapshot {id})',
669
677
  'sync.conflictUnresolved': 'Conflict item {id} must be resolved first (keep current / use imported)',
670
678
  'sync.pushPreviewHeadline': 'Will push {total} {total, plural, section|sections} ({changed} changed)',
671
679
  'sync.pushPreviewEncrypted': 'Encrypted snapshot: the payload is encrypted as a whole; per-section changes vs the baseline cannot be compared.',
@@ -747,6 +755,7 @@ export const uiEn = {
747
755
  'consult.loading': 'Generating consultation report…',
748
756
  'diskUsage.title': 'Disk Usage',
749
757
  'diskUsage.files': '{count} {count, plural, file|files}',
758
+ 'diskUsage.total': 'Total {size} · {files}',
750
759
  'diskUsage.refresh': 'Re-scan',
751
760
  'diskUsage.loading': 'Measuring disk usage…',
752
761
  'diskUsage.unreadable': 'not measured',
@@ -930,6 +939,12 @@ export const uiEn = {
930
939
  'foreign.skip.legacy-rules-file': 'Legacy rules file: DSH has no equivalent, reported only',
931
940
  'foreign.skip.instructions-merged': 'Several instruction sources were merged into one global instruction file',
932
941
  'foreign.skip.instructions-override-selected': 'A higher-priority instruction file (override) was found and is the one imported',
942
+ // 2026-11-12 (#134): four decidable failures of the Trae 2.3.x encrypted session database (SQLCipher)
943
+ 'foreign.importNothing': 'Nothing to import: this source has no convertible configuration or sessions on this machine',
944
+ 'foreign.skip.trae-db-key-invalid': 'The Trae encrypted session database key does not match (version change or an overridden key): the page-header checks failed, so no session was read',
945
+ 'foreign.skip.trae-db-too-large': 'The Trae encrypted session database exceeds this source size limit: it was not decrypted, so no session was read (the global 1 GiB limit is unchanged)',
946
+ 'foreign.skip.trae-db-decrypt-failed': 'The Trae encrypted session database cannot be decrypted: the file is truncated, not in SQLCipher form, or unreadable, so no session was read',
947
+ 'foreign.skip.trae-db-schema-mismatch': 'The Trae encrypted session database decrypted but its schema does not match (chat_session / history_v2 or a required column is missing): fields are never guessed, so no session was read',
933
948
  // 2026-10-18: honest diagnostics for Claude Code project-level config / plugins / permissions / settings keys (8 new codes)
934
949
  'foreign.skip.unsupported-permissions': 'Permission rules (allow/ask/deny) were not migrated: DSH has no equivalent permission-rule file, so they are not in this bundle and will not take effect after import',
935
950
  'foreign.skip.unsupported-settings-keys': 'Other unmigrated top-level keys in settings.json: only key names and counts are recorded; values are never read and never enter this bundle',
@@ -46,7 +46,7 @@ export function placeMenu(anchor, bounds, menu) {
46
46
  if (left + menu.width > bounds.right - MENU_EDGE)
47
47
  left = anchor.right - menu.width;
48
48
  left = clampNumber(left, minLeft, maxLeft);
49
- // 垂直:下方优先;下方放不下且上方更宽裕 → 向上翻转(与 InfoHint 气泡同一判据)。
49
+ // 垂直:下方优先;下方放不下且上方更宽裕 → 向上翻转(与 Select 菜单同一判据)。
50
50
  const below = bounds.bottom - anchor.bottom - MENU_GAP - MENU_EDGE;
51
51
  const above = anchor.top - bounds.top - MENU_GAP - MENU_EDGE;
52
52
  const side = menu.height > below && above > below ? 'top' : 'bottom';
@@ -20,7 +20,10 @@ export interface ConsultDimensionView {
20
20
  label: string;
21
21
  score: number;
22
22
  verdict: HealthVerdict;
23
+ /** 维度名徽章的 kind(按 verdict,历史上用于整枚徽章着色) */
23
24
  badgeKind: ConsultBadgeKind;
25
+ /** 分数徽章的 kind(按分数档位派生 —— 稿上分数用绿/橙分色,与文字 verdict 无关) */
26
+ scoreKind: ConsultBadgeKind;
24
27
  issues: {
25
28
  severity: 'info' | 'warning' | 'error';
26
29
  message: string;
@@ -88,6 +91,14 @@ export declare function consultVerdictBadgeKind(v: HealthVerdict): ConsultBadgeK
88
91
  export declare function consultRecommendationBadgeKind(r: Recommendation): ConsultBadgeKind;
89
92
  /** 维度 label(i18n key 后缀) */
90
93
  export declare function consultDimensionLabel(id: ConsultDimensionId, t: UiT): string;
94
+ /**
95
+ * 维度分数 → 徽章 kind(稿 D-03:161-200 的分色口径,纯函数):
96
+ * ≥90 ok(绿)/ ≥70 warn(橙)/ 其余 error(红)。
97
+ *
98
+ * 为什么分数不再借用 verdict 的 kind:同一维度可能 verdict=warning 而分数 92(绿),
99
+ * 稿上颜色跟的是**分数**,把 verdict 色套到分数上会出现「92 分却标橙」的自相矛盾。
100
+ */
101
+ export declare function consultScoreBadgeKind(score: number): ConsultBadgeKind;
91
102
  /** 把 ConsultReport 转成视图数据(纯函数) */
92
103
  export declare function consultView(report: ConsultReport, t: UiT): ConsultView;
93
104
  /** recommendation 的可读标签 */
@@ -75,6 +75,20 @@ export function consultDimensionLabel(id, t) {
75
75
  case 'migratability': return t('consult.dim.migratability');
76
76
  }
77
77
  }
78
+ /**
79
+ * 维度分数 → 徽章 kind(稿 D-03:161-200 的分色口径,纯函数):
80
+ * ≥90 ok(绿)/ ≥70 warn(橙)/ 其余 error(红)。
81
+ *
82
+ * 为什么分数不再借用 verdict 的 kind:同一维度可能 verdict=warning 而分数 92(绿),
83
+ * 稿上颜色跟的是**分数**,把 verdict 色套到分数上会出现「92 分却标橙」的自相矛盾。
84
+ */
85
+ export function consultScoreBadgeKind(score) {
86
+ if (score >= 90)
87
+ return 'ok';
88
+ if (score >= 70)
89
+ return 'warn';
90
+ return 'error';
91
+ }
78
92
  /** 把 ConsultReport 转成视图数据(纯函数) */
79
93
  export function consultView(report, t) {
80
94
  const dimensions = report.dimensions.map((d) => ({
@@ -83,6 +97,7 @@ export function consultView(report, t) {
83
97
  score: d.score,
84
98
  verdict: d.verdict,
85
99
  badgeKind: consultVerdictBadgeKind(d.verdict),
100
+ scoreKind: consultScoreBadgeKind(d.score),
86
101
  issues: d.issues.map((i) => ({ severity: i.severity, message: i.message })),
87
102
  }));
88
103
  return {
@@ -130,6 +130,13 @@ export interface OverviewActivityItem {
130
130
  kindKey: string;
131
131
  /** 原始摘要(上层渲染前 redact())。 */
132
132
  summary: string;
133
+ /**
134
+ * P2(2026-11-14 真机事故):这一行点得动 —— 给它一个去处。
135
+ * 目前只有「待裁决」的自动同步轮次:冲突分区已经落进 sync-state.pendingMerge,
136
+ * 真正的裁决动作在同步页(那里有合并裁决视图),首页只负责把用户送过去。
137
+ * 无此字段 = 纯信息行(保持原样,不伪造交互)。
138
+ */
139
+ jumpTo?: 'sync';
133
140
  }
134
141
  /** 最近活动列表:按时间倒序取前 limit 条(kindKey 归一 + 徽章语义映射)。 */
135
142
  export declare function overviewActivity(history: OverviewHistoryLite[] | null, limit?: number): OverviewActivityItem[];
@@ -210,6 +210,9 @@ export function overviewActivity(history, limit = 5) {
210
210
  : 'warn',
211
211
  kindKey: overviewKindKey(e.kind),
212
212
  summary: e.summary,
213
+ // 待裁决 = 有具体分区等用户确认(宿主侧 pendingMerge)。首页不能只挂个颜色:
214
+ // 有去处才给入口,其余徽章保持不可点。
215
+ ...(e.kind === 'autosync' && e.result === 'pending' ? { jumpTo: 'sync' } : {}),
213
216
  }));
214
217
  }
215
218
  /** 空态判定:备份与快照均已加载且都为空 → 显示「开始保护你的配置」引导。 */
@@ -51,4 +51,13 @@ export declare function renderImportReport(result: ImportResult, t: UiT): string
51
51
  export declare function suggestedActions(_result: ImportResult): ImportResultAction[];
52
52
  /** 回滚报告渲染(full / partial + 人工恢复清单) */
53
53
  export declare function renderRollbackReport(rr: RollbackReport, t: UiT): string;
54
+ /**
55
+ * 字节 → 人类可读体积(B / KB / MB / GiB)。
56
+ *
57
+ * 口径与 `session-inventory-view.ts` 的 `formatSessionBytes` 对齐,但后缀沿用报告既有的
58
+ * KB/MB 写法(报告文本曾被测试与文档引用):
59
+ * - 非有限值(NaN/Infinity)或负数 → 空串:此前 `NaN` 会渲染成「NaN MB」,把缺数据
60
+ * 伪装成 0 体积之外的另一条假信息(审计 P10-2);
61
+ * - ≥1 GiB 单独一档:`2048.0 MB` 让用户自己换算,且 3 位数 MB 在报告行里最容易读错。
62
+ */
54
63
  export declare function formatBytes(n: number): string;
package/lib/ui/report.js CHANGED
@@ -41,9 +41,9 @@ export function renderExportReport(report, t) {
41
41
  const lines = [t('report.backupCreated'), ''];
42
42
  lines.push(t('report.included'));
43
43
  for (const { section, counts } of report.included) {
44
- const detail = Object.entries(counts)
45
- .map(([k, v]) => `${v} ${k}`)
46
- .join(', ');
44
+ // 计数文案与导出确认页同一份组装(`exportCountsText`):此前这里直接拼适配器词汇,
45
+ // 中文界面出现「settings (18 namespaces, 3 files)」这种半英文行(审计 P10-3)。
46
+ const detail = exportCountsText(counts, t);
47
47
  lines.push(` ✓ ${section}${detail !== '' ? ` (${detail})` : ''}`);
48
48
  }
49
49
  lines.push('');
@@ -217,11 +217,24 @@ export function renderRollbackReport(rr, t) {
217
217
  return lines.join('\n');
218
218
  }
219
219
  /* ---------------- 工具 ---------------- */
220
+ /**
221
+ * 字节 → 人类可读体积(B / KB / MB / GiB)。
222
+ *
223
+ * 口径与 `session-inventory-view.ts` 的 `formatSessionBytes` 对齐,但后缀沿用报告既有的
224
+ * KB/MB 写法(报告文本曾被测试与文档引用):
225
+ * - 非有限值(NaN/Infinity)或负数 → 空串:此前 `NaN` 会渲染成「NaN MB」,把缺数据
226
+ * 伪装成 0 体积之外的另一条假信息(审计 P10-2);
227
+ * - ≥1 GiB 单独一档:`2048.0 MB` 让用户自己换算,且 3 位数 MB 在报告行里最容易读错。
228
+ */
220
229
  export function formatBytes(n) {
230
+ if (!Number.isFinite(n) || n < 0)
231
+ return '';
221
232
  if (n < 1024)
222
233
  return `${n} B`;
223
234
  if (n < 1024 * 1024)
224
235
  return `${(n / 1024).toFixed(1)} KB`;
225
- return `${(n / (1024 * 1024)).toFixed(1)} MB`;
236
+ if (n < 1024 * 1024 * 1024)
237
+ return `${(n / (1024 * 1024)).toFixed(1)} MB`;
238
+ return `${(n / (1024 * 1024 * 1024)).toFixed(2)} GiB`;
226
239
  }
227
240
  //# sourceMappingURL=report.js.map
@@ -519,5 +519,13 @@ export declare function applyPluginPendingChecks(sel: Selection, nodes: Selectio
519
519
  selection: Selection;
520
520
  remaining: PluginPendingCheck[];
521
521
  };
522
+ /**
523
+ * 两条待补勾队列是否等价(同序、同 key、同 kind)。
524
+ *
525
+ * 为什么必须有它:`applyPluginPendingChecks` 每轮都返回**新数组**(内容可完全不变)。
526
+ * 调用方若无条件写回 state,effect 依赖 [pendingChecks, …] 就会自激成无界重渲染
527
+ * (清单读不到时队列永不出队 → 页面卡死,审计 P9-1)。
528
+ */
529
+ export declare function samePendingChecks(a: readonly PluginPendingCheck[], b: readonly PluginPendingCheck[]): boolean;
522
530
  /** 勾上该插件前还需要读取哪些分区的清单(展开/点击时触发惰性读取)。 */
523
531
  export declare function pluginEntryUnreadSections(entry: PluginTreeEntry): SectionId[];
@@ -1008,6 +1008,22 @@ export function applyPluginPendingChecks(sel, nodes, tree, pending) {
1008
1008
  }
1009
1009
  return { selection: out, remaining };
1010
1010
  }
1011
+ /**
1012
+ * 两条待补勾队列是否等价(同序、同 key、同 kind)。
1013
+ *
1014
+ * 为什么必须有它:`applyPluginPendingChecks` 每轮都返回**新数组**(内容可完全不变)。
1015
+ * 调用方若无条件写回 state,effect 依赖 [pendingChecks, …] 就会自激成无界重渲染
1016
+ * (清单读不到时队列永不出队 → 页面卡死,审计 P9-1)。
1017
+ */
1018
+ export function samePendingChecks(a, b) {
1019
+ if (a.length !== b.length)
1020
+ return false;
1021
+ for (let i = 0; i < a.length; i += 1) {
1022
+ if (a[i].key !== b[i].key || a[i].kind !== b[i].kind)
1023
+ return false;
1024
+ }
1025
+ return true;
1026
+ }
1011
1027
  /** 勾上该插件前还需要读取哪些分区的清单(展开/点击时触发惰性读取)。 */
1012
1028
  export function pluginEntryUnreadSections(entry) {
1013
1029
  const out = [];