dsh-config-manager 0.4.0 → 0.4.2

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 (152) hide show
  1. package/lib/cli/actions.js +2 -3
  2. package/lib/cli/import-source.js +2 -6
  3. package/lib/cli/index.js +2 -3
  4. package/lib/client.d.ts +21 -7
  5. package/lib/client.js +26122 -25799
  6. package/lib/core/exporter.js +2 -4
  7. package/lib/core/host-schedulers/cache-cleanup.d.ts +41 -0
  8. package/lib/core/host-schedulers/cache-cleanup.js +45 -0
  9. package/lib/core/host-schedulers/lifecycle-hooks.d.ts +51 -0
  10. package/lib/core/host-schedulers/lifecycle-hooks.js +78 -0
  11. package/lib/core/host-schedulers/market-cache.d.ts +40 -0
  12. package/lib/core/host-schedulers/market-cache.js +92 -0
  13. package/lib/core/messages-core.d.ts +1 -0
  14. package/lib/core/messages-core.js +2 -0
  15. package/lib/core/migration-history.d.ts +18 -2
  16. package/lib/core/migration-history.js +19 -3
  17. package/lib/core/model-tools.js +2 -6
  18. package/lib/core/restore.d.ts +0 -2
  19. package/lib/core/restore.js +16 -18
  20. package/lib/core/verify-recovery.js +4 -7
  21. package/lib/index.d.ts +3 -22
  22. package/lib/index.js +71 -327
  23. package/lib/profiles/dsh-profile-manager.d.ts +23 -1
  24. package/lib/profiles/dsh-profile-manager.js +70 -2
  25. package/lib/routes/kit.d.ts +21 -0
  26. package/lib/routes/kit.js +29 -0
  27. package/lib/routes/prefs.js +6 -6
  28. package/lib/routes/recovery.js +25 -41
  29. package/lib/routes/route-support.d.ts +23 -1
  30. package/lib/routes/route-support.js +185 -0
  31. package/lib/routes/snapshots.js +4 -11
  32. package/lib/routes/sync.js +5 -7
  33. package/lib/security/redaction.d.ts +5 -1
  34. package/lib/security/redaction.js +26 -23
  35. package/lib/sync/autosync-scheduler.js +6 -2
  36. package/lib/sync/backup-scheduler.js +2 -6
  37. package/lib/sync/baseline-heal.d.ts +35 -0
  38. package/lib/sync/baseline-heal.js +39 -0
  39. package/lib/sync/push-precheck.d.ts +35 -0
  40. package/lib/sync/push-precheck.js +58 -0
  41. package/lib/sync/sync-engine.d.ts +9 -12
  42. package/lib/sync/sync-engine.js +24 -43
  43. package/lib/ui/backup-inspect.d.ts +1 -1
  44. package/lib/ui/dsh-profiles-view.d.ts +0 -10
  45. package/lib/ui/dsh-profiles-view.js +3 -7
  46. package/lib/ui/history-model.js +3 -2
  47. package/lib/ui/overview-view.d.ts +3 -3
  48. package/lib/ui/overview-view.js +9 -1
  49. package/lib/ui/snapshots-view.d.ts +0 -14
  50. package/lib/ui/snapshots-view.js +16 -2
  51. package/lib/utils/paths.d.ts +20 -4
  52. package/lib/utils/paths.js +22 -6
  53. package/lib/utils/time.d.ts +31 -0
  54. package/lib/utils/time.js +54 -0
  55. package/package.json +1 -1
  56. package/src/cli/actions.ts +2 -3
  57. package/src/cli/import-source.ts +2 -7
  58. package/src/cli/index.ts +2 -3
  59. package/src/client/about/AboutPanel.tsx +1 -1
  60. package/src/client/about/ReleaseBody.tsx +22 -52
  61. package/src/client/about/ReleaseNotesDialog.tsx +15 -69
  62. package/src/client/about/release-notes-view.ts +4 -11
  63. package/src/client/common/info-hint-guard.test.ts +11 -5
  64. package/src/client/common/ui.tsx +23 -0
  65. package/src/client/config-manager.module.css +201 -32
  66. package/src/client/css-token-guard.test.ts +135 -1
  67. package/src/client/history/history-locales.ts +2 -0
  68. package/src/client/home/HomePanel.tsx +9 -3
  69. package/src/client/import/ConflictList.tsx +3 -3
  70. package/src/client/import/ImportWizardView.tsx +1 -1
  71. package/src/client/library/ArtifactRow.tsx +2 -2
  72. package/src/client/library/RestorePlanView.tsx +21 -9
  73. package/src/client/library/report-dismiss.test.ts +5 -3
  74. package/src/client/locales/about.ts +97 -0
  75. package/src/client/locales/backup.ts +141 -0
  76. package/src/client/locales/common.ts +113 -0
  77. package/src/client/locales/export.ts +184 -0
  78. package/src/client/locales/foreign.ts +184 -0
  79. package/src/client/locales/import-compat.ts +32 -0
  80. package/src/client/locales/import.ts +192 -0
  81. package/src/client/locales/next-steps.ts +25 -0
  82. package/src/client/locales/overview-control.ts +32 -0
  83. package/src/client/locales/overview.ts +145 -0
  84. package/src/client/locales/profiles.ts +263 -0
  85. package/src/client/locales/report.ts +17 -0
  86. package/src/client/locales/restore.ts +132 -0
  87. package/src/client/locales/sessions.ts +257 -0
  88. package/src/client/locales/shell.ts +149 -0
  89. package/src/client/locales.ts +49 -1781
  90. package/src/client/market/MarketImportReview.tsx +2 -2
  91. package/src/client/market/MarketPanel.tsx +1 -1
  92. package/src/client/market/market-view.ts +3 -5
  93. package/src/client/recovery/RecoveryPanel.tsx +62 -1054
  94. package/src/client/recovery/SessionHealthCard.tsx +134 -0
  95. package/src/client/recovery/SessionHealthDialog.tsx +665 -0
  96. package/src/client/recovery/SessionLayoutSection.tsx +284 -0
  97. package/src/client/recovery/recovery-api.ts +10 -1
  98. package/src/client/recovery/recovery-panel-layout.test.ts +20 -5
  99. package/src/client/recovery/session-dialog-mount.test.ts +16 -9
  100. package/src/client/recovery/use-recovery-write.test.ts +90 -0
  101. package/src/client/recovery/use-recovery-write.ts +53 -0
  102. package/src/client/run-store.ts +57 -2
  103. package/src/client/sync/PushPreviewCard.tsx +2 -2
  104. package/src/client/sync/SyncConfirmView.tsx +5 -5
  105. package/src/client/sync/SyncLogList.tsx +2 -2
  106. package/src/client/sync/history-model.ts +7 -5
  107. package/src/client/sync/sync-locales.ts +2 -0
  108. package/src/client/sync/sync-view.ts +3 -4
  109. package/src/core/exporter.ts +2 -4
  110. package/src/core/host-schedulers/cache-cleanup.test.ts +84 -0
  111. package/src/core/host-schedulers/cache-cleanup.ts +74 -0
  112. package/src/core/host-schedulers/lifecycle-hooks.test.ts +111 -0
  113. package/src/core/host-schedulers/lifecycle-hooks.ts +118 -0
  114. package/src/core/host-schedulers/market-cache.test.ts +93 -0
  115. package/src/core/host-schedulers/market-cache.ts +116 -0
  116. package/src/core/messages-core.ts +2 -0
  117. package/src/core/migration-history.test.ts +19 -0
  118. package/src/core/migration-history.ts +28 -5
  119. package/src/core/model-tools.ts +2 -7
  120. package/src/core/restore-failure-state.test.ts +210 -0
  121. package/src/core/restore.ts +16 -18
  122. package/src/core/verify-recovery.ts +4 -7
  123. package/src/index.ts +78 -332
  124. package/src/profiles/dsh-profile-copy-rollback.test.ts +156 -0
  125. package/src/profiles/dsh-profile-manager.ts +71 -3
  126. package/src/routes/kit.ts +37 -0
  127. package/src/routes/prefs.ts +6 -6
  128. package/src/routes/recovery.ts +25 -42
  129. package/src/routes/route-support.ts +208 -1
  130. package/src/routes/snapshots.ts +4 -9
  131. package/src/routes/sync.ts +4 -7
  132. package/src/security/redaction.ts +29 -23
  133. package/src/sync/autosync-scheduler.test.ts +23 -0
  134. package/src/sync/autosync-scheduler.ts +6 -2
  135. package/src/sync/backup-scheduler.ts +3 -6
  136. package/src/sync/baseline-heal.ts +74 -0
  137. package/src/sync/push-precheck.ts +75 -0
  138. package/src/sync/sync-config.test.ts +24 -13
  139. package/src/sync/sync-engine.test.ts +88 -0
  140. package/src/sync/sync-engine.ts +33 -43
  141. package/src/ui/backup-inspect.ts +1 -1
  142. package/src/ui/dsh-profiles-view.ts +3 -5
  143. package/src/ui/history-model.test.ts +2 -1
  144. package/src/ui/history-model.ts +3 -2
  145. package/src/ui/i18n.test.ts +8 -3
  146. package/src/ui/overview-view.test.ts +12 -0
  147. package/src/ui/overview-view.ts +12 -4
  148. package/src/ui/snapshots-view.ts +2 -2
  149. package/src/utils/paths.test.ts +36 -1
  150. package/src/utils/paths.ts +30 -6
  151. package/src/utils/time.test.ts +46 -0
  152. package/src/utils/time.ts +55 -0
@@ -8,11 +8,27 @@ export declare function isAbsolutePath(p: string): boolean;
8
8
  /** ZIP 条目名安全检查(Zip Slip / 绝对路径 / 盘符 / NUL,规范 §19.1-2)。
9
9
  * 规则与 node:path 解耦:纯分段校验,跨平台无歧义。 */
10
10
  export declare function isPathSafe(entryName: string): boolean;
11
- /** 候选目录是否位于父目录之内(含等于父目录)。
11
+ /** 越界判定选项。 */
12
+ export interface PathInsideOptions {
13
+ /**
14
+ * 比较前折叠大小写(Windows 文件系统大小写不敏感)。缺省按当前平台。
15
+ * 显式传 false 的场景:拿另一台机器的路径做形状判定(跨平台导入)。
16
+ */
17
+ foldCase?: boolean;
18
+ }
19
+ /** 候选路径是否位于父目录之内(含等于父目录)。
12
20
  *
13
- * 纯字符串语义(不碰文件系统):两侧必须是**同一种拼写**,调用方若混用
14
- * realpath 结果与原路径(Windows 8.3 短名、macOS `/var`→`/private/var`)会误判为越界 ——
15
- * `path.relative` 不会折叠短名,务必先各自 realpath 再调用。 */
21
+ * 全仓**唯一**的越界判定(restore / verify-recovery / zip / recursive-walk / 路由都走这里):
22
+ * 早期四处各写一份,其中三份用 `rel.startsWith('..')` 判越界 —— 名字真的叫 `..foo` 的
23
+ * 兄弟目录会被误判为逃逸(`path.relative('/a/b','/a/b/..foo') === '..foo'`)。
24
+ * 越界只有两种形态:相对结果是 `..` 段本身,或以 `..` + 分隔符开头;绝对结果(跨盘符)同样越界。
25
+ *
26
+ * 纯字符串语义(**不碰文件系统**):两侧各自 `path.resolve` 后比较。调用方若混用
27
+ * realpath 结果与原路径(Windows 8.3 短名、macOS `/var`→`/private/var`)仍会误判为越界 ——
28
+ * `path.resolve` 不折叠短名,真实路径那一层必须两侧都先 realpath 再调用。
29
+ */
30
+ export declare function isPathInside(child: string, parent: string, options?: PathInsideOptions): boolean;
31
+ /** 候选目录是否位于父目录之内(含等于父目录)—— `isPathInside` 的读法友好别名。 */
16
32
  export declare function isSameOrChild(p: string, parent: string): boolean;
17
33
  /**
18
34
  * 归一化并折叠 `.` / `..` 路径段(Reviewer B P0 修复)。
@@ -47,14 +47,30 @@ export function isPathSafe(entryName) {
47
47
  return false; // 目录穿越
48
48
  return true;
49
49
  }
50
- /** 候选目录是否位于父目录之内(含等于父目录)。
50
+ /** 候选路径是否位于父目录之内(含等于父目录)。
51
51
  *
52
- * 纯字符串语义(不碰文件系统):两侧必须是**同一种拼写**,调用方若混用
53
- * realpath 结果与原路径(Windows 8.3 短名、macOS `/var`→`/private/var`)会误判为越界 ——
54
- * `path.relative` 不会折叠短名,务必先各自 realpath 再调用。 */
52
+ * 全仓**唯一**的越界判定(restore / verify-recovery / zip / recursive-walk / 路由都走这里):
53
+ * 早期四处各写一份,其中三份用 `rel.startsWith('..')` 判越界 —— 名字真的叫 `..foo` 的
54
+ * 兄弟目录会被误判为逃逸(`path.relative('/a/b','/a/b/..foo') === '..foo'`)。
55
+ * 越界只有两种形态:相对结果是 `..` 段本身,或以 `..` + 分隔符开头;绝对结果(跨盘符)同样越界。
56
+ *
57
+ * 纯字符串语义(**不碰文件系统**):两侧各自 `path.resolve` 后比较。调用方若混用
58
+ * realpath 结果与原路径(Windows 8.3 短名、macOS `/var`→`/private/var`)仍会误判为越界 ——
59
+ * `path.resolve` 不折叠短名,真实路径那一层必须两侧都先 realpath 再调用。
60
+ */
61
+ export function isPathInside(child, parent, options = {}) {
62
+ const foldCase = options.foldCase ?? process.platform === 'win32';
63
+ const fold = (v) => (foldCase ? v.toLowerCase() : v);
64
+ const rel = path.relative(fold(path.resolve(parent)), fold(path.resolve(child)));
65
+ if (rel === '')
66
+ return true;
67
+ if (path.isAbsolute(rel))
68
+ return false; // 跨盘符(win32 relative 直接回绝对路径)
69
+ return rel !== '..' && !rel.startsWith(`..${path.sep}`);
70
+ }
71
+ /** 候选目录是否位于父目录之内(含等于父目录)—— `isPathInside` 的读法友好别名。 */
55
72
  export function isSameOrChild(p, parent) {
56
- const rel = path.relative(parent, p);
57
- return rel === '' || (!rel.startsWith('..') && !path.isAbsolute(rel));
73
+ return isPathInside(p, parent);
58
74
  }
59
75
  /**
60
76
  * 内部 control-plane namespace(F23 修复):不可信 import(pluginFiles/self/file adapters)
@@ -0,0 +1,31 @@
1
+ /**
2
+ * 时间戳格式化的唯一实现(host 与 client 共用,**零 import**)。
3
+ *
4
+ * 为什么单列一个模块:同一串 `YYYYMMDD-HHmmss` 曾在 5 处各写一遍(model-tools / backup-scheduler /
5
+ * cli·actions / cli·import-source / cli·index),`YYYY-MM-DD` 2 处,展示用的
6
+ * `YYYY-MM-DD HH:mm` 5 处(sync 历史、sync 状态、market、profiles、release notes)——
7
+ * 改一处口径(比如补毫秒、改本地时区)就得记住改十处,漏一处就是两套时间显示。
8
+ *
9
+ * 约束:**不得 import node 模块**(`src/client/**` 直接消费本模块)。
10
+ *
11
+ * 分工:本模块只负责**格式**,不负责「非法输入怎么显示」——那是各处的产品口径
12
+ * (历史表显示 `—`、profiles 显示空串、release notes 原样回显),由调用方决定;
13
+ * 这里只提供 `parseDateInput` 这一个统一的「能不能解析」判定。
14
+ */
15
+ /** 日期戳 `YYYYMMDD-HHmmss`(**本地时区**,用于导出文件名:定宽、仅 ASCII、可排序)。 */
16
+ export declare function formatDateStamp(d?: Date): string;
17
+ /** 日期 `YYYY-MM-DD`(**本地时区**,用于导出文件名 / 只显示日期的场景)。 */
18
+ export declare function formatDateOnly(d: Date): string;
19
+ /** 展示用本地时间 `YYYY-MM-DD HH:mm`(**本地时区**,精确到分钟)。 */
20
+ export declare function formatMinuteStamp(d: Date): string;
21
+ /**
22
+ * 解析时间输入(ISO 字符串或毫秒数)→ Date;不可解析给 null。
23
+ *
24
+ * 与 `new Date(x)` 的差别只有三条**判定**,解析规则本身完全继承:
25
+ * 1. `null` / `undefined` / 空串 / 纯空白 → null(否则 `new Date('')` 给 Invalid Date,
26
+ * 更糟的是 `new Date(null)` 会静默变成 1970-01-01);
27
+ * 2. `number`:`NaN` / `Infinity` / `-Infinity` → null;
28
+ * 3. 解析结果 `getTime()` 非有限 → null。
29
+ * 调用方拿 null 决定回退文案(`—` / 空串 / 原样回显),本模块不替它选。
30
+ */
31
+ export declare function parseDateInput(input: string | number | null | undefined): Date | null;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * 时间戳格式化的唯一实现(host 与 client 共用,**零 import**)。
3
+ *
4
+ * 为什么单列一个模块:同一串 `YYYYMMDD-HHmmss` 曾在 5 处各写一遍(model-tools / backup-scheduler /
5
+ * cli·actions / cli·import-source / cli·index),`YYYY-MM-DD` 2 处,展示用的
6
+ * `YYYY-MM-DD HH:mm` 5 处(sync 历史、sync 状态、market、profiles、release notes)——
7
+ * 改一处口径(比如补毫秒、改本地时区)就得记住改十处,漏一处就是两套时间显示。
8
+ *
9
+ * 约束:**不得 import node 模块**(`src/client/**` 直接消费本模块)。
10
+ *
11
+ * 分工:本模块只负责**格式**,不负责「非法输入怎么显示」——那是各处的产品口径
12
+ * (历史表显示 `—`、profiles 显示空串、release notes 原样回显),由调用方决定;
13
+ * 这里只提供 `parseDateInput` 这一个统一的「能不能解析」判定。
14
+ */
15
+ function pad2(n) {
16
+ return String(n).padStart(2, '0');
17
+ }
18
+ /** 日期戳 `YYYYMMDD-HHmmss`(**本地时区**,用于导出文件名:定宽、仅 ASCII、可排序)。 */
19
+ export function formatDateStamp(d = new Date()) {
20
+ return `${d.getFullYear()}${pad2(d.getMonth() + 1)}${pad2(d.getDate())}`
21
+ + `-${pad2(d.getHours())}${pad2(d.getMinutes())}${pad2(d.getSeconds())}`;
22
+ }
23
+ /** 日期 `YYYY-MM-DD`(**本地时区**,用于导出文件名 / 只显示日期的场景)。 */
24
+ export function formatDateOnly(d) {
25
+ return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
26
+ }
27
+ /** 展示用本地时间 `YYYY-MM-DD HH:mm`(**本地时区**,精确到分钟)。 */
28
+ export function formatMinuteStamp(d) {
29
+ return `${formatDateOnly(d)} ${pad2(d.getHours())}:${pad2(d.getMinutes())}`;
30
+ }
31
+ /**
32
+ * 解析时间输入(ISO 字符串或毫秒数)→ Date;不可解析给 null。
33
+ *
34
+ * 与 `new Date(x)` 的差别只有三条**判定**,解析规则本身完全继承:
35
+ * 1. `null` / `undefined` / 空串 / 纯空白 → null(否则 `new Date('')` 给 Invalid Date,
36
+ * 更糟的是 `new Date(null)` 会静默变成 1970-01-01);
37
+ * 2. `number`:`NaN` / `Infinity` / `-Infinity` → null;
38
+ * 3. 解析结果 `getTime()` 非有限 → null。
39
+ * 调用方拿 null 决定回退文案(`—` / 空串 / 原样回显),本模块不替它选。
40
+ */
41
+ export function parseDateInput(input) {
42
+ if (input === null || input === undefined)
43
+ return null;
44
+ if (typeof input === 'number') {
45
+ if (!Number.isFinite(input))
46
+ return null;
47
+ return new Date(input);
48
+ }
49
+ if (input.trim() === '')
50
+ return null;
51
+ const d = new Date(input);
52
+ return Number.isFinite(d.getTime()) ? d : null;
53
+ }
54
+ //# sourceMappingURL=time.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-config-manager",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
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",
@@ -34,6 +34,7 @@ import {
34
34
  import { EnvironmentLockManager, OWNERSHIP_FILE } from '../utils/env-lock.ts'
35
35
  import { scanSessionHealth, type SessionHealthScanResult } from '../utils/session-health-scan.ts'
36
36
  import type { SessionVerifyResult } from '../utils/session-verify.ts'
37
+ import { formatDateStamp } from '../utils/time.ts'
37
38
 
38
39
  /* ------------------------------------------------------------ 进程/实例事实 */
39
40
 
@@ -1352,9 +1353,7 @@ export async function exportOfflineBackup(
1352
1353
  if (collection.entries.length === 0) {
1353
1354
  return { ok: false, code: 'nothing-to-export', message: '没有可打包的内容(该 home 下未找到可离线收集的分区)。' }
1354
1355
  }
1355
- const now = new Date()
1356
- const stamp = String(now.getFullYear()) + String(now.getMonth() + 1).padStart(2, '0') + String(now.getDate()).padStart(2, '0')
1357
- + '-' + String(now.getHours()).padStart(2, '0') + String(now.getMinutes()).padStart(2, '0') + String(now.getSeconds()).padStart(2, '0')
1356
+ const stamp = formatDateStamp()
1358
1357
  const { randomBytes } = await import('node:crypto')
1359
1358
  const desired = 'dsh-config-cli-' + stamp + '-' + randomBytes(4).toString('hex') + '.zip'
1360
1359
  await fsp.mkdir(paths.exportsDir, { recursive: true })
@@ -29,6 +29,7 @@ import { foreignSourceContext } from '../routes/foreign-context.ts';
29
29
  import type { ForeignSourceContext, ForeignSourceDetection } from '../foreign/registry.ts';
30
30
  import type { ForeignImportResult } from '../foreign/types.ts';
31
31
  import type { Platform } from '../schema/types.ts';
32
+ import { formatDateStamp } from '../utils/time.ts';
32
33
 
33
34
  /** CLI 侧只依赖这个最小 IO 形状(与 src/cli/index.ts 的 CliIo 结构等价,避免循环 import) */
34
35
  export interface ImportIo {
@@ -110,7 +111,7 @@ function printImportSummary(
110
111
  async function resolveOutPath(options: ImportSourceOptions, sourceId: string): Promise<string> {
111
112
  const desired = options.out !== undefined && options.out !== ''
112
113
  ? path.resolve(options.out)
113
- : path.join(options.exportsDir, 'foreign-' + sourceId + '-' + stamp() + '-' + randomHex4() + '.zip');
114
+ : path.join(options.exportsDir, 'foreign-' + sourceId + '-' + formatDateStamp() + '-' + randomHex4() + '.zip');
114
115
  if (!(await pathExists(desired))) return desired;
115
116
  const base = desired.endsWith('.zip') ? desired.slice(0, -4) : desired;
116
117
  for (let i = 1; ; i += 1) {
@@ -119,12 +120,6 @@ async function resolveOutPath(options: ImportSourceOptions, sourceId: string): P
119
120
  }
120
121
  }
121
122
 
122
- function stamp(): string {
123
- const now = new Date();
124
- return `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}`
125
- + `-${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;
126
- }
127
-
128
123
  function randomHex4(): string {
129
124
  // 用全局 crypto(Node ≥ 19);零额外依赖
130
125
  const bytes = new Uint8Array(4);
package/src/cli/index.ts CHANGED
@@ -54,6 +54,7 @@ import { stringifyJsonSafe } from '../utils/json.ts';
54
54
  import { buildManifest, CHECKSUMS_FILE, MANIFEST_FILE } from '../schema/manifest.ts';
55
55
  import { writeZip } from '../utils/zip.ts';
56
56
  import type { Manifest, SectionId } from '../schema/types.ts';
57
+ import { formatDateStamp } from '../utils/time.ts';
57
58
 
58
59
  /* ------------------------------------------------------------ 参数解析(纯函数) */
59
60
 
@@ -1354,9 +1355,7 @@ async function runBackup(
1354
1355
  }
1355
1356
  } else {
1356
1357
  // 注意:此处刻意不 mkdir —— dry-run 必须零写入,目录在真正落盘前才创建
1357
- const now = new Date();
1358
- const stamp = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}`
1359
- + `-${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;
1358
+ const stamp = formatDateStamp();
1360
1359
  try {
1361
1360
  const rand = await randomHex4();
1362
1361
  outPath = await resolveNonCollidingName(exportsDir, `dsh-config-cli-${stamp}-${rand}.zip`);
@@ -133,7 +133,7 @@ export function AboutPanel({ api, t }: AboutPanelProps) {
133
133
  {/* issue #28 诊断位:插件清单实际读的目录 / profile / 识别到的插件数。
134
134
  用于自查「装了插件却没被备份识别到」——此前用户完全无从查看。 */}
135
135
  {state.rows?.diagnostics != null && (
136
- <div className={css.statRow} style={{ flexDirection: 'column', alignItems: 'flex-start', gap: '4px' }}>
136
+ <div className={css.statRow + ' ' + css.statRowStack}>
137
137
  <span className={css.groupLabel}>{t('about.diag.label')} <InfoHint text={t('about.diag.hint')} label={t('common.infoHint')} /></span>
138
138
  <span>{t('about.diag.profileDir', { path: state.rows.diagnostics.profileDir })}</span>
139
139
  <span>{t('about.diag.profile', { profile: state.rows.diagnostics.profile })}</span>
@@ -58,58 +58,39 @@ function renderInlineMarkdown(text: string) {
58
58
  function MarkdownBlockView({ block }: { block: MarkdownBlock }) {
59
59
  switch (block.type) {
60
60
  case 'heading': {
61
- const headingStyle = {
62
- fontWeight: 600,
63
- color: 'var(--dsw-alias-label-primary)',
64
- marginTop: block.level === 1 ? '12px' : '8px',
65
- marginBottom: '4px',
66
- fontSize: block.level === 1 ? '15px' : block.level === 2 ? '14px' : '13px',
67
- }
68
- return <div style={headingStyle}>{block.text}</div>
61
+ /**
62
+ * 只有字号还留在内联:15/14/13px 三级要靠同一规则表达,而 DESIGN.md §4 的字号 scale
63
+ * 只有 4 档(11/12/12.5/13)—— 把 15/14 写进 CSS 会让 scale-01 直接变红。
64
+ * 这是 css-token-guard 豁免表里唯一一条 release 相关例外(见 TSX_STYLE_WHITELIST)。
65
+ */
66
+ return (
67
+ <div
68
+ className={css.releaseHeading}
69
+ data-level={String(block.level)}
70
+ style={{ fontSize: block.level === 1 ? '15px' : block.level === 2 ? '14px' : '13px' }}
71
+ >
72
+ {block.text}
73
+ </div>
74
+ )
69
75
  }
70
76
  case 'list-item': {
71
77
  return (
72
- <div style={{ display: 'flex', gap: '6px', alignItems: 'flex-start', paddingLeft: '4px' }}>
73
- <span style={{ color: 'var(--dsw-alias-label-tertiary)', userSelect: 'none' }}>
78
+ <div className={css.releaseListItem}>
79
+ <span className={css.releaseBullet}>
74
80
  {block.ordered ? (block.index ?? 1) + '.' : '•'}
75
81
  </span>
76
- <div style={{ flex: 1 }}>{renderInlineMarkdown(block.text)}</div>
82
+ <div className={css.releaseItemBody}>{renderInlineMarkdown(block.text)}</div>
77
83
  </div>
78
84
  )
79
85
  }
80
86
  case 'quote': {
81
- return (
82
- <div
83
- style={{
84
- borderLeft: '3px solid var(--dsw-alias-border-l1)',
85
- paddingLeft: '8px',
86
- color: 'var(--dsw-alias-label-secondary)',
87
- fontStyle: 'italic',
88
- }}
89
- >
90
- {renderInlineMarkdown(block.text)}
91
- </div>
92
- )
87
+ return <div className={css.releaseQuote}>{renderInlineMarkdown(block.text)}</div>
93
88
  }
94
89
  case 'code-block': {
95
- return (
96
- <pre
97
- className={css.cliCommand}
98
- style={{ margin: '4px 0', padding: '8px', fontSize: '12px' }}
99
- >
100
- {block.code}
101
- </pre>
102
- )
90
+ return <pre className={css.cliCommand + ' ' + css.releaseCode}>{block.code}</pre>
103
91
  }
104
92
  case 'hr': {
105
- return (
106
- <div
107
- style={{
108
- borderBottom: '1px solid var(--dsw-alias-border-l2)',
109
- margin: '8px 0',
110
- }}
111
- />
112
- )
93
+ return <div className={css.releaseRule} />
113
94
  }
114
95
  case 'paragraph':
115
96
  default: {
@@ -122,22 +103,11 @@ function MarkdownBlockView({ block }: { block: MarkdownBlock }) {
122
103
  export function ReleaseBody({ body, t }: { body: string; t: TranslateNS<'config-manager'> }) {
123
104
  const blocks = parseMarkdownBlocks(body)
124
105
  return (
125
- <div
126
- style={{
127
- display: 'flex',
128
- flexDirection: 'column',
129
- gap: '6px',
130
- fontSize: '13px',
131
- lineHeight: '1.6',
132
- color: 'var(--dsw-alias-label-primary)',
133
- }}
134
- >
106
+ <div className={css.releaseBody}>
135
107
  {blocks.length > 0 ? (
136
108
  blocks.map((block, idx) => <MarkdownBlockView key={idx} block={block} />)
137
109
  ) : (
138
- <div style={{ color: 'var(--dsw-alias-label-tertiary)', fontStyle: 'italic' }}>
139
- {t('about.releaseNotes.noBody')}
140
- </div>
110
+ <div className={css.releaseEmpty}>{t('about.releaseNotes.noBody')}</div>
141
111
  )}
142
112
  </div>
143
113
  )
@@ -48,37 +48,11 @@ function ReleaseCardView({
48
48
  t: TranslateNS<'config-manager'>
49
49
  }) {
50
50
  return (
51
- <div
52
- style={{
53
- display: 'flex',
54
- flexDirection: 'column',
55
- gap: '8px',
56
- padding: '12px',
57
- background: 'var(--dsw-alias-bg-base)',
58
- border: '1px solid var(--dsw-alias-border-l1)',
59
- borderRadius: '8px',
60
- }}
61
- >
51
+ <div className={css.releaseCard}>
62
52
  {/* 头部:版本号 + 标题 + 徽章 + 日期 + 外链 */}
63
- <div
64
- style={{
65
- display: 'flex',
66
- justifyContent: 'space-between',
67
- alignItems: 'flex-start',
68
- gap: '8px',
69
- flexWrap: 'wrap',
70
- }}
71
- >
72
- <div style={{ display: 'flex', alignItems: 'center', gap: '8px', flexWrap: 'wrap' }}>
73
- <span
74
- style={{
75
- fontSize: '14px',
76
- fontWeight: 600,
77
- color: 'var(--dsw-alias-label-primary)',
78
- }}
79
- >
80
- {release.title}
81
- </span>
53
+ <div className={css.releaseCardHead}>
54
+ <div className={css.releaseTitleRow}>
55
+ <span className={css.releaseTitle}>{release.title}</span>
82
56
  {isFirst && !release.isPrerelease && (
83
57
  <Badge kind="ok">{t('about.releaseNotes.latest')}</Badge>
84
58
  )}
@@ -86,14 +60,7 @@ function ReleaseCardView({
86
60
  <Badge kind="warn">{t('about.releaseNotes.prerelease')}</Badge>
87
61
  )}
88
62
  {release.publishedDateStr && (
89
- <span
90
- style={{
91
- fontSize: '12px',
92
- color: 'var(--dsw-alias-label-tertiary)',
93
- }}
94
- >
95
- {release.publishedDateStr}
96
- </span>
63
+ <span className={css.releaseDate}>{release.publishedDateStr}</span>
97
64
  )}
98
65
  </div>
99
66
 
@@ -235,7 +202,10 @@ export function ReleaseNotesDialog({
235
202
  scroll
236
203
  innerRef={bodyRef}
237
204
  onScroll={handleScroll}
238
- style={{ maxHeight: '65vh', gap: '12px' }}
205
+ /* maxHeight 走内联:Modal.Body 只暴露 style(common/Modal.tsx 不在本次改动范围),
206
+ 而 65vh 是「让无限滚动有界」的布局值,不属 DESIGN.md 的节奏 scale。
207
+ 原 gap: '12px' 一并去掉 —— .dialogBody 不是 flex/grid 容器,gap 从来没有生效过。 */
208
+ style={{ maxHeight: '65vh' }}
239
209
  >
240
210
  {loading && (
241
211
  <div>
@@ -248,7 +218,7 @@ export function ReleaseNotesDialog({
248
218
  <div>
249
219
  {/* G-04:release notes 的错误文本来自 GitHub 状态/网络响应 —— 展示前统一过 redact */}
250
220
  <Banner kind="error">{redact(error)}</Banner>
251
- <div className={css.actionRow} style={{ marginTop: '8px' }}>
221
+ <div className={css.actionRow + ' ' + css.actionRowSpaced}>
252
222
  <Button onClick={() => { void loadFirstPage() }}>
253
223
  {t('about.releaseNotes.retry')}
254
224
  </Button>
@@ -260,9 +230,7 @@ export function ReleaseNotesDialog({
260
230
  )}
261
231
 
262
232
  {!loading && error === null && releases.length === 0 && (
263
- <div style={{ padding: '20px 0', textAlign: 'center', color: 'var(--dsw-alias-label-secondary)' }}>
264
- {t('about.releaseNotes.empty')}
265
- </div>
233
+ <div className={css.releaseNotesEmpty}>{t('about.releaseNotes.empty')}</div>
266
234
  )}
267
235
 
268
236
  {!loading &&
@@ -276,42 +244,20 @@ export function ReleaseNotesDialog({
276
244
  ))}
277
245
 
278
246
  {loadingMore && (
279
- <div style={{ padding: '12px 0', display: 'flex', justifyContent: 'center' }}>
247
+ <div className={css.releaseNotesLoadingMore}>
280
248
  <Spinner label={t('about.releaseNotes.loadingMore')} />
281
249
  </div>
282
250
  )}
283
251
 
284
252
  {!loading && !loadingMore && !hasMore && releases.length > 0 && (
285
- <div
286
- style={{
287
- textAlign: 'center',
288
- padding: '8px 0',
289
- fontSize: '12px',
290
- color: 'var(--dsw-alias-label-tertiary)',
291
- }}
292
- >
293
- {t('about.releaseNotes.allLoaded')}
294
- </div>
253
+ <div className={css.releaseNotesAllLoaded}>{t('about.releaseNotes.allLoaded')}</div>
295
254
  )}
296
255
  </Modal.Body>
297
256
 
298
257
  {/* 底部按钮区 */}
299
- <div
300
- className={css.actionRow}
301
- style={{
302
- justifyContent: 'space-between',
303
- alignItems: 'center',
304
- borderTop: '1px solid var(--dsw-alias-border-l1)',
305
- paddingTop: '10px',
306
- paddingBottom: '14px',
307
- paddingLeft: '16px',
308
- paddingRight: '16px',
309
- flexWrap: 'wrap',
310
- gap: '8px',
311
- }}
312
- >
258
+ <div className={css.actionRow + ' ' + css.releaseNotesFoot}>
313
259
  <Button href={releasesPageUrl}>{t('about.releaseNotes.viewOnGithub')}</Button>
314
- <div style={{ display: 'flex', gap: '8px', alignItems: 'center' }}>
260
+ <div className={css.releaseNotesFootActions}>
315
261
  <Button onClick={handleNeverShow}>
316
262
  {t('about.releaseNotes.neverShow')}
317
263
  </Button>
@@ -9,6 +9,7 @@
9
9
  * - 轻量级安全 Markdown 分块解析器(纯文本结构化,零 dangerouslySetInnerHTML / 零 XSS 风险)
10
10
  */
11
11
  import type { TranslateNS } from '../client-types.ts';
12
+ import { formatDateOnly, parseDateInput } from '../../utils/time.ts';
12
13
 
13
14
  export interface GitHubReleaseRaw {
14
15
  id?: number;
@@ -76,20 +77,12 @@ export function deriveReleasesUrl(repoUrl: string): string {
76
77
  }
77
78
 
78
79
  /**
79
- * 格式化 ISO 日期为可读字符串(YYYY-MM-DD)。
80
+ * 格式化 ISO 日期为可读字符串(YYYY-MM-DD);缺失 = 空串、非法输入原样回显。
80
81
  */
81
82
  export function formatReleaseDate(isoDate: string | null | undefined): string {
82
83
  if (!isoDate || typeof isoDate !== 'string') return '';
83
- try {
84
- const d = new Date(isoDate);
85
- if (isNaN(d.getTime())) return isoDate;
86
- const y = d.getFullYear();
87
- const m = String(d.getMonth() + 1).padStart(2, '0');
88
- const day = String(d.getDate()).padStart(2, '0');
89
- return `${y}-${m}-${day}`;
90
- } catch {
91
- return isoDate;
92
- }
84
+ const d = parseDateInput(isoDate);
85
+ return d === null ? isoDate : formatDateOnly(d);
93
86
  }
94
87
 
95
88
  /**
@@ -139,7 +139,7 @@ const MOVE_PINS: readonly MovePin[] = [
139
139
  { key: 'profiles.create.hint', file: 'src/client/environment/EnvironmentPanel.tsx', kind: '机制' },
140
140
  { key: 'profiles.list.hint', file: 'src/client/environment/EnvironmentPanel.tsx', kind: '省事提示' },
141
141
  // t5:recovery/
142
- { key: 'sessions.desc', file: 'src/client/recovery/RecoveryPanel.tsx', kind: '机制' },
142
+ { key: 'sessions.desc', file: 'src/client/recovery/SessionHealthCard.tsx', kind: '机制' },
143
143
  { key: 'recovery.preview.hint', file: 'src/client/recovery/RecoveryPanel.tsx', kind: '机制' },
144
144
  // t7(2026-10-12 用户要求「所有描述都收进 ⓘ」):页级 / 分区级副标题 + 卡片 / 字段说明。
145
145
  // 判定口径见 DESIGN.md §7(本次把原 KEEP-2 的**静态安全说明**与 KEEP-7 的**静态副标题**一并纳入 MOVE;
@@ -171,9 +171,9 @@ const MOVE_PINS: readonly MovePin[] = [
171
171
  { key: 'snapshots.selectHint', file: 'src/client/library/LibraryActions.tsx', kind: '省事提示' },
172
172
  { key: 'diskUsage.clean.hint', file: 'src/client/environment/maintenance/DiskUsageCard.tsx', kind: '边界' },
173
173
  { key: 'recovery.safeMode.detail', file: 'src/client/recovery/RecoveryPanel.tsx', kind: '机制' },
174
- { key: 'sessions.repair.desc', file: 'src/client/recovery/RecoveryPanel.tsx', kind: '机制' },
174
+ { key: 'sessions.repair.desc', file: 'src/client/recovery/SessionHealthDialog.tsx', kind: '机制' },
175
175
  { key: 'recovery.rescue.desc', file: 'src/client/recovery/RecoveryPanel.tsx', kind: '机制' },
176
- { key: 'sessions.layout.planReadOnly', file: 'src/client/recovery/RecoveryPanel.tsx', kind: '边界' },
176
+ { key: 'sessions.layout.planReadOnly', file: 'src/client/recovery/SessionLayoutSection.tsx', kind: '边界' },
177
177
  { key: 'recovery.incomplete.hint', file: 'src/client/recovery/IncompleteCopiesSection.tsx', kind: '机制' },
178
178
  { key: 'repoPicker.privateOnly', file: 'src/client/sync/SyncRepositoryPicker.tsx', kind: '输入规则' },
179
179
  { key: 'config.tokenHint', file: 'src/client/sync/ChannelConfigDialog.tsx', kind: '输入规则' },
@@ -250,9 +250,15 @@ const HINT_CALL_RE = /<InfoHint\b[\s\S]*?\/>/g;
250
250
  const CANON_ZH = '查看说明';
251
251
  const CANON_EN = 'Show description';
252
252
 
253
- /** 必须带该键的命名空间字典(出现 ⓘ 调用点的命名空间;history 零 MOVE,不参与)。 */
253
+ /**
254
+ * 必须带该键的命名空间字典(出现 ⓘ 调用点的命名空间;history 零 MOVE,不参与)。
255
+ *
256
+ * tech-debt #22(2026-11 字典按域拆分):`common.infoHint` 在原文里物理位于「会话归位」段
257
+ * (HEAD:src/client/locales.ts:715),拆完落在 `src/client/locales/sessions.ts`;聚合器
258
+ * `src/client/locales.ts` 只剩展开语句,不再含任何键字面量。
259
+ */
254
260
  const INFO_HINT_DICTS: readonly string[] = [
255
- 'src/client/locales.ts',
261
+ 'src/client/locales/sessions.ts',
256
262
  'src/client/market/market-locales.ts',
257
263
  'src/client/sync/sync-locales.ts',
258
264
  'src/client/recovery/recovery-locales.ts',
@@ -216,6 +216,29 @@ export function Badge({ kind = 'info', children, title }: BadgeProps) {
216
216
  return <span className={css.badge} data-kind={kind} title={title}>{children}</span>
217
217
  }
218
218
 
219
+ /* ---------------- Chip ---------------- */
220
+
221
+ export interface ChipProps {
222
+ children: ReactNode
223
+ /** 悬停提示(可选) */
224
+ title?: string
225
+ }
226
+
227
+ /**
228
+ * 中性分类片:**没有状态语义**的短标签(来源 / 形态 / 适配器 / 分区数)。
229
+ *
230
+ * 为什么不复用 `<Badge>`:Badge 的 kind 是四态**语义**(info/ok/warn/error),
231
+ * 传一个「中性」进去会逼着 `src/ui/badge-tone.ts` 再造第五档,四态表立刻失去
232
+ * 「一档一义」的约束;而这里要表达的是「分类,不分轻重」。所以拆成独立组件:
233
+ * - Badge = 状态(颜色编码,四态唯一来源)
234
+ * - Chip = 分类(中性灰底,与 Badge 同盒模型基线)
235
+ * 盒模型由 `.chip` 与 `.badge` 逐字对齐保证(同高 19px / 同药丸圆角 / 同 11px 字号),
236
+ * 差别只在色调 —— 同屏混排时它们读起来是「同一套小片子的两种用法」。
237
+ */
238
+ export function Chip({ children, title }: ChipProps) {
239
+ return <span className={css.chip} title={title}>{children}</span>
240
+ }
241
+
219
242
  /* ---------------- Banner ---------------- */
220
243
 
221
244
  export type BannerKind = 'ok' | 'error' | 'info' | 'warn'