| 2583 | } |
| 2584 | |
| 2585 | cbm_detected_agents_t cbm_detect_agents(const char *home_dir) { |
| 2586 | cbm_detected_agents_t agents; |
| 2587 | memset(&agents, 0, sizeof(agents)); |
| 2588 | if (!home_dir || !home_dir[0]) { |
| 2589 | return agents; |
| 2590 | } |
| 2591 | |
| 2592 | char path[CLI_BUF_1K]; |
| 2593 | |
| 2594 | cbm_claude_config_dir(home_dir, path, sizeof(path)); |
| 2595 | agents.claude_code = path[0] != '\0' && dir_exists(path); |
| 2596 | |
| 2597 | cbm_codex_config_dir(home_dir, path, sizeof(path)); |
| 2598 | agents.codex = path[0] != '\0' && dir_exists(path); |
| 2599 | |
| 2600 | snprintf(path, sizeof(path), "%s/.gemini/antigravity-cli", home_dir); |
| 2601 | agents.antigravity = dir_exists(path) || cbm_agent_cli_exists("antigravity", home_dir); |
| 2602 | |
| 2603 | snprintf(path, sizeof(path), "%s/.gemini/settings.json", home_dir); |
| 2604 | agents.gemini = cbm_file_exists(path) || cbm_agent_cli_exists("gemini", home_dir); |
| 2605 | |
| 2606 | cbm_zed_config_dir(home_dir, path, sizeof(path)); |
| 2607 | agents.zed = dir_exists(path); |
| 2608 | |
| 2609 | cbm_opencode_config_path(home_dir, path, sizeof(path)); |
| 2610 | agents.opencode = cbm_file_exists(path) || cbm_agent_cli_exists("opencode", home_dir); |
| 2611 | if (!agents.opencode) { |
| 2612 | snprintf(path, sizeof(path), "%s/.config/opencode", home_dir); |
| 2613 | agents.opencode = dir_exists(path); |
| 2614 | } |
| 2615 | if (!agents.opencode) { |
| 2616 | char env_buf[CLI_BUF_1K]; |
| 2617 | const char *config_dir = |
| 2618 | cbm_safe_getenv("OPENCODE_CONFIG_DIR", env_buf, sizeof(env_buf), NULL); |
| 2619 | agents.opencode = config_dir && config_dir[0] && dir_exists(config_dir); |
| 2620 | } |
| 2621 | |
| 2622 | agents.aider = cbm_agent_cli_exists("aider", home_dir); |
| 2623 | |
| 2624 | #ifdef __APPLE__ |
| 2625 | snprintf(path, sizeof(path), |
| 2626 | "%s/Library/Application Support/Code/User/globalStorage/kilocode.kilo-code", home_dir); |
| 2627 | #elif defined(_WIN32) |
| 2628 | snprintf(path, sizeof(path), "%s/AppData/Roaming/Code/User/globalStorage/kilocode.kilo-code", |
| 2629 | home_dir); |
| 2630 | #else |
| 2631 | snprintf(path, sizeof(path), "%s/.config/Code/User/globalStorage/kilocode.kilo-code", home_dir); |
| 2632 | #endif |
| 2633 | agents.kilocode = dir_exists(path); |
| 2634 | snprintf(path, sizeof(path), "%s/.config/kilo", home_dir); |
| 2635 | agents.kilocode = agents.kilocode || dir_exists(path) || cbm_agent_cli_exists("kilo", home_dir); |
| 2636 | |
| 2637 | #ifdef __APPLE__ |
| 2638 | snprintf(path, sizeof(path), "%s/Library/Application Support/Code/User", home_dir); |
| 2639 | #elif defined(_WIN32) |
| 2640 | snprintf(path, sizeof(path), "%s/AppData/Roaming/Code/User", home_dir); |
| 2641 | #else |
| 2642 | snprintf(path, sizeof(path), "%s/.config/Code/User", home_dir); |
no test coverage detected