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.exportinterface 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.
- Ensure there is a local directory containing the plugin code, for example,
D:\dsh-code\export-plugin. - 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:
- Export Markdown
- Exports a minimalist Q&A pair format (User input + the last visible assistant reply of that turn).
- Saves as a
.mdfile. - Does not include thinking processes, tool calls, or system prompts.
- 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:
- ZIP Parsing: Uses the browser’s native
DecompressionStreamto unzip the ZIP file, parsing out thesession*.jsonlfile in the root directory and images in themedia/directory. - Event Filtering: The plugin only processes
user/messageandassistant/messageevents.- User Input Filtering: Only retains messages where
source.kind === 'user'. This resolves the issue of duplicate records for the same message inagent/inbox/splicedanduser/message(deduplication viamessage 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.
- User Input Filtering: Only retains messages where
Usage¶
- Open a session in the DSH Web interface.
- Click the “More” button in the session row.
- 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.