pub trait Plugin: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn version(&self) -> &str;
fn tool_names(&self) -> &[&str];
fn load(
&self,
registry: &Arc<ToolRegistry>,
ctx: &PluginContext,
) -> Result<()>;
// Provided methods
fn unload(&self, registry: &Arc<ToolRegistry>) { ... }
fn description(&self) -> &str { ... }
fn skills(&self) -> Vec<Arc<Skill>> { ... }
}Expand description
Unified interface for all A3S Code plugins.
A plugin is a self-contained unit that registers one or more tools into a
ToolRegistry when loaded and removes them when unloaded. This gives the
host application a single consistent API for managing optional capabilities.
§Implementing a plugin
use a3s_code_core::plugin::{Plugin, PluginContext};
use a3s_code_core::tools::ToolRegistry;
use anyhow::Result;
use std::sync::Arc;
struct MyPlugin;
impl Plugin for MyPlugin {
fn name(&self) -> &str { "my-plugin" }
fn version(&self) -> &str { "0.1.0" }
fn tool_names(&self) -> &[&str] { &["my_tool"] }
fn load(&self, registry: &Arc<ToolRegistry>, _ctx: &PluginContext) -> Result<()> {
Ok(())
}
}Required Methods§
Sourcefn tool_names(&self) -> &[&str]
fn tool_names(&self) -> &[&str]
Names of all tools this plugin registers.
Used by PluginManager::unload to remove the correct tools.
Sourcefn load(&self, registry: &Arc<ToolRegistry>, ctx: &PluginContext) -> Result<()>
fn load(&self, registry: &Arc<ToolRegistry>, ctx: &PluginContext) -> Result<()>
Register this plugin’s tools into registry.
Called once when the plugin is mounted onto a session.
Provided Methods§
Sourcefn unload(&self, registry: &Arc<ToolRegistry>)
fn unload(&self, registry: &Arc<ToolRegistry>)
Remove this plugin’s tools from registry.
The default implementation unregisters every tool listed in
tool_names(). Override only if you need custom cleanup.
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description shown in plugin listings.
Sourcefn skills(&self) -> Vec<Arc<Skill>>
fn skills(&self) -> Vec<Arc<Skill>>
Skills bundled with this plugin.
When the plugin is loaded successfully, each skill returned here is
registered into PluginContext::skill_registry (if one is provided).
This allows the skill to appear in the system prompt and be matched
against user requests automatically — no manual skill configuration
is needed by the caller.
Override to return plugin-specific skills. The default returns an empty list (no companion skills).