# @rome-os/pantheon-cli

Command-line client for the [Pantheon](https://r.amantru.com) Rome app store. Use it to log in, package a Rome app directory, publish it as a new version, or download an existing app bundle.

## Install

```bash
npm install -g @rome-os/pantheon-cli
# or run ad-hoc
npx @rome-os/pantheon-cli --help
```

The CLI is published as an ES module and requires **Node.js 22+**.

## Usage

```text
pantheon login      Log in to a pantheon instance and store credentials.
pantheon whoami     Show the currently logged-in account.
pantheon publish    Package a Rome app directory and upload it.
pantheon download   Fetch an app bundle.
```

Run `pantheon <command> --help` for command-specific options.

### Authenticate

There are two ways to give the CLI credentials, in order of preference:

1. **`ROME_TOKEN` env var (recommended for CI and long-lived workflows).** Generate a token in the Pantheon dashboard under **Settings → CLI / API token**, copy it once, and export it:

   ```bash
   export ROME_TOKEN=rome_…
   # optionally pin a host (otherwise PANTHEON_HOST or the default is used)
   export PANTHEON_HOST=https://r.amantru.com
   pantheon publish ./my-app
   ```

   The token never expires, can be reset at any time from the dashboard, and is **store-API-only** — it cannot be used to log into the dashboard.

2. **`pantheon login` (interactive shells).** Mints a 24-hour session token via email + password and stores it in `~/.pantheon/pantheon-token.json` (mode `0600`):

   ```bash
   pantheon login
   # or non-interactively
   pantheon login --email you@example.com --password-stdin <<<"$PW"
   ```

If both are present, `ROME_TOKEN` wins. Override the host with `--host <url>` or the `PANTHEON_HOST` env var (default: `https://r.amantru.com`).

### Publish an app

The target directory must contain an `app.yaml` with `id` and `version`:

```bash
pantheon publish ./my-app
pantheon publish ./my-app --dry-run --out my-app.romeapp
pantheon publish ./my-app --exclude dist --exclude .env
```

The CLI builds a deterministic gzipped tarball (no mtimes), prints its `sha256`, and uploads it to `/api/store/publish`. With `--dry-run` it stops after computing the hash.

`node_modules`, `.git`, and `.DS_Store` are excluded by default. Add more with `--exclude <name>` (repeatable); each pattern matches any path segment by exact name, so `--exclude dist` skips a top-level `dist/` and any nested `dist/` too. Pass `--no-default-exclude` to opt out of the built-in defaults.

### Download an app

```bash
# latest live version
pantheon download @your-handle/my-app
# pinned version
pantheon download @your-handle/my-app@1.2.3 --out my-app.romeapp
# unscoped (first-party) listings
pantheon download my-app
```

The downloaded bundle's `sha256` is verified against the listing's `contentHash` before it's written to disk.

## Configuration

| Source                            | Field            | Notes                                                                       |
| --------------------------------- | ---------------- | --------------------------------------------------------------------------- |
| `ROME_TOKEN` env var              | bearer token     | Long-lived API token minted in the dashboard. Wins over the JSON config.    |
| `--host <url>`                    | host             | Per-invocation override.                                                    |
| `PANTHEON_HOST` env var           | host             | Used when no flag is passed and no config is stored.                        |
| `~/.pantheon/pantheon-token.json` | host, email, token | Written by `pantheon login`. File is mode `0600`.                         |

## License

MIT
