New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

pi-bash-image

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pi-bash-image

Inject images into bash tool results — no extra round trip. Append && __PI_IMAGE__ file.png to any bash command.

npmnpm
Version
0.1.0
Version published
Weekly downloads
5
-44.44%
Maintainers
1
Weekly downloads
 
Created
Source

pi-bash-image

A pi extension that lets the LLM include images directly in bash tool results — saving a full API round trip per screenshot.

The Problem

With pi's default tools, viewing an image after a bash command takes two LLM calls:

  • bash: run command, take screenshot
  • read: load the screenshot into context

That's an extra network round trip every time the model needs to see what it did.

The Fix

This extension overrides the bash tool to inject a __PI_IMAGE__ shell function. The model appends it to any command, and the image comes back in the same tool result.

One call. Text + images together.

Install

pi install npm:pi-bash-image

Usage

The model automatically gets instructions via prompt guidelines. Examples of what it'll do:

# Screenshot in the same result
agent-browser screenshot page.png && __PI_IMAGE__ page.png

# Text output + image together
agent-browser snapshot -i | __PI_IMAGE__ page.png

# Multiple images
__PI_IMAGE__ before.png after.png

How It Works

  • A spawnHook prepends the __PI_IMAGE__ shell function to every bash command
  • The function passes through stdin (piped text) and prints a marker with the absolute file path
  • After bash executes, the extension scans stdout for markers, reads the files, detects mime type via magic bytes, and returns them as image content blocks alongside any text output

The override delegates to the real bash tool implementation — rendering, details, everything else is untouched.

Extensible

The implementation uses a pluggable BashCommand interface. Adding new inline commands (not just images) is just defining a new object with a preamble, guideline, and handler — the core loop handles the rest.

License

MIT

Keywords

pi-package

FAQs

Package last updated on 16 Mar 2026

Related posts