command

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 8 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 OK's single-(TOML)-dependency promise rather than pulling in a YAML library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 $.

Jump to

Keyboard shortcuts

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