GitTOU/dsh-tool-gbt9704

Model-facing gbt9704convert tool: reformat a Markdown (.md) or Word (.docx) source into the GB/T 9704-2012 党政机关公文格式 (Party-and-government official document) body layout as a new .docx.

catalog descriptioncatalog 简介 / catalog description:DeepSeek Harness 插件:Markdown/Word 一键排版为 GB/T 9704 党政机关公文格式

Project Overview项目介绍

dsh-tool-gbt9704 is a Cordis-native plugin for the DeepSeek Harness (DSH) agent runtime, maintained by GitTOU, written in TypeScript, and released under the MIT license. It exposes a single model-facing tool named gbt9704_convert that reformats a Markdown (.md) or Word (.docx) source into a new .docx whose body conforms to the GB/T 9704-2012 党政机关公文格式 (Party-and-government official document) layout. Internally it is self-contained: the source is read with Node's fs, parsed through a shared document model (mdast for Markdown, an internal OOXML extractor for existing .docx files), then rendered onto a minimal .docx container built by hand using fflate; the plugin registers no service and keeps no state, so each invocation is a pure path-in / path-out conversion.

The typical workflow is straightforward: a model — or the operator driving DSH — supplies the source path and any optional Config overrides, and the tool re-lays the document out as official 主体. The converter infers 标题 from the first heading or short paragraph, recognises 一、 / (一) / 1. / (1) as the four 层次标题 levels regardless of Markdown heading depth, treats the first short paragraph ending in a full-width colon as 主送机关, and uses the last two paragraphs as 发文机关署名 and 成文日期 when the latter matches 2024年1月5日 or 二〇二四年一月五日. GFM tables, list items, code lines, blockquotes, and PNG/JPEG images map respectively to tables, body paragraphs, body paragraphs, body paragraphs, and centered images. The intended users are 文秘, drafters, and developers inside Chinese party-and-government units, agencies, or state-owned enterprises who use DSH as a writing assistant and want a one-step bridge from Markdown drafts to compliant 公文 layout that can be opened and printed in Word.

Dependencies and limits are spelled out plainly. Runtime needs Node plus the bundled mdast and fflate libraries; the layout values (A4 page, 天头 37 / 订口 28 / 地脚 35 / 翻口 26 mm, body 16 pt 仿宋_GB2312 justified, 22 lines × 28 characters, 579 twip fixed line pitch, title 22 pt 方正小标宋简体, 四号宋体 —1— page numbers) are Config fields defaulting to the standard and overridable from cordis.yml. Known constraints: docx→docx fidelity is intentionally limited to paragraph/table text and images, so headers/footers, comments, tracked changes, charts, text boxes, and per-run fonts are not preserved; only PNG/JPEG are embedded, inline and in-table images are dropped, and remote http(s) Markdown images become warnings; 版头 (发文机关标志, 发文字号, the red separator line, 份号/密级) and 版记 (抄送/印发机关, separators) are out of scope. Fonts 仿宋_GB2312, 方正小标宋简体, and 楷体_GB2312 are common on Windows 公文 deployments but may be missing elsewhere and will be substituted by Word on open. Crucially, the tool performs its own fs reads and writes and does not go through ctx.fs, so its writes bypass the agent's filesystem sandbox and are not recorded as observed file state — operators should still use sandboxed model-facing file mutation tools for ordinary edits and reserve this plugin as a dedicated GB/T 9704-2012 converter, with a first-run check that the host's font set matches the expected 公文 fonts.

dsh-tool-gbt9704 是一个面向 DeepSeek Harness(DSH)的 Cordis 原生插件,由 GitTOU 开发,使用 TypeScript 编写并以 MIT 协议发布。它向模型注册一个名为 gbt9704_convert 的工具,能够将 Markdown(.md)或 Word(.docx)源文件重新排版为符合 GB/T 9704-2012《党政机关公文格式》主体版式的 .docx 文件。转换流程基于共享文档模型:Markdown 经 mdast 解析,已有 .docx 通过内置 OOXML 抽取器解析,再通过 fflate 手写最小 OOXML 容器渲染输出,全程不注册任何服务,也不保留状态。

典型工作流是:模型拿到源文件路径与可选的 Config 覆写,将 Markdown 草稿或旧版公文交给工具加工;工具按文档约定位置识别标题、一/(一)/1./(1)四级层次标题、顶格主送机关、署名与成文日期,再写入新 .docx。调用方通常是党政机关、事业单位中负责公文写作与归档的文秘、撰稿员以及把 DSH 作为写作助手的开发者,他们借助这一工具把现代 Markdown 源稿规范化为公文版式,再用 Word 完成红头、版记与套印。

依赖方面,插件依赖 Node 运行时、mdast 文档模型、fflate 压缩库以及 Cordis 框架本身,配置字段默认值对应国家标准,可在 cordis.yml 中覆写字体、字号、页边距与行距。已知局限包括:docx→docx 不保留页眉页脚、批注与修订;仅支持 PNG/JPEG,居中或单元格内图片会丢失;不处理发文机关标志、发文字号、红线、份号、密级等版头以及抄送、印发机关等版记;仿宋_GB2312、方正小标宋简体、楷体_GB2312 在非 Windows 公文环境可能缺失,须由 Word 替换。该工具直接调用 fs 读写,绕过了 ctx.fs 服务与文件系统沙箱,因此模型侧仍应优先走沙箱化的文件变更工具,gbt9704_convert 仅作为专用转换器使用,首次运行时需注意字体可用性与上述边界。

Pre-install check安装前体检Compatibility · Security兼容性 · 安全性 2 warnings2 项注意
  • Only 3 stars - very few users, little community feedback星标只有 3,几乎没人在用,遇到问题缺少社区反馈
  • No DSH plugin manifest detected - it may only carry the dsh-plugin topic, so the install method must be confirmed on the spot未检测到 DSH 插件清单:可能只是打了 dsh-plugin 话题,安装方式要现场确认
DSH walks through these 9 checksDSH 会逐条核对这 9 项

Compatibility兼容性

  • DSH, Node, OS and profile requirementsDSH 版本 / Node 版本 / 操作系统 / profile 是否满足要求
  • External dependencies and runtimes (Electron / Python / Docker, ...)外部依赖与运行时(Electron / Python / Docker 等)是否齐备
  • Conflicts with installed plugins: command names, skill / tool names, ports, duplicate MCP registration与已装插件是否冲突:命令名、skill / tool 重名、端口占用、重复 MCP 注册

Security安全性

  • Repo matches the facts registered here; archived or abandoned?仓库是否与页面登记一致,是否归档或长期停更
  • Safety of preinstall / install / postinstall and install.sh / setup.ps1preinstall / install / postinstall 与 install.sh、setup.ps1 是否安全
  • curl|bash, download-then-execute, obfuscation, unrelated domains → stop immediatelycurl|bash、下载即执行、混淆代码、无关域名 → 立刻停止
  • Typosquatting or unmaintained packages among the new dependencies新增依赖里有没有 typosquatting 或无人维护的包
  • Requested permissions vs. what the feature actually needs申请了哪些权限、是否超出功能所需(filesystem / network / shell / clipboard)
  • Any sudo / admin requirement, plus uninstall and rollback是否要求 sudo / 管理员权限,以及卸载与回滚方式

Anything uncertain must be marked unknown with a note on how to confirm it. This site's signal screen is a static snapshot, not a security audit.拿不准的必须标「未知」并说明要我怎么确认。本站的信号筛查是静态快照,不能替代安全审计。

Or use CLI install (for developers)或使用命令行安装(适合开发者)

CLI Install命令行安装

dsh plugin --profile web add github:GitTOU/dsh-tool-gbt9704

把 GitTOU/dsh-tool-gbt9704 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

dsh-tool-gbt9704

Model-facing gbt9704_convert tool: reformat a Markdown (.md) or Word (.docx) source into the GB/T 9704-2012 党政机关公文格式 (Party-and-government official document) body layout as a new .docx.

The converter is self-contained: it reads the source with Node's fs, parses it through a shared document model (mdast for Markdown, an OOXML extractor for existing .docx files), renders the model onto a hand-built OOXML document (a minimal .docx container via fflate), and writes the output file. It registers no service and keeps no state; a call is a pure path-in/path-out conversion.

Layout applied (GB/T 9704-2012 body rules)

Element Rule
Sheet A4 210 mm × 297 mm
Margins 天头 37, 订口 28, 地脚 35, 翻口 26 mm → 版心 156 mm × 225 mm
Body 三号仿宋_GB2312 (16 pt), justified, first-line indent two characters
Grid 22 lines per page, 28 characters per line, fixed 28.95 pt (579 twips) line spacing
Title 二号小标宋 (22 pt), centered, two blank lines after
层次标题 一、黑体 / (一)楷体_GB2312 / 1. and (1)仿宋, first-line indent
主送机关 顶格, ends with a full-width colon, one blank line before the body
署名/成文日期 Right-aligned; the date's first character sits two characters right of the signature's (right indents computed from both lengths, per §7.3.5.2)
页码 四号宋体 "—1—", odd pages right-空一字, even pages left-空一字 (evenAndOddHeaders)

All values are Config fields with the standard's defaults; a deployment may override fonts, sizes, margins, or line pitch from cordis.yml.

Writing conventions (约定位置解析)

The tool needs no metadata block; it reads the document by position:

  • The first heading (or the first short paragraph when the source has no heading) is the 标题.
  • Lines beginning with 一、 / (一) / 1. / (1) become the four 层次标题 levels, regardless of Markdown heading depth.
  • The first short paragraph ending in a full-width colon is the 主送机关.
  • The last two paragraphs are the 发文机关署名 and 成文日期 when the last one matches a date form (2024年1月5日 or 二〇二四年一月五日).
  • GFM tables, ordered/unordered list items, code lines, blockquotes, and PNG/JPEG images convert to tables, body paragraphs, body paragraphs, body paragraphs, and centered images respectively.

Showing the opening section of the README — the full document lives in the repository以上为 README 开头摘要,完整文档在仓库内 · View the full README on GitHub →在 GitHub 查看完整 README →

← 上一个 Prev dsh-study-buddy 下一个 Next DeepSeek-Harness-chat-billing →