zzzxxxxxxxxxx/dsh-dcp ↗★ 0

@zzxxxxxx/dsh-dcp

Dynamic context pruning for DeepSeek Harness — model-driven compaction and duplicate-output pruning. | DeepSeek Harness 的动态上下文裁剪:模型驱动的压缩与重复工具输出去重 适合需要优化上下文窗口、减少重复工具输出的 DeepSeek Harness 用户。

Package
@zzxxxxxx/dsh-dcp
Compatibility
Unverified
Harness peer range
>=0.2.0-rc.2
Cordis peer range
~4.0.4
Version
0.1.2
License
AGPL-3.0
Last updated
Oct 5, 2026

Install

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:zzzxxxxxxxxxx/dsh-dcp

配置

设置 → DCP 上下文(宿主 settings.section,id dsh-dcp)列出 12 个可热改字段,写入即时生效;其余 8 个写在插件行的 config: 里,改完重启。

{
  "pruneNotification": "minimal",   // off | minimal
  "protectedFilePatterns": [],
  "turnProtection": { "enabled": false, "turns": 4 },
  "experimental": { "allowSubAgents": false, "customPrompts": false },
  "commands": { "protectedTools": ["subagent*", "skill", "compact", "write", "edit", "plan_enter", "plan_exit"] },
  "manualMode": { "enabled": false, "automaticStrategies": true },
  "compaction": {
    "permission": "allow",          // allow | ask | deny
    "maxContextLimit": "67%",       // 窗口百分比,或绝对 token 数
    "minContextLimit": "33%",
    "modelMaxLimits": {}, "modelMinLimits": {},
    "nudgeFrequency": 5,
    "protectedTools": ["subagent*", "skill"],
    "protectUserMessages": false,
    "recall": true
  },
  "strategies": { "deduplication": { "enabled": true, "protectedTools": [] } }
}
字段默认说明热改
pruneNotification"minimal"自动清理后的报告:minimal 一行计数,off 只留在面板✓
protectedFilePatterns[]路径 glob:命中的调用不被去重改写,压缩时其正文进摘要附录
turnProtection.enabledfalse不把最近几轮列入清理候选✓
turnProtection.turns4保护多少轮✓
experimental.allowSubAgentsfalse让 DCP 也裁剪子代理会话(默认不动它们)✓
experimental.customPromptsfalse允许 $DSH_HOME/dcp-prompts/ 下的提示词覆盖✓
commands.protectedToolssubagent* skill compact write edit plan_enter plan_exit三张保护表之一;同时管辖 /dcp-compact 的 sweep 与面板
manualMode.enabledfalse停发提醒,只在你显式请求后允许压缩一次✓
manualMode.automaticStrategiestrue手动模式下是否继续去重✓
compaction.permission"allow"allow 直接执行;ask 走宿主审批;deny 不注册模型工具
compaction.maxContextLimit"67%"强提醒阈值:高于它要求立刻压缩✓
compaction.minContextLimit"33%"弱提醒阈值:低于它完全不提醒✓
compaction.modelMaxLimits{}按 "provider/model" 覆盖强阈值
compaction.modelMinLimits{}按 "provider/model" 覆盖弱阈值
compaction.nudgeFrequency5每多少个对话节点最多提醒一次✓
compaction.protectedToolssubagent* skill正文逐字进摘要附录,并豁免去重
compaction.protectUserMessagesfalse用户消息逐字保留(粘贴的大段提示词不会被压掉)✓
compaction.recalltrue是否注册 recall 工具
strategies.deduplication.enabledtrue是否改写重复调用的旧输出✓
strategies.deduplication.protectedTools[]额外的去重豁免表

几条语义:

  • 百分比阈值需要路由上报 context window;上报不了就不提醒,不会退化成固定 token 数。
  • 三张「受保护工具」表都会被去重读取:写进 compaction.protectedTools、commands.protectedTools 或 strategies.deduplication.protectedTools 中任意一张,该工具的旧输出都不会被自动改写(commands 的默认表因此让 write/edit 天然免疫去重)。
  • protectedFilePatterns 同时作用于去重与压缩:命中的调用不会被改写,压缩时其正文进摘要附录。glob 是 fail-open 的:单个待匹配值超过 8192 字符、单条 pattern 超过 4096 字符,或匹配步数超过 1 048 576,一律按「不匹配」处理——后果是少保护,不会多保护;收集一次调用声明的路径时最多扫描 10000 个节点。
  • experimental.customPrompts 打开后,可用 $DSH_HOME/dcp-prompts/overrides/.md 覆盖 4 份提示词(compact、compact-targets、context-limit-nudge、turn-nudge);同时插件会把内置文本播种到 $DSH_HOME/dcp-prompts/defaults/.md 作为参考副本——defaults/ 不参与加载,只供对照,整个目录不存在时会重新播种;nudge 的「这不是用户发言」前缀由插件在载入时补回,删不掉。开关与覆盖文件的改动即时生效,无需重启。
  • 排障开关 DSH_DCP_TRACE:设成文件路径后,插件把每次判定按行追加进去(为什么提醒、为什么跳过及其输入、投递结果、配置与提示词是否真的重载、每回合自动清理的产出)。不设就一个字节都不写;没开 trace 时插件不留任何文件。宿主日志(所有插件,不止 DCP)用 dsh-logger-panel 看。
  • 本插件仍在早期,可能还有 bug。遇到问题请到 Issues 反馈,并附上 DSH_DCP_TRACE 生成的日志——它把判定过程写得比会话记录清楚得多。