Documentation
¶
Index ¶
- Variables
- func SetCommandFileOpsForTest(read func(string) ([]byte, error), open func(string) (*os.File, error), ...) (restore func())
- type CommandFile
- type CommandMetadata
- type CommandRegistration
- type Definition
- type Executor
- type Handler
- type HandlerFunc
- type Invocation
- type LoaderOptions
- type Result
Constants ¶
This section is empty.
Variables ¶
var ( ErrDuplicateCommand = errors.New("commands: duplicate registration") ErrUnknownCommand = errors.New("commands: unknown command") )
var ( ErrNoCommand = errors.New("commands: no slash command found") ErrInvalidCommand = errors.New("commands: invalid command") )
Functions ¶
Types ¶
type CommandFile ¶
type CommandFile struct {
Name string
Path string
Metadata CommandMetadata
}
CommandFile captures an on-disk command definition.
type CommandMetadata ¶
type CommandMetadata struct {
Name string `yaml:"name"`
Description string `yaml:"description"`
AllowedTools string `yaml:"allowed-tools"`
ArgumentHint string `yaml:"argument-hint"`
Model string `yaml:"model"`
DisableModelInvocation bool `yaml:"disable-model-invocation"`
}
CommandMetadata describes optional YAML frontmatter fields.
type CommandRegistration ¶
type CommandRegistration struct {
Definition Definition
Handler Handler
}
CommandRegistration wires a definition to its handler.
func LoadFromFS ¶
func LoadFromFS(opts LoaderOptions) ([]CommandRegistration, []error)
LoadFromFS loads slash commands from the filesystem. It never returns a nil registrations slice. Errors are aggregated so a single bad file doesn't prevent others from loading.
type Definition ¶
Definition describes a slash command handler.
func (Definition) Validate ¶
func (d Definition) Validate() error
Validate ensures the definition is sound.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor routes parsed slash commands to registered handlers.
func (*Executor) List ¶
func (e *Executor) List() []Definition
List returns registered command definitions sorted by priority + name.
type Handler ¶
type Handler interface {
Handle(context.Context, Invocation) (Result, error)
}
Handler executes a parsed invocation.
type HandlerFunc ¶
type HandlerFunc func(context.Context, Invocation) (Result, error)
HandlerFunc turns a function into a Handler.
func (HandlerFunc) Handle ¶
func (fn HandlerFunc) Handle(ctx context.Context, inv Invocation) (Result, error)
Handle implements Handler.
type Invocation ¶
type Invocation struct {
Name string
Args []string
Flags map[string]string
Raw string
Position int
}
Invocation represents a parsed slash command invocation.
func Parse ¶
func Parse(input string) ([]Invocation, error)
Parse extracts slash commands from the input text. Each line beginning with '/' is treated as a command. Quoted arguments and --flag syntax are supported.
type LoaderOptions ¶
type LoaderOptions struct {
ProjectRoot string
// Deprecated: user-level scanning has been removed; this field is ignored.
UserHome string
// Deprecated: user-level scanning has been removed; this flag is ignored.
EnableUser bool
FS *config.FS
}
LoaderOptions controls how commands are discovered from the filesystem.