Skip to content
Back to search

dsh-turn-rewind

deepseek harness对话和代码状态回退插件 | DSH — rewind conversation and workspace state, powered by a persistent Change Ledger

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today

Check it deeper on your machine

It has changed since its scan on 11 Nov 2026.

As a Claude Code plugin, install it and then ask Claude Code:

/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/Anionex/dsh-turn-rewind with scanskillsafety

Or from a terminal, clone it and run it:

git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/Anionex/dsh-turn-rewind'

It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.

Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/anionex--dsh-turn-rewind/badge.svg)](/listings/anionex--dsh-turn-rewind)

HTML

<a href="/listings/anionex--dsh-turn-rewind"><img src="/api/listings/anionex--dsh-turn-rewind/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Build the checked-out plugin, then add it to each DSH profile that should expose the service:

pnpm install --frozen-lockfile
pnpm run check

dsh plugin --profile web add @anionex/dsh-turn-rewind
dsh plugin --profile headless add @anionex/dsh-turn-rewind

dsh --profile web --dump-config | grep turn-rewind

Restart a running profile after changing its bundle list.

The package is a DSH Profile Bundle. `package.json` declares `dsh.bundle.patch`, and `cordis.patch.yml` mounts `@anionex/dsh-turn-rewind` without a DSH core patch.

When the profile also provides the DSH Agent service, the plugin captures a hidden checkpoint in the first `agent/pre-step` waterfall before the Agent processes the opening user message. Capture failures are reported but do not reject the user's turn; the corresponding message simply has no usable rewind point. In Web profiles, the same-origin `/turn-rewind` endpoint resolves the selected `user/message` sequence, exposes a paged file preview, mints a short-lived session-bound restore plan, and delegates child creation to DSH's official Host create/fork lifecycle. It never restores files automatically.

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 224 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.

  1. # DSH Turn Rewind
  2. [![X (Twitter)](https://img.shields.io/badge/-@anion__ex-000000?style=flat-square&logo=x&logoColor=white)](https://x.com/anion_ex)
  3. [中文说明](README.zh.md)
  4. Message-anchored project-file recovery for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness), with an option to restart from the restored request.
  5. **Turn Rewind** is the user-facing feature, repository, and Profile Bundle name. **Change Ledger** is the durable restore engine underneath it: the `ctx.changeLedger` service, on-disk format, and storage path keep that name because they describe the reusable snapshot and recovery layer rather than the Web action alone.
  6. Change Ledger gives a DSH session an explicit safety boundary around workspace mutations:
  7. ```text
  8. create restore point
  9. ↓
  10. agent / user / external tools modify the worktree
  11. ↓
  12. preview exact path-level drift
  13. ↓
  14. review a full or selective restore plan
  15. ↓
  16. press the final restore button in the rewind dialog
  17. ↓
  18. create rescue point → restore → verify
  19. ```
  20. It never commits, stashes, resets, switches branches, edits the Git index, or decides automatically that a change should be reverted.
  21. ## What's new
  22. Most recent work first:
  23. - **Rewind button survives the 0.2.2 client slot API** — DSH `0.2.2-rc.1` no longer injects the `useChat`/`useSession` chat snapshot hooks into `conversation.session.header.actions`; the bridge now reads Host-provided turn anchors (`GET /turn-rewind/turns`) and matches rendered user rows by `data-chat-turn`. The legacy snapshot path remains for older Hosts.
  24. - **File rewind works in ordinary directories (0.3.0)** — when the working directory is not a Git repository it is snapshotted as an ordinary directory (`.git` and `node_modules` excluded by default, plus an optional `.dsh-rewindignore`), so messages-only rewind is no longer the only option.
  25. - **The fastest path is now the default (0.3.8)** — the new `auto` mode uses Git-native checkpoints in a Git worktree (reusing the repository object database, so committed content is never stored twice) and the plugin's own store for ordinary directories.
  26. - **Unchanged files are no longer re-read (0.3.5)** — each workspace keeps a persistent path identity cache; a measured 20 000-file / 351 MB workspace dropped from 237 s to about 7 s per capture.
  27. - **One oversized file no longer discards a whole checkpoint (0.3.3)** — it is skipped and reported while the rest is still captured, and a restore never touches a path its checkpoint did not record, so a file that was too large then and small now is never deleted.
  28. - **Checkpoint budget 5 s → 60 s, parallel capture (0.3.4)** — a 5-second budget in a large directory could only ever report a skip.
  29. - **Rewind button and messages-only fixes (0.2.2 / 0.2.3)** — adapted to the DSH 0.1.2-alpha client hooks and restored the messages-only mode that the Host rejected.
  30. - **Settings card matches the official cards (0.3.6 / 0.3.7)** — one collapsed row that expands, consistent with every other plugin card.
  31. ## Preview
  32. Rewind appears as an icon-only third action under each user message, after its timestamp and native Copy action:
  33. ![Turn Rewind action under a user message](docs/assets/turn-rewind-action.png)
  34. Opening it shows the affected files and offers three choices: restore the files and restart from before that message, restore only the files, or rewind only the messages and leave the files untouched:
  35. ![Turn Rewind review dialog](docs/assets/turn-rewind-dialog.png)
  36. ## Why it has a Change Ledger engine
  37. A diff button can show current changes, but it does not own a durable restore lifecycle. Change Ledger owns:
  38. - content-addressed restore-point manifests;
  39. - Git worktree, HEAD, branch, and in-progress-operation fences;
  40. - stale-plan detection between review and mutation;
  41. - exact two-step confirmation plus DSH human approval;
  42. - automatic pre-restore rescue points;
  43. - post-restore hash verification;
  44. - rollback after a failed restore;
  45. - startup reconciliation of interrupted restore journals;
  46. - a public `ctx.changeLedger` service that other plugins can consume.
  47. The durable format is documented in [docs/FORMAT.md](docs/FORMAT.md). The security and failure model is documented in [SECURITY.md](SECURITY.md).
  48. ## Safety contract
  49. - **Explicit only:** nothing is restored automatically — every restore starts from the user pressing the final button in the Web dialog, or from an explicit call through the service API.
  50. - **Read before write:** the dialog preview generates an expiring, session-bound plan from the current tree and changes no files.
  51. - **Human gate:** the dialog's reviewed impact plus the final restore button is the human decision; direct mutation requests without a live session-bound plan pair fail closed.
  52. - **Rescue before mutation:** every restore captures the current eligible tree as a durable rescue point before changing a path.
  53. - **No silent omission:** unsupported submodules, sparse checkouts, oversized files, aggregate limits, and unsupported file types fail point creation.
  54. - **No path escape:** every durable path is canonical and workspace-relative; restore refuses symlink parents and non-empty directory replacement.
  55. - **No stale overwrite:** selected paths and the reviewed HEAD/branch/operation fence are checked again at apply time. Any relevant post-review change invalidates the plan.
  56. - **No Git control-plane mutation:** the index, branch, HEAD, stash, and commits remain untouched.
  57. ## Scope
  58. Two workspace kinds are supported and selected from the Session's own directory:
  59. **Normal Git worktree**
  60. - tracked files, including currently missing tracked paths;
  61. - untracked files not excluded by `.gitignore` or other standard Git excludes;
  62. - regular files, binary or text;
  63. - symbolic links;
  64. - executable and other portable permission bits.
  65. **Ordinary directory (the Session directory is not a Git repository)**
  66. - every regular file and symbolic link below it; links are captured as links and never followed;
  67. - `.git` and `node_modules` are excluded by default;
  68. - an optional `.dsh-rewindignore` in the directory root adds `.gitignore`-style rules; the built-in exclusions are applied last and cannot be re-included;
  69. - snapshot content is stored in the plugin's own content-addressed storage instead of the Git object database;
  70. - running `git init` inside the directory changes the workspace mode, so earlier restore points stop applying (`WORKSPACE_MODE_CHANGED`) and a new message must create a new one.
  71. The following are rejected or deliberately outside the snapshot:
  72. - sparse checkouts;
  73. - submodule gitlinks (create a restore point inside each submodule instead);
  74. - ignored files and files excluded by `.dsh-rewindignore`;
  75. - special files, sockets, devices, and named pipes;
  76. - extended attributes, ACLs, ownership, timestamps, and hard-link topology;
  77. - the Git index and repository metadata.
  78. If an ignored or otherwise unmanaged file occupies a path that restoration would replace, the restore fails rather than deleting it.
  79. ## Install
  80. Build the checked-out plugin, then add it to each DSH profile that should expose the service:
  81. ```sh
  82. pnpm install --frozen-lockfile
  83. pnpm run check
  84. dsh plugin --profile web add @anionex/dsh-turn-rewind
  85. dsh plugin --profile headless add @anionex/dsh-turn-rewind
  86. dsh --profile web --dump-config | grep turn-rewind
  87. ```
  88. Restart a running profile after changing its bundle list.
  89. The package is a DSH Profile Bundle. `package.json` declares `dsh.bundle.patch`, and `cordis.patch.yml` mounts `@anionex/dsh-turn-rewind` without a DSH core patch.
  90. Compatibility is declared and exercised against DSH `0.2.2-rc.1` (previous releases stay supported). On `0.2.2` the `conversation.session.header.actions` slot no longer carries a per-session chat snapshot, so the Web bridge resolves turn anchors from the Host (`GET /turn-rewind/turns`) instead of the removed snapshot hooks.
  91. When the profile also provides the DSH Agent service, the plugin captures a hidden checkpoint in the first `agent/pre-step` waterfall before the Agent processes the opening user message. Capture failures are reported but do not reject the user's turn; the corresponding message simply has no usable rewind point. In Web profiles, the same-origin `/turn-rewind` endpoint resolves the selected `user/message` sequence, exposes a paged file preview, mints a short-lived session-bound restore plan, and delegates child creation to DSH's official Host create/fork lifecycle. It never restores files automatically.
  92. ## User flow
  93. In the Web profile, each direct user message gains a compact, icon-only **Rewind** action after its timestamp and native Copy control. The tooltip reads “Return to before sending this message.” Opening Rewind checks the saved file state, shows a concise preview with a “view all files” action, and offers three modes:
  94. | Mode | Code | Conversation |
  95. | --- | --- | --- |
  96. | **Restore files and restart** (default when files changed) | Restores the project files after automatically backing up their current state. | Creates and opens a Session ending before the selected message, then puts that message's text and attachments back in the composer. |
  97. | **Restore files only** | Restores the project files after automatically backing up their current state. | Leaves the current Session open and unchanged. |
  98. | **Rewind messages only** (default when no checkpoint or no file changes) | Leaves the project files exactly as they are. | Creates and opens a Session ending before the selected message, then puts that message's text and attachments back in the composer. |
  99. Unavailable attachments are reported by name so you can add them again; restored text and available attachments remain in the draft.
  100. The dialog itself is the confirmation: there is no duplicate checkbox. It describes each file as restoring an earlier version, finding a deleted file, removing a later-added file, or restoring permissions/type. **Rewind messages only** is always available — including when the checkpoint for that message is missing, was skipped (for example after disabling automatic checkpoints), or the project files already match the saved state — because it never touches the worktree. It is not blocked by other running Agents in the same worktree.
  101. Before mutation, Turn Rewind rechecks the selected files and repository state, then creates an automatic backup. Changes made after preview invalidate the operation. Any running Agent using the same worktree, including the source Session, blocks restoration; idle Sessions do not block. A reviewed HEAD or branch difference does not block restoration: commits, refs, branch, and index remain unchanged, so restored content may appear as ordinary uncommitted changes against the current HEAD. An in-progress Git operation still blocks. If child creation fails after “restore and restart,” Change Ledger automatically restores the pre-operation files from the backup.
  102. DSH Session logs are append-only, so “restart” creates a new Session instead of truncating the original. For the first message, the Host creates a blank Session in the same working directory; for later messages, it forks at the previous completed `turn/end`. A child may reuse an ancestor's prompt checkpoint only while both the selected `user/message` and its exact `turn/start` remain inside every durable `seedLength` fence. Direct child checkpoints take priority and sibling checkpoints never mix. **Turn Rewind** always treats the two dimensions independently: the two restore modes change project files (optionally followed by a new conversation), while **Rewind messages only** reuses the same fork lifecycle without touching files. The original Session is always retained.
  103. ## Configuration
  104. Runtime-tunable options are editable in the DSH web settings page under **Plugins → Turn Rewind** (`turn-rewind` settings namespace). Changes apply live to the next capture, restore, or deletion; they persist in the host's `settings.yaml` and override the profile patch values below. `storageDir` is deliberately not editable there: the storage root must not move while the engine holds locks and journals, so it stays a patch-layer field.
  105. Override the composition base (and `storageDir`) in the profile patch layer:
  106. ```yaml
  107. - id: turn-rewind
  108. config:
  109. storageDir: ~/.dsh/change-ledger/v1
  110. maxRestorePoints: 50
  111. maxTurnCheckpointsPerSession: 30
  112. maxFiles: 20000
  113. maxFileBytes: 16777216
  114. maxSnapshotBytes: 536870912
  115. planTtlMs: 900000
  116. staleLockMs: 30000
  117. turnCheckpointMode: legacy # off | git-native | legacy; "off" stops creating file checkpoints
  118. turnCheckpointTimeoutMs: 5000
  119. turnCheckpointMaxNewBytes: 33554432
  120. turnCheckpointTrust: fast # fast | strict
  121. A file above `maxFileBytes`, or one whose type is unsupported, is skipped and recorded on the restore point instead of discarding the whole checkpoint; the dialog names it, and a restore never touches a skipped path. Reaching `maxFiles` or `maxSnapshotBytes` keeps the captured part and says so in the dialog.
  122. ```
  123. Setting `turnCheckpointMode: off` (in the patch or in the settings card) stops automatic file checkpoints; every turn records a durable skip instead, and the rewind dialog still offers **Rewind messages only** for those messages.
  124. All size and user-point retention limits fail loudly. Automatic turn checkpoints have a separate per-session retention window and prune only their own oldest checkpoints; user and rescue restore points are never silently pruned. When omitted, `storageDir` resolves to `$DSH_HOME/change-ledger/v1` and falls back to `~/.dsh/change-ledger/v1`; it must not overlap the managed worktree.
  125. ## Checkpoint management
  126. The same settings card includes a storage manager backed by the same-origin `/turn-rewind/manage` endpoint. It lists every workspace this storage root has ever tracked — including projects whose directory no longer exists — grouped with checkpoint counts, approximate sizes, and pending-recovery badges. Per checkpoint, per workspace, or globally (**Clear all**), it deletes unprotected restore points and garbage-collects unreferenced blobs. Restore points still referenced by an incomplete recovery journal, a running restore, or an unfinished Git-native publish are retained and reported. Git-native (v2) checkpoints live in the repository's Git object database, so their disk space is reclaimed by normal Git garbage collection; the displayed sizes are logical values.
  127. ## Recovery
  128. Before writing any path, a restore creates a rescue point and a durable operation journal. If DSH stops with a non-terminal journal, the next plugin startup marks it `interrupted` unless another live DSH process still owns that workspace lock.
  129. Recovery uses the public `ctx.changeLedger` service API: `listRecovery` finds the operation's `rescuePointId`, `inspect` reviews that rescue point, then `planRestore`/`applyRestore` handle the affected paths. Rescue points remain ordinary, inspectable restore points until explicitly deleted.
  130. ## Public service
  131. Other Cordis plugins can inject `changeLedger` and call the same lifecycle through the structured service API:
  132. ```ts
  133. export const inject = ['changeLedger']
  134. export async function apply(ctx: Context) {
  135. const point = await ctx.changeLedger.create({
  136. cwd: '/absolute/git/worktree',
  137. sessionId: 'session-id',
  138. label: 'before refactor',
  139. })
  140. // point.id is a durable restore-point id.
  141. }
  142. ```
  143. The complete exported types are available from `@anionex/dsh-turn-rewind/format`; the engine is available from `@anionex/dsh-turn-rewind/core` for non-Cordis tests and trusted integrations.
  144. ## Development
  145. ```sh
  146. pnpm install --frozen-lockfile
  147. pnpm run check
  148. ```
  149. The test suite creates real temporary Git repositories and covers full/selective restore, stale plans, ignored-path collision refusal, HEAD drift, rescue rollback, crash reconciliation, active-lock preservation, durable-state integrity, symlinks, size limits, sparse checkouts, submodules, deletion, and blob garbage collection.
  150. ## About
  151. DSH Turn Rewind is maintained by [anionex](https://anionex.me/). If you would like to follow my future work, [follow me on X](https://x.com/anion_ex) or [GitHub](https://github.com/Anionex).
  152. ## License
  153. BSD-3-Clause. See [LICENSE](LICENSE).

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.