morlay/better-session
DeepSeek Harness 的分支式会话编辑 monorepo:在不修改上游 @deepseek-ai/ 代码的前提下,为会话提供 就地编辑 / 重试 / 分支 (rewind / retry / fork)闭环——GUI 里直接编辑用户消息、重试任意回合, 重写同一会话(session id 不变),只有分支才派生新 id。
catalog 简介 / catalog descriptioncatalog description:better session
项目介绍Project Overview
better-session 是 DeepSeek Harness 的分支式会话编辑插件,monorepo 形式打包。在不修改上游代码的前提下,为会话提供就地编辑、重试和分支派生:编辑用户消息或重试任意回合时,截断并重写同一会话(session id 不变),仅 fork 才派生新 id。底层使用 RDB(SQLite / PostgreSQL)持久化,UI 替换 conversation 渲染。适合在 GUI 中需要修正输入或回滚重生成时使用。需注意 fork 与就地编辑行为不同,fork 会创建独立会话 id。
better-session is a DSH plugin that adds in-place session editing without modifying upstream code. It bundles sub-packages and exposes edit, retry, and fork operations through GUI replacements and an HTTP endpoint. Edit and retry rewrite the same session (unchanged session id) by truncating and appending, while fork creates a child session. Use it when you need to fix a user prompt, re-roll a turn, or branch from any closed boundary. Note that forks produce new session ids, and live sessions must be coordinated with RDB truncation and agent cursor reset.
请帮我了解并安装插件:【better-session】【https://github.com/morlay/better-session】
把上面这条消息直接发给当前会话里的 DSH,让它帮你了解并安装。安装命令不一定准确,发给 DSH 更稳。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.
或使用命令行安装(适合开发者)Or use CLI install (for developers)
命令行安装CLI Install
dsh plugin --profile web add "@morlay/better-session"
把 morlay/better-session 加入你的 DSH 配置(web profile)即可启用。
READMEREADME
better-session
DeepSeek Harness 的分支式会话编辑 monorepo:在不修改上游
@deepseek-ai/* 代码的前提下,为会话提供 就地编辑 / 重试 / 分支
(rewind / retry / fork)闭环——GUI 里直接编辑用户消息、重试任意回合,
重写同一会话(session id 不变),只有分支才派生新 id。
快速开始
1. 安装(发布后)
一个 bundle 包装齐全部依赖组件:
dsh plugin --profile web add "@morlay/better-session"
安装 @morlay/better-session 会自动带上子包(@morlay/session-branch、
@morlay/session-rdb、@morlay/ui-conversation-message-actions),并由
bundle 的 patch 自动装配:
ctx.sessionPersistence← RDB(SQLite / PostgreSQL)持久化后端ctx.sessionBranch← rewind / fork 数据层ctx.sessionEditor← edit / retry / fork 编排(HTTP:/session-editor)conversation.chat.node← 渲染替换(user 消息行内编辑 / 重试按钮)
2. 使用
装配后即可在 GUI 会话中:
- 编辑 user 消息 → 就地重写并重放(重新生成回复)
- 重试 任意闭合回合 → 就地重放该回合输入(带确认弹窗)
- 分支(fork)→ 从任意闭合边界派生新会话
也可以直接调用服务:
// 编排层(host)
await ctx.sessionEditor.retry({ action: "retry", sessionId, turn: 2, cascade: "truncate" });
// 数据层
await ctx.sessionBranch.rewind(sessionId, 5);
await ctx.sessionBranch.forkFrom(sourceId, { atSeq: 6, childSessionId });
3. 配置(rdb)
$DSH_HOME/settings.yaml:
session-rdb:
type: sqlite # 或 postgres + connectionString
path: /abs/path/to/sessions.sqlite
本地开发(monorepo)
just dep # 安装依赖
just build # 构建全部包(tsdown)
just test # vitest(含 PostgreSQL 契约测试,需 TEST_PG_URL)
just lint # oxlint
just dev # build + setup-dsh + 启动 web(dsh --profile web,DSH_HOME=.dsh-store)
包一览
| 包 | 职责 | 文档 |
|---|---|---|
@morlay/session-branch |
契约层:SessionBranchProvider 抽象 + SessionBranch 服务 + 版本树投影 |
README |
@morlay/session-rdb |
实现层:RDB 持久化(PersistenceBackend)+ 分支 provider(SessionBranchProvider)双服务 |
README |
@morlay/ui-conversation-message-actions |
编排层 + UI:edit / retry / fork 编排 + conversation.chat.node 渲染替换 |
README |
@morlay/better-session |
profile 聚合 bundle:装配以上全部 + 官方 web-app | 本文件 |
设计要点
- 不改上游代码:全部在插件层实现。
- 就地编辑:edit / retry / reroll 用
rewind截断 +append重写同一 会话(session id 不变、版本树单根);只有fork创建新 id。 rewind支持 live 会话:GUI 打开中的会话也能就地编辑(截断 RDB 与 内存 log、同步 coordinator cursor、重置 agent 轮次游标)。ignorable版本效果:分支版本事件不进 canonical log,非 branch 读者 安全跳过。
ruvnet/ruflo
amruthpillai/reactive-resume
volcengine/OpenViking
Molunerfinn/PicGo
titanwings/colleague-skill
nocobase/nocobase
Tencent/WeKnora