slashcommands

package
v0.4.56-beta Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package slashcommands provides recipe-backed slash command parsing and expansion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableRecipeNames

func AvailableRecipeNames(ctx context.Context, processor *fragments.Processor) string

AvailableRecipeNames returns a comma-separated list of available recipe names.

func BuildCommandHint

func BuildCommandHint(arguments map[string]fragments.ArgumentMeta) string

BuildCommandHint builds a hint string for a recipe based on its arguments.

func BuildCommandPlaceholder

func BuildCommandPlaceholder(command string, arguments map[string]fragments.ArgumentMeta) string

BuildCommandPlaceholder builds an example slash invocation for composer placeholders.

func BuildDisplay

func BuildDisplay(command, args string) string

BuildDisplay returns the compact user-facing slash invocation.

func Parse

func Parse(text string) (command string, args string, found bool)

Parse parses a slash command from text. The command name is everything after the leading slash up to the first space. Names may contain slashes.

func ParseArgs

func ParseArgs(args string) (kvArgs map[string]string, additionalText string)

ParseArgs parses key=value pairs and additional text from an arguments string.

Grammar:

args           = *(key_value / word) [additional_text]
key_value      = key "=" value
key            = 1*non_space_non_eq
value          = quoted_value / unquoted_value
quoted_value   = DQUOTE *non_dquote DQUOTE
unquoted_value = *non_space
word           = 1*non_space (collected as additional_text)

Types

type Command

type Command struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Hint        string `json:"hint,omitempty"`
	Placeholder string `json:"placeholder,omitempty"`
}

Command describes an available slash command backed by a recipe.

func BuiltIns

func BuiltIns() []Command

BuiltIns returns slash commands implemented by Kodelet rather than recipes.

func List

func List(ctx context.Context, processor *fragments.Processor) []Command

List returns available slash commands from the fragment/recipe system.

type Expansion

type Expansion struct {
	Command      string
	Prompt       string
	Display      string
	Arguments    map[string]string
	Instructions string
	Metadata     fragments.Metadata
}

Expansion is the result of rendering a slash command.

func Expand

func Expand(ctx context.Context, processor *fragments.Processor, command, args string) (*Expansion, error)

Expand renders a slash command into the full prompt sent to the model and a compact display string for user-facing conversation renderers.

Jump to

Keyboard shortcuts

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