commands

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package commands loads custom slash commands: Markdown files whose body is a prompt, from the user's and the project's command directories, plus the bundled ones. A command runs as a turn; its frontmatter can choose the agent, the model, the permitted tools and plan mode.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alias added in v0.5.3

func Alias(name, args string) (string, string)

Alias returns the command a line "/name args" runs, and its arguments: "skills update x" is ("skills-update", "x"), and "agents update" is ("agents-update", ""); anything else is as it was.

func ToolList added in v0.9.1

func ToolList(s string) []string

ToolList reads a skill's allowed-tools (a space- or comma-separated string, "Bash(git *)" kept whole) as toolList does: "" is nil, no limit.

func ValidName

func ValidName(name string) bool

ValidName reports whether name can be a command's.

Types

type Command

type Command struct {
	Name         string // without the slash; may be namespaced, "db:migrate"
	Description  string
	ArgumentHint string
	// Agent and Model run the command's turn as another agent or on another
	// model ("" for the session's).
	Agent string
	Model string
	// AllowedTools limits the turn to these tools: nil is no limit, and
	// empty (an allowed-tools with nothing in it) is no tools.
	AllowedTools []string
	// Plan runs the command as a plan: tools that change anything are
	// refused.
	Plan bool
	Body string
	// Source is where it came from: "bundled", "user", "project", or
	// "skill".
	Source string
	Path   string
}

Command is one slash command.

func Bundled

func Bundled() []Command

Bundled returns the commands built into Blitz.

func Load

func Load(dir, source string) ([]Command, error)

Load reads the commands under dir: every *.md file, named after its path with subdirectories as namespaces (db/migrate.md is db:migrate). Problems are returned alongside what loaded.

func Parse

func Parse(name, source, path string, data []byte) (Command, error)

Parse reads a command file's frontmatter (optional) and body.

func (Command) Expand

func (c Command) Expand(args string) string

Expand returns the command's prompt for args: $ARGUMENTS is the whole argument string, $1…$9 the words. Without $ARGUMENTS or $1, arguments are appended.

Jump to

Keyboard shortcuts

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