MarketAlly.AIPlugin.Extensions/MarketAlly.AIPlugin.ClaudeCode/Interfaces/IContextClaudeService.cs

147 lines
6.0 KiB
C#
Executable File

namespace MarketAlly.AIPlugin.ClaudeCode;
/// <summary>
/// Service for managing Claude Code context and memory
/// </summary>
public interface IContextClaudeService
{
/// <summary>
/// Retrieves relevant context for a query or conversation
/// </summary>
/// <param name="query">The query to find context for</param>
/// <param name="projectPath">Optional project path to scope the search</param>
/// <param name="maxResults">Maximum number of results to return</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>Relevant context entries</returns>
Task<ClaudeCodeResponse<List<ContextEntry>>> GetRelevantContextAsync(
string query,
string? projectPath = null,
int maxResults = 10,
CancellationToken cancellationToken = default);
/// <summary>
/// Stores context information for future retrieval
/// </summary>
/// <param name="entry">The context entry to store</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>Success response with stored entry ID</returns>
Task<ClaudeCodeResponse<string>> StoreContextAsync(ContextEntry entry, CancellationToken cancellationToken = default);
/// <summary>
/// Retrieves conversation history for a session
/// </summary>
/// <param name="sessionId">Session identifier</param>
/// <param name="maxMessages">Maximum number of messages to return</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>Conversation history</returns>
Task<ClaudeCodeResponse<List<ConversationMessage>>> GetConversationHistoryAsync(
string sessionId,
int maxMessages = 50,
CancellationToken cancellationToken = default);
/// <summary>
/// Stores a conversation message
/// </summary>
/// <param name="message">The conversation message to store</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>Success response</returns>
Task<ClaudeCodeResponse<bool>> StoreConversationMessageAsync(ConversationMessage message, CancellationToken cancellationToken = default);
/// <summary>
/// Gets project-specific insights and decisions
/// </summary>
/// <param name="projectPath">Project path</param>
/// <param name="category">Optional category filter</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>Project insights</returns>
Task<ClaudeCodeResponse<List<ProjectInsight>>> GetProjectInsightsAsync(
string projectPath,
string? category = null,
CancellationToken cancellationToken = default);
/// <summary>
/// Stores a project insight or decision
/// </summary>
/// <param name="insight">The insight to store</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>Success response</returns>
Task<ClaudeCodeResponse<string>> StoreProjectInsightAsync(ProjectInsight insight, CancellationToken cancellationToken = default);
/// <summary>
/// Searches across all stored context using semantic search
/// </summary>
/// <param name="query">Search query</param>
/// <param name="filters">Optional filters</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>Search results</returns>
Task<ClaudeCodeResponse<List<ContextSearchResult>>> SearchAllContextAsync(
string query,
ContextSearchFilters? filters = null,
CancellationToken cancellationToken = default);
}
/// <summary>
/// Context entry model
/// </summary>
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<string, object> Metadata { get; set; } = new();
public List<string> Tags { get; set; } = new();
public double Relevance { get; set; } = 1.0;
}
/// <summary>
/// Conversation message model
/// </summary>
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<string, object> Metadata { get; set; } = new();
public List<string> Attachments { get; set; } = new();
}
/// <summary>
/// Project insight model
/// </summary>
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<string> Tags { get; set; } = new();
public Dictionary<string, object> Data { get; set; } = new();
public string? RelatedFiles { get; set; }
public List<string> References { get; set; } = new();
}
/// <summary>
/// Context search filters
/// </summary>
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<string>? Tags { get; set; }
public int? MaxResults { get; set; } = 50;
public double? MinRelevance { get; set; } = 0.5;
}