| 2541 | } |
| 2542 | |
| 2543 | cbm_detected_agents_t cbm_detect_agents(const char *home_dir) { |
| 2544 | cbm_detected_agents_t agents; |
| 2545 | memset(&agents, 0, sizeof(agents)); |
| 2546 | if (!home_dir || !home_dir[0]) { |
| 2547 | return agents; |
| 2548 | } |
| 2549 | |
| 2550 | char path[CLI_BUF_1K]; |
| 2551 | |
| 2552 | cbm_claude_config_dir(home_dir, path, sizeof(path)); |
| 2553 | agents.claude_code = path[0] != '\0' && dir_exists(path); |
| 2554 | |
| 2555 | cbm_codex_config_dir(home_dir, path, sizeof(path)); |
| 2556 | agents.codex = path[0] != '\0' && dir_exists(path); |
| 2557 | |
| 2558 | snprintf(path, sizeof(path), "%s/.gemini/antigravity-cli", home_dir); |
| 2559 | agents.antigravity = dir_exists(path) || cbm_agent_cli_exists("antigravity", home_dir); |
| 2560 | |
| 2561 | snprintf(path, sizeof(path), "%s/.gemini/settings.json", home_dir); |
| 2562 | agents.gemini = cbm_file_exists(path) || cbm_agent_cli_exists("gemini", home_dir); |
| 2563 | |
| 2564 | cbm_zed_config_dir(home_dir, path, sizeof(path)); |
| 2565 | agents.zed = dir_exists(path); |
| 2566 | |
| 2567 | cbm_opencode_config_path(home_dir, path, sizeof(path)); |
| 2568 | agents.opencode = cbm_file_exists(path) || cbm_agent_cli_exists("opencode", home_dir); |
| 2569 | if (!agents.opencode) { |
| 2570 | snprintf(path, sizeof(path), "%s/.config/opencode", home_dir); |
| 2571 | agents.opencode = dir_exists(path); |
| 2572 | } |
| 2573 | if (!agents.opencode) { |
| 2574 | char env_buf[CLI_BUF_1K]; |
| 2575 | const char *config_dir = |
| 2576 | cbm_safe_getenv("OPENCODE_CONFIG_DIR", env_buf, sizeof(env_buf), NULL); |
| 2577 | agents.opencode = config_dir && config_dir[0] && dir_exists(config_dir); |
| 2578 | } |
| 2579 | |
| 2580 | agents.aider = cbm_agent_cli_exists("aider", home_dir); |
| 2581 | |
| 2582 | #ifdef __APPLE__ |
| 2583 | snprintf(path, sizeof(path), |
| 2584 | "%s/Library/Application Support/Code/User/globalStorage/kilocode.kilo-code", home_dir); |
| 2585 | #elif defined(_WIN32) |
| 2586 | snprintf(path, sizeof(path), "%s/AppData/Roaming/Code/User/globalStorage/kilocode.kilo-code", |
| 2587 | home_dir); |
| 2588 | #else |
| 2589 | snprintf(path, sizeof(path), "%s/.config/Code/User/globalStorage/kilocode.kilo-code", home_dir); |
| 2590 | #endif |
| 2591 | agents.kilocode = dir_exists(path); |
| 2592 | snprintf(path, sizeof(path), "%s/.config/kilo", home_dir); |
| 2593 | agents.kilocode = agents.kilocode || dir_exists(path) || cbm_agent_cli_exists("kilo", home_dir); |
| 2594 | |
| 2595 | #ifdef __APPLE__ |
| 2596 | snprintf(path, sizeof(path), "%s/Library/Application Support/Code/User", home_dir); |
| 2597 | #elif defined(_WIN32) |
| 2598 | snprintf(path, sizeof(path), "%s/AppData/Roaming/Code/User", home_dir); |
| 2599 | #else |
| 2600 | snprintf(path, sizeof(path), "%s/.config/Code/User", home_dir); |
no test coverage detected