Skip to main content

ClaudeConvo

Struct ClaudeConvo 

Source
pub struct ClaudeConvo { /* private fields */ }
Expand description

High-level interface for reading Claude conversations.

This is the primary entry point for most use cases. It provides convenient methods for reading conversations, listing projects, and accessing conversation history.

Chain-default: read_conversation and list_conversations operate on logical conversations (merged session chains). Use read_segment and list_segments for single-file access.

§Example

use toolpath_claude::ClaudeConvo;

let manager = ClaudeConvo::new();

// List all projects
let projects = manager.list_projects()?;

// Read a conversation (follows session chains automatically)
let convo = manager.read_conversation(
    "/Users/alex/project",
    "session-uuid"
)?;

println!("Conversation has {} messages", convo.message_count());

Implementations§

Source§

impl ClaudeConvo

Source

pub fn new() -> Self

Creates a new ClaudeConvo manager with default path resolution.

Source

pub fn with_resolver(resolver: PathResolver) -> Self

Creates a ClaudeConvo manager with a custom path resolver.

This is useful for testing or when working with non-standard paths.

§Example
use toolpath_claude::{ClaudeConvo, PathResolver};

let resolver = PathResolver::new()
    .with_home("/custom/home")
    .with_claude_dir("/custom/.claude");

let manager = ClaudeConvo::with_resolver(resolver);
Source

pub fn io(&self) -> &ConvoIO

Returns a reference to the underlying ConvoIO.

Source

pub fn resolver(&self) -> &PathResolver

Returns a reference to the path resolver.

Source

pub fn read_conversation( &self, project_path: &str, session_id: &str, ) -> Result<Conversation>

Reads a conversation by project path and session ID.

Chain-aware: if this session is part of a chain (file rotation), all segments are merged into a single Conversation with bridge entries filtered out and session_ids populated.

Use Self::read_segment for single-file access.

Source

pub fn read_conversation_metadata( &self, project_path: &str, session_id: &str, ) -> Result<ConversationMetadata>

Reads conversation metadata without loading the full content.

Chain-aware: aggregates message_count (sum), started_at (earliest), and last_activity (latest) across all segments.

Source

pub fn list_conversations(&self, project_path: &str) -> Result<Vec<String>>

Lists logical conversation IDs for a project (chain heads only).

Chained sessions collapse to a single entry (the head). Use Self::list_segments for all file stems.

Source

pub fn list_conversation_metadata( &self, project_path: &str, ) -> Result<Vec<ConversationMetadata>>

Lists metadata for all logical conversations in a project.

Chain heads only. Results are sorted by last activity (most recent first).

Source

pub fn read_segment( &self, project_path: &str, session_id: &str, ) -> Result<Conversation>

Reads a single JSONL file without following chains.

Source

pub fn list_segments(&self, project_path: &str) -> Result<Vec<String>>

Lists all file stems (including successor segments).

Source

pub fn list_projects(&self) -> Result<Vec<String>>

Lists all projects that have conversations.

Returns the original project paths (e.g., “/Users/alex/project”).

Source

pub fn read_history(&self) -> Result<Vec<HistoryEntry>>

Reads the global history file.

The history file contains a record of all queries across all projects.

Source

pub fn exists(&self) -> bool

Checks if the Claude directory exists.

Source

pub fn claude_dir_path(&self) -> Result<PathBuf>

Returns the path to the Claude directory.

Source

pub fn conversation_exists( &self, project_path: &str, session_id: &str, ) -> Result<bool>

Checks if a specific conversation exists.

Source

pub fn project_exists(&self, project_path: &str) -> bool

Checks if a project directory exists.

Source

pub fn query<'a>(&self, conversation: &'a Conversation) -> ConversationQuery<'a>

Creates a query builder for a conversation.

Source

pub fn query_history<'a>(&self, history: &'a [HistoryEntry]) -> HistoryQuery<'a>

Creates a query builder for history entries.

Source

pub fn read_all_conversations( &self, project_path: &str, ) -> Result<Vec<Conversation>>

Reads all conversations for a project.

Returns a vector of conversations sorted by last activity.

Source

pub fn most_recent_conversation( &self, project_path: &str, ) -> Result<Option<Conversation>>

Gets the most recent conversation for a project.

Source

pub fn find_conversations_with_text( &self, project_path: &str, search_text: &str, ) -> Result<Vec<Conversation>>

Finds conversations that contain specific text.

Trait Implementations§

Source§

impl Clone for ClaudeConvo

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConversationProvider for ClaudeConvo

Source§

fn list_conversations(&self, project: &str) -> Result<Vec<String>>

List conversation IDs for a project/workspace.
Source§

fn load_conversation( &self, project: &str, conversation_id: &str, ) -> Result<ConversationView>

Load a full conversation as a ConversationView.
Source§

fn load_metadata( &self, project: &str, conversation_id: &str, ) -> Result<ConversationMeta>

Load metadata only (no turns).
Source§

fn list_metadata(&self, project: &str) -> Result<Vec<ConversationMeta>>

List metadata for all conversations in a project.
Source§

impl Debug for ClaudeConvo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClaudeConvo

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.