Introduction

In DeepSeek Harness (DSH), performing session summaries or item archiving commonly involves having the model directly output Word or Markdown documents, followed by manual adjustments to the formatting. Official red-header documents have fixed standards for agency names, document numbers, titles, body text indentation, signatures, and line spacing. Direct model formatting often leads to numbering errors, placeholder residues, or layout deviations.

The following introduces dsh-tool-hongtou: a workflow plugin maintained by ExElectron, employing a two-stage decoupled pipeline of “LLM-structured outline + deterministic Word 2003 XML rendering,” separating content generation from layout rendering.

What This Is

dsh-tool-hongtou is a DSH plugin for the Cordis host side, currently at version 0.2.0 under the MIT license. It provides a /hongtou command in sessions, reads the complete session context, first produces a valid JSON outline, then injects it into a standard red-header template skeleton to generate a .doc file and saves it to the output/ directory.

The plugin is hosted on GitHub: ExElectron/dsh-tool-hongtou; community directory page: SkillHub Plugin Page (SkillHub is an independent community directory, not officially affiliated with DeepSeek or幻方).

Architecture: Two-Stage Decoupling

When executing /hongtou [subject/title], the pipeline is as follows:

/hongtou [subject/title]
  
  ├─ Session context: ctx.sessionQuery.readSession() reads the complete raw event log
  
  ├─ Stage 1: LLM structured output (lib/phase1-llm.js)
      · Only outputs valid JSON outline, strictly forbidding handwritten XML tags and Markdown symbols
      · Output validated by schema (lib/schema.js) + Markdown/placeholder cleansing
      · Auto-retries once on failure; if still fails, falls back to deterministic extraction (lib/fallback.js, also JSON)
  
  └─ Stage 2: Deterministic layout rendering (lib/phase2-render.js)
       · Pure Node.js code parses JSON, injects into templates/document-skeleton.xml skeleton
       · Numbering (//1.), fonts, line spacing, red lines are all deterministically generated by code
       · Final validation: no text boxes/annotations/comments/placeholders/Markdown residues  saves to output/

Stage 1 is only responsible for structured content; Stage 2 takes over layout via code, with no model involvement in formatting.

Core Capabilities

Layout Replication

The template templates/document-skeleton.xml is assembled from authentic samples via a one-time build script, primarily ensuring:

  • Complete replication of sample <w:fonts> (including FangZheng CuSong Simplified, HuaWen ZhongSong, SimSun, FangSong_GB2312, SimHei, KaiTi, etc.) and 11 <w:styles>;
  • Red-header agency name uses VML art text v:textpath (HuaWen ZhongSong bold, red, height 51pt, width dynamically centered based on character count);
  • Red divider lines are exact dual VML lines from the sample;
  • Document numbers, titles, body text first-line indentation, signatures, dates, and other paragraph attributes along with fixed 28pt line spacing are injected by code;
  • Template contains no text boxes or annotations, placeholders are removed post-generation, and validated for no comment residues.

Model-Non-Formatting Rights

LLM output undergoes double cleansing via stripMarkdown and hasForbiddenContent before entering the rendering layer, filtering links, placeholders (e.g., xxxx, (leave a blank line), (fill in here…), etc.). Illegal content is directly rejected and does not enter the document.

Deterministic Numbering Generation

sections numbering uses “一、二、…”, sub-clauses use “(一)(二)…”, generated by Stage 2 in array order, avoiding model numbering errors.

Installation and Activation

The plugin is mounted via dsh.bundle.patch declaration. To install for the web profile, use the following commands:

# Install from npm
dsh plugin --profile web add dsh-tool-hongtou

# Or install from GitHub
dsh plugin --profile web add github:ExElectron/dsh-tool-hongtou

Alternatively, manually add dependencies and declare the bundle in the profile’s package.json:

"dependencies": {
  "dsh-tool-hongtou": "^0.2.0"
  // Or "dsh-tool-hongtou": "github:ExElectron/dsh-tool-hongtou"
},
"dsh": { "profile": { "bundles": ["dsh-tool-hongtou"] } }

After mounting, dsh needs to be restarted (web profile assembles bundle patches at startup). Runtime requires Node.js >= 22.19.0; peer dependencies include @deepseek-ai/cordis ^4.0.1, @deepseek-ai/dsh-llm ^0.1.0-rc.6, @deepseek-ai/dsh-session-query ^0.1.0-rc.6.

Typical Usage

After restarting dsh, input in the session:

/hongtou
/hongtou Red-header document plugin refactoring items

Without parameters, the plugin extracts content from the current session context; with parameters, the parameter serves as a subject or title clue for structured output. The generated Word 2003 XML document is written to the output/ directory.

Use Cases and Notes

Suitable for scenarios requiring DSH session content to be organized into standard red-header document formats, such as item summaries, internal bulletin drafts, etc. The two-stage design separates “what to write” from “how to format,” reducing layout risks when models directly output Word.

Please note before use:

  1. The plugin runs with the current dsh process permissions; read the source code and confirm the MIT license terms before installation;
  2. Output is in Word 2003 XML format (.doc), requiring an editor compatible with that format to open;
  3. Stage 1 relies on LLM and schema validation; if the model is unavailable, it falls back to deterministic extraction via lib/fallback.js, with content quality depending on the completeness of session context.

Development and Validation

The maintainer provides syntax checking and testing commands in the README:

node --check lib/index.js && node --check lib/schema.js && node --check lib/phase1-llm.js && node --check lib/phase2-render.js
node --test --test-isolation=none test/schema.test.js test/phase1.test.js test/phase2.test.js test/e2e.test.js

Key modules: lib/index.js (entry and orchestration), lib/phase1-llm.js, lib/schema.js, lib/phase2-render.js, lib/fallback.js, templates/document-skeleton.xml.

Conclusion

dsh-tool-hongtou splits red-header document generation into LLM-structured outlines and deterministic XML rendering, providing a reproducible layout output path within the DSH workflow. For source code or issue submission, see GitHub Repository; community index at SkillHub Directory Page.