review

package
v0.0.0-...-cb3f5c8 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BranchContext

type BranchContext struct {
	RepoRoot   string
	Branch     string
	BaseBranch string
	Files      []FileChange
	Stats      DiffStats
	Diff       string
	Unstaged   string
	RecentLog  string
	AgentsMD   string
}

BranchContext contains context for branch review.

func AssembleBranchContext

func AssembleBranchContext(opts BranchContextOptions) (*BranchContext, *transparency.ContextAudit, error)

AssembleBranchContext gathers context for branch review.

type BranchContextOptions

type BranchContextOptions struct {
	MaxDiffBytes    int
	IncludeUnstaged bool
	IncludeAgents   bool
	BaseBranch      string // Defaults to main or master
}

BranchContextOptions configures branch context assembly.

func DefaultBranchContextOptions

func DefaultBranchContextOptions() BranchContextOptions

DefaultBranchContextOptions returns sensible defaults.

type DiffStats

type DiffStats struct {
	Files      int
	Insertions int
	Deletions  int
}

DiffStats contains diff statistics.

func (DiffStats) TotalChanges

func (ds DiffStats) TotalChanges() int

TotalChanges returns total lines changed.

type FileChange

type FileChange struct {
	Status  string
	Path    string
	OldPath string
}

FileChange represents a file change.

type Finding

type Finding struct {
	ID           string   // e.g., "FINDING-001"
	Severity     Severity // CRITICAL, MAJOR, MINOR
	Title        string   // Brief description
	File         string   // File path
	Line         int      // Line number (0 if not specified)
	Evidence     string   // Proof of the issue
	Impact       string   // Business/technical impact
	Fix          string   // Description of fix
	SuggestedFix string   // Code block with suggested fix
}

Finding represents a single issue found during review.

type FixResult

type FixResult struct {
	// Summary describes what was changed
	Summary string

	// FilesChanged lists files that were modified
	FilesChanged []string

	// Trace contains transparency data
	Trace *transparency.Trace

	// Error if fix failed
	Error error
}

FixResult contains the result of fixing a finding.

type Grade

type Grade string

Grade represents the overall review grade.

const (
	GradeA Grade = "A"
	GradeB Grade = "B"
	GradeC Grade = "C"
	GradeD Grade = "D"
	GradeF Grade = "F"
)

type PRCheck

type PRCheck struct {
	Name       string
	Status     string
	Conclusion string
}

PRCheck represents a CI check result.

type PRComment

type PRComment struct {
	Author string
	Body   string
	Path   string // For review comments
	Line   int
}

PRComment represents a PR comment.

type PRContext

type PRContext struct {
	PR       *PRInfo
	Diff     string
	Comments []PRComment
	Checks   []PRCheck
	Files    []string
}

PRContext contains context for PR review.

func AssemblePRContext

func AssemblePRContext(prRef string) (*PRContext, *transparency.ContextAudit, error)

AssemblePRContext gathers context for PR review using gh CLI.

type PRInfo

type PRInfo struct {
	Number       int
	Title        string
	Author       string
	State        string
	URL          string
	Body         string
	CIStatus     string
	Labels       []string
	BaseBranch   string
	HeadBranch   string
	Additions    int
	Deletions    int
	ChangedFiles int
}

PRInfo contains parsed PR metadata.

type PRTools

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

PRTools provides tools for PR review verification.

func NewPRTools

func NewPRTools(prCtx *PRContext) *PRTools

NewPRTools creates PR tools with the given context.

func (*PRTools) Definitions

func (p *PRTools) Definitions() []tools.Definition

Definitions returns the tool definitions for PR review.

func (*PRTools) Execute

func (p *PRTools) Execute(name string, args json.RawMessage) (string, error)

Execute runs a PR tool and returns its output.

type ParsedReview

type ParsedReview struct {
	Grade       Grade
	Summary     string
	BuildStatus string
	TestStatus  string
	Findings    []Finding
	Remarks     []string
	Approved    bool
	Blockers    []string // Finding IDs
	Suggestions []string // Finding IDs
	RawReview   string
}

ParsedReview contains the structured review data.

func ParseReview

func ParseReview(review string) *ParsedReview

ParseReview extracts structured data from review markdown.

func (*ParsedReview) BlockingFindings

func (p *ParsedReview) BlockingFindings() []Finding

BlockingFindings returns findings that block approval (Critical + Major).

func (*ParsedReview) CriticalFindings

func (p *ParsedReview) CriticalFindings() []Finding

CriticalFindings returns only critical severity findings.

func (*ParsedReview) FindingByID

func (p *ParsedReview) FindingByID(id string) *Finding

FindingByID returns a finding by its ID.

func (*ParsedReview) HasBlockers

func (p *ParsedReview) HasBlockers() bool

HasBlockers returns true if there are blocking findings.

func (*ParsedReview) MajorFindings

func (p *ParsedReview) MajorFindings() []Finding

MajorFindings returns only major severity findings.

func (*ParsedReview) MinorFindings

func (p *ParsedReview) MinorFindings() []Finding

MinorFindings returns only minor severity findings.

type ProjectContext

type ProjectContext struct {
	RepoRoot    string
	Branch      string
	Tree        string
	GoMod       string
	PackageJSON string
	ReadmeMD    string
	AgentsMD    string
	RecentLog   string
}

ProjectContext contains context for project review.

func AssembleProjectContext

func AssembleProjectContext(opts ProjectContextOptions) (*ProjectContext, *transparency.ContextAudit, error)

AssembleProjectContext gathers context for project review.

type ProjectContextOptions

type ProjectContextOptions struct {
	MaxTreeDepth  int
	IncludeAgents bool
}

ProjectContextOptions configures project context assembly.

func DefaultProjectContextOptions

func DefaultProjectContextOptions() ProjectContextOptions

DefaultProjectContextOptions returns sensible defaults.

type RunResult

type RunResult struct {
	// Review is the generated review (markdown)
	Review string

	// Parsed contains the structured review data (populated by Parse())
	Parsed *ParsedReview

	// Trace contains transparency data
	Trace *transparency.Trace

	// ContextAudit shows what context was sent
	ContextAudit *transparency.ContextAudit

	// PRInfo contains PR metadata (for PR reviews)
	PRInfo *PRInfo

	// Error if generation failed
	Error error
}

RunResult contains the results of a review.

func (*RunResult) Parse

func (r *RunResult) Parse() *ParsedReview

Parse parses the review markdown into structured data.

type Runner

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

Runner executes the review flow.

func NewRunner

func NewRunner(cfg RunnerConfig) *Runner

NewRunner creates a review runner. If Models and Registry are provided, uses RLM for full tool access. Otherwise falls back to legacy invoker with limited tools.

func (*Runner) FixFinding

func (r *Runner) FixFinding(ctx context.Context, finding *Finding, prompt string) (*FixResult, error)

FixFinding applies a fix for a single finding using RLM.

func (*Runner) ReviewBranch

func (r *Runner) ReviewBranch(ctx context.Context, opts BranchContextOptions) (*RunResult, error)

ReviewBranch reviews the current branch against base using the full tool ecosystem.

func (*Runner) ReviewPR

func (r *Runner) ReviewPR(ctx context.Context, prRef string) (*RunResult, error)

ReviewPR reviews a remote PR using gh CLI.

func (*Runner) ReviewProject

func (r *Runner) ReviewProject(ctx context.Context, opts ProjectContextOptions) (*RunResult, error)

ReviewProject reviews the project as a whole using the full tool ecosystem.

type RunnerConfig

type RunnerConfig struct {
	// For RLM-based execution (preferred)
	Models   *model.Manager
	Registry *tool.Registry
	ModelID  string

	// Legacy config (used if Models not provided)
	Invoker *oneshot.DefaultInvoker
	Ledger  *transparency.CostLedger
}

RunnerConfig configures the review runner.

type Severity

type Severity string

Severity levels for findings.

const (
	SeverityCritical Severity = "CRITICAL"
	SeverityMajor    Severity = "MAJOR"
	SeverityMinor    Severity = "MINOR"
)

type VerificationTools

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

VerificationTools provides read-only tools for code review verification.

func NewVerificationTools

func NewVerificationTools(workDir string) *VerificationTools

NewVerificationTools creates verification tools rooted at workDir.

func (*VerificationTools) Definitions

func (v *VerificationTools) Definitions() []tools.Definition

Definitions returns the tool definitions for verification.

func (*VerificationTools) Execute

func (v *VerificationTools) Execute(name string, args json.RawMessage) (string, error)

Execute runs a verification tool and returns its output.

Jump to

Keyboard shortcuts

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