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

opencode-plugin-image-attachment

v1.0.0

Published

OpenCode plugin: intercept image attachments and delegate to a multimodal sub-agent when the primary model cannot read images

Readme

opencode-plugin-image-attachment

OpenCode plugin that intercepts image attachments and delegates visual analysis to a multimodal sub-agent when the primary model cannot read images.

Problem

Your primary OpenCode agent (e.g. deepseek-v4-flash, glm-5.2) may not support image input. When a user pastes or uploads a screenshot, the model either errors out or sees nothing useful. This plugin:

  1. Detects image parts in incoming messages (base64 data URLs, file attachments with image MIME types, .png/.jpg/etc. filenames).
  2. Saves the image bytes to .opencode/images/<sessionID>/ so a multimodal sub-agent can read them later.
  3. Replaces the raw image data with a text prompt telling the primary agent: "There's an image here, delegate to the vision-capable agent."
  4. Cleans up images older than 1 hour every 10 minutes.

Installation

Local install (from npm)

opencode plugin add opencode-plugin-image-attachment

Local install (from source / GitHub)

Clone or download the plugin, then reference it in your opencode.jsonc:

{
  "plugin": [
    "./path/to/opencode-plugin-image-attachment/index.js"
  ]
}

Prerequisites

You need a multimodal sub-agent configured in your OpenCode setup.
The plugin does not create one — it only tells the primary agent which agent to delegate to.

Example agent definition for AGENTS.md (or your agent config):

# multimodal-looker

Visual analysis specialist. Reads images, screenshots, charts, and other visual content.

## Tools
- read
- glob
- grep
- compress

## Constraint
No bash, no file edits. Purely a "look at the picture and describe it" role.

Configuration

Configure the plugin in opencode.jsonc via the plugin entry:

{
  "plugin": [
    {
      "name": "opencode-plugin-image-attachment",
      "config": {
        "targetAgent": "Observer",
        "maxAge": 3600000,
        "cleanupInterval": 600000
      }
    }
  ]
}

| Option | Type | Default | Description | |--------|------|---------|-------------| | targetAgent | string | "multimodal-looker" | Name of the sub-agent that handles image analysis | | maxAge | number | 3600000 (1h) | Image file TTL in milliseconds | | cleanupInterval | number | 600000 (10min) | How often cleanup sweeps run in ms | | promptTemplate | string | (built-in) | Custom prompt template. Placeholders: {paths}, {targetAgent}, {count} |

Via environment variable

Set OPENCODE_IMAGE_AGENT to override the target agent without editing config:

$env:OPENCODE_IMAGE_AGENT="Observer"

Prompt template

Default template:

[Image attachment detected. Saved to: {paths}. The primary model cannot read images. Delegate visual analysis ({targetAgent}) when the user asks anything about this image: reading, seeing, OCR, describing, or analyzing.]

Customize it:

{
  "config": {
    "promptTemplate": "[图 {count} 张已保存至 {paths},交给 {targetAgent} 处理]"
  }
}

How it works

User sends image
       │
       ▼
Plugin hook (experimental.chat.messages.transform)
       │
       ├── Detect: image type / MIME / extension?
       │     └─ no  → pass through, nothing changed
       │
       ├── Decode base64 data URL
       ├── Save to .opencode/images/<sessionID>/<name>-<sha1[:8]><ext>
       │
       └── Replace image part(s) with text prompt:
             "[Image attachment detected... Delegate to {targetAgent}]"
                              │
                              ▼
                    Primary agent sees the prompt
                    and (if well-configured) spawns
                    the multimodal sub-agent to analyze

Publishing to npm

# login
npm login

# publish
npm publish

# update version
npm version patch   # or minor / major
npm publish

License

MIT