npm package: @palliora.org/cli
Description: CLI for interacting with Palliora network
Author: palliora-org
Latest version: 1.0.1

# Palliora CLI

## 1 - Overview

Palliora CLI (`palliora-cli`) is a command-line tool for interacting with the Palliora ecosystem: uploading models and datasets, managing accounts and keys, and interacting with on-chain storage and staking features. The codebase is implemented in TypeScript and compiled to a single executable script in `dist/palliora-cli.js`.

Primary capabilities (examples):
- Create/import/show account keys and info (see `src/account/*`).
- Join the network as a guardian or validator (see `src/join/*`).
- Manage staking operations (add, reduce, remove, withdraw) under `src/stake/*`.
- On-chain interactions and Palliora-specific utilities under `src/palliora/*` and `src/paliCrypto/*`.

## 2 - User guide

Prerequisites
- Node.js 18+ and `pnpm` (recommended) or npm.

Install and build

1. Clone the repo and install dependencies:

   pnpm install

2. Build the project (this bundles the TypeScript into `dist/`):

   pnpm run build

Running the CLI

- Run the built CLI directly:

  pnpm start

- Or use the packaged command (after build) if you [linked](#build-and-link) or installed the package globally:

  palliora-cli <command> [options]

Common commands (high level)
- Account management: create/import/show/info - manage keys and account metadata (see `src/account`).
- Join network: guardian/validator - join as a guardian or validator and submit relevant transactions (`src/join`).
- Stake operations: add/new/reduce/remove/withdraw - staking flows and helpers (`src/stake`).

See [Commands List](command.md)

Examples

- Create an account (example):

  pnpm start account-create

- Show account info:

  pnpm start account-show

Note: the exact CLI arguments and subcommands mirror the files under `src/` (for example, `src/account/create.ts` corresponds to the `account create` command). Use `pnpm start --help` or `palliora-cli --help` after build to list available commands and flags.

Environment
- Copy `.env.example` to `.env` and populate any RPC endpoints, mnemonics or keys required by your environment. The project uses `dotenv` to load env vars.

## 3 - Developer doc

Project layout (important files/folders)
- `src/palliora-cli.ts` - CLI entry point. This is compiled to `dist/palliora-cli.js` and published as the CLI binary (see `package.json` `bin` field).
- `src/account/` - account key management (create/import/info/show).
- `src/join/` - join flows (guardian, validator, idle, validator checks).
- `src/stake/` - staking commands and transaction builders.
- `src/palliora/` - on-chain helpers, chain spec, onchain FS, websocket provider helpers.
- `src/paliCrypto/` - cryptographic helpers and cipher/index implementations.
- `src/utils/` - small utilities such as CSV parsing and shared helpers.

Build

- Build for local development:

  pnpm run build

Run in development (type-checked/fast iteration)

- For faster iteration you can run directly (if you prefer):

  pnpm dev <command>

Code contributions
- Follow the existing code style (TypeScript ESM modules). Keep public helpers in `src/utils` and reuse the `paliCrypto` helpers for any new crypto code.

Where to look for behavior
- CLI wiring and argument parsing are in `src/palliora-cli.ts` and the command files under `src/` subfolders. Adding a new command typically involves creating a new file and registering it in the CLI entry.

Development tips
- Add new command files under `src/<feature>/` and update the CLI entry if needed.
- Keep environment-specific values in `.env`.

## Development

### Local Development
```sh
# Run in development mode
pnpm dev

# Or run directly
node dist/palliora-cli.js --help
```

### Build and link
```sh
pnpm build && npm link
```

## Troubleshooting

### Command Not Found
```sh
# Clear shell command cache
hash -r
```

### Permission Errors
```sh
# Make sure the file is executable
chmod +x dist/palliora-cli.js
```