common

package
v1.4.233 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const ChatMessageRoleMeta = "meta"
View Source
const FileChangesMarker = "__CREATE_CODING_FEATURE_FILE_CHANGES__"

FileChangesMarker identifies the start of a file changes section in output

View Source
const (
	// MaxFileSize is the maximum size of a file that can be created (10MB)
	MaxFileSize = 10 * 1024 * 1024
)

Variables

This section is empty.

Functions

func ApplyFileChanges added in v1.4.165

func ApplyFileChanges(projectRoot string, changes []FileChange) error

ApplyFileChanges applies the parsed file changes to the file system

func GetAbsolutePath added in v1.4.119

func GetAbsolutePath(path string) (string, error)

GetAbsolutePath resolves a given path to its absolute form, handling ~, ./, ../, UNC paths, and symlinks.

func IsSymlinkToDir added in v1.4.119

func IsSymlinkToDir(path string) bool

Helper function to check if a symlink points to a directory

func NormalizeMessages

func NormalizeMessages(msgs []*chat.ChatCompletionMessage, defaultUserMessage string) (ret []*chat.ChatCompletionMessage)

NormalizeMessages remove empty messages and ensure messages order user-assist-user

func ReturnItem added in v1.4.67

func ReturnItem(item string) string

Types

type Attachment added in v1.4.79

type Attachment struct {
	Type    *string `json:"type,omitempty"`
	Path    *string `json:"path,omitempty"`
	URL     *string `json:"url,omitempty"`
	Content []byte  `json:"content,omitempty"`
	ID      *string `json:"id,omitempty"`
}

func NewAttachment added in v1.4.79

func NewAttachment(value string) (ret *Attachment, err error)

func (*Attachment) Base64Content added in v1.4.79

func (a *Attachment) Base64Content() (ret string, err error)

func (*Attachment) ContentBytes added in v1.4.79

func (a *Attachment) ContentBytes() (ret []byte, err error)

func (*Attachment) GetId added in v1.4.79

func (a *Attachment) GetId() (ret string, err error)

func (*Attachment) ResolveType added in v1.4.79

func (a *Attachment) ResolveType() (ret string, err error)

type ChatOptions

type ChatOptions struct {
	Model              string
	Temperature        float64
	TopP               float64
	PresencePenalty    float64
	FrequencyPenalty   float64
	Raw                bool
	Seed               int
	ModelContextLength int
	MaxTokens          int
	Search             bool
	SearchLocation     string
	ImageFile          string
	ImageSize          string
	ImageQuality       string
	ImageCompression   int
	ImageBackground    string
}

type ChatRequest

type ChatRequest struct {
	ContextName      string
	SessionName      string
	PatternName      string
	PatternVariables map[string]string
	Message          *chat.ChatCompletionMessage
	Language         string
	Meta             string
	InputHasVars     bool
	StrategyName     string
}

type FileChange added in v1.4.165

type FileChange struct {
	Operation string `json:"operation"` // "create" or "update"
	Path      string `json:"path"`      // Relative path from project root
	Content   string `json:"content"`   // New file content
}

FileChange represents a single file change operation to be performed

func ParseFileChanges added in v1.4.165

func ParseFileChanges(output string) (changeSummary string, changes []FileChange, err error)

ParseFileChanges extracts and parses the file change marker section from LLM output

type GroupItems added in v1.4.67

type GroupItems[I any] struct {
	Group string
	Items []I
}

func (*GroupItems[I]) ContainsItemBy added in v1.4.67

func (o *GroupItems[I]) ContainsItemBy(predicate func(item I) bool) (ret bool)

func (*GroupItems[I]) Count added in v1.4.67

func (o *GroupItems[I]) Count() int

type GroupsItemsSelector added in v1.4.67

type GroupsItemsSelector[I any] struct {
	SelectionLabel string
	GetItemKey     func(I) string

	GroupsItems []*GroupItems[I]
}

func NewGroupsItemsSelector added in v1.4.67

func NewGroupsItemsSelector[I any](selectionLabel string,
	getItemLabel func(I) string) *GroupsItemsSelector[I]

func (*GroupsItemsSelector[I]) AddGroupItems added in v1.4.67

func (o *GroupsItemsSelector[I]) AddGroupItems(group string, items ...I)

func (*GroupsItemsSelector[I]) FindGroupsByItem added in v1.4.67

func (o *GroupsItemsSelector[I]) FindGroupsByItem(item I) (groups []string)

func (*GroupsItemsSelector[I]) FindGroupsByItemFirst added in v1.4.67

func (o *GroupsItemsSelector[I]) FindGroupsByItemFirst(item I) (ret string)

func (*GroupsItemsSelector[I]) GetGroupAndItemByItemNumber added in v1.4.67

func (o *GroupsItemsSelector[I]) GetGroupAndItemByItemNumber(number int) (group string, item I, err error)

func (*GroupsItemsSelector[I]) HasGroup added in v1.4.67

func (o *GroupsItemsSelector[I]) HasGroup(group string) (ret bool)

func (*GroupsItemsSelector[I]) Print added in v1.4.67

func (o *GroupsItemsSelector[I]) Print(shellCompleteList bool)

type GroupsItemsSelectorString added in v1.4.67

type GroupsItemsSelectorString struct {
	*GroupsItemsSelector[string]
}

func NewGroupsItemsSelectorString added in v1.4.67

func NewGroupsItemsSelectorString(selectionLabel string) *GroupsItemsSelectorString

type OAuthStorage added in v1.4.231

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

OAuthStorage handles persistent storage of OAuth tokens

func NewOAuthStorage added in v1.4.231

func NewOAuthStorage() (*OAuthStorage, error)

NewOAuthStorage creates a new OAuth storage instance

func (*OAuthStorage) DeleteToken added in v1.4.231

func (s *OAuthStorage) DeleteToken(provider string) error

DeleteToken removes a stored OAuth token

func (*OAuthStorage) GetTokenPath added in v1.4.231

func (s *OAuthStorage) GetTokenPath(provider string) string

GetTokenPath returns the file path for a provider's OAuth token

func (*OAuthStorage) HasValidToken added in v1.4.231

func (s *OAuthStorage) HasValidToken(provider string, bufferMinutes int) bool

HasValidToken checks if a valid (non-expired) token exists for a provider

func (*OAuthStorage) LoadToken added in v1.4.231

func (s *OAuthStorage) LoadToken(provider string) (*OAuthToken, error)

LoadToken loads an OAuth token from disk

func (*OAuthStorage) SaveToken added in v1.4.231

func (s *OAuthStorage) SaveToken(provider string, token *OAuthToken) error

SaveToken saves an OAuth token to disk with proper permissions

type OAuthToken added in v1.4.231

type OAuthToken struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresAt    int64  `json:"expires_at"`
	TokenType    string `json:"token_type"`
	Scope        string `json:"scope"`
}

OAuthToken represents stored OAuth token information

func (*OAuthToken) IsExpired added in v1.4.231

func (t *OAuthToken) IsExpired(bufferMinutes int) bool

IsExpired checks if the token is expired or will expire within the buffer time

Jump to

Keyboard shortcuts

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