Skip to main content

Plugin

Trait Plugin 

Source
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§

Source

fn name(&self) -> &str

Unique plugin identifier (kebab-case, e.g. "agentic-search").

Source

fn version(&self) -> &str

Plugin version string (semver, e.g. "1.0.0").

Source

fn tool_names(&self) -> &[&str]

Names of all tools this plugin registers.

Used by PluginManager::unload to remove the correct tools.

Source

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§

Source

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.

Source

fn description(&self) -> &str

Human-readable description shown in plugin listings.

Source

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).

Implementors§