From 1c8435a9fef9ab91faec9d660ada18f31facebb5 Mon Sep 17 00:00:00 2001 From: jcarver989 <117696+jcarver989@users.noreply.github.com> Date: Wed, 5 Aug 2026 05:29:11 +0000 Subject: [PATCH] chore: scheduled code-cleanup --- crates/aether-lspd/src/daemon.rs | 4 ++-- crates/aether-lspd/src/error.rs | 2 +- crates/aether-project/src/prompt_file.rs | 7 +++---- crates/mcp-servers/src/coding/error.rs | 17 +++++++++-------- crates/mcp-servers/src/coding/tools/bash/mod.rs | 4 ++-- .../mcp-servers/src/coding/tools/glob_filter.rs | 2 +- crates/mcp-servers/src/coding/tools/grep/mod.rs | 2 +- .../src/coding/tools/list_files/mod.rs | 9 ++++----- .../src/coding/tools/web_fetch/mod.rs | 2 +- 9 files changed, 24 insertions(+), 25 deletions(-) diff --git a/crates/aether-lspd/src/daemon.rs b/crates/aether-lspd/src/daemon.rs index 330cb6956..acf9786e2 100644 --- a/crates/aether-lspd/src/daemon.rs +++ b/crates/aether-lspd/src/daemon.rs @@ -38,8 +38,8 @@ impl LspDaemon { create_dir_all(parent).map_err(DaemonError::Io)?; } - let _lockfile = PidLockfile::acquire(&self.socket_path.with_extension("lock")) - .map_err(|e| DaemonError::LockfileError(e.to_string()))?; + let _lockfile = + PidLockfile::acquire(&self.socket_path.with_extension("lock")).map_err(DaemonError::LockfileError)?; let _ = remove_file(&self.socket_path); diff --git a/crates/aether-lspd/src/error.rs b/crates/aether-lspd/src/error.rs index f154fb166..df74d8662 100644 --- a/crates/aether-lspd/src/error.rs +++ b/crates/aether-lspd/src/error.rs @@ -18,7 +18,7 @@ pub enum DaemonError { /// Lockfile error #[error("Lockfile error: {0}")] - LockfileError(String), + LockfileError(#[source] io::Error), } /// Result type for daemon operations diff --git a/crates/aether-project/src/prompt_file.rs b/crates/aether-project/src/prompt_file.rs index dfb9ab285..89ea2280c 100644 --- a/crates/aether-project/src/prompt_file.rs +++ b/crates/aether-project/src/prompt_file.rs @@ -147,7 +147,7 @@ impl PromptFile { harmful: self.harmful, }; - let yaml = serde_yml::to_string(&frontmatter).map_err(|e| PromptFileError::Yaml(e.to_string()))?; + let yaml = serde_yml::to_string(&frontmatter)?; let yaml = normalize_frontmatter_yaml(&yaml); let file_content = if self.body.is_empty() { @@ -169,8 +169,7 @@ impl PromptFile { let (yaml_str, body) = utils::markdown_file::split_frontmatter(content).ok_or(PromptFileError::MissingFrontmatter)?; - let frontmatter: PromptFrontmatter = - serde_yml::from_str(yaml_str).map_err(|e| PromptFileError::Yaml(e.to_string()))?; + let frontmatter: PromptFrontmatter = serde_yml::from_str(yaml_str)?; Ok((frontmatter, body.to_string())) } @@ -223,7 +222,7 @@ pub enum PromptFileError { #[error("IO error: {0}")] Io(#[from] std::io::Error), #[error("YAML error: {0}")] - Yaml(String), + Yaml(#[from] serde_yml::Error), #[error("missing YAML frontmatter")] MissingFrontmatter, #[error("skill '{name}' has an empty description")] diff --git a/crates/mcp-servers/src/coding/error.rs b/crates/mcp-servers/src/coding/error.rs index 6d03390d9..4e9886ffc 100644 --- a/crates/mcp-servers/src/coding/error.rs +++ b/crates/mcp-servers/src/coding/error.rs @@ -3,6 +3,7 @@ //! This module provides structured error types for all coding tool operations, //! replacing the previous `Result` pattern with proper `thiserror` enums. +use std::io; use thiserror::Error; pub use crate::file_ops::FileError; @@ -64,11 +65,11 @@ pub enum BashError { /// Invalid regex pattern for filtering #[error("Invalid regex pattern: {0}")] - InvalidRegex(String), + InvalidRegex(#[source] regex::Error), /// Failed to join background task #[error("Failed to join background task: {0}")] - JoinFailed(String), + JoinFailed(#[source] tokio::task::JoinError), /// Shell ID not found #[error("Shell ID not found: {0}")] @@ -88,7 +89,7 @@ pub enum GlobError { /// Failed to build glob set #[error("Failed to build glob set: {0}")] - BuildFailed(String), + BuildFailed(#[source] globset::Error), } /// Errors related to grep search operations @@ -100,7 +101,7 @@ pub enum GrepError { /// Invalid regex pattern #[error("Invalid regex pattern: {0}")] - InvalidRegex(String), + InvalidRegex(#[source] grep::regex::Error), /// Search error during file processing #[error("Search error: {0}")] @@ -164,15 +165,15 @@ pub enum FindError { pub enum ListFilesError { /// Failed to read directory #[error("Failed to read directory: {0}")] - ReadDirFailed(String), + ReadDirFailed(#[source] io::Error), /// Failed to read directory entry #[error("Failed to read entry: {0}")] - ReadEntryFailed(String), + ReadEntryFailed(#[source] io::Error), /// Failed to read metadata #[error("Failed to read metadata: {0}")] - MetadataFailed(String), + MetadataFailed(#[source] io::Error), } /// Errors related to web fetch operations @@ -180,7 +181,7 @@ pub enum ListFilesError { pub enum WebFetchError { /// Invalid URL format #[error("Invalid URL: {0}")] - InvalidUrl(String), + InvalidUrl(#[source] url::ParseError), /// HTTP request failed #[error("Request failed: {0}")] diff --git a/crates/mcp-servers/src/coding/tools/bash/mod.rs b/crates/mcp-servers/src/coding/tools/bash/mod.rs index 93e2e0ce0..8bf210f9d 100644 --- a/crates/mcp-servers/src/coding/tools/bash/mod.rs +++ b/crates/mcp-servers/src/coding/tools/bash/mod.rs @@ -98,7 +98,7 @@ pub async fn read_background_bash( // Collect all available output let mut output = String::new(); let filter_regex = if let Some(pattern) = filter { - Some(regex::Regex::new(&pattern).map_err(|e| BashError::InvalidRegex(e.to_string()))?) + Some(regex::Regex::new(&pattern).map_err(BashError::InvalidRegex)?) } else { None }; @@ -114,7 +114,7 @@ pub async fn read_background_bash( } if task_handle.is_finished() { - let (exit_code, killed) = task_handle.await.map_err(|e| BashError::JoinFailed(e.to_string()))?; + let (exit_code, killed) = task_handle.await.map_err(BashError::JoinFailed)?; let status = if killed { BackgroundShellStatus::Failed } else { BackgroundShellStatus::Completed }; diff --git a/crates/mcp-servers/src/coding/tools/glob_filter.rs b/crates/mcp-servers/src/coding/tools/glob_filter.rs index 1d171b92f..f28b2915d 100644 --- a/crates/mcp-servers/src/coding/tools/glob_filter.rs +++ b/crates/mcp-servers/src/coding/tools/glob_filter.rs @@ -64,7 +64,7 @@ impl PathGlobMatcher { add_glob(&mut builder, root_pattern, case_sensitivity)?; } - Ok(Self { matcher: builder.build().map_err(|e| GlobError::BuildFailed(e.to_string()))?, kind }) + Ok(Self { matcher: builder.build().map_err(GlobError::BuildFailed)?, kind }) } pub fn matches(&self, path: &Path, search_root: &Path) -> bool { diff --git a/crates/mcp-servers/src/coding/tools/grep/mod.rs b/crates/mcp-servers/src/coding/tools/grep/mod.rs index 18a45bb7a..0bac4a6bf 100644 --- a/crates/mcp-servers/src/coding/tools/grep/mod.rs +++ b/crates/mcp-servers/src/coding/tools/grep/mod.rs @@ -222,7 +222,7 @@ fn build_matcher( matcher_builder.multi_line(true).dot_matches_new_line(true); } - matcher_builder.build(pattern).map_err(|e| GrepError::InvalidRegex(e.to_string())) + matcher_builder.build(pattern).map_err(GrepError::InvalidRegex) } fn build_searcher(args: &GrepInput) -> SearcherBuilder { diff --git a/crates/mcp-servers/src/coding/tools/list_files/mod.rs b/crates/mcp-servers/src/coding/tools/list_files/mod.rs index 4f81e1985..77b490b7a 100644 --- a/crates/mcp-servers/src/coding/tools/list_files/mod.rs +++ b/crates/mcp-servers/src/coding/tools/list_files/mod.rs @@ -55,13 +55,12 @@ pub async fn list_files(args: ListFilesArgs) -> Result Result { url.to_string() }; - Url::parse(&url).map(|u| u.to_string()).map_err(|e| WebFetchError::InvalidUrl(e.to_string())) + Url::parse(&url).map(|u| u.to_string()).map_err(WebFetchError::InvalidUrl) } fn extract_title(html: &str) -> Option {