fix: update meta service to use new plugin configuration approach
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -26,44 +26,68 @@ impl MetaService {
|
|||||||
|
|
||||||
debug!("META_SERVICE: Meta plugin types: {:?}", meta_plugin_types);
|
debug!("META_SERVICE: Meta plugin types: {:?}", meta_plugin_types);
|
||||||
|
|
||||||
let mut meta_plugins: Vec<Box<dyn MetaPlugin>> = meta_plugin_types
|
// Create plugins with their configuration
|
||||||
|
let meta_plugins: Vec<Box<dyn MetaPlugin>> = meta_plugin_types
|
||||||
.iter()
|
.iter()
|
||||||
.map(|meta_plugin_type| {
|
.map(|meta_plugin_type| {
|
||||||
debug!("META_SERVICE: Creating plugin: {:?}", meta_plugin_type);
|
debug!("META_SERVICE: Creating plugin: {:?}", meta_plugin_type);
|
||||||
get_meta_plugin(meta_plugin_type.clone())
|
|
||||||
|
// Get the plugin name to find its configuration
|
||||||
|
let plugin_name = match meta_plugin_type {
|
||||||
|
MetaPluginType::FileMagic => "file_magic",
|
||||||
|
MetaPluginType::FileMime => "file_mime",
|
||||||
|
MetaPluginType::FileEncoding => "file_encoding",
|
||||||
|
MetaPluginType::MagicFile => "magic_file",
|
||||||
|
MetaPluginType::LineCount => "line_count",
|
||||||
|
MetaPluginType::WordCount => "word_count",
|
||||||
|
MetaPluginType::Cwd => "cwd",
|
||||||
|
MetaPluginType::Binary => "binary",
|
||||||
|
MetaPluginType::Text => "text",
|
||||||
|
MetaPluginType::User => "user",
|
||||||
|
MetaPluginType::Shell => "shell",
|
||||||
|
MetaPluginType::ShellPid => "shell_pid",
|
||||||
|
MetaPluginType::KeepPid => "keep_pid",
|
||||||
|
MetaPluginType::Digest => "digest",
|
||||||
|
MetaPluginType::ReadTime => "read_time",
|
||||||
|
MetaPluginType::ReadRate => "read_rate",
|
||||||
|
MetaPluginType::Hostname => "hostname",
|
||||||
|
};
|
||||||
|
|
||||||
|
// Get options and outputs from settings
|
||||||
|
let (options, outputs) = if let Some(meta_plugin_configs) = &settings.meta_plugins {
|
||||||
|
if let Some(config) = meta_plugin_configs.iter().find(|c| c.name == plugin_name) {
|
||||||
|
// Convert options and outputs to the appropriate types
|
||||||
|
let options: std::collections::HashMap<String, serde_yaml::Value> = config
|
||||||
|
.options
|
||||||
|
.iter()
|
||||||
|
.map(|(k, v)| (k.clone(), serde_yaml::Value::String(v.clone())))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let outputs: std::collections::HashMap<String, serde_yaml::Value> = config
|
||||||
|
.outputs
|
||||||
|
.iter()
|
||||||
|
.map(|(k, v)| (k.clone(), serde_yaml::Value::String(v.clone())))
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
(Some(options), Some(outputs))
|
||||||
|
} else {
|
||||||
|
(None, None)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(None, None)
|
||||||
|
};
|
||||||
|
|
||||||
|
get_meta_plugin_with_config(meta_plugin_type.clone(), options, outputs)
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
if let Some(meta_plugin_configs) = &settings.meta_plugins {
|
// Filter out unsupported plugins
|
||||||
for meta_plugin in meta_plugins.iter_mut() {
|
|
||||||
let plugin_name = meta_plugin.meta_name();
|
|
||||||
if let Some(config) = meta_plugin_configs.iter().find(|c| c.name == plugin_name) {
|
|
||||||
let mut configured_outputs = meta_plugin.outputs().clone();
|
|
||||||
for (key, value) in &config.outputs {
|
|
||||||
configured_outputs.insert(key.clone(), serde_yaml::Value::String(value.clone()));
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut configured_options = meta_plugin.default_options();
|
|
||||||
for (key, value) in &config.options {
|
|
||||||
configured_options.insert(key.clone(), value.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Err(e) = meta_plugin.configure_outputs(&configured_outputs) {
|
|
||||||
log::warn!("META_SERVICE: Failed to configure outputs for meta plugin '{}': {}", plugin_name, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Err(e) = meta_plugin.configure_options(&configured_options) {
|
|
||||||
log::warn!(
|
|
||||||
"META_SERVICE: Failed to configure options for meta plugin '{}': {}",
|
|
||||||
plugin_name, e
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let original_len = meta_plugins.len();
|
let original_len = meta_plugins.len();
|
||||||
meta_plugins.retain(|meta_plugin| meta_plugin.is_supported());
|
let meta_plugins: Vec<Box<dyn MetaPlugin>> = meta_plugins
|
||||||
|
.into_iter()
|
||||||
|
.filter(|meta_plugin| meta_plugin.is_supported())
|
||||||
|
.collect();
|
||||||
|
|
||||||
if meta_plugins.len() < original_len {
|
if meta_plugins.len() < original_len {
|
||||||
log::warn!("META_SERVICE: Some meta plugins are enabled but not supported on this system");
|
log::warn!("META_SERVICE: Some meta plugins are enabled but not supported on this system");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user