pi-hashline-edit-pro 2.0.0 → 2.0.1
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 +1 -1
- package/prompts/replace-guidelines.md +2 -3
- package/src/hash-store.ts +23 -7
- package/src/hashline/apply.ts +5 -1
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
- `replace`: hash_bounds must use only anchors from the most recent read of the same file.
|
|
2
1
|
- `replace`: hash_bounds marks the exact lines that are REMOVED, and new_content is their complete replacement applied in order; nothing outside the range changes. Every line inside the range that is not reproduced byte-exact in new_content is deleted from the file — including closing braces and other structural lines.
|
|
3
2
|
- `replace`: minimize the replaced range — anchor only the lines that actually change, so few unchanged lines must be reproduced byte-exact.
|
|
4
3
|
- `replace`: to replace a single line, repeat its hash in both positions of hash_bounds: ["<HASH>", "<HASH>"] — never extend the range to neighboring lines for a one-line edit.
|
|
5
|
-
- `replace`:
|
|
6
|
-
- `replace`:
|
|
4
|
+
- `replace`: when copying a line from read output, remove its HASH│ prefix and keep the leading whitespace exactly as shown.
|
|
5
|
+
- `replace`: to add a blank line, end new_content with an explicit empty line (e.g. ending with \n\n).
|
|
7
6
|
- `replace`: when auto-read shows the post-edit diff, its rows are the fresh anchors for the new file — `+HASH│` and ` HASH│` rows carry current hashes and unchanged lines keep their previous hashes, so you can anchor follow-up edits on the diff without re-reading.
|
package/src/hash-store.ts
CHANGED
|
@@ -418,16 +418,32 @@ export function deleteUndo(store: HashStore, path: string): void {
|
|
|
418
418
|
store.stmts.undoDelete(path);
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
-
|
|
422
|
-
|
|
421
|
+
const STAT_BATCH = 64;
|
|
422
|
+
|
|
423
|
+
async function statMissing(rows: { path: string }[]): Promise<string[]> {
|
|
423
424
|
const missing: string[] = [];
|
|
424
|
-
for (
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
425
|
+
for (let i = 0; i < rows.length; i += STAT_BATCH) {
|
|
426
|
+
const batch = rows.slice(i, i + STAT_BATCH);
|
|
427
|
+
const results = await Promise.all(
|
|
428
|
+
batch.map(async (row) => {
|
|
429
|
+
try {
|
|
430
|
+
await stat(row.path);
|
|
431
|
+
return undefined;
|
|
432
|
+
} catch {
|
|
433
|
+
return row.path;
|
|
434
|
+
}
|
|
435
|
+
}),
|
|
436
|
+
);
|
|
437
|
+
for (const path of results) {
|
|
438
|
+
if (path !== undefined) missing.push(path);
|
|
429
439
|
}
|
|
430
440
|
}
|
|
441
|
+
return missing;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export async function pruneMissing(store: HashStore): Promise<void> {
|
|
445
|
+
const rows = store.stmts.allPaths() as { path: string }[];
|
|
446
|
+
const missing = await statMissing(rows);
|
|
431
447
|
if (missing.length === 0) return;
|
|
432
448
|
withStore(() => {
|
|
433
449
|
for (const path of missing) {
|
package/src/hashline/apply.ts
CHANGED
|
@@ -117,9 +117,13 @@ function resToSpan(
|
|
|
117
117
|
};
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
const prevLine = startLine >= 2 ? fileLines[startLine - 2] : undefined;
|
|
120
121
|
return {
|
|
121
122
|
kind: "replace",
|
|
122
|
-
start:
|
|
123
|
+
start:
|
|
124
|
+
prevLine !== undefined && prevLine.length === 0
|
|
125
|
+
? lineStarts[startLine - 1]!
|
|
126
|
+
: Math.max(0, lineStarts[startLine - 1]! - 1),
|
|
123
127
|
end: content.length,
|
|
124
128
|
replacement: "",
|
|
125
129
|
};
|