Documentation
¶
Overview ¶
Package aireview provides AI-powered code review functionality.
Index ¶
- Constants
- func BuildPrompt(scope Scope, prTitle, prBody, diff string) string
- func BuildSystemPrompt() string
- func BuildUserPrompt(scope Scope, prTitle, prBody, diff string) string
- func GetModelFromEnv() string
- func IsValidScope(s string) bool
- type Config
- type ReviewInput
- type ReviewOutput
- type Reviewer
- type Scope
Constants ¶
const DefaultModel = "claude-sonnet-4"
DefaultModel is the default LLM model to use.
Variables ¶
This section is empty.
Functions ¶
func BuildPrompt ¶
BuildPrompt constructs the full prompt for a code review.
func BuildSystemPrompt ¶
func BuildSystemPrompt() string
BuildSystemPrompt returns the system prompt for the LLM.
func BuildUserPrompt ¶
BuildUserPrompt constructs the user message for a code review.
func GetModelFromEnv ¶
func GetModelFromEnv() string
GetModelFromEnv returns the model from environment variable or default.
func IsValidScope ¶
IsValidScope checks if a scope string is valid.
Types ¶
type Config ¶
type Config struct {
// Model is the LLM model to use (e.g., "claude-sonnet-4", "gpt-4o").
Model string
// Scope is the review focus (full, security, style, performance).
Scope Scope
// MaxTokens is the maximum response length.
MaxTokens int
}
Config holds configuration for AI reviews.
type ReviewInput ¶
ReviewInput contains the PR information for review.
type ReviewOutput ¶
type ReviewOutput struct {
// Content is the full review text.
Content string
// Verdict is the recommended action (APPROVE, COMMENT, REQUEST_CHANGES).
Verdict string
// TokensUsed is the total tokens consumed.
TokensUsed int
}
ReviewOutput contains the AI-generated review.
type Reviewer ¶
type Reviewer struct {
// contains filtered or unexported fields
}
Reviewer performs AI-powered code reviews.
func NewReviewer ¶
NewReviewer creates a new AI reviewer with the given configuration.
func (*Reviewer) Review ¶
func (r *Reviewer) Review(ctx context.Context, input ReviewInput) (*ReviewOutput, error)
Review performs an AI code review on the given PR.
type Scope ¶
type Scope string
Scope represents the focus area for a code review.
const ( // ScopeFull performs a comprehensive review covering all aspects. ScopeFull Scope = "full" // ScopeSecurity focuses on security vulnerabilities and risks. ScopeSecurity Scope = "security" // ScopeStyle focuses on code style, readability, and best practices. ScopeStyle Scope = "style" // ScopePerformance focuses on performance issues and optimizations. ScopePerformance Scope = "performance" )
func GetScopeFromEnv ¶
func GetScopeFromEnv() Scope
GetScopeFromEnv returns the scope from environment variable or default.