pub mod claude_code;
pub mod claude_memory;
pub mod cursor;
mod document;
pub mod git;
pub mod markdown;
mod persist;
pub mod raw_text;
pub mod repo_instructions;
pub mod session_evidence;
pub use persist::{IngestStore, StoreOutcome, store_document_result, store_ingest_result};
use std::path::Path;
use anyhow::Result;
use second_brain_core::schema::{Conversation, Memory};
pub fn project_slug(projects_root: &Path, transcript: &Path) -> Option<String> {
transcript
.strip_prefix(projects_root)
.ok()?
.components()
.next()
.map(|c| c.as_os_str().to_string_lossy().to_string())
}
pub fn encode_project_dir(path: &Path) -> String {
path.to_string_lossy()
.chars()
.flat_map(|c| {
let dashes = if c.is_ascii_alphanumeric() {
0
} else {
c.len_utf16()
};
std::iter::repeat_n('-', dashes).chain((dashes == 0).then_some(c))
})
.collect()
}
pub trait Adapter: Send + Sync {
fn name(&self) -> &str;
fn discover_conversations(&self) -> Result<Vec<ConversationSource>>;
fn ingest_conversation(&self, source: &ConversationSource) -> Result<IngestResult>;
fn session_key(&self, _path: &Path, _content: &str) -> Option<String> {
None
}
}
#[derive(Debug, Clone)]
pub struct ConversationSource {
pub id: String,
pub path: String,
pub source_name: String,
pub machine_id: String,
}
#[derive(Debug, Clone)]
pub struct ExtractedEntity {
pub name: String,
pub entity_type: String,
}
#[derive(Debug, Clone)]
pub struct IngestResult {
pub conversation: Conversation,
pub memories: Vec<Memory>,
pub entities: Vec<(ExtractedEntity, uuid::Uuid)>,
pub entities_extracted: usize,
}