morlay / better-session

Listed

better session

mainSession View source

Installation

npx -y @deepseek-ai/dsh plugin --profile web add github:morlay/better-session

This installation command is an unverified starting point generated from the GitHub repository address.

README

Maintainer-authored documentation snapshot.

View on GitHub ↗
Commit 2c5b4cfSynced Aug 18, 2026

better-session

DeepSeek Harness 的分支式会话编辑 monorepo:在不修改上游 @deepseek-ai/* 代码的前提下,为会话提供 就地编辑 / 重试 / 分支 (rewind / retry / fork)闭环——GUI 里直接编辑用户消息、重试任意回合, 重写同一会话(session id 不变),只有分支才派生新 id。

快速开始

1. 安装(发布后)

一个 bundle 包装齐全部依赖组件:

dsh plugin --profile web add "@morlay/better-session" --config.@morlay:registry=https://npm.pkg.github.com/

安装 @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-sessionprofile 聚合 bundle:装配以上全部 + 官方 web-app本文件

设计要点

  • 不改上游代码:全部在插件层实现。
  • 就地编辑:edit / retry / reroll 用 rewind 截断 + append 重写同一 会话(session id 不变、版本树单根);只有 fork 创建新 id。
  • rewind 支持 live 会话:GUI 打开中的会话也能就地编辑(截断 RDB 与 内存 log、同步 coordinator cursor、重置 agent 轮次游标)。
  • ignorable 版本效果:分支版本事件不进 canonical log,非 branch 读者 安全跳过。

Project files and signals

Shown items are public repository signals detected in the directory snapshot.

TestsDetected
DocumentationDetected

Repository information

Language
TypeScript
License
MIT
Last updated
Aug 18, 2026, 8:17 AM

Install deliberately

Review source code, permissions, lifecycle hooks, dependencies and network access. Test untrusted plugins in an isolated environment.