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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-readseek",
3
- "version": "0.4.16",
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.20",
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 OCR in a single readseek detect call.
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, { ocr: true, signal });
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 ocrText = detection.ocr?.text?.trim();
176
- if (ocrText) {
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: `OCR text extracted from image:\n${ocrText}` },
181
+ { type: "text" as const, text: `Transcribed text from image:\n${transcript}` },
182
182
  ],
183
183
  });
184
184
  }
@@ -108,14 +108,14 @@ export interface ReadSeekCheckOutput {
108
108
  diagnostics: ReadSeekDiagnostic[];
109
109
  }
110
110
 
111
- export interface ReadSeekOcrLine {
111
+ export interface ReadSeekTranscriptRegion {
112
112
  text: string;
113
- bbox: [number, number, number, number];
113
+ quad: [number, number, number, number, number, number, number, number];
114
114
  }
115
115
 
116
- export interface ReadSeekOcrText {
116
+ export interface ReadSeekTranscript {
117
117
  text: string;
118
- lines: ReadSeekOcrLine[];
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
- ocr?: ReadSeekOcrText;
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 parseOcrText(value: unknown): ReadSeekOcrText | undefined {
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 ocr");
647
- const ocr = value as Record<string, unknown>;
648
- if (!Array.isArray(ocr.lines)) throw new Error("invalid readseek detect ocr.lines");
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(ocr.text, "ocr.text"),
651
- lines: ocr.lines.map((line) => {
652
- if (!line || typeof line !== "object") throw new Error("invalid readseek detect ocr line");
653
- const item = line as Record<string, unknown>;
654
- const bbox = item.bbox;
655
- if (!Array.isArray(bbox) || bbox.length !== 4) throw new Error("invalid readseek detect ocr bbox");
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, "ocr.line.text"),
658
- bbox: bbox.map((n, i) => requireNumber(n, `ocr.line.bbox[${i}]`)) as [number, number, number, number],
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
- ocr: parseOcrText(output.ocr),
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: { ocr?: boolean; signal?: AbortSignal } = {},
702
+ options: { transcribe?: boolean; signal?: AbortSignal } = {},
703
703
  ): Promise<ReadSeekDetection> {
704
704
  const args = ["detect"];
705
- if (options.ocr) args.push("--ocr");
705
+ if (options.transcribe) args.push("--transcribe");
706
706
  args.push(filePath);
707
707
  return parseDetectOutput(await runReadSeek(args, { signal: options.signal }));
708
708
  }