DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

123456robust /

123456robust/dsh-history-purge

Verified

删除 / 回收 DSH 历史对话(会话)的插件:设置页批量管理、侧栏单条删除、回收站可还原,附离线 CLI。

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@0be6a754

dsh-history-purge

删掉 DSH 的历史对话(会话)——设置页批量管理 + 侧栏单条删除 + 回收站可还原 + 离线 CLI。

它做什么

入口 位置 能力
设置 → 历史对话 设置面板左侧导航(order 26) 列出全部会话(标题 / 最近活动 / 大小 / 归属工作区 / 运行中 / 置顶 / 归档),勾选批量删除;回收站页可还原、永久删除、清空
侧栏会话「⋯」菜单 → 删除对话 每个会话行的菜单末尾(order 500) 单条删除,进回收站
Agent 工具 history_purge 模型可调用 list / delete / restore / empty
CLI dsh-history-purge 终端 宿主没起床时也能删

默认删除 = 移入回收站($DSH_HOME/history-purge/trash/<时间戳>-<sessionId>/),默认保留 30 天后由宿主启动清理;permanent 才是直接抹盘。删除后会话会从侧栏、工作区账本、会话索引里一起消失;正在运行的会话默认拒删(勾「运行中的也删除」才放行)。

装

已在 web profile 里(本机路径安装,0.1.0):

dsh plugin --profile web add /home/qq/dsh-plugins/dsh-history-purge
# 然后把 dsh-history-purge 加进 profile 的 dsh.profile.bundles(plugin add 不会自己写)

重启 dsh web 生效:

~/.dsh/restart-dsh-web.sh

配置(profile 的 cordis.patch.yml)

- id: dsh-history-purge
  name: dsh-history-purge
  config:
    trashRetentionDays: 30      # 回收站保留天数,0 = 永不自动清理
    permanentByDefault: false   # true = 删除直接抹盘,不进回收站

CLI

dsh-history-purge list --limit 20          # 看会话;--json 出机器可读
dsh-history-purge delete <id> [<id>...]    # 进回收站
dsh-history-purge delete <id> --permanent  # 直接抹盘
dsh-history-purge restore <trash-entry>    # 从回收站还原
dsh-history-purge purge --all --yes        # 永久清空回收站
dsh-history-purge sweep --days 7           # 按保留期清理
dsh-history-purge stats

在仓库目录里直接跑:node bin/dsh-history-purge.js list --home /tmp/fixture。

HTTP 桥

宿主半侧在 webServer 上注册五条同源路由(跨站 / sec-fetch-site: cross-site / Origin: null 一律 403):

GET  /history-purge/state      -> { sessions[], trash[], stats }
POST /history-purge/delete     { ids: string[], permanent?: boolean, force?: boolean }
POST /history-purge/restore    { entries: string[] }
POST /history-purge/purge      { entries?: string[], empty?: boolean }
POST /history-purge/sweep      {}

正在运行的会话默认拒删(force: true 才放行)——删盘但 Agent 还在跑,下一次 flush 会把日志写回来。

删除到底动了什么

  1. $DSH_HOME/sessions/<project>/<sessionId>/ —— 会话日志目录(移走或删除);
  2. $DSH_HOME/storages/session_projcache/sessions/<sessionId>.json —— 投影缓存(含标题);
  3. $DSH_HOME/storages/workspace.json —— 归账 / 归档 / 置顶三个 id 列表。宿主内走 workspaceRegistry 的 detachSession,CLI 直接修剪 JSON。

归档位与置顶位随之解除,不会留下悬空引用。

文件

文件 作用
lib/core.js 纯磁盘实现:列 / 删 / 还原 / 清空 / 过期清理,零 dsh 依赖
lib/index.js 宿主半侧:HTTP 路由、history_purge 工具、启动清扫、registry 摘账
client.js 浏览器半侧:设置分区 + 侧栏菜单项,纯 React + CSS,不引 ui-primitives
bin/dsh-history-purge.js CLI
cordis.patch.yml bundle 插入行

边界

  • 只处理本机 $DSH_HOME;远端 / 多机历史不在范围内。
  • 回收站是本插件自己的目录,DSH 原生没有「会话回收站」,所以被删会话不会再出现在任何原生界面里,只有本插件能还原。
  • 会话日志是 app 的私有格式(zstd + JSONL,header 在第一行)。插件只读第一行取 id / cwd / createdAt,其余字节原样搬动,不做改写。

已验证(本机)

  • 宿主半侧:5 条路由注册、同源 403、空 ids 400、缺失会话 200+失败条目、history_purge 工具 list/delete/restore 全通;
  • 浏览器半侧:在迷你 React harness 里渲染设置分区(标题/标签页/工具栏/列表/回收站/统计)与侧栏菜单项,均无错;
  • 磁盘:真会话目录上跑通 回收站删除 → 还原 → 永久删除;/dev/shm(tmpfs)与会话根跨设备时走 cp + rm 兜底,还原同样成功;
  • profile:dsh plugin --profile web add 已链入,dsh --profile web --dump-config 里能看到 id: dsh-history-purge,启动后 GET /history-purge/state 200;
  • 客户端 bundle:/plugins/??dsh-history-purge/client.js&rev=... 200,内容含 __ModuleLoader__.load 与 settings.section。

没验证到的一环:真实浏览器里的点按流程(本机没装 Chromium / Playwright)。渲染逻辑已用假 React 覆盖,CSS 变量对齐 --dsw-alias-*,但侧栏菜单弹层的视觉与 setMenuOpen(false) 的实际收口需要你刷新页面点一次确认。

回滚

dsh plugin --profile web remove dsh-history-purge
# 再从 profiles/web/package.json 的 dsh.profile.bundles 删掉该行

删插件不会动已删的会话;回收站里的东西留在 $DSH_HOME/history-purge/trash/,要恢复就装回来或手工搬回 sessions/<project>/<id>/。

发布到 GitHub

gh auth login --web            # 或用 GH_TOKEN=ghp_xxx 代替
./scripts/publish.sh           # 建仓 + 推送,仓库名默认 dsh-history-purge
./scripts/publish.sh my-name   # 换仓库名

这台机器的 DNS 把 github.com 解析到 20.205.243.166(TCP 443 不通),而 140.82.113.3 / 20.27.177.113 / 140.82.121.3 可达。scripts/github-tunnel.mjs 是一个只做 CONNECT 的本地代理, 把这些域名粘到可达的边缘 IP;publish.sh 探测到直连不通时会自己拉起它,并把 http.proxy/https.proxy 指过去,推完自动清理。

不想用脚本时:

node scripts/github-tunnel.mjs &
export HTTPS_PROXY=http://127.0.0.1:8899
git remote add origin https://github.com/<you>/dsh-history-purge.git
git push -u origin main
—/ 5

No ratings yet

Verified DSH bundle

Commit 0be6a754d08b

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout