dsh-config-manager 0.8.2 → 0.10.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 (418) hide show
  1. package/lib/adapters/mcp.js +51 -15
  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 +204 -6
  10. package/lib/adapters/prompts.js +15 -4
  11. package/lib/adapters/test-helpers.d.ts +15 -1
  12. package/lib/adapters/test-helpers.js +11 -0
  13. package/lib/cli/actions.d.ts +7 -105
  14. package/lib/cli/actions.js +16 -172
  15. package/lib/cli/control-state.d.ts +54 -0
  16. package/lib/cli/control-state.js +107 -0
  17. package/lib/cli/help.d.ts +1 -1
  18. package/lib/cli/help.js +21 -14
  19. package/lib/cli/index.js +132 -104
  20. package/lib/cli/sessions-repair.js +58 -22
  21. package/lib/cli/web/client-script.d.ts +1 -1
  22. package/lib/cli/web/client-script.js +71 -5
  23. package/lib/cli/web/page.d.ts +9 -19
  24. package/lib/cli/web/page.js +277 -173
  25. package/lib/cli/web/routes.js +85 -25
  26. package/lib/cli/write-gates.d.ts +61 -0
  27. package/lib/cli/write-gates.js +110 -0
  28. package/lib/client.d.ts +196 -75
  29. package/lib/client.js +8139 -7487
  30. package/lib/core/backup.d.ts +0 -4
  31. package/lib/core/backup.js +21 -4
  32. package/lib/core/boot-rescue.d.ts +1 -1
  33. package/lib/core/boot-rescue.js +12 -1
  34. package/lib/core/boot-safety.js +37 -2
  35. package/lib/core/conflict-decisions.js +2 -1
  36. package/lib/core/exporter.js +22 -1
  37. package/lib/core/journal.d.ts +54 -4
  38. package/lib/core/journal.js +158 -35
  39. package/lib/core/local-plugin-host.d.ts +29 -0
  40. package/lib/core/local-plugin-host.js +55 -48
  41. package/lib/core/messages.d.ts +17 -0
  42. package/lib/core/messages.js +34 -0
  43. package/lib/core/migration-history.js +16 -9
  44. package/lib/core/model-tools.d.ts +2 -2
  45. package/lib/core/model-tools.js +20 -2
  46. package/lib/core/patch-chain.d.ts +65 -0
  47. package/lib/core/patch-chain.js +100 -0
  48. package/lib/core/patch-document.d.ts +32 -4
  49. package/lib/core/patch-document.js +48 -17
  50. package/lib/core/patch-secret-guard.d.ts +49 -0
  51. package/lib/core/patch-secret-guard.js +164 -0
  52. package/lib/core/reconcile.d.ts +8 -0
  53. package/lib/core/reconcile.js +18 -3
  54. package/lib/core/reinstall.d.ts +2 -0
  55. package/lib/core/reinstall.js +6 -2
  56. package/lib/core/restore.js +31 -6
  57. package/lib/core/section-sanitize.d.ts +32 -0
  58. package/lib/core/section-sanitize.js +13 -0
  59. package/lib/core/snapshot-diff.d.ts +30 -0
  60. package/lib/core/snapshot-diff.js +56 -20
  61. package/lib/core/startup-barrier.js +8 -2
  62. package/lib/core/types.d.ts +38 -1
  63. package/lib/core/update-check.js +51 -2
  64. package/lib/foreign/kernel.js +9 -2
  65. package/lib/foreign/read-claude-plugins.js +29 -11
  66. package/lib/foreign/read-dsh.js +31 -2
  67. package/lib/foreign/session-ir.js +50 -9
  68. package/lib/foreign/session-read.d.ts +8 -0
  69. package/lib/foreign/session-read.js +26 -0
  70. package/lib/index.d.ts +9 -4
  71. package/lib/index.js +42 -47
  72. package/lib/profiles/dsh-profile-io.d.ts +20 -0
  73. package/lib/profiles/dsh-profile-io.js +27 -0
  74. package/lib/profiles/dsh-profile-manager.d.ts +27 -0
  75. package/lib/profiles/dsh-profile-manager.js +45 -4
  76. package/lib/profiles/dsh-profile-runtime.d.ts +5 -1
  77. package/lib/profiles/dsh-profile-runtime.js +16 -3
  78. package/lib/profiles/process-control.d.ts +18 -1
  79. package/lib/profiles/process-control.js +25 -1
  80. package/lib/routes/profiles.js +2 -1
  81. package/lib/routes/sync.js +19 -1
  82. package/lib/schema/types.d.ts +11 -0
  83. package/lib/security/redaction.js +22 -6
  84. package/lib/sync/autosync-repeat.d.ts +27 -0
  85. package/lib/sync/autosync-repeat.js +23 -0
  86. package/lib/sync/autosync-scheduler.d.ts +47 -2
  87. package/lib/sync/autosync-scheduler.js +217 -53
  88. package/lib/sync/baseline-heal.js +7 -0
  89. package/lib/sync/baseline-record.d.ts +67 -0
  90. package/lib/sync/baseline-record.js +74 -0
  91. package/lib/sync/blob-store.js +13 -0
  92. package/lib/sync/content-diff.d.ts +39 -0
  93. package/lib/sync/content-diff.js +46 -0
  94. package/lib/sync/git/git-transport.d.ts +32 -1
  95. package/lib/sync/git/git-transport.js +146 -26
  96. package/lib/sync/github-auth.d.ts +17 -1
  97. package/lib/sync/github-auth.js +37 -1
  98. package/lib/sync/local-changes.d.ts +15 -0
  99. package/lib/sync/local-changes.js +39 -0
  100. package/lib/sync/merge-apply-plan.d.ts +38 -0
  101. package/lib/sync/merge-apply-plan.js +76 -0
  102. package/lib/sync/merge-keyed.d.ts +68 -0
  103. package/lib/sync/merge-keyed.js +124 -0
  104. package/lib/sync/messages.d.ts +1 -0
  105. package/lib/sync/messages.js +2 -0
  106. package/lib/sync/patch-line-identity.d.ts +19 -0
  107. package/lib/sync/patch-line-identity.js +99 -0
  108. package/lib/sync/pending-merge.d.ts +41 -0
  109. package/lib/sync/pending-merge.js +61 -0
  110. package/lib/sync/plugin-removals.d.ts +15 -15
  111. package/lib/sync/plugin-removals.js +134 -83
  112. package/lib/sync/push-skip.d.ts +55 -0
  113. package/lib/sync/push-skip.js +70 -0
  114. package/lib/sync/s3/s3-transport.d.ts +14 -2
  115. package/lib/sync/s3/s3-transport.js +72 -48
  116. package/lib/sync/sync-engine.d.ts +44 -51
  117. package/lib/sync/sync-engine.js +160 -194
  118. package/lib/sync/sync-history.d.ts +7 -0
  119. package/lib/sync/sync-state.d.ts +28 -0
  120. package/lib/sync/sync-state.js +20 -0
  121. package/lib/sync/transport.d.ts +12 -3
  122. package/lib/sync/transport.js +13 -4
  123. package/lib/sync/webdav/webdav-transport.d.ts +19 -2
  124. package/lib/sync/webdav/webdav-transport.js +81 -40
  125. package/lib/sync/workspace-merge.d.ts +8 -2
  126. package/lib/ui/artifact-view.d.ts +1 -1
  127. package/lib/ui/commands.js +5 -11
  128. package/lib/ui/dsh-profiles-view.d.ts +8 -3
  129. package/lib/ui/dsh-profiles-view.js +9 -5
  130. package/lib/ui/foreign-view.d.ts +14 -0
  131. package/lib/ui/foreign-view.js +34 -0
  132. package/lib/ui/i18n.d.ts +7 -1
  133. package/lib/ui/i18n.js +15 -2
  134. package/lib/ui/menu-placement.js +1 -1
  135. package/lib/ui/migration-consult-view.d.ts +11 -0
  136. package/lib/ui/migration-consult-view.js +15 -0
  137. package/lib/ui/overview-view.d.ts +7 -0
  138. package/lib/ui/overview-view.js +3 -0
  139. package/lib/ui/report.d.ts +9 -0
  140. package/lib/ui/report.js +17 -4
  141. package/lib/ui/selection-model.d.ts +10 -2
  142. package/lib/ui/selection-model.js +23 -3
  143. package/lib/utils/async-once.d.ts +11 -0
  144. package/lib/utils/async-once.js +15 -0
  145. package/lib/utils/patch-chain-read.d.ts +51 -0
  146. package/lib/utils/patch-chain-read.js +240 -0
  147. package/lib/utils/patch-yaml.d.ts +39 -1
  148. package/lib/utils/patch-yaml.js +82 -2
  149. package/lib/utils/paths.d.ts +13 -0
  150. package/lib/utils/paths.js +35 -0
  151. package/lib/utils/workdir-lock.js +18 -3
  152. package/package.json +3 -2
  153. package/src/adapters/mcp.test.ts +29 -0
  154. package/src/adapters/mcp.ts +52 -14
  155. package/src/adapters/messages.ts +2 -0
  156. package/src/adapters/patch-key-guard.ts +29 -0
  157. package/src/adapters/plugin-data.test.ts +126 -0
  158. package/src/adapters/plugin-data.ts +97 -26
  159. package/src/adapters/plugins.test.ts +403 -0
  160. package/src/adapters/plugins.ts +198 -8
  161. package/src/adapters/prompts.ts +15 -4
  162. package/src/adapters/test-helpers.ts +15 -1
  163. package/src/cli/actions.test.ts +74 -1
  164. package/src/cli/actions.ts +27 -246
  165. package/src/cli/control-state.ts +143 -0
  166. package/src/cli/help.ts +21 -14
  167. package/src/cli/index.ts +123 -107
  168. package/src/cli/sessions-repair.ts +55 -22
  169. package/src/cli/web/client-script.ts +71 -5
  170. package/src/cli/web/page.ts +327 -208
  171. package/src/cli/web/routes.ts +85 -25
  172. package/src/cli/web/web.test.ts +65 -0
  173. package/src/cli/write-gates.ts +149 -0
  174. package/src/client/ConfigManagerSection.tsx +8 -4
  175. package/src/client/about/AboutPanel.tsx +9 -12
  176. package/src/client/about/release-notes-view.test.ts +17 -0
  177. package/src/client/about/release-notes-view.ts +49 -24
  178. package/src/client/api.ts +2 -1
  179. package/src/client/chat/ChatEntryView.tsx +2 -2
  180. package/src/client/chat/rollback-entry-view.ts +6 -1
  181. package/src/client/common/CommandPalette.tsx +6 -3
  182. package/src/client/common/ConfirmDialog.tsx +29 -12
  183. package/src/client/common/ContentPicker.tsx +24 -24
  184. package/src/client/common/Modal.tsx +12 -5
  185. package/src/client/common/MoreMenu.tsx +4 -1
  186. package/src/client/common/RunsCenter.tsx +103 -32
  187. package/src/client/common/Select.tsx +2 -2
  188. package/src/client/common/floating-bounds.ts +1 -1
  189. package/src/client/common/floating-units.test.ts +1 -2
  190. package/src/client/common/plan-text-redaction.test.ts +190 -5
  191. package/src/client/common/runs-center-guard.test.ts +60 -0
  192. package/src/client/common/runs-center-view.test.ts +128 -0
  193. package/src/client/common/runs-center-view.ts +96 -0
  194. package/src/client/common/section-title-action.test.ts +66 -0
  195. package/src/client/common/ui.tsx +93 -30
  196. package/src/client/config-manager.module.css +1515 -270
  197. package/src/client/consult/ConsultCard.tsx +7 -6
  198. package/src/client/environment/EnvironmentPanel.tsx +22 -25
  199. package/src/client/environment/maintenance/DiskUsageCard.tsx +69 -96
  200. package/src/client/environment/profiles-incomplete-ui.test.ts +8 -8
  201. package/src/client/export/ExportView.tsx +7 -16
  202. package/src/client/history/HistoryPanel.tsx +88 -28
  203. package/src/client/history/history-locales.ts +3 -3
  204. package/src/client/home/BackupScheduleCard.tsx +77 -69
  205. package/src/client/home/HomePanel.tsx +47 -12
  206. package/src/client/import/ConflictList.tsx +13 -13
  207. package/src/client/import/ForeignImportView.tsx +67 -9
  208. package/src/client/import/ImportWizardView.tsx +4 -4
  209. package/src/client/import/PathMappingForm.tsx +36 -9
  210. package/src/client/import/PathPickerDialog.tsx +2 -1
  211. package/src/client/import/import-wizard-split.test.ts +1 -1
  212. package/src/client/import/import-wizard-steps.tsx +51 -39
  213. package/src/client/import/use-import-wizard-controller.test.ts +129 -0
  214. package/src/client/import/use-import-wizard-controller.ts +116 -22
  215. package/src/client/library/ArtifactRow.tsx +2 -2
  216. package/src/client/library/BackupInspectView.tsx +21 -15
  217. package/src/client/library/LibraryActions.tsx +116 -28
  218. package/src/client/library/LibraryPanel.tsx +14 -15
  219. package/src/client/library/RestorePlanView.tsx +13 -8
  220. package/src/client/locales/about.ts +0 -2
  221. package/src/client/locales/backup.ts +15 -12
  222. package/src/client/locales/common.ts +2 -0
  223. package/src/client/locales/export.ts +5 -12
  224. package/src/client/locales/foreign.ts +4 -2
  225. package/src/client/locales/import.ts +5 -2
  226. package/src/client/locales/overview.ts +4 -0
  227. package/src/client/locales/profiles.ts +32 -4
  228. package/src/client/locales/restore.ts +2 -2
  229. package/src/client/locales/sessions.ts +0 -2
  230. package/src/client/locales/shell.ts +2 -2
  231. package/src/client/market/MarketImportReview.tsx +4 -4
  232. package/src/client/market/MarketPanel.tsx +58 -56
  233. package/src/client/market/MyConfigsList.tsx +34 -32
  234. package/src/client/market/MyConfigsLoginCard.tsx +12 -15
  235. package/src/client/market/MyConfigsView.tsx +8 -15
  236. package/src/client/market/MyConfigsWizard.tsx +7 -12
  237. package/src/client/market/market-locales.ts +0 -6
  238. package/src/client/market/my-configs-split.test.ts +2 -1
  239. package/src/client/nav-menu-clip-guard.test.ts +52 -0
  240. package/src/client/recovery/IncompleteCopiesSection.tsx +1 -3
  241. package/src/client/recovery/RecoveryPanel.tsx +35 -22
  242. package/src/client/recovery/RollbackCard.tsx +132 -75
  243. package/src/client/recovery/RollbackFileChanges.tsx +40 -27
  244. package/src/client/recovery/SessionHealthCard.tsx +2 -2
  245. package/src/client/recovery/SessionHealthDialog.tsx +5 -7
  246. package/src/client/recovery/SessionLayoutSection.tsx +3 -5
  247. package/src/client/recovery/recovery-locales.ts +12 -8
  248. package/src/client/recovery/rollback-enabled.ts +29 -0
  249. package/src/client/recovery/use-recovery-write.ts +5 -0
  250. package/src/client/run-store.test.ts +30 -0
  251. package/src/client/run-store.ts +21 -1
  252. package/src/client/sync/AddChannelCard.tsx +65 -0
  253. package/src/client/sync/AutosyncCard.tsx +184 -108
  254. package/src/client/sync/ChannelClearConfirmDialog.tsx +5 -1
  255. package/src/client/sync/ChannelConfigDialog.tsx +27 -48
  256. package/src/client/sync/MergePreviewView.tsx +5 -7
  257. package/src/client/sync/PushPreviewCard.tsx +2 -1
  258. package/src/client/sync/PushReportSections.tsx +35 -0
  259. package/src/client/sync/SyncChannelEntryCard.tsx +33 -24
  260. package/src/client/sync/SyncConfirmView.tsx +130 -133
  261. package/src/client/sync/SyncLogList.tsx +29 -14
  262. package/src/client/sync/SyncPanel.tsx +188 -185
  263. package/src/client/sync/SyncProbeRow.tsx +5 -7
  264. package/src/client/sync/SyncRepositoryPicker.tsx +17 -4
  265. package/src/client/sync/SyncSecuritySection.tsx +157 -0
  266. package/src/client/sync/SyncSettingsDialog.tsx +293 -0
  267. package/src/client/sync/SyncSettingsView.test.ts +26 -8
  268. package/src/client/sync/WorkDirCard.tsx +2 -4
  269. package/src/client/sync/config-clear-guard.test.ts +94 -0
  270. package/src/client/sync/config-clear-guard.ts +98 -0
  271. package/src/client/sync/config-dirty.test.ts +91 -0
  272. package/src/client/sync/config-dirty.ts +88 -0
  273. package/src/client/sync/history-model.test.ts +2 -0
  274. package/src/client/sync/history-model.ts +5 -0
  275. package/src/client/sync/merge-request.ts +20 -0
  276. package/src/client/sync/sync-api.ts +13 -1
  277. package/src/client/sync/sync-locales.ts +95 -47
  278. package/src/client/sync/sync-panel-clear.test.ts +44 -0
  279. package/src/client/sync/sync-push-preview.test.ts +9 -0
  280. package/src/client/sync/sync-view.test.ts +20 -0
  281. package/src/client/sync/sync-view.ts +76 -4
  282. package/src/core/backup.test.ts +61 -1
  283. package/src/core/backup.ts +21 -4
  284. package/src/core/boot-rescue.test.ts +35 -0
  285. package/src/core/boot-rescue.ts +13 -2
  286. package/src/core/boot-safety.test.ts +25 -0
  287. package/src/core/boot-safety.ts +37 -2
  288. package/src/core/conflict-decisions.ts +2 -1
  289. package/src/core/exporter.ts +21 -1
  290. package/src/core/journal.test.ts +183 -0
  291. package/src/core/journal.ts +163 -25
  292. package/src/core/local-plugin-host.test.ts +68 -2
  293. package/src/core/local-plugin-host.ts +31 -4
  294. package/src/core/messages.ts +34 -0
  295. package/src/core/migration-history.test.ts +27 -0
  296. package/src/core/migration-history.ts +12 -4
  297. package/src/core/model-tools.test.ts +67 -0
  298. package/src/core/model-tools.ts +22 -4
  299. package/src/core/patch-chain.test.ts +83 -0
  300. package/src/core/patch-chain.ts +150 -0
  301. package/src/core/patch-document.test.ts +48 -1
  302. package/src/core/patch-document.ts +66 -15
  303. package/src/core/patch-layers.test.ts +1 -1
  304. package/src/core/patch-secret-guard.test.ts +110 -0
  305. package/src/core/patch-secret-guard.ts +176 -0
  306. package/src/core/reconcile.ts +32 -4
  307. package/src/core/reinstall.ts +8 -2
  308. package/src/core/restore.ts +32 -7
  309. package/src/core/section-sanitize.ts +37 -0
  310. package/src/core/smoke.test.ts +2 -1
  311. package/src/core/snapshot-diff.test.ts +73 -1
  312. package/src/core/snapshot-diff.ts +66 -21
  313. package/src/core/startup-barrier.test.ts +64 -0
  314. package/src/core/startup-barrier.ts +8 -2
  315. package/src/core/types.ts +43 -2
  316. package/src/core/update-check.test.ts +40 -0
  317. package/src/core/update-check.ts +53 -2
  318. package/src/foreign/claude-code.test.ts +5 -0
  319. package/src/foreign/claude-plugins.test.ts +57 -0
  320. package/src/foreign/claude-sessions-bytes.test.ts +7 -1
  321. package/src/foreign/dsh.test.ts +23 -0
  322. package/src/foreign/kernel.ts +9 -2
  323. package/src/foreign/read-claude-plugins.ts +32 -11
  324. package/src/foreign/read-dsh.ts +33 -2
  325. package/src/foreign/session-ir.test.ts +67 -0
  326. package/src/foreign/session-ir.ts +54 -14
  327. package/src/foreign/session-read.ts +23 -0
  328. package/src/index.facade.test.ts +186 -6
  329. package/src/index.ts +53 -47
  330. package/src/profiles/dsh-profile-copy-rollback.test.ts +58 -4
  331. package/src/profiles/dsh-profile-io.ts +29 -0
  332. package/src/profiles/dsh-profile-manager.test.ts +30 -0
  333. package/src/profiles/dsh-profile-manager.ts +53 -5
  334. package/src/profiles/dsh-profile-runtime.test.ts +29 -7
  335. package/src/profiles/dsh-profile-runtime.ts +17 -3
  336. package/src/profiles/process-control.test.ts +97 -0
  337. package/src/profiles/process-control.ts +28 -1
  338. package/src/routes/profiles.ts +2 -1
  339. package/src/routes/sync.ts +19 -1
  340. package/src/schema/types.ts +16 -1
  341. package/src/security/redaction.test.ts +31 -0
  342. package/src/security/redaction.ts +23 -6
  343. package/src/security/security.test.ts +1 -1
  344. package/src/sync/autosync-repeat.test.ts +58 -0
  345. package/src/sync/autosync-repeat.ts +55 -0
  346. package/src/sync/autosync-scheduler.test.ts +515 -0
  347. package/src/sync/autosync-scheduler.ts +225 -51
  348. package/src/sync/baseline-heal.ts +6 -0
  349. package/src/sync/baseline-record.ts +135 -0
  350. package/src/sync/blob-store.test.ts +16 -0
  351. package/src/sync/blob-store.ts +13 -0
  352. package/src/sync/content-diff.test.ts +95 -0
  353. package/src/sync/content-diff.ts +79 -0
  354. package/src/sync/git/git-transport.test.ts +151 -4
  355. package/src/sync/git/git-transport.ts +143 -27
  356. package/src/sync/github-auth.test.ts +26 -1
  357. package/src/sync/github-auth.ts +37 -1
  358. package/src/sync/local-changes.ts +40 -0
  359. package/src/sync/merge-apply-plan.ts +117 -0
  360. package/src/sync/merge-keyed.test.ts +167 -0
  361. package/src/sync/merge-keyed.ts +160 -0
  362. package/src/sync/messages.ts +3 -0
  363. package/src/sync/patch-line-identity.test.ts +73 -0
  364. package/src/sync/patch-line-identity.ts +105 -0
  365. package/src/sync/pending-merge.test.ts +41 -0
  366. package/src/sync/pending-merge.ts +85 -0
  367. package/src/sync/plugin-removals.test.ts +199 -39
  368. package/src/sync/plugin-removals.ts +150 -64
  369. package/src/sync/push-skip.test.ts +326 -0
  370. package/src/sync/push-skip.ts +102 -0
  371. package/src/sync/s3/s3-delete-and-blob-index.test.ts +249 -0
  372. package/src/sync/s3/s3-transport.ts +76 -42
  373. package/src/sync/sync-config.test.ts +39 -12
  374. package/src/sync/sync-device-identity.test.ts +3 -0
  375. package/src/sync/sync-engine.test.ts +465 -12
  376. package/src/sync/sync-engine.ts +189 -193
  377. package/src/sync/sync-history.ts +7 -0
  378. package/src/sync/sync-state.ts +48 -0
  379. package/src/sync/transport.test.ts +13 -1
  380. package/src/sync/transport.ts +12 -4
  381. package/src/sync/webdav/webdav-delete-and-blob-index.test.ts +249 -0
  382. package/src/sync/webdav/webdav-transport.ts +86 -34
  383. package/src/sync/workspace-merge.ts +9 -2
  384. package/src/ui/artifact-view.ts +1 -1
  385. package/src/ui/commands.test.ts +11 -0
  386. package/src/ui/commands.ts +5 -14
  387. package/src/ui/dsh-profiles-view.test.ts +16 -0
  388. package/src/ui/dsh-profiles-view.ts +11 -5
  389. package/src/ui/foreign-view.test.ts +49 -0
  390. package/src/ui/foreign-view.ts +47 -0
  391. package/src/ui/i18n.ts +15 -2
  392. package/src/ui/menu-placement.ts +1 -1
  393. package/src/ui/migration-consult-view.test.ts +20 -1
  394. package/src/ui/migration-consult-view.ts +17 -0
  395. package/src/ui/overview-view.ts +10 -0
  396. package/src/ui/report.test.ts +25 -1
  397. package/src/ui/report.ts +15 -4
  398. package/src/ui/selection-model.test.ts +29 -1
  399. package/src/ui/selection-model.ts +25 -4
  400. package/src/utils/async-once.ts +14 -0
  401. package/src/utils/js-yaml4.d.ts +35 -0
  402. package/src/utils/patch-chain-read.test.ts +171 -0
  403. package/src/utils/patch-chain-read.ts +259 -0
  404. package/src/utils/patch-yaml.test.ts +215 -3
  405. package/src/utils/patch-yaml.ts +98 -2
  406. package/src/utils/paths.test.ts +14 -1
  407. package/src/utils/paths.ts +35 -0
  408. package/src/utils/workdir-lock.test.ts +69 -0
  409. package/src/utils/workdir-lock.ts +17 -3
  410. package/lib/ui/path-mapping.d.ts +0 -38
  411. package/lib/ui/path-mapping.js +0 -75
  412. package/src/client/common/InfoHint.tsx +0 -289
  413. package/src/client/common/info-hint-guard.test.ts +0 -1119
  414. package/src/client/sync/DecryptPasswordCard.tsx +0 -48
  415. package/src/client/sync/SecurityOptionsCard.tsx +0 -97
  416. package/src/client/sync/SyncSectionPickerDialog.tsx +0 -213
  417. package/src/ui/path-mapping.test.ts +0 -67
  418. package/src/ui/path-mapping.ts +0 -103
@@ -12,63 +12,70 @@ import path from 'node:path';
12
12
  import { createHash } from 'node:crypto';
13
13
  import { spawn } from 'node:child_process';
14
14
  import { packLocalPlugins, parsePackOutput, resolveLocalPluginPath } from './local-plugin-pack.js';
15
- import { quoteCmdArg } from './plugin-cli.js';
15
+ import { killTree, quoteCmdArg } from './plugin-cli.js';
16
16
  import { engineMsg } from './messages-core.js';
17
17
  /** `npm pack` 单次调用的超时上限(慢网络/大插件留足余量,但不得无限挂起) */
18
18
  const PACK_TIMEOUT_MS = 5 * 60 * 1000;
19
19
  /** cmd.exe 垫片路径(Windows 上 npm 是 .cmd;与 core/plugin-cli.ts 的 spawnShim 同源做法) */
20
20
  const COMSPEC = process.env.ComSpec ?? 'cmd.exe';
21
21
  /**
22
- * 默认 exec:把 `npm pack` 作为子进程执行并收集 stdout/stderr。
22
+ * 造一个真实 `npm pack` 执行器;默认导出实例给生产用,测试可注入 spawn / killTree。
23
23
  *
24
- * **刻意不用 `execFile(..., { shell: true })`**:该组合会触发 Node 的 DEP0190
25
- * (`shell:true` + args 数组只做拼接不做转义,存在注入面)。仓库既有解法是
26
- * 在 Windows 上显式走 `cmd.exe /d /s /c "<转义后的命令行>"`(见 core/plugin-cli.ts
27
- * 的 spawnShim + quoteCmdArg),本模块复用同一做法。
28
- *
29
- * 失败**不 reject**(把退出码交回调用方判定),只有 spawn 本身失败才 reject——
30
- * 这样「npm 报错」与「npm 不存在」能被分开处理(前者是插件问题,后者是环境问题)。
24
+ * 超时为什么要整棵树:调用方只 `child.kill()` 时,Windows 死掉的只是 cmd.exe 包装进程,
25
+ * npm/pnpm 孙进程成孤儿继续写 tarball,而 `finally` 已经 rm 掉 packDir(审计 P2-3:
26
+ * 孤儿随后在已删除目录里写、或写出一份没人收的产物)。killTree 与 plugin-cli 的
27
+ * `dsh plugin` 子进程用同一实现(Windows taskkill /T /F;POSIX 负 pid 杀进程组 ——
28
+ * 因此 POSIX 上必须 `detached: true` 让子进程自成进程组,否则 -pid 会打到自己的组)。
31
29
  */
32
- const defaultExec = (file, args, opts) => new Promise((resolve, reject) => {
33
- const useShim = process.platform === 'win32';
34
- const [bin, argv] = useShim
35
- ? [COMSPEC, ['/d', '/s', '/c', `"${[file, ...args].map(quoteCmdArg).join(' ')}"`]]
36
- : [file, [...args]];
37
- const child = spawn(bin, argv, {
38
- cwd: opts.cwd,
39
- windowsHide: true,
40
- windowsVerbatimArguments: useShim,
41
- shell: false, // 显式关闭:Windows 路径已由 cmd.exe 自行处理
42
- });
43
- let stdout = '';
44
- let stderr = '';
45
- let settled = false;
46
- const timeoutMs = opts.timeoutMs ?? PACK_TIMEOUT_MS;
47
- const timer = setTimeout(() => {
48
- if (settled)
49
- return;
50
- settled = true;
51
- child.kill();
52
- resolve({ stdout, stderr: engineMsg('core.localPluginHost.packTimeout', { stderr, timeoutMs }), code: 1 });
53
- }, timeoutMs);
54
- timer.unref?.();
55
- child.stdout?.on('data', (d) => { stdout += String(d); });
56
- child.stderr?.on('data', (d) => { stderr += String(d); });
57
- child.on('error', (err) => {
58
- if (settled)
59
- return;
60
- settled = true;
61
- clearTimeout(timer);
62
- reject(err); // spawn 层失败(ENOENT 等):环境问题,如实上抛
63
- });
64
- child.on('close', (code) => {
65
- if (settled)
66
- return;
67
- settled = true;
68
- clearTimeout(timer);
69
- resolve({ stdout, stderr, code });
30
+ export function createPackExec(deps = {}) {
31
+ const spawnImpl = deps.spawn ?? spawn;
32
+ const killTreeImpl = deps.killTree ?? killTree;
33
+ return (file, args, opts) => new Promise((resolve, reject) => {
34
+ const useShim = process.platform === 'win32';
35
+ const [bin, argv] = useShim
36
+ ? [COMSPEC, ['/d', '/s', '/c', `"${[file, ...args].map(quoteCmdArg).join(' ')}"`]]
37
+ : [file, [...args]];
38
+ const child = spawnImpl(bin, argv, {
39
+ cwd: opts.cwd,
40
+ windowsHide: true,
41
+ windowsVerbatimArguments: useShim,
42
+ shell: false, // 显式关闭:Windows 路径已由 cmd.exe 自行处理
43
+ // POSIX:自成进程组,超时才能用负 pid 杀掉整棵树(Windows 忽略该选项,taskkill /T 自己找树)
44
+ detached: process.platform !== 'win32',
45
+ });
46
+ let stdout = '';
47
+ let stderr = '';
48
+ let settled = false;
49
+ const timeoutMs = opts.timeoutMs ?? PACK_TIMEOUT_MS;
50
+ const timer = setTimeout(() => {
51
+ if (settled)
52
+ return;
53
+ settled = true;
54
+ // 整棵树:只 kill() 包装进程会让 npm/pnpm 孙进程成孤儿(见上)
55
+ killTreeImpl(child);
56
+ resolve({ stdout, stderr: engineMsg('core.localPluginHost.packTimeout', { stderr, timeoutMs }), code: 1 });
57
+ }, timeoutMs);
58
+ timer.unref?.();
59
+ child.stdout?.on('data', (d) => { stdout += String(d); });
60
+ child.stderr?.on('data', (d) => { stderr += String(d); });
61
+ child.on('error', (err) => {
62
+ if (settled)
63
+ return;
64
+ settled = true;
65
+ clearTimeout(timer);
66
+ reject(err); // spawn 层失败(ENOENT 等):环境问题,如实上抛
67
+ });
68
+ child.on('close', (code) => {
69
+ if (settled)
70
+ return;
71
+ settled = true;
72
+ clearTimeout(timer);
73
+ resolve({ stdout, stderr, code });
74
+ });
70
75
  });
71
- });
76
+ }
77
+ /** 生产用的默认执行器(真实 spawn + 真实整树终止) */
78
+ const defaultExec = createPackExec();
72
79
  /**
73
80
  * 构造注入给 `PluginsAdapter` 的打包钩子。
74
81
  *
@@ -21,6 +21,7 @@ export declare const zh: {
21
21
  readonly 'export.sectionFailed': '分区 {adapter} 导出失败: {reason}';
22
22
  readonly 'export.credentialsReadFailed': '读取凭据文件失败,跳过秘密导出: {reason}';
23
23
  readonly 'export.vaultRefreshed': '凭据明文未进入备份,已镜像到本机 vault({count} 个文件,恢复时可回填)';
24
+ readonly 'export.pluginDataSensitiveSkipped': '打包时剔除 {count} 个凭据文件(首个:{sample})——第三方插件数据分区永不携带凭据明文';
24
25
  readonly 'export.vaultRefreshSkipped': 'vault 镜像跳过 {rel}: {reason}';
25
26
  readonly 'export.vaultRefreshFailed': 'vault 镜像刷新失败(不影响导出): {reason}';
26
27
  readonly 'export.sessionsLimited': '会话按数量筛选:只带最新 {count} 个(共 {total} 个;单位 = 会话目录,同一会话的日志一起走)';
@@ -196,6 +197,7 @@ export declare const zh: {
196
197
  readonly 'host.patchUnreadable': 'patch 层 {file} 读不出来({reason}):该层的 patch 行不会被导出/同步,也不会被改写';
197
198
  readonly 'host.patchRefuseClobber': 'patch 层 {file} 解析失败({reason}):已拒绝覆盖写入,否则会把这层里读不出来的行整体删掉';
198
199
  readonly 'host.patchRefusePromote': 'patch 层 {file} 的写入会把 {ids} 从 insert(新增)改成顶层行(覆盖):已拒绝写入,文件未改动(顶层行按 id 覆盖,查不到就整条丢弃)';
200
+ readonly 'host.patchRefuseUnknownId': 'patch 层 {file} 的写入含顶层行 {ids},但生效 patch 链(bundle 层 / profile 层 / home 层)没有任何一层提供这些 id:宿主会按 not found 整行丢弃,已拒绝写入,文件未改动';
199
201
  readonly 'host.patchSemanticDrift': 'patch 层 {file} 写回后结构自检不通过({detail}):已拒绝写入,文件未改动';
200
202
  readonly 'host.fsPathEscape': '路径越界: {path}';
201
203
  readonly 'host.activationRowFailed': '插件 {pkg} 已安装,但激活行写入 profile 补丁失败:{reason}(重启后该插件可能未激活;修复后重试安装即可幂等补行)';
@@ -287,8 +289,17 @@ export declare const zh: {
287
289
  readonly 'adapter.pluginInstallFailed': '插件 {name} 安装失败:{msg}。可手动安装:dsh plugin --profile {profile} add {name}(其余配置已导入;可修复依赖后在设置页重试或手动安装)';
288
290
  readonly 'adapter.pluginUpdateFailed': '插件 {name} 更新失败:{msg}。可手动安装:dsh plugin --profile {profile} add {name}(其余配置已导入;可修复依赖后在设置页重试或手动安装)';
289
291
  readonly 'adapter.patchLineCreate': '写入 patch 行 {lineId}';
292
+ readonly 'adapter.patchLineOverride': '覆盖已存在条目(写入 patch 行 {lineId})';
293
+ readonly 'adapter.patchLineOverrideDetail': '该 id 已由 {layers} 提供:只能写顶层覆盖行;写成 insert 会产生第二条同 id 条目(DSH 里保存该插件配置时会报 overridden)';
294
+ readonly 'adapter.patchLineDowngraded': '{ids} 已由其它 patch 层提供,本次改写为覆盖行(不再新增第二条同 id 条目)';
295
+ readonly 'adapter.patchChainPartial': '生效 patch 链有 {count} 层读不出来({files}):本次「这个 id 是否已存在」的判定只覆盖读到的那几层';
296
+ readonly 'adapter.patchLineDuplicateInsert': 'patch 行 {lineId} 在本机已有多条「新增」(insert)来源:同 id 两条新增会让 DSH 保存该插件配置时一直报 overridden';
297
+ readonly 'adapter.patchLineDuplicateInsertDetail': '另一条 insert 来自 {layers};需手工删除其中一条(本插件不会自动删行)';
298
+ readonly 'adapter.patchNotesJoin': ';';
290
299
  readonly 'adapter.patchLineSame': 'patch 行 {lineId} 已一致';
291
300
  readonly 'adapter.patchLineDiff': 'patch 行 {lineId} 与目标不同';
301
+ readonly 'adapter.patchKeyParseFail': 'patch 行 {ref} 在 {path} 处含会让 DSH 整份文件解析失败的键名:先给该键改成合法名字,再导入';
302
+ readonly 'adapter.patchKeyAmbiguous': 'patch 行 {ref} 在 {path} 处的键名 {key} 会被 DSH 读成数字 / 布尔 / null:给键名加引号(\'{key}\':)后重新导入';
292
303
  readonly 'adapter.promptSame': '提示词 {name} 已一致';
293
304
  readonly 'adapter.promptDiff': '提示词 {name} 与目标不同';
294
305
  readonly 'adapter.promptDiffWithLine': '提示词 {name} 与目标不同(目标位于行 {line})';
@@ -324,6 +335,9 @@ export declare const zh: {
324
335
  readonly 'adapter.pwPatchesUnsupported': 'patchedDependencies 为单行 flow 写法,无法安全剔除缺失条目;若目标机没有对应 patch 文件,pnpm 可能拒绝安装:{line}';
325
336
  readonly 'adapter.pwWrittenPatchesDropped': 'pnpm-workspace.yaml 已写入,但移除了 {count} 条 patchedDependencies 声明(目标机没有对应 patch 文件):{names}';
326
337
  readonly 'adapter.patchWritten': 'patch 行 {ref} 已写入,重启后生效';
338
+ readonly 'adapter.patchSecretsKept': '{ref} 已写入,但保留本机原有内容:{paths}(备份里这些字段被脱敏清空,未用空值覆盖本机;如需清空请对该行显式确认“使用备份配置”)';
339
+ readonly 'adapter.patchSecretsCleared': '{ref} 已按备份写入,字段 {paths} 现为空(已显式确认该行使用备份配置)';
340
+ readonly 'adapter.patchLocalReadFailed': 'patch 行 {ref} 未写入:读不出本机现值({reason});无法确认这次写入不会覆盖本机原有内容,已跳过这一行';
327
341
  readonly 'adapter.credentialValueMissing': '凭据值未提供(需补录)';
328
342
  readonly 'adapter.promptWarningNoWrite': '提示项,无需写入';
329
343
  readonly 'adapter.promptMissing': '导入数据缺少提示词 {id}';
@@ -376,6 +390,8 @@ export declare const zh: {
376
390
  readonly 'sync.credentialsNeedPassword': '快照 {id} 含加密凭据载荷,需要解密密码才能读取';
377
391
  readonly 'sync.encryptedNeedsPassword': '快照 {id} 已加密,需要解密密码才能读取(自动同步无法解密,请手动同步)';
378
392
  readonly 'sync.noPortableSections': '没有可同步的 portable 分区(全部导出失败)';
393
+ readonly 'sync.pushSkipConflicted': '已跳过本轮推送:{sections} 仍待冲突裁决(未上传、未改动基线)';
394
+ readonly 'sync.pushAllConflicted': '没有可推送的分区:{sections} 全部仍待冲突裁决(先裁决,或改用强制推送)';
379
395
  readonly 'sync.remoteEmpty': '远端无快照';
380
396
  readonly 'sync.sessionDeletionsRecorded': '已记录 {count} 个本机删除的历史对话(墓碑随快照传播,旧快照不会把它们带回来)';
381
397
  readonly 'sync.sessionsTombstoned': '已按远端墓碑跳过 {count} 个已删除的历史对话(不复活)';
@@ -446,6 +462,7 @@ export declare const zh: {
446
462
  readonly 'sync.pruneListFailed': '远端快照裁剪失败:无法列出远端快照,{reason}';
447
463
  readonly 'sync.pruneDeleteFailed': '远端快照裁剪失败:删除快照 {id} 失败,{reason}';
448
464
  readonly 'sync.gcSkipped': '本轮已放弃回收远端孤立文件({code}):本轮不做回收,快照本身不受影响';
465
+ readonly 'sync.latestSkippedEncrypted': '加密快照不生成远端 latest/ 视图(密文无明文镜像):latest/ 保持上一次明文快照的内容,需要明文视图请推一次非加密快照';
449
466
  readonly 'market.invalidItemId': '非法市场条目 id: {id}(仅允许字母数字开头,字符限 . _ -)';
450
467
  readonly 'market.urlWhitespace': '市场仓库地址不能包含空白字符';
451
468
  readonly 'market.urlUnparseable': '无法解析市场仓库地址: {url}';
@@ -5,6 +5,7 @@ export const zh = {
5
5
  'export.sectionFailed': '分区 {adapter} 导出失败: {reason}',
6
6
  'export.credentialsReadFailed': '读取凭据文件失败,跳过秘密导出: {reason}',
7
7
  'export.vaultRefreshed': '凭据明文未进入备份,已镜像到本机 vault({count} 个文件,恢复时可回填)',
8
+ 'export.pluginDataSensitiveSkipped': '打包时剔除 {count} 个凭据文件(首个:{sample})——第三方插件数据分区永不携带凭据明文',
8
9
  'export.vaultRefreshSkipped': 'vault 镜像跳过 {rel}: {reason}',
9
10
  'export.vaultRefreshFailed': 'vault 镜像刷新失败(不影响导出): {reason}',
10
11
  'export.sessionsLimited': '会话按数量筛选:只带最新 {count} 个(共 {total} 个;单位 = 会话目录,同一会话的日志一起走)',
@@ -185,6 +186,7 @@ export const zh = {
185
186
  'host.patchUnreadable': 'patch 层 {file} 读不出来({reason}):该层的 patch 行不会被导出/同步,也不会被改写',
186
187
  'host.patchRefuseClobber': 'patch 层 {file} 解析失败({reason}):已拒绝覆盖写入,否则会把这层里读不出来的行整体删掉',
187
188
  'host.patchRefusePromote': 'patch 层 {file} 的写入会把 {ids} 从 insert(新增)改成顶层行(覆盖):已拒绝写入,文件未改动(顶层行按 id 覆盖,查不到就整条丢弃)',
189
+ 'host.patchRefuseUnknownId': 'patch 层 {file} 的写入含顶层行 {ids},但生效 patch 链(bundle 层 / profile 层 / home 层)没有任何一层提供这些 id:宿主会按 not found 整行丢弃,已拒绝写入,文件未改动',
188
190
  'host.patchSemanticDrift': 'patch 层 {file} 写回后结构自检不通过({detail}):已拒绝写入,文件未改动',
189
191
  'host.fsPathEscape': '路径越界: {path}',
190
192
  'host.activationRowFailed': '插件 {pkg} 已安装,但激活行写入 profile 补丁失败:{reason}(重启后该插件可能未激活;修复后重试安装即可幂等补行)',
@@ -278,8 +280,17 @@ export const zh = {
278
280
  'adapter.pluginInstallFailed': '插件 {name} 安装失败:{msg}。可手动安装:dsh plugin --profile {profile} add {name}(其余配置已导入;可修复依赖后在设置页重试或手动安装)',
279
281
  'adapter.pluginUpdateFailed': '插件 {name} 更新失败:{msg}。可手动安装:dsh plugin --profile {profile} add {name}(其余配置已导入;可修复依赖后在设置页重试或手动安装)',
280
282
  'adapter.patchLineCreate': '写入 patch 行 {lineId}',
283
+ 'adapter.patchLineOverride': '覆盖已存在条目(写入 patch 行 {lineId})',
284
+ 'adapter.patchLineOverrideDetail': '该 id 已由 {layers} 提供:只能写顶层覆盖行;写成 insert 会产生第二条同 id 条目(DSH 里保存该插件配置时会报 overridden)',
285
+ 'adapter.patchLineDowngraded': '{ids} 已由其它 patch 层提供,本次改写为覆盖行(不再新增第二条同 id 条目)',
286
+ 'adapter.patchChainPartial': '生效 patch 链有 {count} 层读不出来({files}):本次「这个 id 是否已存在」的判定只覆盖读到的那几层',
287
+ 'adapter.patchLineDuplicateInsert': 'patch 行 {lineId} 在本机已有多条「新增」(insert)来源:同 id 两条新增会让 DSH 保存该插件配置时一直报 overridden',
288
+ 'adapter.patchLineDuplicateInsertDetail': '另一条 insert 来自 {layers};需手工删除其中一条(本插件不会自动删行)',
289
+ 'adapter.patchNotesJoin': ';',
281
290
  'adapter.patchLineSame': 'patch 行 {lineId} 已一致',
282
291
  'adapter.patchLineDiff': 'patch 行 {lineId} 与目标不同',
292
+ 'adapter.patchKeyParseFail': 'patch 行 {ref} 在 {path} 处含会让 DSH 整份文件解析失败的键名:先给该键改成合法名字,再导入',
293
+ 'adapter.patchKeyAmbiguous': 'patch 行 {ref} 在 {path} 处的键名 {key} 会被 DSH 读成数字 / 布尔 / null:给键名加引号(\'{key}\':)后重新导入',
283
294
  'adapter.promptSame': '提示词 {name} 已一致',
284
295
  'adapter.promptDiff': '提示词 {name} 与目标不同',
285
296
  'adapter.promptDiffWithLine': '提示词 {name} 与目标不同(目标位于行 {line})',
@@ -316,6 +327,9 @@ export const zh = {
316
327
  'adapter.pwPatchesUnsupported': 'patchedDependencies 为单行 flow 写法,无法安全剔除缺失条目;若目标机没有对应 patch 文件,pnpm 可能拒绝安装:{line}',
317
328
  'adapter.pwWrittenPatchesDropped': 'pnpm-workspace.yaml 已写入,但移除了 {count} 条 patchedDependencies 声明(目标机没有对应 patch 文件):{names}',
318
329
  'adapter.patchWritten': 'patch 行 {ref} 已写入,重启后生效',
330
+ 'adapter.patchSecretsKept': '{ref} 已写入,但保留本机原有内容:{paths}(备份里这些字段被脱敏清空,未用空值覆盖本机;如需清空请对该行显式确认“使用备份配置”)',
331
+ 'adapter.patchSecretsCleared': '{ref} 已按备份写入,字段 {paths} 现为空(已显式确认该行使用备份配置)',
332
+ 'adapter.patchLocalReadFailed': 'patch 行 {ref} 未写入:读不出本机现值({reason});无法确认这次写入不会覆盖本机原有内容,已跳过这一行',
319
333
  'adapter.credentialValueMissing': '凭据值未提供(需补录)',
320
334
  'adapter.promptWarningNoWrite': '提示项,无需写入',
321
335
  'adapter.promptMissing': '导入数据缺少提示词 {id}',
@@ -370,6 +384,8 @@ export const zh = {
370
384
  'sync.credentialsNeedPassword': '快照 {id} 含加密凭据载荷,需要解密密码才能读取',
371
385
  'sync.encryptedNeedsPassword': '快照 {id} 已加密,需要解密密码才能读取(自动同步无法解密,请手动同步)',
372
386
  'sync.noPortableSections': '没有可同步的 portable 分区(全部导出失败)',
387
+ 'sync.pushSkipConflicted': '已跳过本轮推送:{sections} 仍待冲突裁决(未上传、未改动基线)',
388
+ 'sync.pushAllConflicted': '没有可推送的分区:{sections} 全部仍待冲突裁决(先裁决,或改用强制推送)',
373
389
  'sync.remoteEmpty': '远端无快照',
374
390
  'sync.sessionDeletionsRecorded': '已记录 {count} 个本机删除的历史对话(墓碑随快照传播,旧快照不会把它们带回来)',
375
391
  'sync.sessionsTombstoned': '已按远端墓碑跳过 {count} 个已删除的历史对话(不复活)',
@@ -450,6 +466,7 @@ export const zh = {
450
466
  'sync.pruneListFailed': '远端快照裁剪失败:无法列出远端快照,{reason}',
451
467
  'sync.pruneDeleteFailed': '远端快照裁剪失败:删除快照 {id} 失败,{reason}',
452
468
  'sync.gcSkipped': '本轮已放弃回收远端孤立文件({code}):本轮不做回收,快照本身不受影响',
469
+ 'sync.latestSkippedEncrypted': '加密快照不生成远端 latest/ 视图(密文无明文镜像):latest/ 保持上一次明文快照的内容,需要明文视图请推一次非加密快照',
453
470
  // ---------- 配置市场(m-market:只读公开仓库目录读取 + 校验) ----------
454
471
  'market.invalidItemId': '非法市场条目 id: {id}(仅允许字母数字开头,字符限 . _ -)',
455
472
  'market.urlWhitespace': '市场仓库地址不能包含空白字符',
@@ -520,6 +537,7 @@ export const en = {
520
537
  'export.sectionFailed': 'Section {adapter} export failed: {reason}',
521
538
  'export.credentialsReadFailed': 'Failed to read the credentials file; secrets export skipped: {reason}',
522
539
  'export.vaultRefreshed': 'Credential plaintext did not enter the backup; mirrored to the local vault ({count} file(s), available for restore backfill)',
540
+ 'export.pluginDataSensitiveSkipped': 'Dropped {count} credential file(s) at packaging time (first: {sample}) — third-party plugin data never carries credential plaintext',
523
541
  'export.vaultRefreshSkipped': 'Vault mirror skipped {rel}: {reason}',
524
542
  'export.vaultRefreshFailed': 'Vault mirror refresh failed (export unaffected): {reason}',
525
543
  'export.sessionsLimited': 'Sessions filtered by count: only the latest {count} are included ({total} total; the unit is a session directory, so all logs of one session travel together)',
@@ -700,6 +718,7 @@ export const en = {
700
718
  'host.patchUnreadable': 'Cannot read patch layer {file} ({reason}): its patch rows are not exported or synced, and the file is left untouched',
701
719
  'host.patchRefuseClobber': 'Refusing to rewrite patch layer {file}: it cannot be parsed ({reason}), and rewriting would delete every row that could not be read',
702
720
  'host.patchRefusePromote': 'Refusing to write patch layer {file}: it would turn {ids} from insert (add) into top-level rows (override); the file is untouched (top-level rows override by id and are dropped entirely when not found)',
721
+ 'host.patchRefuseUnknownId': 'Refusing to write patch layer {file}: it contains top-level rows {ids} that no layer of the effective patch chain (bundle / profile / home) provides; the host would drop them as not found, so the file is untouched',
703
722
  'host.patchSemanticDrift': 'Structure self-check failed after serializing patch layer {file} ({detail}): the write was refused and the file is untouched',
704
723
  'host.fsPathEscape': 'Path outside home directory: {path}',
705
724
  'host.activationRowFailed': 'Plugin {pkg} is installed, but writing the activation row into the profile patch failed: {reason} (the plugin may be inactive until restart; retrying the install after fixing is idempotent)',
@@ -793,8 +812,17 @@ export const en = {
793
812
  'adapter.pluginInstallFailed': 'Plugin {name} install failed: {msg}. You can install it manually: dsh plugin --profile {profile} add {name} (the rest of the config was imported; fix dependencies and retry from the settings page, or install by hand)',
794
813
  'adapter.pluginUpdateFailed': 'Plugin {name} update failed: {msg}. You can install it manually: dsh plugin --profile {profile} add {name} (the rest of the config was imported; fix dependencies and retry from the settings page, or install by hand)',
795
814
  'adapter.patchLineCreate': 'Write patch row {lineId}',
815
+ 'adapter.patchLineOverride': 'Override the existing entry (write patch row {lineId})',
816
+ 'adapter.patchLineOverrideDetail': 'This id is already provided by {layers}: only a top-level override row is valid; an insert would add a second entry with the same id (saving that plugin config in DSH then reports it as overridden)',
817
+ 'adapter.patchLineDowngraded': '{ids} already provided by another patch layer; written as an override row instead of a second insert',
818
+ 'adapter.patchChainPartial': '{count} layer(s) of the effective patch chain could not be read ({files}); the "does this id already exist" check covers only the readable layers',
819
+ 'adapter.patchLineDuplicateInsert': 'Patch line {lineId} has more than one insert source on this machine: two inserts for the same id make DSH report that plugin config as overridden on every save',
820
+ 'adapter.patchLineDuplicateInsertDetail': 'Another insert comes from {layers}; delete one of them by hand (this plugin never deletes rows on its own)',
821
+ 'adapter.patchNotesJoin': '; ',
796
822
  'adapter.patchLineSame': 'Patch row {lineId} is already identical',
797
823
  'adapter.patchLineDiff': 'Patch row {lineId} differs from the target',
824
+ 'adapter.patchKeyParseFail': 'Patch row {ref} has a key at {path} that makes DSH fail to parse the whole file; rename that key before importing',
825
+ 'adapter.patchKeyAmbiguous': 'Key {key} in patch row {ref} (at {path}) is read as a number / boolean / null by DSH; quote it (\'{key}\':) and import again',
798
826
  'adapter.promptSame': 'Prompt {name} is already identical',
799
827
  'adapter.promptDiff': 'Prompt {name} differs from the target',
800
828
  'adapter.promptDiffWithLine': 'Prompt {name} differs from the target (target lives at row {line})',
@@ -831,6 +859,9 @@ export const en = {
831
859
  'adapter.pwPatchesUnsupported': 'patchedDependencies uses single-line flow syntax, so missing entries cannot be removed safely; if the target lacks the patch files pnpm may refuse installs: {line}',
832
860
  'adapter.pwWrittenPatchesDropped': 'pnpm-workspace.yaml written, but {count} patchedDependencies entries were removed (the target has no matching patch file): {names}',
833
861
  'adapter.patchWritten': 'Patch row {ref} written; takes effect after restart',
862
+ 'adapter.patchSecretsKept': '{ref} written, but local values were kept for: {paths} (these fields were redacted to empty in the backup, so the empty values did not overwrite local content; confirm “use backup config” on this row explicitly if you want them cleared)',
863
+ 'adapter.patchSecretsCleared': '{ref} written from the backup; fields {paths} are now empty (you explicitly confirmed using the backup config for this row)',
864
+ 'adapter.patchLocalReadFailed': 'Patch row {ref} not written: the local value could not be read ({reason}), so the write cannot be proven safe and this row was skipped',
834
865
  'adapter.credentialValueMissing': 'Credential value not provided (re-entry required)',
835
866
  'adapter.promptWarningNoWrite': 'Informational item; nothing to write',
836
867
  'adapter.promptMissing': 'Import data is missing prompt {id}',
@@ -885,6 +916,8 @@ export const en = {
885
916
  'sync.credentialsNeedPassword': 'Snapshot {id} carries an encrypted credentials payload; a decryption password is required',
886
917
  'sync.encryptedNeedsPassword': 'Snapshot {id} is encrypted; a decryption password is required (auto sync cannot decrypt — sync manually)',
887
918
  'sync.noPortableSections': 'No portable sections to sync (all exports failed)',
919
+ 'sync.pushSkipConflicted': 'Push skipped: {sections} still await conflict resolution (nothing uploaded, baseline untouched)',
920
+ 'sync.pushAllConflicted': 'Nothing to push: every target section ({sections}) still awaits conflict resolution (resolve them first, or force push)',
888
921
  'sync.remoteEmpty': 'No snapshots on the remote',
889
922
  'sync.sessionDeletionsRecorded': 'Recorded {count} locally deleted conversation(s) as tombstones (they travel with snapshots, so older snapshots will not bring them back)',
890
923
  'sync.sessionsTombstoned': 'Skipped {count} conversation(s) deleted on the remote side according to tombstones (no resurrection)',
@@ -961,6 +994,7 @@ export const en = {
961
994
  'sync.pruneListFailed': 'Remote snapshot pruning failed: could not list remote snapshots, {reason}',
962
995
  'sync.pruneDeleteFailed': 'Remote snapshot pruning failed: deleting snapshot {id} failed, {reason}',
963
996
  'sync.gcSkipped': 'Skipped reclaiming remote orphan files this round ({code}); snapshots are unaffected',
997
+ 'sync.latestSkippedEncrypted': 'Encrypted snapshots do not produce the remote latest/ view (ciphertext has no plaintext mirror): latest/ keeps the previous plaintext snapshot content; push a non-encrypted snapshot if you need it refreshed',
964
998
  // ---------- config marketplace (m-market: read-only public repo directory read + validation) ----------
965
999
  'market.invalidItemId': 'Invalid marketplace item id: {id} (must start with an alphanumeric; only . _ - allowed)',
966
1000
  'market.urlWhitespace': 'Marketplace repository URL must not contain whitespace',
@@ -137,12 +137,19 @@ export function autosyncUnifiedHistoryInput(entry, msg = engineMsg) {
137
137
  }
138
138
  const defaultIo = {
139
139
  async mkdir(d, o) { await fs.mkdir(d, o); },
140
- async readdirNames(d) { try {
141
- return await fs.readdir(d);
142
- }
143
- catch {
144
- return [];
145
- } },
140
+ // 只有「目录不存在」才算空:权限/路径类型错误必须抛给调用方(审计 P3-6)。
141
+ // 旧实现 catch 一切 → 读不出的目录被当作空目录,历史面板显示「共 0 条」、
142
+ // 自动清理也算 0 条直接跳过,用户完全看不出是读取失败。
143
+ async readdirNames(d) {
144
+ try {
145
+ return await fs.readdir(d);
146
+ }
147
+ catch (err) {
148
+ if (err.code === 'ENOENT')
149
+ return [];
150
+ throw err;
151
+ }
152
+ },
146
153
  async readFileText(p) { return (await fs.readFile(p, 'utf8')).toString(); },
147
154
  async writeAll(t, c) { await atomicWriteFile(t, c, { mode: 0o600, symlink: 'reject' }); },
148
155
  async rm(p, o) { await fs.rm(p, o); },
@@ -360,7 +367,7 @@ export class MigrationStore {
360
367
  * 调用方据此区分「共 N 条,本页只含最近 M 条」。
361
368
  */
362
369
  async read(opts = {}) {
363
- const names = await this.io.readdirNames(this.dir).catch(() => []);
370
+ const names = await this.io.readdirNames(this.dir);
364
371
  const entries = [];
365
372
  const corrupted = [];
366
373
  const sorted = names.filter(isHistoryBasename).sort();
@@ -391,7 +398,7 @@ export class MigrationStore {
391
398
  }
392
399
  /** 目录内合法历史文件总数(只 readdir,不读文件内容;供「自动清理」行展示)。 */
393
400
  async count() {
394
- const names = await this.io.readdirNames(this.dir).catch(() => []);
401
+ const names = await this.io.readdirNames(this.dir);
395
402
  return names.filter(isHistoryBasename).length;
396
403
  }
397
404
  /**
@@ -399,7 +406,7 @@ export class MigrationStore {
399
406
  * 返回本次删除的文件名。
400
407
  */
401
408
  async retention(limit = DEFAULT_MIGRATION_RETENTION) {
402
- const names = (await this.io.readdirNames(this.dir).catch(() => [])).filter(isHistoryBasename).sort();
409
+ const names = (await this.io.readdirNames(this.dir)).filter(isHistoryBasename).sort();
403
410
  const removed = [];
404
411
  // 0(或负数)= 不限制:调用方显式关闭自动清理时按「保留全部」处理,绝不当作「删光」。
405
412
  if (!Number.isFinite(limit) || limit <= 0)
@@ -20,8 +20,8 @@ export interface ModelToolsDeps {
20
20
  syncDir: string;
21
21
  /**
22
22
  * SyncEngine 工厂(git/webdav 按配置分支构造传输;与 host 路由同一来源)。
23
- * D5:agent 侧按工具决定 optInSections(仅合并类工具带用户放行的可选分区),
24
- * 推送/拉取仍走缺省(= 只 portable),与改动前的工具行为逐字节一致。
23
+ * D5:agent 侧按工具决定 optInSections —— 推送 / 拉取 / 预览 / 合并一律带用户放行的 'auto' 档,
24
+ * 再剔除 sessions(与 docs/architecture/agent-tools.md 的工具面口径同一份事实)。
25
25
  */
26
26
  makeSyncEngine: (cfg: SyncConfig, opts?: {
27
27
  optInSections?: readonly SectionId[];
@@ -85,10 +85,17 @@ async function resolveSyncTarget(deps, channel) {
85
85
  }
86
86
  return { cfg, channel: ch };
87
87
  }
88
- /** 解析同步引擎(推送 / 拉取:缺省只同步 portable 分区,与改动前行为逐字节一致)。 */
88
+ /**
89
+ * 解析同步引擎(推送 / 拉取)。
90
+ * D5:与 preview/apply 同一口径 —— 引擎构造期必须拿到用户放行的 'auto' 档可选分区,
91
+ * 否则显式传 mcp 会在 pushTargets 里被判成非 portable 并 skipNonPortable(issue #138 ④)。
92
+ */
89
93
  async function resolveEngine(deps, channel) {
90
94
  const target = await resolveSyncTarget(deps, channel);
91
- return { engine: deps.makeSyncEngine(target.cfg), channel: target.channel };
95
+ return {
96
+ engine: deps.makeSyncEngine(target.cfg, { optInSections: agentOptInSections(deps, target.channel) }),
97
+ channel: target.channel,
98
+ };
92
99
  }
93
100
  /* ------------------------------------------------------------ 结构化结论与摘要 */
94
101
  /** agent 侧永久排除的同步分区(sessions = 会话内容:路径/cwd/对话,绝不因一次工具调用被上下行)。 */
@@ -424,6 +431,9 @@ export function createModelTools(deps) {
424
431
  ...(sections === undefined ? {} : { sections }),
425
432
  ...(encrypt ? { encrypt: true, includeSecrets: false, password: password ?? '' } : {}),
426
433
  ...(input.force === true ? { force: true } : {}),
434
+ // 空数组 = 连磁盘待裁决一起扣(issue #146):agent 的手动推送与 GUI 同口径,
435
+ // 否则「跑一次 push 工具」就能把用户挂着未裁决的分区整块覆盖掉。
436
+ skipSections: [],
427
437
  });
428
438
  const report = await runWithMutationLock(deps.host.mutationLock, { op: 'model-sync-push', isBlocked: () => deps.host.safeModeIsBlocked?.() ?? false }, async (lockCtx) => {
429
439
  if (deps.host.phase3Recovery !== undefined && lockCtx !== null) {
@@ -446,6 +456,14 @@ export function createModelTools(deps) {
446
456
  // 否则模型会把它当成「推送成功但内容为空」继续往下走。
447
457
  ...(report.conflict === true ? { conflict: true } : {}),
448
458
  ...(report.adoptedBase === undefined ? {} : { adoptedBase: report.adoptedBase }),
459
+ // issue #140:内容与远端最新一致 ⇒ 引擎什么都没写(不 upload、不建目录)。
460
+ // 不透传的话模型会把「ok:true + snapshotId」读成「又推了一份新快照」。
461
+ ...(report.skipped === 'unchanged'
462
+ ? { skipped: 'unchanged', adoptedSnapshotId: report.adoptedSnapshotId ?? report.snapshotId }
463
+ // issue #146:目标分区全被未裁决冲突扣下 ⇒ 一个分区都没推,绝不读成「推成功」
464
+ : report.skipped === 'all-conflicted'
465
+ ? { skipped: 'all-conflicted' }
466
+ : {}),
449
467
  ...(report.message === undefined ? {} : { message: report.message }),
450
468
  ...(encrypt ? { passwordSource: stored === undefined ? 'argument' : 'stored' } : {}),
451
469
  };
@@ -0,0 +1,65 @@
1
+ /** 生效链上的一层:层身份 + 已解析的文档。 */
2
+ export interface PatchChainSource {
3
+ /**
4
+ * 层身份。前两种与 `patch-layers.ts` 同口径(相对 homeDir 的 POSIX 路径);bundle 层用
5
+ * `bundles:<包名>/<patch 文件>` —— 它不是本机可写的层,只用于判重与取 name。
6
+ */
7
+ file: string;
8
+ doc: unknown;
9
+ }
10
+ /** 读不出来的层(fail-open:判定只做加强,但缺口必须能上报,不能静默变成「确知没有」)。 */
11
+ export interface PatchChainFailure {
12
+ file: string;
13
+ reason: string;
14
+ }
15
+ /** 门面读到的整条链(宿主合并序)与读失败的层。 */
16
+ export interface PatchChainRead {
17
+ /** 宿主合并序:bundle 层在前,然后 profile 层、home 层 */
18
+ sources: PatchChainSource[];
19
+ /** 读不出来 / 解析不了的层 */
20
+ failures: PatchChainFailure[];
21
+ }
22
+ /** 链上某个 id 的合流结果。 */
23
+ export interface PatchChainEntry {
24
+ id: string;
25
+ /** 条目声明的 name(写顶层覆盖行时必须与之一致,否则宿主整行跳过;`alignOverrideNames` 用它校正) */
26
+ name?: string;
27
+ /** 提供该 id 的层(按合并序去重) */
28
+ layers: string[];
29
+ /** 其中**以 `- insert:` 成员形式**提供该 id 的层(>=2 就是「两条新增抢同一 id」的坏状态) */
30
+ insertLayers: string[];
31
+ }
32
+ /** 写回结果(`applyPatchChanges` 的返回值):被降级的 insert id。 */
33
+ export interface PatchWriteOutcome {
34
+ /**
35
+ * 本次被**降级为顶层覆盖行**的 id:调用方要求 insert,但链上已有其他层提供该 id
36
+ * (issue #144 的存量修复;正常路径在计划阶段就已判定,这里只是最后一道兜底)。
37
+ */
38
+ downgraded: string[];
39
+ }
40
+ /** 把整条链折成 id → 层/形态索引(顺序 = 宿主合并序,先出现者优先记 name)。 */
41
+ export declare function patchChainIndex(read: PatchChainRead): Map<string, PatchChainEntry>;
42
+ /** 链上「**本文件之外**的层」提供的 id(写这一层时的判据)。 */
43
+ export declare function providedByOtherLayers(index: Map<string, PatchChainEntry>, file: string): Map<string, PatchChainEntry>;
44
+ /**
45
+ * 把待写的**顶层行**里的 `name` 校正成链上既有条目的 name(issue #144 的验收标准之一)。
46
+ *
47
+ * 为什么必须校正:宿主对覆盖行做 `name === target.name` 校验,不一致就
48
+ * `patch: name mismatch … skipping` 把整行丢掉 —— 快照来自另一台机器(裸名)而目标机由
49
+ * bundle 提供(scoped 名)时,导入会报「成功」但一个字节都没生效,原报错照旧。
50
+ * `insert` 块成员不动(那是新增,name 由来源决定)。
51
+ */
52
+ export declare function alignOverrideNames(items: readonly unknown[], index: Map<string, PatchChainEntry>): unknown[];
53
+ /** 读整条链的结果:索引 + 读不出来的层(后者供报告面提示「判据不完整」)。 */
54
+ export interface PatchChainIndexRead {
55
+ /** 门面没实现该能力(老宿主 / 测试替身)→ `null`(判定退化为两层) */
56
+ index: Map<string, PatchChainEntry> | null;
57
+ failures: PatchChainFailure[];
58
+ }
59
+ /**
60
+ * 读整条链并折成索引。门面没实现 `readPatchChain`、或读链本身抛错 → `index: null`
61
+ * (判定退化为两层 patch 文件,绝不因为链读失败阻断写入)。
62
+ */
63
+ export declare function readPatchChainIndex(patchFile: {
64
+ readPatchChain?: () => Promise<PatchChainRead>;
65
+ }): Promise<PatchChainIndexRead>;
@@ -0,0 +1,100 @@
1
+ /**
2
+ * 生效 patch 链(issue #144)。
3
+ *
4
+ * DSH 启动时把**多层** patch 合并到同一份 plugin 树上(dsh-app-boot 的 readProfilePatches):
5
+ * bundle 层(各 bundle 的 `dsh.bundle.patch`,按 `dsh.profile.bundles` 顺序)
6
+ * → profile 层(`profiles/<profile>/cordis.patch.yml`)
7
+ * → home 层(`cordis.patch.yml`)→ overlays。
8
+ *
9
+ * 同一个 id 只能有**一份**「新增」来源:两处 `- insert:` 成员会把同一条目插两次,宿主
10
+ * composeEntries 之后拿到的 config 变成数组 / 取到没有 config 的那份,于是插件自己的
11
+ * ConfigEditor 落盘时报
12
+ * `Configuration for "X" is overridden by a home patch or command-line overlay` —— 报错把原因
13
+ * 说反了(真正的原因是「我们插了第二份」,issue #144)。
14
+ *
15
+ * 于是「这个 id 存在吗」必须按**整条链**判定,而不是只看两个 patch 文件(issue #144 之前的
16
+ * 判据只覆盖 home/profile 两层,见 `patchLayerRels`):
17
+ * - 链上已存在 ⇒ 只能写**顶层覆盖行**(`- id: X`,带 config;写 name 时必须与既有条目一致,
18
+ * 否则宿主 `patch: name mismatch … skipping` 整行跳过);
19
+ * - 链上不存在 ⇒ 只能写 `- insert:` 成员(顶层行会被 `patch: entry not found` 丢弃)。
20
+ *
21
+ * 本模块只做**纯计算**(core 层零依赖、不碰 YAML / IO):各层文档由宿主门面读好交进来。
22
+ * 三个消费点共用同一份索引 —— 导入判定(计划项 Create / Update)、写前降级(insert → 覆盖行)、
23
+ * 覆盖行孤儿守卫(整链没人提供该 id ⇒ 拒写)。
24
+ */
25
+ import { patchDocumentEntries } from './patch-document.js';
26
+ /** 把整条链折成 id → 层/形态索引(顺序 = 宿主合并序,先出现者优先记 name)。 */
27
+ export function patchChainIndex(read) {
28
+ const index = new Map();
29
+ for (const source of read.sources) {
30
+ for (const entry of patchDocumentEntries(source.doc)) {
31
+ const known = index.get(entry.id);
32
+ if (known === undefined) {
33
+ const fresh = { id: entry.id, layers: [source.file], insertLayers: [] };
34
+ if (entry.name !== undefined)
35
+ fresh.name = entry.name;
36
+ if (entry.inInsert)
37
+ fresh.insertLayers.push(source.file);
38
+ index.set(entry.id, fresh);
39
+ continue;
40
+ }
41
+ if (!known.layers.includes(source.file))
42
+ known.layers.push(source.file);
43
+ if (entry.inInsert && !known.insertLayers.includes(source.file))
44
+ known.insertLayers.push(source.file);
45
+ // name 取**第一个**声明它的层:宿主按既有条目的 name 校验覆盖行,低优先级层的同名条目最终也会被覆盖
46
+ if (known.name === undefined && entry.name !== undefined)
47
+ known.name = entry.name;
48
+ }
49
+ }
50
+ return index;
51
+ }
52
+ /** 链上「**本文件之外**的层」提供的 id(写这一层时的判据)。 */
53
+ export function providedByOtherLayers(index, file) {
54
+ const out = new Map();
55
+ for (const [id, entry] of index) {
56
+ if (entry.layers.some((layer) => layer !== file))
57
+ out.set(id, entry);
58
+ }
59
+ return out;
60
+ }
61
+ /**
62
+ * 把待写的**顶层行**里的 `name` 校正成链上既有条目的 name(issue #144 的验收标准之一)。
63
+ *
64
+ * 为什么必须校正:宿主对覆盖行做 `name === target.name` 校验,不一致就
65
+ * `patch: name mismatch … skipping` 把整行丢掉 —— 快照来自另一台机器(裸名)而目标机由
66
+ * bundle 提供(scoped 名)时,导入会报「成功」但一个字节都没生效,原报错照旧。
67
+ * `insert` 块成员不动(那是新增,name 由来源决定)。
68
+ */
69
+ export function alignOverrideNames(items, index) {
70
+ return items.map((item) => {
71
+ if (item === null || typeof item !== 'object' || Array.isArray(item))
72
+ return item;
73
+ const obj = item;
74
+ if ('insert' in obj)
75
+ return item;
76
+ const id = obj['id'];
77
+ if (typeof id !== 'string' || id === '')
78
+ return item;
79
+ const wanted = index.get(id)?.name;
80
+ if (wanted === undefined || obj['name'] === wanted)
81
+ return item;
82
+ return { ...obj, name: wanted };
83
+ });
84
+ }
85
+ /**
86
+ * 读整条链并折成索引。门面没实现 `readPatchChain`、或读链本身抛错 → `index: null`
87
+ * (判定退化为两层 patch 文件,绝不因为链读失败阻断写入)。
88
+ */
89
+ export async function readPatchChainIndex(patchFile) {
90
+ if (patchFile.readPatchChain === undefined)
91
+ return { index: null, failures: [] };
92
+ try {
93
+ const read = await patchFile.readPatchChain();
94
+ return { index: patchChainIndex(read), failures: read.failures };
95
+ }
96
+ catch (err) {
97
+ return { index: null, failures: [{ file: 'patch-chain', reason: err instanceof Error ? err.message : String(err) }] };
98
+ }
99
+ }
100
+ //# sourceMappingURL=patch-chain.js.map