Preface¶
DSH (DeepSeek Harness) sessions are append-only event logs, and the model receives a messages array pieced together from history for every request. This brings a specific problem: asking the same question twice in the same session to compare answers side-by-side; or having useless early rounds in a long session that still clog every request sent to the model, which is inefficient and affects subsequent judgments. Existing solutions usually involve creating a new session, at the cost of losing context; manually editing session files risks breaking replay.
The plugin introduced below is elegant01/dsh-scalpel, maintained by elegant01, categorized under “Memory”, and licensed MIT. It does two things: compare two (up to three) answers in the same session, and strip out specified turns from every subsequent request. Its positioning is the “Context Scalpel,” not a session manager—the session files, interface, and others’ perspectives remain unchanged.
Core Features¶
Session Comparison. Select two (or three) answers in the same session. Paragraph-level alignment + word-level highlighting. The panel offers three columns (left, center, right), a ⇄ swap button, an “Only View Differences” button to collapse identical paragraphs, and a search to keep only matching paragraphs based on keywords.
Real Usage Comparison. For each answer, display the total tokens, uncached input, cache read/write, output, and cache hit rate side-by-side. The VS header also shows a line like X tok · Cache Hit Y%.
Session Removal. Remove specified turns from every request sent to the model. Rules are saved by sessionId + turn range. It re-reads per turn, so changing rules doesn’t require a restart.
Budget-based Removal. Select a target 200K / 500K / 1M and keep the most recent few turns. The plugin automatically calculates which turns #1–#K to delete and previews how many tokens will remain after deletion.
Rule Visualization. The panel allows direct viewing of currently active removal intervals, with one-click apply or undo. It uses the local interface provided by the host, so no need to return to the terminal.
It needs to be clarified that the “removal” (剔除) here is not “deletion” (删除). Once history is persisted to disk, it is immutable; the plugin only modifies the copy sent to the model. Therefore, it can never remove the current turn being answered, and can only remove by whole turns, not by splitting individual messages, to ensure tool_use / tool_result remain paired and avoid 400 errors. Changing the prefix will cause the prompt cache to cool down once, which is a design choice.
Installation and Usage¶
dsh plugin --profile desktop add dsh-scalpel
# Add "dsh-scalpel" to dsh.profile.bundles, then completely exit DSH and restart
The plugin requires dsh >=0.2.1-rc.1 <0.2.2. Bundles are captured at startup; refreshing the page alone is ineffective.
For local development, link the repository into the profile’s node_modules, add dependency "dsh-scalpel": "link:../../local-plugins/dsh-scalpel" in package.json, and add dsh-scalpel to dsh.profile.bundles, then completely exit DSH and restart. Note that ~/.dsh/local-plugins/<name>/ will not be automatically scanned; folder existence does not equal loading.
Typical Usage¶
Comparison has three entry points: the “Compare” tab at the top of the session view switcher, the “⚖ Compare” action on the assistant message row, and the terminal command scalpel compare. In the panel, select one on the left and one on the right, and you can add a third for a three-way comparison; by default, it selects the two most recent turns if there are no duplicate questions. End-to-end reproducible CLI commands:
scalpel sessions --limit 5 # Recent sessions
scalpel turns latest # Number of turns in this session
scalpel compare latest --a 1 --b 2 # Turn 1 vs Turn 2
scalpel compare latest --a 1 --b 2 --json # Structured output for other tools
Removal is primarily done via the panel: switch to “Delete Range” at the top, click two rows in the turn table to select a range, each row reports N chars · ~X tok. You can also operate directly via CLI:
scalpel drop latest --from 5 --to 7 --dry # Only print the rules to be written, don't persist
scalpel drop latest --from 5 --to 7 # Actually remove
scalpel undrop latest # Undo all
scalpel rules # Current rules
scalpel audit --limit 20 # How many items removed per turn
The rule file is ~/.dsh/scalpel-drop.json, with the format below:
{
"version": 1,
"sessions": {
"<sessionId>": {
"dropTurns": [[5, 7]], // Remove turns 5~7; a turn = a segment starting with a user message
"dryRun": false // true only writes audit, doesn't touch messages
}
}
}
Session data comes from ~/.dsh/sessions/<workspace>/session-<uuid>/session.v4.jsonl.zstd. Multi-frame zstd is split and decompressed by the magic 28 B5 2F FD. Node 22 has built-in zstdDecompressSync for direct reading without third-party dependencies. The number of items removed per turn and the characters saved are written to ~/.dsh/scalpel-audit.jsonl.
Regarding turn numbers, there are two definitions that are easy to trip over: tool returns (role: "user" + tool_result block) do not count as a separate turn; the host provides session-<uuid>, while the CLI and panel use bare <uuid>, and both notations work.
If installed but not working, run diagnostics first:
scalpel doctor
It will list in one go whether Node has zstd, if exports["./client"] exists, if dsh.client’s platform/immediately is correct, if dependencies and dsh.profile.bundles are written in both places, how long the probe has not been updated, etc. The most common pitfall is adding dependencies but not dsh.profile.bundles (the host won’t load it, and no error is reported), as well as only refreshing the page after changes (the probe timestamp will expose this).
Applicable Scenarios and Notes¶
Suitable for developers who need to control the context volume sent to the model in long sessions, or want to confirm exactly where the difference lies between two answers, and wish to change rules without restarting. It is pure ESM, has no build steps, and client.js is a hand-written bundle. Testing can be done with npm test to verify host-side behavior without installing DSH.
Points to note: The plugin runs with the permissions of the current DSH process. You should check the source code and license (MIT) before installing. It is not suitable for scenarios where you want the model to “never mention B again” in the future—removal only makes the model unable to see it; B remains in your own session. For a completely clean slate, please create a new session with a handover draft. Do not use it to physically delete a segment of history; directly modifying session.v4.jsonl.zstd will break replay. If you really want to delete, archive the entire session.
Conclusion¶
The value of dsh-scalpel lies in putting these two types of context operations—comparison and trimming—into a single plugin, and only acting on the copy sent to the model, without touching the source of truth. See the directory page at https://www.skillhub.cn/plugins/elegant01/dsh-scalpel , and the source code at https://github.com/elegant01/dsh-scalpel . The community directory is an independent site with no official affiliation to DeepSeek or Magic.