把 append-only 会话日志导出为按轨迹来源分组的可读 Markdown 或 HTML。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:whyihaveyou/dsh-suite#path:/packages/plugins/plugin-session-export
GitHub 来源的插件在安装时会在你的机器上执行构建脚本。请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
DSH 插件:把 append-only 会话日志导出成人读的 Markdown / HTML,按 Trajectory 来源分组渲染 (系统提示 / 思维链 / 工具调用 / 子agent)。官方
session-log-export只给 raw JSONL,本插件补齐 「一段对话一份干净文档,可直接贴飞书 / 周报 / 复盘」的缺口。
DSH plugin: export the append-only session log as human-readable Markdown / HTML, grouped by trajectory source (system prompt / reasoning / tool calls / subagent). The official
session-log-exportonly emits raw JSONL; this plugin produces a clean per-conversation document you can paste into a report, IM, or review.
特性 / Features
工具
export_session(defineTool,inject: ['tools','sessions']):format: 'markdown' | 'html'(默认 markdown);HTML 版带折叠与基本样式。- 导出当前会话(默认)、指定
sessionId,或all: true批量导出全部 live 会话。 path缺省写会话 workspace(session.header.cwd)。
按来源分组渲染:系统提示(
request/header)、用户/助手正文、思维链(reasoning 折叠)、 工具调用(参数 + 结果折叠,subagent*等委派工具标为「子agent」)、todo 列表、用量统计。子agent 会话(
header.origin === 'subagent')在头部标注来源与委托深度。Tool
export_session(defineTool,inject: ['tools','sessions']):format: 'markdown' | 'html'(default markdown); HTML has collapsibles + base styling.- Export the current session (default), a named
sessionId, orall: trueto batch-export every live session. pathdefaults to the session workspace (session.header.cwd).
Grouped by source: system prompt (
request/header), user/assistant prose, reasoning (collapsed), tool calls (args + result collapsed, delegation tools flagged as subagent), todos, usage totals.Subagent sessions (
header.origin === 'subagent') are annotated with origin and delegation depth.
安装 / Install
dsh plugin --profile <name> add @dsh-suite/plugin-session-export
(本地开发:dsh plugin --profile <name> add ./packages/plugins/plugin-session-export)
使用 / Usage
模型(或 CLI)可直接调用该工具:
The model (or CLI) can call the tool directly:
export_session({ format: 'html' })
export_session({ all: true, path: '/tmp/session-dumps' })
export_session({ sessionId: 'session-3', format: 'markdown' })
输出示例 / Output sample (Markdown):
# 帮我查一下 Kuramoto 临界指数
会话:`session-1` · 创建时间:2026-08-13T…Z · 模型:`deepseek-official/deepseek-chat`
## 系统提示
```text
You are a helpful assistant…
```
## 对话
### Turn 1
**👤 用户**
帮我查一下 D 维 Kuramoto 模型的临界指数
**🤖 助手**
临界指数为 γ⁻ = γ⁺ = 1 …
<details>
<summary>🧠 思维链(Thinking)</summary>
```text
先定位 Daido 2015 的磁化率定义…
```
</details>
<details>
<summary>🔧 工具调用:web_search</summary>
**参数**
```json
{ "query": "Daido 2015 Kuramoto susceptibility" }
```
**结果**
```text
… 检索到 3 条结果 …
```
</details>
验证 / Verification
- ✅ 纯 ESM 编译(
pnpm build) - ✅
dsh.bundle+cordis.patch.yml装载进真实 DSH profile(--dump-config含本行) - ✅ 工具注册进 registry(
ctx.tools.registerself-check) - ⚠️ 端到端「模型调 export_session → 落盘 → 读回」需真实会话 + API key——未闭环,见下
Blocked / not closed: 无 DEEPSEEK_API_KEY 无法让模型真实调用工具;导出渲染逻辑已按
DSH 真实 SessionEvent 类型实现并编译通过,但尚未在有完整轨迹的会话上端到端落盘验证。
设计准则 / Design principles
遵守 dsh-plugin-design-principles.md:inject 声明依赖(#3)、ctx.tools.register 注册即
effect(#1)、会话数据走 ctx.sessions(服务依赖,非全局状态,#2)、读写文件是不可逆发射、
失败即抛错不半写(#9)。
链接
同类插件
Anionex/dsh-turn-rewind★ 35
对话回退:基于持久 Change Ledger 回滚会话与工作区状态。
Chinesezjc/dsh-interconnect★ 24
跨实例互联:经 interconnect 服务在多个 DSH 实例间转发消息与事件。
Nwflower/dsh-chat-import★ 22
把 Claude Code / Codex / ChatGPT / Cursor / Gemini / Reasonix / opencode 的聊天记录全保真导入为可续聊的 DSH 会话。
hellodigua/dsh-share★ 16
一键分享你的对话。
Moeblack/dsh-message-edit★ 16
基于分支的消息编辑、reroll、重试与版本时间线。
yuezengwu/dsh-explain★ 9
本地优先学习模式:跨会话全局学习线程、按来源讲解。