pi-hashline-edit-pro 4.3.2 → 4.3.3

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.
@@ -13,6 +13,7 @@ import { genDiff, genPatch, spansFromHashes } from "./replace-diff";
13
13
  import { getDiffContextLines } from "./config";
14
14
  import { cntDiff, errCode, makePrepareArguments, splitLines } from "./utils";
15
15
  import { loadP, loadGuide } from "./prompts";
16
+ import { withUndoPrompts, DEFAULT_EDIT_FLAGS, type EditToolFlags } from "./edit-common";
16
17
  import { buildMetrics } from "./replace-response";
17
18
  import { renderEditResult, fmtCall } from "./replace-render";
18
19
  import { Text } from "@earendil-works/pi-tui";
@@ -102,13 +103,18 @@ function fallbackFileMode(): number {
102
103
  return 0o666 & ~process.umask();
103
104
  }
104
105
 
105
- export function regUndo(pi: ExtensionAPI): void {
106
+ export function regUndo(pi: ExtensionAPI, flags: EditToolFlags = DEFAULT_EDIT_FLAGS): void {
107
+ const prompted = withUndoPrompts({
108
+ description: loadP("../prompts/undo-last-change.md"),
109
+ snippet: loadP("../prompts/undo-last-change-snippet.md"),
110
+ guidelines: loadGuide("../prompts/undo-last-change-guidelines.md"),
111
+ }, flags);
106
112
  pi.registerTool({
107
113
  name: "undo_last_change",
108
114
  label: "Undo Last Change",
109
- description: loadP("../prompts/undo-last-change.md"),
110
- promptSnippet: loadP("../prompts/undo-last-change-snippet.md"),
111
- promptGuidelines: loadGuide("../prompts/undo-last-change-guidelines.md"),
115
+ description: prompted.description,
116
+ promptSnippet: prompted.snippet,
117
+ promptGuidelines: prompted.guidelines,
112
118
  prepareArguments: makePrepareArguments(),
113
119
  parameters: Type.Object({
114
120
  path: Type.String({
package/src/replace.ts CHANGED
@@ -3,7 +3,6 @@ import type {
3
3
  ToolDefinition,
4
4
  } from "@earendil-works/pi-coding-agent";
5
5
  import { constants } from "node:fs";
6
- import { relative } from "node:path";
7
6
  import {
8
7
  genDiff,
9
8
  type DiffSpan,
@@ -31,7 +30,7 @@ import {
31
30
  import { loadHashStore, type HashStore } from "./hash-store";
32
31
  import { adoptAnchors, servedForPath, withAnchorSession } from "./anchor-registry";
33
32
  import { resolveTarget } from "./fs-write";
34
- import { toCwd } from "./paths";
33
+ import { toCwd, toDisplayPath } from "./paths";
35
34
  import { queuedEdit, editToolBase, editRenderCallWrapper, editRenderResultWrapper, resolveEditTargetWithRequirement, throwIfStrictInput, getBoundaryDedupMode, withReplacePrompts, DEFAULT_EDIT_FLAGS, type EditToolFlags } from "./edit-common";
36
35
  import { commitEdit, dedupRowsFromFixes } from "./commit";
37
36
  import { batchMemberFor, executeBatchMember, noteBatchFailure } from "./batch";
@@ -148,7 +147,7 @@ export async function execPipeline(
148
147
  const { normalized: originalNormalized, bom, originalEnding, fileHashes: originalHashes, hadUtf8DecodeErrors, absolutePath, identity } = await readNormFile(
149
148
  targetPath, cwd, { signal: options?.signal, accessMode: options?.accessMode, maxLines: MAX_HASH_LINES, store: hashStore, noPersist: options?.noPersist, allocation: options?.noPersist ? "shadow" : "real", preloadedNorm: options?.preloadedNorm },
150
149
  );
151
- const displayPath = relative(cwd, absolutePath).replace(/\\/g, "/") || targetPath;
150
+ const displayPath = toDisplayPath(cwd, absolutePath, targetPath);
152
151
 
153
152
  const dedupMode = await getBoundaryDedupMode();
154
153
  const effectiveSkipBoundaryDedup = options?.skipBoundaryDedup === true || dedupMode === "off";
package/src/utils.ts CHANGED
@@ -137,7 +137,7 @@ export function isHashRow(line: string): boolean {
137
137
  return /^[A-Za-z0-9]{4}│/.test(line);
138
138
  }
139
139
 
140
- function gutterWidth(max: number, fallback: number): number {
140
+ export function gutterWidth(max: number, fallback: number): number {
141
141
  return String(max || fallback).length;
142
142
  }
143
143