diff --git a/ROADMAP.md b/ROADMAP.md index a6af5fad..f6098f46 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -7749,3 +7749,5 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed) 790. **`claw --output-format json system-prompt ` returned `error_kind:"unknown"` + `hint:null`** — dogfooded 2026-05-27 on `e4c3c1aa`. The unknown-option branch in `parse_print_system_prompt_args` emitted plain `"unknown system-prompt option: {other}"` for all unrecognised options except `--json` (which appended a `\n`-delimited suggestion). All non-`--json` cases fell to `unknown+null`. Fix: replaced bare format string with `unknown_option: ... \n` format for all unknown options; `--json` special case preserves its `--output-format json` suggestion in the hint prefix. Integration test `system_prompt_unknown_option_returns_typed_kind_790` covers both paths. 50 CLI contract tests pass. [SCOPE: claw-code] Source: Jobdori system-prompt option probe on `e4c3c1aa`, 2026-05-27. 791. **`claw config show ` and `claw config set ` returned `unexpected_extra_args` + `hint:null`** — dogfooded 2026-05-27 on `9968a27e`. The config arg parser emitted `"unexpected extra arguments after `claw config {}`: {}"` with no `\n` delimiter, so `split_error_hint` returned `None` and `fallback_hint_for_error_kind("unexpected_extra_args")` also returns `None`. Fix: appended `\nUsage: claw config [env|hooks|model|plugins|mcp|settings]` to the error format string. Integration test `config_extra_args_have_non_null_hint_791` covers both paths. 51 CLI contract tests pass. [SCOPE: claw-code] Source: Jobdori config-arg probe on `9968a27e`, 2026-05-27. + +792. **`claw agents list --bogus-flag` and `claw skills list --bogus-flag` silently returned `status:"ok" count:0` instead of an error** — dogfooded 2026-05-27 on `93a159dc`. The `list ` arm in both handlers treated flag-shaped tokens (`--something`) as name substring filters. Since no agents/skills have `--bogus` in their name, result was empty success list — a false positive that masks typos and unknown flags. Fix: added flag-prefix guard at the top of both `list ` arms in `commands/src/lib.rs`; detected filter tokens starting with `-` return `unknown_option` + usage hint. Two new integration tests `agents_list_flag_shaped_filter_returns_unknown_option_792`, `skills_list_flag_shaped_filter_returns_unknown_option_792`. 53 CLI contract tests pass. [SCOPE: claw-code] Source: Jobdori agents/skills list probe on `93a159dc`, 2026-05-27. diff --git a/rust/crates/commands/src/lib.rs b/rust/crates/commands/src/lib.rs index 58a27e09..08dc9f07 100644 --- a/rust/crates/commands/src/lib.rs +++ b/rust/crates/commands/src/lib.rs @@ -2429,6 +2429,18 @@ pub fn handle_agents_slash_command_json(args: Option<&str>, cwd: &Path) -> std:: } Some(args) if args.starts_with("list ") => { let filter = args["list ".len()..].trim().to_lowercase(); + // #792: unknown flags (--something) silently became filter strings, returning + // empty success list instead of an error. Detect and reject flag-shaped tokens. + if filter.starts_with('-') { + return Ok(serde_json::json!({ + "kind": "agents", + "action": "list", + "status": "error", + "error_kind": "unknown_option", + "unexpected": filter, + "hint": "Usage: claw agents list []\nFilters are name substrings, not flags.", + })); + } let roots = discover_definition_roots(cwd, "agents"); let agents = load_agents_from_roots(&roots)?; let filtered: Vec<_> = agents @@ -2582,6 +2594,18 @@ pub fn handle_skills_slash_command_json(args: Option<&str>, cwd: &Path) -> std:: } Some(args) if args.starts_with("list ") => { let filter = args["list ".len()..].trim().to_lowercase(); + // #792: flag-shaped tokens silently became filter strings, returning + // empty success list instead of an error. Detect and reject them. + if filter.starts_with('-') { + return Ok(serde_json::json!({ + "kind": "skills", + "action": "list", + "status": "error", + "error_kind": "unknown_option", + "unexpected": filter, + "hint": "Usage: claw skills list []\nFilters are name substrings, not flags.", + })); + } let roots = discover_skill_roots(cwd); let skills = load_skills_from_roots(&roots)?; let filtered: Vec<_> = skills diff --git a/rust/crates/rusty-claude-cli/tests/output_format_contract.rs b/rust/crates/rusty-claude-cli/tests/output_format_contract.rs index 79d43b3f..25caecd9 100644 --- a/rust/crates/rusty-claude-cli/tests/output_format_contract.rs +++ b/rust/crates/rusty-claude-cli/tests/output_format_contract.rs @@ -2971,3 +2971,95 @@ fn config_extra_args_have_non_null_hint_791() { "config set extra arg must have non-null hint (#791)" ); } + +#[test] +fn agents_list_flag_shaped_filter_returns_unknown_option_792() { + // #792: `claw --output-format json agents list --bogus-flag` silently returned + // status:"ok" count:0 instead of an error. The list filter arm in + // handle_agents_slash_command_json treated "--bogus-flag" as a name substring + // filter (no agents match), producing a false-positive empty success result. + // Fix: detect filter tokens starting with "-" and return unknown_option + hint. + let root = unique_temp_dir("agents-list-flag-792"); + fs::create_dir_all(&root).expect("temp dir"); + std::process::Command::new("git") + .args(["init", "-q"]) + .current_dir(&root) + .output() + .ok(); + + let output = run_claw( + &root, + &[ + "--output-format", + "json", + "agents", + "list", + "--unknown-flag", + ], + &[], + ); + assert!( + !output.status.success(), + "agents list --unknown-flag must exit non-zero (#792)" + ); + let stdout = String::from_utf8_lossy(&output.stdout); + let j: serde_json::Value = serde_json::from_str(stdout.trim()) + .expect("agents list flag-filter should emit valid JSON"); + assert_eq!( + j["error_kind"], "unknown_option", + "agents list flag-shaped filter must return unknown_option, got {:?}", + j["error_kind"] + ); + assert_eq!(j["status"], "error"); + let h = j["hint"] + .as_str() + .expect("unknown_option must have hint (#792)"); + assert!( + h.contains("claw agents list") || h.contains("filter"), + "hint should reference correct usage, got: {h:?}" + ); +} + +#[test] +fn skills_list_flag_shaped_filter_returns_unknown_option_792() { + // #792: same gap as agents — `claw skills list --bogus-flag` returned success + // with empty list instead of unknown_option error. + let root = unique_temp_dir("skills-list-flag-792"); + fs::create_dir_all(&root).expect("temp dir"); + std::process::Command::new("git") + .args(["init", "-q"]) + .current_dir(&root) + .output() + .ok(); + + let output = run_claw( + &root, + &[ + "--output-format", + "json", + "skills", + "list", + "--unknown-flag", + ], + &[], + ); + assert!( + !output.status.success(), + "skills list --unknown-flag must exit non-zero (#792)" + ); + let stdout = String::from_utf8_lossy(&output.stdout); + let j: serde_json::Value = serde_json::from_str(stdout.trim()) + .expect("skills list flag-filter should emit valid JSON"); + assert_eq!( + j["error_kind"], "unknown_option", + "skills list flag-shaped filter must return unknown_option, got {:?}", + j["error_kind"] + ); + assert_eq!(j["status"], "error"); + assert!( + j["hint"] + .as_str() + .is_some_and(|h| h.contains("claw skills list") || h.contains("filter")), + "hint should reference correct usage (#792)" + ); +}