fix: update module declarations and imports

Co-authored-by: aider (openai/andrew/openrouter/google/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-25 13:03:59 -03:00
parent a1bcba5cb1
commit 53c63360cb
4 changed files with 11 additions and 11 deletions

View File

@@ -2,6 +2,7 @@
pub mod common; pub mod common;
pub mod compression_engine; pub mod compression_engine;
pub mod config; pub mod config;
pub mod core;
pub mod db; pub mod db;
pub mod meta_plugin; pub mod meta_plugin;
pub mod modes; pub mod modes;

View File

@@ -2,6 +2,7 @@ use anyhow::{anyhow, Result};
use std::path::PathBuf; use std::path::PathBuf;
use crate::config; use crate::config;
use crate::core::error::CoreError;
use crate::core::item_service::ItemService; use crate::core::item_service::ItemService;
use clap::error::ErrorKind; use clap::error::ErrorKind;
use clap::Command; use clap::Command;
@@ -37,7 +38,7 @@ pub fn mode_delete(
match item_service.delete_item(conn, *item_id) { match item_service.delete_item(conn, *item_id) {
Ok(_) => {} Ok(_) => {}
Err(e) => match e { Err(e) => match e {
crate::core::error::CoreError::ItemNotFound(_) => { CoreError::ItemNotFound(_) => {
warn!("Unable to find item {item_id} in database"); warn!("Unable to find item {item_id} in database");
} }
_ => return Err(anyhow!(e).context(format!("Failed to delete item {}", item_id))), _ => return Err(anyhow!(e).context(format!("Failed to delete item {}", item_id))),

View File

@@ -3,13 +3,12 @@ use crate::core::item_service::ItemService;
use crate::core::types::ItemWithMeta; use crate::core::types::ItemWithMeta;
use crate::modes::common::ColumnType; use crate::modes::common::ColumnType;
use crate::modes::common::{size_column, string_column, OutputFormat}; use crate::modes::common::{size_column, string_column, OutputFormat};
use anyhow::{anyhow, Result}; use anyhow::{Result};
use prettytable::format::Alignment; use prettytable::format::Alignment;
use prettytable::{color, row, Attr, Cell, Row, Table}; use prettytable::{color, row, Attr, Cell, Row, Table};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use serde_json; use serde_json;
use serde_yaml; use serde_yaml;
use std::str::FromStr;
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
struct ListItem { struct ListItem {

View File

@@ -1,8 +1,7 @@
use anyhow::{Result, anyhow}; use anyhow::{Result, anyhow};
use serde_json::Value; use serde_json::Value;
use std::collections::HashMap; use std::collections::HashMap;
use std::str::FromStr; use log::{debug};
use log::{debug, warn};
use crate::modes::server::common::AppState; use crate::modes::server::common::AppState;
use crate::core::async_item_service::AsyncItemService; use crate::core::async_item_service::AsyncItemService;
@@ -74,7 +73,7 @@ impl KeepTools {
let item_with_meta = service let item_with_meta = service
.save_item_from_mcp(content.as_bytes().to_vec(), tags, metadata) .save_item_from_mcp(content.as_bytes().to_vec(), tags, metadata)
.await .await
.map_err(|e| ToolError::Other(anyhow!(e)))?; .map_err(|e| ToolError::Other(anyhow::Error::from(e)))?;
let item_id = item_with_meta let item_id = item_with_meta
.item .item
@@ -96,7 +95,7 @@ impl KeepTools {
let item_with_content = match service.get_item_content(item_id).await { let item_with_content = match service.get_item_content(item_id).await {
Ok(iwc) => iwc, Ok(iwc) => iwc,
Err(CoreError::ItemNotFound(_)) => return Err(ToolError::InvalidArguments(format!("Item {} not found", item_id))), 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; 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 { let item_with_meta = match service.find_item(vec![], tags, HashMap::new()).await {
Ok(iwm) => iwm, Ok(iwm) => iwm,
Err(CoreError::ItemNotFoundGeneric) => return Err(ToolError::InvalidArguments("No items found".to_string())), 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_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 item = item_with_content.item_with_meta.item;
let content = String::from_utf8_lossy(&item_with_content.content).to_string(); let content = String::from_utf8_lossy(&item_with_content.content).to_string();
@@ -172,7 +171,7 @@ impl KeepTools {
.unwrap_or(0) as usize; .unwrap_or(0) as usize;
let service = AsyncItemService::new(self.state.data_dir.clone(), self.state.db.clone()); 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 // Sort by timestamp (newest first) and apply pagination
items_with_meta.sort_by(|a, b| b.item.ts.cmp(&a.item.ts)); items_with_meta.sort_by(|a, b| b.item.ts.cmp(&a.item.ts));
@@ -225,7 +224,7 @@ impl KeepTools {
.unwrap_or_default(); .unwrap_or_default();
let service = AsyncItemService::new(self.state.data_dir.clone(), self.state.db.clone()); 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) // Sort by timestamp (newest first)
items_with_meta.sort_by(|a, b| b.item.ts.cmp(&a.item.ts)); items_with_meta.sort_by(|a, b| b.item.ts.cmp(&a.item.ts));