Resolve claw-code main merge conflicts

This commit is contained in:
Yeachan-Heo
2026-04-06 05:46:52 +00:00
parent 01b263c838
commit f9cb42fb44
5 changed files with 939 additions and 22 deletions

View File

@@ -128,6 +128,11 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
args,
output_format,
} => LiveCli::print_skills(args.as_deref(), output_format)?,
CliAction::Plugins {
action,
target,
output_format,
} => LiveCli::print_plugins(action.as_deref(), target.as_deref(), output_format)?,
CliAction::PrintSystemPrompt {
cwd,
date,
@@ -188,6 +193,11 @@ enum CliAction {
args: Option<String>,
output_format: CliOutputFormat,
},
Plugins {
action: Option<String>,
target: Option<String>,
output_format: CliOutputFormat,
},
PrintSystemPrompt {
cwd: PathBuf,
date: String,
@@ -619,6 +629,10 @@ fn format_unknown_direct_slash_command(name: &str) -> String {
message.push('\n');
message.push_str(&suggestions);
}
if let Some(note) = omc_compatibility_note_for_unknown_slash_command(name) {
message.push('\n');
message.push_str(note);
}
message.push_str("\nRun `claw --help` for CLI usage, or start `claw` and use /help.");
message
}
@@ -630,10 +644,21 @@ fn format_unknown_slash_command(name: &str) -> String {
message.push('\n');
message.push_str(&suggestions);
}
if let Some(note) = omc_compatibility_note_for_unknown_slash_command(name) {
message.push('\n');
message.push_str(note);
}
message.push_str("\n Help /help lists available slash commands");
message
}
fn omc_compatibility_note_for_unknown_slash_command(name: &str) -> Option<&'static str> {
name.starts_with("oh-my-claudecode:")
.then_some(
"Compatibility note: `/oh-my-claudecode:*` is a Claude Code/OMC plugin command. `claw` does not yet load plugin slash commands, Claude statusline stdin, or OMC session hooks.",
)
}
fn render_suggestion_line(label: &str, suggestions: &[String]) -> Option<String> {
(!suggestions.is_empty()).then(|| format!(" {label:<16} {}", suggestions.join(", "),))
}
@@ -1885,14 +1910,18 @@ impl GitWorkspaceSummary {
#[cfg(test)]
fn format_unknown_slash_command_message(name: &str) -> String {
let suggestions = suggest_slash_commands(name);
if suggestions.is_empty() {
format!("unknown slash command: /{name}. Use /help to list available commands.")
} else {
format!(
"unknown slash command: /{name}. Did you mean {}? Use /help to list available commands.",
suggestions.join(", ")
)
let mut message = format!("unknown slash command: /{name}.");
if !suggestions.is_empty() {
message.push_str(" Did you mean ");
message.push_str(&suggestions.join(", "));
message.push('?');
}
if let Some(note) = omc_compatibility_note_for_unknown_slash_command(name) {
message.push(' ');
message.push_str(note);
}
message.push_str(" Use /help to list available commands.");
message
}
fn format_model_report(model: &str, message_count: usize, turns: u32) -> String {
@@ -3569,6 +3598,32 @@ impl LiveCli {
Ok(())
}
fn print_plugins(
action: Option<&str>,
target: Option<&str>,
output_format: CliOutputFormat,
) -> Result<(), Box<dyn std::error::Error>> {
let cwd = env::current_dir()?;
let loader = ConfigLoader::default_for(&cwd);
let runtime_config = loader.load()?;
let mut manager = build_plugin_manager(&cwd, &loader, &runtime_config);
let result = handle_plugins_slash_command(action, target, &mut manager)?;
match output_format {
CliOutputFormat::Text => println!("{}", result.message),
CliOutputFormat::Json => println!(
"{}",
serde_json::to_string_pretty(&json!({
"kind": "plugin",
"action": action.unwrap_or("list"),
"target": target,
"message": result.message,
"reload_runtime": result.reload_runtime,
}))?
),
}
Ok(())
}
fn print_diff() -> Result<(), Box<dyn std::error::Error>> {
println!("{}", render_diff_report()?);
Ok(())
@@ -7449,6 +7504,13 @@ mod tests {
output_format: CliOutputFormat::Text,
}
);
assert_eq!(
parse_args(&["/skill".to_string()]).expect("/skill should parse"),
CliAction::Skills {
args: None,
output_format: CliOutputFormat::Text,
}
);
assert_eq!(
parse_args(&["/skills".to_string(), "help".to_string()])
.expect("/skills help should parse"),
@@ -7457,6 +7519,14 @@ mod tests {
output_format: CliOutputFormat::Text,
}
);
assert_eq!(
parse_args(&["/skill".to_string(), "list".to_string()])
.expect("/skill list should parse"),
CliAction::Skills {
args: Some("list".to_string()),
output_format: CliOutputFormat::Text,
}
);
assert_eq!(
parse_args(&[
"/skills".to_string(),
@@ -7515,6 +7585,16 @@ mod tests {
assert!(report.contains("Use /help"));
}
#[test]
fn formats_namespaced_omc_slash_command_with_contract_guidance() {
let report = format_unknown_slash_command_message("oh-my-claudecode:hud");
assert!(report.contains("unknown slash command: /oh-my-claudecode:hud"));
assert!(report.contains("Claude Code/OMC plugin command"));
assert!(report.contains("plugin slash commands"));
assert!(report.contains("statusline"));
assert!(report.contains("session hooks"));
}
#[test]
fn parses_resume_flag_with_slash_command() {
let args = vec![
@@ -8312,6 +8392,14 @@ UU conflicted.rs",
assert!(message.contains("/help"));
}
#[test]
fn unknown_omc_slash_command_guidance_explains_runtime_gap() {
let message = format_unknown_slash_command("oh-my-claudecode:hud");
assert!(message.contains("Unknown slash command: /oh-my-claudecode:hud"));
assert!(message.contains("Claude Code/OMC plugin command"));
assert!(message.contains("does not yet load plugin slash commands"));
}
#[test]
fn resume_usage_mentions_latest_shortcut() {
let usage = render_resume_usage();

View File

@@ -104,6 +104,31 @@ fn slash_command_names_match_known_commands_and_suggest_nearby_unknown_ones() {
fs::remove_dir_all(temp_dir).expect("cleanup temp dir");
}
#[test]
fn omc_namespaced_slash_commands_surface_a_targeted_compatibility_hint() {
let temp_dir = unique_temp_dir("slash-dispatch-omc");
fs::create_dir_all(&temp_dir).expect("temp dir should exist");
let output = Command::new(env!("CARGO_BIN_EXE_claw"))
.current_dir(&temp_dir)
.arg("/oh-my-claudecode:hud")
.output()
.expect("claw should launch");
assert!(
!output.status.success(),
"stdout:\n{}\n\nstderr:\n{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
let stderr = String::from_utf8(output.stderr).expect("stderr should be utf8");
assert!(stderr.contains("unknown slash command outside the REPL: /oh-my-claudecode:hud"));
assert!(stderr.contains("Claude Code/OMC plugin command"));
assert!(stderr.contains("does not yet load plugin slash commands"));
fs::remove_dir_all(temp_dir).expect("cleanup temp dir");
}
#[test]
fn config_command_loads_defaults_from_standard_config_locations() {
// given