---
name: waffo-pancake-cli
description: Discover and use the Waffo Pancake CLI for merchant API operations, read-only GraphQL, test webhook configuration, offline previews and local diagnostics.
---

# Waffo Pancake CLI

Release candidate: `0.0.1-rc.2`, using the `next` channel. Install with `npm install -g @waffo/pancake-cli@next`, or use `npx @waffo/pancake-cli@0.0.1-rc.2`. In a source checkout, use `pnpm cli` after `pnpm install --frozen-lockfile && pnpm run build`. Runtime and development require Node.js >=22.14; Node.js 24 LTS is recommended for development. Use the pinned pnpm 11.25.0.

For UAT, pass team-provided `--dashboard-url <origin>` and `--api-url <origin>` to login; default URLs target production. Check `whoami` and select `env test` before UAT business operations. Package installation does not deploy compatible hosted services or prove production readiness.

## Discover before acting

```sh
pnpm cli commands --json
pnpm cli schema webhook.add --json
pnpm cli webhook add --help
```

Local examples use `pnpm cli`; the installed executable is named `pancake`. The official TypeScript compiler emits a complete ESM module tree in `dist/`; `pnpm cli` runs `node dist/index.js`. Commander handles commands, arguments and help. `pnpm dev` watches and recompiles; run commands in a second terminal after compilation succeeds. After renaming or deleting source files, restart `pnpm dev` or run `pnpm run build` to remove old output. `pnpm run pack:release` starts with a clean build. Do not invent commands from the roadmap. Temporary local webhook listening is implemented for browser sessions; simulated event sending and MCP are not implemented. `products create` supports offline preview and real onetime/subscription creation with `--yes`.

## Authentication

Use an existing Merchant ID and RSA private-key file; never put private-key contents in arguments or diagnostic output.

```sh
pnpm cli login --merchant-id MER_abc --private-key-file /absolute/path/key.pem --no-interactive --json
pnpm cli whoami --json
pnpm cli stores list --limit 20 --json
pnpm cli logout --json
```

`login` validates the local RSA key and verifies the remote merchant identity before saving one current credential. RSA login stores only the absolute key path. Default interactive login opens the browser and shows a matching code. Confirm the account and code, then click Authorize CLI only for a login you started yourself. The request expires after 15 minutes. The CLI verifies identity and environment before saving a separate merchant session in private configuration. Browser completion appears only after saving; `LOGIN_CONFIRMATION_FAILED` means final confirmation failed after saving: that credential may expire within five minutes, so run login again. `env test|prod` verifies the chosen environment before saving; RSA keys do not support environment switching. Noninteractive browser login is rejected; use the explicit RSA flags above. Never expose session tokens in output or diagnostics. Verified credentials automatically replace the saved login; verification and pre-commit failures preserve the old credential. A cleanup failure explicitly reports that the configuration update already completed. Interactive `login --key-login` accepts a key or file path in a hidden input and detects the format. Pasted keys are saved in an owner-only file; never put raw keys in shell arguments. Merchant/key flags are login-only. `--store-id` sets the saved default on login or overrides the target for an operation.

Alternatively inject `WAFFO_MERCHANT_ID` with exactly one of `WAFFO_PRIVATE_KEY_FILE` or `WAFFO_PRIVATE_KEY` through the agent's secret environment. Never echo these values. A complete environment pair overrides the saved credential without inheriting its store; incomplete or malformed pairs fail. Login reports `savedLoginActive:false` and a warning when environment credentials are present. Browser logout revokes its saved server session before clearing local credentials; unconfirmed revocation retains the credential. RSA logout clears saved credentials and removes marked CLI-managed pasted-key copies, preserves supplied key files and operation records, and warns that environment credentials remain. Unset all three variables to use the saved login or finish logging out.

`whoami` verifies the effective merchant and reports `authenticated:true` plus the source (`stored` or `environment`). Without any credentials, it succeeds locally with `authenticated:false`. Login results identify the verified login input using `source:login`; an environment warning means this saved credential is not effective for subsequent commands.

The CLI verifies environment from the authenticated gateway response header `X-Waffo-Environment: test|prod`. RSA keys have a server-assigned environment; browser sessions send the selected `X-Environment`, which still requires response-header verification. Report `credentialVerified` separately from `actualEnvironment` and `environmentVerified`. Missing or invalid headers mean `actualEnvironment:null`, `environmentVerified:false`, and `doctor` reports `ENVIRONMENT_UNVERIFIED`; never infer environment from merchant identity, an empty result or a local selection. Product creation requires `--yes` and may affect production. Webhook writes remain test-resource-only.

Configuration is version 2. Legacy version 1 must be cleared with explicit `logout` and replaced using `login`; there is no migration or account-switching mechanism. Logout can reset safely readable corrupt configuration, but refuses symlinks, nonregular state files and unknown future versions.

## Read and preview

```sh
pnpm cli products get PROD_abc --type onetime --json
pnpm cli webhook list --store-id STO_abc --json
pnpm cli products create --type onetime --file product.json --dry-run --json
pnpm cli webhook add --file webhook.json --dry-run --json
```

Read the command schema to construct JSON files. `--file -` reads one JSON object from stdin, limited to 1 MiB and five seconds. Decimal amounts must be strings. Do not specify the same field in both the file and arguments. Dry-run performs local validation only: no credentials, network or operation records; it does not prove remote acceptance.

## Expanded merchant coverage

There are 62 registered commands and 33 supported merchant API-Key REST action routes. Run discovery for exact flags and schemas; do not invent `orders get`, `subscriptions get`, or group read commands. Resource lists cover products, versions, orders, subscriptions, payments, refunds, refund tickets, notification recipients and merchants. Product/order variants require `--type onetime|subscription` where documented. Read one page at a time; a full page means `hasMore:"unknown"`.

New actions manage stores, product updates/publication/status, subscription groups, checkout, merchant subscription cancellation, refund tickets, customer session tokens, notification recipients and content scans. Use `--file input.json`, `--dry-run`, explicit `--yes`, and preferably an explicit `--idempotency-key`. Without a key the CLI generates one and returns it. These actions use ID fields inside the input file, not invented positional arguments. Read each schema before constructing input.

Production writes require `--yes --confirm-production`. `products publish` and `groups publish` also require both flags even when logged into Test, because they target PRODUCTION. Store create/update/delete and recipient add/update/remove affect shared Test/Production resources: require `--yes --confirm-shared`, plus `--confirm-production` when authenticated in Production. Do not silently add these flags; obtain the user's explicit approval for the stated impact. Offline previews declare policy, not verified environment; `impact:null` with `requiresProductionConfirmation:"when-prod"` requires identity verification before execution. Execution and operation records report the resolved `impact`. These local confirmations do not grant server permissions or trigger browser reauthorization.

`products publish` and `groups publish` target PRODUCTION from test data. New actions report `response_only`; group delete/publish reports `acknowledgement_only`. Do not describe these as read-back verification. A completed refund-ticket request is not completed repayment. Content scan is stateless but requires confirmation, durable intent and one POST attempt.

`checkout create` and `sessions create` require a new private `--output` file for real execution. The file contains sensitive links/tokens; stdout only acknowledges export. Session issuance requires RSA credentials; browser sessions are rejected before the action request. It is not CLI login. Files cannot overwrite existing files; POSIX mode is 0600 and Windows uses owner-only ACLs. A post-acceptance export or journal failure is `committed_unverified`; do not replay to recover the response.

`graphql query` and `analytics query` accept a JSON file containing `query` and optional `variables`. A real parser rejects mutations, subscriptions and multiple operations before credentials/network, including dry-run. Real execution requires private `--output` because arbitrary aliases/fragments can contain secrets. There is no raw REST passthrough. Group query fields must be confirmed using official documentation/introspection before use; do not invent a group root field. Customer-token-only onetime cancellation, customer subscription cancellation and reactivation are excluded from merchant scope.

## Remote changes

`products create --type onetime|subscription --file product.json --yes --idempotency-key KEY` creates a real product using the effective credential environment. Review the merchant, store, name and prices before confirming. The CLI requires verified environment evidence before writing and requires explicit production confirmation for Production. Subscription input requires `billingPeriod`; trial prices require positive `metadata.trialDays`. For product creation or updates, do not supply `taxIncluded`: the backend fixes tax-exclusive pricing and this CLI rejects that option. Results contain safe product fields; descriptions, metadata and URLs are omitted.

`webhook add/update/remove` also perform remote changes. Add requires `testMode:true`. Update/remove require an accessible existing test webhook in the selected store. Channel and test mode cannot be updated. Listing shows Webhook addresses and omits secrets. Configuring a webhook does not verify event delivery.

Use a reviewed input and `--yes`; this confirms intent without bypassing checks. Preserve the operation ID and idempotency key. A write is attempted once, with a persisted local intent before sending. Reusing a locally recorded key is blocked; this is not a distributed or permanent deduplication guarantee. Before the business request, the intent includes merchant, input fingerprint, impact, exact endpoint and API origin, plus known target/store IDs and the selected environment for browser credentials. RSA credentials do not have a local environment selection.

## Results and recovery

`--json` and non-TTY output produce one JSON object on stdout (except `listen`, which streams NDJSON): `schemaVersion`, `ok`, `data`, `error`, `meta`. Logs go to stderr. Non-interactive calls never prompt. Exit codes: 0 success; 1 execution/verification failure; 2 invalid input/configuration; 130 interruption. Always check `ok` and `meta.outcome`. Authenticated success and error metadata includes `merchantId`, `source`, `actualEnvironment` (`test`, `prod` or `null`) and `environmentVerified`; human output also shows this context and available operation/request IDs. A selected environment alone is not verified evidence. Confirmed write rejections preserve their original exit code; unknown write outcomes always use `OUTCOME_UNKNOWN` and exit 1. `CONFIG_CHANGED` means a concurrent login, environment selection or logout found replaced/cleared configuration and preserved the newer state; inspect `whoami` before making another change.

Checkout `targetResourceId` identifies the product; its `resourceId` identifies the returned session. Promotion-code batch results use `batchId`; session tokens and content-check request IDs are never resource IDs. Accepted-write recovery errors retain a known result ID even when private export or record completion fails. If record updates remain unavailable, inspect the retained initial intent and merchant dashboard.

- `completed`: the command finished; a dry-run still has `data.executed:false`.
- `rejected`: the requested operation was not completed; inspect the error.
- `unknown`: the write may have succeeded. Query and inspect records before taking action; do not retry with a new key.
- `committed_unverified`: the API accepted the change but readback, private export or local-record completion failed. For products run `products get RESOURCE_ID --type onetime|subscription --json` with the same credentials, then inspect the operation; do not repeat the write. If no resource ID is known, inspect the merchant dashboard for the recorded store.

```sh
pnpm cli operations list --json
pnpm cli operations show OPERATION_ID --json
pnpm cli diagnostics export --operation OPERATION_ID --output ./diagnostics.json --json
pnpm cli doctor --debug --json
```

Diagnostics are local, redacted and never automatically uploaded. Ask before sharing them with another party. No request ID from the server means `requestId:null`; local operation IDs are not server audit IDs. Records are capped at 1000; resolved records older than 30 days are pruned on the next operation. Unresolved records are retained.

For repeatable automation use a fixed published version, such as `npx @waffo/pancake-cli@VERSION ...`. Update via the original package manager outside active tasks; do not mutate the running CLI or overwrite unknown config/record versions.

## Discounts

Use `coupons list|get|create|update|deactivate` and `promotion-codes list|create|generate|deactivate`. Coupon lists require storeId; promotion-code lists require couponId in a JSON file. Coupon update changes only name; deactivation is permanent. Generate accepts 1–500 codes. Schema and dry-run validate offline. Discount previews show amounts/percentages, duration, product scope, limits, couponId and batch count/length; customerEmails stay redacted in nested promotion codes too. Execute writes with --yes and an explicit idempotency key. Browser sessions and RSA keys are accepted by gateway source with server-enforced store permissions. Results expose codes and IDs, omit customer restrictions from write summaries, and omit customerEmails from named reads. Use private --output on writes or an explicit arbitrary GraphQL query to export sensitive details. All nine discount commands have isolated Test-environment acceptance evidence, including deactivation read-back; selected Production discount operations also passed, while full stable-release acceptance remains pending.

## Temporary local listener

Use `pancake listen --store-id STO_example --forward-to http://localhost:3000/webhook [--events event.name] [--live] [--json]` for actual merchant events. Browser session only; Test default even when saved mode is Production; only explicit `--live` enables Production. `listen` is a streaming exception to one-result output: standard NDJSON envelopes with data.type ready/delivery/stopped, plus terminal failure when needed. Never expect event bodies or signatures in output. Forwarding is loopback-only, redirects fail, only 2xx is success. Stable eventId identifies duplicates/retries. SIGINT/SIGTERM stop the session; abrupt termination uses the 90-second TTL. No permanent endpoint mutation or synthetic trigger.

## Service and verification boundaries

Private service source is not required to use or develop the open-source client. Remote commands require credentials and a reachable compatible hosted API; browser authorization also needs a compatible Dashboard. Browser login, environment headers and listener relay support must be deployed separately from the CLI. The published candidate passed npm/npx installation, production browser login and logout revocation, selected business operations in Test and Production, and Test sandbox-payment forwarding. Production listener startup, polling, isolation and cleanup passed; real Production payment delivery and actual Windows console Ctrl+C remain pending. These checks do not establish acceptance of every command.

Browser login grants supported business operations in Test and Production within existing merchant/store permissions. Server policy denies account, API Key, payout/bank, other-device, further authorization and API credential, Webhook `secret` and identity-document access. No `--scope` option is needed. Use `logout` only for the current CLI session. RSA permissions are unchanged. Webhook addresses remain readable. Browser secret writes use server acknowledgement (`verification: response_only`); do not claim the secret was read back.
