Loading...
Loading...
Search and analyze AI coding assistant session history using Terraphim. Find past conversations, discover patterns, and learn from previous work. Supports Claude Code, Cursor, Aider, and other AI coding assistants.
npx skill4agent add terraphim/terraphim-skills session-search~/.claude/projects/┌─────────────────────────────────────────────────────────────────┐
│ Session Sources │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Claude Code │ │ Cursor │ │ Aider │ │
│ │ ~/.claude/ │ │ ~/.cursor/ │ │ .aider.chat │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
└─────────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────────┐
│ terraphim_sessions │
│ (Connector Registry) │
└───────────────────────────────┘
│
┌───────────────┴───────────────┐
│ │
▼ ▼
┌──────────────────────┐ ┌──────────────────────┐
│ SessionService │ │ SessionEnricher │
│ (Import, Search) │ │ (Concept Matching) │
└──────────────────────┘ └──────────────────────┘
│
▼
┌───────────────────────────────┐
│ Knowledge Graph Concepts │
│ (terraphim_automata) │
└───────────────────────────────┘# Build with session features
cargo build -p terraphim_agent --features repl-full --release
# Launch REPL
./target/release/terraphim-agent
# In REPL:
/sessions sources # Detect available sources
/sessions import # Import from all sources
/sessions search "rust" # Search for "rust" in sessions
/sessions stats # Show statistics| Command | Description |
|---|---|
| Detect available session sources |
| Import sessions from source |
| List imported sessions |
| Full-text search |
| Show statistics |
| Show session details |
| Search by knowledge graph concept |
| Find related sessions |
| `/sessions timeline [--group day | week |
| `/sessions export [--format json | md] [--output file]` |
| Enrich with concepts |
/sessions search "authentication"
/sessions show abc123-def456/sessions import
/sessions stats
/sessions timeline --group week --limit 10/sessions concepts "error handling"
/sessions related abc123 --min 3# Direct CLI search (without REPL)
terraphim-agent sessions search "database migration"
# Import and search in one pipeline
terraphim-agent sessions import && terraphim-agent sessions search "API design"
# Export specific session
terraphim-agent sessions export --session abc123 --format markdown --output session.md# Check if terraphim-agent has session support
if terraphim-agent sessions sources 2>/dev/null | grep -q "claude-code"; then
echo "Session search available"
fiuse terraphim_sessions::{SessionService, ImportOptions};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create service
let service = SessionService::new();
// Detect sources
let sources = service.detect_sources();
for source in sources {
println!("{}: {:?}", source.id, source.status);
}
// Import sessions
let options = ImportOptions::default().with_limit(100);
let sessions = service.import_all(&options).await?;
// Search
let results = service.search("async rust").await;
for session in results {
println!("{}: {} messages",
session.id,
session.message_count()
);
}
Ok(())
}use terraphim_sessions::{SessionEnricher, EnrichmentConfig};
// Create enricher with automata
let config = EnrichmentConfig {
thesaurus_path: "docs/src/kg/".into(),
min_confidence: 0.8,
};
let enricher = SessionEnricher::new(config)?;
// Enrich session with concepts
let enriched = enricher.enrich(&session)?;
// Get matched concepts
for concept in enriched.concepts {
println!("{}: {} occurrences",
concept.term,
concept.occurrences.len()
);
}
// Find related sessions by shared concepts
let related = find_related_sessions(&sessions, &enriched, 3)?;{
"tool": "session_search",
"arguments": {
"query": "error handling patterns",
"limit": 10
}
}use claude_log_analyzer::{Analyzer, Reporter};
// Analyze from default location
let analyzer = Analyzer::from_default_location()?;
let analyses = analyzer.analyze(None)?;
// Get agent usage statistics
for analysis in &analyses {
for agent in &analysis.agents {
println!("{}: {} invocations",
agent.agent_type,
agent.invocation_count
);
}
}
// Generate report
let reporter = Reporter::new();
reporter.print_terminal(&analyses);You: "How did I solve the authentication issue last month?"
Claude: [session-search skill]
Action:
1. /sessions search "authentication"
2. /sessions timeline --group week
3. /sessions show <relevant-id>
Output:
- Session summaries matching query
- Timeline of related work
- Full conversation detailsYou: "What agents have I used most frequently?"
Claude: [session-search skill]
Action:
1. Import all sessions
2. Analyze agent usage via claude-log-analyzer
3. Generate statistics
Output:
- Agent usage breakdown
- Most productive agents
- Collaboration patternsYou: "I need to implement caching again"
Claude: [session-search skill]
Action:
1. /sessions concepts "caching"
2. /sessions related <cache-session-id>
3. Extract relevant patterns
Output:
- Previous caching implementations
- Related design decisions
- Code patterns to reuseYou: "Export my sessions about the payment system"
Claude: [session-search skill]
Action:
1. /sessions search "payment"
2. /sessions export --format markdown --output payments-history.md
Output:
- Markdown file with full session history
- Ready for sharing or archivalpub struct Session {
pub id: SessionId,
pub source: String, // "claude-code", "cursor", etc.
pub title: Option<String>,
pub messages: Vec<Message>,
pub metadata: SessionMetadata,
}
pub struct Message {
pub role: MessageRole, // User, Assistant, System
pub content: String,
pub timestamp: Option<DateTime>,
}
pub struct SessionMetadata {
pub project_path: Option<String>,
pub started_at: Option<DateTime>,
pub ended_at: Option<DateTime>,
pub agent_types: Vec<String>,
}[dependencies]
terraphim_agent = {
version = "1.6",
features = ["repl-sessions"]
}
terraphim_sessions = {
version = "1.6",
features = ["tsa-full", "enrichment"]
}| Variable | Description |
|---|---|
| Override Claude sessions location |
| Enable verbose logging |
| Issue | Solution |
|---|---|
| No sessions found | Run |
| Import fails | Check permissions on |
| Search too slow | Use |
| Concepts not matching | Verify knowledge graph files in |
| Feature not available | Rebuild with |
terraphim-hooksdebuggingarchitecture