Documentation
¶
Overview ¶
Package prcontext discovers and condenses PR-specific context — comments, prior reviews, CI status, prior AI reviews — into a small briefing that is injected into every review-pass system prompt.
Why this exists:
PR review prompts historically told the model to call gh_pr_comments, get_review, gh_pr_checks at request time. Two problems with that:
- Tools the harness exposes are not available to providers like Claude Code, which run their own internal tool loops.
- Tool-based fetching pays a round-trip per phase. Multi-pass review (batch → synthesis → recheck) re-fetches the same data each phase.
This package follows the same pattern as internal/project (the project context layer): gather raw inputs, hash them for cache invalidation, summarize with the cheap/fast LLM into a small dense briefing, persist to state, inject into prompts.
The hash is deliberately conservative — comment body content, review body content, label set, CI rollup, and prior-review JSON all contribute. If GitHub's `updated_at` glitches or we miss a field, the content hash still catches the change.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Brief ¶
type Brief struct {
// Summary is the rendered briefing, ready for injection into a
// review prompt's PR Context section. Empty when no inputs were
// available (no comments, no prior review) AND nothing was worth
// surfacing — in that case the caller should skip injection.
Summary string
// InputHash is a SHA-256 hash of the raw inputs used to generate
// the summary. Used for cache invalidation.
InputHash string
// FromCache indicates whether the result was loaded from cache.
// When true, Summary will be empty — the caller is expected to use
// the cached summary from state.GetPRBrief().
FromCache bool
}
Brief is the final output of a PR-context discovery pass.
func BuildPRBrief ¶
func BuildPRBrief( ctx context.Context, fastClient ai.Client, pr *git.PullRequest, reviewState *state.State, cachedHash string, onProgress func(string), ) (*Brief, error)
BuildPRBrief gathers PR-specific context and either returns a cached brief (when the input hash matches) or runs the fast LLM to summarize.
Failures are never fatal — on any single error (gh unauthenticated, LLM failure), we log and return an empty Brief. The caller proceeds with the review using whatever context they already have.