From 7bc6dd89a1e57469d48a663227383513e023d228 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 27 Aug 2025 10:48:48 -0300 Subject: [PATCH] fix: update meta service to use new plugin configuration approach Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) --- src/services/meta_service.rs | 86 +++++++++++++++++++++++------------- 1 file changed, 55 insertions(+), 31 deletions(-) diff --git a/src/services/meta_service.rs b/src/services/meta_service.rs index 097e5d9..c2fcd77 100644 --- a/src/services/meta_service.rs +++ b/src/services/meta_service.rs @@ -26,44 +26,68 @@ impl MetaService { debug!("META_SERVICE: Meta plugin types: {:?}", meta_plugin_types); - let mut meta_plugins: Vec> = meta_plugin_types + // Create plugins with their configuration + let meta_plugins: Vec> = meta_plugin_types .iter() .map(|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 = config + .options + .iter() + .map(|(k, v)| (k.clone(), serde_yaml::Value::String(v.clone()))) + .collect(); + + let outputs: std::collections::HashMap = 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(); - if let Some(meta_plugin_configs) = &settings.meta_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 - ); - } - } - } - } - + // Filter out unsupported plugins let original_len = meta_plugins.len(); - meta_plugins.retain(|meta_plugin| meta_plugin.is_supported()); + let meta_plugins: Vec> = meta_plugins + .into_iter() + .filter(|meta_plugin| meta_plugin.is_supported()) + .collect(); + if meta_plugins.len() < original_len { log::warn!("META_SERVICE: Some meta plugins are enabled but not supported on this system"); }