po-et / dsh-session-rescue

已收录

Fix 'corrupt session log' in DeepSeek Harness: diagnose, safely repair, and salvage broken dsh sessions. Zero dependencies.

main会话 查看源代码

安装

npx dsh-session-rescue

此命令根据 GitHub 仓库地址生成。运行前请检查上游 README 与源代码;需要可复现安装时,请固定 release 或 commit。

README

维护者编写的文档快照。

在 GitHub 查看 ↗
提交版本 ca75573同步于 2026年8月18日

dsh-session-rescue

Fix "history unavailable for session … corrupt session log" in DeepSeek Harness — safely, with zero data loss in the common cases.

中文文档

npx dsh-session-rescue

If dsh greets you with any of these, this tool is for you:

  • corrupt session log: seq gap in committed region at line N (expected X, got Y)
  • corrupt session log: unparsable committed event at line N
  • first line is not a session header
  • SessionPersistenceCorruptionError after a crash, force-kill, or running two dsh instances on one session

dsh session logs are append-only and strictly validated: one duplicated write after a crash or a second process, and the whole conversation becomes permanently unloadable — even though your content is usually still all there. dsh-session-rescue diagnoses exactly what dsh's loader rejects, removes the redundant side (replayed rows, stale synthetic interrupt-closers), and rebuilds a loadable log.

Quick start

# 1. See which sessions are broken (safe, read-only)
npx dsh-session-rescue

# 2. Deep-diagnose one session (path or any unique id fragment)
npx dsh-session-rescue doctor 37374e34

# 3. Preview the repair — nothing is written yet
npx dsh-session-rescue repair 37374e34

# 4. Apply it (a timestamped backup is always kept; close dsh first)
npx dsh-session-rescue repair 37374e34 --apply

Can't be repaired? Get your conversation back anyway:

npx dsh-session-rescue export 37374e34        # salvages the transcript to Markdown
npx dsh-session-rescue quarantine 37374e34    # move a broken session out of dsh's sight

Using an AI agent? Just tell it: "Run npx dsh-session-rescue and fix my broken dsh sessions."

What it can fix

DamageCauseRepair
Replayed duplicate rowscrash / force-kill / write-behind replaydrop duplicates — zero loss
Synthetic closer block colliding with the real continuationinterrupt recovery + second writerdrop the synthetic block, keep your real content — zero loss
Torn final zstd framepower loss mid-writenone needed (dsh self-heals; we tell you so)
Unreadable/garbled headermanual edits, partial writesheader reconstruction
Real seq holes (events actually missing)forced compaction, lost writesexplicit --truncate keeps the loadable prefix; export salvages the rest

Why it's safe

Community experience shows naive repairs can kill a session permanently (dangling sourceEventSeqs poisoning). This tool:

  1. Never touches the original without a timestamped backup sitting right next to it.
  2. Validates before writing: the rebuilt log must pass seq-contiguity and sourceEventSeqs reference checks — the same invariants dsh enforces. An unsafe plan is refused, not "fixed harder".
  3. Verifies after writing: the repaired file is re-scanned; if it wouldn't load, the tool tells you and the backup is untouched.
  4. Preserves original bytes: kept lines are copied verbatim, never re-serialized.
  5. Rebuilds the exact physical layout dsh expects (zstd frame 0 = header only).

vs. other tools

dsh-session-rescuedoctor-family toolsexport-family tools
Detect corruption
Repair the session so it loads & continues
Salvage transcript when unrepairable
Refuses unsafe writesn/an/a

Scope & honesty

  • Supports session format version 0 (current dsh developer preview), .jsonl and .jsonl.zstd, JSONL backend only. dsh is pre-1.0 with no format-compatibility promise; on an unknown version this tool refuses loudly instead of guessing.
  • Repair requires dsh to be closed (or at least that session idle) — a live writer would race the swap.
  • Zero dependencies. Node ≥ 22.15 (built-in zstd).

License

MIT

项目文件与信号

以下项目是目录快照中检测到的公开仓库信号。

测试已检测

仓库信息

开发语言
TypeScript
许可证
MIT
最后更新
2026年8月17日 09:51

谨慎安装

请检查源代码、权限、生命周期脚本、依赖与网络访问;不受信任的插件应先在隔离环境中测试。