A small example CLI that runs a Cursor SDK agent against a workspace. One-shot prompts use the local runtime by default, while the interactive TUI can switch between local and cloud execution.
Use Bun 1.3 or newer. This CLI is Bun-only because OpenTUI's native renderer
is exposed through bun:ffi.
Install dependencies:
pnpm installSet an API key:
export CURSOR_API_KEY="crsr_..."Ask for a one-shot task in the current directory:
bun run dev -- "Explain how this project is structured"Start the TUI by omitting the prompt:
bun run devInside the TUI, type / to open the command menu. You can switch between local and cloud execution, choose a model, reset the session, or exit from there.