
# CLI

`acahti` is a thin client for `<instance>/acahti/v1`, the same catalog MCP uses. IDE agents keep MCP; shell agents, pipeline jobs, and people at a terminal use the CLI.

## Install

```bash
npm install -g @benchyard/acahti
```

The package carries binaries for macOS and Linux on amd64 and arm64. `acahti version` prints the release. The CLI talks to any instance through the `/acahti/v1` API and is released on its own schedule.

## Configure

Two values: the instance and an access token.

```bash
export ACAHTI_ROOT_URL=https://acahti.example.com
export ACAHTI_TOKEN=…
acahti whoami
```

A person creates the token from the avatar menu → Access tokens; it is shown once, and deleting it revokes it. Pipeline jobs already have both variables. The CLI sends the token as `Authorization: Bearer`, never the account password.

To store them instead of exporting:

```bash
acahti auth login --hostname https://acahti.example.com --with-token < token.txt
```

This checks the token with `GET /me` and saves both to `~/.config/acahti/credentials.json` (mode `0600`). A person at a keyboard can run `acahti auth login https://acahti.example.com` for the browser flow. `acahti auth status` shows the host and login; `acahti auth logout` deletes the file.

Environment variables win over stored credentials. Without `ACAHTI_ROOT_URL` or a stored host, the CLI uses the HTTPS URL of the git remote named `acahti`.

## Commands

| Command | REST |
|---|---|
| `acahti whoami` | `GET /me` |
| `acahti pr list OWNER/REPO [--state open]` | `GET /repos/OWNER/REPO/pulls` |
| `acahti pr view OWNER/REPO N` | `GET …/pulls/N` |
| `acahti pr create OWNER/REPO --title T --head BRANCH [--base B] [--body B]` | `POST …/pulls` |
| `acahti pr merge OWNER/REPO N` | `POST …/pulls/N/merge` |
| `acahti pr close OWNER/REPO N` | `DELETE …/pulls/N` |
| `acahti checks OWNER/REPO SHA` | `GET …/checks/SHA` |
| `acahti pipeline list OWNER/REPO [--sha S] [--branch B] [--status S]` | `GET …/pipelines` |
| `acahti pipeline view OWNER/REPO N` | `GET …/pipelines/N` |
| `acahti pipeline log OWNER/REPO N [--step N] [--tail N]` | `GET …/pipelines/N/log` |
| `acahti pipeline rerun OWNER/REPO N` | `POST …/pipelines/N/rerun` |
| `acahti inbox [--section pipes\|prs]` | `GET /inbox` |
| `acahti api METHOD /path [-q k=v] [-f k=v] [-d json]` | any path under `/acahti/v1` |

`acahti api` reaches every [MCP tool](/docs/mcp/) with the same arguments.

## After a push

```bash
sha=$(git rev-parse HEAD)
acahti checks acme/demo "$sha"
acahti pipeline list acme/demo --sha "$sha"
acahti pipeline log acme/demo 12
acahti pr merge acme/demo 3
```

`pr merge` requires the newest pipeline on the head SHA to be green, exactly as the MCP tool does.

## Git

Git stays HTTPS. Username is the Acahti login; password is the account password or an access token. An SSH key is not a credential for Git, MCP, or the CLI.
