Filter stub commands from resume-safe help

Keep claw --help's resume-safe slash command summary aligned with the interactive command list by filtering STUB_COMMANDS and adding regression coverage.
This commit is contained in:
Yeachan-Heo
2026-04-29 03:31:34 +00:00
parent cb56dc12ab
commit 1376d92064
3 changed files with 39 additions and 1 deletions

View File

@@ -8952,6 +8952,7 @@ fn print_help_to(out: &mut impl Write) -> io::Result<()> {
writeln!(out)?;
let resume_commands = resume_supported_slash_commands()
.into_iter()
.filter(|spec| !STUB_COMMANDS.contains(&spec.name))
.map(|spec| match spec.argument_hint {
Some(argument_hint) => format!("/{} {}", spec.name, argument_hint),
None => format!("/{}", spec.name),
@@ -13000,6 +13001,32 @@ UU conflicted.rs",
);
}
}
#[test]
fn stub_commands_absent_from_resume_safe_help() {
let mut help = Vec::new();
print_help_to(&mut help).expect("help should render");
let help = String::from_utf8(help).expect("help should be utf8");
let resume_line = help
.lines()
.find(|line| line.starts_with("Resume-safe commands:"))
.expect("resume-safe command line should exist");
let resume_roots = resume_line
.trim_start_matches("Resume-safe commands:")
.split(',')
.filter_map(|entry| entry.trim().strip_prefix('/'))
.filter_map(|entry| entry.split_whitespace().next())
.collect::<Vec<_>>();
for stub in STUB_COMMANDS {
assert!(
!resume_roots.contains(stub),
"stub command /{stub} should not appear in resume-safe command list"
);
}
assert!(resume_roots.contains(&"status"));
}
}
fn write_mcp_server_fixture(script_path: &Path) {