DeepSHPlugins
dsh-session-recovery 專案預覽
GITHUB / COMMUNITY PROJECT

dsh-session-recovery

會話與訊息JavaScriptMIT

從原始磁碟恢復被刪除或損壞的 dsh 會話(session.jsonl.zstd)與記憶庫(memory.db),並透過 web 介面中的 /session-repair 命令修復重建後無法續接的會話。

2 StarsCoprexist 更新時間 2026-08-18
訪問 GitHub 倉庫
dsh-session-recovery 專案預覽

專案介紹

中文

從原始磁碟恢復被刪除或損壞的 dsh 會話(session.jsonl.zstd)與記憶庫(memory.db),並透過 web 介面中的 /session-repair 命令修復重建後無法續接的會話。

English

Recover deleted or corrupted dsh sessions (session.jsonl.zstd) and memory (memory.db) from the raw disk, and repair rebuilt sessions that fail to resume via the /session-repair command in the web UI.

專案資訊與收錄訊號

快照 2026-09-11
作者 / 組織
Coprexist
倉庫
Coprexist/dsh-session-recovery
GitHub Stars
2
Forks
0
開發語言
JavaScript
許可證
MIT
最近推送
2026-08-18
Manifest
資料中檢測到宣告

公開倉庫不自動等於可商用;許可證與當前相容性以原專案文件為準。Manifest 和資料評分不構成安裝安全認證。

資料評分

49/ 100
維護活躍
84
文件與實用資訊
50
生態關注度
14
安裝便捷訊號
75
專案宣告訊號
100

關注度尚低(2)。

評分來自已有資料快照的五維模型,僅作瀏覽參考,不是實際使用評測或安全檢測結論。

安裝與使用

所有專案資料與許可均以對應 GitHub 倉庫為準。

dsh plugin --profile web add github:Coprexist/dsh-session-recovery

複製命令不會自動執行。請先閱讀倉庫文件,確認環境要求與許可證。

專案截圖

倉庫 README

GitHub 原文

已儲存的倉庫文件快照;文件抓取時間未記錄,可能與上方目錄介紹處於不同版本。安裝前請核對當前倉庫說明。

儲存庫檔案保留原文,指令與授權文字不作自動改寫。

dsh-session-recovery

Recover deleted/corrupted DeepSeek Harness sessions & memory from raw disk

DeepSeek Harness Node License Awesome DSH Plugin

English · 中文


🛟 After rm -rf ~/.dsh or file corruption, dsh conversation logs (session.jsonl.zstd) and memory (memory.db) can usually be recovered straight from the raw block device — this repo is a battle-tested manual plus the scripts that made it work.

✨ Features

🧠 Memory recoveryLocate memory.db by its SQLite format 3 header, dump the window, rescue rows via SQLite's official .recover (skips corrupt pages, keeps readable data).
💬 Session recoveryScan disk for zstd frame magic 0xFD2FB528, cluster frames by disk offset, split sessions at turn resets, rebuild official-format session.jsonl.zstd.
🔧 Automatic repairRenumber seq contiguously, deep-fix sourceEventSeqs/messageSeqs, normalize surfaceOp — the rebuilt log passes DSH's validation.
🔁 Resume repairRebuilt sessions can fail at *resume* (invalid persisted inbox splice, Messages with role 'tool' must be a response to tool_calls) — repair-session.js (or the /session-repair web command) replays DSH's inbox/surface/wire rules and fixes the file.
🛡️ Safe by designScripts only read the block device and write to a directory you choose; the original disk is never modified.

🚀 Quick Start

# 1. Stop everything that writes to disk (systemd services, dsh itself)
systemctl stop dsh-web

# 2. Recover memory (SQLite)
node scripts/recover-memory.js /dev/<dev> /tmp/recovered/

# 3. Scan disk for session frames
node scripts/scan-zstd.js /dev/<dev> > /tmp/session-events.jsonl

# 4. Split mixed events into per-session files
node scripts/split-sessions.js /tmp/session-events.jsonl 2026-08-16T07:05:06Z

# 5. Rebuild a session file (official format)
node scripts/rebuild-session.js \
  --input /tmp/sess-A.jsonl \
  --id session-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \
  --created-at 1786705157736 \
  --cwd /path/to/workspace \
  --out-dir ~/.dsh/sessions/--workspace-encoded--/

# 6. Before resuming: verify/repair the rebuilt session (fixes inbox splice
#    skew, duplicate/orphaned tool results, dangling tool calls)
node scripts/repair-session.js \
  ~/.dsh/sessions/--workspace-encoded--/<session-id>/session.jsonl.zstd --dry-run
node scripts/repair-session.js \
  ~/.dsh/sessions/--workspace-encoded--/<session-id>/session.jsonl.zstd
#   → writes session.jsonl.zstd.repaired (+ .bak-<ts>); review, then replace:
cp ~/.dsh/sessions/--workspace-encoded--/<session-id>/session.jsonl.zstd.repaired \
   ~/.dsh/sessions/--workspace-encoded--/<session-id>/session.jsonl.zstd

📖 Full step-by-step manual (Chinese, with every DSH validation rule and error you may hit): RECOVERY.md

📦 Install as a dsh plugin

Note: primarily a recovery toolkit (scripts + manual); it also installs as a dsh plugin that adds the /session-repair command to the web UI.

From a directory containing this repo (local install, no publish needed):

dsh plugin --profile web add file:/path/to/dsh-session-recovery
systemctl restart dsh-web

Then type in any session in the web UI:

/session-repair --dry-run              # analyze the current session (writes nothing)
/session-repair <session-id-or-path>   # repair → writes .repaired + a backup
/session-repair --apply <id>           # also replace the original file

By default only a new .repaired file plus a backup are written; --apply overwrites the original (refused for the live session hosting the command — run it from another session). Restart dsh-web after applying.

Requires Node 24+ (node:sqlite, node:zlib).

📖 Background

DeepSeek Harness stores its data under ~/.dsh:

~/.dsh/
├── sessions/<workspace-encoded>/<session-id>/session.jsonl.zstd   # conversation log
├── memory/memory.db                                               # dsh-mneme memory
└── storages/workspace.json                                        # workspace registry

The session log is a concatenated stream of zstd frames — one frame per JSONL line (source). That per-line framing is exactly what makes partial recovery possible: even if some frames are overwritten, the intact frames around them still decode independently.

🗂️ Repository Layout

├── RECOVERY.md            # Full recovery manual (Chinese, battle-tested)
├── cordis.patch.yml       # dsh plugin patch (registers /session-repair)
├── docs/
│   ├── awesome-entry.yml  # Ready-to-submit Awesome DSH Plugin list entry
│   └── GITHUB-PUBLISH.md  # Publish & PR checklist
├── lib/
│   ├── index.js           # dsh plugin entry: /session-repair command
│   └── repair.js          # Shared repair core (CLI + plugin)
├── scripts/
│   ├── scan-zstd.js       # Disk scan: find & cluster zstd session frames
│   ├── split-sessions.js  # Split mixed recovered events into per-session files
│   ├── rebuild-session.js # Rebuild official-format session.jsonl.zstd
│   ├── repair-session.js  # Fix rebuilt sessions that fail to resume
│   ├── make-test-fixture.js # Generate damaged samples to test repair offline
│   └── recover-memory.js  # Locate & rescue memory.db (SQLite .recover)
└── package.json           # dsh plugin manifest (dsh.bundle + main entry)

🔖 Topics

dsh-plugin · dsh · deepseek-harness · session-recovery · data-recovery · zstd · sqlite

📄 License

MIT

使用前核對

安裝步驟、相容版本與授權範圍以原專案當前文件為準。Stars 和評分是快照中的導航訊號。

安裝與排錯 · 專案問題反饋

同類專案