mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-06 08:04:50 +08:00
Keep doctor and local help paths shell-native
Promote doctor into a real top-level CLI action, reuse the same local report for resumed and REPL doctor invocations, and intercept doctor/status/sandbox help flags before prompt-mode dispatch. The parser change also closes the help fallthrough that previously wandered into runtime startup for local-info commands. Constraint: Preserve prompt shorthand for normal multi-word text input while fixing exact local subcommand help paths Rejected: Route \7[1G[2K[m⠋ 🦀 Thinking...[0m8[1G[2K[m✘ ❌ Request failed [0m through prompt/slash guidance | still shells out through the wrong surface and keeps health checks hidden Rejected: Reuse the status report as doctor output | status does not explain auth/config health or expose a dedicated diagnostic summary Confidence: high Scope-risk: narrow Directive: Keep doctor local-only unless an explicit network probe is intentionally added and separately tested Tested: cargo build -p rusty-claude-cli; cargo test -p rusty-claude-cli; cargo run -p rusty-claude-cli -- doctor --help; CLAW_CONFIG_HOME=/tmp/tmp.7pm9SVzOPN ANTHROPIC_API_KEY= ANTHROPIC_AUTH_TOKEN= cargo run -p rusty-claude-cli -- doctor Not-tested: direct /doctor outside the REPL remains interactive-only
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -161,37 +161,77 @@ fn config_command_loads_defaults_from_standard_config_locations() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_help_flags_render_usage_instead_of_falling_through() {
|
||||
let temp_dir = unique_temp_dir("nested-help");
|
||||
fs::create_dir_all(&temp_dir).expect("temp dir should exist");
|
||||
fn doctor_command_runs_as_a_local_shell_entrypoint() {
|
||||
// given
|
||||
let temp_dir = unique_temp_dir("doctor-entrypoint");
|
||||
let config_home = temp_dir.join("home").join(".claw");
|
||||
fs::create_dir_all(&config_home).expect("config home should exist");
|
||||
|
||||
let mcp_output = command_in(&temp_dir)
|
||||
.args(["mcp", "show", "--help"])
|
||||
// when
|
||||
let output = command_in(&temp_dir)
|
||||
.env("CLAW_CONFIG_HOME", &config_home)
|
||||
.env_remove("ANTHROPIC_API_KEY")
|
||||
.env_remove("ANTHROPIC_AUTH_TOKEN")
|
||||
.env("ANTHROPIC_BASE_URL", "http://127.0.0.1:9")
|
||||
.arg("doctor")
|
||||
.output()
|
||||
.expect("claw should launch");
|
||||
assert_success(&mcp_output);
|
||||
let mcp_stdout = String::from_utf8(mcp_output.stdout).expect("stdout should be utf8");
|
||||
assert!(mcp_stdout.contains("Usage /mcp [list|show <server>|help]"));
|
||||
assert!(mcp_stdout.contains("Unexpected show"));
|
||||
assert!(!mcp_stdout.contains("server `--help` is not configured"));
|
||||
.expect("claw doctor should launch");
|
||||
|
||||
let skills_output = command_in(&temp_dir)
|
||||
.args(["skills", "install", "--help"])
|
||||
.output()
|
||||
.expect("claw should launch");
|
||||
assert_success(&skills_output);
|
||||
let skills_stdout = String::from_utf8(skills_output.stdout).expect("stdout should be utf8");
|
||||
assert!(skills_stdout.contains("Usage /skills [list|install <path>|help]"));
|
||||
assert!(skills_stdout.contains("Unexpected install"));
|
||||
// then
|
||||
assert_success(&output);
|
||||
let stdout = String::from_utf8(output.stdout).expect("stdout should be utf8");
|
||||
assert!(stdout.contains("Doctor"));
|
||||
assert!(stdout.contains("Auth"));
|
||||
assert!(stdout.contains("Config"));
|
||||
assert!(stdout.contains("Workspace"));
|
||||
assert!(stdout.contains("Sandbox"));
|
||||
assert!(!stdout.contains("Thinking"));
|
||||
|
||||
let unknown_output = command_in(&temp_dir)
|
||||
.args(["mcp", "inspect", "--help"])
|
||||
fs::remove_dir_all(temp_dir).expect("cleanup temp dir");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn local_subcommand_help_does_not_fall_through_to_runtime_or_provider_calls() {
|
||||
// given
|
||||
let temp_dir = unique_temp_dir("subcommand-help");
|
||||
let config_home = temp_dir.join("home").join(".claw");
|
||||
fs::create_dir_all(&config_home).expect("config home should exist");
|
||||
|
||||
// when
|
||||
let doctor_help = command_in(&temp_dir)
|
||||
.env("CLAW_CONFIG_HOME", &config_home)
|
||||
.env_remove("ANTHROPIC_API_KEY")
|
||||
.env_remove("ANTHROPIC_AUTH_TOKEN")
|
||||
.env("ANTHROPIC_BASE_URL", "http://127.0.0.1:9")
|
||||
.args(["doctor", "--help"])
|
||||
.output()
|
||||
.expect("claw should launch");
|
||||
assert_success(&unknown_output);
|
||||
let unknown_stdout = String::from_utf8(unknown_output.stdout).expect("stdout should be utf8");
|
||||
assert!(unknown_stdout.contains("Usage /mcp [list|show <server>|help]"));
|
||||
assert!(unknown_stdout.contains("Unexpected inspect"));
|
||||
.expect("doctor help should launch");
|
||||
let status_help = command_in(&temp_dir)
|
||||
.env("CLAW_CONFIG_HOME", &config_home)
|
||||
.env_remove("ANTHROPIC_API_KEY")
|
||||
.env_remove("ANTHROPIC_AUTH_TOKEN")
|
||||
.env("ANTHROPIC_BASE_URL", "http://127.0.0.1:9")
|
||||
.args(["status", "--help"])
|
||||
.output()
|
||||
.expect("status help should launch");
|
||||
|
||||
// then
|
||||
assert_success(&doctor_help);
|
||||
let doctor_stdout = String::from_utf8(doctor_help.stdout).expect("stdout should be utf8");
|
||||
assert!(doctor_stdout.contains("Usage claw doctor"));
|
||||
assert!(doctor_stdout.contains("local-only health report"));
|
||||
assert!(!doctor_stdout.contains("Thinking"));
|
||||
|
||||
assert_success(&status_help);
|
||||
let status_stdout = String::from_utf8(status_help.stdout).expect("stdout should be utf8");
|
||||
assert!(status_stdout.contains("Usage claw status"));
|
||||
assert!(status_stdout.contains("local workspace snapshot"));
|
||||
assert!(!status_stdout.contains("Thinking"));
|
||||
|
||||
let doctor_stderr = String::from_utf8(doctor_help.stderr).expect("stderr should be utf8");
|
||||
let status_stderr = String::from_utf8(status_help.stderr).expect("stderr should be utf8");
|
||||
assert!(!doctor_stderr.contains("auth_unavailable"));
|
||||
assert!(!status_stderr.contains("auth_unavailable"));
|
||||
|
||||
fs::remove_dir_all(temp_dir).expect("cleanup temp dir");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user