threadcontext

package
v0.9.190 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package threadcontext normalizes inline review threads into prompt-safe domain context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SanitizeBody

func SanitizeBody(body string) string

SanitizeBody removes closed codereview marker comments and escapes any remaining marker opening so prompt-facing text cannot carry live markers.

Types

type Anchor

type Anchor struct {
	Path        string
	Side        review.DiffSide
	Line        int
	SubjectType review.AnchorKind
	CommitSHA   string
}

Anchor identifies the review-thread location.

type Comment

type Comment struct {
	ID                        gitprovider.CommentID
	ThreadID                  gitprovider.ThreadID
	Body                      string
	Author                    gitprovider.Identity
	Anchor                    Anchor
	URL                       string
	CreatedAt                 time.Time
	UpdatedAt                 time.Time
	AuthoredByPostingIdentity bool
	HasFindingMarker          bool
	HasThreadReplyMarker      bool
	HasThreadSummaryMarker    bool
	// contains filtered or unexported fields
}

Comment is one prompt-safe normalized thread comment.

type FileContext

type FileContext struct {
	Path      string
	Summaries []ThreadSummary
}

FileContext groups resolved summaries by file path.

func FileScopedResolvedSummaries

func FileScopedResolvedSummaries(threads []Thread) []FileContext

FileScopedResolvedSummaries returns compact resolved thread summaries grouped by file path.

type Options

type Options struct {
	PostingIdentity gitprovider.Identity
}

Options controls thread normalization.

type Status

type Status struct {
	CRAuthoredFinding       bool
	HasCRSummary            bool
	LatestCRComment         *Comment
	LatestHumanReplyAfterCR *Comment
	PendingHumanReply       bool
}

Status summarizes lifecycle-relevant thread state.

type Thread

type Thread struct {
	ID              gitprovider.ThreadID
	Resolved        bool
	Anchor          Anchor
	Comments        []Comment
	Status          Status
	ResolvedSummary *ThreadSummary
}

Thread is one normalized inline review thread.

func Normalize

func Normalize(threads []gitprovider.InlineThread, opts Options) ([]Thread, error)

Normalize converts provider inline threads into deterministic prompt-safe domain threads.

func PendingCRAuthoredFindingThreads

func PendingCRAuthoredFindingThreads(threads []Thread) []Thread

PendingCRAuthoredFindingThreads filters to unresolved CR-authored finding threads that have a human reply after the latest CR-authored comment.

type ThreadSummary

type ThreadSummary struct {
	ThreadID                             gitprovider.ThreadID
	Anchor                               Anchor
	URL                                  string
	Body                                 string
	LastCommentID                        gitprovider.CommentID
	LastCommentAuthor                    gitprovider.Identity
	LastCommentAuthoredByPostingIdentity bool
	LastCommentHasThreadSummaryMarker    bool
}

ThreadSummary is compact context for a resolved thread.

Jump to

Keyboard shortcuts

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