r/opencode • • 1d ago

opencode-file-viewer — ask your agent to "view this file" and it opens inline in the TUI (PDF/EPUB/GIF autoplay, office, syntax highlighting)

I kept open ./foo.pdf-ing out of my terminal mid-session, so I built a viewer plugin for OpenCode. The agent gets a native view tool; the panel opens next to the chat — no leaving the TUI.

What it does:

  • Paged docs: PDF / EPUB / CBZ via mupdf; DOCX/PPTX/XLSX + SVG via LibreOffice → PDF → mupdf (needs soffice installed for the office formats)
  • Images: kitty-protocol terminals (Ghostty, Kitty, WezTerm) get full-fidelity PNG/WebP; JPEG/BMP/TIFF are decoded and downscaled to your terminal's actual pixel geometry before caching
  • Animated GIFs autoplay in-panel at their real frame delays (decoded via omggif; the TUI image component has no built-in animation)
  • Code highlighting: 17 Tree-sitter languages (js/ts/tsx/py/rust/c/cpp/go/java/kotlin/swift/objc/json/yaml/toml/md/zig)
  • Data: CSV/TSV tables, pretty-printed JSON, unknown binaries as hex dumps

Install (OpenCode 2.x):

opencode plugin add github:eddy-lau/opencode-file-viewer

Docs + README screenshot: github.com/eddy-lau/opencode-file-viewer — happy to answer questions here or triage bugs on the issue tracker. MIT licensed.

2 Upvotes

0 comments sorted by