| 9717 | } |
| 9718 | |
| 9719 | static void install_cli_agent_configs(const cbm_detected_agents_t *agents, const char *home, |
| 9720 | const char *binary_path, bool force, bool dry_run) { |
| 9721 | if (agents->codex) { |
| 9722 | char config_dir[CLI_BUF_1K]; |
| 9723 | char cp[CLI_BUF_1K]; |
| 9724 | char ip[CLI_BUF_1K]; |
| 9725 | char skills_dir[CLI_BUF_1K]; |
| 9726 | char ap[CLI_BUF_1K]; |
| 9727 | cbm_codex_config_dir(home, config_dir, sizeof(config_dir)); |
| 9728 | snprintf(cp, sizeof(cp), "%s/config.toml", config_dir); |
| 9729 | snprintf(ip, sizeof(ip), "%s/AGENTS.md", config_dir); |
| 9730 | snprintf(skills_dir, sizeof(skills_dir), "%s/skills", config_dir); |
| 9731 | snprintf(ap, sizeof(ap), "%s/agents/codebase-memory.toml", config_dir); |
| 9732 | /* A broken hook config must not keep legacy full guidance active. */ |
| 9733 | bool pointer_installed = install_codex_activation_pointer(ip, dry_run); |
| 9734 | char command[CLI_BUF_8K]; |
| 9735 | char command_windows[CLI_BUF_8K]; |
| 9736 | char hooks_json[CLI_BUF_1K]; |
| 9737 | snprintf(hooks_json, sizeof(hooks_json), "%s/hooks.json", config_dir); |
| 9738 | bool use_hooks_json = cbm_file_exists(hooks_json); |
| 9739 | bool commands_ok = |
| 9740 | cbm_build_augment_command(binary_path, command, sizeof(command)) == CLI_OK && |
| 9741 | cbm_build_augment_command_windows(binary_path, command_windows, |
| 9742 | sizeof(command_windows)) == CLI_OK; |
| 9743 | cbm_toml_codex_hook_action_t preflight_action = |
| 9744 | use_hooks_json ? CBM_TOML_CODEX_HOOK_REMOVE : CBM_TOML_CODEX_HOOK_UPSERT; |
| 9745 | cbm_toml_codex_hook_failure_t preflight_failure = CBM_TOML_CODEX_HOOK_FAILURE_NONE; |
| 9746 | int preflight_result = commands_ok ? cbm_reconcile_codex_hooks_command_detailed( |
| 9747 | cp, command, command_windows, preflight_action, |
| 9748 | true, &preflight_failure) |
| 9749 | : CLI_ERR; |
| 9750 | if (preflight_result != CLI_OK) { |
| 9751 | if (!g_install_plan) { |
| 9752 | printf("Codex CLI:\n"); |
| 9753 | fflush(stdout); |
| 9754 | } |
| 9755 | const char *reason = preflight_failure == CBM_TOML_CODEX_HOOK_FAILURE_NONE |
| 9756 | ? NULL |
| 9757 | : cbm_toml_codex_hook_failure_name(preflight_failure); |
| 9758 | record_agent_config_error_with_reason( |
| 9759 | false, "Codex CLI", commands_ok ? "hook_preflight" : "hook_command_build", cp, |
| 9760 | reason); |
| 9761 | if (!g_install_plan) { |
| 9762 | report_codex_activation_pointer_install(ip, pointer_installed); |
| 9763 | } |
| 9764 | goto codex_install_done; |
| 9765 | } |
| 9766 | install_generic_agent_config("Codex CLI", binary_path, cp, NULL, dry_run, |
| 9767 | cbm_upsert_codex_mcp); |
| 9768 | if (!g_install_plan) { |
| 9769 | report_codex_activation_pointer_install(ip, pointer_installed); |
| 9770 | } |
| 9771 | install_agent_skill("Codex CLI", skills_dir, force, dry_run); |
| 9772 | install_tiered_agent_profiles( |
| 9773 | (cbm_tiered_profile_set_t){ |
| 9774 | .label = "Codex CLI", |
| 9775 | .verify_path = ap, |
| 9776 | .binary_path = binary_path, |
no test coverage detected