cmd

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func GetInitScript(shell, programName string) string

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 IsInTmux

func IsInTmux() bool

inTmux returns true if running inside tmux

func IsMCPManageSubcommand added in v0.3.0

func IsMCPManageSubcommand(s string) bool

IsMCPManageSubcommand reports whether `nib mcp <s>` is a management command (as opposed to the server-serving forms: bare, --http, --stdio, --addr).

func RunCLI

func RunCLI(ctx context.Context, cfg types.Config, streams Streams, shellJobs *wizmcp.ShellJobs, transports ...mcp.Transport) error

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

func RunMCPCommand(baseDir string, args []string) int

RunMCPCommand dispatches `nib mcp <sub> ...` and returns an exit code. baseDir overrides the config/plugins/skills root; empty means nib's default.

func RunPluginCommand

func RunPluginCommand(baseDir string, args []string) int

RunPluginCommand dispatches `nib plugin <sub> ...` and returns an exit code. baseDir overrides the config/plugins/skills root; empty means nib's default.

func RunSkillCommand

func RunSkillCommand(baseDir string, args []string) int

RunSkillCommand dispatches `nib skill <sub> ...` and returns an exit code. baseDir overrides the config/plugins/skills root; empty means nib's default.

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

func RunTmuxSplit(height string) error

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.

Types

type Streams added in v0.5.0

type Streams struct {
	In  io.Reader
	Out io.Writer
	Err io.Writer
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL