command

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package command loads custom slash commands from Markdown files. A command is a prompt template: invoking /name substitutes the arguments into the body and sends the result as a chat turn. Loading is pure and dependency-free — a small "key: value" frontmatter parser keeps fairpeer's single-(TOML)-dependency promise rather than pulling in a YAML library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSlashCommandTool

func NewSlashCommandTool(entries []SlashEntry) tool.Tool

NewSlashCommandTool builds the tool from the invocable entries (custom commands + skills, adapted by the caller). A later entry wins on a name clash, matching the prompt's command>skill precedence when the caller orders them that way.

Types

type Command

type Command struct {
	Name        string // "review" or "git:commit", derived from the file path
	Description string // from frontmatter
	ArgHint     string // from frontmatter (argument-hint)
	Body        string // template with $ARGUMENTS / $1..$N / $$
	Source      string // originating file path, for diagnostics
}

Command is a custom slash command loaded from a .md file.

func Load

func Load(dirs ...string) ([]Command, error)

Load reads every *.md command file under each dir, in order, so a later dir overrides an earlier one on a name clash (pass the user dir first, project dir last). Missing dirs are skipped. Individual file failures are collected into the returned error but don't prevent the others from loading. The result is sorted by name.

func (Command) Render

func (c Command) Render(args []string) string

Render substitutes args into the command body: $ARGUMENTS is all args joined by spaces, $1..$N are positional (empty when absent), and $$ is a literal $.

type SlashEntry

type SlashEntry struct {
	Name        string // without the leading slash, e.g. "review" or "git:commit"
	Description string
	ArgHint     string                     // optional argument hint, for the listing
	Render      func(args []string) string // expands the template/playbook with args
}

SlashEntry is one invocable slash command exposed to the model through the slash_command tool. It is a uniform view over the two kinds the user can also type at the prompt — custom commands and skills — so the tool need not know which is which. Render turns positional args into the prompt text the command expands to (the same text typing "/name args" would send).

Jump to

Keyboard shortcuts

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