| Crates.io | vx-core |
| lib.rs | vx-core |
| version | 0.4.0 |
| created_at | 2025-06-14 18:43:17.540506+00 |
| updated_at | 2025-06-19 13:52:46.515021+00 |
| description | Core traits and interfaces for vx tool manager |
| homepage | https://github.com/loonghao/vx |
| repository | https://github.com/loonghao/vx |
| max_upload_size | |
| id | 1712575 |
| size | 47,946 |
Core Engine for the vx Universal Tool Manager
Foundational traits, types, and utilities powering the vx ecosystem
vx-core provides the foundational traits, types, and utilities that power the vx tool management system. It defines the core abstractions for tool management, version handling, configuration, and plugin architecture. With the integration of vx-installer, it now offers state-of-the-art installation capabilities with beautiful progress tracking.
use vx_core::{Tool, ToolManager, Version};
// Define a custom tool
struct MyTool;
impl Tool for MyTool {
fn name(&self) -> &str { "mytool" }
fn description(&self) -> &str { "My custom tool" }
// ... implement other required methods
}
use vx_core::{Plugin, PluginManager};
// Create a plugin for your tool
struct MyPlugin;
impl Plugin for MyPlugin {
fn name(&self) -> &str { "my-plugin" }
fn tools(&self) -> Vec<Box<dyn Tool>> {
vec![Box::new(MyTool)]
}
}
use vx_core::config::{Config, ConfigManager};
// Load configuration from multiple sources
let config = ConfigManager::load()?;
let auto_install = config.auto_install.enabled;
use vx_core::InstallerAdapter;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create installer adapter with beautiful progress tracking
let installer = InstallerAdapter::new().await?;
// Install tools with automatic progress bars and checksum verification
let node_path = installer
.download_and_install(
"node",
"18.17.0",
"https://nodejs.org/dist/v18.17.0/node-v18.17.0-linux-x64.tar.gz"
)
.await?;
println!("✅ Node.js installed to: {}", node_path.display());
// Check if a tool version is installed
let is_installed = installer.is_version_installed("node", "18.17.0").await?;
println!("Node.js 18.17.0 installed: {}", is_installed);
Ok(())
}
use vx_core::{ToolManager, GlobalToolManager};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let manager = GlobalToolManager::new()?;
// Install a tool
manager.install_tool("node", "18.17.0").await?;
// List installed tools
let tools = manager.list_installed_tools()?;
for tool in tools {
println!("{}: {}", tool.name, tool.version);
}
Ok(())
}
use vx_core::config::ConfigManager;
let config = ConfigManager::load()?;
// Check if auto-install is enabled
if config.auto_install.enabled {
println!("Auto-install is enabled");
}
// Get tool-specific configuration
if let Some(node_config) = config.tools.get("node") {
println!("Node.js version: {}", node_config.version);
}
use vx_core::{VirtualEnvironment, SymlinkVenv};
let venv = SymlinkVenv::new("my-project")?;
// Add tools to the environment
venv.add_tool("node", "18.17.0")?;
venv.add_tool("uv", "latest")?;
// Activate the environment
venv.activate()?;
vx-core uses a hierarchical configuration system:
~/.vx/config/global.toml.vx.toml in project rootVX_* prefixed variables[auto_install]
enabled = true
timeout = 300
[tools]
node = "18.17.0"
uv = "latest"
[settings]
cache_duration = "7d"
parallel_downloads = 4
vx-core uses anyhow::Result for error handling:
use vx_core::error::VxError;
fn example() -> anyhow::Result<()> {
// Operations that might fail
let tool = manager.find_tool("nonexistent")?;
Ok(())
}
cargo build
cargo test
cargo doc --open
vx-core is designed to be used by:
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please see the contributing guidelines for more information.
vx-installer - 🆕 Universal installation engine with progress trackingvx-cli - Command-line interface with rich UXvx-config - Configuration management systemvx-plugin - Plugin system and trait definitionsvx-tool-node - Node.js tool pluginvx-tool-uv - UV Python tool pluginvx-pm-npm - NPM package manager pluginBuilt with ❤️ for the vx ecosystem