fix(opencode): add -- separator before prompt to prevent --file from consuming it

OpenCode CLI's --file flag is a yargs [array] type that greedily
consumes subsequent arguments as file paths. Without a -- separator,
the prompt text following --file was parsed as a filename, causing
"File not found" errors when images were attached.

Reported-by: community user via image analysis
Made-with: Cursor
This commit is contained in:
Claude committed 2026-04-28 22:07:48 +08:00
1 parent 003d96d68b
commit 9613fc85c4
2 files changed
+4 -3

No files matched your search

+3 -2
View File
@@ -169,8 +169,9 @@ func (s *opencodeSession) buildRunArgs(prompt string, imagePaths []string, chatI
args = append(args, "--file", imagePath)
}
// Append prompt as positional arg.
args = append(args, prompt)
// Use "--" to separate flags from the positional prompt so that
// --file (yargs [array]) does not greedily consume the prompt text.
args = append(args, "--", prompt)
return args
}
+1 -1
View File
@@ -112,7 +112,7 @@ func TestOpencodeSessionBuildRunArgsIncludesImagesAsFiles(t *testing.T) {
"--thinking",
"--file", "/tmp/a.png",
"--file", "/tmp/b.jpg",
"describe these images",
"--", "describe these images",
}
if !reflect.DeepEqual(got, want) {
t.Fatalf("args = %#v, want %#v", got, want)