From 5c62c478783218d7b481a160eb91f63389c42f69 Mon Sep 17 00:00:00 2001 From: Jason Date: Sun, 1 Feb 2026 23:02:33 +0800 Subject: [PATCH] chore(openclaw): remove dead code functions from openclaw_config Remove 6 unused functions marked with #[allow(dead_code)]: - get_openclaw_skills_dir: Skills not supported - get_env_vars/set_env_var: Environment vars unused - get_mcp_servers/set_mcp_server/remove_mcp_server: MCP not supported OpenClaw integration only requires provider management functionality. --- src-tauri/src/openclaw_config.rs | 70 -------------------------------- 1 file changed, 70 deletions(-) diff --git a/src-tauri/src/openclaw_config.rs b/src-tauri/src/openclaw_config.rs index 5a30d256..9488216c 100644 --- a/src-tauri/src/openclaw_config.rs +++ b/src-tauri/src/openclaw_config.rs @@ -70,14 +70,6 @@ pub fn get_openclaw_config_path() -> PathBuf { get_openclaw_dir().join("openclaw.json") } -/// 获取 OpenClaw Skills 目录路径 -/// -/// 返回 `~/.openclaw/skills/` -#[allow(dead_code)] -pub fn get_openclaw_skills_dir() -> PathBuf { - get_openclaw_dir().join("skills") -} - // ============================================================================ // Type Definitions // ============================================================================ @@ -262,65 +254,3 @@ pub fn set_typed_provider(id: &str, config: &OpenClawProviderConfig) -> Result<( let value = serde_json::to_value(config).map_err(|e| AppError::JsonSerialize { source: e })?; set_provider(id, value) } - -// ============================================================================ -// Environment Variables -// ============================================================================ - -/// 获取环境变量配置 -#[allow(dead_code)] -pub fn get_env_vars() -> Result, AppError> { - let config = read_openclaw_config()?; - Ok(config - .get("env") - .and_then(|v| v.as_object()) - .cloned() - .unwrap_or_default()) -} - -/// 设置环境变量 -#[allow(dead_code)] -pub fn set_env_var(key: &str, value: &str) -> Result<(), AppError> { - let mut config = read_openclaw_config()?; - - if config.get("env").is_none() { - config["env"] = json!({}); - } - - if let Some(env) = config.get_mut("env").and_then(|v| v.as_object_mut()) { - env.insert(key.to_string(), Value::String(value.to_string())); - } - - write_openclaw_config(&config) -} - -// ============================================================================ -// MCP Functions (Reserved for future use) -// ============================================================================ - -/// 获取所有 MCP 服务器配置 -/// -/// OpenClaw MCP 配置在 `agents.list[].mcp.servers` -/// 由于 OpenClaw MCP 支持仍在开发中(Issue #4834),暂时返回空 -#[allow(dead_code)] -pub fn get_mcp_servers() -> Result, AppError> { - // OpenClaw MCP support is under development - // Return empty for now - Ok(Map::new()) -} - -/// 设置 MCP 服务器配置 -#[allow(dead_code)] -pub fn set_mcp_server(_id: &str, _config: Value) -> Result<(), AppError> { - // OpenClaw MCP support is under development - log::warn!("OpenClaw MCP support is not yet implemented"); - Ok(()) -} - -/// 删除 MCP 服务器配置 -#[allow(dead_code)] -pub fn remove_mcp_server(_id: &str) -> Result<(), AppError> { - // OpenClaw MCP support is under development - log::warn!("OpenClaw MCP support is not yet implemented"); - Ok(()) -}