Headless mode requires ByteRover CLI v1.6.0 or later.
Key Benefits
- No TTY required: Runs in environments without interactive terminals (containers, SSH sessions, CI runners)
- Structured output: Choose between human-readable text or machine-parseable JSON (NDJSON)
- Graceful error handling: Fails predictably when interactive prompts would be required
- Independent execution: Each command runs as an ephemeral process—no running REPL instance needed
Quick Start
Common Flags
All headless commands support these flags:| Flag | Description | Default |
|---|---|---|
--headless | Enable non-interactive mode (no TTY required) | false |
--format <text|json> | Output format: text for human-readable, json for NDJSON | text |
Supported Commands
Six commands support headless execution:| Command | Required Flags | Description |
|---|---|---|
brv init | --team, --space | Initialize project with team and space |
brv status | None | Show CLI and project status |
brv query | None | Query the context tree |
brv curate | None | Curate context to the context tree |
brv push | -y (skip confirmation) | Push context tree to cloud |
brv pull | None | Pull context tree from cloud |
brv init
Initialize a project in headless mode. Requires both--team and --space flags since interactive selection is unavailable.
brv status
Check CLI and project status without interaction.brv query
Query the context tree for project information.brv curate
Add context to the context tree.brv push
Push context tree changes to ByteRover cloud storage.brv pull
Pull context tree from ByteRover cloud storage.JSON Output Format
When using--format json, ByteRover outputs NDJSON (Newline-Delimited JSON)—one JSON object per line. This format is ideal for streaming and parsing with tools like jq.
Message Structure
Each line follows this structure:Message Types
| Type | Description | When Emitted |
|---|---|---|
action_start | Beginning of a long-running action | Operation begins |
action_stop | End of a long-running action | Operation completes |
log | Informational message | During execution |
warning | Non-fatal issue | Recoverable issue detected |
error | Fatal error | On failure |
result | Structured result data | On success |
Example Output Stream
Authentication for Automation
Headless mode uses API key authentication instead of browser-based OAuth.Generate an API Key
- Go to ByteRover Dashboard
- Click Create API Key
- Copy the key (starts with
brv_) - Store securely in your CI/CD secrets
Secure Storage Best Practices
- GitHub Actions: Repository secrets (
Settings > Secrets > Actions) - GitLab CI: CI/CD variables (
Settings > CI/CD > Variables, masked) - Jenkins: Credentials plugin with secret text
Environment Auto-Detection
ByteRover CLI automatically detects headless Linux environments and adjusts behavior accordingly.Detected Environments
The CLI recognizes these as headless environments:| Environment | Detection Method |
|---|---|
| SSH sessions | SSH_TTY or SSH_CONNECTION environment variables |
| Docker containers | /.dockerenv file exists |
| WSL (Windows Subsystem for Linux) | WSL_DISTRO_NAME, WSLENV, or /proc/version contains “microsoft” |
| No display server | DISPLAY and WAYLAND_DISPLAY unset |
| No D-Bus session | DBUS_SESSION_BUS_ADDRESS unset |
Token Storage Fallback
When the system keychain is unavailable (common in headless environments), ByteRover automatically uses file-based token storage:Error Handling
HeadlessPromptError
When a command requires interactive input that cannot be provided in headless mode, ByteRover throws aHeadlessPromptError:
| Property | Description |
|---|---|
code | Always HEADLESS_PROMPT_REQUIRED |
promptType | Type of prompt: confirm, select, input, search, file_selector |
promptMessage | The prompt that could not be answered |
availableChoices | For select prompts, the available options |
Common Error Scenarios
| Error | Cause | Solution |
|---|---|---|
Missing --team or --space | brv init --headless without required flags | Provide both --team and --space |
| Confirmation required | brv push --headless without -y | Add -y flag to skip confirmation |
| Not authenticated | No valid API key or token | Run brv login --api-key first |
| Project not initialized | No .brv/ directory | Run brv init --headless first |
Troubleshooting
Headless mode requires both --team and --space flags
Headless mode requires both --team and --space flags
Cause: Running You can use either names or IDs. IDs are more reliable in scripts as names may change.
brv init --headless without specifying team and space.Solution: Provide both flags:Command requires a running brv instance
Command requires a running brv instance
Cause: Running
brv query or brv curate without --headless flag when no REPL is running.Solution: Add the --headless flag to run independently:JSON output not appearing
JSON output not appearing
Cause: Errors are written to stderr, not stdout.Solution: Redirect both streams when capturing output:
Authentication fails in CI/CD
Authentication fails in CI/CD
Cause: Keychain unavailable, token expired, or incorrect API key.Solution:
- Verify the API key is correct and not expired
- Ensure the
BYTEROVER_API_KEYsecret is properly configured - Re-run
brv login --api-key $BYTEROVER_API_KEY - Check that the secret is not masked in a way that corrupts special characters
Permission denied for token storage
Permission denied for token storage
Cause: Cannot write to
~/.local/share/brv/ directory.Solution: Ensure the directory exists and is writable: