Preface

In DeepSeek Harness (DSH), performing document-related tasks commonly involves manually crafting prompts and then having users adjust Word formatting against national standards themselves. With numerous formatting items and detailed rules, it’s challenging for Agents to stably produce compliant .docx files. Manual typesetting involves repetitive labor, and checks and revisions are difficult to close within a conversation loop.

The following introduces gongwen-skill (maintained by linhut), which implements the GB/T 9704 “Format for official documents of Party and government organs” as an executable Python CLI and packages it as a Skill and Cordis plugin directly loadable by DSH. Agents can invoke commands for format checking, automatic repair, content optimization, and template generation, transforming document processing from “verbal suggestions” into a “reproducible toolchain.”

What This Is

gongwen-skill is a comprehensive tool for Chinese official document processing. The current version is v2.1.0 (MIT license, GitHub with about 14 stars). It is based on the GB/T 9704 national standard and targets scenarios for official document writing and material preparation in enterprises and public institutions.

The project originated from the open-source desktop application AI Official Document Intelligent Optimization Assistant: it extracts the core formatting engine, removes desktop and database dependencies, and releases independently. Besides the command line, the repository includes .dsh/skills/ skill descriptions, dsh/ bridge layer, and cordis.patch.yml, allowing direct invocation within DSH Agent and Web UI.

The runtime environment requires Python 3.10+; core dependencies are python-docx, pydantic, and pyyaml. The package is available on PyPI (gongwen-skill).

Core Features

Capabilities are organized as “Parse → Check → Repair → Generate → Review,” with the following content derived from the project’s README and capability table.

Format and Templates

  • List Types (list-types): Lists 24 supported document types (including press releases, speeches, hosting scripts, etc.).
  • Template Generation (template): Generates blank templates compliant with GB/T 9704 standard based on type.
  • Parse (parse): Parses .docx into a structured DocumentModel.
  • Format Check (check): Checks against national standards, with issues graded as P0/P1/P2 (read-only).
  • Format Repair (optimize): Automatically repairs fonts, font sizes, line spacing, page margins, etc., outputting compliant documents.
  • Model Generation (generate): Generates .docx from a JSON model.
  • One-Click Fix (fix-common): Addresses common items such as paragraph type correction, numbering splitting, first sentence bolding, and bold scope repair.

Content and Drafts

  • Content Optimization (optimize-content): Defaults to Word native tracked changes + comments (tracked mode, accept/reject item by item in the Review panel); optional inline diff version (inline).
  • Markdown to Official Document (md2docx): Supports Front Matter metadata, converting drafts directly into formatted .docx.
  • Bold First Sentence (bold-first): Bolds the first sentence of body paragraphs according to official document standards.
  • Full Review (full-review): Combines tracked changes and comments, including sentence-level diff revisions and categorized comments.
  • Review Generation (review): Generates review comments based on a five-role review mechanism.

Layout Injection

  • Header (header): Injects the issuing authority logo, document number, signatory, and red dividing line.
  • Footer (footer): Injects copying agencies, printing authority, printing date, and dividing lines.
  • Page Numbers (pagenum): Injects dynamic page numbers using Word PAGE fields (Song 4, default single-right double-left for double-sided printing).

Styles, Rules, and Utilities

  • Style Learning (style-learn / style-list): Learns Run/paragraph/page-level styles from standard documents, generating named templates; later applied via optimize -t template_name.
  • Rule Management (rule-export / rule-import / rule-list): Three-tier customization of YAML rules (official/unit/user).
  • Table Sign Generation (table-signs): Batch generates A5 landscape meeting table signs.
  • Document Audit (audit): Checks for strikethroughs, bold, AI declarations, and other traces.
  • Session Handoff (handoff): Cross-session context passing (--list / --latest).
  • Self-Diagnosis (doctor / repair): Diagnoses 21 items including Python, dependencies, version consistency, fonts, and DSH files; can automatically repair common issues.
  • Version Check (check-update): Compares versions across GitHub, GitCode, and AtomGit repositories.

The repository also provides plain text knowledge bases (prompts/style-prompts.md, prompts/usage-prompts.md, rules/official/*.yaml), allowing Agents to reference writing standards in environments without code execution.

Installation and Enablement

gongwen-skill supports multiple integration methods. Within the DSH ecosystem, you can choose a path based on whether a Web UI tool panel is needed.

Method 1: Register as a DSH Skill (File System, Lightweight)

The DSH Agent scans skill directories on startup (priority from high to low: {project}/.dsh/skills/, {project}/.agents/skills/, ~/.dsh/skills/, ~/.agents/skills/).

Project-level installation example:

git clone https://github.com/linhut/gongwen-skill.git ./third_party/gongwen-skill
ln -s ./third_party/gongwen-skill/.dsh/skills/gongwen-skill ./.dsh/skills/gongwen-skill

After cloning, install Python dependencies:

cd third_party/gongwen-skill
pip install -r requirements.txt
# Or: pip install gongwen-skill

Method 2: As a DSH Cordis Plugin (Web Profile)

If you need to invoke via the tool flow in the DSH Web UI, use the official CLI to mount to the Web Profile:

dsh plugin --profile web add -w gongwen-skill

This command writes to ~/.dsh/profiles/web/package.json according to the preset and rebuilds the bundle. After installation, confirm that the dsh.profile.bundles array includes gongwen-skill (only the root package; do not repeatedly list subdirectories).

Prepare the Python environment locally before starting:

pip install gongwen-skill   # Or run pip install -r requirements.txt in the cloned directory
dsh --profile web

Access http://127.0.0.1:3080/ in the browser to allow the Agent to load the skill in a new session.

Fonts and DSH Configuration (v2.1.0+)

GB/T 9704 typesetting relies on standard fonts. Users who cloned the repository can use the built-in fonts in assets/fonts/; users who installed via PyPI need to execute:

python -m gongwen font install
python -m gongwen font check

DSH plugins can manage default document types, page margins, body fonts, line spacing, and other typesetting parameters via ~/.gongwen-skill/dsh-config.json; pure CLI users are unaffected.

Plugin directory page: SkillHub · linhut/gongwen-skill (category: Workflow).

Typical Usage

The following commands can be executed directly in an Agent session or verified manually in the terminal.

Generate a standard notice template:

python -m gongwen template notice -o 通知模板.docx

Check document format (read-only, JSON output for Agent parsing):

python -m gongwen check 公文.docx -t notice --json

Auto-repair and output the final product:

python -m gongwen optimize 公文.docx -o 成品.docx -t notice --apply

Convert Markdown draft to official document:

python -m gongwen md2docx 草稿.md -o 正式公文.docx -t report --signer "XX单位" --date "2026年8月1日"

Content optimization (Word native tracked changes + comments):

python -m gongwen optimize-content 原文.docx --changes 修订内容.json --apply --mode tracked -t news

Inject header, footer, and page numbers:

python -m gongwen header 公文.docx -o 红头公文.docx --org-name "XX单位" --doc-number "〔2026〕1号"
python -m gongwen footer 红头公文.docx --cc "各单位" --printer "XX办公室" --print-date "2026年8月1日"
python -m gongwen pagenum 红头公文.docx --alignment right

Learn styles from a standard document and apply them:

python -m gongwen style-learn 标准公文.docx -n 模板名
python -m gongwen optimize 公文.docx -o 成品.docx -t 模板名 --apply

In AI conversations, users can describe requirements in natural language, and the Agent with the loaded skill will select and execute the corresponding subcommand.

Applicable Scenarios and Notes

Who Is This For

  • Developers and writers who need to process Party and government or enterprise/ institution official documents within a DSH Agent.
  • Teams that want to automate GB/T 9704 format checks, repairs, and header/footer injection instead of writing formatting instructions manually each time.
  • Scenarios where you have a Markdown draft or Word initial draft and need to convert it to a compliant .docx or an optimized version with review traces with one click.

Usage Notes

  1. Permissions: The plugin runs with the current DSH process permissions, can read and write local files, and execute Python commands. Before installation, you should read the source code and MIT license to confirm it meets your organization’s security requirements.
  2. Environment: The Cordis plugin bridge layer is Node.js, while the actual typesetting is done by the Python CLI; both methods require Python 3.10+ and dependencies on the local machine.
  3. Fonts: Without national standard fonts installed, check and repair results may deviate from expectations; it is recommended to run python -m gongwen font install first.
  4. Content Optimization: The revision content for optimize-content is usually provided in JSON format; the Agent needs to organize the modification plan first, then call the command to write Word tracked changes.
  5. Ecosystem Positioning: SkillHub is a Skills community directory for Chinese users, with no official affiliation with DeepSeek or High-Flyer; DSH itself follows the “everything is a plugin” philosophy, with skills and plugins loaded from local or specified sources.

Conclusion

gongwen-skill brings the GB/T 9704 standard from paper to an callable toolchain: format checking and repair, Markdown to official document conversion, header/footer/page number injection, and Word native tracked review can all be driven by a DSH Agent within a conversation. If you are building an official document workflow in DSH, you can integrate lightly via the Skill file system or mount to the Web Profile using dsh plugin --profile web add -w gongwen-skill.

  • Directory page: https://www.skillhub.cn/plugins/linhut/gongwen-skill
  • GitHub: https://github.com/linhut/gongwen-skill