Skip to main content
The palyra CLI is the primary operator interface for managing both local and remote Palyra runtimes. It is built using clap and provides a hierarchical command structure for bootstrap, diagnostics, agent orchestration, and system configuration.

CLI Architecture and Global Flags

The CLI entry point is defined in crates/palyra-cli/src/args/mod.rs using the Cli struct crates/palyra-cli/src/args/mod.rs#1-140. It implements a set of global options that influence how the CLI interacts with the daemon and local state.

Global Options

FlagDescriptionCode Reference
--profileSelects a named configuration profile from cli/profiles.toml.crates/palyra-cli/src/args/mod.rs#60-60
--configExplicit path to a palyra.toml daemon configuration file.crates/palyra-cli/src/args/mod.rs#62-62
--state-rootOverrides the root directory for local state (logs, identity, etc.).crates/palyra-cli/src/args/mod.rs#64-64
--output-formatSwitches output between text, json, and ndjson.crates/palyra-cli/src/args/mod.rs#73-76
--verboseIncreases logging verbosity (-v for debug, -vv for trace).crates/palyra-cli/src/args/mod.rs#66-67
Sources: crates/palyra-cli/src/args/mod.rs#1-140, crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#55-80

Command Tree Overview

The CLI structure is divided into several functional families. While many commands are top-level for convenience, they often map to underlying gRPC services or local state managers.

Core Lifecycle and Setup

Agent and Runtime Operation

System and Security

Sources: crates/palyra-cli/src/args/mod.rs#1-108, crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#5-54

Implementation Data Flow

The following diagram illustrates how a CLI command is parsed, routed through the transport layer, and executed against the daemon.

CLI Command Execution Flow

Sources: crates/palyra-cli/src/lib.rs#76-90, crates/palyra-cli/src/transport/mod.rs#1-10, crates/palyra-daemon/src/transport/http/handlers/console/diagnostics.rs#6-114

The Doctor Diagnostic System

The doctor command implements a complex recovery and repair system defined in crates/palyra-cli/src/commands/doctor/recovery.rs. It can detect and fix issues ranging from missing config files to corrupted browser profiles.

Key Components

Doctor Execution Logic

Sources: crates/palyra-cli/src/commands/doctor/recovery.rs#8-175, crates/palyra-daemon/src/transport/http/handlers/console/diagnostics.rs#6-114

CLI Parity Matrix and Testing

To ensure consistency across platforms and prevent command drift, Palyra uses a CLI Parity Matrix. This system is implemented in crates/palyra-cli/src/cli_parity.rs and validated via tests in crates/palyra-cli/tests/help_snapshots.rs.

Parity Mechanism

  1. Matrix Definition: A TOML file (tests/cli_parity_matrix.toml) defines all expected commands, their flags, and their parity status (done, partial, etc.) crates/palyra-cli/tests/cli_parity_report.md#1-24.
  2. Snapshot Testing: The test suite executes --help for every command in the matrix and compares the output against committed snapshots in tests/help_snapshots/ crates/palyra-cli/tests/help_snapshots.rs#75-126.
  3. Normalization: To handle platform differences (e.g., .exe extensions on Windows), the system normalizes help text before comparison crates/palyra-cli/tests/help_snapshots.rs#22-24.

Parity Status Summary

StatusMeaning
verifiedThe command exists and matches the committed help snapshot.
doneFull feature parity is expected and implemented.
partialSome flags or subcommands are pending implementation.
Sources: crates/palyra-cli/tests/cli_parity_report.md#1-24, crates/palyra-cli/tests/help_snapshots.rs#1-126, crates/palyra-cli/src/cli_parity.rs#1-50