@agent-api/cli
v0.4.3
Published
First-class command line interface for Agent API
Readme
Agent API CLI
First-class command line interface for Agent API. The CLI shell is built on @agent-api/app-engine, which wraps @agent-api/sdk@^1.3.0 behind a renderer-neutral application core. Commander handles command routing, and Ink renders the current terminal UI.
This repository publishes two packages:
@agent-api/app-engine: reusable application core for agent apps.@agent-api/cli: command-line shell and Ink TUI renderer.
Development
cd cli
npm install
npm run build
node dist/index.js --helpCreate local development commands:
npm run dev:link
agent-tuiLocal Release
The TUI is distributed as a normal npm CLI package. The app does not self-update; startup may show a lightweight update notice, and users update with npm:
npm install -g @agent-api/cli@latestPrepare, verify, and publish a local release:
cd cli
npm run release:localIf your npm account requires two-factor auth for publish:
npm run release:local -- --otp 123456The local release script runs npm ci, builds and tests both packages, creates
npm tarballs in artifacts/, installs the app-engine and CLI tarballs into a
temporary npm prefix, smoke-tests the published bin aliases, and then publishes
@agent-api/app-engine before @agent-api/cli with
npm publish --access public.
For a no-publish rehearsal:
npm run release:local -- --dry-runSet AGENT_TUI_UPDATE_CHECK=0 to disable the startup update notice.
Command Shape
agent-tui
agent-api
agent-api auth login
agent-api profiles list
agent-api agent chat
agent-api workdir status
agent-api doctorInteractive Workbench
Launch the first-class TUI from your current directory:
agent-tuiOpen a specific local workdir and expose local tools to the agent:
agent-tui .
agent-tui ./my-workdir
agent-tui /absolute/path/to/my-workdirThe workdir argument must point to an existing directory. When provided, the workbench automatically turns on local workdir and shell tools in approval mode.
The workbench opens with auth as the first gate. If the active profile is valid, it enters the conversation UI automatically. If not, it shows an in-terminal auth picker for browser session or API key login.
Inside the workbench, configure the agent run dynamically:
/auth show current auth profile
/login return to auth gate without deleting profiles
/logout leave current session and return to auth gate
/switch-profile switch/sign in with a different profile
/delete-profile delete current saved profile and return to auth
/config show current run configuration
/preset <name> set preset; /preset none clears it
/model <name> set explicit model; /model auto clears it
/access full allow local workdir actions without approval
/access approval require approval for local workdir actions
/context toggle local workdir context/tools for each turn
/new [name] start a fresh conversation
/switch <name> switch conversation handleThe current working directory is loaded as the local workdir. Local workdir
tools are only exposed to the model when you enable local context with
/context or start with --workdir.
Authentication
The interactive workbench checks the active profile before it starts. If no valid profile exists, it opens an in-terminal auth picker with two choices:
- Browser session: best for desktop environments and refreshable long-running use.
- API key: best for shell-only servers, CI, and remote terminals.
You can also sign in explicitly from the shell. Browser login is the default for humans:
agent-api auth login --profile work --base-url https://api.agentsway.devAPI keys are supported for shell-only environments and automation:
agent-api auth login --profile ci --api-key sk-...
agent-api auth whoami --profile ci
agent-api auth logout --profile ciProfiles:
agent-api profiles list
agent-api profiles use work
agent-api profiles showAgent Conversations
Chat with the remote agent:
agent-api agent chat "Summarize the current release status" --preset pro-searchStart the interactive TUI with explicit options:
agent-api agent chat --conversation release --workdir .Named conversations continue automatically:
agent-api agent chat "Draft the implementation plan" --conversation release
agent-api agent chat "Now turn that into a checklist" --conversation release
agent-api agent list
agent-api agent show releaseAttach local workdir context:
agent-api agent chat "Review this project and suggest next steps" \
--workdir . \
--context-query auth \
--max-context-files 80The CLI sends local context as bounded, secret-aware project context. The remote Agent API remains the core execution path.
Workdir access defaults to approval mode:
agent-api agent chat --workdir . --access approvalUse full access only for trusted workdirs. In full access mode, valid edit proposals are previewed and applied automatically:
agent-api agent chat --workdir . --access fullLocal Workdir
The CLI uses the SDK local layer for workdir operations:
agent-api workdir status --path .
agent-api workdir summary --path .
agent-api workdir context --path . --query auth --max-files 40Inside the interactive workbench:
/auth show current auth profile
/login return to auth gate without deleting profiles
/logout leave current session and return to auth gate
/switch-profile switch/sign in with a different profile
/delete-profile delete current saved profile and return to auth
/config show current run configuration
/workdir show local workdir summary
/summary show local workdir previews
/search <query> search text in the local workdir
/preset <name> set or clear preset
/model <name> set or clear explicit model
/access <mode> approval or full
/context toggle local context packaging for each turn
/clear clear visible transcript
/quit quitLocal Edit Approval
The workbench can preview and apply local line edits through the SDK local workdir layer:
/edit {"description":"Rename heading","edits":[{"path":"README.md","startLine":1,"endLine":1,"replacement":"# New Heading"}]}
/preview
/apply
/rejectEdits are previewed before they are applied. Apply uses the SDK edit path with rollback on failure.
In --access full, valid proposals are applied immediately after preview generation.
When a workdir is attached, the CLI also tells the remote agent to return local changes as a fenced JSON block:
```agent_api_local_edits
{"description":"short reason","edits":[{"path":"README.md","startLine":1,"endLine":1,"replacement":"# New Heading"}]}
```Detected agent proposals go through the same approval/full-access flow as manual /edit proposals.
