From 1437d1fc1c6040880b74f6d7b598443fee768959 Mon Sep 17 00:00:00 2001 From: Alex Holder Date: Tue, 4 Nov 2025 17:54:28 +0000 Subject: [PATCH] improvement: add useful error message when attempting to use unauthenticated cursor-agent (#5300) Signed-off-by: Alex Holder --- crates/goose/src/providers/cursor_agent.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/crates/goose/src/providers/cursor_agent.rs b/crates/goose/src/providers/cursor_agent.rs index 31b185f3..225d09e0 100644 --- a/crates/goose/src/providers/cursor_agent.rs +++ b/crates/goose/src/providers/cursor_agent.rs @@ -47,6 +47,17 @@ impl CursorAgentProvider { }) } + /// Get authentication status from cursor-agent + async fn get_authentication_status(&self) -> bool { + Command::new(&self.command) + .arg("status") + .output() + .await + .ok() + .map(|output| String::from_utf8_lossy(&output.stdout).contains("✓ Logged in as")) + .unwrap_or(false) + } + /// Search for cursor-agent executable in common installation locations fn find_cursor_agent_executable(command_name: &str) -> Option { let home = std::env::var("HOME").ok()?; @@ -319,6 +330,11 @@ impl CursorAgentProvider { })?; if !exit_status.success() { + if !self.get_authentication_status().await { + return Err(ProviderError::Authentication( + "You are not logged in to cursor-agent. Please run 'cursor-agent login' to authenticate first." + .to_string())); + } return Err(ProviderError::RequestFailed(format!( "Command failed with exit code: {:?}", exit_status.code()