namespace MarketAlly.AIPlugin.ClaudeCode;
///
/// Service for managing Claude Code context and memory
///
public interface IContextClaudeService
{
///
/// Retrieves relevant context for a query or conversation
///
/// The query to find context for
/// Optional project path to scope the search
/// Maximum number of results to return
/// Cancellation token
/// Relevant context entries
Task>> GetRelevantContextAsync(
string query,
string? projectPath = null,
int maxResults = 10,
CancellationToken cancellationToken = default);
///
/// Stores context information for future retrieval
///
/// The context entry to store
/// Cancellation token
/// Success response with stored entry ID
Task> StoreContextAsync(ContextEntry entry, CancellationToken cancellationToken = default);
///
/// Retrieves conversation history for a session
///
/// Session identifier
/// Maximum number of messages to return
/// Cancellation token
/// Conversation history
Task>> GetConversationHistoryAsync(
string sessionId,
int maxMessages = 50,
CancellationToken cancellationToken = default);
///
/// Stores a conversation message
///
/// The conversation message to store
/// Cancellation token
/// Success response
Task> StoreConversationMessageAsync(ConversationMessage message, CancellationToken cancellationToken = default);
///
/// Gets project-specific insights and decisions
///
/// Project path
/// Optional category filter
/// Cancellation token
/// Project insights
Task>> GetProjectInsightsAsync(
string projectPath,
string? category = null,
CancellationToken cancellationToken = default);
///
/// Stores a project insight or decision
///
/// The insight to store
/// Cancellation token
/// Success response
Task> StoreProjectInsightAsync(ProjectInsight insight, CancellationToken cancellationToken = default);
///
/// Searches across all stored context using semantic search
///
/// Search query
/// Optional filters
/// Cancellation token
/// Search results
Task>> SearchAllContextAsync(
string query,
ContextSearchFilters? filters = null,
CancellationToken cancellationToken = default);
}
///
/// Context entry model
///
public class ContextEntry
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string Type { get; set; } = string.Empty; // conversation, decision, insight, documentation
public string Content { get; set; } = string.Empty;
public string? ProjectPath { get; set; }
public string? SessionId { get; set; }
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public Dictionary Metadata { get; set; } = new();
public List Tags { get; set; } = new();
public double Relevance { get; set; } = 1.0;
}
///
/// Conversation message model
///
public class ConversationMessage
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string SessionId { get; set; } = string.Empty;
public string Role { get; set; } = string.Empty; // user, assistant, system
public string Content { get; set; } = string.Empty;
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
public string? ProjectPath { get; set; }
public Dictionary Metadata { get; set; } = new();
public List Attachments { get; set; } = new();
}
///
/// Project insight model
///
public class ProjectInsight
{
public string Id { get; set; } = Guid.NewGuid().ToString();
public string ProjectPath { get; set; } = string.Empty;
public string Type { get; set; } = string.Empty; // decision, pattern, recommendation, issue
public string Category { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
public DateTime? UpdatedAt { get; set; }
public string Confidence { get; set; } = "medium"; // low, medium, high
public List Tags { get; set; } = new();
public Dictionary Data { get; set; } = new();
public string? RelatedFiles { get; set; }
public List References { get; set; } = new();
}
///
/// Context search filters
///
public class ContextSearchFilters
{
public string? ProjectPath { get; set; }
public string? Type { get; set; }
public string? Category { get; set; }
public DateTime? FromDate { get; set; }
public DateTime? ToDate { get; set; }
public List? Tags { get; set; }
public int? MaxResults { get; set; } = 50;
public double? MinRelevance { get; set; } = 0.5;
}