orangeofcarl0-sys/dsh-fresh-start
DSH /fresh 命令:总结对话,开始新会话,归档旧会话。
Project Overview项目介绍
This is a DSH plugin that adds the /fresh command. It summarizes the current conversation, creates a new session that inherits the current working environment, and archives the old session to free memory. Use it when large conversations cause lag or high memory usage. Note that summary may fail if the conversation is too large for the model context window.
这是DeepSeek Harness(DSH)的一键会话刷新插件,提供/fresh命令,可一键总结当前对话、创建继承当前工作环境的新对话、归档旧对话释放内存,适合大体积对话导致卡顿、内存占用过高时使用。需注意超大型对话超出模型上下文窗口时,总结可能失败。
请帮我了解并安装插件:【dsh-fresh-start】【https://github.com/orangeofcarl0-sys/dsh-fresh-start】
Send this message to DSH in your current session. CLI install commands may not be accurate across systems — DSH will figure it out for you.把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。
Or use CLI install (for developers)或使用命令行安装(适合开发者)
CLI Install命令行安装
dsh plugin --profile web add github:orangeofcarl0-sys/dsh-fresh-start
把 orangeofcarl0-sys/dsh-fresh-start 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
dsh-fresh-start
DSH(DeepSeek Harness)/fresh 命令:一键总结当前对话 → 开启新对话(自动跳转)→ 归档老对话。
为什么需要它
超大会话(数十万事件)工作一段时间后,live 事件树越滚越大,每次构建上下文都更慢、更占内存—— 在一个 67 万事件的会话里继续工作,卡顿和内存压力会持续恶化。
/fresh 把这个收尾动作变成一键操作:把历史压缩成一份自然语言摘要,开一个继承当前工作环境
的新会话并把摘要作为开场消息,然后归档老会话释放内存、自动跳转到新会话继续工作。
快速开始
安装
dsh plugin --profile web add github:orangeofcarl0-sys/dsh-fresh-start
插件源为 GitHub 仓库(不走本地路径)。之后插件发新版,同步仓库后更新:
dsh plugin --profile web update dsh-fresh-start
重启 dsh web,日志出现 [fresh-start] installed: /fresh command registered 即成功。
client 插件会随 dsh.client 声明自动进入浏览器清单(/plugins/dsh-fresh-start/client.js
返回 200)。
若 profile 的
cordis.patch.yml里已有本插件的手工挂载行,请先删除,否则会双实例。
使用
在对话输入框输入 /fresh,可选带 preset 参数:
/fresh # 继承当前会话的 preset
/fresh standard # 用指定 preset 开新会话
| 输入 | 目标 preset | 模式 |
|---|---|---|
/fresh standard |
standard |
标准模式 |
/fresh ptc(或旧输入 code) |
ptc |
PTC 模式(Code Mode SDK) |
/fresh minimal |
minimal |
极简模式 |
/fresh create / /fresh creator |
cordis |
创造模式 |
dsh 0.1.2-alpha.5 把内置
codepreset 更名为ptc且不留别名;本插件将ptc直接作为 preset id 使用,code仅作旧输入兼容映射到ptc。
指定不存在的 preset 时命令直接报错,不会静默回退到继承值。
/fresh 的完整流程
/fresh ──▶ ① 压缩(Compact-First)──▶ ② 对话式总结 ──▶ ③ 创建 seeded 新会话
│
自动跳转 ◀── ⑤ client 侧匹配 ◀── ④ 归档老会话
① 压缩(Compact-First)
若当前 preset 挂载了宿主压缩引擎(standard/code/cordis),先 compactNow 强制压缩当前
会话——deriveMessages() 跟随 surface shadow 收紧,后续总结请求体显著缩小,并直接复用
压缩摘要。引擎不可用(minimal)、agent busy、无可压缩范围或引擎抛错时安静降级为纯对话式
总结,不阻断流程(spec:docs/COMPACT_FIRST_SPEC.md)。
② 对话式总结
直接提取 dsh 上传给 LLM 的当前上下文(session.requestHeader() 的 system +
session.deriveMessages() 的全部消息,已压缩时为收紧后的上下文),用一条简单指令让 LLM
总结成自然语言摘要。
区别于 dsh 原生 /compact(用工程 checkpoint 指令 + token 比较,普通对话上常失败):
本实现把 compact 作为前置收紧、对话总结作为最终 seed 生成器。
③ 创建 seeded 新会话
ctx.agents.create 创建新会话:继承老会话的 cwd 与 agent preset(/fresh <preset>
可覆盖),摘要作为新对话的开场消息(seed),新会话的 header.parentSession 指向老会话。
④ 归档 + ⑤ 自动跳转
ctx.workspaceRegistry.archiveSession 归档老会话(释放 live 事件树内存);配套的
client 插件监听归档事件,按 parentId 找到新会话并 ctx.sessions.open 自动跳转过去。
每一步独立、失败降级不阻断后续——例如总结失败时仍会开新对话 + 归档(只是新对话不带 摘要),完整结果在命令返回文本里。
架构:host + client 双端
dsh-fresh-start/
├── lib/
│ ├── index.js # host 侧:/fresh 命令(总结 + 创建 + 归档)
│ └── client.js # client 侧:监听归档事件,自动跳转
├── cordis.patch.yml # dsh bundle 挂载清单
├── docs/COMPACT_FIRST_SPEC.md
└── tests/
- host 侧(
lib/index.js,经cordis.patch.yml挂载进 cordis bundle):/fresh命令本体——压缩 + 总结 + 创建(带摘要 seed 与parentSession标记)+ 归档。 - client 侧(
lib/client.js,随dsh.client声明进入浏览器):监听host/archived-sessions-changed,归档发生时按parentId匹配新会话并自动ctx.sessions.open跳转。含时序兜底:归档广播与新会话列表同步是两个通道,若新会话 尚未同步则进 pending,等会话列表更新后补跳。
兼容性
dsh 版本
以 0.1.5-rc.2 为准(2026-09-11 验证轮,1.3.5)。插件依赖 dsh 内部 API
(ctx.agents.create / ctx.workspaceRegistry / ctx.sessions.open /
session.deriveMessages() 等),dsh 升级可能导致兼容性问题。
0.1.5-rc.1 → 0.1.5-rc.2 验证结论:本插件用到的七个包(dsh-agent-presets /
dsh-llm / dsh-session / dsh-compaction / dsh-permission-presets /
dsh-client-modules / dsh-command-compact)发布产物逐字节比对,lib 与全部数据
目录完全一致,仅 package.json 版本号与依赖范围重指;零代码改动,仅依赖声明与
文档对齐(peers/devDeps 升 ^0.1.5-rc.2,cordis ^4.0.2 不变)。
0.1.5-alpha.1 → 0.1.5-rc.1 验证轮:结论见 CHANGELOG 1.3.4。
1.3.0 对 alpha.5 的适配点(沿袭仍有效):
@deepseek-ai/dsh-agent-presets#resolveSessionPreset已删除 → 内联等价实现 (agent-preset/selected事件倒序扫描取data.agentPreset,回退header.agentPreset,与宿主投影语义一致);- 内置 preset
code更名ptc且不留别名 → 别名表反转(/fresh ptc直接命中 内置 id,/fresh code作旧输入兼容映射到ptc); - compaction 变为全局服务 → Compact-First 优先
ctx.compaction(/compact同款 seam),rc.2 的 per-presetserviceFor形态兜底; @deepseek-ai/dsh-client-runtime在 alpha 线停止发布 → 移除 peer 依赖与dsh.client.inject引用(client 半边零宿主 import,注册方式与 alpha.5 client-modules 机制一致,不受影响)。
其余用到的宿主 API(agents.create 的 seed/meta/setup 形状、
workspaceRegistry.archiveSession / resolveByPath / attachSession、
commands.register、session.requestHeader / deriveMessages、BlockAssembler /
createUserMessage、agentPresets.resolve / mount、permission seeded 分支)逐一
核对 alpha.5 均未变。
历史:rc.7 → rc.8、rc.1 → rc.2 时代的逐包发布产物比对均为增量变更(rc.2 中
sessions.create 收窄的参数本插件从未使用)。
1.4.0 起移除了 dsh-std Community v0.15 清单(原
dsh-plugin.json/ 占位入口 / 结构测试):std 生态自 2026-08-31 后停更,其adapter-dsh的 peer 窗口 (>=0.1.2-alpha.2 <0.1.3)与本插件当前宿主线(0.1.5)不兼容,该轨道从未在真实 宿主中生效;待生态恢复并补齐协议后再评估接入。移除不影响/fresh任何功能。
开发与测试
npm install # 安装 devDependencies(@deepseek-ai/* 0.1.5-rc.2 线,来自 npm)
npm test
测试在 @deepseek-ai/* 依赖 0.1.5-rc.2 线下运行:
tests/smoke_test.mjs(57 断言):命令注册 / 全流程 / 总结失败降级 / 新会话失败仍归档 / 无 workspaces 降级 /parentSession标记 / 不污染deriveMessages()返回值 / provider-model 不完整时回退与降级 / 取消中止 / header 异常结构化报错 —— ALL PASStests/client_test.mjs(9 断言):归档后按 parentId 自动跳转 / pending 兜底补跳 / 不相关归档不跳 / open 异常吞掉且不无限重试 —— ALL PASS
已知局限
- 总结依赖
session.deriveMessages()(dsh 上传的完整上下文),超大会话的上下文若超出 模型窗口,总结可能失败(此时仍会开新对话 + 归档,只是新对话不带摘要)。
更新日志
见 CHANGELOG.md。
liangmianya/dsh-synapse
alaliqing/claude-paper
omdsh-dev/dsh-annotation
Anionex/dsh-turn-rewind
hanshenmesen/dsh-turn-delete
qkycir-123/dsh-run2skill
Tyan66666/billion-context-dsh
PKUfudawei/dsh-capability-menu