commands

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 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 is the one place slash commands are defined. The terminal UI, the web chat, and the messaging gateways all dispatch through it, so a command behaves the same wherever it is typed and only has to be written once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(line string) (name, args string, ok bool)

Parse splits a typed line into a command name and its arguments. It reports false when the line is not a command at all, so callers can pass ordinary messages straight through.

Types

type Action

type Action struct {
	Kind  string `json:"kind,omitempty"`
	Value string `json:"value,omitempty"`
}

Action is a machine-readable instruction for the calling surface, returned alongside the human-readable output.

type Deps

type Deps struct {
	Config  func() *config.Config
	Agent   *agent.Agent
	Store   store.Store
	Skills  *skills.Manager
	MCP     *mcp.Manager
	Reload  func() error
	Version string
	// WebURL is the dashboard address, shown by /web.
	WebURL string
}

Deps are the services commands read and write. Any of them may be nil; a command that needs a missing one says so rather than panicking.

type Input

type Input struct {
	// Name is the command without its leading slash.
	Name string
	// Args is everything after the command name, trimmed.
	Args string
	// SessionID is the conversation the command was typed in, when there is one.
	SessionID string
	Surface   Surface
}

Input is one invocation.

type Result

type Result struct {
	// Output is markdown to show in the transcript.
	Output string `json:"output"`
	Action Action `json:"action,omitempty"`
}

Result is what running a command produced.

func Run

func Run(ctx context.Context, d Deps, in Input) (Result, error)

Run executes a command. An unknown name is an error the caller shows as-is.

type Spec

type Spec struct {
	Name    string `json:"name"`
	Summary string `json:"summary"`
	// Args is a usage hint like "<id>", empty when the command takes none.
	Args string `json:"args,omitempty"`
	// Surfaces lists where the command is offered.
	Surfaces []Surface `json:"surfaces"`
	// Client marks a command the calling surface must carry out itself —
	// clearing its own transcript, quitting, opening a page. The server has no
	// way to do those, so it only reports the intent.
	Client bool `json:"client,omitempty"`
}

Spec describes a command for palettes and help output.

func Catalogue

func Catalogue(s Surface) []Spec

Catalogue returns the commands offered on a surface, sorted by name. Passing an empty surface returns everything.

func Lookup

func Lookup(name string) (Spec, bool)

Lookup finds one command.

type Surface

type Surface string

Surface is where a command was typed. Some commands only make sense in one of them — /quit means nothing in a browser tab.

const (
	SurfaceTUI     Surface = "tui"
	SurfaceWeb     Surface = "web"
	SurfaceGateway Surface = "gateway"
)

Jump to

Keyboard shortcuts

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