Documentation
¶
Index ¶
- Constants
- func AutoPickCandidate(candidates []CommitCandidate) string
- func BreakingChangeHint(diff string) string
- func CommitMessageFromDiff(diff string) string
- func CopilotCLIExists(cliPath string) bool
- func DetectBreakingChange(diff string) bool
- func EnhanceText(ctx context.Context, provider Provider, system, user, fallback string) (string, bool, error)
- func FormatCandidateLabel(c CommitCandidate) string
- func FormatError(providerName string, err error) error
- func MustEnhanceText(ctx context.Context, provider Provider, system, user, fallback string) string
- func RunCopilotSession(ctx context.Context, cfg CopilotConfig, prompt string, cb SessionCallbacks) error
- type Chain
- type CommitCandidate
- type CompleteRequest
- type CompleteResponse
- type CopilotConfig
- type CopilotProvider
- type DiffCompactStats
- type OpenAIProvider
- type Provider
- type RuleFallback
- type SessionCallbacks
Constants ¶
const ModeAllowCopilotText = "allow"
ModeAllowCopilotText is the default permission mode for text-only completions.
Variables ¶
This section is empty.
Functions ¶
func AutoPickCandidate ¶ added in v0.0.14
func AutoPickCandidate(candidates []CommitCandidate) string
AutoPickCandidate chooses the best commit message without user interaction.
func BreakingChangeHint ¶
BreakingChangeHint returns a user-facing hint for breaking changes.
func CommitMessageFromDiff ¶
CommitMessageFromDiff builds a conventional-style message from a git diff.
func CopilotCLIExists ¶
CopilotCLIExists reports whether a Copilot CLI binary appears available.
func DetectBreakingChange ¶
DetectBreakingChange heuristically flags potentially breaking diffs.
func EnhanceText ¶
func EnhanceText(ctx context.Context, provider Provider, system, user, fallback string) (string, bool, error)
EnhanceText runs a completion and returns trimmed text, or the original on failure.
func FormatCandidateLabel ¶
func FormatCandidateLabel(c CommitCandidate) string
FormatCandidateLabel renders a select option label.
func FormatError ¶
FormatError wraps provider errors for CLI output.
func MustEnhanceText ¶
MustEnhanceText returns enhanced text or fallback without error.
func RunCopilotSession ¶
func RunCopilotSession(ctx context.Context, cfg CopilotConfig, prompt string, cb SessionCallbacks) error
RunCopilotSession executes a Copilot prompt and waits until the session is idle.
Types ¶
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain tries providers in order until one succeeds.
func (*Chain) Complete ¶
func (c *Chain) Complete(ctx context.Context, req CompleteRequest) (CompleteResponse, error)
type CommitCandidate ¶
CommitCandidate is one generated commit message option.
func GenerateCommitCandidates ¶
func GenerateCommitCandidates(ctx context.Context, provider Provider, diff string) ([]CommitCandidate, error)
GenerateCommitCandidates asks the provider for 3 commit message options.
type CompleteRequest ¶
CompleteRequest is a chat-style completion input.
type CompleteResponse ¶
CompleteResponse is a normalized completion output.
type CopilotConfig ¶
type CopilotConfig struct {
CLIPath string
LogLevel string
WorkingDir string
GitHubToken string
UseLoggedInUser bool
Model string
ReasoningEffort string
PermissionMode string
AutoUserAnswer string
Streaming bool
}
CopilotConfig configures the Copilot SDK client.
func DefaultCopilotConfig ¶
func DefaultCopilotConfig(workingDir string) CopilotConfig
DefaultCopilotConfig returns sensible defaults for programmatic Copilot use.
type CopilotProvider ¶
type CopilotProvider struct {
// contains filtered or unexported fields
}
CopilotProvider implements Provider using Copilot SDK text completion.
func NewCopilot ¶
func NewCopilot(cfg CopilotConfig) *CopilotProvider
NewCopilot creates a Copilot-backed Provider.
func (*CopilotProvider) Available ¶
func (p *CopilotProvider) Available() bool
func (*CopilotProvider) Complete ¶
func (p *CopilotProvider) Complete(ctx context.Context, req CompleteRequest) (CompleteResponse, error)
func (*CopilotProvider) Name ¶
func (p *CopilotProvider) Name() string
type DiffCompactStats ¶ added in v0.0.13
type DiffCompactStats struct {
OriginalBytes int
CompactBytes int
FileCount int
KeptFiles int
SkippedFiles int
Truncated bool
}
DiffCompactStats describes how a diff was reduced for AI prompts.
func CompactDiffForAI ¶ added in v0.0.13
func CompactDiffForAI(diff string) (string, DiffCompactStats)
CompactDiffForAI shrinks a git diff so commit/review prompts stay within model limits. It keeps a file list summary and truncated hunks, skipping lockfiles and binary patches.
type OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
OpenAIProvider implements Provider using an OpenAI-compatible API.
func NewOpenAI ¶
func NewOpenAI(client *utils.OpenaiClient) *OpenAIProvider
NewOpenAI wraps an existing OpenaiClient.
func OpenAIProviderFromConfig ¶
func OpenAIProviderFromConfig() *OpenAIProvider
OpenAIProviderFromConfig loads OpenAI settings from the fastgit config file and env.
func (*OpenAIProvider) Available ¶
func (p *OpenAIProvider) Available() bool
func (*OpenAIProvider) Complete ¶
func (p *OpenAIProvider) Complete(ctx context.Context, req CompleteRequest) (CompleteResponse, error)
func (*OpenAIProvider) Name ¶
func (p *OpenAIProvider) Name() string
type Provider ¶
type Provider interface {
Name() string
Available() bool
Complete(ctx context.Context, req CompleteRequest) (CompleteResponse, error)
}
Provider is the unified AI completion interface for fastgit commands.
func Default ¶
func Default(client *utils.OpenaiClient) Provider
Default builds the standard provider chain: OpenAI-compatible API, then rule fallback.
func ResolveProvider ¶
ResolveProvider picks a provider chain by name: auto|openai|copilot.
type RuleFallback ¶
type RuleFallback struct{}
RuleFallback generates deterministic text when no AI provider is available.
func NewRuleFallback ¶
func NewRuleFallback() *RuleFallback
func (*RuleFallback) Available ¶
func (p *RuleFallback) Available() bool
func (*RuleFallback) Complete ¶
func (p *RuleFallback) Complete(ctx context.Context, req CompleteRequest) (CompleteResponse, error)
func (*RuleFallback) Name ¶
func (p *RuleFallback) Name() string