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

Function install_cli_agent_configs

src/cli/cli.c:8231–8395  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8229}
8230
8231static void install_cli_agent_configs(const cbm_detected_agents_t *agents, const char *home,
8232 const char *binary_path, bool force, bool dry_run) {
8233 if (agents->codex) {
8234 char config_dir[CLI_BUF_1K];
8235 char cp[CLI_BUF_1K];
8236 char ip[CLI_BUF_1K];
8237 char skills_dir[CLI_BUF_1K];
8238 char ap[CLI_BUF_1K];
8239 cbm_codex_config_dir(home, config_dir, sizeof(config_dir));
8240 snprintf(cp, sizeof(cp), "%s/config.toml", config_dir);
8241 snprintf(ip, sizeof(ip), "%s/AGENTS.md", config_dir);
8242 snprintf(skills_dir, sizeof(skills_dir), "%s/skills", config_dir);
8243 snprintf(ap, sizeof(ap), "%s/agents/codebase-memory.toml", config_dir);
8244 install_generic_agent_config("Codex CLI", binary_path, cp, ip, dry_run,
8245 cbm_upsert_codex_mcp);
8246 install_agent_skill("Codex CLI", skills_dir, force, dry_run);
8247 install_tiered_agent_profiles(
8248 (cbm_tiered_profile_set_t){
8249 .label = "Codex CLI",
8250 .verify_path = ap,
8251 .binary_path = binary_path,
8252 .legacy_verify_content = legacy_codex_verify_agent_content,
8253 .dialect = CBM_GRAPH_DIALECT_CODEX,
8254 },
8255 dry_run);
8256 /* Choose the hook target: if ~/.codex/hooks.json already exists, the
8257 * user manages Codex hooks via the JSON representation — write the
8258 * SessionStart reminder there instead of config.toml. Writing both
8259 * makes Codex warn about loading hooks from two representations (#570).
8260 * config.toml remains the mcp_config target above either way. */
8261 char hooks_json[CLI_BUF_1K];
8262 snprintf(hooks_json, sizeof(hooks_json), "%s/hooks.json", config_dir);
8263 bool use_hooks_json = cbm_file_exists(hooks_json);
8264 const char *hook_target = use_hooks_json ? hooks_json : cp;
8265 if (g_install_plan) {
8266 plan_record("Codex CLI", "hook", hook_target);
8267 } else {
8268 bool hook_ok = true;
8269 if (!dry_run) {
8270 char command[CLI_BUF_8K];
8271 char command_windows[CLI_BUF_8K];
8272 if (cbm_build_augment_command(binary_path, command, sizeof(command)) == CLI_OK &&
8273 cbm_build_augment_command_windows(binary_path, command_windows,
8274 sizeof(command_windows)) == CLI_OK) {
8275 if (use_hooks_json) {
8276 if (cbm_upsert_paired_lifecycle_hooks_json(
8277 hooks_json, command, command_windows, NULL, CMM_HOOK_TIMEOUT_SEC) ==
8278 CLI_OK) {
8279 if (cbm_remove_codex_hooks(cp) != CLI_OK) {
8280 hook_ok = false;
8281 record_agent_config_error(false, "Codex CLI", "legacy_hook_cleanup",
8282 cp);
8283 }
8284 } else {
8285 hook_ok = false;
8286 record_agent_config_error(false, "Codex CLI", "hook_install",
8287 hooks_json);
8288 }

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