dsh-hashline-edit 0.3.8 → 0.3.10
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/README.md
CHANGED
|
@@ -19,17 +19,17 @@ The semantic core is the [pi-better-edit](https://github.com/Rianico/pi-better-e
|
|
|
19
19
|
|
|
20
20
|
The anchor width is baked into the build. Set `PI_BETTER_EDIT_ANCHOR_WIDTH` when you build or pack:
|
|
21
21
|
|
|
22
|
-
-
|
|
23
|
-
-
|
|
22
|
+
- unset builds the 3-char default.
|
|
23
|
+
- `PI_BETTER_EDIT_ANCHOR_WIDTH=4 pnpm run build` (and `pnpm pack`) produces a fully 4-char artifact.
|
|
24
24
|
|
|
25
25
|
| Value | Anchor width | Usable space | Anchor generation |
|
|
26
26
|
| --- | --- | --- | --- |
|
|
27
|
-
| unset
|
|
28
|
-
| `
|
|
27
|
+
| unset (default) | 3 chars | 237,328 | 2 |
|
|
28
|
+
| `4` | 4 chars | 14,766,336 | 1 |
|
|
29
29
|
|
|
30
30
|
The value is inlined into the bundle at build time (`esbuild define`), so the installed plugin never reads an environment variable at runtime — a 3-char build stays 3-char. The persisted store is keyed by the anchor generation, so changing the build width is a hard cache miss (served rows are simply re-read), never a cross-width hit. Width 4 keeps generation 1, so existing stores keep working unchanged.
|
|
31
31
|
|
|
32
|
-
Measured on the DeepSeek-V4.1 tokenizer, a 3-char anchor averages ~2.3 tokens and a 4-char anchor ~3.0 tokens per served line, and neither collapses to one token (see [ADR-0020](docs/adr/0020-configurable-anchor-width-3-4.md)). The default
|
|
32
|
+
Measured on the DeepSeek-V4.1 tokenizer, a 3-char anchor averages ~2.3 tokens and a 4-char anchor ~3.0 tokens per served line, and neither collapses to one token (see [ADR-0020](docs/adr/0020-configurable-anchor-width-3-4.md)). The default is 3; build with `PI_BETTER_EDIT_ANCHOR_WIDTH=4` to ship the 4-char artifact, whose generation-1 store keeps existing rows valid.
|
|
33
33
|
|
|
34
34
|
## Install
|
|
35
35
|
|
package/lib/index.js
CHANGED
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
import { dirname as dirname2, join as join4, parse, resolve, sep } from "node:path";
|
|
49
49
|
|
|
50
50
|
// src/hashline/alphabet.ts
|
|
51
|
-
var HASH_LEN = true ?
|
|
51
|
+
var HASH_LEN = true ? 3 : resolveAnchorWidth(process.env);
|
|
52
52
|
var ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
53
53
|
var ALPHA_SAFE = ALPHA.replace(/-/g, "\\-");
|
|
54
54
|
var ALPHA_RE = new RegExp(`^[${ALPHA_SAFE}]+$`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hashline-edit",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "Hash-anchored read/apply_patch tools for DeepSeek Harness (dsh). Every line gets a unique 3- or 4-char hash (A-Za-z0-9, configurable) that stays stable across edits; apply_patch is the only file-mutation entry point and commits one patch batch per transaction. Undo persists across restarts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anchors",
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
- apply_patch: one call = one transaction; batch related changes and split only when an earlier RESULT decides the next.
|
|
2
|
-
- apply_patch: an identity
|
|
3
|
-
- apply_patch:
|
|
2
|
+
- apply_patch: an identity hunk is `@@<anchor>` or `@@<from>-<to>` followed by `+` lines; an empty body deletes every row of the span. Minimal shape: `*** Begin Patch` / `*** Update File: <path>` / `@@<anchor>` / `+<new line>` / `*** End Patch`.
|
|
3
|
+
- apply_patch: an identity anchor is the bare `{{HASH_LEN}}` characters before `│` in a served row — never the whole row, never a line number; syntax is `@@` plus the anchor with no space between them.
|
|
4
|
+
- apply_patch: served beats text — when this session served the file, an identity hunk is REQUIRED, not preferred; a fragment hunk is limited to a file or region this session never served.
|
|
5
|
+
- apply_patch: anchors in hand mean no re-read — apply the identity hunk to the served rows instead of reading the file again.
|
|
4
6
|
- apply_patch: for a one-line or single-region change to a served file, one identity hunk is the whole call; do not switch to `write` because the file content is already in context.
|
|
5
|
-
- apply_patch: hunks are validated against the pre-call file in order (overlapping ranges reject the batch); a fragment hunk must match exactly once —
|
|
7
|
+
- apply_patch: hunks are validated against the pre-call file in order (overlapping ranges reject the batch); a fragment hunk must match exactly once — `E_UNIQUE_MATCH` writes nothing — while a stale or unknown anchor is rejected; both serve the current rows back.
|
|
6
8
|
- apply_patch: a rejection writes nothing; retry from the served `HASH│content` rows without another `read`.
|
|
7
|
-
- apply_patch: success returns fresh anchors for the changed lines; a patch carries only the changed rows, so a
|
|
9
|
+
- apply_patch: success returns fresh anchors for the changed lines; a patch carries only the changed rows, so a new file or an every-line rewrite stays with `write`.
|
package/prompts/apply-patch.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Change
|
|
1
|
+
Change an existing file with `apply_patch`; it is the default for every change to an existing file, including a one-line change. `write` is only for a new file or a whole-file rewrite in which every line changes. Pass the complete patch as `input`. When this session already served the file (`read`, `grep`, or a `bash` view), every hunk MUST be an identity hunk on a served row: copy the bare anchor before `│` (`@@<anchor>` or `@@<anchor>-<anchor>`), add only the changed `+` lines, and never paste served content back into the hunk. Do not call `read` again to re-fetch anchors you already hold — apply the patch to them directly. A fragment hunk (`@@` or `@@ <context>` matched by file text) is legal only for a file or region this session never served.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
- apply_patch:一次调用 = 一个事务;把相关改动成批处理,只有当先前的结果决定下一步时才拆分。
|
|
2
|
-
- apply_patch
|
|
2
|
+
- apply_patch:身份 hunk 形如 `@@<anchor>` 或 `@@<from>-<to>` 后接 `+` 行;空正文会删除该跨度内所有行。最小形状:`*** Begin Patch` / `*** Update File: <path>` / `@@<anchor>` / `+<新行>` / `*** End Patch`。
|
|
3
|
+
- apply_patch:身份锚点是已服务行中 `│` 之前的 {{HASH_LEN}} 个字符——不是整行,也不是行号;语法是 `@@` 直接加锚点,中间不留空格。
|
|
4
|
+
- apply_patch:已服务优先于文本匹配——本会话服务过该文件时必须用身份 hunk(REQUIRED),不是"优先";片段 hunk 仅限本会话从未服务过的文件或区域。
|
|
5
|
+
- apply_patch:锚点在手上就不要重读——直接把身份 hunk 应用到已服务行,而不是再次 `read` 该文件。
|
|
3
6
|
- apply_patch:对已服务文件的单行或单区域改动,一个身份 hunk 就是整次调用;不要因为文件内容已在上下文里就改用 `write`。
|
|
4
|
-
- apply_patch:各 hunk 按顺序针对调用前的文件校验(重叠范围会拒绝整批);片段 hunk
|
|
7
|
+
- apply_patch:各 hunk 按顺序针对调用前的文件校验(重叠范围会拒绝整批);片段 hunk 必须恰好匹配一次——`E_UNIQUE_MATCH` 时不写入任何内容——陈旧或未知锚点会被拒绝;两者都会回送当前行。
|
|
5
8
|
- apply_patch:拒绝时不写入任何内容;从回送的 `HASH│content` 行重试,无需再次 `read`。
|
|
6
|
-
- apply_patch
|
|
9
|
+
- apply_patch:成功时返回改动行的新锚点;补丁只携带改动的行,新建文件或整文件重写留给 `write`。
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
用 `apply_patch` 修改已有文件;对已有文件的每一处改动都默认用它,包括只改一行。`write` 只用于新建文件,或每一行都改变的重写。把完整补丁作为 `input` 传入。当本会话已服务过该文件(`read`、`grep` 或 `bash` 视图)时,每个 hunk 都必须是基于已服务行的身份 hunk:复制 `│` 之前的裸锚点(`@@<anchor>` 或 `@@<anchor>-<anchor>`),只携带改动的 `+` 行,绝不把已服务内容粘回 hunk。锚点已在手上时不要再调 `read` 重取——直接对它们应用补丁。片段 hunk(`@@` 或按文件文本匹配的 `@@ <context>`)仅用于本会话从未服务过的文件或区域。
|