completion

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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

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

Jump to

Keyboard shortcuts

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