refactor: consolidate user-related plugins into single UserMetaPlugin

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-26 17:55:18 -03:00
parent bedf000632
commit 77bd3f09a3
3 changed files with 89 additions and 381 deletions

View File

@@ -34,6 +34,8 @@ pub struct MetaPluginResponse {
pub struct BaseMetaPlugin {
pub outputs: std::collections::HashMap<String, serde_yaml::Value>,
pub options: std::collections::HashMap<String, serde_yaml::Value>,
pub meta_name: String,
pub is_finalized: bool,
}
impl BaseMetaPlugin {
@@ -56,6 +58,27 @@ impl BaseMetaPlugin {
pub fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
/// Helper function to initialize plugin options and outputs
pub fn initialize_plugin(
&mut self,
default_outputs: &[&str],
options: Option<std::collections::HashMap<String, serde_yaml::Value>>,
outputs: Option<std::collections::HashMap<String, serde_yaml::Value>>,
) {
// Set default outputs
for output_name in default_outputs {
self.outputs.insert(output_name.to_string(), serde_yaml::Value::String(output_name.to_string()));
}
// Apply provided options and outputs
if let Some(opts) = options {
self.options.extend(opts);
}
if let Some(outs) = outputs {
self.outputs.extend(outs);
}
}
}
impl MetaPlugin for BaseMetaPlugin {
@@ -87,10 +110,7 @@ pub enum MetaPluginType {
WordCount,
Cwd,
Binary,
Uid,
User,
Gid,
Group,
User, // Consolidated Uid, User, Gid, Group into User
Shell,
ShellPid,
KeepPid,
@@ -234,10 +254,10 @@ pub fn get_meta_plugin(meta_plugin_type: MetaPluginType) -> Box<dyn MetaPlugin>
MetaPluginType::WordCount => Box::new(MetaPluginProgram::new_simple("wc", vec!["-w"], "word_count".to_string(), true)),
MetaPluginType::Cwd => Box::new(CwdMetaPlugin::new_simple()),
MetaPluginType::Binary => Box::new(BinaryMetaPlugin::new_simple()),
MetaPluginType::Uid => Box::new(UidMetaPlugin::new_simple()),
MetaPluginType::Uid => Box::new(UserMetaPlugin::new_simple()), // Consolidated into UserMetaPlugin
MetaPluginType::User => Box::new(UserMetaPlugin::new_simple()),
MetaPluginType::Gid => Box::new(GidMetaPlugin::new_simple()),
MetaPluginType::Group => Box::new(GroupMetaPlugin::new_simple()),
MetaPluginType::Gid => Box::new(UserMetaPlugin::new_simple()), // Consolidated into UserMetaPlugin
MetaPluginType::Group => Box::new(UserMetaPlugin::new_simple()), // Consolidated into UserMetaPlugin
MetaPluginType::Shell => Box::new(ShellMetaPlugin::new_simple()),
MetaPluginType::ShellPid => Box::new(ShellPidMetaPlugin::new_simple()),
MetaPluginType::KeepPid => Box::new(KeepPidMetaPlugin::new_simple()),