pi-readseek 0.7.8 → 0.8.0

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.
Files changed (2) hide show
  1. package/dist/index.js +18 -14
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1436,8 +1436,9 @@ function readSeekBinaryAvailability() {
1436
1436
  }
1437
1437
  }
1438
1438
  function classifyReadSeekFailure(err) {
1439
- const message = String(err?.message || err);
1440
- const missing = err?.code === "ENOENT" || /Cannot find package|Cannot find module|no such file/i.test(message);
1439
+ const failure = err;
1440
+ const message = String(failure?.message ?? err);
1441
+ const missing = failure?.code === "ENOENT" || /Cannot find package|Cannot find module|no such file/i.test(message);
1441
1442
  if (missing) {
1442
1443
  return { code: "readseek-not-installed", message, hint: "Run npm install to install @jarkkojs/readseek." };
1443
1444
  }
@@ -1962,7 +1963,7 @@ async function readSeekDetect(filePath, options = {}) {
1962
1963
  }
1963
1964
  async function readSeekImage(filePath, modes, options = {}) {
1964
1965
  const requestedModes = modes.length > 1 ? ["all"] : modes;
1965
- const results = await Promise.allSettled(requestedModes.map(async (mode) => parseDetectOutput(await runReadSeekVision(["read", "--image", mode, filePath], { signal: options.signal }))));
1966
+ const results = await Promise.allSettled(requestedModes.map(async (mode) => parseDetectOutput(await runReadSeekVision(["read", "--vision-mode", mode, filePath], { signal: options.signal }))));
1966
1967
  let merged;
1967
1968
  for (const result of results) {
1968
1969
  if (result.status !== "fulfilled" || result.value.kind !== "image")
@@ -1983,7 +1984,7 @@ async function readSeekImage(filePath, modes, options = {}) {
1983
1984
  throw new Error(`readseek returned no image analysis for ${filePath}`);
1984
1985
  }
1985
1986
  async function readSeekPreparedImage(filePath, options = {}) {
1986
- const output = parseDetectOutput(await runReadSeek(["read", "--image", "none", filePath], { signal: options.signal }));
1987
+ const output = parseDetectOutput(await runReadSeek(["read", "--vision-mode", "none", filePath], { signal: options.signal }));
1987
1988
  if (output.kind !== "image" || output.encoding !== "base64" || output.data === undefined || output.mime === undefined) {
1988
1989
  throw new Error(`readseek returned no prepared image for ${filePath}`);
1989
1990
  }
@@ -2025,7 +2026,7 @@ function parsePdfOutput(value) {
2025
2026
  }
2026
2027
  async function readSeekPdf(filePath, mode, options = {}) {
2027
2028
  const run = mode === "none" ? runReadSeek : runReadSeekVision;
2028
- const args = ["read", "--image", mode, filePath];
2029
+ const args = ["read", "--vision-mode", mode, filePath];
2029
2030
  if (options.page !== undefined)
2030
2031
  args.push("--page", String(options.page));
2031
2032
  return parsePdfOutput(await run(args, { signal: options.signal }));
@@ -6633,7 +6634,7 @@ ${textContent}`;
6633
6634
  }
6634
6635
 
6635
6636
  // src/write.ts
6636
- import { access, mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
6637
+ import { mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
6637
6638
  import { dirname as dirname2, relative as relative3 } from "node:path";
6638
6639
  import { withFileMutationQueue as withFileMutationQueue2, truncateHead as truncateHead4 } from "@earendil-works/pi-coding-agent";
6639
6640
  import { Text as Text8 } from "@earendil-works/pi-tui";
@@ -6673,16 +6674,20 @@ function pendingWritePreviewParts(summary, preview, expanded, theme) {
6673
6674
  return { lines: [summary, headerLine], diffData: expanded ? diffData : undefined };
6674
6675
  }
6675
6676
  function isToolErrorResult(result) {
6676
- return "isError" in result;
6677
+ return "isError" in result && result.isError === true;
6677
6678
  }
6678
6679
  async function readPreviousTextForDiff(filePath) {
6679
6680
  try {
6680
6681
  const previous = await readFile2(filePath);
6681
- if (looksLikeBinary(previous))
6682
- return "";
6683
- return previous.toString("utf-8");
6684
- } catch {
6685
- return "";
6682
+ return {
6683
+ content: looksLikeBinary(previous) ? "" : previous.toString("utf-8"),
6684
+ existed: true
6685
+ };
6686
+ } catch (err) {
6687
+ if (err?.code === "ENOENT") {
6688
+ return { content: "", existed: false };
6689
+ }
6690
+ throw err;
6686
6691
  }
6687
6692
  }
6688
6693
  function generateWriteDiff(previousContent, nextContent) {
@@ -6734,8 +6739,7 @@ async function executeWrite(opts) {
6734
6739
  extra: { lines: [], warnings: readSeekWarnings }
6735
6740
  });
6736
6741
  }
6737
- const previousContent = await readPreviousTextForDiff(filePath);
6738
- const existedBeforeWrite = await access(filePath).then(() => true, () => false);
6742
+ const { content: previousContent, existed: existedBeforeWrite } = await readPreviousTextForDiff(filePath);
6739
6743
  await mkdir(dirname2(filePath), { recursive: true });
6740
6744
  await writeFile(filePath, content, "utf-8");
6741
6745
  const rawLines = content.split(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-readseek",
3
- "version": "0.7.8",
3
+ "version": "0.8.0",
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": {
@@ -40,7 +40,7 @@
40
40
  "node": ">=20.0.0"
41
41
  },
42
42
  "dependencies": {
43
- "@jarkkojs/readseek": "^0.7.8",
43
+ "@jarkkojs/readseek": "^0.8.0",
44
44
  "diff": "^8.0.3",
45
45
  "xxhash-wasm": "^1.1.0"
46
46
  },