From 6c556e519db76d3e164fd4d29a484c46cda666d2 Mon Sep 17 00:00:00 2001 From: leeguooooo Date: Sat, 9 May 2026 01:40:56 +0900 Subject: [PATCH] feat(parse): friendly error when `find` has --flag where action verb expected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before, `agent-browser find role button --name Submit` errored at the daemon side with the cryptic `Unknown subaction: --name`. Now it errors at parse time with the offending flag echoed back, the list of valid actions (click, fill, check, hover, text), and a "Did you mean" hint showing where to put the action verb. Backwards compat: `find role button` (no flags, no action) still defaults to click — only `--xxx` in action position errors. --- cli/src/commands.rs | 82 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/cli/src/commands.rs b/cli/src/commands.rs index e098387..d7e1e6d 100644 --- a/cli/src/commands.rs +++ b/cli/src/commands.rs @@ -2180,7 +2180,33 @@ fn parse_find(rest: &[&str], id: &str) -> Result { _ => "find [action] [text]", }, })?; - let subaction = rest.get(2).unwrap_or(&"click"); + let raw_subaction = rest.get(2).copied(); + if let Some(s) = raw_subaction { + if s.starts_with("--") { + return Err(ParseError::InvalidValue { + message: format!( + "Missing action verb for `find {locator}` (got `{flag}` where action was expected).\n\ + Valid actions: click, fill, check, hover, text\n\ + Did you mean: agent-browser find {locator} click {flag} ...?", + locator = locator, + flag = s, + ), + usage: match *locator { + "role" => "find role [--name ] [--exact]", + "text" => "find text [--exact]", + "label" => "find label