Documentation
¶
Overview ¶
Package command discovers, parses, and expands custom slash commands.
Command definitions are loaded from (in priority order):
- Project-level MD: .chord/commands/**/*.md
- Global-level MD: <config-home>/commands/**/*.md
- Project-level YAML: .chord/config.yaml commands field
- Global-level YAML: <config-home>/config.yaml commands field
First occurrence of a name wins. Built-in names are always reserved.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Expand ¶
Expand applies the $ARGUMENTS substitution rule to a template. If template contains $ARGUMENTS, all occurrences are replaced with args. If template does not contain $ARGUMENTS and args is non-empty, args is appended after two newlines. If args is empty and template has no $ARGUMENTS, template is returned as-is.
func ParseInput ¶
ParseInput splits a trimmed slash line into (commandName, arguments). commandName is without the leading "/", e.g. "review". arguments is everything after the first whitespace-separated token. Returns ("", "") if input does not start with "/".
Types ¶
type Definition ¶
type Definition struct {
Name string // without leading "/", e.g. "review" or "foo/bar"
Description string // from frontmatter; may be empty
Template string // full body (with $ARGUMENTS placeholder if present)
Location string // absolute path; YAML commands use config file path
Source string // project-md / global-md / project-yaml / global-yaml
}
Definition holds a single custom slash command.
func Load ¶
func Load(opts LoadOptions) ([]*Definition, []string)
Load scans all four layers, merges them, and returns the final definitions. Warnings from bad files or reserved names are returned but do not block loading.
func Merge ¶
func Merge(sources ...[]*Definition) ([]*Definition, []string)
Merge combines definitions from multiple sources in priority order. Built-in names are skipped with a warning. First occurrence of a name wins.
type LoadOptions ¶
type LoadOptions struct {
ProjectRoot string // project working directory
ConfigHome string // user-level config directory
ProjectCfg map[string]string // project config.yaml commands
ProjectCfgPath string // absolute path to project config.yaml
GlobalCfg map[string]string // global config.yaml commands
GlobalCfgPath string // absolute path to global config.yaml
}
LoadOptions holds the paths needed to load commands from all four layers.