Problem
The run command's --file flag hardcodes text/plain MIME type for all non-directory files, making binary file attachments (images, audio, video) non-functional.
In packages/opencode/src/cli/cmd/run.ts:
const mime = (await Filesystem.isDir(resolvedPath))
? "application/x-directory"
: "text/plain"
Expected behavior
MIME type should be detected from the file (e.g. via extension or magic bytes) so that opencode run --file image.png -m "describe this" correctly passes the image as image/png.
Reproduction
opencode run --format json --file photo.jpg -m "describe this image"
The file is sent as text/plain regardless of actual content type, so the model receives corrupted/unusable binary data.
Suggested fix
Use file extension or content-based MIME detection (e.g. mime-types package or Node's built-in detection) instead of the hardcoded "text/plain" fallback.
Problem
The
runcommand's--fileflag hardcodestext/plainMIME type for all non-directory files, making binary file attachments (images, audio, video) non-functional.In
packages/opencode/src/cli/cmd/run.ts:Expected behavior
MIME type should be detected from the file (e.g. via extension or magic bytes) so that
opencode run --file image.png -m "describe this"correctly passes the image asimage/png.Reproduction
opencode run --format json --file photo.jpg -m "describe this image"The file is sent as
text/plainregardless of actual content type, so the model receives corrupted/unusable binary data.Suggested fix
Use file extension or content-based MIME detection (e.g.
mime-typespackage or Node's built-in detection) instead of the hardcoded"text/plain"fallback.