pi-readseek 0.7.9 → 0.8.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/dist/{index.js → index.ts} +18 -14
- package/package.json +5 -5
|
@@ -1436,8 +1436,9 @@ function readSeekBinaryAvailability() {
|
|
|
1436
1436
|
}
|
|
1437
1437
|
}
|
|
1438
1438
|
function classifyReadSeekFailure(err) {
|
|
1439
|
-
const
|
|
1440
|
-
const
|
|
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", "--
|
|
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", "--
|
|
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", "--
|
|
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 {
|
|
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
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
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,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-readseek",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
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": {
|
|
7
|
-
".": "./dist/index.
|
|
7
|
+
".": "./dist/index.ts"
|
|
8
8
|
},
|
|
9
9
|
"keywords": [
|
|
10
10
|
"pi-package",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"license": "Apache-2.0",
|
|
22
22
|
"pi": {
|
|
23
23
|
"extensions": [
|
|
24
|
-
"./dist/index.
|
|
24
|
+
"./dist/index.ts"
|
|
25
25
|
]
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"README.md"
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
|
-
"build": "bun build index.ts --outfile dist/index.
|
|
34
|
+
"build": "bun build index.ts --outfile dist/index.ts --target=node --packages=external",
|
|
35
35
|
"prepack": "npm run build",
|
|
36
36
|
"test": "npm run build && node scripts/vitest-run.mjs",
|
|
37
37
|
"typecheck": "tsc --noEmit"
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"node": ">=20.0.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@jarkkojs/readseek": "^0.
|
|
43
|
+
"@jarkkojs/readseek": "^0.8.1",
|
|
44
44
|
"diff": "^8.0.3",
|
|
45
45
|
"xxhash-wasm": "^1.1.0"
|
|
46
46
|
},
|