diff --git a/codeagent-wrapper/agent_config_test.go b/codeagent-wrapper/agent_config_test.go index 0a8e9ad..a3602be 100644 --- a/codeagent-wrapper/agent_config_test.go +++ b/codeagent-wrapper/agent_config_test.go @@ -188,6 +188,15 @@ func TestOpencodeBackend_BuildArgs(t *testing.T) { t.Errorf("got %v, want %v", got, want) } }) + + t.Run("stdin mode omits dash", func(t *testing.T) { + cfg := &Config{Mode: "new"} + got := backend.BuildArgs(cfg, "-") + want := []string{"run", "--format", "json"} + if !reflect.DeepEqual(got, want) { + t.Errorf("got %v, want %v", got, want) + } + }) } func TestOpencodeBackend_Interface(t *testing.T) { diff --git a/codeagent-wrapper/backend.go b/codeagent-wrapper/backend.go index d5c5473..5a73410 100644 --- a/codeagent-wrapper/backend.go +++ b/codeagent-wrapper/backend.go @@ -204,7 +204,10 @@ func (OpencodeBackend) BuildArgs(cfg *Config, targetArg string) []string { if cfg.Mode == "resume" && cfg.SessionID != "" { args = append(args, "-s", cfg.SessionID) } - args = append(args, "--format", "json", targetArg) + args = append(args, "--format", "json") + if targetArg != "-" { + args = append(args, targetArg) + } return args }