Skip to main content
The palyra CLI is built on a strictly typed, hierarchical command tree designed for discoverability and cross-platform consistency. It serves as the primary operator interface for both local and remote daemon management, implementing a robust “Parity Matrix” system to ensure that the CLI surface remains synchronized across Unix and Windows environments.

Command Tree Architecture

The CLI utilizes clap for its command-line argument parsing and sub-command routing crates/palyra-cli/src/lib.rs#77-91. The architecture is divided into “Canonical Command Families” (preferred entry points) and “Top-Level Commands” (legacy or specialized utilities).

Core Data Flow

The CLI execution flow follows a standard pattern:
  1. Parsing: Cli::parse() generates the Cli struct crates/palyra-cli/src/cli.rs#1-100.
  2. Profile Resolution: Global options like --profile and --config are evaluated to establish the connection context crates/palyra-cli/src/args/mod.rs#63-89.
  3. Dispatch: The Command enum routes the request to specific module handlers crates/palyra-cli/src/commands/mod.rs#1-53.

Command Family Organization

The system categorizes commands to provide a clean operator surface while maintaining backward compatibility:
CategoryDescriptionExamples
CanonicalPreferred, high-level workflows.setup, acp, gateway, onboarding
Top-LevelSpecific subsystem utilities.doctor, health, logs, memory
NestedSpecialized sub-surfaces.auth profiles, mcp serve, memory learning
Sources: crates/palyra-cli/src/args/mod.rs#138-157, crates/palyra-cli/tests/help_snapshots/root-help-unix.txt#5-56

Profile Guardrails & Strict Mode

The CLI implements safety mechanisms to prevent accidental destructive actions against production environments.

Profile Attributes

Profiles (defined via palyra profile) contain metadata that the CLI uses to enforce safety:

Global Guardrail Flags

Sources: crates/palyra-cli/src/args/mod.rs#101, crates/palyra-cli/src/args/tests.rs#35-92

Parity Testing & Snapshot System

To ensure the CLI provides a consistent experience across all supported platforms, Palyra employs a “Parity Matrix” system. This system validates the CLI surface against a canonical specification.

The Parity Matrix (cli_parity_matrix.toml)

The matrix defines every valid command path, its expected status (done, partial), required aliases, and required flags crates/palyra-cli/tests/cli_parity_matrix.toml#1-31.

Snapshot Validation Logic

The testing suite performs the following steps:
  1. Load Matrix: Reads the TOML specification crates/palyra-cli/tests/help_snapshots.rs#14-20.
  2. Execute Help: Runs palyra <path> --help for every entry crates/palyra-cli/tests/help_snapshots.rs#26-53.
  3. Normalize: Strips platform-specific line endings (\r\n to \n) and binary extensions (palyra.exe to palyra) crates/palyra-cli/tests/help_snapshots.rs#22-24.
  4. Compare: Validates the output against stored snapshots in tests/help_snapshots/ crates/palyra-cli/tests/help_snapshots.rs#100-118.

Parity Acceptance Matrix Diagram

This diagram illustrates how the CliParityMatrix mediates between the code (Clap tree) and the documentation (Snapshots). CLI Parity Verification Flow Sources: crates/palyra-cli/tests/help_snapshots.rs#76-126, crates/palyra-cli/tests/cli_parity_matrix.toml#1-36

Implementation Details

Command Dispatch System

The palyra-cli crate uses a central dispatching logic in lib.rs that maps parsed CliCommand variants to their respective implementation modules. Command Routing Diagram Sources: crates/palyra-cli/src/lib.rs#78-90, crates/palyra-cli/src/commands/mod.rs#1-53, crates/palyra-cli/src/args/mod.rs#1-47

Summary Matrix Example

The system generates a cli_parity_report.md during CI to track progress and regressions across the 100+ command entries crates/palyra-cli/tests/cli_parity_report.md#1-24.
FeatureVerification Method
Command ExistenceClap CommandFactory validation against Matrix crates/palyra-cli/tests/help_snapshots.rs#76-84
Flag Parityrequired_flags check in cli_parity_matrix.toml crates/palyra-cli/tests/cli_parity_matrix.toml#8
Cross-PlatformSeparate Unix/Windows snapshots for root help crates/palyra-cli/tests/cli_parity_matrix.toml#12-13
Install Smokeinstalled_smoke.rs runs binary against temp workdirs crates/palyra-cli/tests/installed_smoke.rs#39-148
Sources: crates/palyra-cli/tests/cli_parity_report.md#26-85, crates/palyra-cli/tests/installed_smoke.rs#1-148