Documentation
¶
Index ¶
- Constants
- func ParseMessages(raw string, n int) []string
- func ValidCommitTypes() []string
- type CommitOptions
- type CommitType
- type Prompt
- func Build(rulesLoaded rules.Loaded, langRes lang.Resolution, ...) Prompt
- func BuildCommitMessage(diffText string, opts CommitOptions) Prompt
- func BuildPlainText(rulesLoaded rules.Loaded, langRes lang.Resolution, ...) Prompt
- func BuildSummary(diffText, manifest string, langRes lang.Resolution, withContext bool) Prompt
Constants ¶
const MessageDelimiter = "<<<commitbrief-msg>>>"
MessageDelimiter is the sentinel line the model is told to emit between consecutive messages when more than one is requested (--generate N). It is deliberately unlikely to appear inside a real commit message so the parser can split multi-line (body-carrying) messages cleanly.
Variables ¶
This section is empty.
Functions ¶
func ParseMessages ¶ added in v1.5.0
ParseMessages splits a FreeForm commit-message response into individual messages. It splits on MessageDelimiter, trims each block, strips stray code fences / wrapping quotes, drops empties, and caps the result at n. Best-effort by design (ADR-0015): if the model ignored the delimiter for an n>1 request the caller gets fewer messages and surfaces that, rather than this rejecting the response.
func ValidCommitTypes ¶ added in v1.5.0
func ValidCommitTypes() []string
ValidCommitTypes returns the accepted --type / commit.type values in canonical order, for flag help and the "invalid type" error message.
Types ¶
type CommitOptions ¶ added in v1.5.0
type CommitOptions struct {
Type CommitType
Count int
}
CommitOptions parameterizes the commit-message prompt: the output format and how many distinct messages to generate in the single call.
type CommitType ¶ added in v1.5.0
type CommitType string
CommitType selects the shape of a generated commit message. The set is closed and validated at the CLI layer (the `commit` command's --type flag / commit.type config) via ParseCommitType. plain is the default.
const ( CommitPlain CommitType = "plain" CommitConventional CommitType = "conventional" CommitConventionalBody CommitType = "conventional+body" CommitGitmoji CommitType = "gitmoji" CommitSubjectBody CommitType = "subject+body" )
func ParseCommitType ¶ added in v1.5.0
func ParseCommitType(s string) (CommitType, bool)
ParseCommitType validates s against the closed set, returning the typed value and ok=false on an unknown token (CLI surfaces an error then).
type Prompt ¶
Prompt is the assembled (system, user) pair ready to hand to a Provider. Use Build to construct it.
func Build ¶
Build assembles the system prompt (project rules + optional architecture constraints + severity rubric + JSON response contract + lang directive + prompt-injection guard) and the user prompt (diff fenced block). OUTPUT.md is no longer part of prompt construction — under ADR-0014 it is a client-side renderer template consumed only by the local Go runtime.
archContext (ADR-0030) is the rendered architecture-constraints block from internal/arch; pass "" to omit it entirely (no architecture.json, or the feature disabled). It folds into the system prompt and therefore into the SHA-256 cache key, so changing architecture.json invalidates stale reviews.
func BuildCommitMessage ¶ added in v1.2.0
func BuildCommitMessage(diffText string, opts CommitOptions) Prompt
BuildCommitMessage assembles the (system, user) prompt for a commit message suggestion over the staged diff (ADR-0015 / ADR-0019). It is used with provider.Request{FreeForm: true} so providers return the message as plain text instead of the structured-findings JSON.
It deliberately does NOT inject the project's COMMITBRIEF.md review rules — those govern critique, not authoring — so the prompt stays small and its cost predictable. The diff is fenced as data with an explicit prompt- injection guard. Messages are always written in English regardless of the review --lang (a deliberate ADR-0019 constraint).
func BuildPlainText ¶ added in v0.9.0
func BuildPlainText(rulesLoaded rules.Loaded, langRes lang.Resolution, diffText, archContext string, withContext bool) Prompt
BuildPlainText is the prompt variant for CLI-backed providers (claude-cli, gemini-cli, codex-cli). Same project rules + severity rubric, but swaps the JSON-contract response format for a fixed plain-text layout. Used by review.go when the active provider satisfies provider.PlainTextEmitter.
When withContext is true (the --with-context flag, ADR-0017), the system prompt gains a section telling the agentic host CLI it may read surrounding project files to ground the review. It is appended only for the CLI path; API providers (Build) have no filesystem and never see it.
archContext (ADR-0030) is threaded through the same way as in Build.
func BuildSummary ¶ added in v1.6.0
func BuildSummary(diffText, manifest string, langRes lang.Resolution, withContext bool) Prompt
BuildSummary assembles the (system, user) prompt for the `commitbrief summary` command: a human-readable, area-grouped explanation of a set of changes (ADR-0020). It is used with provider.Request{FreeForm: true} so providers return prose instead of the structured-findings JSON the review path contracts.
Like BuildCommitMessage it deliberately does NOT inject the project's COMMITBRIEF.md review rules — those govern critique, not narration. The diff (and the optional commit manifest) are fenced as data with an explicit prompt-injection guard. The summary is written in the resolved output language (langRes), so `--lang tr` yields a Turkish summary.
manifest is the pre-formatted commit table (short hash + subject/body + touched files) for a range, or "" for staged/unstaged scopes that have no commits yet. When empty, the model is told to omit per-line attribution.
withContext appends the project-context section (ADR-0017) for CLI-backed providers, telling the agentic host CLI it may read files beyond the diff to ground the summary. The cli layer only sets it once it has verified the active provider is a PlainTextEmitter, so it is never appended for an API provider (which has no filesystem to read).
func (Prompt) EstimatedTokens ¶
EstimatedTokens uses the chars/4 heuristic shared with internal/diff. Provider-side token counts override this; the value is intended for pre-flight checks and dry-run reporting.
func (Prompt) ExceedsContext ¶
ExceedsContext reports whether the estimated token count is larger than the provider's reported context window. Callers should branch on this before sending a request so users get a friendlier error than a provider-side 400.