pi-readseek 0.4.20 → 0.4.22

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.20",
3
+ "version": "0.4.22",
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.21",
42
+ "@jarkkojs/readseek": "^0.4.28",
43
43
  "diff": "^8.0.3",
44
44
  "xxhash-wasm": "^1.1.0"
45
45
  },
package/src/read.ts CHANGED
@@ -165,7 +165,7 @@ export async function executeRead(opts: ExecuteReadOptions): Promise<AgentToolRe
165
165
  } catch {
166
166
  // detect unavailable — fall through to binary-as-text handling below
167
167
  }
168
- if (detection?.type === "image") {
168
+ if (detection?.kind === "image") {
169
169
  const builtinRead = createReadTool(cwd);
170
170
  const builtinResult = await builtinRead.execute(toolCallId, p, signal, onUpdate);
171
171
  const transcript = detection.transcribe?.text?.trim();
@@ -120,7 +120,8 @@ export interface ReadSeekTranscript {
120
120
 
121
121
  export type ReadSeekDetection =
122
122
  | {
123
- type: "source";
123
+ kind: "source";
124
+ type: string;
124
125
  file: string;
125
126
  language: string;
126
127
  engine?: string;
@@ -129,7 +130,8 @@ export type ReadSeekDetection =
129
130
  syntax?: string;
130
131
  }
131
132
  | {
132
- type: "image";
133
+ kind: "image";
134
+ type: string;
133
135
  file: string;
134
136
  mime?: string;
135
137
  format: string;
@@ -139,12 +141,8 @@ export type ReadSeekDetection =
139
141
  transcribe?: ReadSeekTranscript;
140
142
  }
141
143
  | {
142
- type: "binary";
143
- file: string;
144
- mime?: string;
145
- }
146
- | {
147
- type: "text";
144
+ kind: "text";
145
+ type: string;
148
146
  file: string;
149
147
  mime?: string;
150
148
  };
@@ -667,34 +665,38 @@ function parseDetectOutput(value: unknown): ReadSeekDetection {
667
665
  const type = requireString(output.type, "type");
668
666
  const file = requireString(output.file, "file");
669
667
  const mime = optionalString(output.mime, "mime");
670
- switch (type) {
671
- case "source":
672
- return {
673
- type,
674
- file,
675
- language: requireString(output.language, "language"),
676
- engine: optionalString(output.engine, "engine"),
677
- supported: requireBoolean(output.supported, "supported"),
678
- mime,
679
- syntax: optionalString(output.syntax, "syntax"),
680
- };
681
- case "image":
682
- return {
683
- type,
684
- file,
685
- mime,
686
- format: requireString(output.format, "format"),
687
- width: requireNumber(output.width, "width"),
688
- height: requireNumber(output.height, "height"),
689
- animated: requireBoolean(output.animated, "animated"),
690
- transcribe: parseTranscript(output.transcribe),
691
- };
692
- case "binary":
693
- case "text":
694
- return { type, file, mime };
695
- default:
696
- throw new Error(`invalid readseek detect type: ${type}`);
668
+
669
+ // readseek 0.4.22 made the detect enum untagged and repurposed `type` to
670
+ // carry the actual MIME type. Discriminate structurally: image detections
671
+ // carry `format`/`width`/`height`/`animated`; source detections carry
672
+ // `language`. Text and binary are byte-identical on the wire and collapse
673
+ // to the text variant.
674
+ if (output.format !== undefined || output.width !== undefined || output.height !== undefined) {
675
+ return {
676
+ kind: "image",
677
+ type,
678
+ file,
679
+ mime,
680
+ format: requireString(output.format, "format"),
681
+ width: requireNumber(output.width, "width"),
682
+ height: requireNumber(output.height, "height"),
683
+ animated: requireBoolean(output.animated, "animated"),
684
+ transcribe: parseTranscript(output.transcribe),
685
+ };
686
+ }
687
+ if (output.language !== undefined) {
688
+ return {
689
+ kind: "source",
690
+ type,
691
+ file,
692
+ language: requireString(output.language, "language"),
693
+ engine: optionalString(output.engine, "engine"),
694
+ supported: requireBoolean(output.supported, "supported"),
695
+ mime,
696
+ syntax: optionalString(output.syntax, "syntax"),
697
+ };
697
698
  }
699
+ return { kind: "text", type, file, mime };
698
700
  }
699
701
 
700
702
  export async function readseekDetect(