npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-tool-hongtou

v0.2.0

Published

Cordis /hongtou command: two-phase pipeline (LLM structured JSON + deterministic Word 2003 XML template rendering)

Downloads

204

Readme

dsh-tool-hongtou

DeepSeek Harness 红头公文总结插件(Cordis 主机侧插件)——两阶段解耦流水线

架构

/ hongtou [事由/标题]
  │
  ├─ 会话上下文:ctx.sessionQuery.readSession() 读取完整原始事件日志
  │
  ├─ 阶段一:LLM 结构化输出(lib/phase1-llm.js)
  │    · 只输出合法 JSON 提纲,严禁手写 XML 标签与 Markdown 符号
  │    · 输出经 schema 校验(lib/schema.js)+ Markdown/占位符清洗
  │    · 失败自动重试一次;仍失败回退确定性提炼(lib/fallback.js,同为 JSON)
  │
  └─ 阶段二:确定性排版渲染(lib/phase2-render.js)
       · Node.js 纯代码解析 JSON,注入 templates/document-skeleton.xml 骨架
       · 序号(一、/(一)/1.)、字体、行距、红线全部由代码确定性生成
       · 最终校验:无文本框/批注/注释/占位符/Markdown 残留 → 落盘 output/

关键保证

  • 版式 100% 复刻标准红头公文样板templates/document-skeleton.xml 由一次性构建脚本从样板真实片段组装):
    • 完整复制样板 <w:fonts>(含方正粗宋简体/华文中宋/宋体/仿宋_GB2312/黑体/楷体等)、<w:styles>(11 个样式)、<w:docPr><w:sectPr>(含页眉页脚与页码框架);
    • 红头机关名 = VML 艺术字 v:textpath(华文中宋加粗、fillcolor=red、height 51pt,宽度按机关名字数自适应居中);
    • 红色分割线 = 样板原样双 VML 线条(3pt 粗线 from 5.25pt,53.2pt → 1.5pt 细线 60.65pt,横跨版心);
    • 文号段 first-line=4960、标题段宋体加粗 2 号居中 right=654、正文段 first-line-chars=200(首行缩进 2 字符)、落款段 first-line=645+前导空格、日期段 first-line-chars=1400、全程 spacing line=560 exact(28 磅固定行距)、snapToGrid off
    • 模板不含任何文本框、批注;最终文档经 split 移除注入占位符,无注释残留。
  • 模型零排版权:LLM 输出在进入渲染层前经过 stripMarkdown(链接、强调、列表、代码符号、表格管道)与 hasForbiddenContent(xxxx、×××、(空一行)、(空两格)、(此处填写…)等)双重清洗;非法内容直接回退,绝不进入文档。
  • 序号确定性生成sections 编号 一、二、…,子条款编号 (一)(二)…,由阶段二按数组顺序生成,杜绝模型序号错乱。

安装 / 挂载

插件通过 dsh.bundle.patch 声明挂载行。安装到 web profile:

# 从 npm 安装
dsh plugin --profile web add dsh-tool-hongtou

# 或从 GitHub 安装
dsh plugin --profile web add github:ExElectron/dsh-tool-hongtou

或手动在 profile 的 package.json 中添加依赖并声明 bundle:

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

挂载后重启 dsh(web profile 在启动时装配 bundle 补丁),然后在会话中输入:

/hongtou
/hongtou 红头公文插件重构事项

开发

# 语法检查与单元测试(dsh 沙箱内需 --test-isolation=none,避免子进程管道 EPERM)
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

结构

  • lib/index.js — Cordis 插件入口(apply / inject / name),两阶段编排与落盘。
  • lib/phase1-llm.js — 阶段一:LLM 结构化 JSON 输出(system 强约束、JSON 提取、校验重试)。
  • lib/schema.js — JSON schema 校验、Markdown/占位符清洗、提纲规范化。
  • lib/phase2-render.js — 阶段二:模板注入渲染、转义、序号生成、生成后校验。
  • lib/fallback.js — 确定性回退提炼(模型不可用时)。
  • lib/log.js — 会话事件日志序列化与统计。
  • templates/document-skeleton.xml — Word 2003 XML 模板骨架(标准红头版心,无文本框/批注)。
  • test/ — schema / phase1 / phase2 / 端到端测试。