use lorefs::{LoreFS, LoreConfig};
use std::error::Error;
use tempfile::tempdir;
fn main() -> Result<(), Box<dyn Error>> {
let temp_dir = tempdir()?;
let config = LoreConfig::builder()
.base_dir(temp_dir.path())
.reflection_every_n_turns(5) .build()?;
let mut lore = LoreFS::new(config)?;
let user_inputs = [
"My name is Alice.",
"I love building CLI tools.",
"I'm working on a project called 'lorefs'.",
"Remind me what I'm working on?",
"What's my name?",
];
for (i, input) in user_inputs.iter().enumerate() {
println!("\n--- Turn {} ---", i + 1);
println!("User: {}", input);
if input.contains("name is") {
lore.add(input, "USER.md", &["profile", "identity"])?;
println!("AI: Nice to meet you!");
} else if input.contains("working on") {
lore.add(input, "MEMORY.md", &["project", "current_task"])?;
println!("AI: Got it, 'lorefs' sounds interesting.");
} else if input.contains("Remind me") || input.contains("What's my name") {
let search_term = if input.contains("name") { "name" } else { "project" };
let memories = lore.search(search_term, 1, None)?;
if let Some((_, content)) = memories.first() {
println!("AI: I remember you said: {}", content.trim());
} else {
println!("AI: I don't recall that yet.");
}
} else {
println!("AI: Interesting! Tell me more.");
}
}
println!("\nFinal Memory Tree:");
println!("{}", lore.get_memory_tree());
Ok(())
}