completion

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CompletionData embed.FS

CompletionData contains all embedded YAML completion configuration files. These files are embedded at compile time and provide default completions for common CLI tools.

Functions

func NewCompgenCommandHandler

func NewCompgenCommandHandler(runner *interp.Runner) func(next interp.ExecHandlerFunc) interp.ExecHandlerFunc

NewCompgenCommandHandler creates a new ExecHandler for the compgen command

func NewCompleteCommandHandler

func NewCompleteCommandHandler(completionManager *CompletionManager) func(next interp.ExecHandlerFunc) interp.ExecHandlerFunc

NewCompleteCommandHandler creates a new ExecHandler for the complete command

Types

type CompletionFunction

type CompletionFunction struct {
	Name   string
	Runner *interp.Runner
}

CompletionFunction represents a bash completion function

func NewCompletionFunction

func NewCompletionFunction(name string, runner *interp.Runner) *CompletionFunction

NewCompletionFunction creates a new CompletionFunction

func (*CompletionFunction) Execute

func (f *CompletionFunction) Execute(ctx context.Context, args []string) ([]string, error)

Execute runs the completion function with the given arguments

type CompletionManager

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

CompletionManager manages command completion specifications

func NewCompletionManager

func NewCompletionManager() *CompletionManager

NewCompletionManager creates a new CompletionManager

func (*CompletionManager) AddSpec

func (m *CompletionManager) AddSpec(spec CompletionSpec)

AddSpec adds or updates a completion specification

func (*CompletionManager) ExecuteCompletion

func (m *CompletionManager) ExecuteCompletion(ctx context.Context, runner *interp.Runner, spec CompletionSpec, args []string, line string, pos int) ([]shellinput.CompletionCandidate, error)

ExecuteCompletion executes a completion specification for a given command line and returns the list of possible completions

func (*CompletionManager) GetSpec

func (m *CompletionManager) GetSpec(command string) (CompletionSpec, bool)

GetSpec retrieves a completion specification

func (*CompletionManager) ListSpecs

func (m *CompletionManager) ListSpecs() []CompletionSpec

ListSpecs returns all completion specifications

func (*CompletionManager) RemoveSpec

func (m *CompletionManager) RemoveSpec(command string)

RemoveSpec removes a completion specification

func (*CompletionManager) RunExternalCompleter

func (m *CompletionManager) RunExternalCompleter(ctx context.Context, command string, args []string, line string, pos int) ([]shellinput.CompletionCandidate, error)

RunExternalCompleter executes an external command to generate completions

type CompletionManagerInterface

type CompletionManagerInterface interface {
	GetSpec(command string) (CompletionSpec, bool)
	ExecuteCompletion(ctx context.Context, runner *interp.Runner, spec CompletionSpec, args []string, line string, pos int) ([]shellinput.CompletionCandidate, error)
}

CompletionManagerInterface defines the interface for completion management

type CompletionSpec

type CompletionSpec struct {
	Command string
	Type    CompletionType
	Value   string   // function name, wordlist, or command
	Options []string // additional options like -o dirname
}

CompletionSpec represents a completion specification for a command

type CompletionType

type CompletionType string

CompletionType represents the type of completion

const (
	// WordListCompletion represents word list based completion (-W option)
	WordListCompletion CompletionType = "W"
	// FunctionCompletion represents function based completion (-F option)
	FunctionCompletion CompletionType = "F"
	// CommandCompletion represents command based completion (-C option)
	CommandCompletion CompletionType = "C"
)

type ConfigLoader added in v0.34.0

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

ConfigLoader handles loading completion data from embedded YAML files

func NewConfigLoader added in v0.34.0

func NewConfigLoader(filesystem fs.FS) *ConfigLoader

NewConfigLoader creates a new ConfigLoader with the given filesystem

func (*ConfigLoader) ListEmbeddedFiles added in v0.34.0

func (cl *ConfigLoader) ListEmbeddedFiles() ([]string, error)

ListEmbeddedFiles returns a list of all YAML files in the embedded filesystem This can be useful for debugging or introspection

func (*ConfigLoader) LoadAllCompletions added in v0.34.0

func (cl *ConfigLoader) LoadAllCompletions() (map[string][]UserCompletion, error)

LoadAllCompletions loads all completion configurations from embedded YAML files Returns a map of command names to their completion entries

func (*ConfigLoader) LoadCompletionsFromFile added in v0.34.0

func (cl *ConfigLoader) LoadCompletionsFromFile(filename string) (map[string][]UserCompletion, error)

LoadCompletionsFromFile loads completions from a single embedded YAML file This is useful for loading specific configuration files on demand

type DefaultCompleter

type DefaultCompleter struct{}

DefaultCompleter handles built-in default completions for common commands

func (*DefaultCompleter) GetCompletions

func (d *DefaultCompleter) GetCompletions(command string, args []string, line string, pos int) ([]shellinput.CompletionCandidate, bool)

GetCompletions tries to provide completions for the given command and context

type GitCompleter

type GitCompleter struct{}

GitCompleter handles built-in completion for git

func (*GitCompleter) GetCompletions

func (g *GitCompleter) GetCompletions(args []string, line string) []shellinput.CompletionCandidate

type ShellCompletionProvider

type ShellCompletionProvider struct {
	CompletionManager CompletionManagerInterface
	Runner            *interp.Runner
	SubagentProvider  SubagentProvider // Optional, for # completions
	// contains filtered or unexported fields
}

ShellCompletionProvider implements shellinput.CompletionProvider using the shell's CompletionManager

func NewShellCompletionProvider

func NewShellCompletionProvider(manager CompletionManagerInterface, runner *interp.Runner) *ShellCompletionProvider

NewShellCompletionProvider creates a new ShellCompletionProvider

func (*ShellCompletionProvider) GetCompletions

func (p *ShellCompletionProvider) GetCompletions(line string, pos int) []shellinput.CompletionCandidate

GetCompletions returns completion suggestions for the current input line

func (*ShellCompletionProvider) GetHelpInfo

func (p *ShellCompletionProvider) GetHelpInfo(line string, pos int) string

GetHelpInfo returns help information for special commands like #!, #/, and #

func (*ShellCompletionProvider) SetSubagentProvider

func (p *ShellCompletionProvider) SetSubagentProvider(provider SubagentProvider)

SetSubagentProvider sets the subagent provider for # completions

type StaticCompleter

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

StaticCompleter handles static word lists for common commands

func NewStaticCompleter

func NewStaticCompleter() *StaticCompleter

func (*StaticCompleter) GetCompletions

func (s *StaticCompleter) GetCompletions(command string, args []string) []shellinput.CompletionCandidate

GetCompletions returns completion suggestions for a command

func (*StaticCompleter) GetRegisteredCommands added in v0.32.0

func (s *StaticCompleter) GetRegisteredCommands() []string

GetRegisteredCommands returns a sorted list of all commands that have static completions

func (*StaticCompleter) HasCommand added in v0.32.0

func (s *StaticCompleter) HasCommand(command string) bool

HasCommand returns true if the command has registered completions

func (*StaticCompleter) RegisterUserCommand added in v0.32.0

func (s *StaticCompleter) RegisterUserCommand(command string, subcommands []UserCompletion)

RegisterUserCommand allows users to register custom command completions at runtime

func (*StaticCompleter) ReloadUserCompletions added in v0.32.0

func (s *StaticCompleter) ReloadUserCompletions()

ReloadUserCompletions reloads user-defined completions from config files

type SubagentInfo

type SubagentInfo struct {
	ID           string
	Name         string
	Description  string
	AllowedTools []string
	FileRegex    string
	Model        string
}

SubagentInfo represents minimal information about a subagent for completion purposes

type SubagentProvider

type SubagentProvider interface {
	GetAllSubagents() map[string]*SubagentInfo
	GetSubagent(id string) (*SubagentInfo, bool)
}

SubagentProvider defines the interface for providing subagent information to the completion system

type UserCompletion added in v0.32.0

type UserCompletion struct {
	Value       string `yaml:"value" json:"value"`
	Description string `yaml:"description,omitempty" json:"description,omitempty"`
}

UserCompletion represents a single user-defined completion entry

type UserCompletionConfig added in v0.32.0

type UserCompletionConfig struct {
	Commands map[string][]UserCompletion `yaml:"commands" json:"commands"`
}

UserCompletionConfig represents user-defined completion configuration

Jump to

Keyboard shortcuts

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