second-brain-adapters 0.10.0

Conversation parsers for second-brain: Claude Code JSONL and Cursor SQLite adapters
Documentation
pub mod claude_code;
pub mod claude_memory;
pub mod cursor;
mod persist;
pub mod session_evidence;

pub use persist::{IngestStore, StoreOutcome, store_ingest_result};

use std::path::Path;

use anyhow::Result;
use second_brain_core::schema::{Conversation, Memory};

/// The project a transcript belongs to is the directory directly under the
/// adapter's `projects` root. Nothing below that level is a project: Claude
/// Code nests subagent transcripts as `<session>/subagents/*.jsonl` and
/// Cursor nests its own as `agent-transcripts/<session>/*.jsonl`, so the
/// file's parent directory names the wrong thing for both.
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 trait Adapter: Send + Sync {
    fn name(&self) -> &str;
    fn discover_conversations(&self) -> Result<Vec<ConversationSource>>;
    fn ingest_conversation(&self, source: &ConversationSource) -> Result<IngestResult>;
}

#[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,
}