Skip to content

bug: run --file hardcodes text/plain MIME type for all files #16723

Description

@alexey-pelykh

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions