CLI¶
The pegg binary is both the TUI launcher and a full command-line tool. Run
pegg help or pegg <command> --help at any time.
Invocation behavior¶
| Invocation | Behavior |
|---|---|
pegg on a terminal |
Launches the TUI |
pegg "message" |
Runs the orchestrator on the message (headless if stdin is not a terminal) |
pegg --stt |
Records voice, then runs the transcript as the message |
echo "msg" \| pegg |
Reads stdin, appends it to any arguments, and runs the orchestrator |
pegg <command> |
Runs the subcommand |
Errors are printed to stderr as pegg: <error> and the process exits with code
1. Successful commands exit 0. Interactive prompts cancelled with Ctrl+C
also exit 1.
pegg run¶
Run the orchestrator agent on a message, streaming its progress, tools, thinking,
and responses live. Without a message (or with --chat) it starts an interactive
chat in the same session.
pegg run "Explain the build system"
pegg run --provider openai --model gpt-4o "Review internal/agent"
pegg run --model smart-router "Fix the flaky tests" # needs smart_router.enabled
pegg run --session 3f2b1c... "Continue where we left off"
pegg run --stt
| Flag | Default | Description |
|---|---|---|
--provider |
auto | Provider to use |
--model |
auto | Model to use. smart-router selects the best model per task/agent (see Smart Router) |
--select-model |
false |
List available models and let you pick one (overrides --model) |
--session |
— | Session ID to continue |
--select-session |
false |
List sessions and pick one to continue |
--file |
— | File to attach (repeatable) |
--show-thinking |
false |
Print raw reasoning content instead of a Thinking... indicator |
--show-subagent |
false |
Print subagent messages instead of a Subagent indicator |
--chat |
false |
Keep chatting after the first run ends |
--attach |
false |
Attach to a session already running in another client (requires --session) |
--follow |
false |
With --attach, keep following later runs on the session |
--stt |
false |
Record voice; press Enter to stop and use the transcript as the message |
--plan |
false |
Start in plan mode (read-only planning) |
--build |
false |
Start in build mode (execute without plan tools) |
--auto |
false |
Start in auto mode, letting the agent plan on its own (default) |
Model resolution follows the rules in Providers & Models. When resuming a session without an explicit provider/model, the session's stored model is reused.
Modes¶
Sessions run in a mode that controls planning behaviour:
| Mode | Plan reminder | enterplanmode/exitplanmode |
|---|---|---|
build |
no | hidden |
plan |
yes (read-only, writes limited to .pegg/plans) |
hidden |
auto |
only if the model enters plan mode | available |
Pass exactly one of --plan, --build or --auto; the default is auto. When
resuming a session without a mode flag, the session's stored mode is reused. The
chosen mode is persisted to the session.
Output¶
Streaming output is plain text, with ANSI colors only when stdout is a terminal:
Running orchestrator (openai/gpt-4o)
> Explain the build system
tool [orchestrator] read(path=Makefile)
result [orchestrator] read: Path: Makefile | ...
The build is driven by a small Makefile...
• orchestrator finished (2 iterations, 1.2K tokens, $0.003100)
- Tool calls are shown as
tool [agent] name(args...); results are truncated to 500 characters. - Bash stdout/stderr streams live while the command runs; the exit code is printed when it completes.
--show-thinkingprints the model's raw reasoning; otherwise aThinking...spinner is shown on a TTY.--show-subagentprints subagent content instead of aSubagent <name>line.- When the context is compacted mid-run, a line like
↻ Context compacted (sliding-window) — 30 messages, 8000 tokensis printed.
Chat mode¶
With --chat, or when the message is empty, run enters a line-based chat loop:
Exit words: exit, quit, /exit, /quit, bye.
Voice input¶
--stt records from the default microphone and prints:
Press Enter to stop. The recording is transcribed with the STT provider and model configured under Settings → General (see Voice input). The transcript becomes the message. If a message argument is also provided, the transcript is appended to it:
A recorder must be available: sox, arecord, or ffmpeg. Override the command
with stt.record_command in ~/.pegg/pegg.json using {output} for the WAV
path.
Attachments¶
--file can be repeated. Files are copied into the attachment store
(os.TempDir()/pegg) and the agent is told their paths; image/audio/video that the
model supports are also sent inline. PDFs and text files are referenced by path
instead. See Adding Context.
Session selection¶
--select-session opens a paginated picker (10 per page) filtered to sessions from
the current project directory, showing title, provider/model, and creation time.
pegg serve¶
Start a server: the HTTP REST API by default, or ACP with --acp.
pegg serve # HTTP API on 127.0.0.1:8080
pegg serve --port 9000 --host 0.0.0.0
pegg serve --acp # ACP over HTTP at /acp
pegg serve --acp --stdio # ACP over stdin/stdout
| Flag | Default | Description |
|---|---|---|
--port |
config (8080) |
Port to listen on |
--host |
config (127.0.0.1) |
Host to bind to |
--acp |
false |
Start the ACP server instead of the HTTP API |
--stdio |
false |
Use the stdio transport (only with --acp) |
pegg login¶
Add or update a provider with an API key.
| Flag | Description |
|---|---|
--provider |
Provider name. Interactive picker when omitted |
--api-key |
API key. Masked prompt when omitted; may be empty |
The provider's model list is fetched before the config is saved, so a login only succeeds when the credentials work.
pegg login-pegg¶
Sign in to Pegg Forever or save a Pegg Forever API key.
The browser flow opens the website, waits for approval on a loopback callback,
creates a revocable API key assigned to your user, and saves the pegg-forever
provider with the default base URL https://forever.pegg.dev/v1.
| Flag | Description |
|---|---|
--token |
Save this API key directly and skip the browser |
--no-browser |
Print the approval URL instead of opening a browser |
--port |
Local callback port; 0 chooses a free port |
--device |
Device name shown on the website and used in the key name |
--defaults |
Apply the recommended defaults without asking |
--no-defaults |
Skip the recommended defaults |
--defaults-url |
Override the recommended defaults endpoint |
The same credentials are also registered for speech-to-text under
stt.providers, and the decision-model provider reuses the pegg-forever entry,
so no separate login is needed for STT or decisions.
After the provider is saved, Pegg fetches the recommended defaults document
from https://cdn.pegg.dev/defaults.json, prints the proposed changes, and asks
before writing them. In a non-interactive session it prints the changes and
skips unless --defaults is set. See
Forever defaults for the document format.
The command still saves the provider when the GET /models check fails; it
prints a warning and Pegg retries model discovery later. The aliases pegg
forever and pegg pegg-login are also accepted.
pegg team¶
Connect this machine to a team's BYOK configuration. The command opens the
website, approves a one-time connection, creates or reuses a team-scoped API key
assigned to you, and fetches the team's models and defaults. The provider is
saved as pegg-team <team>, for example pegg-team Acme.
pegg team
pegg team --team Acme
pegg team --no-browser --port 8765
pegg team --refresh
pegg team list
pegg team remove "pegg-team Acme"
| Flag / command | Description |
|---|---|
--team |
Team name to preselect on the website; otherwise the current team is used |
--provider |
Team provider to refresh |
--app-url / --api-url |
Override the website or API URL |
--device / --key-name |
Device label and API key name |
--port |
Local callback port; 0 chooses a free port |
--no-browser |
Print the approval URL instead of opening a browser |
--print |
Print the merged pegg config after connecting |
--print-secret |
Include API keys in --print output |
--force |
Save even if the provider check fails |
pegg team list |
List connected team providers |
pegg team remove NAME |
Remove a team provider from the pegg config |
The API key is reused for later connections to the same team and user; revoking it on the website forces a new key. Website-created keys cannot be reused automatically. Team AI on the website controls providers, models and defaults; see Team AI.
Over SSH¶
The callback is a loopback URL on the machine running pegg, so forward the port from your laptop. On the server:
On the laptop:
Open the printed URL and approve. The port must match --port. The server must
also reach the website API (--api-url) and the team service URL
(TEAM_SERVICE_URL). If the session is already open, add the forward with the
OpenSSH escape ~C followed by -L 8765:127.0.0.1:8765.
As an alternative, connect locally, copy ~/.pegg/pegg.json to the server, and
run pegg team --refresh there. See
Troubleshooting for the failure modes.
pegg connect¶
Connect this machine's agent to a website backend so you can chat with it from a browser. Only a pairing token is needed — create one on the website under Agents → Connect a device. The full walkthrough lives in Connect.
pegg connect <token> # first run: connect and remember the token
pegg connect # every run after that
| Subcommand | Description |
|---|---|
pegg connect login [token] |
Save a pairing token without connecting (masked prompt when omitted) |
pegg connect logout |
Forget the saved token (--all also resets the device identity) |
pegg connect status |
Relay, saved token (masked), and device identity |
pegg connect whoami |
This machine's device ID and public key |
pegg connect methods |
List every method the website may call |
pegg connect pair |
Print the device identity to register with a backend |
| Flag | Description |
|---|---|
--token |
Pairing token (may also be passed as the argument) |
--auto-approve |
Skip local confirmation for sensitive remote actions (not recommended) |
--insecure |
Allow ws:// to a non-loopback host (not recommended) |
--device-name |
Human-friendly name for this device |
--allowed-method |
Restrict methods the website may call (repeatable, supports prefix*) |
--max-concurrency |
Maximum parallel runs (default from config) |
--response-timeout |
Seconds a run may produce no output before it is failed |
The relay endpoint is built into the app, so nothing but a token is needed; point a
self-hosted website at connect.relay_url in ~/.pegg/pegg.json. The pairing
token is stored there too, and is only ever displayed masked.
pegg providers¶
| Command | Description |
|---|---|
pegg providers add |
Add a provider with full config options |
pegg providers list |
List providers with masked key and cached model count |
pegg providers refresh [--provider NAME] |
Re-fetch models, bypassing the cache |
pegg providers remove NAME |
Remove a provider and its cached models |
pegg providers add exposes every provider config field:
pegg providers add --name anthropic --api-key your-api-key
pegg providers add --driver openai --base-url http://localhost:11434/v1 --api-key ollama
| Flag | Description |
|---|---|
--name |
Registered provider name, or a custom name when combined with --driver. Interactive picker when omitted — choosing its "Custom endpoint" option prompts for a name and a driver |
--driver |
Driver for custom endpoints (openai, claude, gemini). Requires --base-url |
--api-key |
API key. Masked prompt in interactive mode; may be empty |
--base-url |
Base URL. Required for driver entries |
--header KEY=VALUE |
Request header (repeatable) |
--timeout |
Request timeout in seconds |
--max-retries |
Maximum retry count |
Running it with any of --name, --driver, or --base-url skips all prompts.
Models are fetched in the background after saving; a failed fetch does not block
the add — run pegg providers refresh to retry. Registered names use built-in
endpoints; --base-url/--driver only affect driver entries and custom names.
pegg models¶
List cached models.
| Flag | Description |
|---|---|
--provider |
Only show models for this provider |
pegg doctor¶
Check provider connectivity and look for updates.
checking providers...
openai OK (64 models)
groq FAIL llm: provider error: status 401
checking for updates...
You are running the latest version
Each provider is queried with a fresh (uncached) model fetch. If a newer release
exists, doctor asks Do you want to update? (y/N) and can install it.
pegg config¶
show prints the resolved configuration as pretty JSON with API keys masked. It is
the only config subcommand.
pegg sessions¶
| Command | Description |
|---|---|
pegg sessions list |
List sessions for the current project |
pegg sessions show ID |
Show session metadata and messages |
pegg sessions cancel ID |
Cancel the session's active run in any client |
list flags:
| Flag | Default | Description |
|---|---|---|
--search |
— | Search sessions by title |
--all |
false |
Include sessions from all projects |
--page |
1 |
Page number |
--size |
50 |
Page size |
pegg sessions list --all --search refactor
pegg sessions show 3f2b1c8e-...
pegg sessions cancel 3f2b1c8e-...
pegg run --session 3f2b1c8e-... --attach # follow a run owned by another client
See Sessions.
pegg schedule¶
Create and manage recurring background schedules. A lightweight scheduler runs
whenever a long-running Pegg process is active (TUI, serve, connect), and each
run is saved as a session titled schedule HH.MM.SS. See
Scheduling for the full guide.
pegg schedule create "PR review" --cron "0 9 * * 1-5" --prompt "Review the open PRs"
pegg schedule list
pegg schedule trigger <id>
| Command | Description |
|---|---|
pegg schedule / list [--tags a,b] |
List schedules |
pegg schedule create [name] |
Create a schedule (prompts for missing values) |
pegg schedule get <id> |
Show one schedule |
pegg schedule upcoming |
Preview the next 10 runs |
pegg schedule active |
Show currently running executions |
pegg schedule trigger <id> |
Run immediately |
pegg schedule pause <id> / resume <id> |
Disable / re-enable |
pegg schedule update <id> [flags] |
Change any field |
pegg schedule history <id> |
Past runs |
pegg schedule stats <id> |
Success rate and timing |
pegg schedule delete <id> |
Remove a schedule |
create flags: --name, --cron, --prompt, --workspace, --provider,
--model, --tags, --timeout, --max-parallel, --disabled. When --cron is
omitted interactively, Pegg offers a menu of common expressions plus a custom
option.
On an interactive terminal, the commands that take an <id> (get, trigger,
pause, resume, update, history, stats, delete) accept no id and instead
list your schedules by name for you to pick.
pegg logs¶
View application logs.
| Flag | Default | Description |
|---|---|---|
--search |
— | Search log messages |
--level |
— | Filter by DEBUG, INFO, WARN, or ERROR |
--page |
1 |
Page number |
--size |
50 |
Page size |
With the SQLite logger (default) logs come from ~/.pegg/logs.db. With the
console logger, only the current process's in-memory buffer is available.
Log level¶
logger.level in ~/.peggco/pegg.json sets the minimum level. The default is
info, which keeps logs short and user-facing.
| Level | What belongs there |
|---|---|
debug |
Provider sync, model and price cache bookkeeping, reasoning-option counts, plugin lifecycle, LSP/MCP server start-up, HTTP traces, and other infrastructure detail |
info |
User-visible progress and results: the startup summary, provider/login changes, servers listening, scheduled work, and completed CLI actions |
warn |
Conditions that did not stop Pegg but need attention, such as a provider that failed to load or an MCP server that could not connect |
error |
Actionable failures |
PEGG_DEBUG=1 forces debug for one run and wins over the configured level.
PEGG_LOG_LEVEL overrides logger.level without editing the file.
Messages follow <component>: <short message> (llm: provider loaded,
plugin: loaded). Records also carry structured fields, which are stored as
JSON and included in --search, so internal counts remain queryable without
appearing at info:
pegg cache¶
| Flag | Description |
|---|---|
--provider |
Only clear this provider's cached models |
pegg files¶
Print system file paths and whether they exist:
config exists /home/user/.pegg/pegg.json
logs exists /home/user/.pegg/logs.db
cache exists /home/user/.pegg/cache.db
sessions exists /home/user/.pegg/sessions.db
lsps missing /home/user/.pegg/lsps
vfs missing /home/user/.pegg/vfs
pegg mcp¶
| Command | Description |
|---|---|
pegg mcp list [--global\|--project] |
List configured servers |
pegg mcp add [flags] |
Add a server (interactive unless flags are given) |
pegg mcp remove NAME [--global\|--project] |
Remove a server |
pegg mcp tools [--server NAME] |
List tools exposed by connected servers |
pegg mcp search QUERY [--limit N] [--official] [--json] |
Search the catalog |
pegg mcp info ID |
Show catalog details and required env |
pegg mcp install ID [flags] |
Install a catalog server |
add flags: --global, --project, --name,
--transport stdio|sse|streamable-http (aliases local and http),
--command, --arg (repeatable), --env KEY=VALUE (repeatable), --url,
--header KEY=VALUE (repeatable).
install flags: --global (default), --project, --name, --env KEY=VALUE
(repeatable), --header KEY=VALUE (repeatable), --dry-run, --yes. See
MCP and the Catalog.
pegg lsp¶
| Command | Description |
|---|---|
pegg lsp list [--global\|--project] |
List language servers |
pegg lsp add [flags] |
Add a server (interactive unless flags are given) |
pegg lsp remove NAME [--global\|--project] |
Remove a server |
pegg lsp diag --file PATH |
Print cached diagnostics for a file |
add flags: --global, --project, --name, --command, --arg (repeatable),
--filetype (repeatable), --rootmarker (repeatable), --download URL,
--env KEY=VALUE (repeatable). See LSP.
pegg plugins¶
Install and manage standalone plugins from GitHub releases.
pegg plugins search browser
pegg plugins search browser --json
pegg plugins info owner/repo
pegg plugins install owner/repo
pegg plugins install owner/repo --version v1.2.3 --asset '*linux_amd64*'
pegg plugins list
pegg plugins list --runtime
pegg plugins update owner/repo
pegg plugins update --all --check
pegg plugins remove owner/repo --yes
pegg plugins exclude owner/repo
pegg plugins include owner/repo
pegg plugins new my-plugin --module github.com/me/my-plugin
plugins search prints NAME SOURCE VERSION PLATFORMS OFFICIAL. plugins info
with an owner/repo argument reads catalog metadata; with a bare name it shows the
installed plugin's runtime details. Catalog ids match the install argument, so a
search result installs directly. See the Catalog.
| Flag | Used by | Description |
|---|---|---|
--version |
install |
Release tag (default: latest) |
--asset |
install, update |
Asset name or glob |
--binary |
install, update |
Binary path inside an archive |
--name |
install |
Installed binary name |
--force |
install, update |
Replace/reinstall |
--require-checksum |
install, update |
Fail when no checksum is available |
--skip-checksum |
install, update |
Disable checksum verification |
--all |
update |
Update all GitHub-installed plugins |
--check |
update |
Report updates without installing |
--yes |
remove |
Skip confirmation |
--json |
list, search |
JSON output |
--runtime |
list |
Launch plugins for runtime metadata |
--limit |
search |
Maximum number of results |
Set GITHUB_TOKEN or GH_TOKEN for authenticated API requests. Set
PEGG_GITHUB_API for GitHub Enterprise. See
Plugins for asset selection, checksums, metadata,
and configuration.
pegg tui¶
Launch the terminal UI explicitly. Equivalent to running pegg on a terminal.
pegg version¶
pegg update¶
Check for a newer release and install it in place.
Current version: 0.1.0
Latest version: 0.2.0
Updating to version 0.2.0...
Successfully updated to version 0.2.0
Shell completion¶
Cobra provides completion scripts for bash, zsh, fish, and PowerShell:
pegg completion bash > /etc/bash_completion.d/pegg
pegg completion zsh > "${fpath[1]}/_pegg"
pegg completion fish > ~/.config/fish/completions/pegg.fish
Headless and scripting examples¶
# One-shot prompt, output to stdout
pegg run "List the public API of this package"
# Pipe context in
cat error.log | pegg "Explain the root cause"
# Run in CI with an explicit model and no interactive pickers
pegg run --provider openai --model gpt-4o-mini "Run the tests and fix failures"
# JSON-free plain text is emitted when stdout is not a terminal
OUTPUT="$(pegg run --provider groq --model llama-3.3-70b-versatile 'Summarize README.md')"
For structured output, use the HTTP API instead.