@peppa_q/attach-image-path

Pi extension that detects image file paths in your prompt, reads the file, and injects the real image into the model so it always sees the picture.

Packages

Package details

extension

Install @peppa_q/attach-image-path from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@peppa_q/attach-image-path
Package
@peppa_q/attach-image-path
Version
1.0.0
Published
Aug 22, 2026
Downloads
109/mo · 6/wk
Author
peppa_q
License
MIT
Types
extension
Size
10.2 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./src/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

attach-image-path

A Pi extension that detects image file paths in your prompt, reads the file, and injects the real image into the model — so the model always sees the picture instead of treating the path as plain text.

This fixes the common case where you paste a local screenshot path (e.g. from Snipping Tool) and the model never actually looks at the image.

What it does

Detects an image path in your message (Windows C:\..., WSL /mnt/c/..., or relative paths), reads the file, converts it to base64, and attaches it directly to the prompt via the input transform's images field. The image is fed to the model as a real image, so it's guaranteed to be seen.

Features

  • Windows + WSL paths — converts C:\... to /mnt/c/... using the WSL-native wslpath, honoring your configured mount point in /etc/wsl.conf
  • Space-tolerant — handles paths with spaces like C:\Program Files\My App\shot.png
  • Magic-byte mime detection — detects PNG/JPEG/GIF/WebP/BMP from file headers, not just the extension
  • Size guard — rejects images over 20MB with a clear warning

Install

pi install npm:@peppa_q/attach-image-path

Or try it for one session:

pi -e npm:@peppa_q/attach-image-path

Platform support

This extension is built for Windows + WSL — it exists to turn the Windows screenshot paths you paste (like C:\Users\...\ScreenClip\xxx.png) into images the model can actually see.

  • Windows drive paths (C:\...) are converted via the WSL-native wslpath command, so this works when pi runs inside WSL. If you run pi directly on Windows (not through WSL), the wslpath command is unavailable and drive paths won't resolve.
  • macOS / Linux: native paths (/Users/..., /home/..., ./x.png, /tmp/...) work out of the box. Windows drive paths (C:\...) are not converted — they only make sense on a machine with the matching drive.

If you primarily use pi on Windows, the typical setup is: screenshots live on the Windows filesystem, and you run pi inside WSL so wslpath bridges the two.

Usage

Just paste an image path into your prompt. For example:

C:\Users\demo\Pictures\screenshot.png 这是什么

The extension reads the file, attaches the image, and the model sees it directly.

How it works

It subscribes to the input event. When the prompt contains an image path, it:

  1. Extracts the path (Windows, WSL, or relative)
  2. Normalizes it to a readable absolute path (wslpath for Windows paths)
  3. Reads the file and converts it to base64
  4. Injects the image via the transform result's images field

Notes

  • Uses only Node built-in modules (node:fs/promises, node:path, node:child_process) and Pi core packages (declared as peer dependencies). No bundled runtime dependencies.

License

MIT