MaudieHakimi/dsh-entry-shaper ↗★ 0
dsh-entry-shaper
在发送前对会话元素进行排链塑形 适合需要优化会话发送结构、避免断点税的开发者。
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:MaudieHakimi/dsh-entry-shaper说明文档
阅读完整 README ↗配置
配置一律放在 ~/.dsh-entry-shaper.config.json,不要写进 cordis.patch.yml。
原因:patch 里含 config: 行会让市场无法热挂载(dshmarket/lib/hot.js:295),
只能重启生效;热配置文件则由本插件按 mtime 热读 ⇒ 改配置不用重启 ✓。
{
"enabled": true, // 总开关(任何类别都不动就设 false)
"shapeReasoning": true, // 是否塑形推理这一类(旧名 dropReasoning 仍兼容)
"policy": { // 按类别各给一条 op 序列(文本 → 文本 的纯函数链)
"reasoning": { "ops": [{ "op": "extract", "maxChars": 240 }] },
"toolResult": { "ops": [{ "op": "keep" }] },
"toolArgs": { "ops": [{ "op": "keep" }] },
"assistantText": { "ops": [{ "op": "keep" }] }
},
"cache": { "enabled": true, "path": "~/.dsh-entry-shaper.cache.jsonl", "maxBytes": 8388608 },
"proxy": { "enabled": true, "provider": "deepseek-shaped", "upstream": "deepseek-official" },
"opTimeoutMs": 8000,
"logPath": "~/.dsh-entry-shaper.log"
}
打开代理只需改这里(proxy.enabled: true),本插件会惰性注册该路由 —— 不必重挂载、
不必重启 ✓。随后把会话或默认 provider 换成 proxy.provider(默认 deepseek-shaped)即生效。
⚠️ 路径里不要写
~。配置文件里的路径是原样使用的(没有 shell 展开), 写"logPath": "~/.dsh-entry-shaper.log"会在当前目录下建一个名叫~的目录 ✗。 省略这些键(推荐,默认值已经是正确的绝对路径),或写绝对路径 (如"D:/logs/shaper.log")。
免重启的三个开关
| 想做什么 | 怎么做 | 生效 |
|---|---|---|
| 全部停手(原样转发) | 建空文件 ~/.dsh-entry-shaper.OFF | 立刻,不用重启 |
| 只停某一类 | 把该类别的 ops 改成 [{ "op": "keep" }] | 下一次请求 |
| 完全卸载 | 市场里关掉插件(或从 dsh.profile.bundles 移除) | 立刻(热挂载) |
⚠️ 改配置会改变前缀形态 ⇒ 下一次请求整份按全价重算一次(约 $0.2)。 所以请一次定好,别频繁来回调。
复制即用的配置片段
// ① 默认:推理只留决策句(最省,也最有损)
"reasoning": { "ops": [{ "op": "extract", "maxChars": 240 }] }
// ② 保守:保留推理的真实开头(不按句式挑,模型更容易接上)
"reasoning": { "ops": [{ "op": "head", "chars": 800 }] }
// ③ 两道闸:先抽取再兜底截断
"reasoning": { "ops": [{ "op": "extract", "maxChars": 400 }, { "op": "truncate", "maxChars": 300 }] }
// ④ 完全不动推理
"reasoning": { "ops": [{ "op": "keep" }] }
// ⑤ 工具结果只留首尾(注意官方 tool-result-pruner 已在做,别重复)
"toolResult": { "ops": [{ "op": "truncate", "maxChars": 1024 }] }
// ⑥ 你自己的脚本(任何语言)
"reasoning": { "ops": [{ "op": "exec", "command": "python", "script": "D:/shaper/mine.py" }] }
// ⑦ 让 LLM 来压
"reasoning": { "ops": [{ "op": "http", "system": "压成 3 行要点,保留路径与数字。", "maxTokens": 200 }] }
// ⑧ 进程内自定义算法(免重启)
"reasoning": { "ops": [{ "op": "inline", "use": "code", "code": "return text.split('\\n').slice(-5).join('\\n')" }] }