pi-readseek 0.4.16 → 0.4.17
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 +2 -2
- package/src/read.ts +5 -5
- package/src/readseek-client.ts +20 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-readseek",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.17",
|
|
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.
|
|
42
|
+
"@jarkkojs/readseek": "^0.4.21",
|
|
43
43
|
"diff": "^8.0.3",
|
|
44
44
|
"xxhash-wasm": "^1.1.0"
|
|
45
45
|
},
|
package/src/read.ts
CHANGED
|
@@ -162,23 +162,23 @@ export async function executeRead(opts: ExecuteReadOptions): Promise<AgentToolRe
|
|
|
162
162
|
|
|
163
163
|
const hasBinaryContent = looksLikeBinary(rawBuffer);
|
|
164
164
|
if (hasBinaryContent) {
|
|
165
|
-
// Images are always binary; classify and
|
|
165
|
+
// Images are always binary; classify and transcribe in a single readseek detect call.
|
|
166
166
|
let detection: ReadSeekDetection | undefined;
|
|
167
167
|
try {
|
|
168
|
-
detection = await readseekDetect(absolutePath, {
|
|
168
|
+
detection = await readseekDetect(absolutePath, { transcribe: true, signal });
|
|
169
169
|
} catch {
|
|
170
170
|
// detect unavailable — fall through to binary-as-text handling below
|
|
171
171
|
}
|
|
172
172
|
if (detection?.type === "image") {
|
|
173
173
|
const builtinRead = createReadTool(cwd);
|
|
174
174
|
const builtinResult = await builtinRead.execute(toolCallId, p, signal, onUpdate);
|
|
175
|
-
const
|
|
176
|
-
if (
|
|
175
|
+
const transcript = detection.transcribe?.text?.trim();
|
|
176
|
+
if (transcript) {
|
|
177
177
|
return succeed({
|
|
178
178
|
...builtinResult,
|
|
179
179
|
content: [
|
|
180
180
|
...(builtinResult.content ?? []),
|
|
181
|
-
{ type: "text" as const, text: `
|
|
181
|
+
{ type: "text" as const, text: `Transcribed text from image:\n${transcript}` },
|
|
182
182
|
],
|
|
183
183
|
});
|
|
184
184
|
}
|
package/src/readseek-client.ts
CHANGED
|
@@ -108,14 +108,14 @@ export interface ReadSeekCheckOutput {
|
|
|
108
108
|
diagnostics: ReadSeekDiagnostic[];
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
export interface
|
|
111
|
+
export interface ReadSeekTranscriptRegion {
|
|
112
112
|
text: string;
|
|
113
|
-
|
|
113
|
+
quad: [number, number, number, number, number, number, number, number];
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
export interface
|
|
116
|
+
export interface ReadSeekTranscript {
|
|
117
117
|
text: string;
|
|
118
|
-
|
|
118
|
+
regions: ReadSeekTranscriptRegion[];
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export type ReadSeekDetection =
|
|
@@ -136,7 +136,7 @@ export type ReadSeekDetection =
|
|
|
136
136
|
width: number;
|
|
137
137
|
height: number;
|
|
138
138
|
animated: boolean;
|
|
139
|
-
|
|
139
|
+
transcribe?: ReadSeekTranscript;
|
|
140
140
|
}
|
|
141
141
|
| {
|
|
142
142
|
type: "binary";
|
|
@@ -641,21 +641,21 @@ export async function readseekCheck(
|
|
|
641
641
|
);
|
|
642
642
|
}
|
|
643
643
|
|
|
644
|
-
function
|
|
644
|
+
function parseTranscript(value: unknown): ReadSeekTranscript | undefined {
|
|
645
645
|
if (value === undefined || value === null) return undefined;
|
|
646
|
-
if (typeof value !== "object") throw new Error("invalid readseek detect
|
|
647
|
-
const
|
|
648
|
-
if (!Array.isArray(
|
|
646
|
+
if (typeof value !== "object") throw new Error("invalid readseek detect transcribe");
|
|
647
|
+
const transcribe = value as Record<string, unknown>;
|
|
648
|
+
if (!Array.isArray(transcribe.regions)) throw new Error("invalid readseek detect transcribe.regions");
|
|
649
649
|
return {
|
|
650
|
-
text: requireString(
|
|
651
|
-
|
|
652
|
-
if (!
|
|
653
|
-
const item =
|
|
654
|
-
const
|
|
655
|
-
if (!Array.isArray(
|
|
650
|
+
text: requireString(transcribe.text, "transcribe.text"),
|
|
651
|
+
regions: transcribe.regions.map((region) => {
|
|
652
|
+
if (!region || typeof region !== "object") throw new Error("invalid readseek detect transcribe region");
|
|
653
|
+
const item = region as Record<string, unknown>;
|
|
654
|
+
const quad = item.quad;
|
|
655
|
+
if (!Array.isArray(quad) || quad.length !== 8) throw new Error("invalid readseek detect transcribe quad");
|
|
656
656
|
return {
|
|
657
|
-
text: requireString(item.text, "
|
|
658
|
-
|
|
657
|
+
text: requireString(item.text, "transcribe.region.text"),
|
|
658
|
+
quad: quad.map((n, i) => requireNumber(n, `transcribe.region.quad[${i}]`)) as ReadSeekTranscriptRegion["quad"],
|
|
659
659
|
};
|
|
660
660
|
}),
|
|
661
661
|
};
|
|
@@ -687,7 +687,7 @@ function parseDetectOutput(value: unknown): ReadSeekDetection {
|
|
|
687
687
|
width: requireNumber(output.width, "width"),
|
|
688
688
|
height: requireNumber(output.height, "height"),
|
|
689
689
|
animated: requireBoolean(output.animated, "animated"),
|
|
690
|
-
|
|
690
|
+
transcribe: parseTranscript(output.transcribe),
|
|
691
691
|
};
|
|
692
692
|
case "binary":
|
|
693
693
|
case "text":
|
|
@@ -699,10 +699,10 @@ function parseDetectOutput(value: unknown): ReadSeekDetection {
|
|
|
699
699
|
|
|
700
700
|
export async function readseekDetect(
|
|
701
701
|
filePath: string,
|
|
702
|
-
options: {
|
|
702
|
+
options: { transcribe?: boolean; signal?: AbortSignal } = {},
|
|
703
703
|
): Promise<ReadSeekDetection> {
|
|
704
704
|
const args = ["detect"];
|
|
705
|
-
if (options.
|
|
705
|
+
if (options.transcribe) args.push("--transcribe");
|
|
706
706
|
args.push(filePath);
|
|
707
707
|
return parseDetectOutput(await runReadSeek(args, { signal: options.signal }));
|
|
708
708
|
}
|