Documentation
¶
Index ¶
- Variables
- func GetInitScript(shell, programName string) string
- func IsInTmux() bool
- func IsMCPManageSubcommand(s string) bool
- func RunCLI(ctx context.Context, cfg types.Config, streams Streams, ...) error
- func RunMCP(ctx context.Context, cfg types.Config, args []string, ...) error
- func RunMCPCommand(programName, baseDir string, args []string) int
- func RunPluginCommand(programName, baseDir string, args []string) int
- func RunSkillCommand(programName, baseDir string, args []string) int
- func RunTUI(ctx context.Context, cfg types.Config, height int, streams Streams, ...) error
- func RunTmuxSplit(programName, height string) error
- type Streams
Constants ¶
This section is empty.
Variables ¶
var ErrApprovalNoInput = errors.New("tool call denied: stdin closed, nothing could approve it")
ErrApprovalNoInput ends a CLI session that had to refuse a tool call because stdin was closed and nothing could approve it.
It exists to be told apart from a session that simply ran out of input, which is a success. Under the piped one-shot idiom "I answered you" and "I refused to act" would otherwise both be exit 0 with stdout discarded, which is the same false signal, pointing the other way, as the EOF that used to be a failure. app maps it to its own exit code.
Functions ¶
func GetInitScript ¶
GetInitScript returns the shell integration script for the given shell, wired to invoke programName. An empty programName means "nib", so the zero value reproduces standalone nib's script byte for byte.
programName may be more than one word, because an embedder ships nib as a subcommand ("local-ai chat") rather than as a binary. The script therefore renders it in three different shapes, which coincide only for a plain one-word name: see initScriptCommand, initScriptIdent and initScriptDisplayName.
func IsMCPManageSubcommand ¶ added in v0.3.0
IsMCPManageSubcommand reports whether `nib mcp <s>` is a management command (as opposed to the server-serving forms: bare, --http, --stdio, --addr).
func RunMCP ¶ added in v0.2.0
func RunMCP(ctx context.Context, cfg types.Config, args []string, shellJobs *wizmcp.ShellJobs, transports ...mcp.Transport) error
RunMCP serves nib's agent as an MCP server. args are the tokens after `nib mcp`; shellJobs is the shared background-shell registry; transports are the agent's tool servers.
func RunMCPCommand ¶ added in v0.3.0
RunMCPCommand dispatches `nib mcp <sub> ...` and returns an exit code. baseDir overrides the config/plugins/skills root; empty means nib's default.
programName is what the user types to reach this dispatcher, so every usage line and every "run this later" hint names something that actually exists on their machine. Empty means "nib", which keeps standalone output unchanged; an embedder passes its own several-word form ("local-ai chat").
func RunPluginCommand ¶
RunPluginCommand dispatches `nib plugin <sub> ...` and returns an exit code. baseDir overrides the config/plugins/skills root; empty means nib's default.
programName is what the user types to reach this dispatcher, so every usage line and every "run this later" hint names something that actually exists on their machine. Empty means "nib", which keeps standalone output unchanged; an embedder passes its own several-word form ("local-ai chat").
func RunSkillCommand ¶
RunSkillCommand dispatches `nib skill <sub> ...` and returns an exit code. baseDir overrides the config/plugins/skills root; empty means nib's default.
programName is what the user types to reach this dispatcher, so every usage line and every "run this later" hint names something that actually exists on their machine. Empty means "nib", which keeps standalone output unchanged; an embedder passes its own several-word form ("local-ai chat").
func RunTUI ¶
func RunTUI(ctx context.Context, cfg types.Config, height int, streams Streams, shellJobs *wizmcp.ShellJobs, transports ...mcp.Transport) error
RunTUI runs the Bubble Tea TUI.
Only streams.stdout() is honored, for the shell-capture line at the end. The interactive rendering deliberately stays on /dev/tty: the whole reason this function opens it is that stdout may be a pipe while the terminal is still there, and an embedder's Stdout is exactly as likely to be a pipe as the shell widget's. Rendering into a non-terminal writer would produce a frozen TUI, which is worse than ignoring the injection. An embedder that wants nib's output on its own streams should use CLI mode, which honors all three.
Cancelling ctx unwinds the program and returns ctx.Err(). Signals are the caller's: app.run installs the handler for standalone nib, and an embedder installs its own, because the program itself no longer listens for any. See tuiProgramOptions for why that has to be exactly one owner.
func RunTmuxSplit ¶
runTmuxSplit runs nib in a tmux split pane (like fzf-tmux -d).
`tmux split-window` returns as soon as the pane is spawned, not when its command exits, so we can't capture the inner nib's selected command from its stdout directly. Instead the inner nib writes its command to a temp file and signals a tmux channel on exit; we block on that channel, then relay the file to our own stdout — which is what the Ctrl+Space shell widget captures.
programName is how the user reaches this program, and it is load-bearing rather than cosmetic here: the pane has to re-enter nib, and for an embedder that means the host binary PLUS its subcommand. Empty means "nib". See tmuxSelfInvocation.
The temp file prefix and the tmux channel name stay "nib"-flavored. They are internal identifiers, never shown and never typed: the prefix goes to os.CreateTemp and the channel is that file's basename, so both are unique per invocation and neither is affected by a program name of any shape.
Types ¶
type Streams ¶ added in v0.5.0
Streams are the I/O endpoints a front end reads from and writes to. A nil field means the matching process stream, so the zero value reproduces standalone nib exactly and an embedder overrides only what it cares about.
The fields stay nil-able rather than being defaulted at construction so that "nobody said anything" survives the trip from app.Options, which needs that distinction to gate the TUI. Nothing in this package inspects nil-ness: every read goes through the accessors below, which resolve it to the process stream.