commands

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 58 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 defines slash commands and dispatches them to bound handlers

Index

Constants

View Source
const (
	CategorySession       = "Session"
	CategoryConfiguration = "Configuration"
	CategoryInfo          = "Info"
	CategoryToolsSkills   = "Tools & Skills"
	CategoryExit          = "Exit"
)

Category identifiers in the order the registry introduces them

View Source
const ConfirmTimeout = 300 * time.Second

ConfirmTimeout is how long a pending slash confirm stays resolvable

View Source
const DestructiveAlwaysMessage = "🔒 Future /clear, /new, /reset, and /undo will run without confirmation."

DestructiveAlwaysMessage confirms the persisted opt out on the CLI

View Source
const FlagPresent = "__present__"

FlagPresent is the value an optional argument flag takes when given without a value

View Source
const LegacyAgentProg = "icebath-agent"

LegacyAgentProg is the program name the legacy single query runner parses and reports errors under

View Source
const MaxStackedSkills = 5

MaxStackedSkills caps the leading skill tokens one line may stack

View Source
const PersistFailedProceeding = "⚠️  Couldn't persist opt-out — proceeding once."

PersistFailedProceeding is printed when the opt out could not be saved

View Source
const SlackMaxSlashCommands = 50

SlackMaxSlashCommands is the manifest cap on slash commands

View Source
const TelegramBotAPIMaxCommands = 100

TelegramBotAPIMaxCommands is the Bot API limit for setMyCommands

View Source
const TelegramDefaultMenuMax = 60

TelegramDefaultMenuMax is the default visible menu cap for Telegram

Variables

View Source
var BannerVersionLabel func(ctx context.Context) string

BannerVersionLabel is the startup banner version label, assigned by cmd/icebath from pkg/app

View Source
var Builtin = []Def{}/* 102 elements not displayed */

Builtin is every core slash command in registry order

View Source
var BuiltinPersonalities = map[string]string{
	"helpful":     "You are a helpful, friendly AI assistant.",
	"concise":     "You are a concise assistant. Keep responses brief and to the point.",
	"technical":   "You are a technical expert. Provide detailed, accurate technical information.",
	"creative":    "You are a creative assistant. Think outside the box and offer innovative solutions.",
	"teacher":     "You are a patient teacher. Explain concepts clearly with examples.",
	"kawaii":      "You are a kawaii assistant! Use cute expressions like (◕‿◕), ★, ♪, and ~! Add sparkles and be super enthusiastic about everything! Every response should feel warm and adorable desu~! ヽ(>∀<☆)ノ",
	"catgirl":     "You are Neko-chan, an anime catgirl AI assistant, nya~! Add 'nya' and cat-like expressions to your speech. Use kaomoji like (=^・ω・^=) and ฅ^•ﻌ•^ฅ. Be playful and curious like a cat, nya~!",
	"pirate":      "Arrr! Ye be talkin' to Captain Icebath, the most tech-savvy pirate to sail the digital seas! Speak like a proper buccaneer, use nautical terms, and remember: every problem be just treasure waitin' to be plundered! Yo ho ho!",
	"shakespeare": "Hark! Thou speakest with an assistant most versed in the bardic arts. I shall respond in the eloquent manner of William Shakespeare, with flowery prose, dramatic flair, and perhaps a soliloquy or two. What light through yonder terminal breaks?",
	"surfer":      "Duuude! You're chatting with the chillest AI on the web, bro! Everything's gonna be totally rad. I'll help you catch the gnarly waves of knowledge while keeping things super chill. Cowabunga!",
	"noir":        "The rain hammered against the terminal like regrets on a guilty conscience. They call me Icebath - I solve problems, find answers, dig up the truth that hides in the shadows of your codebase. In this city of silicon and secrets, everyone's got something to hide. What's your story, pal?",
	"uwu":         "hewwo! i'm your fwiendwy assistant uwu~ i wiww twy my best to hewp you! *nuzzles your code* OwO what's this? wet me take a wook! i pwomise to be vewy hewpful >w<",
	"philosopher": "Greetings, seeker of wisdom. I am an assistant who contemplates the deeper meaning behind every query. Let us examine not just the 'how' but the 'why' of your questions. Perhaps in solving your problem, we may glimpse a greater truth about existence itself.",
	"hype":        "YOOO LET'S GOOOO!!! I am SO PUMPED to help you today! Every question is AMAZING and we're gonna CRUSH IT together! This is gonna be LEGENDARY! ARE YOU READY?! LET'S DO THIS!",
}

BuiltinPersonalities are available on every surface without any config

View Source
var BuiltinSubcommands = map[string]bool{}

BuiltinSubcommands are the top level commands plugin discovery never needs to resolve

View Source
var CLITiers = map[string]string{
	"acp": linktier.Extras, "backup": linktier.Extras, "batch": linktier.Extras, "import": linktier.Extras, "browser": linktier.Extras, "vault": linktier.Extras,
	"computer-use": linktier.Extras, "cron": linktier.Extras, "kanban": linktier.Extras, "lsp": linktier.Extras, "pets": linktier.Extras,
	"update": linktier.Extras, "update-takeover": linktier.Extras, "update-finish": linktier.Extras, "update-restart-recovery": linktier.Extras,
	"update-completion": linktier.Extras, "venv-sync": linktier.Extras, "source-completion": linktier.Extras, "import-health": linktier.Extras,
	"pm": linktier.Extras, "security": linktier.Extras, "import-agent": linktier.Extras, "claw": linktier.Extras,
	"slack": linktier.Plugins, "whatsapp": linktier.Plugins, "whatsapp-cloud": linktier.Plugins, "send": linktier.Plugins,
	"camofox": linktier.Plugins, "feishu": linktier.Plugins, "google_chat": linktier.Plugins, "mcp-serve": linktier.Plugins, "meet": linktier.Extras,
	"photon": linktier.Plugins, "spotify": linktier.Plugins, "teams-pipeline": linktier.Plugins,
	"pairing": linktier.Plugins, "gateway setup": linktier.Plugins, "project bind-board": linktier.Extras,
	"egress": linktier.Plugins,
}

CLI command paths outside the core and the tier that carries each, a top level name or a parent path and subcommand

View Source
var Confirms = NewConfirmStore()

Confirms is the process wide pending confirm store

View Source
var Default = NewRegistry()

Default is the process wide command registry

View Source
var DestructiveChoices = []ConfirmChoice{
	{"once", "Approve Once", "proceed this time only"},
	{"always", "Always Approve", "proceed and silence this prompt permanently"},
	{"cancel", "Cancel", "keep current conversation"},
}

DestructiveChoices are the answers of the destructive slash confirm

View Source
var DestructiveDetails = map[string]string{
	"new":      "This starts a fresh session and discards the current conversation history.",
	"undo_one": "This removes the last user/assistant exchange from history.",
}

DestructiveDetails are the chat details for the destructive session commands

View Source
var DestructiveSkipTokens = map[string]bool{"now": true, "--yes": true, "-y": true}

DestructiveSkipTokens bypass the destructive slash confirmation inline

View Source
var ExecuteKeys = []string{"version", "egress", "profile", "bundles", "autoprune", "gateway_help", "gateway_commands"}

ExecuteKeys lists every registry owned executor key the app must bind

View Source
var Executors = map[string]Executor{
	"version":          execVersion,
	"egress":           execEgress,
	"profile":          execProfile,
	"bundles":          execBundles,
	"autoprune":        execAutoprune,
	"gateway_help":     execHelp,
	"gateway_commands": execCommands,
}

Executors maps a command's execute key to its shared executor

View Source
var ImportSources = provider.ImportSources

ImportSources lists the importers the migrate command offers

View Source
var IndicatorStyles = home.IndicatorStyles

IndicatorStyles lists the TUI busy indicator styles the /indicator command accepts

View Source
var KanbanBlockKinds = []string{"capability", "dependency", "needs_input", "transient"}

KanbanBlockKinds are the typed block reasons

View Source
var KanbanInitialStatuses = []string{"blocked", "running"}

KanbanInitialStatuses are the statuses a card may be created in

View Source
var KanbanNotifyDeliveryModes = []string{"notify", "notify+wake", "wake"}

KanbanNotifyDeliveryModes are the notifier reactions to terminal events

View Source
var KanbanSortOrders = []string{"assignee", "created", "created-desc", "priority", "priority-desc", "status"}

KanbanSortOrders are the accepted list sort keys

View Source
var KanbanStatuses = []string{"archived", "blocked", "done", "ready", "review", "running", "scheduled", "todo", "triage"}

KanbanStatuses are the board columns a task may sit in plus archived

View Source
var LoadCLIConfig func(ctx context.Context) map[string]any

CLI config loader the personality completer reads, assigned in wiring with the app loader

View Source
var NeutralPersonalityNames = map[string]bool{"": true, "none": true, "default": true, "neutral": true}

NeutralPersonalityNames are the names that mean no personality overlay

View Source
var PickerCommands = map[string]bool{"model": true, "skin": true, "personality": true}

PickerCommands get no trailing space on exact match because a space would block the picker

View Source
var PreArgparseInheritedFlags = [][2]string{{"--profile", "1"}, {"-p", "1"}}

PreArgparseInheritedFlags are consumed before parsing and carried over on relaunch

View Source
var SlackReservedCommands = map[string]bool{
	"me": true, "status": true, "away": true, "dnd": true, "shrug": true, "remind": true, "msg": true, "feed": true,
	"who": true, "collapse": true, "expand": true, "leave": true, "join": true, "open": true, "search": true,
	"topic": true, "mute": true, "pro": true, "shortcuts": true,
}

SlackReservedCommands are Slack built ins an app cannot register

View Source
var SlackViaIcebathOnly = map[string]bool{
	"moa": true, "debug": true, "egress": true, "init": true, "version": true, "diff": true,
	"update": true, "heartbeat": true, "refine": true, "review": true, "pause": true, "whoami": true,
	"platform": true, "insights": true, "discard": true, "autoprune": true,
}

SlackViaIcebathOnly lists canonical commands reachable on Slack only through the /icebath slash

View Source
var SlashTiers = linktier.SlashTiers

Slash commands outside the core and the tier that carries each

View Source
var StaticContextRefs = []NameMeta{
	{"@diff", "Git working tree diff"},
	{"@staged", "Git staged diff"},
	{"@file:", "Attach a file"},
	{"@folder:", "Attach a folder"},
	{"@git:", "Git log with diffs (e.g. @git:5)"},
	{"@url:", "Fetch web content"},
}

StaticContextRefs are the fixed @ references offered before path and fuzzy file matches

View Source
var TelegramMenuPriority = []string{
	"help", "new", "stop", "status", "egress", "resume", "sessions", "model",
	"debug", "restart", "update", "verbose", "commands",
	"approve", "deny", "queue", "steer", "bg", "btw",
	"reasoning", "usage", "platforms", "platform", "profile", "whoami",
}

TelegramMenuPriority ranks the builtins that survive the small visible menu

View Source
var ValidApprovalModes = []string{"manual", "smart", "off"}

Persistent approval modes the approvals command accepts

Functions

func ActivePersonalityName

func ActivePersonalityName(cfg map[string]any) string

Selected display.personality name when it names a known personality, empty otherwise

func AliasFor

func AliasFor(description, name string) string

AliasFor formats an alias row description

func ApplySlashTierTexts

func ApplySlashTierTexts()

ApplySlashTierTexts rewrites the builtin slash descriptions naming a feature of an unlinked tier, run once before any entry

func AvailablePersonalities

func AvailablePersonalities(cfg config.Tree) map[string]any

Built in personalities overlaid by root then agent level user definitions, later wins

func BoundGatewayCommand

func BoundGatewayCommand(name string) (gateway.RegistryCommand, bool)

Gateway view of the default registry command a typed name binds a handler to, false when it binds none

func CLITierRefusal

func CLITierRefusal(path string) (string, bool)

Refusal of a CLI command path whose tier this binary leaves out

func CmdProfile

func CmdProfile(ctx context.Context, a ProfileArgs, out, errw io.Writer, in io.Reader) error

Runs the profile action a names, a nonzero exit becoming an ExitError

func CoalesceSessionNameArgs

func CoalesceSessionNameArgs(argv []string) []string

CoalesceSessionNameArgs joins unquoted multi word session names after the resume flags

func ConfigCommandSources

func ConfigCommandSources(h string) config.ConfigCommandSources

Readers and writers a config set reaches outside the config package for a home

func DescribePersonality

func DescribePersonality(value any, width int) string

Short single line preview of a personality for list UIs, cut at width runes

func DiscordSkillCommandsByCategory

func DiscordSkillCommandsByCategory(skills SkillSource, reserved map[string]bool) ([]DiscordSkillCategory, []DiscordSkillEntry, []DiscordCollision)

DiscordSkillCommandsByCategory groups gateway skills for Discord autocomplete and reports clamp collisions

func ExitCode

func ExitCode(err error) (int, string)

ExitCode maps an execution error to the process exit status and stderr text

func GatewayAvailable

func GatewayAvailable(d *Def, gates map[string]bool) bool

GatewayAvailable reports whether a command is offered on gateway surfaces

func GatewayHelpLines

func GatewayHelpLines(r *Registry, cfg config.Tree, allowed []string) []string

GatewayHelpLines renders the gateway help catalog, restricted to allowed canonical names when given

func GatewayKnownCommands

func GatewayKnownCommands() map[string]bool

GatewayKnownCommands lists every name and alias the gateway dispatches, config gated ones included

func GenerateBash

func GenerateBash(root *cobra.Command) string

Bash completion script with top level commands, per command words and profile names

func GenerateFish

func GenerateFish(root *cobra.Command) string

Fish completion script with top level commands, their subcommands and profile names

func GenerateZsh

func GenerateZsh(root *cobra.Command) string

Zsh completion script describing top level commands, their subcommands and profile names

func Install

func Install(r *Registry)

Install registers every builtin command into a registry

func IsBangCommand

func IsBangCommand(text any) bool

Reports a shell mode submission, a string whose stripped text starts with an exclamation mark

func IsGatewayKnownCommand

func IsGatewayKnownCommand(ctx context.Context, r *Registry, name string) bool

IsGatewayKnownCommand reports whether a name is a builtin or registered plugin gateway command

func IsInterruptThenDispatch

func IsInterruptThenDispatch(name string) bool

IsInterruptThenDispatch reports whether a name resolves to an interrupt first command

func LooksLikeSlashCommand

func LooksLikeSlashCommand(text string) bool

LooksLikeSlashCommand reports whether text starts a slash command rather than an absolute path

func NormalizePersonalityName

func NormalizePersonalityName(value any) string

Canonical lower case form of a personality name, empty for every neutral spelling

func NormalizeSkillToken

func NormalizeSkillToken(token string) string

NormalizeSkillToken returns the canonical hyphenated slash key of a typed token

func NormalizeTelegramDesc

func NormalizeTelegramDesc(desc string) string

NormalizeTelegramDesc folds Unicode dashes BotFather rejects to ASCII

func ParseBangCommand

func ParseBangCommand(text string) string

Shell command inside a bang submission with exactly one leading mark removed, empty when bare

func ParseWith

func ParseWith(r *Registry, line string) (*Invocation, Kind)

ParseWith classifies a typed line against a specific registry

func PersistPersonality

func PersistPersonality(ctx context.Context, value any) bool

Writes the canonical name to display.personality of the home config, false on any failure

func PersonalityNames

func PersonalityNames(personalities map[string]any) []string

Names of a personalities mapping in the order the merge inserted them, builtins first then user entries

func PluginOptionalChoice

func PluginOptionalChoice(parser any, name, def string, choices ...string)

Declares an optional positional with choices and a default on a plugin command, as add_argument(name, nargs="?", choices=..., default=...)

func ProfileNames

func ProfileNames() []string

ProfileNames lists default plus every named profile for shell completion

func PromptText

func PromptText(value any) string

Normalizes a YAML prompt value of string or list shape to text

func Register

func Register(d Def)

Register adds a command to the default registry

func RenderPersonalityPrompt

func RenderPersonalityPrompt(value any) string

Renders a string or structured personality definition to prompt text

func RequiresArgument

func RequiresArgument(argsHint string) bool

RequiresArgument reports whether a hint makes a bare invocation incomplete

func ResolveConfigGates

func ResolveConfigGates(cfg config.Tree) map[string]bool

ResolveConfigGates returns canonical names whose gateway config gate is truthy in config

func ResolveEphemeralSystemPrompt

func ResolveEphemeralSystemPrompt(cfg map[string]any) string

Session overlay prompt, the active personality render or else the user owned agent.system_prompt

func ResolvePersonality

func ResolvePersonality(value any, cfg config.Tree) (string, string, error)

Canonical name and rendered prompt of a requested personality, neutral names resolving to empty

func ResolveSlashKey

func ResolveSlashKey[T any](command string, table map[string]T) (string, bool)

ResolveSlashKey maps a typed command to its /slug table key, underscores reading as hyphens

func RunBoundGatewayCommand

func RunBoundGatewayCommand(ctx context.Context, name, arg string, host any) error

Runs the default registry handler bound to a typed name against the host taking its turn

func RunGatewayExecQuickCommand

func RunGatewayExecQuickCommand(ctx context.Context, env *tools.Env, execCmd any, cwd string) (string, error)

Runs a gateway exec quick command with a sanitized env and redacted output, its tree stopped on timeout or cancellation

func RunHandler

func RunHandler(ctx context.Context, r *Registry, name, args string, host any) error

Runs the handler bound to a typed command or alias against the host it hands its work to

func SanitizeSlackName

func SanitizeSlackName(raw string) string

SanitizeSlackName lowers, strips invalid characters and edge punctuation and clamps to 32

func SanitizeTelegramName

func SanitizeTelegramName(raw string) string

SanitizeTelegramName lowers, folds hyphens and drops a name that would lose letters

func ScorePath

func ScorePath(filePath, query string) int

Scores a file path against a fuzzy query, higher better, zero no match, one empty query

func Shlex

func Shlex(s string) ([]string, error)

Shlex splits a line with POSIX shell quoting rules

func ShlexArgs

func ShlexArgs(cmd string) []string

ShlexArgs splits the tokens after the command word, whitespace splitting on unbalanced quotes

func ShouldBypassActiveSession

func ShouldBypassActiveSession(name string) bool

ShouldBypassActiveSession reports whether a name resolves to any command dispatched mid run

func SlackAppManifest

func SlackAppManifest(ctx context.Context, r *Registry, cfg config.Tree, requestURL string) map[string]any

SlackAppManifest returns the features.slash_commands manifest portion

func SlackSubcommandMap

func SlackSubcommandMap(ctx context.Context, r *Registry, cfg config.Tree) map[string]string

SlackSubcommandMap maps every name and alias to its /command for the /icebath handler

func SlashArgs

func SlashArgs(cmd string) string

SlashArgs returns the stripped text after the command word

func SlashLinked

func SlashLinked(name string) bool

Whether a slash command name or alias belongs to a tier this binary links

func SlashTierRefusal

func SlashTierRefusal(name string) (string, bool)

Refusal of a typed slash command whose tier this binary leaves out

func Subcommands

func Subcommands(r *Registry) map[string][]string

Subcommands maps /name to its explicit subcommands or the pipe pattern found in the hint

func TelegramMenuMaxCommands

func TelegramMenuMaxCommands(cfg config.Tree) int

TelegramMenuMaxCommands returns the configured Telegram menu cap within Bot API bounds

func TruncateDesc

func TruncateDesc(desc string, limit int) string

TruncateDesc clamps a description to a limit with an ellipsis tail

func UsageSuffix

func UsageSuffix(description, name, argsHint string) string

UsageSuffix formats a description with its usage hint

func UsePluginParser

func UsePluginParser(parser any, name string)

Asks the CLI that attaches a plugin command to build the named parser on it

Types

type ApprovalModeResult

type ApprovalModeResult struct {
	OK      bool
	Mode    string
	Changed bool
	Message string
}

Outcome of inspecting or persisting approvals.mode

func RunApprovalModeCommand

func RunApprovalModeCommand(ctx context.Context, h string, env *tools.Env, requestedMode string) (ApprovalModeResult, error)

Inspects or persists approvals.mode through the config facade, reporting the mode the guard now enforces

type ArgparseError

type ArgparseError struct {
	Cmd *cobra.Command
	Msg string
	// Leftover arguments the parser could not place, reported against the top command
	Unrecognized bool
}

ArgparseError is a parse failure reported as usage and the prog error line with exit status 2

func (*ArgparseError) Error

func (e *ArgparseError) Error() string

func (*ArgparseError) Stderr

func (e *ArgparseError) Stderr() string

Usage line followed by the prog error line, leftover arguments reported by the parser parse_args ran on

type BundleInfo

type BundleInfo struct {
	Name        string
	Slug        string
	Description string
	Skills      []string
}

BundleInfo describes one skill bundle

type BusyPolicy

type BusyPolicy string

Behaviour of a command typed while the agent is mid turn

const (
	BusyReject                BusyPolicy = "reject"
	BusyDispatch              BusyPolicy = "dispatch"
	BusyInterruptThenDispatch BusyPolicy = "interrupt_then_dispatch"
)

type CLI

type CLI struct {
	Root    *cobra.Command
	Profile string
	// contains filtered or unexported fields
}

CLI is the cobra command tree with handlers bound by path

func NewCLI

func NewCLI() *CLI

NewCLI builds the full icebath command tree with every handler unbound

func (*CLI) AddPluginCommand

func (c *CLI) AddPluginCommand(cmd *cobra.Command)

AddPluginCommand registers a plugin provided top level command

func (*CLI) Bind

func (c *CLI) Bind(path string, h CLIHandler) bool

Bind attaches a handler to the command at path and reports whether that path exists

func (*CLI) CommandArgv

func (c *CLI) CommandArgv(argv []string) []string

CommandArgv returns the subcommand and its arguments without the top level flags

func (*CLI) Completion

func (c *CLI) Completion(shell string, w io.Writer) error

Prints the zsh or fish script for that shell and the bash script for any other

func (*CLI) Execute

func (c *CLI) Execute(argv []string) error

Execute parses argv, strips the profile flag, and runs the resolved handler

func (*CLI) ExecuteParsed

func (c *CLI) ExecuteParsed(argv []string) error

Parses argv the way a bare argparse parser would and runs the bound handler, skipping the profile scan

func (*CLI) FirstPositional

func (c *CLI) FirstPositional(argv []string) (string, bool)

FirstPositional returns the first subcommand token of argv or empty

func (*CLI) InheritedFlags

func (c *CLI) InheritedFlags() []string

InheritedFlags lists the top level flags tagged to carry over on relaunch

func (*CLI) LastGiven

func (c *CLI) LastGiven(cmd *cobra.Command, names ...string) string

Flag among names given last on the command line, empty when none was given

func (*CLI) Namespace

func (c *CLI) Namespace(cmd *cobra.Command, args []string) map[string]any

Argparse style vars of a parsed invocation, every parser level from the root down with named positionals

func (*CLI) ParseReadyArgs

func (c *CLI) ParseReadyArgs(argv []string) []string

ParseReadyArgs joins multi word session names and the optional flag values the way argparse reads argv

func (*CLI) PluginCLIDiscoveryNeeded

func (c *CLI) PluginCLIDiscoveryNeeded(argv []string) bool

PluginCLIDiscoveryNeeded reports whether argv may name a plugin provided command

func (*CLI) Positional

func (c *CLI) Positional(cmd *cobra.Command, args []string, name string) string

Positional returns the named positional argument or its declared default

func (*CLI) Run

func (c *CLI) Run(argv []string)

Run executes argv and exits the process with the mapped status

func (*CLI) ScanProfileFlag

func (c *CLI) ScanProfileFlag(argv []string) (string, int, int, error)

ScanProfileFlag finds the profile flag in argv as name, tokens consumed, and index

func (*CLI) TopLevelValueFlagSets

func (c *CLI) TopLevelValueFlagSets() (map[string]bool, map[string]bool)

TopLevelValueFlagSets returns the required value and optional value flags of the root

func (*CLI) Unbound

func (c *CLI) Unbound() []string

Unbound lists every runnable command path without a handler

func (*CLI) UnknownOptions

func (c *CLI) UnknownOptions(argv []string, cmd *cobra.Command) []string

Option tokens of a parse ready argv that no parser level on the way to cmd declares

type CLIHandler

type CLIHandler func(cmd *cobra.Command, args []string) error

CLIHandler runs one bound CLI subcommand

type CommandContext

type CommandContext struct {
	Surface string
	Args    string
	Options map[string]any
}

CommandContext carries the surface name, the raw argument string and the surface options to an executor

type CommandReply

type CommandReply struct {
	Text   string
	Data   map[string]any
	Format string
}

CommandReply is the surface independent text of a shared executor with the data it derived

func ExecuteCommand

func ExecuteCommand(ctx context.Context, name string, cc CommandContext) (CommandReply, error)

Runs the shared executor of the named command, a NoExecutorError when it is unknown or has none

func RunExecute

func RunExecute(ctx context.Context, d *Def, cc CommandContext) (CommandReply, bool, error)

Reply of the definition's shared executor, false when the command has none

type CompleterSources

type CompleterSources struct {
	Ctx                context.Context
	Registry           *Registry
	Cfg                func() config.Tree
	Skills             func() map[string]SkillInfo
	Bundles            func() map[string]BundleInfo
	PluginCommands     func() map[string]string
	CommandAllowed     func(string) bool
	Skins              func() []NameMeta
	ToolsetRows        func() []ToolsetRow
	ConnectedPlatforms func() []PlatformHome
}

CompleterSources supplies the live data the slash completer reads per keystroke

type Completion

type Completion struct {
	Text    string
	Start   int
	Display string
	Meta    string
}

Completion is one prompt completion replacing the word under the cursor

type ConfirmChoice

type ConfirmChoice struct {
	Key    string
	Label  string
	Detail string
}

ConfirmChoice is one answer offered by a slash confirm prompt

type ConfirmHandler

type ConfirmHandler func(ctx context.Context, choice string) (string, error)

ConfirmHandler runs the confirmed command for a choice of once, always or cancel

type ConfirmStore

type ConfirmStore struct {
	// contains filtered or unexported fields
}

ConfirmStore holds pending slash confirms per session so adapters resolve them without the runner

func NewConfirmStore

func NewConfirmStore() *ConfirmStore

NewConfirmStore returns an empty store

func (*ConfirmStore) Clear

func (s *ConfirmStore) Clear(sessionKey string)

Clear drops the pending confirm for a session without running it

func (*ConfirmStore) ClearIfStale

func (s *ConfirmStore) ClearIfStale(sessionKey string, timeout time.Duration) bool

ClearIfStale drops a pending confirm older than the timeout and reports whether it did

func (*ConfirmStore) Pending

func (s *ConfirmStore) Pending(sessionKey string) (PendingConfirm, bool)

Pending returns the pending confirm for a session

func (*ConfirmStore) Register

func (s *ConfirmStore) Register(sessionKey, confirmID, command string, handler ConfirmHandler)

Register records a pending confirm, superseding any prior one for the session

func (*ConfirmStore) Resolve

func (s *ConfirmStore) Resolve(ctx context.Context, sessionKey, confirmID, choice string, timeout time.Duration) (string, bool)

Resolve runs the pending handler with a choice, false when stale, superseded or already resolved

type Def

type Def struct {
	Name        string
	Description string
	Category    string
	Aliases     []string
	ArgsHint    string
	Subcommands []string
	CLIOnly     bool
	BusyPolicy  BusyPolicy
	BusyHandler string
	Plugin      string
	Handler     Handler
	Meta
}

One slash command with its metadata and bound handler

func All

func All(r *Registry) []*Def

All lists registry definitions in builtin order followed by extra registrations sorted

func GatewayAvailableCommands

func GatewayAvailableCommands(r *Registry, cfg config.Tree) []*Def

GatewayAvailableCommands lists registry commands visible on gateway surfaces

func PluginEntries

func PluginEntries(r *Registry) []*Def

PluginEntries lists registered plugin commands sorted by name

func Resolve

func Resolve(name string) *Def

Resolve maps a typed name or alias, leading slash optional, to its definition

func (*Def) Describe

func (d *Def) Describe(ctx context.Context) string

Localized slash description from the catalog, the English field when no catalog carries the key

type DiscordCollision

type DiscordCollision struct {
	Name     string
	CmdKey   string
	Prior    string
	Reserved bool
}

DiscordCollision describes a skill dropped because its clamped name was taken

type DiscordSkillCategory

type DiscordSkillCategory struct {
	Name    string
	Entries []DiscordSkillEntry
}

DiscordSkillCategory groups skills nested under one top level folder

type DiscordSkillEntry

type DiscordSkillEntry struct {
	Name        string
	Description string
	CmdKey      string
}

DiscordSkillEntry is one /skill autocomplete row

type Executor

type Executor func(ctx context.Context, cc CommandContext) (CommandReply, error)

Executor formats one shared command reply from its context, never mutating an agent or session

func ResolveExecutor

func ResolveExecutor(d *Def) Executor

Shared executor of a command definition, nil when its command has no execute key in the table

type ExitError

type ExitError struct {
	Code int
	Msg  string
}

ExitError carries a process exit code and an optional message for stderr

func (*ExitError) Error

func (e *ExitError) Error() string

type GatewaySkill

type GatewaySkill struct {
	Key         string
	Description string
	RelParts    []string
}

GatewaySkill is a skill eligible as a gateway slash command with its path under its scan root

func IterGatewaySkills

func IterGatewaySkills(scope *skills.Scope, platform string) []GatewaySkill

Skills eligible as gateway slash commands for a platform

type Group

type Group struct {
	Category string
	Rows     []Row
}

Group is one help category with its rows in registry order

func CommandsByCategory

func CommandsByCategory(r *Registry) []Group

CommandsByCategory groups CLI visible commands and aliases by category in registry order

type Handler

type Handler func(ctx context.Context, inv *Invocation) error

Executes one parsed slash command against the host its invocation carries

type ImportSource

type ImportSource = provider.ImportSource

ImportSource is one native importer the migrate command offers

type Invocation

type Invocation struct {
	Name string
	Raw  string
	Args string
	Argv []string
	Def  *Def
	// Host surface the handler drives, typed by the binding package
	Host any
}

Invocation is one typed slash command with its parsed arguments

type Kind

type Kind int

Kind classifies one typed composer line

const (
	// KindPrompt is ordinary text for the agent
	KindPrompt Kind = iota
	// KindSlash is a registered slash command or alias
	KindSlash
	// KindBang is a shell command typed with a leading exclamation mark
	KindBang
	// KindSkill is a slash token with no registered command, a quick, plugin, bundle or skill candidate
	KindSkill
)

type LegacyAgentArgs

type LegacyAgentArgs struct {
	Prompt                                           []string
	Query, APIKey, EnabledToolsets, DisabledToolsets *string
	Model, BaseURL                                   string
	MaxTurns, LogPrefixChars                         int
	ListTools, SaveTrajectories, SaveSample, Verbose bool
}

LegacyAgentArgs are the parsed legacy runner options, nil where the option keeps its None default

type LegacyAgentParser

type LegacyAgentParser struct {
	Cmd *cobra.Command
	// contains filtered or unexported fields
}

LegacyAgentParser is the legacy runner argument parser, a cobra command parsed with argparse semantics

func NewLegacyAgentParser

func NewLegacyAgentParser(version string, stdout io.Writer) *LegacyAgentParser

Cobra command carrying every legacy runner flag, its help rendered the way argparse formats this parser

func (*LegacyAgentParser) Error

func (p *LegacyAgentParser) Error(msg string) error

Usage and the prog error line on stderr with exit status 2, the error ArgumentParser.error raises

func (*LegacyAgentParser) Parse

func (p *LegacyAgentParser) Parse(argv []string) (*LegacyAgentArgs, error)

Parses argv like ArgumentParser.parse_args, help and version printed with an exit status 0 error

func (*LegacyAgentParser) PrintHelp

func (p *LegacyAgentParser) PrintHelp(w io.Writer)

Writes the full argparse help of the parser

type Meta

type Meta struct {
	GatewayOnly       bool
	GatewayConfigGate string
	Execute           string
}

Meta carries the gateway and executor fields every Def embeds

func MetaOf

func MetaOf(name string) Meta

MetaOf returns the side table entry for a canonical name or alias

type NameDesc

type NameDesc struct {
	Name        string
	Description string
}

NameDesc is one platform menu entry

func GatewaySkillEntries

func GatewaySkillEntries(ctx context.Context, r *Registry, platform string, source SkillSource, maxSlots int, reserved map[string]bool,
	descLimit int, sanitize func(string) string) ([]NameDesc, int)

GatewaySkillEntries is the exported collectGatewaySkillEntries, names and descriptions with the hidden count

func TelegramBotCommands

func TelegramBotCommands(ctx context.Context, r *Registry, cfg config.Tree, includePlugins bool) []NameDesc

TelegramBotCommands returns sanitized canonical commands for setMyCommands, plugins optionally included

func TelegramMenuCommands

func TelegramMenuCommands(ctx context.Context, r *Registry, cfg config.Tree, skills SkillSource, maxCommands int) ([]NameDesc, int)

TelegramMenuCommands builds the capped Telegram menu with core, plugin then skill tiers and the hidden count

type NameMeta

type NameMeta struct {
	Name string
	Meta string
}

NameMeta pairs a completion name with its description

func LiveSkinRows

func LiveSkinRows(ctx context.Context) []NameMeta

Skin names with their description, else their source, the /skin completion rows

type NoExecutorError

type NoExecutorError struct{ Name string }

NoExecutorError reports a command name with no registry owned executor

func (*NoExecutorError) Error

func (e *NoExecutorError) Error() string

type PendingConfirm

type PendingConfirm struct {
	ConfirmID string
	Command   string
	Handler   ConfirmHandler
	CreatedAt time.Time
}

PendingConfirm is one slash command awaiting the user's choice

type PlatformHome

type PlatformHome struct {
	Name string
	Home string
}

PlatformHome names a connected gateway platform and its home channel

func LiveConnectedPlatforms

func LiveConnectedPlatforms(ctx context.Context) []PlatformHome

Connected gateway platforms with their home channel name, the /handoff completion rows

type PluginCommandEntry

type PluginCommandEntry struct {
	Name, Description, ArgsHint string
}

PluginCommandEntry is one plugin slash command with its description and stripped argument hint

func IterPluginCommandEntries

func IterPluginCommandEntries(ctx context.Context, r *Registry) []PluginCommandEntry

Plugin manager commands in registration order then registry plugin commands, a blank description localized

type ProfileArgs

type ProfileArgs struct {
	Action        string
	ProfileName   string
	Clone         bool
	CloneAll      bool
	CloneFrom     *string
	CloneChannels bool
	SyncImports   bool
	NoAlias       bool
	IsolatedAuth  bool
	NoCredentials bool
	NoSkills      bool
	Description   *string
	Yes           bool
	Text          string
	Auto          bool
	Overwrite     bool
	AllMissing    bool
	Remove        bool
	AliasName     string
	OldName       string
	NewName       string
	Output        string
	Archive       string
	ImportName    string
	Source        string
	InstallName   string
	Alias         bool
	Force         bool
	ForceConfig   bool
}

Parsed arguments of one icebath profile command line, Action empty for the bare command

type QuickCommand

type QuickCommand struct {
	Type        string
	Target      string
	Description string
}

QuickCommand is one user defined slash shortcut from config

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry maps command names and aliases to definitions

func NewRegistry

func NewRegistry() *Registry

NewRegistry returns an empty registry

func (*Registry) Lookup

func (r *Registry) Lookup(name string) *Def

Lookup resolves a name or alias to its definition

func (*Registry) Names

func (r *Registry) Names() []string

Names lists canonical command names sorted

func (*Registry) Register

func (r *Registry) Register(d Def)

Register adds a command, replacing any earlier definition of the same name

func (*Registry) Remove

func (r *Registry) Remove(name string) bool

Remove drops a command and its aliases and reports whether it existed

type Row

type Row struct {
	Command     string
	Description string
}

Row is one /command and description pair of a help listing

type ShlexError

type ShlexError struct{ Message string }

ShlexError reports unbalanced quoting

func (*ShlexError) Error

func (e *ShlexError) Error() string

type SkillInfo

type SkillInfo struct {
	Name            string
	Description     string
	SkillDir        string
	SkillMDPath     string
	SkillIdentifier string
}

SkillInfo describes one installed skill command

type SkillSource

type SkillSource func(platform string) []GatewaySkill

SkillSource yields the gateway eligible skills for a platform

func HomeSkillSource

func HomeSkillSource(h string, cfg config.Tree) SkillSource

SkillSource over the home's skills scope with the given config

type SlackSlash

type SlackSlash struct {
	Name        string
	Description string
	UsageHint   string
}

SlackSlash is one native Slack slash command

func SlackNativeSlashes

func SlackNativeSlashes(ctx context.Context, r *Registry, cfg config.Tree) []SlackSlash

SlackNativeSlashes lists every gateway command as a standalone slash under the manifest cap

type SlashCompleter

type SlashCompleter struct {
	// contains filtered or unexported fields
}

SlashCompleter completes slash commands, subcommands, skill commands, and @ references

func NewCompleter

func NewCompleter(src CompleterSources) *SlashCompleter

NewCompleter builds a completer over the given sources

func TUISlashCompleter

func TUISlashCompleter(ctx context.Context, skillCommands, skillBundles skills.SkillCommands) *SlashCompleter

Slash completer the TUI gateway runs over a session's skill and bundle tables and the live sources of the ctx profile

func (*SlashCompleter) Complete

func (c *SlashCompleter) Complete(text string) []Completion

Completions for the text before the cursor

type TelegramMenuConfig

type TelegramMenuConfig struct {
	MaxCommands  int
	PriorityMode string
	Priority     []string
}

TelegramMenuConfig is the normalized platforms.telegram.extra.command_menu block

func TelegramCommandMenuConfig

func TelegramCommandMenuConfig(cfg config.Tree) TelegramMenuConfig

TelegramCommandMenuConfig reads the command menu config with safe defaults

type ToolsetRow

type ToolsetRow struct {
	Key     string
	Label   string
	Enabled bool
}

ToolsetRow describes one toolset the /tools completer may offer

func LiveToolsetRows

func LiveToolsetRows(ctx context.Context) []ToolsetRow

Configurable and plugin toolsets with their cli enable state from the readonly config of the ctx profile

type UnboundCLIError

type UnboundCLIError struct{ Path string }

UnboundCLIError reports a CLI command the host never bound a handler to

func (*UnboundCLIError) Error

func (e *UnboundCLIError) Error() string

type UnboundError

type UnboundError struct{ Name string }

Refusal of a registered command that has no handler bound

func (*UnboundError) Error

func (e *UnboundError) Error() string

type UnknownCommandError

type UnknownCommandError struct{ Name string }

Refusal of a name no registry entry resolves

func (*UnknownCommandError) Error

func (e *UnknownCommandError) Error() string

type UnknownPersonalityError

type UnknownPersonalityError struct{ Msg string }

UnknownPersonalityError is the ValueError raised for a name no personality carries

func (*UnknownPersonalityError) Error

func (e *UnknownPersonalityError) Error() string

func (*UnknownPersonalityError) PyTypeName

func (e *UnknownPersonalityError) PyTypeName() string

Python exception class name the error stands for

Jump to

Keyboard shortcuts

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