dsh-config-manager 0.1.86 → 0.2.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 (61) hide show
  1. package/lib/cli/web/page.js +2 -2
  2. package/lib/client.d.ts +86 -1
  3. package/lib/client.js +2371 -778
  4. package/lib/core/native-path-picker.d.ts +49 -0
  5. package/lib/core/native-path-picker.js +475 -0
  6. package/lib/core/path-browse.d.ts +42 -0
  7. package/lib/core/path-browse.js +134 -0
  8. package/lib/foreign/claude-sessions.d.ts +1 -1
  9. package/lib/foreign/claude-sessions.js +1 -1
  10. package/lib/index.d.ts +2 -2
  11. package/lib/index.js +3 -3
  12. package/lib/market/security.js +1 -1
  13. package/lib/market/types.d.ts +1 -1
  14. package/lib/market/types.js +1 -1
  15. package/lib/routes/index.d.ts +1 -1
  16. package/lib/routes/index.js +2 -0
  17. package/lib/routes/kit.d.ts +2 -2
  18. package/lib/routes/path-browse.d.ts +3 -0
  19. package/lib/routes/path-browse.js +63 -0
  20. package/lib/security/secret-scanner.js +1 -1
  21. package/lib/ui/sync-settings-view.d.ts +18 -0
  22. package/lib/ui/sync-settings-view.js +20 -0
  23. package/package.json +2 -2
  24. package/src/cli/web/page.ts +2 -2
  25. package/src/client/ConfigManagerSection.tsx +20 -17
  26. package/src/client/api.ts +60 -1
  27. package/src/client/bundle-selfcontained.test.ts +9 -0
  28. package/src/client/chat/chat-entry-view.test.ts +1 -1
  29. package/src/client/chat/rollback-entry-view.test.ts +14 -0
  30. package/src/client/chat/rollback-entry-view.ts +2 -1
  31. package/src/client/common/CopyButton.tsx +21 -2
  32. package/src/client/common/Icon.tsx +7 -0
  33. package/src/client/common/routes.ts +5 -0
  34. package/src/client/config-manager.module.css +70 -0
  35. package/src/client/import/ImportWizardView.tsx +1 -0
  36. package/src/client/import/PathMappingForm.tsx +62 -8
  37. package/src/client/import/PathPickerDialog.tsx +172 -0
  38. package/src/client/import/dsh-directory-pick.test.ts +55 -0
  39. package/src/client/import/dsh-directory-pick.ts +55 -0
  40. package/src/client/import/import-wizard-steps.tsx +5 -2
  41. package/src/client/index.ts +12 -1
  42. package/src/client/locales.ts +25 -0
  43. package/src/client/lucide-icons.d.ts +2 -0
  44. package/src/client/sync/SyncPanel.tsx +4 -4
  45. package/src/client/sync/sync-view.ts +1 -1
  46. package/src/core/native-path-picker.test.ts +118 -0
  47. package/src/core/native-path-picker.ts +517 -0
  48. package/src/core/path-browse.test.ts +88 -0
  49. package/src/core/path-browse.ts +166 -0
  50. package/src/foreign/claude-sessions.ts +3 -3
  51. package/src/index.ts +3 -3
  52. package/src/market/security.ts +1 -1
  53. package/src/market/types.ts +1 -1
  54. package/src/routes/index.ts +3 -1
  55. package/src/routes/kit.ts +2 -2
  56. package/src/routes/path-browse.ts +70 -0
  57. package/src/security/secret-scanner.test.ts +1 -1
  58. package/src/security/secret-scanner.ts +1 -1
  59. package/src/ui/session-issue-labels.ts +1 -1
  60. package/src/ui/sync-settings-view.test.ts +18 -1
  61. package/src/ui/sync-settings-view.ts +21 -0
@@ -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/design/2026-10-04-cli-rescue-console-carbon.md —— 改 STYLE 前先读它,改完跑 web.test.ts 的 R3-02。
8
+ * docs/components/cli-rescue-console.md —— 改 STYLE 前先读它,改完跑 web.test.ts 的 R3-02。
9
9
  *
10
10
  * 呈现纪律:每个数字都要能回答「你怎么知道的」—— 离线拿不到的(结构化分区/凭据/同步令牌)
11
11
  * 一律显式列出并说明原因,绝不显示为 0 或留空。
@@ -17,7 +17,7 @@ import { redact } from '../../security/redaction.js';
17
17
  import { CONSOLE_SCRIPT } from './client-script.js';
18
18
  const STYLE = [
19
19
  // ---- 设计 token:IBM Carbon(亮色语义四色)+ Raycast(暗色 surface 阶梯)----
20
- // 映射表、取的章节与全部偏离记录:docs/design/2026-10-04-cli-rescue-console-carbon.md
20
+ // 映射表、取的章节与全部偏离记录:docs/components/cli-rescue-console.md
21
21
  // 文字色一律取「能读」的那一档:Carbon 的 #24a148 / #f1c21b 只做填充,正文用 #198038 / #8e6a00
22
22
  // (AA 对比度由 web.test.ts 的 R3-02 逐对钉住,改色先过那条测试)。
23
23
  ':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)}',
package/lib/client.d.ts CHANGED
@@ -2367,6 +2367,39 @@ interface ForeignSourcesResponse$1 {
2367
2367
  projectScoped?: boolean;
2368
2368
  sources: readonly ForeignSourceStatusInput[];
2369
2369
  }
2370
+ /** 列举失败的原因码(客户端按它选字典键)。 */
2371
+ type BrowseErrorCode = 'not-found' | 'denied' | 'failed' | 'not-absolute';
2372
+ /** 一条条目:目录(可进入)或文件(可选中)。 */
2373
+ interface BrowseEntry {
2374
+ /** 末段名字(驱动器根即盘符本身,如 `D:\\`)。 */
2375
+ name: string;
2376
+ /** 绝对路径(客户端原样回填输入框)。 */
2377
+ path: string;
2378
+ kind: 'dir' | 'file';
2379
+ }
2380
+ /** 列举结果。 */
2381
+ interface BrowseResult {
2382
+ /** 当前列出的目录;空串 = 「此电脑」(Windows 的盘符根列表)。 */
2383
+ path: string;
2384
+ /** 上一级;已是根时为 null。 */
2385
+ parent: string | null;
2386
+ /** 用户主目录(界面上的快捷入口;不随 path 变化)。 */
2387
+ home: string;
2388
+ entries: BrowseEntry[];
2389
+ /** 命中 {@link BROWSE_ENTRY_LIMIT} 被截断。 */
2390
+ truncated: boolean;
2391
+ /** 失败原因码;成功为 null。 */
2392
+ error: BrowseErrorCode | null;
2393
+ }
2394
+ type NativePickReason = 'canceled' | 'unsupported' | 'failed';
2395
+ type NativePickResult = {
2396
+ ok: true;
2397
+ path: string;
2398
+ } | {
2399
+ ok: false;
2400
+ reason: NativePickReason;
2401
+ detail?: string;
2402
+ };
2370
2403
  /** 超时文案键(全部已存在于 ui/i18n.ts;本模块只做选键,不新增文案口径)。 */
2371
2404
  type TimeoutMessageKey = 'error.requestTimeout' | 'error.fallback' | 'error.exportTimeout' | 'error.syncTimeout' | 'error.recoveryTimeout';
2372
2405
  /** 请求选项:超时档位、超时文案键、调用方取消信号。 */
@@ -2570,6 +2603,19 @@ interface DownloadResult {
2570
2603
  interface DownloadOptions {
2571
2604
  saveDialog?: boolean;
2572
2605
  }
2606
+ /**
2607
+ * DSH 宿主自带目录选择器的结果。
2608
+ * - `ok`:用户选中(`path` 非空);
2609
+ * - `canceled`:用户点了取消,调用方静默收手;
2610
+ * - `unavailable`:宿主没有这个能力(非桌面宿主 / 版本较旧 / 调用抛错),调用方回落下一层。
2611
+ */
2612
+ type DshPickResult = {
2613
+ ok: true;
2614
+ path: string;
2615
+ } | {
2616
+ ok: false;
2617
+ reason: 'canceled' | 'unavailable';
2618
+ };
2573
2619
  /**
2574
2620
  * Config Manager 浏览器半的唯一数据入口。
2575
2621
  * 同时实现 `ExportPort`(export-flow 用)与 `ImportPort`(import-wizard 用)。
@@ -2583,7 +2629,13 @@ declare class ConfigManagerApi {
2583
2629
  exportPassword: string | null;
2584
2630
  /** 客户端展示层翻译器(zh 源 / en 镜像,见 ui/i18n.ts)。 */
2585
2631
  readonly t: UiT;
2586
- constructor(t: UiT);
2632
+ /**
2633
+ * DSH 自带目录选择器(桌面壳全局 `__DSH_DIRECTORY_PICKER__.pick` 或客户端服务 `ctx.get('uiWorkspace').pickDirectory`),
2634
+ * 由 `apply(ctx)` 注入的**惰取** thunk(解析顺序见 `import/dsh-directory-pick.ts`)。
2635
+ * 宿主没提供该能力时保持 `undefined`。
2636
+ */
2637
+ private readonly dshDirectoryPicker;
2638
+ constructor(t: UiT, dshDirectoryPicker?: () => Promise<string | null>);
2587
2639
  /** 健康/版本检查(主页横幅:插件版本 / DSH 版本 / 平台) */
2588
2640
  status(): Promise<ServiceStatus>;
2589
2641
  /** Star 引导弹窗状态(进入页面时判定是否展示 / 是否补记首次使用时间)。 */
@@ -2639,6 +2691,27 @@ declare class ConfigManagerApi {
2639
2691
  decryptPassword?: string;
2640
2692
  sessionFormatDisposition?: SessionFormatDisposition;
2641
2693
  }): Promise<ImportPlan>;
2694
+ /**
2695
+ * 列出一层本机目录(只读;路径映射「选本机路径」弹窗的数据源)。
2696
+ * `target` 缺省或空串 = 「此电脑」根列表(Windows 盘符 / POSIX `/`)。
2697
+ * 失败不抛异常:宿主回 `error: 'not-found'|'denied'|'failed'|'not-absolute'`,弹窗照常可用。
2698
+ */
2699
+ browsePath(target?: string): Promise<BrowseResult>;
2700
+ /**
2701
+ * 弹**系统原生**目录选择器(同一端点的 POST 形态)。
2702
+ *
2703
+ * 用户可能在系统对话框里逛几分钟,所以超时必须远大于常规请求:内核侧 10 分钟兜底,这里再加一道。
2704
+ * 回 `reason: 'unsupported' | 'failed'` 时调用方回落到内置目录浏览器,不当错误处理。
2705
+ */
2706
+ pickNativePath(startPath?: string, title?: string): Promise<NativePickResult>;
2707
+ /**
2708
+ * 复用 **DSH 宿主自带**的原生目录选择器(就是「选择工作区目录」那个窗口)。
2709
+ *
2710
+ * 比插件自己起系统对话框更稳:窗口由 DSH 主进程弹,跟着宿主走,不受插件宿主的进程形态限制。
2711
+ * 完全不设客户端超时 —— 用户可能在原生窗口里逛几分钟,宿主侧 `host.pickDirectory` 也是 caller-signal-only。
2712
+ * 宿主没有该能力或调用抛错一律归成 `unavailable`,由调用方回落插件自己的原生对话框,不当错误处理。
2713
+ */
2714
+ pickDshPath(): Promise<DshPickResult>;
2642
2715
  /** ImportPort.decryptArchive:解锁整体加密备份容器 → 明文 ZIP 路径 + 解密覆盖的凭据 ref 名 */
2643
2716
  decryptArchive(zipPath: string, password: string): Promise<DecryptArchiveResponse>;
2644
2717
  /** ImportPort.executeImportPlan:快照→分阶段 apply→validate→commit/rollback */
@@ -5154,6 +5227,18 @@ declare const zh$4: {
5154
5227
  readonly 'import.paths.kind.homeMismatch': '基础路径不同';
5155
5228
  readonly 'import.paths.unresolved': '还有 {count} 条路径未映射(留空将跳过该路径,可以继续)';
5156
5229
  readonly 'import.paths.empty': '无需映射路径';
5230
+ readonly 'import.paths.browse': '选择本机路径';
5231
+ readonly 'import.paths.picker.title': '选择本机路径';
5232
+ readonly 'import.paths.picker.up': '上一层';
5233
+ readonly 'import.paths.picker.home': '主目录';
5234
+ readonly 'import.paths.picker.thisPc': '此电脑';
5235
+ readonly 'import.paths.picker.useCurrent': '使用当前目录';
5236
+ readonly 'import.paths.picker.empty': '这个目录里没有可进入的项';
5237
+ readonly 'import.paths.picker.truncated': '只显示前 {count} 项';
5238
+ readonly 'import.paths.picker.notFound': '这个路径不存在(已为你打开上一级)';
5239
+ readonly 'import.paths.picker.denied': '没有读取这个目录的权限';
5240
+ readonly 'import.paths.picker.notAbsolute': '请填绝对路径(如 D:\\ 或 /)';
5241
+ readonly 'import.paths.picker.failed': '读取这个目录失败';
5157
5242
  readonly 'home.schedule.title': '定时备份';
5158
5243
  readonly 'snapshots.selectHint': '选择快照以预览恢复计划(只读预览,不会改动任何设置):';
5159
5244
  readonly 'snapshots.status': '状态';