vtcode_core/plugins/
mod.rs1pub mod caching;
11pub mod components;
12pub mod directory;
13pub mod loader;
14pub mod manager;
15pub mod manifest;
16pub mod runtime;
17pub mod validation;
18
19pub use caching::*;
20pub use components::*;
21pub use directory::*;
22pub use loader::*;
23pub use manager::*;
24pub use manifest::*;
25pub use runtime::*;
26pub use validation::*;
27
28crate::id_newtype::define_id_newtype! {
29 pub struct PluginId
31}
32
33pub type PluginName = String;
35
36pub type PluginResult<T> = Result<T, PluginError>;
38
39pub(crate) fn validate_plugin_component(value: &str) -> PluginResult<()> {
40 let mut components = std::path::Path::new(value).components();
41 if value.trim().is_empty()
42 || !matches!(components.next(), Some(std::path::Component::Normal(_)))
43 || components.next().is_some()
44 {
45 return Err(PluginError::LoadingError(format!("Plugin name must be one normal path component: {value}")));
46 }
47 Ok(())
48}
49
50#[cfg(test)]
51mod tests {
52 #[test]
55 fn test_plugin_system_compilation() {
56 }
58}
59
60#[derive(Debug, thiserror::Error)]
62pub enum PluginError {
63 #[error("Plugin manifest validation failed: {0}")]
64 ManifestValidationError(String),
65
66 #[error("Plugin not found: {0}")]
67 NotFound(PluginId),
68
69 #[error("Plugin already exists: {0}")]
70 AlreadyExists(PluginId),
71
72 #[error("Plugin loading failed: {0}")]
73 LoadingError(String),
74
75 #[error("Plugin execution failed: {0}")]
76 ExecutionError(String),
77
78 #[error("Plugin permission denied: {0}")]
79 PermissionDenied(String),
80
81 #[error("Plugin configuration error: {0}")]
82 ConfigurationError(String),
83
84 #[error("I/O error: {0}")]
85 IoError(#[from] std::io::Error),
86
87 #[error("JSON serialization error: {0}")]
88 JsonError(#[from] serde_json::Error),
89
90 #[error("TOML serialization error: {0}")]
91 TomlError(#[from] toml::de::Error),
92}