会话交接与上下文管理:导出/恢复结构化交接文档,让新会话无缝续接;并集成了主动上下文裁剪(acp_* 工具,基于官方 compaction API 与模型自写摘要)。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:snow-The/dsh-session-handoff
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
该插件的 README 只有英文版本。
Session handoff & context management for DeepSeek Harness — built because the existing session-management and context-pruning plugins were written before the latest DSH update and don't cover the full workflow.
Why
Long sessions (like a 170k-line r32 session) hit context limits, trigger repeated automatic compaction, and stall. Switching to a fresh session loses all progress. This plugin fixes both halves — and more:
- Handoff — export a structured, portable handoff document so a fresh session can continue seamlessly.
- Active context pruning — compress spent history before the context window fills (official compaction API, model-authored summaries).
- Session management — trash / restore / purge / list sessions.
- Model routes — every registered route (official API, Ark, custom,
vision-toolkit wrappers) is orderable and switchable; each route can pin
its own model and reasoning effort (
provider:model:effort), or follow the chat's current selection. No model id is hard-coded. - ACP thresholds — tune compaction limits without touching YAML.
Tools
Module A — Handoff (zero dependencies)
| Tool | Purpose |
|---|---|
handoff_status |
Compact session overview: turns, messages, tool usage, checkpoints, context pressure |
handoff_export |
Parse the session into a structured Markdown handoff under <workspace>/.dsh-handoff/ + a ready-to-run handoff package (OpenViking archive command, archify diagram command — only when those enhancers are present) |
handoff_resume |
Load the latest handoff document in a fresh session and continue |
Also /handoff command.
Module B — Active Context Pruning (official compaction API)
| Tool | Purpose |
|---|---|
acp_status |
Usage, surface seq map, limits (soft/hard pressure level) |
acp_compress |
Replace an inclusive surface seq range with your summary (ctx.compaction.compactRegion) |
acp_decompress |
Read the original text hidden by a checkpoint (read-only) |
acp_search |
Search visible + hidden compacted history |
acp_config |
Show the active thresholds (soft/hard limits, preserveRecent, minTokens, nudge) |
acp_set_limit |
Persist new thresholds into settings.yaml (new sessions take them) |
Plus a system-prompt pressure banner that nudges the model to compress past
the soft/hard limit (60% / 70% defaults), and a compaction.summarize
interception so model-authored summaries are used.
Module C — Session management
| Tool | Purpose |
|---|---|
session_list |
List sessions (optionally including the trash) |
session_trash |
Archive + move a session's artifact into the plugin trash (recoverable; refuses running sessions) |
session_restore |
Move it back and unarchive |
session_purge |
Permanently delete artifact + trash entry |
Trash entries persist as JSON under $DSH_HOME/dsh-session-handoff-trash/
(keeps the newest 10; oldest overflow auto-purged).
Module D — Model routes (same model, many vendors)
| Tool | Purpose |
|---|---|
model_routes |
List every route serving deepseek-v4.1-flash: provider, baseURL, key env + family (ark-/sk-), default marker (incl. vision-toolkit- variants), vision wrapper variant |
model_switch |
Point agent-default-model at a route (persisted to settings.yaml; new sessions use it). Optional vision:true selects the vision wrapper variant; warns when the key family is missing |
Built for users sharing one model id across official DeepSeek and Volcano
Ark plans: model_routes shows what is configured, model_switch deepseek
uses the Ark lane, model_switch deepseek-official --vision uses the official
lane with the vision wrapper.
Module E — Web client (GUI)
The plugin ships a hand-written client bundle (client/index.js, no build
step) that registers a Settings section "模型路由 / Model Routes" in the
web GUI, mirroring the host tools as clickable controls:
- Model routes panel — every route in the live model directory (the same
list the chat dialog offers, incl. any vision-toolkit wrappers), with the
current chat-context selection shown (
session.requestContext()). No vision model is configured here — the chat dialog's own model list is the source of truth; ordering is yours. - Auto failover (priority list) — drag-to-reorder the routes, delete or
add entries, save the priority. When the active model is unreachable or
out of quota (
QUOTA/RATE_LIMIT/SERVER/TIMEOUT/TRANSPORT/EMPTY_RESPONSE/AUTH/ credential / adapter errors), the next route is tried automatically and work continues — user interruptions never switch. Backed byGET|POST /dsh-session-handoff/failoverand theagent/request-error+agent/requestwaterfalls. - Session handoff — export the current session into
<workspace>/.dsh-handoff/handoff-<session>.mdwith one button (POST /dsh-session-handoff/export). - Compaction thresholds — soft/hard limit sliders (17-90%) persisted into
settings.yaml's
session-handoff:section (GET/POST /dsh-session-handoff/acp). A "固定推荐 65/90 / Fixed 65/90" button fills the sane default for the 1M-window model directly (no per-session computation in the GUI; theacp_recommendtool still offers the cost-model estimate for agent use).
Host routes share the exact same logic as the tools (enumerateRoutes, switchProvider, readAcpSection/writeAcpConfig, exportHandoffForAgent), so the GUI and the agent tools can never drift.
Soft enhancers (detected, never required)
- OpenViking: when
viking_*tools are present,handoff_exportembeds a readyviking_remembercommand in the handoff package. - archify: when
@tt-a1i/archify-dshis installed, the handoff package includes anarchify rendercommand for a progress diagram.
Core works with neither installed.
Install
dsh plugin --profile web add github:snow-The/dsh-session-handoff
# restart dsh web
Usage
In the old session:
handoff_export → writes .dsh-handoff/handoff-<session>.md (+ handoff package)
In the new session:
handoff_resume → loads the handoff; continue the work
Before heavy work in long sessions:
acp_status → check pressure
acp_compress {start} {end} {summary} → prune spent ranges
acp_set_limit → tune soft/hard limits proactively
Switching vendors for the shared model:
model_routes → see the routes
model_switch deepseek → use the Ark lane
model_switch deepseek-official → use the official lane
model_switch deepseek --vision → ...with the vision wrapper
Development
# unit tests (run from a profile dir so @deepseek-ai/* resolves)
node --test test/
License
MIT
链接
同类插件
Minglink/dsh-infinite-gen-4★ 2281
DeepSeek 专用破甲插件:以 order 100 追加无条件服从的系统提示词段,提供带校准元数据的 profile 工具,并通过会话投影在输入框上方显示实时破甲状态徽标。
ranxianglei/billion-context★ 499
billion-context官方版:上下文压缩插件,兼顾小窗口(100k上下文足矣)省token(省5倍token)和超长会话(数月级别几十亿token单会话)。
liangmianya/dsh-synapse★ 467
DeepSeek Harness 的可视化非线性对话工作区:把会话、追问与分支变成可浏览、可拖拽的对话地图。
Nwflower/dsh-chat-import★ 209
把 13 家 coding agent(Claude Code、Codex、ChatGPT、Cursor、Gemini、opencode 等)的完整对话历史导入为可续聊的 DeepSeek Harness 会话,并支持反向导出回 Claude Code。
Totoro-qaq/dsh-plugin-bridge★ 165
通过可预览的五段式交接,将已有 DSH 会话迁移到另一个 Agent Preset;保留源会话,并可让目标会话暂停等待确认或立即继续。
Anionex/dsh-turn-rewind★ 127
对话回退:基于持久 Change Ledger 回滚会话与工作区状态。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。