pub mod browser;
pub mod config;
pub mod deduplication;
pub mod exporter;
pub mod graph;
pub mod graph_output;
pub mod organization;
pub mod processor;
pub mod search;
pub mod utils;
#[cfg(feature = "mcp")]
pub mod mcp;
use std::path::PathBuf;
pub use crate::exporter::{Bookmark, UrlEntry};
pub use crate::graph::{GraphConfig, GraphBuilder, KnowledgeGraph};
pub struct BookmarkManager {
export_dir: Option<PathBuf>,
}
impl BookmarkManager {
pub fn new() -> Self {
Self {
export_dir: None,
}
}
pub fn with_export_dir(mut self, dir: PathBuf) -> Self {
self.export_dir = Some(dir);
self
}
pub fn export_bookmarks(&self, browser: &str) -> Result<Vec<Bookmark>, Box<dyn std::error::Error>> {
let (bookmarks, _) = crate::exporter::load_browser_data(browser, "bookmarks")?;
Ok(bookmarks)
}
pub fn search(&self, query: &str) -> Result<Vec<Bookmark>, Box<dyn std::error::Error>> {
use crate::search::{search_bookmarks_internal, SearchOptions};
let options = SearchOptions {
title_only: false,
url_only: false,
limit: 100,
};
Ok(search_bookmarks_internal(query, &options)?)
}
pub fn graph_from_bookmarks(&self, bookmarks: &[Bookmark]) -> Result<KnowledgeGraph, Box<dyn std::error::Error>> {
let config = GraphConfig::default();
let mut builder = GraphBuilder::new(config);
Ok(builder.from_bookmarks(bookmarks)?)
}
}
impl Default for BookmarkManager {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_manager_creation() {
let manager = BookmarkManager::new();
assert!(manager.export_dir.is_none());
}
#[test]
fn test_manager_with_export_dir() {
let manager = BookmarkManager::new().with_export_dir(PathBuf::from("/tmp"));
assert_eq!(manager.export_dir, Some(PathBuf::from("/tmp")));
}
}