coders

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 28 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

	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 a auto generate coders user interface.

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) 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) 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 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)
	// 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.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) 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) Name added in v0.1.5

func (e *EditBlockCoder) Name() string

func (*EditBlockCoder) Prompt added in v0.1.5

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

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

func (*Prompt) SetValue

func (p *Prompt) SetValue(value string) *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
const (
	ExecPromptMode PromptMode = iota
	ChatPromptMode
	DefaultPromptMode
)

func GetPromptModeFromString

func GetPromptModeFromString(s string) PromptMode

func (PromptMode) String

func (m PromptMode) String() string

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

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

WaitFormUserConfirm represents a model that waits for user confirmation with a message and a viewport for display.

func NewConfirmModel added in v0.1.5

func NewConfirmModel(message string) *WaitFormUserConfirm

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