Back to home@Funnyvalentine00

dsh-session-continue

No description

Stars
1
Language
TypeScript
Created
Aug 18, 2026
Updated
Aug 18, 2026
GitHub repo

Introduction

@dsh-external/dsh-session-continue

一个 DSH 超级模组(toolkit 形态):按项目/任务关键词自动检索历史会话,并把旧会话的上下文压缩成 handoff 交给当前 Agent,从而继续未完成的工作。

解决什么问题

在 DSH 中,新建对话后默认不会自动携带旧对话的聊天记忆。
如果你说“继续之前那个项目”,当前 Agent 并不知道你指的是哪一次对话、已经做到哪一步、留下了什么结论。

这个插件提供了一个面向模型的工具:

dev_continue_project

它让 Agent 可以:

  1. 全文检索历史会话(基于 DSH 的 ctx.sessionQuery.searchSessions,不是翻 JSONL 文件);
  2. 找到最匹配的旧会话;
  3. 读取该会话的当前上下文ctx.sessionQuery.readSurface);
  4. 返回一份紧凑的 handoff:
    • 会话 id
    • 工作目录
    • 使用的 Agent preset
    • 创建时间 / 最后序号 / 标题
    • 最近的消息、工具调用、工具结果、todo 状态
  5. 当前 Agent 基于这份记忆继续完成未完成的工作。

功能特性

  • ✅ 按关键词跨会话搜索(FTS5,由 dsh-session-query-sqlite 提供)
  • ✅ 支持直接指定 sessionId 跳过搜索
  • ✅ 自动读取旧会话的 surface(当前模型可见上下文)
  • ✅ 输出按“最新在前”排序,控制字符预算,避免一次性灌爆上下文
  • ✅ 无 client 依赖,纯 host 工具,注入即用
  • ✅ 资源注册挂在 ctx.effect 上,热重载/卸载不会留残留
  • ✅ 重启后由 dsh-super-injector 自动恢复

工具说明

dev_continue_project

参数类型必填说明
querystring二选一项目/任务关键词,例如 dsh-routing-suite插件开发
sessionIdstring二选一精确的会话 id;提供后跳过搜索直接读取
limitnumber候选会话数量,默认 5,最大 20
maxCharsnumber返回上下文预算,默认 12000,范围 1000~50000

querysessionId 至少提供一项。

典型用法

用户说:

“继续之前那个 dsh-routing-suite 项目”

Agent 调用:

{
  "name": "dev_continue_project",
  "arguments": {
    "query": "dsh-routing-suite"
  }
}

用户说:

“继续上次做插件开发那个对话”

{
  "name": "dev_continue_project",
  "arguments": {
    "query": "插件开发"
  }
}

用户直接给出会话 id:

{
  "name": "dev_continue_project",
  "arguments": {
    "sessionId": "session-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  }
}

返回内容示例

Found 2 candidate session(s).
1. session-xxx | cwd=E:\dsh插件\router | preset=router-spec | created=2026-08-18T...
   match: dsh-routing-suite 安装与预设复制
2. session-yyy | cwd=E:\dsh插件\test | preset=standard | created=2026-08-17T...
   match: pulse-app-design.html

=== Handoff: session-xxx ===
cwd: E:\dsh插件\router
preset: router-spec
created: 2026-08-18T...
lastSeq: 123
title: 安装 dsh-routing-suite

--- recent context (newest first) ---
#120 [assistant] 已安装 router-standard 和 router-spec...
#121 [tool] str_replace_editor ...
#122 [result] ...
#123 [user] 继续完善 router 预设描述...

工作原理

用户说“继续 xxx”
      │
      ▼
dev_continue_project
      │
      ├─ 有 sessionId? ── 是 ──► 直接读取该会话
      │                        │
      │                        ▼
      │                  ctx.sessionQuery.readSurface(sessionId)
      │
      ▼ 否
ctx.sessionQuery.searchSessions({ query, limit })
      │
      ▼
取最匹配会话
      │
      ▼
ctx.sessionQuery.readSurface(sessionId)
      │
      ▼
格式化 handoff(cwd / preset / 最近事件)
      │
      ▼
返回给当前 Agent 继续完成

安装

方式 A:直接注入(当前环境)

插件目录已包含可直接加载的 lib/index.js

# 在 DSH 内对 AI 说:
dev_inject_plugin {"dir": "E:/dsh插件/router/dsh-session-continue"}

方式 B:从源码构建

需要 DSH 源码 checkout(DSH_CHECKOUT):

DSH_CHECKOUT=<checkout> bash scripts/build.sh
dev_inject_plugin {"dir": "<本目录>"}

依赖

  • @deepseek-ai/dsh-tools
  • @deepseek-ai/dsh-session-query(运行时由 DSH 提供 ctx.sessionQuery
  • cordis
  • schemastery

注意事项

  • 本工具是“把旧会话记忆带到当前对话”,不是 DSH 原生的 resume。
  • 如果希望回到旧对话本体继续,仍建议在 DSH 会话列表里直接恢复旧会话。
  • 搜索基于 DSH 的 FTS5 token 索引;如果关键词过于碎片化,可能搜不到,此时可以给更完整的项目名,或直接提供 sessionId
  • 返回的上下文是压缩摘要,不保证包含旧会话全部细节;如果需要完整原文,可以再让 Agent 读取具体文件或要求更多上下文。

许可证

MIT