DSH Plugins Marketplace

DSH Plugins

Plugins

/

dsh-chat-history-cleaner

d

dsh-chat-history-cleaner

Manifest valid

Delete DSH chat history safely: recoverable trash, per-project cleanup, restore, and permanent purge.

UI (client)hasBundlePatch

dsh-chat-history-cleaner

License: MIT

DSH 历史会话清理插件:在会话菜单删除单条会话,或在设置页按项目批量清理。删除先进入可恢复的回收站,确认后再彻底删除。

English — A DSH plugin to delete chat history safely. It adds a Session menu action and a Settings → Session history page with per-project filtering, a recoverable trash, restore, and permanent purge. See README.en.md.

功能

  • 会话菜单删除:会话行右键 / “…”→「删除会话…」,确认后移入回收站。
  • 设置页「历史会话」:
    • 按项目下拉筛选(全部项目、各项目、无项目目录);
    • 搜索标题 / 目录,按可删除、已归档、受限筛选,按更新时间 / 大小 / 标题排序;
    • 多选后批量移入回收站;
    • 查看回收站条目,恢复或彻底删除,支持清空回收站。
  • 默认只显示可删除会话:打开/运行中的会话在「全部」或「受限」中查看;对它们点删除会直接说明原因,不再进入确认。
  • 回收站:默认位于 ~/.dsh/trash/chat-history/,恢复时移回原项目目录。
  • 安全拒绝:运行中或已打开的会话、子代理会话不能直接删除;删除父会话时其子代理会话一并进入同一回收站条目。
  • 无外部服务:宿主路由使用进程内随机 token,所有操作只发生在本机。

安装

要求 DSH 0.2.2-rc.1 或更新的 0.2.x。发布物是自带构建产物的 Release tarball,不需要在安装时构建。

插件页(推荐)

打开 DSH → 设置 → 插件 → Add plugin,粘贴当前版本的 Release 地址:

https://github.com/WangShuangTong/dsh-chat-history-cleaner/releases/latest/download/dsh-chat-history-cleaner.tgz

安装完成后按提示启用;如果提示需要重启,重启 DSH / Desktop 即可。

CLI

dsh plugin --profile <profile> add https://github.com/WangShuangTong/dsh-chat-history-cleaner/releases/latest/download/dsh-chat-history-cleaner.tgz

把 <profile> 换成 web、desktop 或你使用的 profile。

从源码

git clone https://github.com/WangShuangTong/dsh-chat-history-cleaner.git
cd dsh-chat-history-cleaner
pnpm install
pnpm run check

然后在插件页选择该目录,或使用 dsh plugin --profile <profile> add /absolute/path/to/dsh-chat-history-cleaner。源码安装需要本机有 pnpm 与 Node 24。

这份插件目前以 GitHub Release tarball 分发,未发布 npm 包。

使用

  • 单条删除:会话行右键 / “…”→「删除会话…」→「移到回收站」。
  • 按项目清理:设置 → 历史会话 → 顶部项目下拉框选择项目;列表、筛选计数和批量删除都只作用于该项目。
  • 批量清理:勾选会话 →「移到回收站」。
  • 恢复 / 彻底删除:设置 → 历史会话 → 回收站区域。
  • 打开中的会话:Desktop 进程仍持有的 Agent 会阻止删除;切换/关闭会话或重启 Desktop 可释放,正在跑轮次的会话需先结束或停止。

配置

在 profile 的 cordis.patch.yml 中按行 id 覆盖(patch 会整体替换 config,需写全要保留的键):

- id: chat-history-cleaner
  config:
    debug: false
    maxBatch: 200
    toastMs: 4000
    # trashDir: D:\dsh-trash\chat-history   # 可选,绝对路径
键默认说明
debugfalse客户端加载时输出诊断日志
maxBatch200单次请求最多处理的会话 / 回收站条目数
toastMs4000浏览器提示停留毫秒数
trashDir<DSH home>/trash/chat-history回收站根目录,必须为绝对路径,且不能与 sessions 目录重叠

安全边界

  • 删除前校验会话来自 sessionPersistence.list(),并用 stat.location.path 推导真实目录;只移动该会话目录,不删除项目目录或 sessions 根目录。
  • 回收站条目名、meta 中的相对路径、stored 目录名都按单个安全路径段校验;恢复/彻底删除前复核路径包含关系,并拒绝符号链接 / junction。
  • 批量移动中途失败会回滚已移动目录;meta.json 原子写入。
  • 宿主路由使用每个进程随机生成的 token(x-dsh-chat-history-token),token 只注入页面;无 token 403,非法请求 400,超大请求体 413。
  • 投影缓存(storages/session_projcache)属于派生数据,移入回收站时尽力删除;恢复后由冷读自动重建。

已知限制

  • 仅支持随 DSH 提供的 JSONL 持久化后端;其它后端返回 unsupported-storage。
  • 已加载/运行中的会话不能删除,需宿主释放 Agent。
  • 子代理会话不能单独删除;删除父会话时一并处理。
  • 回收站恢复依赖当前 sessions 根目录;profile home 迁移后按当前根目录 + 相对路径恢复。
  • 投影缓存恢复时不还原(派生数据)。
  • workspace 的归档/置顶标记在回收站期间保留;彻底删除时仅在会话确实不存在时清理。
  • 界面文案在页面加载时确定,切换界面语言需刷新页面。
  • 没有自动清理回收站的策略;需要时手动「清空回收站」。

开发

pnpm install
pnpm run typecheck
pnpm run test
pnpm run build
pnpm run check
  • src/host/:宿主半(配置、路径安全、回收站操作、HTTP 路由)。
  • src/client/:浏览器半(菜单项、设置页、确认弹窗、Toast、API 封装)。
  • src/shared/types.ts:两边共用的 wire 类型。
  • scripts/build.mjs:esbuild 双产物;客户端包在 __ModuleLoader__.load 协议里,React / ReactDOM 保持平台模块。
  • test/:node:test + tsx;覆盖移动、恢复、彻底删除、回滚、拒绝场景、路径穿越、软链、HTTP 校验和筛选逻辑。

许可

MIT

Comments

Loading…