prompt

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Prompt

type Prompt struct {
	System string
	User   string
}

Prompt is the assembled (system, user) pair ready to hand to a Provider. Use Build to construct it.

func Build

func Build(rulesLoaded rules.Loaded, langRes lang.Resolution, diffText string) Prompt

Build assembles the system prompt (project rules + 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.

func BuildCommitMessage added in v1.2.0

func BuildCommitMessage(diffText string) Prompt

BuildCommitMessage assembles the (system, user) prompt for a commit message suggestion over the staged diff. Used with provider.Request{FreeForm: true} so the provider returns the message as plain text instead of the structured-findings JSON (ADR-0015).

func BuildPlainText added in v0.9.0

func BuildPlainText(rulesLoaded rules.Loaded, langRes lang.Resolution, diffText 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.

func (Prompt) EstimatedTokens

func (p Prompt) EstimatedTokens() int

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

func (p Prompt) ExceedsContext(contextWindow int) bool

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.

Jump to

Keyboard shortcuts

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