mirror of
https://github.com/ultraworkers/claw-code.git
synced 2026-05-30 11:45:20 +08:00
Fix skills subcommand JSON help dispatch
This commit is contained in:
parent
e939777f92
commit
003b739db4
@ -2420,6 +2420,13 @@ pub fn handle_skills_slash_command_json(args: Option<&str>, cwd: &Path) -> std::
|
|||||||
pub fn classify_skills_slash_command(args: Option<&str>) -> SkillSlashDispatch {
|
pub fn classify_skills_slash_command(args: Option<&str>) -> SkillSlashDispatch {
|
||||||
match normalize_optional_args(args) {
|
match normalize_optional_args(args) {
|
||||||
None | Some("list" | "help" | "-h" | "--help") => SkillSlashDispatch::Local,
|
None | Some("list" | "help" | "-h" | "--help") => SkillSlashDispatch::Local,
|
||||||
|
Some(args)
|
||||||
|
if args
|
||||||
|
.split_whitespace()
|
||||||
|
.any(|part| matches!(part, "-h" | "--help")) =>
|
||||||
|
{
|
||||||
|
SkillSlashDispatch::Local
|
||||||
|
}
|
||||||
Some(args) if args == "install" || args.starts_with("install ") => {
|
Some(args) if args == "install" || args.starts_with("install ") => {
|
||||||
SkillSlashDispatch::Local
|
SkillSlashDispatch::Local
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10142,6 +10142,47 @@ mod tests {
|
|||||||
allow_broad_cwd: false,
|
allow_broad_cwd: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
assert_eq!(
|
||||||
|
parse_args(&[
|
||||||
|
"skills".to_string(),
|
||||||
|
"list".to_string(),
|
||||||
|
"--help".to_string(),
|
||||||
|
"--output-format".to_string(),
|
||||||
|
"json".to_string(),
|
||||||
|
])
|
||||||
|
.expect("skills list help json should stay local"),
|
||||||
|
CliAction::Skills {
|
||||||
|
args: Some("list --help".to_string()),
|
||||||
|
output_format: CliOutputFormat::Json,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
parse_args(&[
|
||||||
|
"skills".to_string(),
|
||||||
|
"show".to_string(),
|
||||||
|
"--help".to_string(),
|
||||||
|
"--output-format=json".to_string(),
|
||||||
|
])
|
||||||
|
.expect("skills show help json should stay local"),
|
||||||
|
CliAction::Skills {
|
||||||
|
args: Some("show --help".to_string()),
|
||||||
|
output_format: CliOutputFormat::Json,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
parse_args(&[
|
||||||
|
"skills".to_string(),
|
||||||
|
"missing-skill".to_string(),
|
||||||
|
"--help".to_string(),
|
||||||
|
"--output-format".to_string(),
|
||||||
|
"json".to_string(),
|
||||||
|
])
|
||||||
|
.expect("missing skill help json should stay local"),
|
||||||
|
CliAction::Skills {
|
||||||
|
args: Some("missing-skill --help".to_string()),
|
||||||
|
output_format: CliOutputFormat::Json,
|
||||||
|
}
|
||||||
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
parse_args(&["agents".to_string(), "--help".to_string()])
|
parse_args(&["agents".to_string(), "--help".to_string()])
|
||||||
.expect("agents help should parse"),
|
.expect("agents help should parse"),
|
||||||
|
|||||||
@ -64,6 +64,33 @@ fn acp_guidance_emits_json_when_requested() {
|
|||||||
.contains("discoverability alias"));
|
.contains("discoverability alias"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn skills_subcommand_help_json_is_bounded_and_static() {
|
||||||
|
let root = unique_temp_dir("skills-help-json");
|
||||||
|
fs::create_dir_all(&root).expect("temp dir should exist");
|
||||||
|
|
||||||
|
for args in [
|
||||||
|
&["skills", "list", "--help", "--output-format", "json"][..],
|
||||||
|
&["skills", "install", "--help", "--output-format", "json"][..],
|
||||||
|
&["skills", "show", "--help", "--output-format", "json"][..],
|
||||||
|
&[
|
||||||
|
"skills",
|
||||||
|
"missing-skill",
|
||||||
|
"--help",
|
||||||
|
"--output-format",
|
||||||
|
"json",
|
||||||
|
][..],
|
||||||
|
] {
|
||||||
|
let help = assert_json_command(&root, args);
|
||||||
|
assert_eq!(help["kind"], "skills");
|
||||||
|
assert_eq!(help["action"], "help");
|
||||||
|
assert!(help["usage"]["direct_cli"]
|
||||||
|
.as_str()
|
||||||
|
.expect("direct CLI usage")
|
||||||
|
.contains("claw skills"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn inventory_commands_emit_structured_json_when_requested() {
|
fn inventory_commands_emit_structured_json_when_requested() {
|
||||||
let root = unique_temp_dir("inventory-json");
|
let root = unique_temp_dir("inventory-json");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user