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

Function install_cli_agent_configs

src/cli/cli.c:8275–8439  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8273}
8274
8275static void install_cli_agent_configs(const cbm_detected_agents_t *agents, const char *home,
8276 const char *binary_path, bool force, bool dry_run) {
8277 if (agents->codex) {
8278 char config_dir[CLI_BUF_1K];
8279 char cp[CLI_BUF_1K];
8280 char ip[CLI_BUF_1K];
8281 char skills_dir[CLI_BUF_1K];
8282 char ap[CLI_BUF_1K];
8283 cbm_codex_config_dir(home, config_dir, sizeof(config_dir));
8284 snprintf(cp, sizeof(cp), "%s/config.toml", config_dir);
8285 snprintf(ip, sizeof(ip), "%s/AGENTS.md", config_dir);
8286 snprintf(skills_dir, sizeof(skills_dir), "%s/skills", config_dir);
8287 snprintf(ap, sizeof(ap), "%s/agents/codebase-memory.toml", config_dir);
8288 install_generic_agent_config("Codex CLI", binary_path, cp, ip, dry_run,
8289 cbm_upsert_codex_mcp);
8290 install_agent_skill("Codex CLI", skills_dir, force, dry_run);
8291 install_tiered_agent_profiles(
8292 (cbm_tiered_profile_set_t){
8293 .label = "Codex CLI",
8294 .verify_path = ap,
8295 .binary_path = binary_path,
8296 .legacy_verify_content = legacy_codex_verify_agent_content,
8297 .dialect = CBM_GRAPH_DIALECT_CODEX,
8298 },
8299 dry_run);
8300 /* Choose the hook target: if ~/.codex/hooks.json already exists, the
8301 * user manages Codex hooks via the JSON representation — write the
8302 * SessionStart reminder there instead of config.toml. Writing both
8303 * makes Codex warn about loading hooks from two representations (#570).
8304 * config.toml remains the mcp_config target above either way. */
8305 char hooks_json[CLI_BUF_1K];
8306 snprintf(hooks_json, sizeof(hooks_json), "%s/hooks.json", config_dir);
8307 bool use_hooks_json = cbm_file_exists(hooks_json);
8308 const char *hook_target = use_hooks_json ? hooks_json : cp;
8309 if (g_install_plan) {
8310 plan_record("Codex CLI", "hook", hook_target);
8311 } else {
8312 bool hook_ok = true;
8313 if (!dry_run) {
8314 char command[CLI_BUF_8K];
8315 char command_windows[CLI_BUF_8K];
8316 if (cbm_build_augment_command(binary_path, command, sizeof(command)) == CLI_OK &&
8317 cbm_build_augment_command_windows(binary_path, command_windows,
8318 sizeof(command_windows)) == CLI_OK) {
8319 if (use_hooks_json) {
8320 if (cbm_upsert_paired_lifecycle_hooks_json(
8321 hooks_json, command, command_windows, NULL, CMM_HOOK_TIMEOUT_SEC) ==
8322 CLI_OK) {
8323 if (cbm_remove_codex_hooks(cp) != CLI_OK) {
8324 hook_ok = false;
8325 record_agent_config_error(false, "Codex CLI", "legacy_hook_cleanup",
8326 cp);
8327 }
8328 } else {
8329 hook_ok = false;
8330 record_agent_config_error(false, "Codex CLI", "hook_install",
8331 hooks_json);
8332 }

Callers 1

Calls 15

cbm_codex_config_dirFunction · 0.85
install_agent_skillFunction · 0.85
cbm_file_existsFunction · 0.85
plan_recordFunction · 0.85
cbm_remove_codex_hooksFunction · 0.85

Tested by

no test coverage detected