@jerryan/pi-hashline-edit 0.7.0 → 0.7.2
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 +127 -114
- package/package.json +53 -53
- package/prompts/edit.md +3 -3
- package/src/edit-diff.ts +38 -77
- package/src/edit-response.ts +5 -67
- package/src/edit.ts +519 -642
- package/src/hashline.ts +1068 -1058
- package/src/read.ts +10 -2
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") {
|