dsh-better-edit 0.2.0 → 0.2.2
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/CHANGELOG.md +24 -0
- package/README.md +173 -53
- package/README.zh.md +133 -47
- package/lib/guidance.js +391 -0
- package/lib/index.js +56 -32
- package/lib/prompts.js +53 -49
- package/lib/types/guidance.d.ts +130 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/prompts.d.ts +19 -9
- package/package.json +3 -10
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,30 @@ Entries link to the originating spec issue in [pi-hashline-edit-lsz](https://git
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.2.2] - 2026-08-19
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Guidance reset & restore defaults (issue #17): emptying or deleting an override file — or deleting its whole `<preset>/` directory — restores that section's compiled default guidance and order: the default renders at session-start and the file re-seeds at next boot (shipped presets; a deleted custom-preset override stays absent). A whitespace-only file with no front-matter fence means "I want the default"; any well-formed fence (even keyless, even an empty body) is a deliberate-intent signal and is never reset. Malformed fences now fast-fail instead of degrading to prose: a missing closing `---`, a non-integer `order`, or an unknown key rejects the file — the compiled default renders, a warning names the file and the reason, and the file is left untouched on disk for repair.
|
|
14
|
+
|
|
15
|
+
## [0.2.1] - 2026-08-18
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Configurable per-preset tool guidance (issues #7, #8; tickets #9–#13): the four `tool:*` prompt sections resolve from plain-markdown override files keyed by agent preset — `$DSH_HOME/plugins/dsh-better-edit/<preset>/<section>.md` — with an optional `order` front-matter. On first boot the plugin seeds each shipped preset (`standard`, `code`, `minimal`, `cordis`) with its guidance as editable files plus a root README documenting the scheme. Per section the chain is `<preset>/<section>.md` → compiled default; files are read once per agent at session-start, so edits apply to new sessions. Deployments without the `agentPresets` service keep the compiled defaults untouched.
|
|
20
|
+
Default orders sit at 130–133, above the built-in tool-guidance band (100–116 in the shipped
|
|
21
|
+
dsh), so a same-order section merge with unrelated tool guidance cannot occur out of the box; the
|
|
22
|
+
seeded preset files expose that `order` as editable front-matter.
|
|
23
|
+
- Default guidance text simplified per the writing-for-agents principles; the `*_GUIDELINES` constants unified on `*_GUIDANCE`.
|
|
24
|
+
- Thanks to [@R-LEI2536](https://github.com/R-LEI2536) for requesting configurable per-preset prompts and for the design input that shaped this release (issue [#7](https://github.com/Rianico/dsh-better-edit/issues/7)).
|
|
25
|
+
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- Benchmark extended to a third arm, `@oh-my-pi/hashline`: same corpus, same 12 replacements, two modes (per-edit `seq` with renumbered lines + one-document `batch` fixed to original line numbers). Payloads are built from the package's published grammar and validated before counting (the package is Bun-only, so it cannot run under the Node benchmark). Honest result, reported as such: hashline saves 31% vs `str_replace` on the session (43% on multi-line ranges) and remains the plugin's claim; the compact patch language saves 42% per edit / 53% batched — and this README says so. `npm run benchmark` stays byte-deterministic (verified over repeated runs).
|
|
29
|
+
- READMEs (English and 中文) refined along ponytail-style lines: "How It Compares" gains an `@oh-my-pi/hashline` column plus a same-lineage/different-jobs comparison; the Benchmark section documents all three arms, adds an honest "regenerate, don't trust" reproducibility note, and widens the scope-and-honesty block with what the payload numbers do *not* capture (renumber/tag-chase cost, block ops, Bun-vs-Node, tool-pair vs patcher library).
|
|
30
|
+
- `package.json` keywords now include `oh-my-pi` alongside `hashline`.
|
|
31
|
+
- Roadmap gains a first-class decision item: close or justify the gap vs `@oh-my-pi/hashline` (payload-lighter by 42%/53% vs 31%, with block ops / registers / `REM`/`MV` / multi-hunk documents / pluggable fs we do not support — against correctness costs: unverified line numbers, renumber-per-edit, best-effort merge on stale tags, model skill floor). A reference record lives at `../oh-my-pi.md` (workspace-level, outside this repo): the token comparison, the correctness asymmetry, the ability-by-ability status, and the decision rationale.
|
|
32
|
+
|
|
9
33
|
## [0.2.0] - 2026-08-16
|
|
10
34
|
|
|
11
35
|
### Changed
|
package/README.md
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<h1 align="center">dsh-better-edit</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
<strong>
|
|
9
|
-
|
|
8
|
+
<strong>A better edit tool for DeepSeek Harness<br>
|
|
9
|
+
Powered by hash‑anchored positioning — not by line numbers, not by string replacement, fewer tokens, more context space for real work.</strong>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
<a href="#quick-start">Quick Start</a> •
|
|
19
19
|
<a href="#why-hashline">Why Hashline</a> •
|
|
20
20
|
<a href="#benchmark">Benchmark</a> •
|
|
21
|
-
<a href="#installation">Installation</a> •
|
|
22
21
|
<a href="#tools">Tools</a> •
|
|
23
22
|
<a href="#acknowledgments">Acknowledgments</a>
|
|
24
23
|
</p>
|
|
@@ -57,6 +56,26 @@ Not for one-line touch-ups (near parity) or new files (`write`). It pays off in
|
|
|
57
56
|
|
|
58
57
|
## Quick Start
|
|
59
58
|
|
|
59
|
+
### Install
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
npx @deepseek-ai/dsh plugin --profile web add github:Rianico/dsh-better-edit # from github
|
|
63
|
+
npx @deepseek-ai/dsh plugin --profile web add dsh-better-edit # from npm
|
|
64
|
+
npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-better-edit # from a local checkout
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The profile's next session runs with the hashline tools installed. To verify the layer is active:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
dsh --profile <name> --dump-config # shows a "# == dsh-better-edit" layer
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
| Requirement | |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| Node | `^22.19.0 \|\| >=24.0.0` (dsh's requirement; the store uses `node:sqlite`) |
|
|
76
|
+
| Profile | a dsh profile (`dsh plugin` initializes one on first use) |
|
|
77
|
+
| Backends | sandboxed / remote filesystems supported (writes go through `ctx.fs`) |
|
|
78
|
+
|
|
60
79
|
`read` returns every line prefixed by its hash — the hash *is* the line's address:
|
|
61
80
|
|
|
62
81
|
```text
|
|
@@ -84,6 +103,67 @@ and produces a diff with fresh anchors, so the next edit verifies cleanly with n
|
|
|
84
103
|
kQm │ }
|
|
85
104
|
```
|
|
86
105
|
|
|
106
|
+
## Configuring Guidance per Preset
|
|
107
|
+
|
|
108
|
+
The `tool:read` / `tool:edit` / `tool:batch_edit` / `tool:undo_last_edit` guidance sections are
|
|
109
|
+
plain-markdown files, overridable per agent preset. Override files live in the plugin's shared
|
|
110
|
+
home — never the workspace store:
|
|
111
|
+
|
|
112
|
+
```
|
|
113
|
+
$DSH_HOME/plugins/dsh-better-edit/<preset>/<section>.md
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
(default home `~/.dsh`, so `~/.dsh/plugins/dsh-better-edit/`). The section table:
|
|
117
|
+
|
|
118
|
+
| File | Section | Default order |
|
|
119
|
+
| --- | --- | --- |
|
|
120
|
+
| `read.md` | `tool:read` | 130 |
|
|
121
|
+
| `edit.md` | `tool:edit` | 131 |
|
|
122
|
+
| `batch_edit.md` | `tool:batch_edit` | 132 |
|
|
123
|
+
| `undo_last_edit.md` | `tool:undo_last_edit` | 133 |
|
|
124
|
+
|
|
125
|
+
On first boot the plugin seeds the four shipped presets — `standard/`, `code/`,
|
|
126
|
+
`minimal/`, `cordis/` — each with the compiled guidance as editable files (plus
|
|
127
|
+
`order` front-matter), so every preset's guidance starts editable rather than
|
|
128
|
+
blank. A `README.md` at the plugin-home root documents the scheme. Files are
|
|
129
|
+
seeded once and never rewritten, so your edits survive — a reset is the one
|
|
130
|
+
exception (see *Reset / restore defaults* below). A preset directory may
|
|
131
|
+
hold only the sections you want to override — the rest fall through to the
|
|
132
|
+
compiled defaults.
|
|
133
|
+
|
|
134
|
+
A file is pure prose unless it opens with an `order` front-matter fence, which moves the section in
|
|
135
|
+
the assembled system prompt:
|
|
136
|
+
|
|
137
|
+
```md
|
|
138
|
+
---
|
|
139
|
+
order: 150
|
|
140
|
+
---
|
|
141
|
+
|
|
142
|
+
<section text>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Per section, resolution reads `<preset>/<section>.md`, else the compiled
|
|
146
|
+
default. Files are read once per agent at session-start, so edits apply to new
|
|
147
|
+
sessions — never mid-session. A preset with no seeded directory (e.g. a
|
|
148
|
+
user-authored one) falls back to the compiled defaults unless you copy a seeded
|
|
149
|
+
dir to its name. A deployment without the `agentPresets` service (no preset
|
|
150
|
+
roster) keeps the compiled defaults and never touches these files; presets are
|
|
151
|
+
never required.
|
|
152
|
+
|
|
153
|
+
### Reset / restore defaults
|
|
154
|
+
|
|
155
|
+
Emptying or deleting an override file restores that section's compiled default
|
|
156
|
+
guidance and order: the default renders at session-start, and the file re-seeds
|
|
157
|
+
at next boot.
|
|
158
|
+
|
|
159
|
+
- **Reset = delete the file, or empty it AND remove the front-matter fence.** A whitespace-only file with no fence means "I want the default" — the compiled default renders, and the file re-seeds at next boot for any preset dir, shipped or custom.
|
|
160
|
+
- **Blank on purpose = keep a valid fence.** Any well-formed `---` fence — even a keyless `---\n---\n`, even an empty body — is a deliberate-intent signal: the file is explicit content and is never reset or re-seeded.
|
|
161
|
+
- **Broken fence = fast fail.** A `---` fence that does not parse (missing closing `---`, non-integer `order`, unknown key) is rejected: the malformed text is never injected into the context, the compiled default renders, a warning names the file and the reason, and the file is left untouched on disk for repair.
|
|
162
|
+
- **Shipped vs custom.** Shipped preset files (`standard`, `code`, `minimal`, `cordis`) re-seed at boot; a deleted custom-preset override stays absent — absence is no override. Deleting a whole `<preset>/` directory re-seeds all four section files at boot (shipped presets).
|
|
163
|
+
- **Reset restores the current bundle defaults** — a plugin upgrade yields new defaults.
|
|
164
|
+
|
|
165
|
+
Re-seeding happens at boot, never mid-session.
|
|
166
|
+
|
|
87
167
|
## Why Hashline
|
|
88
168
|
|
|
89
169
|
**Token-saving.** An edit call carries `remove_from` / `remove_to` (two 3-char hashes) plus the
|
|
@@ -92,6 +172,11 @@ text verbatim. On a 12-edit session over a realistic file this is **31% fewer ou
|
|
|
92
172
|
on multi-line ranges) — and these are *output* tokens, billed at ~5-6× the input rate. See the
|
|
93
173
|
[benchmark](#benchmark).
|
|
94
174
|
|
|
175
|
+
**But this was never about “fewest tokens.”** Savings scale with the replaced text — near parity on
|
|
176
|
+
one-line touch-ups — and a compact patch language like [@oh-my-pi/hashline](#how-it-compares) can
|
|
177
|
+
emit a lighter payload still (42–53% on the same session). The point is the *right* kind of edit
|
|
178
|
+
call: no re-typing old code, and nothing for the model to track except two stable content addresses.
|
|
179
|
+
|
|
95
180
|
**Correctness.** Every resolved edit range is verified against the exact lines the model was shown.
|
|
96
181
|
A stale, never-served, or ambiguous range is hard-rejected **before anything is written**, and the
|
|
97
182
|
current range is echoed back as fresh anchors (reject-and-serve) — the retry needs no `read`.
|
|
@@ -102,74 +187,108 @@ pins a line by what it *is*, not by where it used to sit.
|
|
|
102
187
|
|
|
103
188
|
### How It Compares
|
|
104
189
|
|
|
105
|
-
| | hashline `edit` | `str_replace` |
|
|
190
|
+
| | hashline `edit` | `str_replace` (Claude Code / Codex) | @oh-my-pi/hashline patch |
|
|
106
191
|
| --- | :---: | :---: | :---: |
|
|
107
|
-
| Replaced text echoed in the call | ✅
|
|
108
|
-
|
|
|
109
|
-
|
|
|
110
|
-
|
|
|
111
|
-
|
|
|
112
|
-
|
|
|
113
|
-
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
192
|
+
| Replaced text never echoed in the call | ✅ 2 hashes only | ❌ verbatim | ✅ `+` rows only |
|
|
193
|
+
| Lines addressed by | content hash | text match | number + file-content tag |
|
|
194
|
+
| Verified against what the model saw | ✅ every line | ❌ first match wins | ~ file version only |
|
|
195
|
+
| Stale file detected | ✅ rejects, fresh anchors | ❌ may match wrong spot | ✅ tag mismatch → refuse or 3-way merge |
|
|
196
|
+
| Anchors survive edits above | ✅ content-addressed | ✅ content-based | ❌ renumber + new tag |
|
|
197
|
+
| Chained edits without re-reads | ✅ diff serves fresh anchors | ~ | ~ via edit-response numbers |
|
|
198
|
+
| Unambiguous when text repeats | ✅ boundary anchors verified | ❌ first occurrence | ~ position, unverified per line |
|
|
199
|
+
| Wrong-line edit never lands silently | ✅ every line verified | ❌ first match wins | ~ possible in principle (tag checks version, not lines) |
|
|
200
|
+
| Block ops / registers / `MV` / `REM` | ❌ | ❌ | ✅ |
|
|
201
|
+
| One document per change | ❌ per-edit call | ❌ per-edit call | ✅ multi-hunk patch |
|
|
202
|
+
| Runtime | ✅ Node (dsh) | — | ⚠️ Bun only |
|
|
203
|
+
| Undo | ✅ persisted | ❌ | ❌ not in scope |
|
|
204
|
+
|
|
205
|
+
> `~` = occasionally / inconsistently. `@oh-my-pi/hashline` is a compact line-anchored patch language
|
|
206
|
+
> ([npm](https://www.npmjs.com/package/@oh-my-pi/hashline), [repo](https://github.com/can1357/oh-my-pi/tree/main/packages/hashline)):
|
|
207
|
+
> `[path#tag]` headers bind each hunk to a full-file content hash, `PUT N.=M:` addresses lines by
|
|
208
|
+
> number, and every edit renumbers — take the next numbers and tag from the edit response or a fresh `read`.
|
|
209
|
+
|
|
210
|
+
**Different jobs, same lineage.** Both descend from the
|
|
211
|
+
[harness-problem](https://stencil.so/blog/the-harness-problem) insight that the model should never
|
|
212
|
+
re-type old code. `@oh-my-pi/hashline` is a **patch-language library** — payload-light (42% saved
|
|
213
|
+
per edit, 53% in a single batch document, see [benchmark](#benchmark)), with syntactic block ops
|
|
214
|
+
(`PUT N*:`), registers, `REM`/`MV`, multi-hunk documents, a pluggable filesystem for any backend,
|
|
215
|
+
and session-aware 3-way-merge recovery on stale tags. This plugin is a **dsh tool pair**: `read`
|
|
216
|
+
hands the model 3-char content hashes, `edit` takes two of them, and every resolved line is verified
|
|
217
|
+
against the served state — no line numbers to renumber, no tag to re-fetch, a wrong anchor can never
|
|
218
|
+
land on the wrong line, and `undo_last_edit` survives restarts. Its trade-offs: a JSON envelope per
|
|
219
|
+
edit costs a little payload, there are no block ops, and it lives inside dsh (Node) rather than as a
|
|
220
|
+
standalone patcher (Bun). Pick hashline-the-library for a cross-backend patch format; pick
|
|
221
|
+
hashline-the-tool for verified, content-addressed edits in your agent.
|
|
222
|
+
|
|
223
|
+
### Correctness in edge cases
|
|
224
|
+
|
|
225
|
+
The token benchmark measures the payload the model emits — it assumes the model gets every
|
|
226
|
+
address right, for free. Correctness is where the two hashline implementations actually diverge.
|
|
227
|
+
These are the real failure modes from the harness-problem literature (wrong-line edits, drift,
|
|
228
|
+
repeated text), and what each tool does when they hit:
|
|
229
|
+
|
|
230
|
+
| Edge case | hashline `edit` (this plugin) | @oh-my-pi/hashline patch |
|
|
231
|
+
| --- | --- | --- |
|
|
232
|
+
| Wrong address (off-by-one anchor / line number) | **Impossible** — anchors resolve to specific lines; every resolved line is verified against served state, rejected **before** anything is written | **Possible** — a wrong line number against a current tag applies **silently** at the wrong place; the tag proves the file version, never the lines |
|
|
233
|
+
| File changed on disk after the model's view | Hard reject + fresh anchors echoed (reject-and-serve); retry needs no `read` | Tag mismatch → refuse **or best-effort 3-way merge** onto unknown current content |
|
|
234
|
+
| An edit above shifts the file | Nothing shifts — anchors are content addresses; the diff serves fresh anchors | **Every edit renumbers** — “RE-GROUND AFTER EVERY EDIT” is the format's own #1 rule; the model carries the bookkeeping |
|
|
235
|
+
| Repeated / identical text | Per-line hashes are unique (collision-resolved); ambiguity → `[E_AMBIGUOUS_ANCHOR]` | Position-based, so repeats don't confuse it — but the position itself is unverified |
|
|
236
|
+
| Lines never shown to the model | `[E_RANGE_UNSERVED]` — hard reject with fresh anchors | Undisplayed hunks rejected — same reliance on the model knowing what it saw |
|
|
237
|
+
| Mid-expression / wrong block node | Irrelevant — any verified line range is valid | Grammar rules + `PUT N*:` node choice; mispointing (anchoring `def` orphans its decorator) silently lands wrong; no syntax check |
|
|
238
|
+
| Multi-edit batch fails mid-way | `batch_edit` — atomic, all-or-nothing; the failing item is echoed as fresh serves | Multi-section patches preflighted up front — also atomic |
|
|
239
|
+
|
|
240
|
+
> The 42–53% oh-my-pi payload saving is a lighter wire format; the table above is what that
|
|
241
|
+
> format asks the model to hold in its head instead — renumbering, tag-chasing, node choice —
|
|
242
|
+
> the exact component that fails most (46–51% patch-failure rates on replace-style edits). This
|
|
243
|
+
> plugin's 31% is the price of a contract where a wrong edit cannot land, and any rejection
|
|
244
|
+
> needs no re-read.
|
|
118
245
|
|
|
119
246
|
## Benchmark
|
|
120
247
|
|
|
121
248
|
Measured on the same 103-line file with the same 12 replacements (8 single-line, 4 multi-line of
|
|
122
|
-
3/6/10/15 lines), tokenized with the pinned `js-tiktoken` `cl100k_base
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
|
249
|
+
3/6/10/15 lines), tokenized with the pinned `js-tiktoken` `cl100k_base`. Three arms emit the same
|
|
250
|
+
replacements: this plugin's `edit` (two 3-char anchors), a `str_replace` tool (old text echoed
|
|
251
|
+
verbatim), and [`@oh-my-pi/hashline`](https://www.npmjs.com/package/@oh-my-pi/hashline) in both of
|
|
252
|
+
its modes — one `[path#tag]` section per edit (`seq`) and one multi-hunk batch document (`batch`):
|
|
253
|
+
|
|
254
|
+
| Criterion | hashline | str_replace | oh-my-pi seq / batch |
|
|
255
|
+
| ----------- | :---: | :---: | :---: |
|
|
256
|
+
| Replaced text sent over the wire | ✅ never | ❌ every edit | ✅ never |
|
|
257
|
+
| Output tokens saved (12-edit session) | ✅ **31%** | ❌ 0% | ✅ **42% / 53%** |
|
|
258
|
+
| Multi-line range savings (3–15 lines) | ✅ **29–47%** | ❌ 0% | ✅ **40–53%** |
|
|
259
|
+
| Effective cost at 5× output pricing | ✅ **~1.4× less** | ❌ 1× | ✅ **~1.7× / ~2.1× less** |
|
|
260
|
+
| Ranges verified against served state | ✅ 100% | ❌ none | ~ file version only |
|
|
261
|
+
| Line numbers the model must track | ✅ none — content anchors | ✅ none — text match | ❌ renumber every edit |
|
|
262
|
+
| Deterministic, reproducible locally | ✅ `npm run benchmark` | — | — |
|
|
132
263
|
|
|
133
264
|
### Reproducible
|
|
134
265
|
|
|
135
266
|
The numbers above are **deterministic and you can reproduce them locally** — `npm run benchmark`:
|
|
136
267
|
|
|
137
|
-
| Scenario | Lines | hashline | str_replace |
|
|
268
|
+
| Scenario | Lines | hashline | str_replace | oh-my-pi seq | oh-my-pi batch |
|
|
138
269
|
| --- | :---: | :---: | :---: | :---: | :---: |
|
|
139
|
-
| single-line ×8 | 1 | 309 | 324 |
|
|
140
|
-
| multi-line ×4 | 3–15 | 393 | 691 |
|
|
141
|
-
| **TOTAL ×12** | | **702** | **1015** | **
|
|
270
|
+
| single-line ×8 | 1 | 309 | 324 | 241 | — |
|
|
271
|
+
| multi-line ×4 | 3–15 | 393 | 691 | 349 | — |
|
|
272
|
+
| **TOTAL ×12** | | **702** | **1015** | **590** | **480** |
|
|
273
|
+
|
|
274
|
+
Saved vs `str_replace`: hashline **313 (31%)** · oh-my-pi per-edit **425 (42%)** · oh-my-pi batch **535 (53%)**.
|
|
142
275
|
|
|
143
276
|
The script is deterministic by construction: a frozen corpus, a content-addressed edit script that
|
|
144
|
-
self-checks (a reformatted corpus throws instead of silently changing what's measured),
|
|
145
|
-
tokenizer
|
|
277
|
+
self-checks (a reformatted corpus throws instead of silently changing what's measured), a pinned
|
|
278
|
+
tokenizer, and oh-my-pi payloads validated against the package's published grammar before counting.
|
|
279
|
+
Because everything is fixed, `npm run benchmark` gives everyone the same result — the numbers in
|
|
280
|
+
this README are a snapshot of that run; regenerate, don't trust.
|
|
146
281
|
|
|
147
282
|
> **Scope & honesty.** The benchmark measures **request-payload tokens** — what the model emits per
|
|
148
283
|
> edit call — with identical read traffic excluded (it cancels) and identical replacement text.
|
|
149
284
|
> It does **not** model transcription failure and retries, which is where the real-world gap is
|
|
150
285
|
> largest: the original [harness-problem](https://stencil.so/blog/the-harness-problem) post reported
|
|
151
286
|
> a **61% output-token reduction** and patch-failure drops from 46–51% to near zero after switching
|
|
152
|
-
> to anchored edits.
|
|
153
|
-
>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
```sh
|
|
158
|
-
dsh plugin --profile <name> add dsh-better-edit # from npm
|
|
159
|
-
dsh plugin --profile <name> add /path/to/dsh-better-edit # from a local checkout
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
The profile's next session runs with the hashline tools installed. To verify the layer is active:
|
|
163
|
-
|
|
164
|
-
```sh
|
|
165
|
-
dsh --profile <name> --dump-config # shows a "# == dsh-better-edit" layer
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
| Requirement | |
|
|
169
|
-
| --- | --- |
|
|
170
|
-
| Node | `^22.19.0 \|\| >=24.0.0` (dsh's requirement; the store uses `node:sqlite`) |
|
|
171
|
-
| Profile | a dsh profile (`dsh plugin` initializes one on first use) |
|
|
172
|
-
| Backends | sandboxed / remote filesystems supported (writes go through `ctx.fs`) |
|
|
287
|
+
> to anchored edits. It also does **not** model what a line-numbered format costs the model *between*
|
|
288
|
+
> calls — renumbering and re-fetching the file tag after every edit — nor block-op power, nor the
|
|
289
|
+
> Bun-vs-Node runtime difference, nor the fact that `@oh-my-pi/hashline` is a standalone patcher
|
|
290
|
+
> while this plugin is a dsh tool pair with `read`/`edit`/`undo`. Full methodology, the per-edit
|
|
291
|
+
> table, and the complete limitation list in [`benchmark/README.md`](benchmark/README.md). The correctness gap behind those numbers is spelled out above in [Correctness in edge cases](#correctness-in-edge-cases).
|
|
173
292
|
|
|
174
293
|
## Tools
|
|
175
294
|
|
|
@@ -250,7 +369,7 @@ dsh-better-edit/
|
|
|
250
369
|
│ ├── write-hook.ts # auto-read appended to write results
|
|
251
370
|
│ ├── served-store.ts # per-workspace SQLite store (node:sqlite)
|
|
252
371
|
│ └── workspace.ts # session-cwd AsyncLocalStorage carrier
|
|
253
|
-
├── benchmark/ # reproducible hashline-vs-str_replace token benchmark
|
|
372
|
+
├── benchmark/ # reproducible hashline-vs-str_replace-vs-oh-my-pi token benchmark
|
|
254
373
|
│ └── corpus/ # frozen 103-line fixture
|
|
255
374
|
├── test/ # 615 tests (ported + regression)
|
|
256
375
|
├── assets/ # logo + banner
|
|
@@ -290,6 +409,7 @@ served-tail truncation fix, reproducible benchmark, EN + 中文 READMEs, publish
|
|
|
290
409
|
|
|
291
410
|
<details><summary>Next</summary>
|
|
292
411
|
|
|
412
|
+
- **Close or justify the gap vs @oh-my-pi/hashline** (reference: [`../oh-my-pi.md`](../oh-my-pi.md)). The sibling patch language is payload-lighter — 42%/53% vs our 31% vs `str_replace` on the benchmark, because a bare patch document skips the JSON envelope we pay per call — and offers four abilities we do not support: syntactic block ops (`PUT N*:`), registers + `REM`/`MV`, one multi-hunk document per change, and a pluggable filesystem. The counterweight is correctness: its line numbers are unverified (a wrong number on a current tag lands silently), every edit renumbers, stale tags trigger best-effort 3-way merge instead of verification, and the grammar raises the model skill floor. Decide each ability reject-or-adopt on its own merits — the payload gap alone is not a reason to switch formats.
|
|
293
413
|
- Verify 0.1.6 live in a dsh session after the served-tail fix.
|
|
294
414
|
- Upstream the served-tail truncation fix to pi-hashline-edit-lsz / upstream (their `upsertServed`
|
|
295
415
|
never truncates either).
|
package/README.zh.md
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<h1 align="center">dsh-better-edit</h1>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
<strong
|
|
9
|
-
|
|
8
|
+
<strong>一个专为 DeepSeek Harness 而生的更好的编辑工具。<br>
|
|
9
|
+
底层基于 hash-anchored 定位——不依赖行号,也不靠字符串替换,更少的词源消耗,留出更多的上下文空间给真正的工作。</strong>
|
|
10
10
|
</p>
|
|
11
11
|
|
|
12
12
|
<p align="center">
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
<a href="#快速开始">快速开始</a> •
|
|
19
19
|
<a href="#为什么用-hashline">为什么用 Hashline</a> •
|
|
20
20
|
<a href="#基准测试">基准测试</a> •
|
|
21
|
-
<a href="#安装">安装</a> •
|
|
22
21
|
<a href="#工具">工具</a> •
|
|
23
22
|
<a href="#致谢">致谢</a>
|
|
24
23
|
</p>
|
|
@@ -53,6 +52,26 @@ Hashline 用两个哈希代替旧文本——**编辑 token 减少 31%**(多
|
|
|
53
52
|
|
|
54
53
|
## 快速开始
|
|
55
54
|
|
|
55
|
+
### 安装
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
npx @deepseek-ai/dsh plugin --profile web add github:Rianico/dsh-better-edit # 从 github
|
|
59
|
+
npx @deepseek-ai/dsh plugin --profile web add dsh-better-edit # 从 npm
|
|
60
|
+
npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-better-edit # 从本地源码
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
该 profile 的下一个会话将带着 hashline 工具运行。验证该层是否生效:
|
|
64
|
+
|
|
65
|
+
```sh
|
|
66
|
+
dsh --profile <name> --dump-config # 会显示 "# == dsh-better-edit" 层
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
| 要求 | |
|
|
70
|
+
| --- | --- |
|
|
71
|
+
| Node | `^22.19.0 \|\| >=24.0.0`(dsh 的要求;存储使用 `node:sqlite`) |
|
|
72
|
+
| Profile | 一个 dsh profile(首次使用 `dsh plugin` 时初始化) |
|
|
73
|
+
| 后端 | 支持沙箱/远程文件系统(写入经 `ctx.fs`) |
|
|
74
|
+
|
|
56
75
|
`read` 返回的每一行都带有哈希前缀——哈希*就是*这一行的地址:
|
|
57
76
|
|
|
58
77
|
```text
|
|
@@ -80,73 +99,139 @@ kQm│}
|
|
|
80
99
|
kQm │ }
|
|
81
100
|
```
|
|
82
101
|
|
|
102
|
+
## 按 preset 配置指引
|
|
103
|
+
|
|
104
|
+
`tool:read` / `tool:edit` / `tool:batch_edit` / `tool:undo_last_edit` 四个提示词片段的指引是
|
|
105
|
+
纯 Markdown 文件,可以按 agent preset 覆盖。覆盖文件位于插件的共享主目录——绝不放在工作区存储中:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
$DSH_HOME/plugins/dsh-better-edit/<preset>/<section>.md
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
(默认主目录为 `~/.dsh`,即 `~/.dsh/plugins/dsh-better-edit/`)。片段对照表:
|
|
112
|
+
|
|
113
|
+
| 文件 | 提示词片段 | 默认 order |
|
|
114
|
+
| --- | --- | --- |
|
|
115
|
+
| `read.md` | `tool:read` | 130 |
|
|
116
|
+
| `edit.md` | `tool:edit` | 131 |
|
|
117
|
+
| `batch_edit.md` | `tool:batch_edit` | 132 |
|
|
118
|
+
| `undo_last_edit.md` | `tool:undo_last_edit` | 133 |
|
|
119
|
+
|
|
120
|
+
首次启动时插件会为四个随附 preset——`standard/`、`code/`、`minimal/`、`cordis/`——各自写入编译内置的
|
|
121
|
+
可编辑指引文件(含 `order` front-matter),让每个 preset 的指引一开始就可编辑,而不是空白。插件主目录
|
|
122
|
+
根的 `README.md` 说明整套机制。文件只在首次写入时生成、之后绝不被覆盖,因此你的修改会保留——唯一的例外是重置(见下文 *重置 / 恢复默认*)。preset 目录
|
|
123
|
+
里可以只放你想覆盖的片段文件,其余自动回退到编译内置默认值。
|
|
124
|
+
|
|
125
|
+
文件默认为纯文本;除非以 `order` front-matter 栅栏开头,它会改变该片段在组装后的系统提示中的位置:
|
|
126
|
+
|
|
127
|
+
```md
|
|
128
|
+
---
|
|
129
|
+
order: 150
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
<片段文本>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
每个片段的解析顺序为:读取 `<preset>/<section>.md`,否则回退到编译内置默认值。文件只在 agent 的
|
|
136
|
+
session-start 时读取一次,因此修改只影响新会话——绝不影响进行中的会话。没有种子目录的 preset(例如
|
|
137
|
+
用户自建的)会回退到编译内置默认值,除非你把某个种子目录复制成它的名字。没有 `agentPresets` 服务
|
|
138
|
+
(即没有 preset 名册)的部署继续使用编译内置默认值,完全不会触碰这些文件;
|
|
139
|
+
preset 从来不是必需的。
|
|
140
|
+
|
|
141
|
+
### 重置 / 恢复默认
|
|
142
|
+
|
|
143
|
+
**想让指引“回到默认”?删掉覆盖文件,或把它清空(同时删掉开头的 `---` 栅栏)即可。**
|
|
144
|
+
|
|
145
|
+
清空文件时,只要文件里是空白内容、并且没有 `---` 栅栏,插件就认为你不想再自定义这一片段了,于是:
|
|
146
|
+
|
|
147
|
+
- 新会话开始时,直接使用插件内置的默认指引;
|
|
148
|
+
- 下一次启动插件时,会用默认内容把这个文件重新生成。
|
|
149
|
+
|
|
150
|
+
再细致一点:
|
|
151
|
+
|
|
152
|
+
- **为什么要连栅栏一起删**:只要文件里还有 `---` 栅栏,哪怕是空的、什么内容也没有,插件都当成“你有意留空”,不会去动它。所以“故意留空”就保留栅栏;“恢复默认”就把栅栏和内容一起清掉。
|
|
153
|
+
- **栅栏写错了会怎样**:少了一个 `---`、`order` 不是数字、出现了不认识的键——只要栅栏格式不对,插件会直接忽略这个文件:仍然渲染默认指引,并在日志里提示是哪个文件、哪里写错了。你写的正文会原样留在磁盘上,方便改好后再用。
|
|
154
|
+
- **自带 preset 与自定义 preset**:插件自带的四个 preset(`standard`、`code`、`minimal`、`cordis`)会在下一次启动时自动补全空白文件;自定义 preset 里删除的覆盖文件不会自动出现(删了就当“没有这个文件”)。删掉某一整个 preset 目录,下次启动时插件会重新生成里面的四个文件(仅限自带 preset)。
|
|
155
|
+
- **恢复的是“当前版本”的默认**:插件升级后,重置得到的是新版本带的新默认内容,不是旧版本留下的。
|
|
156
|
+
|
|
157
|
+
文件的重新生成只发生在插件启动时,绝不影响进行中的会话。
|
|
158
|
+
|
|
83
159
|
## 为什么用 Hashline
|
|
84
160
|
|
|
85
161
|
**省 token。** 一次编辑调用只携带 `remove_from` / `remove_to`(两个 3 字符哈希)加替换文本——从不回显被替换的文本。`str_replace` 调用则必须逐字复现被替换的文本。在一个真实文件上的 12 次编辑会话中,这可以**减少 31% 的输出 token**(多行范围达 43%)——而且这些是*输出* token,按输入的约 5-6 倍计费。见[基准测试](#基准测试)。
|
|
86
162
|
|
|
163
|
+
**但这从来不是“最省 token”。** 节省随被替换文本的规模增长——单行微调时几乎持平——而且像 [@oh-my-pi/hashline](#对比) 这样的紧凑补丁语言还能发出更轻的负载(同一会话中 42–53%)。关键在于**正确形态**的编辑调用:不复述旧代码,模型除了两个稳定的内容地址外无需跟踪任何东西。
|
|
164
|
+
|
|
87
165
|
**正确性。** 每个解析出的编辑范围都会与模型实际看到的行逐行核对。过期、从未提供或歧义的范围会在**写入任何内容之前**被硬性拒绝,并把当前范围以全新锚点的形式回显(reject-and-serve)——重试无需 `read`。
|
|
88
166
|
|
|
89
167
|
**面向 Agent 的现代编辑范式。** 内容地址锚点与行号无关:编辑文件的一部分,其余行的哈希保持不变,因此连续编辑无需重新读取。模型按行**是什么**来定位,而不是按它之前在第几行。
|
|
90
168
|
|
|
91
169
|
### 对比
|
|
92
170
|
|
|
93
|
-
| | hashline `edit` | `str_replace
|
|
171
|
+
| | hashline `edit` | `str_replace`(Claude Code / Codex) | @oh-my-pi/hashline 补丁 |
|
|
94
172
|
| --- | :---: | :---: | :---: |
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
|
|
|
102
|
-
|
|
103
|
-
|
|
173
|
+
| 调用中永不回显被替换文本 | ✅ 只有两个哈希 | ❌ 逐字回显 | ✅ 只有 `+` 行 |
|
|
174
|
+
| 按什么定位行 | 内容哈希 | 文本匹配 | 行号 + 文件内容标签 |
|
|
175
|
+
| 对照模型所见内容校验 | ✅ 每一行 | ❌ 取第一个匹配 | ~ 仅文件版本 |
|
|
176
|
+
| 检测文件已过期 | ✅ 拒绝并回传新锚点 | ❌ 可能匹配到错误位置 | ✅ 标签不匹配 → 拒绝或三方合并 |
|
|
177
|
+
| 上方编辑后锚点依然有效 | ✅ 内容寻址 | ✅ 基于内容 | ❌ 重新编号 + 新标签 |
|
|
178
|
+
| 连续编辑无需重读 | ✅ diff 提供新锚点 | ~ | ~ 从编辑响应取行号 |
|
|
179
|
+
| 文本重复时无歧义 | ✅ 边界锚点需校验 | ❌ 取第一个出现 | ~ 按位置,行未逐行校验 |
|
|
180
|
+
| 错行编辑永远不会悄悄落盘 | ✅ 每一行都校验 | ❌ 取第一个匹配 | ~ 原则上可能(标签只校验版本,不校验行) |
|
|
181
|
+
| 块操作 / 寄存器 / `MV` / `REM` | ❌ | ❌ | ✅ |
|
|
182
|
+
| 一次变更一个文档 | ❌ 每次一个调用 | ❌ 每次一个调用 | ✅ 多 hunk 补丁 |
|
|
183
|
+
| 运行时 | ✅ Node(dsh) | — | ⚠️ 仅 Bun |
|
|
184
|
+
| 撤销 | ✅ 持久化 | ❌ | ❌ 不在范围内 |
|
|
185
|
+
|
|
186
|
+
> `~` = 偶尔/不稳定。`@oh-my-pi/hashline` 是一种紧凑的行锚定补丁语言([npm](https://www.npmjs.com/package/@oh-my-pi/hashline)、[仓库](https://github.com/can1357/oh-my-pi/tree/main/packages/hashline)):`[path#tag]` 头把每个 hunk 绑定到全文件内容哈希,`PUT N.=M:` 按行号定位;每次编辑都会重新编号——下一次的行号与标签取自编辑响应或重新 `read`。
|
|
187
|
+
|
|
188
|
+
**不同的工作,同一条血脉。** 两者都源于 [harness-problem](https://stencil.so/blog/the-harness-problem) 的洞见:模型绝不该复述旧代码。`@oh-my-pi/hashline` 是**补丁语言库**——负载更轻(每次编辑省 42%,单个批量文档省 53%,见[基准测试](#基准测试)),支持语法块操作(`PUT N*:`)、寄存器、`REM`/`MV`、多 hunk 文档、可插拔文件系统(任何后端),以及标签过期时的会话感知三方合并恢复。本插件则是一对 **dsh 工具**:`read` 把 3 字符内容哈希交给模型,`edit` 取其中两个,并对解析出的每一行对照已提供状态校验——无需重新编号、无需重新取标签、错误锚点永远不可能落到错误的行,`undo_last_edit` 重启后依然有效。代价:每次编辑的 JSON 外壳会多一点负载、没有块操作,并且它活在 dsh(Node)内部,而不是独立补丁器(Bun)。要跨后端的补丁格式选 hashline 库;要在 Agent 里做可校验、内容寻址的编辑,选 hashline 工具。
|
|
189
|
+
|
|
190
|
+
### 边界情况下的正确性
|
|
191
|
+
|
|
192
|
+
token 基准测试衡量的是模型发出的负载——它假设模型每次都能拿到**正确**的地址,而且免费。正确性才是两种 hashline 实现真正分道扬镳的地方。下面是 harness-problem 文献里的真实故障模式(错行编辑、漂移、重复文本),以及各自在遭遇它们时的表现:
|
|
193
|
+
|
|
194
|
+
| 边界情况 | hashline `edit`(本插件) | @oh-my-pi/hashline 补丁 |
|
|
195
|
+
| --- | --- | --- |
|
|
196
|
+
| 错误地址(锚点/行号差一行) | **不可能**——锚点解析到具体行;解析出的每一行都对照已提供状态校验,在**写入任何内容之前**被拒绝 | **可能**——当前标签下的错误行号会**悄悄**落到错误位置;标签只证明文件版本,从不证明行 |
|
|
197
|
+
| 模型查看后文件在磁盘上被改动 | 硬拒绝 + 回传新锚点(reject-and-serve);重试无需 `read` | 标签不匹配 → 拒绝**或**对未知的当前内容做尽力而为的三方合并 |
|
|
198
|
+
| 上方编辑导致文件移位 | 什么都不移位——锚点是内容地址;diff 提供新锚点 | **每次编辑都重新编号**——“RE-GROUND AFTER EVERY EDIT” 是它自己的头号规则;账由模型记 |
|
|
199
|
+
| 重复/相同文本 | 每行哈希唯一(冲突已消解);歧义 → `[E_AMBIGUOUS_ANCHOR]` | 基于位置,重复不会混淆——但位置本身未被校验 |
|
|
200
|
+
| 从未展示给模型的行 | `[E_RANGE_UNSERVED]`——硬拒绝并回传新锚点 | 未展示的 hunk 被拒绝——同样依赖模型知道自己看过什么 |
|
|
201
|
+
| 表达式中间 / 错误的块节点 | 无关——任何已校验的行范围都合法 | 语法规则 + `PUT N*:` 节点选择;点错(锚在 `def` 会让装饰器变成孤儿)会悄悄落错;无语法检查 |
|
|
202
|
+
| 多编辑批量中途失败 | `batch_edit`——原子、全有或全无;失败项以新锚点回显 | 多段补丁先预检——同样原子 |
|
|
203
|
+
|
|
204
|
+
> oh-my-pi 42–53% 的负载节省来自更轻的线格式;上表才是该格式反过来要求模型记在脑中的东西——重新编号、追标签、选节点——而这恰恰是最容易出错的组件(替换式编辑的补丁失败率 46–51%)。本插件 31% 的代价买来的是一个“错编辑落不了地、任何拒绝都不需要重读”的契约。
|
|
104
205
|
|
|
105
206
|
## 基准测试
|
|
106
207
|
|
|
107
|
-
在同一份 103 行文件上、用相同的 12 组替换(8 个单行、4 个 3/6/10/15 行多行),以固定的 `js-tiktoken` `cl100k_base`
|
|
208
|
+
在同一份 103 行文件上、用相同的 12 组替换(8 个单行、4 个 3/6/10/15 行多行),以固定的 `js-tiktoken` `cl100k_base` 词表测量。三个被测方发出相同的替换文本:本插件的 `edit`(两个 3 字符锚点)、`str_replace` 工具(逐字回显旧文本)、以及 [`@oh-my-pi/hashline`](https://www.npmjs.com/package/@oh-my-pi/hashline) 的两种模式——每次编辑一个 `[path#tag]` 段(`seq`)和一个多 hunk 批量文档(`batch`):
|
|
108
209
|
|
|
109
|
-
| 指标 | hashline | str_replace |
|
|
110
|
-
| ----------- | :---: | :---: |
|
|
111
|
-
| 被替换文本是否上线 | ✅ 从不 | ❌ 每次编辑都发 |
|
|
112
|
-
| 输出 token 节省(12 次编辑) | ✅ **31%** | ❌ 0% |
|
|
113
|
-
| 多行范围节省(3–15 行) | ✅ **29–47%** | ❌ 0% |
|
|
114
|
-
| 按 5 倍输出计价的实际成本 | ✅ **低约 1.4 倍** | ❌ 1× |
|
|
115
|
-
| 范围对照已提供状态校验 | ✅ 100% | ❌ 无 |
|
|
116
|
-
|
|
|
210
|
+
| 指标 | hashline | str_replace | oh-my-pi seq / batch |
|
|
211
|
+
| ----------- | :---: | :---: | :---: |
|
|
212
|
+
| 被替换文本是否上线 | ✅ 从不 | ❌ 每次编辑都发 | ✅ 从不 |
|
|
213
|
+
| 输出 token 节省(12 次编辑) | ✅ **31%** | ❌ 0% | ✅ **42% / 53%** |
|
|
214
|
+
| 多行范围节省(3–15 行) | ✅ **29–47%** | ❌ 0% | ✅ **40–53%** |
|
|
215
|
+
| 按 5 倍输出计价的实际成本 | ✅ **低约 1.4 倍** | ❌ 1× | ✅ **低约 1.7 倍 / 2.1 倍** |
|
|
216
|
+
| 范围对照已提供状态校验 | ✅ 100% | ❌ 无 | ~ 仅文件版本 |
|
|
217
|
+
| 模型需要跟踪的行号 | ✅ 无——内容锚点 | ✅ 无——文本匹配 | ❌ 每次编辑重新编号 |
|
|
218
|
+
| 确定性、可在本地复现 | ✅ `npm run benchmark` | — | — |
|
|
117
219
|
|
|
118
220
|
### 可复现
|
|
119
221
|
|
|
120
222
|
上面的数字**是确定性的,你可以本地复现**——`npm run benchmark`:
|
|
121
223
|
|
|
122
|
-
| 场景 | 行数 | hashline | str_replace |
|
|
224
|
+
| 场景 | 行数 | hashline | str_replace | oh-my-pi seq | oh-my-pi batch |
|
|
123
225
|
| --- | :---: | :---: | :---: | :---: | :---: |
|
|
124
|
-
| 单行 ×8 | 1 | 309 | 324 |
|
|
125
|
-
| 多行 ×4 | 3–15 | 393 | 691 |
|
|
126
|
-
| **合计 ×12** | | **702** | **1015** | **
|
|
127
|
-
|
|
128
|
-
脚本天然确定:固定语料、内容寻址且自带自检的编辑脚本(语料被重排会直接抛错,而不是悄悄改变测量对象)、固定版本的 tokenizer。因为一切都是固定的,`npm run benchmark` 对每个人都是同一个结果。
|
|
226
|
+
| 单行 ×8 | 1 | 309 | 324 | 241 | — |
|
|
227
|
+
| 多行 ×4 | 3–15 | 393 | 691 | 349 | — |
|
|
228
|
+
| **合计 ×12** | | **702** | **1015** | **590** | **480** |
|
|
129
229
|
|
|
130
|
-
|
|
230
|
+
相对 `str_replace` 的节省:hashline **313(31%)** · oh-my-pi 逐次 **425(42%)** · oh-my-pi 批量 **535(53%)**。
|
|
131
231
|
|
|
132
|
-
|
|
232
|
+
脚本天然确定:固定语料、内容寻址且自带自检的编辑脚本(语料被重排会直接抛错,而不是悄悄改变测量对象)、固定版本的 tokenizer,且 oh-my-pi 负载在计数前会对照其发布的语法校验。因为一切都是固定的,`npm run benchmark` 对每个人都是同一个结果——本 README 里的数字就是该次运行的一个快照;重新生成,不要轻信。
|
|
133
233
|
|
|
134
|
-
|
|
135
|
-
dsh plugin --profile <name> add dsh-better-edit # 从 npm
|
|
136
|
-
dsh plugin --profile <name> add /path/to/dsh-better-edit # 从本地源码
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
该 profile 的下一个会话将带着 hashline 工具运行。验证该层是否生效:
|
|
140
|
-
|
|
141
|
-
```sh
|
|
142
|
-
dsh --profile <name> --dump-config # 会显示 "# == dsh-better-edit" 层
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
| 要求 | |
|
|
146
|
-
| --- | --- |
|
|
147
|
-
| Node | `^22.19.0 \|\| >=24.0.0`(dsh 的要求;存储使用 `node:sqlite`) |
|
|
148
|
-
| Profile | 一个 dsh profile(首次使用 `dsh plugin` 时初始化) |
|
|
149
|
-
| 后端 | 支持沙箱/远程文件系统(写入经 `ctx.fs`) |
|
|
234
|
+
> **范围与诚实。** 基准测试衡量的是**请求负载 token**——每次编辑调用时模型发出的内容——读文件流量完全相同故已排除(可抵消),替换文本也完全一致。它**没有**建模转录失败与重试,而真实差距恰恰主要在那边:最初的 [harness-problem](https://stencil.so/blog/the-harness-problem) 文章报告改用锚定编辑后**输出 token 减少 61%**,补丁失败率从 46–51% 降至接近零。它同样**没有**建模行号格式在调用**之间**让模型付出的代价——每次编辑后重新编号、重新获取文件标签——也不包括块操作能力、Bun 与 Node 的运行时差异,以及 `@oh-my-pi/hashline` 是独立补丁器、而本插件是带 `read`/`edit`/`undo` 的 dsh 工具对这一事实。完整方法论、逐编辑表与完整局限清单见 [`benchmark/README.md`](benchmark/README.md)。这些数字背后的正确性差距见上文[边界情况下的正确性](#边界情况下的正确性)。
|
|
150
235
|
|
|
151
236
|
## 工具
|
|
152
237
|
|
|
@@ -216,7 +301,7 @@ dsh-better-edit/
|
|
|
216
301
|
│ ├── write-hook.ts # 附加到 write 结果的自动读取
|
|
217
302
|
│ ├── served-store.ts # 按工作区的 SQLite 存储(node:sqlite)
|
|
218
303
|
│ └── workspace.ts # 会话 cwd 的 AsyncLocalStorage 载体
|
|
219
|
-
├── benchmark/ # 可复现的 hashline 与
|
|
304
|
+
├── benchmark/ # 可复现的 hashline、str_replace 与 oh-my-pi token 基准测试
|
|
220
305
|
│ └── corpus/ # 固定的 103 行语料
|
|
221
306
|
├── test/ # 615 个测试(移植 + 回归)
|
|
222
307
|
├── assets/ # logo 与 banner
|
|
@@ -251,6 +336,7 @@ npm publish --registry https://registry.npmjs.org # 版本未打 tag 前会被
|
|
|
251
336
|
|
|
252
337
|
<details><summary>下一步</summary>
|
|
253
338
|
|
|
339
|
+
- **缩小或证明与 @oh-my-pi/hashline 的差距**(参考:[`../oh-my-pi.md`](../oh-my-pi.md))。这个兄弟补丁语言负载更轻——基准测试中相对 `str_replace` 省 42%/53%,而我们省 31%,因为它裸文本式的补丁文档跳过了我们每次调用都要付的 JSON 外壳——还提供了我们不支持的四种能力:语法块操作(`PUT N*:`)、寄存器 + `REM`/`MV`、一次变更一个多 hunk 文档、可插拔文件系统。代价在正确性一侧:它的行号未经验证(当前标签下的错行号会静默落盘)、每次编辑都要重新编号、过期标签触发尽力而为的三方合并而非校验、语法也抬高了模型的技能门槛。逐项决定是拒绝还是采纳——负载差距本身不足以成为切换格式的理由。
|
|
254
340
|
- 在 dsh 会话中实测 0.1.7(served-tail 修复之后)。
|
|
255
341
|
- 把 served-tail 截断修复回馈给 pi-hashline-edit-lsz / 上游(他们的 `upsertServed` 同样从不截断)。
|
|
256
342
|
- 对照下一个 dsh 版本重新核对插件接线(当前固定在 `0.1.0-rc.6`;dsh 处于开发者预览阶段,承诺会有破坏性变更)。
|