use anyhow::Result;
use serde_json::json;
use std::path::PathBuf;
use crate::spec_ai_core::persistence::Persistence;
#[derive(Clone)]
pub struct PluginContext<'a> {
pub persistence: &'a Persistence,
pub session_id: &'a str,
pub repo_root: &'a PathBuf,
pub mode: BootstrapMode,
}
#[derive(Debug, Clone)]
pub struct PluginOutcome {
pub plugin_name: String,
pub nodes_created: usize,
pub edges_created: usize,
pub root_node_id: Option<i64>, pub phases: Vec<String>,
pub metadata: serde_json::Value,
}
impl PluginOutcome {
pub fn new(plugin_name: impl Into<String>) -> Self {
Self {
plugin_name: plugin_name.into(),
nodes_created: 0,
edges_created: 0,
root_node_id: None,
phases: Vec::new(),
metadata: json!({}),
}
}
}
#[derive(Clone, Copy)]
pub enum BootstrapMode {
Fresh,
Refresh,
}
pub trait BootstrapPlugin: Send + Sync {
fn name(&self) -> &'static str;
fn phases(&self) -> Vec<&'static str>;
#[allow(clippy::ptr_arg)]
fn should_activate(&self, repo_root: &PathBuf) -> bool;
fn run(&self, context: PluginContext) -> Result<PluginOutcome>;
}