aireview

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package aireview provides AI-powered code review functionality.

Index

Constants

View Source
const DefaultModel = "claude-sonnet-4"

DefaultModel is the default LLM model to use.

Variables

This section is empty.

Functions

func BuildPrompt

func BuildPrompt(scope Scope, prTitle, prBody, diff string) string

BuildPrompt constructs the full prompt for a code review.

func BuildSystemPrompt

func BuildSystemPrompt() string

BuildSystemPrompt returns the system prompt for the LLM.

func BuildUserPrompt

func BuildUserPrompt(scope Scope, prTitle, prBody, diff string) string

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

func IsValidScope(s string) bool

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.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default configuration.

type ReviewInput

type ReviewInput struct {
	Title string
	Body  string
	Diff  string
}

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

func NewReviewer(cfg Config) (*Reviewer, error)

NewReviewer creates a new AI reviewer with the given configuration.

func (*Reviewer) Close

func (r *Reviewer) Close() error

Close releases resources held by the reviewer.

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.

func ValidScopes

func ValidScopes() []Scope

ValidScopes returns all valid review scopes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL