diffreview

package
v0.71.0 Latest Latest
Warning

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

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

Documentation

Overview

Package diffreview is the service behind agents' reviews of a hive session's branch diff. Any agent writes one, through the hive CLI or Hive Desktop; the desktop shows it inline in the session's Diff view.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalid = errors.New("invalid diff review")

ErrInvalid marks a review the service refuses: the message says what to fix.

Functions

This section is empty.

Types

type Changes

type Changes interface {
	ReadChanges(ctx context.Context, sess session.Session, target gitstatus.DiffTarget) (gitstatus.Changes, error)
	ReadFileDiffs(ctx context.Context, sess session.Session, target gitstatus.DiffTarget, paths []string) ([]gitstatus.FileDiff, error)
}

type CommentInput

type CommentInput struct {
	Kind      review.DiffCommentKind
	Path      string
	StartSide review.DiffSide
	StartLine int
	EndSide   review.DiffSide
	EndLine   int
	Text      string
	Severity  review.Severity
}

CommentInput is one comment as an agent writes it. A comment on rows names the first and last line, each on a side: additions numbers lines as the branch has them now, deletions as the base had them. The sides default to additions and EndLine to StartLine. Kind file comments on the whole file and takes no lines.

type Commits

type Commits interface {
	ResolveCommit(ctx context.Context, dir, rev string) (string, error)
}

type PutInput

type PutInput struct {
	SessionID string
	Author    string
	Agent     string
	Summary   string
	Comments  []CommentInput
}

type Service

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

func NewService

func NewService(logger zerolog.Logger, store review.DiffReviewStore, sessions Sessions, changes Changes, commits Commits) *Service

func (*Service) Clear

func (s *Service) Clear(ctx context.Context, sessionID, author string) (int, error)

Clear removes the session's reviews: every one, or only author's when author is set. It returns how many it removed.

func (*Service) Dismiss

func (s *Service) Dismiss(ctx context.Context, commentID string) error

Dismiss removes one comment. The review goes with its last comment.

func (*Service) DismissReview

func (s *Service) DismissReview(ctx context.Context, reviewID string) error

DismissReview removes one review and its comments.

func (*Service) Fingerprint

func (s *Service) Fingerprint(ctx context.Context) (review.DiffReviewFingerprint, error)

func (*Service) List

func (s *Service) List(ctx context.Context, sessionID string) ([]review.DiffReview, error)

List returns the session's reviews, oldest first.

func (*Service) Put

func (s *Service) Put(ctx context.Context, in PutInput) (review.DiffReview, error)

Put stores a review of the session's branch diff, replacing the author's earlier one. Every comment must name a file in that diff and, unless it is a file comment, lines that are rows of it: the desktop can only draw a comment on a row it shows. Put quotes those rows itself.

type Sessions

type Sessions interface {
	GetSession(ctx context.Context, id string) (session.Session, error)
}

Jump to

Keyboard shortcuts

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