mirror of
https://github.com/instructkr/claw-code.git
synced 2026-06-07 10:22:45 -04:00
Compare commits
4 Commits
fix/issue-
...
86f45a11ef
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
86f45a11ef | ||
|
|
87b7e74770 | ||
|
|
ae6a207d4e | ||
|
|
efd34c151a |
@@ -7774,3 +7774,8 @@ Original filing (2026-04-18): the session emitted `SessionStart hook (completed)
|
||||
803. **`claw agents list --bogus`, `skills list --bogus`, and `plugins list --bogus` in text mode silently returned empty success** — dogfooded 2026-05-27 on `fcebf644`. The JSON-mode flag guards added in #792/#793 only covered the JSON branch; the text-mode path through `handle_agents_slash_command`, `handle_skills_slash_command`, and `print_plugins` still passed flag-shaped tokens as substring filters. Fix: added flag-prefix guards to all three text-mode list handlers (agents and skills in `commands/src/lib.rs`, plugins in `main.rs print_plugins`). Also removed the now-redundant JSON-only guard from print_plugins (the early guard catches both modes). Updated `plugins_list_flag_shaped_filter_returns_unknown_option_793` test to check stderr. 62 CLI contract tests pass. [SCOPE: claw-code]
|
||||
|
||||
804. **`claw agents show <name> <extra>` and `claw skills show <name> <extra>` in text mode returned wrong `agent_not_found`/silent empty instead of catching extra args** — dogfooded 2026-05-27 on `bad1b97f`. Parity gap with JSON-mode fix #796: the text-mode show handlers in `commands/src/lib.rs` still used single-split `split_once(' ')` without checking for spaces in the extracted name. Fix: added `contains(' ')` guard to both text-mode show arms; extra tokens now return `unexpected extra arguments` with usage hint. 62 CLI contract tests pass. [SCOPE: claw-code]
|
||||
|
||||
805. **`claw skills show <not-found>` in text mode silently returned "No skills found." instead of an error** — dogfooded 2026-05-27 on `2c3c0f60`. The text-mode show handler in `handle_skills_slash_command` returned `render_skills_report(&matched)` with an empty vec instead of checking for empty match and returning an error. JSON mode already returned `skill_not_found` since #706. Fix: added `matched.is_empty()` guard with `skill_not_found` error + `\n` hint suggesting `claw skills list`. 62 CLI contract tests pass. [SCOPE: claw-code]
|
||||
|
||||
806. **`claw plugins show <not-found>` in text mode returned "No plugins installed." instead of an error** — dogfooded 2026-05-27 on `ae6a207d`. The text-mode path in `print_plugins` printed `payload.message` (the full list render) without checking if the requested plugin existed. JSON mode correctly returned `plugin_not_found`. Fix: added show-action filtering + not-found guard to text-mode path; added `starts_with("plugin_not_found:")` arm to classifier for the new error prefix. 63 CLI contract tests pass. [SCOPE: claw-code]
|
||||
807. **`claw models` / `claw model` with `--output-format json` hang with zero stdout instead of returning bounded model discovery/help JSON or a typed unsupported response** — dogfooded 2026-05-27 on `ae6a207` while checking docs/usage model-alias surface after PR #3162 opened. Both `cargo run -q -p rusty-claude-cli -- models --output-format json` and the actual rebuilt `./rust/target/debug/claw models --output-format json` timed out under an 8s outer timeout with stdout `0`; stderr only contained config deprecation warnings. The same silent timeout reproduced for `models help --output-format json`, `model --output-format json`, and `model help --output-format json`. **Required fix shape:** (a) make `model(s)` help/list/discovery commands return bounded stdout JSON without entering prompt/provider/auth paths; (b) if the command is unsupported, return a standard typed JSON error envelope with `error_kind`, non-null `hint`, and `message`; (c) ensure docs model-alias tables and CLI model discovery surfaces do not diverge; (d) add regression coverage for `models --output-format json`, `models help --output-format json`, `model --output-format json`, and `model help --output-format json` proving they do not hang or emit zero-byte stdout. **Why this matters:** model selection is a setup/control-plane surface. If the natural model discovery commands hang silently, claws cannot verify aliases like `qwen-max` / `qwen-plus`, distinguish unsupported command spelling from provider startup, or safely guide users during first-run model setup. Source: gaebal-gajae 13:30/14:00 dogfood probe; GitHub issue creation was blocked by API rate limit, so the finding was recorded directly in ROADMAP.
|
||||
|
||||
@@ -2606,6 +2606,13 @@ pub fn handle_skills_slash_command(args: Option<&str>, cwd: &Path) -> std::io::R
|
||||
.into_iter()
|
||||
.filter(|s| s.name.to_lowercase() == name_raw)
|
||||
.collect();
|
||||
// #805: text-mode show must return an error when skill not found (parity with JSON)
|
||||
if matched.is_empty() {
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::NotFound,
|
||||
format!("skill '{name_raw}' not found\nRun `claw skills list` to see available skills."),
|
||||
));
|
||||
}
|
||||
Ok(render_skills_report(&matched))
|
||||
}
|
||||
Some("install") => Ok(render_skills_usage(Some("install"))),
|
||||
|
||||
@@ -335,7 +335,7 @@ fn classify_error_kind(message: &str) -> &'static str {
|
||||
"unknown_agents_subcommand"
|
||||
} else if message.starts_with("agent not found:") {
|
||||
"agent_not_found"
|
||||
} else if message.contains("is not installed") {
|
||||
} else if message.contains("is not installed") || message.starts_with("plugin_not_found:") {
|
||||
"plugin_not_found"
|
||||
} else if message.contains("plugin source") && message.contains("was not found") {
|
||||
// #794: `plugins install /nonexistent/path` → "plugin source ... was not found"
|
||||
@@ -1225,10 +1225,10 @@ fn parse_args(args: &[String]) -> Result<CliAction, String> {
|
||||
// `git diff`). No session needed to inspect the working tree.
|
||||
"diff" => {
|
||||
if rest.len() > 1 {
|
||||
return Err(format!(
|
||||
"unexpected extra arguments after `claw diff`: {}\nUsage: claw diff",
|
||||
rest[1..].join(" ")
|
||||
));
|
||||
// #3129: keep malformed `diff ... --output-format json` on the
|
||||
// parser/error path, not the prompt/TUI fallback. The newline
|
||||
// before Usage is part of the JSON hint contract.
|
||||
return Err(unexpected_diff_args_error(&rest[1..]));
|
||||
}
|
||||
Ok(CliAction::Diff { output_format })
|
||||
}
|
||||
@@ -1625,6 +1625,13 @@ fn removed_auth_surface_error(command_name: &str) -> String {
|
||||
)
|
||||
}
|
||||
|
||||
fn unexpected_diff_args_error(extra: &[String]) -> String {
|
||||
format!(
|
||||
"unexpected extra arguments after `claw diff`: {}\nUsage: claw diff",
|
||||
extra.join(" ")
|
||||
)
|
||||
}
|
||||
|
||||
fn parse_acp_args(args: &[String], output_format: CliOutputFormat) -> Result<CliAction, String> {
|
||||
match args {
|
||||
[] => Ok(CliAction::Acp { output_format }),
|
||||
@@ -6399,7 +6406,28 @@ impl LiveCli {
|
||||
}
|
||||
let payload = plugins_command_payload_for(&cwd, action, target)?;
|
||||
match output_format {
|
||||
CliOutputFormat::Text => println!("{}", payload.message),
|
||||
CliOutputFormat::Text => {
|
||||
// #806: text-mode show must return error when plugin not found (parity with JSON)
|
||||
let action_str = action.unwrap_or("list");
|
||||
if matches!(action_str, "show" | "info" | "describe") {
|
||||
if let Some(name) = target {
|
||||
let needle = name.to_lowercase();
|
||||
let found = payload.plugins.iter().any(|p| {
|
||||
p.get("id")
|
||||
.and_then(|v| v.as_str())
|
||||
.map(|id| id.to_lowercase() == needle)
|
||||
.unwrap_or(false)
|
||||
});
|
||||
if !found {
|
||||
return Err(format!(
|
||||
"plugin_not_found: plugin '{}' not found\nRun `claw plugins list` to see available plugins.",
|
||||
name
|
||||
).into());
|
||||
}
|
||||
}
|
||||
}
|
||||
println!("{}", payload.message);
|
||||
}
|
||||
CliOutputFormat::Json => {
|
||||
let action_str = action.unwrap_or("list");
|
||||
// #743/#420: plugins help must return a usage envelope matching agents/mcp/skills help shape.
|
||||
|
||||
@@ -1916,36 +1916,95 @@ fn login_logout_removed_subcommands_have_error_kind_and_hint_765() {
|
||||
fn diff_extra_args_have_typed_error_kind_and_hint_766() {
|
||||
// #766: `claw diff --bogus` returned error_kind:"unknown" + hint:null.
|
||||
// `diff` takes no arguments; extra args were unclassified with no remediation.
|
||||
let root = unique_temp_dir("diff-extra-args-766");
|
||||
let root = git_temp_dir("diff-extra-args-766");
|
||||
|
||||
assert_diff_unexpected_extra_args_json(
|
||||
&root,
|
||||
&["--output-format", "json", "diff", "--bogus"],
|
||||
"claw diff --bogus",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diff_trailing_json_after_malformed_args_is_bounded_json_3129() {
|
||||
// #3129: when --output-format json appeared after malformed `diff` args,
|
||||
// the parser fell through to the interactive/prompt path and emitted zero
|
||||
// JSON stdout. These forms must fail before any provider or TUI path starts.
|
||||
let root = git_temp_dir("diff-trailing-json-3129");
|
||||
|
||||
for (args, label) in [
|
||||
(
|
||||
&["diff", "--bogus-flag", "--output-format", "json"][..],
|
||||
"claw diff --bogus-flag --output-format json",
|
||||
),
|
||||
(
|
||||
&["diff", "does-not-exist", "--output-format", "json"][..],
|
||||
"claw diff does-not-exist --output-format json",
|
||||
),
|
||||
(
|
||||
&[
|
||||
"diff",
|
||||
"--cached",
|
||||
"--bogus-flag",
|
||||
"--output-format",
|
||||
"json",
|
||||
][..],
|
||||
"claw diff --cached --bogus-flag --output-format json",
|
||||
),
|
||||
] {
|
||||
assert_diff_unexpected_extra_args_json(&root, args, label);
|
||||
}
|
||||
}
|
||||
|
||||
fn git_temp_dir(prefix: &str) -> PathBuf {
|
||||
let root = unique_temp_dir(prefix);
|
||||
fs::create_dir_all(&root).expect("temp dir should exist");
|
||||
// Need a git repo for diff to parse past arg validation
|
||||
// Need a git repo so `diff` reaches argument validation before git checks.
|
||||
std::process::Command::new("git")
|
||||
.args(["init", "-q"])
|
||||
.current_dir(&root)
|
||||
.output()
|
||||
.ok();
|
||||
.expect("git init should launch");
|
||||
root
|
||||
}
|
||||
|
||||
let output = run_claw(&root, &["--output-format", "json", "diff", "--bogus"], &[]);
|
||||
fn assert_diff_unexpected_extra_args_json(root: &Path, args: &[&str], label: &str) {
|
||||
let output = run_claw(root, args, &[]);
|
||||
assert!(
|
||||
!output.status.success(),
|
||||
"claw diff --bogus should exit non-zero"
|
||||
"{label} should exit non-zero; stdout:\n{}\nstderr:\n{}",
|
||||
String::from_utf8_lossy(&output.stdout),
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
assert!(
|
||||
output.stdout.is_empty(),
|
||||
"{label} should not enter the spinner/prompt path; stdout:\n{}",
|
||||
String::from_utf8_lossy(&output.stdout)
|
||||
);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
let json_line = stderr
|
||||
.lines()
|
||||
.find(|l| l.trim_start().starts_with('{'))
|
||||
.expect("stderr should contain a JSON error envelope");
|
||||
.unwrap_or_else(|| {
|
||||
panic!("{label} stderr should contain a JSON error envelope; stderr:\n{stderr}")
|
||||
});
|
||||
let parsed: serde_json::Value =
|
||||
serde_json::from_str(json_line).expect("error envelope should be valid JSON");
|
||||
|
||||
assert_eq!(
|
||||
parsed["error_kind"], "unexpected_extra_args",
|
||||
"claw diff --bogus must return error_kind:unexpected_extra_args (#766)"
|
||||
"{label} must return error_kind:unexpected_extra_args"
|
||||
);
|
||||
let hint = parsed["hint"].as_str().unwrap_or("");
|
||||
assert!(
|
||||
!hint.is_empty(),
|
||||
"claw diff --bogus must return non-null hint (#766), got: {hint:?}"
|
||||
"{label} must return non-null hint, got: {hint:?}"
|
||||
);
|
||||
assert!(
|
||||
parsed["message"]
|
||||
.as_str()
|
||||
.is_some_and(|message| !message.is_empty()),
|
||||
"{label} must return non-empty message"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user