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 <actual prompt>').

Remove 'chat' from buildCursorArgs so the generated argv matches the
current cursor-agent CLI interface.

Fixes #3077
This commit is contained in:
Kagura
2026-05-27 16:40:29 +08:00
committed by GitHub
parent bdb60acae9
commit f02bc56e70
4 changed files with 6 additions and 9 deletions

View File

@@ -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 <prompt> --output-format stream-json
// Usage: cursor-agent -p <prompt> --output-format stream-json
//
// --workspace <cwd> --yolo [--model <m>] [--resume <id>]
func buildCursorArgs(prompt string, opts ExecOptions, logger *slog.Logger) []string {
args := []string{
"chat",
"-p", prompt,
"--output-format", "stream-json",
"--yolo",

View File

@@ -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)

View File

@@ -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")
}
}

View File

@@ -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)