2
0
Files
gitcaddy-server/modules/ai/types.go
logikonline 61e835358c feat(actions-manager): add AI service integration for code review and issue triage
Integrate GitCaddy AI service with support for code review, issue triage, documentation generation, code explanation, and chat interface. Add AI client module with HTTP communication, configuration settings, API routes (web and REST), service layer, and UI templates for issue sidebar. Include comprehensive configuration options in app.example.ini for enabling/disabling features and service connection settings.
2026-01-19 11:06:39 -05:00

207 lines
7.4 KiB
Go

// Copyright 2026 MarketAlly. All rights reserved.
// SPDX-License-Identifier: MIT
package ai
// 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 {
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 {
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 {
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 {
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 {
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 {
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 {
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"`
}
// 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"`
}