nuwa-skill
alchaincyf
你想蒸馏的下一个员工,何必是同事。蒸馏任何人的思维方式——心智模型、决策启发式、表达DNA。Distill how anyone thinks.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:lucaixia1982/dsh-token-saver
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
DeepSeek Harness 省钱插件:在你发出的自然语言指令进入模型之前做无损瘦身,并把省下的 token 与金额显示在左侧栏。
A DeepSeek Harness cost-saving plugin: it losslessly slims your instruction before the model sees it, then shows the saved tokens and money in the left sidebar.
指令瘦身(agent/pre-step 钩子)
只做不改语义的删除:行尾空格、连续 3 个以上空格、连续 3 个以上空行、连续重复的非空行、重复段落(≥60 字符)、结尾寒暄(谢谢/麻烦了/thanks…)。
代码块(``` 围栏)内容一字不动,运行时上下文消息一律跳过,单条消息瘦身收益不足 15 token 或不足 4% 时保留原文。
改写只影响进入转写的新消息,历史消息不会被改写。
真实用量记账(session/event → assistant/message)
每次模型调用记录输入未命中 token、输入命中缓存 token、输出 token。DeepSeek 的 usage.inputTokens 只含未命中部分,命中部分单独在 cacheReadTokens,两者相加才是本次输入总量——这个坑插件已经处理。
左侧栏徽章(sidebar.footer.action,id token-saver)
宽栏显示 本次 ¥0.02 · 累计 ¥13.11,窄栏(56px 轨道)只显示本次。悬停八行明细:本次会话、累计省(缓存折扣 + 指令瘦身)、开启前/后对比、累计命中、调用次数、缓存前缀重建次数、瘦身条数。
「本次」按最近一次有模型调用的会话统计,随 ~/.dsh/dsh-token-saver.json 持久化,重启不清零,只保留最近 20 个会话。
缓存健康度
记录 request/header 里 startsSeries 的次数。每重建一次请求序列,可复用的前缀就作废一次、下一次调用几乎全价,所以这个数字越小越好。
价格写死在 index.js 的 DEFAULTS:priceInputMiss: 2、priceInputHit: 0.2、priceOutput: 3(元/百万 token,DeepSeek 官方档)。
指令瘦身省下的 token 会一直留在会话请求前缀里,后续每次调用都会再省一次,累计值按调用次数累加。
dsh-token-saver(包名 @acmepoyen/dsh-token-saver)一键安装;plugin_manager 的 install_bundle(target 用绝对路径);npm i @acmepoyen/dsh-token-saver 后按上面的方式挂载。安装后左侧栏底部会多出一个徽章,不需要重启 DSH 桌面端;改插件代码才需要。
| 文件 | 作用 |
|---|---|
index.js |
宿主半:瘦身 + 记账 + HTTP /plugins/dsh-token-saver/stats |
client.js |
客户端半:侧边栏徽章,5 秒轮询 stats |
cordis.patch.yml |
装载补丁,插入 id: dsh-token-saver |
locale/*.json, icon.svg |
名称与图标 |
聚合数据落在 ~/.dsh/dsh-token-saver.json。
DEFAULTS 并重启。config: { enabled: false },记账与侧栏照常工作。assistant/message 里带 usage 的调用;子代理调用同样计入累计。源码目录跑 deploy.ps1 可把宿主半写成薄壳(带 ?v=时间戳 动态 import)指向工作区源码,再 set_plugin false → true 让装载器重启这一项。已安装位置是拷贝不是软链,改源码不改安装位置就永远不生效。
禁止用 PowerShell 5.1 的 Get-Content / Set-Content 改这两个 .js 文件:它按 ANSI 解码 UTF-8,中文会被写成乱码。改代码用编辑器或 node 脚本,编码一律 UTF-8 无 BOM。
agent/pre-step): removes trailing spaces, runs of 3+ spaces, runs of 3+ blank lines, consecutive duplicate lines, duplicated paragraphs (≥60 chars) and trailing pleasantries — never inside ``` fences, never on runtime-context messages, and only when the gain is ≥15 tokens and ≥4%.session/event → assistant/message): records cache-miss input, cache-hit input and output per call. DeepSeek reports usage.inputTokens as the miss-only part with hits in cacheReadTokens; both are added for the true input total.sidebar.footer.action, id token-saver): wide mode shows 本次 ¥0.02 · 累计 ¥13.11; the 56px rail shows this session only. Hover reveals eight lines, including the pre/post-enable comparison, cache hit rate, call count and how many cache prefixes were rebuilt.request/header.startsSeries — every rebuilt request series drops the reusable prefix, so lower is better.Prices are constants in DEFAULTS (index.js): input miss ¥2, input hit ¥0.2, output ¥3 per million tokens (DeepSeek list price).
Slimmed tokens stay in the request prefix, so they are saved again on every later call; the all-time figure compounds per call.
Install @acmepoyen/dsh-token-saver from the dshfind marketplace, or hand the package directory to plugin_manager's install_bundle, or npm i @acmepoyen/dsh-token-saver and mount it the same way.
DEFAULTS when DeepSeek changes them.~/.dsh/dsh-token-saver.json.MIT
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: prompt-cache。