@gooftoken/dsh-rewind 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +29 -2
- package/assets/icon.svg +6 -0
- package/client.js +1549 -0
- package/cordis.patch.yml +4 -0
- package/docs/DETAIL.md +153 -0
- package/lib/command.d.ts +48 -0
- package/lib/compaction.d.ts +105 -0
- package/lib/config.d.ts +22 -0
- package/lib/git/provider.d.ts +26 -0
- package/lib/git/runner.d.ts +45 -0
- package/lib/git/snapshot.d.ts +60 -0
- package/lib/git/workspace.d.ts +54 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.js +2631 -0
- package/lib/paths.d.ts +16 -0
- package/lib/recorder.d.ts +50 -0
- package/lib/replay.d.ts +72 -0
- package/lib/store.d.ts +34 -0
- package/lib/surface.d.ts +74 -0
- package/lib/types.d.ts +120 -0
- package/lib/undo.d.ts +38 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +92 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 gooftoken contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @gooftoken/dsh-rewind
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DeepSeek Harness plugin: per-turn Git working-tree checkpoints, in-place conversation rewind, and range compaction.
|
|
4
|
+
|
|
5
|
+
- `/rewind` opens a picker in the Web GUI; double-press Escape also opens it. The horizontal action bar offers **Files & conversation**, **Conversation**, **Files**, **Compact after**, and **Compact before**, switched with the left/right arrows. File actions hide themselves when the selected turn has nothing to restore (no usable checkpoint, or the work tree already matches it); when the last rewind can still be undone, an **Undo last rewind** button appears on the left of the footer.
|
|
6
|
+
- Files: each turn start snapshots the repository work tree into a private Git object store; a rewind diffs the snapshot against the current work tree and restores the changed paths. The repository's own index, objects, refs, and commits are never touched.
|
|
7
|
+
- Conversation: a surface replacement returns the model-visible conversation to before the selected turn inside the same session. Background jobs, subagents, and queued input keep running; a plain rewind replaces the tail with an empty developer cut node (no model message, no rewind marker), so the model prefix is exactly the pre-turn prefix and provider prefix caching still applies. When the selected turn was already condensed by a compaction, the plugin replays the pre-compaction messages into the same session: the first rebuilt user message replaces the compacted tail and the remaining messages are appended after it inside one tagged internal turn, so there is no extra surface marker. If there is no user message to rebuild (nothing before the target, or the first missing node is an assistant), an empty developer cut node is used instead; it produces no model message and is written in the same internal turn. Copied assistant messages carry matching `tool/call` records so the stored log still passes the harness reload validation; the host's turn cursor is advanced past the internal turn so the next real turn keeps a unique number, and the picker omits that turn. The first node carries a local `rewind-replay`/`rewind-cut` source tag; the transcript hides the old tail and the fresh copies, and shows the original history once. No new session is created. After the rewind, the target turn's original prompt text is restored to the composer so it can be edited and resent (text only; image/file attachments are not recreated).
|
|
8
|
+
- Undo: `/rewind undo`, or the picker's **Undo last rewind** button, restores the files and conversation of the last successful rewind in the same session. It is one level and only while nothing moved since the rewind: the complete surface hash and the post-rewind work tree must still match, so a new turn, a compaction, or a manual edit refuses the undo. Undo replaces the rewind output with an empty `rewind-undo` developer cut and appends copies of the shadowed messages inside one tagged internal turn (copied assistants carry matching `tool/call` records and the host turn cursor is advanced); the model prefix returns to its pre-rewind state and the log still reloads. The record lives in the plugin store and is cleared after a successful undo; there is no redo.
|
|
9
|
+
- Compaction: **Compact after** condenses the selected turn and everything after it; **Compact before** condenses everything before it. The routed model writes the summary between turns and the span is replaced with a standard DSH compaction checkpoint; the transcript shows DSH's native "context compacted" marker at that boundary, and **compact after** also collapses the summarized tail so the visible history ends where the model context does. Command result text and JSON are never rendered. Background work is not interrupted.
|
|
10
|
+
- The command works without the Web half: `/rewind list`, `/rewind apply <turn> [--files] [--conversation] [--compact-before|--compact-after] [--dry-run]`, `/rewind undo [--dry-run] [--json]`.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
Install the bundle into a profile (`Plugins > Add plugin`, or `plugin_manager`). Requires `git` on the Host and a session working directory inside a Git repository for file rewind. Compaction additionally needs a routed model and a mounted token meter (both part of the standard Web composition).
|
|
15
|
+
|
|
16
|
+
## Configuration
|
|
17
|
+
|
|
18
|
+
See [docs/DETAIL.md](docs/DETAIL.md). Defaults: `storageDir=~/.dsh/rewind`, `timeoutMs=30000`, `outputMaxBytes=8388608`, `maxPathsPerRestore=1000`, `retentionDays=30`.
|
|
19
|
+
|
|
20
|
+
## Limits
|
|
21
|
+
|
|
22
|
+
- Ignored files, files outside the repository, and submodule contents are not covered.
|
|
23
|
+
- Restoring a turn restores the whole work tree at that turn start, including later shell/manual edits and files written by running jobs; the picker states this before you apply, but there is no per-file preview.
|
|
24
|
+
- Rewind is refused while a foreground turn is running; it never cancels background jobs or the running turn. A plain conversation rewind (one that does not replay a compacted prefix) leaves the model prefix unchanged, so the provider prompt cache still applies.
|
|
25
|
+
- Compaction costs one model call, can take tens of seconds, and rewrites the replaced span; subsequent requests rebuild that part of the prompt cache (plain rewind still preserves it). It is refused while a turn runs or another compaction holds the lock.
|
|
26
|
+
- A rewind to before a compaction replays the original messages into the same session. The first rebuilt message replaces the old tail and the rest are appended inside one tagged internal turn; when the first rebuilt node is not a user message (or there is nothing to rebuild), an empty developer cut node replaces the old tail in that same turn. Copied assistant messages carry matching `tool/call` records so the stored log reloads, and the picker omits the internal turn; the host turn rail still lists it. Copies occupy log space (assistant stream evidence is not duplicated), the replayed prefix is rewritten so the next request rebuilds it, and the transcript hides the old tail plus the copies; background work is untouched.
|
|
27
|
+
- Undo is one level and must happen before the session moves on: any new turn, compaction, surface change, or work-tree edit after the rewind refuses it. Undo copies messages into the log (rewriting that part of the prompt prefix) and cannot itself be undone; a file restore that skipped gitlink paths may also block undo when the work tree no longer matches the recorded post-rewind tree.
|
|
28
|
+
- Running alongside `dsh-workspace-changes` doubles the per-turn Git snapshot work.
|
|
29
|
+
|
|
30
|
+
MIT licensed.
|
package/assets/icon.svg
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" width="64" height="64" role="img" aria-label="Rewind">
|
|
2
|
+
<rect width="64" height="64" rx="15" fill="#1f6feb"/>
|
|
3
|
+
<path d="M20.5 25.5a14 14 0 1 1-2.1 14" fill="none" stroke="#ffffff" stroke-width="4.5" stroke-linecap="round"/>
|
|
4
|
+
<path d="M20.5 15.5v10h-10" fill="none" stroke="#ffffff" stroke-width="4.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
+
<circle cx="32" cy="37" r="3.4" fill="#ffffff"/>
|
|
6
|
+
</svg>
|