anomalyco / anomalyco/opencode

run --file before the message swallows the message into the file list

Open
#40,304 1 comment 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Aug 3, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

--file is declared [array] and message is a positional [array], so yargs greedily pulls the message words into the file list when the flag comes first.

Reproduced on 1.18.11, clean node:24-alpine container, nothing else installed.

Fails:

$ opencode run --file /tmp/note.txt summarize this please
Error: File not found: summarize

Works, same arguments, message moved ahead of the flag:

$ opencode run summarize this please --file /tmp/note.txt
Hello file content.

opencode run --help shows why:

Positionals:
  message  message to send                          [array] [default: []]

Options:
  -f, --file   file(s) to attach to message                        [array]

Two things make this cost more time than it should. Flag-before-message is the natural order to write, and the error names the first word of the message, so it reads as "opencode cannot find my file" rather than "the argument order matters". Nothing points at the parse.

Workaround for anyone who lands here: insert -- before the message.

opencode run --file /tmp/note.txt -- summarize this please

Possible fixes, whichever matches your CLI conventions: nargs(1) on --file so it takes exactly one value per occurrence and repeats for multiple files, or requiresArg, or just documenting the -- in the help text.

I have carried a wrapper that injects the -- since 1.15.x, so this is long-standing rather than a recent regression. Happy to send a PR if you have a preference among those three.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.