Preface¶
DeepSeek Harness (DSH) adopts a plugin-based architecture. When handling code editing tasks, traditional line-number (line number) editing has two issues: first, models often need to echo old code to confirm context, wasting tokens; second, in multi-step edits, file content changes can invalidate subsequent edit instructions.
dsh-hashline-edittool provides DSH with a toolset based on content-hash anchors. It assigns a variable-length Base62 identifier to each line in a file, allowing models to edit through anchors, thereby avoiding repeated output of old code and providing atomic batch-write capabilities.
Plugin Positioning¶
This is a workflow plugin developed by the maintainer hyperion2144 under the MIT license. It replaces DSH’s built-in read / edit / grep tools and adds the undo_last_edit, ast_grep, ast_edit, and lsp tools.
Core Features¶
1. Hash Anchor Mechanism¶
- Variable-length encoding: Anchors are not fixed-width hashes but dynamically assigned Base62 encodings. The first 3,844 lines only require 2 characters to cover, and length increases as the file grows (upper limit approximately 62⁸ lines).
- Non-numeric identifier: The encoding skips all-numeric combinations to avoid confusion with line numbers.
- Marker format: Edits use the
<anchor>:<line>format. Here,lineserves only as a position hint; the anchor is the authoritative identifier.
2. Atomic Writing and Validation¶
- Batch atomicity: All editing operations form an atomic batch. If any edit range in the batch fails validation, the entire write operation is rolled back, and no files are written.
- Write path: All write operations go through
ctx.fs. - Staleness detection: During writes, it validates whether the content actually seen by the model matches the current on-disk content. If the content has been tampered with, it returns an
[E_STALE]error and immediately returns the latest anchor and content for the current line for retry.
3. Self-Rendered UI and Configuration¶
- Self-rendered cards: The plugin includes its own React components (such as
HashlineReadRow,HashlineEditRow, etc.) and registers them directly into DSH Web UI slots. The UI renders from structured data without string parsing. - Self-rendered settings panel: Provides a visual settings interface, eliminating the need to manually edit YAML.
- Hot switching: Configuration changes (such as output format, AST/LSP toggles) take effect immediately on the next tool invocation without restarting the process.
4. AST and LSP Support¶
- ast_grep / ast_edit: Provides syntax-tree-level search and editing based on Tree-sitter.
- lsp: Integrates the Language Server Protocol to provide semantic information.
Installation and Enablement¶
Ensure the environment meets the following requirements:
* Node.js version: ^22.19.0 || >=24.0.0
* An existing DSH Profile is required
Run the installation command:
npx @deepseek-ai/dsh plugin --profile web add github:hyperion2144/dsh-hashline-edittool
After installation is complete, enable the plugin in the next session. Verify that the configuration loaded successfully with the following command:
dsh --profile <name> --dump-config
The output should include the # == dsh-hashline-edittool related layer configuration.
Typical Usage¶
Reading Files¶
The output header of the read tool is ANCHOR:FILELINE, formatted as follows:
ANCHOR:FILELINE
G8:1|// UI demo file
ur:2|export const APP = "hashline";
D0:4|export function greet(name: string): string {
Editing Files¶
The model specifies the modification range via anchors in its response. For example, modify line two:
<ur:2>const APP = "hashline";
If the edit is rejected (such as [E_STALE]), the plugin returns the latest anchor and content for the current line, and the model must use the new anchor to resubmit.
Notes¶
- Permissions and source: The plugin runs with the permissions of the current DSH process. Please review the GitHub source code and license before installation.
- Error codes: Common error codes include
[E_RANGE_UNSERVED](range not served),[E_STALE](content stale), and[E_LINE_HINT](line hint mismatch).
Summary¶
dsh-hashline-edittool solves the pain points of traditional line-number editing in context propagation and concurrent conflicts by introducing variable-length Base62 anchors. It provides atomic editing operations, real-time syntax diagnostics, and self-contained UI components, suitable for developers who need complex, multi-step code editing scenarios in DSH.
- GitHub repository: https://github.com/hyperion2144/dsh-hashline-edittool
- Plugin directory: https://www.skillhub.cn/plugins/hyperion2144/dsh-hashline-edittool