dsh-better-edit 1.2.2 → 1.2.3
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 +7 -0
- package/lib/hashline/anchor-pipeline.js +10 -35
- package/lib/read-and-serve.js +2 -2
- package/lib/types/read-and-serve.d.ts +2 -2
- package/lib/write-hook.js +10 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,13 @@ All notable changes to this project will be documented in this file.
|
|
|
11
11
|
|
|
12
12
|
## [Unreleased]
|
|
13
13
|
|
|
14
|
+
## [1.2.3] - 2026-11-16
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **hashline:** stop naming unverified anchors in `E_MALFORMED_ANCHOR` hints — a multi-line paste is refused by shape with the block redacted to `<n>-line block`, and `diagRef`'s `wUp`/`AU6` defaults are gone (#108) (#118)
|
|
19
|
+
* **write-hook:** record the `fs/observed` observation on the post-write auto-read, so an `edit` using an auto-read anchor no longer fails the host read-before-write gate with `E_BLIND_REPLACE` / `E_STALE_RANGE` — the emit is unconditional and fail-open, and the serve seam stays emission-free (ADR-0030) (#109) (#119)
|
|
20
|
+
|
|
14
21
|
## [1.2.2] - 2026-11-15
|
|
15
22
|
|
|
16
23
|
### Bug Fixes
|
|
@@ -34,21 +34,6 @@ function diagRef(ref) {
|
|
|
34
34
|
reason: 'Use the hash alone (e.g. "aB3") — no line numbers or trailing content.',
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
if (trimmed.includes("│") && trimmed.includes("\n")) {
|
|
38
|
-
const lines = trimmed.split("\n");
|
|
39
|
-
const first = lines[0] ?? "";
|
|
40
|
-
const last = lines[lines.length - 1] ?? "";
|
|
41
|
-
const hashRe = new RegExp(HASH_CLASS);
|
|
42
|
-
const firstMatch = first.match(hashRe);
|
|
43
|
-
const lastMatch = last.match(hashRe);
|
|
44
|
-
const firstHash = firstMatch?.[0] ?? "wUp";
|
|
45
|
-
const lastHash = lastMatch?.[0] ?? "AU6";
|
|
46
|
-
const preview = first.slice(0, 60);
|
|
47
|
-
return {
|
|
48
|
-
rawAnchor: trimmed,
|
|
49
|
-
reason: `anchor_from must be a single bare 3-char hash (e.g. "wUp"), not a block with HASH│. Received ${lines.length} lines starting "${preview}…" — use only the first hash "${firstHash}" as anchor_from and "${lastHash}" as anchor_to, and put the new content (without HASH│) in replace_with.`,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
37
|
if (trimmed.includes("│")) {
|
|
53
38
|
return {
|
|
54
39
|
rawAnchor: trimmed,
|
|
@@ -187,31 +172,21 @@ function assertItem(edit) {
|
|
|
187
172
|
}
|
|
188
173
|
}
|
|
189
174
|
const ANCHOR_ROW_RE = new RegExp(`^([+-]?)(${HASH_CLASS})│`);
|
|
190
|
-
function firstHashFromBlock(block) {
|
|
191
|
-
for (const line of block.split("\n")) {
|
|
192
|
-
const m = line.match(ANCHOR_ROW_RE);
|
|
193
|
-
if (m)
|
|
194
|
-
return m[2];
|
|
195
|
-
const bare = line.match(new RegExp(HASH_CLASS));
|
|
196
|
-
if (bare)
|
|
197
|
-
return bare[0];
|
|
198
|
-
}
|
|
199
|
-
return undefined;
|
|
200
|
-
}
|
|
201
175
|
export function resEdit(edit, _warnings) {
|
|
202
176
|
assertItem(edit);
|
|
203
177
|
const editLines = parseText(edit.replace_with);
|
|
204
178
|
const bounds = [edit.anchor_from, edit.anchor_to].map((ref) => {
|
|
205
179
|
const trimmed = ref.trim();
|
|
180
|
+
// #108: a pasted block carries no verified coordinate — refuse by SHAPE, naming no
|
|
181
|
+
// extracted hash. The old first-3-char-alnum-run guess minted a pseudo-anchor whose
|
|
182
|
+
// "use bare <hash> next time" hint steered the model into an unrelated line.
|
|
206
183
|
if (trimmed.includes("\n")) {
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
});
|
|
214
|
-
}
|
|
184
|
+
const lines = trimmed.split("\n").length;
|
|
185
|
+
throw new DomainError("E_MALFORMED_ANCHOR", {
|
|
186
|
+
// Redacted, upstream shape: never echo the pasted block back into the transcript.
|
|
187
|
+
rawAnchor: `${lines}-line block`,
|
|
188
|
+
reason: `anchor_from/anchor_to must be a single bare 3-char hash — the anchor read() served beside the one line you mean. You passed a ${lines}-line block; pass that bare hash, or re-read the file.`,
|
|
189
|
+
});
|
|
215
190
|
}
|
|
216
191
|
const match = trimmed.match(ANCHOR_ROW_RE);
|
|
217
192
|
if (match) {
|
|
@@ -311,7 +286,7 @@ function swapReversedRanges(edit, fileHashes, warnings) {
|
|
|
311
286
|
return { ...edit, hash_bounds: [endRef, startRef] };
|
|
312
287
|
}
|
|
313
288
|
/** @internal — private to anchor-pipeline seam */
|
|
314
|
-
function valEdit(edit, fileLines, fileHashes,
|
|
289
|
+
function valEdit(edit, fileLines, fileHashes, _warnings, signal) {
|
|
315
290
|
assertAligned(fileLines, fileHashes, "valEdit");
|
|
316
291
|
const mismatches = [];
|
|
317
292
|
const hashIndex = new Map();
|
package/lib/read-and-serve.js
CHANGED
|
@@ -31,8 +31,8 @@ const SERVE_NOT_RECORDED_NOTE = "WARNING: the rows above were NOT recorded as se
|
|
|
31
31
|
* carries the UTF-8 rewrite note when the file had decode errors.
|
|
32
32
|
*
|
|
33
33
|
* Emits nothing on the fs-observation gate — callers that need the
|
|
34
|
-
* observation recorded (the `read` tool
|
|
35
|
-
* context.
|
|
34
|
+
* observation recorded (the `read` tool and the write auto-read hook) do that
|
|
35
|
+
* themselves with their exec context.
|
|
36
36
|
*/
|
|
37
37
|
export async function readAndServe(io, rawPath, cwd, options) {
|
|
38
38
|
const { sessionKey, signal } = options;
|
|
@@ -43,7 +43,7 @@ export interface ReadAndServeResult {
|
|
|
43
43
|
* carries the UTF-8 rewrite note when the file had decode errors.
|
|
44
44
|
*
|
|
45
45
|
* Emits nothing on the fs-observation gate — callers that need the
|
|
46
|
-
* observation recorded (the `read` tool
|
|
47
|
-
* context.
|
|
46
|
+
* observation recorded (the `read` tool and the write auto-read hook) do that
|
|
47
|
+
* themselves with their exec context.
|
|
48
48
|
*/
|
|
49
49
|
export declare function readAndServe(io: FileIO, rawPath: string, cwd: string, options: ReadAndServeOptions): Promise<ReadAndServeResult>;
|
package/lib/write-hook.js
CHANGED
|
@@ -103,7 +103,16 @@ export function registerWriteHook(rootCtx, agentCtx, io) {
|
|
|
103
103
|
const cwd = execCwd(exec);
|
|
104
104
|
const sessionKey = execSessionKey(exec);
|
|
105
105
|
const signal = exec.signal;
|
|
106
|
-
const { text } = await readAndServe(io, rawPath, cwd, {
|
|
106
|
+
const { text, absolutePath } = await readAndServe(io, rawPath, cwd, {
|
|
107
|
+
sessionKey,
|
|
108
|
+
signal,
|
|
109
|
+
});
|
|
110
|
+
// Record the present observation with the fs policy gate so later
|
|
111
|
+
// built-in write/edit calls see this file as observed at the version
|
|
112
|
+
// these rows describe — this block advertises every row above as an
|
|
113
|
+
// anchor, and the gate only knows a version it was told about
|
|
114
|
+
// (a no-op when no policy listens).
|
|
115
|
+
await io.emitObserved(absolutePath, exec, signal);
|
|
107
116
|
return {
|
|
108
117
|
kind: "accept",
|
|
109
118
|
content: [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-better-edit",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Hash-anchored read/edit/undo_last_edit tools for DeepSeek Harness (dsh). Every line gets a unique 3-char hash (A-Za-z0-9) that stays stable across edits; stale or ambiguous anchors are rejected, never fuzzy-matched. Undo persists across restarts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anchors",
|