Documentation
¶
Overview ¶
Package coders provides interfaces and types for working with code editors.
Package coders implements command execution for the AI terminal. Handles commands for file management, AI coding, version control, and chat operations.
Index ¶
- Constants
- type AutoCoder
- type AutoCoderOption
- func WithCodeBasePath(path string) AutoCoderOption
- func WithConfig(cfg *options.Config) AutoCoderOption
- func WithEngine(engine *ai.Engine) AutoCoderOption
- func WithLoadedContexts(contexts []*convo.LoadContext) AutoCoderOption
- func WithPrompt(prompt string) AutoCoderOption
- func WithPromptMode(mode ui.PromptMode) AutoCoderOption
- func WithRepo(repo *git.Command) AutoCoderOption
- func WithStore(store convo.Store) AutoCoderOption
- type Coder
- type CoderContext
- type CommandCompleter
- type CommandExecutor
- type EditBlockCoder
- func (e *EditBlockCoder) ApplyEdits(ctx context.Context, edits []PartialCodeBlock) error
- func (e *EditBlockCoder) Execute(ctx context.Context, messages []llms.ChatMessage) error
- func (e *EditBlockCoder) FormatMessages(values map[string]any) ([]llms.ChatMessage, error)
- func (e *EditBlockCoder) GetEdits(_ context.Context, codes string, fences []string) ([]PartialCodeBlock, error)
- func (e *EditBlockCoder) GetModifiedFiles(ctx context.Context) ([]string, error)
- func (e *EditBlockCoder) Name() string
- func (e *EditBlockCoder) Prompt() prompts.ChatPromptTemplate
- func (e *EditBlockCoder) UpdateCodeFences(_ context.Context, code string) (string, string)
- type PartialCodeBlock
Constants ¶
View Source
const ( HEAD = "<<<<<<< SEARCH" DIVIDER = "=======" UPDATED = ">>>>>>> REPLACE" )
View Source
const ( FlagVerbose = "verbose" FlagYes = "yes" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AutoCoder ¶
type AutoCoder struct {
// contains filtered or unexported fields
}
func NewAutoCoder ¶
func NewAutoCoder(opts ...AutoCoderOption) *AutoCoder
type AutoCoderOption ¶ added in v0.13.0
type AutoCoderOption func(*AutoCoder)
func WithCodeBasePath ¶ added in v0.13.0
func WithCodeBasePath(path string) AutoCoderOption
func WithConfig ¶ added in v0.13.0
func WithConfig(cfg *options.Config) AutoCoderOption
func WithEngine ¶ added in v0.13.0
func WithEngine(engine *ai.Engine) AutoCoderOption
func WithLoadedContexts ¶ added in v0.13.0
func WithLoadedContexts(contexts []*convo.LoadContext) AutoCoderOption
func WithPrompt ¶ added in v0.13.0
func WithPrompt(prompt string) AutoCoderOption
func WithPromptMode ¶ added in v0.13.5
func WithPromptMode(mode ui.PromptMode) AutoCoderOption
func WithRepo ¶ added in v0.13.0
func WithRepo(repo *git.Command) AutoCoderOption
func WithStore ¶ added in v0.13.0
func WithStore(store convo.Store) AutoCoderOption
type Coder ¶
type Coder interface { // Name returns the name of the code editor. Name() string // Prompt returns the prompt template used by the code editor. Prompt() prompts.ChatPromptTemplate // FormatMessages formats the messages with the provided values and returns the formatted messages. FormatMessages(values map[string]any) ([]llms.ChatMessage, error) // GetEdits retrieves the list of edits made to the code. GetEdits(ctx context.Context, codes string, fences []string) ([]PartialCodeBlock, error) // GetModifiedFiles retrieves the list of files that have been modified. GetModifiedFiles(ctx context.Context) ([]string, error) // UpdateCodeFences updates the code fence for the given code. UpdateCodeFences(ctx context.Context, code string) (string, string) // ApplyEdits applies the given list of edits to the code. ApplyEdits(ctx context.Context, edits []PartialCodeBlock) error // Execute runs the code editor with the specified input messages. Execute(ctx context.Context, messages []llms.ChatMessage) error }
Coder defines the interface for a code editor.
type CoderContext ¶ added in v0.12.0
func NewCoderContext ¶ added in v0.12.0
func NewCoderContext(cfg *options.Config) (*CoderContext, error)
type CommandCompleter ¶ added in v0.12.0
type CommandCompleter struct {
// contains filtered or unexported fields
}
func NewCommandCompleter ¶ added in v0.12.0
func NewCommandCompleter(repo *git.Command) CommandCompleter
func (CommandCompleter) Complete ¶ added in v0.12.0
func (c CommandCompleter) Complete(d prompt.Document) (suggestions []prompt.Suggest, startChar, endChar pstrings.RuneNumber)
type CommandExecutor ¶ added in v0.12.0
type CommandExecutor struct {
// contains filtered or unexported fields
}
func NewCommandExecutor ¶ added in v0.12.0
func NewCommandExecutor(coder *AutoCoder, historyWriter *chat.HistoryWriter) *CommandExecutor
func (*CommandExecutor) Executor ¶ added in v0.12.0
func (c *CommandExecutor) Executor(input string)
Executor processes command input - parsing, validation and execution
type EditBlockCoder ¶
type EditBlockCoder struct {
// contains filtered or unexported fields
}
func NewEditBlockCoder ¶
func NewEditBlockCoder(coder *AutoCoder, fence []string) *EditBlockCoder
func (*EditBlockCoder) ApplyEdits ¶
func (e *EditBlockCoder) ApplyEdits(ctx context.Context, edits []PartialCodeBlock) error
func (*EditBlockCoder) Execute ¶
func (e *EditBlockCoder) Execute(ctx context.Context, messages []llms.ChatMessage) error
func (*EditBlockCoder) FormatMessages ¶
func (e *EditBlockCoder) FormatMessages(values map[string]any) ([]llms.ChatMessage, error)
func (*EditBlockCoder) GetEdits ¶
func (e *EditBlockCoder) GetEdits(_ context.Context, codes string, fences []string) ([]PartialCodeBlock, error)
func (*EditBlockCoder) GetModifiedFiles ¶
func (e *EditBlockCoder) GetModifiedFiles(ctx context.Context) ([]string, error)
func (*EditBlockCoder) Name ¶
func (e *EditBlockCoder) Name() string
func (*EditBlockCoder) Prompt ¶
func (e *EditBlockCoder) Prompt() prompts.ChatPromptTemplate
func (*EditBlockCoder) UpdateCodeFences ¶
type PartialCodeBlock ¶
type PartialCodeBlock struct { // Path is the file path of the code block. Path string // OriginalText is the original text of the code block. OriginalText string // UpdatedText is the updated text of the code block. UpdatedText string }
PartialCodeBlock represents a partial code block with its file path and original and updated text.
func (PartialCodeBlock) String ¶
func (p PartialCodeBlock) String() string
Click to show internal directories.
Click to hide internal directories.