Documentation
¶
Overview ¶
Package prompt builds LLM prompts from git history.
The default review system prompt is embedded from templates/review_system.tmpl (byte-identical to the historical hardcoded string). Custom user templates (text/template) can override it via BuildReviewWithTemplate (Item 3). The template requires the model to end with a fenced `risk` JSON block (§7.1), parsed back in internal/llm.
Index ¶
- func BuildChangelog(c Changelog) (system, user string)
- func BuildChangelogWithTemplate(c Changelog, systemTemplateFile string) (system, user string, err error)
- func BuildReview(r Review) (system, user string)
- func BuildReviewWithTemplate(r Review, systemTemplateFile string) (system, user string, err error)
- type Changelog
- type Review
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildChangelog ¶ added in v0.4.0
BuildChangelog renders the system and user messages for an AI changelog using the embedded default system prompt (equivalent to BuildChangelogWithTemplate(c, "")).
func BuildChangelogWithTemplate ¶ added in v0.4.0
func BuildChangelogWithTemplate(c Changelog, systemTemplateFile string) (system, user string, err error)
BuildChangelogWithTemplate renders the system prompt from a custom template file, mirroring BuildReviewWithTemplate. If systemTemplateFile is empty the embedded default is used. Otherwise the file is parsed as a text/template and executed with the Changelog as data (fields Range, Commits, Grouped). The user message is built identically in both cases.
func BuildReview ¶
BuildReview renders the system and user messages for a review. The user message carries the commit metadata (subjects, authors, bodies, file lists) followed by the full unified diff in a fenced block. It uses the embedded default system prompt (equivalent to BuildReviewWithTemplate(r, "")).
func BuildReviewWithTemplate ¶ added in v0.2.1
BuildReviewWithTemplate renders the system prompt from a custom template file. If systemTemplateFile is empty, the embedded default is used (identical to BuildReview). Otherwise the file is parsed as a text/template and executed with the Review as data (fields Range, Commits, Diff). The user message is built identically in both cases.
Types ¶
type Changelog ¶ added in v0.4.0
Changelog is the input for building a `changelog --ai` prompt: the raw commit list plus the deterministic categorization, which the model receives as a starting point (it rewrites prose and may reclassify significant non-conventional commits out of Other).
type Review ¶
type Review struct {
Range string
Commits []gitlog.Commit
Diff string
// Staged marks a review of staged (indexed, not yet committed) changes:
// there is no revision range and no commit metadata, only the diff. The
// user message then carries an explicit "staged changes" note instead of
// the range/commit sections. Zero value keeps the historical range-based
// prompt byte-identical.
Staged bool
}
Review is the input for building a review prompt.