Skip to content

Use github.com/vercel/detect-agent package for AI agent detection - #1802

Draft
matv-stripe wants to merge 1 commit into
masterfrom
matv/usegopackage
Draft

Use github.com/vercel/detect-agent package for AI agent detection#1802
matv-stripe wants to merge 1 commit into
masterfrom
matv/usegopackage

Conversation

@matv-stripe

Copy link
Copy Markdown
Contributor

Replaces manual env-var checks in DetectAIAgent with the vercel/detect-agent package, which centralizes agent detection logic and supports more agents (cowork, augment-cli, goose, junie, replit, github-copilot, kiro, devin) and the CLAUDE_CODE env var alias.

Agent name changes to match the package's canonical names:

  • "claude_code" → "claude"
  • "codex_cli" → "codex"
  • "gemini_cli" → "gemini"
  • "open_code" → "opencode"
  • CURSOR_AGENT now maps to "cursor-cli"; "cursor" uses CURSOR_TRACE_ID

Removes the getEnv parameter from DetectAIAgent, shouldAutoLogin, and writeClaudeCodePluginHint since the package reads os.Getenv directly. Tests updated to use t.Setenv() instead of mock env getters.

Committed-By-Agent: claude

Reviewers

r? @
cc @stripe/developer-products

Summary

Replaces manual env-var checks in DetectAIAgent with the
vercel/detect-agent package, which centralizes agent detection logic
and supports more agents (cowork, augment-cli, goose, junie, replit,
github-copilot, kiro, devin) and the CLAUDE_CODE env var alias.

Agent name changes to match the package's canonical names:
- "claude_code" → "claude"
- "codex_cli"   → "codex"
- "gemini_cli"  → "gemini"
- "open_code"   → "opencode"
- CURSOR_AGENT now maps to "cursor-cli"; "cursor" uses CURSOR_TRACE_ID

Removes the getEnv parameter from DetectAIAgent, shouldAutoLogin, and
writeClaudeCodePluginHint since the package reads os.Getenv directly.
Tests updated to use t.Setenv() instead of mock env getters.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
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.

1 participant