@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 CHANGED
@@ -24,7 +24,7 @@ This is a fork of the original [pi-hashline-edit](https://github.com/earendil-wo
24
24
 
25
25
  ```bash
26
26
  # From npm
27
- pi install npm:pi-hashline-edit
27
+ pi install npm:@jerryan/pi-hashline-edit
28
28
 
29
29
  # From a local checkout
30
30
  pi install /path/to/pi-hashline-edit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jerryan/pi-hashline-edit",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Hashline read/edit tool override for pi-coding-agent",
5
5
  "repository": {
6
6
  "type": "git",
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 all come from the same pre-edit read.
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] specifying the inclusive range to replace. Use the same anchor twice for single-line: ["42#A4", "42#A4"].',
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
- throw new Error(`Path is a directory: ${rawPath}. Use ls to inspect directories.`);
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") {