From f02bc56e70e81d5ba0eba347a14dc187f70b4030 Mon Sep 17 00:00:00 2001 From: Kagura Date: Wed, 27 May 2026 16:40:29 +0800 Subject: [PATCH] fix(agent/cursor): remove obsolete 'chat' subcommand from argv (#3077) (#3092) The current cursor-agent CLI no longer has a 'chat' subcommand. The positional 'chat' argument was silently treated as prompt text, leaking into the user message (e.g. 'chat '). Remove 'chat' from buildCursorArgs so the generated argv matches the current cursor-agent CLI interface. Fixes #3077 --- server/pkg/agent/cursor.go | 3 +-- server/pkg/agent/cursor_invocation_test.go | 2 +- server/pkg/agent/cursor_invocation_windows_test.go | 7 +++---- server/pkg/agent/cursor_test.go | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/server/pkg/agent/cursor.go b/server/pkg/agent/cursor.go index e5f1acf5f..f2bfa26e3 100644 --- a/server/pkg/agent/cursor.go +++ b/server/pkg/agent/cursor.go @@ -396,12 +396,11 @@ var cursorBlockedArgs = map[string]blockedArgMode{ // buildCursorArgs assembles the argv for a one-shot cursor-agent invocation. // -// Usage: cursor-agent chat -p --output-format stream-json +// Usage: cursor-agent -p --output-format stream-json // // --workspace --yolo [--model ] [--resume ] func buildCursorArgs(prompt string, opts ExecOptions, logger *slog.Logger) []string { args := []string{ - "chat", "-p", prompt, "--output-format", "stream-json", "--yolo", diff --git a/server/pkg/agent/cursor_invocation_test.go b/server/pkg/agent/cursor_invocation_test.go index ecd16d2f2..316d1b8d2 100644 --- a/server/pkg/agent/cursor_invocation_test.go +++ b/server/pkg/agent/cursor_invocation_test.go @@ -18,7 +18,7 @@ func TestChooseCursorInvocation_PassthroughForNonLauncher(t *testing.T) { execName := "cursor-agent" lookedUp := filepath.Join(t.TempDir(), "cursor-agent") // no .cmd / .bat - args := []string{"chat", "-p", "hello\nworld", "--output-format", "stream-json", "--yolo"} + args := []string{"-p", "hello\nworld", "--output-format", "stream-json", "--yolo"} gotExec, gotArgs := chooseCursorInvocation(execName, lookedUp, args, logger) diff --git a/server/pkg/agent/cursor_invocation_windows_test.go b/server/pkg/agent/cursor_invocation_windows_test.go index e43c26a74..c55b2afe8 100644 --- a/server/pkg/agent/cursor_invocation_windows_test.go +++ b/server/pkg/agent/cursor_invocation_windows_test.go @@ -45,7 +45,6 @@ func TestPlatformCursorInvocation_RewritesCmdLauncherToPowerShellFile(t *testing stubPowerShell(t, fakePS, true) args := []string{ - "chat", "-p", "line1\nline2\nline3", "--output-format", "stream-json", "--yolo", @@ -84,7 +83,7 @@ func TestPlatformCursorInvocation_SkipsWhenNotCmdOrBat(t *testing.T) { stubPowerShell(t, filepath.Join(dir, "powershell.exe"), true) logger := slog.New(slog.NewTextHandler(io.Discard, nil)) - if _, _, ok := platformCursorInvocation(exePath, []string{"chat"}, logger); ok { + if _, _, ok := platformCursorInvocation(exePath, []string{"-p", "hello"}, logger); ok { t.Fatalf("expected ok=false for non-.cmd/.bat launcher") } } @@ -101,7 +100,7 @@ func TestPlatformCursorInvocation_SkipsWhenPS1Missing(t *testing.T) { stubPowerShell(t, filepath.Join(dir, "powershell.exe"), true) logger := slog.New(slog.NewTextHandler(io.Discard, nil)) - if _, _, ok := platformCursorInvocation(cmdPath, []string{"chat"}, logger); ok { + if _, _, ok := platformCursorInvocation(cmdPath, []string{"-p", "hello"}, logger); ok { t.Fatalf("expected ok=false when cursor-agent.ps1 is missing") } } @@ -119,7 +118,7 @@ func TestPlatformCursorInvocation_SkipsWhenPowerShellMissing(t *testing.T) { stubPowerShell(t, "", false) logger := slog.New(slog.NewTextHandler(io.Discard, nil)) - if _, _, ok := platformCursorInvocation(cmdPath, []string{"chat"}, logger); ok { + if _, _, ok := platformCursorInvocation(cmdPath, []string{"-p", "hello"}, logger); ok { t.Fatalf("expected ok=false when no powershell host is available") } } diff --git a/server/pkg/agent/cursor_test.go b/server/pkg/agent/cursor_test.go index 9390885c4..e63af50ec 100644 --- a/server/pkg/agent/cursor_test.go +++ b/server/pkg/agent/cursor_test.go @@ -27,7 +27,6 @@ func TestBuildCursorArgs(t *testing.T) { }, slog.Default()) expected := []string{ - "chat", "-p", "do something", "--output-format", "stream-json", "--yolo", @@ -67,7 +66,7 @@ func TestBuildCursorArgsMinimal(t *testing.T) { t.Parallel() args := buildCursorArgs("hello", ExecOptions{}, slog.Default()) - expected := []string{"chat", "-p", "hello", "--output-format", "stream-json", "--yolo"} + expected := []string{"-p", "hello", "--output-format", "stream-json", "--yolo"} if len(args) != len(expected) { t.Fatalf("expected %d args, got %d: %v", len(expected), len(args), args)