dsh-config-manager 0.4.3 → 0.5.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 (254) hide show
  1. package/README.md +10 -0
  2. package/README.zh-CN.md +10 -0
  3. package/lib/adapters/mcp.d.ts +9 -0
  4. package/lib/adapters/mcp.js +37 -0
  5. package/lib/adapters/plugins.js +10 -2
  6. package/lib/adapters/pnpm-workspace.js +1 -1
  7. package/lib/adapters/self.d.ts +2 -0
  8. package/lib/adapters/self.js +18 -2
  9. package/lib/adapters/workspaces.js +1 -1
  10. package/lib/cli/restore-resume.js +1 -1
  11. package/lib/cli/web/page.js +2 -2
  12. package/lib/client.d.ts +14 -41
  13. package/lib/client.js +794 -716
  14. package/lib/core/backup.d.ts +11 -0
  15. package/lib/core/backup.js +27 -0
  16. package/lib/core/env-lock-lifecycle.d.ts +17 -3
  17. package/lib/core/env-lock-lifecycle.js +38 -0
  18. package/lib/core/external-failure.d.ts +9 -0
  19. package/lib/core/external-failure.js +50 -0
  20. package/lib/core/local-plugin-host.d.ts +9 -7
  21. package/lib/core/local-plugin-host.js +109 -15
  22. package/lib/core/local-plugin-pack.d.ts +20 -0
  23. package/lib/core/local-plugin-pack.js +18 -3
  24. package/lib/core/mcp-connector-store.d.ts +13 -0
  25. package/lib/core/mcp-connector-store.js +16 -1
  26. package/lib/core/messages-core.d.ts +45 -0
  27. package/lib/core/messages-core.js +92 -0
  28. package/lib/core/messages.d.ts +1 -0
  29. package/lib/core/messages.js +6 -0
  30. package/lib/core/model-tool-plans.d.ts +66 -0
  31. package/lib/core/model-tool-plans.js +128 -0
  32. package/lib/core/model-tools.d.ts +96 -8
  33. package/lib/core/model-tools.js +568 -31
  34. package/lib/core/phase3-host.js +10 -2
  35. package/lib/core/plugin-data-registry.d.ts +1 -1
  36. package/lib/core/plugin-data-registry.js +1 -1
  37. package/lib/core/restore-plan-fingerprint.d.ts +2 -0
  38. package/lib/core/restore-plan-fingerprint.js +18 -0
  39. package/lib/core/restore-resume.d.ts +1 -1
  40. package/lib/core/restore-resume.js +1 -1
  41. package/lib/core/restore.d.ts +5 -0
  42. package/lib/core/restore.js +4 -1
  43. package/lib/core/types.d.ts +12 -0
  44. package/lib/foreign/claude-sessions.d.ts +1 -1
  45. package/lib/foreign/claude-sessions.js +1 -1
  46. package/lib/foreign/registry.js +1 -1
  47. package/lib/foreign/types.d.ts +1 -1
  48. package/lib/index.d.ts +15 -15
  49. package/lib/index.js +60 -67
  50. package/lib/market/git-file-writer.js +1 -1
  51. package/lib/market/github-repos.js +1 -1
  52. package/lib/market/market-config.js +1 -1
  53. package/lib/market/messages-market.js +1 -1
  54. package/lib/market/my-repo.js +1 -1
  55. package/lib/market/prepare.js +1 -1
  56. package/lib/market/reader.js +2 -2
  57. package/lib/market/repo-url.d.ts +1 -1
  58. package/lib/market/security.js +2 -2
  59. package/lib/market/star-cache.d.ts +1 -1
  60. package/lib/market/types.d.ts +1 -1
  61. package/lib/market/types.js +1 -1
  62. package/lib/market/url.js +1 -1
  63. package/lib/routes/backup.js +17 -9
  64. package/lib/routes/index.d.ts +1 -1
  65. package/lib/routes/kit.d.ts +2 -2
  66. package/lib/routes/market.d.ts +1 -1
  67. package/lib/routes/market.js +3 -60
  68. package/lib/routes/model-tools-deps.d.ts +41 -0
  69. package/lib/routes/model-tools-deps.js +18 -0
  70. package/lib/routes/recovery.js +5 -3
  71. package/lib/routes/route-support.d.ts +18 -26
  72. package/lib/routes/route-support.js +19 -32
  73. package/lib/routes/snapshots.d.ts +1 -1
  74. package/lib/routes/snapshots.js +4 -40
  75. package/lib/routes/sync.js +40 -28
  76. package/lib/schema/index.d.ts +2 -2
  77. package/lib/schema/index.js +2 -2
  78. package/lib/schema/section-registry.d.ts +5 -3
  79. package/lib/schema/section-registry.js +7 -3
  80. package/lib/security/secret-scanner.js +1 -1
  81. package/lib/sync/apply-bundle.d.ts +50 -0
  82. package/lib/sync/apply-bundle.js +60 -0
  83. package/lib/sync/autosync-scheduler.d.ts +9 -0
  84. package/lib/sync/autosync-scheduler.js +118 -89
  85. package/lib/sync/backup-scheduler.js +5 -4
  86. package/lib/sync/blob-store.d.ts +2 -2
  87. package/lib/sync/git/git-transport.d.ts +12 -0
  88. package/lib/sync/git/git-transport.js +50 -2
  89. package/lib/sync/merge.d.ts +2 -0
  90. package/lib/sync/merge.js +28 -0
  91. package/lib/sync/messages.d.ts +4 -0
  92. package/lib/sync/messages.js +9 -2
  93. package/lib/sync/s3/s3-transport.d.ts +1 -1
  94. package/lib/sync/s3/s3-transport.js +1 -1
  95. package/lib/sync/sync-engine.d.ts +4 -4
  96. package/lib/sync/sync-engine.js +25 -26
  97. package/lib/sync/sync-scope-boot.d.ts +34 -0
  98. package/lib/sync/sync-scope-boot.js +71 -0
  99. package/lib/sync/sync-scope.d.ts +103 -0
  100. package/lib/sync/sync-scope.js +229 -0
  101. package/lib/sync/sync-selection.d.ts +17 -4
  102. package/lib/sync/sync-selection.js +40 -14
  103. package/lib/sync/transport.d.ts +4 -1
  104. package/lib/sync/transport.js +6 -0
  105. package/lib/sync/webdav/webdav-transport.js +1 -1
  106. package/lib/sync/workspace-merge.d.ts +36 -0
  107. package/lib/sync/workspace-merge.js +152 -0
  108. package/lib/ui/backup-schedule.d.ts +13 -2
  109. package/lib/ui/backup-schedule.js +3 -0
  110. package/lib/ui/snapshots-view.d.ts +16 -0
  111. package/lib/ui/snapshots-view.js +21 -0
  112. package/lib/utils/env-lock.d.ts +96 -0
  113. package/lib/utils/env-lock.js +332 -111
  114. package/lib/utils/messages-utils.d.ts +6 -0
  115. package/lib/utils/messages-utils.js +17 -1
  116. package/lib/utils/patch-yaml.js +1 -1
  117. package/lib/utils/zip.js +1 -1
  118. package/package.json +3 -2
  119. package/src/adapters/mcp.test.ts +28 -0
  120. package/src/adapters/mcp.ts +33 -0
  121. package/src/adapters/plugins.test.ts +49 -0
  122. package/src/adapters/plugins.ts +9 -1
  123. package/src/adapters/pnpm-workspace.ts +1 -1
  124. package/src/adapters/self.test.ts +39 -1
  125. package/src/adapters/self.ts +20 -2
  126. package/src/adapters/workspaces.ts +1 -1
  127. package/src/cli/restore-resume.ts +1 -1
  128. package/src/cli/web/page.ts +2 -2
  129. package/src/client/about/AboutPanel.tsx +1 -1
  130. package/src/client/about/about-view.test.ts +1 -1
  131. package/src/client/about/about-view.ts +1 -1
  132. package/src/client/api.ts +1 -6
  133. package/src/client/chat/chat-entry-view.test.ts +1 -1
  134. package/src/client/chat/chat-slots.ts +1 -1
  135. package/src/client/chat/rollback-diff-tab.ts +1 -1
  136. package/src/client/client-types.ts +1 -1
  137. package/src/client/common/routes.ts +1 -5
  138. package/src/client/css-scale-guard.test.ts +1 -1
  139. package/src/client/home/HomePanel.tsx +3 -0
  140. package/src/client/library/ArtifactRow.tsx +14 -2
  141. package/src/client/library/LibraryPanel.tsx +44 -0
  142. package/src/client/locales/overview.ts +10 -2
  143. package/src/client/locales/sessions.ts +3 -0
  144. package/src/client/market/MyConfigsView.tsx +1 -1
  145. package/src/client/market/market-api.ts +2 -14
  146. package/src/client/market/market-locales.ts +1 -1
  147. package/src/client/market/market-view.ts +3 -3
  148. package/src/client/market/my-configs-api.ts +1 -1
  149. package/src/client/market/my-configs-view.ts +1 -1
  150. package/src/client/recovery/recovery-locales.test.ts +1 -1
  151. package/src/client/run-store.ts +1 -1
  152. package/src/client/sync/SyncSectionPickerDialog.tsx +0 -5
  153. package/src/client/sync/history-model.test.ts +28 -7
  154. package/src/client/sync/history-model.ts +6 -3
  155. package/src/client/sync/sync-locales.ts +10 -4
  156. package/src/client/sync/sync-view.ts +1 -1
  157. package/src/core/analyzer-cache.test.ts +1 -1
  158. package/src/core/backup.test.ts +45 -1
  159. package/src/core/backup.ts +25 -0
  160. package/src/core/disk-usage.test.ts +2 -0
  161. package/src/core/env-lock-lifecycle.ts +33 -3
  162. package/src/core/external-failure.test.ts +60 -0
  163. package/src/core/external-failure.ts +54 -0
  164. package/src/core/integrity-extra-entries.test.ts +1 -1
  165. package/src/core/local-plugin-host.test.ts +134 -0
  166. package/src/core/local-plugin-host.ts +122 -17
  167. package/src/core/local-plugin-pack.ts +39 -3
  168. package/src/core/mcp-connector-store.ts +26 -1
  169. package/src/core/messages-core.ts +94 -0
  170. package/src/core/messages.ts +6 -0
  171. package/src/core/model-tool-plans.test.ts +111 -0
  172. package/src/core/model-tool-plans.ts +170 -0
  173. package/src/core/model-tools.test.ts +212 -12
  174. package/src/core/model-tools.ts +710 -38
  175. package/src/core/phase3-host.ts +10 -2
  176. package/src/core/phase3-production-integration.test.ts +43 -0
  177. package/src/core/plugin-data-registry.ts +1 -1
  178. package/src/core/restore-plan-fingerprint.ts +19 -0
  179. package/src/core/restore-resume.ts +1 -1
  180. package/src/core/restore.ts +9 -1
  181. package/src/core/types.ts +12 -0
  182. package/src/foreign/claude-sessions.ts +3 -3
  183. package/src/foreign/registry.ts +1 -1
  184. package/src/foreign/types.ts +1 -1
  185. package/src/index.ts +91 -98
  186. package/src/market/git-file-writer.ts +1 -1
  187. package/src/market/github-repos.test.ts +1 -1
  188. package/src/market/github-repos.ts +1 -1
  189. package/src/market/market-config.ts +1 -1
  190. package/src/market/messages-market.ts +1 -1
  191. package/src/market/my-repo.test.ts +1 -1
  192. package/src/market/my-repo.ts +1 -1
  193. package/src/market/prepare.test.ts +1 -1
  194. package/src/market/prepare.ts +1 -1
  195. package/src/market/reader.ts +2 -2
  196. package/src/market/repo-url.ts +1 -1
  197. package/src/market/security.ts +2 -2
  198. package/src/market/star-cache.ts +1 -1
  199. package/src/market/types.ts +1 -1
  200. package/src/market/url.test.ts +1 -1
  201. package/src/market/url.ts +1 -1
  202. package/src/profiles/dsh-profile-copy-rollback.test.ts +1 -1
  203. package/src/routes/backup.ts +16 -9
  204. package/src/routes/index.ts +1 -1
  205. package/src/routes/kit.ts +2 -2
  206. package/src/routes/market.ts +2 -59
  207. package/src/routes/model-tools-deps.ts +56 -0
  208. package/src/routes/recovery.ts +5 -3
  209. package/src/routes/route-support.ts +49 -36
  210. package/src/routes/snapshots.ts +4 -40
  211. package/src/routes/sync.ts +39 -27
  212. package/src/schema/index.ts +2 -2
  213. package/src/schema/manifest-schema.test.ts +2 -2
  214. package/src/schema/registry.test.ts +1 -1
  215. package/src/schema/section-registry.ts +9 -4
  216. package/src/security/redaction.test.ts +1 -1
  217. package/src/security/secret-scanner.test.ts +2 -2
  218. package/src/security/secret-scanner.ts +1 -1
  219. package/src/sync/apply-bundle.ts +104 -0
  220. package/src/sync/autosync-scheduler.test.ts +180 -6
  221. package/src/sync/autosync-scheduler.ts +132 -92
  222. package/src/sync/backup-scheduler.test.ts +11 -4
  223. package/src/sync/backup-scheduler.ts +5 -4
  224. package/src/sync/blob-store.ts +2 -2
  225. package/src/sync/git/git-transport.test.ts +62 -0
  226. package/src/sync/git/git-transport.ts +54 -3
  227. package/src/sync/merge.ts +29 -0
  228. package/src/sync/messages.ts +9 -2
  229. package/src/sync/s3/s3-transport.ts +1 -1
  230. package/src/sync/sync-engine.test.ts +238 -2
  231. package/src/sync/sync-engine.ts +25 -26
  232. package/src/sync/sync-preview-push.test.ts +2 -1
  233. package/src/sync/sync-scope-boot.ts +87 -0
  234. package/src/sync/sync-scope.test.ts +154 -0
  235. package/src/sync/sync-scope.ts +256 -0
  236. package/src/sync/sync-selection.test.ts +76 -2
  237. package/src/sync/sync-selection.ts +40 -13
  238. package/src/sync/transport.test.ts +21 -1
  239. package/src/sync/transport.ts +12 -0
  240. package/src/sync/webdav/webdav-delete-index-unreadable.test.ts +2 -2
  241. package/src/sync/webdav/webdav-transport.ts +1 -1
  242. package/src/sync/workspace-merge.test.ts +110 -0
  243. package/src/sync/workspace-merge.ts +180 -0
  244. package/src/ui/backup-schedule.test.ts +5 -0
  245. package/src/ui/backup-schedule.ts +21 -2
  246. package/src/ui/session-issue-labels.ts +1 -1
  247. package/src/ui/snapshots-view.test.ts +32 -0
  248. package/src/ui/snapshots-view.ts +34 -0
  249. package/src/utils/env-lock.test.ts +242 -9
  250. package/src/utils/env-lock.ts +247 -13
  251. package/src/utils/messages-utils.ts +17 -1
  252. package/src/utils/patch-yaml.ts +1 -1
  253. package/src/utils/zip.ts +1 -1
  254. package/src/client/CLIENT_DEPENDENCIES.md +0 -94
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * src/utils/** 的领域消息目录(zh 源语言 / en 镜像)——「英文界面零中文」迁移(t5)。
3
3
  *
4
- * 口径(与 src/core/messages.ts 一致,见 docs/design/2026-10-08-i18n-en-hardcoding.md):
4
+ * 口径(与 src/core/messages.ts 一致,见 docs/archive/2026-10-08-i18n-en-hardcoding.md):
5
5
  * - zh 值 = 迁移前的既有中文文案**逐字不变**(既有测试断言依赖它,只允许新增 en);
6
6
  * - en 值类型为 Record<keyof typeof zh, string> —— 缺键/多键即编译错误;
7
7
  * - 动态明细一律走 {param} 插值传参,不得丢信息;
@@ -68,6 +68,7 @@ export const zh = {
68
68
  'utils.envLock.heartbeatExpiredNoIdentity': 'heartbeat 过期且 pid={pid} 存活,但无法可靠取得 OS process identity,保守拒绝删除',
69
69
  'utils.envLock.pidReuse': 'pid reuse:pid={pid} identity 与 recorded 不同',
70
70
  'utils.envLock.ownerAliveDegraded': 'owner 进程存活(heartbeat 可能 degraded),非 stale',
71
+ 'utils.envLock.ownerAliveHeartbeatStopped': 'owner pid={pid} 进程存活且进程身份一致,但 heartbeat {longExpired} → 判定为残留锁(写方已停摆),可显式回收',
71
72
  'utils.envLock.notStaleRefuseRecovery': '非 stale,拒绝 recovery',
72
73
  'utils.envLock.ownershipGone': 'ownership 已消失(被他人接管/清除),停止 recovery',
73
74
  'utils.envLock.captureRenameFailed': '捕获 rename 失败(可能被他人接管),停止',
@@ -86,6 +87,9 @@ export const zh = {
86
87
  'utils.envLock.durationMinutes': '{value} 分钟',
87
88
  'utils.envLock.durationSeconds': '{value} 秒',
88
89
  'utils.envLock.ioPermissionNotLock': '{what}: 权限/ACL 错误 ({code}),非锁占用',
90
+ 'utils.envLock.heartbeatWriteFailed': '环境锁心跳写入失败: {reason}',
91
+ 'utils.envLock.releaseFailedQuarantined': '环境锁释放失败,已把 ownership 挪到 recovering 解除阻塞: {reason}',
92
+ 'utils.envLock.releaseFailedStuck': '环境锁释放失败,且无法挪走 ownership(后续操作会被判为锁被占用): {reason}',
89
93
  // ---------- utils/env-lock.ts:锁被挡时给用户的分类文案(长 / 短两套,同源同分类) ----------
90
94
  'utils.envLock.block.locked': '另一个任务正在运行,请稍后重试。',
91
95
  'utils.envLock.block.blocked': '配置修改已被保护,请先处理恢复事项后再继续。',
@@ -93,10 +97,14 @@ export const zh = {
93
97
  'utils.envLock.block.stale': '检测到上次异常退出残留的配置锁(其持有进程已不存在),操作已被阻止。'
94
98
  + '该锁不会自动清除,重试或重启 DSH 均无效:请在「事故恢复」中点击「回收残留锁」,'
95
99
  + '或运行 dsh-config-manager recover-stale-lock 回收后再重试。',
100
+ 'utils.envLock.block.staleDegraded': '检测到残留的配置锁:其记录中的进程仍在运行,但心跳已长期停止,说明上次释放没有完成。'
101
+ + '操作已被阻止,重试或重启 DSH 都不会自愈:请在「事故恢复」中点击「回收残留锁」,'
102
+ + '或运行 dsh-config-manager recover-stale-lock 回收后再重试。',
96
103
  'utils.envLock.brief.locked': '环境锁被另一项任务占用',
97
104
  'utils.envLock.brief.blocked': '配置修改已被保护,需先处理恢复事项',
98
105
  'utils.envLock.brief.unavailable': '环境锁暂时不可用',
99
106
  'utils.envLock.brief.stale': '残留配置锁(持有进程已不存在),需先回收',
107
+ 'utils.envLock.brief.staleDegraded': '残留配置锁(心跳已长期停止),需先回收',
100
108
  // ---------- utils/proxy.ts:代理隧道(保留原文的双语形态,zh 逐字不变) ----------
101
109
  'utils.proxy.connectTimeout': '代理连接超时 / proxy connect timed out ({ms}ms)',
102
110
  'utils.proxy.malformedConnectResponse': '代理 CONNECT 响应异常(头部过长)/ malformed CONNECT response',
@@ -167,6 +175,7 @@ export const en = {
167
175
  'utils.envLock.heartbeatExpiredNoIdentity': 'heartbeat expired and pid={pid} is alive, but the OS process identity cannot be obtained reliably — conservatively refusing to delete',
168
176
  'utils.envLock.pidReuse': 'pid reuse: pid={pid} identity differs from the recorded one',
169
177
  'utils.envLock.ownerAliveDegraded': 'owner process is alive (heartbeat may be degraded), not stale',
178
+ 'utils.envLock.ownerAliveHeartbeatStopped': 'owner pid={pid} is alive and its process identity matches, but heartbeat {longExpired} → judged a stale lock (the writer stopped), explicit reclaim allowed',
170
179
  'utils.envLock.notStaleRefuseRecovery': 'not stale — refusing recovery',
171
180
  'utils.envLock.ownershipGone': 'ownership has disappeared (taken over/cleared by someone else) — stopping recovery',
172
181
  'utils.envLock.captureRenameFailed': 'capture rename failed (possibly taken over by someone else) — stopping',
@@ -185,16 +194,23 @@ export const en = {
185
194
  'utils.envLock.durationMinutes': '{value} minutes',
186
195
  'utils.envLock.durationSeconds': '{value} seconds',
187
196
  'utils.envLock.ioPermissionNotLock': '{what}: permission/ACL error ({code}), not lock contention',
197
+ 'utils.envLock.heartbeatWriteFailed': 'Environment lock heartbeat write failed: {reason}',
198
+ 'utils.envLock.releaseFailedQuarantined': 'Environment lock release failed; the ownership file was moved to recovering so writes are no longer blocked: {reason}',
199
+ 'utils.envLock.releaseFailedStuck': 'Environment lock release failed and the ownership file could not be moved aside (later operations will look lock-blocked): {reason}',
188
200
  'utils.envLock.block.locked': 'Another task is running, please retry later.',
189
201
  'utils.envLock.block.blocked': 'Configuration changes are protected — resolve the recovery items before continuing.',
190
202
  'utils.envLock.block.unavailable': 'The operation cannot run right now, please retry later; if it keeps failing, check the logs.',
191
203
  'utils.envLock.block.stale': 'A configuration lock left behind by a previous abnormal exit was detected (its owning process no longer exists), so the operation was blocked.'
192
204
  + 'This lock will not clear itself — retrying or restarting DSH will not help: click "Reclaim stale lock" under "Incident recovery",'
193
205
  + 'or run dsh-config-manager recover-stale-lock and then retry.',
206
+ 'utils.envLock.block.staleDegraded': 'A leftover configuration lock was detected: its recorded process is still running, but its heartbeat stopped long ago, so the last release never finished.'
207
+ + 'The operation was blocked, and retrying or restarting DSH will not clear it: click "Reclaim stale lock" under "Incident recovery",'
208
+ + 'or run dsh-config-manager recover-stale-lock and then retry.',
194
209
  'utils.envLock.brief.locked': 'Environment lock held by another task',
195
210
  'utils.envLock.brief.blocked': 'Configuration changes are protected; resolve recovery items first',
196
211
  'utils.envLock.brief.unavailable': 'Environment lock temporarily unavailable',
197
212
  'utils.envLock.brief.stale': 'Stale configuration lock (owning process is gone); reclaim it first',
213
+ 'utils.envLock.brief.staleDegraded': 'Stale configuration lock (heartbeat stopped long ago); reclaim it first',
198
214
  // ---------- utils/proxy.ts ----------
199
215
  'utils.proxy.connectTimeout': 'Proxy connection timed out ({ms}ms)',
200
216
  'utils.proxy.malformedConnectResponse': 'Malformed proxy CONNECT response (headers too long)',
@@ -11,7 +11,7 @@
11
11
  * 调用方若把它 catch 成「这一层没有 patch 行」,用户手写的整层配置就会在导出/同步/预览里凭空消失;
12
12
  * 导入写回时更会把整份文件重写成「只剩本次导入的行」—— 这正是 issue #75 报告的数据丢失。
13
13
  *
14
- * 两个形状与 DSH 逐字对齐(**改这里等于改对外契约**,见 `docs/spec/bundle-format-v1.md`):
14
+ * 两个形状与 DSH 逐字对齐(**改这里等于改对外契约**,见 `docs/contracts/bundle-format-v1.md`):
15
15
  * - 载入:`!!js <源码>` → `{ __jsExpr: <源码> }`
16
16
  * - 写回:`{ __jsExpr: <源码> }` → `!!js <源码>`
17
17
  * 判据与 cordis 的 `isJsExpr`(`value instanceof Object && '__jsExpr' in value`)一致,于是 bundle 里
package/lib/utils/zip.js CHANGED
@@ -84,7 +84,7 @@ export function assertZipEntryCount(count, limits = {}) {
84
84
  }
85
85
  /* ---------------- 写出侧布局片段(zipToBuffer 与 writeZip 共用,避免两份布局漂移) ----------------
86
86
  * 三条 helper 的字段写入顺序与取值**必须与历史 zipToBuffer 逐字一致** —— 产物格式是对外契约
87
- * (docs/spec/bundle-format-v1.md),zip.test.ts 有一条「zipToBuffer 与 writeZip 产物等价」的用例钉住。 */
87
+ * (docs/contracts/bundle-format-v1.md),zip.test.ts 有一条「zipToBuffer 与 writeZip 产物等价」的用例钉住。 */
88
88
  /** 本地文件头(30 字节;不含紧随其后的文件名与压缩数据)。 */
89
89
  function buildLocalHeader(nameLen, crc, compressedSize, size, time, date) {
90
90
  const local = Buffer.alloc(30);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-config-manager",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "license": "MIT",
5
5
  "description": "Backup, restore, export, import, migrate and sync your DeepSeek Harness (DSH) configuration: settings, plugins, MCP servers, skills, agent presets and workspaces. One-click migration to another machine. DSH 配置一键备份、恢复、导出、导入、迁移与同步插件。",
6
6
  "icon": "./icon.svg",
@@ -84,6 +84,7 @@
84
84
  "test": "node --test \"src/**/*.test.ts\" \"tests/**/*.test.ts\"",
85
85
  "smoke": "node --test src/core/smoke.test.ts",
86
86
  "oss:check": "node scripts/oss-live-check.mjs",
87
+ "readme:stars": "node scripts/star-history.mjs",
87
88
  "typecheck": "tsc --noEmit",
88
89
  "typecheck:tests": "tsc -p tsconfig.tests.json --noEmit",
89
90
  "build": "tsc -p tsconfig.build.json && tsdown",
@@ -203,7 +204,7 @@
203
204
  "react": "^18.3.1",
204
205
  "react-dom": "^18.3.1",
205
206
  "schemastery": "^3.18.0",
206
- "tsdown": "0.23.4",
207
+ "tsdown": "0.23.5",
207
208
  "typescript": "^7.0.2"
208
209
  }
209
210
  }
@@ -89,6 +89,34 @@ test('mcp: export 提取 + analyzeImport Create/Skip/Conflict + applyItem 写 pa
89
89
  assert.deepEqual((raw['config'] as Record<string, unknown>)['args'], ['-y', 'x'], 'Conflict useImported 应更新目标行');
90
90
  });
91
91
 
92
+ test('同步判定前提:mcp 导出字节必须可复现 —— 载荷里不得含「导出当刻」的时间戳', async () => {
93
+ // 为什么钉这条:SyncEngine.hasLocalChanges 直接 hashSection(export()),基线也取自同一份载荷;
94
+ // 载荷里只要有 now(),hash 每次都不同 ⇒ 每轮轮询都判「有改动」⇒ 真推一次空快照(AGENTS.md 同步节)。
95
+ const ctx = makeContext('win32', 'C:\\Users\\alice');
96
+ ctx.patchFile.lines.set('mcp-fs', {
97
+ lineId: 'mcp-fs',
98
+ raw: { id: 'mcp-fs', name: 'dsh-mcp-client', config: { serverName: 'filesystem', command: 'npx', args: ['-y', 'x'] } },
99
+ });
100
+ await ctx.fs.writeFile('storages/mcp_connector.json', new TextEncoder().encode(JSON.stringify({
101
+ tables: {
102
+ connections: {
103
+ citra: {
104
+ key: 'citra', connectorId: 'citra', kind: 'manual', name: 'Citra',
105
+ serverName: 'citra', transport: 'stdio', command: 'npx', args: ['-y', '@sylphx/citra'], enabled: true,
106
+ },
107
+ },
108
+ },
109
+ })));
110
+ const adapter = new McpAdapter();
111
+ const first = await adapter.export(ctx, { includeSecrets: false });
112
+ await new Promise((resolve) => { setTimeout(resolve, 25); });
113
+ const second = await adapter.export(ctx, { includeSecrets: false });
114
+ assert.deepEqual(
115
+ second.data, first.data,
116
+ '同一份本地状态两次导出必须逐字节一致(否则同步判定恒为「有改动」)',
117
+ );
118
+ });
119
+
92
120
  test('issue #71: profile 层 MCP 行也要导出,且写回**原层**(不再凭空消失 / 不搬家)', async () => {
93
121
  const src = makeContext('win32', 'C:\\Users\\alice', 'tauri');
94
122
  // 真机形态:MCP server 由手写/工具写进 profile 层(home 层只有别的行)
@@ -83,6 +83,39 @@ export function extractMcpServers(lines: { lineId: string; raw: unknown; file?:
83
83
  return servers;
84
84
  }
85
85
 
86
+ /**
87
+ * 反向操作:从一行 patch 里剔除 MCP 服务器条目(plugins 分区导出时用,2026-11「C8」)。
88
+ *
89
+ * 为什么需要:`cordis.patch.yml` 是一本**清单**,plugins 分区导出整本带走,于是「没勾 MCP
90
+ * 连接器」也会把 dsh-mcp-client 行(command/args/env + 本机 cwd)推到远端 —— 违反
91
+ * 「未勾选分区的数据不进推送」。判定必须与 extractMcpServers 完全同口径(config.serverName
92
+ * 为非空字符串),否则两边会漂。返回 undefined = 该行只剩 MCP 条目,整行丢弃。
93
+ */
94
+ export function stripMcpEntries(raw: unknown): unknown | undefined {
95
+ if (raw === null || typeof raw !== 'object') return raw;
96
+ const obj = raw as Record<string, unknown>;
97
+ if (Array.isArray(obj['insert'])) {
98
+ const before = obj['insert'] as unknown[];
99
+ const kept = before.filter((e) => !isMcpEntry(e));
100
+ if (kept.length === before.length) return raw;
101
+ if (kept.length === 0) return undefined;
102
+ return { ...obj, insert: kept };
103
+ }
104
+ // 非 entry 形态(插件配置行 / 禁用行等)原样保留:只有 entriesOf 认得的行才可能是 MCP 行
105
+ const single = entriesOf(raw);
106
+ if (single.length === 0) return raw;
107
+ return isMcpEntry(single[0]) ? undefined : raw;
108
+ }
109
+
110
+ /** 单个 patch entry 是否是 MCP 服务器行(与 extractMcpServers 的判定同口径) */
111
+ function isMcpEntry(entry: unknown): boolean {
112
+ if (entry === null || typeof entry !== 'object') return false;
113
+ const config = (entry as Record<string, unknown>)['config'];
114
+ if (config === null || typeof config !== 'object') return false;
115
+ const serverName = (config as Record<string, unknown>)['serverName'];
116
+ return typeof serverName === 'string' && serverName !== '';
117
+ }
118
+
86
119
  /** patch 行 → 可枚举的 entry 列表(兼容单行与 insert 块) */
87
120
  function entriesOf(raw: unknown): { id?: unknown; name?: unknown; config?: unknown }[] {
88
121
  if (raw === null || typeof raw !== 'object') return [];
@@ -5,6 +5,7 @@
5
5
  import test from 'node:test';
6
6
  import assert from 'node:assert/strict';
7
7
  import { PluginsAdapter } from './plugins.ts';
8
+ import { McpAdapter } from './mcp.ts';
8
9
  import { makeContext, makeImportContext } from './test-helpers.ts';
9
10
  import { PLUGIN_PROFILE_MANIFEST_REF } from '../core/backup.ts';
10
11
  import type { PluginsSection } from '../schema/types.ts';
@@ -216,6 +217,53 @@ test('issue #71: plugins 导出同时收集两层 patch 行(此前只读 home
216
217
  assert.equal(dst.patchFile.lines.has('mnemon-strategy-a'), false, '不得搬到 home 层');
217
218
  });
218
219
 
220
+ /**
221
+ * C8(2026-11):`cordis.patch.yml` 是一本清单,plugins 导出曾整本带走 —— 没勾「MCP 连接器」时
222
+ * dsh-mcp-client 行(command/args/env + 本机 cwd)照样上远端。用户选定语义:只带非 MCP 行,
223
+ * MCP 行由 mcp 分区负责(勾了才走)。判定必须与 mcp 适配器同口径,否则两边漂。
224
+ */
225
+ test('C8: 未勾选 MCP 时 plugins 载荷不带 MCP patch 行;勾了仍由 mcp 分区带走', async () => {
226
+ const src = makeContext('win32', 'C:\\Users\\alice', 'web');
227
+ src.patchFile.lines.set('skill-badge', { lineId: 'skill-badge', raw: { id: 'skill-badge', disabled: true } });
228
+ // 真机形态:MCP 行由 DSH 的 MCP 工具写进 profile 层,config 里带本机 cwd
229
+ src.patchFile.bucket('profiles/web/cordis.patch.yml').set('mcp-citra', {
230
+ lineId: 'mcp-citra',
231
+ raw: {
232
+ id: 'mcp-citra',
233
+ name: 'dsh-mcp-client',
234
+ config: { serverName: 'citra', command: 'npx', args: ['-y', '@sylphx/citra'], cwd: 'C:\\Users\\alice\\proj' },
235
+ },
236
+ });
237
+ // 块形态混排:只剔 MCP 条目,绝不整块丢(否则连带丢掉同块里的用户行)
238
+ src.patchFile.lines.set('mixed', {
239
+ lineId: 'mixed',
240
+ raw: {
241
+ insert: [
242
+ { id: 'mcp-mixed', name: 'dsh-mcp-client', config: { serverName: 'mixed', command: 'node' } },
243
+ { id: 'plain-row', name: '@x/y', disabled: true },
244
+ ],
245
+ },
246
+ });
247
+
248
+ const pluginsOut = await new PluginsAdapter().export(src, { includeSecrets: false });
249
+ const ids = pluginsOut.data.patch.map((p) => p.lineId);
250
+ assert.ok(!ids.includes('mcp-citra'), 'MCP 行不得进 plugins 载荷: ' + ids.join(','));
251
+ assert.ok(ids.includes('skill-badge'), '非 MCP 行必须保留: ' + ids.join(','));
252
+ const mixed = pluginsOut.data.patch.find((p) => p.lineId === 'mixed');
253
+ const keptInsert = (mixed?.raw as { insert: { id: string }[] }).insert.map((e) => e.id);
254
+ assert.deepEqual(keptInsert, ['plain-row'], '块里只剔 MCP 条目,其余原样保留');
255
+ const payload = JSON.stringify(pluginsOut.data);
256
+ assert.ok(!payload.includes('serverName'), 'MCP 服务器定义不得出现在 plugins 载荷里');
257
+ assert.ok(!payload.includes('alice'), '本机 cwd 不得出现在 plugins 载荷里');
258
+
259
+ // 勾了 mcp:同样的行仍由 mcp 分区带走(剔的是重复来源,不是数据)
260
+ const mcpOut = await new McpAdapter().export(src, { includeSecrets: false });
261
+ assert.deepEqual(
262
+ mcpOut.data.servers.map((s) => s.serverName).sort(), ['citra', 'mixed'],
263
+ 'mcp 分区仍完整导出这些服务器: ' + mcpOut.data.servers.map((s) => s.serverName).join(','),
264
+ );
265
+ });
266
+
219
267
  test('plugins: 导出携带 pnpm-workspace.yaml;analyze 目标无文件 → Create', async () => {
220
268
  const src = makeContext('win32', 'C:\\Users\\alice', 'web');
221
269
  await src.fs.writeFile('profiles/web/pnpm-workspace.yaml', new TextEncoder().encode('allowBuilds:\n ssh2: true\n'));
@@ -422,6 +470,7 @@ test('plugins: preview 不调用打包钩子,但条目/白名单/告警与 exp
422
470
  }],
423
471
  rewritten: { 'local-pkg': packedSpec },
424
472
  warnings: [],
473
+ oversize: [],
425
474
  };
426
475
  });
427
476
 
@@ -24,6 +24,7 @@ import { isPathSafe, normalizePath } from '../utils/paths.ts';
24
24
  import { isENOENT } from '../utils/guards.ts';
25
25
  import { PLUGIN_PATCH_REF_PREFIX, PLUGIN_PROFILE_MANIFEST_REF } from '../core/backup.ts';
26
26
  import { readEffectivePatchLines, resolveWriteLayer, USER_PATCH_FILE } from '../core/patch-layers.ts';
27
+ import { stripMcpEntries } from './mcp.ts';
27
28
  import {
28
29
  parsePnpmPatchedDependencies, restorePnpmMachinePaths, sanitizePnpmWorkspacePatches, stripPnpmMachinePaths,
29
30
  } from './pnpm-workspace.ts';
@@ -431,7 +432,14 @@ export class PluginsAdapter implements ConfigAdapter<PluginsSection> {
431
432
  // issue #71:patch 有两层(home 层 + profile 层),只读 home 层会漏掉 DSH 工具与 marketplace
432
433
  // 写入 profile 层的激活行 —— 导出少了它们,导入到新机就少一批插件加载项。
433
434
  const patchRead = await readEffectivePatchLines(ctx.patchFile, ctx.profile);
434
- for (const l of patchRead.lines) patch.push({ file: l.file, lineId: l.lineId, raw: l.raw });
435
+ for (const l of patchRead.lines) {
436
+ // MCP 行不进 plugins 载荷(2026-11「C8」,用户选择「只带非 MCP 行」):它是 mcp 分区的
437
+ // 数据源,随 plugins 整本带走会让「没勾 MCP 连接器」也把服务器定义与本机 cwd 推到远端。
438
+ // 判定与 mcp 适配器同口径(stripMcpEntries);勾了 mcp 时这些行仍由 mcp 分区带走。
439
+ const raw = stripMcpEntries(l.raw);
440
+ if (raw === undefined) continue;
441
+ patch.push({ file: l.file, lineId: l.lineId, raw });
442
+ }
435
443
  for (const f of patchRead.failures) {
436
444
  warnings.push(msgOf(ctx)('adapter.patchReadFailed', { reason: `${f.file}: ${f.reason}` }));
437
445
  }
@@ -162,7 +162,7 @@ export function sanitizePnpmWorkspacePatches(
162
162
  * 2. 写回时把**目标机自己原有的**那几行接回去:不搬运来源机的路径,也不清掉本机自己的设置。
163
163
  *
164
164
  * `.npmrc` 刻意**不进同步面**(见 plugins.ts 的说明):纳入它会改变 bundle 载荷形态
165
- * (docs/spec/bundle-format-v1.md + conformance),而本机 .npmrc 从来就不由本插件写 ——
165
+ * (docs/contracts/bundle-format-v1.md + conformance),而本机 .npmrc 从来就不由本插件写 ——
166
166
  * 「不碰 = 本机保留」。
167
167
  * ------------------------------------------------------------------ */
168
168
 
@@ -11,7 +11,7 @@
11
11
  import test from 'node:test';
12
12
  import assert from 'node:assert/strict';
13
13
  import { createAdapters } from './index.ts';
14
- import { SelfAdapter, SELF_CONFIG_FILES, SELF_IMPORT_BLOCKED_RELS, SELF_IMPORT_BLOCKED_CODE } from './self.ts';
14
+ import { SelfAdapter, SELF_CONFIG_FILES, SELF_IMPORT_BLOCKED_RELS, SELF_IMPORT_BLOCKED_CODE, isSelfImportBlocked } from './self.ts';
15
15
  import { hashSection } from '../sync/sync-state.ts';
16
16
  import { sha256Hex } from '../utils/hashing.ts';
17
17
  import { makeContext, makeImportContext } from './test-helpers.ts';
@@ -131,6 +131,44 @@ test('SEC-01:包内含 sync-config.json / sync-autosync.json → 报告级 war
131
131
  assert.equal(await dst.fs.exists('dsh-config-manager/sync/sync-autosync.json'), false, '不得凭空创建同步调度配置');
132
132
  });
133
133
 
134
+ test('SEC-01:分档案作用域 sync-profiles/<p>/ 的同步目标同样拦截(按模式,不按清单)', async () => {
135
+ // 判据:档案名是运行时集合,列举不出来 —— 所以按目录模式判,两种形态必须一致
136
+ for (const rel of [
137
+ 'sync-profiles/Test1/sync-config.json',
138
+ 'sync-profiles/Test1/sync-autosync.json',
139
+ 'sync-profiles/open-design/sync-config.json',
140
+ 'sync/sync-config.json',
141
+ 'sync/sync-autosync.json',
142
+ ]) {
143
+ assert.equal(isSelfImportBlocked(rel), true, '必须拦下: ' + rel);
144
+ }
145
+ // 不误伤:同目录里的选择/偏好/运行态不是「同步目标」,白名单外也不该被本判据报成安全事件
146
+ for (const rel of [
147
+ 'sync-profiles/Test1/sync-selection.json',
148
+ 'sync-profiles/Test1/ui-prefs.json',
149
+ 'sync-profiles/Test1/sync-state.json',
150
+ 'sync-profiles/nested/deep/sync-config.json',
151
+ 'sync/sync-selection.json',
152
+ ]) {
153
+ assert.equal(isSelfImportBlocked(rel), false, '不该拦: ' + rel);
154
+ }
155
+
156
+ // 计划阶段:包内带分档案同步目标 → 改判 Warning(去掉 target ⇒ 引擎不写盘、不进快照范围)
157
+ const adapter = new SelfAdapter();
158
+ const evil = '{"schemaVersion":3,"transport":"git","git":{"repoUrl":"https://attacker.example/collect.git"}}';
159
+ const relativePath = 'sync-profiles/Test1/sync-config.json';
160
+ const section = {
161
+ version: 1 as const,
162
+ files: [{ relativePath, data: Buffer.from(evil, 'utf8'), contentHash: sha256Hex(Buffer.from(evil, 'utf8')) }],
163
+ };
164
+ const dst = makeContext('linux', '/home/bob');
165
+ const items = await adapter.analyzeImport(section, makeImportContext(dst, new Map([['self', section]])));
166
+ assert.equal(items.length, 1);
167
+ assert.equal(items[0]?.kind, 'Warning');
168
+ assert.ok(String(items[0]?.detail ?? '').startsWith(SELF_IMPORT_BLOCKED_CODE));
169
+ assert.equal(await dst.fs.exists('dsh-config-manager/' + relativePath), false, '包内地址不得落地');
170
+ });
171
+
134
172
  test('createAdapters: selfDir 缺省挂载 dsh-config-manager;空串不挂载', () => {
135
173
  const withSelf = createAdapters({ selfDir: undefined });
136
174
  assert.ok(withSelf.some((a) => a.id === 'self'), '缺省挂载 self adapter');
@@ -84,6 +84,24 @@ export const SELF_IMPORT_BLOCKED_RELS: readonly string[] = [
84
84
  'sync/sync-autosync.json',
85
85
  ];
86
86
 
87
+ /**
88
+ * 分档案作用域(`sync-profiles/<profile>/`)里**同一类**文件:SEC-01 必须按模式挡。
89
+ *
90
+ * 档案名是运行时集合(用户随时能建新档案),无法列举成数组;而这些文件与 `sync/` 下那两份
91
+ * 语义完全相同 —— 都是「同步目标 / 自动同步开关」,导入一个指向攻击者仓库的包后,用户下次
92
+ * 同步就会把该档案的配置推过去。`SELF_CONFIG_FILES` 白名单本就不含 `sync-profiles/`(导出侧
93
+ * 从不搬别人的档案作用域),这里补的是导入侧的纵深防御。
94
+ */
95
+ const SELF_IMPORT_BLOCKED_PATTERNS: readonly RegExp[] = [
96
+ /^sync-profiles\/[A-Za-z0-9][A-Za-z0-9._-]*\/sync-config\.json$/,
97
+ /^sync-profiles\/[A-Za-z0-9][A-Za-z0-9._-]*\/sync-autosync\.json$/,
98
+ ];
99
+
100
+ /** SEC-01 判据(单一入口):精确 rel 或分档案作用域里的同语义文件,一律不落地。 */
101
+ export function isSelfImportBlocked(rel: string): boolean {
102
+ return SELF_IMPORT_BLOCKED_RELS.includes(rel) || SELF_IMPORT_BLOCKED_PATTERNS.some((pattern) => pattern.test(rel))
103
+ }
104
+
87
105
  /**
88
106
  * 拦截报告项里的**稳定机器码**前缀(`self-import-blocked:<rel>`)。
89
107
  *
@@ -265,7 +283,7 @@ export class SelfAdapter extends FileCollectionAdapter {
265
283
  const items = await super.analyzeImport(data, ctx);
266
284
  return items.map((item) => {
267
285
  const rel = item.target?.ref;
268
- if (rel === undefined || !SELF_IMPORT_BLOCKED_RELS.includes(rel)) return item;
286
+ if (rel === undefined || !isSelfImportBlocked(rel)) return item;
269
287
  const blocked: PlanItem = {
270
288
  id: item.id,
271
289
  kind: 'Warning',
@@ -285,7 +303,7 @@ export class SelfAdapter extends FileCollectionAdapter {
285
303
  */
286
304
  override async applyItem(item: PlanItem, ctx: ImportContext): Promise<ApplyResult> {
287
305
  const ref = item.target?.ref;
288
- if (ref !== undefined && SELF_IMPORT_BLOCKED_RELS.includes(ref)) {
306
+ if (ref !== undefined && isSelfImportBlocked(ref)) {
289
307
  return { ok: false, message: ctx.msg('adapter.selfImportBlocked', { path: ref }), warning: true };
290
308
  }
291
309
  return super.applyItem(item, ctx);
@@ -274,7 +274,7 @@ export class WorkspacesAdapter implements ConfigAdapter<WorkspacesSection> {
274
274
  issues.push({ path: 'workspaces[]', message: msg('adapter.validate.workspaceIdentity'), severity: 'error' });
275
275
  continue;
276
276
  }
277
- // ui-F3:sessionIds 是会话可见性的必需字段(docs/spec/bundle-format-v1.md §6),
277
+ // ui-F3:sessionIds 是会话可见性的必需字段(docs/contracts/bundle-format-v1.md §6),
278
278
  // 而 analyzeImport / finalizeImport 直接读 rec.sessionIds.length —— 缺它有两条后果:
279
279
  // ① validate 放过后 analyzeImport 抛内部 TypeError → 整包被拦下且文案不可行动;
280
280
  // ② 即便绕过,工作区记录也失去会话归属。这里按「必需数组」显式报出字段名。
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * 注意:CLI 只续跑 `cli-restore` 自己创建的 journal。别的入口(GUI restore / model-restore)
11
11
  * 崩掉的记录在这里仍是「需要恢复面板处理」的事故 —— 三者的执行器与参数来源不同,
12
- * 跨入口续跑没有证据支撑(详见 docs/decisions/0004)。
12
+ * 跨入口续跑没有证据支撑(详见 docs/adr/0004)。
13
13
  */
14
14
  import { resolveSafeModeMarker } from '../core/recovery-orchestrator.ts'
15
15
  import { probeRestoreResume, runRestoreWithResume } from '../core/restore-resume.ts'
@@ -5,7 +5,7 @@
5
5
  * HTML:**零脚本、零外部资源、零构建产物**,配合 http.ts 里收紧的 CSP。
6
6
  * 样式内联在 <style> 里(独立于插件 UI 的 CSS Modules;该新 pattern 已登记进 DESIGN.md)。
7
7
  * 这套样式表**有一份外部出处**(亮色 IBM Carbon / 暗色 Raycast 阶梯)与逐条对照表:
8
- * docs/components/cli-rescue-console.md —— 改 STYLE 前先读它,改完跑 web.test.ts 的 R3-02。
8
+ * docs/architecture/cli-rescue-console.md —— 改 STYLE 前先读它,改完跑 web.test.ts 的 R3-02。
9
9
  *
10
10
  * 呈现纪律:每个数字都要能回答「你怎么知道的」—— 离线拿不到的(结构化分区/凭据/同步令牌)
11
11
  * 一律显式列出并说明原因,绝不显示为 0 或留空。
@@ -32,7 +32,7 @@ export interface PageChrome {
32
32
 
33
33
  const STYLE = [
34
34
  // ---- 设计 token:IBM Carbon(亮色语义四色)+ Raycast(暗色 surface 阶梯)----
35
- // 映射表、取的章节与全部偏离记录:docs/components/cli-rescue-console.md
35
+ // 映射表、取的章节与全部偏离记录:docs/architecture/cli-rescue-console.md
36
36
  // 文字色一律取「能读」的那一档:Carbon 的 #24a148 / #f1c21b 只做填充,正文用 #198038 / #8e6a00
37
37
  // (AA 对比度由 web.test.ts 的 R3-02 逐对钉住,改色先过那条测试)。
38
38
  ':root{color-scheme:light dark;--font:system-ui,-apple-system,"Segoe UI",Roboto,"PingFang SC","Hiragino Sans GB","Microsoft YaHei","Noto Sans SC",sans-serif;--mono:ui-monospace,SFMono-Regular,Menlo,Consolas,"Liberation Mono",monospace;--fg:#161616;--muted:#525252;--bg:#f4f4f4;--card:#fff;--surface:#f4f4f4;--line:#e0e0e0;--accent:#0f62fe;--accent-hover:#0043ce;--on-accent:#fff;--ok:#198038;--warn:#8e6a00;--bad:#da1e28;--scrim:rgba(22,22,22,.45)}',
@@ -1,5 +1,5 @@
1
1
  /**
2
- * 「关于(About)」面板(设置页第 6 个 tab 内容,docs/design/2026-08-19-about-tab-design.md §4)。
2
+ * 「关于(About)」面板(设置页第 6 个 tab 内容,docs/archive/2026-08-19-about-tab-design.md §4)。
3
3
  *
4
4
  * 纯静态展示视图 + 外链,无表单 / 无写操作 / 无新增依赖:
5
5
  * - 项目信息卡:插件名 + 官方 Badge;版本 / DSH / 平台 Badge(运行时信息,经 api.status() 获取);
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 「关于(About)」Tab 纯函数渲染模型单测(node:test + node:assert,无需 DOM)。
3
3
  *
4
- * 覆盖(docs/design/2026-08-19-about-tab-design.md §5):
4
+ * 覆盖(docs/archive/2026-08-19-about-tab-design.md §5):
5
5
  * - 链接派生:repoUrl → star / docs / issues 的正确后缀;
6
6
  * - 尾斜杠输入归一化(含多个尾斜杠);
7
7
  * - 状态行格式化:pluginVersion / dshVersion / platform+arch 合并;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * 「关于(About)」Tab 的客户端纯函数渲染模型(node 可测,无 React / 无 DOM)。
3
3
  *
4
- * 设计依据(docs/design/2026-08-19-about-tab-design.md §5):
4
+ * 设计依据(docs/archive/2026-08-19-about-tab-design.md §5):
5
5
  * - 公开元数据(插件名 / 仓库 / 作者)为**静态常量**,不随运行时变化,可读、可测、可维护;
6
6
  * - 版本 / DSH / 平台等运行时信息由面板经 `api.status()` 获取,本层只负责格式化,
7
7
  * 版本号**绝不**在 client 重复维护(AGENTS.md §版本号三处同步教训);
package/src/client/api.ts CHANGED
@@ -6,7 +6,7 @@
6
6
  * 客户端控制器(ExportFlow / ImportWizard)把本类实例当作 port 注入即可,
7
7
  * 无需任何额外适配层 —— 这是「直接绑定 src/ui,不重复实现」的关键。
8
8
  *
9
- * 端点契约(Host 半 `src/index.ts` 按此实现,见 CLIENT_DEPENDENCIES.md 的接口说明):
9
+ * 端点契约(Host 半 `src/index.ts` 按此实现,见 docs/architecture/client-dependencies.md 的接口说明):
10
10
  * ```
11
11
  * GET /api/dsh-config-manager/status → ServiceStatus (健康/版本检查)
12
12
  * POST /api/dsh-config-manager/export → ExportResponse (body: ExportOptions;响应含 runId)
@@ -750,11 +750,6 @@ export class ConfigManagerApi {
750
750
  return postJson<{ ok: boolean; removed: boolean }>(CONFIG_MANAGER_API.snapshotDelete, { snapshotId }, this.t);
751
751
  }
752
752
 
753
- /** P1-⑧:置顶/取消置顶快照(置顶快照豁免自动保留清理,只能手动删除)。 */
754
- async setSnapshotPinned(snapshotId: string, pinned: boolean): Promise<{ pinned: boolean }> {
755
- return postJson<{ ok: boolean; pinned: boolean }>(CONFIG_MANAGER_API.snapshotPin, { snapshotId, pinned }, this.t);
756
- }
757
-
758
753
  // ------------------------------------------------- 档案(DSH 自带 profile)
759
754
  /** 列出 DSH profile:列表 + 当前运行 + 在跑的实例(台账 ∪ 心跳)+ 起步模板。 */
760
755
  async profilesList(): Promise<DshProfilesSnapshot> {
@@ -475,7 +475,7 @@ test('动作行图标走宿主原生(复制 → 对勾 → 回退),拿不
475
475
  /**
476
476
  * 2026-10-17(用户要求「与 DSH 原生气泡完全一致」):§15b 的几何/字号必须与宿主
477
477
  * MessageItem + MessageIconActions 的**同一条取值**逐字同式(宿主产物抽出的取值清单见
478
- * docs/maintenance/known-gaps.md 的「G-39 增量(八)」)。这张用例是那条口径的源级护栏:
478
+ * docs/known-issues/known-gaps.md 的「G-39 增量(八)」)。这张用例是那条口径的源级护栏:
479
479
  * 谁把圆角/内边距/动作行/文件卡改回「近似档」,这里立刻红。
480
480
  */
481
481
  test('气泡与动作行逐值对齐宿主:圆角 xl(20px) / 内边距 10·16 / 动作行 28+delta / 文件卡 240·64', () => {
@@ -45,7 +45,7 @@
45
45
  * 2026-10-12(用户要求「聊天内回退入口只有每条用户消息」):回合尾那一颗入口连同它的「整回合」偏好档
46
46
  * 一起删除 —— 本文件因此**不再镜像**该槽位(没有人再对它 `register`,也没有组件 props 需要推导)。
47
47
  * 历史证据(0.1.5-rc.2 的 `chain` 形态 vs 0.2 的 `list` 形态)保留在
48
- * `docs/lessons/recovery-console.md`,不再需要面向它的形态探测。
48
+ * `docs/evidence/recovery-console.md`,不再需要面向它的形态探测。
49
49
  *
50
50
  * ## 版本差异(T9-F2 的真机证据;登记处据此做形态探测)
51
51
  *
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * ## 纪律
17
17
  * · **抽出来的方法一律 bind 回服务对象**(`openResource` / `register` 都读 `this`;丢 receiver 会抛,
18
- * 见 AGENTS.md 与 docs/lessons/recovery-console.md 的 `uiWorkspace.openSession` 事故);
18
+ * 见 AGENTS.md 与 docs/evidence/recovery-console.md 的 `uiWorkspace.openSession` 事故);
19
19
  * · 服务缺失 / 形态不符 / 调用抛错统统是**降级**(返回结构化结果),绝不打挂插件装配。
20
20
  */
21
21
 
@@ -2,7 +2,7 @@
2
2
  * Client 半的类型集中出口:把对 @deepseek-ai 运行时包的类型依赖收敛到本文件,
3
3
  * 其余组件只从 `../client-types.ts` 引用,避免类型散落与误用值导入。
4
4
  *
5
- * p3 构建前需安装的依赖(见 CLIENT_DEPENDENCIES.md):
5
+ * p3 构建前需安装的依赖(见 docs/architecture/client-dependencies.md):
6
6
  * - @deepseek-ai/dsh-client-runtime(ClientContext 声明合并)
7
7
  * - @deepseek-ai/dsh-client-locale(ctx.locale 声明合并)
8
8
  * - @deepseek-ai/dsh-client-ui-settings(settings.section SlotMap 声明合并)
@@ -72,7 +72,6 @@ export const CONFIG_MANAGER_API = {
72
72
  snapshots: `${API_BASE}/snapshots`,
73
73
  restore: `${API_BASE}/restore`,
74
74
  snapshotDelete: `${API_BASE}/snapshots/delete`,
75
- snapshotPin: `${API_BASE}/snapshots/pin`,
76
75
  snapshotFileDiff: `${API_BASE}/snapshots/file-diff`,
77
76
  backupSchedule: `${API_BASE}/backup-schedule`,
78
77
  backupScheduleRun: `${API_BASE}/backup-schedule/run`,
@@ -149,16 +148,13 @@ export const SYNC_API = {
149
148
  probe: `${API_BASE}/sync/probe`,
150
149
  } as const;
151
150
 
152
- /** 配置市场路由族(内置单市场:浏览 / 下载 / 发布向导;无 add/remove)。 */
151
+ /** 配置市场路由族(内置单市场:浏览 / 下载;无 add/remove)。 */
153
152
  export const MARKET_API = {
154
153
  base: `${API_BASE}/market`,
155
154
  status: `${API_BASE}/market/status`,
156
155
  refresh: `${API_BASE}/market/refresh`,
157
156
  browse: `${API_BASE}/market/browse`,
158
157
  download: `${API_BASE}/market/download`,
159
- prepare: `${API_BASE}/market/prepare`,
160
- /** 受控临时区文件下载端点(发布包 zip 下载复用;GET ?path=,无凭据) */
161
- fileDownload: `${API_BASE}/download`,
162
158
  } as const;
163
159
 
164
160
  /** 「我的配置」路由族(一键上传 / 查看 / 更新 / 收录状态)。 */
@@ -2,7 +2,7 @@
2
2
  * css-scale-guard — 视觉 scale 的**源级执行者**(UI v3 §4.2/§4.3、§12)。
3
3
  *
4
4
  * 为什么需要它:`DESIGN.md` 从 v1 起就写着「唯一允许的 scale」,但实测文件里同时存在
5
- * 10 档字号 / 11 档圆角 / 5 档行高 / 10 档 gap(见 docs/design/2026-10-05-ui-redesign-v3.md §0)——
5
+ * 10 档字号 / 11 档圆角 / 5 档行高 / 10 档 gap(见 docs/archive/2026-10-05-ui-redesign-v3.md §0)——
6
6
  * 散文规范拦不住新增值。本守卫把 scale 变成红灯:越界值直接失败。
7
7
  *
8
8
  * 覆盖:font-size / border-radius / line-height / z-index / padding / margin / gap。
@@ -74,6 +74,9 @@ const BACKUP_SKIP_KEY: Record<BackupSkipReason, ConfigManagerKey> = {
74
74
  running: 'overview.quick.backupSkippedRunning',
75
75
  conflict: 'overview.quick.backupSkippedConflict',
76
76
  locked: 'overview.quick.backupSkippedLocked',
77
+ 'lock-stale': 'overview.quick.backupSkippedLockStale',
78
+ 'lock-unavailable': 'overview.quick.backupSkippedLockUnavailable',
79
+ 'safe-mode': 'overview.quick.backupSkippedSafeMode',
77
80
  other: 'overview.quick.backupSkippedOther',
78
81
  }
79
82
 
@@ -67,10 +67,18 @@ export interface ArtifactRowViewProps {
67
67
  * (旧快照没有该字段,绝不显示空串或占位)。
68
68
  */
69
69
  deviceLabel?: string | undefined
70
+ /**
71
+ * 来源档案徽章(本机快照专用):这份快照是哪个 DSH profile 拍的。
72
+ *
73
+ * 只有 `SnapshotMeta.originProfile` 真的存在时调用方才给值 —— 缺省 undefined 表示**不渲染**
74
+ * (旧快照没有来源,绝不显示空档案名或「未标注」徽章)。`hint` 只在「与当前档案不同」时给,
75
+ * 徽章本体只写档案名,差异语不重复表达。
76
+ */
77
+ originBadge?: { label: string; hint?: string; kind: 'info' | 'warn' } | undefined
70
78
  }
71
79
 
72
80
  export function ArtifactRowView({
73
- row, t, uiT, formatTime, expanded, onToggle, onAction, pending = null, deviceLabel,
81
+ row, t, uiT, formatTime, expanded, onToggle, onAction, pending = null, deviceLabel, originBadge,
74
82
  }: ArtifactRowViewProps) {
75
83
  const detailId = useId()
76
84
  const primary = row.capabilities[0]
@@ -122,13 +130,17 @@ export function ArtifactRowView({
122
130
  </div>
123
131
  )}
124
132
  </div>
125
- {row.badges.length > 0 && (
133
+ {(row.badges.length > 0 || originBadge !== undefined) && (
126
134
  <div className={css.artifactBadges}>
127
135
  {row.badges.map((badge) => (
128
136
  <Badge key={badge} kind={BADGE_KIND[badge]} title={badge === 'encrypted' ? encryptedHint : undefined}>
129
137
  {uiT(ARTIFACT_BADGE_LABEL_KEY[badge])}
130
138
  </Badge>
131
139
  ))}
140
+ {/* 来源档案排在状态徽章之后:先读「这行现在是什么状态」,再读「它来自哪个档案」 */}
141
+ {originBadge !== undefined && (
142
+ <Badge kind={originBadge.kind} title={originBadge.hint}>{originBadge.label}</Badge>
143
+ )}
132
144
  </div>
133
145
  )}
134
146
  <div className={css.artifactActions} onClick={(event) => { event.stopPropagation() }}>