buildprompt

package
v0.7.15 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AggregateActivity

func AggregateActivity(repoActivities []map[string]*github.UserActivity) []*github.UserActivity

AggregateActivity merges activity maps from multiple repos into a sorted slice.

func AggregateDetails

func AggregateDetails(allDetails [][]github.ReviewCommentDetail) []github.ReviewCommentDetail

AggregateDetails flattens detail slices from multiple repos.

func BuildAnalysisPrompt

func BuildAnalysisPrompt(groups []ReviewerGroup) string

BuildAnalysisPrompt builds the prompt for Claude to analyze review patterns.

func EstimateTokenCount

func EstimateTokenCount(text string) int

EstimateTokenCount estimates the token count for a prompt using ~4 chars per token.

func FilterDetailsByReviewers

func FilterDetailsByReviewers(details []github.ReviewCommentDetail, reviewers []*github.UserActivity) []github.ReviewCommentDetail

FilterDetailsByReviewers keeps only comments from the given reviewer logins.

func FormatMarkdownReport

func FormatMarkdownReport(analysis string, detailsPath string, totalComments int, reviewers []string) string

FormatMarkdownReport formats the analysis into a markdown report.

func ResolveOrgAndRepos

func ResolveOrgAndRepos(org string, repos string, workDir string) (string, []string, error)

ResolveOrgAndRepos resolves the org and repos from flags or git remote.

func Run

func Run(ctx context.Context, opts Options, streams iostream.Streams) error

Run executes the full build-prompt pipeline: discover, analyze, generate.

func TopN

func TopN(activities []*github.UserActivity, n int) ([]*github.UserActivity, error)

TopN returns the top n activities. Returns an error if n <= 0.

func WriteDetailsJSON

func WriteDetailsJSON(details []github.ReviewCommentDetail, path string, org string, since time.Time, totalRepos int) error

WriteDetailsJSON writes the details JSON output file.

func WritePRRankingsCSV

func WritePRRankingsCSV(rankings []PRRankingRow, path string) (err error)

WritePRRankingsCSV writes the PR rankings CSV file.

Types

type DetailsJSON

type DetailsJSON struct {
	Metadata DetailsMetadata              `json:"metadata"`
	Comments []github.ReviewCommentDetail `json:"comments"`
}

DetailsJSON is the structure of the details output file.

type DetailsMetadata

type DetailsMetadata struct {
	Organization  string `json:"organization"`
	Since         string `json:"since,omitempty"`
	AnalyzedAt    string `json:"analyzedAt"`
	TotalRepos    int    `json:"totalReposAnalyzed"`
	TotalComments int    `json:"totalComments"`
}

DetailsMetadata is the metadata section of the details JSON.

type Options

type Options struct {
	Org                string
	Repos              []string
	Top                int
	Since              time.Time
	OutputPath         string
	MaxComments        int
	AnalyzeModel       string
	PromptModel        string
	IncludeAttribution bool
}

Options holds the configuration for a build-prompt run.

type OutputPaths

type OutputPaths struct {
	PromptPath   string
	DetailsPath  string
	AnalysisPath string
	CSVPath      string
}

OutputPaths holds the derived file paths for build-prompt outputs.

func DeriveOutputPaths

func DeriveOutputPaths(outputPath string) OutputPaths

DeriveOutputPaths computes the intermediate output file paths.

type PRContext

type PRContext struct {
	Number int
	Title  string
	Author string
	URL    string
	State  string
}

PRContext holds PR metadata for a comment.

type PRRankingRow

type PRRankingRow struct {
	Rank          int
	Repo          string
	PRNumber      int
	PRTitle       string
	PRAuthor      string
	PRURL         string
	TotalComments int
	ReviewerCount int
	State         string
}

PRRankingRow is a row in the PR rankings CSV.

func AggregatePRRankings

func AggregatePRRankings(details []github.ReviewCommentDetail) []PRRankingRow

AggregatePRRankings computes PR rankings sorted by total comments descending.

type ReviewCommentWithContext

type ReviewCommentWithContext struct {
	Reviewer  string
	Body      string
	DiffHunk  string
	CreatedAt string
	Repo      string
	PR        *PRContext
}

ReviewCommentWithContext is a comment with repo context for analysis.

type ReviewerGroup

type ReviewerGroup struct {
	Reviewer      string
	Comments      []ReviewCommentWithContext
	TotalComments int
}

ReviewerGroup groups comments by reviewer for analysis.

func GroupByReviewer

func GroupByReviewer(comments []github.ReviewCommentDetail) []ReviewerGroup

GroupByReviewer groups comments by reviewer login.

func LimitCommentsPerReviewer

func LimitCommentsPerReviewer(groups []ReviewerGroup, maxComments int) []ReviewerGroup

LimitCommentsPerReviewer limits each reviewer group to the most recent N comments.

Jump to

Keyboard shortcuts

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