Documentation
¶
Overview ¶
Package app wires the pieces of lazyshell together: configuration, the session manager and the GUI. It owns the bootstrap sequence and nothing else.
Index ¶
- Constants
- func AllowProject(path string, out io.Writer) error
- func EditConfig(path string, out, errOut io.Writer) error
- func InitProject(dir string, out io.Writer) error
- func InitUserConfig(path string, out io.Writer) error
- func Main(args []string, out io.Writer) error
- func PrintAgentHookConfig(out io.Writer) error
- func RunCtl(inv Invocation, out io.Writer) error
- func RunHook(event string, errOut io.Writer) error
- func RunUpdate(opts Options, out io.Writer) error
- func ShowConfig(opts Options, out, errOut io.Writer) error
- type App
- type CtlOptions
- type Invocation
- type Options
Constants ¶
const ( // CommandRun is the default: start the interface. CommandRun = "" // CommandInit writes a commented lazyshell.yml in the current directory. CommandInit = "init" // CommandAllow approves a project file without launching anything, the // equivalent of `direnv allow`. CommandAllow = "allow" // CommandConfig writes or inspects the user configuration. Its verb is in // Invocation.Arg. CommandConfig = "config" // CommandHook pushes an authoritative AI agent state (Invocation.Arg) for // the calling session — the command an agent's own hook config runs, over // $LAZYSHELL_SOCK. See pkg/hook and pkg/app/hook.go. CommandHook = "hook" // CommandUpdate replaces the running binary with the latest GitHub // release — the in-binary equivalent of scripts/install.sh. See // pkg/update and pkg/app/update_cmd.go. CommandUpdate = "update" // CommandCtl drives a running lazyshell over the agent control socket: // list/read/new/send/kill/rename/wait plus the group verbs, in // Invocation.CtlVerb. Only works when // config.Control.Enabled is true — see pkg/control and pkg/app/ctl.go. CommandCtl = "ctl" )
Sub-commands. They never open the UI: both are things you run once, from a shell, about a project file.
const ( ConfigShow = "show" ConfigInit = "init" // ConfigEdit opens the user configuration in $VISUAL/$EDITOR (falling back // to nano/vim/vi) and reports what lazyshell makes of the saved file. ConfigEdit = "edit" )
Verbs of `lazyshell config`. A bare `lazyshell config` means ConfigShow: reading is safe and is what someone typing the command blind most likely wants, whereas defaulting to init would create a file they did not ask for.
Variables ¶
This section is empty.
Functions ¶
func AllowProject ¶
AllowProject implements `lazyshell allow`: approve a project file without launching anything. An empty path means "whatever this directory resolves to".
func EditConfig ¶
EditConfig implements `lazyshell config edit`: open the user configuration in the user's editor, then say what lazyshell makes of what was saved.
The check afterwards is the point of having this alongside `config init`. Hand-editing YAML is where typos come from, and lazyshell's own doctrine is that a bad key never stops it from starting — which means the mistake would otherwise surface as a silently ignored setting, much later.
func InitProject ¶
InitProject implements `lazyshell init`.
func InitUserConfig ¶
InitUserConfig implements `lazyshell config init`.
func Main ¶
Main is the whole command: parse the arguments, then either run a sub-command or open the interface. cmd/lazyshell is nothing but a call to this.
func PrintAgentHookConfig ¶
PrintAgentHookConfig implements `lazyshell init --agents`: prints the hook config for every adaptateur this phase ships (Claude Code, Codex — see RAPPORT_ANALYSE_INTEGRATION_AGENTS_IA.md for why opencode is not among them yet) instead of writing lazyshell.yml.
func RunCtl ¶
func RunCtl(inv Invocation, out io.Writer) error
RunCtl implements `lazyshell ctl <verbe>` — the agent control API's client (pkg/control). It is the deliberate opposite of RunHook in one respect: RunHook always returns nil, because a hook runs as a side effect of an agent's turn and lazyshell must never be the reason that turn fails. A ctl call *is* the agent's action. An agent that asked for a session and did not get one has to find out, so every failure here — no socket, a refused verb, an unknown session — is a non-zero exit.
Hence no errOut parameter, unlike RunHook: there is no failure this command reports and then shrugs off, so every one of them is the returned error and pkg/app's caller prints it.
func RunHook ¶
RunHook implements `lazyshell hook <event>` — the command a session's own agent hook config runs to push an authoritative state (see pkg/hook and pkg/session's SetAgentState). It always returns nil: this command's whole purpose is to run as a side effect of the agent's own hook mechanism, and a non-zero exit here would make lazyshell the reason an otherwise-healthy agent turn fails. Every failure mode — no $LAZYSHELL_SOCK (not running under lazyshell), an event name that is not one of the four states, a socket that has gone away — degrades to a diagnostic on errOut and nothing else.
func RunUpdate ¶
RunUpdate implements `lazyshell update`: replace the running binary with the latest GitHub release. `--check` only reports, `--force` reinstalls even when there is nothing newer to install.
func ShowConfig ¶
ShowConfig implements `lazyshell config show`: the configuration lazyshell would actually run with, after every layer of the precedence chain has had its say, preceded by which sources were really read.
This exists because every other answer to "why is my key not taking effect" requires reading the source. A typo lands in the warnings, an out-of-range value has been silently corrected, a project file may have overridden the shell, and $LAZYSHELL_PREFIX beats the file — none of which is visible from the file itself.
Types ¶
type App ¶
type App struct {
// contains filtered or unexported fields
}
App is the top-level object of lazyshell.
func New ¶
New builds the application without touching the terminal: it loads the configuration, discovers and (with the user's approval) starts the sessions a project file declares. A malformed config file is reported on stderr and falls back to defaults rather than preventing lazyshell from starting — the terminal is not yet taken over at this point, so it is still safe to print directly, and to prompt on stdin.
type CtlOptions ¶
type CtlOptions struct {
// Name is `ctl new --name` (the session to create) and is unused by
// `ctl rename`, whose new name is a positional argument.
Name string
// Cwd is `ctl new --cwd`: the working directory to start in.
Cwd string
// Command is `ctl new --command`: typed into the new session's shell.
Command string
// Group is `ctl new --group` (the group to create the session in) and
// `ctl list --group` (show only that group). The group verbs take theirs
// as a positional argument instead, since there it is the target rather
// than a modifier.
Group string
// Tail is `ctl read --tail`: last N lines only. Zero is the whole
// scrollback.
Tail int
// Enter is `ctl send --enter`: append a carriage return to the text.
// Off by default — pressing Enter is an explicit act, same as tmux's
// send-keys.
Enter bool
// JSON prints the raw control.Response instead of the human rendering,
// for a caller that would rather parse than scrape.
JSON bool
// State is `ctl wait --state`: the agent state to wait for (idle/working/
// blocked/done).
State string
// Timeout is `ctl wait --timeout`, in seconds. Zero or unset means
// control.DefaultWaitTimeout.
Timeout int
}
CtlOptions are `lazyshell ctl`'s own flags. Kept apart from Options, which is about the interface this command never opens.
type Invocation ¶
type Invocation struct {
Options
// Command is one of the Command* constants.
Command string
// Arg is the sub-command's positional argument: the file to approve for
// `allow`, the verb for `config`, empty for `init`.
Arg string
// CtlVerb is `ctl`'s verb, one of pkg/control's Verb* constants, already
// checked against ctlVerbs.
CtlVerb string
// CtlArgs are the verb's positional arguments, count already checked.
CtlArgs []string
// Ctl are `ctl`'s flags.
Ctl CtlOptions
}
Invocation is a fully parsed command line.
func ParseArgs ¶
func ParseArgs(args []string) (Invocation, error)
ParseArgs turns a command line into an Invocation. It lives here rather than in main so it can be tested without a process.
type Options ¶
type Options struct {
// ConfigFile is --config-file/-f: an explicit project file, which wins over
// every other discovery rule.
ConfigFile string
// NoAutostart is --no-autostart: open the UI without starting anything the
// project file declares.
NoAutostart bool
// Version is --version: print the build version and exit, without touching
// the terminal or the config. Not a sub-command, since it must also work as
// a trailing flag (`lazyshell --version`) the way most CLIs accept it.
Version bool
// Agents is `init --agents`: print the AI agent hook config blocks
// instead of writing lazyshell.yml. Meaningless outside CommandInit, so
// checked only there — see PrintAgentHookConfig.
Agents bool
// EnvFiles is one or more --env-file flags, in the order given: extra
// .env-style files loaded for every session this run creates, after each
// session's own default "<cwd>/.env" — see session.Manager.DefaultEnvFiles.
EnvFiles []string
// NoEnvFile is --no-env-file: skip the automatic "<cwd>/.env" lookup
// entirely, for every session this run creates.
NoEnvFile bool
// Check is `update --check`: report what the latest release is and stop,
// without downloading or replacing anything. Meaningless outside
// CommandUpdate, so checked only there — same as Agents above.
Check bool
// Force is `update --force`: install the latest release even when the
// installed version is not older than it, or is not a published version at
// all (a binary built from source).
Force bool
// Debug is --debug: record every keystroke, action and lifecycle event to
// config.DebugLogPath() and show the last of them in a floating panel over
// the output panel (F12 toggles it). Off by default and deliberately not a
// config key: it is a "I am chasing something right now" switch, not a
// preference, and the log holds everything typed into a shell.
Debug bool
}
Options are the run-time flags.