MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / install_cli_agent_configs

Function install_cli_agent_configs

src/cli/cli.c:8486–8643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8484}
8485
8486static void install_cli_agent_configs(const cbm_detected_agents_t *agents, const char *home,
8487 const char *binary_path, bool force, bool dry_run) {
8488 if (agents->codex) {
8489 char config_dir[CLI_BUF_1K];
8490 char cp[CLI_BUF_1K];
8491 char ip[CLI_BUF_1K];
8492 char skills_dir[CLI_BUF_1K];
8493 char ap[CLI_BUF_1K];
8494 cbm_codex_config_dir(home, config_dir, sizeof(config_dir));
8495 snprintf(cp, sizeof(cp), "%s/config.toml", config_dir);
8496 snprintf(ip, sizeof(ip), "%s/AGENTS.md", config_dir);
8497 snprintf(skills_dir, sizeof(skills_dir), "%s/skills", config_dir);
8498 snprintf(ap, sizeof(ap), "%s/agents/codebase-memory.toml", config_dir);
8499 char command[CLI_BUF_8K];
8500 char command_windows[CLI_BUF_8K];
8501 char hooks_json[CLI_BUF_1K];
8502 snprintf(hooks_json, sizeof(hooks_json), "%s/hooks.json", config_dir);
8503 bool use_hooks_json = cbm_file_exists(hooks_json);
8504 bool commands_ok =
8505 cbm_build_augment_command(binary_path, command, sizeof(command)) == CLI_OK &&
8506 cbm_build_augment_command_windows(binary_path, command_windows,
8507 sizeof(command_windows)) == CLI_OK;
8508 cbm_toml_codex_hook_action_t preflight_action =
8509 use_hooks_json ? CBM_TOML_CODEX_HOOK_REMOVE : CBM_TOML_CODEX_HOOK_UPSERT;
8510 if (!commands_ok || cbm_reconcile_codex_hooks_command(cp, command, command_windows,
8511 preflight_action, true) != CLI_OK) {
8512 record_agent_config_error(false, "Codex CLI",
8513 commands_ok ? "hook_preflight" : "hook_command_build", cp);
8514 goto codex_install_done;
8515 }
8516 install_generic_agent_config("Codex CLI", binary_path, cp, ip, dry_run,
8517 cbm_upsert_codex_mcp);
8518 install_agent_skill("Codex CLI", skills_dir, force, dry_run);
8519 install_tiered_agent_profiles(
8520 (cbm_tiered_profile_set_t){
8521 .label = "Codex CLI",
8522 .verify_path = ap,
8523 .binary_path = binary_path,
8524 .legacy_verify_content = legacy_codex_verify_agent_content,
8525 .dialect = CBM_GRAPH_DIALECT_CODEX,
8526 },
8527 dry_run);
8528 /* Choose the hook target: if ~/.codex/hooks.json already exists, the
8529 * user manages Codex hooks via the JSON representation — write the
8530 * SessionStart reminder there instead of config.toml. Writing both
8531 * makes Codex warn about loading hooks from two representations (#570).
8532 * config.toml remains the mcp_config target above either way. */
8533 const char *hook_target = use_hooks_json ? hooks_json : cp;
8534 if (g_install_plan) {
8535 plan_record("Codex CLI", "hook", hook_target);
8536 } else {
8537 bool hook_ok = true;
8538 if (!dry_run && use_hooks_json) {
8539 hook_ok =
8540 cbm_upsert_paired_lifecycle_hooks_json(hooks_json, command, command_windows,
8541 NULL, CMM_HOOK_TIMEOUT_SEC) == CLI_OK &&
8542 cbm_reconcile_codex_hooks_command(cp, command, command_windows,
8543 CBM_TOML_CODEX_HOOK_REMOVE, false) == CLI_OK;

Callers 1

Tested by

no test coverage detected