commit

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultModel = "claude-sonnet-4-6"

Variables

View Source
var (
	ErrMissingAPIKey     = errors.New("missing API key")
	ErrProviderRequest   = errors.New("provider request failed")
	ErrMalformedResponse = errors.New("malformed provider response")
	ErrUnstagedChanges   = errors.New("unstaged changes present alongside staged changes")
)

Functions

func BuildPrompt

func BuildPrompt(diff string, files []model.FileSummary) string

BuildPrompt constructs a deterministic prompt from a staged-only diff and file summaries.

func CheckStagingGuard

func CheckStagingGuard(ctx context.Context, git gitexec.GitRunner) error

CheckStagingGuard returns ErrUnstagedChanges when unstaged or untracked changes are present alongside staged changes.

func CollectStagedSnapshot

func CollectStagedSnapshot(ctx context.Context, git gitexec.GitRunner) (string, []model.FileSummary, error)

CollectStagedSnapshot returns the staged-only diff text and parsed file summaries.

func PrepareEditorCmd

func PrepareEditorCmd(message string) (cmd *exec.Cmd, tmpPath string, err error)

PrepareEditorCmd writes message to a temp file and returns an exec.Cmd that opens $EDITOR (or "vi" as fallback) on that file. The caller must call cleanup() after reading the edited result.

func ReadEditedMessage

func ReadEditedMessage(path string) (string, error)

ReadEditedMessage reads a file path and returns its trimmed content.

Types

type ClaudeProvider

type ClaudeProvider struct {
	// contains filtered or unexported fields
}

ClaudeProvider generates commit messages using the Anthropic Messages API.

func NewClaudeProvider

func NewClaudeProvider(apiKey string, modelOverride string, opts ...option.RequestOption) (*ClaudeProvider, error)

NewClaudeProvider creates a ClaudeProvider. If apiKey is empty, ANTHROPIC_API_KEY is read from the environment. Pass option.WithBaseURL for testing.

func (*ClaudeProvider) Generate

func (p *ClaudeProvider) Generate(ctx context.Context, diff string, files []model.FileSummary) (string, error)

Generate sends the diff and file summaries to Claude and returns the commit message.

type CommitMessageProvider

type CommitMessageProvider interface {
	Generate(ctx context.Context, diff string, files []model.FileSummary) (string, error)
}

CommitMessageProvider generates commit messages from diffs.

type Executor

type Executor struct {
	Git gitexec.GitRunner
}

Executor runs git commit with a given message.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, message string) (string, error)

Execute runs git commit -m and returns the resulting short SHA.

Jump to

Keyboard shortcuts

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