Documentation
¶
Overview ¶
Package commands provides slash command loading and execution.
Index ¶
- type Command
- type Loader
- type Registry
- func (r *Registry) All() []*Command
- func (r *Registry) Clear()
- func (r *Registry) Count() int
- func (r *Registry) Get(name string) (*Command, error)
- func (r *Registry) Has(name string) bool
- func (r *Registry) List() []string
- func (r *Registry) Register(cmd *Command) error
- func (r *Registry) RegisterAll(commands []*Command) error
- func (r *Registry) Remove(name string) bool
- type SlashCommandTool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct {
// Name is the unique identifier for the command (used with /name)
Name string `yaml:"name"`
// Description explains what the command does
Description string `yaml:"description"`
// Args maps argument names to their descriptions for template expansion
Args map[string]string `yaml:"args"`
// Content is the markdown template body after frontmatter
Content string `yaml:"-"`
// FilePath is the absolute path to the command file
FilePath string `yaml:"-"`
// Source indicates where the command was loaded from: "user", "project", or "builtin"
Source string `yaml:"-"`
}
Command represents a slash command with metadata and template content
func ParseBytes ¶
ParseBytes parses command data from bytes
func (*Command) UsageString ¶
UsageString returns a formatted usage string for the command
type Loader ¶
type Loader struct {
UserDir string // User-global commands directory (~/.hex/commands/)
ProjectDir string // Project-local commands directory (.hex/commands/)
BuiltinDir string // Built-in commands directory (embedded or distributed)
PluginPaths []string // Additional command paths from plugins
}
Loader discovers and loads commands from multiple directories
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores loaded commands and provides thread-safe access
func (*Registry) RegisterAll ¶
RegisterAll adds multiple commands to the registry
type SlashCommandTool ¶
type SlashCommandTool struct {
// contains filtered or unexported fields
}
SlashCommandTool allows Claude to execute slash commands
func NewSlashCommandTool ¶
func NewSlashCommandTool(registry *Registry) *SlashCommandTool
NewSlashCommandTool creates a new slash command tool with the given registry
func (*SlashCommandTool) Description ¶
func (t *SlashCommandTool) Description() string
Description returns the tool description
func (*SlashCommandTool) Execute ¶
func (t *SlashCommandTool) Execute(_ context.Context, params map[string]interface{}) (*tools.Result, error)
Execute expands and returns a slash command's content
func (*SlashCommandTool) RequiresApproval ¶
func (t *SlashCommandTool) RequiresApproval(_ map[string]interface{}) bool
RequiresApproval returns false - slash commands are safe to execute