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-harnessmm-reuse

v0.4.0

Published

Guarded decision reuse for DeepSeek Harness: the actor authors a small executable decision graph, and the harness executes its resolved steps without a model round trip.

Readme

dsh-harnessmm-reuse

把 arXiv:2610.32813(HarnessMM)的 EDG + GDR + 选择器 + CCS 移植到 DeepSeek Harness 的插件。 模型在自己的回复里顺手写一张决策表,插件把它从流里剥出来;之后某个工具结果满足了表里的 guard,就直接执行那一步,不再发这次模型请求。

RSI(论文 §5.6,离线迭代配置)明确不做。

与论文的对照

| 论文 | 本实现 | 状态 | |---|---|---| | EDG:节点 (label, predecessor, guard, literal args),有向无环 | <bank>{"nodes":[…]}</bank>;after 可以是 $action(本次回复里的动作)或更早的 label;声明顺序必须早于依赖,因此天然无环 | 一致 | | 授权通道:慢模型在自己的 CoT 里顺手写,不额外调用 | 同:写进回复文本,插件在 llm/stream 里边流边剥,块不进历史 | 一致 | | GDR:前驱完成 ∧ guard 成立 ∧ 参数闭合 | 同,并且派发前按工具声明的 schema 校验参数(lib/toolargs.js);工具不可见直接不入选 | 一致 | | 候选集合 = 所有可执行节点 | 同,多个候选时交给选择器 | 一致 | | 选择器:单 token + 模型上报 logprobs | 一次 maxTokens: 8 / temperature: 0 的受限补全,整标签精确匹配,否则弃权 | 近似:DSH 的 GenerateOptions 没有 logprobs | | CCS 证书:图哈希 / 决策 id / 前驱 receipt / 精确参数 / 工具 receipt / 被绕过的回调 | 八个字段都写;tool_receipt 在 tools/result 时补全 | 一致 | | 完整任务计费:作者、选择器、回退、失败 | 账本记 bank、证书、拒绝原因、替换次数、选择器 token | 近似:作者 token 未单列(块已从流里剥离,只能估算) | | RSI | 未实现 | 明确不做 |

机制

  1. 写表:慢模型这次要做 edit,而它已经知道改完要跑 npm test,就在同一条回复里附一段
    <bank>{"nodes":[{"label":"test","after":"$action","tool":"pwsh","args":{"command":"npm test"},"guard":{"exit":0}}]}</bank>
  2. 剥离:插件在 llm/stream 里把这些字符从文本增量中扣掉,并重写 block-end 的文本, 所以会话日志里只有干净回复。
  3. 复用:下一次模型请求到达时,如果前驱 receipt 已经落地且 guard 成立,插件直接返回一段 合成的 tool-call chunk 流——这一轮没有 provider 请求。
  4. 选择:多个节点同时可执行时,用一次受限补全选一个 label,或弃权回模型。
  5. 证书:替换时先写证书骨架,工具结果落地后在 tools/result 补上 tool_receipt。

安装

plugin_manager { action: "install_bundle", target: "dsh-harnessmm-reuse" }

本地目录装:install_bundle 的 target 传本目录绝对路径。装完重启 Harness。

配置

| 字段 | 默认 | 含义 | 生效时机 | |---|---|---|---| | enabled | true | 是否用已存决策应答请求 | 下一次请求 | | authoring | true | 系统提示里教 bank 格式,并从回复流里剥离 | 下一次请求 | | maxNodes | 6 | 一张表最多几个节点 | 下一张表 | | maxChain | 6 | 一张表最多连续执行几次 | 立即 | | ledger | true | 写 storages/harnessmm/ledger.jsonl | 下一次写入 |

字段都标了 .volatile(),插件页有配置表单。不想用 UI 就改 profile 的 cordis.patch.yml:

- id: harnessmm
  config:
    maxNodes: 4

验证

# 逻辑:解析 / DAG / guard / 候选 / 剥离
node --test test/unit.test.mjs

# 真包契约:合成流能被 BlockAssembler 组装、剥离后仍能组装
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\contract-test.ps1

# 端到端(隔离 profile,不碰真实 DSH_HOME)
powershell -NoProfile -ExecutionPolicy Bypass -File .\scripts\verify.ps1

跑完看:

node scripts\session-steps.mjs "$env:USERPROFILE\.dsh\sessions"

被替换的那一步特征:usage=none、call id 以 call_hm_ 开头、没有文本。

实测

基准:scripts/bench.ps1,同模型、同提示、同任务、每臂独立副本。任务是"修好让 node check.js 通过"。

结论先说:机制能用,采纳稀薄,短任务上不划算。

| 场景 | 不装 paid / raw | 装 paid / raw | 替换 | paid | raw | |---|---|---|---|---|---| | 短任务 5–6 步(3 组) | 3,920 / — | 4,489 / — | 1 | +14.5% | — | | 长任务 11–16 步(3 组) | 12,728 / 281,016 | 14,306 / 256,994 | 1 | −12.4% | +8.5% |

两个口径必须分开看:

  • paid = 未命中缓存的输入 + 输出,接近账单;
  • raw = 再加上 cacheRead,接近"上下文被重放了多少 token",也是论文用的口径。

同一次实验,两个口径符号相反。而且长任务里 raw 的 +8.5% 主要来自插件臂少了 4 次请求(30 vs 34), 不是来自那 1 次替换——两个臂的步数本来就有方差,这个数还不能归因。

采纳取决于指令的具体程度,不是通道:

| 指令 | 写表 | |---|---| | 系统提示·抽象条件式 | 0 / 6 次运行 | | 系统提示·MUST + 移到末尾 | 0 / 3 | | 系统提示·具体触发(0.4.0 现在的默认) | 2 / 6(其中 1 次成功替换) | | 用户消息·指名具体节点 | 2 / 3 |

写出来的表长这样,随后自己触发了一次替换(证书完整):

{"kind":"bank","body":[{"label":"verify","after":"$action","tool":"pwsh","guard":{"exit":0}}]}
{"kind":"certificate","decision_id":"verify",
 "predecessor_receipt":{"call":"chatcmpl-tool-b9a4…","error":false,"exit":0},
 "exact_args":{"command":"node check.js","description":"Re-run the project check script"},
 "tool_receipt":{"error":false,"head":"OK\n"},
 "bypassed_callback":"session-fe81…#request:5"}

边际收益:同一会话内算,不跨臂比

跨臂比较会把「机制的效果」和「模型这次多走了几步」混在一起,所以改用会话内核算(scripts/accounting.mjs): 每处替换用它后面那次请求的用量来定价(同一会话、同一前缀)。

三组长任务会话的实测:

session 1   steps= 6  subs=0  raw= 49,425
session 2   steps=13  subs=1  raw=110,248   savedRaw=9,280  paid=6,312  savedPaid=448
session 3   steps=12  subs=0  raw= 97,321
合计        requests=30 subs=1 savedRaw=9,280  savedPaid=448

对照提示词成本(约 190 token/请求):

| 口径 | 替换省下 | 说明文字成本 | 净 | 回本所需采纳率 | |---|---|---|---|---| | raw | 9,280 | 190 × 30 = 5,700 | +3,580(+1.4%) | 每 49 次请求 1 次 | | paid | 448 | 190(只付一次) | +258(+2.0%) | 每 2.4 次请求 1 次 |

也就是说:单看机制,它是净正的,但只有 1–2%;而两臂的总量方差(raw ±30k、paid ±1.5k)远大于这个效应, 所以前面几次跨臂对照才会出现符号相反的结果。

一次替换到底值多少(单样本实测)

同一条会话里,替换掉的是第 5 次请求,它前后的请求长这样:

step 4  in=159  out=125  cache=8704     ← 写出决策表的那次请求
step 5  usage=none                      ← 被替换掉的请求
step 6  in=321  out=127  cache=8832     ← 若没替换,第 5 次大致就是这个形状

所以一次替换:

| 口径 | 省下的量 | 与上下文的关系 | |---|---|---| | raw(in+out+cacheRead) | ≈ 9,300 token | ≈ 1 倍上下文,随对话线性增长 | | paid(in+out) | ≈ 450 token | ≈ 5%,因为历史 append-only、缓存命中率 95%+ |

按这个数算盈亏平衡:说明文字约 190 token/步。

  • raw 口径:每 ~47 步需要 1 次替换才回本;
  • paid 口径:每 ~2.4 步需要 1 次,实际做不到。 为什么还是不省:这类任务 5–6 步,一次替换省下的是"一次未命中缓存的请求"(约 230 token),而系统提示里那段说明每轮都要重放(约 190 token × 6 轮 ≈ 1.1k)。固定成本大于单次收益,所以净亏 14.5%。

它在长任务里才可能划算:步数越多、缓存命中越差,单次替换省下的越多,而提示词成本被摊薄。

第一轮 0.4.0 基准出现过一次 -189%,原因是某次运行的首个请求 in=6,493(同批次其他首请求约 900), 属冷启动异常,重跑同一脚本后收敛到 -1.4%,上图取重跑值。

所以:省 token 的前提仍然是"模型愿意写表",而在这批任务上它一次都没写。下一版要解决的不是替换 逻辑(已经可用),而是让写表成为模型的任务习惯——preset 技能是最直接的路。

已知限制

  • 选择器没有 logprobs,只能整标签精确匹配;比论文的"单 token 概率"更保守,也更粗糙。
  • 作者的 token 无法从回复里单独计量(块已被剥离),账本只记节点数量。
  • 决策表只在内存,进程重启即失效;失效后退化为原 Harness。
  • guard 失败不会"重试",而是让整张表作废、交回模型——这是刻意的,避免带着偏差继续跑。