ops

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package ops implements AI-powered git operations that compose the core provider and context types from the ai package.

Package ops implements AI-powered git operations built on top of the ai provider and context subsystems.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BisectAnalysis

type BisectAnalysis struct {
	Summary    string            `json:"summary"`
	Candidates []BisectCandidate `json:"candidates"`
}

BisectAnalysis holds the AI's analysis of commits in a bisect range.

type BisectAnalyzer

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

BisectAnalyzer provides AI-enhanced bisect analysis by examining the commits and diffs between a known-good and known-bad ref.

func NewBisectAnalyzer

func NewBisectAnalyzer(registry *ai.Registry, builder *ai.Builder) *BisectAnalyzer

NewBisectAnalyzer creates a BisectAnalyzer backed by the given registry and context builder.

func (*BisectAnalyzer) Analyze

func (a *BisectAnalyzer) Analyze(ctx context.Context, good, bad string) (*BisectAnalysis, error)

Analyze examines the commits between good and bad refs, returning AI-generated probability assessments for each candidate commit.

type BisectCandidate

type BisectCandidate struct {
	Hash        string  `json:"hash"`
	Subject     string  `json:"subject"`
	Reason      string  `json:"reason"`
	Probability float64 `json:"probability"` // 0.0-1.0
}

BisectCandidate is a commit with a probability of being the culprit.

type BranchAnalyzer

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

BranchAnalyzer recommends branch cleanup actions by examining all local branches and their tracking state.

func NewBranchAnalyzer

func NewBranchAnalyzer(registry *ai.Registry, builder *ai.Builder, client git.GitClient) *BranchAnalyzer

NewBranchAnalyzer creates a BranchAnalyzer backed by the given registry, context builder, and git client (used to list branches).

func (*BranchAnalyzer) Analyze

Analyze lists all local branches, sends them to the AI provider for analysis, and returns a recommendation for each.

type BranchRecommendation

type BranchRecommendation struct {
	Name    string `json:"name"`               // Branch name
	Action  string `json:"action"`             // "keep", "delete", "archive", "rename"
	Reason  string `json:"reason"`             // Why this action was suggested
	NewName string `json:"new_name,omitempty"` // If action is "rename"
}

BranchRecommendation is the AI's suggestion for a single branch.

type ChangelogEntry

type ChangelogEntry struct {
	Category     string   `json:"category"`      // "added", "changed", "fixed", "removed", "security", "deprecated"
	Description  string   `json:"description"`   // Human-readable description
	CommitHashes []string `json:"commit_hashes"` // Related commit hashes
}

ChangelogEntry is a single changelog item.

type ChangelogGenerator

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

ChangelogGenerator produces categorized changelogs from commit ranges.

func NewChangelogGenerator

func NewChangelogGenerator(registry *ai.Registry, builder *ai.Builder) *ChangelogGenerator

NewChangelogGenerator creates a ChangelogGenerator with the given registry and context builder.

func (*ChangelogGenerator) Generate

func (g *ChangelogGenerator) Generate(ctx context.Context, fromRef, toRef string) ([]ChangelogEntry, error)

Generate creates a changelog from commits between two refs.

type CommitAction

type CommitAction struct {
	Hash       string `json:"hash"`                  // Commit hash
	Subject    string `json:"subject"`               // Original subject
	Action     string `json:"action"`                // "pick", "squash", "fixup", "reword", "drop"
	Reason     string `json:"reason"`                // Why this action was suggested
	NewSubject string `json:"new_subject,omitempty"` // If action is "reword", the suggested new subject
}

CommitAction is the AI's recommendation for a single commit during rebase.

type CommitGenerator

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

CommitGenerator generates conventional commit messages using AI.

func NewCommitGenerator

func NewCommitGenerator(registry *ai.Registry, builder *ai.Builder) *CommitGenerator

NewCommitGenerator creates a CommitGenerator with the given registry and context builder.

func (*CommitGenerator) Generate

func (g *CommitGenerator) Generate(ctx context.Context) (*CommitSuggestion, error)

Generate creates a commit message suggestion based on staged changes.

type CommitSplitter

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

CommitSplitter suggests how to split large commits into smaller, logically cohesive pieces.

func NewCommitSplitter

func NewCommitSplitter(registry *ai.Registry, builder *ai.Builder) *CommitSplitter

NewCommitSplitter creates a CommitSplitter with the given registry and context builder.

func (*CommitSplitter) Suggest

func (s *CommitSplitter) Suggest(ctx context.Context, commitHash string) (*SplitPlan, error)

Suggest analyzes a commit and suggests how to split it into smaller, logically cohesive commits.

type CommitSuggestion

type CommitSuggestion struct {
	Type    string `json:"type"`            // "feat", "fix", "docs", "style", "refactor", "test", "chore"
	Scope   string `json:"scope,omitempty"` // Optional scope like "auth", "api"
	Subject string `json:"subject"`         // Short commit subject line (50 chars max)
	Body    string `json:"body,omitempty"`  // Optional extended description
}

CommitSuggestion holds an AI-generated commit message.

func (*CommitSuggestion) String

func (s *CommitSuggestion) String() string

String formats the suggestion as a conventional commit message (e.g. "feat(auth): add login endpoint").

type ConflictResolution

type ConflictResolution struct {
	// File is the repository-relative path of the conflicted file.
	File string
	// FullResolved is the complete file content with all conflict markers
	// replaced by the AI's resolutions.
	FullResolved string
	// Regions contains the AI's resolution for each conflict region.
	Regions []ResolvedRegion
}

ConflictResolution holds the AI's resolution for a conflicted file.

type ConflictResolver

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

ConflictResolver uses AI to resolve merge conflicts.

func NewConflictResolver

func NewConflictResolver(registry *ai.Registry, builder *ai.Builder) *ConflictResolver

NewConflictResolver creates a resolver that uses the given registry to obtain an AI provider and the builder to construct conflict context.

func (*ConflictResolver) Resolve

func (r *ConflictResolver) Resolve(ctx context.Context, files []string) ([]ConflictResolution, error)

Resolve resolves conflicts in the given files using AI. Returns one ConflictResolution per file that has conflicts.

type PRDescription

type PRDescription struct {
	Title           string   `json:"title"`                      // PR title
	Summary         string   `json:"summary"`                    // Brief summary
	TestingNotes    string   `json:"testing_notes,omitempty"`    // How to test
	FullMarkdown    string   `json:"-"`                          // Complete PR description in markdown
	Changes         []string `json:"changes"`                    // List of changes made
	BreakingChanges []string `json:"breaking_changes,omitempty"` // Breaking changes, if any
}

PRDescription holds the AI-generated PR metadata.

type PRDescriptionGenerator

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

PRDescriptionGenerator creates AI-powered PR descriptions.

func NewPRDescriptionGenerator

func NewPRDescriptionGenerator(registry *ai.Registry, builder *ai.Builder) *PRDescriptionGenerator

NewPRDescriptionGenerator creates a PRDescriptionGenerator backed by the given provider registry and context builder.

func (*PRDescriptionGenerator) Generate

func (g *PRDescriptionGenerator) Generate(ctx context.Context, targetBranch string) (*PRDescription, error)

Generate creates a PR description for the current branch vs target.

type RebaseAssistant

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

RebaseAssistant provides AI-powered rebase suggestions by analyzing commits on the current branch relative to the target ("onto") ref.

func NewRebaseAssistant

func NewRebaseAssistant(registry *ai.Registry, builder *ai.Builder) *RebaseAssistant

NewRebaseAssistant creates a RebaseAssistant backed by the given registry and context builder.

func (*RebaseAssistant) Suggest

func (a *RebaseAssistant) Suggest(ctx context.Context, onto string) (*RebaseSuggestion, error)

Suggest analyzes the commits between the "onto" ref and HEAD, returning AI-generated recommendations for each commit's rebase action.

type RebaseSuggestion

type RebaseSuggestion struct {
	Commits []CommitAction `json:"commits"`
}

RebaseSuggestion holds the AI's recommendations for a rebase.

type ResolvedRegion

type ResolvedRegion struct {
	// OriginalRegion is the conflict region from the original file.
	OriginalRegion ai.ConflictRegion
	// Resolution is the resolved content for this region.
	Resolution string
	// Explanation describes why the AI chose this resolution.
	Explanation string
	// Confidence is a score from 0.0 to 1.0 indicating the AI's certainty.
	Confidence float64
}

ResolvedRegion contains the AI's resolution for a single conflict region.

type ReviewFinding

type ReviewFinding struct {
	File       string `json:"file"`                 // File path
	Severity   string `json:"severity"`             // "error", "warning", "info", "hint"
	Category   string `json:"category"`             // "security", "bug", "performance", "style", "test"
	Message    string `json:"message"`              // Human-readable description
	Suggestion string `json:"suggestion,omitempty"` // Suggested fix (optional)
	Line       int    `json:"line"`                 // Line number in the new version
}

ReviewFinding is a single code review annotation.

type Reviewer

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

Reviewer performs AI-powered code review on diffs.

func NewReviewer

func NewReviewer(registry *ai.Registry, builder *ai.Builder) *Reviewer

NewReviewer creates a Reviewer backed by the given provider registry and context builder.

func (*Reviewer) Review

func (r *Reviewer) Review(ctx context.Context, opts git.DiffOpts) ([]ReviewFinding, error)

Review performs an AI code review on the given diff and returns a list of findings sorted by severity (error > warning > info > hint).

type SplitPiece

type SplitPiece struct {
	CommitMessage string   `json:"commit_message"` // Suggested commit message
	Reason        string   `json:"reason"`         // Why these files are grouped
	Files         []string `json:"files"`          // Files in this piece
	Order         int      `json:"order"`          // Suggested commit order
}

SplitPiece is one logical grouping of changes.

type SplitPlan

type SplitPlan struct {
	OriginalHash string       `json:"original_hash"`
	Pieces       []SplitPiece `json:"pieces"`
}

SplitPlan is the AI's recommendation for splitting a commit.

Jump to

Keyboard shortcuts

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