Liangebra/dsh-smart-compact ↗★ 0
dsh-smart-compact
Custom DSH CompactionEngine backend: configurable threshold prompting, mandatory fallback at the limit, DCP-inspired dedup/purge, custom summary prompt, and /compact like the original. Zero external state — everything is rebuilt from the append-only session log.
安装
此插件尚未提供可验证的 bundle,或兼容性检查未通过。请先阅读仓库说明。 阅读完整 README ↗
说明文档
阅读完整 README ↗dsh-smart-compact
DeepSeek Harness 的自定义 CompactionEngine 后端:
可配置的阈值提示、达到上限时的强制自动压缩安全网、DCP 风格的去重 / 清理建议、
完全可配置的摘要提示词,以及保持原版行为的 /compact 命令。
为什么叫这个名字? 三大策略族——重复工具输出去重、报错调用清理、模型驱动的
compress工具与 nudge 提示——源自 DCP(Dynamic Context Pruning,动态上下文修剪), 即 opencode-dcp 保持长会话低成本的做法。但机制不同:opencode-dcp 只修剪 发给模型的载荷、不改动会话历史;本引擎挂在 DSH 的CompactionEngine槽位上, 在会话日志中写入标准的持久化压缩 bracket(零外部状态、原文永不删除)。 "smart-compact" 命名的是机制;DCP 的血统在策略模块(dcp.ts)和dcp_status工具里。
零外部状态。 没有内核、没有账本文件、没有数据库、没有需要与日志保持同步的内存 状态机。每次压缩都是 append-only 会话日志里的标准持久化 bracket:
compaction/start → compaction/summary → user/message(surface 替换) → compaction/end
原始事件永不删除;块信息按需从日志重建(rebuildBlockLedger),所以崩溃、重启或
恢复会话后看到的状态始终一致。
挂载
每个 realm 只挂一个压缩后端——先禁用自带的 compaction-basic 行,再把它加进你的
组合文件(如 ~/.dsh/profiles/web/cordis.patch.yml):
- id: compaction-smart
name: 'dsh-smart-compact'
config:
thresholdRatio: 0.5
mandatoryRatio: 0.9
summarizationMaxTokens: 8192
preserveRecent: 5
dedupEnabled: true
purgeErroredTurns: 4
summaryPrompt: |
Write ONE dense technical summary of the content below.
Preserve exact paths, commands, error strings, identifiers,
decisions and pending work; discard spent detail.
{content}
插件以 ctx.compaction 注册。改完组合后重启 dsh web(web profile 没有 HMR)。
配置
| 选项 | 默认 | 含义 |
|---|---|---|
thresholdRatio |