slash

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package slash resolves a submitted TUI input line into an action: send text to the agent, eagerly load a skill, or report an error. It also expands a command's prompt template.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(c types.CommandConfig, args string) (string, error)

Expand renders a command's prompt template with the given args.

Types

type Action

type Action struct {
	Kind   Kind
	Text   string             // for KindSend: the message to send
	Skill  string             // for KindLoadSkill: the skill name
	Err    string             // for KindError
	Model  string             // for KindModelSet: the model to switch to
	YoloOn *bool              // for KindYolo: nil = toggle, non-nil = set explicitly (on/off)
	Mode   types.ApprovalMode // for KindApprove: the approval mode, empty = show the current one
	// ClassifierOff is /classifier off. KindClassifier also uses Endpoint
	// and Model; both empty opens the picker.
	ClassifierOff bool

	// Resume actions:
	ResumeAll bool   // KindResume: widen the picker to sessions from any cwd
	ResumeID  string // KindResume: non-empty loads this session directly, skipping the picker

	// Loop actions:
	Interval time.Duration // KindLoopStart: 0 = self-paced
	Payload  string        // KindLoopStart: the prompt/slash-command to repeat
	LoopID   string        // KindLoopStop: empty = stop all

	// Attachment actions:
	Files      []string // KindSend: resolved @path attachments
	AttachOp   AttachOp // KindAttach: which op
	AttachPath string   // KindAttach+AttachStage: file to stage
	Transcribe bool     // KindAttach+AttachStage: --transcribe/-t override

	// Login/logout actions:
	Provider string // KindLogin/KindLogout: provider ID; empty = list

	// Settings actions (KindSettings). An empty SettingKey lists every key; a
	// key alone shows it; a key with a value sets it. The value stays raw text
	// here: typing and validation need the key's type, which lives in config,
	// and slash has no business knowing the config schema.
	SettingKey      string
	SettingValue    string // raw, possibly containing spaces
	SettingHasValue bool   // a value was given (distinguishes an empty string)
	SettingUnset    bool   // the value was "default" or "unset": remove the key

	// Endpoint actions:
	Endpoint string // KindEndpoint: endpoint ID; empty = picker.

}

Action is the resolved result of a submitted input line.

func Resolve

func Resolve(input string, cmds []types.CommandConfig, skills []types.Skill, agents []types.AgentTypeConfig) Action

Resolve maps an input line to an Action. Non-slash input is sent verbatim.

type AttachOp added in v0.4.1

type AttachOp int

AttachOp enumerates the /attach sub-operations.

const (
	AttachStage AttachOp = iota // stage AttachPath (optionally Transcribe)
	AttachList                  // list staged attachments
	AttachClear                 // clear staged attachments
)

type Kind

type Kind int

Kind enumerates the resolved action types.

const (
	KindSend         Kind = iota // send Text to the agent
	KindLoadSkill                // eagerly load Skill into the session prompt
	KindError                    // report Err to the user, send nothing
	KindCompact                  // compact the current conversation
	KindLoopStart                // start a recurring/self-paced loop
	KindLoopStop                 // stop one loop (LoopID) or all (empty)
	KindLoopList                 // list active loops
	KindGoalSet                  // set/replace the session goal (Text)
	KindGoalShow                 // show the current goal
	KindGoalClear                // clear the current goal
	KindGoalResume               // resume a goal an interrupt paused
	KindAttach                   // stage/list/clear file attachments
	KindModelList                // list available models
	KindModelPick                // pick a model from the available models
	KindModelSet                 // switch the session model to Model
	KindYolo                     // toggle (or explicitly set) session-wide auto-approval
	KindResume                   // resume a recorded session (ResumeID) or open the picker
	KindLogin                    // log in to a provider (Provider empty = list)
	KindLogout                   // log out of a provider (Provider empty = list)
	KindSettings                 // list, show, set or unset a config key (SettingKey etc.)
	KindEndpoint                 // switch endpoint (Endpoint empty = open the picker)
	KindEndpointAdd              // open the add-endpoint form
	KindModelReset               // drop the saved model override for the current endpoint
	KindModelDefault             // save Model (empty = the one in use) as the endpoint's default
	KindAbout                    // print version, config paths, and tool inventory
	KindApprove                  // set the approval mode (Mode), or show it when Mode is empty
	KindClassifier               // set the classifier (Endpoint, Model), turn it off, or pick one
)

Jump to

Keyboard shortcuts

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