commands

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClearCommand

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

ClearCommand clears the conversation history

func NewClearCommand

func NewClearCommand(repo domain.ConversationRepository) *ClearCommand

func (*ClearCommand) CanExecute

func (c *ClearCommand) CanExecute(args []string) bool

func (*ClearCommand) Execute

func (c *ClearCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*ClearCommand) GetDescription

func (c *ClearCommand) GetDescription() string

func (*ClearCommand) GetName

func (c *ClearCommand) GetName() string

func (*ClearCommand) GetUsage

func (c *ClearCommand) GetUsage() string

type Command

type Command interface {
	GetName() string
	GetDescription() string
	GetUsage() string
	Execute(ctx context.Context, args []string) (CommandResult, error)
	CanExecute(args []string) bool
}

Command interface represents a chat command that can be executed

type CommandResult

type CommandResult struct {
	Output     string
	Success    bool
	SideEffect SideEffectType
	Data       any // Additional data for the side effect
}

CommandResult represents the result of a command execution

type ConfigCommand added in v0.41.0

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

ConfigCommand allows runtime configuration management

func NewConfigCommand added in v0.41.0

func NewConfigCommand(cfg *config.Config, reloadFunc func() (*config.Config, error), configService interface {
	SetValue(key, value string) error
}) *ConfigCommand

NewConfigCommand creates a new config command

func (*ConfigCommand) CanExecute added in v0.41.0

func (c *ConfigCommand) CanExecute(args []string) bool

func (*ConfigCommand) Execute added in v0.41.0

func (c *ConfigCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*ConfigCommand) GetDescription added in v0.41.0

func (c *ConfigCommand) GetDescription() string

func (*ConfigCommand) GetName added in v0.41.0

func (c *ConfigCommand) GetName() string

func (*ConfigCommand) GetUsage added in v0.41.0

func (c *ConfigCommand) GetUsage() string

type ExitCommand

type ExitCommand struct{}

ExitCommand exits the application

func NewExitCommand

func NewExitCommand() *ExitCommand

func (*ExitCommand) CanExecute

func (c *ExitCommand) CanExecute(args []string) bool

func (*ExitCommand) Execute

func (c *ExitCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*ExitCommand) GetDescription

func (c *ExitCommand) GetDescription() string

func (*ExitCommand) GetName

func (c *ExitCommand) GetName() string

func (*ExitCommand) GetUsage

func (c *ExitCommand) GetUsage() string

type ExportCommand

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

ExportCommand exports the conversation

func NewExportCommand

func NewExportCommand(repo domain.ConversationRepository, agentService domain.AgentService, modelService domain.ModelService, config *config.Config) *ExportCommand

func (*ExportCommand) CanExecute

func (c *ExportCommand) CanExecute(args []string) bool

func (*ExportCommand) Execute

func (c *ExportCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*ExportCommand) GetDescription

func (c *ExportCommand) GetDescription() string

func (*ExportCommand) GetName

func (c *ExportCommand) GetName() string

func (*ExportCommand) GetUsage

func (c *ExportCommand) GetUsage() string

func (*ExportCommand) PerformExport

func (c *ExportCommand) PerformExport(ctx context.Context) (string, error)

PerformExport performs the actual export operation (called by side effect handler)

type HelpCommand

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

HelpCommand shows available commands

func NewHelpCommand

func NewHelpCommand(registry *Registry) *HelpCommand

func (*HelpCommand) CanExecute

func (c *HelpCommand) CanExecute(args []string) bool

func (*HelpCommand) Execute

func (c *HelpCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*HelpCommand) GetDescription

func (c *HelpCommand) GetDescription() string

func (*HelpCommand) GetName

func (c *HelpCommand) GetName() string

func (*HelpCommand) GetUsage

func (c *HelpCommand) GetUsage() string

type Registry

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

Registry manages all available commands

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new command registry

func (*Registry) Execute

func (r *Registry) Execute(ctx context.Context, name string, args []string) (CommandResult, error)

Execute executes a command by name with arguments

func (*Registry) Get

func (r *Registry) Get(name string) (Command, bool)

Get retrieves a command by name

func (*Registry) GetAll

func (r *Registry) GetAll() []Command

GetAll returns all registered commands

func (*Registry) GetCommands added in v0.15.0

func (r *Registry) GetCommands() map[string]string

GetCommands returns a map of command names to descriptions

func (*Registry) GetCommandsStartingWith

func (r *Registry) GetCommandsStartingWith(prefix string) []string

GetCommandsStartingWith returns commands that start with the given prefix

func (*Registry) List

func (r *Registry) List() []string

List returns all registered command names

func (*Registry) ParseCommand

func (r *Registry) ParseCommand(input string) (string, []string, error)

ParseCommand parses a command line input into command name and arguments Handles quoted strings properly

func (*Registry) Register

func (r *Registry) Register(cmd Command)

Register adds a command to the registry

func (*Registry) Unregister

func (r *Registry) Unregister(name string)

Unregister removes a command from the registry

type SideEffectType

type SideEffectType int

SideEffectType defines the types of side effects a command can have

const (
	SideEffectNone SideEffectType = iota
	SideEffectClearConversation
	SideEffectExportConversation
	SideEffectExit
	SideEffectSwitchModel
	SideEffectShowHelp
	SideEffectReloadConfig
)

type SwitchCommand

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

SwitchCommand switches the active model

func NewSwitchCommand

func NewSwitchCommand(modelService domain.ModelService) *SwitchCommand

func (*SwitchCommand) CanExecute

func (c *SwitchCommand) CanExecute(args []string) bool

func (*SwitchCommand) Execute

func (c *SwitchCommand) Execute(ctx context.Context, args []string) (CommandResult, error)

func (*SwitchCommand) GetDescription

func (c *SwitchCommand) GetDescription() string

func (*SwitchCommand) GetName

func (c *SwitchCommand) GetName() string

func (*SwitchCommand) GetUsage

func (c *SwitchCommand) GetUsage() string

Jump to

Keyboard shortcuts

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