refactor: update meta plugin to use output mappings

Co-authored-by: aider (openai/andrew/openrouter/anthropic/claude-sonnet-4) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-19 12:57:06 -03:00
parent 1659bf20d4
commit 58ecbd63cf
7 changed files with 386 additions and 58 deletions

View File

@@ -11,7 +11,7 @@ pub struct BinaryMetaPlugin {
max_buffer_size: usize,
is_saved: bool,
item_id: Option<i64>,
output_names: std::collections::HashMap<String, String>,
outputs: std::collections::HashMap<String, serde_yaml::Value>,
}
impl BinaryMetaPlugin {
@@ -22,7 +22,7 @@ impl BinaryMetaPlugin {
max_buffer_size: 4096, // 4KB
is_saved: false,
item_id: None,
output_names: std::collections::HashMap::new(),
outputs: std::collections::HashMap::new(),
}
}
@@ -33,7 +33,7 @@ impl BinaryMetaPlugin {
let value = if is_binary_result { "true".to_string() } else { "false".to_string() };
// Save to database immediately using central output handler
let _ = output_metadata(conn, item_id, &self.meta_name, value, &self.output_names);
let _ = self.save_meta(conn, item_id, "binary", value);
self.is_saved = true;
}
@@ -93,8 +93,8 @@ impl MetaPlugin for BinaryMetaPlugin {
if let Some(outputs) = options.get("outputs") {
if let Some(outputs_map) = outputs.as_mapping() {
for (key, value) in outputs_map {
if let (Some(key_str), Some(value_str)) = (key.as_str(), value.as_str()) {
self.output_names.insert(key_str.to_string(), value_str.to_string());
if let Some(key_str) = key.as_str() {
self.outputs.insert(key_str.to_string(), value.clone());
}
}
}
@@ -102,7 +102,11 @@ impl MetaPlugin for BinaryMetaPlugin {
Ok(())
}
fn get_output_name(&self, default_name: &str) -> String {
self.output_names.get(default_name).cloned().unwrap_or_else(|| default_name.to_string())
fn get_outputs(&self) -> &std::collections::HashMap<String, serde_yaml::Value> {
&self.outputs
}
fn set_outputs(&mut self, outputs: std::collections::HashMap<String, serde_yaml::Value>) {
self.outputs = outputs;
}
}