Skip to content

Commit a3270db

Browse files
committed
fix: ultraworkers#127 reject unrecognized suffix args for diagnostic verbs
Diagnostic verbs (help, version, status, sandbox, doctor, state) now reject unrecognized suffix arguments at parse time instead of silently falling through to Prompt dispatch. Fixes: claw doctor --json (and similar) no longer accepts --json silently and attempts to send it to the LLM as a prompt. Now properly emits: 'unrecognized argument `--json` for subcommand `doctor`' Joined parser-level trust gap quintet ultraworkers#108 + ultraworkers#117 + ultraworkers#119 + ultraworkers#122 + ultraworkers#127. Prevents token burn on rejected arguments. Verified: cargo build --workspace passes, claw doctor --json errors cleanly. Refs: ultraworkers#127, ROADMAP
1 parent 12f1f9a commit a3270db

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

  • rust/crates/rusty-claude-cli/src

rust/crates/rusty-claude-cli/src/main.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,31 @@ fn parse_single_word_command_alias(
746746
permission_mode_override: Option<PermissionMode>,
747747
output_format: CliOutputFormat,
748748
) -> Option<Result<CliAction, String>> {
749+
if rest.is_empty() {
750+
return None;
751+
}
752+
753+
// Diagnostic verbs (help, version, status, sandbox, doctor, state) accept only the verb itself
754+
// or --help / -h as a suffix. Any other suffix args are unrecognized.
755+
let verb = &rest[0];
756+
let is_diagnostic = matches!(
757+
verb.as_str(),
758+
"help" | "version" | "status" | "sandbox" | "doctor" | "state"
759+
);
760+
761+
if is_diagnostic && rest.len() > 1 {
762+
// Diagnostic verb with trailing args: reject unrecognized suffix
763+
if is_help_flag(&rest[1]) && rest.len() == 2 {
764+
// "doctor --help" is valid, routed to parse_local_help_action() instead
765+
return None;
766+
}
767+
// Unrecognized suffix like "--json"
768+
return Some(Err(format!(
769+
"unrecognized argument `{}` for subcommand `{}`",
770+
rest[1], verb
771+
)));
772+
}
773+
749774
if rest.len() != 1 {
750775
return None;
751776
}

0 commit comments

Comments
 (0)