Skip to main content
The palyra-cli crate provides the primary command-line interface for operators to manage both local and remote Palyra runtimes crates/palyra-cli/src/lib.rs#1-5. It serves as a unified entry point for administrative tasks, agent interaction, and system diagnostics. The CLI is built using a strict output contract where all user-visible strings and JSON field names are pinned by parity and snapshot tests crates/palyra-cli/src/lib.rs#23-25.

Architecture Overview

The CLI follows a dispatch lifecycle managed by the RootCommandContext. It parses global options to establish the environment before executing specific subcommand logic.

CLI Execution Lifecycle

The following diagram illustrates how a command moves from the shell into the internal execution logic. CLI Dispatch Pipeline Sources: crates/palyra-cli/src/lib.rs#3-15, crates/palyra-cli/src/app/mod.rs#45-58, crates/palyra-cli/src/args/mod.rs#1-12

Key Components

ComponentRoleCode Reference
CliTop-level clap derive structure for argument parsing.crates/palyra-cli/src/args/mod.rs#12
RootCommandContextResolves profiles, state roots, and connection endpoints.crates/palyra-cli/src/app/mod.rs#45
CliConnectionProfileNamed configuration for targeting specific environments.crates/palyra-cli/src/app/mod.rs#153
OutputFormatArgGlobal flag for switching between Text, JSON, and NDJSON.crates/palyra-cli/src/args/mod.rs#97-101
Sources: crates/palyra-cli/src/app/mod.rs#45-153, crates/palyra-cli/src/args/mod.rs#1-153

Command Families

The CLI is organized into functional groups, often referred to as “command families” crates/palyra-cli/src/args/mod.rs#154-191. Command Hierarchy Mapping Sources: crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#5-66, crates/palyra-cli/src/commands/mod.rs#4-67

CLI Architecture and Core Commands

This group handles the fundamental lifecycle of the Palyra installation. It includes setup (the preferred bootstrap workflow), gateway (admin and runtime diagnostics), and the doctor diagnostic system for environment repair crates/palyra-cli/src/args/mod.rs#175-179. For details, see CLI Architecture and Core Commands.

Agent and Session Commands

These commands facilitate interaction with agents. The acp command provides the Agent Control Protocol bridge, while agent allows for interactive or one-off sessions crates/palyra-cli/src/args/mod.rs#71-75. This family also includes the tui (Terminal User Interface) and the mcp (Model Context Protocol) facade crates/palyra-cli/src/args/mod.rs#110-148. For details, see Agent and Session Commands.

CLI Output, Profiles, and Auxiliary Commands

This family manages the operator’s local environment. The profile command manages a registry of connection profiles (local, remote, or custom) with isolated state roots crates/palyra-cli/src/args/profile.rs#10-27. It also covers auth for credential management and backup for portable system snapshots crates/palyra-cli/src/args/mod.rs#81-85. For details, see CLI Output, Profiles, and Auxiliary Commands.

Design Patterns

Profile Isolation

The CLI enforces isolation by assigning per-profile state roots and config snapshots crates/palyra-cli/src/args/profile.rs#25-27. When a profile is created via palyra profile create, it typically resides in a subdirectory of the global state root crates/palyra-cli/src/app/mod.rs#34-39.

Global Guardrails

Parity Testing

The CLI maintains a CliParityMatrix to ensure feature parity across platforms and consistent help output crates/palyra-cli/tests/cli_parity_matrix.toml#1-15. Help snapshots are pinned for every command to prevent accidental UX regressions crates/palyra-cli/tests/help_snapshots.rs#1-8. Sources: crates/palyra-cli/src/app/mod.rs#32-58, crates/palyra-cli/src/args/profile.rs#10-27, crates/palyra-cli/tests/cli_parity_matrix.toml#1-15, crates/palyra-cli/tests/help_snapshots.rs#1-8

Child Pages