coders

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package coders provides interfaces and types for working with code editors.

Index

Constants

View Source
const (
	HEAD    = "<<<<<<< SEARCH"
	DIVIDER = "======="
	UPDATED = ">>>>>>> REPLACE"
)
View Source
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) Done

func (a *AutoCoder) Done()

Done sets the checkpoint to done.

func (*AutoCoder) Error

func (a *AutoCoder) Error(args interface{}) error

Error sets the status to error with the given error message and returns the error.

func (*AutoCoder) Errorf

func (a *AutoCoder) Errorf(format string, args ...interface{}) error

Errorf sets the status to error with the formatted error message and returns the error.

func (*AutoCoder) GetCurrentSuggestions added in v0.1.7

func (a *AutoCoder) GetCurrentSuggestions() []string

GetCurrentSuggestions returns the current suggestions.

func (*AutoCoder) Info

func (a *AutoCoder) Info(desc string)

Info sets the status to info with the given description.

func (*AutoCoder) Infof

func (a *AutoCoder) Infof(format string, args ...interface{})

Infof sets the status to info with the formatted description.

func (*AutoCoder) Init

func (a *AutoCoder) Init() tea.Cmd

func (*AutoCoder) Loading

func (a *AutoCoder) Loading(desc string)

Loading sets the status to loading with the given description.

func (*AutoCoder) Success

func (a *AutoCoder) Success(desc string)

Success sets the status to success with the given description.

func (*AutoCoder) Successf

func (a *AutoCoder) Successf(format string, args ...interface{})

Successf sets the status to success with the formatted description.

func (*AutoCoder) Trace added in v0.1.9

func (a *AutoCoder) Trace(desc string)

Trace sets the status to trace with the given description.

func (*AutoCoder) Tracef added in v0.1.9

func (a *AutoCoder) Tracef(format string, args ...interface{})

Tracef sets the status to trace with the formatted description.

func (*AutoCoder) Update

func (a *AutoCoder) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*AutoCoder) View

func (a *AutoCoder) View() string

func (*AutoCoder) WaitForUserConfirm added in v0.1.5

func (a *AutoCoder) WaitForUserConfirm(format string, args ...interface{}) bool

WaitForUserConfirm waits for user confirmation with the formatted message and returns the user's choice.

func (*AutoCoder) Warning

func (a *AutoCoder) Warning(desc string)

Warning sets the status to warning with the given description.

func (*AutoCoder) Warningf

func (a *AutoCoder) Warningf(format string, args ...interface{})

Warningf sets the status to warning with the formatted description.

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 (*EditBlockCoder) UpdateCodeFences added in v0.1.9

func (e *EditBlockCoder) UpdateCodeFences(_ context.Context, code string) (string, string)

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) AsString

func (p *Prompt) AsString() string

func (*Prompt) Blur

func (p *Prompt) Blur() *Prompt

func (*Prompt) Focus

func (p *Prompt) Focus() *Prompt

func (*Prompt) GetMode

func (p *Prompt) GetMode() PromptMode

func (*Prompt) GetValue

func (p *Prompt) GetValue() string

func (*Prompt) Height added in v0.1.6

func (p *Prompt) Height() int

func (*Prompt) SetMode

func (p *Prompt) SetMode(mode PromptMode) *Prompt

func (*Prompt) SetSuggestions added in v0.1.7

func (p *Prompt) SetSuggestions(suggestions []string)

func (*Prompt) SetValue

func (p *Prompt) SetValue(value string) *Prompt

func (*Prompt) SetWidth added in v0.1.6

func (p *Prompt) SetWidth(width int) *Prompt

func (*Prompt) Update

func (p *Prompt) Update(msg tea.Msg) (*Prompt, tea.Cmd)

func (*Prompt) View

func (p *Prompt) View() string

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 (r *Renderer) RenderContent(in string) string

func (*Renderer) RenderError

func (r *Renderer) RenderError(in string) string

func (*Renderer) RenderHelp

func (r *Renderer) RenderHelp(in string) string

func (*Renderer) RenderHelpMessage

func (r *Renderer) RenderHelpMessage() string

func (*Renderer) RenderSuccess

func (r *Renderer) RenderSuccess(in string) string

func (*Renderer) RenderTrace added in v0.1.9

func (r *Renderer) RenderTrace(in string) string

func (*Renderer) RenderWarning

func (r *Renderer) RenderWarning(in string) string

func (*Renderer) RenderWelcomeMessage added in v0.1.5

func (r *Renderer) RenderWelcomeMessage(username string) string

type Spinner

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

func NewSpinner

func NewSpinner() *Spinner

func (*Spinner) Tick

func (s *Spinner) Tick() tea.Msg

func (*Spinner) Update

func (s *Spinner) Update(msg tea.Msg) (*Spinner, tea.Cmd)

func (*Spinner) View

func (s *Spinner) View() string

func (*Spinner) ViewWithMessage

func (s *Spinner) ViewWithMessage(prefix, spinnerMsg string) string

type State

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

type StatusType

type StatusType int

type Suggester added in v0.1.7

type Suggester interface {
	GetSuggestions(input string) []string
}

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 (*WaitFormUserConfirm) View added in v0.1.5

func (m *WaitFormUserConfirm) View() string

Jump to

Keyboard shortcuts

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