pi-hashline-edit-pro 0.16.6 → 0.16.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-hashline-edit-pro",
3
- "version": "0.16.6",
3
+ "version": "0.16.7",
4
4
  "description": "Strict hashline read/replace tool for pi-coding-agent with hash-anchored edits (3-char, 18-bit, perfect hashing)",
5
5
  "main": "index.ts",
6
6
  "repository": {
@@ -2,20 +2,6 @@ Replace lines in a text file using HASH anchors from `read`.
2
2
 
3
3
  Put all operations on one file in a single `replace` call. Stack every region into the `changes` array, even when they are far apart. Anchors within one call must all come from the same pre-edit read; the runtime applies them atomically against that one snapshot.
4
4
 
5
- How to use:
6
-
7
- 1. Call `read` to get HASH anchors:
8
- ```
9
- read({ path: "src/main.ts" })
10
- ```
11
-
12
- 2. Copy the 3-character HASH (before `│`) into `hash_range_inclusive`:
13
- ```json
14
- { "changes": [
15
- { "content_lines": ["const x = 99;"], "hash_range_inclusive": ["MQX", "MQX"] }
16
- ], "path": "src/main.ts" }
17
- ```
18
-
19
5
  Examples:
20
6
 
21
7
  1. Single line replace:
@@ -51,13 +37,6 @@ Examples:
51
37
  ], "path": "src/main.ts" }
52
38
  ```
53
39
 
54
- 5. Seed content into an empty file (replace the single empty-line hash returned by read):
55
- ```json
56
- { "changes": [
57
- { "content_lines": ["first line", "second line"], "hash_range_inclusive": ["aB3", "aB3"] }
58
- ], "path": "src/main.ts" }
59
- ```
60
-
61
40
  ⚠️ Common mistake: do not copy the `HASH│` prefix into `content_lines`.
62
41
 
63
42
  Wrong:
@@ -123,17 +102,4 @@ Right: Only include the new lines that belong in the range:
123
102
  { "content_lines": [" const y = 2;", " return y;"], "hash_range_inclusive": ["X", "Y"] }
124
103
  The `}` on line 4 is outside the range and stays in place.
125
104
 
126
- Error recovery:
127
- - `[E_STALE_ANCHOR]` — the anchored line's content changed since the last read. Call `read` to get fresh anchors, then copy the 3-char HASH of the start and end of the range you are replacing into `hash_range_inclusive` and retry. (Staleness is per-line: editing or appending lines does not invalidate anchors for lines whose content is unchanged, so anchors for untouched regions stay valid across edits.)
128
- - `[E_BAD_REF]` — malformed HASH. Re-read and try again.
129
- - `[E_BAD_OP]` — invalid operation (e.g. start line > end line).
130
- - `[E_BAD_SHAPE]` — malformed request or change item (missing fields, wrong types, unknown fields).
131
- - `[E_LEGACY_SHAPE]` — old `oldText`/`newText` or `old_text`/`new_text` format detected. Use `{content_lines, hash_range_inclusive}` instead.
132
- - `[E_EDIT_CONFLICT]` — two changes overlap on the same line range. Make changes non-overlapping.
133
- - `[E_AMBIGUOUS_ANCHOR]` — hash collision. Call `read` to get fresh anchors.
134
- - `[E_BARE_HASH_PREFIX]` — a `content_lines` entry starts with `HASH│`. Remove the hash prefix; keep only the literal line content that appears after `│` in `read` output. `content_lines` uses file content only, `hash_range_inclusive` uses hash anchors.
135
- - `[E_INVALID_PATCH]` — a `content_lines` entry matches the diff preview's `+HASH│…` addition-row form. Use literal file content. (Plain `+`/`-` lines are not rejected — they are written literally.)
136
- - `[E_WOULD_EMPTY]` — edit would empty a non-empty file.
137
- - `[E_FILE_TOO_LARGE]` — file exceeds the 1,000,000-line edit limit. Use `write` or a non-line-based approach for very large files.
138
-
139
105
  **Undo:** If a replace produced incorrect results, call `undo_last_replace` with the file path to revert the last replace. The tool reports how many lines were removed and restored. After undoing, call `read` to get fresh anchors for a corrected replace.
@@ -1,17 +1,5 @@
1
1
  Replace lines in a text file using HASH anchors from `read`. Only one edit per call (no bulk `changes` array — `hash_range_inclusive` and `content_lines` sit at the top level).
2
2
 
3
- How to use:
4
-
5
- 1. Call `read` to get HASH anchors:
6
- ```
7
- read({ path: "src/main.ts" })
8
- ```
9
-
10
- 2. Copy the 3-character HASH (before `│`) into `hash_range_inclusive`:
11
- ```json
12
- { "content_lines": ["const x = 99;"], "hash_range_inclusive": ["MQX", "MQX"], "path": "src/main.ts" }
13
- ```
14
-
15
3
  Examples:
16
4
 
17
5
  1. Single line replace:
@@ -38,11 +26,6 @@ Examples:
38
26
  { "content_lines": ["old last line", "new line"], "hash_range_inclusive": ["ZPM", "ZPM"], "path": "src/main.ts" }
39
27
  ```
40
28
 
41
- 5. Seed content into an empty file (replace the single empty-line hash returned by read):
42
- ```json
43
- { "content_lines": ["first line", "second line"], "hash_range_inclusive": ["aB3", "aB3"], "path": "src/main.ts" }
44
- ```
45
-
46
29
  ⚠️ Common mistake: do not copy the `HASH│` prefix into `content_lines`.
47
30
 
48
31
  Wrong:
@@ -109,16 +92,4 @@ Right: Only include the new lines that belong in the range:
109
92
  { "content_lines": [" const y = 2;", " return y;"], "hash_range_inclusive": ["X", "Y"] }
110
93
  The `}` on line 4 is outside the range and stays in place.
111
94
 
112
- Error recovery:
113
- - `[E_STALE_ANCHOR]` — the anchored line's content changed since the last read. Call `read` to get fresh anchors, then copy the 3-char HASH of the start and end of the range you are replacing into `hash_range_inclusive` and retry. (Staleness is per-line: editing or appending lines does not invalidate anchors for lines whose content is unchanged, so anchors for untouched regions stay valid across edits.)
114
- - `[E_BAD_REF]` — malformed HASH. Re-read and try again.
115
- - `[E_BAD_OP]` — invalid operation (e.g. start line > end line).
116
- - `[E_BAD_SHAPE]` — malformed request or change item (missing fields, wrong types, unknown fields).
117
- - `[E_LEGACY_SHAPE]` — old `oldText`/`newText` or `old_text`/`new_text` format detected. Use `{content_lines, hash_range_inclusive}` instead.
118
- - `[E_AMBIGUOUS_ANCHOR]` — hash collision. Call `read` to get fresh anchors.
119
- - `[E_BARE_HASH_PREFIX]` — a `content_lines` entry starts with `HASH│`. Remove the hash prefix; keep only the literal line content that appears after `│` in `read` output. `content_lines` uses file content only, `hash_range_inclusive` uses hash anchors.
120
- - `[E_INVALID_PATCH]` — a `content_lines` entry matches the diff preview's `+HASH│…` addition-row form. Use literal file content. (Plain `+`/`-` lines are not rejected — they are written literally.)
121
- - `[E_WOULD_EMPTY]` — edit would empty a non-empty file.
122
- - `[E_FILE_TOO_LARGE]` — file exceeds the 1,000,000-line edit limit. Use `write` or a non-line-based approach for very large files.
123
-
124
95
  **Undo:** If a replace produced incorrect results, call `undo_last_replace` with the file path to revert the last replace. The tool reports how many lines were removed and restored. After undoing, call `read` to get fresh anchors for a corrected replace.
@@ -1,7 +0,0 @@
1
- - Use `replace` with HASH anchors for all file changes; batch every change to one file into a single `replace` call.
2
- - After a successful `replace`, the response shows the change summary. {{AUTO_READ_GUIDANCE}}
3
- - On `[E_STALE_ANCHOR]`, call `read` to get fresh anchors, copy the 3-character HASH of the start and end of the range you are replacing into `hash_range_inclusive`, and retry.
4
- - `hash_range_inclusive` replaces the ENTIRE range inclusively. Every line from the first anchor through the second anchor is deleted. Only put the replacement lines in `content_lines` — do not include lines that already exist outside the range.
5
- - **Preserve leading whitespace (indentation) exactly.** The content after `│` in read output includes all leading spaces and tabs — copy them into `content_lines` unchanged.
6
- - **`content_lines` must be a native JSON array of strings**, not a JSON string. Do NOT serialize it: `"content_lines": "[\"line1\", \"line2\"]"` is WRONG. Use `"content_lines": ["line1", "line2"]` instead.
7
- - Two modes are available: bulk (default, uses `changes` array) and flat (top-level `hash_range_inclusive`/`content_lines`). Toggle with `/toggle-replace-mode`.
@@ -1 +0,0 @@
1
- Replace lines in a text file via HASH anchors from read, batching all changes to a file in one call. Supports bulk mode (changes array) and flat mode (top-level fields), toggled via /toggle-replace-mode.
@@ -1,188 +0,0 @@
1
- Replace lines in a text file using HASH anchors from `read`.
2
-
3
- Two modes are available, toggled via `/toggle-replace-mode` (persists across sessions):
4
-
5
- **Bulk mode (default):** `hash_range_inclusive` and `content_lines` go inside a `changes` array, supporting multiple edits in one call.
6
-
7
- **Flat mode:** `hash_range_inclusive` and `content_lines` sit at the top level. Only one edit per call.
8
-
9
- ---
10
-
11
- Put all operations on one file in a single `replace` call. Stack every region into the `changes` array, even when they are far apart. Anchors within one call must all come from the same pre-edit read; the runtime applies them atomically against that one snapshot.
12
-
13
- How to use:
14
-
15
- 1. Call `read` to get HASH anchors:
16
- ```
17
- read({ path: "src/main.ts" })
18
- ```
19
-
20
- 2. Copy the 3-character HASH (before `│`) into `hash_range_inclusive`:
21
-
22
- **Bulk mode:**
23
- ```json
24
- { "changes": [
25
- { "content_lines": ["const x = 99;"], "hash_range_inclusive": ["MQX", "MQX"] }
26
- ], "path": "src/main.ts" }
27
- ```
28
-
29
- **Flat mode:**
30
- ```json
31
- { "content_lines": ["const x = 99;"], "hash_range_inclusive": ["MQX", "MQX"], "path": "src/main.ts" }
32
- ```
33
-
34
- Examples:
35
-
36
- 1. Single line replace:
37
-
38
- Bulk:
39
- ```json
40
- { "changes": [
41
- { "content_lines": ["const x = 1;"], "hash_range_inclusive": ["MQX", "MQX"] }
42
- ], "path": "src/main.ts" }
43
- ```
44
-
45
- Flat:
46
- ```json
47
- { "content_lines": ["const x = 1;"], "hash_range_inclusive": ["MQX", "MQX"], "path": "src/main.ts" }
48
- ```
49
-
50
- 2. Range replace (3 lines → 3 new lines):
51
-
52
- Bulk:
53
- ```json
54
- { "changes": [
55
- { "content_lines": [
56
- "function greet(name) {",
57
- " return `Hello, ${name}`;",
58
- "}"
59
- ], "hash_range_inclusive": ["ZPM", "VRW"] }
60
- ], "path": "src/main.ts" }
61
- ```
62
-
63
- Flat:
64
- ```json
65
- { "content_lines": [
66
- "function greet(name) {",
67
- " return `Hello, ${name}`;",
68
- "}"
69
- ], "hash_range_inclusive": ["ZPM", "VRW"], "path": "src/main.ts" }
70
- ```
71
-
72
- 3. Multiple regions in one call (bulk mode only — flat mode supports one edit per call):
73
- ```json
74
- { "changes": [
75
- { "content_lines": [], "hash_range_inclusive": ["aB3", "xY7"] },
76
- { "content_lines": [], "hash_range_inclusive": ["MQX", "ZPM"] }
77
- ], "path": "src/server.ts" }
78
- ```
79
-
80
- 4. Append after the last line (include the old last line so the new line is added after it):
81
-
82
- Bulk:
83
- ```json
84
- { "changes": [
85
- { "content_lines": ["old last line", "new line"], "hash_range_inclusive": ["ZPM", "ZPM"] }
86
- ], "path": "src/main.ts" }
87
- ```
88
-
89
- Flat:
90
- ```json
91
- { "content_lines": ["old last line", "new line"], "hash_range_inclusive": ["ZPM", "ZPM"], "path": "src/main.ts" }
92
- ```
93
-
94
- 5. Seed content into an empty file (replace the single empty-line hash returned by read):
95
-
96
- Bulk:
97
- ```json
98
- { "changes": [
99
- { "content_lines": ["first line", "second line"], "hash_range_inclusive": ["aB3", "aB3"] }
100
- ], "path": "src/main.ts" }
101
- ```
102
-
103
- Flat:
104
- ```json
105
- { "content_lines": ["first line", "second line"], "hash_range_inclusive": ["aB3", "aB3"], "path": "src/main.ts" }
106
- ```
107
-
108
- ⚠️ Common mistake: do not copy the `HASH│` prefix into `content_lines`.
109
-
110
- Wrong:
111
- ```json
112
- { "content_lines": ["F4T│import { x } from \"./x\";"], "hash_range_inclusive": ["F4T", "F4T"] }
113
-
114
- Right:
115
- ```json
116
- { "content_lines": ["import { x } from \"./x\";"], "hash_range_inclusive": ["F4T", "F4T"] }
117
-
118
- `hash_range_inclusive` uses the hash anchor. `content_lines` uses literal file content only — the same text that appears after the `│` in `read` output.
119
-
120
- ⚠️ Common mistake: `hash_range_inclusive` is only the 3-character HASH, not the full `HASH│content` line.
121
-
122
- Wrong:
123
- ```json
124
- { "content_lines": [...], "hash_range_inclusive": ["F4T│import { x } from \"./x\";", "F4T│import { x } from \"./x\";"] }
125
-
126
- Right:
127
- ```json
128
- { "content_lines": [...], "hash_range_inclusive": ["F4T", "F4T"] }
129
-
130
- ⚠️ Common mistake: do not serialize `content_lines` as a JSON string.
131
-
132
- Wrong:
133
- ```json
134
- { "content_lines": "[\"line1\", \"line2\"]", "hash_range_inclusive": ["F4T", "F4T"] }
135
-
136
- Right:
137
- ```json
138
- { "content_lines": ["line1", "line2"], "hash_range_inclusive": ["F4T", "F4T"] }
139
-
140
- `content_lines` must be a native JSON array of strings, not a string that looks like an array. Pass it as a proper JSON array value.
141
-
142
- Rules:
143
- - `hash_range_inclusive` is a pair `[start, end]`. A single-line replace is `hash_range_inclusive: ["X", "X"]`.
144
- - To delete a range, use `content_lines: []`.
145
- - `hash_range_inclusive` elements are HASH anchors only (e.g. `aB3`). Do not include `│` or line content.
146
- - `content_lines` is literal file content — each string becomes exactly one line in the file. No `HASH│` prefix. A line that happens to start with `+` or `-` is written as-is; the only rejected form is the diff preview's `+HASH│…` row (see `[E_INVALID_PATCH]`).
147
- - **Preserve leading whitespace (indentation) exactly.** The content after `│` in read output includes all leading spaces and tabs — copy them into `content_lines` unchanged. Dropping indentation will produce broken code.
148
- - Don't add `""` for spacing unless you actually want a new blank line.
149
- - Copy anchors from the most recent `read` of the file. Do not guess or construct them.
150
- - All changes in one call must be non-conflicting. The runtime rejects with `[E_EDIT_CONFLICT]` if two ranges overlap.
151
- - If `content_lines` matches current content, the replace is classified as `noop` (file unchanged).
152
- - The `hash_range_inclusive` is inclusive — the entire span from the first anchor through the second anchor is deleted and replaced with `content_lines`. The old lines in that span are gone. If your replacement content includes lines that already exist in the file (e.g. closing brackets), make sure those lines are within your range, otherwise they will appear twice.
153
- - `changes` (in bulk mode), `hash_range_inclusive`, and `content_lines` must be native JSON values, not JSON strings. Do not serialize them — pass them as proper arrays and strings.
154
- On success, the response text shows the line change summary (e.g. "Added 3 line(s), removed 1 line(s).") plus any warnings if present. {{AUTO_READ_GUIDANCE}}
155
-
156
- ⚠️ Common mistake: `hash_range_inclusive` replaces the ENTIRE range. Every line from the first anchor through the second anchor is deleted and replaced with `content_lines`. Do not include "context" or "surrounding" lines in `content_lines` — they are outside the range and will be preserved automatically.
157
-
158
- Wrong: To replace lines 2-3 in this function:
159
- ```
160
- function greet() {
161
- const x = 1;
162
- return x;
163
- }
164
- ```
165
- A model might write:
166
- ```json
167
- { "content_lines": [" const y = 2;", " return y;", "}"], "hash_range_inclusive": ["X", "Y"] }
168
- This produces `function greet() {\n const y = 2;\n return y;\n}\n}` — the `}` appears twice because it was already on line 4 (outside the range) AND in `content_lines`.
169
-
170
- Right: Only include the new lines that belong in the range:
171
- ```json
172
- { "content_lines": [" const y = 2;", " return y;"], "hash_range_inclusive": ["X", "Y"] }
173
- The `}` on line 4 is outside the range and stays in place.
174
-
175
- Error recovery:
176
- - `[E_STALE_ANCHOR]` — the anchored line's content changed since the last read. Call `read` to get fresh anchors, then copy the 3-char HASH of the start and end of the range you are replacing into `hash_range_inclusive` and retry. (Staleness is per-line: editing or appending lines does not invalidate anchors for lines whose content is unchanged, so anchors for untouched regions stay valid across edits.)
177
- - `[E_BAD_REF]` — malformed HASH. Re-read and try again.
178
- - `[E_BAD_OP]` — invalid operation (e.g. start line > end line).
179
- - `[E_BAD_SHAPE]` — malformed request or change item (missing fields, wrong types, unknown fields).
180
- - `[E_LEGACY_SHAPE]` — old `oldText`/`newText` or `old_text`/`new_text` format detected. Use `{content_lines, hash_range_inclusive}` instead.
181
- - `[E_EDIT_CONFLICT]` — two changes overlap on the same line range. Make changes non-overlapping.
182
- - `[E_AMBIGUOUS_ANCHOR]` — hash collision. Call `read` to get fresh anchors.
183
- - `[E_BARE_HASH_PREFIX]` — a `content_lines` entry starts with `HASH│`. Remove the hash prefix; keep only the literal line content that appears after `│` in `read` output. `content_lines` uses file content only, `hash_range_inclusive` uses hash anchors.
184
- - `[E_INVALID_PATCH]` — a `content_lines` entry matches the diff preview's `+HASH│…` addition-row form. Use literal file content. (Plain `+`/`-` lines are not rejected — they are written literally.)
185
- - `[E_WOULD_EMPTY]` — edit would empty a non-empty file.
186
- - `[E_FILE_TOO_LARGE]` — file exceeds the 1,000,000-line edit limit. Use `write` or a non-line-based approach for very large files.
187
-
188
- **Undo:** If a replace produced incorrect results, call `undo_last_replace` with the file path to revert the last replace. The tool reports how many lines were removed and restored. After undoing, call `read` to get fresh anchors for a corrected replace.