feat: extract meta plugins configured into separate table
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -124,112 +124,109 @@ fn build_config_table(settings: &config::Settings) -> Table {
|
||||
Cell::new(&compression),
|
||||
]));
|
||||
}
|
||||
|
||||
// Add meta plugins information
|
||||
if let Some(meta_plugins) = &settings.meta_plugins {
|
||||
config_table.add_empty_row();
|
||||
config_table.add_row(Row::new(vec![
|
||||
Cell::new("Meta Plugins").with_style(Attr::Bold),
|
||||
Cell::new(""),
|
||||
]));
|
||||
|
||||
for plugin_config in meta_plugins {
|
||||
// Create the plugin to get its default options
|
||||
let meta_plugin_type = match MetaPluginType::from_str(&plugin_config.name) {
|
||||
Ok(plugin_type) => plugin_type,
|
||||
Err(_) => continue,
|
||||
};
|
||||
|
||||
// Get the plugin with no options to see its pure defaults
|
||||
let _default_plugin = get_meta_plugin(
|
||||
meta_plugin_type.clone(),
|
||||
None,
|
||||
None,
|
||||
);
|
||||
|
||||
// Add plugin name
|
||||
config_table.add_row(Row::new(vec![
|
||||
Cell::new(&format!(" {}", plugin_config.name)),
|
||||
Cell::new(""),
|
||||
]));
|
||||
|
||||
// Get the actual plugin with user-provided options to see the merged result
|
||||
// Convert outputs from HashMap<String, String> to HashMap<String, serde_yaml::Value>
|
||||
let outputs_converted: std::collections::HashMap<String, serde_yaml::Value> = plugin_config.outputs
|
||||
.iter()
|
||||
.map(|(k, v)| (k.clone(), serde_yaml::Value::String(v.clone())))
|
||||
.collect();
|
||||
|
||||
// Convert options from HashMap<String, serde_yaml::Value> to the correct type
|
||||
// (they're already in the correct type, so we can use them directly)
|
||||
let options_converted = plugin_config.options.clone();
|
||||
|
||||
let actual_plugin = get_meta_plugin(
|
||||
meta_plugin_type,
|
||||
Some(options_converted),
|
||||
Some(outputs_converted),
|
||||
);
|
||||
|
||||
// Show the merged options
|
||||
let options_str = if actual_plugin.options().is_empty() {
|
||||
"{}".to_string()
|
||||
} else {
|
||||
serde_yaml::to_string(actual_plugin.options())
|
||||
.unwrap_or_else(|_| "Unable to serialize options".to_string())
|
||||
.trim()
|
||||
.to_string()
|
||||
};
|
||||
config_table.add_row(Row::new(vec![
|
||||
Cell::new(" Options"),
|
||||
Cell::new(&options_str),
|
||||
]));
|
||||
|
||||
// Show the merged outputs
|
||||
let outputs_str = if actual_plugin.outputs().is_empty() {
|
||||
"{}".to_string()
|
||||
} else {
|
||||
let mut output_pairs = Vec::new();
|
||||
for (key, value) in actual_plugin.outputs() {
|
||||
// Convert serde_yaml::Value to a string representation
|
||||
let value_str = match value {
|
||||
serde_yaml::Value::String(s) => s.clone(),
|
||||
serde_yaml::Value::Number(n) => n.to_string(),
|
||||
serde_yaml::Value::Bool(b) => b.to_string(),
|
||||
serde_yaml::Value::Null => "null".to_string(),
|
||||
serde_yaml::Value::Sequence(_) => {
|
||||
serde_yaml::to_string(value).unwrap_or_else(|_| "[]".to_string())
|
||||
}
|
||||
serde_yaml::Value::Mapping(_) => {
|
||||
serde_yaml::to_string(value).unwrap_or_else(|_| "{}".to_string())
|
||||
}
|
||||
serde_yaml::Value::Tagged(_) => {
|
||||
serde_yaml::to_string(value).unwrap_or_else(|_| "tagged".to_string())
|
||||
}
|
||||
};
|
||||
// Trim any extra whitespace from the serialized values
|
||||
let value_str = value_str.trim().to_string();
|
||||
if key == &value_str {
|
||||
output_pairs.push(key.clone());
|
||||
} else {
|
||||
output_pairs.push(format!("{}->{}", key, value_str));
|
||||
}
|
||||
}
|
||||
if output_pairs.is_empty() {
|
||||
"{}".to_string()
|
||||
} else {
|
||||
output_pairs.join(", ")
|
||||
}
|
||||
};
|
||||
config_table.add_row(Row::new(vec![
|
||||
Cell::new(" Outputs"),
|
||||
Cell::new(&outputs_str),
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
||||
config_table
|
||||
}
|
||||
|
||||
fn build_meta_plugins_configured_table(settings: &config::Settings) -> Option<Table> {
|
||||
let meta_plugins = settings.meta_plugins.as_ref()?;
|
||||
if meta_plugins.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let mut table = Table::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
table.set_format(get_format_box_chars_no_border_line_separator());
|
||||
} else {
|
||||
table.set_format(*FORMAT_NO_BORDER_LINE_SEPARATOR);
|
||||
}
|
||||
|
||||
table.set_titles(Row::new(vec![
|
||||
Cell::new("Plugin Name").with_style(Attr::Bold),
|
||||
Cell::new("Options").with_style(Attr::Bold),
|
||||
Cell::new("Outputs").with_style(Attr::Bold),
|
||||
]));
|
||||
|
||||
for plugin_config in meta_plugins {
|
||||
// Create the plugin to get its default options
|
||||
let meta_plugin_type = match MetaPluginType::from_str(&plugin_config.name) {
|
||||
Ok(plugin_type) => plugin_type,
|
||||
Err(_) => continue,
|
||||
};
|
||||
|
||||
// Get the actual plugin with user-provided options to see the merged result
|
||||
// Convert outputs from HashMap<String, String> to HashMap<String, serde_yaml::Value>
|
||||
let outputs_converted: std::collections::HashMap<String, serde_yaml::Value> = plugin_config.outputs
|
||||
.iter()
|
||||
.map(|(k, v)| (k.clone(), serde_yaml::Value::String(v.clone())))
|
||||
.collect();
|
||||
|
||||
// Convert options from HashMap<String, serde_yaml::Value> to the correct type
|
||||
let options_converted = plugin_config.options.clone();
|
||||
|
||||
let actual_plugin = get_meta_plugin(
|
||||
meta_plugin_type,
|
||||
Some(options_converted),
|
||||
Some(outputs_converted),
|
||||
);
|
||||
|
||||
// Show the merged options
|
||||
let options_str = if actual_plugin.options().is_empty() {
|
||||
"{}".to_string()
|
||||
} else {
|
||||
serde_yaml::to_string(actual_plugin.options())
|
||||
.unwrap_or_else(|_| "Unable to serialize options".to_string())
|
||||
.trim()
|
||||
.to_string()
|
||||
};
|
||||
|
||||
// Show the merged outputs
|
||||
let outputs_str = if actual_plugin.outputs().is_empty() {
|
||||
"{}".to_string()
|
||||
} else {
|
||||
let mut output_pairs = Vec::new();
|
||||
for (key, value) in actual_plugin.outputs() {
|
||||
// Convert serde_yaml::Value to a string representation
|
||||
let value_str = match value {
|
||||
serde_yaml::Value::String(s) => s.clone(),
|
||||
serde_yaml::Value::Number(n) => n.to_string(),
|
||||
serde_yaml::Value::Bool(b) => b.to_string(),
|
||||
serde_yaml::Value::Null => "null".to_string(),
|
||||
serde_yaml::Value::Sequence(_) => {
|
||||
serde_yaml::to_string(value).unwrap_or_else(|_| "[]".to_string())
|
||||
}
|
||||
serde_yaml::Value::Mapping(_) => {
|
||||
serde_yaml::to_string(value).unwrap_or_else(|_| "{}".to_string())
|
||||
}
|
||||
serde_yaml::Value::Tagged(_) => {
|
||||
serde_yaml::to_string(value).unwrap_or_else(|_| "tagged".to_string())
|
||||
}
|
||||
};
|
||||
// Trim any extra whitespace from the serialized values
|
||||
let value_str = value_str.trim().to_string();
|
||||
if key == &value_str {
|
||||
output_pairs.push(key.clone());
|
||||
} else {
|
||||
output_pairs.push(format!("{}->{}", key, value_str));
|
||||
}
|
||||
}
|
||||
if output_pairs.is_empty() {
|
||||
"{}".to_string()
|
||||
} else {
|
||||
output_pairs.join(", ")
|
||||
}
|
||||
};
|
||||
|
||||
table.add_row(Row::new(vec![
|
||||
Cell::new(&plugin_config.name),
|
||||
Cell::new(&options_str),
|
||||
Cell::new(&outputs_str),
|
||||
]));
|
||||
}
|
||||
|
||||
Some(table)
|
||||
}
|
||||
|
||||
fn build_meta_plugin_table(meta_plugin_info: &Vec<MetaPluginInfo>) -> Table {
|
||||
let mut meta_plugin_table = Table::new();
|
||||
if std::io::stdout().is_terminal() {
|
||||
@@ -308,6 +305,14 @@ pub fn mode_status(
|
||||
println!("CONFIG:");
|
||||
build_config_table(settings).printstd();
|
||||
println!();
|
||||
|
||||
// Print META PLUGINS CONFIGURED if they exist
|
||||
if let Some(meta_plugins_table) = build_meta_plugins_configured_table(settings) {
|
||||
println!("META PLUGINS CONFIGURED:");
|
||||
meta_plugins_table.printstd();
|
||||
println!();
|
||||
}
|
||||
|
||||
println!("PATHS:");
|
||||
build_path_table(&status_info.paths).printstd();
|
||||
println!();
|
||||
|
||||
Reference in New Issue
Block a user