npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hffmnnj.image-mirror

v1.0.2

Published

Mirror every image an OpenCode V2 agent sees into the user chat without adding it back to the agent context

Readme

Image Mirror for OpenCode

Every image an agent sees should also be visible to the human in the chat. This OpenCode V2 plugin makes that happen without ever sending the image back to the model a second time.

  • npm package and plugin ID: hffmnnj.image-mirror
  • Hooks the session.context model request, the exact point where the agent's images are assembled
  • Mirrors only images that are not already in the user's chat
  • Mirrored notices carry a file path, never image bytes, so the agent context stays clean

Why

Images reach an agent in several ways: attached by a user, returned by a tool, or injected into a request by another plugin's context hook. The first two are already rendered in the chat timeline. The third is not — the model sees an image the user never sees.

This plugin closes that gap. It compares each model request against the session's stored history and publishes display-only notices for the images that would otherwise be invisible.

The context guarantee

A mirror notice is posted with ctx.session.synthetic({ resume: false }). OpenCode renders synthetic messages in the chat, but lowers their text to a plain text part for the model. The notice contains only a markdown image reference to a local file:

![shot.png](/home/me/.local/share/opencode/image-mirror/<sha256>.png)

No base64 payload, no media part, no data URL, and no image bytes are added to any model request. The agent therefore never sees a second copy of an image it already received. The plugin also avoids the failure mode of removing notices from a request: removing the last user-role message can break turn ordering for models that require the conversation to end with user input. resume: false keeps an idle session asleep, so a mirror never triggers an extra model turn.

Requirements

OpenCode V2 with @opencode/plugin 2.x. No API keys, credentials, or external services are used.

Install

Add the package to the plugins array in your OpenCode config. Keep unrelated entries unchanged.

{
  "$schema": "https://opencode.ai/config.json",
  "plugins": ["hffmnnj.image-mirror"]
}

The plugin takes no options. Plugin changes apply after saving the config; use /reload if you want to force a full reload.

How it works

  1. A session.context hook inspects the outgoing model request for image media parts and image files in tool results.
  2. Messages whose IDs are in the stored session history, and images whose fingerprints already appear in stored attachments or tool results, are skipped — they are already on screen.
  3. Each remaining image is written once to a stable path under the OpenCode data directory ($OPENCODEV2_DATA_HOME, $XDG_DATA_HOME, or ~/.local/share), named by its SHA-256 fingerprint.
  4. A display-only synthetic notice with a markdown image reference is posted to the session with resume: false.
  5. A durable per-session fingerprint ledger prevents re-mirroring on later model calls.

Images referenced by remote URLs are mirrored by reference rather than downloaded.

What gets mirrored

| Image source | Already in chat? | Action | | --- | --- | --- | | User attachment | Yes | Skipped | | Tool result with an image file | Yes | Skipped | | Image injected by another plugin's context hook | No | Mirrored | | Image injected under a different message ID | No | Skipped when its bytes match chat history | | A mirrored image on a later turn | Yes | Skipped by the ledger |

Privacy

Image bytes are written only to your local OpenCode data directory. Nothing is uploaded, logged, or sent to a third party by this plugin.

Development

bun install
bun run check   # typecheck + unit tests

Unit tests cover image detection across media parts and tool results, chat-history and fingerprint deduplication, and the invariant that mirror notices contain only paths.

License

MIT