prompt

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildChangelog added in v0.4.0

func BuildChangelog(c Changelog) (system, user string)

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

func BuildReview(r Review) (system, user string)

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

func BuildReviewWithTemplate(r Review, systemTemplateFile string) (system, user string, err error)

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

type Changelog struct {
	Range   string
	Commits []gitlog.Commit
	Grouped gitlog.Changelog
}

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.

Jump to

Keyboard shortcuts

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