Documentation
¶
Index ¶
- Constants
- Variables
- func BuildInsightsPrompt(data InsightsData) string
- func BuildSimple(repoPath, sha, agentName string) (string, error)
- func FormatToolAttempts(attempts []storage.Response) string
- func FormatUserComments(comments []storage.Response) string
- func GetSystemPrompt(agentName string, promptType string) string
- func IsToolResponse(r storage.Response) bool
- func LoadGuidelines(repoPath string) string
- func SplitResponses(responses []storage.Response) (toolAttempts, userComments []storage.Response)
- func WriteDiffSnapshot(repoPath, gitRef string, excludes []string) (string, func(), error)
- type AddressAttemptTemplateContext
- type AddressTemplateContext
- type Builder
- func (b *Builder) Build(repoPath, gitRef string, repoID int64, contextCount int, ...) (string, error)
- func (b *Builder) BuildAddressPrompt(repoPath string, review *storage.Review, previousAttempts []storage.Response, ...) (string, error)
- func (b *Builder) BuildDirty(repoPath, diff string, repoID int64, contextCount int, ...) (string, error)
- func (b *Builder) BuildDirtyWithSnapshot(repoPath, diff string, repoID int64, contextCount int, ...) (SnapshotResult, error)
- func (b *Builder) BuildWithAdditionalContext(repoPath, gitRef string, repoID int64, contextCount int, ...) (string, error)
- func (b *Builder) BuildWithAdditionalContextAndDiffFile(repoPath, gitRef string, repoID int64, contextCount int, ...) (string, error)
- func (b *Builder) BuildWithDiffFile(repoPath, gitRef string, repoID int64, contextCount int, ...) (string, error)
- func (b *Builder) BuildWithSnapshot(repoPath, gitRef string, repoID int64, contextCount int, ...) (SnapshotResult, error)
- type CommitFallbackContext
- type DiffContext
- type DirtyFallbackContext
- type DirtySubjectContext
- type FallbackContext
- type FallbackMode
- type GenericFallbackContext
- type HistoricalReviewContext
- type InRangeReviewTemplateContext
- type InsightsData
- type InsightsReview
- type MarkdownSection
- type PreviousReviewTemplateContext
- type PromptMeta
- type RangeEntryContext
- type RangeFallbackContext
- type RangeSubjectContext
- type ReviewAttemptTemplateContext
- type ReviewCommentTemplateContext
- type ReviewKind
- type ReviewOptionalContext
- type ReviewTemplateContext
- type SingleSubjectContext
- type SnapshotResult
- type SubjectContext
- func (s *SubjectContext) BlankNextRangeSubject() bool
- func (s SubjectContext) Clone() SubjectContext
- func (s *SubjectContext) DropLastRangeEntry() bool
- func (s *SubjectContext) TrimSingleAuthor() bool
- func (s *SubjectContext) TrimSingleMessage() bool
- func (s *SubjectContext) TrimSingleSubjectTo(maxBytes int) bool
- type SystemTemplateContext
- type TemplateContext
Constants ¶
const DiffFilePathPlaceholder = "/tmp/roborev diff placeholder"
DiffFilePathPlaceholder is a sentinel path embedded in prebuilt prompts for oversized diffs. The worker replaces it with a real diff file path at execution time so the stored prompt remains reusable across retries.
const InsightsSystemPrompt = `` /* 2418-byte string literal not displayed */
InsightsSystemPrompt is the instruction for analyzing review patterns
const MaxPromptSize = 250 * 1024
MaxPromptSize is the legacy maximum size of a prompt in bytes (250KB). New code should use Builder.maxPromptSize() which respects config.
const PreviousAttemptsHeader = `` /* 357-byte string literal not displayed */
const UserCommentsHeader = `` /* 223-byte string literal not displayed */
Variables ¶
var ErrDiffTruncatedNoFile = errors.New("diff too large to inline and no snapshot file available")
ErrDiffTruncatedNoFile is returned when the diff is too large to inline and no snapshot file path was provided. Callers should write the diff to a file and retry with BuildWithDiffFile.
Functions ¶
func BuildInsightsPrompt ¶ added in v0.49.0
func BuildInsightsPrompt(data InsightsData) string
BuildInsightsPrompt constructs the full prompt for insights analysis. It prioritizes unaddressed (open) findings over addressed (closed) ones when truncating to fit within size limits.
func BuildSimple ¶
BuildSimple constructs a simpler prompt without database context
func FormatToolAttempts ¶ added in v0.51.0
func FormatUserComments ¶ added in v0.51.0
func GetSystemPrompt ¶ added in v0.17.0
GetSystemPrompt returns the system prompt for the specified agent and type. If a specific template exists for the agent, it uses that. Otherwise, it falls back to the default templates. Supported prompt types: review, range, dirty, address, design-review, run, security
func IsToolResponse ¶ added in v0.51.0
func LoadGuidelines ¶ added in v0.49.0
LoadGuidelines loads review guidelines from the repo's default branch, falling back to filesystem config when the default branch has no .roborev.toml.
func SplitResponses ¶ added in v0.51.0
Types ¶
type AddressAttemptTemplateContext ¶ added in v0.52.0
type AddressTemplateContext ¶ added in v0.52.0
type AddressTemplateContext struct {
ProjectGuidelines *MarkdownSection
ToolAttempts []AddressAttemptTemplateContext
UserComments []AddressAttemptTemplateContext
SeverityFilter string
ReviewFindings string
OriginalDiff string
JobID int64
}
func (AddressTemplateContext) Clone ¶ added in v0.52.0
func (c AddressTemplateContext) Clone() AddressTemplateContext
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder constructs review prompts
func NewBuilderWithConfig ¶ added in v0.47.0
NewBuilderWithConfig creates a prompt builder that also resolves global config settings (e.g., exclude_patterns).
func (*Builder) Build ¶
func (b *Builder) Build(repoPath, gitRef string, repoID int64, contextCount int, agentName, reviewType, minSeverity string) (string, error)
Build constructs a review prompt for a commit or range with context from previous reviews. reviewType selects the system prompt variant (e.g., "security"); any default alias (see config.IsDefaultReviewType) uses the standard prompt.
func (*Builder) BuildAddressPrompt ¶
func (b *Builder) BuildAddressPrompt(repoPath string, review *storage.Review, previousAttempts []storage.Response, minSeverity string) (string, error)
BuildAddressPrompt constructs a prompt for addressing review findings. When minSeverity is non-empty, a severity filtering instruction is injected before the findings section.
func (*Builder) BuildDirty ¶
func (b *Builder) BuildDirty(repoPath, diff string, repoID int64, contextCount int, agentName, reviewType, minSeverity string) (string, error)
BuildDirty constructs a review prompt for uncommitted (dirty) changes. The diff is provided directly since it was captured at enqueue time. reviewType selects the system prompt variant (e.g., "security"); any default alias (see config.IsDefaultReviewType) uses the standard prompt.
func (*Builder) BuildDirtyWithSnapshot ¶ added in v0.51.0
func (b *Builder) BuildDirtyWithSnapshot(repoPath, diff string, repoID int64, contextCount int, agentName, reviewType, minSeverity string) (SnapshotResult, error)
BuildDirtyWithSnapshot builds a dirty review prompt, writing the diff to a snapshot file when it's too large to inline.
func (*Builder) BuildWithAdditionalContext ¶ added in v0.50.0
func (b *Builder) BuildWithAdditionalContext(repoPath, gitRef string, repoID int64, contextCount int, agentName, reviewType, minSeverity, additionalContext string) (string, error)
BuildWithAdditionalContext constructs a review prompt with an optional caller-provided markdown context block inserted ahead of the current diff.
func (*Builder) BuildWithAdditionalContextAndDiffFile ¶ added in v0.51.0
func (b *Builder) BuildWithAdditionalContextAndDiffFile(repoPath, gitRef string, repoID int64, contextCount int, agentName, reviewType, minSeverity, additionalContext, diffFilePath string) (string, error)
BuildWithAdditionalContextAndDiffFile constructs a review prompt with caller-provided markdown context and an optional oversized-diff file reference.
func (*Builder) BuildWithDiffFile ¶ added in v0.51.0
func (b *Builder) BuildWithDiffFile(repoPath, gitRef string, repoID int64, contextCount int, agentName, reviewType, minSeverity, diffFilePath string) (string, error)
BuildWithDiffFile constructs a review prompt where a pre-written diff file is referenced for large diffs instead of inline content.
func (*Builder) BuildWithSnapshot ¶ added in v0.51.0
func (b *Builder) BuildWithSnapshot(repoPath, gitRef string, repoID int64, contextCount int, agentName, reviewType, minSeverity string, excludes []string) (SnapshotResult, error)
BuildWithSnapshot builds a review prompt, automatically writing a diff snapshot file when the diff is too large to inline.
type CommitFallbackContext ¶ added in v0.52.0
type DiffContext ¶ added in v0.52.0
func (DiffContext) Clone ¶ added in v0.52.0
func (d DiffContext) Clone() DiffContext
func (DiffContext) HasBody ¶ added in v0.52.0
func (d DiffContext) HasBody() bool
type DirtyFallbackContext ¶ added in v0.52.0
type DirtyFallbackContext struct {
Body string
}
type DirtySubjectContext ¶ added in v0.52.0
type DirtySubjectContext struct {
Description string
}
type FallbackContext ¶ added in v0.52.0
type FallbackContext struct {
Mode FallbackMode
Text string
Commit *CommitFallbackContext
Range *RangeFallbackContext
Dirty *DirtyFallbackContext
Generic *GenericFallbackContext
}
func (FallbackContext) Clone ¶ added in v0.52.0
func (f FallbackContext) Clone() FallbackContext
func (FallbackContext) HasContent ¶ added in v0.52.0
func (f FallbackContext) HasContent() bool
func (FallbackContext) IsEmpty ¶ added in v0.52.0
func (f FallbackContext) IsEmpty() bool
func (FallbackContext) Rendered ¶ added in v0.52.0
func (f FallbackContext) Rendered() string
type FallbackMode ¶ added in v0.52.0
type FallbackMode string
const ( FallbackModeNone FallbackMode = "" FallbackModeCommit FallbackMode = "commit" FallbackModeRange FallbackMode = "range" FallbackModeDirty FallbackMode = "dirty" FallbackModeGeneric FallbackMode = "generic" )
type GenericFallbackContext ¶ added in v0.52.0
type GenericFallbackContext struct {
ViewCmd string
}
type HistoricalReviewContext ¶ added in v0.52.0
type HistoricalReviewContext struct {
SHA string
Review *storage.Review
Responses []storage.Response
}
HistoricalReviewContext holds a commit SHA and its associated review (if any) plus responses.
type InRangeReviewTemplateContext ¶ added in v0.52.0
type InRangeReviewTemplateContext struct {
Commit string
Agent string
Verdict string
Output string
Comments []ReviewCommentTemplateContext
}
type InsightsData ¶ added in v0.49.0
type InsightsData struct {
Reviews []InsightsReview
Guidelines string
RepoName string
Since time.Time
MaxReviews int // Cap for number of reviews to include
MaxOutputPerReview int // Cap for individual review output size
MaxPromptSize int // Overall prompt size budget (0 = use MaxPromptSize default)
}
InsightsData holds the data needed to build an insights prompt
type InsightsReview ¶ added in v0.49.0
type InsightsReview struct {
JobID int64
Agent string
GitRef string
Branch string
FinishedAt *time.Time
Output string
Responses []storage.Response
Closed bool
Verdict string // "P" or "F"
}
InsightsReview is a simplified review record for the insights prompt
func InsightsReviewFromJob ¶ added in v0.49.0
func InsightsReviewFromJob( job storage.ReviewJob, output string, responses []storage.Response, closed bool, ) InsightsReview
InsightsReviewFromJob converts a ReviewJob (with verdict) to an InsightsReview. The review output must be fetched separately.
type MarkdownSection ¶ added in v0.52.0
type PreviousReviewTemplateContext ¶ added in v0.52.0
type PreviousReviewTemplateContext struct {
Commit string
Output string
Comments []ReviewCommentTemplateContext
Available bool
}
type PromptMeta ¶ added in v0.52.0
type RangeEntryContext ¶ added in v0.52.0
type RangeFallbackContext ¶ added in v0.52.0
type RangeSubjectContext ¶ added in v0.52.0
type RangeSubjectContext struct {
Count int
Entries []RangeEntryContext
}
type ReviewAttemptTemplateContext ¶ added in v0.52.0
type ReviewAttemptTemplateContext struct {
Label string
Agent string
When string
Output string
Comments []ReviewCommentTemplateContext
}
type ReviewCommentTemplateContext ¶ added in v0.52.0
type ReviewKind ¶ added in v0.52.0
type ReviewKind string
const ( ReviewKindSingle ReviewKind = "single" ReviewKindRange ReviewKind = "range" ReviewKindDirty ReviewKind = "dirty" )
type ReviewOptionalContext ¶ added in v0.52.0
type ReviewOptionalContext struct {
ProjectGuidelines *MarkdownSection
AdditionalContext string
PreviousReviews []PreviousReviewTemplateContext
InRangeReviews []InRangeReviewTemplateContext
PreviousAttempts []ReviewAttemptTemplateContext
}
func (ReviewOptionalContext) Clone ¶ added in v0.52.0
func (o ReviewOptionalContext) Clone() ReviewOptionalContext
func (ReviewOptionalContext) IsEmpty ¶ added in v0.52.0
func (o ReviewOptionalContext) IsEmpty() bool
func (ReviewOptionalContext) ProjectGuidelinesBody ¶ added in v0.52.0
func (o ReviewOptionalContext) ProjectGuidelinesBody() string
func (*ReviewOptionalContext) TrimNext ¶ added in v0.52.0
func (o *ReviewOptionalContext) TrimNext() bool
type ReviewTemplateContext ¶ added in v0.52.0
type ReviewTemplateContext struct {
Kind ReviewKind
Optional ReviewOptionalContext
Subject SubjectContext
Diff DiffContext
Fallback FallbackContext
}
func (ReviewTemplateContext) Clone ¶ added in v0.52.0
func (c ReviewTemplateContext) Clone() ReviewTemplateContext
type SingleSubjectContext ¶ added in v0.52.0
type SnapshotResult ¶ added in v0.51.0
type SnapshotResult struct {
Prompt string
Cleanup func()
}
SnapshotResult holds a prompt and an optional cleanup function for a diff snapshot file.
type SubjectContext ¶ added in v0.52.0
type SubjectContext struct {
Single *SingleSubjectContext
Range *RangeSubjectContext
Dirty *DirtySubjectContext
}
func (*SubjectContext) BlankNextRangeSubject ¶ added in v0.52.0
func (s *SubjectContext) BlankNextRangeSubject() bool
func (SubjectContext) Clone ¶ added in v0.52.0
func (s SubjectContext) Clone() SubjectContext
func (*SubjectContext) DropLastRangeEntry ¶ added in v0.52.0
func (s *SubjectContext) DropLastRangeEntry() bool
func (*SubjectContext) TrimSingleAuthor ¶ added in v0.52.0
func (s *SubjectContext) TrimSingleAuthor() bool
func (*SubjectContext) TrimSingleMessage ¶ added in v0.52.0
func (s *SubjectContext) TrimSingleMessage() bool
func (*SubjectContext) TrimSingleSubjectTo ¶ added in v0.52.0
func (s *SubjectContext) TrimSingleSubjectTo(maxBytes int) bool
type SystemTemplateContext ¶ added in v0.52.0
type TemplateContext ¶ added in v0.52.0
type TemplateContext struct {
Meta PromptMeta
Review *ReviewTemplateContext
Address *AddressTemplateContext
System *SystemTemplateContext
}
func (TemplateContext) Clone ¶ added in v0.52.0
func (c TemplateContext) Clone() TemplateContext