pi-image-preview 0.1.0 → 0.1.2
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/README.md +1 -1
- package/package.json +1 -1
- package/src/extension-runtime.ts +4 -22
- package/src/prompt.ts +0 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pi-image-preview
|
|
2
2
|
|
|
3
|
-
Image preview extension for [pi coding agent](https://github.com/
|
|
3
|
+
Image preview extension for [pi coding agent](https://github.com/badlogic/pi-mono) — renders inline image thumbnails above the editor using the kitty graphics protocol with full tmux support.
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-image-preview",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Image preview extension for pi coding agent — renders inline image thumbnails above the editor using kitty graphics protocol with tmux support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
package/src/extension-runtime.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import type { ImageContent, ContentBlock } from "./content.ts";
|
|
3
3
|
import { ImageGallery, type GalleryImage } from "./image-gallery.ts";
|
|
4
|
-
import { PREFER_INLINE_SCREENSHOT_PROMPT } from "./prompt.ts";
|
|
5
4
|
import { upgradeScreenshotToolResult } from "./tool-result-upgrader.ts";
|
|
6
5
|
import { debugLog } from "./debug.ts";
|
|
7
6
|
|
|
@@ -240,10 +239,6 @@ export function registerImagePreviewExtension(
|
|
|
240
239
|
|
|
241
240
|
// ── Event handlers ─────────────────────────────────────
|
|
242
241
|
|
|
243
|
-
pi.on("before_agent_start", () => {
|
|
244
|
-
return { systemPrompt: PREFER_INLINE_SCREENSHOT_PROMPT };
|
|
245
|
-
});
|
|
246
|
-
|
|
247
242
|
// Clean up resources when the process exits
|
|
248
243
|
const cleanup = (): void => {
|
|
249
244
|
stopPolling();
|
|
@@ -292,15 +287,12 @@ export function registerImagePreviewExtension(
|
|
|
292
287
|
return { action: "continue" };
|
|
293
288
|
}
|
|
294
289
|
|
|
295
|
-
//
|
|
290
|
+
// Collect images for all tracked paths in the submitted text
|
|
296
291
|
const usedImages: ImageContent[] = [];
|
|
297
|
-
let strippedText = fullText;
|
|
298
292
|
|
|
299
293
|
for (const [trackedPath, entry] of tracked) {
|
|
300
294
|
if (fullText.includes(trackedPath)) {
|
|
301
295
|
usedImages.push(entry.image);
|
|
302
|
-
// Strip the path from the text
|
|
303
|
-
strippedText = strippedText.split(trackedPath).join("");
|
|
304
296
|
}
|
|
305
297
|
}
|
|
306
298
|
|
|
@@ -308,24 +300,14 @@ export function registerImagePreviewExtension(
|
|
|
308
300
|
return { action: "continue" };
|
|
309
301
|
}
|
|
310
302
|
|
|
311
|
-
// Clean up whitespace after stripping paths
|
|
312
|
-
strippedText = strippedText.replace(/\s+/g, " ").trim();
|
|
313
|
-
|
|
314
303
|
// Clear state
|
|
315
304
|
resetDraft(ctx);
|
|
316
305
|
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
pi.sendUserMessage(
|
|
320
|
-
usedImages,
|
|
321
|
-
ctx.isIdle() ? undefined : { deliverAs: "steer" },
|
|
322
|
-
);
|
|
323
|
-
return { action: "handled" };
|
|
324
|
-
}
|
|
325
|
-
|
|
306
|
+
// Keep the original text as-is (paths stay visible in chat),
|
|
307
|
+
// just attach the actual image data alongside
|
|
326
308
|
return {
|
|
327
309
|
action: "transform",
|
|
328
|
-
text:
|
|
310
|
+
text: fullText,
|
|
329
311
|
images: [...(event.images ?? []), ...usedImages],
|
|
330
312
|
};
|
|
331
313
|
});
|
package/src/prompt.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export const PREFER_INLINE_SCREENSHOT_PROMPT =
|
|
2
|
-
"When you need to inspect a screenshot yourself, prefer screenshot tool calls that return the image inline. Avoid passing filePath to screenshot tools unless the user explicitly asked you to save a file or you do not need to inspect the image content yourself.";
|