feat: full conversation migration (266 sessions / 70k messages) with robust parsing
11e2b39 verified Download src/cli/commands/export.ts from hongcoding/agentlens: direct link, hf CLI and curl.
- Browser
- Download file 1.56 kB
-
https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/src/cli/commands/export.ts
- Command line
-
hf download hf://datasets/hongcoding/agentlens/src/cli/commands/export.ts
-
curl -L -o export.ts https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/src/cli/commands/export.ts
1.56 kB
| import { exportDsh } from "../../export/dsh.js"; | |
| interface ExportOpts { | |
| from: string; | |
| out: string; | |
| withAttachments?: boolean; | |
| noMaterials?: boolean; | |
| noConversations?: boolean; | |
| } | |
| export async function exportData(opts: ExportOpts): Promise<void> { | |
| if (opts.from !== "dsh") { | |
| console.log(`暂不支持从 "${opts.from}" 导出。当前支持:dsh`); | |
| return; | |
| } | |
| console.log("正在导出 DSH 完整资料(人物设定 + 文件资料 + 对话记录)...\n"); | |
| const result = exportDsh({ | |
| outDir: opts.out, | |
| withAttachments: opts.withAttachments === true, | |
| withMaterials: opts.noMaterials !== true, | |
| withConversations: opts.noConversations !== true, | |
| }); | |
| console.log(` ✅ 人物设定:${result.personas} 个 Bot → personas.md`); | |
| if (result.materialsDirs.length > 0) { | |
| console.log(` ✅ 文件资料:${result.materialsDirs.length} 个目录,${(result.materialsBytes / 1024 / 1024).toFixed(1)} MB`); | |
| for (const d of result.materialsDirs) console.log(` ${d}`); | |
| } | |
| if (result.conversationFiles > 0) { | |
| console.log(` ✅ 对话记录:${result.conversationFiles} 个会话,${result.conversationLines} 条消息 → conversations/`); | |
| } | |
| if (result.conversationFailures > 0) { | |
| console.log(` ⚠ ${result.conversationFailures} 个会话文件无法读取(已跳过,不影响其他数据)`); | |
| } | |
| console.log(`\n导出完成:${result.outDir}`); | |
| console.log("把这个目录放进任何 AI Agent 的项目里,它就能读取你的人物设定、资料和对话。"); | |
| } | |