Expand description
AI coding agent detection for agent-specific profiles.
This module detects which AI coding agent is invoking dcg, enabling per-agent trust levels and configuration overrides.
§Detection Methods
- Environment variables (primary): Most agents set identifying env vars
- Explicit flag:
--agent=<name>CLI flag for manual override - Parent process inspection (fallback): Check process tree for agent names
§Supported Agents
- Claude Code:
CLAUDE_CODE=1orCLAUDE_SESSION_IDenv var - Augment Code:
AUGMENT_AGENT=1orAUGMENT_CONVERSATION_IDenv var - Aider:
AIDER_SESSION=1env var - Continue:
CONTINUE_SESSION_IDenv var - Codex CLI:
CODEX_CLI=1env var - Gemini CLI:
GEMINI_CLI=1env var - Copilot CLI:
COPILOT_CLI=1orCOPILOT_AGENT_START_TIME_SECenv var
§Usage
ⓘ
use destructive_command_guard::agent::{Agent, detect_agent};
let agent = detect_agent();
println!("Detected agent: {}", agent);Structs§
- Detection
Result - Result of agent detection with metadata.
Enums§
- Agent
- Known AI coding agents that dcg can detect and configure per-agent policies for.
- Detection
Method - How an agent was detected.
Functions§
- clear_
cache - Clear the agent detection cache.
- detect_
agent - Detect the current AI coding agent, using cache if available.
- detect_
agent_ with_ details - Detect the current AI coding agent with full details.
- from_
explicit - Create a detection result from an explicit agent name.