feat: Created a new .install command to install bundled assets on-demand

This commit is contained in:
2026-05-18 14:59:02 -06:00
parent 06fe1f9471
commit a22faad992
8 changed files with 222 additions and 18 deletions
+19 -2
View File
@@ -203,7 +203,7 @@ pub struct Functions {
}
impl Functions {
pub fn install_builtin_global_tools() -> Result<()> {
pub fn install_builtin_global_tools(force: bool) -> Result<()> {
info!(
"Installing global built-in functions in {}",
paths::functions_dir().display()
@@ -228,7 +228,8 @@ impl Functions {
#[cfg_attr(not(unix), expect(unused))]
let is_script = matches!(file_extension.as_deref(), Some("sh") | Some("py"));
if file_path.exists() {
let force_this = force && file.as_ref() != "mcp.json";
if file_path.exists() && !force_this {
debug!(
"Function file already exists, skipping: {}",
file_path.display()
@@ -251,6 +252,22 @@ impl Functions {
Ok(())
}
pub fn install_mcp_config() -> Result<()> {
let file_path = paths::mcp_config_file();
let embedded = FunctionAssets::get("mcp.json")
.ok_or_else(|| anyhow!("Failed to load embedded mcp.json"))?;
let content = unsafe { std::str::from_utf8_unchecked(&embedded.data) };
ensure_parent_exists(&file_path)?;
info!("Reinstalling MCP config file: {}", file_path.display());
let mut config_file = File::create(&file_path)?;
config_file.write_all(content.as_bytes())?;
Ok(())
}
pub fn init(visible_tools: &[String]) -> Result<Self> {
Self::clear_global_functions_bin_dir()?;