import { importDsh, type ImportTarget } from "../../import/dsh-import.js"; interface ImportOpts { from: string; to: string; out?: string; withAttachments?: boolean; } export async function importData(opts: ImportOpts): Promise { if (opts.from !== "dsh") { console.log(`暂不支持从 "${opts.from}" 导入。当前支持:dsh`); return; } const valid: ImportTarget[] = ["codex", "claude", "zcode", "workbuddy", "mimo"]; if (!valid.includes(opts.to as ImportTarget)) { console.log(`不支持的目标 "${opts.to}"。可选:${valid.join(", ")}`); return; } console.log(`正在把 DSH 全部资料导入 ${opts.to}(人物设定 + 文件资料 + 对话记录)...\n`); const r = importDsh({ target: opts.to as ImportTarget, dataDir: opts.out, withAttachments: opts.withAttachments === true, }); console.log(` ✅ 数据目录:${r.dataDir}`); console.log(` ✅ 全局指令:${r.instructionsFile}(已写入导入段落,幂等)`); if (r.skillFile) console.log(` ✅ Skill:${r.skillFile}`); console.log(`\n 人设 ${r.personas} 个 · 模型配置已导出 · 对话 ${r.conversations} 条 · 文件 ${(r.materialsBytes / 1024 / 1024).toFixed(1)} MB`); if (r.threads) { console.log(` ✅ Codex 侧栏:${r.threads.imported} 个会话已写入(重启 Codex 可见)`); if (r.threads.failures > 0) console.log(` ⚠ ${r.threads.failures} 个会话写入失败(已跳过)`); if (r.threads.codexWasRunning) console.log(" 💡 Codex 正在运行,可能需要重启才能看到新会话"); } console.log(`\n重启 ${opts.to} 后,它会自动读取这些资料。`); }