npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-daily-session-export

v0.1.0

Published

Export dsh session event logs to shareable Markdown/HTML documents (developer preview)

Readme

session-export

dsh(DeepSeek Harness)插件。把当前会话的结构化事件流导出为可分享/归档的文档:Markdown 完整时间线,或自包含单文件 HTML(内联 CSS,浏览器打开后可直接打印为 PDF)。dsh 的 session log 本身就是结构化事件流(用户消息、助手回复、工具调用/结果、审批、路由……),本插件把它渲染成人可读的文档——不引入任何 PDF/网络依赖。

状态:developer preview。尚未在真实 dsh 运行时中验证,手动验证步骤见下文。

安装与配置

# dsh 配置示例
- id: session-export
  name: dsh-daily-session-export
  config:
    enabled: true
    outputDir: ./exports        # 导出文件写入目录(相对路径基于 dsh 进程工作目录),按需创建
    format: markdown            # 默认格式:markdown / html
    includeToolResults: true    # 是否包含工具结果正文
    toolResultMaxLength: 2000   # 工具结果/工具参数/JSON 载荷的截断长度(字符)
    includeReasoning: false     # 是否包含助手消息中的推理(thinking)内容
    redact: true                # 导出前脱敏(API key / PEM / Bearer / AWS / GitHub token)
    extraRedactPatterns: []     # 追加的自定义脱敏正则(命中替换为 [REDACTED:custom])
    showTimestamps: true        # 小节标题是否带事件时间戳

工具

  • session_export:把当前会话导出为文件。参数均可选:formatfileName(纯文件名,缺省按 会话id-时间戳 生成,扩展名按格式自动修正)以及上文全部渲染开关的本次调用覆盖。目标文件已存在时报错,绝不覆盖。返回文件路径 + 字节数 + 统计 JSON,render 为可读摘要。
  • session_export_preview:不落盘,返回导出文档的前 lines 行(默认 40)与总行数/统计,用于确认格式与脱敏效果后再决定导出。

PDF 获取方式:用 format: html 导出后在浏览器打开,使用浏览器"打印 → 另存为 PDF"。本插件不捆绑 PDF 依赖。

渲染说明

  • 文档结构:头部元信息(会话 id、导出时间、事件统计)→ 按事件顺序的时间线。turn/start 形成二级标题;用户/上下文消息、助手回复、工具调用与结果、审批(asked/decided/policy)、todo 快照、路由切换各自渲染为小节;插件自定义事件(如 cost-meter/budget-exceeded)按 Event: <类型> + JSON 载荷兜底渲染。
  • 以下结构性事件计入统计但不渲染step/startstep/endassistant/chunk(原始流片段)、request/header(含完整系统提示词与工具 schema,体积大且敏感)、agent/inbox/spliced
  • 推理内容没有独立事件类型——它位于 assistant/message 的 content blocks(type: 'reasoning')中,由 includeReasoning 开关控制(HTML 中渲染为可折叠的 <details>)。
  • 数据源是发起工具调用的那个 agent 的会话exec.agent.session.events),与 cost-meter 取当前会话的接缝一致;无关联会话的调用(如插件内部派发)会收到可读报错。

权限透明

本插件对宿主环境的影响面,逐条交代清楚:

  • 读写位置:只写配置的输出目录(outputDir,默认 ./exports),写入用 wx 标志——目标已存在即报错,不覆盖。此外只读当前会话的内存事件流,不读其他文件。
  • 网络域名:无。本插件不发起任何网络请求。
  • 凭证:不持有任何凭证。导出内容默认经脱敏规则处理(redact: true)。
  • 确认点:无交互确认;session_export 属 L1 级副作用(写本地新文件),可由 approval-guard 等审批门按工具名分级管控。
  • 日志内容:导出文件包含会话中的消息文本、工具参数与结果(截断后)。默认脱敏覆盖常见密钥形态,但不能保证穷尽所有秘密——分享导出文件前请自行过目(可先用 session_export_preview 检查)。

已知限制

  • 只导出调用时的当前会话快照;会话继续推进不会追加到已导出文件(重新导出即可,文件名带时间戳不会冲突)。
  • 脱敏是基于正则的启发式规则(PEM / AWS / GitHub / Bearer / sk- 式 API key / 环境变量赋值),可能漏掉自定义格式的秘密;redact: false 时导出内容完全原始。
  • request/header 事件(系统提示词、工具 schema 全量快照)一律不渲染,因此导出不包含完整系统提示词。
  • Markdown 渲染中的 details 小节(推理内容)以引用块降级呈现,无折叠交互。
  • 尚未在真实 dsh 运行时验证(见下)。

手动验证

本仓库的 CI 只覆盖类型检查与纯函数单测。接入真实 dsh 后请手动验证:

  1. 在 dsh 配置中启用本插件,确认启动日志出现 session-export: loaded
  2. 与模型完成几轮对话(包含至少一次工具调用),让 agent 调用 session_export_preview,确认预览含用户/助手/工具小节,统计数字与对话规模相符。
  3. 让 agent 调用 session_export,确认 ./exports/ 下生成 会话id-时间戳.md,内容完整、时间戳正确、无密钥明文(可在对话中故意贴一个 sk- 开头的假 key 验证脱敏)。
  4. 再次以相同 fileName 调用,确认报错"目标文件已存在"且原文件未被改动。
  5. format: html 导出,浏览器打开确认排版正常、推理内容(includeReasoning: true)可折叠、打印为 PDF 正常。

许可

MIT