Documentation
¶
Overview ¶
Package coders provides interfaces and types for working with code editors.
Index ¶
- Constants
- func StartAutCoder() error
- type AutoCoder
- func (a *AutoCoder) Done()
- func (a *AutoCoder) Error(args interface{}) error
- func (a *AutoCoder) Errorf(format string, args ...interface{}) error
- func (a *AutoCoder) GetCurrentSuggestions() []string
- func (a *AutoCoder) Info(desc string)
- func (a *AutoCoder) Infof(format string, args ...interface{})
- func (a *AutoCoder) Init() tea.Cmd
- func (a *AutoCoder) Loading(desc string)
- func (a *AutoCoder) Success(desc string)
- func (a *AutoCoder) Successf(format string, args ...interface{})
- func (a *AutoCoder) Trace(desc string)
- func (a *AutoCoder) Tracef(format string, args ...interface{})
- func (a *AutoCoder) Update(msg tea.Msg) (tea.Model, tea.Cmd)
- func (a *AutoCoder) View() string
- func (a *AutoCoder) WaitForUserConfirm(format string, args ...interface{}) bool
- func (a *AutoCoder) Warning(desc string)
- func (a *AutoCoder) Warningf(format string, args ...interface{})
- type AutoCoderSuggester
- type Checkpoint
- type Coder
- type Components
- type EditBlockCoder
- func (e *EditBlockCoder) ApplyEdits(ctx context.Context, edits []PartialCodeBlock, needConfirm bool) error
- func (e *EditBlockCoder) Execute(ctx context.Context, messages []llms.MessageContent) error
- func (e *EditBlockCoder) FormatMessages(values map[string]any) ([]llms.MessageContent, error)
- func (e *EditBlockCoder) GetEdits(_ context.Context) ([]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
- type Prompt
- func (p *Prompt) AsString() string
- func (p *Prompt) Blur() *Prompt
- func (p *Prompt) Focus() *Prompt
- func (p *Prompt) GetMode() PromptMode
- func (p *Prompt) GetValue() string
- func (p *Prompt) Height() int
- func (p *Prompt) SetMode(mode PromptMode) *Prompt
- func (p *Prompt) SetSuggestions(suggestions []string)
- func (p *Prompt) SetValue(value string) *Prompt
- func (p *Prompt) SetWidth(width int) *Prompt
- func (p *Prompt) Update(msg tea.Msg) (*Prompt, tea.Cmd)
- func (p *Prompt) View() string
- type PromptMode
- type Renderer
- func (r *Renderer) RenderContent(in string) string
- func (r *Renderer) RenderError(in string) string
- func (r *Renderer) RenderHelp(in string) string
- func (r *Renderer) RenderHelpMessage() string
- func (r *Renderer) RenderSuccess(in string) string
- func (r *Renderer) RenderTrace(in string) string
- func (r *Renderer) RenderWarning(in string) string
- func (r *Renderer) RenderWelcomeMessage(username string) string
- type Spinner
- type State
- type StatusType
- type Suggester
- type WaitFormUserConfirm
- func (m *WaitFormUserConfirm) GotoBottom()
- func (m *WaitFormUserConfirm) SetContent(content string)
- func (m *WaitFormUserConfirm) SetHeight(height int)
- func (m *WaitFormUserConfirm) SetWidth(width int)
- func (m *WaitFormUserConfirm) Update(msg tea.Msg) (*WaitFormUserConfirm, tea.Cmd)
- func (m *WaitFormUserConfirm) View() string
Constants ¶
const ( HEAD = "<<<<<<< SEARCH" DIVIDER = "=======" UPDATED = ">>>>>>> REPLACE" )
const ( StatusLoading StatusType = iota StatusInfo StatusSuccess StatusWarning StatusError StatusTrace StatusLoadingIcon = " ⏳ " StatusInfoIcon = " ℹ️ " StatusSuccessIcon = " ✅ " StatusErrorIcon = " ❌ " StatusWarningIcon = " ⚠️ " )
Variables ¶
This section is empty.
Functions ¶
func StartAutCoder ¶
func StartAutCoder() error
Types ¶
type AutoCoder ¶
type AutoCoder struct {
// contains filtered or unexported fields
}
AutoCoder is an interface for auto-generating code.
func NewAutoCoder ¶
func NewAutoCoder() *AutoCoder
func (*AutoCoder) Error ¶
Error sets the status to error with the given error message and returns the error.
func (*AutoCoder) Errorf ¶
Errorf sets the status to error with the formatted error message and returns the error.
func (*AutoCoder) GetCurrentSuggestions ¶ added in v0.1.7
GetCurrentSuggestions returns the current suggestions.
func (*AutoCoder) Trace ¶ added in v0.1.9
Trace sets the status to trace with the given description.
func (*AutoCoder) Tracef ¶ added in v0.1.9
Tracef sets the status to trace with the formatted description.
func (*AutoCoder) WaitForUserConfirm ¶ added in v0.1.5
WaitForUserConfirm waits for user confirmation with the formatted message and returns the user's choice.
type AutoCoderSuggester ¶ added in v0.1.7
type AutoCoderSuggester struct {
// contains filtered or unexported fields
}
AutoCoderSuggester is a struct that implements the Suggester interface for AutoCoder.
func NewAutoCoderSuggester ¶ added in v0.1.7
func NewAutoCoderSuggester(files, commands []string) *AutoCoderSuggester
NewAutoCoderSuggester creates a new instance of AutoCoderSuggester.
func (*AutoCoderSuggester) GetSuggestions ¶ added in v0.1.7
func (s *AutoCoderSuggester) GetSuggestions(input string) []string
type Checkpoint ¶
type Checkpoint struct { Done bool Desc string Error error Type StatusType // contains filtered or unexported fields }
func (Checkpoint) Render ¶
func (s Checkpoint) Render() tea.Cmd
Render prints the description of the checkpoint and blinks the text input.
type Coder ¶ added in v0.1.5
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.MessageContent, error) // GetEdits retrieves the list of edits made to the code. GetEdits(ctx context.Context) ([]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, needConfirm bool) error // Execute runs the code editor with the specified input messages. Execute(ctx context.Context, messages []llms.MessageContent) error }
Coder defines the interface for a code editor.
type Components ¶
type Components struct {
// contains filtered or unexported fields
}
func NewComponents ¶
func NewComponents() *Components
type EditBlockCoder ¶ added in v0.1.5
type EditBlockCoder struct {
// contains filtered or unexported fields
}
func NewEditBlockCoder ¶ added in v0.1.5
func NewEditBlockCoder(coder *AutoCoder, fence []string) *EditBlockCoder
func (*EditBlockCoder) ApplyEdits ¶ added in v0.1.5
func (e *EditBlockCoder) ApplyEdits(ctx context.Context, edits []PartialCodeBlock, needConfirm bool) error
func (*EditBlockCoder) Execute ¶ added in v0.1.5
func (e *EditBlockCoder) Execute(ctx context.Context, messages []llms.MessageContent) error
func (*EditBlockCoder) FormatMessages ¶ added in v0.1.5
func (e *EditBlockCoder) FormatMessages(values map[string]any) ([]llms.MessageContent, error)
func (*EditBlockCoder) GetEdits ¶ added in v0.1.5
func (e *EditBlockCoder) GetEdits(_ context.Context) ([]PartialCodeBlock, error)
func (*EditBlockCoder) GetModifiedFiles ¶ added in v0.1.9
func (e *EditBlockCoder) GetModifiedFiles(ctx context.Context) ([]string, error)
func (*EditBlockCoder) Name ¶ added in v0.1.5
func (e *EditBlockCoder) Name() string
func (*EditBlockCoder) Prompt ¶ added in v0.1.5
func (e *EditBlockCoder) Prompt() prompts.ChatPromptTemplate
func (*EditBlockCoder) UpdateCodeFences ¶ added in v0.1.9
type PartialCodeBlock ¶ added in v0.1.5
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 ¶ added in v0.1.5
func (p PartialCodeBlock) String() string
type Prompt ¶
type Prompt struct {
// contains filtered or unexported fields
}
func NewPrompt ¶
func NewPrompt(mode PromptMode) *Prompt
func (*Prompt) GetMode ¶
func (p *Prompt) GetMode() PromptMode
func (*Prompt) SetMode ¶
func (p *Prompt) SetMode(mode PromptMode) *Prompt
func (*Prompt) SetSuggestions ¶ added in v0.1.7
type PromptMode ¶
type PromptMode int
PromptMode represents the mode of the prompt.
const ( ExecPromptMode PromptMode = iota // ExecPromptMode represents the execution mode. ChatPromptMode // ChatPromptMode represents the chat mode. DefaultPromptMode // DefaultPromptMode represents the default mode. )
Constants representing different prompt modes.
func GetPromptModeFromString ¶
func GetPromptModeFromString(s string) PromptMode
GetPromptModeFromString returns the PromptMode corresponding to the given string.
func (PromptMode) String ¶
func (m PromptMode) String() string
String returns the string representation of the PromptMode.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
func NewRenderer ¶
func NewRenderer(options ...glamour.TermRendererOption) *Renderer
func (*Renderer) RenderContent ¶
func (*Renderer) RenderError ¶
func (*Renderer) RenderHelp ¶
func (*Renderer) RenderHelpMessage ¶
func (*Renderer) RenderSuccess ¶
func (*Renderer) RenderTrace ¶ added in v0.1.9
func (*Renderer) RenderWarning ¶
func (*Renderer) RenderWelcomeMessage ¶ added in v0.1.5
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
func NewSpinner ¶
func NewSpinner() *Spinner
func (*Spinner) ViewWithMessage ¶
type StatusType ¶
type StatusType int
type Suggester ¶ added in v0.1.7
Suggester is an interface for providing suggestions based on input.
type WaitFormUserConfirm ¶ added in v0.1.5
type WaitFormUserConfirm struct {
// contains filtered or unexported fields
}
WaitFormUserConfirm is a model that displays a confirmation message to the user and waits for their response. It handles user input for confirmation (yes) or cancellation (no). This model uses a viewport to display the message and a channel to receive the user's choice.
func NewConfirmModel ¶ added in v0.1.5
func NewConfirmModel(message string) *WaitFormUserConfirm
func (*WaitFormUserConfirm) GotoBottom ¶ added in v0.1.6
func (m *WaitFormUserConfirm) GotoBottom()
func (*WaitFormUserConfirm) SetContent ¶ added in v0.1.6
func (m *WaitFormUserConfirm) SetContent(content string)
func (*WaitFormUserConfirm) SetHeight ¶ added in v0.1.6
func (m *WaitFormUserConfirm) SetHeight(height int)
func (*WaitFormUserConfirm) SetWidth ¶ added in v0.1.6
func (m *WaitFormUserConfirm) SetWidth(width int)
func (*WaitFormUserConfirm) Update ¶ added in v0.1.5
func (m *WaitFormUserConfirm) Update(msg tea.Msg) (*WaitFormUserConfirm, tea.Cmd)
func (*WaitFormUserConfirm) View ¶ added in v0.1.5
func (m *WaitFormUserConfirm) View() string