using System.Text.Json; namespace MarketAlly.AIPlugin.ClaudeCode; /// /// Main service interface for Claude Code integration /// public interface IClaudeCodeService { /// /// Sends a chat message to Claude Code and gets a response /// /// The chat request /// Cancellation token /// Claude's response Task> SendChatMessageAsync(ChatRequest request, CancellationToken cancellationToken = default); /// /// Analyzes a file or code snippet /// /// The analysis request /// Cancellation token /// Analysis results Task> AnalyzeCodeAsync(AnalysisRequest request, CancellationToken cancellationToken = default); /// /// Gets current rate limit status /// /// Cancellation token /// Rate limit information Task> GetRateLimitStatusAsync(CancellationToken cancellationToken = default); /// /// Searches project context for relevant information /// /// Search query /// Project path /// Cancellation token /// Search results Task>> SearchContextAsync(string query, string? projectPath = null, CancellationToken cancellationToken = default); /// /// Stores a decision or insight for future reference /// /// The decision storage request /// Cancellation token /// Success response Task> StoreDecisionAsync(StoreDecisionRequest request, CancellationToken cancellationToken = default); } /// /// Chat request model /// public class ChatRequest { public string Message { get; set; } = string.Empty; public string? SessionId { get; set; } public string? ProjectPath { get; set; } public Dictionary? Context { get; set; } public bool IncludeProjectContext { get; set; } = true; public bool IncludeHistory { get; set; } = true; } /// /// Analysis request model /// public class AnalysisRequest { public string? FilePath { get; set; } public string? Code { get; set; } public string AnalysisType { get; set; } = "general"; // general, security, performance, documentation public string? ProjectPath { get; set; } public Dictionary? Options { get; set; } } /// /// Store decision request model /// public class StoreDecisionRequest { public string Decision { get; set; } = string.Empty; public string Category { get; set; } = "decision"; public string? ProjectPath { get; set; } public Dictionary? Metadata { get; set; } } /// /// Analysis result model /// public class AnalysisResult { public string Summary { get; set; } = string.Empty; public List Issues { get; set; } = new(); public List Recommendations { get; set; } = new(); public Dictionary Metrics { get; set; } = new(); } /// /// Analysis issue model /// public class AnalysisIssue { public string Type { get; set; } = string.Empty; public string Severity { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public string? Line { get; set; } public string? File { get; set; } } /// /// Analysis recommendation model /// public class AnalysisRecommendation { public string Title { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; public string Priority { get; set; } = string.Empty; public List ActionItems { get; set; } = new(); } /// /// Context search result model /// public class ContextSearchResult { public string Id { get; set; } = string.Empty; public string Type { get; set; } = string.Empty; public string Content { get; set; } = string.Empty; public DateTime Timestamp { get; set; } public double Relevance { get; set; } public Dictionary Metadata { get; set; } = new(); } /// /// Rate limit information model /// public class RateLimitInfo { public string Tier { get; set; } = string.Empty; public int Current { get; set; } public int Limit { get; set; } public DateTime ResetTime { get; set; } public TimeSpan TimeToReset { get; set; } public double PercentageUsed { get; set; } public bool IsNearLimit { get; set; } } /// /// Generic response wrapper for Claude Code operations /// /// Response data type public class ClaudeCodeResponse { public bool Success { get; set; } public T? Data { get; set; } public string? Error { get; set; } public string? ErrorCode { get; set; } public RateLimitInfo? RateLimitInfo { get; set; } public Dictionary Metadata { get; set; } = new(); public static ClaudeCodeResponse CreateSuccess(T data, RateLimitInfo? rateLimitInfo = null) { return new ClaudeCodeResponse { Success = true, Data = data, RateLimitInfo = rateLimitInfo }; } public static ClaudeCodeResponse CreateError(string error, string? errorCode = null, RateLimitInfo? rateLimitInfo = null) { return new ClaudeCodeResponse { Success = false, Error = error, ErrorCode = errorCode, RateLimitInfo = rateLimitInfo }; } }