@nelsonlongxiang/dsh-tool-hash-line-edit
v0.2.1
Published
Hash-anchored line editing tool (hash_line_edit) for DeepSeek Harness: PUT/CUT line patches validated by a [path#TAG] content tag from a complete read
Downloads
127
Readme
@nelsonlongxiang/dsh-tool-hash-line-edit
A DeepSeek Harness (DSH) host plugin that adds the model-facing hash_line_edit tool: line-addressed file edits validated by a [path#TAG] content tag, with a built-in [path#????] probe that returns the complete line-numbered content and its tag.
What it does
The plugin registers one tool (hash_line_edit) plus its system-prompt guidance into the host composition:
- Probe — patch
[<path>#????](header only) reads the target file and returns its complete line-numbered content with the[path#TAG]anchor line (rendered text); the canonical value also carries the four-hextagfield, so code-dispatch callers that see the value rather than the render can quote the anchor. The tag uses the same xxHash32 low-word algorithm as the original hashline tool (line1\nline2\nline3\n→34E9; trailing[ \t\r]per line is normalized away — different file content yields a correspondingly different tag). The probe records the read observation, so the following edit passes the observation policy's read-before-edit gate without any other read tool. Files above 2 MiB are refused (FS_TOO_LARGE) — hash-anchored editing targets small, fully quoted files. - Edit — a patch carries the header
[path#TAG]on its own line, followed by operations:PUT N.=M:then+payload lines — replace lines N–MCUT N.=M— delete lines N–MPUT <N:then+payload lines — insert before line NPUT >N:/PUT >$:then+payload lines — insert after line N / append at EOF
- Execution parses the patch, verifies the tag against current file contents (
stale_tagon mismatch → re-probe), resolves per-call sandbox policy, obtains thefs/edit-intentversion guard from the mounted observation policy, and commits throughctx.fs.writeText— so sandbox confinement, escalation (sandbox_permissions/justificationunder a confining backend), read-before-edit, and stale-version protection all behave like the built-in filesystem tools. - Results carry
before/aftertext and diff-card presentation metadata; successful writes emitfs/observed.
Coordinates are 1-based and refer to the complete pre-edit probe result. Overlapping replace/delete ranges and malformed hunks are rejected before any mutation. New files are not supported — use the built-in write tool.
Requirements
The profile must already provide the standard filesystem stack: a ctx.fs provider (e.g. dsh-fs-local) and, for guarded mutations, dsh-fs-observation-policy. The plugin injects tools, fs, and systemPrompt.
Install
npx -p @deepseek-ai/dsh dsh plugin --profile <name> add @nelsonlongxiang/dsh-tool-hash-line-editRestart the profile after installing. The plugin is host-only (no client face).
Config
| Key | Default | Meaning |
|---|---|---|
| enabled | true | Register the tool and its prompt section; false contributes nothing. |
Development
pnpm install
pnpm verify # typecheck + tests + buildTests run the plugin through a real Cordis composition (in-memory ctx.fs provider plus the observation policy) and pin the tag vector, grammar, guarded-mutation, and stale-tag behavior.
scripts/inspect-transcript.mjs is a local development/diagnostic helper: it decodes a DSH .jsonl.zstd session log and prints events mentioning the tool (smoke-test evidence extraction). It is intentionally not shipped with the package — files only exports lib, cordis.patch.yml, and this README.
Origin
Extracted from the DeepSeek Harness monorepo's packages/fs/tool-fs hash_line_edit implementation (PR #21) into an independently installable plugin; tag compatibility with the original ai-native-expect-agents hashline tool is preserved.
