| 11984 | } |
| 11985 | |
| 11986 | static void uninstall_cli_agents(const cbm_detected_agents_t *agents, const char *home, |
| 11987 | bool dry_run) { |
| 11988 | if (agents->codex) { |
| 11989 | char config_dir[CLI_BUF_1K]; |
| 11990 | char cp[CLI_BUF_1K]; |
| 11991 | char ip[CLI_BUF_1K]; |
| 11992 | char skills_dir[CLI_BUF_1K]; |
| 11993 | char ap[CLI_BUF_1K]; |
| 11994 | char installed_binary[CLI_BUF_1K]; |
| 11995 | cbm_codex_config_dir(home, config_dir, sizeof(config_dir)); |
| 11996 | snprintf(cp, sizeof(cp), "%s/config.toml", config_dir); |
| 11997 | snprintf(ip, sizeof(ip), "%s/AGENTS.md", config_dir); |
| 11998 | snprintf(skills_dir, sizeof(skills_dir), "%s/skills", config_dir); |
| 11999 | snprintf(ap, sizeof(ap), "%s/agents/codebase-memory.toml", config_dir); |
| 12000 | bool pointer_removed = uninstall_codex_activation_pointer(ip, dry_run); |
| 12001 | cbm_agent_installed_binary_path(home, installed_binary, sizeof(installed_binary)); |
| 12002 | char hook_command[CLI_BUF_8K]; |
| 12003 | char hook_command_windows[CLI_BUF_8K]; |
| 12004 | bool hook_command_ok = cbm_build_augment_command(installed_binary, hook_command, |
| 12005 | sizeof(hook_command)) == CLI_OK; |
| 12006 | bool hook_commands_ok = hook_command_ok && cbm_build_augment_command_windows( |
| 12007 | installed_binary, hook_command_windows, |
| 12008 | sizeof(hook_command_windows)) == CLI_OK; |
| 12009 | cbm_toml_codex_hook_failure_t preflight_failure = CBM_TOML_CODEX_HOOK_FAILURE_NONE; |
| 12010 | bool hook_preflight_ok = |
| 12011 | hook_commands_ok && cbm_reconcile_codex_hooks_command_detailed( |
| 12012 | cp, hook_command, hook_command_windows, |
| 12013 | CBM_TOML_CODEX_HOOK_REMOVE, true, &preflight_failure) == CLI_OK; |
| 12014 | if (!hook_preflight_ok) { |
| 12015 | printf("Codex CLI:\n"); |
| 12016 | fflush(stdout); |
| 12017 | const char *reason = preflight_failure == CBM_TOML_CODEX_HOOK_FAILURE_NONE |
| 12018 | ? NULL |
| 12019 | : cbm_toml_codex_hook_failure_name(preflight_failure); |
| 12020 | record_agent_config_error_with_reason(true, "Codex CLI", "hook_preflight", cp, reason); |
| 12021 | report_codex_activation_pointer_uninstall(ip, pointer_removed); |
| 12022 | goto codex_toml_done; |
| 12023 | } |
| 12024 | uninstall_agent_mcp_instr((mcp_uninstall_args_t){"Codex CLI", cp, NULL}, dry_run, |
| 12025 | cbm_remove_codex_mcp_owned); |
| 12026 | report_codex_activation_pointer_uninstall(ip, pointer_removed); |
| 12027 | if (!dry_run && |
| 12028 | cbm_reconcile_codex_hooks_command(cp, hook_command, hook_command_windows, |
| 12029 | CBM_TOML_CODEX_HOOK_REMOVE, false) != CLI_OK) { |
| 12030 | record_agent_config_error(true, "Codex CLI", "hook_uninstall", cp); |
| 12031 | } |
| 12032 | codex_toml_done: |
| 12033 | uninstall_agent_skill("Codex CLI", skills_dir, dry_run); |
| 12034 | uninstall_tiered_agent_profiles( |
| 12035 | (cbm_tiered_profile_set_t){ |
| 12036 | .label = "Codex CLI", |
| 12037 | .verify_path = ap, |
| 12038 | .binary_path = installed_binary, |
| 12039 | .legacy_verify_content = legacy_codex_verify_agent_content, |
| 12040 | .dialect = CBM_GRAPH_DIALECT_CODEX, |
| 12041 | }, |
| 12042 | dry_run); |
| 12043 | if (!dry_run) { |
no test coverage detected