DeepSeek Harness Session Export Plugin

Preface

The core architecture of DeepSeek Harness (DSH) is pluggable. When using the Web client for debugging, demonstrations, or logging sessions, developers often need to save conversation logs as local files. The official export functionality typically relies on specific routing or backend processing, which is not lightweight enough. This plugin utilizes pure frontend injection to add “Export Markdown” and “Export PDF” options to the “More” menu in the DSH Web session, making the operation of saving session logs more intuitive and efficient.

Plugin Introduction

  • Plugin Name: dsh-export-plugin
  • Maintainer: guyusky
  • Functional Positioning: A client-side plugin used to quickly export session logs within the DSH Web interface.
  • Implementation Method: Pure frontend injection with no dependency on additional npm packages. It reuses the official /api/session.export interface to fetch session ZIP data, then parses and transforms it on the frontend.

Installation

Installing the plugin requires using the npx command to link the local directory to the DSH plugin system.

  1. Ensure there is a local directory containing the plugin code, for example, D:\dsh-code\export-plugin.
  2. Execute the following command in the terminal:
npx @deepseek-ai/dsh plugin --profile web add D:\dsh-code\export-plugin

After installation, the DSH Web service must be restarted for the menu injection to take effect.

Core Functions

The plugin injects two action items below “Archive Session” in the “More” menu of the session list:

  1. Export Markdown
    • Exports a minimalist Q&A pair format (User input + the last visible assistant reply of that turn).
    • Saves as a .md file.
    • Does not include thinking processes, tool calls, or system prompts.
  2. Export PDF
    • Exports clean Q&A pairs (including text and images).
    • Uses A4 layout and leverages the browser’s native print function to generate the PDF.
    • Requires selecting “Save as PDF” in the system print dialog.

Technical Implementation and Filtering Rules

The plugin reuses the /api/session.export route from the official dsh-session-log-export package. This interface returns a ZIP file containing canonical JSONL logs and image assets. The plugin performs the following tasks on the frontend:

  1. ZIP Parsing: Uses the browser’s native DecompressionStream to unzip the ZIP file, parsing out the session*.jsonl file in the root directory and images in the media/ directory.
  2. Event Filtering: The plugin only processes user/message and assistant/message events.
    • User Input Filtering: Only retains messages where source.kind === 'user'. This resolves the issue of duplicate records for the same message in agent/inbox/spliced and user/message (deduplication via message id).
    • System Content Filtering: Automatically filters out system-injected content such as runtime-context, time-context, skill-catalog, and workspace instructions to prevent them from mixing into the user question list.
    • Assistant Reply Filtering: Only retains the last visible assistant reply for each conversation turn, discarding transitional text, thinking processes (thinking), tool calls (tool_use), and their results.

Usage

  1. Open a session in the DSH Web interface.
  2. Click the “More” button in the session row.
  3. Select “Export Markdown” or “Export PDF” from the pop-up menu.
    • If Markdown is selected, the file will be downloaded directly to the local machine.
    • If PDF is selected, the browser will open the print preview window, and the user needs to manually click “Save as PDF”.

Notes

  • PDF Saving: Due to browser security sandbox restrictions, PDF export cannot save files directly via code; manual operation in the print dialog is required.
  • Content Scope: The exported content only includes “User Input” and “Final Assistant Reply”. It does not include the model’s chain of thought, intermediate drafts, tool call details, or system prompts.
  • Menu Structure Changes: The plugin monitors DOM changes via MutationObserver. However, if an official upgrade alters the menu structure causing text matching to fail, the plugin code may need to be updated and the service restarted.
  • Event Format Compatibility: The plugin is primarily targeted at V4 event formats. If a DSH upgrade leads to unknown event types, Markdown export will preserve them as-is in code blocks, while PDF export will ignore them directly.
  • Large File Performance: Sessions containing a large number of images or exceeding 50 turns may result in larger file sizes or slower printing processes.

Summary

Through a minimalist Q&A pair export method, this plugin solves the need for saving session logs in the DeepSeek Harness Web interface. For developers or demonstration scenarios where only the final conversation result needs to be recorded, it provides a lightweight solution with no backend configuration and zero dependencies.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye