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