package
0.2.0
Repository: https://github.com/mgla96/snappr.git
Documentation: pkg.go.dev

# Packages

No description provided by the author

# README

app

import "github.com/Mgla96/snappr/internal/app"

Package app provides the main business logic for the snappr application.

Index

Constants

const (
    ErrUnmarshalLLMResponse = errors.New("error unmarshalling LLM response")
    ErrMissingGHToken       = errors.New("GH_TOKEN environment variable is required. Please set it before running this command")
    ErrMissingLLMToken      = errors.New("LLM_TOKEN environment variable is required. Please set it before running this command")
)

const (
    KnowledgeSourceTypeFile KnowledgeSourceType = "file"
    KnowledgeSourceTypeURL  KnowledgeSourceType = "url"
    KnowledgeSourceTypeAPI  KnowledgeSourceType = "api"
    KnowledgeSourceTypeText KnowledgeSourceType = "text"
    NotImplementedMessage   string              = "Not implemented"
)

func CheckGHToken

func CheckGHToken() error

CheckGHToken checks if the GH_TOKEN environment variable is set.

func CheckLLMToken

func CheckLLMToken() error

CheckLLMToken checks if the LLM_TOKEN environment variable is set.

func CheckTokens

func CheckTokens() error

func GetWorkflowByName

func GetWorkflowByName(name string, workflowList []config.PromptWorkflow) *config.PromptWorkflow

GetWorkflowByName returns workflow information by name from a list of workflows.

func NewDefaultPromptAndKnowledgeConfig

func NewDefaultPromptAndKnowledgeConfig(configPath string) error

NewDefaultPromptAndKnowledgeConfig creates a config.yaml file with the default prompt and knowledge config.

func RetrieveKnowledge

func RetrieveKnowledge(sourceName string, knowledgeSources []KnowledgeSource) (string, error)

type App

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

func New

func New(cfg *config.Config, githubClient githubClient, llmClient llmClient, logger zerolog.Logger) *App

New creates a new instance of the App.

func Setup

func Setup() (*App, error)

Setup sets up the application utilizing environment variables.

func SetupNoEnv

func SetupNoEnv(cfg *config.Config) *App

SetupNoEnv sets up the application from a config struct instead of utilizing environment variables.

func (*App) ExecuteCreatePR

func (a *App) ExecuteCreatePR(ctx context.Context, commitSHA, branch, workflowName, fileRegexPattern string, printOnly bool) error

ExecuteCreatePR executes the create PR workflow.

func (*App) ExecutePRReview

func (a *App) ExecutePRReview(ctx context.Context, commitSHA string, prNumber int, workflowName, fileRegexPattern string, printOnly bool) error

ExecutePRReview executes the PR review workflow.

type FileChange

type FileChange struct {
    Path        string `json:"path"`
    FullContent string `json:"full_content"`
    Patch       string `json:"patch"`
}

type KnowledgeSource

type KnowledgeSource struct {
    Name  string              `mapstructure:"name"`
    Type  KnowledgeSourceType `mapstructure:"type"`
    Value string              `mapstructure:"value"`
}

type KnowledgeSourceType

type KnowledgeSourceType string

type PRChanges

type PRChanges struct {
    Files []FileChange `json:"files"`
}

type PRCommentInfo

type PRCommentInfo struct {
    CommentBody string
    StartLine   int
    Line        int
}

type PRCreation

type PRCreation struct {
    // Title of the pull request
    Title string `json:"title"`
    // Body of the pull request
    Body string `json:"body"`
    // UpdatedFiles is a list of files that have been updated in the pull request
    UpdatedFiles []PRCreationFile `json:"updated_files"`
}

type PRCreationFile

type PRCreationFile struct {
    // Path is the file path of the file that has been updated
    Path string `json:"path"`
    // FullContent is the full content of the file that has been updated
    FullContent   string `json:"full_content"`
    CommitMessage string `json:"commit_message"`
}

type PRReviewMap

type PRReviewMap map[string][]PRCommentInfo

type SnapprUserConfig

type SnapprUserConfig struct {
    PromptWorkflows  []config.PromptWorkflow  `yaml:"promptWorkflows"`
    KnowledgeSources []config.KnowledgeSource `yaml:"knowledgeSources"`
}

Generated by gomarkdoc