mirror of
https://github.com/chenhg5/cc-connect.git
synced 2026-10-26 01:50:40 +08:00
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:
1 parent
003d96d68b
commit
9613fc85c4
2 files changed
+4
-3
No files matched your search
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user