review

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package review_code implements the AI-powered code review tool.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrVertexAIMissingConfig indicates that Vertex AI is enabled but project/location configuration is missing.
	ErrVertexAIMissingConfig = fmt.Errorf("vertex AI enabled but missing configuration")

	// ErrAuthFailed indicates that no valid authentication credentials were found.
	ErrAuthFailed = fmt.Errorf("authentication failed")
)

Functions

func Register

func Register(server *mcp.Server, defaultModel string)

Register registers the code_review tool with the server.

Types

type ContentGenerator

type ContentGenerator interface {
	GenerateContent(ctx context.Context, model string, contents []*genai.Content,
		config *genai.GenerateContentConfig) (*genai.GenerateContentResponse, error)
}

ContentGenerator abstracts the generative model for testing.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler holds the dependencies for the review code tool.

func NewHandler

func NewHandler(ctx context.Context, defaultModel string, opts ...Option) (*Handler, error)

NewHandler creates a new Handler.

func (*Handler) Tool

Tool performs an AI-powered code review and returns structured data.

type Option

type Option func(*Handler)

Option is a function that configures a Handler.

func WithGenerator

func WithGenerator(generator ContentGenerator) Option

WithGenerator sets the ContentGenerator for the Handler.

type Params

type Params struct {
	FileContent string `json:"file_content"`
	ModelName   string `json:"model_name,omitempty"`
	Hint        string `json:"hint,omitempty"`
}

Params defines the input parameters for the code_review tool.

type RealGenerator

type RealGenerator struct {
	// contains filtered or unexported fields
}

RealGenerator wraps the actual GenAI client.

func (*RealGenerator) GenerateContent

func (r *RealGenerator) GenerateContent(ctx context.Context, model string, contents []*genai.Content,
	config *genai.GenerateContentConfig) (*genai.GenerateContentResponse, error)

GenerateContent generates content using the underlying GenAI client.

type Result

type Result struct {
	Suggestions []Suggestion `json:"suggestions"`
}

Result defines the structured output for the code_review tool.

type Suggestion

type Suggestion struct {
	LineNumber int    `json:"line_number"`
	Severity   string `json:"severity"` // "error", "warning", "suggestion"
	Finding    string `json:"finding"`
	Comment    string `json:"comment"`
}

Suggestion defines the structured output for a single review suggestion.

Jump to

Keyboard shortcuts

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