nx icon indicating copy to clipboard operation
nx copied to clipboard

feat(core): detect VS Code Copilot as AI agent

Open Stanzilla opened this issue 1 week ago โ€ข 3 comments

Current Behavior

When running Nx commands from VS Code Copilot's chat panel, Nx does not detect that it's running inside an AI agent. This means the TUI is enabled, which doesn't work well with AI agents that expect plain text output.

Expected Behavior

Nx should detect when it's running from VS Code Copilot's chat panel and disable the TUI accordingly, similar to how it handles Claude Code, Cursor, and Repl.it.

Related Issue(s)

Fixes #33698

Implementation

Added detection for VS Code Copilot by checking if the PATH environment variable contains github.copilot-chat. When VS Code Copilot runs terminal commands, it adds its CLI tool path (e.g., .../globalStorage/github.copilot-chat/copilotCli) to the PATH.

Changes:

  • Added is_vscode_copilot() function to detect VS Code Copilot
  • Added is_vscode_copilot_from_path() helper for testability
  • Updated is_ai_agent() to include VS Code Copilot detection
  • Added unit tests for the new detection logic

Stanzilla avatar Dec 08 '25 22:12 Stanzilla

Deploy request for nx-docs pending review.

Visit the deploys page to approve it

Name Link
Latest commit 9e837192e96d738c17523ea8548727f3df584592

netlify[bot] avatar Dec 08 '25 22:12 netlify[bot]

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
nx-dev Ready Ready Preview Dec 9, 2025 11:23am

vercel[bot] avatar Dec 08 '25 22:12 vercel[bot]

View your CI Pipeline Execution โ†— for commit cbbcf4fad2ad7529377e20d4bc0a7424c012fb1e

Command Status Duration Result
nx affected --targets=lint,test,test-kt,build,e... โŒ Failed 1h 39m 57s View โ†—
nx run-many -t check-imports check-lock-files c... โœ… Succeeded 2m 37s View โ†—
nx-cloud record -- nx-cloud conformance:check โœ… Succeeded 12s View โ†—
nx-cloud record -- nx format:check โœ… Succeeded <1s View โ†—
nx-cloud record -- nx sync:check โœ… Succeeded <1s View โ†—

โ˜๏ธ Nx Cloud last updated this comment at 2025-12-09 11:16:50 UTC

nx-cloud[bot] avatar Dec 09 '25 03:12 nx-cloud[bot]

Thanks for catching that @MaxKless! You're right - I just verified and the github.copilot-chat path is present in the regular VS Code terminal as well, not just in Copilot agent mode.

I've checked the environment more thoroughly, and unfortunately there doesn't appear to be a unique environment variable that distinguishes Copilot agent mode from regular VS Code terminal usage:

  • GIT_PAGER=cat is set, but this might also be common in regular VS Code
  • No COPILOT_* or similar specific env vars are set
  • TTY status is the same in both cases (stdin/stdout/stderr all report as terminals)
  • Parent process is the same VS Code helper

Do you have any suggestions for how we might detect Copilot agent mode specifically? Some possibilities:

  1. Is there perhaps a VS Code extension API that could set a specific env var when running from agent mode?
  2. Could Copilot itself set something like GITHUB_COPILOT_AGENT=1 when invoking terminal commands?
  3. Should we file an issue with the Copilot team to request an environment variable for this use case?

Alternatively, would it make sense to approach this from a different angle - perhaps detecting that the terminal is not truly interactive in some way, even if it reports as a TTY?

Stanzilla avatar Dec 12 '25 14:12 Stanzilla