@jerryan/pi-hashline-edit 0.7.0 → 0.7.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/README.md +1 -1
- package/package.json +1 -1
- package/prompts/edit.md +1 -1
- package/src/edit.ts +1 -1
- package/src/read.ts +10 -2
package/README.md
CHANGED
package/package.json
CHANGED
package/prompts/edit.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Patch a UTF-8 text file using `LINE#HASH` anchors copied verbatim from `read`.
|
|
2
2
|
|
|
3
|
-
Submit one `edit` call per file. All operations go in a single `edits` array; anchors must
|
|
3
|
+
Submit one `edit` call per file. All operations go in a single `edits` array; anchors must come from the same fresh source — the most recent `read` or `--- Anchors ---` block of a successful `edit` on this file.
|
|
4
4
|
|
|
5
5
|
Each edit entry replaces an inclusive anchor range:
|
|
6
6
|
```json
|
package/src/edit.ts
CHANGED
|
@@ -29,7 +29,7 @@ const editEntrySchema = Type.Object(
|
|
|
29
29
|
{
|
|
30
30
|
range: Type.Tuple([Type.String(), Type.String()], {
|
|
31
31
|
description:
|
|
32
|
-
'LINE#HASH anchor pair [start, end]
|
|
32
|
+
'LINE#HASH anchor pair [start, end] copied from a recent `read` or `--- Anchors ---` block. Use the same anchor twice for single-line: ["42#A4", "42#A4"].',
|
|
33
33
|
}),
|
|
34
34
|
lines: Type.Array(Type.String(), {
|
|
35
35
|
description: "New content lines. Use [] to delete.",
|
package/src/read.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from "@earendil-works/pi-coding-agent";
|
|
10
10
|
import { Type } from "@sinclair/typebox";
|
|
11
11
|
import { readFileSync } from "fs";
|
|
12
|
-
import { access as fsAccess } from "fs/promises";
|
|
12
|
+
import { access as fsAccess, readdir as fsReaddir } from "fs/promises";
|
|
13
13
|
import { constants } from "fs";
|
|
14
14
|
import { normalizeToLF, stripBom } from "./edit-diff";
|
|
15
15
|
import { loadFileKindAndText } from "./file-kind";
|
|
@@ -180,7 +180,15 @@ export function registerReadTool(pi: ExtensionAPI): void {
|
|
|
180
180
|
throwIfAborted(signal);
|
|
181
181
|
const file = await loadFileKindAndText(absolutePath);
|
|
182
182
|
if (file.kind === "directory") {
|
|
183
|
-
|
|
183
|
+
const entries = await fsReaddir(absolutePath);
|
|
184
|
+
const listing = entries
|
|
185
|
+
.slice(0, 50)
|
|
186
|
+
.map((name) => ` ${name}`)
|
|
187
|
+
.join("\n");
|
|
188
|
+
const cap = entries.length > 50 ? `\n ... and ${entries.length - 50} more` : "";
|
|
189
|
+
throw new Error(
|
|
190
|
+
`Path is a directory: ${rawPath}\n${listing}${cap}\n\nUse ls to explore further or read a specific file.`,
|
|
191
|
+
);
|
|
184
192
|
}
|
|
185
193
|
|
|
186
194
|
if (file.kind === "binary") {
|