Documentation
¶
Index ¶
- func ExtractPipeContext(line string, pos int) (extracted string, newPos int)
- type AgentCompleter
- type AliasCompleter
- type CobraCompleter
- type Completer
- type EnvCompleter
- type EnvProvider
- type ExecutableCompleter
- type FileCompleter
- type FunctionProvider
- type Item
- type Kind
- type Prefetcher
- type Priority
- type Result
- type Router
- func (r *Router) Complete(ctx context.Context, line string, pos int) (Result, error)
- func (r *Router) Completers() []Completer
- func (r *Router) Fuzzy() bool
- func (r *Router) Prefetch(line string, pos int)
- func (r *Router) Register(c Completer, priority Priority)
- func (r *Router) SetFuzzy(enabled bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractPipeContext ¶
ExtractPipeContext extracts the command context after the last pipe. For "cat file | pb", returns ("pb", 3) where 3 is the new position. For "ls -la", returns ("ls -la", 5) unchanged. This allows completers to work correctly with piped commands.
Types ¶
type AgentCompleter ¶
type AgentCompleter struct {
// contains filtered or unexported fields
}
AgentCompleter provides AI-assisted completions via ??.
func NewAgentCompleter ¶
func NewAgentCompleter(client *agent.Client) *AgentCompleter
NewAgentCompleter creates a new agent completer.
func (*AgentCompleter) Name ¶
func (c *AgentCompleter) Name() string
Name returns the completer name.
type AliasCompleter ¶
type AliasCompleter struct {
// contains filtered or unexported fields
}
AliasCompleter completes user-defined aliases and functions.
func NewAliasCompleter ¶
func NewAliasCompleter(provider FunctionProvider) *AliasCompleter
NewAliasCompleter creates a new alias completer.
func (*AliasCompleter) Complete ¶
Complete returns completions for aliases and functions. Unlike ExecutableCompleter, this completes anywhere (not just command position) because functions can be arguments to xargs, find -exec, etc.
func (*AliasCompleter) Name ¶
func (c *AliasCompleter) Name() string
Name returns the completer name.
type CobraCompleter ¶
type CobraCompleter struct {
// contains filtered or unexported fields
}
CobraCompleter provides completions from Cobra-based CLI tools. It uses background prefetching to avoid blocking on TAB press.
func NewCobraCompleter ¶
func NewCobraCompleter() *CobraCompleter
NewCobraCompleter creates a new Cobra completer.
func (*CobraCompleter) ClearCache ¶
func (c *CobraCompleter) ClearCache()
ClearCache clears the completion cache.
func (*CobraCompleter) Complete ¶
Complete returns completions from cache only. Use Prefetch to populate the cache in the background.
func (*CobraCompleter) Name ¶
func (c *CobraCompleter) Name() string
Name returns the completer name.
func (*CobraCompleter) Prefetch ¶
func (c *CobraCompleter) Prefetch(line string, pos int)
Prefetch triggers background fetching of Cobra completions. Call this when the user types a space after a command.
func (*CobraCompleter) SetCacheTTL ¶
func (c *CobraCompleter) SetCacheTTL(ttl time.Duration)
SetCacheTTL sets the cache TTL.
type Completer ¶
type Completer interface {
// Complete returns completions for the given line and cursor position.
Complete(ctx context.Context, line string, pos int) (Result, error)
// Name returns the completer name for logging.
Name() string
}
Completer provides completions for a given input.
type EnvCompleter ¶
type EnvCompleter struct {
// contains filtered or unexported fields
}
EnvCompleter completes environment variable names.
func NewEnvCompleter ¶
func NewEnvCompleter(provider EnvProvider) *EnvCompleter
NewEnvCompleter creates a new environment variable completer. If provider is nil, falls back to os.Environ().
func (*EnvCompleter) Complete ¶
Complete returns completions for environment variables. Triggers when the user types $ or ${ followed by variable name prefix.
func (*EnvCompleter) SetMaskSensitive ¶
func (c *EnvCompleter) SetMaskSensitive(enabled bool)
SetMaskSensitive enables or disables masking of sensitive env var values.
type EnvProvider ¶
type EnvProvider interface {
Environ() []string
}
EnvProvider is the interface for getting environment variables from the executor.
type ExecutableCompleter ¶
type ExecutableCompleter struct {
// contains filtered or unexported fields
}
ExecutableCompleter completes executable names from PATH. It is triggered when completing the first word of a command (or after a pipe).
func NewExecutableCompleter ¶
func NewExecutableCompleter() *ExecutableCompleter
NewExecutableCompleter creates a new executable completer.
func (*ExecutableCompleter) Complete ¶
Complete returns executable completions from PATH. Only completes when in command position (first word or after pipe).
func (*ExecutableCompleter) Name ¶
func (c *ExecutableCompleter) Name() string
Name returns the completer name.
type FileCompleter ¶
type FileCompleter struct {
// contains filtered or unexported fields
}
FileCompleter completes filesystem paths.
func NewFileCompleter ¶
func NewFileCompleter() *FileCompleter
NewFileCompleter creates a new filesystem completer.
func (*FileCompleter) SetFuzzyMode ¶
func (c *FileCompleter) SetFuzzyMode(enabled bool)
SetFuzzyMode sets whether to return all candidates (for router-level fuzzy filtering).
func (*FileCompleter) SetShowHidden ¶
func (c *FileCompleter) SetShowHidden(show bool)
SetShowHidden toggles hidden file visibility.
type FunctionProvider ¶
type FunctionProvider interface {
Functions() []string
}
FunctionProvider is the interface for getting function names from the executor.
type Item ¶
type Item struct {
Value string // The actual completion value
Display string // What to show in the menu (may differ from Value)
Description string // Optional description
Icon string // Nerd Font icon (optional)
Score int // For fuzzy sorting (higher = better match)
}
Item represents a single completion suggestion.
func FuzzyFilter ¶
FuzzyFilter filters and sorts items by fuzzy match score.
type Prefetcher ¶
Prefetcher is an optional interface for completers that support background prefetching.
type Priority ¶
type Priority int
Priority defines completer ordering (lower = higher priority).
const ( PriorityToolNative Priority = 100 // Try first for subcommand completion PriorityAlias Priority = 125 // User-defined functions/aliases (before executables) PriorityEnv Priority = 130 // Environment variables ($VAR) PriorityExecutable Priority = 150 // Executable names from PATH (command position only) PriorityFilesystem Priority = 200 // Fallback for file arguments PriorityAgent Priority = 300 // AI-powered fallback )
type Result ¶
type Result struct {
Items []Item // List of completions
Prefix string // Common prefix to preserve
}
Result holds completion results from a completer.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router dispatches completion requests to registered completers.
func (*Router) Complete ¶
Complete tries each completer in priority order until one returns results.
func (*Router) Completers ¶
Completers returns the registered completers for inspection.
func (*Router) Prefetch ¶
Prefetch triggers background prefetching for all completers that support it. Call this when the user types a space after a command.