second_brain_adapters/
lib.rs1pub mod claude_code;
2pub mod claude_memory;
3pub mod cursor;
4mod persist;
5
6pub use persist::{IngestStore, StoreOutcome, store_ingest_result};
7
8use std::path::Path;
9
10use anyhow::Result;
11use second_brain_core::schema::{Conversation, Memory};
12
13pub fn project_slug(projects_root: &Path, transcript: &Path) -> Option<String> {
19 transcript
20 .strip_prefix(projects_root)
21 .ok()?
22 .components()
23 .next()
24 .map(|c| c.as_os_str().to_string_lossy().to_string())
25}
26
27pub trait Adapter: Send + Sync {
28 fn name(&self) -> &str;
29 fn discover_conversations(&self) -> Result<Vec<ConversationSource>>;
30 fn ingest_conversation(&self, source: &ConversationSource) -> Result<IngestResult>;
31}
32
33#[derive(Debug, Clone)]
34pub struct ConversationSource {
35 pub id: String,
36 pub path: String,
37 pub source_name: String,
38 pub machine_id: String,
39}
40
41#[derive(Debug, Clone)]
42pub struct ExtractedEntity {
43 pub name: String,
44 pub entity_type: String,
45}
46
47#[derive(Debug, Clone)]
48pub struct IngestResult {
49 pub conversation: Conversation,
50 pub memories: Vec<Memory>,
51 pub entities: Vec<(ExtractedEntity, uuid::Uuid)>,
52 pub entities_extracted: usize,
53}