Documentation
¶
Overview ¶
Package commands implements the slash-command registry for conduit.
Mirrors src/commands/ from the TS source. Each command is a function that receives the argument string and returns a Result. The TUI dispatches slash commands before sending to the agent loop.
Package commands — status output styling helpers.
Slash commands return Result{Type: "text"} and the TUI renders the text as a system message. To make labeled status output readable on dark backgrounds we embed ANSI escape sequences directly. The TUI render layer renders the "· " prefix dim and lets these escapes show through.
All ANSI escape constants derive from theme.Active() and rebuild on theme switch via theme.OnChange.
Index ¶
- func RegisterAccountCommand(r *Registry)
- func RegisterBuddyCommand(r *Registry, getUserID func() string)
- func RegisterBuiltins(r *Registry)
- func RegisterBundledSkillCommands(r *Registry)
- func RegisterCompactCommand(r *Registry)
- func RegisterCoordinatorCommand(r *Registry)
- func RegisterHooksCommand(r *Registry, hooksConfig *settings.HooksSettings)
- func RegisterMCPApproveCommand(r *Registry, manager *mcp.Manager, cwd string)
- func RegisterMCPCommand(r *Registry, manager *mcp.Manager)
- func RegisterMiscCommands(r *Registry)
- func RegisterModelCommand(r *Registry, getModel func() string, setModel func(string))
- func RegisterOutputStyleCommand(r *Registry, cwd string)
- func RegisterPermissionsCommand(r *Registry, gate *permissions.Gate)
- func RegisterPluginBrowserCommand(r *Registry, ps []*plugins.Plugin)
- func RegisterPluginCommands(r *Registry, ps []*plugins.Plugin)
- func RegisterPromptCommands(r *Registry)
- func RegisterRTKCommands(r *Registry)
- func RegisterRecordingCommand(r *Registry)
- func RegisterSessionCommands(r *Registry, state *SessionState)
- func RegisterSkillsCommand(r *Registry, ps []*plugins.Plugin)
- func RegisterTerminalSetupCommand(r *Registry)
- type Command
- type Handler
- type PickerOption
- type PluginPanelData
- type PluginPanelInstalledEntry
- type PluginPanelMarketplaceRow
- type Registry
- type Result
- type SessionState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterAccountCommand ¶
func RegisterAccountCommand(r *Registry)
RegisterAccountCommand adds the /account slash command.
func RegisterBuddyCommand ¶
RegisterBuddyCommand adds /buddy to display and manage the companion.
func RegisterBuiltins ¶
func RegisterBuiltins(r *Registry)
RegisterBuiltins adds the standard slash commands to r. compact and model commands that need external state are wired in the TUI.
func RegisterBundledSkillCommands ¶
func RegisterBundledSkillCommands(r *Registry)
RegisterBundledSkillCommands registers slash commands for built-in skills (/simplify, /remember, etc.). These run the skill body as a user prompt, same flow as plugin slash commands.
func RegisterCompactCommand ¶
func RegisterCompactCommand(r *Registry)
RegisterCompactCommand adds /compact that callers implement by returning Type=="compact".
func RegisterCoordinatorCommand ¶
func RegisterCoordinatorCommand(r *Registry)
RegisterCoordinatorCommand adds /coordinator that toggles coordinator mode on/off. When active, the agent acts as an orchestrator managing sub-agent workers.
func RegisterHooksCommand ¶
func RegisterHooksCommand(r *Registry, hooksConfig *settings.HooksSettings)
RegisterHooksCommand adds /hooks showing configured hook matchers.
func RegisterMCPApproveCommand ¶
RegisterMCPApproveCommand registers /mcp-approve, the back-end for the startup approval picker. Args: "<server-name> <yes|yes_all|no>". Persists the choice to user settings then triggers a reconnect for "yes"/"yes_all".
func RegisterMCPCommand ¶
RegisterMCPCommand registers /mcp — interactive MCP server browser.
func RegisterMiscCommands ¶
func RegisterMiscCommands(r *Registry)
RegisterMiscCommands adds miscellaneous slash commands.
func RegisterModelCommand ¶
RegisterModelCommand adds /model with the current model name and a setter.
func RegisterOutputStyleCommand ¶
RegisterOutputStyleCommand adds /output-style to list and activate output styles.
func RegisterPermissionsCommand ¶
func RegisterPermissionsCommand(r *Registry, gate *permissions.Gate)
RegisterPermissionsCommand adds /permissions showing current mode and allow/deny/ask lists.
func RegisterPluginBrowserCommand ¶
RegisterPluginBrowserCommand registers /plugin and its subcommands.
func RegisterPluginCommands ¶
RegisterPluginCommands registers slash commands for all loaded plugins.
func RegisterPromptCommands ¶
func RegisterPromptCommands(r *Registry)
RegisterPromptCommands registers slash commands that inject a canned prompt into the agent as a user turn. Mirrors the "type: prompt" commands in src/commands/ of the TS source.
func RegisterRTKCommands ¶
func RegisterRTKCommands(r *Registry)
RegisterRTKCommands adds /rtk gain and /rtk discover slash commands.
func RegisterRecordingCommand ¶
func RegisterRecordingCommand(r *Registry)
RegisterRecordingCommand registers the /record slash command.
Usage:
/record — toggle: start if not recording, stop if recording /record start — start recording /record stop — stop recording
The recording is written to ~/.claude/recordings/<timestamp>.cast in asciicast v2 format, readable by asciinema play.
func RegisterSessionCommands ¶
func RegisterSessionCommands(r *Registry, state *SessionState)
RegisterSessionCommands registers all session-dependent slash commands.
func RegisterSkillsCommand ¶
RegisterSkillsCommand registers /skills — lists available skills from installed plugins.
func RegisterTerminalSetupCommand ¶
func RegisterTerminalSetupCommand(r *Registry)
RegisterTerminalSetupCommand adds /terminalSetup, which detects the user's terminal via TERM_PROGRAM and prints either:
- "no setup needed" for native CSI-u terminals, or
- the exact manual recipe for terminals that need configuration (Apple Terminal, VSCode, Cursor, Windsurf, Alacritty, Zed).
Mirrors src/commands/terminalSetup/terminalSetup.tsx — currently info-only (the user runs the recipe themselves). The plist/keybindings. json automation in CC's source is a future commit; doing it info-only first keeps user dotfiles untouched until we ship a tested backup/restore path.
Types ¶
type PickerOption ¶
PickerOption is one row in the small generic picker overlay used by /theme, /model, and /output-style. Exported because the TUI parses these via JSON (see model.go renderPicker).
type PluginPanelData ¶
type PluginPanelData struct {
Installed []PluginPanelInstalledEntry `json:"installed"`
Marketplaces []PluginPanelMarketplaceRow `json:"marketplaces"`
Errors []string `json:"errors"`
}
PluginPanelData is the JSON payload sent via "plugin-panel" result.
type PluginPanelInstalledEntry ¶
type PluginPanelInstalledEntry struct {
ID string `json:"id"` // "name@marketplace"
Name string `json:"name"`
Marketplace string `json:"marketplace"`
Version string `json:"version"`
Scope string `json:"scope"`
Enabled bool `json:"enabled"`
InstallPath string `json:"installPath"`
}
PluginPanelInstalledEntry is one installed plugin entry for the panel.
type PluginPanelMarketplaceRow ¶
type PluginPanelMarketplaceRow struct {
Name string `json:"name"`
Source string `json:"source"` // human-readable source string
LastUpdated string `json:"lastUpdated"`
PluginCount int `json:"pluginCount"` // from marketplace.json, 0 if unavailable
}
PluginPanelMarketplaceRow is one marketplace row for the panel.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all registered slash commands.
type Result ¶
type Result struct {
// Type is "text", "clear", "model", "compact", "prompt", "error", etc.
Type string
// Text is the message to display or the prompt to inject (for Type=="prompt").
Text string
// Model is the new model name (for Type=="model").
Model string
}
Result is what a command returns to the TUI.
type SessionState ¶
type SessionState struct {
GetCost func() string
GetVimMode func() bool
SetVimMode func(bool)
GetEffort func() string
SetEffort func(string)
GetFast func() bool
SetFast func(bool)
Logout func() error
GetHistory func() []string // message contents for /files, /context
GetCwd func() string
// Rewind removes the last n conversation turns from in-memory history.
// Returns the number of turns actually removed.
Rewind func(n int) int
// SearchTranscript searches all session transcripts for cwd and returns results.
SearchTranscript func(term string) string
// GetTokens returns current (inputTokens, outputTokens, costUSD) from LiveState.
GetTokens func() (int, int, float64)
// GetTurnCosts returns the per-turn cost deltas for the current session.
GetTurnCosts func() []float64
// GetStatus returns a one-line status string (model, mode, session ID, cost, context %).
GetStatus func() string
// GetTasks returns a formatted list of active TaskTool tasks.
GetTasks func() string
// GetAgents returns a formatted list of active sub-agents.
GetAgents func() string
// GetLastThinking returns the last assistant thinking blocks as text.
GetLastThinking func() string
// GetColor returns the current ANSI color toggle state.
GetColor func() bool
// SetColor sets the ANSI color toggle.
SetColor func(bool)
// CopyLastResponse copies the last assistant response to clipboard.
// Returns "" on success, error message otherwise.
CopyLast func() string
// RenameSession sets the title of the current session.
RenameSession func(title string) error
// TagSession assigns a tag label to the current session. Empty clears.
TagSession func(tag string) error
// GetSessionTag returns the active tag for the current session ("" if none).
GetSessionTag func() string
// GetSessionFiles returns (reads, writes) file paths from session JSONL.
GetSessionFiles func() (reads, writes []string)
// GetRateLimitWarning returns the current rate limit warning string (empty if none).
GetRateLimitWarning func() string
// CheckAuth returns nil if the current bearer token is valid, error otherwise.
CheckAuth func() error
// ExtractMemory triggers the memory extraction sub-agent over the recent
// conversation. Returns a brief status string (or error). Wired in run.go
// because the sub-agent runner lives on the agent.Loop.
ExtractMemory func() (string, error)
// GetSessionInfo returns session ID, file path, message count, and start time.
GetSessionInfo func() (id, path string, messages int, startedAt time.Time)
// GetSessionActivity returns last-activity time for idle reporting in /session.
GetSessionActivity func() time.Time
// GetKeybindings returns the flat binding list from the active resolver so
// /keybindings can show actual (including user-customized) bindings.
GetKeybindings func() []keybindings.Binding
}
SessionState holds mutable session state that slash commands can read/modify.