| Crates.io | vx-plugin |
| lib.rs | vx-plugin |
| version | 0.4.0 |
| created_at | 2025-06-19 09:44:09.487623+00 |
| updated_at | 2025-06-19 13:51:22.802156+00 |
| description | Plugin system for vx - Universal Development Tool Manager |
| homepage | https://github.com/loonghao/vx |
| repository | https://github.com/loonghao/vx |
| max_upload_size | |
| id | 1718049 |
| size | 130,263 |
Extensible Plugin System for the vx Universal Tool Manager
Powerful, trait-based plugin architecture with beautiful installation experience
vx-plugin provides the powerful plugin architecture for vx, enabling developers to create custom tools and package managers that integrate seamlessly with the vx ecosystem. With the integration of vx-installer, plugins now benefit from beautiful progress tracking and advanced installation capabilities.
use vx_plugin::{VxTool, VersionInfo, Result};
use async_trait::async_trait;
struct MyTool;
#[async_trait]
impl VxTool for MyTool {
fn name(&self) -> &str {
"mytool"
}
async fn fetch_versions(&self, include_prerelease: bool) -> Result<Vec<VersionInfo>> {
// Fetch versions from your tool's API or registry
Ok(vec![
VersionInfo::new("1.0.0"),
VersionInfo::new("1.1.0"),
])
}
// Optional: Provide custom installation workflow with vx-installer integration
async fn default_install_workflow(&self, version: &str) -> Result<PathBuf> {
// This method automatically gets beautiful progress bars and security features
// when using the vx-installer integration
let download_url = format!("https://releases.example.com/mytool-{}.tar.gz", version);
// The installation will automatically show progress bars, verify checksums,
// and handle multiple archive formats
self.install_from_url(version, &download_url).await
}
}
use vx_plugin::{VxPackageManager, Ecosystem, PackageSpec, Result};
use async_trait::async_trait;
use std::path::Path;
struct MyPackageManager;
#[async_trait]
impl VxPackageManager for MyPackageManager {
fn name(&self) -> &str {
"mypm"
}
fn ecosystem(&self) -> Ecosystem {
Ecosystem::Node
}
async fn install_packages(&self, packages: &[PackageSpec], project_path: &Path) -> Result<()> {
// Install packages using your package manager
Ok(())
}
}
use vx_plugin::{VxPlugin, VxTool, VxPackageManager};
use async_trait::async_trait;
struct MyPlugin;
#[async_trait]
impl VxPlugin for MyPlugin {
fn name(&self) -> &str {
"my-plugin"
}
fn tools(&self) -> Vec<Box<dyn VxTool>> {
vec![Box::new(MyTool)]
}
fn package_managers(&self) -> Vec<Box<dyn VxPackageManager>> {
vec![Box::new(MyPackageManager)]
}
}
vx-plugin integrates seamlessly with the vx-installer engine to provide beautiful installation experiences:
When your plugin installs tools, users automatically get:
# Beautiful progress bars appear automatically
🚀 Installing MyTool v1.0.0...
⬇️ [████████████████████████████████] 25.4MB/25.4MB (3.2MB/s, 0s remaining)
📦 Extracting archive...
🔧 Setting up tool...
✅ MyTool v1.0.0 installed successfully!
All plugin installations automatically include:
Your plugins can handle multiple archive formats without additional code:
// This automatically handles ZIP, TAR.GZ, TAR.XZ, TAR.BZ2, and raw binaries
async fn install_version(&self, version: &str) -> Result<PathBuf> {
let download_url = self.get_download_url(version)?;
// vx-installer automatically detects format and shows progress
self.install_from_url(version, &download_url).await
}
The VxTool trait is the core interface for implementing tool support. Tools can be anything from compilers and interpreters to CLI utilities and development tools.
Required Methods:
name() - Return the tool namefetch_versions() - Fetch available versions from the tool's sourceOptional Methods (Enhanced with vx-installer):
install_version() - Install a specific version with beautiful progress barsdefault_install_workflow() - Custom installation with automatic progress trackingexecute() - Execute the tool with arguments and environment isolationget_status() - Get tool installation status with detailed informationget_download_url() - Provide download URLs for automatic installationverify_installation() - Verify tool installation integrityThe VxPackageManager trait provides a unified interface for different package managers across various ecosystems.
Required Methods:
name() - Return the package manager nameecosystem() - Return the ecosystem (Node, Python, Rust, etc.)install_packages() - Install packages in a projectOptional Methods:
remove_packages() - Remove packagesupdate_packages() - Update packageslist_packages() - List installed packagessearch_packages() - Search for packagesThe VxPlugin trait is the main interface for creating plugins that can provide both tools and package managers.
Required Methods:
name() - Return the plugin nameOptional Methods:
tools() - Return tools provided by this pluginpackage_managers() - Return package managers provided by this plugininitialize() - Initialize the pluginshutdown() - Shutdown the pluginThe PluginRegistry manages all loaded plugins and provides discovery functionality:
use vx_plugin::{PluginRegistry, PluginRegistryBuilder};
// Create a registry with plugins
let registry = PluginRegistryBuilder::new()
.with_plugin(Box::new(MyPlugin))
.build()
.await?;
// Use the registry
let tool = registry.get_tool("mytool");
let pm = registry.get_package_manager("mypm");
See the examples/ directory for complete working examples:
simple_tool_plugin.rs - Basic tool plugin implementationpackage_manager_plugin.rs - Package manager plugin implementationcombined_plugin.rs - Plugin providing both tools and package managersvx-installer - 🆕 Universal installation engine with progress trackingvx-core - Core functionality and utilitiesvx-cli - Command-line interface with rich UXvx-config - Configuration management systemvx-tool-node - Node.js tool plugin with NPX supportvx-tool-uv - UV Python tool plugin with UVX supportvx-tool-go - Go toolchain pluginvx-tool-rust - Rust and Cargo pluginvx-pm-npm - NPM package manager pluginThis project is licensed under the MIT License - see the LICENSE file for details.
Build powerful plugins for the vx ecosystem