Documentation
¶
Overview ¶
Package cli provides Sidecar's non-interactive command dispatch boundary.
Index ¶
- Constants
- func RemainingArgs(args []string) []string
- func RenderAgents(root *Command) string
- func RenderHelp(cmd *Command) string
- func RenderJSON(w io.Writer, cmd *Command) error
- func RenderMarkdownDoc(root *Command) string
- func Run(args []string, stdout, stderr io.Writer) (handled bool, exitCode int)
- func StartupConfigPage() (string, bool)
- type AgentDoc
- type ArgSpec
- type Command
- type Env
- type Example
- type ExitCode
- type Flag
- type TargetDoc
Constants ¶
const ConfigPageSetup = "setup"
ConfigPageSetup is the Configuration destination `sidecar setup` asks for. The app treats an unknown name as "the default page", which is what keeps the plumbing usable by a future caller that names a different one.
Variables ¶
This section is empty.
Functions ¶
func RemainingArgs ¶ added in v1.0.0
RemainingArgs is what the process should parse as flags after Run returns handled=false. A launch command consumes its own name, so `sidecar setup -project /x` parses -project exactly as `sidecar -project /x` does.
func RenderAgents ¶ added in v1.0.0
RenderAgents lists what an agent can do from Sidecar. It is generated from the same registry the help and the reference doc come from, so a command that grows an agent-facing use appears here by declaring it, not by someone remembering to update a list.
func RenderHelp ¶ added in v1.0.0
RenderHelp returns the formatted help string for a command.
func RenderJSON ¶ added in v1.0.0
RenderJSON writes the JSON representation of a command tree to w.
func RenderMarkdownDoc ¶ added in v1.0.0
RenderMarkdownDoc generates reference markdown documentation for the CLI command tree.
func Run ¶
Run dispatches a non-interactive command. handled=false leaves legacy TUI flag parsing entirely untouched.
func StartupConfigPage ¶ added in v1.0.0
StartupConfigPage reports the Configuration destination a launch command recorded, if any. main passes it to the app; nothing else reads it.
Types ¶
type AgentDoc ¶ added in v1.0.0
type AgentDoc struct {
Invocation string `json:"invocation,omitempty"`
Summary string `json:"summary,omitempty"`
}
AgentDoc is a command's agent-facing summary: an invocation and why it helps.
type ArgSpec ¶ added in v1.0.0
type ArgSpec struct {
Min int `json:"min"`
Max int `json:"max"` // -1 for unbounded
Description string `json:"description,omitempty"`
}
ArgSpec specifies positional argument requirements.
type Command ¶ added in v1.0.0
type Command struct {
Name string `json:"name"`
Summary string `json:"summary"`
Usage string `json:"usage"`
Long string `json:"long,omitempty"`
Targets []TargetDoc `json:"targets,omitempty"`
Flags []Flag `json:"flags,omitempty"`
Args ArgSpec `json:"args,omitempty"`
ExitCodes []ExitCode `json:"exitCodes,omitempty"`
Examples []Example `json:"examples,omitempty"`
Sub []*Command `json:"subcommands,omitempty"`
Run func(Env, []string) int `json:"-"`
// Mutates marks a command that changes state outside this process: a tmux
// session, a git worktree, a manifest, the notification log.
//
// It is what makes SIDECAR_ISOLATED_STATE a guarantee rather than a claim.
// A misconfigured proof run — the variable exported, the state tree still
// the real one — is refused by Run before the handler is entered, so it
// cannot get as far as `tmux new-session` or `git worktree add` and then
// fail an assert on the write that follows. Per-write assertions still
// exist and still fail closed; this only moves the refusal to before the
// side effects instead of after the first of them (td-8d18de).
//
// Not published in the command tree: it is dispatch's business, not a
// contract a caller reads.
Mutates bool `json:"-"`
// Launch is for a command that does not run non-interactively at all: it
// records what the app should do and hands the process back to normal
// startup by reporting handled=false. `sidecar setup` is the only one — it
// starts Sidecar the ordinary way with Configuration open, rather than
// printing a second settings interface into the terminal.
Launch func(Env, []string) (handled bool, exitCode int) `json:"-"`
// Agent is what `sidecar --agents` says about this command: the one line an
// agent needs to decide whether to reach for it. Commands without one are
// left out of that list, so it stays a short list of things worth doing
// rather than a second copy of the help.
Agent AgentDoc `json:"agent,omitempty"`
}
Command is a declarative command definition.
func RootCommand ¶ added in v1.0.0
func RootCommand() *Command
RootCommand returns the root command hierarchy.
func (*Command) FindSubcommand ¶ added in v1.0.0
FindSubcommand looks up a direct child subcommand by name.
type Env ¶ added in v1.0.0
type Env struct {
Stdout io.Writer
Stderr io.Writer
// Stdin is the caller's standard input. It is used only by surfaces that
// accept a bounded structured payload — today, a provider hook handing
// `agent report-session` its event JSON — and is nil for every command that
// does not read one.
Stdin io.Reader
StateDir string
Ctx context.Context
NotificationDelivery notifydelivery.Coordinator
FeatureOverrides map[string]bool
// IntegrationService overrides the agent-integration application service.
//
// It exists so the integration command tests describe a machine instead of
// having one: without it every test of `agent integration` would inspect,
// and the mutating ones would rewrite, the developer's real
// ~/.config/opencode.
IntegrationService *agentintegration.Service
}
Env holds the execution environment passed to a command handler.
type Example ¶ added in v1.0.0
type Example struct {
Description string `json:"description,omitempty"`
Command string `json:"command"`
}
Example illustrates command usage.
Source Files
¶
- agent.go
- agent_integration.go
- agent_lifecycle.go
- agent_remote.go
- agent_report_session.go
- agent_start_record.go
- cli.go
- command.go
- create.go
- create_shell.go
- create_worktree.go
- help.go
- host.go
- host_registry.go
- layout.go
- layout_render.go
- layout_run.go
- notify.go
- open.go
- open_target.go
- registry.go
- session.go
- setup.go
- shell_delete.go
- shell_records.go
- shell_target.go
- terminal_links.go