When developing agents in a DeepSeek Harness (DSH) environment, file editing often encounters mechanical reliability issues: after multiple conversation rounds modify the same file, line numbers may drift; text transferred between different systems may change line breaks (CRLF/LF). If a model relies on absolute line numbers or static text for replacement, matching failures are highly likely.

Preface

What Is This

DeepSeek Harness Hash Anchor File Editing Plugin (magian1127/deepseek-harness-hashline) provides hashline_read and hashline_edit. It uses the LINE:HASH format as anchors, binding editing operations to specific line content recently read by the model. This solves editing failures caused by multi-round modifications, atomic batch modifications, and line-ending differences.

Core Features

This plugin mainly includes the following capabilities:

  • LINE:HASH reading: Reads files in LINE\|HASH content format. It uses a 4-character hexadecimal SHA-256 prefix by default, and the results report both EOL (line endings) and BOM (byte order mark).
  • Three anchoring edits: Supports set_line (set a single line), replace_lines (replace a line range), and insert_after (insert after a line). The edits parameter of hashline_edit is a flat array of objects.
  • Dialect recovery: Automatically detects and recovers common malformed call patterns, such as omitting op (automatically inferred as set_line or replace_lines) or promoting fields to the root level.
  • Atomic batch editing: Validates all anchors in one call, rejects overlapping modifications, and then writes atomically.
  • Version CAS protection: Uses the DSH file versioning mechanism to prevent concurrent overwrites between validation and writing.
  • Text fidelity: Preserves UTF-8 BOM, LF/CRLF, and mixed line endings, and does not break the end-of-file state.
  • Failure recovery: When hash matching fails, it automatically relocates to nearby lines or reports an error with the real anchors.
  • Native result cards: Reading reuses the DSH native ReadBlock; editing displays native-style diff cards, with deleted/added lines marked by a gray gutter.
  • Reversible strict replacement: After enabling “replace built-in read/write,” the Agent uses strict-anchored read/edit, making agent operations safer.
  • Chinese-language prompt support: Tool descriptions, error messages, and other text can be configured to use Chinese.

Installation and Enablement

DSH bundles are isolated by profile. Web GUI, Open Design, and Headless modes must each be installed separately.

  1. Web GUI mode
    node bin/dsh-hashline.mjs install --profile web --link $PWD
  1. Open Design mode
    dsh plugin --profile open-design add "link:$PWD"
  1. Headless mode
    dsh plugin --profile headless add "link:$PWD"

Note: The --link parameter must point to this plugin’s source directory. After installation, use commands such as node bin/dsh-hashline.mjs status --profile web to confirm the status.

Typical Usage

When reading files, use the LINE|HASH format:

LINE\|HASH 3a2f1b  这是被锚定的内容

When editing, call hashline_edit with edits as a flat array of objects:

  • Basic editing: Specify op (optional), anchor (anchor text), and new_text (new text).
    {
      "edits": [
        {
          "op": "set_line",
          "anchor": "LINE|HASH 3a2f1b",
          "new_text": "新的内容"
        }
      ]
    }
  • Dialect simplification: If op is omitted, the system automatically infers it by shape:
    • With anchor + new_text -> set_line
    • With start_anchor + end_anchor + new_text -> replace_lines

If non-anchor fields such as old_string or replace are passed, the operation will be rejected with a prompt to use the built-in edit.

Applicable Scenarios and Notes

  • Applicable scenarios: Scenarios requiring highly reliable file editing, especially maintaining the same file across multiple conversation rounds, or ensuring that text format (such as preserving BOM) is not broken.
  • Notes:
    • Experimental stage: It is currently still in testing/experimental stage, and interfaces, configuration options, and behavior may change at any time. Do not use it in production projects.
    • Permission requirements: The Web GUI configuration card requires DSH to include settings.register(..., { exposeToClients: true }).
    • Data security: The plugin does not upload data or maintain independent data files.

Summary

This plugin uses a hash anchoring mechanism to solve mechanical reliability issues in file editing within the DSH environment, providing atomicity, fidelity, and automatic fault tolerance. It is currently in the testing period and is suitable for validating stability and behavior in an isolated environment.