Skip to main content

CLI

Use this page to look up commands, options, exit codes, and environment variables for afe.

The afe command runs flows, serves the engine, and inspects tickets. It talks to a server over the API unless a command says --local.

afe --help
afe <command> --help

afe validate​

Check every manifest in a folder and print all the issues.

afe validate config/ # the folder positionally
afe validate -c config/ # or with the flag
OptionDefaultMeaning
[folder]—The configuration folder, positionally (the same as --config).
--config, -c.The configuration folder.

Exit code 1 when there is any error, 0 otherwise.

afe serve​

Serve the engine API on a configuration folder. The token comes from AFE_API_TOKEN.

OptionDefaultMeaning
--config, -c.The configuration folder.
--host127.0.0.1Interface to listen on.
--port8765Port to listen on.
--ops-host127.0.0.1Interface for /livez, /readyz and /metrics.
--ops-portoffPort for /livez, /readyz and /metrics; off when absent.
--session-hours8Hours a browser session lasts.
--uioffServe the web UI too.

afe worker​

Run queued tickets until SIGINT or SIGTERM.

OptionDefaultMeaning
--config, -c.The configuration folder.
--concurrency1Tickets to run at once.
--dryoffRun agents on the dry harness.
--ops-host127.0.0.1Interface for /livez, /readyz and /metrics.
--ops-portoffPort for /livez, /readyz and /metrics; off when absent.

afe run​

Start a ticket and follow it; answer its questions when there is a terminal.

OptionDefaultMeaning
<flow>—The flow to run (positional).
--input, -i—The ticket input (YAML). Required.
--config, -c.The configuration folder, with --local.
--urlws://127.0.0.1:8765/rpcThe engine API URL.
--localoffRun the engine in process.
--dryoffWith --local: agents on the dry harness.
--project—The project the flow works on.
--revisioncurrentRun on this configuration revision, not the current one.

afe resume​

Answer a paused ticket (or restart it) and follow it.

OptionDefaultMeaning
<ticket>—The ticket to resume (positional).
[action]—The answer, one of the offered actions (positional).
--comment—A comment with the answer.
--urlws://127.0.0.1:8765/rpcThe engine API URL.

afe rerun​

Start a ticket again on the same configuration revision, and follow it.

OptionDefaultMeaning
<ticket>—The ticket to run again (positional).
--urlws://127.0.0.1:8765/rpcThe engine API URL.

afe cancel​

Cancel a ticket; its artifacts are kept.

OptionDefaultMeaning
<ticket>—The ticket to cancel (positional).
--urlws://127.0.0.1:8765/rpcThe engine API URL.

afe clean​

Remove a finished ticket's worktrees, branches, sandbox and bundles. A ticket that is not finished is refused. Running the command again finds nothing to remove.

It removes:

  • The ticket's folder under worktrees and its worktree registrations.
  • The afe/<ticket key>/* branches in the clone the engine made for the project.
  • The ticket's sandbox and its stored bundles.

It keeps every branch when the repository is not a clone the engine made. That covers the project's own source, a local path and a repository whose .git is linked elsewhere. Only the ticket's worktree folder goes, and the command adds a line, branches kept: <repository>.

A clone made before V9f has no .git/afe-clone marker, so the engine does not delete its branches. Delete them by hand.

OptionDefaultMeaning
<ticket>—The finished ticket to clean (positional).
--urlws://127.0.0.1:8765/rpcThe engine API URL.

afe inspect​

Show a ticket: state, totals, the question it waits on, artifacts.

OptionDefaultMeaning
<ticket>—The ticket to show (positional).
--urlws://127.0.0.1:8765/rpcThe engine API URL.

afe tickets​

List tickets, the most recent first, reading every page of ticket.list until the last.

OptionDefaultMeaning
--stateallOnly tickets in this state.
--urlws://127.0.0.1:8765/rpcThe engine API URL.

afe workers​

List live workers and queue metrics.

OptionDefaultMeaning
--urlws://127.0.0.1:8765/rpcThe engine API URL.

afe login​

Sign in with the OpenID Connect device flow and keep the token for later commands. The command prints the address and the code the provider asks for, waits while you approve them, then stores the token for that server. No client secret is needed.

The token goes to ~/.config/afe/token, or to $XDG_CONFIG_HOME/afe/token when that variable is set. The file holds one entry per server and is created with mode 0600. The CLI refuses to read a file other accounts can read, and says to run chmod 600 on it. It renews an expired access token with the refresh token, so you sign in again only when the provider ends the session.

OptionDefaultMeaning
--urlws://127.0.0.1:8765/rpcThe engine API URL.

It exits 1 with one line when the provider denies the request, when the code expires, or when the server has single sign-on turned off.

afe logout​

Forget the token saved for one server. It prints signed out from <url>, or no saved token for <url> when there was none.

OptionDefaultMeaning
--urlws://127.0.0.1:8765/rpcThe engine API URL.

afe audit​

Read the audit trail, newest first, with filters. jsonl and csv write one record per line as each page arrives, so a long export streams.

OptionDefaultMeaning
--since—Only entries at or after this instant.
--until—Only entries before this instant.
--actor—Only entries by this caller id.
--action—Only entries with this action.
--object—Only entries on this object id.
--project—Only entries about this project.
--outcome—accepted or refused.
--formattabletable, jsonl or csv.
--urlws://127.0.0.1:8765/rpcThe engine API URL.

afe service-account​

Create, list and revoke the engine's service accounts. The token of a new account is printed once.

OptionDefaultMeaning
create <name>—Create an account, with --expires for the day it stops working.
list—List the accounts, revoked ones included.
revoke <name>—Revoke one account by name.
--urlws://127.0.0.1:8765/rpcThe engine API URL.

Exit codes​

CodeMeaning
0The ticket is done.
2The ticket waits for a person.
1Anything else: a failure, a bad configuration, an API error.

Environment​

VariableRead byMeaning
AFE_API_TOKENthe remote commandsThe bearer token. It wins over a token saved by afe login.
XDG_CONFIG_HOMEafe login, afe logout and the remote commandsThe folder that holds afe/token. Defaults to ~/.config.
AFE_POSTGRES_DSN, AFE_REDIS_URLserve, workerThe connection strings named by a Runtime (see Runtime).

A remote command with no AFE_API_TOKEN and no saved token prints one line, error: set AFE_API_TOKEN to talk to a server, and exits 1 instead of a traceback.

When the saved session cannot be renewed, a command prints session expired: sign in again with afe login and exits 1. The same line appears when a watching command loses its connection because the session ended.

See also​

  • API for the protocol used by remote commands.
  • Manifests for configuration fields.
  • Web UI for the browser interface.