commitgen

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const SystemPrompt = `` /* 1111-byte string literal not displayed */

SystemPrompt is the primary instruction for the AI.

Variables

This section is empty.

Functions

func BuildPrompt

func BuildPrompt(content, extraContext string, isStat bool) string

BuildPrompt wraps the diff for the user turn of the prompt. extraContext is optional free-text appended to guide the AI. isStat indicates the content is a --stat summary rather than a full diff.

func GenerateCommitMessage

func GenerateCommitMessage(ctx context.Context, diff DiffResult, extraContext string, p Provider) (string, error)

GenerateCommitMessage builds the prompt from the staged diff and calls the provider. extraContext is optional free-text to guide the AI (can be empty).

Types

type DiffResult

type DiffResult struct {
	Content string
	IsStat  bool
}

DiffResult holds the diff content and whether it was truncated to stat-only.

func GetStagedDiff

func GetStagedDiff(ctx context.Context) (DiffResult, error)

GetStagedDiff returns the staged diff, falling back to --stat if the full diff exceeds maxDiffBytes to avoid hitting AI token limits.

type Provider

type Provider interface {
	Generate(ctx context.Context, prompt string) (string, error)
}

Provider is the interface that all AI provider implementations must satisfy. Implementations are thin adapters: they accept a fully-formed prompt and return raw text.

func NewProvider

func NewProvider(cfg ProviderConfig) (Provider, error)

NewProvider returns a Provider implementation for the given ProviderConfig. Currently supports "gemini", "openai", "ollama", and "anthropic".

func NewProviderFromEntry

func NewProviderFromEntry(entry config.CommitGenEntry) (Provider, error)

NewProviderFromEntry constructs a Provider directly from a config.CommitGenEntry, avoiding the need for callers to manually map fields into ProviderConfig.

type ProviderConfig

type ProviderConfig struct {
	Provider string
	Model    string
	APIKey   string
	Host     string // used by ollama
}

ProviderConfig holds the configuration required to construct a Provider.

Directories

Path Synopsis
provider

Jump to

Keyboard shortcuts

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