2
0
Files
logikonline 3a8bdd936c feat(pages): add A/B testing framework for landing pages
Implement comprehensive A/B testing system for landing page optimization:
- Database models for experiments, variants, and events
- AI-powered variant generation and analysis
- Visitor tracking with conversion metrics
- Experiment lifecycle management (draft/active/paused/completed)
- Email notifications for experiment results
- Cron job for automated experiment monitoring
- UI for viewing experiment results and statistics
2026-03-07 12:39:42 -05:00

294 lines
11 KiB
Go

// Copyright 2026 MarketAlly. All rights reserved.
// SPDX-License-Identifier: MIT
package ai
// ProviderConfig contains per-request AI provider configuration.
// When sent to the AI sidecar, it overrides the sidecar's default provider/model/key.
// Fields left empty fall back to the sidecar's defaults.
type ProviderConfig struct {
Provider string `json:"provider,omitempty"` // "claude", "openai", "gemini"
Model string `json:"model,omitempty"`
APIKey string `json:"api_key,omitempty"`
}
// FileDiff represents a file diff for code review
type FileDiff struct {
Path string `json:"path"`
OldPath string `json:"old_path,omitempty"`
Status string `json:"status"` // added, modified, deleted, renamed
Patch string `json:"patch"`
Content string `json:"content,omitempty"`
Language string `json:"language,omitempty"`
}
// ReviewOptions contains options for code review
type ReviewOptions struct {
CheckSecurity bool `json:"check_security"`
CheckPerformance bool `json:"check_performance"`
CheckStyle bool `json:"check_style"`
CheckTests bool `json:"check_tests"`
SuggestImprovements bool `json:"suggest_improvements"`
FocusAreas string `json:"focus_areas,omitempty"`
LanguageHints string `json:"language_hints,omitempty"`
}
// ReviewComment represents a code review comment
type ReviewComment struct {
Path string `json:"path"`
Line int `json:"line"`
EndLine int `json:"end_line,omitempty"`
Body string `json:"body"`
Severity string `json:"severity"` // info, warning, error, critical
Category string `json:"category"` // security, performance, style, bug
SuggestedFix string `json:"suggested_fix,omitempty"`
}
// SecurityIssue represents a security issue found during review
type SecurityIssue struct {
Path string `json:"path"`
Line int `json:"line"`
IssueType string `json:"issue_type"`
Description string `json:"description"`
Severity string `json:"severity"`
Remediation string `json:"remediation"`
}
// SecurityAnalysis contains security analysis results
type SecurityAnalysis struct {
Issues []SecurityIssue `json:"issues"`
RiskScore int `json:"risk_score"`
Summary string `json:"summary"`
}
// ReviewPullRequestRequest is the request for reviewing a pull request
type ReviewPullRequestRequest struct {
ProviderConfig *ProviderConfig `json:"provider_config,omitempty"`
RepoID int64 `json:"repo_id"`
PullRequestID int64 `json:"pull_request_id"`
BaseBranch string `json:"base_branch"`
HeadBranch string `json:"head_branch"`
Files []FileDiff `json:"files"`
PRTitle string `json:"pr_title"`
PRDescription string `json:"pr_description"`
Options ReviewOptions `json:"options"`
}
// ReviewPullRequestResponse is the response from reviewing a pull request
type ReviewPullRequestResponse struct {
Summary string `json:"summary"`
Comments []ReviewComment `json:"comments"`
Verdict string `json:"verdict"` // approve, request_changes, comment
Suggestions []string `json:"suggestions"`
Security SecurityAnalysis `json:"security"`
EstimatedReviewMinutes int `json:"estimated_review_minutes"`
}
// TriageIssueRequest is the request for triaging an issue
type TriageIssueRequest struct {
ProviderConfig *ProviderConfig `json:"provider_config,omitempty"`
RepoID int64 `json:"repo_id"`
IssueID int64 `json:"issue_id"`
Title string `json:"title"`
Body string `json:"body"`
ExistingLabels []string `json:"existing_labels"`
AvailableLabels []string `json:"available_labels"`
}
// TriageIssueResponse is the response from triaging an issue
type TriageIssueResponse struct {
Priority string `json:"priority"` // critical, high, medium, low
Category string `json:"category"` // bug, feature, question, docs
SuggestedLabels []string `json:"suggested_labels"`
SuggestedAssignees []string `json:"suggested_assignees"`
Summary string `json:"summary"`
IsDuplicate bool `json:"is_duplicate"`
DuplicateOf int64 `json:"duplicate_of,omitempty"`
}
// SuggestLabelsRequest is the request for suggesting labels
type SuggestLabelsRequest struct {
ProviderConfig *ProviderConfig `json:"provider_config,omitempty"`
RepoID int64 `json:"repo_id"`
Title string `json:"title"`
Body string `json:"body"`
AvailableLabels []string `json:"available_labels"`
}
// LabelSuggestion represents a suggested label
type LabelSuggestion struct {
Label string `json:"label"`
Confidence float32 `json:"confidence"`
Reason string `json:"reason"`
}
// SuggestLabelsResponse is the response from suggesting labels
type SuggestLabelsResponse struct {
Suggestions []LabelSuggestion `json:"suggestions"`
}
// ExplainCodeRequest is the request for explaining code
type ExplainCodeRequest struct {
ProviderConfig *ProviderConfig `json:"provider_config,omitempty"`
RepoID int64 `json:"repo_id"`
FilePath string `json:"file_path"`
Code string `json:"code"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
Question string `json:"question,omitempty"`
}
// CodeReference represents a reference to related documentation
type CodeReference struct {
Description string `json:"description"`
URL string `json:"url"`
}
// ExplainCodeResponse is the response from explaining code
type ExplainCodeResponse struct {
Explanation string `json:"explanation"`
KeyConcepts []string `json:"key_concepts"`
References []CodeReference `json:"references"`
}
// GenerateDocumentationRequest is the request for generating documentation
type GenerateDocumentationRequest struct {
ProviderConfig *ProviderConfig `json:"provider_config,omitempty"`
RepoID int64 `json:"repo_id"`
FilePath string `json:"file_path"`
Code string `json:"code"`
DocType string `json:"doc_type"` // function, class, module, api
Language string `json:"language"`
Style string `json:"style"` // jsdoc, docstring, xml, markdown
}
// DocumentationSection represents a section of documentation
type DocumentationSection struct {
Title string `json:"title"`
Content string `json:"content"`
}
// GenerateDocumentationResponse is the response from generating documentation
type GenerateDocumentationResponse struct {
Documentation string `json:"documentation"`
Sections []DocumentationSection `json:"sections"`
}
// GenerateCommitMessageRequest is the request for generating a commit message
type GenerateCommitMessageRequest struct {
ProviderConfig *ProviderConfig `json:"provider_config,omitempty"`
RepoID int64 `json:"repo_id"`
Files []FileDiff `json:"files"`
Style string `json:"style"` // conventional, descriptive, brief
}
// GenerateCommitMessageResponse is the response from generating a commit message
type GenerateCommitMessageResponse struct {
Message string `json:"message"`
Alternatives []string `json:"alternatives"`
}
// SummarizeChangesRequest is the request for summarizing changes
type SummarizeChangesRequest struct {
ProviderConfig *ProviderConfig `json:"provider_config,omitempty"`
RepoID int64 `json:"repo_id"`
Files []FileDiff `json:"files"`
Context string `json:"context"`
}
// SummarizeChangesResponse is the response from summarizing changes
type SummarizeChangesResponse struct {
Summary string `json:"summary"`
BulletPoints []string `json:"bullet_points"`
ImpactAssessment string `json:"impact_assessment"`
}
// IssueComment represents a comment on an issue for AI context
type IssueComment struct {
Author string `json:"author"`
Body string `json:"body"`
CreatedAt string `json:"created_at,omitempty"`
}
// GenerateIssueResponseRequest is the request for generating an AI response to an issue
type GenerateIssueResponseRequest struct {
ProviderConfig *ProviderConfig `json:"provider_config,omitempty"`
RepoID int64 `json:"repo_id"`
IssueID int64 `json:"issue_id"`
Title string `json:"title"`
Body string `json:"body"`
Comments []IssueComment `json:"comments,omitempty"`
ResponseType string `json:"response_type,omitempty"` // clarification, solution, acknowledgment
CustomInstructions string `json:"custom_instructions,omitempty"`
}
// GenerateIssueResponseResponse is the response from generating an issue response
type GenerateIssueResponseResponse struct {
Response string `json:"response"`
FollowUpQuestions []string `json:"follow_up_questions,omitempty"`
Confidence float64 `json:"confidence"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
}
// InspectWorkflowRequest is the request for inspecting a workflow file
type InspectWorkflowRequest struct {
ProviderConfig *ProviderConfig `json:"provider_config,omitempty"`
RepoID int64 `json:"repo_id"`
FilePath string `json:"file_path"`
Content string `json:"content"`
RunnerLabels []string `json:"runner_labels,omitempty"`
}
// WorkflowIssue represents an issue found in a workflow file
type WorkflowIssue struct {
Line int `json:"line"`
Severity string `json:"severity"` // "error", "warning", "info"
Message string `json:"message"`
Fix string `json:"fix,omitempty"`
}
// InspectWorkflowResponse is the response from inspecting a workflow file
type InspectWorkflowResponse struct {
Valid bool `json:"valid"`
Issues []WorkflowIssue `json:"issues"`
Suggestions []string `json:"suggestions"`
Confidence float64 `json:"confidence"`
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
}
// ExecuteTaskRequest is the request for executing a generic AI task
type ExecuteTaskRequest struct {
ProviderConfig *ProviderConfig `json:"provider_config,omitempty"`
RepoID int64 `json:"repo_id"`
Task string `json:"task"`
Context map[string]string `json:"context"`
AllowedTools []string `json:"allowed_tools,omitempty"`
}
// ExecuteTaskResponse is the response from executing a generic AI task
type ExecuteTaskResponse struct {
Success bool `json:"success"`
Result string `json:"result"`
Error string `json:"error,omitempty"`
}
// HealthCheckResponse is the response from a health check
type HealthCheckResponse struct {
Healthy bool `json:"healthy"`
Version string `json:"version"`
ProviderStatus map[string]string `json:"provider_status"`
License *LicenseInfo `json:"license,omitempty"`
}
// LicenseInfo contains AI service license information
type LicenseInfo struct {
Tier string `json:"tier"`
Customer string `json:"customer"`
ExpiresAt string `json:"expires_at"`
Features []string `json:"features"`
SeatCount int `json:"seat_count"`
IsTrial bool `json:"is_trial"`
}