Skip to content

Commit 88ffd32

Browse files
authored
Detect GitHub Copilot CLI via AI_AGENT and COPILOT_AGENT_SESSION_ID (#960)
1 parent 7ed782b commit 88ffd32

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎src/DiffEngine/AiCliDetector.cs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ static AiCliDetector()
88

99
// GitHub Copilot
1010
// https://docs.github.com/en/copilot/using-github-copilot/using-github-copilot-in-the-command-line
11-
IsCopilot = variables.Contains("GITHUB_COPILOT_RUNTIME");
11+
// Copilot CLI sets AI_AGENT=github-copilot / github-copilot-cli, VS Code agent mode sets github_copilot_vscode_agent
12+
var aiAgent = Environment.GetEnvironmentVariable("AI_AGENT");
13+
IsCopilot = variables.Contains("GITHUB_COPILOT_RUNTIME") ||
14+
variables.Contains("COPILOT_AGENT_SESSION_ID") ||
15+
(aiAgent != null && aiAgent.StartsWith("github", StringComparison.OrdinalIgnoreCase));
1216

1317
// Aider
1418
// https://aider.chat/docs/config/dotenv.html

0 commit comments

Comments
 (0)