ai

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatIssuesForPrompt

func FormatIssuesForPrompt(issues []models.Issue, locale string) string

FormatIssuesForPrompt formats the issue list to be included in the prompt

func FormatTemplateForPrompt

func FormatTemplateForPrompt(template *models.IssueTemplate, lang string, templateType string) string

FormatTemplateForPrompt formats a template for inclusion in an AI prompt. It handles both Issue and PR templates with proper language support.

func GetCommitPromptTemplate

func GetCommitPromptTemplate(lang string, hasTicket bool) string

GetCommitPromptTemplate returns the commit template based on language and whether there is a ticket

func GetIssueDefaultStructure added in v1.7.0

func GetIssueDefaultStructure(lang string) string

GetIssueDefaultStructure returns the default structure for issues when no template is provided

func GetIssuePromptTemplate

func GetIssuePromptTemplate(lang string) string

GetIssuePromptTemplate returns the appropriate issue generation template based on language

func GetIssueReferenceInstructions

func GetIssueReferenceInstructions(lang string) string

GetIssueReferenceInstructions returns issue reference instructions based on the language

func GetNoIssueReferenceInstruction

func GetNoIssueReferenceInstruction(locale string) string

func GetPRIssueContextInstructions

func GetPRIssueContextInstructions(locale string) string

GetPRIssueContextInstructions returns issue context instructions for PRs

func GetPRPromptTemplate

func GetPRPromptTemplate(lang string) string

GetPRPromptTemplate returns the appropriate template based on the language

func GetPRTemplateInstructions

func GetPRTemplateInstructions(lang string) string

GetPRTemplateInstructions returns PR template instructions based on the language

func GetReleaseNotesSectionHeaders

func GetReleaseNotesSectionHeaders(locale string) map[string]string

func GetReleasePromptTemplate

func GetReleasePromptTemplate(lang string) string

GetReleasePromptTemplate returns the release template based on the language

func GetTechnicalAnalysisInstruction

func GetTechnicalAnalysisInstruction(locale string) string

func GetTemplateInstructions

func GetTemplateInstructions(lang string) string

GetTemplateInstructions returns template instructions based on the language

func RenderPrompt

func RenderPrompt(name, tmplStr string, data interface{}) (string, error)

RenderPrompt renders a prompt template with the provided data

Types

type CommitSummarizer added in v1.6.0

type CommitSummarizer interface {
	// GenerateSuggestions generates a list of commit message suggestions.
	GenerateSuggestions(ctx context.Context, info models.CommitInfo, count int) ([]models.CommitSuggestion, error)
}

CommitSummarizer is an interface that defines the service to generate commit suggestions.

type ConfirmationCallback

type ConfirmationCallback func(result ConfirmationResult) (choice string, proceed bool)

type ConfirmationResult

type ConfirmationResult struct {
	EstimatedCost  float64
	InputTokens    int
	OutputTokens   int
	SuggestedModel string
	CurrentModel   string
	RationaleKey   string
}

type CostAwareAIProvider added in v1.6.0

type CostAwareAIProvider interface {
	// CountTokens counts the tokens of a prompt without making the actual model call.
	// This allows estimating the cost before executing the generation.
	CountTokens(ctx context.Context, prompt string) (int, error)

	// GetModelName returns the name of the current model (e.g.: "gemini-2.5-flash")
	GetModelName() string

	// GetProviderName returns the name of the provider (e.g.: "gemini", "openai", "anthropic")
	GetProviderName() string
}

CostAwareAIProvider defines the interface for AI providers that support cost tracking.

type CostAwareWrapper

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

func NewCostAwareWrapper

func NewCostAwareWrapper(cfg WrapperConfig) (*CostAwareWrapper, error)

NewCostAwareWrapper creates a provider-agnostic wrapper

func (*CostAwareWrapper) SetSkipConfirmation

func (w *CostAwareWrapper) SetSkipConfirmation(skip bool)

SetSkipConfirmation allows enabling or disabling manual user confirmation.

func (*CostAwareWrapper) WrapGenerate

func (w *CostAwareWrapper) WrapGenerate(
	ctx context.Context,
	command string,
	prompt string,
	generateFn GenerateFunc,
) (interface{}, *models.TokenUsage, error)

WrapGenerate wraps any generation function with tracking

type GenerateFunc

type GenerateFunc func(ctx context.Context, model string, prompt string) (interface{}, *models.TokenUsage, error)

type IssueContentGenerator added in v1.6.0

type IssueContentGenerator interface {
	// GenerateIssueContent generates the title, description, and labels of an issue
	// based on the context provided in the request.
	GenerateIssueContent(ctx context.Context, request models.IssueGenerationRequest) (*models.IssueGenerationResult, error)
}

IssueContentGenerator defines the interface to generate issue content with AI.

type PRSummarizer added in v1.6.0

type PRSummarizer interface {
	// GeneratePRSummary generates a summary of a Pull Request given a prompt.
	GeneratePRSummary(ctx context.Context, prompt string, availableLabels []string) (models.PRSummary, error)
}

PRSummarizer defines the interface for services that summarize Pull Requests.

type PromptData

type PromptData struct {
	Count           int
	Files           string
	Diff            string
	Ticket          string
	History         string
	Instructions    string
	IssueNumber     int
	RelatedIssues   string
	IssueInfo       string
	RepoOwner       string
	RepoName        string
	PreviousVersion string
	CurrentVersion  string
	LatestVersion   string
	ReleaseDate     string
	Changelog       string
	PRContent       string
	TechnicalInfo   string
}

PromptData holds the parameters for template rendering

type ReleaseNotesGenerator added in v1.6.0

type ReleaseNotesGenerator interface {
	GenerateNotes(ctx context.Context, release *models.Release) (*models.ReleaseNotes, error)
}

ReleaseNotesGenerator defines the interface to generate release notes.

type TokenCounter added in v1.6.0

type TokenCounter interface {
	CountTokens(ctx context.Context, content string) (int, error)
}

TokenCounter is a simpler interface for providers that only need to count tokens.

type WrapperConfig

type WrapperConfig struct {
	Provider              CostAwareAIProvider
	BudgetDaily           float64
	EstimatedOutputTokens int
	SkipConfirmation      bool
	OnConfirmation        ConfirmationCallback
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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