Skip to content

feat(cli): expand AI agent detection#1261

Merged
MichaelHogers merged 2 commits intomainfrom
herve/expand-agent-detection
Mar 17, 2026
Merged

feat(cli): expand AI agent detection#1261
MichaelHogers merged 2 commits intomainfrom
herve/expand-agent-detection

Conversation

@MichaelHogers
Copy link
Contributor

@MichaelHogers MichaelHogers commented Mar 17, 2026

Summary

Expands operator detection to cover AI coding agents we were missing compared to similar CLIs

  • ClineCLINE_ACTIVE
  • Codex CLICODEX_SANDBOX, CODEX_THREAD_ID
  • Gemini CLIGEMINI_CLI
  • OpenCodeOPENCODE
  • Cursor — adds CURSOR_AGENT as fallback alongside existing CURSOR_TRACE_ID

All new operators map to agent CLI mode, so they get the same non-interactive confirmation flow as existing agents.

Before / After

Agent Before After
Cline not detected CLINE_ACTIVE
Codex CLI not detected CODEX_SANDBOX / CODEX_THREAD_ID
Gemini CLI not detected GEMINI_CLI
OpenCode not detected OPENCODE
Cursor CURSOR_TRACE_ID only CURSOR_TRACE_ID or CURSOR_AGENT

Context

Compared our detection with other CLIs. Other CLIs covered 7 agents; we covered 5. This PR closes the gap and adds a second env var for Cursor (Stripe uses CURSOR_AGENT, we used CURSOR_TRACE_ID — now we check both).

Test plan

  • All 38 unit tests pass (cli-mode.spec.ts)
  • Verify env vars are correct by testing inside each agent (or checking their docs)

…i CLI, and OpenCode

Add detection for four new AI coding agents that were missing compared
to similar tooling (e.g. Stripe CLI). Also add CURSOR_AGENT as a
fallback env var for Cursor detection alongside the existing
CURSOR_TRACE_ID.

New operators and their env vars:
- Cline: CLINE_ACTIVE
- Codex CLI: CODEX_SANDBOX, CODEX_THREAD_ID
- Gemini CLI: GEMINI_CLI
- OpenCode: OPENCODE
- Cursor (additional): CURSOR_AGENT
Cline (and potentially other future agents) are VS Code extensions,
so TERM_PROGRAM=vscode is always set when they're active. The previous
ordering would misclassify Cline as 'vscode' (interactive) instead of
'cline' (agent). Moving the VS Code check after all agent-specific
checks ensures extensions are correctly detected as agents.
@MichaelHogers MichaelHogers merged commit ee5b472 into main Mar 17, 2026
4 checks passed
@MichaelHogers MichaelHogers deleted the herve/expand-agent-detection branch March 17, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants