Skip to main content

Module detect

Module detect 

Source
Expand description

AI CLI detection.

Scans PATH for known AI coding CLI binaries and merges with custom CLIs from the user’s configuration. Provides the combined list for interactive selection or direct use.

§Thread-Safe Architecture

This module uses a thread-safe approach for PATH-based command resolution:

  1. No Global Environment Mutation: Unlike the previous implementation that used unsafe { std::env::set_var("PATH", ...) }, this version never modifies the global environment.

  2. Process-Isolated PATH: The resolve_command_in function and related internal functions use std::process::Command::env() to set PATH only for individual process executions. This ensures thread safety and allows true parallel test execution.

  3. Test Parallelization: All tests can run in parallel without #[serial_test::serial] attributes because there’s no shared mutable state.

  4. Robust PATH Construction: When testing with custom PATH directories, the implementation automatically includes system paths (/usr/bin:/bin:/usr/local/bin) to ensure the which command itself can be found.

Structs§

CliInfo
Information about an available AI CLI.
CustomCliDef
A custom CLI definition provided by the user’s configuration.

Enums§

CliSource
How a CLI was discovered.

Functions§

detect_clis
Detects all available AI CLIs by combining auto-detected and custom CLIs.
detect_known_clis
Scans PATH for known AI CLI binaries.
resolve_custom_clis
Resolves custom CLI definitions to CliInfo entries.