feat: add options to meta plugins

Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-19 14:18:59 -03:00
parent 107a1f3eb4
commit a3494ee831
6 changed files with 173 additions and 0 deletions

View File

@@ -104,6 +104,10 @@ pub trait MetaPlugin {
fn outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value>;
fn outputs_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value>;
// Access to options mapping
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value>;
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value>;
// Get the default output names this plugin can produce
fn default_outputs(&self) -> Vec<String> {
// Default implementation returns empty - plugins should override this

View File

@@ -12,6 +12,7 @@ pub struct BinaryMetaPlugin {
is_saved: bool,
item_id: Option<i64>,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl BinaryMetaPlugin {
@@ -50,6 +51,7 @@ impl BinaryMetaPlugin {
is_saved: false,
item_id: None,
outputs: final_outputs,
options: final_options,
}
}
@@ -140,4 +142,12 @@ impl MetaPlugin for BinaryMetaPlugin {
options.insert("max_buffer_size".to_string(), serde_yaml::Value::Number(4096.into()));
options
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}

View File

@@ -11,6 +11,7 @@ pub struct DigestSha256MetaPlugin {
meta_name: String,
item_id: Option<i64>,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl DigestSha256MetaPlugin {
@@ -35,6 +36,7 @@ impl DigestSha256MetaPlugin {
meta_name: "digest_sha256".to_string(),
item_id: None,
outputs: final_outputs,
options: final_options,
}
}
@@ -88,6 +90,14 @@ impl MetaPlugin for DigestSha256MetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
@@ -96,6 +106,7 @@ pub struct ReadTimeMetaPlugin {
start_time: Option<Instant>,
meta_name: String,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl ReadTimeMetaPlugin {
@@ -119,6 +130,7 @@ impl ReadTimeMetaPlugin {
start_time: None,
meta_name: "read_time".to_string(),
outputs: final_outputs,
options: final_options,
}
}
@@ -161,6 +173,14 @@ impl MetaPlugin for ReadTimeMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
#[derive(Debug, Clone, Default)]
@@ -169,6 +189,7 @@ pub struct ReadRateMetaPlugin {
bytes_read: u64,
meta_name: String,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl ReadRateMetaPlugin {
@@ -193,6 +214,7 @@ impl ReadRateMetaPlugin {
bytes_read: 0,
meta_name: "read_rate".to_string(),
outputs: final_outputs,
options: final_options,
}
}
@@ -236,4 +258,12 @@ impl MetaPlugin for ReadRateMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}

View File

@@ -13,6 +13,7 @@ pub struct MagicFileMetaPlugin {
item_id: Option<i64>,
cookie: Option<Cookie>,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl MagicFileMetaPlugin {
@@ -51,6 +52,7 @@ impl MagicFileMetaPlugin {
item_id: None,
cookie: None,
outputs: final_outputs,
options: final_options,
}
}
@@ -186,5 +188,13 @@ impl MetaPlugin for MagicFileMetaPlugin {
options.insert("max_buffer_size".to_string(), serde_yaml::Value::Number(4096.into()));
options
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}

View File

@@ -18,6 +18,7 @@ pub struct MetaPluginProgram {
item_id: Option<i64>,
result: Option<String>,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl std::fmt::Debug for MetaPluginProgram {
@@ -31,6 +32,7 @@ impl std::fmt::Debug for MetaPluginProgram {
.field("process", &self.process)
.field("writer", &"Box<dyn Write>")
.field("outputs", &self.outputs)
.field("options", &self.options)
.finish()
}
}
@@ -56,6 +58,14 @@ impl MetaPluginProgram {
}
}
// Start with default options
let mut final_options = std::collections::HashMap::new();
if let Some(opts) = _options {
for (key, value) in opts {
final_options.insert(key, value);
}
}
MetaPluginProgram {
program: program_path.map_or_else(|_| program.to_string(), |p| p.to_string_lossy().to_string()),
args: args.iter().map(|s| s.to_string()).collect(),
@@ -67,6 +77,7 @@ impl MetaPluginProgram {
item_id: None,
result: None,
outputs: final_outputs,
options: final_options,
}
}
@@ -187,4 +198,12 @@ impl MetaPlugin for MetaPluginProgram {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}

View File

@@ -14,6 +14,7 @@ pub struct CwdMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl CwdMetaPlugin {
@@ -37,6 +38,7 @@ impl CwdMetaPlugin {
meta_name: "cwd".to_string(),
is_saved: false,
outputs: final_outputs,
options: final_options,
}
}
@@ -89,6 +91,14 @@ impl MetaPlugin for CwdMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
#[derive(Debug, Clone, Default)]
@@ -96,6 +106,7 @@ pub struct UidMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl UidMetaPlugin {
@@ -119,6 +130,7 @@ impl UidMetaPlugin {
meta_name: "uid".to_string(),
is_saved: false,
outputs: final_outputs,
options: final_options,
}
}
@@ -167,6 +179,14 @@ impl MetaPlugin for UidMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
#[derive(Debug, Clone, Default)]
@@ -174,6 +194,7 @@ pub struct UserMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl UserMetaPlugin {
@@ -197,6 +218,7 @@ impl UserMetaPlugin {
meta_name: "user".to_string(),
is_saved: false,
outputs: final_outputs,
options: final_options,
}
}
@@ -248,6 +270,14 @@ impl MetaPlugin for UserMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
#[derive(Debug, Clone, Default)]
@@ -255,6 +285,7 @@ pub struct GidMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl GidMetaPlugin {
@@ -278,6 +309,7 @@ impl GidMetaPlugin {
meta_name: "gid".to_string(),
is_saved: false,
outputs: final_outputs,
options: final_options,
}
}
@@ -326,6 +358,14 @@ impl MetaPlugin for GidMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
#[derive(Debug, Clone, Default)]
@@ -333,6 +373,7 @@ pub struct GroupMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl GroupMetaPlugin {
@@ -356,6 +397,7 @@ impl GroupMetaPlugin {
meta_name: "group".to_string(),
is_saved: false,
outputs: final_outputs,
options: final_options,
}
}
@@ -407,6 +449,14 @@ impl MetaPlugin for GroupMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
#[derive(Debug, Clone, Default)]
@@ -414,6 +464,7 @@ pub struct ShellMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl ShellMetaPlugin {
@@ -437,6 +488,7 @@ impl ShellMetaPlugin {
meta_name: "shell".to_string(),
is_saved: false,
outputs: final_outputs,
options: final_options,
}
}
@@ -488,6 +540,14 @@ impl MetaPlugin for ShellMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
#[derive(Debug, Clone, Default)]
@@ -495,6 +555,7 @@ pub struct ShellPidMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl ShellPidMetaPlugin {
@@ -518,6 +579,7 @@ impl ShellPidMetaPlugin {
meta_name: "shell_pid".to_string(),
is_saved: false,
outputs: final_outputs,
options: final_options,
}
}
@@ -569,6 +631,14 @@ impl MetaPlugin for ShellPidMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
#[derive(Debug, Clone, Default)]
@@ -576,6 +646,7 @@ pub struct KeepPidMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl KeepPidMetaPlugin {
@@ -599,6 +670,7 @@ impl KeepPidMetaPlugin {
meta_name: "keep_pid".to_string(),
is_saved: false,
outputs: final_outputs,
options: final_options,
}
}
@@ -647,6 +719,14 @@ impl MetaPlugin for KeepPidMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
#[derive(Debug, Clone, Default)]
@@ -654,6 +734,7 @@ pub struct HostnameMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl HostnameMetaPlugin {
@@ -677,6 +758,7 @@ impl HostnameMetaPlugin {
meta_name: "hostname".to_string(),
is_saved: false,
outputs: final_outputs,
options: final_options,
}
}
@@ -728,6 +810,14 @@ impl MetaPlugin for HostnameMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}
#[derive(Debug, Clone, Default)]
@@ -735,6 +825,7 @@ pub struct FullHostnameMetaPlugin {
meta_name: String,
is_saved: bool,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
options: std::collections::HashMap<String, serde_yaml::Value>,
}
impl FullHostnameMetaPlugin {
@@ -758,6 +849,7 @@ impl FullHostnameMetaPlugin {
meta_name: "full_hostname".to_string(),
is_saved: false,
outputs: final_outputs,
options: final_options,
}
}
@@ -827,4 +919,12 @@ impl MetaPlugin for FullHostnameMetaPlugin {
fn default_options(&self) -> std::collections::HashMap<String, serde_yaml::Value> {
std::collections::HashMap::new()
}
fn options(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.options
}
fn options_mut(&mut self) -> &mut std::collections::HashMap<String, serde_yaml::Value> {
&mut self.options
}
}