Skip to main content

detect_with_env

Function detect_with_env 

Source
pub fn detect_with_env(env: HashMap<String, String>) -> Option<DetectedAgent>
Expand description

Detect the AI coding agent using a caller-supplied environment map.

This is the testable variant of detect. Pass a HashMap<String, String> built from whichever key/value pairs you want to simulate.

ยงExample

use std::collections::HashMap;

let mut env = HashMap::new();
env.insert("CODEX_THREAD_ID".to_string(), "thread-42".to_string());

let agent = detect_coding_agent::detect_with_env(env).unwrap();
assert_eq!(agent.id, "codex");