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-auto-vision

v1.0.1

Published

OpenCode plugin that auto-detects a model's media capabilities and routes pasted images/videos to a vision MCP tool — so text-only models can still 'see' pasted media.

Readme

opencode-auto-vision

License: MIT OpenCode Plugin npm version GitHub repo

An OpenCode plugin that gives text-only models the ability to handle pasted images and videos — by auto-detecting whether the current model supports a media kind and, if not, routing the media to a vision MCP tool.

Unlike pattern-based vision plugins, you don't enumerate which models to intercept: opencode-auto-vision reads each model's declared capabilities (attachment + modalities.input) and only steps in when the model genuinely can't handle the pasted media. Vision-capable models are skipped automatically.

How it works

user pastes image/video + asks a question
  ↓
experimental.chat.messages.transform hook  (runs right before the LLM call)
  ├─ find last user message, collect media FileParts (image/* and video/*)
  ├─ for each media kind, ask: does (provider/model) support it natively?
  │     • resolved from the opencode provider catalog (cached once)
  │     • unknown model → assume yes (never interferes blindly)
  ├─ if the model supports every present kind → skip (native vision)
  ├─ else, for each unsupported media part:
  │     • file://  → use the local path directly
  │     • data:    → base64-decode → save to a stable tmp path (sha256(partId))
  │     • http(s): → pass the URL straight to the MCP tool
  │     • strip the raw media part (kills the "model does not support image input" error)
  └─ inject a text instruction pointing the model at the saved path + tool
  ↓
model sees the path hint → calls the configured MCP tool (analyze_image / analyze_video)

Features

  • Capability-based auto-detect — no per-model config; vision models are left alone.
  • Images and video — png/jpeg/webp/gif/bmp + mp4/mov/webm/mkv.
  • Any MCP vision tool — configurable imageTool / videoTool (defaults to analyze_image / analyze_video from @z_ai/mcp-server).
  • Stable temp pathssha256(partId).ext, so re-transforms after tool calls reuse the same file.
  • Age-based cleanup of temp files on load.
  • Toast notifications on partial/total failures.
  • Escape hatchforceModels patterns to override capabilities if ever needed.

Install

Add to your opencode.json:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["opencode-auto-vision"]
}

And make sure a vision MCP tool is configured, e.g. the Z.AI vision server:

{
  "mcp": {
    "zai-mcp-server": {
      "type": "local",
      "command": ["npx", "-y", "@z_ai/mcp-server@latest"],
      "environment": { "Z_AI_API_KEY": "your-key", "Z_AI_MODE": "ZAI" }
    }
  }
}

Configuration

Optional. Drop a file at ~/.config/opencode/opencode-auto-vision.jsonc (user) or .opencode/opencode-auto-vision.jsonc (project). See opencode-auto-vision.example.jsonc.

{
  "imageTool": "analyze_image",
  "videoTool": "analyze_video",
  "cleanupAfterHours": 24
}

| Option | Default | Description | | -------------------- | -------------------------- | ----------------------------------------------------------------- | | imageTool | analyze_image | MCP tool the model calls for images. | | videoTool | analyze_video | MCP tool the model calls for videos. | | cleanupAfterHours | 24 | Temp files older than this are removed on plugin load. | | promptTemplate | built-in | Custom prompt. Variables: {mediaList} {mediaCount} {kind} {toolName} {userText}. | | forceModels | [] | Patterns (provider/*, *model, *) that force interception. |

Media is always saved under the system temp dir ($TMPDIR/opencode-auto-vision); this is not configurable.

Usage

  1. Select a text-only model in OpenCode (e.g. zai-coding-plan/glm-5.2).
  2. Paste an image or video (Cmd+V / Ctrl+V).
  3. Ask your question — the plugin routes the media to your vision MCP tool automatically.

Switch to a vision model (e.g. glm-5v-turbo) and the plugin silently steps aside.

License

MIT © Artem Bambalov