pi-readseek 0.4.5 → 0.4.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-readseek",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "description": "Pi extension for readseek-backed hash-anchored read/edit/grep, structural code maps, structural search, and file exploration",
5
5
  "type": "module",
6
6
  "exports": {
@@ -39,7 +39,7 @@
39
39
  "node": ">=20.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@jarkkojs/readseek": "^0.4.8",
42
+ "@jarkkojs/readseek": "^0.4.10",
43
43
  "diff": "^8.0.3",
44
44
  "ignore": "^7.0.5",
45
45
  "picomatch": "^4.0.4",
package/src/edit-diff.ts CHANGED
@@ -315,8 +315,8 @@ export function generateCompactOrFullDiff(
315
315
  const lineNum = changedIndex + 1;
316
316
  const oldLine = oldLines[changedIndex] ?? "";
317
317
  const newLine = newLines[changedIndex] ?? "";
318
- const oldHash = computeLineHash(lineNum, oldLine);
319
- const newHash = computeLineHash(lineNum, newLine);
318
+ const oldHash = computeLineHash(oldLine);
319
+ const newHash = computeLineHash(newLine);
320
320
  return {
321
321
  diff: `${lineNum}:${oldHash}|${oldLine} → ${lineNum}:${newHash}|${newLine}`,
322
322
  firstChangedLine: lineNum,
@@ -347,7 +347,7 @@ export function generateCompactOrFullDiff(
347
347
  if (!failed && deletedIndex !== -1 && j === newLines.length) {
348
348
  const lineNum = deletedIndex + 1;
349
349
  const oldLine = oldLines[deletedIndex] ?? "";
350
- const oldHash = computeLineHash(lineNum, oldLine);
350
+ const oldHash = computeLineHash(oldLine);
351
351
  return {
352
352
  diff: `${lineNum}:${oldHash}|${oldLine} → [deleted]`,
353
353
  firstChangedLine: lineNum,
package/src/edit.ts CHANGED
@@ -1,9 +1,12 @@
1
+ import { readFile as fsReadFile, writeFile as fsWriteFile } from "fs/promises";
2
+
3
+ import { createPatch } from "diff";
1
4
  import { withFileMutationQueue, type ExtensionAPI, type EditToolDetails, type ToolRenderResultOptions } from "@earendil-works/pi-coding-agent";
2
5
  import { Type } from "@sinclair/typebox";
3
6
  import type { Static } from "@sinclair/typebox";
7
+ import { Text } from "@earendil-works/pi-tui";
8
+
4
9
  import { defineToolPromptMetadata } from "./tool-prompt-metadata.js";
5
- import { readFile as fsReadFile, writeFile as fsWriteFile } from "fs/promises";
6
- import { createPatch } from "diff";
7
10
  import { detectLineEnding, generateCompactOrFullDiff, normalizeToLF, replaceText, restoreLineEndings, stripBom } from "./edit-diff.js";
8
11
  import { HashlineMismatchError, applyHashlineEdits, computeLineHash, ensureHashInit, parseLineRef, type HashlineEditItem, escapeControlCharsForDisplay } from "./hashline.js";
9
12
  import { resolveToCwd } from "./path-utils.js";
@@ -13,7 +16,6 @@ import { buildEditOutput } from "./edit-output.js";
13
16
  import { classifyEdit, isDifftAvailable, runDifftastic } from "./edit-classify.js";
14
17
  import type { SemanticSummary } from "./readseek-value.js";
15
18
  import { buildReadseekError } from "./readseek-value.js";
16
- import { Text } from "@earendil-works/pi-tui";
17
19
  import { countEditTypes, formatEditCallText, formatEditResultText } from "./edit-render-helpers.js";
18
20
  import { validateSyntaxRegression } from "./edit-syntax-validate.js";
19
21
  import { resolveSyntaxValidateMode, type SyntaxValidateOptions } from "./syntax-validate-mode.js";
@@ -252,7 +254,7 @@ export async function executeEdit(opts: ExecuteEditOptions): Promise<any> {
252
254
  const parsed = parseLineRef(ref);
253
255
  if (parsed.line >= 1 && parsed.line <= origLines.length) {
254
256
  const lineContent = origLines[parsed.line - 1];
255
- const hash = computeLineHash(parsed.line, lineContent);
257
+ const hash = computeLineHash(lineContent);
256
258
  anchorSnapshots.set(ref, `${parsed.line}:${hash}|${escapeControlCharsForDisplay(lineContent)}`);
257
259
  }
258
260
  } catch {
package/src/grep.ts CHANGED
@@ -1,8 +1,11 @@
1
+ import { readFile as fsReadFile, stat as fsStat } from "fs/promises";
2
+ import path from "path";
3
+
1
4
  import type { ExtensionAPI, ToolRenderResultOptions } from "@earendil-works/pi-coding-agent";
2
5
  import { createGrepTool } from "@earendil-works/pi-coding-agent";
3
6
  import { Type } from "@sinclair/typebox";
4
- import { readFile as fsReadFile, stat as fsStat } from "fs/promises";
5
- import path from "path";
7
+ import { Text } from "@earendil-works/pi-tui";
8
+
6
9
  import { defineToolPromptMetadata } from "./tool-prompt-metadata.js";
7
10
  import { normalizeToLF, stripBom, hasBareCarriageReturn } from "./edit-diff.js";
8
11
  import { looksLikeBinary } from "./binary-detect.js";
@@ -14,7 +17,6 @@ import { getOrGenerateMap } from "./map-cache.js";
14
17
  import { scopeGrepGroupsToSymbols } from "./grep-symbol-scope.js";
15
18
  import { resolveToCwd } from "./path-utils.js";
16
19
  import { throwIfAborted } from "./runtime.js";
17
- import { Text } from "@earendil-works/pi-tui";
18
20
  import { formatGrepCallText, formatGrepResultText } from "./grep-render-helpers.js";
19
21
  import { coerceObviousBase10Int } from "./coerce-obvious-int.js";
20
22
  import { clampLineToWidth, clampLinesToWidth, linkToolPath, renderErrorResult, renderPendingResult, renderToolLabel, resolveRenderResultContext, summaryLine } from "./tui-render-utils.js";
package/src/hashline.ts CHANGED
@@ -100,7 +100,7 @@ function xxh32(input: string): number {
100
100
  return state.h32Fn(input, 0) >>> 0;
101
101
  }
102
102
 
103
- export function computeLineHash(_idx: number, line: string): string {
103
+ export function computeLineHash(line: string): string {
104
104
  if (line.endsWith("\r")) line = line.slice(0, -1);
105
105
  line = line.replace(/\s+/g, "");
106
106
  return DICT[xxh32(line) % HASH_MOD];
@@ -115,7 +115,7 @@ export function escapeControlCharsForDisplay(text: string): string {
115
115
  }
116
116
 
117
117
  export function formatHashlineDisplay(lineNumber: number, content: string): string {
118
- return `${lineNumber}:${computeLineHash(lineNumber, content)}|${escapeControlCharsForDisplay(content)}`;
118
+ return `${lineNumber}:${computeLineHash(content)}|${escapeControlCharsForDisplay(content)}`;
119
119
  }
120
120
 
121
121
  export function parseLineRef(ref: string): { line: number; hash: string; content?: string } {
@@ -167,7 +167,7 @@ function findSimilarLines(
167
167
 
168
168
  candidates.sort((a, b) => b.score - a.score);
169
169
  return candidates.slice(0, maxSuggestions).map((c) => {
170
- const hash = computeLineHash(c.line, c.content);
170
+ const hash = computeLineHash(c.content);
171
171
  return ` ${c.line}:${hash}|${escapeControlCharsForDisplay(c.content)}`;
172
172
  });
173
173
  }
@@ -180,7 +180,7 @@ function formatMismatchError(
180
180
  for (const m of mismatches) mismatchSet.set(m.line, m);
181
181
  const updatedAnchors: ReadseekLine[] = mismatches.map((m) => {
182
182
  const raw = fileLines[m.line - 1] ?? "";
183
- const hash = computeLineHash(m.line, raw);
183
+ const hash = computeLineHash(raw);
184
184
  return {
185
185
  line: m.line,
186
186
  hash,
@@ -206,7 +206,7 @@ function formatMismatchError(
206
206
  if (prev !== -1 && num > prev + 1) out.push(" ...");
207
207
  prev = num;
208
208
  const content = fileLines[num - 1];
209
- const hash = computeLineHash(num, content);
209
+ const hash = computeLineHash(content);
210
210
  const prefix = `${num}:${hash}`;
211
211
  out.push(
212
212
  mismatchSet.has(num)
@@ -427,7 +427,7 @@ export function applyHashlineEdits(
427
427
  for (let i = 0; i < fileLines.length; i++) {
428
428
  throwIfAborted(signal);
429
429
  const lineNumber = i + 1;
430
- const h = computeLineHash(lineNumber, fileLines[i]);
430
+ const h = computeLineHash(fileLines[i]);
431
431
  lineHashes.push(h);
432
432
  const lines = hashToLines.get(h);
433
433
  if (lines) lines.push(lineNumber);
@@ -487,7 +487,7 @@ export function applyHashlineEdits(
487
487
  }
488
488
  if (fuzzyHits.length === 1) {
489
489
  const hit = fuzzyHits[0];
490
- const newHash = computeLineHash(hit.line, fileLines[hit.line - 1]);
490
+ const newHash = computeLineHash(fileLines[hit.line - 1]);
491
491
  ref.line = hit.line;
492
492
  ref.hash = newHash;
493
493
  relocationNotes.add(
package/src/read.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { readFile as fsReadFile } from "fs/promises";
2
+
1
3
  import type { ExtensionAPI, ToolRenderResultOptions, AgentToolResult } from "@earendil-works/pi-coding-agent";
2
4
  import {
3
5
  createReadTool,
@@ -6,8 +8,9 @@ import {
6
8
  DEFAULT_MAX_LINES,
7
9
  } from "@earendil-works/pi-coding-agent";
8
10
  import { Type } from "@sinclair/typebox";
11
+ import { Text } from "@earendil-works/pi-tui";
12
+
9
13
  import { defineToolPromptMetadata } from "./tool-prompt-metadata.js";
10
- import { readFile as fsReadFile } from "fs/promises";
11
14
  import { normalizeToLF, stripBom, hasBareCarriageReturn } from "./edit-diff.js";
12
15
  import { ensureHashInit, escapeControlCharsForDisplay } from "./hashline.js";
13
16
  import { buildReadseekWarning, buildToolErrorResult, renderReadseekLines, type ReadseekLine, type ReadseekWarning } from "./readseek-value.js";
@@ -24,7 +27,6 @@ import { buildReadOutput } from "./read-output.js";
24
27
  import { buildLocalBundle } from "./read-local-bundle.js";
25
28
  import { coerceObviousBase10Int } from "./coerce-obvious-int.js";
26
29
  import { readseekRead } from "./readseek-client.js";
27
- import { Text } from "@earendil-works/pi-tui";
28
30
  import { formatReadCallText, formatReadResultText } from "./read-render-helpers.js";
29
31
  import { clampLineToWidth, clampLinesToWidth, linkToolPath, renderPendingResult, renderToolLabel, resolveRenderResultContext, summaryLine, wrapReadHashlinesForWidth } from "./tui-render-utils.js";
30
32
  import type { FileAnchoredCallback } from "./tool-types.js";
@@ -71,7 +71,7 @@ export function buildReadseekLineWithHash(line: number, hash: string, raw: strin
71
71
  }
72
72
 
73
73
  export function buildReadseekLine(line: number, raw: string): ReadseekLine {
74
- return buildReadseekLineWithHash(line, computeLineHash(line, raw), raw);
74
+ return buildReadseekLineWithHash(line, computeLineHash(raw), raw);
75
75
  }
76
76
 
77
77
  export function buildReadseekLines(startLine: number, rawLines: string[]): ReadseekLine[] {
package/src/sg.ts CHANGED
@@ -1,8 +1,10 @@
1
+ import path from "node:path";
2
+ import { stat as fsStat } from "node:fs/promises";
3
+
1
4
  import type { ExtensionAPI, ToolRenderResultOptions } from "@earendil-works/pi-coding-agent";
2
5
  import { Text } from "@earendil-works/pi-tui";
3
6
  import { Type } from "@sinclair/typebox";
4
- import path from "node:path";
5
- import { stat as fsStat } from "node:fs/promises";
7
+
6
8
  import { defineToolPromptMetadata } from "./tool-prompt-metadata.js";
7
9
  import { buildReadseekLineWithHash, buildToolErrorResult, type ReadseekLine } from "./readseek-value.js";
8
10
  import { resolveToCwd } from "./path-utils.js";
@@ -1,6 +1,7 @@
1
- import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize } from "@earendil-works/pi-coding-agent";
2
1
  import { readFileSync } from "node:fs";
3
2
 
3
+ import { DEFAULT_MAX_BYTES, DEFAULT_MAX_LINES, formatSize } from "@earendil-works/pi-coding-agent";
4
+
4
5
  const COMPACT_DESCRIPTIONS: Record<string, string> = {
5
6
  "read.md": "Read text files/images by path; text has LINE:HASH anchors, images return attachments.",
6
7
  "edit.md": "Edit existing text files using fresh LINE:HASH anchors from read, grep, search, or write.",
@@ -1,6 +1,8 @@
1
- import { getCapabilities, hyperlink, Text, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
2
1
  import { relative } from "node:path";
3
2
  import { pathToFileURL } from "node:url";
3
+
4
+ import { getCapabilities, hyperlink, Text, truncateToWidth, visibleWidth, wrapTextWithAnsi } from "@earendil-works/pi-tui";
5
+
4
6
  import { resolveToCwd } from "./path-utils.js";
5
7
 
6
8
  export const SUMMARY_PREFIX = "↳";
package/src/write.ts CHANGED
@@ -1,8 +1,10 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname, relative } from "node:path";
3
+
1
4
  import { withFileMutationQueue, type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
5
  import { Text } from "@earendil-works/pi-tui";
3
6
  import { Type } from "@sinclair/typebox";
4
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
- import { dirname, relative } from "node:path";
7
+
6
8
  import { resolveToCwd } from "./path-utils.js";
7
9
  import { ensureHashInit, formatHashlineDisplay } from "./hashline.js";
8
10
  import { buildReadseekError, buildReadseekLine, buildReadseekWarning, type ReadseekLine, type ReadseekWarning } from "./readseek-value.js";