Documentation
¶
Overview ¶
Package core provides shared CLI infrastructure: global flags, session lifecycle, assistant wiring, tool execution, and MCP server connections.
Index ¶
- Variables
- func ConnectMCP(ctx context.Context, asst *assistant.Assistant, events chan<- ui.Event)
- func ConnectMCPServers(ctx context.Context, mcps config.StringCollection[mcp.Server], only []string, ...) ([]*mcp.Session, []string)
- func ExecuteTool(ctx context.Context, t tool.Tool, args map[string]any, eventsCh chan ui.Event, ...) (string, error)
- func HeadlessUI(_ Flags) (ui.UI, error)
- func InteractiveUI(flags Flags) (ui.UI, error)
- func NewAssistant(flags Flags, events chan<- ui.Event, onProgress func(string)) (*assistant.Assistant, *slash.Registry, error)
- func NotSet(string) bool
- func OutputError(w io.Writer, jsonOutput bool, err error) error
- func OutputResult(w io.Writer, jsonOutput bool, output string, err error) error
- func OutputSetupError(w io.Writer, jsonOutput bool, err error) error
- func ProjectConfigDir() string
- func Run() error
- func RunInteractive(ctx context.Context, cancel context.CancelCauseFunc, asst *assistant.Assistant, ...) error
- func RunSession(flags Flags, makeUI func(Flags) (ui.UI, error), work SessionFunc) error
- func RunSingleTool(w io.Writer, toolName string, toolArgs map[string]any) error
- func StoreFlags(f Flags)
- type Flags
- type InitFlags
- type LoginFlags
- type ModelsFlags
- type PluginsAddFlags
- type PluginsFlags
- type PluginsUpdateFlags
- type QueryFlags
- type RunFlags
- type SessionFunc
- type SkillsAddFlags
- type SkillsFlags
- type SkillsUpdateFlags
- type SpeakFlags
- type TasksFlags
- type TasksRunFlags
- type ToolsFlags
- type TranscribeFlags
- type WebFlags
Constants ¶
This section is empty.
Variables ¶
var EmbeddedConfig embed.FS
EmbeddedConfig holds the embedded .aura configuration.
var ErrUserAbort = errors.New("user abort")
ErrUserAbort is the cancellation cause set when the user sends SIGINT/SIGTERM. Programmatic cancellations (timeouts, parent context) use different causes, allowing downstream code to distinguish user intent from infrastructure errors.
var LaunchDir string
LaunchDir holds the CWD at process start, before os.Chdir(--workdir). Set in PersistentPreRunE, used by tasks for template variable expansion.
var WorkDir string
WorkDir holds the effective working directory after os.Chdir(--workdir). Defaults to LaunchDir when --workdir is not set.
Functions ¶
func ConnectMCP ¶
ConnectMCP connects to MCP servers in parallel and registers tools on the assistant. Blocks until all servers are connected or confirmed unreachable.
func ConnectMCPServers ¶
func ConnectMCPServers( ctx context.Context, mcps config.StringCollection[mcp.Server], only []string, interactive bool, ) ([]*mcp.Session, []string)
ConnectMCPServers connects to enabled MCP servers and returns sessions + warnings. When only is non-empty, only servers in the whitelist are connected. Used by the tools command for standalone MCP connection.
func ExecuteTool ¶
func ExecuteTool( ctx context.Context, t tool.Tool, args map[string]any, eventsCh chan ui.Event, interactive bool, ) (string, error)
ExecuteTool runs a tool with a spinner and events bridge when interactive. When interactive is true, a spinner shows progress and tool-emitted SpinnerMessage events update the spinner text. When false, the tool runs silently.
func HeadlessUI ¶
HeadlessUI creates a headless UI for non-interactive commands.
func InteractiveUI ¶
InteractiveUI creates a TUI or Simple UI based on flags.
func NewAssistant ¶
func NewAssistant( flags Flags, events chan<- ui.Event, onProgress func(string), ) (*assistant.Assistant, *slash.Registry, error)
NewAssistant creates a configured assistant with slash commands wired. MCP connections are NOT made here — they happen in the background after the UI starts. Returns the assistant and the slash registry (for hint resolution by the TUI).
func OutputError ¶
OutputError handles error output in both plain and JSON formats.
func OutputResult ¶
OutputResult handles both plain and JSON output for tool results.
func OutputSetupError ¶
OutputSetupError handles setup/infrastructure errors (config, plugins, estimator). Like OutputError, but marks the result as a setup error so the parent process can route it to the user instead of the LLM.
func ProjectConfigDir ¶
func ProjectConfigDir() string
ProjectConfigDir returns .aura in the current directory if it exists, or "".
func RunInteractive ¶
func RunInteractive(ctx context.Context, cancel context.CancelCauseFunc, asst *assistant.Assistant, u ui.UI) error
RunInteractive is the SessionFunc for interactive commands (run, web). It wires the Ask tool, starts the assistant loop, and blocks on the UI.
func RunSession ¶
RunSession handles the full assistant session lifecycle: flags, config, UI, assistant, MCP, signal handling, graceful shutdown, auto-save. The work callback does the mode-specific processing.
func RunSingleTool ¶
RunSingleTool handles the full lifecycle of a single-tool CLI command: flags, config, tool registry, lookup, execute, print output. Used by vision, transcribe, and speak commands.
func StoreFlags ¶
func StoreFlags(f Flags)
StoreFlags saves the parsed flags for later retrieval via GetFlags. Called once from the root Before hook after Destination pointers are resolved.
Types ¶
type Flags ¶
type Flags struct {
Config []string
Provider string
Agent string
Model string
EnvFile []string
Workdir string
Show bool
Print bool
PrintEnv bool
Simple bool
Auto bool
Mode string
System string
Think string
Debug bool
Experiments bool
WithoutPlugins bool
UnsafePlugins bool
Resume string
Continue bool
Output string
IncludeTools []string
ExcludeTools []string
IncludeMCPs []string
ExcludeMCPs []string
MaxSteps int
TokenBudget int
Providers []string
Dry string
Set map[string]string
Home string
Mirror *mirror.Mirror
Writer io.Writer
// Subcommand flags (nested by command path).
Run RunFlags
Web WebFlags
Models ModelsFlags
Tools ToolsFlags
Query QueryFlags
Init InitFlags
Transcribe TranscribeFlags
Speak SpeakFlags
Tasks TasksFlags
Plugins PluginsFlags
Skills SkillsFlags
Login LoginFlags
// IsSet reports whether a root-level flag was explicitly set via CLI or env var.
// Wired to cmd.IsSet in the Before hook.
IsSet func(string) bool
}
Flags holds all CLI flag values, resolved via urfave/cli Destination pointers. Persistent (root) flags are top-level fields; subcommand flags are nested in per-command sub-structs. Precedence: CLI flag > AURA_* env var > default value.
func GetFlags ¶
func GetFlags() Flags
GetFlags returns the flags stored during the root Before hook.
func (Flags) ConfigOptions ¶
ConfigOptions returns the base config.Options derived from CLI flags. Callers that need additional fields (WithPlugins, ExtraTaskFiles, etc.) can mutate the returned struct before passing it to config.New.
func (Flags) Homes ¶
Homes returns all config directories in merge order: global home first, then the --config entries. Files.Load iterates left-to-right with last-wins dedup.
func (Flags) LoadEnvFiles ¶
LoadEnvFiles loads environment files from the EnvFile list. When explicit is true (CLI flag or AURA_ENV_FILE), every file must exist. When false (default), missing files are silently ignored.
type LoginFlags ¶
type LoginFlags struct {
Local bool
}
type ModelsFlags ¶
type PluginsAddFlags ¶
type PluginsFlags ¶
type PluginsFlags struct {
Add PluginsAddFlags
Update PluginsUpdateFlags
}
type PluginsUpdateFlags ¶
type QueryFlags ¶
type QueryFlags struct {
Top int
}
type SessionFunc ¶
type SessionFunc func(ctx context.Context, cancel context.CancelCauseFunc, asst *assistant.Assistant, u ui.UI) error
SessionFunc is the mode-specific work done within a session. It receives a cancellable context, the fully-wired assistant, and the UI. For interactive mode, this runs Loop() + UI.Run(). For batch mode, this runs ProcessInput() calls sequentially.
type SkillsAddFlags ¶
type SkillsFlags ¶
type SkillsFlags struct {
Add SkillsAddFlags
Update SkillsUpdateFlags
}
type SkillsUpdateFlags ¶
type SkillsUpdateFlags struct {
All bool
}
type SpeakFlags ¶
type SpeakFlags struct {
Voice string
}
type TasksFlags ¶
type TasksFlags struct {
Files []string
Run TasksRunFlags
}
type TasksRunFlags ¶
type ToolsFlags ¶
type TranscribeFlags ¶
type TranscribeFlags struct {
Language string
}