| 10907 | } |
| 10908 | |
| 10909 | static void uninstall_cli_agents(const cbm_detected_agents_t *agents, const char *home, |
| 10910 | bool dry_run) { |
| 10911 | if (agents->codex) { |
| 10912 | char config_dir[CLI_BUF_1K]; |
| 10913 | char cp[CLI_BUF_1K]; |
| 10914 | char ip[CLI_BUF_1K]; |
| 10915 | char skills_dir[CLI_BUF_1K]; |
| 10916 | char ap[CLI_BUF_1K]; |
| 10917 | char installed_binary[CLI_BUF_1K]; |
| 10918 | cbm_codex_config_dir(home, config_dir, sizeof(config_dir)); |
| 10919 | snprintf(cp, sizeof(cp), "%s/config.toml", config_dir); |
| 10920 | snprintf(ip, sizeof(ip), "%s/AGENTS.md", config_dir); |
| 10921 | snprintf(skills_dir, sizeof(skills_dir), "%s/skills", config_dir); |
| 10922 | snprintf(ap, sizeof(ap), "%s/agents/codebase-memory.toml", config_dir); |
| 10923 | cbm_agent_installed_binary_path(home, installed_binary, sizeof(installed_binary)); |
| 10924 | char hook_command[CLI_BUF_8K]; |
| 10925 | char hook_command_windows[CLI_BUF_8K]; |
| 10926 | bool hook_command_ok = cbm_build_augment_command(installed_binary, hook_command, |
| 10927 | sizeof(hook_command)) == CLI_OK; |
| 10928 | bool hook_commands_ok = hook_command_ok && cbm_build_augment_command_windows( |
| 10929 | installed_binary, hook_command_windows, |
| 10930 | sizeof(hook_command_windows)) == CLI_OK; |
| 10931 | cbm_toml_codex_hook_failure_t preflight_failure = CBM_TOML_CODEX_HOOK_FAILURE_NONE; |
| 10932 | bool hook_preflight_ok = |
| 10933 | hook_commands_ok && cbm_reconcile_codex_hooks_command_detailed( |
| 10934 | cp, hook_command, hook_command_windows, |
| 10935 | CBM_TOML_CODEX_HOOK_REMOVE, true, &preflight_failure) == CLI_OK; |
| 10936 | if (!hook_preflight_ok) { |
| 10937 | printf("Codex CLI:\n"); |
| 10938 | fflush(stdout); |
| 10939 | const char *reason = preflight_failure == CBM_TOML_CODEX_HOOK_FAILURE_NONE |
| 10940 | ? NULL |
| 10941 | : cbm_toml_codex_hook_failure_name(preflight_failure); |
| 10942 | record_agent_config_error_with_reason(true, "Codex CLI", "hook_preflight", cp, reason); |
| 10943 | goto codex_toml_done; |
| 10944 | } |
| 10945 | uninstall_agent_mcp_instr((mcp_uninstall_args_t){"Codex CLI", cp, ip}, dry_run, |
| 10946 | cbm_remove_codex_mcp_owned); |
| 10947 | if (!dry_run && |
| 10948 | cbm_reconcile_codex_hooks_command(cp, hook_command, hook_command_windows, |
| 10949 | CBM_TOML_CODEX_HOOK_REMOVE, false) != CLI_OK) { |
| 10950 | record_agent_config_error(true, "Codex CLI", "hook_uninstall", cp); |
| 10951 | } |
| 10952 | codex_toml_done: |
| 10953 | uninstall_agent_skill("Codex CLI", skills_dir, dry_run); |
| 10954 | uninstall_tiered_agent_profiles( |
| 10955 | (cbm_tiered_profile_set_t){ |
| 10956 | .label = "Codex CLI", |
| 10957 | .verify_path = ap, |
| 10958 | .binary_path = installed_binary, |
| 10959 | .legacy_verify_content = legacy_codex_verify_agent_content, |
| 10960 | .dialect = CBM_GRAPH_DIALECT_CODEX, |
| 10961 | }, |
| 10962 | dry_run); |
| 10963 | if (!dry_run) { |
| 10964 | char hooks_json[CLI_BUF_1K]; |
| 10965 | snprintf(hooks_json, sizeof(hooks_json), "%s/hooks.json", config_dir); |
| 10966 | if (cbm_file_exists(hooks_json) && |
no test coverage detected