From 53c63360cb70641f92d71bc19771db8169062cb3 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Mon, 25 Aug 2025 13:03:59 -0300 Subject: [PATCH] fix: update module declarations and imports Co-authored-by: aider (openai/andrew/openrouter/google/gemini-2.5-pro) --- src/lib.rs | 1 + src/modes/delete.rs | 3 ++- src/modes/list.rs | 3 +-- src/modes/server/mcp/tools.rs | 15 +++++++-------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 163a24a..3d2b6df 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,6 +2,7 @@ pub mod common; pub mod compression_engine; pub mod config; +pub mod core; pub mod db; pub mod meta_plugin; pub mod modes; diff --git a/src/modes/delete.rs b/src/modes/delete.rs index 55444ba..3b33577 100644 --- a/src/modes/delete.rs +++ b/src/modes/delete.rs @@ -2,6 +2,7 @@ use anyhow::{anyhow, Result}; use std::path::PathBuf; use crate::config; +use crate::core::error::CoreError; use crate::core::item_service::ItemService; use clap::error::ErrorKind; use clap::Command; @@ -37,7 +38,7 @@ pub fn mode_delete( match item_service.delete_item(conn, *item_id) { Ok(_) => {} Err(e) => match e { - crate::core::error::CoreError::ItemNotFound(_) => { + CoreError::ItemNotFound(_) => { warn!("Unable to find item {item_id} in database"); } _ => return Err(anyhow!(e).context(format!("Failed to delete item {}", item_id))), diff --git a/src/modes/list.rs b/src/modes/list.rs index b17d3aa..9472cdc 100644 --- a/src/modes/list.rs +++ b/src/modes/list.rs @@ -3,13 +3,12 @@ use crate::core::item_service::ItemService; use crate::core::types::ItemWithMeta; use crate::modes::common::ColumnType; use crate::modes::common::{size_column, string_column, OutputFormat}; -use anyhow::{anyhow, Result}; +use anyhow::{Result}; use prettytable::format::Alignment; use prettytable::{color, row, Attr, Cell, Row, Table}; use serde::{Deserialize, Serialize}; use serde_json; use serde_yaml; -use std::str::FromStr; #[derive(Serialize, Deserialize)] struct ListItem { diff --git a/src/modes/server/mcp/tools.rs b/src/modes/server/mcp/tools.rs index 8c94aaf..8a06595 100644 --- a/src/modes/server/mcp/tools.rs +++ b/src/modes/server/mcp/tools.rs @@ -1,8 +1,7 @@ use anyhow::{Result, anyhow}; use serde_json::Value; use std::collections::HashMap; -use std::str::FromStr; -use log::{debug, warn}; +use log::{debug}; use crate::modes::server::common::AppState; use crate::core::async_item_service::AsyncItemService; @@ -74,7 +73,7 @@ impl KeepTools { let item_with_meta = service .save_item_from_mcp(content.as_bytes().to_vec(), tags, metadata) .await - .map_err(|e| ToolError::Other(anyhow!(e)))?; + .map_err(|e| ToolError::Other(anyhow::Error::from(e)))?; let item_id = item_with_meta .item @@ -96,7 +95,7 @@ impl KeepTools { let item_with_content = match service.get_item_content(item_id).await { Ok(iwc) => iwc, Err(CoreError::ItemNotFound(_)) => return Err(ToolError::InvalidArguments(format!("Item {} not found", item_id))), - Err(e) => return Err(ToolError::Other(anyhow!(e))), + Err(e) => return Err(ToolError::Other(anyhow::Error::from(e))), }; let item = item_with_content.item_with_meta.item; @@ -129,11 +128,11 @@ impl KeepTools { let item_with_meta = match service.find_item(vec![], tags, HashMap::new()).await { Ok(iwm) => iwm, Err(CoreError::ItemNotFoundGeneric) => return Err(ToolError::InvalidArguments("No items found".to_string())), - Err(e) => return Err(ToolError::Other(anyhow!(e))), + Err(e) => return Err(ToolError::Other(anyhow::Error::from(e))), }; let item_id = item_with_meta.item.id.ok_or_else(|| anyhow!("Item missing ID after find"))?; - let item_with_content = service.get_item_content(item_id).await.map_err(|e| ToolError::Other(anyhow!(e)))?; + let item_with_content = service.get_item_content(item_id).await.map_err(|e| ToolError::Other(anyhow::Error::from(e)))?; let item = item_with_content.item_with_meta.item; let content = String::from_utf8_lossy(&item_with_content.content).to_string(); @@ -172,7 +171,7 @@ impl KeepTools { .unwrap_or(0) as usize; let service = AsyncItemService::new(self.state.data_dir.clone(), self.state.db.clone()); - let mut items_with_meta = service.list_items(tags, HashMap::new()).await.map_err(|e| ToolError::Other(anyhow!(e)))?; + let mut items_with_meta = service.list_items(tags, HashMap::new()).await.map_err(|e| ToolError::Other(anyhow::Error::from(e)))?; // Sort by timestamp (newest first) and apply pagination items_with_meta.sort_by(|a, b| b.item.ts.cmp(&a.item.ts)); @@ -225,7 +224,7 @@ impl KeepTools { .unwrap_or_default(); let service = AsyncItemService::new(self.state.data_dir.clone(), self.state.db.clone()); - let mut items_with_meta = service.list_items(tags.clone(), metadata.clone()).await.map_err(|e| ToolError::Other(anyhow!(e)))?; + let mut items_with_meta = service.list_items(tags.clone(), metadata.clone()).await.map_err(|e| ToolError::Other(anyhow::Error::from(e)))?; // Sort by timestamp (newest first) items_with_meta.sort_by(|a, b| b.item.ts.cmp(&a.item.ts));