feat: add meta plugin configuration support
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -256,6 +256,8 @@ pub trait MetaPlugin where Self: 'static {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_meta_plugin(meta_plugin_type: MetaPluginType) -> Box<dyn MetaPlugin> {
|
pub fn get_meta_plugin(meta_plugin_type: MetaPluginType) -> Box<dyn MetaPlugin> {
|
||||||
|
// For now, use new_simple() which passes None for options and outputs
|
||||||
|
// The calling code should be updated to use a different function that accepts options and outputs
|
||||||
match meta_plugin_type {
|
match meta_plugin_type {
|
||||||
MetaPluginType::FileMagic => Box::new(MetaPluginProgram::new_simple("file", vec!["-bE", "-"], "file_magic".to_string(), true)),
|
MetaPluginType::FileMagic => Box::new(MetaPluginProgram::new_simple("file", vec!["-bE", "-"], "file_magic".to_string(), true)),
|
||||||
MetaPluginType::FileMime => Box::new(MetaPluginProgram::new_simple("file", vec!["-b", "--mime-type", "-"], "file_mime".to_string(), true)),
|
MetaPluginType::FileMime => Box::new(MetaPluginProgram::new_simple("file", vec!["-b", "--mime-type", "-"], "file_mime".to_string(), true)),
|
||||||
@@ -276,3 +278,30 @@ pub fn get_meta_plugin(meta_plugin_type: MetaPluginType) -> Box<dyn MetaPlugin>
|
|||||||
MetaPluginType::Hostname => Box::new(HostnameMetaPlugin::new_simple()),
|
MetaPluginType::Hostname => Box::new(HostnameMetaPlugin::new_simple()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add a new function to create plugins with options and outputs
|
||||||
|
pub fn get_meta_plugin_with_config(
|
||||||
|
meta_plugin_type: MetaPluginType,
|
||||||
|
options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||||
|
outputs: Option<std::collections::HashMap<String, serde_yaml::Value>>,
|
||||||
|
) -> Box<dyn MetaPlugin> {
|
||||||
|
match meta_plugin_type {
|
||||||
|
MetaPluginType::FileMagic => Box::new(MetaPluginProgram::new("file", vec!["-bE", "-"], "file_magic".to_string(), true, options, outputs)),
|
||||||
|
MetaPluginType::FileMime => Box::new(MetaPluginProgram::new("file", vec!["-b", "--mime-type", "-"], "file_mime".to_string(), true, options, outputs)),
|
||||||
|
MetaPluginType::FileEncoding => Box::new(MetaPluginProgram::new("file", vec!["-b", "--mime-encoding", "-"], "file_encoding".to_string(), true, options, outputs)),
|
||||||
|
MetaPluginType::MagicFile => Box::new(MagicFileMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::LineCount => Box::new(MetaPluginProgram::new("wc", vec!["-l"], "line_count".to_string(), true, options, outputs)),
|
||||||
|
MetaPluginType::WordCount => Box::new(MetaPluginProgram::new("wc", vec!["-w"], "word_count".to_string(), true, options, outputs)),
|
||||||
|
MetaPluginType::Cwd => Box::new(CwdMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::Binary => Box::new(BinaryMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::Text => Box::new(TextMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::User => Box::new(UserMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::Shell => Box::new(ShellMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::ShellPid => Box::new(ShellPidMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::KeepPid => Box::new(KeepPidMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::Digest => Box::new(DigestMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::ReadTime => Box::new(ReadTimeMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::ReadRate => Box::new(ReadRateMetaPlugin::new(options, outputs)),
|
||||||
|
MetaPluginType::Hostname => Box::new(HostnameMetaPlugin::new(options, outputs)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -351,8 +351,10 @@ impl ItemService {
|
|||||||
MetaPluginType::Hostname,
|
MetaPluginType::Hostname,
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut plugins: Vec<Box<dyn MetaPlugin>> =
|
let mut plugins: Vec<Box<dyn MetaPlugin>> = plugin_types
|
||||||
plugin_types.iter().map(|p| get_meta_plugin(p.clone())).collect();
|
.iter()
|
||||||
|
.map(|p| get_meta_plugin(p.clone()))
|
||||||
|
.collect();
|
||||||
debug!("ITEM_SERVICE: Created {} meta plugins for MCP item", plugins.len());
|
debug!("ITEM_SERVICE: Created {} meta plugins for MCP item", plugins.len());
|
||||||
|
|
||||||
self.meta_service
|
self.meta_service
|
||||||
|
|||||||
Reference in New Issue
Block a user